@meltingspot/widget 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +131 -23
- package/index.cjs +1 -1
- package/index.mjs +1 -1
- package/index.standalone.js +2 -2
- package/package.json +3 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
<!--
|
|
4
|
+
To add a new release, copy from this template:
|
|
5
|
+
|
|
6
|
+
## vX.Y.Z
|
|
7
|
+
|
|
8
|
+
Date: YYYY-MM-DD
|
|
9
|
+
|
|
10
|
+
### Major Changes
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
-->
|
|
17
|
+
|
|
18
|
+
## v1.0.0
|
|
19
|
+
|
|
20
|
+
Date: 2026-06-17
|
|
21
|
+
|
|
22
|
+
### Major Changes
|
|
23
|
+
|
|
24
|
+
Initial release of the `@meltingspot/widget` SDK.
|
package/README.md
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
# Widget SDK
|
|
2
2
|
|
|
3
|
-
Embed a MeltingSpot Widget into your own web application
|
|
3
|
+
Embed a MeltingSpot Widget into your own web application: inline, as a modal, or as a drawer.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
### Via `<script>` (CDN)
|
|
8
8
|
|
|
9
|
-
The standalone bundle is self-contained
|
|
9
|
+
The standalone bundle is self-contained: it exposes `window.MeltingSpot.Widget`
|
|
10
10
|
and injects its styles automatically (no separate stylesheet to load).
|
|
11
11
|
|
|
12
12
|
```html
|
|
13
13
|
<script
|
|
14
14
|
crossorigin
|
|
15
|
-
async
|
|
16
15
|
src="https://cdn.jsdelivr.net/npm/@meltingspot/widget"
|
|
17
16
|
></script>
|
|
18
17
|
```
|
|
@@ -28,10 +27,26 @@ import { Widget } from '@meltingspot/widget';
|
|
|
28
27
|
import '@meltingspot/widget/stylesheet.css';
|
|
29
28
|
```
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
> dependencies so your bundler resolves a single shared instance of each.
|
|
30
|
+
## Authentication (`authToken`)
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
`authToken` is the current user's **MeltingSpot SSO token**. Provide it to render
|
|
33
|
+
the widget as an authenticated member; omit it to show only public content to an
|
|
34
|
+
anonymous visitor. Activate [SSO](https://help.meltingspot.io/english/manage-spot/sso) on
|
|
35
|
+
your spot to obtain these tokens.
|
|
36
|
+
|
|
37
|
+
## Rendering modes
|
|
38
|
+
|
|
39
|
+
The SDK offers three ways to render a widget, depending on how much control you want:
|
|
40
|
+
|
|
41
|
+
| Mode | Methods | Behaviour |
|
|
42
|
+
| ---------- | ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| **Inline** | `injectWidgetInto` | Renders the widget immediately inside a container element you provide. Always visible, part of the layout. |
|
|
44
|
+
| **Modal** | `bindWidgetModalTo` / `createWidgetModal` | Renders the widget in a centered overlay opened on demand. `bind*` wires it to a trigger; `create*` returns a handle you open/close yourself. |
|
|
45
|
+
| **Drawer** | `bindWidgetDrawerTo` / `createWidgetDrawer` | Renders the widget in a side panel sliding from the left or right. Same `bind*` vs `create*` distinction. |
|
|
46
|
+
|
|
47
|
+
`bind*` methods attach the open behaviour to an existing element (e.g. a button),
|
|
48
|
+
with zero extra wiring. `create*` methods return a `Modal` / `Drawer` instance with
|
|
49
|
+
`.open()` / `.close()` so you drive visibility from your own code.
|
|
35
50
|
|
|
36
51
|
### Inline
|
|
37
52
|
|
|
@@ -49,37 +64,130 @@ import '@meltingspot/widget/stylesheet.css';
|
|
|
49
64
|
</script>
|
|
50
65
|
```
|
|
51
66
|
|
|
52
|
-
### Modal
|
|
67
|
+
### Modal (bound to a trigger)
|
|
53
68
|
|
|
54
69
|
```html
|
|
55
|
-
<button id="open-widget-modal" type="button"
|
|
70
|
+
<button id="open-widget-modal" type="button">Open</button>
|
|
56
71
|
<script>
|
|
57
|
-
window.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
window.addEventListener('DOMContentLoaded', function () {
|
|
73
|
+
window.MeltingSpot.Widget.bindWidgetModalTo('open-widget-modal', {
|
|
74
|
+
spotId: 'YOUR_SPOT_ID',
|
|
75
|
+
widgetId: 'YOUR_WIDGET_ID',
|
|
76
|
+
authToken: 'OPTIONAL_SSO_TOKEN',
|
|
77
|
+
themeMode: 'auto',
|
|
78
|
+
});
|
|
62
79
|
});
|
|
63
80
|
</script>
|
|
64
81
|
```
|
|
65
82
|
|
|
66
|
-
### Drawer
|
|
83
|
+
### Drawer (bound to a trigger)
|
|
67
84
|
|
|
68
85
|
```html
|
|
69
|
-
<button id="open-widget-drawer" type="button"
|
|
86
|
+
<button id="open-widget-drawer" type="button">Open</button>
|
|
70
87
|
<script>
|
|
71
|
-
window.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
window.addEventListener('DOMContentLoaded', function () {
|
|
89
|
+
window.MeltingSpot.Widget.bindWidgetDrawerTo('open-widget-drawer', {
|
|
90
|
+
position: 'right', // 'left' | 'right' (required)
|
|
91
|
+
spotId: 'YOUR_SPOT_ID',
|
|
92
|
+
widgetId: 'YOUR_WIDGET_ID',
|
|
93
|
+
authToken: 'OPTIONAL_SSO_TOKEN',
|
|
94
|
+
themeMode: 'auto',
|
|
95
|
+
});
|
|
77
96
|
});
|
|
78
97
|
</script>
|
|
79
98
|
```
|
|
80
99
|
|
|
81
|
-
|
|
100
|
+
### Programmatic modal / drawer (`create*`)
|
|
82
101
|
|
|
83
|
-
|
|
102
|
+
When you need to open or close the widget from your own logic, create a handle:
|
|
84
103
|
|
|
104
|
+
```typescript
|
|
105
|
+
import { Widget } from '@meltingspot/widget';
|
|
106
|
+
|
|
107
|
+
const drawer = Widget.createWidgetDrawer({
|
|
108
|
+
spotId: 'YOUR_SPOT_ID',
|
|
109
|
+
widgetId: 'YOUR_WIDGET_ID',
|
|
110
|
+
authToken: 'OPTIONAL_SSO_TOKEN',
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
drawer.open(); // slide in
|
|
114
|
+
drawer.close(); // slide out
|
|
115
|
+
|
|
116
|
+
// Same API for a modal:
|
|
117
|
+
const modal = Widget.createWidgetModal({
|
|
118
|
+
spotId: 'YOUR_SPOT_ID',
|
|
119
|
+
widgetId: 'YOUR_WIDGET_ID',
|
|
120
|
+
});
|
|
121
|
+
modal.open();
|
|
85
122
|
```
|
|
123
|
+
|
|
124
|
+
## Parameters
|
|
125
|
+
|
|
126
|
+
### Common (all methods)
|
|
127
|
+
|
|
128
|
+
Fields of the `options` object (the last argument of every method).
|
|
129
|
+
|
|
130
|
+
| Option | Type | Required | Default | Description |
|
|
131
|
+
| --------------- | ----------------------------------------- | -------- | --------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
132
|
+
| `spotId` | `string` | Yes\* | n/a | Target spot id. \*Optional on `inject*`/`bind*` if set via config; required on `create*`. |
|
|
133
|
+
| `widgetId` | `string` | Yes | n/a | Target widget id. |
|
|
134
|
+
| `authToken` | `string` | No | none (public content) | Current user's MeltingSpot SSO token. |
|
|
135
|
+
| `themeMode` | `'auto' \| 'system' \| 'light' \| 'dark'` | No | `'auto'` | Force a theme. |
|
|
136
|
+
| `domain` | `string` | No | none (default MeltingSpot domain) | Custom domain key of your spot. See [`domain`](#domain). |
|
|
137
|
+
| `utmParameters` | `UtmParameters` | No | parsed from the page URL params | UTM params appended to the widget URL. |
|
|
138
|
+
| `rootDocument` | `Document` | No | current `document` | Document to inject into. |
|
|
139
|
+
|
|
140
|
+
### Method-specific
|
|
141
|
+
|
|
142
|
+
Each method takes a positional `target` argument followed by the `options` object.
|
|
143
|
+
The tables below list the positional `target` and the method-specific `options.*`
|
|
144
|
+
fields; the [common fields](#common-all-methods) above apply to every method's
|
|
145
|
+
`options`.
|
|
146
|
+
|
|
147
|
+
#### `injectWidgetInto(target, options)`
|
|
148
|
+
|
|
149
|
+
| Parameter | Type | Required | Default | Description |
|
|
150
|
+
| --------- | ------------------- | -------- | ------- | -------------------------------------- |
|
|
151
|
+
| `target` | `string \| Element` | Yes | n/a | Container the widget is rendered into. |
|
|
152
|
+
|
|
153
|
+
#### `bindWidgetModalTo(target, options)`
|
|
154
|
+
|
|
155
|
+
| Parameter | Type | Required | Default | Description |
|
|
156
|
+
| -------------- | ------------------- | -------- | --------------- | ------------------------------------ |
|
|
157
|
+
| `target` | `string \| Element` | Yes | n/a | Element whose click opens the modal. |
|
|
158
|
+
| `options.into` | `string \| Element` | No | `document.body` | Where the modal mounts. |
|
|
159
|
+
|
|
160
|
+
#### `bindWidgetDrawerTo(target, options)`
|
|
161
|
+
|
|
162
|
+
| Parameter | Type | Required | Default | Description |
|
|
163
|
+
| ------------------ | ------------------- | -------- | --------------- | ------------------------------------- |
|
|
164
|
+
| `target` | `string \| Element` | Yes | n/a | Element whose click opens the drawer. |
|
|
165
|
+
| `options.position` | `'left' \| 'right'` | Yes | n/a | Side the drawer slides from. |
|
|
166
|
+
| `options.into` | `string \| Element` | No | `document.body` | Where the drawer mounts. |
|
|
167
|
+
|
|
168
|
+
#### `createWidgetModal(options)` / `createWidgetDrawer(options)`
|
|
169
|
+
|
|
170
|
+
No method-specific parameters: they take the common `options` only and return a
|
|
171
|
+
handle with `.open()` / `.close()`.
|
|
172
|
+
|
|
173
|
+
### `domain`
|
|
174
|
+
|
|
175
|
+
The custom domain key of your spot. It is forwarded to the widget so the internal
|
|
176
|
+
links it generates point to your custom domain instead of the default MeltingSpot
|
|
177
|
+
one.
|
|
178
|
+
|
|
179
|
+
See the ["Multi-domains" section of the embed guide](https://help.meltingspot.io/english/manage-spot/embed) for details.
|
|
180
|
+
|
|
181
|
+
### `UtmParameters`
|
|
182
|
+
|
|
183
|
+
Appended to the widget URL as `utm_*` query params (`source` becomes `utm_source`, etc.).
|
|
184
|
+
|
|
185
|
+
| Field | Type | Required | Default | Description |
|
|
186
|
+
| ---------- | -------- | -------- | ------- | --------------------- |
|
|
187
|
+
| `source` | `string` | Yes | n/a | `utm_source` value. |
|
|
188
|
+
| `medium` | `string` | No | unset | `utm_medium` value. |
|
|
189
|
+
| `campaign` | `string` | No | unset | `utm_campaign` value. |
|
|
190
|
+
| `term` | `string` | No | unset | `utm_term` value. |
|
|
191
|
+
| `content` | `string` | No | unset | `utm_content` value. |
|
|
192
|
+
|
|
193
|
+
See the [Widget helpdesk](https://help.meltingspot.io/english/manage-spot/widget) for the full integration guide.
|
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@meltingspot/core"),p=require("@meltingspot/embed"),C="
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@meltingspot/core"),p=require("@meltingspot/embed"),C="1.0.0",d=new i.Logger({appName:"Widget SDK",appVersion:C});class b{constructor(t,e,o){this.content=t,this.rootDocument=e,this.dialogClassname=o,this.dialogElement=null,this.triggerElement=null,this.iframeElement=null,this.currentListener=null}inject({into:t,bind:e,options:o}){this.remove();const r=i.getHTMLElement({input:t,rootDocument:this.rootDocument});if(this.dialogElement=i.createDialog(this.rootDocument),this.dialogElement.classList.add(this.dialogClassname),this.dialogElement.onclose=()=>this.#e(),r.appendChild(this.dialogElement),e){this.triggerElement=i.getHTMLElement({input:e,rootDocument:this.rootDocument});const c=this.open.bind(this,o);this.currentListener=a=>{a.stopPropagation(),a.preventDefault(),c()},this.triggerElement.addEventListener("click",this.currentListener)}}remove(){this.dialogElement&&(this.dialogElement.remove(),this.dialogElement.onclose=null,this.dialogElement=null),this.triggerElement&&(this.currentListener&&this.triggerElement.removeEventListener("click",this.currentListener),this.triggerElement=null,this.currentListener=null)}open(t){this.dialogElement||this.inject({into:this.rootDocument.body}),this.dialogElement&&(this.#t(),this.dialogElement.showModal())}close(){this.dialogElement&&this.dialogElement.close()}#t(){this.dialogElement&&(this.iframeElement=this.dialogElement.appendChild(this.content.iframe))}#e(){this.iframeElement&&(this.iframeElement.remove(),this.iframeElement=null)}}class w extends b{constructor(t,e){super(t,e,"ms-drawer")}open(t){const{position:e="right"}=t??{};super.open(t),this.dialogElement&&(this.dialogElement.dataset.position=e)}}class I extends b{constructor(t,e){super(t,e,"ms-modal")}}class U{constructor(t){this.baseURL=i.formatBaseUrl(t.baseURL),this.spotId=i.formatUUID(t.spotId),this.widgetId=i.formatUUID(t.widgetId),this.authToken=t.authToken??null,this.themeMode=t.themeMode??"auto",this.domain=t.domain??null,this.utmParameters=t.utmParameters??null,this.rootDocument=t.rootDocument}get iframe(){const t=new URL(`/widgets/spot/${this.spotId}/widget/${this.widgetId}`,i.trimSlashRight(this.baseURL)),e=i.createIframe({url:t,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,...i.flattenUtmParameters(this.utmParameters)},rootDocument:this.rootDocument});return e.classList.add("ms-widget"),e}}class L{constructor(t){this.baseURL=i.formatBaseUrl(t.baseURL),this.spotId=i.formatUUID(t.spotId),this.widgetContentId=i.formatUUID(t.widgetContentId),this.contentId=i.formatUUID(t.contentId),this.widgetId=i.formatUUID(t.widgetId),this.contentType=t.contentType,this.authToken=t.authToken??null,this.themeMode=t.themeMode??"auto",this.domain=t.domain??null,this.utmParameters=t.utmParameters??null,this.rootDocument=t.rootDocument}get iframe(){const t=new URL(`/widgets/spot/${this.spotId}/widgetContent/${this.widgetContentId}`,i.trimSlashRight(this.baseURL));t.searchParams.set("widgetId",this.widgetId);const e=i.createIframe({url:t,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,contentId:this.contentId,contentType:this.contentType,...i.flattenUtmParameters(this.utmParameters)},rootDocument:this.rootDocument});return e.classList.add("ms-widget-content"),e}}const n=class n{static injectWidgetInto(t,e){const{spotId:o,rootDocument:r,msCommunityWebBaseUrl:c}=i.ConfigurationService.getConfiguration({spotId:e.spotId,rootDocument:e.rootDocument,msCommunityWebBaseUrl:e.baseURL});if(!o)throw d.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widget:a,args:m}=n.createWidget({...e,spotId:o,rootDocument:r,baseURL:c}),s=new p.EmbedFrame(a);return s.inject(t),n.widgets.push(s),d.log("Widget injected",n.cleanupLoggedArgs(m),t),s}static injectWidgetContentInto(t,e){const{spotId:o,rootDocument:r,msCommunityWebBaseUrl:c}=i.ConfigurationService.getConfiguration({spotId:e.spotId,rootDocument:e.rootDocument,msCommunityWebBaseUrl:e.baseURL});if(!o)throw d.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widgetContent:a,args:m}=n.createWidgetContent({...e,spotId:o,rootDocument:r,baseURL:c}),s=new p.EmbedFrame(a);return s.inject(t),n.widgets.push(s),d.log("WidgetContent injected",n.cleanupLoggedArgs(m),t),s}static bindWidgetModalTo(t,e){return n.bindEntityModalTo(t,{type:"Widget",data:e})}static bindWidgetDrawerTo(t,e){return n.bindEntityDrawerTo(t,{type:"Widget",data:e})}static createWidgetDrawer(t){const{widget:e}=n.createWidget(t);return d.log("Create Widget drawer",{data:n.cleanupLoggedArgs(t)}),new w(e,t.rootDocument??document)}static createWidgetModal(t){const{widget:e}=n.createWidget(t);return d.log("Create Widget modal",{data:n.cleanupLoggedArgs(t)}),new I(e,t.rootDocument??document)}static createWidgetEmbed(t){const{widget:e}=n.createWidget(t),o=new p.EmbedFrame(e);return d.log("Create Widget embed",{data:n.cleanupLoggedArgs(t)}),o}static clear(){n.widgets.forEach(t=>{t.remove()}),n.widgets=[],n.widgetOptions={},d.log("All Widget SDK MeltingSpot elements were cleared")}static bindEntityDrawerTo(t,e){const{spotId:o,rootDocument:r,msCommunityWebBaseUrl:c}=i.ConfigurationService.getConfiguration({spotId:e.data.spotId,rootDocument:e.data.rootDocument??document,msCommunityWebBaseUrl:e.data.baseURL});if(!o)throw d.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let a,m;switch(e.type){case"Widget":{const u=n.createWidget({...e.data,spotId:o,rootDocument:r,baseURL:c});a=u.widget,m=u.args}break;case"WidgetContent":{const u=n.createWidgetContent({...e.data,spotId:o,rootDocument:r,baseURL:c});a=u.widgetContent,m=u.args}}const s=new w(a,r),l={position:e.data.position},g=e.data.into??r.body;return s.inject({into:g,bind:t,options:l}),n.widgets.push(s),d.log("Widget bound to drawer",n.cleanupLoggedArgs(m),l,g,t),s}static bindEntityModalTo(t,e){const{spotId:o,rootDocument:r,msCommunityWebBaseUrl:c}=i.ConfigurationService.getConfiguration({spotId:e.data.spotId,rootDocument:e.data.rootDocument??document,msCommunityWebBaseUrl:e.data.baseURL});if(!o)throw d.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let a,m;switch(e.type){case"Widget":{const g=n.createWidget({...e.data,spotId:o,rootDocument:r,baseURL:c});a=g.widget,m=g.args}break;case"WidgetContent":{const g=n.createWidgetContent({...e.data,spotId:o,rootDocument:r,baseURL:c});a=g.widgetContent,m=g.args}}const s=new I(a,r),l=e.data.into??r.body;return s.inject({into:l,bind:t}),n.widgets.push(s),d.log("Widget bound to modal",n.cleanupLoggedArgs(m),l,t),s}static handleMessageEvent(t){if(!t.data||typeof t.data!="object"||t.data.type!=="OpenWidgetContent")return;const e=t.data?.widgetId;if(!e||typeof e!="string"){d.error("widgetId is required in the message event data");return}const o=n.widgetOptions[e];if(!o){d.error("No widget options found for widgetId",{widgetId:e});return}let r=null;try{r=new URL(o.baseURL).origin}catch{r=null}if(!r||t.origin!==r){d.warn("Ignoring OpenWidgetContent from unexpected origin",{origin:t.origin,expectedOrigin:r});return}const{spotId:c,rootDocument:a,msCommunityWebBaseUrl:m}=i.ConfigurationService.getConfiguration({spotId:o.spotId,rootDocument:o.rootDocument??document,msCommunityWebBaseUrl:o.baseURL}),{widgetContent:s}=n.createWidgetContent({...o,widgetContentId:t.data.widgetContentId,contentType:t.data.contentType,contentId:t.data.contentId,widgetId:e,spotId:c,rootDocument:a,baseURL:m});t.data.openingIn==="Drawer"?new w(s,a).open():t.data.openingIn==="Modal"&&new I(s,a).open()}static createWidget(t){const e=new URLSearchParams(window.location.search),o={spotId:t.spotId,widgetId:t.widgetId,authToken:t.authToken,themeMode:t.themeMode,domain:t.domain,rootDocument:t.rootDocument,baseURL:t.baseURL,utmParameters:t.utmParameters??i.parseUtmParameters(e)};return n.widgetOptions[o.widgetId]=o,n.messageListened||(window.addEventListener("message",n.handleMessageEvent),n.messageListened=!0),{widget:new U(o),args:o}}static createWidgetContent(t){const e=new URLSearchParams(window.location.search),o={spotId:t.spotId,contentId:t.contentId,contentType:t.contentType,widgetContentId:t.widgetContentId,widgetId:t.widgetId,authToken:t.authToken,themeMode:t.themeMode,domain:t.domain,rootDocument:t.rootDocument,baseURL:t.baseURL,utmParameters:t.utmParameters??i.parseUtmParameters(e)};return{widgetContent:new L(o),args:o}}static cleanupLoggedArgs(t){const{authToken:e,...o}=t;return{...o,authToken:e?"***":void 0}}};n.widgets=[],n.messageListened=!1,n.widgetOptions={};let f=n;const D=globalThis;D.MeltingSpot||(D.MeltingSpot={});D.MeltingSpot.Widget=f;exports.Drawer=w;exports.Modal=I;exports.Widget=f;
|
package/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Logger as T, getHTMLElement as L, createDialog as P, formatBaseUrl as W, formatUUID as l, trimSlashRight as E, createIframe as U, flattenUtmParameters as y, ConfigurationService as h, parseUtmParameters as C } from "@meltingspot/core";
|
|
2
2
|
import { EmbedFrame as I } from "@meltingspot/embed";
|
|
3
|
-
const M = "
|
|
3
|
+
const M = "1.0.0", r = new T({
|
|
4
4
|
appName: "Widget SDK",
|
|
5
5
|
appVersion: M
|
|
6
6
|
});
|
package/index.standalone.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){try{if(typeof document==="undefined")return;var s=document.createElement("style");s.setAttribute("data-meltingspot","widget");s.textContent=":where(dialog.ms-dialog)[open]{opacity:1}body:has(dialog.ms-dialog[open]){overflow:hidden}:where(dialog.ms-dialog){border:0;position:fixed;inset:0;padding:0;overflow:hidden;max-width:100%;max-height:100%;opacity:0;transition:opacity .2s ease-out,overlay .2s ease-out allow-discrete,display .2s ease-out allow-discrete}:where(dialog.ms-dialog) .ms-dialog-close-button{position:absolute;top:8px;right:8px;font-size:16px;border:0;border-radius:4px;background:none;box-sizing:border-box;width:2rem;height:2rem;min-width:2rem;min-height:2rem;padding:0;color:#fff}:where(dialog.ms-dialog) .ms-dialog-close-button span{mix-blend-mode:difference}:where(dialog.ms-dialog) .ms-dialog-close-button svg{transform:translateZ(0);mix-blend-mode:difference;margin:auto}:where(dialog.ms-dialog) .ms-dialog-close-button:hover{background:#c8c8c81a;background-blend-mode:difference}@starting-style{:where(dialog.ms-dialog)[open]{opacity:0}}:where(dialog.ms-dialog)::backdrop{background-color:#0000;transition:display .2s allow-discrete,overlay .2s allow-discrete,background-color .2s}:where(dialog.ms-dialog)[open]::backdrop{background-color:#00000040}@starting-style{:where(dialog.ms-dialog)[open]::backdrop{background-color:#0000}}:where(.ms-modal){width:100%;height:100%;margin:0;border-radius:0}:where(.ms-drawer){max-width:640px;width:100%;height:100%;box-sizing:border-box}:where(.ms-drawer)[data-position=left]{margin:0 auto 0 0}:where(.ms-drawer)[data-position=right]{margin:0 0 0 auto}@media(min-width:640px){:where(.ms-modal){width:640px;height:80vh;margin:auto;border-radius:8px}}@media(min-width:1280px){:where(.ms-modal){width:50vw}}\n";document.head.appendChild(s);}catch(e){}})();(function(kt,Pn){typeof exports=="object"&&typeof module<"u"?Pn(exports):typeof define=="function"&&define.amd?define(["exports"],Pn):(kt=typeof globalThis<"u"?globalThis:kt||self,Pn(kt.MeltingSpotWidget={}))})(this,(function(kt){"use strict";const Pn={withStackTrace:!1},nu=(u,o,r=Pn)=>{const c=o.isOk()?{type:"Ok",value:o.value}:{type:"Err",value:o.error},d=r.withStackTrace?new Error().stack:void 0;return{data:c,message:u,stack:d}};function or(u,o,r,c){function d(v){return v instanceof r?v:new r(function(g){g(v)})}return new(r||(r=Promise))(function(v,g){function y(H){try{F(c.next(H))}catch(U){g(U)}}function A(H){try{F(c.throw(H))}catch(U){g(U)}}function F(H){H.done?v(H.value):d(H.value).then(y,A)}F((c=c.apply(u,[])).next())})}function ru(u){var o=typeof Symbol=="function"&&Symbol.iterator,r=o&&u[o],c=0;if(r)return r.call(u);if(u&&typeof u.length=="number")return{next:function(){return u&&c>=u.length&&(u=void 0),{value:u&&u[c++],done:!u}}};throw new TypeError(o?"Object is not iterable.":"Symbol.iterator is not defined.")}function Vt(u){return this instanceof Vt?(this.v=u,this):new Vt(u)}function lf(u,o,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var c=r.apply(u,o||[]),d,v=[];return d={},g("next"),g("throw"),g("return"),d[Symbol.asyncIterator]=function(){return this},d;function g($){c[$]&&(d[$]=function(q){return new Promise(function(k,M){v.push([$,q,k,M])>1||y($,q)})})}function y($,q){try{A(c[$](q))}catch(k){U(v[0][3],k)}}function A($){$.value instanceof Vt?Promise.resolve($.value.v).then(F,H):U(v[0][2],$)}function F($){y("next",$)}function H($){y("throw",$)}function U($,q){$(q),v.shift(),v.length&&y(v[0][0],v[0][1])}}function hf(u){var o,r;return o={},c("next"),c("throw",function(d){throw d}),c("return"),o[Symbol.iterator]=function(){return this},o;function c(d,v){o[d]=u[d]?function(g){return(r=!r)?{value:Vt(u[d](g)),done:d==="return"}:v?v(g):g}:v}}function df(u){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=u[Symbol.asyncIterator],r;return o?o.call(u):(u=typeof ru=="function"?ru(u):u[Symbol.iterator](),r={},c("next"),c("throw"),c("return"),r[Symbol.asyncIterator]=function(){return this},r);function c(v){r[v]=u[v]&&function(g){return new Promise(function(y,A){g=u[v](g),d(y,A,g.done,g.value)})}}function d(v,g,y,A){Promise.resolve(A).then(function(F){v({value:F,done:y})},g)}}class Xe{constructor(o){this._promise=o}static fromSafePromise(o){const r=o.then(c=>new jt(c));return new Xe(r)}static fromPromise(o,r){const c=o.then(d=>new jt(d)).catch(d=>new en(r(d)));return new Xe(c)}static fromThrowable(o,r){return(...c)=>new Xe(or(this,void 0,void 0,function*(){try{return new jt(yield o(...c))}catch(d){return new en(r?r(d):d)}}))}static combine(o){return gf(o)}static combineWithAllErrors(o){return pf(o)}map(o){return new Xe(this._promise.then(r=>or(this,void 0,void 0,function*(){return r.isErr()?new en(r.error):new jt(yield o(r.value))})))}mapErr(o){return new Xe(this._promise.then(r=>or(this,void 0,void 0,function*(){return r.isOk()?new jt(r.value):new en(yield o(r.error))})))}andThen(o){return new Xe(this._promise.then(r=>{if(r.isErr())return new en(r.error);const c=o(r.value);return c instanceof Xe?c._promise:c}))}orElse(o){return new Xe(this._promise.then(r=>or(this,void 0,void 0,function*(){return r.isErr()?o(r.error):new jt(r.value)})))}match(o,r){return this._promise.then(c=>c.match(o,r))}unwrapOr(o){return this._promise.then(r=>r.unwrapOr(o))}safeUnwrap(){return lf(this,arguments,function*(){return yield Vt(yield Vt(yield*hf(df(yield Vt(this._promise.then(r=>r.safeUnwrap()))))))})}then(o,r){return this._promise.then(o,r)}}const iu=u=>new Xe(Promise.resolve(new en(u))),ou=u=>{let o=ae([]);for(const r of u)if(r.isErr()){o=Z(r.error);break}else o.map(c=>c.push(r.value));return o},gf=u=>Xe.fromSafePromise(Promise.all(u)).andThen(ou),uu=u=>{let o=ae([]);for(const r of u)r.isErr()&&o.isErr()?o.error.push(r.error):r.isErr()&&o.isOk()?o=Z([r.error]):r.isOk()&&o.isOk()&&o.value.push(r.value);return o},pf=u=>Xe.fromSafePromise(Promise.all(u)).andThen(uu);var _i;(function(u){function o(d,v){return(...g)=>{try{const y=d(...g);return ae(y)}catch(y){return Z(v?v(y):y)}}}u.fromThrowable=o;function r(d){return ou(d)}u.combine=r;function c(d){return uu(d)}u.combineWithAllErrors=c})(_i||(_i={}));const ae=u=>new jt(u),Z=u=>new en(u);class jt{constructor(o){this.value=o}isOk(){return!0}isErr(){return!this.isOk()}map(o){return ae(o(this.value))}mapErr(o){return ae(this.value)}andThen(o){return o(this.value)}orElse(o){return ae(this.value)}asyncAndThen(o){return o(this.value)}asyncMap(o){return Xe.fromSafePromise(o(this.value))}unwrapOr(o){return this.value}match(o,r){return o(this.value)}safeUnwrap(){const o=this.value;return(function*(){return o})()}_unsafeUnwrap(o){return this.value}_unsafeUnwrapErr(o){throw nu("Called `_unsafeUnwrapErr` on an Ok",this,o)}}class en{constructor(o){this.error=o}isOk(){return!1}isErr(){return!this.isOk()}map(o){return Z(this.error)}mapErr(o){return Z(o(this.error))}andThen(o){return Z(this.error)}orElse(o){return o(this.error)}asyncAndThen(o){return iu(this.error)}asyncMap(o){return iu(this.error)}unwrapOr(o){return o}match(o,r){return r(this.error)}safeUnwrap(){const o=this.error;return(function*(){throw yield Z(o),new Error("Do not use this generator out of `safeTry`")})()}_unsafeUnwrap(o){throw nu("Called `_unsafeUnwrap` on an Err",this,o)}_unsafeUnwrapErr(o){return this.error}}_i.fromThrowable;var ut;(function(u){u[u.CONTINUE=100]="CONTINUE",u[u.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",u[u.PROCESSING=102]="PROCESSING",u[u.EARLY_HINTS=103]="EARLY_HINTS",u[u.OK=200]="OK",u[u.CREATED=201]="CREATED",u[u.ACCEPTED=202]="ACCEPTED",u[u.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",u[u.NO_CONTENT=204]="NO_CONTENT",u[u.RESET_CONTENT=205]="RESET_CONTENT",u[u.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",u[u.MULTI_STATUS=207]="MULTI_STATUS",u[u.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",u[u.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",u[u.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",u[u.SEE_OTHER=303]="SEE_OTHER",u[u.NOT_MODIFIED=304]="NOT_MODIFIED",u[u.USE_PROXY=305]="USE_PROXY",u[u.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",u[u.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",u[u.BAD_REQUEST=400]="BAD_REQUEST",u[u.UNAUTHORIZED=401]="UNAUTHORIZED",u[u.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",u[u.FORBIDDEN=403]="FORBIDDEN",u[u.NOT_FOUND=404]="NOT_FOUND",u[u.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",u[u.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",u[u.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",u[u.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",u[u.CONFLICT=409]="CONFLICT",u[u.GONE=410]="GONE",u[u.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",u[u.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",u[u.REQUEST_TOO_LONG=413]="REQUEST_TOO_LONG",u[u.REQUEST_URI_TOO_LONG=414]="REQUEST_URI_TOO_LONG",u[u.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",u[u.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",u[u.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",u[u.IM_A_TEAPOT=418]="IM_A_TEAPOT",u[u.INSUFFICIENT_SPACE_ON_RESOURCE=419]="INSUFFICIENT_SPACE_ON_RESOURCE",u[u.METHOD_FAILURE=420]="METHOD_FAILURE",u[u.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",u[u.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",u[u.LOCKED=423]="LOCKED",u[u.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",u[u.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",u[u.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",u[u.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",u[u.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",u[u.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",u[u.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",u[u.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",u[u.BAD_GATEWAY=502]="BAD_GATEWAY",u[u.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",u[u.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",u[u.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",u[u.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",u[u.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"})(ut||(ut={}));const mf=new RegExp("^/+"),_f=u=>u.replace(mf,""),vf=new RegExp("/+$"),ur=u=>u.replace(vf,"");function vi(u,o){const r=u.startsWith("/")?u.slice(1):u;return new URL(r,o).toString()}const wi=u=>{const{input:o,rootDocument:r=document}=u;if(typeof o=="string"){const c=r.getElementById(o);if(!c)throw new Error(`Could not found an HTMLElement with ID '${o}'.`);return c}if(o.tagName)return o;throw new Error(`Expected a string or an HTMLElement, but received: ${typeof o}`)},wf=u=>{const o=u.createElement("dialog");o.innerHTML=`
|
|
1
|
+
(function(){try{if(typeof document==="undefined")return;var s=document.createElement("style");s.setAttribute("data-meltingspot","widget");s.textContent=":where(dialog.ms-dialog)[open]{opacity:1}body:has(dialog.ms-dialog[open]){overflow:hidden}:where(dialog.ms-dialog){border:0;position:fixed;inset:0;padding:0;overflow:hidden;max-width:100%;max-height:100%;opacity:0;transition:opacity .2s ease-out,overlay .2s ease-out allow-discrete,display .2s ease-out allow-discrete}:where(dialog.ms-dialog) .ms-dialog-close-button{position:absolute;top:8px;right:8px;font-size:16px;border:0;border-radius:4px;background:none;box-sizing:border-box;width:2rem;height:2rem;min-width:2rem;min-height:2rem;padding:0;color:#fff}:where(dialog.ms-dialog) .ms-dialog-close-button span{mix-blend-mode:difference}:where(dialog.ms-dialog) .ms-dialog-close-button svg{transform:translateZ(0);mix-blend-mode:difference;margin:auto}:where(dialog.ms-dialog) .ms-dialog-close-button:hover{background:#c8c8c81a;background-blend-mode:difference}@starting-style{:where(dialog.ms-dialog)[open]{opacity:0}}:where(dialog.ms-dialog)::backdrop{background-color:#0000;transition:display .2s allow-discrete,overlay .2s allow-discrete,background-color .2s}:where(dialog.ms-dialog)[open]::backdrop{background-color:#00000040}@starting-style{:where(dialog.ms-dialog)[open]::backdrop{background-color:#0000}}:where(.ms-modal){width:100%;height:100%;margin:0;border-radius:0}:where(.ms-drawer){max-width:640px;width:100%;height:100%;box-sizing:border-box}:where(.ms-drawer)[data-position=left]{margin:0 auto 0 0}:where(.ms-drawer)[data-position=right]{margin:0 0 0 auto}@media(min-width:640px){:where(.ms-modal){width:640px;height:80vh;margin:auto;border-radius:8px}}@media(min-width:1280px){:where(.ms-modal){width:50vw}}\n";(document.head||document.documentElement).appendChild(s);}catch(e){if(typeof console!=="undefined"){console.error("[MeltingSpot] failed to inject standalone styles",e);}}})();(function(kt,Pn){typeof exports=="object"&&typeof module<"u"?Pn(exports):typeof define=="function"&&define.amd?define(["exports"],Pn):(kt=typeof globalThis<"u"?globalThis:kt||self,Pn(kt.MeltingSpotWidget={}))})(this,(function(kt){"use strict";const Pn={withStackTrace:!1},nu=(u,o,r=Pn)=>{const c=o.isOk()?{type:"Ok",value:o.value}:{type:"Err",value:o.error},d=r.withStackTrace?new Error().stack:void 0;return{data:c,message:u,stack:d}};function or(u,o,r,c){function d(v){return v instanceof r?v:new r(function(g){g(v)})}return new(r||(r=Promise))(function(v,g){function y(H){try{F(c.next(H))}catch(U){g(U)}}function A(H){try{F(c.throw(H))}catch(U){g(U)}}function F(H){H.done?v(H.value):d(H.value).then(y,A)}F((c=c.apply(u,[])).next())})}function ru(u){var o=typeof Symbol=="function"&&Symbol.iterator,r=o&&u[o],c=0;if(r)return r.call(u);if(u&&typeof u.length=="number")return{next:function(){return u&&c>=u.length&&(u=void 0),{value:u&&u[c++],done:!u}}};throw new TypeError(o?"Object is not iterable.":"Symbol.iterator is not defined.")}function Vt(u){return this instanceof Vt?(this.v=u,this):new Vt(u)}function lf(u,o,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var c=r.apply(u,o||[]),d,v=[];return d={},g("next"),g("throw"),g("return"),d[Symbol.asyncIterator]=function(){return this},d;function g($){c[$]&&(d[$]=function(q){return new Promise(function(k,M){v.push([$,q,k,M])>1||y($,q)})})}function y($,q){try{A(c[$](q))}catch(k){U(v[0][3],k)}}function A($){$.value instanceof Vt?Promise.resolve($.value.v).then(F,H):U(v[0][2],$)}function F($){y("next",$)}function H($){y("throw",$)}function U($,q){$(q),v.shift(),v.length&&y(v[0][0],v[0][1])}}function hf(u){var o,r;return o={},c("next"),c("throw",function(d){throw d}),c("return"),o[Symbol.iterator]=function(){return this},o;function c(d,v){o[d]=u[d]?function(g){return(r=!r)?{value:Vt(u[d](g)),done:d==="return"}:v?v(g):g}:v}}function df(u){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=u[Symbol.asyncIterator],r;return o?o.call(u):(u=typeof ru=="function"?ru(u):u[Symbol.iterator](),r={},c("next"),c("throw"),c("return"),r[Symbol.asyncIterator]=function(){return this},r);function c(v){r[v]=u[v]&&function(g){return new Promise(function(y,A){g=u[v](g),d(y,A,g.done,g.value)})}}function d(v,g,y,A){Promise.resolve(A).then(function(F){v({value:F,done:y})},g)}}class Xe{constructor(o){this._promise=o}static fromSafePromise(o){const r=o.then(c=>new jt(c));return new Xe(r)}static fromPromise(o,r){const c=o.then(d=>new jt(d)).catch(d=>new en(r(d)));return new Xe(c)}static fromThrowable(o,r){return(...c)=>new Xe(or(this,void 0,void 0,function*(){try{return new jt(yield o(...c))}catch(d){return new en(r?r(d):d)}}))}static combine(o){return gf(o)}static combineWithAllErrors(o){return pf(o)}map(o){return new Xe(this._promise.then(r=>or(this,void 0,void 0,function*(){return r.isErr()?new en(r.error):new jt(yield o(r.value))})))}mapErr(o){return new Xe(this._promise.then(r=>or(this,void 0,void 0,function*(){return r.isOk()?new jt(r.value):new en(yield o(r.error))})))}andThen(o){return new Xe(this._promise.then(r=>{if(r.isErr())return new en(r.error);const c=o(r.value);return c instanceof Xe?c._promise:c}))}orElse(o){return new Xe(this._promise.then(r=>or(this,void 0,void 0,function*(){return r.isErr()?o(r.error):new jt(r.value)})))}match(o,r){return this._promise.then(c=>c.match(o,r))}unwrapOr(o){return this._promise.then(r=>r.unwrapOr(o))}safeUnwrap(){return lf(this,arguments,function*(){return yield Vt(yield Vt(yield*hf(df(yield Vt(this._promise.then(r=>r.safeUnwrap()))))))})}then(o,r){return this._promise.then(o,r)}}const iu=u=>new Xe(Promise.resolve(new en(u))),ou=u=>{let o=ae([]);for(const r of u)if(r.isErr()){o=Z(r.error);break}else o.map(c=>c.push(r.value));return o},gf=u=>Xe.fromSafePromise(Promise.all(u)).andThen(ou),uu=u=>{let o=ae([]);for(const r of u)r.isErr()&&o.isErr()?o.error.push(r.error):r.isErr()&&o.isOk()?o=Z([r.error]):r.isOk()&&o.isOk()&&o.value.push(r.value);return o},pf=u=>Xe.fromSafePromise(Promise.all(u)).andThen(uu);var _i;(function(u){function o(d,v){return(...g)=>{try{const y=d(...g);return ae(y)}catch(y){return Z(v?v(y):y)}}}u.fromThrowable=o;function r(d){return ou(d)}u.combine=r;function c(d){return uu(d)}u.combineWithAllErrors=c})(_i||(_i={}));const ae=u=>new jt(u),Z=u=>new en(u);class jt{constructor(o){this.value=o}isOk(){return!0}isErr(){return!this.isOk()}map(o){return ae(o(this.value))}mapErr(o){return ae(this.value)}andThen(o){return o(this.value)}orElse(o){return ae(this.value)}asyncAndThen(o){return o(this.value)}asyncMap(o){return Xe.fromSafePromise(o(this.value))}unwrapOr(o){return this.value}match(o,r){return o(this.value)}safeUnwrap(){const o=this.value;return(function*(){return o})()}_unsafeUnwrap(o){return this.value}_unsafeUnwrapErr(o){throw nu("Called `_unsafeUnwrapErr` on an Ok",this,o)}}class en{constructor(o){this.error=o}isOk(){return!1}isErr(){return!this.isOk()}map(o){return Z(this.error)}mapErr(o){return Z(o(this.error))}andThen(o){return Z(this.error)}orElse(o){return o(this.error)}asyncAndThen(o){return iu(this.error)}asyncMap(o){return iu(this.error)}unwrapOr(o){return o}match(o,r){return r(this.error)}safeUnwrap(){const o=this.error;return(function*(){throw yield Z(o),new Error("Do not use this generator out of `safeTry`")})()}_unsafeUnwrap(o){throw nu("Called `_unsafeUnwrap` on an Err",this,o)}_unsafeUnwrapErr(o){return this.error}}_i.fromThrowable;var ut;(function(u){u[u.CONTINUE=100]="CONTINUE",u[u.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",u[u.PROCESSING=102]="PROCESSING",u[u.EARLY_HINTS=103]="EARLY_HINTS",u[u.OK=200]="OK",u[u.CREATED=201]="CREATED",u[u.ACCEPTED=202]="ACCEPTED",u[u.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",u[u.NO_CONTENT=204]="NO_CONTENT",u[u.RESET_CONTENT=205]="RESET_CONTENT",u[u.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",u[u.MULTI_STATUS=207]="MULTI_STATUS",u[u.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",u[u.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",u[u.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",u[u.SEE_OTHER=303]="SEE_OTHER",u[u.NOT_MODIFIED=304]="NOT_MODIFIED",u[u.USE_PROXY=305]="USE_PROXY",u[u.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",u[u.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",u[u.BAD_REQUEST=400]="BAD_REQUEST",u[u.UNAUTHORIZED=401]="UNAUTHORIZED",u[u.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",u[u.FORBIDDEN=403]="FORBIDDEN",u[u.NOT_FOUND=404]="NOT_FOUND",u[u.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",u[u.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",u[u.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",u[u.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",u[u.CONFLICT=409]="CONFLICT",u[u.GONE=410]="GONE",u[u.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",u[u.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",u[u.REQUEST_TOO_LONG=413]="REQUEST_TOO_LONG",u[u.REQUEST_URI_TOO_LONG=414]="REQUEST_URI_TOO_LONG",u[u.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",u[u.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",u[u.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",u[u.IM_A_TEAPOT=418]="IM_A_TEAPOT",u[u.INSUFFICIENT_SPACE_ON_RESOURCE=419]="INSUFFICIENT_SPACE_ON_RESOURCE",u[u.METHOD_FAILURE=420]="METHOD_FAILURE",u[u.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",u[u.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",u[u.LOCKED=423]="LOCKED",u[u.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",u[u.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",u[u.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",u[u.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",u[u.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",u[u.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",u[u.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",u[u.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",u[u.BAD_GATEWAY=502]="BAD_GATEWAY",u[u.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",u[u.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",u[u.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",u[u.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",u[u.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"})(ut||(ut={}));const mf=new RegExp("^/+"),_f=u=>u.replace(mf,""),vf=new RegExp("/+$"),ur=u=>u.replace(vf,"");function vi(u,o){const r=u.startsWith("/")?u.slice(1):u;return new URL(r,o).toString()}const wi=u=>{const{input:o,rootDocument:r=document}=u;if(typeof o=="string"){const c=r.getElementById(o);if(!c)throw new Error(`Could not found an HTMLElement with ID '${o}'.`);return c}if(o.tagName)return o;throw new Error(`Expected a string or an HTMLElement, but received: ${typeof o}`)},wf=u=>{const o=u.createElement("dialog");o.innerHTML=`
|
|
2
2
|
<form method="dialog">
|
|
3
3
|
<button class="ms-dialog-close-button" aria-label="Close" autofocus>
|
|
4
4
|
<span>
|
|
@@ -30,4 +30,4 @@ __p += '`),re&&(I+=`' +
|
|
|
30
30
|
function print() { __p += __j.call(arguments, '') }
|
|
31
31
|
`:`;
|
|
32
32
|
`)+I+`return __p
|
|
33
|
-
}`;var J=af(function(){return oe(f,S+"return "+I).apply(r,l)});if(J.source=I,zo(J))throw J;return J}function y_(e){return se(e).toLowerCase()}function I_(e){return se(e).toUpperCase()}function A_(e,t,n){if(e=se(e),e&&(n||t===r))return ms(e);if(!e||!(t=nt(t)))return e;var i=wt(e),s=wt(t),f=_s(i,s),l=vs(i,s)+1;return Jt(i,f,l).join("")}function L_(e,t,n){if(e=se(e),e&&(n||t===r))return e.slice(0,Es(e)+1);if(!e||!(t=nt(t)))return e;var i=wt(e),s=vs(i,wt(t))+1;return Jt(i,0,s).join("")}function R_(e,t,n){if(e=se(e),e&&(n||t===r))return e.replace(Gi,"");if(!e||!(t=nt(t)))return e;var i=wt(e),s=_s(i,wt(t));return Jt(i,s).join("")}function O_(e,t){var n=ce,i=ie;if(we(t)){var s="separator"in t?t.separator:s;n="length"in t?Q(t.length):n,i="omission"in t?nt(t.omission):i}e=se(e);var f=e.length;if(An(e)){var l=wt(e);f=l.length}if(n>=f)return e;var h=n-Ln(i);if(h<1)return i;var m=l?Jt(l,0,h).join(""):e.slice(0,h);if(s===r)return m+i;if(l&&(h+=m.length-h),qo(s)){if(e.slice(h).search(s)){var E,T=m;for(s.global||(s=so(s.source,se(Fu.exec(s))+"g")),s.lastIndex=0;E=s.exec(T);)var I=E.index;m=m.slice(0,I===r?h:I)}}else if(e.indexOf(nt(s),h)!=h){var R=m.lastIndexOf(s);R>-1&&(m=m.slice(0,R))}return m+i}function M_(e){return e=se(e),e&&Wc.test(e)?e.replace(Nu,rh):e}var b_=Sn(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Zo=aa("toUpperCase");function sf(e,t,n){return e=se(e),t=n?r:t,t===r?Vl(e)?uh(e):Bl(e):e.match(t)||[]}var af=X(function(e,t){try{return et(e,r,t)}catch(n){return zo(n)?n:new B(n)}}),x_=Pt(function(e,t){return at(t,function(n){n=Mt(n),$t(e,n,Bo(e[n],e))}),e});function D_(e){var t=e==null?0:e.length,n=N();return e=t?pe(e,function(i){if(typeof i[1]!="function")throw new ft(g);return[n(i[0]),i[1]]}):[],X(function(i){for(var s=-1;++s<t;){var f=e[s];if(et(f[0],this,i))return et(f[1],this,i)}})}function S_(e){return rd(lt(e,U))}function Jo(e){return function(){return e}}function U_(e,t){return e==null||e!==e?t:e}var $_=ca(),N_=ca(!0);function Je(e){return e}function Xo(e){return Ys(typeof e=="function"?e:lt(e,U))}function P_(e){return Hs(lt(e,U))}function C_(e,t){return Bs(e,lt(t,U))}var F_=X(function(e,t){return function(n){return Vn(n,e,t)}}),W_=X(function(e,t){return function(n){return Vn(e,n,t)}});function Vo(e,t,n){var i=Se(t),s=Xr(t,i);n==null&&!(we(t)&&(s.length||!i.length))&&(n=t,t=e,e=this,s=Xr(t,Se(t)));var f=!(we(n)&&"chain"in n)||!!n.chain,l=Ft(e);return at(s,function(h){var m=t[h];e[h]=m,l&&(e.prototype[h]=function(){var E=this.__chain__;if(f||E){var T=e(this.__wrapped__),I=T.__actions__=Ke(this.__actions__);return I.push({func:m,args:arguments,thisArg:e}),T.__chain__=E,T}return m.apply(e,Gt([this.value()],arguments))})}),e}function Y_(){return Ce._===this&&(Ce._=hh),this}function jo(){}function k_(e){return e=Q(e),X(function(t){return Gs(t,e)})}var H_=xo(pe),B_=xo(ls),G_=xo(eo);function ff(e){return Co(e)?to(Mt(e)):Ed(e)}function z_(e){return function(t){return e==null?r:cn(e,t)}}var q_=ha(),K_=ha(!0);function eu(){return[]}function tu(){return!1}function Q_(){return{}}function Z_(){return""}function J_(){return!0}function X_(e,t){if(e=Q(e),e<1||e>L)return[];var n=V,i=Ye(e,V);t=N(t),e-=V;for(var s=io(i,t);++n<e;)t(n);return s}function V_(e){return z(e)?pe(e,Mt):rt(e)?[e]:Ke(Ma(se(e)))}function j_(e){var t=++ch;return se(e)+t}var e0=ri(function(e,t){return e+t},0),t0=Do("ceil"),n0=ri(function(e,t){return e/t},1),r0=Do("floor");function i0(e){return e&&e.length?Jr(e,Je,mo):r}function o0(e,t){return e&&e.length?Jr(e,N(t,2),mo):r}function u0(e){return gs(e,Je)}function s0(e,t){return gs(e,N(t,2))}function a0(e){return e&&e.length?Jr(e,Je,Eo):r}function f0(e,t){return e&&e.length?Jr(e,N(t,2),Eo):r}var c0=ri(function(e,t){return e*t},1),l0=Do("round"),h0=ri(function(e,t){return e-t},0);function d0(e){return e&&e.length?ro(e,Je):0}function g0(e,t){return e&&e.length?ro(e,N(t,2)):0}return a.after=Pp,a.ary=Wa,a.assign=Im,a.assignIn=ja,a.assignInWith=mi,a.assignWith=Am,a.at=Lm,a.before=Ya,a.bind=Bo,a.bindAll=x_,a.bindKey=ka,a.castArray=Qp,a.chain=Pa,a.chunk=rg,a.compact=ig,a.concat=og,a.cond=D_,a.conforms=S_,a.constant=Jo,a.countBy=dp,a.create=Rm,a.curry=Ha,a.curryRight=Ba,a.debounce=Ga,a.defaults=Om,a.defaultsDeep=Mm,a.defer=Cp,a.delay=Fp,a.difference=ug,a.differenceBy=sg,a.differenceWith=ag,a.drop=fg,a.dropRight=cg,a.dropRightWhile=lg,a.dropWhile=hg,a.fill=dg,a.filter=pp,a.flatMap=vp,a.flatMapDeep=wp,a.flatMapDepth=Ep,a.flatten=Sa,a.flattenDeep=gg,a.flattenDepth=pg,a.flip=Wp,a.flow=$_,a.flowRight=N_,a.fromPairs=mg,a.functions=Nm,a.functionsIn=Pm,a.groupBy=Tp,a.initial=vg,a.intersection=wg,a.intersectionBy=Eg,a.intersectionWith=Tg,a.invert=Fm,a.invertBy=Wm,a.invokeMap=Ip,a.iteratee=Xo,a.keyBy=Ap,a.keys=Se,a.keysIn=Ze,a.map=ci,a.mapKeys=km,a.mapValues=Hm,a.matches=P_,a.matchesProperty=C_,a.memoize=hi,a.merge=Bm,a.mergeWith=ef,a.method=F_,a.methodOf=W_,a.mixin=Vo,a.negate=di,a.nthArg=k_,a.omit=Gm,a.omitBy=zm,a.once=Yp,a.orderBy=Lp,a.over=H_,a.overArgs=kp,a.overEvery=B_,a.overSome=G_,a.partial=Go,a.partialRight=za,a.partition=Rp,a.pick=qm,a.pickBy=tf,a.property=ff,a.propertyOf=z_,a.pull=Lg,a.pullAll=$a,a.pullAllBy=Rg,a.pullAllWith=Og,a.pullAt=Mg,a.range=q_,a.rangeRight=K_,a.rearg=Hp,a.reject=bp,a.remove=bg,a.rest=Bp,a.reverse=ko,a.sampleSize=Dp,a.set=Qm,a.setWith=Zm,a.shuffle=Sp,a.slice=xg,a.sortBy=Np,a.sortedUniq=Cg,a.sortedUniqBy=Fg,a.split=v_,a.spread=Gp,a.tail=Wg,a.take=Yg,a.takeRight=kg,a.takeRightWhile=Hg,a.takeWhile=Bg,a.tap=ip,a.throttle=zp,a.thru=fi,a.toArray=Ja,a.toPairs=nf,a.toPairsIn=rf,a.toPath=V_,a.toPlainObject=Va,a.transform=Jm,a.unary=qp,a.union=Gg,a.unionBy=zg,a.unionWith=qg,a.uniq=Kg,a.uniqBy=Qg,a.uniqWith=Zg,a.unset=Xm,a.unzip=Ho,a.unzipWith=Na,a.update=Vm,a.updateWith=jm,a.values=Nn,a.valuesIn=e_,a.without=Jg,a.words=sf,a.wrap=Kp,a.xor=Xg,a.xorBy=Vg,a.xorWith=jg,a.zip=ep,a.zipObject=tp,a.zipObjectDeep=np,a.zipWith=rp,a.entries=nf,a.entriesIn=rf,a.extend=ja,a.extendWith=mi,Vo(a,a),a.add=e0,a.attempt=af,a.camelCase=i_,a.capitalize=of,a.ceil=t0,a.clamp=t_,a.clone=Zp,a.cloneDeep=Xp,a.cloneDeepWith=Vp,a.cloneWith=Jp,a.conformsTo=jp,a.deburr=uf,a.defaultTo=U_,a.divide=n0,a.endsWith=o_,a.eq=Tt,a.escape=u_,a.escapeRegExp=s_,a.every=gp,a.find=mp,a.findIndex=xa,a.findKey=bm,a.findLast=_p,a.findLastIndex=Da,a.findLastKey=xm,a.floor=r0,a.forEach=Ca,a.forEachRight=Fa,a.forIn=Dm,a.forInRight=Sm,a.forOwn=Um,a.forOwnRight=$m,a.get=Ko,a.gt=em,a.gte=tm,a.has=Cm,a.hasIn=Qo,a.head=Ua,a.identity=Je,a.includes=yp,a.indexOf=_g,a.inRange=n_,a.invoke=Ym,a.isArguments=dn,a.isArray=z,a.isArrayBuffer=nm,a.isArrayLike=Qe,a.isArrayLikeObject=ye,a.isBoolean=rm,a.isBuffer=Xt,a.isDate=im,a.isElement=om,a.isEmpty=um,a.isEqual=sm,a.isEqualWith=am,a.isError=zo,a.isFinite=fm,a.isFunction=Ft,a.isInteger=qa,a.isLength=gi,a.isMap=Ka,a.isMatch=cm,a.isMatchWith=lm,a.isNaN=hm,a.isNative=dm,a.isNil=pm,a.isNull=gm,a.isNumber=Qa,a.isObject=we,a.isObjectLike=Ee,a.isPlainObject=ir,a.isRegExp=qo,a.isSafeInteger=mm,a.isSet=Za,a.isString=pi,a.isSymbol=rt,a.isTypedArray=$n,a.isUndefined=_m,a.isWeakMap=vm,a.isWeakSet=wm,a.join=yg,a.kebabCase=a_,a.last=dt,a.lastIndexOf=Ig,a.lowerCase=f_,a.lowerFirst=c_,a.lt=Em,a.lte=Tm,a.max=i0,a.maxBy=o0,a.mean=u0,a.meanBy=s0,a.min=a0,a.minBy=f0,a.stubArray=eu,a.stubFalse=tu,a.stubObject=Q_,a.stubString=Z_,a.stubTrue=J_,a.multiply=c0,a.nth=Ag,a.noConflict=Y_,a.noop=jo,a.now=li,a.pad=l_,a.padEnd=h_,a.padStart=d_,a.parseInt=g_,a.random=r_,a.reduce=Op,a.reduceRight=Mp,a.repeat=p_,a.replace=m_,a.result=Km,a.round=l0,a.runInContext=p,a.sample=xp,a.size=Up,a.snakeCase=__,a.some=$p,a.sortedIndex=Dg,a.sortedIndexBy=Sg,a.sortedIndexOf=Ug,a.sortedLastIndex=$g,a.sortedLastIndexBy=Ng,a.sortedLastIndexOf=Pg,a.startCase=w_,a.startsWith=E_,a.subtract=h0,a.sum=d0,a.sumBy=g0,a.template=T_,a.times=X_,a.toFinite=Wt,a.toInteger=Q,a.toLength=Xa,a.toLower=y_,a.toNumber=gt,a.toSafeInteger=ym,a.toString=se,a.toUpper=I_,a.trim=A_,a.trimEnd=L_,a.trimStart=R_,a.truncate=O_,a.unescape=M_,a.uniqueId=j_,a.upperCase=b_,a.upperFirst=Zo,a.each=Ca,a.eachRight=Fa,a.first=Ua,Vo(a,(function(){var e={};return Rt(a,function(t,n){fe.call(a.prototype,n)||(e[n]=t)}),e})(),{chain:!1}),a.VERSION=c,at(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){a[e].placeholder=a}),at(["drop","take"],function(e,t){te.prototype[e]=function(n){n=n===r?1:xe(Q(n),0);var i=this.__filtered__&&!t?new te(this):this.clone();return i.__filtered__?i.__takeCount__=Ye(n,i.__takeCount__):i.__views__.push({size:Ye(n,V),type:e+(i.__dir__<0?"Right":"")}),i},te.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),at(["filter","map","takeWhile"],function(e,t){var n=t+1,i=n==W||n==O;te.prototype[e]=function(s){var f=this.clone();return f.__iteratees__.push({iteratee:N(s,3),type:n}),f.__filtered__=f.__filtered__||i,f}}),at(["head","last"],function(e,t){var n="take"+(t?"Right":"");te.prototype[e]=function(){return this[n](1).value()[0]}}),at(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");te.prototype[e]=function(){return this.__filtered__?new te(this):this[n](1)}}),te.prototype.compact=function(){return this.filter(Je)},te.prototype.find=function(e){return this.filter(e).head()},te.prototype.findLast=function(e){return this.reverse().find(e)},te.prototype.invokeMap=X(function(e,t){return typeof e=="function"?new te(this):this.map(function(n){return Vn(n,e,t)})}),te.prototype.reject=function(e){return this.filter(di(N(e)))},te.prototype.slice=function(e,t){e=Q(e);var n=this;return n.__filtered__&&(e>0||t<0)?new te(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=Q(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},te.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},te.prototype.toArray=function(){return this.take(V)},Rt(te.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),s=a[i?"take"+(t=="last"?"Right":""):t],f=i||/^find/.test(t);s&&(a.prototype[t]=function(){var l=this.__wrapped__,h=i?[1]:arguments,m=l instanceof te,E=h[0],T=m||z(l),I=function(j){var re=s.apply(a,Gt([j],h));return i&&R?re[0]:re};T&&n&&typeof E=="function"&&E.length!=1&&(m=T=!1);var R=this.__chain__,S=!!this.__actions__.length,P=f&&!R,J=m&&!S;if(!f&&T){l=J?l:new te(this);var C=e.apply(l,h);return C.__actions__.push({func:fi,args:[I],thisArg:r}),new ct(C,R)}return P&&J?e.apply(this,h):(C=this.thru(I),P?i?C.value()[0]:C.value():C)})}),at(["pop","push","shift","sort","splice","unshift"],function(e){var t=Nr[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);a.prototype[e]=function(){var s=arguments;if(i&&!this.__chain__){var f=this.value();return t.apply(z(f)?f:[],s)}return this[n](function(l){return t.apply(z(l)?l:[],s)})}}),Rt(te.prototype,function(e,t){var n=a[t];if(n){var i=n.name+"";fe.call(bn,i)||(bn[i]=[]),bn[i].push({name:t,func:n})}}),bn[ni(r,he).name]=[{name:"wrapper",func:r}],te.prototype.clone=Mh,te.prototype.reverse=bh,te.prototype.value=xh,a.prototype.at=op,a.prototype.chain=up,a.prototype.commit=sp,a.prototype.next=ap,a.prototype.plant=cp,a.prototype.reverse=lp,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=hp,a.prototype.first=a.prototype.head,zn&&(a.prototype[zn]=fp),a}),Rn=sh();on?((on.exports=Rn)._=Rn,Ji._=Rn):Ce._=Rn}).call(jf)})(Fn,Fn.exports)),Fn.exports}ec();const tc="0.1.0";class Ti{constructor(o){this.debug=!1,this.debug=o?.debug??!1,this.appName=o?.appName,this.appVersion=o?.appVersion}log(o,...r){this.debug&&this.print(o,"info",r)}warn(o,...r){this.print(o,"warn",r)}error(o,...r){this.print(o,"error",r)}print(o,r,c){const g=[`[${["MeltingSpot",this.appName,this.appVersion].filter(Boolean).join(" - ")}] ${o}`];c.length&&g.push(...c),console[r](...g)}}const nc=new Ti({appName:"Core SDK",appVersion:tc}),nn=u=>u.toLowerCase().replace(/[^a-z0-9-]/g,""),rc=["/user"],ic=({deeplink:u,spotId:o})=>{try{const r=new URL(u,"https://unused.com");let c=r.pathname;return r.search&&(c+=r.search),r.hash&&(c+=r.hash),rc.some(d=>c.startsWith(d))||(c=`/spot/${o}/${_f(c)}`),c}catch(r){return nc.warn("Failed to parse deeplink URL",r),null}},oc=[/(^|\.)meltingspot\.io$/i],yi=u=>{let o;try{const v=ur(u);o=new URL(v)}catch{throw new Error(`Invalid baseURL: ${u}`)}const r=o.hostname==="localhost"||o.hostname==="127.0.0.1",c=o.protocol==="https:",d=oc.some(v=>v.test(o.hostname));if(!r&&(!c||!d))throw new Error(`Untrusted baseURL origin: ${o.origin}`);return o.origin},uc={msApiBaseUrl:"https://openapi.meltingspot.io/",msCommunityWebBaseUrl:"https://go.meltingspot.io/",ssoToken:void 0,spotId:"",rootDocument:globalThis.document};class Ue{constructor(){this.configuration=uc}static getInstance(){return Ue.instance||(Ue.instance=new Ue),Ue.instance}setConfiguration(o){this.configuration={...this.configuration,...o}}static getConfiguration(o={}){return{...Ue.getInstance().configuration,...o}}}const Eu="%[a-f0-9]{2}",Tu=new RegExp("("+Eu+")|([^%]+?)","gi"),yu=new RegExp("("+Eu+")+","gi");function Ii(u,o){try{return[decodeURIComponent(u.join(""))]}catch{}if(u.length===1)return u;o=o||1;const r=u.slice(0,o),c=u.slice(o);return Array.prototype.concat.call([],Ii(r),Ii(c))}function sc(u){try{return decodeURIComponent(u)}catch{let o=u.match(Tu)||[];for(let r=1;r<o.length;r++)u=Ii(o,r).join(""),o=u.match(Tu)||[];return u}}function ac(u){const o={"%FE%FF":"��","%FF%FE":"��"};let r=yu.exec(u);for(;r;){try{o[r[0]]=decodeURIComponent(r[0])}catch{const d=sc(r[0]);d!==r[0]&&(o[r[0]]=d)}r=yu.exec(u)}o["%C2"]="�";const c=Object.keys(o);for(const d of c)u=u.replace(new RegExp(d,"g"),o[d]);return u}function fc(u){if(typeof u!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof u+"`");try{return decodeURIComponent(u)}catch{return ac(u)}}function cc(u,o){const r={};if(Array.isArray(o))for(const c of o){const d=Object.getOwnPropertyDescriptor(u,c);d?.enumerable&&Object.defineProperty(r,c,d)}else for(const c of Reflect.ownKeys(u)){const d=Object.getOwnPropertyDescriptor(u,c);if(d.enumerable){const v=u[c];o(c,v,u)&&Object.defineProperty(r,c,d)}}return r}function Iu(u,o){if(!(typeof u=="string"&&typeof o=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(u===""||o==="")return[];const r=u.indexOf(o);return r===-1?[]:[u.slice(0,r),u.slice(r+o.length)]}const lc=u=>u==null,hc=u=>encodeURIComponent(u).replaceAll(/[!'()*]/g,o=>`%${o.charCodeAt(0).toString(16).toUpperCase()}`),Ai=Symbol("encodeFragmentIdentifier");function dc(u){switch(u.arrayFormat){case"index":return o=>(r,c)=>{const d=r.length;return c===void 0||u.skipNull&&c===null||u.skipEmptyString&&c===""?r:c===null?[...r,[Ae(o,u),"[",d,"]"].join("")]:[...r,[Ae(o,u),"[",Ae(d,u),"]=",Ae(c,u)].join("")]};case"bracket":return o=>(r,c)=>c===void 0||u.skipNull&&c===null||u.skipEmptyString&&c===""?r:c===null?[...r,[Ae(o,u),"[]"].join("")]:[...r,[Ae(o,u),"[]=",Ae(c,u)].join("")];case"colon-list-separator":return o=>(r,c)=>c===void 0||u.skipNull&&c===null||u.skipEmptyString&&c===""?r:c===null?[...r,[Ae(o,u),":list="].join("")]:[...r,[Ae(o,u),":list=",Ae(c,u)].join("")];case"comma":case"separator":case"bracket-separator":{const o=u.arrayFormat==="bracket-separator"?"[]=":"=";return r=>(c,d)=>d===void 0||u.skipNull&&d===null||u.skipEmptyString&&d===""?c:(d=d===null?"":d,c.length===0?[[Ae(r,u),o,Ae(d,u)].join("")]:[[c,Ae(d,u)].join(u.arrayFormatSeparator)])}default:return o=>(r,c)=>c===void 0||u.skipNull&&c===null||u.skipEmptyString&&c===""?r:c===null?[...r,Ae(o,u)]:[...r,[Ae(o,u),"=",Ae(c,u)].join("")]}}function gc(u){let o;switch(u.arrayFormat){case"index":return(r,c,d)=>{if(o=/\[(\d*)]$/.exec(r),r=r.replace(/\[\d*]$/,""),!o){d[r]=c;return}d[r]===void 0&&(d[r]={}),d[r][o[1]]=c};case"bracket":return(r,c,d)=>{if(o=/(\[])$/.exec(r),r=r.replace(/\[]$/,""),!o){d[r]=c;return}if(d[r]===void 0){d[r]=[c];return}d[r]=[...d[r],c]};case"colon-list-separator":return(r,c,d)=>{if(o=/(:list)$/.exec(r),r=r.replace(/:list$/,""),!o){d[r]=c;return}if(d[r]===void 0){d[r]=[c];return}d[r]=[...d[r],c]};case"comma":case"separator":return(r,c,d)=>{const v=typeof c=="string"&&c.includes(u.arrayFormatSeparator),g=typeof c=="string"&&!v&&bt(c,u).includes(u.arrayFormatSeparator);c=g?bt(c,u):c;const y=v||g?c.split(u.arrayFormatSeparator).map(A=>bt(A,u)):c===null?c:bt(c,u);d[r]=y};case"bracket-separator":return(r,c,d)=>{const v=/(\[])$/.test(r);if(r=r.replace(/\[]$/,""),!v){d[r]=c&&bt(c,u);return}const g=c===null?[]:bt(c,u).split(u.arrayFormatSeparator);if(d[r]===void 0){d[r]=g;return}d[r]=[...d[r],...g]};default:return(r,c,d)=>{if(d[r]===void 0){d[r]=c;return}d[r]=[...[d[r]].flat(),c]}}}function Au(u){if(typeof u!="string"||u.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function Ae(u,o){return o.encode?o.strict?hc(u):encodeURIComponent(u):u}function bt(u,o){return o.decode?fc(u):u}function Lu(u){return Array.isArray(u)?u.sort():typeof u=="object"?Lu(Object.keys(u)).sort((o,r)=>Number(o)-Number(r)).map(o=>u[o]):u}function Ru(u){const o=u.indexOf("#");return o!==-1&&(u=u.slice(0,o)),u}function pc(u){let o="";const r=u.indexOf("#");return r!==-1&&(o=u.slice(r)),o}function Ou(u,o,r){return r==="string"&&typeof u=="string"?u:typeof r=="function"&&typeof u=="string"?r(u):r==="boolean"&&u===null?!0:r==="boolean"&&u!==null&&(u.toLowerCase()==="true"||u.toLowerCase()==="false")?u.toLowerCase()==="true":r==="boolean"&&u!==null&&(u.toLowerCase()==="1"||u.toLowerCase()==="0")?u.toLowerCase()==="1":r==="string[]"&&o.arrayFormat!=="none"&&typeof u=="string"?[u]:r==="number[]"&&o.arrayFormat!=="none"&&!Number.isNaN(Number(u))&&typeof u=="string"&&u.trim()!==""?[Number(u)]:r==="number"&&!Number.isNaN(Number(u))&&typeof u=="string"&&u.trim()!==""?Number(u):o.parseBooleans&&u!==null&&(u.toLowerCase()==="true"||u.toLowerCase()==="false")?u.toLowerCase()==="true":o.parseNumbers&&!Number.isNaN(Number(u))&&typeof u=="string"&&u.trim()!==""?Number(u):u}function Li(u){u=Ru(u);const o=u.indexOf("?");return o===-1?"":u.slice(o+1)}function Ri(u,o){o={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...o},Au(o.arrayFormatSeparator);const r=gc(o),c=Object.create(null);if(typeof u!="string"||(u=u.trim().replace(/^[?#&]/,""),!u))return c;for(const d of u.split("&")){if(d==="")continue;const v=o.decode?d.replaceAll("+"," "):d;let[g,y]=Iu(v,"=");g===void 0&&(g=v),y=y===void 0?null:["comma","separator","bracket-separator"].includes(o.arrayFormat)?y:bt(y,o),r(bt(g,o),y,c)}for(const[d,v]of Object.entries(c))if(typeof v=="object"&&v!==null&&o.types[d]!=="string")for(const[g,y]of Object.entries(v)){const A=o.types[d]?o.types[d].replace("[]",""):void 0;v[g]=Ou(y,o,A)}else typeof v=="object"&&v!==null&&o.types[d]==="string"?c[d]=Object.values(v).join(o.arrayFormatSeparator):c[d]=Ou(v,o,o.types[d]);return o.sort===!1?c:(o.sort===!0?Object.keys(c).sort():Object.keys(c).sort(o.sort)).reduce((d,v)=>{const g=c[v];return d[v]=g&&typeof g=="object"&&!Array.isArray(g)?Lu(g):g,d},Object.create(null))}function Mu(u,o){if(!u)return"";o={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...o},Au(o.arrayFormatSeparator);const r=g=>o.skipNull&&lc(u[g])||o.skipEmptyString&&u[g]==="",c=dc(o),d={};for(const[g,y]of Object.entries(u))r(g)||(d[g]=y);const v=Object.keys(d);return o.sort!==!1&&v.sort(o.sort),v.map(g=>{const y=u[g];return y===void 0?"":y===null?Ae(g,o):Array.isArray(y)?y.length===0&&o.arrayFormat==="bracket-separator"?Ae(g,o)+"[]":y.reduce(c(g),[]).join("&"):Ae(g,o)+"="+Ae(y,o)}).filter(g=>g.length>0).join("&")}function bu(u,o){o={decode:!0,...o};let[r,c]=Iu(u,"#");return r===void 0&&(r=u),{url:r?.split("?")?.[0]??"",query:Ri(Li(u),o),...o&&o.parseFragmentIdentifier&&c?{fragmentIdentifier:bt(c,o)}:{}}}function xu(u,o){o={encode:!0,strict:!0,[Ai]:!0,...o};const r=Ru(u.url).split("?")[0]||"",c=Li(u.url),d={...Ri(c,{sort:!1,...o}),...u.query};let v=Mu(d,o);v&&=`?${v}`;let g=pc(u.url);if(typeof u.fragmentIdentifier=="string"){const y=new URL(r);y.hash=u.fragmentIdentifier,g=o[Ai]?y.hash:`#${u.fragmentIdentifier}`}return`${r}${v}${g}`}function Du(u,o,r){r={parseFragmentIdentifier:!0,[Ai]:!1,...r};const{url:c,query:d,fragmentIdentifier:v}=bu(u,r);return xu({url:c,query:cc(d,o),fragmentIdentifier:v},r)}function mc(u,o,r){const c=Array.isArray(o)?d=>!o.includes(d):(d,v)=>!o(d,v);return Du(u,c,r)}const _c=Object.freeze(Object.defineProperty({__proto__:null,exclude:mc,extract:Li,parse:Ri,parseUrl:bu,pick:Du,stringify:Mu,stringifyUrl:xu},Symbol.toStringTag,{value:"Module"}));class qe extends Error{constructor(o,r){super(`HTTP Error ${o}${r?`: ${r}`:""}`),this.code=o,this.name="HttpError",Object.setPrototypeOf(this,qe.prototype)}}var $e=(u=>(u.GET="GET",u.PATCH="PATCH",u.POST="POST",u))($e||{});class vc{constructor(){this.headers={}}setHeaders(o){this.headers=o}async get(o){try{const r=o.query?`${o.url}?${this.serializeQuery(o.query)}`:o.url,c=await fetch(r,{headers:{...this.headers,...o.headers,"Content-Type":"application/json"}});return c.ok?ae(await c.json()):Z(new qe(c.status,await c.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return Z(new qe(ut.INTERNAL_SERVER_ERROR,c))}}async post(o){try{const r=await fetch(o.url,{method:"POST",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload)});return r.ok?ae(await r.json()):Z(new qe(r.status,await r.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return Z(new qe(ut.INTERNAL_SERVER_ERROR,c))}}async patch(o){try{const r=await fetch(o.url,{method:"PATCH",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload)});return r.ok?ae(await r.json()):Z(new qe(r.status,await r.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return Z(new qe(ut.INTERNAL_SERVER_ERROR,c))}}serializeQuery(o){if(typeof o=="string")return o;if(typeof o=="object")for(const r in o)o[r]===void 0&&delete o[r];return o=_c.stringify(o,{arrayFormat:"none"}),o}}const Tr={accessToken:{email:"/v1/auth/accessToken/email",sso:{jwt:"/v1/auth/accessToken/sso/jwt"}},refreshAccessToken:"/v1/auth/accessToken~refresh",password:{reset:"/v1/auth/password~reset"}};class Ht extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return Ht.instance||(Ht.instance=new Ht),Ht.instance}async loginWithPassword(o,r){const c=await this.callApi({endpoint:Tr.accessToken.email,method:"POST",body:{email:o,password:r},withSpotId:!0});if(c.isErr())return Z(c.error);const{accessToken:d,refreshToken:v}=c.value;return this.setTokens(d.token,v.token),ae({accessToken:d.token,refreshToken:v.token})}async loginWithSsoToken(o){const r=await this.callApi({endpoint:Tr.accessToken.sso.jwt,method:"POST",body:{token:o},withSpotId:!0});if(r.isErr())return Z(r.error);const{accessToken:c,refreshToken:d}=r.value;return this.setTokens(c.token,d.token),ae({accessToken:c.token,refreshToken:d.token})}loginWithAuthTokens(o,r){return this.setTokens(o,r),{accessToken:o,refreshToken:r}}resetPassword(o){return this.callApi({endpoint:Tr.password.reset,method:"POST",body:{email:o}})}async refresh(){const o=await this.callApi({endpoint:Tr.refreshAccessToken,method:"POST",body:{refreshToken:this.refreshToken}});if(o.isErr())return Z(o.error);const{accessToken:r,refreshToken:c}=o.value;return this.setTokens(r.token,c.token),ae({accessToken:r.token,refreshToken:c.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(o,r){if(this.accessToken!==o||this.refreshToken!==r){this.accessToken=o,this.refreshToken=r;const c=new CustomEvent("auth:tokens-updated",{detail:{accessToken:o,refreshToken:r}});this.dispatchEvent(c)}}async callApi(o){try{const{spotId:r,msApiBaseUrl:c}=Ue.getConfiguration(),d=vi(o.endpoint,c),v={"Content-Type":"application/json",...o.headers};o.withSpotId&&r&&(v[Su.SpotId]=r);const g=await fetch(d,{method:o.method,body:o.body?JSON.stringify(o.body):void 0,headers:v});if(!g.ok)return Z(new qe(g.status,g.statusText));if(g.status===ut.NO_CONTENT)return ae(void 0);const y=await g.json();return ae(y)}catch(r){return Z(new qe(ut.INTERNAL_SERVER_ERROR,r instanceof Error?r.message:String(r)))}}}var Su=(u=>(u.Authorization="Authorization",u.SpotId="x-spotid",u))(Su||{});class It{constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=Ht.getInstance(),this.httpService=new vc}static getInstance(){return It.instance||(It.instance=new It),It.instance}static buildAuthenticatedRequest(o){const{msApiBaseUrl:r,spotId:c}=Ue.getConfiguration(),d=vi(o,r),v=Ht.getInstance().getAccessToken();if(!v)return Z(new Error("Not authenticated"));const g={"Content-Type":"application/json",Authorization:`Bearer ${v}`};return c&&(g["x-spotid"]=c),ae({url:d,headers:g})}static async stream(o,r,c){const d=It.buildAuthenticatedRequest(o);if(d.isErr())return Z(d.error);const{url:v,headers:g}=d.value;try{const y=await fetch(v,{method:"POST",headers:g,...r!==void 0?{body:JSON.stringify(r)}:{},...c?{signal:c}:{}});if(!y.ok){const A=await y.text();return Z(new Error(`HTTP ${y.status}: ${A}`))}return y.body?ae(y.body):Z(new Error("Response body is empty"))}catch(y){const A=y instanceof Error?y.message:"Unknown error";return Z(y instanceof Error?y:new Error(A))}}get pendingCount(){return this.queue.length}enqueue(o){return new Promise(r=>{const c=async()=>{try{const d=await o();r(d)}catch(d){r(Z(new qe(ut.INTERNAL_SERVER_ERROR,d instanceof Error?d.message:"Unknown error")))}};this.queue.push(c),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){const o=this.queue.shift();if(!o)break;await o()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){const o=this.isPaused;this.isPaused=!1,o&&this.processQueue()}async call(o){return this.enqueue(async()=>{const r=async()=>{const{spotId:d,msApiBaseUrl:v}=Ue.getConfiguration(),g={...o.options?.headers??{}};d&&(g["x-spotid"]=d);const y=this.authService.getAccessToken(),{requiresAuth:A=!0}=o;if(!y&&A)return Z(new qe(ut.UNAUTHORIZED));y&&(g.Authorization=`Bearer ${y}`);const F=vi(o.endpoint,v);switch(o.method){case $e.GET:return this.httpService.get({...o.options??{},headers:g,url:F});case $e.PATCH:return this.httpService.patch({...o.options??{},headers:g,url:F});case $e.POST:return this.httpService.post({...o.options??{},headers:g,url:F});default:return Z(new qe(ut.METHOD_NOT_ALLOWED,"Method not allowed"))}};let c=await r();if(c.isErr()&&c.error.code===ut.UNAUTHORIZED){const d=await this.authService.refresh();if(d.isErr())return Z(new qe(ut.UNAUTHORIZED,d.error.message));c=await r()}return c})}}const At={playbooks:"/v1/playbooks",pages:u=>`/v1/playbooks/${u}/pages`,hotspots:(u,o)=>`/v1/playbooks/${u}/pages/${o}/hotspots`,hotspot:(u,o,r)=>`/v1/playbooks/${u}/pages/${o}/hotspots/${r}`,accessibleIntents:(u,o)=>`/v1/playbooks/${u}/pages/${o}/accessibleIntents`,intents:(u,o,r)=>`/v1/playbooks/${u}/pages/${o}/hotspots/${r}/intents`,intent:(u,o,r,c)=>`/v1/playbooks/${u}/pages/${o}/hotspots/${r}/intents/${c}`},yr=50;class gn{static getInstance(){return gn.instance||(gn.instance=new gn),gn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async listPlaybooks(o){const r=await this.meltingSpotApi.call({method:$e.GET,endpoint:At.playbooks,options:{query:{page:o?.page??1,limit:o?.limit??yr,...o?.domain?{"domain[eq]":o.domain}:{}}}});return r.isErr()?Z(r.error):ae(r.value)}async listPlaybookPages(o){const r=await this.meltingSpotApi.call({method:$e.GET,endpoint:At.pages(o.playbookId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.url?{"url[eq]":o.url}:{}}}});return r.isErr()?Z(r.error):ae(r.value)}async createPlaybookPage(o,r){const c=await this.meltingSpotApi.call({method:$e.POST,endpoint:At.pages(o.playbookId),options:{payload:r}});return c.isErr()?Z(c.error):ae(c.value)}async listAccessiblePlaybookIntents(o){const r=await this.meltingSpotApi.call({method:$e.GET,endpoint:At.accessibleIntents(o.playbookId,o.pageId),options:{query:{...o.domain?{"domain[eq]":o.domain}:{}}}});return r.isErr()?Z(r.error):ae(r.value)}async listPlaybookHotspots(o){const r=await this.meltingSpotApi.call({method:$e.GET,endpoint:At.hotspots(o.playbookId,o.pageId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.intentStatus?{"intentStatus[eq]":o.intentStatus}:{},...o.widgetType?{"widgetType[eq]":o.widgetType}:{}}}});return r.isErr()?Z(r.error):ae(r.value)}async createPlaybookHotspot(o,r){const c=await this.meltingSpotApi.call({method:$e.POST,endpoint:At.hotspots(o.playbookId,o.pageId),options:{payload:r}});return c.isErr()?Z(c.error):ae(c.value)}async updatePlaybookHotspot(o,r){const c=await this.meltingSpotApi.call({method:$e.PATCH,endpoint:At.hotspot(o.playbookId,o.pageId,o.hotspotId),options:{payload:r}});return c.isErr()?Z(c.error):ae(c.value)}async listPlaybookIntents(o){const r=await this.meltingSpotApi.call({method:$e.GET,endpoint:At.intents(o.playbookId,o.pageId,o.hotspotId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.status?{"status[eq]":o.status}:{}}}});return r.isErr()?Z(r.error):ae(r.value)}async createPlaybookIntent(o,r){const c=await this.meltingSpotApi.call({method:$e.POST,endpoint:At.intents(o.playbookId,o.pageId,o.hotspotId),options:{payload:r}});return c.isErr()?Z(c.error):ae(c.value)}async updatePlaybookIntent(o,r){const c=await this.meltingSpotApi.call({method:$e.PATCH,endpoint:At.intent(o.playbookId,o.pageId,o.hotspotId,o.intentId),options:{payload:r}});return c.isErr()?Z(c.error):ae(c.value)}}const wc={me:"/v1/spots/me"},Ec=50;class pn{static getInstance(){return pn.instance||(pn.instance=new pn),pn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async listSpotsForMe(o){const r=await this.meltingSpotApi.call({method:$e.GET,endpoint:wc.me,options:{query:{page:1,limit:Ec,...o?.spotMemberRole?{"spotMemberRole[eq]":o.spotMemberRole}:{}}}});return r.isErr()?Z(r.error):ae(r.value)}}const Tc={spotMember:{me:"/v1/spotMembers/me"}};class mn{static getInstance(){return mn.instance||(mn.instance=new mn),mn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async getSpotMemberForMe(){const o=await this.meltingSpotApi.call({method:$e.GET,endpoint:Tc.spotMember.me});return o.isErr()?Z(o.error):ae(o.value)}}const yc={spotMemberSsoToken:"/v1/spotMembers/auth/sso/jwt"};class _n{static getInstance(){return _n.instance||(_n.instance=new _n),_n.instance}constructor(){this.meltingSpotApi=It.getInstance()}async generateSsoToken(){const o=await this.meltingSpotApi.call({method:$e.POST,endpoint:yc.spotMemberSsoToken,options:{payload:{}}});return o.isErr()?Z(o.error):ae(o.value.token)}}class vn{static getInstance(){return vn.instance||(vn.instance=new vn),vn.instance}constructor(){this.spotMemberAuthApiService=_n.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}}const Oi=u=>{const o=u.get("utm_source");if(o)return{source:o,medium:u.get("utm_medium")??void 0,campaign:u.get("utm_campaign")??void 0,term:u.get("utm_term")??void 0,content:u.get("utm_content")??void 0}},Mi=u=>u?Object.entries(u).reduce((o,[r,c])=>(c!=null&&(o[`utm_${r}`]=c),o),{}):{},Ic=Ue.getInstance(),Ac=Ht.getInstance(),Lc=vn.getInstance(),Rc={Playbook:gn.getInstance(),Spot:pn.getInstance(),SpotMember:mn.getInstance()},wn=globalThis;wn.MeltingSpot||(wn.MeltingSpot={}),wn.MeltingSpot.Configuration=Ic,wn.MeltingSpot.Auth=Ac,wn.MeltingSpot.Sso=Lc,wn.MeltingSpot.Api=Rc;const Oc="0.1.0",bi=new Ti({appName:"Embed SDK",appVersion:Oc});class Ir{constructor(o){this.content=o}#e=null;#t=null;set onRemove(o){this.#t=o}inject(o){this.remove();const r=wi({input:o,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add("ms-embed"),r.appendChild(this.#e)}remove(){this.#e&&(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),this.#e=null)}}class Mc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.deeplink=o.deeplink?ic({deeplink:o.deeplink,spotId:this.spotId}):null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=this.authToken&&this.authToken.trim().length>0?"/sso/jwt":"",r=new URL(`/spot/${this.spotId}${o}`,ur(this.baseURL)),c=Ei({url:r,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...Mi(this.utmParameters)},rootDocument:this.rootDocument});return c.classList.add("ms-spot"),c}}const xi={READY:"meltingspot:ready",ERROR:"meltingspot:error"},Oe=class Oe{static injectSpotInto(o,r){const{onReady:c,onError:d,...v}=r,{spotId:g,rootDocument:y,msCommunityWebBaseUrl:A}=Ue.getConfiguration({spotId:v.spotId,rootDocument:v.rootDocument,msCommunityWebBaseUrl:v.baseURL});if(!g)throw bi.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const F=new URLSearchParams(window.location.search),H={spotId:g,authToken:v.authToken??F.get("ms_token"),domain:v.domain,deeplink:v.deeplink??F.get("ms_url"),themeMode:v.themeMode,utmParameters:v.utmParameters??Oi(F),baseURL:A,rootDocument:y},U=new Ir(new Mc(H));if(U.inject(o),Oe.embeds.push(U),c||d){const $=U.content.iframe.contentWindow;$&&(Oe.iframeCallbacks.set($,{onReady:c,onError:d}),U.onRemove=q=>{Oe.iframeCallbacks.delete(q)}),Oe.ensureMessageListener()}return bi.log("Spot injected",H,o),U}static clear(){Oe.embeds.forEach(o=>{o.remove()}),Oe.embeds=[],Oe.iframeCallbacks.clear(),Oe.messageListened&&(window.removeEventListener("message",Oe.handleMessageEvent),Oe.messageListened=!1),bi.log("All MeltingSpot embeds cleared")}static handleMessageEvent(o){if(!o.data||typeof o.data!="object"||o.data.type!==xi.READY&&o.data.type!==xi.ERROR)return;const r=o.source,c=Oe.iframeCallbacks.get(r);if(!c)return;const{msCommunityWebBaseUrl:d}=Ue.getConfiguration({});if(d)try{const v=new URL(d).origin;if(o.origin!==v)return}catch{}o.data.type===xi.READY?c.onReady?.():c.onError?.(o.data.error)}static ensureMessageListener(){Oe.messageListened||(window.addEventListener("message",Oe.handleMessageEvent),Oe.messageListened=!0)}};Oe.embeds=[],Oe.messageListened=!1,Oe.iframeCallbacks=new Map;let Di=Oe;const Si=globalThis;Si.MeltingSpot||(Si.MeltingSpot={}),Si.MeltingSpot.Embed=Di;const bc="0.1.0",He=new Ti({appName:"Widget SDK",appVersion:bc});class Uu{constructor(o,r,c){this.content=o,this.rootDocument=r,this.dialogClassname=c,this.dialogElement=null,this.triggerElement=null,this.iframeElement=null,this.currentListener=null}inject({into:o,bind:r,options:c}){this.remove();const d=wi({input:o,rootDocument:this.rootDocument});if(this.dialogElement=wf(this.rootDocument),this.dialogElement.classList.add(this.dialogClassname),this.dialogElement.onclose=()=>this.#t(),d.appendChild(this.dialogElement),r){this.triggerElement=wi({input:r,rootDocument:this.rootDocument});const v=this.open.bind(this,c);this.currentListener=g=>{g.stopPropagation(),g.preventDefault(),v()},this.triggerElement.addEventListener("click",this.currentListener)}}remove(){this.dialogElement&&(this.dialogElement.remove(),this.dialogElement.onclose=null,this.dialogElement=null),this.triggerElement&&(this.currentListener&&this.triggerElement.removeEventListener("click",this.currentListener),this.triggerElement=null,this.currentListener=null)}open(o){this.dialogElement||this.inject({into:this.rootDocument.body}),this.dialogElement&&(this.#e(),this.dialogElement.showModal())}close(){this.dialogElement&&this.dialogElement.close()}#e(){this.dialogElement&&(this.iframeElement=this.dialogElement.appendChild(this.content.iframe))}#t(){this.iframeElement&&(this.iframeElement.remove(),this.iframeElement=null)}}class Ar extends Uu{constructor(o,r){super(o,r,"ms-drawer")}open(o){const{position:r="right"}=o??{};super.open(o),this.dialogElement&&(this.dialogElement.dataset.position=r)}}class Lr extends Uu{constructor(o,r){super(o,r,"ms-modal")}}class xc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.widgetId=nn(o.widgetId),this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=new URL(`/widgets/spot/${this.spotId}/widget/${this.widgetId}`,ur(this.baseURL)),r=Ei({url:o,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,...Mi(this.utmParameters)},rootDocument:this.rootDocument});return r.classList.add("ms-widget"),r}}class Dc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.widgetContentId=nn(o.widgetContentId),this.contentId=nn(o.contentId),this.widgetId=nn(o.widgetId),this.contentType=o.contentType,this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=new URL(`/widgets/spot/${this.spotId}/widgetContent/${this.widgetContentId}`,ur(this.baseURL));o.searchParams.set("widgetId",this.widgetId);const r=Ei({url:o,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,contentId:this.contentId,contentType:this.contentType,...Mi(this.utmParameters)},rootDocument:this.rootDocument});return r.classList.add("ms-widget-content"),r}}const ee=class ee{static injectWidgetInto(o,r){const{spotId:c,rootDocument:d,msCommunityWebBaseUrl:v}=Ue.getConfiguration({spotId:r.spotId,rootDocument:r.rootDocument,msCommunityWebBaseUrl:r.baseURL});if(!c)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widget:g,args:y}=ee.createWidget({...r,spotId:c,rootDocument:d,baseURL:v}),A=new Ir(g);return A.inject(o),ee.widgets.push(A),He.log("Widget injected",ee.cleanupLoggedArgs(y),o),A}static injectWidgetContentInto(o,r){const{spotId:c,rootDocument:d,msCommunityWebBaseUrl:v}=Ue.getConfiguration({spotId:r.spotId,rootDocument:r.rootDocument,msCommunityWebBaseUrl:r.baseURL});if(!c)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widgetContent:g,args:y}=ee.createWidgetContent({...r,spotId:c,rootDocument:d,baseURL:v}),A=new Ir(g);return A.inject(o),ee.widgets.push(A),He.log("WidgetContent injected",ee.cleanupLoggedArgs(y),o),A}static bindWidgetModalTo(o,r){return ee.bindEntityModalTo(o,{type:"Widget",data:r})}static bindWidgetDrawerTo(o,r){return ee.bindEntityDrawerTo(o,{type:"Widget",data:r})}static createWidgetDrawer(o){const{widget:r}=ee.createWidget(o);return He.log("Create Widget drawer",{data:ee.cleanupLoggedArgs(o)}),new Ar(r,o.rootDocument??document)}static createWidgetModal(o){const{widget:r}=ee.createWidget(o);return He.log("Create Widget modal",{data:ee.cleanupLoggedArgs(o)}),new Lr(r,o.rootDocument??document)}static createWidgetEmbed(o){const{widget:r}=ee.createWidget(o),c=new Ir(r);return He.log("Create Widget embed",{data:ee.cleanupLoggedArgs(o)}),c}static clear(){ee.widgets.forEach(o=>{o.remove()}),ee.widgets=[],ee.widgetOptions={},He.log("All Widget SDK MeltingSpot elements were cleared")}static bindEntityDrawerTo(o,r){const{spotId:c,rootDocument:d,msCommunityWebBaseUrl:v}=Ue.getConfiguration({spotId:r.data.spotId,rootDocument:r.data.rootDocument??document,msCommunityWebBaseUrl:r.data.baseURL});if(!c)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let g,y;switch(r.type){case"Widget":{const U=ee.createWidget({...r.data,spotId:c,rootDocument:d,baseURL:v});g=U.widget,y=U.args}break;case"WidgetContent":{const U=ee.createWidgetContent({...r.data,spotId:c,rootDocument:d,baseURL:v});g=U.widgetContent,y=U.args}}const A=new Ar(g,d),F={position:r.data.position},H=r.data.into??d.body;return A.inject({into:H,bind:o,options:F}),ee.widgets.push(A),He.log("Widget bound to drawer",ee.cleanupLoggedArgs(y),F,H,o),A}static bindEntityModalTo(o,r){const{spotId:c,rootDocument:d,msCommunityWebBaseUrl:v}=Ue.getConfiguration({spotId:r.data.spotId,rootDocument:r.data.rootDocument??document,msCommunityWebBaseUrl:r.data.baseURL});if(!c)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let g,y;switch(r.type){case"Widget":{const H=ee.createWidget({...r.data,spotId:c,rootDocument:d,baseURL:v});g=H.widget,y=H.args}break;case"WidgetContent":{const H=ee.createWidgetContent({...r.data,spotId:c,rootDocument:d,baseURL:v});g=H.widgetContent,y=H.args}}const A=new Lr(g,d),F=r.data.into??d.body;return A.inject({into:F,bind:o}),ee.widgets.push(A),He.log("Widget bound to modal",ee.cleanupLoggedArgs(y),F,o),A}static handleMessageEvent(o){if(!o.data||typeof o.data!="object"||o.data.type!=="OpenWidgetContent")return;const r=o.data?.widgetId;if(!r||typeof r!="string"){He.error("widgetId is required in the message event data");return}const c=ee.widgetOptions[r];if(!c){He.error("No widget options found for widgetId",{widgetId:r});return}let d=null;try{d=new URL(c.baseURL).origin}catch{d=null}if(!d||o.origin!==d){He.warn("Ignoring OpenWidgetContent from unexpected origin",{origin:o.origin,expectedOrigin:d});return}const{spotId:v,rootDocument:g,msCommunityWebBaseUrl:y}=Ue.getConfiguration({spotId:c.spotId,rootDocument:c.rootDocument??document,msCommunityWebBaseUrl:c.baseURL}),{widgetContent:A}=ee.createWidgetContent({...c,widgetContentId:o.data.widgetContentId,contentType:o.data.contentType,contentId:o.data.contentId,widgetId:r,spotId:v,rootDocument:g,baseURL:y});o.data.openingIn==="Drawer"?new Ar(A,g).open():o.data.openingIn==="Modal"&&new Lr(A,g).open()}static createWidget(o){const r=new URLSearchParams(window.location.search),c={spotId:o.spotId,widgetId:o.widgetId,authToken:o.authToken,themeMode:o.themeMode,domain:o.domain,rootDocument:o.rootDocument,baseURL:o.baseURL,utmParameters:o.utmParameters??Oi(r)};return ee.widgetOptions[c.widgetId]=c,ee.messageListened||(window.addEventListener("message",ee.handleMessageEvent),ee.messageListened=!0),{widget:new xc(c),args:c}}static createWidgetContent(o){const r=new URLSearchParams(window.location.search),c={spotId:o.spotId,contentId:o.contentId,contentType:o.contentType,widgetContentId:o.widgetContentId,widgetId:o.widgetId,authToken:o.authToken,themeMode:o.themeMode,domain:o.domain,rootDocument:o.rootDocument,baseURL:o.baseURL,utmParameters:o.utmParameters??Oi(r)};return{widgetContent:new Dc(c),args:c}}static cleanupLoggedArgs(o){const{authToken:r,...c}=o;return{...c,authToken:r?"***":void 0}}};ee.widgets=[],ee.messageListened=!1,ee.widgetOptions={};let Rr=ee;const Ui=globalThis;Ui.MeltingSpot||(Ui.MeltingSpot={}),Ui.MeltingSpot.Widget=Rr,kt.Drawer=Ar,kt.Modal=Lr,kt.Widget=Rr,Object.defineProperty(kt,Symbol.toStringTag,{value:"Module"})}));
|
|
33
|
+
}`;var J=af(function(){return oe(f,S+"return "+I).apply(r,l)});if(J.source=I,zo(J))throw J;return J}function y_(e){return se(e).toLowerCase()}function I_(e){return se(e).toUpperCase()}function A_(e,t,n){if(e=se(e),e&&(n||t===r))return ms(e);if(!e||!(t=nt(t)))return e;var i=wt(e),s=wt(t),f=_s(i,s),l=vs(i,s)+1;return Jt(i,f,l).join("")}function L_(e,t,n){if(e=se(e),e&&(n||t===r))return e.slice(0,Es(e)+1);if(!e||!(t=nt(t)))return e;var i=wt(e),s=vs(i,wt(t))+1;return Jt(i,0,s).join("")}function R_(e,t,n){if(e=se(e),e&&(n||t===r))return e.replace(Gi,"");if(!e||!(t=nt(t)))return e;var i=wt(e),s=_s(i,wt(t));return Jt(i,s).join("")}function O_(e,t){var n=ce,i=ie;if(we(t)){var s="separator"in t?t.separator:s;n="length"in t?Q(t.length):n,i="omission"in t?nt(t.omission):i}e=se(e);var f=e.length;if(An(e)){var l=wt(e);f=l.length}if(n>=f)return e;var h=n-Ln(i);if(h<1)return i;var m=l?Jt(l,0,h).join(""):e.slice(0,h);if(s===r)return m+i;if(l&&(h+=m.length-h),qo(s)){if(e.slice(h).search(s)){var E,T=m;for(s.global||(s=so(s.source,se(Fu.exec(s))+"g")),s.lastIndex=0;E=s.exec(T);)var I=E.index;m=m.slice(0,I===r?h:I)}}else if(e.indexOf(nt(s),h)!=h){var R=m.lastIndexOf(s);R>-1&&(m=m.slice(0,R))}return m+i}function M_(e){return e=se(e),e&&Wc.test(e)?e.replace(Nu,rh):e}var b_=Sn(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Zo=aa("toUpperCase");function sf(e,t,n){return e=se(e),t=n?r:t,t===r?Vl(e)?uh(e):Bl(e):e.match(t)||[]}var af=X(function(e,t){try{return et(e,r,t)}catch(n){return zo(n)?n:new B(n)}}),x_=Pt(function(e,t){return at(t,function(n){n=Mt(n),$t(e,n,Bo(e[n],e))}),e});function D_(e){var t=e==null?0:e.length,n=N();return e=t?pe(e,function(i){if(typeof i[1]!="function")throw new ft(g);return[n(i[0]),i[1]]}):[],X(function(i){for(var s=-1;++s<t;){var f=e[s];if(et(f[0],this,i))return et(f[1],this,i)}})}function S_(e){return rd(lt(e,U))}function Jo(e){return function(){return e}}function U_(e,t){return e==null||e!==e?t:e}var $_=ca(),N_=ca(!0);function Je(e){return e}function Xo(e){return Ys(typeof e=="function"?e:lt(e,U))}function P_(e){return Hs(lt(e,U))}function C_(e,t){return Bs(e,lt(t,U))}var F_=X(function(e,t){return function(n){return Vn(n,e,t)}}),W_=X(function(e,t){return function(n){return Vn(e,n,t)}});function Vo(e,t,n){var i=Se(t),s=Xr(t,i);n==null&&!(we(t)&&(s.length||!i.length))&&(n=t,t=e,e=this,s=Xr(t,Se(t)));var f=!(we(n)&&"chain"in n)||!!n.chain,l=Ft(e);return at(s,function(h){var m=t[h];e[h]=m,l&&(e.prototype[h]=function(){var E=this.__chain__;if(f||E){var T=e(this.__wrapped__),I=T.__actions__=Ke(this.__actions__);return I.push({func:m,args:arguments,thisArg:e}),T.__chain__=E,T}return m.apply(e,Gt([this.value()],arguments))})}),e}function Y_(){return Ce._===this&&(Ce._=hh),this}function jo(){}function k_(e){return e=Q(e),X(function(t){return Gs(t,e)})}var H_=xo(pe),B_=xo(ls),G_=xo(eo);function ff(e){return Co(e)?to(Mt(e)):Ed(e)}function z_(e){return function(t){return e==null?r:cn(e,t)}}var q_=ha(),K_=ha(!0);function eu(){return[]}function tu(){return!1}function Q_(){return{}}function Z_(){return""}function J_(){return!0}function X_(e,t){if(e=Q(e),e<1||e>L)return[];var n=V,i=Ye(e,V);t=N(t),e-=V;for(var s=io(i,t);++n<e;)t(n);return s}function V_(e){return z(e)?pe(e,Mt):rt(e)?[e]:Ke(Ma(se(e)))}function j_(e){var t=++ch;return se(e)+t}var e0=ri(function(e,t){return e+t},0),t0=Do("ceil"),n0=ri(function(e,t){return e/t},1),r0=Do("floor");function i0(e){return e&&e.length?Jr(e,Je,mo):r}function o0(e,t){return e&&e.length?Jr(e,N(t,2),mo):r}function u0(e){return gs(e,Je)}function s0(e,t){return gs(e,N(t,2))}function a0(e){return e&&e.length?Jr(e,Je,Eo):r}function f0(e,t){return e&&e.length?Jr(e,N(t,2),Eo):r}var c0=ri(function(e,t){return e*t},1),l0=Do("round"),h0=ri(function(e,t){return e-t},0);function d0(e){return e&&e.length?ro(e,Je):0}function g0(e,t){return e&&e.length?ro(e,N(t,2)):0}return a.after=Pp,a.ary=Wa,a.assign=Im,a.assignIn=ja,a.assignInWith=mi,a.assignWith=Am,a.at=Lm,a.before=Ya,a.bind=Bo,a.bindAll=x_,a.bindKey=ka,a.castArray=Qp,a.chain=Pa,a.chunk=rg,a.compact=ig,a.concat=og,a.cond=D_,a.conforms=S_,a.constant=Jo,a.countBy=dp,a.create=Rm,a.curry=Ha,a.curryRight=Ba,a.debounce=Ga,a.defaults=Om,a.defaultsDeep=Mm,a.defer=Cp,a.delay=Fp,a.difference=ug,a.differenceBy=sg,a.differenceWith=ag,a.drop=fg,a.dropRight=cg,a.dropRightWhile=lg,a.dropWhile=hg,a.fill=dg,a.filter=pp,a.flatMap=vp,a.flatMapDeep=wp,a.flatMapDepth=Ep,a.flatten=Sa,a.flattenDeep=gg,a.flattenDepth=pg,a.flip=Wp,a.flow=$_,a.flowRight=N_,a.fromPairs=mg,a.functions=Nm,a.functionsIn=Pm,a.groupBy=Tp,a.initial=vg,a.intersection=wg,a.intersectionBy=Eg,a.intersectionWith=Tg,a.invert=Fm,a.invertBy=Wm,a.invokeMap=Ip,a.iteratee=Xo,a.keyBy=Ap,a.keys=Se,a.keysIn=Ze,a.map=ci,a.mapKeys=km,a.mapValues=Hm,a.matches=P_,a.matchesProperty=C_,a.memoize=hi,a.merge=Bm,a.mergeWith=ef,a.method=F_,a.methodOf=W_,a.mixin=Vo,a.negate=di,a.nthArg=k_,a.omit=Gm,a.omitBy=zm,a.once=Yp,a.orderBy=Lp,a.over=H_,a.overArgs=kp,a.overEvery=B_,a.overSome=G_,a.partial=Go,a.partialRight=za,a.partition=Rp,a.pick=qm,a.pickBy=tf,a.property=ff,a.propertyOf=z_,a.pull=Lg,a.pullAll=$a,a.pullAllBy=Rg,a.pullAllWith=Og,a.pullAt=Mg,a.range=q_,a.rangeRight=K_,a.rearg=Hp,a.reject=bp,a.remove=bg,a.rest=Bp,a.reverse=ko,a.sampleSize=Dp,a.set=Qm,a.setWith=Zm,a.shuffle=Sp,a.slice=xg,a.sortBy=Np,a.sortedUniq=Cg,a.sortedUniqBy=Fg,a.split=v_,a.spread=Gp,a.tail=Wg,a.take=Yg,a.takeRight=kg,a.takeRightWhile=Hg,a.takeWhile=Bg,a.tap=ip,a.throttle=zp,a.thru=fi,a.toArray=Ja,a.toPairs=nf,a.toPairsIn=rf,a.toPath=V_,a.toPlainObject=Va,a.transform=Jm,a.unary=qp,a.union=Gg,a.unionBy=zg,a.unionWith=qg,a.uniq=Kg,a.uniqBy=Qg,a.uniqWith=Zg,a.unset=Xm,a.unzip=Ho,a.unzipWith=Na,a.update=Vm,a.updateWith=jm,a.values=Nn,a.valuesIn=e_,a.without=Jg,a.words=sf,a.wrap=Kp,a.xor=Xg,a.xorBy=Vg,a.xorWith=jg,a.zip=ep,a.zipObject=tp,a.zipObjectDeep=np,a.zipWith=rp,a.entries=nf,a.entriesIn=rf,a.extend=ja,a.extendWith=mi,Vo(a,a),a.add=e0,a.attempt=af,a.camelCase=i_,a.capitalize=of,a.ceil=t0,a.clamp=t_,a.clone=Zp,a.cloneDeep=Xp,a.cloneDeepWith=Vp,a.cloneWith=Jp,a.conformsTo=jp,a.deburr=uf,a.defaultTo=U_,a.divide=n0,a.endsWith=o_,a.eq=Tt,a.escape=u_,a.escapeRegExp=s_,a.every=gp,a.find=mp,a.findIndex=xa,a.findKey=bm,a.findLast=_p,a.findLastIndex=Da,a.findLastKey=xm,a.floor=r0,a.forEach=Ca,a.forEachRight=Fa,a.forIn=Dm,a.forInRight=Sm,a.forOwn=Um,a.forOwnRight=$m,a.get=Ko,a.gt=em,a.gte=tm,a.has=Cm,a.hasIn=Qo,a.head=Ua,a.identity=Je,a.includes=yp,a.indexOf=_g,a.inRange=n_,a.invoke=Ym,a.isArguments=dn,a.isArray=z,a.isArrayBuffer=nm,a.isArrayLike=Qe,a.isArrayLikeObject=ye,a.isBoolean=rm,a.isBuffer=Xt,a.isDate=im,a.isElement=om,a.isEmpty=um,a.isEqual=sm,a.isEqualWith=am,a.isError=zo,a.isFinite=fm,a.isFunction=Ft,a.isInteger=qa,a.isLength=gi,a.isMap=Ka,a.isMatch=cm,a.isMatchWith=lm,a.isNaN=hm,a.isNative=dm,a.isNil=pm,a.isNull=gm,a.isNumber=Qa,a.isObject=we,a.isObjectLike=Ee,a.isPlainObject=ir,a.isRegExp=qo,a.isSafeInteger=mm,a.isSet=Za,a.isString=pi,a.isSymbol=rt,a.isTypedArray=$n,a.isUndefined=_m,a.isWeakMap=vm,a.isWeakSet=wm,a.join=yg,a.kebabCase=a_,a.last=dt,a.lastIndexOf=Ig,a.lowerCase=f_,a.lowerFirst=c_,a.lt=Em,a.lte=Tm,a.max=i0,a.maxBy=o0,a.mean=u0,a.meanBy=s0,a.min=a0,a.minBy=f0,a.stubArray=eu,a.stubFalse=tu,a.stubObject=Q_,a.stubString=Z_,a.stubTrue=J_,a.multiply=c0,a.nth=Ag,a.noConflict=Y_,a.noop=jo,a.now=li,a.pad=l_,a.padEnd=h_,a.padStart=d_,a.parseInt=g_,a.random=r_,a.reduce=Op,a.reduceRight=Mp,a.repeat=p_,a.replace=m_,a.result=Km,a.round=l0,a.runInContext=p,a.sample=xp,a.size=Up,a.snakeCase=__,a.some=$p,a.sortedIndex=Dg,a.sortedIndexBy=Sg,a.sortedIndexOf=Ug,a.sortedLastIndex=$g,a.sortedLastIndexBy=Ng,a.sortedLastIndexOf=Pg,a.startCase=w_,a.startsWith=E_,a.subtract=h0,a.sum=d0,a.sumBy=g0,a.template=T_,a.times=X_,a.toFinite=Wt,a.toInteger=Q,a.toLength=Xa,a.toLower=y_,a.toNumber=gt,a.toSafeInteger=ym,a.toString=se,a.toUpper=I_,a.trim=A_,a.trimEnd=L_,a.trimStart=R_,a.truncate=O_,a.unescape=M_,a.uniqueId=j_,a.upperCase=b_,a.upperFirst=Zo,a.each=Ca,a.eachRight=Fa,a.first=Ua,Vo(a,(function(){var e={};return Rt(a,function(t,n){fe.call(a.prototype,n)||(e[n]=t)}),e})(),{chain:!1}),a.VERSION=c,at(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){a[e].placeholder=a}),at(["drop","take"],function(e,t){te.prototype[e]=function(n){n=n===r?1:xe(Q(n),0);var i=this.__filtered__&&!t?new te(this):this.clone();return i.__filtered__?i.__takeCount__=Ye(n,i.__takeCount__):i.__views__.push({size:Ye(n,V),type:e+(i.__dir__<0?"Right":"")}),i},te.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),at(["filter","map","takeWhile"],function(e,t){var n=t+1,i=n==W||n==O;te.prototype[e]=function(s){var f=this.clone();return f.__iteratees__.push({iteratee:N(s,3),type:n}),f.__filtered__=f.__filtered__||i,f}}),at(["head","last"],function(e,t){var n="take"+(t?"Right":"");te.prototype[e]=function(){return this[n](1).value()[0]}}),at(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");te.prototype[e]=function(){return this.__filtered__?new te(this):this[n](1)}}),te.prototype.compact=function(){return this.filter(Je)},te.prototype.find=function(e){return this.filter(e).head()},te.prototype.findLast=function(e){return this.reverse().find(e)},te.prototype.invokeMap=X(function(e,t){return typeof e=="function"?new te(this):this.map(function(n){return Vn(n,e,t)})}),te.prototype.reject=function(e){return this.filter(di(N(e)))},te.prototype.slice=function(e,t){e=Q(e);var n=this;return n.__filtered__&&(e>0||t<0)?new te(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=Q(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},te.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},te.prototype.toArray=function(){return this.take(V)},Rt(te.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),s=a[i?"take"+(t=="last"?"Right":""):t],f=i||/^find/.test(t);s&&(a.prototype[t]=function(){var l=this.__wrapped__,h=i?[1]:arguments,m=l instanceof te,E=h[0],T=m||z(l),I=function(j){var re=s.apply(a,Gt([j],h));return i&&R?re[0]:re};T&&n&&typeof E=="function"&&E.length!=1&&(m=T=!1);var R=this.__chain__,S=!!this.__actions__.length,P=f&&!R,J=m&&!S;if(!f&&T){l=J?l:new te(this);var C=e.apply(l,h);return C.__actions__.push({func:fi,args:[I],thisArg:r}),new ct(C,R)}return P&&J?e.apply(this,h):(C=this.thru(I),P?i?C.value()[0]:C.value():C)})}),at(["pop","push","shift","sort","splice","unshift"],function(e){var t=Nr[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);a.prototype[e]=function(){var s=arguments;if(i&&!this.__chain__){var f=this.value();return t.apply(z(f)?f:[],s)}return this[n](function(l){return t.apply(z(l)?l:[],s)})}}),Rt(te.prototype,function(e,t){var n=a[t];if(n){var i=n.name+"";fe.call(bn,i)||(bn[i]=[]),bn[i].push({name:t,func:n})}}),bn[ni(r,he).name]=[{name:"wrapper",func:r}],te.prototype.clone=Mh,te.prototype.reverse=bh,te.prototype.value=xh,a.prototype.at=op,a.prototype.chain=up,a.prototype.commit=sp,a.prototype.next=ap,a.prototype.plant=cp,a.prototype.reverse=lp,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=hp,a.prototype.first=a.prototype.head,zn&&(a.prototype[zn]=fp),a}),Rn=sh();on?((on.exports=Rn)._=Rn,Ji._=Rn):Ce._=Rn}).call(jf)})(Fn,Fn.exports)),Fn.exports}ec();const tc="1.0.0";class Ti{constructor(o){this.debug=!1,this.debug=o?.debug??!1,this.appName=o?.appName,this.appVersion=o?.appVersion}log(o,...r){this.debug&&this.print(o,"info",r)}warn(o,...r){this.print(o,"warn",r)}error(o,...r){this.print(o,"error",r)}print(o,r,c){const g=[`[${["MeltingSpot",this.appName,this.appVersion].filter(Boolean).join(" - ")}] ${o}`];c.length&&g.push(...c),console[r](...g)}}const nc=new Ti({appName:"Core SDK",appVersion:tc}),nn=u=>u.toLowerCase().replace(/[^a-z0-9-]/g,""),rc=["/user"],ic=({deeplink:u,spotId:o})=>{try{const r=new URL(u,"https://unused.com");let c=r.pathname;return r.search&&(c+=r.search),r.hash&&(c+=r.hash),rc.some(d=>c.startsWith(d))||(c=`/spot/${o}/${_f(c)}`),c}catch(r){return nc.warn("Failed to parse deeplink URL",r),null}},oc=[/(^|\.)meltingspot\.io$/i],yi=u=>{let o;try{const v=ur(u);o=new URL(v)}catch{throw new Error(`Invalid baseURL: ${u}`)}const r=o.hostname==="localhost"||o.hostname==="127.0.0.1",c=o.protocol==="https:",d=oc.some(v=>v.test(o.hostname));if(!r&&(!c||!d))throw new Error(`Untrusted baseURL origin: ${o.origin}`);return o.origin},uc={msApiBaseUrl:"https://openapi.meltingspot.io/",msCommunityWebBaseUrl:"https://go.meltingspot.io/",ssoToken:void 0,spotId:"",rootDocument:globalThis.document};class Ue{constructor(){this.configuration=uc}static getInstance(){return Ue.instance||(Ue.instance=new Ue),Ue.instance}setConfiguration(o){this.configuration={...this.configuration,...o}}static getConfiguration(o={}){return{...Ue.getInstance().configuration,...o}}}const Eu="%[a-f0-9]{2}",Tu=new RegExp("("+Eu+")|([^%]+?)","gi"),yu=new RegExp("("+Eu+")+","gi");function Ii(u,o){try{return[decodeURIComponent(u.join(""))]}catch{}if(u.length===1)return u;o=o||1;const r=u.slice(0,o),c=u.slice(o);return Array.prototype.concat.call([],Ii(r),Ii(c))}function sc(u){try{return decodeURIComponent(u)}catch{let o=u.match(Tu)||[];for(let r=1;r<o.length;r++)u=Ii(o,r).join(""),o=u.match(Tu)||[];return u}}function ac(u){const o={"%FE%FF":"��","%FF%FE":"��"};let r=yu.exec(u);for(;r;){try{o[r[0]]=decodeURIComponent(r[0])}catch{const d=sc(r[0]);d!==r[0]&&(o[r[0]]=d)}r=yu.exec(u)}o["%C2"]="�";const c=Object.keys(o);for(const d of c)u=u.replace(new RegExp(d,"g"),o[d]);return u}function fc(u){if(typeof u!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof u+"`");try{return decodeURIComponent(u)}catch{return ac(u)}}function cc(u,o){const r={};if(Array.isArray(o))for(const c of o){const d=Object.getOwnPropertyDescriptor(u,c);d?.enumerable&&Object.defineProperty(r,c,d)}else for(const c of Reflect.ownKeys(u)){const d=Object.getOwnPropertyDescriptor(u,c);if(d.enumerable){const v=u[c];o(c,v,u)&&Object.defineProperty(r,c,d)}}return r}function Iu(u,o){if(!(typeof u=="string"&&typeof o=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(u===""||o==="")return[];const r=u.indexOf(o);return r===-1?[]:[u.slice(0,r),u.slice(r+o.length)]}const lc=u=>u==null,hc=u=>encodeURIComponent(u).replaceAll(/[!'()*]/g,o=>`%${o.charCodeAt(0).toString(16).toUpperCase()}`),Ai=Symbol("encodeFragmentIdentifier");function dc(u){switch(u.arrayFormat){case"index":return o=>(r,c)=>{const d=r.length;return c===void 0||u.skipNull&&c===null||u.skipEmptyString&&c===""?r:c===null?[...r,[Ae(o,u),"[",d,"]"].join("")]:[...r,[Ae(o,u),"[",Ae(d,u),"]=",Ae(c,u)].join("")]};case"bracket":return o=>(r,c)=>c===void 0||u.skipNull&&c===null||u.skipEmptyString&&c===""?r:c===null?[...r,[Ae(o,u),"[]"].join("")]:[...r,[Ae(o,u),"[]=",Ae(c,u)].join("")];case"colon-list-separator":return o=>(r,c)=>c===void 0||u.skipNull&&c===null||u.skipEmptyString&&c===""?r:c===null?[...r,[Ae(o,u),":list="].join("")]:[...r,[Ae(o,u),":list=",Ae(c,u)].join("")];case"comma":case"separator":case"bracket-separator":{const o=u.arrayFormat==="bracket-separator"?"[]=":"=";return r=>(c,d)=>d===void 0||u.skipNull&&d===null||u.skipEmptyString&&d===""?c:(d=d===null?"":d,c.length===0?[[Ae(r,u),o,Ae(d,u)].join("")]:[[c,Ae(d,u)].join(u.arrayFormatSeparator)])}default:return o=>(r,c)=>c===void 0||u.skipNull&&c===null||u.skipEmptyString&&c===""?r:c===null?[...r,Ae(o,u)]:[...r,[Ae(o,u),"=",Ae(c,u)].join("")]}}function gc(u){let o;switch(u.arrayFormat){case"index":return(r,c,d)=>{if(o=/\[(\d*)]$/.exec(r),r=r.replace(/\[\d*]$/,""),!o){d[r]=c;return}d[r]===void 0&&(d[r]={}),d[r][o[1]]=c};case"bracket":return(r,c,d)=>{if(o=/(\[])$/.exec(r),r=r.replace(/\[]$/,""),!o){d[r]=c;return}if(d[r]===void 0){d[r]=[c];return}d[r]=[...d[r],c]};case"colon-list-separator":return(r,c,d)=>{if(o=/(:list)$/.exec(r),r=r.replace(/:list$/,""),!o){d[r]=c;return}if(d[r]===void 0){d[r]=[c];return}d[r]=[...d[r],c]};case"comma":case"separator":return(r,c,d)=>{const v=typeof c=="string"&&c.includes(u.arrayFormatSeparator),g=typeof c=="string"&&!v&&bt(c,u).includes(u.arrayFormatSeparator);c=g?bt(c,u):c;const y=v||g?c.split(u.arrayFormatSeparator).map(A=>bt(A,u)):c===null?c:bt(c,u);d[r]=y};case"bracket-separator":return(r,c,d)=>{const v=/(\[])$/.test(r);if(r=r.replace(/\[]$/,""),!v){d[r]=c&&bt(c,u);return}const g=c===null?[]:bt(c,u).split(u.arrayFormatSeparator);if(d[r]===void 0){d[r]=g;return}d[r]=[...d[r],...g]};default:return(r,c,d)=>{if(d[r]===void 0){d[r]=c;return}d[r]=[...[d[r]].flat(),c]}}}function Au(u){if(typeof u!="string"||u.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function Ae(u,o){return o.encode?o.strict?hc(u):encodeURIComponent(u):u}function bt(u,o){return o.decode?fc(u):u}function Lu(u){return Array.isArray(u)?u.sort():typeof u=="object"?Lu(Object.keys(u)).sort((o,r)=>Number(o)-Number(r)).map(o=>u[o]):u}function Ru(u){const o=u.indexOf("#");return o!==-1&&(u=u.slice(0,o)),u}function pc(u){let o="";const r=u.indexOf("#");return r!==-1&&(o=u.slice(r)),o}function Ou(u,o,r){return r==="string"&&typeof u=="string"?u:typeof r=="function"&&typeof u=="string"?r(u):r==="boolean"&&u===null?!0:r==="boolean"&&u!==null&&(u.toLowerCase()==="true"||u.toLowerCase()==="false")?u.toLowerCase()==="true":r==="boolean"&&u!==null&&(u.toLowerCase()==="1"||u.toLowerCase()==="0")?u.toLowerCase()==="1":r==="string[]"&&o.arrayFormat!=="none"&&typeof u=="string"?[u]:r==="number[]"&&o.arrayFormat!=="none"&&!Number.isNaN(Number(u))&&typeof u=="string"&&u.trim()!==""?[Number(u)]:r==="number"&&!Number.isNaN(Number(u))&&typeof u=="string"&&u.trim()!==""?Number(u):o.parseBooleans&&u!==null&&(u.toLowerCase()==="true"||u.toLowerCase()==="false")?u.toLowerCase()==="true":o.parseNumbers&&!Number.isNaN(Number(u))&&typeof u=="string"&&u.trim()!==""?Number(u):u}function Li(u){u=Ru(u);const o=u.indexOf("?");return o===-1?"":u.slice(o+1)}function Ri(u,o){o={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...o},Au(o.arrayFormatSeparator);const r=gc(o),c=Object.create(null);if(typeof u!="string"||(u=u.trim().replace(/^[?#&]/,""),!u))return c;for(const d of u.split("&")){if(d==="")continue;const v=o.decode?d.replaceAll("+"," "):d;let[g,y]=Iu(v,"=");g===void 0&&(g=v),y=y===void 0?null:["comma","separator","bracket-separator"].includes(o.arrayFormat)?y:bt(y,o),r(bt(g,o),y,c)}for(const[d,v]of Object.entries(c))if(typeof v=="object"&&v!==null&&o.types[d]!=="string")for(const[g,y]of Object.entries(v)){const A=o.types[d]?o.types[d].replace("[]",""):void 0;v[g]=Ou(y,o,A)}else typeof v=="object"&&v!==null&&o.types[d]==="string"?c[d]=Object.values(v).join(o.arrayFormatSeparator):c[d]=Ou(v,o,o.types[d]);return o.sort===!1?c:(o.sort===!0?Object.keys(c).sort():Object.keys(c).sort(o.sort)).reduce((d,v)=>{const g=c[v];return d[v]=g&&typeof g=="object"&&!Array.isArray(g)?Lu(g):g,d},Object.create(null))}function Mu(u,o){if(!u)return"";o={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...o},Au(o.arrayFormatSeparator);const r=g=>o.skipNull&&lc(u[g])||o.skipEmptyString&&u[g]==="",c=dc(o),d={};for(const[g,y]of Object.entries(u))r(g)||(d[g]=y);const v=Object.keys(d);return o.sort!==!1&&v.sort(o.sort),v.map(g=>{const y=u[g];return y===void 0?"":y===null?Ae(g,o):Array.isArray(y)?y.length===0&&o.arrayFormat==="bracket-separator"?Ae(g,o)+"[]":y.reduce(c(g),[]).join("&"):Ae(g,o)+"="+Ae(y,o)}).filter(g=>g.length>0).join("&")}function bu(u,o){o={decode:!0,...o};let[r,c]=Iu(u,"#");return r===void 0&&(r=u),{url:r?.split("?")?.[0]??"",query:Ri(Li(u),o),...o&&o.parseFragmentIdentifier&&c?{fragmentIdentifier:bt(c,o)}:{}}}function xu(u,o){o={encode:!0,strict:!0,[Ai]:!0,...o};const r=Ru(u.url).split("?")[0]||"",c=Li(u.url),d={...Ri(c,{sort:!1,...o}),...u.query};let v=Mu(d,o);v&&=`?${v}`;let g=pc(u.url);if(typeof u.fragmentIdentifier=="string"){const y=new URL(r);y.hash=u.fragmentIdentifier,g=o[Ai]?y.hash:`#${u.fragmentIdentifier}`}return`${r}${v}${g}`}function Du(u,o,r){r={parseFragmentIdentifier:!0,[Ai]:!1,...r};const{url:c,query:d,fragmentIdentifier:v}=bu(u,r);return xu({url:c,query:cc(d,o),fragmentIdentifier:v},r)}function mc(u,o,r){const c=Array.isArray(o)?d=>!o.includes(d):(d,v)=>!o(d,v);return Du(u,c,r)}const _c=Object.freeze(Object.defineProperty({__proto__:null,exclude:mc,extract:Li,parse:Ri,parseUrl:bu,pick:Du,stringify:Mu,stringifyUrl:xu},Symbol.toStringTag,{value:"Module"}));class qe extends Error{constructor(o,r){super(`HTTP Error ${o}${r?`: ${r}`:""}`),this.code=o,this.name="HttpError",Object.setPrototypeOf(this,qe.prototype)}}var $e=(u=>(u.GET="GET",u.PATCH="PATCH",u.POST="POST",u))($e||{});class vc{constructor(){this.headers={}}setHeaders(o){this.headers=o}async get(o){try{const r=o.query?`${o.url}?${this.serializeQuery(o.query)}`:o.url,c=await fetch(r,{headers:{...this.headers,...o.headers,"Content-Type":"application/json"}});return c.ok?ae(await c.json()):Z(new qe(c.status,await c.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return Z(new qe(ut.INTERNAL_SERVER_ERROR,c))}}async post(o){try{const r=await fetch(o.url,{method:"POST",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload)});return r.ok?ae(await r.json()):Z(new qe(r.status,await r.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return Z(new qe(ut.INTERNAL_SERVER_ERROR,c))}}async patch(o){try{const r=await fetch(o.url,{method:"PATCH",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload)});return r.ok?ae(await r.json()):Z(new qe(r.status,await r.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return Z(new qe(ut.INTERNAL_SERVER_ERROR,c))}}serializeQuery(o){if(typeof o=="string")return o;if(typeof o=="object")for(const r in o)o[r]===void 0&&delete o[r];return o=_c.stringify(o,{arrayFormat:"none"}),o}}const Tr={accessToken:{email:"/v1/auth/accessToken/email",sso:{jwt:"/v1/auth/accessToken/sso/jwt"}},refreshAccessToken:"/v1/auth/accessToken~refresh",password:{reset:"/v1/auth/password~reset"}};class Ht extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return Ht.instance||(Ht.instance=new Ht),Ht.instance}async loginWithPassword(o,r){const c=await this.callApi({endpoint:Tr.accessToken.email,method:"POST",body:{email:o,password:r},withSpotId:!0});if(c.isErr())return Z(c.error);const{accessToken:d,refreshToken:v}=c.value;return this.setTokens(d.token,v.token),ae({accessToken:d.token,refreshToken:v.token})}async loginWithSsoToken(o){const r=await this.callApi({endpoint:Tr.accessToken.sso.jwt,method:"POST",body:{token:o},withSpotId:!0});if(r.isErr())return Z(r.error);const{accessToken:c,refreshToken:d}=r.value;return this.setTokens(c.token,d.token),ae({accessToken:c.token,refreshToken:d.token})}loginWithAuthTokens(o,r){return this.setTokens(o,r),{accessToken:o,refreshToken:r}}resetPassword(o){return this.callApi({endpoint:Tr.password.reset,method:"POST",body:{email:o}})}async refresh(){const o=await this.callApi({endpoint:Tr.refreshAccessToken,method:"POST",body:{refreshToken:this.refreshToken}});if(o.isErr())return Z(o.error);const{accessToken:r,refreshToken:c}=o.value;return this.setTokens(r.token,c.token),ae({accessToken:r.token,refreshToken:c.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(o,r){if(this.accessToken!==o||this.refreshToken!==r){this.accessToken=o,this.refreshToken=r;const c=new CustomEvent("auth:tokens-updated",{detail:{accessToken:o,refreshToken:r}});this.dispatchEvent(c)}}async callApi(o){try{const{spotId:r,msApiBaseUrl:c}=Ue.getConfiguration(),d=vi(o.endpoint,c),v={"Content-Type":"application/json",...o.headers};o.withSpotId&&r&&(v[Su.SpotId]=r);const g=await fetch(d,{method:o.method,body:o.body?JSON.stringify(o.body):void 0,headers:v});if(!g.ok)return Z(new qe(g.status,g.statusText));if(g.status===ut.NO_CONTENT)return ae(void 0);const y=await g.json();return ae(y)}catch(r){return Z(new qe(ut.INTERNAL_SERVER_ERROR,r instanceof Error?r.message:String(r)))}}}var Su=(u=>(u.Authorization="Authorization",u.SpotId="x-spotid",u))(Su||{});class It{constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=Ht.getInstance(),this.httpService=new vc}static getInstance(){return It.instance||(It.instance=new It),It.instance}static buildAuthenticatedRequest(o){const{msApiBaseUrl:r,spotId:c}=Ue.getConfiguration(),d=vi(o,r),v=Ht.getInstance().getAccessToken();if(!v)return Z(new Error("Not authenticated"));const g={"Content-Type":"application/json",Authorization:`Bearer ${v}`};return c&&(g["x-spotid"]=c),ae({url:d,headers:g})}static async stream(o,r,c){const d=It.buildAuthenticatedRequest(o);if(d.isErr())return Z(d.error);const{url:v,headers:g}=d.value;try{const y=await fetch(v,{method:"POST",headers:g,...r!==void 0?{body:JSON.stringify(r)}:{},...c?{signal:c}:{}});if(!y.ok){const A=await y.text();return Z(new Error(`HTTP ${y.status}: ${A}`))}return y.body?ae(y.body):Z(new Error("Response body is empty"))}catch(y){const A=y instanceof Error?y.message:"Unknown error";return Z(y instanceof Error?y:new Error(A))}}get pendingCount(){return this.queue.length}enqueue(o){return new Promise(r=>{const c=async()=>{try{const d=await o();r(d)}catch(d){r(Z(new qe(ut.INTERNAL_SERVER_ERROR,d instanceof Error?d.message:"Unknown error")))}};this.queue.push(c),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){const o=this.queue.shift();if(!o)break;await o()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){const o=this.isPaused;this.isPaused=!1,o&&this.processQueue()}async call(o){return this.enqueue(async()=>{const r=async()=>{const{spotId:d,msApiBaseUrl:v}=Ue.getConfiguration(),g={...o.options?.headers??{}};d&&(g["x-spotid"]=d);const y=this.authService.getAccessToken(),{requiresAuth:A=!0}=o;if(!y&&A)return Z(new qe(ut.UNAUTHORIZED));y&&(g.Authorization=`Bearer ${y}`);const F=vi(o.endpoint,v);switch(o.method){case $e.GET:return this.httpService.get({...o.options??{},headers:g,url:F});case $e.PATCH:return this.httpService.patch({...o.options??{},headers:g,url:F});case $e.POST:return this.httpService.post({...o.options??{},headers:g,url:F});default:return Z(new qe(ut.METHOD_NOT_ALLOWED,"Method not allowed"))}};let c=await r();if(c.isErr()&&c.error.code===ut.UNAUTHORIZED){const d=await this.authService.refresh();if(d.isErr())return Z(new qe(ut.UNAUTHORIZED,d.error.message));c=await r()}return c})}}const At={playbooks:"/v1/playbooks",pages:u=>`/v1/playbooks/${u}/pages`,hotspots:(u,o)=>`/v1/playbooks/${u}/pages/${o}/hotspots`,hotspot:(u,o,r)=>`/v1/playbooks/${u}/pages/${o}/hotspots/${r}`,accessibleIntents:(u,o)=>`/v1/playbooks/${u}/pages/${o}/accessibleIntents`,intents:(u,o,r)=>`/v1/playbooks/${u}/pages/${o}/hotspots/${r}/intents`,intent:(u,o,r,c)=>`/v1/playbooks/${u}/pages/${o}/hotspots/${r}/intents/${c}`},yr=50;class gn{static getInstance(){return gn.instance||(gn.instance=new gn),gn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async listPlaybooks(o){const r=await this.meltingSpotApi.call({method:$e.GET,endpoint:At.playbooks,options:{query:{page:o?.page??1,limit:o?.limit??yr,...o?.domain?{"domain[eq]":o.domain}:{}}}});return r.isErr()?Z(r.error):ae(r.value)}async listPlaybookPages(o){const r=await this.meltingSpotApi.call({method:$e.GET,endpoint:At.pages(o.playbookId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.url?{"url[eq]":o.url}:{}}}});return r.isErr()?Z(r.error):ae(r.value)}async createPlaybookPage(o,r){const c=await this.meltingSpotApi.call({method:$e.POST,endpoint:At.pages(o.playbookId),options:{payload:r}});return c.isErr()?Z(c.error):ae(c.value)}async listAccessiblePlaybookIntents(o){const r=await this.meltingSpotApi.call({method:$e.GET,endpoint:At.accessibleIntents(o.playbookId,o.pageId),options:{query:{...o.domain?{"domain[eq]":o.domain}:{}}}});return r.isErr()?Z(r.error):ae(r.value)}async listPlaybookHotspots(o){const r=await this.meltingSpotApi.call({method:$e.GET,endpoint:At.hotspots(o.playbookId,o.pageId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.intentStatus?{"intentStatus[eq]":o.intentStatus}:{},...o.widgetType?{"widgetType[eq]":o.widgetType}:{}}}});return r.isErr()?Z(r.error):ae(r.value)}async createPlaybookHotspot(o,r){const c=await this.meltingSpotApi.call({method:$e.POST,endpoint:At.hotspots(o.playbookId,o.pageId),options:{payload:r}});return c.isErr()?Z(c.error):ae(c.value)}async updatePlaybookHotspot(o,r){const c=await this.meltingSpotApi.call({method:$e.PATCH,endpoint:At.hotspot(o.playbookId,o.pageId,o.hotspotId),options:{payload:r}});return c.isErr()?Z(c.error):ae(c.value)}async listPlaybookIntents(o){const r=await this.meltingSpotApi.call({method:$e.GET,endpoint:At.intents(o.playbookId,o.pageId,o.hotspotId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.status?{"status[eq]":o.status}:{}}}});return r.isErr()?Z(r.error):ae(r.value)}async createPlaybookIntent(o,r){const c=await this.meltingSpotApi.call({method:$e.POST,endpoint:At.intents(o.playbookId,o.pageId,o.hotspotId),options:{payload:r}});return c.isErr()?Z(c.error):ae(c.value)}async updatePlaybookIntent(o,r){const c=await this.meltingSpotApi.call({method:$e.PATCH,endpoint:At.intent(o.playbookId,o.pageId,o.hotspotId,o.intentId),options:{payload:r}});return c.isErr()?Z(c.error):ae(c.value)}}const wc={me:"/v1/spots/me"},Ec=50;class pn{static getInstance(){return pn.instance||(pn.instance=new pn),pn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async listSpotsForMe(o){const r=await this.meltingSpotApi.call({method:$e.GET,endpoint:wc.me,options:{query:{page:1,limit:Ec,...o?.spotMemberRole?{"spotMemberRole[eq]":o.spotMemberRole}:{}}}});return r.isErr()?Z(r.error):ae(r.value)}}const Tc={spotMember:{me:"/v1/spotMembers/me"}};class mn{static getInstance(){return mn.instance||(mn.instance=new mn),mn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async getSpotMemberForMe(){const o=await this.meltingSpotApi.call({method:$e.GET,endpoint:Tc.spotMember.me});return o.isErr()?Z(o.error):ae(o.value)}}const yc={spotMemberSsoToken:"/v1/spotMembers/auth/sso/jwt"};class _n{static getInstance(){return _n.instance||(_n.instance=new _n),_n.instance}constructor(){this.meltingSpotApi=It.getInstance()}async generateSsoToken(){const o=await this.meltingSpotApi.call({method:$e.POST,endpoint:yc.spotMemberSsoToken,options:{payload:{}}});return o.isErr()?Z(o.error):ae(o.value.token)}}class vn{static getInstance(){return vn.instance||(vn.instance=new vn),vn.instance}constructor(){this.spotMemberAuthApiService=_n.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}}const Oi=u=>{const o=u.get("utm_source");if(o)return{source:o,medium:u.get("utm_medium")??void 0,campaign:u.get("utm_campaign")??void 0,term:u.get("utm_term")??void 0,content:u.get("utm_content")??void 0}},Mi=u=>u?Object.entries(u).reduce((o,[r,c])=>(c!=null&&(o[`utm_${r}`]=c),o),{}):{},Ic=Ue.getInstance(),Ac=Ht.getInstance(),Lc=vn.getInstance(),Rc={Playbook:gn.getInstance(),Spot:pn.getInstance(),SpotMember:mn.getInstance()},wn=globalThis;wn.MeltingSpot||(wn.MeltingSpot={}),wn.MeltingSpot.Configuration=Ic,wn.MeltingSpot.Auth=Ac,wn.MeltingSpot.Sso=Lc,wn.MeltingSpot.Api=Rc;const Oc="1.0.0",bi=new Ti({appName:"Embed SDK",appVersion:Oc});class Ir{constructor(o){this.content=o}#e=null;#t=null;set onRemove(o){this.#t=o}inject(o){this.remove();const r=wi({input:o,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add("ms-embed"),r.appendChild(this.#e)}remove(){this.#e&&(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),this.#e=null)}}class Mc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.deeplink=o.deeplink?ic({deeplink:o.deeplink,spotId:this.spotId}):null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=this.authToken&&this.authToken.trim().length>0?"/sso/jwt":"",r=new URL(`/spot/${this.spotId}${o}`,ur(this.baseURL)),c=Ei({url:r,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...Mi(this.utmParameters)},rootDocument:this.rootDocument});return c.classList.add("ms-spot"),c}}const xi={READY:"meltingspot:ready",ERROR:"meltingspot:error"},Oe=class Oe{static injectSpotInto(o,r){const{onReady:c,onError:d,...v}=r,{spotId:g,rootDocument:y,msCommunityWebBaseUrl:A}=Ue.getConfiguration({spotId:v.spotId,rootDocument:v.rootDocument,msCommunityWebBaseUrl:v.baseURL});if(!g)throw bi.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const F=new URLSearchParams(window.location.search),H={spotId:g,authToken:v.authToken??F.get("ms_token"),domain:v.domain,deeplink:v.deeplink??F.get("ms_url"),themeMode:v.themeMode,utmParameters:v.utmParameters??Oi(F),baseURL:A,rootDocument:y},U=new Ir(new Mc(H));if(U.inject(o),Oe.embeds.push(U),c||d){const $=U.content.iframe.contentWindow;$&&(Oe.iframeCallbacks.set($,{onReady:c,onError:d}),U.onRemove=q=>{Oe.iframeCallbacks.delete(q)}),Oe.ensureMessageListener()}return bi.log("Spot injected",H,o),U}static clear(){Oe.embeds.forEach(o=>{o.remove()}),Oe.embeds=[],Oe.iframeCallbacks.clear(),Oe.messageListened&&(window.removeEventListener("message",Oe.handleMessageEvent),Oe.messageListened=!1),bi.log("All MeltingSpot embeds cleared")}static handleMessageEvent(o){if(!o.data||typeof o.data!="object"||o.data.type!==xi.READY&&o.data.type!==xi.ERROR)return;const r=o.source,c=Oe.iframeCallbacks.get(r);if(!c)return;const{msCommunityWebBaseUrl:d}=Ue.getConfiguration({});if(d)try{const v=new URL(d).origin;if(o.origin!==v)return}catch{}o.data.type===xi.READY?c.onReady?.():c.onError?.(o.data.error)}static ensureMessageListener(){Oe.messageListened||(window.addEventListener("message",Oe.handleMessageEvent),Oe.messageListened=!0)}};Oe.embeds=[],Oe.messageListened=!1,Oe.iframeCallbacks=new Map;let Di=Oe;const Si=globalThis;Si.MeltingSpot||(Si.MeltingSpot={}),Si.MeltingSpot.Embed=Di;const bc="1.0.0",He=new Ti({appName:"Widget SDK",appVersion:bc});class Uu{constructor(o,r,c){this.content=o,this.rootDocument=r,this.dialogClassname=c,this.dialogElement=null,this.triggerElement=null,this.iframeElement=null,this.currentListener=null}inject({into:o,bind:r,options:c}){this.remove();const d=wi({input:o,rootDocument:this.rootDocument});if(this.dialogElement=wf(this.rootDocument),this.dialogElement.classList.add(this.dialogClassname),this.dialogElement.onclose=()=>this.#t(),d.appendChild(this.dialogElement),r){this.triggerElement=wi({input:r,rootDocument:this.rootDocument});const v=this.open.bind(this,c);this.currentListener=g=>{g.stopPropagation(),g.preventDefault(),v()},this.triggerElement.addEventListener("click",this.currentListener)}}remove(){this.dialogElement&&(this.dialogElement.remove(),this.dialogElement.onclose=null,this.dialogElement=null),this.triggerElement&&(this.currentListener&&this.triggerElement.removeEventListener("click",this.currentListener),this.triggerElement=null,this.currentListener=null)}open(o){this.dialogElement||this.inject({into:this.rootDocument.body}),this.dialogElement&&(this.#e(),this.dialogElement.showModal())}close(){this.dialogElement&&this.dialogElement.close()}#e(){this.dialogElement&&(this.iframeElement=this.dialogElement.appendChild(this.content.iframe))}#t(){this.iframeElement&&(this.iframeElement.remove(),this.iframeElement=null)}}class Ar extends Uu{constructor(o,r){super(o,r,"ms-drawer")}open(o){const{position:r="right"}=o??{};super.open(o),this.dialogElement&&(this.dialogElement.dataset.position=r)}}class Lr extends Uu{constructor(o,r){super(o,r,"ms-modal")}}class xc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.widgetId=nn(o.widgetId),this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=new URL(`/widgets/spot/${this.spotId}/widget/${this.widgetId}`,ur(this.baseURL)),r=Ei({url:o,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,...Mi(this.utmParameters)},rootDocument:this.rootDocument});return r.classList.add("ms-widget"),r}}class Dc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.widgetContentId=nn(o.widgetContentId),this.contentId=nn(o.contentId),this.widgetId=nn(o.widgetId),this.contentType=o.contentType,this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=new URL(`/widgets/spot/${this.spotId}/widgetContent/${this.widgetContentId}`,ur(this.baseURL));o.searchParams.set("widgetId",this.widgetId);const r=Ei({url:o,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,contentId:this.contentId,contentType:this.contentType,...Mi(this.utmParameters)},rootDocument:this.rootDocument});return r.classList.add("ms-widget-content"),r}}const ee=class ee{static injectWidgetInto(o,r){const{spotId:c,rootDocument:d,msCommunityWebBaseUrl:v}=Ue.getConfiguration({spotId:r.spotId,rootDocument:r.rootDocument,msCommunityWebBaseUrl:r.baseURL});if(!c)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widget:g,args:y}=ee.createWidget({...r,spotId:c,rootDocument:d,baseURL:v}),A=new Ir(g);return A.inject(o),ee.widgets.push(A),He.log("Widget injected",ee.cleanupLoggedArgs(y),o),A}static injectWidgetContentInto(o,r){const{spotId:c,rootDocument:d,msCommunityWebBaseUrl:v}=Ue.getConfiguration({spotId:r.spotId,rootDocument:r.rootDocument,msCommunityWebBaseUrl:r.baseURL});if(!c)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widgetContent:g,args:y}=ee.createWidgetContent({...r,spotId:c,rootDocument:d,baseURL:v}),A=new Ir(g);return A.inject(o),ee.widgets.push(A),He.log("WidgetContent injected",ee.cleanupLoggedArgs(y),o),A}static bindWidgetModalTo(o,r){return ee.bindEntityModalTo(o,{type:"Widget",data:r})}static bindWidgetDrawerTo(o,r){return ee.bindEntityDrawerTo(o,{type:"Widget",data:r})}static createWidgetDrawer(o){const{widget:r}=ee.createWidget(o);return He.log("Create Widget drawer",{data:ee.cleanupLoggedArgs(o)}),new Ar(r,o.rootDocument??document)}static createWidgetModal(o){const{widget:r}=ee.createWidget(o);return He.log("Create Widget modal",{data:ee.cleanupLoggedArgs(o)}),new Lr(r,o.rootDocument??document)}static createWidgetEmbed(o){const{widget:r}=ee.createWidget(o),c=new Ir(r);return He.log("Create Widget embed",{data:ee.cleanupLoggedArgs(o)}),c}static clear(){ee.widgets.forEach(o=>{o.remove()}),ee.widgets=[],ee.widgetOptions={},He.log("All Widget SDK MeltingSpot elements were cleared")}static bindEntityDrawerTo(o,r){const{spotId:c,rootDocument:d,msCommunityWebBaseUrl:v}=Ue.getConfiguration({spotId:r.data.spotId,rootDocument:r.data.rootDocument??document,msCommunityWebBaseUrl:r.data.baseURL});if(!c)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let g,y;switch(r.type){case"Widget":{const U=ee.createWidget({...r.data,spotId:c,rootDocument:d,baseURL:v});g=U.widget,y=U.args}break;case"WidgetContent":{const U=ee.createWidgetContent({...r.data,spotId:c,rootDocument:d,baseURL:v});g=U.widgetContent,y=U.args}}const A=new Ar(g,d),F={position:r.data.position},H=r.data.into??d.body;return A.inject({into:H,bind:o,options:F}),ee.widgets.push(A),He.log("Widget bound to drawer",ee.cleanupLoggedArgs(y),F,H,o),A}static bindEntityModalTo(o,r){const{spotId:c,rootDocument:d,msCommunityWebBaseUrl:v}=Ue.getConfiguration({spotId:r.data.spotId,rootDocument:r.data.rootDocument??document,msCommunityWebBaseUrl:r.data.baseURL});if(!c)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let g,y;switch(r.type){case"Widget":{const H=ee.createWidget({...r.data,spotId:c,rootDocument:d,baseURL:v});g=H.widget,y=H.args}break;case"WidgetContent":{const H=ee.createWidgetContent({...r.data,spotId:c,rootDocument:d,baseURL:v});g=H.widgetContent,y=H.args}}const A=new Lr(g,d),F=r.data.into??d.body;return A.inject({into:F,bind:o}),ee.widgets.push(A),He.log("Widget bound to modal",ee.cleanupLoggedArgs(y),F,o),A}static handleMessageEvent(o){if(!o.data||typeof o.data!="object"||o.data.type!=="OpenWidgetContent")return;const r=o.data?.widgetId;if(!r||typeof r!="string"){He.error("widgetId is required in the message event data");return}const c=ee.widgetOptions[r];if(!c){He.error("No widget options found for widgetId",{widgetId:r});return}let d=null;try{d=new URL(c.baseURL).origin}catch{d=null}if(!d||o.origin!==d){He.warn("Ignoring OpenWidgetContent from unexpected origin",{origin:o.origin,expectedOrigin:d});return}const{spotId:v,rootDocument:g,msCommunityWebBaseUrl:y}=Ue.getConfiguration({spotId:c.spotId,rootDocument:c.rootDocument??document,msCommunityWebBaseUrl:c.baseURL}),{widgetContent:A}=ee.createWidgetContent({...c,widgetContentId:o.data.widgetContentId,contentType:o.data.contentType,contentId:o.data.contentId,widgetId:r,spotId:v,rootDocument:g,baseURL:y});o.data.openingIn==="Drawer"?new Ar(A,g).open():o.data.openingIn==="Modal"&&new Lr(A,g).open()}static createWidget(o){const r=new URLSearchParams(window.location.search),c={spotId:o.spotId,widgetId:o.widgetId,authToken:o.authToken,themeMode:o.themeMode,domain:o.domain,rootDocument:o.rootDocument,baseURL:o.baseURL,utmParameters:o.utmParameters??Oi(r)};return ee.widgetOptions[c.widgetId]=c,ee.messageListened||(window.addEventListener("message",ee.handleMessageEvent),ee.messageListened=!0),{widget:new xc(c),args:c}}static createWidgetContent(o){const r=new URLSearchParams(window.location.search),c={spotId:o.spotId,contentId:o.contentId,contentType:o.contentType,widgetContentId:o.widgetContentId,widgetId:o.widgetId,authToken:o.authToken,themeMode:o.themeMode,domain:o.domain,rootDocument:o.rootDocument,baseURL:o.baseURL,utmParameters:o.utmParameters??Oi(r)};return{widgetContent:new Dc(c),args:c}}static cleanupLoggedArgs(o){const{authToken:r,...c}=o;return{...c,authToken:r?"***":void 0}}};ee.widgets=[],ee.messageListened=!1,ee.widgetOptions={};let Rr=ee;const Ui=globalThis;Ui.MeltingSpot||(Ui.MeltingSpot={}),Ui.MeltingSpot.Widget=Rr,kt.Drawer=Ar,kt.Modal=Lr,kt.Widget=Rr,Object.defineProperty(kt,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "MeltingSpot Widget SDK",
|
|
4
4
|
"homepage": "https://meltingspot.io",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "1.0.0",
|
|
7
7
|
"main": "./index.cjs",
|
|
8
8
|
"module": "./index.mjs",
|
|
9
9
|
"typings": "./index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@meltingspot/core": "
|
|
25
|
-
"@meltingspot/embed": "
|
|
24
|
+
"@meltingspot/core": "1.0.0",
|
|
25
|
+
"@meltingspot/embed": "1.0.0"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"provenance": false
|