import { z } from "zod";
import { normalizeHostname } from "@open-mercato/core/modules/customer_accounts/lib/hostname";
const emailField = z.string().email().max(255);
const passwordField = z.string().min(8).max(128);
const displayNameField = z.string().min(1).max(255);
const signupSchema = z.object({
  email: emailField,
  password: passwordField,
  displayName: displayNameField,
  tenantId: z.string().uuid().optional(),
  organizationId: z.string().uuid().optional()
});
const loginSchema = z.object({
  email: emailField,
  password: z.string().min(1).max(128),
  tenantId: z.string().uuid().optional(),
  organizationId: z.string().uuid().optional()
});
const emailVerifySchema = z.object({
  token: z.string().min(1).max(512)
});
const passwordResetRequestSchema = z.object({
  email: emailField,
  tenantId: z.string().uuid().optional()
});
const passwordResetConfirmSchema = z.object({
  token: z.string().min(1).max(512),
  password: passwordField
});
const magicLinkRequestSchema = z.object({
  email: emailField,
  tenantId: z.string().uuid().optional()
});
const magicLinkVerifySchema = z.object({
  token: z.string().min(1).max(512)
});
const invitationAcceptSchema = z.object({
  token: z.string().min(1).max(512),
  password: passwordField,
  displayName: displayNameField
});
const profileUpdateSchema = z.object({
  displayName: displayNameField.optional()
});
const passwordChangeSchema = z.object({
  currentPassword: z.string().min(1).max(128),
  newPassword: passwordField
});
const createRoleSchema = z.object({
  name: z.string().min(1).max(255),
  slug: z.string().min(1).max(255).regex(/^[a-z0-9_-]+$/),
  description: z.string().max(1e3).optional(),
  isDefault: z.boolean().optional(),
  customerAssignable: z.boolean().optional()
});
const updateRoleSchema = z.object({
  name: z.string().min(1).max(255).optional(),
  description: z.string().max(1e3).optional(),
  isDefault: z.boolean().optional(),
  customerAssignable: z.boolean().optional()
});
const updateRoleAclSchema = z.object({
  features: z.array(z.string().min(1).max(255)),
  isPortalAdmin: z.boolean().optional()
});
const inviteUserSchema = z.object({
  email: emailField,
  customerEntityId: z.string().uuid().optional(),
  roleIds: z.array(z.string().uuid()).min(1),
  displayName: displayNameField.optional()
});
const assignRolesSchema = z.object({
  roleIds: z.array(z.string().uuid()).min(1)
});
const adminCreateUserSchema = z.object({
  email: emailField,
  password: passwordField,
  displayName: displayNameField,
  roleIds: z.array(z.string().uuid()).optional(),
  customerEntityId: z.string().uuid().optional()
});
const adminUpdateUserSchema = z.object({
  displayName: displayNameField.optional(),
  isActive: z.boolean().optional(),
  lockedUntil: z.string().datetime().nullable().optional(),
  personEntityId: z.string().uuid().nullable().optional(),
  customerEntityId: z.string().uuid().nullable().optional(),
  roleIds: z.array(z.string().uuid()).optional()
});
const adminResetPasswordSchema = z.object({
  newPassword: passwordField
});
const hostnameSchema = z.string().min(1, "Hostname is required").max(512, "Hostname is too long").transform((value, ctx) => {
  try {
    return normalizeHostname(value);
  } catch (err) {
    ctx.addIssue({
      code: z.ZodIssueCode.custom,
      message: err instanceof Error ? err.message : "Invalid hostname"
    });
    return z.NEVER;
  }
});
const registerDomainSchema = z.object({
  hostname: hostnameSchema,
  organizationId: z.string().uuid(),
  replacesDomainId: z.string().uuid().optional()
});
export {
  adminCreateUserSchema,
  adminResetPasswordSchema,
  adminUpdateUserSchema,
  assignRolesSchema,
  createRoleSchema,
  emailVerifySchema,
  hostnameSchema,
  invitationAcceptSchema,
  inviteUserSchema,
  loginSchema,
  magicLinkRequestSchema,
  magicLinkVerifySchema,
  passwordChangeSchema,
  passwordResetConfirmSchema,
  passwordResetRequestSchema,
  profileUpdateSchema,
  registerDomainSchema,
  signupSchema,
  updateRoleAclSchema,
  updateRoleSchema
};
//# sourceMappingURL=validators.js.map
