"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/theme/index.ts
var theme_exports = {};
__export(theme_exports, {
  applyTheme: () => applyTheme,
  createTheme: () => createTheme,
  listLocalThemes: () => listLocalThemes,
  loadLocalTheme: () => loadLocalTheme,
  themeSchema: () => themeSchema2
});
module.exports = __toCommonJS(theme_exports);

// ../theme-core/src/site-styles/types.ts
function asSiteStyleId(value) {
  const siteStyleId = brandNonEmptyString(value, "SiteStyleId");
  if (!siteStyleId.startsWith("site-style:")) {
    throw new Error(
      `SiteStyleId must start with "site-style:". Received: ${value}`
    );
  }
  return siteStyleId;
}
function brandNonEmptyString(value, label) {
  if (value.length === 0) {
    throw new Error(`${label} must be a non-empty string.`);
  }
  return value;
}

// ../theme-core/src/schema.ts
var import_zod12 = require("zod");

// ../theme-core/src/lib/media.ts
var import_zod = __toESM(require("zod"));
var hotspotSchema = import_zod.default.object({
  x: import_zod.default.number().min(0).max(1),
  y: import_zod.default.number().min(0).max(1),
  radius: import_zod.default.number().optional()
});
var rotationSchema = import_zod.default.union([import_zod.default.literal(0), import_zod.default.literal(90), import_zod.default.literal(180), import_zod.default.literal(270)]);
var rectSchema = import_zod.default.tuple([import_zod.default.number(), import_zod.default.number(), import_zod.default.number(), import_zod.default.number()]);
var aspectCropSchema = import_zod.default.object({
  aspect: import_zod.default.preprocess((value) => value == null ? void 0 : value, import_zod.default.string().optional()),
  rect: import_zod.default.preprocess((value) => value == null ? void 0 : value, rectSchema.optional()),
  hotspot: import_zod.default.preprocess((value) => value == null ? void 0 : value, hotspotSchema.optional()),
  rotation: import_zod.default.preprocess((value) => value == null ? void 0 : value, rotationSchema.optional())
});
var transformSchema = import_zod.default.object({
  aspectCrops: import_zod.default.preprocess((value) => {
    if (!value || typeof value !== "object" || Array.isArray(value)) {
      return void 0;
    }
    return value;
  }, import_zod.default.record(import_zod.default.string(), aspectCropSchema.catch({}))).optional(),
  rect: rectSchema.optional(),
  hotspot: hotspotSchema.optional(),
  rotation: rotationSchema.optional()
});
var mediaSchema = import_zod.default.object({
  type: import_zod.default.enum(["image", "video", "audio", "document", "spreadsheet", "archive"]),
  purpose: import_zod.default.string().optional(),
  placeholder: import_zod.default.boolean().default(true).optional(),
  assetId: import_zod.default.string().optional(),
  identifier: import_zod.default.string().optional(),
  src: import_zod.default.string().optional(),
  alt: import_zod.default.string().optional(),
  filename: import_zod.default.string().optional(),
  mimeType: import_zod.default.string().optional(),
  width: import_zod.default.number().optional(),
  height: import_zod.default.number().optional(),
  storageBucket: import_zod.default.string().optional(),
  storagePath: import_zod.default.string().optional(),
  transform: transformSchema.optional()
});

// ../theme-core/src/buttons/types.ts
var import_zod2 = require("zod");
var cornerStyleSchema = import_zod2.z.enum(["square", "rounded", "pill"]);
var shadowSizeSchema = import_zod2.z.enum(["none", "low", "medium", "high"]);
var textTransformSchema = import_zod2.z.enum(["none", "uppercase", "lowercase", "capitalize"]);
var fontWeightSchema = import_zod2.z.union([import_zod2.z.literal(500), import_zod2.z.literal(600), import_zod2.z.literal(700)]);
var buttonTypographySchema = import_zod2.z.enum(["body", "heading"]);
var hoverTransformSchema = import_zod2.z.enum(["none", "lift", "scale", "press"]);
var hoverColorSchema = import_zod2.z.enum(["none", "brighten", "darken", "saturate", "token"]);
var buttonPaddingPresetSchema = import_zod2.z.enum(["compact", "default", "spacious"]);
var gradientStyleSchema = import_zod2.z.enum(["linear", "radial", "conic"]);
var gradientSharpnessSchema = import_zod2.z.enum(["smooth", "medium", "hard"]);
var buttonSizeNameSchema = import_zod2.z.enum(["sm", "md", "lg", "xl"]);
var buttonSizeConfigSchema = import_zod2.z.object({
  padding: import_zod2.z.string(),
  fontSize: import_zod2.z.string().optional()
});
var buttonSizesSchema = import_zod2.z.object({
  sm: buttonSizeConfigSchema,
  md: buttonSizeConfigSchema,
  lg: buttonSizeConfigSchema,
  xl: buttonSizeConfigSchema.optional()
});
var backgroundTreatmentSchema = import_zod2.z.enum(["solid", "gradient", "outline", "ghost"]);
var outlineHoverEffectSchema = import_zod2.z.enum([
  "border-glow",
  "border-shift",
  "border-grow",
  "fill-transition",
  "border-trace"
]);
var buttonGlobalSettingsSchema = import_zod2.z.object({
  cornerStyle: cornerStyleSchema,
  cornerRadius: import_zod2.z.number().min(0).max(24).optional(),
  shadow: shadowSizeSchema,
  textTransform: textTransformSchema,
  fontWeight: fontWeightSchema,
  borderWidth: import_zod2.z.union([import_zod2.z.literal(1), import_zod2.z.literal(2), import_zod2.z.literal(3)]),
  // Typography source (body or heading)
  typography: buttonTypographySchema.optional(),
  // Italic style
  italic: import_zod2.z.boolean().optional(),
  // Padding preset (applies to all variants unless overridden)
  paddingPreset: buttonPaddingPresetSchema.optional(),
  hoverTransform: hoverTransformSchema,
  hoverColor: hoverColorSchema,
  // When hoverColor is 'token', this specifies which token to use
  hoverColorToken: import_zod2.z.string().optional(),
  // Gradient settings (if any variant uses gradients)
  gradientStyle: gradientStyleSchema.optional(),
  gradientAngle: import_zod2.z.number().min(0).max(360).optional(),
  gradientSharpness: gradientSharpnessSchema.optional()
});
var gradientDirectionSchema = import_zod2.z.enum(["to-r", "to-l", "to-t", "to-b", "to-tr", "to-tl", "to-br", "to-bl"]);
var buttonBackgroundSchema = import_zod2.z.discriminatedUnion("type", [
  import_zod2.z.object({ type: import_zod2.z.literal("solid"), colorToken: import_zod2.z.string() }),
  import_zod2.z.object({
    type: import_zod2.z.literal("gradient"),
    stops: import_zod2.z.array(import_zod2.z.string()).min(2),
    direction: gradientDirectionSchema
  }),
  import_zod2.z.object({ type: import_zod2.z.literal("transparent") })
]);
var effectApplicationSchema = import_zod2.z.object({
  effectId: import_zod2.z.string(),
  options: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.any()).optional()
});
var buttonBorderSchema = import_zod2.z.object({
  widthClass: import_zod2.z.string(),
  colorToken: import_zod2.z.string()
});
var buttonVariantLegacySchema = import_zod2.z.object({
  id: import_zod2.z.string(),
  name: import_zod2.z.string().min(1).max(20),
  enabled: import_zod2.z.boolean(),
  priority: import_zod2.z.union([import_zod2.z.literal(1), import_zod2.z.literal(2), import_zod2.z.literal(3)]),
  backgroundTreatment: backgroundTreatmentSchema,
  color: import_zod2.z.string().optional(),
  gradientColors: import_zod2.z.tuple([import_zod2.z.string(), import_zod2.z.string()]).optional(),
  borderColor: import_zod2.z.string().optional(),
  outlineHoverEffect: outlineHoverEffectSchema.optional(),
  effectPreset: import_zod2.z.string().optional()
});
var buttonVariantSchema = import_zod2.z.object({
  id: import_zod2.z.string(),
  name: import_zod2.z.string().min(1).max(20),
  enabled: import_zod2.z.boolean(),
  priority: import_zod2.z.union([import_zod2.z.literal(1), import_zod2.z.literal(2), import_zod2.z.literal(3)]),
  // Base appearance (token-based)
  background: buttonBackgroundSchema,
  textColorToken: import_zod2.z.string(),
  borderRadius: import_zod2.z.string(),
  // Optional shadow override (uses theme.shadow if not specified)
  shadow: import_zod2.z.object({
    elevation: import_zod2.z.enum(["none", "low", "medium", "high"]),
    softness: import_zod2.z.enum(["crisp", "soft", "hard"]).nullable(),
    position: import_zod2.z.enum(["bottom", "bottom-right"]).default("bottom")
  }).optional(),
  // Border (optional)
  border: buttonBorderSchema.optional(),
  // Padding (optional, defaults to "0.5rem 1rem")
  padding: import_zod2.z.string().optional(),
  // Font size (optional, Tailwind text size class)
  fontSize: import_zod2.z.string().optional(),
  // Hover background token (per-variant override, takes precedence over global hoverColorToken)
  hoverBackgroundToken: import_zod2.z.string().optional(),
  // Effect composition
  effects: import_zod2.z.object({
    base: import_zod2.z.array(effectApplicationSchema).optional(),
    hover: import_zod2.z.array(effectApplicationSchema).optional(),
    active: import_zod2.z.array(effectApplicationSchema).optional(),
    focus: import_zod2.z.array(effectApplicationSchema).optional()
  }).optional()
});
var buttonSystemSchema = import_zod2.z.object({
  global: buttonGlobalSettingsSchema,
  variants: import_zod2.z.array(buttonVariantSchema).min(1).max(6),
  sizes: buttonSizesSchema.optional()
});

// ../theme-core/src/cards/types.ts
var import_zod3 = require("zod");
var cardSpacingSchema = import_zod3.z.enum(["none", "compact", "cozy", "medium", "comfortable", "spacious"]);
var gradientDirectionSchema2 = import_zod3.z.enum(["to-r", "to-l", "to-t", "to-b", "to-tr", "to-tl", "to-br", "to-bl"]);
var cardBackgroundSchema = import_zod3.z.discriminatedUnion("type", [
  import_zod3.z.object({ type: import_zod3.z.literal("solid"), colorToken: import_zod3.z.string() }),
  import_zod3.z.object({
    type: import_zod3.z.literal("gradient"),
    fromToken: import_zod3.z.string(),
    toToken: import_zod3.z.string(),
    direction: gradientDirectionSchema2
  }),
  import_zod3.z.object({ type: import_zod3.z.literal("transparent") })
]);
var cardBorderSchema = import_zod3.z.object({
  widthClass: import_zod3.z.string(),
  colorToken: import_zod3.z.string()
});
var cardVariantSchema = import_zod3.z.object({
  id: import_zod3.z.string(),
  name: import_zod3.z.string().min(1).max(20),
  enabled: import_zod3.z.boolean(),
  priority: import_zod3.z.union([import_zod3.z.literal(1), import_zod3.z.literal(2), import_zod3.z.literal(3)]),
  // Appearance (token-based)
  background: cardBackgroundSchema,
  spacing: cardSpacingSchema,
  // Optional overrides (uses theme defaults if not specified)
  shadow: import_zod3.z.object({
    elevation: import_zod3.z.enum(["none", "low", "medium", "high"]),
    softness: import_zod3.z.enum(["crisp", "soft", "hard"]).nullable(),
    position: import_zod3.z.enum(["bottom", "bottom-right"]).default("bottom")
  }).optional(),
  corners: import_zod3.z.enum(["square", "soft", "rounded", "pill"]).optional(),
  // Border (optional)
  border: cardBorderSchema.optional()
});
var cardSystemSchema = import_zod3.z.object({
  variants: import_zod3.z.array(cardVariantSchema).min(1).max(3)
});

// ../theme-core/src/accordions/types.ts
var import_zod4 = require("zod");
var accordionIconSchema = import_zod4.z.enum([
  "plus-minus",
  // + becomes - (swap or rotate 90°)
  "chevron",
  // › becomes ⌄ (rotate 90° or 180°)
  "caret",
  // ▸ becomes ▾ (rotate 90° or 180°)
  "arrow",
  // → becomes ↓ (rotate 90° or 180°)
  "circle-plus-minus"
  // ⊕ becomes ⊖ (swap with fade)
]);
var accordionSystemSchema = import_zod4.z.object({
  // Visual styling (solid color only - gradients can be added later if needed)
  background: import_zod4.z.object({
    type: import_zod4.z.literal("solid"),
    colorToken: import_zod4.z.string()
  }),
  // Spacing (padding inside items)
  spacing: import_zod4.z.enum(["none", "compact", "cozy", "medium", "comfortable", "spacious"]),
  // Border radius (null = inherit from theme.corners)
  corners: import_zod4.z.enum(["square", "soft", "rounded", "pill"]).nullable(),
  // Border styling (null = inherit from theme.border)
  border: import_zod4.z.object({
    widthClass: import_zod4.z.string(),
    // e.g., 'border', 'border-2', 'border-0'
    colorToken: import_zod4.z.string()
  }).nullable(),
  // Shadow (null = inherit from theme.shadow)
  shadow: import_zod4.z.object({
    elevation: import_zod4.z.enum(["none", "low", "medium", "high"]),
    softness: import_zod4.z.enum(["soft", "crisp", "hard"]).nullable(),
    position: import_zod4.z.enum(["bottom", "bottom-right"])
  }).nullable(),
  // Icon style and animation
  icon: import_zod4.z.object({
    style: accordionIconSchema,
    position: import_zod4.z.enum(["left", "right"]),
    size: import_zod4.z.enum(["sm", "md", "lg"])
  }),
  // Trigger (question) styling
  trigger: import_zod4.z.object({
    textColorToken: import_zod4.z.string(),
    fontWeight: import_zod4.z.enum(["regular", "medium", "semibold", "bold"]).nullable()
    // null = inherit from theme
  }),
  // Hover state styling
  hover: import_zod4.z.object({
    backgroundColorToken: import_zod4.z.string().optional(),
    textColorToken: import_zod4.z.string().optional(),
    borderColorToken: import_zod4.z.string().optional()
  }),
  // Content (answer) styling
  content: import_zod4.z.object({
    textColorToken: import_zod4.z.string()
  })
});

// ../theme-core/src/inputs/types.ts
var import_zod5 = require("zod");
var inputSystemSchema = import_zod5.z.object({
  // Base styling (applied to all inputs)
  base: import_zod5.z.object({
    background: import_zod5.z.union([
      import_zod5.z.object({
        type: import_zod5.z.literal("solid"),
        colorToken: import_zod5.z.string()
      }),
      import_zod5.z.object({
        type: import_zod5.z.literal("transparent")
      })
    ]),
    textColorToken: import_zod5.z.string(),
    border: import_zod5.z.object({
      widthClass: import_zod5.z.string(),
      // e.g., 'border', 'border-2'
      colorToken: import_zod5.z.string(),
      style: import_zod5.z.enum(["all", "underline"]).optional()
    }),
    corners: import_zod5.z.enum(["square", "soft", "rounded", "pill"]).nullable(),
    // null = inherit from theme.corners
    shadow: import_zod5.z.object({
      elevation: import_zod5.z.enum(["none", "low", "medium"]),
      softness: import_zod5.z.enum(["soft", "crisp", "hard"]).nullable()
    }).nullable(),
    spacing: import_zod5.z.enum(["compact", "cozy", "medium", "comfortable"]),
    // padding inside inputs
    fontSize: import_zod5.z.enum(["sm", "base", "lg"])
  }),
  // Label styling
  label: import_zod5.z.object({
    textColorToken: import_zod5.z.string(),
    fontWeight: import_zod5.z.enum(["regular", "medium", "semibold", "bold", "black"]),
    fontSize: import_zod5.z.enum(["2xs", "xs", "sm", "base"]),
    textTransform: import_zod5.z.enum(["none", "uppercase", "lowercase", "capitalize"]).optional(),
    letterSpacing: import_zod5.z.enum(["normal", "wide", "wider", "widest"]).optional(),
    opacity: import_zod5.z.number().min(0.2).max(1).optional()
  }),
  // Focus state
  focus: import_zod5.z.object({
    ringColorToken: import_zod5.z.string(),
    ringWidth: import_zod5.z.enum(["0", "1", "2", "3"]),
    borderColorToken: import_zod5.z.string().optional()
    // Change border color on focus
  }),
  // Error state (for validation feedback)
  error: import_zod5.z.object({
    borderColorToken: import_zod5.z.string(),
    textColorToken: import_zod5.z.string()
  }),
  // Disabled state
  disabled: import_zod5.z.object({
    backgroundColorToken: import_zod5.z.string(),
    textColorToken: import_zod5.z.string(),
    opacity: import_zod5.z.number().min(0.3).max(0.7)
  })
});

// ../theme-core/src/gradients/types.ts
var import_zod6 = require("zod");
var gradientStopSchema = import_zod6.z.object({
  color: import_zod6.z.string(),
  // Theme color token name (e.g., 'primary-500')
  position: import_zod6.z.number().min(0).max(100)
  // Percentage 0-100
});
var gradientConfigSchema = import_zod6.z.object({
  type: import_zod6.z.enum(["linear", "radial"]),
  angle: import_zod6.z.number().min(0).max(360).optional(),
  // For linear gradients (degrees)
  position: import_zod6.z.string().optional(),
  // For radial gradients ('center', 'top left', etc.)
  stops: import_zod6.z.array(gradientStopSchema).min(2)
});

// ../theme-core/src/navigation/types.ts
var import_zod8 = require("zod");

// ../theme-core/src/interactive/baseSchema.ts
var import_zod7 = require("zod");
var interactiveTypographySchema = import_zod7.z.object({
  /** Font family source */
  typography: import_zod7.z.enum(["body", "heading"]).default("body"),
  /** Font weight */
  fontWeight: import_zod7.z.enum(["regular", "medium", "semibold", "bold"]).default("medium"),
  /** Text transform */
  textTransform: import_zod7.z.enum(["none", "uppercase", "capitalize"]).default("none"),
  /** Italic style */
  italic: import_zod7.z.boolean().default(false)
});
var effectApplicationSchema2 = import_zod7.z.object({
  /** Effect preset ID */
  effectId: import_zod7.z.string(),
  /** User-provided customization options */
  options: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.any()).optional()
});
var effectCompositionSchema = import_zod7.z.object({
  /** Effects always applied */
  base: import_zod7.z.array(effectApplicationSchema2).optional(),
  /** Effects applied on hover */
  hover: import_zod7.z.array(effectApplicationSchema2).optional(),
  /** Effects applied on active/pressed */
  active: import_zod7.z.array(effectApplicationSchema2).optional(),
  /** Effects applied on focus */
  focus: import_zod7.z.array(effectApplicationSchema2).optional()
});

// ../theme-core/src/navigation/types.ts
var navLinkPaddingSchema = import_zod8.z.enum(["none", "compact", "default"]);
var navLinkPaddingXSchema = import_zod8.z.enum(["none", "tight", "compact", "default", "relaxed", "spacious"]);
var navLinkBorderRadiusSchema = import_zod8.z.enum(["none", "sm", "md", "full"]);
var navLinkTextSizeSchema = import_zod8.z.enum(["xs", "sm", "base", "lg"]);
var navLinkLetterSpacingSchema = import_zod8.z.enum(["normal", "wide", "wider", "widest"]);
var navLinkStyleSchema = import_zod8.z.object({
  /** Display name for the style */
  name: import_zod8.z.string().min(1).max(30).optional(),
  /** Typography settings (inherited from interactive base) */
  ...interactiveTypographySchema.shape,
  /** Text color token */
  colorToken: import_zod8.z.string().default("text"),
  /** Optional text size override */
  textSize: navLinkTextSizeSchema.optional(),
  /** Optional letter spacing override */
  letterSpacing: navLinkLetterSpacingSchema.optional(),
  /** Hover/active color token (for color-change effects) */
  hoverColorToken: import_zod8.z.string().nullable().optional(),
  /** Padding preset */
  padding: navLinkPaddingSchema.default("compact"),
  /** Horizontal padding override (overrides horizontal component of padding preset) */
  paddingX: navLinkPaddingXSchema.optional(),
  /** Border radius (for capsule/pill styles) */
  borderRadius: navLinkBorderRadiusSchema.default("none"),
  /** Composable effects */
  effects: effectCompositionSchema.optional()
});

// ../theme-core/src/customCss/validation.ts
var import_zod9 = require("zod");
var FORBIDDEN_SELECTORS = [":root", "html", "body"];
var UNIVERSAL_SELECTOR = "*";
var REMOTE_URL_PATTERN = /url\s*\(\s*['"]?(https?:|\/\/)/i;
var JAVASCRIPT_URL_PATTERN = /javascript\s*:/i;
function isForbiddenSelectorPart(part) {
  const normalized = part.toLowerCase().trim();
  if (!normalized) return true;
  if (normalized === UNIVERSAL_SELECTOR || normalized.startsWith("* ") || normalized.endsWith(" *") || normalized.includes(" * ")) {
    return true;
  }
  for (const forbidden of FORBIDDEN_SELECTORS) {
    if (normalized === forbidden) return true;
    if (normalized.startsWith(forbidden + " ")) return true;
    if (normalized.startsWith(forbidden + ">")) return true;
    if (normalized.startsWith(forbidden + "+")) return true;
    if (normalized.startsWith(forbidden + "~")) return true;
    if (normalized.startsWith(forbidden + ".")) return true;
    if (normalized.startsWith(forbidden + "#")) return true;
    if (normalized.startsWith(forbidden + "[")) return true;
    if (normalized.startsWith(forbidden + ":") && !normalized.startsWith(forbidden + "::")) return true;
  }
  return false;
}
function hasScopeEscapingSiblingCombinator(selector) {
  const normalized = selector.trim();
  return /&\s*[+~]/.test(normalized);
}
function containsForbiddenSelector(selector) {
  const normalized = selector.toLowerCase().trim();
  if (!normalized) return true;
  if (hasScopeEscapingSiblingCombinator(selector)) {
    return true;
  }
  const parts = normalized.split(",");
  for (const part of parts) {
    if (isForbiddenSelectorPart(part)) {
      return true;
    }
  }
  return false;
}
var selectorSchema = import_zod9.z.string().min(1, "Selector cannot be empty").max(200, "Selector too long (max 200 characters)").refine(
  (s) => !containsForbiddenSelector(s),
  { message: "Global selectors (:root, html, body, *) are not allowed" }
);
function containsRemoteUrl(value) {
  return REMOTE_URL_PATTERN.test(value);
}
function containsJavascriptUrl(value) {
  return JAVASCRIPT_URL_PATTERN.test(value);
}
var declarationValueSchema = import_zod9.z.string().max(500, "Declaration value too long (max 500 characters)").refine(
  (v) => !containsRemoteUrl(v),
  { message: "Remote url() references are not allowed. Use local paths, data URIs, or fragment IDs." }
).refine(
  (v) => !containsJavascriptUrl(v),
  { message: "javascript: URLs are not allowed" }
);
var declarationsSchema = import_zod9.z.record(
  import_zod9.z.string().min(1).max(100),
  // property name
  declarationValueSchema
  // property value
);
var customCssRuleSchema = import_zod9.z.object({
  id: import_zod9.z.string().min(1, "Rule ID is required").max(50, "Rule ID too long"),
  selector: selectorSchema,
  declarations: declarationsSchema
});
var blockCustomCssRuleSchema = customCssRuleSchema.extend({
  blockKind: import_zod9.z.string().min(1, "Block kind is required").max(50, "Block kind too long")
});
var customCssRulesSchema = import_zod9.z.array(customCssRuleSchema).optional();
var blockCustomCssRulesSchema = import_zod9.z.array(blockCustomCssRuleSchema).optional();

// ../theme-core/src/customCss/atRuleValidation.ts
var import_zod10 = require("zod");
var KEYFRAME_OFFSET_PATTERN = /^(from|to|\d{1,3}%)$/i;
var ANIMATION_NAME_PATTERN = /^[a-zA-Z_-][a-zA-Z0-9_-]*$/;
var BLOCKED_AT_RULES = ["@import", "@charset"];
var BLOCKED_AT_RULE_PATTERN = /@(?:import|charset)\b/i;
var ruleIdSchema = import_zod10.z.string().min(1, "Rule ID is required").max(50, "Rule ID too long");
var nestedRuleSchema = import_zod10.z.object({
  selector: selectorSchema,
  declarations: declarationsSchema
});
function isValidKeyframeOffset(offset) {
  const trimmed = offset.trim().toLowerCase();
  if (trimmed === "from" || trimmed === "to") return true;
  const match = trimmed.match(/^(\d{1,3})%$/);
  if (!match || match[1] === void 0) return false;
  const value = parseInt(match[1], 10);
  return value >= 0 && value <= 100;
}
var keyframeOffsetSchema = import_zod10.z.string().transform((offset) => offset.trim()).refine(
  (offset) => KEYFRAME_OFFSET_PATTERN.test(offset),
  { message: 'Invalid keyframe offset. Use percentages (0%, 50%, 100%) or "from"/"to"' }
).refine(
  isValidKeyframeOffset,
  { message: "Keyframe offset must be between 0% and 100%" }
);
var animationNameSchema = import_zod10.z.string().min(1, "Animation name is required").max(50, "Animation name too long").refine(
  (name) => ANIMATION_NAME_PATTERN.test(name),
  { message: "Invalid animation name. Use letters, numbers, dashes, underscores (start with letter, dash, or underscore)" }
);
var keyframeSchema = import_zod10.z.object({
  offset: keyframeOffsetSchema,
  declarations: declarationsSchema
});
var keyframesAtRuleSchema = import_zod10.z.object({
  id: ruleIdSchema,
  type: import_zod10.z.literal("keyframes"),
  name: animationNameSchema,
  frames: import_zod10.z.array(keyframeSchema).min(1, "At least one keyframe is required")
});
var fontFaceDeclarationsSchema = import_zod10.z.record(import_zod10.z.string().min(1).max(100), declarationValueSchema).refine(
  (decls) => "fontFamily" in decls || "font-family" in decls,
  { message: "font-family is required in @font-face" }
);
var fontFaceAtRuleSchema = import_zod10.z.object({
  id: ruleIdSchema,
  type: import_zod10.z.literal("font-face"),
  declarations: fontFaceDeclarationsSchema
});
var mediaQuerySchema = import_zod10.z.string().min(1, "Media query is required").max(200, "Media query too long");
var mediaAtRuleSchema = import_zod10.z.object({
  id: ruleIdSchema,
  type: import_zod10.z.literal("media"),
  query: mediaQuerySchema,
  rules: import_zod10.z.array(nestedRuleSchema).min(1, "At least one rule is required")
});
var supportsConditionSchema = import_zod10.z.string().min(1, "Supports condition is required").max(200, "Supports condition too long");
var supportsAtRuleSchema = import_zod10.z.object({
  id: ruleIdSchema,
  type: import_zod10.z.literal("supports"),
  condition: supportsConditionSchema,
  rules: import_zod10.z.array(nestedRuleSchema).min(1, "At least one rule is required")
});
function containsBlockedAtRule(css) {
  return BLOCKED_AT_RULE_PATTERN.test(css);
}
var rawCssSchema = import_zod10.z.string().min(1, "CSS is required").max(5e3, "Raw CSS too long (max 5000 characters)").refine(
  (css) => css.trim().startsWith("@"),
  { message: "Raw at-rule must start with @" }
).refine(
  (css) => !containsBlockedAtRule(css),
  { message: `Blocked at-rules: ${BLOCKED_AT_RULES.join(", ")}. Use typed at-rules or local assets instead.` }
);
var rawAtRuleSchema = import_zod10.z.object({
  id: ruleIdSchema,
  type: import_zod10.z.literal("raw"),
  css: rawCssSchema
});
var customCssAtRuleSchema = import_zod10.z.discriminatedUnion("type", [
  keyframesAtRuleSchema,
  fontFaceAtRuleSchema,
  mediaAtRuleSchema,
  supportsAtRuleSchema,
  rawAtRuleSchema
]);
var customCssAtRulesSchema = import_zod10.z.array(customCssAtRuleSchema).optional();

// ../theme-core/src/shared/componentStyles.ts
var import_zod11 = require("zod");
var componentBorderSchema = import_zod11.z.object({
  width: import_zod11.z.enum(["none", "hairline", "thin", "medium", "thick"]).default("none"),
  style: import_zod11.z.enum(["solid", "dashed"]).default("solid"),
  colorToken: import_zod11.z.string().optional()
  // defaults to "border" if not set
});
var componentShadowSchema = import_zod11.z.object({
  elevation: import_zod11.z.enum(["none", "sm", "md", "lg", "xl", "2xl"]).default("sm")
});

// ../theme-core/src/schema.ts
var axesSchema = import_zod12.z.object({
  tone: import_zod12.z.enum(["minimal", "classic", "bold"]),
  energy: import_zod12.z.enum(["calm", "vibrant"]),
  density: import_zod12.z.enum(["airy", "regular", "compact"]),
  mediaBias: import_zod12.z.enum(["text", "media", "mixed"]),
  conversionBias: import_zod12.z.enum(["low", "med", "high"]),
  motion: import_zod12.z.enum(["subtle", "standard", "expressive"])
});
var colourHexString = import_zod12.z.string().regex(/^#([0-9A-Fa-f]{3}){1,2}$/);
var paletteColorSchema = import_zod12.z.object({
  name: import_zod12.z.string().min(1),
  hex: colourHexString
});
var paletteMetaSchema = import_zod12.z.object({
  mode: import_zod12.z.enum(["light", "dark"])
});
var paletteSchema = import_zod12.z.object({
  colors: import_zod12.z.array(paletteColorSchema),
  meta: paletteMetaSchema
});
var typographyStyleSchema = import_zod12.z.object({
  family: import_zod12.z.string().min(1),
  weight: import_zod12.z.enum(["light", "regular", "medium", "semibold", "bold"]),
  letterSpacing: import_zod12.z.enum(["tight", "normal", "loose"]),
  lineHeight: import_zod12.z.enum(["normal", "relaxed", "loose"])
});
var bodyTypographyStyleSchema = typographyStyleSchema.extend({
  size: import_zod12.z.enum(["md", "lg", "xl"])
});
var headingSizeSchema = import_zod12.z.enum(["xs", "sm", "md", "lg", "xl", "2xl"]);
var headingTypographyOverridesSchema = import_zod12.z.object({
  weight: import_zod12.z.enum(["light", "regular", "medium", "semibold", "bold"]).nullable().optional(),
  letterSpacing: import_zod12.z.enum(["tight", "normal", "loose"]).nullable().optional(),
  size: headingSizeSchema.nullable().optional(),
  lineHeight: import_zod12.z.enum(["normal", "relaxed", "loose"]).nullable().optional(),
  italic: import_zod12.z.boolean().nullable().optional(),
  colorToken: import_zod12.z.string().min(1).nullable().optional()
  // Palette token name for heading color
});
var headingTypographyStyleSchema = typographyStyleSchema.extend({
  case: import_zod12.z.enum(["uppercase", "normal", "smallCaps"]).nullable(),
  italic: import_zod12.z.boolean().nullable(),
  colorToken: import_zod12.z.string().min(1).nullable().optional()
  // Palette token name for heading color
});
var proseLinkUnderlineStyleSchema = import_zod12.z.enum(["solid", "dotted", "dashed"]);
var proseLinkUnderlineThicknessSchema = import_zod12.z.enum(["auto", "fromFont", "thin", "medium", "thick"]);
var proseLinkUnderlineOffsetSchema = import_zod12.z.enum(["auto", "tight", "normal", "loose"]);
var proseLinkStyleSchema = import_zod12.z.object({
  colorToken: import_zod12.z.string().min(1).optional(),
  hoverColorToken: import_zod12.z.string().min(1).optional(),
  underline: import_zod12.z.boolean().optional(),
  decorationColorToken: import_zod12.z.string().min(1).optional(),
  hoverDecorationColorToken: import_zod12.z.string().min(1).optional(),
  underlineStyle: proseLinkUnderlineStyleSchema.optional(),
  underlineThickness: proseLinkUnderlineThicknessSchema.optional(),
  underlineOffset: proseLinkUnderlineOffsetSchema.optional()
});
var semanticSpacingSchema = import_zod12.z.enum([
  "none",
  "compact",
  "cozy",
  "medium",
  "comfortable",
  "spacious"
]);
var boxRoundedSchema = import_zod12.z.enum(["none", "sm", "md", "lg", "xl", "2xl", "full"]);
var boxBackgroundOverlaySchema = import_zod12.z.object({
  type: import_zod12.z.enum(["none", "color", "gradient"]).nullable().optional(),
  color: import_zod12.z.string().nullable().optional(),
  gradient: import_zod12.z.string().nullable().optional(),
  opacity: import_zod12.z.number().min(0).max(1).nullable().optional()
});
var boxBackgroundSchema = import_zod12.z.object({
  type: import_zod12.z.enum(["color", "gradient", "image"]).optional(),
  color: import_zod12.z.string().nullable().optional(),
  gradient: import_zod12.z.string().nullable().optional(),
  image: mediaSchema.nullable().optional(),
  objectFit: import_zod12.z.enum(["fill", "fit", "original", "custom"]).nullable().optional(),
  scale: import_zod12.z.string().nullable().optional(),
  position: import_zod12.z.string().nullable().optional(),
  opacity: import_zod12.z.number().min(0).max(1).nullable().optional(),
  overlay: boxBackgroundOverlaySchema.nullable().optional(),
  textColor: import_zod12.z.string().nullable().optional(),
  headingColor: import_zod12.z.string().nullable().optional()
});
var sectionStylesOverrideSchema = import_zod12.z.object({
  background: boxBackgroundSchema.nullable().optional(),
  spacing: semanticSpacingSchema.nullable().optional(),
  minHeight: import_zod12.z.enum(["none", "hero", "immersive"]).nullable().optional()
});
var containerStylesOverrideSchema = import_zod12.z.object({
  background: boxBackgroundSchema.nullable().optional(),
  spacing: semanticSpacingSchema.nullable().optional(),
  raised: import_zod12.z.boolean().nullable().optional(),
  rounded: boxRoundedSchema.nullable().optional(),
  fullWidth: import_zod12.z.boolean().nullable().optional()
});
var cardBorderOverrideSchema = import_zod12.z.object({
  enabled: import_zod12.z.boolean().nullable().optional(),
  width: import_zod12.z.enum(["none", "1", "2", "3"]).nullable().optional(),
  colorToken: import_zod12.z.string().nullable().optional()
});
var cardStylesOverrideSchema = import_zod12.z.object({
  background: boxBackgroundSchema.nullable().optional(),
  border: cardBorderOverrideSchema.nullable().optional(),
  spacing: semanticSpacingSchema.nullable().optional(),
  raised: import_zod12.z.boolean().nullable().optional(),
  rounded: boxRoundedSchema.nullable().optional()
});
var blockStyleOverridesSchema = import_zod12.z.object({
  sectionStyles: sectionStylesOverrideSchema.nullable().optional(),
  containerStyles: containerStylesOverrideSchema.nullable().optional(),
  cardStyles: cardStylesOverrideSchema.nullable().optional()
});
var blockThemeOverrideSchema = import_zod12.z.object({
  typography: import_zod12.z.object({
    proseLinkStyle: proseLinkStyleSchema.optional()
  }).optional(),
  styles: blockStyleOverridesSchema.optional()
});
var typographyScaleSchema = import_zod12.z.enum([
  // New intuitive names
  "compact",
  // ratio 1.2 (was minorThird)
  "balanced",
  // ratio 1.25 (was majorThird)
  "spacious",
  // ratio 1.333 (was perfectFourth)
  // Legacy names (backward compatibility)
  "minorThird",
  "majorThird",
  "perfectFourth"
]);
var typographySchema = import_zod12.z.object({
  body: bodyTypographyStyleSchema,
  headings: import_zod12.z.object({
    default: headingTypographyStyleSchema,
    h1: headingTypographyOverridesSchema,
    h2: headingTypographyOverridesSchema,
    h3: headingTypographyOverridesSchema,
    // Allow per-level overrides for additional heading levels
    h4: headingTypographyOverridesSchema.optional(),
    h5: headingTypographyOverridesSchema.optional(),
    h6: headingTypographyOverridesSchema.optional()
  }),
  scale: typographyScaleSchema,
  proseLinkStyle: proseLinkStyleSchema.optional()
});
var spaceSchema = import_zod12.z.enum(["comfortable", "standard", "dense"]);
var corners = import_zod12.z.enum(["square", "soft", "rounded", "pill"]);
var shadow = import_zod12.z.object({
  elevation: import_zod12.z.enum(["none", "low", "medium", "high"]),
  softness: import_zod12.z.enum(["crisp", "soft", "hard"]).nullable(),
  position: import_zod12.z.enum(["bottom", "bottom-right"]).default("bottom")
});
var border = import_zod12.z.object({
  width: import_zod12.z.enum(["none", "hairline", "thin", "thick"]),
  style: import_zod12.z.enum(["solid", "dashed"])
});
var motion = import_zod12.z.object({
  level: import_zod12.z.enum(["off", "low", "medium", "high"]),
  easing: import_zod12.z.enum(["standard", "snappy", "gentle"]).nullable()
});
var buttonStyle = import_zod12.z.object({
  shape: corners
  // Used for --radius-control CSS variable
});
var cardStyle = import_zod12.z.object({
  elevation: import_zod12.z.enum(["none", "low", "medium", "high"]),
  border: import_zod12.z.enum(["none", "subtle", "defined"]),
  shape: corners,
  headerStyle: import_zod12.z.enum(["plain", "accentBar", "subtleBg"]).nullable(),
  mediaTreatment: import_zod12.z.enum(["square", "rounded", "bleed"]).nullable()
});
var inputStyle = import_zod12.z.object({
  shape: corners,
  border: import_zod12.z.enum(["subtle", "defined", "underline"]),
  focus: import_zod12.z.enum(["glow", "ring", "underline"]),
  label: import_zod12.z.enum(["inside", "above"])
});
var headerVariant = import_zod12.z.enum(["classic", "centered", "transparent", "floating", "editorial"]);
var headerPositioning = import_zod12.z.enum(["static", "sticky", "fixed"]);
var headerNavStyle = import_zod12.z.enum([
  "minimal",
  "underline",
  "underline-grow",
  "capsule",
  "scale",
  "frosted",
  "solid"
]);
var navFontWeight = import_zod12.z.enum(["regular", "medium", "semibold", "bold"]);
var headerMaxWidth = import_zod12.z.enum(["container", "full"]);
var headerContainerSchema = import_zod12.z.object({
  rounded: import_zod12.z.enum(["none", "sm", "md", "lg", "xl", "2xl"]).default("xl"),
  border: import_zod12.z.boolean().default(true),
  shadow: import_zod12.z.boolean().default(true),
  padding: import_zod12.z.enum(["sm", "md", "lg"]).default("md"),
  tint: import_zod12.z.string().nullable().optional(),
  opacity: import_zod12.z.number().min(0).max(1).default(0.12)
}).optional();
var headerBorderSchema = componentBorderSchema.extend({
  position: import_zod12.z.enum(["bottom", "top", "both", "none"]).default("bottom")
}).optional();
var logoStyleSchema = import_zod12.z.object({
  fontFamily: import_zod12.z.enum(["heading", "body"]).default("heading"),
  letterSpacing: import_zod12.z.enum(["normal", "wide", "wider", "widest"]).default("normal"),
  gradient: import_zod12.z.boolean().default(false)
}).optional();
var headerLogoTextSchema = import_zod12.z.object({
  mobileWrapLines: import_zod12.z.union([import_zod12.z.literal(1), import_zod12.z.literal(2)]).optional(),
  mobileMaxWidth: import_zod12.z.enum(["xs", "sm", "md"]).optional(),
  hideOnShrink: import_zod12.z.boolean().optional()
}).optional();
var navEffectsSchema = import_zod12.z.object({
  underlineGradient: import_zod12.z.boolean().default(false),
  glow: import_zod12.z.boolean().default(false),
  glowColor: import_zod12.z.string().optional(),
  neumorphic: import_zod12.z.boolean().default(false)
}).optional();
var dropdownStyleSchema = import_zod12.z.object({
  // Container styling
  background: import_zod12.z.string().default("surface"),
  // color token
  textColor: import_zod12.z.string().default("text"),
  // color token
  borderColor: import_zod12.z.string().nullable().default("border"),
  // null = no border
  shadow: import_zod12.z.enum(["none", "sm", "md", "lg"]).default("md"),
  borderRadius: import_zod12.z.enum(["none", "sm", "md", "lg"]).default("md"),
  // Link hover states (explicit control)
  hoverBackground: import_zod12.z.string().nullable().optional(),
  // color token, null = transparent
  hoverTextColor: import_zod12.z.string().nullable().optional(),
  // color token, null = inherit
  // Typography
  textTransform: import_zod12.z.enum(["none", "uppercase", "capitalize"]).default("none"),
  letterSpacing: import_zod12.z.enum(["normal", "wide", "wider"]).default("normal"),
  fontWeight: import_zod12.z.enum(["regular", "medium", "semibold", "bold"]).optional(),
  // optional = inherit from navWeight
  textSize: import_zod12.z.enum(["xs", "sm", "base", "lg"]).optional()
  // optional = no override (browser default)
}).optional();
var headerCtaGapSchema = import_zod12.z.enum(["none", "tight", "compact", "default", "relaxed", "spacious"]);
var navContainerSchema = import_zod12.z.object({
  type: import_zod12.z.enum(["none", "pill", "glass"]).default("none"),
  tint: import_zod12.z.string().nullable().optional(),
  opacity: import_zod12.z.number().min(0).max(1).default(0.15)
}).default({ type: "none", tint: null, opacity: 0.15 });
var headerBackgroundSchema = import_zod12.z.object({
  type: import_zod12.z.enum(["color", "gradient", "image"]),
  color: import_zod12.z.string().nullable().optional(),
  gradient: gradientConfigSchema.nullable().optional(),
  image: mediaSchema.nullable().optional(),
  textColor: import_zod12.z.string().nullable().optional()
});
var headerSchema = import_zod12.z.object({
  variant: headerVariant,
  positioning: headerPositioning,
  shrinkOnScroll: import_zod12.z.boolean(),
  maxWidth: headerMaxWidth,
  logoOverride: mediaSchema.nullable().optional(),
  background: headerBackgroundSchema.default({ type: "color", color: "surface" }),
  textColor: import_zod12.z.string().nullable().optional(),
  // Site title and general header text
  navStyle: headerNavStyle,
  navColor: import_zod12.z.string().nullable().optional(),
  // Nav links (inherits textColor if not set)
  navWeight: navFontWeight.default("medium"),
  // New fields for header system enhancement
  container: headerContainerSchema,
  border: headerBorderSchema,
  shadow: componentShadowSchema.optional(),
  // defaults to 'sm' for sticky in CSS generator
  logo: logoStyleSchema,
  logoText: headerLogoTextSchema,
  navEffects: navEffectsSchema,
  navContainer: navContainerSchema,
  // Full nav link customization (overrides navStyle if set)
  navLinkStyle: navLinkStyleSchema.optional(),
  // CTA button spacing (desktop left margin)
  ctaGap: headerCtaGapSchema.optional(),
  // Dropdown menu styling (nav dropdowns and mobile drawer)
  dropdownStyle: dropdownStyleSchema
});
var footerVariant = import_zod12.z.enum(["simple", "columns", "split"]);
var footerMaxWidth = import_zod12.z.enum(["container", "full"]);
var footerMode = import_zod12.z.enum(["default", "blocks", "default+blocks", "none"]);
var footerNavLayoutMode = import_zod12.z.enum(["stack", "inline", "inline-wrap"]);
var footerNavLayoutAlign = import_zod12.z.enum(["start", "center", "end", "space-between"]);
var footerSpacing = import_zod12.z.enum(["none", "tight", "compact", "default", "relaxed", "spacious"]);
var footerLogoPlacement = import_zod12.z.enum(["left", "right", "above", "below"]);
var footerLogoSize = import_zod12.z.enum(["sm", "md", "lg", "xl"]);
var footerLogoMaxHeight = import_zod12.z.enum(["sm", "md", "lg", "xl"]);
var footerBottomTextLinkStyleSchema = import_zod12.z.object({
  colorToken: import_zod12.z.string().optional(),
  hoverColorToken: import_zod12.z.string().nullable().optional(),
  decorationColorToken: import_zod12.z.string().nullable().optional(),
  underline: import_zod12.z.boolean().optional()
});
var footerBottomBarSchema = import_zod12.z.object({
  enabled: import_zod12.z.boolean().optional(),
  fullBleed: import_zod12.z.boolean().optional(),
  background: headerBackgroundSchema.optional(),
  textColor: import_zod12.z.string().nullable().optional(),
  textAlign: import_zod12.z.enum(["left", "center", "right"]).optional(),
  paddingY: footerSpacing.optional(),
  paddingX: footerSpacing.optional(),
  borderTop: import_zod12.z.object({
    colorToken: import_zod12.z.string().nullable().optional(),
    width: import_zod12.z.enum(["none", "thin", "medium", "thick"]).optional()
  }).optional()
});
var footerNavLayoutSchema = import_zod12.z.object({
  layout: footerNavLayoutMode.optional(),
  align: footerNavLayoutAlign.optional(),
  gapX: footerSpacing.optional(),
  gapY: footerSpacing.optional(),
  columns: import_zod12.z.number().int().min(1).max(6).optional()
});
var footerLogoSchema = import_zod12.z.object({
  showLogo: import_zod12.z.boolean().default(true),
  showLogoText: import_zod12.z.boolean().optional(),
  placement: footerLogoPlacement.optional(),
  size: footerLogoSize.optional(),
  maxHeight: footerLogoMaxHeight.optional(),
  align: import_zod12.z.enum(["start", "center", "end"]).optional()
});
var footerSchema = import_zod12.z.object({
  /**
   * SDK-only footer rendering mode.
   *
   * Backwards compatible: missing/undefined behaves as 'default'.
   */
  mode: footerMode.optional(),
  variant: footerVariant,
  maxWidth: footerMaxWidth,
  showLogoText: import_zod12.z.boolean().optional(),
  background: headerBackgroundSchema.default({ type: "color", color: "surface" }),
  // Footer nav styling (independent from header)
  navStyle: headerNavStyle.default("minimal"),
  navColor: import_zod12.z.string().nullable().optional(),
  navWeight: navFontWeight.default("medium"),
  // Full nav link customization (overrides navStyle if set)
  navLinkStyle: navLinkStyleSchema.optional(),
  // Footer bottom rich-text link styling (scoped to footer prose links)
  bottomTextLinkStyle: footerBottomTextLinkStyleSchema.optional(),
  // Footer layout controls
  navLayout: footerNavLayoutSchema.optional(),
  logo: footerLogoSchema.optional(),
  bottomBar: footerBottomBarSchema.optional()
});
var containerPaddingPresetSchema = import_zod12.z.enum(["tight", "compact", "default", "relaxed"]);
var layoutSchema = import_zod12.z.object({
  containerPadding: import_zod12.z.object({
    mobile: containerPaddingPresetSchema.optional(),
    tablet: containerPaddingPresetSchema.optional(),
    desktop: containerPaddingPresetSchema.optional()
  }).optional()
}).optional();
var heroTypographySizeSchema = import_zod12.z.enum([
  "sm",
  "base",
  "lg",
  "xl",
  "2xl",
  "3xl",
  "4xl",
  "5xl",
  "6xl"
]);
var heroTypographyLineHeightSchema = import_zod12.z.enum(["tight", "snug", "normal", "relaxed"]);
var heroResponsiveTypographySchema = import_zod12.z.object({
  headlineSize: heroTypographySizeSchema.optional(),
  headlineLineHeight: heroTypographyLineHeightSchema.optional(),
  subheadlineSize: heroTypographySizeSchema.optional(),
  subheadlineLineHeight: heroTypographyLineHeightSchema.optional()
});
var heroTypographySchema = import_zod12.z.object({
  headlineSize: heroTypographySizeSchema.optional(),
  headlineLineHeight: heroTypographyLineHeightSchema.optional(),
  subheadlineSize: heroTypographySizeSchema.optional(),
  subheadlineLineHeight: heroTypographyLineHeightSchema.optional(),
  microHeadlineSize: heroTypographySizeSchema.optional(),
  microHeadlineLineHeight: heroTypographyLineHeightSchema.optional(),
  microSubheadlineSize: heroTypographySizeSchema.optional(),
  microSubheadlineLineHeight: heroTypographyLineHeightSchema.optional(),
  responsive: import_zod12.z.object({
    tablet: heroResponsiveTypographySchema.optional(),
    mobile: heroResponsiveTypographySchema.optional()
  }).optional()
});
var heroSchema = import_zod12.z.object({
  typography: heroTypographySchema.optional()
}).optional();
var gradientsSchema = import_zod12.z.object({
  button: import_zod12.z.string().min(1).nullable().optional(),
  hero: import_zod12.z.string().min(1).nullable().optional(),
  background: import_zod12.z.string().min(1).nullable().optional()
});
var themeSchema = import_zod12.z.object({
  name: import_zod12.z.string().min(1).max(30),
  description: import_zod12.z.string().min(1).max(400),
  rationale: import_zod12.z.string().min(1).max(400),
  siteStyleId: import_zod12.z.string().min(1).transform((value) => asSiteStyleId(value)).optional(),
  axes: axesSchema,
  palette: paletteSchema,
  typography: typographySchema,
  space: spaceSchema,
  border,
  shadow,
  motion,
  corners,
  gradients: gradientsSchema.optional(),
  layout: layoutSchema,
  hero: heroSchema,
  header: headerSchema,
  footer: footerSchema,
  buttons: buttonSystemSchema.optional(),
  // New button system (optional for backwards compatibility)
  cards: cardSystemSchema.optional(),
  // Card variant system (optional for backwards compatibility)
  accordions: accordionSystemSchema.optional(),
  // Accordion system (optional - generated if not provided)
  inputs: inputSystemSchema.optional(),
  // Input system (optional - generated if not provided)
  inputStyle: inputStyle.optional(),
  // Simple input styling API (drives InputSystem defaults)
  // Block-specific customization (Tier 3)
  // blockCustomVars: Per-block CSS variable overrides as bare values
  // Example: { "event-registration": { "--step-color": "#6d28d9" } }
  blockCustomVars: import_zod12.z.record(
    import_zod12.z.string(),
    // block kind (matches data-block attribute)
    import_zod12.z.record(import_zod12.z.string(), import_zod12.z.string())
    // { '--var-name': 'value' }
  ).optional(),
  // Structured block-kind theme overrides (v1: typography prose-link style only)
  // Keyed by block kind (usually data-block value like "hero"; "block.hero" also accepted)
  blockOverrides: import_zod12.z.record(
    import_zod12.z.string(),
    blockThemeOverrideSchema
  ).optional(),
  // Structured custom CSS rules
  // Validated, scoped, and safe by construction - no @import, remote url(), or global selectors
  customCssRules: customCssRulesSchema,
  // Structured block-specific CSS rules
  blockCustomCssRules: blockCustomCssRulesSchema,
  // Structured CSS at-rules (@keyframes, @media, @font-face, etc.)
  // @keyframes and @font-face are global; @media/@supports have scoped selectors
  customCssAtRules: customCssAtRulesSchema,
  /**
   * Style groups define named visual presets that content authors can apply to blocks.
   *
   * Unlike variants (which change block structure/layout), style groups only affect
   * CSS styling. The selected style group is rendered as a `data-style-group` attribute
   * on the block wrapper, which can be targeted in `blockCustomCssRules`.
   *
   * @example
   * ```typescript
   * {
   *   styleGroups: {
   *     hero: ['bold', 'minimal', 'featured'],
   *     'body-text': ['intro', 'compact'],
   *   },
   *   blockCustomCssRules: [
   *     {
   *       id: 'hero-bold-headline',
   *       blockKind: 'hero',
   *       selector: '&[data-style-group="bold"] .hero-headline',
   *       declarations: { fontWeight: '800', fontSize: '3rem' }
   *     }
   *   ]
   * }
   * ```
   */
  styleGroups: import_zod12.z.record(import_zod12.z.string(), import_zod12.z.array(import_zod12.z.string())).optional()
});
var themesTurnSchema = import_zod12.z.object({
  message: import_zod12.z.string().min(1),
  themes: import_zod12.z.array(themeSchema).length(3)
});

// src/theme/loader.ts
var fs = __toESM(require("fs/promises"));
var path = __toESM(require("path"));
async function loadLocalTheme(contentDir, themeName = "current") {
  if (!/^[a-z0-9][a-z0-9-_]*$/.test(themeName)) {
    throw new Error(
      `Invalid theme name: "${themeName}". Theme names must be lowercase alphanumeric with hyphens/underscores.`
    );
  }
  const themesDir = path.join(contentDir, "themes");
  const filePath = path.join(themesDir, `${themeName}.json`);
  try {
    await fs.access(filePath);
  } catch {
    let availableThemes = [];
    try {
      const files = await fs.readdir(themesDir);
      availableThemes = files.filter((f) => f.endsWith(".json")).map((f) => f.replace(/\.json$/, ""));
    } catch {
    }
    let errorMessage = `Theme file not found: ${filePath}`;
    if (availableThemes.length > 0) {
      errorMessage += `

Available themes:
${availableThemes.map((t) => `  - ${t}`).join("\n")}`;
    } else {
      errorMessage += `

No theme files found in ${themesDir}.
Run 'riverbankcms pull theme' to download your site's theme.`;
    }
    throw new Error(errorMessage);
  }
  let rawContent;
  try {
    rawContent = await fs.readFile(filePath, "utf-8");
  } catch (error) {
    throw new Error(
      `Failed to read theme file: ${filePath}
${error instanceof Error ? error.message : String(error)}`
    );
  }
  let parsedContent;
  try {
    parsedContent = JSON.parse(rawContent);
  } catch (error) {
    throw new Error(
      `Invalid JSON in theme file: ${filePath}
${error instanceof Error ? error.message : String(error)}`
    );
  }
  const result = themeSchema.safeParse(parsedContent);
  if (!result.success) {
    const issues = result.error.issues.map((issue) => `  - ${issue.path.join(".")}: ${issue.message}`).join("\n");
    throw new Error(`Invalid theme at ${filePath}
${issues}`);
  }
  return {
    theme: result.data,
    name: themeName,
    filePath: path.resolve(filePath)
  };
}
async function listLocalThemes(contentDir) {
  const themesDir = path.join(contentDir, "themes");
  try {
    const files = await fs.readdir(themesDir);
    return files.filter((f) => f.endsWith(".json")).map((f) => f.replace(/\.json$/, "")).sort();
  } catch {
    return [];
  }
}

// src/theme/index.ts
var themeSchema2 = themeSchema;
function applyTheme(theme, element) {
  const targetElement = element ?? (typeof document !== "undefined" ? document.documentElement : null);
  if (!targetElement) {
    console.warn("[Builder SDK] Cannot apply theme: no document available");
    return;
  }
  targetElement.setAttribute("data-builder-theme", JSON.stringify(theme));
}
function createTheme(partial = {}) {
  return { ...partial };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  applyTheme,
  createTheme,
  listLocalThemes,
  loadLocalTheme,
  themeSchema
});
//# sourceMappingURL=theme.js.map