@lightspeed/crane 3.4.0 → 3.4.2-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/CHANGELOG.md +23 -0
- package/dist/cli.mjs +30 -30
- package/package.json +2 -2
- package/template/preview/assets/close.svg +3 -0
- package/template/preview/assets/crane-logo.svg +16 -0
- package/template/preview/sections/preview.html +99 -1
- package/template/preview/shared/preview.ts +6 -4
- package/template/preview/vite.config.js +1 -0
- package/template/reference/sections/intro-slider/settings/translations.ts +1 -0
- package/template/sections/example-section/component/image/Image.vue +4 -3
- package/template/footers/example-footer/entity/color.ts +0 -4
- package/template/reference/sections/featured-products/entity/color.ts +0 -4
- package/template/reference/sections/intro-slider/entity/color.ts +0 -4
- package/template/reference/sections/trending-categories/entity/color.ts +0 -4
- package/template/sections/example-section/entity/color.ts +0 -4
package/dist/cli.mjs
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import*as pt from"fs";import b,{existsSync as H,readFileSync as on,statSync as Xe,promises as rn,writeFileSync as sn,createReadStream as ri,mkdtempSync as si,mkdirSync as ii,rmSync as co}from"fs";import*as ft from"path";import j,{resolve as S,dirname as uo,relative as lo,basename as ai,sep as an,parse as po,join as ee}from"path";import ci from"cac";import{green as ue,yellow as ui,red as li,gray as di}from"kolorist";import Le from"prompts";import fo from"adm-zip";import{glob as I,globSync as ho}from"glob";import le from"typescript";import{normalizePath as pi,build as Ee,defineConfig as ht,createServer as fi}from"vite";import{SectionTypeEnum as ge,BackgroundStyleEnum as cn,ButtonAppearanceEnum as hi,ButtonSizeEnum as mi,ButtonShapeEnum as Ei,OverlayTypeEnum as mt,DesignEditorType as Q,PluginTypeEnum as te,ConfigTypeEnum as N}from"@lightspeed/crane-api";import*as M from"process";import Et from"process";import{JSONPath as gi}from"jsonpath-plus";import{readFile as un,writeFile as _i}from"fs/promises";import{pathToFileURL as mo,URL as yi}from"url";import ln,{AxiosError as Eo}from"axios";import Si from"tinycolor2";import{builtinModules as go}from"module";import{viteExternalsPlugin as _o}from"vite-plugin-externals";import Ti from"vite-plugin-compression";import Oi from"@vitejs/plugin-vue";import Ii from"vite-tsconfig-paths";import wi from"vite-plugin-checker";import{encode as vi}from"@jridgewell/sourcemap-codec";import{promisify as yo}from"node:util";import So from"node:zlib";import D from"node:fs";import V from"node:path";import U from"node:process";import Ci from"micromatch";import{fileURLToPath as Ri}from"node:url";import{ConcurrencyManager as bi}from"axios-concurrency";import{inc as Ai}from"semver";import Ni from"cli-progress";import{WebSocketServer as $i,WebSocket as Di}from"ws";import*as Li from"os";import{spawnSync as ki}from"child_process";const Pi="3.3.0",x={[ge.SECTION]:{source:"sections",dist:"dist/sections"},[ge.HEADER]:{source:"headers",dist:"dist/headers"},[ge.FOOTER]:{source:"footers",dist:"dist/footers"}};var C=(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))(C||{});function ke(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:ke(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:ke(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}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 y=d[m];y in a||(a[y]=u[y].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 Pe 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,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}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 zi(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 Io=Symbol("evaluating");function R(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==Io)return o===void 0&&(o=Io,o=n()),o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Re(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Oe(...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 ji(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 Ui=gt(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ze(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 ze(e)?{...e}:Array.isArray(e)?[...e]:e}const Mi=new Set(["string","number","symbol"]);function je(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ie(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 Fi(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 Gi(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=Oe(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 Re(this,"shape",i),i},checks:[]});return Ie(e,s)}function Zi(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=Oe(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 Re(this,"shape",i),i},checks:[]});return Ie(e,s)}function Bi(e,t){if(!ze(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=Oe(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Re(this,"shape",s),s}});return Ie(e,r)}function Hi(e,t){if(!ze(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Oe(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return Re(this,"shape",o),o}});return Ie(e,n)}function Vi(e,t){const n=Oe(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return Re(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return Ie(e,n)}function Wi(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=Oe(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 Re(this,"shape",c),c},checks:[]});return Ie(t,i)}function Yi(e,t,n){const o=Oe(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 Re(this,"shape",s),s}});return Ie(t,o)}function Ue(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 we(e,t,n){const o={...e,path:e.path??[]};if(!e.message){const r=_t(e.inst?._zod.def?.error?.(e))??_t(t?.error?.(e))??_t(n.customError?.(e))??_t(n.localeError?.(e))??"Invalid input";o.message=r}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 qe(...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=l("$ZodError",Ro),Ao=l("$ZodError",Ro,{Parent:Error});function Ki(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 Ji(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 En=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 Pe;if(i.issues.length){const a=new(r?.Err??e)(i.issues.map(c=>we(c,s,_e())));throw vo(a,r?.callee),a}return i.value},gn=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=>we(c,s,_e())));throw vo(a,r?.callee),a}return i.value},yt=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 Pe;return s.issues.length?{success:!1,error:new(e??bo)(s.issues.map(i=>we(i,r,_e())))}:{success:!0,data:s.value}},Xi=yt(Ao),St=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=>we(i,r,_e())))}:{success:!0,data:s.value}},Qi=St(Ao),qi=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return En(e)(t,n,r)},ea=e=>(t,n,o)=>En(e)(t,n,o),ta=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return gn(e)(t,n,r)},na=e=>async(t,n,o)=>gn(e)(t,n,o),oa=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return yt(e)(t,n,r)},ra=e=>(t,n,o)=>yt(e)(t,n,o),sa=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return St(e)(t,n,r)},ia=e=>async(t,n,o)=>St(e)(t,n,o),aa=/^[cC][^\s-]{8,}$/,ca=/^[0-9a-z]+$/,ua=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,la=/^[0-9a-vA-V]{20}$/,da=/^[A-Za-z0-9]{27}$/,pa=/^[a-zA-Z0-9_-]{21}$/,fa=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ha=/^([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)$/,ma=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ea="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ga(){return new RegExp(Ea,"u")}const _a=/^(?:(?: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])$/,ya=/^(([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}|:))$/,Sa=/^((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])$/,Ta=/^(([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])$/,Oa=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$o=/^[A-Za-z0-9_-]*$/,Ia=/^\+[1-9]\d{6,14}$/,Do="(?:(?:\\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])))",wa=new RegExp(`^${Do}$`);function Lo(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 va(e){return new RegExp(`^${Lo(e)}$`)}function Ca(e){const t=Lo({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(`^${Do}T(?:${o})$`)}const Ra=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},ba=/^-?\d+$/,ko=/^-?\d+(?:\.\d+)?$/,Aa=/^(?:true|false)$/i,Na=/^[^A-Z]*$/,$a=/^[^a-z]*$/,J=l("$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=l("$ZodCheckLessThan",(e,t)=>{J.init(e,t);const n=Po[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})}}),jo=l("$ZodCheckGreaterThan",(e,t)=>{J.init(e,t);const n=Po[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})}}),Da=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):zi(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})}}),La=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]=xi[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!fn(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=mn(r);o.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Pa=l("$ZodCheckMinLength",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!fn(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=mn(r);o.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),za=l("$ZodCheckLengthEquals",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!fn(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=mn(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})}}),Tt=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=()=>{})}),ja=l("$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})}}),Ua=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Na),Tt.init(e,t)}),Ma=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=$a),Tt.init(e,t)}),Fa=l("$ZodCheckIncludes",(e,t)=>{J.init(e,t);const n=je(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})}}),xa=l("$ZodCheckStartsWith",(e,t)=>{J.init(e,t);const n=new RegExp(`^${je(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})}}),Ga=l("$ZodCheckEndsWith",(e,t)=>{J.init(e,t);const n=new RegExp(`.*${je(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})}}),Za=l("$ZodCheckOverwrite",(e,t)=>{J.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Ba{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(`
|
|
1
|
+
import*as pt from"fs";import C,{existsSync as H,readFileSync as on,statSync as Xe,promises as rn,writeFileSync as sn,createReadStream as pi,mkdtempSync as fi,mkdirSync as hi,rmSync as co}from"fs";import*as ft from"path";import z,{resolve as S,dirname as uo,relative as lo,basename as mi,sep as an,parse as po,join as ee}from"path";import Ei from"cac";import{green as ce,yellow as gi,red as _i,gray as yi}from"kolorist";import Le from"prompts";import fo from"adm-zip";import{glob as I,globSync as ho}from"glob";import ue from"typescript";import{normalizePath as Si,build as ge,defineConfig as ht,createServer as Ti}from"vite";import{SectionTypeEnum as _e,BackgroundStyleEnum as cn,ButtonAppearanceEnum as Oi,ButtonSizeEnum as Ii,ButtonShapeEnum as wi,OverlayTypeEnum as mt,DesignEditorType as q,PluginTypeEnum as te,ConfigTypeEnum as N}from"@lightspeed/crane-api";import*as F from"process";import Et from"process";import{JSONPath as vi}from"jsonpath-plus";import{readFile as un,writeFile as Ci}from"fs/promises";import{pathToFileURL as mo,URL as Ri}from"url";import ln,{AxiosError as Eo}from"axios";import bi from"tinycolor2";import{builtinModules as go}from"module";import{viteExternalsPlugin as _o}from"vite-plugin-externals";import Ai from"vite-plugin-compression";import Ni from"@vitejs/plugin-vue";import $i from"vite-tsconfig-paths";import Di from"vite-plugin-checker";import{encode as Li}from"@jridgewell/sourcemap-codec";import{promisify as yo}from"node:util";import So from"node:zlib";import D from"node:fs";import V from"node:path";import j from"node:process";import ki from"micromatch";import{fileURLToPath as Pi}from"node:url";import{ConcurrencyManager as zi}from"axios-concurrency";import{inc as ji}from"semver";import Ui from"cli-progress";import{WebSocketServer as Fi,WebSocket as Mi}from"ws";import*as Gi from"os";import{spawnSync as xi}from"child_process";const Bi="3.4.2-rc.0",G={[_e.SECTION]:{source:"sections",dist:"dist/sections"},[_e.HEADER]:{source:"headers",dist:"dist/headers"},[_e.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 ke(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:ke(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:ke(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}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 y=d[m];y in a||(a[y]=u[y].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 Pe 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 ye(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,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}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 Zi(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 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(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 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 Hi(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 Vi=gt(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ze(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 ze(e)?{...e}:Array.isArray(e)?[...e]:e}const Wi=new Set(["string","number","symbol"]);function je(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 Yi(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Ki={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 Ji(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=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,s)}function Xi(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=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,s)}function Qi(e,t){if(!ze(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=Ie(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return be(this,"shape",s),s}});return we(e,r)}function qi(e,t){if(!ze(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 ea(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 ta(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=Ie(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 we(t,i)}function na(e,t,n){const o=Ie(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 we(t,o)}function Ue(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 _t(e){return typeof e=="string"?e:e?.message}function ve(e,t,n){const o={...e,path:e.path??[]};if(!e.message){const r=_t(e.inst?._zod.def?.error?.(e))??_t(t?.error?.(e))??_t(n.customError?.(e))??_t(n.localeError?.(e))??"Invalid input";o.message=r}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 qe(...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=l("$ZodError",Ro),Ao=l("$ZodError",Ro,{Parent:Error});function oa(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 ra(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 En=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 Pe;if(i.issues.length){const a=new(r?.Err??e)(i.issues.map(c=>ve(c,s,ye())));throw vo(a,r?.callee),a}return i.value},gn=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=>ve(c,s,ye())));throw vo(a,r?.callee),a}return i.value},yt=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 Pe;return s.issues.length?{success:!1,error:new(e??bo)(s.issues.map(i=>ve(i,r,ye())))}:{success:!0,data:s.value}},sa=yt(Ao),St=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=>ve(i,r,ye())))}:{success:!0,data:s.value}},ia=St(Ao),aa=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return En(e)(t,n,r)},ca=e=>(t,n,o)=>En(e)(t,n,o),ua=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return gn(e)(t,n,r)},la=e=>async(t,n,o)=>gn(e)(t,n,o),da=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return yt(e)(t,n,r)},pa=e=>(t,n,o)=>yt(e)(t,n,o),fa=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return St(e)(t,n,r)},ha=e=>async(t,n,o)=>St(e)(t,n,o),ma=/^[cC][^\s-]{8,}$/,Ea=/^[0-9a-z]+$/,ga=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,_a=/^[0-9a-vA-V]{20}$/,ya=/^[A-Za-z0-9]{27}$/,Sa=/^[a-zA-Z0-9_-]{21}$/,Ta=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Oa=/^([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)$/,Ia=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,wa="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function va(){return new RegExp(wa,"u")}const Ca=/^(?:(?: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])$/,Ra=/^(([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}|:))$/,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])\/([0-9]|[1-2][0-9]|3[0-2])$/,Aa=/^(([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])$/,Na=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$o=/^[A-Za-z0-9_-]*$/,$a=/^\+[1-9]\d{6,14}$/,Do="(?:(?:\\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])))",Da=new RegExp(`^${Do}$`);function Lo(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 La(e){return new RegExp(`^${Lo(e)}$`)}function ka(e){const t=Lo({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(`^${Do}T(?:${o})$`)}const Pa=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},za=/^-?\d+$/,ko=/^-?\d+(?:\.\d+)?$/,ja=/^(?:true|false)$/i,Ua=/^[^A-Z]*$/,Fa=/^[^a-z]*$/,J=l("$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=l("$ZodCheckLessThan",(e,t)=>{J.init(e,t);const n=Po[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})}}),jo=l("$ZodCheckGreaterThan",(e,t)=>{J.init(e,t);const n=Po[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})}}),Ma=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):Zi(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})}}),Ga=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]=Ki[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=za)}),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})}}),xa=l("$ZodCheckMaxLength",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!fn(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=mn(r);o.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ba=l("$ZodCheckMinLength",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!fn(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=mn(r);o.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Za=l("$ZodCheckLengthEquals",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!fn(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=mn(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})}}),Tt=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=()=>{})}),Ha=l("$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})}}),Va=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ua),Tt.init(e,t)}),Wa=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Fa),Tt.init(e,t)}),Ya=l("$ZodCheckIncludes",(e,t)=>{J.init(e,t);const n=je(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})}}),Ka=l("$ZodCheckStartsWith",(e,t)=>{J.init(e,t);const n=new RegExp(`^${je(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})}}),Ja=l("$ZodCheckEndsWith",(e,t)=>{J.init(e,t);const n=new RegExp(`.*${je(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})}}),Xa=l("$ZodCheckOverwrite",(e,t)=>{J.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Qa{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
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
|
|
3
|
+
`))}}const qa={major:4,minor:3,patch:6},L=l("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=qa;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=Ue(i),d;for(const m of a){if(m._zod.def.when){if(!m._zod.def.when(i))continue}else if(u)continue;const y=i.issues.length,T=m._zod.check(i);if(T instanceof Promise&&c?.async===!1)throw new Pe;if(d||T instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await T,i.issues.length!==y&&(u||(u=Ue(i,y)))});else{if(i.issues.length===y)continue;u||(u=Ue(i,y))}}return d?d.then(()=>i):i},s=(i,a,c)=>{if(Ue(i))return i.aborted=!0,i;const u=r(a,o,c);if(u instanceof Promise){if(c.async===!1)throw new Pe;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 Pe;return c.then(u=>r(u,o,a))}return r(c,o,a)}}b(e,"~standard",()=>({validate:r=>{try{const s=sa(e,r);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return ia(e,r).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),_n=l("$ZodString",(e,t)=>{L.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Pa(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)=>{Tt.init(e,t),_n.init(e,t)}),ec=l("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Oa),$.init(e,t)}),tc=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=No(o))}else t.pattern??(t.pattern=No());$.init(e,t)}),nc=l("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ia),$.init(e,t)}),oc=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})}}}),rc=l("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=va()),$.init(e,t)}),sc=l("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Sa),$.init(e,t)}),ic=l("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ma),$.init(e,t)}),ac=l("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ea),$.init(e,t)}),cc=l("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ga),$.init(e,t)}),uc=l("$ZodXID",(e,t)=>{t.pattern??(t.pattern=_a),$.init(e,t)}),lc=l("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ya),$.init(e,t)}),dc=l("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ka(t)),$.init(e,t)}),pc=l("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Da),$.init(e,t)}),fc=l("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=La(t)),$.init(e,t)}),hc=l("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ta),$.init(e,t)}),mc=l("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ca),$.init(e,t),e._zod.bag.format="ipv4"}),Ec=l("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ra),$.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})}}}),gc=l("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ba),$.init(e,t)}),_c=l("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Aa),$.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 Uo(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const yc=l("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Na),$.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 Sc(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 Tc=l("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=$o),$.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Sc(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Oc=l("$ZodE164",(e,t)=>{t.pattern??(t.pattern=$a),$.init(e,t)});function Ic(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 wc=l("$ZodJWT",(e,t)=>{$.init(e,t),e._zod.check=n=>{Ic(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Fo=l("$ZodNumber",(e,t)=>{L.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 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}}),vc=l("$ZodNumberFormat",(e,t)=>{Ga.init(e,t),Fo.init(e,t)}),Cc=l("$ZodBoolean",(e,t)=>{L.init(e,t),e._zod.pattern=ja,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}}),Rc=l("$ZodUnknown",(e,t)=>{L.init(e,t),e._zod.parse=n=>n}),bc=l("$ZodNever",(e,t)=>{L.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(...Fe(n,e.issues)),t.value[n]=e.value}const Ac=l("$ZodArray",(e,t)=>{L.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=>Mo(u,n,i))):Mo(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function Ot(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 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=Yi(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function xo(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 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:s}),e.length?Promise.all(e).then(()=>n):n}const Nc=l("$ZodObject",(e,t)=>{if(L.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 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 y of i.keys){const T=m[y],Z=T._zod.optout==="optional",B=T._zod.run({value:u[y],issues:[]},c);B instanceof Promise?d.push(B.then(dt=>Ot(dt,a,y,u,Z))):Ot(B,a,y,u,Z)}return s?xo(d,u,a,c,o.value,e):d.length?Promise.all(d).then(()=>a):a}}),$c=l("$ZodObjectJIT",(e,t)=>{Nc.init(e,t);const n=e._zod.parse,o=gt(()=>Go(t)),r=y=>{const T=new Qa(["shape","payload","ctx"]),Z=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 dt=Object.create(null);let ui=0;for(const fe of Z.keys)dt[fe]=`key_${ui++}`;T.write("const newResult = {};");for(const fe of Z.keys){const K=dt[fe],ae=wo(fe),di=y[fe]?._zod?.optout==="optional";T.write(`const ${K} = ${B(fe)};`),di?T.write(`
|
|
4
4
|
if (${K}.issues.length) {
|
|
5
|
-
if (${
|
|
5
|
+
if (${ae} in input) {
|
|
6
6
|
payload.issues = payload.issues.concat(${K}.issues.map(iss => ({
|
|
7
7
|
...iss,
|
|
8
|
-
path: iss.path ? [${
|
|
8
|
+
path: iss.path ? [${ae}, ...iss.path] : [${ae}]
|
|
9
9
|
})));
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
if (${K}.value === undefined) {
|
|
14
|
-
if (${
|
|
15
|
-
newResult[${
|
|
14
|
+
if (${ae} in input) {
|
|
15
|
+
newResult[${ae}] = undefined;
|
|
16
16
|
}
|
|
17
17
|
} else {
|
|
18
|
-
newResult[${
|
|
18
|
+
newResult[${ae}] = ${K}.value;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
`):T.write(`
|
|
22
22
|
if (${K}.issues.length) {
|
|
23
23
|
payload.issues = payload.issues.concat(${K}.issues.map(iss => ({
|
|
24
24
|
...iss,
|
|
25
|
-
path: iss.path ? [${
|
|
25
|
+
path: iss.path ? [${ae}, ...iss.path] : [${ae}]
|
|
26
26
|
})));
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
if (${K}.value === undefined) {
|
|
30
|
-
if (${
|
|
31
|
-
newResult[${
|
|
30
|
+
if (${ae} in input) {
|
|
31
|
+
newResult[${ae}] = undefined;
|
|
32
32
|
}
|
|
33
33
|
} else {
|
|
34
|
-
newResult[${
|
|
34
|
+
newResult[${ae}] = ${K}.value;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
`)}T.write("payload.value = newResult;"),T.write("return payload;");const ni=T.compile();return(fe,K)=>ni(y,fe,K)};let s;const i=Qe,a=!dn.jitless,u=a&&Ui.value,d=t.catchall;let m;e._zod.parse=(y,T)=>{m??(m=o.value);const B=y.value;return i(B)?a&&u&&T?.async===!1&&T.jitless!==!0?(s||(s=r(t.shape)),y=s(y,T),d?Go([],B,y,T,m,e):y):n(y,T):(y.issues.push({expected:"object",code:"invalid_type",input:B,inst:e}),y)}});function Zo(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=>!Ue(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=>we(i,o,_e())))}),t)}const Bo=l("$ZodUnion",(e,t)=>{L.init(e,t),R(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),R(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),R(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),R(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=>hn(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=>Zo(c,r,e,s)):Zo(a,r,e,s)}}),wc=l("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Bo.init(e,t);const n=e._zod.parse;R(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=gt(()=>{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)}}),vc=l("$ZodIntersection",(e,t)=>{L.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])=>Ho(n,c,u)):Ho(n,s,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(ze(e)&&ze(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=yn(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=yn(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 Ho(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}),Ue(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 Cc=l("$ZodRecord",(e,t)=>{L.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!ze(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(...Me(u,m.issues)),n.value[u]=m.value})):(d.issues.length&&n.issues.push(...Me(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"&&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]=r[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(m=>we(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(...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 s.length?Promise.all(s).then(()=>n):n}}),Rc=l("$ZodEnum",(e,t)=>{L.init(e,t);const n=Oo(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(r=>Mi.has(typeof r)).map(r=>typeof r=="string"?je(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(L.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"?je(o):o?je(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}}),Ac=l("$ZodTransform",(e,t)=>{L.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new To(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 Pe;return n.value=r,n}});function Vo(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Wo=l("$ZodOptional",(e,t)=>{L.init(e,t),e._zod.optin="optional",e._zod.optout="optional",R(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),R(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 r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>Vo(s,n.value)):Vo(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),Nc=l("$ZodExactOptional",(e,t)=>{Wo.init(e,t),R(e._zod,"values",()=>t.innerType._zod.values),R(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,o)=>t.innerType._zod.run(n,o)}),$c=l("$ZodNullable",(e,t)=>{L.init(e,t),R(e._zod,"optin",()=>t.innerType._zod.optin),R(e._zod,"optout",()=>t.innerType._zod.optout),R(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${hn(n.source)}|null)$`):void 0}),R(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)}),Dc=l("$ZodDefault",(e,t)=>{L.init(e,t),e._zod.optin="optional",R(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=>Yo(s,t)):Yo(r,t)}});function Yo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Lc=l("$ZodPrefault",(e,t)=>{L.init(e,t),e._zod.optin="optional",R(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)=>{L.init(e,t),R(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=>Ko(s,e)):Ko(r,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 Pc=l("$ZodCatch",(e,t)=>{L.init(e,t),R(e._zod,"optin",()=>t.innerType._zod.optin),R(e._zod,"optout",()=>t.innerType._zod.optout),R(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=>we(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=>we(s,o,_e()))},input:n.value}),n.issues=[]),n)}}),zc=l("$ZodPipe",(e,t)=>{L.init(e,t),R(e._zod,"values",()=>t.in._zod.values),R(e._zod,"optin",()=>t.in._zod.optin),R(e._zod,"optout",()=>t.out._zod.optout),R(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=>It(i,t.in,o)):It(s,t.in,o)}const r=t.in._zod.run(n,o);return r instanceof Promise?r.then(s=>It(s,t.out,o)):It(r,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 jc=l("$ZodReadonly",(e,t)=>{L.init(e,t),R(e._zod,"propValues",()=>t.innerType._zod.propValues),R(e._zod,"values",()=>t.innerType._zod.values),R(e._zod,"optin",()=>t.innerType?._zod?.optin),R(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(Jo):Jo(r)}});function Jo(e){return e.value=Object.freeze(e.value),e}const Uc=l("$ZodCustom",(e,t)=>{J.init(e,t),L.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=>Xo(s,n,o,e));Xo(r,n,o,e)}});function Xo(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(qe(r))}}var Qo;class Mc{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 Fc(){return new Mc}(Qo=globalThis).__zod_globalRegistry??(Qo.__zod_globalRegistry=Fc());const et=globalThis.__zod_globalRegistry;function xc(e,t){return new e({type:"string",...g(t)})}function Gc(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 Zc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function Bc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function Hc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function Vc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function er(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function Wc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function Yc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function Kc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function Jc(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function Xc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function Qc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function qc(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function eu(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function tu(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function nu(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function ou(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function ru(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function su(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function iu(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function au(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function cu(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function uu(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function lu(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function du(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function pu(e,t){return new e({type:"number",checks:[],...g(t)})}function fu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...g(t)})}function hu(e,t){return new e({type:"boolean",...g(t)})}function mu(e){return new e({type:"unknown"})}function Eu(e,t){return new e({type:"never",...g(t)})}function tr(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 nr(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 or(e,t){return new Da({check:"multiple_of",...g(t),value:e})}function rr(e,t){return new ka({check:"max_length",...g(t),maximum:e})}function wt(e,t){return new Pa({check:"min_length",...g(t),minimum:e})}function sr(e,t){return new za({check:"length_equals",...g(t),length:e})}function gu(e,t){return new ja({check:"string_format",format:"regex",...g(t),pattern:e})}function _u(e){return new Ua({check:"string_format",format:"lowercase",...g(e)})}function yu(e){return new Ma({check:"string_format",format:"uppercase",...g(e)})}function Su(e,t){return new Fa({check:"string_format",format:"includes",...g(t),includes:e})}function Tu(e,t){return new xa({check:"string_format",format:"starts_with",...g(t),prefix:e})}function Ou(e,t){return new Ga({check:"string_format",format:"ends_with",...g(t),suffix:e})}function Fe(e){return new Za({check:"overwrite",tx:e})}function Iu(e){return Fe(t=>t.normalize(e))}function wu(){return Fe(e=>e.trim())}function vu(){return Fe(e=>e.toLowerCase())}function Cu(){return Fe(e=>e.toUpperCase())}function Ru(){return Fe(e=>ji(e))}function bu(e,t,n){return new e({type:"array",element:t,...g(n)})}function Au(e,t,n){return new e({type:"custom",check:"custom",fn:t,...g(n)})}function Nu(e){const t=$u(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(qe(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(qe(r))}},e(n.value,n)));return t}function $u(e,t){const n=new J({check:"custom",...g(t)});return n._zod.check=e,n}function ir(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??et,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 y=i.schema,T=t.processors[r.type];if(!T)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);T(e,t,y,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"&&W(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 ar(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,y=e.external.uri??(B=>B);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 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>
|
|
37
|
+
`)}T.write("payload.value = newResult;"),T.write("return payload;");const li=T.compile();return(fe,K)=>li(y,fe,K)};let s;const i=Qe,a=!dn.jitless,u=a&&Vi.value,d=t.catchall;let m;e._zod.parse=(y,T)=>{m??(m=o.value);const Z=y.value;return i(Z)?a&&u&&T?.async===!1&&T.jitless!==!0?(s||(s=r(t.shape)),y=s(y,T),d?xo([],Z,y,T,m,e):y):n(y,T):(y.issues.push({expected:"object",code:"invalid_type",input:Z,inst:e}),y)}});function Bo(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=>!Ue(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=>ve(i,o,ye())))}),t)}const Zo=l("$ZodUnion",(e,t)=>{L.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=>hn(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=>Bo(c,r,e,s)):Bo(a,r,e,s)}}),Dc=l("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Zo.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=gt(()=>{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)}}),Lc=l("$ZodIntersection",(e,t)=>{L.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])=>Ho(n,c,u)):Ho(n,s,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(ze(e)&&ze(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=yn(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=yn(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 Ho(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}),Ue(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 kc=l("$ZodRecord",(e,t)=>{L.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!ze(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"&&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]=r[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(m=>ve(m,o,ye())),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}}),Pc=l("$ZodEnum",(e,t)=>{L.init(e,t);const n=Oo(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(r=>Wi.has(typeof r)).map(r=>typeof r=="string"?je(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}}),zc=l("$ZodLiteral",(e,t)=>{if(L.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"?je(o):o?je(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}}),jc=l("$ZodTransform",(e,t)=>{L.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new To(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 Pe;return n.value=r,n}});function Vo(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Wo=l("$ZodOptional",(e,t)=>{L.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 r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>Vo(s,n.value)):Vo(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),Uc=l("$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)}),Fc=l("$ZodNullable",(e,t)=>{L.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)}),Mc=l("$ZodDefault",(e,t)=>{L.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=>Yo(s,t)):Yo(r,t)}});function Yo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Gc=l("$ZodPrefault",(e,t)=>{L.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))}),xc=l("$ZodNonOptional",(e,t)=>{L.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=>Ko(s,e)):Ko(r,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 Bc=l("$ZodCatch",(e,t)=>{L.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=>ve(i,o,ye()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(s=>ve(s,o,ye()))},input:n.value}),n.issues=[]),n)}}),Zc=l("$ZodPipe",(e,t)=>{L.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=>It(i,t.in,o)):It(s,t.in,o)}const r=t.in._zod.run(n,o);return r instanceof Promise?r.then(s=>It(s,t.out,o)):It(r,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 Hc=l("$ZodReadonly",(e,t)=>{L.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(Jo):Jo(r)}});function Jo(e){return e.value=Object.freeze(e.value),e}const Vc=l("$ZodCustom",(e,t)=>{J.init(e,t),L.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=>Xo(s,n,o,e));Xo(r,n,o,e)}});function Xo(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(qe(r))}}var Qo;class Wc{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 Yc(){return new Wc}(Qo=globalThis).__zod_globalRegistry??(Qo.__zod_globalRegistry=Yc());const et=globalThis.__zod_globalRegistry;function Kc(e,t){return new e({type:"string",...g(t)})}function Jc(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 Xc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function Qc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function qc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function eu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function er(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function tu(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function nu(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function ou(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function ru(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function su(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function iu(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function au(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function cu(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function uu(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function lu(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function du(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function pu(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function fu(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function hu(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function mu(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function Eu(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function gu(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function _u(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function yu(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function Su(e,t){return new e({type:"number",checks:[],...g(t)})}function Tu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...g(t)})}function Ou(e,t){return new e({type:"boolean",...g(t)})}function Iu(e){return new e({type:"unknown"})}function wu(e,t){return new e({type:"never",...g(t)})}function tr(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 nr(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 or(e,t){return new Ma({check:"multiple_of",...g(t),value:e})}function rr(e,t){return new xa({check:"max_length",...g(t),maximum:e})}function wt(e,t){return new Ba({check:"min_length",...g(t),minimum:e})}function sr(e,t){return new Za({check:"length_equals",...g(t),length:e})}function vu(e,t){return new Ha({check:"string_format",format:"regex",...g(t),pattern:e})}function Cu(e){return new Va({check:"string_format",format:"lowercase",...g(e)})}function Ru(e){return new Wa({check:"string_format",format:"uppercase",...g(e)})}function bu(e,t){return new Ya({check:"string_format",format:"includes",...g(t),includes:e})}function Au(e,t){return new Ka({check:"string_format",format:"starts_with",...g(t),prefix:e})}function Nu(e,t){return new Ja({check:"string_format",format:"ends_with",...g(t),suffix:e})}function Me(e){return new Xa({check:"overwrite",tx:e})}function $u(e){return Me(t=>t.normalize(e))}function Du(){return Me(e=>e.trim())}function Lu(){return Me(e=>e.toLowerCase())}function ku(){return Me(e=>e.toUpperCase())}function Pu(){return Me(e=>Hi(e))}function zu(e,t,n){return new e({type:"array",element:t,...g(n)})}function ju(e,t,n){const o=g(n);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Uu(e,t,n){return new e({type:"custom",check:"custom",fn:t,...g(n)})}function Fu(e){const t=Mu(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(qe(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(qe(r))}},e(n.value,n)));return t}function Mu(e,t){const n=new J({check:"custom",...g(t)});return n._zod.check=e,n}function ir(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??et,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 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 y=i.schema,T=t.processors[r.type];if(!T)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.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"&&W(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 ar(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,y=e.external.uri??(Z=>Z);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 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]){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 cr(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 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,u),i._zod.parent===d)for(const Z in c)Z==="$ref"||Z==="allOf"||Z in u||delete c[Z];if(T.$ref&&y.def)for(const Z in c)Z==="$ref"||Z==="allOf"||Z in y.def&&JSON.stringify(c[Z])===JSON.stringify(y.def[Z])&&delete c[Z]}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 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: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 W(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 W(o.element,n);if(o.type==="set")return W(o.valueType,n);if(o.type==="lazy")return W(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 W(o.innerType,n);if(o.type==="intersection")return W(o.left,n)||W(o.right,n);if(o.type==="record"||o.type==="map")return W(o.keyType,n)||W(o.valueType,n);if(o.type==="pipe")return W(o.in,n)||W(o.out,n);if(o.type==="object"){for(const r in o.shape)if(W(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(const r of o.options)if(W(r,n))return!0;return!1}if(o.type==="tuple"){for(const r of o.items)if(W(r,n))return!0;return!!(o.rest&&W(o.rest,n))}return!1}const Du=(e,t={})=>n=>{const o=ir({...n,processors:t});return F(e,o),ar(o,e),cr(o,e)},vt=(e,t,n={})=>o=>{const{libraryOptions:r,target:s}=o??{},i=ir({...r??{},target:s,io:t,processors:n});return F(e,i),ar(i,e),cr(i,e)},Lu={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ku=(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=Lu[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}))])}},Pu=(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)},zu=(e,t,n,o)=>{n.type="boolean"},ju=(e,t,n,o)=>{n.not={}},Uu=(e,t,n,o)=>{},Mu=(e,t,n,o)=>{const r=e._zod.def,s=Oo(r.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},Fu=(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},xu=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Gu=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Zu=(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"]})},Bu=(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)},Hu=(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},Vu=(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},Wu=(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)}},Yu=(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"}]},Ku=(e,t,n,o)=>{const r=e._zod.def;F(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},Ju=(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))},Xu=(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)))},Qu=(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},qu=(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},ur=(e,t,n,o)=>{const r=e._zod.def;F(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},tl=l("ZodISODateTime",(e,t)=>{oc.init(e,t),P.init(e,t)});function nl(e){return cu(tl,e)}const ol=l("ZodISODate",(e,t)=>{rc.init(e,t),P.init(e,t)});function rl(e){return uu(ol,e)}const sl=l("ZodISOTime",(e,t)=>{sc.init(e,t),P.init(e,t)});function il(e){return lu(sl,e)}const al=l("ZodISODuration",(e,t)=>{ic.init(e,t),P.init(e,t)});function cl(e){return du(al,e)}const ul=(e,t)=>{bo.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Ji(e,n)},flatten:{value:n=>Ki(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}}})},ne=l("ZodError",ul,{Parent:Error}),ll=En(ne),dl=gn(ne),pl=yt(ne),fl=St(ne),hl=qi(ne),ml=ea(ne),El=ta(ne),gl=na(ne),_l=oa(ne),yl=ra(ne),Sl=sa(ne),Tl=ia(ne),k=l("ZodType",(e,t)=>(L.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:vt(e,"input"),output:vt(e,"output")}}),e.toJSONSchema=Du(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Oe(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)=>Ie(e,n,o),e.brand=()=>e,e.register=((n,o)=>(n.add(e,o),e)),e.parse=(n,o)=>ll(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>pl(e,n,o),e.parseAsync=async(n,o)=>dl(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>fl(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>hl(e,n,o),e.decode=(n,o)=>ml(e,n,o),e.encodeAsync=async(n,o)=>El(e,n,o),e.decodeAsync=async(n,o)=>gl(e,n,o),e.safeEncode=(n,o)=>_l(e,n,o),e.safeDecode=(n,o)=>yl(e,n,o),e.safeEncodeAsync=async(n,o)=>Sl(e,n,o),e.safeDecodeAsync=async(n,o)=>Tl(e,n,o),e.refine=(n,o)=>e.check(fd(n,o)),e.superRefine=n=>e.check(hd(n)),e.overwrite=n=>e.check(Fe(n)),e.optional=()=>_r(e),e.exactOptional=()=>ed(e),e.nullable=()=>yr(e),e.nullish=()=>_r(yr(e)),e.nonoptional=n=>id(e,n),e.array=()=>A(e),e.or=n=>xe([e,n]),e.and=n=>Yl(e,n),e.transform=n=>Tr(e,Ql(n)),e.default=n=>od(e,n),e.prefault=n=>sd(e,n),e.catch=n=>cd(e,n),e.pipe=n=>Tr(e,n),e.readonly=()=>dd(e),e.describe=n=>{const o=e.clone();return et.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){return et.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return et.get(e);const o=e.clone();return et.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),lr=l("_ZodString",(e,t)=>{_n.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,r,s)=>ku(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(gu(...o)),e.includes=(...o)=>e.check(Su(...o)),e.startsWith=(...o)=>e.check(Tu(...o)),e.endsWith=(...o)=>e.check(Ou(...o)),e.min=(...o)=>e.check(wt(...o)),e.max=(...o)=>e.check(rr(...o)),e.length=(...o)=>e.check(sr(...o)),e.nonempty=(...o)=>e.check(wt(1,...o)),e.lowercase=o=>e.check(_u(o)),e.uppercase=o=>e.check(yu(o)),e.trim=()=>e.check(wu()),e.normalize=(...o)=>e.check(Iu(...o)),e.toLowerCase=()=>e.check(vu()),e.toUpperCase=()=>e.check(Cu()),e.slugify=()=>e.check(Ru())}),Ol=l("ZodString",(e,t)=>{_n.init(e,t),lr.init(e,t),e.email=n=>e.check(Gc(Il,n)),e.url=n=>e.check(er(pr,n)),e.jwt=n=>e.check(au(Ul,n)),e.emoji=n=>e.check(Wc(wl,n)),e.guid=n=>e.check(qo(dr,n)),e.uuid=n=>e.check(Zc(Ct,n)),e.uuidv4=n=>e.check(Bc(Ct,n)),e.uuidv6=n=>e.check(Hc(Ct,n)),e.uuidv7=n=>e.check(Vc(Ct,n)),e.nanoid=n=>e.check(Yc(vl,n)),e.guid=n=>e.check(qo(dr,n)),e.cuid=n=>e.check(Kc(Cl,n)),e.cuid2=n=>e.check(Jc(Rl,n)),e.ulid=n=>e.check(Xc(bl,n)),e.base64=n=>e.check(ru(Pl,n)),e.base64url=n=>e.check(su(zl,n)),e.xid=n=>e.check(Qc(Al,n)),e.ksuid=n=>e.check(qc(Nl,n)),e.ipv4=n=>e.check(eu($l,n)),e.ipv6=n=>e.check(tu(Dl,n)),e.cidrv4=n=>e.check(nu(Ll,n)),e.cidrv6=n=>e.check(ou(kl,n)),e.e164=n=>e.check(iu(jl,n)),e.datetime=n=>e.check(nl(n)),e.date=n=>e.check(rl(n)),e.time=n=>e.check(il(n)),e.duration=n=>e.check(cl(n))});function h(e){return xc(Ol,e)}const P=l("ZodStringFormat",(e,t)=>{$.init(e,t),lr.init(e,t)}),Il=l("ZodEmail",(e,t)=>{Ya.init(e,t),P.init(e,t)}),dr=l("ZodGUID",(e,t)=>{Va.init(e,t),P.init(e,t)}),Ct=l("ZodUUID",(e,t)=>{Wa.init(e,t),P.init(e,t)}),pr=l("ZodURL",(e,t)=>{Ka.init(e,t),P.init(e,t)});function fr(e){return er(pr,e)}const wl=l("ZodEmoji",(e,t)=>{Ja.init(e,t),P.init(e,t)}),vl=l("ZodNanoID",(e,t)=>{Xa.init(e,t),P.init(e,t)}),Cl=l("ZodCUID",(e,t)=>{Qa.init(e,t),P.init(e,t)}),Rl=l("ZodCUID2",(e,t)=>{qa.init(e,t),P.init(e,t)}),bl=l("ZodULID",(e,t)=>{ec.init(e,t),P.init(e,t)}),Al=l("ZodXID",(e,t)=>{tc.init(e,t),P.init(e,t)}),Nl=l("ZodKSUID",(e,t)=>{nc.init(e,t),P.init(e,t)}),$l=l("ZodIPv4",(e,t)=>{ac.init(e,t),P.init(e,t)}),Dl=l("ZodIPv6",(e,t)=>{cc.init(e,t),P.init(e,t)}),Ll=l("ZodCIDRv4",(e,t)=>{uc.init(e,t),P.init(e,t)}),kl=l("ZodCIDRv6",(e,t)=>{lc.init(e,t),P.init(e,t)}),Pl=l("ZodBase64",(e,t)=>{dc.init(e,t),P.init(e,t)}),zl=l("ZodBase64URL",(e,t)=>{fc.init(e,t),P.init(e,t)}),jl=l("ZodE164",(e,t)=>{hc.init(e,t),P.init(e,t)}),Ul=l("ZodJWT",(e,t)=>{Ec.init(e,t),P.init(e,t)}),hr=l("ZodNumber",(e,t)=>{Mo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Pu(e,o,r),e.gt=(o,r)=>e.check(nr(o,r)),e.gte=(o,r)=>e.check(Tn(o,r)),e.min=(o,r)=>e.check(Tn(o,r)),e.lt=(o,r)=>e.check(tr(o,r)),e.lte=(o,r)=>e.check(Sn(o,r)),e.max=(o,r)=>e.check(Sn(o,r)),e.int=o=>e.check(oe(o)),e.safe=o=>e.check(oe(o)),e.positive=o=>e.check(nr(0,o)),e.nonnegative=o=>e.check(Tn(0,o)),e.negative=o=>e.check(tr(0,o)),e.nonpositive=o=>e.check(Sn(0,o)),e.multipleOf=(o,r)=>e.check(or(o,r)),e.step=(o,r)=>e.check(or(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 Rt(e){return pu(hr,e)}const Ml=l("ZodNumberFormat",(e,t)=>{gc.init(e,t),hr.init(e,t)});function oe(e){return fu(Ml,e)}const Fl=l("ZodBoolean",(e,t)=>{_c.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>zu(e,n,o)});function v(e){return hu(Fl,e)}const xl=l("ZodUnknown",(e,t)=>{yc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Uu()});function mr(){return mu(xl)}const Gl=l("ZodNever",(e,t)=>{Sc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ju(e,n,o)});function Zl(e){return Eu(Gl,e)}const Bl=l("ZodArray",(e,t)=>{Tc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Zu(e,n,o,r),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(rr(n,o)),e.length=(n,o)=>e.check(sr(n,o)),e.unwrap=()=>e.element});function A(e,t){return bu(Bl,e,t)}const Hl=l("ZodObject",(e,t)=>{Ic.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Bu(e,n,o,r),R(e,"shape",()=>t.shape),e.keyof=()=>z(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:mr()}),e.loose=()=>e.clone({...e._zod.def,catchall:mr()}),e.strict=()=>e.clone({...e._zod.def,catchall:Zl()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Bi(e,n),e.safeExtend=n=>Hi(e,n),e.merge=n=>Vi(e,n),e.pick=n=>Gi(e,n),e.omit=n=>Zi(e,n),e.partial=(...n)=>Wi(gr,e,n[0]),e.required=(...n)=>Yi(Sr,e,n[0])});function p(e,t){const n={type:"object",shape:e??{},...g(t)};return new Hl(n)}const Er=l("ZodUnion",(e,t)=>{Bo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Hu(e,n,o,r),e.options=t.options});function xe(e,t){return new Er({type:"union",options:e,...g(t)})}const Vl=l("ZodDiscriminatedUnion",(e,t)=>{Er.init(e,t),wc.init(e,t)});function re(e,t,n){return new Vl({type:"union",options:t,discriminator:e,...g(n)})}const Wl=l("ZodIntersection",(e,t)=>{vc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Vu(e,n,o,r)});function Yl(e,t){return new Wl({type:"intersection",left:e,right:t})}const Kl=l("ZodRecord",(e,t)=>{Cc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Wu(e,n,o,r),e.keyType=t.keyType,e.valueType=t.valueType});function Y(e,t,n){return new Kl({type:"record",keyType:e,valueType:t,...g(n)})}const On=l("ZodEnum",(e,t)=>{Rc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Mu(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 On({...t,checks:[],...g(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 On({...t,checks:[],...g(r),entries:s})}});function z(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 Jl=l("ZodLiteral",(e,t)=>{bc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Fu(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 Jl({type:"literal",values:Array.isArray(e)?e:[e],...g(t)})}const Xl=l("ZodTransform",(e,t)=>{Ac.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Gu(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new To(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(qe(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(qe(i))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(s=>(n.value=s,n)):(n.value=r,n)}});function Ql(e){return new Xl({type:"transform",transform:e})}const gr=l("ZodOptional",(e,t)=>{Wo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ur(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function _r(e){return new gr({type:"optional",innerType:e})}const ql=l("ZodExactOptional",(e,t)=>{Nc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ur(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function ed(e){return new ql({type:"optional",innerType:e})}const td=l("ZodNullable",(e,t)=>{$c.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Yu(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function yr(e){return new td({type:"nullable",innerType:e})}const nd=l("ZodDefault",(e,t)=>{Dc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ju(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function od(e,t){return new nd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Co(t)}})}const rd=l("ZodPrefault",(e,t)=>{Lc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Xu(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function sd(e,t){return new rd({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Co(t)}})}const Sr=l("ZodNonOptional",(e,t)=>{kc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ku(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function id(e,t){return new Sr({type:"nonoptional",innerType:e,...g(t)})}const ad=l("ZodCatch",(e,t)=>{Pc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Qu(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function cd(e,t){return new ad({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const ud=l("ZodPipe",(e,t)=>{zc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>qu(e,n,o,r),e.in=t.in,e.out=t.out});function Tr(e,t){return new ud({type:"pipe",in:e,out:t})}const ld=l("ZodReadonly",(e,t)=>{jc.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 dd(e){return new ld({type:"readonly",innerType:e})}const pd=l("ZodCustom",(e,t)=>{Uc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>xu(e,n)});function fd(e,t={}){return Au(pd,e,t)}function hd(e){return Nu(e)}const md={url:"must be a valid URL",email:"must be a valid email address"},Ed=e=>{const t=e?.at(-1);return typeof t=="string"?`'${t}'`:"Field"},gd=e=>e===null?"null":typeof e,_d=e=>{switch(e.code){case"invalid_type":{const{input:t}=e;return t===void 0?{message:`${Ed(e.path)} is required`}:{message:`Expected ${String(e.expected)}, received ${gd(t)}`}}case"invalid_format":{const t=md[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}},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"};z(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"};z(Object.values(w));const Ge={SECTION:"SECTION",HEADER:"HEADER",FOOTER:"FOOTER"},yd=z(Object.values(Ge)),tt={CONTENT:"Content",DESIGN:"Design"};z(Object.values(tt));const Sd={TEXT:"TEXT",IMAGE:"IMAGE"},Td=z(Object.values(Sd)),ve={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"},Od=z(Object.values(ve)),bt={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"},Id=z(Object.values(bt)),wd={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"},vd=z(Object.values(wd)),Cd={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"},Rd=z(Object.values(Cd)),bd={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"},Ad=z(Object.values(bd)),In={COLOR:"COLOR",GRADIENT:"GRADIENT"},Nd=z(Object.values(In));z(["none","all","small"]);const be={PRODUCT:"PRODUCT",CATALOG:"CATALOG",CATEGORY:"CATEGORY",HOME:"HOME",CUSTOM:"CUSTOM"},Or={HOME:"home",CATALOG:"catalog",CATEGORY:"category",PRODUCT:"product"},$d=z(Object.values(be));z(Object.values(Or));const Dd={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"},Ld=z(Object.values(Dd)),kd={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"},Pd=z(Object.values(kd)),zd={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"},jd={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"},Ud=z(Object.values(jd)),Ae={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_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"},Md=/^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,Fd=/^[a-z]{2}(_([a-z]{2}|[A-Z]{2}|[0-9]{3}))?$/,Ce=(e,t)=>{const n=Ae.INTEGER_RANGE(e.toString(),t.toString());return oe().min(e,{message:n}).max(t,{message:n})},wn=p({path:h(),size:Rt().nonnegative()}).strict(),Ir=p({size:Rt().nonnegative()}).strict(),_=h().regex(/^\$.+/,{message:"must start with '$' followed by at least one character"}),xd=p({r:Ce(0,255),g:Ce(0,255),b:Ce(0,255),a:Ce(0,1)}).strict(),vn=h().regex(Md,{message:Ae.VALID_HEX_COLOR()}),q=xe([vn,z(["global.color.title","global.color.body","global.color.button","global.color.link","global.color.background"])]),wr=z(["global.textSize.title","global.textSize.subtitle","global.textSize.body"]),nt=z(["catalog","category","product"]),At=h().refine(e=>e.startsWith("#")||fr().safeParse(e).success,{message:"must be a valid URL or a hash fragment starting with #"}),ot=p({url:h(),width:oe().min(0,{message:Ae.NON_NEGATIVE_INTEGER()}).optional(),height:oe().min(0,{message:Ae.NON_NEGATIVE_INTEGER()}).optional()}).strict(),Gd=p({homogeneity:v().optional(),color:xd.optional()}).strict(),Zd=p({ORIGINAL:ot.optional(),WEBP_LOW_RES:ot.optional(),WEBP_HI_2X_RES:ot.optional(),MOBILE_WEBP_LOW_RES:ot.optional(),MOBILE_WEBP_HI_RES:ot.optional()}).strict().refine(e=>Object.keys(e).length>=1,{message:"set must have at least one property"}),Nt=p({set:Zd,borderInfo:Gd.optional()}).strict(),Cn=p({type:E(O.IMAGE),imageData:Nt}).strict(),vr=p({type:E(O.IMAGE),label:_,static:v().optional(),defaults:Cn.optional()}).strict(),Bd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Rn(e){return e===be.PRODUCT||e===be.CATALOG||e===be.CATEGORY}function Cr(e,t,n){if(!e)return;const o=gi({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 Rr(e,t,n){e===ve.HYPER_LINK&&!t&&n.at("link").addIssue("BUTTON_LINK_REQUIRED")}function br(e,t,n){(e===ve.GO_TO_CATEGORY||e===ve.GO_TO_CATEGORY_LINK)&&!t&&n.at("categoryId").addIssue("BUTTON_CATEGORY_ID_REQUIRED")}function Ar(e,t,n){e===ve.MAIL_LINK&&!t&&n.at("email").addIssue("BUTTON_EMAIL_REQUIRED")}function Nr(e,t,n){e===ve.TEL_LINK&&!t&&n.at("phone").addIssue("BUTTON_PHONE_REQUIRED")}function $r(e,t,n,o){if(e===ve.SCROLL_TO_TILE&&!(t??n)){const r=t?"tileId":"tileIdForScroll";o.at(r).addIssue("BUTTON_TILE_ID_REQUIRED",r)}}function Hd(e,t,n){e===ve.GO_TO_PAGE&&!t&&n.at("pageIdForNavigate").addIssue("BUTTON_PAGE_ID_REQUIRED")}const Vd="custom";function G(e,t=[]){const n=r=>Array.isArray(r)?r:[r],o=n(t);return{raw:e,addIssue(r,...s){e.addIssue({code:Vd,message:Ae[r](...s),path:o,params:{errorMessageKey:r}})},at(r){const s=o.concat(n(r));return G(e,s)}}}const bn=p({type:E(O.BUTTON),title:_,buttonType:Od,link:h().optional(),linkTarget:h().optional(),email:h().regex(Bd,{message:Ae.VALID_EMAIL()}).optional(),phone:h().optional(),tileId:h().optional(),categoryId:Rt().optional()}).strict().superRefine((e,t)=>{const n=G(t);Rr(e.buttonType,e.link,n),br(e.buttonType,e.categoryId,n),Ar(e.buttonType,e.email,n),Nr(e.buttonType,e.phone,n),$r(e.buttonType,e.tileId,void 0,n)}),Dr=p({type:E(O.BUTTON),label:_,defaults:bn.optional()}).strict(),An=p({type:E(O.CATEGORY_SELECTOR)}).strict(),Lr=p({type:E(O.CATEGORY_SELECTOR),label:_,maxCategories:Ce(1,32),defaults:An.optional()}).strict(),Nn=p({type:E(O.DIVIDER)}).strict(),kr=p({type:E(O.DIVIDER),label:_,defaults:Nn.optional()}).strict(),Wd=p({label:_,link:At}).strict(),Yd=p({title:_.optional(),link:At.optional()}).strict(),$n=p({type:E(O.INFO),text:_.optional(),button:Yd.optional()}).strict(),Pr=p({type:E(O.INFO),label:_,description:_,button:Wd.optional(),defaults:$n.optional()}).strict(),Dn=p({type:E(O.INPUTBOX),text:_}).strict(),zr=p({type:E(O.INPUTBOX),label:_,placeholder:_,defaults:Dn.optional()}).strict(),Ln=p({type:E(O.PRODUCT_SELECTOR)}).strict(),jr=p({type:E(O.PRODUCT_SELECTOR),label:_,maxProducts:Ce(1,32),defaults:Ln.optional()}).strict(),kn=p({type:E(O.SELECTBOX),value:h()}).strict(),Kd=p({value:h().min(1,{message:"value must not be empty"}),label:_}).strict(),Ur=p({type:E(O.SELECTBOX),label:_,placeholder:_,description:_,options:A(Kd).min(1,{message:"must have at least one option"}),defaults:kn.optional()}).strict(),Pn=p({type:E(O.TEXTAREA),text:_}).strict(),Mr=p({type:E(O.TEXTAREA),label:_,placeholder:_,defaults:Pn.optional()}).strict(),zn=p({type:E(O.TOGGLE),enabled:v()}).strict(),Fr=p({type:E(O.TOGGLE),label:_,description:_,defaults:zn.optional()}).strict(),xr=p({type:E(O.DECK)}).strict(),Jd=re("type",[Dn,Pn,bn,Cn,zn,kn,Nn,$n,Ln,An]),Xd=p({type:E(O.DECK),cards:A(p({settings:Y(h(),Jd).superRefine((e,t)=>{Object.keys(e).length<1&&G(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()).min(1,{message:"cards must have at least one card"})}).strict(),Gr=[zr,Mr,Dr,vr,Fr,Ur,kr,Pr,Lr,jr],Qd=p({type:E(O.DECK),label:_,addButtonLabel:_,maxCards:oe().min(1,{message:"must be a positive integer"}),cards:p({defaultCardContent:p({label:_,settings:Y(h(),re("type",[...Gr])).superRefine((e,t)=>{Object.keys(e).length<1&&G(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:xr.optional()}).strict(),qd=re("type",[...Gr,Qd]),ep=p({type:E(O.DECK),label:_,addButtonLabel:_,maxCards:oe().min(1,{message:"must be a positive integer"}),cards:p({defaultCardContent:p({label:_,settings:Y(h(),qd).superRefine((e,t)=>{Object.keys(e).length<1&&G(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:xr.optional()}).strict(),Zr=p({type:E(O.LOGO),logoType:Td.optional(),text:_.optional(),imageData:Nt.optional()}).strict(),tp=p({type:E(O.LOGO),label:_.optional(),defaults:Zr.optional()}).strict(),Br=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=G(t);Rr(e.type,e.link,n),br(e.type,e.categoryId,n),Ar(e.type,e.email,n),Nr(e.type,e.phone,n),$r(e.type,void 0,e.tileIdForScroll,n),Hd(e.type,e.pageIdForNavigate,n)}),Hr=p({type:E(O.MENU),items:A(Br).optional()}).strict(),np=p({type:E(O.MENU),label:_.optional(),defaults:Hr.optional()}).strict(),Vr=p({type:E(O.NAVIGATION_MENU),items:A(Br).optional()}).strict(),op=p({type:E(O.NAVIGATION_MENU),defaults:Vr.optional()}).strict(),$t=p({type:E(w.BACKGROUND),style:Nd.optional(),color:xe([q,A(q)]).optional()}).strict().superRefine((e,t)=>{const n=G(t).at("color");e.style===In.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===In.COLOR&&(e.color===void 0?n.addIssue("COLOR_REQUIRED_STYLE_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_STYLE_COLOR"))}),rp=p({type:E(w.BACKGROUND),fieldName:h(),defaults:$t.optional()}).strict(),Wr=p({type:E(w.BACKGROUND),label:_,colors:A(q).optional(),enableAlphaColor:v().optional(),enableAutoColor:v().optional(),defaults:$t.optional()}).strict(),Dt=p({type:E(w.BUTTON),appearance:vd.optional(),size:Rd.optional(),shape:Ad.optional(),font:h().optional(),color:q.optional(),visible:v().optional()}).strict(),sp=p({type:E(w.BUTTON),fieldName:h(),defaults:Dt.optional()}).strict(),Yr=p({type:E(w.BUTTON),label:_,colors:A(q).optional(),enableAutoColor:v().optional(),enableAlphaColor:v().optional(),hideVisibleToggle:v().optional(),hideSize:v().optional(),defaults:Dt.optional()}).strict(),Lt=p({type:E(w.COLOR_PICKER),color:q.optional()}).strict(),ip=p({type:E(w.COLOR_PICKER),fieldName:h(),defaults:Lt.optional()}).strict(),Kr=p({type:E(w.COLOR_PICKER),label:_,description:_.optional(),colors:A(q).optional(),enableAlphaColor:v().optional(),enableAutoColor:v().optional(),defaults:Lt.optional()}).strict(),kt=p({type:E(w.DIVIDER)}).strict(),ap=p({type:E(w.DIVIDER),fieldName:h(),defaults:kt.optional()}).strict(),Jr=p({type:E(w.DIVIDER),label:_,defaults:kt.optional()}).strict(),Pt=p({type:E(w.IMAGE),overlay:Id.optional(),color:xe([q,A(q)]).optional(),visible:v().optional()}).strict().superRefine((e,t)=>{const n=G(t).at("color");e.overlay===bt.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===bt.COLOR?e.color===void 0?n.addIssue("COLOR_REQUIRED_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_COLOR"):(e.overlay===bt.NONE||e.overlay===void 0)&&e.color!==void 0&&n.addIssue("COLOR_MUST_BE_UNDEFINED_NONE")}),cp=p({type:E(w.IMAGE),fieldName:h(),defaults:Pt.optional()}).strict(),Xr=p({type:E(w.IMAGE),label:_,static:v().optional(),colors:A(vn).optional(),enableAlphaColor:v().optional(),hideVisibleToggle:v().optional(),defaults:Pt.optional()}).strict(),up=p({label:_,link:At}).strict(),lp=p({label:_.optional(),link:At.optional()}).strict(),zt=p({type:E(w.INFO),description:_.optional(),button:lp.optional()}).strict(),dp=p({type:E(w.INFO),fieldName:h(),defaults:zt.optional()}).strict(),Qr=p({type:E(w.INFO),label:_,description:_,button:up.optional(),defaults:zt.optional()}).strict(),pp=p({visible:v(),width:Ce(1,49).optional(),color:q.optional()}).strict(),jt=p({type:E(w.LOGO),font:h().optional(),size:xe([oe().min(1,{message:"must be at least 1"}),wr]).optional(),bold:v().optional(),italic:v().optional(),color:q.optional(),visible:v().optional(),spacing:Ce(1,9).optional(),frame:pp.optional(),capitalization:z(["none","all","small"]).optional()}).strict(),fp=p({type:E(w.LOGO),fieldName:h(),defaults:jt.optional()}).strict(),qr=p({type:E(w.LOGO),label:_,colors:A(q).optional(),sizes:A(oe().min(1,{message:"must be at least 1"})).optional(),defaults:jt.optional()}).strict(),hp=p({value:h().optional(),label:_.optional()}).strict(),Ut=p({type:E(w.SELECTBOX),value:h().optional()}).strict(),mp=p({type:E(w.SELECTBOX),fieldName:h(),defaults:Ut.optional()}).strict(),es=p({type:E(w.SELECTBOX),label:_,description:_.optional(),options:A(hp).optional(),defaults:Ut.optional()}).strict(),Mt=p({type:E(w.TEXT),font:h().optional(),size:xe([oe().min(1,{message:"must be at least 1"}),wr]).optional(),bold:v().optional(),italic:v().optional(),color:q.optional(),visible:v().optional()}).strict(),Ep=p({type:E(w.TEXT),fieldName:h(),defaults:Mt.optional()}).strict(),ts=p({type:E(w.TEXT),label:_,colors:A(vn).optional(),sizes:A(oe().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(),Ft=p({type:E(w.TOGGLE),enabled:v().optional()}).strict(),gp=p({type:E(w.TOGGLE),fieldName:h(),defaults:Ft.optional()}).strict(),ns=p({type:E(w.TOGGLE),label:_,defaults:Ft.optional()}).strict();function _p(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_SHOWCASE_ITEMS_REQUIRED")}function yp(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 Sp(e,t,n){Object.keys(e).length===0&&n.at("editors").addIssue("ACCORDION_ITEM_EDITORS_REQUIRED",t)}function Tp(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_ITEMS_REQUIRED")}function Op(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 Ip(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 os=p({type:E(w.ACCORDION)}).strict(),wp=re("type",[Mt,Dt,Pt,Ft,Ut,$t,Lt,jt,kt,zt]),vp=p({editors:Y(h(),wp)}).strict(),Cp=p({type:E(w.ACCORDION),items:Y(h(),vp)}).strict().superRefine((e,t)=>{const n=G(t);_p(e.items,n),yp(e.items,n)}),Rp=p({type:E(w.ACCORDION),fieldName:h(),defaults:os.optional()}).strict(),bp=re("type",[ts,Yr,Xr,ns,es,Wr,Kr,qr,Jr,Qr]),Ap=p({label:_,positionFieldName:h().optional(),editors:Y(h(),bp)}).strict().superRefine((e,t)=>{Sp(e.editors,e.label,G(t))}),Np=p({type:E(w.ACCORDION),sortable:v().optional(),items:Y(h(),Ap),defaults:os.optional()}).strict().superRefine((e,t)=>{const n=G(t);Tp(e.items,n),e.sortable===!0&&(Op(e.items,n),Ip(e.items,n))}),rs=re("type",[Dn,Pn,bn,Cn,zn,kn,Hr,Vr,Zr,Nn,$n,Xd,Ln,An]),ss=re("type",[Mt,Dt,Pt,Ft,Ut,$t,Lt,jt,kt,Cp,zt]),$p=p({showcaseId:h(),blockName:h(),previewImage:Nt,content:Y(h(),rs),design:Y(h(),ss),layoutId:h().optional()}).strict(),Dp=p({blockName:h(),content:Y(h(),rs).optional(),design:Y(h(),ss).optional(),layoutId:h().optional()}).strict();function Lp(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 Pp(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 zp=new RegExp(`^(${Object.values(zd).join("|")})(_\\d{3})?$`),jp=h().regex(zp,"id must match pattern: [default_section_name] or [default_section_name]_XXX where XXX is three digits"),Up=h().regex(new RegExp("\\d{3}"),"showcase_id must be a three digit string"),is=p({type:E("default"),id:jp,showcase_id:Up.optional()}).strict(),jn=p({type:E("custom"),id:h(),showcase_id:h().optional(),showcase_overrides:Dp.optional(),category:Ud.optional()}).strict(),Mp=p({type:E("store"),id:h().optional()}).strict(),Fp=re("type",[is,jn,Mp]),xp=p({title:h()}).strict(),Gp=p({metadata:xp.optional(),sections:A(Fp)}).strict(),Zp=Gp.safeExtend({type:$d,id:h().min(1,{message:"id is required"})}).strict().superRefine((e,t)=>{const n=G(t);kp(e,n),Lp(e,n),Pp(e,n)}),as=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:fr({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:Nt,categories:A(Ld).refine(e=>new Set(e).size===e.length,{message:"categories must contain unique items"}).optional()}).strict(),Bp=is.extend({id:h()}),cs=re("type",[Bp,jn]),Hp=p({metadata:as,header:cs,footer:cs}).strict(),Vp=p({id:h().min(1,{message:"id is required"}),assets:wn.array().optional(),configuration:Hp,pages:A(Zp)}).strict(),xt=2097152,Gt=512e3;function ye(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 Wp={menu:{type:O.NAVIGATION_MENU},logo:{type:O.LOGO}},Yp={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 us(e){switch(e){case Ge.HEADER:return Wp;default:return{}}}function ls(e){switch(e){case Ge.HEADER:return Yp;default:return{}}}function ds({validationType:e,sectionType:t}){switch(e){case tt.CONTENT:return us(t);case tt.DESIGN:return ls(t);default:return{}}}const Kp=jn.extend({id:h().min(1,{message:"section id is required"})}),Jp=p({metadata:as,sections:A(Kp).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&&G(t).at(["collection","metadata","name"]).addIssue("REQUIRED_COLLECTION_NAME")}),Xp=p({id:h().min(1,{message:"id is required"}),descriptor:Jp}).strict(),Qp=re("type",[zr,Mr,Dr,vr,Fr,Ur,ep,np,op,tp,kr,Pr,jr,Lr]),Un=Y(h(),Qp),qp=re("type",[ts,Yr,Xr,ns,es,Wr,Kr,qr,Jr,Np,Qr]),Mn=Y(h(),qp),ef=re("type",[Ep,sp,cp,gp,mp,rp,ip,fp,ap,dp,Rp]),Fn=p({layoutId:h(),layoutIcon:Pd.optional(),selectedContentSettings:A(h()),selectedDesignSettings:A(ef)}).strict(),tf=h().regex(Fd,Ae.VALID_LANGUAGE_CODE()),Zt=Y(tf,Y(_,h()));function ps(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 fs(e,t,n){Cr(e,t,n)}function nf(e,t,n){if(e.type!==O.DECK||t.type!==O.DECK)return;const o=t.cards?.defaultCardContent?.settings,r=e.cards;if(!o||!Array.isArray(r))return;const s=new Set(Object.keys(o));r.forEach((i,a)=>{i.settings&&Object.keys(i.settings).forEach(c=>{s.has(c)||n.at(["cards",a,"settings",c]).addIssue("INVALID_DECK_CARD_SETTING",c)})})}function of(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===O.SELECTBOX&&i.type===O.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===O.DECK&&nf(r,i,s)})}function rf(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 sf(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 af(e,t,n){e.layoutId&&((t||[]).some(o=>o.layoutId===e.layoutId)||n.at("layoutId").addIssue("SHOWCASE_LAYOUT",e.layoutId))}function cf(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 hs(e,t,n){for(const[o,r]of Object.entries(e)){const s=r;if(s.type===O.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===O.DECK){const i=s;i.cards?.defaultCardContent?.settings&&hs(i.cards.defaultCardContent.settings,t,n.at([o,"cards","defaultCardContent","settings"]))}}}function uf(e,t,n){t>xt&&n.at(j.basename(e)).addIssue("REQUIRED_SECTION_ASSET",ye(t),ye(xt))}function lf(e,t){e>Gt&&t.addIssue("REQUIRED_SERVER_SIZE",ye(e),ye(Gt))}const df=p({id:h(),type:yd,name:h(),content:Un,design:Mn,layout:A(Fn).optional(),showcase:A($p),translationsSettings:Zt.optional(),translationsShowcases:Zt.optional(),assets:wn.array().optional(),server:Ir,previewCount:oe().optional()}).strict().superRefine((e,t)=>{const n=G(t),o=ds({validationType:tt.CONTENT,sectionType:e.type}),r=ds({validationType:tt.DESIGN,sectionType:e.type});ps(e.content,o,n.at("content")),ps(e.design,r,n.at("design")),hs(e.content,e.design,n.at("content")),sf(e.design,n.at("design")),e.assets&&e.assets.forEach(i=>{uf(i.path,i.size,n.at("assets"))}),lf(e.server.size,n.at("server"));const s=e.assets?.map(i=>i.path)??[];fs(e.content,s,n.at("content")),cf(e.showcase,n.at("showcase")),e.showcase.forEach((i,a)=>{const c=n.at(["showcase",a]);fs(i,s,c),of(i,e.content,c),rf(i,e.design,c),af(i,e.layout,c)})}),pf=p({translations:Zt.optional()}).strict(),ff=z(["products","category","product"]),hf=p({id:h(),sectionId:h(),assets:wn.array().optional(),content:Un.optional(),design:Mn.optional(),translationsSettings:Zt.optional(),layouts:Fn.array().optional()}).strict().superRefine((e,t)=>{const n=G(t);nt.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,nt.options.join(", ")),e.assets&&e.assets.forEach(o=>{o.size>xt&&n.at(["assets",j.basename(o.path)]).addIssue("REQUIRED_SECTION_ASSET",ye(o.size),ye(xt))})});p({id:h(),sectionId:nt,pageId:ff,content:Un.optional(),design:Mn.optional(),layouts:Fn.array().optional()}).strict();const mf=p({id:h(),sectionId:h(),layoutId:h(),server:Ir}).strict().superRefine((e,t)=>{const n=G(t);nt.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,nt.options.join(", ")),e.server.size>Gt&&n.at("server").addIssue("REQUIRED_SERVER_SIZE",ye(e.server.size),ye(Gt))});function Ef(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 gf(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 _f(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&&Cr(e.content,r,o.at(["content"]))}function ms(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"),_f(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 yf(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 Sf=p({version:h(),name:h(),shared:pf.optional(),sections:A(df),templates:A(Vp),layouts:A(hf),slots:A(mf),collections:A(Xp),compressionEnabled:v(),externalizationEnabled:v(),vueVersion:h(),openSource:v().optional()}).strict().superRefine((e,t)=>{e.templates.forEach((n,o)=>{const r=G(t).at(["templates",o]);Ef(n.configuration.header,e.sections,r.at(["configuration","header"])),gf(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"?ms(c,e.sections,d):c.type==="store"&&yf(c,s,e.layouts,d)})})}),e.collections.forEach((n,o)=>{n.descriptor.sections.forEach((r,s)=>{const i=G(t).at(["collections",o,"sections",s]);ms(r,e.sections,i,!0)})})});_e({customError:_d});const f={error:e=>console.log(li(e)),warn:e=>console.log(ui(e)),info:e=>console.log(ue(e))},Tf="dist",Of="dist/shared",he="dist/sections",xn="dist/headers",Gn="dist/footers",Se="dist/templates",Ze="layouts",Es="preview",X=`dist/${Ze}`,rt="dist/collections",gs="dist/manifest.json",If=[he,xn,Gn,Se,X];function Bt(e){return!!e}function Ne(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}const wf="Resource name can only contain alphanumeric characters, dashes, and underscores";function vf(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:wf}}function Cf(e){return e===!0?!0:typeof e=="string"&&e.trim().length===0}function Rf(e){return j.parse(e).name}function bf(e){return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function Ht(){const e=await un(S(process.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}function Af(e){return e.includes(`
|
|
40
|
-
`)}function
|
|
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 cr(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 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,u),i._zod.parent===d)for(const B in c)B==="$ref"||B==="allOf"||B in u||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 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: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 W(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 W(o.element,n);if(o.type==="set")return W(o.valueType,n);if(o.type==="lazy")return W(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 W(o.innerType,n);if(o.type==="intersection")return W(o.left,n)||W(o.right,n);if(o.type==="record"||o.type==="map")return W(o.keyType,n)||W(o.valueType,n);if(o.type==="pipe")return W(o.in,n)||W(o.out,n);if(o.type==="object"){for(const r in o.shape)if(W(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(const r of o.options)if(W(r,n))return!0;return!1}if(o.type==="tuple"){for(const r of o.items)if(W(r,n))return!0;return!!(o.rest&&W(o.rest,n))}return!1}const Gu=(e,t={})=>n=>{const o=ir({...n,processors:t});return M(e,o),ar(o,e),cr(o,e)},vt=(e,t,n={})=>o=>{const{libraryOptions:r,target:s}=o??{},i=ir({...r??{},target:s,io:t,processors:n});return M(e,i),ar(i,e),cr(i,e)},xu={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Bu=(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=xu[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}))])}},Zu=(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)},Hu=(e,t,n,o)=>{n.type="boolean"},Vu=(e,t,n,o)=>{n.not={}},Wu=(e,t,n,o)=>{},Yu=(e,t,n,o)=>{const r=e._zod.def,s=Oo(r.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},Ku=(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},Ju=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Xu=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Qu=(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=M(s.element,t,{...o,path:[...o.path,"items"]})},qu=(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]=M(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=M(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},el=(e,t,n,o)=>{const r=e._zod.def,s=r.inclusive===!1,i=r.options.map((a,c)=>M(a,t,{...o,path:[...o.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=i:n.anyOf=i},tl=(e,t,n,o)=>{const r=e._zod.def,s=M(r.left,t,{...o,path:[...o.path,"allOf",0]}),i=M(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},nl=(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=M(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=M(s.keyType,t,{...o,path:[...o.path,"propertyNames"]})),r.additionalProperties=M(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)}},ol=(e,t,n,o)=>{const r=e._zod.def,s=M(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"}]},rl=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},sl=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},il=(e,t,n,o)=>{const r=e._zod.def;M(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)))},al=(e,t,n,o)=>{const r=e._zod.def;M(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},cl=(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;M(s,t,o);const i=t.seen.get(e);i.ref=s},ul=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0},ur=(e,t,n,o)=>{const r=e._zod.def;M(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},ll=l("ZodISODateTime",(e,t)=>{dc.init(e,t),P.init(e,t)});function dl(e){return Eu(ll,e)}const pl=l("ZodISODate",(e,t)=>{pc.init(e,t),P.init(e,t)});function fl(e){return gu(pl,e)}const hl=l("ZodISOTime",(e,t)=>{fc.init(e,t),P.init(e,t)});function ml(e){return _u(hl,e)}const El=l("ZodISODuration",(e,t)=>{hc.init(e,t),P.init(e,t)});function gl(e){return yu(El,e)}const _l=(e,t)=>{bo.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>ra(e,n)},flatten:{value:n=>oa(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}}})},ne=l("ZodError",_l,{Parent:Error}),yl=En(ne),Sl=gn(ne),Tl=yt(ne),Ol=St(ne),Il=aa(ne),wl=ca(ne),vl=ua(ne),Cl=la(ne),Rl=da(ne),bl=pa(ne),Al=fa(ne),Nl=ha(ne),k=l("ZodType",(e,t)=>(L.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:vt(e,"input"),output:vt(e,"output")}}),e.toJSONSchema=Gu(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)=>yl(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>Tl(e,n,o),e.parseAsync=async(n,o)=>Sl(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>Ol(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>Il(e,n,o),e.decode=(n,o)=>wl(e,n,o),e.encodeAsync=async(n,o)=>vl(e,n,o),e.decodeAsync=async(n,o)=>Cl(e,n,o),e.safeEncode=(n,o)=>Rl(e,n,o),e.safeDecode=(n,o)=>bl(e,n,o),e.safeEncodeAsync=async(n,o)=>Al(e,n,o),e.safeDecodeAsync=async(n,o)=>Nl(e,n,o),e.refine=(n,o)=>e.check(Od(n,o)),e.superRefine=n=>e.check(Id(n)),e.overwrite=n=>e.check(Me(n)),e.optional=()=>_r(e),e.exactOptional=()=>ld(e),e.nullable=()=>yr(e),e.nullish=()=>_r(yr(e)),e.nonoptional=n=>Ed(e,n),e.array=()=>A(e),e.or=n=>td([e,n]),e.and=n=>rd(e,n),e.transform=n=>Tr(e,cd(n)),e.default=n=>fd(e,n),e.prefault=n=>md(e,n),e.catch=n=>_d(e,n),e.pipe=n=>Tr(e,n),e.readonly=()=>Td(e),e.describe=n=>{const o=e.clone();return et.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){return et.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return et.get(e);const o=e.clone();return et.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),lr=l("_ZodString",(e,t)=>{_n.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Bu(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(vu(...o)),e.includes=(...o)=>e.check(bu(...o)),e.startsWith=(...o)=>e.check(Au(...o)),e.endsWith=(...o)=>e.check(Nu(...o)),e.min=(...o)=>e.check(wt(...o)),e.max=(...o)=>e.check(rr(...o)),e.length=(...o)=>e.check(sr(...o)),e.nonempty=(...o)=>e.check(wt(1,...o)),e.lowercase=o=>e.check(Cu(o)),e.uppercase=o=>e.check(Ru(o)),e.trim=()=>e.check(Du()),e.normalize=(...o)=>e.check($u(...o)),e.toLowerCase=()=>e.check(Lu()),e.toUpperCase=()=>e.check(ku()),e.slugify=()=>e.check(Pu())}),$l=l("ZodString",(e,t)=>{_n.init(e,t),lr.init(e,t),e.email=n=>e.check(Jc(Dl,n)),e.url=n=>e.check(er(pr,n)),e.jwt=n=>e.check(mu(Wl,n)),e.emoji=n=>e.check(tu(Ll,n)),e.guid=n=>e.check(qo(dr,n)),e.uuid=n=>e.check(Xc(Ct,n)),e.uuidv4=n=>e.check(Qc(Ct,n)),e.uuidv6=n=>e.check(qc(Ct,n)),e.uuidv7=n=>e.check(eu(Ct,n)),e.nanoid=n=>e.check(nu(kl,n)),e.guid=n=>e.check(qo(dr,n)),e.cuid=n=>e.check(ou(Pl,n)),e.cuid2=n=>e.check(ru(zl,n)),e.ulid=n=>e.check(su(jl,n)),e.base64=n=>e.check(pu(Zl,n)),e.base64url=n=>e.check(fu(Hl,n)),e.xid=n=>e.check(iu(Ul,n)),e.ksuid=n=>e.check(au(Fl,n)),e.ipv4=n=>e.check(cu(Ml,n)),e.ipv6=n=>e.check(uu(Gl,n)),e.cidrv4=n=>e.check(lu(xl,n)),e.cidrv6=n=>e.check(du(Bl,n)),e.e164=n=>e.check(hu(Vl,n)),e.datetime=n=>e.check(dl(n)),e.date=n=>e.check(fl(n)),e.time=n=>e.check(ml(n)),e.duration=n=>e.check(gl(n))});function h(e){return Kc($l,e)}const P=l("ZodStringFormat",(e,t)=>{$.init(e,t),lr.init(e,t)}),Dl=l("ZodEmail",(e,t)=>{nc.init(e,t),P.init(e,t)}),dr=l("ZodGUID",(e,t)=>{ec.init(e,t),P.init(e,t)}),Ct=l("ZodUUID",(e,t)=>{tc.init(e,t),P.init(e,t)}),pr=l("ZodURL",(e,t)=>{oc.init(e,t),P.init(e,t)});function fr(e){return er(pr,e)}const Ll=l("ZodEmoji",(e,t)=>{rc.init(e,t),P.init(e,t)}),kl=l("ZodNanoID",(e,t)=>{sc.init(e,t),P.init(e,t)}),Pl=l("ZodCUID",(e,t)=>{ic.init(e,t),P.init(e,t)}),zl=l("ZodCUID2",(e,t)=>{ac.init(e,t),P.init(e,t)}),jl=l("ZodULID",(e,t)=>{cc.init(e,t),P.init(e,t)}),Ul=l("ZodXID",(e,t)=>{uc.init(e,t),P.init(e,t)}),Fl=l("ZodKSUID",(e,t)=>{lc.init(e,t),P.init(e,t)}),Ml=l("ZodIPv4",(e,t)=>{mc.init(e,t),P.init(e,t)}),Gl=l("ZodIPv6",(e,t)=>{Ec.init(e,t),P.init(e,t)}),xl=l("ZodCIDRv4",(e,t)=>{gc.init(e,t),P.init(e,t)}),Bl=l("ZodCIDRv6",(e,t)=>{_c.init(e,t),P.init(e,t)}),Zl=l("ZodBase64",(e,t)=>{yc.init(e,t),P.init(e,t)}),Hl=l("ZodBase64URL",(e,t)=>{Tc.init(e,t),P.init(e,t)}),Vl=l("ZodE164",(e,t)=>{Oc.init(e,t),P.init(e,t)}),Wl=l("ZodJWT",(e,t)=>{wc.init(e,t),P.init(e,t)}),hr=l("ZodNumber",(e,t)=>{Fo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Zu(e,o,r),e.gt=(o,r)=>e.check(nr(o,r)),e.gte=(o,r)=>e.check(Tn(o,r)),e.min=(o,r)=>e.check(Tn(o,r)),e.lt=(o,r)=>e.check(tr(o,r)),e.lte=(o,r)=>e.check(Sn(o,r)),e.max=(o,r)=>e.check(Sn(o,r)),e.int=o=>e.check(he(o)),e.safe=o=>e.check(he(o)),e.positive=o=>e.check(nr(0,o)),e.nonnegative=o=>e.check(Tn(0,o)),e.negative=o=>e.check(tr(0,o)),e.nonpositive=o=>e.check(Sn(0,o)),e.multipleOf=(o,r)=>e.check(or(o,r)),e.step=(o,r)=>e.check(or(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 Rt(e){return Su(hr,e)}const Yl=l("ZodNumberFormat",(e,t)=>{vc.init(e,t),hr.init(e,t)});function he(e){return Tu(Yl,e)}const Kl=l("ZodBoolean",(e,t)=>{Cc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Hu(e,n,o)});function v(e){return Ou(Kl,e)}const Jl=l("ZodUnknown",(e,t)=>{Rc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Wu()});function mr(){return Iu(Jl)}const Xl=l("ZodNever",(e,t)=>{bc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Vu(e,n,o)});function Ql(e){return wu(Xl,e)}const ql=l("ZodArray",(e,t)=>{Ac.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Qu(e,n,o,r),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(rr(n,o)),e.length=(n,o)=>e.check(sr(n,o)),e.unwrap=()=>e.element});function A(e,t){return zu(ql,e,t)}const ed=l("ZodObject",(e,t)=>{$c.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>qu(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:mr()}),e.loose=()=>e.clone({...e._zod.def,catchall:mr()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ql()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Qi(e,n),e.safeExtend=n=>qi(e,n),e.merge=n=>ea(e,n),e.pick=n=>Ji(e,n),e.omit=n=>Xi(e,n),e.partial=(...n)=>ta(gr,e,n[0]),e.required=(...n)=>na(Sr,e,n[0])});function p(e,t){const n={type:"object",shape:e??{},...g(t)};return new ed(n)}const Er=l("ZodUnion",(e,t)=>{Zo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>el(e,n,o,r),e.options=t.options});function td(e,t){return new Er({type:"union",options:e,...g(t)})}const nd=l("ZodDiscriminatedUnion",(e,t)=>{Er.init(e,t),Dc.init(e,t)});function oe(e,t,n){return new nd({type:"union",options:t,discriminator:e,...g(n)})}const od=l("ZodIntersection",(e,t)=>{Lc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>tl(e,n,o,r)});function rd(e,t){return new od({type:"intersection",left:e,right:t})}const sd=l("ZodRecord",(e,t)=>{kc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>nl(e,n,o,r),e.keyType=t.keyType,e.valueType=t.valueType});function Y(e,t,n){return new sd({type:"record",keyType:e,valueType:t,...g(n)})}const On=l("ZodEnum",(e,t)=>{Pc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Yu(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 On({...t,checks:[],...g(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 On({...t,checks:[],...g(r),entries:s})}});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 id=l("ZodLiteral",(e,t)=>{zc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ku(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 id({type:"literal",values:Array.isArray(e)?e:[e],...g(t)})}const ad=l("ZodTransform",(e,t)=>{jc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Xu(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new To(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(qe(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(qe(i))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(s=>(n.value=s,n)):(n.value=r,n)}});function cd(e){return new ad({type:"transform",transform:e})}const gr=l("ZodOptional",(e,t)=>{Wo.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ur(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function _r(e){return new gr({type:"optional",innerType:e})}const ud=l("ZodExactOptional",(e,t)=>{Uc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ur(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function ld(e){return new ud({type:"optional",innerType:e})}const dd=l("ZodNullable",(e,t)=>{Fc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ol(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function yr(e){return new dd({type:"nullable",innerType:e})}const pd=l("ZodDefault",(e,t)=>{Mc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>sl(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function fd(e,t){return new pd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Co(t)}})}const hd=l("ZodPrefault",(e,t)=>{Gc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>il(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function md(e,t){return new hd({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Co(t)}})}const Sr=l("ZodNonOptional",(e,t)=>{xc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>rl(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Ed(e,t){return new Sr({type:"nonoptional",innerType:e,...g(t)})}const gd=l("ZodCatch",(e,t)=>{Bc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>al(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _d(e,t){return new gd({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const yd=l("ZodPipe",(e,t)=>{Zc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>cl(e,n,o,r),e.in=t.in,e.out=t.out});function Tr(e,t){return new yd({type:"pipe",in:e,out:t})}const Sd=l("ZodReadonly",(e,t)=>{Hc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ul(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Td(e){return new Sd({type:"readonly",innerType:e})}const Or=l("ZodCustom",(e,t)=>{Vc.init(e,t),k.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ju(e,n)});function Ge(e,t){return ju(Or,e??(()=>!0),t)}function Od(e,t={}){return Uu(Or,e,t)}function Id(e){return Fu(e)}const wd={url:"must be a valid URL",email:"must be a valid email address"},vd=e=>{const t=e?.at(-1);return typeof t=="string"?`'${t}'`:"Field"},Cd=e=>e===null?"null":typeof e,Rd=e=>{switch(e.code){case"invalid_type":{const{input:t}=e;return t===void 0?{message:`${vd(e.path)} is required`}:{message:`Expected ${String(e.expected)}, received ${Cd(t)}`}}case"invalid_format":{const t=wd[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}},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 xe={SECTION:"SECTION",HEADER:"HEADER",FOOTER:"FOOTER"},bd=U(Object.values(xe)),tt={CONTENT:"Content",DESIGN:"Design"};U(Object.values(tt));const Ad={TEXT:"TEXT",IMAGE:"IMAGE"},Nd=U(Object.values(Ad)),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"},$d=U(Object.values(Ce)),bt={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"},Dd=U(Object.values(bt)),Ld={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"},kd=U(Object.values(Ld)),Pd={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"},zd=U(Object.values(Pd)),jd={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"},Ud=U(Object.values(jd)),In={COLOR:"COLOR",GRADIENT:"GRADIENT"},Fd=U(Object.values(In));U(["none","all","small"]);const Ae={PRODUCT:"PRODUCT",CATALOG:"CATALOG",CATEGORY:"CATEGORY",HOME:"HOME",CUSTOM:"CUSTOM"},Ir={HOME:"home",CATALOG:"catalog",CATEGORY:"category",PRODUCT:"product"},Md=U(Object.values(Ae));U(Object.values(Ir));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)),Bd={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"},Zd=U(Object.values(Bd)),Hd={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"},Vd={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"},Wd=U(Object.values(Vd)),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"},wr=/^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,vr=/^global\.fontFamily\.(title|body)$/,Cr=/^global\.textSize\.(title|subtitle|body)$/,Rr=/^global\.color\.(title|body|button|link|background)$/,Yd=/^[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(),br=p({size:Rt().nonnegative()}).strict(),_=h().regex(/^\$.+/,{message:"must start with '$' followed by at least one character"}),Kd=p({r:Re(0,255),g:Re(0,255),b:Re(0,255),a:Re(0,1)}).strict(),Ar=h().regex(wr,{message:X.VALID_HEX_COLOR()});Ge(e=>typeof e=="string"&&vr.test(e),{message:X.VALID_GLOBAL_FONT()});const vn=h().refine(e=>!e.startsWith("global.")||vr.test(e),{message:X.VALID_GLOBAL_FONT()});Ge(e=>typeof e=="string"&&Rr.test(e),{message:X.VALID_GLOBAL_COLOR()});const le=Ge(e=>typeof e=="string"&&(wr.test(e)||Rr.test(e)),{message:X.VALID_COLOR()}),Nr=Ge(e=>typeof e=="string"?le.safeParse(e).success:Array.isArray(e)&&e.every(t=>le.safeParse(t).success),{message:X.VALID_COLOR()});Ge(e=>typeof e=="string"&&Cr.test(e),{message:X.VALID_GLOBAL_TEXT_SIZE()});const $r=Ge(e=>typeof e=="number"?Number.isInteger(e)&&e>=1:typeof e=="string"&&Cr.test(e),{message:X.VALID_TEXT_SIZE()}),nt=U(["catalog","category","product"]),At=h().refine(e=>e.startsWith("#")||fr().safeParse(e).success,{message:"must be a valid URL or a hash fragment starting with #"}),ot=p({url:h(),width:he().min(0,{message:X.NON_NEGATIVE_INTEGER()}).optional(),height:he().min(0,{message:X.NON_NEGATIVE_INTEGER()}).optional()}).strict(),Jd=p({homogeneity:v().optional(),color:Kd.optional()}).strict(),Xd=p({ORIGINAL:ot.optional(),WEBP_LOW_RES:ot.optional(),WEBP_HI_2X_RES:ot.optional(),MOBILE_WEBP_LOW_RES:ot.optional(),MOBILE_WEBP_HI_RES:ot.optional()}).strict().refine(e=>Object.keys(e).length>=1,{message:"set must have at least one property"}),Nt=p({set:Xd,borderInfo:Jd.optional()}).strict(),Cn=p({type:E(O.IMAGE),imageData:Nt}).strict(),Dr=p({type:E(O.IMAGE),label:_,static:v().optional(),defaults:Cn.optional()}).strict(),Qd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Rn(e){return e===Ae.PRODUCT||e===Ae.CATALOG||e===Ae.CATEGORY}function Lr(e,t,n){if(!e)return;const o=vi({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 kr(e,t,n){e===Ce.HYPER_LINK&&!t&&n.at("link").addIssue("BUTTON_LINK_REQUIRED")}function Pr(e,t,n){(e===Ce.GO_TO_CATEGORY||e===Ce.GO_TO_CATEGORY_LINK)&&!t&&n.at("categoryId").addIssue("BUTTON_CATEGORY_ID_REQUIRED")}function zr(e,t,n){e===Ce.MAIL_LINK&&!t&&n.at("email").addIssue("BUTTON_EMAIL_REQUIRED")}function jr(e,t,n){e===Ce.TEL_LINK&&!t&&n.at("phone").addIssue("BUTTON_PHONE_REQUIRED")}function Ur(e,t,n,o){if(e===Ce.SCROLL_TO_TILE&&!(t??n)){const r=t?"tileId":"tileIdForScroll";o.at(r).addIssue("BUTTON_TILE_ID_REQUIRED",r)}}function qd(e,t,n){e===Ce.GO_TO_PAGE&&!t&&n.at("pageIdForNavigate").addIssue("BUTTON_PAGE_ID_REQUIRED")}const ep="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:ep,message:X[r](...s),path:o,params:{errorMessageKey:r}})},at(r){const s=o.concat(n(r));return x(e,s)}}}const bn=p({type:E(O.BUTTON),title:_,buttonType:$d,link:h().optional(),linkTarget:h().optional(),email:h().regex(Qd,{message:X.VALID_EMAIL()}).optional(),phone:h().optional(),tileId:h().optional(),categoryId:Rt().optional()}).strict().superRefine((e,t)=>{const n=x(t);kr(e.buttonType,e.link,n),Pr(e.buttonType,e.categoryId,n),zr(e.buttonType,e.email,n),jr(e.buttonType,e.phone,n),Ur(e.buttonType,e.tileId,void 0,n)}),Fr=p({type:E(O.BUTTON),label:_,defaults:bn.optional()}).strict(),An=p({type:E(O.CATEGORY_SELECTOR)}).strict(),Mr=p({type:E(O.CATEGORY_SELECTOR),label:_,maxCategories:Re(1,32),defaults:An.optional()}).strict(),Nn=p({type:E(O.DIVIDER)}).strict(),Gr=p({type:E(O.DIVIDER),label:_,defaults:Nn.optional()}).strict(),tp=p({label:_,link:At}).strict(),np=p({title:_.optional(),link:At.optional()}).strict(),$n=p({type:E(O.INFO),text:_.optional(),button:np.optional()}).strict(),xr=p({type:E(O.INFO),label:_,description:_,button:tp.optional(),defaults:$n.optional()}).strict(),Dn=p({type:E(O.INPUTBOX),text:_}).strict(),Br=p({type:E(O.INPUTBOX),label:_,placeholder:_,defaults:Dn.optional()}).strict(),Ln=p({type:E(O.PRODUCT_SELECTOR)}).strict(),Zr=p({type:E(O.PRODUCT_SELECTOR),label:_,maxProducts:Re(1,32),defaults:Ln.optional()}).strict(),kn=p({type:E(O.SELECTBOX),value:h()}).strict(),op=p({value:h().min(1,{message:"value must not be empty"}),label:_}).strict(),Hr=p({type:E(O.SELECTBOX),label:_,placeholder:_,description:_,options:A(op).min(1,{message:"must have at least one option"}),defaults:kn.optional()}).strict(),Pn=p({type:E(O.TEXTAREA),text:_}).strict(),Vr=p({type:E(O.TEXTAREA),label:_,placeholder:_,defaults:Pn.optional()}).strict(),zn=p({type:E(O.TOGGLE),enabled:v()}).strict(),Wr=p({type:E(O.TOGGLE),label:_,description:_,defaults:zn.optional()}).strict(),Yr=p({type:E(O.DECK)}).strict(),rp=oe("type",[Dn,Pn,bn,Cn,zn,kn,Nn,$n,Ln,An]),sp=p({type:E(O.DECK),cards:A(p({settings:Y(h(),rp).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(),Kr=[Br,Vr,Fr,Dr,Wr,Hr,Gr,xr,Mr,Zr],ip=p({type:E(O.DECK),label:_,addButtonLabel:_,maxCards:he().min(1,{message:"must be a positive integer"}),cards:p({defaultCardContent:p({label:_,settings:Y(h(),oe("type",[...Kr])).superRefine((e,t)=>{Object.keys(e).length<1&&x(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:Yr.optional()}).strict(),ap=oe("type",[...Kr,ip]),cp=p({type:E(O.DECK),label:_,addButtonLabel:_,maxCards:he().min(1,{message:"must be a positive integer"}),cards:p({defaultCardContent:p({label:_,settings:Y(h(),ap).superRefine((e,t)=>{Object.keys(e).length<1&&x(t).addIssue("DECK_SETTINGS_REQUIRED")})}).strict()}).strict(),defaults:Yr.optional()}).strict(),Jr=p({type:E(O.LOGO),logoType:Nd.optional(),text:_.optional(),imageData:Nt.optional()}).strict(),up=p({type:E(O.LOGO),label:_.optional(),defaults:Jr.optional()}).strict(),Xr=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);kr(e.type,e.link,n),Pr(e.type,e.categoryId,n),zr(e.type,e.email,n),jr(e.type,e.phone,n),Ur(e.type,void 0,e.tileIdForScroll,n),qd(e.type,e.pageIdForNavigate,n)}),Qr=p({type:E(O.MENU),items:A(Xr).optional()}).strict(),lp=p({type:E(O.MENU),label:_.optional(),defaults:Qr.optional()}).strict(),qr=p({type:E(O.NAVIGATION_MENU),items:A(Xr).optional()}).strict(),dp=p({type:E(O.NAVIGATION_MENU),defaults:qr.optional()}).strict(),$t=p({type:E(w.BACKGROUND),style:Fd.optional(),color:Nr.optional()}).strict().superRefine((e,t)=>{const n=x(t).at("color");e.style===In.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===In.COLOR&&(e.color===void 0?n.addIssue("COLOR_REQUIRED_STYLE_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_STYLE_COLOR"))}),pp=p({type:E(w.BACKGROUND),fieldName:h(),defaults:$t.optional()}).strict(),es=p({type:E(w.BACKGROUND),label:_,colors:A(le).optional(),enableAlphaColor:v().optional(),enableAutoColor:v().optional(),defaults:$t.optional()}).strict(),Dt=p({type:E(w.BUTTON),appearance:kd.optional(),size:zd.optional(),shape:Ud.optional(),font:vn.optional(),color:le.optional(),visible:v().optional()}).strict(),fp=p({type:E(w.BUTTON),fieldName:h(),defaults:Dt.optional()}).strict(),ts=p({type:E(w.BUTTON),label:_,colors:A(le).optional(),enableAutoColor:v().optional(),enableAlphaColor:v().optional(),hideVisibleToggle:v().optional(),hideSize:v().optional(),defaults:Dt.optional()}).strict(),Lt=p({type:E(w.COLOR_PICKER),color:le.optional()}).strict(),hp=p({type:E(w.COLOR_PICKER),fieldName:h(),defaults:Lt.optional()}).strict(),ns=p({type:E(w.COLOR_PICKER),label:_,description:_.optional(),colors:A(le).optional(),enableAlphaColor:v().optional(),enableAutoColor:v().optional(),defaults:Lt.optional()}).strict(),kt=p({type:E(w.DIVIDER)}).strict(),mp=p({type:E(w.DIVIDER),fieldName:h(),defaults:kt.optional()}).strict(),os=p({type:E(w.DIVIDER),label:_,defaults:kt.optional()}).strict(),Pt=p({type:E(w.IMAGE),overlay:Dd.optional(),color:Nr.optional(),visible:v().optional()}).strict().superRefine((e,t)=>{const n=x(t).at("color");e.overlay===bt.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===bt.COLOR?e.color===void 0?n.addIssue("COLOR_REQUIRED_COLOR"):Array.isArray(e.color)&&n.addIssue("COLOR_MUST_BE_SINGLE_COLOR"):(e.overlay===bt.NONE||e.overlay===void 0)&&e.color!==void 0&&n.addIssue("COLOR_MUST_BE_UNDEFINED_NONE")}),Ep=p({type:E(w.IMAGE),fieldName:h(),defaults:Pt.optional()}).strict(),rs=p({type:E(w.IMAGE),label:_,static:v().optional(),colors:A(Ar).optional(),enableAlphaColor:v().optional(),hideVisibleToggle:v().optional(),defaults:Pt.optional()}).strict(),gp=p({label:_,link:At}).strict(),_p=p({label:_.optional(),link:At.optional()}).strict(),zt=p({type:E(w.INFO),description:_.optional(),button:_p.optional()}).strict(),yp=p({type:E(w.INFO),fieldName:h(),defaults:zt.optional()}).strict(),ss=p({type:E(w.INFO),label:_,description:_,button:gp.optional(),defaults:zt.optional()}).strict(),Sp=p({visible:v(),width:Re(1,49).optional(),color:le.optional()}).strict(),jt=p({type:E(w.LOGO),font:vn.optional(),size:$r.optional(),bold:v().optional(),italic:v().optional(),color:le.optional(),visible:v().optional(),spacing:Re(1,9).optional(),frame:Sp.optional(),capitalization:U(["none","all","small"]).optional()}).strict(),Tp=p({type:E(w.LOGO),fieldName:h(),defaults:jt.optional()}).strict(),is=p({type:E(w.LOGO),label:_,colors:A(le).optional(),sizes:A(he().min(1,{message:"must be at least 1"})).optional(),defaults:jt.optional()}).strict(),Op=p({value:h().optional(),label:_.optional()}).strict(),Ut=p({type:E(w.SELECTBOX),value:h().optional()}).strict(),Ip=p({type:E(w.SELECTBOX),fieldName:h(),defaults:Ut.optional()}).strict(),as=p({type:E(w.SELECTBOX),label:_,description:_.optional(),options:A(Op).optional(),defaults:Ut.optional()}).strict(),Ft=p({type:E(w.TEXT),font:vn.optional(),size:$r.optional(),bold:v().optional(),italic:v().optional(),color:le.optional(),visible:v().optional()}).strict(),wp=p({type:E(w.TEXT),fieldName:h(),defaults:Ft.optional()}).strict(),cs=p({type:E(w.TEXT),label:_,colors:A(Ar).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:Ft.optional()}).strict(),Mt=p({type:E(w.TOGGLE),enabled:v().optional()}).strict(),vp=p({type:E(w.TOGGLE),fieldName:h(),defaults:Mt.optional()}).strict(),us=p({type:E(w.TOGGLE),label:_,defaults:Mt.optional()}).strict();function Cp(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_SHOWCASE_ITEMS_REQUIRED")}function Rp(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 bp(e,t,n){Object.keys(e).length===0&&n.at("editors").addIssue("ACCORDION_ITEM_EDITORS_REQUIRED",t)}function Ap(e,t){Object.keys(e).length===0&&t.at("items").addIssue("ACCORDION_ITEMS_REQUIRED")}function Np(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 $p(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 ls=p({type:E(w.ACCORDION)}).strict(),Dp=oe("type",[Ft,Dt,Pt,Mt,Ut,$t,Lt,jt,kt,zt]),Lp=p({editors:Y(h(),Dp)}).strict(),kp=p({type:E(w.ACCORDION),items:Y(h(),Lp)}).strict().superRefine((e,t)=>{const n=x(t);Cp(e.items,n),Rp(e.items,n)}),Pp=p({type:E(w.ACCORDION),fieldName:h(),defaults:ls.optional()}).strict(),zp=oe("type",[cs,ts,rs,us,as,es,ns,is,os,ss]),jp=p({label:_,positionFieldName:h().optional(),editors:Y(h(),zp)}).strict().superRefine((e,t)=>{bp(e.editors,e.label,x(t))}),Up=p({type:E(w.ACCORDION),sortable:v().optional(),items:Y(h(),jp),defaults:ls.optional()}).strict().superRefine((e,t)=>{const n=x(t);Ap(e.items,n),e.sortable===!0&&(Np(e.items,n),$p(e.items,n))}),ds=oe("type",[Dn,Pn,bn,Cn,zn,kn,Qr,qr,Jr,Nn,$n,sp,Ln,An]),ps=oe("type",[Ft,Dt,Pt,Mt,Ut,$t,Lt,jt,kt,kp,zt]),Fp=p({showcaseId:h(),blockName:h(),previewImage:Nt,content:Y(h(),ds),design:Y(h(),ps),layoutId:h().optional()}).strict(),Mp=p({blockName:h(),content:Y(h(),ds).optional(),design:Y(h(),ps).optional(),layoutId:h().optional()}).strict();function Gp(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 xp(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 Bp(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 Zp=new RegExp(`^(${Object.values(Hd).join("|")})(_\\d{3})?$`),Hp=h().regex(Zp,"id must match pattern: [default_section_name] or [default_section_name]_XXX where XXX is three digits"),Vp=h().regex(new RegExp("\\d{3}"),"showcase_id must be a three digit string"),fs=p({type:E("default"),id:Hp,showcase_id:Vp.optional()}).strict(),jn=p({type:E("custom"),id:h(),showcase_id:h().optional(),showcase_overrides:Mp.optional(),category:Wd.optional()}).strict(),Wp=p({type:E("store"),id:h().optional()}).strict(),Yp=oe("type",[fs,jn,Wp]),Kp=p({title:h()}).strict(),Jp=p({metadata:Kp.optional(),sections:A(Yp)}).strict(),Xp=Jp.safeExtend({type:Md,id:h().min(1,{message:"id is required"})}).strict().superRefine((e,t)=>{const n=x(t);xp(e,n),Gp(e,n),Bp(e,n)}),hs=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:fr({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:Nt,categories:A(xd).refine(e=>new Set(e).size===e.length,{message:"categories must contain unique items"}).optional()}).strict(),Qp=fs.extend({id:h()}),ms=oe("type",[Qp,jn]),qp=p({metadata:hs,header:ms,footer:ms}).strict(),ef=p({id:h().min(1,{message:"id is required"}),assets:wn.array().optional(),configuration:qp,pages:A(Xp)}).strict(),Gt=2097152,xt=512e3;function Se(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 tf={menu:{type:O.NAVIGATION_MENU},logo:{type:O.LOGO}},nf={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 Es(e){switch(e){case xe.HEADER:return tf;default:return{}}}function gs(e){switch(e){case xe.HEADER:return nf;default:return{}}}function _s({validationType:e,sectionType:t}){switch(e){case tt.CONTENT:return Es(t);case tt.DESIGN:return gs(t);default:return{}}}const of=jn.extend({id:h().min(1,{message:"section id is required"})}),rf=p({metadata:hs,sections:A(of).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")}),sf=p({id:h().min(1,{message:"id is required"}),descriptor:rf}).strict(),af=oe("type",[Br,Vr,Fr,Dr,Wr,Hr,cp,lp,dp,up,Gr,xr,Zr,Mr]),Un=Y(h(),af),cf=oe("type",[cs,ts,rs,us,as,es,ns,is,os,Up,ss]),Fn=Y(h(),cf),uf=oe("type",[wp,fp,Ep,vp,Ip,pp,hp,Tp,mp,yp,Pp]),Mn=p({layoutId:h(),layoutIcon:Zd.optional(),selectedContentSettings:A(h()),selectedDesignSettings:A(uf)}).strict(),lf=h().regex(Yd,X.VALID_LANGUAGE_CODE()),Bt=Y(lf,Y(_,h()));function ys(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 Ss(e,t,n){Lr(e,t,n)}function df(e,t,n){if(e.type!==O.DECK||t.type!==O.DECK)return;const o=t.cards?.defaultCardContent?.settings,r=e.cards;if(!o||!Array.isArray(r))return;const s=new Set(Object.keys(o));r.forEach((i,a)=>{i.settings&&Object.keys(i.settings).forEach(c=>{s.has(c)||n.at(["cards",a,"settings",c]).addIssue("INVALID_DECK_CARD_SETTING",c)})})}function pf(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===O.SELECTBOX&&i.type===O.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===O.DECK&&df(r,i,s)})}function ff(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 hf(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 mf(e,t,n){e.layoutId&&((t||[]).some(o=>o.layoutId===e.layoutId)||n.at("layoutId").addIssue("SHOWCASE_LAYOUT",e.layoutId))}function Ef(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 Ts(e,t,n){for(const[o,r]of Object.entries(e)){const s=r;if(s.type===O.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===O.DECK){const i=s;i.cards?.defaultCardContent?.settings&&Ts(i.cards.defaultCardContent.settings,t,n.at([o,"cards","defaultCardContent","settings"]))}}}function gf(e,t,n){t>Gt&&n.at(z.basename(e)).addIssue("REQUIRED_SECTION_ASSET",Se(t),Se(Gt))}function _f(e,t){e>xt&&t.addIssue("REQUIRED_SERVER_SIZE",Se(e),Se(xt))}const yf=p({id:h(),type:bd,name:h(),content:Un,design:Fn,layout:A(Mn).optional(),showcase:A(Fp),translationsSettings:Bt.optional(),translationsShowcases:Bt.optional(),assets:wn.array().optional(),server:br,previewCount:he().optional()}).strict().superRefine((e,t)=>{const n=x(t),o=_s({validationType:tt.CONTENT,sectionType:e.type}),r=_s({validationType:tt.DESIGN,sectionType:e.type});ys(e.content,o,n.at("content")),ys(e.design,r,n.at("design")),Ts(e.content,e.design,n.at("content")),hf(e.design,n.at("design")),e.assets&&e.assets.forEach(i=>{gf(i.path,i.size,n.at("assets"))}),_f(e.server.size,n.at("server"));const s=e.assets?.map(i=>i.path)??[];Ss(e.content,s,n.at("content")),Ef(e.showcase,n.at("showcase")),e.showcase.forEach((i,a)=>{const c=n.at(["showcase",a]);Ss(i,s,c),pf(i,e.content,c),ff(i,e.design,c),mf(i,e.layout,c)})}),Sf=p({translations:Bt.optional()}).strict(),Tf=U(["products","category","product"]),Of=p({id:h(),sectionId:h(),assets:wn.array().optional(),content:Un.optional(),design:Fn.optional(),translationsSettings:Bt.optional(),layouts:Mn.array().optional()}).strict().superRefine((e,t)=>{const n=x(t);nt.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,nt.options.join(", ")),e.assets&&e.assets.forEach(o=>{o.size>Gt&&n.at(["assets",z.basename(o.path)]).addIssue("REQUIRED_SECTION_ASSET",Se(o.size),Se(Gt))})});p({id:h(),sectionId:nt,pageId:Tf,content:Un.optional(),design:Fn.optional(),layouts:Mn.array().optional()}).strict();const If=p({id:h(),sectionId:h(),layoutId:h(),server:br}).strict().superRefine((e,t)=>{const n=x(t);nt.safeParse(e.sectionId).success||n.at(["sectionId"]).addIssue("INVALID_STORE_SECTION_ID",e.sectionId,nt.options.join(", ")),e.server.size>xt&&n.at("server").addIssue("REQUIRED_SERVER_SIZE",Se(e.server.size),Se(xt))});function wf(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 vf(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 Cf(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&&Lr(e.content,r,o.at(["content"]))}function Os(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"),Cf(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 Rf(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 bf=p({version:h(),name:h(),shared:Sf.optional(),sections:A(yf),templates:A(ef),layouts:A(Of),slots:A(If),collections:A(sf),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]);wf(n.configuration.header,e.sections,r.at(["configuration","header"])),vf(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"?Os(c,e.sections,d):c.type==="store"&&Rf(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]);Os(r,e.sections,i,!0)})})});ye({customError:Rd});const f={error:e=>console.log(_i(e)),warn:e=>console.log(gi(e)),info:e=>console.log(ce(e))},Af="dist",Nf="dist/shared",me="dist/sections",Gn="dist/headers",xn="dist/footers",Te="dist/templates",Be="layouts",Is="preview",Q=`dist/${Be}`,rt="dist/collections",ws="dist/manifest.json",$f=[me,Gn,xn,Te,Q];function Zt(e){return!!e}function Ne(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}const Df="Resource name can only contain alphanumeric characters, dashes, and underscores";function Lf(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:Df}}function kf(e){return e===!0?!0:typeof e=="string"&&e.trim().length===0}function Pf(e){return z.parse(e).name}function zf(e){return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function Ht(){const e=await un(S(process.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}function jf(e){return e.includes(`
|
|
40
|
+
`)}function Uf(e,t,n){return e.split(`
|
|
41
41
|
`).map((o,r)=>r>=n?t+o:o).join(`
|
|
42
|
-
`)}function $e(e,t){const n=[];if(e instanceof Eo){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=
|
|
42
|
+
`)}function $e(e,t){const n=[];if(e instanceof Eo){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=jf(s.errorMessage)?Uf(s.errorMessage," ",1):s.errorMessage;n.push(` Error Message: ${i}`)}}const o=n.length>0?n.join(`
|
|
43
43
|
`):e?.message??"Unknown error";if(!t||t.length===0)return o;const r=n.length>0?`
|
|
44
|
-
`:" ";return`${t}${r}${o}`}function Zn(e,t){return Object.keys(e).reduce((n,o)=>{const r=e[o],s=t[o];return Ne(r)&&Ne(s)?n[o]=Zn(r,s):n[o]=r,n},{...t})}function $f({contentSettings:e,sectionType:t}){const n=us(t);return Zn(e,n)}function Df({designSettings:e,sectionType:t}){const n=ls(t);return Zn(e,n)}async function se(e){return(await import(mo(e).href+`?t=${Date.now()}`)).default}function Bn(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=Si(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function _s(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 Lf(e){if(e!==void 0)return{...e,color:de(e.color)}}function st(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function kf(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 Pf({style:e,color:t}){const n=Array.isArray(t)?t:[t,t];return{background:{type:kf(e),solid:{color:de(n.at(0))},gradient:{fromColor:de(n.at(0)),toColor:de(n.at(1))}}}}function zf(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(hi)}`)}}function jf(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(mi)}`)}}function Uf(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(Ei)}`)}}function Mf(e){const t=zf(e.appearance),n=jf(e.size),o=Uf(e.shape),r=Bn(e.font),s=de(e.color),i=e.visible;return st({appearance:t,size:n,style:o,font:r,color:s,visible:i})}function Ff(e){const t=de(e.color);return st({color:t})}function xf(e){if(e!==void 0)switch(e){case mt.COLOR:return"solid";case mt.GRADIENT:return"gradient";case mt.NONE:return"none";default:throw new Error(`Unknown image overlay type: ${e}. Right options: ${Object.keys(mt)}`)}}function Gf(e){const t=e.color,n=Array.isArray(t)?t:[t,t];return{overlay:{type:xf(e.overlay),solid:{color:de(n.at(0))},gradient:{fromColor:de(n.at(0)),toColor:de(n.at(1))}}}}function Zf(e){const t=Bn(e.font),n=de(e.color),o=_s(e.size),r=e.bold,s=e.italic,i=e.spacing,a=e.capitalization;return{font:t,color:n,size:o,frame:Lf(e.frame),bold:r,italic:s,spacing:i,capitalization:a}}function Bf(e){const t=e.value;return st({value:t})}function Hf(e){const t=Bn(e.font),n=de(e.color),o=_s(e.size),r=e.bold,s=e.italic;return st({font:t,color:n,size:o,bold:r,italic:s})}function Vf(e){const t=e.enabled;return st({enabled:t})}function Hn(e,t){if(t.defaults===void 0)return;let n={};switch(e){case Q.TEXT:{n=Hf(t.defaults);break}case Q.BUTTON:{n=Mf(t.defaults);break}case Q.IMAGE:{n=Gf(t.defaults);break}case Q.BACKGROUND:{n=Pf(t.defaults);break}case Q.COLOR_PICKER:{n=Ff(t.defaults);break}case Q.LOGO:{n=Zf(t.defaults);break}case Q.SELECTBOX:{n=Bf(t.defaults);break}case Q.TOGGLE:{n=Vf(t.defaults);break}case Q.DIVIDER:case Q.INFO:break;case Q.ACCORDION:return t.defaults;default:throw new Error(`Unknown design editor type: ${e}`)}return n}function ys(e){const t={};return Object.keys(e).forEach(n=>{const o=e[n],r=o.type;if(r===Q.ACCORDION){const i=Object.fromEntries(Object.entries(o.items).map(([a,c])=>[a,{...c,editors:ys(c.editors)}]));t[n]={...o,items:i};return}const s=Hn(r,o);s&&o.defaults?t[n]={...o,defaults:s}:t[n]=o}),t}function Wf(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],r=o.type;if(r===Q.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 s=Hn(r,{defaults:o});s!==void 0?t[n]={...o,...s,type:o.type}:t[n]=o}),t}function Yf(e,t){if(!t)return;const n=e[t];return n===void 0?{en:t}:n}function Kf(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 Jf(e){return e.every(t=>t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")}function Be(e,t){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return Jf(e)?e:e.map(r=>Be(r,t));const n=e,o={};for(const r in n){const s=n[r];typeof s=="string"&&s.startsWith("$")?o[r]=Yf(t,s):typeof s=="object"&&s!==null?o[r]=Be(s,t):o[r]=s}return o}async function it(e){return e?Kf(e):{}}async function Xf(e,t=he){const n=S(process.cwd(),`${t}/${e}/js/settings/translations.mjs`);return await se(n)}async function Vt(e,t=he){const n=S(process.cwd(),`${t}/${e}/js/showcases/translations.mjs`);return await se(n)}async function Qf(e,t){const n=S(process.cwd(),`${X}/${t}/${e}/js/settings/translations.mjs`);if(H(n))return await se(n)}async function Wn(e,t,n){const o=n?$f({contentSettings:e,sectionType:n}):e;return Be(o,t)}async function qf(e,t=he){try{const n=S(M.cwd(),`${t}/${e}/js/settings/content.mjs`),o=await se(n);return ke(o)}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function Yn(e,t,n){const o=n?Df({designSettings:e,sectionType:n}):e,r=ys(o);return Be(r,t)}async function eh(e,t=he){try{const n=S(M.cwd(),`${t}/${e}/js/settings/design.mjs`),o=await se(n);return ke(o)}catch(n){const o=n;throw new Error(`Design settings is invalid or undefined. Error ${o.stack}`)}}async function th(e,t){return Promise.all(e.map(async n=>{const o=n.design?Vn(n.design):void 0,r={...n,design:o??n.design};return Be(r,t)}))}async function nh(e,t=he){try{const n=await I("*.mjs",{cwd:S(M.cwd(),`${t}/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(n.map(async o=>{const r=S(M.cwd(),`${t}/${e}/js/showcases/${o}`);return await se(r)}))}catch(n){throw new Error(`Showcases is invalid or undefined. Error ${n}`)}}async function Ss(e){return e?.map(t=>({...t,selectedDesignSettings:Wf(t.selectedDesignSettings)??t.selectedDesignSettings}))??[]}async function oh(e,t=he){try{const n=S(M.cwd(),`${t}/${e}/js/settings/layout.mjs`);return H(n)?await se(n):[]}catch{throw new Error(`Layout descriptor for section [${e}] is either invalid or undefined`)}}function rh(e){let t={};const n=S(M.cwd(),`${Es}/shared/analytics.json`);if(!H(n))return 0;try{const o=on(n,"utf-8");t=JSON.parse(o)}catch(o){console.warn("Error processing analytics.json file",o)}return t[e]||0}const He={Server:0,Client:1,SectionAsset:4,PageTemplateDescriptor:6,TemplateAsset:7,SharedTranslation:13},Kn="https://blockbuster.ecwid.com",sh="/api/v1/custom-apps/resources/sections/upload",ih="/api/v1/custom-apps/resources/templates/upload",ah="/api/v1/custom-apps/manifests/sections",ch="/api/v1/custom-apps/manifests/templates",uh=5,lh=3,dh=[C.Server,C.Client,C.ClientChunks,C.ClientAsset,C.Asset],ph=[C.LayoutClient,C.LayoutAsset],fh=[C.SlotServer,C.SlotClient,C.SlotClientChunks,C.SlotClientAsset],hh=[C.Dependency,C.TemplateAsset,C.SourceCode,C.CollectionAsset],Ve={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.`},Ts={catalog:"products",category:"category",product:"product"},Os=e=>Ts[e],Is=e=>e in Ts;function mh(e){return e.replace(/\\/g,"/")}function Eh(e){return e.replace(/^dist\/layouts\//,"").replace(/^layouts\//,"")}function Wt(e){return Eh(mh(e))}function gh(e){const t=Wt(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(!Is(n))throw new Error(`Layout cannot be placed in a non-storefront section: ${n}`);const r=Os(n);return{id:o,sectionId:n,pageId:r}}async function _h(e){return Promise.all(e.map(async t=>{const n=t.sectionId,o=Os(n),r=await it(t.translationsSettings),s=await Wn(t.content??{},r),i=await Yn(t.design??{},r),a=await Ss(t.layouts);return{id:t.id,sectionId:n,pageId:o,contentEditors:s,designEditors:i,layouts:a}}))}function We(e,t,...n){if(!e||!t)throw new Error(`Cannot build layout path. Invalid parameters - sectionId: "${e}", layoutId: "${t}"`);return`${X}/${e}/${t}/${n.join("/")}`}const at=(e=ge.SECTION)=>x[e].dist,ct={[C.Server]:{type:"server_js_compressed",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,sectionType:t})=>`${at(t)}/${e}/js/main/server/`},[C.Client]:{type:"client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${at(t)}/${e}/js/main/client/`},[C.ClientChunks]:{type:"client_js_chunks",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${at(t)}/${e}/js/main/client/chunks/`,fileName:"*"},[C.ClientAsset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${at(t)}/${e}/js/main/client/assets/`},[C.Asset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${at(t)}/${e}/assets/`},[C.TemplateAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${Se}/assets/`},[C.Dependency]:{type:"dependencies",fileName:"package.json",isSingleton:!0,toPath:()=>{}},[C.SourceCode]:{type:"source_code",fileName:"source-code.zip",isSingleton:!0,toPath:()=>{}},[C.LayoutClient]:{type:"layout_client_js",fileName:"index.mjs",isSingleton:!0,toPath:({sectionId:e,layoutId:t})=>We(e,t,"")},[C.LayoutAsset]:{type:"layout_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t})=>We(e,t,"assets/")},[C.SlotServer]:{type:"slot_server_js",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,layoutId:t,slotId:n})=>We(e,t,"slots",n,"js/main/server/")},[C.SlotClient]:{type:"slot_client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>We(e,t,"slots",n,"js/main/client/")},[C.SlotClientChunks]:{type:"slot_client_js_chunks",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>We(e,t,"slots",n,"js/main/client/chunks/")},[C.SlotClientAsset]:{type:"slot_client_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>We(e,t,"slots",n,"js/main/client/assets/")},[C.CollectionAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${rt}/assets/`}};function yh(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 un(e),n=JSON.parse(t.toString());if(yh(n))return n;throw new Error(`Package file located at path: ${e} does not contain a version field`)}const Sh={layout:e=>e.layoutId,showcase:e=>e.showcaseId,templates:e=>{const t=e.id;return t?.includes("_")?t.substring(t.indexOf("_")+1):t}};function Th(e,t){const n=Sh[e];return n?n(t):t.id}const Oh=new Set(["content","design"]);function Yt(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"&&Ne(e)){const i=e[r],a=Array.isArray(i)?i[s]:void 0;if(Ne(a)){const c=Th(r,a);return o.push(`${r}[${c||s}]`),Yt(a,t,n+2,o)}}if(typeof r=="string"&&typeof s=="string"&&Oh.has(r)){o.push(`${r}[${s}]`);const i=Ne(e)&&!Array.isArray(e)?e[r]:void 0,a=Ne(i)&&!Array.isArray(i)?i[s]:void 0;return Yt(a,t,n+2,o)}return o.push(r),Yt(Ne(e)?e[r]:void 0,t,n+1,o)}function Ih(e){const t=e.errors.map(o=>Yt(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 wh(e){const t=Sf.safeParse(e);return{manifest:e,errors:t.success?[]:t.error.issues}}const vh=`Build successful:
|
|
44
|
+
`:" ";return`${t}${r}${o}`}function Bn(e,t){return Object.keys(e).reduce((n,o)=>{const r=e[o],s=t[o];return Ne(r)&&Ne(s)?n[o]=Bn(r,s):n[o]=r,n},{...t})}function Ff({contentSettings:e,sectionType:t}){const n=Es(t);return Bn(e,n)}function Mf({designSettings:e,sectionType:t}){const n=gs(t);return Bn(e,n)}async function re(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=bi(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function vs(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 Gf(e){if(e!==void 0)return{...e,color:de(e.color)}}function st(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function xf(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 Bf({style:e,color:t}){const n=Array.isArray(t)?t:[t,t];return{background:{type:xf(e),solid:{color:de(n.at(0))},gradient:{fromColor:de(n.at(0)),toColor:de(n.at(1))}}}}function Zf(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(Oi)}`)}}function Hf(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(Ii)}`)}}function Vf(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(wi)}`)}}function Wf(e){const t=Zf(e.appearance),n=Hf(e.size),o=Vf(e.shape),r=Zn(e.font),s=de(e.color),i=e.visible;return st({appearance:t,size:n,style:o,font:r,color:s,visible:i})}function Yf(e){const t=de(e.color);return st({color:t})}function Kf(e){if(e!==void 0)switch(e){case mt.COLOR:return"solid";case mt.GRADIENT:return"gradient";case mt.NONE:return"none";default:throw new Error(`Unknown image overlay type: ${e}. Right options: ${Object.keys(mt)}`)}}function Jf(e){const t=e.color,n=Array.isArray(t)?t:[t,t];return{overlay:{type:Kf(e.overlay),solid:{color:de(n.at(0))},gradient:{fromColor:de(n.at(0)),toColor:de(n.at(1))}}}}function Xf(e){const t=Zn(e.font),n=de(e.color),o=vs(e.size),r=e.bold,s=e.italic,i=e.spacing,a=e.capitalization;return{font:t,color:n,size:o,frame:Gf(e.frame),bold:r,italic:s,spacing:i,capitalization:a}}function Qf(e){const t=e.value;return st({value:t})}function qf(e){const t=Zn(e.font),n=de(e.color),o=vs(e.size),r=e.bold,s=e.italic;return st({font:t,color:n,size:o,bold:r,italic:s})}function eh(e){const t=e.enabled;return st({enabled:t})}function Hn(e,t){if(t.defaults===void 0)return;let n={};switch(e){case q.TEXT:{n=qf(t.defaults);break}case q.BUTTON:{n=Wf(t.defaults);break}case q.IMAGE:{n=Jf(t.defaults);break}case q.BACKGROUND:{n=Bf(t.defaults);break}case q.COLOR_PICKER:{n=Yf(t.defaults);break}case q.LOGO:{n=Xf(t.defaults);break}case q.SELECTBOX:{n=Qf(t.defaults);break}case q.TOGGLE:{n=eh(t.defaults);break}case q.DIVIDER:case q.INFO:break;case q.ACCORDION:return t.defaults;default:throw new Error(`Unknown design editor type: ${e}`)}return n}function Cs(e){const t={};return Object.keys(e).forEach(n=>{const o=e[n],r=o.type;if(r===q.ACCORDION){const i=Object.fromEntries(Object.entries(o.items).map(([a,c])=>[a,{...c,editors:Cs(c.editors)}]));t[n]={...o,items:i};return}const s=Hn(r,o);s&&o.defaults?t[n]={...o,defaults:s}:t[n]=o}),t}function th(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],r=o.type;if(r===q.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 s=Hn(r,{defaults:o});s!==void 0?t[n]={...o,...s,type:o.type}:t[n]=o}),t}function nh(e,t){if(!t)return;const n=e[t];return n===void 0?{en:t}:n}function oh(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 rh(e){return e.every(t=>t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")}function Ze(e,t){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return rh(e)?e:e.map(r=>Ze(r,t));const n=e,o={};for(const r in n){const s=n[r];typeof s=="string"&&s.startsWith("$")?o[r]=nh(t,s):typeof s=="object"&&s!==null?o[r]=Ze(s,t):o[r]=s}return o}async function it(e){return e?oh(e):{}}async function sh(e,t=me){const n=S(process.cwd(),`${t}/${e}/js/settings/translations.mjs`);return await re(n)}async function Vt(e,t=me){const n=S(process.cwd(),`${t}/${e}/js/showcases/translations.mjs`);return await re(n)}async function ih(e,t){const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/translations.mjs`);if(H(n))return await re(n)}async function Wn(e,t,n){const o=n?Ff({contentSettings:e,sectionType:n}):e;return Ze(o,t)}async function ah(e,t=me){try{const n=S(F.cwd(),`${t}/${e}/js/settings/content.mjs`),o=await re(n);return ke(o)}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function Yn(e,t,n){const o=n?Mf({designSettings:e,sectionType:n}):e,r=Cs(o);return Ze(r,t)}async function ch(e,t=me){try{const n=S(F.cwd(),`${t}/${e}/js/settings/design.mjs`),o=await re(n);return ke(o)}catch(n){const o=n;throw new Error(`Design settings is invalid or undefined. Error ${o.stack}`)}}async function uh(e,t){return Promise.all(e.map(async n=>{const o=n.design?Vn(n.design):void 0,r={...n,design:o??n.design};return Ze(r,t)}))}async function lh(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 r=S(F.cwd(),`${t}/${e}/js/showcases/${o}`);return await re(r)}))}catch(n){throw new Error(`Showcases is invalid or undefined. Error ${n}`)}}async function Rs(e){return e?.map(t=>({...t,selectedDesignSettings:th(t.selectedDesignSettings)??t.selectedDesignSettings}))??[]}async function dh(e,t=me){try{const n=S(F.cwd(),`${t}/${e}/js/settings/layout.mjs`);return H(n)?await re(n):[]}catch{throw new Error(`Layout descriptor for section [${e}] is either invalid or undefined`)}}function ph(e){let t={};const n=S(F.cwd(),`${Is}/shared/analytics.json`);if(!H(n))return 0;try{const o=on(n,"utf-8");t=JSON.parse(o)}catch(o){console.warn("Error processing analytics.json file",o)}return t[e]||0}const He={Server:0,Client:1,SectionAsset:4,PageTemplateDescriptor:6,TemplateAsset:7,SharedTranslation:13},Kn="https://blockbuster.ecwid.com",fh="/api/v1/custom-apps/resources/sections/upload",hh="/api/v1/custom-apps/resources/templates/upload",mh="/api/v1/custom-apps/manifests/sections",Eh="/api/v1/custom-apps/manifests/templates",gh=5,_h=3,yh=[R.Server,R.Client,R.ClientChunks,R.ClientAsset,R.Asset],Sh=[R.LayoutClient,R.LayoutAsset],Th=[R.SlotServer,R.SlotClient,R.SlotClientChunks,R.SlotClientAsset],Oh=[R.Dependency,R.TemplateAsset,R.SourceCode,R.CollectionAsset],Ve={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.`},bs={catalog:"products",category:"category",product:"product"},As=e=>bs[e],Ns=e=>e in bs;function Ih(e){return e.replace(/\\/g,"/")}function wh(e){return e.replace(/^dist\/layouts\//,"").replace(/^layouts\//,"")}function Wt(e){return wh(Ih(e))}function vh(e){const t=Wt(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(!Ns(n))throw new Error(`Layout cannot be placed in a non-storefront section: ${n}`);const r=As(n);return{id:o,sectionId:n,pageId:r}}async function Ch(e){return Promise.all(e.map(async t=>{const n=t.sectionId,o=As(n),r=await it(t.translationsSettings),s=await Wn(t.content??{},r),i=await Yn(t.design??{},r),a=await Rs(t.layouts);return{id:t.id,sectionId:n,pageId:o,contentEditors:s,designEditors:i,layouts:a}}))}function We(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 at=(e=_e.SECTION)=>G[e].dist,ct={[R.Server]:{type:"server_js_compressed",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,sectionType:t})=>`${at(t)}/${e}/js/main/server/`},[R.Client]:{type:"client_js",fileName:"client.js",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${at(t)}/${e}/js/main/client/`},[R.ClientChunks]:{type:"client_js_chunks",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${at(t)}/${e}/js/main/client/chunks/`,fileName:"*"},[R.ClientAsset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${at(t)}/${e}/js/main/client/assets/`},[R.Asset]:{type:"assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,sectionType:t})=>`${at(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})=>We(e,t,"")},[R.LayoutAsset]:{type:"layout_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t})=>We(e,t,"assets/")},[R.SlotServer]:{type:"slot_server_js",fileName:"server.js.gz",isSingleton:!0,toPath:({sectionId:e,layoutId:t,slotId:n})=>We(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})=>We(e,t,"slots",n,"js/main/client/")},[R.SlotClientChunks]:{type:"slot_client_js_chunks",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>We(e,t,"slots",n,"js/main/client/chunks/")},[R.SlotClientAsset]:{type:"slot_client_assets",fileName:"*",isSingleton:!1,toPath:({sectionId:e,layoutId:t,slotId:n})=>We(e,t,"slots",n,"js/main/client/assets/")},[R.CollectionAsset]:{type:"template_assets",fileName:"*",isSingleton:!1,toPath:()=>`${rt}/assets/`}};function Rh(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 un(e),n=JSON.parse(t.toString());if(Rh(n))return n;throw new Error(`Package file located at path: ${e} does not contain a version field`)}const bh={layout:e=>e.layoutId,showcase:e=>e.showcaseId,templates:e=>{const t=e.id;return t?.includes("_")?t.substring(t.indexOf("_")+1):t}};function Ah(e,t){const n=bh[e];return n?n(t):t.id}const Nh=new Set(["content","design"]);function Yt(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"&&Ne(e)){const i=e[r],a=Array.isArray(i)?i[s]:void 0;if(Ne(a)){const c=Ah(r,a);return o.push(`${r}[${c||s}]`),Yt(a,t,n+2,o)}}if(typeof r=="string"&&typeof s=="string"&&Nh.has(r)){o.push(`${r}[${s}]`);const i=Ne(e)&&!Array.isArray(e)?e[r]:void 0,a=Ne(i)&&!Array.isArray(i)?i[s]:void 0;return Yt(a,t,n+2,o)}return o.push(r),Yt(Ne(e)?e[r]:void 0,t,n+1,o)}function $h(e){const t=e.errors.map(o=>Yt(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 Dh(e){const t=bf.safeParse(e);return{manifest:e,errors:t.success?[]:t.error.issues}}const Lh=`Build successful:
|
|
45
45
|
For preview run: npx @lightspeed/crane@latest preview
|
|
46
|
-
For deploy run: npx @lightspeed/crane@latest deploy`;function
|
|
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
|
|
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
|
|
46
|
+
For deploy run: npx @lightspeed/crane@latest deploy`;function kh(e,t){if(e.errors.length===0){f.info(Lh);return}f.error("Invalid configuration detected:"),$h(e),t||process.exit(1)}const $s={"process.env":{NODE_ENV:"production"}},Ph=[...go,...go.map(e=>`node:${e}`)],zh=[/@vue\/compiler-dom/,/@vue\/runtime-dom/,/@vue\/server-renderer/,/@vue\/compiler-ssr/,/@vue\/shared/],Ds=e=>({pluginType:te.Server,define:$s,ssr:!0,ssrOptions:{noExternal:!0},entryFileNames:"server.js",externalOption:[...Ph,...zh],inlineDynamicImports:!0,...e,outDir:e.outDir}),Ls=e=>({pluginType:te.Client,define:$s,ssr:!1,entryFileNames:"client.js",assetFileNames:"assets/[name].[ext]",chunkFileNames:"chunks/[name].js",inlineDynamicImports:!1,...e,outDir:e.outDir}),Ye=e=>({pluginType:te.Misc,ssr:!1,...e,entryFileNames:e.entryFileNames,outDir:e.outDir}),jh=e=>({pluginType:te.Layout,ssr:!1,entryFileNames:"index.mjs",...e,outDir:e.outDir}),Kt=e=>({pluginType:te.Asset,ssr:!1,assetFileNames:"[name].[ext]",...e,outDir:e.outDir});let Jt=!1;function Uh(e){Jt=e}function Xn(){return Jt}const ks=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Fh=80,Mh="\x1B[?25l",Gh="\x1B[?25h",xh="\x1B[2K\r",Bh=44;let Zh=class{frameIndex=0;timer=null;realWrite=null;buffer=[];start(){Jt||(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(Mh),this.render(),this.timer=setInterval(()=>this.render(),Fh))}render(){if(!this.realWrite)return;const t=" Build is in progress...".padEnd(Bh-1," "),n=ce(ks[this.frameIndex]+t);this.realWrite(`\r${n}`),this.frameIndex=(this.frameIndex+1)%ks.length}stop(){if(!Jt&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.realWrite)){process.stdout.write=this.realWrite,this.realWrite(`${xh}${Gh}`);for(const t of this.buffer)this.realWrite(t);this.buffer=[],this.realWrite=null}}};const Ps=new Zh,Hh=()=>Ai({ext:".gz",algorithm:"gzip",verbose:Xn()}),Vh="/* EXTERNAL_IMPORTS_START */",Wh="/* EXTERNAL_IMPORTS_END */",Yh=()=>({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=Vh+i+Wh,c=o.code.replace(r,"");o.code=a+c}}}}}),Kh=()=>({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})}}),Jh=()=>{const e=process.env.npm_lifecycle_event;return Di({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:()=>Ni(),tsconfigPaths:()=>$i(),checker:()=>Jh()};class nn{constructor(t){this.bits=t instanceof nn?t.bits.slice():[]}add(t){this.bits[t>>5]|=1<<(t&31)}has(t){return!!(this.bits[t>>5]&1<<(t&31))}}class lt{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 lt(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 lt(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 Xh(){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 Qh=Xh();class qh{constructor(t){this.version=3,this.file=t.file,this.sources=t.sources,this.sourcesContent=t.sourcesContent,this.names=t.names,this.mappings=Li(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,"+Qh(this.toString())}}function em(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 nm=Object.prototype.toString;function om(e){return nm.call(e)==="[object Object]"}function zs(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 rm=/\w/;class sm{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
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"?
|
|
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"?rm.test(o[i])?c||(this.rawSegments.push(u),c=!0):(this.rawSegments.push(u),c=!1):this.rawSegments.push(u)}o[i]===`
|
|
51
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
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
|
-
`,Ke={insertLeft:!1,insertRight:!1,storeName:!1};class ao{constructor(t,n={}){const o=new lt(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 nn},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 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 nn(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
|
|
53
|
+
`,Ke={insertLeft:!1,insertRight:!1,storeName:!1};class ao{constructor(t,n={}){const o=new lt(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 nn},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 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 nn(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 sm(t.hires),s=zs(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 qh(this.generateDecodedMap(t))}_ensureindentStr(){this.indentStr===void 0&&(this.indentStr=em(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(om(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
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 Ke.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),Ke.insertLeft=!0),this.appendLeft(t,n)}insertRight(t,n){return Ke.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),Ke.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&&(Ke.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),Ke.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 lt(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(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="",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=
|
|
56
|
-
${
|
|
57
|
-
`,qh=(e,t)=>{const n=e.split("?")[0],o=ai(n);return(o==="server.ts"||o==="client.ts")&&!t.includes($s)},Ds=()=>{let e=!1;return{name:"static-translation-plugin",enforce:"pre",apply:"build",buildStart(){e=H(Ns)},transform(t,n){if(!e||!qh(n,t))return null;const o=n.split("?")[0],r=uo(o),s=pi(lo(r,Ns)),i=Qh(s),a=new ao(t);return a.prepend(i),{code:a.toString()}}}},Ls={[te.Server]:()=>[pe.vue(),pe.tsconfigPaths(),Fh(),jh(),Ds()],[te.Client]:()=>[pe.vue(),pe.tsconfigPaths(),_o({vue:"EcVue"}),Ds()],[te.Misc]:()=>[pe.tsconfigPaths()],[te.Layout]:()=>[pe.vue(),pe.tsconfigPaths(),_o({vue:["EcExternals","Vue"]})],[te.Asset]:()=>[xh()],[te.SharedFiles]:()=>[pe.tsconfigPaths()]},ks={[N.Server]:vs({outDir:({name:e,sectionType:t})=>`./${x[t].dist}/${e}/js/main/server`}),[N.Client]:Cs({outDir:({name:e,sectionType:t})=>`./${x[t].dist}/${e}/js/main/client`}),[N.SectionSetting]:Ye({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${x[t].dist}/${e}/js/settings`}),[N.SectionShowcase]:Ye({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${x[t].dist}/${e}/js/showcases`}),[N.SectionAsset]:Kt({outDir:({name:e,sectionType:t})=>`./${x[t].dist}/${e}/assets`}),[N.TemplateDescriptor]:Ye({entryFileNames:"[name].mjs",outDir:()=>`./${Se}/js`}),[N.PageTemplateDescriptor]:Ye({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${Se}/${e}`}),[N.TemplateAsset]:Kt({outDir:()=>`./${Se}/assets`}),[N.Layout]:Ah({outDir:({name:e,sectionId:t})=>`./${X}/${t}/${e}`}),[N.LayoutSettings]:Ye({entryFileNames:"[name].mjs",outDir:({name:e,sectionId:t})=>`./${X}/${t}/${e}/js/settings`}),[N.LayoutAsset]:Kt({outDir:({name:e,sectionId:t})=>`./${X}/${t}/${e}/assets`}),[N.SlotServer]:vs({outDir:({name:e,layoutId:t,sectionId:n})=>`./${X}/${n}/${t}/slots/${e}/js/main/server`}),[N.SlotClient]:Cs({outDir:({name:e,layoutId:t,sectionId:n})=>`./${X}/${n}/${t}/slots/${e}/js/main/client`}),[N.CollectionDescriptor]:Ye({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${rt}/${e}`}),[N.CollectionAsset]:Kt({outDir:()=>`./${rt}/assets`}),[N.SharedTranslation]:{pluginType:te.SharedFiles,ssr:!1,inlineDynamicImports:!0,entryFileNames:"translation.mjs",outDir:()=>"./dist/shared"}};function em(e){switch(typeof e){case"string":return[S(process.cwd(),e)];case"object":return e.map(t=>S(process.cwd(),t));default:return[]}}function Ps({name:e,entryPoints:t,configType:n,layoutId:o,sectionId:r,sectionType:s=ge.SECTION}){const i=ks[n],a=i.define,c=i.ssrOptions,u=i.entryFileNames,d=i.chunkFileNames,m=i.assetFileNames,y=i.inlineDynamicImports,T=i.externalOption;return{logLevel:Xn()?void 0:"silent",plugins:Ls[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:T,preserveEntrySignatures:"strict",input:em(t),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:y,entryFileNames:u,chunkFileNames:d,assetFileNames:m}}},assetsInclude:["**/*.json"]}}const tm=Object.values(x).map(e=>e.source).join("|");function zs(e,t,n){if(!e)return`${t}.mjs`;const o=lo(process.cwd(),e).replace(/\\/g,"/").match(`^(${tm})/([^/]+)/${n}/([^/.]+)`);return o?`${o[1]}/${o[2]}/js/${n}/${o[3]}.mjs`:`${t}.mjs`}function js(e,t){const n=ks[N.SectionSetting];return{logLevel:Xn()?void 0:"silent",plugins:Ls[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 nm(e){return js(e,t=>zs(t.facadeModuleId??void 0,t.name,"settings"))}function om(e){return js(e,t=>zs(t.facadeModuleId??void 0,t.name,"showcases"))}async function rm(){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}=gh(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 sm(e){await ie({entryPoints:[e.clientEntrypoint],configType:N.Layout,name:e.name,sectionId:e.sectionId}),await Promise.all([ie({entryPoints:e.settingsEntryPoints,configType:N.LayoutSettings,name:e.name,sectionId:e.sectionId}),ie({entryPoints:e.assetsEntrypoints,configType:N.LayoutAsset,name:e.name,sectionId:e.sectionId})])}async function im(e){e===void 0||e.length===0||await Promise.all(e.map(t=>sm(t)))}async function am(e){const t=e.flatMap(o=>o.settingsEntryPoints),n=e.flatMap(o=>o.showcaseEntryPoints);t.length>0&&await Ee({configFile:!1,...ht(nm(t))}),n.length>0&&await Ee({configFile:!1,...ht(om(n))})}async function cm(e){await Promise.all([Ee({configFile:!1,...ht(Ps({name:e.name,entryPoints:e.serverEntrypoint,configType:He.Server,sectionType:e.type}))}),ie({entryPoints:e.clientEntrypoint,configType:He.Client,name:e.name,sectionType:e.type}),ie({entryPoints:e.assetEntryPoints,configType:He.SectionAsset,name:e.name,sectionType:e.type})])}async function um(){const e=S(process.cwd(),"shared/translation.ts");H(e)&&await ie({entryPoints:["shared/translation.ts"],configType:He.SharedTranslation})}async function Us(e){await Promise.all([am(e),...e.map(cm)])}function lm(e){const t=Wt(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(!Is(n))throw new Error(`Slot cannot be placed in a non-storefront section: ${n}`);return{id:r,sectionId:n,layoutId:o}}async function dm(e,t){return Promise.all(e.map(async n=>{const o=t.find(a=>a.id===n.layoutId&&a.sectionId===n.sectionId),r=await it(o?.translationsSettings),s=await Wn(o?.content??{},r),i=await Yn(o?.design??{},r);return{id:n.id,sectionId:n.sectionId,layoutId:n.layoutId,contentEditors:s,designEditors:i}}))}async function pm(){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}=lm(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 fm(e){const t={name:e.id,layoutId:e.layoutId,sectionId:e.sectionId};await Promise.all([ie({entryPoints:[e.serverEntrypoint],configType:N.SlotServer,...t}),ie({entryPoints:[e.clientEntrypoint],configType:N.SlotClient,...t})])}async function hm(e){e?.length&&await Promise.all(e.map(fm))}async function mm(e){return(await I(`**/${e}/pages/*.{js,ts}`,{ignore:["node_modules/**","dist/**"]})).filter(t=>{const n=po(t).name.toLowerCase();return!Object.values(Or).includes(n)})}async function Em(){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(an),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 mm(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 gm(){const e=await I("./templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]}),t=await I("./templates/assets/*",{ignore:["node_modules/**","dist/**"]});return{pageTemplates:await Em(),templates:e,assets:t}}async function _m({templateBuildConfig:e}){await Promise.all([ie({entryPoints:e.assets,configType:He.TemplateAsset}),...e.pageTemplates?.map(async t=>{const n=[t.configurationEntrypoint,t.homeEntrypoint,t.categoryEntrypoint,t.catalogEntrypoint,t.productEntrypoint,...t.customEntrypoint??[]].filter(Bt);if(n.length===0)throw new Error("No entry points provided for page template");await ie({entryPoints:n,configType:He.PageTemplateDescriptor,name:t.name})})||[]])}async function ym(){const e=await gm();await _m({templateBuildConfig:e})}async function Sm(){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(an),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 Tm(){const e=await Sm();e.length!==0&&await Promise.all(e.flatMap(t=>[ie({entryPoints:t.assetsEntrypoints,configType:N.CollectionAsset,name:t.name}),ie({entryPoints:t.configurationEntrypoint?[t.configurationEntrypoint]:[],configType:N.CollectionDescriptor,name:t.name})]))}function Ms(e){return{name:e.name,type:e.type,serverEntrypoint:e.serverEntrypoint,clientEntrypoint:[e.clientEntrypoint].filter(Bt).flat(),settingsEntryPoints:[e.contentSettingsEntrypoint,e.designSettingsEntrypoint,e.layoutSettingsEntrypoint,e.settingsTranslationsEntrypoint].filter(Bt),showcaseEntryPoints:[...e.showcasesEntrypoints??[],e.showcasesTranslationsEntrypoint].filter(Bt),assetEntryPoints:e.assetsEntrypoints??[]}}function Fs(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 Om(e,t=he){const n=S(process.cwd(),`${t}/${e}/js/main/server/server.js.gz`),o=yo(So.gunzip),r=await b.promises.readFile(n);return{size:(await o(r)).length}}async function Im(e,t=he){try{const n=S(process.cwd(),`${t}/${e}/assets/`);return(await I("*",{cwd:n})).map(o=>{const r=S(n,o);return{path:o,size:Xe(r).size}})}catch{throw new Error(`Asset files for section [${e}] is either invalid or undefined`)}}async function Qn(e,t){const n=await Xf(e,x[t].dist),o=await Vt(e,x[t].dist),r=await qf(e,x[t].dist),s=await eh(e,x[t].dist),i=await nh(e,x[t].dist),a=await oh(e,x[t].dist),c=Fs(a),u=await Im(e,x[t].dist),d=await Om(e,x[t].dist),m=rh(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 wm(){const e=await I("*/",{cwd:S(process.cwd(),`${he}/`)}),t=await I("*/",{cwd:S(process.cwd(),`${xn}/`)}),n=await I("*/",{cwd:S(process.cwd(),`${Gn}/`)});return Promise.all([...e.map(async o=>Qn(o,Ge.SECTION)),...t.map(async o=>Qn(o,Ge.HEADER)),...n.map(async o=>Qn(o,Ge.FOOTER))])}async function vm(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:Xe(o).size}})}catch{throw new Error("Asset files for layouts are either invalid or undefined")}}async function Cm(e){const t=Wt(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([bm(o,n),Am(o,n),Qf(o,n),vm(e),Nm(o,n)]);return{id:o,sectionId:n,content:r,design:s,translationsSettings:i,assets:a,layouts:c}}async function Rm(){const e=`${X}/{product,catalog,category}/*`,t=await I(e,{ignore:["node_modules/**"]});return Promise.all(t.map(Cm))}async function bm(e,t){try{const n=S(process.cwd(),`${X}/${t}/${e}/js/settings/content.mjs`),o=await se(n);return ke(o)}catch(n){throw new Error(`Content descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function Am(e,t){try{const n=S(process.cwd(),`${X}/${t}/${e}/js/settings/design.mjs`),o=await se(n);return ke(o)}catch(n){throw new Error(`Design descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function Nm(e,t){try{const n=S(process.cwd(),`${X}/${t}/${e}/js/settings/layout.mjs`);if(!b.existsSync(n))return[];const o=await se(n);return Fs(o)}catch(n){throw new Error(`Layout settings descriptor for layout [${e}] in section [${t}] is either invalid or undefined: ${n}`)}}async function $m(e,t,n){const o=S(process.cwd(),`${X}/${n}/${t}/slots/${e}/js/main/server/server.js.gz`),r=yo(So.gunzip),s=await b.promises.readFile(o);return{size:(await r(s)).length}}async function Dm(e){const t=Wt(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 $m(r,o,n);return{id:r,sectionId:n,layoutId:o,server:s}}async function Lm(){const e=`${X}/{product,catalog,category}/*/slots/*`,t=await I(e,{ignore:["node_modules/**"]});return await Promise.all(t.map(Dm))}async function km(){try{const e=S(process.cwd(),`${Se}/assets/`);return(await I("*",{cwd:e})).map(t=>{const n=S(e,t);return{path:t,size:Xe(n).size}})}catch{throw new Error("Asset files for templates are either invalid or undefined")}}function Pm(e){return e in be?be[e]:be.CUSTOM}async function zm(e){const t=await I(`${Se}/${e}/*.mjs`,{ignore:[`${Se}/${e}/configuration*.mjs`]});return Promise.all(t.map(async n=>{const{sections:o,metadata:r}=await qn(n),s=Rf(n);return{type:Pm(s.toUpperCase()),id:s,metadata:r,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 jm(e){const t=await I(`${Se}/**/configuration*.mjs`,{});return Promise.all(t.map(async n=>{const o=j.basename(j.dirname(n));return{id:`${e}_${o}`,assets:await km(),configuration:await qn(n),pages:await zm(o)}}))}async function Um(e){return await jm(e)}async function Mm(){const e=S(process.cwd(),`${Of}/translation.mjs`);return await se(e)}async function Fm(){return{translations:await Mm()}}async function xm(e){const t=await I(`${rt}/*/configuration*.mjs`,{ignore:["node_modules/**",`${rt}/assets/**`]});return Promise.all(t.map(async n=>{const o=j.basename(j.dirname(n)),r=await qn(n);return{id:`${e}_${o}`,descriptor:r}}))}async function Gm(){const e=await Ht(),[t,n,o,r,s,i,a]=await Promise.all([Jn(),Fm(),wm(),Rm(),Lm(),Um(e.appClientId),xm(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 eo(e){return H(`${xn}/${e}`)?ge.HEADER:H(`${Gn}/${e}`)?ge.FOOTER:ge.SECTION}async function to(e,t){const n=e.design?Vn(e.design):void 0,o={...e,design:n??e.design},r=await it(t);return Be(o,r)}function no(e){return e.type==="custom"&&e.id!==void 0&&e.showcase_overrides!==void 0}async function xs(e){if(no(e)){const t=await Vt(e.id,x[eo(e.id)].dist);return{...e,showcase_overrides:await to(e.showcase_overrides,t)}}return e}async function Zm(e){const t=no(e.header)?{...e.header,showcase_overrides:await to(e.header.showcase_overrides,await Vt(e.header.id,x[eo(e.header.id)].dist))}:e.header,n=no(e.footer)?{...e.footer,showcase_overrides:await to(e.footer.showcase_overrides,await Vt(e.footer.id,x[eo(e.footer.id)].dist))}:e.footer;return{...e,header:t,footer:n}}async function Bm(e){const t=await Promise.all(e.pages.map(async o=>({...o,sections:await Promise.all(o.sections.map(r=>xs(r)))}))),n=await Zm(e.configuration);return{id:e.id,descriptor:{...n,pages:t}}}async function Hm(e){return Promise.all(e.map(t=>Bm(t)))}async function Vm(e){const t=new Map;return await Promise.all(e.map(async n=>{const[o,r]=await Promise.all([it(n.translationsSettings),it(n.translationsShowcases)]);t.set(n.id,{settings:o,showcases:r})})),t}async function Wm(e,t,n){const[o,r,s,i]=await Promise.all([Wn(e.content,t,e.type),Yn(e.design,t,e.type),th(e.showcase,n),Ss(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 Ym(e,t){return Promise.all(e.map(async n=>{const o=t.get(n.id)??{settings:{},showcases:{}};return Wm(n,o.settings,o.showcases)}))}async function Km(e){return Promise.all(e.map(async t=>{const n=await Promise.all(t.descriptor.sections.map(o=>xs(o)));return{...t,descriptor:{...t.descriptor,sections:n}}}))}async function Jm(e){const t=await Vm(e.sections),[n,o,r,s,i]=await Promise.all([Ym(e.sections,t),_h(e.layouts),dm(e.slots,e.layouts),Hm(e.templates),Km(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 Xm(e){const t=S(Et.cwd(),gs);return _i(t,JSON.stringify(e))}function Qm(e){return Object.entries(x).find(t=>t[1].source===e)?.[0]}async function Gs(){const e=await I("**/server.{js,ts}",{ignore:["node_modules/**","dist/**","templates/**","layouts/**","collections/**"]});return Promise.all(e.map(async t=>{const n=uo(t).split(an),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,y,T]=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:Qm(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:y.at(0),assetsEntrypoints:T}}))}const qm=["/settings/","/showcases/"];function eE(e){return qm.some(t=>e.includes(t))}function tE(){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),r=le.getPreEmitDiagnostics(o).filter(s=>!s.file||!eE(s.file.fileName));if(r.length>0){const s={getCanonicalFileName:i=>i,getCurrentDirectory:le.sys.getCurrentDirectory,getNewLine:()=>le.sys.newLine};throw console.error(le.formatDiagnosticsWithColorAndContext(r,s)),new Error(`TypeScript found ${r.length} error(s)`)}}async function nE(e){tE(),await Ee({configFile:!1,logLevel:"error",plugins:[pe.vue(),pe.tsconfigPaths(),pe.checker()],build:{write:!1,rollupOptions:{input:S(process.cwd(),e)}}})}function oE(){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 rE(){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(s=>{const i=S(process.cwd(),s);e.addLocalFile(i,po(s).dir)});const o=ct[C.SourceCode].fileName,r=S(process.cwd(),o);await e.writeZipPromise(r)}catch(o){throw f.error("Error while zipping source files"),o}}async function Xt(e=!1,t=!1){Nh(t),bs.start(),await oE();try{const[n,o,r]=await Promise.all([rm(),Gs(),pm()]),s=o.map(Ms);o.length>0&&await nE(o[0].serverEntrypoint);try{await Promise.all([um(),Us(s),ym(),Tm(),im(n),hm(r),rE()])}finally{bs.stop()}const i=await Gm(),a=await wh(i);Ch(a,e);const c=await Jm(i);await Xm(c)}catch(n){f.error(`Error while building: ${n.message}`),e||process.exit(1)}}async function ie({entryPoints:e,configType:t,name:n,sectionType:o,sectionId:r,layoutId:s}){if(e.length!==0){const i=ht(Ps({name:n,entryPoints:e,configType:t,sectionType:o,sectionId:r,layoutId:s}));await Ee({configFile:!1,...i})}}function Zs(e,t,n){pt.statSync(e).isDirectory()?(pt.mkdirSync(t,{recursive:!0}),pt.readdirSync(e).forEach(o=>{const r=ft.resolve(e,o),s=ft.resolve(t,o);Zs(r,s,n)})):Ci.isMatch(e,n,{dot:!0})||pt.copyFileSync(e,t)}function Te(e,t,n,o,r=[]){const s=ft.join(e,o?.[n]??n);Zs(ft.join(t,n),s,r)}function sE(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 me(e){return V.resolve(Ri(import.meta.url),"../..",e)}function iE(){const e=me("package.json");return e!==""?JSON.parse(D.readFileSync(e,"utf8")):{}}async function aE(e){try{const t=e,n=U.cwd(),o=V.join(n,t),r=["templates","headers","preview","footers","reference","page-templates","layouts","collections","blank"],s={_gitignore:".gitignore"};D.existsSync(o)?(f.error(`App with the name: ${e} already exists. If you'd like to override it, delete previous version first`),U.exit(1)):D.mkdirSync(o);const i=me("template");D.readdirSync(i).filter(d=>d!=="package.json").filter(d=>!r.includes(d)).forEach(async d=>Te(o,i,d,s));const a=JSON.parse(D.readFileSync(V.join(i,"package.json"),"utf-8"));a.name=e;const c=iE();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=V.join(o,"package.json");D.writeFileSync(u,`${JSON.stringify(a,null,2)}
|
|
58
|
-
`),f.info(`App ${e} created`)}catch(t){f.error(`Error while creating app: ${t.message}`),
|
|
59
|
-
`)}function
|
|
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 Ke.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),Ke.insertLeft=!0),this.appendLeft(t,n)}insertRight(t,n){return Ke.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),Ke.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&&(Ke.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),Ke.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 lt(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(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="",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=zs(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 js=S(process.cwd(),"shared/translation.ts"),Us="globalThis.craneSharedTranslation = translation",im=e=>`import translation from '${e}';
|
|
56
|
+
${Us};
|
|
57
|
+
`,am=(e,t)=>{const n=e.split("?")[0],o=mi(n);return(o==="server.ts"||o==="client.ts")&&!t.includes(Us)},Fs=()=>{let e=!1;return{name:"static-translation-plugin",enforce:"pre",apply:"build",buildStart(){e=H(js)},transform(t,n){if(!e||!am(n,t))return null;const o=n.split("?")[0],r=uo(o),s=Si(lo(r,js)),i=im(s),a=new ao(t);return a.prepend(i),{code:a.toString()}}}},Ms={[te.Server]:()=>[pe.vue(),pe.tsconfigPaths(),Yh(),Hh(),Fs()],[te.Client]:()=>[pe.vue(),pe.tsconfigPaths(),_o({vue:"EcVue"}),Fs()],[te.Misc]:()=>[pe.tsconfigPaths()],[te.Layout]:()=>[pe.vue(),pe.tsconfigPaths(),_o({vue:["EcExternals","Vue"]})],[te.Asset]:()=>[Kh()],[te.SharedFiles]:()=>[pe.tsconfigPaths()]},Gs={[N.Server]:Ds({outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/main/server`}),[N.Client]:Ls({outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/main/client`}),[N.SectionSetting]:Ye({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/settings`}),[N.SectionShowcase]:Ye({entryFileNames:"[name].mjs",outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/js/showcases`}),[N.SectionAsset]:Kt({outDir:({name:e,sectionType:t})=>`./${G[t].dist}/${e}/assets`}),[N.TemplateDescriptor]:Ye({entryFileNames:"[name].mjs",outDir:()=>`./${Te}/js`}),[N.PageTemplateDescriptor]:Ye({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${Te}/${e}`}),[N.TemplateAsset]:Kt({outDir:()=>`./${Te}/assets`}),[N.Layout]:jh({outDir:({name:e,sectionId:t})=>`./${Q}/${t}/${e}`}),[N.LayoutSettings]:Ye({entryFileNames:"[name].mjs",outDir:({name:e,sectionId:t})=>`./${Q}/${t}/${e}/js/settings`}),[N.LayoutAsset]:Kt({outDir:({name:e,sectionId:t})=>`./${Q}/${t}/${e}/assets`}),[N.SlotServer]:Ds({outDir:({name:e,layoutId:t,sectionId:n})=>`./${Q}/${n}/${t}/slots/${e}/js/main/server`}),[N.SlotClient]:Ls({outDir:({name:e,layoutId:t,sectionId:n})=>`./${Q}/${n}/${t}/slots/${e}/js/main/client`}),[N.CollectionDescriptor]:Ye({entryFileNames:"[name].mjs",outDir:({name:e})=>`./${rt}/${e}`}),[N.CollectionAsset]:Kt({outDir:()=>`./${rt}/assets`}),[N.SharedTranslation]:{pluginType:te.SharedFiles,ssr:!1,inlineDynamicImports:!0,entryFileNames:"translation.mjs",outDir:()=>"./dist/shared"}};function cm(e){switch(typeof e){case"string":return[S(process.cwd(),e)];case"object":return e.map(t=>S(process.cwd(),t));default:return[]}}function xs({name:e,entryPoints:t,configType:n,layoutId:o,sectionId:r,sectionType:s=_e.SECTION}){const i=Gs[n],a=i.define,c=i.ssrOptions,u=i.entryFileNames,d=i.chunkFileNames,m=i.assetFileNames,y=i.inlineDynamicImports,T=i.externalOption;return{logLevel:Xn()?void 0:"silent",plugins:Ms[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:T,preserveEntrySignatures:"strict",input:cm(t),treeshake:{moduleSideEffects:!1},output:{validate:!0,inlineDynamicImports:y,entryFileNames:u,chunkFileNames:d,assetFileNames:m}}},assetsInclude:["**/*.json"]}}const um=Object.values(G).map(e=>e.source).join("|");function Bs(e,t,n){if(!e)return`${t}.mjs`;const o=lo(process.cwd(),e).replace(/\\/g,"/").match(`^(${um})/([^/]+)/${n}/([^/.]+)`);return o?`${o[1]}/${o[2]}/js/${n}/${o[3]}.mjs`:`${t}.mjs`}function Zs(e,t){const n=Gs[N.SectionSetting];return{logLevel:Xn()?void 0:"silent",plugins:Ms[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 lm(e){return Zs(e,t=>Bs(t.facadeModuleId??void 0,t.name,"settings"))}function dm(e){return Zs(e,t=>Bs(t.facadeModuleId??void 0,t.name,"showcases"))}async function pm(){const e={ignore:["node_modules/**","dist/**"]},t=await I(`./${Be}/{product,category,catalog}/*/client.{js,ts}`,e);return await Promise.all(t.map(async n=>{const{id:o,sectionId:r,pageId:s}=vh(n),[i,a]=await Promise.all([I(`./${Be}/${r}/${o}/settings/{content,design,translations,layout}.{js,ts}`,e),I(`./${Be}/${r}/${o}/assets/*`,e)]);return{name:o,sectionId:r,pageId:s,clientEntrypoint:n,settingsEntryPoints:i,assetsEntrypoints:a}}))}async function fm(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 hm(e){e===void 0||e.length===0||await Promise.all(e.map(t=>fm(t)))}async function mm(e){const t=e.flatMap(o=>o.settingsEntryPoints),n=e.flatMap(o=>o.showcaseEntryPoints);t.length>0&&await ge({configFile:!1,...ht(lm(t))}),n.length>0&&await ge({configFile:!1,...ht(dm(n))})}async function Em(e){await Promise.all([ge({configFile:!1,...ht(xs({name:e.name,entryPoints:e.serverEntrypoint,configType:He.Server,sectionType:e.type}))}),se({entryPoints:e.clientEntrypoint,configType:He.Client,name:e.name,sectionType:e.type}),se({entryPoints:e.assetEntryPoints,configType:He.SectionAsset,name:e.name,sectionType:e.type})])}async function gm(){const e=S(process.cwd(),"shared/translation.ts");H(e)&&await se({entryPoints:["shared/translation.ts"],configType:He.SharedTranslation})}async function Hs(e){await Promise.all([mm(e),...e.map(Em)])}function _m(e){const t=Wt(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(!Ns(n))throw new Error(`Slot cannot be placed in a non-storefront section: ${n}`);return{id:r,sectionId:n,layoutId:o}}async function ym(e,t){return Promise.all(e.map(async n=>{const o=t.find(a=>a.id===n.layoutId&&a.sectionId===n.sectionId),r=await it(o?.translationsSettings),s=await Wn(o?.content??{},r),i=await Yn(o?.design??{},r);return{id:n.id,sectionId:n.sectionId,layoutId:n.layoutId,contentEditors:s,designEditors:i}}))}async function Sm(){const e={ignore:["node_modules/**","dist/**"]},t=await I(`${Be}/{product,category,catalog}/*/slots/*/server.ts`,e);return Promise.all(t.map(async n=>{const{id:o,sectionId:r,layoutId:s}=_m(n),i=(await I(`${Be}/${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 Tm(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 Om(e){e?.length&&await Promise.all(e.map(Tm))}async function Im(e){return(await I(`**/${e}/pages/*.{js,ts}`,{ignore:["node_modules/**","dist/**"]})).filter(t=>{const n=po(t).name.toLowerCase();return!Object.values(Ir).includes(n)})}async function wm(){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(an),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 Im(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 vm(){const e=await I("./templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]}),t=await I("./templates/assets/*",{ignore:["node_modules/**","dist/**"]});return{pageTemplates:await wm(),templates:e,assets:t}}async function Cm({templateBuildConfig:e}){await Promise.all([se({entryPoints:e.assets,configType:He.TemplateAsset}),...e.pageTemplates?.map(async t=>{const n=[t.configurationEntrypoint,t.homeEntrypoint,t.categoryEntrypoint,t.catalogEntrypoint,t.productEntrypoint,...t.customEntrypoint??[]].filter(Zt);if(n.length===0)throw new Error("No entry points provided for page template");await se({entryPoints:n,configType:He.PageTemplateDescriptor,name:t.name})})||[]])}async function Rm(){const e=await vm();await Cm({templateBuildConfig:e})}async function bm(){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(an),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 Am(){const e=await bm();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 Vs(e){return{name:e.name,type:e.type,serverEntrypoint:e.serverEntrypoint,clientEntrypoint:[e.clientEntrypoint].filter(Zt).flat(),settingsEntryPoints:[e.contentSettingsEntrypoint,e.designSettingsEntrypoint,e.layoutSettingsEntrypoint,e.settingsTranslationsEntrypoint].filter(Zt),showcaseEntryPoints:[...e.showcasesEntrypoints??[],e.showcasesTranslationsEntrypoint].filter(Zt),assetEntryPoints:e.assetsEntrypoints??[]}}function Ws(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 Nm(e,t=me){const n=S(process.cwd(),`${t}/${e}/js/main/server/server.js.gz`),o=yo(So.gunzip),r=await C.promises.readFile(n);return{size:(await o(r)).length}}async function $m(e,t=me){try{const n=S(process.cwd(),`${t}/${e}/assets/`);return(await I("*",{cwd:n})).map(o=>{const r=S(n,o);return{path:o,size:Xe(r).size}})}catch{throw new Error(`Asset files for section [${e}] is either invalid or undefined`)}}async function Qn(e,t){const n=await sh(e,G[t].dist),o=await Vt(e,G[t].dist),r=await ah(e,G[t].dist),s=await ch(e,G[t].dist),i=await lh(e,G[t].dist),a=await dh(e,G[t].dist),c=Ws(a),u=await $m(e,G[t].dist),d=await Nm(e,G[t].dist),m=ph(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 Dm(){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,xe.SECTION)),...t.map(async o=>Qn(o,xe.HEADER)),...n.map(async o=>Qn(o,xe.FOOTER))])}async function Lm(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:Xe(o).size}})}catch{throw new Error("Asset files for layouts are either invalid or undefined")}}async function km(e){const t=Wt(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([zm(o,n),jm(o,n),ih(o,n),Lm(e),Um(o,n)]);return{id:o,sectionId:n,content:r,design:s,translationsSettings:i,assets:a,layouts:c}}async function Pm(){const e=`${Q}/{product,catalog,category}/*`,t=await I(e,{ignore:["node_modules/**"]});return Promise.all(t.map(km))}async function zm(e,t){try{const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/content.mjs`),o=await re(n);return ke(o)}catch(n){throw new Error(`Content descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function jm(e,t){try{const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/design.mjs`),o=await re(n);return ke(o)}catch(n){throw new Error(`Design descriptor for layout [${e}] is either invalid or undefined: ${n}`)}}async function Um(e,t){try{const n=S(process.cwd(),`${Q}/${t}/${e}/js/settings/layout.mjs`);if(!C.existsSync(n))return[];const o=await re(n);return Ws(o)}catch(n){throw new Error(`Layout settings descriptor for layout [${e}] in section [${t}] is either invalid or undefined: ${n}`)}}async function Fm(e,t,n){const o=S(process.cwd(),`${Q}/${n}/${t}/slots/${e}/js/main/server/server.js.gz`),r=yo(So.gunzip),s=await C.promises.readFile(o);return{size:(await r(s)).length}}async function Mm(e){const t=Wt(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 Fm(r,o,n);return{id:r,sectionId:n,layoutId:o,server:s}}async function Gm(){const e=`${Q}/{product,catalog,category}/*/slots/*`,t=await I(e,{ignore:["node_modules/**"]});return await Promise.all(t.map(Mm))}async function xm(){try{const e=S(process.cwd(),`${Te}/assets/`);return(await I("*",{cwd:e})).map(t=>{const n=S(e,t);return{path:t,size:Xe(n).size}})}catch{throw new Error("Asset files for templates are either invalid or undefined")}}function Bm(e){return e in Ae?Ae[e]:Ae.CUSTOM}async function Zm(e){const t=await I(`${Te}/${e}/*.mjs`,{ignore:[`${Te}/${e}/configuration*.mjs`]});return Promise.all(t.map(async n=>{const{sections:o,metadata:r}=await qn(n),s=Pf(n);return{type:Bm(s.toUpperCase()),id:s,metadata:r,sections:o}}))}async function qn(e){try{return await re(S(process.cwd(),e))}catch{throw new Error(`Template file [${e}] is either invalid or undefined`)}}async function Hm(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 xm(),configuration:await qn(n),pages:await Zm(o)}}))}async function Vm(e){return await Hm(e)}async function Wm(){const e=S(process.cwd(),`${Nf}/translation.mjs`);return await re(e)}async function Ym(){return{translations:await Wm()}}async function Km(e){const t=await I(`${rt}/*/configuration*.mjs`,{ignore:["node_modules/**",`${rt}/assets/**`]});return Promise.all(t.map(async n=>{const o=z.basename(z.dirname(n)),r=await qn(n);return{id:`${e}_${o}`,descriptor:r}}))}async function Ys(){const e=await Ht(),[t,n,o,r,s,i,a]=await Promise.all([Jn(),Ym(),Dm(),Pm(),Gm(),Vm(e.appClientId),Km(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 eo(e){return H(`${Gn}/${e}`)?_e.HEADER:H(`${xn}/${e}`)?_e.FOOTER:_e.SECTION}async function to(e,t){const n=e.design?Vn(e.design):void 0,o={...e,design:n??e.design},r=await it(t);return Ze(o,r)}function no(e){return e.type==="custom"&&e.id!==void 0&&e.showcase_overrides!==void 0}async function Ks(e){if(no(e)){const t=await Vt(e.id,G[eo(e.id)].dist);return{...e,showcase_overrides:await to(e.showcase_overrides,t)}}return e}async function Jm(e){const t=no(e.header)?{...e.header,showcase_overrides:await to(e.header.showcase_overrides,await Vt(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 Vt(e.footer.id,G[eo(e.footer.id)].dist))}:e.footer;return{...e,header:t,footer:n}}async function Xm(e){const t=await Promise.all(e.pages.map(async o=>({...o,sections:await Promise.all(o.sections.map(r=>Ks(r)))}))),n=await Jm(e.configuration);return{id:e.id,descriptor:{...n,pages:t}}}async function Qm(e){return Promise.all(e.map(t=>Xm(t)))}async function qm(e){const t=new Map;return await Promise.all(e.map(async n=>{const[o,r]=await Promise.all([it(n.translationsSettings),it(n.translationsShowcases)]);t.set(n.id,{settings:o,showcases:r})})),t}async function eE(e,t,n){const[o,r,s,i]=await Promise.all([Wn(e.content,t,e.type),Yn(e.design,t,e.type),uh(e.showcase,n),Rs(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 eE(n,o.settings,o.showcases)}))}async function nE(e){return Promise.all(e.map(async t=>{const n=await Promise.all(t.descriptor.sections.map(o=>Ks(o)));return{...t,descriptor:{...t.descriptor,sections:n}}}))}async function Js(e){const t=await qm(e.sections),[n,o,r,s,i]=await Promise.all([tE(e.sections,t),Ch(e.layouts),ym(e.slots,e.layouts),Qm(e.templates),nE(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 oE(e){const t=S(Et.cwd(),ws);return Ci(t,JSON.stringify(e))}function rE(e){return Object.entries(G).find(t=>t[1].source===e)?.[0]}async function Xs(){const e=await I("**/server.{js,ts}",{ignore:["node_modules/**","dist/**","templates/**","layouts/**","collections/**"]});return Promise.all(e.map(async t=>{const n=uo(t).split(an),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,y,T]=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:rE(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:y.at(0),assetsEntrypoints:T}}))}const sE=["/settings/","/showcases/"];function iE(e){return sE.some(t=>e.includes(t))}function aE(){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||!iE(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 cE(e){aE(),await ge({configFile:!1,logLevel:"error",plugins:[pe.vue(),pe.tsconfigPaths(),pe.checker()],build:{write:!1,rollupOptions:{input:S(process.cwd(),e)}}})}function uE(){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 lE(){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(s=>{const i=S(process.cwd(),s);e.addLocalFile(i,po(s).dir)});const o=ct[R.SourceCode].fileName,r=S(process.cwd(),o);await e.writeZipPromise(r)}catch(o){throw f.error("Error while zipping source files"),o}}async function Xt(e=!1,t=!1){Uh(t),Ps.start(),await uE();try{const[n,o,r]=await Promise.all([pm(),Xs(),Sm()]),s=o.map(Vs);o.length>0&&await cE(o[0].serverEntrypoint);try{await Promise.all([gm(),Hs(s),Rm(),Am(),hm(n),Om(r),lE()])}finally{Ps.stop()}const i=await Ys(),a=await Dh(i);kh(a,e);const c=await Js(i);await oE(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=ht(xs({name:n,entryPoints:e,configType:t,sectionType:o,sectionId:r,layoutId:s}));await ge({configFile:!1,...i})}}function Qs(e,t,n){pt.statSync(e).isDirectory()?(pt.mkdirSync(t,{recursive:!0}),pt.readdirSync(e).forEach(o=>{const r=ft.resolve(e,o),s=ft.resolve(t,o);Qs(r,s,n)})):ki.isMatch(e,n,{dot:!0})||pt.copyFileSync(e,t)}function Oe(e,t,n,o,r=[]){const s=ft.join(e,o?.[n]??n);Qs(ft.join(t,n),s,r)}function dE(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 V.resolve(Pi(import.meta.url),"../..",e)}function pE(){const e=Ee("package.json");return e!==""?JSON.parse(D.readFileSync(e,"utf8")):{}}async function fE(e){try{const t=e,n=j.cwd(),o=V.join(n,t),r=["templates","headers","preview","footers","reference","page-templates","layouts","collections","blank"],s={_gitignore:".gitignore"};D.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)):D.mkdirSync(o);const i=Ee("template");D.readdirSync(i).filter(d=>d!=="package.json").filter(d=>!r.includes(d)).forEach(async d=>Oe(o,i,d,s));const a=JSON.parse(D.readFileSync(V.join(i,"package.json"),"utf-8"));a.name=e;const c=pE();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=V.join(o,"package.json");D.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 oo(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=>Oe(i,a,c)),f.info(`${o} ${n} created`)}catch(r){f.error(`Error while creating ${o}: ${r.message}`),j.exit(1)}}function ro(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=>Oe(o,n,r)))}async function hE(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 Le({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(s,i,a){const c=z.join(i,s.name),u=z.join(a,s.name);s.isDirectory()?await Qt(c,u,n):await hE(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 so(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 mE(e,t){await so(),oo(`${`template${t?"/blank":""}`}/sections/${`${t?"blank-section":"example-section"}`}`,"sections",e,"Section")}function EE(e){return{renameFiles:{"example-collection":`${e}`},targetPath:e,sourcePath:"template/collections",onCollectionCreated:()=>f.info(`Collection [${e}] has been created`)}}async function gE(e){const{targetPath:t,renameFiles:n,sourcePath:o,onCollectionCreated:r}=EE(e);try{const s=j.cwd(),i=V.join(s,"collections"),a=Ee(o),c=D.readdirSync(a);D.existsSync(i)?D.existsSync(V.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)):D.mkdirSync(i),c.forEach(u=>Oe(i,a,u,n)),r()}catch(s){f.error(`Error while creating collection: ${s.message}`),j.exit(1)}}async function _E(e){await so(),oo("template/footers/example-footer","footers",e,"Footer")}async function yE(e){await so(),oo("template/headers/example-header","headers",e,"Header")}async function SE(e,t){try{const n=j.cwd(),o=V.join(n,"templates"),r=Ee("template/page-templates/example-template/pages");D.existsSync(V.join(o,e))||(f.error(`Template with the name: [${e}] doesn't exists. Please create a template first.`),j.exit(1)),D.existsSync(V.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=D.readFileSync(V.join(r,"custom.ts"),"utf-8").replace(/title\s*:\s*'Custom Page'/,`title: '${zf(t)}'`),i=V.join(o,e,"pages",`${t}.ts`);D.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 TE(){try{const e=j.cwd(),t=Ee("template/reference"),n=D.readdirSync(t);let o=!1;for(const r of n){const s=V.join(t,r),i=V.join(e,r);D.existsSync(i)||D.mkdirSync(i,{recursive:!0});const a=D.readdirSync(s),c=D.readdirSync(i);if(r==="shared"){a.forEach(u=>{Oe(i,s,u)});continue}for(const u of a){if(u==="assets"){Oe(i,s,u);continue}if(c.includes(u)){const{name:d}=await Le({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?(Oe(i,s,u,{[u]:d}),o=!0):f.info(`Skipped: ${u}`)}else Oe(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 OE=["**/example-template/pages/custom.ts"];async function IE(e){const{targetPath:t,renameFiles:n,sourcePath:o,onTemplateCreated:r}=dE(e);try{const s=j.cwd(),i=V.join(s,"templates"),a=Ee(o),c=D.readdirSync(a);D.existsSync(i)?D.existsSync(V.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)):D.mkdirSync(i),c.forEach(u=>Oe(i,a,u,n,OE)),ro("headers"),ro("footers"),ro("layouts"),r()}catch(s){f.error(`Error while creating template descriptors: ${s.message}`),j.exit(1)}}function wE(){try{const e=S(Et.cwd(),`${Is}/shared/analytics.json`);H(e)&&sn(e,JSON.stringify({},null,2),"utf-8")}catch(e){console.warn("Can not clean up preview analytics.json file",e)}}function qt({deploymentContext:e,sectionType:t=_e.SECTION}){const n=e.pathContext,o=n.toPath({sectionId:e.currentSection,sectionType:t,layoutId:e.layoutId,slotId:e.slotId}),r=o===void 0?ho(n.fileName):ho(n.fileName,{cwd:S(process.cwd(),o),ignore:n.ignore});return(n.isSingleton?r.splice(0):r).map(s=>({url:s,sectionType:t,context:e}))}const vE=e=>e.app.manifest.blocks.flatMap(t=>yh.flatMap(n=>{const o={config:e,currentSection:t.id,pathContext:ct[n]};return qt({deploymentContext:o,sectionType:t.type})})),CE=e=>Oh.flatMap(t=>{const n={config:e,pathContext:ct[t]};return qt({deploymentContext:n})}),RE=e=>e.app.manifest.layouts.flatMap(t=>Sh.flatMap(n=>{const o={config:e,pathContext:ct[n],currentSection:t.sectionId,layoutId:t.id};return qt({deploymentContext:o})})),bE=e=>e.app.manifest.slots.flatMap(t=>Th.flatMap(n=>{const o={config:e,pathContext:ct[n],currentSection:t.sectionId,layoutId:t.layoutId,slotId:t.id};return qt({deploymentContext:o})})),AE=e=>`\x1B[32m${e}\x1B[0m`,NE=(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:`${Se(n.value/i,2)}/s`})},$E=()=>new Ui.SingleBar({format:`|${AE("{bar}")}| {status} || {percentage}% || {value}/{total} Files || Speed: {speed}`,barCompleteChar:"\u2588",barIncompleteChar:"\u2591"});async function qs(e){await new Promise(t=>setTimeout(t,e))}const ei="Please ensure you have built your application before deploying.";async function DE(){try{const e=await un(S(Et.cwd(),ws));return JSON.parse(e.toString())}catch(e){throw e.code==="ENOENT"?new Error(`Manifest file not found. ${ei}`):e instanceof SyntaxError?new Error(`Manifest file is not valid. ${ei}`):e}}const LE={value:0},ie=$E();let ti=Date.now();const ni=e=>2**e*500;async function kE(e){const t=ji(e.version,"patch");if(t===null)throw Error("Error while incrementing app version");e.version=t,sn(S(F.cwd(),"package.json"),`${JSON.stringify(e,null,2)}
|
|
59
|
+
`)}function PE(e){return e instanceof Eo&&(e.code==="ECONNRESET"||e.response?.status!==void 0&&e.response?.status>=500&&e.response?.status<600)}function oi(e,t){return e<_h&&PE(t)}async function ri(e,t,n,o){const r={value:0},s=e.config.app.manifest.templates.length>0||e.config.app.manifest.collections.length>0?hh:fh;return e.config.axios.post(s,{file:pi(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=>NE(i,ie,LE,r,ti)}).then(i=>(ie.increment(),i)).catch(async i=>{if(oi(o,i))return await qs(ni(o)),ri(e,t,n,o+1);throw ie.increment(),i})}function zE(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 ri(n,t.url,o,0)})}function jE(e){const t=[...vE(e),...CE(e),...RE(e),...bE(e)];return zE(t)}async function si(e,t=0){const n=e.app.manifest.templates.length>0||e.app.manifest.collections.length>0?Eh:mh;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(oi(t,o))return await qs(ni(t)),si(e,t+1);throw o})}async function UE(e){try{if(!$f.some(i=>H(S(F.cwd(),i))))throw new Error(Ve.INCORRECT_DISTRIBUTION_FOLDER(Af));const t=e??Kn;f.info("Custom application deployment :: Started");const n=ln.create({baseURL:t});zi(n,gh),f.info("Loading configuration files ...");const o=await Promise.all([Ht(),Jn(),DE()]).then(([i,a,c])=>({axios:n,app:{crane:i,packageJson:a,manifest:c}}));f.info("Uploading files ..."),ti=Date.now(),await Promise.all(jE(o)).catch(i=>{ie.stop(),i.response?.status===404?f.error($e(i,Ve.DEPRECATED_VERSION_DEPLOYMENT)):f.error($e(i,Ve.ASSET_FILES_UPLOAD)),F.exit(1)}).finally(()=>{ie.increment(),ie.stop()}),ie.update({speed:"N/A",status:"Finalising deployment"}),await si(o).catch(i=>{ie.stop(),i.response?.status===404?f.error($e(i,Ve.DEPRECATED_VERSION_DEPLOYMENT)):f.error($e(i,Ve.MANIFEST_DEPLOYMENT)),F.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 kE(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($e(t,Ve.DEFAULT)),F.exit(1)}finally{wE()}}function FE(){process.env.CRANE_DEBUG_ENABLED="true"}function ME(){return process.env.CRANE_DEBUG_ENABLED==="true"}function GE(e,...t){ME()&&console.debug(yi(`[DEBUG] ${e}`),...t)}function xE(){return{name:"app-block-api",configureServer(e){e.middlewares.use(async(t,n,o)=>{e.moduleGraph.invalidateAll();const r=new Ri(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 Ys(),a=(await Js(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 De=null;function BE(){De&&De.clients.forEach(e=>{e.readyState===Mi.OPEN&&e.send(JSON.stringify({type:"full-reload"}))})}async function ZE(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 HE(e,t){const n=S(`${e}/shared/preview.ts`),o=S(`${e}/shared/utils.ts`),r=S(`${e}/shared/api-routes.ts`),s=S(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 VE(){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 ZE(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 HE(s,t)}function WE(e){const t=e.replace(/\\/g,"/").match(/(?:sections|headers|footers)\/([^/]+)/);return t?t[1]:null}function YE(e){const t=e.replace(/\\/g,"/");return t.includes("shared")&&!t.includes("sections")&&!t.includes("headers")&&!t.includes("footers")}async function KE(e){const t=(await Xs()).find(o=>o.name===e);if(!t){console.warn(`Block ${e} not found, falling back to full build`),await Xt(!0);return}const n=Vs(t);await Hs([n]),console.log(`Block ${e} rebuilt successfully`)}var JE=(e=>(e.FULL="full",e.INCREMENTAL="incremental",e))(JE||{});function XE(){return{timeout:null,inProgress:!1,pendingBuild:null}}function QE(e,t){const n=async o=>{e.inProgress=!0;try{o.type==="incremental"&&o.blockName?await KE(o.blockName):await Xt(!0),t.ws.send({type:"full-reload",path:"*"}),BE()}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 qE(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 eg(e,t){return async n=>{if(!qE(n))return;e.timeout&&clearTimeout(e.timeout);const o=WE(n),r=YE(n);e.timeout=setTimeout(async()=>{r?await t({type:"full"}):o&&await t({type:"incremental",blockName:o})},1e3)}}function tg(e,t){const n=XE(),o=QE(n,e),r=eg(n,o);e.watcher.add(t),e.watcher.on("add",r),e.watcher.on("change",r),e.watcher.on("unlink",r)}async function ng(){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:r}=await n.startServer();return{server:o,port:r}}function og(){De=new Fi({port:0}),De.on("listening",()=>{const e=De?.address();if(e&&typeof e=="object"){const t=e.port;process.env.CRANE_WEBSOCKET_PORT=String(t)}})}async function rg(){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 Ti({configFile:e,root:process.cwd(),plugins:[xE()]});return await s.listen(),tg(s,[t,n,o,r]),s}async function sg(){await Xt(),await VE(),console.log(`
|
|
60
60
|
\u{1F4E6} Starting preview servers...
|
|
61
|
-
`);let e=null,t=null;
|
|
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
|
|
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=
|
|
61
|
+
`);let e=null,t=null;GE("Starting SSR server");const n=await ng();e=n.server,t=n.port,process.env.PREVIEW_SSR_PORT=String(t),og();const o=await rg(),r=()=>{e&&e.close(),De&&De.close(),o.close(),process.exit(0)};return process.on("SIGINT",r),process.on("SIGTERM",r),o}const ig=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i,ag=/^[-a-zA-Z0-9_.^~<>=|* +]+$/;function ii({name:e,version:t}){return ig.test(e)&&ag.test(t)}function en(e){if(!H(e))return{dependencies:{},devDependencies:{},overrides:{}};let t;try{t=JSON.parse(on(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 cg(e,t){const n=en(ee(e,"package.json")),o=en(ee(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 ug(e,t){const n=en(ee(e,"package.json")).overrides,o=en(ee(t,"package.json")).overrides;return Object.fromEntries(Object.entries(n).filter(([r,s])=>o[r]!==s))}function lg(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 ai(e){return e.map(t=>`${t.name}@${t.version}`).join(" ")}function dg(e){const t=e.filter(r=>!r.isDev),n=e.filter(r=>r.isDev),o=[];return t.length>0&&o.push(`npm install ${ai(t)}`),n.length>0&&o.push(`npm install -D ${ai(n)}`),o}function pg(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=xi("npm",s,{cwd:t,stdio:"inherit"});if(i.status!==0)throw new Error(`npm ${o.join(" ")} exited with code ${i.status}`)}}async function fg(e,t){if(e.length===0)return;const n=e.filter(c=>!ii(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(ii);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=dg(o);switch((await Le({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{pg(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=ee(t,"package.json"),u=JSON.parse(on(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)))}sn(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
|
|
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 hg(e,t,n){const o=t.split("_").pop()??t,r=ee(e,"sections",o),s=ee(e,o);let i=null;if(H(r)&&Xe(r).isDirectory()?i=r:H(s)&&Xe(s).isDirectory()&&(i=s),i){const a=ee(n,o);H(a)&&((await Le({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 mg(e,t,n){const o=fi(ee(Gi.tmpdir(),"crane-source-"));new fo(Buffer.from(e)).extractAllTo(o,!0);try{const r=F.cwd(),s=ee(r,"sections");H(s)||hi(s,{recursive:!0}),await hg(o,t,s);const i=ee(o,"shared");if(H(i)){const c=ee(r,"shared");f.info("Copying shared folder..."),await Qt(i,c,!0)}const a=cg(o,r);await fg(a,r),lg(ug(o,r)),f.info(`Source code for section [${n}] has been copied.`)}finally{co(o,{recursive:!0,force:!0})}}async function ci(e){const t=e??Kn,n=ln.create({baseURL:t}),o=await Ht();return[...(await n.get("/api/v1/custom-apps/manifests/collections/sections",{params:{appClientId:o.appClientId},headers:{Authorization:`Bearer ${o.appSecretKey}`}})).data.sections]}async function Eg(e,t){const n=(await ci(t)).find(o=>o.sectionId===e);return n||(f.error(`Section [${e}] not found in collection sections list.`),F.exit(1)),n}async function gg(e,t,n){const o=n??Kn,r=ln.create({baseURL:o}),s=await Ht();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 mg(i.data,t,e)}async function _g(e){try{f.info("Fetching sections list...");const t=await ci(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($e(t,"Error while fetching sections list")),F.exit(1)}}async function yg(e,t){try{const n=await Eg(e,t);n.openSource||(f.error(`Section [${e}] is not open source. Only open source sections can be pulled.`),F.exit(1)),await gg(e,n.sectionId,t)}catch(n){f.error($e(n,"Error while pulling section")),F.exit(1)}}async function Sg(e,t){const{list:n,section:o}=e;if(n){await _g(t);return}if(o){await yg(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 Tg={deploy:["url"],pull:["url"],init:[""],build:["generatePreview"]},Og=["preview","build","deploy","pull"];function Ig(e,t){return Og.includes(e.rawName)?!1:e.options.length!==0&&Object.keys(t).length===1}function wg(e){return e.includes("-h")||e.includes("--help")}function vg(e,t){return Object.keys(t).some(n=>n!=="--"&&!e.hasOption(n)&&!Tg[e.rawName]?.includes(n))}function Cg(e){return e.length!==0}function Rg(e,t,n){return e.matchedCommand!==void 0&&(Ig(e.matchedCommand,n)||wg(e.rawArgs)||vg(e.matchedCommand,e.options)||Cg(t))}function bg(e,t,n){e.matchedCommand&&!Rg(e,t,n)?e.runMatchedCommand():e.outputHelp()}function tn(e){if(kf(e))return console.log("Please specify a name for your resource."),!1;const{isValid:t,errorMessage:n}=Lf(e);return n&&console.log(n),t}async function io(e){const t=await Le({type:"text",name:"name",message:`Please specify a name for your ${e}:`});if(t.name!==void 0){const n=z.basename(t.name);return tn(n)?n:io(e)}}async function Ag(e,t,n,o){const r=await io(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 Je(e,t,n,o,r){if(r!==void 0)if(!tn(r))await Ag(e,t,n,o);else{const s=z.basename(r.toString());await o(s)}}function Ng(){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 $g(e){const t=Ng();if(typeof e=="string"||typeof e=="number"){if(t.includes(e.toString()))return e.toString();tn(e)?f.warn(`Template [${e}] doesn't exist`):f.error(`[${e}] is an invalid template name.`)}const n=await Le({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 Dg(e,t){if(typeof t=="string"||typeof t=="number"){if(tn(t))return t.toString();f.error(`${t} is invalid name.`)}return io(e)}async function Lg(e,t,n){const o=await $g(t),r=await Dg("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 SE(o,r)}async function kg(e,t){try{const{app:n,section:o,header:r,footer:s,template:i,referenceTemplate:a,page:c,blank:u,collection:d}=e;await Je(t,"app",ce("init --app <name>"),fE,n),await Je(t,"section",ce(`init --section <name>${u?" --blank":""}`),m=>mE(m,u===!0),o),await Je(t,"header",ce("init --header <name>"),yE,r),await Je(t,"footer",ce("init --footer <name>"),_E,s),c===void 0?await Je(t,"template",ce("init --template <name>"),IE,i):await Lg(t,i,c),await Je(t,"collection",ce("init --collection <name>"),gE,d),a&&await TE()}catch(n){f.error(`Error while executing init operation: ${n.message}`),process.exit(1)}}function Pg(){try{const e=Ei("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=>kg(n,e)),e.command("build","Builds your resource code").option("-v, --verbose","Show detailed build output").allowUnknownOptions().action(n=>Xt(!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&&FE(),await sg()}),e.command("deploy","Deploys your resource code").allowUnknownOptions().action(()=>UE(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=>Sg(n,e.options.url)),e.version(Bi),e.usage("<action> <resource>");const t=e.parse(process.argv,{run:!1});bg(e,t.args,t.options)}catch(e){f.error(`Error while parsing input: ${e.message}`),process.exit(1)}}export{Pg as run};
|