import { z } from "zod";
const StackPermissionsSchema = z.object({
  canRead: z.boolean(),
  canWrite: z.boolean(),
  canHandoff: z.boolean(),
  canMerge: z.boolean(),
  canAdminister: z.boolean()
});
const stackIdSchema = z.string().min(1).max(200);
const userIdSchema = z.string().min(1).max(100);
const frameIdSchema = z.string().min(1).max(100);
const teamIdSchema = z.string().min(1).max(100);
const CreateSharedStackSchema = z.object({
  teamId: teamIdSchema,
  name: z.string().min(1).max(200),
  ownerId: userIdSchema,
  permissions: StackPermissionsSchema.optional()
});
const SwitchStackSchema = z.object({
  stackId: stackIdSchema
});
const FrameContextSchema = z.object({
  totalFrames: z.number().min(1).max(1e4),
  frameTypes: z.array(z.string()).min(1).max(50),
  estimatedSize: z.number().min(0).max(1e6),
  // Max 1MB
  dependencies: z.array(z.string()).max(100)
});
const BusinessContextSchema = z.object({
  milestone: z.string().max(100).optional(),
  priority: z.enum(["low", "medium", "high", "critical"]).optional(),
  deadline: z.date().optional(),
  stakeholders: z.array(userIdSchema).max(20).optional()
});
const HandoffRequestSchema = z.object({
  initiatedAt: z.date(),
  initiatorId: userIdSchema,
  frameContext: FrameContextSchema,
  businessContext: BusinessContextSchema.optional()
});
const InitiateHandoffSchema = z.object({
  targetStackId: stackIdSchema,
  frameIds: z.array(frameIdSchema).min(1).max(1e3),
  handoffRequest: HandoffRequestSchema,
  reviewerId: userIdSchema.optional(),
  description: z.string().max(1e3).optional()
});
const HandoffApprovalSchema = z.object({
  reviewerId: userIdSchema,
  decision: z.enum(["approved", "rejected", "needs_changes"]),
  feedback: z.string().max(2e3).optional(),
  suggestedChanges: z.array(
    z.object({
      frameId: frameIdSchema,
      suggestion: z.string().max(500),
      reason: z.string().max(300).optional()
    })
  ).max(50).optional()
});
const ConflictResolutionSchema = z.object({
  strategy: z.enum(["source_wins", "target_wins", "merge_both", "manual"]),
  resolvedBy: userIdSchema,
  notes: z.string().max(1e3).optional()
});
const MergePolicyRuleSchema = z.object({
  condition: z.string().min(1).max(500),
  action: z.enum(["source_wins", "target_wins", "merge_both", "manual_review"]),
  priority: z.number().min(1).max(10)
});
const CreateMergePolicySchema = z.object({
  name: z.string().min(1).max(100),
  description: z.string().max(500).optional(),
  rules: z.array(MergePolicyRuleSchema).min(1).max(20),
  autoApplyThreshold: z.enum(["low", "medium", "high"])
});
const StartMergeSessionSchema = z.object({
  sourceStackId: stackIdSchema,
  targetStackId: stackIdSchema,
  frameIds: z.array(frameIdSchema).max(1e3).optional(),
  policyName: z.string().max(100).optional()
});
function validateInput(schema, input) {
  try {
    return schema.parse(input);
  } catch (error) {
    if (error instanceof z.ZodError) {
      const details = error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ");
      throw new Error(`Validation failed: ${details}`);
    }
    throw error;
  }
}
function validateInputSafe(schema, input) {
  try {
    const data = schema.parse(input);
    return { success: true, data };
  } catch (error) {
    if (error instanceof z.ZodError) {
      const details = error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ");
      return { success: false, error: `Validation failed: ${details}` };
    }
    return { success: false, error: "Unknown validation error" };
  }
}
export {
  BusinessContextSchema,
  ConflictResolutionSchema,
  CreateMergePolicySchema,
  CreateSharedStackSchema,
  FrameContextSchema,
  HandoffApprovalSchema,
  HandoffRequestSchema,
  InitiateHandoffSchema,
  MergePolicyRuleSchema,
  StackPermissionsSchema,
  StartMergeSessionSchema,
  SwitchStackSchema,
  validateInput,
  validateInputSafe
};
//# sourceMappingURL=validation.js.map
