@wix/cli-app 1.1.100 → 1.1.102

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 (80) hide show
  1. package/build/{AddPermissionCommand-A5KKB76L.js → AddPermissionCommand-JWFWU33A.js} +2 -2
  2. package/build/{DevCommand-UX2UK2TP.js → DevCommand-6OGRGURU.js} +10 -10
  3. package/build/{DevCommand-UX2UK2TP.js.map → DevCommand-6OGRGURU.js.map} +1 -1
  4. package/build/{GenerateCommand-QDCN4PVN.js → GenerateCommand-XVAC4XSX.js} +7 -7
  5. package/build/{LogsCommand-IRTCFK5W.js → LogsCommand-LWIHQA42.js} +3 -3
  6. package/build/PreviewCommand-B6ZKKE76.js +19 -0
  7. package/build/ReleaseCommand-74EIKSEC.js +23 -0
  8. package/build/{ServeCommand-PLWXLCXA.js → ServeCommand-3ZP2YZ5Z.js} +3 -3
  9. package/build/{build-4VOYYMMY.js → build-HYWIEVFV.js} +6 -6
  10. package/build/{chunk-UBDEBCFQ.js → chunk-3CBDXOAT.js} +7 -7
  11. package/build/{chunk-MDZHJBG6.js → chunk-675XBLUK.js} +2 -2
  12. package/build/{chunk-XBDV7LQ3.js → chunk-7KYOZVDT.js} +6 -6
  13. package/build/{chunk-UT5P3NIZ.js → chunk-7OFAQ3I5.js} +2 -2
  14. package/build/{chunk-DGHVMD27.js → chunk-ARET4KWX.js} +4 -4
  15. package/build/{chunk-JVKNABAO.js → chunk-ESHNTWNK.js} +2 -2
  16. package/build/{chunk-2T5ZVVAV.js → chunk-FD7SWKJQ.js} +2 -2
  17. package/build/{chunk-6PTN75QU.js → chunk-IQYQOEW3.js} +150 -37
  18. package/build/{chunk-6PTN75QU.js.map → chunk-IQYQOEW3.js.map} +1 -1
  19. package/build/{chunk-APL5CTYZ.js → chunk-IUORUH2M.js} +47 -2
  20. package/build/{chunk-APL5CTYZ.js.map → chunk-IUORUH2M.js.map} +1 -1
  21. package/build/{chunk-ES7WO7Z2.js → chunk-JGOWLR4V.js} +2 -2
  22. package/build/{chunk-EMIR5PRB.js → chunk-JHSKAYS4.js} +2 -2
  23. package/build/{chunk-XGNO5T7L.js → chunk-KQNNXJG2.js} +2 -2
  24. package/build/{chunk-7CJYZWA3.js → chunk-N3ILQXOU.js} +341 -173
  25. package/build/{chunk-7CJYZWA3.js.map → chunk-N3ILQXOU.js.map} +1 -1
  26. package/build/{chunk-OQZRTEP3.js → chunk-OMZRNT5C.js} +6 -6
  27. package/build/{chunk-JQ66YTUM.js → chunk-R4PKDJ5K.js} +7 -7
  28. package/build/chunk-R4PKDJ5K.js.map +1 -0
  29. package/build/{chunk-HMXUFEZL.js → chunk-UJID64BQ.js} +3 -3
  30. package/build/{chunk-6NEEHJII.js → chunk-Z74G4VXQ.js} +2 -2
  31. package/build/cloudflare-runtime/entry.js +5 -2
  32. package/build/cloudflare-runtime/getRegisteredExtensions.js +5 -2
  33. package/build/index.js +23 -23
  34. package/build/platform-sdk/chunk-BBFFXVJD.js +2 -0
  35. package/build/platform-sdk/chunk-BBFFXVJD.js.map +1 -0
  36. package/build/platform-sdk/{chunk-ZBGVDXLX.js → chunk-MAZR75DI.js} +2 -2
  37. package/build/platform-sdk/chunk-MAZR75DI.js.map +1 -0
  38. package/build/platform-sdk/chunk-NHYZDMR5.js +2 -0
  39. package/build/platform-sdk/chunk-NHYZDMR5.js.map +1 -0
  40. package/build/platform-sdk/dashboard.js +1 -1
  41. package/build/platform-sdk/editor.js +2 -2
  42. package/build/platform-sdk/editor.js.map +1 -1
  43. package/build/platform-sdk/sdk-context.js +1 -1
  44. package/build/platform-sdk/sdk-context.js.map +1 -1
  45. package/build/platform-sdk/site.js +1 -1
  46. package/build/{preview-JILQHRBU.js → preview-FVP3X6OT.js} +12 -12
  47. package/build/{release-FRBHXZKG.js → release-M6JMQJPF.js} +14 -14
  48. package/build/{render-command-55PFYTHV.js → render-command-4XSRQ32M.js} +5 -5
  49. package/package.json +4 -4
  50. package/build/PreviewCommand-MN3237VK.js +0 -19
  51. package/build/ReleaseCommand-JXWC5LKU.js +0 -23
  52. package/build/chunk-JQ66YTUM.js.map +0 -1
  53. package/build/platform-sdk/chunk-J3SVE4GM.js +0 -2
  54. package/build/platform-sdk/chunk-J3SVE4GM.js.map +0 -1
  55. package/build/platform-sdk/chunk-J7RIIVO6.js +0 -2
  56. package/build/platform-sdk/chunk-J7RIIVO6.js.map +0 -1
  57. package/build/platform-sdk/chunk-ZBGVDXLX.js.map +0 -1
  58. /package/build/{AddPermissionCommand-A5KKB76L.js.map → AddPermissionCommand-JWFWU33A.js.map} +0 -0
  59. /package/build/{GenerateCommand-QDCN4PVN.js.map → GenerateCommand-XVAC4XSX.js.map} +0 -0
  60. /package/build/{LogsCommand-IRTCFK5W.js.map → LogsCommand-LWIHQA42.js.map} +0 -0
  61. /package/build/{PreviewCommand-MN3237VK.js.map → PreviewCommand-B6ZKKE76.js.map} +0 -0
  62. /package/build/{ReleaseCommand-JXWC5LKU.js.map → ReleaseCommand-74EIKSEC.js.map} +0 -0
  63. /package/build/{ServeCommand-PLWXLCXA.js.map → ServeCommand-3ZP2YZ5Z.js.map} +0 -0
  64. /package/build/{build-4VOYYMMY.js.map → build-HYWIEVFV.js.map} +0 -0
  65. /package/build/{chunk-UBDEBCFQ.js.map → chunk-3CBDXOAT.js.map} +0 -0
  66. /package/build/{chunk-MDZHJBG6.js.map → chunk-675XBLUK.js.map} +0 -0
  67. /package/build/{chunk-XBDV7LQ3.js.map → chunk-7KYOZVDT.js.map} +0 -0
  68. /package/build/{chunk-UT5P3NIZ.js.map → chunk-7OFAQ3I5.js.map} +0 -0
  69. /package/build/{chunk-DGHVMD27.js.map → chunk-ARET4KWX.js.map} +0 -0
  70. /package/build/{chunk-JVKNABAO.js.map → chunk-ESHNTWNK.js.map} +0 -0
  71. /package/build/{chunk-2T5ZVVAV.js.map → chunk-FD7SWKJQ.js.map} +0 -0
  72. /package/build/{chunk-ES7WO7Z2.js.map → chunk-JGOWLR4V.js.map} +0 -0
  73. /package/build/{chunk-EMIR5PRB.js.map → chunk-JHSKAYS4.js.map} +0 -0
  74. /package/build/{chunk-XGNO5T7L.js.map → chunk-KQNNXJG2.js.map} +0 -0
  75. /package/build/{chunk-OQZRTEP3.js.map → chunk-OMZRNT5C.js.map} +0 -0
  76. /package/build/{chunk-HMXUFEZL.js.map → chunk-UJID64BQ.js.map} +0 -0
  77. /package/build/{chunk-6NEEHJII.js.map → chunk-Z74G4VXQ.js.map} +0 -0
  78. /package/build/{preview-JILQHRBU.js.map → preview-FVP3X6OT.js.map} +0 -0
  79. /package/build/{release-FRBHXZKG.js.map → release-M6JMQJPF.js.map} +0 -0
  80. /package/build/{render-command-55PFYTHV.js.map → render-command-4XSRQ32M.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/@wix/sdk-runtime/build/context.js","../../../node_modules/@wix/sdk-runtime/build/context-v2.js"],"sourcesContent":["import { wixContext } from '@wix/sdk-context';\nexport function resolveContext() {\n const oldContext = typeof $wixContext !== 'undefined' && $wixContext.initWixModules\n ? $wixContext.initWixModules\n : typeof globalThis.__wix_context__ !== 'undefined' &&\n globalThis.__wix_context__.initWixModules\n ? globalThis.__wix_context__.initWixModules\n : undefined;\n if (oldContext) {\n return {\n // @ts-expect-error\n initWixModules(modules, elevated) {\n return runWithoutContext(() => oldContext(modules, elevated));\n },\n fetchWithAuth() {\n throw new Error('fetchWithAuth is not available in this context');\n },\n graphql() {\n throw new Error('graphql is not available in this context');\n },\n };\n }\n const contextualClient = typeof $wixContext !== 'undefined'\n ? $wixContext.client\n : typeof wixContext.client !== 'undefined'\n ? wixContext.client\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.client\n : undefined;\n const elevatedClient = typeof $wixContext !== 'undefined'\n ? $wixContext.elevatedClient\n : typeof wixContext.elevatedClient !== 'undefined'\n ? wixContext.elevatedClient\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.elevatedClient\n : undefined;\n if (!contextualClient && !elevatedClient) {\n return;\n }\n return {\n initWixModules(wixModules, elevated) {\n if (elevated) {\n if (!elevatedClient) {\n throw new Error('An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules');\n }\n return runWithoutContext(() => elevatedClient.use(wixModules));\n }\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return runWithoutContext(() => contextualClient.use(wixModules));\n },\n fetchWithAuth: (urlOrRequest, requestInit) => {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.fetchWithAuth(urlOrRequest, requestInit);\n },\n getAuth() {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.auth;\n },\n async graphql(query, variables, opts) {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.graphql(query, variables, opts);\n },\n };\n}\nexport function contextualizeHostModule(hostModule, prop) {\n return (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(hostModule)[prop].apply(undefined, args);\n };\n}\nexport function getContextualAuth() {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.getAuth();\n}\nexport function contextualizeRESTModule(restModule, expectedArgsLength) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(restModule, args[expectedArgsLength]?.suppressAuth ? true : false)\n .apply(undefined, args);\n });\n}\nexport function contextualizeEventDefinitionModule(eventDefinition) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n}\nexport function contextualizeSerivcePluginModule(servicePlugin) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n}\nexport * from './context-v2.js';\nexport function runWithoutContext(fn) {\n const globalContext = globalThis.__wix_context__;\n const moduleContext = {\n client: wixContext.client,\n elevatedClient: wixContext.elevatedClient,\n };\n let closureContext;\n globalThis.__wix_context__ = undefined;\n wixContext.client = undefined;\n wixContext.elevatedClient = undefined;\n if (typeof $wixContext !== 'undefined') {\n closureContext = {\n client: $wixContext?.client,\n elevatedClient: $wixContext?.elevatedClient,\n };\n delete $wixContext.client;\n delete $wixContext.elevatedClient;\n }\n try {\n return fn();\n }\n finally {\n globalThis.__wix_context__ = globalContext;\n wixContext.client = moduleContext.client;\n wixContext.elevatedClient = moduleContext.elevatedClient;\n if (typeof $wixContext !== 'undefined') {\n $wixContext.client = closureContext.client;\n $wixContext.elevatedClient = closureContext.elevatedClient;\n }\n }\n}\n","import { EventDefinition, ServicePluginDefinition, } from '@wix/sdk-types';\nimport { resolveContext } from './context.js';\nexport { EventDefinition, ServicePluginDefinition, };\nexport function contextualizeHostModuleV2(hostModule, props) {\n return {\n ...hostModule,\n ...Object.fromEntries(props.map((prop) => [\n prop,\n (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(hostModule)[prop].apply(undefined, args);\n },\n ])),\n };\n}\nexport function contextualizeRESTModuleV2(restModule, elevated) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n // @ts-expect-error - if there is no context, we want to behave like the original module\n return restModule.apply(undefined, args);\n }\n return (context\n .initWixModules(restModule, elevated)\n // @ts-expect-error - we know the args here are meant to be passed to the initalized module\n .apply(undefined, args));\n });\n}\nexport function contextualizeEventDefinitionModuleV2(eventDefinition) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => { };\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n contextualMethod.__type = eventDefinition.__type;\n contextualMethod.type = eventDefinition.type;\n contextualMethod.isDomainEvent = eventDefinition.isDomainEvent;\n contextualMethod.transformations = eventDefinition.transformations;\n return contextualMethod;\n}\nexport function contextualizeSerivcePluginModuleV2(servicePlugin) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => { };\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n contextualMethod.__type = servicePlugin.__type;\n contextualMethod.componentType = servicePlugin.componentType;\n contextualMethod.methods = servicePlugin.methods;\n return contextualMethod;\n}\n"],"mappings":"AAAA,OAAS,cAAAA,MAAkB,mBCGpB,SAASC,EAA0BC,EAAYC,EAAO,CACzD,MAAO,CACH,GAAGD,EACH,GAAG,OAAO,YAAYC,EAAM,IAAKC,GAAS,CACtCA,EACA,IAAIC,IAAS,CACT,IAAMC,EAAUC,EAAe,EAC/B,GAAI,CAACD,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOA,EACF,eAAeJ,CAAU,EAAEE,CAAI,EAAE,MAAM,OAAWC,CAAI,CAC/D,CACJ,CAAC,CAAC,CACN,CACJ,CACO,SAASG,EAA0BC,EAAYC,EAAU,CAC5D,MAAQ,IAAIL,IAAS,CACjB,IAAMC,EAAUC,EAAe,EAC/B,OAAKD,EAIGA,EACH,eAAeG,EAAYC,CAAQ,EAEnC,MAAM,OAAWL,CAAI,EALfI,EAAW,MAAM,OAAWJ,CAAI,CAM/C,CACJ,CD9BO,SAASM,GAAiB,CAC7B,IAAMC,EAAa,OAAO,YAAgB,KAAe,YAAY,eAC/D,YAAY,eACZ,OAAO,WAAW,gBAAoB,KACpC,WAAW,gBAAgB,eACzB,WAAW,gBAAgB,eAC3B,OACV,GAAIA,EACA,MAAO,CAEH,eAAeC,EAASC,EAAU,CAC9B,OAAOC,EAAkB,IAAMH,EAAWC,EAASC,CAAQ,CAAC,CAChE,EACA,eAAgB,CACZ,MAAM,IAAI,MAAM,gDAAgD,CACpE,EACA,SAAU,CACN,MAAM,IAAI,MAAM,0CAA0C,CAC9D,CACJ,EAEJ,IAAME,EAAmB,OAAO,YAAgB,IAC1C,YAAY,OACZ,OAAOC,EAAW,OAAW,IACzBA,EAAW,OACX,OAAO,WAAW,gBAAoB,IAClC,WAAW,gBAAgB,OAC3B,OACRC,EAAiB,OAAO,YAAgB,IACxC,YAAY,eACZ,OAAOD,EAAW,eAAmB,IACjCA,EAAW,eACX,OAAO,WAAW,gBAAoB,IAClC,WAAW,gBAAgB,eAC3B,OACd,GAAI,GAACD,GAAoB,CAACE,GAG1B,MAAO,CACH,eAAeC,EAAYL,EAAU,CACjC,GAAIA,EAAU,CACV,GAAI,CAACI,EACD,MAAM,IAAI,MAAM,2JAA2J,EAE/K,OAAOH,EAAkB,IAAMG,EAAe,IAAIC,CAAU,CAAC,CACjE,CACA,GAAI,CAACH,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOD,EAAkB,IAAMC,EAAiB,IAAIG,CAAU,CAAC,CACnE,EACA,cAAe,CAACC,EAAcC,IAAgB,CAC1C,GAAI,CAACL,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOA,EAAiB,cAAcI,EAAcC,CAAW,CACnE,EACA,SAAU,CACN,GAAI,CAACL,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOA,EAAiB,IAC5B,EACA,MAAM,QAAQM,EAAOC,EAAWC,EAAM,CAClC,GAAI,CAACR,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOA,EAAiB,QAAQM,EAAOC,EAAWC,CAAI,CAC1D,CACJ,CACJ,CA+CO,SAASC,EAAkBC,EAAI,CAClC,IAAMC,EAAgB,WAAW,gBAC3BC,EAAgB,CAClB,OAAQC,EAAW,OACnB,eAAgBA,EAAW,cAC/B,EACIC,EACJ,WAAW,gBAAkB,OAC7BD,EAAW,OAAS,OACpBA,EAAW,eAAiB,OACxB,OAAO,YAAgB,MACvBC,EAAiB,CACb,OAAQ,aAAa,OACrB,eAAgB,aAAa,cACjC,EACA,OAAO,YAAY,OACnB,OAAO,YAAY,gBAEvB,GAAI,CACA,OAAOJ,EAAG,CACd,QACA,CACI,WAAW,gBAAkBC,EAC7BE,EAAW,OAASD,EAAc,OAClCC,EAAW,eAAiBD,EAAc,eACtC,OAAO,YAAgB,MACvB,YAAY,OAASE,EAAe,OACpC,YAAY,eAAiBA,EAAe,eAEpD,CACJ","names":["wixContext","contextualizeHostModuleV2","hostModule","props","prop","args","context","resolveContext","contextualizeRESTModuleV2","restModule","elevated","resolveContext","oldContext","modules","elevated","runWithoutContext","contextualClient","wixContext","elevatedClient","wixModules","urlOrRequest","requestInit","query","variables","opts","runWithoutContext","fn","globalContext","moduleContext","wixContext","closureContext"]}
@@ -1,2 +1,2 @@
1
- import{a as J,b as G}from"./chunk-J7RIIVO6.js";import{a as q}from"./chunk-ZBGVDXLX.js";import"./chunk-J3SVE4GM.js";import"./chunk-7EYXEF6M.js";import"./chunk-SBZEOPXX.js";function C(){return C=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},C.apply(null,arguments)}import Re,{useEffect as De,useState as ye}from"react";function w(e){"@babel/helpers - typeof";return w=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(e)}function Q(e,t){if(w(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(w(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function $(e){var t=Q(e,"string");return w(t)=="symbol"?t:t+""}function X(e,t,n){return(t=$(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var k=class extends Error{constructor(t){let{message:n,code:r}=t;super(n),X(this,"code",void 0),this.message=n,this.code=r}};var Y=()=>{let e=c=>{let{channel:o}=c;return function(){let f=o.showToast(...arguments);return{remove:()=>Promise.resolve(f).then(h=>h.remove())}}},t=c=>{let{channel:o}=c;return function(){let f=o.observeState(...arguments);return{disconnect:()=>Promise.resolve(f).then(h=>h.disconnect())}}};return{showToast:e,observeState:t,navigate:c=>{let{channel:o}=c;return function(){return o.navigate(...arguments)}},navigateBack:c=>{let{channel:o}=c;return()=>o.navigateBack()},openModal:c=>{let{channel:o}=c;return(f,g)=>{let[h,U]=typeof f=="string"?[f,g]:[f.modalId,f.params],E=o.openModal(h,U);return{modalClosed:Promise.resolve(E).then(y=>y.modalClosed)}}},closeModal:c=>{let{channel:o}=c;return f=>{if(f===void 0)return o.closeModal();let g=JSON.parse(JSON.stringify(f));return o.closeModal(g)}},getAccessToken:c=>{let{channel:o}=c;return()=>o.getAccessToken()},getPageUrl:c=>{let{channel:o}=c;return function(){return o.getPageUrl(...arguments)}},openMediaManager:c=>{let{channel:o}=c;return function(){return o.openMediaManager(...arguments)}},addSitePlugin:c=>{let{channel:o}=c;return(f,g)=>{let h="802c76e4-b381-4bb3-9152-96acabbf3194",U=g?.placement||{},E=o.openModal(h,{...U,pluginId:f,action:"populate"});return Promise.resolve(E).then(y=>y.modalClosed).then(y=>{if(y?.type===void 0)throw new k({message:"Aborted by user",code:3006});if(y?.type==="ERROR")throw new k(y.data.error)})}},onBeforeUnload:c=>{let{channel:o}=c;return function(){return o.onBeforeUnload(...arguments)}},setPageTitle:c=>{let{channel:o}=c;return f=>o.setPageTitle(f)},getLanguage:c=>{let o=null;return async()=>{var f;if(o)return o;let g=null;return o=await new Promise(h=>{g=t(c)((U,E)=>{h(E.language)})}),(f=g)==null||f.disconnect(),o}},requestFeedback:c=>{let{channel:o}=c;return function(){return o.requestFeedback(...arguments)}},onLayerStateChange:c=>{let{channel:o}=c;return function(){let f=o.onLayerStateChange(...arguments);return{remove:()=>Promise.resolve(f).then(h=>h.remove())}}},installApp:c=>{let{channel:o}=c;return o.installApp},getSiteInfo:c=>{let{channel:o}=c;return o.getSiteInfo},getWidget:c=>{let{channel:o}=c;return function(){if("getWidget"in o)return o.getWidget(...arguments);throw new Error("Unsupported")}},getDashboardPlugins:c=>{let{channel:o}=c;return function(){if("getDashboardPlugins"in o)return o.getDashboardPlugins(...arguments);throw new Error("Unsupported")}},getDashboardMenuPlugins:c=>{let{channel:o}=c;return function(){if("getDashboardMenuPlugins"in o)return o.getDashboardMenuPlugins(...arguments);throw new Error("Unsupported")}}}};var Z=e=>{let{createHost:t}=e,n=Y();return{...J(n),host:t,auth:()=>({getAuthHeaders:async r=>({headers:{Authorization:await n.getAccessToken(r)()}})})}};var te=Symbol("Comlink.proxy"),we=Symbol("Comlink.endpoint"),D=Symbol("Comlink.releaseProxy"),L=Symbol("Comlink.thrown"),ne=e=>typeof e=="object"&&e!==null||typeof e=="function",xe={canHandle:e=>ne(e)&&e[te],serialize(e){let{port1:t,port2:n}=new MessageChannel;return W(e,t),[n,[n]]},deserialize(e){return e.start(),_(e)}},Pe={canHandle:e=>ne(e)&&L in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},re=new Map([["proxy",xe],["throw",Pe]]);function W(e,t=self){t.addEventListener("message",function n(r){if(!r||!r.data)return;let{id:s,type:a,path:u}=Object.assign({path:[]},r.data),i=(r.data.argumentList||[]).map(x),l;try{let d=u.slice(0,-1).reduce((m,b)=>m[b],e),p=u.reduce((m,b)=>m[b],e);switch(a){case 0:l=p;break;case 1:d[u.slice(-1)[0]]=x(r.data.value),l=!0;break;case 2:l=p.apply(d,i);break;case 3:{let m=new p(...i);l=A(m)}break;case 4:{let{port1:m,port2:b}=new MessageChannel;W(e,b),l=Se(m,[m])}break;case 5:l=void 0;break}}catch(d){l={value:d,[L]:0}}Promise.resolve(l).catch(d=>({value:d,[L]:0})).then(d=>{let[p,m]=B(d);t.postMessage(Object.assign(Object.assign({},p),{id:s}),m),a===5&&(t.removeEventListener("message",n),oe(t))})}),t.start&&t.start()}function ve(e){return e.constructor.name==="MessagePort"}function oe(e){ve(e)&&e.close()}function _(e,t){return R(e,[],t)}function O(e){if(e)throw new Error("Proxy has been released and is not useable")}function R(e,t=[],n=function(){}){let r=!1,s=new Proxy(n,{get(a,u){if(O(r),u===D)return()=>M(e,{type:5,path:t.map(i=>i.toString())}).then(()=>{oe(e),r=!0});if(u==="then"){if(t.length===0)return{then:()=>s};let i=M(e,{type:0,path:t.map(l=>l.toString())}).then(x);return i.then.bind(i)}return R(e,[...t,u])},set(a,u,i){O(r);let[l,d]=B(i);return M(e,{type:1,path:[...t,u].map(p=>p.toString()),value:l},d).then(x)},apply(a,u,i){O(r);let l=t[t.length-1];if(l===we)return M(e,{type:4}).then(x);if(l==="bind")return R(e,t.slice(0,-1));let[d,p]=ee(i);return M(e,{type:2,path:t.map(m=>m.toString()),argumentList:d},p).then(x)},construct(a,u){O(r);let[i,l]=ee(u);return M(e,{type:3,path:t.map(d=>d.toString()),argumentList:i},l).then(x)}});return s}function Me(e){return Array.prototype.concat.apply([],e)}function ee(e){let t=e.map(B);return[t.map(n=>n[0]),Me(t.map(n=>n[1]))]}var se=new WeakMap;function Se(e,t){return se.set(e,t),e}function A(e){return Object.assign(e,{[te]:!0})}function B(e){for(let[t,n]of re)if(n.canHandle(e)){let[r,s]=n.serialize(e);return[{type:3,name:t,value:r},s]}return[{type:0,value:e},se.get(e)||[]]}function x(e){switch(e.type){case 3:return re.get(e.name).deserialize(e.value);case 0:return e.value}}function M(e,t,n){return new Promise(r=>{let s=Ee();e.addEventListener("message",function a(u){!u.data||!u.data.id||u.data.id!==s||(e.removeEventListener("message",a),r(u.data))}),e.start&&e.start(),e.postMessage(Object.assign({id:s},t),n)})}function Ee(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var T="__proxyCallbackId__wixSDK__",j="__proxyPromiseId__wixSDK__",ie=e=>Ae(e,t=>async function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];let[a,u]=z(r),i=await t(A(a),u);return ce(i)});var ke=async e=>{let[t,n]=z(await e);return A({proxies:t,clonables:n})},ce=async e=>I(e?.proxies,await e?.clonables),z=e=>{let t=(s,a)=>{if(ue(a)){let u=ae();return s.promises[u]=a,{[j]:u}}if(Ue(a)){let u=ae();return s.callbacks[u]=(i,l)=>{let d=I(i,l),p=a(...d);return ke(p)},{[T]:u}}return Array.isArray(a)?a.map(u=>t(s,u)):H(a)?le(a,u=>t(s,u)):a},n={promises:{},callbacks:{}},r=t(n,e);return[n,r]},I=(e,t)=>{if(Array.isArray(t))return t.map(n=>I(e,n));if(H(t)&&t.hasOwnProperty(j)){let n=t[j];return e.promises[n]}if(H(t)&&t.hasOwnProperty(T)){let n=t[T];return async function(){for(var r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];let[u,i]=z(s),l=await e.callbacks[n](A(u),i);return ce(l)}}return H(t)?le(t,n=>I(e,n)):t},Ae=(e,t)=>new Proxy(e,{get(n,r){return n[r]?t(n[r]):()=>{throw new Error(`Serialization error occurred while accessing ${r} property of ${n}`)}}}),ue=e=>e instanceof Promise,H=e=>e&&typeof e=="object"&&!ue(e),Ue=e=>typeof e=="function",le=(e,t)=>{let n=r=>{let[s,a]=r;return[s,t(a)]};return Object.fromEntries(Object.entries(e).map(n))},ae=(()=>{let e=0;return()=>++e})();var Ce="wix-sdk-bo-hello-handshake",de=e=>{let{postMessage:t,origin:n}=e,{port1:r,port2:s}=new MessageChannel;t({code:Ce,version:"1.0.0",port:s},n,[s]);let i=ie(_(r));return{channel:i,close:()=>i[D]()}};var fe=(e,t)=>{let n=()=>e.updateHeight(t.offsetHeight),r=new ResizeObserver(n);return r.observe(t),()=>r.disconnect()};var Oe=["https://manage.wix.com","https://manage.editorx.com"],He=new Set(Oe),me=e=>He.has(e);var pe=e=>{let t=new EventTarget,n=typeof window>"u",r=i=>{t.dispatchEvent(new CustomEvent("beforeunload",{cancelable:!0}))||(i.preventDefault(),i.returnValue=!0)},s=e.onBeforeUnload(r),a=()=>{n||window.removeEventListener("beforeunload",r),s.then(i=>{let{remove:l}=i;return l()})};return n||(window.addEventListener("beforeunload",r),window.addEventListener("unload",a)),{onBeforeUnload:i=>(t.addEventListener("beforeunload",i),{remove:()=>{t.removeEventListener("beforeunload",i)}}),clearBeforeUnloadHandler:a}};function Ie(e){if(e)try{return JSON.parse(decodeURIComponent(e))}catch(t){console.warn('Failed to parse "essentials" query parameter. Make sure to run the code inside a supported Wix App extension.',t);return}}function ge(e){return e.has("essentials")?Ie(e.get("essentials")):void 0}var he=function(e){e===void 0&&(e={});let t=e.fullUrl&&new URL(e.fullUrl).search||typeof window<"u"&&window.location.search||"",n=new URLSearchParams(t),r=e.origin||n.get("origin")||"",s=e.postMessage||window.parent.postMessage.bind(window.parent);if(!me(r))throw new Error("Wix Dashboard SDK: Unable to establish a connection with the Wix dashboard. Please ensure that you are running your app within the Wix dashboard.");let{channel:a,close:u}=de({postMessage:s,origin:r}),i=[u];if(e.autoHeightUpdate===void 0||e.autoHeightUpdate){let P=e.autoHeightElement||document.documentElement,v=fe(a,P);i.push(()=>v())}let{onBeforeUnload:l,clearBeforeUnloadHandler:d}=pe(a);i.push(d);let p=Le(n.get("siteInfo")||""),m=()=>p,b=new Proxy(a,{get(P,v,K){return v==="onBeforeUnload"?l:v==="getSiteInfo"?m:Reflect.get(P,v,K)}}),{monitoring:S,...F}=ge(n)||{},N=G({hostContext:S?.context,monitoringConfig:S?.config,sentrySDK:typeof window<"u"?window.Sentry:void 0});return{channel:b,close:()=>i.forEach(P=>P()),getMonitoringClient:N,essentials:F}},Le=e=>{try{return JSON.parse(decodeURIComponent(e))}catch(t){return console.warn('Failed to parse "siteInfo" query parameter. Make sure to run the code inside a supported Wix App extension.',t),{}}};var V=Z({createHost:he});var be=(e,t)=>{let[n,r]=ye(()=>e());return t(n)&&r(e()),n},We=e=>t=>{let{host:n,compProps:r}=_e(t);return be(()=>(q({auth:V.auth(),host:n}).enableContext("module"),n),s=>s!==n),r?Re.createElement(e,C({host:n},r)):null},_e=e=>{let{host:t,...n}=e,{host:r,hostType:s}=be(()=>t?{host:t,hostType:"local"}:{host:V.host(),hostType:"remote"},i=>!!t&&t!==i.host),[a,u]=ye(void 0);return De(()=>{if(s==="local")return;let i=r.channel.observeState(d=>{u(d||{})}),l=async()=>{(await i).disconnect(),r.close()};return()=>{l()}},[r,s]),s==="local"?{host:r,compProps:n}:{host:r,compProps:a?{...a,...n}:void 0}};export{We as withContextualWixClient};
1
+ import{a as J,b as G}from"./chunk-BBFFXVJD.js";import{a as q}from"./chunk-MAZR75DI.js";import"./chunk-NHYZDMR5.js";import"./chunk-7EYXEF6M.js";import"./chunk-SBZEOPXX.js";function C(){return C=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},C.apply(null,arguments)}import Re,{useEffect as De,useState as ye}from"react";function w(e){"@babel/helpers - typeof";return w=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(e)}function Q(e,t){if(w(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(w(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function $(e){var t=Q(e,"string");return w(t)=="symbol"?t:t+""}function X(e,t,n){return(t=$(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var k=class extends Error{constructor(t){let{message:n,code:r}=t;super(n),X(this,"code",void 0),this.message=n,this.code=r}};var Y=()=>{let e=c=>{let{channel:o}=c;return function(){let f=o.showToast(...arguments);return{remove:()=>Promise.resolve(f).then(h=>h.remove())}}},t=c=>{let{channel:o}=c;return function(){let f=o.observeState(...arguments);return{disconnect:()=>Promise.resolve(f).then(h=>h.disconnect())}}};return{showToast:e,observeState:t,navigate:c=>{let{channel:o}=c;return function(){return o.navigate(...arguments)}},navigateBack:c=>{let{channel:o}=c;return()=>o.navigateBack()},openModal:c=>{let{channel:o}=c;return(f,g)=>{let[h,U]=typeof f=="string"?[f,g]:[f.modalId,f.params],E=o.openModal(h,U);return{modalClosed:Promise.resolve(E).then(y=>y.modalClosed)}}},closeModal:c=>{let{channel:o}=c;return f=>{if(f===void 0)return o.closeModal();let g=JSON.parse(JSON.stringify(f));return o.closeModal(g)}},getAccessToken:c=>{let{channel:o}=c;return()=>o.getAccessToken()},getPageUrl:c=>{let{channel:o}=c;return function(){return o.getPageUrl(...arguments)}},openMediaManager:c=>{let{channel:o}=c;return function(){return o.openMediaManager(...arguments)}},addSitePlugin:c=>{let{channel:o}=c;return(f,g)=>{let h="802c76e4-b381-4bb3-9152-96acabbf3194",U=g?.placement||{},E=o.openModal(h,{...U,pluginId:f,action:"populate"});return Promise.resolve(E).then(y=>y.modalClosed).then(y=>{if(y?.type===void 0)throw new k({message:"Aborted by user",code:3006});if(y?.type==="ERROR")throw new k(y.data.error)})}},onBeforeUnload:c=>{let{channel:o}=c;return function(){return o.onBeforeUnload(...arguments)}},setPageTitle:c=>{let{channel:o}=c;return f=>o.setPageTitle(f)},getLanguage:c=>{let o=null;return async()=>{var f;if(o)return o;let g=null;return o=await new Promise(h=>{g=t(c)((U,E)=>{h(E.language)})}),(f=g)==null||f.disconnect(),o}},requestFeedback:c=>{let{channel:o}=c;return function(){return o.requestFeedback(...arguments)}},onLayerStateChange:c=>{let{channel:o}=c;return function(){let f=o.onLayerStateChange(...arguments);return{remove:()=>Promise.resolve(f).then(h=>h.remove())}}},installApp:c=>{let{channel:o}=c;return o.installApp},getSiteInfo:c=>{let{channel:o}=c;return o.getSiteInfo},getWidget:c=>{let{channel:o}=c;return function(){if("getWidget"in o)return o.getWidget(...arguments);throw new Error("Unsupported")}},getDashboardPlugins:c=>{let{channel:o}=c;return function(){if("getDashboardPlugins"in o)return o.getDashboardPlugins(...arguments);throw new Error("Unsupported")}},getDashboardMenuPlugins:c=>{let{channel:o}=c;return function(){if("getDashboardMenuPlugins"in o)return o.getDashboardMenuPlugins(...arguments);throw new Error("Unsupported")}}}};var Z=e=>{let{createHost:t}=e,n=Y();return{...J(n),host:t,auth:()=>({getAuthHeaders:async r=>({headers:{Authorization:await n.getAccessToken(r)()}})})}};var te=Symbol("Comlink.proxy"),we=Symbol("Comlink.endpoint"),D=Symbol("Comlink.releaseProxy"),L=Symbol("Comlink.thrown"),ne=e=>typeof e=="object"&&e!==null||typeof e=="function",xe={canHandle:e=>ne(e)&&e[te],serialize(e){let{port1:t,port2:n}=new MessageChannel;return W(e,t),[n,[n]]},deserialize(e){return e.start(),_(e)}},Pe={canHandle:e=>ne(e)&&L in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},re=new Map([["proxy",xe],["throw",Pe]]);function W(e,t=self){t.addEventListener("message",function n(r){if(!r||!r.data)return;let{id:s,type:a,path:u}=Object.assign({path:[]},r.data),i=(r.data.argumentList||[]).map(x),l;try{let d=u.slice(0,-1).reduce((m,b)=>m[b],e),p=u.reduce((m,b)=>m[b],e);switch(a){case 0:l=p;break;case 1:d[u.slice(-1)[0]]=x(r.data.value),l=!0;break;case 2:l=p.apply(d,i);break;case 3:{let m=new p(...i);l=A(m)}break;case 4:{let{port1:m,port2:b}=new MessageChannel;W(e,b),l=Se(m,[m])}break;case 5:l=void 0;break}}catch(d){l={value:d,[L]:0}}Promise.resolve(l).catch(d=>({value:d,[L]:0})).then(d=>{let[p,m]=B(d);t.postMessage(Object.assign(Object.assign({},p),{id:s}),m),a===5&&(t.removeEventListener("message",n),oe(t))})}),t.start&&t.start()}function ve(e){return e.constructor.name==="MessagePort"}function oe(e){ve(e)&&e.close()}function _(e,t){return R(e,[],t)}function O(e){if(e)throw new Error("Proxy has been released and is not useable")}function R(e,t=[],n=function(){}){let r=!1,s=new Proxy(n,{get(a,u){if(O(r),u===D)return()=>M(e,{type:5,path:t.map(i=>i.toString())}).then(()=>{oe(e),r=!0});if(u==="then"){if(t.length===0)return{then:()=>s};let i=M(e,{type:0,path:t.map(l=>l.toString())}).then(x);return i.then.bind(i)}return R(e,[...t,u])},set(a,u,i){O(r);let[l,d]=B(i);return M(e,{type:1,path:[...t,u].map(p=>p.toString()),value:l},d).then(x)},apply(a,u,i){O(r);let l=t[t.length-1];if(l===we)return M(e,{type:4}).then(x);if(l==="bind")return R(e,t.slice(0,-1));let[d,p]=ee(i);return M(e,{type:2,path:t.map(m=>m.toString()),argumentList:d},p).then(x)},construct(a,u){O(r);let[i,l]=ee(u);return M(e,{type:3,path:t.map(d=>d.toString()),argumentList:i},l).then(x)}});return s}function Me(e){return Array.prototype.concat.apply([],e)}function ee(e){let t=e.map(B);return[t.map(n=>n[0]),Me(t.map(n=>n[1]))]}var se=new WeakMap;function Se(e,t){return se.set(e,t),e}function A(e){return Object.assign(e,{[te]:!0})}function B(e){for(let[t,n]of re)if(n.canHandle(e)){let[r,s]=n.serialize(e);return[{type:3,name:t,value:r},s]}return[{type:0,value:e},se.get(e)||[]]}function x(e){switch(e.type){case 3:return re.get(e.name).deserialize(e.value);case 0:return e.value}}function M(e,t,n){return new Promise(r=>{let s=Ee();e.addEventListener("message",function a(u){!u.data||!u.data.id||u.data.id!==s||(e.removeEventListener("message",a),r(u.data))}),e.start&&e.start(),e.postMessage(Object.assign({id:s},t),n)})}function Ee(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var T="__proxyCallbackId__wixSDK__",j="__proxyPromiseId__wixSDK__",ie=e=>Ae(e,t=>async function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];let[a,u]=z(r),i=await t(A(a),u);return ce(i)});var ke=async e=>{let[t,n]=z(await e);return A({proxies:t,clonables:n})},ce=async e=>I(e?.proxies,await e?.clonables),z=e=>{let t=(s,a)=>{if(ue(a)){let u=ae();return s.promises[u]=a,{[j]:u}}if(Ue(a)){let u=ae();return s.callbacks[u]=(i,l)=>{let d=I(i,l),p=a(...d);return ke(p)},{[T]:u}}return Array.isArray(a)?a.map(u=>t(s,u)):H(a)?le(a,u=>t(s,u)):a},n={promises:{},callbacks:{}},r=t(n,e);return[n,r]},I=(e,t)=>{if(Array.isArray(t))return t.map(n=>I(e,n));if(H(t)&&t.hasOwnProperty(j)){let n=t[j];return e.promises[n]}if(H(t)&&t.hasOwnProperty(T)){let n=t[T];return async function(){for(var r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];let[u,i]=z(s),l=await e.callbacks[n](A(u),i);return ce(l)}}return H(t)?le(t,n=>I(e,n)):t},Ae=(e,t)=>new Proxy(e,{get(n,r){return n[r]?t(n[r]):()=>{throw new Error(`Serialization error occurred while accessing ${r} property of ${n}`)}}}),ue=e=>e instanceof Promise,H=e=>e&&typeof e=="object"&&!ue(e),Ue=e=>typeof e=="function",le=(e,t)=>{let n=r=>{let[s,a]=r;return[s,t(a)]};return Object.fromEntries(Object.entries(e).map(n))},ae=(()=>{let e=0;return()=>++e})();var Ce="wix-sdk-bo-hello-handshake",de=e=>{let{postMessage:t,origin:n}=e,{port1:r,port2:s}=new MessageChannel;t({code:Ce,version:"1.0.0",port:s},n,[s]);let i=ie(_(r));return{channel:i,close:()=>i[D]()}};var fe=(e,t)=>{let n=()=>e.updateHeight(t.offsetHeight),r=new ResizeObserver(n);return r.observe(t),()=>r.disconnect()};var Oe=["https://manage.wix.com","https://manage.editorx.com"],He=new Set(Oe),me=e=>He.has(e);var pe=e=>{let t=new EventTarget,n=typeof window>"u",r=i=>{t.dispatchEvent(new CustomEvent("beforeunload",{cancelable:!0}))||(i.preventDefault(),i.returnValue=!0)},s=e.onBeforeUnload(r),a=()=>{n||window.removeEventListener("beforeunload",r),s.then(i=>{let{remove:l}=i;return l()})};return n||(window.addEventListener("beforeunload",r),window.addEventListener("unload",a)),{onBeforeUnload:i=>(t.addEventListener("beforeunload",i),{remove:()=>{t.removeEventListener("beforeunload",i)}}),clearBeforeUnloadHandler:a}};function Ie(e){if(e)try{return JSON.parse(decodeURIComponent(e))}catch(t){console.warn('Failed to parse "essentials" query parameter. Make sure to run the code inside a supported Wix App extension.',t);return}}function ge(e){return e.has("essentials")?Ie(e.get("essentials")):void 0}var he=function(e){e===void 0&&(e={});let t=e.fullUrl&&new URL(e.fullUrl).search||typeof window<"u"&&window.location.search||"",n=new URLSearchParams(t),r=e.origin||n.get("origin")||"",s=e.postMessage||window.parent.postMessage.bind(window.parent);if(!me(r))throw new Error("Wix Dashboard SDK: Unable to establish a connection with the Wix dashboard. Please ensure that you are running your app within the Wix dashboard.");let{channel:a,close:u}=de({postMessage:s,origin:r}),i=[u];if(e.autoHeightUpdate===void 0||e.autoHeightUpdate){let P=e.autoHeightElement||document.documentElement,v=fe(a,P);i.push(()=>v())}let{onBeforeUnload:l,clearBeforeUnloadHandler:d}=pe(a);i.push(d);let p=Le(n.get("siteInfo")||""),m=()=>p,b=new Proxy(a,{get(P,v,K){return v==="onBeforeUnload"?l:v==="getSiteInfo"?m:Reflect.get(P,v,K)}}),{monitoring:S,...F}=ge(n)||{},N=G({hostContext:S?.context,monitoringConfig:S?.config,sentrySDK:typeof window<"u"?window.Sentry:void 0});return{channel:b,close:()=>i.forEach(P=>P()),getMonitoringClient:N,essentials:F}},Le=e=>{try{return JSON.parse(decodeURIComponent(e))}catch(t){return console.warn('Failed to parse "siteInfo" query parameter. Make sure to run the code inside a supported Wix App extension.',t),{}}};var V=Z({createHost:he});var be=(e,t)=>{let[n,r]=ye(()=>e());return t(n)&&r(e()),n},We=e=>t=>{let{host:n,compProps:r}=_e(t);return be(()=>(q({auth:V.auth(),host:n}).enableContext("module"),n),s=>s!==n),r?Re.createElement(e,C({host:n},r)):null},_e=e=>{let{host:t,...n}=e,{host:r,hostType:s}=be(()=>t?{host:t,hostType:"local"}:{host:V.host(),hostType:"remote"},i=>!!t&&t!==i.host),[a,u]=ye(void 0);return De(()=>{if(s==="local")return;let i=r.channel.observeState(d=>{u(d||{})}),l=async()=>{(await i).disconnect(),r.close()};return()=>{l()}},[r,s]),s==="local"?{host:r,compProps:n}:{host:r,compProps:a?{...a,...n}:void 0}};export{We as withContextualWixClient};
2
2
  //# sourceMappingURL=dashboard.js.map
@@ -1,8 +1,8 @@
1
- import{a as Ee,b as be}from"./chunk-J7RIIVO6.js";import{a as ve}from"./chunk-ZBGVDXLX.js";import"./chunk-J3SVE4GM.js";import{c as Qe,d as Ze}from"./chunk-7EYXEF6M.js";import{b as ye,d as we,e as Xe,f as l,g as a,h,i as w,j as u}from"./chunk-SBZEOPXX.js";var xe=ye(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.EventType=void 0;var Ce;(function(i){i.removeAppCompleted="removeAppCompleted",i.componentSelectionChanged="componentSelectionChanged",i.appInstalled="appInstalled",i.appUpdateCompleted="appUpdateCompleted"})(Ce||(lt.EventType=Ce={}))});var Ot=ye(I=>{"use strict";var ti=I&&I.__createBinding||(Object.create?function(i,t,e,n){n===void 0&&(n=e);var s=Object.getOwnPropertyDescriptor(t,e);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(i,n,s)}:function(i,t,e,n){n===void 0&&(n=e),i[n]=t[e]}),ei=I&&I.__setModuleDefault||(Object.create?function(i,t){Object.defineProperty(i,"default",{enumerable:!0,value:t})}:function(i,t){i.default=t}),ii=I&&I.__importStar||function(){var i=function(t){return i=Object.getOwnPropertyNames||function(e){var n=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[n.length]=s);return n},i(t)};return function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n=i(t),s=0;s<n.length;s++)n[s]!=="default"&&ti(e,t,n[s]);return ei(e,t),e}}();Object.defineProperty(I,"__esModule",{value:!0});I.EventType=I.WixSDKTypes=void 0;var ni=ii((Ze(),Xe(Qe)));I.WixSDKTypes=ni;var si=xe();Object.defineProperty(I,"EventType",{enumerable:!0,get:function(){return si.EventType}})});var G=we(Ot(),1);var S=class S{constructor(){l(this,"uid",0);l(this,"callbacks",new Map);l(this,"inTransaction",!1);l(this,"isSilent",!1);l(this,"queue",[])}silent(t=!0){this.isSilent=t}startTransaction(){this.inTransaction=!0}commit(){this.inTransaction=!1;let t=this.queue;this.queue=[],this.isSilent||t.forEach(e=>{this.notify(e)})}notify(t){this.isSilent||(this.inTransaction?this.queue.push(t):this.callbacks.forEach(e=>{e(t)}))}subscribe(t){let e=this.uid++;return this.callbacks.set(e,t),()=>{this.callbacks.delete(e)}}notifyWithStep(t,e){this.notify({...t,meta:{...t.meta,step:e}})}async withEvent(t,e){let n=e();if(n&&n.hasOwnProperty("then"))try{return this.notifyWithStep(t,S.EventSteps.Start),n=await n,this.notifyWithStep(t,S.EventSteps.End),n}catch(s){throw this.notifyWithStep({...t,meta:{...t.meta,error:s}},S.EventSteps.Error),s}else return this.notify(t),n}};l(S,"biEvents",{PLATFORM_WORKER_SPAWN:123,PLATFORM_APP_RUNNER_INIT_APP_API:124,PLATFORM_APP_RUNNER_RUN_APP:125,PLATFORM_APP_RUNNER_REMOVE_APP:126,PLATFORM_WORKER_APP_BUNDLE_LOAD:127,PLATFORM_WORKER_APP_BUNDLE_EXECUTE:128,PLATFORM_IFRAME_INIT:129,PLATFORM_APP_API_INIT:130,PLATFORM_APP_API_GET:131}),l(S,"EventSteps",{Start:"start",End:"end",Error:"error"});var kt=S,ht=(i=>(i.WorkerSpawn="WorkerSpawn",i.HostEvent="HostEvent",i.ApplicationsSpecsReceived="ApplicationsSpecsReceived",i.InitApplicationApi="InitApplicationApi",i.RunApplication="RunApplication",i.getApplicationApi="getApplicationApi",i.IframeInit="IframeInit",i))(ht||{}),Ut=(i=>(i.EditorReady="EditorReady",i))(Ut||{});var v=(i=>(i.ApplicationInit="ApplicationInit",i.ApplicationExecute="ApplicationExecute",i.ApplicationRemoved="ApplicationRemoved",i.ApplicationLoad="ApplicationLoad",i.ApplicationApiInit="ApplicationApiInit",i.CustomEvent="CustomEvent",i.HostEvent="HostEvent",i.EditorReady="EditorReady",i))(v||{}),Lt=class{createApplicationRemovedEvent(t){return{type:"ApplicationRemoved",payload:{appDefinitionId:t},meta:{bi:{evid:b.biEvents.PLATFORM_WORKER_SPAWN,appDefId:t}}}}createApplicationLoadEvent(t,e){return{type:"ApplicationLoad",payload:{appDefinitionId:t.appDefinitionId,url:e},meta:{bi:{evid:b.biEvents.PLATFORM_WORKER_APP_BUNDLE_LOAD,appDefId:t.appDefinitionId,appType:t.appType,bundleUrl:e}}}}createApplicationExecuteEvent(t,e){return{type:"ApplicationExecute",payload:{appDefinitionId:t.appDefinitionId,url:e},meta:{bi:{evid:b.biEvents.PLATFORM_WORKER_APP_BUNDLE_EXECUTE,appDefId:t.appDefinitionId,appType:t.appType,bundleUrl:e}}}}createApplicationApiInitEvent(t,e){return{type:"ApplicationApiInit",payload:{appDefinitionId:t},meta:{bi:{evid:b.biEvents.PLATFORM_APP_API_INIT,appDefId:t,scope:e}}}}},b=class extends kt{constructor(){super(...arguments);l(this,"factories",new Lt)}},pt=class pt{constructor(t){this.events=t}mapToPlatformHostEvent(t){if(typeof t=="string")try{t=JSON.parse(t)}catch{}return{type:ht.HostEvent,payload:{type:t.args.eventType,...t.args.eventPayload},meta:{appDefinitionId:t.appDefinitionId??null,intent:t.intent}}}notify(t){let e=this.mapToPlatformHostEvent(t);pt.allowedEvents.includes(e.payload.type)&&this.events.notify(e)}};l(pt,"allowedEvents",[G.EventType.componentSelectionChanged,G.EventType.appInstalled,G.EventType.appUpdateCompleted,G.EventType.removeAppCompleted]);var Te=pt;var A=class i extends Error{constructor(e,n,s){let r=e?` ${e}`:"",o=`[${s}]#${n}`;super(`${o}.${r}`);l(this,"state",{});l(this,"displayName");l(this,"prefix");l(this,"errorMessage");l(this,"parent");l(this,"messages",[]);l(this,"code");this.displayName=o,this.errorMessage=e,this.prefix=s,this.code=n,this.name=o,Object.defineProperty(this,"message",{get:()=>this.getDisplayMessage()}),Error.captureStackTrace&&Error.captureStackTrace(this,i)}get parentError(){let e=this.parent;if(!e)return null;if(this.parent instanceof i)return this.parent;let n=e.name??"[Unknown Error]";return{getBreadcrumbs(){return[n]},getMessage(){return[n,e.message??"unknown error message"].join(`
1
+ import{a as Ee,b as be}from"./chunk-BBFFXVJD.js";import{a as ve}from"./chunk-MAZR75DI.js";import"./chunk-NHYZDMR5.js";import{c as Qe,d as Ze}from"./chunk-7EYXEF6M.js";import{b as ye,d as we,e as Xe,f as l,g as a,h,i as w,j as u}from"./chunk-SBZEOPXX.js";var xe=ye(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.EventType=void 0;var Ce;(function(i){i.removeAppCompleted="removeAppCompleted",i.componentSelectionChanged="componentSelectionChanged",i.appInstalled="appInstalled",i.appUpdateCompleted="appUpdateCompleted"})(Ce||(lt.EventType=Ce={}))});var Ot=ye(I=>{"use strict";var ti=I&&I.__createBinding||(Object.create?function(i,t,e,n){n===void 0&&(n=e);var s=Object.getOwnPropertyDescriptor(t,e);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(i,n,s)}:function(i,t,e,n){n===void 0&&(n=e),i[n]=t[e]}),ei=I&&I.__setModuleDefault||(Object.create?function(i,t){Object.defineProperty(i,"default",{enumerable:!0,value:t})}:function(i,t){i.default=t}),ii=I&&I.__importStar||function(){var i=function(t){return i=Object.getOwnPropertyNames||function(e){var n=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[n.length]=s);return n},i(t)};return function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n=i(t),s=0;s<n.length;s++)n[s]!=="default"&&ti(e,t,n[s]);return ei(e,t),e}}();Object.defineProperty(I,"__esModule",{value:!0});I.EventType=I.WixSDKTypes=void 0;var ni=ii((Ze(),Xe(Qe)));I.WixSDKTypes=ni;var si=xe();Object.defineProperty(I,"EventType",{enumerable:!0,get:function(){return si.EventType}})});var G=we(Ot(),1);var S=class S{constructor(){l(this,"uid",0);l(this,"callbacks",new Map);l(this,"inTransaction",!1);l(this,"isSilent",!1);l(this,"queue",[])}silent(t=!0){this.isSilent=t}startTransaction(){this.inTransaction=!0}commit(){this.inTransaction=!1;let t=this.queue;this.queue=[],this.isSilent||t.forEach(e=>{this.notify(e)})}notify(t){this.isSilent||(this.inTransaction?this.queue.push(t):this.callbacks.forEach(e=>{e(t)}))}subscribe(t){let e=this.uid++;return this.callbacks.set(e,t),()=>{this.callbacks.delete(e)}}notifyWithStep(t,e){this.notify({...t,meta:{...t.meta,step:e}})}async withEvent(t,e){let n=e();if(n&&n.hasOwnProperty("then"))try{return this.notifyWithStep(t,S.EventSteps.Start),n=await n,this.notifyWithStep(t,S.EventSteps.End),n}catch(s){throw this.notifyWithStep({...t,meta:{...t.meta,error:s}},S.EventSteps.Error),s}else return this.notify(t),n}};l(S,"biEvents",{PLATFORM_WORKER_SPAWN:123,PLATFORM_APP_RUNNER_INIT_APP_API:124,PLATFORM_APP_RUNNER_RUN_APP:125,PLATFORM_APP_RUNNER_REMOVE_APP:126,PLATFORM_WORKER_APP_BUNDLE_LOAD:127,PLATFORM_WORKER_APP_BUNDLE_EXECUTE:128,PLATFORM_IFRAME_INIT:129,PLATFORM_APP_API_INIT:130,PLATFORM_APP_API_GET:131}),l(S,"EventSteps",{Start:"start",End:"end",Error:"error"});var kt=S,ht=(i=>(i.WorkerSpawn="WorkerSpawn",i.HostEvent="HostEvent",i.ApplicationsSpecsReceived="ApplicationsSpecsReceived",i.InitApplicationApi="InitApplicationApi",i.RunApplication="RunApplication",i.getApplicationApi="getApplicationApi",i.IframeInit="IframeInit",i))(ht||{}),Ut=(i=>(i.EditorReady="EditorReady",i))(Ut||{});var v=(i=>(i.ApplicationInit="ApplicationInit",i.ApplicationExecute="ApplicationExecute",i.ApplicationRemoved="ApplicationRemoved",i.ApplicationLoad="ApplicationLoad",i.ApplicationApiInit="ApplicationApiInit",i.CustomEvent="CustomEvent",i.HostEvent="HostEvent",i.EditorReady="EditorReady",i))(v||{}),Lt=class{createApplicationRemovedEvent(t){return{type:"ApplicationRemoved",payload:{appDefinitionId:t},meta:{bi:{evid:b.biEvents.PLATFORM_WORKER_SPAWN,appDefId:t}}}}createApplicationLoadEvent(t,e){return{type:"ApplicationLoad",payload:{appDefinitionId:t.appDefinitionId,url:e},meta:{bi:{evid:b.biEvents.PLATFORM_WORKER_APP_BUNDLE_LOAD,appDefId:t.appDefinitionId,appType:t.appType,bundleUrl:e}}}}createApplicationExecuteEvent(t,e){return{type:"ApplicationExecute",payload:{appDefinitionId:t.appDefinitionId,url:e},meta:{bi:{evid:b.biEvents.PLATFORM_WORKER_APP_BUNDLE_EXECUTE,appDefId:t.appDefinitionId,appType:t.appType,bundleUrl:e}}}}createApplicationApiInitEvent(t,e){return{type:"ApplicationApiInit",payload:{appDefinitionId:t},meta:{bi:{evid:b.biEvents.PLATFORM_APP_API_INIT,appDefId:t,scope:e}}}}},b=class extends kt{constructor(){super(...arguments);l(this,"factories",new Lt)}},pt=class pt{constructor(t){this.events=t}mapToPlatformHostEvent(t){if(typeof t=="string")try{t=JSON.parse(t)}catch{}return{type:ht.HostEvent,payload:{type:t.args.eventType,...t.args.eventPayload},meta:{appDefinitionId:t.appDefinitionId??null,intent:t.intent}}}notify(t){let e=this.mapToPlatformHostEvent(t);pt.allowedEvents.includes(e.payload.type)&&this.events.notify(e)}};l(pt,"allowedEvents",[G.EventType.componentSelectionChanged,G.EventType.appInstalled,G.EventType.appUpdateCompleted,G.EventType.removeAppCompleted]);var Te=pt;var A=class i extends Error{constructor(e,n,s){let r=e?` ${e}`:"",o=`[${s}]#${n}`;super(`${o}.${r}`);l(this,"state",{});l(this,"displayName");l(this,"prefix");l(this,"errorMessage");l(this,"parent");l(this,"messages",[]);l(this,"code");this.displayName=o,this.errorMessage=e,this.prefix=s,this.code=n,this.name=o,Object.defineProperty(this,"message",{get:()=>this.getDisplayMessage()}),Error.captureStackTrace&&Error.captureStackTrace(this,i)}get parentError(){let e=this.parent;if(!e)return null;if(this.parent instanceof i)return this.parent;let n=e.name??"[Unknown Error]";return{getBreadcrumbs(){return[n]},getMessage(){return[n,e.message??"unknown error message"].join(`
2
2
  `)}}}getDisplayMessage(){return[(this.parentError?this.getBreadcrumbs():[]).join(" -> "),this.getMessage()].filter(n=>n.trim().length).join(`
3
3
  `)}getMessage(){let e=Object.entries(this.state).reduce((c,[p,d])=>(d&&c.push(` \u2013 ${p}: ${d}`),c),[]).join(`
4
4
  `),n=this.messages.reduce((c,p)=>(c.push(` - ${p.join(" ")}`),c),[]).join(`
5
5
  `),s=this.parentError,r=s?["",s.getMessage(),""].join(`
6
6
  `):"",o=this.errorMessage?`${this.displayName}: ${this.errorMessage}`:this.displayName;return[r,o,e,n].filter(c=>c.trim().length).join(`
7
- `)}getBreadcrumbs(){let e=this.parentError;return e?[...e.getBreadcrumbs(),this.displayName]:[this.displayName]}withParentError(e){return this.parent=e,this}withMessage(...e){return this.messages.push(e),this}};function E(i){return function t(e,n=""){let s=new i(n,e);return Error.captureStackTrace&&Error.captureStackTrace(s,t),s}}var jt=class extends A{constructor(e,n){super(e,n,"Editor Platform Internal Error");l(this,"state",{})}withHost(e){return this.state={...this.state,host:e},this}},ri=E(jt);var $=(i=>(i.IncorrectEnvironment="IncorrectEnvironment",i))($||{}),$t=class extends A{constructor(e,n){super(e,n,"EP Context Error");l(this,"state",{})}withUrl(e){return this.state={...this.state,url:e},this}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}},J=E($t);async function oi(i,t){if(!i?.type)return i;switch(i.type){case"componentSelectionChanged":let e=i.componentRefs||[],n=await Promise.all(e.map(s=>t.components.getComponent(s)));return{type:i.type,components:n};default:return i}}var Wt=class{constructor(t,e,n){l(this,"events");l(this,"subscribe");l(this,"commit");l(this,"startTransaction");l(this,"silent");this.appDefinitionId=t,this.privateAPI=n,this.events=e,this.subscribe=e.subscribe.bind(e),this.commit=e.commit.bind(e),this.startTransaction=e.startTransaction.bind(e),this.silent=e.silent.bind(e)}notify(t){this.events.notify({type:t.type,payload:t.payload,meta:{appDefinitionId:this.appDefinitionId}})}notifyCustomEvent(t,e){this.notify({type:v.CustomEvent,payload:{...e,type:t}})}addEventListener(t,e){return this.events.subscribe(async n=>{let s=n.meta?.appDefinitionId===this.appDefinitionId||n.meta?.appDefinitionId===null,r=()=>oi(n.payload,this.privateAPI);t==="*"?e(await r()):n.type===v.CustomEvent?t===n.payload?.type&&!s&&e(await r()):n.type===v.HostEvent&&t===n.payload?.type&&s&&e(await r())})}},ai=200,ci=50,O,qt,Me,ut=class{constructor(t){h(this,O);l(this,"injectionUUID");l(this,"injectionUUID_Deprecated");this.injectionUUID_Deprecated=`__${t}_CONTEXT_INJECTION_STATUS_KEY`,this.injectionUUID=`__${t}_CONTEXT_INJECTION_STATUS_KEY#0.1`,u(this,O,qt).call(this)||u(this,O,Me).call(this)}resolveInjected(){globalThis[this.injectionUUID]?.resolve()}waitInjected(){return new Promise((t,e)=>{let n=!1,s,r=0,o=()=>{n||(s=setTimeout(()=>{if(r++,r<ci){r%10===0&&console.log(J($.IncorrectEnvironment,"contexts are not resolved, still re-trying").withMessage(`try number ${r}`).message),o();return}if(!n){let c=J($.IncorrectEnvironment,"contexts are not resolved, threw by timeout");e(c)}},ai))};o(),u(this,O,qt).call(this)?.then(()=>{n=!0,clearTimeout(s),t()})})}};O=new WeakSet,qt=function(){return globalThis[this.injectionUUID]?.promise},Me=function(){let t,e=new Promise(n=>{t=n});globalThis[this.injectionUUID]={promise:e,resolve:t},globalThis[this.injectionUUID_Deprecated]=new Promise(n=>{e.then(n)})};var Ft="__ENVIRONMENT_CONTEXT_KEY",Pt=(i=>(i.Worker="Worker",i.Frame="Frame",i.ComponentPanel="ComponentPanel",i))(Pt||{}),dt=class dt{constructor(t){this.environmentContext=t}static async inject(t){if(globalThis[Ft])throw J($.IncorrectEnvironment,"Environment context already exists and should not be overridden");globalThis[Ft]=new dt(t),this.status.resolveInjected()}static async getInstance(){return await this.status.waitInjected(),globalThis[Ft]}getPrivateAPI(){return this.environmentContext.privateApi}getEvents(){return this.environmentContext.events}getApplicationAPIs(){return this.environmentContext.applicationAPIs??{}}getEnvironment(){return this.environmentContext.environment}};l(dt,"status",new ut("environment"));var N=dt,Y="__APPLICATION_CONTEXT_KEY",ft=class ft{constructor(t,e){l(this,"events");this.context=t,this.environment=e,this.events=new Wt(t.appDefinitionId?t.appDefinitionId:null,this.environment.getEvents(),this.environment.getPrivateAPI())}static async inject(t){if(globalThis[Y])throw J($.IncorrectEnvironment,"Application context already exists and should not be overridden");globalThis[Y]=new ft(t,await N.getInstance()),this.status.resolveInjected()}static async getInstance(){return typeof __APPLICATION_CONTEXT_KEY<"u"?__APPLICATION_CONTEXT_KEY:(await this.status.waitInjected(),globalThis[Y])}getContext(){return this.context}getAppDefinitionId(){return this.context.appDefinitionId}getManifestContextId(){return this.context.manifestContextId}getEvents(){return this.events}getEnvironmentContext(){return this.environment}getPrivateAPI(){return this.environment.getPrivateAPI()}getPrivateApplicationAPI(){let t=this.getAppDefinitionId();if(!t)throw J($.IncorrectEnvironment,"appDefinitionId is not available");return this.environment.getApplicationAPIs()[t]}};l(ft,"status",new ut("application"));var y=ft;var Ke=we(Ot());var tt=i=>`"editor-platform-transport": ${i}`,De=i=>tt(`[Internal Error] ${i}`),Se="\u0192",Ne="\u2202",Oe="_get_",ke="_set_",mt="+",Re="-",Ht="\xB7",Xt="\xD7",Qt="\xB0",Le=i=>i[0]===Xt?"":i,_e=i=>i===null||typeof i>"u"||typeof i=="symbol"||typeof i=="number"||typeof i=="boolean"||typeof i=="function"||typeof i=="string",li=i=>!!i&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof Set)&&!(i instanceof Map),pi=i=>W(i.split(Ht)),W=i=>i.map(Le).filter(Boolean).join(".");function xt(i,t){return{marker:i,...t}}var hi=xt("A",{shouldUse:i=>Array.isArray(i),serialize:(i,t)=>{i.length?i.forEach((e,n)=>{t(`${n}`,e)}):t("",Qt)},deserialize:{create:()=>[],has:(i,t)=>!(typeof i[t]>"u"),append:(i,t,e)=>{i.push(e)}}}),ui=xt("M",{shouldUse:i=>i instanceof Map,serialize:(i,t)=>{i.forEach((e,n)=>{t(n,e)})},deserialize:{create:()=>new Map,has:(i,t)=>i.has(t),append:(i,t,e)=>{i.set(t,e)}}}),di=xt("S",{shouldUse:i=>i instanceof Set,serialize:(i,t)=>{let e=0;i.forEach(n=>{t(`${e++}`,n)})},deserialize:{create:()=>new Set,has:(i,t)=>i.has(t),append:(i,t,e)=>{i.add(e)}}}),zt=xt("O",{shouldUse:i=>typeof i=="object",serialize:(i,t)=>{let e=n=>{let r=Reflect.ownKeys(n).filter(c=>c!=="constructor").filter(c=>typeof c!="symbol");r.length?r.filter(c=>c!=="constructor").filter(c=>typeof c!="symbol").forEach(c=>{let p=Reflect.get(i,c);t(c,p)}):t("",Qt);let o=Reflect.getPrototypeOf(n);!o||o?.hasOwnProperty("__proto__")||e(o)};e(i)},deserialize:{create:()=>({}),has:(i,t)=>!!i[t],append:(i,t,e)=>{i[t]=e}}}),Ue=[hi,di,ui];function fi(i,t){let e=i;for(;e;){let n=Object.getOwnPropertyDescriptor(e,t);if(n)return n;e=Reflect.getPrototypeOf(e)}return null}function Pi(i,t){let e=new WeakMap,n=r=>{let o=r.slice(1).map(Le).filter(Boolean);return o.slice(1).reduce((c,p)=>({context:c.context[c.pointer],pointer:p}),{context:i,pointer:o[0]})},s=(r,o=[])=>{if(e.has(r)&&e.get(r)?.some(d=>o.join(".").startsWith(d))){t(o,{...n(o),value:"[Circular]"});return}if(r&&!_e(r)&&(e.has(r)&&e.set(r,[]),e.set(r,[...e.get(r)??[],o.join(".")])),_e(r)){t(o,{...n(o),value:r});return}let c=Ue.find(p=>p.shouldUse(r))??zt;if(c){c.serialize(r,(p,d)=>{s(d,[...o,`${Xt}${c.marker}`,p])});return}};return s(i)}var mi=(i,t)=>{if(!li(i))throw new Error(tt("only objects are serializable at the root level"));let e={data:[]},n=(r,o)=>{e.data.push([r,o])},s=(r,o)=>{t(pi(r),(...c)=>o.context[o.pointer](...c)),n(r,Se)};return Pi(i,(r,{value:o,context:c,pointer:p})=>{let d=r.slice(1).join(Ht),f=fi(c,p);if(f?.get||f?.set){f?.get&&t(W([...r,Oe]),()=>c[p]),f?.set&&t(W([...r,ke]),V=>{c[p]=V});let D=[f?.get?mt:Re,f?.set?mt:Re];n(d,`${Ne}${D.join("")}`)}else typeof o=="function"?s(d,{context:c,pointer:p}):n(d,o)}),e},gi=(i,t)=>typeof i!="object"||i===null?i:i.data.reduce((e,[n,s])=>{let r=e,o=n.split(Ht),c=zt,p=null;for(let d=0;d<o.length;d++){let f=o[d];if(f[0]===Xt){let D=c.deserialize.has(r,p);if(c=[zt,...Ue].find(V=>V.marker===f[1]),!c)throw new Error(tt(`unknown marker "${f[1]}"`));D||(r[p]=c.deserialize.create()),r=r[p]}else p=f}if(s?.toString()===Qt)return e;if(s?.toString()===Se)c.deserialize.append(r,p,t(W(o)));else if(s?.toString()[0]===Ne){let d=s?.toString()[1]===mt,f=s?.toString()[2]===mt,D={};if(d){let V=t(W([...o,Oe]));D.get=()=>V()}f&&(D.set=t(W([...o,ke]))),Object.defineProperty(r,p,D)}else c.deserialize.append(r,p,s);return e},{[Symbol("transferred object")]:`${(JSON.stringify(i.data).length/1024).toFixed(2)}Kb`});function je(){let i=globalThis.performance;if(i&&i.now)return i.now();let t="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=e.length,s=0,r=10;for(;s<r;)t+=e.charAt(Math.floor(Math.random()*n)),s+=1;return t}var X=(i=>(i.ExposeAPI="ExposeAPI",i.Call="Call",i.Response="Response",i.Cleanup="Cleanup",i))(X||{}),M=class i{constructor(t,e){l(this,"correlationId",`M-${je()}`);l(this,"parentCorrelationId");this.type=t,this.payload=e}withParentCorrelationId(t){return this.parentCorrelationId=t,this}serialize(t){return JSON.stringify({parentCorrelationId:this.parentCorrelationId,correlationId:this.correlationId,type:this.type,payload:mi(this.payload,(e,n)=>{t(this.correlationId,e,n)})})}static fromEvent(t,e){let n=JSON.parse(t);return new i(n.type,gi(n.payload,s=>e(n.correlationId,s))).withParentCorrelationId(n.correlationId)}},Bt=class extends M{constructor(t){super("Cleanup",t)}},Vt=class extends M{constructor(t){super("Response",t)}},gt=class extends M{constructor(t){super("Response",t)}},Gt=class extends M{constructor(t){super("Call",t)}},Kt=(i,t)=>`${i}_${t}`,Et,bt,q,C,Yt=class{constructor(t){h(this,Et,new FinalizationRegistry(t=>{this.postMessage(new Bt(t))}));h(this,bt,{[X.Cleanup]:t=>{let e=t.payload.functionMarkerKey,n=t.payload.callId;delete a(this,q)[e],n&&delete a(this,C)[n]},[X.Response]:async t=>{let e=t.payload.callId,n=t.payload.errorMessage;if(n)if(t.payload.errorStack){let r=new Error(n);r.stack=t.payload.errorStack,a(this,C)[e]?.reject(r)}else a(this,C)[e]?.reject(n);else{let s=t.payload.response;a(this,C)[e]?.resolve(s)}delete a(this,C)[e]},[X.Call]:async t=>{let e=t.payload.functionMarkerKey,n=a(this,q)[e];if(!n){this.postMessage(new gt({callId:t.payload.callId,errorMessage:tt("function is not available")}));return}try{let s=await n.value(...t.payload.props??[]);this.postMessage(new Vt({callId:t.payload.callId,response:s}))}catch(s){this.postMessage(new gt({callId:t.payload.callId,errorMessage:s.message,errorStack:s.stack}))}}});h(this,q,{});h(this,C,{});l(this,"queue",[]);this.port=t,this.port.onmessage=e=>{this.onMessage(e)}}onMessage(t){let e=M.fromEvent(t.data,(n,s)=>{let r=this.replaceTransferredFunction(n,s);return a(this,Et).register(r,{functionMarkerKey:Kt(n,s)}),r});a(this,bt)[e.type]?.(e),this.messageEvents[e.type]?.(e)}postMessage(t){this.port.postMessage(t.serialize(this.registerTransferredFunction.bind(this)))}registerTransferredFunction(t,e,n){let s=Kt(t,e);a(this,q)[s]={path:e,value:n}}replaceTransferredFunction(t,e){return(...n)=>{let s=`CALL-${crypto.randomUUID()}`;return this.postMessage(new Gt({callId:s,functionMarkerKey:Kt(t,e),props:n})),new Promise((r,o)=>{a(this,C)[s]={resolve:r,reject:o}})}}flush(){this.queue.forEach(t=>{this.postMessage(t)}),this.queue=[]}};Et=new WeakMap,bt=new WeakMap,q=new WeakMap,C=new WeakMap;var It=class extends Yt{constructor(){super(...arguments);l(this,"messageEvents",{})}expose(e){if(!e.type)throw new Error(tt('wrong exposed API instance, "type" property is required'));this.queue.push(new M(X.ExposeAPI,e)),this.flush()}};var H=(i=>(i.Ping="EDITOR_PLATFORM_TRANSPORT_EVENT:__Ping",i.RequestPort="EDITOR_PLATFORM_TRANSPORT_EVENT:__RequestPort",i.Pong="EDITOR_PLATFORM_TRANSPORT_EVENT:__Pong",i.Port="EDITOR_PLATFORM_TRANSPORT_EVENT:__Port",i))(H||{});var K,T,Ct,Fe,Jt=class{constructor(t,e){h(this,Ct);h(this,K,new Set);h(this,T);this.postMessage=t,this.onMessage=e}setActivePort(t){this.dispose(),w(this,T,t),u(this,Ct,Fe).call(this)}dispose(){a(this,T)&&(a(this,T).close(),a(this,T).onmessage=null)}onHandshake(t){return a(this,K).add(t),()=>{a(this,K).delete(t)}}};K=new WeakMap,T=new WeakMap,Ct=new WeakSet,Fe=function(){let t=a(this,T);if(!t){console.warn(De("port is required no notify onHandshake listeners"));return}a(this,K).forEach(e=>e(t))};var Q,Z,R,$e,We,qe,At=class extends Jt{constructor(e,n){super(e,n);h(this,R);h(this,Q,!1);h(this,Z,`consumer-${je()}`);u(this,R,$e).call(this);let s={type:H.Ping};e(JSON.stringify(s))}};Q=new WeakMap,Z=new WeakMap,R=new WeakSet,$e=function(){this.onMessage(e=>{try{let n=JSON.parse(e.data);switch(n.type){case H.Pong:{u(this,R,We).call(this);break}case H.Port:{u(this,R,qe).call(this,n.targetMemberId,e.ports?.[0]);break}}}catch{}})},We=function(){if(a(this,Q))return;w(this,Q,!0);let e={type:H.RequestPort,memberId:a(this,Z)};this.postMessage(JSON.stringify(e))},qe=function(e,n){if(e===a(this,Z)){if(!n)throw new Error(De("no port at consumer handshake"));this.setActivePort(n)}};var yt=class{get onConnect(){return this.handshake.onHandshake.bind(this.handshake)}},wt=class i extends yt{constructor(){super(...arguments);l(this,"handshake",new At(e=>{globalThis.parent.postMessage(e,"*")},e=>{globalThis.addEventListener("message",e)}))}static exposeAPI(e){new i().onConnect(s=>{new It(s).expose(e)})}};var vt=class i extends yt{constructor(){super(...arguments);l(this,"handshake",new At(e=>{globalThis.postMessage(e)},e=>{globalThis.addEventListener("message",e)}))}static exposeAPI(e){new i().onConnect(s=>{new It(s).expose(e)})}};var Tt=class{constructor(t){this.platformAppEvents=t}notify(t){switch(t.type){case Ut.EditorReady:this.platformAppEvents.notify({...t,type:v.EditorReady});break;case ht.HostEvent:this.platformAppEvents.notify({...t,type:v.HostEvent});break}}subscribe(t){this.platformAppEvents.subscribe(e=>{t(e)})}},re=(i=>(i.Frame="PLATFORM_FRAME_API",i.Worker="PLATFORM_WORKER_API",i))(re||{}),Mt=class{constructor(t,e){this.type=t,this.envType=e}async injectEnvironmentContext({events:t,privateApi:e}){await N.inject({environment:this.envType,events:t,privateApi:e,applicationAPIs:{}})}async injectApplicationContext(t){await y.inject(t)}},Ii={classic:"https://www.unpkg.com/@wix/design-system/dist/statics/tokens-default.global.css",studio:"https://www.unpkg.com/@wix/design-system/dist/statics/tokens-studio.global.css"},et,it,_t,nt,Dt,ze,te=class extends Mt{constructor(){super(re.Frame,Pt.Frame);h(this,Dt);h(this,et,new b);h(this,it,new Tt(a(this,et)));h(this,_t);h(this,nt);u(this,Dt,ze).call(this)}async initEnvironment(e){let{applicationPrivateAPI:n,privateAPI:s,context:r}=e,o=e.context?.appDefinitionId??e.appDefinitionId,c=e.context?e.context:{appDefinitionId:o};w(this,nt,n),w(this,_t,s),await this.injectEnvironmentContext({privateApi:s,events:a(this,et),applicationAPIs:o?{[o]:a(this,nt)}:{}}),await this.injectApplicationContext(c)}notify(e){a(this,it).notify(e)}subscribe(e){a(this,it).subscribe(e)}};et=new WeakMap,it=new WeakMap,_t=new WeakMap,nt=new WeakMap,Dt=new WeakSet,ze=function(){if(typeof globalThis?.document?.head?.prepend=="function"){let n=new URL(globalThis.location.href).searchParams.get("editorType")==="CLASSIC"?"classic":"studio",s=Ii[n],r=s&&!!document.querySelectorAll(`link[type="text/css"][href="${s}"]`)?.length;if(s&&!r){let o=document.createElement("link");o.setAttribute("rel","stylesheet"),o.setAttribute("type","text/css"),o.setAttribute("href",s),globalThis.document.head.prepend(o)}}};var _=(i=>(i.ApplicationLoadError="ApplicationLoadError",i.ApplicationFetchError="ApplicationFetchError",i.ApplicationExecuteError="ApplicationExecuteError",i))(_||{}),ee=class extends A{constructor(e,n){super(e,n,"EP Application Container Error");l(this,"state",{})}withUrl(e){return this.state={...this.state,url:e},this}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}withApiMethod(e){return this.state={...this.state,apiMethod:e},this}withApiType(e){return this.state={...this.state,apiType:e},this}},k=E(ee),Ai="__APPLICATION_REGISTRY_KEY";async function yi(i,t,e){let n=new Function(Y,Ai,e),s,r=o=>{if(s)throw k(_.ApplicationExecuteError,"Application registry called more than once").withAppDefinitionId(t.appDefinitionId);if(o.type!==t.type)throw k(_.ApplicationExecuteError,"Application has different type").withMessage("expected type",t.type).withMessage("received type",o.type);s=o};try{let o={...t};n.call(null,new y(o,await N.getInstance()),r)}catch(o){throw k(_.ApplicationExecuteError,o.message).withAppDefinitionId(t.appDefinitionId).withParentError(o)}return new Promise((o,c)=>{let p=i.subscribe(d=>{let f=setTimeout(()=>{clearTimeout(f),p(),s||c(k(_.ApplicationExecuteError,"Application registry was not called, threw by timeout").withAppDefinitionId(t.appDefinitionId))},5e3);d.type===v.ApplicationInit&&d.meta.appDefinitionId===t.appDefinitionId&&(clearTimeout(f),p(),s||c(k(_.ApplicationExecuteError,"Application registry was not called").withAppDefinitionId(t.appDefinitionId)),o({instance:s}))})})}var L,st,P,ie=class{constructor(t,e){h(this,L,{});h(this,st);h(this,P);w(this,st,t),w(this,P,e),a(this,P).subscribe(n=>{switch(n.type){case v.HostEvent:{n.payload.type===Ke.EventType.removeAppCompleted&&a(this,P).withEvent(a(this,P).factories.createApplicationRemovedEvent(n.payload.appDefinitionId),()=>this.removeApplication(n.payload.appDefinitionId));break}}})}async runApplication(t){let e=await this.loadApplication(t),n=await this.executeApplication(t,e);return this.setApplication(t.appDefinitionId,n),n}setApplication(t,e){a(this,L)[t]=e,a(this,P).withEvent(a(this,P).factories.createApplicationApiInitEvent(t,e?.api?.private?"private":"public"),()=>{a(this,st).applicationManager.setApplication(e)})}getApplication(t){return a(this,L)[t]}getAppDefinitionIds(){return Object.keys(a(this,L))}removeApplication(t){delete a(this,L)[t]}async loadApplication(t){let e=t.url;return a(this,P).withEvent(a(this,P).factories.createApplicationLoadEvent(t,e),async()=>{try{return await this.loadApplicationBundle(e)}catch(n){throw k(_.ApplicationLoadError).withUrl(e).withAppDefinitionId(t.appDefinitionId).withParentError(n)}})}async loadApplicationBundle(t){let e=await fetch(t,{method:"GET"});if(!(e.status>=200&&e.status<=299))throw k(_.ApplicationFetchError).withUrl(t);return e.text()}async executeApplication(t,e){return a(this,P).withEvent(a(this,P).factories.createApplicationExecuteEvent(t,t.url),async()=>{let{instance:n}=await yi(a(this,P),t,e);return n})}};L=new WeakMap,st=new WeakMap,P=new WeakMap;var z,rt,ot,U,at,ne=class extends Mt{constructor(){super(re.Worker,Pt.Worker);h(this,z,new b);h(this,rt,new Tt(a(this,z)));h(this,ot,null);h(this,U);h(this,at,[])}create(){}async initEnvironment(e){let{buildPrivateAPI:n}=e;w(this,U,await n({type:"EDITOR_ADDON"})),await this.injectEnvironmentContext({events:a(this,z),privateApi:a(this,U),applicationAPIs:{}}),w(this,ot,new ie(a(this,U),a(this,z))),a(this,at).forEach(s=>s(this))}async notify(e){await this.waitReady(),a(this,rt).notify(e)}subscribe(e){a(this,rt).subscribe(e)}async runApplication(e){await this.waitReady(),await a(this,ot).runApplication(e)}waitReady(){return new Promise(e=>{if(a(this,U))return e(this);a(this,at).push(e)})}};z=new WeakMap,rt=new WeakMap,ot=new WeakMap,U=new WeakMap,at=new WeakMap;var Zt="$_EP_TRANSPORT_ENV_CONTEXT_GUARD",B,Be,Ve,Rt=class{constructor(){h(this,B)}isEnvironmentApiExposed(){return!!globalThis[Zt]}async getContexts(){let[t,e]=await Promise.all([N.getInstance(),y.getInstance()]);return{environmentContext:t,applicationContext:e}}expose(){if(this.isEnvironmentApiExposed())return;let t=typeof importScripts=="function",e=globalThis.self&&globalThis.top&&globalThis.self!==globalThis.top;t?(u(this,B,Be).call(this),globalThis[Zt]=!0):e&&(u(this,B,Ve).call(this),globalThis[Zt]=!0)}};B=new WeakSet,Be=function(){vt.exposeAPI(new ne)},Ve=function(){wt.exposeAPI(new te)};var se=class extends A{constructor(e,n){super(e,n,"EP EnvironmentAPI Error");l(this,"state",{})}withUrl(e){return this.state={...this.state,url:e},this}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}},Xi=E(se);new Rt().expose();var oe=class extends A{constructor(e,n){super(e,n,"Auth Strategy Error");l(this,"state",{})}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}},Ge=E(oe);function wi(i,t){let e=Date.now(),n=i?new Date(i).getTime():null;return n&&n-e>t}var vi=30*60*1e3,Ei=()=>{let i;return{getAuthHeaders:async()=>{let t=await y.getInstance(),e=t.getAppDefinitionId(),n=t.getPrivateAPI();if(!e)throw Ge("EmptyAppDefinitionId");return(!i||wi(i.expires,vi))&&(i=await n.auth.getAccessToken(e,await n.info.getMetaSiteId())),i?.token?{headers:{Authorization:i.token}}:(console.error(Ge("EmptyAppAuthInstance").withAppDefinitionId(e)),{headers:{Authorization:""}})}}},m=class i{constructor(t,e=[]){this.ShapeConstructor=t,this.selectedMethods=e}withPublicMethod(t){return new i(this.ShapeConstructor,[...this.selectedMethods,t])}build(){if(!this.selectedMethods.length)throw new Error("methods are not defined for the SDK shape");let t=this.selectedMethods.reduce((e,n)=>({...e,[n]:s=>{let r=new this.ShapeConstructor(s?.applicationContext);return r[n]?r[n].bind(r):()=>{console.error(`"${n}" is not defined in the SDK shape`)}}}),{});return Ee(t)}},ae=class extends A{constructor(t,e){super(t,e,"Base SDK Error")}},bi=E(ae),g=class{constructor(t=null){this.overriddenApplicationContext=t}getApplicationContext(){return this.overriddenApplicationContext?this.overriddenApplicationContext:y.getInstance()}async getAppDefinitionId(){return(await this.getApplicationContext()).getAppDefinitionId()}async getManifestContextId(){return(await this.getApplicationContext()).getManifestContextId()}async getRequiredManifestContextId(){let t=await this.getManifestContextId();if(!t)throw bi("ManifestContextIdRequired");return t}async getEnvironmentContext(){return(await this.getApplicationContext()).getEnvironmentContext()}async getPlatformPrivateAPI(){return(await this.getApplicationContext()).getPrivateAPI()}},ce=class extends g{async getPrivateAPI(){return(await this.getApplicationContext()).getPrivateApplicationAPI()}async getPublicAPI(t){return(await this.getPlatformPrivateAPI()).applicationManager.getPublicApplicationAPI(t)}async getAppInstance(){return(await this.getPlatformPrivateAPI()).info.getAppInstance(await this.getAppDefinitionId())}},on=new m(ce).withPublicMethod("getPrivateAPI").withPublicMethod("getPublicAPI").withPublicMethod("getAppInstance").build(),Nt=class extends g{async addEventListener(t,e){return(await this.getApplicationContext()).getEvents().addEventListener(t,e)}},an=new m(Nt).withPublicMethod("addEventListener").build(),le=class extends g{async getSelection(){let t=await this.getPlatformPrivateAPI(),e=await t.components.getSelectedComponents();return Promise.all(e.map(n=>t.components.getComponent(n)))}async onSelectionChange(t){new Nt(this.getApplicationContext()).addEventListener("componentSelectionChanged",n=>{t(n.components)})}},cn=new m(le).withPublicMethod("onSelectionChange").withPublicMethod("getSelection").build(),pe=class extends g{async getViewMode(){return(await this.getPlatformPrivateAPI()).info.getViewMode()}async getLanguageCode(){return(await this.getPlatformPrivateAPI()).info.getLanguageCode()}async getSiteDirection(){return(await this.getPlatformPrivateAPI()).info.getSiteDirection()}async siteHasCustomClasses(){return(await this.getPlatformPrivateAPI()).info.siteHasCustomClasses()}},ln=new m(pe).withPublicMethod("getViewMode").withPublicMethod("getLanguageCode").withPublicMethod("getSiteDirection").withPublicMethod("siteHasCustomClasses").build(),ct=(i=>(i.UndefinedCompRef="UndefinedCompRef",i.NotAvailableMethod="NotAvailableMethod",i))(ct||{}),he=class extends A{constructor(t,e){super(t,e,"Widget Error")}},St=E(he),Je="underline";function Ci(i){return i.map(t=>He({font:t}).family).filter(Boolean)}function He(i){let t={family:void 0,size:void 0};if(i?.font){let{variableName:e,fallbackValue:n}=xi(i.font);t.cssVariableName=e;let s=n.match(/(?:(["']).*?\1|\S)+/g)||[];for(let r=0;r<s.length;r++){let o=s[r];switch(o){case"bold":t.bold=!0;break;case"italic":t.italic=!0;break;default:o?.endsWith("px")?t.size=parseInt(o,10):r===s.length-1?t.family=o:t.family=(t.family||"")+" "+o}}}return i?.textDecoration&&(t.underline=i.textDecoration===Je),t.family=t.family?.trim().replace(/['"]+/g,""),t}function xi(i){let t=i.trim(),e=t.match(/var\((--[\w-]+),\s*(.+)\)/);return e?{variableName:e[1],fallbackValue:e[2]?.trim()??""}:{variableName:void 0,fallbackValue:t}}var F=class i{constructor(t,e){this.compRef=t,this.privateAPI=e}async getProp(t){return(await this.privateAPI.refComponents.getProps(this.compRef))?.[t]}async setProp(t,e){await this.privateAPI.refComponents.setProps(this.compRef,{[t]:e})}async getDesignPreset(){return this.privateAPI.designPresets.getDesignPresetName(this.compRef)}async setDesignPreset(t){await this.privateAPI.designPresets.setDesignPresetByName(this.compRef,t)}async getNestedWidget(t){let e=await this.privateAPI.refComponents.findComponentBySelector(this.compRef,t);return e?new i(e,this.privateAPI):null}},x,j,ue=class extends g{constructor(){super(...arguments);h(this,x)}async setPreloadFonts(e){let n=await this.getPlatformPrivateAPI(),s=await u(this,x,j).call(this);if(await n.refComponents.isRefComponent(s))throw St(ct.NotAvailableMethod,"not available for the current component type");let r=Ci(e);await n.customElement.setPreloadFonts(s,r)}async getProp(e){let n=await this.getPlatformPrivateAPI(),s=await u(this,x,j).call(this);return await n.refComponents.isRefComponent(s)?new F(s,n).getProp(e):n.customElement.getAttribute(s,e)}async setProp(e,n){let s=await this.getPlatformPrivateAPI(),r=await u(this,x,j).call(this);if(await s.refComponents.isRefComponent(r))return new F(r,s).setProp(e,n);await s.customElement.setAttribute(r,e,n)}async getDesignPreset(){let e=await this.getPlatformPrivateAPI(),n=await u(this,x,j).call(this);if(!await e.refComponents.isRefComponent(n))throw St(ct.NotAvailableMethod,"not available for the current component type");return new F(n,e).getDesignPreset()}async setDesignPreset(e){let n=await this.getPlatformPrivateAPI(),s=await u(this,x,j).call(this);if(!await n.refComponents.isRefComponent(s))throw St(ct.NotAvailableMethod,"not available for the current component type");return new F(s,n).setDesignPreset(e)}async getNestedWidget(e){let n=await this.getPlatformPrivateAPI(),s=await u(this,x,j).call(this);return new F(s,n).getNestedWidget(e)}};x=new WeakSet,j=async function(){let s=(await(await this.getPlatformPrivateAPI()).components.getSelectedComponents())[0];if(!s)throw St(ct.UndefinedCompRef);return s};var Ti=new m(ue).withPublicMethod("getNestedWidget").withPublicMethod("setDesignPreset").withPublicMethod("getDesignPreset").withPublicMethod("setProp").withPublicMethod("getProp").withPublicMethod("setPreloadFonts"),pn=Ti.build();function Mi(i){return`${i.cssVariableName?`var(${i.cssVariableName}, `:""}${i.italic?"italic ":""}${i.bold?"bold ":""}${i.size||16}px ${i.family?.split(",").map(t=>`"${t.replace(/['"]+/g,"")}"`).join(",")||"serif"}${i.cssVariableName?")":""}`}function Ri(i){if(!i)return null;let t=i,e=t.match(/var\((--[\w-]+),\s*(.+)\)/);return e?{cssVariableName:e[1],color:e[2]}:{color:t}}function Ye(i){return i?i.cssVariableName?`var(${i.cssVariableName}, ${i.color})`:i.color:""}var _i={transformFontInternalValue:i=>{if(i){let{theme:t,cssVariableName:e,bold:n,italic:s,underline:r,...o}=i;return{...o,style:{bold:n,italic:s,underline:r},editorKey:e||t||""}}else return{editorKey:"font_7",family:"helvetica-w01-roman",size:16,style:{}}}},de=class extends g{async selectColor(t,e){let n=await this.getPlatformPrivateAPI(),s=Ri(t),r=Ye(s);return await n.inputs.openColorPicker({color:s?.cssVariableName||s?.theme||s?.color},({color:o,theme:c,cssVariableTheme:p})=>{s={color:o,theme:c,cssVariableName:p},r=Ye(s),e?.onChange?.(r)}),r}async selectFont(t,e){let n=await this.getPlatformPrivateAPI(),s=He(t),r=t;return await n.inputs.openFontPickerV2({...e,panelSectionsDefinition:{htmlTag:"hidden"},componentStyle:_i.transformFontInternalValue(s)},(o,c)=>{r={font:Mi(o),textDecoration:o.underline?Je:void 0},e?.onChange?.(r)}),r}},hn=new m(de).withPublicMethod("selectColor").withPublicMethod("selectFont").build(),fe=class extends g{async openLanguageSupportPanel(){return(await this.getPlatformPrivateAPI()).panels.openLanguageSupportPanel()}async openFontsUploadPanel(){return(await this.getPlatformPrivateAPI()).panels.openFontsUploadPanel()}},un=new m(fe).withPublicMethod("openLanguageSupportPanel").withPublicMethod("openFontsUploadPanel").build(),Pe=class extends g{async openDashboardModal(t){return(await this.getPlatformPrivateAPI()).panels.openDashboardPanel(await this.getAppDefinitionId(),t)}},dn=new m(Pe).withPublicMethod("openDashboardModal").build(),me=class extends g{async getStyleDefinitions(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getStyleDefinitions(e)}async getStyles(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getStyles(e)}async setStyles(t){let e=await this.getPlatformPrivateAPI(),n=await this.getRequiredManifestContextId();return e.builderComponent.setStyles(n,t)}async getDataDefinitions(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getDataDefinitions(e)}async getData(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getData(e)}async setData(t){let e=await this.getPlatformPrivateAPI(),n=await this.getRequiredManifestContextId();return e.builderComponent.setData(n,t)}async getState(){return null}async setState(){return null}async getStateDefinitions(){return null}async onChange(t){let e=await this.getPlatformPrivateAPI(),n=await this.getRequiredManifestContextId();return e.builderComponent.onContextualManifestChange(n,t)}async selectLink(t){let e=await this.getPlatformPrivateAPI(),n=await this.getRequiredManifestContextId();return e.builderComponent.selectLink(n,t)}async selectColor(t){let e=await this.getPlatformPrivateAPI();try{let n=await this.getRequiredManifestContextId();return await e.builderComponent.selectColor(n,t)}catch{}}},fn=new m(me).withPublicMethod("getDataDefinitions").withPublicMethod("getData").withPublicMethod("setData").withPublicMethod("getStyleDefinitions").withPublicMethod("getStyles").withPublicMethod("setStyles").withPublicMethod("getState").withPublicMethod("setState").withPublicMethod("onChange").withPublicMethod("getStateDefinitions").withPublicMethod("selectLink").withPublicMethod("selectColor").build(),ge=class extends g{async get(t){return(await this.getPlatformPrivateAPI()).userPreferences.get(await this.getAppDefinitionId(),t)}async set(t){return(await this.getPlatformPrivateAPI()).userPreferences.set(await this.getAppDefinitionId(),t)}},Pn=new m(ge).withPublicMethod("set").withPublicMethod("get").build(),Ie=class extends g{async getData(){return(await this.getPlatformPrivateAPI()).externalPanels.getData()}async setData(t){return(await this.getPlatformPrivateAPI()).externalPanels.setData(t)}async getStyle(){return(await this.getPlatformPrivateAPI()).externalPanels.getStyle()}async setStyle(t){return(await this.getPlatformPrivateAPI()).externalPanels.setStyle(t)}async getTheme(){return(await this.getPlatformPrivateAPI()).externalPanels.getTheme()}async selectMedia(){return(await this.getPlatformPrivateAPI()).externalPanels.selectMedia()}async selectLink(...t){return(await this.getPlatformPrivateAPI()).externalPanels.selectLink(...t)}async selectColor(...t){return async()=>(await this.getPlatformPrivateAPI()).externalPanels.selectColor(...t)}async translate(t,e){return(await this.getPlatformPrivateAPI()).externalPanels.translate(t,e)}},mn=new m(Ie).withPublicMethod("getTheme").withPublicMethod("getData").withPublicMethod("getStyle").withPublicMethod("selectColor").withPublicMethod("selectLink").withPublicMethod("selectMedia").withPublicMethod("setData").withPublicMethod("setStyle").withPublicMethod("translate").build(),Di=()=>{let i=new URLSearchParams(window.location.search),t=i.has("essentials")?JSON.parse(i.get("essentials")):void 0,{monitoring:e,...n}=t||{},s=i.get("appDefinitionId"),{context:r,config:o}=e||{},c=be({hostContext:{appId:s,...r},monitoringConfig:o,sentrySDK:typeof window<"u"?window.Sentry:void 0});return{environment:{},applicationContext:y.getInstance(),channel:{observeState:async()=>({disconnect(){}})},getMonitoringClient:c,essentials:n}},Si=()=>({environment:{},applicationContext:y.getInstance(),channel:{observeState:async()=>({disconnect(){}})}}),Ae={host:()=>typeof importScripts=="function"?Si():Di(),auth:Ei};var wn=()=>{let i=Ae.host(),t=Ae.auth();ve({auth:t,host:i}).enableContext("module")};export{wn as enableClient};
7
+ `)}getBreadcrumbs(){let e=this.parentError;return e?[...e.getBreadcrumbs(),this.displayName]:[this.displayName]}withParentError(e){return this.parent=e,this}withMessage(...e){return this.messages.push(e),this}};function E(i){return function t(e,n=""){let s=new i(n,e);return Error.captureStackTrace&&Error.captureStackTrace(s,t),s}}var jt=class extends A{constructor(e,n){super(e,n,"Editor Platform Internal Error");l(this,"state",{})}withHost(e){return this.state={...this.state,host:e},this}},ri=E(jt);var $=(i=>(i.IncorrectEnvironment="IncorrectEnvironment",i))($||{}),$t=class extends A{constructor(e,n){super(e,n,"EP Context Error");l(this,"state",{})}withUrl(e){return this.state={...this.state,url:e},this}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}},J=E($t);async function oi(i,t){if(!i?.type)return i;switch(i.type){case"componentSelectionChanged":let e=i.componentRefs||[],n=await Promise.all(e.map(s=>t.components.getComponent(s)));return{type:i.type,components:n};default:return i}}var Wt=class{constructor(t,e,n){l(this,"events");l(this,"subscribe");l(this,"commit");l(this,"startTransaction");l(this,"silent");this.appDefinitionId=t,this.privateAPI=n,this.events=e,this.subscribe=e.subscribe.bind(e),this.commit=e.commit.bind(e),this.startTransaction=e.startTransaction.bind(e),this.silent=e.silent.bind(e)}notify(t){this.events.notify({type:t.type,payload:t.payload,meta:{appDefinitionId:this.appDefinitionId}})}notifyCustomEvent(t,e){this.notify({type:v.CustomEvent,payload:{...e,type:t}})}addEventListener(t,e){return this.events.subscribe(async n=>{let s=n.meta?.appDefinitionId===this.appDefinitionId||n.meta?.appDefinitionId===null,r=()=>oi(n.payload,this.privateAPI);t==="*"?e(await r()):n.type===v.CustomEvent?t===n.payload?.type&&!s&&e(await r()):n.type===v.HostEvent&&t===n.payload?.type&&s&&e(await r())})}},ai=200,ci=50,O,qt,Me,ut=class{constructor(t){h(this,O);l(this,"injectionUUID");l(this,"injectionUUID_Deprecated");this.injectionUUID_Deprecated=`__${t}_CONTEXT_INJECTION_STATUS_KEY`,this.injectionUUID=`__${t}_CONTEXT_INJECTION_STATUS_KEY#0.1`,u(this,O,qt).call(this)||u(this,O,Me).call(this)}resolveInjected(){globalThis[this.injectionUUID]?.resolve()}waitInjected(){return new Promise((t,e)=>{let n=!1,s,r=0,o=()=>{n||(s=setTimeout(()=>{if(r++,r<ci){r%10===0&&console.log(J($.IncorrectEnvironment,"contexts are not resolved, still re-trying").withMessage(`try number ${r}`).message),o();return}if(!n){let c=J($.IncorrectEnvironment,"contexts are not resolved, threw by timeout");e(c)}},ai))};o(),u(this,O,qt).call(this)?.then(()=>{n=!0,clearTimeout(s),t()})})}};O=new WeakSet,qt=function(){return globalThis[this.injectionUUID]?.promise},Me=function(){let t,e=new Promise(n=>{t=n});globalThis[this.injectionUUID]={promise:e,resolve:t},globalThis[this.injectionUUID_Deprecated]=new Promise(n=>{e.then(n)})};var Ft="__ENVIRONMENT_CONTEXT_KEY",Pt=(i=>(i.Worker="Worker",i.Frame="Frame",i.ComponentPanel="ComponentPanel",i))(Pt||{}),dt=class dt{constructor(t){this.environmentContext=t}static async inject(t){if(globalThis[Ft])throw J($.IncorrectEnvironment,"Environment context already exists and should not be overridden");globalThis[Ft]=new dt(t),this.status.resolveInjected()}static async getInstance(){return await this.status.waitInjected(),globalThis[Ft]}getPrivateAPI(){return this.environmentContext.privateApi}getEvents(){return this.environmentContext.events}getApplicationAPIs(){return this.environmentContext.applicationAPIs??{}}getEnvironment(){return this.environmentContext.environment}};l(dt,"status",new ut("environment"));var N=dt,Y="__APPLICATION_CONTEXT_KEY",ft=class ft{constructor(t,e){l(this,"events");this.context=t,this.environment=e,this.events=new Wt(t.appDefinitionId?t.appDefinitionId:null,this.environment.getEvents(),this.environment.getPrivateAPI())}static async inject(t){if(globalThis[Y])throw J($.IncorrectEnvironment,"Application context already exists and should not be overridden");globalThis[Y]=new ft(t,await N.getInstance()),this.status.resolveInjected()}static async getInstance(){return typeof __APPLICATION_CONTEXT_KEY<"u"?__APPLICATION_CONTEXT_KEY:(await this.status.waitInjected(),globalThis[Y])}getContext(){return this.context}getAppDefinitionId(){return this.context.appDefinitionId}getManifestContextId(){return this.context.manifestContextId}getEvents(){return this.events}getEnvironmentContext(){return this.environment}getPrivateAPI(){return this.environment.getPrivateAPI()}getPrivateApplicationAPI(){let t=this.getAppDefinitionId();if(!t)throw J($.IncorrectEnvironment,"appDefinitionId is not available");return this.environment.getApplicationAPIs()[t]}};l(ft,"status",new ut("application"));var y=ft;var Ke=we(Ot());var tt=i=>`"editor-platform-transport": ${i}`,De=i=>tt(`[Internal Error] ${i}`),Se="\u0192",Ne="\u2202",Oe="_get_",ke="_set_",mt="+",Re="-",Ht="\xB7",Xt="\xD7",Qt="\xB0",Le=i=>i[0]===Xt?"":i,_e=i=>i===null||typeof i>"u"||typeof i=="symbol"||typeof i=="number"||typeof i=="boolean"||typeof i=="function"||typeof i=="string",li=i=>!!i&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof Set)&&!(i instanceof Map),pi=i=>W(i.split(Ht)),W=i=>i.map(Le).filter(Boolean).join(".");function xt(i,t){return{marker:i,...t}}var hi=xt("A",{shouldUse:i=>Array.isArray(i),serialize:(i,t)=>{i.length?i.forEach((e,n)=>{t(`${n}`,e)}):t("",Qt)},deserialize:{create:()=>[],has:(i,t)=>!(typeof i[t]>"u"),append:(i,t,e)=>{i.push(e)}}}),ui=xt("M",{shouldUse:i=>i instanceof Map,serialize:(i,t)=>{i.forEach((e,n)=>{t(n,e)})},deserialize:{create:()=>new Map,has:(i,t)=>i.has(t),append:(i,t,e)=>{i.set(t,e)}}}),di=xt("S",{shouldUse:i=>i instanceof Set,serialize:(i,t)=>{let e=0;i.forEach(n=>{t(`${e++}`,n)})},deserialize:{create:()=>new Set,has:(i,t)=>i.has(t),append:(i,t,e)=>{i.add(e)}}}),zt=xt("O",{shouldUse:i=>typeof i=="object",serialize:(i,t)=>{let e=n=>{let r=Reflect.ownKeys(n).filter(c=>c!=="constructor").filter(c=>typeof c!="symbol");r.length?r.filter(c=>c!=="constructor").filter(c=>typeof c!="symbol").forEach(c=>{let p=Reflect.get(i,c);t(c,p)}):t("",Qt);let o=Reflect.getPrototypeOf(n);!o||o?.hasOwnProperty("__proto__")||e(o)};e(i)},deserialize:{create:()=>({}),has:(i,t)=>!!i[t],append:(i,t,e)=>{i[t]=e}}}),Ue=[hi,di,ui];function fi(i,t){let e=i;for(;e;){let n=Object.getOwnPropertyDescriptor(e,t);if(n)return n;e=Reflect.getPrototypeOf(e)}return null}function Pi(i,t){let e=new WeakMap,n=r=>{let o=r.slice(1).map(Le).filter(Boolean);return o.slice(1).reduce((c,p)=>({context:c.context[c.pointer],pointer:p}),{context:i,pointer:o[0]})},s=(r,o=[])=>{if(e.has(r)&&e.get(r)?.some(d=>o.join(".").startsWith(d))){t(o,{...n(o),value:"[Circular]"});return}if(r&&!_e(r)&&(e.has(r)&&e.set(r,[]),e.set(r,[...e.get(r)??[],o.join(".")])),_e(r)){t(o,{...n(o),value:r});return}let c=Ue.find(p=>p.shouldUse(r))??zt;if(c){c.serialize(r,(p,d)=>{s(d,[...o,`${Xt}${c.marker}`,p])});return}};return s(i)}var mi=(i,t)=>{if(!li(i))throw new Error(tt("only objects are serializable at the root level"));let e={data:[]},n=(r,o)=>{e.data.push([r,o])},s=(r,o)=>{t(pi(r),(...c)=>o.context[o.pointer](...c)),n(r,Se)};return Pi(i,(r,{value:o,context:c,pointer:p})=>{let d=r.slice(1).join(Ht),f=fi(c,p);if(f?.get||f?.set){f?.get&&t(W([...r,Oe]),()=>c[p]),f?.set&&t(W([...r,ke]),V=>{c[p]=V});let D=[f?.get?mt:Re,f?.set?mt:Re];n(d,`${Ne}${D.join("")}`)}else typeof o=="function"?s(d,{context:c,pointer:p}):n(d,o)}),e},gi=(i,t)=>typeof i!="object"||i===null?i:i.data.reduce((e,[n,s])=>{let r=e,o=n.split(Ht),c=zt,p=null;for(let d=0;d<o.length;d++){let f=o[d];if(f[0]===Xt){let D=c.deserialize.has(r,p);if(c=[zt,...Ue].find(V=>V.marker===f[1]),!c)throw new Error(tt(`unknown marker "${f[1]}"`));D||(r[p]=c.deserialize.create()),r=r[p]}else p=f}if(s?.toString()===Qt)return e;if(s?.toString()===Se)c.deserialize.append(r,p,t(W(o)));else if(s?.toString()[0]===Ne){let d=s?.toString()[1]===mt,f=s?.toString()[2]===mt,D={};if(d){let V=t(W([...o,Oe]));D.get=()=>V()}f&&(D.set=t(W([...o,ke]))),Object.defineProperty(r,p,D)}else c.deserialize.append(r,p,s);return e},{[Symbol("transferred object")]:`${(JSON.stringify(i.data).length/1024).toFixed(2)}Kb`});function je(){let i=globalThis.performance;if(i&&i.now)return i.now();let t="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=e.length,s=0,r=10;for(;s<r;)t+=e.charAt(Math.floor(Math.random()*n)),s+=1;return t}var X=(i=>(i.ExposeAPI="ExposeAPI",i.Call="Call",i.Response="Response",i.Cleanup="Cleanup",i))(X||{}),M=class i{constructor(t,e){l(this,"correlationId",`M-${je()}`);l(this,"parentCorrelationId");this.type=t,this.payload=e}withParentCorrelationId(t){return this.parentCorrelationId=t,this}serialize(t){return JSON.stringify({parentCorrelationId:this.parentCorrelationId,correlationId:this.correlationId,type:this.type,payload:mi(this.payload,(e,n)=>{t(this.correlationId,e,n)})})}static fromEvent(t,e){let n=JSON.parse(t);return new i(n.type,gi(n.payload,s=>e(n.correlationId,s))).withParentCorrelationId(n.correlationId)}},Bt=class extends M{constructor(t){super("Cleanup",t)}},Vt=class extends M{constructor(t){super("Response",t)}},gt=class extends M{constructor(t){super("Response",t)}},Gt=class extends M{constructor(t){super("Call",t)}},Kt=(i,t)=>`${i}_${t}`,Et,bt,q,C,Yt=class{constructor(t){h(this,Et,new FinalizationRegistry(t=>{this.postMessage(new Bt(t))}));h(this,bt,{[X.Cleanup]:t=>{let e=t.payload.functionMarkerKey,n=t.payload.callId;delete a(this,q)[e],n&&delete a(this,C)[n]},[X.Response]:async t=>{let e=t.payload.callId,n=t.payload.errorMessage;if(n)if(t.payload.errorStack){let r=new Error(n);r.stack=t.payload.errorStack,a(this,C)[e]?.reject(r)}else a(this,C)[e]?.reject(n);else{let s=t.payload.response;a(this,C)[e]?.resolve(s)}delete a(this,C)[e]},[X.Call]:async t=>{let e=t.payload.functionMarkerKey,n=a(this,q)[e];if(!n){this.postMessage(new gt({callId:t.payload.callId,errorMessage:tt("function is not available")}));return}try{let s=await n.value(...t.payload.props??[]);this.postMessage(new Vt({callId:t.payload.callId,response:s}))}catch(s){this.postMessage(new gt({callId:t.payload.callId,errorMessage:s.message,errorStack:s.stack}))}}});h(this,q,{});h(this,C,{});l(this,"queue",[]);this.port=t,this.port.onmessage=e=>{this.onMessage(e)}}onMessage(t){let e=M.fromEvent(t.data,(n,s)=>{let r=this.replaceTransferredFunction(n,s);return a(this,Et).register(r,{functionMarkerKey:Kt(n,s)}),r});a(this,bt)[e.type]?.(e),this.messageEvents[e.type]?.(e)}postMessage(t){this.port.postMessage(t.serialize(this.registerTransferredFunction.bind(this)))}registerTransferredFunction(t,e,n){let s=Kt(t,e);a(this,q)[s]={path:e,value:n}}replaceTransferredFunction(t,e){return(...n)=>{let s=`CALL-${crypto.randomUUID()}`;return this.postMessage(new Gt({callId:s,functionMarkerKey:Kt(t,e),props:n})),new Promise((r,o)=>{a(this,C)[s]={resolve:r,reject:o}})}}flush(){this.queue.forEach(t=>{this.postMessage(t)}),this.queue=[]}};Et=new WeakMap,bt=new WeakMap,q=new WeakMap,C=new WeakMap;var It=class extends Yt{constructor(){super(...arguments);l(this,"messageEvents",{})}expose(e){if(!e.type)throw new Error(tt('wrong exposed API instance, "type" property is required'));this.queue.push(new M(X.ExposeAPI,e)),this.flush()}};var H=(i=>(i.Ping="EDITOR_PLATFORM_TRANSPORT_EVENT:__Ping",i.RequestPort="EDITOR_PLATFORM_TRANSPORT_EVENT:__RequestPort",i.Pong="EDITOR_PLATFORM_TRANSPORT_EVENT:__Pong",i.Port="EDITOR_PLATFORM_TRANSPORT_EVENT:__Port",i))(H||{});var K,T,Ct,Fe,Jt=class{constructor(t,e){h(this,Ct);h(this,K,new Set);h(this,T);this.postMessage=t,this.onMessage=e}setActivePort(t){this.dispose(),w(this,T,t),u(this,Ct,Fe).call(this)}dispose(){a(this,T)&&(a(this,T).close(),a(this,T).onmessage=null)}onHandshake(t){return a(this,K).add(t),()=>{a(this,K).delete(t)}}};K=new WeakMap,T=new WeakMap,Ct=new WeakSet,Fe=function(){let t=a(this,T);if(!t){console.warn(De("port is required no notify onHandshake listeners"));return}a(this,K).forEach(e=>e(t))};var Q,Z,R,$e,We,qe,At=class extends Jt{constructor(e,n){super(e,n);h(this,R);h(this,Q,!1);h(this,Z,`consumer-${je()}`);u(this,R,$e).call(this);let s={type:H.Ping};e(JSON.stringify(s))}};Q=new WeakMap,Z=new WeakMap,R=new WeakSet,$e=function(){this.onMessage(e=>{try{let n=JSON.parse(e.data);switch(n.type){case H.Pong:{u(this,R,We).call(this);break}case H.Port:{u(this,R,qe).call(this,n.targetMemberId,e.ports?.[0]);break}}}catch{}})},We=function(){if(a(this,Q))return;w(this,Q,!0);let e={type:H.RequestPort,memberId:a(this,Z)};this.postMessage(JSON.stringify(e))},qe=function(e,n){if(e===a(this,Z)){if(!n)throw new Error(De("no port at consumer handshake"));this.setActivePort(n)}};var yt=class{get onConnect(){return this.handshake.onHandshake.bind(this.handshake)}},wt=class i extends yt{constructor(){super(...arguments);l(this,"handshake",new At(e=>{globalThis.parent.postMessage(e,"*")},e=>{globalThis.addEventListener("message",e)}))}static exposeAPI(e){new i().onConnect(s=>{new It(s).expose(e)})}};var vt=class i extends yt{constructor(){super(...arguments);l(this,"handshake",new At(e=>{globalThis.postMessage(e)},e=>{globalThis.addEventListener("message",e)}))}static exposeAPI(e){new i().onConnect(s=>{new It(s).expose(e)})}};var Tt=class{constructor(t){this.platformAppEvents=t}notify(t){switch(t.type){case Ut.EditorReady:this.platformAppEvents.notify({...t,type:v.EditorReady});break;case ht.HostEvent:this.platformAppEvents.notify({...t,type:v.HostEvent});break}}subscribe(t){this.platformAppEvents.subscribe(e=>{t(e)})}},re=(i=>(i.Frame="PLATFORM_FRAME_API",i.Worker="PLATFORM_WORKER_API",i))(re||{}),Mt=class{constructor(t,e){this.type=t,this.envType=e}async injectEnvironmentContext({events:t,privateApi:e}){await N.inject({environment:this.envType,events:t,privateApi:e,applicationAPIs:{}})}async injectApplicationContext(t){await y.inject(t)}},Ii={classic:"https://www.unpkg.com/@wix/design-system/dist/statics/tokens-default.global.css",studio:"https://www.unpkg.com/@wix/design-system/dist/statics/tokens-studio.global.css"},et,it,_t,nt,Dt,ze,te=class extends Mt{constructor(){super(re.Frame,Pt.Frame);h(this,Dt);h(this,et,new b);h(this,it,new Tt(a(this,et)));h(this,_t);h(this,nt);u(this,Dt,ze).call(this)}async initEnvironment(e){let{applicationPrivateAPI:n,privateAPI:s,context:r}=e,o=e.context?.appDefinitionId??e.appDefinitionId,c=e.context?e.context:{appDefinitionId:o};w(this,nt,n),w(this,_t,s),await this.injectEnvironmentContext({privateApi:s,events:a(this,et),applicationAPIs:o?{[o]:a(this,nt)}:{}}),await this.injectApplicationContext(c)}notify(e){a(this,it).notify(e)}subscribe(e){a(this,it).subscribe(e)}};et=new WeakMap,it=new WeakMap,_t=new WeakMap,nt=new WeakMap,Dt=new WeakSet,ze=function(){if(typeof globalThis?.document?.head?.prepend=="function"){let n=new URL(globalThis.location.href).searchParams.get("editorType")==="CLASSIC"?"classic":"studio",s=Ii[n],r=s&&!!document.querySelectorAll(`link[type="text/css"][href="${s}"]`)?.length;if(s&&!r){let o=document.createElement("link");o.setAttribute("rel","stylesheet"),o.setAttribute("type","text/css"),o.setAttribute("href",s),globalThis.document.head.prepend(o)}}};var _=(i=>(i.ApplicationLoadError="ApplicationLoadError",i.ApplicationFetchError="ApplicationFetchError",i.ApplicationExecuteError="ApplicationExecuteError",i))(_||{}),ee=class extends A{constructor(e,n){super(e,n,"EP Application Container Error");l(this,"state",{})}withUrl(e){return this.state={...this.state,url:e},this}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}withApiMethod(e){return this.state={...this.state,apiMethod:e},this}withApiType(e){return this.state={...this.state,apiType:e},this}},k=E(ee),Ai="__APPLICATION_REGISTRY_KEY";async function yi(i,t,e){let n=new Function(Y,Ai,e),s,r=o=>{if(s)throw k(_.ApplicationExecuteError,"Application registry called more than once").withAppDefinitionId(t.appDefinitionId);if(o.type!==t.type)throw k(_.ApplicationExecuteError,"Application has different type").withMessage("expected type",t.type).withMessage("received type",o.type);s=o};try{let o={...t};n.call(null,new y(o,await N.getInstance()),r)}catch(o){throw k(_.ApplicationExecuteError,o.message).withAppDefinitionId(t.appDefinitionId).withParentError(o)}return new Promise((o,c)=>{let p=i.subscribe(d=>{let f=setTimeout(()=>{clearTimeout(f),p(),s||c(k(_.ApplicationExecuteError,"Application registry was not called, threw by timeout").withAppDefinitionId(t.appDefinitionId))},5e3);d.type===v.ApplicationInit&&d.meta.appDefinitionId===t.appDefinitionId&&(clearTimeout(f),p(),s||c(k(_.ApplicationExecuteError,"Application registry was not called").withAppDefinitionId(t.appDefinitionId)),o({instance:s}))})})}var L,st,P,ie=class{constructor(t,e){h(this,L,{});h(this,st);h(this,P);w(this,st,t),w(this,P,e),a(this,P).subscribe(n=>{switch(n.type){case v.HostEvent:{n.payload.type===Ke.EventType.removeAppCompleted&&a(this,P).withEvent(a(this,P).factories.createApplicationRemovedEvent(n.payload.appDefinitionId),()=>this.removeApplication(n.payload.appDefinitionId));break}}})}async runApplication(t){let e=await this.loadApplication(t),n=await this.executeApplication(t,e);return this.setApplication(t.appDefinitionId,n),n}setApplication(t,e){a(this,L)[t]=e,a(this,P).withEvent(a(this,P).factories.createApplicationApiInitEvent(t,e?.api?.private?"private":"public"),()=>{a(this,st).applicationManager.setApplication(e)})}getApplication(t){return a(this,L)[t]}getAppDefinitionIds(){return Object.keys(a(this,L))}removeApplication(t){delete a(this,L)[t]}async loadApplication(t){let e=t.url;return a(this,P).withEvent(a(this,P).factories.createApplicationLoadEvent(t,e),async()=>{try{return await this.loadApplicationBundle(e)}catch(n){throw k(_.ApplicationLoadError).withUrl(e).withAppDefinitionId(t.appDefinitionId).withParentError(n)}})}async loadApplicationBundle(t){let e=await fetch(t,{method:"GET"});if(!(e.status>=200&&e.status<=299))throw k(_.ApplicationFetchError).withUrl(t);return e.text()}async executeApplication(t,e){return a(this,P).withEvent(a(this,P).factories.createApplicationExecuteEvent(t,t.url),async()=>{let{instance:n}=await yi(a(this,P),t,e);return n})}};L=new WeakMap,st=new WeakMap,P=new WeakMap;var z,rt,ot,U,at,ne=class extends Mt{constructor(){super(re.Worker,Pt.Worker);h(this,z,new b);h(this,rt,new Tt(a(this,z)));h(this,ot,null);h(this,U);h(this,at,[])}create(){}async initEnvironment(e){let{buildPrivateAPI:n}=e;w(this,U,await n({type:"EDITOR_ADDON"})),await this.injectEnvironmentContext({events:a(this,z),privateApi:a(this,U),applicationAPIs:{}}),w(this,ot,new ie(a(this,U),a(this,z))),a(this,at).forEach(s=>s(this))}async notify(e){await this.waitReady(),a(this,rt).notify(e)}subscribe(e){a(this,rt).subscribe(e)}async runApplication(e){await this.waitReady(),await a(this,ot).runApplication(e)}waitReady(){return new Promise(e=>{if(a(this,U))return e(this);a(this,at).push(e)})}};z=new WeakMap,rt=new WeakMap,ot=new WeakMap,U=new WeakMap,at=new WeakMap;var Zt="$_EP_TRANSPORT_ENV_CONTEXT_GUARD",B,Be,Ve,Rt=class{constructor(){h(this,B)}isEnvironmentApiExposed(){return!!globalThis[Zt]}async getContexts(){let[t,e]=await Promise.all([N.getInstance(),y.getInstance()]);return{environmentContext:t,applicationContext:e}}expose(){if(this.isEnvironmentApiExposed())return;let t=typeof importScripts=="function",e=globalThis.self&&globalThis.top&&globalThis.self!==globalThis.top;t?(u(this,B,Be).call(this),globalThis[Zt]=!0):e&&(u(this,B,Ve).call(this),globalThis[Zt]=!0)}};B=new WeakSet,Be=function(){vt.exposeAPI(new ne)},Ve=function(){wt.exposeAPI(new te)};var se=class extends A{constructor(e,n){super(e,n,"EP EnvironmentAPI Error");l(this,"state",{})}withUrl(e){return this.state={...this.state,url:e},this}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}},Xi=E(se);new Rt().expose();var oe=class extends A{constructor(e,n){super(e,n,"Auth Strategy Error");l(this,"state",{})}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}},Ge=E(oe);function wi(i,t){let e=Date.now(),n=i?new Date(i).getTime():null;return n&&n-e>t}var vi=30*60*1e3,Ei=()=>{let i;return{getAuthHeaders:async()=>{let t=await y.getInstance(),e=t.getAppDefinitionId(),n=t.getPrivateAPI();if(!e)throw Ge("EmptyAppDefinitionId");return(!i||wi(i.expires,vi))&&(i=await n.auth.getAccessToken(e,await n.info.getMetaSiteId())),i?.token?{headers:{Authorization:i.token}}:(console.error(Ge("EmptyAppAuthInstance").withAppDefinitionId(e)),{headers:{Authorization:""}})}}},m=class i{constructor(t,e=[]){this.ShapeConstructor=t,this.selectedMethods=e}withPublicMethod(t){return new i(this.ShapeConstructor,[...this.selectedMethods,t])}build(){if(!this.selectedMethods.length)throw new Error("methods are not defined for the SDK shape");let t=this.selectedMethods.reduce((e,n)=>({...e,[n]:s=>{let r=new this.ShapeConstructor(s?.applicationContext);return r[n]?r[n].bind(r):()=>{console.error(`"${n}" is not defined in the SDK shape`)}}}),{});return Ee(t)}},ae=class extends A{constructor(t,e){super(t,e,"Base SDK Error")}},bi=E(ae),g=class{constructor(t=null){this.overriddenApplicationContext=t}getApplicationContext(){return this.overriddenApplicationContext?this.overriddenApplicationContext:y.getInstance()}async getAppDefinitionId(){return(await this.getApplicationContext()).getAppDefinitionId()}async getManifestContextId(){return(await this.getApplicationContext()).getManifestContextId()}async getRequiredManifestContextId(){let t=await this.getManifestContextId();if(!t)throw bi("ManifestContextIdRequired");return t}async getEnvironmentContext(){return(await this.getApplicationContext()).getEnvironmentContext()}async getPlatformPrivateAPI(){return(await this.getApplicationContext()).getPrivateAPI()}},ce=class extends g{async getPrivateAPI(){return(await this.getApplicationContext()).getPrivateApplicationAPI()}async getPublicAPI(t){return(await this.getPlatformPrivateAPI()).applicationManager.getPublicApplicationAPI(t)}async getAppInstance(){return(await this.getPlatformPrivateAPI()).info.getAppInstance(await this.getAppDefinitionId())}},on=new m(ce).withPublicMethod("getPrivateAPI").withPublicMethod("getPublicAPI").withPublicMethod("getAppInstance").build(),Nt=class extends g{async addEventListener(t,e){return(await this.getApplicationContext()).getEvents().addEventListener(t,e)}},an=new m(Nt).withPublicMethod("addEventListener").build(),le=class extends g{async getSelection(){let t=await this.getPlatformPrivateAPI(),e=await t.components.getSelectedComponents();return Promise.all(e.map(n=>t.components.getComponent(n)))}async onSelectionChange(t){new Nt(this.getApplicationContext()).addEventListener("componentSelectionChanged",n=>{t(n.components)})}},cn=new m(le).withPublicMethod("onSelectionChange").withPublicMethod("getSelection").build(),pe=class extends g{async getViewMode(){return(await this.getPlatformPrivateAPI()).info.getViewMode()}async getLanguageCode(){return(await this.getPlatformPrivateAPI()).info.getLanguageCode()}async getSiteDirection(){return(await this.getPlatformPrivateAPI()).info.getSiteDirection()}async siteHasCustomClasses(){return(await this.getPlatformPrivateAPI()).info.siteHasCustomClasses()}},ln=new m(pe).withPublicMethod("getViewMode").withPublicMethod("getLanguageCode").withPublicMethod("getSiteDirection").withPublicMethod("siteHasCustomClasses").build(),ct=(i=>(i.UndefinedCompRef="UndefinedCompRef",i.NotAvailableMethod="NotAvailableMethod",i))(ct||{}),he=class extends A{constructor(t,e){super(t,e,"Widget Error")}},St=E(he),Je="underline";function Ci(i){return i.map(t=>He({font:t}).family).filter(Boolean)}function He(i){let t={family:void 0,size:void 0};if(i?.font){let{variableName:e,fallbackValue:n}=xi(i.font);t.cssVariableName=e;let s=n.match(/(?:(["']).*?\1|\S)+/g)||[];for(let r=0;r<s.length;r++){let o=s[r];switch(o){case"bold":t.bold=!0;break;case"italic":t.italic=!0;break;default:o?.endsWith("px")?t.size=parseInt(o,10):r===s.length-1?t.family=o:t.family=(t.family||"")+" "+o}}}return i?.textDecoration&&(t.underline=i.textDecoration===Je),t.family=t.family?.trim().replace(/['"]+/g,""),t}function xi(i){let t=i.trim(),e=t.match(/var\((--[\w-]+),\s*(.+)\)/);return e?{variableName:e[1],fallbackValue:e[2]?.trim()??""}:{variableName:void 0,fallbackValue:t}}var F=class i{constructor(t,e){this.compRef=t,this.privateAPI=e}async getProp(t){return(await this.privateAPI.refComponents.getProps(this.compRef))?.[t]}async setProp(t,e){await this.privateAPI.refComponents.setProps(this.compRef,{[t]:e})}async getDesignPreset(){return this.privateAPI.designPresets.getDesignPresetName(this.compRef)}async setDesignPreset(t){await this.privateAPI.designPresets.setDesignPresetByName(this.compRef,t)}async getNestedWidget(t){let e=await this.privateAPI.refComponents.findComponentBySelector(this.compRef,t);return e?new i(e,this.privateAPI):null}},x,j,ue=class extends g{constructor(){super(...arguments);h(this,x)}async setPreloadFonts(e){let n=await this.getPlatformPrivateAPI(),s=await u(this,x,j).call(this);if(await n.refComponents.isRefComponent(s))throw St(ct.NotAvailableMethod,"not available for the current component type");let r=Ci(e);await n.customElement.setPreloadFonts(s,r)}async getProp(e){let n=await this.getPlatformPrivateAPI(),s=await u(this,x,j).call(this);return await n.refComponents.isRefComponent(s)?new F(s,n).getProp(e):n.customElement.getAttribute(s,e)}async setProp(e,n){let s=await this.getPlatformPrivateAPI(),r=await u(this,x,j).call(this);if(await s.refComponents.isRefComponent(r))return new F(r,s).setProp(e,n);await s.customElement.setAttribute(r,e,n)}async getDesignPreset(){let e=await this.getPlatformPrivateAPI(),n=await u(this,x,j).call(this);if(!await e.refComponents.isRefComponent(n))throw St(ct.NotAvailableMethod,"not available for the current component type");return new F(n,e).getDesignPreset()}async setDesignPreset(e){let n=await this.getPlatformPrivateAPI(),s=await u(this,x,j).call(this);if(!await n.refComponents.isRefComponent(s))throw St(ct.NotAvailableMethod,"not available for the current component type");return new F(s,n).setDesignPreset(e)}async getNestedWidget(e){let n=await this.getPlatformPrivateAPI(),s=await u(this,x,j).call(this);return new F(s,n).getNestedWidget(e)}};x=new WeakSet,j=async function(){let s=(await(await this.getPlatformPrivateAPI()).components.getSelectedComponents())[0];if(!s)throw St(ct.UndefinedCompRef);return s};var Ti=new m(ue).withPublicMethod("getNestedWidget").withPublicMethod("setDesignPreset").withPublicMethod("getDesignPreset").withPublicMethod("setProp").withPublicMethod("getProp").withPublicMethod("setPreloadFonts"),pn=Ti.build();function Mi(i){return`${i.cssVariableName?`var(${i.cssVariableName}, `:""}${i.italic?"italic ":""}${i.bold?"bold ":""}${i.size||16}px ${i.family?.split(",").map(t=>`"${t.replace(/['"]+/g,"")}"`).join(",")||"serif"}${i.cssVariableName?")":""}`}function Ri(i){if(!i)return null;let t=i,e=t.match(/var\((--[\w-]+),\s*(.+)\)/);return e?{cssVariableName:e[1],color:e[2]}:{color:t}}function Ye(i){return i?i.cssVariableName?`var(${i.cssVariableName}, ${i.color})`:i.color:""}var _i={transformFontInternalValue:i=>{if(i){let{theme:t,cssVariableName:e,bold:n,italic:s,underline:r,...o}=i;return{...o,style:{bold:n,italic:s,underline:r},editorKey:e||t||""}}else return{editorKey:"font_7",family:"helvetica-w01-roman",size:16,style:{}}}},de=class extends g{async selectColor(t,e){let n=await this.getPlatformPrivateAPI(),s=Ri(t),r=Ye(s);return await n.inputs.openColorPicker({color:s?.cssVariableName||s?.theme||s?.color},({color:o,theme:c,cssVariableTheme:p})=>{s={color:o,theme:c,cssVariableName:p},r=Ye(s),e?.onChange?.(r)}),r}async selectFont(t,e){let n=await this.getPlatformPrivateAPI(),s=He(t),r=t;return await n.inputs.openFontPickerV2({...e,panelSectionsDefinition:{htmlTag:"hidden"},componentStyle:_i.transformFontInternalValue(s)},(o,c)=>{r={font:Mi(o),textDecoration:o.underline?Je:void 0},e?.onChange?.(r)}),r}},hn=new m(de).withPublicMethod("selectColor").withPublicMethod("selectFont").build(),fe=class extends g{async openLanguageSupportPanel(){return(await this.getPlatformPrivateAPI()).panels.openLanguageSupportPanel()}async openFontsUploadPanel(){return(await this.getPlatformPrivateAPI()).panels.openFontsUploadPanel()}},un=new m(fe).withPublicMethod("openLanguageSupportPanel").withPublicMethod("openFontsUploadPanel").build(),Pe=class extends g{async openDashboardModal(t){return(await this.getPlatformPrivateAPI()).panels.openDashboardPanel(await this.getAppDefinitionId(),t)}},dn=new m(Pe).withPublicMethod("openDashboardModal").build(),me=class extends g{async getStyleDefinitions(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getStyleDefinitions(e)}async getStyles(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getStyles(e)}async setStyles(t){let e=await this.getPlatformPrivateAPI(),n=await this.getRequiredManifestContextId();return e.builderComponent.setStyles(n,t)}async getDataDefinitions(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getDataDefinitions(e)}async getData(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getData(e)}async setData(t){let e=await this.getPlatformPrivateAPI(),n=await this.getRequiredManifestContextId();return e.builderComponent.setData(n,t)}async getState(){return null}async setState(){return null}async getStateDefinitions(){return null}async onChange(t){let e=await this.getPlatformPrivateAPI(),n=await this.getRequiredManifestContextId();return e.builderComponent.onContextualManifestChange(n,t)}async selectMedia(t){let e=await this.getPlatformPrivateAPI(),n=await this.getRequiredManifestContextId();return e.builderComponent.selectMedia(n,t)}async selectLink(t){let e=await this.getPlatformPrivateAPI(),n=await this.getRequiredManifestContextId();return e.builderComponent.selectLink(n,t)}async selectColor(t){let e=await this.getPlatformPrivateAPI();try{let n=await this.getRequiredManifestContextId();return await e.builderComponent.selectColor(n,t)}catch{}}},fn=new m(me).withPublicMethod("getDataDefinitions").withPublicMethod("getData").withPublicMethod("setData").withPublicMethod("getStyleDefinitions").withPublicMethod("getStyles").withPublicMethod("setStyles").withPublicMethod("getState").withPublicMethod("setState").withPublicMethod("onChange").withPublicMethod("getStateDefinitions").withPublicMethod("selectMedia").withPublicMethod("selectLink").withPublicMethod("selectColor").build(),ge=class extends g{async get(t){return(await this.getPlatformPrivateAPI()).userPreferences.get(await this.getAppDefinitionId(),t)}async set(t){return(await this.getPlatformPrivateAPI()).userPreferences.set(await this.getAppDefinitionId(),t)}},Pn=new m(ge).withPublicMethod("set").withPublicMethod("get").build(),Ie=class extends g{async getData(){return(await this.getPlatformPrivateAPI()).externalPanels.getData()}async setData(t){return(await this.getPlatformPrivateAPI()).externalPanels.setData(t)}async getStyle(){return(await this.getPlatformPrivateAPI()).externalPanels.getStyle()}async setStyle(t){return(await this.getPlatformPrivateAPI()).externalPanels.setStyle(t)}async getTheme(){return(await this.getPlatformPrivateAPI()).externalPanels.getTheme()}async selectMedia(){return(await this.getPlatformPrivateAPI()).externalPanels.selectMedia()}async selectLink(...t){return(await this.getPlatformPrivateAPI()).externalPanels.selectLink(...t)}async selectColor(...t){return async()=>(await this.getPlatformPrivateAPI()).externalPanels.selectColor(...t)}async translate(t,e){return(await this.getPlatformPrivateAPI()).externalPanels.translate(t,e)}},mn=new m(Ie).withPublicMethod("getTheme").withPublicMethod("getData").withPublicMethod("getStyle").withPublicMethod("selectColor").withPublicMethod("selectLink").withPublicMethod("selectMedia").withPublicMethod("setData").withPublicMethod("setStyle").withPublicMethod("translate").build(),Di=()=>{let i=new URLSearchParams(window.location.search),t=i.has("essentials")?JSON.parse(i.get("essentials")):void 0,{monitoring:e,...n}=t||{},s=i.get("appDefinitionId"),{context:r,config:o}=e||{},c=be({hostContext:{appId:s,...r},monitoringConfig:o,sentrySDK:typeof window<"u"?window.Sentry:void 0});return{environment:{},applicationContext:y.getInstance(),channel:{observeState:async()=>({disconnect(){}})},getMonitoringClient:c,essentials:n}},Si=()=>({environment:{},applicationContext:y.getInstance(),channel:{observeState:async()=>({disconnect(){}})}}),Ae={host:()=>typeof importScripts=="function"?Si():Di(),auth:Ei};var wn=()=>{let i=Ae.host(),t=Ae.auth();ve({auth:t,host:i}).enableContext("module")};export{wn as enableClient};
8
8
  //# sourceMappingURL=editor.js.map