"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }

var _chunkDGUM43GVjs = require('./chunk-DGUM43GV.js');

// ../api/src/endpoints.ts
var ENDPOINT_DEFINITIONS = {
  // AI endpoints - no cache due to dynamic nature
  aiContentUpdateChat: {
    path: "/ai/content-update-chat",
    method: "POST",
    auth: "user",
    responseKind: "stream"
  },
  aiChat: {
    path: "/ai/chat",
    method: "POST",
    auth: "user",
    responseKind: "stream"
  },
  applySeoChanges: {
    path: "/seo/apply",
    method: "POST",
    auth: "user",
    responseKind: "json"
  },
  aiCreateBriefChat: {
    path: "/ai/chat/create-brief",
    method: "POST",
    auth: "user",
    responseKind: "json"
  },
  aiPrototypeChat: {
    path: "/ai/chat/create-prototype",
    method: "POST",
    revalidate: 30,
    // Short cache for AI responses to avoid duplicate calls
    tags: ["ai-prototype"],
    auth: "user",
    responseKind: "json"
  },
  aiPatchDryRun: {
    path: "/ai/patch/dry-run",
    method: "POST",
    auth: "user",
    responseKind: "json"
  },
  aiPatchApply: {
    path: "/ai/patch/apply",
    method: "POST",
    auth: "user",
    responseKind: "json"
  },
  aiPlaygroundPropose: {
    path: "/sites/{siteId}/ai/playground/propose",
    method: "POST",
    auth: "user",
    responseKind: "json"
  },
  // Admin SEO
  listGscPropertiesAdmin: {
    path: "/admin/seo/gsc/properties",
    method: "GET",
    auth: "admin",
    responseKind: "json"
  },
  adminSetGscPersist: {
    path: "/admin/seo/gsc/meta/persist",
    method: "POST",
    auth: "admin",
    responseKind: "json"
  },
  adminStartGscVerification: {
    path: "/admin/seo/gsc/properties/verify/start",
    method: "POST",
    auth: "admin",
    responseKind: "json"
  },
  adminConfirmGscVerification: {
    path: "/admin/seo/gsc/properties/verify/confirm",
    method: "POST",
    auth: "admin",
    responseKind: "json"
  },
  adminRunGscIngest: {
    path: "/admin/seo/ingest/run",
    method: "POST",
    auth: "admin",
    responseKind: "json"
  },
  getSeoVerificationMeta: {
    path: "/public/seo/verification/meta",
    method: "GET",
    auth: "public",
    responseKind: "json"
  },
  checkRedirect: {
    path: "/api/public/content/redirect",
    method: "GET",
    revalidate: 86400,
    // 24 hours - redirects rarely change
    tags: ["redirect"],
    auth: "public",
    responseKind: "json"
  },
  listRedirectRules: {
    path: "/sites/{siteId}/redirects",
    method: "GET",
    auth: "user",
    responseKind: "json"
  },
  createRedirectRule: {
    path: "/sites/{siteId}/redirects",
    method: "POST",
    auth: "user",
    responseKind: "json"
  },
  deleteRedirectRule: {
    path: "/sites/{siteId}/redirects/{ruleId}",
    method: "DELETE",
    auth: "user",
    responseKind: "json"
  },
  // API Keys (Account-level - DEPRECATED, use site-scoped endpoints)
  listApiKeys: {
    path: "/account/api-keys",
    method: "GET",
    auth: "user",
    responseKind: "json"
  },
  createApiKey: {
    path: "/account/api-keys",
    method: "POST",
    auth: "user",
    responseKind: "json"
  },
  revokeApiKey: {
    path: "/account/api-keys/{keyId}",
    method: "DELETE",
    auth: "user",
    responseKind: "json"
  },
  // API Keys (Site-scoped - preferred)
  listSiteApiKeys: {
    path: "/sites/{siteId}/api-keys",
    method: "GET",
    auth: "user",
    tags: ["site-{siteId}", "api-keys"],
    responseKind: "json"
  },
  createSiteApiKey: {
    path: "/sites/{siteId}/api-keys",
    method: "POST",
    auth: "user",
    tags: ["site-{siteId}", "api-keys"],
    responseKind: "json"
  },
  revokeSiteApiKey: {
    path: "/sites/{siteId}/api-keys/{keyId}",
    method: "DELETE",
    auth: "user",
    tags: ["site-{siteId}", "api-keys"],
    responseKind: "json"
  },
  getSitePreviewKey: {
    path: "/sites/{siteId}/api-keys/preview",
    method: "GET",
    auth: "user",
    tags: ["site-{siteId}", "api-keys", "preview-key"],
    responseKind: "json"
  },
  regenerateSitePreviewKey: {
    path: "/sites/{siteId}/api-keys/preview/regenerate",
    method: "POST",
    auth: "user",
    tags: ["site-{siteId}", "api-keys", "preview-key"],
    responseKind: "json"
  },
  getSiteApiKeyAccessLogs: {
    path: "/sites/{siteId}/api-keys/access-logs",
    method: "GET",
    auth: "user",
    tags: ["site-{siteId}", "api-keys", "access-logs"],
    responseKind: "json"
  },
  getBookingSettings: {
    path: "/sites/{siteId}/bookings/settings",
    method: "GET",
    auth: "user",
    responseKind: "json"
  },
  updateBookingSettings: {
    path: "/sites/{siteId}/bookings/settings",
    method: "PUT",
    auth: "user",
    responseKind: "json"
  },
  listAppointmentResources: {
    path: "/sites/{siteId}/bookings/resources",
    method: "GET",
    auth: "user",
    responseKind: "json"
  },
  createAppointmentResource: {
    path: "/sites/{siteId}/bookings/resources",
    method: "POST",
    auth: "user",
    responseKind: "json"
  },
  getAppointmentResource: {
    path: "/sites/{siteId}/bookings/resources/{resourceId}",
    method: "GET",
    auth: "user",
    responseKind: "json"
  },
  updateAppointmentResource: {
    path: "/sites/{siteId}/bookings/resources/{resourceId}",
    method: "PUT",
    auth: "user",
    responseKind: "json"
  },
  deleteAppointmentResource: {
    path: "/sites/{siteId}/bookings/resources/{resourceId}",
    method: "DELETE",
    auth: "user",
    responseKind: "json"
  },
  listAppointmentServices: {
    path: "/sites/{siteId}/bookings/services",
    method: "GET",
    auth: "user",
    responseKind: "json"
  },
  createAppointmentService: {
    path: "/sites/{siteId}/bookings/services",
    method: "POST",
    auth: "user",
    responseKind: "json"
  },
  getAppointmentService: {
    path: "/sites/{siteId}/bookings/services/{serviceId}",
    method: "GET",
    auth: "user",
    responseKind: "json"
  },
  updateAppointmentService: {
    path: "/sites/{siteId}/bookings/services/{serviceId}",
    method: "PUT",
    auth: "user",
    responseKind: "json"
  },
  deleteAppointmentService: {
    path: "/sites/{siteId}/bookings/services/{serviceId}",
    method: "DELETE",
    auth: "user",
    responseKind: "json"
  },
  getAppointmentServicesReference: {
    path: "/sites/{siteId}/bookings/services/reference",
    method: "GET",
    auth: "user",
    responseKind: "json"
  },
  getAppointmentResourcesReference: {
    path: "/sites/{siteId}/bookings/resources/reference",
    method: "GET",
    auth: "user",
    responseKind: "json"
  },
  // Service-Resource linking
  getResourceServices: {
    path: "/sites/{siteId}/bookings/resources/{resourceId}/services",
    method: "GET",
    auth: "user",
    responseKind: "json"
  },
  updateResourceServices: {
    path: "/sites/{siteId}/bookings/resources/{resourceId}/services",
    method: "PUT",
    auth: "user",
    responseKind: "json"
  },
  getServiceResources: {
    path: "/sites/{siteId}/bookings/services/{serviceId}/resources",
    method: "GET",
    auth: "user",
    responseKind: "json"
  },
  updateServiceResources: {
    path: "/sites/{siteId}/bookings/services/{serviceId}/resources",
    method: "PUT",
    auth: "user",
    responseKind: "json"
  },
  // Availability management
  listAvailabilityRules: {
    path: "/sites/{siteId}/bookings/resources/{resourceId}/availability",
    method: "GET",
    auth: "user",
    responseKind: "json"
  },
  upsertAvailabilityRule: {
    path: "/sites/{siteId}/bookings/resources/{resourceId}/availability",
    method: "POST",
    auth: "user",
    responseKind: "json"
  },
  deleteAvailabilityRule: {
    path: "/sites/{siteId}/bookings/resources/{resourceId}/availability/{ruleId}",
    method: "DELETE",
    auth: "user",
    responseKind: "json"
  },
  listBlackouts: {
    path: "/sites/{siteId}/bookings/resources/{resourceId}/blackouts",
    method: "GET",
    auth: "user",
    responseKind: "json"
  },
  createBlackout: {
    path: "/sites/{siteId}/bookings/resources/{resourceId}/blackouts",
    method: "POST",
    auth: "user",
    responseKind: "json"
  },
  deleteBlackout: {
    path: "/sites/{siteId}/bookings/resources/{resourceId}/blackouts/{blackoutId}",
    method: "DELETE",
    auth: "user",
    responseKind: "json"
  },
  getAvailableSlots: {
    path: "/sites/{siteId}/bookings/availability/slots",
    method: "GET",
    auth: "user",
    responseKind: "json"
  },
  createAppointment: {
    path: "/sites/{siteId}/bookings/appointments",
    method: "POST",
    auth: "user",
    responseKind: "json"
  },
  // Data retrieval endpoints - good candidates for caching
  getBrief: {
    path: "/briefs",
    method: "GET",
    revalidate: 120,
    // 2 minutes
    tags: ["brief"],
    auth: "user",
    responseKind: "json"
  },
  // Unified site data endpoint - use this for all site lookups
  getSite: {
    path: "/sites",
    method: "GET",
    revalidate: 900,
    // 15 minutes - site data changes less frequently
    tags: ["site"],
    auth: "user",
    responseKind: "json"
  },
  // DEPRECATED: Use getSite with ?slug={slug} instead
  getSiteBySlug: {
    path: "/sites/by-slug/{slug}",
    method: "GET",
    revalidate: 900,
    // 15 minutes - site data changes less frequently
    tags: ["site", "site-{slug}"],
    auth: "user",
    responseKind: "json"
  },
  // DEPRECATED: Use getSite with ?domain={domain} instead
  getSiteByDomain: {
    path: "/sites/by-domain/{domain}",
    method: "GET",
    revalidate: 900,
    // 15 minutes - site data changes less frequently
    tags: ["site", "site-domain-{domain}"],
    auth: "user",
    responseKind: "json"
  },
  createBriefTurn: {
    path: "/brief-turns",
    method: "POST",
    tags: ["brief"],
    // Tags for invalidation after mutation
    auth: "user",
    responseKind: "json"
  },
  upsertBrief: {
    path: "/briefs",
    method: "PUT",
    tags: ["brief"],
    auth: "user",
    responseKind: "json"
  },
  aiBriefToSpec: {
    path: "/ai/actions/brief-to-spec",
    method: "POST",
    tags: ["brief", "spec"],
    auth: "user",
    responseKind: "json"
  },
  createSite: {
    path: "/sites",
    method: "POST",
    tags: ["site"],
    auth: "user",
    responseKind: "json"
  },
  createSiteManual: {
    path: "/sites/manual",
    method: "POST",
    tags: ["site"],
    auth: "user",
    responseKind: "json"
  },
  updateSite: {
    path: "/sites",
    method: "PUT",
    tags: ["site"],
    auth: "user",
    responseKind: "json"
  },
  deleteSite: {
    path: "/sites/{siteId}",
    method: "DELETE",
    tags: ["site", "site-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  listSiteMembers: {
    path: "/sites/{siteId}/members",
    method: "GET",
    tags: ["site-{siteId}", "site-members-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  inviteSiteMember: {
    path: "/sites/{siteId}/members",
    method: "POST",
    tags: ["site-{siteId}", "site-members-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  updateSiteMemberRole: {
    path: "/sites/{siteId}/members/{memberId}",
    method: "PATCH",
    tags: ["site-{siteId}", "site-members-{siteId}", "site-member-{memberId}"],
    auth: "user",
    responseKind: "json"
  },
  authLogin: {
    path: "/auth/login/submit",
    method: "POST",
    tags: ["auth"],
    auth: "public",
    responseKind: "json"
  },
  authForgotPassword: {
    path: "/auth/forgot/submit",
    method: "POST",
    tags: ["auth"],
    auth: "public",
    responseKind: "json"
  },
  authRegister: {
    path: "/auth/register/submit",
    method: "POST",
    tags: ["auth"],
    auth: "public",
    responseKind: "json"
  },
  authReauthenticate: {
    path: "/auth/reauth/submit",
    method: "POST",
    tags: ["auth"],
    auth: "public",
    responseKind: "json"
  },
  lookupSiteDomains: {
    path: "/sites/{siteId}/domains/lookup",
    method: "POST",
    tags: ["site-{siteId}", "site-domains"],
    auth: "user",
    responseKind: "json"
  },
  registerSiteDomain: {
    path: "/sites/{siteId}/domains/register",
    method: "POST",
    tags: ["site-{siteId}", "site-domains"],
    auth: "user",
    responseKind: "json"
  },
  addCustomDomain: {
    path: "/sites/{siteId}/domains/custom",
    method: "POST",
    tags: ["site-{siteId}", "site-domains"],
    auth: "user",
    responseKind: "json"
  },
  removeCustomDomain: {
    path: "/sites/{siteId}/domains/custom",
    method: "DELETE",
    tags: ["site-{siteId}", "site-domains"],
    auth: "user",
    responseKind: "json"
  },
  syncCustomDomainToEdgeConfig: {
    path: "/sites/{siteId}/domains/custom/sync",
    method: "POST",
    tags: ["site-{siteId}", "site-domains"],
    auth: "user",
    responseKind: "json"
  },
  removeSiteMember: {
    path: "/sites/{siteId}/members/{memberId}",
    method: "DELETE",
    tags: ["site-{siteId}", "site-members-{siteId}", "site-member-{memberId}"],
    auth: "user",
    responseKind: "json"
  },
  revokeSiteInvitation: {
    path: "/sites/{siteId}/members/invitations/{invitationId}",
    method: "DELETE",
    tags: ["site-{siteId}", "site-members-{siteId}", "site-invite-{invitationId}"],
    auth: "user",
    responseKind: "json"
  },
  transferSiteOwnership: {
    path: "/sites/{siteId}/members/transfer-ownership",
    method: "POST",
    tags: ["site-{siteId}", "site-members-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  listContentEntries: {
    path: "/sites/{siteId}/content/{type}",
    method: "GET",
    revalidate: 60,
    tags: ["site-{siteId}", "content-{siteId}-{type}"],
    auth: "user",
    responseKind: "json"
  },
  getContentTemplate: {
    path: "/sites/{siteId}/content/types/{type}/template",
    method: "GET",
    revalidate: 60,
    tags: ["site-{siteId}", "content-template-{siteId}-{type}"],
    auth: "user",
    responseKind: "json"
  },
  updateContentTemplateBlock: {
    path: "/sites/{siteId}/content/types/{type}/template/blocks/{blockId}",
    method: "PATCH",
    tags: ["site-{siteId}", "content-template-{siteId}-{type}", "content-template-block-{blockId}"],
    auth: "user",
    responseKind: "json"
  },
  applyContentTemplateAddon: {
    path: "/sites/{siteId}/content/types/{type}/template/addons",
    method: "POST",
    tags: ["site-{siteId}", "content-template-{siteId}-{type}"],
    auth: "user",
    responseKind: "json"
  },
  updateContentTemplateBlockBindings: {
    path: "/sites/{siteId}/content/types/{type}/template/blocks/{blockId}/bindings",
    method: "PATCH",
    tags: ["site-{siteId}", "content-template-{siteId}-{type}", "content-template-block-{blockId}"],
    auth: "user",
    responseKind: "json"
  },
  createTemplateBlock: {
    path: "/sites/{siteId}/content/types/{type}/template/blocks",
    method: "POST",
    tags: ["site-{siteId}", "content-template-{siteId}-{type}"],
    auth: "user",
    responseKind: "json"
  },
  deleteTemplateBlock: {
    path: "/sites/{siteId}/content/types/{type}/template/blocks/{blockId}",
    method: "DELETE",
    tags: ["site-{siteId}", "content-template-{siteId}-{type}", "content-template-block-{blockId}"],
    auth: "user",
    responseKind: "json"
  },
  reorderTemplateBlocks: {
    path: "/sites/{siteId}/content/types/{type}/template/blocks/reorder",
    method: "POST",
    tags: ["site-{siteId}", "content-template-{siteId}-{type}"],
    auth: "user",
    responseKind: "json"
  },
  getTransforms: {
    path: "/transforms",
    method: "GET",
    revalidate: 3600,
    tags: ["transforms"],
    auth: "public",
    responseKind: "json"
  },
  createContentEntry: {
    path: "/sites/{siteId}/content/{type}",
    method: "POST",
    tags: ["site-{siteId}", "content-{siteId}-{type}"],
    auth: "user",
    responseKind: "json"
  },
  getContentEntry: {
    path: "/sites/{siteId}/content/{type}/{entryId}",
    method: "GET",
    tags: ["site-{siteId}", "content-{siteId}-{type}", "content-entry-{entryId}"],
    auth: "user",
    responseKind: "json"
  },
  updateContentEntry: {
    path: "/sites/{siteId}/content/{type}/{entryId}",
    method: "PUT",
    tags: ["site-{siteId}", "content-{siteId}-{type}", "content-entry-{entryId}"],
    auth: "user",
    responseKind: "json"
  },
  updateContentEntryContent: {
    path: "/sites/{siteId}/content/{type}/{entryId}/content",
    method: "PUT",
    tags: ["site-{siteId}", "content-{siteId}-{type}", "content-entry-{entryId}"],
    auth: "user",
    responseKind: "json"
  },
  updateRouteMetadata: {
    path: "/sites/{siteId}/routes/{routeId}/metadata",
    method: "PATCH",
    tags: ["site-{siteId}", "route-{routeId}"],
    auth: "user",
    responseKind: "json"
  },
  publishContentEntry: {
    path: "/sites/{siteId}/content/{type}/{entryId}/publish",
    method: "POST",
    tags: ["site-{siteId}", "content-{siteId}-{type}", "content-entry-{entryId}"],
    auth: "user",
    responseKind: "json"
  },
  discardContentEntry: {
    path: "/sites/{siteId}/content/{type}/{entryId}/discard",
    method: "POST",
    tags: ["site-{siteId}", "content-{siteId}-{type}", "content-entry-{entryId}"],
    auth: "user",
    responseKind: "json"
  },
  unpublishContentEntry: {
    path: "/sites/{siteId}/content/{type}/{entryId}/unpublish",
    method: "POST",
    tags: ["site-{siteId}", "content-{siteId}-{type}", "content-entry-{entryId}"],
    auth: "user",
    responseKind: "json"
  },
  // Content types: enable + setup
  listContentTypes: {
    path: "/sites/{siteId}/content-types",
    method: "GET",
    revalidate: 120,
    // 2 minutes
    tags: ["site-{siteId}", "content-types"],
    auth: "user",
    responseKind: "json"
  },
  enableContentType: {
    path: "/sites/{siteId}/content-types/{key}/enable",
    method: "POST",
    tags: ["site-{siteId}", "content-types", "content-type-{key}"],
    auth: "user",
    responseKind: "json"
  },
  setupContentType: {
    path: "/sites/{siteId}/content-types/{key}/setup",
    method: "POST",
    tags: ["site-{siteId}", "content-types", "content-type-{key}"],
    auth: "user",
    responseKind: "json"
  },
  deleteContentEntry: {
    path: "/sites/{siteId}/content/{type}/{entryId}",
    method: "DELETE",
    tags: ["site-{siteId}", "content-{siteId}-{type}", "content-entry-{entryId}"],
    auth: "user",
    responseKind: "json"
  },
  updateSiteGeneralSettings: {
    path: "/sites/{siteId}/settings/general",
    method: "POST",
    tags: ["site-{siteId}", "site-settings-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  getSiteLayoutSettings: {
    path: "/sites/{siteId}/settings/layout",
    method: "GET",
    revalidate: 120,
    tags: ["site-{siteId}", "site-settings-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  updateSiteLayoutSettings: {
    path: "/sites/{siteId}/settings/layout",
    method: "POST",
    tags: ["site-{siteId}", "site-settings-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  getMaintenanceSettings: {
    path: "/sites/{siteId}/settings/maintenance",
    method: "GET",
    revalidate: 120,
    tags: ["site-{siteId}", "site-settings-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  updateMaintenanceSettings: {
    path: "/sites/{siteId}/settings/maintenance",
    method: "POST",
    tags: ["site-{siteId}", "site-settings-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  setHomepage: {
    path: "/sites/{siteId}/settings/homepage",
    method: "POST",
    tags: ["site-{siteId}", "site-homepage"],
    auth: "user",
    responseKind: "json"
  },
  listAccountDomains: {
    path: "/domains",
    method: "GET",
    tags: ["domains"],
    auth: "user",
    responseKind: "json"
  },
  searchDomains: {
    path: "/domains/search",
    method: "POST",
    tags: ["domains"],
    auth: "user",
    responseKind: "json"
  },
  registerDomain: {
    path: "/domains/register",
    method: "POST",
    tags: ["domains"],
    auth: "user",
    responseKind: "json"
  },
  assignDomain: {
    path: "/domains/{domainId}/assign",
    method: "POST",
    tags: ["domains", "domain-{domainId}"],
    auth: "user",
    responseKind: "json"
  },
  adminStartImpersonation: {
    path: "/admin/impersonation/start",
    method: "POST",
    tags: ["admin", "impersonation"],
    auth: "user",
    responseKind: "json"
  },
  adminStopImpersonation: {
    path: "/admin/impersonation/stop",
    method: "POST",
    tags: ["admin", "impersonation"],
    auth: "user",
    responseKind: "json"
  },
  adminAssignRole: {
    path: "/admin/roles/assign",
    method: "POST",
    tags: ["admin", "roles"],
    auth: "user",
    responseKind: "json"
  },
  adminRevokeRole: {
    path: "/admin/roles/revoke",
    method: "POST",
    tags: ["admin", "roles"],
    auth: "user",
    responseKind: "json"
  },
  adminChangePlan: {
    path: "/admin/billing/plan",
    method: "POST",
    tags: ["admin", "billing"],
    auth: "user",
    responseKind: "json"
  },
  changePlan: {
    path: "/billing/plan/change",
    method: "POST",
    tags: ["billing"],
    auth: "user",
    responseKind: "json"
  },
  mfaTotpEnroll: {
    path: "/auth/mfa/totp/enroll",
    method: "POST",
    tags: ["mfa"],
    auth: "user",
    responseKind: "json"
  },
  mfaTotpVerify: {
    path: "/auth/mfa/totp/verify",
    method: "POST",
    tags: ["mfa"],
    auth: "user",
    responseKind: "json"
  },
  mfaTotpActivate: {
    path: "/auth/mfa/totp/activate",
    method: "POST",
    tags: ["mfa"],
    auth: "user",
    responseKind: "json"
  },
  mfaDeleteFactor: {
    path: "/auth/mfa/factors/{factorId}",
    method: "DELETE",
    tags: ["mfa"],
    auth: "user",
    responseKind: "json"
  },
  mfaBackupCodesGet: {
    path: "/auth/mfa/backup-codes",
    method: "GET",
    tags: ["mfa"],
    auth: "user",
    responseKind: "json"
  },
  mfaBackupCodesRotate: {
    path: "/auth/mfa/backup-codes/rotate",
    method: "POST",
    tags: ["mfa"],
    auth: "user",
    responseKind: "json"
  },
  mfaPhoneEnroll: {
    path: "/auth/mfa/phone/enroll",
    method: "POST",
    tags: ["mfa"],
    auth: "user",
    responseKind: "json"
  },
  mfaPhoneChallenge: {
    path: "/auth/mfa/phone/challenge",
    method: "POST",
    tags: ["mfa"],
    auth: "user",
    responseKind: "json"
  },
  mfaPhoneVerify: {
    path: "/auth/mfa/phone/verify",
    method: "POST",
    tags: ["mfa"],
    auth: "user",
    responseKind: "json"
  },
  accountUpdatePassword: {
    path: "/account/password/update",
    method: "POST",
    tags: ["account"],
    auth: "user",
    responseKind: "json"
  },
  accountRevokeSessions: {
    path: "/account/sessions/revoke",
    method: "POST",
    tags: ["account"],
    auth: "user",
    responseKind: "json"
  },
  adminListInvites: {
    path: "/admin/invites",
    method: "GET",
    tags: ["admin", "invites"],
    auth: "user",
    responseKind: "json"
  },
  adminCreateInvite: {
    path: "/admin/invites",
    method: "POST",
    tags: ["admin", "invites"],
    auth: "user",
    responseKind: "json"
  },
  adminRevokeInvite: {
    path: "/admin/invites/{inviteId}",
    method: "DELETE",
    tags: ["admin", "invites"],
    auth: "user",
    responseKind: "json"
  },
  adminCreateUser: {
    path: "/admin/users",
    method: "POST",
    tags: ["admin", "users"],
    auth: "admin",
    responseKind: "json"
  },
  adminListAllowedDomains: {
    path: "/admin/allowed-domains",
    method: "GET",
    tags: ["admin", "allowed-domains"],
    auth: "user",
    responseKind: "json"
  },
  adminAddAllowedDomain: {
    path: "/admin/allowed-domains",
    method: "POST",
    tags: ["admin", "allowed-domains"],
    auth: "user",
    responseKind: "json"
  },
  adminDeleteAllowedDomain: {
    path: "/admin/allowed-domains/{domainId}",
    method: "DELETE",
    tags: ["admin", "allowed-domains"],
    auth: "user",
    responseKind: "json"
  },
  authAcceptInvite: {
    path: "/auth/invite/accept",
    method: "POST",
    tags: ["auth", "invite"],
    auth: "user",
    responseKind: "json"
  },
  acceptSiteInvitation: {
    path: "/sites/invitations/accept",
    method: "POST",
    tags: ["site-invitations"],
    auth: "user",
    responseKind: "json"
  },
  getNavigationMenus: {
    path: "/sites/{siteId}/navigation/menus",
    method: "GET",
    tags: ["site-{siteId}", "navigation"],
    auth: "user",
    responseKind: "json"
  },
  createNavigationMenu: {
    path: "/sites/{siteId}/navigation/menus",
    method: "POST",
    tags: ["site-{siteId}", "navigation"],
    auth: "user",
    responseKind: "json"
  },
  updateNavigationMenu: {
    path: "/sites/{siteId}/navigation/menus/{menuId}",
    method: "PATCH",
    tags: ["site-{siteId}", "navigation", "navigation-menu-{menuId}"],
    auth: "user",
    responseKind: "json"
  },
  deleteNavigationMenu: {
    path: "/sites/{siteId}/navigation/menus/{menuId}",
    method: "DELETE",
    tags: ["site-{siteId}", "navigation", "navigation-menu-{menuId}"],
    auth: "user",
    responseKind: "json"
  },
  createNavigationItem: {
    path: "/sites/{siteId}/navigation/menus/{menuId}/items",
    method: "POST",
    tags: ["site-{siteId}", "navigation", "navigation-menu-{menuId}"],
    auth: "user",
    responseKind: "json"
  },
  updateNavigationItem: {
    path: "/sites/{siteId}/navigation/menus/{menuId}/items/{itemId}",
    method: "PATCH",
    tags: ["site-{siteId}", "navigation", "navigation-menu-{menuId}", "navigation-item-{itemId}"],
    auth: "user",
    responseKind: "json"
  },
  deleteNavigationItem: {
    path: "/sites/{siteId}/navigation/menus/{menuId}/items/{itemId}",
    method: "DELETE",
    tags: ["site-{siteId}", "navigation", "navigation-menu-{menuId}", "navigation-item-{itemId}"],
    auth: "user",
    responseKind: "json"
  },
  reorderNavigationItems: {
    path: "/sites/{siteId}/navigation/menus/{menuId}/items/reorder",
    method: "POST",
    tags: ["site-{siteId}", "navigation", "navigation-menu-{menuId}"],
    auth: "user",
    responseKind: "json"
  },
  getRoutableContent: {
    path: "/sites/{siteId}/routable-content",
    method: "GET",
    revalidate: 60,
    tags: ["site-{siteId}", "routable-content-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  // Generic public content preview (preferred)
  getPublishedEntryPreview: {
    path: "/public/content/{siteId}/{type}/{slug}/preview",
    method: "GET",
    revalidate: 60,
    tags: ["content-{siteId}-{type}-{slug}"],
    auth: "public",
    responseKind: "json"
  },
  listPublishedEntries: {
    path: "/public/content/{siteId}/{type}/entries",
    method: "GET",
    revalidate: 60,
    tags: ["content-{siteId}-{type}"],
    auth: "public",
    responseKind: "json"
  },
  getPublishedPostPreview: {
    path: "/public/posts/{siteId}/{slug}/preview",
    method: "GET",
    revalidate: 60,
    tags: ["blog-post:{siteId}:{slug}"],
    auth: "public",
    responseKind: "json"
  },
  proposalsSelect: {
    path: "/proposals/select",
    method: "POST",
    tags: ["proposal", "site"],
    auth: "user",
    responseKind: "json"
  },
  createTheme: {
    path: "/ai/chat/create-theme",
    method: "POST",
    revalidate: 60,
    // 1 minute cache for theme creation to avoid duplicate requests
    tags: ["theme", "ai-theme"],
    auth: "user",
    responseKind: "json"
  },
  generateThemes: {
    path: "/theme/generate",
    method: "POST",
    tags: ["theme"],
    auth: "user",
    responseKind: "json"
  },
  extractThemeFromInspiration: {
    path: "/theme/extract-from-inspiration",
    method: "POST",
    tags: ["theme", "preferences"],
    auth: "user",
    responseKind: "json"
  },
  saveSiteTheme: {
    path: "/sites/{siteId}/theme/save",
    method: "POST",
    tags: ["site-{siteId}", "theme"],
    auth: "user",
    responseKind: "json"
  },
  uploadSiteLogo: {
    path: "/storage/upload-site-logo",
    method: "POST",
    tags: ["site", "logo"],
    auth: "user",
    responseKind: "json"
  },
  upsertThemePreferences: {
    path: "/theme-preferences/upsert",
    method: "POST",
    tags: ["theme", "preferences"],
    auth: "user",
    responseKind: "json"
  },
  finalizeSite: {
    path: "/sites/finalize",
    method: "POST",
    tags: ["site"],
    auth: "user",
    responseKind: "json"
  },
  instagramUploadZip: {
    path: "/api/instagram/upload-zip",
    method: "POST",
    tags: ["instagram-import"],
    auth: "user",
    responseKind: "json"
  },
  getAnalyticsReport: {
    path: "/sites/{siteId}/analytics/report",
    method: "GET",
    revalidate: 300,
    tags: ["site-{siteId}", "analytics-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  getSeoOverview: {
    path: "/sites/{siteId}/seo/overview",
    method: "GET",
    revalidate: 300,
    tags: ["site-{siteId}", "seo-overview-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  getSeoPages: {
    path: "/sites/{siteId}/seo/pages",
    method: "GET",
    revalidate: 300,
    tags: ["site-{siteId}", "seo-pages-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  getSeoQueries: {
    path: "/sites/{siteId}/seo/queries",
    method: "GET",
    revalidate: 300,
    tags: ["site-{siteId}", "seo-queries-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  getPerformanceOverview: {
    path: "/sites/{siteId}/performance/overview",
    method: "GET",
    revalidate: 300,
    tags: ["site-{siteId}", "performance-overview-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  createMediaAsset: {
    path: "/media",
    method: "POST",
    tags: ["media"],
    auth: "user",
    responseKind: "json"
  },
  mediaList: {
    path: "/media",
    method: "GET",
    tags: ["media"],
    auth: "user",
    responseKind: "json"
  },
  mediaGet: {
    path: "/media/{assetId}",
    method: "GET",
    tags: ["media", "media-{assetId}"],
    auth: "user",
    responseKind: "json"
  },
  mediaUpdate: {
    path: "/media/{assetId}",
    method: "PATCH",
    tags: ["media", "media-{assetId}"],
    auth: "user",
    responseKind: "json"
  },
  mediaDelete: {
    path: "/media/{assetId}",
    method: "DELETE",
    tags: ["media", "media-{assetId}"],
    auth: "user",
    responseKind: "void"
  },
  mediaBulkDelete: {
    path: "/media/bulk-delete",
    method: "POST",
    tags: ["media"],
    auth: "user",
    responseKind: "json"
  },
  mediaGetSignedUrl: {
    path: "/media/{assetId}/signed-url",
    method: "GET",
    tags: ["media", "media-{assetId}"],
    auth: "user",
    responseKind: "json"
  },
  mediaUpload: {
    path: "/media/upload",
    method: "POST",
    tags: ["media"],
    auth: "user",
    responseKind: "json"
  },
  getMediaLabels: {
    path: "/media/labels",
    method: "GET",
    tags: ["media", "media-labels"],
    auth: "user",
    responseKind: "json"
  },
  getMediaSettings: {
    path: "/media/settings",
    method: "GET",
    tags: ["media-settings"],
    auth: "user",
    responseKind: "json"
  },
  updateMediaSettings: {
    path: "/media/settings",
    method: "POST",
    tags: ["media-settings"],
    auth: "user",
    responseKind: "json"
  },
  // Media endpoints
  mediaSearch: {
    path: "/media/search",
    method: "POST",
    tags: ["media-search"],
    auth: "user",
    responseKind: "json"
  },
  classifyMediaAsset: {
    path: "/media/{assetId}/classify",
    method: "POST",
    tags: ["media", "media-{assetId}"],
    auth: "user",
    responseKind: "json"
  },
  classifyMediaBatch: {
    path: "/media/classify",
    method: "POST",
    tags: ["media"],
    auth: "user",
    responseKind: "json"
  },
  mediaJobsStatus: {
    path: "/media/jobs/status",
    method: "GET",
    tags: ["media"],
    auth: "user",
    responseKind: "json"
  },
  enqueueMediaClassifyJob: {
    path: "/media/jobs",
    method: "POST",
    tags: ["media"],
    auth: "user",
    responseKind: "json"
  },
  runMediaClassifyJob: {
    path: "/media/jobs/run",
    method: "POST",
    tags: ["media"],
    auth: "user",
    responseKind: "json"
  },
  runAllMediaClassifyJobs: {
    path: "/media/jobs/run-all",
    method: "POST",
    tags: ["media"],
    auth: "user",
    responseKind: "json"
  },
  initSiteContent: {
    path: "/sites/{siteId}/content/init",
    method: "POST",
    tags: ["site", "content"],
    auth: "user",
    responseKind: "json"
  },
  updateBlockContent: {
    path: "/blocks/{blockId}/content",
    method: "POST",
    tags: ["block", "block-{blockId}", "content"],
    auth: "user",
    responseKind: "json"
  },
  saveBlockContent: {
    path: "/blocks/{blockId}/content",
    method: "POST",
    tags: ["block", "block-{blockId}", "content"],
    auth: "user",
    responseKind: "json"
  },
  createBlock: {
    path: "/sites/{siteId}/pages/{pageId}/blocks",
    method: "POST",
    tags: ["site-{siteId}", "page-{pageId}", "blocks"],
    auth: "user",
    responseKind: "json"
  },
  reorderBlocks: {
    path: "/sites/{siteId}/pages/{pageId}/blocks/reorder",
    method: "POST",
    tags: ["site-{siteId}", "page-{pageId}", "blocks"],
    auth: "user",
    responseKind: "json"
  },
  deleteBlock: {
    path: "/sites/{siteId}/pages/{pageId}/blocks/{blockId}",
    method: "DELETE",
    tags: ["site-{siteId}", "page-{pageId}", "blocks"],
    auth: "user",
    responseKind: "json"
  },
  listBlocks: {
    path: "/sites/{siteId}/pages/{pageId}/blocks",
    method: "GET",
    tags: ["site-{siteId}", "page-{pageId}", "blocks"],
    auth: "user",
    responseKind: "json"
  },
  getBlockContent: {
    path: "/blocks/{blockId}/content",
    method: "GET",
    tags: ["block-{blockId}", "content"],
    auth: "user",
    responseKind: "json"
  },
  // DEPRECATED: Use getSite with ?id={id} instead
  getSiteById: {
    path: "/sites/by-id/{id}",
    method: "GET",
    revalidate: 900,
    // 15 minutes
    tags: ["site-{id}"],
    auth: "user",
    responseKind: "json"
  },
  // Page data endpoints
  getPageById: {
    path: "/sites/{siteId}/pages/{pageId}",
    method: "GET",
    revalidate: 900,
    // 15 minutes
    tags: ["site-{siteId}", "page-{pageId}"],
    auth: "user",
    responseKind: "json"
  },
  getContentByPath: {
    path: "/sites/{siteId}/pages",
    method: "GET",
    tags: ["site-{siteId}", "routable-content-{siteId}"],
    auth: "public",
    responseKind: "json"
  },
  getPageByPath: {
    path: "/sites/{siteId}/pages",
    method: "GET",
    tags: ["site-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  // Forms CRUD
  listForms: {
    path: "/sites/{siteId}/forms",
    method: "GET",
    tags: ["site-{siteId}", "forms"],
    auth: "user",
    responseKind: "json"
  },
  listBookingForms: {
    path: "/sites/{siteId}/bookings/forms",
    method: "GET",
    tags: ["site-{siteId}", "forms"],
    auth: "user",
    responseKind: "json"
  },
  createForm: {
    path: "/sites/{siteId}/forms",
    method: "POST",
    tags: ["site-{siteId}", "forms"],
    auth: "user",
    responseKind: "json"
  },
  updateForm: {
    path: "/sites/{siteId}/forms/{slug}",
    method: "PATCH",
    tags: ["site-{siteId}", "forms", "form-{slug}"],
    auth: "user",
    responseKind: "json"
  },
  deleteForm: {
    path: "/sites/{siteId}/forms/{slug}",
    method: "DELETE",
    tags: ["site-{siteId}", "forms", "form-{slug}"],
    auth: "user",
    responseKind: "json"
  },
  listFormSubmissions: {
    path: "/sites/{siteId}/forms/{slug}/submissions",
    method: "GET",
    revalidate: 30,
    tags: ["site-{siteId}", "form-{slug}", "form-submissions-{slug}"],
    auth: "user",
    responseKind: "json"
  },
  // Public submit
  submitForm: {
    path: "/forms/submit",
    method: "POST",
    tags: ["forms-submit"],
    auth: "public",
    responseKind: "json"
  },
  // Public forms
  getPublicFormById: {
    path: "/public/forms/{formId}",
    method: "GET",
    revalidate: 60,
    tags: ["form-{formId}"],
    auth: "public",
    responseKind: "json"
  },
  // Public booking services
  getPublicBookingServices: {
    path: "/public/bookings/services",
    method: "GET",
    revalidate: 60,
    tags: ["site-{siteId}"],
    auth: "public",
    responseKind: "json"
  },
  devToolsImpersonateAdmin: {
    path: "/dev-tools/impersonate/admin",
    method: "POST",
    auth: "admin",
    responseKind: "json"
  },
  devToolsImpersonateRandom: {
    path: "/dev-tools/impersonate/random",
    method: "POST",
    auth: "admin",
    responseKind: "json"
  },
  devToolsSeedDemoData: {
    path: "/dev-tools/seed",
    method: "POST",
    auth: "admin",
    responseKind: "json"
  },
  // Public analytics collection endpoint
  analyticsCollect: {
    path: "/api/analytics/collect",
    method: "POST",
    auth: "public",
    responseKind: "json"
  },
  // Public events for event calendar block
  listPublicEvents: {
    path: "/public/sites/{siteId}/events",
    method: "GET",
    revalidate: 60,
    tags: ["public-events-{siteId}"],
    auth: "public",
    responseKind: "json"
  },
  // Public event registration
  registerForEvent: {
    path: "/public/sites/{siteId}/events/register",
    method: "POST",
    tags: ["public-events-{siteId}", "event-registration"],
    auth: "public",
    responseKind: "json"
  },
  // Content Types CRUD
  listSiteContentTypes: {
    path: "/sites/{siteId}/content-types",
    method: "GET",
    revalidate: 60,
    tags: ["site-{siteId}", "content-types-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  getContentType: {
    path: "/sites/{siteId}/content-types/by-id/{typeId}",
    method: "GET",
    revalidate: 60,
    tags: ["site-{siteId}", "content-type-{typeId}"],
    auth: "user",
    responseKind: "json"
  },
  createContentType: {
    path: "/sites/{siteId}/content-types",
    method: "POST",
    tags: ["site-{siteId}", "content-types-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  updateContentType: {
    path: "/sites/{siteId}/content-types/by-id/{typeId}",
    method: "PATCH",
    tags: ["site-{siteId}", "content-type-{typeId}", "content-types-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  deleteContentType: {
    path: "/sites/{siteId}/content-types/by-id/{typeId}",
    method: "DELETE",
    tags: ["site-{siteId}", "content-type-{typeId}", "content-types-{sideId}"],
    auth: "user",
    responseKind: "json"
  },
  duplicateContentType: {
    path: "/sites/{siteId}/content-types/by-id/{typeId}/duplicate",
    method: "POST",
    tags: ["site-{siteId}", "content-type-{typeId}", "content-types-{siteId}"],
    auth: "user",
    responseKind: "json"
  },
  // Admin site creation
  adminCreateSite: {
    path: "/admin/sites",
    method: "POST",
    tags: ["admin", "sites"],
    auth: "admin",
    responseKind: "json"
  },
  // SDK Config
  refreshSdkConfig: {
    path: "/sites/{siteId}/refresh-sdk-config",
    method: "POST",
    tags: ["site-{siteId}", "sdk-config"],
    auth: "user",
    responseKind: "json"
  },
  // Stripe Connect - Site billing
  stripeConnectAuthorize: {
    path: "/sites/{siteId}/billing/connect/authorize",
    method: "POST",
    tags: ["site-{siteId}", "stripe-connect"],
    auth: "user",
    responseKind: "json"
  },
  stripeConnectStatus: {
    path: "/sites/{siteId}/billing/connect/status",
    method: "GET",
    tags: ["site-{siteId}", "stripe-connect"],
    auth: "user",
    responseKind: "json"
  },
  stripeConnectDisconnect: {
    path: "/sites/{siteId}/billing/connect/disconnect",
    method: "DELETE",
    tags: ["site-{siteId}", "stripe-connect"],
    auth: "user",
    responseKind: "json"
  },
  // Backup
  importSiteBackup: {
    path: "/sites/{siteId}/backup/import",
    method: "POST",
    tags: ["site-{siteId}", "backup"],
    auth: "user",
    responseKind: "json"
  },
  previewBackup: {
    path: "/backup/preview",
    method: "POST",
    tags: ["backup"],
    auth: "user",
    responseKind: "json"
  },
  importBackupAsNewSite: {
    path: "/sites/backup/import-as-new",
    method: "POST",
    tags: ["site", "backup"],
    auth: "user",
    responseKind: "json"
  },
  // Admin billing price overrides
  adminGetPriceOverride: {
    path: "/admin/billing/price-override",
    method: "GET",
    tags: ["admin", "billing", "price-override"],
    auth: "admin",
    responseKind: "json"
  },
  adminUpsertPriceOverride: {
    path: "/admin/billing/price-override",
    method: "POST",
    tags: ["admin", "billing", "price-override"],
    auth: "admin",
    responseKind: "json"
  },
  adminDeletePriceOverride: {
    path: "/admin/billing/price-override",
    method: "DELETE",
    tags: ["admin", "billing", "price-override"],
    auth: "admin",
    responseKind: "json"
  }
};
var API_ENDPOINTS = ENDPOINT_DEFINITIONS;
function buildEndpointURL(baseURL, endpoint) {
  return baseURL + API_ENDPOINTS[endpoint].path;
}

// ../api/src/url.ts
function getCmsApiUrl() {
  if (typeof window !== "undefined") {
    return "/api";
  }
  const internalUrl = process.env.CMS_API_URL;
  if (internalUrl) {
    return internalUrl.replace(/\/$/, "");
  }
  const dashboardUrl = process.env.NEXT_PUBLIC_DASHBOARD_URL;
  if (dashboardUrl) {
    const base = dashboardUrl.replace(/\/$/, "");
    return `${base}/api`;
  }
  const legacyApiUrl = process.env.NEXT_PUBLIC_CMS_API_URL;
  if (legacyApiUrl) {
    return legacyApiUrl.replace(/\/$/, "");
  }
  throw new Error(
    "NEXT_PUBLIC_DASHBOARD_URL is not configured. Set it to your dashboard URL (e.g., http://dashboard.local:4000)"
  );
}
function resolveApiBaseUrl() {
  return getCmsApiUrl();
}

// ../api/src/request.ts
var revalidateTag = null;
if (typeof window === "undefined") {
  try {
    const nextCache = _chunkDGUM43GVjs.__require.call(void 0, "next/cache");
    revalidateTag = nextCache.revalidateTag;
  } catch (e) {
    revalidateTag = null;
  }
}
var ApiRequestError = class extends Error {
  constructor(message, options) {
    super(message);
    this.name = "ApiRequestError";
    this.endpoint = options.endpoint;
    this.status = options.status;
    this.method = options.method;
    this.auth = options.auth;
    this.requestId = options.requestId;
    this.body = options.body;
    this.cause = options.cause;
  }
};
function buildEndpointURL2(baseURL, endpoint) {
  return baseURL + API_ENDPOINTS[endpoint].path;
}
function invalidateCacheTags(tags, params) {
  if (typeof window !== "undefined" || !revalidateTag || !tags) return;
  tags.forEach((tag) => {
    let processedTag = tag;
    if (params) {
      Object.entries(params).forEach(([key, value]) => {
        processedTag = processedTag.replace(`{${key}}`, String(value));
      });
    }
    try {
      revalidateTag(processedTag, "max");
    } catch (e2) {
    }
  });
}
async function parseErrorBody(response) {
  const clone = response.clone();
  const contentType = _nullishCoalesce(clone.headers.get("content-type"), () => ( ""));
  if (contentType.includes("application/json")) {
    try {
      return await clone.json();
    } catch (e3) {
    }
  }
  try {
    const text = await clone.text();
    return text.length ? text : null;
  } catch (e4) {
    return null;
  }
}
async function parseSuccessResponse(endpoint, response, config) {
  const responseKind = _nullishCoalesce(config.responseKind, () => ( "json"));
  const auth = _nullishCoalesce(config.auth, () => ( "user"));
  const requestId = _nullishCoalesce(response.headers.get("x-request-id"), () => ( void 0));
  switch (responseKind) {
    case "json": {
      if (response.status === 204 || response.status === 205 || response.status === 304) {
        return void 0;
      }
      const raw = await response.text();
      if (!raw.trim()) {
        return void 0;
      }
      try {
        return JSON.parse(raw);
      } catch (cause) {
        throw new ApiRequestError(
          `Failed to parse JSON response for endpoint ${String(endpoint)}`,
          {
            endpoint,
            status: response.status,
            method: config.method,
            auth,
            requestId,
            body: raw,
            cause
          }
        );
      }
    }
    case "text": {
      return await response.text();
    }
    case "stream": {
      const body = response.body;
      if (!body) {
        throw new ApiRequestError(
          `Expected a streamed body for endpoint ${String(endpoint)}`,
          {
            endpoint,
            status: response.status,
            method: config.method,
            auth,
            requestId
          }
        );
      }
      const stream = body;
      return stream;
    }
    case "void": {
      return void 0;
    }
    default: {
      return void 0;
    }
  }
}
function createRawCMSClient(headers = {}, baseUrl) {
  return ({
    endpoint,
    body,
    params,
    options = {}
  }) => {
    const resolvedBaseUrl = _nullishCoalesce(baseUrl, () => ( resolveApiBaseUrl()));
    let url = buildEndpointURL2(resolvedBaseUrl, endpoint);
    const originalPath = API_ENDPOINTS[endpoint].path;
    const unusedParams = {};
    if (params) {
      Object.entries(params).forEach(([key, value]) => {
        const placeholder = `{${key}}`;
        if (originalPath.includes(placeholder)) {
          url = url.replace(placeholder, value);
        } else {
          unusedParams[key] = value;
        }
      });
    }
    const endpointConfig = API_ENDPOINTS[endpoint];
    const method = endpointConfig.method;
    const isGetOrHead = method === "GET" || method === "HEAD";
    if (isGetOrHead) {
      const queryParams = new URLSearchParams();
      Object.entries(unusedParams).forEach(([key, value]) => {
        if (value !== void 0 && value !== null) {
          queryParams.append(key, String(value));
        }
      });
      if (body) {
        Object.entries(body).forEach(([key, value]) => {
          if (value !== void 0 && value !== null) {
            queryParams.append(key, String(value));
          }
        });
      }
      const queryString = queryParams.toString();
      if (queryString) {
        url += (url.includes("?") ? "&" : "?") + queryString;
      }
    }
    const isFormData = typeof FormData !== "undefined" && body instanceof FormData;
    const nextOptions = {};
    if (isGetOrHead && "revalidate" in endpointConfig && typeof endpointConfig.revalidate === "number") {
      nextOptions.revalidate = endpointConfig.revalidate;
    }
    if ("tags" in endpointConfig && Array.isArray(endpointConfig.tags)) {
      nextOptions.tags = endpointConfig.tags.map((tag) => {
        let processedTag = tag;
        if (params) {
          Object.entries(params).forEach(([key, value]) => {
            processedTag = processedTag.replace(`{${key}}`, String(value));
          });
        }
        return processedTag;
      });
    }
    const requestInit = {
      method,
      ...options,
      // Don't include body for GET/HEAD requests
      body: isGetOrHead ? void 0 : isFormData ? body : body ? JSON.stringify(body) : void 0,
      headers: {
        ...options.headers,
        ...headers,
        // Don't set Content-Type for GET/HEAD requests without body
        ...isGetOrHead ? {} : isFormData ? {} : { "Content-Type": "application/json" }
      },
      // Add Next.js caching options
      next: Object.keys(nextOptions).length > 0 ? nextOptions : void 0
    };
    const fetchPromise = fetch(url, requestInit);
    if (!isGetOrHead && "tags" in endpointConfig && Array.isArray(endpointConfig.tags)) {
      const tags = endpointConfig.tags.map((tag) => tag);
      return fetchPromise.then((response) => {
        if (response.ok) {
          invalidateCacheTags(tags, params);
        }
        return response;
      });
    }
    return fetchPromise;
  };
}
function createParsedClient(rawClient) {
  return async (params) => {
    const response = await rawClient(params);
    const endpoint = params.endpoint;
    const config = API_ENDPOINTS[endpoint];
    const auth = _nullishCoalesce(config.auth, () => ( "user"));
    if (!response.ok) {
      const body = await parseErrorBody(response);
      const requestId = _nullishCoalesce(response.headers.get("x-request-id"), () => ( void 0));
      throw new ApiRequestError(
        `Request to ${String(endpoint)} failed with status ${response.status}`,
        {
          endpoint,
          status: response.status,
          method: config.method,
          auth,
          requestId,
          body
        }
      );
    }
    return parseSuccessResponse(endpoint, response, config);
  };
}
function createCMSClient(headers = {}, baseUrl) {
  return createParsedClient(createRawCMSClient(headers, baseUrl));
}
function createBearerAPIClient(token, baseUrl) {
  const authHeaders = {
    Authorization: `Bearer ${token}`
  };
  return createCMSClient(authHeaders, baseUrl);
}

// ../api/src/aiPlayground.ts
var _zod = require('zod');
var Rfc6902PatchOp = _zod.z.discriminatedUnion("op", [
  // Standard RFC-6902 operations
  _zod.z.object({
    op: _zod.z.literal("add"),
    path: _zod.z.string(),
    value: _zod.z.unknown()
  }),
  _zod.z.object({
    op: _zod.z.literal("remove"),
    path: _zod.z.string()
  }),
  _zod.z.object({
    op: _zod.z.literal("replace"),
    path: _zod.z.string(),
    value: _zod.z.unknown()
  }),
  _zod.z.object({
    op: _zod.z.literal("move"),
    from: _zod.z.string(),
    path: _zod.z.string()
  }),
  _zod.z.object({
    op: _zod.z.literal("copy"),
    from: _zod.z.string(),
    path: _zod.z.string()
  }),
  // Block-level operations (Phase 2)
  _zod.z.object({
    op: _zod.z.literal("add_block"),
    blockKind: _zod.z.string(),
    afterBlockId: _zod.z.string().nullable(),
    content: _zod.z.record(_zod.z.string(), _zod.z.unknown()),
    rationale: _zod.z.string()
  }),
  _zod.z.object({
    op: _zod.z.literal("delete_block"),
    blockId: _zod.z.string(),
    rationale: _zod.z.string()
  }),
  _zod.z.object({
    op: _zod.z.literal("reorder_block"),
    blockId: _zod.z.string(),
    afterBlockId: _zod.z.string().nullable(),
    rationale: _zod.z.string()
  })
]);
var PatchEnvelope = _zod.z.object({
  blockId: _zod.z.string(),
  blockKind: _zod.z.string().optional(),
  blockPurpose: _zod.z.string().optional().nullable(),
  ops: _zod.z.array(Rfc6902PatchOp),
  rationale: _zod.z.string(),
  currentContent: _zod.z.record(_zod.z.string(), _zod.z.unknown()).optional()
});
var ContentUpdateResponse = _zod.z.object({
  patches: _zod.z.array(PatchEnvelope),
  assistantMessage: _zod.z.string()
});
var PlaygroundProposeRequest = _zod.z.object({
  request: _zod.z.string().min(1).max(2e3)
});
var PlaygroundProposeResponse = _zod.z.object({
  patches: _zod.z.array(PatchEnvelope),
  assistantMessage: _zod.z.string(),
  validation: _zod.z.object({
    valid: _zod.z.boolean(),
    issues: _zod.z.array(_zod.z.string()),
    filtered: _zod.z.number()
  })
});
var MultiPagePatchEnvelope = _zod.z.object({
  pageId: _zod.z.string(),
  blockId: _zod.z.string().optional(),
  // Not present for page-level ops
  blockKind: _zod.z.string().optional(),
  blockPurpose: _zod.z.string().optional().nullable(),
  ops: _zod.z.array(Rfc6902PatchOp),
  rationale: _zod.z.string(),
  currentContent: _zod.z.record(_zod.z.string(), _zod.z.unknown()).optional()
});
var MultiPageUpdateResponse = _zod.z.object({
  patches: _zod.z.array(MultiPagePatchEnvelope),
  assistantMessage: _zod.z.string(),
  pagesModified: _zod.z.number(),
  toolCallsUsed: _zod.z.number()
});

// src/client/cache.ts
var SimpleCache = class {
  constructor(options = {}) {
    this.cache = /* @__PURE__ */ new Map();
    this.maxSize = _nullishCoalesce(options.maxSize, () => ( 100));
    this.ttl = _nullishCoalesce(options.ttl, () => ( 3e5));
  }
  get(key) {
    const entry = this.cache.get(key);
    if (!entry) return void 0;
    if (Date.now() > entry.expires) {
      this.cache.delete(key);
      return void 0;
    }
    return entry.value;
  }
  set(key, value) {
    if (this.cache.size >= this.maxSize) {
      const firstKey = this.cache.keys().next().value;
      if (firstKey) {
        this.cache.delete(firstKey);
      }
    }
    this.cache.set(key, {
      value,
      expires: Date.now() + this.ttl
    });
  }
  clear() {
    this.cache.clear();
  }
  has(key) {
    return this.get(key) !== void 0;
  }
};

// src/client/index.ts
function createRiverbankClient(config) {
  if (!config.baseUrl) {
    throw new Error(
      "baseUrl is required when creating a Builder client. Expected format: https://dashboard.example.com/api (must include /api path)"
    );
  }
  if (!config.baseUrl.endsWith("/api")) {
    throw new Error(
      `baseUrl must end with '/api'. Received: ${config.baseUrl}. Expected format: https://dashboard.example.com/api`
    );
  }
  const cacheEnabled = _nullishCoalesce(_optionalChain([config, 'access', _ => _.cache, 'optionalAccess', _2 => _2.enabled]), () => ( true));
  const cacheTTL = (_nullishCoalesce(_optionalChain([config, 'access', _3 => _3.cache, 'optionalAccess', _4 => _4.ttl]), () => ( 300))) * 1e3;
  const cacheMaxSize = _nullishCoalesce(_optionalChain([config, 'access', _5 => _5.cache, 'optionalAccess', _6 => _6.maxSize]), () => ( 100));
  const apiClient = createBearerAPIClient(config.apiKey, config.baseUrl);
  const cache = new SimpleCache({
    maxSize: cacheMaxSize,
    ttl: cacheTTL
  });
  async function cachedFetch(cacheKey, fetcher, options) {
    if (cacheEnabled && !_optionalChain([options, 'optionalAccess', _7 => _7.force])) {
      const cached = cache.get(cacheKey);
      if (cached !== void 0) {
        return cached;
      }
    }
    const data = await fetcher();
    if (cacheEnabled) {
      cache.set(cacheKey, data);
    }
    return data;
  }
  return {
    async getSite(params) {
      const { slug, domain, id } = params;
      if (!slug && !domain && !id) {
        throw new Error(
          `getSite() requires at least one identifier: slug, domain, or id. Received: ${JSON.stringify(params)}`
        );
      }
      const cacheKey = `site:${slug || domain || id}`;
      return cachedFetch(cacheKey, async () => {
        const apiParams = {};
        if (params.slug) apiParams.slug = params.slug;
        if (params.domain) apiParams.domain = params.domain;
        if (params.id) apiParams.id = params.id;
        return await apiClient({ endpoint: "getSite", params: apiParams });
      });
    },
    async getPage(params) {
      const { siteId, path, preview = false } = params;
      const cacheKey = `page:${siteId}:${path}:${preview}`;
      return cachedFetch(cacheKey, async () => {
        return await apiClient({ endpoint: "getContentByPath", params: { siteId }, body: { path, preview } });
      });
    },
    async getEntries(params) {
      const { siteId, contentType, limit, offset, order, preview = false, mode, entryIds, includeMeta } = params;
      const entryIdsCacheKey = mode === "manual" && _optionalChain([entryIds, 'optionalAccess', _8 => _8.length]) ? entryIds.join(",") : "";
      const cacheKey = `entries:${siteId}:${contentType}:${_nullishCoalesce(limit, () => ( ""))}:${_nullishCoalesce(offset, () => ( ""))}:${_nullishCoalesce(order, () => ( ""))}:${preview}:${_nullishCoalesce(mode, () => ( ""))}:${entryIdsCacheKey}:${_nullishCoalesce(includeMeta, () => ( ""))}`;
      return cachedFetch(cacheKey, async () => {
        const apiParams = {
          siteId,
          type: contentType
        };
        if (typeof limit === "number") {
          apiParams.limit = String(limit);
        }
        if (typeof offset === "number") {
          apiParams.offset = String(offset);
        }
        if (includeMeta) {
          apiParams.meta = "true";
        }
        if (order === "newest") {
          apiParams.order = "published_at.desc";
        } else if (order === "oldest") {
          apiParams.order = "published_at.asc";
        } else if (order === "title") {
          apiParams.order = "title.asc";
        }
        if (preview) {
          apiParams.stage = "preview";
        }
        if (mode === "manual" && _optionalChain([entryIds, 'optionalAccess', _9 => _9.length])) {
          apiParams.mode = "manual";
          apiParams.entryIds = JSON.stringify(entryIds);
        }
        return await apiClient({ endpoint: "listPublishedEntries", params: apiParams });
      });
    },
    async getEntry(params) {
      const { siteId, contentType, slug } = params;
      const cacheKey = `entry:${siteId}:${contentType}:${slug}`;
      return cachedFetch(cacheKey, async () => {
        return await apiClient({ endpoint: "getPublishedEntryPreview", params: { siteId, type: contentType, slug } });
      });
    },
    async getPublicFormById(params) {
      const { formId } = params;
      if (!formId) {
        throw new Error("getPublicFormById() requires formId");
      }
      const cacheKey = `public-form:${formId}`;
      return cachedFetch(cacheKey, async () => {
        return await apiClient({ endpoint: "getPublicFormById", params: { formId } });
      });
    },
    async getPublicBookingServices(params) {
      const { siteId, ids } = params;
      if (!siteId) {
        throw new Error("getPublicBookingServices() requires siteId");
      }
      const cacheKey = `public-booking-services:${siteId}:${_nullishCoalesce(ids, () => ( ""))}`;
      return cachedFetch(cacheKey, async () => {
        const apiParams = { siteId };
        if (ids) apiParams.ids = ids;
        return await apiClient({ endpoint: "getPublicBookingServices", params: apiParams });
      });
    },
    async listPublicEvents(params) {
      const { siteId, limit, from, to, stage } = params;
      if (!siteId) {
        throw new Error("listPublicEvents() requires siteId");
      }
      const cacheKey = `public-events:${siteId}:${_nullishCoalesce(limit, () => ( ""))}:${_nullishCoalesce(from, () => ( ""))}:${_nullishCoalesce(to, () => ( ""))}:${_nullishCoalesce(stage, () => ( ""))}`;
      return cachedFetch(cacheKey, async () => {
        const apiParams = { siteId };
        if (typeof limit === "number") apiParams.limit = String(limit);
        if (from) apiParams.from = from;
        if (to) apiParams.to = to;
        if (stage) apiParams.stage = stage;
        return await apiClient({ endpoint: "listPublicEvents", params: apiParams });
      });
    },
    clearCache() {
      cache.clear();
    }
    // Cast to RiverbankClient to satisfy overloaded getEntries signature
    // The implementation correctly returns the right type based on includeMeta
  };
}





exports.API_ENDPOINTS = API_ENDPOINTS; exports.buildEndpointURL = buildEndpointURL; exports.createRiverbankClient = createRiverbankClient;
//# sourceMappingURL=chunk-R5B6IOFQ.js.map