@wix/cli-app 1.1.106 → 1.1.108

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 (86) hide show
  1. package/build/{AddPermissionCommand-QEKDCRQW.js → AddPermissionCommand-W3TQTL3X.js} +2 -2
  2. package/build/{DevCommand-736A5TG3.js → DevCommand-3HZJQQIQ.js} +10 -10
  3. package/build/{DevCommand-736A5TG3.js.map → DevCommand-3HZJQQIQ.js.map} +1 -1
  4. package/build/{GenerateCommand-F6WNIVZH.js → GenerateCommand-UQ3JHQTJ.js} +47 -8
  5. package/build/GenerateCommand-UQ3JHQTJ.js.map +1 -0
  6. package/build/{LogsCommand-POFQ7L7U.js → LogsCommand-JHADSYUE.js} +3 -3
  7. package/build/PreviewCommand-WBQRDP7K.js +19 -0
  8. package/build/ReleaseCommand-3KDJB3KZ.js +23 -0
  9. package/build/{ServeCommand-LLCIQQ4X.js → ServeCommand-IPKP6PJ2.js} +3 -3
  10. package/build/{build-HZ5SXQHP.js → build-LZ3CJXNM.js} +6 -6
  11. package/build/{chunk-2X5STX6V.js → chunk-6OQZW27N.js} +8 -2
  12. package/build/{chunk-2X5STX6V.js.map → chunk-6OQZW27N.js.map} +1 -1
  13. package/build/{chunk-VDPMGGS6.js → chunk-7KESMWRI.js} +13 -7
  14. package/build/{chunk-VDPMGGS6.js.map → chunk-7KESMWRI.js.map} +1 -1
  15. package/build/{chunk-NWQVBGCX.js → chunk-BER5YRAG.js} +2 -2
  16. package/build/{chunk-XPAQVBEL.js → chunk-FO7ABKNR.js} +3 -3
  17. package/build/{chunk-BINOF7AQ.js → chunk-HAUIN5OS.js} +36 -60
  18. package/build/chunk-HAUIN5OS.js.map +1 -0
  19. package/build/{chunk-FWWBKP43.js → chunk-IGC7QYU5.js} +2 -2
  20. package/build/{chunk-BFLRYBN2.js → chunk-LOVLYP4H.js} +5 -5
  21. package/build/{chunk-VMKXYUIA.js → chunk-LWOWN5OI.js} +5 -5
  22. package/build/{chunk-7QAX4LBK.js → chunk-MAZMH6ES.js} +6 -6
  23. package/build/{chunk-G32WRBNI.js → chunk-OKHXUGGH.js} +2 -2
  24. package/build/{chunk-T5HHDBBR.js → chunk-PBROWK34.js} +8 -2
  25. package/build/{chunk-T5HHDBBR.js.map → chunk-PBROWK34.js.map} +1 -1
  26. package/build/{chunk-7JLHWVDX.js → chunk-PFAJ5ETM.js} +2 -2
  27. package/build/{chunk-XW5CZ6RF.js → chunk-RDXTHRJ4.js} +14 -2
  28. package/build/{chunk-XW5CZ6RF.js.map → chunk-RDXTHRJ4.js.map} +1 -1
  29. package/build/{chunk-4TQGXVYE.js → chunk-UEUJOHB4.js} +3 -3
  30. package/build/{chunk-4IYY6ZGZ.js → chunk-UN2TQTOP.js} +375 -200
  31. package/build/chunk-UN2TQTOP.js.map +1 -0
  32. package/build/{chunk-5Y7LGHZ6.js → chunk-UPQ6AZFY.js} +2 -2
  33. package/build/{chunk-E6VEU7TV.js → chunk-W5SE5OVE.js} +210 -334
  34. package/build/{chunk-E6VEU7TV.js.map → chunk-W5SE5OVE.js.map} +1 -1
  35. package/build/{chunk-PEMPZ5MM.js → chunk-Z4NG6X6T.js} +2 -2
  36. package/build/cloudflare-runtime/entry.js +256 -32
  37. package/build/cloudflare-runtime/getRegisteredExtensions.js +252 -28
  38. package/build/index.js +24 -24
  39. package/build/platform-sdk/chunk-J3SVE4GM.js +2 -0
  40. package/build/platform-sdk/chunk-J3SVE4GM.js.map +1 -0
  41. package/build/platform-sdk/chunk-J7RIIVO6.js +2 -0
  42. package/build/platform-sdk/chunk-J7RIIVO6.js.map +1 -0
  43. package/build/platform-sdk/chunk-RHDUKNAJ.js +2 -0
  44. package/build/platform-sdk/chunk-RHDUKNAJ.js.map +1 -0
  45. package/build/platform-sdk/dashboard.js +1 -1
  46. package/build/platform-sdk/dashboard.js.map +1 -1
  47. package/build/platform-sdk/editor.js +2 -2
  48. package/build/platform-sdk/editor.js.map +1 -1
  49. package/build/platform-sdk/sdk-context.js +1 -1
  50. package/build/platform-sdk/sdk-context.js.map +1 -1
  51. package/build/platform-sdk/site.js +1 -1
  52. package/build/{preview-R6YTZ7DV.js → preview-OVNN2RP4.js} +13 -13
  53. package/build/{release-IJJ3EB2C.js → release-OMLRH2VC.js} +15 -15
  54. package/build/{render-command-FJOPHPRO.js → render-command-DIMIKL4B.js} +6 -6
  55. package/package.json +6 -6
  56. package/build/GenerateCommand-F6WNIVZH.js.map +0 -1
  57. package/build/PreviewCommand-DGVLJIC5.js +0 -19
  58. package/build/ReleaseCommand-BK665XSD.js +0 -23
  59. package/build/chunk-4IYY6ZGZ.js.map +0 -1
  60. package/build/chunk-BINOF7AQ.js.map +0 -1
  61. package/build/platform-sdk/chunk-BBFFXVJD.js +0 -2
  62. package/build/platform-sdk/chunk-BBFFXVJD.js.map +0 -1
  63. package/build/platform-sdk/chunk-MAZR75DI.js +0 -2
  64. package/build/platform-sdk/chunk-MAZR75DI.js.map +0 -1
  65. package/build/platform-sdk/chunk-NHYZDMR5.js +0 -2
  66. package/build/platform-sdk/chunk-NHYZDMR5.js.map +0 -1
  67. /package/build/{AddPermissionCommand-QEKDCRQW.js.map → AddPermissionCommand-W3TQTL3X.js.map} +0 -0
  68. /package/build/{LogsCommand-POFQ7L7U.js.map → LogsCommand-JHADSYUE.js.map} +0 -0
  69. /package/build/{PreviewCommand-DGVLJIC5.js.map → PreviewCommand-WBQRDP7K.js.map} +0 -0
  70. /package/build/{ReleaseCommand-BK665XSD.js.map → ReleaseCommand-3KDJB3KZ.js.map} +0 -0
  71. /package/build/{ServeCommand-LLCIQQ4X.js.map → ServeCommand-IPKP6PJ2.js.map} +0 -0
  72. /package/build/{build-HZ5SXQHP.js.map → build-LZ3CJXNM.js.map} +0 -0
  73. /package/build/{chunk-NWQVBGCX.js.map → chunk-BER5YRAG.js.map} +0 -0
  74. /package/build/{chunk-XPAQVBEL.js.map → chunk-FO7ABKNR.js.map} +0 -0
  75. /package/build/{chunk-FWWBKP43.js.map → chunk-IGC7QYU5.js.map} +0 -0
  76. /package/build/{chunk-BFLRYBN2.js.map → chunk-LOVLYP4H.js.map} +0 -0
  77. /package/build/{chunk-VMKXYUIA.js.map → chunk-LWOWN5OI.js.map} +0 -0
  78. /package/build/{chunk-7QAX4LBK.js.map → chunk-MAZMH6ES.js.map} +0 -0
  79. /package/build/{chunk-G32WRBNI.js.map → chunk-OKHXUGGH.js.map} +0 -0
  80. /package/build/{chunk-7JLHWVDX.js.map → chunk-PFAJ5ETM.js.map} +0 -0
  81. /package/build/{chunk-4TQGXVYE.js.map → chunk-UEUJOHB4.js.map} +0 -0
  82. /package/build/{chunk-5Y7LGHZ6.js.map → chunk-UPQ6AZFY.js.map} +0 -0
  83. /package/build/{chunk-PEMPZ5MM.js.map → chunk-Z4NG6X6T.js.map} +0 -0
  84. /package/build/{preview-R6YTZ7DV.js.map → preview-OVNN2RP4.js.map} +0 -0
  85. /package/build/{release-IJJ3EB2C.js.map → release-OMLRH2VC.js.map} +0 -0
  86. /package/build/{render-command-FJOPHPRO.js.map → render-command-DIMIKL4B.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","../../../node_modules/@wix/sdk-runtime/build/host-modules.js","../../../node_modules/@wix/monitoring/build/index.js","../../../node_modules/@wix/monitoring-common-sentry/build/index.js","../../../node_modules/@wix/monitoring-browser-sentry/build/index.js","../../../node_modules/@wix/monitoring-browser-panorama/build/index.js","../../../node_modules/@wix/monitoring-browser-sdk-host/build/index.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","import { contextualizeHostModuleV2 } from './context-v2.js';\nexport function createHostModule(hostModuleAPI) {\n return contextualizeHostModuleV2({\n __type: 'host',\n create: (host) => Object.entries(hostModuleAPI).reduce((acc, [key, fn]) => ({\n ...acc,\n [key]: fn(host),\n }), {}),\n }, Object.keys(hostModuleAPI));\n}\n","// src/context/context-utils.ts\nvar validValue = (value) => value !== void 0 && value !== null && value !== \"\";\nvar pickByValidValues = (obj) => pickBy(obj, validValue);\nfunction pickBy(object, predicate = (value) => !!value) {\n if (!object) {\n return {};\n }\n const result = {};\n for (const key in object) {\n if (predicate(object[key], key)) {\n result[key] = object[key];\n }\n }\n return result;\n}\nvar generateTagsAndContext = (context) => {\n const tags = pickByValidValues({\n \"app.id\": context.appId,\n \"app.version\": context.appVersion,\n \"app.instanceId\": context.appInstanceId,\n \"extension.id\": context.extensionId,\n \"extension.name\": context.extensionName,\n \"extension.type\": context.extensionType,\n platform: context.platform\n });\n const contexts = pickBy(\n {\n \"extension.data\": pickByValidValues({\n ...context.extensionData\n }),\n site: pickByValidValues({\n url: context.siteUrl,\n id: context.tenantType === \"SITE\" ? context.tenantId : void 0\n }),\n account: pickByValidValues({\n id: context.tenantType === \"ACCOUNT\" ? context.tenantId : void 0\n })\n },\n (value) => !!value && Object.keys(value).length > 0\n );\n return {\n tags,\n contexts\n };\n};\n\n// src/fallback-client.ts\nvar FallbackMonitoringClient = class {\n constructor(message) {\n this.message = message;\n this.captureException = () => {\n console.error(this.message);\n };\n this.captureMessage = () => {\n console.error(this.message);\n };\n this.startSpan = (spanOptions, callback) => {\n console.error(this.message);\n return callback(void 0);\n };\n this.startSpanManual = () => {\n console.error(this.message);\n return {\n end: () => {\n },\n fail: () => {\n }\n };\n };\n this.endSpanManual = () => {\n console.error(this.message);\n };\n this.addBreadcrumb = () => {\n console.error(this.message);\n };\n }\n};\nvar createFallbackMonitoringClient = (message) => {\n return new FallbackMonitoringClient(message);\n};\nexport {\n createFallbackMonitoringClient,\n generateTagsAndContext\n};\n","// src/utils.ts\nvar isPromise = (value) => typeof value?.then === \"function\";\nvar runWithMaybePromise = (value, cb) => {\n if (!cb) {\n return value;\n }\n if (isPromise(value)) {\n return value.then((res) => {\n cb(res, true);\n return res;\n });\n } else {\n cb(value, false);\n return value;\n }\n};\nvar runWithMaybeDelay = (cb, maybeTimeCompensation) => {\n if (!cb) {\n return;\n }\n if (maybeTimeCompensation) {\n setTimeout(cb, maybeTimeCompensation);\n } else {\n cb();\n }\n};\nvar generateRandomId = () => Date.now() + Math.random();\n\n// src/manual-span.ts\nvar ManualSpanRegistryImpl = class {\n constructor(options) {\n this.options = options;\n this.spanMap = /* @__PURE__ */ new Map();\n }\n createSpan(spanOptions, sentryOptionsOrPromise) {\n let resolveSpan;\n let rejectSpan;\n let error;\n const startTime = Date.now();\n let maybeDurationCompensation;\n const maybePromise = runWithMaybePromise(\n sentryOptionsOrPromise,\n ({ sentrySDK, scope }, isPromise2) => {\n if (isPromise2) {\n maybeDurationCompensation = Date.now() - startTime;\n }\n const promise = sentrySDK.startSpan(\n {\n ...spanOptions,\n scope,\n forceTransaction: this.options.forceTransaction\n },\n () => new Promise((resolve, reject) => {\n resolveSpan = resolve;\n rejectSpan = reject;\n })\n );\n promise?.catch((e) => {\n if (e?.message !== error?.message) {\n throw e;\n }\n });\n }\n );\n const endSpan = (cb) => {\n this.spanMap.delete(spanOptions.name);\n runWithMaybePromise(maybePromise, () => {\n runWithMaybeDelay(cb, maybeDurationCompensation);\n });\n };\n const span = {\n end: () => {\n endSpan(() => resolveSpan?.());\n },\n fail: (_error) => {\n error = error ?? _error;\n endSpan(() => rejectSpan?.(_error));\n }\n };\n this.spanMap.set(spanOptions.name, span);\n return span;\n }\n getSpan(spanOptions) {\n return this.spanMap.get(spanOptions.name);\n }\n};\nvar createManualSpanRegistry = (options) => new ManualSpanRegistryImpl(options);\nexport {\n createManualSpanRegistry,\n generateRandomId,\n isPromise,\n runWithMaybeDelay,\n runWithMaybePromise\n};\n","// src/factory.ts\nimport { createFallbackMonitoringClient } from \"@wix/monitoring\";\n\n// src/browser/client.ts\nimport { isPromise } from \"@wix/monitoring-common-sentry\";\n\n// src/abstract-browser-client.ts\nimport {\n createManualSpanRegistry\n} from \"@wix/monitoring-common-sentry\";\n\n// src/context-utils.ts\nimport { generateTagsAndContext } from \"@wix/monitoring\";\nvar setTagsAndContextsOnScope = (scope, { tags, contexts }) => {\n if (tags) {\n scope.setTags(tags);\n }\n if (contexts) {\n Object.entries(contexts).forEach(\n ([key, value]) => typeof value !== \"undefined\" && scope.setContext(key, value)\n );\n }\n};\nvar setHostContextOnScope = (scope, hostContext) => {\n if (!hostContext) {\n return;\n }\n const { tags, contexts } = generateTagsAndContext(hostContext);\n setTagsAndContextsOnScope(scope, { tags, contexts });\n};\n\n// src/abstract-browser-client.ts\nvar MandatorySDKMethods = [\"onLoad\", \"forceLoad\"];\nvar manualSpanRegistryMap = /* @__PURE__ */ new Map();\nvar AbstractSentryBrowserClient = class {\n constructor(options) {\n this.options = options;\n this.resolvedState = null;\n this.validateOptions = (options) => {\n const missingSDKMethods = MandatorySDKMethods.filter(\n (method) => typeof options.sentrySDK?.[method] !== \"function\"\n );\n if (missingSDKMethods.length > 0) {\n throw new Error(\n `Missing the following options.sentrySDK methods: ${missingSDKMethods.join(\", \")}`\n );\n }\n };\n this.validateOptions(options);\n let manualSpanRegistry = manualSpanRegistryMap.get(options.dsn);\n if (!manualSpanRegistry) {\n manualSpanRegistry = createManualSpanRegistry({\n // Force spans to be reported as individual transactions (one http request per one span)\n forceTransaction: true\n });\n manualSpanRegistryMap.set(options.dsn, manualSpanRegistry);\n }\n this.manualSpanRegistry = manualSpanRegistry;\n }\n isFullSDK() {\n return typeof this.options.sentrySDK.BrowserClient === \"function\";\n }\n init() {\n if (this.resolvedState) {\n return this.resolvedState;\n }\n const {\n sentrySDK,\n transport,\n hostContext,\n dsn,\n release,\n environment,\n tracesSampleRate = 1,\n debug = false\n } = this.options;\n const scope = new sentrySDK.Scope();\n const sentryClient = new sentrySDK.BrowserClient({\n dsn,\n transport: transport ?? sentrySDK.makeFetchTransport,\n integrations: sentrySDK.getDefaultIntegrations({}),\n stackParser: sentrySDK.defaultStackParser,\n tracesSampleRate: tracesSampleRate || 1,\n debug,\n environment,\n release\n });\n setHostContextOnScope(scope, hostContext);\n scope.setClient(sentryClient);\n sentryClient.init();\n this.resolvedState = {\n sentrySDK,\n scope,\n sentryClient\n };\n return this.resolvedState;\n }\n loadFullSDK(handler) {\n if (this.isFullSDK()) {\n handler?.(this.init());\n return;\n }\n if (this.promise) {\n this.promise.then(handler);\n return;\n }\n this.promise = new Promise((resolve) => {\n this.options.sentrySDK.onLoad(() => {\n if (this.resolvedState) {\n return;\n }\n const resolvedState = this.init();\n resolve(resolvedState);\n handler?.(resolvedState);\n });\n });\n this.options.sentrySDK.forceLoad();\n }\n};\n\n// src/browser/client.ts\nvar SentryBrowserClient = class extends AbstractSentryBrowserClient {\n constructor() {\n super(...arguments);\n /**\n * Records a new breadcrumb which will be attached to future events.\n * Breadcrumbs will be added to subsequent events to provide more context on user's actions prior to an error or crash.\n * @param breadcrumb The breadcrumb to record.\n */\n this.addBreadcrumb = (breadcrumb) => {\n const filteredBreadcrumb = {\n type: breadcrumb.type,\n category: breadcrumb.category,\n message: breadcrumb.message,\n level: breadcrumb.level,\n data: breadcrumb.data\n };\n this.loadFullSDK(({ scope }) => {\n scope.addBreadcrumb(filteredBreadcrumb);\n });\n };\n /**\n * Captures an exception event and sends it to Sentry.\n * @param error The error to capture\n * @param captureContext Optional additional data to attach to the Sentry event.\n */\n this.captureException = (error, captureContext) => {\n this.loadFullSDK(({ sentryClient, scope }) => {\n sentryClient.captureException(\n error,\n {\n captureContext: {\n level: captureContext?.level ?? \"error\",\n tags: captureContext?.tags,\n contexts: captureContext?.contexts\n }\n },\n scope\n );\n });\n };\n /**\n * Captures a message event and sends it to Sentry.\n * @param message The message to capture\n * @param captureContext Define the level of the message or pass in additional data to attach to the message.\n */\n this.captureMessage = (message, captureContext) => {\n this.loadFullSDK(({ sentryClient, scope }) => {\n sentryClient.captureMessage(\n message,\n captureContext?.level ?? \"error\",\n {\n captureContext: {\n level: captureContext?.level ?? \"error\",\n tags: captureContext?.tags,\n contexts: captureContext?.contexts\n }\n },\n scope\n );\n });\n };\n /**\n * Wraps a function with a span and finishes the span after the function is done. The created span is the active span and will be used as parent by other spans created inside the function, as long as the function is executed while the scope is active.\n * @param spanOptions The options for the span\n * @param callback The function to wrap with a span\n * @returns The return value of the callback\n */\n this.startSpan = (spanOptions, callback) => {\n if (this.isFullSDK()) {\n const { sentrySDK, scope } = this.init();\n return sentrySDK.startSpan({ ...spanOptions, scope }, callback);\n }\n this.loadFullSDK();\n const simulateAndReportSuccessfulSpan = (callbackResult2, startTime2) => {\n const spanDuration = Date.now() - startTime2;\n const simulatedCallback = () => {\n return new Promise(\n (resolve) => setTimeout(() => resolve(callbackResult2), spanDuration)\n );\n };\n this.loadFullSDK(async ({ sentrySDK, scope }) => {\n return sentrySDK.startSpan(\n { ...spanOptions, scope },\n simulatedCallback\n );\n });\n };\n const simulateAndReportFailedSpan = async (error2, startTime2) => {\n const spanDuration = Date.now() - startTime2;\n const simulatedCallback = () => {\n return new Promise(\n (_, reject) => setTimeout(() => reject(error2), spanDuration)\n );\n };\n this.loadFullSDK(async ({ sentrySDK, scope }) => {\n try {\n await sentrySDK.startSpan(\n { ...spanOptions, scope },\n simulatedCallback\n );\n } catch (e) {\n if (e?.message !== error2?.message) {\n throw e;\n }\n }\n });\n };\n const startTime = Date.now();\n let callbackResult;\n let error;\n try {\n callbackResult = callback();\n } catch (e) {\n error = e;\n }\n if (error) {\n simulateAndReportFailedSpan(error, startTime);\n throw error;\n } else {\n if (isPromise(callbackResult)) {\n callbackResult.then((res) => simulateAndReportSuccessfulSpan(res, startTime)).catch((e) => simulateAndReportFailedSpan(e, startTime));\n } else {\n simulateAndReportSuccessfulSpan(callbackResult, startTime);\n }\n return callbackResult;\n }\n };\n this.startSpanManual = (spanOptions) => {\n const resolvedStateOrPromise = this.isFullSDK() ? this.init() : new Promise((resolve) => this.loadFullSDK(resolve));\n const span = this.manualSpanRegistry.createSpan(\n spanOptions,\n resolvedStateOrPromise\n );\n return span;\n };\n this.endSpanManual = (spanOptions) => {\n const span = this.manualSpanRegistry.getSpan(spanOptions);\n span?.end();\n };\n }\n};\n\n// src/factory.ts\nvar unsupportedEnvironmentMessage = (version) => `Sentry SDK version \"${version}\" is not supported. Please make sure to use monitoring SDK only in supported environments.`;\nvar major = (version) => {\n try {\n return parseInt(version.split(\".\")[0], 10);\n } catch {\n console.warn(\"Failed to parse Sentry SDK version\");\n return void 0;\n }\n};\nvar createSentryBrowserClient = ({\n sentrySDK,\n dsn,\n ...options\n}) => {\n if (!sentrySDK) {\n return createFallbackMonitoringClient(\n \"Unsupported environment - Sentry SDK is not loaded into the environment. Please make sure to use monitoring SDK only in supported environments.\"\n );\n }\n if (!dsn) {\n return createFallbackMonitoringClient(\n \"Missing Sentry DSN in the app's monitoring configuration. Please make sure to set it.\"\n );\n }\n try {\n const sentrySdkMajorVersion = sentrySDK.SDK_VERSION && major(sentrySDK.SDK_VERSION);\n if (sentrySdkMajorVersion && sentrySdkMajorVersion < 7) {\n return createFallbackMonitoringClient(\n unsupportedEnvironmentMessage(sentrySDK.SDK_VERSION)\n );\n }\n return new SentryBrowserClient({ ...options, dsn, sentrySDK });\n } catch (e) {\n return createFallbackMonitoringClient(\n `Failed to initialize monitoring client: ${e.message}`\n );\n }\n};\nexport {\n createSentryBrowserClient\n};\n","// src/client.ts\nimport { generateRandomId, isPromise } from \"@wix/monitoring-common-sentry\";\nvar PanoramaBrowserClient = class {\n constructor(options) {\n this.options = options;\n this.captureException = (error, captureContext) => {\n const { panoramaClient } = this.options;\n if (!(error instanceof Error)) {\n error = new Error(error);\n }\n panoramaClient.errorMonitor().reportError(error, this.contextToData(captureContext));\n };\n this.captureMessage = (message, captureContext) => {\n const { panoramaClient } = this.options;\n const logger = panoramaClient.logger();\n let loggerByLevel;\n switch (captureContext?.level) {\n case \"error\":\n loggerByLevel = logger.error;\n break;\n case \"warning\":\n loggerByLevel = logger.warn;\n break;\n default:\n loggerByLevel = logger.info;\n }\n loggerByLevel(message, this.contextToData(captureContext));\n };\n this.startSpan = (spanOptions, callback) => {\n const { panoramaClient } = this.options;\n const { name } = spanOptions;\n let res;\n const transaction = panoramaClient.transaction(name, {\n id: generateRandomId()\n });\n const data = this.contextToData(spanOptions);\n transaction.start(data);\n try {\n res = callback();\n if (isPromise(res)) {\n res = res.then((_res) => {\n transaction.finish(data);\n return _res;\n }).catch((e) => {\n this.reportErrorInContextOfSpan(e, spanOptions);\n throw e;\n });\n } else {\n transaction.finish(data);\n }\n } catch (e) {\n this.reportErrorInContextOfSpan(e, spanOptions);\n throw e;\n }\n return res;\n };\n this.addBreadcrumb = (breadcrumb) => {\n const { panoramaClient } = this.options;\n panoramaClient.errorMonitor().addBreadcrumb(breadcrumb);\n };\n }\n contextToData(captureContext) {\n return captureContext && {\n ...captureContext?.tags && { tags: captureContext.tags },\n ...captureContext?.contexts && { context: captureContext.contexts },\n ...captureContext?.level && {\n severity: captureContext.level\n }\n };\n }\n reportErrorInContextOfSpan(error, spanOptions) {\n const { panoramaClient } = this.options;\n const { name } = spanOptions;\n const data = this.contextToData({\n ...spanOptions,\n contexts: { transaction: { name } }\n });\n panoramaClient.errorMonitor().reportError(error, data);\n }\n startSpanManual(spanOptions) {\n const { panoramaClient } = this.options;\n const { name } = spanOptions;\n const transaction = panoramaClient.transaction(name, {\n id: generateRandomId()\n });\n const data = this.contextToData(spanOptions);\n transaction.start(data);\n let reported = false;\n const reportOnce = (cb) => {\n if (reported) {\n return;\n }\n reported = true;\n cb();\n };\n return {\n end: () => {\n reportOnce(() => transaction.finish(data));\n },\n fail: (error) => {\n reportOnce(() => this.reportErrorInContextOfSpan(error, spanOptions));\n }\n };\n }\n endSpanManual(spanOptions) {\n const { panoramaClient } = this.options;\n const { name } = spanOptions;\n panoramaClient.transaction(name).finish();\n }\n};\n\n// src/factory.ts\nimport { createFallbackMonitoringClient } from \"@wix/monitoring\";\nvar createPanoramaBrowserClient = (options) => {\n const { panoramaClient } = options;\n if (!panoramaClient) {\n return createFallbackMonitoringClient(\"Missing Panorama client\");\n }\n return new PanoramaBrowserClient(options);\n};\nexport {\n createPanoramaBrowserClient\n};\n","// src/monitoring-client.ts\nimport { createFallbackMonitoringClient } from \"@wix/monitoring\";\nimport { createSentryBrowserClient } from \"@wix/monitoring-browser-sentry\";\nimport {\n createPanoramaBrowserClient\n} from \"@wix/monitoring-browser-panorama\";\nvar isSentryConfig = (monitoringConfig) => monitoringConfig?.type === \"SENTRY\";\nvar isPanoramaConfig = (monitoringConfig) => monitoringConfig?.type === \"PANORAMA\";\nvar getMonitoringClientFunction = ({\n sentrySDK,\n sentryTransport,\n panoramaClient,\n monitoringConfig,\n hostContext\n}) => {\n if (isSentryConfig(monitoringConfig)) {\n const { sentryOptions } = monitoringConfig;\n return () => createSentryBrowserClient({\n dsn: sentryOptions?.dsn,\n hostContext,\n sentrySDK,\n transport: sentryTransport\n });\n } else if (isPanoramaConfig(monitoringConfig)) {\n return () => createPanoramaBrowserClient({ panoramaClient });\n }\n return () => createFallbackMonitoringClient(\n \"Invalid monitoring configuration. Please check the monitoring setup of your application.\"\n );\n};\nexport {\n getMonitoringClientFunction\n};\n"],"mappings":"AAAA,OAAS,cAAAA,MAAkB,mBACpB,SAASC,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,OAAON,EAAW,OAAW,IACzBA,EAAW,OACX,OAAO,WAAW,gBAAoB,IAClC,WAAW,gBAAgB,OAC3B,OACRO,EAAiB,OAAO,YAAgB,IACxC,YAAY,eACZ,OAAOP,EA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ACJ,GAAIP,EAAeC,CAAgB,EAAG,CACpC,GAAM,CAAE,cAAAO,CAAc,EAAIP,EAC1B,MAAO,IAAMQ,EAA0B,CACrC,IAAKD,GAAe,IACpB,YAAAD,EACA,UAAAH,EACA,UAAWC,CACb,CAAC,CACH,SAAWH,EAAiBD,CAAgB,EAC1C,MAAO,IAAMS,EAA4B,CAAE,eAAAJ,CAAe,CAAC,EAE7D,MAAO,IAAMK,EACX,0FACF,CACF","names":["wixContext","resolveContext","oldContext","modules","elevated","runWithoutContext","contextualClient","elevatedClient","wixModules","urlOrRequest","requestInit","query","variables","opts","runWithoutContext","fn","globalContext","moduleContext","wixContext","closureContext","contextualizeHostModuleV2","hostModule","props","prop","args","context","resolveContext","createHostModule","hostModuleAPI","contextualizeHostModuleV2","host","acc","key","fn","validValue","value","pickByValidValues","obj","pickBy","object","predicate","result","key","generateTagsAndContext","context","tags","contexts","FallbackMonitoringClient","message","spanOptions","callback","createFallbackMonitoringClient","isPromise","value","runWithMaybePromise","cb","res","runWithMaybeDelay","maybeTimeCompensation","generateRandomId","ManualSpanRegistryImpl","options","spanOptions","sentryOptionsOrPromise","resolveSpan","rejectSpan","error","startTime","maybeDurationCompensation","maybePromise","sentrySDK","scope","isPromise2","resolve","reject","e","endSpan","span","_error","createManualSpanRegistry","setTagsAndContextsOnScope","scope","tags","contexts","key","value","setHostContextOnScope","hostContext","generateTagsAndContext","MandatorySDKMethods","manualSpanRegistryMap","AbstractSentryBrowserClient","options","missingSDKMethods","method","manualSpanRegistry","createManualSpanRegistry","sentrySDK","transport","dsn","release","environment","tracesSampleRate","debug","sentryClient","handler","resolve","resolvedState","SentryBrowserClient","breadcrumb","filteredBreadcrumb","error","captureContext","message","spanOptions","callback","simulateAndReportSuccessfulSpan","callbackResult2","startTime2","spanDuration","simulatedCallback","simulateAndReportFailedSpan","error2","_","reject","e","startTime","callbackResult","isPromise","res","resolvedStateOrPromise","unsupportedEnvironmentMessage","version","major","createSentryBrowserClient","createFallbackMonitoringClient","sentrySdkMajorVersion","PanoramaBrowserClient","options","error","captureContext","panoramaClient","message","logger","loggerByLevel","spanOptions","callback","name","res","transaction","generateRandomId","data","isPromise","_res","e","breadcrumb","reported","reportOnce","cb","createPanoramaBrowserClient","createFallbackMonitoringClient","isSentryConfig","monitoringConfig","isPanoramaConfig","getMonitoringClientFunction","sentrySDK","sentryTransport","panoramaClient","hostContext","sentryOptions","createSentryBrowserClient","createPanoramaBrowserClient","createFallbackMonitoringClient"]}
@@ -0,0 +1,2 @@
1
+ import{b as A}from"./chunk-J3SVE4GM.js";import{a as L,b as M,d as $}from"./chunk-7EYXEF6M.js";import{f as _}from"./chunk-SBZEOPXX.js";$();import{wixContext as Z}from"@wix/sdk-context";var ee=e=>{switch(e){case"get":case"GET":return"GET";case"post":case"POST":return"POST";case"put":case"PUT":return"PUT";case"delete":case"DELETE":return"DELETE";case"patch":case"PATCH":return"PATCH";case"head":case"HEAD":return"HEAD";case"options":case"OPTIONS":return"OPTIONS";default:throw new Error(`Unknown method: ${e}`)}},q=e=>t=>async s=>{let a,r=n=>{if(a=e(s)(n),a.url===void 0)throw new Error("Url was not successfully created for this request, please reach out to support channels for assistance.");let{method:i,url:o,params:p}=a;return{...a,method:ee(i),url:o,data:a.data,params:p}};try{let n=await t.request(r);if(a===void 0)throw new Error("Request options were not created for this request, please reach out to support channels for assistance.");let i=Array.isArray(a.transformResponse)?a.transformResponse:[a.transformResponse],o=n.data;return i.forEach(p=>{p&&(o=p(n.data,n.headers))}),o}catch(n){throw typeof n=="object"&&n!==null&&"response"in n&&typeof n.response=="object"&&n.response!==null&&"data"in n.response?n.response.data:n}},j=e=>e.__isAmbassador?!0:!!e().__isAmbassador;var N="__metadata",x="www.wixapis.com",W="edge.wixapis.com";var v=class extends Error{constructor(s,a){super(s);_(this,"message");_(this,"response");this.message=s,this.response=a}async details(){let s=await this.response.json();return te(this.response.status,s?.message,s?.details,{requestId:this.response.headers.get("X-Wix-Request-Id"),details:s})}},te=(e,t,s,a)=>({details:{...!s?.validationError&&{applicationError:{description:t,code:e,data:a}},...s},message:t,requestId:a?.requestId});var O=e=>e?.method&&["post","put","patch"].includes(e.method.toLocaleLowerCase())&&e.body?{"Content-Type":"application/json"}:{},J=e=>e&&typeof e=="object"&&!Array.isArray(e);var D=e=>e.__type==="host";function F(e,t){return e.create(t)}var se="x-wix-bi-gateway";function k(e,t,s){return{[se]:re({environment:`js-sdk${s?`-${s}`:""}`,"package-name":e.packageName??t?.PACKAGE_NAME,"method-fqn":e.methodFqn,entity:e.entityFqdn})}}function re(e){return Object.entries(e).filter(([t,s])=>!!s).map(([t,s])=>`${t}=${s}`).join(",")}function P(e){return ie(e).map(t=>t.toLocaleUpperCase()).join("_")}var ne=/([\p{Ll}\d])(\p{Lu})/gu,oe=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,B="$1\0$2",ae=/[^\p{L}\d]+/giu;function ie(e){let t=e.trim();t=t.replace(ne,B).replace(oe,B),t=t.replace(ae,"\0");let s=0,a=t.length;for(;t.charAt(s)==="\0";)s++;if(s===a)return[];for(;t.charAt(a-1)==="\0";)a--;return t.slice(s,a).split(/\0/g)}var de=e=>"validationError"in(e.response?.data?.details??{}),ce=e=>"applicationError"in(e.response?.data?.details??{}),pe=e=>(e.response?.status??-1)>=400&&(e.response?.status??-1)<500;function C(e,t={explicitPathsToArguments:{},spreadPathsToArguments:{},singleArgumentUnchanged:!1},s=[]){if(typeof e!="object"||e===null)throw e;if(de(e))return ue(e,t,s);if(ce(e))return le(e);if(pe(e)){let a=e.response?.status,r=e.response?.statusText??"UNKNOWN",n=e.response?.data?.message??r,i={applicationError:{description:r,code:P(r),data:{}},requestId:e.requestId};return b(e,{message:JSON.stringify({message:n,details:i},null,2),extraProperties:{details:i,status:a}})}return he(e)}var ue=(e,t,s)=>{let a=e.response?.data,r=e.requestId,{fieldViolations:n}=a.details.validationError,i=fe(t,n,s)?.sort((l,c)=>l.field<c.field?-1:1),o=`INVALID_ARGUMENT: ${i?.map(({field:l,description:c})=>`"${l}" ${c}`)?.join(", ")}`,p={validationError:{fieldViolations:i},requestId:r};return b(e,{message:JSON.stringify({message:o,details:p},null,2),extraProperties:{details:p,status:e.response?.status,requestId:r}})},b=(e,{message:t,extraProperties:s})=>Object.assign(e,{...s,message:t}),le=e=>{let t=e.response?.status,s=e.response?.statusText??"UNKNOWN",a=e.response?.data?.message??s,r=e.response?.data?.details?.applicationError?.description??s,n=e.response?.data?.details?.applicationError?.code??P(s),i=e.response?.data?.details?.applicationError?.data??{},o=a===r?a:`${a}: ${r}`,p={applicationError:{description:r,code:n,data:i},requestId:e.requestId};return b(e,{message:JSON.stringify({message:o,details:p},null,2),extraProperties:{details:p,status:t,requestId:e.requestId}})},he=e=>{let t=e.requestId?`System error occurred, request-id: ${e.requestId}`:`System error occurred: ${JSON.stringify(e)}`;return b(e,{message:t,extraProperties:{requestId:e.requestId,status:e.response?.status,code:P(e.response?.statusText??"UNKNOWN"),...!e.response&&{runtimeError:e}}})},fe=({spreadPathsToArguments:e,explicitPathsToArguments:t,singleArgumentUnchanged:s},a,r)=>{let n={...e,...t},i=Object.keys(n);return a?.filter(o=>!a.some(l=>l.field.length>o.field.length&&l.field.startsWith(o.field)&&i.includes(l.field))).map(o=>{let p=t[o.field];if(p)return{...o,field:G(p,r)};let l=i?.sort((c,h)=>h.length-c.length)?.find(c=>o.field.startsWith(c));if(l){let c=n[l];if(c)return{...o,field:o.field.replace(l,G(c,r))}}return s?{...o,field:`${r[0]}.${o.field}`}:o})},G=(e,t)=>{let s=me(e);return s!==null&&typeof s<"u"?e.replace(`$[${s}]`,t[s]):e},me=e=>{let t=e.match(/\$\[(?<argIndex>\d+)\]/);return t&&t.groups&&Number(t.groups.argIndex)};function X(e,t,s,a,r,n,i,o,p){return A(()=>e({request:async l=>{let c=l({host:i?.HTTPHost||x}),h=c;h.method==="GET"&&h.fallback?.length&&h.params.toString().length>4e3&&(h=c.fallback[0]);let y=i?.HTTPHost??x,d=`https://${p?W:y}${h.url}`;h.params&&h.params.toString()&&(d+=`?${h.params.toString()}`);try{let u=k(c,t,o),g={method:h.method,...h.data&&{body:JSON.stringify(h.data)},headers:{...u}},f=await s(d,g);if(f.status!==200){let m=null;try{m=await f.json()}catch{}let T=ye(f.status,m?.message,m?.details,{requestId:f.headers.get("X-Wix-Request-Id"),details:m}),H=C(T);throw a?.handleError(H,{requestOptions:{url:h.url,method:h.method,entityFqdn:c.entityFqdn,methodFqn:c.methodFqn}}),T}return{data:await f.json(),headers:f.headers,status:f.status,statusText:f.statusText}}catch(u){throw u.message?.includes("fetch is not defined")&&console.error("Node.js v18+ is required"),u}},fetchWithAuth:s,wixAPIFetch:r,getActiveToken:n}))}var R=class extends Error{constructor(s){super();_(this,"response");_(this,"requestId");this.response=s.response,this.requestId=s.requestId}},ye=(e,t,s,a)=>new R({response:{data:{details:{...!s?.validationError&&{applicationError:{description:t,code:e,data:a}},...s},message:t},status:e},requestId:a?.requestId});$();function I(){return{emit(e,...t){for(let s=0,a=this.events[e]||[],r=a.length;s<r;s++)a[s](...t)},events:{},on(e,t){return(this.events[e]||=[]).push(t),()=>{this.events[e]=this.events[e]?.filter(s=>t!==s)}}}}var Y=e=>e.__type==="event-definition";function K(e,t,s,a){let r;if(e.isDomainEvent){let i=s,{deletedEvent:o,actionEvent:p,createdEvent:l,updatedEvent:c,...h}=i,y={...a,...h};o?o?.deletedEntity?r={entity:o?.deletedEntity,metadata:y}:r={metadata:y}:p?r={data:p.body,metadata:y}:r={entity:l?.entity??c?.currentEntity,metadata:y}}else r={data:s,metadata:a};let n=e.transformations??(i=>i);return t(n(r))}function z(e){let t=new Map,s=I(),a={...s,getRegisteredEvents:()=>t,async process(r,n={expectedEvents:[]}){let{eventType:i,identity:o,instanceId:p,payload:l}=await this.parseJWT(r),c=[...n.expectedEvents,...Array.from(t.keys()).map(y=>({type:y}))];if(c.length>0&&!c.some(({type:y})=>y===i))throw new Error(`Unexpected event type: ${i}. Expected one of: ${c.map(y=>y.type).join(", ")}`);let h=t.get(i)??[];return await Promise.all(h.map(({eventDefinition:y,handler:d})=>K(y,d,l,{instanceId:p,identity:o}))),{instanceId:p,eventType:i,payload:l,identity:o}},async processRequest(r,n){let i=await r.text();return this.process(i,n)},async parseJWT(r){if(!e.decodeJWT)throw new Error("decodeJWT is not supported by the authentication strategy");let{decoded:n,valid:i}=await e.decodeJWT(r);if(!i)throw new Error("JWT is not valid");if(typeof n.data!="string")throw new Error(`Unexpected type of JWT data: expected string, got ${typeof n.data}`);let o=JSON.parse(n.data),p=o.eventType,l=o.instanceId,c=o.identity?JSON.parse(o.identity):void 0,h=JSON.parse(o.data);return{instanceId:l,eventType:p,payload:h,identity:c}},async parseRequest(r){let n=await r.text();return this.parseJWT(n)},async executeHandlers(r){let n=Array.from(t.keys()).map(o=>({type:o}));if(n.length>0&&!n.some(({type:o})=>o===r.eventType))throw new Error(`Unexpected event type: ${r.eventType}. Expected one of: ${n.map(o=>o.type).join(", ")}`);let i=t.get(r.eventType)??[];await Promise.all(i.map(({eventDefinition:o,handler:p})=>K(o,p,r.payload,{instanceId:r.instanceId,identity:r.identity})))},apps:{AppInstalled:L("AppInstalled")(),AppRemoved:L("AppRemoved")()}};return{initModule(r){return n=>{let i=t.get(r.type)??[];i.push({eventDefinition:r,handler:n}),t.set(r.type,i),s.emit("registered",r)}},client:a}}var Q=e=>e.__type==="service-plugin-definition";function V(e){let t=new Map,s=I(),a={...s,getRegisteredServicePlugins:()=>t,async parseJWT(r){if(!e.decodeJWT)throw new Error("decodeJWT is not supported by the authentication strategy");let{decoded:n,valid:i}=await e.decodeJWT(r,!0);if(!i)throw new Error("JWT is not valid");if(typeof n.data!="object"||n.data===null||!("metadata"in n.data)||typeof n.data.metadata!="object"||n.data.metadata===null||!("appExtensionType"in n.data.metadata)||typeof n.data.metadata.appExtensionType!="string")throw new Error("Unexpected JWT data: expected object with metadata.appExtensionType string");return n.data},async process(r){let n=await this.parseJWT(r.body);return this.executeHandler(n,r.url)},async parseRequest(r){let n=await r.text();return this.parseJWT(n)},async processRequest(r){let n=r.url,i=await r.text();try{let o=await this.process({url:n,body:i});return Response.json(o)}catch(o){if(o.errorType==="SPI"&&o.applicationCode&&o.httpCode)return Response.json({applicationError:{code:o.applicationCode,data:o.data}},{status:o.httpCode});throw o}},async executeHandler(r,n){let i=r.metadata.appExtensionType.toLowerCase(),o=t.get(i)??[];if(o.length===0)throw new Error(`No service plugin implementations found for component type ${i}`);if(o.length>1)throw new Error(`Multiple service plugin implementations found for component type ${i}. This is currently not supported`);let{implementation:p,servicePluginDefinition:l}=o[0],c=l.methods.find(y=>n.endsWith(y.primaryHttpMappingPath));if(!c)throw new Error("Unexpect request: request url did not match any method: "+n);let h=p[c.name];if(!h)throw new Error(`Got request for service plugin method ${c.name} but no implementation was provided. Available methods: ${Object.keys(p).join(", ")}`);return c.transformations.toREST(await h(c.transformations.fromREST(r)))}};return{initModule(r){return n=>{let i=t.get(r.componentType.toLowerCase())??[];i.push({servicePluginDefinition:r,implementation:n}),t.set(r.componentType.toLowerCase(),i),s.emit("registered",r)}},client:a}}var w="X-Wix-Consistent";function ze(e){let t=e.headers||{Authorization:""},s=e.auth||{getAuthHeaders:d=>Promise.resolve({headers:{}})},a=s.getAuthHeaders.bind(void 0,e.host);s.getAuthHeaders=a;let r=async(d,u)=>{let g=await a(),f={...u?.headers??{},...g.headers,...e.host?.essentials?.passThroughHeaders,...t[w]?{[w]:t[w]}:{}},E=e.host?.getErrorHandler?.();try{if(typeof d=="string"||d instanceof URL){let m=await fetch(d,{...u,headers:f});E?.handleError(m,{requestOptions:{url:d.toString(),method:u?.method}});let T=S(m);return T&&(t[w]=T),m}else{for(let[H,U]of Object.entries(f))typeof U=="string"&&d.headers.set(H,U);let m=await fetch(d,u);E?.handleError(m,{requestOptions:{url:d.url,method:u?.method}});let T=S(m);return T&&(t[w]=T),m}}catch(m){throw E?.handleError(m,{requestOptions:{url:typeof d=="string"||d instanceof URL?d.toString():d.url,method:u?.method}}),m}},{client:n,initModule:i}=V(s),{client:o,initModule:p}=z(s),l=async(d,u)=>{let g=await a(),f=O(u),E=await fetch(d,{...u,headers:{...f,...t,...g?.headers,...u?.headers,...e.host?.essentials?.passThroughHeaders,...t[w]?{[w]:t[w]}:{}}}),m=S(E);return m&&(t[w]=m),E},c=(d,u)=>{if(Y(d))return p(d);if(Q(d))return i(d);if(D(d)&&e.host)return F(d,e.host);if(typeof d=="function"){if("__type"in d&&d.__type===M)return d;let g=e.host?.apiBaseUrl??x,f=e.useCDN===void 0?e.auth?.shouldUseCDN:e.useCDN;return X(A(()=>j(d))?q(d):d,u??{},l,e.host?.getErrorHandler?.(),(E,m)=>{let T=new URL(E,`https://${g}`);return T.host=g,T.protocol="https",l(T.toString(),m)},s.getActiveToken,{HTTPHost:g},e.host?.name,f)}else return J(d)?Object.fromEntries(Object.entries(d).map(([g,f])=>[g,c(f,d[N])])):d},h=d=>{for(let u in d)t[u]=d[u]};return{...e.modules?c(e.modules):{},auth:s,setHeaders:h,use:c,enableContext(d,u={elevated:!1}){d==="global"?globalThis.__wix_context__!=null?u.elevated?globalThis.__wix_context__.elevatedClient=this:globalThis.__wix_context__.client=this:u.elevated?globalThis.__wix_context__={elevatedClient:this}:globalThis.__wix_context__={client:this}:u.elevated?Z.elevatedClient=this:Z.client=this},fetch:(d,u)=>{let g=e.host?.apiBaseUrl??x,f=new URL(d,`https://${g}`);return f.host=g,f.protocol="https",l(f.toString(),u)},fetchWithAuth:r,async graphql(d,u,g={apiVersion:"alpha"}){let f=e?.host?.apiBaseUrl??x,E=await l(`https://${f}/graphql/${g.apiVersion}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:d,variables:u})});if(E.status!==200)throw new v(`GraphQL request failed with status ${E.status}`,E);let{data:m,errors:T}=await E.json();return{data:m??{},errors:T}},webhooks:o,servicePlugins:n}}function S(e){return e.headers?.get(w)??e.headers?.get(w.toLowerCase())}export{ze as a};
2
+ //# sourceMappingURL=chunk-RHDUKNAJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/@wix/sdk/build/wixClient.js","../../../node_modules/@wix/sdk/build/ambassador-modules.js","../../../node_modules/@wix/sdk/build/common.js","../../../node_modules/@wix/sdk/build/fetch-error.js","../../../node_modules/@wix/sdk/build/helpers.js","../../../node_modules/@wix/sdk/build/host-modules.js","../../../node_modules/@wix/sdk/build/bi/biHeaderGenerator.js","../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/utils.js","../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/transform-error.js","../../../node_modules/@wix/sdk/build/rest-modules.js","../../../node_modules/@wix/sdk/build/event-handlers-modules.js","../../../node_modules/@wix/sdk/build/nanoevents.js","../../../node_modules/@wix/sdk/build/service-plugin-modules.js"],"sourcesContent":["import { wixContext } from '@wix/sdk-context';\nimport { SERVICE_PLUGIN_ERROR_TYPE, } from '@wix/sdk-types';\nimport { isAmbassadorModule, toHTTPModule } from './ambassador-modules.js';\nimport { DEFAULT_API_URL, PUBLIC_METADATA_KEY } from './common.js';\nimport { FetchErrorResponse } from './fetch-error.js';\nimport { getDefaultContentHeader, isObject } from './helpers.js';\nimport { buildHostModule, isHostModule } from './host-modules.js';\nimport { buildRESTDescriptor } from './rest-modules.js';\nimport { eventHandlersModules, isEventHandlerModule, } from './event-handlers-modules.js';\nimport { isServicePluginModule, servicePluginsModules, } from './service-plugin-modules.js';\nimport { runWithoutContext } from '@wix/sdk-runtime/context';\nexport const X_WIX_CONSISTENT_HEADER = 'X-Wix-Consistent';\nexport function createClient(config) {\n const _headers = config.headers || { Authorization: '' };\n const authStrategy = config.auth ||\n {\n getAuthHeaders: (_) => Promise.resolve({ headers: {} }),\n };\n const boundGetAuthHeaders = authStrategy.getAuthHeaders.bind(undefined, config.host);\n authStrategy.getAuthHeaders = boundGetAuthHeaders;\n const fetchWithAuth = async (urlOrRequest, requestInit) => {\n const authHeaders = await boundGetAuthHeaders();\n const headers = {\n ...(requestInit?.headers ?? {}),\n ...authHeaders.headers,\n ...config.host?.essentials?.passThroughHeaders,\n ...(_headers[X_WIX_CONSISTENT_HEADER]\n ? { [X_WIX_CONSISTENT_HEADER]: _headers[X_WIX_CONSISTENT_HEADER] }\n : {}),\n };\n const errorHandler = config.host?.getErrorHandler?.();\n try {\n if (typeof urlOrRequest === 'string' || urlOrRequest instanceof URL) {\n const response = await fetch(urlOrRequest, {\n ...requestInit,\n headers,\n });\n errorHandler?.handleError(response, {\n requestOptions: {\n url: urlOrRequest.toString(),\n method: requestInit?.method,\n },\n });\n const consistentHeader = findConsistentHeader(response);\n if (consistentHeader) {\n _headers[X_WIX_CONSISTENT_HEADER] = consistentHeader;\n }\n return response;\n }\n else {\n for (const [k, v] of Object.entries(headers)) {\n if (typeof v === 'string') {\n urlOrRequest.headers.set(k, v);\n }\n }\n const response = await fetch(urlOrRequest, requestInit);\n errorHandler?.handleError(response, {\n requestOptions: {\n url: urlOrRequest.url,\n method: requestInit?.method,\n },\n });\n const consistentHeader = findConsistentHeader(response);\n if (consistentHeader) {\n _headers[X_WIX_CONSISTENT_HEADER] = consistentHeader;\n }\n return response;\n }\n }\n catch (e) {\n errorHandler?.handleError(e, {\n requestOptions: {\n url: typeof urlOrRequest === 'string' || urlOrRequest instanceof URL\n ? urlOrRequest.toString()\n : urlOrRequest.url,\n method: requestInit?.method,\n },\n });\n throw e;\n }\n };\n const { client: servicePluginsClient, initModule: initServicePluginModule } = servicePluginsModules(authStrategy);\n const { client: eventHandlersClient, initModule: initEventHandlerModule } = eventHandlersModules(authStrategy);\n const boundFetch = async (url, options) => {\n const authHeaders = await boundGetAuthHeaders();\n const defaultContentTypeHeader = getDefaultContentHeader(options);\n const response = await fetch(url, {\n ...options,\n headers: {\n ...defaultContentTypeHeader,\n ..._headers,\n ...authHeaders?.headers,\n ...options?.headers,\n ...config.host?.essentials?.passThroughHeaders,\n // Ensure consistent header always takes precedence\n ...(_headers[X_WIX_CONSISTENT_HEADER]\n ? { [X_WIX_CONSISTENT_HEADER]: _headers[X_WIX_CONSISTENT_HEADER] }\n : {}),\n },\n });\n const consistentHeader = findConsistentHeader(response);\n if (consistentHeader) {\n _headers[X_WIX_CONSISTENT_HEADER] = consistentHeader;\n }\n return response;\n };\n // This is typed as `any` because when trying to properly type it as defined\n // on the WixClient, typescript starts failing with `Type instantiation is\n // excessively deep and possibly infinite.`\n const use = (modules, metadata) => {\n if (isEventHandlerModule(modules)) {\n return initEventHandlerModule(modules);\n }\n else if (isServicePluginModule(modules)) {\n return initServicePluginModule(modules);\n }\n else if (isHostModule(modules) && config.host) {\n return buildHostModule(modules, config.host);\n }\n else if (typeof modules === 'function') {\n // The generated namespaces all have the error classes on them and\n // a class is also a function, so we need to explicitly ignore these\n // error classes using a static field that exists on them.\n if ('__type' in modules && modules.__type === SERVICE_PLUGIN_ERROR_TYPE) {\n return modules;\n }\n const apiBaseUrl = config.host?.apiBaseUrl ?? DEFAULT_API_URL;\n const shouldUseCDN = config.useCDN === undefined ? config.auth?.shouldUseCDN : config.useCDN;\n return buildRESTDescriptor(runWithoutContext(() => isAmbassadorModule(modules))\n ? toHTTPModule(modules)\n : modules, metadata ?? {}, boundFetch, config.host?.getErrorHandler?.(), (relativeUrl, fetchOptions) => {\n const finalUrl = new URL(relativeUrl, `https://${apiBaseUrl}`);\n finalUrl.host = apiBaseUrl;\n finalUrl.protocol = 'https';\n return boundFetch(finalUrl.toString(), fetchOptions);\n }, authStrategy.getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name, shouldUseCDN);\n }\n else if (isObject(modules)) {\n return Object.fromEntries(Object.entries(modules).map(([key, value]) => {\n return [key, use(value, modules[PUBLIC_METADATA_KEY])];\n }));\n }\n else {\n return modules;\n }\n };\n const setHeaders = (headers) => {\n for (const k in headers) {\n _headers[k] = headers[k];\n }\n };\n const wrappedModules = config.modules\n ? use(config.modules)\n : {};\n return {\n ...wrappedModules,\n auth: authStrategy,\n setHeaders,\n use,\n enableContext(contextType, opts = { elevated: false }) {\n if (contextType === 'global') {\n if (globalThis.__wix_context__ != null) {\n if (opts.elevated) {\n globalThis.__wix_context__.elevatedClient = this;\n }\n else {\n globalThis.__wix_context__.client = this;\n }\n }\n else {\n if (opts.elevated) {\n globalThis.__wix_context__ = { elevatedClient: this };\n }\n else {\n globalThis.__wix_context__ = { client: this };\n }\n }\n }\n else {\n if (opts.elevated) {\n wixContext.elevatedClient = this;\n }\n else {\n wixContext.client = this;\n }\n }\n },\n /**\n * @param relativeUrl The URL to fetch relative to the API base URL\n * @param options The fetch options\n * @returns The fetch Response object\n * @deprecated Use `fetchWithAuth` instead\n */\n fetch: (relativeUrl, options) => {\n const apiBaseUrl = config.host?.apiBaseUrl ?? DEFAULT_API_URL;\n const finalUrl = new URL(relativeUrl, `https://${apiBaseUrl}`);\n finalUrl.host = apiBaseUrl;\n finalUrl.protocol = 'https';\n return boundFetch(finalUrl.toString(), options);\n },\n fetchWithAuth,\n async graphql(query, variables, opts = {\n apiVersion: 'alpha',\n }) {\n const apiBaseUrl = config?.host?.apiBaseUrl ?? DEFAULT_API_URL;\n const res = await boundFetch(`https://${apiBaseUrl}/graphql/${opts.apiVersion}`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ query, variables }),\n });\n if (res.status !== 200) {\n throw new FetchErrorResponse(`GraphQL request failed with status ${res.status}`, res);\n }\n const { data, errors } = await res.json();\n return { data: data ?? {}, errors };\n },\n webhooks: eventHandlersClient,\n servicePlugins: servicePluginsClient,\n };\n}\nfunction findConsistentHeader(response) {\n return (response.headers?.get(X_WIX_CONSISTENT_HEADER) ??\n response.headers?.get(X_WIX_CONSISTENT_HEADER.toLowerCase()));\n}\n","const parseMethod = (method) => {\n switch (method) {\n case 'get':\n case 'GET':\n return 'GET';\n case 'post':\n case 'POST':\n return 'POST';\n case 'put':\n case 'PUT':\n return 'PUT';\n case 'delete':\n case 'DELETE':\n return 'DELETE';\n case 'patch':\n case 'PATCH':\n return 'PATCH';\n case 'head':\n case 'HEAD':\n return 'HEAD';\n case 'options':\n case 'OPTIONS':\n return 'OPTIONS';\n default:\n throw new Error(`Unknown method: ${method}`);\n }\n};\nexport const toHTTPModule = (factory) => (httpClient) => async (payload) => {\n let requestOptions;\n const HTTPFactory = (context) => {\n requestOptions = factory(payload)(context);\n if (requestOptions.url === undefined) {\n throw new Error('Url was not successfully created for this request, please reach out to support channels for assistance.');\n }\n const { method, url, params } = requestOptions;\n return {\n ...requestOptions,\n method: parseMethod(method),\n url,\n data: requestOptions.data,\n params,\n };\n };\n try {\n const response = await httpClient.request(HTTPFactory);\n if (requestOptions === undefined) {\n throw new Error('Request options were not created for this request, please reach out to support channels for assistance.');\n }\n const transformations = Array.isArray(requestOptions.transformResponse)\n ? requestOptions.transformResponse\n : [requestOptions.transformResponse];\n /**\n * Based on Axios implementation:\n * https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/lib/core/transformData.js#L22\n */\n let data = response.data;\n transformations.forEach((transform) => {\n if (transform) {\n data = transform(response.data, response.headers);\n }\n });\n return data;\n }\n catch (e) {\n if (typeof e === 'object' &&\n e !== null &&\n 'response' in e &&\n typeof e.response === 'object' &&\n e.response !== null &&\n 'data' in e.response) {\n throw e.response.data;\n }\n throw e;\n }\n};\n/*\n * Because of issues with tree-shaking, we cant really put static parameter on module.\n * We still have check for __isAmbassador for backward compatibility\n */\nexport const isAmbassadorModule = (module) => {\n if (module.__isAmbassador) {\n return true;\n }\n const fn = module();\n return Boolean(fn.__isAmbassador);\n};\n","export const PUBLIC_METADATA_KEY = '__metadata';\nexport const DEFAULT_API_URL = 'www.wixapis.com';\nexport const DEFAULT_EDGE_API_URL = 'edge.wixapis.com';\nexport const FORCE_WRITE_API_URLS = ['/ecom/v1/carts/current'];\n","export class FetchErrorResponse extends Error {\n message;\n response;\n constructor(message, response) {\n super(message);\n this.message = message;\n this.response = response;\n }\n async details() {\n const dataError = await this.response.json();\n return errorBuilder(this.response.status, dataError?.message, dataError?.details, {\n requestId: this.response.headers.get('X-Wix-Request-Id'),\n details: dataError,\n });\n }\n}\nconst errorBuilder = (code, description, details, data) => {\n return {\n details: {\n ...(!details?.validationError && {\n applicationError: {\n description,\n code,\n data,\n },\n }),\n ...details,\n },\n message: description,\n requestId: data?.requestId,\n };\n};\n","// we follow a simplified version of the axios convention\n// https://github.com/axios/axios/blob/649d739288c8e2c55829ac60e2345a0f3439c730/lib/defaults/index.js#L65\nexport const getDefaultContentHeader = (options) => {\n if (options?.method &&\n ['post', 'put', 'patch'].includes(options.method.toLocaleLowerCase()) &&\n options.body) {\n return { 'Content-Type': 'application/json' };\n }\n return {};\n};\nexport const isObject = (val) => val && typeof val === 'object' && !Array.isArray(val);\nexport function parsePublicKeyIfEncoded(publicKey) {\n if (publicKey.includes('\\n') || publicKey.includes('\\r')) {\n // publicKey is multi-line string, can be used as is\n return publicKey.trim();\n }\n else {\n // publicKey is base64 encoded\n return typeof atob !== 'undefined'\n ? atob(publicKey)\n : Buffer.from(publicKey, 'base64').toString('utf-8');\n }\n}\n","export const isHostModule = (val) => val.__type === 'host';\nexport function buildHostModule(val, host) {\n return val.create(host);\n}\n","export const WixBIHeaderName = 'x-wix-bi-gateway';\nexport function biHeaderGenerator(apiMetadata, publicMetadata, environment) {\n return {\n [WixBIHeaderName]: objectToKeyValue({\n environment: `js-sdk${environment ? `-${environment}` : ``}`,\n 'package-name': apiMetadata.packageName ?? publicMetadata?.PACKAGE_NAME,\n 'method-fqn': apiMetadata.methodFqn,\n entity: apiMetadata.entityFqdn,\n }),\n };\n}\nfunction objectToKeyValue(input) {\n return Object.entries(input)\n .filter(([_, value]) => Boolean(value))\n .map(([key, value]) => `${key}=${value}`)\n .join(',');\n}\n","import { WIX_PROTOCOL } from './constants.js';\nexport function alignIfLegacy(url, type) {\n const { protocol } = new URL(url);\n return protocol === `${type}:` ? `${WIX_PROTOCOL}${url}` : url;\n}\nexport function removeUndefinedKeys(obj) {\n return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined));\n}\nexport function constantCase(input) {\n return split(input)\n .map((part) => part.toLocaleUpperCase())\n .join('_');\n}\nconst SPLIT_LOWER_UPPER_RE = /([\\p{Ll}\\d])(\\p{Lu})/gu;\nconst SPLIT_UPPER_UPPER_RE = /(\\p{Lu})([\\p{Lu}][\\p{Ll}])/gu;\nconst SPLIT_REPLACE_VALUE = '$1\\0$2';\nconst DEFAULT_STRIP_REGEXP = /[^\\p{L}\\d]+/giu;\nexport function split(value) {\n let result = value.trim();\n result = result\n .replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE)\n .replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);\n result = result.replace(DEFAULT_STRIP_REGEXP, '\\0');\n let start = 0;\n let end = result.length;\n // Trim the delimiter from around the output string.\n while (result.charAt(start) === '\\0') {\n start++;\n }\n if (start === end) {\n return [];\n }\n while (result.charAt(end - 1) === '\\0') {\n end--;\n }\n return result.slice(start, end).split(/\\0/g);\n}\n","import { constantCase } from './utils.js';\nconst isValidationError = (httpClientError) => 'validationError' in (httpClientError.response?.data?.details ?? {});\nconst isApplicationError = (httpClientError) => 'applicationError' in\n (httpClientError.response?.data?.details ?? {});\nconst isClientError = (httpClientError) => (httpClientError.response?.status ?? -1) >= 400 &&\n (httpClientError.response?.status ?? -1) < 500;\nexport function transformError(httpClientError, pathsToArguments = {\n explicitPathsToArguments: {},\n spreadPathsToArguments: {},\n singleArgumentUnchanged: false,\n}, argumentNames = []) {\n if (typeof httpClientError !== 'object' || httpClientError === null) {\n throw httpClientError;\n }\n if (isValidationError(httpClientError)) {\n return buildValidationError(httpClientError, pathsToArguments, argumentNames);\n }\n if (isApplicationError(httpClientError)) {\n return buildApplicationError(httpClientError);\n }\n if (isClientError(httpClientError)) {\n const status = httpClientError.response?.status;\n const statusText = httpClientError.response?.statusText ?? 'UNKNOWN';\n const message = httpClientError.response?.data?.message ?? statusText;\n const details = {\n applicationError: {\n description: statusText,\n code: constantCase(statusText),\n data: {},\n },\n requestId: httpClientError.requestId,\n };\n return wrapError(httpClientError, {\n message: JSON.stringify({\n message,\n details,\n }, null, 2),\n extraProperties: {\n details,\n status,\n },\n });\n }\n return buildSystemError(httpClientError);\n}\nconst buildValidationError = (httpClientError, pathsToArguments, argumentNames) => {\n const validationErrorResponse = httpClientError.response\n ?.data;\n const requestId = httpClientError.requestId;\n const { fieldViolations } = validationErrorResponse.details.validationError;\n const transformedFieldViolations = violationsWithRenamedFields(pathsToArguments, fieldViolations, argumentNames)?.sort((a, b) => (a.field < b.field ? -1 : 1));\n const message = `INVALID_ARGUMENT: ${transformedFieldViolations\n ?.map(({ field, description }) => `\"${field}\" ${description}`)\n ?.join(', ')}`;\n const details = {\n validationError: { fieldViolations: transformedFieldViolations },\n requestId,\n };\n return wrapError(httpClientError, {\n message: JSON.stringify({ message, details }, null, 2),\n extraProperties: {\n details,\n status: httpClientError.response?.status,\n requestId,\n },\n });\n};\nconst wrapError = (baseError, { message, extraProperties, }) => {\n return Object.assign(baseError, {\n ...extraProperties,\n message,\n });\n};\nconst buildApplicationError = (httpClientError) => {\n const status = httpClientError.response?.status;\n const statusText = httpClientError.response?.statusText ?? 'UNKNOWN';\n const message = httpClientError.response?.data?.message ?? statusText;\n const description = httpClientError.response?.data?.details?.applicationError?.description ??\n statusText;\n const code = httpClientError.response?.data?.details?.applicationError?.code ??\n constantCase(statusText);\n const data = httpClientError.response?.data?.details?.applicationError?.data ?? {};\n const combinedMessage = message === description ? message : `${message}: ${description}`;\n const details = {\n applicationError: {\n description,\n code,\n data,\n },\n requestId: httpClientError.requestId,\n };\n return wrapError(httpClientError, {\n message: JSON.stringify({ message: combinedMessage, details }, null, 2),\n extraProperties: {\n details,\n status,\n requestId: httpClientError.requestId,\n },\n });\n};\nconst buildSystemError = (httpClientError) => {\n const message = httpClientError.requestId\n ? `System error occurred, request-id: ${httpClientError.requestId}`\n : `System error occurred: ${JSON.stringify(httpClientError)}`;\n return wrapError(httpClientError, {\n message,\n extraProperties: {\n requestId: httpClientError.requestId,\n status: httpClientError.response?.status,\n code: constantCase(httpClientError.response?.statusText ?? 'UNKNOWN'),\n ...(!httpClientError.response && {\n runtimeError: httpClientError,\n }),\n },\n });\n};\nconst violationsWithRenamedFields = ({ spreadPathsToArguments, explicitPathsToArguments, singleArgumentUnchanged, }, fieldViolations, argumentNames) => {\n const allPathsToArguments = {\n ...spreadPathsToArguments,\n ...explicitPathsToArguments,\n };\n const allPathsToArgumentsKeys = Object.keys(allPathsToArguments);\n return fieldViolations\n ?.filter((fieldViolation) => {\n // In some cases, the violations error will include both some.nested and some.nested.path,\n // so we'll pick the more specific one if it's covered by the paths in the transformation.\n const containedInAMoreSpecificViolationField = fieldViolations.some((anotherViolation) => anotherViolation.field.length > fieldViolation.field.length &&\n anotherViolation.field.startsWith(fieldViolation.field) &&\n allPathsToArgumentsKeys.includes(anotherViolation.field));\n return !containedInAMoreSpecificViolationField;\n })\n .map((fieldViolation) => {\n // This means we've got some.nested.field in the violation,\n // matched against { some: { nested: { field: $[0].a.b.c } } } in the transformation.\n // some.nested.field is replaced entirely with $[0].a.b.c, with $[0] replaced with the name of argument 0\n const exactMatchArgumentExpression = explicitPathsToArguments[fieldViolation.field];\n if (exactMatchArgumentExpression) {\n return {\n ...fieldViolation,\n field: withRenamedArgument(exactMatchArgumentExpression, argumentNames),\n };\n }\n const longestPartialPathMatch = allPathsToArgumentsKeys\n ?.sort((a, b) => b.length - a.length)\n ?.find((path) => fieldViolation.field.startsWith(path));\n if (longestPartialPathMatch) {\n // This means we've got some.nested.field in the violation,\n // matched against { some: { nested: { *: $[0].a.b.c } } } in the transformation.\n // Only the prefix some.nested is replaced with $[0].a.b.c, with $[0] replaced with the name of argument 0\n // This can also happen in the case where the #wrap function is used.\n const partialMatchArgumentExpression = allPathsToArguments[longestPartialPathMatch];\n if (partialMatchArgumentExpression) {\n return {\n ...fieldViolation,\n field: fieldViolation.field.replace(longestPartialPathMatch, withRenamedArgument(partialMatchArgumentExpression, argumentNames)),\n };\n }\n }\n if (singleArgumentUnchanged) {\n return {\n ...fieldViolation,\n field: `${argumentNames[0]}.${fieldViolation.field}`,\n };\n }\n return fieldViolation;\n });\n};\nconst withRenamedArgument = (fieldValue, argumentNames) => {\n const argIndex = getArgumentIndex(fieldValue);\n if (argIndex !== null && typeof argIndex !== 'undefined') {\n return fieldValue.replace(`$[${argIndex}]`, argumentNames[argIndex]);\n }\n return fieldValue;\n};\nconst getArgumentIndex = (s) => {\n const match = s.match(/\\$\\[(?<argIndex>\\d+)\\]/);\n return match && match.groups && Number(match.groups.argIndex);\n};\n","import { biHeaderGenerator } from './bi/biHeaderGenerator.js';\nimport { DEFAULT_API_URL, DEFAULT_EDGE_API_URL } from './common.js';\nimport { runWithoutContext } from '@wix/sdk-runtime/context';\nimport { transformError } from '@wix/sdk-runtime/transform-error';\nexport function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler, wixAPIFetch, getActiveToken, options, hostName, useCDN) {\n return runWithoutContext(() => origFunc({\n request: async (factory) => {\n const requestOptions = factory({\n host: options?.HTTPHost || DEFAULT_API_URL,\n });\n let request = requestOptions;\n if (request.method === 'GET' &&\n request.fallback?.length &&\n request.params.toString().length > 4000) {\n request = requestOptions.fallback[0];\n }\n const domain = options?.HTTPHost ?? DEFAULT_API_URL;\n let url = `https://${useCDN ? DEFAULT_EDGE_API_URL : domain}${request.url}`;\n if (request.params && request.params.toString()) {\n url += `?${request.params.toString()}`;\n }\n try {\n const biHeader = biHeaderGenerator(requestOptions, publicMetadata, hostName);\n const requestOptionsInit = {\n method: request.method,\n ...(request.data && {\n body: JSON.stringify(request.data),\n }),\n headers: {\n ...biHeader,\n },\n };\n const res = await boundFetch(url, requestOptionsInit);\n if (res.status !== 200) {\n let dataError = null;\n try {\n dataError = await res.json();\n }\n catch (e) {\n //\n }\n const error = errorBuilder(res.status, dataError?.message, dataError?.details, {\n requestId: res.headers.get('X-Wix-Request-Id'),\n details: dataError,\n });\n const transformedError = transformError(error);\n errorHandler?.handleError(transformedError, {\n requestOptions: {\n url: request.url,\n method: request.method,\n entityFqdn: requestOptions.entityFqdn,\n methodFqn: requestOptions.methodFqn,\n },\n });\n throw error;\n }\n const data = await res.json();\n return {\n data,\n headers: res.headers,\n status: res.status,\n statusText: res.statusText,\n };\n }\n catch (e) {\n if (e.message?.includes('fetch is not defined')) {\n console.error('Node.js v18+ is required');\n }\n throw e;\n }\n },\n fetchWithAuth: boundFetch,\n wixAPIFetch,\n getActiveToken,\n }));\n}\nclass SDKError extends Error {\n response;\n requestId;\n constructor(params) {\n super();\n this.response = params.response;\n this.requestId = params.requestId;\n }\n}\nconst errorBuilder = (code, description, details, data) => {\n return new SDKError({\n response: {\n data: {\n details: {\n ...(!details?.validationError && {\n applicationError: {\n description,\n code,\n data,\n },\n }),\n ...details,\n },\n message: description,\n },\n status: code,\n },\n requestId: data?.requestId,\n });\n};\n","import { EventDefinition, } from '@wix/sdk-types';\nimport { createNanoEvents } from './nanoevents.js';\nexport const isEventHandlerModule = (val) => val.__type === 'event-definition';\nexport function buildEventDefinition(eventDefinition, registerHandler) {\n return (handler) => {\n registerHandler(eventDefinition, handler);\n };\n}\nfunction runHandler(eventDefinition, handler, payload, baseEventMetadata) {\n let envelope;\n if (eventDefinition.isDomainEvent) {\n const domainEventPayload = payload;\n const { deletedEvent, actionEvent, createdEvent, updatedEvent, ...domainEventMetadata } = domainEventPayload;\n const metadata = {\n ...baseEventMetadata,\n ...domainEventMetadata,\n };\n if (deletedEvent) {\n if (deletedEvent?.deletedEntity) {\n envelope = {\n entity: deletedEvent?.deletedEntity,\n metadata,\n };\n }\n else {\n envelope = { metadata };\n }\n }\n else if (actionEvent) {\n envelope = {\n data: actionEvent.body,\n metadata,\n };\n }\n else {\n envelope = {\n entity: createdEvent?.entity ?? updatedEvent?.currentEntity,\n metadata,\n };\n }\n }\n else {\n envelope = {\n data: payload,\n metadata: baseEventMetadata,\n };\n }\n const transformFromRESTFn = eventDefinition.transformations ?? ((x) => x);\n return handler(transformFromRESTFn(envelope));\n}\nexport function eventHandlersModules(authStrategy) {\n const eventHandlers = new Map();\n const webhooksEmitter = createNanoEvents();\n const client = {\n ...webhooksEmitter,\n getRegisteredEvents: () => eventHandlers,\n async process(jwt, opts = {\n expectedEvents: [],\n }) {\n const { eventType, identity, instanceId, payload } = await this.parseJWT(jwt);\n const allExpectedEvents = [\n ...opts.expectedEvents,\n ...Array.from(eventHandlers.keys()).map((type) => ({ type })),\n ];\n if (allExpectedEvents.length > 0 &&\n !allExpectedEvents.some(({ type }) => type === eventType)) {\n throw new Error(`Unexpected event type: ${eventType}. Expected one of: ${allExpectedEvents\n .map((x) => x.type)\n .join(', ')}`);\n }\n const handlers = eventHandlers.get(eventType) ?? [];\n await Promise.all(handlers.map(({ eventDefinition, handler }) => runHandler(eventDefinition, handler, payload, {\n instanceId,\n identity,\n })));\n return {\n instanceId,\n eventType,\n payload,\n identity,\n };\n },\n async processRequest(request, opts) {\n const body = await request.text();\n return this.process(body, opts);\n },\n async parseJWT(jwt) {\n if (!authStrategy.decodeJWT) {\n throw new Error('decodeJWT is not supported by the authentication strategy');\n }\n const { decoded, valid } = await authStrategy.decodeJWT(jwt);\n if (!valid) {\n throw new Error('JWT is not valid');\n }\n if (typeof decoded.data !== 'string') {\n throw new Error(`Unexpected type of JWT data: expected string, got ${typeof decoded.data}`);\n }\n const parsedDecoded = JSON.parse(decoded.data);\n const eventType = parsedDecoded.eventType;\n const instanceId = parsedDecoded.instanceId;\n const identity = parsedDecoded.identity\n ? JSON.parse(parsedDecoded.identity)\n : undefined;\n const payload = JSON.parse(parsedDecoded.data);\n return {\n instanceId,\n eventType,\n payload,\n identity,\n };\n },\n async parseRequest(request) {\n const jwt = await request.text();\n return this.parseJWT(jwt);\n },\n async executeHandlers(event) {\n const allExpectedEvents = Array.from(eventHandlers.keys()).map((type) => ({ type }));\n if (allExpectedEvents.length > 0 &&\n !allExpectedEvents.some(({ type }) => type === event.eventType)) {\n throw new Error(`Unexpected event type: ${event.eventType}. Expected one of: ${allExpectedEvents\n .map((x) => x.type)\n .join(', ')}`);\n }\n const handlers = eventHandlers.get(event.eventType) ?? [];\n await Promise.all(handlers.map(({ eventDefinition, handler }) => runHandler(eventDefinition, handler, event.payload, {\n instanceId: event.instanceId,\n identity: event.identity,\n })));\n },\n apps: {\n AppInstalled: EventDefinition('AppInstalled')(),\n AppRemoved: EventDefinition('AppRemoved')(),\n },\n };\n return {\n initModule(eventDefinition) {\n return (handler) => {\n const handlers = eventHandlers.get(eventDefinition.type) ?? [];\n handlers.push({ eventDefinition, handler });\n eventHandlers.set(eventDefinition.type, handlers);\n webhooksEmitter.emit('registered', eventDefinition);\n };\n },\n client,\n };\n}\n","// Inlined from https://github.com/ai/nanoevents/blob/main/index.js\n/**\n * Create event emitter.\n *\n * ```js\n * import { createNanoEvents } from 'nanoevents'\n *\n * class Ticker {\n * constructor() {\n * this.emitter = createNanoEvents()\n * }\n * on(...args) {\n * return this.emitter.on(...args)\n * }\n * tick() {\n * this.emitter.emit('tick')\n * }\n * }\n * ```\n * @returns Event emitter.\n */\nexport function createNanoEvents() {\n return {\n emit(event, ...args) {\n for (let i = 0, callbacks = this.events[event] || [], length = callbacks.length; i < length; i++) {\n callbacks[i](...args);\n }\n },\n events: {},\n on(event, cb) {\n (this.events[event] ||= []).push(cb);\n return () => {\n this.events[event] = this.events[event]?.filter((i) => cb !== i);\n };\n },\n };\n}\n","import { createNanoEvents } from './nanoevents.js';\nexport const isServicePluginModule = (val) => val.__type === 'service-plugin-definition';\nexport function servicePluginsModules(authStrategy) {\n const servicePluginsImplementations = new Map();\n const servicePluginsEmitter = createNanoEvents();\n const client = {\n ...servicePluginsEmitter,\n getRegisteredServicePlugins: () => servicePluginsImplementations,\n async parseJWT(jwt) {\n if (!authStrategy.decodeJWT) {\n throw new Error('decodeJWT is not supported by the authentication strategy');\n }\n const { decoded, valid } = await authStrategy.decodeJWT(jwt, true);\n if (!valid) {\n throw new Error('JWT is not valid');\n }\n if (typeof decoded.data !== 'object' ||\n decoded.data === null ||\n !('metadata' in decoded.data) ||\n typeof decoded.data.metadata !== 'object' ||\n decoded.data.metadata === null ||\n !('appExtensionType' in decoded.data.metadata) ||\n typeof decoded.data.metadata.appExtensionType !== 'string') {\n throw new Error('Unexpected JWT data: expected object with metadata.appExtensionType string');\n }\n return decoded.data;\n },\n async process(request) {\n const servicePluginRequest = await this.parseJWT(request.body);\n return this.executeHandler(servicePluginRequest, request.url);\n },\n async parseRequest(request) {\n const body = await request.text();\n return this.parseJWT(body);\n },\n async processRequest(request) {\n const url = request.url;\n const body = await request.text();\n try {\n const implMethodResult = await this.process({ url, body });\n return Response.json(implMethodResult);\n }\n catch (err) {\n if (err.errorType === 'SPI' && err.applicationCode && err.httpCode) {\n return Response.json({ applicationError: { code: err.applicationCode, data: err.data } }, { status: err.httpCode });\n }\n throw err;\n }\n },\n async executeHandler(servicePluginRequest, url) {\n const componentType = servicePluginRequest.metadata.appExtensionType.toLowerCase();\n const implementations = servicePluginsImplementations.get(componentType) ?? [];\n if (implementations.length === 0) {\n throw new Error(`No service plugin implementations found for component type ${componentType}`);\n }\n else if (implementations.length > 1) {\n throw new Error(`Multiple service plugin implementations found for component type ${componentType}. This is currently not supported`);\n }\n const { implementation: impl, servicePluginDefinition } = implementations[0];\n const method = servicePluginDefinition.methods.find((m) => url.endsWith(m.primaryHttpMappingPath));\n if (!method) {\n throw new Error('Unexpect request: request url did not match any method: ' + url);\n }\n const implMethod = impl[method.name];\n if (!implMethod) {\n throw new Error(`Got request for service plugin method ${method.name} but no implementation was provided. Available methods: ${Object.keys(impl).join(', ')}`);\n }\n return method.transformations.toREST(await implMethod(method.transformations.fromREST(servicePluginRequest)));\n },\n };\n return {\n initModule(servicePluginDefinition) {\n return (implementation) => {\n const implementations = servicePluginsImplementations.get(servicePluginDefinition.componentType.toLowerCase()) ?? [];\n implementations.push({ servicePluginDefinition, implementation });\n servicePluginsImplementations.set(servicePluginDefinition.componentType.toLowerCase(), implementations);\n servicePluginsEmit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AAME,GAAQ,CAAC,EAAG,OAAAC,CAAO,CACtC,EACA,SAAUvC,EACV,eAAgBH,CACpB,CACJ,CACA,SAASJ,EAAqBF,EAAU,CACpC,OAAQA,EAAS,SAAS,IAAIb,CAAuB,GACjDa,EAAS,SAAS,IAAIb,EAAwB,YAAY,CAAC,CACnE","names":["init_browser","wixContext","parseMethod","method","toHTTPModule","factory","httpClient","payload","requestOptions","HTTPFactory","context","url","params","response","transformations","data","transform","e","isAmbassadorModule","module","PUBLIC_METADATA_KEY","DEFAULT_API_URL","DEFAULT_EDGE_API_URL","FetchErrorResponse","message","response","__publicField","dataError","errorBuilder","code","description","details","data","getDefaultContentHeader","options","isObject","val","isHostModule","val","buildHostModule","host","WixBIHeaderName","biHeaderGenerator","apiMetadata","publicMetadata","environment","objectToKeyValue","input","_","value","key","constantCase","input","split","part","SPLIT_LOWER_UPPER_RE","SPLIT_UPPER_UPPER_RE","SPLIT_REPLACE_VALUE","DEFAULT_STRIP_REGEXP","value","result","start","end","isValidationError","httpClientError","isApplicationError","isClientError","transformError","pathsToArguments","argumentNames","buildValidationError","buildApplicationError","status","statusText","message","details","constantCase","wrapError","buildSystemError","validationErrorResponse","requestId","fieldViolations","transformedFieldViolations","violationsWithRenamedFields","a","b","field","description","baseError","extraProperties","code","data","combinedMessage","spreadPathsToArguments","explicitPathsToArguments","singleArgumentUnchanged","allPathsToArguments","allPathsToArgumentsKeys","fieldViolation","anotherViolation","exactMatchArgumentExpression","withRenamedArgument","longestPartialPathMatch","path","partialMatchArgumentExpression","fieldValue","argIndex","getArgumentIndex","s","match","buildRESTDescriptor","origFunc","publicMetadata","boundFetch","errorHandler","wixAPIFetch","getActiveToken","options","hostName","useCDN","runWithoutContext","factory","requestOptions","DEFAULT_API_URL","request","domain","url","DEFAULT_EDGE_API_URL","biHeader","biHeaderGenerator","requestOptionsInit","res","dataError","error","errorBuilder","transformedError","transformError","e","SDKError","params","__publicField","code","description","details","data","init_browser","createNanoEvents","event","args","i","callbacks","length","cb","isEventHandlerModule","val","runHandler","eventDefinition","handler","payload","baseEventMetadata","envelope","domainEventPayload","deletedEvent","actionEvent","createdEvent","updatedEvent","domainEventMetadata","metadata","transformFromRESTFn","x","eventHandlersModules","authStrategy","eventHandlers","webhooksEmitter","createNanoEvents","client","jwt","opts","eventType","identity","instanceId","allExpectedEvents","type","handlers","request","body","decoded","valid","parsedDecoded","event","EventDefinition","isServicePluginModule","val","servicePluginsModules","authStrategy","servicePluginsImplementations","servicePluginsEmitter","createNanoEvents","client","jwt","decoded","valid","request","servicePluginRequest","body","url","implMethodResult","err","componentType","implementations","impl","servicePluginDefinition","method","m","implMethod","implementation","X_WIX_CONSISTENT_HEADER","createClient","config","_headers","authStrategy","_","boundGetAuthHeaders","fetchWithAuth","urlOrRequest","requestInit","authHeaders","headers","errorHandler","response","consistentHeader","findConsistentHeader","k","v","e","servicePluginsClient","initServicePluginModule","servicePluginsModules","eventHandlersClient","initEventHandlerModule","eventHandlersModules","boundFetch","url","options","defaultContentTypeHeader","getDefaultContentHeader","use","modules","metadata","isEventHandlerModule","isServicePluginModule","isHostModule","buildHostModule","SERVICE_PLUGIN_ERROR_TYPE","apiBaseUrl","DEFAULT_API_URL","shouldUseCDN","buildRESTDescriptor","runWithoutContext","isAmbassadorModule","toHTTPModule","relativeUrl","fetchOptions","finalUrl","isObject","key","value","PUBLIC_METADATA_KEY","setHeaders","contextType","opts","wixContext","query","variables","res","FetchErrorResponse","data","errors"]}
@@ -1,2 +1,2 @@
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};
1
+ import{a as $,b as G}from"./chunk-J7RIIVO6.js";import{a as J}from"./chunk-RHDUKNAJ.js";import"./chunk-J3SVE4GM.js";import"./chunk-7EYXEF6M.js";import"./chunk-SBZEOPXX.js";function A(){return A=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},A.apply(null,arguments)}import Te,{useEffect as We,useState as xe}from"react";function b(e){"@babel/helpers - typeof";return b=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},b(e)}function Q(e,t){if(b(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(b(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function X(e){var t=Q(e,"string");return b(t)=="symbol"?t:t+""}function Y(e,t,n){return(t=X(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var M=class extends Error{constructor(t){let{message:n,code:r}=t;super(n),Y(this,"code",void 0),this.message=n,this.code=r}};var Z=()=>{let e=s=>{let{channel:o}=s;return function(){let d=o.showToast(...arguments);return{remove:()=>Promise.resolve(d).then(h=>h.remove())}}},t=s=>{let{channel:o}=s;return function(){let d=o.observeState(...arguments);return{disconnect:()=>Promise.resolve(d).then(h=>h.disconnect())}}};return{showToast:e,observeState:t,navigate:s=>{let{channel:o}=s;return function(){return o.navigate(...arguments)}},navigateBack:s=>{let{channel:o}=s;return()=>o.navigateBack()},openModal:s=>{let{channel:o}=s;return(d,g)=>{let[h,k]=typeof d=="string"?[d,g]:[d.modalId,d.params],S=o.openModal(h,k);return{modalClosed:Promise.resolve(S).then(w=>w.modalClosed)}}},closeModal:s=>{let{channel:o}=s;return d=>{if(d===void 0)return o.closeModal();let g=JSON.parse(JSON.stringify(d));return o.closeModal(g)}},getAccessToken:s=>{let{channel:o}=s;return()=>o.getAccessToken()},getPageUrl:s=>{let{channel:o}=s;return function(){return o.getPageUrl(...arguments)}},openMediaManager:s=>{let{channel:o}=s;return function(){return o.openMediaManager(...arguments)}},addSitePlugin:s=>{let{channel:o}=s;return(d,g)=>{let h="802c76e4-b381-4bb3-9152-96acabbf3194",k=g?.placement||{},S=o.openModal(h,{...k,pluginId:d,action:"populate"});return Promise.resolve(S).then(w=>w.modalClosed).then(w=>{if(w?.type===void 0)throw new M({message:"Aborted by user",code:3006});if(w?.type==="ERROR")throw new M(w.data.error)})}},onBeforeUnload:s=>{let{channel:o}=s;return function(){return o.onBeforeUnload(...arguments)}},setPageTitle:s=>{let{channel:o}=s;return d=>o.setPageTitle(d)},getLanguage:s=>{let o=null;return async()=>{var d;if(o)return o;let g=null;return o=await new Promise(h=>{g=t(s)((k,S)=>{h(S.language)})}),(d=g)==null||d.disconnect(),o}},requestFeedback:s=>{let{channel:o}=s;return function(){return o.requestFeedback(...arguments)}},onLayerStateChange:s=>{let{channel:o}=s;return function(){let d=o.onLayerStateChange(...arguments);return{remove:()=>Promise.resolve(d).then(h=>h.remove())}}},installApp:s=>{let{channel:o}=s;return o.installApp},getSiteInfo:s=>{let{channel:o}=s;return o.getSiteInfo},getWidget:s=>{let{channel:o}=s;return function(){if("getWidget"in o)return o.getWidget(...arguments);throw new Error("Unsupported")}},getDashboardPlugins:s=>{let{channel:o}=s;return function(){if("getDashboardPlugins"in o)return o.getDashboardPlugins(...arguments);throw new Error("Unsupported")}},getDashboardMenuPlugins:s=>{let{channel:o}=s;return function(){if("getDashboardMenuPlugins"in o)return o.getDashboardMenuPlugins(...arguments);throw new Error("Unsupported")}}}};var ee=e=>{let{createHost:t}=e,n=Z();return{...$(n),host:t,auth:()=>({getAuthHeaders:async r=>({headers:{Authorization:await n.getAccessToken(r)()}})})}};var ne=Symbol("Comlink.proxy"),ve=Symbol("Comlink.endpoint"),L=Symbol("Comlink.releaseProxy"),O=Symbol("Comlink.thrown"),re=e=>typeof e=="object"&&e!==null||typeof e=="function",Se={canHandle:e=>re(e)&&e[ne],serialize(e){let{port1:t,port2:n}=new MessageChannel;return R(e,t),[n,[n]]},deserialize(e){return e.start(),D(e)}},Me={canHandle:e=>re(e)&&O 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}},oe=new Map([["proxy",Se],["throw",Me]]);function R(e,t=self){t.addEventListener("message",function n(r){if(!r||!r.data)return;let{id:a,type:i,path:u}=Object.assign({path:[]},r.data),c=(r.data.argumentList||[]).map(x),l;try{let f=u.slice(0,-1).reduce((m,y)=>m[y],e),p=u.reduce((m,y)=>m[y],e);switch(i){case 0:l=p;break;case 1:f[u.slice(-1)[0]]=x(r.data.value),l=!0;break;case 2:l=p.apply(f,c);break;case 3:{let m=new p(...c);l=E(m)}break;case 4:{let{port1:m,port2:y}=new MessageChannel;R(e,y),l=Ae(m,[m])}break;case 5:l=void 0;break}}catch(f){l={value:f,[O]:0}}Promise.resolve(l).catch(f=>({value:f,[O]:0})).then(f=>{let[p,m]=T(f);t.postMessage(Object.assign(Object.assign({},p),{id:a}),m),i===5&&(t.removeEventListener("message",n),se(t))})}),t.start&&t.start()}function Ee(e){return e.constructor.name==="MessagePort"}function se(e){Ee(e)&&e.close()}function D(e,t){return H(e,[],t)}function C(e){if(e)throw new Error("Proxy has been released and is not useable")}function H(e,t=[],n=function(){}){let r=!1,a=new Proxy(n,{get(i,u){if(C(r),u===L)return()=>P(e,{type:5,path:t.map(c=>c.toString())}).then(()=>{se(e),r=!0});if(u==="then"){if(t.length===0)return{then:()=>a};let c=P(e,{type:0,path:t.map(l=>l.toString())}).then(x);return c.then.bind(c)}return H(e,[...t,u])},set(i,u,c){C(r);let[l,f]=T(c);return P(e,{type:1,path:[...t,u].map(p=>p.toString()),value:l},f).then(x)},apply(i,u,c){C(r);let l=t[t.length-1];if(l===ve)return P(e,{type:4}).then(x);if(l==="bind")return H(e,t.slice(0,-1));let[f,p]=te(c);return P(e,{type:2,path:t.map(m=>m.toString()),argumentList:f},p).then(x)},construct(i,u){C(r);let[c,l]=te(u);return P(e,{type:3,path:t.map(f=>f.toString()),argumentList:c},l).then(x)}});return a}function ke(e){return Array.prototype.concat.apply([],e)}function te(e){let t=e.map(T);return[t.map(n=>n[0]),ke(t.map(n=>n[1]))]}var ae=new WeakMap;function Ae(e,t){return ae.set(e,t),e}function E(e){return Object.assign(e,{[ne]:!0})}function T(e){for(let[t,n]of oe)if(n.canHandle(e)){let[r,a]=n.serialize(e);return[{type:3,name:t,value:r},a]}return[{type:0,value:e},ae.get(e)||[]]}function x(e){switch(e.type){case 3:return oe.get(e.name).deserialize(e.value);case 0:return e.value}}function P(e,t,n){return new Promise(r=>{let a=Ce();e.addEventListener("message",function i(u){!u.data||!u.data.id||u.data.id!==a||(e.removeEventListener("message",i),r(u.data))}),e.start&&e.start(),e.postMessage(Object.assign({id:a},t),n)})}function Ce(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var W="__proxyCallbackId__wixSDK__",_="__proxyPromiseId__wixSDK__",ce=e=>Ue(e,t=>async function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];let[i,u]=B(r),c=await t(E(i),u);return ue(c)});var Ie=async e=>{let[t,n]=B(await e);return E({proxies:t,clonables:n})},ue=async e=>U(e?.proxies,await e?.clonables),B=e=>{let t=(a,i)=>{if(le(i)){let u=ie();return a.promises[u]=i,{[_]:u}}if(Oe(i)){let u=ie();return a.callbacks[u]=(c,l)=>{let f=U(c,l),p=i(...f);return Ie(p)},{[W]:u}}return Array.isArray(i)?i.map(u=>t(a,u)):I(i)?de(i,u=>t(a,u)):i},n={promises:{},callbacks:{}},r=t(n,e);return[n,r]},U=(e,t)=>{if(Array.isArray(t))return t.map(n=>U(e,n));if(I(t)&&t.hasOwnProperty(_)){let n=t[_];return e.promises[n]}if(I(t)&&t.hasOwnProperty(W)){let n=t[W];return async function(){for(var r=arguments.length,a=new Array(r),i=0;i<r;i++)a[i]=arguments[i];let[u,c]=B(a),l=await e.callbacks[n](E(u),c);return ue(l)}}return I(t)?de(t,n=>U(e,n)):t},Ue=(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}`)}}}),le=e=>e instanceof Promise,I=e=>e&&typeof e=="object"&&!le(e),Oe=e=>typeof e=="function",de=(e,t)=>{let n=r=>{let[a,i]=r;return[a,t(i)]};return Object.fromEntries(Object.entries(e).map(n))},ie=(()=>{let e=0;return()=>++e})();var He="wix-sdk-bo-hello-handshake",fe=e=>{let{postMessage:t,origin:n}=e,{port1:r,port2:a}=new MessageChannel;t({code:He,version:"1.0.0",port:a},n,[a]);let c=ce(D(r));return{channel:c,close:()=>c[L]()}};var me=(e,t)=>{let n=()=>e.updateHeight(t.offsetHeight),r=new ResizeObserver(n);return r.observe(t),()=>r.disconnect()};var Le=["https://manage.wix.com","https://manage.editorx.com"],Re=new Set(Le),pe=e=>Re.has(e);var ge=e=>{let t=new EventTarget,n=typeof window>"u",r=c=>{t.dispatchEvent(new CustomEvent("beforeunload",{cancelable:!0}))||(c.preventDefault(),c.returnValue=!0)},a=e.onBeforeUnload(r),i=()=>{n||window.removeEventListener("beforeunload",r),a.then(c=>{let{remove:l}=c;return l()})};return n||(window.addEventListener("beforeunload",r),window.addEventListener("unload",i)),{onBeforeUnload:c=>(t.addEventListener("beforeunload",c),{remove:()=>{t.removeEventListener("beforeunload",c)}}),clearBeforeUnloadHandler:i}};function De(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 he(e){return e.has("essentials")?De(e.get("essentials")):void 0}var ye=e=>t=>{let{message:n,action:r,requestId:a}=t;n&&e.showToast({type:"error",details:a!=null?{requestId:a}:void 0,message:n,action:r&&{...r,removeToastOnClick:!0,uiType:"link"}})};var be=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")||"",a=e.postMessage||window.parent.postMessage.bind(window.parent);if(!pe(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:i,close:u}=fe({postMessage:a,origin:r}),c=[u];if(e.autoHeightUpdate===void 0||e.autoHeightUpdate){let s=e.autoHeightElement||document.documentElement,o=me(i,s);c.push(()=>o())}let{onBeforeUnload:l,clearBeforeUnloadHandler:f}=ge(i);c.push(f);let p=we(n.get("siteInfo")||"","siteInfo"),m=()=>p,y=we(n.get("contextIds")||"","contextIds"),z=()=>y,V=!!y,F=new Proxy(i,{get(s,o,d){return o==="onBeforeUnload"?l:o==="getSiteInfo"?m:Reflect.get(s,o,d)}}),N={getContextIds:z,openItemSelector:()=>{throw new Error("openItemSelector is not implemented")}},{monitoring:v,...K}=he(n)||{},q=G({hostContext:v?.context,monitoringConfig:v?.config,sentrySDK:typeof window<"u"?window.Sentry:void 0});return{channel:F,close:()=>c.forEach(s=>s()),getMonitoringClient:q,essentials:K,...V&&{admin:N},showError:ye(i)}},we=(e,t)=>{try{return JSON.parse(decodeURIComponent(e))}catch(n){return console.warn(`Failed to parse ${t} query parameter. Make sure to run the code inside a supported Wix App extension.`,n),{}}};var j=ee({createHost:be});var Pe=(e,t)=>{let[n,r]=xe(()=>e());return t(n)&&r(e()),n},_e=e=>t=>{let{host:n,compProps:r}=Be(t);return Pe(()=>(J({auth:j.auth(),host:n}).enableContext("module"),n),a=>a!==n),r?Te.createElement(e,A({host:n},r)):null},Be=e=>{let{host:t,...n}=e,{host:r,hostType:a}=Pe(()=>t?{host:t,hostType:"local"}:{host:j.host(),hostType:"remote"},c=>!!t&&t!==c.host),[i,u]=xe(void 0);return We(()=>{if(a==="local")return;let c=r.channel.observeState(f=>{u(f||{})}),l=async()=>{(await c).disconnect(),r.close()};return()=>{l()}},[r,a]),a==="local"?{host:r,compProps:n}:{host:r,compProps:i?{...i,...n}:void 0}};export{_e as withContextualWixClient};
2
2
  //# sourceMappingURL=dashboard.js.map