@meltingspot/widget 1.15.0 → 1.15.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 +10 -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,16 @@ Date: YYYY-MM-DD
|
|
|
15
15
|
|
|
16
16
|
-->
|
|
17
17
|
|
|
18
|
+
## v1.15.1
|
|
19
|
+
|
|
20
|
+
Date: 2026-10-06
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Bump `@meltingspot/core` and `@meltingspot/embed` to `1.15.1`.
|
|
25
|
+
- `baseURL` is optional again: when you leave it out, widgets load from
|
|
26
|
+
MeltingSpot by default instead of failing with `Invalid baseURL: undefined`.
|
|
27
|
+
|
|
18
28
|
## v1.15.0
|
|
19
29
|
|
|
20
30
|
Date: 2026-10-02
|
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@meltingspot/core"),t=require("@meltingspot/embed");var n=new e.Logger({appName:`Widget SDK`,appVersion:`1.15.
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@meltingspot/core"),t=require("@meltingspot/embed");var n=new e.Logger({appName:`Widget SDK`,appVersion:`1.15.1`}),r=class{constructor(e,t,n){this.content=e,this.rootDocument=t,this.dialogClassname=n,this.dialogElement=null,this.triggerElement=null,this.iframeElement=null,this.currentListener=null}inject({into:t,bind:n,options:r}){this.remove();let i=(0,e.getHTMLElement)({input:t,rootDocument:this.rootDocument});if(this.dialogElement=(0,e.createDialog)(this.rootDocument),this.dialogElement.classList.add(this.dialogClassname),this.dialogElement.onclose=()=>this.#t(),i.appendChild(this.dialogElement),n){this.triggerElement=(0,e.getHTMLElement)({input:n,rootDocument:this.rootDocument});let t=this.open.bind(this,r);this.currentListener=e=>{e.stopPropagation(),e.preventDefault(),t()},this.triggerElement.addEventListener(`click`,this.currentListener)}}remove(){this.dialogElement&&=(this.dialogElement.remove(),this.dialogElement.onclose=null,null),this.triggerElement&&(this.currentListener&&this.triggerElement.removeEventListener(`click`,this.currentListener),this.triggerElement=null,this.currentListener=null)}open(e){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(),null)}},i=class extends r{constructor(e,t){super(e,t,`ms-drawer`)}open(e){let{position:t=`right`}=e??{};super.open(e),this.dialogElement&&(this.dialogElement.dataset.position=t)}},a=class extends r{constructor(e,t){super(e,t,`ms-modal`)}},o=class{constructor(t){this.baseURL=(0,e.formatBaseUrl)(t.baseURL),this.spotId=(0,e.formatUUID)(t.spotId),this.widgetId=(0,e.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(){let t=new URL(`/widgets/spot/${this.spotId}/widget/${this.widgetId}`,(0,e.trimSlashRight)(this.baseURL)),n=(0,e.createIframe)({url:t,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,...(0,e.flattenUtmParameters)(this.utmParameters)},rootDocument:this.rootDocument});return n.classList.add(`ms-widget`),n}},s=class{constructor(t){this.baseURL=(0,e.formatBaseUrl)(t.baseURL),this.spotId=(0,e.formatUUID)(t.spotId),this.widgetContentId=(0,e.formatUUID)(t.widgetContentId),this.contentId=(0,e.formatUUID)(t.contentId),this.widgetId=(0,e.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(){let t=new URL(`/widgets/spot/${this.spotId}/widgetContent/${this.widgetContentId}`,(0,e.trimSlashRight)(this.baseURL));t.searchParams.set(`widgetId`,this.widgetId);let n=(0,e.createIframe)({url:t,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,contentId:this.contentId,contentType:this.contentType,...(0,e.flattenUtmParameters)(this.utmParameters)},rootDocument:this.rootDocument});return n.classList.add(`ms-widget-content`),n}},c=class r{static{this.widgets=[]}static{this.messageListened=!1}static{this.widgetOptions={}}static injectWidgetInto(i,a){let{spotId:o,rootDocument:s,msCommunityWebBaseUrl:c}=e.ConfigurationService.getConfiguration({spotId:a.spotId,rootDocument:a.rootDocument,msCommunityWebBaseUrl:a.baseURL});if(!o)throw n.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let{widget:l,args:u}=r.createWidget({...a,spotId:o,rootDocument:s,baseURL:c}),d=new t.EmbedFrame(l);return d.inject(i),r.widgets.push(d),n.log(`Widget injected`,r.cleanupLoggedArgs(u),i),d}static injectWidgetContentInto(i,a){let{spotId:o,rootDocument:s,msCommunityWebBaseUrl:c}=e.ConfigurationService.getConfiguration({spotId:a.spotId,rootDocument:a.rootDocument,msCommunityWebBaseUrl:a.baseURL});if(!o)throw n.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let{widgetContent:l,args:u}=r.createWidgetContent({...a,spotId:o,rootDocument:s,baseURL:c}),d=new t.EmbedFrame(l);return d.inject(i),r.widgets.push(d),n.log(`WidgetContent injected`,r.cleanupLoggedArgs(u),i),d}static bindWidgetModalTo(e,t){return r.bindEntityModalTo(e,{type:`Widget`,data:t})}static bindWidgetDrawerTo(e,t){return r.bindEntityDrawerTo(e,{type:`Widget`,data:t})}static createWidgetDrawer(e){let{widget:t}=r.createWidget(e);return n.log(`Create Widget drawer`,{data:r.cleanupLoggedArgs(e)}),new i(t,e.rootDocument??document)}static createWidgetModal(e){let{widget:t}=r.createWidget(e);return n.log(`Create Widget modal`,{data:r.cleanupLoggedArgs(e)}),new a(t,e.rootDocument??document)}static createWidgetEmbed(e){let{widget:i}=r.createWidget(e),a=new t.EmbedFrame(i);return n.log(`Create Widget embed`,{data:r.cleanupLoggedArgs(e)}),a}static clear(){r.widgets.forEach(e=>{e.remove()}),r.widgets=[],r.widgetOptions={},n.log(`All Widget SDK MeltingSpot elements were cleared`)}static bindEntityDrawerTo(t,a){let{spotId:o,rootDocument:s,msCommunityWebBaseUrl:c}=e.ConfigurationService.getConfiguration({spotId:a.data.spotId,rootDocument:a.data.rootDocument??document,msCommunityWebBaseUrl:a.data.baseURL});if(!o)throw n.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let l,u;switch(a.type){case`Widget`:{let e=r.createWidget({...a.data,spotId:o,rootDocument:s,baseURL:c});l=e.widget,u=e.args}break;case`WidgetContent`:{let e=r.createWidgetContent({...a.data,spotId:o,rootDocument:s,baseURL:c});l=e.widgetContent,u=e.args}}let d=new i(l,s),f={position:a.data.position},p=a.data.into??s.body;return d.inject({into:p,bind:t,options:f}),r.widgets.push(d),n.log(`Widget bound to drawer`,r.cleanupLoggedArgs(u),f,p,t),d}static bindEntityModalTo(t,i){let{spotId:o,rootDocument:s,msCommunityWebBaseUrl:c}=e.ConfigurationService.getConfiguration({spotId:i.data.spotId,rootDocument:i.data.rootDocument??document,msCommunityWebBaseUrl:i.data.baseURL});if(!o)throw n.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let l,u;switch(i.type){case`Widget`:{let e=r.createWidget({...i.data,spotId:o,rootDocument:s,baseURL:c});l=e.widget,u=e.args}break;case`WidgetContent`:{let e=r.createWidgetContent({...i.data,spotId:o,rootDocument:s,baseURL:c});l=e.widgetContent,u=e.args}}let d=new a(l,s),f=i.data.into??s.body;return d.inject({into:f,bind:t}),r.widgets.push(d),n.log(`Widget bound to modal`,r.cleanupLoggedArgs(u),f,t),d}static handleMessageEvent(t){if(!t.data||typeof t.data!=`object`||t.data.type!==`OpenWidgetContent`)return;let o=t.data?.widgetId;if(!o||typeof o!=`string`){n.error(`widgetId is required in the message event data`);return}let s=r.widgetOptions[o];if(!s){n.error(`No widget options found for widgetId`,{widgetId:o});return}let c=null;try{c=new URL(s.baseURL).origin}catch{c=null}if(!c||t.origin!==c){n.warn(`Ignoring OpenWidgetContent from unexpected origin`,{origin:t.origin,expectedOrigin:c});return}let{spotId:l,rootDocument:u,msCommunityWebBaseUrl:d}=e.ConfigurationService.getConfiguration({spotId:s.spotId,rootDocument:s.rootDocument??document,msCommunityWebBaseUrl:s.baseURL}),{widgetContent:f}=r.createWidgetContent({...s,widgetContentId:t.data.widgetContentId,contentType:t.data.contentType,contentId:t.data.contentId,widgetId:o,spotId:l,rootDocument:u,baseURL:d});t.data.openingIn===`Drawer`?new i(f,u).open():t.data.openingIn===`Modal`&&new a(f,u).open()}static createWidget(t){let n=new URLSearchParams(window.location.search),i={spotId:t.spotId,widgetId:t.widgetId,authToken:t.authToken,themeMode:t.themeMode,domain:t.domain,rootDocument:t.rootDocument,baseURL:t.baseURL,utmParameters:t.utmParameters??(0,e.parseUtmParameters)(n)};return r.widgetOptions[i.widgetId]=i,r.messageListened||=(window.addEventListener(`message`,r.handleMessageEvent),!0),{widget:new o(i),args:i}}static createWidgetContent(t){let n=new URLSearchParams(window.location.search),r={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??(0,e.parseUtmParameters)(n)};return{widgetContent:new s(r),args:r}}static cleanupLoggedArgs(e){let{authToken:t,...n}=e;return{...n,authToken:t?`***`:void 0}}},l=globalThis;l.MeltingSpot||={},l.MeltingSpot.Widget=c,exports.Drawer=i,exports.Modal=a,exports.Widget=c;
|
package/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { EmbedFrame as u } from "@meltingspot/embed";
|
|
|
4
4
|
//#region src/logger.ts
|
|
5
5
|
var d = new t({
|
|
6
6
|
appName: "Widget SDK",
|
|
7
|
-
appVersion: "1.15.
|
|
7
|
+
appVersion: "1.15.1"
|
|
8
8
|
}), f = class {
|
|
9
9
|
constructor(e, t, n) {
|
|
10
10
|
this.content = e, this.rootDocument = t, this.dialogClassname = n, this.dialogElement = null, this.triggerElement = null, this.iframeElement = null, this.currentListener = null;
|
package/index.standalone.js
CHANGED
|
@@ -30,4 +30,4 @@ __p += '`),r&&(f+=`' +
|
|
|
30
30
|
function print() { __p += __j.call(arguments, '') }
|
|
31
31
|
`:`;
|
|
32
32
|
`)+f+`return __p
|
|
33
|
-
}`;var g=af(function(){return ot(o,m+`return `+f).apply(n,s)});if(g.source=f,ou(g))throw g;return g}function Jd(e){return Q(e).toLowerCase()}function Yd(e){return Q(e).toUpperCase()}function Xd(e,t,r){if(e=Q(e),e&&(r||t===n))return Rn(e);if(!e||!(t=wa(t)))return e;var i=or(e),a=or(t);return Ia(i,Hn(i,a),Un(i,a)+1).join(``)}function Zd(e,t,r){if(e=Q(e),e&&(r||t===n))return e.slice(0,sr(e)+1);if(!e||!(t=wa(t)))return e;var i=or(e);return Ia(i,0,Un(i,or(t))+1).join(``)}function Qd(e,t,r){if(e=Q(e),e&&(r||t===n))return e.replace(Ue,``);if(!e||!(t=wa(t)))return e;var i=or(e);return Ia(i,Hn(i,or(t))).join(``)}function $d(e,t){var r=30,i=`...`;if(Y(t)){var a=`separator`in t?t.separator:a;r=`length`in t?Z(t.length):r,i=`omission`in t?wa(t.omission):i}e=Q(e);var o=e.length;if(Yn(e)){var s=or(e);o=s.length}if(r>=o)return e;var c=r-ar(i);if(c<1)return i;var l=s?Ia(s,0,c).join(``):e.slice(0,c);if(a===n)return l+i;if(s&&(c+=l.length-c),bu(a)){if(e.slice(c).search(a)){var u,d=l;for(a.global||(a=ct(a.source,Q(Ze.exec(a))+`g`)),a.lastIndex=0;u=a.exec(d);)var f=u.index;l=l.slice(0,f===n?c:f)}}else if(e.indexOf(wa(a),c)!=c){var p=l.lastIndexOf(a);p>-1&&(l=l.slice(0,p))}return l+i}function ef(e){return e=Q(e),e&&Ne.test(e)?e.replace(je,cr):e}var tf=io(function(e,t,n){return e+(n?` `:``)+t.toUpperCase()}),nf=ro(`toUpperCase`);function rf(e,t,r){return e=Q(e),t=r?n:t,t===n?Xn(e)?dr(e):wn(e):e.match(t)||[]}var af=W(function(e,t){try{return un(e,n,t)}catch(e){return ou(e)?e:new at(e)}}),of=ko(function(e,t){return fn(t,function(t){t=bs(t),si(e,t,xl(e[t],e))}),e});function sf(e){var t=e==null?0:e.length,n=G();return e=t?B(e,function(e){if(typeof e[1]!=`function`)throw new ut(r);return[n(e[0]),e[1]]}):[],W(function(n){for(var r=-1;++r<t;){var i=e[r];if(un(i[0],this,n))return un(i[1],this,n)}})}function cf(e){return di(ui(e,1))}function lf(e){return function(){return e}}function uf(e,t){return e==null||e!==e?t:e}var df=co(),ff=co(!0);function pf(e){return e}function mf(e){return qi(typeof e==`function`?e:ui(e,1))}function hf(e){return Qi(ui(e,1))}function gf(e,t){return $i(e,ui(t,1))}var _f=W(function(e,t){return function(n){return Fi(n,e,t)}}),vf=W(function(e,t){return function(n){return Fi(e,n,t)}});function yf(e,t,n){var r=$(t),i=Ti(t,r);n==null&&!(Y(t)&&(i.length||!r.length))&&(n=t,t=e,e=this,i=Ti(t,$(t)));var a=!(Y(n)&&`chain`in n)||!!n.chain,o=cu(e);return fn(i,function(n){var r=t[n];e[n]=r,o&&(e.prototype[n]=function(){var t=this.__chain__;if(a||t){var n=e(this.__wrapped__);return(n.__actions__=Ja(this.__actions__)).push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,vn([this.value()],arguments))})}),e}function bf(){return R._===this&&(R._=vt),this}function xf(){}function Sf(e){return e=Z(e),W(function(t){return na(t,e)})}var Cf=po(B),wf=po(mn),Tf=po(xn);function Ef(e){return Zo(e)?jn(bs(e)):oa(e)}function Df(e){return function(t){return e==null?n:Ei(e,t)}}var Of=go(),kf=go(!0);function Af(){return[]}function jf(){return!1}function Mf(){return{}}function Nf(){return``}function Pf(){return!0}function Ff(e,t){if(e=Z(e),e<1||e>g)return[];var n=y,r=L(e,y);t=G(t),e-=y;for(var i=In(r,t);++n<e;)t(n);return i}function If(e){return q(e)?B(e,bs):wu(e)?[e]:Ja(ys(Q(e)))}function Lf(e){var t=++mt;return Q(e)+t}var Rf=fo(function(e,t){return e+t},0),zf=yo(`ceil`),Bf=fo(function(e,t){return e/t},1),Vf=yo(`floor`);function Hf(e){return e&&e.length?vi(e,pf,ki):n}function Uf(e,t){return e&&e.length?vi(e,G(t,2),ki):n}function Wf(e){return An(e,pf)}function Gf(e,t){return An(e,G(t,2))}function Kf(e){return e&&e.length?vi(e,pf,Xi):n}function qf(e,t){return e&&e.length?vi(e,G(t,2),Xi):n}var Jf=fo(function(e,t){return e*t},1),Yf=yo(`round`),Xf=fo(function(e,t){return e-t},0);function Zf(e){return e&&e.length?Fn(e,pf):0}function Qf(e,t){return e&&e.length?Fn(e,G(t,2)):0}return V.after=vl,V.ary=yl,V.assign=Lu,V.assignIn=Ru,V.assignInWith=zu,V.assignWith=Bu,V.at=Vu,V.before=bl,V.bind=xl,V.bindAll=of,V.bindKey=Sl,V.castArray=Vl,V.chain=Pc,V.chunk=ws,V.compact=Ts,V.concat=Es,V.cond=sf,V.conforms=cf,V.constant=lf,V.countBy=Gc,V.create=Hu,V.curry=Cl,V.curryRight=wl,V.debounce=Tl,V.defaults=Uu,V.defaultsDeep=Wu,V.defer=El,V.delay=Dl,V.difference=Ds,V.differenceBy=Os,V.differenceWith=ks,V.drop=As,V.dropRight=js,V.dropRightWhile=Ms,V.dropWhile=Ns,V.fill=Ps,V.filter=qc,V.flatMap=Xc,V.flatMapDeep=Zc,V.flatMapDepth=Qc,V.flatten=Ls,V.flattenDeep=Rs,V.flattenDepth=zs,V.flip=Ol,V.flow=df,V.flowRight=ff,V.fromPairs=Bs,V.functions=Zu,V.functionsIn=Qu,V.groupBy=tl,V.initial=Us,V.intersection=Ws,V.intersectionBy=Gs,V.intersectionWith=Ks,V.invert=nd,V.invertBy=rd,V.invokeMap=rl,V.iteratee=mf,V.keyBy=il,V.keys=$,V.keysIn=ad,V.map=al,V.mapKeys=od,V.mapValues=sd,V.matches=hf,V.matchesProperty=gf,V.memoize=kl,V.merge=cd,V.mergeWith=ld,V.method=_f,V.methodOf=vf,V.mixin=yf,V.negate=Al,V.nthArg=Sf,V.omit=ud,V.omitBy=dd,V.once=jl,V.orderBy=ol,V.over=Cf,V.overArgs=Ml,V.overEvery=wf,V.overSome=Tf,V.partial=Nl,V.partialRight=Pl,V.partition=sl,V.pick=fd,V.pickBy=pd,V.property=Ef,V.propertyOf=Df,V.pull=Zs,V.pullAll=Qs,V.pullAllBy=$s,V.pullAllWith=ec,V.pullAt=tc,V.range=Of,V.rangeRight=kf,V.rearg=Fl,V.reject=ul,V.remove=nc,V.rest=Il,V.reverse=rc,V.sampleSize=fl,V.set=hd,V.setWith=gd,V.shuffle=pl,V.slice=ic,V.sortBy=gl,V.sortedUniq=dc,V.sortedUniqBy=fc,V.split=Wd,V.spread=Ll,V.tail=pc,V.take=mc,V.takeRight=hc,V.takeRightWhile=gc,V.takeWhile=_c,V.tap=Fc,V.throttle=Rl,V.thru=Ic,V.toArray=ju,V.toPairs=_d,V.toPairsIn=vd,V.toPath=If,V.toPlainObject=Fu,V.transform=yd,V.unary=zl,V.union=vc,V.unionBy=yc,V.unionWith=bc,V.uniq=xc,V.uniqBy=Sc,V.uniqWith=Cc,V.unset=bd,V.unzip=wc,V.unzipWith=Tc,V.update=xd,V.updateWith=Sd,V.values=Cd,V.valuesIn=wd,V.without=Ec,V.words=rf,V.wrap=Bl,V.xor=Dc,V.xorBy=Oc,V.xorWith=kc,V.zip=Ac,V.zipObject=jc,V.zipObjectDeep=Mc,V.zipWith=Nc,V.entries=_d,V.entriesIn=vd,V.extend=Ru,V.extendWith=zu,yf(V,V),V.add=Rf,V.attempt=af,V.camelCase=Od,V.capitalize=kd,V.ceil=zf,V.clamp=Td,V.clone=Hl,V.cloneDeep=Wl,V.cloneDeepWith=Gl,V.cloneWith=Ul,V.conformsTo=Kl,V.deburr=Ad,V.defaultTo=uf,V.divide=Bf,V.endsWith=jd,V.eq=ql,V.escape=Md,V.escapeRegExp=Nd,V.every=Kc,V.find=Jc,V.findIndex=Fs,V.findKey=Gu,V.findLast=Yc,V.findLastIndex=Is,V.findLastKey=Ku,V.floor=Vf,V.forEach=$c,V.forEachRight=el,V.forIn=qu,V.forInRight=Ju,V.forOwn=Yu,V.forOwnRight=Xu,V.get=$u,V.gt=Jl,V.gte=Yl,V.has=ed,V.hasIn=td,V.head=Vs,V.identity=pf,V.includes=nl,V.indexOf=Hs,V.inRange=Ed,V.invoke=id,V.isArguments=Xl,V.isArray=q,V.isArrayBuffer=Zl,V.isArrayLike=Ql,V.isArrayLikeObject=J,V.isBoolean=$l,V.isBuffer=eu,V.isDate=tu,V.isElement=nu,V.isEmpty=ru,V.isEqual=iu,V.isEqualWith=au,V.isError=ou,V.isFinite=su,V.isFunction=cu,V.isInteger=lu,V.isLength=uu,V.isMap=du,V.isMatch=fu,V.isMatchWith=pu,V.isNaN=mu,V.isNative=hu,V.isNil=_u,V.isNull=gu,V.isNumber=vu,V.isObject=Y,V.isObjectLike=X,V.isPlainObject=yu,V.isRegExp=bu,V.isSafeInteger=xu,V.isSet=Su,V.isString=Cu,V.isSymbol=wu,V.isTypedArray=Tu,V.isUndefined=Eu,V.isWeakMap=Du,V.isWeakSet=Ou,V.join=qs,V.kebabCase=Pd,V.last=Js,V.lastIndexOf=Ys,V.lowerCase=Fd,V.lowerFirst=Id,V.lt=ku,V.lte=Au,V.max=Hf,V.maxBy=Uf,V.mean=Wf,V.meanBy=Gf,V.min=Kf,V.minBy=qf,V.stubArray=Af,V.stubFalse=jf,V.stubObject=Mf,V.stubString=Nf,V.stubTrue=Pf,V.multiply=Jf,V.nth=Xs,V.noConflict=bf,V.noop=xf,V.now=_l,V.pad=Ld,V.padEnd=Rd,V.padStart=zd,V.parseInt=Bd,V.random=Dd,V.reduce=cl,V.reduceRight=ll,V.repeat=Vd,V.replace=Hd,V.result=md,V.round=Yf,V.runInContext=e,V.sample=dl,V.size=ml,V.snakeCase=Ud,V.some=hl,V.sortedIndex=ac,V.sortedIndexBy=oc,V.sortedIndexOf=sc,V.sortedLastIndex=cc,V.sortedLastIndexBy=lc,V.sortedLastIndexOf=uc,V.startCase=Gd,V.startsWith=Kd,V.subtract=Xf,V.sum=Zf,V.sumBy=Qf,V.template=qd,V.times=Ff,V.toFinite=Mu,V.toInteger=Z,V.toLength=Nu,V.toLower=Jd,V.toNumber=Pu,V.toSafeInteger=Iu,V.toString=Q,V.toUpper=Yd,V.trim=Xd,V.trimEnd=Zd,V.trimStart=Qd,V.truncate=$d,V.unescape=ef,V.uniqueId=Lf,V.upperCase=tf,V.upperFirst=nf,V.each=$c,V.eachRight=el,V.first=Vs,yf(V,function(){var e={};return Ci(V,function(t,n){N.call(V.prototype,n)||(e[n]=t)}),e}(),{chain:!1}),V.VERSION=`4.17.21`,fn([`bind`,`bindKey`,`curry`,`curryRight`,`partial`,`partialRight`],function(e){V[e].placeholder=V}),fn([`drop`,`take`],function(e,t){H.prototype[e]=function(r){r=r===n?1:P(Z(r),0);var i=this.__filtered__&&!t?new H(this):this.clone();return i.__filtered__?i.__takeCount__=L(r,i.__takeCount__):i.__views__.push({size:L(r,y),type:e+(i.__dir__<0?`Right`:``)}),i},H.prototype[e+`Right`]=function(t){return this.reverse()[e](t).reverse()}}),fn([`filter`,`map`,`takeWhile`],function(e,t){var n=t+1,r=n==1||n==3;H.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:G(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}}),fn([`head`,`last`],function(e,t){var n=`take`+(t?`Right`:``);H.prototype[e]=function(){return this[n](1).value()[0]}}),fn([`initial`,`tail`],function(e,t){var n=`drop`+(t?``:`Right`);H.prototype[e]=function(){return this.__filtered__?new H(this):this[n](1)}}),H.prototype.compact=function(){return this.filter(pf)},H.prototype.find=function(e){return this.filter(e).head()},H.prototype.findLast=function(e){return this.reverse().find(e)},H.prototype.invokeMap=W(function(e,t){return typeof e==`function`?new H(this):this.map(function(n){return Fi(n,e,t)})}),H.prototype.reject=function(e){return this.filter(Al(G(e)))},H.prototype.slice=function(e,t){e=Z(e);var r=this;return r.__filtered__&&(e>0||t<0)?new H(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(t=Z(t),r=t<0?r.dropRight(-t):r.take(t-e)),r)},H.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},H.prototype.toArray=function(){return this.take(y)},Ci(H.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=V[i?`take`+(t==`last`?`Right`:``):t],o=i||/^find/.test(t);a&&(V.prototype[t]=function(){var t=this.__wrapped__,s=i?[1]:arguments,c=t instanceof H,l=s[0],u=c||q(t),d=function(e){var t=a.apply(V,vn([e],s));return i&&f?t[0]:t};u&&r&&typeof l==`function`&&l.length!=1&&(c=u=!1);var f=this.__chain__,p=!!this.__actions__.length,m=o&&!f,h=c&&!p;if(!o&&u){t=h?t:new H(this);var g=e.apply(t,s);return g.__actions__.push({func:Ic,args:[d],thisArg:n}),new br(g,f)}return m&&h?e.apply(this,s):(g=this.thru(d),m?i?g.value()[0]:g.value():g)})}),fn([`pop`,`push`,`shift`,`sort`,`splice`,`unshift`],function(e){var t=j[e],n=/^(?:push|sort|unshift)$/.test(e)?`tap`:`thru`,r=/^(?:pop|shift)$/.test(e);V.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(q(i)?i:[],e)}return this[n](function(n){return t.apply(q(n)?n:[],e)})}}),Ci(H.prototype,function(e,t){var n=V[t];if(n){var r=n.name+``;N.call(Mn,r)||(Mn[r]=[]),Mn[r].push({name:t,func:n})}}),Mn[lo(n,s).name]=[{name:`wrapper`,func:n}],H.prototype.clone=xr,H.prototype.reverse=Sr,H.prototype.value=Cr,V.prototype.at=Lc,V.prototype.chain=Rc,V.prototype.commit=zc,V.prototype.next=Bc,V.prototype.plant=Hc,V.prototype.reverse=Uc,V.prototype.toJSON=V.prototype.valueOf=V.prototype.value=Wc,V.prototype.first=V.prototype.head,kt&&(V.prototype[kt]=Vc),V})();typeof define==`function`&&typeof define.amd==`object`&&define.amd?(R._=fr,define(function(){return fr})):en?((en.exports=fr)._=fr,$t._=fr):R._=fr}).call(e)}))(),Object.values(function(e){return e.EditMode=`edit-mode`,e.Preview=`preview`,e}({}));var ke=`1.15.0`,Ae=class{constructor(e){this.debug=!1,this.debug=e?.debug??!1,this.appName=e?.appName,this.appVersion=e?.appVersion}log(e,...t){this.debug&&this.print(e,`info`,t)}warn(e,...t){this.print(e,`warn`,t)}error(e,...t){this.print(e,`error`,t)}print(e,t,n){let r=[`[${[`MeltingSpot`,this.appName,this.appVersion].filter(Boolean).join(` - `)}] ${e}`];n.length&&r.push(...n),console[t](...r)}},je=new Ae({appName:`Core SDK`,appVersion:ke}),Me=e=>e.toLowerCase().replace(/[^a-z0-9-]/g,``),Ne=[`/user`],Pe=({deeplink:e,spotId:t})=>{try{let n=new URL(e,`https://unused.com`),r=n.pathname;return n.search&&(r+=n.search),n.hash&&(r+=n.hash),Ne.some(e=>r.startsWith(e))||(r=`/spot/${t}/${ie(r)}`),r}catch(e){return je.warn(`Failed to parse deeplink URL`,e),null}},Fe=[/(^|\.)meltingspot\.io$/i],Ie=e=>{let t;try{let n=oe(e);t=new URL(n)}catch{throw Error(`Invalid baseURL: ${e}`)}let n=t.hostname===`localhost`||t.hostname===`127.0.0.1`,r=t.protocol===`https:`,i=Fe.some(e=>e.test(t.hostname));if(!n&&(!r||!i))throw Error(`Untrusted baseURL origin: ${t.origin}`);return t.origin},Le={msApiBaseUrl:`https://openapi.meltingspot.io/`,msCommunityWebBaseUrl:`https://go.meltingspot.io/`,ssoToken:void 0,spotId:``,autoJoin:!1,rootDocument:globalThis.document},Re=class e{constructor(){this.configuration=Le}static getInstance(){return e.instance||=new e,e.instance}setConfiguration(e){this.configuration={...this.configuration,...e}}static getConfiguration(t={}){return{...e.getInstance().configuration,...t}}},ze=RegExp(`(%[a-f0-9]{2})|([^%]+?)`,`gi`),Be=RegExp(`(%[a-f0-9]{2})+`,`gi`);function Ve(e,t){try{return[decodeURIComponent(e.join(``))]}catch{}if(e.length===1)return e;t||=1;let n=e.slice(0,t),r=e.slice(t);return Array.prototype.concat.call([],Ve(n),Ve(r))}function He(e){try{return decodeURIComponent(e)}catch{let t=e.match(ze)||[];for(let n=1;n<t.length;n++)e=Ve(t,n).join(``),t=e.match(ze)||[];return e}}function Ue(e){let t={"%FE%FF":`��`,"%FF%FE":`��`},n=Be.exec(e);for(;n;){try{t[n[0]]=decodeURIComponent(n[0])}catch{let e=He(n[0]);e!==n[0]&&(t[n[0]]=e)}n=Be.exec(e)}t[`%C2`]=`�`;let r=Object.keys(t);for(let n of r)e=e.replace(new RegExp(n,`g`),t[n]);return e}function O(e){if(typeof e!=`string`)throw TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return decodeURIComponent(e)}catch{return Ue(e)}}function We(e,t){let n={};if(Array.isArray(t))for(let r of t){let t=Object.getOwnPropertyDescriptor(e,r);t?.enumerable&&Object.defineProperty(n,r,t)}else for(let r of Reflect.ownKeys(e)){let i=Object.getOwnPropertyDescriptor(e,r);if(i.enumerable){let a=e[r];t(r,a,e)&&Object.defineProperty(n,r,i)}}return n}function Ge(e,t){if(typeof e!=`string`||typeof t!=`string`)throw TypeError("Expected the arguments to be of type `string`");if(e===``||t===``)return[];let n=e.indexOf(t);return n===-1?[]:[e.slice(0,n),e.slice(n+t.length)]}var Ke=c({exclude:()=>lt,extract:()=>it,parse:()=>at,parseUrl:()=>st,pick:()=>ct,stringify:()=>ot,stringifyUrl:()=>A}),qe=e=>e==null,Je=e=>encodeURIComponent(e).replaceAll(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Ye=Symbol(`encodeFragmentIdentifier`);function Xe(e){switch(e.arrayFormat){case`index`:return t=>(n,r)=>{let i=n.length;return r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[k(t,e),`[`,i,`]`].join(``)]:[...n,[k(t,e),`[`,k(i,e),`]=`,k(r,e)].join(``)]};case`bracket`:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[k(t,e),`[]`].join(``)]:[...n,[k(t,e),`[]=`,k(r,e)].join(``)];case`colon-list-separator`:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[k(t,e),`:list=`].join(``)]:[...n,[k(t,e),`:list=`,k(r,e)].join(``)];case`comma`:case`separator`:case`bracket-separator`:{let t=e.arrayFormat===`bracket-separator`?`[]=`:`=`;return n=>(r,i)=>i===void 0||e.skipNull&&i===null||e.skipEmptyString&&i===``?r:(i=i===null?``:i,r.length===0?[[k(n,e),t,k(i,e)].join(``)]:[[r,k(i,e)].join(e.arrayFormatSeparator)])}default:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,k(t,e)]:[...n,[k(t,e),`=`,k(r,e)].join(``)]}}function Ze(e){let t;switch(e.arrayFormat){case`index`:return(e,n,r)=>{if(t=/\[(\d*)]$/.exec(e),e=e.replace(/\[\d*]$/,``),!t){r[e]=n;return}r[e]===void 0&&(r[e]={}),r[e][t[1]]=n};case`bracket`:return(e,n,r)=>{if(t=/(\[])$/.exec(e),e=e.replace(/\[]$/,``),!t){r[e]=n;return}if(r[e]===void 0){r[e]=[n];return}r[e]=[...r[e],n]};case`colon-list-separator`:return(e,n,r)=>{if(t=/(:list)$/.exec(e),e=e.replace(/:list$/,``),!t){r[e]=n;return}if(r[e]===void 0){r[e]=[n];return}r[e]=[...r[e],n]};case`comma`:case`separator`:return(t,n,r)=>{let i=typeof n==`string`&&n.includes(e.arrayFormatSeparator),a=typeof n==`string`&&!i&&$e(n,e).includes(e.arrayFormatSeparator);n=a?$e(n,e):n,r[t]=i||a?n.split(e.arrayFormatSeparator).map(t=>$e(t,e)):n===null?n:$e(n,e)};case`bracket-separator`:return(t,n,r)=>{let i=/(\[])$/.test(t);if(t=t.replace(/\[]$/,``),!i){r[t]=n&&$e(n,e);return}let a=n===null?[]:$e(n,e).split(e.arrayFormatSeparator);if(r[t]===void 0){r[t]=a;return}r[t]=[...r[t],...a]};default:return(e,t,n)=>{if(n[e]===void 0){n[e]=t;return}n[e]=[...[n[e]].flat(),t]}}}function Qe(e){if(typeof e!=`string`||e.length!==1)throw TypeError(`arrayFormatSeparator must be single character string`)}function k(e,t){return t.encode?t.strict?Je(e):encodeURIComponent(e):e}function $e(e,t){return t.decode?O(e):e}function et(e){return Array.isArray(e)?e.sort():typeof e==`object`?et(Object.keys(e)).sort((e,t)=>Number(e)-Number(t)).map(t=>e[t]):e}function tt(e){let t=e.indexOf(`#`);return t!==-1&&(e=e.slice(0,t)),e}function nt(e){let t=``,n=e.indexOf(`#`);return n!==-1&&(t=e.slice(n)),t}function rt(e,t,n){return n===`string`&&typeof e==`string`?e:typeof n==`function`&&typeof e==`string`?n(e):n===`boolean`&&e===null?!0:n===`boolean`&&e!==null&&(e.toLowerCase()===`true`||e.toLowerCase()===`false`)?e.toLowerCase()===`true`:n===`boolean`&&e!==null&&(e.toLowerCase()===`1`||e.toLowerCase()===`0`)?e.toLowerCase()===`1`:n===`string[]`&&t.arrayFormat!==`none`&&typeof e==`string`?[e]:n===`number[]`&&t.arrayFormat!==`none`&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?[Number(e)]:n===`number`&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?Number(e):t.parseBooleans&&e!==null&&(e.toLowerCase()===`true`||e.toLowerCase()===`false`)?e.toLowerCase()===`true`:t.parseNumbers&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?Number(e):e}function it(e){e=tt(e);let t=e.indexOf(`?`);return t===-1?``:e.slice(t+1)}function at(e,t){t={decode:!0,sort:!0,arrayFormat:`none`,arrayFormatSeparator:`,`,parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...t},Qe(t.arrayFormatSeparator);let n=Ze(t),r=Object.create(null);if(typeof e!=`string`||(e=e.trim().replace(/^[?#&]/,``),!e))return r;for(let i of e.split(`&`)){if(i===``)continue;let e=t.decode?i.replaceAll(`+`,` `):i,[a,o]=Ge(e,`=`);a===void 0&&(a=e),o=o===void 0?null:[`comma`,`separator`,`bracket-separator`].includes(t.arrayFormat)?o:$e(o,t),n($e(a,t),o,r)}for(let[e,n]of Object.entries(r))if(typeof n==`object`&&n&&t.types[e]!==`string`)for(let[r,i]of Object.entries(n)){let a=t.types[e]?t.types[e].replace(`[]`,``):void 0;n[r]=rt(i,t,a)}else r[e]=typeof n==`object`&&n&&t.types[e]===`string`?Object.values(n).join(t.arrayFormatSeparator):rt(n,t,t.types[e]);return t.sort===!1?r:(t.sort===!0?Object.keys(r).sort():Object.keys(r).sort(t.sort)).reduce((e,t)=>{let n=r[t];return e[t]=n&&typeof n==`object`&&!Array.isArray(n)?et(n):n,e},Object.create(null))}function ot(e,t){if(!e)return``;t={encode:!0,strict:!0,arrayFormat:`none`,arrayFormatSeparator:`,`,...t},Qe(t.arrayFormatSeparator);let n=n=>t.skipNull&&qe(e[n])||t.skipEmptyString&&e[n]===``,r=Xe(t),i={};for(let[t,r]of Object.entries(e))n(t)||(i[t]=r);let a=Object.keys(i);return t.sort!==!1&&a.sort(t.sort),a.map(n=>{let i=e[n];return i===void 0?``:i===null?k(n,t):Array.isArray(i)?i.length===0&&t.arrayFormat===`bracket-separator`?k(n,t)+`[]`:i.reduce(r(n),[]).join(`&`):k(n,t)+`=`+k(i,t)}).filter(e=>e.length>0).join(`&`)}function st(e,t){t={decode:!0,...t};let[n,r]=Ge(e,`#`);return n===void 0&&(n=e),{url:n?.split(`?`)?.[0]??``,query:at(it(e),t),...t&&t.parseFragmentIdentifier&&r?{fragmentIdentifier:$e(r,t)}:{}}}function A(e,t){t={encode:!0,strict:!0,[Ye]:!0,...t};let n=tt(e.url).split(`?`)[0]||``,r=ot({...at(it(e.url),{sort:!1,...t}),...e.query},t);r&&=`?${r}`;let i=nt(e.url);if(typeof e.fragmentIdentifier==`string`){let r=new URL(n);r.hash=e.fragmentIdentifier,i=t[Ye]?r.hash:`#${e.fragmentIdentifier}`}return`${n}${r}${i}`}function ct(e,t,n){n={parseFragmentIdentifier:!0,[Ye]:!1,...n};let{url:r,query:i,fragmentIdentifier:a}=st(e,n);return A({url:r,query:We(i,t),fragmentIdentifier:a},n)}function lt(e,t,n){return ct(e,Array.isArray(t)?e=>!t.includes(e):(e,n)=>!t(e,n),n)}var ut=Ke,j=class e extends Error{constructor(t,n){super(`HTTP Error ${t}${n?`: ${n}`:``}`),this.code=t,this.name=`HttpError`,Object.setPrototypeOf(this,e.prototype)}},M=function(e){return e.DELETE=`DELETE`,e.GET=`GET`,e.PATCH=`PATCH`,e.POST=`POST`,e}({}),dt=class e{constructor(){this.headers={}}setHeaders(e){this.headers=e}async get(t){try{let n=t.query?`${t.url}?${this.serializeQuery(t.query)}`:t.url,r=await fetch(n,{headers:{...this.headers,...t.headers,"Content-Type":`application/json`},...t.signal?{signal:t.signal}:{}});return r.ok?T(await e.parseBody(r)):E(new j(r.status,await r.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new j(D.INTERNAL_SERVER_ERROR,t))}}async post(t){try{let n=await fetch(t.url,{method:`POST`,headers:{...this.headers,...t.headers,"Content-Type":`application/json`},body:JSON.stringify(t.payload),...t.signal?{signal:t.signal}:{}});return n.ok?T(await e.parseBody(n)):E(new j(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new j(D.INTERNAL_SERVER_ERROR,t))}}async delete(t){try{let n=await fetch(t.url,{method:`DELETE`,headers:{...this.headers,...t.headers,Accept:`application/json`},...t.signal?{signal:t.signal}:{}});return n.ok?T(await e.parseBody(n)):E(new j(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new j(D.INTERNAL_SERVER_ERROR,t))}}async patch(t){try{let n=await fetch(t.url,{method:`PATCH`,headers:{...this.headers,...t.headers,"Content-Type":`application/json`},body:JSON.stringify(t.payload),...t.signal?{signal:t.signal}:{}});return n.ok?T(await e.parseBody(n)):E(new j(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new j(D.INTERNAL_SERVER_ERROR,t))}}static async parseBody(e){if(e.status!==D.NO_CONTENT)return await e.json()}serializeQuery(e){if(typeof e==`string`)return e;if(typeof e==`object`)for(let t in e)e[t]===void 0&&delete e[t];return e=ut.stringify(e,{arrayFormat:`none`}),e}},ft={accessToken:{email:`/v1/auth/accessToken/email`,sso:{jwt:`/v1/auth/accessToken/sso/jwt`}},refreshAccessToken:`/v1/auth/accessToken~refresh`,password:{reset:`/v1/auth/password~reset`}},pt=class e extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return e.instance||=new e,e.instance}async loginWithPassword(e,t){let n=await this.callApi({endpoint:ft.accessToken.email,method:`POST`,body:{email:e,password:t},withSpotId:!0});if(n.isErr())return E(n.error);let{accessToken:r,refreshToken:i}=n.value;return this.setTokens(r.token,i.token),T({accessToken:r.token,refreshToken:i.token})}async loginWithSsoToken(e){let t=await this.callApi({endpoint:ft.accessToken.sso.jwt,method:`POST`,body:{token:e},withSpotId:!0});if(t.isErr())return E(t.error);let{accessToken:n,refreshToken:r}=t.value;return this.setTokens(n.token,r.token),T({accessToken:n.token,refreshToken:r.token})}loginWithAuthTokens(e,t){return this.setTokens(e,t),{accessToken:e,refreshToken:t}}resetPassword(e){return this.callApi({endpoint:ft.password.reset,method:`POST`,body:{email:e}})}async refresh(){let e=await this.callApi({endpoint:ft.refreshAccessToken,method:`POST`,body:{refreshToken:this.refreshToken}});if(e.isErr())return E(e.error);let{accessToken:t,refreshToken:n}=e.value;return this.setTokens(t.token,n.token),T({accessToken:t.token,refreshToken:n.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(e,t){if(this.accessToken!==e||this.refreshToken!==t){this.accessToken=e,this.refreshToken=t;let n=new CustomEvent(`auth:tokens-updated`,{detail:{accessToken:e,refreshToken:t}});this.dispatchEvent(n)}}async callApi(e){try{let{spotId:t,msApiBaseUrl:n}=Re.getConfiguration(),r=se(e.endpoint,n),i={"Content-Type":`application/json`,...e.headers};e.withSpotId&&t&&(i[N.SpotId]=t);let a=await fetch(r,{method:e.method,body:e.body?JSON.stringify(e.body):void 0,headers:i});return a.ok?a.status===D.NO_CONTENT?T(void 0):T(await a.json()):E(new j(a.status,a.statusText))}catch(e){return E(new j(D.INTERNAL_SERVER_ERROR,e instanceof Error?e.message:String(e)))}}},N=function(e){return e.Authorization=`Authorization`,e.SpotId=`x-spotid`,e}({}),mt=class e{static getInstance(){return e.instance||=new e,e.instance}static buildAuthenticatedRequest(e){let{msApiBaseUrl:t,spotId:n}=Re.getConfiguration(),r=se(e,t),i=pt.getInstance().getAccessToken();if(!i)return E(Error(`Not authenticated`));let a={"Content-Type":`application/json`,Authorization:`Bearer ${i}`};return n&&(a[`x-spotid`]=n),T({url:r,headers:a})}static async stream(t,n,r){let{streamTransport:i}=Re.getConfiguration();if(i)return i({endpoint:t,body:n,signal:r});let a=e.buildAuthenticatedRequest(t);if(a.isErr())return E(a.error);let{url:o,headers:s}=a.value;try{let e=await fetch(o,{method:`POST`,headers:s,...n===void 0?{}:{body:JSON.stringify(n)},...r?{signal:r}:{}});if(!e.ok){let t=await e.text();return E(Error(`HTTP ${e.status}: ${t}`))}return e.body?T(e.body):E(Error(`Response body is empty`))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(e instanceof Error?e:Error(t))}}get pendingCount(){return this.queue.length}constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=pt.getInstance(),this.httpService=new dt}enqueue(e){return new Promise(t=>{this.queue.push(async()=>{try{t(await e())}catch(e){t(E(new j(D.INTERNAL_SERVER_ERROR,e instanceof Error?e.message:`Unknown error`)))}}),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){let e=this.queue.shift();if(!e)break;await e()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){let e=this.isPaused;this.isPaused=!1,e&&this.processQueue()}async call(e){return this.enqueue(async()=>{let t=async()=>{let{spotId:t,msApiBaseUrl:n}=Re.getConfiguration(),r={...e.options?.headers??{}};t&&(r[`x-spotid`]=t);let i=this.authService.getAccessToken(),{requiresAuth:a=!0}=e;if(!i&&a)return E(new j(D.UNAUTHORIZED));i&&(r.Authorization=`Bearer ${i}`);let o=se(e.endpoint,n);switch(e.method){case M.DELETE:return this.httpService.delete({...e.options??{},headers:r,url:o});case M.GET:return this.httpService.get({...e.options??{},headers:r,url:o});case M.PATCH:return this.httpService.patch({...e.options??{},headers:r,url:o});case M.POST:return this.httpService.post({...e.options??{},headers:r,url:o});default:return E(new j(D.METHOD_NOT_ALLOWED,`Method not allowed`))}},n=await t();if(n.isErr()&&n.error.code===D.UNAUTHORIZED){let e=await this.authService.refresh();if(e.isErr())return E(new j(D.UNAUTHORIZED,e.error.message));n=await t()}return n})}},ht={playbooks:`/v1/playbooks`,pages:e=>`/v1/playbooks/${e}/pages`,hotspots:(e,t)=>`/v1/playbooks/${e}/pages/${t}/hotspots`,hotspot:(e,t,n)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}`,accessibleIntents:(e,t)=>`/v1/playbooks/${e}/pages/${t}/accessibleIntents`,intents:(e,t,n)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}/intents`,intent:(e,t,n,r)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}/intents/${r}`},gt=50,_t=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=mt.getInstance()}async listPlaybooks(e){let t=await this.meltingSpotApi.call({method:M.GET,endpoint:ht.playbooks,options:{query:{page:e?.page??1,limit:e?.limit??gt,...e?.domain?{"domain[eq]":e.domain}:{},...e?.host===void 0?{}:{"domain[matchesHost]":e.host}}}});return t.isErr()?E(t.error):T(t.value)}async listPlaybookPages(e){let t=await this.meltingSpotApi.call({method:M.GET,endpoint:ht.pages(e.playbookId),options:{query:{page:e.page??1,limit:e.limit??gt,...e.url?{"url[eq]":e.url}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookPage(e,t){let n=await this.meltingSpotApi.call({method:M.POST,endpoint:ht.pages(e.playbookId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async listAccessiblePlaybookIntents(e){let t=await this.meltingSpotApi.call({method:M.GET,endpoint:ht.accessibleIntents(e.playbookId,e.pageId),options:{query:{...e.domain?{domain:e.domain}:{}}}});return t.isErr()?E(t.error):T(t.value)}async listPlaybookHotspots(e){let t=await this.meltingSpotApi.call({method:M.GET,endpoint:ht.hotspots(e.playbookId,e.pageId),options:{query:{page:e.page??1,limit:e.limit??gt,...e.intentStatus?{"intentStatus[eq]":e.intentStatus}:{},...e.widgetType?{"widgetType[eq]":e.widgetType}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookHotspot(e,t){let n=await this.meltingSpotApi.call({method:M.POST,endpoint:ht.hotspots(e.playbookId,e.pageId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async updatePlaybookHotspot(e,t){let n=await this.meltingSpotApi.call({method:M.PATCH,endpoint:ht.hotspot(e.playbookId,e.pageId,e.hotspotId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async listPlaybookIntents(e){let t=await this.meltingSpotApi.call({method:M.GET,endpoint:ht.intents(e.playbookId,e.pageId,e.hotspotId),options:{query:{page:e.page??1,limit:e.limit??gt,...e.status?{"status[eq]":e.status}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookIntent(e,t){let n=await this.meltingSpotApi.call({method:M.POST,endpoint:ht.intents(e.playbookId,e.pageId,e.hotspotId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async updatePlaybookIntent(e,t){let n=await this.meltingSpotApi.call({method:M.PATCH,endpoint:ht.intent(e.playbookId,e.pageId,e.hotspotId,e.intentId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}},vt={me:`/v1/spots/me`},yt=1,bt=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=mt.getInstance()}async listSpotsForMe(e){let t=await this.meltingSpotApi.call({method:M.GET,endpoint:vt.me,options:{query:{page:e?.page??yt,limit:e?.limit??50,...e?.spotMemberRole?{"spotMemberRole[eq]":e.spotMemberRole}:{},...e?.id?{"id[eq]":e.id}:{},...e?.name?{"name[contains]":e.name}:{}}}});return t.isErr()?E(t.error):T(t.value)}},xt={spotMember:{me:`/v1/spotMembers/me`,joinFromSso:`/v1/spotMembers~joinFromSso`,search:`/v1/spotMembers~search`}},St=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=mt.getInstance()}async getSpotMemberForMe(){let e=await this.meltingSpotApi.call({method:M.GET,endpoint:xt.spotMember.me});return e.isErr()?E(e.error):T(e.value)}async searchSpotMembers(e){let t={page:e.page,limit:e.limit};e.search&&(t.search=e.search);let n=await this.meltingSpotApi.call({method:M.GET,endpoint:xt.spotMember.search,options:{query:t}});return n.isErr()?E(n.error):T(n.value)}async joinFromSso(e){let t=await this.meltingSpotApi.call({method:M.POST,endpoint:xt.spotMember.joinFromSso,options:{payload:{token:e}}});return t.isErr()?E(t.error):T(t.value)}},Ct={spotMemberSsoToken:`/v1/spotMembers/auth/sso/jwt`,previewAccessKey:`/v1/spotMembers/auth/preview/accessKey`},wt=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=mt.getInstance()}async generateSsoToken(){let e=await this.meltingSpotApi.call({method:M.POST,endpoint:Ct.spotMemberSsoToken,options:{payload:{}}});return e.isErr()?E(e.error):T(e.value.token)}async generatePreviewAccessKey(e){let t=await this.meltingSpotApi.call({method:M.POST,endpoint:Ct.previewAccessKey,options:{payload:{targetSpotMemberId:e.targetSpotMemberId}}});return t.isErr()?E(t.error):T(t.value)}},Tt=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.spotMemberAuthApiService=wt.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}},Et=e=>{let t=e.get(`utm_source`);if(t)return{source:t,medium:e.get(`utm_medium`)??void 0,campaign:e.get(`utm_campaign`)??void 0,term:e.get(`utm_term`)??void 0,content:e.get(`utm_content`)??void 0}},Dt=e=>e?Object.entries(e).reduce((e,[t,n])=>(n!=null&&(e[`utm_${t}`]=n),e),{}):{},Ot=Re.getInstance(),kt=pt.getInstance(),At=Tt.getInstance(),jt={Playbook:_t.getInstance(),Spot:bt.getInstance(),SpotMember:St.getInstance()},Mt=globalThis;Mt.MeltingSpot||={},Mt.MeltingSpot.Configuration=Ot,Mt.MeltingSpot.Auth=kt,Mt.MeltingSpot.Sso=At,Mt.MeltingSpot.Api=jt;var Nt=new Ae({appName:`Embed SDK`,appVersion:`1.15.0`}),Pt=class{#e=null;#t=null;constructor(e){this.content=e}set onRemove(e){this.#t=e}inject(e){this.remove();let t=ce({input:e,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add(`ms-embed`),t.appendChild(this.#e)}remove(){this.#e&&=(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),null)}},Ft=class{constructor(e){this.baseURL=Ie(e.baseURL),this.spotId=Me(e.spotId),this.authToken=e.authToken??null,this.themeMode=e.themeMode??`auto`,this.domain=e.domain??null,this.deeplink=e.deeplink?Pe({deeplink:e.deeplink,spotId:this.spotId}):null,this.utmParameters=e.utmParameters??null,this.rootDocument=e.rootDocument}get iframe(){let e=this.authToken&&this.authToken.trim().length>0?`/sso/jwt`:``,t=de({url:new URL(`/spot/${this.spotId}${e}`,oe(this.baseURL)),searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...Dt(this.utmParameters)},rootDocument:this.rootDocument});return t.classList.add(`ms-spot`),t}},It={READY:`meltingspot:ready`,ERROR:`meltingspot:error`,PREFILL_DRAFT:`meltingspot:prefillDraft`},Lt=class e{static{this.embeds=[]}static{this.messageListened=!1}static{this.iframeCallbacks=new Map}static injectSpotInto(t,n){let{onReady:r,onError:i,...a}=n,{spotId:o,rootDocument:s,msCommunityWebBaseUrl:c}=Re.getConfiguration({spotId:a.spotId,rootDocument:a.rootDocument,msCommunityWebBaseUrl:a.baseURL});if(!o)throw Nt.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let l=new URLSearchParams(window.location.search),u={spotId:o,authToken:a.authToken??l.get(`ms_token`),domain:a.domain,deeplink:a.deeplink??l.get(`ms_url`),themeMode:a.themeMode,utmParameters:a.utmParameters??Et(l),baseURL:c,rootDocument:s},d=new Pt(new Ft(u));if(d.inject(t),e.embeds.push(d),r||i){let t=d.content.iframe.contentWindow;t&&(e.iframeCallbacks.set(t,{onReady:r,onError:i}),d.onRemove=t=>{e.iframeCallbacks.delete(t)}),e.ensureMessageListener()}return Nt.log(`Spot injected`,u,t),d}static clear(){e.embeds.forEach(e=>{e.remove()}),e.embeds=[],e.iframeCallbacks.clear(),e.messageListened&&=(window.removeEventListener(`message`,e.handleMessageEvent),!1),Nt.log(`All MeltingSpot embeds cleared`)}static handleMessageEvent(t){if(!t.data||typeof t.data!=`object`||t.data.type!==It.READY&&t.data.type!==It.ERROR)return;let n=t.source,r=e.iframeCallbacks.get(n);if(!r)return;let{msCommunityWebBaseUrl:i}=Re.getConfiguration({});if(i)try{let e=new URL(i).origin;if(t.origin!==e)return}catch{}t.data.type===It.READY?r.onReady?.():r.onError?.(t.data.error)}static ensureMessageListener(){e.messageListened||=(window.addEventListener(`message`,e.handleMessageEvent),!0)}},Rt=globalThis;Rt.MeltingSpot||={},Rt.MeltingSpot.Embed=Lt;var zt=new Ae({appName:`Widget SDK`,appVersion:`1.15.0`}),Bt=class{constructor(e,t,n){this.content=e,this.rootDocument=t,this.dialogClassname=n,this.dialogElement=null,this.triggerElement=null,this.iframeElement=null,this.currentListener=null}inject({into:e,bind:t,options:n}){this.remove();let r=ce({input:e,rootDocument:this.rootDocument});if(this.dialogElement=le(this.rootDocument),this.dialogElement.classList.add(this.dialogClassname),this.dialogElement.onclose=()=>this.#t(),r.appendChild(this.dialogElement),t){this.triggerElement=ce({input:t,rootDocument:this.rootDocument});let e=this.open.bind(this,n);this.currentListener=t=>{t.stopPropagation(),t.preventDefault(),e()},this.triggerElement.addEventListener(`click`,this.currentListener)}}remove(){this.dialogElement&&=(this.dialogElement.remove(),this.dialogElement.onclose=null,null),this.triggerElement&&(this.currentListener&&this.triggerElement.removeEventListener(`click`,this.currentListener),this.triggerElement=null,this.currentListener=null)}open(e){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(),null)}},Vt=class extends Bt{constructor(e,t){super(e,t,`ms-drawer`)}open(e){let{position:t=`right`}=e??{};super.open(e),this.dialogElement&&(this.dialogElement.dataset.position=t)}},Ht=class extends Bt{constructor(e,t){super(e,t,`ms-modal`)}},Ut=class{constructor(e){this.baseURL=Ie(e.baseURL),this.spotId=Me(e.spotId),this.widgetId=Me(e.widgetId),this.authToken=e.authToken??null,this.themeMode=e.themeMode??`auto`,this.domain=e.domain??null,this.utmParameters=e.utmParameters??null,this.rootDocument=e.rootDocument}get iframe(){let e=de({url:new URL(`/widgets/spot/${this.spotId}/widget/${this.widgetId}`,oe(this.baseURL)),searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,...Dt(this.utmParameters)},rootDocument:this.rootDocument});return e.classList.add(`ms-widget`),e}},P=class{constructor(e){this.baseURL=Ie(e.baseURL),this.spotId=Me(e.spotId),this.widgetContentId=Me(e.widgetContentId),this.contentId=Me(e.contentId),this.widgetId=Me(e.widgetId),this.contentType=e.contentType,this.authToken=e.authToken??null,this.themeMode=e.themeMode??`auto`,this.domain=e.domain??null,this.utmParameters=e.utmParameters??null,this.rootDocument=e.rootDocument}get iframe(){let e=new URL(`/widgets/spot/${this.spotId}/widgetContent/${this.widgetContentId}`,oe(this.baseURL));e.searchParams.set(`widgetId`,this.widgetId);let t=de({url:e,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,contentId:this.contentId,contentType:this.contentType,...Dt(this.utmParameters)},rootDocument:this.rootDocument});return t.classList.add(`ms-widget-content`),t}},Wt=class e{static{this.widgets=[]}static{this.messageListened=!1}static{this.widgetOptions={}}static injectWidgetInto(t,n){let{spotId:r,rootDocument:i,msCommunityWebBaseUrl:a}=Re.getConfiguration({spotId:n.spotId,rootDocument:n.rootDocument,msCommunityWebBaseUrl:n.baseURL});if(!r)throw zt.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let{widget:o,args:s}=e.createWidget({...n,spotId:r,rootDocument:i,baseURL:a}),c=new Pt(o);return c.inject(t),e.widgets.push(c),zt.log(`Widget injected`,e.cleanupLoggedArgs(s),t),c}static injectWidgetContentInto(t,n){let{spotId:r,rootDocument:i,msCommunityWebBaseUrl:a}=Re.getConfiguration({spotId:n.spotId,rootDocument:n.rootDocument,msCommunityWebBaseUrl:n.baseURL});if(!r)throw zt.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let{widgetContent:o,args:s}=e.createWidgetContent({...n,spotId:r,rootDocument:i,baseURL:a}),c=new Pt(o);return c.inject(t),e.widgets.push(c),zt.log(`WidgetContent injected`,e.cleanupLoggedArgs(s),t),c}static bindWidgetModalTo(t,n){return e.bindEntityModalTo(t,{type:`Widget`,data:n})}static bindWidgetDrawerTo(t,n){return e.bindEntityDrawerTo(t,{type:`Widget`,data:n})}static createWidgetDrawer(t){let{widget:n}=e.createWidget(t);return zt.log(`Create Widget drawer`,{data:e.cleanupLoggedArgs(t)}),new Vt(n,t.rootDocument??document)}static createWidgetModal(t){let{widget:n}=e.createWidget(t);return zt.log(`Create Widget modal`,{data:e.cleanupLoggedArgs(t)}),new Ht(n,t.rootDocument??document)}static createWidgetEmbed(t){let{widget:n}=e.createWidget(t),r=new Pt(n);return zt.log(`Create Widget embed`,{data:e.cleanupLoggedArgs(t)}),r}static clear(){e.widgets.forEach(e=>{e.remove()}),e.widgets=[],e.widgetOptions={},zt.log(`All Widget SDK MeltingSpot elements were cleared`)}static bindEntityDrawerTo(t,n){let{spotId:r,rootDocument:i,msCommunityWebBaseUrl:a}=Re.getConfiguration({spotId:n.data.spotId,rootDocument:n.data.rootDocument??document,msCommunityWebBaseUrl:n.data.baseURL});if(!r)throw zt.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let o,s;switch(n.type){case`Widget`:{let t=e.createWidget({...n.data,spotId:r,rootDocument:i,baseURL:a});o=t.widget,s=t.args}break;case`WidgetContent`:{let t=e.createWidgetContent({...n.data,spotId:r,rootDocument:i,baseURL:a});o=t.widgetContent,s=t.args}}let c=new Vt(o,i),l={position:n.data.position},u=n.data.into??i.body;return c.inject({into:u,bind:t,options:l}),e.widgets.push(c),zt.log(`Widget bound to drawer`,e.cleanupLoggedArgs(s),l,u,t),c}static bindEntityModalTo(t,n){let{spotId:r,rootDocument:i,msCommunityWebBaseUrl:a}=Re.getConfiguration({spotId:n.data.spotId,rootDocument:n.data.rootDocument??document,msCommunityWebBaseUrl:n.data.baseURL});if(!r)throw zt.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let o,s;switch(n.type){case`Widget`:{let t=e.createWidget({...n.data,spotId:r,rootDocument:i,baseURL:a});o=t.widget,s=t.args}break;case`WidgetContent`:{let t=e.createWidgetContent({...n.data,spotId:r,rootDocument:i,baseURL:a});o=t.widgetContent,s=t.args}}let c=new Ht(o,i),l=n.data.into??i.body;return c.inject({into:l,bind:t}),e.widgets.push(c),zt.log(`Widget bound to modal`,e.cleanupLoggedArgs(s),l,t),c}static handleMessageEvent(t){if(!t.data||typeof t.data!=`object`||t.data.type!==`OpenWidgetContent`)return;let n=t.data?.widgetId;if(!n||typeof n!=`string`){zt.error(`widgetId is required in the message event data`);return}let r=e.widgetOptions[n];if(!r){zt.error(`No widget options found for widgetId`,{widgetId:n});return}let i=null;try{i=new URL(r.baseURL).origin}catch{i=null}if(!i||t.origin!==i){zt.warn(`Ignoring OpenWidgetContent from unexpected origin`,{origin:t.origin,expectedOrigin:i});return}let{spotId:a,rootDocument:o,msCommunityWebBaseUrl:s}=Re.getConfiguration({spotId:r.spotId,rootDocument:r.rootDocument??document,msCommunityWebBaseUrl:r.baseURL}),{widgetContent:c}=e.createWidgetContent({...r,widgetContentId:t.data.widgetContentId,contentType:t.data.contentType,contentId:t.data.contentId,widgetId:n,spotId:a,rootDocument:o,baseURL:s});t.data.openingIn===`Drawer`?new Vt(c,o).open():t.data.openingIn===`Modal`&&new Ht(c,o).open()}static createWidget(t){let n=new URLSearchParams(window.location.search),r={spotId:t.spotId,widgetId:t.widgetId,authToken:t.authToken,themeMode:t.themeMode,domain:t.domain,rootDocument:t.rootDocument,baseURL:t.baseURL,utmParameters:t.utmParameters??Et(n)};return e.widgetOptions[r.widgetId]=r,e.messageListened||=(window.addEventListener(`message`,e.handleMessageEvent),!0),{widget:new Ut(r),args:r}}static createWidgetContent(e){let t=new URLSearchParams(window.location.search),n={spotId:e.spotId,contentId:e.contentId,contentType:e.contentType,widgetContentId:e.widgetContentId,widgetId:e.widgetId,authToken:e.authToken,themeMode:e.themeMode,domain:e.domain,rootDocument:e.rootDocument,baseURL:e.baseURL,utmParameters:e.utmParameters??Et(t)};return{widgetContent:new P(n),args:n}}static cleanupLoggedArgs(e){let{authToken:t,...n}=e;return{...n,authToken:t?`***`:void 0}}},Gt=globalThis;Gt.MeltingSpot||={},Gt.MeltingSpot.Widget=Wt,e.Drawer=Vt,e.Modal=Ht,e.Widget=Wt});
|
|
33
|
+
}`;var g=af(function(){return ot(o,m+`return `+f).apply(n,s)});if(g.source=f,ou(g))throw g;return g}function Jd(e){return Q(e).toLowerCase()}function Yd(e){return Q(e).toUpperCase()}function Xd(e,t,r){if(e=Q(e),e&&(r||t===n))return Rn(e);if(!e||!(t=wa(t)))return e;var i=or(e),a=or(t);return Ia(i,Hn(i,a),Un(i,a)+1).join(``)}function Zd(e,t,r){if(e=Q(e),e&&(r||t===n))return e.slice(0,sr(e)+1);if(!e||!(t=wa(t)))return e;var i=or(e);return Ia(i,0,Un(i,or(t))+1).join(``)}function Qd(e,t,r){if(e=Q(e),e&&(r||t===n))return e.replace(Ue,``);if(!e||!(t=wa(t)))return e;var i=or(e);return Ia(i,Hn(i,or(t))).join(``)}function $d(e,t){var r=30,i=`...`;if(Y(t)){var a=`separator`in t?t.separator:a;r=`length`in t?Z(t.length):r,i=`omission`in t?wa(t.omission):i}e=Q(e);var o=e.length;if(Yn(e)){var s=or(e);o=s.length}if(r>=o)return e;var c=r-ar(i);if(c<1)return i;var l=s?Ia(s,0,c).join(``):e.slice(0,c);if(a===n)return l+i;if(s&&(c+=l.length-c),bu(a)){if(e.slice(c).search(a)){var u,d=l;for(a.global||(a=ct(a.source,Q(Ze.exec(a))+`g`)),a.lastIndex=0;u=a.exec(d);)var f=u.index;l=l.slice(0,f===n?c:f)}}else if(e.indexOf(wa(a),c)!=c){var p=l.lastIndexOf(a);p>-1&&(l=l.slice(0,p))}return l+i}function ef(e){return e=Q(e),e&&Ne.test(e)?e.replace(je,cr):e}var tf=io(function(e,t,n){return e+(n?` `:``)+t.toUpperCase()}),nf=ro(`toUpperCase`);function rf(e,t,r){return e=Q(e),t=r?n:t,t===n?Xn(e)?dr(e):wn(e):e.match(t)||[]}var af=W(function(e,t){try{return un(e,n,t)}catch(e){return ou(e)?e:new at(e)}}),of=ko(function(e,t){return fn(t,function(t){t=bs(t),si(e,t,xl(e[t],e))}),e});function sf(e){var t=e==null?0:e.length,n=G();return e=t?B(e,function(e){if(typeof e[1]!=`function`)throw new ut(r);return[n(e[0]),e[1]]}):[],W(function(n){for(var r=-1;++r<t;){var i=e[r];if(un(i[0],this,n))return un(i[1],this,n)}})}function cf(e){return di(ui(e,1))}function lf(e){return function(){return e}}function uf(e,t){return e==null||e!==e?t:e}var df=co(),ff=co(!0);function pf(e){return e}function mf(e){return qi(typeof e==`function`?e:ui(e,1))}function hf(e){return Qi(ui(e,1))}function gf(e,t){return $i(e,ui(t,1))}var _f=W(function(e,t){return function(n){return Fi(n,e,t)}}),vf=W(function(e,t){return function(n){return Fi(e,n,t)}});function yf(e,t,n){var r=$(t),i=Ti(t,r);n==null&&!(Y(t)&&(i.length||!r.length))&&(n=t,t=e,e=this,i=Ti(t,$(t)));var a=!(Y(n)&&`chain`in n)||!!n.chain,o=cu(e);return fn(i,function(n){var r=t[n];e[n]=r,o&&(e.prototype[n]=function(){var t=this.__chain__;if(a||t){var n=e(this.__wrapped__);return(n.__actions__=Ja(this.__actions__)).push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,vn([this.value()],arguments))})}),e}function bf(){return R._===this&&(R._=vt),this}function xf(){}function Sf(e){return e=Z(e),W(function(t){return na(t,e)})}var Cf=po(B),wf=po(mn),Tf=po(xn);function Ef(e){return Zo(e)?jn(bs(e)):oa(e)}function Df(e){return function(t){return e==null?n:Ei(e,t)}}var Of=go(),kf=go(!0);function Af(){return[]}function jf(){return!1}function Mf(){return{}}function Nf(){return``}function Pf(){return!0}function Ff(e,t){if(e=Z(e),e<1||e>g)return[];var n=y,r=L(e,y);t=G(t),e-=y;for(var i=In(r,t);++n<e;)t(n);return i}function If(e){return q(e)?B(e,bs):wu(e)?[e]:Ja(ys(Q(e)))}function Lf(e){var t=++mt;return Q(e)+t}var Rf=fo(function(e,t){return e+t},0),zf=yo(`ceil`),Bf=fo(function(e,t){return e/t},1),Vf=yo(`floor`);function Hf(e){return e&&e.length?vi(e,pf,ki):n}function Uf(e,t){return e&&e.length?vi(e,G(t,2),ki):n}function Wf(e){return An(e,pf)}function Gf(e,t){return An(e,G(t,2))}function Kf(e){return e&&e.length?vi(e,pf,Xi):n}function qf(e,t){return e&&e.length?vi(e,G(t,2),Xi):n}var Jf=fo(function(e,t){return e*t},1),Yf=yo(`round`),Xf=fo(function(e,t){return e-t},0);function Zf(e){return e&&e.length?Fn(e,pf):0}function Qf(e,t){return e&&e.length?Fn(e,G(t,2)):0}return V.after=vl,V.ary=yl,V.assign=Lu,V.assignIn=Ru,V.assignInWith=zu,V.assignWith=Bu,V.at=Vu,V.before=bl,V.bind=xl,V.bindAll=of,V.bindKey=Sl,V.castArray=Vl,V.chain=Pc,V.chunk=ws,V.compact=Ts,V.concat=Es,V.cond=sf,V.conforms=cf,V.constant=lf,V.countBy=Gc,V.create=Hu,V.curry=Cl,V.curryRight=wl,V.debounce=Tl,V.defaults=Uu,V.defaultsDeep=Wu,V.defer=El,V.delay=Dl,V.difference=Ds,V.differenceBy=Os,V.differenceWith=ks,V.drop=As,V.dropRight=js,V.dropRightWhile=Ms,V.dropWhile=Ns,V.fill=Ps,V.filter=qc,V.flatMap=Xc,V.flatMapDeep=Zc,V.flatMapDepth=Qc,V.flatten=Ls,V.flattenDeep=Rs,V.flattenDepth=zs,V.flip=Ol,V.flow=df,V.flowRight=ff,V.fromPairs=Bs,V.functions=Zu,V.functionsIn=Qu,V.groupBy=tl,V.initial=Us,V.intersection=Ws,V.intersectionBy=Gs,V.intersectionWith=Ks,V.invert=nd,V.invertBy=rd,V.invokeMap=rl,V.iteratee=mf,V.keyBy=il,V.keys=$,V.keysIn=ad,V.map=al,V.mapKeys=od,V.mapValues=sd,V.matches=hf,V.matchesProperty=gf,V.memoize=kl,V.merge=cd,V.mergeWith=ld,V.method=_f,V.methodOf=vf,V.mixin=yf,V.negate=Al,V.nthArg=Sf,V.omit=ud,V.omitBy=dd,V.once=jl,V.orderBy=ol,V.over=Cf,V.overArgs=Ml,V.overEvery=wf,V.overSome=Tf,V.partial=Nl,V.partialRight=Pl,V.partition=sl,V.pick=fd,V.pickBy=pd,V.property=Ef,V.propertyOf=Df,V.pull=Zs,V.pullAll=Qs,V.pullAllBy=$s,V.pullAllWith=ec,V.pullAt=tc,V.range=Of,V.rangeRight=kf,V.rearg=Fl,V.reject=ul,V.remove=nc,V.rest=Il,V.reverse=rc,V.sampleSize=fl,V.set=hd,V.setWith=gd,V.shuffle=pl,V.slice=ic,V.sortBy=gl,V.sortedUniq=dc,V.sortedUniqBy=fc,V.split=Wd,V.spread=Ll,V.tail=pc,V.take=mc,V.takeRight=hc,V.takeRightWhile=gc,V.takeWhile=_c,V.tap=Fc,V.throttle=Rl,V.thru=Ic,V.toArray=ju,V.toPairs=_d,V.toPairsIn=vd,V.toPath=If,V.toPlainObject=Fu,V.transform=yd,V.unary=zl,V.union=vc,V.unionBy=yc,V.unionWith=bc,V.uniq=xc,V.uniqBy=Sc,V.uniqWith=Cc,V.unset=bd,V.unzip=wc,V.unzipWith=Tc,V.update=xd,V.updateWith=Sd,V.values=Cd,V.valuesIn=wd,V.without=Ec,V.words=rf,V.wrap=Bl,V.xor=Dc,V.xorBy=Oc,V.xorWith=kc,V.zip=Ac,V.zipObject=jc,V.zipObjectDeep=Mc,V.zipWith=Nc,V.entries=_d,V.entriesIn=vd,V.extend=Ru,V.extendWith=zu,yf(V,V),V.add=Rf,V.attempt=af,V.camelCase=Od,V.capitalize=kd,V.ceil=zf,V.clamp=Td,V.clone=Hl,V.cloneDeep=Wl,V.cloneDeepWith=Gl,V.cloneWith=Ul,V.conformsTo=Kl,V.deburr=Ad,V.defaultTo=uf,V.divide=Bf,V.endsWith=jd,V.eq=ql,V.escape=Md,V.escapeRegExp=Nd,V.every=Kc,V.find=Jc,V.findIndex=Fs,V.findKey=Gu,V.findLast=Yc,V.findLastIndex=Is,V.findLastKey=Ku,V.floor=Vf,V.forEach=$c,V.forEachRight=el,V.forIn=qu,V.forInRight=Ju,V.forOwn=Yu,V.forOwnRight=Xu,V.get=$u,V.gt=Jl,V.gte=Yl,V.has=ed,V.hasIn=td,V.head=Vs,V.identity=pf,V.includes=nl,V.indexOf=Hs,V.inRange=Ed,V.invoke=id,V.isArguments=Xl,V.isArray=q,V.isArrayBuffer=Zl,V.isArrayLike=Ql,V.isArrayLikeObject=J,V.isBoolean=$l,V.isBuffer=eu,V.isDate=tu,V.isElement=nu,V.isEmpty=ru,V.isEqual=iu,V.isEqualWith=au,V.isError=ou,V.isFinite=su,V.isFunction=cu,V.isInteger=lu,V.isLength=uu,V.isMap=du,V.isMatch=fu,V.isMatchWith=pu,V.isNaN=mu,V.isNative=hu,V.isNil=_u,V.isNull=gu,V.isNumber=vu,V.isObject=Y,V.isObjectLike=X,V.isPlainObject=yu,V.isRegExp=bu,V.isSafeInteger=xu,V.isSet=Su,V.isString=Cu,V.isSymbol=wu,V.isTypedArray=Tu,V.isUndefined=Eu,V.isWeakMap=Du,V.isWeakSet=Ou,V.join=qs,V.kebabCase=Pd,V.last=Js,V.lastIndexOf=Ys,V.lowerCase=Fd,V.lowerFirst=Id,V.lt=ku,V.lte=Au,V.max=Hf,V.maxBy=Uf,V.mean=Wf,V.meanBy=Gf,V.min=Kf,V.minBy=qf,V.stubArray=Af,V.stubFalse=jf,V.stubObject=Mf,V.stubString=Nf,V.stubTrue=Pf,V.multiply=Jf,V.nth=Xs,V.noConflict=bf,V.noop=xf,V.now=_l,V.pad=Ld,V.padEnd=Rd,V.padStart=zd,V.parseInt=Bd,V.random=Dd,V.reduce=cl,V.reduceRight=ll,V.repeat=Vd,V.replace=Hd,V.result=md,V.round=Yf,V.runInContext=e,V.sample=dl,V.size=ml,V.snakeCase=Ud,V.some=hl,V.sortedIndex=ac,V.sortedIndexBy=oc,V.sortedIndexOf=sc,V.sortedLastIndex=cc,V.sortedLastIndexBy=lc,V.sortedLastIndexOf=uc,V.startCase=Gd,V.startsWith=Kd,V.subtract=Xf,V.sum=Zf,V.sumBy=Qf,V.template=qd,V.times=Ff,V.toFinite=Mu,V.toInteger=Z,V.toLength=Nu,V.toLower=Jd,V.toNumber=Pu,V.toSafeInteger=Iu,V.toString=Q,V.toUpper=Yd,V.trim=Xd,V.trimEnd=Zd,V.trimStart=Qd,V.truncate=$d,V.unescape=ef,V.uniqueId=Lf,V.upperCase=tf,V.upperFirst=nf,V.each=$c,V.eachRight=el,V.first=Vs,yf(V,function(){var e={};return Ci(V,function(t,n){N.call(V.prototype,n)||(e[n]=t)}),e}(),{chain:!1}),V.VERSION=`4.17.21`,fn([`bind`,`bindKey`,`curry`,`curryRight`,`partial`,`partialRight`],function(e){V[e].placeholder=V}),fn([`drop`,`take`],function(e,t){H.prototype[e]=function(r){r=r===n?1:P(Z(r),0);var i=this.__filtered__&&!t?new H(this):this.clone();return i.__filtered__?i.__takeCount__=L(r,i.__takeCount__):i.__views__.push({size:L(r,y),type:e+(i.__dir__<0?`Right`:``)}),i},H.prototype[e+`Right`]=function(t){return this.reverse()[e](t).reverse()}}),fn([`filter`,`map`,`takeWhile`],function(e,t){var n=t+1,r=n==1||n==3;H.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:G(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}}),fn([`head`,`last`],function(e,t){var n=`take`+(t?`Right`:``);H.prototype[e]=function(){return this[n](1).value()[0]}}),fn([`initial`,`tail`],function(e,t){var n=`drop`+(t?``:`Right`);H.prototype[e]=function(){return this.__filtered__?new H(this):this[n](1)}}),H.prototype.compact=function(){return this.filter(pf)},H.prototype.find=function(e){return this.filter(e).head()},H.prototype.findLast=function(e){return this.reverse().find(e)},H.prototype.invokeMap=W(function(e,t){return typeof e==`function`?new H(this):this.map(function(n){return Fi(n,e,t)})}),H.prototype.reject=function(e){return this.filter(Al(G(e)))},H.prototype.slice=function(e,t){e=Z(e);var r=this;return r.__filtered__&&(e>0||t<0)?new H(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(t=Z(t),r=t<0?r.dropRight(-t):r.take(t-e)),r)},H.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},H.prototype.toArray=function(){return this.take(y)},Ci(H.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=V[i?`take`+(t==`last`?`Right`:``):t],o=i||/^find/.test(t);a&&(V.prototype[t]=function(){var t=this.__wrapped__,s=i?[1]:arguments,c=t instanceof H,l=s[0],u=c||q(t),d=function(e){var t=a.apply(V,vn([e],s));return i&&f?t[0]:t};u&&r&&typeof l==`function`&&l.length!=1&&(c=u=!1);var f=this.__chain__,p=!!this.__actions__.length,m=o&&!f,h=c&&!p;if(!o&&u){t=h?t:new H(this);var g=e.apply(t,s);return g.__actions__.push({func:Ic,args:[d],thisArg:n}),new br(g,f)}return m&&h?e.apply(this,s):(g=this.thru(d),m?i?g.value()[0]:g.value():g)})}),fn([`pop`,`push`,`shift`,`sort`,`splice`,`unshift`],function(e){var t=j[e],n=/^(?:push|sort|unshift)$/.test(e)?`tap`:`thru`,r=/^(?:pop|shift)$/.test(e);V.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(q(i)?i:[],e)}return this[n](function(n){return t.apply(q(n)?n:[],e)})}}),Ci(H.prototype,function(e,t){var n=V[t];if(n){var r=n.name+``;N.call(Mn,r)||(Mn[r]=[]),Mn[r].push({name:t,func:n})}}),Mn[lo(n,s).name]=[{name:`wrapper`,func:n}],H.prototype.clone=xr,H.prototype.reverse=Sr,H.prototype.value=Cr,V.prototype.at=Lc,V.prototype.chain=Rc,V.prototype.commit=zc,V.prototype.next=Bc,V.prototype.plant=Hc,V.prototype.reverse=Uc,V.prototype.toJSON=V.prototype.valueOf=V.prototype.value=Wc,V.prototype.first=V.prototype.head,kt&&(V.prototype[kt]=Vc),V})();typeof define==`function`&&typeof define.amd==`object`&&define.amd?(R._=fr,define(function(){return fr})):en?((en.exports=fr)._=fr,$t._=fr):R._=fr}).call(e)}))(),Object.values(function(e){return e.EditMode=`edit-mode`,e.Preview=`preview`,e}({}));var ke=`1.15.1`,Ae=class{constructor(e){this.debug=!1,this.debug=e?.debug??!1,this.appName=e?.appName,this.appVersion=e?.appVersion}log(e,...t){this.debug&&this.print(e,`info`,t)}warn(e,...t){this.print(e,`warn`,t)}error(e,...t){this.print(e,`error`,t)}print(e,t,n){let r=[`[${[`MeltingSpot`,this.appName,this.appVersion].filter(Boolean).join(` - `)}] ${e}`];n.length&&r.push(...n),console[t](...r)}},je=new Ae({appName:`Core SDK`,appVersion:ke}),Me=e=>e.toLowerCase().replace(/[^a-z0-9-]/g,``),Ne=[`/user`],Pe=({deeplink:e,spotId:t})=>{try{let n=new URL(e,`https://unused.com`),r=n.pathname;return n.search&&(r+=n.search),n.hash&&(r+=n.hash),Ne.some(e=>r.startsWith(e))||(r=`/spot/${t}/${ie(r)}`),r}catch(e){return je.warn(`Failed to parse deeplink URL`,e),null}},Fe=[/(^|\.)meltingspot\.io$/i],Ie=e=>{let t;try{let n=oe(e);t=new URL(n)}catch{throw Error(`Invalid baseURL: ${e}`)}let n=t.hostname===`localhost`||t.hostname===`127.0.0.1`,r=t.protocol===`https:`,i=Fe.some(e=>e.test(t.hostname));if(!n&&(!r||!i))throw Error(`Untrusted baseURL origin: ${t.origin}`);return t.origin},Le={msApiBaseUrl:`https://openapi.meltingspot.io/`,msCommunityWebBaseUrl:`https://go.meltingspot.io/`,ssoToken:void 0,spotId:``,autoJoin:!1,rootDocument:globalThis.document},Re=class e{constructor(){this.configuration=Le}static getInstance(){return e.instance||=new e,e.instance}setConfiguration(e){this.configuration={...this.configuration,...e}}static getConfiguration(t={}){let n=e.getInstance(),r=Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0));return{...n.configuration,...r}}},ze=RegExp(`(%[a-f0-9]{2})|([^%]+?)`,`gi`),Be=RegExp(`(%[a-f0-9]{2})+`,`gi`);function Ve(e,t){try{return[decodeURIComponent(e.join(``))]}catch{}if(e.length===1)return e;t||=1;let n=e.slice(0,t),r=e.slice(t);return Array.prototype.concat.call([],Ve(n),Ve(r))}function He(e){try{return decodeURIComponent(e)}catch{let t=e.match(ze)||[];for(let n=1;n<t.length;n++)e=Ve(t,n).join(``),t=e.match(ze)||[];return e}}function Ue(e){let t={"%FE%FF":`��`,"%FF%FE":`��`},n=Be.exec(e);for(;n;){try{t[n[0]]=decodeURIComponent(n[0])}catch{let e=He(n[0]);e!==n[0]&&(t[n[0]]=e)}n=Be.exec(e)}t[`%C2`]=`�`;let r=Object.keys(t);for(let n of r)e=e.replace(new RegExp(n,`g`),t[n]);return e}function O(e){if(typeof e!=`string`)throw TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return decodeURIComponent(e)}catch{return Ue(e)}}function We(e,t){let n={};if(Array.isArray(t))for(let r of t){let t=Object.getOwnPropertyDescriptor(e,r);t?.enumerable&&Object.defineProperty(n,r,t)}else for(let r of Reflect.ownKeys(e)){let i=Object.getOwnPropertyDescriptor(e,r);if(i.enumerable){let a=e[r];t(r,a,e)&&Object.defineProperty(n,r,i)}}return n}function Ge(e,t){if(typeof e!=`string`||typeof t!=`string`)throw TypeError("Expected the arguments to be of type `string`");if(e===``||t===``)return[];let n=e.indexOf(t);return n===-1?[]:[e.slice(0,n),e.slice(n+t.length)]}var Ke=c({exclude:()=>lt,extract:()=>it,parse:()=>at,parseUrl:()=>st,pick:()=>ct,stringify:()=>ot,stringifyUrl:()=>A}),qe=e=>e==null,Je=e=>encodeURIComponent(e).replaceAll(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Ye=Symbol(`encodeFragmentIdentifier`);function Xe(e){switch(e.arrayFormat){case`index`:return t=>(n,r)=>{let i=n.length;return r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[k(t,e),`[`,i,`]`].join(``)]:[...n,[k(t,e),`[`,k(i,e),`]=`,k(r,e)].join(``)]};case`bracket`:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[k(t,e),`[]`].join(``)]:[...n,[k(t,e),`[]=`,k(r,e)].join(``)];case`colon-list-separator`:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[k(t,e),`:list=`].join(``)]:[...n,[k(t,e),`:list=`,k(r,e)].join(``)];case`comma`:case`separator`:case`bracket-separator`:{let t=e.arrayFormat===`bracket-separator`?`[]=`:`=`;return n=>(r,i)=>i===void 0||e.skipNull&&i===null||e.skipEmptyString&&i===``?r:(i=i===null?``:i,r.length===0?[[k(n,e),t,k(i,e)].join(``)]:[[r,k(i,e)].join(e.arrayFormatSeparator)])}default:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,k(t,e)]:[...n,[k(t,e),`=`,k(r,e)].join(``)]}}function Ze(e){let t;switch(e.arrayFormat){case`index`:return(e,n,r)=>{if(t=/\[(\d*)]$/.exec(e),e=e.replace(/\[\d*]$/,``),!t){r[e]=n;return}r[e]===void 0&&(r[e]={}),r[e][t[1]]=n};case`bracket`:return(e,n,r)=>{if(t=/(\[])$/.exec(e),e=e.replace(/\[]$/,``),!t){r[e]=n;return}if(r[e]===void 0){r[e]=[n];return}r[e]=[...r[e],n]};case`colon-list-separator`:return(e,n,r)=>{if(t=/(:list)$/.exec(e),e=e.replace(/:list$/,``),!t){r[e]=n;return}if(r[e]===void 0){r[e]=[n];return}r[e]=[...r[e],n]};case`comma`:case`separator`:return(t,n,r)=>{let i=typeof n==`string`&&n.includes(e.arrayFormatSeparator),a=typeof n==`string`&&!i&&$e(n,e).includes(e.arrayFormatSeparator);n=a?$e(n,e):n,r[t]=i||a?n.split(e.arrayFormatSeparator).map(t=>$e(t,e)):n===null?n:$e(n,e)};case`bracket-separator`:return(t,n,r)=>{let i=/(\[])$/.test(t);if(t=t.replace(/\[]$/,``),!i){r[t]=n&&$e(n,e);return}let a=n===null?[]:$e(n,e).split(e.arrayFormatSeparator);if(r[t]===void 0){r[t]=a;return}r[t]=[...r[t],...a]};default:return(e,t,n)=>{if(n[e]===void 0){n[e]=t;return}n[e]=[...[n[e]].flat(),t]}}}function Qe(e){if(typeof e!=`string`||e.length!==1)throw TypeError(`arrayFormatSeparator must be single character string`)}function k(e,t){return t.encode?t.strict?Je(e):encodeURIComponent(e):e}function $e(e,t){return t.decode?O(e):e}function et(e){return Array.isArray(e)?e.sort():typeof e==`object`?et(Object.keys(e)).sort((e,t)=>Number(e)-Number(t)).map(t=>e[t]):e}function tt(e){let t=e.indexOf(`#`);return t!==-1&&(e=e.slice(0,t)),e}function nt(e){let t=``,n=e.indexOf(`#`);return n!==-1&&(t=e.slice(n)),t}function rt(e,t,n){return n===`string`&&typeof e==`string`?e:typeof n==`function`&&typeof e==`string`?n(e):n===`boolean`&&e===null?!0:n===`boolean`&&e!==null&&(e.toLowerCase()===`true`||e.toLowerCase()===`false`)?e.toLowerCase()===`true`:n===`boolean`&&e!==null&&(e.toLowerCase()===`1`||e.toLowerCase()===`0`)?e.toLowerCase()===`1`:n===`string[]`&&t.arrayFormat!==`none`&&typeof e==`string`?[e]:n===`number[]`&&t.arrayFormat!==`none`&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?[Number(e)]:n===`number`&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?Number(e):t.parseBooleans&&e!==null&&(e.toLowerCase()===`true`||e.toLowerCase()===`false`)?e.toLowerCase()===`true`:t.parseNumbers&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?Number(e):e}function it(e){e=tt(e);let t=e.indexOf(`?`);return t===-1?``:e.slice(t+1)}function at(e,t){t={decode:!0,sort:!0,arrayFormat:`none`,arrayFormatSeparator:`,`,parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...t},Qe(t.arrayFormatSeparator);let n=Ze(t),r=Object.create(null);if(typeof e!=`string`||(e=e.trim().replace(/^[?#&]/,``),!e))return r;for(let i of e.split(`&`)){if(i===``)continue;let e=t.decode?i.replaceAll(`+`,` `):i,[a,o]=Ge(e,`=`);a===void 0&&(a=e),o=o===void 0?null:[`comma`,`separator`,`bracket-separator`].includes(t.arrayFormat)?o:$e(o,t),n($e(a,t),o,r)}for(let[e,n]of Object.entries(r))if(typeof n==`object`&&n&&t.types[e]!==`string`)for(let[r,i]of Object.entries(n)){let a=t.types[e]?t.types[e].replace(`[]`,``):void 0;n[r]=rt(i,t,a)}else r[e]=typeof n==`object`&&n&&t.types[e]===`string`?Object.values(n).join(t.arrayFormatSeparator):rt(n,t,t.types[e]);return t.sort===!1?r:(t.sort===!0?Object.keys(r).sort():Object.keys(r).sort(t.sort)).reduce((e,t)=>{let n=r[t];return e[t]=n&&typeof n==`object`&&!Array.isArray(n)?et(n):n,e},Object.create(null))}function ot(e,t){if(!e)return``;t={encode:!0,strict:!0,arrayFormat:`none`,arrayFormatSeparator:`,`,...t},Qe(t.arrayFormatSeparator);let n=n=>t.skipNull&&qe(e[n])||t.skipEmptyString&&e[n]===``,r=Xe(t),i={};for(let[t,r]of Object.entries(e))n(t)||(i[t]=r);let a=Object.keys(i);return t.sort!==!1&&a.sort(t.sort),a.map(n=>{let i=e[n];return i===void 0?``:i===null?k(n,t):Array.isArray(i)?i.length===0&&t.arrayFormat===`bracket-separator`?k(n,t)+`[]`:i.reduce(r(n),[]).join(`&`):k(n,t)+`=`+k(i,t)}).filter(e=>e.length>0).join(`&`)}function st(e,t){t={decode:!0,...t};let[n,r]=Ge(e,`#`);return n===void 0&&(n=e),{url:n?.split(`?`)?.[0]??``,query:at(it(e),t),...t&&t.parseFragmentIdentifier&&r?{fragmentIdentifier:$e(r,t)}:{}}}function A(e,t){t={encode:!0,strict:!0,[Ye]:!0,...t};let n=tt(e.url).split(`?`)[0]||``,r=ot({...at(it(e.url),{sort:!1,...t}),...e.query},t);r&&=`?${r}`;let i=nt(e.url);if(typeof e.fragmentIdentifier==`string`){let r=new URL(n);r.hash=e.fragmentIdentifier,i=t[Ye]?r.hash:`#${e.fragmentIdentifier}`}return`${n}${r}${i}`}function ct(e,t,n){n={parseFragmentIdentifier:!0,[Ye]:!1,...n};let{url:r,query:i,fragmentIdentifier:a}=st(e,n);return A({url:r,query:We(i,t),fragmentIdentifier:a},n)}function lt(e,t,n){return ct(e,Array.isArray(t)?e=>!t.includes(e):(e,n)=>!t(e,n),n)}var ut=Ke,j=class e extends Error{constructor(t,n){super(`HTTP Error ${t}${n?`: ${n}`:``}`),this.code=t,this.name=`HttpError`,Object.setPrototypeOf(this,e.prototype)}},M=function(e){return e.DELETE=`DELETE`,e.GET=`GET`,e.PATCH=`PATCH`,e.POST=`POST`,e}({}),dt=class e{constructor(){this.headers={}}setHeaders(e){this.headers=e}async get(t){try{let n=t.query?`${t.url}?${this.serializeQuery(t.query)}`:t.url,r=await fetch(n,{headers:{...this.headers,...t.headers,"Content-Type":`application/json`},...t.signal?{signal:t.signal}:{}});return r.ok?T(await e.parseBody(r)):E(new j(r.status,await r.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new j(D.INTERNAL_SERVER_ERROR,t))}}async post(t){try{let n=await fetch(t.url,{method:`POST`,headers:{...this.headers,...t.headers,"Content-Type":`application/json`},body:JSON.stringify(t.payload),...t.signal?{signal:t.signal}:{}});return n.ok?T(await e.parseBody(n)):E(new j(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new j(D.INTERNAL_SERVER_ERROR,t))}}async delete(t){try{let n=await fetch(t.url,{method:`DELETE`,headers:{...this.headers,...t.headers,Accept:`application/json`},...t.signal?{signal:t.signal}:{}});return n.ok?T(await e.parseBody(n)):E(new j(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new j(D.INTERNAL_SERVER_ERROR,t))}}async patch(t){try{let n=await fetch(t.url,{method:`PATCH`,headers:{...this.headers,...t.headers,"Content-Type":`application/json`},body:JSON.stringify(t.payload),...t.signal?{signal:t.signal}:{}});return n.ok?T(await e.parseBody(n)):E(new j(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new j(D.INTERNAL_SERVER_ERROR,t))}}static async parseBody(e){if(e.status!==D.NO_CONTENT)return await e.json()}serializeQuery(e){if(typeof e==`string`)return e;if(typeof e==`object`)for(let t in e)e[t]===void 0&&delete e[t];return e=ut.stringify(e,{arrayFormat:`none`}),e}},ft={accessToken:{email:`/v1/auth/accessToken/email`,sso:{jwt:`/v1/auth/accessToken/sso/jwt`}},refreshAccessToken:`/v1/auth/accessToken~refresh`,password:{reset:`/v1/auth/password~reset`}},pt=class e extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return e.instance||=new e,e.instance}async loginWithPassword(e,t){let n=await this.callApi({endpoint:ft.accessToken.email,method:`POST`,body:{email:e,password:t},withSpotId:!0});if(n.isErr())return E(n.error);let{accessToken:r,refreshToken:i}=n.value;return this.setTokens(r.token,i.token),T({accessToken:r.token,refreshToken:i.token})}async loginWithSsoToken(e){let t=await this.callApi({endpoint:ft.accessToken.sso.jwt,method:`POST`,body:{token:e},withSpotId:!0});if(t.isErr())return E(t.error);let{accessToken:n,refreshToken:r}=t.value;return this.setTokens(n.token,r.token),T({accessToken:n.token,refreshToken:r.token})}loginWithAuthTokens(e,t){return this.setTokens(e,t),{accessToken:e,refreshToken:t}}resetPassword(e){return this.callApi({endpoint:ft.password.reset,method:`POST`,body:{email:e}})}async refresh(){let e=await this.callApi({endpoint:ft.refreshAccessToken,method:`POST`,body:{refreshToken:this.refreshToken}});if(e.isErr())return E(e.error);let{accessToken:t,refreshToken:n}=e.value;return this.setTokens(t.token,n.token),T({accessToken:t.token,refreshToken:n.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(e,t){if(this.accessToken!==e||this.refreshToken!==t){this.accessToken=e,this.refreshToken=t;let n=new CustomEvent(`auth:tokens-updated`,{detail:{accessToken:e,refreshToken:t}});this.dispatchEvent(n)}}async callApi(e){try{let{spotId:t,msApiBaseUrl:n}=Re.getConfiguration(),r=se(e.endpoint,n),i={"Content-Type":`application/json`,...e.headers};e.withSpotId&&t&&(i[N.SpotId]=t);let a=await fetch(r,{method:e.method,body:e.body?JSON.stringify(e.body):void 0,headers:i});return a.ok?a.status===D.NO_CONTENT?T(void 0):T(await a.json()):E(new j(a.status,a.statusText))}catch(e){return E(new j(D.INTERNAL_SERVER_ERROR,e instanceof Error?e.message:String(e)))}}},N=function(e){return e.Authorization=`Authorization`,e.SpotId=`x-spotid`,e}({}),mt=class e{static getInstance(){return e.instance||=new e,e.instance}static buildAuthenticatedRequest(e){let{msApiBaseUrl:t,spotId:n}=Re.getConfiguration(),r=se(e,t),i=pt.getInstance().getAccessToken();if(!i)return E(Error(`Not authenticated`));let a={"Content-Type":`application/json`,Authorization:`Bearer ${i}`};return n&&(a[`x-spotid`]=n),T({url:r,headers:a})}static async stream(t,n,r){let{streamTransport:i}=Re.getConfiguration();if(i)return i({endpoint:t,body:n,signal:r});let a=e.buildAuthenticatedRequest(t);if(a.isErr())return E(a.error);let{url:o,headers:s}=a.value;try{let e=await fetch(o,{method:`POST`,headers:s,...n===void 0?{}:{body:JSON.stringify(n)},...r?{signal:r}:{}});if(!e.ok){let t=await e.text();return E(Error(`HTTP ${e.status}: ${t}`))}return e.body?T(e.body):E(Error(`Response body is empty`))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(e instanceof Error?e:Error(t))}}get pendingCount(){return this.queue.length}constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=pt.getInstance(),this.httpService=new dt}enqueue(e){return new Promise(t=>{this.queue.push(async()=>{try{t(await e())}catch(e){t(E(new j(D.INTERNAL_SERVER_ERROR,e instanceof Error?e.message:`Unknown error`)))}}),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){let e=this.queue.shift();if(!e)break;await e()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){let e=this.isPaused;this.isPaused=!1,e&&this.processQueue()}async call(e){return this.enqueue(async()=>{let t=async()=>{let{spotId:t,msApiBaseUrl:n}=Re.getConfiguration(),r={...e.options?.headers??{}};t&&(r[`x-spotid`]=t);let i=this.authService.getAccessToken(),{requiresAuth:a=!0}=e;if(!i&&a)return E(new j(D.UNAUTHORIZED));i&&(r.Authorization=`Bearer ${i}`);let o=se(e.endpoint,n);switch(e.method){case M.DELETE:return this.httpService.delete({...e.options??{},headers:r,url:o});case M.GET:return this.httpService.get({...e.options??{},headers:r,url:o});case M.PATCH:return this.httpService.patch({...e.options??{},headers:r,url:o});case M.POST:return this.httpService.post({...e.options??{},headers:r,url:o});default:return E(new j(D.METHOD_NOT_ALLOWED,`Method not allowed`))}},n=await t();if(n.isErr()&&n.error.code===D.UNAUTHORIZED){let e=await this.authService.refresh();if(e.isErr())return E(new j(D.UNAUTHORIZED,e.error.message));n=await t()}return n})}},ht={playbooks:`/v1/playbooks`,pages:e=>`/v1/playbooks/${e}/pages`,hotspots:(e,t)=>`/v1/playbooks/${e}/pages/${t}/hotspots`,hotspot:(e,t,n)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}`,accessibleIntents:(e,t)=>`/v1/playbooks/${e}/pages/${t}/accessibleIntents`,intents:(e,t,n)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}/intents`,intent:(e,t,n,r)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}/intents/${r}`},gt=50,_t=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=mt.getInstance()}async listPlaybooks(e){let t=await this.meltingSpotApi.call({method:M.GET,endpoint:ht.playbooks,options:{query:{page:e?.page??1,limit:e?.limit??gt,...e?.domain?{"domain[eq]":e.domain}:{},...e?.host===void 0?{}:{"domain[matchesHost]":e.host}}}});return t.isErr()?E(t.error):T(t.value)}async listPlaybookPages(e){let t=await this.meltingSpotApi.call({method:M.GET,endpoint:ht.pages(e.playbookId),options:{query:{page:e.page??1,limit:e.limit??gt,...e.url?{"url[eq]":e.url}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookPage(e,t){let n=await this.meltingSpotApi.call({method:M.POST,endpoint:ht.pages(e.playbookId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async listAccessiblePlaybookIntents(e){let t=await this.meltingSpotApi.call({method:M.GET,endpoint:ht.accessibleIntents(e.playbookId,e.pageId),options:{query:{...e.domain?{domain:e.domain}:{}}}});return t.isErr()?E(t.error):T(t.value)}async listPlaybookHotspots(e){let t=await this.meltingSpotApi.call({method:M.GET,endpoint:ht.hotspots(e.playbookId,e.pageId),options:{query:{page:e.page??1,limit:e.limit??gt,...e.intentStatus?{"intentStatus[eq]":e.intentStatus}:{},...e.widgetType?{"widgetType[eq]":e.widgetType}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookHotspot(e,t){let n=await this.meltingSpotApi.call({method:M.POST,endpoint:ht.hotspots(e.playbookId,e.pageId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async updatePlaybookHotspot(e,t){let n=await this.meltingSpotApi.call({method:M.PATCH,endpoint:ht.hotspot(e.playbookId,e.pageId,e.hotspotId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async listPlaybookIntents(e){let t=await this.meltingSpotApi.call({method:M.GET,endpoint:ht.intents(e.playbookId,e.pageId,e.hotspotId),options:{query:{page:e.page??1,limit:e.limit??gt,...e.status?{"status[eq]":e.status}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookIntent(e,t){let n=await this.meltingSpotApi.call({method:M.POST,endpoint:ht.intents(e.playbookId,e.pageId,e.hotspotId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async updatePlaybookIntent(e,t){let n=await this.meltingSpotApi.call({method:M.PATCH,endpoint:ht.intent(e.playbookId,e.pageId,e.hotspotId,e.intentId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}},vt={me:`/v1/spots/me`},yt=1,bt=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=mt.getInstance()}async listSpotsForMe(e){let t=await this.meltingSpotApi.call({method:M.GET,endpoint:vt.me,options:{query:{page:e?.page??yt,limit:e?.limit??50,...e?.spotMemberRole?{"spotMemberRole[eq]":e.spotMemberRole}:{},...e?.id?{"id[eq]":e.id}:{},...e?.name?{"name[contains]":e.name}:{}}}});return t.isErr()?E(t.error):T(t.value)}},xt={spotMember:{me:`/v1/spotMembers/me`,joinFromSso:`/v1/spotMembers~joinFromSso`,search:`/v1/spotMembers~search`}},St=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=mt.getInstance()}async getSpotMemberForMe(){let e=await this.meltingSpotApi.call({method:M.GET,endpoint:xt.spotMember.me});return e.isErr()?E(e.error):T(e.value)}async searchSpotMembers(e){let t={page:e.page,limit:e.limit};e.search&&(t.search=e.search);let n=await this.meltingSpotApi.call({method:M.GET,endpoint:xt.spotMember.search,options:{query:t}});return n.isErr()?E(n.error):T(n.value)}async joinFromSso(e){let t=await this.meltingSpotApi.call({method:M.POST,endpoint:xt.spotMember.joinFromSso,options:{payload:{token:e}}});return t.isErr()?E(t.error):T(t.value)}},Ct={spotMemberSsoToken:`/v1/spotMembers/auth/sso/jwt`,previewAccessKey:`/v1/spotMembers/auth/preview/accessKey`},wt=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=mt.getInstance()}async generateSsoToken(){let e=await this.meltingSpotApi.call({method:M.POST,endpoint:Ct.spotMemberSsoToken,options:{payload:{}}});return e.isErr()?E(e.error):T(e.value.token)}async generatePreviewAccessKey(e){let t=await this.meltingSpotApi.call({method:M.POST,endpoint:Ct.previewAccessKey,options:{payload:{targetSpotMemberId:e.targetSpotMemberId}}});return t.isErr()?E(t.error):T(t.value)}},Tt=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.spotMemberAuthApiService=wt.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}},Et=e=>{let t=e.get(`utm_source`);if(t)return{source:t,medium:e.get(`utm_medium`)??void 0,campaign:e.get(`utm_campaign`)??void 0,term:e.get(`utm_term`)??void 0,content:e.get(`utm_content`)??void 0}},Dt=e=>e?Object.entries(e).reduce((e,[t,n])=>(n!=null&&(e[`utm_${t}`]=n),e),{}):{},Ot=Re.getInstance(),kt=pt.getInstance(),At=Tt.getInstance(),jt={Playbook:_t.getInstance(),Spot:bt.getInstance(),SpotMember:St.getInstance()},Mt=globalThis;Mt.MeltingSpot||={},Mt.MeltingSpot.Configuration=Ot,Mt.MeltingSpot.Auth=kt,Mt.MeltingSpot.Sso=At,Mt.MeltingSpot.Api=jt;var Nt=new Ae({appName:`Embed SDK`,appVersion:`1.15.1`}),Pt=class{#e=null;#t=null;constructor(e){this.content=e}set onRemove(e){this.#t=e}inject(e){this.remove();let t=ce({input:e,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add(`ms-embed`),t.appendChild(this.#e)}remove(){this.#e&&=(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),null)}},Ft=class{constructor(e){this.baseURL=Ie(e.baseURL),this.spotId=Me(e.spotId),this.authToken=e.authToken??null,this.themeMode=e.themeMode??`auto`,this.domain=e.domain??null,this.deeplink=e.deeplink?Pe({deeplink:e.deeplink,spotId:this.spotId}):null,this.utmParameters=e.utmParameters??null,this.rootDocument=e.rootDocument}get iframe(){let e=this.authToken&&this.authToken.trim().length>0?`/sso/jwt`:``,t=de({url:new URL(`/spot/${this.spotId}${e}`,oe(this.baseURL)),searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...Dt(this.utmParameters)},rootDocument:this.rootDocument});return t.classList.add(`ms-spot`),t}},It={READY:`meltingspot:ready`,ERROR:`meltingspot:error`,PREFILL_DRAFT:`meltingspot:prefillDraft`},Lt=class e{static{this.embeds=[]}static{this.messageListened=!1}static{this.iframeCallbacks=new Map}static injectSpotInto(t,n){let{onReady:r,onError:i,...a}=n,{spotId:o,rootDocument:s,msCommunityWebBaseUrl:c}=Re.getConfiguration({spotId:a.spotId,rootDocument:a.rootDocument,msCommunityWebBaseUrl:a.baseURL});if(!o)throw Nt.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let l=new URLSearchParams(window.location.search),u={spotId:o,authToken:a.authToken??l.get(`ms_token`),domain:a.domain,deeplink:a.deeplink??l.get(`ms_url`),themeMode:a.themeMode,utmParameters:a.utmParameters??Et(l),baseURL:c,rootDocument:s},d=new Pt(new Ft(u));if(d.inject(t),e.embeds.push(d),r||i){let t=d.content.iframe.contentWindow;t&&(e.iframeCallbacks.set(t,{onReady:r,onError:i}),d.onRemove=t=>{e.iframeCallbacks.delete(t)}),e.ensureMessageListener()}return Nt.log(`Spot injected`,u,t),d}static clear(){e.embeds.forEach(e=>{e.remove()}),e.embeds=[],e.iframeCallbacks.clear(),e.messageListened&&=(window.removeEventListener(`message`,e.handleMessageEvent),!1),Nt.log(`All MeltingSpot embeds cleared`)}static handleMessageEvent(t){if(!t.data||typeof t.data!=`object`||t.data.type!==It.READY&&t.data.type!==It.ERROR)return;let n=t.source,r=e.iframeCallbacks.get(n);if(!r)return;let{msCommunityWebBaseUrl:i}=Re.getConfiguration({});if(i)try{let e=new URL(i).origin;if(t.origin!==e)return}catch{}t.data.type===It.READY?r.onReady?.():r.onError?.(t.data.error)}static ensureMessageListener(){e.messageListened||=(window.addEventListener(`message`,e.handleMessageEvent),!0)}},Rt=globalThis;Rt.MeltingSpot||={},Rt.MeltingSpot.Embed=Lt;var zt=new Ae({appName:`Widget SDK`,appVersion:`1.15.1`}),Bt=class{constructor(e,t,n){this.content=e,this.rootDocument=t,this.dialogClassname=n,this.dialogElement=null,this.triggerElement=null,this.iframeElement=null,this.currentListener=null}inject({into:e,bind:t,options:n}){this.remove();let r=ce({input:e,rootDocument:this.rootDocument});if(this.dialogElement=le(this.rootDocument),this.dialogElement.classList.add(this.dialogClassname),this.dialogElement.onclose=()=>this.#t(),r.appendChild(this.dialogElement),t){this.triggerElement=ce({input:t,rootDocument:this.rootDocument});let e=this.open.bind(this,n);this.currentListener=t=>{t.stopPropagation(),t.preventDefault(),e()},this.triggerElement.addEventListener(`click`,this.currentListener)}}remove(){this.dialogElement&&=(this.dialogElement.remove(),this.dialogElement.onclose=null,null),this.triggerElement&&(this.currentListener&&this.triggerElement.removeEventListener(`click`,this.currentListener),this.triggerElement=null,this.currentListener=null)}open(e){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(),null)}},Vt=class extends Bt{constructor(e,t){super(e,t,`ms-drawer`)}open(e){let{position:t=`right`}=e??{};super.open(e),this.dialogElement&&(this.dialogElement.dataset.position=t)}},Ht=class extends Bt{constructor(e,t){super(e,t,`ms-modal`)}},Ut=class{constructor(e){this.baseURL=Ie(e.baseURL),this.spotId=Me(e.spotId),this.widgetId=Me(e.widgetId),this.authToken=e.authToken??null,this.themeMode=e.themeMode??`auto`,this.domain=e.domain??null,this.utmParameters=e.utmParameters??null,this.rootDocument=e.rootDocument}get iframe(){let e=de({url:new URL(`/widgets/spot/${this.spotId}/widget/${this.widgetId}`,oe(this.baseURL)),searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,...Dt(this.utmParameters)},rootDocument:this.rootDocument});return e.classList.add(`ms-widget`),e}},P=class{constructor(e){this.baseURL=Ie(e.baseURL),this.spotId=Me(e.spotId),this.widgetContentId=Me(e.widgetContentId),this.contentId=Me(e.contentId),this.widgetId=Me(e.widgetId),this.contentType=e.contentType,this.authToken=e.authToken??null,this.themeMode=e.themeMode??`auto`,this.domain=e.domain??null,this.utmParameters=e.utmParameters??null,this.rootDocument=e.rootDocument}get iframe(){let e=new URL(`/widgets/spot/${this.spotId}/widgetContent/${this.widgetContentId}`,oe(this.baseURL));e.searchParams.set(`widgetId`,this.widgetId);let t=de({url:e,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,contentId:this.contentId,contentType:this.contentType,...Dt(this.utmParameters)},rootDocument:this.rootDocument});return t.classList.add(`ms-widget-content`),t}},Wt=class e{static{this.widgets=[]}static{this.messageListened=!1}static{this.widgetOptions={}}static injectWidgetInto(t,n){let{spotId:r,rootDocument:i,msCommunityWebBaseUrl:a}=Re.getConfiguration({spotId:n.spotId,rootDocument:n.rootDocument,msCommunityWebBaseUrl:n.baseURL});if(!r)throw zt.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let{widget:o,args:s}=e.createWidget({...n,spotId:r,rootDocument:i,baseURL:a}),c=new Pt(o);return c.inject(t),e.widgets.push(c),zt.log(`Widget injected`,e.cleanupLoggedArgs(s),t),c}static injectWidgetContentInto(t,n){let{spotId:r,rootDocument:i,msCommunityWebBaseUrl:a}=Re.getConfiguration({spotId:n.spotId,rootDocument:n.rootDocument,msCommunityWebBaseUrl:n.baseURL});if(!r)throw zt.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let{widgetContent:o,args:s}=e.createWidgetContent({...n,spotId:r,rootDocument:i,baseURL:a}),c=new Pt(o);return c.inject(t),e.widgets.push(c),zt.log(`WidgetContent injected`,e.cleanupLoggedArgs(s),t),c}static bindWidgetModalTo(t,n){return e.bindEntityModalTo(t,{type:`Widget`,data:n})}static bindWidgetDrawerTo(t,n){return e.bindEntityDrawerTo(t,{type:`Widget`,data:n})}static createWidgetDrawer(t){let{widget:n}=e.createWidget(t);return zt.log(`Create Widget drawer`,{data:e.cleanupLoggedArgs(t)}),new Vt(n,t.rootDocument??document)}static createWidgetModal(t){let{widget:n}=e.createWidget(t);return zt.log(`Create Widget modal`,{data:e.cleanupLoggedArgs(t)}),new Ht(n,t.rootDocument??document)}static createWidgetEmbed(t){let{widget:n}=e.createWidget(t),r=new Pt(n);return zt.log(`Create Widget embed`,{data:e.cleanupLoggedArgs(t)}),r}static clear(){e.widgets.forEach(e=>{e.remove()}),e.widgets=[],e.widgetOptions={},zt.log(`All Widget SDK MeltingSpot elements were cleared`)}static bindEntityDrawerTo(t,n){let{spotId:r,rootDocument:i,msCommunityWebBaseUrl:a}=Re.getConfiguration({spotId:n.data.spotId,rootDocument:n.data.rootDocument??document,msCommunityWebBaseUrl:n.data.baseURL});if(!r)throw zt.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let o,s;switch(n.type){case`Widget`:{let t=e.createWidget({...n.data,spotId:r,rootDocument:i,baseURL:a});o=t.widget,s=t.args}break;case`WidgetContent`:{let t=e.createWidgetContent({...n.data,spotId:r,rootDocument:i,baseURL:a});o=t.widgetContent,s=t.args}}let c=new Vt(o,i),l={position:n.data.position},u=n.data.into??i.body;return c.inject({into:u,bind:t,options:l}),e.widgets.push(c),zt.log(`Widget bound to drawer`,e.cleanupLoggedArgs(s),l,u,t),c}static bindEntityModalTo(t,n){let{spotId:r,rootDocument:i,msCommunityWebBaseUrl:a}=Re.getConfiguration({spotId:n.data.spotId,rootDocument:n.data.rootDocument??document,msCommunityWebBaseUrl:n.data.baseURL});if(!r)throw zt.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let o,s;switch(n.type){case`Widget`:{let t=e.createWidget({...n.data,spotId:r,rootDocument:i,baseURL:a});o=t.widget,s=t.args}break;case`WidgetContent`:{let t=e.createWidgetContent({...n.data,spotId:r,rootDocument:i,baseURL:a});o=t.widgetContent,s=t.args}}let c=new Ht(o,i),l=n.data.into??i.body;return c.inject({into:l,bind:t}),e.widgets.push(c),zt.log(`Widget bound to modal`,e.cleanupLoggedArgs(s),l,t),c}static handleMessageEvent(t){if(!t.data||typeof t.data!=`object`||t.data.type!==`OpenWidgetContent`)return;let n=t.data?.widgetId;if(!n||typeof n!=`string`){zt.error(`widgetId is required in the message event data`);return}let r=e.widgetOptions[n];if(!r){zt.error(`No widget options found for widgetId`,{widgetId:n});return}let i=null;try{i=new URL(r.baseURL).origin}catch{i=null}if(!i||t.origin!==i){zt.warn(`Ignoring OpenWidgetContent from unexpected origin`,{origin:t.origin,expectedOrigin:i});return}let{spotId:a,rootDocument:o,msCommunityWebBaseUrl:s}=Re.getConfiguration({spotId:r.spotId,rootDocument:r.rootDocument??document,msCommunityWebBaseUrl:r.baseURL}),{widgetContent:c}=e.createWidgetContent({...r,widgetContentId:t.data.widgetContentId,contentType:t.data.contentType,contentId:t.data.contentId,widgetId:n,spotId:a,rootDocument:o,baseURL:s});t.data.openingIn===`Drawer`?new Vt(c,o).open():t.data.openingIn===`Modal`&&new Ht(c,o).open()}static createWidget(t){let n=new URLSearchParams(window.location.search),r={spotId:t.spotId,widgetId:t.widgetId,authToken:t.authToken,themeMode:t.themeMode,domain:t.domain,rootDocument:t.rootDocument,baseURL:t.baseURL,utmParameters:t.utmParameters??Et(n)};return e.widgetOptions[r.widgetId]=r,e.messageListened||=(window.addEventListener(`message`,e.handleMessageEvent),!0),{widget:new Ut(r),args:r}}static createWidgetContent(e){let t=new URLSearchParams(window.location.search),n={spotId:e.spotId,contentId:e.contentId,contentType:e.contentType,widgetContentId:e.widgetContentId,widgetId:e.widgetId,authToken:e.authToken,themeMode:e.themeMode,domain:e.domain,rootDocument:e.rootDocument,baseURL:e.baseURL,utmParameters:e.utmParameters??Et(t)};return{widgetContent:new P(n),args:n}}static cleanupLoggedArgs(e){let{authToken:t,...n}=e;return{...n,authToken:t?`***`:void 0}}},Gt=globalThis;Gt.MeltingSpot||={},Gt.MeltingSpot.Widget=Wt,e.Drawer=Vt,e.Modal=Ht,e.Widget=Wt});
|
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.15.
|
|
6
|
+
"version": "1.15.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.15.
|
|
25
|
-
"@meltingspot/embed": "1.15.
|
|
24
|
+
"@meltingspot/core": "1.15.1",
|
|
25
|
+
"@meltingspot/embed": "1.15.1"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"provenance": false
|