@lightspeed/crane 1.1.0 → 1.1.1

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.
Files changed (39) hide show
  1. package/dist/app.d.mts +147 -10
  2. package/dist/app.d.ts +147 -10
  3. package/dist/app.mjs +1 -1
  4. package/dist/cli.mjs +22 -11
  5. package/package.json +5 -2
  6. package/template/footers/example-footer/ExampleFooter.vue +36 -2
  7. package/template/footers/example-footer/component/ReportAbuse.vue +18 -0
  8. package/template/footers/example-footer/entity/color.ts +4 -0
  9. package/template/footers/example-footer/settings/content.ts +3 -0
  10. package/template/footers/example-footer/settings/design.ts +11 -0
  11. package/template/footers/example-footer/settings/translations.ts +12 -0
  12. package/template/footers/example-footer/showcases/1.ts +2 -0
  13. package/template/footers/example-footer/showcases/translations.ts +9 -0
  14. package/template/footers/example-footer/type.ts +2 -2
  15. package/template/headers/example-header/ExampleHeader.vue +20 -7
  16. package/template/headers/example-header/assets/cart.svg +20 -0
  17. package/template/headers/example-header/assets/search.svg +13 -0
  18. package/template/headers/example-header/component/Cart.vue +64 -0
  19. package/template/headers/example-header/component/SearchForm.vue +89 -0
  20. package/template/headers/example-header/showcases/1.ts +11 -0
  21. package/template/headers/example-header/type.ts +2 -2
  22. package/template/package.json +3 -2
  23. package/template/sections/example-section/component/image/ImagesGrid.vue +18 -37
  24. package/template/sections/example-section/settings/content.ts +53 -55
  25. package/template/sections/example-section/settings/translations.ts +27 -24
  26. package/template/sections/example-section/showcases/1.ts +143 -103
  27. package/template/sections/example-section/showcases/2.ts +127 -103
  28. package/template/sections/example-section/showcases/translations.ts +4 -0
  29. package/template/templates/template.ts +143 -103
  30. package/types.d.ts +14 -1
  31. package/template/footers/example-footer/component/SampleComponent.vue +0 -11
  32. package/template/headers/settings/content.ts +0 -1
  33. package/template/headers/settings/design.ts +0 -1
  34. package/template/headers/settings/layout.ts +0 -1
  35. /package/template/{footers → headers/example-header}/settings/content.ts +0 -0
  36. /package/template/{footers → headers/example-header}/settings/design.ts +0 -0
  37. /package/template/{footers → headers/example-header}/settings/layout.ts +0 -0
  38. /package/template/{footers → headers/example-header}/settings/translations.ts +0 -0
  39. /package/template/headers/{settings → example-header/showcases}/translations.ts +0 -0
package/dist/cli.mjs CHANGED
@@ -1,12 +1,23 @@
1
- import We from"cac";import h from"node:fs";import T from"node:path";import{fileURLToPath as P}from"node:url";import*as _ from"fs";import{rmSync as Ve,rename as Ye,unlink as Qe,existsSync as S,statSync as et,writeFileSync as tt,createReadStream as st}from"fs";import*as D from"path";import{resolve as m,parse as I,dirname as ot,sep as nt}from"path";import{red as it,yellow as rt,green as x}from"kolorist";import*as z from"node:process";import w from"node:process";import{glob as u,globSync as K}from"glob";import{build as J,defineConfig as H}from"vite";import{pathToFileURL as v}from"url";import{builtinModules as Z}from"module";import W from"@vitejs/plugin-vue";import R from"vite-tsconfig-paths";import at from"vite-plugin-checker";import{viteExternalsPlugin as ct}from"vite-plugin-externals";import pt from"ajv/dist/2020.js";import lt from"ajv-formats";import{readFile as V}from"fs/promises";import dt,{AxiosError as Y}from"axios";import{inc as mt}from"semver";import*as l from"process";import{ConcurrencyManager as ft}from"axios-concurrency";import ut from"tinycolor2";import yt from"prompts";function Q(e,t){_.statSync(e).isDirectory()?(_.mkdirSync(t,{recursive:!0}),_.readdirSync(e).forEach(s=>{const o=D.resolve(e,s),n=D.resolve(t,s);Q(o,n)})):_.copyFileSync(e,t)}function k(e,t,s,o){const n=D.join(e,o?.[s]??s);Q(D.join(t,s),n)}function ee(e,t=2){if(!+e)return"0 Bytes";const s=1024,o=t<0?0:t,n=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],i=Math.floor(Math.log(e)/Math.log(s));return`${parseFloat((e/Math.pow(s,i)).toFixed(o))} ${n[i]}`}const p={error:e=>console.log(it(e)),warn:e=>console.log(rt(e)),info:e=>console.log(x(e))},b="_temp",a="dist/sections",C="dist/templates",te=2*1024*1024;function B(e){return!!e}function se(){const e=["|","/","-","\\"];let t=0;return setInterval(()=>{process.stdout.write(`\r${e[t]}`),t=(t+1)%e.length},100)}function U(e){clearInterval(e),process.stdout.write("\r")}async function oe(e){try{const t=e,s=w.cwd(),o=T.join(s,t),n=["templates"],i={_gitignore:".gitignore"};h.existsSync(o)?(p.error(`App with the name: ${e} already exists. If you'd like to override it, delete previous version first`),w.exit(1)):h.mkdirSync(o);const c=T.resolve(P(import.meta.url),"../..","template");h.readdirSync(c).filter(g=>g!=="package.json").filter(g=>!n.includes(g)).forEach(async g=>k(o,c,g,i));const r=JSON.parse(h.readFileSync(T.join(c,"package.json"),"utf-8"));r.name=e;const E=T.join(o,"package.json");h.writeFileSync(E,`${JSON.stringify(r,null,2)}
2
- `),p.info(`App ${e} created`)}catch(t){p.error(`Error while creating app: ${t.message}`),w.exit(1)}}async function ne(e){try{const t=e,s=w.cwd(),o=T.join(s,"sections",t);h.existsSync(o)?(p.error(`Section with the name: ${e} already exists. If you'd like to override it, delete previous version first`),w.exit(1)):h.mkdirSync(o);const n=T.resolve(P(import.meta.url),"../..","template/sections/example-section");h.readdirSync(n).forEach(async i=>k(o,n,i)),p.info(`Section ${e} created`)}catch(t){p.error(`Error while creating section: ${t.message}`),w.exit(1)}}async function ie(e){try{const t=w.cwd(),s=T.join(t,"templates"),o={"template.ts":`${e}.ts`};h.existsSync(s)?h.existsSync(T.join(s,`${e}.ts`))&&(p.error(`Template with the name: ${e} already exists. If you'd like to override it, delete previous version first`),w.exit(1)):h.mkdirSync(s);const n=T.resolve(P(import.meta.url),"../..","template/templates");h.readdirSync(n).forEach(async i=>k(s,n,i,o)),p.info(`Template descriptor file [${e}.ts] has been created`)}catch(t){p.error(`Error while creating template descriptors: ${t.message}`),w.exit(1)}}var f=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.SectionSetting=2]="SectionSetting",e[e.SectionShowcase=3]="SectionShowcase",e[e.SectionAsset=4]="SectionAsset",e[e.TemplateDescriptor=5]="TemplateDescriptor",e[e.TemplateAsset=6]="TemplateAsset",e))(f||{}),$=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.Misc=2]="Misc",e))($||{});const ht={[$.Server]:[W(),R()],[$.Client]:[W(),R(),ae(),ct({vue:"EcVue"})],[$.Misc]:[R(),ae()]},re={"process.env":{NODE_ENV:"production"}},j={[f.Server]:{pluginType:$.Server,define:re,ssr:!0,ssrOptions:{noExternal:!0},outDir:e=>`./${a}/${e}/js/main/server`,externalOption:[...Z,...Z.map(e=>`node:${e}`)],entryFileNames:"[name].js"},[f.Client]:{pluginType:$.Client,define:re,ssr:!1,outDir:e=>`./${a}/${e}/js/main/client`,entryFileNames:"[name].js",chunkFileNames:"[name].js",assetFileNames:"assets/[name].[ext]"},[f.SectionSetting]:{pluginType:$.Misc,ssr:!1,outDir:e=>`./${a}/${e}/js/settings`,entryFileNames:"[name].mjs"},[f.SectionShowcase]:{pluginType:$.Misc,ssr:!1,outDir:e=>`./${a}/${e}/js/showcases`,entryFileNames:"[name].mjs"},[f.SectionAsset]:{pluginType:$.Misc,ssr:!1,outDir:e=>`./${a}/${e}/assets`,assetFileNames:"[name].[ext]"},[f.TemplateDescriptor]:{pluginType:$.Misc,ssr:!1,outDir:()=>`./${C}/js`,entryFileNames:`[name]${b}.mjs`},[f.TemplateAsset]:{pluginType:$.Misc,ssr:!1,outDir:()=>`./${C}/assets`,assetFileNames:"[name].[ext]"}};function gt(e){switch(typeof e){case"string":return[m(process.cwd(),e)];case"object":return e.map(t=>m(process.cwd(),t));default:return[]}}function ae(){const e=process.env.npm_lifecycle_event;return at({typescript:!0,vueTsc:!1,eslint:{lintCommand:`eslint --max-warnings=0 "./sections/**/*.{js,ts,vue}" --cache --cache-location "./build/eslintcache/${e}.json"`}})}function ce(e,t,s){const o=j[s].define,n=j[s].ssrOptions,i=j[s].externalOption,c=j[s].entryFileNames,r=j[s].chunkFileNames,E=j[s].assetFileNames;return{plugins:ht[j[s].pluginType],...o!=null&&{define:o},...n!=null&&{ssr:n},resolve:{alias:{"@":"/src"}},build:{ssr:j[s].ssr,outDir:j[s].outDir(e),emptyOutDir:!0,rollupOptions:{...i!=null&&{external:i},preserveEntrySignatures:"strict",input:gt(t),output:{validate:!0,...c!=null&&{entryFileNames:c},...r!=null&&{chunkFileNames:r},...E!=null&&{assetFileNames:E}}}}}}const pe="https://json-schema.org/draft/2020-12/schema",le="https://lightspeedhq.com/template.schema.json",de="Custom Template",me="A custom template enclosing the necessary custom and default blocks",fe="object",ue={metadata:{type:"object",properties:{name:{description:"Name of the template",type:"string",minLength:2,maxLength:60},description:{description:"Short description of the template",type:"string",minLength:2,maxLength:150},preview_url:{description:"Preview url of the demo website",type:"string",format:"uri",pattern:"^(https?)://([^.]+?\\.)company\\.site($|/[A-Za-z0-9\\-._~:/?#\\[\\]@!$&'()*+,;=]*)?$"},cover_image:{type:"object",properties:{set:{description:"Name of the image set",type:"object",patternProperties:{".*":{type:"object",properties:{url:{description:"Path to the preview image relative to the 'assets' folder for a specific resolution",type:"string"}},required:["url"],additionalProperties:!1}}}},required:["set"],additionalProperties:!1}},required:["name","description","cover_image"],additionalProperties:!1},sections:{description:"List of sections contained by this template",type:"array",items:{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]}},allOf:[{if:{properties:{type:{const:"default"}}},then:{$ref:"template-default.schema.json#/$defs/default-section"}},{if:{properties:{type:{const:"custom"}}},then:{$ref:"template-custom.schema.json#/$defs/custom-section"}}]},minItems:1,uniqueItems:!1}},ye=["metadata","sections"],$t={$schema:pe,$id:le,title:de,description:me,type:fe,properties:ue,required:ye},he={__proto__:null,$id:le,$schema:pe,default:$t,description:me,properties:ue,required:ye,title:de,type:fe},ge="https://json-schema.org/draft/2020-12/schema",$e="https://lightspeedhq.com/template-default.schema.json",Ee="Default Section",Te="Default section for a Custom Template",we="object",je={"default-section":{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]},id:{description:"Identification of the section",type:"string",pattern:"^((header|cover|announcement_bar|slider|special_offer|customer_review|company_info|shipping_payment|location|store|footer)(_\\d{3})?)$"}},required:["type","id"],additionalProperties:!1}},Et={$schema:ge,$id:$e,title:Ee,description:Te,type:we,$defs:je},Tt={__proto__:null,$defs:je,$id:$e,$schema:ge,default:Et,description:Te,title:Ee,type:we},Oe="https://json-schema.org/draft/2020-12/schema",ve="https://lightspeedhq.com/template-custom.schema.json",Se="Custom Section",be="Custom section for a Custom Template",Ce="object",Ae={"custom-section":{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]},id:{description:"Identification of the section",type:"string"},showcase_id:{description:"Showcase id of the section",type:"string"},showcase_overrides:{type:"object",description:"Overrides for the showcase",properties:{content:{type:"object",patternProperties:{".*":{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]}},allOf:[{if:{properties:{type:{const:"INPUTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/input_box"}},{if:{properties:{type:{const:"TEXTAREA"}}},then:{$ref:"template-custom-content.schema.json#/$defs/text_area"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"template-custom-content.schema.json#/$defs/button"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/select_box"}}]}},minProperties:1},design:{type:"object",patternProperties:{".*":{type:"object",properties:{type:{description:"Type of the design configuration element",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]}},allOf:[{if:{properties:{type:{const:"TEXT"}}},then:{$ref:"template-custom-design.schema.json#/$defs/text"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"template-custom-design.schema.json#/$defs/button"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"template-custom-design.schema.json#/$defs/image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"template-custom-design.schema.json#/$defs/toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"template-custom-design.schema.json#/$defs/select_box"}},{if:{properties:{type:{const:"BACKGROUND"}}},then:{$ref:"template-custom-design.schema.json#/$defs/background"}}]}},minProperties:1},layoutId:{description:"Layout ID for the showcase",type:"string"},blockName:{description:"Section name for the showcase",type:"string"}},required:["content","design"]}},required:["type","id"],additionalProperties:!1}},wt={$schema:Oe,$id:ve,title:Se,description:be,type:Ce,$defs:Ae},jt={__proto__:null,$defs:Ae,$id:ve,$schema:Oe,default:wt,description:be,title:Se,type:Ce},Ne="https://json-schema.org/draft/2020-12/schema",Le="https://lightspeedhq.com/template-custom-content.schema.json",_e="Custom Section :: Content Configuration",De="Content tab configuration of a Custom Section for a Custom Template",Ie="object",xe={input_box:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},text:{type:"string"}},required:["type","text"],additionalProperties:!1},text_area:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},text:{type:"string"}},required:["type","text"],additionalProperties:!1},button:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},title:{type:"string"},buttonType:{type:"string",enum:["SCROLL_TO_TILE","HYPER_LINK","MAIL_LINK","TEL_LINK","GO_TO_STORE_LINK","GO_TO_PAGE"]},link:{type:"string",format:"uri"},linkTarget:{type:"string"},email:{type:"string"},phone:{type:"string"},tileId:{type:"string"}},required:["type","title"],additionalProperties:!1},image:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},imageData:{type:"object",properties:{set:{type:"object"},borderInfo:{type:"object"},bucket:{type:"string"}},required:["set"]}},required:["type"],additionalProperties:!1},toggle:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},enabled:{type:"boolean"}},required:["type"],additionalProperties:!1},select_box:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},value:{type:"string"}},required:["type"],additionalProperties:!1}},Ot={$schema:Ne,$id:Le,title:_e,description:De,type:Ie,$defs:xe},vt={__proto__:null,$defs:xe,$id:Le,$schema:Ne,default:Ot,description:De,title:_e,type:Ie},Ge="https://json-schema.org/draft/2020-12/schema",Pe="https://lightspeedhq.com/template-custom-design.schema.json",Re="Custom Section :: Design Configuration",ke="Design tab configuration of a Custom Section for a Custom Template",Be="object",Ue={text:{type:"object",properties:{type:{description:"Type of the text",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},font:{description:"Default font for the text",type:"string"},size:{description:"Default size for the text",type:"integer",minimum:1,exclusiveMaximum:50},bold:{description:"Default boldness for the text",type:"boolean"},italic:{description:"Default italic style for the text",type:"boolean"},color:{description:"Default color for the text",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},visible:{description:"Default visibility for the text",type:"boolean"}},additionalProperties:!1},button:{type:"object",properties:{type:{description:"Type of the button",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},font:{description:"Default font for the button",type:"string"},size:{description:"Default size for the button",type:"string",enum:["SMALL","MEDIUM","LARGE"]},appearance:{description:"Default appearance for the button",type:"string",enum:["SOLID","OUTLINE","TEXT"]},shape:{description:"Default shape for the button",type:"string",enum:["ROUND_CORNER","RECTANGLE","PILL"]},color:{description:"Default color for the button",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"}},additionalProperties:!1},image:{type:"object",properties:{type:{description:"Type of the image",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},overlay:{description:"Default overlay for the image",type:"string",enum:["COLOR","GRADIENT","NONE"]}},if:{properties:{overlay:{const:"GRADIENT"}}},then:{properties:{color:{description:"Default color for the image",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},minItems:2,maxItems:2}}},else:{properties:{color:{description:"Default color for the image",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"}}}},toggle:{type:"object",properties:{type:{description:"Type of the toggle",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},enabled:{description:"Default enabled status for the toggle",type:"boolean"}},additionalProperties:!1},select_box:{type:"object",properties:{type:{description:"Type of the checkbox",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},value:{description:"Default option for the checkbox",type:"string"}},additionalProperties:!1},background:{type:"object",properties:{type:{description:"Type of the background",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},style:{description:"Default style for the background",type:"string",enum:["COLOR","GRADIENT"]}},if:{properties:{style:{const:"GRADIENT"}}},then:{properties:{color:{description:"Default colors for the image",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},minItems:2,maxItems:2}}},else:{properties:{color:{description:"Default color for the image",type:"string"}}}}},St={$schema:Ge,$id:Pe,title:Re,description:ke,type:Be,$defs:Ue},bt={__proto__:null,$defs:Ue,$id:Pe,$schema:Ge,default:St,description:ke,title:Re,type:Be};async function Ct(){const e=await u("**/server.{js,ts}",{ignore:["node_modules/**","dist/**","headers/**","footers/**"]});return Promise.all(e.map(async t=>{const s=ot(t).split(nt).pop()??"default",o=await u(`**/${s}/client.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),n=await u(`**/${s}/settings/content.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await u(`**/${s}/settings/design.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),c=await u(`**/${s}/settings/layout.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),r=await u(`**/${s}/settings/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),E=await u(`**/${s}/showcases/*.{js,ts}`,{ignore:["node_modules/**","dist/**",`**/${s}/showcases/translations.{js,ts}`]}),g=await u(`**/${s}/showcases/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),G=await u(`**/${s}/assets/*`,{ignore:["node_modules/**","dist/**"]});return{name:s,serverEntrypoint:t,clientEntrypoint:o.at(0),contentSettingsEntrypoint:n.at(0),designSettingsEntrypoint:i.at(0),layoutSettingsEntrypoint:c.at(0),settingsTranslationsEntrypoint:r.at(0),showcasesEntrypoints:E,showcasesTranslationsEntrypoint:g.at(0),assetsEntrypoints:G}}))}async function At(){const e=await u("./templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]}),t=await u("./templates/assets/*",{ignore:["node_modules/**","dist/**"]});return{templates:e,assets:t}}async function M(e,t){try{const s=m(z.cwd(),t?`${e}${b}.mjs`:`${e}.mjs`);return(await import(v(s).href)).default}catch{throw new Error(`File [${e}${b}.mjs] is either invalid or undefined`)}}async function Nt(){let e=new pt({allErrors:!0,schemas:[he,Tt,jt,vt,bt]});return lt(e),e.compile(he)}async function Lt(e,t,s,o){if(e(t)&&o===void 0)new Promise(n=>{Ye(`${s}${b}.mjs`,`${s}.mjs`,function(i){i&&n(i)})});else throw new Promise(n=>{Qe(`${s}${b}.mjs`,function(i){i&&n(i)})}),new Error(`Invalid file [${I(s).name}].
1
+ import bn from"cac";import S from"node:fs";import F from"node:path";import{fileURLToPath as J}from"node:url";import*as V from"fs";import de,{existsSync as R,rename as Cn,unlink as En,statSync as wn,promises as $n,writeFileSync as vn,createReadStream as Tn}from"fs";import*as Q from"path";import ee,{resolve as E,parse as te,dirname as On,sep as jn}from"path";import{red as Sn,yellow as An,green as ne}from"kolorist";import*as Ge from"node:process";import M from"node:process";import{glob as O,globSync as Ue}from"glob";import{normalizePath as Xe,build as ze,defineConfig as qe}from"vite";import{pathToFileURL as G}from"url";import{builtinModules as Ke}from"module";import He from"@vitejs/plugin-vue";import me from"vite-tsconfig-paths";import{viteExternalsPlugin as kn}from"vite-plugin-externals";import se from"fs-extra";import Fn from"os";import Je from"tty";import B from"zlib";import xn from"util";import _n from"vite-plugin-checker";import Rn from"ajv/dist/2020.js";import In from"ajv-formats";import{readFile as We}from"fs/promises";import Nn,{AxiosError as Ye}from"axios";import{inc as Ln}from"semver";import*as C from"process";import{ConcurrencyManager as Mn}from"axios-concurrency";import Dn from"tinycolor2";import Bn from"prompts";function Ze(e,t){V.statSync(e).isDirectory()?(V.mkdirSync(t,{recursive:!0}),V.readdirSync(e).forEach(s=>{const r=Q.resolve(e,s),n=Q.resolve(t,s);Ze(r,n)})):V.copyFileSync(e,t)}function oe(e,t,s,r){const n=Q.join(e,r?.[s]??s);Ze(Q.join(t,s),n)}function Ve(e,t=2){if(!+e)return"0 Bytes";const s=1024,r=t<0?0:t,n=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],o=Math.floor(Math.log(e)/Math.log(s));return`${parseFloat((e/Math.pow(s,o)).toFixed(r))} ${n[o]}`}const b={error:e=>console.log(Sn(e)),warn:e=>console.log(An(e)),info:e=>console.log(ne(e))},X="_temp",A="dist/sections",he="dist/headers",ye="dist/footers",z="dist/templates",Qe=2*1024*1024;function ge(e){return!!e}function et(){const e=["|","/","-","\\"];let t=0;return setInterval(()=>{process.stdout.write(`\r${e[t]}`),t=(t+1)%e.length},100)}function be(e){clearInterval(e),process.stdout.write("\r")}async function tt(e){try{const t=e,s=M.cwd(),r=F.join(s,t),n=["templates","headers","footers"],o={_gitignore:".gitignore"};S.existsSync(r)?(b.error(`App with the name: ${e} already exists. If you'd like to override it, delete previous version first`),M.exit(1)):S.mkdirSync(r);const i=F.resolve(J(import.meta.url),"../..","template");S.readdirSync(i).filter(u=>u!=="package.json").filter(u=>!n.includes(u)).forEach(async u=>oe(r,i,u,o));const c=JSON.parse(S.readFileSync(F.join(i,"package.json"),"utf-8"));c.name=e;const a=F.join(r,"package.json");S.writeFileSync(a,`${JSON.stringify(c,null,2)}
2
+ `),b.info(`App ${e} created`)}catch(t){b.error(`Error while creating app: ${t.message}`),M.exit(1)}}async function nt(e){try{const t=e,s=M.cwd(),r=F.join(s,"sections",t);S.existsSync(r)?(b.error(`Section with the name: ${e} already exists. If you'd like to override it, delete previous version first`),M.exit(1)):S.mkdirSync(r);const n=F.resolve(J(import.meta.url),"../..","template/sections/example-section");S.readdirSync(n).forEach(async o=>oe(r,n,o)),b.info(`Section ${e} created`)}catch(t){b.error(`Error while creating section: ${t.message}`),M.exit(1)}}async function st(e,t=!1){try{const s=M.cwd(),r=F.join(s,"templates"),n={"template.ts":`${e}.ts`};S.existsSync(r)?S.existsSync(F.join(r,`${e}.ts`))&&(b.error(`Template with the name: ${e} already exists. If you'd like to override it, delete previous version first`),M.exit(1)):S.mkdirSync(r);const o=F.resolve(J(import.meta.url),"../..","template/templates");if(S.readdirSync(o).forEach(async i=>oe(r,o,i,n)),t){const i={headers:F.resolve(J(import.meta.url),"../..","template/headers"),footers:F.resolve(J(import.meta.url),"../..","template/footers")};["headers","footers"].forEach(c=>{const a=F.join(s,c);if(!S.existsSync(a)){S.mkdirSync(a);const u=i[c];S.readdirSync(u).forEach(async p=>oe(a,u,p))}})}b.info(`Template descriptor file [${e}.ts] has been created`)}catch(s){b.error(`Error while creating template descriptors: ${s.message}`),M.exit(1)}}var j=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.SectionSetting=2]="SectionSetting",e[e.SectionShowcase=3]="SectionShowcase",e[e.SectionAsset=4]="SectionAsset",e[e.TemplateDescriptor=5]="TemplateDescriptor",e[e.TemplateAsset=6]="TemplateAsset",e))(j||{}),_=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.Misc=2]="Misc",e))(_||{});function ot(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ce={exports:{}},Ee,rt;function Pn(){return rt||(rt=1,Ee={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),Ee}var we,it;function at(){if(it)return we;it=1;const e=Pn(),t={};for(const n of Object.keys(e))t[e[n]]=n;const s={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};we=s;for(const n of Object.keys(s)){if(!("channels"in s[n]))throw new Error("missing channels property: "+n);if(!("labels"in s[n]))throw new Error("missing channel labels property: "+n);if(s[n].labels.length!==s[n].channels)throw new Error("channel and label counts mismatch: "+n);const{channels:o,labels:i}=s[n];delete s[n].channels,delete s[n].labels,Object.defineProperty(s[n],"channels",{value:o}),Object.defineProperty(s[n],"labels",{value:i})}s.rgb.hsl=function(n){const o=n[0]/255,i=n[1]/255,c=n[2]/255,a=Math.min(o,i,c),u=Math.max(o,i,c),p=u-a;let l,f;u===a?l=0:o===u?l=(i-c)/p:i===u?l=2+(c-o)/p:c===u&&(l=4+(o-i)/p),l=Math.min(l*60,360),l<0&&(l+=360);const d=(a+u)/2;return u===a?f=0:d<=.5?f=p/(u+a):f=p/(2-u-a),[l,f*100,d*100]},s.rgb.hsv=function(n){let o,i,c,a,u;const p=n[0]/255,l=n[1]/255,f=n[2]/255,d=Math.max(p,l,f),m=d-Math.min(p,l,f),h=function(g){return(d-g)/6/m+1/2};return m===0?(a=0,u=0):(u=m/d,o=h(p),i=h(l),c=h(f),p===d?a=c-i:l===d?a=1/3+o-c:f===d&&(a=2/3+i-o),a<0?a+=1:a>1&&(a-=1)),[a*360,u*100,d*100]},s.rgb.hwb=function(n){const o=n[0],i=n[1];let c=n[2];const a=s.rgb.hsl(n)[0],u=1/255*Math.min(o,Math.min(i,c));return c=1-1/255*Math.max(o,Math.max(i,c)),[a,u*100,c*100]},s.rgb.cmyk=function(n){const o=n[0]/255,i=n[1]/255,c=n[2]/255,a=Math.min(1-o,1-i,1-c),u=(1-o-a)/(1-a)||0,p=(1-i-a)/(1-a)||0,l=(1-c-a)/(1-a)||0;return[u*100,p*100,l*100,a*100]};function r(n,o){return(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}return s.rgb.keyword=function(n){const o=t[n];if(o)return o;let i=1/0,c;for(const a of Object.keys(e)){const u=e[a],p=r(n,u);p<i&&(i=p,c=a)}return c},s.keyword.rgb=function(n){return e[n]},s.rgb.xyz=function(n){let o=n[0]/255,i=n[1]/255,c=n[2]/255;o=o>.04045?((o+.055)/1.055)**2.4:o/12.92,i=i>.04045?((i+.055)/1.055)**2.4:i/12.92,c=c>.04045?((c+.055)/1.055)**2.4:c/12.92;const a=o*.4124+i*.3576+c*.1805,u=o*.2126+i*.7152+c*.0722,p=o*.0193+i*.1192+c*.9505;return[a*100,u*100,p*100]},s.rgb.lab=function(n){const o=s.rgb.xyz(n);let i=o[0],c=o[1],a=o[2];i/=95.047,c/=100,a/=108.883,i=i>.008856?i**(1/3):7.787*i+16/116,c=c>.008856?c**(1/3):7.787*c+16/116,a=a>.008856?a**(1/3):7.787*a+16/116;const u=116*c-16,p=500*(i-c),l=200*(c-a);return[u,p,l]},s.hsl.rgb=function(n){const o=n[0]/360,i=n[1]/100,c=n[2]/100;let a,u,p;if(i===0)return p=c*255,[p,p,p];c<.5?a=c*(1+i):a=c+i-c*i;const l=2*c-a,f=[0,0,0];for(let d=0;d<3;d++)u=o+1/3*-(d-1),u<0&&u++,u>1&&u--,6*u<1?p=l+(a-l)*6*u:2*u<1?p=a:3*u<2?p=l+(a-l)*(2/3-u)*6:p=l,f[d]=p*255;return f},s.hsl.hsv=function(n){const o=n[0];let i=n[1]/100,c=n[2]/100,a=i;const u=Math.max(c,.01);c*=2,i*=c<=1?c:2-c,a*=u<=1?u:2-u;const p=(c+i)/2,l=c===0?2*a/(u+a):2*i/(c+i);return[o,l*100,p*100]},s.hsv.rgb=function(n){const o=n[0]/60,i=n[1]/100;let c=n[2]/100;const a=Math.floor(o)%6,u=o-Math.floor(o),p=255*c*(1-i),l=255*c*(1-i*u),f=255*c*(1-i*(1-u));switch(c*=255,a){case 0:return[c,f,p];case 1:return[l,c,p];case 2:return[p,c,f];case 3:return[p,l,c];case 4:return[f,p,c];case 5:return[c,p,l]}},s.hsv.hsl=function(n){const o=n[0],i=n[1]/100,c=n[2]/100,a=Math.max(c,.01);let u,p;p=(2-i)*c;const l=(2-i)*a;return u=i*a,u/=l<=1?l:2-l,u=u||0,p/=2,[o,u*100,p*100]},s.hwb.rgb=function(n){const o=n[0]/360;let i=n[1]/100,c=n[2]/100;const a=i+c;let u;a>1&&(i/=a,c/=a);const p=Math.floor(6*o),l=1-c;u=6*o-p,p&1&&(u=1-u);const f=i+u*(l-i);let d,m,h;switch(p){default:case 6:case 0:d=l,m=f,h=i;break;case 1:d=f,m=l,h=i;break;case 2:d=i,m=l,h=f;break;case 3:d=i,m=f,h=l;break;case 4:d=f,m=i,h=l;break;case 5:d=l,m=i,h=f;break}return[d*255,m*255,h*255]},s.cmyk.rgb=function(n){const o=n[0]/100,i=n[1]/100,c=n[2]/100,a=n[3]/100,u=1-Math.min(1,o*(1-a)+a),p=1-Math.min(1,i*(1-a)+a),l=1-Math.min(1,c*(1-a)+a);return[u*255,p*255,l*255]},s.xyz.rgb=function(n){const o=n[0]/100,i=n[1]/100,c=n[2]/100;let a,u,p;return a=o*3.2406+i*-1.5372+c*-.4986,u=o*-.9689+i*1.8758+c*.0415,p=o*.0557+i*-.204+c*1.057,a=a>.0031308?1.055*a**(1/2.4)-.055:a*12.92,u=u>.0031308?1.055*u**(1/2.4)-.055:u*12.92,p=p>.0031308?1.055*p**(1/2.4)-.055:p*12.92,a=Math.min(Math.max(0,a),1),u=Math.min(Math.max(0,u),1),p=Math.min(Math.max(0,p),1),[a*255,u*255,p*255]},s.xyz.lab=function(n){let o=n[0],i=n[1],c=n[2];o/=95.047,i/=100,c/=108.883,o=o>.008856?o**(1/3):7.787*o+16/116,i=i>.008856?i**(1/3):7.787*i+16/116,c=c>.008856?c**(1/3):7.787*c+16/116;const a=116*i-16,u=500*(o-i),p=200*(i-c);return[a,u,p]},s.lab.xyz=function(n){const o=n[0],i=n[1],c=n[2];let a,u,p;u=(o+16)/116,a=i/500+u,p=u-c/200;const l=u**3,f=a**3,d=p**3;return u=l>.008856?l:(u-16/116)/7.787,a=f>.008856?f:(a-16/116)/7.787,p=d>.008856?d:(p-16/116)/7.787,a*=95.047,u*=100,p*=108.883,[a,u,p]},s.lab.lch=function(n){const o=n[0],i=n[1],c=n[2];let a;a=Math.atan2(c,i)*360/2/Math.PI,a<0&&(a+=360);const p=Math.sqrt(i*i+c*c);return[o,p,a]},s.lch.lab=function(n){const o=n[0],i=n[1],a=n[2]/360*2*Math.PI,u=i*Math.cos(a),p=i*Math.sin(a);return[o,u,p]},s.rgb.ansi16=function(n,o=null){const[i,c,a]=n;let u=o===null?s.rgb.hsv(n)[2]:o;if(u=Math.round(u/50),u===0)return 30;let p=30+(Math.round(a/255)<<2|Math.round(c/255)<<1|Math.round(i/255));return u===2&&(p+=60),p},s.hsv.ansi16=function(n){return s.rgb.ansi16(s.hsv.rgb(n),n[2])},s.rgb.ansi256=function(n){const o=n[0],i=n[1],c=n[2];return o===i&&i===c?o<8?16:o>248?231:Math.round((o-8)/247*24)+232:16+36*Math.round(o/255*5)+6*Math.round(i/255*5)+Math.round(c/255*5)},s.ansi16.rgb=function(n){let o=n%10;if(o===0||o===7)return n>50&&(o+=3.5),o=o/10.5*255,[o,o,o];const i=(~~(n>50)+1)*.5,c=(o&1)*i*255,a=(o>>1&1)*i*255,u=(o>>2&1)*i*255;return[c,a,u]},s.ansi256.rgb=function(n){if(n>=232){const u=(n-232)*10+8;return[u,u,u]}n-=16;let o;const i=Math.floor(n/36)/5*255,c=Math.floor((o=n%36)/6)/5*255,a=o%6/5*255;return[i,c,a]},s.rgb.hex=function(n){const i=(((Math.round(n[0])&255)<<16)+((Math.round(n[1])&255)<<8)+(Math.round(n[2])&255)).toString(16).toUpperCase();return"000000".substring(i.length)+i},s.hex.rgb=function(n){const o=n.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!o)return[0,0,0];let i=o[0];o[0].length===3&&(i=i.split("").map(l=>l+l).join(""));const c=parseInt(i,16),a=c>>16&255,u=c>>8&255,p=c&255;return[a,u,p]},s.rgb.hcg=function(n){const o=n[0]/255,i=n[1]/255,c=n[2]/255,a=Math.max(Math.max(o,i),c),u=Math.min(Math.min(o,i),c),p=a-u;let l,f;return p<1?l=u/(1-p):l=0,p<=0?f=0:a===o?f=(i-c)/p%6:a===i?f=2+(c-o)/p:f=4+(o-i)/p,f/=6,f%=1,[f*360,p*100,l*100]},s.hsl.hcg=function(n){const o=n[1]/100,i=n[2]/100,c=i<.5?2*o*i:2*o*(1-i);let a=0;return c<1&&(a=(i-.5*c)/(1-c)),[n[0],c*100,a*100]},s.hsv.hcg=function(n){const o=n[1]/100,i=n[2]/100,c=o*i;let a=0;return c<1&&(a=(i-c)/(1-c)),[n[0],c*100,a*100]},s.hcg.rgb=function(n){const o=n[0]/360,i=n[1]/100,c=n[2]/100;if(i===0)return[c*255,c*255,c*255];const a=[0,0,0],u=o%1*6,p=u%1,l=1-p;let f=0;switch(Math.floor(u)){case 0:a[0]=1,a[1]=p,a[2]=0;break;case 1:a[0]=l,a[1]=1,a[2]=0;break;case 2:a[0]=0,a[1]=1,a[2]=p;break;case 3:a[0]=0,a[1]=l,a[2]=1;break;case 4:a[0]=p,a[1]=0,a[2]=1;break;default:a[0]=1,a[1]=0,a[2]=l}return f=(1-i)*c,[(i*a[0]+f)*255,(i*a[1]+f)*255,(i*a[2]+f)*255]},s.hcg.hsv=function(n){const o=n[1]/100,i=n[2]/100,c=o+i*(1-o);let a=0;return c>0&&(a=o/c),[n[0],a*100,c*100]},s.hcg.hsl=function(n){const o=n[1]/100,c=n[2]/100*(1-o)+.5*o;let a=0;return c>0&&c<.5?a=o/(2*c):c>=.5&&c<1&&(a=o/(2*(1-c))),[n[0],a*100,c*100]},s.hcg.hwb=function(n){const o=n[1]/100,i=n[2]/100,c=o+i*(1-o);return[n[0],(c-o)*100,(1-c)*100]},s.hwb.hcg=function(n){const o=n[1]/100,c=1-n[2]/100,a=c-o;let u=0;return a<1&&(u=(c-a)/(1-a)),[n[0],a*100,u*100]},s.apple.rgb=function(n){return[n[0]/65535*255,n[1]/65535*255,n[2]/65535*255]},s.rgb.apple=function(n){return[n[0]/255*65535,n[1]/255*65535,n[2]/255*65535]},s.gray.rgb=function(n){return[n[0]/100*255,n[0]/100*255,n[0]/100*255]},s.gray.hsl=function(n){return[0,0,n[0]]},s.gray.hsv=s.gray.hsl,s.gray.hwb=function(n){return[0,100,n[0]]},s.gray.cmyk=function(n){return[0,0,0,n[0]]},s.gray.lab=function(n){return[n[0],0,0]},s.gray.hex=function(n){const o=Math.round(n[0]/100*255)&255,c=((o<<16)+(o<<8)+o).toString(16).toUpperCase();return"000000".substring(c.length)+c},s.rgb.gray=function(n){return[(n[0]+n[1]+n[2])/3/255*100]},we}var $e,ct;function Gn(){if(ct)return $e;ct=1;const e=at();function t(){const o={},i=Object.keys(e);for(let c=i.length,a=0;a<c;a++)o[i[a]]={distance:-1,parent:null};return o}function s(o){const i=t(),c=[o];for(i[o].distance=0;c.length;){const a=c.pop(),u=Object.keys(e[a]);for(let p=u.length,l=0;l<p;l++){const f=u[l],d=i[f];d.distance===-1&&(d.distance=i[a].distance+1,d.parent=a,c.unshift(f))}}return i}function r(o,i){return function(c){return i(o(c))}}function n(o,i){const c=[i[o].parent,o];let a=e[i[o].parent][o],u=i[o].parent;for(;i[u].parent;)c.unshift(i[u].parent),a=r(e[i[u].parent][u],a),u=i[u].parent;return a.conversion=c,a}return $e=function(o){const i=s(o),c={},a=Object.keys(i);for(let u=a.length,p=0;p<u;p++){const l=a[p];i[l].parent!==null&&(c[l]=n(l,i))}return c},$e}var ve,lt;function Un(){if(lt)return ve;lt=1;const e=at(),t=Gn(),s={},r=Object.keys(e);function n(i){const c=function(...a){const u=a[0];return u==null?u:(u.length>1&&(a=u),i(a))};return"conversion"in i&&(c.conversion=i.conversion),c}function o(i){const c=function(...a){const u=a[0];if(u==null)return u;u.length>1&&(a=u);const p=i(a);if(typeof p=="object")for(let l=p.length,f=0;f<l;f++)p[f]=Math.round(p[f]);return p};return"conversion"in i&&(c.conversion=i.conversion),c}return r.forEach(i=>{s[i]={},Object.defineProperty(s[i],"channels",{value:e[i].channels}),Object.defineProperty(s[i],"labels",{value:e[i].labels});const c=t(i);Object.keys(c).forEach(u=>{const p=c[u];s[i][u]=o(p),s[i][u].raw=n(p)})}),ve=s,ve}Ce.exports,function(e){const t=(p,l)=>(...f)=>`\x1B[${p(...f)+l}m`,s=(p,l)=>(...f)=>{const d=p(...f);return`\x1B[${38+l};5;${d}m`},r=(p,l)=>(...f)=>{const d=p(...f);return`\x1B[${38+l};2;${d[0]};${d[1]};${d[2]}m`},n=p=>p,o=(p,l,f)=>[p,l,f],i=(p,l,f)=>{Object.defineProperty(p,l,{get:()=>{const d=f();return Object.defineProperty(p,l,{value:d,enumerable:!0,configurable:!0}),d},enumerable:!0,configurable:!0})};let c;const a=(p,l,f,d)=>{c===void 0&&(c=Un());const m=d?10:0,h={};for(const[g,y]of Object.entries(c)){const T=g==="ansi16"?"ansi":g;g===l?h[T]=p(f,m):typeof y=="object"&&(h[T]=p(y[l],m))}return h};function u(){const p=new Map,l={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};l.color.gray=l.color.blackBright,l.bgColor.bgGray=l.bgColor.bgBlackBright,l.color.grey=l.color.blackBright,l.bgColor.bgGrey=l.bgColor.bgBlackBright;for(const[f,d]of Object.entries(l)){for(const[m,h]of Object.entries(d))l[m]={open:`\x1B[${h[0]}m`,close:`\x1B[${h[1]}m`},d[m]=l[m],p.set(h[0],h[1]);Object.defineProperty(l,f,{value:d,enumerable:!1})}return Object.defineProperty(l,"codes",{value:p,enumerable:!1}),l.color.close="\x1B[39m",l.bgColor.close="\x1B[49m",i(l.color,"ansi",()=>a(t,"ansi16",n,!1)),i(l.color,"ansi256",()=>a(s,"ansi256",n,!1)),i(l.color,"ansi16m",()=>a(r,"rgb",o,!1)),i(l.bgColor,"ansi",()=>a(t,"ansi16",n,!0)),i(l.bgColor,"ansi256",()=>a(s,"ansi256",n,!0)),i(l.bgColor,"ansi16m",()=>a(r,"rgb",o,!0)),l}Object.defineProperty(e,"exports",{enumerable:!0,get:u})}(Ce);var Xn=Ce.exports,zn=(e,t=process.argv)=>{const s=e.startsWith("-")?"":e.length===1?"-":"--",r=t.indexOf(s+e),n=t.indexOf("--");return r!==-1&&(n===-1||r<n)};const qn=Fn,ut=Je,x=zn,{env:$}=process;let P;x("no-color")||x("no-colors")||x("color=false")||x("color=never")?P=0:(x("color")||x("colors")||x("color=true")||x("color=always"))&&(P=1),"FORCE_COLOR"in $&&($.FORCE_COLOR==="true"?P=1:$.FORCE_COLOR==="false"?P=0:P=$.FORCE_COLOR.length===0?1:Math.min(parseInt($.FORCE_COLOR,10),3));function Te(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Oe(e,t){if(P===0)return 0;if(x("color=16m")||x("color=full")||x("color=truecolor"))return 3;if(x("color=256"))return 2;if(e&&!t&&P===void 0)return 0;const s=P||0;if($.TERM==="dumb")return s;if(process.platform==="win32"){const r=qn.release().split(".");return Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in $)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(r=>r in $)||$.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in $)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test($.TEAMCITY_VERSION)?1:0;if($.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in $){const r=parseInt(($.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch($.TERM_PROGRAM){case"iTerm.app":return r>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test($.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test($.TERM)||"COLORTERM"in $?1:s}function Kn(e){const t=Oe(e,e&&e.isTTY);return Te(t)}var pt={supportsColor:Kn,stdout:Te(Oe(!0,ut.isatty(1))),stderr:Te(Oe(!0,ut.isatty(2)))};const Hn=(e,t,s)=>{let r=e.indexOf(t);if(r===-1)return e;const n=t.length;let o=0,i="";do i+=e.substr(o,r-o)+t+s,o=r+n,r=e.indexOf(t,o);while(r!==-1);return i+=e.substr(o),i},Jn=(e,t,s,r)=>{let n=0,o="";do{const i=e[r-1]==="\r";o+=e.substr(n,(i?r-1:r)-n)+t+(i?`\r
3
+ `:`
4
+ `)+s,n=r+1,r=e.indexOf(`
5
+ `,n)}while(r!==-1);return o+=e.substr(n),o};var Wn={stringReplaceAll:Hn,stringEncaseCRLFWithFirstIndex:Jn},je,ft;function Yn(){if(ft)return je;ft=1;const e=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,t=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,s=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,r=/\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,n=new Map([["n",`
6
+ `],["r","\r"],["t"," "],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e","\x1B"],["a","\x07"]]);function o(u){const p=u[0]==="u",l=u[1]==="{";return p&&!l&&u.length===5||u[0]==="x"&&u.length===3?String.fromCharCode(parseInt(u.slice(1),16)):p&&l?String.fromCodePoint(parseInt(u.slice(2,-1),16)):n.get(u)||u}function i(u,p){const l=[],f=p.trim().split(/\s*,\s*/g);let d;for(const m of f){const h=Number(m);if(!Number.isNaN(h))l.push(h);else if(d=m.match(s))l.push(d[2].replace(r,(g,y,T)=>y?o(y):T));else throw new Error(`Invalid Chalk template style argument: ${m} (in style '${u}')`)}return l}function c(u){t.lastIndex=0;const p=[];let l;for(;(l=t.exec(u))!==null;){const f=l[1];if(l[2]){const d=i(f,l[2]);p.push([f].concat(d))}else p.push([f])}return p}function a(u,p){const l={};for(const d of p)for(const m of d.styles)l[m[0]]=d.inverse?null:m.slice(1);let f=u;for(const[d,m]of Object.entries(l))if(Array.isArray(m)){if(!(d in f))throw new Error(`Unknown Chalk style: ${d}`);f=m.length>0?f[d](...m):f[d]}return f}return je=(u,p)=>{const l=[],f=[];let d=[];if(p.replace(e,(m,h,g,y,T,N)=>{if(h)d.push(o(h));else if(y){const L=d.join("");d=[],f.push(l.length===0?L:a(u,l)(L)),l.push({inverse:g,styles:c(y)})}else if(T){if(l.length===0)throw new Error("Found extraneous } in Chalk template literal");f.push(a(u,l)(d.join(""))),d=[],l.pop()}else d.push(N)}),f.push(d.join("")),l.length>0){const m=`Chalk template literal is missing ${l.length} closing bracket${l.length===1?"":"s"} (\`}\`)`;throw new Error(m)}return f.join("")},je}const W=Xn,{stdout:Se,stderr:Ae}=pt,{stringReplaceAll:Zn,stringEncaseCRLFWithFirstIndex:Vn}=Wn,{isArray:re}=Array,dt=["ansi","ansi","ansi256","ansi16m"],q=Object.create(null),Qn=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const s=Se?Se.level:0;e.level=t.level===void 0?s:t.level};class es{constructor(t){return mt(t)}}const mt=e=>{const t={};return Qn(t,e),t.template=(...s)=>gt(t.template,...s),Object.setPrototypeOf(t,ie.prototype),Object.setPrototypeOf(t.template,t),t.template.constructor=()=>{throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.")},t.template.Instance=es,t.template};function ie(e){return mt(e)}for(const[e,t]of Object.entries(W))q[e]={get(){const s=ae(this,ke(t.open,t.close,this._styler),this._isEmpty);return Object.defineProperty(this,e,{value:s}),s}};q.visible={get(){const e=ae(this,this._styler,!0);return Object.defineProperty(this,"visible",{value:e}),e}};const ht=["rgb","hex","keyword","hsl","hsv","hwb","ansi","ansi256"];for(const e of ht)q[e]={get(){const{level:t}=this;return function(...s){const r=ke(W.color[dt[t]][e](...s),W.color.close,this._styler);return ae(this,r,this._isEmpty)}}};for(const e of ht){const t="bg"+e[0].toUpperCase()+e.slice(1);q[t]={get(){const{level:s}=this;return function(...r){const n=ke(W.bgColor[dt[s]][e](...r),W.bgColor.close,this._styler);return ae(this,n,this._isEmpty)}}}}const ts=Object.defineProperties(()=>{},{...q,level:{enumerable:!0,get(){return this._generator.level},set(e){this._generator.level=e}}}),ke=(e,t,s)=>{let r,n;return s===void 0?(r=e,n=t):(r=s.openAll+e,n=t+s.closeAll),{open:e,close:t,openAll:r,closeAll:n,parent:s}},ae=(e,t,s)=>{const r=(...n)=>re(n[0])&&re(n[0].raw)?yt(r,gt(r,...n)):yt(r,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(r,ts),r._generator=e,r._styler=t,r._isEmpty=s,r},yt=(e,t)=>{if(e.level<=0||!t)return e._isEmpty?"":t;let s=e._styler;if(s===void 0)return t;const{openAll:r,closeAll:n}=s;if(t.indexOf("\x1B")!==-1)for(;s!==void 0;)t=Zn(t,s.close,s.open),s=s.parent;const o=t.indexOf(`
7
+ `);return o!==-1&&(t=Vn(t,n,r,o)),r+t+n};let Fe;const gt=(e,...t)=>{const[s]=t;if(!re(s)||!re(s.raw))return t.join(" ");const r=t.slice(1),n=[s.raw[0]];for(let o=1;o<s.length;o++)n.push(String(r[o-1]).replace(/[{}\\]/g,"\\$&"),String(s.raw[o]));return Fe===void 0&&(Fe=Yn()),Fe(e,n.join(""))};Object.defineProperties(ie.prototype,q);const ce=ie();ce.supportsColor=Se,ce.stderr=ie({level:Ae?Ae.level:0}),ce.stderr.supportsColor=Ae;var ns=ce;const le=ot(ns);var xe={exports:{}},ue={exports:{}},_e,bt;function ss(){if(bt)return _e;bt=1;var e=1e3,t=e*60,s=t*60,r=s*24,n=r*7,o=r*365.25;_e=function(p,l){l=l||{};var f=typeof p;if(f==="string"&&p.length>0)return i(p);if(f==="number"&&isFinite(p))return l.long?a(p):c(p);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(p))};function i(p){if(p=String(p),!(p.length>100)){var l=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(p);if(l){var f=parseFloat(l[1]),d=(l[2]||"ms").toLowerCase();switch(d){case"years":case"year":case"yrs":case"yr":case"y":return f*o;case"weeks":case"week":case"w":return f*n;case"days":case"day":case"d":return f*r;case"hours":case"hour":case"hrs":case"hr":case"h":return f*s;case"minutes":case"minute":case"mins":case"min":case"m":return f*t;case"seconds":case"second":case"secs":case"sec":case"s":return f*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return f;default:return}}}}function c(p){var l=Math.abs(p);return l>=r?Math.round(p/r)+"d":l>=s?Math.round(p/s)+"h":l>=t?Math.round(p/t)+"m":l>=e?Math.round(p/e)+"s":p+"ms"}function a(p){var l=Math.abs(p);return l>=r?u(p,l,r,"day"):l>=s?u(p,l,s,"hour"):l>=t?u(p,l,t,"minute"):l>=e?u(p,l,e,"second"):p+" ms"}function u(p,l,f,d){var m=l>=f*1.5;return Math.round(p/f)+" "+d+(m?"s":"")}return _e}var Re,Ct;function Et(){if(Ct)return Re;Ct=1;function e(t){r.debug=r,r.default=r,r.coerce=u,r.disable=i,r.enable=o,r.enabled=c,r.humanize=ss(),r.destroy=p,Object.keys(t).forEach(l=>{r[l]=t[l]}),r.names=[],r.skips=[],r.formatters={};function s(l){let f=0;for(let d=0;d<l.length;d++)f=(f<<5)-f+l.charCodeAt(d),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=s;function r(l){let f,d=null,m,h;function g(...y){if(!g.enabled)return;const T=g,N=Number(new Date),L=N-(f||N);T.diff=L,T.prev=f,T.curr=N,f=N,y[0]=r.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let U=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(Z,yn)=>{if(Z==="%%")return"%";U++;const Pe=r.formatters[yn];if(typeof Pe=="function"){const gn=y[U];Z=Pe.call(T,gn),y.splice(U,1),U--}return Z}),r.formatArgs.call(T,y),(T.log||r.log).apply(T,y)}return g.namespace=l,g.useColors=r.useColors(),g.color=r.selectColor(l),g.extend=n,g.destroy=r.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(m!==r.namespaces&&(m=r.namespaces,h=r.enabled(l)),h),set:y=>{d=y}}),typeof r.init=="function"&&r.init(g),g}function n(l,f){const d=r(this.namespace+(typeof f>"u"?":":f)+l);return d.log=this.log,d}function o(l){r.save(l),r.namespaces=l,r.names=[],r.skips=[];let f;const d=(typeof l=="string"?l:"").split(/[\s,]+/),m=d.length;for(f=0;f<m;f++)d[f]&&(l=d[f].replace(/\*/g,".*?"),l[0]==="-"?r.skips.push(new RegExp("^"+l.slice(1)+"$")):r.names.push(new RegExp("^"+l+"$")))}function i(){const l=[...r.names.map(a),...r.skips.map(a).map(f=>"-"+f)].join(",");return r.enable(""),l}function c(l){if(l[l.length-1]==="*")return!0;let f,d;for(f=0,d=r.skips.length;f<d;f++)if(r.skips[f].test(l))return!1;for(f=0,d=r.names.length;f<d;f++)if(r.names[f].test(l))return!0;return!1}function a(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function u(l){return l instanceof Error?l.stack||l.message:l}function p(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}return Re=e,Re}var wt;function os(){return wt||(wt=1,function(e,t){t.formatArgs=r,t.save=n,t.load=o,t.useColors=s,t.storage=i(),t.destroy=(()=>{let a=!1;return()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function s(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let a;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(a=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(a[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const u="color: "+this.color;a.splice(1,0,u,"color: inherit");let p=0,l=0;a[0].replace(/%[a-zA-Z%]/g,f=>{f!=="%%"&&(p++,f==="%c"&&(l=p))}),a.splice(l,0,u)}t.log=console.debug||console.log||(()=>{});function n(a){try{a?t.storage.setItem("debug",a):t.storage.removeItem("debug")}catch{}}function o(){let a;try{a=t.storage.getItem("debug")}catch{}return!a&&typeof process<"u"&&"env"in process&&(a=process.env.DEBUG),a}function i(){try{return localStorage}catch{}}e.exports=Et()(t);const{formatters:c}=e.exports;c.j=function(a){try{return JSON.stringify(a)}catch(u){return"[UnexpectedJSONParseError]: "+u.message}}}(ue,ue.exports)),ue.exports}var pe={exports:{}},$t;function rs(){return $t||($t=1,function(e,t){const s=Je,r=xn;t.init=p,t.log=c,t.formatArgs=o,t.save=a,t.load=u,t.useColors=n,t.destroy=r.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const f=pt;f&&(f.stderr||f).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}t.inspectOpts=Object.keys(process.env).filter(f=>/^debug_/i.test(f)).reduce((f,d)=>{const m=d.substring(6).toLowerCase().replace(/_([a-z])/g,(g,y)=>y.toUpperCase());let h=process.env[d];return/^(yes|on|true|enabled)$/i.test(h)?h=!0:/^(no|off|false|disabled)$/i.test(h)?h=!1:h==="null"?h=null:h=Number(h),f[m]=h,f},{});function n(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:s.isatty(process.stderr.fd)}function o(f){const{namespace:d,useColors:m}=this;if(m){const h=this.color,g="\x1B[3"+(h<8?h:"8;5;"+h),y=` ${g};1m${d} \x1B[0m`;f[0]=y+f[0].split(`
8
+ `).join(`
9
+ `+y),f.push(g+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else f[0]=i()+d+" "+f[0]}function i(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function c(...f){return process.stderr.write(r.formatWithOptions(t.inspectOpts,...f)+`
10
+ `)}function a(f){f?process.env.DEBUG=f:delete process.env.DEBUG}function u(){return process.env.DEBUG}function p(f){f.inspectOpts={};const d=Object.keys(t.inspectOpts);for(let m=0;m<d.length;m++)f.inspectOpts[d[m]]=t.inspectOpts[d[m]]}e.exports=Et()(t);const{formatters:l}=e.exports;l.o=function(f){return this.inspectOpts.colors=this.useColors,r.inspect(f,this.inspectOpts).split(`
11
+ `).map(d=>d.trim()).join(" ")},l.O=function(f){return this.inspectOpts.colors=this.useColors,r.inspect(f,this.inspectOpts)}}(pe,pe.exports)),pe.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?xe.exports=os():xe.exports=rs();var is=xe.exports;const as=ot(is),cs=e=>typeof e=="function",ls=e=>Object.prototype.toString.call(e)==="[object RegExp]";function vt(e,t){let s=[];try{de.existsSync(e)&&(de.lstatSync(e).isDirectory()?de.readdirSync(e).forEach(function(o){const i=vt(ee.join(e,"/",o),t);s=s.concat(i)}):t!==void 0||s.push(e))}catch(r){throw r}return s}const Ie=as.debug("vite-plugin-compression"),us=/\.(js|mjs|json|css|html)$/i,Tt=new Map;function ps(e={}){let t,s;const r={name:"vite:compression"},{disable:n=!1,filter:o=us,verbose:i=!0,threshold:c=1025,compressionOptions:a={},deleteOriginFile:u=!1,success:p=()=>{}}=e;let{ext:l=""}=e;const{algorithm:f="gzip"}=e;return f==="gzip"&&!l&&(l=".gz"),f==="brotliCompress"&&!l&&(l=".br"),n?r:(Ie("plugin options:",e),{...r,apply:"build",enforce:"post",configResolved(d){s=d,t=ee.isAbsolute(s.build.outDir)?s.build.outDir:ee.join(s.root,s.build.outDir),Ie("resolvedConfig:",d)},async closeBundle(){let d=vt(t)||[];if(Ie("files:",d),!d.length)return;d=fs(d,o);const m=ds(f,a),h=new Map,g=d.map(async y=>{const{mtimeMs:T,size:N}=await se.stat(y);if(T<=(Tt.get(y)||0)||N<c)return;let L=await se.readFile(y);u&&se.remove(y);try{L=await ms(L,f,m)}catch{s.logger.error("compress error:"+y)}const U=L.byteLength,fe=hs(y,l);h.set(y,{size:U/1024,oldSize:N/1024,cname:fe}),await se.writeFile(fe,L),Tt.set(y,Date.now())});return Promise.all(g).then(()=>{i&&(ys(s,h,f),p())})}})}function fs(e,t){if(t){const s=ls(t),r=cs(t);e=e.filter(n=>s?t.test(n):r?t(n):!0)}return e}function ds(e="",t={}){return{...{gzip:{level:B.constants.Z_BEST_COMPRESSION},deflate:{level:B.constants.Z_BEST_COMPRESSION},deflateRaw:{level:B.constants.Z_BEST_COMPRESSION},brotliCompress:{params:{[B.constants.BROTLI_PARAM_QUALITY]:B.constants.BROTLI_MAX_QUALITY,[B.constants.BROTLI_PARAM_MODE]:B.constants.BROTLI_MODE_TEXT}}}[e],...t}}function ms(e,t,s={}){return new Promise((r,n)=>{B[t](e,s,(o,i)=>o?n(o):r(i))})}function hs(e,t){const s=t.startsWith(".")?t:`.${t}`;return`${e}${s}`}function ys(e,t,s){e.logger.info(`
12
+ ${le.cyan("\u2728 [vite-plugin-compression]:algorithm="+s)} - compressed file successfully: `);const r=Array.from(t.keys(),o=>o.length),n=Math.max(...r);t.forEach((o,i)=>{const{size:c,oldSize:a,cname:u}=o,p=Xe(u).replace(Xe(`${e.build.outDir}/`),""),l=`${a.toFixed(2)}kb / ${s}: ${c.toFixed(2)}kb`;e.logger.info(le.dim(ee.basename(e.build.outDir)+"/")+le.blueBright(p)+" ".repeat(2+n-i.length)+" "+le.dim(l))}),e.logger.info(`
13
+ `)}const gs=()=>ps({ext:".gz",algorithm:"gzip",deleteOriginFile:!0}),Ot=()=>{const e=process.env.npm_lifecycle_event;return _n({typescript:!0,vueTsc:!1,eslint:{lintCommand:`eslint --max-warnings=0 "./sections/**/*.{js,ts,vue}" --cache --cache-location "./build/eslintcache/${e}.json"`}})},bs={[_.Server]:[He(),me(),gs()],[_.Client]:[He(),me(),Ot(),kn({vue:"EcVue"})],[_.Misc]:[me(),Ot()]},v={SECTION:{source:"sections",dist:"dist/sections"},HEADER:{source:"headers",dist:"dist/headers"},FOOTER:{source:"footers",dist:"dist/footers"}};function Cs(e){return R(`${he}/${e}`)?"HEADER":R(`${ye}/${e}`)?"FOOTER":"SECTION"}const jt={"process.env":{NODE_ENV:"production"}},Es=[...Ke,...Ke.map(e=>`node:${e}`)],ws=[/@vue\/compiler-dom/,/@vue\/runtime-dom/,/@vue\/server-renderer/,/@vue\/compiler-ssr/,/@vue\/shared/],I={[j.Server]:{pluginType:_.Server,define:jt,ssr:!0,ssrOptions:{noExternal:!0},outDir:(e,t)=>`./${v[t].dist}/${e}/js/main/server`,externalOption:[...Es],entryFileNames:"server.js",inlineDynamicImports:!0},[j.Client]:{pluginType:_.Client,define:jt,ssr:!1,outDir:(e,t)=>`./${v[t].dist}/${e}/js/main/client`,entryFileNames:"client.js",assetFileNames:"assets/[name].[ext]",inlineDynamicImports:!0},[j.SectionSetting]:{pluginType:_.Misc,ssr:!1,outDir:(e,t)=>`./${v[t].dist}/${e}/js/settings`,entryFileNames:"[name].mjs"},[j.SectionShowcase]:{pluginType:_.Misc,ssr:!1,outDir:(e,t)=>`./${v[t].dist}/${e}/js/showcases`,entryFileNames:"[name].mjs"},[j.SectionAsset]:{pluginType:_.Misc,ssr:!1,outDir:(e,t)=>`./${v[t].dist}/${e}/assets`,assetFileNames:"[name].[ext]"},[j.TemplateDescriptor]:{pluginType:_.Misc,ssr:!1,outDir:()=>`./${z}/js`,entryFileNames:`[name]${X}.mjs`},[j.TemplateAsset]:{pluginType:_.Misc,ssr:!1,outDir:()=>`./${z}/assets`,assetFileNames:"[name].[ext]"}};function $s(e){switch(typeof e){case"string":return[E(process.cwd(),e)];case"object":return e.map(t=>E(process.cwd(),t));default:return[]}}function vs(e,t){const{externalOption:s}=I[e];return t?.externalizeVue&&e===j.Server?[...s??[],...ws]:s}function St(e,t,s,r,n){const o=I[s].define,i=I[s].ssrOptions,c=I[s].entryFileNames,a=I[s].chunkFileNames,u=I[s].assetFileNames,p=I[s].inlineDynamicImports,l=vs(s,n);return{plugins:bs[I[s].pluginType],...o!=null&&{define:o},...i!=null&&{ssr:i},resolve:{alias:{"@":"/src"}},build:{ssr:I[s].ssr,outDir:I[s].outDir(e,r),emptyOutDir:!0,minify:"terser",terserOptions:{compress:{drop_console:!1}},rollupOptions:{...l!=null&&{external:l},preserveEntrySignatures:"strict",input:$s(t),output:{validate:!0,inlineDynamicImports:p,...c!=null&&{entryFileNames:c},...a!=null&&{chunkFileNames:a},...u!=null&&{assetFileNames:u}}}}}}const At="https://json-schema.org/draft/2020-12/schema",kt="https://lightspeedhq.com/template.schema.json",Ft="Custom Template",xt="A custom template enclosing the necessary custom and default blocks",_t="object",Rt={metadata:{type:"object",properties:{name:{description:"Name of the template",type:"string",minLength:2,maxLength:60},description:{description:"Short description of the template",type:"string",minLength:2,maxLength:150},preview_url:{description:"Preview url of the demo website",type:"string",format:"uri",pattern:"^(https?)://([^.]+?\\.)company\\.site($|/[A-Za-z0-9\\-._~:/?#\\[\\]@!$&'()*+,;=]*)?$"},cover_image:{type:"object",properties:{set:{description:"Name of the image set",type:"object",patternProperties:{".*":{type:"object",properties:{url:{description:"Path to the preview image relative to the 'assets' folder for a specific resolution",type:"string"}},required:["url"],additionalProperties:!1}}}},required:["set"],additionalProperties:!1}},required:["name","description","cover_image"],additionalProperties:!1},sections:{description:"List of sections contained by this template",type:"array",items:{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]}},allOf:[{if:{properties:{type:{const:"default"}}},then:{$ref:"template-default.schema.json#/$defs/default-section"}},{if:{properties:{type:{const:"custom"}}},then:{$ref:"template-custom.schema.json#/$defs/custom-section"}}]},minItems:1,uniqueItems:!1}},It=["metadata","sections"],Ts={$schema:At,$id:kt,title:Ft,description:xt,type:_t,properties:Rt,required:It},Nt={__proto__:null,$id:kt,$schema:At,default:Ts,description:xt,properties:Rt,required:It,title:Ft,type:_t},Lt="https://json-schema.org/draft/2020-12/schema",Mt="https://lightspeedhq.com/template-default.schema.json",Dt="Default Section",Bt="Default section for a Custom Template",Pt="object",Gt={"default-section":{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]},id:{description:"Identification of the section",type:"string",pattern:"^((header|cover|announcement_bar|slider|special_offer|customer_review|company_info|shipping_payment|location|store|footer)(_\\d{3})?)$"}},required:["type","id"],additionalProperties:!1}},Os={$schema:Lt,$id:Mt,title:Dt,description:Bt,type:Pt,$defs:Gt},js={__proto__:null,$defs:Gt,$id:Mt,$schema:Lt,default:Os,description:Bt,title:Dt,type:Pt},Ut="https://json-schema.org/draft/2020-12/schema",Xt="https://lightspeedhq.com/template-custom.schema.json",zt="Custom Section",qt="Custom section for a Custom Template",Kt="object",Ht={"custom-section":{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]},id:{description:"Identification of the section",type:"string"},showcase_id:{description:"Showcase id of the section",type:"string"},showcase_overrides:{type:"object",description:"Overrides for the showcase",properties:{content:{type:"object",patternProperties:{".*":{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX","DECK"]}},allOf:[{if:{properties:{type:{const:"INPUTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/input_box"}},{if:{properties:{type:{const:"TEXTAREA"}}},then:{$ref:"template-custom-content.schema.json#/$defs/text_area"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"template-custom-content.schema.json#/$defs/button"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/select_box"}},{if:{properties:{type:{const:"DECK"}}},then:{$ref:"template-custom-content.schema.json#/$defs/deck"}}]}},minProperties:1},design:{type:"object",patternProperties:{".*":{type:"object",properties:{type:{description:"Type of the design configuration element",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]}},allOf:[{if:{properties:{type:{const:"TEXT"}}},then:{$ref:"template-custom-design.schema.json#/$defs/text"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"template-custom-design.schema.json#/$defs/button"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"template-custom-design.schema.json#/$defs/image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"template-custom-design.schema.json#/$defs/toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"template-custom-design.schema.json#/$defs/select_box"}},{if:{properties:{type:{const:"BACKGROUND"}}},then:{$ref:"template-custom-design.schema.json#/$defs/background"}}]}},minProperties:1},layoutId:{description:"Layout ID for the showcase",type:"string"},blockName:{description:"Section name for the showcase",type:"string"}},required:["content","design"]}},required:["type","id"],additionalProperties:!1}},Ss={$schema:Ut,$id:Xt,title:zt,description:qt,type:Kt,$defs:Ht},As={__proto__:null,$defs:Ht,$id:Xt,$schema:Ut,default:Ss,description:qt,title:zt,type:Kt},Jt="https://json-schema.org/draft/2020-12/schema",Wt="https://lightspeedhq.com/template-custom-content.schema.json",Yt="Custom Section :: Content Configuration",Zt="Content tab configuration of a Custom Section for a Custom Template",Vt="object",Qt={input_box:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX","DECK"]},text:{type:"string"}},required:["type","text"],additionalProperties:!1},text_area:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX","DECK"]},text:{type:"string"}},required:["type","text"],additionalProperties:!1},button:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX","DECK"]},title:{type:"string"},buttonType:{type:"string",enum:["SCROLL_TO_TILE","HYPER_LINK","MAIL_LINK","TEL_LINK","GO_TO_STORE_LINK","GO_TO_PAGE"]},link:{type:"string",format:"uri"},linkTarget:{type:"string"},email:{type:"string"},phone:{type:"string"},tileId:{type:"string"}},required:["type","title"],additionalProperties:!1},image:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX","DECK"]},imageData:{type:"object",properties:{set:{type:"object"},borderInfo:{type:"object"},bucket:{type:"string"}},required:["set"]}},required:["type"],additionalProperties:!1},toggle:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX","DECK"]},enabled:{type:"boolean"}},required:["type"],additionalProperties:!1},select_box:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX","DECK"]},value:{type:"string"}},required:["type"],additionalProperties:!1},deck:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX","DECK"]},cards:{description:"Cards of the content configuration element",type:"array",items:{type:"object",required:["settings"]},properties:{settings:{type:"object",patternProperties:{".*":{type:"object",properties:{type:{description:"Type of the settings configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]}},allOf:[{if:{properties:{type:{const:"INPUTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/input_box"}},{if:{properties:{type:{const:"TEXTAREA"}}},then:{$ref:"template-custom-content.schema.json#/$defs/text_area"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"template-custom-content.schema.json#/$defs/button"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/select_box"}}]}},minProperties:1}}}}}},ks={$schema:Jt,$id:Wt,title:Yt,description:Zt,type:Vt,$defs:Qt},Fs={__proto__:null,$defs:Qt,$id:Wt,$schema:Jt,default:ks,description:Zt,title:Yt,type:Vt},en="https://json-schema.org/draft/2020-12/schema",tn="https://lightspeedhq.com/template-custom-design.schema.json",nn="Custom Section :: Design Configuration",sn="Design tab configuration of a Custom Section for a Custom Template",on="object",rn={text:{type:"object",properties:{type:{description:"Type of the text",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},font:{description:"Default font for the text",type:"string"},size:{description:"Default size for the text",type:"integer",minimum:1,exclusiveMaximum:50},bold:{description:"Default boldness for the text",type:"boolean"},italic:{description:"Default italic style for the text",type:"boolean"},color:{description:"Default color for the text",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},visible:{description:"Default visibility for the text",type:"boolean"}},additionalProperties:!1},button:{type:"object",properties:{type:{description:"Type of the button",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},font:{description:"Default font for the button",type:"string"},size:{description:"Default size for the button",type:"string",enum:["SMALL","MEDIUM","LARGE"]},appearance:{description:"Default appearance for the button",type:"string",enum:["SOLID","OUTLINE","TEXT"]},shape:{description:"Default shape for the button",type:"string",enum:["ROUND_CORNER","RECTANGLE","PILL"]},color:{description:"Default color for the button",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"}},additionalProperties:!1},image:{type:"object",properties:{type:{description:"Type of the image",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},overlay:{description:"Default overlay for the image",type:"string",enum:["COLOR","GRADIENT","NONE"]}},if:{properties:{overlay:{const:"GRADIENT"}}},then:{properties:{color:{description:"Default color for the image",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},minItems:2,maxItems:2}}},else:{properties:{color:{description:"Default color for the image",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"}}}},toggle:{type:"object",properties:{type:{description:"Type of the toggle",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},enabled:{description:"Default enabled status for the toggle",type:"boolean"}},additionalProperties:!1},select_box:{type:"object",properties:{type:{description:"Type of the checkbox",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},value:{description:"Default option for the checkbox",type:"string"}},additionalProperties:!1},background:{type:"object",properties:{type:{description:"Type of the background",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},style:{description:"Default style for the background",type:"string",enum:["COLOR","GRADIENT"]}},if:{properties:{style:{const:"GRADIENT"}}},then:{properties:{color:{description:"Default colors for the image",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},minItems:2,maxItems:2}}},else:{properties:{color:{description:"Default color for the image",type:"string"}}}}},xs={$schema:en,$id:tn,title:nn,description:sn,type:on,$defs:rn},_s={__proto__:null,$defs:rn,$id:tn,$schema:en,default:xs,description:sn,title:nn,type:on};function Rs(e){return Object.entries(v).find(t=>t[1].source===e)?.[0]}async function Is(){const e=await O("**/server.{js,ts}",{ignore:["node_modules/**","dist/**"]});return Promise.all(e.map(async t=>{const s=On(t).split(jn),r=s.pop()??"default",n=s.pop();if(n===void 0)throw new Error("Cannot determine type of section, outer directory is undefined");const o=await O(`**/${r}/client.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await O(`**/${r}/settings/content.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),c=await O(`**/${r}/settings/design.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),a=await O(`**/${r}/settings/layout.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),u=await O(`**/${r}/settings/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),p=await O(`**/${r}/showcases/*.{js,ts}`,{ignore:["node_modules/**","dist/**",`**/${r}/showcases/translations.{js,ts}`]}),l=await O(`**/${r}/showcases/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),f=await O(`**/${r}/assets/*`,{ignore:["node_modules/**","dist/**"]});return{name:r,type:Rs(n),serverEntrypoint:t,clientEntrypoint:o.at(0),contentSettingsEntrypoint:i.at(0),designSettingsEntrypoint:c.at(0),layoutSettingsEntrypoint:a.at(0),settingsTranslationsEntrypoint:u.at(0),showcasesEntrypoints:p,showcasesTranslationsEntrypoint:l.at(0),assetsEntrypoints:f}}))}async function Ns(){const e=await O("./templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]}),t=await O("./templates/assets/*",{ignore:["node_modules/**","dist/**"]});return{templates:e,assets:t}}async function Ne(e,t){try{const s=E(Ge.cwd(),t?`${e}${X}.mjs`:`${e}.mjs`);return(await import(G(s).href)).default}catch{throw new Error(`File [${e}${X}.mjs] is either invalid or undefined`)}}async function Ls(){let e=new Rn({allErrors:!0,schemas:[Nt,js,As,Fs,_s]});return In(e),e.compile(Nt)}async function Ms(e,t,s,r){if(e(t)&&r===void 0)new Promise(n=>{Cn(`${s}${X}.mjs`,`${s}.mjs`,function(o){o&&n(o)})});else throw new Promise(n=>{En(`${s}${X}.mjs`,function(o){o&&n(o)})}),new Error(`Invalid file [${te(s).name}].
3
14
  Note: Errors regarding failingKeyword: "then" can sometimes be false negatives. Please focus on fixing other errors first!
4
- Errors: ${JSON.stringify([...e.errors??[],...o??[]],null,2)}`)}async function _t(e){const t=[];for(const s of e.sections){const o=e.sections.indexOf(s);if(o===0&&s.id!=="header"&&t.push({instancePath:`/sections/${o}/id`,message:"The first section must be a default `header`"}),o===e.sections.length-1&&s.id!=="footer"&&t.push({instancePath:`/sections/${o}/id`,message:"The last section must be a default `footer`"}),s.type==="custom")if(!S(`${a}/${s.id}`))t.push({instancePath:`/sections/${o}/id`,message:"Custom section must have a corresponding block defined"});else{if(s.content!==void 0)if(!S(`${a}/${s.id}/js/settings/content.mjs`))t.push({instancePath:`/sections/${o}/content`,message:"Content descriptor is overridden, please provide a default descriptor in the block's settings folder"});else{const n=await M(`${a}/${s.id}/js/settings/content`,!1),i=new Set(Object.keys(n));Object.keys(s.content).every(c=>i.has(c))||t.push({instancePath:`/sections/${o}/content`,message:"Content descriptor must be a subset of the default content descriptor"})}if(s.design!==void 0)if(!S(`${a}/${s.id}/js/settings/design.mjs`))t.push({instancePath:`/sections/${o}/design`,message:"Design descriptor is overridden, please provide a default descriptor in the block's settings folder"});else{const n=await M(`${a}/${s.id}/js/settings/design`,!1),i=new Set(Object.keys(n));Object.keys(s.design).every(c=>i.has(c))||t.push({instancePath:`/sections/${o}/design`,message:"Design descriptor must be a subset of the default design descriptor"})}s.showcase_id!==void 0&&(S(`${a}/${s.id}/js/showcases/${s.showcase_id}.mjs`)||t.push({instancePath:`/sections/${o}/showcase-id`,message:"Custom section must have a corresponding showcase defined in case showcase_id is specified"}))}}return t.length===0?void 0:t}function Dt(e){const t=e.reduce((s,o)=>{const n=et(o);return n.size>te&&(s[o]=ee(n.size)),s},{});if(Object.keys(t).length!==0){const s=Math.max(...Object.keys(t).map(o=>o.length));p.error(`Size of individual assets must not exceed threshold [${ee(te)}]!`);for(let o in t)p.error(`File: ${o}`.padEnd(s+10)+`| ${t[o]}`);throw new Error("Invalid asset file size")}}async function It(){async function e(t,s,o){s.length!==0&&await J({configFile:!1,...H(ce(t,s,o))})}Ve("dist",{recursive:!0,force:!0});try{const t=await Ct().then(o=>o.map(n=>({name:n.name,serverEntrypoint:n.serverEntrypoint,clientEntrypoint:[n.clientEntrypoint].filter(B).flat(),settingsEntryPoints:[n.contentSettingsEntrypoint,n.designSettingsEntrypoint,n.layoutSettingsEntrypoint,n.settingsTranslationsEntrypoint].filter(B),showcaseEntryPoints:[...n.showcasesEntrypoints??[],n.showcasesTranslationsEntrypoint].filter(B),assetEntryPoints:n.assetsEntrypoints??[]})));for(const o of t)Dt(o.assetEntryPoints),await J({configFile:!1,...H(ce(o.name,o.serverEntrypoint,f.Server))}),await e(o.name,o.clientEntrypoint,f.Client),await e(o.name,o.settingsEntryPoints,f.SectionSetting),await e(o.name,o.showcaseEntryPoints,f.SectionShowcase),await e(o.name,o.assetEntryPoints,f.SectionAsset);const s=await At();if(s.templates.length!==0){const o=await Nt();await e(void 0,s.assets,f.TemplateAsset),await e(void 0,s.templates,f.TemplateDescriptor);for(const n of s.templates){const i=`${C}/js/${I(n).name}`,c=await M(i,!0);await Lt(o,c,i,await _t(c))}}p.info("Build successful. For deploy run: npx @lightspeed/crane@latest deploy")}catch(t){p.error(`Error while building: ${t.message}`),z.exit(1)}}function Me(e){if(e!==void 0)return e.startsWith("global.")?{type:"GLOBAL_FONT",font:e}:{type:"PRESET_FONT",font:e}}function O(e){if(e===void 0)return;if(e.startsWith("global."))return{type:"GLOBAL_COLOR",raw:e};const t=ut(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function xt(e){if(e!==void 0)return typeof e=="string"&&e.startsWith("global.")?{type:"GLOBAL_TEXT_SIZE",size:e}:{type:"NUMERIC_TEXT_SIZE",size:e}}const Gt={COLOR:"COLOR",GRADIENT:"GRADIENT"};function Pt(e){switch(e){case"COLOR":return"solid";case"GRADIENT":return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(Gt)}`)}}function Rt(e){const t=e.style,s=e.color,o=Array.isArray(s)?s:[s,s];return e.background={type:Pt(t),solid:{color:O(o.at(0))},gradient:{fromColor:O(o.at(0)),toColor:O(o.at(1))}},e.style=void 0,e.color=void 0,e}const kt={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"};function Bt(e){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(kt)}`)}}const Ut={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"};function Mt(e){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(Ut)}`)}}const Xt={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"};function Ft(e){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(Xt)}`)}}function qt(e){const t=e.appearance;t!==void 0&&(e.appearance=Bt(t));const s=e.size;s!==void 0&&(e.size=Mt(s));const o=e.shape;o!==void 0&&(e.style=Ft(o),e.shape=void 0);const n=e.font;e.font=Me(n);const i=e.color;return e.color=O(i),e}const zt={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"};function Kt(e){switch(e){case"COLOR":return"solid";case"GRADIENT":return"gradient";case"NONE":return"none";default:throw new Error(`Unknown image overlay type: ${e}. Right options: ${Object.keys(zt)}`)}}function Jt(e){const t=e.overlay,s=e.color,o=Array.isArray(s)?s:[s,s];return e.overlay={type:Kt(t),solid:{color:O(o.at(0))},gradient:{fromColor:O(o.at(0)),toColor:O(o.at(1))}},e.color=void 0,e}function Ht(e){const t=e.font;e.font=Me(t);const s=e.color;e.color=O(s);const o=e.size;return e.size=xt(o),e}function Zt(e){const t=e.color;return e.color=O(t),e}function Wt(e){Object.keys(e).forEach(t=>{const s=e[t],o=s.type;X(o,s.defaults)})}function Vt(e){e.forEach(t=>{t.type!==void 0&&t.defaults!==void 0&&(X(t.type,t.defaults),t.defaults.type=t.type)})}function Xe(e){Object.keys(e).forEach(t=>{const s=e[t],o=s.type;X(o,s)})}function X(e,t){switch(e){case"TEXT":{Ht(t);break}case"BUTTON":{qt(t);break}case"IMAGE":{Jt(t);break}case"BACKGROUND":{Rt(t);break}case"COLOR_PICKER":{Zt(t);break}case"TOGGLE":case"SELECTBOX":break;default:throw new Error(`Unknown design editor type: ${e}`)}return t}const Yt=200;var y=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.ClientAsset=2]="ClientAsset",e[e.Asset=3]="Asset",e[e.TemplateAsset=4]="TemplateAsset",e[e.Dependency=5]="Dependency",e))(y||{});const A={[y.Server]:{type:"server_js",isSingleton:!0,toPath:e=>`${a}/${e}/js/main/server/`,fileName:"server.js"},[y.Client]:{type:"client_js",isSingleton:!1,toPath:e=>`${a}/${e}/js/main/client/`,fileName:"client.js"},[y.ClientAsset]:{type:"assets",isSingleton:!1,toPath:e=>`${a}/${e}/js/main/client/assets/`,fileName:"*"},[y.Asset]:{type:"assets",isSingleton:!1,toPath:e=>`${a}/${e}/assets/`,fileName:"*"},[y.TemplateAsset]:{type:"template_assets",isSingleton:!1,toPath:()=>`${C}/assets/`,fileName:"*"},[y.Dependency]:{type:"dependencies",isSingleton:!0,toPath:()=>{},fileName:"package.json"}},Qt="https://blockbuster.ecwid.com",es="/api/v1/custom-apps/resources/sections/upload",ts="/api/v1/custom-apps/resources/templates/upload",ss="/api/v1/custom-apps/manifests/sections",os="/api/v1/custom-apps/manifests/templates",ns=5,is=3;async function rs(){const e=await V(m(l.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}async function as(){const e=m(l.cwd(),"package.json"),t=await V(e),s=JSON.parse(t.toString());if(cs(s))return s;throw new Error(`Package file located at path: ${e} does not contain a version field`)}function cs(e){return typeof e=="object"&&e!==null&&"version"in e&&typeof e.version=="string"}async function ps(e){const t=mt(e.version,"patch");if(t===null)throw Error("Error while incrementing app version");e.version=t,tt(m(l.cwd(),"package.json"),`${JSON.stringify(e,null,2)}
5
- `)}async function ls(e,t){try{const s=m(l.cwd(),`${a}/${e}/js/settings/content.mjs`),o=(await import(v(s).href)).default;return L(o,t),o}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function ds(e,t){try{const s=m(l.cwd(),`${a}/${e}/js/settings/design.mjs`),o=(await import(v(s).href)).default;return Wt(o),L(o,t),o}catch(s){const o=s;throw new Error(`Design settings is invalid or undefined. Error ${o.stack}`)}}async function ms(e,t){try{const s=await u("*.mjs",{cwd:m(l.cwd(),`${a}/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(s.map(async o=>{const n=m(l.cwd(),`${a}/${e}/js/showcases/${o}`),i=(await import(v(n).href)).default;return Xe(i.design),L(i,t),i}))}catch(s){throw new Error(`Showcases is invalid or undefined. Error ${s}`)}}async function fs(e){try{const t=m(l.cwd(),`${a}/${e}/js/settings/layout.mjs`);if(!S(t))return[];const s=(await import(v(t).href)).default;return s.forEach(o=>Vt(o.selectedDesignSettings)),s}catch{throw new Error(`Layout descriptor for section [${e}] is either invalid or undefined`)}}async function us(e){return await qe(`${a}/${e}/js/settings/translations.mjs`)}async function Fe(e){return await qe(`${a}/${e}/js/showcases/translations.mjs`)}async function qe(e){const t=m(l.cwd(),e),s=(await import(v(t).href)).default;return hs(s)}function L(e,t){if(e&&typeof e=="object"){const s=e;for(let o in s){const n=s[o];typeof n=="string"&&n.startsWith("$")&&(s[o]=ys(t,n)),typeof n=="object"&&L(n,t)}}}function ys(e,t){if(!t)return;const s=e[t];return s===void 0?{en:t}:s}function hs(e){const t={};for(let s in e){const o=e[s];for(let n in o){const i=t[n],c=o[n];if(i===void 0){const r={};r[s]=c,t[n]=r}else i[s]=c}}return t}async function gs(){const e=await u("*/",{cwd:m(l.cwd(),`${a}/`)});return Promise.all(e.map(async t=>{const s=await us(t),o=await Fe(t),n=await ls(t,s),i=await ds(t,s),c=await ms(t,o),r=await fs(t);return{id:t,name:{en:t},contentEditors:n,designEditors:i,layouts:r,showcases:c}}))}async function $s(e){try{return(await import(v(m(l.cwd(),e)).href)).default}catch{throw new Error(`Template descriptor [${e}] is either invalid or undefined`)}}async function Es(){const e=await u(`${C}/js/**.mjs`,{ignore:[`${C}/js/**${b}.mjs`]});return Promise.all(e.map(async t=>{const s=await $s(t),o=s.sections.filter(n=>n.type==="custom");for(const n of o){const i=await Fe(n.id);n.showcase_overrides!==void 0&&(L(n.showcase_overrides,i),Xe(n.showcase_overrides.design))}return{id:`${I(l.cwd()).name.replace(/[^a-zA-Z0-9]/g,"_")}_${I(t).name}`,descriptor:s}}))}function Ts(e){const t=e.pathContext,s=t.toPath(e.currentSection),o=s===void 0?K(t.fileName):K(t.fileName,{cwd:m(l.cwd(),s),ignore:t.ignore});return t.isSingleton?o.splice(0):o}function ws(e){return e instanceof Y&&(e.code==="ECONNRESET"||e.response?.status!==void 0&&e.response?.status>=500&&e.response?.status<600)}function ze(e,t){return e<is&&ws(t)}async function Ke(e){await new Promise(t=>{setTimeout(t,2**e*500)})}function Je(e,t,s,o){const n=e.config.app.templates.length>0?ts:es;return e.config.axios.post(n,{file:st(m(l.cwd(),s!==void 0?s+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.pathContext.type!=="dependencies"&&{fileName:t}},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${e.config.app.crane.appSecretKey}`}}).then(i=>({status:i.status})).catch(async i=>ze(o,i)?(await Ke(o),Je(e,t,s,o+1)):{status:i.response?.status,message:i.message})}function N(e){const t=Ts(e),s=e.pathContext.toPath(e.currentSection);return t.map(o=>Je(e,o,s,0))}function js(e){return[...e.app.sections.flatMap(t=>[...N({config:e,currentSection:t.id,pathContext:A[y.Server]}),...N({config:e,currentSection:t.id,pathContext:A[y.Client]}),...N({config:e,currentSection:t.id,pathContext:A[y.ClientAsset]}),...N({config:e,currentSection:t.id,pathContext:A[y.Asset]})]),...N({config:e,pathContext:A[y.Dependency]}),...N({config:e,pathContext:A[y.TemplateAsset]})]}function Os(e){return e.includes(`
6
- `)}function vs(e,t,s){return e.split(`
7
- `).map((o,n)=>n>=s?t+o:o).join(`
8
- `)}function He(e,t){const s=[];if(e instanceof Y){e.response?.status!==void 0&&s.push(` HTTP Status Code: ${e.response.status}`);const i=e.response?.data;if(i?.errorCode&&s.push(` Error Code: ${i.errorCode}`),i?.errorMessage){const c=Os(i.errorMessage)?vs(i.errorMessage," ",1):i.errorMessage;s.push(` Error Message: ${c}`)}}const o=s.length>0?s.join(`
9
- `):e?.message??"Unknown error";if(!t||t.length===0)return o;const n=s.length>0?`
10
- `:" ";return`${t}${n}${o}`}async function Ze(e,t=0){const s=e.app.templates.length>0?os:ss;return e.axios.post(s,{version:e.app.packageJson.version,name:"Custom Block App",blocks:e.app.sections,templates:e.app.templates},{params:{appClientId:e.app.crane.appClientId},headers:{Authorization:`Bearer ${e.app.crane.appSecretKey}`}}).catch(async o=>{if(ze(t,o))return await Ke(t),Ze(e,t+1);throw o})}async function Ss(e){try{S(m(l.cwd(),a))||(p.error(`Distribution folder [${a}] not found, please execute the build command first.`),l.exit(1));const t=e??Qt;p.info("Custom application deployment :: Started");const s=dt.create({baseURL:t});ft(s,ns),p.info("Loading configuration files ...");const o=await Promise.all([rs(),as(),gs(),Es()]).then(([r,E,g,G])=>({axios:s,app:{crane:r,packageJson:E,sections:g,templates:G}}));p.info("Uploading asset files ...");let n=se();const i=await Promise.all(js(o)).finally(()=>{U(n)});i.every(r=>r.status===Yt)||(i.map(r=>r.message).filter((r,E,g)=>g.indexOf(r)===E).forEach(r=>p.error(`Error while uploading asset files: ${r}`)),l.exit(1)),p.info("Uploading manifest files ..."),n=se(),await Ze(o).catch(r=>{U(n),p.error(He(r,"Error while deploying manifest file:")),l.exit(1)}).finally(()=>{U(n)});const c=o.app.sections.map(r=>r.id);p.info(`Custom application deployment :: Successful
11
- Current app version: ${o.app.packageJson.version}
12
- Deployed sections: ${c.join(", ")}`),await ps(o.app.packageJson),o.app.templates.length>0&&p.info(`Deployed templates: ${o.app.templates.map(r=>r.id).join(", ")}`)}catch(t){p.error(He(t,"Error while deploying:")),l.exit(1)}}const bs="1.1.0",d=We("crane");function Cs(){d.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("--template <name>","Creates the directory and files necessary to build a custom template inside your app folder.").action(e=>{if(e.app)return oe(e.app);if(e.section)return ne(e.section);if(e.template)return ie(e.template);d.outputHelp()}),d.command("build","Builds your resource code").action(It),d.command("deploy","Deploys your resource code into Ecwid"),d.on("command:*",()=>{console.error("Invalid command: %s",d.args.join(" ")),d.outputHelp(),process.exit(1)}),d.on("command:init",()=>{const e=d.options.section,t=d.options.app,s=d.options.template;q(t)?F("app",x("init --app <name>"),oe):q(e)?F("section",x("init --section <name>"),ne):q(s)&&F("template",x("init --template <name>"),ie)}),d.on("command:deploy",()=>Ss(d.options.url)),d.help(),d.usage("<action> <resource>"),d.version(bs),d.parse()}try{Cs()}catch{}async function F(e,t,s){const o=`You can use ${t} to directly specify the name of the ${e}.`;console.log(o);const n=await yt({type:"text",name:"name",message:`Please specify a name for your ${e}:`});if(n.name)return s(n.name);console.log("Please provide a name for the template."),d.outputHelp()}function q(e){return e&&(typeof e!="string"||e.trim().length==0)}
15
+ Errors: ${JSON.stringify([...e.errors??[],...r??[]],null,2)}`)}async function Ds(e){const t=[];for(const s of e.sections){const r=e.sections.indexOf(s);if(r===0){const n=s.id==="header"&&s.type==="default",o=R(`${he}/${s.id}`);!n&&!o&&t.push({instancePath:`/sections/${r}/id`,message:"The first section must be a `header`"})}else if(r===e.sections.length-1){const n=s.id==="footer"&&s.type==="default",o=R(`${ye}/${s.id}`);!n&&!o&&t.push({instancePath:`/sections/${r}/id`,message:"The last section must be a `footer`"})}else if(s.type==="custom")if(!R(`${A}/${s.id}`))t.push({instancePath:`/sections/${r}/id`,message:"Custom section must have a corresponding block defined"});else{if(s.content!==void 0)if(!R(`${A}/${s.id}/js/settings/content.mjs`))t.push({instancePath:`/sections/${r}/content`,message:"Content descriptor is overridden, please provide a default descriptor in the block's settings folder"});else{const n=await Ne(`${A}/${s.id}/js/settings/content`,!1),o=new Set(Object.keys(n));Object.keys(s.content).every(i=>o.has(i))||t.push({instancePath:`/sections/${r}/content`,message:"Content descriptor must be a subset of the default content descriptor"})}if(s.design!==void 0)if(!R(`${A}/${s.id}/js/settings/design.mjs`))t.push({instancePath:`/sections/${r}/design`,message:"Design descriptor is overridden, please provide a default descriptor in the block's settings folder"});else{const n=await Ne(`${A}/${s.id}/js/settings/design`,!1),o=new Set(Object.keys(n));Object.keys(s.design).every(i=>o.has(i))||t.push({instancePath:`/sections/${r}/design`,message:"Design descriptor must be a subset of the default design descriptor"})}s.showcase_id!==void 0&&(R(`${A}/${s.id}/js/showcases/${s.showcase_id}.mjs`)||t.push({instancePath:`/sections/${r}/showcase-id`,message:"Custom section must have a corresponding showcase defined in case showcase_id is specified"}))}}return t.length===0?void 0:t}function Bs(e){const t=e.reduce((s,r)=>{const n=wn(r);return n.size>Qe&&(s[r]=Ve(n.size)),s},{});if(Object.keys(t).length!==0){const s=Math.max(...Object.keys(t).map(r=>r.length));b.error(`Size of individual assets must not exceed threshold [${Ve(Qe)}]!`);for(let r in t)b.error(`File: ${r}`.padEnd(s+10)+`| ${t[r]}`);throw new Error("Invalid asset file size")}}function Ps(){return $n.rm("dist",{recursive:!0,force:!0})}async function Gs(e){async function t(s,r,n,o="SECTION"){r.length!==0&&await ze({configFile:!1,...qe(St(s,r,n,o,e))})}try{const[s,r]=await Promise.all([Is(),Ns(),Ps()]),n=s.map(o=>({name:o.name,type:o.type,serverEntrypoint:o.serverEntrypoint,clientEntrypoint:[o.clientEntrypoint].filter(ge).flat(),settingsEntryPoints:[o.contentSettingsEntrypoint,o.designSettingsEntrypoint,o.layoutSettingsEntrypoint,o.settingsTranslationsEntrypoint].filter(ge),showcaseEntryPoints:[...o.showcasesEntrypoints??[],o.showcasesTranslationsEntrypoint].filter(ge),assetsEntrypoints:o.assetsEntrypoints??[]}));for(const o of n)Bs(o.assetsEntrypoints),await Promise.all([ze({configFile:!1,...qe(St(o.name,o.serverEntrypoint,j.Server,o.type,e))}),t(o.name,o.clientEntrypoint,j.Client,o.type),t(o.name,o.settingsEntryPoints,j.SectionSetting,o.type),t(o.name,o.showcaseEntryPoints,j.SectionShowcase,o.type),t(o.name,o.assetsEntrypoints,j.SectionAsset,o.type)]);if(r.templates.length!==0){const[o]=await Promise.all([Ls(),t(void 0,r.assets,j.TemplateAsset),t(void 0,r.templates,j.TemplateDescriptor)]);for(const i of r.templates){const c=`${z}/js/${te(i).name}`,a=await Ne(c,!0);await Ms(o,a,c,await Ds(a))}}b.info("Build successful. For deploy run: npx @lightspeed/crane@latest deploy")}catch(s){b.error(`Error while building: ${s.message}`),Ge.exit(1)}}function an(e){if(e!==void 0)return e.startsWith("global.")?{type:"GLOBAL_FONT",font:e}:{type:"PRESET_FONT",font:e}}function D(e){if(e===void 0)return;if(e.startsWith("global."))return{type:"GLOBAL_COLOR",raw:e};const t=Dn(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function Us(e){if(e!==void 0)return typeof e=="string"&&e.startsWith("global.")?{type:"GLOBAL_TEXT_SIZE",size:e}:{type:"NUMERIC_TEXT_SIZE",size:e}}const Xs={COLOR:"COLOR",GRADIENT:"GRADIENT"};function zs(e){switch(e){case"COLOR":return"solid";case"GRADIENT":return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(Xs)}`)}}function qs(e){const t=e.style,s=e.color,r=Array.isArray(s)?s:[s,s];return e.background={type:zs(t),solid:{color:D(r.at(0))},gradient:{fromColor:D(r.at(0)),toColor:D(r.at(1))}},e.style=void 0,e.color=void 0,e}const Ks={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"};function Hs(e){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(Ks)}`)}}const Js={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"};function Ws(e){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(Js)}`)}}const Ys={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"};function Zs(e){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(Ys)}`)}}function Vs(e){const t=e.appearance;t!==void 0&&(e.appearance=Hs(t));const s=e.size;s!==void 0&&(e.size=Ws(s));const r=e.shape;r!==void 0&&(e.style=Zs(r),e.shape=void 0);const n=e.font;e.font=an(n);const o=e.color;return e.color=D(o),e}const Qs={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"};function eo(e){switch(e){case"COLOR":return"solid";case"GRADIENT":return"gradient";case"NONE":return"none";default:throw new Error(`Unknown image overlay type: ${e}. Right options: ${Object.keys(Qs)}`)}}function to(e){const t=e.overlay,s=e.color,r=Array.isArray(s)?s:[s,s];return e.overlay={type:eo(t),solid:{color:D(r.at(0))},gradient:{fromColor:D(r.at(0)),toColor:D(r.at(1))}},e.color=void 0,e}function no(e){const t=e.font;e.font=an(t);const s=e.color;e.color=D(s);const r=e.size;return e.size=Us(r),e}function so(e){const t=e.color;return e.color=D(t),e}function oo(e){Object.keys(e).forEach(t=>{const s=e[t],r=s.type;Le(r,s.defaults)})}function ro(e){e.forEach(t=>{t.type!==void 0&&t.defaults!==void 0&&(Le(t.type,t.defaults),t.defaults.type=t.type)})}function cn(e){Object.keys(e).forEach(t=>{const s=e[t],r=s.type;Le(r,s)})}function Le(e,t){switch(e){case"TEXT":{no(t);break}case"BUTTON":{Vs(t);break}case"IMAGE":{to(t);break}case"BACKGROUND":{qs(t);break}case"COLOR_PICKER":{so(t);break}case"TOGGLE":case"SELECTBOX":break;default:throw new Error(`Unknown design editor type: ${e}`)}return t}const io=200;var k=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.ClientAsset=2]="ClientAsset",e[e.Asset=3]="Asset",e[e.TemplateAsset=4]="TemplateAsset",e[e.Dependency=5]="Dependency",e))(k||{});const K={[k.Server]:{type:"server_js_compressed",isSingleton:!0,toPath:(e,t)=>`${v[t].dist}/${e}/js/main/server/`,fileName:"server.js.gz"},[k.Client]:{type:"client_js",isSingleton:!1,toPath:(e,t)=>`${v[t].dist}/${e}/js/main/client/`,fileName:"client.js"},[k.ClientAsset]:{type:"assets",isSingleton:!1,toPath:(e,t)=>`${v[t].dist}/${e}/js/main/client/assets/`,fileName:"*"},[k.Asset]:{type:"assets",isSingleton:!1,toPath:(e,t)=>`${v[t].dist}/${e}/assets/`,fileName:"*"},[k.TemplateAsset]:{type:"template_assets",isSingleton:!1,toPath:()=>`${z}/assets/`,fileName:"*"},[k.Dependency]:{type:"dependencies",isSingleton:!0,toPath:()=>{},fileName:"package.json"}},ao="https://blockbuster.ecwid.com",co="/api/v1/custom-apps/resources/sections/upload",lo="/api/v1/custom-apps/resources/templates/upload",uo="/api/v1/custom-apps/manifests/sections",po="/api/v1/custom-apps/manifests/templates",fo=5,mo=3;async function ho(){const e=await We(E(C.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}async function yo(){const e=E(C.cwd(),"package.json"),t=await We(e),s=JSON.parse(t.toString());if(go(s))return s;throw new Error(`Package file located at path: ${e} does not contain a version field`)}function go(e){return typeof e=="object"&&e!==null&&"version"in e&&typeof e.version=="string"}async function bo(e){const t=Ln(e.version,"patch");if(t===null)throw Error("Error while incrementing app version");e.version=t,vn(E(C.cwd(),"package.json"),`${JSON.stringify(e,null,2)}
16
+ `)}async function Co(e,t,s=A){try{const r=E(C.cwd(),`${s}/${e}/js/settings/content.mjs`),n=(await import(G(r).href)).default;return Y(n,t),n}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function Eo(e,t,s=A){try{const r=E(C.cwd(),`${s}/${e}/js/settings/design.mjs`),n=(await import(G(r).href)).default;return oo(n),Y(n,t),n}catch(r){const n=r;throw new Error(`Design settings is invalid or undefined. Error ${n.stack}`)}}async function wo(e,t,s=A){try{const r=await O("*.mjs",{cwd:E(C.cwd(),`${s}/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(r.map(async n=>{const o=E(C.cwd(),`${s}/${e}/js/showcases/${n}`),i=(await import(G(o).href)).default;return cn(i.design),Y(i,t),i}))}catch(r){throw new Error(`Showcases is invalid or undefined. Error ${r}`)}}async function $o(e,t=A){try{const s=E(C.cwd(),`${t}/${e}/js/settings/layout.mjs`);if(!R(s))return[];const r=(await import(G(s).href)).default;return r.forEach(n=>ro(n.selectedDesignSettings)),r}catch{throw new Error(`Layout descriptor for section [${e}] is either invalid or undefined`)}}async function vo(e,t=A){return await un(`${t}/${e}/js/settings/translations.mjs`)}async function ln(e,t=A){return await un(`${t}/${e}/js/showcases/translations.mjs`)}async function un(e){const t=E(C.cwd(),e),s=(await import(G(t).href)).default;return Oo(s)}function Y(e,t){if(e&&typeof e=="object"){const s=e;for(let r in s){const n=s[r];typeof n=="string"&&n.startsWith("$")&&(s[r]=To(t,n)),typeof n=="object"&&Y(n,t)}}}function To(e,t){if(!t)return;const s=e[t];return s===void 0?{en:t}:s}function Oo(e){const t={};for(let s in e){const r=e[s];for(let n in r){const o=t[n],i=r[n];if(o===void 0){const c={};c[s]=i,t[n]=c}else o[s]=i}}return t}async function Me(e,t){const s=await vo(e,v[t].dist),r=await ln(e,v[t].dist),n=await Co(e,s,v[t].dist),o=await Eo(e,s,v[t].dist),i=await wo(e,r,v[t].dist),c=await $o(e,v[t].dist);return{id:e,type:t,name:{en:e},contentEditors:n,designEditors:o,layouts:c,showcases:i}}async function jo(){const e=await O("*/",{cwd:E(C.cwd(),`${A}/`)}),t=await O("*/",{cwd:E(C.cwd(),`${he}/`)}),s=await O("*/",{cwd:E(C.cwd(),`${ye}/`)});return Promise.all([...e.map(async r=>Me(r,"SECTION")),...t.map(async r=>Me(r,"HEADER")),...s.map(async r=>Me(r,"FOOTER"))])}async function So(e){try{return(await import(G(E(C.cwd(),e)).href)).default}catch{throw new Error(`Template descriptor [${e}] is either invalid or undefined`)}}async function Ao(){const e=await O(`${z}/js/**.mjs`,{ignore:[`${z}/js/**${X}.mjs`]});return Promise.all(e.map(async t=>{const s=await So(t),r=s.sections.filter(n=>n.type==="custom");for(const n of r){const o=Cs(n.id),i=await ln(n.id,v[o].dist);n.showcase_overrides!==void 0&&(Y(n.showcase_overrides,i),cn(n.showcase_overrides.design))}return{id:`${te(C.cwd()).name.replace(/[^a-zA-Z0-9]/g,"_")}_${te(t).name}`,descriptor:s}}))}function ko(e,t){const s=e.pathContext,r=s.toPath(e.currentSection,t),n=r===void 0?Ue(s.fileName):Ue(s.fileName,{cwd:E(C.cwd(),r),ignore:s.ignore});return s.isSingleton?n.splice(0):n}function Fo(e){return e instanceof Ye&&(e.code==="ECONNRESET"||e.response?.status!==void 0&&e.response?.status>=500&&e.response?.status<600)}function pn(e,t){return e<mo&&Fo(t)}async function fn(e){await new Promise(t=>{setTimeout(t,2**e*500)})}function dn(e,t,s,r){const n=e.config.app.templates.length>0?lo:co;return e.config.axios.post(n,{file:Tn(E(C.cwd(),s!==void 0?s+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.pathContext.type!=="dependencies"&&{fileName:t}},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${e.config.app.crane.appSecretKey}`}}).then(o=>({status:o.status})).catch(async o=>pn(r,o)?(await fn(r),dn(e,t,s,r+1)):{status:o.response?.status,message:o.message})}function H(e,t="SECTION"){const s=ko(e,t),r=e.pathContext.toPath(e.currentSection,t);return s.map(n=>dn(e,n,r,0))}function xo(e){return[...e.app.sections.flatMap(t=>[...H({config:e,currentSection:t.id,pathContext:K[k.Server]},t.type),...H({config:e,currentSection:t.id,pathContext:K[k.Client]},t.type),...H({config:e,currentSection:t.id,pathContext:K[k.ClientAsset]},t.type),...H({config:e,currentSection:t.id,pathContext:K[k.Asset]},t.type)]),...H({config:e,pathContext:K[k.Dependency]}),...H({config:e,pathContext:K[k.TemplateAsset]})]}function _o(e){return e.includes(`
17
+ `)}function Ro(e,t,s){return e.split(`
18
+ `).map((r,n)=>n>=s?t+r:r).join(`
19
+ `)}function mn(e,t){const s=[];if(e instanceof Ye){e.response?.status!==void 0&&s.push(` HTTP Status Code: ${e.response.status}`);const o=e.response?.data;if(o?.errorCode&&s.push(` Error Code: ${o.errorCode}`),o?.errorMessage){const i=_o(o.errorMessage)?Ro(o.errorMessage," ",1):o.errorMessage;s.push(` Error Message: ${i}`)}}const r=s.length>0?s.join(`
20
+ `):e?.message??"Unknown error";if(!t||t.length===0)return r;const n=s.length>0?`
21
+ `:" ";return`${t}${n}${r}`}async function hn(e,t=0){const s=e.app.templates.length>0?po:uo;return e.axios.post(s,{version:e.app.packageJson.version,name:"Custom Block App",blocks:e.app.sections,templates:e.app.templates,compressionEnabled:!0},{params:{appClientId:e.app.crane.appClientId},headers:{Authorization:`Bearer ${e.app.crane.appSecretKey}`}}).catch(async r=>{if(pn(t,r))return await fn(t),hn(e,t+1);throw r})}async function Io(e){try{R(E(C.cwd(),A))||(b.error(`Distribution folder [${A}] not found, please execute the build command first.`),C.exit(1));const t=e??ao;b.info("Custom application deployment :: Started");const s=Nn.create({baseURL:t});Mn(s,fo),b.info("Loading configuration files ...");const r=await Promise.all([ho(),yo(),jo(),Ao()]).then(([c,a,u,p])=>({axios:s,app:{crane:c,packageJson:a,sections:u,templates:p}}));b.info("Uploading asset files ...");let n=et();const o=await Promise.all(xo(r)).finally(()=>{be(n)});o.every(c=>c.status===io)||(o.map(c=>c.message).filter((c,a,u)=>u.indexOf(c)===a).forEach(c=>b.error(`Error while uploading asset files: ${c}`)),C.exit(1)),b.info("Uploading manifest files ..."),n=et(),await hn(r).catch(c=>{be(n),b.error(mn(c,"Error while deploying manifest file:")),C.exit(1)}).finally(()=>{be(n)});const i=r.app.sections.map(c=>c.id);b.info(`Custom application deployment :: Successful
22
+ Current app version: ${r.app.packageJson.version}
23
+ Deployed sections: ${i.join(", ")}`),await bo(r.app.packageJson),r.app.templates.length>0&&b.info(`Deployed templates: ${r.app.templates.map(c=>c.id).join(", ")}`)}catch(t){b.error(mn(t,"Error while deploying:")),C.exit(1)}}const No="1.1.1",w=bn("crane");function Lo(){w.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("--template <name>","Creates the directory and files necessary to build a custom template inside your app folder.").option("--custom-headers-footers","Creates the directories and files necessary to build a custom header and footer inside your app folder.").action(e=>{if(e.app)return tt(e.app);if(e.section)return nt(e.section);if(e.template)return st(e.template,e.customHeadersFooters);w.outputHelp()}),w.command("build","Builds your resource code").option("--externalize-vue","Externalize @vue core libraries to reduce the bundle size").action(Gs),w.command("deploy","Deploys your resource code into Ecwid"),w.on("command:*",()=>{console.error("Invalid command: %s",w.args.join(" ")),w.outputHelp(),process.exit(1)}),w.on("command:init",()=>{const e=w.options.section,t=w.options.app,s=w.options.template,r=w.options.customHeadersFooters||!1;Be(t)?De("app",ne("init --app <name>"),tt):Be(e)?De("section",ne("init --section <name>"),nt):Be(s)&&De("template",ne("init --template <name>"),st,r)}),w.on("command:deploy",()=>Io(w.options.url)),w.help(),w.usage("<action> <resource>"),w.version(No),w.parse()}try{Lo()}catch{}async function De(e,t,s,r){const n=`You can use ${t} to directly specify the name of the ${e}.`;console.log(n);const o=await Bn({type:"text",name:"name",message:`Please specify a name for your ${e}:`});if(o.name)return e==="template"?s(o.name,r):s(o.name);console.log("Please provide a name for the template."),w.outputHelp()}function Be(e){return e&&(typeof e!="string"||e.trim().length==0)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightspeed/crane",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "bin": "bin/crane.js",
6
6
  "main": "./dist/app.mjs",
@@ -36,18 +36,20 @@
36
36
  "@types/fs-extra": "^11.0.1",
37
37
  "@types/jest": "^29.5.12",
38
38
  "@types/node": "^20.4.5",
39
- "dir-compare": "^5.0.0",
40
39
  "express": "^4.19.2",
41
40
  "express-fileupload": "^1.5.1",
42
41
  "jest": "^29.7.0",
42
+ "terser": "^5.35.0",
43
43
  "ts-jest": "^29.1.5",
44
44
  "ts-node": "^10.9.2",
45
45
  "typescript": "5.4.5",
46
46
  "unbuild": "^2.0.0",
47
+ "vite-plugin-compression": "^0.5.1",
47
48
  "vite-plugin-dts": "^3.4.0",
48
49
  "vite-plugin-static-copy": "^0.17.0"
49
50
  },
50
51
  "dependencies": {
52
+ "@jest/globals": "^29.7.0",
51
53
  "@jridgewell/sourcemap-codec": "^1.4.15",
52
54
  "@lightspeed/eslint-config-crane": "1.0.2",
53
55
  "@types/prompts": "^2.4.2",
@@ -57,6 +59,7 @@
57
59
  "axios": "^1.7.7",
58
60
  "axios-concurrency": "^1.0.4",
59
61
  "cac": "^6.7.14",
62
+ "dir-compare": "^5.0.0",
60
63
  "eslint": "npm:eslint-customized-for-crane@8.57.0",
61
64
  "fs-extra": "^11.1.1",
62
65
  "glob": "^9.3.5",
@@ -1,17 +1,51 @@
1
1
  <template>
2
2
  <div
3
- class="custom-footer"
3
+ class="custom-block"
4
+ :style="backgroundStyle"
4
5
  >
5
6
  <div>
6
- the components will sit here
7
+ <ReportAbuse />
8
+ <div class="custom-block__blank_space" />
7
9
  </div>
8
10
  </div>
9
11
  </template>
10
12
 
11
13
  <script setup lang="ts">
14
+ import { computed } from 'vue';
15
+ import { useBackgroundElementDesign } from '@lightspeed/crane';
16
+ import ReportAbuse from './component/ReportAbuse.vue';
17
+ import { Design } from './type.ts';
12
18
 
19
+ const backgroundDesign = useBackgroundElementDesign<Design>('background');
20
+ const background = computed(() => ({
21
+ type: backgroundDesign.background?.type,
22
+ solidColor: backgroundDesign.background?.solid?.color as Color,
23
+ fromColor: backgroundDesign.background?.gradient?.fromColor as Color,
24
+ toColor: backgroundDesign.background?.gradient?.toColor as Color,
25
+ }));
26
+
27
+ const backgroundStyle = computed(() => {
28
+ if (background.value.type === 'gradient') {
29
+ return { 'background-image': `linear-gradient(to right, ${background.value.fromColor.hex}, ${background.value.toColor.hex})` };
30
+ }
31
+ return { 'background-color': background.value.solidColor.hex };
32
+ });
13
33
  </script>
14
34
 
15
35
  <style scoped lang="scss">
36
+ .custom-block {
37
+ padding: 50px;
38
+
39
+ @media screen and (min-width: 700px) {
40
+ padding: 75px;
41
+ }
42
+
43
+ @media screen and (min-width: 1200px) {
44
+ padding: 100px;
45
+ }
16
46
 
47
+ &__blank_space {
48
+ height: 40px;
49
+ }
50
+ }
17
51
  </style>
@@ -0,0 +1,18 @@
1
+ <template>
2
+ <div>
3
+ <a :href="externalContent?.reportAbuse?.url" target="{{ externalContent?.reportAbuseData?.target }}}">
4
+ {{ externalContent?.reportAbuse?.title }}
5
+ </a>
6
+ </div>
7
+ </template>
8
+
9
+ <script setup lang="ts">
10
+ import { useVueBaseProps } from '@lightspeed/crane';
11
+ import { Design } from '../type.ts';
12
+
13
+ const baseProps = useVueBaseProps<unknown, Design>();
14
+ const externalContent: ExternalContentData = baseProps.externalContent.value;
15
+ </script>
16
+
17
+ <style lang="scss" scoped>
18
+ </style>
@@ -0,0 +1,4 @@
1
+ export enum ColorType {
2
+ SOLID = 'solid',
3
+ GRADIENT = 'gradient',
4
+ }
@@ -0,0 +1,3 @@
1
+ export default {
2
+
3
+ } as const;
@@ -0,0 +1,11 @@
1
+ export default {
2
+ background: {
3
+ type: 'BACKGROUND',
4
+ label: '$label.background.label',
5
+ colors: ['#FFFFFF66', '#0000004D', '#00000099', '#64C7FF66', '#F9947266', '#C794CD66', '#FFD17466'],
6
+ defaults: {
7
+ style: 'COLOR',
8
+ color: 'global.color.background',
9
+ },
10
+ },
11
+ } as const;
@@ -0,0 +1,12 @@
1
+ export default {
2
+ en: {
3
+ '$label.reportAbuse.label': 'Custom Footer',
4
+ '$label.background.label': 'Background',
5
+ },
6
+
7
+ nl: {
8
+ '$label.reportAbuse.label': 'aangepaste voettekst',
9
+ '$label.background.label': 'Achtergrond',
10
+
11
+ },
12
+ } as const;
@@ -1,4 +1,5 @@
1
1
  export default {
2
+ showcaseId: '1',
2
3
  previewImage: {
3
4
  set: {
4
5
  ORIGINAL: {
@@ -6,6 +7,7 @@ export default {
6
7
  },
7
8
  },
8
9
  },
10
+ blockName: '$label.showcase_1.blockName',
9
11
  content: {},
10
12
  design: {},
11
13
  } as const;
@@ -0,0 +1,9 @@
1
+ export default {
2
+ en: {
3
+ '$label.showcase_1.blockName': 'Custom footer',
4
+ },
5
+
6
+ nl: {
7
+ '$label.showcase_1.blockName': 'aangepaste voettekst',
8
+ },
9
+ } as const;
@@ -1,5 +1,5 @@
1
- import ContentSettings from '../settings/content.ts';
2
- import DesignSettings from '../settings/design.ts';
1
+ import ContentSettings from './settings/content.ts';
2
+ import DesignSettings from './settings/design.ts';
3
3
 
4
4
  export type Content = InferContentType<typeof ContentSettings>;
5
5
  export type Design = InferDesignType<typeof DesignSettings>;
@@ -1,17 +1,30 @@
1
1
  <template>
2
- <div
3
- class="custom-header"
4
- >
5
- <div>
6
- the components will sit here
2
+ <div class="custom-header">
3
+ <div class="custom-header__left" />
4
+ <div class="custom-header__right">
5
+ <SearchForm />
6
+ <CartIcon />
7
7
  </div>
8
8
  </div>
9
9
  </template>
10
10
 
11
11
  <script setup lang="ts">
12
-
12
+ import CartIcon from './component/Cart.vue';
13
+ import SearchForm from './component/SearchForm.vue';
13
14
  </script>
14
15
 
15
16
  <style scoped lang="scss">
16
-
17
+ .custom-header{
18
+ display: flex;
19
+ justify-content: space-between;
20
+ padding: 10px;
21
+ .custom-header__right{
22
+ display: flex;
23
+ flex: 0 0 auto;
24
+ align-items: center;
25
+ justify-content: flex-end;
26
+ order: 3;
27
+ text-align: right;
28
+ }
29
+ }
17
30
  </style>
@@ -0,0 +1,20 @@
1
+ <svg
2
+ width="30"
3
+ height="30"
4
+ viewBox="0 0 24 24"
5
+ xmlns="http://www.w3.org/2000/svg"
6
+ >
7
+ <path
8
+ d="M18 23.5H6C3.8 23.5 2 21.7 2 19.5V4.2H22V19.5C22 21.7 20.2 23.5 18 23.5ZM3 5.2V19.5C3 21.2 4.3 22.5 6 22.5H18C19.7 22.5 21 21.2 21 19.5V5.2H3Z"
9
+ />
10
+ <path
11
+ d="M12 1C9.7 1 8 2.5 8 4.5C8 4.8 7.8 5 7.5 5C7.2 5 7 4.8 7 4.5C7 1.8 9.3 0 12 0C14.7 0 17 1.8 17 4.5C17 4.8 16.8 5 16.5 5C16.2 5 16 4.8 16 4.5C16 2.5 14.3 1 12 1Z"
12
+ fill-rule="evenodd"
13
+ clip-rule="evenodd"
14
+ />
15
+ <path
16
+ d="M2 4.18018H22V19.5002C22 21.7093 20.2091 23.5002 18 23.5002H6C3.79086 23.5002 2 21.7093 2 19.5002V4.18018Z"
17
+ fill-rule="evenodd"
18
+ clip-rule="evenodd"
19
+ />
20
+ </svg>
@@ -0,0 +1,13 @@
1
+ <svg
2
+ width="24"
3
+ height="24"
4
+ viewBox="0 0 24 24"
5
+ xmlns="http://www.w3.org/2000/svg"
6
+ >
7
+ <path
8
+ d="M16.8333 9.83333C16.8333 5.96667 13.7 2.86667 9.86667 2.86667C6 2.86667 2.9 6 2.9 9.83333C2.9 13.7 6.03333 16.8 9.86667 16.8C13.7 16.8333 16.8333 13.7 16.8333 9.83333ZM22 21.4L21.4 22L15.0667 15.6667C13.6667 16.9 11.8667 17.6667 9.83333 17.6667C5.5 17.6667 2 14.1667 2 9.83333C2 5.5 5.5 2 9.83333 2C14.1667 2 17.6667 5.5 17.6667 9.83333C17.6667 11.8333 16.9 13.6667 15.6667 15.0667L22 21.4Z"
9
+ fill="#f5faff"
10
+ fill-rule="evenodd"
11
+ clip-rule="evenodd"
12
+ />
13
+ </svg>