@meltingspot/embed 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -15,6 +15,14 @@ Date: YYYY-MM-DD
15
15
 
16
16
  -->
17
17
 
18
+ ## v1.7.0
19
+
20
+ Date: 2026-08-10
21
+
22
+ ### Minor Changes
23
+
24
+ - Bump `@meltingspot/core` to `1.7.0`.
25
+
18
26
  ## v1.6.0
19
27
 
20
28
  Date: 2026-07-31
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@meltingspot/core"),L="1.6.0",l=new s.Logger({appName:"Embed SDK",appVersion:L});class g{constructor(e){this.content=e}#e=null;#t=null;set onRemove(e){this.#t=e}inject(e){this.remove();const i=s.getHTMLElement({input:e,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add("ms-embed"),i.appendChild(this.#e)}remove(){this.#e&&(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),this.#e=null)}}class D{constructor(e){this.baseURL=s.formatBaseUrl(e.baseURL),this.spotId=s.formatUUID(e.spotId),this.authToken=e.authToken??null,this.themeMode=e.themeMode??"auto",this.domain=e.domain??null,this.deeplink=e.deeplink?s.formatDeeplink({deeplink:e.deeplink,spotId:this.spotId}):null,this.utmParameters=e.utmParameters??null,this.rootDocument=e.rootDocument}get iframe(){const e=this.authToken&&this.authToken.trim().length>0?"/sso/jwt":"",i=new URL(`/spot/${this.spotId}${e}`,s.trimSlashRight(this.baseURL)),n=s.createIframe({url:i,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...s.flattenUtmParameters(this.utmParameters)},rootDocument:this.rootDocument});return n.classList.add("ms-spot"),n}}const m={READY:"meltingspot:ready",ERROR:"meltingspot:error",PREFILL_DRAFT:"meltingspot:prefillDraft"},t=class t{static injectSpotInto(e,i){const{onReady:n,onError:a,...o}=i,{spotId:u,rootDocument:E,msCommunityWebBaseUrl:k}=s.ConfigurationService.getConfiguration({spotId:o.spotId,rootDocument:o.rootDocument,msCommunityWebBaseUrl:o.baseURL});if(!u)throw l.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const d=new URLSearchParams(window.location.search),p={spotId:u,authToken:o.authToken??d.get("ms_token"),domain:o.domain,deeplink:o.deeplink??d.get("ms_url"),themeMode:o.themeMode,utmParameters:o.utmParameters??s.parseUtmParameters(d),baseURL:k,rootDocument:E},r=new g(new D(p));if(r.inject(e),t.embeds.push(r),n||a){const f=r.content.iframe.contentWindow;f&&(t.iframeCallbacks.set(f,{onReady:n,onError:a}),r.onRemove=R=>{t.iframeCallbacks.delete(R)}),t.ensureMessageListener()}return l.log("Spot injected",p,e),r}static clear(){t.embeds.forEach(e=>{e.remove()}),t.embeds=[],t.iframeCallbacks.clear(),t.messageListened&&(window.removeEventListener("message",t.handleMessageEvent),t.messageListened=!1),l.log("All MeltingSpot embeds cleared")}static handleMessageEvent(e){if(!e.data||typeof e.data!="object"||e.data.type!==m.READY&&e.data.type!==m.ERROR)return;const i=e.source,n=t.iframeCallbacks.get(i);if(!n)return;const{msCommunityWebBaseUrl:a}=s.ConfigurationService.getConfiguration({});if(a)try{const o=new URL(a).origin;if(e.origin!==o)return}catch{}e.data.type===m.READY?n.onReady?.():n.onError?.(e.data.error)}static ensureMessageListener(){t.messageListened||(window.addEventListener("message",t.handleMessageEvent),t.messageListened=!0)}};t.embeds=[],t.messageListened=!1,t.iframeCallbacks=new Map;let c=t;const h=globalThis;h.MeltingSpot||(h.MeltingSpot={});h.MeltingSpot.Embed=c;exports.EMBED_POST_MESSAGE_TYPE=m;exports.Embed=c;exports.EmbedFrame=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@meltingspot/core"),L="1.7.0",l=new s.Logger({appName:"Embed SDK",appVersion:L});class g{constructor(e){this.content=e}#e=null;#t=null;set onRemove(e){this.#t=e}inject(e){this.remove();const i=s.getHTMLElement({input:e,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add("ms-embed"),i.appendChild(this.#e)}remove(){this.#e&&(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),this.#e=null)}}class D{constructor(e){this.baseURL=s.formatBaseUrl(e.baseURL),this.spotId=s.formatUUID(e.spotId),this.authToken=e.authToken??null,this.themeMode=e.themeMode??"auto",this.domain=e.domain??null,this.deeplink=e.deeplink?s.formatDeeplink({deeplink:e.deeplink,spotId:this.spotId}):null,this.utmParameters=e.utmParameters??null,this.rootDocument=e.rootDocument}get iframe(){const e=this.authToken&&this.authToken.trim().length>0?"/sso/jwt":"",i=new URL(`/spot/${this.spotId}${e}`,s.trimSlashRight(this.baseURL)),n=s.createIframe({url:i,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...s.flattenUtmParameters(this.utmParameters)},rootDocument:this.rootDocument});return n.classList.add("ms-spot"),n}}const m={READY:"meltingspot:ready",ERROR:"meltingspot:error",PREFILL_DRAFT:"meltingspot:prefillDraft"},t=class t{static injectSpotInto(e,i){const{onReady:n,onError:a,...o}=i,{spotId:u,rootDocument:E,msCommunityWebBaseUrl:k}=s.ConfigurationService.getConfiguration({spotId:o.spotId,rootDocument:o.rootDocument,msCommunityWebBaseUrl:o.baseURL});if(!u)throw l.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const d=new URLSearchParams(window.location.search),p={spotId:u,authToken:o.authToken??d.get("ms_token"),domain:o.domain,deeplink:o.deeplink??d.get("ms_url"),themeMode:o.themeMode,utmParameters:o.utmParameters??s.parseUtmParameters(d),baseURL:k,rootDocument:E},r=new g(new D(p));if(r.inject(e),t.embeds.push(r),n||a){const f=r.content.iframe.contentWindow;f&&(t.iframeCallbacks.set(f,{onReady:n,onError:a}),r.onRemove=R=>{t.iframeCallbacks.delete(R)}),t.ensureMessageListener()}return l.log("Spot injected",p,e),r}static clear(){t.embeds.forEach(e=>{e.remove()}),t.embeds=[],t.iframeCallbacks.clear(),t.messageListened&&(window.removeEventListener("message",t.handleMessageEvent),t.messageListened=!1),l.log("All MeltingSpot embeds cleared")}static handleMessageEvent(e){if(!e.data||typeof e.data!="object"||e.data.type!==m.READY&&e.data.type!==m.ERROR)return;const i=e.source,n=t.iframeCallbacks.get(i);if(!n)return;const{msCommunityWebBaseUrl:a}=s.ConfigurationService.getConfiguration({});if(a)try{const o=new URL(a).origin;if(e.origin!==o)return}catch{}e.data.type===m.READY?n.onReady?.():n.onError?.(e.data.error)}static ensureMessageListener(){t.messageListened||(window.addEventListener("message",t.handleMessageEvent),t.messageListened=!0)}};t.embeds=[],t.messageListened=!1,t.iframeCallbacks=new Map;let c=t;const h=globalThis;h.MeltingSpot||(h.MeltingSpot={});h.MeltingSpot.Embed=c;exports.EMBED_POST_MESSAGE_TYPE=m;exports.Embed=c;exports.EmbedFrame=g;
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Logger as L, getHTMLElement as E, formatBaseUrl as w, formatUUID as D, formatDeeplink as I, trimSlashRight as U, createIframe as M, flattenUtmParameters as P, ConfigurationService as f, parseUtmParameters as S } from "@meltingspot/core";
2
- const C = "1.6.0", m = new L({ appName: "Embed SDK", appVersion: C });
2
+ const C = "1.7.0", m = new L({ appName: "Embed SDK", appVersion: C });
3
3
  class T {
4
4
  constructor(e) {
5
5
  this.content = e;
@@ -17,4 +17,4 @@ __p += '`),tn&&(y+=`' +
17
17
  function print() { __p += __j.call(arguments, '') }
18
18
  `:`;
19
19
  `)+y+`return __p
20
- }`;var Z=Ja(function(){return sn(f,D+"return "+y).apply(r,l)});if(Z.source=y,bu(Z))throw Z;return Z}function lm(n){return an(n).toLowerCase()}function hm(n){return an(n).toUpperCase()}function pm(n,e,t){if(n=an(n),n&&(t||e===r))return io(n);if(!n||!(e=ee(e)))return n;var i=ve(n),o=ve(e),f=uo(i,o),l=so(i,o)+1;return Ze(i,f,l).join("")}function dm(n,e,t){if(n=an(n),n&&(t||e===r))return n.slice(0,ao(n)+1);if(!n||!(e=ee(e)))return n;var i=ve(n),o=so(i,ve(e))+1;return Ze(i,0,o).join("")}function _m(n,e,t){if(n=an(n),n&&(t||e===r))return n.replace(bi,"");if(!n||!(e=ee(e)))return n;var i=ve(n),o=uo(i,ve(e));return Ze(i,o).join("")}function gm(n,e){var t=cn,i=rn;if(En(e)){var o="separator"in e?e.separator:o;t="length"in e?Q(e.length):t,i="omission"in e?ee(e.omission):i}n=an(n);var f=n.length;if(Tt(n)){var l=ve(n);f=l.length}if(t>=f)return n;var h=t-yt(i);if(h<1)return i;var g=l?Ze(l,0,h).join(""):n.slice(0,h);if(o===r)return g+i;if(l&&(h+=g.length-h),Su(o)){if(n.slice(h).search(o)){var w,T=g;for(o.global||(o=Ki(o.source,an(Rs.exec(o))+"g")),o.lastIndex=0;w=o.exec(T);)var y=w.index;g=g.slice(0,y===r?h:y)}}else if(n.indexOf(ee(o),h)!=h){var R=g.lastIndexOf(o);R>-1&&(g=g.slice(0,R))}return g+i}function mm(n){return n=an(n),n&&xc.test(n)?n.replace(As,ql):n}var vm=Lt(function(n,e,t){return n+(t?" ":"")+e.toUpperCase()}),$u=Xo("toUpperCase");function Za(n,e,t){return n=an(n),e=t?r:e,e===r?kl(n)?Zl(n):Dl(n):n.match(e)||[]}var Ja=J(function(n,e){try{return jn(n,r,e)}catch(t){return bu(t)?t:new W(t)}}),Em=Ue(function(n,e){return oe(e,function(t){t=Me(t),Ne(n,t,xu(n[t],n))}),n});function wm(n){var e=n==null?0:n.length,t=U();return n=e?_n(n,function(i){if(typeof i[1]!="function")throw new ae(d);return[t(i[0]),i[1]]}):[],J(function(i){for(var o=-1;++o<e;){var f=n[o];if(jn(f[0],this,i))return jn(f[1],this,i)}})}function Tm(n){return qh(ce(n,N))}function Uu(n){return function(){return n}}function ym(n,e){return n==null||n!==n?e:n}var Am=jo(),Im=jo(!0);function Qn(n){return n}function Pu(n){return Lo(typeof n=="function"?n:ce(n,N))}function Om(n){return So(ce(n,N))}function Rm(n,e){return Do(n,ce(e,N))}var Mm=J(function(n,e){return function(t){return Zt(t,n,e)}}),xm=J(function(n,e){return function(t){return Zt(n,t,e)}});function Fu(n,e,t){var i=Nn(e),o=zr(e,i);t==null&&!(En(e)&&(o.length||!i.length))&&(t=e,e=n,n=this,o=zr(e,Nn(e)));var f=!(En(t)&&"chain"in t)||!!t.chain,l=Fe(n);return oe(o,function(h){var g=e[h];n[h]=g,l&&(n.prototype[h]=function(){var w=this.__chain__;if(f||w){var T=n(this.__wrapped__),y=T.__actions__=zn(this.__actions__);return y.push({func:g,args:arguments,thisArg:n}),T.__chain__=w,T}return g.apply(n,Be([this.value()],arguments))})}),n}function Lm(){return Pn._===this&&(Pn._=eh),this}function Yu(){}function bm(n){return n=Q(n),J(function(e){return No(e,n)})}var Sm=_u(_n),Dm=_u(js),Nm=_u(Hi);function Xa(n){return yu(n)?ki(Me(n)):fp(n)}function $m(n){return function(e){return n==null?r:ot(n,e)}}var Um=ea(),Pm=ea(!0);function Cu(){return[]}function Hu(){return!1}function Fm(){return{}}function Ym(){return""}function Cm(){return!0}function Hm(n,e){if(n=Q(n),n<1||n>O)return[];var t=X,i=Cn(n,X);e=U(e),n-=X;for(var o=Gi(i,e);++t<n;)e(t);return o}function km(n){return z(n)?_n(n,Me):te(n)?[n]:zn(ma(an(n)))}function Wm(n){var e=++jl;return an(n)+e}var Bm=Xr(function(n,e){return n+e},0),Gm=gu("ceil"),zm=Xr(function(n,e){return n/e},1),qm=gu("floor");function Km(n){return n&&n.length?Gr(n,Qn,eu):r}function Qm(n,e){return n&&n.length?Gr(n,U(e,2),eu):r}function Zm(n){return to(n,Qn)}function Jm(n,e){return to(n,U(e,2))}function Xm(n){return n&&n.length?Gr(n,Qn,uu):r}function Vm(n,e){return n&&n.length?Gr(n,U(e,2),uu):r}var jm=Xr(function(n,e){return n*e},1),n0=gu("round"),e0=Xr(function(n,e){return n-e},0);function t0(n){return n&&n.length?Bi(n,Qn):0}function r0(n,e){return n&&n.length?Bi(n,U(e,2)):0}return a.after=O_,a.ary=xa,a.assign=hg,a.assignIn=Wa,a.assignInWith=ci,a.assignWith=pg,a.at=dg,a.before=La,a.bind=xu,a.bindAll=Em,a.bindKey=ba,a.castArray=F_,a.chain=Oa,a.chunk=qp,a.compact=Kp,a.concat=Qp,a.cond=wm,a.conforms=Tm,a.constant=Uu,a.countBy=t_,a.create=_g,a.curry=Sa,a.curryRight=Da,a.debounce=Na,a.defaults=gg,a.defaultsDeep=mg,a.defer=R_,a.delay=M_,a.difference=Zp,a.differenceBy=Jp,a.differenceWith=Xp,a.drop=Vp,a.dropRight=jp,a.dropRightWhile=nd,a.dropWhile=ed,a.fill=td,a.filter=i_,a.flatMap=o_,a.flatMapDeep=a_,a.flatMapDepth=f_,a.flatten=Ta,a.flattenDeep=rd,a.flattenDepth=id,a.flip=x_,a.flow=Am,a.flowRight=Im,a.fromPairs=ud,a.functions=Ig,a.functionsIn=Og,a.groupBy=c_,a.initial=od,a.intersection=ad,a.intersectionBy=fd,a.intersectionWith=cd,a.invert=Mg,a.invertBy=xg,a.invokeMap=h_,a.iteratee=Pu,a.keyBy=p_,a.keys=Nn,a.keysIn=Kn,a.map=ii,a.mapKeys=bg,a.mapValues=Sg,a.matches=Om,a.matchesProperty=Rm,a.memoize=si,a.merge=Dg,a.mergeWith=Ba,a.method=Mm,a.methodOf=xm,a.mixin=Fu,a.negate=oi,a.nthArg=bm,a.omit=Ng,a.omitBy=$g,a.once=L_,a.orderBy=d_,a.over=Sm,a.overArgs=b_,a.overEvery=Dm,a.overSome=Nm,a.partial=Lu,a.partialRight=$a,a.partition=__,a.pick=Ug,a.pickBy=Ga,a.property=Xa,a.propertyOf=$m,a.pull=dd,a.pullAll=Aa,a.pullAllBy=_d,a.pullAllWith=gd,a.pullAt=md,a.range=Um,a.rangeRight=Pm,a.rearg=S_,a.reject=v_,a.remove=vd,a.rest=D_,a.reverse=Ru,a.sampleSize=w_,a.set=Fg,a.setWith=Yg,a.shuffle=T_,a.slice=Ed,a.sortBy=I_,a.sortedUniq=Rd,a.sortedUniqBy=Md,a.split=om,a.spread=N_,a.tail=xd,a.take=Ld,a.takeRight=bd,a.takeRightWhile=Sd,a.takeWhile=Dd,a.tap=Kd,a.throttle=$_,a.thru=ri,a.toArray=Ca,a.toPairs=za,a.toPairsIn=qa,a.toPath=km,a.toPlainObject=ka,a.transform=Cg,a.unary=U_,a.union=Nd,a.unionBy=$d,a.unionWith=Ud,a.uniq=Pd,a.uniqBy=Fd,a.uniqWith=Yd,a.unset=Hg,a.unzip=Mu,a.unzipWith=Ia,a.update=kg,a.updateWith=Wg,a.values=Dt,a.valuesIn=Bg,a.without=Cd,a.words=Za,a.wrap=P_,a.xor=Hd,a.xorBy=kd,a.xorWith=Wd,a.zip=Bd,a.zipObject=Gd,a.zipObjectDeep=zd,a.zipWith=qd,a.entries=za,a.entriesIn=qa,a.extend=Wa,a.extendWith=ci,Fu(a,a),a.add=Bm,a.attempt=Ja,a.camelCase=Kg,a.capitalize=Ka,a.ceil=Gm,a.clamp=Gg,a.clone=Y_,a.cloneDeep=H_,a.cloneDeepWith=k_,a.cloneWith=C_,a.conformsTo=W_,a.deburr=Qa,a.defaultTo=ym,a.divide=zm,a.endsWith=Qg,a.eq=we,a.escape=Zg,a.escapeRegExp=Jg,a.every=r_,a.find=u_,a.findIndex=Ea,a.findKey=vg,a.findLast=s_,a.findLastIndex=wa,a.findLastKey=Eg,a.floor=qm,a.forEach=Ra,a.forEachRight=Ma,a.forIn=wg,a.forInRight=Tg,a.forOwn=yg,a.forOwnRight=Ag,a.get=Du,a.gt=B_,a.gte=G_,a.has=Rg,a.hasIn=Nu,a.head=ya,a.identity=Qn,a.includes=l_,a.indexOf=sd,a.inRange=zg,a.invoke=Lg,a.isArguments=ct,a.isArray=z,a.isArrayBuffer=z_,a.isArrayLike=qn,a.isArrayLikeObject=yn,a.isBoolean=q_,a.isBuffer=Je,a.isDate=K_,a.isElement=Q_,a.isEmpty=Z_,a.isEqual=J_,a.isEqualWith=X_,a.isError=bu,a.isFinite=V_,a.isFunction=Fe,a.isInteger=Ua,a.isLength=ai,a.isMap=Pa,a.isMatch=j_,a.isMatchWith=ng,a.isNaN=eg,a.isNative=tg,a.isNil=ig,a.isNull=rg,a.isNumber=Fa,a.isObject=En,a.isObjectLike=wn,a.isPlainObject=er,a.isRegExp=Su,a.isSafeInteger=ug,a.isSet=Ya,a.isString=fi,a.isSymbol=te,a.isTypedArray=St,a.isUndefined=sg,a.isWeakMap=og,a.isWeakSet=ag,a.join=ld,a.kebabCase=Xg,a.last=he,a.lastIndexOf=hd,a.lowerCase=Vg,a.lowerFirst=jg,a.lt=fg,a.lte=cg,a.max=Km,a.maxBy=Qm,a.mean=Zm,a.meanBy=Jm,a.min=Xm,a.minBy=Vm,a.stubArray=Cu,a.stubFalse=Hu,a.stubObject=Fm,a.stubString=Ym,a.stubTrue=Cm,a.multiply=jm,a.nth=pd,a.noConflict=Lm,a.noop=Yu,a.now=ui,a.pad=nm,a.padEnd=em,a.padStart=tm,a.parseInt=rm,a.random=qg,a.reduce=g_,a.reduceRight=m_,a.repeat=im,a.replace=um,a.result=Pg,a.round=n0,a.runInContext=p,a.sample=E_,a.size=y_,a.snakeCase=sm,a.some=A_,a.sortedIndex=wd,a.sortedIndexBy=Td,a.sortedIndexOf=yd,a.sortedLastIndex=Ad,a.sortedLastIndexBy=Id,a.sortedLastIndexOf=Od,a.startCase=am,a.startsWith=fm,a.subtract=e0,a.sum=t0,a.sumBy=r0,a.template=cm,a.times=Hm,a.toFinite=Ye,a.toInteger=Q,a.toLength=Ha,a.toLower=lm,a.toNumber=pe,a.toSafeInteger=lg,a.toString=an,a.toUpper=hm,a.trim=pm,a.trimEnd=dm,a.trimStart=_m,a.truncate=gm,a.unescape=mm,a.uniqueId=Wm,a.upperCase=vm,a.upperFirst=$u,a.each=Ra,a.eachRight=Ma,a.first=ya,Fu(a,(function(){var n={};return Oe(a,function(e,t){fn.call(a.prototype,t)||(n[t]=e)}),n})(),{chain:!1}),a.VERSION=c,oe(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){a[n].placeholder=a}),oe(["drop","take"],function(n,e){j.prototype[n]=function(t){t=t===r?1:Sn(Q(t),0);var i=this.__filtered__&&!e?new j(this):this.clone();return i.__filtered__?i.__takeCount__=Cn(t,i.__takeCount__):i.__views__.push({size:Cn(t,X),type:n+(i.__dir__<0?"Right":"")}),i},j.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),oe(["filter","map","takeWhile"],function(n,e){var t=e+1,i=t==Y||t==M;j.prototype[n]=function(o){var f=this.clone();return f.__iteratees__.push({iteratee:U(o,3),type:t}),f.__filtered__=f.__filtered__||i,f}}),oe(["head","last"],function(n,e){var t="take"+(e?"Right":"");j.prototype[n]=function(){return this[t](1).value()[0]}}),oe(["initial","tail"],function(n,e){var t="drop"+(e?"":"Right");j.prototype[n]=function(){return this.__filtered__?new j(this):this[t](1)}}),j.prototype.compact=function(){return this.filter(Qn)},j.prototype.find=function(n){return this.filter(n).head()},j.prototype.findLast=function(n){return this.reverse().find(n)},j.prototype.invokeMap=J(function(n,e){return typeof n=="function"?new j(this):this.map(function(t){return Zt(t,n,e)})}),j.prototype.reject=function(n){return this.filter(oi(U(n)))},j.prototype.slice=function(n,e){n=Q(n);var t=this;return t.__filtered__&&(n>0||e<0)?new j(t):(n<0?t=t.takeRight(-n):n&&(t=t.drop(n)),e!==r&&(e=Q(e),t=e<0?t.dropRight(-e):t.take(e-n)),t)},j.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},j.prototype.toArray=function(){return this.take(X)},Oe(j.prototype,function(n,e){var t=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),o=a[i?"take"+(e=="last"?"Right":""):e],f=i||/^find/.test(e);o&&(a.prototype[e]=function(){var l=this.__wrapped__,h=i?[1]:arguments,g=l instanceof j,w=h[0],T=g||z(l),y=function(V){var tn=o.apply(a,Be([V],h));return i&&R?tn[0]:tn};T&&t&&typeof w=="function"&&w.length!=1&&(g=T=!1);var R=this.__chain__,D=!!this.__actions__.length,P=f&&!R,Z=g&&!D;if(!f&&T){l=Z?l:new j(this);var F=n.apply(l,h);return F.__actions__.push({func:ri,args:[y],thisArg:r}),new fe(F,R)}return P&&Z?n.apply(this,h):(F=this.thru(y),P?i?F.value()[0]:F.value():F)})}),oe(["pop","push","shift","sort","splice","unshift"],function(n){var e=Lr[n],t=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",i=/^(?:pop|shift)$/.test(n);a.prototype[n]=function(){var o=arguments;if(i&&!this.__chain__){var f=this.value();return e.apply(z(f)?f:[],o)}return this[t](function(l){return e.apply(z(l)?l:[],o)})}}),Oe(j.prototype,function(n,e){var t=a[e];if(t){var i=t.name+"";fn.call(Rt,i)||(Rt[i]=[]),Rt[i].push({name:e,func:t})}}),Rt[Jr(r,hn).name]=[{name:"wrapper",func:r}],j.prototype.clone=mh,j.prototype.reverse=vh,j.prototype.value=Eh,a.prototype.at=Qd,a.prototype.chain=Zd,a.prototype.commit=Jd,a.prototype.next=Xd,a.prototype.plant=jd,a.prototype.reverse=n_,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=e_,a.prototype.first=a.prototype.head,Wt&&(a.prototype[Wt]=Vd),a}),At=Jl();tt?((tt.exports=At)._=At,Pi._=At):Pn._=At}).call(Bf)})(Ut,Ut.exports)),Ut.exports}Gf();const zf="1.6.0";class ss{constructor(u){this.debug=!1,this.debug=u?.debug??!1,this.appName=u?.appName,this.appVersion=u?.appVersion}log(u,...r){this.debug&&this.print(u,"info",r)}warn(u,...r){this.print(u,"warn",r)}error(u,...r){this.print(u,"error",r)}print(u,r,c){const d=[`[${["MeltingSpot",this.appName,this.appVersion].filter(Boolean).join(" - ")}] ${u}`];c.length&&d.push(...c),console[r](...d)}}const qf=new ss({appName:"Core SDK",appVersion:zf}),Kf=s=>s.toLowerCase().replace(/[^a-z0-9-]/g,""),Qf=["/user"],Zf=({deeplink:s,spotId:u})=>{try{const r=new URL(s,"https://unused.com");let c=r.pathname;return r.search&&(c+=r.search),r.hash&&(c+=r.hash),Qf.some(_=>c.startsWith(_))||(c=`/spot/${u}/${sf(c)}`),c}catch(r){return qf.warn("Failed to parse deeplink URL",r),null}},Jf=[/(^|\.)meltingspot\.io$/i],Xf=s=>{let u;try{const v=qu(s);u=new URL(v)}catch{throw new Error(`Invalid baseURL: ${s}`)}const r=u.hostname==="localhost"||u.hostname==="127.0.0.1",c=u.protocol==="https:",_=Jf.some(v=>v.test(u.hostname));if(!r&&(!c||!_))throw new Error(`Untrusted baseURL origin: ${u.origin}`);return u.origin},Vf={msApiBaseUrl:"https://openapi.meltingspot.io/",msCommunityWebBaseUrl:"https://go.meltingspot.io/",ssoToken:void 0,spotId:"",autoJoin:!1,rootDocument:globalThis.document};class Jn{constructor(){this.configuration=Vf}static getInstance(){return Jn.instance||(Jn.instance=new Jn),Jn.instance}setConfiguration(u){this.configuration={...this.configuration,...u}}static getConfiguration(u={}){return{...Jn.getInstance().configuration,...u}}}const os="%[a-f0-9]{2}",as=new RegExp("("+os+")|([^%]+?)","gi"),fs=new RegExp("("+os+")+","gi");function pi(s,u){try{return[decodeURIComponent(s.join(""))]}catch{}if(s.length===1)return s;u=u||1;const r=s.slice(0,u),c=s.slice(u);return Array.prototype.concat.call([],pi(r),pi(c))}function jf(s){try{return decodeURIComponent(s)}catch{let u=s.match(as)||[];for(let r=1;r<u.length;r++)s=pi(u,r).join(""),u=s.match(as)||[];return s}}function nc(s){const u={"%FE%FF":"��","%FF%FE":"��"};let r=fs.exec(s);for(;r;){try{u[r[0]]=decodeURIComponent(r[0])}catch{const _=jf(r[0]);_!==r[0]&&(u[r[0]]=_)}r=fs.exec(s)}u["%C2"]="�";const c=Object.keys(u);for(const _ of c)s=s.replace(new RegExp(_,"g"),u[_]);return s}function ec(s){if(typeof s!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof s+"`");try{return decodeURIComponent(s)}catch{return nc(s)}}function tc(s,u){const r={};if(Array.isArray(u))for(const c of u){const _=Object.getOwnPropertyDescriptor(s,c);_?.enumerable&&Object.defineProperty(r,c,_)}else for(const c of Reflect.ownKeys(s)){const _=Object.getOwnPropertyDescriptor(s,c);if(_.enumerable){const v=s[c];u(c,v,s)&&Object.defineProperty(r,c,_)}}return r}function cs(s,u){if(!(typeof s=="string"&&typeof u=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(s===""||u==="")return[];const r=s.indexOf(u);return r===-1?[]:[s.slice(0,r),s.slice(r+u.length)]}const rc=s=>s==null,ic=s=>encodeURIComponent(s).replaceAll(/[!'()*]/g,u=>`%${u.charCodeAt(0).toString(16).toUpperCase()}`),di=Symbol("encodeFragmentIdentifier");function uc(s){switch(s.arrayFormat){case"index":return u=>(r,c)=>{const _=r.length;return c===void 0||s.skipNull&&c===null||s.skipEmptyString&&c===""?r:c===null?[...r,[In(u,s),"[",_,"]"].join("")]:[...r,[In(u,s),"[",In(_,s),"]=",In(c,s)].join("")]};case"bracket":return u=>(r,c)=>c===void 0||s.skipNull&&c===null||s.skipEmptyString&&c===""?r:c===null?[...r,[In(u,s),"[]"].join("")]:[...r,[In(u,s),"[]=",In(c,s)].join("")];case"colon-list-separator":return u=>(r,c)=>c===void 0||s.skipNull&&c===null||s.skipEmptyString&&c===""?r:c===null?[...r,[In(u,s),":list="].join("")]:[...r,[In(u,s),":list=",In(c,s)].join("")];case"comma":case"separator":case"bracket-separator":{const u=s.arrayFormat==="bracket-separator"?"[]=":"=";return r=>(c,_)=>_===void 0||s.skipNull&&_===null||s.skipEmptyString&&_===""?c:(_=_===null?"":_,c.length===0?[[In(r,s),u,In(_,s)].join("")]:[[c,In(_,s)].join(s.arrayFormatSeparator)])}default:return u=>(r,c)=>c===void 0||s.skipNull&&c===null||s.skipEmptyString&&c===""?r:c===null?[...r,In(u,s)]:[...r,[In(u,s),"=",In(c,s)].join("")]}}function sc(s){let u;switch(s.arrayFormat){case"index":return(r,c,_)=>{if(u=/\[(\d*)]$/.exec(r),r=r.replace(/\[\d*]$/,""),!u){_[r]=c;return}_[r]===void 0&&(_[r]={}),_[r][u[1]]=c};case"bracket":return(r,c,_)=>{if(u=/(\[])$/.exec(r),r=r.replace(/\[]$/,""),!u){_[r]=c;return}if(_[r]===void 0){_[r]=[c];return}_[r]=[..._[r],c]};case"colon-list-separator":return(r,c,_)=>{if(u=/(:list)$/.exec(r),r=r.replace(/:list$/,""),!u){_[r]=c;return}if(_[r]===void 0){_[r]=[c];return}_[r]=[..._[r],c]};case"comma":case"separator":return(r,c,_)=>{const v=typeof c=="string"&&c.includes(s.arrayFormatSeparator),d=typeof c=="string"&&!v&&xe(c,s).includes(s.arrayFormatSeparator);c=d?xe(c,s):c;const A=v||d?c.split(s.arrayFormatSeparator).map(I=>xe(I,s)):c===null?c:xe(c,s);_[r]=A};case"bracket-separator":return(r,c,_)=>{const v=/(\[])$/.test(r);if(r=r.replace(/\[]$/,""),!v){_[r]=c&&xe(c,s);return}const d=c===null?[]:xe(c,s).split(s.arrayFormatSeparator);if(_[r]===void 0){_[r]=d;return}_[r]=[..._[r],...d]};default:return(r,c,_)=>{if(_[r]===void 0){_[r]=c;return}_[r]=[...[_[r]].flat(),c]}}}function ls(s){if(typeof s!="string"||s.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function In(s,u){return u.encode?u.strict?ic(s):encodeURIComponent(s):s}function xe(s,u){return u.decode?ec(s):s}function hs(s){return Array.isArray(s)?s.sort():typeof s=="object"?hs(Object.keys(s)).sort((u,r)=>Number(u)-Number(r)).map(u=>s[u]):s}function ps(s){const u=s.indexOf("#");return u!==-1&&(s=s.slice(0,u)),s}function oc(s){let u="";const r=s.indexOf("#");return r!==-1&&(u=s.slice(r)),u}function ds(s,u,r){return r==="string"&&typeof s=="string"?s:typeof r=="function"&&typeof s=="string"?r(s):r==="boolean"&&s===null?!0:r==="boolean"&&s!==null&&(s.toLowerCase()==="true"||s.toLowerCase()==="false")?s.toLowerCase()==="true":r==="boolean"&&s!==null&&(s.toLowerCase()==="1"||s.toLowerCase()==="0")?s.toLowerCase()==="1":r==="string[]"&&u.arrayFormat!=="none"&&typeof s=="string"?[s]:r==="number[]"&&u.arrayFormat!=="none"&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?[Number(s)]:r==="number"&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?Number(s):u.parseBooleans&&s!==null&&(s.toLowerCase()==="true"||s.toLowerCase()==="false")?s.toLowerCase()==="true":u.parseNumbers&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?Number(s):s}function _i(s){s=ps(s);const u=s.indexOf("?");return u===-1?"":s.slice(u+1)}function gi(s,u){u={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...u},ls(u.arrayFormatSeparator);const r=sc(u),c=Object.create(null);if(typeof s!="string"||(s=s.trim().replace(/^[?#&]/,""),!s))return c;for(const _ of s.split("&")){if(_==="")continue;const v=u.decode?_.replaceAll("+"," "):_;let[d,A]=cs(v,"=");d===void 0&&(d=v),A=A===void 0?null:["comma","separator","bracket-separator"].includes(u.arrayFormat)?A:xe(A,u),r(xe(d,u),A,c)}for(const[_,v]of Object.entries(c))if(typeof v=="object"&&v!==null&&u.types[_]!=="string")for(const[d,A]of Object.entries(v)){const I=u.types[_]?u.types[_].replace("[]",""):void 0;v[d]=ds(A,u,I)}else typeof v=="object"&&v!==null&&u.types[_]==="string"?c[_]=Object.values(v).join(u.arrayFormatSeparator):c[_]=ds(v,u,u.types[_]);return u.sort===!1?c:(u.sort===!0?Object.keys(c).sort():Object.keys(c).sort(u.sort)).reduce((_,v)=>{const d=c[v];return _[v]=d&&typeof d=="object"&&!Array.isArray(d)?hs(d):d,_},Object.create(null))}function _s(s,u){if(!s)return"";u={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...u},ls(u.arrayFormatSeparator);const r=d=>u.skipNull&&rc(s[d])||u.skipEmptyString&&s[d]==="",c=uc(u),_={};for(const[d,A]of Object.entries(s))r(d)||(_[d]=A);const v=Object.keys(_);return u.sort!==!1&&v.sort(u.sort),v.map(d=>{const A=s[d];return A===void 0?"":A===null?In(d,u):Array.isArray(A)?A.length===0&&u.arrayFormat==="bracket-separator"?In(d,u)+"[]":A.reduce(c(d),[]).join("&"):In(d,u)+"="+In(A,u)}).filter(d=>d.length>0).join("&")}function gs(s,u){u={decode:!0,...u};let[r,c]=cs(s,"#");return r===void 0&&(r=s),{url:r?.split("?")?.[0]??"",query:gi(_i(s),u),...u&&u.parseFragmentIdentifier&&c?{fragmentIdentifier:xe(c,u)}:{}}}function ms(s,u){u={encode:!0,strict:!0,[di]:!0,...u};const r=ps(s.url).split("?")[0]||"",c=_i(s.url),_={...gi(c,{sort:!1,...u}),...s.query};let v=_s(_,u);v&&=`?${v}`;let d=oc(s.url);if(typeof s.fragmentIdentifier=="string"){const A=new URL(r);A.hash=s.fragmentIdentifier,d=u[di]?A.hash:`#${s.fragmentIdentifier}`}return`${r}${v}${d}`}function vs(s,u,r){r={parseFragmentIdentifier:!0,[di]:!1,...r};const{url:c,query:_,fragmentIdentifier:v}=gs(s,r);return ms({url:c,query:tc(_,u),fragmentIdentifier:v},r)}function ac(s,u,r){const c=Array.isArray(u)?_=>!u.includes(_):(_,v)=>!u(_,v);return vs(s,c,r)}const fc=Object.freeze(Object.defineProperty({__proto__:null,exclude:ac,extract:_i,parse:gi,parseUrl:gs,pick:vs,stringify:_s,stringifyUrl:ms},Symbol.toStringTag,{value:"Module"}));class Gn extends Error{constructor(u,r){super(`HTTP Error ${u}${r?`: ${r}`:""}`),this.code=u,this.name="HttpError",Object.setPrototypeOf(this,Gn.prototype)}}var On=(s=>(s.GET="GET",s.PATCH="PATCH",s.POST="POST",s))(On||{});class cc{constructor(){this.headers={}}setHeaders(u){this.headers=u}async get(u){try{const r=u.query?`${u.url}?${this.serializeQuery(u.query)}`:u.url,c=await fetch(r,{headers:{...this.headers,...u.headers,"Content-Type":"application/json"},...u.signal?{signal:u.signal}:{}});return c.ok?un(await c.json()):B(new Gn(c.status,await c.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return B(new Gn(ue.INTERNAL_SERVER_ERROR,c))}}async post(u){try{const r=await fetch(u.url,{method:"POST",headers:{...this.headers,...u.headers,"Content-Type":"application/json"},body:JSON.stringify(u.payload),...u.signal?{signal:u.signal}:{}});return r.ok?un(await r.json()):B(new Gn(r.status,await r.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return B(new Gn(ue.INTERNAL_SERVER_ERROR,c))}}async patch(u){try{const r=await fetch(u.url,{method:"PATCH",headers:{...this.headers,...u.headers,"Content-Type":"application/json"},body:JSON.stringify(u.payload),...u.signal?{signal:u.signal}:{}});return r.ok?un(await r.json()):B(new Gn(r.status,await r.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return B(new Gn(ue.INTERNAL_SERVER_ERROR,c))}}serializeQuery(u){if(typeof u=="string")return u;if(typeof u=="object")for(const r in u)u[r]===void 0&&delete u[r];return u=fc.stringify(u,{arrayFormat:"none"}),u}}const mr={accessToken:{email:"/v1/auth/accessToken/email",sso:{jwt:"/v1/auth/accessToken/sso/jwt"}},refreshAccessToken:"/v1/auth/accessToken~refresh",password:{reset:"/v1/auth/password~reset"}};class ke extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return ke.instance||(ke.instance=new ke),ke.instance}async loginWithPassword(u,r){const c=await this.callApi({endpoint:mr.accessToken.email,method:"POST",body:{email:u,password:r},withSpotId:!0});if(c.isErr())return B(c.error);const{accessToken:_,refreshToken:v}=c.value;return this.setTokens(_.token,v.token),un({accessToken:_.token,refreshToken:v.token})}async loginWithSsoToken(u){const r=await this.callApi({endpoint:mr.accessToken.sso.jwt,method:"POST",body:{token:u},withSpotId:!0});if(r.isErr())return B(r.error);const{accessToken:c,refreshToken:_}=r.value;return this.setTokens(c.token,_.token),un({accessToken:c.token,refreshToken:_.token})}loginWithAuthTokens(u,r){return this.setTokens(u,r),{accessToken:u,refreshToken:r}}resetPassword(u){return this.callApi({endpoint:mr.password.reset,method:"POST",body:{email:u}})}async refresh(){const u=await this.callApi({endpoint:mr.refreshAccessToken,method:"POST",body:{refreshToken:this.refreshToken}});if(u.isErr())return B(u.error);const{accessToken:r,refreshToken:c}=u.value;return this.setTokens(r.token,c.token),un({accessToken:r.token,refreshToken:c.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(u,r){if(this.accessToken!==u||this.refreshToken!==r){this.accessToken=u,this.refreshToken=r;const c=new CustomEvent("auth:tokens-updated",{detail:{accessToken:u,refreshToken:r}});this.dispatchEvent(c)}}async callApi(u){try{const{spotId:r,msApiBaseUrl:c}=Jn.getConfiguration(),_=hi(u.endpoint,c),v={"Content-Type":"application/json",...u.headers};u.withSpotId&&r&&(v[Es.SpotId]=r);const d=await fetch(_,{method:u.method,body:u.body?JSON.stringify(u.body):void 0,headers:v});if(!d.ok)return B(new Gn(d.status,d.statusText));if(d.status===ue.NO_CONTENT)return un(void 0);const A=await d.json();return un(A)}catch(r){return B(new Gn(ue.INTERNAL_SERVER_ERROR,r instanceof Error?r.message:String(r)))}}}var Es=(s=>(s.Authorization="Authorization",s.SpotId="x-spotid",s))(Es||{});class ye{constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=ke.getInstance(),this.httpService=new cc}static getInstance(){return ye.instance||(ye.instance=new ye),ye.instance}static buildAuthenticatedRequest(u){const{msApiBaseUrl:r,spotId:c}=Jn.getConfiguration(),_=hi(u,r),v=ke.getInstance().getAccessToken();if(!v)return B(new Error("Not authenticated"));const d={"Content-Type":"application/json",Authorization:`Bearer ${v}`};return c&&(d["x-spotid"]=c),un({url:_,headers:d})}static async stream(u,r,c){const{streamTransport:_}=Jn.getConfiguration();if(_)return _({endpoint:u,body:r,signal:c});const v=ye.buildAuthenticatedRequest(u);if(v.isErr())return B(v.error);const{url:d,headers:A}=v.value;try{const I=await fetch(d,{method:"POST",headers:A,...r!==void 0?{body:JSON.stringify(r)}:{},...c?{signal:c}:{}});if(!I.ok){const H=await I.text();return B(new Error(`HTTP ${I.status}: ${H}`))}return I.body?un(I.body):B(new Error("Response body is empty"))}catch(I){const H=I instanceof Error?I.message:"Unknown error";return B(I instanceof Error?I:new Error(H))}}get pendingCount(){return this.queue.length}enqueue(u){return new Promise(r=>{const c=async()=>{try{const _=await u();r(_)}catch(_){r(B(new Gn(ue.INTERNAL_SERVER_ERROR,_ instanceof Error?_.message:"Unknown error")))}};this.queue.push(c),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){const u=this.queue.shift();if(!u)break;await u()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){const u=this.isPaused;this.isPaused=!1,u&&this.processQueue()}async call(u){return this.enqueue(async()=>{const r=async()=>{const{spotId:_,msApiBaseUrl:v}=Jn.getConfiguration(),d={...u.options?.headers??{}};_&&(d["x-spotid"]=_);const A=this.authService.getAccessToken(),{requiresAuth:I=!0}=u;if(!A&&I)return B(new Gn(ue.UNAUTHORIZED));A&&(d.Authorization=`Bearer ${A}`);const H=hi(u.endpoint,v);switch(u.method){case On.GET:return this.httpService.get({...u.options??{},headers:d,url:H});case On.PATCH:return this.httpService.patch({...u.options??{},headers:d,url:H});case On.POST:return this.httpService.post({...u.options??{},headers:d,url:H});default:return B(new Gn(ue.METHOD_NOT_ALLOWED,"Method not allowed"))}};let c=await r();if(c.isErr()&&c.error.code===ue.UNAUTHORIZED){const _=await this.authService.refresh();if(_.isErr())return B(new Gn(ue.UNAUTHORIZED,_.error.message));c=await r()}return c})}}const Ae={playbooks:"/v1/playbooks",pages:s=>`/v1/playbooks/${s}/pages`,hotspots:(s,u)=>`/v1/playbooks/${s}/pages/${u}/hotspots`,hotspot:(s,u,r)=>`/v1/playbooks/${s}/pages/${u}/hotspots/${r}`,accessibleIntents:(s,u)=>`/v1/playbooks/${s}/pages/${u}/accessibleIntents`,intents:(s,u,r)=>`/v1/playbooks/${s}/pages/${u}/hotspots/${r}/intents`,intent:(s,u,r,c)=>`/v1/playbooks/${s}/pages/${u}/hotspots/${r}/intents/${c}`},vr=50;class lt{static getInstance(){return lt.instance||(lt.instance=new lt),lt.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async listPlaybooks(u){const r=await this.meltingSpotApi.call({method:On.GET,endpoint:Ae.playbooks,options:{query:{page:u?.page??1,limit:u?.limit??vr,...u?.domain?{"domain[eq]":u.domain}:{}}}});return r.isErr()?B(r.error):un(r.value)}async listPlaybookPages(u){const r=await this.meltingSpotApi.call({method:On.GET,endpoint:Ae.pages(u.playbookId),options:{query:{page:u.page??1,limit:u.limit??vr,...u.url?{"url[eq]":u.url}:{}}}});return r.isErr()?B(r.error):un(r.value)}async createPlaybookPage(u,r){const c=await this.meltingSpotApi.call({method:On.POST,endpoint:Ae.pages(u.playbookId),options:{payload:r}});return c.isErr()?B(c.error):un(c.value)}async listAccessiblePlaybookIntents(u){const r=await this.meltingSpotApi.call({method:On.GET,endpoint:Ae.accessibleIntents(u.playbookId,u.pageId),options:{query:{...u.domain?{domain:u.domain}:{}}}});return r.isErr()?B(r.error):un(r.value)}async listPlaybookHotspots(u){const r=await this.meltingSpotApi.call({method:On.GET,endpoint:Ae.hotspots(u.playbookId,u.pageId),options:{query:{page:u.page??1,limit:u.limit??vr,...u.intentStatus?{"intentStatus[eq]":u.intentStatus}:{},...u.widgetType?{"widgetType[eq]":u.widgetType}:{}}}});return r.isErr()?B(r.error):un(r.value)}async createPlaybookHotspot(u,r){const c=await this.meltingSpotApi.call({method:On.POST,endpoint:Ae.hotspots(u.playbookId,u.pageId),options:{payload:r}});return c.isErr()?B(c.error):un(c.value)}async updatePlaybookHotspot(u,r){const c=await this.meltingSpotApi.call({method:On.PATCH,endpoint:Ae.hotspot(u.playbookId,u.pageId,u.hotspotId),options:{payload:r}});return c.isErr()?B(c.error):un(c.value)}async listPlaybookIntents(u){const r=await this.meltingSpotApi.call({method:On.GET,endpoint:Ae.intents(u.playbookId,u.pageId,u.hotspotId),options:{query:{page:u.page??1,limit:u.limit??vr,...u.status?{"status[eq]":u.status}:{}}}});return r.isErr()?B(r.error):un(r.value)}async createPlaybookIntent(u,r){const c=await this.meltingSpotApi.call({method:On.POST,endpoint:Ae.intents(u.playbookId,u.pageId,u.hotspotId),options:{payload:r}});return c.isErr()?B(c.error):un(c.value)}async updatePlaybookIntent(u,r){const c=await this.meltingSpotApi.call({method:On.PATCH,endpoint:Ae.intent(u.playbookId,u.pageId,u.hotspotId,u.intentId),options:{payload:r}});return c.isErr()?B(c.error):un(c.value)}}const lc={me:"/v1/spots/me"},hc=50;class ht{static getInstance(){return ht.instance||(ht.instance=new ht),ht.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async listSpotsForMe(u){const r=await this.meltingSpotApi.call({method:On.GET,endpoint:lc.me,options:{query:{page:1,limit:hc,...u?.spotMemberRole?{"spotMemberRole[eq]":u.spotMemberRole}:{}}}});return r.isErr()?B(r.error):un(r.value)}}const mi={spotMember:{me:"/v1/spotMembers/me",joinFromSso:"/v1/spotMembers~joinFromSso",search:"/v1/spotMembers~search"}};class pt{static getInstance(){return pt.instance||(pt.instance=new pt),pt.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async getSpotMemberForMe(){const u=await this.meltingSpotApi.call({method:On.GET,endpoint:mi.spotMember.me});return u.isErr()?B(u.error):un(u.value)}async searchSpotMembers(u){const r={page:u.page,limit:u.limit};u.search&&(r.search=u.search);const c=await this.meltingSpotApi.call({method:On.GET,endpoint:mi.spotMember.search,options:{query:r}});return c.isErr()?B(c.error):un(c.value)}async joinFromSso(u){const r=await this.meltingSpotApi.call({method:On.POST,endpoint:mi.spotMember.joinFromSso,options:{payload:{token:u}}});return r.isErr()?B(r.error):un(r.value)}}const ws={spotMemberSsoToken:"/v1/spotMembers/auth/sso/jwt",previewAccessKey:"/v1/spotMembers/auth/preview/accessKey"};class dt{static getInstance(){return dt.instance||(dt.instance=new dt),dt.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async generateSsoToken(){const u=await this.meltingSpotApi.call({method:On.POST,endpoint:ws.spotMemberSsoToken,options:{payload:{}}});return u.isErr()?B(u.error):un(u.value.token)}async generatePreviewAccessKey(u){const r=await this.meltingSpotApi.call({method:On.POST,endpoint:ws.previewAccessKey,options:{payload:{targetSpotMemberId:u.targetSpotMemberId}}});return r.isErr()?B(r.error):un(r.value)}}class _t{static getInstance(){return _t.instance||(_t.instance=new _t),_t.instance}constructor(){this.spotMemberAuthApiService=dt.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}}const pc=s=>{const u=s.get("utm_source");if(u)return{source:u,medium:s.get("utm_medium")??void 0,campaign:s.get("utm_campaign")??void 0,term:s.get("utm_term")??void 0,content:s.get("utm_content")??void 0}},dc=s=>s?Object.entries(s).reduce((u,[r,c])=>(c!=null&&(u[`utm_${r}`]=c),u),{}):{},_c=Jn.getInstance(),gc=ke.getInstance(),mc=_t.getInstance(),vc={Playbook:lt.getInstance(),Spot:ht.getInstance(),SpotMember:pt.getInstance()},gt=globalThis;gt.MeltingSpot||(gt.MeltingSpot={}),gt.MeltingSpot.Configuration=_c,gt.MeltingSpot.Auth=gc,gt.MeltingSpot.Sso=mc,gt.MeltingSpot.Api=vc;const Ec="1.6.0",vi=new ss({appName:"Embed SDK",appVersion:Ec});class Ts{constructor(u){this.content=u}#n=null;#e=null;set onRemove(u){this.#e=u}inject(u){this.remove();const r=af({input:u,rootDocument:this.content.rootDocument});this.#n=this.content.iframe,this.#n.classList.add("ms-embed"),r.appendChild(this.#n)}remove(){this.#n&&(this.#n.contentWindow&&this.#e?.(this.#n.contentWindow),this.#n.remove(),this.#n=null)}}class wc{constructor(u){this.baseURL=Xf(u.baseURL),this.spotId=Kf(u.spotId),this.authToken=u.authToken??null,this.themeMode=u.themeMode??"auto",this.domain=u.domain??null,this.deeplink=u.deeplink?Zf({deeplink:u.deeplink,spotId:this.spotId}):null,this.utmParameters=u.utmParameters??null,this.rootDocument=u.rootDocument}get iframe(){const u=this.authToken&&this.authToken.trim().length>0?"/sso/jwt":"",r=new URL(`/spot/${this.spotId}${u}`,qu(this.baseURL)),c=cf({url:r,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...dc(this.utmParameters)},rootDocument:this.rootDocument});return c.classList.add("ms-spot"),c}}const Er={READY:"meltingspot:ready",ERROR:"meltingspot:error",PREFILL_DRAFT:"meltingspot:prefillDraft"},xn=class xn{static injectSpotInto(u,r){const{onReady:c,onError:_,...v}=r,{spotId:d,rootDocument:A,msCommunityWebBaseUrl:I}=Jn.getConfiguration({spotId:v.spotId,rootDocument:v.rootDocument,msCommunityWebBaseUrl:v.baseURL});if(!d)throw vi.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const H=new URLSearchParams(window.location.search),nn={spotId:d,authToken:v.authToken??H.get("ms_token"),domain:v.domain,deeplink:v.deeplink??H.get("ms_url"),themeMode:v.themeMode,utmParameters:v.utmParameters??pc(H),baseURL:I,rootDocument:A},N=new Ts(new wc(nn));if(N.inject(u),xn.embeds.push(N),c||_){const $=N.content.iframe.contentWindow;$&&(xn.iframeCallbacks.set($,{onReady:c,onError:_}),N.onRemove=q=>{xn.iframeCallbacks.delete(q)}),xn.ensureMessageListener()}return vi.log("Spot injected",nn,u),N}static clear(){xn.embeds.forEach(u=>{u.remove()}),xn.embeds=[],xn.iframeCallbacks.clear(),xn.messageListened&&(window.removeEventListener("message",xn.handleMessageEvent),xn.messageListened=!1),vi.log("All MeltingSpot embeds cleared")}static handleMessageEvent(u){if(!u.data||typeof u.data!="object"||u.data.type!==Er.READY&&u.data.type!==Er.ERROR)return;const r=u.source,c=xn.iframeCallbacks.get(r);if(!c)return;const{msCommunityWebBaseUrl:_}=Jn.getConfiguration({});if(_)try{const v=new URL(_).origin;if(u.origin!==v)return}catch{}u.data.type===Er.READY?c.onReady?.():c.onError?.(u.data.error)}static ensureMessageListener(){xn.messageListened||(window.addEventListener("message",xn.handleMessageEvent),xn.messageListened=!0)}};xn.embeds=[],xn.messageListened=!1,xn.iframeCallbacks=new Map;let wr=xn;const Ei=globalThis;Ei.MeltingSpot||(Ei.MeltingSpot={}),Ei.MeltingSpot.Embed=wr,He.EMBED_POST_MESSAGE_TYPE=Er,He.Embed=wr,He.EmbedFrame=Ts,Object.defineProperty(He,Symbol.toStringTag,{value:"Module"})}));
20
+ }`;var Z=Ja(function(){return sn(f,D+"return "+y).apply(r,l)});if(Z.source=y,bu(Z))throw Z;return Z}function lm(n){return an(n).toLowerCase()}function hm(n){return an(n).toUpperCase()}function pm(n,e,t){if(n=an(n),n&&(t||e===r))return io(n);if(!n||!(e=ee(e)))return n;var i=ve(n),o=ve(e),f=uo(i,o),l=so(i,o)+1;return Ze(i,f,l).join("")}function dm(n,e,t){if(n=an(n),n&&(t||e===r))return n.slice(0,ao(n)+1);if(!n||!(e=ee(e)))return n;var i=ve(n),o=so(i,ve(e))+1;return Ze(i,0,o).join("")}function _m(n,e,t){if(n=an(n),n&&(t||e===r))return n.replace(bi,"");if(!n||!(e=ee(e)))return n;var i=ve(n),o=uo(i,ve(e));return Ze(i,o).join("")}function gm(n,e){var t=cn,i=rn;if(En(e)){var o="separator"in e?e.separator:o;t="length"in e?Q(e.length):t,i="omission"in e?ee(e.omission):i}n=an(n);var f=n.length;if(Tt(n)){var l=ve(n);f=l.length}if(t>=f)return n;var h=t-yt(i);if(h<1)return i;var g=l?Ze(l,0,h).join(""):n.slice(0,h);if(o===r)return g+i;if(l&&(h+=g.length-h),Su(o)){if(n.slice(h).search(o)){var w,T=g;for(o.global||(o=Ki(o.source,an(Rs.exec(o))+"g")),o.lastIndex=0;w=o.exec(T);)var y=w.index;g=g.slice(0,y===r?h:y)}}else if(n.indexOf(ee(o),h)!=h){var R=g.lastIndexOf(o);R>-1&&(g=g.slice(0,R))}return g+i}function mm(n){return n=an(n),n&&xc.test(n)?n.replace(As,ql):n}var vm=Lt(function(n,e,t){return n+(t?" ":"")+e.toUpperCase()}),$u=Xo("toUpperCase");function Za(n,e,t){return n=an(n),e=t?r:e,e===r?kl(n)?Zl(n):Dl(n):n.match(e)||[]}var Ja=J(function(n,e){try{return jn(n,r,e)}catch(t){return bu(t)?t:new W(t)}}),Em=Ue(function(n,e){return oe(e,function(t){t=Me(t),Ne(n,t,xu(n[t],n))}),n});function wm(n){var e=n==null?0:n.length,t=U();return n=e?_n(n,function(i){if(typeof i[1]!="function")throw new ae(d);return[t(i[0]),i[1]]}):[],J(function(i){for(var o=-1;++o<e;){var f=n[o];if(jn(f[0],this,i))return jn(f[1],this,i)}})}function Tm(n){return qh(ce(n,N))}function Uu(n){return function(){return n}}function ym(n,e){return n==null||n!==n?e:n}var Am=jo(),Im=jo(!0);function Qn(n){return n}function Pu(n){return Lo(typeof n=="function"?n:ce(n,N))}function Om(n){return So(ce(n,N))}function Rm(n,e){return Do(n,ce(e,N))}var Mm=J(function(n,e){return function(t){return Zt(t,n,e)}}),xm=J(function(n,e){return function(t){return Zt(n,t,e)}});function Fu(n,e,t){var i=Nn(e),o=zr(e,i);t==null&&!(En(e)&&(o.length||!i.length))&&(t=e,e=n,n=this,o=zr(e,Nn(e)));var f=!(En(t)&&"chain"in t)||!!t.chain,l=Fe(n);return oe(o,function(h){var g=e[h];n[h]=g,l&&(n.prototype[h]=function(){var w=this.__chain__;if(f||w){var T=n(this.__wrapped__),y=T.__actions__=zn(this.__actions__);return y.push({func:g,args:arguments,thisArg:n}),T.__chain__=w,T}return g.apply(n,Be([this.value()],arguments))})}),n}function Lm(){return Pn._===this&&(Pn._=eh),this}function Yu(){}function bm(n){return n=Q(n),J(function(e){return No(e,n)})}var Sm=_u(_n),Dm=_u(js),Nm=_u(Hi);function Xa(n){return yu(n)?ki(Me(n)):fp(n)}function $m(n){return function(e){return n==null?r:ot(n,e)}}var Um=ea(),Pm=ea(!0);function Cu(){return[]}function Hu(){return!1}function Fm(){return{}}function Ym(){return""}function Cm(){return!0}function Hm(n,e){if(n=Q(n),n<1||n>O)return[];var t=X,i=Cn(n,X);e=U(e),n-=X;for(var o=Gi(i,e);++t<n;)e(t);return o}function km(n){return z(n)?_n(n,Me):te(n)?[n]:zn(ma(an(n)))}function Wm(n){var e=++jl;return an(n)+e}var Bm=Xr(function(n,e){return n+e},0),Gm=gu("ceil"),zm=Xr(function(n,e){return n/e},1),qm=gu("floor");function Km(n){return n&&n.length?Gr(n,Qn,eu):r}function Qm(n,e){return n&&n.length?Gr(n,U(e,2),eu):r}function Zm(n){return to(n,Qn)}function Jm(n,e){return to(n,U(e,2))}function Xm(n){return n&&n.length?Gr(n,Qn,uu):r}function Vm(n,e){return n&&n.length?Gr(n,U(e,2),uu):r}var jm=Xr(function(n,e){return n*e},1),n0=gu("round"),e0=Xr(function(n,e){return n-e},0);function t0(n){return n&&n.length?Bi(n,Qn):0}function r0(n,e){return n&&n.length?Bi(n,U(e,2)):0}return a.after=O_,a.ary=xa,a.assign=hg,a.assignIn=Wa,a.assignInWith=ci,a.assignWith=pg,a.at=dg,a.before=La,a.bind=xu,a.bindAll=Em,a.bindKey=ba,a.castArray=F_,a.chain=Oa,a.chunk=qp,a.compact=Kp,a.concat=Qp,a.cond=wm,a.conforms=Tm,a.constant=Uu,a.countBy=t_,a.create=_g,a.curry=Sa,a.curryRight=Da,a.debounce=Na,a.defaults=gg,a.defaultsDeep=mg,a.defer=R_,a.delay=M_,a.difference=Zp,a.differenceBy=Jp,a.differenceWith=Xp,a.drop=Vp,a.dropRight=jp,a.dropRightWhile=nd,a.dropWhile=ed,a.fill=td,a.filter=i_,a.flatMap=o_,a.flatMapDeep=a_,a.flatMapDepth=f_,a.flatten=Ta,a.flattenDeep=rd,a.flattenDepth=id,a.flip=x_,a.flow=Am,a.flowRight=Im,a.fromPairs=ud,a.functions=Ig,a.functionsIn=Og,a.groupBy=c_,a.initial=od,a.intersection=ad,a.intersectionBy=fd,a.intersectionWith=cd,a.invert=Mg,a.invertBy=xg,a.invokeMap=h_,a.iteratee=Pu,a.keyBy=p_,a.keys=Nn,a.keysIn=Kn,a.map=ii,a.mapKeys=bg,a.mapValues=Sg,a.matches=Om,a.matchesProperty=Rm,a.memoize=si,a.merge=Dg,a.mergeWith=Ba,a.method=Mm,a.methodOf=xm,a.mixin=Fu,a.negate=oi,a.nthArg=bm,a.omit=Ng,a.omitBy=$g,a.once=L_,a.orderBy=d_,a.over=Sm,a.overArgs=b_,a.overEvery=Dm,a.overSome=Nm,a.partial=Lu,a.partialRight=$a,a.partition=__,a.pick=Ug,a.pickBy=Ga,a.property=Xa,a.propertyOf=$m,a.pull=dd,a.pullAll=Aa,a.pullAllBy=_d,a.pullAllWith=gd,a.pullAt=md,a.range=Um,a.rangeRight=Pm,a.rearg=S_,a.reject=v_,a.remove=vd,a.rest=D_,a.reverse=Ru,a.sampleSize=w_,a.set=Fg,a.setWith=Yg,a.shuffle=T_,a.slice=Ed,a.sortBy=I_,a.sortedUniq=Rd,a.sortedUniqBy=Md,a.split=om,a.spread=N_,a.tail=xd,a.take=Ld,a.takeRight=bd,a.takeRightWhile=Sd,a.takeWhile=Dd,a.tap=Kd,a.throttle=$_,a.thru=ri,a.toArray=Ca,a.toPairs=za,a.toPairsIn=qa,a.toPath=km,a.toPlainObject=ka,a.transform=Cg,a.unary=U_,a.union=Nd,a.unionBy=$d,a.unionWith=Ud,a.uniq=Pd,a.uniqBy=Fd,a.uniqWith=Yd,a.unset=Hg,a.unzip=Mu,a.unzipWith=Ia,a.update=kg,a.updateWith=Wg,a.values=Dt,a.valuesIn=Bg,a.without=Cd,a.words=Za,a.wrap=P_,a.xor=Hd,a.xorBy=kd,a.xorWith=Wd,a.zip=Bd,a.zipObject=Gd,a.zipObjectDeep=zd,a.zipWith=qd,a.entries=za,a.entriesIn=qa,a.extend=Wa,a.extendWith=ci,Fu(a,a),a.add=Bm,a.attempt=Ja,a.camelCase=Kg,a.capitalize=Ka,a.ceil=Gm,a.clamp=Gg,a.clone=Y_,a.cloneDeep=H_,a.cloneDeepWith=k_,a.cloneWith=C_,a.conformsTo=W_,a.deburr=Qa,a.defaultTo=ym,a.divide=zm,a.endsWith=Qg,a.eq=we,a.escape=Zg,a.escapeRegExp=Jg,a.every=r_,a.find=u_,a.findIndex=Ea,a.findKey=vg,a.findLast=s_,a.findLastIndex=wa,a.findLastKey=Eg,a.floor=qm,a.forEach=Ra,a.forEachRight=Ma,a.forIn=wg,a.forInRight=Tg,a.forOwn=yg,a.forOwnRight=Ag,a.get=Du,a.gt=B_,a.gte=G_,a.has=Rg,a.hasIn=Nu,a.head=ya,a.identity=Qn,a.includes=l_,a.indexOf=sd,a.inRange=zg,a.invoke=Lg,a.isArguments=ct,a.isArray=z,a.isArrayBuffer=z_,a.isArrayLike=qn,a.isArrayLikeObject=yn,a.isBoolean=q_,a.isBuffer=Je,a.isDate=K_,a.isElement=Q_,a.isEmpty=Z_,a.isEqual=J_,a.isEqualWith=X_,a.isError=bu,a.isFinite=V_,a.isFunction=Fe,a.isInteger=Ua,a.isLength=ai,a.isMap=Pa,a.isMatch=j_,a.isMatchWith=ng,a.isNaN=eg,a.isNative=tg,a.isNil=ig,a.isNull=rg,a.isNumber=Fa,a.isObject=En,a.isObjectLike=wn,a.isPlainObject=er,a.isRegExp=Su,a.isSafeInteger=ug,a.isSet=Ya,a.isString=fi,a.isSymbol=te,a.isTypedArray=St,a.isUndefined=sg,a.isWeakMap=og,a.isWeakSet=ag,a.join=ld,a.kebabCase=Xg,a.last=he,a.lastIndexOf=hd,a.lowerCase=Vg,a.lowerFirst=jg,a.lt=fg,a.lte=cg,a.max=Km,a.maxBy=Qm,a.mean=Zm,a.meanBy=Jm,a.min=Xm,a.minBy=Vm,a.stubArray=Cu,a.stubFalse=Hu,a.stubObject=Fm,a.stubString=Ym,a.stubTrue=Cm,a.multiply=jm,a.nth=pd,a.noConflict=Lm,a.noop=Yu,a.now=ui,a.pad=nm,a.padEnd=em,a.padStart=tm,a.parseInt=rm,a.random=qg,a.reduce=g_,a.reduceRight=m_,a.repeat=im,a.replace=um,a.result=Pg,a.round=n0,a.runInContext=p,a.sample=E_,a.size=y_,a.snakeCase=sm,a.some=A_,a.sortedIndex=wd,a.sortedIndexBy=Td,a.sortedIndexOf=yd,a.sortedLastIndex=Ad,a.sortedLastIndexBy=Id,a.sortedLastIndexOf=Od,a.startCase=am,a.startsWith=fm,a.subtract=e0,a.sum=t0,a.sumBy=r0,a.template=cm,a.times=Hm,a.toFinite=Ye,a.toInteger=Q,a.toLength=Ha,a.toLower=lm,a.toNumber=pe,a.toSafeInteger=lg,a.toString=an,a.toUpper=hm,a.trim=pm,a.trimEnd=dm,a.trimStart=_m,a.truncate=gm,a.unescape=mm,a.uniqueId=Wm,a.upperCase=vm,a.upperFirst=$u,a.each=Ra,a.eachRight=Ma,a.first=ya,Fu(a,(function(){var n={};return Oe(a,function(e,t){fn.call(a.prototype,t)||(n[t]=e)}),n})(),{chain:!1}),a.VERSION=c,oe(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){a[n].placeholder=a}),oe(["drop","take"],function(n,e){j.prototype[n]=function(t){t=t===r?1:Sn(Q(t),0);var i=this.__filtered__&&!e?new j(this):this.clone();return i.__filtered__?i.__takeCount__=Cn(t,i.__takeCount__):i.__views__.push({size:Cn(t,X),type:n+(i.__dir__<0?"Right":"")}),i},j.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),oe(["filter","map","takeWhile"],function(n,e){var t=e+1,i=t==Y||t==M;j.prototype[n]=function(o){var f=this.clone();return f.__iteratees__.push({iteratee:U(o,3),type:t}),f.__filtered__=f.__filtered__||i,f}}),oe(["head","last"],function(n,e){var t="take"+(e?"Right":"");j.prototype[n]=function(){return this[t](1).value()[0]}}),oe(["initial","tail"],function(n,e){var t="drop"+(e?"":"Right");j.prototype[n]=function(){return this.__filtered__?new j(this):this[t](1)}}),j.prototype.compact=function(){return this.filter(Qn)},j.prototype.find=function(n){return this.filter(n).head()},j.prototype.findLast=function(n){return this.reverse().find(n)},j.prototype.invokeMap=J(function(n,e){return typeof n=="function"?new j(this):this.map(function(t){return Zt(t,n,e)})}),j.prototype.reject=function(n){return this.filter(oi(U(n)))},j.prototype.slice=function(n,e){n=Q(n);var t=this;return t.__filtered__&&(n>0||e<0)?new j(t):(n<0?t=t.takeRight(-n):n&&(t=t.drop(n)),e!==r&&(e=Q(e),t=e<0?t.dropRight(-e):t.take(e-n)),t)},j.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},j.prototype.toArray=function(){return this.take(X)},Oe(j.prototype,function(n,e){var t=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),o=a[i?"take"+(e=="last"?"Right":""):e],f=i||/^find/.test(e);o&&(a.prototype[e]=function(){var l=this.__wrapped__,h=i?[1]:arguments,g=l instanceof j,w=h[0],T=g||z(l),y=function(V){var tn=o.apply(a,Be([V],h));return i&&R?tn[0]:tn};T&&t&&typeof w=="function"&&w.length!=1&&(g=T=!1);var R=this.__chain__,D=!!this.__actions__.length,P=f&&!R,Z=g&&!D;if(!f&&T){l=Z?l:new j(this);var F=n.apply(l,h);return F.__actions__.push({func:ri,args:[y],thisArg:r}),new fe(F,R)}return P&&Z?n.apply(this,h):(F=this.thru(y),P?i?F.value()[0]:F.value():F)})}),oe(["pop","push","shift","sort","splice","unshift"],function(n){var e=Lr[n],t=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",i=/^(?:pop|shift)$/.test(n);a.prototype[n]=function(){var o=arguments;if(i&&!this.__chain__){var f=this.value();return e.apply(z(f)?f:[],o)}return this[t](function(l){return e.apply(z(l)?l:[],o)})}}),Oe(j.prototype,function(n,e){var t=a[e];if(t){var i=t.name+"";fn.call(Rt,i)||(Rt[i]=[]),Rt[i].push({name:e,func:t})}}),Rt[Jr(r,hn).name]=[{name:"wrapper",func:r}],j.prototype.clone=mh,j.prototype.reverse=vh,j.prototype.value=Eh,a.prototype.at=Qd,a.prototype.chain=Zd,a.prototype.commit=Jd,a.prototype.next=Xd,a.prototype.plant=jd,a.prototype.reverse=n_,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=e_,a.prototype.first=a.prototype.head,Wt&&(a.prototype[Wt]=Vd),a}),At=Jl();tt?((tt.exports=At)._=At,Pi._=At):Pn._=At}).call(Bf)})(Ut,Ut.exports)),Ut.exports}Gf();const zf="1.7.0";class ss{constructor(u){this.debug=!1,this.debug=u?.debug??!1,this.appName=u?.appName,this.appVersion=u?.appVersion}log(u,...r){this.debug&&this.print(u,"info",r)}warn(u,...r){this.print(u,"warn",r)}error(u,...r){this.print(u,"error",r)}print(u,r,c){const d=[`[${["MeltingSpot",this.appName,this.appVersion].filter(Boolean).join(" - ")}] ${u}`];c.length&&d.push(...c),console[r](...d)}}const qf=new ss({appName:"Core SDK",appVersion:zf}),Kf=s=>s.toLowerCase().replace(/[^a-z0-9-]/g,""),Qf=["/user"],Zf=({deeplink:s,spotId:u})=>{try{const r=new URL(s,"https://unused.com");let c=r.pathname;return r.search&&(c+=r.search),r.hash&&(c+=r.hash),Qf.some(_=>c.startsWith(_))||(c=`/spot/${u}/${sf(c)}`),c}catch(r){return qf.warn("Failed to parse deeplink URL",r),null}},Jf=[/(^|\.)meltingspot\.io$/i],Xf=s=>{let u;try{const v=qu(s);u=new URL(v)}catch{throw new Error(`Invalid baseURL: ${s}`)}const r=u.hostname==="localhost"||u.hostname==="127.0.0.1",c=u.protocol==="https:",_=Jf.some(v=>v.test(u.hostname));if(!r&&(!c||!_))throw new Error(`Untrusted baseURL origin: ${u.origin}`);return u.origin},Vf={msApiBaseUrl:"https://openapi.meltingspot.io/",msCommunityWebBaseUrl:"https://go.meltingspot.io/",ssoToken:void 0,spotId:"",autoJoin:!1,rootDocument:globalThis.document};class Jn{constructor(){this.configuration=Vf}static getInstance(){return Jn.instance||(Jn.instance=new Jn),Jn.instance}setConfiguration(u){this.configuration={...this.configuration,...u}}static getConfiguration(u={}){return{...Jn.getInstance().configuration,...u}}}const os="%[a-f0-9]{2}",as=new RegExp("("+os+")|([^%]+?)","gi"),fs=new RegExp("("+os+")+","gi");function pi(s,u){try{return[decodeURIComponent(s.join(""))]}catch{}if(s.length===1)return s;u=u||1;const r=s.slice(0,u),c=s.slice(u);return Array.prototype.concat.call([],pi(r),pi(c))}function jf(s){try{return decodeURIComponent(s)}catch{let u=s.match(as)||[];for(let r=1;r<u.length;r++)s=pi(u,r).join(""),u=s.match(as)||[];return s}}function nc(s){const u={"%FE%FF":"��","%FF%FE":"��"};let r=fs.exec(s);for(;r;){try{u[r[0]]=decodeURIComponent(r[0])}catch{const _=jf(r[0]);_!==r[0]&&(u[r[0]]=_)}r=fs.exec(s)}u["%C2"]="�";const c=Object.keys(u);for(const _ of c)s=s.replace(new RegExp(_,"g"),u[_]);return s}function ec(s){if(typeof s!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof s+"`");try{return decodeURIComponent(s)}catch{return nc(s)}}function tc(s,u){const r={};if(Array.isArray(u))for(const c of u){const _=Object.getOwnPropertyDescriptor(s,c);_?.enumerable&&Object.defineProperty(r,c,_)}else for(const c of Reflect.ownKeys(s)){const _=Object.getOwnPropertyDescriptor(s,c);if(_.enumerable){const v=s[c];u(c,v,s)&&Object.defineProperty(r,c,_)}}return r}function cs(s,u){if(!(typeof s=="string"&&typeof u=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(s===""||u==="")return[];const r=s.indexOf(u);return r===-1?[]:[s.slice(0,r),s.slice(r+u.length)]}const rc=s=>s==null,ic=s=>encodeURIComponent(s).replaceAll(/[!'()*]/g,u=>`%${u.charCodeAt(0).toString(16).toUpperCase()}`),di=Symbol("encodeFragmentIdentifier");function uc(s){switch(s.arrayFormat){case"index":return u=>(r,c)=>{const _=r.length;return c===void 0||s.skipNull&&c===null||s.skipEmptyString&&c===""?r:c===null?[...r,[In(u,s),"[",_,"]"].join("")]:[...r,[In(u,s),"[",In(_,s),"]=",In(c,s)].join("")]};case"bracket":return u=>(r,c)=>c===void 0||s.skipNull&&c===null||s.skipEmptyString&&c===""?r:c===null?[...r,[In(u,s),"[]"].join("")]:[...r,[In(u,s),"[]=",In(c,s)].join("")];case"colon-list-separator":return u=>(r,c)=>c===void 0||s.skipNull&&c===null||s.skipEmptyString&&c===""?r:c===null?[...r,[In(u,s),":list="].join("")]:[...r,[In(u,s),":list=",In(c,s)].join("")];case"comma":case"separator":case"bracket-separator":{const u=s.arrayFormat==="bracket-separator"?"[]=":"=";return r=>(c,_)=>_===void 0||s.skipNull&&_===null||s.skipEmptyString&&_===""?c:(_=_===null?"":_,c.length===0?[[In(r,s),u,In(_,s)].join("")]:[[c,In(_,s)].join(s.arrayFormatSeparator)])}default:return u=>(r,c)=>c===void 0||s.skipNull&&c===null||s.skipEmptyString&&c===""?r:c===null?[...r,In(u,s)]:[...r,[In(u,s),"=",In(c,s)].join("")]}}function sc(s){let u;switch(s.arrayFormat){case"index":return(r,c,_)=>{if(u=/\[(\d*)]$/.exec(r),r=r.replace(/\[\d*]$/,""),!u){_[r]=c;return}_[r]===void 0&&(_[r]={}),_[r][u[1]]=c};case"bracket":return(r,c,_)=>{if(u=/(\[])$/.exec(r),r=r.replace(/\[]$/,""),!u){_[r]=c;return}if(_[r]===void 0){_[r]=[c];return}_[r]=[..._[r],c]};case"colon-list-separator":return(r,c,_)=>{if(u=/(:list)$/.exec(r),r=r.replace(/:list$/,""),!u){_[r]=c;return}if(_[r]===void 0){_[r]=[c];return}_[r]=[..._[r],c]};case"comma":case"separator":return(r,c,_)=>{const v=typeof c=="string"&&c.includes(s.arrayFormatSeparator),d=typeof c=="string"&&!v&&xe(c,s).includes(s.arrayFormatSeparator);c=d?xe(c,s):c;const A=v||d?c.split(s.arrayFormatSeparator).map(I=>xe(I,s)):c===null?c:xe(c,s);_[r]=A};case"bracket-separator":return(r,c,_)=>{const v=/(\[])$/.test(r);if(r=r.replace(/\[]$/,""),!v){_[r]=c&&xe(c,s);return}const d=c===null?[]:xe(c,s).split(s.arrayFormatSeparator);if(_[r]===void 0){_[r]=d;return}_[r]=[..._[r],...d]};default:return(r,c,_)=>{if(_[r]===void 0){_[r]=c;return}_[r]=[...[_[r]].flat(),c]}}}function ls(s){if(typeof s!="string"||s.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function In(s,u){return u.encode?u.strict?ic(s):encodeURIComponent(s):s}function xe(s,u){return u.decode?ec(s):s}function hs(s){return Array.isArray(s)?s.sort():typeof s=="object"?hs(Object.keys(s)).sort((u,r)=>Number(u)-Number(r)).map(u=>s[u]):s}function ps(s){const u=s.indexOf("#");return u!==-1&&(s=s.slice(0,u)),s}function oc(s){let u="";const r=s.indexOf("#");return r!==-1&&(u=s.slice(r)),u}function ds(s,u,r){return r==="string"&&typeof s=="string"?s:typeof r=="function"&&typeof s=="string"?r(s):r==="boolean"&&s===null?!0:r==="boolean"&&s!==null&&(s.toLowerCase()==="true"||s.toLowerCase()==="false")?s.toLowerCase()==="true":r==="boolean"&&s!==null&&(s.toLowerCase()==="1"||s.toLowerCase()==="0")?s.toLowerCase()==="1":r==="string[]"&&u.arrayFormat!=="none"&&typeof s=="string"?[s]:r==="number[]"&&u.arrayFormat!=="none"&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?[Number(s)]:r==="number"&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?Number(s):u.parseBooleans&&s!==null&&(s.toLowerCase()==="true"||s.toLowerCase()==="false")?s.toLowerCase()==="true":u.parseNumbers&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?Number(s):s}function _i(s){s=ps(s);const u=s.indexOf("?");return u===-1?"":s.slice(u+1)}function gi(s,u){u={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...u},ls(u.arrayFormatSeparator);const r=sc(u),c=Object.create(null);if(typeof s!="string"||(s=s.trim().replace(/^[?#&]/,""),!s))return c;for(const _ of s.split("&")){if(_==="")continue;const v=u.decode?_.replaceAll("+"," "):_;let[d,A]=cs(v,"=");d===void 0&&(d=v),A=A===void 0?null:["comma","separator","bracket-separator"].includes(u.arrayFormat)?A:xe(A,u),r(xe(d,u),A,c)}for(const[_,v]of Object.entries(c))if(typeof v=="object"&&v!==null&&u.types[_]!=="string")for(const[d,A]of Object.entries(v)){const I=u.types[_]?u.types[_].replace("[]",""):void 0;v[d]=ds(A,u,I)}else typeof v=="object"&&v!==null&&u.types[_]==="string"?c[_]=Object.values(v).join(u.arrayFormatSeparator):c[_]=ds(v,u,u.types[_]);return u.sort===!1?c:(u.sort===!0?Object.keys(c).sort():Object.keys(c).sort(u.sort)).reduce((_,v)=>{const d=c[v];return _[v]=d&&typeof d=="object"&&!Array.isArray(d)?hs(d):d,_},Object.create(null))}function _s(s,u){if(!s)return"";u={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...u},ls(u.arrayFormatSeparator);const r=d=>u.skipNull&&rc(s[d])||u.skipEmptyString&&s[d]==="",c=uc(u),_={};for(const[d,A]of Object.entries(s))r(d)||(_[d]=A);const v=Object.keys(_);return u.sort!==!1&&v.sort(u.sort),v.map(d=>{const A=s[d];return A===void 0?"":A===null?In(d,u):Array.isArray(A)?A.length===0&&u.arrayFormat==="bracket-separator"?In(d,u)+"[]":A.reduce(c(d),[]).join("&"):In(d,u)+"="+In(A,u)}).filter(d=>d.length>0).join("&")}function gs(s,u){u={decode:!0,...u};let[r,c]=cs(s,"#");return r===void 0&&(r=s),{url:r?.split("?")?.[0]??"",query:gi(_i(s),u),...u&&u.parseFragmentIdentifier&&c?{fragmentIdentifier:xe(c,u)}:{}}}function ms(s,u){u={encode:!0,strict:!0,[di]:!0,...u};const r=ps(s.url).split("?")[0]||"",c=_i(s.url),_={...gi(c,{sort:!1,...u}),...s.query};let v=_s(_,u);v&&=`?${v}`;let d=oc(s.url);if(typeof s.fragmentIdentifier=="string"){const A=new URL(r);A.hash=s.fragmentIdentifier,d=u[di]?A.hash:`#${s.fragmentIdentifier}`}return`${r}${v}${d}`}function vs(s,u,r){r={parseFragmentIdentifier:!0,[di]:!1,...r};const{url:c,query:_,fragmentIdentifier:v}=gs(s,r);return ms({url:c,query:tc(_,u),fragmentIdentifier:v},r)}function ac(s,u,r){const c=Array.isArray(u)?_=>!u.includes(_):(_,v)=>!u(_,v);return vs(s,c,r)}const fc=Object.freeze(Object.defineProperty({__proto__:null,exclude:ac,extract:_i,parse:gi,parseUrl:gs,pick:vs,stringify:_s,stringifyUrl:ms},Symbol.toStringTag,{value:"Module"}));class Gn extends Error{constructor(u,r){super(`HTTP Error ${u}${r?`: ${r}`:""}`),this.code=u,this.name="HttpError",Object.setPrototypeOf(this,Gn.prototype)}}var On=(s=>(s.GET="GET",s.PATCH="PATCH",s.POST="POST",s))(On||{});class cc{constructor(){this.headers={}}setHeaders(u){this.headers=u}async get(u){try{const r=u.query?`${u.url}?${this.serializeQuery(u.query)}`:u.url,c=await fetch(r,{headers:{...this.headers,...u.headers,"Content-Type":"application/json"},...u.signal?{signal:u.signal}:{}});return c.ok?un(await c.json()):B(new Gn(c.status,await c.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return B(new Gn(ue.INTERNAL_SERVER_ERROR,c))}}async post(u){try{const r=await fetch(u.url,{method:"POST",headers:{...this.headers,...u.headers,"Content-Type":"application/json"},body:JSON.stringify(u.payload),...u.signal?{signal:u.signal}:{}});return r.ok?un(await r.json()):B(new Gn(r.status,await r.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return B(new Gn(ue.INTERNAL_SERVER_ERROR,c))}}async patch(u){try{const r=await fetch(u.url,{method:"PATCH",headers:{...this.headers,...u.headers,"Content-Type":"application/json"},body:JSON.stringify(u.payload),...u.signal?{signal:u.signal}:{}});return r.ok?un(await r.json()):B(new Gn(r.status,await r.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return B(new Gn(ue.INTERNAL_SERVER_ERROR,c))}}serializeQuery(u){if(typeof u=="string")return u;if(typeof u=="object")for(const r in u)u[r]===void 0&&delete u[r];return u=fc.stringify(u,{arrayFormat:"none"}),u}}const mr={accessToken:{email:"/v1/auth/accessToken/email",sso:{jwt:"/v1/auth/accessToken/sso/jwt"}},refreshAccessToken:"/v1/auth/accessToken~refresh",password:{reset:"/v1/auth/password~reset"}};class ke extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return ke.instance||(ke.instance=new ke),ke.instance}async loginWithPassword(u,r){const c=await this.callApi({endpoint:mr.accessToken.email,method:"POST",body:{email:u,password:r},withSpotId:!0});if(c.isErr())return B(c.error);const{accessToken:_,refreshToken:v}=c.value;return this.setTokens(_.token,v.token),un({accessToken:_.token,refreshToken:v.token})}async loginWithSsoToken(u){const r=await this.callApi({endpoint:mr.accessToken.sso.jwt,method:"POST",body:{token:u},withSpotId:!0});if(r.isErr())return B(r.error);const{accessToken:c,refreshToken:_}=r.value;return this.setTokens(c.token,_.token),un({accessToken:c.token,refreshToken:_.token})}loginWithAuthTokens(u,r){return this.setTokens(u,r),{accessToken:u,refreshToken:r}}resetPassword(u){return this.callApi({endpoint:mr.password.reset,method:"POST",body:{email:u}})}async refresh(){const u=await this.callApi({endpoint:mr.refreshAccessToken,method:"POST",body:{refreshToken:this.refreshToken}});if(u.isErr())return B(u.error);const{accessToken:r,refreshToken:c}=u.value;return this.setTokens(r.token,c.token),un({accessToken:r.token,refreshToken:c.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(u,r){if(this.accessToken!==u||this.refreshToken!==r){this.accessToken=u,this.refreshToken=r;const c=new CustomEvent("auth:tokens-updated",{detail:{accessToken:u,refreshToken:r}});this.dispatchEvent(c)}}async callApi(u){try{const{spotId:r,msApiBaseUrl:c}=Jn.getConfiguration(),_=hi(u.endpoint,c),v={"Content-Type":"application/json",...u.headers};u.withSpotId&&r&&(v[Es.SpotId]=r);const d=await fetch(_,{method:u.method,body:u.body?JSON.stringify(u.body):void 0,headers:v});if(!d.ok)return B(new Gn(d.status,d.statusText));if(d.status===ue.NO_CONTENT)return un(void 0);const A=await d.json();return un(A)}catch(r){return B(new Gn(ue.INTERNAL_SERVER_ERROR,r instanceof Error?r.message:String(r)))}}}var Es=(s=>(s.Authorization="Authorization",s.SpotId="x-spotid",s))(Es||{});class ye{constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=ke.getInstance(),this.httpService=new cc}static getInstance(){return ye.instance||(ye.instance=new ye),ye.instance}static buildAuthenticatedRequest(u){const{msApiBaseUrl:r,spotId:c}=Jn.getConfiguration(),_=hi(u,r),v=ke.getInstance().getAccessToken();if(!v)return B(new Error("Not authenticated"));const d={"Content-Type":"application/json",Authorization:`Bearer ${v}`};return c&&(d["x-spotid"]=c),un({url:_,headers:d})}static async stream(u,r,c){const{streamTransport:_}=Jn.getConfiguration();if(_)return _({endpoint:u,body:r,signal:c});const v=ye.buildAuthenticatedRequest(u);if(v.isErr())return B(v.error);const{url:d,headers:A}=v.value;try{const I=await fetch(d,{method:"POST",headers:A,...r!==void 0?{body:JSON.stringify(r)}:{},...c?{signal:c}:{}});if(!I.ok){const H=await I.text();return B(new Error(`HTTP ${I.status}: ${H}`))}return I.body?un(I.body):B(new Error("Response body is empty"))}catch(I){const H=I instanceof Error?I.message:"Unknown error";return B(I instanceof Error?I:new Error(H))}}get pendingCount(){return this.queue.length}enqueue(u){return new Promise(r=>{const c=async()=>{try{const _=await u();r(_)}catch(_){r(B(new Gn(ue.INTERNAL_SERVER_ERROR,_ instanceof Error?_.message:"Unknown error")))}};this.queue.push(c),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){const u=this.queue.shift();if(!u)break;await u()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){const u=this.isPaused;this.isPaused=!1,u&&this.processQueue()}async call(u){return this.enqueue(async()=>{const r=async()=>{const{spotId:_,msApiBaseUrl:v}=Jn.getConfiguration(),d={...u.options?.headers??{}};_&&(d["x-spotid"]=_);const A=this.authService.getAccessToken(),{requiresAuth:I=!0}=u;if(!A&&I)return B(new Gn(ue.UNAUTHORIZED));A&&(d.Authorization=`Bearer ${A}`);const H=hi(u.endpoint,v);switch(u.method){case On.GET:return this.httpService.get({...u.options??{},headers:d,url:H});case On.PATCH:return this.httpService.patch({...u.options??{},headers:d,url:H});case On.POST:return this.httpService.post({...u.options??{},headers:d,url:H});default:return B(new Gn(ue.METHOD_NOT_ALLOWED,"Method not allowed"))}};let c=await r();if(c.isErr()&&c.error.code===ue.UNAUTHORIZED){const _=await this.authService.refresh();if(_.isErr())return B(new Gn(ue.UNAUTHORIZED,_.error.message));c=await r()}return c})}}const Ae={playbooks:"/v1/playbooks",pages:s=>`/v1/playbooks/${s}/pages`,hotspots:(s,u)=>`/v1/playbooks/${s}/pages/${u}/hotspots`,hotspot:(s,u,r)=>`/v1/playbooks/${s}/pages/${u}/hotspots/${r}`,accessibleIntents:(s,u)=>`/v1/playbooks/${s}/pages/${u}/accessibleIntents`,intents:(s,u,r)=>`/v1/playbooks/${s}/pages/${u}/hotspots/${r}/intents`,intent:(s,u,r,c)=>`/v1/playbooks/${s}/pages/${u}/hotspots/${r}/intents/${c}`},vr=50;class lt{static getInstance(){return lt.instance||(lt.instance=new lt),lt.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async listPlaybooks(u){const r=await this.meltingSpotApi.call({method:On.GET,endpoint:Ae.playbooks,options:{query:{page:u?.page??1,limit:u?.limit??vr,...u?.domain?{"domain[eq]":u.domain}:{}}}});return r.isErr()?B(r.error):un(r.value)}async listPlaybookPages(u){const r=await this.meltingSpotApi.call({method:On.GET,endpoint:Ae.pages(u.playbookId),options:{query:{page:u.page??1,limit:u.limit??vr,...u.url?{"url[eq]":u.url}:{}}}});return r.isErr()?B(r.error):un(r.value)}async createPlaybookPage(u,r){const c=await this.meltingSpotApi.call({method:On.POST,endpoint:Ae.pages(u.playbookId),options:{payload:r}});return c.isErr()?B(c.error):un(c.value)}async listAccessiblePlaybookIntents(u){const r=await this.meltingSpotApi.call({method:On.GET,endpoint:Ae.accessibleIntents(u.playbookId,u.pageId),options:{query:{...u.domain?{domain:u.domain}:{}}}});return r.isErr()?B(r.error):un(r.value)}async listPlaybookHotspots(u){const r=await this.meltingSpotApi.call({method:On.GET,endpoint:Ae.hotspots(u.playbookId,u.pageId),options:{query:{page:u.page??1,limit:u.limit??vr,...u.intentStatus?{"intentStatus[eq]":u.intentStatus}:{},...u.widgetType?{"widgetType[eq]":u.widgetType}:{}}}});return r.isErr()?B(r.error):un(r.value)}async createPlaybookHotspot(u,r){const c=await this.meltingSpotApi.call({method:On.POST,endpoint:Ae.hotspots(u.playbookId,u.pageId),options:{payload:r}});return c.isErr()?B(c.error):un(c.value)}async updatePlaybookHotspot(u,r){const c=await this.meltingSpotApi.call({method:On.PATCH,endpoint:Ae.hotspot(u.playbookId,u.pageId,u.hotspotId),options:{payload:r}});return c.isErr()?B(c.error):un(c.value)}async listPlaybookIntents(u){const r=await this.meltingSpotApi.call({method:On.GET,endpoint:Ae.intents(u.playbookId,u.pageId,u.hotspotId),options:{query:{page:u.page??1,limit:u.limit??vr,...u.status?{"status[eq]":u.status}:{}}}});return r.isErr()?B(r.error):un(r.value)}async createPlaybookIntent(u,r){const c=await this.meltingSpotApi.call({method:On.POST,endpoint:Ae.intents(u.playbookId,u.pageId,u.hotspotId),options:{payload:r}});return c.isErr()?B(c.error):un(c.value)}async updatePlaybookIntent(u,r){const c=await this.meltingSpotApi.call({method:On.PATCH,endpoint:Ae.intent(u.playbookId,u.pageId,u.hotspotId,u.intentId),options:{payload:r}});return c.isErr()?B(c.error):un(c.value)}}const lc={me:"/v1/spots/me"},hc=50;class ht{static getInstance(){return ht.instance||(ht.instance=new ht),ht.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async listSpotsForMe(u){const r=await this.meltingSpotApi.call({method:On.GET,endpoint:lc.me,options:{query:{page:1,limit:hc,...u?.spotMemberRole?{"spotMemberRole[eq]":u.spotMemberRole}:{}}}});return r.isErr()?B(r.error):un(r.value)}}const mi={spotMember:{me:"/v1/spotMembers/me",joinFromSso:"/v1/spotMembers~joinFromSso",search:"/v1/spotMembers~search"}};class pt{static getInstance(){return pt.instance||(pt.instance=new pt),pt.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async getSpotMemberForMe(){const u=await this.meltingSpotApi.call({method:On.GET,endpoint:mi.spotMember.me});return u.isErr()?B(u.error):un(u.value)}async searchSpotMembers(u){const r={page:u.page,limit:u.limit};u.search&&(r.search=u.search);const c=await this.meltingSpotApi.call({method:On.GET,endpoint:mi.spotMember.search,options:{query:r}});return c.isErr()?B(c.error):un(c.value)}async joinFromSso(u){const r=await this.meltingSpotApi.call({method:On.POST,endpoint:mi.spotMember.joinFromSso,options:{payload:{token:u}}});return r.isErr()?B(r.error):un(r.value)}}const ws={spotMemberSsoToken:"/v1/spotMembers/auth/sso/jwt",previewAccessKey:"/v1/spotMembers/auth/preview/accessKey"};class dt{static getInstance(){return dt.instance||(dt.instance=new dt),dt.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async generateSsoToken(){const u=await this.meltingSpotApi.call({method:On.POST,endpoint:ws.spotMemberSsoToken,options:{payload:{}}});return u.isErr()?B(u.error):un(u.value.token)}async generatePreviewAccessKey(u){const r=await this.meltingSpotApi.call({method:On.POST,endpoint:ws.previewAccessKey,options:{payload:{targetSpotMemberId:u.targetSpotMemberId}}});return r.isErr()?B(r.error):un(r.value)}}class _t{static getInstance(){return _t.instance||(_t.instance=new _t),_t.instance}constructor(){this.spotMemberAuthApiService=dt.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}}const pc=s=>{const u=s.get("utm_source");if(u)return{source:u,medium:s.get("utm_medium")??void 0,campaign:s.get("utm_campaign")??void 0,term:s.get("utm_term")??void 0,content:s.get("utm_content")??void 0}},dc=s=>s?Object.entries(s).reduce((u,[r,c])=>(c!=null&&(u[`utm_${r}`]=c),u),{}):{},_c=Jn.getInstance(),gc=ke.getInstance(),mc=_t.getInstance(),vc={Playbook:lt.getInstance(),Spot:ht.getInstance(),SpotMember:pt.getInstance()},gt=globalThis;gt.MeltingSpot||(gt.MeltingSpot={}),gt.MeltingSpot.Configuration=_c,gt.MeltingSpot.Auth=gc,gt.MeltingSpot.Sso=mc,gt.MeltingSpot.Api=vc;const Ec="1.7.0",vi=new ss({appName:"Embed SDK",appVersion:Ec});class Ts{constructor(u){this.content=u}#n=null;#e=null;set onRemove(u){this.#e=u}inject(u){this.remove();const r=af({input:u,rootDocument:this.content.rootDocument});this.#n=this.content.iframe,this.#n.classList.add("ms-embed"),r.appendChild(this.#n)}remove(){this.#n&&(this.#n.contentWindow&&this.#e?.(this.#n.contentWindow),this.#n.remove(),this.#n=null)}}class wc{constructor(u){this.baseURL=Xf(u.baseURL),this.spotId=Kf(u.spotId),this.authToken=u.authToken??null,this.themeMode=u.themeMode??"auto",this.domain=u.domain??null,this.deeplink=u.deeplink?Zf({deeplink:u.deeplink,spotId:this.spotId}):null,this.utmParameters=u.utmParameters??null,this.rootDocument=u.rootDocument}get iframe(){const u=this.authToken&&this.authToken.trim().length>0?"/sso/jwt":"",r=new URL(`/spot/${this.spotId}${u}`,qu(this.baseURL)),c=cf({url:r,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...dc(this.utmParameters)},rootDocument:this.rootDocument});return c.classList.add("ms-spot"),c}}const Er={READY:"meltingspot:ready",ERROR:"meltingspot:error",PREFILL_DRAFT:"meltingspot:prefillDraft"},xn=class xn{static injectSpotInto(u,r){const{onReady:c,onError:_,...v}=r,{spotId:d,rootDocument:A,msCommunityWebBaseUrl:I}=Jn.getConfiguration({spotId:v.spotId,rootDocument:v.rootDocument,msCommunityWebBaseUrl:v.baseURL});if(!d)throw vi.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const H=new URLSearchParams(window.location.search),nn={spotId:d,authToken:v.authToken??H.get("ms_token"),domain:v.domain,deeplink:v.deeplink??H.get("ms_url"),themeMode:v.themeMode,utmParameters:v.utmParameters??pc(H),baseURL:I,rootDocument:A},N=new Ts(new wc(nn));if(N.inject(u),xn.embeds.push(N),c||_){const $=N.content.iframe.contentWindow;$&&(xn.iframeCallbacks.set($,{onReady:c,onError:_}),N.onRemove=q=>{xn.iframeCallbacks.delete(q)}),xn.ensureMessageListener()}return vi.log("Spot injected",nn,u),N}static clear(){xn.embeds.forEach(u=>{u.remove()}),xn.embeds=[],xn.iframeCallbacks.clear(),xn.messageListened&&(window.removeEventListener("message",xn.handleMessageEvent),xn.messageListened=!1),vi.log("All MeltingSpot embeds cleared")}static handleMessageEvent(u){if(!u.data||typeof u.data!="object"||u.data.type!==Er.READY&&u.data.type!==Er.ERROR)return;const r=u.source,c=xn.iframeCallbacks.get(r);if(!c)return;const{msCommunityWebBaseUrl:_}=Jn.getConfiguration({});if(_)try{const v=new URL(_).origin;if(u.origin!==v)return}catch{}u.data.type===Er.READY?c.onReady?.():c.onError?.(u.data.error)}static ensureMessageListener(){xn.messageListened||(window.addEventListener("message",xn.handleMessageEvent),xn.messageListened=!0)}};xn.embeds=[],xn.messageListened=!1,xn.iframeCallbacks=new Map;let wr=xn;const Ei=globalThis;Ei.MeltingSpot||(Ei.MeltingSpot={}),Ei.MeltingSpot.Embed=wr,He.EMBED_POST_MESSAGE_TYPE=Er,He.Embed=wr,He.EmbedFrame=Ts,Object.defineProperty(He,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "MeltingSpot Embed SDK",
4
4
  "homepage": "https://meltingspot.io",
5
5
  "license": "BSD-3-Clause",
6
- "version": "1.6.0",
6
+ "version": "1.7.0",
7
7
  "main": "./index.cjs",
8
8
  "module": "./index.mjs",
9
9
  "typings": "./index.d.ts",
@@ -17,7 +17,7 @@
17
17
  }
18
18
  },
19
19
  "dependencies": {
20
- "@meltingspot/core": "1.6.0"
20
+ "@meltingspot/core": "1.7.0"
21
21
  },
22
22
  "publishConfig": {
23
23
  "provenance": false