import { z } from "zod";
import { PROJECT_COLOR_KEYS } from "../lib/timesheets-ui/colors.js";
const projectColorSchema = z.string().refine(
  (value) => PROJECT_COLOR_KEYS.includes(value),
  { message: "Invalid project color key." }
);
const tagsSchema = z.array(z.string().min(1)).optional().default([]);
const optimisticUpdatedAtSchema = z.string().refine(
  (value) => !Number.isNaN(new Date(value).getTime()),
  { message: "Invalid datetime" }
);
const scopedCreateFields = {
  tenantId: z.string().uuid(),
  organizationId: z.string().uuid()
};
const scopedUpdateFields = {
  id: z.string().uuid()
};
const staffTeamCreateSchema = z.object({
  ...scopedCreateFields,
  name: z.string().min(1),
  description: z.string().optional().nullable(),
  isActive: z.boolean().optional()
});
const staffTeamUpdateSchema = z.object({
  ...scopedUpdateFields,
  name: z.string().min(1).optional(),
  description: z.string().optional().nullable(),
  isActive: z.boolean().optional()
});
const staffTeamRoleCreateSchema = z.object({
  ...scopedCreateFields,
  teamId: z.string().uuid().optional().nullable(),
  name: z.string().min(1),
  description: z.string().optional().nullable(),
  appearanceIcon: z.string().trim().max(100).optional().nullable(),
  appearanceColor: z.string().trim().regex(/^#([0-9a-fA-F]{6})$/).optional().nullable()
});
const staffTeamRoleUpdateSchema = z.object({
  ...scopedUpdateFields,
  teamId: z.string().uuid().optional().nullable(),
  name: z.string().min(1).optional(),
  description: z.string().optional().nullable(),
  appearanceIcon: z.string().trim().max(100).optional().nullable(),
  appearanceColor: z.string().trim().regex(/^#([0-9a-fA-F]{6})$/).optional().nullable()
});
const staffTeamMemberCreateSchema = z.object({
  ...scopedCreateFields,
  teamId: z.string().uuid().optional().nullable(),
  displayName: z.string().min(1),
  description: z.string().optional().nullable(),
  userId: z.string().uuid().optional().nullable(),
  roleIds: z.array(z.string().uuid()).optional().default([]),
  tags: tagsSchema,
  availabilityRuleSetId: z.string().uuid().optional().nullable(),
  isActive: z.boolean().optional()
});
const staffTeamMemberUpdateSchema = z.object({
  ...scopedUpdateFields,
  teamId: z.string().uuid().optional().nullable(),
  displayName: z.string().min(1).optional(),
  description: z.string().optional().nullable(),
  userId: z.string().uuid().optional().nullable(),
  roleIds: z.array(z.string().uuid()).optional(),
  tags: z.array(z.string().min(1)).optional(),
  availabilityRuleSetId: z.string().uuid().optional().nullable(),
  isActive: z.boolean().optional()
});
const staffTeamMemberActivityCreateSchema = z.object({
  ...scopedCreateFields,
  entityId: z.string().uuid(),
  activityType: z.string().min(1).max(100),
  subject: z.string().max(200).optional(),
  body: z.string().max(8e3).optional(),
  occurredAt: z.coerce.date().optional(),
  authorUserId: z.string().uuid().optional(),
  appearanceIcon: z.string().trim().max(100).optional().nullable(),
  appearanceColor: z.string().trim().regex(/^#([0-9a-fA-F]{6})$/).optional().nullable()
});
const staffTeamMemberActivityUpdateSchema = z.object({
  id: z.string().uuid()
}).merge(staffTeamMemberActivityCreateSchema.partial());
const staffTeamMemberJobHistoryCreateSchema = z.object({
  ...scopedCreateFields,
  entityId: z.string().uuid(),
  name: z.string().min(1).max(200),
  companyName: z.string().max(200).optional().nullable(),
  description: z.string().max(2e3).optional().nullable(),
  startDate: z.coerce.date(),
  endDate: z.coerce.date().optional().nullable()
});
const staffTeamMemberJobHistoryUpdateSchema = z.object({
  id: z.string().uuid(),
  updatedAt: optimisticUpdatedAtSchema.optional()
}).merge(staffTeamMemberJobHistoryCreateSchema.partial());
const staffTeamMemberCommentCreateSchema = z.object({
  ...scopedCreateFields,
  entityId: z.string().uuid(),
  body: z.string().min(1).max(8e3),
  authorUserId: z.string().uuid().optional(),
  appearanceIcon: z.string().trim().max(100).optional().nullable(),
  appearanceColor: z.string().trim().regex(/^#([0-9a-fA-F]{6})$/).optional().nullable()
});
const staffTeamMemberCommentUpdateSchema = z.object({
  id: z.string().uuid()
}).merge(staffTeamMemberCommentCreateSchema.partial());
const staffTeamMemberAddressCreateSchema = z.object({
  ...scopedCreateFields,
  entityId: z.string().uuid(),
  name: z.string().max(150).optional(),
  purpose: z.string().max(150).optional(),
  companyName: z.string().max(200).optional(),
  addressLine1: z.string().min(1).max(300),
  addressLine2: z.string().max(300).optional(),
  buildingNumber: z.string().max(50).optional(),
  flatNumber: z.string().max(50).optional(),
  city: z.string().max(150).optional(),
  region: z.string().max(150).optional(),
  postalCode: z.string().max(30).optional(),
  country: z.string().max(150).optional(),
  latitude: z.coerce.number().optional(),
  longitude: z.coerce.number().optional(),
  isPrimary: z.boolean().optional()
});
const staffTeamMemberAddressUpdateSchema = z.object({
  id: z.string().uuid()
}).merge(staffTeamMemberAddressCreateSchema.partial());
const staffTeamMemberTagAssignmentSchema = z.object({
  ...scopedCreateFields,
  memberId: z.string().uuid(),
  tag: z.string().min(1)
});
const staffLeaveRequestStatusSchema = z.enum(["pending", "approved", "rejected"]);
const validateStaffLeaveRequestDateRange = (value, ctx) => {
  if (!value.startDate || !value.endDate) return;
  if (value.endDate < value.startDate) {
    ctx.addIssue({
      code: z.ZodIssueCode.custom,
      message: "End date must be after start date.",
      path: ["endDate"]
    });
  }
};
const staffLeaveRequestCreateSchema = z.object({
  ...scopedCreateFields,
  memberId: z.string().uuid(),
  timezone: z.string().min(1),
  startDate: z.coerce.date(),
  endDate: z.coerce.date(),
  unavailabilityReasonEntryId: z.string().uuid().optional().nullable(),
  unavailabilityReasonValue: z.string().trim().min(1).max(150).optional().nullable(),
  note: z.string().max(2e3).optional().nullable(),
  submittedByUserId: z.string().uuid().optional().nullable()
}).superRefine(validateStaffLeaveRequestDateRange);
const staffLeaveRequestUpdateSchema = z.object({
  ...scopedUpdateFields,
  timezone: z.string().min(1).optional(),
  memberId: z.string().uuid().optional(),
  startDate: z.coerce.date().optional(),
  endDate: z.coerce.date().optional(),
  unavailabilityReasonEntryId: z.string().uuid().optional().nullable(),
  unavailabilityReasonValue: z.string().trim().min(1).max(150).optional().nullable(),
  note: z.string().max(2e3).optional().nullable()
}).superRefine(validateStaffLeaveRequestDateRange);
const staffLeaveRequestDecisionSchema = z.object({
  id: z.string().uuid(),
  decisionComment: z.string().max(2e3).optional().nullable(),
  decidedByUserId: z.string().uuid().optional().nullable()
});
const staffTeamMemberSelfCreateSchema = z.object({
  ...scopedCreateFields,
  displayName: z.string().min(1),
  description: z.string().max(2e3).optional().nullable()
});
const timeEntrySourceSchema = z.enum(["manual", "timer", "kiosk", "mobile"]);
const timeProjectStatusSchema = z.enum(["active", "on_hold", "completed"]);
const timeProjectMemberStatusSchema = z.enum(["active", "inactive"]);
const timeEntrySegmentTypeSchema = z.enum(["work", "break"]);
const projectCodeSchema = z.string().min(1).max(50).regex(/^[a-zA-Z0-9-]+$/);
const staffTimeEntryCreateSchema = z.object({
  ...scopedCreateFields,
  staffMemberId: z.string().uuid(),
  date: z.coerce.date(),
  durationMinutes: z.number().int().min(0).max(1440),
  startedAt: z.coerce.date().optional().nullable(),
  endedAt: z.coerce.date().optional().nullable(),
  timeProjectId: z.string().uuid().optional().nullable(),
  customerId: z.string().uuid().optional().nullable(),
  dealId: z.string().uuid().optional().nullable(),
  orderId: z.string().uuid().optional().nullable(),
  notes: z.string().max(2e3).optional().nullable(),
  source: timeEntrySourceSchema.optional().default("manual")
});
const staffTimeEntryUpdateSchema = z.object({
  ...scopedUpdateFields,
  date: z.coerce.date().optional(),
  durationMinutes: z.number().int().min(0).max(1440).optional(),
  timeProjectId: z.string().uuid().optional().nullable(),
  customerId: z.string().uuid().optional().nullable(),
  dealId: z.string().uuid().optional().nullable(),
  orderId: z.string().uuid().optional().nullable(),
  notes: z.string().max(2e3).optional().nullable()
});
const staffTimeEntryStartTimerSchema = z.object({
  ...scopedCreateFields,
  staffMemberId: z.string().uuid(),
  date: z.coerce.date(),
  timeProjectId: z.string().uuid().optional().nullable(),
  notes: z.string().max(2e3).optional().nullable()
});
const staffTimeEntryBulkItemSchema = z.object({
  id: z.string().uuid().optional().nullable(),
  date: z.coerce.date(),
  timeProjectId: z.string().uuid(),
  durationMinutes: z.number().int().min(0).max(1440),
  notes: z.string().max(2e3).optional().nullable()
});
const staffTimeEntryBulkSaveSchema = z.object({
  entries: z.array(staffTimeEntryBulkItemSchema).min(1).max(200)
});
const staffTimeEntrySegmentCreateSchema = z.object({
  ...scopedCreateFields,
  timeEntryId: z.string().uuid(),
  startedAt: z.coerce.date(),
  endedAt: z.coerce.date().optional().nullable(),
  segmentType: timeEntrySegmentTypeSchema.optional().default("work")
});
const staffTimeEntrySegmentUpdateSchema = z.object({
  ...scopedUpdateFields,
  startedAt: z.coerce.date().optional(),
  endedAt: z.coerce.date().optional().nullable(),
  segmentType: timeEntrySegmentTypeSchema.optional()
});
const staffTimeProjectCreateSchema = z.object({
  ...scopedCreateFields,
  name: z.string().min(1).max(255),
  customerId: z.string().uuid().optional().nullable(),
  code: projectCodeSchema,
  description: z.string().max(2e3).optional().nullable(),
  projectType: z.string().max(100).optional().nullable(),
  color: projectColorSchema.optional().nullable(),
  status: timeProjectStatusSchema.optional().default("active"),
  ownerUserId: z.string().uuid().optional().nullable(),
  costCenter: z.string().max(100).optional().nullable(),
  startDate: z.coerce.date().optional().nullable()
});
const staffTimeProjectUpdateSchema = z.object({
  ...scopedUpdateFields,
  name: z.string().min(1).max(255).optional(),
  customerId: z.string().uuid().optional().nullable(),
  code: projectCodeSchema.optional(),
  description: z.string().max(2e3).optional().nullable(),
  projectType: z.string().max(100).optional().nullable(),
  color: projectColorSchema.optional().nullable(),
  status: timeProjectStatusSchema.optional(),
  ownerUserId: z.string().uuid().optional().nullable(),
  costCenter: z.string().max(100).optional().nullable(),
  startDate: z.coerce.date().optional().nullable()
});
const staffTimeProjectMemberAssignSchema = z.object({
  ...scopedCreateFields,
  timeProjectId: z.string().uuid(),
  staffMemberId: z.string().uuid(),
  role: z.string().max(100).optional().nullable(),
  status: timeProjectMemberStatusSchema.optional().default("active"),
  assignedStartDate: z.coerce.date(),
  assignedEndDate: z.coerce.date().optional().nullable()
});
const staffTimeProjectMemberUpdateSchema = z.object({
  ...scopedUpdateFields,
  role: z.string().max(100).optional().nullable(),
  status: timeProjectMemberStatusSchema.optional(),
  assignedEndDate: z.coerce.date().optional().nullable()
});
const staffMyProjectVisibilityUpdateSchema = z.object({
  showInGrid: z.boolean()
});
export {
  optimisticUpdatedAtSchema,
  staffLeaveRequestCreateSchema,
  staffLeaveRequestDecisionSchema,
  staffLeaveRequestUpdateSchema,
  staffMyProjectVisibilityUpdateSchema,
  staffTeamCreateSchema,
  staffTeamMemberActivityCreateSchema,
  staffTeamMemberActivityUpdateSchema,
  staffTeamMemberAddressCreateSchema,
  staffTeamMemberAddressUpdateSchema,
  staffTeamMemberCommentCreateSchema,
  staffTeamMemberCommentUpdateSchema,
  staffTeamMemberCreateSchema,
  staffTeamMemberJobHistoryCreateSchema,
  staffTeamMemberJobHistoryUpdateSchema,
  staffTeamMemberSelfCreateSchema,
  staffTeamMemberTagAssignmentSchema,
  staffTeamMemberUpdateSchema,
  staffTeamRoleCreateSchema,
  staffTeamRoleUpdateSchema,
  staffTeamUpdateSchema,
  staffTimeEntryBulkItemSchema,
  staffTimeEntryBulkSaveSchema,
  staffTimeEntryCreateSchema,
  staffTimeEntrySegmentCreateSchema,
  staffTimeEntrySegmentUpdateSchema,
  staffTimeEntryStartTimerSchema,
  staffTimeEntryUpdateSchema,
  staffTimeProjectCreateSchema,
  staffTimeProjectMemberAssignSchema,
  staffTimeProjectMemberUpdateSchema,
  staffTimeProjectUpdateSchema
};
//# sourceMappingURL=validators.js.map
