@meltingspot/widget 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/index.cjs +1 -1
- package/index.mjs +1 -1
- package/index.standalone.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,22 @@ Date: YYYY-MM-DD
|
|
|
15
15
|
|
|
16
16
|
-->
|
|
17
17
|
|
|
18
|
+
## v1.5.1
|
|
19
|
+
|
|
20
|
+
Date: 2026-07-23
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Bump `@meltingspot/core` and `@meltingspot/embed` to `1.5.1`.
|
|
25
|
+
|
|
26
|
+
## v1.5.0
|
|
27
|
+
|
|
28
|
+
Date: 2026-07-20
|
|
29
|
+
|
|
30
|
+
### Minor Changes
|
|
31
|
+
|
|
32
|
+
- Bump `@meltingspot/core` and `@meltingspot/embed` to `1.5.0`.
|
|
33
|
+
|
|
18
34
|
## v1.4.0
|
|
19
35
|
|
|
20
36
|
Date: 2026-07-17
|
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@meltingspot/core"),p=require("@meltingspot/embed"),C="1.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@meltingspot/core"),p=require("@meltingspot/embed"),C="1.5.1",d=new i.Logger({appName:"Widget SDK",appVersion:C});class b{constructor(t,e,o){this.content=t,this.rootDocument=e,this.dialogClassname=o,this.dialogElement=null,this.triggerElement=null,this.iframeElement=null,this.currentListener=null}inject({into:t,bind:e,options:o}){this.remove();const r=i.getHTMLElement({input:t,rootDocument:this.rootDocument});if(this.dialogElement=i.createDialog(this.rootDocument),this.dialogElement.classList.add(this.dialogClassname),this.dialogElement.onclose=()=>this.#e(),r.appendChild(this.dialogElement),e){this.triggerElement=i.getHTMLElement({input:e,rootDocument:this.rootDocument});const c=this.open.bind(this,o);this.currentListener=a=>{a.stopPropagation(),a.preventDefault(),c()},this.triggerElement.addEventListener("click",this.currentListener)}}remove(){this.dialogElement&&(this.dialogElement.remove(),this.dialogElement.onclose=null,this.dialogElement=null),this.triggerElement&&(this.currentListener&&this.triggerElement.removeEventListener("click",this.currentListener),this.triggerElement=null,this.currentListener=null)}open(t){this.dialogElement||this.inject({into:this.rootDocument.body}),this.dialogElement&&(this.#t(),this.dialogElement.showModal())}close(){this.dialogElement&&this.dialogElement.close()}#t(){this.dialogElement&&(this.iframeElement=this.dialogElement.appendChild(this.content.iframe))}#e(){this.iframeElement&&(this.iframeElement.remove(),this.iframeElement=null)}}class w extends b{constructor(t,e){super(t,e,"ms-drawer")}open(t){const{position:e="right"}=t??{};super.open(t),this.dialogElement&&(this.dialogElement.dataset.position=e)}}class I extends b{constructor(t,e){super(t,e,"ms-modal")}}class U{constructor(t){this.baseURL=i.formatBaseUrl(t.baseURL),this.spotId=i.formatUUID(t.spotId),this.widgetId=i.formatUUID(t.widgetId),this.authToken=t.authToken??null,this.themeMode=t.themeMode??"auto",this.domain=t.domain??null,this.utmParameters=t.utmParameters??null,this.rootDocument=t.rootDocument}get iframe(){const t=new URL(`/widgets/spot/${this.spotId}/widget/${this.widgetId}`,i.trimSlashRight(this.baseURL)),e=i.createIframe({url:t,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,...i.flattenUtmParameters(this.utmParameters)},rootDocument:this.rootDocument});return e.classList.add("ms-widget"),e}}class L{constructor(t){this.baseURL=i.formatBaseUrl(t.baseURL),this.spotId=i.formatUUID(t.spotId),this.widgetContentId=i.formatUUID(t.widgetContentId),this.contentId=i.formatUUID(t.contentId),this.widgetId=i.formatUUID(t.widgetId),this.contentType=t.contentType,this.authToken=t.authToken??null,this.themeMode=t.themeMode??"auto",this.domain=t.domain??null,this.utmParameters=t.utmParameters??null,this.rootDocument=t.rootDocument}get iframe(){const t=new URL(`/widgets/spot/${this.spotId}/widgetContent/${this.widgetContentId}`,i.trimSlashRight(this.baseURL));t.searchParams.set("widgetId",this.widgetId);const e=i.createIframe({url:t,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,contentId:this.contentId,contentType:this.contentType,...i.flattenUtmParameters(this.utmParameters)},rootDocument:this.rootDocument});return e.classList.add("ms-widget-content"),e}}const n=class n{static injectWidgetInto(t,e){const{spotId:o,rootDocument:r,msCommunityWebBaseUrl:c}=i.ConfigurationService.getConfiguration({spotId:e.spotId,rootDocument:e.rootDocument,msCommunityWebBaseUrl:e.baseURL});if(!o)throw d.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widget:a,args:m}=n.createWidget({...e,spotId:o,rootDocument:r,baseURL:c}),s=new p.EmbedFrame(a);return s.inject(t),n.widgets.push(s),d.log("Widget injected",n.cleanupLoggedArgs(m),t),s}static injectWidgetContentInto(t,e){const{spotId:o,rootDocument:r,msCommunityWebBaseUrl:c}=i.ConfigurationService.getConfiguration({spotId:e.spotId,rootDocument:e.rootDocument,msCommunityWebBaseUrl:e.baseURL});if(!o)throw d.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widgetContent:a,args:m}=n.createWidgetContent({...e,spotId:o,rootDocument:r,baseURL:c}),s=new p.EmbedFrame(a);return s.inject(t),n.widgets.push(s),d.log("WidgetContent injected",n.cleanupLoggedArgs(m),t),s}static bindWidgetModalTo(t,e){return n.bindEntityModalTo(t,{type:"Widget",data:e})}static bindWidgetDrawerTo(t,e){return n.bindEntityDrawerTo(t,{type:"Widget",data:e})}static createWidgetDrawer(t){const{widget:e}=n.createWidget(t);return d.log("Create Widget drawer",{data:n.cleanupLoggedArgs(t)}),new w(e,t.rootDocument??document)}static createWidgetModal(t){const{widget:e}=n.createWidget(t);return d.log("Create Widget modal",{data:n.cleanupLoggedArgs(t)}),new I(e,t.rootDocument??document)}static createWidgetEmbed(t){const{widget:e}=n.createWidget(t),o=new p.EmbedFrame(e);return d.log("Create Widget embed",{data:n.cleanupLoggedArgs(t)}),o}static clear(){n.widgets.forEach(t=>{t.remove()}),n.widgets=[],n.widgetOptions={},d.log("All Widget SDK MeltingSpot elements were cleared")}static bindEntityDrawerTo(t,e){const{spotId:o,rootDocument:r,msCommunityWebBaseUrl:c}=i.ConfigurationService.getConfiguration({spotId:e.data.spotId,rootDocument:e.data.rootDocument??document,msCommunityWebBaseUrl:e.data.baseURL});if(!o)throw d.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let a,m;switch(e.type){case"Widget":{const u=n.createWidget({...e.data,spotId:o,rootDocument:r,baseURL:c});a=u.widget,m=u.args}break;case"WidgetContent":{const u=n.createWidgetContent({...e.data,spotId:o,rootDocument:r,baseURL:c});a=u.widgetContent,m=u.args}}const s=new w(a,r),l={position:e.data.position},g=e.data.into??r.body;return s.inject({into:g,bind:t,options:l}),n.widgets.push(s),d.log("Widget bound to drawer",n.cleanupLoggedArgs(m),l,g,t),s}static bindEntityModalTo(t,e){const{spotId:o,rootDocument:r,msCommunityWebBaseUrl:c}=i.ConfigurationService.getConfiguration({spotId:e.data.spotId,rootDocument:e.data.rootDocument??document,msCommunityWebBaseUrl:e.data.baseURL});if(!o)throw d.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let a,m;switch(e.type){case"Widget":{const g=n.createWidget({...e.data,spotId:o,rootDocument:r,baseURL:c});a=g.widget,m=g.args}break;case"WidgetContent":{const g=n.createWidgetContent({...e.data,spotId:o,rootDocument:r,baseURL:c});a=g.widgetContent,m=g.args}}const s=new I(a,r),l=e.data.into??r.body;return s.inject({into:l,bind:t}),n.widgets.push(s),d.log("Widget bound to modal",n.cleanupLoggedArgs(m),l,t),s}static handleMessageEvent(t){if(!t.data||typeof t.data!="object"||t.data.type!=="OpenWidgetContent")return;const e=t.data?.widgetId;if(!e||typeof e!="string"){d.error("widgetId is required in the message event data");return}const o=n.widgetOptions[e];if(!o){d.error("No widget options found for widgetId",{widgetId:e});return}let r=null;try{r=new URL(o.baseURL).origin}catch{r=null}if(!r||t.origin!==r){d.warn("Ignoring OpenWidgetContent from unexpected origin",{origin:t.origin,expectedOrigin:r});return}const{spotId:c,rootDocument:a,msCommunityWebBaseUrl:m}=i.ConfigurationService.getConfiguration({spotId:o.spotId,rootDocument:o.rootDocument??document,msCommunityWebBaseUrl:o.baseURL}),{widgetContent:s}=n.createWidgetContent({...o,widgetContentId:t.data.widgetContentId,contentType:t.data.contentType,contentId:t.data.contentId,widgetId:e,spotId:c,rootDocument:a,baseURL:m});t.data.openingIn==="Drawer"?new w(s,a).open():t.data.openingIn==="Modal"&&new I(s,a).open()}static createWidget(t){const e=new URLSearchParams(window.location.search),o={spotId:t.spotId,widgetId:t.widgetId,authToken:t.authToken,themeMode:t.themeMode,domain:t.domain,rootDocument:t.rootDocument,baseURL:t.baseURL,utmParameters:t.utmParameters??i.parseUtmParameters(e)};return n.widgetOptions[o.widgetId]=o,n.messageListened||(window.addEventListener("message",n.handleMessageEvent),n.messageListened=!0),{widget:new U(o),args:o}}static createWidgetContent(t){const e=new URLSearchParams(window.location.search),o={spotId:t.spotId,contentId:t.contentId,contentType:t.contentType,widgetContentId:t.widgetContentId,widgetId:t.widgetId,authToken:t.authToken,themeMode:t.themeMode,domain:t.domain,rootDocument:t.rootDocument,baseURL:t.baseURL,utmParameters:t.utmParameters??i.parseUtmParameters(e)};return{widgetContent:new L(o),args:o}}static cleanupLoggedArgs(t){const{authToken:e,...o}=t;return{...o,authToken:e?"***":void 0}}};n.widgets=[],n.messageListened=!1,n.widgetOptions={};let f=n;const D=globalThis;D.MeltingSpot||(D.MeltingSpot={});D.MeltingSpot.Widget=f;exports.Drawer=w;exports.Modal=I;exports.Widget=f;
|
package/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Logger as T, getHTMLElement as L, createDialog as P, formatBaseUrl as W, formatUUID as l, trimSlashRight as E, createIframe as U, flattenUtmParameters as y, ConfigurationService as h, parseUtmParameters as C } from "@meltingspot/core";
|
|
2
2
|
import { EmbedFrame as I } from "@meltingspot/embed";
|
|
3
|
-
const M = "1.
|
|
3
|
+
const M = "1.5.1", r = new T({
|
|
4
4
|
appName: "Widget SDK",
|
|
5
5
|
appVersion: M
|
|
6
6
|
});
|
package/index.standalone.js
CHANGED
|
@@ -30,4 +30,4 @@ __p += '`),re&&(I+=`' +
|
|
|
30
30
|
function print() { __p += __j.call(arguments, '') }
|
|
31
31
|
`:`;
|
|
32
32
|
`)+I+`return __p
|
|
33
|
-
}`;var J=ff(function(){return oe(c,S+"return "+I).apply(r,l)});if(J.source=I,zo(J))throw J;return J}function y_(e){return ae(e).toLowerCase()}function I_(e){return ae(e).toUpperCase()}function A_(e,t,n){if(e=ae(e),e&&(n||t===r))return _u(e);if(!e||!(t=nt(t)))return e;var i=wt(e),u=wt(t),c=vu(i,u),l=wu(i,u)+1;return Jt(i,c,l).join("")}function R_(e,t,n){if(e=ae(e),e&&(n||t===r))return e.slice(0,Tu(e)+1);if(!e||!(t=nt(t)))return e;var i=wt(e),u=wu(i,wt(t))+1;return Jt(i,0,u).join("")}function L_(e,t,n){if(e=ae(e),e&&(n||t===r))return e.replace(Gi,"");if(!e||!(t=nt(t)))return e;var i=wt(e),u=vu(i,wt(t));return Jt(i,u).join("")}function O_(e,t){var n=ce,i=ie;if(we(t)){var u="separator"in t?t.separator:u;n="length"in t?Z(t.length):n,i="omission"in t?nt(t.omission):i}e=ae(e);var c=e.length;if(An(e)){var l=wt(e);c=l.length}if(n>=c)return e;var h=n-Rn(i);if(h<1)return i;var m=l?Jt(l,0,h).join(""):e.slice(0,h);if(u===r)return m+i;if(l&&(h+=m.length-h),qo(u)){if(e.slice(h).search(u)){var E,T=m;for(u.global||(u=uo(u.source,ae(Ws.exec(u))+"g")),u.lastIndex=0;E=u.exec(T);)var I=E.index;m=m.slice(0,I===r?h:I)}}else if(e.indexOf(nt(u),h)!=h){var L=m.lastIndexOf(u);L>-1&&(m=m.slice(0,L))}return m+i}function M_(e){return e=ae(e),e&&Wc.test(e)?e.replace(Ps,rh):e}var b_=Sn(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Zo=fa("toUpperCase");function af(e,t,n){return e=ae(e),t=n?r:t,t===r?Vl(e)?sh(e):Bl(e):e.match(t)||[]}var ff=X(function(e,t){try{return et(e,r,t)}catch(n){return zo(n)?n:new B(n)}}),x_=Pt(function(e,t){return at(t,function(n){n=Mt(n),$t(e,n,Bo(e[n],e))}),e});function D_(e){var t=e==null?0:e.length,n=P();return e=t?pe(e,function(i){if(typeof i[1]!="function")throw new ft(g);return[n(i[0]),i[1]]}):[],X(function(i){for(var u=-1;++u<t;){var c=e[u];if(et(c[0],this,i))return et(c[1],this,i)}})}function S_(e){return rd(lt(e,U))}function Jo(e){return function(){return e}}function U_(e,t){return e==null||e!==e?t:e}var $_=la(),N_=la(!0);function Je(e){return e}function Xo(e){return ku(typeof e=="function"?e:lt(e,U))}function P_(e){return Bu(lt(e,U))}function C_(e,t){return Gu(e,lt(t,U))}var F_=X(function(e,t){return function(n){return Vn(n,e,t)}}),W_=X(function(e,t){return function(n){return Vn(e,n,t)}});function Vo(e,t,n){var i=$e(t),u=Xr(t,i);n==null&&!(we(t)&&(u.length||!i.length))&&(n=t,t=e,e=this,u=Xr(t,$e(t)));var c=!(we(n)&&"chain"in n)||!!n.chain,l=Ft(e);return at(u,function(h){var m=t[h];e[h]=m,l&&(e.prototype[h]=function(){var E=this.__chain__;if(c||E){var T=e(this.__wrapped__),I=T.__actions__=Ke(this.__actions__);return I.push({func:m,args:arguments,thisArg:e}),T.__chain__=E,T}return m.apply(e,Gt([this.value()],arguments))})}),e}function Y_(){return Ce._===this&&(Ce._=hh),this}function jo(){}function k_(e){return e=Z(e),X(function(t){return zu(t,e)})}var H_=xo(pe),B_=xo(hu),G_=xo(eo);function cf(e){return Co(e)?to(Mt(e)):Ed(e)}function z_(e){return function(t){return e==null?r:cn(e,t)}}var q_=da(),K_=da(!0);function es(){return[]}function ts(){return!1}function Q_(){return{}}function Z_(){return""}function J_(){return!0}function X_(e,t){if(e=Z(e),e<1||e>R)return[];var n=V,i=Ye(e,V);t=P(t),e-=V;for(var u=io(i,t);++n<e;)t(n);return u}function V_(e){return z(e)?pe(e,Mt):rt(e)?[e]:Ke(ba(ae(e)))}function j_(e){var t=++ch;return ae(e)+t}var e0=ri(function(e,t){return e+t},0),t0=Do("ceil"),n0=ri(function(e,t){return e/t},1),r0=Do("floor");function i0(e){return e&&e.length?Jr(e,Je,mo):r}function o0(e,t){return e&&e.length?Jr(e,P(t,2),mo):r}function s0(e){return pu(e,Je)}function u0(e,t){return pu(e,P(t,2))}function a0(e){return e&&e.length?Jr(e,Je,Eo):r}function f0(e,t){return e&&e.length?Jr(e,P(t,2),Eo):r}var c0=ri(function(e,t){return e*t},1),l0=Do("round"),h0=ri(function(e,t){return e-t},0);function d0(e){return e&&e.length?ro(e,Je):0}function g0(e,t){return e&&e.length?ro(e,P(t,2)):0}return a.after=Pp,a.ary=Ya,a.assign=Im,a.assignIn=ef,a.assignInWith=mi,a.assignWith=Am,a.at=Rm,a.before=ka,a.bind=Bo,a.bindAll=x_,a.bindKey=Ha,a.castArray=Qp,a.chain=Ca,a.chunk=rg,a.compact=ig,a.concat=og,a.cond=D_,a.conforms=S_,a.constant=Jo,a.countBy=dp,a.create=Lm,a.curry=Ba,a.curryRight=Ga,a.debounce=za,a.defaults=Om,a.defaultsDeep=Mm,a.defer=Cp,a.delay=Fp,a.difference=sg,a.differenceBy=ug,a.differenceWith=ag,a.drop=fg,a.dropRight=cg,a.dropRightWhile=lg,a.dropWhile=hg,a.fill=dg,a.filter=pp,a.flatMap=vp,a.flatMapDeep=wp,a.flatMapDepth=Ep,a.flatten=Ua,a.flattenDeep=gg,a.flattenDepth=pg,a.flip=Wp,a.flow=$_,a.flowRight=N_,a.fromPairs=mg,a.functions=Nm,a.functionsIn=Pm,a.groupBy=Tp,a.initial=vg,a.intersection=wg,a.intersectionBy=Eg,a.intersectionWith=Tg,a.invert=Fm,a.invertBy=Wm,a.invokeMap=Ip,a.iteratee=Xo,a.keyBy=Ap,a.keys=$e,a.keysIn=Ze,a.map=ci,a.mapKeys=km,a.mapValues=Hm,a.matches=P_,a.matchesProperty=C_,a.memoize=hi,a.merge=Bm,a.mergeWith=tf,a.method=F_,a.methodOf=W_,a.mixin=Vo,a.negate=di,a.nthArg=k_,a.omit=Gm,a.omitBy=zm,a.once=Yp,a.orderBy=Rp,a.over=H_,a.overArgs=kp,a.overEvery=B_,a.overSome=G_,a.partial=Go,a.partialRight=qa,a.partition=Lp,a.pick=qm,a.pickBy=nf,a.property=cf,a.propertyOf=z_,a.pull=Rg,a.pullAll=Na,a.pullAllBy=Lg,a.pullAllWith=Og,a.pullAt=Mg,a.range=q_,a.rangeRight=K_,a.rearg=Hp,a.reject=bp,a.remove=bg,a.rest=Bp,a.reverse=ko,a.sampleSize=Dp,a.set=Qm,a.setWith=Zm,a.shuffle=Sp,a.slice=xg,a.sortBy=Np,a.sortedUniq=Cg,a.sortedUniqBy=Fg,a.split=v_,a.spread=Gp,a.tail=Wg,a.take=Yg,a.takeRight=kg,a.takeRightWhile=Hg,a.takeWhile=Bg,a.tap=ip,a.throttle=zp,a.thru=fi,a.toArray=Xa,a.toPairs=rf,a.toPairsIn=of,a.toPath=V_,a.toPlainObject=ja,a.transform=Jm,a.unary=qp,a.union=Gg,a.unionBy=zg,a.unionWith=qg,a.uniq=Kg,a.uniqBy=Qg,a.uniqWith=Zg,a.unset=Xm,a.unzip=Ho,a.unzipWith=Pa,a.update=Vm,a.updateWith=jm,a.values=Nn,a.valuesIn=e_,a.without=Jg,a.words=af,a.wrap=Kp,a.xor=Xg,a.xorBy=Vg,a.xorWith=jg,a.zip=ep,a.zipObject=tp,a.zipObjectDeep=np,a.zipWith=rp,a.entries=rf,a.entriesIn=of,a.extend=ef,a.extendWith=mi,Vo(a,a),a.add=e0,a.attempt=ff,a.camelCase=i_,a.capitalize=sf,a.ceil=t0,a.clamp=t_,a.clone=Zp,a.cloneDeep=Xp,a.cloneDeepWith=Vp,a.cloneWith=Jp,a.conformsTo=jp,a.deburr=uf,a.defaultTo=U_,a.divide=n0,a.endsWith=o_,a.eq=Tt,a.escape=s_,a.escapeRegExp=u_,a.every=gp,a.find=mp,a.findIndex=Da,a.findKey=bm,a.findLast=_p,a.findLastIndex=Sa,a.findLastKey=xm,a.floor=r0,a.forEach=Fa,a.forEachRight=Wa,a.forIn=Dm,a.forInRight=Sm,a.forOwn=Um,a.forOwnRight=$m,a.get=Ko,a.gt=em,a.gte=tm,a.has=Cm,a.hasIn=Qo,a.head=$a,a.identity=Je,a.includes=yp,a.indexOf=_g,a.inRange=n_,a.invoke=Ym,a.isArguments=dn,a.isArray=z,a.isArrayBuffer=nm,a.isArrayLike=Qe,a.isArrayLikeObject=ye,a.isBoolean=rm,a.isBuffer=Xt,a.isDate=im,a.isElement=om,a.isEmpty=sm,a.isEqual=um,a.isEqualWith=am,a.isError=zo,a.isFinite=fm,a.isFunction=Ft,a.isInteger=Ka,a.isLength=gi,a.isMap=Qa,a.isMatch=cm,a.isMatchWith=lm,a.isNaN=hm,a.isNative=dm,a.isNil=pm,a.isNull=gm,a.isNumber=Za,a.isObject=we,a.isObjectLike=Ee,a.isPlainObject=ir,a.isRegExp=qo,a.isSafeInteger=mm,a.isSet=Ja,a.isString=pi,a.isSymbol=rt,a.isTypedArray=$n,a.isUndefined=_m,a.isWeakMap=vm,a.isWeakSet=wm,a.join=yg,a.kebabCase=a_,a.last=dt,a.lastIndexOf=Ig,a.lowerCase=f_,a.lowerFirst=c_,a.lt=Em,a.lte=Tm,a.max=i0,a.maxBy=o0,a.mean=s0,a.meanBy=u0,a.min=a0,a.minBy=f0,a.stubArray=es,a.stubFalse=ts,a.stubObject=Q_,a.stubString=Z_,a.stubTrue=J_,a.multiply=c0,a.nth=Ag,a.noConflict=Y_,a.noop=jo,a.now=li,a.pad=l_,a.padEnd=h_,a.padStart=d_,a.parseInt=g_,a.random=r_,a.reduce=Op,a.reduceRight=Mp,a.repeat=p_,a.replace=m_,a.result=Km,a.round=l0,a.runInContext=p,a.sample=xp,a.size=Up,a.snakeCase=__,a.some=$p,a.sortedIndex=Dg,a.sortedIndexBy=Sg,a.sortedIndexOf=Ug,a.sortedLastIndex=$g,a.sortedLastIndexBy=Ng,a.sortedLastIndexOf=Pg,a.startCase=w_,a.startsWith=E_,a.subtract=h0,a.sum=d0,a.sumBy=g0,a.template=T_,a.times=X_,a.toFinite=Wt,a.toInteger=Z,a.toLength=Va,a.toLower=y_,a.toNumber=gt,a.toSafeInteger=ym,a.toString=ae,a.toUpper=I_,a.trim=A_,a.trimEnd=R_,a.trimStart=L_,a.truncate=O_,a.unescape=M_,a.uniqueId=j_,a.upperCase=b_,a.upperFirst=Zo,a.each=Fa,a.eachRight=Wa,a.first=$a,Vo(a,(function(){var e={};return Lt(a,function(t,n){fe.call(a.prototype,n)||(e[n]=t)}),e})(),{chain:!1}),a.VERSION=f,at(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){a[e].placeholder=a}),at(["drop","take"],function(e,t){te.prototype[e]=function(n){n=n===r?1:xe(Z(n),0);var i=this.__filtered__&&!t?new te(this):this.clone();return i.__filtered__?i.__takeCount__=Ye(n,i.__takeCount__):i.__views__.push({size:Ye(n,V),type:e+(i.__dir__<0?"Right":"")}),i},te.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),at(["filter","map","takeWhile"],function(e,t){var n=t+1,i=n==W||n==O;te.prototype[e]=function(u){var c=this.clone();return c.__iteratees__.push({iteratee:P(u,3),type:n}),c.__filtered__=c.__filtered__||i,c}}),at(["head","last"],function(e,t){var n="take"+(t?"Right":"");te.prototype[e]=function(){return this[n](1).value()[0]}}),at(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");te.prototype[e]=function(){return this.__filtered__?new te(this):this[n](1)}}),te.prototype.compact=function(){return this.filter(Je)},te.prototype.find=function(e){return this.filter(e).head()},te.prototype.findLast=function(e){return this.reverse().find(e)},te.prototype.invokeMap=X(function(e,t){return typeof e=="function"?new te(this):this.map(function(n){return Vn(n,e,t)})}),te.prototype.reject=function(e){return this.filter(di(P(e)))},te.prototype.slice=function(e,t){e=Z(e);var n=this;return n.__filtered__&&(e>0||t<0)?new te(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=Z(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},te.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},te.prototype.toArray=function(){return this.take(V)},Lt(te.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),u=a[i?"take"+(t=="last"?"Right":""):t],c=i||/^find/.test(t);u&&(a.prototype[t]=function(){var l=this.__wrapped__,h=i?[1]:arguments,m=l instanceof te,E=h[0],T=m||z(l),I=function(j){var re=u.apply(a,Gt([j],h));return i&&L?re[0]:re};T&&n&&typeof E=="function"&&E.length!=1&&(m=T=!1);var L=this.__chain__,S=!!this.__actions__.length,C=c&&!L,J=m&&!S;if(!c&&T){l=J?l:new te(this);var F=e.apply(l,h);return F.__actions__.push({func:fi,args:[I],thisArg:r}),new ct(F,L)}return C&&J?e.apply(this,h):(F=this.thru(I),C?i?F.value()[0]:F.value():F)})}),at(["pop","push","shift","sort","splice","unshift"],function(e){var t=Nr[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);a.prototype[e]=function(){var u=arguments;if(i&&!this.__chain__){var c=this.value();return t.apply(z(c)?c:[],u)}return this[n](function(l){return t.apply(z(l)?l:[],u)})}}),Lt(te.prototype,function(e,t){var n=a[t];if(n){var i=n.name+"";fe.call(bn,i)||(bn[i]=[]),bn[i].push({name:t,func:n})}}),bn[ni(r,he).name]=[{name:"wrapper",func:r}],te.prototype.clone=Mh,te.prototype.reverse=bh,te.prototype.value=xh,a.prototype.at=op,a.prototype.chain=sp,a.prototype.commit=up,a.prototype.next=ap,a.prototype.plant=cp,a.prototype.reverse=lp,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=hp,a.prototype.first=a.prototype.head,zn&&(a.prototype[zn]=fp),a}),Ln=uh();on?((on.exports=Ln)._=Ln,Ji._=Ln):Ce._=Ln}).call(ec)})(Fn,Fn.exports)),Fn.exports}tc();const nc="1.4.0";class Ti{constructor(o){this.debug=!1,this.debug=o?.debug??!1,this.appName=o?.appName,this.appVersion=o?.appVersion}log(o,...r){this.debug&&this.print(o,"info",r)}warn(o,...r){this.print(o,"warn",r)}error(o,...r){this.print(o,"error",r)}print(o,r,f){const g=[`[${["MeltingSpot",this.appName,this.appVersion].filter(Boolean).join(" - ")}] ${o}`];f.length&&g.push(...f),console[r](...g)}}const rc=new Ti({appName:"Core SDK",appVersion:nc}),nn=s=>s.toLowerCase().replace(/[^a-z0-9-]/g,""),ic=["/user"],oc=({deeplink:s,spotId:o})=>{try{const r=new URL(s,"https://unused.com");let f=r.pathname;return r.search&&(f+=r.search),r.hash&&(f+=r.hash),ic.some(d=>f.startsWith(d))||(f=`/spot/${o}/${vf(f)}`),f}catch(r){return rc.warn("Failed to parse deeplink URL",r),null}},sc=[/(^|\.)meltingspot\.io$/i],yi=s=>{let o;try{const _=sr(s);o=new URL(_)}catch{throw new Error(`Invalid baseURL: ${s}`)}const r=o.hostname==="localhost"||o.hostname==="127.0.0.1",f=o.protocol==="https:",d=sc.some(_=>_.test(o.hostname));if(!r&&(!f||!d))throw new Error(`Untrusted baseURL origin: ${o.origin}`);return o.origin},uc={msApiBaseUrl:"https://openapi.meltingspot.io/",msCommunityWebBaseUrl:"https://go.meltingspot.io/",ssoToken:void 0,spotId:"",autoJoin:!1,rootDocument:globalThis.document};class De{constructor(){this.configuration=uc}static getInstance(){return De.instance||(De.instance=new De),De.instance}setConfiguration(o){this.configuration={...this.configuration,...o}}static getConfiguration(o={}){return{...De.getInstance().configuration,...o}}}const Es="%[a-f0-9]{2}",Ts=new RegExp("("+Es+")|([^%]+?)","gi"),ys=new RegExp("("+Es+")+","gi");function Ii(s,o){try{return[decodeURIComponent(s.join(""))]}catch{}if(s.length===1)return s;o=o||1;const r=s.slice(0,o),f=s.slice(o);return Array.prototype.concat.call([],Ii(r),Ii(f))}function ac(s){try{return decodeURIComponent(s)}catch{let o=s.match(Ts)||[];for(let r=1;r<o.length;r++)s=Ii(o,r).join(""),o=s.match(Ts)||[];return s}}function fc(s){const o={"%FE%FF":"��","%FF%FE":"��"};let r=ys.exec(s);for(;r;){try{o[r[0]]=decodeURIComponent(r[0])}catch{const d=ac(r[0]);d!==r[0]&&(o[r[0]]=d)}r=ys.exec(s)}o["%C2"]="�";const f=Object.keys(o);for(const d of f)s=s.replace(new RegExp(d,"g"),o[d]);return s}function cc(s){if(typeof s!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof s+"`");try{return decodeURIComponent(s)}catch{return fc(s)}}function lc(s,o){const r={};if(Array.isArray(o))for(const f of o){const d=Object.getOwnPropertyDescriptor(s,f);d?.enumerable&&Object.defineProperty(r,f,d)}else for(const f of Reflect.ownKeys(s)){const d=Object.getOwnPropertyDescriptor(s,f);if(d.enumerable){const _=s[f];o(f,_,s)&&Object.defineProperty(r,f,d)}}return r}function Is(s,o){if(!(typeof s=="string"&&typeof o=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(s===""||o==="")return[];const r=s.indexOf(o);return r===-1?[]:[s.slice(0,r),s.slice(r+o.length)]}const hc=s=>s==null,dc=s=>encodeURIComponent(s).replaceAll(/[!'()*]/g,o=>`%${o.charCodeAt(0).toString(16).toUpperCase()}`),Ai=Symbol("encodeFragmentIdentifier");function gc(s){switch(s.arrayFormat){case"index":return o=>(r,f)=>{const d=r.length;return f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,[Ae(o,s),"[",d,"]"].join("")]:[...r,[Ae(o,s),"[",Ae(d,s),"]=",Ae(f,s)].join("")]};case"bracket":return o=>(r,f)=>f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,[Ae(o,s),"[]"].join("")]:[...r,[Ae(o,s),"[]=",Ae(f,s)].join("")];case"colon-list-separator":return o=>(r,f)=>f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,[Ae(o,s),":list="].join("")]:[...r,[Ae(o,s),":list=",Ae(f,s)].join("")];case"comma":case"separator":case"bracket-separator":{const o=s.arrayFormat==="bracket-separator"?"[]=":"=";return r=>(f,d)=>d===void 0||s.skipNull&&d===null||s.skipEmptyString&&d===""?f:(d=d===null?"":d,f.length===0?[[Ae(r,s),o,Ae(d,s)].join("")]:[[f,Ae(d,s)].join(s.arrayFormatSeparator)])}default:return o=>(r,f)=>f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,Ae(o,s)]:[...r,[Ae(o,s),"=",Ae(f,s)].join("")]}}function pc(s){let o;switch(s.arrayFormat){case"index":return(r,f,d)=>{if(o=/\[(\d*)]$/.exec(r),r=r.replace(/\[\d*]$/,""),!o){d[r]=f;return}d[r]===void 0&&(d[r]={}),d[r][o[1]]=f};case"bracket":return(r,f,d)=>{if(o=/(\[])$/.exec(r),r=r.replace(/\[]$/,""),!o){d[r]=f;return}if(d[r]===void 0){d[r]=[f];return}d[r]=[...d[r],f]};case"colon-list-separator":return(r,f,d)=>{if(o=/(:list)$/.exec(r),r=r.replace(/:list$/,""),!o){d[r]=f;return}if(d[r]===void 0){d[r]=[f];return}d[r]=[...d[r],f]};case"comma":case"separator":return(r,f,d)=>{const _=typeof f=="string"&&f.includes(s.arrayFormatSeparator),g=typeof f=="string"&&!_&&bt(f,s).includes(s.arrayFormatSeparator);f=g?bt(f,s):f;const y=_||g?f.split(s.arrayFormatSeparator).map(A=>bt(A,s)):f===null?f:bt(f,s);d[r]=y};case"bracket-separator":return(r,f,d)=>{const _=/(\[])$/.test(r);if(r=r.replace(/\[]$/,""),!_){d[r]=f&&bt(f,s);return}const g=f===null?[]:bt(f,s).split(s.arrayFormatSeparator);if(d[r]===void 0){d[r]=g;return}d[r]=[...d[r],...g]};default:return(r,f,d)=>{if(d[r]===void 0){d[r]=f;return}d[r]=[...[d[r]].flat(),f]}}}function As(s){if(typeof s!="string"||s.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function Ae(s,o){return o.encode?o.strict?dc(s):encodeURIComponent(s):s}function bt(s,o){return o.decode?cc(s):s}function Rs(s){return Array.isArray(s)?s.sort():typeof s=="object"?Rs(Object.keys(s)).sort((o,r)=>Number(o)-Number(r)).map(o=>s[o]):s}function Ls(s){const o=s.indexOf("#");return o!==-1&&(s=s.slice(0,o)),s}function mc(s){let o="";const r=s.indexOf("#");return r!==-1&&(o=s.slice(r)),o}function Os(s,o,r){return r==="string"&&typeof s=="string"?s:typeof r=="function"&&typeof s=="string"?r(s):r==="boolean"&&s===null?!0:r==="boolean"&&s!==null&&(s.toLowerCase()==="true"||s.toLowerCase()==="false")?s.toLowerCase()==="true":r==="boolean"&&s!==null&&(s.toLowerCase()==="1"||s.toLowerCase()==="0")?s.toLowerCase()==="1":r==="string[]"&&o.arrayFormat!=="none"&&typeof s=="string"?[s]:r==="number[]"&&o.arrayFormat!=="none"&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?[Number(s)]:r==="number"&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?Number(s):o.parseBooleans&&s!==null&&(s.toLowerCase()==="true"||s.toLowerCase()==="false")?s.toLowerCase()==="true":o.parseNumbers&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?Number(s):s}function Ri(s){s=Ls(s);const o=s.indexOf("?");return o===-1?"":s.slice(o+1)}function Li(s,o){o={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...o},As(o.arrayFormatSeparator);const r=pc(o),f=Object.create(null);if(typeof s!="string"||(s=s.trim().replace(/^[?#&]/,""),!s))return f;for(const d of s.split("&")){if(d==="")continue;const _=o.decode?d.replaceAll("+"," "):d;let[g,y]=Is(_,"=");g===void 0&&(g=_),y=y===void 0?null:["comma","separator","bracket-separator"].includes(o.arrayFormat)?y:bt(y,o),r(bt(g,o),y,f)}for(const[d,_]of Object.entries(f))if(typeof _=="object"&&_!==null&&o.types[d]!=="string")for(const[g,y]of Object.entries(_)){const A=o.types[d]?o.types[d].replace("[]",""):void 0;_[g]=Os(y,o,A)}else typeof _=="object"&&_!==null&&o.types[d]==="string"?f[d]=Object.values(_).join(o.arrayFormatSeparator):f[d]=Os(_,o,o.types[d]);return o.sort===!1?f:(o.sort===!0?Object.keys(f).sort():Object.keys(f).sort(o.sort)).reduce((d,_)=>{const g=f[_];return d[_]=g&&typeof g=="object"&&!Array.isArray(g)?Rs(g):g,d},Object.create(null))}function Ms(s,o){if(!s)return"";o={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...o},As(o.arrayFormatSeparator);const r=g=>o.skipNull&&hc(s[g])||o.skipEmptyString&&s[g]==="",f=gc(o),d={};for(const[g,y]of Object.entries(s))r(g)||(d[g]=y);const _=Object.keys(d);return o.sort!==!1&&_.sort(o.sort),_.map(g=>{const y=s[g];return y===void 0?"":y===null?Ae(g,o):Array.isArray(y)?y.length===0&&o.arrayFormat==="bracket-separator"?Ae(g,o)+"[]":y.reduce(f(g),[]).join("&"):Ae(g,o)+"="+Ae(y,o)}).filter(g=>g.length>0).join("&")}function bs(s,o){o={decode:!0,...o};let[r,f]=Is(s,"#");return r===void 0&&(r=s),{url:r?.split("?")?.[0]??"",query:Li(Ri(s),o),...o&&o.parseFragmentIdentifier&&f?{fragmentIdentifier:bt(f,o)}:{}}}function xs(s,o){o={encode:!0,strict:!0,[Ai]:!0,...o};const r=Ls(s.url).split("?")[0]||"",f=Ri(s.url),d={...Li(f,{sort:!1,...o}),...s.query};let _=Ms(d,o);_&&=`?${_}`;let g=mc(s.url);if(typeof s.fragmentIdentifier=="string"){const y=new URL(r);y.hash=s.fragmentIdentifier,g=o[Ai]?y.hash:`#${s.fragmentIdentifier}`}return`${r}${_}${g}`}function Ds(s,o,r){r={parseFragmentIdentifier:!0,[Ai]:!1,...r};const{url:f,query:d,fragmentIdentifier:_}=bs(s,r);return xs({url:f,query:lc(d,o),fragmentIdentifier:_},r)}function _c(s,o,r){const f=Array.isArray(o)?d=>!o.includes(d):(d,_)=>!o(d,_);return Ds(s,f,r)}const vc=Object.freeze(Object.defineProperty({__proto__:null,exclude:_c,extract:Ri,parse:Li,parseUrl:bs,pick:Ds,stringify:Ms,stringifyUrl:xs},Symbol.toStringTag,{value:"Module"}));class qe extends Error{constructor(o,r){super(`HTTP Error ${o}${r?`: ${r}`:""}`),this.code=o,this.name="HttpError",Object.setPrototypeOf(this,qe.prototype)}}var Se=(s=>(s.GET="GET",s.PATCH="PATCH",s.POST="POST",s))(Se||{});class wc{constructor(){this.headers={}}setHeaders(o){this.headers=o}async get(o){try{const r=o.query?`${o.url}?${this.serializeQuery(o.query)}`:o.url,f=await fetch(r,{headers:{...this.headers,...o.headers,"Content-Type":"application/json"},...o.signal?{signal:o.signal}:{}});return f.ok?se(await f.json()):Q(new qe(f.status,await f.text()))}catch(r){const f=r instanceof Error?r.message:"Unknown error";return Q(new qe(st.INTERNAL_SERVER_ERROR,f))}}async post(o){try{const r=await fetch(o.url,{method:"POST",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload),...o.signal?{signal:o.signal}:{}});return r.ok?se(await r.json()):Q(new qe(r.status,await r.text()))}catch(r){const f=r instanceof Error?r.message:"Unknown error";return Q(new qe(st.INTERNAL_SERVER_ERROR,f))}}async patch(o){try{const r=await fetch(o.url,{method:"PATCH",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload),...o.signal?{signal:o.signal}:{}});return r.ok?se(await r.json()):Q(new qe(r.status,await r.text()))}catch(r){const f=r instanceof Error?r.message:"Unknown error";return Q(new qe(st.INTERNAL_SERVER_ERROR,f))}}serializeQuery(o){if(typeof o=="string")return o;if(typeof o=="object")for(const r in o)o[r]===void 0&&delete o[r];return o=vc.stringify(o,{arrayFormat:"none"}),o}}const Tr={accessToken:{email:"/v1/auth/accessToken/email",sso:{jwt:"/v1/auth/accessToken/sso/jwt"}},refreshAccessToken:"/v1/auth/accessToken~refresh",password:{reset:"/v1/auth/password~reset"}};class Ht extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return Ht.instance||(Ht.instance=new Ht),Ht.instance}async loginWithPassword(o,r){const f=await this.callApi({endpoint:Tr.accessToken.email,method:"POST",body:{email:o,password:r},withSpotId:!0});if(f.isErr())return Q(f.error);const{accessToken:d,refreshToken:_}=f.value;return this.setTokens(d.token,_.token),se({accessToken:d.token,refreshToken:_.token})}async loginWithSsoToken(o){const r=await this.callApi({endpoint:Tr.accessToken.sso.jwt,method:"POST",body:{token:o},withSpotId:!0});if(r.isErr())return Q(r.error);const{accessToken:f,refreshToken:d}=r.value;return this.setTokens(f.token,d.token),se({accessToken:f.token,refreshToken:d.token})}loginWithAuthTokens(o,r){return this.setTokens(o,r),{accessToken:o,refreshToken:r}}resetPassword(o){return this.callApi({endpoint:Tr.password.reset,method:"POST",body:{email:o}})}async refresh(){const o=await this.callApi({endpoint:Tr.refreshAccessToken,method:"POST",body:{refreshToken:this.refreshToken}});if(o.isErr())return Q(o.error);const{accessToken:r,refreshToken:f}=o.value;return this.setTokens(r.token,f.token),se({accessToken:r.token,refreshToken:f.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(o,r){if(this.accessToken!==o||this.refreshToken!==r){this.accessToken=o,this.refreshToken=r;const f=new CustomEvent("auth:tokens-updated",{detail:{accessToken:o,refreshToken:r}});this.dispatchEvent(f)}}async callApi(o){try{const{spotId:r,msApiBaseUrl:f}=De.getConfiguration(),d=vi(o.endpoint,f),_={"Content-Type":"application/json",...o.headers};o.withSpotId&&r&&(_[Ss.SpotId]=r);const g=await fetch(d,{method:o.method,body:o.body?JSON.stringify(o.body):void 0,headers:_});if(!g.ok)return Q(new qe(g.status,g.statusText));if(g.status===st.NO_CONTENT)return se(void 0);const y=await g.json();return se(y)}catch(r){return Q(new qe(st.INTERNAL_SERVER_ERROR,r instanceof Error?r.message:String(r)))}}}var Ss=(s=>(s.Authorization="Authorization",s.SpotId="x-spotid",s))(Ss||{});class It{constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=Ht.getInstance(),this.httpService=new wc}static getInstance(){return It.instance||(It.instance=new It),It.instance}static buildAuthenticatedRequest(o){const{msApiBaseUrl:r,spotId:f}=De.getConfiguration(),d=vi(o,r),_=Ht.getInstance().getAccessToken();if(!_)return Q(new Error("Not authenticated"));const g={"Content-Type":"application/json",Authorization:`Bearer ${_}`};return f&&(g["x-spotid"]=f),se({url:d,headers:g})}static async stream(o,r,f){const{streamTransport:d}=De.getConfiguration();if(d)return d({endpoint:o,body:r,signal:f});const _=It.buildAuthenticatedRequest(o);if(_.isErr())return Q(_.error);const{url:g,headers:y}=_.value;try{const A=await fetch(g,{method:"POST",headers:y,...r!==void 0?{body:JSON.stringify(r)}:{},...f?{signal:f}:{}});if(!A.ok){const $=await A.text();return Q(new Error(`HTTP ${A.status}: ${$}`))}return A.body?se(A.body):Q(new Error("Response body is empty"))}catch(A){const $=A instanceof Error?A.message:"Unknown error";return Q(A instanceof Error?A:new Error($))}}get pendingCount(){return this.queue.length}enqueue(o){return new Promise(r=>{const f=async()=>{try{const d=await o();r(d)}catch(d){r(Q(new qe(st.INTERNAL_SERVER_ERROR,d instanceof Error?d.message:"Unknown error")))}};this.queue.push(f),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){const o=this.queue.shift();if(!o)break;await o()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){const o=this.isPaused;this.isPaused=!1,o&&this.processQueue()}async call(o){return this.enqueue(async()=>{const r=async()=>{const{spotId:d,msApiBaseUrl:_}=De.getConfiguration(),g={...o.options?.headers??{}};d&&(g["x-spotid"]=d);const y=this.authService.getAccessToken(),{requiresAuth:A=!0}=o;if(!y&&A)return Q(new qe(st.UNAUTHORIZED));y&&(g.Authorization=`Bearer ${y}`);const $=vi(o.endpoint,_);switch(o.method){case Se.GET:return this.httpService.get({...o.options??{},headers:g,url:$});case Se.PATCH:return this.httpService.patch({...o.options??{},headers:g,url:$});case Se.POST:return this.httpService.post({...o.options??{},headers:g,url:$});default:return Q(new qe(st.METHOD_NOT_ALLOWED,"Method not allowed"))}};let f=await r();if(f.isErr()&&f.error.code===st.UNAUTHORIZED){const d=await this.authService.refresh();if(d.isErr())return Q(new qe(st.UNAUTHORIZED,d.error.message));f=await r()}return f})}}const At={playbooks:"/v1/playbooks",pages:s=>`/v1/playbooks/${s}/pages`,hotspots:(s,o)=>`/v1/playbooks/${s}/pages/${o}/hotspots`,hotspot:(s,o,r)=>`/v1/playbooks/${s}/pages/${o}/hotspots/${r}`,accessibleIntents:(s,o)=>`/v1/playbooks/${s}/pages/${o}/accessibleIntents`,intents:(s,o,r)=>`/v1/playbooks/${s}/pages/${o}/hotspots/${r}/intents`,intent:(s,o,r,f)=>`/v1/playbooks/${s}/pages/${o}/hotspots/${r}/intents/${f}`},yr=50;class gn{static getInstance(){return gn.instance||(gn.instance=new gn),gn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async listPlaybooks(o){const r=await this.meltingSpotApi.call({method:Se.GET,endpoint:At.playbooks,options:{query:{page:o?.page??1,limit:o?.limit??yr,...o?.domain?{"domain[eq]":o.domain}:{}}}});return r.isErr()?Q(r.error):se(r.value)}async listPlaybookPages(o){const r=await this.meltingSpotApi.call({method:Se.GET,endpoint:At.pages(o.playbookId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.url?{"url[eq]":o.url}:{}}}});return r.isErr()?Q(r.error):se(r.value)}async createPlaybookPage(o,r){const f=await this.meltingSpotApi.call({method:Se.POST,endpoint:At.pages(o.playbookId),options:{payload:r}});return f.isErr()?Q(f.error):se(f.value)}async listAccessiblePlaybookIntents(o){const r=await this.meltingSpotApi.call({method:Se.GET,endpoint:At.accessibleIntents(o.playbookId,o.pageId),options:{query:{...o.domain?{domain:o.domain}:{}}}});return r.isErr()?Q(r.error):se(r.value)}async listPlaybookHotspots(o){const r=await this.meltingSpotApi.call({method:Se.GET,endpoint:At.hotspots(o.playbookId,o.pageId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.intentStatus?{"intentStatus[eq]":o.intentStatus}:{},...o.widgetType?{"widgetType[eq]":o.widgetType}:{}}}});return r.isErr()?Q(r.error):se(r.value)}async createPlaybookHotspot(o,r){const f=await this.meltingSpotApi.call({method:Se.POST,endpoint:At.hotspots(o.playbookId,o.pageId),options:{payload:r}});return f.isErr()?Q(f.error):se(f.value)}async updatePlaybookHotspot(o,r){const f=await this.meltingSpotApi.call({method:Se.PATCH,endpoint:At.hotspot(o.playbookId,o.pageId,o.hotspotId),options:{payload:r}});return f.isErr()?Q(f.error):se(f.value)}async listPlaybookIntents(o){const r=await this.meltingSpotApi.call({method:Se.GET,endpoint:At.intents(o.playbookId,o.pageId,o.hotspotId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.status?{"status[eq]":o.status}:{}}}});return r.isErr()?Q(r.error):se(r.value)}async createPlaybookIntent(o,r){const f=await this.meltingSpotApi.call({method:Se.POST,endpoint:At.intents(o.playbookId,o.pageId,o.hotspotId),options:{payload:r}});return f.isErr()?Q(f.error):se(f.value)}async updatePlaybookIntent(o,r){const f=await this.meltingSpotApi.call({method:Se.PATCH,endpoint:At.intent(o.playbookId,o.pageId,o.hotspotId,o.intentId),options:{payload:r}});return f.isErr()?Q(f.error):se(f.value)}}const Ec={me:"/v1/spots/me"},Tc=50;class pn{static getInstance(){return pn.instance||(pn.instance=new pn),pn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async listSpotsForMe(o){const r=await this.meltingSpotApi.call({method:Se.GET,endpoint:Ec.me,options:{query:{page:1,limit:Tc,...o?.spotMemberRole?{"spotMemberRole[eq]":o.spotMemberRole}:{}}}});return r.isErr()?Q(r.error):se(r.value)}}const Us={spotMember:{me:"/v1/spotMembers/me",joinFromSso:"/v1/spotMembers~joinFromSso"}};class mn{static getInstance(){return mn.instance||(mn.instance=new mn),mn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async getSpotMemberForMe(){const o=await this.meltingSpotApi.call({method:Se.GET,endpoint:Us.spotMember.me});return o.isErr()?Q(o.error):se(o.value)}async joinFromSso(o){const r=await this.meltingSpotApi.call({method:Se.POST,endpoint:Us.spotMember.joinFromSso,options:{payload:{token:o}}});return r.isErr()?Q(r.error):se(r.value)}}const yc={spotMemberSsoToken:"/v1/spotMembers/auth/sso/jwt"};class _n{static getInstance(){return _n.instance||(_n.instance=new _n),_n.instance}constructor(){this.meltingSpotApi=It.getInstance()}async generateSsoToken(){const o=await this.meltingSpotApi.call({method:Se.POST,endpoint:yc.spotMemberSsoToken,options:{payload:{}}});return o.isErr()?Q(o.error):se(o.value.token)}}class vn{static getInstance(){return vn.instance||(vn.instance=new vn),vn.instance}constructor(){this.spotMemberAuthApiService=_n.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}}const Oi=s=>{const o=s.get("utm_source");if(o)return{source:o,medium:s.get("utm_medium")??void 0,campaign:s.get("utm_campaign")??void 0,term:s.get("utm_term")??void 0,content:s.get("utm_content")??void 0}},Mi=s=>s?Object.entries(s).reduce((o,[r,f])=>(f!=null&&(o[`utm_${r}`]=f),o),{}):{},Ic=De.getInstance(),Ac=Ht.getInstance(),Rc=vn.getInstance(),Lc={Playbook:gn.getInstance(),Spot:pn.getInstance(),SpotMember:mn.getInstance()},wn=globalThis;wn.MeltingSpot||(wn.MeltingSpot={}),wn.MeltingSpot.Configuration=Ic,wn.MeltingSpot.Auth=Ac,wn.MeltingSpot.Sso=Rc,wn.MeltingSpot.Api=Lc;const Oc="1.4.0",bi=new Ti({appName:"Embed SDK",appVersion:Oc});class Ir{constructor(o){this.content=o}#e=null;#t=null;set onRemove(o){this.#t=o}inject(o){this.remove();const r=wi({input:o,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add("ms-embed"),r.appendChild(this.#e)}remove(){this.#e&&(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),this.#e=null)}}class Mc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.deeplink=o.deeplink?oc({deeplink:o.deeplink,spotId:this.spotId}):null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=this.authToken&&this.authToken.trim().length>0?"/sso/jwt":"",r=new URL(`/spot/${this.spotId}${o}`,sr(this.baseURL)),f=Ei({url:r,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...Mi(this.utmParameters)},rootDocument:this.rootDocument});return f.classList.add("ms-spot"),f}}const xi={READY:"meltingspot:ready",ERROR:"meltingspot:error"},Oe=class Oe{static injectSpotInto(o,r){const{onReady:f,onError:d,..._}=r,{spotId:g,rootDocument:y,msCommunityWebBaseUrl:A}=De.getConfiguration({spotId:_.spotId,rootDocument:_.rootDocument,msCommunityWebBaseUrl:_.baseURL});if(!g)throw bi.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const $=new URLSearchParams(window.location.search),H={spotId:g,authToken:_.authToken??$.get("ms_token"),domain:_.domain,deeplink:_.deeplink??$.get("ms_url"),themeMode:_.themeMode,utmParameters:_.utmParameters??Oi($),baseURL:A,rootDocument:y},U=new Ir(new Mc(H));if(U.inject(o),Oe.embeds.push(U),f||d){const N=U.content.iframe.contentWindow;N&&(Oe.iframeCallbacks.set(N,{onReady:f,onError:d}),U.onRemove=q=>{Oe.iframeCallbacks.delete(q)}),Oe.ensureMessageListener()}return bi.log("Spot injected",H,o),U}static clear(){Oe.embeds.forEach(o=>{o.remove()}),Oe.embeds=[],Oe.iframeCallbacks.clear(),Oe.messageListened&&(window.removeEventListener("message",Oe.handleMessageEvent),Oe.messageListened=!1),bi.log("All MeltingSpot embeds cleared")}static handleMessageEvent(o){if(!o.data||typeof o.data!="object"||o.data.type!==xi.READY&&o.data.type!==xi.ERROR)return;const r=o.source,f=Oe.iframeCallbacks.get(r);if(!f)return;const{msCommunityWebBaseUrl:d}=De.getConfiguration({});if(d)try{const _=new URL(d).origin;if(o.origin!==_)return}catch{}o.data.type===xi.READY?f.onReady?.():f.onError?.(o.data.error)}static ensureMessageListener(){Oe.messageListened||(window.addEventListener("message",Oe.handleMessageEvent),Oe.messageListened=!0)}};Oe.embeds=[],Oe.messageListened=!1,Oe.iframeCallbacks=new Map;let Di=Oe;const Si=globalThis;Si.MeltingSpot||(Si.MeltingSpot={}),Si.MeltingSpot.Embed=Di;const bc="1.4.0",He=new Ti({appName:"Widget SDK",appVersion:bc});class $s{constructor(o,r,f){this.content=o,this.rootDocument=r,this.dialogClassname=f,this.dialogElement=null,this.triggerElement=null,this.iframeElement=null,this.currentListener=null}inject({into:o,bind:r,options:f}){this.remove();const d=wi({input:o,rootDocument:this.rootDocument});if(this.dialogElement=Ef(this.rootDocument),this.dialogElement.classList.add(this.dialogClassname),this.dialogElement.onclose=()=>this.#t(),d.appendChild(this.dialogElement),r){this.triggerElement=wi({input:r,rootDocument:this.rootDocument});const _=this.open.bind(this,f);this.currentListener=g=>{g.stopPropagation(),g.preventDefault(),_()},this.triggerElement.addEventListener("click",this.currentListener)}}remove(){this.dialogElement&&(this.dialogElement.remove(),this.dialogElement.onclose=null,this.dialogElement=null),this.triggerElement&&(this.currentListener&&this.triggerElement.removeEventListener("click",this.currentListener),this.triggerElement=null,this.currentListener=null)}open(o){this.dialogElement||this.inject({into:this.rootDocument.body}),this.dialogElement&&(this.#e(),this.dialogElement.showModal())}close(){this.dialogElement&&this.dialogElement.close()}#e(){this.dialogElement&&(this.iframeElement=this.dialogElement.appendChild(this.content.iframe))}#t(){this.iframeElement&&(this.iframeElement.remove(),this.iframeElement=null)}}class Ar extends $s{constructor(o,r){super(o,r,"ms-drawer")}open(o){const{position:r="right"}=o??{};super.open(o),this.dialogElement&&(this.dialogElement.dataset.position=r)}}class Rr extends $s{constructor(o,r){super(o,r,"ms-modal")}}class xc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.widgetId=nn(o.widgetId),this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=new URL(`/widgets/spot/${this.spotId}/widget/${this.widgetId}`,sr(this.baseURL)),r=Ei({url:o,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,...Mi(this.utmParameters)},rootDocument:this.rootDocument});return r.classList.add("ms-widget"),r}}class Dc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.widgetContentId=nn(o.widgetContentId),this.contentId=nn(o.contentId),this.widgetId=nn(o.widgetId),this.contentType=o.contentType,this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=new URL(`/widgets/spot/${this.spotId}/widgetContent/${this.widgetContentId}`,sr(this.baseURL));o.searchParams.set("widgetId",this.widgetId);const r=Ei({url:o,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,contentId:this.contentId,contentType:this.contentType,...Mi(this.utmParameters)},rootDocument:this.rootDocument});return r.classList.add("ms-widget-content"),r}}const ee=class ee{static injectWidgetInto(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=De.getConfiguration({spotId:r.spotId,rootDocument:r.rootDocument,msCommunityWebBaseUrl:r.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widget:g,args:y}=ee.createWidget({...r,spotId:f,rootDocument:d,baseURL:_}),A=new Ir(g);return A.inject(o),ee.widgets.push(A),He.log("Widget injected",ee.cleanupLoggedArgs(y),o),A}static injectWidgetContentInto(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=De.getConfiguration({spotId:r.spotId,rootDocument:r.rootDocument,msCommunityWebBaseUrl:r.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widgetContent:g,args:y}=ee.createWidgetContent({...r,spotId:f,rootDocument:d,baseURL:_}),A=new Ir(g);return A.inject(o),ee.widgets.push(A),He.log("WidgetContent injected",ee.cleanupLoggedArgs(y),o),A}static bindWidgetModalTo(o,r){return ee.bindEntityModalTo(o,{type:"Widget",data:r})}static bindWidgetDrawerTo(o,r){return ee.bindEntityDrawerTo(o,{type:"Widget",data:r})}static createWidgetDrawer(o){const{widget:r}=ee.createWidget(o);return He.log("Create Widget drawer",{data:ee.cleanupLoggedArgs(o)}),new Ar(r,o.rootDocument??document)}static createWidgetModal(o){const{widget:r}=ee.createWidget(o);return He.log("Create Widget modal",{data:ee.cleanupLoggedArgs(o)}),new Rr(r,o.rootDocument??document)}static createWidgetEmbed(o){const{widget:r}=ee.createWidget(o),f=new Ir(r);return He.log("Create Widget embed",{data:ee.cleanupLoggedArgs(o)}),f}static clear(){ee.widgets.forEach(o=>{o.remove()}),ee.widgets=[],ee.widgetOptions={},He.log("All Widget SDK MeltingSpot elements were cleared")}static bindEntityDrawerTo(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=De.getConfiguration({spotId:r.data.spotId,rootDocument:r.data.rootDocument??document,msCommunityWebBaseUrl:r.data.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let g,y;switch(r.type){case"Widget":{const U=ee.createWidget({...r.data,spotId:f,rootDocument:d,baseURL:_});g=U.widget,y=U.args}break;case"WidgetContent":{const U=ee.createWidgetContent({...r.data,spotId:f,rootDocument:d,baseURL:_});g=U.widgetContent,y=U.args}}const A=new Ar(g,d),$={position:r.data.position},H=r.data.into??d.body;return A.inject({into:H,bind:o,options:$}),ee.widgets.push(A),He.log("Widget bound to drawer",ee.cleanupLoggedArgs(y),$,H,o),A}static bindEntityModalTo(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=De.getConfiguration({spotId:r.data.spotId,rootDocument:r.data.rootDocument??document,msCommunityWebBaseUrl:r.data.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let g,y;switch(r.type){case"Widget":{const H=ee.createWidget({...r.data,spotId:f,rootDocument:d,baseURL:_});g=H.widget,y=H.args}break;case"WidgetContent":{const H=ee.createWidgetContent({...r.data,spotId:f,rootDocument:d,baseURL:_});g=H.widgetContent,y=H.args}}const A=new Rr(g,d),$=r.data.into??d.body;return A.inject({into:$,bind:o}),ee.widgets.push(A),He.log("Widget bound to modal",ee.cleanupLoggedArgs(y),$,o),A}static handleMessageEvent(o){if(!o.data||typeof o.data!="object"||o.data.type!=="OpenWidgetContent")return;const r=o.data?.widgetId;if(!r||typeof r!="string"){He.error("widgetId is required in the message event data");return}const f=ee.widgetOptions[r];if(!f){He.error("No widget options found for widgetId",{widgetId:r});return}let d=null;try{d=new URL(f.baseURL).origin}catch{d=null}if(!d||o.origin!==d){He.warn("Ignoring OpenWidgetContent from unexpected origin",{origin:o.origin,expectedOrigin:d});return}const{spotId:_,rootDocument:g,msCommunityWebBaseUrl:y}=De.getConfiguration({spotId:f.spotId,rootDocument:f.rootDocument??document,msCommunityWebBaseUrl:f.baseURL}),{widgetContent:A}=ee.createWidgetContent({...f,widgetContentId:o.data.widgetContentId,contentType:o.data.contentType,contentId:o.data.contentId,widgetId:r,spotId:_,rootDocument:g,baseURL:y});o.data.openingIn==="Drawer"?new Ar(A,g).open():o.data.openingIn==="Modal"&&new Rr(A,g).open()}static createWidget(o){const r=new URLSearchParams(window.location.search),f={spotId:o.spotId,widgetId:o.widgetId,authToken:o.authToken,themeMode:o.themeMode,domain:o.domain,rootDocument:o.rootDocument,baseURL:o.baseURL,utmParameters:o.utmParameters??Oi(r)};return ee.widgetOptions[f.widgetId]=f,ee.messageListened||(window.addEventListener("message",ee.handleMessageEvent),ee.messageListened=!0),{widget:new xc(f),args:f}}static createWidgetContent(o){const r=new URLSearchParams(window.location.search),f={spotId:o.spotId,contentId:o.contentId,contentType:o.contentType,widgetContentId:o.widgetContentId,widgetId:o.widgetId,authToken:o.authToken,themeMode:o.themeMode,domain:o.domain,rootDocument:o.rootDocument,baseURL:o.baseURL,utmParameters:o.utmParameters??Oi(r)};return{widgetContent:new Dc(f),args:f}}static cleanupLoggedArgs(o){const{authToken:r,...f}=o;return{...f,authToken:r?"***":void 0}}};ee.widgets=[],ee.messageListened=!1,ee.widgetOptions={};let Lr=ee;const Ui=globalThis;Ui.MeltingSpot||(Ui.MeltingSpot={}),Ui.MeltingSpot.Widget=Lr,kt.Drawer=Ar,kt.Modal=Rr,kt.Widget=Lr,Object.defineProperty(kt,Symbol.toStringTag,{value:"Module"})}));
|
|
33
|
+
}`;var J=ff(function(){return oe(c,S+"return "+I).apply(r,l)});if(J.source=I,zo(J))throw J;return J}function y_(e){return ae(e).toLowerCase()}function I_(e){return ae(e).toUpperCase()}function A_(e,t,n){if(e=ae(e),e&&(n||t===r))return _u(e);if(!e||!(t=nt(t)))return e;var i=wt(e),u=wt(t),c=vu(i,u),l=wu(i,u)+1;return Jt(i,c,l).join("")}function R_(e,t,n){if(e=ae(e),e&&(n||t===r))return e.slice(0,Tu(e)+1);if(!e||!(t=nt(t)))return e;var i=wt(e),u=wu(i,wt(t))+1;return Jt(i,0,u).join("")}function L_(e,t,n){if(e=ae(e),e&&(n||t===r))return e.replace(Gi,"");if(!e||!(t=nt(t)))return e;var i=wt(e),u=vu(i,wt(t));return Jt(i,u).join("")}function O_(e,t){var n=ce,i=ie;if(we(t)){var u="separator"in t?t.separator:u;n="length"in t?Z(t.length):n,i="omission"in t?nt(t.omission):i}e=ae(e);var c=e.length;if(An(e)){var l=wt(e);c=l.length}if(n>=c)return e;var h=n-Rn(i);if(h<1)return i;var m=l?Jt(l,0,h).join(""):e.slice(0,h);if(u===r)return m+i;if(l&&(h+=m.length-h),qo(u)){if(e.slice(h).search(u)){var E,T=m;for(u.global||(u=uo(u.source,ae(Ws.exec(u))+"g")),u.lastIndex=0;E=u.exec(T);)var I=E.index;m=m.slice(0,I===r?h:I)}}else if(e.indexOf(nt(u),h)!=h){var L=m.lastIndexOf(u);L>-1&&(m=m.slice(0,L))}return m+i}function M_(e){return e=ae(e),e&&Wc.test(e)?e.replace(Ps,rh):e}var b_=Sn(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Zo=fa("toUpperCase");function af(e,t,n){return e=ae(e),t=n?r:t,t===r?Vl(e)?sh(e):Bl(e):e.match(t)||[]}var ff=X(function(e,t){try{return et(e,r,t)}catch(n){return zo(n)?n:new B(n)}}),x_=Pt(function(e,t){return at(t,function(n){n=Mt(n),$t(e,n,Bo(e[n],e))}),e});function D_(e){var t=e==null?0:e.length,n=P();return e=t?pe(e,function(i){if(typeof i[1]!="function")throw new ft(g);return[n(i[0]),i[1]]}):[],X(function(i){for(var u=-1;++u<t;){var c=e[u];if(et(c[0],this,i))return et(c[1],this,i)}})}function S_(e){return rd(lt(e,U))}function Jo(e){return function(){return e}}function U_(e,t){return e==null||e!==e?t:e}var $_=la(),N_=la(!0);function Je(e){return e}function Xo(e){return ku(typeof e=="function"?e:lt(e,U))}function P_(e){return Bu(lt(e,U))}function C_(e,t){return Gu(e,lt(t,U))}var F_=X(function(e,t){return function(n){return Vn(n,e,t)}}),W_=X(function(e,t){return function(n){return Vn(e,n,t)}});function Vo(e,t,n){var i=$e(t),u=Xr(t,i);n==null&&!(we(t)&&(u.length||!i.length))&&(n=t,t=e,e=this,u=Xr(t,$e(t)));var c=!(we(n)&&"chain"in n)||!!n.chain,l=Ft(e);return at(u,function(h){var m=t[h];e[h]=m,l&&(e.prototype[h]=function(){var E=this.__chain__;if(c||E){var T=e(this.__wrapped__),I=T.__actions__=Ke(this.__actions__);return I.push({func:m,args:arguments,thisArg:e}),T.__chain__=E,T}return m.apply(e,Gt([this.value()],arguments))})}),e}function Y_(){return Ce._===this&&(Ce._=hh),this}function jo(){}function k_(e){return e=Z(e),X(function(t){return zu(t,e)})}var H_=xo(pe),B_=xo(hu),G_=xo(eo);function cf(e){return Co(e)?to(Mt(e)):Ed(e)}function z_(e){return function(t){return e==null?r:cn(e,t)}}var q_=da(),K_=da(!0);function es(){return[]}function ts(){return!1}function Q_(){return{}}function Z_(){return""}function J_(){return!0}function X_(e,t){if(e=Z(e),e<1||e>R)return[];var n=V,i=Ye(e,V);t=P(t),e-=V;for(var u=io(i,t);++n<e;)t(n);return u}function V_(e){return z(e)?pe(e,Mt):rt(e)?[e]:Ke(ba(ae(e)))}function j_(e){var t=++ch;return ae(e)+t}var e0=ri(function(e,t){return e+t},0),t0=Do("ceil"),n0=ri(function(e,t){return e/t},1),r0=Do("floor");function i0(e){return e&&e.length?Jr(e,Je,mo):r}function o0(e,t){return e&&e.length?Jr(e,P(t,2),mo):r}function s0(e){return pu(e,Je)}function u0(e,t){return pu(e,P(t,2))}function a0(e){return e&&e.length?Jr(e,Je,Eo):r}function f0(e,t){return e&&e.length?Jr(e,P(t,2),Eo):r}var c0=ri(function(e,t){return e*t},1),l0=Do("round"),h0=ri(function(e,t){return e-t},0);function d0(e){return e&&e.length?ro(e,Je):0}function g0(e,t){return e&&e.length?ro(e,P(t,2)):0}return a.after=Pp,a.ary=Ya,a.assign=Im,a.assignIn=ef,a.assignInWith=mi,a.assignWith=Am,a.at=Rm,a.before=ka,a.bind=Bo,a.bindAll=x_,a.bindKey=Ha,a.castArray=Qp,a.chain=Ca,a.chunk=rg,a.compact=ig,a.concat=og,a.cond=D_,a.conforms=S_,a.constant=Jo,a.countBy=dp,a.create=Lm,a.curry=Ba,a.curryRight=Ga,a.debounce=za,a.defaults=Om,a.defaultsDeep=Mm,a.defer=Cp,a.delay=Fp,a.difference=sg,a.differenceBy=ug,a.differenceWith=ag,a.drop=fg,a.dropRight=cg,a.dropRightWhile=lg,a.dropWhile=hg,a.fill=dg,a.filter=pp,a.flatMap=vp,a.flatMapDeep=wp,a.flatMapDepth=Ep,a.flatten=Ua,a.flattenDeep=gg,a.flattenDepth=pg,a.flip=Wp,a.flow=$_,a.flowRight=N_,a.fromPairs=mg,a.functions=Nm,a.functionsIn=Pm,a.groupBy=Tp,a.initial=vg,a.intersection=wg,a.intersectionBy=Eg,a.intersectionWith=Tg,a.invert=Fm,a.invertBy=Wm,a.invokeMap=Ip,a.iteratee=Xo,a.keyBy=Ap,a.keys=$e,a.keysIn=Ze,a.map=ci,a.mapKeys=km,a.mapValues=Hm,a.matches=P_,a.matchesProperty=C_,a.memoize=hi,a.merge=Bm,a.mergeWith=tf,a.method=F_,a.methodOf=W_,a.mixin=Vo,a.negate=di,a.nthArg=k_,a.omit=Gm,a.omitBy=zm,a.once=Yp,a.orderBy=Rp,a.over=H_,a.overArgs=kp,a.overEvery=B_,a.overSome=G_,a.partial=Go,a.partialRight=qa,a.partition=Lp,a.pick=qm,a.pickBy=nf,a.property=cf,a.propertyOf=z_,a.pull=Rg,a.pullAll=Na,a.pullAllBy=Lg,a.pullAllWith=Og,a.pullAt=Mg,a.range=q_,a.rangeRight=K_,a.rearg=Hp,a.reject=bp,a.remove=bg,a.rest=Bp,a.reverse=ko,a.sampleSize=Dp,a.set=Qm,a.setWith=Zm,a.shuffle=Sp,a.slice=xg,a.sortBy=Np,a.sortedUniq=Cg,a.sortedUniqBy=Fg,a.split=v_,a.spread=Gp,a.tail=Wg,a.take=Yg,a.takeRight=kg,a.takeRightWhile=Hg,a.takeWhile=Bg,a.tap=ip,a.throttle=zp,a.thru=fi,a.toArray=Xa,a.toPairs=rf,a.toPairsIn=of,a.toPath=V_,a.toPlainObject=ja,a.transform=Jm,a.unary=qp,a.union=Gg,a.unionBy=zg,a.unionWith=qg,a.uniq=Kg,a.uniqBy=Qg,a.uniqWith=Zg,a.unset=Xm,a.unzip=Ho,a.unzipWith=Pa,a.update=Vm,a.updateWith=jm,a.values=Nn,a.valuesIn=e_,a.without=Jg,a.words=af,a.wrap=Kp,a.xor=Xg,a.xorBy=Vg,a.xorWith=jg,a.zip=ep,a.zipObject=tp,a.zipObjectDeep=np,a.zipWith=rp,a.entries=rf,a.entriesIn=of,a.extend=ef,a.extendWith=mi,Vo(a,a),a.add=e0,a.attempt=ff,a.camelCase=i_,a.capitalize=sf,a.ceil=t0,a.clamp=t_,a.clone=Zp,a.cloneDeep=Xp,a.cloneDeepWith=Vp,a.cloneWith=Jp,a.conformsTo=jp,a.deburr=uf,a.defaultTo=U_,a.divide=n0,a.endsWith=o_,a.eq=Tt,a.escape=s_,a.escapeRegExp=u_,a.every=gp,a.find=mp,a.findIndex=Da,a.findKey=bm,a.findLast=_p,a.findLastIndex=Sa,a.findLastKey=xm,a.floor=r0,a.forEach=Fa,a.forEachRight=Wa,a.forIn=Dm,a.forInRight=Sm,a.forOwn=Um,a.forOwnRight=$m,a.get=Ko,a.gt=em,a.gte=tm,a.has=Cm,a.hasIn=Qo,a.head=$a,a.identity=Je,a.includes=yp,a.indexOf=_g,a.inRange=n_,a.invoke=Ym,a.isArguments=dn,a.isArray=z,a.isArrayBuffer=nm,a.isArrayLike=Qe,a.isArrayLikeObject=ye,a.isBoolean=rm,a.isBuffer=Xt,a.isDate=im,a.isElement=om,a.isEmpty=sm,a.isEqual=um,a.isEqualWith=am,a.isError=zo,a.isFinite=fm,a.isFunction=Ft,a.isInteger=Ka,a.isLength=gi,a.isMap=Qa,a.isMatch=cm,a.isMatchWith=lm,a.isNaN=hm,a.isNative=dm,a.isNil=pm,a.isNull=gm,a.isNumber=Za,a.isObject=we,a.isObjectLike=Ee,a.isPlainObject=ir,a.isRegExp=qo,a.isSafeInteger=mm,a.isSet=Ja,a.isString=pi,a.isSymbol=rt,a.isTypedArray=$n,a.isUndefined=_m,a.isWeakMap=vm,a.isWeakSet=wm,a.join=yg,a.kebabCase=a_,a.last=dt,a.lastIndexOf=Ig,a.lowerCase=f_,a.lowerFirst=c_,a.lt=Em,a.lte=Tm,a.max=i0,a.maxBy=o0,a.mean=s0,a.meanBy=u0,a.min=a0,a.minBy=f0,a.stubArray=es,a.stubFalse=ts,a.stubObject=Q_,a.stubString=Z_,a.stubTrue=J_,a.multiply=c0,a.nth=Ag,a.noConflict=Y_,a.noop=jo,a.now=li,a.pad=l_,a.padEnd=h_,a.padStart=d_,a.parseInt=g_,a.random=r_,a.reduce=Op,a.reduceRight=Mp,a.repeat=p_,a.replace=m_,a.result=Km,a.round=l0,a.runInContext=p,a.sample=xp,a.size=Up,a.snakeCase=__,a.some=$p,a.sortedIndex=Dg,a.sortedIndexBy=Sg,a.sortedIndexOf=Ug,a.sortedLastIndex=$g,a.sortedLastIndexBy=Ng,a.sortedLastIndexOf=Pg,a.startCase=w_,a.startsWith=E_,a.subtract=h0,a.sum=d0,a.sumBy=g0,a.template=T_,a.times=X_,a.toFinite=Wt,a.toInteger=Z,a.toLength=Va,a.toLower=y_,a.toNumber=gt,a.toSafeInteger=ym,a.toString=ae,a.toUpper=I_,a.trim=A_,a.trimEnd=R_,a.trimStart=L_,a.truncate=O_,a.unescape=M_,a.uniqueId=j_,a.upperCase=b_,a.upperFirst=Zo,a.each=Fa,a.eachRight=Wa,a.first=$a,Vo(a,(function(){var e={};return Lt(a,function(t,n){fe.call(a.prototype,n)||(e[n]=t)}),e})(),{chain:!1}),a.VERSION=f,at(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){a[e].placeholder=a}),at(["drop","take"],function(e,t){te.prototype[e]=function(n){n=n===r?1:xe(Z(n),0);var i=this.__filtered__&&!t?new te(this):this.clone();return i.__filtered__?i.__takeCount__=Ye(n,i.__takeCount__):i.__views__.push({size:Ye(n,V),type:e+(i.__dir__<0?"Right":"")}),i},te.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),at(["filter","map","takeWhile"],function(e,t){var n=t+1,i=n==W||n==O;te.prototype[e]=function(u){var c=this.clone();return c.__iteratees__.push({iteratee:P(u,3),type:n}),c.__filtered__=c.__filtered__||i,c}}),at(["head","last"],function(e,t){var n="take"+(t?"Right":"");te.prototype[e]=function(){return this[n](1).value()[0]}}),at(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");te.prototype[e]=function(){return this.__filtered__?new te(this):this[n](1)}}),te.prototype.compact=function(){return this.filter(Je)},te.prototype.find=function(e){return this.filter(e).head()},te.prototype.findLast=function(e){return this.reverse().find(e)},te.prototype.invokeMap=X(function(e,t){return typeof e=="function"?new te(this):this.map(function(n){return Vn(n,e,t)})}),te.prototype.reject=function(e){return this.filter(di(P(e)))},te.prototype.slice=function(e,t){e=Z(e);var n=this;return n.__filtered__&&(e>0||t<0)?new te(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=Z(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},te.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},te.prototype.toArray=function(){return this.take(V)},Lt(te.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),u=a[i?"take"+(t=="last"?"Right":""):t],c=i||/^find/.test(t);u&&(a.prototype[t]=function(){var l=this.__wrapped__,h=i?[1]:arguments,m=l instanceof te,E=h[0],T=m||z(l),I=function(j){var re=u.apply(a,Gt([j],h));return i&&L?re[0]:re};T&&n&&typeof E=="function"&&E.length!=1&&(m=T=!1);var L=this.__chain__,S=!!this.__actions__.length,C=c&&!L,J=m&&!S;if(!c&&T){l=J?l:new te(this);var F=e.apply(l,h);return F.__actions__.push({func:fi,args:[I],thisArg:r}),new ct(F,L)}return C&&J?e.apply(this,h):(F=this.thru(I),C?i?F.value()[0]:F.value():F)})}),at(["pop","push","shift","sort","splice","unshift"],function(e){var t=Nr[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);a.prototype[e]=function(){var u=arguments;if(i&&!this.__chain__){var c=this.value();return t.apply(z(c)?c:[],u)}return this[n](function(l){return t.apply(z(l)?l:[],u)})}}),Lt(te.prototype,function(e,t){var n=a[t];if(n){var i=n.name+"";fe.call(bn,i)||(bn[i]=[]),bn[i].push({name:t,func:n})}}),bn[ni(r,he).name]=[{name:"wrapper",func:r}],te.prototype.clone=Mh,te.prototype.reverse=bh,te.prototype.value=xh,a.prototype.at=op,a.prototype.chain=sp,a.prototype.commit=up,a.prototype.next=ap,a.prototype.plant=cp,a.prototype.reverse=lp,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=hp,a.prototype.first=a.prototype.head,zn&&(a.prototype[zn]=fp),a}),Ln=uh();on?((on.exports=Ln)._=Ln,Ji._=Ln):Ce._=Ln}).call(ec)})(Fn,Fn.exports)),Fn.exports}tc();const nc="1.5.1";class Ti{constructor(o){this.debug=!1,this.debug=o?.debug??!1,this.appName=o?.appName,this.appVersion=o?.appVersion}log(o,...r){this.debug&&this.print(o,"info",r)}warn(o,...r){this.print(o,"warn",r)}error(o,...r){this.print(o,"error",r)}print(o,r,f){const g=[`[${["MeltingSpot",this.appName,this.appVersion].filter(Boolean).join(" - ")}] ${o}`];f.length&&g.push(...f),console[r](...g)}}const rc=new Ti({appName:"Core SDK",appVersion:nc}),nn=s=>s.toLowerCase().replace(/[^a-z0-9-]/g,""),ic=["/user"],oc=({deeplink:s,spotId:o})=>{try{const r=new URL(s,"https://unused.com");let f=r.pathname;return r.search&&(f+=r.search),r.hash&&(f+=r.hash),ic.some(d=>f.startsWith(d))||(f=`/spot/${o}/${vf(f)}`),f}catch(r){return rc.warn("Failed to parse deeplink URL",r),null}},sc=[/(^|\.)meltingspot\.io$/i],yi=s=>{let o;try{const _=sr(s);o=new URL(_)}catch{throw new Error(`Invalid baseURL: ${s}`)}const r=o.hostname==="localhost"||o.hostname==="127.0.0.1",f=o.protocol==="https:",d=sc.some(_=>_.test(o.hostname));if(!r&&(!f||!d))throw new Error(`Untrusted baseURL origin: ${o.origin}`);return o.origin},uc={msApiBaseUrl:"https://openapi.meltingspot.io/",msCommunityWebBaseUrl:"https://go.meltingspot.io/",ssoToken:void 0,spotId:"",autoJoin:!1,rootDocument:globalThis.document};class De{constructor(){this.configuration=uc}static getInstance(){return De.instance||(De.instance=new De),De.instance}setConfiguration(o){this.configuration={...this.configuration,...o}}static getConfiguration(o={}){return{...De.getInstance().configuration,...o}}}const Es="%[a-f0-9]{2}",Ts=new RegExp("("+Es+")|([^%]+?)","gi"),ys=new RegExp("("+Es+")+","gi");function Ii(s,o){try{return[decodeURIComponent(s.join(""))]}catch{}if(s.length===1)return s;o=o||1;const r=s.slice(0,o),f=s.slice(o);return Array.prototype.concat.call([],Ii(r),Ii(f))}function ac(s){try{return decodeURIComponent(s)}catch{let o=s.match(Ts)||[];for(let r=1;r<o.length;r++)s=Ii(o,r).join(""),o=s.match(Ts)||[];return s}}function fc(s){const o={"%FE%FF":"��","%FF%FE":"��"};let r=ys.exec(s);for(;r;){try{o[r[0]]=decodeURIComponent(r[0])}catch{const d=ac(r[0]);d!==r[0]&&(o[r[0]]=d)}r=ys.exec(s)}o["%C2"]="�";const f=Object.keys(o);for(const d of f)s=s.replace(new RegExp(d,"g"),o[d]);return s}function cc(s){if(typeof s!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof s+"`");try{return decodeURIComponent(s)}catch{return fc(s)}}function lc(s,o){const r={};if(Array.isArray(o))for(const f of o){const d=Object.getOwnPropertyDescriptor(s,f);d?.enumerable&&Object.defineProperty(r,f,d)}else for(const f of Reflect.ownKeys(s)){const d=Object.getOwnPropertyDescriptor(s,f);if(d.enumerable){const _=s[f];o(f,_,s)&&Object.defineProperty(r,f,d)}}return r}function Is(s,o){if(!(typeof s=="string"&&typeof o=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(s===""||o==="")return[];const r=s.indexOf(o);return r===-1?[]:[s.slice(0,r),s.slice(r+o.length)]}const hc=s=>s==null,dc=s=>encodeURIComponent(s).replaceAll(/[!'()*]/g,o=>`%${o.charCodeAt(0).toString(16).toUpperCase()}`),Ai=Symbol("encodeFragmentIdentifier");function gc(s){switch(s.arrayFormat){case"index":return o=>(r,f)=>{const d=r.length;return f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,[Ae(o,s),"[",d,"]"].join("")]:[...r,[Ae(o,s),"[",Ae(d,s),"]=",Ae(f,s)].join("")]};case"bracket":return o=>(r,f)=>f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,[Ae(o,s),"[]"].join("")]:[...r,[Ae(o,s),"[]=",Ae(f,s)].join("")];case"colon-list-separator":return o=>(r,f)=>f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,[Ae(o,s),":list="].join("")]:[...r,[Ae(o,s),":list=",Ae(f,s)].join("")];case"comma":case"separator":case"bracket-separator":{const o=s.arrayFormat==="bracket-separator"?"[]=":"=";return r=>(f,d)=>d===void 0||s.skipNull&&d===null||s.skipEmptyString&&d===""?f:(d=d===null?"":d,f.length===0?[[Ae(r,s),o,Ae(d,s)].join("")]:[[f,Ae(d,s)].join(s.arrayFormatSeparator)])}default:return o=>(r,f)=>f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,Ae(o,s)]:[...r,[Ae(o,s),"=",Ae(f,s)].join("")]}}function pc(s){let o;switch(s.arrayFormat){case"index":return(r,f,d)=>{if(o=/\[(\d*)]$/.exec(r),r=r.replace(/\[\d*]$/,""),!o){d[r]=f;return}d[r]===void 0&&(d[r]={}),d[r][o[1]]=f};case"bracket":return(r,f,d)=>{if(o=/(\[])$/.exec(r),r=r.replace(/\[]$/,""),!o){d[r]=f;return}if(d[r]===void 0){d[r]=[f];return}d[r]=[...d[r],f]};case"colon-list-separator":return(r,f,d)=>{if(o=/(:list)$/.exec(r),r=r.replace(/:list$/,""),!o){d[r]=f;return}if(d[r]===void 0){d[r]=[f];return}d[r]=[...d[r],f]};case"comma":case"separator":return(r,f,d)=>{const _=typeof f=="string"&&f.includes(s.arrayFormatSeparator),g=typeof f=="string"&&!_&&bt(f,s).includes(s.arrayFormatSeparator);f=g?bt(f,s):f;const y=_||g?f.split(s.arrayFormatSeparator).map(A=>bt(A,s)):f===null?f:bt(f,s);d[r]=y};case"bracket-separator":return(r,f,d)=>{const _=/(\[])$/.test(r);if(r=r.replace(/\[]$/,""),!_){d[r]=f&&bt(f,s);return}const g=f===null?[]:bt(f,s).split(s.arrayFormatSeparator);if(d[r]===void 0){d[r]=g;return}d[r]=[...d[r],...g]};default:return(r,f,d)=>{if(d[r]===void 0){d[r]=f;return}d[r]=[...[d[r]].flat(),f]}}}function As(s){if(typeof s!="string"||s.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function Ae(s,o){return o.encode?o.strict?dc(s):encodeURIComponent(s):s}function bt(s,o){return o.decode?cc(s):s}function Rs(s){return Array.isArray(s)?s.sort():typeof s=="object"?Rs(Object.keys(s)).sort((o,r)=>Number(o)-Number(r)).map(o=>s[o]):s}function Ls(s){const o=s.indexOf("#");return o!==-1&&(s=s.slice(0,o)),s}function mc(s){let o="";const r=s.indexOf("#");return r!==-1&&(o=s.slice(r)),o}function Os(s,o,r){return r==="string"&&typeof s=="string"?s:typeof r=="function"&&typeof s=="string"?r(s):r==="boolean"&&s===null?!0:r==="boolean"&&s!==null&&(s.toLowerCase()==="true"||s.toLowerCase()==="false")?s.toLowerCase()==="true":r==="boolean"&&s!==null&&(s.toLowerCase()==="1"||s.toLowerCase()==="0")?s.toLowerCase()==="1":r==="string[]"&&o.arrayFormat!=="none"&&typeof s=="string"?[s]:r==="number[]"&&o.arrayFormat!=="none"&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?[Number(s)]:r==="number"&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?Number(s):o.parseBooleans&&s!==null&&(s.toLowerCase()==="true"||s.toLowerCase()==="false")?s.toLowerCase()==="true":o.parseNumbers&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?Number(s):s}function Ri(s){s=Ls(s);const o=s.indexOf("?");return o===-1?"":s.slice(o+1)}function Li(s,o){o={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...o},As(o.arrayFormatSeparator);const r=pc(o),f=Object.create(null);if(typeof s!="string"||(s=s.trim().replace(/^[?#&]/,""),!s))return f;for(const d of s.split("&")){if(d==="")continue;const _=o.decode?d.replaceAll("+"," "):d;let[g,y]=Is(_,"=");g===void 0&&(g=_),y=y===void 0?null:["comma","separator","bracket-separator"].includes(o.arrayFormat)?y:bt(y,o),r(bt(g,o),y,f)}for(const[d,_]of Object.entries(f))if(typeof _=="object"&&_!==null&&o.types[d]!=="string")for(const[g,y]of Object.entries(_)){const A=o.types[d]?o.types[d].replace("[]",""):void 0;_[g]=Os(y,o,A)}else typeof _=="object"&&_!==null&&o.types[d]==="string"?f[d]=Object.values(_).join(o.arrayFormatSeparator):f[d]=Os(_,o,o.types[d]);return o.sort===!1?f:(o.sort===!0?Object.keys(f).sort():Object.keys(f).sort(o.sort)).reduce((d,_)=>{const g=f[_];return d[_]=g&&typeof g=="object"&&!Array.isArray(g)?Rs(g):g,d},Object.create(null))}function Ms(s,o){if(!s)return"";o={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...o},As(o.arrayFormatSeparator);const r=g=>o.skipNull&&hc(s[g])||o.skipEmptyString&&s[g]==="",f=gc(o),d={};for(const[g,y]of Object.entries(s))r(g)||(d[g]=y);const _=Object.keys(d);return o.sort!==!1&&_.sort(o.sort),_.map(g=>{const y=s[g];return y===void 0?"":y===null?Ae(g,o):Array.isArray(y)?y.length===0&&o.arrayFormat==="bracket-separator"?Ae(g,o)+"[]":y.reduce(f(g),[]).join("&"):Ae(g,o)+"="+Ae(y,o)}).filter(g=>g.length>0).join("&")}function bs(s,o){o={decode:!0,...o};let[r,f]=Is(s,"#");return r===void 0&&(r=s),{url:r?.split("?")?.[0]??"",query:Li(Ri(s),o),...o&&o.parseFragmentIdentifier&&f?{fragmentIdentifier:bt(f,o)}:{}}}function xs(s,o){o={encode:!0,strict:!0,[Ai]:!0,...o};const r=Ls(s.url).split("?")[0]||"",f=Ri(s.url),d={...Li(f,{sort:!1,...o}),...s.query};let _=Ms(d,o);_&&=`?${_}`;let g=mc(s.url);if(typeof s.fragmentIdentifier=="string"){const y=new URL(r);y.hash=s.fragmentIdentifier,g=o[Ai]?y.hash:`#${s.fragmentIdentifier}`}return`${r}${_}${g}`}function Ds(s,o,r){r={parseFragmentIdentifier:!0,[Ai]:!1,...r};const{url:f,query:d,fragmentIdentifier:_}=bs(s,r);return xs({url:f,query:lc(d,o),fragmentIdentifier:_},r)}function _c(s,o,r){const f=Array.isArray(o)?d=>!o.includes(d):(d,_)=>!o(d,_);return Ds(s,f,r)}const vc=Object.freeze(Object.defineProperty({__proto__:null,exclude:_c,extract:Ri,parse:Li,parseUrl:bs,pick:Ds,stringify:Ms,stringifyUrl:xs},Symbol.toStringTag,{value:"Module"}));class qe extends Error{constructor(o,r){super(`HTTP Error ${o}${r?`: ${r}`:""}`),this.code=o,this.name="HttpError",Object.setPrototypeOf(this,qe.prototype)}}var Se=(s=>(s.GET="GET",s.PATCH="PATCH",s.POST="POST",s))(Se||{});class wc{constructor(){this.headers={}}setHeaders(o){this.headers=o}async get(o){try{const r=o.query?`${o.url}?${this.serializeQuery(o.query)}`:o.url,f=await fetch(r,{headers:{...this.headers,...o.headers,"Content-Type":"application/json"},...o.signal?{signal:o.signal}:{}});return f.ok?se(await f.json()):Q(new qe(f.status,await f.text()))}catch(r){const f=r instanceof Error?r.message:"Unknown error";return Q(new qe(st.INTERNAL_SERVER_ERROR,f))}}async post(o){try{const r=await fetch(o.url,{method:"POST",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload),...o.signal?{signal:o.signal}:{}});return r.ok?se(await r.json()):Q(new qe(r.status,await r.text()))}catch(r){const f=r instanceof Error?r.message:"Unknown error";return Q(new qe(st.INTERNAL_SERVER_ERROR,f))}}async patch(o){try{const r=await fetch(o.url,{method:"PATCH",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload),...o.signal?{signal:o.signal}:{}});return r.ok?se(await r.json()):Q(new qe(r.status,await r.text()))}catch(r){const f=r instanceof Error?r.message:"Unknown error";return Q(new qe(st.INTERNAL_SERVER_ERROR,f))}}serializeQuery(o){if(typeof o=="string")return o;if(typeof o=="object")for(const r in o)o[r]===void 0&&delete o[r];return o=vc.stringify(o,{arrayFormat:"none"}),o}}const Tr={accessToken:{email:"/v1/auth/accessToken/email",sso:{jwt:"/v1/auth/accessToken/sso/jwt"}},refreshAccessToken:"/v1/auth/accessToken~refresh",password:{reset:"/v1/auth/password~reset"}};class Ht extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return Ht.instance||(Ht.instance=new Ht),Ht.instance}async loginWithPassword(o,r){const f=await this.callApi({endpoint:Tr.accessToken.email,method:"POST",body:{email:o,password:r},withSpotId:!0});if(f.isErr())return Q(f.error);const{accessToken:d,refreshToken:_}=f.value;return this.setTokens(d.token,_.token),se({accessToken:d.token,refreshToken:_.token})}async loginWithSsoToken(o){const r=await this.callApi({endpoint:Tr.accessToken.sso.jwt,method:"POST",body:{token:o},withSpotId:!0});if(r.isErr())return Q(r.error);const{accessToken:f,refreshToken:d}=r.value;return this.setTokens(f.token,d.token),se({accessToken:f.token,refreshToken:d.token})}loginWithAuthTokens(o,r){return this.setTokens(o,r),{accessToken:o,refreshToken:r}}resetPassword(o){return this.callApi({endpoint:Tr.password.reset,method:"POST",body:{email:o}})}async refresh(){const o=await this.callApi({endpoint:Tr.refreshAccessToken,method:"POST",body:{refreshToken:this.refreshToken}});if(o.isErr())return Q(o.error);const{accessToken:r,refreshToken:f}=o.value;return this.setTokens(r.token,f.token),se({accessToken:r.token,refreshToken:f.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(o,r){if(this.accessToken!==o||this.refreshToken!==r){this.accessToken=o,this.refreshToken=r;const f=new CustomEvent("auth:tokens-updated",{detail:{accessToken:o,refreshToken:r}});this.dispatchEvent(f)}}async callApi(o){try{const{spotId:r,msApiBaseUrl:f}=De.getConfiguration(),d=vi(o.endpoint,f),_={"Content-Type":"application/json",...o.headers};o.withSpotId&&r&&(_[Ss.SpotId]=r);const g=await fetch(d,{method:o.method,body:o.body?JSON.stringify(o.body):void 0,headers:_});if(!g.ok)return Q(new qe(g.status,g.statusText));if(g.status===st.NO_CONTENT)return se(void 0);const y=await g.json();return se(y)}catch(r){return Q(new qe(st.INTERNAL_SERVER_ERROR,r instanceof Error?r.message:String(r)))}}}var Ss=(s=>(s.Authorization="Authorization",s.SpotId="x-spotid",s))(Ss||{});class It{constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=Ht.getInstance(),this.httpService=new wc}static getInstance(){return It.instance||(It.instance=new It),It.instance}static buildAuthenticatedRequest(o){const{msApiBaseUrl:r,spotId:f}=De.getConfiguration(),d=vi(o,r),_=Ht.getInstance().getAccessToken();if(!_)return Q(new Error("Not authenticated"));const g={"Content-Type":"application/json",Authorization:`Bearer ${_}`};return f&&(g["x-spotid"]=f),se({url:d,headers:g})}static async stream(o,r,f){const{streamTransport:d}=De.getConfiguration();if(d)return d({endpoint:o,body:r,signal:f});const _=It.buildAuthenticatedRequest(o);if(_.isErr())return Q(_.error);const{url:g,headers:y}=_.value;try{const A=await fetch(g,{method:"POST",headers:y,...r!==void 0?{body:JSON.stringify(r)}:{},...f?{signal:f}:{}});if(!A.ok){const $=await A.text();return Q(new Error(`HTTP ${A.status}: ${$}`))}return A.body?se(A.body):Q(new Error("Response body is empty"))}catch(A){const $=A instanceof Error?A.message:"Unknown error";return Q(A instanceof Error?A:new Error($))}}get pendingCount(){return this.queue.length}enqueue(o){return new Promise(r=>{const f=async()=>{try{const d=await o();r(d)}catch(d){r(Q(new qe(st.INTERNAL_SERVER_ERROR,d instanceof Error?d.message:"Unknown error")))}};this.queue.push(f),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){const o=this.queue.shift();if(!o)break;await o()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){const o=this.isPaused;this.isPaused=!1,o&&this.processQueue()}async call(o){return this.enqueue(async()=>{const r=async()=>{const{spotId:d,msApiBaseUrl:_}=De.getConfiguration(),g={...o.options?.headers??{}};d&&(g["x-spotid"]=d);const y=this.authService.getAccessToken(),{requiresAuth:A=!0}=o;if(!y&&A)return Q(new qe(st.UNAUTHORIZED));y&&(g.Authorization=`Bearer ${y}`);const $=vi(o.endpoint,_);switch(o.method){case Se.GET:return this.httpService.get({...o.options??{},headers:g,url:$});case Se.PATCH:return this.httpService.patch({...o.options??{},headers:g,url:$});case Se.POST:return this.httpService.post({...o.options??{},headers:g,url:$});default:return Q(new qe(st.METHOD_NOT_ALLOWED,"Method not allowed"))}};let f=await r();if(f.isErr()&&f.error.code===st.UNAUTHORIZED){const d=await this.authService.refresh();if(d.isErr())return Q(new qe(st.UNAUTHORIZED,d.error.message));f=await r()}return f})}}const At={playbooks:"/v1/playbooks",pages:s=>`/v1/playbooks/${s}/pages`,hotspots:(s,o)=>`/v1/playbooks/${s}/pages/${o}/hotspots`,hotspot:(s,o,r)=>`/v1/playbooks/${s}/pages/${o}/hotspots/${r}`,accessibleIntents:(s,o)=>`/v1/playbooks/${s}/pages/${o}/accessibleIntents`,intents:(s,o,r)=>`/v1/playbooks/${s}/pages/${o}/hotspots/${r}/intents`,intent:(s,o,r,f)=>`/v1/playbooks/${s}/pages/${o}/hotspots/${r}/intents/${f}`},yr=50;class gn{static getInstance(){return gn.instance||(gn.instance=new gn),gn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async listPlaybooks(o){const r=await this.meltingSpotApi.call({method:Se.GET,endpoint:At.playbooks,options:{query:{page:o?.page??1,limit:o?.limit??yr,...o?.domain?{"domain[eq]":o.domain}:{}}}});return r.isErr()?Q(r.error):se(r.value)}async listPlaybookPages(o){const r=await this.meltingSpotApi.call({method:Se.GET,endpoint:At.pages(o.playbookId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.url?{"url[eq]":o.url}:{}}}});return r.isErr()?Q(r.error):se(r.value)}async createPlaybookPage(o,r){const f=await this.meltingSpotApi.call({method:Se.POST,endpoint:At.pages(o.playbookId),options:{payload:r}});return f.isErr()?Q(f.error):se(f.value)}async listAccessiblePlaybookIntents(o){const r=await this.meltingSpotApi.call({method:Se.GET,endpoint:At.accessibleIntents(o.playbookId,o.pageId),options:{query:{...o.domain?{domain:o.domain}:{}}}});return r.isErr()?Q(r.error):se(r.value)}async listPlaybookHotspots(o){const r=await this.meltingSpotApi.call({method:Se.GET,endpoint:At.hotspots(o.playbookId,o.pageId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.intentStatus?{"intentStatus[eq]":o.intentStatus}:{},...o.widgetType?{"widgetType[eq]":o.widgetType}:{}}}});return r.isErr()?Q(r.error):se(r.value)}async createPlaybookHotspot(o,r){const f=await this.meltingSpotApi.call({method:Se.POST,endpoint:At.hotspots(o.playbookId,o.pageId),options:{payload:r}});return f.isErr()?Q(f.error):se(f.value)}async updatePlaybookHotspot(o,r){const f=await this.meltingSpotApi.call({method:Se.PATCH,endpoint:At.hotspot(o.playbookId,o.pageId,o.hotspotId),options:{payload:r}});return f.isErr()?Q(f.error):se(f.value)}async listPlaybookIntents(o){const r=await this.meltingSpotApi.call({method:Se.GET,endpoint:At.intents(o.playbookId,o.pageId,o.hotspotId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.status?{"status[eq]":o.status}:{}}}});return r.isErr()?Q(r.error):se(r.value)}async createPlaybookIntent(o,r){const f=await this.meltingSpotApi.call({method:Se.POST,endpoint:At.intents(o.playbookId,o.pageId,o.hotspotId),options:{payload:r}});return f.isErr()?Q(f.error):se(f.value)}async updatePlaybookIntent(o,r){const f=await this.meltingSpotApi.call({method:Se.PATCH,endpoint:At.intent(o.playbookId,o.pageId,o.hotspotId,o.intentId),options:{payload:r}});return f.isErr()?Q(f.error):se(f.value)}}const Ec={me:"/v1/spots/me"},Tc=50;class pn{static getInstance(){return pn.instance||(pn.instance=new pn),pn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async listSpotsForMe(o){const r=await this.meltingSpotApi.call({method:Se.GET,endpoint:Ec.me,options:{query:{page:1,limit:Tc,...o?.spotMemberRole?{"spotMemberRole[eq]":o.spotMemberRole}:{}}}});return r.isErr()?Q(r.error):se(r.value)}}const Us={spotMember:{me:"/v1/spotMembers/me",joinFromSso:"/v1/spotMembers~joinFromSso"}};class mn{static getInstance(){return mn.instance||(mn.instance=new mn),mn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async getSpotMemberForMe(){const o=await this.meltingSpotApi.call({method:Se.GET,endpoint:Us.spotMember.me});return o.isErr()?Q(o.error):se(o.value)}async joinFromSso(o){const r=await this.meltingSpotApi.call({method:Se.POST,endpoint:Us.spotMember.joinFromSso,options:{payload:{token:o}}});return r.isErr()?Q(r.error):se(r.value)}}const yc={spotMemberSsoToken:"/v1/spotMembers/auth/sso/jwt"};class _n{static getInstance(){return _n.instance||(_n.instance=new _n),_n.instance}constructor(){this.meltingSpotApi=It.getInstance()}async generateSsoToken(){const o=await this.meltingSpotApi.call({method:Se.POST,endpoint:yc.spotMemberSsoToken,options:{payload:{}}});return o.isErr()?Q(o.error):se(o.value.token)}}class vn{static getInstance(){return vn.instance||(vn.instance=new vn),vn.instance}constructor(){this.spotMemberAuthApiService=_n.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}}const Oi=s=>{const o=s.get("utm_source");if(o)return{source:o,medium:s.get("utm_medium")??void 0,campaign:s.get("utm_campaign")??void 0,term:s.get("utm_term")??void 0,content:s.get("utm_content")??void 0}},Mi=s=>s?Object.entries(s).reduce((o,[r,f])=>(f!=null&&(o[`utm_${r}`]=f),o),{}):{},Ic=De.getInstance(),Ac=Ht.getInstance(),Rc=vn.getInstance(),Lc={Playbook:gn.getInstance(),Spot:pn.getInstance(),SpotMember:mn.getInstance()},wn=globalThis;wn.MeltingSpot||(wn.MeltingSpot={}),wn.MeltingSpot.Configuration=Ic,wn.MeltingSpot.Auth=Ac,wn.MeltingSpot.Sso=Rc,wn.MeltingSpot.Api=Lc;const Oc="1.5.1",bi=new Ti({appName:"Embed SDK",appVersion:Oc});class Ir{constructor(o){this.content=o}#e=null;#t=null;set onRemove(o){this.#t=o}inject(o){this.remove();const r=wi({input:o,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add("ms-embed"),r.appendChild(this.#e)}remove(){this.#e&&(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),this.#e=null)}}class Mc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.deeplink=o.deeplink?oc({deeplink:o.deeplink,spotId:this.spotId}):null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=this.authToken&&this.authToken.trim().length>0?"/sso/jwt":"",r=new URL(`/spot/${this.spotId}${o}`,sr(this.baseURL)),f=Ei({url:r,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...Mi(this.utmParameters)},rootDocument:this.rootDocument});return f.classList.add("ms-spot"),f}}const xi={READY:"meltingspot:ready",ERROR:"meltingspot:error"},Oe=class Oe{static injectSpotInto(o,r){const{onReady:f,onError:d,..._}=r,{spotId:g,rootDocument:y,msCommunityWebBaseUrl:A}=De.getConfiguration({spotId:_.spotId,rootDocument:_.rootDocument,msCommunityWebBaseUrl:_.baseURL});if(!g)throw bi.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const $=new URLSearchParams(window.location.search),H={spotId:g,authToken:_.authToken??$.get("ms_token"),domain:_.domain,deeplink:_.deeplink??$.get("ms_url"),themeMode:_.themeMode,utmParameters:_.utmParameters??Oi($),baseURL:A,rootDocument:y},U=new Ir(new Mc(H));if(U.inject(o),Oe.embeds.push(U),f||d){const N=U.content.iframe.contentWindow;N&&(Oe.iframeCallbacks.set(N,{onReady:f,onError:d}),U.onRemove=q=>{Oe.iframeCallbacks.delete(q)}),Oe.ensureMessageListener()}return bi.log("Spot injected",H,o),U}static clear(){Oe.embeds.forEach(o=>{o.remove()}),Oe.embeds=[],Oe.iframeCallbacks.clear(),Oe.messageListened&&(window.removeEventListener("message",Oe.handleMessageEvent),Oe.messageListened=!1),bi.log("All MeltingSpot embeds cleared")}static handleMessageEvent(o){if(!o.data||typeof o.data!="object"||o.data.type!==xi.READY&&o.data.type!==xi.ERROR)return;const r=o.source,f=Oe.iframeCallbacks.get(r);if(!f)return;const{msCommunityWebBaseUrl:d}=De.getConfiguration({});if(d)try{const _=new URL(d).origin;if(o.origin!==_)return}catch{}o.data.type===xi.READY?f.onReady?.():f.onError?.(o.data.error)}static ensureMessageListener(){Oe.messageListened||(window.addEventListener("message",Oe.handleMessageEvent),Oe.messageListened=!0)}};Oe.embeds=[],Oe.messageListened=!1,Oe.iframeCallbacks=new Map;let Di=Oe;const Si=globalThis;Si.MeltingSpot||(Si.MeltingSpot={}),Si.MeltingSpot.Embed=Di;const bc="1.5.1",He=new Ti({appName:"Widget SDK",appVersion:bc});class $s{constructor(o,r,f){this.content=o,this.rootDocument=r,this.dialogClassname=f,this.dialogElement=null,this.triggerElement=null,this.iframeElement=null,this.currentListener=null}inject({into:o,bind:r,options:f}){this.remove();const d=wi({input:o,rootDocument:this.rootDocument});if(this.dialogElement=Ef(this.rootDocument),this.dialogElement.classList.add(this.dialogClassname),this.dialogElement.onclose=()=>this.#t(),d.appendChild(this.dialogElement),r){this.triggerElement=wi({input:r,rootDocument:this.rootDocument});const _=this.open.bind(this,f);this.currentListener=g=>{g.stopPropagation(),g.preventDefault(),_()},this.triggerElement.addEventListener("click",this.currentListener)}}remove(){this.dialogElement&&(this.dialogElement.remove(),this.dialogElement.onclose=null,this.dialogElement=null),this.triggerElement&&(this.currentListener&&this.triggerElement.removeEventListener("click",this.currentListener),this.triggerElement=null,this.currentListener=null)}open(o){this.dialogElement||this.inject({into:this.rootDocument.body}),this.dialogElement&&(this.#e(),this.dialogElement.showModal())}close(){this.dialogElement&&this.dialogElement.close()}#e(){this.dialogElement&&(this.iframeElement=this.dialogElement.appendChild(this.content.iframe))}#t(){this.iframeElement&&(this.iframeElement.remove(),this.iframeElement=null)}}class Ar extends $s{constructor(o,r){super(o,r,"ms-drawer")}open(o){const{position:r="right"}=o??{};super.open(o),this.dialogElement&&(this.dialogElement.dataset.position=r)}}class Rr extends $s{constructor(o,r){super(o,r,"ms-modal")}}class xc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.widgetId=nn(o.widgetId),this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=new URL(`/widgets/spot/${this.spotId}/widget/${this.widgetId}`,sr(this.baseURL)),r=Ei({url:o,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,...Mi(this.utmParameters)},rootDocument:this.rootDocument});return r.classList.add("ms-widget"),r}}class Dc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.widgetContentId=nn(o.widgetContentId),this.contentId=nn(o.contentId),this.widgetId=nn(o.widgetId),this.contentType=o.contentType,this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=new URL(`/widgets/spot/${this.spotId}/widgetContent/${this.widgetContentId}`,sr(this.baseURL));o.searchParams.set("widgetId",this.widgetId);const r=Ei({url:o,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,contentId:this.contentId,contentType:this.contentType,...Mi(this.utmParameters)},rootDocument:this.rootDocument});return r.classList.add("ms-widget-content"),r}}const ee=class ee{static injectWidgetInto(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=De.getConfiguration({spotId:r.spotId,rootDocument:r.rootDocument,msCommunityWebBaseUrl:r.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widget:g,args:y}=ee.createWidget({...r,spotId:f,rootDocument:d,baseURL:_}),A=new Ir(g);return A.inject(o),ee.widgets.push(A),He.log("Widget injected",ee.cleanupLoggedArgs(y),o),A}static injectWidgetContentInto(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=De.getConfiguration({spotId:r.spotId,rootDocument:r.rootDocument,msCommunityWebBaseUrl:r.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widgetContent:g,args:y}=ee.createWidgetContent({...r,spotId:f,rootDocument:d,baseURL:_}),A=new Ir(g);return A.inject(o),ee.widgets.push(A),He.log("WidgetContent injected",ee.cleanupLoggedArgs(y),o),A}static bindWidgetModalTo(o,r){return ee.bindEntityModalTo(o,{type:"Widget",data:r})}static bindWidgetDrawerTo(o,r){return ee.bindEntityDrawerTo(o,{type:"Widget",data:r})}static createWidgetDrawer(o){const{widget:r}=ee.createWidget(o);return He.log("Create Widget drawer",{data:ee.cleanupLoggedArgs(o)}),new Ar(r,o.rootDocument??document)}static createWidgetModal(o){const{widget:r}=ee.createWidget(o);return He.log("Create Widget modal",{data:ee.cleanupLoggedArgs(o)}),new Rr(r,o.rootDocument??document)}static createWidgetEmbed(o){const{widget:r}=ee.createWidget(o),f=new Ir(r);return He.log("Create Widget embed",{data:ee.cleanupLoggedArgs(o)}),f}static clear(){ee.widgets.forEach(o=>{o.remove()}),ee.widgets=[],ee.widgetOptions={},He.log("All Widget SDK MeltingSpot elements were cleared")}static bindEntityDrawerTo(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=De.getConfiguration({spotId:r.data.spotId,rootDocument:r.data.rootDocument??document,msCommunityWebBaseUrl:r.data.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let g,y;switch(r.type){case"Widget":{const U=ee.createWidget({...r.data,spotId:f,rootDocument:d,baseURL:_});g=U.widget,y=U.args}break;case"WidgetContent":{const U=ee.createWidgetContent({...r.data,spotId:f,rootDocument:d,baseURL:_});g=U.widgetContent,y=U.args}}const A=new Ar(g,d),$={position:r.data.position},H=r.data.into??d.body;return A.inject({into:H,bind:o,options:$}),ee.widgets.push(A),He.log("Widget bound to drawer",ee.cleanupLoggedArgs(y),$,H,o),A}static bindEntityModalTo(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=De.getConfiguration({spotId:r.data.spotId,rootDocument:r.data.rootDocument??document,msCommunityWebBaseUrl:r.data.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let g,y;switch(r.type){case"Widget":{const H=ee.createWidget({...r.data,spotId:f,rootDocument:d,baseURL:_});g=H.widget,y=H.args}break;case"WidgetContent":{const H=ee.createWidgetContent({...r.data,spotId:f,rootDocument:d,baseURL:_});g=H.widgetContent,y=H.args}}const A=new Rr(g,d),$=r.data.into??d.body;return A.inject({into:$,bind:o}),ee.widgets.push(A),He.log("Widget bound to modal",ee.cleanupLoggedArgs(y),$,o),A}static handleMessageEvent(o){if(!o.data||typeof o.data!="object"||o.data.type!=="OpenWidgetContent")return;const r=o.data?.widgetId;if(!r||typeof r!="string"){He.error("widgetId is required in the message event data");return}const f=ee.widgetOptions[r];if(!f){He.error("No widget options found for widgetId",{widgetId:r});return}let d=null;try{d=new URL(f.baseURL).origin}catch{d=null}if(!d||o.origin!==d){He.warn("Ignoring OpenWidgetContent from unexpected origin",{origin:o.origin,expectedOrigin:d});return}const{spotId:_,rootDocument:g,msCommunityWebBaseUrl:y}=De.getConfiguration({spotId:f.spotId,rootDocument:f.rootDocument??document,msCommunityWebBaseUrl:f.baseURL}),{widgetContent:A}=ee.createWidgetContent({...f,widgetContentId:o.data.widgetContentId,contentType:o.data.contentType,contentId:o.data.contentId,widgetId:r,spotId:_,rootDocument:g,baseURL:y});o.data.openingIn==="Drawer"?new Ar(A,g).open():o.data.openingIn==="Modal"&&new Rr(A,g).open()}static createWidget(o){const r=new URLSearchParams(window.location.search),f={spotId:o.spotId,widgetId:o.widgetId,authToken:o.authToken,themeMode:o.themeMode,domain:o.domain,rootDocument:o.rootDocument,baseURL:o.baseURL,utmParameters:o.utmParameters??Oi(r)};return ee.widgetOptions[f.widgetId]=f,ee.messageListened||(window.addEventListener("message",ee.handleMessageEvent),ee.messageListened=!0),{widget:new xc(f),args:f}}static createWidgetContent(o){const r=new URLSearchParams(window.location.search),f={spotId:o.spotId,contentId:o.contentId,contentType:o.contentType,widgetContentId:o.widgetContentId,widgetId:o.widgetId,authToken:o.authToken,themeMode:o.themeMode,domain:o.domain,rootDocument:o.rootDocument,baseURL:o.baseURL,utmParameters:o.utmParameters??Oi(r)};return{widgetContent:new Dc(f),args:f}}static cleanupLoggedArgs(o){const{authToken:r,...f}=o;return{...f,authToken:r?"***":void 0}}};ee.widgets=[],ee.messageListened=!1,ee.widgetOptions={};let Lr=ee;const Ui=globalThis;Ui.MeltingSpot||(Ui.MeltingSpot={}),Ui.MeltingSpot.Widget=Lr,kt.Drawer=Ar,kt.Modal=Rr,kt.Widget=Lr,Object.defineProperty(kt,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "MeltingSpot Widget SDK",
|
|
4
4
|
"homepage": "https://meltingspot.io",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.5.1",
|
|
7
7
|
"main": "./index.cjs",
|
|
8
8
|
"module": "./index.mjs",
|
|
9
9
|
"typings": "./index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@meltingspot/core": "1.
|
|
25
|
-
"@meltingspot/embed": "1.
|
|
24
|
+
"@meltingspot/core": "1.5.1",
|
|
25
|
+
"@meltingspot/embed": "1.5.1"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"provenance": false
|