import type {
  ApplicationTask,
  AppSettings,
  Job,
  PipelineRun,
  ResumeProjectCatalogItem,
  StageEvent,
} from "../types";

export const createJob = (overrides: Partial<Job> = {}): Job => ({
  id: "job-1",
  source: "linkedin",
  sourceJobId: null,
  jobUrlDirect: null,
  datePosted: null,
  title: "Backend Engineer",
  employer: "Acme Labs",
  employerUrl: null,
  jobUrl: "https://example.com/job-1",
  applicationLink: "https://example.com/apply",
  disciplines: null,
  deadline: null,
  salary: null,
  location: "California",
  degreeRequired: null,
  starting: null,
  jobDescription: "Job description content",
  status: "ready",
  outcome: null,
  closedAt: null,
  suitabilityScore: 90,
  suitabilityReason: "Strong fit",
  suitabilityAnalysis: null,
  coverLetter: null,
  tailoredSummary: null,
  tailoredHeadline: null,
  tailoredSkills: null,
  selectedProjectIds: null,
  pdfPath: null,
  tracerLinksEnabled: false,
  sponsorMatchScore: null,
  sponsorMatchNames: null,
  sponsorshipSignals: null,
  notes: null,
  jobType: null,
  salarySource: null,
  salaryInterval: null,
  salaryMinAmount: null,
  salaryMaxAmount: null,
  salaryCurrency: null,
  isRemote: null,
  jobLevel: null,
  jobFunction: null,
  listingType: null,
  emails: null,
  companyIndustry: null,
  companyLogo: null,
  companyUrlDirect: null,
  companyAddresses: null,
  companyNumEmployees: null,
  companyRevenue: null,
  companyDescription: null,
  skills: null,
  experienceRange: null,
  companyRating: null,
  companyReviewsCount: null,
  vacancyCount: null,
  workFromHomeType: null,
  discoveredAt: "2025-01-01T00:00:00Z",
  processedAt: null,
  appliedAt: null,
  createdAt: "2025-01-01T00:00:00Z",
  updatedAt: "2025-01-01T00:00:00Z",
  ownerProfileId: "__default__",
  ...overrides,
});

export const createStageEvent = (
  overrides: Partial<StageEvent> = {},
): StageEvent => ({
  id: "event-1",
  applicationId: "job-1",
  title: "Moved to applied",
  groupId: null,
  fromStage: null,
  toStage: "applied",
  occurredAt: Date.now(),
  metadata: null,
  outcome: null,
  ...overrides,
});

export const createApplicationTask = (
  overrides: Partial<ApplicationTask> = {},
): ApplicationTask => ({
  id: "task-1",
  applicationId: "job-1",
  type: "todo",
  title: "Follow up",
  dueDate: null,
  isCompleted: false,
  notes: null,
  ...overrides,
});

export const createPipelineRun = (
  overrides: Partial<PipelineRun> = {},
): PipelineRun => ({
  id: "run-1",
  startedAt: "2025-01-01T00:00:00Z",
  completedAt: null,
  status: "running",
  jobsDiscovered: 0,
  jobsProcessed: 0,
  errorMessage: null,
  ...overrides,
});

export const createResumeProjectCatalogItem = (
  overrides: Partial<ResumeProjectCatalogItem> = {},
): ResumeProjectCatalogItem => ({
  id: "p1",
  name: "Project 1",
  description: "Description 1",
  date: "2024",
  isVisibleInBase: true,
  ...overrides,
});

export const createAppSettings = (
  overrides: Partial<AppSettings> = {},
): AppSettings => ({
  jobSearchProfile: {
    value: {
      targetRoles: [],
      experienceLevel: "",
      mustHaveSkills: [],
      niceToHaveSkills: [],
      dealBreakers: [],
      preferredWorkArrangement: [],
      preferredLocations: [],
      minimumSalary: "",
      industriesToTarget: [],
      industriesToAvoid: [],
      aboutMe: "",
    },
    default: {
      targetRoles: [],
      experienceLevel: "",
      mustHaveSkills: [],
      niceToHaveSkills: [],
      dealBreakers: [],
      preferredWorkArrangement: [],
      preferredLocations: [],
      minimumSalary: "",
      industriesToTarget: [],
      industriesToAvoid: [],
      aboutMe: "",
    },
    override: null,
  },
  model: { value: "gpt-4o", default: "gpt-4o", override: null },
  modelScorer: { value: "gpt-4o", override: null },
  modelTailoring: { value: "gpt-4o", override: null },
  modelProjectSelection: { value: "gpt-4o", override: null },
  llmProvider: { value: "openai", default: "openai", override: null },
  llmBaseUrl: {
    value: "https://api.openai.com/v1",
    default: "https://api.openai.com/v1",
    override: null,
  },
  pipelineWebhookUrl: { value: "", default: "", override: null },
  jobCompleteWebhookUrl: { value: "", default: "", override: null },
  profileProjects: [],
  resumeProjects: {
    value: { maxProjects: 3, lockedProjectIds: [], aiSelectableProjectIds: [] },
    default: {
      maxProjects: 3,
      lockedProjectIds: [],
      aiSelectableProjectIds: [],
    },
    override: null,
  },
  activeProfileId: null,
  basicAuthActiveProfileByUser: null,
  rxresumeBaseResumeId: null,
  rxresumeBaseResumeIdV4: null,
  rxresumeBaseResumeIdV5: null,
  ukvisajobsMaxJobs: { value: 50, default: 50, override: null },
  adzunaMaxJobsPerTerm: { value: 50, default: 50, override: null },
  gradcrackerMaxJobsPerTerm: { value: 50, default: 50, override: null },
  startupjobsMaxJobsPerTerm: { value: 50, default: 50, override: null },
  usajobsMaxJobsPerTerm: { value: 50, default: 50, override: null },
  jobicyMaxJobsPerTerm: { value: 50, default: 50, override: null },
  themuseMaxJobsPerTerm: { value: 50, default: 50, override: null },
  joobleMaxJobsPerTerm: { value: 50, default: 50, override: null },
  careerjetMaxJobsPerTerm: { value: 50, default: 50, override: null },
  reedMaxJobsPerTerm: { value: 50, default: 50, override: null },
  remoteokMaxJobsPerTerm: { value: 50, default: 50, override: null },
  remotiveMaxJobsPerTerm: { value: 50, default: 50, override: null },
  arbeitnowMaxJobsPerTerm: { value: 50, default: 50, override: null },
  himalayasMaxJobsPerTerm: { value: 50, default: 50, override: null },
  weworkremotelyMaxJobsPerTerm: { value: 50, default: 50, override: null },
  workingnomadsMaxJobsPerTerm: { value: 50, default: 50, override: null },
  testdevjobsMaxJobsPerTerm: { value: 100, default: 100, override: null },
  testdevjobsMaxPages: { value: 3, default: 3, override: null },
  builtinMaxJobsPerTerm: { value: 100, default: 100, override: null },
  builtinMaxPagesPerTerm: { value: 3, default: 3, override: null },
  wellfoundMaxJobsPerTerm: { value: 50, default: 50, override: null },
  googleJobsMaxJobsPerTerm: { value: 30, default: 30, override: null },
  fourdayweekMaxJobsPerTerm: { value: 50, default: 50, override: null },
  qajobsboardMaxJobsPerTerm: { value: 100, default: 100, override: null },
  arcRemoteJobsPaths: {
    value: ["/remote-jobs/playwright", "/remote-jobs/cypress"],
    default: ["/remote-jobs/playwright", "/remote-jobs/cypress"],
    override: null,
  },
  arcMaxJobsPerPath: { value: 120, default: 120, override: null },
  leverCompanies: { value: [], default: [], override: null },
  ashbyCompanies: { value: [], default: [], override: null },
  greenhouseCompanies: { value: [], default: [], override: null },
  workdayTenants: { value: [], default: [], override: null },
  smartrecruitersCompanies: { value: [], default: [], override: null },
  smartrecruitersMaxJobsPerCompany: {
    value: 100,
    default: 100,
    override: null,
  },
  teamtailorCompanies: { value: [], default: [], override: null },
  huntflowTenants: { value: [], default: [], override: null },
  factorialTenants: { value: [], default: [], override: null },
  careersPageUrls: { value: [], default: [], override: null },
  elutaRssLocations: { value: [], default: [], override: null },
  elutaMaxJobsPerTerm: { value: 100, default: 100, override: null },
  bctenetRssUrls: { value: [], default: [], override: null },
  bctenetMaxJobsPerTerm: { value: 400, default: 400, override: null },
  icimsTenants: { value: [], default: [], override: null },
  icimsMaxJobsPerTenant: { value: 250, default: 250, override: null },
  icimsMaxPagesPerSearch: { value: 10, default: 10, override: null },
  searchTerms: {
    value: ["Software Engineer"],
    default: ["Software Engineer"],
    override: null,
  },
  workplaceTypes: {
    value: ["remote", "hybrid", "onsite"],
    default: ["remote", "hybrid", "onsite"],
    override: null,
  },
  blockedCompanyKeywords: {
    value: [],
    default: [],
    override: null,
  },
  blockedCountries: {
    value: [],
    default: [],
    override: null,
  },
  scoringInstructions: {
    value: "",
    default: "",
    override: null,
  },
  searchCities: {
    value: "United Kingdom",
    default: "United Kingdom",
    override: null,
  },
  jobspyResultsWanted: { value: 20, default: 20, override: null },
  jobspyCountryIndeed: {
    value: "united kingdom",
    default: "united kingdom",
    override: null,
  },
  showSponsorInfo: { value: true, default: true, override: null },
  renderMarkdownInJobDescriptions: {
    value: true,
    default: true,
    override: null,
  },
  chatStyleTone: {
    value: "professional",
    default: "professional",
    override: null,
  },
  chatStyleFormality: { value: "medium", default: "medium", override: null },
  chatStyleConstraints: { value: "", default: "", override: null },
  chatStyleDoNotUse: { value: "", default: "", override: null },
  chatStyleLanguageMode: {
    value: "manual",
    default: "manual",
    override: null,
  },
  chatStyleManualLanguage: {
    value: "english",
    default: "english",
    override: null,
  },
  llmApiKeyHint: null,
  rxresumeApiKeyHint: null,
  rxresumeEmail: null,
  rxresumeUrl: null,
  localResumeProfilePath: null,
  rxresumePasswordHint: null,
  basicAuthUser: null,
  basicAuthPasswordHint: null,
  ukvisajobsEmail: null,
  ukvisajobsPasswordHint: null,
  adzunaAppId: null,
  adzunaAppKeyHint: null,
  webhookSecretHint: null,
  usajobsUserAgent: null,
  themuseApiKey: null,
  careerjetAffid: null,
  careerjetReferer: null,
  careerjetUserIp: null,
  careerjetUserAgent: null,
  usajobsApiKeyHint: null,
  joobleApiKeyHint: null,
  reedApiKeyHint: null,
  basicAuthActive: false,
  localResumeFileConfigured: false,
  backupEnabled: { value: false, default: false, override: null },
  backupHour: { value: 3, default: 3, override: null },
  backupMaxCount: { value: 7, default: 7, override: null },
  penalizeMissingSalary: { value: false, default: false, override: null },
  missingSalaryPenalty: { value: 10, default: 10, override: null },
  autoSkipScoreThreshold: { value: null, default: null, override: null },
  rxresumeMode: { value: "v5", default: "v5", override: null },
  ...overrides,
});
