@kyro-cms/core 0.12.16 → 0.12.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-handler-graphql.cjs +1 -1
- package/dist/api-handler-graphql.js +1 -1
- package/dist/api-handler-trpc.cjs +1 -1
- package/dist/api-handler-trpc.js +1 -1
- package/dist/api-handler.cjs +1 -1
- package/dist/api-handler.js +1 -1
- package/dist/{chunk-IQYP3DDJ.cjs → chunk-BIJHVTNO.cjs} +2 -2
- package/dist/{chunk-NI7S5JMH.js → chunk-CIA3BVH3.js} +5 -5
- package/dist/{chunk-ZZIGN5PZ.js → chunk-I4ZACL66.js} +1 -1
- package/dist/{chunk-M5JUPA7G.cjs → chunk-LMIBASPC.cjs} +5 -5
- package/dist/{chunk-RY3BG3AN.cjs → chunk-RL36RMMG.cjs} +1 -1
- package/dist/{chunk-DTSYK7KK.js → chunk-YFRLT77I.js} +2 -2
- package/dist/index.cjs +26 -19
- package/dist/index.d.cts +202 -2
- package/dist/index.d.ts +202 -2
- package/dist/index.js +26 -19
- package/dist/rest/index.cjs +1 -1
- package/dist/rest/index.js +1 -1
- package/package.json +4 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkRL36RMMG_cjs=require('./chunk-RL36RMMG.cjs');require('./chunk-BIJHVTNO.cjs'),require('./chunk-QMQXKCCQ.cjs'),require('./chunk-65G73T7Z.cjs'),require('./chunk-KD7LUCFY.cjs'),require('./chunk-WMZEULS2.cjs'),require('./chunk-HS2KNFAB.cjs'),require('./chunk-LMIBASPC.cjs'),require('./chunk-GCQTSPX6.cjs'),require('./chunk-WIZ6C5QZ.cjs'),require('./chunk-GO34AOBZ.cjs'),require('./chunk-HOP4D5XZ.cjs'),require('./chunk-HVXO3OFB.cjs'),require('./chunk-XUONID6O.cjs'),require('./chunk-NY47CFVP.cjs'),require('./chunk-G3J2EU5D.cjs'),require('./chunk-4ORJMSJU.cjs'),require('./chunk-3ZFRP5M2.cjs'),require('./chunk-GYQMNXXW.cjs'),require('./chunk-MIOMMB23.cjs'),require('./chunk-RYIEE2TH.cjs'),require('./chunk-HHH4XNNS.cjs'),require('./chunk-EJDIR56C.cjs'),require('./chunk-D5P2IPGX.cjs'),require('./chunk-Q3Q7BJVQ.cjs'),require('./chunk-AHSFSERC.cjs');function n(e){return new Response(e.body,e)}var p={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};function r(){return new Response(JSON.stringify({error:"GraphQL is disabled"}),{status:503,headers:{"Content-Type":"application/json"}})}async function o(){try{return (await chunkRL36RMMG_cjs.a.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.graphqlEnabled??p.graphqlEnabled}catch{return true}}var l=async e=>{if(await chunkRL36RMMG_cjs.b(),!await o())return r();let t=await chunkRL36RMMG_cjs.a.getGraphQL().fetch(e.request,e.locals);return n(t)},u=async e=>{if(await chunkRL36RMMG_cjs.b(),!await o())return r();let t=await chunkRL36RMMG_cjs.a.getGraphQL().fetch(e.request,e.locals);return n(t)};exports.GET=u;exports.POST=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b,a}from'./chunk-
|
|
1
|
+
import {b,a}from'./chunk-I4ZACL66.js';import'./chunk-YFRLT77I.js';import'./chunk-O62KJ2J7.js';import'./chunk-NZ35PV5R.js';import'./chunk-5SEHX7ON.js';import'./chunk-ISCIUG37.js';import'./chunk-PP7W5UKL.js';import'./chunk-CIA3BVH3.js';import'./chunk-6NGUY76Y.js';import'./chunk-K6WUOU6P.js';import'./chunk-IETGL7WJ.js';import'./chunk-IKOXCJYO.js';import'./chunk-NRLIGDYF.js';import'./chunk-I67R6MR5.js';import'./chunk-HLSB2MCK.js';import'./chunk-GKYEJ2UF.js';import'./chunk-PP5S2UBV.js';import'./chunk-3RR6IV5I.js';import'./chunk-RHCWCG3O.js';import'./chunk-OG7CNQGU.js';import'./chunk-W6P4N3Z7.js';import'./chunk-IZCTG4RG.js';import'./chunk-TQNM4C7H.js';import'./chunk-6SPPR5JZ.js';import'./chunk-KDNYHLD2.js';import'./chunk-5J6HXUF6.js';function n(e){return new Response(e.body,e)}var p={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};function r(){return new Response(JSON.stringify({error:"GraphQL is disabled"}),{status:503,headers:{"Content-Type":"application/json"}})}async function o(){try{return (await a.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.graphqlEnabled??p.graphqlEnabled}catch{return true}}var l=async e=>{if(await b(),!await o())return r();let t=await a.getGraphQL().fetch(e.request,e.locals);return n(t)},u=async e=>{if(await b(),!await o())return r();let t=await a.getGraphQL().fetch(e.request,e.locals);return n(t)};export{u as GET,l as POST};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkRL36RMMG_cjs=require('./chunk-RL36RMMG.cjs');require('./chunk-BIJHVTNO.cjs'),require('./chunk-QMQXKCCQ.cjs'),require('./chunk-65G73T7Z.cjs'),require('./chunk-KD7LUCFY.cjs'),require('./chunk-WMZEULS2.cjs'),require('./chunk-HS2KNFAB.cjs'),require('./chunk-LMIBASPC.cjs'),require('./chunk-GCQTSPX6.cjs'),require('./chunk-WIZ6C5QZ.cjs'),require('./chunk-GO34AOBZ.cjs'),require('./chunk-HOP4D5XZ.cjs'),require('./chunk-HVXO3OFB.cjs'),require('./chunk-XUONID6O.cjs'),require('./chunk-NY47CFVP.cjs'),require('./chunk-G3J2EU5D.cjs'),require('./chunk-4ORJMSJU.cjs'),require('./chunk-3ZFRP5M2.cjs'),require('./chunk-GYQMNXXW.cjs'),require('./chunk-MIOMMB23.cjs'),require('./chunk-RYIEE2TH.cjs'),require('./chunk-HHH4XNNS.cjs'),require('./chunk-EJDIR56C.cjs'),require('./chunk-D5P2IPGX.cjs'),require('./chunk-Q3Q7BJVQ.cjs'),require('./chunk-AHSFSERC.cjs');function n(){return new Response(JSON.stringify({error:"tRPC is disabled"}),{status:503,headers:{"Content-Type":"application/json"}})}var r={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};async function s(){try{return (await chunkRL36RMMG_cjs.a.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.trpcEnabled??r.trpcEnabled}catch{return true}}var i=async e=>(await chunkRL36RMMG_cjs.b(),await s()?chunkRL36RMMG_cjs.a.getTRPC().fetch(e.request,e.locals):n());exports.ALL=i;
|
package/dist/api-handler-trpc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b,a}from'./chunk-
|
|
1
|
+
import {b,a}from'./chunk-I4ZACL66.js';import'./chunk-YFRLT77I.js';import'./chunk-O62KJ2J7.js';import'./chunk-NZ35PV5R.js';import'./chunk-5SEHX7ON.js';import'./chunk-ISCIUG37.js';import'./chunk-PP7W5UKL.js';import'./chunk-CIA3BVH3.js';import'./chunk-6NGUY76Y.js';import'./chunk-K6WUOU6P.js';import'./chunk-IETGL7WJ.js';import'./chunk-IKOXCJYO.js';import'./chunk-NRLIGDYF.js';import'./chunk-I67R6MR5.js';import'./chunk-HLSB2MCK.js';import'./chunk-GKYEJ2UF.js';import'./chunk-PP5S2UBV.js';import'./chunk-3RR6IV5I.js';import'./chunk-RHCWCG3O.js';import'./chunk-OG7CNQGU.js';import'./chunk-W6P4N3Z7.js';import'./chunk-IZCTG4RG.js';import'./chunk-TQNM4C7H.js';import'./chunk-6SPPR5JZ.js';import'./chunk-KDNYHLD2.js';import'./chunk-5J6HXUF6.js';function n(){return new Response(JSON.stringify({error:"tRPC is disabled"}),{status:503,headers:{"Content-Type":"application/json"}})}var r={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};async function s(){try{return (await a.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.trpcEnabled??r.trpcEnabled}catch{return true}}var i=async e=>(await b(),await s()?a.getTRPC().fetch(e.request,e.locals):n());export{i as ALL};
|
package/dist/api-handler.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkRL36RMMG_cjs=require('./chunk-RL36RMMG.cjs');require('./chunk-BIJHVTNO.cjs'),require('./chunk-QMQXKCCQ.cjs'),require('./chunk-65G73T7Z.cjs'),require('./chunk-KD7LUCFY.cjs'),require('./chunk-WMZEULS2.cjs'),require('./chunk-HS2KNFAB.cjs'),require('./chunk-LMIBASPC.cjs'),require('./chunk-GCQTSPX6.cjs'),require('./chunk-WIZ6C5QZ.cjs'),require('./chunk-GO34AOBZ.cjs'),require('./chunk-HOP4D5XZ.cjs'),require('./chunk-HVXO3OFB.cjs'),require('./chunk-XUONID6O.cjs'),require('./chunk-NY47CFVP.cjs'),require('./chunk-G3J2EU5D.cjs'),require('./chunk-4ORJMSJU.cjs'),require('./chunk-3ZFRP5M2.cjs'),require('./chunk-GYQMNXXW.cjs'),require('./chunk-MIOMMB23.cjs'),require('./chunk-RYIEE2TH.cjs'),require('./chunk-HHH4XNNS.cjs'),require('./chunk-EJDIR56C.cjs'),require('./chunk-D5P2IPGX.cjs'),require('./chunk-Q3Q7BJVQ.cjs'),require('./chunk-AHSFSERC.cjs');Object.defineProperty(exports,"ALL",{enumerable:true,get:function(){return chunkRL36RMMG_cjs.c}});Object.defineProperty(exports,"kyroInstance",{enumerable:true,get:function(){return chunkRL36RMMG_cjs.a}});Object.defineProperty(exports,"warmKyroInstance",{enumerable:true,get:function(){return chunkRL36RMMG_cjs.b}});
|
package/dist/api-handler.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{c as ALL,a as kyroInstance,b as warmKyroInstance}from'./chunk-
|
|
1
|
+
export{c as ALL,a as kyroInstance,b as warmKyroInstance}from'./chunk-I4ZACL66.js';import'./chunk-YFRLT77I.js';import'./chunk-O62KJ2J7.js';import'./chunk-NZ35PV5R.js';import'./chunk-5SEHX7ON.js';import'./chunk-ISCIUG37.js';import'./chunk-PP7W5UKL.js';import'./chunk-CIA3BVH3.js';import'./chunk-6NGUY76Y.js';import'./chunk-K6WUOU6P.js';import'./chunk-IETGL7WJ.js';import'./chunk-IKOXCJYO.js';import'./chunk-NRLIGDYF.js';import'./chunk-I67R6MR5.js';import'./chunk-HLSB2MCK.js';import'./chunk-GKYEJ2UF.js';import'./chunk-PP5S2UBV.js';import'./chunk-3RR6IV5I.js';import'./chunk-RHCWCG3O.js';import'./chunk-OG7CNQGU.js';import'./chunk-W6P4N3Z7.js';import'./chunk-IZCTG4RG.js';import'./chunk-TQNM4C7H.js';import'./chunk-6SPPR5JZ.js';import'./chunk-KDNYHLD2.js';import'./chunk-5J6HXUF6.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
'use strict';var chunk65G73T7Z_cjs=require('./chunk-65G73T7Z.cjs'),chunkKD7LUCFY_cjs=require('./chunk-KD7LUCFY.cjs'),chunkWMZEULS2_cjs=require('./chunk-WMZEULS2.cjs'),chunkHS2KNFAB_cjs=require('./chunk-HS2KNFAB.cjs'),
|
|
1
|
+
'use strict';var chunk65G73T7Z_cjs=require('./chunk-65G73T7Z.cjs'),chunkKD7LUCFY_cjs=require('./chunk-KD7LUCFY.cjs'),chunkWMZEULS2_cjs=require('./chunk-WMZEULS2.cjs'),chunkHS2KNFAB_cjs=require('./chunk-HS2KNFAB.cjs'),chunkLMIBASPC_cjs=require('./chunk-LMIBASPC.cjs'),chunkXUONID6O_cjs=require('./chunk-XUONID6O.cjs'),chunkNY47CFVP_cjs=require('./chunk-NY47CFVP.cjs'),chunkG3J2EU5D_cjs=require('./chunk-G3J2EU5D.cjs'),chunk3ZFRP5M2_cjs=require('./chunk-3ZFRP5M2.cjs'),chunkMIOMMB23_cjs=require('./chunk-MIOMMB23.cjs'),chunkEJDIR56C_cjs=require('./chunk-EJDIR56C.cjs'),zod=require('zod'),graphqlYoga=require('graphql-yoga'),module$1=require('module'),crypto=require('crypto');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function O(n,e){for(let t of n){if(t.name===e)return true;if("tabs"in t&&t.tabs){for(let s of t.tabs)if(O(s.fields,e))return true}if("fields"in t&&t.fields&&O(t.fields,e))return true}return false}var V=class extends Error{errors;constructor(e){super(`Configuration validation failed:
|
|
2
2
|
${e.join(`
|
|
3
|
-
`)}`),this.name="ConfigValidationError",this.errors=e;}};function B(n){let e=[];if(n.slug?/^[a-z][a-z0-9_-]*$/.test(n.slug)||e.push(`Collection slug "${n.slug}" must be lowercase alphanumeric with dashes`):e.push('Collection is missing a "slug" property'),!n.fields||n.fields.length===0)e.push(`Collection "${n.slug}" has no fields defined`);else {let t=R(n.fields,n.slug);e.push(...t);}if(n.access)for(let[t,s]of Object.entries(n.access))typeof s!="boolean"&&typeof s!="function"&&e.push(`Collection "${n.slug}" has invalid access.${t} (must be boolean or function)`);if(n.admin?.useAsTitle&&(O(n.fields,n.admin.useAsTitle)||e.push(`Collection "${n.slug}" admin.useAsTitle references unknown field "${n.admin.useAsTitle}"`)),n.admin?.defaultColumns)for(let t of n.admin.defaultColumns)O(n.fields,t)||e.push(`Collection "${n.slug}" admin.defaultColumns references unknown field "${t}"`);if(n.upload&&n.upload.fileSize&&n.upload.fileSize<=0&&e.push(`Collection "${n.slug}" upload.fileSize must be positive`),n.versions&&n.versions.maxPerDoc&&n.versions.maxPerDoc<=0&&e.push(`Collection "${n.slug}" versions.maxPerDoc must be positive`),n.auth){let t=n.fields.some(i=>i.name==="email"),s=n.fields.some(i=>i.name==="password");t||e.push(`Collection "${n.slug}" with auth enabled requires an "email" field`),s||e.push(`Collection "${n.slug}" with auth enabled requires a "password" field`);}return e}function H(n){let e=[];if(n.slug?/^[a-z][a-z0-9_-]*$/.test(n.slug)||e.push(`Global slug "${n.slug}" must be lowercase alphanumeric with dashes`):e.push('Global is missing a "slug" property'),!n.fields||n.fields.length===0)e.push(`Global "${n.slug}" has no fields defined`);else {let t=R(n.fields,`global:${n.slug}`);e.push(...t);}return e}function R(n,e){let t=[],s=new Set;for(let i=0;i<n.length;i++){let o=n[i];if(o.type==="row"||o.type==="collapsible"||o.type==="tabs"){if("fields"in o&&o.fields){let r=R(o.fields,e);t.push(...r);}else if("tabs"in o)for(let r of o.tabs){let c=R(r.fields,e);t.push(...c);}continue}let a=o.name;if(!a){t.push(`${e}: Field at index ${i} is missing a "name" property`);continue}if(s.has(a)&&t.push(`${e}: Duplicate field name "${a}"`),s.add(a),/^[a-zA-Z][a-zA-Z0-9_]*$/.test(a)||t.push(`${e}: Field name "${a}" must be alphanumeric with underscores`),!o.type){t.push(`${e}: Field "${a}" is missing a "type" property`);continue}switch(o.type){case "relationship":o.relationTo||t.push(`${e}: Relationship field "${a}" is missing "relationTo"`);break;case "array":if(!o.fields||o.fields.length===0)t.push(`${e}: Array field "${a}" has no fields defined`);else {let r=R(o.fields,`${e}.${a}`);t.push(...r);}break;case "group":if(!o.fields||o.fields.length===0)t.push(`${e}: Group field "${a}" has no fields defined`);else {let r=R(o.fields,`${e}.${a}`);t.push(...r);}break;case "blocks":if(!o.blocks||o.blocks.length===0)t.push(`${e}: Blocks field "${a}" has no blocks defined`);else {let r=Ge(o.blocks,`${e}.${a}`);t.push(...r);}break;case "select":case "radio":if(typeof o.options=="function")break;if((!o.options||o.options.length===0)&&!o.dynamicOptions)t.push(`${e}: ${o.type} field "${a}" has no options defined`);else if(Array.isArray(o.options)){let r=o.options.map(d=>d.value),c=new Set(r);r.length!==c.size&&t.push(`${e}: ${o.type} field "${a}" has duplicate option values`);}break;case "upload":o.relationTo||t.push(`${e}: Upload field "${a}" is missing "relationTo"`);break}"min"in o&&"max"in o&&o.min>o.max&&t.push(`${e}: Field "${a}" has min greater than max`),"minLength"in o&&"maxLength"in o&&o.minLength>o.maxLength&&t.push(`${e}: Field "${a}" has minLength greater than maxLength`),"minRows"in o&&"maxRows"in o&&o.minRows>o.maxRows&&t.push(`${e}: Field "${a}" has minRows greater than maxRows`);}return t}function Ge(n,e){let t=[],s=new Set;for(let i of n){if(!i.slug){t.push(`${e}: Block is missing a "slug" property`);continue}if(s.has(i.slug)&&t.push(`${e}: Duplicate block slug "${i.slug}"`),s.add(i.slug),i.label||t.push(`${e}: Block "${i.slug}" is missing a "label" property`),!i.fields||i.fields.length===0)t.push(`${e}: Block "${i.slug}" has no fields defined`);else {let o=R(i.fields,`${e}.${i.slug}`);t.push(...o);}}return t}function xe(n,e=[]){let t=[],s=new Set;for(let i of n)s.has(i.slug)&&t.push(`Duplicate collection slug "${i.slug}"`),s.add(i.slug);for(let i of e)s.has(i.slug)&&t.push(`Duplicate global slug "${i.slug}"`),s.add(i.slug);for(let i of n){let o=B(i);t.push(...o);}for(let i of e){let o=H(i);t.push(...o);}for(let i of n){let o=P(i.fields,n);t.push(...o);}if(t.length>0)throw new V(t)}function P(n,e){let t=[],s=new Set(e.map(i=>i.slug));for(let i of n){if(i.type==="relationship"){let o=Array.isArray(i.relationTo)?i.relationTo:[i.relationTo];for(let a of o)a!=="*"&&!s.has(a)&&console.warn(`[Kyro Config Warning]: Relationship field "${i.name}" references unknown collection "${a}". Select options will not be available until this collection is registered.`);}if(i.type==="upload"){let o=Array.isArray(i.relationTo)?i.relationTo:[i.relationTo];for(let a of o)s.has(a)||t.push(`Upload field "${i.name}" references unknown collection "${a}"`);}if("fields"in i&&i.fields){let o=P(i.fields,e);t.push(...o);}if("tabs"in i)for(let o of i.tabs){let a=P(o.fields,e);t.push(...a);}if("blocks"in i)for(let o of i.blocks){let a=P(o.fields,e);t.push(...a);}}return t}function A(n){switch(n.type){case "text":return Ue(n);case "number":return Ke(n);case "checkbox":return Me(n);case "date":return Ve(n);case "email":return Be(n);case "password":return He(n);case "textarea":return We(n);case "select":return ze(n);case "radio":return Xe(n);case "color":return Je(n);case "richtext":return Ye(n);case "json":return Qe(n);case "code":return et(n);case "upload":return ve(n);case "image":return ve(n);case "markdown":return tt(n);case "relationship":return Ee(n);case "relationship-block":return Ee(n);case "array":return st(n);case "list":return nt(n);case "group":return it(n);case "blocks":return ot(n);case "row":return at(n);case "collapsible":return rt(n);case "tabs":return lt(n);default:return zod.z.any()}}function Ue(n){let e=zod.z.string();return n.minLength&&(e=e.min(n.minLength)),n.maxLength&&(e=e.max(n.maxLength)),n.pattern&&(e=e.regex(new RegExp(n.pattern))),n.variant==="email"&&(e=e.email()),n.variant==="url"&&(e=e.url()),n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Ke(n){let e=n.integer?zod.z.coerce.number().int():zod.z.coerce.number();return n.min!==void 0&&(e=e.min(n.min)),n.max!==void 0&&(e=e.max(n.max)),n.step&&(e=e.refine(t=>Number.isInteger(t/n.step),`Value must be divisible by ${n.step}`)),n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Me(n){let e=zod.z.boolean();return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Ve(n){let e=zod.z.string().refine(t=>!isNaN(Date.parse(t)),"Invalid date format");return n.minDate&&(e=e.refine(t=>new Date(t)>=new Date(n.minDate),`Date must be after ${n.minDate}`)),n.maxDate&&(e=e.refine(t=>new Date(t)<=new Date(n.maxDate),`Date must be before ${n.maxDate}`)),n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Be(n){let e=zod.z.string().email("Invalid email");return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function He(n){let e=zod.z.string().min(6,"Password must be at least 6 characters");return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function We(n){let e=zod.z.string();return n.minLength&&(e=e.min(n.minLength)),n.maxLength&&(e=e.max(n.maxLength)),n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function ze(n){let e;if(Array.isArray(n.options)&&n.options.length>0){let t=n.options.map(s=>s.value);n.hasMany?e=zod.z.array(zod.z.enum(t)):e=zod.z.enum(t);}else e=n.hasMany?zod.z.array(zod.z.string()):zod.z.string();return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Xe(n){let e;if(Array.isArray(n.options)&&n.options.length>0){let t=n.options.map(s=>s.value);e=zod.z.enum(t);}else e=zod.z.string();return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Je(n){let e=zod.z.string();return n.format==="hex"&&(e=e.regex(/^#[0-9A-Fa-f]{6}$/)),n.format==="rgb"&&(e=e.regex(/^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$/)),n.format==="hsl"&&(e=e.regex(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/)),n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Ye(n){let e=zod.z.array(zod.z.record(zod.z.any()));return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Qe(n){let e=zod.z.union([zod.z.record(zod.z.any()),zod.z.array(zod.z.any())]);return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function et(n){let e=zod.z.string();return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function ve(n){let e;if(n.relationTo){let t=zod.z.object({id:zod.z.string(),url:zod.z.string().optional(),filename:zod.z.string().optional(),mimeType:zod.z.string().optional()});e=zod.z.union([zod.z.string(),t]);}else e=zod.z.string();return n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function tt(n){let e=zod.z.string();return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Ee(n){let e;return Array.isArray(n.relationTo)?e=zod.z.object({relationTo:zod.z.enum(n.relationTo),value:zod.z.string()}):e=zod.z.union([zod.z.string(),zod.z.object({relationTo:zod.z.string(),value:zod.z.string()})]),n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function st(n){let e=zod.z.object(Object.fromEntries(n.fields.filter(s=>s.name).map(s=>[s.name,A(s)]))).passthrough(),t=zod.z.array(e);return n.minRows&&(t=t.min(n.minRows)),n.maxRows&&(t=t.max(n.maxRows)),n.required||(t=t.optional().nullable()),n.validate&&(t=T(t,n.validate)),t}function nt(n){let e=zod.z.array(zod.z.string());return n.required||(e=e.optional().nullable()),e}function it(n){let e=zod.z.object(Object.fromEntries(n.fields.filter(t=>t.name).map(t=>[t.name,A(t)])));return n.required?e:e.optional().nullable()}function ot(n){let e=n.blocks||[];e.map(o=>zod.z.object({blockType:zod.z.literal(o.slug),...Object.fromEntries(o.fields.filter(a=>a.name).map(a=>[a.name,A(a)]))}));let s=e.map(o=>o.slug),i;if(s.length>0){let o=zod.z.object({blockType:zod.z.enum(s)}).catchall(zod.z.any()),a=zod.z.object({blockType:zod.z.string()}).catchall(zod.z.any());i=zod.z.array(zod.z.union([o,a,zod.z.record(zod.z.any())]));}else i=zod.z.array(zod.z.union([zod.z.object({blockType:zod.z.string()}).catchall(zod.z.any()),zod.z.record(zod.z.any())]));return n.minRows&&(i=i.min(n.minRows)),n.maxRows&&(i=i.max(n.maxRows)),n.required||(i=i.optional().nullable()),n.validate&&(i=T(i,n.validate)),i}function at(n){return zod.z.object(Object.fromEntries(n.fields.filter(t=>t.name).map(t=>[t.name,A(t)])))}function rt(n){return zod.z.object(Object.fromEntries(n.fields.filter(t=>t.name).map(t=>[t.name,A(t)])))}function lt(n){let e={};for(let t of n.tabs)for(let s of t.fields)s.name&&(e[s.name]=A(s));return zod.z.object(e).passthrough().optional()}function T(n,e){return n.refine(async t=>await e(t,{required:false})===true,{message:"Custom validation failed"})}function w(n){let e={};for(let t of n)if(t.type==="tabs"&&"tabs"in t){let s={};for(let i of t.tabs){let o=w(i.fields);Object.assign(s,o);}t.name?e[t.name]=zod.z.object(s).passthrough().optional():Object.assign(e,s);}else if(t.type==="row"&&"fields"in t){let s=w(t.fields);t.name?e[t.name]=zod.z.object(s).passthrough().optional():Object.assign(e,s);}else if(t.type==="collapsible"&&"fields"in t){let s=w(t.fields);t.name?e[t.name]=zod.z.object(s).passthrough().optional():Object.assign(e,s);}else {if(!t.name)continue;e[t.name]=A(t);}return e}function v(n){let e={};for(let t of n)if(t.type==="tabs"&&"tabs"in t){let s={};for(let i of t.tabs){let o=v(i.fields);Object.assign(s,o);}t.name?e[t.name]=zod.z.object(s).passthrough().optional().nullable():Object.assign(e,s);}else if(t.type==="row"&&"fields"in t){let s=v(t.fields);t.name?e[t.name]=zod.z.object(s).passthrough().optional().nullable():Object.assign(e,s);}else if(t.type==="collapsible"&&"fields"in t){let s=v(t.fields);t.name?e[t.name]=zod.z.object(s).passthrough().optional().nullable():Object.assign(e,s);}else if(t.type==="group"&&"fields"in t)t.name?e[t.name]=zod.z.object(v(t.fields)).passthrough().optional().nullable():Object.assign(e,v(t.fields));else {if(!t.name)continue;e[t.name]=A(t).optional().nullable();}return e}function Re(n){let e=w(n.fields);return n.timestamps&&(e.createdAt=zod.z.string().optional(),e.updatedAt=zod.z.string().optional()),n.tenantScoped&&(e.tenantId=zod.z.string().optional()),e.id=zod.z.string().optional(),zod.z.object(e).passthrough()}function we(n){let e=w(n.fields);return zod.z.object(e).passthrough()}function Ne(n){let e={};for(let t of n.fields)if(t.name)if(t.type==="tabs"&&"tabs"in t){let s={};for(let i of t.tabs)for(let o of i.fields)o.name&&(s[o.name]=A(o).optional().nullable());e[t.name]=zod.z.object(s).optional().nullable();}else if(t.type==="row"&&"fields"in t){let s={};for(let i of t.fields)i.name&&(s[i.name]=A(i).optional().nullable());Object.assign(e,s);}else t.type==="collapsible"&&"fields"in t?e[t.name]=zod.z.object(v(t.fields)).optional().nullable():t.type==="group"&&"fields"in t?e[t.name]=zod.z.object(v(t.fields)).optional().nullable():e[t.name]=A(t).optional().nullable();return zod.z.object(e).passthrough()}function De(n){let e={};for(let t of n.fields)t.name&&(e[t.name]=zod.z.object({equals:zod.z.any().optional(),not_equals:zod.z.any().optional(),in:zod.z.array(zod.z.any()).optional(),not_in:zod.z.array(zod.z.any()).optional(),greater_than:zod.z.number().optional(),greater_than_equal:zod.z.number().optional(),less_than:zod.z.number().optional(),less_than_equal:zod.z.number().optional(),like:zod.z.string().optional(),not_like:zod.z.string().optional(),contains:zod.z.string().optional(),exists:zod.z.boolean().optional()}).optional());return e.AND=zod.z.array(zod.z.lazy(()=>zod.z.object(e))).optional(),e.OR=zod.z.array(zod.z.lazy(()=>zod.z.object(e))).optional(),zod.z.object(e).optional()}function Fe(n){let e=w(n.fields);return e.id=zod.z.string().optional(),zod.z.object(e).passthrough()}function ke(n){let e={};for(let t of n.fields)if(t.name)if(t.type==="tabs"&&"tabs"in t){let s={};for(let i of t.tabs)for(let o of i.fields)o.name&&(s[o.name]=A(o).optional().nullable());e[t.name]=zod.z.object(s).optional().nullable();}else t.type==="collapsible"&&"fields"in t?e[t.name]=zod.z.object(v(t.fields)).optional().nullable():t.type==="group"&&"fields"in t?e[t.name]=zod.z.object(v(t.fields)).optional().nullable():e[t.name]=A(t).optional().nullable();return zod.z.object(e).passthrough()}var F=class{storageProviders=chunkM5JUPA7G_cjs.f();collections=new Map;globals=new Map;plugins=[];schemaCache=new Map;initialized=false;addCollection(e){if(this.initialized)throw new Error("Cannot add collections after Registry has been initialized");if(this.collections.has(e.slug)){console.warn(`[Registry] Duplicate collection slug "${e.slug}" \u2014 skipping`);return}let t={...e,fields:[...e.fields]};for(let i of this.plugins){let o=i.extensions?.collections?.find(a=>a.slug===t.slug);o&&(t={...t,...o.config,fields:[...t.fields,...o.config.fields||[]]});}if(t.seo){let i=chunkKD7LUCFY_cjs.a(),o=t.fields.findIndex(a=>a.type==="tabs"&&a.name==="tabs");if(o!==-1){let a=t.fields[o];t.fields[o]={...a,tabs:[...a.tabs,{label:"SEO Settings",fields:i.fields}]};}else t.fields.push(i);}t.fields=this.applyFieldDefaults(t);let s=B(t);if(s.length>0)throw new Error(`Invalid collection config: ${s.join(", ")}`);this.collections.set(t.slug,t),this.clearSchemaCache(t.slug);}addCollections(e){for(let t of e)this.addCollection(t);}getCollection(e){return this.collections.get(e)}getCollections(){return Array.from(this.collections.values())}getCollectionSlugs(){return Array.from(this.collections.keys())}hasCollection(e){return this.collections.has(e)}removeCollection(e){if(this.initialized)throw new Error("Cannot remove collections after Registry has been initialized");return this.clearSchemaCache(e),this.collections.delete(e)}addGlobal(e){if(this.initialized)throw new Error("Cannot add globals after Registry has been initialized");this._addGlobalUnsafe(e);}addGlobalPostInit(e){this.globals.has(e.slug)&&this.globals.delete(e.slug),this._addGlobalUnsafe(e);}_addGlobalUnsafe(e){if(this.globals.has(e.slug)){console.warn(`[Registry] Duplicate global slug "${e.slug}" \u2014 skipping`);return}let t=H(e);if(t.length>0)throw new Error(`Invalid global config: ${t.join(", ")}`);let s={...e};for(let i of this.plugins){let o=i.extensions?.globals?.find(a=>a.slug===s.slug);o&&(s={...s,...o.config,fields:[...s.fields||[],...o.config.fields||[]]});}this.globals.set(s.slug,s),this.clearSchemaCache(`global:${s.slug}`);}addGlobals(e){for(let t of e)this.addGlobal(t);}getGlobal(e){return this.globals.get(e)}getGlobals(){return Array.from(this.globals.values())}getGlobalSlugs(){return Array.from(this.globals.keys())}hasGlobal(e){return this.globals.has(e)}removeGlobal(e){if(this.initialized)throw new Error("Cannot remove globals after Registry has been initialized");return this.clearSchemaCache(`global:${e}`),this.globals.delete(e)}addPlugin(e){if(this.initialized)throw new Error("Cannot add plugins after Registry has been initialized");this.plugins.push(e);}getPlugins(){return [...this.plugins]}getZodSchema(e){let t=this.schemaCache.get(e);if(t)return t;let s=this.collections.get(e);if(s){let o=Re(s);return this.schemaCache.set(e,o),o}let i=this.globals.get(e);if(i){let o=Fe(i);return this.schemaCache.set(`global:${e}`,o),o}throw new Error(`No collection or global found with slug "${e}"`)}getCreateZodSchema(e){let t=`${e}:create`,s=this.schemaCache.get(t);if(s)return s;let i=this.collections.get(e);if(i){let o=we(i);return this.schemaCache.set(t,o),o}throw new Error(`No collection found with slug "${e}"`)}getUpdateZodSchema(e){let t=`${e}:update`,s=this.schemaCache.get(t);if(s)return s;let i=this.collections.get(e);if(i){let a=Ne(i);return this.schemaCache.set(t,a),a}let o=this.globals.get(e);if(o){let a=ke(o);return this.schemaCache.set(`global:${e}:update`,a),a}throw new Error(`No collection or global found with slug "${e}"`)}getWhereZodSchema(e){let t=`${e}:where`,s=this.schemaCache.get(t);if(s)return s;let i=this.collections.get(e);if(i){let o=De(i);return this.schemaCache.set(t,o),o}throw new Error(`No collection found with slug "${e}"`)}getFieldZodSchema(e){return A(e)}clearSchemaCache(e){this.schemaCache.delete(e),this.schemaCache.delete(`${e}:create`),this.schemaCache.delete(`${e}:update`),this.schemaCache.delete(`${e}:where`);}applyFieldDefaults(e){let t=[...e.fields];return t.some(s=>s.name==="id")||t.unshift({name:"id",type:"text",admin:{readOnly:true,hidden:true}}),e.tenantScoped&&!t.some(s=>s.name==="tenantId")&&t.push({name:"tenantId",type:"text",required:true,admin:{readOnly:true,hidden:true}}),e.timestamps&&!t.some(s=>s.name==="createdAt")&&(t.push({name:"createdAt",type:"date",admin:{readOnly:true,hidden:true}}),t.push({name:"updatedAt",type:"date",admin:{readOnly:true,hidden:true}})),e.versions?.drafts&&!t.some(s=>s.name==="status")&&t.push({name:"status",type:"select",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}],admin:{readOnly:true,hidden:true}}),e.auth&&!t.some(s=>s.name==="password")&&t.push({name:"password",type:"password",required:true,admin:{hidden:true}}),t}getFields(e){let t=this.collections.get(e);if(t)return t.fields;let s=this.globals.get(e);if(s)return s.fields;throw new Error(`No collection or global found with slug "${e}"`)}getFieldMap(e){let t=this.getFields(e),s=new Map,i=o=>{for(let a of o){if(a.name&&s.set(a.name,a),"fields"in a&&a.fields&&i(a.fields),"tabs"in a)for(let r of a.tabs)i(r.fields);if("blocks"in a)for(let r of a.blocks)i(r.fields);}};return i(t),s}getVisibleFields(e){return this.getFields(e).filter(s=>!s.admin?.hidden)}validate(){let e=this.getCollections(),t=this.getGlobals();xe(e,t);}async init(e){this.validate();for(let t of this.plugins){t.init&&await t.init(e||this);let s=t.collections||[];for(let o of s)o.slug&&!this.hasCollection(o.slug)&&this.addCollection(o);let i=t.globals||[];for(let o of i)o.slug&&!this.hasGlobal(o.slug)&&this.addGlobal(o);}this.initialized=true;}isInitialized(){return this.initialized}getPaginationDefaults(e){let t=this.collections.get(e);return {defaultLimit:t?.admin?.pagination?.defaultLimit||10,limits:t?.admin?.pagination?.limits||[10,25,50,100]}}getDefaultSort(e){let s=this.collections.get(e)?.admin?.useAsTitle;return s||"createdAt"}getDefaultColumns(e){let t=this.collections.get(e);return t?.admin?.defaultColumns?t.admin.defaultColumns:this.getVisibleFields(e).slice(0,4).map(i=>i.name)}getAdminTitle(e){let t=this.collections.get(e);return t?.label||t?.admin?.description||e}getAdminLabel(e){let t=this.collections.get(e);return t?.singularLabel||t?.label||e}getAdminGroup(e){return this.collections.get(e)?.admin?.group}getStats(){let e=0;for(let t of this.collections.values())e+=t.fields.length;for(let t of this.globals.values())e+=t.fields.length;return {collections:this.collections.size,globals:this.globals.size,plugins:this.plugins.length,fields:e}}toJSON(){return {collections:this.getCollections(),globals:this.getGlobals()}}},N=null;function ct(){return N||(N=new F),N}function dt(){N=null;}function W(){return N=new F,N}var x=class{name;displayName;adminEntry;version;description;hooks={};collections=[];globals=[];fields=[];extensions={collections:[],globals:[]};adminComponents={};adminStyles=[];serverMiddleware;clientMiddleware;constructor(e){this.name=e;}async init(e){}async beforeInit(e){}async afterInit(e){}getCollections(){return this.collections}getGlobals(){return this.globals}getHooks(){return this.hooks}},$=class{plugins=new Map;hooks=new Map;register(e){if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);this.plugins.set(e.name,e);let t=e.getHooks?.()||{};for(let[s,i]of Object.entries(t))if(Array.isArray(i))for(let o of i)this.registerHook(s,o);}unregister(e){let t=this.plugins.get(e);if(!t)return;let s=t.getHooks?.()||{};for(let[i,o]of Object.entries(s))if(Array.isArray(o))for(let a of o)this.unregisterHook(i,a);this.plugins.delete(e);}get(e){return this.plugins.get(e)}getAll(){return Array.from(this.plugins.values())}has(e){return this.plugins.has(e)}registerHook(e,t){this.hooks.has(e)||this.hooks.set(e,[]),this.hooks.get(e).push(t);}unregisterHook(e,t){let s=this.hooks.get(e);if(s){let i=s.indexOf(t);i>-1&&s.splice(i,1);}}async executeHook(e,t){let s=this.hooks.get(e)||[],i=t;for(let o of s)try{let a=await o({...t,data:i});a!==void 0&&(i=a);}catch(a){console.error(`[PluginManager] Error in hook "${e}":`,a);}return i}getAllCollections(){let e=[];for(let t of this.plugins.values()){let s=t.getCollections?.()||[];e.push(...s);}return e}getAllGlobals(){let e=[];for(let t of this.plugins.values()){let s=t.getGlobals?.()||[];e.push(...s);}return e}getAllFields(){let e=[];for(let t of this.plugins.values())e.push(...t.fields);return e}getAdminComponents(){let e={};for(let t of this.plugins.values())Object.assign(e,t.adminComponents);return e}getAdminStyles(){let e=[];for(let t of this.plugins.values())e.push(...t.adminStyles);return e}},z=class extends x{constructor(){super("seo"),this.displayName="Core SEO",this.description="Advanced SEO features including sitemaps, robots.txt, and structured data",this.adminEntry="@kyro-cms/admin/plugins/seo-admin",this.collections.push({slug:"seo-settings",label:"SEO Settings",fields:[{name:"sitemap",type:"checkbox",label:"Enable Sitemap",defaultValue:true},{name:"robotsTxt",type:"richtext",label:"robots.txt Content"},{name:"canonicalUrl",type:"text",variant:"url",label:"Canonical URL"},{name:"ogImage",type:"text",label:"Default OG Image URL"}]});}},X=class extends x{constructor(){super("analytics"),this.displayName="Core Analytics",this.description="Built-in privacy-friendly analytics and dashboards",this.collections.push({slug:"analytics-events",label:"Analytics Events",fields:[{name:"name",type:"text",required:true},{name:"properties",type:"json",label:"Event Properties"},{name:"timestamp",type:"date",required:true},{name:"userId",type:"text",label:"User ID"},{name:"sessionId",type:"text",label:"Session ID"}]}),this.adminComponents.AnalyticsDashboard={};}},J=class extends x{constructor(){super("comments"),this.description="Commenting system for products and posts",this.collections.push({slug:"comments",label:"Comments",fields:[{name:"content",type:"richtext",required:true},{name:"author",type:"text",required:true},{name:"email",type:"email"},{name:"approved",type:"checkbox",defaultValue:false},{name:"parent",type:"text",label:"Parent Comment ID"},{name:"resourceType",type:"text",required:true},{name:"resourceId",type:"text",required:true}]}),this.adminComponents.CommentModeration={};}},Y=class extends x{constructor(){super("reviews"),this.description="Product reviews and ratings",this.collections.push({slug:"reviews",label:"Reviews",fields:[{name:"rating",type:"number",required:true,min:1,max:5},{name:"title",type:"text"},{name:"content",type:"richtext",required:true},{name:"author",type:"relationship",relationTo:"customers"},{name:"product",type:"relationship",relationTo:"products",required:true},{name:"approved",type:"checkbox",defaultValue:false},{name:"verified",type:"checkbox",label:"Verified Purchase"},{name:"helpful",type:"number",label:"Helpful Count",defaultValue:0}]}),this.adminComponents.ReviewModeration={};}},Q=class extends x{constructor(){super("wishlist"),this.description="Customer wishlists",this.collections.push({slug:"wishlists",label:"Wishlists",fields:[{name:"customer",type:"relationship",relationTo:"customers",required:true},{name:"name",type:"text",label:"Wishlist Name",defaultValue:"My Wishlist"},{name:"items",type:"blocks",label:"Items",blocks:[{slug:"wishlist-item",label:"Item",fields:[{name:"product",type:"relationship",relationTo:"products"},{name:"quantity",type:"number",defaultValue:1},{name:"addedAt",type:"date"},{name:"priority",type:"select",options:[{label:"Low",value:"low"},{label:"Medium",value:"medium"},{label:"High",value:"high"}]}]}]}]});}},Ot={SEO:z,Analytics:X,Comments:J,Reviews:Y,Wishlist:Q};var ut={aws:{type:"aws",configKey:"s3",displayName:"S3 Compatible (AWS, Backblaze, Wasabi, etc.)",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"us-east-1",admin:{placeholder:"us-east-1"}},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"endpoint",type:"text",label:"Endpoint URL",admin:{placeholder:"https://s3.custom.com"}},{name:"cdnUrl",type:"text",label:"CDN URL",admin:{placeholder:"https://cdn.example.com"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads"}}]},r2:{type:"r2",configKey:"r2",displayName:"Cloudflare R2",configFields:[{name:"accountId",type:"text",label:"Account ID",required:true,admin:{placeholder:"Your Cloudflare Account ID"}},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"publicDevUrl",type:"text",label:"Public Dev URL ID",admin:{placeholder:"pub-xxxxxxxxxxxxxxxx",description:"Enter ONLY the ID (e.g., pub-b8d8c4cc8bcf4d868ddd95efc1b305aa). Do NOT include https:// or the full URL. Found in R2 Dashboard \u2192 Public Dev URL."}},{name:"cdnUrl",type:"text",label:"Custom CDN URL",admin:{placeholder:"https://assets.example.com (optional)"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads (optional)",description:"Optional prefix for all object keys. Do not use '/' as prefix."}}]},gcs:{type:"gcs",configKey:"gcs",displayName:"Google Cloud Storage",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"projectId",type:"text",label:"Project ID"},{name:"clientEmail",type:"text",label:"Client Email"},{name:"privateKey",type:"password",label:"Private Key"},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},digitalocean:{type:"digitalocean",configKey:"digitalocean",displayName:"DigitalOcean Spaces",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"nyc3"},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},backblaze:{type:"backblaze",configKey:"backblaze",displayName:"Backblaze B2",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"accountId",type:"text",label:"Account ID"},{name:"applicationKeyId",type:"text",label:"Application Key ID",required:true},{name:"applicationKey",type:"password",label:"Application Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},wasabi:{type:"wasabi",configKey:"wasabi",displayName:"Wasabi",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"us-east-1"},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]}};function pt(n,e){switch(n){case "r2":return e?.endpoint||`https://${e?.accountId||""}.r2.cloudflarestorage.com`;case "digitalocean":return e?.endpoint||`https://${e?.region||"nyc3"}.digitaloceanspaces.com`;case "backblaze":return e?.endpoint||"https://s3.backblazeb2.com";case "wasabi":return e?.endpoint||`https://s3.${e?.region||"us-east-1"}.wasabisys.com`;default:return e?.endpoint}}function Ie(n,e){return {provider:n,bucket:e?.bucket||"",region:e?.region||"us-east-1",accessKeyId:e?.accessKeyId||e?.clientEmail||e?.applicationKeyId||"",secretAccessKey:e?.secretAccessKey||e?.privateKey||e?.applicationKey||"",endpoint:pt(n,e),cdnUrl:e?.cdnUrl,prefix:e?.prefix,accountId:e?.accountId,publicDevUrl:e?.publicDevUrl}}function ft(n,e,t){let s=t[e.configKey]||{};return Ie(n,s)}function yt(n,e,t){let s=t?.[e.configKey]||t;return Ie(n,s)}var ee=class extends x{constructor(){super("@kyro-cms/storage-s3"),this.version="1.0.0",this.description="S3-compatible storage (AWS R2 GCS DigitalOcean Backblaze Wasabi)";}async init(e){let t=e.registry?.storageProviders;if(!t)return;let s=this.name;for(let i of Object.values(ut))t.register({type:i.type,displayName:i.displayName,pluginName:s,configKey:i.configKey,configFields:i.configFields,extractConfig:o=>ft(i.type,i,o),extractRawConfig:o=>yt(i.type,i,o),factory:o=>chunkM5JUPA7G_cjs.a(o)});}},Pe=new ee;var te=class extends x{constructor(){super("@kyro-cms/storage-cloudinary"),this.version="1.0.0",this.description="Cloudinary image and video storage";}async init(e){let t=e.registry?.storageProviders;t&&t.register({type:"cloudinary",displayName:"Cloudinary",pluginName:this.name,configKey:"cloudinary",configFields:[{name:"cloudName",type:"text",label:"Cloud Name",required:true},{name:"apiKey",type:"text",label:"API Key",required:true},{name:"apiSecret",type:"password",label:"API Secret",required:true},{name:"folder",type:"text",label:"Folder",admin:{placeholder:"Optional folder path"}},{name:"uploadPreset",type:"text",label:"Upload Preset (optional)",admin:{placeholder:"Leave empty for signed uploads",description:"If not set, uploads will be signed with API Secret"}}],extractConfig:s=>({cloudName:s.cloudinary?.cloudName||"",apiKey:s.cloudinary?.apiKey||"",apiSecret:s.cloudinary?.apiSecret||"",folder:s.cloudinary?.folder,uploadPreset:s.cloudinary?.uploadPreset}),extractRawConfig:s=>{let i=s?.cloudinary||s;return {cloudName:i?.cloudName||"",apiKey:i?.apiKey||"",apiSecret:i?.apiSecret||"",folder:i?.folder,uploadPreset:i?.uploadPreset}},factory:s=>chunkM5JUPA7G_cjs.b(s)});}},Oe=new te;var se=class extends x{constructor(){super("@kyro-cms/storage-ftp"),this.version="1.0.0",this.description="FTP/SFTP storage provider";}async init(e){let t=e.registry?.storageProviders;t&&t.register({type:"ftp",displayName:"FTP",pluginName:this.name,configKey:"ftp",configFields:[{name:"host",type:"text",label:"Host",required:true,admin:{placeholder:"ftp.example.com"}},{name:"port",type:"number",label:"Port",defaultValue:21,admin:{placeholder:"21 for FTP"}},{name:"user",type:"text",label:"Username",required:true},{name:"password",type:"password",label:"Password",required:true},{name:"secure",type:"checkbox",label:"Use TLS/SSL",defaultValue:false,admin:{description:"Enable TLS/SSL for secure connections (FTP only)"}},{name:"baseUrl",type:"text",label:"Base URL",required:true,admin:{placeholder:"https://files.example.com"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads"}}],extractConfig:s=>({host:s.ftp?.host||"",port:s.ftp?.port||21,user:s.ftp?.user||"",password:s.ftp?.password||"",secure:s.ftp?.secure||false,baseUrl:s.ftp?.baseUrl||"",prefix:s.ftp?.prefix,type:"ftp"}),extractRawConfig:s=>{let i=s?.ftp||s;return {host:i?.host||"",port:i?.port||21,user:i?.user||"",password:i?.password||"",secure:i?.secure||false,baseUrl:i?.baseUrl||"",prefix:i?.prefix,type:"ftp"}},factory:s=>chunkM5JUPA7G_cjs.c(s)});}},$e=new se;var ht=[Pe,Oe,$e];function ne(n,e,t){let s=e.split(".");if(s.length===0)return false;let i=s[0],o=s.slice(1).join(".");for(let a of n)if(a.name===i)return o?a.fields&&Array.isArray(a.fields)||a.type==="array"&&a.fields&&Array.isArray(a.fields)?ne(a.fields,o,t):false:(Object.assign(a,t),true);return o?false:(n.push({name:i,...t}),true)}function mt(n,e){if(e)for(let t of n){let s=e[t.slug];if(s){let{fields:i,...o}=s;if(t.admin={...t.admin,...o},i&&t.fields&&Array.isArray(t.fields))for(let[a,r]of Object.entries(i))ne(t.fields,a,r);}}}var ie=class{registry;db;pubsub;webhookService;settings;pluginManager;wsServer;config;constructor(e){this.config=e,this.registry=W(),this.db=e.adapter,this.pubsub=new chunkG3J2EU5D_cjs.b(this.registry),this.webhookService=chunkXUONID6O_cjs.o(this.db),this.pluginManager=new $;for(let t of ht)this.pluginManager.register(t),this.registry.addPlugin(t);if(e.plugins)for(let t of e.plugins)this.pluginManager.register(t),this.registry.addPlugin(t);e.collections&&e.admin?.collectionOverrides&&mt(e.collections,e.admin.collectionOverrides),e.collections&&this.registry.addCollections(e.collections),e.globals&&this.registry.addGlobals(e.globals);}async init(){await this.pluginManager.executeHook("beforeInit",{kyro:this}),await this.registry.init(this),await this.pluginManager.executeHook("afterInit",{kyro:this}),this.registry.addGlobalPostInit(chunk65G73T7Z_cjs.a);let e={slug:"plugin-settings",admin:{hidden:true},fields:[{name:"states",type:"json"}]};if(this.registry.addGlobalPostInit(e),!this.db)throw new Error("Database adapter is null \u2014 failed to load at startup. Check the server console for the exact error.");let t={slug:chunkNY47CFVP_cjs.d,fields:[{name:"userId",type:"text",required:true},{name:"name",type:"text",required:true},{name:"key",type:"text",required:true},{name:"keyPrefix",type:"text",required:true},{name:"permissions",type:"json"},{name:"lastUsedAt",type:"date"},{name:"expiresAt",type:"date"}]},s={slug:chunkXUONID6O_cjs.f,fields:[{name:"name",type:"text",required:true},{name:"url",type:"text",required:true},{name:"events",type:"json",required:true},{name:"collections",type:"json"},{name:"status",type:"text",required:true},{name:"secret",type:"text"},{name:"headers",type:"json"},{name:"action",type:"text"},{name:"config",type:"json"},{name:"lastTriggered",type:"date"},{name:"lastError",type:"text"}]},i={slug:chunkXUONID6O_cjs.g,fields:[{name:"webhookId",type:"text",required:true},{name:"event",type:"text",required:true},{name:"payload",type:"json",required:true},{name:"attempt",type:"number",required:true},{name:"status",type:"text",required:true},{name:"responseStatus",type:"number"},{name:"responseBody",type:"text"},{name:"error",type:"text"},{name:"duration",type:"number"},{name:"deliveredAt",type:"date"},{name:"nextRetryAt",type:"date"}]},o=this.registry.getGlobals();if(this.db instanceof chunk3ZFRP5M2_cjs.c&&this.db.dialect==="postgres"){let a=this.db,r=chunkNY47CFVP_cjs.d.replace(/-/g,"_");a.schema[r]||(a.schema[r]=chunkMIOMMB23_cjs.g);}await this.db.init([...this.registry.getCollections(),t,s,i],o),await this.loadPluginState(),this.pubsub.autoRegisterHooks();}async loadSettings(){if(this.settings)return this.settings;try{let e=await this.db.findOne({collection:"_globals_access-settings",where:{},draft:!0});e&&(this.settings={access:e});}catch{}return this.settings||{}}async loadPluginState(){let e=this.registry.storageProviders,t=e.getAllPluginNames(),s={};try{let i=await this.db.findOne({collection:"_globals_plugin-settings",where:{},draft:!0});i&&i.states&&(s=i.states);}catch{}for(let i of t)s[i]!==void 0&&e.setPluginEnabled(i,s[i]);}getREST(e){let t=typeof this.config.auth=="object"?this.config.auth:null,s=t?.secret,i=t?.checkSession!==false;return chunkM5JUPA7G_cjs.s({registry:this.registry,db:this.db,authSecret:s,authAdapter:this.config.authAdapter,checkSession:i,...e,cors:this.config.cors,webhookService:this.webhookService,settings:this.settings})}getGraphQL(e){let t=chunkHS2KNFAB_cjs.c({registry:this.registry,db:this.db,settings:this.settings});return {fetch:graphqlYoga.createYoga({schema:t,context:async({request:i})=>{let o=chunkNY47CFVP_cjs.f(i),a,r;if(o&&this.db){let d=await chunkNY47CFVP_cjs.e(o,this.db);d.user&&(a=d.user,r=chunkNY47CFVP_cjs.g(d));}let c=e?.tenantId;return {db:this.db,registry:this.registry,user:a,req:i,tenantId:c,apiKey:r,relationLoader:new chunkHS2KNFAB_cjs.a({db:this.db,tenantId:c,user:a})}},graphiql:this.config.graphQL?.disablePlayground!==true,plugins:[]}).fetch,schema:t}}getTRPC(e){return {fetch:async(t,s)=>{let o=new URL(t.url).pathname.replace(/^\/api\/trpc\//,""),[a,...r]=o.split("."),c=r.join(".");if(c=c.replace(/\.(query|mutate|subscribe)$/,""),!a||!c)return new Response(JSON.stringify({error:{message:"Invalid tRPC path",code:-32600,data:{code:"BAD_REQUEST",httpStatus:400}}}),{status:400,headers:{"Content-Type":"application/json"}});let d=await chunkWMZEULS2_cjs.a({db:this.db,registry:this.registry,req:t,user:e?.user,tenantId:e?.tenantId,settings:this.settings}),p=chunkWMZEULS2_cjs.i(d)[a];if(!p)return new Response(JSON.stringify({error:{message:`Collection '${a}' not found`,code:-32601,data:{code:"NOT_FOUND",httpStatus:404}}}),{status:404,headers:{"Content-Type":"application/json"}});let m=p[c];if(typeof m!="function")return new Response(JSON.stringify({error:{message:`Procedure '${c}' not found`,code:-32601,data:{code:"NOT_FOUND",httpStatus:404}}}),{status:404,headers:{"Content-Type":"application/json"}});try{let y={};if(t.method==="POST"||t.method==="PATCH")y=await t.json().catch(()=>({}));else {let C=new URL(t.url).searchParams.get("input");if(C)try{y=JSON.parse(decodeURIComponent(C));}catch{}}let g=y?.["0"]??y,f=await m({...g,collection:a});return new Response(JSON.stringify({result:{data:f}}),{status:200,headers:{"Content-Type":"application/json"}})}catch(y){let g=y.message||"Internal error",f=g.includes("not found")?404:g.includes("denied")||g.includes("authentication required")?403:g.includes("conflict")?409:500,C=f===404?-32601:f===403?-32001:f===409?-32002:-32603;return new Response(JSON.stringify({error:{message:g,code:C,data:{code:"INTERNAL_SERVER_ERROR",httpStatus:f}}}),{status:f,headers:{"Content-Type":"application/json"}})}},router:null}}getWS(){return this.wsServer}async startWebSocket(e){let t=this.settings?.access?.apiAccess;if(t?.wsEnabled===false)return null;let s=async o=>{let a=await chunkNY47CFVP_cjs.e(o,this.db);if(!a.valid)throw new Error(a.error||"Invalid API key");if(!a.user)throw new Error("API key has no associated user");return a.user},i=e?.port||8080;if(globalThis.__KYRO_WS_SERVER__)try{await globalThis.__KYRO_WS_SERVER__.close();}catch{}return this.wsServer=chunkG3J2EU5D_cjs.d({pubsub:this.pubsub,port:i,requireAuth:e?.requireAuth??t?.requireAuth,verifyToken:e?.verifyToken||s}),globalThis.__KYRO_WS_SERVER__=this.wsServer,this.wsServer}async shutdown(){await this.pluginManager.executeHook("beforeServerStop",{kyro:this}),this.wsServer&&await this.wsServer.close(),await this.db.disconnect(),await this.pluginManager.executeHook("afterServerStop",{kyro:this});}};function fs(n){return new ie(n)}var Tt=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-IQYP3DDJ.cjs', document.baseURI).href))),Ct="node:sqlite",{DatabaseSync:At}=Tt(Ct);function E(n){let e=[];for(let t of n)if(t.type==="tabs"&&"tabs"in t)for(let s of t.tabs)e.push(...E(s.fields));else t.type==="row"&&"fields"in t?e.push(...E(t.fields)):t.type==="collapsible"&&"fields"in t?e.push(...E(t.fields)):e.push(t);return e}function xt(n,e){let t=e,s=n[t.name];if(t.type==="json"||t.type==="richtext"||t.type==="array"||t.type==="group"||t.type==="blocks"||t.type==="list"||t.type==="relationship-block")try{s=s?JSON.parse(s):null;}catch{s=null;}if(t.type==="checkbox"&&(s=!!s),t.type==="date"&&s)try{let i=new Date(s);isNaN(i.getTime())?s=null:s=i.toISOString();}catch{s=null;}if((t.type==="upload"||t.type==="image")&&s)try{let i=JSON.parse(s);Array.isArray(i)?s=i.map(o=>typeof o=="object"&&o!==null?o:{id:o}):s=typeof i=="object"?i:{id:i};}catch{s={id:s};}if(t.type==="relationship"&&s)try{let i=JSON.parse(s);Array.isArray(i),s=i;}catch{s={relationTo:Array.isArray(t.relationTo)?t.relationTo[0]:t.relationTo,value:s};}if(t.type==="list"&&s)try{let i=JSON.parse(s);s=Array.isArray(i)?i:[];}catch{s=[];}if(t.type==="relationship-block"&&s)try{let i=JSON.parse(s);s=Array.isArray(i)?i:[];}catch{s=[];}return s}function Le(n,e){return Array.isArray(n)?n.map(t=>{if(!t||typeof t!="object")return t;let s=t.data?{...t.data}:void 0;if(!s)return t;let i=e.find(o=>o.slug===t.type||o.slug===t.slug);if(!i||!Array.isArray(i.fields))return t;for(let o of i.fields){if(o.name&&(o.type==="upload"||o.type==="image")&&s[o.name]){let a=s[o.name];Array.isArray(a)?s[o.name]=a.map(r=>typeof r=="string"?{id:r}:r):typeof a=="string"&&(s[o.name]={id:a});}if(o.type==="blocks"&&o.name&&s[o.name]){let a=o.blocks||[];s[o.name]=Le(s[o.name],a);}}return {...t,data:s}}):n}function oe(n,e){try{return n.prepare(`PRAGMA table_info(${e})`).all().map(s=>s.name)}catch{return []}}var ae=class extends chunkEJDIR56C_cjs.a{db;path;migrations=new Map;versionsTableName="kyro_versions";constructor(e){super(),this.path=e.path,e.db?this.db=e.db:this.db=null;}async connect(){if(this.db||(this.db=new At(this.path||":memory:")),this.db&&typeof this.db.prepare=="function"&&!this.db.prepare.__wrapped){let e=this.db.prepare.bind(this.db),t=s=>{let i=e(s),o=a=>typeof a=="boolean"?a?1:0:a===void 0?null:a;return new Proxy(i,{get(a,r,c){if(r==="all")return (...u)=>a.all(...u.map(o));if(r==="get")return (...u)=>a.get(...u.map(o));if(r==="run")return (...u)=>a.run(...u.map(o));let d=Reflect.get(a,r,c);return typeof d=="function"?d.bind(a):d}})};t.__wrapped=true,this.db.prepare=t;}this.db.exec("PRAGMA journal_mode = WAL"),this.db.exec("PRAGMA foreign_keys = ON"),this.connected=true;}async disconnect(){this.db&&this.db.close(),this.connected=false;}ensureTable(e,t){let s=t||this.getTableNameFor(e.slug),i=["id TEXT PRIMARY KEY"];for(let r of E(e.fields)){if(!r.name||r.name==="id")continue;let c=this.fieldToSQL(r);c&&i.push(c);}let o=E(e.fields);o.some(r=>r.name==="createdAt")||i.push(`${this.col("createdAt")} TEXT DEFAULT (datetime('now'))`),o.some(r=>r.name==="updatedAt")||i.push(`${this.col("updatedAt")} TEXT DEFAULT (datetime('now'))`),o.some(r=>r.name==="status")||i.push("status TEXT DEFAULT 'draft'"),o.some(r=>r.name==="hasDraft")||i.push("hasDraft INTEGER DEFAULT 0"),e.tenantScoped&&i.push("tenant_id TEXT NOT NULL");let a=oe(this.db,s);if(a.length===0){let r=`CREATE TABLE IF NOT EXISTS ${s} (${i.join(", ")})`;this.db.exec(r),this.db.exec(`CREATE INDEX IF NOT EXISTS idx_${s}_status ON ${s}(status)`);for(let c of E(e.fields))c.name&&c.indexed&&this.db.exec(`CREATE INDEX IF NOT EXISTS idx_${s}_${c.name} ON ${s}(${this.col(c.name)})`),c.name&&c.unique&&this.db.exec(`CREATE UNIQUE INDEX IF NOT EXISTS idx_${s}_${c.name}_unique ON ${s}(${this.col(c.name)})`);}else {let r=new Set(a);for(let c of i){let d=c.split(" ")[0].replace(/^"/,"").replace(/"$/,"");if(!r.has(d)&&d!=="id")try{d==="status"?this.db.exec(`ALTER TABLE ${s} ADD COLUMN ${this.col(d)} TEXT DEFAULT 'published'`):d==="hasDraft"?this.db.exec(`ALTER TABLE ${s} ADD COLUMN ${this.col(d)} INTEGER DEFAULT 0`):this.db.exec(`ALTER TABLE ${s} ADD COLUMN ${this.col(d)} TEXT`);}catch{}}}this.migrations.set(s,true);}ensureVersionsTable(){this.db.exec(`
|
|
3
|
+
`)}`),this.name="ConfigValidationError",this.errors=e;}};function B(n){let e=[];if(n.slug?/^[a-z][a-z0-9_-]*$/.test(n.slug)||e.push(`Collection slug "${n.slug}" must be lowercase alphanumeric with dashes`):e.push('Collection is missing a "slug" property'),!n.fields||n.fields.length===0)e.push(`Collection "${n.slug}" has no fields defined`);else {let t=R(n.fields,n.slug);e.push(...t);}if(n.access)for(let[t,s]of Object.entries(n.access))typeof s!="boolean"&&typeof s!="function"&&e.push(`Collection "${n.slug}" has invalid access.${t} (must be boolean or function)`);if(n.admin?.useAsTitle&&(O(n.fields,n.admin.useAsTitle)||e.push(`Collection "${n.slug}" admin.useAsTitle references unknown field "${n.admin.useAsTitle}"`)),n.admin?.defaultColumns)for(let t of n.admin.defaultColumns)O(n.fields,t)||e.push(`Collection "${n.slug}" admin.defaultColumns references unknown field "${t}"`);if(n.upload&&n.upload.fileSize&&n.upload.fileSize<=0&&e.push(`Collection "${n.slug}" upload.fileSize must be positive`),n.versions&&n.versions.maxPerDoc&&n.versions.maxPerDoc<=0&&e.push(`Collection "${n.slug}" versions.maxPerDoc must be positive`),n.auth){let t=n.fields.some(i=>i.name==="email"),s=n.fields.some(i=>i.name==="password");t||e.push(`Collection "${n.slug}" with auth enabled requires an "email" field`),s||e.push(`Collection "${n.slug}" with auth enabled requires a "password" field`);}return e}function H(n){let e=[];if(n.slug?/^[a-z][a-z0-9_-]*$/.test(n.slug)||e.push(`Global slug "${n.slug}" must be lowercase alphanumeric with dashes`):e.push('Global is missing a "slug" property'),!n.fields||n.fields.length===0)e.push(`Global "${n.slug}" has no fields defined`);else {let t=R(n.fields,`global:${n.slug}`);e.push(...t);}return e}function R(n,e){let t=[],s=new Set;for(let i=0;i<n.length;i++){let o=n[i];if(o.type==="row"||o.type==="collapsible"||o.type==="tabs"){if("fields"in o&&o.fields){let r=R(o.fields,e);t.push(...r);}else if("tabs"in o)for(let r of o.tabs){let c=R(r.fields,e);t.push(...c);}continue}let a=o.name;if(!a){t.push(`${e}: Field at index ${i} is missing a "name" property`);continue}if(s.has(a)&&t.push(`${e}: Duplicate field name "${a}"`),s.add(a),/^[a-zA-Z][a-zA-Z0-9_]*$/.test(a)||t.push(`${e}: Field name "${a}" must be alphanumeric with underscores`),!o.type){t.push(`${e}: Field "${a}" is missing a "type" property`);continue}switch(o.type){case "relationship":o.relationTo||t.push(`${e}: Relationship field "${a}" is missing "relationTo"`);break;case "array":if(!o.fields||o.fields.length===0)t.push(`${e}: Array field "${a}" has no fields defined`);else {let r=R(o.fields,`${e}.${a}`);t.push(...r);}break;case "group":if(!o.fields||o.fields.length===0)t.push(`${e}: Group field "${a}" has no fields defined`);else {let r=R(o.fields,`${e}.${a}`);t.push(...r);}break;case "blocks":if(!o.blocks||o.blocks.length===0)t.push(`${e}: Blocks field "${a}" has no blocks defined`);else {let r=Ge(o.blocks,`${e}.${a}`);t.push(...r);}break;case "select":case "radio":if(typeof o.options=="function")break;if((!o.options||o.options.length===0)&&!o.dynamicOptions)t.push(`${e}: ${o.type} field "${a}" has no options defined`);else if(Array.isArray(o.options)){let r=o.options.map(d=>d.value),c=new Set(r);r.length!==c.size&&t.push(`${e}: ${o.type} field "${a}" has duplicate option values`);}break;case "upload":o.relationTo||t.push(`${e}: Upload field "${a}" is missing "relationTo"`);break}"min"in o&&"max"in o&&o.min>o.max&&t.push(`${e}: Field "${a}" has min greater than max`),"minLength"in o&&"maxLength"in o&&o.minLength>o.maxLength&&t.push(`${e}: Field "${a}" has minLength greater than maxLength`),"minRows"in o&&"maxRows"in o&&o.minRows>o.maxRows&&t.push(`${e}: Field "${a}" has minRows greater than maxRows`);}return t}function Ge(n,e){let t=[],s=new Set;for(let i of n){if(!i.slug){t.push(`${e}: Block is missing a "slug" property`);continue}if(s.has(i.slug)&&t.push(`${e}: Duplicate block slug "${i.slug}"`),s.add(i.slug),i.label||t.push(`${e}: Block "${i.slug}" is missing a "label" property`),!i.fields||i.fields.length===0)t.push(`${e}: Block "${i.slug}" has no fields defined`);else {let o=R(i.fields,`${e}.${i.slug}`);t.push(...o);}}return t}function xe(n,e=[]){let t=[],s=new Set;for(let i of n)s.has(i.slug)&&t.push(`Duplicate collection slug "${i.slug}"`),s.add(i.slug);for(let i of e)s.has(i.slug)&&t.push(`Duplicate global slug "${i.slug}"`),s.add(i.slug);for(let i of n){let o=B(i);t.push(...o);}for(let i of e){let o=H(i);t.push(...o);}for(let i of n){let o=P(i.fields,n);t.push(...o);}if(t.length>0)throw new V(t)}function P(n,e){let t=[],s=new Set(e.map(i=>i.slug));for(let i of n){if(i.type==="relationship"){let o=Array.isArray(i.relationTo)?i.relationTo:[i.relationTo];for(let a of o)a!=="*"&&!s.has(a)&&console.warn(`[Kyro Config Warning]: Relationship field "${i.name}" references unknown collection "${a}". Select options will not be available until this collection is registered.`);}if(i.type==="upload"){let o=Array.isArray(i.relationTo)?i.relationTo:[i.relationTo];for(let a of o)s.has(a)||t.push(`Upload field "${i.name}" references unknown collection "${a}"`);}if("fields"in i&&i.fields){let o=P(i.fields,e);t.push(...o);}if("tabs"in i)for(let o of i.tabs){let a=P(o.fields,e);t.push(...a);}if("blocks"in i)for(let o of i.blocks){let a=P(o.fields,e);t.push(...a);}}return t}function A(n){switch(n.type){case "text":return Ue(n);case "number":return Ke(n);case "checkbox":return Me(n);case "date":return Ve(n);case "email":return Be(n);case "password":return He(n);case "textarea":return We(n);case "select":return ze(n);case "radio":return Xe(n);case "color":return Je(n);case "richtext":return Ye(n);case "json":return Qe(n);case "code":return et(n);case "upload":return ve(n);case "image":return ve(n);case "markdown":return tt(n);case "relationship":return Ee(n);case "relationship-block":return Ee(n);case "array":return st(n);case "list":return nt(n);case "group":return it(n);case "blocks":return ot(n);case "row":return at(n);case "collapsible":return rt(n);case "tabs":return lt(n);default:return zod.z.any()}}function Ue(n){let e=zod.z.string();return n.minLength&&(e=e.min(n.minLength)),n.maxLength&&(e=e.max(n.maxLength)),n.pattern&&(e=e.regex(new RegExp(n.pattern))),n.variant==="email"&&(e=e.email()),n.variant==="url"&&(e=e.url()),n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Ke(n){let e=n.integer?zod.z.coerce.number().int():zod.z.coerce.number();return n.min!==void 0&&(e=e.min(n.min)),n.max!==void 0&&(e=e.max(n.max)),n.step&&(e=e.refine(t=>Number.isInteger(t/n.step),`Value must be divisible by ${n.step}`)),n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Me(n){let e=zod.z.boolean();return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Ve(n){let e=zod.z.string().refine(t=>!isNaN(Date.parse(t)),"Invalid date format");return n.minDate&&(e=e.refine(t=>new Date(t)>=new Date(n.minDate),`Date must be after ${n.minDate}`)),n.maxDate&&(e=e.refine(t=>new Date(t)<=new Date(n.maxDate),`Date must be before ${n.maxDate}`)),n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Be(n){let e=zod.z.string().email("Invalid email");return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function He(n){let e=zod.z.string().min(6,"Password must be at least 6 characters");return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function We(n){let e=zod.z.string();return n.minLength&&(e=e.min(n.minLength)),n.maxLength&&(e=e.max(n.maxLength)),n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function ze(n){let e;if(Array.isArray(n.options)&&n.options.length>0){let t=n.options.map(s=>s.value);n.hasMany?e=zod.z.array(zod.z.enum(t)):e=zod.z.enum(t);}else e=n.hasMany?zod.z.array(zod.z.string()):zod.z.string();return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Xe(n){let e;if(Array.isArray(n.options)&&n.options.length>0){let t=n.options.map(s=>s.value);e=zod.z.enum(t);}else e=zod.z.string();return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Je(n){let e=zod.z.string();return n.format==="hex"&&(e=e.regex(/^#[0-9A-Fa-f]{6}$/)),n.format==="rgb"&&(e=e.regex(/^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$/)),n.format==="hsl"&&(e=e.regex(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/)),n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Ye(n){let e=zod.z.array(zod.z.record(zod.z.any()));return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Qe(n){let e=zod.z.union([zod.z.record(zod.z.any()),zod.z.array(zod.z.any())]);return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function et(n){let e=zod.z.string();return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function ve(n){let e;if(n.relationTo){let t=zod.z.object({id:zod.z.string(),url:zod.z.string().optional(),filename:zod.z.string().optional(),mimeType:zod.z.string().optional()});e=zod.z.union([zod.z.string(),t]);}else e=zod.z.string();return n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function tt(n){let e=zod.z.string();return n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function Ee(n){let e;return Array.isArray(n.relationTo)?e=zod.z.object({relationTo:zod.z.enum(n.relationTo),value:zod.z.string()}):e=zod.z.union([zod.z.string(),zod.z.object({relationTo:zod.z.string(),value:zod.z.string()})]),n.hasMany&&(e=zod.z.array(e)),n.required||(e=e.optional().nullable()),n.validate&&(e=T(e,n.validate)),e}function st(n){let e=zod.z.object(Object.fromEntries(n.fields.filter(s=>s.name).map(s=>[s.name,A(s)]))).passthrough(),t=zod.z.array(e);return n.minRows&&(t=t.min(n.minRows)),n.maxRows&&(t=t.max(n.maxRows)),n.required||(t=t.optional().nullable()),n.validate&&(t=T(t,n.validate)),t}function nt(n){let e=zod.z.array(zod.z.string());return n.required||(e=e.optional().nullable()),e}function it(n){let e=zod.z.object(Object.fromEntries(n.fields.filter(t=>t.name).map(t=>[t.name,A(t)])));return n.required?e:e.optional().nullable()}function ot(n){let e=n.blocks||[];e.map(o=>zod.z.object({blockType:zod.z.literal(o.slug),...Object.fromEntries(o.fields.filter(a=>a.name).map(a=>[a.name,A(a)]))}));let s=e.map(o=>o.slug),i;if(s.length>0){let o=zod.z.object({blockType:zod.z.enum(s)}).catchall(zod.z.any()),a=zod.z.object({blockType:zod.z.string()}).catchall(zod.z.any());i=zod.z.array(zod.z.union([o,a,zod.z.record(zod.z.any())]));}else i=zod.z.array(zod.z.union([zod.z.object({blockType:zod.z.string()}).catchall(zod.z.any()),zod.z.record(zod.z.any())]));return n.minRows&&(i=i.min(n.minRows)),n.maxRows&&(i=i.max(n.maxRows)),n.required||(i=i.optional().nullable()),n.validate&&(i=T(i,n.validate)),i}function at(n){return zod.z.object(Object.fromEntries(n.fields.filter(t=>t.name).map(t=>[t.name,A(t)])))}function rt(n){return zod.z.object(Object.fromEntries(n.fields.filter(t=>t.name).map(t=>[t.name,A(t)])))}function lt(n){let e={};for(let t of n.tabs)for(let s of t.fields)s.name&&(e[s.name]=A(s));return zod.z.object(e).passthrough().optional()}function T(n,e){return n.refine(async t=>await e(t,{required:false})===true,{message:"Custom validation failed"})}function w(n){let e={};for(let t of n)if(t.type==="tabs"&&"tabs"in t){let s={};for(let i of t.tabs){let o=w(i.fields);Object.assign(s,o);}t.name?e[t.name]=zod.z.object(s).passthrough().optional():Object.assign(e,s);}else if(t.type==="row"&&"fields"in t){let s=w(t.fields);t.name?e[t.name]=zod.z.object(s).passthrough().optional():Object.assign(e,s);}else if(t.type==="collapsible"&&"fields"in t){let s=w(t.fields);t.name?e[t.name]=zod.z.object(s).passthrough().optional():Object.assign(e,s);}else {if(!t.name)continue;e[t.name]=A(t);}return e}function v(n){let e={};for(let t of n)if(t.type==="tabs"&&"tabs"in t){let s={};for(let i of t.tabs){let o=v(i.fields);Object.assign(s,o);}t.name?e[t.name]=zod.z.object(s).passthrough().optional().nullable():Object.assign(e,s);}else if(t.type==="row"&&"fields"in t){let s=v(t.fields);t.name?e[t.name]=zod.z.object(s).passthrough().optional().nullable():Object.assign(e,s);}else if(t.type==="collapsible"&&"fields"in t){let s=v(t.fields);t.name?e[t.name]=zod.z.object(s).passthrough().optional().nullable():Object.assign(e,s);}else if(t.type==="group"&&"fields"in t)t.name?e[t.name]=zod.z.object(v(t.fields)).passthrough().optional().nullable():Object.assign(e,v(t.fields));else {if(!t.name)continue;e[t.name]=A(t).optional().nullable();}return e}function Re(n){let e=w(n.fields);return n.timestamps&&(e.createdAt=zod.z.string().optional(),e.updatedAt=zod.z.string().optional()),n.tenantScoped&&(e.tenantId=zod.z.string().optional()),e.id=zod.z.string().optional(),zod.z.object(e).passthrough()}function we(n){let e=w(n.fields);return zod.z.object(e).passthrough()}function Ne(n){let e={};for(let t of n.fields)if(t.name)if(t.type==="tabs"&&"tabs"in t){let s={};for(let i of t.tabs)for(let o of i.fields)o.name&&(s[o.name]=A(o).optional().nullable());e[t.name]=zod.z.object(s).optional().nullable();}else if(t.type==="row"&&"fields"in t){let s={};for(let i of t.fields)i.name&&(s[i.name]=A(i).optional().nullable());Object.assign(e,s);}else t.type==="collapsible"&&"fields"in t?e[t.name]=zod.z.object(v(t.fields)).optional().nullable():t.type==="group"&&"fields"in t?e[t.name]=zod.z.object(v(t.fields)).optional().nullable():e[t.name]=A(t).optional().nullable();return zod.z.object(e).passthrough()}function De(n){let e={};for(let t of n.fields)t.name&&(e[t.name]=zod.z.object({equals:zod.z.any().optional(),not_equals:zod.z.any().optional(),in:zod.z.array(zod.z.any()).optional(),not_in:zod.z.array(zod.z.any()).optional(),greater_than:zod.z.number().optional(),greater_than_equal:zod.z.number().optional(),less_than:zod.z.number().optional(),less_than_equal:zod.z.number().optional(),like:zod.z.string().optional(),not_like:zod.z.string().optional(),contains:zod.z.string().optional(),exists:zod.z.boolean().optional()}).optional());return e.AND=zod.z.array(zod.z.lazy(()=>zod.z.object(e))).optional(),e.OR=zod.z.array(zod.z.lazy(()=>zod.z.object(e))).optional(),zod.z.object(e).optional()}function Fe(n){let e=w(n.fields);return e.id=zod.z.string().optional(),zod.z.object(e).passthrough()}function ke(n){let e={};for(let t of n.fields)if(t.name)if(t.type==="tabs"&&"tabs"in t){let s={};for(let i of t.tabs)for(let o of i.fields)o.name&&(s[o.name]=A(o).optional().nullable());e[t.name]=zod.z.object(s).optional().nullable();}else t.type==="collapsible"&&"fields"in t?e[t.name]=zod.z.object(v(t.fields)).optional().nullable():t.type==="group"&&"fields"in t?e[t.name]=zod.z.object(v(t.fields)).optional().nullable():e[t.name]=A(t).optional().nullable();return zod.z.object(e).passthrough()}var F=class{storageProviders=chunkLMIBASPC_cjs.f();collections=new Map;globals=new Map;plugins=[];schemaCache=new Map;initialized=false;addCollection(e){if(this.initialized)throw new Error("Cannot add collections after Registry has been initialized");if(this.collections.has(e.slug)){console.warn(`[Registry] Duplicate collection slug "${e.slug}" \u2014 skipping`);return}let t={...e,fields:[...e.fields]};for(let i of this.plugins){let o=i.extensions?.collections?.find(a=>a.slug===t.slug);o&&(t={...t,...o.config,fields:[...t.fields,...o.config.fields||[]]});}if(t.seo){let i=chunkKD7LUCFY_cjs.a(),o=t.fields.findIndex(a=>a.type==="tabs"&&a.name==="tabs");if(o!==-1){let a=t.fields[o];t.fields[o]={...a,tabs:[...a.tabs,{label:"SEO Settings",fields:i.fields}]};}else t.fields.push(i);}t.fields=this.applyFieldDefaults(t);let s=B(t);if(s.length>0)throw new Error(`Invalid collection config: ${s.join(", ")}`);this.collections.set(t.slug,t),this.clearSchemaCache(t.slug);}addCollections(e){for(let t of e)this.addCollection(t);}getCollection(e){return this.collections.get(e)}getCollections(){return Array.from(this.collections.values())}getCollectionSlugs(){return Array.from(this.collections.keys())}hasCollection(e){return this.collections.has(e)}removeCollection(e){if(this.initialized)throw new Error("Cannot remove collections after Registry has been initialized");return this.clearSchemaCache(e),this.collections.delete(e)}addGlobal(e){if(this.initialized)throw new Error("Cannot add globals after Registry has been initialized");this._addGlobalUnsafe(e);}addGlobalPostInit(e){this.globals.has(e.slug)&&this.globals.delete(e.slug),this._addGlobalUnsafe(e);}_addGlobalUnsafe(e){if(this.globals.has(e.slug)){console.warn(`[Registry] Duplicate global slug "${e.slug}" \u2014 skipping`);return}let t=H(e);if(t.length>0)throw new Error(`Invalid global config: ${t.join(", ")}`);let s={...e};for(let i of this.plugins){let o=i.extensions?.globals?.find(a=>a.slug===s.slug);o&&(s={...s,...o.config,fields:[...s.fields||[],...o.config.fields||[]]});}this.globals.set(s.slug,s),this.clearSchemaCache(`global:${s.slug}`);}addGlobals(e){for(let t of e)this.addGlobal(t);}getGlobal(e){return this.globals.get(e)}getGlobals(){return Array.from(this.globals.values())}getGlobalSlugs(){return Array.from(this.globals.keys())}hasGlobal(e){return this.globals.has(e)}removeGlobal(e){if(this.initialized)throw new Error("Cannot remove globals after Registry has been initialized");return this.clearSchemaCache(`global:${e}`),this.globals.delete(e)}addPlugin(e){if(this.initialized)throw new Error("Cannot add plugins after Registry has been initialized");this.plugins.push(e);}getPlugins(){return [...this.plugins]}getZodSchema(e){let t=this.schemaCache.get(e);if(t)return t;let s=this.collections.get(e);if(s){let o=Re(s);return this.schemaCache.set(e,o),o}let i=this.globals.get(e);if(i){let o=Fe(i);return this.schemaCache.set(`global:${e}`,o),o}throw new Error(`No collection or global found with slug "${e}"`)}getCreateZodSchema(e){let t=`${e}:create`,s=this.schemaCache.get(t);if(s)return s;let i=this.collections.get(e);if(i){let o=we(i);return this.schemaCache.set(t,o),o}throw new Error(`No collection found with slug "${e}"`)}getUpdateZodSchema(e){let t=`${e}:update`,s=this.schemaCache.get(t);if(s)return s;let i=this.collections.get(e);if(i){let a=Ne(i);return this.schemaCache.set(t,a),a}let o=this.globals.get(e);if(o){let a=ke(o);return this.schemaCache.set(`global:${e}:update`,a),a}throw new Error(`No collection or global found with slug "${e}"`)}getWhereZodSchema(e){let t=`${e}:where`,s=this.schemaCache.get(t);if(s)return s;let i=this.collections.get(e);if(i){let o=De(i);return this.schemaCache.set(t,o),o}throw new Error(`No collection found with slug "${e}"`)}getFieldZodSchema(e){return A(e)}clearSchemaCache(e){this.schemaCache.delete(e),this.schemaCache.delete(`${e}:create`),this.schemaCache.delete(`${e}:update`),this.schemaCache.delete(`${e}:where`);}applyFieldDefaults(e){let t=[...e.fields];return t.some(s=>s.name==="id")||t.unshift({name:"id",type:"text",admin:{readOnly:true,hidden:true}}),e.tenantScoped&&!t.some(s=>s.name==="tenantId")&&t.push({name:"tenantId",type:"text",required:true,admin:{readOnly:true,hidden:true}}),e.timestamps&&!t.some(s=>s.name==="createdAt")&&(t.push({name:"createdAt",type:"date",admin:{readOnly:true,hidden:true}}),t.push({name:"updatedAt",type:"date",admin:{readOnly:true,hidden:true}})),e.versions?.drafts&&!t.some(s=>s.name==="status")&&t.push({name:"status",type:"select",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}],admin:{readOnly:true,hidden:true}}),e.auth&&!t.some(s=>s.name==="password")&&t.push({name:"password",type:"password",required:true,admin:{hidden:true}}),t}getFields(e){let t=this.collections.get(e);if(t)return t.fields;let s=this.globals.get(e);if(s)return s.fields;throw new Error(`No collection or global found with slug "${e}"`)}getFieldMap(e){let t=this.getFields(e),s=new Map,i=o=>{for(let a of o){if(a.name&&s.set(a.name,a),"fields"in a&&a.fields&&i(a.fields),"tabs"in a)for(let r of a.tabs)i(r.fields);if("blocks"in a)for(let r of a.blocks)i(r.fields);}};return i(t),s}getVisibleFields(e){return this.getFields(e).filter(s=>!s.admin?.hidden)}validate(){let e=this.getCollections(),t=this.getGlobals();xe(e,t);}async init(e){this.validate();for(let t of this.plugins){t.init&&await t.init(e||this);let s=t.collections||[];for(let o of s)o.slug&&!this.hasCollection(o.slug)&&this.addCollection(o);let i=t.globals||[];for(let o of i)o.slug&&!this.hasGlobal(o.slug)&&this.addGlobal(o);}this.initialized=true;}isInitialized(){return this.initialized}getPaginationDefaults(e){let t=this.collections.get(e);return {defaultLimit:t?.admin?.pagination?.defaultLimit||10,limits:t?.admin?.pagination?.limits||[10,25,50,100]}}getDefaultSort(e){let s=this.collections.get(e)?.admin?.useAsTitle;return s||"createdAt"}getDefaultColumns(e){let t=this.collections.get(e);return t?.admin?.defaultColumns?t.admin.defaultColumns:this.getVisibleFields(e).slice(0,4).map(i=>i.name)}getAdminTitle(e){let t=this.collections.get(e);return t?.label||t?.admin?.description||e}getAdminLabel(e){let t=this.collections.get(e);return t?.singularLabel||t?.label||e}getAdminGroup(e){return this.collections.get(e)?.admin?.group}getStats(){let e=0;for(let t of this.collections.values())e+=t.fields.length;for(let t of this.globals.values())e+=t.fields.length;return {collections:this.collections.size,globals:this.globals.size,plugins:this.plugins.length,fields:e}}toJSON(){return {collections:this.getCollections(),globals:this.getGlobals()}}},N=null;function ct(){return N||(N=new F),N}function dt(){N=null;}function W(){return N=new F,N}var x=class{name;displayName;adminEntry;version;description;hooks={};collections=[];globals=[];fields=[];extensions={collections:[],globals:[]};adminComponents={};adminStyles=[];serverMiddleware;clientMiddleware;constructor(e){this.name=e;}async init(e){}async beforeInit(e){}async afterInit(e){}getCollections(){return this.collections}getGlobals(){return this.globals}getHooks(){return this.hooks}},$=class{plugins=new Map;hooks=new Map;register(e){if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);this.plugins.set(e.name,e);let t=e.getHooks?.()||{};for(let[s,i]of Object.entries(t))if(Array.isArray(i))for(let o of i)this.registerHook(s,o);}unregister(e){let t=this.plugins.get(e);if(!t)return;let s=t.getHooks?.()||{};for(let[i,o]of Object.entries(s))if(Array.isArray(o))for(let a of o)this.unregisterHook(i,a);this.plugins.delete(e);}get(e){return this.plugins.get(e)}getAll(){return Array.from(this.plugins.values())}has(e){return this.plugins.has(e)}registerHook(e,t){this.hooks.has(e)||this.hooks.set(e,[]),this.hooks.get(e).push(t);}unregisterHook(e,t){let s=this.hooks.get(e);if(s){let i=s.indexOf(t);i>-1&&s.splice(i,1);}}async executeHook(e,t){let s=this.hooks.get(e)||[],i=t;for(let o of s)try{let a=await o({...t,data:i});a!==void 0&&(i=a);}catch(a){console.error(`[PluginManager] Error in hook "${e}":`,a);}return i}getAllCollections(){let e=[];for(let t of this.plugins.values()){let s=t.getCollections?.()||[];e.push(...s);}return e}getAllGlobals(){let e=[];for(let t of this.plugins.values()){let s=t.getGlobals?.()||[];e.push(...s);}return e}getAllFields(){let e=[];for(let t of this.plugins.values())e.push(...t.fields);return e}getAdminComponents(){let e={};for(let t of this.plugins.values())Object.assign(e,t.adminComponents);return e}getAdminStyles(){let e=[];for(let t of this.plugins.values())e.push(...t.adminStyles);return e}},z=class extends x{constructor(){super("seo"),this.displayName="Core SEO",this.description="Advanced SEO features including sitemaps, robots.txt, and structured data",this.adminEntry="@kyro-cms/admin/plugins/seo-admin",this.collections.push({slug:"seo-settings",label:"SEO Settings",fields:[{name:"sitemap",type:"checkbox",label:"Enable Sitemap",defaultValue:true},{name:"robotsTxt",type:"richtext",label:"robots.txt Content"},{name:"canonicalUrl",type:"text",variant:"url",label:"Canonical URL"},{name:"ogImage",type:"text",label:"Default OG Image URL"}]});}},X=class extends x{constructor(){super("analytics"),this.displayName="Core Analytics",this.description="Built-in privacy-friendly analytics and dashboards",this.collections.push({slug:"analytics-events",label:"Analytics Events",fields:[{name:"name",type:"text",required:true},{name:"properties",type:"json",label:"Event Properties"},{name:"timestamp",type:"date",required:true},{name:"userId",type:"text",label:"User ID"},{name:"sessionId",type:"text",label:"Session ID"}]}),this.adminComponents.AnalyticsDashboard={};}},J=class extends x{constructor(){super("comments"),this.description="Commenting system for products and posts",this.collections.push({slug:"comments",label:"Comments",fields:[{name:"content",type:"richtext",required:true},{name:"author",type:"text",required:true},{name:"email",type:"email"},{name:"approved",type:"checkbox",defaultValue:false},{name:"parent",type:"text",label:"Parent Comment ID"},{name:"resourceType",type:"text",required:true},{name:"resourceId",type:"text",required:true}]}),this.adminComponents.CommentModeration={};}},Y=class extends x{constructor(){super("reviews"),this.description="Product reviews and ratings",this.collections.push({slug:"reviews",label:"Reviews",fields:[{name:"rating",type:"number",required:true,min:1,max:5},{name:"title",type:"text"},{name:"content",type:"richtext",required:true},{name:"author",type:"relationship",relationTo:"customers"},{name:"product",type:"relationship",relationTo:"products",required:true},{name:"approved",type:"checkbox",defaultValue:false},{name:"verified",type:"checkbox",label:"Verified Purchase"},{name:"helpful",type:"number",label:"Helpful Count",defaultValue:0}]}),this.adminComponents.ReviewModeration={};}},Q=class extends x{constructor(){super("wishlist"),this.description="Customer wishlists",this.collections.push({slug:"wishlists",label:"Wishlists",fields:[{name:"customer",type:"relationship",relationTo:"customers",required:true},{name:"name",type:"text",label:"Wishlist Name",defaultValue:"My Wishlist"},{name:"items",type:"blocks",label:"Items",blocks:[{slug:"wishlist-item",label:"Item",fields:[{name:"product",type:"relationship",relationTo:"products"},{name:"quantity",type:"number",defaultValue:1},{name:"addedAt",type:"date"},{name:"priority",type:"select",options:[{label:"Low",value:"low"},{label:"Medium",value:"medium"},{label:"High",value:"high"}]}]}]}]});}},Ot={SEO:z,Analytics:X,Comments:J,Reviews:Y,Wishlist:Q};var ut={aws:{type:"aws",configKey:"s3",displayName:"S3 Compatible (AWS, Backblaze, Wasabi, etc.)",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"us-east-1",admin:{placeholder:"us-east-1"}},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"endpoint",type:"text",label:"Endpoint URL",admin:{placeholder:"https://s3.custom.com"}},{name:"cdnUrl",type:"text",label:"CDN URL",admin:{placeholder:"https://cdn.example.com"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads"}}]},r2:{type:"r2",configKey:"r2",displayName:"Cloudflare R2",configFields:[{name:"accountId",type:"text",label:"Account ID",required:true,admin:{placeholder:"Your Cloudflare Account ID"}},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"publicDevUrl",type:"text",label:"Public Dev URL ID",admin:{placeholder:"pub-xxxxxxxxxxxxxxxx",description:"Enter ONLY the ID (e.g., pub-b8d8c4cc8bcf4d868ddd95efc1b305aa). Do NOT include https:// or the full URL. Found in R2 Dashboard \u2192 Public Dev URL."}},{name:"cdnUrl",type:"text",label:"Custom CDN URL",admin:{placeholder:"https://assets.example.com (optional)"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads (optional)",description:"Optional prefix for all object keys. Do not use '/' as prefix."}}]},gcs:{type:"gcs",configKey:"gcs",displayName:"Google Cloud Storage",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"projectId",type:"text",label:"Project ID"},{name:"clientEmail",type:"text",label:"Client Email"},{name:"privateKey",type:"password",label:"Private Key"},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},digitalocean:{type:"digitalocean",configKey:"digitalocean",displayName:"DigitalOcean Spaces",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"nyc3"},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},backblaze:{type:"backblaze",configKey:"backblaze",displayName:"Backblaze B2",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"accountId",type:"text",label:"Account ID"},{name:"applicationKeyId",type:"text",label:"Application Key ID",required:true},{name:"applicationKey",type:"password",label:"Application Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]},wasabi:{type:"wasabi",configKey:"wasabi",displayName:"Wasabi",configFields:[{name:"bucket",type:"text",label:"Bucket Name",required:true},{name:"region",type:"text",label:"Region",defaultValue:"us-east-1"},{name:"accessKeyId",type:"text",label:"Access Key ID",required:true},{name:"secretAccessKey",type:"password",label:"Secret Access Key",required:true},{name:"cdnUrl",type:"text",label:"CDN URL"},{name:"prefix",type:"text",label:"Path Prefix"}]}};function pt(n,e){switch(n){case "r2":return e?.endpoint||`https://${e?.accountId||""}.r2.cloudflarestorage.com`;case "digitalocean":return e?.endpoint||`https://${e?.region||"nyc3"}.digitaloceanspaces.com`;case "backblaze":return e?.endpoint||"https://s3.backblazeb2.com";case "wasabi":return e?.endpoint||`https://s3.${e?.region||"us-east-1"}.wasabisys.com`;default:return e?.endpoint}}function Ie(n,e){return {provider:n,bucket:e?.bucket||"",region:e?.region||"us-east-1",accessKeyId:e?.accessKeyId||e?.clientEmail||e?.applicationKeyId||"",secretAccessKey:e?.secretAccessKey||e?.privateKey||e?.applicationKey||"",endpoint:pt(n,e),cdnUrl:e?.cdnUrl,prefix:e?.prefix,accountId:e?.accountId,publicDevUrl:e?.publicDevUrl}}function ft(n,e,t){let s=t[e.configKey]||{};return Ie(n,s)}function yt(n,e,t){let s=t?.[e.configKey]||t;return Ie(n,s)}var ee=class extends x{constructor(){super("@kyro-cms/storage-s3"),this.version="1.0.0",this.description="S3-compatible storage (AWS R2 GCS DigitalOcean Backblaze Wasabi)";}async init(e){let t=e.registry?.storageProviders;if(!t)return;let s=this.name;for(let i of Object.values(ut))t.register({type:i.type,displayName:i.displayName,pluginName:s,configKey:i.configKey,configFields:i.configFields,extractConfig:o=>ft(i.type,i,o),extractRawConfig:o=>yt(i.type,i,o),factory:o=>chunkLMIBASPC_cjs.a(o)});}},Pe=new ee;var te=class extends x{constructor(){super("@kyro-cms/storage-cloudinary"),this.version="1.0.0",this.description="Cloudinary image and video storage";}async init(e){let t=e.registry?.storageProviders;t&&t.register({type:"cloudinary",displayName:"Cloudinary",pluginName:this.name,configKey:"cloudinary",configFields:[{name:"cloudName",type:"text",label:"Cloud Name",required:true},{name:"apiKey",type:"text",label:"API Key",required:true},{name:"apiSecret",type:"password",label:"API Secret",required:true},{name:"folder",type:"text",label:"Folder",admin:{placeholder:"Optional folder path"}},{name:"uploadPreset",type:"text",label:"Upload Preset (optional)",admin:{placeholder:"Leave empty for signed uploads",description:"If not set, uploads will be signed with API Secret"}}],extractConfig:s=>({cloudName:s.cloudinary?.cloudName||"",apiKey:s.cloudinary?.apiKey||"",apiSecret:s.cloudinary?.apiSecret||"",folder:s.cloudinary?.folder,uploadPreset:s.cloudinary?.uploadPreset}),extractRawConfig:s=>{let i=s?.cloudinary||s;return {cloudName:i?.cloudName||"",apiKey:i?.apiKey||"",apiSecret:i?.apiSecret||"",folder:i?.folder,uploadPreset:i?.uploadPreset}},factory:s=>chunkLMIBASPC_cjs.b(s)});}},Oe=new te;var se=class extends x{constructor(){super("@kyro-cms/storage-ftp"),this.version="1.0.0",this.description="FTP/SFTP storage provider";}async init(e){let t=e.registry?.storageProviders;t&&t.register({type:"ftp",displayName:"FTP",pluginName:this.name,configKey:"ftp",configFields:[{name:"host",type:"text",label:"Host",required:true,admin:{placeholder:"ftp.example.com"}},{name:"port",type:"number",label:"Port",defaultValue:21,admin:{placeholder:"21 for FTP"}},{name:"user",type:"text",label:"Username",required:true},{name:"password",type:"password",label:"Password",required:true},{name:"secure",type:"checkbox",label:"Use TLS/SSL",defaultValue:false,admin:{description:"Enable TLS/SSL for secure connections (FTP only)"}},{name:"baseUrl",type:"text",label:"Base URL",required:true,admin:{placeholder:"https://files.example.com"}},{name:"prefix",type:"text",label:"Path Prefix",admin:{placeholder:"uploads"}}],extractConfig:s=>({host:s.ftp?.host||"",port:s.ftp?.port||21,user:s.ftp?.user||"",password:s.ftp?.password||"",secure:s.ftp?.secure||false,baseUrl:s.ftp?.baseUrl||"",prefix:s.ftp?.prefix,type:"ftp"}),extractRawConfig:s=>{let i=s?.ftp||s;return {host:i?.host||"",port:i?.port||21,user:i?.user||"",password:i?.password||"",secure:i?.secure||false,baseUrl:i?.baseUrl||"",prefix:i?.prefix,type:"ftp"}},factory:s=>chunkLMIBASPC_cjs.c(s)});}},$e=new se;var ht=[Pe,Oe,$e];function ne(n,e,t){let s=e.split(".");if(s.length===0)return false;let i=s[0],o=s.slice(1).join(".");for(let a of n)if(a.name===i)return o?a.fields&&Array.isArray(a.fields)||a.type==="array"&&a.fields&&Array.isArray(a.fields)?ne(a.fields,o,t):false:(Object.assign(a,t),true);return o?false:(n.push({name:i,...t}),true)}function mt(n,e){if(e)for(let t of n){let s=e[t.slug];if(s){let{fields:i,...o}=s;if(t.admin={...t.admin,...o},i&&t.fields&&Array.isArray(t.fields))for(let[a,r]of Object.entries(i))ne(t.fields,a,r);}}}var ie=class{registry;db;pubsub;webhookService;settings;pluginManager;wsServer;config;constructor(e){this.config=e,this.registry=W(),this.db=e.adapter,this.pubsub=new chunkG3J2EU5D_cjs.b(this.registry),this.webhookService=chunkXUONID6O_cjs.o(this.db),this.pluginManager=new $;for(let t of ht)this.pluginManager.register(t),this.registry.addPlugin(t);if(e.plugins)for(let t of e.plugins)this.pluginManager.register(t),this.registry.addPlugin(t);e.collections&&e.admin?.collectionOverrides&&mt(e.collections,e.admin.collectionOverrides),e.collections&&this.registry.addCollections(e.collections),e.globals&&this.registry.addGlobals(e.globals);}async init(){await this.pluginManager.executeHook("beforeInit",{kyro:this}),await this.registry.init(this),await this.pluginManager.executeHook("afterInit",{kyro:this}),this.registry.addGlobalPostInit(chunk65G73T7Z_cjs.a);let e={slug:"plugin-settings",admin:{hidden:true},fields:[{name:"states",type:"json"}]};if(this.registry.addGlobalPostInit(e),!this.db)throw new Error("Database adapter is null \u2014 failed to load at startup. Check the server console for the exact error.");let t={slug:chunkNY47CFVP_cjs.d,fields:[{name:"userId",type:"text",required:true},{name:"name",type:"text",required:true},{name:"key",type:"text",required:true},{name:"keyPrefix",type:"text",required:true},{name:"permissions",type:"json"},{name:"lastUsedAt",type:"date"},{name:"expiresAt",type:"date"}]},s={slug:chunkXUONID6O_cjs.f,fields:[{name:"name",type:"text",required:true},{name:"url",type:"text",required:true},{name:"events",type:"json",required:true},{name:"collections",type:"json"},{name:"status",type:"text",required:true},{name:"secret",type:"text"},{name:"headers",type:"json"},{name:"action",type:"text"},{name:"config",type:"json"},{name:"lastTriggered",type:"date"},{name:"lastError",type:"text"}]},i={slug:chunkXUONID6O_cjs.g,fields:[{name:"webhookId",type:"text",required:true},{name:"event",type:"text",required:true},{name:"payload",type:"json",required:true},{name:"attempt",type:"number",required:true},{name:"status",type:"text",required:true},{name:"responseStatus",type:"number"},{name:"responseBody",type:"text"},{name:"error",type:"text"},{name:"duration",type:"number"},{name:"deliveredAt",type:"date"},{name:"nextRetryAt",type:"date"}]},o=this.registry.getGlobals();if(this.db instanceof chunk3ZFRP5M2_cjs.c&&this.db.dialect==="postgres"){let a=this.db,r=chunkNY47CFVP_cjs.d.replace(/-/g,"_");a.schema[r]||(a.schema[r]=chunkMIOMMB23_cjs.g);}await this.db.init([...this.registry.getCollections(),t,s,i],o),await this.loadPluginState(),this.pubsub.autoRegisterHooks();}async loadSettings(){if(this.settings)return this.settings;try{let e=await this.db.findOne({collection:"_globals_access-settings",where:{},draft:!0});e&&(this.settings={access:e});}catch{}return this.settings||{}}async loadPluginState(){let e=this.registry.storageProviders,t=e.getAllPluginNames(),s={};try{let i=await this.db.findOne({collection:"_globals_plugin-settings",where:{},draft:!0});i&&i.states&&(s=i.states);}catch{}for(let i of t)s[i]!==void 0&&e.setPluginEnabled(i,s[i]);}getREST(e){let t=typeof this.config.auth=="object"?this.config.auth:null,s=t?.secret,i=t?.checkSession!==false;return chunkLMIBASPC_cjs.t({registry:this.registry,db:this.db,authSecret:s,authAdapter:this.config.authAdapter,checkSession:i,...e,cors:this.config.cors,webhookService:this.webhookService,settings:this.settings})}getGraphQL(e){let t=chunkHS2KNFAB_cjs.c({registry:this.registry,db:this.db,settings:this.settings});return {fetch:graphqlYoga.createYoga({schema:t,context:async({request:i})=>{let o=chunkNY47CFVP_cjs.f(i),a,r;if(o&&this.db){let d=await chunkNY47CFVP_cjs.e(o,this.db);d.user&&(a=d.user,r=chunkNY47CFVP_cjs.g(d));}let c=e?.tenantId;return {db:this.db,registry:this.registry,user:a,req:i,tenantId:c,apiKey:r,relationLoader:new chunkHS2KNFAB_cjs.a({db:this.db,tenantId:c,user:a})}},graphiql:this.config.graphQL?.disablePlayground!==true,plugins:[]}).fetch,schema:t}}getTRPC(e){return {fetch:async(t,s)=>{let o=new URL(t.url).pathname.replace(/^\/api\/trpc\//,""),[a,...r]=o.split("."),c=r.join(".");if(c=c.replace(/\.(query|mutate|subscribe)$/,""),!a||!c)return new Response(JSON.stringify({error:{message:"Invalid tRPC path",code:-32600,data:{code:"BAD_REQUEST",httpStatus:400}}}),{status:400,headers:{"Content-Type":"application/json"}});let d=await chunkWMZEULS2_cjs.a({db:this.db,registry:this.registry,req:t,user:e?.user,tenantId:e?.tenantId,settings:this.settings}),p=chunkWMZEULS2_cjs.i(d)[a];if(!p)return new Response(JSON.stringify({error:{message:`Collection '${a}' not found`,code:-32601,data:{code:"NOT_FOUND",httpStatus:404}}}),{status:404,headers:{"Content-Type":"application/json"}});let m=p[c];if(typeof m!="function")return new Response(JSON.stringify({error:{message:`Procedure '${c}' not found`,code:-32601,data:{code:"NOT_FOUND",httpStatus:404}}}),{status:404,headers:{"Content-Type":"application/json"}});try{let y={};if(t.method==="POST"||t.method==="PATCH")y=await t.json().catch(()=>({}));else {let C=new URL(t.url).searchParams.get("input");if(C)try{y=JSON.parse(decodeURIComponent(C));}catch{}}let g=y?.["0"]??y,f=await m({...g,collection:a});return new Response(JSON.stringify({result:{data:f}}),{status:200,headers:{"Content-Type":"application/json"}})}catch(y){let g=y.message||"Internal error",f=g.includes("not found")?404:g.includes("denied")||g.includes("authentication required")?403:g.includes("conflict")?409:500,C=f===404?-32601:f===403?-32001:f===409?-32002:-32603;return new Response(JSON.stringify({error:{message:g,code:C,data:{code:"INTERNAL_SERVER_ERROR",httpStatus:f}}}),{status:f,headers:{"Content-Type":"application/json"}})}},router:null}}getWS(){return this.wsServer}async startWebSocket(e){let t=this.settings?.access?.apiAccess;if(t?.wsEnabled===false)return null;let s=async o=>{let a=await chunkNY47CFVP_cjs.e(o,this.db);if(!a.valid)throw new Error(a.error||"Invalid API key");if(!a.user)throw new Error("API key has no associated user");return a.user},i=e?.port||8080;if(globalThis.__KYRO_WS_SERVER__)try{await globalThis.__KYRO_WS_SERVER__.close();}catch{}return this.wsServer=chunkG3J2EU5D_cjs.d({pubsub:this.pubsub,port:i,requireAuth:e?.requireAuth??t?.requireAuth,verifyToken:e?.verifyToken||s}),globalThis.__KYRO_WS_SERVER__=this.wsServer,this.wsServer}async shutdown(){await this.pluginManager.executeHook("beforeServerStop",{kyro:this}),this.wsServer&&await this.wsServer.close(),await this.db.disconnect(),await this.pluginManager.executeHook("afterServerStop",{kyro:this});}};function fs(n){return new ie(n)}var Tt=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-BIJHVTNO.cjs', document.baseURI).href))),Ct="node:sqlite",{DatabaseSync:At}=Tt(Ct);function E(n){let e=[];for(let t of n)if(t.type==="tabs"&&"tabs"in t)for(let s of t.tabs)e.push(...E(s.fields));else t.type==="row"&&"fields"in t?e.push(...E(t.fields)):t.type==="collapsible"&&"fields"in t?e.push(...E(t.fields)):e.push(t);return e}function xt(n,e){let t=e,s=n[t.name];if(t.type==="json"||t.type==="richtext"||t.type==="array"||t.type==="group"||t.type==="blocks"||t.type==="list"||t.type==="relationship-block")try{s=s?JSON.parse(s):null;}catch{s=null;}if(t.type==="checkbox"&&(s=!!s),t.type==="date"&&s)try{let i=new Date(s);isNaN(i.getTime())?s=null:s=i.toISOString();}catch{s=null;}if((t.type==="upload"||t.type==="image")&&s)try{let i=JSON.parse(s);Array.isArray(i)?s=i.map(o=>typeof o=="object"&&o!==null?o:{id:o}):s=typeof i=="object"?i:{id:i};}catch{s={id:s};}if(t.type==="relationship"&&s)try{let i=JSON.parse(s);Array.isArray(i),s=i;}catch{s={relationTo:Array.isArray(t.relationTo)?t.relationTo[0]:t.relationTo,value:s};}if(t.type==="list"&&s)try{let i=JSON.parse(s);s=Array.isArray(i)?i:[];}catch{s=[];}if(t.type==="relationship-block"&&s)try{let i=JSON.parse(s);s=Array.isArray(i)?i:[];}catch{s=[];}return s}function Le(n,e){return Array.isArray(n)?n.map(t=>{if(!t||typeof t!="object")return t;let s=t.data?{...t.data}:void 0;if(!s)return t;let i=e.find(o=>o.slug===t.type||o.slug===t.slug);if(!i||!Array.isArray(i.fields))return t;for(let o of i.fields){if(o.name&&(o.type==="upload"||o.type==="image")&&s[o.name]){let a=s[o.name];Array.isArray(a)?s[o.name]=a.map(r=>typeof r=="string"?{id:r}:r):typeof a=="string"&&(s[o.name]={id:a});}if(o.type==="blocks"&&o.name&&s[o.name]){let a=o.blocks||[];s[o.name]=Le(s[o.name],a);}}return {...t,data:s}}):n}function oe(n,e){try{return n.prepare(`PRAGMA table_info(${e})`).all().map(s=>s.name)}catch{return []}}var ae=class extends chunkEJDIR56C_cjs.a{db;path;migrations=new Map;versionsTableName="kyro_versions";constructor(e){super(),this.path=e.path,e.db?this.db=e.db:this.db=null;}async connect(){if(this.db||(this.db=new At(this.path||":memory:")),this.db&&typeof this.db.prepare=="function"&&!this.db.prepare.__wrapped){let e=this.db.prepare.bind(this.db),t=s=>{let i=e(s),o=a=>typeof a=="boolean"?a?1:0:a===void 0?null:a;return new Proxy(i,{get(a,r,c){if(r==="all")return (...u)=>a.all(...u.map(o));if(r==="get")return (...u)=>a.get(...u.map(o));if(r==="run")return (...u)=>a.run(...u.map(o));let d=Reflect.get(a,r,c);return typeof d=="function"?d.bind(a):d}})};t.__wrapped=true,this.db.prepare=t;}this.db.exec("PRAGMA journal_mode = WAL"),this.db.exec("PRAGMA foreign_keys = ON"),this.connected=true;}async disconnect(){this.db&&this.db.close(),this.connected=false;}ensureTable(e,t){let s=t||this.getTableNameFor(e.slug),i=["id TEXT PRIMARY KEY"];for(let r of E(e.fields)){if(!r.name||r.name==="id")continue;let c=this.fieldToSQL(r);c&&i.push(c);}let o=E(e.fields);o.some(r=>r.name==="createdAt")||i.push(`${this.col("createdAt")} TEXT DEFAULT (datetime('now'))`),o.some(r=>r.name==="updatedAt")||i.push(`${this.col("updatedAt")} TEXT DEFAULT (datetime('now'))`),o.some(r=>r.name==="status")||i.push("status TEXT DEFAULT 'draft'"),o.some(r=>r.name==="hasDraft")||i.push("hasDraft INTEGER DEFAULT 0"),e.tenantScoped&&i.push("tenant_id TEXT NOT NULL");let a=oe(this.db,s);if(a.length===0){let r=`CREATE TABLE IF NOT EXISTS ${s} (${i.join(", ")})`;this.db.exec(r),this.db.exec(`CREATE INDEX IF NOT EXISTS idx_${s}_status ON ${s}(status)`);for(let c of E(e.fields))c.name&&c.indexed&&this.db.exec(`CREATE INDEX IF NOT EXISTS idx_${s}_${c.name} ON ${s}(${this.col(c.name)})`),c.name&&c.unique&&this.db.exec(`CREATE UNIQUE INDEX IF NOT EXISTS idx_${s}_${c.name}_unique ON ${s}(${this.col(c.name)})`);}else {let r=new Set(a);for(let c of i){let d=c.split(" ")[0].replace(/^"/,"").replace(/"$/,"");if(!r.has(d)&&d!=="id")try{d==="status"?this.db.exec(`ALTER TABLE ${s} ADD COLUMN ${this.col(d)} TEXT DEFAULT 'published'`):d==="hasDraft"?this.db.exec(`ALTER TABLE ${s} ADD COLUMN ${this.col(d)} INTEGER DEFAULT 0`):this.db.exec(`ALTER TABLE ${s} ADD COLUMN ${this.col(d)} TEXT`);}catch{}}}this.migrations.set(s,true);}ensureVersionsTable(){this.db.exec(`
|
|
4
4
|
CREATE TABLE IF NOT EXISTS ${this.versionsTableName} (
|
|
5
5
|
id TEXT PRIMARY KEY,
|
|
6
6
|
collection_slug TEXT NOT NULL,
|