@meltingspot/embed 1.17.0 → 1.18.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 +22 -0
- package/README.md +21 -0
- package/index.cjs +1 -1
- package/index.mjs +120 -28
- package/index.standalone.js +1 -1
- package/meltingSpotEmbed.d.ts +10 -1
- package/oidc/oidcRedirectRequest.d.ts +22 -0
- package/oidc/oidcReturnFragment.d.ts +26 -0
- package/package.json +2 -2
- package/rendering/embedFrame.d.ts +3 -1
- package/spot.d.ts +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,28 @@ Date: YYYY-MM-DD
|
|
|
15
15
|
|
|
16
16
|
-->
|
|
17
17
|
|
|
18
|
+
## v1.18.0
|
|
19
|
+
|
|
20
|
+
Date: 2026-10-21
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- Bump `@meltingspot/core` to `1.18.0`.
|
|
25
|
+
- Fallback for the OpenID Connect login of an embedded spot: when the browser
|
|
26
|
+
blocks the login window (in-app browsers), the spot asks the SDK to open the
|
|
27
|
+
login in the page itself. The SDK checks that the request comes from a spot
|
|
28
|
+
it injected and goes to the MeltingSpot API only, then navigates the page.
|
|
29
|
+
Back on your embed page, when the spot is injected, it removes the login
|
|
30
|
+
result from the address at once and opens the spot on it, which completes
|
|
31
|
+
the login. Call `injectSpotInto` early in the page. Without this
|
|
32
|
+
version, the spot says the login window was blocked.
|
|
33
|
+
- If you place the spot iframe in a `sandbox` yourself, it must carry
|
|
34
|
+
`allow-scripts`, `allow-same-origin`, `allow-popups` and
|
|
35
|
+
`allow-popups-to-escape-sandbox`.
|
|
36
|
+
- Limit: the fallback serves the first spot injected in the page, on the embed
|
|
37
|
+
page declared for the spot. A site that embeds several spots, or on several
|
|
38
|
+
pages, gets the fallback on that one only.
|
|
39
|
+
|
|
18
40
|
## v1.17.0
|
|
19
41
|
|
|
20
42
|
Date: 2026-10-14
|
package/README.md
CHANGED
|
@@ -101,6 +101,27 @@ MeltingSpot one.
|
|
|
101
101
|
|
|
102
102
|
See the ["Multi-domains" section of the embed guide](https://help.meltingspot.io/english/manage-spot/embed) for details.
|
|
103
103
|
|
|
104
|
+
### OpenID Connect login fallback
|
|
105
|
+
|
|
106
|
+
When the browser blocks the window of an OpenID Connect login (in-app
|
|
107
|
+
browsers), the spot asks the SDK to open the login in the page itself: the SDK
|
|
108
|
+
only ever navigates the page to the MeltingSpot API, and back on your embed
|
|
109
|
+
page it opens the spot on the login result.
|
|
110
|
+
|
|
111
|
+
If you place the spot iframe in a `sandbox` yourself, it must carry
|
|
112
|
+
`allow-scripts`, `allow-same-origin`, `allow-popups` and
|
|
113
|
+
`allow-popups-to-escape-sandbox`.
|
|
114
|
+
|
|
115
|
+
Limits of this fallback:
|
|
116
|
+
|
|
117
|
+
- the login comes back only to the embed page declared for your spot;
|
|
118
|
+
- it opens the **first** spot injected in that page: a page that embeds several
|
|
119
|
+
spots completes the login in the first one only.
|
|
120
|
+
|
|
121
|
+
Call `injectSpotInto` early in your page, **before** loading your analytics and
|
|
122
|
+
error-tracking tools: when the spot is injected, the SDK removes the login
|
|
123
|
+
result from the address of the page, before they can read it.
|
|
124
|
+
|
|
104
125
|
### `UtmParameters`
|
|
105
126
|
|
|
106
127
|
Appended to the embed URL as `utm_*` query params (`source` becomes `utm_source`, etc.).
|
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@meltingspot/core");var t=new e.Logger({appName:`Embed SDK`,appVersion:`1.
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@meltingspot/core");var t=new e.Logger({appName:`Embed SDK`,appVersion:`1.18.0`}),n=`EmbedRedirect`,r=/^\/spot\/([^/]+)\/sso\/oidc\/embed\/authorize$/,i=e=>{try{return new URL(e).origin}catch{return}},a=(e,t)=>{let a=t.find(({contentWindow:t})=>t!==null&&t===e.source);if(!a||!a.origin||e.origin!==a.origin)return;let o=e.data?.url;if(typeof o!=`string`)return;let s;try{s=new URL(o)}catch{return}let c=i(a.msCoreBaseUrl),l=r.exec(s.pathname)?.[1];if(!(!c||s.origin!==c||l?.toLowerCase()!==a.spotId.toLowerCase()||s.searchParams.get(`mode`)!==n))return{source:e.source,origin:e.origin,url:s.toString()}},o=e=>{window.location.assign(e)},s={ATTEMPT:`ms_oidc_attempt`,CODE:`ms_oidc_code`,ERROR:`ms_oidc_error`},c=(e=window.location,t=window.history)=>{let n=new URLSearchParams(e.hash.replace(/^#/,``)),r=Object.values(s);if(!r.some(e=>n.has(e)))return;let i=n.get(s.ATTEMPT),a=n.get(s.CODE)||void 0,o=n.get(s.ERROR)||void 0;r.forEach(e=>n.delete(e));let c=n.toString();return t.replaceState(t.state,``,e.pathname+e.search+(c?`#${c}`:``)),i&&(a||o)?{attemptId:i,code:a,error:o}:void 0},l=e=>{let t=new URLSearchParams({[s.ATTEMPT]:e.attemptId});return e.code&&t.set(s.CODE,e.code),e.error&&t.set(s.ERROR,e.error),t.toString()},u=class{#e=null;#t=null;constructor(e){this.content=e}set onRemove(e){this.#t=e}get contentWindow(){return this.#e?.contentWindow??null}get origin(){if(!this.#e)return null;try{return new URL(this.#e.src).origin}catch{return null}}inject(t){this.remove();let n=(0,e.getHTMLElement)({input:t,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add(`ms-embed`),n.appendChild(this.#e)}remove(){this.#e&&=(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),null)}},d=class{#e;constructor(t){this.baseURL=(0,e.formatBaseUrl)(t.baseURL),this.spotId=(0,e.formatUUID)(t.spotId),this.authToken=t.authToken??null,this.themeMode=t.themeMode??`auto`,this.domain=t.domain??null,this.deeplink=t.deeplink?(0,e.formatDeeplink)({deeplink:t.deeplink,spotId:this.spotId}):null,this.utmParameters=t.utmParameters??null,this.rootDocument=t.rootDocument,this.#e=t.oidcReturn??null}get iframe(){let t=this.#e;this.#e=null;let n=t?null:this.authToken,r=this.getPath(t,n),i=new URL(`/spot/${this.spotId}${r}`,(0,e.trimSlashRight)(this.baseURL));t&&(i.hash=l(t));let a=(0,e.createIframe)({url:i,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:n,domain:this.domain,deeplink:this.deeplink,...(0,e.flattenUtmParameters)(this.utmParameters)},rootDocument:this.rootDocument});return a.classList.add(`ms-spot`),a}getPath(e,t){return e?`/sso/oidc/embed`:t&&t.trim().length>0?`/sso/jwt`:``}},f={READY:`meltingspot:ready`,ERROR:`meltingspot:error`,PREFILL_DRAFT:`meltingspot:prefillDraft`,OIDC_REDIRECT:`ms:sso:oidc:redirect`,OIDC_REDIRECT_ACK:`ms:sso:oidc:redirect:ack`},p=class n{static{this.embeds=[]}static{this.messageListened=!1}static{this.iframeCallbacks=new Map}static injectSpotInto(r,i){let{onReady:a,onError:o,...s}=i,{spotId:l,rootDocument:f,msCommunityWebBaseUrl:p,msCoreBaseUrl:m}=e.ConfigurationService.getConfiguration({spotId:s.spotId,rootDocument:s.rootDocument,msCommunityWebBaseUrl:s.baseURL});if(!l)throw t.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let h=new URLSearchParams(window.location.search),g={spotId:l,authToken:s.authToken??h.get(`ms_token`),domain:s.domain,deeplink:s.deeplink??h.get(`ms_url`),themeMode:s.themeMode,utmParameters:s.utmParameters??(0,e.parseUtmParameters)(h),baseURL:p,rootDocument:f},_=(0,e.getHTMLElement)({input:r,rootDocument:f}),v=new d({...g,oidcReturn:c()}),y=new u(v);if(y.inject(_),n.embeds.push({frame:y,spotId:v.spotId,msCoreBaseUrl:m}),n.ensureMessageListener(),a||o){let e=y.content.iframe.contentWindow;e&&(n.iframeCallbacks.set(e,{onReady:a,onError:o}),y.onRemove=e=>{n.iframeCallbacks.delete(e)})}return t.log(`Spot injected`,g,typeof r==`string`?r:r.id),y}static clear(){n.embeds.forEach(({frame:e})=>{e.remove()}),n.embeds=[],n.iframeCallbacks.clear(),n.messageListened&&=(window.removeEventListener(`message`,n.handleMessageEvent),!1),t.log(`All MeltingSpot embeds cleared`)}static handleMessageEvent(t){if(!t.data||typeof t.data!=`object`)return;if(t.data.type===f.OIDC_REDIRECT){n.handleOidcRedirect(t);return}if(t.data.type!==f.READY&&t.data.type!==f.ERROR)return;let r=t.source,i=n.iframeCallbacks.get(r);if(!i)return;let{msCommunityWebBaseUrl:a}=e.ConfigurationService.getConfiguration({});if(a)try{let e=new URL(a).origin;if(t.origin!==e)return}catch{}t.data.type===f.READY?i.onReady?.():i.onError?.(t.data.error)}static handleOidcRedirect(e){let r=a(e,n.embeds.map(({frame:e,spotId:t,msCoreBaseUrl:n})=>({contentWindow:e.contentWindow,origin:e.origin,spotId:t,msCoreBaseUrl:n})));if(!r){t.warn(`OpenID Connect login request ignored`);return}r.source.postMessage({type:f.OIDC_REDIRECT_ACK},r.origin),t.log(`Navigating to the OpenID Connect login`),o(r.url)}static ensureMessageListener(){n.messageListened||=(window.addEventListener(`message`,n.handleMessageEvent),!0)}},m=globalThis;m.MeltingSpot||={},m.MeltingSpot.Embed=p,exports.EMBED_POST_MESSAGE_TYPE=f,exports.Embed=p,exports.EmbedFrame=u;
|
package/index.mjs
CHANGED
|
@@ -3,8 +3,51 @@ import { ConfigurationService as e, Logger as t, createIframe as n, flattenUtmPa
|
|
|
3
3
|
//#region src/logger.ts
|
|
4
4
|
var u = new t({
|
|
5
5
|
appName: "Embed SDK",
|
|
6
|
-
appVersion: "1.
|
|
7
|
-
}), d =
|
|
6
|
+
appVersion: "1.18.0"
|
|
7
|
+
}), d = "EmbedRedirect", f = /^\/spot\/([^/]+)\/sso\/oidc\/embed\/authorize$/, p = (e) => {
|
|
8
|
+
try {
|
|
9
|
+
return new URL(e).origin;
|
|
10
|
+
} catch {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
}, m = (e, t) => {
|
|
14
|
+
let n = t.find(({ contentWindow: t }) => t !== null && t === e.source);
|
|
15
|
+
if (!n || !n.origin || e.origin !== n.origin) return;
|
|
16
|
+
let r = e.data?.url;
|
|
17
|
+
if (typeof r != "string") return;
|
|
18
|
+
let i;
|
|
19
|
+
try {
|
|
20
|
+
i = new URL(r);
|
|
21
|
+
} catch {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
let a = p(n.msCoreBaseUrl), o = f.exec(i.pathname)?.[1];
|
|
25
|
+
if (!(!a || i.origin !== a || o?.toLowerCase() !== n.spotId.toLowerCase() || i.searchParams.get("mode") !== d)) return {
|
|
26
|
+
source: e.source,
|
|
27
|
+
origin: e.origin,
|
|
28
|
+
url: i.toString()
|
|
29
|
+
};
|
|
30
|
+
}, h = (e) => {
|
|
31
|
+
window.location.assign(e);
|
|
32
|
+
}, g = {
|
|
33
|
+
ATTEMPT: "ms_oidc_attempt",
|
|
34
|
+
CODE: "ms_oidc_code",
|
|
35
|
+
ERROR: "ms_oidc_error"
|
|
36
|
+
}, _ = (e = window.location, t = window.history) => {
|
|
37
|
+
let n = new URLSearchParams(e.hash.replace(/^#/, "")), r = Object.values(g);
|
|
38
|
+
if (!r.some((e) => n.has(e))) return;
|
|
39
|
+
let i = n.get(g.ATTEMPT), a = n.get(g.CODE) || void 0, o = n.get(g.ERROR) || void 0;
|
|
40
|
+
r.forEach((e) => n.delete(e));
|
|
41
|
+
let s = n.toString();
|
|
42
|
+
return t.replaceState(t.state, "", e.pathname + e.search + (s ? `#${s}` : "")), i && (a || o) ? {
|
|
43
|
+
attemptId: i,
|
|
44
|
+
code: a,
|
|
45
|
+
error: o
|
|
46
|
+
} : void 0;
|
|
47
|
+
}, v = (e) => {
|
|
48
|
+
let t = new URLSearchParams({ [g.ATTEMPT]: e.attemptId });
|
|
49
|
+
return e.code && t.set(g.CODE, e.code), e.error && t.set(g.ERROR, e.error), t.toString();
|
|
50
|
+
}, y = class {
|
|
8
51
|
#e = null;
|
|
9
52
|
#t = null;
|
|
10
53
|
constructor(e) {
|
|
@@ -13,6 +56,17 @@ var u = new t({
|
|
|
13
56
|
set onRemove(e) {
|
|
14
57
|
this.#t = e;
|
|
15
58
|
}
|
|
59
|
+
get contentWindow() {
|
|
60
|
+
return this.#e?.contentWindow ?? null;
|
|
61
|
+
}
|
|
62
|
+
get origin() {
|
|
63
|
+
if (!this.#e) return null;
|
|
64
|
+
try {
|
|
65
|
+
return new URL(this.#e.src).origin;
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
16
70
|
inject(e) {
|
|
17
71
|
this.remove();
|
|
18
72
|
let t = s({
|
|
@@ -24,33 +78,43 @@ var u = new t({
|
|
|
24
78
|
remove() {
|
|
25
79
|
this.#e &&= (this.#e.contentWindow && this.#t?.(this.#e.contentWindow), this.#e.remove(), null);
|
|
26
80
|
}
|
|
27
|
-
},
|
|
81
|
+
}, b = class {
|
|
82
|
+
#e;
|
|
28
83
|
constructor(e) {
|
|
29
84
|
this.baseURL = i(e.baseURL), this.spotId = o(e.spotId), this.authToken = e.authToken ?? null, this.themeMode = e.themeMode ?? "auto", this.domain = e.domain ?? null, this.deeplink = e.deeplink ? a({
|
|
30
85
|
deeplink: e.deeplink,
|
|
31
86
|
spotId: this.spotId
|
|
32
|
-
}) : null, this.utmParameters = e.utmParameters ?? null, this.rootDocument = e.rootDocument;
|
|
87
|
+
}) : null, this.utmParameters = e.utmParameters ?? null, this.rootDocument = e.rootDocument, this.#e = e.oidcReturn ?? null;
|
|
33
88
|
}
|
|
34
89
|
get iframe() {
|
|
35
|
-
let e = this
|
|
36
|
-
|
|
90
|
+
let e = this.#e;
|
|
91
|
+
this.#e = null;
|
|
92
|
+
let t = e ? null : this.authToken, i = this.getPath(e, t), a = new URL(`/spot/${this.spotId}${i}`, l(this.baseURL));
|
|
93
|
+
e && (a.hash = v(e));
|
|
94
|
+
let o = n({
|
|
95
|
+
url: a,
|
|
37
96
|
searchParams: {
|
|
38
97
|
embed: this.spotId,
|
|
39
98
|
themeMode: this.themeMode,
|
|
40
|
-
ms_token:
|
|
99
|
+
ms_token: t,
|
|
41
100
|
domain: this.domain,
|
|
42
101
|
deeplink: this.deeplink,
|
|
43
102
|
...r(this.utmParameters)
|
|
44
103
|
},
|
|
45
104
|
rootDocument: this.rootDocument
|
|
46
105
|
});
|
|
47
|
-
return
|
|
106
|
+
return o.classList.add("ms-spot"), o;
|
|
48
107
|
}
|
|
49
|
-
|
|
108
|
+
getPath(e, t) {
|
|
109
|
+
return e ? "/sso/oidc/embed" : t && t.trim().length > 0 ? "/sso/jwt" : "";
|
|
110
|
+
}
|
|
111
|
+
}, x = {
|
|
50
112
|
READY: "meltingspot:ready",
|
|
51
113
|
ERROR: "meltingspot:error",
|
|
52
|
-
PREFILL_DRAFT: "meltingspot:prefillDraft"
|
|
53
|
-
|
|
114
|
+
PREFILL_DRAFT: "meltingspot:prefillDraft",
|
|
115
|
+
OIDC_REDIRECT: "ms:sso:oidc:redirect",
|
|
116
|
+
OIDC_REDIRECT_ACK: "ms:sso:oidc:redirect:ack"
|
|
117
|
+
}, S = class t {
|
|
54
118
|
static {
|
|
55
119
|
this.embeds = [];
|
|
56
120
|
}
|
|
@@ -61,40 +125,55 @@ var u = new t({
|
|
|
61
125
|
this.iframeCallbacks = /* @__PURE__ */ new Map();
|
|
62
126
|
}
|
|
63
127
|
static injectSpotInto(n, r) {
|
|
64
|
-
let { onReady: i, onError: a, ...o } = r, { spotId:
|
|
128
|
+
let { onReady: i, onError: a, ...o } = r, { spotId: l, rootDocument: d, msCommunityWebBaseUrl: f, msCoreBaseUrl: p } = e.getConfiguration({
|
|
65
129
|
spotId: o.spotId,
|
|
66
130
|
rootDocument: o.rootDocument,
|
|
67
131
|
msCommunityWebBaseUrl: o.baseURL
|
|
68
132
|
});
|
|
69
|
-
if (!
|
|
133
|
+
if (!l) throw u.error("Spot ID is required"), Error("Spot ID is not configured. Please set the spotId in the configuration.");
|
|
70
134
|
let m = new URLSearchParams(window.location.search), h = {
|
|
71
|
-
spotId:
|
|
135
|
+
spotId: l,
|
|
72
136
|
authToken: o.authToken ?? m.get("ms_token"),
|
|
73
137
|
domain: o.domain,
|
|
74
138
|
deeplink: o.deeplink ?? m.get("ms_url"),
|
|
75
139
|
themeMode: o.themeMode,
|
|
76
140
|
utmParameters: o.utmParameters ?? c(m),
|
|
77
|
-
baseURL:
|
|
78
|
-
rootDocument:
|
|
79
|
-
}, g =
|
|
80
|
-
|
|
81
|
-
|
|
141
|
+
baseURL: f,
|
|
142
|
+
rootDocument: d
|
|
143
|
+
}, g = s({
|
|
144
|
+
input: n,
|
|
145
|
+
rootDocument: d
|
|
146
|
+
}), v = new b({
|
|
147
|
+
...h,
|
|
148
|
+
oidcReturn: _()
|
|
149
|
+
}), x = new y(v);
|
|
150
|
+
if (x.inject(g), t.embeds.push({
|
|
151
|
+
frame: x,
|
|
152
|
+
spotId: v.spotId,
|
|
153
|
+
msCoreBaseUrl: p
|
|
154
|
+
}), t.ensureMessageListener(), i || a) {
|
|
155
|
+
let e = x.content.iframe.contentWindow;
|
|
82
156
|
e && (t.iframeCallbacks.set(e, {
|
|
83
157
|
onReady: i,
|
|
84
158
|
onError: a
|
|
85
|
-
}),
|
|
159
|
+
}), x.onRemove = (e) => {
|
|
86
160
|
t.iframeCallbacks.delete(e);
|
|
87
|
-
})
|
|
161
|
+
});
|
|
88
162
|
}
|
|
89
|
-
return u.log("Spot injected", h, n),
|
|
163
|
+
return u.log("Spot injected", h, typeof n == "string" ? n : n.id), x;
|
|
90
164
|
}
|
|
91
165
|
static clear() {
|
|
92
|
-
t.embeds.forEach((e) => {
|
|
166
|
+
t.embeds.forEach(({ frame: e }) => {
|
|
93
167
|
e.remove();
|
|
94
168
|
}), t.embeds = [], t.iframeCallbacks.clear(), t.messageListened &&= (window.removeEventListener("message", t.handleMessageEvent), !1), u.log("All MeltingSpot embeds cleared");
|
|
95
169
|
}
|
|
96
170
|
static handleMessageEvent(n) {
|
|
97
|
-
if (!n.data || typeof n.data != "object"
|
|
171
|
+
if (!n.data || typeof n.data != "object") return;
|
|
172
|
+
if (n.data.type === x.OIDC_REDIRECT) {
|
|
173
|
+
t.handleOidcRedirect(n);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (n.data.type !== x.READY && n.data.type !== x.ERROR) return;
|
|
98
177
|
let r = n.source, i = t.iframeCallbacks.get(r);
|
|
99
178
|
if (!i) return;
|
|
100
179
|
let { msCommunityWebBaseUrl: a } = e.getConfiguration({});
|
|
@@ -102,12 +181,25 @@ var u = new t({
|
|
|
102
181
|
let e = new URL(a).origin;
|
|
103
182
|
if (n.origin !== e) return;
|
|
104
183
|
} catch {}
|
|
105
|
-
n.data.type ===
|
|
184
|
+
n.data.type === x.READY ? i.onReady?.() : i.onError?.(n.data.error);
|
|
185
|
+
}
|
|
186
|
+
static handleOidcRedirect(e) {
|
|
187
|
+
let n = m(e, t.embeds.map(({ frame: e, spotId: t, msCoreBaseUrl: n }) => ({
|
|
188
|
+
contentWindow: e.contentWindow,
|
|
189
|
+
origin: e.origin,
|
|
190
|
+
spotId: t,
|
|
191
|
+
msCoreBaseUrl: n
|
|
192
|
+
})));
|
|
193
|
+
if (!n) {
|
|
194
|
+
u.warn("OpenID Connect login request ignored");
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
n.source.postMessage({ type: x.OIDC_REDIRECT_ACK }, n.origin), u.log("Navigating to the OpenID Connect login"), h(n.url);
|
|
106
198
|
}
|
|
107
199
|
static ensureMessageListener() {
|
|
108
200
|
t.messageListened ||= (window.addEventListener("message", t.handleMessageEvent), !0);
|
|
109
201
|
}
|
|
110
|
-
},
|
|
111
|
-
|
|
202
|
+
}, C = globalThis;
|
|
203
|
+
C.MeltingSpot ||= {}, C.MeltingSpot.Embed = S;
|
|
112
204
|
//#endregion
|
|
113
|
-
export {
|
|
205
|
+
export { x as EMBED_POST_MESSAGE_TYPE, S as Embed, y as EmbedFrame };
|
package/index.standalone.js
CHANGED
|
@@ -17,4 +17,4 @@ __p += '`),r&&(f+=`' +
|
|
|
17
17
|
function print() { __p += __j.call(arguments, '') }
|
|
18
18
|
`:`;
|
|
19
19
|
`)+f+`return __p
|
|
20
|
-
}`;var g=af(function(){return at(o,m+`return `+f).apply(n,s)});if(g.source=f,ou(g))throw g;return g}function Jd(e){return Q(e).toLowerCase()}function Yd(e){return Q(e).toUpperCase()}function Xd(e,t,r){if(e=Q(e),e&&(r||t===n))return Ln(e);if(!e||!(t=Ca(t)))return e;var i=ar(e),a=ar(t);return Fa(i,Vn(i,a),Hn(i,a)+1).join(``)}function Zd(e,t,r){if(e=Q(e),e&&(r||t===n))return e.slice(0,or(e)+1);if(!e||!(t=Ca(t)))return e;var i=ar(e);return Fa(i,0,Hn(i,ar(t))+1).join(``)}function Qd(e,t,r){if(e=Q(e),e&&(r||t===n))return e.replace(He,``);if(!e||!(t=Ca(t)))return e;var i=ar(e);return Fa(i,Vn(i,ar(t))).join(``)}function $d(e,t){var r=30,i=`...`;if(Y(t)){var a=`separator`in t?t.separator:a;r=`length`in t?Z(t.length):r,i=`omission`in t?Ca(t.omission):i}e=Q(e);var o=e.length;if(Jn(e)){var s=ar(e);o=s.length}if(r>=o)return e;var c=r-ir(i);if(c<1)return i;var l=s?Fa(s,0,c).join(``):e.slice(0,c);if(a===n)return l+i;if(s&&(c+=l.length-c),bu(a)){if(e.slice(c).search(a)){var u,d=l;for(a.global||(a=st(a.source,Q(Xe.exec(a))+`g`)),a.lastIndex=0;u=a.exec(d);)var f=u.index;l=l.slice(0,f===n?c:f)}}else if(e.indexOf(Ca(a),c)!=c){var p=l.lastIndexOf(a);p>-1&&(l=l.slice(0,p))}return l+i}function ef(e){return e=Q(e),e&&Me.test(e)?e.replace(Ae,sr):e}var tf=ro(function(e,t,n){return e+(n?` `:``)+t.toUpperCase()}),nf=no(`toUpperCase`);function rf(e,t,r){return e=Q(e),t=r?n:t,t===n?Yn(e)?ur(e):Cn(e):e.match(t)||[]}var af=G(function(e,t){try{return ln(e,n,t)}catch(e){return ou(e)?e:new it(e)}}),of=Oo(function(e,t){return dn(t,function(t){t=bs(t),oi(e,t,xl(e[t],e))}),e});function sf(e){var t=e==null?0:e.length,n=K();return e=t?V(e,function(e){if(typeof e[1]!=`function`)throw new M(r);return[n(e[0]),e[1]]}):[],G(function(n){for(var r=-1;++r<t;){var i=e[r];if(ln(i[0],this,n))return ln(i[1],this,n)}})}function cf(e){return ui(li(e,1))}function lf(e){return function(){return e}}function uf(e,t){return e==null||e!==e?t:e}var df=so(),ff=so(!0);function pf(e){return e}function mf(e){return Ki(typeof e==`function`?e:li(e,1))}function hf(e){return Zi(li(e,1))}function gf(e,t){return Qi(e,li(t,1))}var _f=G(function(e,t){return function(n){return Pi(n,e,t)}}),vf=G(function(e,t){return function(n){return Pi(e,n,t)}});function yf(e,t,n){var r=$(t),i=wi(t,r);n==null&&!(Y(t)&&(i.length||!r.length))&&(n=t,t=e,e=this,i=wi(t,$(t)));var a=!(Y(n)&&`chain`in n)||!!n.chain,o=cu(e);return dn(i,function(n){var r=t[n];e[n]=r,o&&(e.prototype[n]=function(){var t=this.__chain__;if(a||t){var n=e(this.__wrapped__);return(n.__actions__=qa(this.__actions__)).push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,_n([this.value()],arguments))})}),e}function bf(){return z._===this&&(z._=_t),this}function xf(){}function Sf(e){return e=Z(e),G(function(t){return ta(t,e)})}var Cf=fo(V),wf=fo(pn),Tf=fo(bn);function Ef(e){return Zo(e)?An(bs(e)):aa(e)}function Df(e){return function(t){return e==null?n:Ti(e,t)}}var Of=ho(),kf=ho(!0);function Af(){return[]}function jf(){return!1}function Mf(){return{}}function Nf(){return``}function Pf(){return!0}function Ff(e,t){if(e=Z(e),e<1||e>g)return[];var n=y,r=R(e,y);t=K(t),e-=y;for(var i=Fn(r,t);++n<e;)t(n);return i}function If(e){return q(e)?V(e,bs):wu(e)?[e]:qa(ys(Q(e)))}function Lf(e){var t=++pt;return Q(e)+t}var Rf=uo(function(e,t){return e+t},0),zf=vo(`ceil`),Bf=uo(function(e,t){return e/t},1),Vf=vo(`floor`);function Hf(e){return e&&e.length?_i(e,pf,Oi):n}function Uf(e,t){return e&&e.length?_i(e,K(t,2),Oi):n}function Wf(e){return kn(e,pf)}function Gf(e,t){return kn(e,K(t,2))}function Kf(e){return e&&e.length?_i(e,pf,Yi):n}function qf(e,t){return e&&e.length?_i(e,K(t,2),Yi):n}var Jf=uo(function(e,t){return e*t},1),Yf=vo(`round`),Xf=uo(function(e,t){return e-t},0);function Zf(e){return e&&e.length?Pn(e,pf):0}function Qf(e,t){return e&&e.length?Pn(e,K(t,2)):0}return H.after=vl,H.ary=yl,H.assign=Lu,H.assignIn=Ru,H.assignInWith=zu,H.assignWith=Bu,H.at=Vu,H.before=bl,H.bind=xl,H.bindAll=of,H.bindKey=Sl,H.castArray=Vl,H.chain=Pc,H.chunk=ws,H.compact=Ts,H.concat=Es,H.cond=sf,H.conforms=cf,H.constant=lf,H.countBy=Gc,H.create=Hu,H.curry=Cl,H.curryRight=wl,H.debounce=Tl,H.defaults=Uu,H.defaultsDeep=Wu,H.defer=El,H.delay=Dl,H.difference=Ds,H.differenceBy=Os,H.differenceWith=ks,H.drop=As,H.dropRight=js,H.dropRightWhile=Ms,H.dropWhile=Ns,H.fill=Ps,H.filter=qc,H.flatMap=Xc,H.flatMapDeep=Zc,H.flatMapDepth=Qc,H.flatten=Ls,H.flattenDeep=Rs,H.flattenDepth=zs,H.flip=Ol,H.flow=df,H.flowRight=ff,H.fromPairs=Bs,H.functions=Zu,H.functionsIn=Qu,H.groupBy=tl,H.initial=Us,H.intersection=Ws,H.intersectionBy=Gs,H.intersectionWith=Ks,H.invert=nd,H.invertBy=rd,H.invokeMap=rl,H.iteratee=mf,H.keyBy=il,H.keys=$,H.keysIn=ad,H.map=al,H.mapKeys=od,H.mapValues=sd,H.matches=hf,H.matchesProperty=gf,H.memoize=kl,H.merge=cd,H.mergeWith=ld,H.method=_f,H.methodOf=vf,H.mixin=yf,H.negate=Al,H.nthArg=Sf,H.omit=ud,H.omitBy=dd,H.once=jl,H.orderBy=ol,H.over=Cf,H.overArgs=Ml,H.overEvery=wf,H.overSome=Tf,H.partial=Nl,H.partialRight=Pl,H.partition=sl,H.pick=fd,H.pickBy=pd,H.property=Ef,H.propertyOf=Df,H.pull=Zs,H.pullAll=Qs,H.pullAllBy=$s,H.pullAllWith=ec,H.pullAt=tc,H.range=Of,H.rangeRight=kf,H.rearg=Fl,H.reject=ul,H.remove=nc,H.rest=Il,H.reverse=rc,H.sampleSize=fl,H.set=hd,H.setWith=gd,H.shuffle=pl,H.slice=ic,H.sortBy=gl,H.sortedUniq=dc,H.sortedUniqBy=fc,H.split=Wd,H.spread=Ll,H.tail=pc,H.take=mc,H.takeRight=hc,H.takeRightWhile=gc,H.takeWhile=_c,H.tap=Fc,H.throttle=Rl,H.thru=Ic,H.toArray=ju,H.toPairs=_d,H.toPairsIn=vd,H.toPath=If,H.toPlainObject=Fu,H.transform=yd,H.unary=zl,H.union=vc,H.unionBy=yc,H.unionWith=bc,H.uniq=xc,H.uniqBy=Sc,H.uniqWith=Cc,H.unset=bd,H.unzip=wc,H.unzipWith=Tc,H.update=xd,H.updateWith=Sd,H.values=Cd,H.valuesIn=wd,H.without=Ec,H.words=rf,H.wrap=Bl,H.xor=Dc,H.xorBy=Oc,H.xorWith=kc,H.zip=Ac,H.zipObject=jc,H.zipObjectDeep=Mc,H.zipWith=Nc,H.entries=_d,H.entriesIn=vd,H.extend=Ru,H.extendWith=zu,yf(H,H),H.add=Rf,H.attempt=af,H.camelCase=Od,H.capitalize=kd,H.ceil=zf,H.clamp=Td,H.clone=Hl,H.cloneDeep=Wl,H.cloneDeepWith=Gl,H.cloneWith=Ul,H.conformsTo=Kl,H.deburr=Ad,H.defaultTo=uf,H.divide=Bf,H.endsWith=jd,H.eq=ql,H.escape=Md,H.escapeRegExp=Nd,H.every=Kc,H.find=Jc,H.findIndex=Fs,H.findKey=Gu,H.findLast=Yc,H.findLastIndex=Is,H.findLastKey=Ku,H.floor=Vf,H.forEach=$c,H.forEachRight=el,H.forIn=qu,H.forInRight=Ju,H.forOwn=Yu,H.forOwnRight=Xu,H.get=$u,H.gt=Jl,H.gte=Yl,H.has=ed,H.hasIn=td,H.head=Vs,H.identity=pf,H.includes=nl,H.indexOf=Hs,H.inRange=Ed,H.invoke=id,H.isArguments=Xl,H.isArray=q,H.isArrayBuffer=Zl,H.isArrayLike=Ql,H.isArrayLikeObject=J,H.isBoolean=$l,H.isBuffer=eu,H.isDate=tu,H.isElement=nu,H.isEmpty=ru,H.isEqual=iu,H.isEqualWith=au,H.isError=ou,H.isFinite=su,H.isFunction=cu,H.isInteger=lu,H.isLength=uu,H.isMap=du,H.isMatch=fu,H.isMatchWith=pu,H.isNaN=mu,H.isNative=hu,H.isNil=_u,H.isNull=gu,H.isNumber=vu,H.isObject=Y,H.isObjectLike=X,H.isPlainObject=yu,H.isRegExp=bu,H.isSafeInteger=xu,H.isSet=Su,H.isString=Cu,H.isSymbol=wu,H.isTypedArray=Tu,H.isUndefined=Eu,H.isWeakMap=Du,H.isWeakSet=Ou,H.join=qs,H.kebabCase=Pd,H.last=Js,H.lastIndexOf=Ys,H.lowerCase=Fd,H.lowerFirst=Id,H.lt=ku,H.lte=Au,H.max=Hf,H.maxBy=Uf,H.mean=Wf,H.meanBy=Gf,H.min=Kf,H.minBy=qf,H.stubArray=Af,H.stubFalse=jf,H.stubObject=Mf,H.stubString=Nf,H.stubTrue=Pf,H.multiply=Jf,H.nth=Xs,H.noConflict=bf,H.noop=xf,H.now=_l,H.pad=Ld,H.padEnd=Rd,H.padStart=zd,H.parseInt=Bd,H.random=Dd,H.reduce=cl,H.reduceRight=ll,H.repeat=Vd,H.replace=Hd,H.result=md,H.round=Yf,H.runInContext=e,H.sample=dl,H.size=ml,H.snakeCase=Ud,H.some=hl,H.sortedIndex=ac,H.sortedIndexBy=oc,H.sortedIndexOf=sc,H.sortedLastIndex=cc,H.sortedLastIndexBy=lc,H.sortedLastIndexOf=uc,H.startCase=Gd,H.startsWith=Kd,H.subtract=Xf,H.sum=Zf,H.sumBy=Qf,H.template=qd,H.times=Ff,H.toFinite=Mu,H.toInteger=Z,H.toLength=Nu,H.toLower=Jd,H.toNumber=Pu,H.toSafeInteger=Iu,H.toString=Q,H.toUpper=Yd,H.trim=Xd,H.trimEnd=Zd,H.trimStart=Qd,H.truncate=$d,H.unescape=ef,H.uniqueId=Lf,H.upperCase=tf,H.upperFirst=nf,H.each=$c,H.eachRight=el,H.first=Vs,yf(H,function(){var e={};return Si(H,function(t,n){P.call(H.prototype,n)||(e[n]=t)}),e}(),{chain:!1}),H.VERSION=`4.17.21`,dn([`bind`,`bindKey`,`curry`,`curryRight`,`partial`,`partialRight`],function(e){H[e].placeholder=H}),dn([`drop`,`take`],function(e,t){U.prototype[e]=function(r){r=r===n?1:F(Z(r),0);var i=this.__filtered__&&!t?new U(this):this.clone();return i.__filtered__?i.__takeCount__=R(r,i.__takeCount__):i.__views__.push({size:R(r,y),type:e+(i.__dir__<0?`Right`:``)}),i},U.prototype[e+`Right`]=function(t){return this.reverse()[e](t).reverse()}}),dn([`filter`,`map`,`takeWhile`],function(e,t){var n=t+1,r=n==1||n==3;U.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:K(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}}),dn([`head`,`last`],function(e,t){var n=`take`+(t?`Right`:``);U.prototype[e]=function(){return this[n](1).value()[0]}}),dn([`initial`,`tail`],function(e,t){var n=`drop`+(t?``:`Right`);U.prototype[e]=function(){return this.__filtered__?new U(this):this[n](1)}}),U.prototype.compact=function(){return this.filter(pf)},U.prototype.find=function(e){return this.filter(e).head()},U.prototype.findLast=function(e){return this.reverse().find(e)},U.prototype.invokeMap=G(function(e,t){return typeof e==`function`?new U(this):this.map(function(n){return Pi(n,e,t)})}),U.prototype.reject=function(e){return this.filter(Al(K(e)))},U.prototype.slice=function(e,t){e=Z(e);var r=this;return r.__filtered__&&(e>0||t<0)?new U(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(t=Z(t),r=t<0?r.dropRight(-t):r.take(t-e)),r)},U.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},U.prototype.toArray=function(){return this.take(y)},Si(U.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=H[i?`take`+(t==`last`?`Right`:``):t],o=i||/^find/.test(t);a&&(H.prototype[t]=function(){var t=this.__wrapped__,s=i?[1]:arguments,c=t instanceof U,l=s[0],u=c||q(t),d=function(e){var t=a.apply(H,_n([e],s));return i&&f?t[0]:t};u&&r&&typeof l==`function`&&l.length!=1&&(c=u=!1);var f=this.__chain__,p=!!this.__actions__.length,m=o&&!f,h=c&&!p;if(!o&&u){t=h?t:new U(this);var g=e.apply(t,s);return g.__actions__.push({func:Ic,args:[d],thisArg:n}),new yr(g,f)}return m&&h?e.apply(this,s):(g=this.thru(d),m?i?g.value()[0]:g.value():g)})}),dn([`pop`,`push`,`shift`,`sort`,`splice`,`unshift`],function(e){var t=N[e],n=/^(?:push|sort|unshift)$/.test(e)?`tap`:`thru`,r=/^(?:pop|shift)$/.test(e);H.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(q(i)?i:[],e)}return this[n](function(n){return t.apply(q(n)?n:[],e)})}}),Si(U.prototype,function(e,t){var n=H[t];if(n){var r=n.name+``;P.call(jn,r)||(jn[r]=[]),jn[r].push({name:t,func:n})}}),jn[co(n,s).name]=[{name:`wrapper`,func:n}],U.prototype.clone=br,U.prototype.reverse=xr,U.prototype.value=Sr,H.prototype.at=Lc,H.prototype.chain=Rc,H.prototype.commit=zc,H.prototype.next=Bc,H.prototype.plant=Hc,H.prototype.reverse=Uc,H.prototype.toJSON=H.prototype.valueOf=H.prototype.value=Wc,H.prototype.first=H.prototype.head,Ot&&(H.prototype[Ot]=Vc),H})();typeof define==`function`&&typeof define.amd==`object`&&define.amd?(z._=dr,define(function(){return dr})):$t?(($t.exports=dr)._=dr,Qt._=dr):z._=dr}).call(e)}))(),Object.values(function(e){return e.EditMode=`edit-mode`,e.Preview=`preview`,e}({}));var De=`1.17.0`,Oe=class{constructor(e){this.debug=!1,this.debug=e?.debug??!1,this.appName=e?.appName,this.appVersion=e?.appVersion}log(e,...t){this.debug&&this.print(e,`info`,t)}warn(e,...t){this.print(e,`warn`,t)}error(e,...t){this.print(e,`error`,t)}print(e,t,n){let r=[`[${[`MeltingSpot`,this.appName,this.appVersion].filter(Boolean).join(` - `)}] ${e}`];n.length&&r.push(...n),console[t](...r)}},ke=new Oe({appName:`Core SDK`,appVersion:De}),Ae=e=>e.toLowerCase().replace(/[^a-z0-9-]/g,``),je=[`/user`],Me=({deeplink:e,spotId:t})=>{try{let n=new URL(e,`https://unused.com`),r=n.pathname;return n.search&&(r+=n.search),n.hash&&(r+=n.hash),je.some(e=>r.startsWith(e))||(r=`/spot/${t}/${ie(r)}`),r}catch(e){return ke.warn(`Failed to parse deeplink URL`,e),null}},Ne=[/(^|\.)meltingspot\.io$/i],Pe=e=>{let t;try{let n=oe(e);t=new URL(n)}catch{throw Error(`Invalid baseURL: ${e}`)}let n=t.hostname===`localhost`||t.hostname===`127.0.0.1`,r=t.protocol===`https:`,i=Ne.some(e=>e.test(t.hostname));if(!n&&(!r||!i))throw Error(`Untrusted baseURL origin: ${t.origin}`);return t.origin},Fe={msApiBaseUrl:`https://openapi.meltingspot.io/`,msCommunityWebBaseUrl:`https://go.meltingspot.io/`,ssoToken:void 0,spotId:``,autoJoin:!1,rootDocument:globalThis.document},Ie=class e{constructor(){this.configuration=Fe}static getInstance(){return e.instance||=new e,e.instance}setConfiguration(e){this.configuration={...this.configuration,...e}}static getConfiguration(t={}){let n=e.getInstance(),r=Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0));return{...n.configuration,...r}}},Le=RegExp(`(%[a-f0-9]{2})|([^%]+?)`,`gi`),Re=RegExp(`(%[a-f0-9]{2})+`,`gi`);function ze(e,t){try{return[decodeURIComponent(e.join(``))]}catch{}if(e.length===1)return e;t||=1;let n=e.slice(0,t),r=e.slice(t);return Array.prototype.concat.call([],ze(n),ze(r))}function Be(e){try{return decodeURIComponent(e)}catch{let t=e.match(Le)||[];for(let n=1;n<t.length;n++)e=ze(t,n).join(``),t=e.match(Le)||[];return e}}function Ve(e){let t={"%FE%FF":`��`,"%FF%FE":`��`},n=Re.exec(e);for(;n;){try{t[n[0]]=decodeURIComponent(n[0])}catch{let e=Be(n[0]);e!==n[0]&&(t[n[0]]=e)}n=Re.exec(e)}t[`%C2`]=`�`;let r=Object.keys(t);for(let n of r)e=e.replace(new RegExp(n,`g`),t[n]);return e}function He(e){if(typeof e!=`string`)throw TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return decodeURIComponent(e)}catch{return Ve(e)}}function k(e,t){let n={};if(Array.isArray(t))for(let r of t){let t=Object.getOwnPropertyDescriptor(e,r);t?.enumerable&&Object.defineProperty(n,r,t)}else for(let r of Reflect.ownKeys(e)){let i=Object.getOwnPropertyDescriptor(e,r);if(i.enumerable){let a=e[r];t(r,a,e)&&Object.defineProperty(n,r,i)}}return n}function Ue(e,t){if(typeof e!=`string`||typeof t!=`string`)throw TypeError("Expected the arguments to be of type `string`");if(e===``||t===``)return[];let n=e.indexOf(t);return n===-1?[]:[e.slice(0,n),e.slice(n+t.length)]}var We=c({exclude:()=>st,extract:()=>nt,parse:()=>rt,parseUrl:()=>at,pick:()=>j,stringify:()=>it,stringifyUrl:()=>ot}),Ge=e=>e==null,Ke=e=>encodeURIComponent(e).replaceAll(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),qe=Symbol(`encodeFragmentIdentifier`);function Je(e){switch(e.arrayFormat){case`index`:return t=>(n,r)=>{let i=n.length;return r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[A(t,e),`[`,i,`]`].join(``)]:[...n,[A(t,e),`[`,A(i,e),`]=`,A(r,e)].join(``)]};case`bracket`:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[A(t,e),`[]`].join(``)]:[...n,[A(t,e),`[]=`,A(r,e)].join(``)];case`colon-list-separator`:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[A(t,e),`:list=`].join(``)]:[...n,[A(t,e),`:list=`,A(r,e)].join(``)];case`comma`:case`separator`:case`bracket-separator`:{let t=e.arrayFormat===`bracket-separator`?`[]=`:`=`;return n=>(r,i)=>i===void 0||e.skipNull&&i===null||e.skipEmptyString&&i===``?r:(i=i===null?``:i,r.length===0?[[A(n,e),t,A(i,e)].join(``)]:[[r,A(i,e)].join(e.arrayFormatSeparator)])}default:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,A(t,e)]:[...n,[A(t,e),`=`,A(r,e)].join(``)]}}function Ye(e){let t;switch(e.arrayFormat){case`index`:return(e,n,r)=>{if(t=/\[(\d*)]$/.exec(e),e=e.replace(/\[\d*]$/,``),!t){r[e]=n;return}r[e]===void 0&&(r[e]={}),r[e][t[1]]=n};case`bracket`:return(e,n,r)=>{if(t=/(\[])$/.exec(e),e=e.replace(/\[]$/,``),!t){r[e]=n;return}if(r[e]===void 0){r[e]=[n];return}r[e]=[...r[e],n]};case`colon-list-separator`:return(e,n,r)=>{if(t=/(:list)$/.exec(e),e=e.replace(/:list$/,``),!t){r[e]=n;return}if(r[e]===void 0){r[e]=[n];return}r[e]=[...r[e],n]};case`comma`:case`separator`:return(t,n,r)=>{let i=typeof n==`string`&&n.includes(e.arrayFormatSeparator),a=typeof n==`string`&&!i&&Ze(n,e).includes(e.arrayFormatSeparator);n=a?Ze(n,e):n,r[t]=i||a?n.split(e.arrayFormatSeparator).map(t=>Ze(t,e)):n===null?n:Ze(n,e)};case`bracket-separator`:return(t,n,r)=>{let i=/(\[])$/.test(t);if(t=t.replace(/\[]$/,``),!i){r[t]=n&&Ze(n,e);return}let a=n===null?[]:Ze(n,e).split(e.arrayFormatSeparator);if(r[t]===void 0){r[t]=a;return}r[t]=[...r[t],...a]};default:return(e,t,n)=>{if(n[e]===void 0){n[e]=t;return}n[e]=[...[n[e]].flat(),t]}}}function Xe(e){if(typeof e!=`string`||e.length!==1)throw TypeError(`arrayFormatSeparator must be single character string`)}function A(e,t){return t.encode?t.strict?Ke(e):encodeURIComponent(e):e}function Ze(e,t){return t.decode?He(e):e}function Qe(e){return Array.isArray(e)?e.sort():typeof e==`object`?Qe(Object.keys(e)).sort((e,t)=>Number(e)-Number(t)).map(t=>e[t]):e}function $e(e){let t=e.indexOf(`#`);return t!==-1&&(e=e.slice(0,t)),e}function et(e){let t=``,n=e.indexOf(`#`);return n!==-1&&(t=e.slice(n)),t}function tt(e,t,n){return n===`string`&&typeof e==`string`?e:typeof n==`function`&&typeof e==`string`?n(e):n===`boolean`&&e===null?!0:n===`boolean`&&e!==null&&(e.toLowerCase()===`true`||e.toLowerCase()===`false`)?e.toLowerCase()===`true`:n===`boolean`&&e!==null&&(e.toLowerCase()===`1`||e.toLowerCase()===`0`)?e.toLowerCase()===`1`:n===`string[]`&&t.arrayFormat!==`none`&&typeof e==`string`?[e]:n===`number[]`&&t.arrayFormat!==`none`&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?[Number(e)]:n===`number`&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?Number(e):t.parseBooleans&&e!==null&&(e.toLowerCase()===`true`||e.toLowerCase()===`false`)?e.toLowerCase()===`true`:t.parseNumbers&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?Number(e):e}function nt(e){e=$e(e);let t=e.indexOf(`?`);return t===-1?``:e.slice(t+1)}function rt(e,t){t={decode:!0,sort:!0,arrayFormat:`none`,arrayFormatSeparator:`,`,parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...t},Xe(t.arrayFormatSeparator);let n=Ye(t),r=Object.create(null);if(typeof e!=`string`||(e=e.trim().replace(/^[?#&]/,``),!e))return r;for(let i of e.split(`&`)){if(i===``)continue;let e=t.decode?i.replaceAll(`+`,` `):i,[a,o]=Ue(e,`=`);a===void 0&&(a=e),o=o===void 0?null:[`comma`,`separator`,`bracket-separator`].includes(t.arrayFormat)?o:Ze(o,t),n(Ze(a,t),o,r)}for(let[e,n]of Object.entries(r))if(typeof n==`object`&&n&&t.types[e]!==`string`)for(let[r,i]of Object.entries(n)){let a=t.types[e]?t.types[e].replace(`[]`,``):void 0;n[r]=tt(i,t,a)}else r[e]=typeof n==`object`&&n&&t.types[e]===`string`?Object.values(n).join(t.arrayFormatSeparator):tt(n,t,t.types[e]);return t.sort===!1?r:(t.sort===!0?Object.keys(r).sort():Object.keys(r).sort(t.sort)).reduce((e,t)=>{let n=r[t];return e[t]=n&&typeof n==`object`&&!Array.isArray(n)?Qe(n):n,e},Object.create(null))}function it(e,t){if(!e)return``;t={encode:!0,strict:!0,arrayFormat:`none`,arrayFormatSeparator:`,`,...t},Xe(t.arrayFormatSeparator);let n=n=>t.skipNull&&Ge(e[n])||t.skipEmptyString&&e[n]===``,r=Je(t),i={};for(let[t,r]of Object.entries(e))n(t)||(i[t]=r);let a=Object.keys(i);return t.sort!==!1&&a.sort(t.sort),a.map(n=>{let i=e[n];return i===void 0?``:i===null?A(n,t):Array.isArray(i)?i.length===0&&t.arrayFormat===`bracket-separator`?A(n,t)+`[]`:i.reduce(r(n),[]).join(`&`):A(n,t)+`=`+A(i,t)}).filter(e=>e.length>0).join(`&`)}function at(e,t){t={decode:!0,...t};let[n,r]=Ue(e,`#`);return n===void 0&&(n=e),{url:n?.split(`?`)?.[0]??``,query:rt(nt(e),t),...t&&t.parseFragmentIdentifier&&r?{fragmentIdentifier:Ze(r,t)}:{}}}function ot(e,t){t={encode:!0,strict:!0,[qe]:!0,...t};let n=$e(e.url).split(`?`)[0]||``,r=it({...rt(nt(e.url),{sort:!1,...t}),...e.query},t);r&&=`?${r}`;let i=et(e.url);if(typeof e.fragmentIdentifier==`string`){let r=new URL(n);r.hash=e.fragmentIdentifier,i=t[qe]?r.hash:`#${e.fragmentIdentifier}`}return`${n}${r}${i}`}function j(e,t,n){n={parseFragmentIdentifier:!0,[qe]:!1,...n};let{url:r,query:i,fragmentIdentifier:a}=at(e,n);return ot({url:r,query:k(i,t),fragmentIdentifier:a},n)}function st(e,t,n){return j(e,Array.isArray(t)?e=>!t.includes(e):(e,n)=>!t(e,n),n)}var ct=We,M=class e extends Error{constructor(t,n){super(`HTTP Error ${t}${n?`: ${n}`:``}`),this.code=t,this.name=`HttpError`,Object.setPrototypeOf(this,e.prototype)}},N=function(e){return e.DELETE=`DELETE`,e.GET=`GET`,e.PATCH=`PATCH`,e.POST=`POST`,e}({}),lt=class e{constructor(){this.headers={}}setHeaders(e){this.headers=e}async get(t){try{let n=t.query?`${t.url}?${this.serializeQuery(t.query)}`:t.url,r=await fetch(n,{headers:{...this.headers,...t.headers,"Content-Type":`application/json`},...t.signal?{signal:t.signal}:{}});return r.ok?T(await e.parseBody(r)):E(new M(r.status,await r.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}async post(t){try{let n=await fetch(t.url,{method:`POST`,headers:{...this.headers,...t.headers,"Content-Type":`application/json`},body:JSON.stringify(t.payload),...t.signal?{signal:t.signal}:{}});return n.ok?T(await e.parseBody(n)):E(new M(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}async delete(t){try{let n=await fetch(t.url,{method:`DELETE`,headers:{...this.headers,...t.headers,Accept:`application/json`},...t.signal?{signal:t.signal}:{}});return n.ok?T(await e.parseBody(n)):E(new M(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}async patch(t){try{let n=await fetch(t.url,{method:`PATCH`,headers:{...this.headers,...t.headers,"Content-Type":`application/json`},body:JSON.stringify(t.payload),...t.signal?{signal:t.signal}:{}});return n.ok?T(await e.parseBody(n)):E(new M(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}static async parseBody(e){if(e.status!==D.NO_CONTENT)return await e.json()}serializeQuery(e){if(typeof e==`string`)return e;if(typeof e==`object`)for(let t in e)e[t]===void 0&&delete e[t];return e=ct.stringify(e,{arrayFormat:`none`}),e}},ut={accessToken:{email:`/v1/auth/accessToken/email`,sso:{jwt:`/v1/auth/accessToken/sso/jwt`}},refreshAccessToken:`/v1/auth/accessToken~refresh`,password:{reset:`/v1/auth/password~reset`}},dt=class e extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return e.instance||=new e,e.instance}async loginWithPassword(e,t){let n=await this.callApi({endpoint:ut.accessToken.email,method:`POST`,body:{email:e,password:t},withSpotId:!0});if(n.isErr())return E(n.error);let{accessToken:r,refreshToken:i}=n.value;return this.setTokens(r.token,i.token),T({accessToken:r.token,refreshToken:i.token})}async loginWithSsoToken(e){let t=await this.callApi({endpoint:ut.accessToken.sso.jwt,method:`POST`,body:{token:e},withSpotId:!0});if(t.isErr())return E(t.error);let{accessToken:n,refreshToken:r}=t.value;return this.setTokens(n.token,r.token),T({accessToken:n.token,refreshToken:r.token})}loginWithAuthTokens(e,t){return this.setTokens(e,t),{accessToken:e,refreshToken:t}}resetPassword(e){return this.callApi({endpoint:ut.password.reset,method:`POST`,body:{email:e}})}async refresh(){let e=await this.callApi({endpoint:ut.refreshAccessToken,method:`POST`,body:{refreshToken:this.refreshToken}});if(e.isErr())return E(e.error);let{accessToken:t,refreshToken:n}=e.value;return this.setTokens(t.token,n.token),T({accessToken:t.token,refreshToken:n.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(e,t){if(this.accessToken!==e||this.refreshToken!==t){this.accessToken=e,this.refreshToken=t;let n=new CustomEvent(`auth:tokens-updated`,{detail:{accessToken:e,refreshToken:t}});this.dispatchEvent(n)}}async callApi(e){try{let{spotId:t,msApiBaseUrl:n}=Ie.getConfiguration(),r=se(e.endpoint,n),i={"Content-Type":`application/json`,...e.headers};e.withSpotId&&t&&(i[ft.SpotId]=t);let a=await fetch(r,{method:e.method,body:e.body?JSON.stringify(e.body):void 0,headers:i});return a.ok?a.status===D.NO_CONTENT?T(void 0):T(await a.json()):E(new M(a.status,a.statusText))}catch(e){return E(new M(D.INTERNAL_SERVER_ERROR,e instanceof Error?e.message:String(e)))}}},ft=function(e){return e.Authorization=`Authorization`,e.SpotId=`x-spotid`,e}({}),P=class e{static getInstance(){return e.instance||=new e,e.instance}static buildAuthenticatedRequest(e){let{msApiBaseUrl:t,spotId:n}=Ie.getConfiguration(),r=se(e,t),i=dt.getInstance().getAccessToken();if(!i)return E(Error(`Not authenticated`));let a={"Content-Type":`application/json`,Authorization:`Bearer ${i}`};return n&&(a[`x-spotid`]=n),T({url:r,headers:a})}static async stream(t,n,r){let{streamTransport:i}=Ie.getConfiguration();if(i)return i({endpoint:t,body:n,signal:r});let a=e.buildAuthenticatedRequest(t);if(a.isErr())return E(a.error);let{url:o,headers:s}=a.value;try{let e=await fetch(o,{method:`POST`,headers:s,...n===void 0?{}:{body:JSON.stringify(n)},...r?{signal:r}:{}});if(!e.ok){let t=await e.text();return E(Error(`HTTP ${e.status}: ${t}`))}return e.body?T(e.body):E(Error(`Response body is empty`))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(e instanceof Error?e:Error(t))}}get pendingCount(){return this.queue.length}constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=dt.getInstance(),this.httpService=new lt}enqueue(e){return new Promise(t=>{this.queue.push(async()=>{try{t(await e())}catch(e){t(E(new M(D.INTERNAL_SERVER_ERROR,e instanceof Error?e.message:`Unknown error`)))}}),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){let e=this.queue.shift();if(!e)break;await e()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){let e=this.isPaused;this.isPaused=!1,e&&this.processQueue()}async call(e){return this.enqueue(async()=>{let t=async()=>{let{spotId:t,msApiBaseUrl:n}=Ie.getConfiguration(),r={...e.options?.headers??{}};t&&(r[`x-spotid`]=t);let i=this.authService.getAccessToken(),{requiresAuth:a=!0}=e;if(!i&&a)return E(new M(D.UNAUTHORIZED));i&&(r.Authorization=`Bearer ${i}`);let o=se(e.endpoint,n);switch(e.method){case N.DELETE:return this.httpService.delete({...e.options??{},headers:r,url:o});case N.GET:return this.httpService.get({...e.options??{},headers:r,url:o});case N.PATCH:return this.httpService.patch({...e.options??{},headers:r,url:o});case N.POST:return this.httpService.post({...e.options??{},headers:r,url:o});default:return E(new M(D.METHOD_NOT_ALLOWED,`Method not allowed`))}},n=await t();if(n.isErr()&&n.error.code===D.UNAUTHORIZED){let e=await this.authService.refresh();if(e.isErr())return E(new M(D.UNAUTHORIZED,e.error.message));n=await t()}return n})}},pt={playbooks:`/v1/playbooks`,pages:e=>`/v1/playbooks/${e}/pages`,hotspots:(e,t)=>`/v1/playbooks/${e}/pages/${t}/hotspots`,hotspot:(e,t,n)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}`,accessibleIntents:(e,t)=>`/v1/playbooks/${e}/pages/${t}/accessibleIntents`,intents:(e,t,n)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}/intents`,intent:(e,t,n,r)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}/intents/${r}`},mt=50,ht=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async listPlaybooks(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.playbooks,options:{query:{page:e?.page??1,limit:e?.limit??mt,...e?.domain?{"domain[eq]":e.domain}:{},...e?.host===void 0?{}:{"domain[matchesHost]":e.host}}}});return t.isErr()?E(t.error):T(t.value)}async listPlaybookPages(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.pages(e.playbookId),options:{query:{page:e.page??1,limit:e.limit??mt,...e.url?{"url[eq]":e.url}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookPage(e,t){let n=await this.meltingSpotApi.call({method:N.POST,endpoint:pt.pages(e.playbookId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async listAccessiblePlaybookIntents(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.accessibleIntents(e.playbookId,e.pageId),options:{query:{...e.domain?{domain:e.domain}:{}}}});return t.isErr()?E(t.error):T(t.value)}async listPlaybookHotspots(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.hotspots(e.playbookId,e.pageId),options:{query:{page:e.page??1,limit:e.limit??mt,...e.intentStatus?{"intentStatus[eq]":e.intentStatus}:{},...e.widgetType?{"widgetType[eq]":e.widgetType}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookHotspot(e,t){let n=await this.meltingSpotApi.call({method:N.POST,endpoint:pt.hotspots(e.playbookId,e.pageId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async updatePlaybookHotspot(e,t){let n=await this.meltingSpotApi.call({method:N.PATCH,endpoint:pt.hotspot(e.playbookId,e.pageId,e.hotspotId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async listPlaybookIntents(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.intents(e.playbookId,e.pageId,e.hotspotId),options:{query:{page:e.page??1,limit:e.limit??mt,...e.status?{"status[eq]":e.status}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookIntent(e,t){let n=await this.meltingSpotApi.call({method:N.POST,endpoint:pt.intents(e.playbookId,e.pageId,e.hotspotId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async updatePlaybookIntent(e,t){let n=await this.meltingSpotApi.call({method:N.PATCH,endpoint:pt.intent(e.playbookId,e.pageId,e.hotspotId,e.intentId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}},gt={me:`/v1/spots/me`},_t=1,vt=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async listSpotsForMe(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:gt.me,options:{query:{page:e?.page??_t,limit:e?.limit??50,...e?.spotMemberRole?{"spotMemberRole[eq]":e.spotMemberRole}:{},...e?.id?{"id[eq]":e.id}:{},...e?.name?{"name[contains]":e.name}:{}}}});return t.isErr()?E(t.error):T(t.value)}},yt={spotMember:{me:`/v1/spotMembers/me`,joinFromSso:`/v1/spotMembers~joinFromSso`,search:`/v1/spotMembers~search`}},bt=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async getSpotMemberForMe(){let e=await this.meltingSpotApi.call({method:N.GET,endpoint:yt.spotMember.me});return e.isErr()?E(e.error):T(e.value)}async searchSpotMembers(e){let t={page:e.page,limit:e.limit};e.search&&(t.search=e.search);let n=await this.meltingSpotApi.call({method:N.GET,endpoint:yt.spotMember.search,options:{query:t}});return n.isErr()?E(n.error):T(n.value)}async joinFromSso(e){let t=await this.meltingSpotApi.call({method:N.POST,endpoint:yt.spotMember.joinFromSso,options:{payload:{token:e}}});return t.isErr()?E(t.error):T(t.value)}},xt={spotMemberSsoToken:`/v1/spotMembers/auth/sso/jwt`,previewAccessKey:`/v1/spotMembers/auth/preview/accessKey`},St=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async generateSsoToken(){let e=await this.meltingSpotApi.call({method:N.POST,endpoint:xt.spotMemberSsoToken,options:{payload:{}}});return e.isErr()?E(e.error):T(e.value.token)}async generatePreviewAccessKey(e){let t=await this.meltingSpotApi.call({method:N.POST,endpoint:xt.previewAccessKey,options:{payload:{targetSpotMemberId:e.targetSpotMemberId}}});return t.isErr()?E(t.error):T(t.value)}},Ct=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.spotMemberAuthApiService=St.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}},wt=e=>{let t=e.get(`utm_source`);if(t)return{source:t,medium:e.get(`utm_medium`)??void 0,campaign:e.get(`utm_campaign`)??void 0,term:e.get(`utm_term`)??void 0,content:e.get(`utm_content`)??void 0}},Tt=e=>e?Object.entries(e).reduce((e,[t,n])=>(n!=null&&(e[`utm_${t}`]=n),e),{}):{},Et=Ie.getInstance(),Dt=dt.getInstance(),Ot=Ct.getInstance(),kt={Playbook:ht.getInstance(),Spot:vt.getInstance(),SpotMember:bt.getInstance()},At=globalThis;At.MeltingSpot||={},At.MeltingSpot.Configuration=Et,At.MeltingSpot.Auth=Dt,At.MeltingSpot.Sso=Ot,At.MeltingSpot.Api=kt;var jt=new Oe({appName:`Embed SDK`,appVersion:`1.17.0`}),Mt=class{#e=null;#t=null;constructor(e){this.content=e}set onRemove(e){this.#t=e}inject(e){this.remove();let t=ce({input:e,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add(`ms-embed`),t.appendChild(this.#e)}remove(){this.#e&&=(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),null)}},Nt=class{constructor(e){this.baseURL=Pe(e.baseURL),this.spotId=Ae(e.spotId),this.authToken=e.authToken??null,this.themeMode=e.themeMode??`auto`,this.domain=e.domain??null,this.deeplink=e.deeplink?Me({deeplink:e.deeplink,spotId:this.spotId}):null,this.utmParameters=e.utmParameters??null,this.rootDocument=e.rootDocument}get iframe(){let e=this.authToken&&this.authToken.trim().length>0?`/sso/jwt`:``,t=ue({url:new URL(`/spot/${this.spotId}${e}`,oe(this.baseURL)),searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...Tt(this.utmParameters)},rootDocument:this.rootDocument});return t.classList.add(`ms-spot`),t}},Pt={READY:`meltingspot:ready`,ERROR:`meltingspot:error`,PREFILL_DRAFT:`meltingspot:prefillDraft`},Ft=class e{static{this.embeds=[]}static{this.messageListened=!1}static{this.iframeCallbacks=new Map}static injectSpotInto(t,n){let{onReady:r,onError:i,...a}=n,{spotId:o,rootDocument:s,msCommunityWebBaseUrl:c}=Ie.getConfiguration({spotId:a.spotId,rootDocument:a.rootDocument,msCommunityWebBaseUrl:a.baseURL});if(!o)throw jt.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let l=new URLSearchParams(window.location.search),u={spotId:o,authToken:a.authToken??l.get(`ms_token`),domain:a.domain,deeplink:a.deeplink??l.get(`ms_url`),themeMode:a.themeMode,utmParameters:a.utmParameters??wt(l),baseURL:c,rootDocument:s},d=new Mt(new Nt(u));if(d.inject(t),e.embeds.push(d),r||i){let t=d.content.iframe.contentWindow;t&&(e.iframeCallbacks.set(t,{onReady:r,onError:i}),d.onRemove=t=>{e.iframeCallbacks.delete(t)}),e.ensureMessageListener()}return jt.log(`Spot injected`,u,t),d}static clear(){e.embeds.forEach(e=>{e.remove()}),e.embeds=[],e.iframeCallbacks.clear(),e.messageListened&&=(window.removeEventListener(`message`,e.handleMessageEvent),!1),jt.log(`All MeltingSpot embeds cleared`)}static handleMessageEvent(t){if(!t.data||typeof t.data!=`object`||t.data.type!==Pt.READY&&t.data.type!==Pt.ERROR)return;let n=t.source,r=e.iframeCallbacks.get(n);if(!r)return;let{msCommunityWebBaseUrl:i}=Ie.getConfiguration({});if(i)try{let e=new URL(i).origin;if(t.origin!==e)return}catch{}t.data.type===Pt.READY?r.onReady?.():r.onError?.(t.data.error)}static ensureMessageListener(){e.messageListened||=(window.addEventListener(`message`,e.handleMessageEvent),!0)}},It=globalThis;It.MeltingSpot||={},It.MeltingSpot.Embed=Ft,e.EMBED_POST_MESSAGE_TYPE=Pt,e.Embed=Ft,e.EmbedFrame=Mt});
|
|
20
|
+
}`;var g=af(function(){return at(o,m+`return `+f).apply(n,s)});if(g.source=f,ou(g))throw g;return g}function Jd(e){return Q(e).toLowerCase()}function Yd(e){return Q(e).toUpperCase()}function Xd(e,t,r){if(e=Q(e),e&&(r||t===n))return Ln(e);if(!e||!(t=Ca(t)))return e;var i=ar(e),a=ar(t);return Fa(i,Vn(i,a),Hn(i,a)+1).join(``)}function Zd(e,t,r){if(e=Q(e),e&&(r||t===n))return e.slice(0,or(e)+1);if(!e||!(t=Ca(t)))return e;var i=ar(e);return Fa(i,0,Hn(i,ar(t))+1).join(``)}function Qd(e,t,r){if(e=Q(e),e&&(r||t===n))return e.replace(He,``);if(!e||!(t=Ca(t)))return e;var i=ar(e);return Fa(i,Vn(i,ar(t))).join(``)}function $d(e,t){var r=30,i=`...`;if(Y(t)){var a=`separator`in t?t.separator:a;r=`length`in t?Z(t.length):r,i=`omission`in t?Ca(t.omission):i}e=Q(e);var o=e.length;if(Jn(e)){var s=ar(e);o=s.length}if(r>=o)return e;var c=r-ir(i);if(c<1)return i;var l=s?Fa(s,0,c).join(``):e.slice(0,c);if(a===n)return l+i;if(s&&(c+=l.length-c),bu(a)){if(e.slice(c).search(a)){var u,d=l;for(a.global||(a=st(a.source,Q(Xe.exec(a))+`g`)),a.lastIndex=0;u=a.exec(d);)var f=u.index;l=l.slice(0,f===n?c:f)}}else if(e.indexOf(Ca(a),c)!=c){var p=l.lastIndexOf(a);p>-1&&(l=l.slice(0,p))}return l+i}function ef(e){return e=Q(e),e&&Me.test(e)?e.replace(Ae,sr):e}var tf=ro(function(e,t,n){return e+(n?` `:``)+t.toUpperCase()}),nf=no(`toUpperCase`);function rf(e,t,r){return e=Q(e),t=r?n:t,t===n?Yn(e)?ur(e):Cn(e):e.match(t)||[]}var af=G(function(e,t){try{return ln(e,n,t)}catch(e){return ou(e)?e:new it(e)}}),of=Oo(function(e,t){return dn(t,function(t){t=bs(t),oi(e,t,xl(e[t],e))}),e});function sf(e){var t=e==null?0:e.length,n=K();return e=t?V(e,function(e){if(typeof e[1]!=`function`)throw new M(r);return[n(e[0]),e[1]]}):[],G(function(n){for(var r=-1;++r<t;){var i=e[r];if(ln(i[0],this,n))return ln(i[1],this,n)}})}function cf(e){return ui(li(e,1))}function lf(e){return function(){return e}}function uf(e,t){return e==null||e!==e?t:e}var df=so(),ff=so(!0);function pf(e){return e}function mf(e){return Ki(typeof e==`function`?e:li(e,1))}function hf(e){return Zi(li(e,1))}function gf(e,t){return Qi(e,li(t,1))}var _f=G(function(e,t){return function(n){return Pi(n,e,t)}}),vf=G(function(e,t){return function(n){return Pi(e,n,t)}});function yf(e,t,n){var r=$(t),i=wi(t,r);n==null&&!(Y(t)&&(i.length||!r.length))&&(n=t,t=e,e=this,i=wi(t,$(t)));var a=!(Y(n)&&`chain`in n)||!!n.chain,o=cu(e);return dn(i,function(n){var r=t[n];e[n]=r,o&&(e.prototype[n]=function(){var t=this.__chain__;if(a||t){var n=e(this.__wrapped__);return(n.__actions__=qa(this.__actions__)).push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,_n([this.value()],arguments))})}),e}function bf(){return z._===this&&(z._=_t),this}function xf(){}function Sf(e){return e=Z(e),G(function(t){return ta(t,e)})}var Cf=fo(V),wf=fo(pn),Tf=fo(bn);function Ef(e){return Zo(e)?An(bs(e)):aa(e)}function Df(e){return function(t){return e==null?n:Ti(e,t)}}var Of=ho(),kf=ho(!0);function Af(){return[]}function jf(){return!1}function Mf(){return{}}function Nf(){return``}function Pf(){return!0}function Ff(e,t){if(e=Z(e),e<1||e>g)return[];var n=y,r=R(e,y);t=K(t),e-=y;for(var i=Fn(r,t);++n<e;)t(n);return i}function If(e){return q(e)?V(e,bs):wu(e)?[e]:qa(ys(Q(e)))}function Lf(e){var t=++pt;return Q(e)+t}var Rf=uo(function(e,t){return e+t},0),zf=vo(`ceil`),Bf=uo(function(e,t){return e/t},1),Vf=vo(`floor`);function Hf(e){return e&&e.length?_i(e,pf,Oi):n}function Uf(e,t){return e&&e.length?_i(e,K(t,2),Oi):n}function Wf(e){return kn(e,pf)}function Gf(e,t){return kn(e,K(t,2))}function Kf(e){return e&&e.length?_i(e,pf,Yi):n}function qf(e,t){return e&&e.length?_i(e,K(t,2),Yi):n}var Jf=uo(function(e,t){return e*t},1),Yf=vo(`round`),Xf=uo(function(e,t){return e-t},0);function Zf(e){return e&&e.length?Pn(e,pf):0}function Qf(e,t){return e&&e.length?Pn(e,K(t,2)):0}return H.after=vl,H.ary=yl,H.assign=Lu,H.assignIn=Ru,H.assignInWith=zu,H.assignWith=Bu,H.at=Vu,H.before=bl,H.bind=xl,H.bindAll=of,H.bindKey=Sl,H.castArray=Vl,H.chain=Pc,H.chunk=ws,H.compact=Ts,H.concat=Es,H.cond=sf,H.conforms=cf,H.constant=lf,H.countBy=Gc,H.create=Hu,H.curry=Cl,H.curryRight=wl,H.debounce=Tl,H.defaults=Uu,H.defaultsDeep=Wu,H.defer=El,H.delay=Dl,H.difference=Ds,H.differenceBy=Os,H.differenceWith=ks,H.drop=As,H.dropRight=js,H.dropRightWhile=Ms,H.dropWhile=Ns,H.fill=Ps,H.filter=qc,H.flatMap=Xc,H.flatMapDeep=Zc,H.flatMapDepth=Qc,H.flatten=Ls,H.flattenDeep=Rs,H.flattenDepth=zs,H.flip=Ol,H.flow=df,H.flowRight=ff,H.fromPairs=Bs,H.functions=Zu,H.functionsIn=Qu,H.groupBy=tl,H.initial=Us,H.intersection=Ws,H.intersectionBy=Gs,H.intersectionWith=Ks,H.invert=nd,H.invertBy=rd,H.invokeMap=rl,H.iteratee=mf,H.keyBy=il,H.keys=$,H.keysIn=ad,H.map=al,H.mapKeys=od,H.mapValues=sd,H.matches=hf,H.matchesProperty=gf,H.memoize=kl,H.merge=cd,H.mergeWith=ld,H.method=_f,H.methodOf=vf,H.mixin=yf,H.negate=Al,H.nthArg=Sf,H.omit=ud,H.omitBy=dd,H.once=jl,H.orderBy=ol,H.over=Cf,H.overArgs=Ml,H.overEvery=wf,H.overSome=Tf,H.partial=Nl,H.partialRight=Pl,H.partition=sl,H.pick=fd,H.pickBy=pd,H.property=Ef,H.propertyOf=Df,H.pull=Zs,H.pullAll=Qs,H.pullAllBy=$s,H.pullAllWith=ec,H.pullAt=tc,H.range=Of,H.rangeRight=kf,H.rearg=Fl,H.reject=ul,H.remove=nc,H.rest=Il,H.reverse=rc,H.sampleSize=fl,H.set=hd,H.setWith=gd,H.shuffle=pl,H.slice=ic,H.sortBy=gl,H.sortedUniq=dc,H.sortedUniqBy=fc,H.split=Wd,H.spread=Ll,H.tail=pc,H.take=mc,H.takeRight=hc,H.takeRightWhile=gc,H.takeWhile=_c,H.tap=Fc,H.throttle=Rl,H.thru=Ic,H.toArray=ju,H.toPairs=_d,H.toPairsIn=vd,H.toPath=If,H.toPlainObject=Fu,H.transform=yd,H.unary=zl,H.union=vc,H.unionBy=yc,H.unionWith=bc,H.uniq=xc,H.uniqBy=Sc,H.uniqWith=Cc,H.unset=bd,H.unzip=wc,H.unzipWith=Tc,H.update=xd,H.updateWith=Sd,H.values=Cd,H.valuesIn=wd,H.without=Ec,H.words=rf,H.wrap=Bl,H.xor=Dc,H.xorBy=Oc,H.xorWith=kc,H.zip=Ac,H.zipObject=jc,H.zipObjectDeep=Mc,H.zipWith=Nc,H.entries=_d,H.entriesIn=vd,H.extend=Ru,H.extendWith=zu,yf(H,H),H.add=Rf,H.attempt=af,H.camelCase=Od,H.capitalize=kd,H.ceil=zf,H.clamp=Td,H.clone=Hl,H.cloneDeep=Wl,H.cloneDeepWith=Gl,H.cloneWith=Ul,H.conformsTo=Kl,H.deburr=Ad,H.defaultTo=uf,H.divide=Bf,H.endsWith=jd,H.eq=ql,H.escape=Md,H.escapeRegExp=Nd,H.every=Kc,H.find=Jc,H.findIndex=Fs,H.findKey=Gu,H.findLast=Yc,H.findLastIndex=Is,H.findLastKey=Ku,H.floor=Vf,H.forEach=$c,H.forEachRight=el,H.forIn=qu,H.forInRight=Ju,H.forOwn=Yu,H.forOwnRight=Xu,H.get=$u,H.gt=Jl,H.gte=Yl,H.has=ed,H.hasIn=td,H.head=Vs,H.identity=pf,H.includes=nl,H.indexOf=Hs,H.inRange=Ed,H.invoke=id,H.isArguments=Xl,H.isArray=q,H.isArrayBuffer=Zl,H.isArrayLike=Ql,H.isArrayLikeObject=J,H.isBoolean=$l,H.isBuffer=eu,H.isDate=tu,H.isElement=nu,H.isEmpty=ru,H.isEqual=iu,H.isEqualWith=au,H.isError=ou,H.isFinite=su,H.isFunction=cu,H.isInteger=lu,H.isLength=uu,H.isMap=du,H.isMatch=fu,H.isMatchWith=pu,H.isNaN=mu,H.isNative=hu,H.isNil=_u,H.isNull=gu,H.isNumber=vu,H.isObject=Y,H.isObjectLike=X,H.isPlainObject=yu,H.isRegExp=bu,H.isSafeInteger=xu,H.isSet=Su,H.isString=Cu,H.isSymbol=wu,H.isTypedArray=Tu,H.isUndefined=Eu,H.isWeakMap=Du,H.isWeakSet=Ou,H.join=qs,H.kebabCase=Pd,H.last=Js,H.lastIndexOf=Ys,H.lowerCase=Fd,H.lowerFirst=Id,H.lt=ku,H.lte=Au,H.max=Hf,H.maxBy=Uf,H.mean=Wf,H.meanBy=Gf,H.min=Kf,H.minBy=qf,H.stubArray=Af,H.stubFalse=jf,H.stubObject=Mf,H.stubString=Nf,H.stubTrue=Pf,H.multiply=Jf,H.nth=Xs,H.noConflict=bf,H.noop=xf,H.now=_l,H.pad=Ld,H.padEnd=Rd,H.padStart=zd,H.parseInt=Bd,H.random=Dd,H.reduce=cl,H.reduceRight=ll,H.repeat=Vd,H.replace=Hd,H.result=md,H.round=Yf,H.runInContext=e,H.sample=dl,H.size=ml,H.snakeCase=Ud,H.some=hl,H.sortedIndex=ac,H.sortedIndexBy=oc,H.sortedIndexOf=sc,H.sortedLastIndex=cc,H.sortedLastIndexBy=lc,H.sortedLastIndexOf=uc,H.startCase=Gd,H.startsWith=Kd,H.subtract=Xf,H.sum=Zf,H.sumBy=Qf,H.template=qd,H.times=Ff,H.toFinite=Mu,H.toInteger=Z,H.toLength=Nu,H.toLower=Jd,H.toNumber=Pu,H.toSafeInteger=Iu,H.toString=Q,H.toUpper=Yd,H.trim=Xd,H.trimEnd=Zd,H.trimStart=Qd,H.truncate=$d,H.unescape=ef,H.uniqueId=Lf,H.upperCase=tf,H.upperFirst=nf,H.each=$c,H.eachRight=el,H.first=Vs,yf(H,function(){var e={};return Si(H,function(t,n){P.call(H.prototype,n)||(e[n]=t)}),e}(),{chain:!1}),H.VERSION=`4.17.21`,dn([`bind`,`bindKey`,`curry`,`curryRight`,`partial`,`partialRight`],function(e){H[e].placeholder=H}),dn([`drop`,`take`],function(e,t){U.prototype[e]=function(r){r=r===n?1:F(Z(r),0);var i=this.__filtered__&&!t?new U(this):this.clone();return i.__filtered__?i.__takeCount__=R(r,i.__takeCount__):i.__views__.push({size:R(r,y),type:e+(i.__dir__<0?`Right`:``)}),i},U.prototype[e+`Right`]=function(t){return this.reverse()[e](t).reverse()}}),dn([`filter`,`map`,`takeWhile`],function(e,t){var n=t+1,r=n==1||n==3;U.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:K(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}}),dn([`head`,`last`],function(e,t){var n=`take`+(t?`Right`:``);U.prototype[e]=function(){return this[n](1).value()[0]}}),dn([`initial`,`tail`],function(e,t){var n=`drop`+(t?``:`Right`);U.prototype[e]=function(){return this.__filtered__?new U(this):this[n](1)}}),U.prototype.compact=function(){return this.filter(pf)},U.prototype.find=function(e){return this.filter(e).head()},U.prototype.findLast=function(e){return this.reverse().find(e)},U.prototype.invokeMap=G(function(e,t){return typeof e==`function`?new U(this):this.map(function(n){return Pi(n,e,t)})}),U.prototype.reject=function(e){return this.filter(Al(K(e)))},U.prototype.slice=function(e,t){e=Z(e);var r=this;return r.__filtered__&&(e>0||t<0)?new U(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(t=Z(t),r=t<0?r.dropRight(-t):r.take(t-e)),r)},U.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},U.prototype.toArray=function(){return this.take(y)},Si(U.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=H[i?`take`+(t==`last`?`Right`:``):t],o=i||/^find/.test(t);a&&(H.prototype[t]=function(){var t=this.__wrapped__,s=i?[1]:arguments,c=t instanceof U,l=s[0],u=c||q(t),d=function(e){var t=a.apply(H,_n([e],s));return i&&f?t[0]:t};u&&r&&typeof l==`function`&&l.length!=1&&(c=u=!1);var f=this.__chain__,p=!!this.__actions__.length,m=o&&!f,h=c&&!p;if(!o&&u){t=h?t:new U(this);var g=e.apply(t,s);return g.__actions__.push({func:Ic,args:[d],thisArg:n}),new yr(g,f)}return m&&h?e.apply(this,s):(g=this.thru(d),m?i?g.value()[0]:g.value():g)})}),dn([`pop`,`push`,`shift`,`sort`,`splice`,`unshift`],function(e){var t=N[e],n=/^(?:push|sort|unshift)$/.test(e)?`tap`:`thru`,r=/^(?:pop|shift)$/.test(e);H.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(q(i)?i:[],e)}return this[n](function(n){return t.apply(q(n)?n:[],e)})}}),Si(U.prototype,function(e,t){var n=H[t];if(n){var r=n.name+``;P.call(jn,r)||(jn[r]=[]),jn[r].push({name:t,func:n})}}),jn[co(n,s).name]=[{name:`wrapper`,func:n}],U.prototype.clone=br,U.prototype.reverse=xr,U.prototype.value=Sr,H.prototype.at=Lc,H.prototype.chain=Rc,H.prototype.commit=zc,H.prototype.next=Bc,H.prototype.plant=Hc,H.prototype.reverse=Uc,H.prototype.toJSON=H.prototype.valueOf=H.prototype.value=Wc,H.prototype.first=H.prototype.head,Ot&&(H.prototype[Ot]=Vc),H})();typeof define==`function`&&typeof define.amd==`object`&&define.amd?(z._=dr,define(function(){return dr})):$t?(($t.exports=dr)._=dr,Qt._=dr):z._=dr}).call(e)}))(),Object.values(function(e){return e.EditMode=`edit-mode`,e.Preview=`preview`,e}({}));var De=`1.18.0`,Oe=class{constructor(e){this.debug=!1,this.debug=e?.debug??!1,this.appName=e?.appName,this.appVersion=e?.appVersion}log(e,...t){this.debug&&this.print(e,`info`,t)}warn(e,...t){this.print(e,`warn`,t)}error(e,...t){this.print(e,`error`,t)}print(e,t,n){let r=[`[${[`MeltingSpot`,this.appName,this.appVersion].filter(Boolean).join(` - `)}] ${e}`];n.length&&r.push(...n),console[t](...r)}},ke=new Oe({appName:`Core SDK`,appVersion:De}),Ae=e=>e.toLowerCase().replace(/[^a-z0-9-]/g,``),je=[`/user`],Me=({deeplink:e,spotId:t})=>{try{let n=new URL(e,`https://unused.com`),r=n.pathname;return n.search&&(r+=n.search),n.hash&&(r+=n.hash),je.some(e=>r.startsWith(e))||(r=`/spot/${t}/${ie(r)}`),r}catch(e){return ke.warn(`Failed to parse deeplink URL`,e),null}},Ne=[/(^|\.)meltingspot\.io$/i],Pe=e=>{let t;try{let n=oe(e);t=new URL(n)}catch{throw Error(`Invalid baseURL: ${e}`)}let n=t.hostname===`localhost`||t.hostname===`127.0.0.1`,r=t.protocol===`https:`,i=Ne.some(e=>e.test(t.hostname));if(!n&&(!r||!i))throw Error(`Untrusted baseURL origin: ${t.origin}`);return t.origin},Fe={msApiBaseUrl:`https://openapi.meltingspot.io/`,msCommunityWebBaseUrl:`https://go.meltingspot.io/`,msCoreBaseUrl:`https://go-api.meltingspot.io/`,ssoToken:void 0,spotId:``,autoJoin:!1,rootDocument:globalThis.document},Ie=class e{constructor(){this.configuration=Fe}static getInstance(){return e.instance||=new e,e.instance}setConfiguration(e){this.configuration={...this.configuration,...e}}static getConfiguration(t={}){let n=e.getInstance(),r=Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0));return{...n.configuration,...r}}},Le=RegExp(`(%[a-f0-9]{2})|([^%]+?)`,`gi`),Re=RegExp(`(%[a-f0-9]{2})+`,`gi`);function ze(e,t){try{return[decodeURIComponent(e.join(``))]}catch{}if(e.length===1)return e;t||=1;let n=e.slice(0,t),r=e.slice(t);return Array.prototype.concat.call([],ze(n),ze(r))}function Be(e){try{return decodeURIComponent(e)}catch{let t=e.match(Le)||[];for(let n=1;n<t.length;n++)e=ze(t,n).join(``),t=e.match(Le)||[];return e}}function Ve(e){let t={"%FE%FF":`��`,"%FF%FE":`��`},n=Re.exec(e);for(;n;){try{t[n[0]]=decodeURIComponent(n[0])}catch{let e=Be(n[0]);e!==n[0]&&(t[n[0]]=e)}n=Re.exec(e)}t[`%C2`]=`�`;let r=Object.keys(t);for(let n of r)e=e.replace(new RegExp(n,`g`),t[n]);return e}function He(e){if(typeof e!=`string`)throw TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return decodeURIComponent(e)}catch{return Ve(e)}}function k(e,t){let n={};if(Array.isArray(t))for(let r of t){let t=Object.getOwnPropertyDescriptor(e,r);t?.enumerable&&Object.defineProperty(n,r,t)}else for(let r of Reflect.ownKeys(e)){let i=Object.getOwnPropertyDescriptor(e,r);if(i.enumerable){let a=e[r];t(r,a,e)&&Object.defineProperty(n,r,i)}}return n}function Ue(e,t){if(typeof e!=`string`||typeof t!=`string`)throw TypeError("Expected the arguments to be of type `string`");if(e===``||t===``)return[];let n=e.indexOf(t);return n===-1?[]:[e.slice(0,n),e.slice(n+t.length)]}var We=c({exclude:()=>st,extract:()=>nt,parse:()=>rt,parseUrl:()=>at,pick:()=>j,stringify:()=>it,stringifyUrl:()=>ot}),Ge=e=>e==null,Ke=e=>encodeURIComponent(e).replaceAll(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),qe=Symbol(`encodeFragmentIdentifier`);function Je(e){switch(e.arrayFormat){case`index`:return t=>(n,r)=>{let i=n.length;return r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[A(t,e),`[`,i,`]`].join(``)]:[...n,[A(t,e),`[`,A(i,e),`]=`,A(r,e)].join(``)]};case`bracket`:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[A(t,e),`[]`].join(``)]:[...n,[A(t,e),`[]=`,A(r,e)].join(``)];case`colon-list-separator`:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[A(t,e),`:list=`].join(``)]:[...n,[A(t,e),`:list=`,A(r,e)].join(``)];case`comma`:case`separator`:case`bracket-separator`:{let t=e.arrayFormat===`bracket-separator`?`[]=`:`=`;return n=>(r,i)=>i===void 0||e.skipNull&&i===null||e.skipEmptyString&&i===``?r:(i=i===null?``:i,r.length===0?[[A(n,e),t,A(i,e)].join(``)]:[[r,A(i,e)].join(e.arrayFormatSeparator)])}default:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,A(t,e)]:[...n,[A(t,e),`=`,A(r,e)].join(``)]}}function Ye(e){let t;switch(e.arrayFormat){case`index`:return(e,n,r)=>{if(t=/\[(\d*)]$/.exec(e),e=e.replace(/\[\d*]$/,``),!t){r[e]=n;return}r[e]===void 0&&(r[e]={}),r[e][t[1]]=n};case`bracket`:return(e,n,r)=>{if(t=/(\[])$/.exec(e),e=e.replace(/\[]$/,``),!t){r[e]=n;return}if(r[e]===void 0){r[e]=[n];return}r[e]=[...r[e],n]};case`colon-list-separator`:return(e,n,r)=>{if(t=/(:list)$/.exec(e),e=e.replace(/:list$/,``),!t){r[e]=n;return}if(r[e]===void 0){r[e]=[n];return}r[e]=[...r[e],n]};case`comma`:case`separator`:return(t,n,r)=>{let i=typeof n==`string`&&n.includes(e.arrayFormatSeparator),a=typeof n==`string`&&!i&&Ze(n,e).includes(e.arrayFormatSeparator);n=a?Ze(n,e):n,r[t]=i||a?n.split(e.arrayFormatSeparator).map(t=>Ze(t,e)):n===null?n:Ze(n,e)};case`bracket-separator`:return(t,n,r)=>{let i=/(\[])$/.test(t);if(t=t.replace(/\[]$/,``),!i){r[t]=n&&Ze(n,e);return}let a=n===null?[]:Ze(n,e).split(e.arrayFormatSeparator);if(r[t]===void 0){r[t]=a;return}r[t]=[...r[t],...a]};default:return(e,t,n)=>{if(n[e]===void 0){n[e]=t;return}n[e]=[...[n[e]].flat(),t]}}}function Xe(e){if(typeof e!=`string`||e.length!==1)throw TypeError(`arrayFormatSeparator must be single character string`)}function A(e,t){return t.encode?t.strict?Ke(e):encodeURIComponent(e):e}function Ze(e,t){return t.decode?He(e):e}function Qe(e){return Array.isArray(e)?e.sort():typeof e==`object`?Qe(Object.keys(e)).sort((e,t)=>Number(e)-Number(t)).map(t=>e[t]):e}function $e(e){let t=e.indexOf(`#`);return t!==-1&&(e=e.slice(0,t)),e}function et(e){let t=``,n=e.indexOf(`#`);return n!==-1&&(t=e.slice(n)),t}function tt(e,t,n){return n===`string`&&typeof e==`string`?e:typeof n==`function`&&typeof e==`string`?n(e):n===`boolean`&&e===null?!0:n===`boolean`&&e!==null&&(e.toLowerCase()===`true`||e.toLowerCase()===`false`)?e.toLowerCase()===`true`:n===`boolean`&&e!==null&&(e.toLowerCase()===`1`||e.toLowerCase()===`0`)?e.toLowerCase()===`1`:n===`string[]`&&t.arrayFormat!==`none`&&typeof e==`string`?[e]:n===`number[]`&&t.arrayFormat!==`none`&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?[Number(e)]:n===`number`&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?Number(e):t.parseBooleans&&e!==null&&(e.toLowerCase()===`true`||e.toLowerCase()===`false`)?e.toLowerCase()===`true`:t.parseNumbers&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?Number(e):e}function nt(e){e=$e(e);let t=e.indexOf(`?`);return t===-1?``:e.slice(t+1)}function rt(e,t){t={decode:!0,sort:!0,arrayFormat:`none`,arrayFormatSeparator:`,`,parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...t},Xe(t.arrayFormatSeparator);let n=Ye(t),r=Object.create(null);if(typeof e!=`string`||(e=e.trim().replace(/^[?#&]/,``),!e))return r;for(let i of e.split(`&`)){if(i===``)continue;let e=t.decode?i.replaceAll(`+`,` `):i,[a,o]=Ue(e,`=`);a===void 0&&(a=e),o=o===void 0?null:[`comma`,`separator`,`bracket-separator`].includes(t.arrayFormat)?o:Ze(o,t),n(Ze(a,t),o,r)}for(let[e,n]of Object.entries(r))if(typeof n==`object`&&n&&t.types[e]!==`string`)for(let[r,i]of Object.entries(n)){let a=t.types[e]?t.types[e].replace(`[]`,``):void 0;n[r]=tt(i,t,a)}else r[e]=typeof n==`object`&&n&&t.types[e]===`string`?Object.values(n).join(t.arrayFormatSeparator):tt(n,t,t.types[e]);return t.sort===!1?r:(t.sort===!0?Object.keys(r).sort():Object.keys(r).sort(t.sort)).reduce((e,t)=>{let n=r[t];return e[t]=n&&typeof n==`object`&&!Array.isArray(n)?Qe(n):n,e},Object.create(null))}function it(e,t){if(!e)return``;t={encode:!0,strict:!0,arrayFormat:`none`,arrayFormatSeparator:`,`,...t},Xe(t.arrayFormatSeparator);let n=n=>t.skipNull&&Ge(e[n])||t.skipEmptyString&&e[n]===``,r=Je(t),i={};for(let[t,r]of Object.entries(e))n(t)||(i[t]=r);let a=Object.keys(i);return t.sort!==!1&&a.sort(t.sort),a.map(n=>{let i=e[n];return i===void 0?``:i===null?A(n,t):Array.isArray(i)?i.length===0&&t.arrayFormat===`bracket-separator`?A(n,t)+`[]`:i.reduce(r(n),[]).join(`&`):A(n,t)+`=`+A(i,t)}).filter(e=>e.length>0).join(`&`)}function at(e,t){t={decode:!0,...t};let[n,r]=Ue(e,`#`);return n===void 0&&(n=e),{url:n?.split(`?`)?.[0]??``,query:rt(nt(e),t),...t&&t.parseFragmentIdentifier&&r?{fragmentIdentifier:Ze(r,t)}:{}}}function ot(e,t){t={encode:!0,strict:!0,[qe]:!0,...t};let n=$e(e.url).split(`?`)[0]||``,r=it({...rt(nt(e.url),{sort:!1,...t}),...e.query},t);r&&=`?${r}`;let i=et(e.url);if(typeof e.fragmentIdentifier==`string`){let r=new URL(n);r.hash=e.fragmentIdentifier,i=t[qe]?r.hash:`#${e.fragmentIdentifier}`}return`${n}${r}${i}`}function j(e,t,n){n={parseFragmentIdentifier:!0,[qe]:!1,...n};let{url:r,query:i,fragmentIdentifier:a}=at(e,n);return ot({url:r,query:k(i,t),fragmentIdentifier:a},n)}function st(e,t,n){return j(e,Array.isArray(t)?e=>!t.includes(e):(e,n)=>!t(e,n),n)}var ct=We,M=class e extends Error{constructor(t,n){super(`HTTP Error ${t}${n?`: ${n}`:``}`),this.code=t,this.name=`HttpError`,Object.setPrototypeOf(this,e.prototype)}},N=function(e){return e.DELETE=`DELETE`,e.GET=`GET`,e.PATCH=`PATCH`,e.POST=`POST`,e}({}),lt=class e{constructor(){this.headers={}}setHeaders(e){this.headers=e}async get(t){try{let n=t.query?`${t.url}?${this.serializeQuery(t.query)}`:t.url,r=await fetch(n,{headers:{...this.headers,...t.headers,"Content-Type":`application/json`},...t.signal?{signal:t.signal}:{}});return r.ok?T(await e.parseBody(r)):E(new M(r.status,await r.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}async post(t){try{let n=await fetch(t.url,{method:`POST`,headers:{...this.headers,...t.headers,"Content-Type":`application/json`},body:JSON.stringify(t.payload),...t.signal?{signal:t.signal}:{}});return n.ok?T(await e.parseBody(n)):E(new M(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}async delete(t){try{let n=await fetch(t.url,{method:`DELETE`,headers:{...this.headers,...t.headers,Accept:`application/json`},...t.signal?{signal:t.signal}:{}});return n.ok?T(await e.parseBody(n)):E(new M(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}async patch(t){try{let n=await fetch(t.url,{method:`PATCH`,headers:{...this.headers,...t.headers,"Content-Type":`application/json`},body:JSON.stringify(t.payload),...t.signal?{signal:t.signal}:{}});return n.ok?T(await e.parseBody(n)):E(new M(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}static async parseBody(e){if(e.status!==D.NO_CONTENT)return await e.json()}serializeQuery(e){if(typeof e==`string`)return e;if(typeof e==`object`)for(let t in e)e[t]===void 0&&delete e[t];return e=ct.stringify(e,{arrayFormat:`none`}),e}},ut={accessToken:{email:`/v1/auth/accessToken/email`,sso:{jwt:`/v1/auth/accessToken/sso/jwt`}},refreshAccessToken:`/v1/auth/accessToken~refresh`,password:{reset:`/v1/auth/password~reset`}},dt=class e extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return e.instance||=new e,e.instance}async loginWithPassword(e,t){let n=await this.callApi({endpoint:ut.accessToken.email,method:`POST`,body:{email:e,password:t},withSpotId:!0});if(n.isErr())return E(n.error);let{accessToken:r,refreshToken:i}=n.value;return this.setTokens(r.token,i.token),T({accessToken:r.token,refreshToken:i.token})}async loginWithSsoToken(e){let t=await this.callApi({endpoint:ut.accessToken.sso.jwt,method:`POST`,body:{token:e},withSpotId:!0});if(t.isErr())return E(t.error);let{accessToken:n,refreshToken:r}=t.value;return this.setTokens(n.token,r.token),T({accessToken:n.token,refreshToken:r.token})}loginWithAuthTokens(e,t){return this.setTokens(e,t),{accessToken:e,refreshToken:t}}resetPassword(e){return this.callApi({endpoint:ut.password.reset,method:`POST`,body:{email:e}})}async refresh(){let e=await this.callApi({endpoint:ut.refreshAccessToken,method:`POST`,body:{refreshToken:this.refreshToken}});if(e.isErr())return E(e.error);let{accessToken:t,refreshToken:n}=e.value;return this.setTokens(t.token,n.token),T({accessToken:t.token,refreshToken:n.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(e,t){if(this.accessToken!==e||this.refreshToken!==t){this.accessToken=e,this.refreshToken=t;let n=new CustomEvent(`auth:tokens-updated`,{detail:{accessToken:e,refreshToken:t}});this.dispatchEvent(n)}}async callApi(e){try{let{spotId:t,msApiBaseUrl:n}=Ie.getConfiguration(),r=se(e.endpoint,n),i={"Content-Type":`application/json`,...e.headers};e.withSpotId&&t&&(i[ft.SpotId]=t);let a=await fetch(r,{method:e.method,body:e.body?JSON.stringify(e.body):void 0,headers:i});return a.ok?a.status===D.NO_CONTENT?T(void 0):T(await a.json()):E(new M(a.status,a.statusText))}catch(e){return E(new M(D.INTERNAL_SERVER_ERROR,e instanceof Error?e.message:String(e)))}}},ft=function(e){return e.Authorization=`Authorization`,e.SpotId=`x-spotid`,e}({}),P=class e{static getInstance(){return e.instance||=new e,e.instance}static buildAuthenticatedRequest(e){let{msApiBaseUrl:t,spotId:n}=Ie.getConfiguration(),r=se(e,t),i=dt.getInstance().getAccessToken();if(!i)return E(Error(`Not authenticated`));let a={"Content-Type":`application/json`,Authorization:`Bearer ${i}`};return n&&(a[`x-spotid`]=n),T({url:r,headers:a})}static async stream(t,n,r){let{streamTransport:i}=Ie.getConfiguration();if(i)return i({endpoint:t,body:n,signal:r});let a=e.buildAuthenticatedRequest(t);if(a.isErr())return E(a.error);let{url:o,headers:s}=a.value;try{let e=await fetch(o,{method:`POST`,headers:s,...n===void 0?{}:{body:JSON.stringify(n)},...r?{signal:r}:{}});if(!e.ok){let t=await e.text();return E(Error(`HTTP ${e.status}: ${t}`))}return e.body?T(e.body):E(Error(`Response body is empty`))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(e instanceof Error?e:Error(t))}}get pendingCount(){return this.queue.length}constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=dt.getInstance(),this.httpService=new lt}enqueue(e){return new Promise(t=>{this.queue.push(async()=>{try{t(await e())}catch(e){t(E(new M(D.INTERNAL_SERVER_ERROR,e instanceof Error?e.message:`Unknown error`)))}}),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){let e=this.queue.shift();if(!e)break;await e()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){let e=this.isPaused;this.isPaused=!1,e&&this.processQueue()}async call(e){return this.enqueue(async()=>{let t=async()=>{let{spotId:t,msApiBaseUrl:n}=Ie.getConfiguration(),r={...e.options?.headers??{}};t&&(r[`x-spotid`]=t);let i=this.authService.getAccessToken(),{requiresAuth:a=!0}=e;if(!i&&a)return E(new M(D.UNAUTHORIZED));i&&(r.Authorization=`Bearer ${i}`);let o=se(e.endpoint,n);switch(e.method){case N.DELETE:return this.httpService.delete({...e.options??{},headers:r,url:o});case N.GET:return this.httpService.get({...e.options??{},headers:r,url:o});case N.PATCH:return this.httpService.patch({...e.options??{},headers:r,url:o});case N.POST:return this.httpService.post({...e.options??{},headers:r,url:o});default:return E(new M(D.METHOD_NOT_ALLOWED,`Method not allowed`))}},n=await t();if(n.isErr()&&n.error.code===D.UNAUTHORIZED){let e=await this.authService.refresh();if(e.isErr())return E(new M(D.UNAUTHORIZED,e.error.message));n=await t()}return n})}},pt={playbooks:`/v1/playbooks`,pages:e=>`/v1/playbooks/${e}/pages`,hotspots:(e,t)=>`/v1/playbooks/${e}/pages/${t}/hotspots`,hotspot:(e,t,n)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}`,accessibleIntents:(e,t)=>`/v1/playbooks/${e}/pages/${t}/accessibleIntents`,intents:(e,t,n)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}/intents`,intent:(e,t,n,r)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}/intents/${r}`},mt=50,ht=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async listPlaybooks(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.playbooks,options:{query:{page:e?.page??1,limit:e?.limit??mt,...e?.domain?{"domain[eq]":e.domain}:{},...e?.host===void 0?{}:{"domain[matchesHost]":e.host}}}});return t.isErr()?E(t.error):T(t.value)}async listPlaybookPages(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.pages(e.playbookId),options:{query:{page:e.page??1,limit:e.limit??mt,...e.url?{"url[eq]":e.url}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookPage(e,t){let n=await this.meltingSpotApi.call({method:N.POST,endpoint:pt.pages(e.playbookId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async listAccessiblePlaybookIntents(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.accessibleIntents(e.playbookId,e.pageId),options:{query:{...e.domain?{domain:e.domain}:{}}}});return t.isErr()?E(t.error):T(t.value)}async listPlaybookHotspots(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.hotspots(e.playbookId,e.pageId),options:{query:{page:e.page??1,limit:e.limit??mt,...e.intentStatus?{"intentStatus[eq]":e.intentStatus}:{},...e.widgetType?{"widgetType[eq]":e.widgetType}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookHotspot(e,t){let n=await this.meltingSpotApi.call({method:N.POST,endpoint:pt.hotspots(e.playbookId,e.pageId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async updatePlaybookHotspot(e,t){let n=await this.meltingSpotApi.call({method:N.PATCH,endpoint:pt.hotspot(e.playbookId,e.pageId,e.hotspotId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async listPlaybookIntents(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.intents(e.playbookId,e.pageId,e.hotspotId),options:{query:{page:e.page??1,limit:e.limit??mt,...e.status?{"status[eq]":e.status}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookIntent(e,t){let n=await this.meltingSpotApi.call({method:N.POST,endpoint:pt.intents(e.playbookId,e.pageId,e.hotspotId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async updatePlaybookIntent(e,t){let n=await this.meltingSpotApi.call({method:N.PATCH,endpoint:pt.intent(e.playbookId,e.pageId,e.hotspotId,e.intentId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}},gt={me:`/v1/spots/me`},_t=1,vt=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async listSpotsForMe(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:gt.me,options:{query:{page:e?.page??_t,limit:e?.limit??50,...e?.spotMemberRole?{"spotMemberRole[eq]":e.spotMemberRole}:{},...e?.id?{"id[eq]":e.id}:{},...e?.name?{"name[contains]":e.name}:{}}}});return t.isErr()?E(t.error):T(t.value)}},yt={spotMember:{me:`/v1/spotMembers/me`,joinFromSso:`/v1/spotMembers~joinFromSso`,search:`/v1/spotMembers~search`}},bt=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async getSpotMemberForMe(){let e=await this.meltingSpotApi.call({method:N.GET,endpoint:yt.spotMember.me});return e.isErr()?E(e.error):T(e.value)}async searchSpotMembers(e){let t={page:e.page,limit:e.limit};e.search&&(t.search=e.search);let n=await this.meltingSpotApi.call({method:N.GET,endpoint:yt.spotMember.search,options:{query:t}});return n.isErr()?E(n.error):T(n.value)}async joinFromSso(e){let t=await this.meltingSpotApi.call({method:N.POST,endpoint:yt.spotMember.joinFromSso,options:{payload:{token:e}}});return t.isErr()?E(t.error):T(t.value)}},xt={spotMemberSsoToken:`/v1/spotMembers/auth/sso/jwt`,previewAccessKey:`/v1/spotMembers/auth/preview/accessKey`},St=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async generateSsoToken(){let e=await this.meltingSpotApi.call({method:N.POST,endpoint:xt.spotMemberSsoToken,options:{payload:{}}});return e.isErr()?E(e.error):T(e.value.token)}async generatePreviewAccessKey(e){let t=await this.meltingSpotApi.call({method:N.POST,endpoint:xt.previewAccessKey,options:{payload:{targetSpotMemberId:e.targetSpotMemberId}}});return t.isErr()?E(t.error):T(t.value)}},Ct=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.spotMemberAuthApiService=St.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}},wt=e=>{let t=e.get(`utm_source`);if(t)return{source:t,medium:e.get(`utm_medium`)??void 0,campaign:e.get(`utm_campaign`)??void 0,term:e.get(`utm_term`)??void 0,content:e.get(`utm_content`)??void 0}},Tt=e=>e?Object.entries(e).reduce((e,[t,n])=>(n!=null&&(e[`utm_${t}`]=n),e),{}):{},Et=Ie.getInstance(),Dt=dt.getInstance(),Ot=Ct.getInstance(),kt={Playbook:ht.getInstance(),Spot:vt.getInstance(),SpotMember:bt.getInstance()},At=globalThis;At.MeltingSpot||={},At.MeltingSpot.Configuration=Et,At.MeltingSpot.Auth=Dt,At.MeltingSpot.Sso=Ot,At.MeltingSpot.Api=kt;var jt=new Oe({appName:`Embed SDK`,appVersion:`1.18.0`}),Mt=`EmbedRedirect`,Nt=/^\/spot\/([^/]+)\/sso\/oidc\/embed\/authorize$/,Pt=e=>{try{return new URL(e).origin}catch{return}},Ft=(e,t)=>{let n=t.find(({contentWindow:t})=>t!==null&&t===e.source);if(!n||!n.origin||e.origin!==n.origin)return;let r=e.data?.url;if(typeof r!=`string`)return;let i;try{i=new URL(r)}catch{return}let a=Pt(n.msCoreBaseUrl),o=Nt.exec(i.pathname)?.[1];if(!(!a||i.origin!==a||o?.toLowerCase()!==n.spotId.toLowerCase()||i.searchParams.get(`mode`)!==Mt))return{source:e.source,origin:e.origin,url:i.toString()}},It=e=>{window.location.assign(e)},Lt={ATTEMPT:`ms_oidc_attempt`,CODE:`ms_oidc_code`,ERROR:`ms_oidc_error`},Rt=(e=window.location,t=window.history)=>{let n=new URLSearchParams(e.hash.replace(/^#/,``)),r=Object.values(Lt);if(!r.some(e=>n.has(e)))return;let i=n.get(Lt.ATTEMPT),a=n.get(Lt.CODE)||void 0,o=n.get(Lt.ERROR)||void 0;r.forEach(e=>n.delete(e));let s=n.toString();return t.replaceState(t.state,``,e.pathname+e.search+(s?`#${s}`:``)),i&&(a||o)?{attemptId:i,code:a,error:o}:void 0},zt=e=>{let t=new URLSearchParams({[Lt.ATTEMPT]:e.attemptId});return e.code&&t.set(Lt.CODE,e.code),e.error&&t.set(Lt.ERROR,e.error),t.toString()},Bt=class{#e=null;#t=null;constructor(e){this.content=e}set onRemove(e){this.#t=e}get contentWindow(){return this.#e?.contentWindow??null}get origin(){if(!this.#e)return null;try{return new URL(this.#e.src).origin}catch{return null}}inject(e){this.remove();let t=ce({input:e,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add(`ms-embed`),t.appendChild(this.#e)}remove(){this.#e&&=(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),null)}},Vt=class{#e;constructor(e){this.baseURL=Pe(e.baseURL),this.spotId=Ae(e.spotId),this.authToken=e.authToken??null,this.themeMode=e.themeMode??`auto`,this.domain=e.domain??null,this.deeplink=e.deeplink?Me({deeplink:e.deeplink,spotId:this.spotId}):null,this.utmParameters=e.utmParameters??null,this.rootDocument=e.rootDocument,this.#e=e.oidcReturn??null}get iframe(){let e=this.#e;this.#e=null;let t=e?null:this.authToken,n=this.getPath(e,t),r=new URL(`/spot/${this.spotId}${n}`,oe(this.baseURL));e&&(r.hash=zt(e));let i=ue({url:r,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:t,domain:this.domain,deeplink:this.deeplink,...Tt(this.utmParameters)},rootDocument:this.rootDocument});return i.classList.add(`ms-spot`),i}getPath(e,t){return e?`/sso/oidc/embed`:t&&t.trim().length>0?`/sso/jwt`:``}},Ht={READY:`meltingspot:ready`,ERROR:`meltingspot:error`,PREFILL_DRAFT:`meltingspot:prefillDraft`,OIDC_REDIRECT:`ms:sso:oidc:redirect`,OIDC_REDIRECT_ACK:`ms:sso:oidc:redirect:ack`},F=class e{static{this.embeds=[]}static{this.messageListened=!1}static{this.iframeCallbacks=new Map}static injectSpotInto(t,n){let{onReady:r,onError:i,...a}=n,{spotId:o,rootDocument:s,msCommunityWebBaseUrl:c,msCoreBaseUrl:l}=Ie.getConfiguration({spotId:a.spotId,rootDocument:a.rootDocument,msCommunityWebBaseUrl:a.baseURL});if(!o)throw jt.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let u=new URLSearchParams(window.location.search),d={spotId:o,authToken:a.authToken??u.get(`ms_token`),domain:a.domain,deeplink:a.deeplink??u.get(`ms_url`),themeMode:a.themeMode,utmParameters:a.utmParameters??wt(u),baseURL:c,rootDocument:s},f=ce({input:t,rootDocument:s}),p=new Vt({...d,oidcReturn:Rt()}),m=new Bt(p);if(m.inject(f),e.embeds.push({frame:m,spotId:p.spotId,msCoreBaseUrl:l}),e.ensureMessageListener(),r||i){let t=m.content.iframe.contentWindow;t&&(e.iframeCallbacks.set(t,{onReady:r,onError:i}),m.onRemove=t=>{e.iframeCallbacks.delete(t)})}return jt.log(`Spot injected`,d,typeof t==`string`?t:t.id),m}static clear(){e.embeds.forEach(({frame:e})=>{e.remove()}),e.embeds=[],e.iframeCallbacks.clear(),e.messageListened&&=(window.removeEventListener(`message`,e.handleMessageEvent),!1),jt.log(`All MeltingSpot embeds cleared`)}static handleMessageEvent(t){if(!t.data||typeof t.data!=`object`)return;if(t.data.type===Ht.OIDC_REDIRECT){e.handleOidcRedirect(t);return}if(t.data.type!==Ht.READY&&t.data.type!==Ht.ERROR)return;let n=t.source,r=e.iframeCallbacks.get(n);if(!r)return;let{msCommunityWebBaseUrl:i}=Ie.getConfiguration({});if(i)try{let e=new URL(i).origin;if(t.origin!==e)return}catch{}t.data.type===Ht.READY?r.onReady?.():r.onError?.(t.data.error)}static handleOidcRedirect(t){let n=Ft(t,e.embeds.map(({frame:e,spotId:t,msCoreBaseUrl:n})=>({contentWindow:e.contentWindow,origin:e.origin,spotId:t,msCoreBaseUrl:n})));if(!n){jt.warn(`OpenID Connect login request ignored`);return}n.source.postMessage({type:Ht.OIDC_REDIRECT_ACK},n.origin),jt.log(`Navigating to the OpenID Connect login`),It(n.url)}static ensureMessageListener(){e.messageListened||=(window.addEventListener(`message`,e.handleMessageEvent),!0)}},Ut=globalThis;Ut.MeltingSpot||={},Ut.MeltingSpot.Embed=F,e.EMBED_POST_MESSAGE_TYPE=Ht,e.Embed=F,e.EmbedFrame=Bt});
|
package/meltingSpotEmbed.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export declare const EMBED_POST_MESSAGE_TYPE: {
|
|
|
4
4
|
readonly READY: "meltingspot:ready";
|
|
5
5
|
readonly ERROR: "meltingspot:error";
|
|
6
6
|
readonly PREFILL_DRAFT: "meltingspot:prefillDraft";
|
|
7
|
+
readonly OIDC_REDIRECT: "ms:sso:oidc:redirect";
|
|
8
|
+
readonly OIDC_REDIRECT_ACK: "ms:sso:oidc:redirect:ack";
|
|
7
9
|
};
|
|
8
10
|
export interface EmbedLifecycleCallbacks {
|
|
9
11
|
onReady?: () => void;
|
|
@@ -13,7 +15,7 @@ export interface EmbedLifecycleCallbacks {
|
|
|
13
15
|
code?: string;
|
|
14
16
|
}) => void;
|
|
15
17
|
}
|
|
16
|
-
export type InjectSpotIntoOptions = Omit<SpotArgs, 'spotId'> & EmbedLifecycleCallbacks & {
|
|
18
|
+
export type InjectSpotIntoOptions = Omit<SpotArgs, 'spotId' | 'oidcReturn'> & EmbedLifecycleCallbacks & {
|
|
17
19
|
spotId?: string;
|
|
18
20
|
};
|
|
19
21
|
export declare class MeltingSpotEmbed {
|
|
@@ -28,5 +30,12 @@ export declare class MeltingSpotEmbed {
|
|
|
28
30
|
static injectSpotInto(element: string | HTMLElement, options: InjectSpotIntoOptions): EmbedFrame;
|
|
29
31
|
static clear(): void;
|
|
30
32
|
private static handleMessageEvent;
|
|
33
|
+
/**
|
|
34
|
+
* Navigates the page to the fallback journey of an OpenID Connect login,
|
|
35
|
+
* when an iframe of the SDK asks for it (AD-29): the request is accepted
|
|
36
|
+
* first, so that the iframe does not tell the window was blocked, then the
|
|
37
|
+
* page leaves. Any other request is ignored. The address is never logged.
|
|
38
|
+
*/
|
|
39
|
+
private static handleOidcRedirect;
|
|
31
40
|
private static ensureMessageListener;
|
|
32
41
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Maybe, Nullable } from '../../../core/src/index.ts';
|
|
2
|
+
export interface OidcRedirectFrame {
|
|
3
|
+
contentWindow: Nullable<Window>;
|
|
4
|
+
origin: Nullable<string>;
|
|
5
|
+
spotId: string;
|
|
6
|
+
msCoreBaseUrl: string;
|
|
7
|
+
}
|
|
8
|
+
export interface OidcRedirectRequest {
|
|
9
|
+
source: Window;
|
|
10
|
+
origin: string;
|
|
11
|
+
url: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Whether a `ms:sso:oidc:redirect` message is a request the SDK serves
|
|
15
|
+
* (AD-29), and the navigation it asks for: it comes from an iframe the SDK
|
|
16
|
+
* created, at the community origin of that iframe, and its `url` is an
|
|
17
|
+
* `embed/authorize` of the fallback journey, for the Spot of that iframe, on
|
|
18
|
+
* the origin of the core API.
|
|
19
|
+
* Anything else is ignored: the SDK never becomes an open redirector.
|
|
20
|
+
*/
|
|
21
|
+
export declare const readOidcRedirectRequest: (event: Pick<MessageEvent, "source" | "origin" | "data">, frames: OidcRedirectFrame[]) => Maybe<OidcRedirectRequest>;
|
|
22
|
+
export declare const navigatePage: (url: string) => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Maybe } from '../../../core/src/index.ts';
|
|
2
|
+
export declare const OIDC_RETURN_FRAGMENT_KEY: {
|
|
3
|
+
readonly ATTEMPT: "ms_oidc_attempt";
|
|
4
|
+
readonly CODE: "ms_oidc_code";
|
|
5
|
+
readonly ERROR: "ms_oidc_error";
|
|
6
|
+
};
|
|
7
|
+
export interface OidcReturnFragment {
|
|
8
|
+
attemptId: string;
|
|
9
|
+
code?: string;
|
|
10
|
+
error?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reads the keys of the OpenID Connect return in the fragment of the page and
|
|
14
|
+
* removes them from the address at once (`history.replaceState`), before any
|
|
15
|
+
* log or error capture: the passage code never stays in the address of the
|
|
16
|
+
* site. An incomplete fragment (no attempt, or no code nor error) is removed
|
|
17
|
+
* and ignored. Any other key of the fragment is kept.
|
|
18
|
+
*
|
|
19
|
+
* Called by `injectSpotInto`, never at the import of the SDK: the coach and
|
|
20
|
+
* widget bundles import it on any page, the content scripts of the browser
|
|
21
|
+
* extensions too, and they must not take the return from the embed SDK of the
|
|
22
|
+
* page. Once removed from the address, the return is given to the first Spot
|
|
23
|
+
* only: the next Spots open as usual.
|
|
24
|
+
*/
|
|
25
|
+
export declare const consumeOidcReturnFragment: (location?: Pick<Location, "pathname" | "search" | "hash">, history?: Pick<History, "replaceState" | "state">) => Maybe<OidcReturnFragment>;
|
|
26
|
+
export declare const toOidcReturnHash: (fragment: OidcReturnFragment) => string;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "MeltingSpot Embed SDK",
|
|
4
4
|
"homepage": "https://meltingspot.io",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.18.0",
|
|
7
7
|
"main": "./index.cjs",
|
|
8
8
|
"module": "./index.mjs",
|
|
9
9
|
"typings": "./index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@meltingspot/core": "1.
|
|
20
|
+
"@meltingspot/core": "1.18.0"
|
|
21
21
|
},
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"provenance": false
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable } from '../../../core/src/index.ts';
|
|
1
|
+
import { Injectable, Nullable } from '../../../core/src/index.ts';
|
|
2
2
|
export interface EmbedContent {
|
|
3
3
|
iframe: HTMLIFrameElement;
|
|
4
4
|
rootDocument?: Document;
|
|
@@ -8,6 +8,8 @@ export declare class EmbedFrame implements Injectable {
|
|
|
8
8
|
readonly content: EmbedContent;
|
|
9
9
|
constructor(content: EmbedContent);
|
|
10
10
|
set onRemove(callback: (contentWindow: Window) => void);
|
|
11
|
+
get contentWindow(): Nullable<Window>;
|
|
12
|
+
get origin(): Nullable<string>;
|
|
11
13
|
inject(into: string | HTMLElement): void;
|
|
12
14
|
remove(): void;
|
|
13
15
|
}
|
package/spot.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Nullable, ThemeMode, UtmParameters } from '../../core/src/index.ts';
|
|
2
|
+
import { OidcReturnFragment } from './oidc/oidcReturnFragment';
|
|
2
3
|
import { EmbedContent } from './rendering/embedFrame';
|
|
3
4
|
export interface SpotArgs {
|
|
4
5
|
/**
|
|
@@ -33,8 +34,14 @@ export interface SpotArgs {
|
|
|
33
34
|
* The root document to use for the embed injection.
|
|
34
35
|
*/
|
|
35
36
|
rootDocument?: Document;
|
|
37
|
+
/**
|
|
38
|
+
* The return of the fallback journey of an OpenID Connect login, read in
|
|
39
|
+
* the address of the page: the Spot opens on its embed return page (AD-29).
|
|
40
|
+
*/
|
|
41
|
+
oidcReturn?: Nullable<OidcReturnFragment>;
|
|
36
42
|
}
|
|
37
43
|
export declare class Spot implements EmbedContent {
|
|
44
|
+
#private;
|
|
38
45
|
readonly baseURL: string;
|
|
39
46
|
readonly spotId: string;
|
|
40
47
|
readonly authToken: Nullable<string>;
|
|
@@ -45,4 +52,5 @@ export declare class Spot implements EmbedContent {
|
|
|
45
52
|
readonly rootDocument?: Document;
|
|
46
53
|
constructor(args: SpotArgs);
|
|
47
54
|
get iframe(): HTMLIFrameElement;
|
|
55
|
+
private getPath;
|
|
48
56
|
}
|