@craftercms/studio-ui
Version:
Services, components, models & utils to build CrafterCMS authoring extensions.
1 lines • 55.8 kB
JavaScript
!function(){"use strict";var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function r(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function i(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function s(e){return"function"==typeof e}function a(e){return function(t){if(function(e){return s(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function c(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var u=c((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function l(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var h=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,n,a,c;if(!this.closed){this.closed=!0;var l=this._parentage;if(l)if(this._parentage=null,Array.isArray(l))try{for(var h=r(l),d=h.next();!d.done;d=h.next()){d.value.remove(this)}}catch(t){e={error:t}}finally{try{d&&!d.done&&(t=h.return)&&t.call(h)}finally{if(e)throw e.error}}else l.remove(this);var p=this.initialTeardown;if(s(p))try{p()}catch(e){c=e instanceof u?e.errors:[e]}var y=this._finalizers;if(y){this._finalizers=null;try{for(var b=r(y),m=b.next();!m.done;m=b.next()){var g=m.value;try{f(g)}catch(e){c=null!=c?c:[],e instanceof u?c=i(i([],o(c)),o(e.errors)):c.push(e)}}}catch(e){n={error:e}}finally{try{m&&!m.done&&(a=b.return)&&a.call(b)}finally{if(n)throw n.error}}}if(c)throw new u(c)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)f(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&l(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&l(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function d(e){return e instanceof h||e&&"closed"in e&&s(e.remove)&&s(e.add)&&s(e.unsubscribe)}function f(e){s(e)?e():e.unsubscribe()}h.EMPTY;var p={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},y=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,i([e,t],o(n)))};function b(){}var m=function(e){function n(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,d(t)&&t.add(n)):n.destination=O,n}return t(n,e),n.create=function(e,t,n){return new w(e,t,n)},n.prototype.next=function(e){this.isStopped||this._next(e)},n.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},n.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},n.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},n.prototype._next=function(e){this.destination.next(e)},n.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},n.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},n}(h),g=Function.prototype.bind;function v(e,t){return g.call(e,t)}var _=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){S(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){S(e)}else S(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){S(e)}},e}(),w=function(e){function n(t,n,r){var o,i,a=e.call(this)||this;s(t)||!t?o={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=r?r:void 0}:a&&p.useDeprecatedNextContext?((i=Object.create(t)).unsubscribe=function(){return a.unsubscribe()},o={next:t.next&&v(t.next,i),error:t.error&&v(t.error,i),complete:t.complete&&v(t.complete,i)}):o=t;return a.destination=new _(o),a}return t(n,e),n}(m);function S(e){var t;t=e,y((function(){throw t}))}var O={closed:!0,next:b,error:function(e){throw e},complete:b};var k=function(e){function n(t,n,r,o,i,s){var a=e.call(this,t)||this;return a.onFinalize=i,a.shouldUnsubscribe=s,a._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return t(n,e),n.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},n}(m);function E(e,t){return a((function(n,r){var o,i,s,a=0;n.subscribe(new k(r,(function(n){r.next(e.call(t,n,a++))}),o,i,s))}))}var C="function"==typeof Symbol&&Symbol.observable||"@@observable";function T(e){return e}function A(e){return 0===e.length?T:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var j=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r,o=this,i=(r=e)&&r instanceof m||function(e){return e&&s(e.next)&&s(e.error)&&s(e.complete)}(r)&&d(r)?e:new w(e,t,n);return function(){var e=o,t=e.operator,n=e.source;i.add(t?t.call(i,n):n?o._subscribe(i):o._trySubscribe(i))}(),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=P(t))((function(t,r){var o=new w({next:function(t){try{e(t)}catch(e){r(e),o.unsubscribe()}},error:r,complete:t});n.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[C]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return A(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=P(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function P(e){var t;return null!==(t=null!=e?e:p.Promise)&&void 0!==t?t:Promise}function x(e){switch(e.responseType){case"json":if("response"in e)return e.response;var t=e;return JSON.parse(t.responseText);case"document":return e.responseXML;default:return"response"in e?e.response:(t=e).responseText}}var I=function(e,t,n,r){void 0===r&&(r="download_load"),this.originalEvent=e,this.xhr=t,this.request=n,this.type=r;var o=t.status,i=t.responseType;this.status=null!=o?o:0,this.responseType=null!=i?i:"";var s=t.getAllResponseHeaders();this.responseHeaders=s?s.split("\n").reduce((function(e,t){var n=t.indexOf(": ");return e[t.slice(0,n)]=t.slice(n+2),e}),{}):{},this.response=x(t);var a=e.loaded,c=e.total;this.loaded=a,this.total=c},N=c((function(e){return function(e,t,n){var r;this.message=e,this.name="AjaxError",this.xhr=t,this.request=n,this.status=t.status,this.responseType=t.responseType;try{r=x(t)}catch(e){r=t.responseText}this.response=r}})),H=function(){function e(e,t){return N.call(this,"ajax timeout",e,t),this.name="AjaxTimeoutError",this}return e.prototype=Object.create(N.prototype),e}();function R(e,t){return M({method:"GET",url:e,headers:t})}function F(e,t,n){return M({method:"POST",url:e,body:t,headers:n})}function U(e,t){return M({method:"DELETE",url:e,headers:t})}function B(e,t,n){return M({method:"PUT",url:e,body:t,headers:n})}function D(e,t,n){return M({method:"PATCH",url:e,body:t,headers:n})}var W=E((function(e){return e.response}));function V(e,t){return W(M({method:"GET",url:e,headers:t}))}var L,M=(L=function(e){var t;return t="string"==typeof e?{url:e}:e,new j((function(e){var r,o,i,s=n({async:!0,crossDomain:!1,withCredentials:!1,method:"GET",timeout:0,responseType:"json"},t),a=s.queryParams,c=s.body,u=s.headers,l=s.url;if(!l)throw new TypeError("url is required");if(a)if(l.includes("?")){var h=l.split("?");if(2<h.length)throw new TypeError("invalid url");i=new URLSearchParams(h[1]),new URLSearchParams(a).forEach((function(e,t){return i.set(t,e)})),l=h[0]+"?"+i}else l=l+"?"+(i=new URLSearchParams(a));var d={};if(u)for(var f in u)u.hasOwnProperty(f)&&(d[f.toLowerCase()]=u[f]);var p=s.crossDomain;p||"x-requested-with"in d||(d["x-requested-with"]="XMLHttpRequest");var y=s.withCredentials,b=s.xsrfCookieName,m=s.xsrfHeaderName;if((y||!p)&&b&&m){var g=null!==(o=null===(r=null===document||void 0===document?void 0:document.cookie.match(new RegExp("(^|;\\s*)("+b+")=([^;]*)")))||void 0===r?void 0:r.pop())&&void 0!==o?o:"";g&&(d[m]=g)}var v,_=function(e,t){var n;if(!e||"string"==typeof e||function(e){return"undefined"!=typeof FormData&&e instanceof FormData}(e)||function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}(e)||function(e){return J(e,"ArrayBuffer")}(e)||function(e){return J(e,"File")}(e)||function(e){return J(e,"Blob")}(e)||function(e){return"undefined"!=typeof ReadableStream&&e instanceof ReadableStream}(e))return e;if(function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView(e)}(e))return e.buffer;if("object"==typeof e)return t["content-type"]=null!==(n=t["content-type"])&&void 0!==n?n:"application/json;charset=utf-8",JSON.stringify(e);throw new TypeError("Unknown body type")}(c,d),w=n(n({},s),{url:l,headers:d,body:_});v=t.createXHR?t.createXHR():new XMLHttpRequest;var S=t.progressSubscriber,O=t.includeDownloadProgress,k=void 0!==O&&O,E=t.includeUploadProgress,C=void 0!==E&&E,T=function(t,n){v.addEventListener(t,(function(){var t,r=n();null===(t=null==S?void 0:S.error)||void 0===t||t.call(S,r),e.error(r)}))};T("timeout",(function(){return new H(v,w)})),T("abort",(function(){return new N("aborted",v,w)}));var A=function(e,t){return new I(t,v,w,e+"_"+t.type)},j=function(t,n,r){t.addEventListener(n,(function(t){e.next(A(r,t))}))};C&&[q,G,K].forEach((function(e){return j(v.upload,e,$)})),S&&[q,G].forEach((function(e){return v.upload.addEventListener(e,(function(e){var t;return null===(t=null==S?void 0:S.next)||void 0===t?void 0:t.call(S,e)}))})),k&&[q,G].forEach((function(e){return j(v,e,z)}));var P=function(t){var n="ajax error"+(t?" "+t:"");e.error(new N(n,v,w))};v.addEventListener("error",(function(e){var t;null===(t=null==S?void 0:S.error)||void 0===t||t.call(S,e),P()})),v.addEventListener(K,(function(t){var n,r,o=v.status;if(o<400){null===(n=null==S?void 0:S.complete)||void 0===n||n.call(S);var i=void 0;try{i=A(z,t)}catch(t){return void e.error(t)}e.next(i),e.complete()}else null===(r=null==S?void 0:S.error)||void 0===r||r.call(S,t),P(o)}));var x=w.user,R=w.method,F=w.async;for(var f in x?v.open(R,l,F,x,w.password):v.open(R,l,F),F&&(v.timeout=w.timeout,v.responseType=w.responseType),"withCredentials"in v&&(v.withCredentials=w.withCredentials),d)d.hasOwnProperty(f)&&v.setRequestHeader(f,d[f]);return _?v.send(_):v.send(),function(){v&&4!==v.readyState&&v.abort()}}))},L.get=R,L.post=F,L.delete=U,L.put=B,L.patch=D,L.getJSON=V,L),$="upload",z="download",q="loadstart",G="progress",K="load";var X=Object.prototype.toString;function J(e,t){return X.call(e)==="[object "+t+"]"}var Y=e=>encodeURIComponent(e).replace(/[!'()*]/g,(e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)),Q="%[a-f0-9]{2}",Z=new RegExp("("+Q+")|([^%]+?)","gi"),ee=new RegExp("("+Q+")+","gi");function te(e,t){try{return[decodeURIComponent(e.join(""))]}catch(e){}if(1===e.length)return e;t=t||1;var n=e.slice(0,t),r=e.slice(t);return Array.prototype.concat.call([],te(n),te(r))}function ne(e){try{return decodeURIComponent(e)}catch(r){for(var t=e.match(Z)||[],n=1;n<t.length;n++)t=(e=te(t,n).join("")).match(Z)||[];return e}}var re=function(e){if("string"!=typeof e)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return e=e.replace(/\+/g," "),decodeURIComponent(e)}catch(t){return function(e){for(var t={"%FE%FF":"��","%FF%FE":"��"},n=ee.exec(e);n;){try{t[n[0]]=decodeURIComponent(n[0])}catch(e){var r=ne(n[0]);r!==n[0]&&(t[n[0]]=r)}n=ee.exec(e)}t["%C2"]="�";for(var o=Object.keys(t),i=0;i<o.length;i++){var s=o[i];e=e.replace(new RegExp(s,"g"),t[s])}return e}(e)}},oe=(e,t)=>{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===t)return[e];const n=e.indexOf(t);return-1===n?[e]:[e.slice(0,n),e.slice(n+t.length)]},ie=function(e,t){for(var n={},r=Object.keys(e),o=Array.isArray(t),i=0;i<r.length;i++){var s=r[i],a=e[s];(o?-1!==t.indexOf(s):t(s,a,e))&&(n[s]=a)}return n};function se(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];throw Error("[Immer] minified error nr: "+e+(n.length?" "+n.map((function(e){return"'"+e+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function ae(e){return!!e&&!!e[Ge]}function ce(e){var t;return!!e&&(function(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Ke}(e)||Array.isArray(e)||!!e[qe]||!!(null===(t=e.constructor)||void 0===t?void 0:t[qe])||pe(e)||ye(e))}function ue(e,t,n){void 0===n&&(n=!1),0===le(e)?(n?Object.keys:Xe)(e).forEach((function(r){n&&"symbol"==typeof r||t(r,e[r],e)})):e.forEach((function(n,r){return t(r,n,e)}))}function le(e){var t=e[Ge];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:pe(e)?2:ye(e)?3:0}function he(e,t){return 2===le(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function de(e,t,n){var r=le(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n}function fe(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function pe(e){return Le&&e instanceof Map}function ye(e){return Me&&e instanceof Set}function be(e){return e.o||e.t}function me(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=Je(e);delete t[Ge];for(var n=Xe(t),r=0;r<n.length;r++){var o=n[r],i=t[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(Object.getPrototypeOf(e),t)}function ge(e,t){return void 0===t&&(t=!1),_e(e)||ae(e)||!ce(e)||(le(e)>1&&(e.set=e.add=e.clear=e.delete=ve),Object.freeze(e),t&&ue(e,(function(e,t){return ge(t,!0)}),!0)),e}function ve(){se(2)}function _e(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function we(e){var t=Ye[e];return t||se(18,e),t}function Se(){return We}function Oe(e,t){t&&(we("Patches"),e.u=[],e.s=[],e.v=t)}function ke(e){Ee(e),e.p.forEach(Te),e.p=null}function Ee(e){e===We&&(We=e.l)}function Ce(e){return We={p:[],l:We,h:e,m:!0,_:0}}function Te(e){var t=e[Ge];0===t.i||1===t.i?t.j():t.O=!0}function Ae(e,t){t._=t.p.length;var n=t.p[0],r=void 0!==e&&e!==n;return t.h.g||we("ES5").S(t,e,r),r?(n[Ge].P&&(ke(t),se(4)),ce(e)&&(e=je(t,e),t.l||xe(t,e)),t.u&&we("Patches").M(n[Ge].t,e,t.u,t.s)):e=je(t,n,[]),ke(t),t.u&&t.v(t.u,t.s),e!==ze?e:void 0}function je(e,t,n){if(_e(t))return t;var r=t[Ge];if(!r)return ue(t,(function(o,i){return Pe(e,r,t,o,i,n)}),!0),t;if(r.A!==e)return t;if(!r.P)return xe(e,r.t,!0),r.t;if(!r.I){r.I=!0,r.A._--;var o=4===r.i||5===r.i?r.o=me(r.k):r.o,i=o,s=!1;3===r.i&&(i=new Set(o),o.clear(),s=!0),ue(i,(function(t,i){return Pe(e,r,o,t,i,n,s)})),xe(e,o,!1),n&&e.u&&we("Patches").N(r,n,e.u,e.s)}return r.o}function Pe(e,t,n,r,o,i,s){if(ae(o)){var a=je(e,o,i&&t&&3!==t.i&&!he(t.R,r)?i.concat(r):void 0);if(de(n,r,a),!ae(a))return;e.m=!1}else s&&n.add(o);if(ce(o)&&!_e(o)){if(!e.h.D&&e._<1)return;je(e,o),t&&t.A.l||xe(e,o)}}function xe(e,t,n){void 0===n&&(n=!1),!e.l&&e.h.D&&e.m&&ge(t,n)}function Ie(e,t){var n=e[Ge];return(n?be(n):e)[t]}function Ne(e,t){if(t in e)for(var n=Object.getPrototypeOf(e);n;){var r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Object.getPrototypeOf(n)}}function He(e){e.P||(e.P=!0,e.l&&He(e.l))}function Re(e){e.o||(e.o=me(e.t))}function Fe(e,t,n){var r=pe(t)?we("MapSet").F(t,n):ye(t)?we("MapSet").T(t,n):e.g?function(e,t){var n=Array.isArray(e),r={i:n?1:0,A:t?t.A:Se(),P:!1,I:!1,R:{},l:t,t:e,k:null,o:null,j:null,C:!1},o=r,i=Qe;n&&(o=[r],i=Ze);var s=Proxy.revocable(o,i),a=s.revoke,c=s.proxy;return r.k=c,r.j=a,c}(t,n):we("ES5").J(t,n);return(n?n.A:Se()).p.push(r),r}function Ue(e){return ae(e)||se(22,e),function e(t){if(!ce(t))return t;var n,r=t[Ge],o=le(t);if(r){if(!r.P&&(r.i<4||!we("ES5").K(r)))return r.t;r.I=!0,n=Be(t,o),r.I=!1}else n=Be(t,o);return ue(n,(function(t,o){r&&function(e,t){return 2===le(e)?e.get(t):e[t]}(r.t,t)===o||de(n,t,e(o))})),3===o?new Set(n):n}(e)}function Be(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return me(e)}!function(e){const t=Y,n=re,r=oe,o=ie;function i(e){if("string"!=typeof e||1!==e.length)throw new TypeError("arrayFormatSeparator must be single character string")}function s(e,n){return n.encode?n.strict?t(e):encodeURIComponent(e):e}function a(e,t){return t.decode?n(e):e}function c(e){return Array.isArray(e)?e.sort():"object"==typeof e?c(Object.keys(e)).sort(((e,t)=>Number(e)-Number(t))).map((t=>e[t])):e}function u(e){const t=e.indexOf("#");return-1!==t&&(e=e.slice(0,t)),e}function l(e){const t=(e=u(e)).indexOf("?");return-1===t?"":e.slice(t+1)}function h(e,t){return t.parseNumbers&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?e=Number(e):!t.parseBooleans||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(e="true"===e.toLowerCase()),e}function d(e,t){i((t=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},t)).arrayFormatSeparator);const n=function(e){let t;switch(e.arrayFormat){case"index":return(e,n,r)=>{t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===r[e]&&(r[e]={}),r[e][t[1]]=n):r[e]=n};case"bracket":return(e,n,r)=>{t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==r[e]?r[e]=[].concat(r[e],n):r[e]=[n]:r[e]=n};case"comma":case"separator":return(t,n,r)=>{const o="string"==typeof n&&n.includes(e.arrayFormatSeparator),i="string"==typeof n&&!o&&a(n,e).includes(e.arrayFormatSeparator);n=i?a(n,e):n;const s=o||i?n.split(e.arrayFormatSeparator).map((t=>a(t,e))):null===n?n:a(n,e);r[t]=s};default:return(e,t,n)=>{void 0!==n[e]?n[e]=[].concat(n[e],t):n[e]=t}}}(t),o=Object.create(null);if("string"!=typeof e)return o;if(!(e=e.trim().replace(/^[?#&]/,"")))return o;for(const i of e.split("&")){if(""===i)continue;let[e,s]=r(t.decode?i.replace(/\+/g," "):i,"=");s=void 0===s?null:["comma","separator"].includes(t.arrayFormat)?s:a(s,t),n(a(e,t),s,o)}for(const e of Object.keys(o)){const n=o[e];if("object"==typeof n&&null!==n)for(const e of Object.keys(n))n[e]=h(n[e],t);else o[e]=h(n,t)}return!1===t.sort?o:(!0===t.sort?Object.keys(o).sort():Object.keys(o).sort(t.sort)).reduce(((e,t)=>{const n=o[t];return Boolean(n)&&"object"==typeof n&&!Array.isArray(n)?e[t]=c(n):e[t]=n,e}),Object.create(null))}e.extract=l,e.parse=d,e.stringify=(e,t)=>{if(!e)return"";i((t=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},t)).arrayFormatSeparator);const n=n=>t.skipNull&&null==e[n]||t.skipEmptyString&&""===e[n],r=function(e){switch(e.arrayFormat){case"index":return t=>(n,r)=>{const o=n.length;return void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,[s(t,e),"[",o,"]"].join("")]:[...n,[s(t,e),"[",s(o,e),"]=",s(r,e)].join("")]};case"bracket":return t=>(n,r)=>void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,[s(t,e),"[]"].join("")]:[...n,[s(t,e),"[]=",s(r,e)].join("")];case"comma":case"separator":return t=>(n,r)=>null==r||0===r.length?n:0===n.length?[[s(t,e),"=",s(r,e)].join("")]:[[n,s(r,e)].join(e.arrayFormatSeparator)];default:return t=>(n,r)=>void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,s(t,e)]:[...n,[s(t,e),"=",s(r,e)].join("")]}}(t),o={};for(const t of Object.keys(e))n(t)||(o[t]=e[t]);const a=Object.keys(o);return!1!==t.sort&&a.sort(t.sort),a.map((n=>{const o=e[n];return void 0===o?"":null===o?s(n,t):Array.isArray(o)?o.reduce(r(n),[]).join("&"):s(n,t)+"="+s(o,t)})).filter((e=>e.length>0)).join("&")},e.parseUrl=(e,t)=>{t=Object.assign({decode:!0},t);const[n,o]=r(e,"#");return Object.assign({url:n.split("?")[0]||"",query:d(l(e),t)},t&&t.parseFragmentIdentifier&&o?{fragmentIdentifier:a(o,t)}:{})},e.stringifyUrl=(t,n)=>{n=Object.assign({encode:!0,strict:!0},n);const r=u(t.url).split("?")[0]||"",o=e.extract(t.url),i=e.parse(o,{sort:!1}),a=Object.assign(i,t.query);let c=e.stringify(a,n);c&&(c=`?${c}`);let l=function(e){let t="";const n=e.indexOf("#");return-1!==n&&(t=e.slice(n)),t}(t.url);return t.fragmentIdentifier&&(l=`#${s(t.fragmentIdentifier,n)}`),`${r}${c}${l}`},e.pick=(t,n,r)=>{r=Object.assign({parseFragmentIdentifier:!0},r);const{url:i,query:s,fragmentIdentifier:a}=e.parseUrl(t,r);return e.stringifyUrl({url:i,query:o(s,n),fragmentIdentifier:a},r)},e.exclude=(t,n,r)=>{const o=Array.isArray(n)?e=>!n.includes(e):(e,t)=>!n(e,t);return e.pick(t,o,r)}}({});var De,We,Ve="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),Le="undefined"!=typeof Map,Me="undefined"!=typeof Set,$e="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,ze=Ve?Symbol.for("immer-nothing"):((De={})["immer-nothing"]=!0,De),qe=Ve?Symbol.for("immer-draftable"):"__$immer_draftable",Ge=Ve?Symbol.for("immer-state"):"__$immer_state",Ke=""+Object.prototype.constructor,Xe="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,Je=Object.getOwnPropertyDescriptors||function(e){var t={};return Xe(e).forEach((function(n){t[n]=Object.getOwnPropertyDescriptor(e,n)})),t},Ye={},Qe={get:function(e,t){if(t===Ge)return e;var n=be(e);if(!he(n,t))return function(e,t,n){var r,o=Ne(t,n);return o?"value"in o?o.value:null===(r=o.get)||void 0===r?void 0:r.call(e.k):void 0}(e,n,t);var r=n[t];return e.I||!ce(r)?r:r===Ie(e.t,t)?(Re(e),e.o[t]=Fe(e.A.h,r,e)):r},has:function(e,t){return t in be(e)},ownKeys:function(e){return Reflect.ownKeys(be(e))},set:function(e,t,n){var r=Ne(be(e),t);if(null==r?void 0:r.set)return r.set.call(e.k,n),!0;if(!e.P){var o=Ie(be(e),t),i=null==o?void 0:o[Ge];if(i&&i.t===n)return e.o[t]=n,e.R[t]=!1,!0;if(fe(n,o)&&(void 0!==n||he(e.t,t)))return!0;Re(e),He(e)}return e.o[t]===n&&(void 0!==n||t in e.o)||Number.isNaN(n)&&Number.isNaN(e.o[t])||(e.o[t]=n,e.R[t]=!0),!0},deleteProperty:function(e,t){return void 0!==Ie(e.t,t)||t in e.t?(e.R[t]=!1,Re(e),He(e)):delete e.R[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var n=be(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty:function(){se(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){se(12)}},Ze={};ue(Qe,(function(e,t){Ze[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Ze.deleteProperty=function(e,t){return Ze.set.call(this,e,t,void 0)},Ze.set=function(e,t,n){return Qe.set.call(this,e[0],t,n,e[0])};var et=function(){function e(e){var t=this;this.g=$e,this.D=!0,this.produce=function(e,n,r){if("function"==typeof e&&"function"!=typeof n){var o=n;n=e;var i=t;return function(e){var t=this;void 0===e&&(e=o);for(var r=arguments.length,s=Array(r>1?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];return i.produce(e,(function(e){var r;return(r=n).call.apply(r,[t,e].concat(s))}))}}var s;if("function"!=typeof n&&se(6),void 0!==r&&"function"!=typeof r&&se(7),ce(e)){var a=Ce(t),c=Fe(t,e,void 0),u=!0;try{s=n(c),u=!1}finally{u?ke(a):Ee(a)}return"undefined"!=typeof Promise&&s instanceof Promise?s.then((function(e){return Oe(a,r),Ae(e,a)}),(function(e){throw ke(a),e})):(Oe(a,r),Ae(s,a))}if(!e||"object"!=typeof e){if(void 0===(s=n(e))&&(s=e),s===ze&&(s=void 0),t.D&&ge(s,!0),r){var l=[],h=[];we("Patches").M(e,s,l,h),r(l,h)}return s}se(21,e)},this.produceWithPatches=function(e,n){if("function"==typeof e)return function(n){for(var r=arguments.length,o=Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return t.produceWithPatches(n,(function(t){return e.apply(void 0,[t].concat(o))}))};var r,o,i=t.produce(e,n,(function(e,t){r=e,o=t}));return"undefined"!=typeof Promise&&i instanceof Promise?i.then((function(e){return[e,r,o]})):[i,r,o]},"boolean"==typeof(null==e?void 0:e.useProxies)&&this.setUseProxies(e.useProxies),"boolean"==typeof(null==e?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze)}var t=e.prototype;return t.createDraft=function(e){ce(e)||se(8),ae(e)&&(e=Ue(e));var t=Ce(this),n=Fe(this,e,void 0);return n[Ge].C=!0,Ee(t),n},t.finishDraft=function(e,t){var n=(e&&e[Ge]).A;return Oe(n,t),Ae(void 0,n)},t.setAutoFreeze=function(e){this.D=e},t.setUseProxies=function(e){e&&!$e&&se(20),this.g=e},t.applyPatches=function(e,t){var n;for(n=t.length-1;n>=0;n--){var r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));var o=we("Patches").$;return ae(e)?o(e,t):this.produce(e,(function(e){return o(e,t)}))},e}(),tt=new et;tt.produce,tt.produceWithPatches.bind(tt),tt.setAutoFreeze.bind(tt),tt.setUseProxies.bind(tt),tt.applyPatches.bind(tt),tt.createDraft.bind(tt),tt.finishDraft.bind(tt);var nt=this&&this.__extends||function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),rt=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},ot=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e},it=Object.defineProperty,st=Object.defineProperties,at=Object.getOwnPropertyDescriptors,ct=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,lt=Object.prototype.propertyIsEnumerable,ht=function(e,t,n){return t in e?it(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},dt=function(e,t){for(var n in t||(t={}))ut.call(t,n)&&ht(e,n,t[n]);if(ct)for(var r=0,o=ct(t);r<o.length;r++){n=o[r];lt.call(t,n)&&ht(e,n,t[n])}return e},ft=function(e,t){return st(e,at(t))};function pt(e,t){function n(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];if(t){var o=t.apply(void 0,n);if(!o)throw new Error("prepareAction did not return an object");return dt(dt({type:e,payload:o.payload},"meta"in o&&{meta:o.meta}),"error"in o&&{error:o.error})}return{type:e,payload:n[0]}}return n.toString=function(){return""+e},n.type=e,n.match=function(t){return t.type===e},n}!function(e){function t(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var o=e.apply(this,n)||this;return Object.setPrototypeOf(o,t.prototype),o}nt(t,e),Object.defineProperty(t,Symbol.species,{get:function(){return t},enumerable:!1,configurable:!0}),t.prototype.concat=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.prototype.concat.apply(this,t)},t.prototype.prepend=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return 1===e.length&&Array.isArray(e[0])?new(t.bind.apply(t,ot([void 0],e[0].concat(this)))):new(t.bind.apply(t,ot([void 0],e.concat(this))))}}(Array);var yt=["name","message","stack","code"],bt=function(e,t){this.payload=e,this.meta=t},mt=function(e,t){this.payload=e,this.meta=t},gt=function(e){if("object"==typeof e&&null!==e){for(var t={},n=0,r=yt;n<r.length;n++){var o=r[n];"string"==typeof e[o]&&(t[o]=e[o])}return t}return{message:String(e)}};function vt(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}!function(){function e(e,t,n){var r=pt(e+"/fulfilled",(function(e,t,n,r){return{payload:e,meta:ft(dt({},r||{}),{arg:n,requestId:t,requestStatus:"fulfilled"})}})),o=pt(e+"/pending",(function(e,t,n){return{payload:void 0,meta:ft(dt({},n||{}),{arg:t,requestId:e,requestStatus:"pending"})}})),i=pt(e+"/rejected",(function(e,t,r,o,i){return{payload:o,error:(n&&n.serializeError||gt)(e||"Rejected"),meta:ft(dt({},i||{}),{arg:r,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===(null==e?void 0:e.name),condition:"ConditionError"===(null==e?void 0:e.name)})}})),s="undefined"!=typeof AbortController?AbortController:function(){function e(){this.signal={aborted:!1,addEventListener:function(){},dispatchEvent:function(){return!1},onabort:function(){},removeEventListener:function(){},reason:void 0,throwIfAborted:function(){}}}return e.prototype.abort=function(){},e}();return Object.assign((function(e){return function(a,c,u){var l,h=(null==n?void 0:n.idGenerator)?n.idGenerator(e):function(e){void 0===e&&(e=21);for(var t="",n=e;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t}(),d=new s;function f(e){l=e,d.abort()}var p=function(){return s=this,p=null,y=function(){var s,p,y,b,m,g;return rt(this,(function(v){switch(v.label){case 0:return v.trys.push([0,4,,5]),b=null==(s=null==n?void 0:n.condition)?void 0:s.call(n,e,{getState:c,extra:u}),null===(_=b)||"object"!=typeof _||"function"!=typeof _.then?[3,2]:[4,b];case 1:b=v.sent(),v.label=2;case 2:if(!1===b||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};return m=new Promise((function(e,t){return d.signal.addEventListener("abort",(function(){return t({name:"AbortError",message:l||"Aborted"})}))})),a(o(h,e,null==(p=null==n?void 0:n.getPendingMeta)?void 0:p.call(n,{requestId:h,arg:e},{getState:c,extra:u}))),[4,Promise.race([m,Promise.resolve(t(e,{dispatch:a,getState:c,extra:u,requestId:h,signal:d.signal,abort:f,rejectWithValue:function(e,t){return new bt(e,t)},fulfillWithValue:function(e,t){return new mt(e,t)}})).then((function(t){if(t instanceof bt)throw t;return t instanceof mt?r(t.payload,h,e,t.meta):r(t,h,e)}))])];case 3:return y=v.sent(),[3,5];case 4:return g=v.sent(),y=g instanceof bt?i(null,h,e,g.payload,g.meta):i(g,h,e),[3,5];case 5:return n&&!n.dispatchConditionRejection&&i.match(y)&&y.meta.condition||a(y),[2,y]}var _}))},new Promise((function(e,t){var n=function(e){try{o(y.next(e))}catch(e){t(e)}},r=function(e){try{o(y.throw(e))}catch(e){t(e)}},o=function(t){return t.done?e(t.value):Promise.resolve(t.value).then(n,r)};o((y=y.apply(s,p)).next())}));var s,p,y}();return Object.assign(p,{abort:f,requestId:h,arg:e,unwrap:function(){return p.then(vt)}})}}),{pending:o,rejected:i,fulfilled:r,typePrefix:e})}e.withTypes=function(){return e}}();var _t="listenerMiddleware";pt(_t+"/add"),pt(_t+"/removeAll"),pt(_t+"/remove"),"function"==typeof queueMicrotask&&queueMicrotask.bind("undefined"!=typeof window?window:"undefined"!=typeof global?global:globalThis),function(){function e(e,t){var n=o[e];return n?n.enumerable=t:o[e]=n={configurable:!0,enumerable:t,get:function(){var t=this[Ge];return Qe.get(t,e)},set:function(t){var n=this[Ge];Qe.set(n,e,t)}},n}function t(e){for(var t=e.length-1;t>=0;t--){var o=e[t][Ge];if(!o.P)switch(o.i){case 5:r(o)&&He(o);break;case 4:n(o)&&He(o)}}}function n(e){for(var t=e.t,n=e.k,r=Xe(n),o=r.length-1;o>=0;o--){var i=r[o];if(i!==Ge){var s=t[i];if(void 0===s&&!he(t,i))return!0;var a=n[i],c=a&&a[Ge];if(c?c.t!==s:!fe(a,s))return!0}}var u=!!t[Ge];return r.length!==Xe(t).length+(u?0:1)}function r(e){var t=e.k;if(t.length!==e.t.length)return!0;var n=Object.getOwnPropertyDescriptor(t,t.length-1);if(n&&!n.get)return!0;for(var r=0;r<t.length;r++)if(!t.hasOwnProperty(r))return!0;return!1}var o={};!function(e,t){Ye[e]||(Ye[e]=t)}("ES5",{J:function(t,n){var r=Array.isArray(t),o=function(t,n){if(t){for(var r=Array(n.length),o=0;o<n.length;o++)Object.defineProperty(r,""+o,e(o,!0));return r}var i=Je(n);delete i[Ge];for(var s=Xe(i),a=0;a<s.length;a++){var c=s[a];i[c]=e(c,t||!!i[c].enumerable)}return Object.create(Object.getPrototypeOf(n),i)}(r,t),i={i:r?5:4,A:n?n.A:Se(),P:!1,I:!1,R:{},l:n,t:t,k:o,o:null,O:!1,C:!1};return Object.defineProperty(o,Ge,{value:i,writable:!0}),o},S:function(e,n,o){o?ae(n)&&n[Ge].A===e&&t(e.p):(e.u&&function e(t){if(t&&"object"==typeof t){var n=t[Ge];if(n){var o=n.t,i=n.k,s=n.R,a=n.i;if(4===a)ue(i,(function(t){t!==Ge&&(void 0!==o[t]||he(o,t)?s[t]||e(i[t]):(s[t]=!0,He(n)))})),ue(o,(function(e){void 0!==i[e]||he(i,e)||(s[e]=!1,He(n))}));else if(5===a){if(r(n)&&(He(n),s.length=!0),i.length<o.length)for(var c=i.length;c<o.length;c++)s[c]=!1;else for(var u=o.length;u<i.length;u++)s[u]=!0;for(var l=Math.min(i.length,o.length),h=0;h<l;h++)i.hasOwnProperty(h)||(s[h]=!0),void 0===s[h]&&e(i[h])}}}}(e.p[0]),t(e.p))},K:function(e){return 4===e.i?n(e):r(e)}})}();var wt={},St=Symbol("OmitGlobalHeaders");function Ot(e,t){return M.get(e,function(e){if(void 0===e&&(e={}),e&&e!==St)return Object.values(e).includes(St)?e:Object.assign({},wt,e)}(t))}function kt(){return Ot("/studio/refresh.json").pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.length;if(0===n)throw new Error("list of properties cannot be empty.");return E((function(t){for(var r=t,o=0;o<n;o++){var i=null==r?void 0:r[e[o]];if(void 0===i)return;r=i}return r}))}("response"),E((function(e){return{token:e.token,expiresAt:new Date(e.expiresAt).getTime()}})))}var Et=pt("LOGOUT"),Ct=pt("REFRESH_AUTH_TOKEN"),Tt=pt("SHARED_WORKER_TOKEN"),At=pt("SHARED_WORKER_UNAUTHENTICATED"),jt=pt("SHARED_WORKER_ERROR"),Pt=pt("CONNECT"),xt=pt("DISCONNECT"),It=pt("TIMEOUT");const Nt="\n",Ht="\0";class Rt{constructor(e){const{command:t,headers:n,body:r,binaryBody:o,escapeHeaderValues:i,skipContentLengthHeader:s}=e;this.command=t,this.headers=Object.assign({},n||{}),o?(this._binaryBody=o,this.isBinaryBody=!0):(this._body=r||"",this.isBinaryBody=!1),this.escapeHeaderValues=i||!1,this.skipContentLengthHeader=s||!1}get body(){return!this._body&&this.isBinaryBody&&(this._body=(new TextDecoder).decode(this._binaryBody)),this._body||""}get binaryBody(){return this._binaryBody||this.isBinaryBody||(this._binaryBody=(new TextEncoder).encode(this._body)),this._binaryBody}static fromRawFrame(e,t){const n={},r=e=>e.replace(/^\s+|\s+$/g,"");for(const o of e.headers.reverse()){o.indexOf(":");const i=r(o[0]);let s=r(o[1]);t&&"CONNECT"!==e.command&&"CONNECTED"!==e.command&&(s=Rt.hdrValueUnEscape(s)),n[i]=s}return new Rt({command:e.command,headers:n,binaryBody:e.binaryBody,escapeHeaderValues:t})}toString(){return this.serializeCmdAndHeaders()}serialize(){const e=this.serializeCmdAndHeaders();return this.isBinaryBody?Rt.toUnit8Array(e,this._binaryBody).buffer:e+this._body+Ht}serializeCmdAndHeaders(){const e=[this.command];this.skipContentLengthHeader&&delete this.headers["content-length"];for(const t of Object.keys(this.headers||{})){const n=this.headers[t];this.escapeHeaderValues&&"CONNECT"!==this.command&&"CONNECTED"!==this.command?e.push(`${t}:${Rt.hdrValueEscape(`${n}`)}`):e.push(`${t}:${n}`)}return(this.isBinaryBody||!this.isBodyEmpty()&&!this.skipContentLengthHeader)&&e.push(`content-length:${this.bodyLength()}`),e.join(Nt)+Nt+Nt}isBodyEmpty(){return 0===this.bodyLength()}bodyLength(){const e=this.binaryBody;return e?e.length:0}static sizeOfUTF8(e){return e?(new TextEncoder).encode(e).length:0}static toUnit8Array(e,t){const n=(new TextEncoder).encode(e),r=new Uint8Array([0]),o=new Uint8Array(n.length+t.length+r.length);return o.set(n),o.set(t,n.length),o.set(r,n.length+t.length),o}static marshall(e){return new Rt(e).serialize()}static hdrValueEscape(e){return e.replace(/\\/g,"\\\\").replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/:/g,"\\c")}static hdrValueUnEscape(e){return e.replace(/\\r/g,"\r").replace(/\\n/g,"\n").replace(/\\c/g,":").replace(/\\\\/g,"\\")}}class Ft{constructor(e,t){this.onFrame=e,this.onIncomingPing=t,this._encoder=new TextEncoder,this._decoder=new TextDecoder,this._token=[],this._initState()}parseChunk(e,t=!1){let n;if(n="string"==typeof e?this._encoder.encode(e):new Uint8Array(e),t&&0!==n[n.length-1]){const e=new Uint8Array(n.length+1);e.set(n,0),e[n.length]=0,n=e}for(let e=0;e<n.length;e++){const t=n[e];this._onByte(t)}}_collectFrame(e){0!==e&&13!==e&&(10!==e?(this._onByte=this._collectCommand,this._reinjectByte(e)):this.onIncomingPing())}_collectCommand(e){if(13!==e)return 10===e?(this._results.command=this._consumeTokenAsUTF8(),void(this._onByte=this._collectHeaders)):void this._consumeByte(e)}_collectHeaders(e){13!==e&&(10!==e?(this._onByte=this._collectHeaderKey,this._reinjectByte(e)):this._setupCollectBody())}_reinjectByte(e){this._onByte(e)}_collectHeaderKey(e){if(58===e)return this._headerKey=this._consumeTokenAsUTF8(),void(this._onByte=this._collectHeaderValue);this._consumeByte(e)}_collectHeaderValue(e){if(13!==e)return 10===e?(this._results.headers.push([this._headerKey,this._consumeTokenAsUTF8()]),this._headerKey=void 0,void(this._onByte=this._collectHeaders)):void this._consumeByte(e)}_setupCollectBody(){const e=this._results.headers.filter((e=>"content-length"===e[0]))[0];e?(this._bodyBytesRemaining=parseInt(e[1],10),this._onByte=this._collectBodyFixedSize):this._onByte=this._collectBodyNullTerminated}_collectBodyNullTerminated(e){0!==e?this._consumeByte(e):this._retrievedBody()}_collectBodyFixedSize(e){0!=this._bodyBytesRemaining--?this._consumeByte(e):this._retrievedBody()}_retrievedBody(){this._results.binaryBody=this._consumeTokenAsRaw();try{this.onFrame(this._results)}catch(e){console.log("Ignoring an exception thrown by a frame handler. Original exception: ",e)}this._initState()}_consumeByte(e){this._token.push(e)}_consumeTokenAsUTF8(){return this._decoder.decode(this._consumeTokenAsRaw())}_consumeTokenAsRaw(){const e=new Uint8Array(this._token);return this._token=[],e}_initState(){this._results={command:void 0,headers:[],binaryBody:void 0},this._token=[],this._headerKey=void 0,this._onByte=this._collectFrame}}var Ut,Bt;!function(e){e[e.CONNECTING=0]="CONNECTING",e[e.OPEN=1]="OPEN",e[e.CLOSING=2]="CLOSING",e[e.CLOSED=3]="CLOSED"}(Ut=Ut||(Ut={})),function(e){e[e.ACTIVE=0]="ACTIVE",e[e.DEACTIVATING=1]="DEACTIVATING",e[e.INACTIVE=2]="INACTIVE"}(Bt=Bt||(Bt={}));class Dt{constructor(e){this.versions=e}supportedVersions(){return this.versions.join(",")}protocolVersions(){return this.versions.map((e=>`v${e.replace(".","")}.stomp`))}}Dt.V1_0="1.0",Dt.V1_1="1.1",Dt.V1_2="1.2",Dt.default=new Dt([Dt.V1_2,Dt.V1_1,Dt.V1_0]);class Wt{constructor(e,t,n){this._client=e,this._webSocket=t,this._connected=!1,this._serverFrameHandlers={CONNECTED:e=>{this.debug(`connected to server ${e.headers.server}`),this._connected=!0,this._connectedVersion=e.headers.version,this._connectedVersion===Dt.V1_2&&(this._escapeHeaderValues=!0),this._setupHeartbeat(e.headers),this.onConnect(e)},MESSAGE:e=>{const t=e.headers.subscription,n=this._subscriptions[t]||this.onUnhandledMessage,r=e,o=this,i=this._connectedVersion===Dt.V1_2?r.headers.ack:r.headers["message-id"];r.ack=(e={})=>o.ack(i,t,e),r.nack=(e={})=>o.nack(i,t,e),n(r)},RECEIPT:e=>{const t=this._receiptWatchers[e.headers["receipt-id"]];t?(t(e),delete this._receiptWatchers[e.headers["receipt-id"]]):this.onUnhandledReceipt(e)},ERROR:e=>{this.onStompError(e)}},this._counter=0,this._subscriptions={},this._receiptWatchers={},this._partialData="",this._escapeHeaderValues=!1,this._lastServerActivityTS=Date.now(),this.debug=n.debug,this.stompVersions=n.stompVersions,this.connectHeaders=n.connectHeaders,this.disconnectHeaders=n.disconnectHeaders,this.heartbeatIncoming=n.heartbeatIncoming,this.heartbeatOutgoing=n.heartbeatOutgoing,this.splitLargeFrames=n.splitLargeFrames,this.maxWebSocketChunkSize=n.maxWebSocketChunkSize,this.forceBinaryWSFrames=n.forceBinaryWSFrames,this.logRawCommunication=n.logRawCommunication,this.appendMissingNULLonIncoming=n.appendMissingNULLonIncoming,this.discardWebsocketOnCommFailure=n.discardWebsocketOnCommFailure,this.onConnect=n.onConnect,this.onDisconnect=n.onDisconnect,this.onStompError=n.onStompError,this.onWebSocketClose=n.onWebSocketClose,this.onWebSocketError=n.onWebSocketError,this.onUnhandledMessage=n.onUnhandledMessage,this.onUnhandledReceipt=n.onUnhandledReceipt,this.onUnhandledFrame=n.onUnhandledFrame}get connectedVersion(){return this._connectedVersion}get connected(){return this._connected}start(){const e=new Ft((e=>{const t=Rt.fromRawFrame(e,this._escapeHeaderValues);this.logRawCommunication||this.debug(`<<< ${t}`);(this._serverFrameHandlers[t.command]||this.onUnhandledFrame)(t)}),(()=>{this.debug("<<< PONG")}));this._webSocket.onmessage=t=>{if(this.debug("Received data"),this._lastServerActivityTS=Date.now(),this.logRawCommunication){const e=t.data instanceof ArrayBuffer?(new TextDecoder).decode(t.data):t.data;this.debug(`<<< ${e}`)}e.parseChunk(t.data,this.appendMissingNULLonIncoming)},this._webSocket.onclose=e=>{this.debug(`Connection closed to ${this._webSocket.url}`),this._cleanUp(),this.onWebSocketClose(e)},this._webSocket.onerror=e=>{this.onWebSocketError(e)},this._webSocket.onopen=()=>{const e=Object.assign({},this.connectHeaders);this.debug("Web Socket Opened..."),e["accept-version"]=this.stompVersions.supportedVersions(),e["heart-beat"]=[this.heartbeatOutgoing,this.heartbeatIncoming].join(","),this._transmit({command:"CONNECT",headers:e})}}_setupHeartbeat(e){if(e.version!==Dt.V1_1&&e.version!==Dt.V1_2)return;if(!e["heart-beat"])return;const[t,n]=e["heart-beat"].split(",").map((e=>parseInt(e,10)));if(0!==this.heartbeatOutgoing&&0!==n){const e=Math.max(this.heartbeatOutgoing,n);this.debug(`send PING every ${e}ms`),this._pinger=setInterval((()=>{this._webSocket.readyState===Ut.OPEN&&(this._webSocket.send(Nt),this.debug(">>> PING"))}),e)}if(0!==this.heartbeatIncoming&&0!==t){const e=Math.max(this.heartbeatIncoming,t);this.debug(`check PONG every ${e}ms`),this._ponger=setInterval((()=>{const t=Date.now()-this._lastServerActivityTS;t>2*e&&(this.debug(`did not receive server activity for the last ${t}ms`),this._closeOrDiscardWebsocket())}),e)}}_closeOrDiscardWebsocket(){this.discardWebsocketOnCommFailure?(this.debug("Discarding websocket, the underlying socket may linger for a while"),this.discardWebsocket()):(this.debug("Issuing close on the websocket"),this._closeWebsocket())}forceDisconnect(){this._webSocket&&(this._webSocket.readyState!==Ut.CONNECTING&&this._webSocket.readyState!==Ut.OPEN||this._closeOrDiscardWebsocket())}_closeWebsocket(){this._webSocket.onmessage=()=>{},this._webSocket.close()}discardWebsocket(){var e,t;"function"!=typeof this._webSocket.terminate&&(e=this._webSocket,t=e=>this.debug(e),e.terminate=function(){const n=()=>{};this.onerror=n,this.onmessage=n,this.onopen=n;const r=new Date,o=Math.random().toString().substring(2,8),i=this.onclose;this.onclose=e=>{const n=(new Date).getTime()-r.getTime();t(`Discarded socket (#${o}) closed after ${n}ms, with code/reason: ${e.code}/${e.reason}`)},this.close(),i?.call(e,{code:4001,reason:`Quick discarding socket (#${o}) without waiting for the shutdown sequence.`,wasClean:!1})}),this._webSocket.terminate()}_transmit(e){const{command:t,headers:n,body:r,binaryBody:o,skipContentLengthHeader:i}=e,s=new Rt({command:t,headers:n,body:r,binaryBody:o,escapeHeaderValues:this._escapeHeaderValues,skipContentLengthHeader:i});let a=s.serialize();if(this.logRawCommunication?this.debug(`>>> ${a}`):this.debug(`>>> ${s}`),this.forceBinaryWSFrames&&"string"==typeof a&&(a=(new TextEncoder).encode(a)),"string"==typeof a&&this.splitLargeFrames){let e=a;for(;e.length>0;){const t=e.substring(0,this.maxWebSocketChunkSize);e=e.substring(this.maxWebSocketChunkSize),this._webSocket.send(t),this.debug(`chunk sent = ${t.length}, remaining = ${e.length}`)}}else this._webSocket.send(a)}dispose(){if(this.connected)try{const e=Object.assign({},this.disconnectHeaders);e.receipt||(e.receipt="close-"+this._counter++),this.watchForReceipt(e.receipt,(e=>{this._closeWebsocket(),this._cleanUp(),this.onDisconnect(e)})),this._transmit({command:"DISCONNECT",headers:e})}catch(e){this.debug(`Ignoring error during disconnect ${e}`)}else this._webSocket.readyState!==Ut.CONNECTING&&this._webSocket.readyState!==Ut.OPEN||this._closeWebsocket()}_cleanUp(){this._connected=!1,this._pinger&&(clearInterval(this._pinger),this._pinger=void 0),this._ponger&&(clearInterval(this._ponger),this._ponger=void 0)}publish(e){const{destination:t,headers:n,body:r,binaryBody:o,skipContentLengthHeader:i}=e,s=Object.assign({destination:t},n);this._transmit({command:"SEND",headers:s,body:r,binaryBody:o,skipContentLengthHeader:i})}watchForReceipt(e,t){this._receiptWatchers[e]=t}subscribe(e,t,n={}){(n=Object.assign({},n)).id||(n.id="sub-"+this._counter++),n.destination=e,this._subscriptions[n.id]=t,this._transmit({command:"SUBSCRIBE",headers:n});const r=this;return{id:n.id,unsubscribe:e=>r.unsubscribe(n.id,e)}}unsubscribe(e,t={}){t=Object.assign({},t),delete this._subscriptions[e],t.id=e,this._transmit({command:"UNSUBSCRIBE",headers:t})}begin(e){const t=e||"tx-"+this._counter++;this._transmit({command:"BEGIN",headers:{transaction:t}});const n=this;return{id:t,commit(){n.commit(t)},abort(){n.abort(t)}}}commit(e){this._transmit({command:"COMMIT",headers:{transaction:e}})}abort(e){this._transmit({command:"ABORT",headers:{transaction:e}})}ack(e,t,n={}){n=Object.assign({},n),this._connectedVersion===Dt.V1_2?n.id=e:n["message-id"]=e,n.subscription=t,this._transmit({command:"ACK",headers:n})}nack(e,t,n={}){return n=Object.assign({},n),this._connectedVersion===Dt.V1_2?n.id=e:n["message-id"]=e,n.subscription=t,this._transmit({command:"NACK",headers:n})}}class Vt{constructor(e={}){this.stompVersions=Dt.default,this.connectionTimeout=0,this.reconnectDelay=5e3,this.heartbeatIncoming=1e4,this.heartbeatOutgoing=1e4,this.splitLargeFrames=!1,this.maxWebSocketChunkSize=8192,this.forceBinaryWSFrames=!1,this.appendMissingNULLonIncoming=!1,this.discardWebsocketOnCommFailure=!1,this.state=Bt.INACTIVE;const t=()=>{};this.debug=t,this.beforeConnect=t,this.onConnect=t,this.onDisconnect=t,this.onUnhandledMessage=t,this.onUnhandledReceipt=t,this.onUnhandledFrame=t,this.onStompError=t,this.onWebSocketClose=t,this.onWebSocketError=t,this.logRawCommunication=!1,this.onChangeState=t,this.connectHeaders={},this._disconnectHeaders={},this.configure(e)}get webSocket(){return this._stompHandler?._webSocket}get disconnectHeaders(){return this._disconnectHeaders}set disconnectHeaders(e){this._disconnectHeaders=e,this._stompHandler&&(this._stompHandler.disconnectHeaders=this._disconnectHeaders)}get connected(){return!!this._stompHandler&&this._stompHandler.connected}get connectedVersion(){return this._stompHandler?this._stompHandler.connectedVersion:void 0}get active(){return this.state===Bt.ACTIVE}_changeState(e){this.state=e,this.onChangeState(e)}configure(e){Object.assign(this,e)}activate(){const e=()=>{this.active?this.debug("Already ACTIVE, ignoring request to activate"):(this._changeState(Bt.ACTIVE),this._connect())};this.state===Bt.DEACTIVATING?(this.debug("Waiting for deactivation to finish before activating"),this.deactivate().then((()=>{e()}))):e()}async _connect(){if(await this.beforeCon