@lightspeed/crane 3.4.4-rc.4 → 3.4.5-rc.0

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/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import*as ft from"fs";import C,{existsSync as V,readFileSync as sn,statSync as Qe,promises as rn,writeFileSync as an,createReadStream as gi,mkdtempSync as _i,mkdirSync as yi,rmSync as co}from"fs";import*as ht from"path";import z,{resolve as S,dirname as lo,relative as uo,basename as Si,sep as cn,parse as po,join as ne}from"path";import Ti from"cac";import{green as ce,yellow as Oi,red as Ii,gray as wi}from"kolorist";import Pe from"prompts";import fo from"adm-zip";import{glob as I,globSync as ho}from"glob";import le from"typescript";import{normalizePath as vi,build as ge,defineConfig as mt,createServer as Ci}from"vite";import"vue";import"vue/server-renderer";import*as F from"process";import Et from"process";import{JSONPath as Ri}from"jsonpath-plus";import{readFile as ln,writeFile as bi}from"fs/promises";import{pathToFileURL as mo,URL as Ai}from"url";import un,{AxiosError as Eo}from"axios";import Ni from"tinycolor2";import{builtinModules as go}from"module";import{viteExternalsPlugin as _o}from"vite-plugin-externals";import $i from"vite-plugin-compression";import Li from"@vitejs/plugin-vue";import Di from"vite-tsconfig-paths";import ki from"vite-plugin-checker";import{encode as Pi}from"@jridgewell/sourcemap-codec";import{promisify as yo}from"node:util";import So from"node:zlib";import L from"node:fs";import W from"node:path";import j from"node:process";import zi from"micromatch";import{fileURLToPath as ji}from"node:url";import{ConcurrencyManager as Ui}from"axios-concurrency";import{inc as Fi}from"semver";import Mi from"cli-progress";import{WebSocketServer as Gi,WebSocket as xi}from"ws";import*as Bi from"os";import{spawnSync as Zi}from"child_process";const Hi="3.4.4-rc.4";function u(e,t,n){function o(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const l=i.prototype,d=Object.keys(l);for(let m=0;m<d.length;m++){const y=d[m];y in a||(a[y]=l[y].bind(a))}}const s=n?.Parent??Object;class r extends s{}Object.defineProperty(r,"name",{value:e});function i(a){var c;const l=n?.Parent?new r:this;o(l,a),(c=l._zod).deferred??(c.deferred=[]);for(const d of l._zod.deferred)d();return l}return Object.defineProperty(i,"init",{value:o}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class ze extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class To extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const dn={};function _e(e){return e&&Object.assign(dn,e),dn}function Oo(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,s])=>t.indexOf(+o)===-1).map(([o,s])=>s)}function pn(e,t){return typeof t=="bigint"?t.toString():t}function gt(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function fn(e){return e==null}function hn(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Vi(e,t){const n=(e.toString().split(".")[1]||"").length,o=t.toString();let s=(o.split(".")[1]||"").length;if(s===0&&/\d?e-\d?/.test(o)){const c=o.match(/\d?e-(\d?)/);c?.[1]&&(s=Number.parseInt(c[1]))}const r=n>s?n:s,i=Number.parseInt(e.toFixed(r).replace(".","")),a=Number.parseInt(t.toFixed(r).replace(".",""));return i%a/10**r}const Io=Symbol("evaluating");function b(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==Io)return o===void 0&&(o=Io,o=n()),o},set(s){Object.defineProperty(e,t,{value:s})},configurable:!0})}function be(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ie(...e){const t={};for(const n of e){const o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function wo(e){return JSON.stringify(e)}function Wi(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const vo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function qe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Yi=gt(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function je(e){if(qe(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(qe(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Co(e){return je(e)?{...e}:Array.isArray(e)?[...e]:e}const Ki=new Set(["string","number","symbol"]);function Ue(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function we(e,t,n){const o=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(o._zod.parent=e),o}function g(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Ji(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Xi={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Qi(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const r=Ie(e._zod.def,{get shape(){const i={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=n.shape[a])}return be(this,"shape",i),i},checks:[]});return we(e,r)}function qi(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const r=Ie(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return be(this,"shape",i),i},checks:[]});return we(e,r)}function ea(e,t){if(!je(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const r=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(r,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=Ie(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return be(this,"shape",r),r}});return we(e,s)}function ta(e,t){if(!je(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ie(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return be(this,"shape",o),o}});return we(e,n)}function na(e,t){const n=Ie(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return be(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return we(e,n)}function oa(e,t,n){const s=t._zod.def.checks;if(s&&s.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=Ie(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const l in n){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:a[l]}):a[l])}else for(const l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return be(this,"shape",c),c},checks:[]});return we(t,i)}function sa(e,t,n){const o=Ie(t._zod.def,{get shape(){const s=t._zod.def.shape,r={...s};if(n)for(const i in n){if(!(i in r))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(r[i]=new e({type:"nonoptional",innerType:s[i]}))}else for(const i in s)r[i]=new e({type:"nonoptional",innerType:s[i]});return be(this,"shape",r),r}});return we(t,o)}function Fe(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Me(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function _t(e){return typeof e=="string"?e:e?.message}function ve(e,t,n){const o={...e,path:e.path??[]};if(!e.message){const s=_t(e.inst?._zod.def?.error?.(e))??_t(t?.error?.(e))??_t(n.customError?.(e))??_t(n.localeError?.(e))??"Invalid input";o.message=s}return delete o.inst,delete o.continue,t?.reportInput||delete o.input,o}function mn(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function et(...e){const[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}const Ro=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,pn,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},bo=u("$ZodError",Ro),Ao=u("$ZodError",Ro,{Parent:Error});function ra(e,t=n=>n.message){const n={},o=[];for(const s of e.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(t(s))):o.push(t(s));return{formErrors:o,fieldErrors:n}}function ia(e,t=n=>n.message){const n={_errors:[]},o=s=>{for(const r of s.issues)if(r.code==="invalid_union"&&r.errors.length)r.errors.map(i=>o({issues:i}));else if(r.code==="invalid_key")o({issues:r.issues});else if(r.code==="invalid_element")o({issues:r.issues});else if(r.path.length===0)n._errors.push(t(r));else{let i=n,a=0;for(;a<r.path.length;){const c=r.path[a];a===r.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(r))):i[c]=i[c]||{_errors:[]},i=i[c],a++}}};return o(e),n}const En=e=>(t,n,o,s)=>{const r=o?Object.assign(o,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new ze;if(i.issues.length){const a=new(s?.Err??e)(i.issues.map(c=>ve(c,r,_e())));throw vo(a,s?.callee),a}return i.value},gn=e=>async(t,n,o,s)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(s?.Err??e)(i.issues.map(c=>ve(c,r,_e())));throw vo(a,s?.callee),a}return i.value},yt=e=>(t,n,o)=>{const s=o?{...o,async:!1}:{async:!1},r=t._zod.run({value:n,issues:[]},s);if(r instanceof Promise)throw new ze;return r.issues.length?{success:!1,error:new(e??bo)(r.issues.map(i=>ve(i,s,_e())))}:{success:!0,data:r.value}},aa=yt(Ao),St=e=>async(t,n,o)=>{const s=o?Object.assign(o,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},s);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new e(r.issues.map(i=>ve(i,s,_e())))}:{success:!0,data:r.value}},ca=St(Ao),la=e=>(t,n,o)=>{const s=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return En(e)(t,n,s)},ua=e=>(t,n,o)=>En(e)(t,n,o),da=e=>async(t,n,o)=>{const s=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return gn(e)(t,n,s)},pa=e=>async(t,n,o)=>gn(e)(t,n,o),fa=e=>(t,n,o)=>{const s=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return yt(e)(t,n,s)},ha=e=>(t,n,o)=>yt(e)(t,n,o),ma=e=>async(t,n,o)=>{const s=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return St(e)(t,n,s)},Ea=e=>async(t,n,o)=>St(e)(t,n,o),ga=/^[cC][^\s-]{8,}$/,_a=/^[0-9a-z]+$/,ya=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Sa=/^[0-9a-vA-V]{20}$/,Ta=/^[A-Za-z0-9]{27}$/,Oa=/^[a-zA-Z0-9_-]{21}$/,Ia=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,wa=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,No=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,va=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ca="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Ra(){return new RegExp(Ca,"u")}const ba=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Aa=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Na=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,$a=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,La=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$o=/^[A-Za-z0-9_-]*$/,Da=/^\+[1-9]\d{6,14}$/,Lo="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",ka=new RegExp(`^${Lo}$`);function Do(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Pa(e){return new RegExp(`^${Do(e)}$`)}function za(e){const t=Do({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${n.join("|")})`;return new RegExp(`^${Lo}T(?:${o})$`)}const ja=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ua=/^-?\d+$/,ko=/^-?\d+(?:\.\d+)?$/,Fa=/^(?:true|false)$/i,Ma=/^[^A-Z]*$/,Ga=/^[^a-z]*$/,J=u("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Po={number:"number",bigint:"bigint",object:"date"},zo=u("$ZodCheckLessThan",(e,t)=>{J.init(e,t);const n=Po[typeof t.value];e._zod.onattach.push(o=>{const s=o._zod.bag,r=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<r&&(t.inclusive?s.maximum=t.value:s.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),jo=u("$ZodCheckGreaterThan",(e,t)=>{J.init(e,t);const n=Po[typeof t.value];e._zod.onattach.push(o=>{const s=o._zod.bag,r=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?s.minimum=t.value:s.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xa=u("$ZodCheckMultipleOf",(e,t)=>{J.init(e,t),e._zod.onattach.push(n=>{var o;(o=n._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Vi(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ba=u("$ZodCheckNumberFormat",(e,t)=>{J.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),o=n?"int":"number",[s,r]=Xi[t.format];e._zod.onattach.push(i=>{const a=i._zod.bag;a.format=t.format,a.minimum=s,a.maximum=r,n&&(a.pattern=Ua)}),e._zod.check=i=>{const a=i.value;if(n){if(!Number.isInteger(a)){i.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}a<s&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort}),a>r&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),Za=u("$ZodCheckMaxLength",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const s=o.value;return!fn(s)&&s.length!==void 0}),e._zod.onattach.push(o=>{const s=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<s&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const s=o.value;if(s.length<=t.maximum)return;const i=mn(s);o.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Ha=u("$ZodCheckMinLength",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const s=o.value;return!fn(s)&&s.length!==void 0}),e._zod.onattach.push(o=>{const s=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>s&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const s=o.value;if(s.length>=t.minimum)return;const i=mn(s);o.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Va=u("$ZodCheckLengthEquals",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const s=o.value;return!fn(s)&&s.length!==void 0}),e._zod.onattach.push(o=>{const s=o._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=o=>{const s=o.value,r=s.length;if(r===t.length)return;const i=mn(s),a=r>t.length;o.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Tt=u("$ZodCheckStringFormat",(e,t)=>{var n,o;J.init(e,t),e._zod.onattach.push(s=>{const r=s._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Wa=u("$ZodCheckRegex",(e,t)=>{Tt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ya=u("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ma),Tt.init(e,t)}),Ka=u("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ga),Tt.init(e,t)}),Ja=u("$ZodCheckIncludes",(e,t)=>{J.init(e,t);const n=Ue(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(s=>{const r=s._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(o)}),e._zod.check=s=>{s.value.includes(t.includes,t.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),Xa=u("$ZodCheckStartsWith",(e,t)=>{J.init(e,t);const n=new RegExp(`^${Ue(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Qa=u("$ZodCheckEndsWith",(e,t)=>{J.init(e,t);const n=new RegExp(`.*${Ue(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}}),qa=u("$ZodCheckOverwrite",(e,t)=>{J.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class ec{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const o=t.split(`
2
- `).filter(i=>i),s=Math.min(...o.map(i=>i.length-i.trimStart().length)),r=o.map(i=>i.slice(s)).map(i=>" ".repeat(this.indent*2)+i);for(const i of r)this.content.push(i)}compile(){const t=Function,n=this?.args,s=[...(this?.content??[""]).map(r=>` ${r}`)];return new t(...n,s.join(`
3
- `))}}const tc={major:4,minor:3,patch:6},D=u("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=tc;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const s of o)for(const r of s._zod.onattach)r(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const s=(i,a,c)=>{let l=Fe(i),d;for(const m of a){if(m._zod.def.when){if(!m._zod.def.when(i))continue}else if(l)continue;const y=i.issues.length,T=m._zod.check(i);if(T instanceof Promise&&c?.async===!1)throw new ze;if(d||T instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await T,i.issues.length!==y&&(l||(l=Fe(i,y)))});else{if(i.issues.length===y)continue;l||(l=Fe(i,y))}}return d?d.then(()=>i):i},r=(i,a,c)=>{if(Fe(i))return i.aborted=!0,i;const l=s(a,o,c);if(l instanceof Promise){if(c.async===!1)throw new ze;return l.then(d=>e._zod.parse(d,c))}return e._zod.parse(l,c)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction==="backward"){const l=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return l instanceof Promise?l.then(d=>r(d,i,a)):r(l,i,a)}const c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new ze;return c.then(l=>s(l,o,a))}return s(c,o,a)}}b(e,"~standard",()=>({validate:s=>{try{const r=aa(e,s);return r.success?{value:r.data}:{issues:r.error?.issues}}catch{return ca(e,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),_n=u("$ZodString",(e,t)=>{D.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ja(e._zod.bag),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),$=u("$ZodStringFormat",(e,t)=>{Tt.init(e,t),_n.init(e,t)}),nc=u("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=wa),$.init(e,t)}),oc=u("$ZodUUID",(e,t)=>{if(t.version){const o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=No(o))}else t.pattern??(t.pattern=No());$.init(e,t)}),sc=u("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=va),$.init(e,t)}),rc=u("$ZodURL",(e,t)=>{$.init(e,t),e._zod.check=n=>{try{const o=n.value.trim(),s=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(s.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=s.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),ic=u("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Ra()),$.init(e,t)}),ac=u("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Oa),$.init(e,t)}),cc=u("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ga),$.init(e,t)}),lc=u("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=_a),$.init(e,t)}),uc=u("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ya),$.init(e,t)}),dc=u("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Sa),$.init(e,t)}),pc=u("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ta),$.init(e,t)}),fc=u("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=za(t)),$.init(e,t)}),hc=u("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ka),$.init(e,t)}),mc=u("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Pa(t)),$.init(e,t)}),Ec=u("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ia),$.init(e,t)}),gc=u("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ba),$.init(e,t),e._zod.bag.format="ipv4"}),_c=u("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Aa),$.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),yc=u("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Na),$.init(e,t)}),Sc=u("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=$a),$.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(o.length!==2)throw new Error;const[s,r]=o;if(!r)throw new Error;const i=Number(r);if(`${i}`!==r)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${s}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Uo(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Tc=u("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=La),$.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Uo(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Oc(e){if(!$o.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Uo(n)}const Ic=u("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=$o),$.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Oc(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),wc=u("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Da),$.init(e,t)});function vc(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[o]=n;if(!o)return!1;const s=JSON.parse(atob(o));return!("typ"in s&&s?.typ!=="JWT"||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}}const Cc=u("$ZodJWT",(e,t)=>{$.init(e,t),e._zod.check=n=>{vc(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Fo=u("$ZodNumber",(e,t)=>{D.init(e,t),e._zod.pattern=e._zod.bag.pattern??ko,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const s=n.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return n;const r=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...r?{received:r}:{}}),n}}),Rc=u("$ZodNumberFormat",(e,t)=>{Ba.init(e,t),Fo.init(e,t)}),bc=u("$ZodBoolean",(e,t)=>{D.init(e,t),e._zod.pattern=Fa,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=!!n.value}catch{}const s=n.value;return typeof s=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),n}}),Ac=u("$ZodUnknown",(e,t)=>{D.init(e,t),e._zod.parse=n=>n}),Nc=u("$ZodNever",(e,t)=>{D.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Mo(e,t,n){e.issues.length&&t.issues.push(...Me(n,e.issues)),t.value[n]=e.value}const $c=u("$ZodArray",(e,t)=>{D.init(e,t),e._zod.parse=(n,o)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=Array(s.length);const r=[];for(let i=0;i<s.length;i++){const a=s[i],c=t.element._zod.run({value:a,issues:[]},o);c instanceof Promise?r.push(c.then(l=>Mo(l,n,i))):Mo(c,n,i)}return r.length?Promise.all(r).then(()=>n):n}});function Ot(e,t,n,o,s){if(e.issues.length){if(s&&!(n in o))return;t.issues.push(...Me(n,e.issues))}e.value===void 0?n in o&&(t.value[n]=void 0):t.value[n]=e.value}function Go(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=Ji(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function xo(e,t,n,o,s,r){const i=[],a=s.keySet,c=s.catchall._zod,l=c.def.type,d=c.optout==="optional";for(const m in t){if(a.has(m))continue;if(l==="never"){i.push(m);continue}const y=c.run({value:t[m],issues:[]},o);y instanceof Promise?e.push(y.then(T=>Ot(T,n,m,t,d))):Ot(y,n,m,t,d)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:r}),e.length?Promise.all(e).then(()=>n):n}const Lc=u("$ZodObject",(e,t)=>{if(D.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const o=gt(()=>Go(t));b(e._zod,"propValues",()=>{const a=t.shape,c={};for(const l in a){const d=a[l]._zod;if(d.values){c[l]??(c[l]=new Set);for(const m of d.values)c[l].add(m)}}return c});const s=qe,r=t.catchall;let i;e._zod.parse=(a,c)=>{i??(i=o.value);const l=a.value;if(!s(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};const d=[],m=i.shape;for(const y of i.keys){const T=m[y],H=T._zod.optout==="optional",B=T._zod.run({value:l[y],issues:[]},c);B instanceof Promise?d.push(B.then(pt=>Ot(pt,a,y,l,H))):Ot(B,a,y,l,H)}return r?xo(d,l,a,c,o.value,e):d.length?Promise.all(d).then(()=>a):a}}),Dc=u("$ZodObjectJIT",(e,t)=>{Lc.init(e,t);const n=e._zod.parse,o=gt(()=>Go(t)),s=y=>{const T=new ec(["shape","payload","ctx"]),H=o.value,B=fe=>{const K=wo(fe);return`shape[${K}]._zod.run({ value: input[${K}], issues: [] }, ctx)`};T.write("const input = payload.value;");const pt=Object.create(null);let hi=0;for(const fe of H.keys)pt[fe]=`key_${hi++}`;T.write("const newResult = {};");for(const fe of H.keys){const K=pt[fe],ae=wo(fe),Ei=y[fe]?._zod?.optout==="optional";T.write(`const ${K} = ${B(fe)};`),Ei?T.write(`
1
+ import*as ft from"fs";import C,{existsSync as V,readFileSync as cn,statSync as Qe,promises as un,writeFileSync as ln,createReadStream as Oi,mkdtempSync as Ii,mkdirSync as wi,rmSync as po}from"fs";import*as ht from"path";import z,{resolve as T,dirname as fo,relative as ho,basename as vi,sep as dn,parse as mo,join as ne}from"path";import Ci from"cac";import{green as ce,yellow as Ri,red as bi,gray as Ai}from"kolorist";import Pe from"prompts";import Eo from"adm-zip";import{glob as I,globSync as go}from"glob";import ue from"typescript";import{normalizePath as Ni,build as ge,defineConfig as mt,createServer as $i}from"vite";import"vue";import"vue/server-renderer";import*as M from"process";import Et from"process";import{JSONPath as Li}from"jsonpath-plus";import{readFile as pn,writeFile as Di}from"fs/promises";import{pathToFileURL as _o,URL as ki}from"url";import fn,{AxiosError as yo}from"axios";import Pi from"tinycolor2";import{ButtonTypeEnum as gt}from"@lightspeed/crane-api";import{builtinModules as So}from"module";import{viteExternalsPlugin as To}from"vite-plugin-externals";import zi from"vite-plugin-compression";import ji from"@vitejs/plugin-vue";import Ui from"vite-tsconfig-paths";import Mi from"vite-plugin-checker";import{encode as Fi}from"@jridgewell/sourcemap-codec";import{promisify as Oo}from"node:util";import Io from"node:zlib";import L from"node:fs";import W from"node:path";import j from"node:process";import Gi from"micromatch";import{fileURLToPath as xi}from"node:url";import{ConcurrencyManager as Bi}from"axios-concurrency";import{inc as Zi}from"semver";import Hi from"cli-progress";import{WebSocketServer as Vi,WebSocket as Wi}from"ws";import*as Yi from"os";import{spawnSync as Ki}from"child_process";const Ji="3.4.5-rc.0";function l(e,t,n){function o(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=i.prototype,d=Object.keys(u);for(let m=0;m<d.length;m++){const S=d[m];S in a||(a[S]=u[S].bind(a))}}const r=n?.Parent??Object;class s extends r{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const u=n?.Parent?new s:this;o(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(i,"init",{value:o}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class ze extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class wo extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const hn={};function _e(e){return e&&Object.assign(hn,e),hn}function vo(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}function mn(e,t){return typeof t=="bigint"?t.toString():t}function _t(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function En(e){return e==null}function gn(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Xi(e,t){const n=(e.toString().split(".")[1]||"").length,o=t.toString();let r=(o.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(o)){const c=o.match(/\d?e-(\d?)/);c?.[1]&&(r=Number.parseInt(c[1]))}const s=n>r?n:r,i=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return i%a/10**s}const Co=Symbol("evaluating");function b(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==Co)return o===void 0&&(o=Co,o=n()),o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function be(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function we(...e){const t={};for(const n of e){const o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function Ro(e){return JSON.stringify(e)}function Qi(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const bo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function qe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const qi=_t(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function je(e){if(qe(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(qe(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Ao(e){return je(e)?{...e}:Array.isArray(e)?[...e]:e}const ea=new Set(["string","number","symbol"]);function Ue(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ve(e,t,n){const o=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(o._zod.parent=e),o}function _(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function ta(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const na={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function oa(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=we(e._zod.def,{get shape(){const i={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=n.shape[a])}return be(this,"shape",i),i},checks:[]});return ve(e,s)}function ra(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=we(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return be(this,"shape",i),i},checks:[]});return ve(e,s)}function sa(e,t){if(!je(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=we(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return be(this,"shape",s),s}});return ve(e,r)}function ia(e,t){if(!je(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=we(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return be(this,"shape",o),o}});return ve(e,n)}function aa(e,t){const n=we(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return be(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return ve(e,n)}function ca(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=we(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const u in n){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return be(this,"shape",c),c},checks:[]});return ve(t,i)}function ua(e,t,n){const o=we(t._zod.def,{get shape(){const r=t._zod.def.shape,s={...r};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)s[i]=new e({type:"nonoptional",innerType:r[i]});return be(this,"shape",s),s}});return ve(t,o)}function Me(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Fe(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function yt(e){return typeof e=="string"?e:e?.message}function Ce(e,t,n){const o={...e,path:e.path??[]};if(!e.message){const r=yt(e.inst?._zod.def?.error?.(e))??yt(t?.error?.(e))??yt(n.customError?.(e))??yt(n.localeError?.(e))??"Invalid input";o.message=r}return delete o.inst,delete o.continue,t?.reportInput||delete o.input,o}function _n(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function et(...e){const[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}const No=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,mn,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$o=l("$ZodError",No),Lo=l("$ZodError",No,{Parent:Error});function la(e,t=n=>n.message){const n={},o=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));return{formErrors:o,fieldErrors:n}}function da(e,t=n=>n.message){const n={_errors:[]},o=r=>{for(const s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>o({issues:i}));else if(s.code==="invalid_key")o({issues:s.issues});else if(s.code==="invalid_element")o({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(s))):i[c]=i[c]||{_errors:[]},i=i[c],a++}}};return o(e),n}const yn=e=>(t,n,o,r)=>{const s=o?Object.assign(o,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new ze;if(i.issues.length){const a=new(r?.Err??e)(i.issues.map(c=>Ce(c,s,_e())));throw bo(a,r?.callee),a}return i.value},Sn=e=>async(t,n,o,r)=>{const s=o?Object.assign(o,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(r?.Err??e)(i.issues.map(c=>Ce(c,s,_e())));throw bo(a,r?.callee),a}return i.value},St=e=>(t,n,o)=>{const r=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new ze;return s.issues.length?{success:!1,error:new(e??$o)(s.issues.map(i=>Ce(i,r,_e())))}:{success:!0,data:s.value}},pa=St(Lo),Tt=e=>async(t,n,o)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>Ce(i,r,_e())))}:{success:!0,data:s.value}},fa=Tt(Lo),ha=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return yn(e)(t,n,r)},ma=e=>(t,n,o)=>yn(e)(t,n,o),Ea=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Sn(e)(t,n,r)},ga=e=>async(t,n,o)=>Sn(e)(t,n,o),_a=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return St(e)(t,n,r)},ya=e=>(t,n,o)=>St(e)(t,n,o),Sa=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Tt(e)(t,n,r)},Ta=e=>async(t,n,o)=>Tt(e)(t,n,o),Oa=/^[cC][^\s-]{8,}$/,Ia=/^[0-9a-z]+$/,wa=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,va=/^[0-9a-vA-V]{20}$/,Ca=/^[A-Za-z0-9]{27}$/,Ra=/^[a-zA-Z0-9_-]{21}$/,ba=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Aa=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Do=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Na=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,$a="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function La(){return new RegExp($a,"u")}const Da=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ka=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Pa=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,za=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ja=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ko=/^[A-Za-z0-9_-]*$/,Ua=/^\+[1-9]\d{6,14}$/,Po="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Ma=new RegExp(`^${Po}$`);function zo(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Fa(e){return new RegExp(`^${zo(e)}$`)}function Ga(e){const t=zo({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${n.join("|")})`;return new RegExp(`^${Po}T(?:${o})$`)}const xa=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ba=/^-?\d+$/,jo=/^-?\d+(?:\.\d+)?$/,Za=/^(?:true|false)$/i,Ha=/^[^A-Z]*$/,Va=/^[^a-z]*$/,J=l("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Uo={number:"number",bigint:"bigint",object:"date"},Mo=l("$ZodCheckLessThan",(e,t)=>{J.init(e,t);const n=Uo[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,s=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Fo=l("$ZodCheckGreaterThan",(e,t)=>{J.init(e,t);const n=Uo[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,s=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Wa=l("$ZodCheckMultipleOf",(e,t)=>{J.init(e,t),e._zod.onattach.push(n=>{var o;(o=n._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Xi(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ya=l("$ZodCheckNumberFormat",(e,t)=>{J.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),o=n?"int":"number",[r,s]=na[t.format];e._zod.onattach.push(i=>{const a=i._zod.bag;a.format=t.format,a.minimum=r,a.maximum=s,n&&(a.pattern=Ba)}),e._zod.check=i=>{const a=i.value;if(n){if(!Number.isInteger(a)){i.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}a<r&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Ka=l("$ZodCheckMaxLength",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!En(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const r=o.value;if(r.length<=t.maximum)return;const i=_n(r);o.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ja=l("$ZodCheckMinLength",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!En(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const r=o.value;if(r.length>=t.minimum)return;const i=_n(r);o.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Xa=l("$ZodCheckLengthEquals",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!En(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=o=>{const r=o.value,s=r.length;if(s===t.length)return;const i=_n(r),a=s>t.length;o.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Ot=l("$ZodCheckStringFormat",(e,t)=>{var n,o;J.init(e,t),e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Qa=l("$ZodCheckRegex",(e,t)=>{Ot.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),qa=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ha),Ot.init(e,t)}),ec=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Va),Ot.init(e,t)}),tc=l("$ZodCheckIncludes",(e,t)=>{J.init(e,t);const n=Ue(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(o)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),nc=l("$ZodCheckStartsWith",(e,t)=>{J.init(e,t);const n=new RegExp(`^${Ue(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),oc=l("$ZodCheckEndsWith",(e,t)=>{J.init(e,t);const n=new RegExp(`.*${Ue(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}}),rc=l("$ZodCheckOverwrite",(e,t)=>{J.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class sc{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const o=t.split(`
2
+ `).filter(i=>i),r=Math.min(...o.map(i=>i.length-i.trimStart().length)),s=o.map(i=>i.slice(r)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this?.args,r=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...n,r.join(`
3
+ `))}}const ic={major:4,minor:3,patch:6},D=l("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ic;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const r of o)for(const s of r._zod.onattach)s(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=(i,a,c)=>{let u=Me(i),d;for(const m of a){if(m._zod.def.when){if(!m._zod.def.when(i))continue}else if(u)continue;const S=i.issues.length,O=m._zod.check(i);if(O instanceof Promise&&c?.async===!1)throw new ze;if(d||O instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await O,i.issues.length!==S&&(u||(u=Me(i,S)))});else{if(i.issues.length===S)continue;u||(u=Me(i,S))}}return d?d.then(()=>i):i},s=(i,a,c)=>{if(Me(i))return i.aborted=!0,i;const u=r(a,o,c);if(u instanceof Promise){if(c.async===!1)throw new ze;return u.then(d=>e._zod.parse(d,c))}return e._zod.parse(u,c)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction==="backward"){const u=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(d=>s(d,i,a)):s(u,i,a)}const c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new ze;return c.then(u=>r(u,o,a))}return r(c,o,a)}}b(e,"~standard",()=>({validate:r=>{try{const s=pa(e,r);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return fa(e,r).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Tn=l("$ZodString",(e,t)=>{D.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??xa(e._zod.bag),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),$=l("$ZodStringFormat",(e,t)=>{Ot.init(e,t),Tn.init(e,t)}),ac=l("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Aa),$.init(e,t)}),cc=l("$ZodUUID",(e,t)=>{if(t.version){const o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Do(o))}else t.pattern??(t.pattern=Do());$.init(e,t)}),uc=l("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Na),$.init(e,t)}),lc=l("$ZodURL",(e,t)=>{$.init(e,t),e._zod.check=n=>{try{const o=n.value.trim(),r=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),dc=l("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=La()),$.init(e,t)}),pc=l("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ra),$.init(e,t)}),fc=l("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Oa),$.init(e,t)}),hc=l("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ia),$.init(e,t)}),mc=l("$ZodULID",(e,t)=>{t.pattern??(t.pattern=wa),$.init(e,t)}),Ec=l("$ZodXID",(e,t)=>{t.pattern??(t.pattern=va),$.init(e,t)}),gc=l("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ca),$.init(e,t)}),_c=l("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ga(t)),$.init(e,t)}),yc=l("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ma),$.init(e,t)}),Sc=l("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Fa(t)),$.init(e,t)}),Tc=l("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ba),$.init(e,t)}),Oc=l("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Da),$.init(e,t),e._zod.bag.format="ipv4"}),Ic=l("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ka),$.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),wc=l("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Pa),$.init(e,t)}),vc=l("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=za),$.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(o.length!==2)throw new Error;const[r,s]=o;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Go(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Cc=l("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ja),$.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Go(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Rc(e){if(!ko.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Go(n)}const bc=l("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ko),$.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Rc(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Ac=l("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ua),$.init(e,t)});function Nc(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[o]=n;if(!o)return!1;const r=JSON.parse(atob(o));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const $c=l("$ZodJWT",(e,t)=>{$.init(e,t),e._zod.check=n=>{Nc(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),xo=l("$ZodNumber",(e,t)=>{D.init(e,t),e._zod.pattern=e._zod.bag.pattern??jo,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const s=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),Lc=l("$ZodNumberFormat",(e,t)=>{Ya.init(e,t),xo.init(e,t)}),Dc=l("$ZodBoolean",(e,t)=>{D.init(e,t),e._zod.pattern=Za,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),kc=l("$ZodUnknown",(e,t)=>{D.init(e,t),e._zod.parse=n=>n}),Pc=l("$ZodNever",(e,t)=>{D.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Bo(e,t,n){e.issues.length&&t.issues.push(...Fe(n,e.issues)),t.value[n]=e.value}const zc=l("$ZodArray",(e,t)=>{D.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const s=[];for(let i=0;i<r.length;i++){const a=r[i],c=t.element._zod.run({value:a,issues:[]},o);c instanceof Promise?s.push(c.then(u=>Bo(u,n,i))):Bo(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function It(e,t,n,o,r){if(e.issues.length){if(r&&!(n in o))return;t.issues.push(...Fe(n,e.issues))}e.value===void 0?n in o&&(t.value[n]=void 0):t.value[n]=e.value}function Zo(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=ta(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ho(e,t,n,o,r,s){const i=[],a=r.keySet,c=r.catchall._zod,u=c.def.type,d=c.optout==="optional";for(const m in t){if(a.has(m))continue;if(u==="never"){i.push(m);continue}const S=c.run({value:t[m],issues:[]},o);S instanceof Promise?e.push(S.then(O=>It(O,n,m,t,d))):It(S,n,m,t,d)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const jc=l("$ZodObject",(e,t)=>{if(D.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const o=_t(()=>Zo(t));b(e._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const d=a[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const m of d.values)c[u].add(m)}}return c});const r=qe,s=t.catchall;let i;e._zod.parse=(a,c)=>{i??(i=o.value);const u=a.value;if(!r(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};const d=[],m=i.shape;for(const S of i.keys){const O=m[S],H=O._zod.optout==="optional",B=O._zod.run({value:u[S],issues:[]},c);B instanceof Promise?d.push(B.then(pt=>It(pt,a,S,u,H))):It(B,a,S,u,H)}return s?Ho(d,u,a,c,o.value,e):d.length?Promise.all(d).then(()=>a):a}}),Uc=l("$ZodObjectJIT",(e,t)=>{jc.init(e,t);const n=e._zod.parse,o=_t(()=>Zo(t)),r=S=>{const O=new sc(["shape","payload","ctx"]),H=o.value,B=fe=>{const K=Ro(fe);return`shape[${K}]._zod.run({ value: input[${K}], issues: [] }, ctx)`};O.write("const input = payload.value;");const pt=Object.create(null);let yi=0;for(const fe of H.keys)pt[fe]=`key_${yi++}`;O.write("const newResult = {};");for(const fe of H.keys){const K=pt[fe],ae=Ro(fe),Ti=S[fe]?._zod?.optout==="optional";O.write(`const ${K} = ${B(fe)};`),Ti?O.write(`
4
4
  if (${K}.issues.length) {
5
5
  if (${ae} in input) {
6
6
  payload.issues = payload.issues.concat(${K}.issues.map(iss => ({
@@ -18,7 +18,7 @@ import*as ft from"fs";import C,{existsSync as V,readFileSync as sn,statSync as Q
18
18
  newResult[${ae}] = ${K}.value;
19
19
  }
20
20
 
21
- `):T.write(`
21
+ `):O.write(`
22
22
  if (${K}.issues.length) {
23
23
  payload.issues = payload.issues.concat(${K}.issues.map(iss => ({
24
24
  ...iss,
@@ -34,32 +34,32 @@ import*as ft from"fs";import C,{existsSync as V,readFileSync as sn,statSync as Q
34
34
  newResult[${ae}] = ${K}.value;
35
35
  }
36
36
 
37
- `)}T.write("payload.value = newResult;"),T.write("return payload;");const mi=T.compile();return(fe,K)=>mi(y,fe,K)};let r;const i=qe,a=!dn.jitless,l=a&&Yi.value,d=t.catchall;let m;e._zod.parse=(y,T)=>{m??(m=o.value);const H=y.value;return i(H)?a&&l&&T?.async===!1&&T.jitless!==!0?(r||(r=s(t.shape)),y=r(y,T),d?xo([],H,y,T,m,e):y):n(y,T):(y.issues.push({expected:"object",code:"invalid_type",input:H,inst:e}),y)}});function Bo(e,t,n,o){for(const r of e)if(r.issues.length===0)return t.value=r.value,t;const s=e.filter(r=>!Fe(r));return s.length===1?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(r=>r.issues.map(i=>ve(i,o,_e())))}),t)}const Zo=u("$ZodUnion",(e,t)=>{D.init(e,t),b(e._zod,"optin",()=>t.options.some(s=>s._zod.optin==="optional")?"optional":void 0),b(e._zod,"optout",()=>t.options.some(s=>s._zod.optout==="optional")?"optional":void 0),b(e._zod,"values",()=>{if(t.options.every(s=>s._zod.values))return new Set(t.options.flatMap(s=>Array.from(s._zod.values)))}),b(e._zod,"pattern",()=>{if(t.options.every(s=>s._zod.pattern)){const s=t.options.map(r=>r._zod.pattern);return new RegExp(`^(${s.map(r=>hn(r.source)).join("|")})$`)}});const n=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(s,r)=>{if(n)return o(s,r);let i=!1;const a=[];for(const c of t.options){const l=c._zod.run({value:s.value,issues:[]},r);if(l instanceof Promise)a.push(l),i=!0;else{if(l.issues.length===0)return l;a.push(l)}}return i?Promise.all(a).then(c=>Bo(c,s,e,r)):Bo(a,s,e,r)}}),kc=u("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Zo.init(e,t);const n=e._zod.parse;b(e._zod,"propValues",()=>{const s={};for(const r of t.options){const i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const[a,c]of Object.entries(i)){s[a]||(s[a]=new Set);for(const l of c)s[a].add(l)}}return s});const o=gt(()=>{const s=t.options,r=new Map;for(const i of s){const a=i._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const c of a){if(r.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);r.set(c,i)}}return r});e._zod.parse=(s,r)=>{const i=s.value;if(!qe(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),s;const a=o.value.get(i?.[t.discriminator]);return a?a._zod.run(s,r):t.unionFallback?n(s,r):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:i,path:[t.discriminator],inst:e}),s)}}),Pc=u("$ZodIntersection",(e,t)=>{D.init(e,t),e._zod.parse=(n,o)=>{const s=n.value,r=t.left._zod.run({value:s,issues:[]},o),i=t.right._zod.run({value:s,issues:[]},o);return r instanceof Promise||i instanceof Promise?Promise.all([r,i]).then(([c,l])=>Ho(n,c,l)):Ho(n,r,i)}});function yn(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(je(e)&&je(t)){const n=Object.keys(t),o=Object.keys(e).filter(r=>n.indexOf(r)!==-1),s={...e,...t};for(const r of o){const i=yn(e[r],t[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};s[r]=i.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const s=e[o],r=t[o],i=yn(s,r);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ho(e,t,n){const o=new Map;let s;for(const a of t.issues)if(a.code==="unrecognized_keys"){s??(s=a);for(const c of a.keys)o.has(c)||o.set(c,{}),o.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)o.has(c)||o.set(c,{}),o.get(c).r=!0;else e.issues.push(a);const r=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(r.length&&s&&e.issues.push({...s,keys:r}),Fe(e))return e;const i=yn(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const zc=u("$ZodRecord",(e,t)=>{D.init(e,t),e._zod.parse=(n,o)=>{const s=n.value;if(!je(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;const r=[],i=t.keyType._zod.values;if(i){n.value={};const a=new Set;for(const l of i)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){a.add(typeof l=="number"?l.toString():l);const d=t.valueType._zod.run({value:s[l],issues:[]},o);d instanceof Promise?r.push(d.then(m=>{m.issues.length&&n.issues.push(...Me(l,m.issues)),n.value[l]=m.value})):(d.issues.length&&n.issues.push(...Me(l,d.issues)),n.value[l]=d.value)}let c;for(const l in s)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(s)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&ko.test(a)&&c.issues.length){const m=t.keyType._zod.run({value:Number(a),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(c=m)}if(c.issues.length){t.mode==="loose"?n.value[a]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(m=>ve(m,o,_e())),input:a,path:[a],inst:e});continue}const d=t.valueType._zod.run({value:s[a],issues:[]},o);d instanceof Promise?r.push(d.then(m=>{m.issues.length&&n.issues.push(...Me(a,m.issues)),n.value[c.value]=m.value})):(d.issues.length&&n.issues.push(...Me(a,d.issues)),n.value[c.value]=d.value)}}return r.length?Promise.all(r).then(()=>n):n}}),jc=u("$ZodEnum",(e,t)=>{D.init(e,t);const n=Oo(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(s=>Ki.has(typeof s)).map(s=>typeof s=="string"?Ue(s):s.toString()).join("|")})$`),e._zod.parse=(s,r)=>{const i=s.value;return o.has(i)||s.issues.push({code:"invalid_value",values:n,input:i,inst:e}),s}}),Uc=u("$ZodLiteral",(e,t)=>{if(D.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(o=>typeof o=="string"?Ue(o):o?Ue(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,s)=>{const r=o.value;return n.has(r)||o.issues.push({code:"invalid_value",values:t.values,input:r,inst:e}),o}}),Fc=u("$ZodTransform",(e,t)=>{D.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new To(e.constructor.name);const s=t.transform(n.value,n);if(o.async)return(s instanceof Promise?s:Promise.resolve(s)).then(i=>(n.value=i,n));if(s instanceof Promise)throw new ze;return n.value=s,n}});function Vo(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Wo=u("$ZodOptional",(e,t)=>{D.init(e,t),e._zod.optin="optional",e._zod.optout="optional",b(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),b(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${hn(n.source)})?$`):void 0}),e._zod.parse=(n,o)=>{if(t.innerType._zod.optin==="optional"){const s=t.innerType._zod.run(n,o);return s instanceof Promise?s.then(r=>Vo(r,n.value)):Vo(s,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),Mc=u("$ZodExactOptional",(e,t)=>{Wo.init(e,t),b(e._zod,"values",()=>t.innerType._zod.values),b(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,o)=>t.innerType._zod.run(n,o)}),Gc=u("$ZodNullable",(e,t)=>{D.init(e,t),b(e._zod,"optin",()=>t.innerType._zod.optin),b(e._zod,"optout",()=>t.innerType._zod.optout),b(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${hn(n.source)}|null)$`):void 0}),b(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>n.value===null?n:t.innerType._zod.run(n,o)}),xc=u("$ZodDefault",(e,t)=>{D.init(e,t),e._zod.optin="optional",b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)return n.value=t.defaultValue,n;const s=t.innerType._zod.run(n,o);return s instanceof Promise?s.then(r=>Yo(r,t)):Yo(s,t)}});function Yo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Bc=u("$ZodPrefault",(e,t)=>{D.init(e,t),e._zod.optin="optional",b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>(o.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,o))}),Zc=u("$ZodNonOptional",(e,t)=>{D.init(e,t),b(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,o)=>{const s=t.innerType._zod.run(n,o);return s instanceof Promise?s.then(r=>Ko(r,e)):Ko(s,e)}});function Ko(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Hc=u("$ZodCatch",(e,t)=>{D.init(e,t),b(e._zod,"optin",()=>t.innerType._zod.optin),b(e._zod,"optout",()=>t.innerType._zod.optout),b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const s=t.innerType._zod.run(n,o);return s instanceof Promise?s.then(r=>(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(i=>ve(i,o,_e()))},input:n.value}),n.issues=[]),n)):(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(r=>ve(r,o,_e()))},input:n.value}),n.issues=[]),n)}}),Vc=u("$ZodPipe",(e,t)=>{D.init(e,t),b(e._zod,"values",()=>t.in._zod.values),b(e._zod,"optin",()=>t.in._zod.optin),b(e._zod,"optout",()=>t.out._zod.optout),b(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,o)=>{if(o.direction==="backward"){const r=t.out._zod.run(n,o);return r instanceof Promise?r.then(i=>It(i,t.in,o)):It(r,t.in,o)}const s=t.in._zod.run(n,o);return s instanceof Promise?s.then(r=>It(r,t.out,o)):It(s,t.out,o)}});function It(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Wc=u("$ZodReadonly",(e,t)=>{D.init(e,t),b(e._zod,"propValues",()=>t.innerType._zod.propValues),b(e._zod,"values",()=>t.innerType._zod.values),b(e._zod,"optin",()=>t.innerType?._zod?.optin),b(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const s=t.innerType._zod.run(n,o);return s instanceof Promise?s.then(Jo):Jo(s)}});function Jo(e){return e.value=Object.freeze(e.value),e}const Yc=u("$ZodCustom",(e,t)=>{J.init(e,t),D.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=n=>{const o=n.value,s=t.fn(o);if(s instanceof Promise)return s.then(r=>Xo(r,n,o,e));Xo(s,n,o,e)}});function Xo(e,t,n,o){if(!e){const s={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(s.params=o._zod.def.params),t.issues.push(et(s))}}var Qo;class Kc{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const o=n[0];return this._map.set(t,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const o={...this.get(n)??{}};delete o.id;const s={...o,...this._map.get(t)};return Object.keys(s).length?s:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Jc(){return new Kc}(Qo=globalThis).__zod_globalRegistry??(Qo.__zod_globalRegistry=Jc());const tt=globalThis.__zod_globalRegistry;function Xc(e,t){return new e({type:"string",...g(t)})}function Qc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function qo(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function qc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function el(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function tl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function nl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function es(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function ol(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function sl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function rl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function il(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function al(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function cl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function ll(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function ul(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function dl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function pl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function fl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function hl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function ml(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function El(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function gl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function _l(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function yl(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function Sl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function Tl(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function Ol(e,t){return new e({type:"number",checks:[],...g(t)})}function Il(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...g(t)})}function wl(e,t){return new e({type:"boolean",...g(t)})}function vl(e){return new e({type:"unknown"})}function Cl(e,t){return new e({type:"never",...g(t)})}function ts(e,t){return new zo({check:"less_than",...g(t),value:e,inclusive:!1})}function Sn(e,t){return new zo({check:"less_than",...g(t),value:e,inclusive:!0})}function ns(e,t){return new jo({check:"greater_than",...g(t),value:e,inclusive:!1})}function Tn(e,t){return new jo({check:"greater_than",...g(t),value:e,inclusive:!0})}function os(e,t){return new xa({check:"multiple_of",...g(t),value:e})}function ss(e,t){return new Za({check:"max_length",...g(t),maximum:e})}function wt(e,t){return new Ha({check:"min_length",...g(t),minimum:e})}function rs(e,t){return new Va({check:"length_equals",...g(t),length:e})}function Rl(e,t){return new Wa({check:"string_format",format:"regex",...g(t),pattern:e})}function bl(e){return new Ya({check:"string_format",format:"lowercase",...g(e)})}function Al(e){return new Ka({check:"string_format",format:"uppercase",...g(e)})}function Nl(e,t){return new Ja({check:"string_format",format:"includes",...g(t),includes:e})}function $l(e,t){return new Xa({check:"string_format",format:"starts_with",...g(t),prefix:e})}function Ll(e,t){return new Qa({check:"string_format",format:"ends_with",...g(t),suffix:e})}function Ge(e){return new qa({check:"overwrite",tx:e})}function Dl(e){return Ge(t=>t.normalize(e))}function kl(){return Ge(e=>e.trim())}function Pl(){return Ge(e=>e.toLowerCase())}function zl(){return Ge(e=>e.toUpperCase())}function jl(){return Ge(e=>Wi(e))}function Ul(e,t,n){return new e({type:"array",element:t,...g(n)})}function Fl(e,t,n){const o=g(n);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Ml(e,t,n){return new e({type:"custom",check:"custom",fn:t,...g(n)})}function Gl(e){const t=xl(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(et(o,n.value,t._zod.def));else{const s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=t),s.continue??(s.continue=!t._zod.def.abort),n.issues.push(et(s))}},e(n.value,n)));return t}function xl(e,t){const n=new J({check:"custom",...g(t)});return n._zod.check=e,n}function is(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??tt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function M(e,t,n={path:[],schemaPath:[]}){var o;const s=e._zod.def,r=t.seen.get(e);if(r)return r.count++,n.schemaPath.includes(e)&&(r.cycle=n.path),r.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,d);else{const y=i.schema,T=t.processors[s.type];if(!T)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);T(e,t,y,d)}const m=e._zod.parent;m&&(i.ref||(i.ref=m),M(m,t,d),t.seen.get(m).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),t.io==="input"&&Y(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((o=i.schema).default??(o.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function as(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const i of e.seen.entries()){const a=e.metadataRegistry.get(i[0])?.id;if(a){const c=o.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,i[0])}}const s=i=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const m=e.external.registry.get(i[0])?.id,y=e.external.uri??(H=>H);if(m)return{ref:y(m)};const T=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=T,{defId:T,ref:`${y("__shared")}#/${a}/${T}`}}if(i[1]===n)return{ref:"#"};const l=`#/${a}/`,d=i[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:l+d}},r=i=>{if(i[1].schema.$ref)return;const a=i[1],{ref:c,defId:l}=s(i);a.def={...a.schema},l&&(a.defId=l);const d=a.schema;for(const m in d)delete d[m];d.$ref=c};if(e.cycles==="throw")for(const i of e.seen.entries()){const a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
37
+ `)}O.write("payload.value = newResult;"),O.write("return payload;");const Si=O.compile();return(fe,K)=>Si(S,fe,K)};let s;const i=qe,a=!hn.jitless,u=a&&qi.value,d=t.catchall;let m;e._zod.parse=(S,O)=>{m??(m=o.value);const H=S.value;return i(H)?a&&u&&O?.async===!1&&O.jitless!==!0?(s||(s=r(t.shape)),S=s(S,O),d?Ho([],H,S,O,m,e):S):n(S,O):(S.issues.push({expected:"object",code:"invalid_type",input:H,inst:e}),S)}});function Vo(e,t,n,o){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const r=e.filter(s=>!Me(s));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>Ce(i,o,_e())))}),t)}const Wo=l("$ZodUnion",(e,t)=>{D.init(e,t),b(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),b(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),b(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),b(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${r.map(s=>gn(s.source)).join("|")})$`)}});const n=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(r,s)=>{if(n)return o(r,s);let i=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:r.value,issues:[]},s);if(u instanceof Promise)a.push(u),i=!0;else{if(u.issues.length===0)return u;a.push(u)}}return i?Promise.all(a).then(c=>Vo(c,r,e,s)):Vo(a,r,e,s)}}),Mc=l("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Wo.init(e,t);const n=e._zod.parse;b(e._zod,"propValues",()=>{const r={};for(const s of t.options){const i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,c]of Object.entries(i)){r[a]||(r[a]=new Set);for(const u of c)r[a].add(u)}}return r});const o=_t(()=>{const r=t.options,s=new Map;for(const i of r){const a=i._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});e._zod.parse=(r,s)=>{const i=r.value;if(!qe(i))return r.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),r;const a=o.value.get(i?.[t.discriminator]);return a?a._zod.run(r,s):t.unionFallback?n(r,s):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:i,path:[t.discriminator],inst:e}),r)}}),Fc=l("$ZodIntersection",(e,t)=>{D.init(e,t),e._zod.parse=(n,o)=>{const r=n.value,s=t.left._zod.run({value:r,issues:[]},o),i=t.right._zod.run({value:r,issues:[]},o);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Yo(n,c,u)):Yo(n,s,i)}});function On(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(je(e)&&je(t)){const n=Object.keys(t),o=Object.keys(e).filter(s=>n.indexOf(s)!==-1),r={...e,...t};for(const s of o){const i=On(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};r[s]=i.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const r=e[o],s=t[o],i=On(r,s);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Yo(e,t,n){const o=new Map;let r;for(const a of t.issues)if(a.code==="unrecognized_keys"){r??(r=a);for(const c of a.keys)o.has(c)||o.set(c,{}),o.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)o.has(c)||o.set(c,{}),o.get(c).r=!0;else e.issues.push(a);const s=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&r&&e.issues.push({...r,keys:s}),Me(e))return e;const i=On(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const Gc=l("$ZodRecord",(e,t)=>{D.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!je(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;const s=[],i=t.keyType._zod.values;if(i){n.value={};const a=new Set;for(const u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const d=t.valueType._zod.run({value:r[u],issues:[]},o);d instanceof Promise?s.push(d.then(m=>{m.issues.length&&n.issues.push(...Fe(u,m.issues)),n.value[u]=m.value})):(d.issues.length&&n.issues.push(...Fe(u,d.issues)),n.value[u]=d.value)}let c;for(const u in r)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(r)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&jo.test(a)&&c.issues.length){const m=t.keyType._zod.run({value:Number(a),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(c=m)}if(c.issues.length){t.mode==="loose"?n.value[a]=r[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(m=>Ce(m,o,_e())),input:a,path:[a],inst:e});continue}const d=t.valueType._zod.run({value:r[a],issues:[]},o);d instanceof Promise?s.push(d.then(m=>{m.issues.length&&n.issues.push(...Fe(a,m.issues)),n.value[c.value]=m.value})):(d.issues.length&&n.issues.push(...Fe(a,d.issues)),n.value[c.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}}),xc=l("$ZodEnum",(e,t)=>{D.init(e,t);const n=vo(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(r=>ea.has(typeof r)).map(r=>typeof r=="string"?Ue(r):r.toString()).join("|")})$`),e._zod.parse=(r,s)=>{const i=r.value;return o.has(i)||r.issues.push({code:"invalid_value",values:n,input:i,inst:e}),r}}),Bc=l("$ZodLiteral",(e,t)=>{if(D.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(o=>typeof o=="string"?Ue(o):o?Ue(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,r)=>{const s=o.value;return n.has(s)||o.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),o}}),Zc=l("$ZodTransform",(e,t)=>{D.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new wo(e.constructor.name);const r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then(i=>(n.value=i,n));if(r instanceof Promise)throw new ze;return n.value=r,n}});function Ko(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Jo=l("$ZodOptional",(e,t)=>{D.init(e,t),e._zod.optin="optional",e._zod.optout="optional",b(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),b(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${gn(n.source)})?$`):void 0}),e._zod.parse=(n,o)=>{if(t.innerType._zod.optin==="optional"){const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>Ko(s,n.value)):Ko(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),Hc=l("$ZodExactOptional",(e,t)=>{Jo.init(e,t),b(e._zod,"values",()=>t.innerType._zod.values),b(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,o)=>t.innerType._zod.run(n,o)}),Vc=l("$ZodNullable",(e,t)=>{D.init(e,t),b(e._zod,"optin",()=>t.innerType._zod.optin),b(e._zod,"optout",()=>t.innerType._zod.optout),b(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${gn(n.source)}|null)$`):void 0}),b(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>n.value===null?n:t.innerType._zod.run(n,o)}),Wc=l("$ZodDefault",(e,t)=>{D.init(e,t),e._zod.optin="optional",b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>Xo(s,t)):Xo(r,t)}});function Xo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Yc=l("$ZodPrefault",(e,t)=>{D.init(e,t),e._zod.optin="optional",b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>(o.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,o))}),Kc=l("$ZodNonOptional",(e,t)=>{D.init(e,t),b(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,o)=>{const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>Qo(s,e)):Qo(r,e)}});function Qo(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Jc=l("$ZodCatch",(e,t)=>{D.init(e,t),b(e._zod,"optin",()=>t.innerType._zod.optin),b(e._zod,"optout",()=>t.innerType._zod.optout),b(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>Ce(i,o,_e()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(s=>Ce(s,o,_e()))},input:n.value}),n.issues=[]),n)}}),Xc=l("$ZodPipe",(e,t)=>{D.init(e,t),b(e._zod,"values",()=>t.in._zod.values),b(e._zod,"optin",()=>t.in._zod.optin),b(e._zod,"optout",()=>t.out._zod.optout),b(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,o)=>{if(o.direction==="backward"){const s=t.out._zod.run(n,o);return s instanceof Promise?s.then(i=>wt(i,t.in,o)):wt(s,t.in,o)}const r=t.in._zod.run(n,o);return r instanceof Promise?r.then(s=>wt(s,t.out,o)):wt(r,t.out,o)}});function wt(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Qc=l("$ZodReadonly",(e,t)=>{D.init(e,t),b(e._zod,"propValues",()=>t.innerType._zod.propValues),b(e._zod,"values",()=>t.innerType._zod.values),b(e._zod,"optin",()=>t.innerType?._zod?.optin),b(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(qo):qo(r)}});function qo(e){return e.value=Object.freeze(e.value),e}const qc=l("$ZodCustom",(e,t)=>{J.init(e,t),D.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=n=>{const o=n.value,r=t.fn(o);if(r instanceof Promise)return r.then(s=>er(s,n,o,e));er(r,n,o,e)}});function er(e,t,n,o){if(!e){const r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(r.params=o._zod.def.params),t.issues.push(et(r))}}var tr;class eu{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const o=n[0];return this._map.set(t,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const o={...this.get(n)??{}};delete o.id;const r={...o,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function tu(){return new eu}(tr=globalThis).__zod_globalRegistry??(tr.__zod_globalRegistry=tu());const tt=globalThis.__zod_globalRegistry;function nu(e,t){return new e({type:"string",..._(t)})}function ou(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,..._(t)})}function nr(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,..._(t)})}function ru(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,..._(t)})}function su(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",..._(t)})}function iu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",..._(t)})}function au(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",..._(t)})}function or(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,..._(t)})}function cu(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,..._(t)})}function uu(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,..._(t)})}function lu(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,..._(t)})}function du(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,..._(t)})}function pu(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,..._(t)})}function fu(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,..._(t)})}function hu(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,..._(t)})}function mu(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,..._(t)})}function Eu(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,..._(t)})}function gu(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,..._(t)})}function _u(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,..._(t)})}function yu(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,..._(t)})}function Su(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,..._(t)})}function Tu(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,..._(t)})}function Ou(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,..._(t)})}function Iu(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,..._(t)})}function wu(e,t){return new e({type:"string",format:"date",check:"string_format",..._(t)})}function vu(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,..._(t)})}function Cu(e,t){return new e({type:"string",format:"duration",check:"string_format",..._(t)})}function Ru(e,t){return new e({type:"number",checks:[],..._(t)})}function bu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",..._(t)})}function Au(e,t){return new e({type:"boolean",..._(t)})}function Nu(e){return new e({type:"unknown"})}function $u(e,t){return new e({type:"never",..._(t)})}function rr(e,t){return new Mo({check:"less_than",..._(t),value:e,inclusive:!1})}function In(e,t){return new Mo({check:"less_than",..._(t),value:e,inclusive:!0})}function sr(e,t){return new Fo({check:"greater_than",..._(t),value:e,inclusive:!1})}function wn(e,t){return new Fo({check:"greater_than",..._(t),value:e,inclusive:!0})}function ir(e,t){return new Wa({check:"multiple_of",..._(t),value:e})}function ar(e,t){return new Ka({check:"max_length",..._(t),maximum:e})}function vt(e,t){return new Ja({check:"min_length",..._(t),minimum:e})}function cr(e,t){return new Xa({check:"length_equals",..._(t),length:e})}function Lu(e,t){return new Qa({check:"string_format",format:"regex",..._(t),pattern:e})}function Du(e){return new qa({check:"string_format",format:"lowercase",..._(e)})}function ku(e){return new ec({check:"string_format",format:"uppercase",..._(e)})}function Pu(e,t){return new tc({check:"string_format",format:"includes",..._(t),includes:e})}function zu(e,t){return new nc({check:"string_format",format:"starts_with",..._(t),prefix:e})}function ju(e,t){return new oc({check:"string_format",format:"ends_with",..._(t),suffix:e})}function Ge(e){return new rc({check:"overwrite",tx:e})}function Uu(e){return Ge(t=>t.normalize(e))}function Mu(){return Ge(e=>e.trim())}function Fu(){return Ge(e=>e.toLowerCase())}function Gu(){return Ge(e=>e.toUpperCase())}function xu(){return Ge(e=>Qi(e))}function Bu(e,t,n){return new e({type:"array",element:t,..._(n)})}function Zu(e,t,n){const o=_(n);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Hu(e,t,n){return new e({type:"custom",check:"custom",fn:t,..._(n)})}function Vu(e){const t=Wu(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(et(o,n.value,t._zod.def));else{const r=o;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(et(r))}},e(n.value,n)));return t}function Wu(e,t){const n=new J({check:"custom",..._(t)});return n._zod.check=e,n}function ur(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??tt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function F(e,t,n={path:[],schemaPath:[]}){var o;const r=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,d);else{const S=i.schema,O=t.processors[r.type];if(!O)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);O(e,t,S,d)}const m=e._zod.parent;m&&(i.ref||(i.ref=m),F(m,t,d),t.seen.get(m).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),t.io==="input"&&Y(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((o=i.schema).default??(o.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function lr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const i of e.seen.entries()){const a=e.metadataRegistry.get(i[0])?.id;if(a){const c=o.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,i[0])}}const r=i=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const m=e.external.registry.get(i[0])?.id,S=e.external.uri??(H=>H);if(m)return{ref:S(m)};const O=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=O,{defId:O,ref:`${S("__shared")}#/${a}/${O}`}}if(i[1]===n)return{ref:"#"};const u=`#/${a}/`,d=i[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+d}},s=i=>{if(i[1].schema.$ref)return;const a=i[1],{ref:c,defId:u}=r(i);a.def={...a.schema},u&&(a.defId=u);const d=a.schema;for(const m in d)delete d[m];d.$ref=c};if(e.cycles==="throw")for(const i of e.seen.entries()){const a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
38
38
 
39
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const a=i[1];if(t===i[0]){r(i);continue}if(e.external){const l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){r(i);continue}}if(e.metadataRegistry.get(i[0])?.id){r(i);continue}if(a.cycle){r(i);continue}if(a.count>1&&e.reused==="ref"){r(i);continue}}}function cs(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=i=>{const a=e.seen.get(i);if(a.ref===null)return;const c=a.def??a.schema,l={...c},d=a.ref;if(a.ref=null,d){o(d);const y=e.seen.get(d),T=y.schema;if(T.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(T)):Object.assign(c,T),Object.assign(c,l),i._zod.parent===d)for(const B in c)B==="$ref"||B==="allOf"||B in l||delete c[B];if(T.$ref&&y.def)for(const B in c)B==="$ref"||B==="allOf"||B in y.def&&JSON.stringify(c[B])===JSON.stringify(y.def[B])&&delete c[B]}const m=i._zod.parent;if(m&&m!==d){o(m);const y=e.seen.get(m);if(y?.schema.$ref&&(c.$ref=y.schema.$ref,y.def))for(const T in c)T==="$ref"||T==="allOf"||T in y.def&&JSON.stringify(c[T])===JSON.stringify(y.def[T])&&delete c[T]}e.override({zodSchema:i,jsonSchema:c,path:a.path??[]})};for(const i of[...e.seen.entries()].reverse())o(i[0]);const s={};if(e.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const i=e.external.registry.get(t)?.id;if(!i)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(i)}Object.assign(s,n.def??n.schema);const r=e.external?.defs??{};for(const i of e.seen.entries()){const a=i[1];a.def&&a.defId&&(r[a.defId]=a.def)}e.external||Object.keys(r).length>0&&(e.target==="draft-2020-12"?s.$defs=r:s.definitions=r);try{const i=JSON.parse(JSON.stringify(s));return Object.defineProperty(i,"~standard",{value:{...t["~standard"],jsonSchema:{input:vt(t,"input",e.processors),output:vt(t,"output",e.processors)}},enumerable:!1,writable:!1}),i}catch{throw new Error("Error converting schema to JSON.")}}function Y(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return Y(o.element,n);if(o.type==="set")return Y(o.valueType,n);if(o.type==="lazy")return Y(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return Y(o.innerType,n);if(o.type==="intersection")return Y(o.left,n)||Y(o.right,n);if(o.type==="record"||o.type==="map")return Y(o.keyType,n)||Y(o.valueType,n);if(o.type==="pipe")return Y(o.in,n)||Y(o.out,n);if(o.type==="object"){for(const s in o.shape)if(Y(o.shape[s],n))return!0;return!1}if(o.type==="union"){for(const s of o.options)if(Y(s,n))return!0;return!1}if(o.type==="tuple"){for(const s of o.items)if(Y(s,n))return!0;return!!(o.rest&&Y(o.rest,n))}return!1}const Bl=(e,t={})=>n=>{const o=is({...n,processors:t});return M(e,o),as(o,e),cs(o,e)},vt=(e,t,n={})=>o=>{const{libraryOptions:s,target:r}=o??{},i=is({...s??{},target:r,io:t,processors:n});return M(e,i),as(i,e),cs(i,e)},Zl={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Hl=(e,t,n,o)=>{const s=n;s.type="string";const{minimum:r,maximum:i,format:a,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof r=="number"&&(s.minLength=r),typeof i=="number"&&(s.maxLength=i),a&&(s.format=Zl[a]??a,s.format===""&&delete s.format,a==="time"&&delete s.format),l&&(s.contentEncoding=l),c&&c.size>0){const d=[...c];d.length===1?s.pattern=d[0].source:d.length>1&&(s.allOf=[...d.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Vl=(e,t,n,o)=>{const s=n,{minimum:r,maximum:i,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.includes("int")?s.type="integer":s.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(s.minimum=d,s.exclusiveMinimum=!0):s.exclusiveMinimum=d),typeof r=="number"&&(s.minimum=r,typeof d=="number"&&t.target!=="draft-04"&&(d>=r?delete s.minimum:delete s.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(s.maximum=l,s.exclusiveMaximum=!0):s.exclusiveMaximum=l),typeof i=="number"&&(s.maximum=i,typeof l=="number"&&t.target!=="draft-04"&&(l<=i?delete s.maximum:delete s.exclusiveMaximum)),typeof c=="number"&&(s.multipleOf=c)},Wl=(e,t,n,o)=>{n.type="boolean"},Yl=(e,t,n,o)=>{n.not={}},Kl=(e,t,n,o)=>{},Jl=(e,t,n,o)=>{const s=e._zod.def,r=Oo(s.entries);r.every(i=>typeof i=="number")&&(n.type="number"),r.every(i=>typeof i=="string")&&(n.type="string"),n.enum=r},Xl=(e,t,n,o)=>{const s=e._zod.def,r=[];for(const i of s.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");r.push(Number(i))}else r.push(i);if(r.length!==0)if(r.length===1){const i=r[0];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else r.every(i=>typeof i=="number")&&(n.type="number"),r.every(i=>typeof i=="string")&&(n.type="string"),r.every(i=>typeof i=="boolean")&&(n.type="boolean"),r.every(i=>i===null)&&(n.type="null"),n.enum=r},Ql=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},ql=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},eu=(e,t,n,o)=>{const s=n,r=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(s.minItems=i),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=M(r.element,t,{...o,path:[...o.path,"items"]})},tu=(e,t,n,o)=>{const s=n,r=e._zod.def;s.type="object",s.properties={};const i=r.shape;for(const l in i)s.properties[l]=M(i[l],t,{...o,path:[...o.path,"properties",l]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(l=>{const d=r.shape[l]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(s.required=Array.from(c)),r.catchall?._zod.def.type==="never"?s.additionalProperties=!1:r.catchall?r.catchall&&(s.additionalProperties=M(r.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(s.additionalProperties=!1)},nu=(e,t,n,o)=>{const s=e._zod.def,r=s.inclusive===!1,i=s.options.map((a,c)=>M(a,t,{...o,path:[...o.path,r?"oneOf":"anyOf",c]}));r?n.oneOf=i:n.anyOf=i},ou=(e,t,n,o)=>{const s=e._zod.def,r=M(s.left,t,{...o,path:[...o.path,"allOf",0]}),i=M(s.right,t,{...o,path:[...o.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(r)?r.allOf:[r],...a(i)?i.allOf:[i]];n.allOf=c},su=(e,t,n,o)=>{const s=n,r=e._zod.def;s.type="object";const i=r.keyType,c=i._zod.bag?.patterns;if(r.mode==="loose"&&c&&c.size>0){const d=M(r.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});s.patternProperties={};for(const m of c)s.patternProperties[m.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(s.propertyNames=M(r.keyType,t,{...o,path:[...o.path,"propertyNames"]})),s.additionalProperties=M(r.valueType,t,{...o,path:[...o.path,"additionalProperties"]});const l=i._zod.values;if(l){const d=[...l].filter(m=>typeof m=="string"||typeof m=="number");d.length>0&&(s.required=d)}},ru=(e,t,n,o)=>{const s=e._zod.def,r=M(s.innerType,t,o),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=s.innerType,n.nullable=!0):n.anyOf=[r,{type:"null"}]},iu=(e,t,n,o)=>{const s=e._zod.def;M(s.innerType,t,o);const r=t.seen.get(e);r.ref=s.innerType},au=(e,t,n,o)=>{const s=e._zod.def;M(s.innerType,t,o);const r=t.seen.get(e);r.ref=s.innerType,n.default=JSON.parse(JSON.stringify(s.defaultValue))},cu=(e,t,n,o)=>{const s=e._zod.def;M(s.innerType,t,o);const r=t.seen.get(e);r.ref=s.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},lu=(e,t,n,o)=>{const s=e._zod.def;M(s.innerType,t,o);const r=t.seen.get(e);r.ref=s.innerType;let i;try{i=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},uu=(e,t,n,o)=>{const s=e._zod.def,r=t.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;M(r,t,o);const i=t.seen.get(e);i.ref=r},du=(e,t,n,o)=>{const s=e._zod.def;M(s.innerType,t,o);const r=t.seen.get(e);r.ref=s.innerType,n.readOnly=!0},ls=(e,t,n,o)=>{const s=e._zod.def;M(s.innerType,t,o);const r=t.seen.get(e);r.ref=s.innerType},pu=u("ZodISODateTime",(e,t)=>{fc.init(e,t),P.init(e,t)});function fu(e){return _l(pu,e)}const hu=u("ZodISODate",(e,t)=>{hc.init(e,t),P.init(e,t)});function mu(e){return yl(hu,e)}const Eu=u("ZodISOTime",(e,t)=>{mc.init(e,t),P.init(e,t)});function gu(e){return Sl(Eu,e)}const _u=u("ZodISODuration",(e,t)=>{Ec.init(e,t),P.init(e,t)});function yu(e){return Tl(_u,e)}const Su=(e,t)=>{bo.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>ia(e,n)},flatten:{value:n=>ra(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,pn,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,pn,2)}},isEmpty:{get(){return e.issues.length===0}}})},oe=u("ZodError",Su,{Parent:Error}),Tu=En(oe),Ou=gn(oe),Iu=yt(oe),wu=St(oe),vu=la(oe),Cu=ua(oe),Ru=da(oe),bu=pa(oe),Au=fa(oe),Nu=ha(oe),$u=ma(oe),Lu=Ea(oe),k=u("ZodType",(e,t)=>(D.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:vt(e,"input"),output:vt(e,"output")}}),e.toJSONSchema=Bl(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Ie(t,{checks:[...t.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0}),e.with=e.check,e.clone=(n,o)=>we(e,n,o),e.brand=()=>e,e.register=((n,o)=>(n.add(e,o),e)),e.parse=(n,o)=>Tu(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>Iu(e,n,o),e.parseAsync=async(n,o)=>Ou(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>wu(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>vu(e,n,o),e.decode=(n,o)=>Cu(e,n,o),e.encodeAsync=async(n,o)=>Ru(e,n,o),e.decodeAsync=async(n,o)=>bu(e,n,o),e.safeEncode=(n,o)=>Au(e,n,o),e.safeDecode=(n,o)=>Nu(e,n,o),e.safeEncodeAsync=async(n,o)=>$u(e,n,o),e.safeDecodeAsync=async(n,o)=>Lu(e,n,o),e.refine=(n,o)=>e.check(wd(n,o)),e.superRefine=n=>e.check(vd(n)),e.overwrite=n=>e.check(Ge(n)),e.optional=()=>_s(e),e.exactOptional=()=>pd(e),e.nullable=()=>ys(e),e.nullish=()=>_s(ys(e)),e.nonoptional=n=>_d(e,n),e.array=()=>A(e),e.or=n=>od([e,n]),e.and=n=>id(e,n),e.transform=n=>Ts(e,ud(n)),e.default=n=>md(e,n),e.prefault=n=>gd(e,n),e.catch=n=>Sd(e,n),e.pipe=n=>Ts(e,n),e.readonly=()=>Id(e),e.describe=n=>{const o=e.clone();return tt.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){return tt.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return tt.get(e);const o=e.clone();return tt.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),us=u("_ZodString",(e,t)=>{_n.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,s,r)=>Hl(e,o,s);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...o)=>e.check(Rl(...o)),e.includes=(...o)=>e.check(Nl(...o)),e.startsWith=(...o)=>e.check($l(...o)),e.endsWith=(...o)=>e.check(Ll(...o)),e.min=(...o)=>e.check(wt(...o)),e.max=(...o)=>e.check(ss(...o)),e.length=(...o)=>e.check(rs(...o)),e.nonempty=(...o)=>e.check(wt(1,...o)),e.lowercase=o=>e.check(bl(o)),e.uppercase=o=>e.check(Al(o)),e.trim=()=>e.check(kl()),e.normalize=(...o)=>e.check(Dl(...o)),e.toLowerCase=()=>e.check(Pl()),e.toUpperCase=()=>e.check(zl()),e.slugify=()=>e.check(jl())}),Du=u("ZodString",(e,t)=>{_n.init(e,t),us.init(e,t),e.email=n=>e.check(Qc(ku,n)),e.url=n=>e.check(es(ps,n)),e.jwt=n=>e.check(gl(Ku,n)),e.emoji=n=>e.check(ol(Pu,n)),e.guid=n=>e.check(qo(ds,n)),e.uuid=n=>e.check(qc(Ct,n)),e.uuidv4=n=>e.check(el(Ct,n)),e.uuidv6=n=>e.check(tl(Ct,n)),e.uuidv7=n=>e.check(nl(Ct,n)),e.nanoid=n=>e.check(sl(zu,n)),e.guid=n=>e.check(qo(ds,n)),e.cuid=n=>e.check(rl(ju,n)),e.cuid2=n=>e.check(il(Uu,n)),e.ulid=n=>e.check(al(Fu,n)),e.base64=n=>e.check(hl(Vu,n)),e.base64url=n=>e.check(ml(Wu,n)),e.xid=n=>e.check(cl(Mu,n)),e.ksuid=n=>e.check(ll(Gu,n)),e.ipv4=n=>e.check(ul(xu,n)),e.ipv6=n=>e.check(dl(Bu,n)),e.cidrv4=n=>e.check(pl(Zu,n)),e.cidrv6=n=>e.check(fl(Hu,n)),e.e164=n=>e.check(El(Yu,n)),e.datetime=n=>e.check(fu(n)),e.date=n=>e.check(mu(n)),e.time=n=>e.check(gu(n)),e.duration=n=>e.check(yu(n))});function h(e){return Xc(Du,e)}const P=u("ZodStringFormat",(e,t)=>{$.init(e,t),us.init(e,t)}),ku=u("ZodEmail",(e,t)=>{sc.init(e,t),P.init(e,t)}),ds=u("ZodGUID",(e,t)=>{nc.init(e,t),P.init(e,t)}),Ct=u("ZodUUID",(e,t)=>{oc.init(e,t),P.init(e,t)}),ps=u("ZodURL",(e,t)=>{rc.init(e,t),P.init(e,t)});function fs(e){return es(ps,e)}const Pu=u("ZodEmoji",(e,t)=>{ic.init(e,t),P.init(e,t)}),zu=u("ZodNanoID",(e,t)=>{ac.init(e,t),P.init(e,t)}),ju=u("ZodCUID",(e,t)=>{cc.init(e,t),P.init(e,t)}),Uu=u("ZodCUID2",(e,t)=>{lc.init(e,t),P.init(e,t)}),Fu=u("ZodULID",(e,t)=>{uc.init(e,t),P.init(e,t)}),Mu=u("ZodXID",(e,t)=>{dc.init(e,t),P.init(e,t)}),Gu=u("ZodKSUID",(e,t)=>{pc.init(e,t),P.init(e,t)}),xu=u("ZodIPv4",(e,t)=>{gc.init(e,t),P.init(e,t)}),Bu=u("ZodIPv6",(e,t)=>{_c.init(e,t),P.init(e,t)}),Zu=u("ZodCIDRv4",(e,t)=>{yc.init(e,t),P.init(e,t)}),Hu=u("ZodCIDRv6",(e,t)=>{Sc.init(e,t),P.init(e,t)}),Vu=u("ZodBase64",(e,t)=>{Tc.init(e,t),P.init(e,t)}),Wu=u("ZodBase64URL",(e,t)=>{Ic.init(e,t),P.init(e,t)}),Yu=u("ZodE164",(e,t)=>{wc.init(e,t),P.init(e,t)}),Ku=u("ZodJWT",(e,t)=>{Cc.init(e,t),P.init(e,t)}),hs=u("ZodNumber",(e,t)=>{Fo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,s,r)=>Vl(e,o,s),e.gt=(o,s)=>e.check(ns(o,s)),e.gte=(o,s)=>e.check(Tn(o,s)),e.min=(o,s)=>e.check(Tn(o,s)),e.lt=(o,s)=>e.check(ts(o,s)),e.lte=(o,s)=>e.check(Sn(o,s)),e.max=(o,s)=>e.check(Sn(o,s)),e.int=o=>e.check(he(o)),e.safe=o=>e.check(he(o)),e.positive=o=>e.check(ns(0,o)),e.nonnegative=o=>e.check(Tn(0,o)),e.negative=o=>e.check(ts(0,o)),e.nonpositive=o=>e.check(Sn(0,o)),e.multipleOf=(o,s)=>e.check(os(o,s)),e.step=(o,s)=>e.check(os(o,s)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Rt(e){return Ol(hs,e)}const Ju=u("ZodNumberFormat",(e,t)=>{Rc.init(e,t),hs.init(e,t)});function he(e){return Il(Ju,e)}const Xu=u("ZodBoolean",(e,t)=>{bc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Wl(e,n,o)});function v(e){return wl(Xu,e)}const Qu=u("ZodUnknown",(e,t)=>{Ac.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Kl()});function ms(){return vl(Qu)}const qu=u("ZodNever",(e,t)=>{Nc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Yl(e,n,o)});function ed(e){return Cl(qu,e)}const td=u("ZodArray",(e,t)=>{$c.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>eu(e,n,o,s),e.element=t.element,e.min=(n,o)=>e.check(wt(n,o)),e.nonempty=n=>e.check(wt(1,n)),e.max=(n,o)=>e.check(ss(n,o)),e.length=(n,o)=>e.check(rs(n,o)),e.unwrap=()=>e.element});function A(e,t){return Ul(td,e,t)}const nd=u("ZodObject",(e,t)=>{Dc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>tu(e,n,o,s),b(e,"shape",()=>t.shape),e.keyof=()=>U(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:ms()}),e.loose=()=>e.clone({...e._zod.def,catchall:ms()}),e.strict=()=>e.clone({...e._zod.def,catchall:ed()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>ea(e,n),e.safeExtend=n=>ta(e,n),e.merge=n=>na(e,n),e.pick=n=>Qi(e,n),e.omit=n=>qi(e,n),e.partial=(...n)=>oa(gs,e,n[0]),e.required=(...n)=>sa(Ss,e,n[0])});function p(e,t){const n={type:"object",shape:e??{},...g(t)};return new nd(n)}const Es=u("ZodUnion",(e,t)=>{Zo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>nu(e,n,o,s),e.options=t.options});function od(e,t){return new Es({type:"union",options:e,...g(t)})}const sd=u("ZodDiscriminatedUnion",(e,t)=>{Es.init(e,t),kc.init(e,t)});function q(e,t,n){return new sd({type:"union",options:t,discriminator:e,...g(n)})}const rd=u("ZodIntersection",(e,t)=>{Pc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>ou(e,n,o,s)});function id(e,t){return new rd({type:"intersection",left:e,right:t})}const ad=u("ZodRecord",(e,t)=>{zc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>su(e,n,o,s),e.keyType=t.keyType,e.valueType=t.valueType});function Z(e,t,n){return new ad({type:"record",keyType:e,valueType:t,...g(n)})}const On=u("ZodEnum",(e,t)=>{jc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,s,r)=>Jl(e,o,s),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(o,s)=>{const r={};for(const i of o)if(n.has(i))r[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new On({...t,checks:[],...g(s),entries:r})},e.exclude=(o,s)=>{const r={...t.entries};for(const i of o)if(n.has(i))delete r[i];else throw new Error(`Key ${i} not found in enum`);return new On({...t,checks:[],...g(s),entries:r})}});function U(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new On({type:"enum",entries:n,...g(t)})}const cd=u("ZodLiteral",(e,t)=>{Uc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Xl(e,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function E(e,t){return new cd({type:"literal",values:Array.isArray(e)?e:[e],...g(t)})}const ld=u("ZodTransform",(e,t)=>{Fc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>ql(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new To(e.constructor.name);n.addIssue=r=>{if(typeof r=="string")n.issues.push(et(r,n.value,t));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(et(i))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(r=>(n.value=r,n)):(n.value=s,n)}});function ud(e){return new ld({type:"transform",transform:e})}const gs=u("ZodOptional",(e,t)=>{Wo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>ls(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function _s(e){return new gs({type:"optional",innerType:e})}const dd=u("ZodExactOptional",(e,t)=>{Mc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>ls(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function pd(e){return new dd({type:"optional",innerType:e})}const fd=u("ZodNullable",(e,t)=>{Gc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>ru(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function ys(e){return new fd({type:"nullable",innerType:e})}const hd=u("ZodDefault",(e,t)=>{xc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>au(e,n,o,s),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function md(e,t){return new hd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Co(t)}})}const Ed=u("ZodPrefault",(e,t)=>{Bc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>cu(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function gd(e,t){return new Ed({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Co(t)}})}const Ss=u("ZodNonOptional",(e,t)=>{Zc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>iu(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function _d(e,t){return new Ss({type:"nonoptional",innerType:e,...g(t)})}const yd=u("ZodCatch",(e,t)=>{Hc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>lu(e,n,o,s),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Sd(e,t){return new yd({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Td=u("ZodPipe",(e,t)=>{Vc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>uu(e,n,o,s),e.in=t.in,e.out=t.out});function Ts(e,t){return new Td({type:"pipe",in:e,out:t})}const Od=u("ZodReadonly",(e,t)=>{Wc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>du(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function Id(e){return new Od({type:"readonly",innerType:e})}const Os=u("ZodCustom",(e,t)=>{Yc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Ql(e,n)});function xe(e,t){return Fl(Os,e??(()=>!0),t)}function wd(e,t={}){return Ml(Os,e,t)}function vd(e){return Gl(e)}const Ce={SCROLL_TO_TILE:"SCROLL_TO_TILE",HYPER_LINK:"HYPER_LINK",MAIL_LINK:"MAIL_LINK",TEL_LINK:"TEL_LINK",GO_TO_STORE:"GO_TO_STORE",GO_TO_STORE_LINK:"GO_TO_STORE_LINK",GO_TO_PAGE:"GO_TO_PAGE",GO_TO_CATEGORY:"GO_TO_CATEGORY",GO_TO_CATEGORY_LINK:"GO_TO_CATEGORY_LINK"},Cd=U(Object.values(Ce)),nt={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"},Rd=U(Object.values(nt)),bt=nt,Is={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"},bd=U(Object.values(Is)),Ad=Is,ws={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"},Nd=U(Object.values(ws)),$d=ws,vs={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"},Ld=U(Object.values(vs)),Dd=vs,At={COLOR:"COLOR",GRADIENT:"GRADIENT"},kd=U(Object.values(At)),In=At,Ae={SECTION:"SECTION",HEADER:"HEADER",FOOTER:"FOOTER"},Pd=U(Object.values(Ae)),ye=Ae;var ee=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.Misc=2]="Misc",e[e.Layout=3]="Layout",e[e.Asset=4]="Asset",e[e.SharedFiles=5]="SharedFiles",e))(ee||{}),N=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.SectionSetting=2]="SectionSetting",e[e.SectionShowcase=3]="SectionShowcase",e[e.SectionAsset=4]="SectionAsset",e[e.TemplateDescriptor=5]="TemplateDescriptor",e[e.PageTemplateDescriptor=6]="PageTemplateDescriptor",e[e.TemplateAsset=7]="TemplateAsset",e[e.Layout=8]="Layout",e[e.LayoutSettings=9]="LayoutSettings",e[e.LayoutAsset=10]="LayoutAsset",e[e.SlotServer=11]="SlotServer",e[e.SlotClient=12]="SlotClient",e[e.SharedTranslation=13]="SharedTranslation",e[e.CollectionDescriptor=14]="CollectionDescriptor",e[e.CollectionAsset=15]="CollectionAsset",e))(N||{}),zd=(e=>(e.SCROLL_TO_TILE="SCROLL_TO_TILE",e.HYPER_LINK="HYPER_LINK",e.MAIL_LINK="MAIL_LINK",e.TEL_LINK="TEL_LINK",e.GO_TO_STORE="GO_TO_STORE",e.GO_TO_STORE_LINK="GO_TO_STORE_LINK",e.GO_TO_PAGE="GO_TO_PAGE",e))(zd||{});const O={TEXTAREA:"TEXTAREA",INPUTBOX:"INPUTBOX",SELECTBOX:"SELECTBOX",IMAGE:"IMAGE",TOGGLE:"TOGGLE",BUTTON:"BUTTON",DECK:"DECK",MENU:"MENU",NAVIGATION_MENU:"NAVIGATION_MENU",LOGO:"LOGO",INFO:"INFO",DIVIDER:"DIVIDER",PRODUCT_SELECTOR:"PRODUCT_SELECTOR",CATEGORY_SELECTOR:"CATEGORY_SELECTOR"};U(Object.values(O));const w={TEXT:"TEXT",BUTTON:"BUTTON",IMAGE:"IMAGE",TOGGLE:"TOGGLE",SELECTBOX:"SELECTBOX",BACKGROUND:"BACKGROUND",COLOR_PICKER:"COLOR_PICKER",LOGO:"LOGO",DIVIDER:"DIVIDER",INFO:"INFO",ACCORDION:"ACCORDION"};U(Object.values(w));const te=w,ot={CONTENT:"Content",DESIGN:"Design"};U(Object.values(ot));const jd={TEXT:"TEXT",IMAGE:"IMAGE"},Ud=U(Object.values(jd));var Fd=(e=>(e.ORIGINAL="original",e.WEBP_LOW_RES="webp-200x200",e.WEBP_HI_2X_RES="webp-2000x2000",e.MOBILE_WEBP_LOW_RES="cropped-webp-100x200",e.MOBILE_WEBP_HI_RES="cropped-webp-1000x2000",e))(Fd||{}),Md=(e=>(e.TILE_LOADED="tile-loaded",e.TILE_UNLOADED="tile-unloaded",e))(Md||{});const Gd={apparel_footwear:"apparel_footwear",vape_smoke:"vape_smoke",home_garden:"home_garden",sport_outdoor:"sport_outdoor",jewelry_accessories:"jewelry_accessories",pet_animals:"pet_animals",bikes:"bikes",health_beauty:"health_beauty",gift_shop:"gift_shop",electronics:"electronics",other:"other"},xd=U(Object.values(Gd)),G={[ye.SECTION]:{source:"sections",dist:"dist/sections"},[ye.HEADER]:{source:"headers",dist:"dist/headers"},[ye.FOOTER]:{source:"footers",dist:"dist/footers"}};var R=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.ClientChunks=2]="ClientChunks",e[e.ClientAsset=3]="ClientAsset",e[e.Asset=4]="Asset",e[e.TemplateAsset=5]="TemplateAsset",e[e.Dependency=6]="Dependency",e[e.SourceCode=7]="SourceCode",e[e.LayoutClient=8]="LayoutClient",e[e.LayoutAsset=9]="LayoutAsset",e[e.SlotServer=10]="SlotServer",e[e.SlotClient=11]="SlotClient",e[e.SlotClientChunks=12]="SlotClientChunks",e[e.SlotClientAsset=13]="SlotClientAsset",e[e.CollectionAsset=14]="CollectionAsset",e))(R||{});function Be(e){const t={};for(const[n,o]of Object.entries(e)){let s={...o};if(o.type==="DECK"&&o.cards&&typeof o.cards=="object"&&"defaultCardContent"in o.cards){const r=o.cards;r.defaultCardContent?.settings&&(s={...s,cards:{...r,defaultCardContent:{...r.defaultCardContent,settings:Be(r.defaultCardContent.settings)}}})}if(o.type==="ACCORDION"&&o.cards&&typeof o.cards=="object"&&!("defaultCardContent"in o.cards)){const r=o.cards,i={};for(const[a,c]of Object.entries(r))c.editors?i[a]={...c,editors:Be(c.editors)}:i[a]=c;s={...s,cards:i}}if(s.defaults&&typeof s.defaults=="object"&&!("type"in s.defaults)){const r=Object.assign({type:s.type},s.defaults);s={...s,defaults:r}}t[n]=s}return t}const Bd={url:"must be a valid URL",email:"must be a valid email address"},Zd=e=>{const t=e?.at(-1);return typeof t=="string"?`'${t}'`:"Field"},Hd=e=>e===null?"null":typeof e,Vd=e=>{switch(e.code){case"invalid_type":{const{input:t}=e;return t===void 0?{message:`${Zd(e.path)} is required`}:{message:`Expected ${String(e.expected)}, received ${Hd(t)}`}}case"invalid_format":{const t=Bd[e.format];return t?{message:t}:void 0}case"unrecognized_keys":return{message:`Unrecognized property: ${e.keys.map(t=>`'${t}'`).join(", ")}`};case"invalid_union":{const t=e.path?.at(-1);return typeof t=="string"?{message:`'${t}' is required or has invalid value`}:void 0}case"invalid_value":{const{values:t}=e;return t?{message:`Expected one of: ${t.map(n=>`'${String(n)}'`).join(", ")}`}:void 0}case"invalid_key":{const t=e.issues?.[0];return t?{message:t.message}:void 0}default:return}};U(["none","all","small"]);const Ne={PRODUCT:"PRODUCT",CATALOG:"CATALOG",CATEGORY:"CATEGORY",HOME:"HOME",CUSTOM:"CUSTOM"},Cs={HOME:"home",CATALOG:"catalog",CATEGORY:"category",PRODUCT:"product"},Wd=U(Object.values(Ne));U(Object.values(Cs));const Yd={HEADER_LEFT:"HEADER_LEFT",HEADER_CENTER_LOGO_BURGER:"HEADER_CENTER_LOGO_BURGER",HEADER_CENTER_LOGO_COMPACT:"HEADER_CENTER_LOGO_COMPACT",HEADER_CENTER_LOGO_DETAILED:"HEADER_CENTER_LOGO_DETAILED",HEADER_LEFT_LOGO_BURGER:"HEADER_LEFT_LOGO_BURGER",HEADER_LEFT_LOGO_COMPACT:"HEADER_LEFT_LOGO_COMPACT",HEADER_LEFT_LOGO_DETAILED:"HEADER_LEFT_LOGO_DETAILED",HEADER_LEFT_LOGO_SEARCH:"HEADER_LEFT_LOGO_SEARCH",HEADER_LEFT_LOGO_TEXT:"HEADER_LEFT_LOGO_TEXT",TEXT_ONE_COLUMN:"TEXT_ONE_COLUMN",TEXT_TITLE_LEFT:"TEXT_TITLE_LEFT",TEXT_SUBTITLE_RIGHT:"TEXT_SUBTITLE_RIGHT",TEXT_TWO_COLUMNS:"TEXT_TWO_COLUMNS",TEXT_CENTER:"TEXT_CENTER",TEXT_DESCRIPTION_RIGHT:"TEXT_DESCRIPTION_RIGHT",CTA_BANNER_LEFT:"CTA_BANNER_LEFT",CTA_BANNER_RIGHT:"CTA_BANNER_RIGHT",CTA_BANNER_CENTER:"CTA_BANNER_CENTER",CTA_BANNER_BOTTOM:"CTA_BANNER_BOTTOM",CTA_PROMO_BAR_LEFT:"CTA_PROMO_BAR_LEFT",CTA_PROMO_BAR_RIGHT:"CTA_PROMO_BAR_RIGHT",CTA_STORY_LEFT:"CTA_STORY_LEFT",CTA_STORY_RIGHT:"CTA_STORY_RIGHT",CTA_FULLWIDTH_CENTER:"CTA_FULLWIDTH_CENTER",CTA_FULLWIDTH_LEFT:"CTA_FULLWIDTH_LEFT",CTA_FULLWIDTH_NO_IMAGE:"CTA_FULLWIDTH_NO_IMAGE",COVER_FULLSCREEN_CENTER:"COVER_FULLSCREEN_CENTER",COVER_FULLSCREEN_LEFT:"COVER_FULLSCREEN_LEFT",COVER_FULLSCREEN_CENTER_LEFT:"COVER_FULLSCREEN_CENTER_LEFT",COVER_FULLSCREEN_RIGHT:"COVER_FULLSCREEN_RIGHT",COVER_FULLSCREEN_BOTTOM:"COVER_FULLSCREEN_BOTTOM",COVER_FULLSCREEN_BOTTOM_RIGHT:"COVER_FULLSCREEN_BOTTOM_RIGHT",COVER_FULLSCREEN_BOTTOM_LEFT:"COVER_FULLSCREEN_BOTTOM_LEFT",COVER_FULLSCREEN_TOP:"COVER_FULLSCREEN_TOP",COVER_SIDEBAR_RIGHT:"COVER_SIDEBAR_RIGHT",COVER_SIDEBAR_LEFT:"COVER_SIDEBAR_LEFT",COVER_HALFSCREEN_LEFT:"COVER_HALFSCREEN_LEFT",COVER_HALFSCREEN_CENTER:"COVER_HALFSCREEN_CENTER",COVER_COLLAGE_BOTTOM:"COVER_COLLAGE_BOTTOM",COVER_COLLAGE_LEFT:"COVER_COLLAGE_LEFT",IMAGE_SUBTITLE_RIGHT:"IMAGE_SUBTITLE_RIGHT",IMAGE_TITLE_LEFT:"IMAGE_TITLE_LEFT",IMAGE_LEFT:"IMAGE_LEFT",IMAGE_RIGHT:"IMAGE_RIGHT",IMAGE_CENTER:"IMAGE_CENTER",IMAGE_SIDE_TITLE:"IMAGE_SIDE_TITLE",LOCATION_MAP_RIGHT:"LOCATION_MAP_RIGHT",LOCATION_MAP_LEFT:"LOCATION_MAP_LEFT",LOCATION_IMAGE_RIGHT:"LOCATION_IMAGE_RIGHT",LOCATION_IMAGE_LEFT:"LOCATION_IMAGE_LEFT",LOCATION_BACKGROUND_RIGHT:"LOCATION_BACKGROUND_RIGHT",LOCATION_BACKGROUND_LEFT:"LOCATION_BACKGROUND_LEFT",LOCATION_FULL:"LOCATION_FULL",LOCATION_SHORT:"LOCATION_SHORT",REVIEWS_MINIMAL:"REVIEWS_MINIMAL",REVIEWS_CARDS:"REVIEWS_CARDS",REVIEWS:"REVIEWS",REVIEWS_CLASSIC:"REVIEWS_CLASSIC",REVIEWS_FULLSCREEN_BG:"REVIEWS_FULLSCREEN_BG",REVIEWS_FULLSCREEN_SIDEBAR_LEFT:"REVIEWS_FULLSCREEN_SIDEBAR_LEFT",REVIEWS_FULLSCREEN_SIDEBAR_RIGHT:"REVIEWS_FULLSCREEN_SIDEBAR_RIGHT",REVIEWS_CARDS_PHOTO:"REVIEWS_CARDS_PHOTO",REVIEWS_PHOTO_SPEECH_RIGHT:"REVIEWS_PHOTO_SPEECH_RIGHT",REVIEWS_PHOTO_SPEECH_LEFT:"REVIEWS_PHOTO_SPEECH_LEFT",REVIEWS_SOCIAL_FEED:"REVIEWS_SOCIAL_FEED",REVIEWS_ADAPTIVE:"REVIEWS_ADAPTIVE",FEATURES_CLASSIC_CENTER:"FEATURES_CLASSIC_CENTER",FEATURES_CLASSIC_LEFT:"FEATURES_CLASSIC_LEFT",FEATURES_ACCORDION:"FEATURES_ACCORDION",FEATURES_MINIMAL:"FEATURES_MINIMAL",FEATURES_SMALL_ICONS:"FEATURES_SMALL_ICONS",FEATURES_CAROUSEL:"FEATURES_CAROUSEL",FEATURES_IMAGE_LEFT:"FEATURES_IMAGE_LEFT",FEATURES_IMAGE_RIGHT:"FEATURES_IMAGE_RIGHT",ANNOUNCEMENT_CENTER:"ANNOUNCEMENT_CENTER",TWO_COLUMNS_SIDEBAR_ON_THE_LEFT:"TWO_COLUMNS_SIDEBAR_ON_THE_LEFT",TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT:"TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT",THREE_COLUMNS_SIDEBAR_ON_THE_RIGHT:"THREE_COLUMNS_SIDEBAR_ON_THE_RIGHT",THREE_COLUMNS_SIDEBAR_ON_THE_LEFT:"THREE_COLUMNS_SIDEBAR_ON_THE_LEFT",TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT_DESCRIPTION_UNDER_IMAGE:"TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT_DESCRIPTION_UNDER_IMAGE",SLIDER_FULLSCREEN_CENTER:"SLIDER_FULLSCREEN_CENTER",SLIDER_FULLSCREEN_LEFT:"SLIDER_FULLSCREEN_LEFT",SLIDER_BASIC:"SLIDER_BASIC",SLIDER_CAROUSEL:"SLIDER_CAROUSEL",SLIDER_CAROUSEL_PORTRAIT:"SLIDER_CAROUSEL_PORTRAIT",SLIDER_SPLIT:"SLIDER_SPLIT",SLIDER_SPLIT_REVERSE:"SLIDER_SPLIT_REVERSE"},Kd=U(Object.values(Yd)),Jd={HEADER:"header",COVER:"cover",ANNOUNCEMENT_BAR:"announcement_bar",SLIDER:"slider",SPECIAL_OFFER:"special_offer",CUSTOMER_REVIEW:"customer_review",COMPANY_INFO:"company_info",SHIPPING_PAYMENT:"shipping_payment",LOCATION:"location",STORE:"store",FOOTER:"footer",VIDEO:"video",IMAGE_GALLERY:"image_gallery",CONTACT_INFO:"contact_info",CONTACTS_WIDGET_WHATSAPP:"contacts_widget_whatsapp",CONTACTS_WIDGET_INSTAGRAM:"contacts_widget_instagram",CONTACTS_WIDGET_FACEBOOK:"contacts_widget_facebook",CONTACTS_WIDGET_PHONE:"contacts_widget_phone"},Xd={COVER:"COVER",ANNOUNCEMENT:"ANNOUNCEMENT",STORE:"STORE",SLIDER:"SLIDER",VIDEO:"VIDEO",SPECIAL_OFFER:"SPECIAL_OFFER",CUSTOMER_REVIEW:"CUSTOMER_REVIEW",COMPANY_INFO:"COMPANY_INFO",SHIPPING_PAYMENT:"SHIPPING_PAYMENT",LOCATION:"LOCATION",COLLECTIONS:"COLLECTIONS",BRANDS:"BRANDS",CONTACT_INFO:"CONTACT_INFO"},Qd=U(Object.values(Xd)),X={REQUIRED_HEADER_ID:()=>'Header section must have id "header" when type is "default"',REQUIRED_CUSTOM_HEADER:(...e)=>`Custom header section with id "${e[0]}" must exist in headers directory`,REQUIRED_CUSTOM_HEADER_TYPE:(...e)=>`Custom header section with id "${e[0]}" must be of type "HEADER"`,REQUIRED_FOOTER_ID:()=>'Footer section must have id "footer" when type is "default"',REQUIRED_CUSTOM_FOOTER:(...e)=>`Custom footer section with id "${e[0]}" must exist in footers directory`,REQUIRED_CUSTOM_FOOTER_TYPE:(...e)=>`Custom footer section with id "${e[0]}" must be of type "FOOTER"`,REQUIRED_PAGE_SECTION:(...e)=>`Custom section with id "${e[0]}" must exist in sections directory`,REQUIRED_PAGE_SECTION_TYPE:()=>'Section "header" or "footer" is not allowed among page sections',SHOWCASE_ID_NOT_FOUND:(...e)=>`Showcase with id "${e[0]}" must exist in section's showcase directory`,DUPLICATE_SHOWCASE_ID:(...e)=>`Showcase id "${e[0]}" must be unique within section showcases`,SHOWCASE_OVERRIDE_CONTENT:(...e)=>`Content editor "${e[0]}" in showcase_overrides must exist in section's content configuration file`,SHOWCASE_OVERRIDE_DESIGN:(...e)=>`Design editor "${e[0]}" in showcase_overrides must exist in section's design configuration file`,SHOWCASE_OVERRIDE_LAYOUT:(...e)=>`LayoutId "${e[0]}" in showcase_overrides must exist in section's layout configuration file`,SHOWCASE_LAYOUT:(...e)=>`LayoutId "${e[0]}" in showcase must exist in section's layout configuration file`,INVALID_SHOWCASE_CONTENT_ELEMENT:(...e)=>`Element "${e[0]}" is not defined in content.ts`,SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH:(...e)=>`Element "${e[0]}" type mismatch: showcase has type "${e[1]}" but content.ts has type "${e[2]}"`,INVALID_SHOWCASE_DESIGN_ELEMENT:(...e)=>`Element "${e[0]}" is not defined in design.ts`,SHOWCASE_DESIGN_ELEMENT_TYPE_MISMATCH:(...e)=>`Element "${e[0]}" type mismatch: showcase has type "${e[1]}" but design.ts has type "${e[2]}"`,INVALID_DECK_CARD_SETTING:(...e)=>`Setting "${e[0]}" is not defined in content.ts defaultCardContent.settings`,DECK_SETTINGS_REQUIRED:()=>"settings must have at least one property",INVALID_SELECTBOX_OPTION:(...e)=>`Option value "${e[0]}" for element "${e[1]}" is not defined in content.ts options`,REQUIRED_STORE_LAYOUT:(...e)=>`Store section with id "${e[0]}" and page type "${e[1]}" must have a corresponding layout defined`,INVALID_STORE_SECTION_ID:(...e)=>`Store layout sectionId "${e[0]}" must be one of: ${e[1]}`,REQUIRED_SECTION_ASSET:(...e)=>`Asset size ${e[0]} exceeds threshold of ${e[1]}.`,REQUIRED_SERVER_SIZE:(...e)=>`Size of individual server file [${e[0]}] must not exceed threshold [${e[1]}].`,MISSING_IMAGE_ASSET:(...e)=>`Image ${e[0]} is missing from assets folder`,MANDATORY_SETTING_TYPE_MISMATCH:(...e)=>`Editor type "${e[0]}" for reserved key "${e[1]}" does not match the required type "${e[2]}".`,MANDATORY_SETTING_NAME_MISMATCH:(...e)=>`Editor key "${e[0]}" for overridden content type "${e[1]}" does not match the required key name "${e[2]}".`,DUPLICATED_MANDATORY_SETTING:(...e)=>`Editor type "${e[0]}" can only be used once.`,IMAGE_EDITOR_STATIC_MISMATCH:(...e)=>`Both "${e[0]}" content and design editor need to have same value for attribute static`,DUPLICATE_DESIGN_EDITOR_NAME:()=>"Non-unique design editor name detected",COLOR_REQUIRED_GRADIENT:()=>"color is required when overlay is GRADIENT",COLOR_MUST_BE_ARRAY_GRADIENT:()=>"color must be an array when overlay is GRADIENT",COLOR_ARRAY_LENGTH_GRADIENT:()=>"color array must have exactly 2 items when overlay is GRADIENT",COLOR_REQUIRED_COLOR:()=>"color is required when overlay is COLOR",COLOR_MUST_BE_SINGLE_COLOR:()=>"color must be a single value when overlay is COLOR",COLOR_MUST_BE_UNDEFINED_NONE:()=>"color must be undefined when overlay is NONE or not set",COLOR_REQUIRED_STYLE_GRADIENT:()=>"color is required when style is GRADIENT",COLOR_MUST_BE_ARRAY_STYLE_GRADIENT:()=>"color must be an array when style is GRADIENT",COLOR_ARRAY_LENGTH_STYLE_GRADIENT:()=>"color array must have exactly 2 items when style is GRADIENT",COLOR_REQUIRED_STYLE_COLOR:()=>"color is required when style is COLOR",COLOR_MUST_BE_SINGLE_STYLE_COLOR:()=>"color must be a single value when style is COLOR",BUTTON_LINK_REQUIRED:()=>"link is required when buttonType is HYPER_LINK",BUTTON_CATEGORY_ID_REQUIRED:()=>"categoryId is required when buttonType is GO_TO_CATEGORY or GO_TO_CATEGORY_LINK",BUTTON_EMAIL_REQUIRED:()=>"email is required when buttonType is MAIL_LINK",BUTTON_PHONE_REQUIRED:()=>"phone is required when buttonType is TEL_LINK",BUTTON_TILE_ID_REQUIRED:(...e)=>`${e[0]} is required when buttonType is SCROLL_TO_TILE`,BUTTON_PAGE_ID_REQUIRED:()=>"pageIdForNavigate is required when type is GO_TO_PAGE",TEMPLATE_PAGE_SECTIONS_REQUIRED:()=>"sections must contain at least one section",TEMPLATE_PAGE_SINGLE_SECTION_REQUIRED:(...e)=>`Page type "${e[0]}" must have exactly one section`,TEMPLATE_PAGE_STORE_SECTION_REQUIRED:(...e)=>`Page type "${e[0]}" must have a section of type "store"`,TEMPLATE_PAGE_NO_STORE_SECTIONS:(...e)=>`Page type "${e[0]}" cannot contain store sections`,TEMPLATE_PAGE_CUSTOM_METADATA_REQUIRED:()=>'Page type "CUSTOM" must have a metadata property',TEMPLATE_PAGE_METADATA_NOT_ALLOWED:(...e)=>`Page type "${e[0]}" must not have a metadata property`,NON_NEGATIVE_INTEGER:()=>"must be a non-negative integer",INTEGER_RANGE:(...e)=>`must be between ${e[0]} and ${e[1]}`,VALID_HEX_COLOR:()=>"must be a valid hex color (#RGB, #RRGGBB, or #RRGGBBAA)",VALID_GLOBAL_FONT:()=>"must be a valid global font reference (global.fontFamily.title or global.fontFamily.body)",VALID_GLOBAL_TEXT_SIZE:()=>"must be a valid global text size reference (global.textSize.title, global.textSize.subtitle, or global.textSize.body)",VALID_GLOBAL_COLOR:()=>"must be a valid global color reference (global.color.title, global.color.body, global.color.button, global.color.link, or global.color.background)",VALID_COLOR:()=>"must be a valid hex color (#RGB, #RRGGBB, or #RRGGBBAA) or global color reference (global.color.title, global.color.body, global.color.button, global.color.link, or global.color.background)",VALID_TEXT_SIZE:()=>"must be an integer of at least 1 or a valid global text size reference (global.textSize.title, global.textSize.subtitle, or global.textSize.body)",VALID_LANGUAGE_CODE:()=>"must be a valid language code (e.g., en, nl, fr, en_US, en_GB, zh_Hans)",VALID_URL:()=>"must be a valid URL",VALID_EMAIL:()=>"must be a valid email address",ACCORDION_ITEM_POSITION_FIELD_REQUIRED:(...e)=>`Item "${e[0]}" must have positionFieldName when sortable is true`,ACCORDION_ITEMS_REQUIRED:()=>"items must have at least one item",ACCORDION_ITEM_EDITORS_REQUIRED:(...e)=>`Item "${e[0]}" must have at least one editor`,ACCORDION_SHOWCASE_ITEMS_REQUIRED:()=>"items must have at least one item",ACCORDION_SHOWCASE_ITEM_EDITORS_REQUIRED:(...e)=>`Item "${e[0]}" must have at least one editor override`,ACCORDION_DUPLICATE_POSITION_FIELD_NAME:()=>"positionFieldName must be unique across accordion items when sortable is true",REQUIRED_COLLECTION_NAME:()=>"Collection must have a name in metadata"},Rs=/^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,bs=/^global\.fontFamily\.(title|body)$/,As=/^global\.textSize\.(title|subtitle|body)$/,Ns=/^global\.color\.(title|body|button|link|background)$/,qd=/^[a-z]{2}(_([a-z]{2}|[A-Z]{2}|[0-9]{3}))?$/,Re=(e,t)=>{const n=X.INTEGER_RANGE(e.toString(),t.toString());return he().min(e,{message:n}).max(t,{message:n})},wn=p({path:h(),size:Rt().nonnegative()}).strict(),$s=p({size:Rt().nonnegative()}).strict(),_=h().regex(/^\$.+/,{message:"must start with '$' followed by at least one character"}),ep=p({r:Re(0,255),g:Re(0,255),b:Re(0,255),a:Re(0,1)}).strict(),Ls=h().regex(Rs,{message:X.VALID_HEX_COLOR()});xe(e=>typeof e=="string"&&bs.test(e),{message:X.VALID_GLOBAL_FONT()});const vn=h().refine(e=>!e.startsWith("global.")||bs.test(e),{message:X.VALID_GLOBAL_FONT()});xe(e=>typeof e=="string"&&Ns.test(e),{message:X.VALID_GLOBAL_COLOR()});const ue=xe(e=>typeof e=="string"&&(Rs.test(e)||Ns.test(e)),{message:X.VALID_COLOR()}),Ds=xe(e=>typeof e=="string"?ue.safeParse(e).success:Array.isArray(e)&&e.every(t=>ue.safeParse(t).success),{message:X.VALID_COLOR()});xe(e=>typeof e=="string"&&As.test(e),{message:X.VALID_GLOBAL_TEXT_SIZE()});const ks=xe(e=>typeof e=="number"?Number.isInteger(e)&&e>=1:typeof e=="string"&&As.test(e),{message:X.VALID_TEXT_SIZE()}),st=U(["catalog","category","product"]),Nt=h().refine(e=>e.startsWith("#")||fs().safeParse(e).success,{message:"must be a valid URL or a hash fragment starting with #"}),rt=p({url:h(),width:he().min(0,{message:X.NON_NEGATIVE_INTEGER()}).optional(),height:he().min(0,{message:X.NON_NEGATIVE_INTEGER()}).optional()}).strict(),tp=p({homogeneity:v().optional(),color:ep.optional()}).strict(),np=p({ORIGINAL:rt.optional(),WEBP_LOW_RES:rt.optional(),WEBP_HI_2X_RES:rt.optional(),MOBILE_WEBP_LOW_RES:rt.optional(),MOBILE_WEBP_HI_RES:rt.optional()}).strict().refine(e=>Object.keys(e).length>=1,{message:"set must have at least one property"}),$t=p({set:np,borderInfo:tp.optional()}).strict(),Cn=p({type:E(O.IMAGE),imageData:$t}).strict(),Ps=p({type:E(O.IMAGE),label:_,static:v().optional(),defaults:Cn.optional()}).strict(),op=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Rn(e){return e===Ne.PRODUCT||e===Ne.CATALOG||e===Ne.CATEGORY}function zs(e,t,n){if(!e)return;const o=Ri({path:"$..set..url",json:e,resultType:"all"}),s=/^https?:\/\//;o.forEach(r=>{const i=r.value;if(!s.test(i)&&!t.includes(i)){const a=r.pointer.split("/").filter(c=>c.length>0);n.at(a).addIssue("MISSING_IMAGE_ASSET",i)}})}function js(e,t,n){e===Ce.HYPER_LINK&&!t&&n.at("link").addIssue("BUTTON_LINK_REQUIRED")}function Us(e,t,n){(e===Ce.GO_TO_CATEGORY||e===Ce.GO_TO_CATEGORY_LINK)&&!t&&n.at("categoryId").addIssue("BUTTON_CATEGORY_ID_REQUIRED")}function Fs(e,t,n){e===Ce.MAIL_LINK&&!t&&n.at("email").addIssue("BUTTON_EMAIL_REQUIRED")}function Ms(e,t,n){e===Ce.TEL_LINK&&!t&&n.at("phone").addIssue("BUTTON_PHONE_REQUIRED")}function Gs(e,t,n,o){if(e===Ce.SCROLL_TO_TILE&&!(t??n)){const s=t?"tileId":"tileIdForScroll";o.at(s).addIssue("BUTTON_TILE_ID_REQUIRED",s)}}function sp(e,t,n){e===Ce.GO_TO_PAGE&&!t&&n.at("pageIdForNavigate").addIssue("BUTTON_PAGE_ID_REQUIRED")}const rp="custom";function x(e,t=[]){const n=s=>Array.isArray(s)?s:[s],o=n(t);return{raw:e,addIssue(s,...r){e.addIssue({code:rp,message:X[s](...r),path:o,params:{errorMessageKey:s}})},at(s){const r=o.concat(n(s));return x(e,r)}}}const bn=p({type:E(O.BUTTON),title:_,buttonType:Cd,link:h().optional(),linkTarget:h().optional(),email:h().regex(op,{message:X.VALID_EMAIL()}).optional(),phone:h().optional(),tileId:h().optional(),categoryId:Rt().optional()}).strict().superRefine((e,t)=>{const n=x(t);js(e.buttonType,e.link,n),Us(e.buttonType,e.categoryId,n),Fs(e.buttonType,e.email,n),Ms(e.buttonType,e.phone,n),Gs(e.buttonType,e.tileId,void 0,n)}),xs=p({type:E(O.BUTTON),label:_,defaults:bn.optional()}).strict(),An=p({type:E(O.CATEGORY_SELECTOR)}).strict(),Bs=p({type:E(O.CATEGORY_SELECTOR),label:_,maxCategories:Re(1,32),defaults:An.optional()}).strict(),Nn=p({type:E(O.DIVIDER)}).strict(),Zs=p({type:E(O.DIVIDER),label:_,defaults:Nn.optional()}).strict(),ip=p({label:_,link:Nt}).strict(),ap=p({title:_.optional(),link:Nt.optional()}).strict(),$n=p({type:E(O.INFO),text:_.optional(),button:ap.optional()}).strict(),Hs=p({type:E(O.INFO),label:_,description:_,button:ip.optional(),defaults:$n.optional()}).strict(),Ln=p({type:E(O.INPUTBOX),text:_}).strict(),Vs=p({type:E(O.INPUTBOX),label:_,placeholder:_,defaults:Ln.optional()}).strict(),Dn=p({type:E(O.PRODUCT_SELECTOR)}).strict(),Ws=p({type:E(O.PRODUCT_SELECTOR),label:_,maxProducts:Re(1,32),defaults:Dn.optional()}).strict(),kn=p({type:E(O.SELECTBOX),value:h()}).strict(),cp=p({value:h().min(1,{message:"value must not be empty"}),label:_}).strict(),Ys=p({type:E(O.SELECTBOX),label:_,placeholder:_,description:_,options:A(cp).min(1,{message:"must have at least one option"}),defaults:kn.optional()}).strict(),Pn=p({type:E(O.TEXTAREA),text:_}).strict(),Ks=p({type:E(O.TEXTAREA),label:_,placeholder:_,defaults:Pn.optional()}).strict(),zn=p({type:E(O.TOGGLE),enabled:v()}).strict(),Js=p({type:E(O.TOGGLE),label:_,description:_,defaults:zn.optional()}).strict(),Xs=p({type:E(O.DECK)}).strict(),Qs=[Ln,Pn,bn,Cn,zn,kn,Nn,$n,Dn,An],lp=q("type",[...Qs]),up=p({type:E(O.DECK),cards:A(p({settings:Z(h(),lp).superRefine((e,t)=>{Object.keys(e).length<1&&x(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()).min(1,{message:"cards must have at least one card"})}).strict(),dp=q("type",[...Qs,up]),pp=p({type:E(O.DECK),cards:A(p({settings:Z(h(),dp).superRefine((e,t)=>{Object.keys(e).length<1&&x(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()).min(1,{message:"cards must have at least one card"})}).strict(),qs=[Vs,Ks,xs,Ps,Js,Ys,Zs,Hs,Bs,Ws],fp=p({type:E(O.DECK),label:_,addButtonLabel:_,maxCards:he().min(1,{message:"must be a positive integer"}),cards:p({defaultCardContent:p({label:_,settings:Z(h(),q("type",[...qs])).superRefine((e,t)=>{Object.keys(e).length<1&&x(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:Xs.optional()}).strict(),hp=q("type",[...qs,fp]),mp=p({type:E(O.DECK),label:_,addButtonLabel:_,maxCards:he().min(1,{message:"must be a positive integer"}),cards:p({defaultCardContent:p({label:_,settings:Z(h(),hp).superRefine((e,t)=>{Object.keys(e).length<1&&x(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:Xs.optional()}).strict(),er=p({type:E(O.LOGO),logoType:Ud.optional(),text:_.optional(),imageData:$t.optional()}).strict(),Ep=p({type:E(O.LOGO),label:_.optional(),defaults:er.optional()}).strict(),tr=p({id:h(),title:h().optional(),type:h().optional(),link:h().optional(),email:h().optional(),phone:h().optional(),tileIdForScroll:h().optional(),pageIdForNavigate:h().optional(),showStoreCategories:v().optional(),isSubmenuOpened:v().optional(),categoryId:Rt().optional()}).strict().superRefine((e,t)=>{const n=x(t);js(e.type,e.link,n),Us(e.type,e.categoryId,n),Fs(e.type,e.email,n),Ms(e.type,e.phone,n),Gs(e.type,void 0,e.tileIdForScroll,n),sp(e.type,e.pageIdForNavigate,n)}),nr=p({type:E(O.MENU),items:A(tr).optional()}).strict(),gp=p({type:E(O.MENU),label:_.optional(),defaults:nr.optional()}).strict(),or=p({type:E(O.NAVIGATION_MENU),items:A(tr).optional()}).strict(),_p=p({type:E(O.NAVIGATION_MENU),defaults:or.optional()}).strict(),Lt=p({type:E(w.BACKGROUND),style:kd.optional(),color:Ds.optional()}).strict().superRefine((e,t)=>{const n=x(t).at("color");e.style===At.GRADIENT?e.color===void 0?n.addIssue("COLOR_REQUIRED_STYLE_GRADIENT"):Array.isArray(e.color)?e.color.length!==2&&n.addIssue("COLOR_ARRAY_LENGTH_STYLE_GRADIENT"):n.addIssue("COLOR_MUST_BE_ARRAY_STYLE_GRADIENT"):e.style===At.COLOR&&(e.color===void 0?n.addIssue("COLOR_REQUIRED_STYLE_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_STYLE_COLOR"))}),yp=p({type:E(w.BACKGROUND),fieldName:h(),defaults:Lt.optional()}).strict(),sr=p({type:E(w.BACKGROUND),label:_,colors:A(ue).optional(),enableAlphaColor:v().optional(),enableAutoColor:v().optional(),defaults:Lt.optional()}).strict(),Dt=p({type:E(w.BUTTON),appearance:bd.optional(),size:Nd.optional(),shape:Ld.optional(),font:vn.optional(),color:ue.optional(),visible:v().optional()}).strict(),Sp=p({type:E(w.BUTTON),fieldName:h(),defaults:Dt.optional()}).strict(),rr=p({type:E(w.BUTTON),label:_,colors:A(ue).optional(),enableAutoColor:v().optional(),enableAlphaColor:v().optional(),hideVisibleToggle:v().optional(),hideSize:v().optional(),defaults:Dt.optional()}).strict(),kt=p({type:E(w.COLOR_PICKER),color:ue.optional()}).strict(),Tp=p({type:E(w.COLOR_PICKER),fieldName:h(),defaults:kt.optional()}).strict(),ir=p({type:E(w.COLOR_PICKER),label:_,description:_.optional(),colors:A(ue).optional(),enableAlphaColor:v().optional(),enableAutoColor:v().optional(),defaults:kt.optional()}).strict(),Pt=p({type:E(w.DIVIDER)}).strict(),Op=p({type:E(w.DIVIDER),fieldName:h(),defaults:Pt.optional()}).strict(),ar=p({type:E(w.DIVIDER),label:_,defaults:Pt.optional()}).strict(),zt=p({type:E(w.IMAGE),overlay:Rd.optional(),color:Ds.optional(),visible:v().optional()}).strict().superRefine((e,t)=>{const n=x(t).at("color");e.overlay===nt.GRADIENT?e.color===void 0?n.addIssue("COLOR_REQUIRED_GRADIENT"):Array.isArray(e.color)?e.color.length!==2&&n.addIssue("COLOR_ARRAY_LENGTH_GRADIENT"):n.addIssue("COLOR_MUST_BE_ARRAY_GRADIENT"):e.overlay===nt.COLOR?e.color===void 0?n.addIssue("COLOR_REQUIRED_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_COLOR"):(e.overlay===nt.NONE||e.overlay===void 0)&&e.color!==void 0&&n.addIssue("COLOR_MUST_BE_UNDEFINED_NONE")}),Ip=p({type:E(w.IMAGE),fieldName:h(),defaults:zt.optional()}).strict(),cr=p({type:E(w.IMAGE),label:_,static:v().optional(),colors:A(Ls).optional(),enableAlphaColor:v().optional(),hideVisibleToggle:v().optional(),defaults:zt.optional()}).strict(),wp=p({label:_,link:Nt}).strict(),vp=p({label:_.optional(),link:Nt.optional()}).strict(),jt=p({type:E(w.INFO),description:_.optional(),button:vp.optional()}).strict(),Cp=p({type:E(w.INFO),fieldName:h(),defaults:jt.optional()}).strict(),lr=p({type:E(w.INFO),label:_,description:_,button:wp.optional(),defaults:jt.optional()}).strict(),Rp=p({visible:v(),width:Re(1,49).optional(),color:ue.optional()}).strict(),Ut=p({type:E(w.LOGO),font:vn.optional(),size:ks.optional(),bold:v().optional(),italic:v().optional(),color:ue.optional(),visible:v().optional(),spacing:Re(1,9).optional(),frame:Rp.optional(),capitalization:U(["none","all","small"]).optional()}).strict(),bp=p({type:E(w.LOGO),fieldName:h(),defaults:Ut.optional()}).strict(),ur=p({type:E(w.LOGO),label:_,colors:A(ue).optional(),sizes:A(he().min(1,{message:"must be at least 1"})).optional(),defaults:Ut.optional()}).strict(),Ap=p({value:h().optional(),label:_.optional()}).strict(),Ft=p({type:E(w.SELECTBOX),value:h().optional()}).strict(),Np=p({type:E(w.SELECTBOX),fieldName:h(),defaults:Ft.optional()}).strict(),dr=p({type:E(w.SELECTBOX),label:_,description:_.optional(),options:A(Ap).optional(),defaults:Ft.optional()}).strict(),Mt=p({type:E(w.TEXT),font:vn.optional(),size:ks.optional(),bold:v().optional(),italic:v().optional(),color:ue.optional(),visible:v().optional()}).strict(),$p=p({type:E(w.TEXT),fieldName:h(),defaults:Mt.optional()}).strict(),pr=p({type:E(w.TEXT),label:_,colors:A(Ls).optional(),sizes:A(he().min(1,{message:"must be at least 1"})).optional(),enableAlphaColor:v().optional(),enableAutoColor:v().optional(),hideVisibleToggle:v().optional(),hideSize:v().optional(),defaults:Mt.optional()}).strict(),Gt=p({type:E(w.TOGGLE),enabled:v().optional()}).strict(),Lp=p({type:E(w.TOGGLE),fieldName:h(),defaults:Gt.optional()}).strict(),fr=p({type:E(w.TOGGLE),label:_,defaults:Gt.optional()}).strict();function Dp(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_SHOWCASE_ITEMS_REQUIRED")}function kp(e,t){for(const[n,o]of Object.entries(e))Object.keys(o.editors).length===0&&t.at(["items",n,"editors"]).addIssue("ACCORDION_SHOWCASE_ITEM_EDITORS_REQUIRED",n)}function Pp(e,t,n){Object.keys(e).length===0&&n.at("editors").addIssue("ACCORDION_ITEM_EDITORS_REQUIRED",t)}function zp(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_ITEMS_REQUIRED")}function jp(e,t){for(const[n,o]of Object.entries(e))o.positionFieldName||t.at(["items",n,"positionFieldName"]).addIssue("ACCORDION_ITEM_POSITION_FIELD_REQUIRED",n)}function Up(e,t){const n=Object.values(e).map(o=>o.positionFieldName).filter(Boolean);new Set(n).size!==n.length&&t.at("items").addIssue("ACCORDION_DUPLICATE_POSITION_FIELD_NAME")}const hr=p({type:E(w.ACCORDION)}).strict(),Fp=q("type",[Mt,Dt,zt,Gt,Ft,Lt,kt,Ut,Pt,jt]),Mp=p({editors:Z(h(),Fp)}).strict(),Gp=p({type:E(w.ACCORDION),items:Z(h(),Mp)}).strict().superRefine((e,t)=>{const n=x(t);Dp(e.items,n),kp(e.items,n)}),xp=p({type:E(w.ACCORDION),fieldName:h(),defaults:hr.optional()}).strict(),Bp=q("type",[pr,rr,cr,fr,dr,sr,ir,ur,ar,lr]),Zp=p({label:_,positionFieldName:h().optional(),editors:Z(h(),Bp)}).strict().superRefine((e,t)=>{Pp(e.editors,e.label,x(t))}),Hp=p({type:E(w.ACCORDION),sortable:v().optional(),items:Z(h(),Zp),defaults:hr.optional()}).strict().superRefine((e,t)=>{const n=x(t);zp(e.items,n),e.sortable===!0&&(jp(e.items,n),Up(e.items,n))}),mr=q("type",[Ln,Pn,bn,Cn,zn,kn,nr,or,er,Nn,$n,pp,Dn,An]),Er=q("type",[Mt,Dt,zt,Gt,Ft,Lt,kt,Ut,Pt,Gp,jt]),Vp=p({showcaseId:h(),blockName:h(),previewImage:$t,content:Z(h(),mr),design:Z(h(),Er),layoutId:h().optional()}).strict(),Wp=p({blockName:h(),content:Z(h(),mr).optional(),design:Z(h(),Er).optional(),layoutId:h().optional()}).strict();function Yp(e,t){Rn(e.type)&&(e.sections.length!==1?t.at("sections").addIssue("TEMPLATE_PAGE_SINGLE_SECTION_REQUIRED",e.type):e.sections[0]?.type!=="store"&&t.at(["sections",0,"type"]).addIssue("TEMPLATE_PAGE_STORE_SECTION_REQUIRED",e.type))}function Kp(e,t){Rn(e.type)&&e.sections.length===0&&t.at("sections").addIssue("TEMPLATE_PAGE_SECTIONS_REQUIRED"),e.sections.forEach((n,o)=>{Rn(e.type)||n.type==="store"&&t.at(["sections",o,"type"]).addIssue("TEMPLATE_PAGE_NO_STORE_SECTIONS",e.type),n.type==="default"&&n.id&&(n.id==="header"||n.id==="footer")&&t.at(["sections",o,"id"]).addIssue("REQUIRED_PAGE_SECTION_TYPE")})}function Jp(e,t){e.type==="CUSTOM"?e.metadata||t.at("metadata").addIssue("TEMPLATE_PAGE_CUSTOM_METADATA_REQUIRED"):e.metadata!==void 0&&t.at("metadata").addIssue("TEMPLATE_PAGE_METADATA_NOT_ALLOWED",e.type)}const Xp=new RegExp(`^(${Object.values(Jd).join("|")})(_\\d{3})?$`),Qp=h().regex(Xp,"id must match pattern: [default_section_name] or [default_section_name]_XXX where XXX is three digits"),qp=h().regex(new RegExp("\\d{3}"),"showcase_id must be a three digit string"),gr=p({type:E("default"),id:Qp,showcase_id:qp.optional()}).strict(),jn=p({type:E("custom"),id:h(),showcase_id:h().optional(),showcase_overrides:Wp.optional(),category:Qd.optional()}).strict(),ef=p({type:E("store"),id:h().optional()}).strict(),tf=q("type",[gr,jn,ef]),nf=p({title:h()}).strict(),of=p({metadata:nf.optional(),sections:A(tf)}).strict(),sf=of.safeExtend({type:Wd,id:h().min(1,{message:"id is required"})}).strict().superRefine((e,t)=>{const n=x(t);Kp(e,n),Yp(e,n),Jp(e,n)}),_r=p({name:h().min(2,{message:"name must be at least 2 characters"}).max(60,{message:"name must be at most 60 characters"}),description:h().min(2,{message:"description must be at least 2 characters"}).max(150,{message:"description must be at most 150 characters"}),preview_url:fs({message:"preview_url must be a valid URL"}).regex(/^(https?):\/\/([^.]+?\.)?(company\.site|ecwid\.qa)($|\/[A-Za-z0-9\-._~:/?#\[\]@!$&'()*+,;=]*)?$/,"preview_url must match pattern: (https?)://([^.]+?\\.)?(company\\.site|ecwid\\.qa)(...)?").optional(),cover_image:$t,categories:A(xd).refine(e=>new Set(e).size===e.length,{message:"categories must contain unique items"}).optional()}).strict(),rf=gr.extend({id:h()}),yr=q("type",[rf,jn]),af=p({metadata:_r,header:yr,footer:yr}).strict(),cf=p({id:h().min(1,{message:"id is required"}),assets:wn.array().optional(),configuration:af,pages:A(sf)}).strict(),xt=2097152,Bt=512e3;function Se(e,t=2){if(!+e)return"0 Bytes";const n=1024,o=t<0?0:t,s=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],r=Math.floor(Math.log(e)/Math.log(n));return`${parseFloat((e/n**r).toFixed(o))} ${s[r]}`}const lf={menu:{type:O.NAVIGATION_MENU},logo:{type:O.LOGO}},uf={logo:{type:"LOGO",label:"$label.logo.label",colors:["#FFFFFF66","#0000004D","#00000099","#64C7FF66","#F9947266","#C794CD66","#FFD17466"],sizes:[18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60],defaults:{type:"LOGO",font:"global.fontFamily.body",size:40,bold:!0,italic:!1,color:"#313131",visible:!0,spacing:2,capitalization:"all",frame:{visible:!0,width:3,color:"#313131"}}}};function Sr(e){switch(e){case Ae.HEADER:return lf;default:return{}}}function Tr(e){switch(e){case Ae.HEADER:return uf;default:return{}}}function Or({validationType:e,sectionType:t}){switch(e){case ot.CONTENT:return Sr(t);case ot.DESIGN:return Tr(t);default:return{}}}const df=jn.extend({id:h().min(1,{message:"section id is required"})}),pf=p({metadata:_r,sections:A(df).min(1,{message:"sections must contain at least one section"}).max(20,{message:"sections must contain at most 20 sections"})}).strict().superRefine((e,t)=>{e.metadata.name.trim().length===0&&x(t).at(["collection","metadata","name"]).addIssue("REQUIRED_COLLECTION_NAME")}),ff=p({id:h().min(1,{message:"id is required"}),descriptor:pf}).strict(),hf=q("type",[Vs,Ks,xs,Ps,Js,Ys,mp,gp,_p,Ep,Zs,Hs,Ws,Bs]),Un=Z(h(),hf),mf=q("type",[pr,rr,cr,fr,dr,sr,ir,ur,ar,Hp,lr]),Fn=Z(h(),mf),Ef=q("type",[$p,Sp,Ip,Lp,Np,yp,Tp,bp,Op,Cp,xp]),Mn=p({layoutId:h(),layoutIcon:Kd.optional(),selectedContentSettings:A(h()),selectedDesignSettings:A(Ef)}).strict(),gf=h().regex(qd,X.VALID_LANGUAGE_CODE()),Zt=Z(gf,Z(_,h()));function Ir(e,t,n){if(!e||Object.keys(t).length===0)return;const o=Object.entries(t),s=o.map(([,{type:i}])=>i),r=Object.values(e).map(({type:i})=>i);Object.entries(e).forEach(([i,a])=>{const c=t[i];c&&"type"in c&&a.type!==c.type&&n.at(i).addIssue("MANDATORY_SETTING_TYPE_MISMATCH",a.type,i,c.type)}),Object.entries(e).forEach(([i,a])=>{const c=o.find(([,{type:l}])=>l===a.type)?.[0];c&&i!==c&&n.at(i).addIssue("MANDATORY_SETTING_NAME_MISMATCH",i,a.type,c)}),new Set(r.filter(i=>s.includes(i))).forEach(i=>{if(r.filter(a=>a===i).length>1){const a=o.findLast(([,{type:c}])=>c===i)?.[0];n.at(a).addIssue("DUPLICATED_MANDATORY_SETTING",i)}})}function wr(e,t,n){zs(e,t,n)}function vr(e,t,n){if(e.type!==O.DECK||t.type!==O.DECK)return;const o=t.cards?.defaultCardContent?.settings,s=e.cards;!o||!Array.isArray(s)||s.forEach((r,i)=>{r.settings&&Object.entries(r.settings).forEach(([a,c])=>{const l=o[a],d=n.at(["cards",i,"settings",a]);if(!l){d.addIssue("INVALID_DECK_CARD_SETTING",a);return}if(c.type!==l.type){d.addIssue("SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH",a,c.type,l.type);return}c.type===O.DECK&&l.type===O.DECK&&vr(c,l,d)})})}function _f(e,t,n){e.content&&Object.entries(e.content).forEach(([o,s])=>{const r=n.at(["content",o]),i=t[o];if(!i){r.addIssue("INVALID_SHOWCASE_CONTENT_ELEMENT",o);return}if(s.type!==i.type){r.addIssue("SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH",o,s.type,i.type);return}if(s.type===O.SELECTBOX&&i.type===O.SELECTBOX){const a=i,c=s;a.options&&c.value!==void 0&&(new Set(a.options.map(l=>l.value)).has(c.value)||r.addIssue("INVALID_SELECTBOX_OPTION",c.value,o))}s.type===O.DECK&&vr(s,i,r)})}function yf(e,t,n){e.design&&Object.entries(e.design).forEach(([o,s])=>{const r=n.at(["design",o]),i=t[o];if(!i){r.addIssue("INVALID_SHOWCASE_DESIGN_ELEMENT",o);return}s.type!==i.type&&r.addIssue("SHOWCASE_DESIGN_ELEMENT_TYPE_MISMATCH",o,s.type,i.type)})}function Sf(e,t){Object.entries(e).flatMap(([n,o])=>{switch(o.type){case w.ACCORDION:return Object.entries(o.items).flatMap(([s,r])=>Object.keys(r.editors).map(i=>({name:i,path:[n,"items",s,"editors",i]})));default:return[{name:n,path:[n]}]}}).filter(({name:n},o,s)=>s.findIndex(r=>r.name===n)<o).forEach(({path:n})=>t.at(n).addIssue("DUPLICATE_DESIGN_EDITOR_NAME"))}function Tf(e,t,n){e.layoutId&&((t||[]).some(o=>o.layoutId===e.layoutId)||n.at("layoutId").addIssue("SHOWCASE_LAYOUT",e.layoutId))}function Of(e,t){const n=new Set;e.forEach((o,s)=>{if(n.has(o.showcaseId)){t.at([s,"showcaseId"]).addIssue("DUPLICATE_SHOWCASE_ID",o.showcaseId);return}n.add(o.showcaseId)})}function Cr(e,t,n){for(const[o,s]of Object.entries(e)){const r=s;if(r.type===O.IMAGE){const i=t[o];if(i?.type===w.IMAGE){const a=r.static??!1,c=i.static??!1;a!==c&&n.at(o).addIssue("IMAGE_EDITOR_STATIC_MISMATCH",o)}}else if(r.type===O.DECK){const i=r;i.cards?.defaultCardContent?.settings&&Cr(i.cards.defaultCardContent.settings,t,n.at([o,"cards","defaultCardContent","settings"]))}}}function If(e,t,n){t>xt&&n.at(z.basename(e)).addIssue("REQUIRED_SECTION_ASSET",Se(t),Se(xt))}function wf(e,t){e>Bt&&t.addIssue("REQUIRED_SERVER_SIZE",Se(e),Se(Bt))}const vf=p({id:h(),type:Pd,name:h(),content:Un,design:Fn,layout:A(Mn).optional(),showcase:A(Vp),translationsSettings:Zt.optional(),translationsShowcases:Zt.optional(),assets:wn.array().optional(),server:$s,previewCount:he().optional()}).strict().superRefine((e,t)=>{const n=x(t),o=Or({validationType:ot.CONTENT,sectionType:e.type}),s=Or({validationType:ot.DESIGN,sectionType:e.type});Ir(e.content,o,n.at("content")),Ir(e.design,s,n.at("design")),Cr(e.content,e.design,n.at("content")),Sf(e.design,n.at("design")),e.assets&&e.assets.forEach(i=>{If(i.path,i.size,n.at("assets"))}),wf(e.server.size,n.at("server"));const r=e.assets?.map(i=>i.path)??[];wr(e.content,r,n.at("content")),Of(e.showcase,n.at("showcase")),e.showcase.forEach((i,a)=>{const c=n.at(["showcase",a]);wr(i,r,c),_f(i,e.content,c),yf(i,e.design,c),Tf(i,e.layout,c)})}),Cf=p({translations:Zt.optional()}).strict(),Rf=U(["products","category","product"]),bf=p({id:h(),sectionId:h(),assets:wn.array().optional(),content:Un.optional(),design:Fn.optional(),translationsSettings:Zt.optional(),layouts:Mn.array().optional()}).strict().superRefine((e,t)=>{const n=x(t);st.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,st.options.join(", ")),e.assets&&e.assets.forEach(o=>{o.size>xt&&n.at(["assets",z.basename(o.path)]).addIssue("REQUIRED_SECTION_ASSET",Se(o.size),Se(xt))})});p({id:h(),sectionId:st,pageId:Rf,content:Un.optional(),design:Fn.optional(),layouts:Mn.array().optional()}).strict();const Af=p({id:h(),sectionId:h(),layoutId:h(),server:$s}).strict().superRefine((e,t)=>{const n=x(t);st.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,st.options.join(", ")),e.server.size>Bt&&n.at("server").addIssue("REQUIRED_SERVER_SIZE",Se(e.server.size),Se(Bt))});function Nf(e,t,n){if(e){if(e.type==="default")e.id!=="header"&&n.at("id").addIssue("REQUIRED_HEADER_ID");else if(e.type==="custom"&&e.id){const o=t.find(s=>s.id===e.id);o?(o.type!=="HEADER"&&n.at("id").addIssue("REQUIRED_CUSTOM_HEADER_TYPE",e.id),e.showcase_id&&((o.showcase||[]).some(s=>s.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))):n.at("id").addIssue("REQUIRED_CUSTOM_HEADER",e.id)}}}function $f(e,t,n){if(e){if(e.type==="default")e.id!=="footer"&&n.at("id").addIssue("REQUIRED_FOOTER_ID");else if(e.type==="custom"&&e.id){const o=t.find(s=>s.id===e.id);o?(o.type!=="FOOTER"&&n.at("id").addIssue("REQUIRED_CUSTOM_FOOTER_TYPE",e.id),e.showcase_id&&((o.showcase||[]).some(s=>s.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))):n.at("id").addIssue("REQUIRED_CUSTOM_FOOTER",e.id)}}}function Lf(e,t,n){if(!e)return;const o=n.at(["showcase_overrides"]);["content","design"].forEach(r=>{const i=e[r];if(i){const a=t[r]||{};Object.keys(i).forEach(c=>{if(!(c in a)){const l=r==="content"?"SHOWCASE_OVERRIDE_CONTENT":"SHOWCASE_OVERRIDE_DESIGN";o.at([r,c]).addIssue(l,c)}})}}),e.layoutId&&((t.layout||[]).some(r=>r.layoutId===e.layoutId)||o.at(["layoutId"]).addIssue("SHOWCASE_OVERRIDE_LAYOUT",e.layoutId));const s=t.assets?.map(r=>r.path)??[];e.content&&zs(e.content,s,o.at(["content"]))}function Rr(e,t,n,o=!1){if(!e.id)return;const s=t.find(r=>r.id===e.id);if(!s){n.at("id").addIssue("REQUIRED_PAGE_SECTION",e.id);return}!o&&(s.type==="HEADER"||s.type==="FOOTER")&&n.at("id").addIssue("REQUIRED_PAGE_SECTION_TYPE"),Lf(e.showcase_overrides,s,n),e.showcase_id&&((s.showcase||[]).some(r=>r.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))}function Df(e,t,n,o){e.id&&(n.some(s=>s.sectionId===t.type.toLowerCase()&&s.id===e.id)||o.at("id").addIssue("REQUIRED_STORE_LAYOUT",e.id,t.type.toLowerCase()))}const kf=p({version:h(),name:h(),shared:Cf.optional(),sections:A(vf),templates:A(cf),layouts:A(bf),slots:A(Af),collections:A(ff),compressionEnabled:v(),externalizationEnabled:v(),vueVersion:h(),openSource:v().optional()}).strict().superRefine((e,t)=>{e.templates.forEach((n,o)=>{const s=x(t).at(["templates",o]);Nf(n.configuration.header,e.sections,s.at(["configuration","header"])),$f(n.configuration.footer,e.sections,s.at(["configuration","footer"])),n.pages.forEach((r,i)=>{const a=s.at(["pages",i]);r.sections.forEach((c,l)=>{const d=a.at(["sections",l]);c.type==="custom"?Rr(c,e.sections,d):c.type==="store"&&Df(c,r,e.layouts,d)})})}),e.collections.forEach((n,o)=>{n.descriptor.sections.forEach((s,r)=>{const i=x(t).at(["collections",o,"sections",r]);Rr(s,e.sections,i,!0)})})});_e({customError:Vd});const f={error:e=>console.log(Ii(e)),warn:e=>console.log(Oi(e)),info:e=>console.log(ce(e))},Pf="dist",zf="dist/shared",me="dist/sections",Gn="dist/headers",xn="dist/footers",Te="dist/templates",Ze="layouts",br="preview",Q=`dist/${Ze}`,it="dist/collections",Ar="dist/manifest.json",jf=[me,Gn,xn,Te,Q];function Ht(e){return!!e}function $e(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}const Uf="Resource name can only contain alphanumeric characters, dashes, and underscores";function Ff(e){if(typeof e=="string"||typeof e=="number"){const t=/^[a-zA-Z0-9_-]+$/.test(e.toString());if(t)return{isValid:t,errorMessage:null}}return{isValid:!1,errorMessage:Uf}}function Mf(e){return e===!0?!0:typeof e=="string"&&e.trim().length===0}function Gf(e){return z.parse(e).name}function xf(e){return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function Vt(){const e=await ln(S(process.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}function Bf(e){return e.includes(`
40
- `)}function Zf(e,t,n){return e.split(`
41
- `).map((o,s)=>s>=n?t+o:o).join(`
42
- `)}function Le(e,t){const n=[];if(e instanceof Eo){e.response?.status!==void 0&&n.push(` HTTP Status Code: ${e.response.status}`);const r=e.response?.data;if(r?.errorCode&&n.push(` Error Code: ${r.errorCode}`),r?.errorMessage){const i=Bf(r.errorMessage)?Zf(r.errorMessage," ",1):r.errorMessage;n.push(` Error Message: ${i}`)}}const o=n.length>0?n.join(`
43
- `):e?.message??"Unknown error";if(!t||t.length===0)return o;const s=n.length>0?`
44
- `:" ";return`${t}${s}${o}`}function Bn(e,t){return Object.keys(e).reduce((n,o)=>{const s=e[o],r=t[o];return $e(s)&&$e(r)?n[o]=Bn(s,r):n[o]=s,n},{...t})}function Hf({contentSettings:e,sectionType:t}){const n=Sr(t);return Bn(e,n)}function Vf({designSettings:e,sectionType:t}){const n=Tr(t);return Bn(e,n)}async function se(e){return(await import(mo(e).href+`?t=${Date.now()}`)).default}function Zn(e){if(e!==void 0)return e.startsWith("global.")?{type:"GLOBAL_FONT",font:e}:{type:"PRESET_FONT",font:e}}function de(e){if(e===void 0)return;if(e.startsWith("global."))return{type:"GLOBAL_COLOR",raw:e};const t=Ni(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function Nr(e){if(e!==void 0)return typeof e=="string"&&e.startsWith("global.")?{type:"GLOBAL_TEXT_SIZE",size:e}:{type:"NUMERIC_TEXT_SIZE",size:Number(e)}}function Wf(e){if(e!==void 0)return{...e,color:de(e.color)}}function De(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function Yf(e){if(e!==void 0)switch(e){case In.COLOR:return"solid";case In.GRADIENT:return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(In)}`)}}function Kf({style:e,color:t}){const n=Array.isArray(t)?t:[t,t];return{background:{type:Yf(e),solid:{color:de(n.at(0))},gradient:{fromColor:de(n.at(0)),toColor:de(n.at(1))}}}}function Jf(e){if(e!==void 0)switch(e){case"SOLID":return"solid-button";case"OUTLINE":return"outline-button";case"TEXT":return"text-link";default:throw new Error(`Unknown button appearance: ${e}. Right options: ${Object.keys(Ad)}`)}}function Xf(e){if(e!==void 0)switch(e){case"SMALL":return"small";case"MEDIUM":return"medium";case"LARGE":return"large";default:throw new Error(`Unknown button size: ${e}. Right options: ${Object.keys($d)}`)}}function Qf(e){if(e!==void 0)switch(e){case"ROUND_CORNER":return"round-corner";case"RECTANGLE":return"rectangle";case"PILL":return"pill";default:throw new Error(`Unknown button shape: ${e}. Right options: ${Object.keys(Dd)}`)}}function qf(e){const t=Jf(e.appearance),n=Xf(e.size),o=Qf(e.shape),s=Zn(e.font),r=de(e.color),i=e.visible;return De({appearance:t,size:n,style:o,font:s,color:r,visible:i})}function eh(e){const t=de(e.color);return De({color:t})}function th(e){if(e!==void 0)switch(e){case bt.COLOR:return"solid";case bt.GRADIENT:return"gradient";case bt.NONE:return"none";default:throw new Error(`Unknown image overlay type: ${e}. Right options: ${Object.keys(bt)}`)}}function nh(e){const t=e.color,n=Array.isArray(t)?t:[t,t],o=e.visible,s={type:th(e.overlay),solid:{color:de(n.at(0))},gradient:{fromColor:de(n.at(0)),toColor:de(n.at(1))}};return De({overlay:s,visible:o})}function oh(e){const t=Zn(e.font),n=de(e.color),o=Nr(e.size),s=e.bold,r=e.italic,i=e.spacing,a=e.capitalization,c=e.visible;return De({font:t,color:n,size:o,frame:Wf(e.frame),bold:s,italic:r,spacing:i,capitalization:a,visible:c})}function sh(e){const t=e.value;return De({value:t})}function rh(e){const t=Zn(e.font),n=de(e.color),o=Nr(e.size),s=e.bold,r=e.italic,i=e.visible;return De({font:t,color:n,size:o,bold:s,italic:r,visible:i})}function ih(e){const t=e.enabled;return De({enabled:t})}function Hn(e,t){if(t.defaults===void 0)return;let n={};switch(e){case te.TEXT:{n=rh(t.defaults);break}case te.BUTTON:{n=qf(t.defaults);break}case te.IMAGE:{n=nh(t.defaults);break}case te.BACKGROUND:{n=Kf(t.defaults);break}case te.COLOR_PICKER:{n=eh(t.defaults);break}case te.LOGO:{n=oh(t.defaults);break}case te.SELECTBOX:{n=sh(t.defaults);break}case te.TOGGLE:{n=ih(t.defaults);break}case te.DIVIDER:case te.INFO:break;case te.ACCORDION:return t.defaults;default:throw new Error(`Unknown design editor type: ${e}`)}return n}function $r(e){const t={};return Object.keys(e).forEach(n=>{const o=e[n],s=o.type;if(s===te.ACCORDION){const i=Object.fromEntries(Object.entries(o.items).map(([a,c])=>[a,{...c,editors:$r(c.editors)}]));t[n]={...o,items:i};return}const r=Hn(s,o);r&&o.defaults?t[n]={...o,defaults:r}:t[n]=o}),t}function ah(e){return e===void 0?e:e.map(t=>{if(t.type!==void 0&&t.defaults!==void 0&&t.fieldName!==void 0){const n={...Hn(t.type,t)??t.defaults,type:t.defaults.type??t.type};return{type:t.type,fieldName:t.fieldName,defaults:n}}return t})}function Vn(e){if(e===void 0)return;const t={};return Object.keys(e).forEach(n=>{const o=e[n],s=o.type;if(s===te.ACCORDION){const i=Object.fromEntries(Object.entries(o.items).map(([a,c])=>[a,{...c,editors:Vn(c.editors)??c.editors}]));t[n]={type:o.type,items:i};return}const r=Hn(s,{defaults:o});r!==void 0?t[n]={...o,...r,type:o.type}:t[n]=o}),t}function ch(e,t){if(!t)return;const n=e[t];return n===void 0?{en:t}:n}function lh(e){const t={};for(const n in e){const o=e[n];for(const s in o){const r=t[s],i=o[s];if(r===void 0){const a={};a[n]=i,t[s]=a}else r[n]=i}}return t}function uh(e){return e.every(t=>t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")}function He(e,t){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return uh(e)?e:e.map(s=>He(s,t));const n=e,o={};for(const s in n){const r=n[s];typeof r=="string"&&r.startsWith("$")?o[s]=ch(t,r):typeof r=="object"&&r!==null?o[s]=He(r,t):o[s]=r}return o}async function at(e){return e?lh(e):{}}async function dh(e,t=me){const n=S(process.cwd(),`${t}/${e}/js/settings/translations.mjs`);return await se(n)}async function Wt(e,t=me){const n=S(process.cwd(),`${t}/${e}/js/showcases/translations.mjs`);return await se(n)}async function ph(e,t){const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/translations.mjs`);if(V(n))return await se(n)}async function Wn(e,t,n){const o=n?Hf({contentSettings:e,sectionType:n}):e;return He(o,t)}async function fh(e,t=me){try{const n=S(F.cwd(),`${t}/${e}/js/settings/content.mjs`),o=await se(n);return Be(o)}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function Yn(e,t,n){const o=n?Vf({designSettings:e,sectionType:n}):e,s=$r(o);return He(s,t)}async function hh(e,t=me){try{const n=S(F.cwd(),`${t}/${e}/js/settings/design.mjs`),o=await se(n);return Be(o)}catch(n){const o=n;throw new Error(`Design settings is invalid or undefined. Error ${o.stack}`)}}async function mh(e,t){return Promise.all(e.map(async n=>{const o=n.design?Vn(n.design):void 0,s={...n,design:o??n.design};return He(s,t)}))}async function Eh(e,t=me){try{const n=await I("*.mjs",{cwd:S(F.cwd(),`${t}/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(n.map(async o=>{const s=S(F.cwd(),`${t}/${e}/js/showcases/${o}`);return await se(s)}))}catch(n){throw new Error(`Showcases is invalid or undefined. Error ${n}`)}}async function Lr(e){return e?.map(t=>({...t,selectedDesignSettings:ah(t.selectedDesignSettings)??t.selectedDesignSettings}))??[]}async function gh(e,t=me){try{const n=S(F.cwd(),`${t}/${e}/js/settings/layout.mjs`);return V(n)?await se(n):[]}catch{throw new Error(`Layout descriptor for section [${e}] is either invalid or undefined`)}}function _h(e){let t={};const n=S(F.cwd(),`${br}/shared/analytics.json`);if(!V(n))return 0;try{const o=sn(n,"utf-8");t=JSON.parse(o)}catch(o){console.warn("Error processing analytics.json file",o)}return t[e]||0}const Ve={Server:0,Client:1,SectionAsset:4,PageTemplateDescriptor:6,TemplateAsset:7,SharedTranslation:13},Kn="https://blockbuster.ecwid.com",yh="/api/v1/custom-apps/resources/sections/upload",Sh="/api/v1/custom-apps/resources/templates/upload",Th="/api/v1/custom-apps/manifests/sections",Oh="/api/v1/custom-apps/manifests/templates",Ih=5,wh=3,vh=[R.Server,R.Client,R.ClientChunks,R.ClientAsset,R.Asset],Ch=[R.LayoutClient,R.LayoutAsset],Rh=[R.SlotServer,R.SlotClient,R.SlotClientChunks,R.SlotClientAsset],bh=[R.Dependency,R.TemplateAsset,R.SourceCode,R.CollectionAsset],We={DEFAULT:"Error while deploying:",ASSET_FILES_UPLOAD:"Error while uploading asset files:",MANIFEST_DEPLOYMENT:"Error while deploying manifest file:",DEPRECATED_VERSION_DEPLOYMENT:"You are using a non-supported version of crane. Please update to the latest crane version to continue.",INCORRECT_DISTRIBUTION_FOLDER:e=>`Distribution folder [${e}] is not found or has incorrect structure, please execute the build command first.`},Dr={catalog:"products",category:"category",product:"product"},kr=e=>Dr[e],Pr=e=>e in Dr;function Ah(e){return e.replace(/\\/g,"/")}function Nh(e){return e.replace(/^dist\/layouts\//,"").replace(/^layouts\//,"")}function Yt(e){return Nh(Ah(e))}function $h(e){const t=Yt(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,o]=t;if(!Pr(n))throw new Error(`Layout cannot be placed in a non-storefront section: ${n}`);const s=kr(n);return{id:o,sectionId:n,pageId:s}}async function Lh(e){return Promise.all(e.map(async t=>{const n=t.sectionId,o=kr(n),s=await at(t.translationsSettings),r=await Wn(t.content??{},s),i=await Yn(t.design??{},s),a=await Lr(t.layouts);return{id:t.id,sectionId:n,pageId:o,contentEditors:r,designEditors:i,layouts:a}}))}function Ye(e,t,...n){if(!e||!t)throw new Error(`Cannot build layout path. Invalid parameters - sectionId: "${e}", layoutId: "${t}"`);return`${Q}/${e}/${t}/${n.join("/")}`}const ct=(e=ye.SECTION)=>G[e].dist,lt={[R.Server]:{type:"server_js_compressed",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,sectionType:t})=>`${ct(t)}/${e}/js/main/server/`},[R.Client]:{type:"client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${ct(t)}/${e}/js/main/client/`},[R.ClientChunks]:{type:"client_js_chunks",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${ct(t)}/${e}/js/main/client/chunks/`,fileName:"*"},[R.ClientAsset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${ct(t)}/${e}/js/main/client/assets/`},[R.Asset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${ct(t)}/${e}/assets/`},[R.TemplateAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${Te}/assets/`},[R.Dependency]:{type:"dependencies",fileName:"package.json",isSingleton:!0,toPath:()=>{}},[R.SourceCode]:{type:"source_code",fileName:"source-code.zip",isSingleton:!0,toPath:()=>{}},[R.LayoutClient]:{type:"layout_client_js",fileName:"index.mjs",isSingleton:!0,toPath:({sectionId:e,layoutId:t})=>Ye(e,t,"")},[R.LayoutAsset]:{type:"layout_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t})=>Ye(e,t,"assets/")},[R.SlotServer]:{type:"slot_server_js",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ye(e,t,"slots",n,"js/main/server/")},[R.SlotClient]:{type:"slot_client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ye(e,t,"slots",n,"js/main/client/")},[R.SlotClientChunks]:{type:"slot_client_js_chunks",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ye(e,t,"slots",n,"js/main/client/chunks/")},[R.SlotClientAsset]:{type:"slot_client_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ye(e,t,"slots",n,"js/main/client/assets/")},[R.CollectionAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${it}/assets/`}};function Dh(e){return typeof e=="object"&&e!==null&&"version"in e&&typeof e.version=="string"}async function Jn(){const e=S(Et.cwd(),"package.json"),t=await ln(e),n=JSON.parse(t.toString());if(Dh(n))return n;throw new Error(`Package file located at path: ${e} does not contain a version field`)}const kh={layout:e=>e.layoutId,showcase:e=>e.showcaseId,templates:e=>{const t=e.id;return t?.includes("_")?t.substring(t.indexOf("_")+1):t}};function Ph(e,t){const n=kh[e];return n?n(t):t.id}const zh=new Set(["content","design"]);function Kt(e,t,n=0,o=[]){if(n>=t.length)return o;const s=t[n],r=t[n+1];if(typeof s=="string"&&typeof r=="number"&&$e(e)){const i=e[s],a=Array.isArray(i)?i[r]:void 0;if($e(a)){const c=Ph(s,a);return o.push(`${s}[${c||r}]`),Kt(a,t,n+2,o)}}if(typeof s=="string"&&typeof r=="string"&&zh.has(s)){o.push(`${s}[${r}]`);const i=$e(e)&&!Array.isArray(e)?e[s]:void 0,a=$e(i)&&!Array.isArray(i)?i[r]:void 0;return Kt(a,t,n+2,o)}return o.push(s),Kt($e(e)?e[s]:void 0,t,n+1,o)}function jh(e){const t=e.errors.map(o=>Kt(e.manifest,o.path).join(".")),n={path:Math.max(...t.map(o=>o.length),0),message:Math.max(...e.errors.map(o=>o.message.length),0)};e.errors.map((o,s)=>{const r=o.params?.errorMessageKey||"GENERAL_ISSUE";return`${t[s].padEnd(n.path," ")} | ${o.message.padEnd(n.message," ")} | ${r}`}).forEach(o=>f.error(o))}async function Uh(e){const t=kf.safeParse(e);return{manifest:e,errors:t.success?[]:t.error.issues}}const Fh=`Build successful:
39
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const a=i[1];if(t===i[0]){s(i);continue}if(e.external){const u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&e.reused==="ref"){s(i);continue}}}function dr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=i=>{const a=e.seen.get(i);if(a.ref===null)return;const c=a.def??a.schema,u={...c},d=a.ref;if(a.ref=null,d){o(d);const S=e.seen.get(d),O=S.schema;if(O.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(O)):Object.assign(c,O),Object.assign(c,u),i._zod.parent===d)for(const B in c)B==="$ref"||B==="allOf"||B in u||delete c[B];if(O.$ref&&S.def)for(const B in c)B==="$ref"||B==="allOf"||B in S.def&&JSON.stringify(c[B])===JSON.stringify(S.def[B])&&delete c[B]}const m=i._zod.parent;if(m&&m!==d){o(m);const S=e.seen.get(m);if(S?.schema.$ref&&(c.$ref=S.schema.$ref,S.def))for(const O in c)O==="$ref"||O==="allOf"||O in S.def&&JSON.stringify(c[O])===JSON.stringify(S.def[O])&&delete c[O]}e.override({zodSchema:i,jsonSchema:c,path:a.path??[]})};for(const i of[...e.seen.entries()].reverse())o(i[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const i=e.external.registry.get(t)?.id;if(!i)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(i)}Object.assign(r,n.def??n.schema);const s=e.external?.defs??{};for(const i of e.seen.entries()){const a=i[1];a.def&&a.defId&&(s[a.defId]=a.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?r.$defs=s:r.definitions=s);try{const i=JSON.parse(JSON.stringify(r));return Object.defineProperty(i,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ct(t,"input",e.processors),output:Ct(t,"output",e.processors)}},enumerable:!1,writable:!1}),i}catch{throw new Error("Error converting schema to JSON.")}}function Y(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return Y(o.element,n);if(o.type==="set")return Y(o.valueType,n);if(o.type==="lazy")return Y(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return Y(o.innerType,n);if(o.type==="intersection")return Y(o.left,n)||Y(o.right,n);if(o.type==="record"||o.type==="map")return Y(o.keyType,n)||Y(o.valueType,n);if(o.type==="pipe")return Y(o.in,n)||Y(o.out,n);if(o.type==="object"){for(const r in o.shape)if(Y(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(const r of o.options)if(Y(r,n))return!0;return!1}if(o.type==="tuple"){for(const r of o.items)if(Y(r,n))return!0;return!!(o.rest&&Y(o.rest,n))}return!1}const Yu=(e,t={})=>n=>{const o=ur({...n,processors:t});return F(e,o),lr(o,e),dr(o,e)},Ct=(e,t,n={})=>o=>{const{libraryOptions:r,target:s}=o??{},i=ur({...r??{},target:s,io:t,processors:n});return F(e,i),lr(i,e),dr(i,e)},Ku={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ju=(e,t,n,o)=>{const r=n;r.type="string";const{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(r.minLength=s),typeof i=="number"&&(r.maxLength=i),a&&(r.format=Ku[a]??a,r.format===""&&delete r.format,a==="time"&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?r.pattern=d[0].source:d.length>1&&(r.allOf=[...d.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Xu=(e,t,n,o)=>{const r=n,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.includes("int")?r.type="integer":r.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.minimum=d,r.exclusiveMinimum=!0):r.exclusiveMinimum=d),typeof s=="number"&&(r.minimum=s,typeof d=="number"&&t.target!=="draft-04"&&(d>=s?delete r.minimum:delete r.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.maximum=u,r.exclusiveMaximum=!0):r.exclusiveMaximum=u),typeof i=="number"&&(r.maximum=i,typeof u=="number"&&t.target!=="draft-04"&&(u<=i?delete r.maximum:delete r.exclusiveMaximum)),typeof c=="number"&&(r.multipleOf=c)},Qu=(e,t,n,o)=>{n.type="boolean"},qu=(e,t,n,o)=>{n.not={}},el=(e,t,n,o)=>{},tl=(e,t,n,o)=>{const r=e._zod.def,s=vo(r.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},nl=(e,t,n,o)=>{const r=e._zod.def,s=[];for(const i of r.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){const i=s[0];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),s.every(i=>typeof i=="boolean")&&(n.type="boolean"),s.every(i=>i===null)&&(n.type="null"),n.enum=s},ol=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},rl=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},sl=(e,t,n,o)=>{const r=n,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(r.minItems=i),typeof a=="number"&&(r.maxItems=a),r.type="array",r.items=F(s.element,t,{...o,path:[...o.path,"items"]})},il=(e,t,n,o)=>{const r=n,s=e._zod.def;r.type="object",r.properties={};const i=s.shape;for(const u in i)r.properties[u]=F(i[u],t,{...o,path:[...o.path,"properties",u]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{const d=s.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(r.required=Array.from(c)),s.catchall?._zod.def.type==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=F(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},al=(e,t,n,o)=>{const r=e._zod.def,s=r.inclusive===!1,i=r.options.map((a,c)=>F(a,t,{...o,path:[...o.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=i:n.anyOf=i},cl=(e,t,n,o)=>{const r=e._zod.def,s=F(r.left,t,{...o,path:[...o.path,"allOf",0]}),i=F(r.right,t,{...o,path:[...o.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];n.allOf=c},ul=(e,t,n,o)=>{const r=n,s=e._zod.def;r.type="object";const i=s.keyType,c=i._zod.bag?.patterns;if(s.mode==="loose"&&c&&c.size>0){const d=F(s.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});r.patternProperties={};for(const m of c)r.patternProperties[m.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=F(s.keyType,t,{...o,path:[...o.path,"propertyNames"]})),r.additionalProperties=F(s.valueType,t,{...o,path:[...o.path,"additionalProperties"]});const u=i._zod.values;if(u){const d=[...u].filter(m=>typeof m=="string"||typeof m=="number");d.length>0&&(r.required=d)}},ll=(e,t,n,o)=>{const r=e._zod.def,s=F(r.innerType,t,o),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=r.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},dl=(e,t,n,o)=>{const r=e._zod.def;F(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},pl=(e,t,n,o)=>{const r=e._zod.def;F(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},fl=(e,t,n,o)=>{const r=e._zod.def;F(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},hl=(e,t,n,o)=>{const r=e._zod.def;F(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},ml=(e,t,n,o)=>{const r=e._zod.def,s=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;F(s,t,o);const i=t.seen.get(e);i.ref=s},El=(e,t,n,o)=>{const r=e._zod.def;F(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0},pr=(e,t,n,o)=>{const r=e._zod.def;F(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},gl=l("ZodISODateTime",(e,t)=>{_c.init(e,t),P.init(e,t)});function _l(e){return Iu(gl,e)}const yl=l("ZodISODate",(e,t)=>{yc.init(e,t),P.init(e,t)});function Sl(e){return wu(yl,e)}const Tl=l("ZodISOTime",(e,t)=>{Sc.init(e,t),P.init(e,t)});function Ol(e){return vu(Tl,e)}const Il=l("ZodISODuration",(e,t)=>{Tc.init(e,t),P.init(e,t)});function wl(e){return Cu(Il,e)}const vl=(e,t)=>{$o.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>da(e,n)},flatten:{value:n=>la(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,mn,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,mn,2)}},isEmpty:{get(){return e.issues.length===0}}})},oe=l("ZodError",vl,{Parent:Error}),Cl=yn(oe),Rl=Sn(oe),bl=St(oe),Al=Tt(oe),Nl=ha(oe),$l=ma(oe),Ll=Ea(oe),Dl=ga(oe),kl=_a(oe),Pl=ya(oe),zl=Sa(oe),jl=Ta(oe),k=l("ZodType",(e,t)=>(D.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ct(e,"input"),output:Ct(e,"output")}}),e.toJSONSchema=Yu(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(we(t,{checks:[...t.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0}),e.with=e.check,e.clone=(n,o)=>ve(e,n,o),e.brand=()=>e,e.register=((n,o)=>(n.add(e,o),e)),e.parse=(n,o)=>Cl(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>bl(e,n,o),e.parseAsync=async(n,o)=>Rl(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>Al(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>Nl(e,n,o),e.decode=(n,o)=>$l(e,n,o),e.encodeAsync=async(n,o)=>Ll(e,n,o),e.decodeAsync=async(n,o)=>Dl(e,n,o),e.safeEncode=(n,o)=>kl(e,n,o),e.safeDecode=(n,o)=>Pl(e,n,o),e.safeEncodeAsync=async(n,o)=>zl(e,n,o),e.safeDecodeAsync=async(n,o)=>jl(e,n,o),e.refine=(n,o)=>e.check(Ad(n,o)),e.superRefine=n=>e.check(Nd(n)),e.overwrite=n=>e.check(Ge(n)),e.optional=()=>Tr(e),e.exactOptional=()=>gd(e),e.nullable=()=>Or(e),e.nullish=()=>Tr(Or(e)),e.nonoptional=n=>Id(e,n),e.array=()=>A(e),e.or=n=>cd([e,n]),e.and=n=>dd(e,n),e.transform=n=>wr(e,md(n)),e.default=n=>Sd(e,n),e.prefault=n=>Od(e,n),e.catch=n=>vd(e,n),e.pipe=n=>wr(e,n),e.readonly=()=>bd(e),e.describe=n=>{const o=e.clone();return tt.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){return tt.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return tt.get(e);const o=e.clone();return tt.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),fr=l("_ZodString",(e,t)=>{Tn.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Ju(e,o,r);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...o)=>e.check(Lu(...o)),e.includes=(...o)=>e.check(Pu(...o)),e.startsWith=(...o)=>e.check(zu(...o)),e.endsWith=(...o)=>e.check(ju(...o)),e.min=(...o)=>e.check(vt(...o)),e.max=(...o)=>e.check(ar(...o)),e.length=(...o)=>e.check(cr(...o)),e.nonempty=(...o)=>e.check(vt(1,...o)),e.lowercase=o=>e.check(Du(o)),e.uppercase=o=>e.check(ku(o)),e.trim=()=>e.check(Mu()),e.normalize=(...o)=>e.check(Uu(...o)),e.toLowerCase=()=>e.check(Fu()),e.toUpperCase=()=>e.check(Gu()),e.slugify=()=>e.check(xu())}),Ul=l("ZodString",(e,t)=>{Tn.init(e,t),fr.init(e,t),e.email=n=>e.check(ou(Ml,n)),e.url=n=>e.check(or(mr,n)),e.jwt=n=>e.check(Ou(ed,n)),e.emoji=n=>e.check(cu(Fl,n)),e.guid=n=>e.check(nr(hr,n)),e.uuid=n=>e.check(ru(Rt,n)),e.uuidv4=n=>e.check(su(Rt,n)),e.uuidv6=n=>e.check(iu(Rt,n)),e.uuidv7=n=>e.check(au(Rt,n)),e.nanoid=n=>e.check(uu(Gl,n)),e.guid=n=>e.check(nr(hr,n)),e.cuid=n=>e.check(lu(xl,n)),e.cuid2=n=>e.check(du(Bl,n)),e.ulid=n=>e.check(pu(Zl,n)),e.base64=n=>e.check(yu(Xl,n)),e.base64url=n=>e.check(Su(Ql,n)),e.xid=n=>e.check(fu(Hl,n)),e.ksuid=n=>e.check(hu(Vl,n)),e.ipv4=n=>e.check(mu(Wl,n)),e.ipv6=n=>e.check(Eu(Yl,n)),e.cidrv4=n=>e.check(gu(Kl,n)),e.cidrv6=n=>e.check(_u(Jl,n)),e.e164=n=>e.check(Tu(ql,n)),e.datetime=n=>e.check(_l(n)),e.date=n=>e.check(Sl(n)),e.time=n=>e.check(Ol(n)),e.duration=n=>e.check(wl(n))});function h(e){return nu(Ul,e)}const P=l("ZodStringFormat",(e,t)=>{$.init(e,t),fr.init(e,t)}),Ml=l("ZodEmail",(e,t)=>{uc.init(e,t),P.init(e,t)}),hr=l("ZodGUID",(e,t)=>{ac.init(e,t),P.init(e,t)}),Rt=l("ZodUUID",(e,t)=>{cc.init(e,t),P.init(e,t)}),mr=l("ZodURL",(e,t)=>{lc.init(e,t),P.init(e,t)});function Er(e){return or(mr,e)}const Fl=l("ZodEmoji",(e,t)=>{dc.init(e,t),P.init(e,t)}),Gl=l("ZodNanoID",(e,t)=>{pc.init(e,t),P.init(e,t)}),xl=l("ZodCUID",(e,t)=>{fc.init(e,t),P.init(e,t)}),Bl=l("ZodCUID2",(e,t)=>{hc.init(e,t),P.init(e,t)}),Zl=l("ZodULID",(e,t)=>{mc.init(e,t),P.init(e,t)}),Hl=l("ZodXID",(e,t)=>{Ec.init(e,t),P.init(e,t)}),Vl=l("ZodKSUID",(e,t)=>{gc.init(e,t),P.init(e,t)}),Wl=l("ZodIPv4",(e,t)=>{Oc.init(e,t),P.init(e,t)}),Yl=l("ZodIPv6",(e,t)=>{Ic.init(e,t),P.init(e,t)}),Kl=l("ZodCIDRv4",(e,t)=>{wc.init(e,t),P.init(e,t)}),Jl=l("ZodCIDRv6",(e,t)=>{vc.init(e,t),P.init(e,t)}),Xl=l("ZodBase64",(e,t)=>{Cc.init(e,t),P.init(e,t)}),Ql=l("ZodBase64URL",(e,t)=>{bc.init(e,t),P.init(e,t)}),ql=l("ZodE164",(e,t)=>{Ac.init(e,t),P.init(e,t)}),ed=l("ZodJWT",(e,t)=>{$c.init(e,t),P.init(e,t)}),gr=l("ZodNumber",(e,t)=>{xo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Xu(e,o,r),e.gt=(o,r)=>e.check(sr(o,r)),e.gte=(o,r)=>e.check(wn(o,r)),e.min=(o,r)=>e.check(wn(o,r)),e.lt=(o,r)=>e.check(rr(o,r)),e.lte=(o,r)=>e.check(In(o,r)),e.max=(o,r)=>e.check(In(o,r)),e.int=o=>e.check(he(o)),e.safe=o=>e.check(he(o)),e.positive=o=>e.check(sr(0,o)),e.nonnegative=o=>e.check(wn(0,o)),e.negative=o=>e.check(rr(0,o)),e.nonpositive=o=>e.check(In(0,o)),e.multipleOf=(o,r)=>e.check(ir(o,r)),e.step=(o,r)=>e.check(ir(o,r)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function bt(e){return Ru(gr,e)}const td=l("ZodNumberFormat",(e,t)=>{Lc.init(e,t),gr.init(e,t)});function he(e){return bu(td,e)}const nd=l("ZodBoolean",(e,t)=>{Dc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Qu(e,n,o)});function v(e){return Au(nd,e)}const od=l("ZodUnknown",(e,t)=>{kc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>el()});function _r(){return Nu(od)}const rd=l("ZodNever",(e,t)=>{Pc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>qu(e,n,o)});function sd(e){return $u(rd,e)}const id=l("ZodArray",(e,t)=>{zc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>sl(e,n,o,r),e.element=t.element,e.min=(n,o)=>e.check(vt(n,o)),e.nonempty=n=>e.check(vt(1,n)),e.max=(n,o)=>e.check(ar(n,o)),e.length=(n,o)=>e.check(cr(n,o)),e.unwrap=()=>e.element});function A(e,t){return Bu(id,e,t)}const ad=l("ZodObject",(e,t)=>{Uc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>il(e,n,o,r),b(e,"shape",()=>t.shape),e.keyof=()=>U(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:_r()}),e.loose=()=>e.clone({...e._zod.def,catchall:_r()}),e.strict=()=>e.clone({...e._zod.def,catchall:sd()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>sa(e,n),e.safeExtend=n=>ia(e,n),e.merge=n=>aa(e,n),e.pick=n=>oa(e,n),e.omit=n=>ra(e,n),e.partial=(...n)=>ca(Sr,e,n[0]),e.required=(...n)=>ua(Ir,e,n[0])});function p(e,t){const n={type:"object",shape:e??{},..._(t)};return new ad(n)}const yr=l("ZodUnion",(e,t)=>{Wo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>al(e,n,o,r),e.options=t.options});function cd(e,t){return new yr({type:"union",options:e,..._(t)})}const ud=l("ZodDiscriminatedUnion",(e,t)=>{yr.init(e,t),Mc.init(e,t)});function q(e,t,n){return new ud({type:"union",options:t,discriminator:e,..._(n)})}const ld=l("ZodIntersection",(e,t)=>{Fc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>cl(e,n,o,r)});function dd(e,t){return new ld({type:"intersection",left:e,right:t})}const pd=l("ZodRecord",(e,t)=>{Gc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ul(e,n,o,r),e.keyType=t.keyType,e.valueType=t.valueType});function Z(e,t,n){return new pd({type:"record",keyType:e,valueType:t,..._(n)})}const vn=l("ZodEnum",(e,t)=>{xc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,r,s)=>tl(e,o,r),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(o,r)=>{const s={};for(const i of o)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new vn({...t,checks:[],..._(r),entries:s})},e.exclude=(o,r)=>{const s={...t.entries};for(const i of o)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new vn({...t,checks:[],..._(r),entries:s})}});function U(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new vn({type:"enum",entries:n,..._(t)})}const fd=l("ZodLiteral",(e,t)=>{Bc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>nl(e,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function E(e,t){return new fd({type:"literal",values:Array.isArray(e)?e:[e],..._(t)})}const hd=l("ZodTransform",(e,t)=>{Zc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>rl(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new wo(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(et(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(et(i))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(s=>(n.value=s,n)):(n.value=r,n)}});function md(e){return new hd({type:"transform",transform:e})}const Sr=l("ZodOptional",(e,t)=>{Jo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>pr(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Tr(e){return new Sr({type:"optional",innerType:e})}const Ed=l("ZodExactOptional",(e,t)=>{Hc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>pr(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function gd(e){return new Ed({type:"optional",innerType:e})}const _d=l("ZodNullable",(e,t)=>{Vc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ll(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Or(e){return new _d({type:"nullable",innerType:e})}const yd=l("ZodDefault",(e,t)=>{Wc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>pl(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Sd(e,t){return new yd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Ao(t)}})}const Td=l("ZodPrefault",(e,t)=>{Yc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>fl(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Od(e,t){return new Td({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Ao(t)}})}const Ir=l("ZodNonOptional",(e,t)=>{Kc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>dl(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Id(e,t){return new Ir({type:"nonoptional",innerType:e,..._(t)})}const wd=l("ZodCatch",(e,t)=>{Jc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>hl(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function vd(e,t){return new wd({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Cd=l("ZodPipe",(e,t)=>{Xc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ml(e,n,o,r),e.in=t.in,e.out=t.out});function wr(e,t){return new Cd({type:"pipe",in:e,out:t})}const Rd=l("ZodReadonly",(e,t)=>{Qc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>El(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function bd(e){return new Rd({type:"readonly",innerType:e})}const vr=l("ZodCustom",(e,t)=>{qc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ol(e,n)});function xe(e,t){return Zu(vr,e??(()=>!0),t)}function Ad(e,t={}){return Hu(vr,e,t)}function Nd(e){return Vu(e)}const ye={SCROLL_TO_TILE:"SCROLL_TO_TILE",HYPER_LINK:"HYPER_LINK",MAIL_LINK:"MAIL_LINK",TEL_LINK:"TEL_LINK",GO_TO_STORE:"GO_TO_STORE",GO_TO_STORE_LINK:"GO_TO_STORE_LINK",GO_TO_PAGE:"GO_TO_PAGE",GO_TO_CATEGORY:"GO_TO_CATEGORY",GO_TO_CATEGORY_LINK:"GO_TO_CATEGORY_LINK"},$d=U(Object.values(ye)),At=ye,nt={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"},Ld=U(Object.values(nt)),Nt=nt,Cr={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"},Dd=U(Object.values(Cr)),kd=Cr,Rr={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"},Pd=U(Object.values(Rr)),zd=Rr,br={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"},jd=U(Object.values(br)),Ud=br,$t={COLOR:"COLOR",GRADIENT:"GRADIENT"},Md=U(Object.values($t)),Cn=$t,Ae={SECTION:"SECTION",HEADER:"HEADER",FOOTER:"FOOTER"},Fd=U(Object.values(Ae)),Se=Ae;var ee=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.Misc=2]="Misc",e[e.Layout=3]="Layout",e[e.Asset=4]="Asset",e[e.SharedFiles=5]="SharedFiles",e))(ee||{}),N=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.SectionSetting=2]="SectionSetting",e[e.SectionShowcase=3]="SectionShowcase",e[e.SectionAsset=4]="SectionAsset",e[e.TemplateDescriptor=5]="TemplateDescriptor",e[e.PageTemplateDescriptor=6]="PageTemplateDescriptor",e[e.TemplateAsset=7]="TemplateAsset",e[e.Layout=8]="Layout",e[e.LayoutSettings=9]="LayoutSettings",e[e.LayoutAsset=10]="LayoutAsset",e[e.SlotServer=11]="SlotServer",e[e.SlotClient=12]="SlotClient",e[e.SharedTranslation=13]="SharedTranslation",e[e.CollectionDescriptor=14]="CollectionDescriptor",e[e.CollectionAsset=15]="CollectionAsset",e))(N||{}),Gd=(e=>(e.SCROLL_TO_TILE="SCROLL_TO_TILE",e.HYPER_LINK="HYPER_LINK",e.MAIL_LINK="MAIL_LINK",e.TEL_LINK="TEL_LINK",e.GO_TO_STORE="GO_TO_STORE",e.GO_TO_STORE_LINK="GO_TO_STORE_LINK",e.GO_TO_PAGE="GO_TO_PAGE",e))(Gd||{});const g={TEXTAREA:"TEXTAREA",INPUTBOX:"INPUTBOX",SELECTBOX:"SELECTBOX",IMAGE:"IMAGE",TOGGLE:"TOGGLE",BUTTON:"BUTTON",DECK:"DECK",MENU:"MENU",NAVIGATION_MENU:"NAVIGATION_MENU",LOGO:"LOGO",INFO:"INFO",DIVIDER:"DIVIDER",PRODUCT_SELECTOR:"PRODUCT_SELECTOR",CATEGORY_SELECTOR:"CATEGORY_SELECTOR"};U(Object.values(g));const w={TEXT:"TEXT",BUTTON:"BUTTON",IMAGE:"IMAGE",TOGGLE:"TOGGLE",SELECTBOX:"SELECTBOX",BACKGROUND:"BACKGROUND",COLOR_PICKER:"COLOR_PICKER",LOGO:"LOGO",DIVIDER:"DIVIDER",INFO:"INFO",ACCORDION:"ACCORDION"};U(Object.values(w));const te=w,ot={CONTENT:"Content",DESIGN:"Design"};U(Object.values(ot));const xd={TEXT:"TEXT",IMAGE:"IMAGE"},Bd=U(Object.values(xd));var Zd=(e=>(e.ORIGINAL="original",e.WEBP_LOW_RES="webp-200x200",e.WEBP_HI_2X_RES="webp-2000x2000",e.MOBILE_WEBP_LOW_RES="cropped-webp-100x200",e.MOBILE_WEBP_HI_RES="cropped-webp-1000x2000",e))(Zd||{}),Hd=(e=>(e.TILE_LOADED="tile-loaded",e.TILE_UNLOADED="tile-unloaded",e))(Hd||{});const Vd={apparel_footwear:"apparel_footwear",vape_smoke:"vape_smoke",home_garden:"home_garden",sport_outdoor:"sport_outdoor",jewelry_accessories:"jewelry_accessories",pet_animals:"pet_animals",bikes:"bikes",health_beauty:"health_beauty",gift_shop:"gift_shop",electronics:"electronics",other:"other"},Wd=U(Object.values(Vd)),G={[Se.SECTION]:{source:"sections",dist:"dist/sections"},[Se.HEADER]:{source:"headers",dist:"dist/headers"},[Se.FOOTER]:{source:"footers",dist:"dist/footers"}};var R=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.ClientChunks=2]="ClientChunks",e[e.ClientAsset=3]="ClientAsset",e[e.Asset=4]="Asset",e[e.TemplateAsset=5]="TemplateAsset",e[e.Dependency=6]="Dependency",e[e.SourceCode=7]="SourceCode",e[e.LayoutClient=8]="LayoutClient",e[e.LayoutAsset=9]="LayoutAsset",e[e.SlotServer=10]="SlotServer",e[e.SlotClient=11]="SlotClient",e[e.SlotClientChunks=12]="SlotClientChunks",e[e.SlotClientAsset=13]="SlotClientAsset",e[e.CollectionAsset=14]="CollectionAsset",e))(R||{});function Be(e){const t={};for(const[n,o]of Object.entries(e)){let r={...o};if(o.type==="DECK"&&o.cards&&typeof o.cards=="object"&&"defaultCardContent"in o.cards){const s=o.cards;s.defaultCardContent?.settings&&(r={...r,cards:{...s,defaultCardContent:{...s.defaultCardContent,settings:Be(s.defaultCardContent.settings)}}})}if(o.type==="ACCORDION"&&o.cards&&typeof o.cards=="object"&&!("defaultCardContent"in o.cards)){const s=o.cards,i={};for(const[a,c]of Object.entries(s))c.editors?i[a]={...c,editors:Be(c.editors)}:i[a]=c;r={...r,cards:i}}if(r.defaults&&typeof r.defaults=="object"&&!("type"in r.defaults)){const s=Object.assign({type:r.type},r.defaults);r={...r,defaults:s}}t[n]=r}return t}const Yd={url:"must be a valid URL",email:"must be a valid email address"},Kd=e=>{const t=e?.at(-1);return typeof t=="string"?`'${t}'`:"Field"},Jd=e=>e===null?"null":typeof e,Xd=e=>{switch(e.code){case"invalid_type":{const{input:t}=e;return t===void 0?{message:`${Kd(e.path)} is required`}:{message:`Expected ${String(e.expected)}, received ${Jd(t)}`}}case"invalid_format":{const t=Yd[e.format];return t?{message:t}:void 0}case"unrecognized_keys":return{message:`Unrecognized property: ${e.keys.map(t=>`'${t}'`).join(", ")}`};case"invalid_union":{const t=e.path?.at(-1);return typeof t=="string"?{message:`'${t}' is required or has invalid value`}:void 0}case"invalid_value":{const{values:t}=e;return t?{message:`Expected one of: ${t.map(n=>`'${String(n)}'`).join(", ")}`}:void 0}case"invalid_key":{const t=e.issues?.[0];return t?{message:t.message}:void 0}default:return}};U(["none","all","small"]);const Ne={PRODUCT:"PRODUCT",CATALOG:"CATALOG",CATEGORY:"CATEGORY",HOME:"HOME",CUSTOM:"CUSTOM"},Ar={HOME:"home",CATALOG:"catalog",CATEGORY:"category",PRODUCT:"product"},Qd=U(Object.values(Ne));U(Object.values(Ar));const qd={HEADER_LEFT:"HEADER_LEFT",HEADER_CENTER_LOGO_BURGER:"HEADER_CENTER_LOGO_BURGER",HEADER_CENTER_LOGO_COMPACT:"HEADER_CENTER_LOGO_COMPACT",HEADER_CENTER_LOGO_DETAILED:"HEADER_CENTER_LOGO_DETAILED",HEADER_LEFT_LOGO_BURGER:"HEADER_LEFT_LOGO_BURGER",HEADER_LEFT_LOGO_COMPACT:"HEADER_LEFT_LOGO_COMPACT",HEADER_LEFT_LOGO_DETAILED:"HEADER_LEFT_LOGO_DETAILED",HEADER_LEFT_LOGO_SEARCH:"HEADER_LEFT_LOGO_SEARCH",HEADER_LEFT_LOGO_TEXT:"HEADER_LEFT_LOGO_TEXT",TEXT_ONE_COLUMN:"TEXT_ONE_COLUMN",TEXT_TITLE_LEFT:"TEXT_TITLE_LEFT",TEXT_SUBTITLE_RIGHT:"TEXT_SUBTITLE_RIGHT",TEXT_TWO_COLUMNS:"TEXT_TWO_COLUMNS",TEXT_CENTER:"TEXT_CENTER",TEXT_DESCRIPTION_RIGHT:"TEXT_DESCRIPTION_RIGHT",CTA_BANNER_LEFT:"CTA_BANNER_LEFT",CTA_BANNER_RIGHT:"CTA_BANNER_RIGHT",CTA_BANNER_CENTER:"CTA_BANNER_CENTER",CTA_BANNER_BOTTOM:"CTA_BANNER_BOTTOM",CTA_PROMO_BAR_LEFT:"CTA_PROMO_BAR_LEFT",CTA_PROMO_BAR_RIGHT:"CTA_PROMO_BAR_RIGHT",CTA_STORY_LEFT:"CTA_STORY_LEFT",CTA_STORY_RIGHT:"CTA_STORY_RIGHT",CTA_FULLWIDTH_CENTER:"CTA_FULLWIDTH_CENTER",CTA_FULLWIDTH_LEFT:"CTA_FULLWIDTH_LEFT",CTA_FULLWIDTH_NO_IMAGE:"CTA_FULLWIDTH_NO_IMAGE",COVER_FULLSCREEN_CENTER:"COVER_FULLSCREEN_CENTER",COVER_FULLSCREEN_LEFT:"COVER_FULLSCREEN_LEFT",COVER_FULLSCREEN_CENTER_LEFT:"COVER_FULLSCREEN_CENTER_LEFT",COVER_FULLSCREEN_RIGHT:"COVER_FULLSCREEN_RIGHT",COVER_FULLSCREEN_BOTTOM:"COVER_FULLSCREEN_BOTTOM",COVER_FULLSCREEN_BOTTOM_RIGHT:"COVER_FULLSCREEN_BOTTOM_RIGHT",COVER_FULLSCREEN_BOTTOM_LEFT:"COVER_FULLSCREEN_BOTTOM_LEFT",COVER_FULLSCREEN_TOP:"COVER_FULLSCREEN_TOP",COVER_SIDEBAR_RIGHT:"COVER_SIDEBAR_RIGHT",COVER_SIDEBAR_LEFT:"COVER_SIDEBAR_LEFT",COVER_HALFSCREEN_LEFT:"COVER_HALFSCREEN_LEFT",COVER_HALFSCREEN_CENTER:"COVER_HALFSCREEN_CENTER",COVER_COLLAGE_BOTTOM:"COVER_COLLAGE_BOTTOM",COVER_COLLAGE_LEFT:"COVER_COLLAGE_LEFT",IMAGE_SUBTITLE_RIGHT:"IMAGE_SUBTITLE_RIGHT",IMAGE_TITLE_LEFT:"IMAGE_TITLE_LEFT",IMAGE_LEFT:"IMAGE_LEFT",IMAGE_RIGHT:"IMAGE_RIGHT",IMAGE_CENTER:"IMAGE_CENTER",IMAGE_SIDE_TITLE:"IMAGE_SIDE_TITLE",LOCATION_MAP_RIGHT:"LOCATION_MAP_RIGHT",LOCATION_MAP_LEFT:"LOCATION_MAP_LEFT",LOCATION_IMAGE_RIGHT:"LOCATION_IMAGE_RIGHT",LOCATION_IMAGE_LEFT:"LOCATION_IMAGE_LEFT",LOCATION_BACKGROUND_RIGHT:"LOCATION_BACKGROUND_RIGHT",LOCATION_BACKGROUND_LEFT:"LOCATION_BACKGROUND_LEFT",LOCATION_FULL:"LOCATION_FULL",LOCATION_SHORT:"LOCATION_SHORT",REVIEWS_MINIMAL:"REVIEWS_MINIMAL",REVIEWS_CARDS:"REVIEWS_CARDS",REVIEWS:"REVIEWS",REVIEWS_CLASSIC:"REVIEWS_CLASSIC",REVIEWS_FULLSCREEN_BG:"REVIEWS_FULLSCREEN_BG",REVIEWS_FULLSCREEN_SIDEBAR_LEFT:"REVIEWS_FULLSCREEN_SIDEBAR_LEFT",REVIEWS_FULLSCREEN_SIDEBAR_RIGHT:"REVIEWS_FULLSCREEN_SIDEBAR_RIGHT",REVIEWS_CARDS_PHOTO:"REVIEWS_CARDS_PHOTO",REVIEWS_PHOTO_SPEECH_RIGHT:"REVIEWS_PHOTO_SPEECH_RIGHT",REVIEWS_PHOTO_SPEECH_LEFT:"REVIEWS_PHOTO_SPEECH_LEFT",REVIEWS_SOCIAL_FEED:"REVIEWS_SOCIAL_FEED",REVIEWS_ADAPTIVE:"REVIEWS_ADAPTIVE",FEATURES_CLASSIC_CENTER:"FEATURES_CLASSIC_CENTER",FEATURES_CLASSIC_LEFT:"FEATURES_CLASSIC_LEFT",FEATURES_ACCORDION:"FEATURES_ACCORDION",FEATURES_MINIMAL:"FEATURES_MINIMAL",FEATURES_SMALL_ICONS:"FEATURES_SMALL_ICONS",FEATURES_CAROUSEL:"FEATURES_CAROUSEL",FEATURES_IMAGE_LEFT:"FEATURES_IMAGE_LEFT",FEATURES_IMAGE_RIGHT:"FEATURES_IMAGE_RIGHT",ANNOUNCEMENT_CENTER:"ANNOUNCEMENT_CENTER",TWO_COLUMNS_SIDEBAR_ON_THE_LEFT:"TWO_COLUMNS_SIDEBAR_ON_THE_LEFT",TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT:"TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT",THREE_COLUMNS_SIDEBAR_ON_THE_RIGHT:"THREE_COLUMNS_SIDEBAR_ON_THE_RIGHT",THREE_COLUMNS_SIDEBAR_ON_THE_LEFT:"THREE_COLUMNS_SIDEBAR_ON_THE_LEFT",TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT_DESCRIPTION_UNDER_IMAGE:"TWO_COLUMNS_SIDEBAR_ON_THE_RIGHT_DESCRIPTION_UNDER_IMAGE",SLIDER_FULLSCREEN_CENTER:"SLIDER_FULLSCREEN_CENTER",SLIDER_FULLSCREEN_LEFT:"SLIDER_FULLSCREEN_LEFT",SLIDER_BASIC:"SLIDER_BASIC",SLIDER_CAROUSEL:"SLIDER_CAROUSEL",SLIDER_CAROUSEL_PORTRAIT:"SLIDER_CAROUSEL_PORTRAIT",SLIDER_SPLIT:"SLIDER_SPLIT",SLIDER_SPLIT_REVERSE:"SLIDER_SPLIT_REVERSE"},ep=U(Object.values(qd)),tp={HEADER:"header",COVER:"cover",ANNOUNCEMENT_BAR:"announcement_bar",SLIDER:"slider",SPECIAL_OFFER:"special_offer",CUSTOMER_REVIEW:"customer_review",COMPANY_INFO:"company_info",SHIPPING_PAYMENT:"shipping_payment",LOCATION:"location",STORE:"store",FOOTER:"footer",VIDEO:"video",IMAGE_GALLERY:"image_gallery",CONTACT_INFO:"contact_info",CONTACTS_WIDGET_WHATSAPP:"contacts_widget_whatsapp",CONTACTS_WIDGET_INSTAGRAM:"contacts_widget_instagram",CONTACTS_WIDGET_FACEBOOK:"contacts_widget_facebook",CONTACTS_WIDGET_PHONE:"contacts_widget_phone"},np={COVER:"COVER",ANNOUNCEMENT:"ANNOUNCEMENT",STORE:"STORE",SLIDER:"SLIDER",VIDEO:"VIDEO",SPECIAL_OFFER:"SPECIAL_OFFER",CUSTOMER_REVIEW:"CUSTOMER_REVIEW",COMPANY_INFO:"COMPANY_INFO",SHIPPING_PAYMENT:"SHIPPING_PAYMENT",LOCATION:"LOCATION",COLLECTIONS:"COLLECTIONS",BRANDS:"BRANDS",CONTACT_INFO:"CONTACT_INFO"},op=U(Object.values(np)),X={REQUIRED_HEADER_ID:()=>'Header section must have id "header" when type is "default"',REQUIRED_CUSTOM_HEADER:(...e)=>`Custom header section with id "${e[0]}" must exist in headers directory`,REQUIRED_CUSTOM_HEADER_TYPE:(...e)=>`Custom header section with id "${e[0]}" must be of type "HEADER"`,REQUIRED_FOOTER_ID:()=>'Footer section must have id "footer" when type is "default"',REQUIRED_CUSTOM_FOOTER:(...e)=>`Custom footer section with id "${e[0]}" must exist in footers directory`,REQUIRED_CUSTOM_FOOTER_TYPE:(...e)=>`Custom footer section with id "${e[0]}" must be of type "FOOTER"`,REQUIRED_PAGE_SECTION:(...e)=>`Custom section with id "${e[0]}" must exist in sections directory`,REQUIRED_PAGE_SECTION_TYPE:()=>'Section "header" or "footer" is not allowed among page sections',SHOWCASE_ID_NOT_FOUND:(...e)=>`Showcase with id "${e[0]}" must exist in section's showcase directory`,DUPLICATE_SHOWCASE_ID:(...e)=>`Showcase id "${e[0]}" must be unique within section showcases`,SHOWCASE_OVERRIDE_CONTENT:(...e)=>`Content editor "${e[0]}" in showcase_overrides must exist in section's content configuration file`,SHOWCASE_OVERRIDE_DESIGN:(...e)=>`Design editor "${e[0]}" in showcase_overrides must exist in section's design configuration file`,SHOWCASE_OVERRIDE_LAYOUT:(...e)=>`LayoutId "${e[0]}" in showcase_overrides must exist in section's layout configuration file`,SHOWCASE_LAYOUT:(...e)=>`LayoutId "${e[0]}" in showcase must exist in section's layout configuration file`,INVALID_SHOWCASE_CONTENT_ELEMENT:(...e)=>`Element "${e[0]}" is not defined in content.ts`,SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH:(...e)=>`Element "${e[0]}" type mismatch: showcase has type "${e[1]}" but content.ts has type "${e[2]}"`,INVALID_SHOWCASE_DESIGN_ELEMENT:(...e)=>`Element "${e[0]}" is not defined in design.ts`,SHOWCASE_DESIGN_ELEMENT_TYPE_MISMATCH:(...e)=>`Element "${e[0]}" type mismatch: showcase has type "${e[1]}" but design.ts has type "${e[2]}"`,INVALID_DECK_CARD_SETTING:(...e)=>`Setting "${e[0]}" is not defined in content.ts defaultCardContent.settings`,DECK_SETTINGS_REQUIRED:()=>"settings must have at least one property",INVALID_SELECTBOX_OPTION:(...e)=>`Option value "${e[0]}" for element "${e[1]}" is not defined in content.ts options`,REQUIRED_STORE_LAYOUT:(...e)=>`Store section with id "${e[0]}" and page type "${e[1]}" must have a corresponding layout defined`,INVALID_STORE_SECTION_ID:(...e)=>`Store layout sectionId "${e[0]}" must be one of: ${e[1]}`,REQUIRED_SECTION_ASSET:(...e)=>`Asset size ${e[0]} exceeds threshold of ${e[1]}.`,REQUIRED_SERVER_SIZE:(...e)=>`Size of individual server file [${e[0]}] must not exceed threshold [${e[1]}].`,MISSING_IMAGE_ASSET:(...e)=>`Image ${e[0]} is missing from assets folder`,MANDATORY_SETTING_TYPE_MISMATCH:(...e)=>`Editor type "${e[0]}" for reserved key "${e[1]}" does not match the required type "${e[2]}".`,MANDATORY_SETTING_NAME_MISMATCH:(...e)=>`Editor key "${e[0]}" for overridden content type "${e[1]}" does not match the required key name "${e[2]}".`,DUPLICATED_MANDATORY_SETTING:(...e)=>`Editor type "${e[0]}" can only be used once.`,IMAGE_EDITOR_STATIC_MISMATCH:(...e)=>`Both "${e[0]}" content and design editor need to have same value for attribute static`,DUPLICATE_DESIGN_EDITOR_NAME:()=>"Non-unique design editor name detected",COLOR_REQUIRED_GRADIENT:()=>"color is required when overlay is GRADIENT",COLOR_MUST_BE_ARRAY_GRADIENT:()=>"color must be an array when overlay is GRADIENT",COLOR_ARRAY_LENGTH_GRADIENT:()=>"color array must have exactly 2 items when overlay is GRADIENT",COLOR_REQUIRED_COLOR:()=>"color is required when overlay is COLOR",COLOR_MUST_BE_SINGLE_COLOR:()=>"color must be a single value when overlay is COLOR",COLOR_MUST_BE_UNDEFINED_NONE:()=>"color must be undefined when overlay is NONE or not set",COLOR_REQUIRED_STYLE_GRADIENT:()=>"color is required when style is GRADIENT",COLOR_MUST_BE_ARRAY_STYLE_GRADIENT:()=>"color must be an array when style is GRADIENT",COLOR_ARRAY_LENGTH_STYLE_GRADIENT:()=>"color array must have exactly 2 items when style is GRADIENT",COLOR_REQUIRED_STYLE_COLOR:()=>"color is required when style is COLOR",COLOR_MUST_BE_SINGLE_STYLE_COLOR:()=>"color must be a single value when style is COLOR",BUTTON_LINK_REQUIRED:()=>"link is required when buttonType is HYPER_LINK",BUTTON_CATEGORY_ID_REQUIRED:()=>"categoryId is required when buttonType is GO_TO_CATEGORY or GO_TO_CATEGORY_LINK",BUTTON_EMAIL_REQUIRED:()=>"email is required when buttonType is MAIL_LINK",BUTTON_PHONE_REQUIRED:()=>"phone is required when buttonType is TEL_LINK",BUTTON_TILE_ID_REQUIRED:(...e)=>`${e[0]} is required when buttonType is SCROLL_TO_TILE`,BUTTON_PAGE_ID_REQUIRED:()=>"pageIdForNavigate is required when type is GO_TO_PAGE",TEMPLATE_PAGE_SECTIONS_REQUIRED:()=>"sections must contain at least one section",TEMPLATE_PAGE_SINGLE_SECTION_REQUIRED:(...e)=>`Page type "${e[0]}" must have exactly one section`,TEMPLATE_PAGE_STORE_SECTION_REQUIRED:(...e)=>`Page type "${e[0]}" must have a section of type "store"`,TEMPLATE_PAGE_NO_STORE_SECTIONS:(...e)=>`Page type "${e[0]}" cannot contain store sections`,TEMPLATE_PAGE_CUSTOM_METADATA_REQUIRED:()=>'Page type "CUSTOM" must have a metadata property',TEMPLATE_PAGE_METADATA_NOT_ALLOWED:(...e)=>`Page type "${e[0]}" must not have a metadata property`,NON_NEGATIVE_INTEGER:()=>"must be a non-negative integer",INTEGER_RANGE:(...e)=>`must be between ${e[0]} and ${e[1]}`,VALID_HEX_COLOR:()=>"must be a valid hex color (#RGB, #RRGGBB, or #RRGGBBAA)",VALID_GLOBAL_FONT:()=>"must be a valid global font reference (global.fontFamily.title or global.fontFamily.body)",VALID_GLOBAL_TEXT_SIZE:()=>"must be a valid global text size reference (global.textSize.title, global.textSize.subtitle, or global.textSize.body)",VALID_GLOBAL_COLOR:()=>"must be a valid global color reference (global.color.title, global.color.body, global.color.button, global.color.link, or global.color.background)",VALID_COLOR:()=>"must be a valid hex color (#RGB, #RRGGBB, or #RRGGBBAA) or global color reference (global.color.title, global.color.body, global.color.button, global.color.link, or global.color.background)",VALID_TEXT_SIZE:()=>"must be an integer of at least 1 or a valid global text size reference (global.textSize.title, global.textSize.subtitle, or global.textSize.body)",VALID_LANGUAGE_CODE:()=>"must be a valid language code (e.g., en, nl, fr, en_US, en_GB, zh_Hans)",VALID_URL:()=>"must be a valid URL",VALID_EMAIL:()=>"must be a valid email address",ACCORDION_ITEM_POSITION_FIELD_REQUIRED:(...e)=>`Item "${e[0]}" must have positionFieldName when sortable is true`,ACCORDION_ITEMS_REQUIRED:()=>"items must have at least one item",ACCORDION_ITEM_EDITORS_REQUIRED:(...e)=>`Item "${e[0]}" must have at least one editor`,ACCORDION_SHOWCASE_ITEMS_REQUIRED:()=>"items must have at least one item",ACCORDION_SHOWCASE_ITEM_EDITORS_REQUIRED:(...e)=>`Item "${e[0]}" must have at least one editor override`,ACCORDION_DUPLICATE_POSITION_FIELD_NAME:()=>"positionFieldName must be unique across accordion items when sortable is true",REQUIRED_COLLECTION_NAME:()=>"Collection must have a name in metadata"},Nr=/^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,$r=/^global\.fontFamily\.(title|body)$/,Lr=/^global\.textSize\.(title|subtitle|body)$/,Dr=/^global\.color\.(title|body|button|link|background)$/,rp=/^[a-z]{2}(_([a-z]{2}|[A-Z]{2}|[0-9]{3}))?$/,Re=(e,t)=>{const n=X.INTEGER_RANGE(e.toString(),t.toString());return he().min(e,{message:n}).max(t,{message:n})},Rn=p({path:h(),size:bt().nonnegative()}).strict(),kr=p({size:bt().nonnegative()}).strict(),y=h().regex(/^\$.+/,{message:"must start with '$' followed by at least one character"}),sp=p({r:Re(0,255),g:Re(0,255),b:Re(0,255),a:Re(0,1)}).strict(),Pr=h().regex(Nr,{message:X.VALID_HEX_COLOR()});xe(e=>typeof e=="string"&&$r.test(e),{message:X.VALID_GLOBAL_FONT()});const bn=h().refine(e=>!e.startsWith("global.")||$r.test(e),{message:X.VALID_GLOBAL_FONT()});xe(e=>typeof e=="string"&&Dr.test(e),{message:X.VALID_GLOBAL_COLOR()});const le=xe(e=>typeof e=="string"&&(Nr.test(e)||Dr.test(e)),{message:X.VALID_COLOR()}),zr=xe(e=>typeof e=="string"?le.safeParse(e).success:Array.isArray(e)&&e.every(t=>le.safeParse(t).success),{message:X.VALID_COLOR()});xe(e=>typeof e=="string"&&Lr.test(e),{message:X.VALID_GLOBAL_TEXT_SIZE()});const jr=xe(e=>typeof e=="number"?Number.isInteger(e)&&e>=1:typeof e=="string"&&Lr.test(e),{message:X.VALID_TEXT_SIZE()}),rt=U(["catalog","category","product"]),Lt=h().refine(e=>e.startsWith("#")||Er().safeParse(e).success,{message:"must be a valid URL or a hash fragment starting with #"}),st=p({url:h(),width:he().min(0,{message:X.NON_NEGATIVE_INTEGER()}).optional(),height:he().min(0,{message:X.NON_NEGATIVE_INTEGER()}).optional()}).strict(),ip=p({homogeneity:v().optional(),color:sp.optional()}).strict(),ap=p({ORIGINAL:st.optional(),WEBP_LOW_RES:st.optional(),WEBP_HI_2X_RES:st.optional(),MOBILE_WEBP_LOW_RES:st.optional(),MOBILE_WEBP_HI_RES:st.optional()}).strict().refine(e=>Object.keys(e).length>=1,{message:"set must have at least one property"}),Dt=p({set:ap,borderInfo:ip.optional()}).strict(),An=p({type:E(g.IMAGE),imageData:Dt}).strict(),Ur=p({type:E(g.IMAGE),label:y,static:v().optional(),defaults:An.optional()}).strict(),cp=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Nn(e){return e===Ne.PRODUCT||e===Ne.CATALOG||e===Ne.CATEGORY}function Mr(e,t,n){if(!e)return;const o=Li({path:"$..set..url",json:e,resultType:"all"}),r=/^https?:\/\//;o.forEach(s=>{const i=s.value;if(!r.test(i)&&!t.includes(i)){const a=s.pointer.split("/").filter(c=>c.length>0);n.at(a).addIssue("MISSING_IMAGE_ASSET",i)}})}function Fr(e,t,n){e===ye.HYPER_LINK&&!t&&n.at("link").addIssue("BUTTON_LINK_REQUIRED")}function Gr(e,t,n){(e===ye.GO_TO_CATEGORY||e===ye.GO_TO_CATEGORY_LINK)&&!t&&n.at("categoryId").addIssue("BUTTON_CATEGORY_ID_REQUIRED")}function xr(e,t,n){e===ye.MAIL_LINK&&!t&&n.at("email").addIssue("BUTTON_EMAIL_REQUIRED")}function Br(e,t,n){e===ye.TEL_LINK&&!t&&n.at("phone").addIssue("BUTTON_PHONE_REQUIRED")}function Zr(e,t,n,o){if(e===ye.SCROLL_TO_TILE&&!(t??n)){const r=t?"tileId":"tileIdForScroll";o.at(r).addIssue("BUTTON_TILE_ID_REQUIRED",r)}}function up(e,t,n){e===ye.GO_TO_PAGE&&!t&&n.at("pageIdForNavigate").addIssue("BUTTON_PAGE_ID_REQUIRED")}const lp="custom";function x(e,t=[]){const n=r=>Array.isArray(r)?r:[r],o=n(t);return{raw:e,addIssue(r,...s){e.addIssue({code:lp,message:X[r](...s),path:o,params:{errorMessageKey:r}})},at(r){const s=o.concat(n(r));return x(e,s)}}}const $n=p({type:E(g.BUTTON),title:y,buttonType:$d,link:h().optional(),linkTarget:h().optional(),email:h().regex(cp,{message:X.VALID_EMAIL()}).optional(),phone:h().optional(),tileId:h().optional(),categoryId:bt().optional()}).strict().superRefine((e,t)=>{const n=x(t);Fr(e.buttonType,e.link,n),Gr(e.buttonType,e.categoryId,n),xr(e.buttonType,e.email,n),Br(e.buttonType,e.phone,n),Zr(e.buttonType,e.tileId,void 0,n)}),Hr=p({type:E(g.BUTTON),label:y,defaults:$n.optional()}).strict(),Ln=p({type:E(g.CATEGORY_SELECTOR)}).strict(),Vr=p({type:E(g.CATEGORY_SELECTOR),label:y,maxCategories:Re(1,32),defaults:Ln.optional()}).strict(),Dn=p({type:E(g.DIVIDER)}).strict(),Wr=p({type:E(g.DIVIDER),label:y,defaults:Dn.optional()}).strict(),dp=p({label:y,link:Lt}).strict(),pp=p({title:y.optional(),link:Lt.optional()}).strict(),kn=p({type:E(g.INFO),text:y.optional(),button:pp.optional()}).strict(),Yr=p({type:E(g.INFO),label:y,description:y,button:dp.optional(),defaults:kn.optional()}).strict(),Pn=p({type:E(g.INPUTBOX),text:y}).strict(),Kr=p({type:E(g.INPUTBOX),label:y,placeholder:y,defaults:Pn.optional()}).strict(),zn=p({type:E(g.PRODUCT_SELECTOR)}).strict(),Jr=p({type:E(g.PRODUCT_SELECTOR),label:y,maxProducts:Re(1,32),defaults:zn.optional()}).strict(),jn=p({type:E(g.SELECTBOX),value:h()}).strict(),fp=p({value:h().min(1,{message:"value must not be empty"}),label:y}).strict(),Xr=p({type:E(g.SELECTBOX),label:y,placeholder:y,description:y,options:A(fp).min(1,{message:"must have at least one option"}),defaults:jn.optional()}).strict(),Un=p({type:E(g.TEXTAREA),text:y}).strict(),Qr=p({type:E(g.TEXTAREA),label:y,placeholder:y,defaults:Un.optional()}).strict(),Mn=p({type:E(g.TOGGLE),enabled:v()}).strict(),qr=p({type:E(g.TOGGLE),label:y,description:y,defaults:Mn.optional()}).strict(),es=p({type:E(g.DECK)}).strict(),ts=[Pn,Un,$n,An,Mn,jn,Dn,kn,zn,Ln],hp=q("type",[...ts]),mp=p({type:E(g.DECK),cards:A(p({settings:Z(h(),hp).superRefine((e,t)=>{Object.keys(e).length<1&&x(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()).min(1,{message:"cards must have at least one card"})}).strict(),Ep=q("type",[...ts,mp]),gp=p({type:E(g.DECK),cards:A(p({settings:Z(h(),Ep).superRefine((e,t)=>{Object.keys(e).length<1&&x(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()).min(1,{message:"cards must have at least one card"})}).strict(),ns=[Kr,Qr,Hr,Ur,qr,Xr,Wr,Yr,Vr,Jr],_p=p({type:E(g.DECK),label:y,addButtonLabel:y,maxCards:he().min(1,{message:"must be a positive integer"}),cards:p({defaultCardContent:p({label:y,settings:Z(h(),q("type",[...ns])).superRefine((e,t)=>{Object.keys(e).length<1&&x(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:es.optional()}).strict(),yp=q("type",[...ns,_p]),Sp=p({type:E(g.DECK),label:y,addButtonLabel:y,maxCards:he().min(1,{message:"must be a positive integer"}),cards:p({defaultCardContent:p({label:y,settings:Z(h(),yp).superRefine((e,t)=>{Object.keys(e).length<1&&x(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:es.optional()}).strict(),os=p({type:E(g.LOGO),logoType:Bd.optional(),text:y.optional(),imageData:Dt.optional()}).strict(),Tp=p({type:E(g.LOGO),label:y.optional(),defaults:os.optional()}).strict(),rs=p({id:h(),title:h().optional(),type:h().optional(),link:h().optional(),email:h().optional(),phone:h().optional(),tileIdForScroll:h().optional(),pageIdForNavigate:h().optional(),showStoreCategories:v().optional(),isSubmenuOpened:v().optional(),categoryId:bt().optional()}).strict().superRefine((e,t)=>{const n=x(t);Fr(e.type,e.link,n),Gr(e.type,e.categoryId,n),xr(e.type,e.email,n),Br(e.type,e.phone,n),Zr(e.type,void 0,e.tileIdForScroll,n),up(e.type,e.pageIdForNavigate,n)}),ss=p({type:E(g.MENU),items:A(rs).optional()}).strict(),Op=p({type:E(g.MENU),label:y.optional(),defaults:ss.optional()}).strict(),is=p({type:E(g.NAVIGATION_MENU),items:A(rs).optional()}).strict(),Ip=p({type:E(g.NAVIGATION_MENU),defaults:is.optional()}).strict(),kt=p({type:E(w.BACKGROUND),style:Md.optional(),color:zr.optional()}).strict().superRefine((e,t)=>{const n=x(t).at("color");e.style===$t.GRADIENT?e.color===void 0?n.addIssue("COLOR_REQUIRED_STYLE_GRADIENT"):Array.isArray(e.color)?e.color.length!==2&&n.addIssue("COLOR_ARRAY_LENGTH_STYLE_GRADIENT"):n.addIssue("COLOR_MUST_BE_ARRAY_STYLE_GRADIENT"):e.style===$t.COLOR&&(e.color===void 0?n.addIssue("COLOR_REQUIRED_STYLE_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_STYLE_COLOR"))}),wp=p({type:E(w.BACKGROUND),fieldName:h(),defaults:kt.optional()}).strict(),as=p({type:E(w.BACKGROUND),label:y,colors:A(le).optional(),enableAlphaColor:v().optional(),enableAutoColor:v().optional(),defaults:kt.optional()}).strict(),Pt=p({type:E(w.BUTTON),appearance:Dd.optional(),size:Pd.optional(),shape:jd.optional(),font:bn.optional(),color:le.optional(),visible:v().optional()}).strict(),vp=p({type:E(w.BUTTON),fieldName:h(),defaults:Pt.optional()}).strict(),cs=p({type:E(w.BUTTON),label:y,colors:A(le).optional(),enableAutoColor:v().optional(),enableAlphaColor:v().optional(),hideVisibleToggle:v().optional(),hideSize:v().optional(),defaults:Pt.optional()}).strict(),zt=p({type:E(w.COLOR_PICKER),color:le.optional()}).strict(),Cp=p({type:E(w.COLOR_PICKER),fieldName:h(),defaults:zt.optional()}).strict(),us=p({type:E(w.COLOR_PICKER),label:y,description:y.optional(),colors:A(le).optional(),enableAlphaColor:v().optional(),enableAutoColor:v().optional(),defaults:zt.optional()}).strict(),jt=p({type:E(w.DIVIDER)}).strict(),Rp=p({type:E(w.DIVIDER),fieldName:h(),defaults:jt.optional()}).strict(),ls=p({type:E(w.DIVIDER),label:y,defaults:jt.optional()}).strict(),Ut=p({type:E(w.IMAGE),overlay:Ld.optional(),color:zr.optional(),visible:v().optional()}).strict().superRefine((e,t)=>{const n=x(t).at("color");e.overlay===nt.GRADIENT?e.color===void 0?n.addIssue("COLOR_REQUIRED_GRADIENT"):Array.isArray(e.color)?e.color.length!==2&&n.addIssue("COLOR_ARRAY_LENGTH_GRADIENT"):n.addIssue("COLOR_MUST_BE_ARRAY_GRADIENT"):e.overlay===nt.COLOR?e.color===void 0?n.addIssue("COLOR_REQUIRED_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_COLOR"):(e.overlay===nt.NONE||e.overlay===void 0)&&e.color!==void 0&&n.addIssue("COLOR_MUST_BE_UNDEFINED_NONE")}),bp=p({type:E(w.IMAGE),fieldName:h(),defaults:Ut.optional()}).strict(),ds=p({type:E(w.IMAGE),label:y,static:v().optional(),colors:A(Pr).optional(),enableAlphaColor:v().optional(),hideVisibleToggle:v().optional(),defaults:Ut.optional()}).strict(),Ap=p({label:y,link:Lt}).strict(),Np=p({label:y.optional(),link:Lt.optional()}).strict(),Mt=p({type:E(w.INFO),description:y.optional(),button:Np.optional()}).strict(),$p=p({type:E(w.INFO),fieldName:h(),defaults:Mt.optional()}).strict(),ps=p({type:E(w.INFO),label:y,description:y,button:Ap.optional(),defaults:Mt.optional()}).strict(),Lp=p({visible:v(),width:Re(1,49).optional(),color:le.optional()}).strict(),Ft=p({type:E(w.LOGO),font:bn.optional(),size:jr.optional(),bold:v().optional(),italic:v().optional(),color:le.optional(),visible:v().optional(),spacing:Re(1,9).optional(),frame:Lp.optional(),capitalization:U(["none","all","small"]).optional()}).strict(),Dp=p({type:E(w.LOGO),fieldName:h(),defaults:Ft.optional()}).strict(),fs=p({type:E(w.LOGO),label:y,colors:A(le).optional(),sizes:A(he().min(1,{message:"must be at least 1"})).optional(),defaults:Ft.optional()}).strict(),kp=p({value:h().optional(),label:y.optional()}).strict(),Gt=p({type:E(w.SELECTBOX),value:h().optional()}).strict(),Pp=p({type:E(w.SELECTBOX),fieldName:h(),defaults:Gt.optional()}).strict(),hs=p({type:E(w.SELECTBOX),label:y,description:y.optional(),options:A(kp).optional(),defaults:Gt.optional()}).strict(),xt=p({type:E(w.TEXT),font:bn.optional(),size:jr.optional(),bold:v().optional(),italic:v().optional(),color:le.optional(),visible:v().optional()}).strict(),zp=p({type:E(w.TEXT),fieldName:h(),defaults:xt.optional()}).strict(),ms=p({type:E(w.TEXT),label:y,colors:A(Pr).optional(),sizes:A(he().min(1,{message:"must be at least 1"})).optional(),enableAlphaColor:v().optional(),enableAutoColor:v().optional(),hideVisibleToggle:v().optional(),hideSize:v().optional(),defaults:xt.optional()}).strict(),Bt=p({type:E(w.TOGGLE),enabled:v().optional()}).strict(),jp=p({type:E(w.TOGGLE),fieldName:h(),defaults:Bt.optional()}).strict(),Es=p({type:E(w.TOGGLE),label:y,defaults:Bt.optional()}).strict();function Up(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_SHOWCASE_ITEMS_REQUIRED")}function Mp(e,t){for(const[n,o]of Object.entries(e))Object.keys(o.editors).length===0&&t.at(["items",n,"editors"]).addIssue("ACCORDION_SHOWCASE_ITEM_EDITORS_REQUIRED",n)}function Fp(e,t,n){Object.keys(e).length===0&&n.at("editors").addIssue("ACCORDION_ITEM_EDITORS_REQUIRED",t)}function Gp(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_ITEMS_REQUIRED")}function xp(e,t){for(const[n,o]of Object.entries(e))o.positionFieldName||t.at(["items",n,"positionFieldName"]).addIssue("ACCORDION_ITEM_POSITION_FIELD_REQUIRED",n)}function Bp(e,t){const n=Object.values(e).map(o=>o.positionFieldName).filter(Boolean);new Set(n).size!==n.length&&t.at("items").addIssue("ACCORDION_DUPLICATE_POSITION_FIELD_NAME")}const gs=p({type:E(w.ACCORDION)}).strict(),Zp=q("type",[xt,Pt,Ut,Bt,Gt,kt,zt,Ft,jt,Mt]),Hp=p({editors:Z(h(),Zp)}).strict(),Vp=p({type:E(w.ACCORDION),items:Z(h(),Hp)}).strict().superRefine((e,t)=>{const n=x(t);Up(e.items,n),Mp(e.items,n)}),Wp=p({type:E(w.ACCORDION),fieldName:h(),defaults:gs.optional()}).strict(),Yp=q("type",[ms,cs,ds,Es,hs,as,us,fs,ls,ps]),Kp=p({label:y,positionFieldName:h().optional(),editors:Z(h(),Yp)}).strict().superRefine((e,t)=>{Fp(e.editors,e.label,x(t))}),Jp=p({type:E(w.ACCORDION),sortable:v().optional(),items:Z(h(),Kp),defaults:gs.optional()}).strict().superRefine((e,t)=>{const n=x(t);Gp(e.items,n),e.sortable===!0&&(xp(e.items,n),Bp(e.items,n))}),_s=q("type",[Pn,Un,$n,An,Mn,jn,ss,is,os,Dn,kn,gp,zn,Ln]),ys=q("type",[xt,Pt,Ut,Bt,Gt,kt,zt,Ft,jt,Vp,Mt]),Xp=p({showcaseId:h(),blockName:h(),previewImage:Dt,content:Z(h(),_s),design:Z(h(),ys),layoutId:h().optional()}).strict(),Qp=p({blockName:h(),content:Z(h(),_s).optional(),design:Z(h(),ys).optional(),layoutId:h().optional()}).strict();function qp(e,t){Nn(e.type)&&(e.sections.length!==1?t.at("sections").addIssue("TEMPLATE_PAGE_SINGLE_SECTION_REQUIRED",e.type):e.sections[0]?.type!=="store"&&t.at(["sections",0,"type"]).addIssue("TEMPLATE_PAGE_STORE_SECTION_REQUIRED",e.type))}function ef(e,t){Nn(e.type)&&e.sections.length===0&&t.at("sections").addIssue("TEMPLATE_PAGE_SECTIONS_REQUIRED"),e.sections.forEach((n,o)=>{Nn(e.type)||n.type==="store"&&t.at(["sections",o,"type"]).addIssue("TEMPLATE_PAGE_NO_STORE_SECTIONS",e.type),n.type==="default"&&n.id&&(n.id==="header"||n.id==="footer")&&t.at(["sections",o,"id"]).addIssue("REQUIRED_PAGE_SECTION_TYPE")})}function tf(e,t){e.type==="CUSTOM"?e.metadata||t.at("metadata").addIssue("TEMPLATE_PAGE_CUSTOM_METADATA_REQUIRED"):e.metadata!==void 0&&t.at("metadata").addIssue("TEMPLATE_PAGE_METADATA_NOT_ALLOWED",e.type)}const nf=new RegExp(`^(${Object.values(tp).join("|")})(_\\d{3})?$`),of=h().regex(nf,"id must match pattern: [default_section_name] or [default_section_name]_XXX where XXX is three digits"),rf=h().regex(new RegExp("\\d{3}"),"showcase_id must be a three digit string"),Ss=p({type:E("default"),id:of,showcase_id:rf.optional()}).strict(),Fn=p({type:E("custom"),id:h(),showcase_id:h().optional(),showcase_overrides:Qp.optional(),category:op.optional()}).strict(),sf=p({type:E("store"),id:h().optional()}).strict(),af=q("type",[Ss,Fn,sf]),cf=p({title:h()}).strict(),uf=p({metadata:cf.optional(),sections:A(af)}).strict(),lf=uf.safeExtend({type:Qd,id:h().min(1,{message:"id is required"})}).strict().superRefine((e,t)=>{const n=x(t);ef(e,n),qp(e,n),tf(e,n)}),Ts=p({name:h().min(2,{message:"name must be at least 2 characters"}).max(60,{message:"name must be at most 60 characters"}),description:h().min(2,{message:"description must be at least 2 characters"}).max(150,{message:"description must be at most 150 characters"}),preview_url:Er({message:"preview_url must be a valid URL"}).regex(/^(https?):\/\/([^.]+?\.)?(company\.site|ecwid\.qa)($|\/[A-Za-z0-9\-._~:/?#\[\]@!$&'()*+,;=]*)?$/,"preview_url must match pattern: (https?)://([^.]+?\\.)?(company\\.site|ecwid\\.qa)(...)?").optional(),cover_image:Dt,categories:A(Wd).refine(e=>new Set(e).size===e.length,{message:"categories must contain unique items"}).optional()}).strict(),df=Ss.extend({id:h()}),Os=q("type",[df,Fn]),pf=p({metadata:Ts,header:Os,footer:Os}).strict(),ff=p({id:h().min(1,{message:"id is required"}),assets:Rn.array().optional(),configuration:pf,pages:A(lf)}).strict(),Zt=2097152,Ht=512e3;function Te(e,t=2){if(!+e)return"0 Bytes";const n=1024,o=t<0?0:t,r=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],s=Math.floor(Math.log(e)/Math.log(n));return`${parseFloat((e/n**s).toFixed(o))} ${r[s]}`}const hf={menu:{type:g.NAVIGATION_MENU},logo:{type:g.LOGO}},mf={logo:{type:"LOGO",label:"$label.logo.label",colors:["#FFFFFF66","#0000004D","#00000099","#64C7FF66","#F9947266","#C794CD66","#FFD17466"],sizes:[18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60],defaults:{type:"LOGO",font:"global.fontFamily.body",size:40,bold:!0,italic:!1,color:"#313131",visible:!0,spacing:2,capitalization:"all",frame:{visible:!0,width:3,color:"#313131"}}}};function Is(e){switch(e){case Ae.HEADER:return hf;default:return{}}}function ws(e){switch(e){case Ae.HEADER:return mf;default:return{}}}function vs({validationType:e,sectionType:t}){switch(e){case ot.CONTENT:return Is(t);case ot.DESIGN:return ws(t);default:return{}}}const Ef=Fn.extend({id:h().min(1,{message:"section id is required"})}),gf=p({metadata:Ts,sections:A(Ef).min(1,{message:"sections must contain at least one section"}).max(20,{message:"sections must contain at most 20 sections"})}).strict().superRefine((e,t)=>{e.metadata.name.trim().length===0&&x(t).at(["collection","metadata","name"]).addIssue("REQUIRED_COLLECTION_NAME")}),_f=p({id:h().min(1,{message:"id is required"}),descriptor:gf}).strict(),yf=q("type",[Kr,Qr,Hr,Ur,qr,Xr,Sp,Op,Ip,Tp,Wr,Yr,Jr,Vr]),Gn=Z(h(),yf),Sf=q("type",[ms,cs,ds,Es,hs,as,us,fs,ls,Jp,ps]),xn=Z(h(),Sf),Tf=q("type",[zp,vp,bp,jp,Pp,wp,Cp,Dp,Rp,$p,Wp]),Bn=p({layoutId:h(),layoutIcon:ep.optional(),selectedContentSettings:A(h()),selectedDesignSettings:A(Tf)}).strict(),Of=h().regex(rp,X.VALID_LANGUAGE_CODE()),Vt=Z(Of,Z(y,h()));function Cs(e,t,n){if(!e||Object.keys(t).length===0)return;const o=Object.entries(t),r=o.map(([,{type:i}])=>i),s=Object.values(e).map(({type:i})=>i);Object.entries(e).forEach(([i,a])=>{const c=t[i];c&&"type"in c&&a.type!==c.type&&n.at(i).addIssue("MANDATORY_SETTING_TYPE_MISMATCH",a.type,i,c.type)}),Object.entries(e).forEach(([i,a])=>{const c=o.find(([,{type:u}])=>u===a.type)?.[0];c&&i!==c&&n.at(i).addIssue("MANDATORY_SETTING_NAME_MISMATCH",i,a.type,c)}),new Set(s.filter(i=>r.includes(i))).forEach(i=>{if(s.filter(a=>a===i).length>1){const a=o.findLast(([,{type:c}])=>c===i)?.[0];n.at(a).addIssue("DUPLICATED_MANDATORY_SETTING",i)}})}function Rs(e,t,n){Mr(e,t,n)}function bs(e,t,n){if(e.type!==g.DECK||t.type!==g.DECK)return;const o=t.cards?.defaultCardContent?.settings,r=e.cards;!o||!Array.isArray(r)||r.forEach((s,i)=>{s.settings&&Object.entries(s.settings).forEach(([a,c])=>{const u=o[a],d=n.at(["cards",i,"settings",a]);if(!u){d.addIssue("INVALID_DECK_CARD_SETTING",a);return}if(c.type!==u.type){d.addIssue("SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH",a,c.type,u.type);return}c.type===g.DECK&&u.type===g.DECK&&bs(c,u,d)})})}function If(e,t,n){e.content&&Object.entries(e.content).forEach(([o,r])=>{const s=n.at(["content",o]),i=t[o];if(!i){s.addIssue("INVALID_SHOWCASE_CONTENT_ELEMENT",o);return}if(r.type!==i.type){s.addIssue("SHOWCASE_CONTENT_ELEMENT_TYPE_MISMATCH",o,r.type,i.type);return}if(r.type===g.SELECTBOX&&i.type===g.SELECTBOX){const a=i,c=r;a.options&&c.value!==void 0&&(new Set(a.options.map(u=>u.value)).has(c.value)||s.addIssue("INVALID_SELECTBOX_OPTION",c.value,o))}r.type===g.DECK&&bs(r,i,s)})}function wf(e,t,n){e.design&&Object.entries(e.design).forEach(([o,r])=>{const s=n.at(["design",o]),i=t[o];if(!i){s.addIssue("INVALID_SHOWCASE_DESIGN_ELEMENT",o);return}r.type!==i.type&&s.addIssue("SHOWCASE_DESIGN_ELEMENT_TYPE_MISMATCH",o,r.type,i.type)})}function vf(e,t){Object.entries(e).flatMap(([n,o])=>{switch(o.type){case w.ACCORDION:return Object.entries(o.items).flatMap(([r,s])=>Object.keys(s.editors).map(i=>({name:i,path:[n,"items",r,"editors",i]})));default:return[{name:n,path:[n]}]}}).filter(({name:n},o,r)=>r.findIndex(s=>s.name===n)<o).forEach(({path:n})=>t.at(n).addIssue("DUPLICATE_DESIGN_EDITOR_NAME"))}function Cf(e,t,n){e.layoutId&&((t||[]).some(o=>o.layoutId===e.layoutId)||n.at("layoutId").addIssue("SHOWCASE_LAYOUT",e.layoutId))}function Rf(e,t){const n=new Set;e.forEach((o,r)=>{if(n.has(o.showcaseId)){t.at([r,"showcaseId"]).addIssue("DUPLICATE_SHOWCASE_ID",o.showcaseId);return}n.add(o.showcaseId)})}function As(e,t,n){for(const[o,r]of Object.entries(e)){const s=r;if(s.type===g.IMAGE){const i=t[o];if(i?.type===w.IMAGE){const a=s.static??!1,c=i.static??!1;a!==c&&n.at(o).addIssue("IMAGE_EDITOR_STATIC_MISMATCH",o)}}else if(s.type===g.DECK){const i=s;i.cards?.defaultCardContent?.settings&&As(i.cards.defaultCardContent.settings,t,n.at([o,"cards","defaultCardContent","settings"]))}}}function bf(e,t,n){t>Zt&&n.at(z.basename(e)).addIssue("REQUIRED_SECTION_ASSET",Te(t),Te(Zt))}function Af(e,t){e>Ht&&t.addIssue("REQUIRED_SERVER_SIZE",Te(e),Te(Ht))}const Nf=p({id:h(),type:Fd,name:h(),content:Gn,design:xn,layout:A(Bn).optional(),showcase:A(Xp),translationsSettings:Vt.optional(),translationsShowcases:Vt.optional(),assets:Rn.array().optional(),server:kr,previewCount:he().optional()}).strict().superRefine((e,t)=>{const n=x(t),o=vs({validationType:ot.CONTENT,sectionType:e.type}),r=vs({validationType:ot.DESIGN,sectionType:e.type});Cs(e.content,o,n.at("content")),Cs(e.design,r,n.at("design")),As(e.content,e.design,n.at("content")),vf(e.design,n.at("design")),e.assets&&e.assets.forEach(i=>{bf(i.path,i.size,n.at("assets"))}),Af(e.server.size,n.at("server"));const s=e.assets?.map(i=>i.path)??[];Rs(e.content,s,n.at("content")),Rf(e.showcase,n.at("showcase")),e.showcase.forEach((i,a)=>{const c=n.at(["showcase",a]);Rs(i,s,c),If(i,e.content,c),wf(i,e.design,c),Cf(i,e.layout,c)})}),$f=p({translations:Vt.optional()}).strict(),Lf=U(["products","category","product"]),Df=p({id:h(),sectionId:h(),assets:Rn.array().optional(),content:Gn.optional(),design:xn.optional(),translationsSettings:Vt.optional(),layouts:Bn.array().optional()}).strict().superRefine((e,t)=>{const n=x(t);rt.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,rt.options.join(", ")),e.assets&&e.assets.forEach(o=>{o.size>Zt&&n.at(["assets",z.basename(o.path)]).addIssue("REQUIRED_SECTION_ASSET",Te(o.size),Te(Zt))})});p({id:h(),sectionId:rt,pageId:Lf,content:Gn.optional(),design:xn.optional(),layouts:Bn.array().optional()}).strict();const kf=p({id:h(),sectionId:h(),layoutId:h(),server:kr}).strict().superRefine((e,t)=>{const n=x(t);rt.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,rt.options.join(", ")),e.server.size>Ht&&n.at("server").addIssue("REQUIRED_SERVER_SIZE",Te(e.server.size),Te(Ht))});function Pf(e,t,n){if(e){if(e.type==="default")e.id!=="header"&&n.at("id").addIssue("REQUIRED_HEADER_ID");else if(e.type==="custom"&&e.id){const o=t.find(r=>r.id===e.id);o?(o.type!=="HEADER"&&n.at("id").addIssue("REQUIRED_CUSTOM_HEADER_TYPE",e.id),e.showcase_id&&((o.showcase||[]).some(r=>r.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))):n.at("id").addIssue("REQUIRED_CUSTOM_HEADER",e.id)}}}function zf(e,t,n){if(e){if(e.type==="default")e.id!=="footer"&&n.at("id").addIssue("REQUIRED_FOOTER_ID");else if(e.type==="custom"&&e.id){const o=t.find(r=>r.id===e.id);o?(o.type!=="FOOTER"&&n.at("id").addIssue("REQUIRED_CUSTOM_FOOTER_TYPE",e.id),e.showcase_id&&((o.showcase||[]).some(r=>r.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))):n.at("id").addIssue("REQUIRED_CUSTOM_FOOTER",e.id)}}}function jf(e,t,n){if(!e)return;const o=n.at(["showcase_overrides"]);["content","design"].forEach(s=>{const i=e[s];if(i){const a=t[s]||{};Object.keys(i).forEach(c=>{if(!(c in a)){const u=s==="content"?"SHOWCASE_OVERRIDE_CONTENT":"SHOWCASE_OVERRIDE_DESIGN";o.at([s,c]).addIssue(u,c)}})}}),e.layoutId&&((t.layout||[]).some(s=>s.layoutId===e.layoutId)||o.at(["layoutId"]).addIssue("SHOWCASE_OVERRIDE_LAYOUT",e.layoutId));const r=t.assets?.map(s=>s.path)??[];e.content&&Mr(e.content,r,o.at(["content"]))}function Ns(e,t,n,o=!1){if(!e.id)return;const r=t.find(s=>s.id===e.id);if(!r){n.at("id").addIssue("REQUIRED_PAGE_SECTION",e.id);return}!o&&(r.type==="HEADER"||r.type==="FOOTER")&&n.at("id").addIssue("REQUIRED_PAGE_SECTION_TYPE"),jf(e.showcase_overrides,r,n),e.showcase_id&&((r.showcase||[]).some(s=>s.showcaseId===e.showcase_id)||n.at("showcase_id").addIssue("SHOWCASE_ID_NOT_FOUND",e.showcase_id))}function Uf(e,t,n,o){e.id&&(n.some(r=>r.sectionId===t.type.toLowerCase()&&r.id===e.id)||o.at("id").addIssue("REQUIRED_STORE_LAYOUT",e.id,t.type.toLowerCase()))}const Mf=p({version:h(),name:h(),shared:$f.optional(),sections:A(Nf),templates:A(ff),layouts:A(Df),slots:A(kf),collections:A(_f),compressionEnabled:v(),externalizationEnabled:v(),vueVersion:h(),openSource:v().optional()}).strict().superRefine((e,t)=>{e.templates.forEach((n,o)=>{const r=x(t).at(["templates",o]);Pf(n.configuration.header,e.sections,r.at(["configuration","header"])),zf(n.configuration.footer,e.sections,r.at(["configuration","footer"])),n.pages.forEach((s,i)=>{const a=r.at(["pages",i]);s.sections.forEach((c,u)=>{const d=a.at(["sections",u]);c.type==="custom"?Ns(c,e.sections,d):c.type==="store"&&Uf(c,s,e.layouts,d)})})}),e.collections.forEach((n,o)=>{n.descriptor.sections.forEach((r,s)=>{const i=x(t).at(["collections",o,"sections",s]);Ns(r,e.sections,i,!0)})})});_e({customError:Xd});const f={error:e=>console.log(bi(e)),warn:e=>console.log(Ri(e)),info:e=>console.log(ce(e))},Ff="dist",Gf="dist/shared",me="dist/sections",Zn="dist/headers",Hn="dist/footers",Oe="dist/templates",Ze="layouts",$s="preview",Q=`dist/${Ze}`,it="dist/collections",Ls="dist/manifest.json",xf=[me,Zn,Hn,Oe,Q];function Wt(e){return!!e}function $e(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}const Bf="Resource name can only contain alphanumeric characters, dashes, and underscores";function Zf(e){if(typeof e=="string"||typeof e=="number"){const t=/^[a-zA-Z0-9_-]+$/.test(e.toString());if(t)return{isValid:t,errorMessage:null}}return{isValid:!1,errorMessage:Bf}}function Hf(e){return e===!0?!0:typeof e=="string"&&e.trim().length===0}function Vf(e){return z.parse(e).name}function Wf(e){return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function Yt(){const e=await pn(T(process.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}function Yf(e){return e.includes(`
40
+ `)}function Kf(e,t,n){return e.split(`
41
+ `).map((o,r)=>r>=n?t+o:o).join(`
42
+ `)}function Le(e,t){const n=[];if(e instanceof yo){e.response?.status!==void 0&&n.push(` HTTP Status Code: ${e.response.status}`);const s=e.response?.data;if(s?.errorCode&&n.push(` Error Code: ${s.errorCode}`),s?.errorMessage){const i=Yf(s.errorMessage)?Kf(s.errorMessage," ",1):s.errorMessage;n.push(` Error Message: ${i}`)}}const o=n.length>0?n.join(`
43
+ `):e?.message??"Unknown error";if(!t||t.length===0)return o;const r=n.length>0?`
44
+ `:" ";return`${t}${r}${o}`}function Vn(e,t){return Object.keys(e).reduce((n,o)=>{const r=e[o],s=t[o];return $e(r)&&$e(s)?n[o]=Vn(r,s):n[o]=r,n},{...t})}function Jf({contentSettings:e,sectionType:t}){const n=Is(t);return Vn(e,n)}function Xf({designSettings:e,sectionType:t}){const n=ws(t);return Vn(e,n)}async function re(e){return(await import(_o(e).href+`?t=${Date.now()}`)).default}function Wn(e){if(e!==void 0)return e.startsWith("global.")?{type:"GLOBAL_FONT",font:e}:{type:"PRESET_FONT",font:e}}function de(e){if(e===void 0)return;if(e.startsWith("global."))return{type:"GLOBAL_COLOR",raw:e};const t=Pi(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function Ds(e){if(e!==void 0)return typeof e=="string"&&e.startsWith("global.")?{type:"GLOBAL_TEXT_SIZE",size:e}:{type:"NUMERIC_TEXT_SIZE",size:Number(e)}}function Qf(e){if(e!==void 0)return{...e,color:de(e.color)}}function De(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function qf(e){if(e!==void 0)switch(e){case Cn.COLOR:return"solid";case Cn.GRADIENT:return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(Cn)}`)}}function eh({style:e,color:t}){const n=Array.isArray(t)?t:[t,t];return{background:{type:qf(e),solid:{color:de(n.at(0))},gradient:{fromColor:de(n.at(0)),toColor:de(n.at(1))}}}}function th(e){if(e!==void 0)switch(e){case"SOLID":return"solid-button";case"OUTLINE":return"outline-button";case"TEXT":return"text-link";default:throw new Error(`Unknown button appearance: ${e}. Right options: ${Object.keys(kd)}`)}}function nh(e){if(e!==void 0)switch(e){case"SMALL":return"small";case"MEDIUM":return"medium";case"LARGE":return"large";default:throw new Error(`Unknown button size: ${e}. Right options: ${Object.keys(zd)}`)}}function oh(e){if(e!==void 0)switch(e){case"ROUND_CORNER":return"round-corner";case"RECTANGLE":return"rectangle";case"PILL":return"pill";default:throw new Error(`Unknown button shape: ${e}. Right options: ${Object.keys(Ud)}`)}}function rh(e){return e===At.GO_TO_STORE?At.GO_TO_STORE_LINK:e===At.GO_TO_CATEGORY?At.GO_TO_CATEGORY_LINK:e}function sh(e){const t=th(e.appearance),n=nh(e.size),o=oh(e.shape),r=Wn(e.font),s=de(e.color),i=e.visible;return De({appearance:t,size:n,style:o,font:r,color:s,visible:i})}function ih(e){return{...e,buttonType:rh(e.buttonType)}}function ah(e){const t=de(e.color);return De({color:t})}function ch(e){if(e!==void 0)switch(e){case Nt.COLOR:return"solid";case Nt.GRADIENT:return"gradient";case Nt.NONE:return"none";default:throw new Error(`Unknown image overlay type: ${e}. Right options: ${Object.keys(Nt)}`)}}function uh(e){const t=e.color,n=Array.isArray(t)?t:[t,t],o=e.visible,r={type:ch(e.overlay),solid:{color:de(n.at(0))},gradient:{fromColor:de(n.at(0)),toColor:de(n.at(1))}};return De({overlay:r,visible:o})}function lh(e){const t=Wn(e.font),n=de(e.color),o=Ds(e.size),r=e.bold,s=e.italic,i=e.spacing,a=e.capitalization,c=e.visible;return De({font:t,color:n,size:o,frame:Qf(e.frame),bold:r,italic:s,spacing:i,capitalization:a,visible:c})}function dh(e){const t=e.value;return De({value:t})}function ph(e){const t=Wn(e.font),n=de(e.color),o=Ds(e.size),r=e.bold,s=e.italic,i=e.visible;return De({font:t,color:n,size:o,bold:r,italic:s,visible:i})}function fh(e){const t=e.enabled;return De({enabled:t})}function hh(e){return e===gt.GO_TO_STORE_LINK?gt.GO_TO_STORE:e===gt.GO_TO_CATEGORY_LINK?gt.GO_TO_CATEGORY:e}function ks(e){return e.map(t=>t.type?{...t,type:hh(t.type)}:t)}function mh(e){return e.items?{...e,items:ks(e.items)}:e}function Eh(e){return e.items?{...e,items:ks(e.items)}:e}function gh(e){if(!e.cards)return e;const t=e.cards.map(n=>{if(!n.settings)return n;const o={};return Object.keys(n.settings).forEach(r=>{const s=n.settings[r],i=s.type,a=Kt(i,{defaults:s});a&&s?o[r]={...s,...a}:o[r]=s}),{...n,settings:o}});return{...e,cards:t}}function Yn(e,t){if(t.defaults===void 0)return;let n={};switch(e){case te.TEXT:{n=ph(t.defaults);break}case te.BUTTON:{n=sh(t.defaults);break}case te.IMAGE:{n=uh(t.defaults);break}case te.BACKGROUND:{n=eh(t.defaults);break}case te.COLOR_PICKER:{n=ah(t.defaults);break}case te.LOGO:{n=lh(t.defaults);break}case te.SELECTBOX:{n=dh(t.defaults);break}case te.TOGGLE:{n=fh(t.defaults);break}case te.DIVIDER:case te.INFO:break;case te.ACCORDION:return t.defaults;default:throw new Error(`Unknown design editor type: ${e}`)}return n}function Ps(e){const t={};return Object.keys(e).forEach(n=>{const o=e[n],r=o.type;if(r===te.ACCORDION){const i=Object.fromEntries(Object.entries(o.items).map(([a,c])=>[a,{...c,editors:Ps(c.editors)}]));t[n]={...o,items:i};return}const s=Yn(r,o);s&&o.defaults?t[n]={...o,defaults:s}:t[n]=o}),t}function _h(e){return e===void 0?e:e.map(t=>{if(t.type!==void 0&&t.defaults!==void 0&&t.fieldName!==void 0){const n={...Yn(t.type,t)??t.defaults,type:t.defaults.type??t.type};return{type:t.type,fieldName:t.fieldName,defaults:n}}return t})}function Kn(e){if(e===void 0)return;const t={};return Object.keys(e).forEach(n=>{const o=e[n],r=o.type;if(r===te.ACCORDION){const i=Object.fromEntries(Object.entries(o.items).map(([a,c])=>[a,{...c,editors:Kn(c.editors)??c.editors}]));t[n]={type:o.type,items:i};return}const s=Yn(r,{defaults:o});s!==void 0?t[n]={...o,...s,type:o.type}:t[n]=o}),t}function Kt(e,t){if(t.defaults!==void 0)switch(e){case g.BUTTON:return ih(t.defaults);case g.MENU:return mh(t.defaults);case g.NAVIGATION_MENU:return Eh(t.defaults);case g.DECK:return gh(t.defaults);case g.CATEGORY_SELECTOR:case g.DIVIDER:case g.IMAGE:case g.INPUTBOX:case g.INFO:case g.LOGO:case g.PRODUCT_SELECTOR:case g.SELECTBOX:case g.TEXTAREA:case g.TOGGLE:return{...t.defaults};default:throw new Error(`Unknown content editor type: ${e}`)}}function yh(e){const t={};return Object.keys(e).forEach(n=>{const o=e[n],r=o.type;if(r===g.DECK)t[n]=zs(o);else{const s=Kt(r,o);s&&o.defaults?t[n]={...o,defaults:s}:t[n]=o}}),t}function zs(e){const t=e.cards.defaultCardContent.settings,n=yh(t);return{...e,cards:{...e.cards,defaultCardContent:{...e.cards.defaultCardContent,settings:n}}}}function Sh(e){const t={};return Object.keys(e).forEach(n=>{const o=e[n],r=o.type;if(r===g.DECK)t[n]=zs(o);else{const s=Kt(r,o);s&&o.defaults?t[n]={...o,defaults:s}:t[n]=o}}),t}function Th(e){if(e===void 0)return;const t={};return Object.keys(e).forEach(n=>{const o=e[n],r=o.type,s=Kt(r,{defaults:o});s!==void 0?t[n]={...o,...s,type:o.type}:t[n]=o}),t}function Oh(e,t){if(!t)return;const n=e[t];return n===void 0?{en:t}:n}function Ih(e){const t={};for(const n in e){const o=e[n];for(const r in o){const s=t[r],i=o[r];if(s===void 0){const a={};a[n]=i,t[r]=a}else s[n]=i}}return t}function wh(e){return e.every(t=>t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")}function He(e,t){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return wh(e)?e:e.map(r=>He(r,t));const n=e,o={};for(const r in n){const s=n[r];typeof s=="string"&&s.startsWith("$")?o[r]=Oh(t,s):typeof s=="object"&&s!==null?o[r]=He(s,t):o[r]=s}return o}async function at(e){return e?Ih(e):{}}async function vh(e,t=me){const n=T(process.cwd(),`${t}/${e}/js/settings/translations.mjs`);return await re(n)}async function Jt(e,t=me){const n=T(process.cwd(),`${t}/${e}/js/showcases/translations.mjs`);return await re(n)}async function Ch(e,t){const n=T(process.cwd(),`${Q}/${t}/${e}/js/settings/translations.mjs`);if(V(n))return await re(n)}async function Jn(e,t,n){const o=n?Jf({contentSettings:e,sectionType:n}):e,r=Sh(o);return He(r,t)}async function Rh(e,t=me){try{const n=T(M.cwd(),`${t}/${e}/js/settings/content.mjs`),o=await re(n);return Be(o)}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function Xn(e,t,n){const o=n?Xf({designSettings:e,sectionType:n}):e,r=Ps(o);return He(r,t)}async function bh(e,t=me){try{const n=T(M.cwd(),`${t}/${e}/js/settings/design.mjs`),o=await re(n);return Be(o)}catch(n){const o=n;throw new Error(`Design settings is invalid or undefined. Error ${o.stack}`)}}async function Ah(e,t){return Promise.all(e.map(async n=>{const o=n.content?Th(n.content):void 0,r=n.design?Kn(n.design):void 0,s={...n,content:o??n.content,design:r??n.design};return He(s,t)}))}async function Nh(e,t=me){try{const n=await I("*.mjs",{cwd:T(M.cwd(),`${t}/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(n.map(async o=>{const r=T(M.cwd(),`${t}/${e}/js/showcases/${o}`);return await re(r)}))}catch(n){throw new Error(`Showcases is invalid or undefined. Error ${n}`)}}async function js(e){return e?.map(t=>({...t,selectedDesignSettings:_h(t.selectedDesignSettings)??t.selectedDesignSettings}))??[]}async function $h(e,t=me){try{const n=T(M.cwd(),`${t}/${e}/js/settings/layout.mjs`);return V(n)?await re(n):[]}catch{throw new Error(`Layout descriptor for section [${e}] is either invalid or undefined`)}}function Lh(e){let t={};const n=T(M.cwd(),`${$s}/shared/analytics.json`);if(!V(n))return 0;try{const o=cn(n,"utf-8");t=JSON.parse(o)}catch(o){console.warn("Error processing analytics.json file",o)}return t[e]||0}const Ve={Server:0,Client:1,SectionAsset:4,PageTemplateDescriptor:6,TemplateAsset:7,SharedTranslation:13},Qn="https://blockbuster.ecwid.com",Dh="/api/v1/custom-apps/resources/sections/upload",kh="/api/v1/custom-apps/resources/templates/upload",Ph="/api/v1/custom-apps/manifests/sections",zh="/api/v1/custom-apps/manifests/templates",jh=5,Uh=3,Mh=[R.Server,R.Client,R.ClientChunks,R.ClientAsset,R.Asset],Fh=[R.LayoutClient,R.LayoutAsset],Gh=[R.SlotServer,R.SlotClient,R.SlotClientChunks,R.SlotClientAsset],xh=[R.Dependency,R.TemplateAsset,R.SourceCode,R.CollectionAsset],We={DEFAULT:"Error while deploying:",ASSET_FILES_UPLOAD:"Error while uploading asset files:",MANIFEST_DEPLOYMENT:"Error while deploying manifest file:",DEPRECATED_VERSION_DEPLOYMENT:"You are using a non-supported version of crane. Please update to the latest crane version to continue.",INCORRECT_DISTRIBUTION_FOLDER:e=>`Distribution folder [${e}] is not found or has incorrect structure, please execute the build command first.`},Us={catalog:"products",category:"category",product:"product"},Ms=e=>Us[e],Fs=e=>e in Us;function Bh(e){return e.replace(/\\/g,"/")}function Zh(e){return e.replace(/^dist\/layouts\//,"").replace(/^layouts\//,"")}function Xt(e){return Zh(Bh(e))}function Hh(e){const t=Xt(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,o]=t;if(!Fs(n))throw new Error(`Layout cannot be placed in a non-storefront section: ${n}`);const r=Ms(n);return{id:o,sectionId:n,pageId:r}}async function Vh(e){return Promise.all(e.map(async t=>{const n=t.sectionId,o=Ms(n),r=await at(t.translationsSettings),s=await Jn(t.content??{},r),i=await Xn(t.design??{},r),a=await js(t.layouts);return{id:t.id,sectionId:n,pageId:o,contentEditors:s,designEditors:i,layouts:a}}))}function Ye(e,t,...n){if(!e||!t)throw new Error(`Cannot build layout path. Invalid parameters - sectionId: "${e}", layoutId: "${t}"`);return`${Q}/${e}/${t}/${n.join("/")}`}const ct=(e=Se.SECTION)=>G[e].dist,ut={[R.Server]:{type:"server_js_compressed",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,sectionType:t})=>`${ct(t)}/${e}/js/main/server/`},[R.Client]:{type:"client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${ct(t)}/${e}/js/main/client/`},[R.ClientChunks]:{type:"client_js_chunks",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${ct(t)}/${e}/js/main/client/chunks/`,fileName:"*"},[R.ClientAsset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${ct(t)}/${e}/js/main/client/assets/`},[R.Asset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${ct(t)}/${e}/assets/`},[R.TemplateAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${Oe}/assets/`},[R.Dependency]:{type:"dependencies",fileName:"package.json",isSingleton:!0,toPath:()=>{}},[R.SourceCode]:{type:"source_code",fileName:"source-code.zip",isSingleton:!0,toPath:()=>{}},[R.LayoutClient]:{type:"layout_client_js",fileName:"index.mjs",isSingleton:!0,toPath:({sectionId:e,layoutId:t})=>Ye(e,t,"")},[R.LayoutAsset]:{type:"layout_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t})=>Ye(e,t,"assets/")},[R.SlotServer]:{type:"slot_server_js",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ye(e,t,"slots",n,"js/main/server/")},[R.SlotClient]:{type:"slot_client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ye(e,t,"slots",n,"js/main/client/")},[R.SlotClientChunks]:{type:"slot_client_js_chunks",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ye(e,t,"slots",n,"js/main/client/chunks/")},[R.SlotClientAsset]:{type:"slot_client_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>Ye(e,t,"slots",n,"js/main/client/assets/")},[R.CollectionAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${it}/assets/`}};function Wh(e){return typeof e=="object"&&e!==null&&"version"in e&&typeof e.version=="string"}async function qn(){const e=T(Et.cwd(),"package.json"),t=await pn(e),n=JSON.parse(t.toString());if(Wh(n))return n;throw new Error(`Package file located at path: ${e} does not contain a version field`)}const Yh={layout:e=>e.layoutId,showcase:e=>e.showcaseId,templates:e=>{const t=e.id;return t?.includes("_")?t.substring(t.indexOf("_")+1):t}};function Kh(e,t){const n=Yh[e];return n?n(t):t.id}const Jh=new Set(["content","design"]);function Qt(e,t,n=0,o=[]){if(n>=t.length)return o;const r=t[n],s=t[n+1];if(typeof r=="string"&&typeof s=="number"&&$e(e)){const i=e[r],a=Array.isArray(i)?i[s]:void 0;if($e(a)){const c=Kh(r,a);return o.push(`${r}[${c||s}]`),Qt(a,t,n+2,o)}}if(typeof r=="string"&&typeof s=="string"&&Jh.has(r)){o.push(`${r}[${s}]`);const i=$e(e)&&!Array.isArray(e)?e[r]:void 0,a=$e(i)&&!Array.isArray(i)?i[s]:void 0;return Qt(a,t,n+2,o)}return o.push(r),Qt($e(e)?e[r]:void 0,t,n+1,o)}function Xh(e){const t=e.errors.map(o=>Qt(e.manifest,o.path).join(".")),n={path:Math.max(...t.map(o=>o.length),0),message:Math.max(...e.errors.map(o=>o.message.length),0)};e.errors.map((o,r)=>{const s=o.params?.errorMessageKey||"GENERAL_ISSUE";return`${t[r].padEnd(n.path," ")} | ${o.message.padEnd(n.message," ")} | ${s}`}).forEach(o=>f.error(o))}async function Qh(e){const t=Mf.safeParse(e);return{manifest:e,errors:t.success?[]:t.error.issues}}const qh=`Build successful:
45
45
  For preview run: npx @lightspeed/crane@latest preview
46
- For deploy run: npx @lightspeed/crane@latest deploy`;function Mh(e,t){if(e.errors.length===0){f.info(Fh);return}f.error("Invalid configuration detected:"),jh(e),t||process.exit(1)}const zr={"process.env":{NODE_ENV:"production"}},Gh=[...go,...go.map(e=>`node:${e}`)],xh=[/@vue\/compiler-dom/,/@vue\/runtime-dom/,/@vue\/server-renderer/,/@vue\/compiler-ssr/,/@vue\/shared/],jr=e=>({pluginType:ee.Server,define:zr,ssr:!0,ssrOptions:{noExternal:!0},entryFileNames:"server.js",externalOption:[...Gh,...xh],inlineDynamicImports:!0,...e,outDir:e.outDir}),Ur=e=>({pluginType:ee.Client,define:zr,ssr:!1,entryFileNames:"client.js",assetFileNames:"assets/[name].[ext]",chunkFileNames:"chunks/[name].js",inlineDynamicImports:!1,...e,outDir:e.outDir}),Ke=e=>({pluginType:ee.Misc,ssr:!1,...e,entryFileNames:e.entryFileNames,outDir:e.outDir}),Bh=e=>({pluginType:ee.Layout,ssr:!1,entryFileNames:"index.mjs",...e,outDir:e.outDir}),Jt=e=>({pluginType:ee.Asset,ssr:!1,assetFileNames:"[name].[ext]",...e,outDir:e.outDir});let Xt=!1;function Zh(e){Xt=e}function Xn(){return Xt}const Fr=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Hh=80,Vh="\x1B[?25l",Wh="\x1B[?25h",Yh="\x1B[2K\r",Kh=44;let Jh=class{frameIndex=0;timer=null;realWrite=null;buffer=[];start(){Xt||(this.frameIndex=0,this.buffer=[],this.realWrite=process.stdout.write.bind(process.stdout),process.stdout.write=((t,n,o)=>(this.buffer.push(typeof t=="string"?t:String(t)),typeof n=="function"&&(o=n),o&&o(),!0)),this.realWrite(Vh),this.render(),this.timer=setInterval(()=>this.render(),Hh))}render(){if(!this.realWrite)return;const t=" Build is in progress...".padEnd(Kh-1," "),n=ce(Fr[this.frameIndex]+t);this.realWrite(`\r${n}`),this.frameIndex=(this.frameIndex+1)%Fr.length}stop(){if(!Xt&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.realWrite)){process.stdout.write=this.realWrite,this.realWrite(`${Yh}${Wh}`);for(const t of this.buffer)this.realWrite(t);this.buffer=[],this.realWrite=null}}};const Mr=new Jh,Xh=()=>$i({ext:".gz",algorithm:"gzip",verbose:Xn()}),Qh="/* EXTERNAL_IMPORTS_START */",qh="/* EXTERNAL_IMPORTS_END */",em=()=>({name:"external-imports-wrapper-plugin",enforce:"post",apply:"build",generateBundle(e,t){for(const n of Object.keys(t)){const o=t[n];if(o.type==="chunk"){const s=/import.*\?commonjs-external["'];/g,r=o.code.match(s);if(r!==null){const i=r.join(""),a=Qh+i+qh,c=o.code.replace(s,"");o.code=a+c}}}}}),tm=()=>({name:"disable-json-plugin",enforce:"pre",apply:"build",configResolved(e){const t=e.plugins?.findIndex(n=>n?.name==="vite:json");t!==-1&&(e.plugins[t]={name:"vite:json",load:()=>null,transform:()=>null})}}),nm=()=>{const e=process.env.npm_lifecycle_event;return ki({typescript:!1,vueTsc:!1,eslint:e?.startsWith("test")?!1:{lintCommand:`eslint --max-warnings=0 "./sections/**/*.{js,ts,vue}" --cache --cache-location "./build/eslintcache/${e}.json"`}})},pe={vue:()=>Li(),tsconfigPaths:()=>Di(),checker:()=>nm()};class on{constructor(t){this.bits=t instanceof on?t.bits.slice():[]}add(t){this.bits[t>>5]|=1<<(t&31)}has(t){return!!(this.bits[t>>5]&1<<(t&31))}}class dt{constructor(t,n,o){this.start=t,this.end=n,this.original=o,this.intro="",this.outro="",this.content=o,this.storeName=!1,this.edited=!1,this.previous=null,this.next=null}appendLeft(t){this.outro+=t}appendRight(t){this.intro=this.intro+t}clone(){const t=new dt(this.start,this.end,this.original);return t.intro=this.intro,t.outro=this.outro,t.content=this.content,t.storeName=this.storeName,t.edited=this.edited,t}contains(t){return this.start<t&&t<this.end}eachNext(t){let n=this;for(;n;)t(n),n=n.next}eachPrevious(t){let n=this;for(;n;)t(n),n=n.previous}edit(t,n,o){return this.content=t,o||(this.intro="",this.outro=""),this.storeName=n,this.edited=!0,this}prependLeft(t){this.outro=t+this.outro}prependRight(t){this.intro=t+this.intro}reset(){this.intro="",this.outro="",this.edited&&(this.content=this.original,this.storeName=!1,this.edited=!1)}split(t){const n=t-this.start,o=this.original.slice(0,n),s=this.original.slice(n);this.original=o;const r=new dt(t,this.end,s);return r.outro=this.outro,this.outro="",this.end=t,this.edited?(r.edit("",!1),this.content=""):this.content=o,r.next=this.next,r.next&&(r.next.previous=r),r.previous=this,this.next=r,r}toString(){return this.intro+this.content+this.outro}trimEnd(t){if(this.outro=this.outro.replace(t,""),this.outro.length)return!0;const n=this.content.replace(t,"");if(n.length)return n!==this.content&&(this.split(this.start+n.length).edit("",void 0,!0),this.edited&&this.edit(n,this.storeName,!0)),!0;if(this.edit("",void 0,!0),this.intro=this.intro.replace(t,""),this.intro.length)return!0}trimStart(t){if(this.intro=this.intro.replace(t,""),this.intro.length)return!0;const n=this.content.replace(t,"");if(n.length){if(n!==this.content){const o=this.split(this.end-n.length);this.edited&&o.edit(n,this.storeName,!0),this.edit("",void 0,!0)}return!0}else if(this.edit("",void 0,!0),this.outro=this.outro.replace(t,""),this.outro.length)return!0}}function om(){return typeof globalThis<"u"&&typeof globalThis.btoa=="function"?e=>globalThis.btoa(unescape(encodeURIComponent(e))):typeof Buffer=="function"?e=>Buffer.from(e,"utf-8").toString("base64"):()=>{throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.")}}const sm=om();class rm{constructor(t){this.version=3,this.file=t.file,this.sources=t.sources,this.sourcesContent=t.sourcesContent,this.names=t.names,this.mappings=Pi(t.mappings),typeof t.x_google_ignoreList<"u"&&(this.x_google_ignoreList=t.x_google_ignoreList)}toString(){return JSON.stringify(this)}toUrl(){return"data:application/json;charset=utf-8;base64,"+sm(this.toString())}}function im(e){const t=e.split(`
47
- `),n=t.filter(r=>/^\t+/.test(r)),o=t.filter(r=>/^ {2,}/.test(r));if(n.length===0&&o.length===0)return null;if(n.length>=o.length)return" ";const s=o.reduce((r,i)=>{const a=/^ +/.exec(i)[0].length;return Math.min(a,r)},1/0);return new Array(s+1).join(" ")}function am(e,t){const n=e.split(/[/\\]/),o=t.split(/[/\\]/);for(n.pop();n[0]===o[0];)n.shift(),o.shift();if(n.length){let s=n.length;for(;s--;)n[s]=".."}return n.concat(o).join("/")}const cm=Object.prototype.toString;function lm(e){return cm.call(e)==="[object Object]"}function Gr(e){const t=e.split(`
48
- `),n=[];for(let o=0,s=0;o<t.length;o++)n.push(s),s+=t[o].length+1;return function(s){let r=0,i=n.length;for(;r<i;){const l=r+i>>1;s<n[l]?i=l:r=l+1}const a=r-1,c=s-n[a];return{line:a,column:c}}}const um=/\w/;class dm{constructor(t){this.hires=t,this.generatedCodeLine=0,this.generatedCodeColumn=0,this.raw=[],this.rawSegments=this.raw[this.generatedCodeLine]=[],this.pending=null}addEdit(t,n,o,s){if(n.length){const r=n.length-1;let i=n.indexOf(`
49
- `,0),a=-1;for(;i>=0&&r>i;){const l=[this.generatedCodeColumn,t,o.line,o.column];s>=0&&l.push(s),this.rawSegments.push(l),this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,a=i,i=n.indexOf(`
50
- `,i+1)}const c=[this.generatedCodeColumn,t,o.line,o.column];s>=0&&c.push(s),this.rawSegments.push(c),this.advance(n.slice(a+1))}else this.pending&&(this.rawSegments.push(this.pending),this.advance(n));this.pending=null}addUneditedChunk(t,n,o,s,r){let i=n.start,a=!0,c=!1;for(;i<n.end;){if(this.hires||a||r.has(i)){const l=[this.generatedCodeColumn,t,s.line,s.column];this.hires==="boundary"?um.test(o[i])?c||(this.rawSegments.push(l),c=!0):(this.rawSegments.push(l),c=!1):this.rawSegments.push(l)}o[i]===`
51
- `?(s.line+=1,s.column=0,this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,a=!0):(s.column+=1,this.generatedCodeColumn+=1,a=!1),i+=1}this.pending=null}advance(t){if(!t)return;const n=t.split(`
52
- `);if(n.length>1){for(let o=0;o<n.length-1;o++)this.generatedCodeLine++,this.raw[this.generatedCodeLine]=this.rawSegments=[];this.generatedCodeColumn=0}this.generatedCodeColumn+=n[n.length-1].length}}const ut=`
53
- `,Je={insertLeft:!1,insertRight:!1,storeName:!1};class ao{constructor(t,n={}){const o=new dt(0,t.length,t);Object.defineProperties(this,{original:{writable:!0,value:t},outro:{writable:!0,value:""},intro:{writable:!0,value:""},firstChunk:{writable:!0,value:o},lastChunk:{writable:!0,value:o},lastSearchedChunk:{writable:!0,value:o},byStart:{writable:!0,value:{}},byEnd:{writable:!0,value:{}},filename:{writable:!0,value:n.filename},indentExclusionRanges:{writable:!0,value:n.indentExclusionRanges},sourcemapLocations:{writable:!0,value:new on},storedNames:{writable:!0,value:{}},indentStr:{writable:!0,value:void 0},ignoreList:{writable:!0,value:n.ignoreList}}),this.byStart[0]=o,this.byEnd[t.length]=o}addSourcemapLocation(t){this.sourcemapLocations.add(t)}append(t){if(typeof t!="string")throw new TypeError("outro content must be a string");return this.outro+=t,this}appendLeft(t,n){if(typeof n!="string")throw new TypeError("inserted content must be a string");this._split(t);const o=this.byEnd[t];return o?o.appendLeft(n):this.intro+=n,this}appendRight(t,n){if(typeof n!="string")throw new TypeError("inserted content must be a string");this._split(t);const o=this.byStart[t];return o?o.appendRight(n):this.outro+=n,this}clone(){const t=new ao(this.original,{filename:this.filename});let n=this.firstChunk,o=t.firstChunk=t.lastSearchedChunk=n.clone();for(;n;){t.byStart[o.start]=o,t.byEnd[o.end]=o;const s=n.next,r=s&&s.clone();r&&(o.next=r,r.previous=o,o=r),n=s}return t.lastChunk=o,this.indentExclusionRanges&&(t.indentExclusionRanges=this.indentExclusionRanges.slice()),t.sourcemapLocations=new on(this.sourcemapLocations),t.intro=this.intro,t.outro=this.outro,t}generateDecodedMap(t){t=t||{};const n=0,o=Object.keys(this.storedNames),s=new dm(t.hires),r=Gr(this.original);return this.intro&&s.advance(this.intro),this.firstChunk.eachNext(i=>{const a=r(i.start);i.intro.length&&s.advance(i.intro),i.edited?s.addEdit(n,i.content,a,i.storeName?o.indexOf(i.original):-1):s.addUneditedChunk(n,i,this.original,a,this.sourcemapLocations),i.outro.length&&s.advance(i.outro)}),{file:t.file?t.file.split(/[/\\]/).pop():void 0,sources:[t.source?am(t.file||"",t.source):t.file||""],sourcesContent:t.includeContent?[this.original]:void 0,names:o,mappings:s.raw,x_google_ignoreList:this.ignoreList?[n]:void 0}}generateMap(t){return new rm(this.generateDecodedMap(t))}_ensureindentStr(){this.indentStr===void 0&&(this.indentStr=im(this.original))}_getRawIndentString(){return this._ensureindentStr(),this.indentStr}getIndentString(){return this._ensureindentStr(),this.indentStr===null?" ":this.indentStr}indent(t,n){const o=/^[^\r\n]/gm;if(lm(t)&&(n=t,t=void 0),t===void 0&&(this._ensureindentStr(),t=this.indentStr||" "),t==="")return this;n=n||{};const s={};n.exclude&&(typeof n.exclude[0]=="number"?[n.exclude]:n.exclude).forEach(d=>{for(let m=d[0];m<d[1];m+=1)s[m]=!0});let r=n.indentStart!==!1;const i=l=>r?`${t}${l}`:(r=!0,l);this.intro=this.intro.replace(o,i);let a=0,c=this.firstChunk;for(;c;){const l=c.end;if(c.edited)s[a]||(c.content=c.content.replace(o,i),c.content.length&&(r=c.content[c.content.length-1]===`
54
- `));else for(a=c.start;a<l;){if(!s[a]){const d=this.original[a];d===`
55
- `?r=!0:d!=="\r"&&r&&(r=!1,a===c.start||(this._splitChunk(c,a),c=c.next),c.prependRight(t))}a+=1}a=c.end,c=c.next}return this.outro=this.outro.replace(o,i),this}insert(){throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)")}insertLeft(t,n){return Je.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),Je.insertLeft=!0),this.appendLeft(t,n)}insertRight(t,n){return Je.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),Je.insertRight=!0),this.prependRight(t,n)}move(t,n,o){if(o>=t&&o<=n)throw new Error("Cannot move a selection inside itself");this._split(t),this._split(n),this._split(o);const s=this.byStart[t],r=this.byEnd[n],i=s.previous,a=r.next,c=this.byStart[o];if(!c&&r===this.lastChunk)return this;const l=c?c.previous:this.lastChunk;return i&&(i.next=a),a&&(a.previous=i),l&&(l.next=s),c&&(c.previous=r),s.previous||(this.firstChunk=r.next),r.next||(this.lastChunk=s.previous,this.lastChunk.next=null),s.previous=l,r.next=c||null,l||(this.firstChunk=s),c||(this.lastChunk=r),this}overwrite(t,n,o,s){return s=s||{},this.update(t,n,o,{...s,overwrite:!s.contentOnly})}update(t,n,o,s){if(typeof o!="string")throw new TypeError("replacement content must be a string");for(;t<0;)t+=this.original.length;for(;n<0;)n+=this.original.length;if(n>this.original.length)throw new Error("end is out of bounds");if(t===n)throw new Error("Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead");this._split(t),this._split(n),s===!0&&(Je.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),Je.storeName=!0),s={storeName:!0});const r=s!==void 0?s.storeName:!1,i=s!==void 0?s.overwrite:!1;if(r){const l=this.original.slice(t,n);Object.defineProperty(this.storedNames,l,{writable:!0,value:!0,enumerable:!0})}const a=this.byStart[t],c=this.byEnd[n];if(a){let l=a;for(;l!==c;){if(l.next!==this.byStart[l.end])throw new Error("Cannot overwrite across a split point");l=l.next,l.edit("",!1)}a.edit(o,r,!i)}else{const l=new dt(t,n,"").edit(o,r);c.next=l,l.previous=c}return this}prepend(t){if(typeof t!="string")throw new TypeError("outro content must be a string");return this.intro=t+this.intro,this}prependLeft(t,n){if(typeof n!="string")throw new TypeError("inserted content must be a string");this._split(t);const o=this.byEnd[t];return o?o.prependLeft(n):this.intro=n+this.intro,this}prependRight(t,n){if(typeof n!="string")throw new TypeError("inserted content must be a string");this._split(t);const o=this.byStart[t];return o?o.prependRight(n):this.outro=n+this.outro,this}remove(t,n){for(;t<0;)t+=this.original.length;for(;n<0;)n+=this.original.length;if(t===n)return this;if(t<0||n>this.original.length)throw new Error("Character is out of bounds");if(t>n)throw new Error("end must be greater than start");this._split(t),this._split(n);let o=this.byStart[t];for(;o;)o.intro="",o.outro="",o.edit(""),o=n>o.end?this.byStart[o.end]:null;return this}reset(t,n){for(;t<0;)t+=this.original.length;for(;n<0;)n+=this.original.length;if(t===n)return this;if(t<0||n>this.original.length)throw new Error("Character is out of bounds");if(t>n)throw new Error("end must be greater than start");this._split(t),this._split(n);let o=this.byStart[t];for(;o;)o.reset(),o=n>o.end?this.byStart[o.end]:null;return this}lastChar(){if(this.outro.length)return this.outro[this.outro.length-1];let t=this.lastChunk;do{if(t.outro.length)return t.outro[t.outro.length-1];if(t.content.length)return t.content[t.content.length-1];if(t.intro.length)return t.intro[t.intro.length-1]}while(t=t.previous);return this.intro.length?this.intro[this.intro.length-1]:""}lastLine(){let t=this.outro.lastIndexOf(ut);if(t!==-1)return this.outro.substr(t+1);let n=this.outro,o=this.lastChunk;do{if(o.outro.length>0){if(t=o.outro.lastIndexOf(ut),t!==-1)return o.outro.substr(t+1)+n;n=o.outro+n}if(o.content.length>0){if(t=o.content.lastIndexOf(ut),t!==-1)return o.content.substr(t+1)+n;n=o.content+n}if(o.intro.length>0){if(t=o.intro.lastIndexOf(ut),t!==-1)return o.intro.substr(t+1)+n;n=o.intro+n}}while(o=o.previous);return t=this.intro.lastIndexOf(ut),t!==-1?this.intro.substr(t+1)+n:this.intro+n}slice(t=0,n=this.original.length){for(;t<0;)t+=this.original.length;for(;n<0;)n+=this.original.length;let o="",s=this.firstChunk;for(;s&&(s.start>t||s.end<=t);){if(s.start<n&&s.end>=n)return o;s=s.next}if(s&&s.edited&&s.start!==t)throw new Error(`Cannot use replaced character ${t} as slice start anchor.`);const r=s;for(;s;){s.intro&&(r!==s||s.start===t)&&(o+=s.intro);const i=s.start<n&&s.end>=n;if(i&&s.edited&&s.end!==n)throw new Error(`Cannot use replaced character ${n} as slice end anchor.`);const a=r===s?t-s.start:0,c=i?s.content.length+n-s.end:s.content.length;if(o+=s.content.slice(a,c),s.outro&&(!i||s.end===n)&&(o+=s.outro),i)break;s=s.next}return o}snip(t,n){const o=this.clone();return o.remove(0,t),o.remove(n,o.original.length),o}_split(t){if(this.byStart[t]||this.byEnd[t])return;let n=this.lastSearchedChunk;const o=t>n.end;for(;n;){if(n.contains(t))return this._splitChunk(n,t);n=o?this.byStart[n.end]:this.byEnd[n.start]}}_splitChunk(t,n){if(t.edited&&t.content.length){const s=Gr(this.original)(n);throw new Error(`Cannot split a chunk that has already been edited (${s.line}:${s.column} \u2013 "${t.original}")`)}const o=t.split(n);return this.byEnd[n]=t,this.byStart[n]=o,this.byEnd[o.end]=o,t===this.lastChunk&&(this.lastChunk=o),this.lastSearchedChunk=t,!0}toString(){let t=this.intro,n=this.firstChunk;for(;n;)t+=n.toString(),n=n.next;return t+this.outro}isEmpty(){let t=this.firstChunk;do if(t.intro.length&&t.intro.trim()||t.content.length&&t.content.trim()||t.outro.length&&t.outro.trim())return!1;while(t=t.next);return!0}length(){let t=this.firstChunk,n=0;do n+=t.intro.length+t.content.length+t.outro.length;while(t=t.next);return n}trimLines(){return this.trim("[\\r\\n]")}trim(t){return this.trimStart(t).trimEnd(t)}trimEndAborted(t){const n=new RegExp((t||"\\s")+"+$");if(this.outro=this.outro.replace(n,""),this.outro.length)return!0;let o=this.lastChunk;do{const s=o.end,r=o.trimEnd(n);if(o.end!==s&&(this.lastChunk===o&&(this.lastChunk=o.next),this.byEnd[o.end]=o,this.byStart[o.next.start]=o.next,this.byEnd[o.next.end]=o.next),r)return!0;o=o.previous}while(o);return!1}trimEnd(t){return this.trimEndAborted(t),this}trimStartAborted(t){const n=new RegExp("^"+(t||"\\s")+"+");if(this.intro=this.intro.replace(n,""),this.intro.length)return!0;let o=this.firstChunk;do{const s=o.end,r=o.trimStart(n);if(o.end!==s&&(o===this.lastChunk&&(this.lastChunk=o.next),this.byEnd[o.end]=o,this.byStart[o.next.start]=o.next,this.byEnd[o.next.end]=o.next),r)return!0;o=o.next}while(o);return!1}trimStart(t){return this.trimStartAborted(t),this}hasChanged(){return this.original!==this.toString()}_replaceRegexp(t,n){function o(r,i){return typeof n=="string"?n.replace(/\$(\$|&|\d+)/g,(a,c)=>c==="$"?"$":c==="&"?r[0]:+c<r.length?r[+c]:`$${c}`):n(...r,r.index,i,r.groups)}function s(r,i){let a;const c=[];for(;a=r.exec(i);)c.push(a);return c}if(t.global)s(t,this.original).forEach(i=>{if(i.index!=null){const a=o(i,this.original);a!==i[0]&&this.overwrite(i.index,i.index+i[0].length,a)}});else{const r=this.original.match(t);if(r&&r.index!=null){const i=o(r,this.original);i!==r[0]&&this.overwrite(r.index,r.index+r[0].length,i)}}return this}_replaceString(t,n){const{original:o}=this,s=o.indexOf(t);return s!==-1&&this.overwrite(s,s+t.length,n),this}replace(t,n){return typeof t=="string"?this._replaceString(t,n):this._replaceRegexp(t,n)}_replaceAllString(t,n){const{original:o}=this,s=t.length;for(let r=o.indexOf(t);r!==-1;r=o.indexOf(t,r+s))o.slice(r,r+s)!==n&&this.overwrite(r,r+s,n);return this}replaceAll(t,n){if(typeof t=="string")return this._replaceAllString(t,n);if(!t.global)throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");return this._replaceRegexp(t,n)}}const xr=S(process.cwd(),"shared/translation.ts"),Br="globalThis.craneSharedTranslation = translation",pm=e=>`import translation from '${e}';
56
- ${Br};
57
- `,fm=(e,t)=>{const n=e.split("?")[0],o=Si(n);return(o==="server.ts"||o==="client.ts")&&!t.includes(Br)},Zr=()=>{let e=!1;return{name:"static-translation-plugin",enforce:"pre",apply:"build",buildStart(){e=V(xr)},transform(t,n){if(!e||!fm(n,t))return null;const o=n.split("?")[0],s=lo(o),r=vi(uo(s,xr)),i=pm(r),a=new ao(t);return a.prepend(i),{code:a.toString()}}}},Hr={[ee.Server]:()=>[pe.vue(),pe.tsconfigPaths(),em(),Xh(),Zr()],[ee.Client]:()=>[pe.vue(),pe.tsconfigPaths(),_o({vue:"EcVue"}),Zr()],[ee.Misc]:()=>[pe.tsconfigPaths()],[ee.Layout]:()=>[pe.vue(),pe.tsconfigPaths(),_o({vue:["EcExternals","Vue"]})],[ee.Asset]:()=>[tm()],[ee.SharedFiles]:()=>[pe.tsconfigPaths()]},Vr={[N.Server]:jr({outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/main/server`}),[N.Client]:Ur({outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/main/client`}),[N.SectionSetting]:Ke({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/settings`}),[N.SectionShowcase]:Ke({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/showcases`}),[N.SectionAsset]:Jt({outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/assets`}),[N.TemplateDescriptor]:Ke({entryFileNames:"[name].mjs",outDir:()=>`./${Te}/js`}),[N.PageTemplateDescriptor]:Ke({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${Te}/${e}`}),[N.TemplateAsset]:Jt({outDir:()=>`./${Te}/assets`}),[N.Layout]:Bh({outDir:({name:e,sectionId:t})=>`./${Q}/${t}/${e}`}),[N.LayoutSettings]:Ke({entryFileNames:"[name].mjs",outDir:({name:e,sectionId:t})=>`./${Q}/${t}/${e}/js/settings`}),[N.LayoutAsset]:Jt({outDir:({name:e,sectionId:t})=>`./${Q}/${t}/${e}/assets`}),[N.SlotServer]:jr({outDir:({name:e,layoutId:t,sectionId:n})=>`./${Q}/${n}/${t}/slots/${e}/js/main/server`}),[N.SlotClient]:Ur({outDir:({name:e,layoutId:t,sectionId:n})=>`./${Q}/${n}/${t}/slots/${e}/js/main/client`}),[N.CollectionDescriptor]:Ke({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${it}/${e}`}),[N.CollectionAsset]:Jt({outDir:()=>`./${it}/assets`}),[N.SharedTranslation]:{pluginType:ee.SharedFiles,ssr:!1,inlineDynamicImports:!0,entryFileNames:"translation.mjs",outDir:()=>"./dist/shared"}};function hm(e){switch(typeof e){case"string":return[S(process.cwd(),e)];case"object":return e.map(t=>S(process.cwd(),t));default:return[]}}function Wr({name:e,entryPoints:t,configType:n,layoutId:o,sectionId:s,sectionType:r=ye.SECTION}){const i=Vr[n],a=i.define,c=i.ssrOptions,l=i.entryFileNames,d=i.chunkFileNames,m=i.assetFileNames,y=i.inlineDynamicImports,T=i.externalOption;return{logLevel:Xn()?void 0:"silent",plugins:Hr[i.pluginType](),ssr:c,define:a,resolve:{alias:{"@":"/src"}},build:{ssr:i.ssr,outDir:i.outDir({name:e,sectionType:r,layoutId:o,sectionId:s}),emptyOutDir:!0,minify:i.ssr?"terser":"esbuild",...i.ssr&&{terserOptions:{mangle:{reserved:["gc"]}}},rollupOptions:{external:T,preserveEntrySignatures:"strict",input:hm(t),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:y,entryFileNames:l,chunkFileNames:d,assetFileNames:m}}},assetsInclude:["**/*.json"]}}const mm=Object.values(G).map(e=>e.source).join("|");function Yr(e,t,n){if(!e)return`${t}.mjs`;const o=uo(process.cwd(),e).replace(/\\/g,"/").match(`^(${mm})/([^/]+)/${n}/([^/.]+)`);return o?`${o[1]}/${o[2]}/js/${n}/${o[3]}.mjs`:`${t}.mjs`}function Kr(e,t){const n=Vr[N.SectionSetting];return{logLevel:Xn()?void 0:"silent",plugins:Hr[n.pluginType](),define:n.define,resolve:{alias:{"@":"/src"}},css:{preprocessorOptions:{scss:{api:"modern-compiler"}}},build:{ssr:n.ssr,outDir:"./dist",emptyOutDir:!1,minify:"esbuild",rollupOptions:{external:n.externalOption,preserveEntrySignatures:"strict",input:e.map(o=>S(process.cwd(),o)),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:n.inlineDynamicImports,entryFileNames:t,chunkFileNames:"chunks/[name]-[hash].js",assetFileNames:n.assetFileNames}}},assetsInclude:["**/*.json"]}}function Em(e){return Kr(e,t=>Yr(t.facadeModuleId??void 0,t.name,"settings"))}function gm(e){return Kr(e,t=>Yr(t.facadeModuleId??void 0,t.name,"showcases"))}async function _m(){const e={ignore:["node_modules/**","dist/**"]},t=await I(`./${Ze}/{product,category,catalog}/*/client.{js,ts}`,e);return await Promise.all(t.map(async n=>{const{id:o,sectionId:s,pageId:r}=$h(n),[i,a]=await Promise.all([I(`./${Ze}/${s}/${o}/settings/{content,design,translations,layout}.{js,ts}`,e),I(`./${Ze}/${s}/${o}/assets/*`,e)]);return{name:o,sectionId:s,pageId:r,clientEntrypoint:n,settingsEntryPoints:i,assetsEntrypoints:a}}))}async function ym(e){await re({entryPoints:[e.clientEntrypoint],configType:N.Layout,name:e.name,sectionId:e.sectionId}),await Promise.all([re({entryPoints:e.settingsEntryPoints,configType:N.LayoutSettings,name:e.name,sectionId:e.sectionId}),re({entryPoints:e.assetsEntrypoints,configType:N.LayoutAsset,name:e.name,sectionId:e.sectionId})])}async function Sm(e){e===void 0||e.length===0||await Promise.all(e.map(t=>ym(t)))}async function Tm(e){const t=e.flatMap(o=>o.settingsEntryPoints),n=e.flatMap(o=>o.showcaseEntryPoints);t.length>0&&await ge({configFile:!1,...mt(Em(t))}),n.length>0&&await ge({configFile:!1,...mt(gm(n))})}async function Om(e){await Promise.all([ge({configFile:!1,...mt(Wr({name:e.name,entryPoints:e.serverEntrypoint,configType:Ve.Server,sectionType:e.type}))}),re({entryPoints:e.clientEntrypoint,configType:Ve.Client,name:e.name,sectionType:e.type}),re({entryPoints:e.assetEntryPoints,configType:Ve.SectionAsset,name:e.name,sectionType:e.type})])}async function Im(){const e=S(process.cwd(),"shared/translation.ts");V(e)&&await re({entryPoints:["shared/translation.ts"],configType:Ve.SharedTranslation})}async function Jr(e){await Promise.all([Tm(e),...e.map(Om)])}function wm(e){const t=Yt(e).split("/");if(t.length<4||t[2]!=="slots")throw new Error(`Invalid slot path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/slots/{slotId}/[...path]`);const[n,o,,s]=t;if(!Pr(n))throw new Error(`Slot cannot be placed in a non-storefront section: ${n}`);return{id:s,sectionId:n,layoutId:o}}async function vm(e,t){return Promise.all(e.map(async n=>{const o=t.find(a=>a.id===n.layoutId&&a.sectionId===n.sectionId),s=await at(o?.translationsSettings),r=await Wn(o?.content??{},s),i=await Yn(o?.design??{},s);return{id:n.id,sectionId:n.sectionId,layoutId:n.layoutId,contentEditors:r,designEditors:i}}))}async function Cm(){const e={ignore:["node_modules/**","dist/**"]},t=await I(`${Ze}/{product,category,catalog}/*/slots/*/server.ts`,e);return Promise.all(t.map(async n=>{const{id:o,sectionId:s,layoutId:r}=wm(n),i=(await I(`${Ze}/${s}/${r}/slots/${o}/client.{js,ts}`,e))[0];if(i===void 0)throw new Error(`Cannot find client entrypoint file for slot ${o} of section ${s}`);return{id:o,sectionId:s,layoutId:r,serverEntrypoint:n,clientEntrypoint:i}}))}async function Rm(e){const t={name:e.id,layoutId:e.layoutId,sectionId:e.sectionId};await Promise.all([re({entryPoints:[e.serverEntrypoint],configType:N.SlotServer,...t}),re({entryPoints:[e.clientEntrypoint],configType:N.SlotClient,...t})])}async function bm(e){e?.length&&await Promise.all(e.map(Rm))}async function Am(e){return(await I(`**/${e}/pages/*.{js,ts}`,{ignore:["node_modules/**","dist/**"]})).filter(t=>{const n=po(t).name.toLowerCase();return!Object.values(Cs).includes(n)})}async function Nm(){const e=await I("./templates/*",{ignore:["templates/assets/**","templates/**.{js,ts}","node_modules/**","dist/**"]}).catch(t=>(f.error(`Error while getting page template entry points: ${t}`),[]));return Promise.all(e.map(async t=>{const n=t.split(cn),o=n.pop()??"default";if(n.pop()===void 0)throw new Error("Cannot determine template with custom pages, outer directory is undefined");const s=await I(`**/templates/${o}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),r=await I(`**/templates/${o}/pages/home.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await I(`**/templates/${o}/pages/category.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),a=await I(`**/templates/${o}/pages/catalog.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),c=await I(`**/templates/${o}/pages/product.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),l=await Am(o);return{name:o,configurationEntrypoint:s.at(0),homeEntrypoint:r.at(0),categoryEntrypoint:i.at(0),catalogEntrypoint:a.at(0),productEntrypoint:c.at(0),customEntrypoint:l.length>0?l:void 0}}))}async function $m(){const e=await I("./templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]}),t=await I("./templates/assets/*",{ignore:["node_modules/**","dist/**"]});return{pageTemplates:await Nm(),templates:e,assets:t}}async function Lm({templateBuildConfig:e}){await Promise.all([re({entryPoints:e.assets,configType:Ve.TemplateAsset}),...e.pageTemplates?.map(async t=>{const n=[t.configurationEntrypoint,t.homeEntrypoint,t.categoryEntrypoint,t.catalogEntrypoint,t.productEntrypoint,...t.customEntrypoint??[]].filter(Ht);if(n.length===0)throw new Error("No entry points provided for page template");await re({entryPoints:n,configType:Ve.PageTemplateDescriptor,name:t.name})})||[]])}async function Dm(){const e=await $m();await Lm({templateBuildConfig:e})}async function km(){const e=await I("./collections/*",{ignore:["collections/assets/**","collections/**.{js,ts}","node_modules/**","dist/**"]}).catch(n=>(f.error(`Error while getting collection entry points: ${n}`),[])),t=await I("./collections/assets/*",{ignore:["node_modules/**","dist/**"]});return Promise.all(e.map(async n=>{const o=n.split(cn),s=o.pop()??"default";if(o.pop()===void 0)throw new Error("Cannot determine collection, outer directory is undefined");const r=await I(`**/collections/${s}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]});return{name:s,configurationEntrypoint:r.at(0),assetsEntrypoints:t}}))}async function Pm(){const e=await km();e.length!==0&&await Promise.all(e.flatMap(t=>[re({entryPoints:t.assetsEntrypoints,configType:N.CollectionAsset,name:t.name}),re({entryPoints:t.configurationEntrypoint?[t.configurationEntrypoint]:[],configType:N.CollectionDescriptor,name:t.name})]))}function Xr(e){return{name:e.name,type:e.type,serverEntrypoint:e.serverEntrypoint,clientEntrypoint:[e.clientEntrypoint].filter(Ht).flat(),settingsEntryPoints:[e.contentSettingsEntrypoint,e.designSettingsEntrypoint,e.layoutSettingsEntrypoint,e.settingsTranslationsEntrypoint].filter(Ht),showcaseEntryPoints:[...e.showcasesEntrypoints??[],e.showcasesTranslationsEntrypoint].filter(Ht),assetEntryPoints:e.assetsEntrypoints??[]}}function Qr(e){return e.map(t=>({...t,selectedDesignSettings:t.selectedDesignSettings.map(n=>{const o=n.defaults;return o&&typeof o=="object"&&!("type"in o)?{...n,defaults:{type:n.type,...o}}:n})}))}async function zm(e,t=me){const n=S(process.cwd(),`${t}/${e}/js/main/server/server.js.gz`),o=yo(So.gunzip),s=await C.promises.readFile(n);return{size:(await o(s)).length}}async function jm(e,t=me){try{const n=S(process.cwd(),`${t}/${e}/assets/`);return(await I("*",{cwd:n})).map(o=>{const s=S(n,o);return{path:o,size:Qe(s).size}})}catch{throw new Error(`Asset files for section [${e}] is either invalid or undefined`)}}async function Qn(e,t){const n=await dh(e,G[t].dist),o=await Wt(e,G[t].dist),s=await fh(e,G[t].dist),r=await hh(e,G[t].dist),i=await Eh(e,G[t].dist),a=await gh(e,G[t].dist),c=Qr(a),l=await jm(e,G[t].dist),d=await zm(e,G[t].dist),m=_h(e);return{id:e,type:t,name:e,content:s,design:r,layout:c,showcase:i,translationsSettings:n,translationsShowcases:o,assets:l,server:d,previewCount:m}}async function Um(){const e=await I("*/",{cwd:S(process.cwd(),`${me}/`)}),t=await I("*/",{cwd:S(process.cwd(),`${Gn}/`)}),n=await I("*/",{cwd:S(process.cwd(),`${xn}/`)});return Promise.all([...e.map(async o=>Qn(o,Ae.SECTION)),...t.map(async o=>Qn(o,Ae.HEADER)),...n.map(async o=>Qn(o,Ae.FOOTER))])}async function Fm(e){try{const t=S(process.cwd(),`${e}/assets/`);return(await I("*",{cwd:t})).map(n=>{const o=S(t,n);return{path:n,size:Qe(o).size}})}catch{throw new Error("Asset files for layouts are either invalid or undefined")}}async function Mm(e){const t=Yt(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,o]=t,[s,r,i,a,c]=await Promise.all([xm(o,n),Bm(o,n),ph(o,n),Fm(e),Zm(o,n)]);return{id:o,sectionId:n,content:s,design:r,translationsSettings:i,assets:a,layouts:c}}async function Gm(){const e=`${Q}/{product,catalog,category}/*`,t=await I(e,{ignore:["node_modules/**"]});return Promise.all(t.map(Mm))}async function xm(e,t){try{const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/content.mjs`),o=await se(n);return Be(o)}catch(n){throw new Error(`Content descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function Bm(e,t){try{const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/design.mjs`),o=await se(n);return Be(o)}catch(n){throw new Error(`Design descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function Zm(e,t){try{const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/layout.mjs`);if(!C.existsSync(n))return[];const o=await se(n);return Qr(o)}catch(n){throw new Error(`Layout settings descriptor for layout [${e}] in section [${t}] is either invalid or undefined: ${n}`)}}async function Hm(e,t,n){const o=S(process.cwd(),`${Q}/${n}/${t}/slots/${e}/js/main/server/server.js.gz`),s=yo(So.gunzip),r=await C.promises.readFile(o);return{size:(await s(r)).length}}async function Vm(e){const t=Yt(e).split("/");if(t.length<4||t[2]!=="slots")throw new Error(`Invalid slot path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/slots/{slotId}/[...path]`);const[n,o,,s]=t,r=await Hm(s,o,n);return{id:s,sectionId:n,layoutId:o,server:r}}async function Wm(){const e=`${Q}/{product,catalog,category}/*/slots/*`,t=await I(e,{ignore:["node_modules/**"]});return await Promise.all(t.map(Vm))}async function Ym(){try{const e=S(process.cwd(),`${Te}/assets/`);return(await I("*",{cwd:e})).map(t=>{const n=S(e,t);return{path:t,size:Qe(n).size}})}catch{throw new Error("Asset files for templates are either invalid or undefined")}}function Km(e){return e in Ne?Ne[e]:Ne.CUSTOM}async function Jm(e){const t=await I(`${Te}/${e}/*.mjs`,{ignore:[`${Te}/${e}/configuration*.mjs`]});return Promise.all(t.map(async n=>{const{sections:o,metadata:s}=await qn(n),r=Gf(n);return{type:Km(r.toUpperCase()),id:r,metadata:s,sections:o}}))}async function qn(e){try{return await se(S(process.cwd(),e))}catch{throw new Error(`Template file [${e}] is either invalid or undefined`)}}async function Xm(e){const t=await I(`${Te}/**/configuration*.mjs`,{});return Promise.all(t.map(async n=>{const o=z.basename(z.dirname(n));return{id:`${e}_${o}`,assets:await Ym(),configuration:await qn(n),pages:await Jm(o)}}))}async function Qm(e){return await Xm(e)}async function qm(){const e=S(process.cwd(),`${zf}/translation.mjs`);return await se(e)}async function eE(){return{translations:await qm()}}async function tE(e){const t=await I(`${it}/*/configuration*.mjs`,{ignore:["node_modules/**",`${it}/assets/**`]});return Promise.all(t.map(async n=>{const o=z.basename(z.dirname(n)),s=await qn(n);return{id:`${e}_${o}`,descriptor:s}}))}async function qr(){const e=await Vt(),[t,n,o,s,r,i,a]=await Promise.all([Jn(),eE(),Um(),Gm(),Wm(),Qm(e.appClientId),tE(e.appClientId)]);return{version:t.version,name:"Custom Block App",shared:n,sections:o,templates:i,layouts:s,slots:r,collections:a,compressionEnabled:!0,externalizationEnabled:!0,vueVersion:t.dependencies.vue,openSource:t.openSource}}function eo(e){return V(`${Gn}/${e}`)?ye.HEADER:V(`${xn}/${e}`)?ye.FOOTER:ye.SECTION}async function to(e,t){const n=e.design?Vn(e.design):void 0,o={...e,design:n??e.design},s=await at(t);return He(o,s)}function no(e){return e.type==="custom"&&e.id!==void 0&&e.showcase_overrides!==void 0}async function ei(e){if(no(e)){const t=await Wt(e.id,G[eo(e.id)].dist);return{...e,showcase_overrides:await to(e.showcase_overrides,t)}}return e}async function nE(e){const t=no(e.header)?{...e.header,showcase_overrides:await to(e.header.showcase_overrides,await Wt(e.header.id,G[eo(e.header.id)].dist))}:e.header,n=no(e.footer)?{...e.footer,showcase_overrides:await to(e.footer.showcase_overrides,await Wt(e.footer.id,G[eo(e.footer.id)].dist))}:e.footer;return{...e,header:t,footer:n}}async function oE(e){const t=await Promise.all(e.pages.map(async o=>({...o,sections:await Promise.all(o.sections.map(s=>ei(s)))}))),n=await nE(e.configuration);return{id:e.id,descriptor:{...n,pages:t}}}async function sE(e){return Promise.all(e.map(t=>oE(t)))}async function rE(e){const t=new Map;return await Promise.all(e.map(async n=>{const[o,s]=await Promise.all([at(n.translationsSettings),at(n.translationsShowcases)]);t.set(n.id,{settings:o,showcases:s})})),t}async function iE(e,t,n){const[o,s,r,i]=await Promise.all([Wn(e.content,t,e.type),Yn(e.design,t,e.type),mh(e.showcase,n),Lr(e.layout)]);return{id:e.id,type:e.type,name:{en:e.name},contentEditors:o,designEditors:s,layouts:i,showcases:r,previewCount:e.previewCount}}async function aE(e,t){return Promise.all(e.map(async n=>{const o=t.get(n.id)??{settings:{},showcases:{}};return iE(n,o.settings,o.showcases)}))}async function cE(e){return Promise.all(e.map(async t=>{const n=await Promise.all(t.descriptor.sections.map(o=>ei(o)));return{...t,descriptor:{...t.descriptor,sections:n}}}))}async function ti(e){const t=await rE(e.sections),[n,o,s,r,i]=await Promise.all([aE(e.sections,t),Lh(e.layouts),vm(e.slots,e.layouts),sE(e.templates),cE(e.collections)]);return{version:e.version,name:e.name,blocks:n,templates:r,layouts:o,slots:s,compressionEnabled:e.compressionEnabled,externalizationEnabled:e.externalizationEnabled,vueVersion:e.vueVersion,collections:i,openSource:e.openSource}}async function lE(e){const t=S(Et.cwd(),Ar);return bi(t,JSON.stringify(e))}function uE(e){return Object.entries(G).find(t=>t[1].source===e)?.[0]}async function ni(){const e=await I("**/server.{js,ts}",{ignore:["node_modules/**","dist/**","templates/**","layouts/**","collections/**"]});return Promise.all(e.map(async t=>{const n=lo(t).split(cn),o=n.pop()??"default",s=n.pop();if(s===void 0)throw new Error("Cannot determine type of section, outer directory is undefined");const r=["node_modules/**","dist/**"],[i,a,c,l,d,m,y,T]=await Promise.all([I(`**/${o}/client.{js,ts}`,{ignore:r}),I(`**/${o}/settings/content.{js,ts}`,{ignore:r}),I(`**/${o}/settings/design.{js,ts}`,{ignore:r}),I(`**/${o}/settings/layout.{js,ts}`,{ignore:r}),I(`**/${o}/settings/translations.{js,ts}`,{ignore:r}),I(`**/${o}/showcases/*.{js,ts}`,{ignore:[...r,`**/${o}/showcases/translations.{js,ts}`]}),I(`**/${o}/showcases/translations.{js,ts}`,{ignore:r}),I(`**/${o}/assets/*`,{ignore:r})]);return{name:o,type:uE(s),serverEntrypoint:t,clientEntrypoint:i.at(0),contentSettingsEntrypoint:a.at(0),designSettingsEntrypoint:c.at(0),layoutSettingsEntrypoint:l.at(0),settingsTranslationsEntrypoint:d.at(0),showcasesEntrypoints:m,showcasesTranslationsEntrypoint:y.at(0),assetsEntrypoints:T}}))}const dE=["/settings/","/showcases/"];function pE(e){return dE.some(t=>e.includes(t))}function fE(){const e=le.findConfigFile(process.cwd(),le.sys.fileExists,"tsconfig.json");if(!e)return;const t=le.readConfigFile(e,le.sys.readFile),n=le.parseJsonConfigFileContent(t.config,le.sys,process.cwd()),o=le.createProgram(n.fileNames,n.options),s=le.getPreEmitDiagnostics(o).filter(r=>!r.file||!pE(r.file.fileName));if(s.length>0){const r={getCanonicalFileName:i=>i,getCurrentDirectory:le.sys.getCurrentDirectory,getNewLine:()=>le.sys.newLine};throw console.error(le.formatDiagnosticsWithColorAndContext(s,r)),new Error(`TypeScript found ${s.length} error(s)`)}}async function hE(e){fE(),await ge({configFile:!1,logLevel:"error",plugins:[pe.vue(),pe.tsconfigPaths(),pe.checker()],build:{write:!1,rollupOptions:{input:S(process.cwd(),e)}}})}function mE(){return Promise.all([rn.rm("dist",{recursive:!0,force:!0}),rn.rm("source-code",{recursive:!0,force:!0}),rn.rm("source-code.zip",{force:!0})])}async function EE(){const e=new fo,t=["node_modules/**/*","dist/**/*","build/**/*",".git/**/*","**/assets/**/*","crane.config.json"];(await Jn()).openSource===!0&&t.splice(t.indexOf("**/assets/**/*"),1);const n=await I("**/*",{cwd:S(process.cwd()),ignore:t,dot:!0,nodir:!0});try{n.forEach(r=>{const i=S(process.cwd(),r);e.addLocalFile(i,po(r).dir)});const o=lt[R.SourceCode].fileName,s=S(process.cwd(),o);await e.writeZipPromise(s)}catch(o){throw f.error("Error while zipping source files"),o}}async function Qt(e=!1,t=!1){Zh(t),Mr.start(),await mE();try{const[n,o,s]=await Promise.all([_m(),ni(),Cm()]),r=o.map(Xr);o.length>0&&await hE(o[0].serverEntrypoint);try{await Promise.all([Im(),Jr(r),Dm(),Pm(),Sm(n),bm(s),EE()])}finally{Mr.stop()}const i=await qr(),a=await Uh(i);Mh(a,e);const c=await ti(i);await lE(c)}catch(n){f.error(`Error while building: ${n.message}`),e||process.exit(1)}}async function re({entryPoints:e,configType:t,name:n,sectionType:o,sectionId:s,layoutId:r}){if(e.length!==0){const i=mt(Wr({name:n,entryPoints:e,configType:t,sectionType:o,sectionId:s,layoutId:r}));await ge({configFile:!1,...i})}}function oi(e,t,n){ft.statSync(e).isDirectory()?(ft.mkdirSync(t,{recursive:!0}),ft.readdirSync(e).forEach(o=>{const s=ht.resolve(e,o),r=ht.resolve(t,o);oi(s,r,n)})):zi.isMatch(e,n,{dot:!0})||ft.copyFileSync(e,t)}function Oe(e,t,n,o,s=[]){const r=ht.join(e,o?.[n]??n);oi(ht.join(t,n),r,s)}function gE(e){return{renameFiles:{"example-template":`${e}`},targetPath:e,sourcePath:"template/page-templates",onTemplateCreated:()=>f.info(`Template [${e}] with pages structure named has been created`)}}function Ee(e){return W.resolve(ji(import.meta.url),"../..",e)}function _E(){const e=Ee("package.json");return e!==""?JSON.parse(L.readFileSync(e,"utf8")):{}}async function yE(e){try{const t=e,n=j.cwd(),o=W.join(n,t),s=["templates","headers","preview","footers","reference","page-templates","layouts","collections","blank"],r={_gitignore:".gitignore"};L.existsSync(o)?(f.error(`App with the name: ${e} already exists. If you'd like to override it, delete previous version first`),j.exit(1)):L.mkdirSync(o);const i=Ee("template");L.readdirSync(i).filter(d=>d!=="package.json").filter(d=>!s.includes(d)).forEach(async d=>Oe(o,i,d,r));const a=JSON.parse(L.readFileSync(W.join(i,"package.json"),"utf-8"));a.name=e;const c=_E();c.version&&(a.dependencies["@lightspeed/crane-api"]=c.dependencies["@lightspeed/crane-api"]),c.dependencies["@lightspeed/eslint-config-crane"]&&(a.dependencies["@lightspeed/eslint-config-crane"]=c.dependencies["@lightspeed/eslint-config-crane"]);const l=W.join(o,"package.json");L.writeFileSync(l,`${JSON.stringify(a,null,2)}
58
- `),f.info(`App ${e} created`)}catch(t){f.error(`Error while creating app: ${t.message}`),j.exit(1)}}function oo(e,t,n,o){try{const s=j.cwd(),r=z.join(s,t);C.existsSync(r)||C.mkdirSync(r);const i=z.join(s,t,n);C.existsSync(i)?(f.error(`${o} with the name: ${n} already exists. If you'd like to override it, delete previous version first`),j.exit(1)):C.mkdirSync(i);const a=Ee(e);C.readdirSync(a).forEach(async c=>Oe(i,a,c)),f.info(`${o} ${n} created`)}catch(s){f.error(`Error while creating ${o}: ${s.message}`),j.exit(1)}}function so(e){const t=j.cwd(),n=Ee(`template/${e}`),o=z.join(t,e);C.existsSync(o)||(C.mkdirSync(o),C.readdirSync(n).forEach(async s=>Oe(o,n,s)))}async function SE(e,t,n,o){if(!C.existsSync(n)){C.copyFileSync(t,n);return}const s=C.readFileSync(t),r=C.readFileSync(n);s.equals(r)||(o?(await Pe({type:"select",name:"value",message:`File "${e.name}" exists but differs from template. What would you like to do?`,choices:[{title:"Keep existing file",value:"keep"},{title:"Replace with template version",value:"replace"}],initial:0})).value==="replace"?(C.copyFileSync(t,n),f.info(`Replaced "${e.name}" with template version.`)):f.info(`Kept existing "${e.name}".`):f.warn(`File "${e.name}" exists but differs from template. File will be skipped, this may lead to issues.`))}async function qt(e,t,n=!1){async function o(r,i,a){const c=z.join(i,r.name),l=z.join(a,r.name);r.isDirectory()?await qt(c,l,n):await SE(r,c,l,n)}const s=C.readdirSync(e,{withFileTypes:!0});C.existsSync(t)||C.mkdirSync(t,{recursive:!0}),await s.reduce(async(r,i)=>(await r,o(i,e,t)),Promise.resolve())}async function ro(e=!1){try{const t=j.cwd(),n=z.join(t,"shared"),o=Ee("template/shared");if(!C.existsSync(o))return;await qt(o,n,e)}catch(t){f.error(`Error while processing shared folder: ${t.message}`),j.exit(1)}}async function TE(e,t){await ro(),oo(`${`template${t?"/blank":""}`}/sections/${`${t?"blank-section":"example-section"}`}`,"sections",e,"Section")}function OE(e){return{renameFiles:{"example-collection":`${e}`},targetPath:e,sourcePath:"template/collections",onCollectionCreated:()=>f.info(`Collection [${e}] has been created`)}}async function IE(e){const{targetPath:t,renameFiles:n,sourcePath:o,onCollectionCreated:s}=OE(e);try{const r=j.cwd(),i=W.join(r,"collections"),a=Ee(o),c=L.readdirSync(a);L.existsSync(i)?L.existsSync(W.join(i,t))&&(f.error(`Collection with the name: ${e} already exists. If you'd like to override it, delete previous version first`),j.exit(1)):L.mkdirSync(i),c.forEach(l=>Oe(i,a,l,n)),s()}catch(r){f.error(`Error while creating collection: ${r.message}`),j.exit(1)}}async function wE(e){await ro(),oo("template/footers/example-footer","footers",e,"Footer")}async function vE(e){await ro(),oo("template/headers/example-header","headers",e,"Header")}async function CE(e,t){try{const n=j.cwd(),o=W.join(n,"templates"),s=Ee("template/page-templates/example-template/pages");L.existsSync(W.join(o,e))||(f.error(`Template with the name: [${e}] doesn't exists. Please create a template first.`),j.exit(1)),L.existsSync(W.join(o,e,"pages",`${t}.ts`))&&(f.error(`Page with the name: [${t}.ts] already exists. If you'd like to override it, delete previous version first`),j.exit(1));const r=L.readFileSync(W.join(s,"custom.ts"),"utf-8").replace(/title\s*:\s*'Custom Page'/,`title: '${xf(t)}'`),i=W.join(o,e,"pages",`${t}.ts`);L.writeFileSync(i,r),f.info(`Page [${t}.ts] created for template ${e}`)}catch(n){f.error(`Error while creating page: ${n.message}`),j.exit(1)}}async function RE(){try{const e=j.cwd(),t=Ee("template/reference"),n=L.readdirSync(t);let o=!1;for(const s of n){const r=W.join(t,s),i=W.join(e,s);L.existsSync(i)||L.mkdirSync(i,{recursive:!0});const a=L.readdirSync(r),c=L.readdirSync(i);if(s==="shared"){a.forEach(l=>{Oe(i,r,l)});continue}for(const l of a){if(l==="assets"){Oe(i,r,l);continue}if(c.includes(l)){const{name:d}=await Pe({type:"text",name:"name",message:`The "${l}" already exists in ${s} directory: provide a new name to keep both or press Esc to skip this one.`});d?(Oe(i,r,l,{[l]:d}),o=!0):f.info(`Skipped: ${l}`)}else Oe(i,r,l)}}f.info("Reference templates have been added to the app"),o&&f.warn("Some files or folders were renamed to avoid conflicts. Template files may need to be updated to reflect these changes.")}catch(e){f.error(`Error while creating template descriptors: ${e.message}`),j.exit(1)}}const bE=["**/example-template/pages/custom.ts"];async function AE(e){const{targetPath:t,renameFiles:n,sourcePath:o,onTemplateCreated:s}=gE(e);try{const r=j.cwd(),i=W.join(r,"templates"),a=Ee(o),c=L.readdirSync(a);L.existsSync(i)?L.existsSync(W.join(i,t))&&(f.error(`Template with the name: ${e} already exists. If you'd like to override it, delete previous version first`),j.exit(1)):L.mkdirSync(i),c.forEach(l=>Oe(i,a,l,n,bE)),so("headers"),so("footers"),so("layouts"),s()}catch(r){f.error(`Error while creating template descriptors: ${r.message}`),j.exit(1)}}function NE(){try{const e=S(Et.cwd(),`${br}/shared/analytics.json`);V(e)&&an(e,JSON.stringify({},null,2),"utf-8")}catch(e){console.warn("Can not clean up preview analytics.json file",e)}}function en({deploymentContext:e,sectionType:t=ye.SECTION}){const n=e.pathContext,o=n.toPath({sectionId:e.currentSection,sectionType:t,layoutId:e.layoutId,slotId:e.slotId}),s=o===void 0?ho(n.fileName):ho(n.fileName,{cwd:S(process.cwd(),o),ignore:n.ignore});return(n.isSingleton?s.splice(0):s).map(r=>({url:r,sectionType:t,context:e}))}const $E=e=>e.app.manifest.blocks.flatMap(t=>vh.flatMap(n=>{const o={config:e,currentSection:t.id,pathContext:lt[n]};return en({deploymentContext:o,sectionType:t.type})})),LE=e=>bh.flatMap(t=>{const n={config:e,pathContext:lt[t]};return en({deploymentContext:n})}),DE=e=>e.app.manifest.layouts.flatMap(t=>Ch.flatMap(n=>{const o={config:e,pathContext:lt[n],currentSection:t.sectionId,layoutId:t.id};return en({deploymentContext:o})})),kE=e=>e.app.manifest.slots.flatMap(t=>Rh.flatMap(n=>{const o={config:e,pathContext:lt[n],currentSection:t.sectionId,layoutId:t.layoutId,slotId:t.id};return en({deploymentContext:o})})),PE=e=>`\x1B[32m${e}\x1B[0m`,zE=(e,t,n,o,s)=>{if(!e.total)return;const{loaded:r}=e,i=(Date.now()-s)/1e3;n.value+=r-o.value,o.value=r,t.update({speed:`${Se(n.value/i,2)}/s`})},jE=()=>new Mi.SingleBar({format:`|${PE("{bar}")}| {status} || {percentage}% || {value}/{total} Files || Speed: {speed}`,barCompleteChar:"\u2588",barIncompleteChar:"\u2591"});async function si(e){await new Promise(t=>setTimeout(t,e))}const ri="Please ensure you have built your application before deploying.";async function UE(){try{const e=await ln(S(Et.cwd(),Ar));return JSON.parse(e.toString())}catch(e){throw e.code==="ENOENT"?new Error(`Manifest file not found. ${ri}`):e instanceof SyntaxError?new Error(`Manifest file is not valid. ${ri}`):e}}const FE={value:0},ie=jE();let ii=Date.now();const ai=e=>2**e*500;async function ME(e){const t=Fi(e.version,"patch");if(t===null)throw Error("Error while incrementing app version");e.version=t,an(S(F.cwd(),"package.json"),`${JSON.stringify(e,null,2)}
59
- `)}function GE(e){return e instanceof Eo&&(e.code==="ECONNRESET"||e.response?.status!==void 0&&e.response?.status>=500&&e.response?.status<600)}function ci(e,t){return e<wh&&GE(t)}async function li(e,t,n,o){const s={value:0},r=e.config.app.manifest.templates.length>0||e.config.app.manifest.collections.length>0?Sh:yh;return e.config.axios.post(r,{file:gi(S(F.cwd(),n!==void 0?n+t:t))},{params:{appClientId:e.config.app.crane.appClientId,type:e.pathContext.type,version:e.config.app.packageJson.version,...e.currentSection!==void 0&&{block:e.currentSection},...e.layoutId!==void 0&&{layoutId:e.layoutId},...e.slotId!==void 0&&{slotId:e.slotId},...!["dependencies","source_code"].includes(e.pathContext.type)&&{fileName:t}},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${e.config.app.crane.appSecretKey}`},onUploadProgress:i=>zE(i,ie,FE,s,ii)}).then(i=>(ie.increment(),i)).catch(async i=>{if(ci(o,i))return await si(ai(o)),li(e,t,n,o+1);throw ie.increment(),i})}function xE(e){return ie.start(e.length+1,0,{speed:"N/A",status:"Deployment in progress"}),e.map(t=>{const n=t.context,o=n.pathContext.toPath({sectionId:n.currentSection,sectionType:t.sectionType,layoutId:n.layoutId,slotId:n.slotId});return li(n,t.url,o,0)})}function BE(e){const t=[...$E(e),...LE(e),...DE(e),...kE(e)];return xE(t)}async function ui(e,t=0){const n=e.app.manifest.templates.length>0||e.app.manifest.collections.length>0?Oh:Th;return e.axios.post(n,e.app.manifest,{params:{appClientId:e.app.crane.appClientId},headers:{Authorization:`Bearer ${e.app.crane.appSecretKey}`}}).catch(async o=>{if(ci(t,o))return await si(ai(t)),ui(e,t+1);throw o})}async function ZE(e){try{if(!jf.some(i=>V(S(F.cwd(),i))))throw new Error(We.INCORRECT_DISTRIBUTION_FOLDER(Pf));const t=e??Kn;f.info("Custom application deployment :: Started");const n=un.create({baseURL:t});Ui(n,Ih),f.info("Loading configuration files ...");const o=await Promise.all([Vt(),Jn(),UE()]).then(([i,a,c])=>({axios:n,app:{crane:i,packageJson:a,manifest:c}}));f.info("Uploading files ..."),ii=Date.now(),await Promise.all(BE(o)).catch(i=>{ie.stop(),i.response?.status===404?f.error(Le(i,We.DEPRECATED_VERSION_DEPLOYMENT)):f.error(Le(i,We.ASSET_FILES_UPLOAD)),F.exit(1)}).finally(()=>{ie.increment(),ie.stop()}),ie.update({speed:"N/A",status:"Finalising deployment"}),await ui(o).catch(i=>{ie.stop(),i.response?.status===404?f.error(Le(i,We.DEPRECATED_VERSION_DEPLOYMENT)):f.error(Le(i,We.MANIFEST_DEPLOYMENT)),F.exit(1)}).finally(()=>{ie.increment(),ie.stop()});const s=o.app.manifest.blocks.map(i=>i.id),r=o.app.packageJson.version;f.info("Custom application deployment :: Successful"),f.info(`Current app version: ${r}`),f.info(`Deployed sections: ${s.sort().join(", ")}`),await ME(o.app.packageJson),o.app.manifest.templates.length>0&&f.info(`Deployed templates: ${o.app.manifest.templates.map(i=>i.id).sort().join(", ")}`),o.app.manifest.slots.length>0&&f.info(`Deployed slots: ${o.app.manifest.slots.map(i=>i.id).sort().join(", ")}`),o.app.manifest.collections.length>0&&f.info(`Deployed collections: ${o.app.manifest.collections.map(i=>i.id).sort().join(", ")}`)}catch(t){ie.stop(),f.error(Le(t,We.DEFAULT)),F.exit(1)}finally{NE()}}function HE(){process.env.CRANE_DEBUG_ENABLED="true"}function VE(){return process.env.CRANE_DEBUG_ENABLED==="true"}function WE(e,...t){VE()&&console.debug(wi(`[DEBUG] ${e}`),...t)}function YE(){return{name:"app-block-api",configureServer(e){e.middlewares.use(async(t,n,o)=>{e.moduleGraph.invalidateAll();const s=new Ai(t.url||"",`http://${t.headers.host}`);if(s.pathname==="/api/v1/block-config"&&t.method==="GET"){const r=s.searchParams.get("section");if(!r){n.statusCode=400,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({error:"Missing blockId parameter"}));return}try{const i=await qr(),a=(await ti(i)).blocks.find(c=>c.id===r);n.statusCode=200,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify(a))}catch(i){n.statusCode=500,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({error:i.message}))}return}o()})}}}let ke=null;function KE(){ke&&ke.clients.forEach(e=>{e.readyState===xi.OPEN&&e.send(JSON.stringify({type:"full-reload"}))})}async function JE(e,t){const n=S(`${e}/ssr-server.ts`),o=S(t);await ge({build:{lib:{entry:n,formats:["es"],fileName:()=>"ssr-server.mjs"},outDir:o,emptyOutDir:!1,minify:!1,rollupOptions:{external:["http","fs","@swc/core","module-from-string","linkedom"],output:{entryFileNames:"ssr-server.mjs"}},target:"esnext"}})}async function XE(e,t){const n=S(`${e}/shared/preview.ts`),o=S(`${e}/shared/utils.ts`),s=S(`${e}/shared/api-routes.ts`),r=S(t);await ge({build:{lib:{entry:n,formats:["es"],fileName:()=>"preview.js"},outDir:r,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"preview.js"}},target:"esnext"}}),await ge({build:{lib:{entry:o,formats:["es"],fileName:()=>"utils.js"},outDir:r,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"utils.js"}},target:"esnext"}}),await ge({build:{lib:{entry:s,formats:["es"],fileName:()=>"api-routes.js"},outDir:r,emptyOutDir:!1,minify:!1,rollupOptions:{external:["path","fs","http","https","url","stream","util","events","buffer"],output:{entryFileNames:"api-routes.js"}},target:"esnext"}})}async function QE(){const e="preview",t=`${e}/shared`,n="vite.config.js",o=`${e}/sections`,s=`${o}/preview.html`;[e,o].forEach(c=>{C.existsSync(c)||C.mkdirSync(c,{recursive:!0})});const r=Ee("template/preview");C.copyFileSync(`${r}/${n}`,`${e}/${n}`),await JE(r,e),C.copyFileSync(`${r}/sections/preview.html`,s);const i=`${r}/assets`,a=`${e}/assets`;C.existsSync(i)&&(C.mkdirSync(a,{recursive:!0}),C.readdirSync(i).forEach(c=>{C.copyFileSync(`${i}/${c}`,`${a}/${c}`)})),C.existsSync(t)||C.mkdirSync(t),await XE(r,t)}function qE(e){const t=e.replace(/\\/g,"/").match(/(?:sections|headers|footers)\/([^/]+)/);return t?t[1]:null}function eg(e){const t=e.replace(/\\/g,"/");return t.includes("shared")&&!t.includes("sections")&&!t.includes("headers")&&!t.includes("footers")}async function tg(e){const t=(await ni()).find(o=>o.name===e);if(!t){console.warn(`Block ${e} not found, falling back to full build`),await Qt(!0);return}const n=Xr(t);await Jr([n]),console.log(`Block ${e} rebuilt successfully`)}var ng=(e=>(e.FULL="full",e.INCREMENTAL="incremental",e))(ng||{});function og(){return{timeout:null,inProgress:!1,pendingBuild:null}}function sg(e,t){const n=async o=>{e.inProgress=!0;try{o.type==="incremental"&&o.blockName?await tg(o.blockName):await Qt(!0),t.ws.send({type:"full-reload",path:"*"}),KE()}catch(s){console.error("Build error:",s)}finally{if(e.inProgress=!1,e.pendingBuild){const s=e.pendingBuild;e.pendingBuild=null,setTimeout(()=>n(s),0)}}};return async o=>{if(e.inProgress){o.type==="full"||e.pendingBuild?.type==="full"?e.pendingBuild={type:"full"}:e.pendingBuild=o;return}await n(o)}}function rg(e){const t=e.replace(/\\/g,"/"),n=t.match(/sections\/([^/]+)/),o=t.match(/headers\/([^/]+)/),s=t.match(/footers\/([^/]+)/),r=t.match(/shared\//);return!!(n||o||s||r)}function ig(e,t){return async n=>{if(!rg(n))return;e.timeout&&clearTimeout(e.timeout);const o=qE(n),s=eg(n);e.timeout=setTimeout(async()=>{s?await t({type:"full"}):o&&await t({type:"incremental",blockName:o})},1e3)}}function ag(e,t){const n=og(),o=sg(n,e),s=ig(n,o);e.watcher.add(t),e.watcher.on("add",s),e.watcher.on("change",s),e.watcher.on("unlink",s)}async function cg(){const e=z.resolve(process.cwd(),"preview/ssr-server.mjs");if(!C.existsSync(e))throw console.warn(`\u26A0\uFE0F SSR server not found at ${e}`),new Error(`SSR server not found at ${e}`);process.env.PREVIEW_SSR_PORT="0";let t=e;process.platform==="win32"&&(t=mo(e).href);const n=await import(t),{server:o,port:s}=await n.startServer();return{server:o,port:s}}function lg(){ke=new Gi({port:0}),ke.on("listening",()=>{const e=ke?.address();if(e&&typeof e=="object"){const t=e.port;process.env.CRANE_WEBSOCKET_PORT=String(t)}})}async function ug(){const e=z.resolve(process.cwd(),"preview/vite.config.js"),t=z.resolve(process.cwd(),"sections/**/*"),n=z.resolve(process.cwd(),"headers/**/*"),o=z.resolve(process.cwd(),"footers/**/*"),s=z.resolve(process.cwd(),"shared/**/*"),r=await Ci({configFile:e,root:process.cwd(),plugins:[YE()]});return await r.listen(),ag(r,[t,n,o,s]),r}async function dg(){await Qt(),await QE(),console.log(`
46
+ For deploy run: npx @lightspeed/crane@latest deploy`;function em(e,t){if(e.errors.length===0){f.info(qh);return}f.error("Invalid configuration detected:"),Xh(e),t||process.exit(1)}const Gs={"process.env":{NODE_ENV:"production"}},tm=[...So,...So.map(e=>`node:${e}`)],nm=[/@vue\/compiler-dom/,/@vue\/runtime-dom/,/@vue\/server-renderer/,/@vue\/compiler-ssr/,/@vue\/shared/],xs=e=>({pluginType:ee.Server,define:Gs,ssr:!0,ssrOptions:{noExternal:!0},entryFileNames:"server.js",externalOption:[...tm,...nm],inlineDynamicImports:!0,...e,outDir:e.outDir}),Bs=e=>({pluginType:ee.Client,define:Gs,ssr:!1,entryFileNames:"client.js",assetFileNames:"assets/[name].[ext]",chunkFileNames:"chunks/[name].js",inlineDynamicImports:!1,...e,outDir:e.outDir}),Ke=e=>({pluginType:ee.Misc,ssr:!1,...e,entryFileNames:e.entryFileNames,outDir:e.outDir}),om=e=>({pluginType:ee.Layout,ssr:!1,entryFileNames:"index.mjs",...e,outDir:e.outDir}),qt=e=>({pluginType:ee.Asset,ssr:!1,assetFileNames:"[name].[ext]",...e,outDir:e.outDir});let en=!1;function rm(e){en=e}function eo(){return en}const Zs=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],sm=80,im="\x1B[?25l",am="\x1B[?25h",cm="\x1B[2K\r",um=44;let lm=class{frameIndex=0;timer=null;realWrite=null;buffer=[];start(){en||(this.frameIndex=0,this.buffer=[],this.realWrite=process.stdout.write.bind(process.stdout),process.stdout.write=((t,n,o)=>(this.buffer.push(typeof t=="string"?t:String(t)),typeof n=="function"&&(o=n),o&&o(),!0)),this.realWrite(im),this.render(),this.timer=setInterval(()=>this.render(),sm))}render(){if(!this.realWrite)return;const t=" Build is in progress...".padEnd(um-1," "),n=ce(Zs[this.frameIndex]+t);this.realWrite(`\r${n}`),this.frameIndex=(this.frameIndex+1)%Zs.length}stop(){if(!en&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.realWrite)){process.stdout.write=this.realWrite,this.realWrite(`${cm}${am}`);for(const t of this.buffer)this.realWrite(t);this.buffer=[],this.realWrite=null}}};const Hs=new lm,dm=()=>zi({ext:".gz",algorithm:"gzip",verbose:eo()}),pm="/* EXTERNAL_IMPORTS_START */",fm="/* EXTERNAL_IMPORTS_END */",hm=()=>({name:"external-imports-wrapper-plugin",enforce:"post",apply:"build",generateBundle(e,t){for(const n of Object.keys(t)){const o=t[n];if(o.type==="chunk"){const r=/import.*\?commonjs-external["'];/g,s=o.code.match(r);if(s!==null){const i=s.join(""),a=pm+i+fm,c=o.code.replace(r,"");o.code=a+c}}}}}),mm=()=>({name:"disable-json-plugin",enforce:"pre",apply:"build",configResolved(e){const t=e.plugins?.findIndex(n=>n?.name==="vite:json");t!==-1&&(e.plugins[t]={name:"vite:json",load:()=>null,transform:()=>null})}}),Em=()=>{const e=process.env.npm_lifecycle_event;return Mi({typescript:!1,vueTsc:!1,eslint:e?.startsWith("test")?!1:{lintCommand:`eslint --max-warnings=0 "./sections/**/*.{js,ts,vue}" --cache --cache-location "./build/eslintcache/${e}.json"`}})},pe={vue:()=>ji(),tsconfigPaths:()=>Ui(),checker:()=>Em()};class an{constructor(t){this.bits=t instanceof an?t.bits.slice():[]}add(t){this.bits[t>>5]|=1<<(t&31)}has(t){return!!(this.bits[t>>5]&1<<(t&31))}}class dt{constructor(t,n,o){this.start=t,this.end=n,this.original=o,this.intro="",this.outro="",this.content=o,this.storeName=!1,this.edited=!1,this.previous=null,this.next=null}appendLeft(t){this.outro+=t}appendRight(t){this.intro=this.intro+t}clone(){const t=new dt(this.start,this.end,this.original);return t.intro=this.intro,t.outro=this.outro,t.content=this.content,t.storeName=this.storeName,t.edited=this.edited,t}contains(t){return this.start<t&&t<this.end}eachNext(t){let n=this;for(;n;)t(n),n=n.next}eachPrevious(t){let n=this;for(;n;)t(n),n=n.previous}edit(t,n,o){return this.content=t,o||(this.intro="",this.outro=""),this.storeName=n,this.edited=!0,this}prependLeft(t){this.outro=t+this.outro}prependRight(t){this.intro=t+this.intro}reset(){this.intro="",this.outro="",this.edited&&(this.content=this.original,this.storeName=!1,this.edited=!1)}split(t){const n=t-this.start,o=this.original.slice(0,n),r=this.original.slice(n);this.original=o;const s=new dt(t,this.end,r);return s.outro=this.outro,this.outro="",this.end=t,this.edited?(s.edit("",!1),this.content=""):this.content=o,s.next=this.next,s.next&&(s.next.previous=s),s.previous=this,this.next=s,s}toString(){return this.intro+this.content+this.outro}trimEnd(t){if(this.outro=this.outro.replace(t,""),this.outro.length)return!0;const n=this.content.replace(t,"");if(n.length)return n!==this.content&&(this.split(this.start+n.length).edit("",void 0,!0),this.edited&&this.edit(n,this.storeName,!0)),!0;if(this.edit("",void 0,!0),this.intro=this.intro.replace(t,""),this.intro.length)return!0}trimStart(t){if(this.intro=this.intro.replace(t,""),this.intro.length)return!0;const n=this.content.replace(t,"");if(n.length){if(n!==this.content){const o=this.split(this.end-n.length);this.edited&&o.edit(n,this.storeName,!0),this.edit("",void 0,!0)}return!0}else if(this.edit("",void 0,!0),this.outro=this.outro.replace(t,""),this.outro.length)return!0}}function gm(){return typeof globalThis<"u"&&typeof globalThis.btoa=="function"?e=>globalThis.btoa(unescape(encodeURIComponent(e))):typeof Buffer=="function"?e=>Buffer.from(e,"utf-8").toString("base64"):()=>{throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.")}}const _m=gm();class ym{constructor(t){this.version=3,this.file=t.file,this.sources=t.sources,this.sourcesContent=t.sourcesContent,this.names=t.names,this.mappings=Fi(t.mappings),typeof t.x_google_ignoreList<"u"&&(this.x_google_ignoreList=t.x_google_ignoreList)}toString(){return JSON.stringify(this)}toUrl(){return"data:application/json;charset=utf-8;base64,"+_m(this.toString())}}function Sm(e){const t=e.split(`
47
+ `),n=t.filter(s=>/^\t+/.test(s)),o=t.filter(s=>/^ {2,}/.test(s));if(n.length===0&&o.length===0)return null;if(n.length>=o.length)return" ";const r=o.reduce((s,i)=>{const a=/^ +/.exec(i)[0].length;return Math.min(a,s)},1/0);return new Array(r+1).join(" ")}function Tm(e,t){const n=e.split(/[/\\]/),o=t.split(/[/\\]/);for(n.pop();n[0]===o[0];)n.shift(),o.shift();if(n.length){let r=n.length;for(;r--;)n[r]=".."}return n.concat(o).join("/")}const Om=Object.prototype.toString;function Im(e){return Om.call(e)==="[object Object]"}function Vs(e){const t=e.split(`
48
+ `),n=[];for(let o=0,r=0;o<t.length;o++)n.push(r),r+=t[o].length+1;return function(r){let s=0,i=n.length;for(;s<i;){const u=s+i>>1;r<n[u]?i=u:s=u+1}const a=s-1,c=r-n[a];return{line:a,column:c}}}const wm=/\w/;class vm{constructor(t){this.hires=t,this.generatedCodeLine=0,this.generatedCodeColumn=0,this.raw=[],this.rawSegments=this.raw[this.generatedCodeLine]=[],this.pending=null}addEdit(t,n,o,r){if(n.length){const s=n.length-1;let i=n.indexOf(`
49
+ `,0),a=-1;for(;i>=0&&s>i;){const u=[this.generatedCodeColumn,t,o.line,o.column];r>=0&&u.push(r),this.rawSegments.push(u),this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,a=i,i=n.indexOf(`
50
+ `,i+1)}const c=[this.generatedCodeColumn,t,o.line,o.column];r>=0&&c.push(r),this.rawSegments.push(c),this.advance(n.slice(a+1))}else this.pending&&(this.rawSegments.push(this.pending),this.advance(n));this.pending=null}addUneditedChunk(t,n,o,r,s){let i=n.start,a=!0,c=!1;for(;i<n.end;){if(this.hires||a||s.has(i)){const u=[this.generatedCodeColumn,t,r.line,r.column];this.hires==="boundary"?wm.test(o[i])?c||(this.rawSegments.push(u),c=!0):(this.rawSegments.push(u),c=!1):this.rawSegments.push(u)}o[i]===`
51
+ `?(r.line+=1,r.column=0,this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,a=!0):(r.column+=1,this.generatedCodeColumn+=1,a=!1),i+=1}this.pending=null}advance(t){if(!t)return;const n=t.split(`
52
+ `);if(n.length>1){for(let o=0;o<n.length-1;o++)this.generatedCodeLine++,this.raw[this.generatedCodeLine]=this.rawSegments=[];this.generatedCodeColumn=0}this.generatedCodeColumn+=n[n.length-1].length}}const lt=`
53
+ `,Je={insertLeft:!1,insertRight:!1,storeName:!1};class lo{constructor(t,n={}){const o=new dt(0,t.length,t);Object.defineProperties(this,{original:{writable:!0,value:t},outro:{writable:!0,value:""},intro:{writable:!0,value:""},firstChunk:{writable:!0,value:o},lastChunk:{writable:!0,value:o},lastSearchedChunk:{writable:!0,value:o},byStart:{writable:!0,value:{}},byEnd:{writable:!0,value:{}},filename:{writable:!0,value:n.filename},indentExclusionRanges:{writable:!0,value:n.indentExclusionRanges},sourcemapLocations:{writable:!0,value:new an},storedNames:{writable:!0,value:{}},indentStr:{writable:!0,value:void 0},ignoreList:{writable:!0,value:n.ignoreList}}),this.byStart[0]=o,this.byEnd[t.length]=o}addSourcemapLocation(t){this.sourcemapLocations.add(t)}append(t){if(typeof t!="string")throw new TypeError("outro content must be a string");return this.outro+=t,this}appendLeft(t,n){if(typeof n!="string")throw new TypeError("inserted content must be a string");this._split(t);const o=this.byEnd[t];return o?o.appendLeft(n):this.intro+=n,this}appendRight(t,n){if(typeof n!="string")throw new TypeError("inserted content must be a string");this._split(t);const o=this.byStart[t];return o?o.appendRight(n):this.outro+=n,this}clone(){const t=new lo(this.original,{filename:this.filename});let n=this.firstChunk,o=t.firstChunk=t.lastSearchedChunk=n.clone();for(;n;){t.byStart[o.start]=o,t.byEnd[o.end]=o;const r=n.next,s=r&&r.clone();s&&(o.next=s,s.previous=o,o=s),n=r}return t.lastChunk=o,this.indentExclusionRanges&&(t.indentExclusionRanges=this.indentExclusionRanges.slice()),t.sourcemapLocations=new an(this.sourcemapLocations),t.intro=this.intro,t.outro=this.outro,t}generateDecodedMap(t){t=t||{};const n=0,o=Object.keys(this.storedNames),r=new vm(t.hires),s=Vs(this.original);return this.intro&&r.advance(this.intro),this.firstChunk.eachNext(i=>{const a=s(i.start);i.intro.length&&r.advance(i.intro),i.edited?r.addEdit(n,i.content,a,i.storeName?o.indexOf(i.original):-1):r.addUneditedChunk(n,i,this.original,a,this.sourcemapLocations),i.outro.length&&r.advance(i.outro)}),{file:t.file?t.file.split(/[/\\]/).pop():void 0,sources:[t.source?Tm(t.file||"",t.source):t.file||""],sourcesContent:t.includeContent?[this.original]:void 0,names:o,mappings:r.raw,x_google_ignoreList:this.ignoreList?[n]:void 0}}generateMap(t){return new ym(this.generateDecodedMap(t))}_ensureindentStr(){this.indentStr===void 0&&(this.indentStr=Sm(this.original))}_getRawIndentString(){return this._ensureindentStr(),this.indentStr}getIndentString(){return this._ensureindentStr(),this.indentStr===null?" ":this.indentStr}indent(t,n){const o=/^[^\r\n]/gm;if(Im(t)&&(n=t,t=void 0),t===void 0&&(this._ensureindentStr(),t=this.indentStr||" "),t==="")return this;n=n||{};const r={};n.exclude&&(typeof n.exclude[0]=="number"?[n.exclude]:n.exclude).forEach(d=>{for(let m=d[0];m<d[1];m+=1)r[m]=!0});let s=n.indentStart!==!1;const i=u=>s?`${t}${u}`:(s=!0,u);this.intro=this.intro.replace(o,i);let a=0,c=this.firstChunk;for(;c;){const u=c.end;if(c.edited)r[a]||(c.content=c.content.replace(o,i),c.content.length&&(s=c.content[c.content.length-1]===`
54
+ `));else for(a=c.start;a<u;){if(!r[a]){const d=this.original[a];d===`
55
+ `?s=!0:d!=="\r"&&s&&(s=!1,a===c.start||(this._splitChunk(c,a),c=c.next),c.prependRight(t))}a+=1}a=c.end,c=c.next}return this.outro=this.outro.replace(o,i),this}insert(){throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)")}insertLeft(t,n){return Je.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),Je.insertLeft=!0),this.appendLeft(t,n)}insertRight(t,n){return Je.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),Je.insertRight=!0),this.prependRight(t,n)}move(t,n,o){if(o>=t&&o<=n)throw new Error("Cannot move a selection inside itself");this._split(t),this._split(n),this._split(o);const r=this.byStart[t],s=this.byEnd[n],i=r.previous,a=s.next,c=this.byStart[o];if(!c&&s===this.lastChunk)return this;const u=c?c.previous:this.lastChunk;return i&&(i.next=a),a&&(a.previous=i),u&&(u.next=r),c&&(c.previous=s),r.previous||(this.firstChunk=s.next),s.next||(this.lastChunk=r.previous,this.lastChunk.next=null),r.previous=u,s.next=c||null,u||(this.firstChunk=r),c||(this.lastChunk=s),this}overwrite(t,n,o,r){return r=r||{},this.update(t,n,o,{...r,overwrite:!r.contentOnly})}update(t,n,o,r){if(typeof o!="string")throw new TypeError("replacement content must be a string");for(;t<0;)t+=this.original.length;for(;n<0;)n+=this.original.length;if(n>this.original.length)throw new Error("end is out of bounds");if(t===n)throw new Error("Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead");this._split(t),this._split(n),r===!0&&(Je.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),Je.storeName=!0),r={storeName:!0});const s=r!==void 0?r.storeName:!1,i=r!==void 0?r.overwrite:!1;if(s){const u=this.original.slice(t,n);Object.defineProperty(this.storedNames,u,{writable:!0,value:!0,enumerable:!0})}const a=this.byStart[t],c=this.byEnd[n];if(a){let u=a;for(;u!==c;){if(u.next!==this.byStart[u.end])throw new Error("Cannot overwrite across a split point");u=u.next,u.edit("",!1)}a.edit(o,s,!i)}else{const u=new dt(t,n,"").edit(o,s);c.next=u,u.previous=c}return this}prepend(t){if(typeof t!="string")throw new TypeError("outro content must be a string");return this.intro=t+this.intro,this}prependLeft(t,n){if(typeof n!="string")throw new TypeError("inserted content must be a string");this._split(t);const o=this.byEnd[t];return o?o.prependLeft(n):this.intro=n+this.intro,this}prependRight(t,n){if(typeof n!="string")throw new TypeError("inserted content must be a string");this._split(t);const o=this.byStart[t];return o?o.prependRight(n):this.outro=n+this.outro,this}remove(t,n){for(;t<0;)t+=this.original.length;for(;n<0;)n+=this.original.length;if(t===n)return this;if(t<0||n>this.original.length)throw new Error("Character is out of bounds");if(t>n)throw new Error("end must be greater than start");this._split(t),this._split(n);let o=this.byStart[t];for(;o;)o.intro="",o.outro="",o.edit(""),o=n>o.end?this.byStart[o.end]:null;return this}reset(t,n){for(;t<0;)t+=this.original.length;for(;n<0;)n+=this.original.length;if(t===n)return this;if(t<0||n>this.original.length)throw new Error("Character is out of bounds");if(t>n)throw new Error("end must be greater than start");this._split(t),this._split(n);let o=this.byStart[t];for(;o;)o.reset(),o=n>o.end?this.byStart[o.end]:null;return this}lastChar(){if(this.outro.length)return this.outro[this.outro.length-1];let t=this.lastChunk;do{if(t.outro.length)return t.outro[t.outro.length-1];if(t.content.length)return t.content[t.content.length-1];if(t.intro.length)return t.intro[t.intro.length-1]}while(t=t.previous);return this.intro.length?this.intro[this.intro.length-1]:""}lastLine(){let t=this.outro.lastIndexOf(lt);if(t!==-1)return this.outro.substr(t+1);let n=this.outro,o=this.lastChunk;do{if(o.outro.length>0){if(t=o.outro.lastIndexOf(lt),t!==-1)return o.outro.substr(t+1)+n;n=o.outro+n}if(o.content.length>0){if(t=o.content.lastIndexOf(lt),t!==-1)return o.content.substr(t+1)+n;n=o.content+n}if(o.intro.length>0){if(t=o.intro.lastIndexOf(lt),t!==-1)return o.intro.substr(t+1)+n;n=o.intro+n}}while(o=o.previous);return t=this.intro.lastIndexOf(lt),t!==-1?this.intro.substr(t+1)+n:this.intro+n}slice(t=0,n=this.original.length){for(;t<0;)t+=this.original.length;for(;n<0;)n+=this.original.length;let o="",r=this.firstChunk;for(;r&&(r.start>t||r.end<=t);){if(r.start<n&&r.end>=n)return o;r=r.next}if(r&&r.edited&&r.start!==t)throw new Error(`Cannot use replaced character ${t} as slice start anchor.`);const s=r;for(;r;){r.intro&&(s!==r||r.start===t)&&(o+=r.intro);const i=r.start<n&&r.end>=n;if(i&&r.edited&&r.end!==n)throw new Error(`Cannot use replaced character ${n} as slice end anchor.`);const a=s===r?t-r.start:0,c=i?r.content.length+n-r.end:r.content.length;if(o+=r.content.slice(a,c),r.outro&&(!i||r.end===n)&&(o+=r.outro),i)break;r=r.next}return o}snip(t,n){const o=this.clone();return o.remove(0,t),o.remove(n,o.original.length),o}_split(t){if(this.byStart[t]||this.byEnd[t])return;let n=this.lastSearchedChunk;const o=t>n.end;for(;n;){if(n.contains(t))return this._splitChunk(n,t);n=o?this.byStart[n.end]:this.byEnd[n.start]}}_splitChunk(t,n){if(t.edited&&t.content.length){const r=Vs(this.original)(n);throw new Error(`Cannot split a chunk that has already been edited (${r.line}:${r.column} \u2013 "${t.original}")`)}const o=t.split(n);return this.byEnd[n]=t,this.byStart[n]=o,this.byEnd[o.end]=o,t===this.lastChunk&&(this.lastChunk=o),this.lastSearchedChunk=t,!0}toString(){let t=this.intro,n=this.firstChunk;for(;n;)t+=n.toString(),n=n.next;return t+this.outro}isEmpty(){let t=this.firstChunk;do if(t.intro.length&&t.intro.trim()||t.content.length&&t.content.trim()||t.outro.length&&t.outro.trim())return!1;while(t=t.next);return!0}length(){let t=this.firstChunk,n=0;do n+=t.intro.length+t.content.length+t.outro.length;while(t=t.next);return n}trimLines(){return this.trim("[\\r\\n]")}trim(t){return this.trimStart(t).trimEnd(t)}trimEndAborted(t){const n=new RegExp((t||"\\s")+"+$");if(this.outro=this.outro.replace(n,""),this.outro.length)return!0;let o=this.lastChunk;do{const r=o.end,s=o.trimEnd(n);if(o.end!==r&&(this.lastChunk===o&&(this.lastChunk=o.next),this.byEnd[o.end]=o,this.byStart[o.next.start]=o.next,this.byEnd[o.next.end]=o.next),s)return!0;o=o.previous}while(o);return!1}trimEnd(t){return this.trimEndAborted(t),this}trimStartAborted(t){const n=new RegExp("^"+(t||"\\s")+"+");if(this.intro=this.intro.replace(n,""),this.intro.length)return!0;let o=this.firstChunk;do{const r=o.end,s=o.trimStart(n);if(o.end!==r&&(o===this.lastChunk&&(this.lastChunk=o.next),this.byEnd[o.end]=o,this.byStart[o.next.start]=o.next,this.byEnd[o.next.end]=o.next),s)return!0;o=o.next}while(o);return!1}trimStart(t){return this.trimStartAborted(t),this}hasChanged(){return this.original!==this.toString()}_replaceRegexp(t,n){function o(s,i){return typeof n=="string"?n.replace(/\$(\$|&|\d+)/g,(a,c)=>c==="$"?"$":c==="&"?s[0]:+c<s.length?s[+c]:`$${c}`):n(...s,s.index,i,s.groups)}function r(s,i){let a;const c=[];for(;a=s.exec(i);)c.push(a);return c}if(t.global)r(t,this.original).forEach(i=>{if(i.index!=null){const a=o(i,this.original);a!==i[0]&&this.overwrite(i.index,i.index+i[0].length,a)}});else{const s=this.original.match(t);if(s&&s.index!=null){const i=o(s,this.original);i!==s[0]&&this.overwrite(s.index,s.index+s[0].length,i)}}return this}_replaceString(t,n){const{original:o}=this,r=o.indexOf(t);return r!==-1&&this.overwrite(r,r+t.length,n),this}replace(t,n){return typeof t=="string"?this._replaceString(t,n):this._replaceRegexp(t,n)}_replaceAllString(t,n){const{original:o}=this,r=t.length;for(let s=o.indexOf(t);s!==-1;s=o.indexOf(t,s+r))o.slice(s,s+r)!==n&&this.overwrite(s,s+r,n);return this}replaceAll(t,n){if(typeof t=="string")return this._replaceAllString(t,n);if(!t.global)throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");return this._replaceRegexp(t,n)}}const Ws=T(process.cwd(),"shared/translation.ts"),Ys="globalThis.craneSharedTranslation = translation",Cm=e=>`import translation from '${e}';
56
+ ${Ys};
57
+ `,Rm=(e,t)=>{const n=e.split("?")[0],o=vi(n);return(o==="server.ts"||o==="client.ts")&&!t.includes(Ys)},Ks=()=>{let e=!1;return{name:"static-translation-plugin",enforce:"pre",apply:"build",buildStart(){e=V(Ws)},transform(t,n){if(!e||!Rm(n,t))return null;const o=n.split("?")[0],r=fo(o),s=Ni(ho(r,Ws)),i=Cm(s),a=new lo(t);return a.prepend(i),{code:a.toString()}}}},Js={[ee.Server]:()=>[pe.vue(),pe.tsconfigPaths(),hm(),dm(),Ks()],[ee.Client]:()=>[pe.vue(),pe.tsconfigPaths(),To({vue:"EcVue"}),Ks()],[ee.Misc]:()=>[pe.tsconfigPaths()],[ee.Layout]:()=>[pe.vue(),pe.tsconfigPaths(),To({vue:["EcExternals","Vue"]})],[ee.Asset]:()=>[mm()],[ee.SharedFiles]:()=>[pe.tsconfigPaths()]},Xs={[N.Server]:xs({outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/main/server`}),[N.Client]:Bs({outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/main/client`}),[N.SectionSetting]:Ke({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/settings`}),[N.SectionShowcase]:Ke({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/showcases`}),[N.SectionAsset]:qt({outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/assets`}),[N.TemplateDescriptor]:Ke({entryFileNames:"[name].mjs",outDir:()=>`./${Oe}/js`}),[N.PageTemplateDescriptor]:Ke({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${Oe}/${e}`}),[N.TemplateAsset]:qt({outDir:()=>`./${Oe}/assets`}),[N.Layout]:om({outDir:({name:e,sectionId:t})=>`./${Q}/${t}/${e}`}),[N.LayoutSettings]:Ke({entryFileNames:"[name].mjs",outDir:({name:e,sectionId:t})=>`./${Q}/${t}/${e}/js/settings`}),[N.LayoutAsset]:qt({outDir:({name:e,sectionId:t})=>`./${Q}/${t}/${e}/assets`}),[N.SlotServer]:xs({outDir:({name:e,layoutId:t,sectionId:n})=>`./${Q}/${n}/${t}/slots/${e}/js/main/server`}),[N.SlotClient]:Bs({outDir:({name:e,layoutId:t,sectionId:n})=>`./${Q}/${n}/${t}/slots/${e}/js/main/client`}),[N.CollectionDescriptor]:Ke({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${it}/${e}`}),[N.CollectionAsset]:qt({outDir:()=>`./${it}/assets`}),[N.SharedTranslation]:{pluginType:ee.SharedFiles,ssr:!1,inlineDynamicImports:!0,entryFileNames:"translation.mjs",outDir:()=>"./dist/shared"}};function bm(e){switch(typeof e){case"string":return[T(process.cwd(),e)];case"object":return e.map(t=>T(process.cwd(),t));default:return[]}}function Qs({name:e,entryPoints:t,configType:n,layoutId:o,sectionId:r,sectionType:s=Se.SECTION}){const i=Xs[n],a=i.define,c=i.ssrOptions,u=i.entryFileNames,d=i.chunkFileNames,m=i.assetFileNames,S=i.inlineDynamicImports,O=i.externalOption;return{logLevel:eo()?void 0:"silent",plugins:Js[i.pluginType](),ssr:c,define:a,resolve:{alias:{"@":"/src"}},build:{ssr:i.ssr,outDir:i.outDir({name:e,sectionType:s,layoutId:o,sectionId:r}),emptyOutDir:!0,minify:i.ssr?"terser":"esbuild",...i.ssr&&{terserOptions:{mangle:{reserved:["gc"]}}},rollupOptions:{external:O,preserveEntrySignatures:"strict",input:bm(t),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:S,entryFileNames:u,chunkFileNames:d,assetFileNames:m}}},assetsInclude:["**/*.json"]}}const Am=Object.values(G).map(e=>e.source).join("|");function qs(e,t,n){if(!e)return`${t}.mjs`;const o=ho(process.cwd(),e).replace(/\\/g,"/").match(`^(${Am})/([^/]+)/${n}/([^/.]+)`);return o?`${o[1]}/${o[2]}/js/${n}/${o[3]}.mjs`:`${t}.mjs`}function ei(e,t){const n=Xs[N.SectionSetting];return{logLevel:eo()?void 0:"silent",plugins:Js[n.pluginType](),define:n.define,resolve:{alias:{"@":"/src"}},css:{preprocessorOptions:{scss:{api:"modern-compiler"}}},build:{ssr:n.ssr,outDir:"./dist",emptyOutDir:!1,minify:"esbuild",rollupOptions:{external:n.externalOption,preserveEntrySignatures:"strict",input:e.map(o=>T(process.cwd(),o)),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:n.inlineDynamicImports,entryFileNames:t,chunkFileNames:"chunks/[name]-[hash].js",assetFileNames:n.assetFileNames}}},assetsInclude:["**/*.json"]}}function Nm(e){return ei(e,t=>qs(t.facadeModuleId??void 0,t.name,"settings"))}function $m(e){return ei(e,t=>qs(t.facadeModuleId??void 0,t.name,"showcases"))}async function Lm(){const e={ignore:["node_modules/**","dist/**"]},t=await I(`./${Ze}/{product,category,catalog}/*/client.{js,ts}`,e);return await Promise.all(t.map(async n=>{const{id:o,sectionId:r,pageId:s}=Hh(n),[i,a]=await Promise.all([I(`./${Ze}/${r}/${o}/settings/{content,design,translations,layout}.{js,ts}`,e),I(`./${Ze}/${r}/${o}/assets/*`,e)]);return{name:o,sectionId:r,pageId:s,clientEntrypoint:n,settingsEntryPoints:i,assetsEntrypoints:a}}))}async function Dm(e){await se({entryPoints:[e.clientEntrypoint],configType:N.Layout,name:e.name,sectionId:e.sectionId}),await Promise.all([se({entryPoints:e.settingsEntryPoints,configType:N.LayoutSettings,name:e.name,sectionId:e.sectionId}),se({entryPoints:e.assetsEntrypoints,configType:N.LayoutAsset,name:e.name,sectionId:e.sectionId})])}async function km(e){e===void 0||e.length===0||await Promise.all(e.map(t=>Dm(t)))}async function Pm(e){const t=e.flatMap(o=>o.settingsEntryPoints),n=e.flatMap(o=>o.showcaseEntryPoints);t.length>0&&await ge({configFile:!1,...mt(Nm(t))}),n.length>0&&await ge({configFile:!1,...mt($m(n))})}async function zm(e){await Promise.all([ge({configFile:!1,...mt(Qs({name:e.name,entryPoints:e.serverEntrypoint,configType:Ve.Server,sectionType:e.type}))}),se({entryPoints:e.clientEntrypoint,configType:Ve.Client,name:e.name,sectionType:e.type}),se({entryPoints:e.assetEntryPoints,configType:Ve.SectionAsset,name:e.name,sectionType:e.type})])}async function jm(){const e=T(process.cwd(),"shared/translation.ts");V(e)&&await se({entryPoints:["shared/translation.ts"],configType:Ve.SharedTranslation})}async function ti(e){await Promise.all([Pm(e),...e.map(zm)])}function Um(e){const t=Xt(e).split("/");if(t.length<4||t[2]!=="slots")throw new Error(`Invalid slot path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/slots/{slotId}/[...path]`);const[n,o,,r]=t;if(!Fs(n))throw new Error(`Slot cannot be placed in a non-storefront section: ${n}`);return{id:r,sectionId:n,layoutId:o}}async function Mm(e,t){return Promise.all(e.map(async n=>{const o=t.find(a=>a.id===n.layoutId&&a.sectionId===n.sectionId),r=await at(o?.translationsSettings),s=await Jn(o?.content??{},r),i=await Xn(o?.design??{},r);return{id:n.id,sectionId:n.sectionId,layoutId:n.layoutId,contentEditors:s,designEditors:i}}))}async function Fm(){const e={ignore:["node_modules/**","dist/**"]},t=await I(`${Ze}/{product,category,catalog}/*/slots/*/server.ts`,e);return Promise.all(t.map(async n=>{const{id:o,sectionId:r,layoutId:s}=Um(n),i=(await I(`${Ze}/${r}/${s}/slots/${o}/client.{js,ts}`,e))[0];if(i===void 0)throw new Error(`Cannot find client entrypoint file for slot ${o} of section ${r}`);return{id:o,sectionId:r,layoutId:s,serverEntrypoint:n,clientEntrypoint:i}}))}async function Gm(e){const t={name:e.id,layoutId:e.layoutId,sectionId:e.sectionId};await Promise.all([se({entryPoints:[e.serverEntrypoint],configType:N.SlotServer,...t}),se({entryPoints:[e.clientEntrypoint],configType:N.SlotClient,...t})])}async function xm(e){e?.length&&await Promise.all(e.map(Gm))}async function Bm(e){return(await I(`**/${e}/pages/*.{js,ts}`,{ignore:["node_modules/**","dist/**"]})).filter(t=>{const n=mo(t).name.toLowerCase();return!Object.values(Ar).includes(n)})}async function Zm(){const e=await I("./templates/*",{ignore:["templates/assets/**","templates/**.{js,ts}","node_modules/**","dist/**"]}).catch(t=>(f.error(`Error while getting page template entry points: ${t}`),[]));return Promise.all(e.map(async t=>{const n=t.split(dn),o=n.pop()??"default";if(n.pop()===void 0)throw new Error("Cannot determine template with custom pages, outer directory is undefined");const r=await I(`**/templates/${o}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),s=await I(`**/templates/${o}/pages/home.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await I(`**/templates/${o}/pages/category.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),a=await I(`**/templates/${o}/pages/catalog.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),c=await I(`**/templates/${o}/pages/product.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),u=await Bm(o);return{name:o,configurationEntrypoint:r.at(0),homeEntrypoint:s.at(0),categoryEntrypoint:i.at(0),catalogEntrypoint:a.at(0),productEntrypoint:c.at(0),customEntrypoint:u.length>0?u:void 0}}))}async function Hm(){const e=await I("./templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]}),t=await I("./templates/assets/*",{ignore:["node_modules/**","dist/**"]});return{pageTemplates:await Zm(),templates:e,assets:t}}async function Vm({templateBuildConfig:e}){await Promise.all([se({entryPoints:e.assets,configType:Ve.TemplateAsset}),...e.pageTemplates?.map(async t=>{const n=[t.configurationEntrypoint,t.homeEntrypoint,t.categoryEntrypoint,t.catalogEntrypoint,t.productEntrypoint,...t.customEntrypoint??[]].filter(Wt);if(n.length===0)throw new Error("No entry points provided for page template");await se({entryPoints:n,configType:Ve.PageTemplateDescriptor,name:t.name})})||[]])}async function Wm(){const e=await Hm();await Vm({templateBuildConfig:e})}async function Ym(){const e=await I("./collections/*",{ignore:["collections/assets/**","collections/**.{js,ts}","node_modules/**","dist/**"]}).catch(n=>(f.error(`Error while getting collection entry points: ${n}`),[])),t=await I("./collections/assets/*",{ignore:["node_modules/**","dist/**"]});return Promise.all(e.map(async n=>{const o=n.split(dn),r=o.pop()??"default";if(o.pop()===void 0)throw new Error("Cannot determine collection, outer directory is undefined");const s=await I(`**/collections/${r}/configuration.{js,ts}`,{ignore:["node_modules/**","dist/**"]});return{name:r,configurationEntrypoint:s.at(0),assetsEntrypoints:t}}))}async function Km(){const e=await Ym();e.length!==0&&await Promise.all(e.flatMap(t=>[se({entryPoints:t.assetsEntrypoints,configType:N.CollectionAsset,name:t.name}),se({entryPoints:t.configurationEntrypoint?[t.configurationEntrypoint]:[],configType:N.CollectionDescriptor,name:t.name})]))}function ni(e){return{name:e.name,type:e.type,serverEntrypoint:e.serverEntrypoint,clientEntrypoint:[e.clientEntrypoint].filter(Wt).flat(),settingsEntryPoints:[e.contentSettingsEntrypoint,e.designSettingsEntrypoint,e.layoutSettingsEntrypoint,e.settingsTranslationsEntrypoint].filter(Wt),showcaseEntryPoints:[...e.showcasesEntrypoints??[],e.showcasesTranslationsEntrypoint].filter(Wt),assetEntryPoints:e.assetsEntrypoints??[]}}function oi(e){return e.map(t=>({...t,selectedDesignSettings:t.selectedDesignSettings.map(n=>{const o=n.defaults;return o&&typeof o=="object"&&!("type"in o)?{...n,defaults:{type:n.type,...o}}:n})}))}async function Jm(e,t=me){const n=T(process.cwd(),`${t}/${e}/js/main/server/server.js.gz`),o=Oo(Io.gunzip),r=await C.promises.readFile(n);return{size:(await o(r)).length}}async function Xm(e,t=me){try{const n=T(process.cwd(),`${t}/${e}/assets/`);return(await I("*",{cwd:n})).map(o=>{const r=T(n,o);return{path:o,size:Qe(r).size}})}catch{throw new Error(`Asset files for section [${e}] is either invalid or undefined`)}}async function to(e,t){const n=await vh(e,G[t].dist),o=await Jt(e,G[t].dist),r=await Rh(e,G[t].dist),s=await bh(e,G[t].dist),i=await Nh(e,G[t].dist),a=await $h(e,G[t].dist),c=oi(a),u=await Xm(e,G[t].dist),d=await Jm(e,G[t].dist),m=Lh(e);return{id:e,type:t,name:e,content:r,design:s,layout:c,showcase:i,translationsSettings:n,translationsShowcases:o,assets:u,server:d,previewCount:m}}async function Qm(){const e=await I("*/",{cwd:T(process.cwd(),`${me}/`)}),t=await I("*/",{cwd:T(process.cwd(),`${Zn}/`)}),n=await I("*/",{cwd:T(process.cwd(),`${Hn}/`)});return Promise.all([...e.map(async o=>to(o,Ae.SECTION)),...t.map(async o=>to(o,Ae.HEADER)),...n.map(async o=>to(o,Ae.FOOTER))])}async function qm(e){try{const t=T(process.cwd(),`${e}/assets/`);return(await I("*",{cwd:t})).map(n=>{const o=T(t,n);return{path:n,size:Qe(o).size}})}catch{throw new Error("Asset files for layouts are either invalid or undefined")}}async function eE(e){const t=Xt(e).split("/");if(t.length<2)throw new Error(`Invalid layout path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/[...path]`);const[n,o]=t,[r,s,i,a,c]=await Promise.all([nE(o,n),oE(o,n),Ch(o,n),qm(e),rE(o,n)]);return{id:o,sectionId:n,content:r,design:s,translationsSettings:i,assets:a,layouts:c}}async function tE(){const e=`${Q}/{product,catalog,category}/*`,t=await I(e,{ignore:["node_modules/**"]});return Promise.all(t.map(eE))}async function nE(e,t){try{const n=T(process.cwd(),`${Q}/${t}/${e}/js/settings/content.mjs`),o=await re(n);return Be(o)}catch(n){throw new Error(`Content descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function oE(e,t){try{const n=T(process.cwd(),`${Q}/${t}/${e}/js/settings/design.mjs`),o=await re(n);return Be(o)}catch(n){throw new Error(`Design descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function rE(e,t){try{const n=T(process.cwd(),`${Q}/${t}/${e}/js/settings/layout.mjs`);if(!C.existsSync(n))return[];const o=await re(n);return oi(o)}catch(n){throw new Error(`Layout settings descriptor for layout [${e}] in section [${t}] is either invalid or undefined: ${n}`)}}async function sE(e,t,n){const o=T(process.cwd(),`${Q}/${n}/${t}/slots/${e}/js/main/server/server.js.gz`),r=Oo(Io.gunzip),s=await C.promises.readFile(o);return{size:(await r(s)).length}}async function iE(e){const t=Xt(e).split("/");if(t.length<4||t[2]!=="slots")throw new Error(`Invalid slot path: ${e}. Expected format: [dist/]layouts/{sectionId}/{layoutId}/slots/{slotId}/[...path]`);const[n,o,,r]=t,s=await sE(r,o,n);return{id:r,sectionId:n,layoutId:o,server:s}}async function aE(){const e=`${Q}/{product,catalog,category}/*/slots/*`,t=await I(e,{ignore:["node_modules/**"]});return await Promise.all(t.map(iE))}async function cE(){try{const e=T(process.cwd(),`${Oe}/assets/`);return(await I("*",{cwd:e})).map(t=>{const n=T(e,t);return{path:t,size:Qe(n).size}})}catch{throw new Error("Asset files for templates are either invalid or undefined")}}function uE(e){return e in Ne?Ne[e]:Ne.CUSTOM}async function lE(e){const t=await I(`${Oe}/${e}/*.mjs`,{ignore:[`${Oe}/${e}/configuration*.mjs`]});return Promise.all(t.map(async n=>{const{sections:o,metadata:r}=await no(n),s=Vf(n);return{type:uE(s.toUpperCase()),id:s,metadata:r,sections:o}}))}async function no(e){try{return await re(T(process.cwd(),e))}catch{throw new Error(`Template file [${e}] is either invalid or undefined`)}}async function dE(e){const t=await I(`${Oe}/**/configuration*.mjs`,{});return Promise.all(t.map(async n=>{const o=z.basename(z.dirname(n));return{id:`${e}_${o}`,assets:await cE(),configuration:await no(n),pages:await lE(o)}}))}async function pE(e){return await dE(e)}async function fE(){const e=T(process.cwd(),`${Gf}/translation.mjs`);return await re(e)}async function hE(){return{translations:await fE()}}async function mE(e){const t=await I(`${it}/*/configuration*.mjs`,{ignore:["node_modules/**",`${it}/assets/**`]});return Promise.all(t.map(async n=>{const o=z.basename(z.dirname(n)),r=await no(n);return{id:`${e}_${o}`,descriptor:r}}))}async function ri(){const e=await Yt(),[t,n,o,r,s,i,a]=await Promise.all([qn(),hE(),Qm(),tE(),aE(),pE(e.appClientId),mE(e.appClientId)]);return{version:t.version,name:"Custom Block App",shared:n,sections:o,templates:i,layouts:r,slots:s,collections:a,compressionEnabled:!0,externalizationEnabled:!0,vueVersion:t.dependencies.vue,openSource:t.openSource}}function oo(e){return V(`${Zn}/${e}`)?Se.HEADER:V(`${Hn}/${e}`)?Se.FOOTER:Se.SECTION}async function ro(e,t){const n=e.design?Kn(e.design):void 0,o={...e,design:n??e.design},r=await at(t);return He(o,r)}function so(e){return e.type==="custom"&&e.id!==void 0&&e.showcase_overrides!==void 0}async function si(e){if(so(e)){const t=await Jt(e.id,G[oo(e.id)].dist);return{...e,showcase_overrides:await ro(e.showcase_overrides,t)}}return e}async function EE(e){const t=so(e.header)?{...e.header,showcase_overrides:await ro(e.header.showcase_overrides,await Jt(e.header.id,G[oo(e.header.id)].dist))}:e.header,n=so(e.footer)?{...e.footer,showcase_overrides:await ro(e.footer.showcase_overrides,await Jt(e.footer.id,G[oo(e.footer.id)].dist))}:e.footer;return{...e,header:t,footer:n}}async function gE(e){const t=await Promise.all(e.pages.map(async o=>({...o,sections:await Promise.all(o.sections.map(r=>si(r)))}))),n=await EE(e.configuration);return{id:e.id,descriptor:{...n,pages:t}}}async function _E(e){return Promise.all(e.map(t=>gE(t)))}async function yE(e){const t=new Map;return await Promise.all(e.map(async n=>{const[o,r]=await Promise.all([at(n.translationsSettings),at(n.translationsShowcases)]);t.set(n.id,{settings:o,showcases:r})})),t}async function SE(e,t,n){const[o,r,s,i]=await Promise.all([Jn(e.content,t,e.type),Xn(e.design,t,e.type),Ah(e.showcase,n),js(e.layout)]);return{id:e.id,type:e.type,name:{en:e.name},contentEditors:o,designEditors:r,layouts:i,showcases:s,previewCount:e.previewCount}}async function TE(e,t){return Promise.all(e.map(async n=>{const o=t.get(n.id)??{settings:{},showcases:{}};return SE(n,o.settings,o.showcases)}))}async function OE(e){return Promise.all(e.map(async t=>{const n=await Promise.all(t.descriptor.sections.map(o=>si(o)));return{...t,descriptor:{...t.descriptor,sections:n}}}))}async function ii(e){const t=await yE(e.sections),[n,o,r,s,i]=await Promise.all([TE(e.sections,t),Vh(e.layouts),Mm(e.slots,e.layouts),_E(e.templates),OE(e.collections)]);return{version:e.version,name:e.name,blocks:n,templates:s,layouts:o,slots:r,compressionEnabled:e.compressionEnabled,externalizationEnabled:e.externalizationEnabled,vueVersion:e.vueVersion,collections:i,openSource:e.openSource}}async function IE(e){const t=T(Et.cwd(),Ls);return Di(t,JSON.stringify(e))}function wE(e){return Object.entries(G).find(t=>t[1].source===e)?.[0]}async function ai(){const e=await I("**/server.{js,ts}",{ignore:["node_modules/**","dist/**","templates/**","layouts/**","collections/**"]});return Promise.all(e.map(async t=>{const n=fo(t).split(dn),o=n.pop()??"default",r=n.pop();if(r===void 0)throw new Error("Cannot determine type of section, outer directory is undefined");const s=["node_modules/**","dist/**"],[i,a,c,u,d,m,S,O]=await Promise.all([I(`**/${o}/client.{js,ts}`,{ignore:s}),I(`**/${o}/settings/content.{js,ts}`,{ignore:s}),I(`**/${o}/settings/design.{js,ts}`,{ignore:s}),I(`**/${o}/settings/layout.{js,ts}`,{ignore:s}),I(`**/${o}/settings/translations.{js,ts}`,{ignore:s}),I(`**/${o}/showcases/*.{js,ts}`,{ignore:[...s,`**/${o}/showcases/translations.{js,ts}`]}),I(`**/${o}/showcases/translations.{js,ts}`,{ignore:s}),I(`**/${o}/assets/*`,{ignore:s})]);return{name:o,type:wE(r),serverEntrypoint:t,clientEntrypoint:i.at(0),contentSettingsEntrypoint:a.at(0),designSettingsEntrypoint:c.at(0),layoutSettingsEntrypoint:u.at(0),settingsTranslationsEntrypoint:d.at(0),showcasesEntrypoints:m,showcasesTranslationsEntrypoint:S.at(0),assetsEntrypoints:O}}))}const vE=["/settings/","/showcases/"];function CE(e){return vE.some(t=>e.includes(t))}function RE(){const e=ue.findConfigFile(process.cwd(),ue.sys.fileExists,"tsconfig.json");if(!e)return;const t=ue.readConfigFile(e,ue.sys.readFile),n=ue.parseJsonConfigFileContent(t.config,ue.sys,process.cwd()),o=ue.createProgram(n.fileNames,n.options),r=ue.getPreEmitDiagnostics(o).filter(s=>!s.file||!CE(s.file.fileName));if(r.length>0){const s={getCanonicalFileName:i=>i,getCurrentDirectory:ue.sys.getCurrentDirectory,getNewLine:()=>ue.sys.newLine};throw console.error(ue.formatDiagnosticsWithColorAndContext(r,s)),new Error(`TypeScript found ${r.length} error(s)`)}}async function bE(e){RE(),await ge({configFile:!1,logLevel:"error",plugins:[pe.vue(),pe.tsconfigPaths(),pe.checker()],build:{write:!1,rollupOptions:{input:T(process.cwd(),e)}}})}function AE(){return Promise.all([un.rm("dist",{recursive:!0,force:!0}),un.rm("source-code",{recursive:!0,force:!0}),un.rm("source-code.zip",{force:!0})])}async function NE(){const e=new Eo,t=["node_modules/**/*","dist/**/*","build/**/*",".git/**/*","**/assets/**/*","crane.config.json"];(await qn()).openSource===!0&&t.splice(t.indexOf("**/assets/**/*"),1);const n=await I("**/*",{cwd:T(process.cwd()),ignore:t,dot:!0,nodir:!0});try{n.forEach(s=>{const i=T(process.cwd(),s);e.addLocalFile(i,mo(s).dir)});const o=ut[R.SourceCode].fileName,r=T(process.cwd(),o);await e.writeZipPromise(r)}catch(o){throw f.error("Error while zipping source files"),o}}async function tn(e=!1,t=!1){rm(t),Hs.start(),await AE();try{const[n,o,r]=await Promise.all([Lm(),ai(),Fm()]),s=o.map(ni);o.length>0&&await bE(o[0].serverEntrypoint);try{await Promise.all([jm(),ti(s),Wm(),Km(),km(n),xm(r),NE()])}finally{Hs.stop()}const i=await ri(),a=await Qh(i);em(a,e);const c=await ii(i);await IE(c)}catch(n){f.error(`Error while building: ${n.message}`),e||process.exit(1)}}async function se({entryPoints:e,configType:t,name:n,sectionType:o,sectionId:r,layoutId:s}){if(e.length!==0){const i=mt(Qs({name:n,entryPoints:e,configType:t,sectionType:o,sectionId:r,layoutId:s}));await ge({configFile:!1,...i})}}function ci(e,t,n){ft.statSync(e).isDirectory()?(ft.mkdirSync(t,{recursive:!0}),ft.readdirSync(e).forEach(o=>{const r=ht.resolve(e,o),s=ht.resolve(t,o);ci(r,s,n)})):Gi.isMatch(e,n,{dot:!0})||ft.copyFileSync(e,t)}function Ie(e,t,n,o,r=[]){const s=ht.join(e,o?.[n]??n);ci(ht.join(t,n),s,r)}function $E(e){return{renameFiles:{"example-template":`${e}`},targetPath:e,sourcePath:"template/page-templates",onTemplateCreated:()=>f.info(`Template [${e}] with pages structure named has been created`)}}function Ee(e){return W.resolve(xi(import.meta.url),"../..",e)}function LE(){const e=Ee("package.json");return e!==""?JSON.parse(L.readFileSync(e,"utf8")):{}}async function DE(e){try{const t=e,n=j.cwd(),o=W.join(n,t),r=["templates","headers","preview","footers","reference","page-templates","layouts","collections","blank"],s={_gitignore:".gitignore"};L.existsSync(o)?(f.error(`App with the name: ${e} already exists. If you'd like to override it, delete previous version first`),j.exit(1)):L.mkdirSync(o);const i=Ee("template");L.readdirSync(i).filter(d=>d!=="package.json").filter(d=>!r.includes(d)).forEach(async d=>Ie(o,i,d,s));const a=JSON.parse(L.readFileSync(W.join(i,"package.json"),"utf-8"));a.name=e;const c=LE();c.version&&(a.dependencies["@lightspeed/crane-api"]=c.dependencies["@lightspeed/crane-api"]),c.dependencies["@lightspeed/eslint-config-crane"]&&(a.dependencies["@lightspeed/eslint-config-crane"]=c.dependencies["@lightspeed/eslint-config-crane"]);const u=W.join(o,"package.json");L.writeFileSync(u,`${JSON.stringify(a,null,2)}
58
+ `),f.info(`App ${e} created`)}catch(t){f.error(`Error while creating app: ${t.message}`),j.exit(1)}}function io(e,t,n,o){try{const r=j.cwd(),s=z.join(r,t);C.existsSync(s)||C.mkdirSync(s);const i=z.join(r,t,n);C.existsSync(i)?(f.error(`${o} with the name: ${n} already exists. If you'd like to override it, delete previous version first`),j.exit(1)):C.mkdirSync(i);const a=Ee(e);C.readdirSync(a).forEach(async c=>Ie(i,a,c)),f.info(`${o} ${n} created`)}catch(r){f.error(`Error while creating ${o}: ${r.message}`),j.exit(1)}}function ao(e){const t=j.cwd(),n=Ee(`template/${e}`),o=z.join(t,e);C.existsSync(o)||(C.mkdirSync(o),C.readdirSync(n).forEach(async r=>Ie(o,n,r)))}async function kE(e,t,n,o){if(!C.existsSync(n)){C.copyFileSync(t,n);return}const r=C.readFileSync(t),s=C.readFileSync(n);r.equals(s)||(o?(await Pe({type:"select",name:"value",message:`File "${e.name}" exists but differs from template. What would you like to do?`,choices:[{title:"Keep existing file",value:"keep"},{title:"Replace with template version",value:"replace"}],initial:0})).value==="replace"?(C.copyFileSync(t,n),f.info(`Replaced "${e.name}" with template version.`)):f.info(`Kept existing "${e.name}".`):f.warn(`File "${e.name}" exists but differs from template. File will be skipped, this may lead to issues.`))}async function nn(e,t,n=!1){async function o(s,i,a){const c=z.join(i,s.name),u=z.join(a,s.name);s.isDirectory()?await nn(c,u,n):await kE(s,c,u,n)}const r=C.readdirSync(e,{withFileTypes:!0});C.existsSync(t)||C.mkdirSync(t,{recursive:!0}),await r.reduce(async(s,i)=>(await s,o(i,e,t)),Promise.resolve())}async function co(e=!1){try{const t=j.cwd(),n=z.join(t,"shared"),o=Ee("template/shared");if(!C.existsSync(o))return;await nn(o,n,e)}catch(t){f.error(`Error while processing shared folder: ${t.message}`),j.exit(1)}}async function PE(e,t){await co(),io(`${`template${t?"/blank":""}`}/sections/${`${t?"blank-section":"example-section"}`}`,"sections",e,"Section")}function zE(e){return{renameFiles:{"example-collection":`${e}`},targetPath:e,sourcePath:"template/collections",onCollectionCreated:()=>f.info(`Collection [${e}] has been created`)}}async function jE(e){const{targetPath:t,renameFiles:n,sourcePath:o,onCollectionCreated:r}=zE(e);try{const s=j.cwd(),i=W.join(s,"collections"),a=Ee(o),c=L.readdirSync(a);L.existsSync(i)?L.existsSync(W.join(i,t))&&(f.error(`Collection with the name: ${e} already exists. If you'd like to override it, delete previous version first`),j.exit(1)):L.mkdirSync(i),c.forEach(u=>Ie(i,a,u,n)),r()}catch(s){f.error(`Error while creating collection: ${s.message}`),j.exit(1)}}async function UE(e){await co(),io("template/footers/example-footer","footers",e,"Footer")}async function ME(e){await co(),io("template/headers/example-header","headers",e,"Header")}async function FE(e,t){try{const n=j.cwd(),o=W.join(n,"templates"),r=Ee("template/page-templates/example-template/pages");L.existsSync(W.join(o,e))||(f.error(`Template with the name: [${e}] doesn't exists. Please create a template first.`),j.exit(1)),L.existsSync(W.join(o,e,"pages",`${t}.ts`))&&(f.error(`Page with the name: [${t}.ts] already exists. If you'd like to override it, delete previous version first`),j.exit(1));const s=L.readFileSync(W.join(r,"custom.ts"),"utf-8").replace(/title\s*:\s*'Custom Page'/,`title: '${Wf(t)}'`),i=W.join(o,e,"pages",`${t}.ts`);L.writeFileSync(i,s),f.info(`Page [${t}.ts] created for template ${e}`)}catch(n){f.error(`Error while creating page: ${n.message}`),j.exit(1)}}async function GE(){try{const e=j.cwd(),t=Ee("template/reference"),n=L.readdirSync(t);let o=!1;for(const r of n){const s=W.join(t,r),i=W.join(e,r);L.existsSync(i)||L.mkdirSync(i,{recursive:!0});const a=L.readdirSync(s),c=L.readdirSync(i);if(r==="shared"){a.forEach(u=>{Ie(i,s,u)});continue}for(const u of a){if(u==="assets"){Ie(i,s,u);continue}if(c.includes(u)){const{name:d}=await Pe({type:"text",name:"name",message:`The "${u}" already exists in ${r} directory: provide a new name to keep both or press Esc to skip this one.`});d?(Ie(i,s,u,{[u]:d}),o=!0):f.info(`Skipped: ${u}`)}else Ie(i,s,u)}}f.info("Reference templates have been added to the app"),o&&f.warn("Some files or folders were renamed to avoid conflicts. Template files may need to be updated to reflect these changes.")}catch(e){f.error(`Error while creating template descriptors: ${e.message}`),j.exit(1)}}const xE=["**/example-template/pages/custom.ts"];async function BE(e){const{targetPath:t,renameFiles:n,sourcePath:o,onTemplateCreated:r}=$E(e);try{const s=j.cwd(),i=W.join(s,"templates"),a=Ee(o),c=L.readdirSync(a);L.existsSync(i)?L.existsSync(W.join(i,t))&&(f.error(`Template with the name: ${e} already exists. If you'd like to override it, delete previous version first`),j.exit(1)):L.mkdirSync(i),c.forEach(u=>Ie(i,a,u,n,xE)),ao("headers"),ao("footers"),ao("layouts"),r()}catch(s){f.error(`Error while creating template descriptors: ${s.message}`),j.exit(1)}}function ZE(){try{const e=T(Et.cwd(),`${$s}/shared/analytics.json`);V(e)&&ln(e,JSON.stringify({},null,2),"utf-8")}catch(e){console.warn("Can not clean up preview analytics.json file",e)}}function on({deploymentContext:e,sectionType:t=Se.SECTION}){const n=e.pathContext,o=n.toPath({sectionId:e.currentSection,sectionType:t,layoutId:e.layoutId,slotId:e.slotId}),r=o===void 0?go(n.fileName):go(n.fileName,{cwd:T(process.cwd(),o),ignore:n.ignore});return(n.isSingleton?r.splice(0):r).map(s=>({url:s,sectionType:t,context:e}))}const HE=e=>e.app.manifest.blocks.flatMap(t=>Mh.flatMap(n=>{const o={config:e,currentSection:t.id,pathContext:ut[n]};return on({deploymentContext:o,sectionType:t.type})})),VE=e=>xh.flatMap(t=>{const n={config:e,pathContext:ut[t]};return on({deploymentContext:n})}),WE=e=>e.app.manifest.layouts.flatMap(t=>Fh.flatMap(n=>{const o={config:e,pathContext:ut[n],currentSection:t.sectionId,layoutId:t.id};return on({deploymentContext:o})})),YE=e=>e.app.manifest.slots.flatMap(t=>Gh.flatMap(n=>{const o={config:e,pathContext:ut[n],currentSection:t.sectionId,layoutId:t.layoutId,slotId:t.id};return on({deploymentContext:o})})),KE=e=>`\x1B[32m${e}\x1B[0m`,JE=(e,t,n,o,r)=>{if(!e.total)return;const{loaded:s}=e,i=(Date.now()-r)/1e3;n.value+=s-o.value,o.value=s,t.update({speed:`${Te(n.value/i,2)}/s`})},XE=()=>new Hi.SingleBar({format:`|${KE("{bar}")}| {status} || {percentage}% || {value}/{total} Files || Speed: {speed}`,barCompleteChar:"\u2588",barIncompleteChar:"\u2591"});async function ui(e){await new Promise(t=>setTimeout(t,e))}const li="Please ensure you have built your application before deploying.";async function QE(){try{const e=await pn(T(Et.cwd(),Ls));return JSON.parse(e.toString())}catch(e){throw e.code==="ENOENT"?new Error(`Manifest file not found. ${li}`):e instanceof SyntaxError?new Error(`Manifest file is not valid. ${li}`):e}}const qE={value:0},ie=XE();let di=Date.now();const pi=e=>2**e*500;async function eg(e){const t=Zi(e.version,"patch");if(t===null)throw Error("Error while incrementing app version");e.version=t,ln(T(M.cwd(),"package.json"),`${JSON.stringify(e,null,2)}
59
+ `)}function tg(e){return e instanceof yo&&(e.code==="ECONNRESET"||e.response?.status!==void 0&&e.response?.status>=500&&e.response?.status<600)}function fi(e,t){return e<Uh&&tg(t)}async function hi(e,t,n,o){const r={value:0},s=e.config.app.manifest.templates.length>0||e.config.app.manifest.collections.length>0?kh:Dh;return e.config.axios.post(s,{file:Oi(T(M.cwd(),n!==void 0?n+t:t))},{params:{appClientId:e.config.app.crane.appClientId,type:e.pathContext.type,version:e.config.app.packageJson.version,...e.currentSection!==void 0&&{block:e.currentSection},...e.layoutId!==void 0&&{layoutId:e.layoutId},...e.slotId!==void 0&&{slotId:e.slotId},...!["dependencies","source_code"].includes(e.pathContext.type)&&{fileName:t}},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${e.config.app.crane.appSecretKey}`},onUploadProgress:i=>JE(i,ie,qE,r,di)}).then(i=>(ie.increment(),i)).catch(async i=>{if(fi(o,i))return await ui(pi(o)),hi(e,t,n,o+1);throw ie.increment(),i})}function ng(e){return ie.start(e.length+1,0,{speed:"N/A",status:"Deployment in progress"}),e.map(t=>{const n=t.context,o=n.pathContext.toPath({sectionId:n.currentSection,sectionType:t.sectionType,layoutId:n.layoutId,slotId:n.slotId});return hi(n,t.url,o,0)})}function og(e){const t=[...HE(e),...VE(e),...WE(e),...YE(e)];return ng(t)}async function mi(e,t=0){const n=e.app.manifest.templates.length>0||e.app.manifest.collections.length>0?zh:Ph;return e.axios.post(n,e.app.manifest,{params:{appClientId:e.app.crane.appClientId},headers:{Authorization:`Bearer ${e.app.crane.appSecretKey}`}}).catch(async o=>{if(fi(t,o))return await ui(pi(t)),mi(e,t+1);throw o})}async function rg(e){try{if(!xf.some(i=>V(T(M.cwd(),i))))throw new Error(We.INCORRECT_DISTRIBUTION_FOLDER(Ff));const t=e??Qn;f.info("Custom application deployment :: Started");const n=fn.create({baseURL:t});Bi(n,jh),f.info("Loading configuration files ...");const o=await Promise.all([Yt(),qn(),QE()]).then(([i,a,c])=>({axios:n,app:{crane:i,packageJson:a,manifest:c}}));f.info("Uploading files ..."),di=Date.now(),await Promise.all(og(o)).catch(i=>{ie.stop(),i.response?.status===404?f.error(Le(i,We.DEPRECATED_VERSION_DEPLOYMENT)):f.error(Le(i,We.ASSET_FILES_UPLOAD)),M.exit(1)}).finally(()=>{ie.increment(),ie.stop()}),ie.update({speed:"N/A",status:"Finalising deployment"}),await mi(o).catch(i=>{ie.stop(),i.response?.status===404?f.error(Le(i,We.DEPRECATED_VERSION_DEPLOYMENT)):f.error(Le(i,We.MANIFEST_DEPLOYMENT)),M.exit(1)}).finally(()=>{ie.increment(),ie.stop()});const r=o.app.manifest.blocks.map(i=>i.id),s=o.app.packageJson.version;f.info("Custom application deployment :: Successful"),f.info(`Current app version: ${s}`),f.info(`Deployed sections: ${r.sort().join(", ")}`),await eg(o.app.packageJson),o.app.manifest.templates.length>0&&f.info(`Deployed templates: ${o.app.manifest.templates.map(i=>i.id).sort().join(", ")}`),o.app.manifest.slots.length>0&&f.info(`Deployed slots: ${o.app.manifest.slots.map(i=>i.id).sort().join(", ")}`),o.app.manifest.collections.length>0&&f.info(`Deployed collections: ${o.app.manifest.collections.map(i=>i.id).sort().join(", ")}`)}catch(t){ie.stop(),f.error(Le(t,We.DEFAULT)),M.exit(1)}finally{ZE()}}function sg(){process.env.CRANE_DEBUG_ENABLED="true"}function ig(){return process.env.CRANE_DEBUG_ENABLED==="true"}function ag(e,...t){ig()&&console.debug(Ai(`[DEBUG] ${e}`),...t)}function cg(){return{name:"app-block-api",configureServer(e){e.middlewares.use(async(t,n,o)=>{e.moduleGraph.invalidateAll();const r=new ki(t.url||"",`http://${t.headers.host}`);if(r.pathname==="/api/v1/block-config"&&t.method==="GET"){const s=r.searchParams.get("section");if(!s){n.statusCode=400,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({error:"Missing blockId parameter"}));return}try{const i=await ri(),a=(await ii(i)).blocks.find(c=>c.id===s);n.statusCode=200,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify(a))}catch(i){n.statusCode=500,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({error:i.message}))}return}o()})}}}let ke=null;function ug(){ke&&ke.clients.forEach(e=>{e.readyState===Wi.OPEN&&e.send(JSON.stringify({type:"full-reload"}))})}async function lg(e,t){const n=T(`${e}/ssr-server.ts`),o=T(t);await ge({build:{lib:{entry:n,formats:["es"],fileName:()=>"ssr-server.mjs"},outDir:o,emptyOutDir:!1,minify:!1,rollupOptions:{external:["http","fs","@swc/core","module-from-string","linkedom"],output:{entryFileNames:"ssr-server.mjs"}},target:"esnext"}})}async function dg(e,t){const n=T(`${e}/shared/preview.ts`),o=T(`${e}/shared/utils.ts`),r=T(`${e}/shared/api-routes.ts`),s=T(t);await ge({build:{lib:{entry:n,formats:["es"],fileName:()=>"preview.js"},outDir:s,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"preview.js"}},target:"esnext"}}),await ge({build:{lib:{entry:o,formats:["es"],fileName:()=>"utils.js"},outDir:s,emptyOutDir:!1,minify:!1,rollupOptions:{output:{entryFileNames:"utils.js"}},target:"esnext"}}),await ge({build:{lib:{entry:r,formats:["es"],fileName:()=>"api-routes.js"},outDir:s,emptyOutDir:!1,minify:!1,rollupOptions:{external:["path","fs","http","https","url","stream","util","events","buffer"],output:{entryFileNames:"api-routes.js"}},target:"esnext"}})}async function pg(){const e="preview",t=`${e}/shared`,n="vite.config.js",o=`${e}/sections`,r=`${o}/preview.html`;[e,o].forEach(c=>{C.existsSync(c)||C.mkdirSync(c,{recursive:!0})});const s=Ee("template/preview");C.copyFileSync(`${s}/${n}`,`${e}/${n}`),await lg(s,e),C.copyFileSync(`${s}/sections/preview.html`,r);const i=`${s}/assets`,a=`${e}/assets`;C.existsSync(i)&&(C.mkdirSync(a,{recursive:!0}),C.readdirSync(i).forEach(c=>{C.copyFileSync(`${i}/${c}`,`${a}/${c}`)})),C.existsSync(t)||C.mkdirSync(t),await dg(s,t)}function fg(e){const t=e.replace(/\\/g,"/").match(/(?:sections|headers|footers)\/([^/]+)/);return t?t[1]:null}function hg(e){const t=e.replace(/\\/g,"/");return t.includes("shared")&&!t.includes("sections")&&!t.includes("headers")&&!t.includes("footers")}async function mg(e){const t=(await ai()).find(o=>o.name===e);if(!t){console.warn(`Block ${e} not found, falling back to full build`),await tn(!0);return}const n=ni(t);await ti([n]),console.log(`Block ${e} rebuilt successfully`)}var Eg=(e=>(e.FULL="full",e.INCREMENTAL="incremental",e))(Eg||{});function gg(){return{timeout:null,inProgress:!1,pendingBuild:null}}function _g(e,t){const n=async o=>{e.inProgress=!0;try{o.type==="incremental"&&o.blockName?await mg(o.blockName):await tn(!0),t.ws.send({type:"full-reload",path:"*"}),ug()}catch(r){console.error("Build error:",r)}finally{if(e.inProgress=!1,e.pendingBuild){const r=e.pendingBuild;e.pendingBuild=null,setTimeout(()=>n(r),0)}}};return async o=>{if(e.inProgress){o.type==="full"||e.pendingBuild?.type==="full"?e.pendingBuild={type:"full"}:e.pendingBuild=o;return}await n(o)}}function yg(e){const t=e.replace(/\\/g,"/"),n=t.match(/sections\/([^/]+)/),o=t.match(/headers\/([^/]+)/),r=t.match(/footers\/([^/]+)/),s=t.match(/shared\//);return!!(n||o||r||s)}function Sg(e,t){return async n=>{if(!yg(n))return;e.timeout&&clearTimeout(e.timeout);const o=fg(n),r=hg(n);e.timeout=setTimeout(async()=>{r?await t({type:"full"}):o&&await t({type:"incremental",blockName:o})},1e3)}}function Tg(e,t){const n=gg(),o=_g(n,e),r=Sg(n,o);e.watcher.add(t),e.watcher.on("add",r),e.watcher.on("change",r),e.watcher.on("unlink",r)}async function Og(){const e=z.resolve(process.cwd(),"preview/ssr-server.mjs");if(!C.existsSync(e))throw console.warn(`\u26A0\uFE0F SSR server not found at ${e}`),new Error(`SSR server not found at ${e}`);process.env.PREVIEW_SSR_PORT="0";let t=e;process.platform==="win32"&&(t=_o(e).href);const n=await import(t),{server:o,port:r}=await n.startServer();return{server:o,port:r}}function Ig(){ke=new Vi({port:0}),ke.on("listening",()=>{const e=ke?.address();if(e&&typeof e=="object"){const t=e.port;process.env.CRANE_WEBSOCKET_PORT=String(t)}})}async function wg(){const e=z.resolve(process.cwd(),"preview/vite.config.js"),t=z.resolve(process.cwd(),"sections/**/*"),n=z.resolve(process.cwd(),"headers/**/*"),o=z.resolve(process.cwd(),"footers/**/*"),r=z.resolve(process.cwd(),"shared/**/*"),s=await $i({configFile:e,root:process.cwd(),plugins:[cg()]});return await s.listen(),Tg(s,[t,n,o,r]),s}async function vg(){await tn(),await pg(),console.log(`
60
60
  \u{1F4E6} Starting preview servers...
61
- `);let e=null,t=null;WE("Starting SSR server");const n=await cg();e=n.server,t=n.port,process.env.PREVIEW_SSR_PORT=String(t),lg();const o=await ug(),s=()=>{e&&e.close(),ke&&ke.close(),o.close(),process.exit(0)};return process.on("SIGINT",s),process.on("SIGTERM",s),o}const pg=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i,fg=/^[-a-zA-Z0-9_.^~<>=|* +]+$/;function di({name:e,version:t}){return pg.test(e)&&fg.test(t)}function tn(e){if(!V(e))return{dependencies:{},devDependencies:{},overrides:{}};let t;try{t=JSON.parse(sn(e,"utf-8"))}catch{return{dependencies:{},devDependencies:{},overrides:{}}}const n=t.overrides??{},o=Object.fromEntries(Object.entries(n).filter(s=>typeof s[1]=="string"));return{dependencies:t.dependencies??{},devDependencies:t.devDependencies??{},overrides:o}}function hg(e,t){const n=tn(ne(e,"package.json")),o=tn(ne(t,"package.json")),s={...o.dependencies,...o.devDependencies},r=[];for(const[i,a]of Object.entries(n.dependencies))s[i]||r.push({name:i,version:a,isDev:!1});for(const[i,a]of Object.entries(n.devDependencies))s[i]||r.push({name:i,version:a,isDev:!0});return r.sort((i,a)=>i.name.localeCompare(a.name))}function mg(e,t){const n=tn(ne(e,"package.json")).overrides,o=tn(ne(t,"package.json")).overrides;return Object.fromEntries(Object.entries(n).filter(([s,r])=>o[s]!==r))}function Eg(e){const t=Object.entries(e);if(t.length!==0){f.warn(`
62
- The pulled source code defines npm overrides not present in your project:`);for(const[n,o]of t)f.warn(` - ${n}: "${o}"`);f.warn('Review these and add them to your package.json "overrides" section if needed.')}}function pi(e){return e.map(t=>`${t.name}@${t.version}`).join(" ")}function gg(e){const t=e.filter(s=>!s.isDev),n=e.filter(s=>s.isDev),o=[];return t.length>0&&o.push(`npm install ${pi(t)}`),n.length>0&&o.push(`npm install -D ${pi(n)}`),o}function _g(e,t){const n=[{args:["install"],specs:e.filter(o=>!o.isDev).map(o=>`${o.name}@${o.version}`)},{args:["install","-D"],specs:e.filter(o=>o.isDev).map(o=>`${o.name}@${o.version}`)}];for(const{args:o,specs:s}of n){if(s.length===0)continue;const r=[...o,...s];f.info(`Running: npm ${r.join(" ")}`);const i=Zi("npm",r,{cwd:t,stdio:"inherit"});if(i.status!==0)throw new Error(`npm ${o.join(" ")} exited with code ${i.status}`)}}async function yg(e,t){if(e.length===0)return;const n=e.filter(c=>!di(c));if(n.length>0){f.warn("Skipping dependencies with unsafe names/versions:");for(const c of n)f.warn(` - ${c.name}@${c.version}`)}const o=e.filter(di);if(o.length===0)return;const s=o.length===1?"dependency":"dependencies";f.warn(`
63
- The pulled source code uses ${o.length} ${s} not found in your project:`);const r=o.filter(c=>!c.isDev),i=o.filter(c=>c.isDev);if(r.length>0){f.warn(" dependencies:");for(const c of r)f.warn(` - ${c.name}@${c.version}`)}if(i.length>0){f.warn(" devDependencies:");for(const c of i)f.warn(` - ${c.name}@${c.version}`)}const a=gg(o);switch((await Pe({type:"select",name:"value",message:"How would you like to handle these dependencies?",choices:[{title:"Install dependencies now",value:"install",description:`Runs: ${a.join(" && ")}`},{title:"Add to package.json without installing",value:"add"},{title:"Show install command (copy & run later)",value:"show"},{title:"Skip",value:"skip"}],initial:0})).value){case"install":try{_g(o,t),f.info("Dependencies installed successfully.")}catch{f.error("Failed to install dependencies. You can try running the commands manually:");for(const c of a)f.warn(` ${c}`)}break;case"add":{const c=ne(t,"package.json"),l=JSON.parse(sn(c,"utf-8"));if(r.length>0){l.dependencies||(l.dependencies={});for(const d of r)l.dependencies[d.name]=d.version;l.dependencies=Object.fromEntries(Object.entries(l.dependencies).sort(([d],[m])=>d.localeCompare(m)))}if(i.length>0){l.devDependencies||(l.devDependencies={});for(const d of i)l.devDependencies[d.name]=d.version;l.devDependencies=Object.fromEntries(Object.entries(l.devDependencies).sort(([d],[m])=>d.localeCompare(m)))}an(c,`${JSON.stringify(l,null,2)}
61
+ `);let e=null,t=null;ag("Starting SSR server");const n=await Og();e=n.server,t=n.port,process.env.PREVIEW_SSR_PORT=String(t),Ig();const o=await wg(),r=()=>{e&&e.close(),ke&&ke.close(),o.close(),process.exit(0)};return process.on("SIGINT",r),process.on("SIGTERM",r),o}const Cg=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i,Rg=/^[-a-zA-Z0-9_.^~<>=|* +]+$/;function Ei({name:e,version:t}){return Cg.test(e)&&Rg.test(t)}function rn(e){if(!V(e))return{dependencies:{},devDependencies:{},overrides:{}};let t;try{t=JSON.parse(cn(e,"utf-8"))}catch{return{dependencies:{},devDependencies:{},overrides:{}}}const n=t.overrides??{},o=Object.fromEntries(Object.entries(n).filter(r=>typeof r[1]=="string"));return{dependencies:t.dependencies??{},devDependencies:t.devDependencies??{},overrides:o}}function bg(e,t){const n=rn(ne(e,"package.json")),o=rn(ne(t,"package.json")),r={...o.dependencies,...o.devDependencies},s=[];for(const[i,a]of Object.entries(n.dependencies))r[i]||s.push({name:i,version:a,isDev:!1});for(const[i,a]of Object.entries(n.devDependencies))r[i]||s.push({name:i,version:a,isDev:!0});return s.sort((i,a)=>i.name.localeCompare(a.name))}function Ag(e,t){const n=rn(ne(e,"package.json")).overrides,o=rn(ne(t,"package.json")).overrides;return Object.fromEntries(Object.entries(n).filter(([r,s])=>o[r]!==s))}function Ng(e){const t=Object.entries(e);if(t.length!==0){f.warn(`
62
+ The pulled source code defines npm overrides not present in your project:`);for(const[n,o]of t)f.warn(` - ${n}: "${o}"`);f.warn('Review these and add them to your package.json "overrides" section if needed.')}}function gi(e){return e.map(t=>`${t.name}@${t.version}`).join(" ")}function $g(e){const t=e.filter(r=>!r.isDev),n=e.filter(r=>r.isDev),o=[];return t.length>0&&o.push(`npm install ${gi(t)}`),n.length>0&&o.push(`npm install -D ${gi(n)}`),o}function Lg(e,t){const n=[{args:["install"],specs:e.filter(o=>!o.isDev).map(o=>`${o.name}@${o.version}`)},{args:["install","-D"],specs:e.filter(o=>o.isDev).map(o=>`${o.name}@${o.version}`)}];for(const{args:o,specs:r}of n){if(r.length===0)continue;const s=[...o,...r];f.info(`Running: npm ${s.join(" ")}`);const i=Ki("npm",s,{cwd:t,stdio:"inherit"});if(i.status!==0)throw new Error(`npm ${o.join(" ")} exited with code ${i.status}`)}}async function Dg(e,t){if(e.length===0)return;const n=e.filter(c=>!Ei(c));if(n.length>0){f.warn("Skipping dependencies with unsafe names/versions:");for(const c of n)f.warn(` - ${c.name}@${c.version}`)}const o=e.filter(Ei);if(o.length===0)return;const r=o.length===1?"dependency":"dependencies";f.warn(`
63
+ The pulled source code uses ${o.length} ${r} not found in your project:`);const s=o.filter(c=>!c.isDev),i=o.filter(c=>c.isDev);if(s.length>0){f.warn(" dependencies:");for(const c of s)f.warn(` - ${c.name}@${c.version}`)}if(i.length>0){f.warn(" devDependencies:");for(const c of i)f.warn(` - ${c.name}@${c.version}`)}const a=$g(o);switch((await Pe({type:"select",name:"value",message:"How would you like to handle these dependencies?",choices:[{title:"Install dependencies now",value:"install",description:`Runs: ${a.join(" && ")}`},{title:"Add to package.json without installing",value:"add"},{title:"Show install command (copy & run later)",value:"show"},{title:"Skip",value:"skip"}],initial:0})).value){case"install":try{Lg(o,t),f.info("Dependencies installed successfully.")}catch{f.error("Failed to install dependencies. You can try running the commands manually:");for(const c of a)f.warn(` ${c}`)}break;case"add":{const c=ne(t,"package.json"),u=JSON.parse(cn(c,"utf-8"));if(s.length>0){u.dependencies||(u.dependencies={});for(const d of s)u.dependencies[d.name]=d.version;u.dependencies=Object.fromEntries(Object.entries(u.dependencies).sort(([d],[m])=>d.localeCompare(m)))}if(i.length>0){u.devDependencies||(u.devDependencies={});for(const d of i)u.devDependencies[d.name]=d.version;u.devDependencies=Object.fromEntries(Object.entries(u.devDependencies).sort(([d],[m])=>d.localeCompare(m)))}ln(c,`${JSON.stringify(u,null,2)}
64
64
  `),f.info('Dependencies added to package.json. Run "npm install" to install them.');break}case"show":f.info(`
65
- Run the following command(s) to install the dependencies:`);for(const c of a)f.info(` ${c}`);break;default:f.info("Skipping dependency installation.");break}}async function Sg(e,t,n){const o=t.split("_").pop()??t,s=ne(e,"sections",o),r=ne(e,o);let i=null;if(V(s)&&Qe(s).isDirectory()?i=s:V(r)&&Qe(r).isDirectory()&&(i=r),i){const a=ne(n,o);V(a)&&((await Pe({type:"confirm",name:"value",message:`Section directory [sections/${o}/] already exists. Do you want to overwrite it?`,initial:!1})).value||(f.error("Operation cancelled. Section directory already exists."),F.exit(1)),f.info(`Deleting existing section directory [sections/${o}/]...`),co(a,{recursive:!0,force:!0})),f.info(`Copying section [sections/${o}/]...`),await qt(i,a,!1)}else f.error(`Section directory [sections/${o}/] not found in source code.`),F.exit(1)}async function Tg(e,t,n){const o=_i(ne(Bi.tmpdir(),"crane-source-"));new fo(Buffer.from(e)).extractAllTo(o,!0);try{const s=F.cwd(),r=ne(s,"sections");V(r)||yi(r,{recursive:!0}),await Sg(o,t,r);const i=ne(o,"shared");if(V(i)){const c=ne(s,"shared");f.info("Copying shared folder..."),await qt(i,c,!0)}const a=hg(o,s);await yg(a,s),Eg(mg(o,s)),f.info(`Source code for section [${n}] has been copied.`)}finally{co(o,{recursive:!0,force:!0})}}async function fi(e){const t=e??Kn,n=un.create({baseURL:t}),o=await Vt();return[...(await n.get("/api/v1/custom-apps/manifests/collections/sections",{params:{appClientId:o.appClientId},headers:{Authorization:`Bearer ${o.appSecretKey}`}})).data.sections]}async function Og(e,t){const n=(await fi(t)).find(o=>o.sectionId===e);return n||(f.error(`Section [${e}] not found in collection sections list.`),F.exit(1)),n}async function Ig(e,t,n){const o=n??Kn,s=un.create({baseURL:o}),r=await Vt();f.info(`Downloading source code for section [${e}]...`);const i=await s.get(`/api/v1/custom-apps/manifests/collections/sections/${e}/source-code`,{params:{appClientId:r.appClientId},headers:{Authorization:`Bearer ${r.appSecretKey}`},responseType:"arraybuffer"});await Tg(i.data,t,e)}async function wg(e){try{f.info("Fetching sections list...");const t=await fi(e);f.info("Sections list retrieved successfully:");const n=t.map(o=>({sectionId:o.sectionId,openSource:o.openSource,type:o.type}));console.log(JSON.stringify({sections:n},null,2))}catch(t){f.error(Le(t,"Error while fetching sections list")),F.exit(1)}}async function vg(e,t){try{const n=await Og(e,t);n.openSource||(f.error(`Section [${e}] is not open source. Only open source sections can be pulled.`),F.exit(1)),await Ig(e,n.sectionId,t)}catch(n){f.error(Le(n,"Error while pulling section")),F.exit(1)}}async function Cg(e,t){const{list:n,section:o}=e;if(n){await wg(t);return}if(o){await vg(o,t);return}f.error("Please specify an action. Use --list to fetch sections list or --section to pull a section."),F.exit(1)}const Rg={deploy:["url"],pull:["url"],init:[""],build:["generatePreview"]},bg=["preview","build","deploy","pull"];function Ag(e,t){return bg.includes(e.rawName)?!1:e.options.length!==0&&Object.keys(t).length===1}function Ng(e){return e.includes("-h")||e.includes("--help")}function $g(e,t){return Object.keys(t).some(n=>n!=="--"&&!e.hasOption(n)&&!Rg[e.rawName]?.includes(n))}function Lg(e){return e.length!==0}function Dg(e,t,n){return e.matchedCommand!==void 0&&(Ag(e.matchedCommand,n)||Ng(e.rawArgs)||$g(e.matchedCommand,e.options)||Lg(t))}function kg(e,t,n){e.matchedCommand&&!Dg(e,t,n)?e.runMatchedCommand():e.outputHelp()}function nn(e){if(Mf(e))return console.log("Please specify a name for your resource."),!1;const{isValid:t,errorMessage:n}=Ff(e);return n&&console.log(n),t}async function io(e){const t=await Pe({type:"text",name:"name",message:`Please specify a name for your ${e}:`});if(t.name!==void 0){const n=z.basename(t.name);return nn(n)?n:io(e)}}async function Pg(e,t,n,o){const s=await io(t);return s===void 0?(console.log(`You can use ${n} to directly specify the name of the ${t}.`),e.outputHelp()):o(s)}async function Xe(e,t,n,o,s){if(s!==void 0)if(!nn(s))await Pg(e,t,n,o);else{const r=z.basename(s.toString());await o(r)}}function zg(){C.existsSync("./templates")||(f.error(`No template found. Please create a template first using ${ce("init --template <name>")}`),process.exit(1));const e=C.readdirSync("./templates",{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name).filter(t=>t!=="assets");return e.length===0&&(f.error(`No template found. Please create a template first using ${ce("init --template <name>")}`),process.exit(1)),e}async function jg(e){const t=zg();if(typeof e=="string"||typeof e=="number"){if(t.includes(e.toString()))return e.toString();nn(e)?f.warn(`Template [${e}] doesn't exist`):f.error(`[${e}] is an invalid template name.`)}const n=await Pe({type:"select",name:"choice",message:"Please choose a template:",choices:t.map(o=>({title:o,value:o}))});return n.choice||(f.error("No template selected"),process.exit(1)),n.choice}async function Ug(e,t){if(typeof t=="string"||typeof t=="number"){if(nn(t))return t.toString();f.error(`${t} is invalid name.`)}return io(e)}async function Fg(e,t,n){const o=await jg(t),s=await Ug("page",n);if(s===void 0)return console.log(`You can use ${ce("init --page <name>")} to directly specify the name of the page.`),e.outputHelp();await CE(o,s)}async function Mg(e,t){try{const{app:n,section:o,header:s,footer:r,template:i,referenceTemplate:a,page:c,blank:l,collection:d}=e;await Xe(t,"app",ce("init --app <name>"),yE,n),await Xe(t,"section",ce(`init --section <name>${l?" --blank":""}`),m=>TE(m,l===!0),o),await Xe(t,"header",ce("init --header <name>"),vE,s),await Xe(t,"footer",ce("init --footer <name>"),wE,r),c===void 0?await Xe(t,"template",ce("init --template <name>"),AE,i):await Fg(t,i,c),await Xe(t,"collection",ce("init --collection <name>"),IE,d),a&&await RE()}catch(n){f.error(`Error while executing init operation: ${n.message}`),process.exit(1)}}function Gg(){try{const e=Ti("crane");e.option("-h, --help","Display this message"),e.command("init","Initialize a new resource in the form of a directory.").option("--app [name]","Creates an app folder inside your current directory.").option("--section [name]","Creates the files necessary for one custom section with the given name, this can be repeated for each section.").option("--header [name]","Creates the files necessary for one custom header with the given name, this can be repeated for each header.").option("--footer [name]","Creates the files necessary for one custom footer with the given name, this can be repeated for each footer.").option("--template [name]","Creates the directory and files necessary to build a custom template inside your app folder.").option("--collection [name]","Creates a collection folder containing custom sections, headers, and footers.").option("--reference-template","Adds files necessary for the reference templates inside your app folder. ").option("--page [name]","Create the file necessary for one custom page with the given name, this can be repeated for each custom page.").option("--blank","Creates an empty resource with minimal files (use with section).").allowUnknownOptions().action(async n=>Mg(n,e)),e.command("build","Builds your resource code").option("-v, --verbose","Show detailed build output").allowUnknownOptions().action(n=>Qt(!1,n.verbose===!0)),e.command("preview","Runs a local server to preview resources").option("--verbose","Show debug logs").allowUnknownOptions().action(async n=>{n.verbose&&HE(),await dg()}),e.command("deploy","Deploys your resource code").allowUnknownOptions().action(()=>ZE(e.options.url)),e.command("pull","Pulls resources from the API").option("--list","Fetches the list of sections from the API").option("--section [name]","Downloads source code for an open source section").allowUnknownOptions().action(async n=>Cg(n,e.options.url)),e.version(Hi),e.usage("<action> <resource>");const t=e.parse(process.argv,{run:!1});kg(e,t.args,t.options)}catch(e){f.error(`Error while parsing input: ${e.message}`),process.exit(1)}}export{Gg as run};
65
+ Run the following command(s) to install the dependencies:`);for(const c of a)f.info(` ${c}`);break;default:f.info("Skipping dependency installation.");break}}async function kg(e,t,n){const o=t.split("_").pop()??t,r=ne(e,"sections",o),s=ne(e,o);let i=null;if(V(r)&&Qe(r).isDirectory()?i=r:V(s)&&Qe(s).isDirectory()&&(i=s),i){const a=ne(n,o);V(a)&&((await Pe({type:"confirm",name:"value",message:`Section directory [sections/${o}/] already exists. Do you want to overwrite it?`,initial:!1})).value||(f.error("Operation cancelled. Section directory already exists."),M.exit(1)),f.info(`Deleting existing section directory [sections/${o}/]...`),po(a,{recursive:!0,force:!0})),f.info(`Copying section [sections/${o}/]...`),await nn(i,a,!1)}else f.error(`Section directory [sections/${o}/] not found in source code.`),M.exit(1)}async function Pg(e,t,n){const o=Ii(ne(Yi.tmpdir(),"crane-source-"));new Eo(Buffer.from(e)).extractAllTo(o,!0);try{const r=M.cwd(),s=ne(r,"sections");V(s)||wi(s,{recursive:!0}),await kg(o,t,s);const i=ne(o,"shared");if(V(i)){const c=ne(r,"shared");f.info("Copying shared folder..."),await nn(i,c,!0)}const a=bg(o,r);await Dg(a,r),Ng(Ag(o,r)),f.info(`Source code for section [${n}] has been copied.`)}finally{po(o,{recursive:!0,force:!0})}}async function _i(e){const t=e??Qn,n=fn.create({baseURL:t}),o=await Yt();return[...(await n.get("/api/v1/custom-apps/manifests/collections/sections",{params:{appClientId:o.appClientId},headers:{Authorization:`Bearer ${o.appSecretKey}`}})).data.sections]}async function zg(e,t){const n=(await _i(t)).find(o=>o.sectionId===e);return n||(f.error(`Section [${e}] not found in collection sections list.`),M.exit(1)),n}async function jg(e,t,n){const o=n??Qn,r=fn.create({baseURL:o}),s=await Yt();f.info(`Downloading source code for section [${e}]...`);const i=await r.get(`/api/v1/custom-apps/manifests/collections/sections/${e}/source-code`,{params:{appClientId:s.appClientId},headers:{Authorization:`Bearer ${s.appSecretKey}`},responseType:"arraybuffer"});await Pg(i.data,t,e)}async function Ug(e){try{f.info("Fetching sections list...");const t=await _i(e);f.info("Sections list retrieved successfully:");const n=t.map(o=>({sectionId:o.sectionId,openSource:o.openSource,type:o.type}));console.log(JSON.stringify({sections:n},null,2))}catch(t){f.error(Le(t,"Error while fetching sections list")),M.exit(1)}}async function Mg(e,t){try{const n=await zg(e,t);n.openSource||(f.error(`Section [${e}] is not open source. Only open source sections can be pulled.`),M.exit(1)),await jg(e,n.sectionId,t)}catch(n){f.error(Le(n,"Error while pulling section")),M.exit(1)}}async function Fg(e,t){const{list:n,section:o}=e;if(n){await Ug(t);return}if(o){await Mg(o,t);return}f.error("Please specify an action. Use --list to fetch sections list or --section to pull a section."),M.exit(1)}const Gg={deploy:["url"],pull:["url"],init:[""],build:["generatePreview"]},xg=["preview","build","deploy","pull"];function Bg(e,t){return xg.includes(e.rawName)?!1:e.options.length!==0&&Object.keys(t).length===1}function Zg(e){return e.includes("-h")||e.includes("--help")}function Hg(e,t){return Object.keys(t).some(n=>n!=="--"&&!e.hasOption(n)&&!Gg[e.rawName]?.includes(n))}function Vg(e){return e.length!==0}function Wg(e,t,n){return e.matchedCommand!==void 0&&(Bg(e.matchedCommand,n)||Zg(e.rawArgs)||Hg(e.matchedCommand,e.options)||Vg(t))}function Yg(e,t,n){e.matchedCommand&&!Wg(e,t,n)?e.runMatchedCommand():e.outputHelp()}function sn(e){if(Hf(e))return console.log("Please specify a name for your resource."),!1;const{isValid:t,errorMessage:n}=Zf(e);return n&&console.log(n),t}async function uo(e){const t=await Pe({type:"text",name:"name",message:`Please specify a name for your ${e}:`});if(t.name!==void 0){const n=z.basename(t.name);return sn(n)?n:uo(e)}}async function Kg(e,t,n,o){const r=await uo(t);return r===void 0?(console.log(`You can use ${n} to directly specify the name of the ${t}.`),e.outputHelp()):o(r)}async function Xe(e,t,n,o,r){if(r!==void 0)if(!sn(r))await Kg(e,t,n,o);else{const s=z.basename(r.toString());await o(s)}}function Jg(){C.existsSync("./templates")||(f.error(`No template found. Please create a template first using ${ce("init --template <name>")}`),process.exit(1));const e=C.readdirSync("./templates",{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name).filter(t=>t!=="assets");return e.length===0&&(f.error(`No template found. Please create a template first using ${ce("init --template <name>")}`),process.exit(1)),e}async function Xg(e){const t=Jg();if(typeof e=="string"||typeof e=="number"){if(t.includes(e.toString()))return e.toString();sn(e)?f.warn(`Template [${e}] doesn't exist`):f.error(`[${e}] is an invalid template name.`)}const n=await Pe({type:"select",name:"choice",message:"Please choose a template:",choices:t.map(o=>({title:o,value:o}))});return n.choice||(f.error("No template selected"),process.exit(1)),n.choice}async function Qg(e,t){if(typeof t=="string"||typeof t=="number"){if(sn(t))return t.toString();f.error(`${t} is invalid name.`)}return uo(e)}async function qg(e,t,n){const o=await Xg(t),r=await Qg("page",n);if(r===void 0)return console.log(`You can use ${ce("init --page <name>")} to directly specify the name of the page.`),e.outputHelp();await FE(o,r)}async function e_(e,t){try{const{app:n,section:o,header:r,footer:s,template:i,referenceTemplate:a,page:c,blank:u,collection:d}=e;await Xe(t,"app",ce("init --app <name>"),DE,n),await Xe(t,"section",ce(`init --section <name>${u?" --blank":""}`),m=>PE(m,u===!0),o),await Xe(t,"header",ce("init --header <name>"),ME,r),await Xe(t,"footer",ce("init --footer <name>"),UE,s),c===void 0?await Xe(t,"template",ce("init --template <name>"),BE,i):await qg(t,i,c),await Xe(t,"collection",ce("init --collection <name>"),jE,d),a&&await GE()}catch(n){f.error(`Error while executing init operation: ${n.message}`),process.exit(1)}}function t_(){try{const e=Ci("crane");e.option("-h, --help","Display this message"),e.command("init","Initialize a new resource in the form of a directory.").option("--app [name]","Creates an app folder inside your current directory.").option("--section [name]","Creates the files necessary for one custom section with the given name, this can be repeated for each section.").option("--header [name]","Creates the files necessary for one custom header with the given name, this can be repeated for each header.").option("--footer [name]","Creates the files necessary for one custom footer with the given name, this can be repeated for each footer.").option("--template [name]","Creates the directory and files necessary to build a custom template inside your app folder.").option("--collection [name]","Creates a collection folder containing custom sections, headers, and footers.").option("--reference-template","Adds files necessary for the reference templates inside your app folder. ").option("--page [name]","Create the file necessary for one custom page with the given name, this can be repeated for each custom page.").option("--blank","Creates an empty resource with minimal files (use with section).").allowUnknownOptions().action(async n=>e_(n,e)),e.command("build","Builds your resource code").option("-v, --verbose","Show detailed build output").allowUnknownOptions().action(n=>tn(!1,n.verbose===!0)),e.command("preview","Runs a local server to preview resources").option("--verbose","Show debug logs").allowUnknownOptions().action(async n=>{n.verbose&&sg(),await vg()}),e.command("deploy","Deploys your resource code").allowUnknownOptions().action(()=>rg(e.options.url)),e.command("pull","Pulls resources from the API").option("--list","Fetches the list of sections from the API").option("--section [name]","Downloads source code for an open source section").allowUnknownOptions().action(async n=>Fg(n,e.options.url)),e.version(Ji),e.usage("<action> <resource>");const t=e.parse(process.argv,{run:!1});Yg(e,t.args,t.options)}catch(e){f.error(`Error while parsing input: ${e.message}`),process.exit(1)}}export{t_ as run};