@nhost/nhost-js 1.0.0 → 1.0.3

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/dist/index.es.js CHANGED
@@ -1,12 +1,12 @@
1
- var tc=Object.create;var _r=Object.defineProperty;var rc=Object.getOwnPropertyDescriptor;var nc=Object.getOwnPropertyNames;var ic=Object.getPrototypeOf,sc=Object.prototype.hasOwnProperty;var oc=t=>_r(t,"__esModule",{value:!0});var m=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ac=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of nc(e))!sc.call(t,i)&&(r||i!=="default")&&_r(t,i,{get:()=>e[i],enumerable:!(n=rc(e,i))||n.enumerable});return t},Lt=(t,e)=>ac(oc(_r(t!=null?tc(ic(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var ui=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var _=(t,e,r)=>(ui(t,e,"read from private field"),r?r.call(t):e.get(t)),Le=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},st=(t,e,r,n)=>(ui(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r);var Kr=m((dm,vs)=>{"use strict";vs.exports=function(e,r){return function(){for(var i=new Array(arguments.length),s=0;s<i.length;s++)i[s]=arguments[s];return e.apply(r,i)}}});var K=m((hm,Ss)=>{"use strict";var vf=Kr(),we=Object.prototype.toString;function Qr(t){return Array.isArray(t)}function Xr(t){return typeof t=="undefined"}function yf(t){return t!==null&&!Xr(t)&&t.constructor!==null&&!Xr(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function ys(t){return we.call(t)==="[object ArrayBuffer]"}function gf(t){return we.call(t)==="[object FormData]"}function Ef(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&ys(t.buffer),e}function Sf(t){return typeof t=="string"}function wf(t){return typeof t=="number"}function gs(t){return t!==null&&typeof t=="object"}function ir(t){if(we.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function xf(t){return we.call(t)==="[object Date]"}function bf(t){return we.call(t)==="[object File]"}function Tf(t){return we.call(t)==="[object Blob]"}function Es(t){return we.call(t)==="[object Function]"}function Af(t){return gs(t)&&Es(t.pipe)}function Rf(t){return we.call(t)==="[object URLSearchParams]"}function Of(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Cf(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function Zr(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),Qr(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}function Yr(){var t={};function e(i,s){ir(t[s])&&ir(i)?t[s]=Yr(t[s],i):ir(i)?t[s]=Yr({},i):Qr(i)?t[s]=i.slice():t[s]=i}for(var r=0,n=arguments.length;r<n;r++)Zr(arguments[r],e);return t}function Pf(t,e,r){return Zr(e,function(i,s){r&&typeof i=="function"?t[s]=vf(i,r):t[s]=i}),t}function Nf(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}Ss.exports={isArray:Qr,isArrayBuffer:ys,isBuffer:yf,isFormData:gf,isArrayBufferView:Ef,isString:Sf,isNumber:wf,isObject:gs,isPlainObject:ir,isUndefined:Xr,isDate:xf,isFile:bf,isBlob:Tf,isFunction:Es,isStream:Af,isURLSearchParams:Rf,isStandardBrowserEnv:Cf,forEach:Zr,merge:Yr,extend:Pf,trim:Of,stripBOM:Nf}});var en=m((pm,xs)=>{"use strict";var Ke=K();function ws(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}xs.exports=function(e,r,n){if(!r)return e;var i;if(n)i=n(r);else if(Ke.isURLSearchParams(r))i=r.toString();else{var s=[];Ke.forEach(r,function(c,f){c===null||typeof c=="undefined"||(Ke.isArray(c)?f=f+"[]":c=[c],Ke.forEach(c,function(l){Ke.isDate(l)?l=l.toISOString():Ke.isObject(l)&&(l=JSON.stringify(l)),s.push(ws(f)+"="+ws(l))}))}),i=s.join("&")}if(i){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}});var Ts=m((mm,bs)=>{"use strict";var If=K();function sr(){this.handlers=[]}sr.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};sr.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};sr.prototype.forEach=function(e){If.forEach(this.handlers,function(n){n!==null&&e(n)})};bs.exports=sr});var Rs=m((vm,As)=>{"use strict";var _f=K();As.exports=function(e,r){_f.forEach(e,function(i,s){s!==r&&s.toUpperCase()===r.toUpperCase()&&(e[r]=i,delete e[s])})}});var tn=m((ym,Os)=>{"use strict";Os.exports=function(e,r,n,i,s){return e.config=r,n&&(e.code=n),e.request=i,e.response=s,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}});var rn=m((gm,Cs)=>{"use strict";var kf=tn();Cs.exports=function(e,r,n,i,s){var o=new Error(e);return kf(o,r,n,i,s)}});var Ns=m((Em,Ps)=>{"use strict";var qf=rn();Ps.exports=function(e,r,n){var i=n.config.validateStatus;!n.status||!i||i(n.status)?e(n):r(qf("Request failed with status code "+n.status,n.config,null,n.request,n))}});var _s=m((Sm,Is)=>{"use strict";var or=K();Is.exports=or.isStandardBrowserEnv()?function(){return{write:function(r,n,i,s,o,a){var c=[];c.push(r+"="+encodeURIComponent(n)),or.isNumber(i)&&c.push("expires="+new Date(i).toGMTString()),or.isString(s)&&c.push("path="+s),or.isString(o)&&c.push("domain="+o),a===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(r){var n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var qs=m((wm,ks)=>{"use strict";ks.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}});var Us=m((xm,Ds)=>{"use strict";Ds.exports=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e}});var Ls=m((bm,Ms)=>{"use strict";var Df=qs(),Uf=Us();Ms.exports=function(e,r){return e&&!Df(r)?Uf(e,r):r}});var Bs=m((Tm,js)=>{"use strict";var nn=K(),Mf=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];js.exports=function(e){var r={},n,i,s;return e&&nn.forEach(e.split(`
2
- `),function(a){if(s=a.indexOf(":"),n=nn.trim(a.substr(0,s)).toLowerCase(),i=nn.trim(a.substr(s+1)),n){if(r[n]&&Mf.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([i]):r[n]=r[n]?r[n]+", "+i:i}}),r}});var Hs=m((Am,Vs)=>{"use strict";var Fs=K();Vs.exports=Fs.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function i(s){var o=s;return e&&(r.setAttribute("href",o),o=r.href),r.setAttribute("href",o),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=i(window.location.href),function(o){var a=Fs.isString(o)?i(o):o;return a.protocol===n.protocol&&a.host===n.host}}():function(){return function(){return!0}}()});var Rt=m((Rm,Gs)=>{"use strict";function sn(t){this.message=t}sn.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};sn.prototype.__CANCEL__=!0;Gs.exports=sn});var an=m((Om,Js)=>{"use strict";var ar=K(),Lf=Ns(),jf=_s(),Bf=en(),Ff=Ls(),Vf=Bs(),Hf=Hs(),on=rn(),Gf=Ot(),Jf=Rt();Js.exports=function(e){return new Promise(function(n,i){var s=e.data,o=e.headers,a=e.responseType,c;function f(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}ar.isFormData(s)&&delete o["Content-Type"];var u=new XMLHttpRequest;if(e.auth){var l=e.auth.username||"",d=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(l+":"+d)}var h=Ff(e.baseURL,e.url);u.open(e.method.toUpperCase(),Bf(h,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function g(){if(!!u){var p="getAllResponseHeaders"in u?Vf(u.getAllResponseHeaders()):null,w=!a||a==="text"||a==="json"?u.responseText:u.response,y={data:w,status:u.status,statusText:u.statusText,headers:p,config:e,request:u};Lf(function(C){n(C),f()},function(C){i(C),f()},y),u=null}}if("onloadend"in u?u.onloadend=g:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(g)},u.onabort=function(){!u||(i(on("Request aborted",e,"ECONNABORTED",u)),u=null)},u.onerror=function(){i(on("Network Error",e,null,u)),u=null},u.ontimeout=function(){var w=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",y=e.transitional||Gf.transitional;e.timeoutErrorMessage&&(w=e.timeoutErrorMessage),i(on(w,e,y.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},ar.isStandardBrowserEnv()){var E=(e.withCredentials||Hf(h))&&e.xsrfCookieName?jf.read(e.xsrfCookieName):void 0;E&&(o[e.xsrfHeaderName]=E)}"setRequestHeader"in u&&ar.forEach(o,function(w,y){typeof s=="undefined"&&y.toLowerCase()==="content-type"?delete o[y]:u.setRequestHeader(y,w)}),ar.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),a&&a!=="json"&&(u.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&u.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(c=function(p){!u||(i(!p||p&&p.type?new Jf("canceled"):p),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c))),s||(s=null),u.send(s)})}});var Ot=m((Cm,Ws)=>{"use strict";var H=K(),zs=Rs(),zf=tn(),$f={"Content-Type":"application/x-www-form-urlencoded"};function $s(t,e){!H.isUndefined(t)&&H.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Wf(){var t;return typeof XMLHttpRequest!="undefined"?t=an():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(t=an()),t}function Kf(t,e,r){if(H.isString(t))try{return(e||JSON.parse)(t),H.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var ur={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Wf(),transformRequest:[function(e,r){return zs(r,"Accept"),zs(r,"Content-Type"),H.isFormData(e)||H.isArrayBuffer(e)||H.isBuffer(e)||H.isStream(e)||H.isFile(e)||H.isBlob(e)?e:H.isArrayBufferView(e)?e.buffer:H.isURLSearchParams(e)?($s(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):H.isObject(e)||r&&r["Content-Type"]==="application/json"?($s(r,"application/json"),Kf(e)):e}],transformResponse:[function(e){var r=this.transitional||ur.transitional,n=r&&r.silentJSONParsing,i=r&&r.forcedJSONParsing,s=!n&&this.responseType==="json";if(s||i&&H.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(s)throw o.name==="SyntaxError"?zf(o,this,"E_JSON_PARSE"):o}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};H.forEach(["delete","get","head"],function(e){ur.headers[e]={}});H.forEach(["post","put","patch"],function(e){ur.headers[e]=H.merge($f)});Ws.exports=ur});var Xs=m((Pm,Ks)=>{"use strict";var Xf=K(),Yf=Ot();Ks.exports=function(e,r,n){var i=this||Yf;return Xf.forEach(n,function(o){e=o.call(i,e,r)}),e}});var un=m((Nm,Ys)=>{"use strict";Ys.exports=function(e){return!!(e&&e.__CANCEL__)}});var eo=m((Im,Zs)=>{"use strict";var Qs=K(),cn=Xs(),Qf=un(),Zf=Ot(),el=Rt();function fn(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new el("canceled")}Zs.exports=function(e){fn(e),e.headers=e.headers||{},e.data=cn.call(e,e.data,e.headers,e.transformRequest),e.headers=Qs.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Qs.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var r=e.adapter||Zf.adapter;return r(e).then(function(i){return fn(e),i.data=cn.call(e,i.data,i.headers,e.transformResponse),i},function(i){return Qf(i)||(fn(e),i&&i.response&&(i.response.data=cn.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})}});var ln=m((_m,to)=>{"use strict";var re=K();to.exports=function(e,r){r=r||{};var n={};function i(u,l){return re.isPlainObject(u)&&re.isPlainObject(l)?re.merge(u,l):re.isPlainObject(l)?re.merge({},l):re.isArray(l)?l.slice():l}function s(u){if(re.isUndefined(r[u])){if(!re.isUndefined(e[u]))return i(void 0,e[u])}else return i(e[u],r[u])}function o(u){if(!re.isUndefined(r[u]))return i(void 0,r[u])}function a(u){if(re.isUndefined(r[u])){if(!re.isUndefined(e[u]))return i(void 0,e[u])}else return i(void 0,r[u])}function c(u){if(u in r)return i(e[u],r[u]);if(u in e)return i(void 0,e[u])}var f={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c};return re.forEach(Object.keys(e).concat(Object.keys(r)),function(l){var d=f[l]||s,h=d(l);re.isUndefined(h)&&d!==c||(n[l]=h)}),n}});var dn=m((km,ro)=>{ro.exports={version:"0.25.0"}});var so=m((qm,io)=>{"use strict";var tl=dn().version,hn={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){hn[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var no={};hn.transitional=function(e,r,n){function i(s,o){return"[Axios v"+tl+"] Transitional option '"+s+"'"+o+(n?". "+n:"")}return function(s,o,a){if(e===!1)throw new Error(i(o," has been removed"+(r?" in "+r:"")));return r&&!no[o]&&(no[o]=!0,console.warn(i(o," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(s,o,a):!0}};function rl(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),i=n.length;i-- >0;){var s=n[i],o=e[s];if(o){var a=t[s],c=a===void 0||o(a,s,t);if(c!==!0)throw new TypeError("option "+s+" must be "+c);continue}if(r!==!0)throw Error("Unknown option "+s)}}io.exports={assertOptions:rl,validators:hn}});var lo=m((Dm,fo)=>{"use strict";var uo=K(),nl=en(),oo=Ts(),ao=eo(),cr=ln(),co=so(),Xe=co.validators;function Ct(t){this.defaults=t,this.interceptors={request:new oo,response:new oo}}Ct.prototype.request=function(e,r){if(typeof e=="string"?(r=r||{},r.url=e):r=e||{},!r.url)throw new Error("Provided config url is not valid");r=cr(this.defaults,r),r.method?r.method=r.method.toLowerCase():this.defaults.method?r.method=this.defaults.method.toLowerCase():r.method="get";var n=r.transitional;n!==void 0&&co.assertOptions(n,{silentJSONParsing:Xe.transitional(Xe.boolean),forcedJSONParsing:Xe.transitional(Xe.boolean),clarifyTimeoutError:Xe.transitional(Xe.boolean)},!1);var i=[],s=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(s=s&&h.synchronous,i.unshift(h.fulfilled,h.rejected))});var o=[];this.interceptors.response.forEach(function(h){o.push(h.fulfilled,h.rejected)});var a;if(!s){var c=[ao,void 0];for(Array.prototype.unshift.apply(c,i),c=c.concat(o),a=Promise.resolve(r);c.length;)a=a.then(c.shift(),c.shift());return a}for(var f=r;i.length;){var u=i.shift(),l=i.shift();try{f=u(f)}catch(d){l(d);break}}try{a=ao(f)}catch(d){return Promise.reject(d)}for(;o.length;)a=a.then(o.shift(),o.shift());return a};Ct.prototype.getUri=function(e){if(!e.url)throw new Error("Provided config url is not valid");return e=cr(this.defaults,e),nl(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};uo.forEach(["delete","get","head","options"],function(e){Ct.prototype[e]=function(r,n){return this.request(cr(n||{},{method:e,url:r,data:(n||{}).data}))}});uo.forEach(["post","put","patch"],function(e){Ct.prototype[e]=function(r,n,i){return this.request(cr(i||{},{method:e,url:r,data:n}))}});fo.exports=Ct});var po=m((Um,ho)=>{"use strict";var il=Rt();function Ye(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(i){e=i});var r=this;this.promise.then(function(n){if(!!r._listeners){var i,s=r._listeners.length;for(i=0;i<s;i++)r._listeners[i](n);r._listeners=null}}),this.promise.then=function(n){var i,s=new Promise(function(o){r.subscribe(o),i=o}).then(n);return s.cancel=function(){r.unsubscribe(i)},s},t(function(i){r.reason||(r.reason=new il(i),e(r.reason))})}Ye.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};Ye.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};Ye.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}};Ye.source=function(){var e,r=new Ye(function(i){e=i});return{token:r,cancel:e}};ho.exports=Ye});var vo=m((Mm,mo)=>{"use strict";mo.exports=function(e){return function(n){return e.apply(null,n)}}});var go=m((Lm,yo)=>{"use strict";var sl=K();yo.exports=function(e){return sl.isObject(e)&&e.isAxiosError===!0}});var wo=m((jm,pn)=>{"use strict";var Eo=K(),ol=Kr(),fr=lo(),al=ln(),ul=Ot();function So(t){var e=new fr(t),r=ol(fr.prototype.request,e);return Eo.extend(r,fr.prototype,e),Eo.extend(r,e),r.create=function(i){return So(al(t,i))},r}var de=So(ul);de.Axios=fr;de.Cancel=Rt();de.CancelToken=po();de.isCancel=un();de.VERSION=dn().version;de.all=function(e){return Promise.all(e)};de.spread=vo();de.isAxiosError=go();pn.exports=de;pn.exports.default=de});var bo=m((Bm,xo)=>{xo.exports=wo()});var gn=m((Ay,Mo)=>{"use strict";Mo.exports=function(e,r){return function(){for(var i=new Array(arguments.length),s=0;s<i.length;s++)i[s]=arguments[s];return e.apply(r,i)}}});var X=m((Ry,Bo)=>{"use strict";var yl=gn(),De=Object.prototype.toString;function wn(t){return De.call(t)==="[object Array]"}function En(t){return typeof t=="undefined"}function gl(t){return t!==null&&!En(t)&&t.constructor!==null&&!En(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function El(t){return De.call(t)==="[object ArrayBuffer]"}function Sl(t){return typeof FormData!="undefined"&&t instanceof FormData}function wl(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&t.buffer instanceof ArrayBuffer,e}function xl(t){return typeof t=="string"}function bl(t){return typeof t=="number"}function Lo(t){return t!==null&&typeof t=="object"}function vr(t){if(De.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function Tl(t){return De.call(t)==="[object Date]"}function Al(t){return De.call(t)==="[object File]"}function Rl(t){return De.call(t)==="[object Blob]"}function jo(t){return De.call(t)==="[object Function]"}function Ol(t){return Lo(t)&&jo(t.pipe)}function Cl(t){return typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams}function Pl(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Nl(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function xn(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),wn(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}function Sn(){var t={};function e(i,s){vr(t[s])&&vr(i)?t[s]=Sn(t[s],i):vr(i)?t[s]=Sn({},i):wn(i)?t[s]=i.slice():t[s]=i}for(var r=0,n=arguments.length;r<n;r++)xn(arguments[r],e);return t}function Il(t,e,r){return xn(e,function(i,s){r&&typeof i=="function"?t[s]=yl(i,r):t[s]=i}),t}function _l(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}Bo.exports={isArray:wn,isArrayBuffer:El,isBuffer:gl,isFormData:Sl,isArrayBufferView:wl,isString:xl,isNumber:bl,isObject:Lo,isPlainObject:vr,isUndefined:En,isDate:Tl,isFile:Al,isBlob:Rl,isFunction:jo,isStream:Ol,isURLSearchParams:Cl,isStandardBrowserEnv:Nl,forEach:xn,merge:Sn,extend:Il,trim:Pl,stripBOM:_l}});var bn=m((Oy,Vo)=>{"use strict";var et=X();function Fo(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}Vo.exports=function(e,r,n){if(!r)return e;var i;if(n)i=n(r);else if(et.isURLSearchParams(r))i=r.toString();else{var s=[];et.forEach(r,function(c,f){c===null||typeof c=="undefined"||(et.isArray(c)?f=f+"[]":c=[c],et.forEach(c,function(l){et.isDate(l)?l=l.toISOString():et.isObject(l)&&(l=JSON.stringify(l)),s.push(Fo(f)+"="+Fo(l))}))}),i=s.join("&")}if(i){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}});var Go=m((Cy,Ho)=>{"use strict";var kl=X();function yr(){this.handlers=[]}yr.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};yr.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};yr.prototype.forEach=function(e){kl.forEach(this.handlers,function(n){n!==null&&e(n)})};Ho.exports=yr});var zo=m((Py,Jo)=>{"use strict";var ql=X();Jo.exports=function(e,r){ql.forEach(e,function(i,s){s!==r&&s.toUpperCase()===r.toUpperCase()&&(e[r]=i,delete e[s])})}});var Tn=m((Ny,$o)=>{"use strict";$o.exports=function(e,r,n,i,s){return e.config=r,n&&(e.code=n),e.request=i,e.response=s,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}});var An=m((Iy,Wo)=>{"use strict";var Dl=Tn();Wo.exports=function(e,r,n,i,s){var o=new Error(e);return Dl(o,r,n,i,s)}});var Xo=m((_y,Ko)=>{"use strict";var Ul=An();Ko.exports=function(e,r,n){var i=n.config.validateStatus;!n.status||!i||i(n.status)?e(n):r(Ul("Request failed with status code "+n.status,n.config,null,n.request,n))}});var Qo=m((ky,Yo)=>{"use strict";var gr=X();Yo.exports=gr.isStandardBrowserEnv()?function(){return{write:function(r,n,i,s,o,a){var c=[];c.push(r+"="+encodeURIComponent(n)),gr.isNumber(i)&&c.push("expires="+new Date(i).toGMTString()),gr.isString(s)&&c.push("path="+s),gr.isString(o)&&c.push("domain="+o),a===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(r){var n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var ea=m((qy,Zo)=>{"use strict";Zo.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var ra=m((Dy,ta)=>{"use strict";ta.exports=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e}});var ia=m((Uy,na)=>{"use strict";var Ml=ea(),Ll=ra();na.exports=function(e,r){return e&&!Ml(r)?Ll(e,r):r}});var oa=m((My,sa)=>{"use strict";var Rn=X(),jl=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];sa.exports=function(e){var r={},n,i,s;return e&&Rn.forEach(e.split(`
3
- `),function(a){if(s=a.indexOf(":"),n=Rn.trim(a.substr(0,s)).toLowerCase(),i=Rn.trim(a.substr(s+1)),n){if(r[n]&&jl.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([i]):r[n]=r[n]?r[n]+", "+i:i}}),r}});var ca=m((Ly,ua)=>{"use strict";var aa=X();ua.exports=aa.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function i(s){var o=s;return e&&(r.setAttribute("href",o),o=r.href),r.setAttribute("href",o),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=i(window.location.href),function(o){var a=aa.isString(o)?i(o):o;return a.protocol===n.protocol&&a.host===n.host}}():function(){return function(){return!0}}()});var Cn=m((jy,fa)=>{"use strict";var Er=X(),Bl=Xo(),Fl=Qo(),Vl=bn(),Hl=ia(),Gl=oa(),Jl=ca(),On=An();fa.exports=function(e){return new Promise(function(n,i){var s=e.data,o=e.headers,a=e.responseType;Er.isFormData(s)&&delete o["Content-Type"];var c=new XMLHttpRequest;if(e.auth){var f=e.auth.username||"",u=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(f+":"+u)}var l=Hl(e.baseURL,e.url);c.open(e.method.toUpperCase(),Vl(l,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function d(){if(!!c){var g="getAllResponseHeaders"in c?Gl(c.getAllResponseHeaders()):null,E=!a||a==="text"||a==="json"?c.responseText:c.response,p={data:E,status:c.status,statusText:c.statusText,headers:g,config:e,request:c};Bl(n,i,p),c=null}}if("onloadend"in c?c.onloadend=d:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(d)},c.onabort=function(){!c||(i(On("Request aborted",e,"ECONNABORTED",c)),c=null)},c.onerror=function(){i(On("Network Error",e,null,c)),c=null},c.ontimeout=function(){var E="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(E=e.timeoutErrorMessage),i(On(E,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",c)),c=null},Er.isStandardBrowserEnv()){var h=(e.withCredentials||Jl(l))&&e.xsrfCookieName?Fl.read(e.xsrfCookieName):void 0;h&&(o[e.xsrfHeaderName]=h)}"setRequestHeader"in c&&Er.forEach(o,function(E,p){typeof s=="undefined"&&p.toLowerCase()==="content-type"?delete o[p]:c.setRequestHeader(p,E)}),Er.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),a&&a!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(E){!c||(c.abort(),i(E),c=null)}),s||(s=null),c.send(s)})}});var wr=m((By,ha)=>{"use strict";var G=X(),la=zo(),zl=Tn(),$l={"Content-Type":"application/x-www-form-urlencoded"};function da(t,e){!G.isUndefined(t)&&G.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Wl(){var t;return typeof XMLHttpRequest!="undefined"?t=Cn():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(t=Cn()),t}function Kl(t,e,r){if(G.isString(t))try{return(e||JSON.parse)(t),G.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var Sr={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Wl(),transformRequest:[function(e,r){return la(r,"Accept"),la(r,"Content-Type"),G.isFormData(e)||G.isArrayBuffer(e)||G.isBuffer(e)||G.isStream(e)||G.isFile(e)||G.isBlob(e)?e:G.isArrayBufferView(e)?e.buffer:G.isURLSearchParams(e)?(da(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):G.isObject(e)||r&&r["Content-Type"]==="application/json"?(da(r,"application/json"),Kl(e)):e}],transformResponse:[function(e){var r=this.transitional,n=r&&r.silentJSONParsing,i=r&&r.forcedJSONParsing,s=!n&&this.responseType==="json";if(s||i&&G.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(s)throw o.name==="SyntaxError"?zl(o,this,"E_JSON_PARSE"):o}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};Sr.headers={common:{Accept:"application/json, text/plain, */*"}};G.forEach(["delete","get","head"],function(e){Sr.headers[e]={}});G.forEach(["post","put","patch"],function(e){Sr.headers[e]=G.merge($l)});ha.exports=Sr});var ma=m((Fy,pa)=>{"use strict";var Xl=X(),Yl=wr();pa.exports=function(e,r,n){var i=this||Yl;return Xl.forEach(n,function(o){e=o.call(i,e,r)}),e}});var Pn=m((Vy,va)=>{"use strict";va.exports=function(e){return!!(e&&e.__CANCEL__)}});var Ea=m((Hy,ga)=>{"use strict";var ya=X(),Nn=ma(),Ql=Pn(),Zl=wr();function In(t){t.cancelToken&&t.cancelToken.throwIfRequested()}ga.exports=function(e){In(e),e.headers=e.headers||{},e.data=Nn.call(e,e.data,e.headers,e.transformRequest),e.headers=ya.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),ya.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var r=e.adapter||Zl.adapter;return r(e).then(function(i){return In(e),i.data=Nn.call(e,i.data,i.headers,e.transformResponse),i},function(i){return Ql(i)||(In(e),i&&i.response&&(i.response.data=Nn.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})}});var _n=m((Gy,Sa)=>{"use strict";var W=X();Sa.exports=function(e,r){r=r||{};var n={},i=["url","method","data"],s=["headers","auth","proxy","params"],o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function c(d,h){return W.isPlainObject(d)&&W.isPlainObject(h)?W.merge(d,h):W.isPlainObject(h)?W.merge({},h):W.isArray(h)?h.slice():h}function f(d){W.isUndefined(r[d])?W.isUndefined(e[d])||(n[d]=c(void 0,e[d])):n[d]=c(e[d],r[d])}W.forEach(i,function(h){W.isUndefined(r[h])||(n[h]=c(void 0,r[h]))}),W.forEach(s,f),W.forEach(o,function(h){W.isUndefined(r[h])?W.isUndefined(e[h])||(n[h]=c(void 0,e[h])):n[h]=c(void 0,r[h])}),W.forEach(a,function(h){h in r?n[h]=c(e[h],r[h]):h in e&&(n[h]=c(void 0,e[h]))});var u=i.concat(s).concat(o).concat(a),l=Object.keys(e).concat(Object.keys(r)).filter(function(h){return u.indexOf(h)===-1});return W.forEach(l,f),n}});var wa=m((Jy,ed)=>{ed.exports={name:"axios",version:"0.21.4",description:"Promise based HTTP client for the browser and node.js",main:"index.js",scripts:{test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},repository:{type:"git",url:"https://github.com/axios/axios.git"},keywords:["xhr","http","ajax","promise","node"],author:"Matt Zabriskie",license:"MIT",bugs:{url:"https://github.com/axios/axios/issues"},homepage:"https://axios-http.com",devDependencies:{coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},browser:{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},jsdelivr:"dist/axios.min.js",unpkg:"dist/axios.min.js",typings:"./index.d.ts",dependencies:{"follow-redirects":"^1.14.0"},bundlesize:[{path:"./dist/axios.min.js",threshold:"5kB"}]}});var Ra=m((zy,Aa)=>{"use strict";var ba=wa(),kn={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){kn[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var xa={},td=ba.version.split(".");function Ta(t,e){for(var r=e?e.split("."):td,n=t.split("."),i=0;i<3;i++){if(r[i]>n[i])return!0;if(r[i]<n[i])return!1}return!1}kn.transitional=function(e,r,n){var i=r&&Ta(r);function s(o,a){return"[Axios v"+ba.version+"] Transitional option '"+o+"'"+a+(n?". "+n:"")}return function(o,a,c){if(e===!1)throw new Error(s(a," has been removed in "+r));return i&&!xa[a]&&(xa[a]=!0,console.warn(s(a," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(o,a,c):!0}};function rd(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),i=n.length;i-- >0;){var s=n[i],o=e[s];if(o){var a=t[s],c=a===void 0||o(a,s,t);if(c!==!0)throw new TypeError("option "+s+" must be "+c);continue}if(r!==!0)throw Error("Unknown option "+s)}}Aa.exports={isOlderVersion:Ta,assertOptions:rd,validators:kn}});var _a=m(($y,Ia)=>{"use strict";var Pa=X(),nd=bn(),Oa=Go(),Ca=Ea(),xr=_n(),Na=Ra(),tt=Na.validators;function kt(t){this.defaults=t,this.interceptors={request:new Oa,response:new Oa}}kt.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=xr(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;r!==void 0&&Na.assertOptions(r,{silentJSONParsing:tt.transitional(tt.boolean,"1.0.0"),forcedJSONParsing:tt.transitional(tt.boolean,"1.0.0"),clarifyTimeoutError:tt.transitional(tt.boolean,"1.0.0")},!1);var n=[],i=!0;this.interceptors.request.forEach(function(d){typeof d.runWhen=="function"&&d.runWhen(e)===!1||(i=i&&d.synchronous,n.unshift(d.fulfilled,d.rejected))});var s=[];this.interceptors.response.forEach(function(d){s.push(d.fulfilled,d.rejected)});var o;if(!i){var a=[Ca,void 0];for(Array.prototype.unshift.apply(a,n),a=a.concat(s),o=Promise.resolve(e);a.length;)o=o.then(a.shift(),a.shift());return o}for(var c=e;n.length;){var f=n.shift(),u=n.shift();try{c=f(c)}catch(l){u(l);break}}try{o=Ca(c)}catch(l){return Promise.reject(l)}for(;s.length;)o=o.then(s.shift(),s.shift());return o};kt.prototype.getUri=function(e){return e=xr(this.defaults,e),nd(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};Pa.forEach(["delete","get","head","options"],function(e){kt.prototype[e]=function(r,n){return this.request(xr(n||{},{method:e,url:r,data:(n||{}).data}))}});Pa.forEach(["post","put","patch"],function(e){kt.prototype[e]=function(r,n,i){return this.request(xr(i||{},{method:e,url:r,data:n}))}});Ia.exports=kt});var Dn=m((Wy,ka)=>{"use strict";function qn(t){this.message=t}qn.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};qn.prototype.__CANCEL__=!0;ka.exports=qn});var Da=m((Ky,qa)=>{"use strict";var id=Dn();function br(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(i){e=i});var r=this;t(function(i){r.reason||(r.reason=new id(i),e(r.reason))})}br.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};br.source=function(){var e,r=new br(function(i){e=i});return{token:r,cancel:e}};qa.exports=br});var Ma=m((Xy,Ua)=>{"use strict";Ua.exports=function(e){return function(n){return e.apply(null,n)}}});var ja=m((Yy,La)=>{"use strict";La.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var Va=m((Qy,Un)=>{"use strict";var Ba=X(),sd=gn(),Tr=_a(),od=_n(),ad=wr();function Fa(t){var e=new Tr(t),r=sd(Tr.prototype.request,e);return Ba.extend(r,Tr.prototype,e),Ba.extend(r,e),r}var ue=Fa(ad);ue.Axios=Tr;ue.create=function(e){return Fa(od(ue.defaults,e))};ue.Cancel=Dn();ue.CancelToken=Da();ue.isCancel=Pn();ue.all=function(e){return Promise.all(e)};ue.spread=Ma();ue.isAxiosError=ja();Un.exports=ue;Un.exports.default=ue});var Ga=m((Zy,Ha)=>{Ha.exports=Va()});var jn=m((ug,za)=>{"use strict";za.exports=function(e,r){return function(){for(var i=new Array(arguments.length),s=0;s<i.length;s++)i[s]=arguments[s];return e.apply(r,i)}}});var Y=m((cg,Ka)=>{"use strict";var ud=jn(),Ue=Object.prototype.toString;function Vn(t){return Ue.call(t)==="[object Array]"}function Bn(t){return typeof t=="undefined"}function cd(t){return t!==null&&!Bn(t)&&t.constructor!==null&&!Bn(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function fd(t){return Ue.call(t)==="[object ArrayBuffer]"}function ld(t){return typeof FormData!="undefined"&&t instanceof FormData}function dd(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&t.buffer instanceof ArrayBuffer,e}function hd(t){return typeof t=="string"}function pd(t){return typeof t=="number"}function $a(t){return t!==null&&typeof t=="object"}function Ar(t){if(Ue.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function md(t){return Ue.call(t)==="[object Date]"}function vd(t){return Ue.call(t)==="[object File]"}function yd(t){return Ue.call(t)==="[object Blob]"}function Wa(t){return Ue.call(t)==="[object Function]"}function gd(t){return $a(t)&&Wa(t.pipe)}function Ed(t){return typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams}function Sd(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function wd(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function Hn(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),Vn(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}function Fn(){var t={};function e(i,s){Ar(t[s])&&Ar(i)?t[s]=Fn(t[s],i):Ar(i)?t[s]=Fn({},i):Vn(i)?t[s]=i.slice():t[s]=i}for(var r=0,n=arguments.length;r<n;r++)Hn(arguments[r],e);return t}function xd(t,e,r){return Hn(e,function(i,s){r&&typeof i=="function"?t[s]=ud(i,r):t[s]=i}),t}function bd(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}Ka.exports={isArray:Vn,isArrayBuffer:fd,isBuffer:cd,isFormData:ld,isArrayBufferView:dd,isString:hd,isNumber:pd,isObject:$a,isPlainObject:Ar,isUndefined:Bn,isDate:md,isFile:vd,isBlob:yd,isFunction:Wa,isStream:gd,isURLSearchParams:Ed,isStandardBrowserEnv:wd,forEach:Hn,merge:Fn,extend:xd,trim:Sd,stripBOM:bd}});var Gn=m((fg,Ya)=>{"use strict";var rt=Y();function Xa(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}Ya.exports=function(e,r,n){if(!r)return e;var i;if(n)i=n(r);else if(rt.isURLSearchParams(r))i=r.toString();else{var s=[];rt.forEach(r,function(c,f){c===null||typeof c=="undefined"||(rt.isArray(c)?f=f+"[]":c=[c],rt.forEach(c,function(l){rt.isDate(l)?l=l.toISOString():rt.isObject(l)&&(l=JSON.stringify(l)),s.push(Xa(f)+"="+Xa(l))}))}),i=s.join("&")}if(i){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}});var Za=m((lg,Qa)=>{"use strict";var Td=Y();function Rr(){this.handlers=[]}Rr.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};Rr.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};Rr.prototype.forEach=function(e){Td.forEach(this.handlers,function(n){n!==null&&e(n)})};Qa.exports=Rr});var tu=m((dg,eu)=>{"use strict";var Ad=Y();eu.exports=function(e,r){Ad.forEach(e,function(i,s){s!==r&&s.toUpperCase()===r.toUpperCase()&&(e[r]=i,delete e[s])})}});var Jn=m((hg,ru)=>{"use strict";ru.exports=function(e,r,n,i,s){return e.config=r,n&&(e.code=n),e.request=i,e.response=s,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}});var zn=m((pg,nu)=>{"use strict";var Rd=Jn();nu.exports=function(e,r,n,i,s){var o=new Error(e);return Rd(o,r,n,i,s)}});var su=m((mg,iu)=>{"use strict";var Od=zn();iu.exports=function(e,r,n){var i=n.config.validateStatus;!n.status||!i||i(n.status)?e(n):r(Od("Request failed with status code "+n.status,n.config,null,n.request,n))}});var au=m((vg,ou)=>{"use strict";var Or=Y();ou.exports=Or.isStandardBrowserEnv()?function(){return{write:function(r,n,i,s,o,a){var c=[];c.push(r+"="+encodeURIComponent(n)),Or.isNumber(i)&&c.push("expires="+new Date(i).toGMTString()),Or.isString(s)&&c.push("path="+s),Or.isString(o)&&c.push("domain="+o),a===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(r){var n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var cu=m((yg,uu)=>{"use strict";uu.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var lu=m((gg,fu)=>{"use strict";fu.exports=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e}});var hu=m((Eg,du)=>{"use strict";var Cd=cu(),Pd=lu();du.exports=function(e,r){return e&&!Cd(r)?Pd(e,r):r}});var mu=m((Sg,pu)=>{"use strict";var $n=Y(),Nd=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];pu.exports=function(e){var r={},n,i,s;return e&&$n.forEach(e.split(`
4
- `),function(a){if(s=a.indexOf(":"),n=$n.trim(a.substr(0,s)).toLowerCase(),i=$n.trim(a.substr(s+1)),n){if(r[n]&&Nd.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([i]):r[n]=r[n]?r[n]+", "+i:i}}),r}});var gu=m((wg,yu)=>{"use strict";var vu=Y();yu.exports=vu.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function i(s){var o=s;return e&&(r.setAttribute("href",o),o=r.href),r.setAttribute("href",o),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=i(window.location.href),function(o){var a=vu.isString(o)?i(o):o;return a.protocol===n.protocol&&a.host===n.host}}():function(){return function(){return!0}}()});var qt=m((xg,Eu)=>{"use strict";function Wn(t){this.message=t}Wn.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};Wn.prototype.__CANCEL__=!0;Eu.exports=Wn});var Xn=m((bg,Su)=>{"use strict";var Cr=Y(),Id=su(),_d=au(),kd=Gn(),qd=hu(),Dd=mu(),Ud=gu(),Kn=zn(),Md=Dt(),Ld=qt();Su.exports=function(e){return new Promise(function(n,i){var s=e.data,o=e.headers,a=e.responseType,c;function f(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}Cr.isFormData(s)&&delete o["Content-Type"];var u=new XMLHttpRequest;if(e.auth){var l=e.auth.username||"",d=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(l+":"+d)}var h=qd(e.baseURL,e.url);u.open(e.method.toUpperCase(),kd(h,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function g(){if(!!u){var p="getAllResponseHeaders"in u?Dd(u.getAllResponseHeaders()):null,w=!a||a==="text"||a==="json"?u.responseText:u.response,y={data:w,status:u.status,statusText:u.statusText,headers:p,config:e,request:u};Id(function(C){n(C),f()},function(C){i(C),f()},y),u=null}}if("onloadend"in u?u.onloadend=g:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(g)},u.onabort=function(){!u||(i(Kn("Request aborted",e,"ECONNABORTED",u)),u=null)},u.onerror=function(){i(Kn("Network Error",e,null,u)),u=null},u.ontimeout=function(){var w=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",y=e.transitional||Md.transitional;e.timeoutErrorMessage&&(w=e.timeoutErrorMessage),i(Kn(w,e,y.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},Cr.isStandardBrowserEnv()){var E=(e.withCredentials||Ud(h))&&e.xsrfCookieName?_d.read(e.xsrfCookieName):void 0;E&&(o[e.xsrfHeaderName]=E)}"setRequestHeader"in u&&Cr.forEach(o,function(w,y){typeof s=="undefined"&&y.toLowerCase()==="content-type"?delete o[y]:u.setRequestHeader(y,w)}),Cr.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),a&&a!=="json"&&(u.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&u.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(c=function(p){!u||(i(!p||p&&p.type?new Ld("canceled"):p),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c))),s||(s=null),u.send(s)})}});var Dt=m((Tg,bu)=>{"use strict";var J=Y(),wu=tu(),jd=Jn(),Bd={"Content-Type":"application/x-www-form-urlencoded"};function xu(t,e){!J.isUndefined(t)&&J.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Fd(){var t;return typeof XMLHttpRequest!="undefined"?t=Xn():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(t=Xn()),t}function Vd(t,e,r){if(J.isString(t))try{return(e||JSON.parse)(t),J.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var Pr={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Fd(),transformRequest:[function(e,r){return wu(r,"Accept"),wu(r,"Content-Type"),J.isFormData(e)||J.isArrayBuffer(e)||J.isBuffer(e)||J.isStream(e)||J.isFile(e)||J.isBlob(e)?e:J.isArrayBufferView(e)?e.buffer:J.isURLSearchParams(e)?(xu(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):J.isObject(e)||r&&r["Content-Type"]==="application/json"?(xu(r,"application/json"),Vd(e)):e}],transformResponse:[function(e){var r=this.transitional||Pr.transitional,n=r&&r.silentJSONParsing,i=r&&r.forcedJSONParsing,s=!n&&this.responseType==="json";if(s||i&&J.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(s)throw o.name==="SyntaxError"?jd(o,this,"E_JSON_PARSE"):o}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};J.forEach(["delete","get","head"],function(e){Pr.headers[e]={}});J.forEach(["post","put","patch"],function(e){Pr.headers[e]=J.merge(Bd)});bu.exports=Pr});var Au=m((Ag,Tu)=>{"use strict";var Hd=Y(),Gd=Dt();Tu.exports=function(e,r,n){var i=this||Gd;return Hd.forEach(n,function(o){e=o.call(i,e,r)}),e}});var Yn=m((Rg,Ru)=>{"use strict";Ru.exports=function(e){return!!(e&&e.__CANCEL__)}});var Pu=m((Og,Cu)=>{"use strict";var Ou=Y(),Qn=Au(),Jd=Yn(),zd=Dt(),$d=qt();function Zn(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new $d("canceled")}Cu.exports=function(e){Zn(e),e.headers=e.headers||{},e.data=Qn.call(e,e.data,e.headers,e.transformRequest),e.headers=Ou.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Ou.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var r=e.adapter||zd.adapter;return r(e).then(function(i){return Zn(e),i.data=Qn.call(e,i.data,i.headers,e.transformResponse),i},function(i){return Jd(i)||(Zn(e),i&&i.response&&(i.response.data=Qn.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})}});var ei=m((Cg,Nu)=>{"use strict";var ne=Y();Nu.exports=function(e,r){r=r||{};var n={};function i(u,l){return ne.isPlainObject(u)&&ne.isPlainObject(l)?ne.merge(u,l):ne.isPlainObject(l)?ne.merge({},l):ne.isArray(l)?l.slice():l}function s(u){if(ne.isUndefined(r[u])){if(!ne.isUndefined(e[u]))return i(void 0,e[u])}else return i(e[u],r[u])}function o(u){if(!ne.isUndefined(r[u]))return i(void 0,r[u])}function a(u){if(ne.isUndefined(r[u])){if(!ne.isUndefined(e[u]))return i(void 0,e[u])}else return i(void 0,r[u])}function c(u){if(u in r)return i(e[u],r[u]);if(u in e)return i(void 0,e[u])}var f={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c};return ne.forEach(Object.keys(e).concat(Object.keys(r)),function(l){var d=f[l]||s,h=d(l);ne.isUndefined(h)&&d!==c||(n[l]=h)}),n}});var ti=m((Pg,Iu)=>{Iu.exports={version:"0.23.0"}});var qu=m((Ng,ku)=>{"use strict";var Wd=ti().version,ri={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){ri[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var _u={};ri.transitional=function(e,r,n){function i(s,o){return"[Axios v"+Wd+"] Transitional option '"+s+"'"+o+(n?". "+n:"")}return function(s,o,a){if(e===!1)throw new Error(i(o," has been removed"+(r?" in "+r:"")));return r&&!_u[o]&&(_u[o]=!0,console.warn(i(o," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(s,o,a):!0}};function Kd(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),i=n.length;i-- >0;){var s=n[i],o=e[s];if(o){var a=t[s],c=a===void 0||o(a,s,t);if(c!==!0)throw new TypeError("option "+s+" must be "+c);continue}if(r!==!0)throw Error("Unknown option "+s)}}ku.exports={assertOptions:Kd,validators:ri}});var Bu=m((Ig,ju)=>{"use strict";var Mu=Y(),Xd=Gn(),Du=Za(),Uu=Pu(),Nr=ei(),Lu=qu(),nt=Lu.validators;function Ut(t){this.defaults=t,this.interceptors={request:new Du,response:new Du}}Ut.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=Nr(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;r!==void 0&&Lu.assertOptions(r,{silentJSONParsing:nt.transitional(nt.boolean),forcedJSONParsing:nt.transitional(nt.boolean),clarifyTimeoutError:nt.transitional(nt.boolean)},!1);var n=[],i=!0;this.interceptors.request.forEach(function(d){typeof d.runWhen=="function"&&d.runWhen(e)===!1||(i=i&&d.synchronous,n.unshift(d.fulfilled,d.rejected))});var s=[];this.interceptors.response.forEach(function(d){s.push(d.fulfilled,d.rejected)});var o;if(!i){var a=[Uu,void 0];for(Array.prototype.unshift.apply(a,n),a=a.concat(s),o=Promise.resolve(e);a.length;)o=o.then(a.shift(),a.shift());return o}for(var c=e;n.length;){var f=n.shift(),u=n.shift();try{c=f(c)}catch(l){u(l);break}}try{o=Uu(c)}catch(l){return Promise.reject(l)}for(;s.length;)o=o.then(s.shift(),s.shift());return o};Ut.prototype.getUri=function(e){return e=Nr(this.defaults,e),Xd(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};Mu.forEach(["delete","get","head","options"],function(e){Ut.prototype[e]=function(r,n){return this.request(Nr(n||{},{method:e,url:r,data:(n||{}).data}))}});Mu.forEach(["post","put","patch"],function(e){Ut.prototype[e]=function(r,n,i){return this.request(Nr(i||{},{method:e,url:r,data:n}))}});ju.exports=Ut});var Vu=m((_g,Fu)=>{"use strict";var Yd=qt();function it(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(i){e=i});var r=this;this.promise.then(function(n){if(!!r._listeners){var i,s=r._listeners.length;for(i=0;i<s;i++)r._listeners[i](n);r._listeners=null}}),this.promise.then=function(n){var i,s=new Promise(function(o){r.subscribe(o),i=o}).then(n);return s.cancel=function(){r.unsubscribe(i)},s},t(function(i){r.reason||(r.reason=new Yd(i),e(r.reason))})}it.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};it.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};it.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}};it.source=function(){var e,r=new it(function(i){e=i});return{token:r,cancel:e}};Fu.exports=it});var Gu=m((kg,Hu)=>{"use strict";Hu.exports=function(e){return function(n){return e.apply(null,n)}}});var zu=m((qg,Ju)=>{"use strict";Ju.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var Ku=m((Dg,ni)=>{"use strict";var $u=Y(),Qd=jn(),Ir=Bu(),Zd=ei(),eh=Dt();function Wu(t){var e=new Ir(t),r=Qd(Ir.prototype.request,e);return $u.extend(r,Ir.prototype,e),$u.extend(r,e),r.create=function(i){return Wu(Zd(t,i))},r}var he=Wu(eh);he.Axios=Ir;he.Cancel=qt();he.CancelToken=Vu();he.isCancel=Yn();he.VERSION=ti().version;he.all=function(e){return Promise.all(e)};he.spread=Gu();he.isAxiosError=zu();ni.exports=he;ni.exports.default=he});var ii=m((Ug,Xu)=>{Xu.exports=Ku()});var v=function(){return v=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},v.apply(this,arguments)};function je(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function T(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function A(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function k(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))}var P;(function(t){t.Start="xstate.start",t.Stop="xstate.stop",t.Raise="xstate.raise",t.Send="xstate.send",t.Cancel="xstate.cancel",t.NullEvent="",t.Assign="xstate.assign",t.After="xstate.after",t.DoneState="done.state",t.DoneInvoke="done.invoke",t.Log="xstate.log",t.Init="xstate.init",t.Invoke="xstate.invoke",t.ErrorExecution="error.execution",t.ErrorCommunication="error.communication",t.ErrorPlatform="error.platform",t.ErrorCustom="xstate.error",t.Update="xstate.update",t.Pure="xstate.pure",t.Choose="xstate.choose"})(P||(P={}));var ge;(function(t){t.Parent="#_parent",t.Internal="#_internal"})(ge||(ge={}));var ot=P.Start,Be=P.Stop,Fe=P.Raise,be=P.Send,jt=P.Cancel,ci=P.NullEvent,Bt=P.Assign,sh=P.After,oh=P.DoneState,Ft=P.Log,fi=P.Init,at=P.Invoke,ah=P.ErrorExecution,kr=P.ErrorPlatform,qr=P.ErrorCustom,ut=P.Update,li=P.Choose,di=P.Pure;var Vt=".",Dr={},Ht="xstate.guard",hi="";var U=!0;var Gt;function ft(t,e,r){r===void 0&&(r=Vt);var n=Ve(t,r),i=Ve(e,r);return R(i)?R(n)?i===n:!1:R(n)?n in i:Object.keys(n).every(function(s){return s in i?ft(n[s],i[s]):!1})}function Jt(t){try{return R(t)||typeof t=="number"?"".concat(t):t.type}catch{throw new Error("Events must be strings or objects with a string event.type property.")}}function zt(t,e){try{return pe(t)?t:t.toString().split(e)}catch{throw new Error("'".concat(t,"' is not a valid state path."))}}function uc(t){return typeof t=="object"&&"value"in t&&"context"in t&&"event"in t&&"_event"in t}function Ve(t,e){if(uc(t))return t.value;if(pe(t))return ct(t);if(typeof t!="string")return t;var r=zt(t,e);return ct(r)}function ct(t){if(t.length===1)return t[0];for(var e={},r=e,n=0;n<t.length-1;n++)n===t.length-2?r[t[n]]=t[n+1]:(r[t[n]]={},r=r[t[n]]);return e}function He(t,e){for(var r={},n=Object.keys(t),i=0;i<n.length;i++){var s=n[i];r[s]=e(t[s],s,t,i)}return r}function Ur(t,e,r){var n,i,s={};try{for(var o=T(Object.keys(t)),a=o.next();!a.done;a=o.next()){var c=a.value,f=t[c];!r(f)||(s[c]=e(f,c,t))}}catch(u){n={error:u}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}var pi=function(t){return function(e){var r,n,i=e;try{for(var s=T(t),o=s.next();!o.done;o=s.next()){var a=o.value;i=i[a]}}catch(c){r={error:c}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return i}};function mi(t,e){return function(r){var n,i,s=r;try{for(var o=T(t),a=o.next();!a.done;a=o.next()){var c=a.value;s=s[e][c]}}catch(f){n={error:f}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}}function lt(t){if(!t)return[[]];if(R(t))return[[t]];var e=D(Object.keys(t).map(function(r){var n=t[r];return typeof n!="string"&&(!n||!Object.keys(n).length)?[[r]]:lt(t[r]).map(function(i){return[r].concat(i)})}));return e}function D(t){var e;return(e=[]).concat.apply(e,k([],A(t),!1))}function vi(t){return pe(t)?t:[t]}function te(t){return t===void 0?[]:vi(t)}function Te(t,e,r){var n,i;if(N(t))return t(e,r.data);var s={};try{for(var o=T(Object.keys(t)),a=o.next();!a.done;a=o.next()){var c=a.value,f=t[c];N(f)?s[c]=f(e,r.data):s[c]=f}}catch(u){n={error:u}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}function yi(t){return/^(done|error)\./.test(t)}function Mr(t){return!!(t instanceof Promise||t!==null&&(N(t)||typeof t=="object")&&N(t.then))}function gi(t){return t!==null&&typeof t=="object"&&"transition"in t&&typeof t.transition=="function"}function $t(t,e){var r,n,i=A([[],[]],2),s=i[0],o=i[1];try{for(var a=T(t),c=a.next();!c.done;c=a.next()){var f=c.value;e(f)?s.push(f):o.push(f)}}catch(u){r={error:u}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return[s,o]}function Ei(t,e){return He(t.states,function(r,n){if(!!r){var i=(R(e)?void 0:e[n])||(r?r.current:void 0);if(!!i)return{current:i,states:Ei(r,i)}}})}function Si(t,e){return{current:e,states:Ei(t,e)}}function Lr(t,e,r,n){U||j(!!t,"Attempting to update undefined context");var i=t&&r.reduce(function(s,o){var a,c,f=o.assignment,u={state:n,action:o,_event:e},l={};if(N(f))l=f(s,e.data,u);else try{for(var d=T(Object.keys(f)),h=d.next();!h.done;h=d.next()){var g=h.value,E=f[g];l[g]=N(E)?E(s,e.data,u):E}}catch(p){a={error:p}}finally{try{h&&!h.done&&(c=d.return)&&c.call(d)}finally{if(a)throw a.error}}return Object.assign({},s,l)},t);return i}var j=function(){};U||(j=function(t,e){var r=t instanceof Error?t:void 0;if(!(!r&&t)&&console!==void 0){var n=["Warning: ".concat(e)];r&&n.push(r),console.warn.apply(console,n)}});function pe(t){return Array.isArray(t)}function N(t){return typeof t=="function"}function R(t){return typeof t=="string"}function Wt(t,e){if(!!t)return R(t)?{type:Ht,name:t,predicate:e?e[t]:void 0}:N(t)?{type:Ht,name:t.name,predicate:t}:t}function wi(t){try{return"subscribe"in t&&N(t.subscribe)}catch{return!1}}var ce=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}(),ph=(Gt={},Gt[ce]=function(){return this},Gt[Symbol.observable]=function(){return this},Gt);function fe(t){return!!t&&"__xstatenode"in t}function xi(t){return!!t&&typeof t.send=="function"}function dt(t,e){return R(t)||typeof t=="number"?v({type:t},e):t}function F(t,e){if(!R(t)&&"$$type"in t&&t.$$type==="scxml")return t;var r=dt(t);return v({name:r.type,data:r,$$type:"scxml",type:"external"},e)}function Ae(t,e){var r=vi(e).map(function(n){return typeof n=="undefined"||typeof n=="string"||fe(n)?{target:n,event:t}:v(v({},n),{event:t})});return r}function bi(t){if(!(t===void 0||t===hi))return te(t)}function Ti(t,e,r){if(!U){var n=t.stack?" Stacktrace was '".concat(t.stack,"'"):"";if(t===e)console.error("Missing onError handler for invocation '".concat(r,"', error was '").concat(t,"'.").concat(n));else{var i=e.stack?" Stacktrace was '".concat(e.stack,"'"):"";console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '".concat(r,"'. ")+"Original error: '".concat(t,"'. ").concat(n," Current error is '").concat(e,"'.").concat(i))}}}function Kt(t,e,r,n,i){var s=t.options.guards,o={state:i,cond:e,_event:n};if(e.type===Ht)return((s==null?void 0:s[e.name])||e.predicate)(r,n.data,o);var a=s==null?void 0:s[e.type];if(!a)throw new Error("Guard '".concat(e.type,"' is not implemented on machine '").concat(t.id,"'."));return a(r,n.data,o)}function Xt(t){return typeof t=="string"?{type:t}:t}function ht(t,e,r){if(typeof t=="object")return t;var n=function(){};return{next:t,error:e||n,complete:r||n}}function pt(t,e){return"".concat(t,":invocation[").concat(e,"]")}var Re=F({type:fi});function Yt(t,e){return e&&e[t]||void 0}function Ge(t,e){var r;if(R(t)||typeof t=="number"){var n=Yt(t,e);N(n)?r={type:t,exec:n}:n?r=n:r={type:t,exec:void 0}}else if(N(t))r={type:t.name||t.toString(),exec:t};else{var n=Yt(t.type,e);if(N(n))r=v(v({},t),{exec:n});else if(n){var i=n.type||t.type;r=v(v(v({},n),t),{type:i})}else r=t}return r}var mt=function(t,e){if(!t)return[];var r=pe(t)?t:[t];return r.map(function(n){return Ge(n,e)})};function Zt(t){var e=Ge(t);return v(v({id:R(t)?t:e.id},e),{type:e.type})}function Ai(t){return R(t)?{type:Fe,event:t}:vt(t,{to:ge.Internal})}function cc(t){return{type:Fe,_event:F(t.event)}}function vt(t,e){return{to:e?e.to:void 0,type:be,event:N(t)?t:dt(t),delay:e?e.delay:void 0,id:e&&e.id!==void 0?e.id:N(t)?t.name:Jt(t)}}function fc(t,e,r,n){var i={_event:r},s=F(N(t.event)?t.event(e,r.data,i):t.event),o;if(R(t.delay)){var a=n&&n[t.delay];o=N(a)?a(e,r.data,i):a}else o=N(t.delay)?t.delay(e,r.data,i):t.delay;var c=N(t.to)?t.to(e,r.data,i):t.to;return v(v({},t),{to:c,_event:s,event:s.data,delay:o})}var lc=function(t,e,r){return v(v({},t),{value:R(t.expr)?t.expr:t.expr(e,r.data,{_event:r})})},Ri=function(t){return{type:jt,sendId:t}};function Oi(t){var e=Zt(t);return{type:P.Start,activity:e,exec:void 0}}function Ci(t){var e=N(t)?t:Zt(t);return{type:P.Stop,activity:e,exec:void 0}}function dc(t,e,r){var n=N(t.activity)?t.activity(e,r.data):t.activity,i=typeof n=="string"?{id:n}:n,s={type:P.Stop,activity:i};return s}var Pi=function(t){return{type:Bt,assignment:t}};function Ni(t,e){var r=e?"#".concat(e):"";return"".concat(P.After,"(").concat(t,")").concat(r)}function yt(t,e){var r="".concat(P.DoneState,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Oe(t,e){var r="".concat(P.DoneInvoke,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Ce(t,e){var r="".concat(P.ErrorPlatform,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Qt(t,e,r,n,i,s){s===void 0&&(s=!1);var o=A(s?[[],i]:$t(i,function(d){return d.type===Bt}),2),a=o[0],c=o[1],f=a.length?Lr(r,n,a,e):r,u=s?[r]:void 0,l=D(c.map(function(d){var h;switch(d.type){case Fe:return cc(d);case be:var g=fc(d,f,n,t.options.delays);return U||j(!R(d.delay)||typeof g.delay=="number","No delay reference for delay expression '".concat(d.delay,"' was found on machine '").concat(t.id,"'")),g;case Ft:return lc(d,f,n);case li:{var E=d,p=(h=E.conds.find(function(L){var V=Wt(L.cond,t.options.guards);return!V||Kt(t,V,f,n,e)}))===null||h===void 0?void 0:h.actions;if(!p)return[];var w=A(Qt(t,e,f,n,mt(te(p),t.options.actions),s),2),y=w[0],x=w[1];return f=x,u==null||u.push(f),y}case di:{var p=d.get(f,n.data);if(!p)return[];var C=A(Qt(t,e,f,n,mt(te(p),t.options.actions),s),2),I=C[0],B=C[1];return f=B,u==null||u.push(f),I}case Be:return dc(d,f,n);case Bt:{f=Lr(f,n,[d],e),u==null||u.push(f);break}default:var b=Ge(d,t.options.actions),S=b.exec;if(S&&u){var O=u.length-1;b=v(v({},b),{exec:function(L){for(var V=[],Q=1;Q<arguments.length;Q++)V[Q-1]=arguments[Q];S.apply(void 0,k([u[O]],A(V),!1))}})}return b}}).filter(function(d){return!!d}));return[l,f]}var Ii=[],Pe=function(t,e){Ii.push(t);var r=e(t);return Ii.pop(),r};function _i(t){var e;return e={id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},getSnapshot:function(){},toJSON:function(){return{id:t}}},e[ce]=function(){return this},e}function ki(t,e,r,n){var i,s=Xt(t.src),o=(i=e==null?void 0:e.options.services)===null||i===void 0?void 0:i[s.type],a=t.data?Te(t.data,r,n):void 0,c=o?qi(o,t.id,a):_i(t.id);return c.meta=t,c}function qi(t,e,r){var n=_i(e);if(n.deferred=!0,fe(t)){var i=n.state=Pe(void 0,function(){return(r?t.withContext(r):t).initialState});n.getSnapshot=function(){return i}}return n}function hc(t){try{return typeof t.send=="function"}catch{return!1}}function Di(t){return hc(t)&&"id"in t}function Ui(t){var e;return v((e={subscribe:function(){return{unsubscribe:function(){}}},id:"anonymous",getSnapshot:function(){}},e[ce]=function(){return this},e),t)}var gt=function(t){return t.type==="atomic"||t.type==="final"};function Ne(t){return Object.keys(t.states).map(function(e){return t.states[e]})}function Br(t){var e=[t];return gt(t)?e:e.concat(D(Ne(t).map(Br)))}function Ie(t,e){var r,n,i,s,o,a,c,f,u=new Set(t),l=jr(u),d=new Set(e);try{for(var h=T(d),g=h.next();!g.done;g=h.next())for(var E=g.value,p=E.parent;p&&!d.has(p);)d.add(p),p=p.parent}catch(O){r={error:O}}finally{try{g&&!g.done&&(n=h.return)&&n.call(h)}finally{if(r)throw r.error}}var w=jr(d);try{for(var y=T(d),x=y.next();!x.done;x=y.next()){var E=x.value;if(E.type==="compound"&&(!w.get(E)||!w.get(E).length))l.get(E)?l.get(E).forEach(function(L){return d.add(L)}):E.initialStateNodes.forEach(function(L){return d.add(L)});else if(E.type==="parallel")try{for(var C=(o=void 0,T(Ne(E))),I=C.next();!I.done;I=C.next()){var B=I.value;B.type!=="history"&&(d.has(B)||(d.add(B),l.get(B)?l.get(B).forEach(function(L){return d.add(L)}):B.initialStateNodes.forEach(function(L){return d.add(L)})))}}catch(L){o={error:L}}finally{try{I&&!I.done&&(a=C.return)&&a.call(C)}finally{if(o)throw o.error}}}}catch(O){i={error:O}}finally{try{x&&!x.done&&(s=y.return)&&s.call(y)}finally{if(i)throw i.error}}try{for(var b=T(d),S=b.next();!S.done;S=b.next())for(var E=S.value,p=E.parent;p&&!d.has(p);)d.add(p),p=p.parent}catch(O){c={error:O}}finally{try{S&&!S.done&&(f=b.return)&&f.call(b)}finally{if(c)throw c.error}}return d}function Mi(t,e){var r=e.get(t);if(!r)return{};if(t.type==="compound"){var n=r[0];if(n){if(gt(n))return n.key}else return{}}var i={};return r.forEach(function(s){i[s.key]=Mi(s,e)}),i}function jr(t){var e,r,n=new Map;try{for(var i=T(t),s=i.next();!s.done;s=i.next()){var o=s.value;n.has(o)||n.set(o,[]),o.parent&&(n.has(o.parent)||n.set(o.parent,[]),n.get(o.parent).push(o))}}catch(a){e={error:a}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return n}function Li(t,e){var r=Ie([t],e);return Mi(t,jr(r))}function Et(t,e){return Array.isArray(t)?t.some(function(r){return r===e}):t instanceof Set?t.has(e):!1}function ji(t){return k([],A(new Set(D(k([],A(t.map(function(e){return e.ownEvents})),!1)))),!1)}function _e(t,e){return e.type==="compound"?Ne(e).some(function(r){return r.type==="final"&&Et(t,r)}):e.type==="parallel"?Ne(e).every(function(r){return _e(t,r)}):!1}function Bi(t){return t===void 0&&(t=[]),t.reduce(function(e,r){return r.meta!==void 0&&(e[r.id]=r.meta),e},{})}function Fr(t){return new Set(D(t.map(function(e){return e.tags})))}function Vr(t,e){if(t===e)return!0;if(t===void 0||e===void 0)return!1;if(R(t)||R(e))return t===e;var r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&r.every(function(i){return Vr(t[i],e[i])})}function Fi(t){return typeof t!="object"||t===null?!1:"value"in t&&"_event"in t}function Vi(t,e){var r=t.exec,n=v(v({},t),{exec:r!==void 0?function(){return r(e.context,e.event,{action:t,state:e,_event:e._event})}:void 0});return n}var se=function(){function t(e){var r=this,n;this.actions=[],this.activities=Dr,this.meta={},this.events=[],this.value=e.value,this.context=e.context,this._event=e._event,this._sessionid=e._sessionid,this.event=this._event.data,this.historyValue=e.historyValue,this.history=e.history,this.actions=e.actions||[],this.activities=e.activities||Dr,this.meta=Bi(e.configuration),this.events=e.events||[],this.matches=this.matches.bind(this),this.toStrings=this.toStrings.bind(this),this.configuration=e.configuration,this.transitions=e.transitions,this.children=e.children,this.done=!!e.done,this.tags=(n=Array.isArray(e.tags)?new Set(e.tags):e.tags)!==null&&n!==void 0?n:new Set,this.machine=e.machine,Object.defineProperty(this,"nextEvents",{get:function(){return ji(r.configuration)}})}return t.from=function(e,r){if(e instanceof t)return e.context!==r?new t({value:e.value,context:r,_event:e._event,_sessionid:null,historyValue:e.historyValue,history:e.history,actions:[],activities:e.activities,meta:{},events:[],configuration:[],transitions:[],children:{}}):e;var n=Re;return new t({value:e,context:r,_event:n,_sessionid:null,historyValue:void 0,history:void 0,actions:[],activities:void 0,meta:void 0,events:[],configuration:[],transitions:[],children:{}})},t.create=function(e){return new t(e)},t.inert=function(e,r){if(e instanceof t){if(!e.actions.length)return e;var n=Re;return new t({value:e.value,context:r,_event:n,_sessionid:null,historyValue:e.historyValue,history:e.history,activities:e.activities,configuration:e.configuration,transitions:[],children:{}})}return t.from(e,r)},t.prototype.toStrings=function(e,r){var n=this;if(e===void 0&&(e=this.value),r===void 0&&(r="."),R(e))return[e];var i=Object.keys(e);return i.concat.apply(i,k([],A(i.map(function(s){return n.toStrings(e[s],r).map(function(o){return s+r+o})})),!1))},t.prototype.toJSON=function(){var e=this;e.configuration,e.transitions;var r=e.tags;e.machine;var n=je(e,["configuration","transitions","tags","machine"]);return v(v({},n),{tags:Array.from(r)})},t.prototype.matches=function(e){return ft(e,this.value)},t.prototype.hasTag=function(e){return this.tags.has(e)},t.prototype.can=function(e){var r;U&&j(!!this.machine,"state.can(...) used outside of a machine-created State object; this will always return false.");var n=(r=this.machine)===null||r===void 0?void 0:r.getTransitionData(this,e);return!!(n!=null&&n.transitions.length)&&n.transitions.some(function(i){return i.target!==void 0||i.actions.length})},t}();var pc={deferEvents:!1},Hr=function(){function t(e){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=v(v({},pc),e)}return t.prototype.initialize=function(e){if(this.initialized=!0,e){if(!this.options.deferEvents){this.schedule(e);return}this.process(e)}this.flushEvents()},t.prototype.schedule=function(e){if(!this.initialized||this.processingEvent){this.queue.push(e);return}if(this.queue.length!==0)throw new Error("Event queue should be empty when it is not processing events");this.process(e),this.flushEvents()},t.prototype.clear=function(){this.queue=[]},t.prototype.flushEvents=function(){for(var e=this.queue.shift();e;)this.process(e),e=this.queue.shift()},t.prototype.process=function(e){this.processingEvent=!0;try{e()}catch(r){throw this.clear(),r}finally{this.processingEvent=!1}},t}();var Gr=new Map,mc=0,St={bookId:function(){return"x:".concat(mc++)},register:function(t,e){return Gr.set(t,e),t},get:function(t){return Gr.get(t)},free:function(t){Gr.delete(t)}};function er(){if(typeof globalThis!="undefined")return globalThis;if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;U||console.warn("XState could not find a global object in this environment. Please let the maintainers know and raise an issue here: https://github.com/statelyai/xstate/issues")}function vc(){var t=er();if(t&&"__xstate__"in t)return t.__xstate__}function Hi(t){if(!!er()){var e=vc();e&&e.register(t)}}function Gi(t,e){e===void 0&&(e={});var r=t.initialState,n=new Set,i=[],s=!1,o=function(){if(!s){for(s=!0;i.length>0;){var f=i.shift();r=t.transition(r,f,c),n.forEach(function(u){return u.next(r)})}s=!1}},a=Ui({id:e.id,send:function(f){i.push(f),o()},getSnapshot:function(){return r},subscribe:function(f,u,l){var d=ht(f,u,l);return n.add(d),d.next(r),{unsubscribe:function(){n.delete(d)}}}}),c={parent:e.parent,self:a,id:e.id||"anonymous",observers:n};return r=t.start?t.start(c):r,a}var yc={sync:!1,autoForward:!1},z;(function(t){t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped"})(z||(z={}));var Ji=function(){function t(e,r){var n=this;r===void 0&&(r=t.defaultOptions),this.machine=e,this.scheduler=new Hr,this.delayedEventsMap={},this.listeners=new Set,this.contextListeners=new Set,this.stopListeners=new Set,this.doneListeners=new Set,this.eventListeners=new Set,this.sendListeners=new Set,this.initialized=!1,this.status=z.NotStarted,this.children=new Map,this.forwardTo=new Set,this.init=this.start,this.send=function(u,l){if(pe(u))return n.batch(u),n.state;var d=F(dt(u,l));if(n.status===z.Stopped)return U||j(!1,'Event "'.concat(d.name,'" was sent to stopped service "').concat(n.machine.id,`". This service has already reached its final state, and will not transition.
5
- Event: `).concat(JSON.stringify(d.data))),n.state;if(n.status!==z.Running&&!n.options.deferEvents)throw new Error('Event "'.concat(d.name,'" was sent to uninitialized service "').concat(n.machine.id,`". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.
6
- Event: `).concat(JSON.stringify(d.data)));return n.scheduler.schedule(function(){n.forward(d);var h=n.nextState(d);n.update(h,d)}),n._state},this.sendTo=function(u,l){var d=n.parent&&(l===ge.Parent||n.parent.id===l),h=d?n.parent:R(l)?n.children.get(l)||St.get(l):xi(l)?l:void 0;if(!h){if(!d)throw new Error("Unable to send event to child '".concat(l,"' from service '").concat(n.id,"'."));U||j(!1,"Service '".concat(n.id,"' has no parent: unable to send event ").concat(u.type));return}"machine"in h?h.send(v(v({},u),{name:u.name===qr?"".concat(Ce(n.id)):u.name,origin:n.sessionId})):h.send(u.data)};var i=v(v({},t.defaultOptions),r),s=i.clock,o=i.logger,a=i.parent,c=i.id,f=c!==void 0?c:e.id;this.id=f,this.logger=o,this.clock=s,this.parent=a,this.options=i,this.scheduler=new Hr({deferEvents:this.options.deferEvents}),this.sessionId=St.bookId()}return Object.defineProperty(t.prototype,"initialState",{get:function(){var e=this;return this._initialState?this._initialState:Pe(this,function(){return e._initialState=e.machine.initialState,e._initialState})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return U||j(this.status!==z.NotStarted,"Attempted to read state from uninitialized service '".concat(this.id,"'. Make sure the service is started first.")),this._state},enumerable:!1,configurable:!0}),t.prototype.execute=function(e,r){var n,i;try{for(var s=T(e.actions),o=s.next();!o.done;o=s.next()){var a=o.value;this.exec(a,e,r)}}catch(c){n={error:c}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}},t.prototype.update=function(e,r){var n,i,s,o,a,c,f,u,l=this;if(e._sessionid=this.sessionId,this._state=e,this.options.execute&&this.execute(this.state),this.children.forEach(function(O){l.state.children[O.id]=O}),this.devTools&&this.devTools.send(r.data,e),e.event)try{for(var d=T(this.eventListeners),h=d.next();!h.done;h=d.next()){var g=h.value;g(e.event)}}catch(O){n={error:O}}finally{try{h&&!h.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}try{for(var E=T(this.listeners),p=E.next();!p.done;p=E.next()){var g=p.value;g(e,e.event)}}catch(O){s={error:O}}finally{try{p&&!p.done&&(o=E.return)&&o.call(E)}finally{if(s)throw s.error}}try{for(var w=T(this.contextListeners),y=w.next();!y.done;y=w.next()){var x=y.value;x(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(O){a={error:O}}finally{try{y&&!y.done&&(c=w.return)&&c.call(w)}finally{if(a)throw a.error}}var C=_e(e.configuration||[],this.machine);if(this.state.configuration&&C){var I=e.configuration.find(function(O){return O.type==="final"&&O.parent===l.machine}),B=I&&I.doneData?Te(I.doneData,e.context,r):void 0;try{for(var b=T(this.doneListeners),S=b.next();!S.done;S=b.next()){var g=S.value;g(Oe(this.id,B))}}catch(O){f={error:O}}finally{try{S&&!S.done&&(u=b.return)&&u.call(b)}finally{if(f)throw f.error}}this.stop()}},t.prototype.onTransition=function(e){return this.listeners.add(e),this.status===z.Running&&e(this.state,this.state.event),this},t.prototype.subscribe=function(e,r,n){var i=this;if(!e)return{unsubscribe:function(){}};var s,o=n;return typeof e=="function"?s=e:(s=e.next.bind(e),o=e.complete.bind(e)),this.listeners.add(s),this.status===z.Running&&s(this.state),o&&this.onDone(o),{unsubscribe:function(){s&&i.listeners.delete(s),o&&i.doneListeners.delete(o)}}},t.prototype.onEvent=function(e){return this.eventListeners.add(e),this},t.prototype.onSend=function(e){return this.sendListeners.add(e),this},t.prototype.onChange=function(e){return this.contextListeners.add(e),this},t.prototype.onStop=function(e){return this.stopListeners.add(e),this},t.prototype.onDone=function(e){return this.doneListeners.add(e),this},t.prototype.off=function(e){return this.listeners.delete(e),this.eventListeners.delete(e),this.sendListeners.delete(e),this.stopListeners.delete(e),this.doneListeners.delete(e),this.contextListeners.delete(e),this},t.prototype.start=function(e){var r=this;if(this.status===z.Running)return this;this.machine._init(),St.register(this.sessionId,this),this.initialized=!0,this.status=z.Running;var n=e===void 0?this.initialState:Pe(this,function(){return Fi(e)?r.machine.resolveState(e):r.machine.resolveState(se.from(e,r.machine.context))});return this.options.devTools&&this.attachDev(),this.scheduler.initialize(function(){r.update(n,Re)}),this},t.prototype.stop=function(){var e,r,n,i,s,o,a,c,f,u,l=this;try{for(var d=T(this.listeners),h=d.next();!h.done;h=d.next()){var g=h.value;this.listeners.delete(g)}}catch(S){e={error:S}}finally{try{h&&!h.done&&(r=d.return)&&r.call(d)}finally{if(e)throw e.error}}try{for(var E=T(this.stopListeners),p=E.next();!p.done;p=E.next()){var g=p.value;g(),this.stopListeners.delete(g)}}catch(S){n={error:S}}finally{try{p&&!p.done&&(i=E.return)&&i.call(E)}finally{if(n)throw n.error}}try{for(var w=T(this.contextListeners),y=w.next();!y.done;y=w.next()){var g=y.value;this.contextListeners.delete(g)}}catch(S){s={error:S}}finally{try{y&&!y.done&&(o=w.return)&&o.call(w)}finally{if(s)throw s.error}}try{for(var x=T(this.doneListeners),C=x.next();!C.done;C=x.next()){var g=C.value;this.doneListeners.delete(g)}}catch(S){a={error:S}}finally{try{C&&!C.done&&(c=x.return)&&c.call(x)}finally{if(a)throw a.error}}if(!this.initialized)return this;k([],A(this.state.configuration),!1).sort(function(S,O){return O.order-S.order}).forEach(function(S){var O,L;try{for(var V=T(S.definition.exit),Q=V.next();!Q.done;Q=V.next()){var ye=Q.value;l.exec(ye,l.state)}}catch(Mt){O={error:Mt}}finally{try{Q&&!Q.done&&(L=V.return)&&L.call(V)}finally{if(O)throw O.error}}}),this.children.forEach(function(S){N(S.stop)&&S.stop()});try{for(var I=T(Object.keys(this.delayedEventsMap)),B=I.next();!B.done;B=I.next()){var b=B.value;this.clock.clearTimeout(this.delayedEventsMap[b])}}catch(S){f={error:S}}finally{try{B&&!B.done&&(u=I.return)&&u.call(I)}finally{if(f)throw f.error}}return this.scheduler.clear(),this.initialized=!1,this.status=z.Stopped,St.free(this.sessionId),this},t.prototype.batch=function(e){var r=this;if(this.status===z.NotStarted&&this.options.deferEvents)U||j(!1,"".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,`" and are deferred. Make sure .start() is called for this service.
7
- Event: `).concat(JSON.stringify(event)));else if(this.status!==z.Running)throw new Error("".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.'));this.scheduler.schedule(function(){var n,i,s=r.state,o=!1,a=[],c=function(d){var h=F(d);r.forward(h),s=Pe(r,function(){return r.machine.transition(s,h)}),a.push.apply(a,k([],A(s.actions.map(function(g){return Vi(g,s)})),!1)),o=o||!!s.changed};try{for(var f=T(e),u=f.next();!u.done;u=f.next()){var l=u.value;c(l)}}catch(d){n={error:d}}finally{try{u&&!u.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}s.changed=o,s.actions=a,r.update(s,F(e[e.length-1]))})},t.prototype.sender=function(e){return this.send.bind(this,e)},t.prototype.nextState=function(e){var r=this,n=F(e);if(n.name.indexOf(kr)===0&&!this.state.nextEvents.some(function(s){return s.indexOf(kr)===0}))throw n.data.data;var i=Pe(this,function(){return r.machine.transition(r.state,n)});return i},t.prototype.forward=function(e){var r,n;try{for(var i=T(this.forwardTo),s=i.next();!s.done;s=i.next()){var o=s.value,a=this.children.get(o);if(!a)throw new Error("Unable to forward event '".concat(e,"' from interpreter '").concat(this.id,"' to nonexistant child '").concat(o,"'."));a.send(e)}}catch(c){r={error:c}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}},t.prototype.defer=function(e){var r=this;this.delayedEventsMap[e.id]=this.clock.setTimeout(function(){e.to?r.sendTo(e._event,e.to):r.send(e._event)},e.delay)},t.prototype.cancel=function(e){this.clock.clearTimeout(this.delayedEventsMap[e]),delete this.delayedEventsMap[e]},t.prototype.exec=function(e,r,n){n===void 0&&(n=this.machine.options.actions);var i=r.context,s=r._event,o=e.exec||Yt(e.type,n),a=N(o)?o:o?o.exec:e.exec;if(a)try{return a(i,s.data,{action:e,state:this.state,_event:s})}catch(C){throw this.parent&&this.parent.send({type:"xstate.error",data:C}),C}switch(e.type){case be:var c=e;if(typeof c.delay=="number"){this.defer(c);return}else c.to?this.sendTo(c._event,c.to):this.send(c._event);break;case jt:this.cancel(e.sendId);break;case ot:{if(this.status!==z.Running)return;var f=e.activity;if(!this.state.activities[f.id||f.type])break;if(f.type===P.Invoke){var u=Xt(f.src),l=this.machine.options.services?this.machine.options.services[u.type]:void 0,d=f.id,h=f.data;U||j(!("forward"in f),"`forward` property is deprecated (found in invocation of '".concat(f.src,"' in in machine '").concat(this.machine.id,"'). ")+"Please use `autoForward` instead.");var g="autoForward"in f?f.autoForward:!!f.forward;if(!l){U||j(!1,"No service found for invocation '".concat(f.src,"' in machine '").concat(this.machine.id,"'."));return}var E=h?Te(h,i,s):void 0;if(typeof l=="string")return;var p=N(l)?l(i,s.data,{data:E,src:u,meta:f.meta}):l;if(!p)return;var w=void 0;fe(p)&&(p=E?p.withContext(E):p,w={autoForward:g}),this.spawn(p,d,w)}else this.spawnActivity(f);break}case Be:{this.stopChild(e.activity.id);break}case Ft:var y=e.label,x=e.value;y?this.logger(y,x):this.logger(x);break;default:U||j(!1,"No implementation found for action type '".concat(e.type,"'"));break}},t.prototype.removeChild=function(e){var r;this.children.delete(e),this.forwardTo.delete(e),(r=this.state)===null||r===void 0||delete r.children[e]},t.prototype.stopChild=function(e){var r=this.children.get(e);!r||(this.removeChild(e),N(r.stop)&&r.stop())},t.prototype.spawn=function(e,r,n){if(Mr(e))return this.spawnPromise(Promise.resolve(e),r);if(N(e))return this.spawnCallback(e,r);if(Di(e))return this.spawnActor(e,r);if(wi(e))return this.spawnObservable(e,r);if(fe(e))return this.spawnMachine(e,v(v({},n),{id:r}));if(gi(e))return this.spawnBehavior(e,r);throw new Error('Unable to spawn entity "'.concat(r,'" of type "').concat(typeof e,'".'))},t.prototype.spawnMachine=function(e,r){var n=this;r===void 0&&(r={});var i=new t(e,v(v({},this.options),{parent:this,id:r.id||e.id})),s=v(v({},yc),r);s.sync&&i.onTransition(function(a){n.send(ut,{state:a,id:i.id})});var o=i;return this.children.set(i.id,o),s.autoForward&&this.forwardTo.add(i.id),i.onDone(function(a){n.removeChild(i.id),n.send(F(a,{origin:i.id}))}).start(),o},t.prototype.spawnBehavior=function(e,r){var n=Gi(e,{id:r,parent:this});return this.children.set(r,n),n},t.prototype.spawnPromise=function(e,r){var n,i=this,s=!1,o;e.then(function(c){s||(o=c,i.removeChild(r),i.send(F(Oe(r,c),{origin:r})))},function(c){if(!s){i.removeChild(r);var f=Ce(r,c);try{i.send(F(f,{origin:r}))}catch(u){Ti(c,u,r),i.devTools&&i.devTools.send(f,i.state),i.machine.strict&&i.stop()}}});var a=(n={id:r,send:function(){},subscribe:function(c,f,u){var l=ht(c,f,u),d=!1;return e.then(function(h){d||(l.next(h),!d&&l.complete())},function(h){d||l.error(h)}),{unsubscribe:function(){return d=!0}}},stop:function(){s=!0},toJSON:function(){return{id:r}},getSnapshot:function(){return o}},n[ce]=function(){return this},n);return this.children.set(r,a),a},t.prototype.spawnCallback=function(e,r){var n,i=this,s=!1,o=new Set,a=new Set,c,f=function(d){c=d,a.forEach(function(h){return h(d)}),!s&&i.send(F(d,{origin:r}))},u;try{u=e(f,function(d){o.add(d)})}catch(d){this.send(Ce(r,d))}if(Mr(u))return this.spawnPromise(u,r);var l=(n={id:r,send:function(d){return o.forEach(function(h){return h(d)})},subscribe:function(d){var h=ht(d);return a.add(h.next),{unsubscribe:function(){a.delete(h.next)}}},stop:function(){s=!0,N(u)&&u()},toJSON:function(){return{id:r}},getSnapshot:function(){return c}},n[ce]=function(){return this},n);return this.children.set(r,l),l},t.prototype.spawnObservable=function(e,r){var n,i=this,s,o=e.subscribe(function(c){s=c,i.send(F(c,{origin:r}))},function(c){i.removeChild(r),i.send(F(Ce(r,c),{origin:r}))},function(){i.removeChild(r),i.send(F(Oe(r),{origin:r}))}),a=(n={id:r,send:function(){},subscribe:function(c,f,u){return e.subscribe(c,f,u)},stop:function(){return o.unsubscribe()},getSnapshot:function(){return s},toJSON:function(){return{id:r}}},n[ce]=function(){return this},n);return this.children.set(r,a),a},t.prototype.spawnActor=function(e,r){return this.children.set(r,e),e},t.prototype.spawnActivity=function(e){var r=this.machine.options&&this.machine.options.activities?this.machine.options.activities[e.type]:void 0;if(!r){U||j(!1,"No implementation found for activity '".concat(e.type,"'"));return}var n=r(this.state.context,e);this.spawnEffect(e.id,n)},t.prototype.spawnEffect=function(e,r){var n;this.children.set(e,(n={id:e,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},stop:r||void 0,getSnapshot:function(){},toJSON:function(){return{id:e}}},n[ce]=function(){return this},n))},t.prototype.attachDev=function(){var e=er();if(this.options.devTools&&e){if(e.__REDUX_DEVTOOLS_EXTENSION__){var r=typeof this.options.devTools=="object"?this.options.devTools:void 0;this.devTools=e.__REDUX_DEVTOOLS_EXTENSION__.connect(v(v({name:this.id,autoPause:!0,stateSanitizer:function(n){return{value:n.value,context:n.context,actions:n.actions}}},r),{features:v({jump:!1,skip:!1},r?r.features:void 0)}),this.machine),this.devTools.init(this.state)}Hi(this)}},t.prototype.toJSON=function(){return{id:this.id}},t.prototype[ce]=function(){return this},t.prototype.getSnapshot=function(){return this.status===z.NotStarted?this.initialState:this._state},t.defaultOptions={execute:!0,deferEvents:!0,clock:{setTimeout:function(e,r){return setTimeout(e,r)},clearTimeout:function(e){return clearTimeout(e)}},logger:console.log.bind(console),devTools:!1},t.interpret=me,t}();function me(t,e){var r=new Ji(t,e);return r}function gc(t){if(typeof t=="string"){var e={type:t};return e.toString=function(){return t},e}return t}function wt(t){return v(v({type:at},t),{toJSON:function(){t.onDone,t.onError;var e=je(t,["onDone","onError"]);return v(v({},e),{type:at,src:gc(t.src)})}})}var $e="",Jr="#",xt="*",Je={},ze=function(t){return t[0]===Jr},Ec=function(){return{actions:{},guards:{},services:{},activities:{},delays:{}}},Sc=function(t,e,r){var n=r.slice(0,-1).some(function(s){return!("cond"in s)&&!("in"in s)&&(R(s.target)||fe(s.target))}),i=e===$e?"the transient event":"event '".concat(e,"'");j(!n,"One or more transitions for ".concat(i," on state '").concat(t.id,"' are unreachable. ")+"Make sure that the default transition is the last one defined.")},zi=function(){function t(e,r,n,i){var s=this;n===void 0&&(n="context"in e?e.context:void 0);var o;this.config=e,this._context=n,this.order=-1,this.__xstatenode=!0,this.__cache={events:void 0,relativeValue:new Map,initialStateValue:void 0,initialState:void 0,on:void 0,transitions:void 0,candidates:{},delayedTransitions:void 0},this.idMap={},this.tags=[],this.options=Object.assign(Ec(),r),this.parent=i==null?void 0:i.parent,this.key=this.config.key||(i==null?void 0:i.key)||this.config.id||"(machine)",this.machine=this.parent?this.parent.machine:this,this.path=this.parent?this.parent.path.concat(this.key):[],this.delimiter=this.config.delimiter||(this.parent?this.parent.delimiter:Vt),this.id=this.config.id||k([this.machine.key],A(this.path),!1).join(this.delimiter),this.version=this.parent?this.parent.version:this.config.version,this.type=this.config.type||(this.config.parallel?"parallel":this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.schema=this.parent?this.machine.schema:(o=this.config.schema)!==null&&o!==void 0?o:{},this.description=this.config.description,U||j(!("parallel"in this.config),'The "parallel" property is deprecated and will be removed in version 4.1. '.concat(this.config.parallel?"Replace with `type: 'parallel'`":"Use `type: '".concat(this.type,"'`")," in the config for state node '").concat(this.id,"' instead.")),this.initial=this.config.initial,this.states=this.config.states?He(this.config.states,function(f,u){var l,d=new t(f,{},void 0,{parent:s,key:u});return Object.assign(s.idMap,v((l={},l[d.id]=d,l),d.idMap)),d}):Je;var a=0;function c(f){var u,l;f.order=a++;try{for(var d=T(Ne(f)),h=d.next();!h.done;h=d.next()){var g=h.value;c(g)}}catch(E){u={error:E}}finally{try{h&&!h.done&&(l=d.return)&&l.call(d)}finally{if(u)throw u.error}}}c(this),this.history=this.config.history===!0?"shallow":this.config.history||!1,this._transient=!!this.config.always||(this.config.on?Array.isArray(this.config.on)?this.config.on.some(function(f){var u=f.event;return u===$e}):$e in this.config.on:!1),this.strict=!!this.config.strict,this.onEntry=te(this.config.entry||this.config.onEntry).map(function(f){return Ge(f)}),this.onExit=te(this.config.exit||this.config.onExit).map(function(f){return Ge(f)}),this.meta=this.config.meta,this.doneData=this.type==="final"?this.config.data:void 0,this.invoke=te(this.config.invoke).map(function(f,u){var l,d;if(fe(f)){var h=pt(s.id,u);return s.machine.options.services=v((l={},l[h]=f,l),s.machine.options.services),wt({src:h,id:h})}else if(R(f.src)){var h=f.id||pt(s.id,u);return wt(v(v({},f),{id:h,src:f.src}))}else if(fe(f.src)||N(f.src)){var h=f.id||pt(s.id,u);return s.machine.options.services=v((d={},d[h]=f.src,d),s.machine.options.services),wt(v(v({id:h},f),{src:h}))}else{var g=f.src;return wt(v(v({id:pt(s.id,u)},f),{src:g}))}}),this.activities=te(this.config.activities).concat(this.invoke).map(function(f){return Zt(f)}),this.transition=this.transition.bind(this),this.tags=te(this.config.tags)}return t.prototype._init=function(){this.__cache.transitions||Br(this).forEach(function(e){return e.on})},t.prototype.withConfig=function(e,r){var n=this.options,i=n.actions,s=n.activities,o=n.guards,a=n.services,c=n.delays;return new t(this.config,{actions:v(v({},i),e.actions),activities:v(v({},s),e.activities),guards:v(v({},o),e.guards),services:v(v({},a),e.services),delays:v(v({},c),e.delays)},r!=null?r:this.context)},t.prototype.withContext=function(e){return new t(this.config,this.options,e)},Object.defineProperty(t.prototype,"context",{get:function(){return N(this._context)?this._context():this._context},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"definition",{get:function(){return{id:this.id,key:this.key,version:this.version,context:this.context,type:this.type,initial:this.initial,history:this.history,states:He(this.states,function(e){return e.definition}),on:this.on,transitions:this.transitions,entry:this.onEntry,exit:this.onExit,activities:this.activities||[],meta:this.meta,order:this.order||-1,data:this.doneData,invoke:this.invoke,description:this.description,tags:this.tags}},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return this.definition},Object.defineProperty(t.prototype,"on",{get:function(){if(this.__cache.on)return this.__cache.on;var e=this.transitions;return this.__cache.on=e.reduce(function(r,n){return r[n.eventType]=r[n.eventType]||[],r[n.eventType].push(n),r},{})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"after",{get:function(){return this.__cache.delayedTransitions||(this.__cache.delayedTransitions=this.getDelayedTransitions(),this.__cache.delayedTransitions)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transitions",{get:function(){return this.__cache.transitions||(this.__cache.transitions=this.formatTransitions(),this.__cache.transitions)},enumerable:!1,configurable:!0}),t.prototype.getCandidates=function(e){if(this.__cache.candidates[e])return this.__cache.candidates[e];var r=e===$e,n=this.transitions.filter(function(i){var s=i.eventType===e;return r?s:s||i.eventType===xt});return this.__cache.candidates[e]=n,n},t.prototype.getDelayedTransitions=function(){var e=this,r=this.config.after;if(!r)return[];var n=function(s,o){var a=N(s)?"".concat(e.id,":delay[").concat(o,"]"):s,c=Ni(a,e.id);return e.onEntry.push(vt(c,{delay:s})),e.onExit.push(Ri(c)),c},i=pe(r)?r.map(function(s,o){var a=n(s.delay,o);return v(v({},s),{event:a})}):D(Object.keys(r).map(function(s,o){var a=r[s],c=R(a)?{target:a}:a,f=isNaN(+s)?s:+s,u=n(f,o);return te(c).map(function(l){return v(v({},l),{event:u,delay:f})})}));return i.map(function(s){var o=s.delay;return v(v({},e.formatTransition(s)),{delay:o})})},t.prototype.getStateNodes=function(e){var r,n=this;if(!e)return[];var i=e instanceof se?e.value:Ve(e,this.delimiter);if(R(i)){var s=this.getStateNode(i).initial;return s!==void 0?this.getStateNodes((r={},r[i]=s,r)):[this,this.states[i]]}var o=Object.keys(i),a=[this];return a.push.apply(a,k([],A(D(o.map(function(c){return n.getStateNode(c).getStateNodes(i[c])}))),!1)),a},t.prototype.handles=function(e){var r=Jt(e);return this.events.includes(r)},t.prototype.resolveState=function(e){var r=e instanceof se?e:se.create(e),n=Array.from(Ie([],this.getStateNodes(r.value)));return new se(v(v({},r),{value:this.resolve(r.value),configuration:n,done:_e(n,this),tags:Fr(n),machine:this.machine}))},t.prototype.transitionLeafNode=function(e,r,n){var i=this.getStateNode(e),s=i.next(r,n);return!s||!s.transitions.length?this.next(r,n):s},t.prototype.transitionCompoundNode=function(e,r,n){var i=Object.keys(e),s=this.getStateNode(i[0]),o=s._transition(e[i[0]],r,n);return!o||!o.transitions.length?this.next(r,n):o},t.prototype.transitionParallelNode=function(e,r,n){var i,s,o={};try{for(var a=T(Object.keys(e)),c=a.next();!c.done;c=a.next()){var f=c.value,u=e[f];if(!!u){var l=this.getStateNode(f),d=l._transition(u,r,n);d&&(o[f]=d)}}}catch(y){i={error:y}}finally{try{c&&!c.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}var h=Object.keys(o).map(function(y){return o[y]}),g=D(h.map(function(y){return y.transitions})),E=h.some(function(y){return y.transitions.length>0});if(!E)return this.next(r,n);var p=D(h.map(function(y){return y.entrySet})),w=D(Object.keys(o).map(function(y){return o[y].configuration}));return{transitions:g,entrySet:p,exitSet:D(h.map(function(y){return y.exitSet})),configuration:w,source:r,actions:D(Object.keys(o).map(function(y){return o[y].actions}))}},t.prototype._transition=function(e,r,n){return R(e)?this.transitionLeafNode(e,r,n):Object.keys(e).length===1?this.transitionCompoundNode(e,r,n):this.transitionParallelNode(e,r,n)},t.prototype.getTransitionData=function(e,r){return this._transition(e.value,e,F(r))},t.prototype.next=function(e,r){var n,i,s=this,o=r.name,a=[],c=[],f;try{for(var u=T(this.getCandidates(o)),l=u.next();!l.done;l=u.next()){var d=l.value,h=d.cond,g=d.in,E=e.context,p=g?R(g)&&ze(g)?e.matches(Ve(this.getStateNodeById(g).path,this.delimiter)):ft(Ve(g,this.delimiter),pi(this.path.slice(0,-2))(e.value)):!0,w=!1;try{w=!h||Kt(this.machine,h,E,r,e)}catch(I){throw new Error("Unable to evaluate guard '".concat(h.name||h.type,"' in transition for event '").concat(o,"' in state node '").concat(this.id,`':
8
- `).concat(I.message))}if(w&&p){d.target!==void 0&&(c=d.target),a.push.apply(a,k([],A(d.actions),!1)),f=d;break}}}catch(I){n={error:I}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}if(!!f){if(!c.length)return{transitions:[f],entrySet:[],exitSet:[],configuration:e.value?[this]:[],source:e,actions:a};var y=D(c.map(function(I){return s.getRelativeStateNodes(I,e.historyValue)})),x=!!f.internal,C=x?[]:D(y.map(function(I){return s.nodesFromChild(I)}));return{transitions:[f],entrySet:C,exitSet:x?[]:[this],configuration:y,source:e,actions:a}}},t.prototype.nodesFromChild=function(e){if(e.escapes(this))return[];for(var r=[],n=e;n&&n!==this;)r.push(n),n=n.parent;return r.push(this),r},t.prototype.escapes=function(e){if(this===e)return!1;for(var r=this.parent;r;){if(r===e)return!1;r=r.parent}return!0},t.prototype.getActions=function(e,r,n,i){var s,o,a,c,f=Ie([],i?this.getStateNodes(i.value):[this]),u=e.configuration.length?Ie(f,e.configuration):f;try{for(var l=T(u),d=l.next();!d.done;d=l.next()){var h=d.value;Et(f,h)||e.entrySet.push(h)}}catch(b){s={error:b}}finally{try{d&&!d.done&&(o=l.return)&&o.call(l)}finally{if(s)throw s.error}}try{for(var g=T(f),E=g.next();!E.done;E=g.next()){var h=E.value;(!Et(u,h)||Et(e.exitSet,h.parent))&&e.exitSet.push(h)}}catch(b){a={error:b}}finally{try{E&&!E.done&&(c=g.return)&&c.call(g)}finally{if(a)throw a.error}}var p=D(e.entrySet.map(function(b){var S=[];if(b.type!=="final")return S;var O=b.parent;if(!O.parent)return S;S.push(yt(b.id,b.doneData),yt(O.id,b.doneData?Te(b.doneData,r,n):void 0));var L=O.parent;return L.type==="parallel"&&Ne(L).every(function(V){return _e(e.configuration,V)})&&S.push(yt(L.id)),S}));e.exitSet.sort(function(b,S){return S.order-b.order}),e.entrySet.sort(function(b,S){return b.order-S.order});var w=new Set(e.entrySet),y=new Set(e.exitSet),x=A([D(Array.from(w).map(function(b){return k(k([],A(b.activities.map(function(S){return Oi(S)})),!1),A(b.onEntry),!1)})).concat(p.map(Ai)),D(Array.from(y).map(function(b){return k(k([],A(b.onExit),!1),A(b.activities.map(function(S){return Ci(S)})),!1)}))],2),C=x[0],I=x[1],B=mt(I.concat(e.actions).concat(C),this.machine.options.actions);return B},t.prototype.transition=function(e,r,n){e===void 0&&(e=this.initialState);var i=F(r),s;if(e instanceof se)s=n===void 0?e:this.resolveState(se.from(e,n));else{var o=R(e)?this.resolve(ct(this.getResolvedPath(e))):this.resolve(e),a=n!=null?n:this.machine.context;s=this.resolveState(se.from(o,a))}if(!U&&i.name===xt)throw new Error("An event cannot have the wildcard type ('".concat(xt,"')"));if(this.strict&&!this.events.includes(i.name)&&!yi(i.name))throw new Error("Machine '".concat(this.id,"' does not accept event '").concat(i.name,"'"));var c=this._transition(s.value,s,i)||{transitions:[],configuration:[],entrySet:[],exitSet:[],source:s,actions:[]},f=Ie([],this.getStateNodes(s.value)),u=c.configuration.length?Ie(f,c.configuration):f;return c.configuration=k([],A(u),!1),this.resolveTransition(c,s,s.context,i)},t.prototype.resolveRaisedTransition=function(e,r,n){var i,s=e.actions;return e=this.transition(e,r),e._event=n,e.event=n.data,(i=e.actions).unshift.apply(i,k([],A(s),!1)),e},t.prototype.resolveTransition=function(e,r,n,i){var s,o,a=this;i===void 0&&(i=Re);var c=e.configuration,f=!r||e.transitions.length>0,u=f?Li(this.machine,c):void 0,l=r?r.historyValue?r.historyValue:e.source?this.machine.historyValue(r.value):void 0:void 0,d=this.getActions(e,n,i,r),h=r?v({},r.activities):{};try{for(var g=T(d),E=g.next();!E.done;E=g.next()){var p=E.value;p.type===ot?h[p.activity.id||p.activity.type]=p:p.type===Be&&(h[p.activity.id||p.activity.type]=!1)}}catch(ee){s={error:ee}}finally{try{E&&!E.done&&(o=g.return)&&o.call(g)}finally{if(s)throw s.error}}var w=A(Qt(this,r,n,i,d,this.machine.config.preserveActionOrder),2),y=w[0],x=w[1],C=A($t(y,function(ee){return ee.type===Fe||ee.type===be&&ee.to===ge.Internal}),2),I=C[0],B=C[1],b=y.filter(function(ee){var Me;return ee.type===ot&&((Me=ee.activity)===null||Me===void 0?void 0:Me.type)===at}),S=b.reduce(function(ee,Me){return ee[Me.activity.id]=ki(Me.activity,a.machine,x,i),ee},r?v({},r.children):{}),O=f?e.configuration:r?r.configuration:[],L=_e(O,this),V=new se({value:u||r.value,context:x,_event:i,_sessionid:r?r._sessionid:null,historyValue:u?l?Si(l,u):void 0:r?r.historyValue:void 0,history:!u||e.source?r:void 0,actions:u?B:[],activities:u?h:r?r.activities:{},events:[],configuration:O,transitions:e.transitions,children:S,done:L,tags:r==null?void 0:r.tags,machine:this}),Q=n!==x;V.changed=i.name===ut||Q;var ye=V.history;ye&&delete ye.history;var Mt=!L&&(this._transient||c.some(function(ee){return ee._transient}));if(!f&&(!Mt||i.name===$e))return V;var Z=V;if(!L)for(Mt&&(Z=this.resolveRaisedTransition(Z,{type:ci},i));I.length;){var Zu=I.shift();Z=this.resolveRaisedTransition(Z,Zu._event,i)}var ec=Z.changed||(ye?!!Z.actions.length||Q||typeof ye.value!=typeof Z.value||!Vr(Z.value,ye.value):void 0);return Z.changed=ec,Z.history=ye,Z.tags=Fr(Z.configuration),Z},t.prototype.getStateNode=function(e){if(ze(e))return this.machine.getStateNodeById(e);if(!this.states)throw new Error("Unable to retrieve child state '".concat(e,"' from '").concat(this.id,"'; no child states exist."));var r=this.states[e];if(!r)throw new Error("Child state '".concat(e,"' does not exist on '").concat(this.id,"'"));return r},t.prototype.getStateNodeById=function(e){var r=ze(e)?e.slice(Jr.length):e;if(r===this.id)return this;var n=this.machine.idMap[r];if(!n)throw new Error("Child state node '#".concat(r,"' does not exist on machine '").concat(this.id,"'"));return n},t.prototype.getStateNodeByPath=function(e){if(typeof e=="string"&&ze(e))try{return this.getStateNodeById(e.slice(1))}catch{}for(var r=zt(e,this.delimiter).slice(),n=this;r.length;){var i=r.shift();if(!i.length)break;n=n.getStateNode(i)}return n},t.prototype.resolve=function(e){var r,n=this;if(!e)return this.initialStateValue||Je;switch(this.type){case"parallel":return He(this.initialStateValue,function(s,o){return s?n.getStateNode(o).resolve(e[o]||s):Je});case"compound":if(R(e)){var i=this.getStateNode(e);return i.type==="parallel"||i.type==="compound"?(r={},r[e]=i.initialStateValue,r):e}return Object.keys(e).length?He(e,function(s,o){return s?n.getStateNode(o).resolve(s):Je}):this.initialStateValue||{};default:return e||Je}},t.prototype.getResolvedPath=function(e){if(ze(e)){var r=this.machine.idMap[e.slice(Jr.length)];if(!r)throw new Error("Unable to find state node '".concat(e,"'"));return r.path}return zt(e,this.delimiter)},Object.defineProperty(t.prototype,"initialStateValue",{get:function(){var e;if(this.__cache.initialStateValue)return this.__cache.initialStateValue;var r;if(this.type==="parallel")r=Ur(this.states,function(n){return n.initialStateValue||Je},function(n){return n.type!=="history"});else if(this.initial!==void 0){if(!this.states[this.initial])throw new Error("Initial state '".concat(this.initial,"' not found on '").concat(this.key,"'"));r=gt(this.states[this.initial])?this.initial:(e={},e[this.initial]=this.states[this.initial].initialStateValue,e)}else r={};return this.__cache.initialStateValue=r,this.__cache.initialStateValue},enumerable:!1,configurable:!0}),t.prototype.getInitialState=function(e,r){this._init();var n=this.getStateNodes(e);return this.resolveTransition({configuration:n,entrySet:n,exitSet:[],transitions:[],source:void 0,actions:[]},void 0,r!=null?r:this.machine.context,void 0)},Object.defineProperty(t.prototype,"initialState",{get:function(){var e=this.initialStateValue;if(!e)throw new Error("Cannot retrieve initial state from simple state '".concat(this.id,"'."));return this.getInitialState(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){var e;if(this.type==="history"){var r=this.config;R(r.target)?e=ze(r.target)?ct(this.machine.getStateNodeById(r.target).path.slice(this.path.length-1)):r.target:e=r.target}return e},enumerable:!1,configurable:!0}),t.prototype.getRelativeStateNodes=function(e,r,n){return n===void 0&&(n=!0),n?e.type==="history"?e.resolveHistory(r):e.initialStateNodes:[e]},Object.defineProperty(t.prototype,"initialStateNodes",{get:function(){var e=this;if(gt(this))return[this];if(this.type==="compound"&&!this.initial)return U||j(!1,"Compound state node '".concat(this.id,"' has no initial state.")),[this];var r=lt(this.initialStateValue);return D(r.map(function(n){return e.getFromRelativePath(n)}))},enumerable:!1,configurable:!0}),t.prototype.getFromRelativePath=function(e){if(!e.length)return[this];var r=A(e),n=r[0],i=r.slice(1);if(!this.states)throw new Error("Cannot retrieve subPath '".concat(n,"' from node with no states"));var s=this.getStateNode(n);if(s.type==="history")return s.resolveHistory();if(!this.states[n])throw new Error("Child state '".concat(n,"' does not exist on '").concat(this.id,"'"));return this.states[n].getFromRelativePath(i)},t.prototype.historyValue=function(e){if(!!Object.keys(this.states).length)return{current:e||this.initialStateValue,states:Ur(this.states,function(r,n){if(!e)return r.historyValue();var i=R(e)?void 0:e[n];return r.historyValue(i||r.initialStateValue)},function(r){return!r.history})}},t.prototype.resolveHistory=function(e){var r=this;if(this.type!=="history")return[this];var n=this.parent;if(!e){var i=this.target;return i?D(lt(i).map(function(o){return n.getFromRelativePath(o)})):n.initialStateNodes}var s=mi(n.path,"states")(e).current;return R(s)?[n.getStateNode(s)]:D(lt(s).map(function(o){return r.history==="deep"?n.getFromRelativePath(o):[n.states[o[0]]]}))},Object.defineProperty(t.prototype,"stateIds",{get:function(){var e=this,r=D(Object.keys(this.states).map(function(n){return e.states[n].stateIds}));return[this.id].concat(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"events",{get:function(){var e,r,n,i;if(this.__cache.events)return this.__cache.events;var s=this.states,o=new Set(this.ownEvents);if(s)try{for(var a=T(Object.keys(s)),c=a.next();!c.done;c=a.next()){var f=c.value,u=s[f];if(u.states)try{for(var l=(n=void 0,T(u.events)),d=l.next();!d.done;d=l.next()){var h=d.value;o.add("".concat(h))}}catch(g){n={error:g}}finally{try{d&&!d.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}}}catch(g){e={error:g}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return this.__cache.events=Array.from(o)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ownEvents",{get:function(){var e=new Set(this.transitions.filter(function(r){return!(!r.target&&!r.actions.length&&r.internal)}).map(function(r){return r.eventType}));return Array.from(e)},enumerable:!1,configurable:!0}),t.prototype.resolveTarget=function(e){var r=this;if(e!==void 0)return e.map(function(n){if(!R(n))return n;var i=n[0]===r.delimiter;if(i&&!r.parent)return r.getStateNodeByPath(n.slice(1));var s=i?r.key+n:n;if(r.parent)try{var o=r.parent.getStateNodeByPath(s);return o}catch(a){throw new Error("Invalid transition definition for state node '".concat(r.id,`':
9
- `).concat(a.message))}else return r.getStateNodeByPath(s)})},t.prototype.formatTransition=function(e){var r=this,n=bi(e.target),i="internal"in e?e.internal:n?n.some(function(c){return R(c)&&c[0]===r.delimiter}):!0,s=this.machine.options.guards,o=this.resolveTarget(n),a=v(v({},e),{actions:mt(te(e.actions)),cond:Wt(e.cond,s),target:o,source:this,internal:i,eventType:e.event,toJSON:function(){return v(v({},a),{target:a.target?a.target.map(function(c){return"#".concat(c.id)}):void 0,source:"#".concat(r.id)})}});return a},t.prototype.formatTransitions=function(){var e,r,n=this,i;if(!this.config.on)i=[];else if(Array.isArray(this.config.on))i=this.config.on;else{var s=this.config.on,o=xt,a=s[o],c=a===void 0?[]:a,f=je(s,[typeof o=="symbol"?o:o+""]);i=D(Object.keys(f).map(function(y){!U&&y===$e&&j(!1,"Empty string transition configs (e.g., `{ on: { '': ... }}`) for transient transitions are deprecated. Specify the transition in the `{ always: ... }` property instead. "+'Please check the `on` configuration for "#'.concat(n.id,'".'));var x=Ae(y,f[y]);return U||Sc(n,y,x),x}).concat(Ae(xt,c)))}var u=this.config.always?Ae("",this.config.always):[],l=this.config.onDone?Ae(String(yt(this.id)),this.config.onDone):[];U||j(!(this.config.onDone&&!this.parent),'Root nodes cannot have an ".onDone" transition. Please check the config of "'.concat(this.id,'".'));var d=D(this.invoke.map(function(y){var x=[];return y.onDone&&x.push.apply(x,k([],A(Ae(String(Oe(y.id)),y.onDone)),!1)),y.onError&&x.push.apply(x,k([],A(Ae(String(Ce(y.id)),y.onError)),!1)),x})),h=this.after,g=D(k(k(k(k([],A(l),!1),A(d),!1),A(i),!1),A(u),!1).map(function(y){return te(y).map(function(x){return n.formatTransition(x)})}));try{for(var E=T(h),p=E.next();!p.done;p=E.next()){var w=p.value;g.push(w)}}catch(y){e={error:y}}finally{try{p&&!p.done&&(r=E.return)&&r.call(E)}finally{if(e)throw e.error}}return g},t}();function oe(t,e){return new zi(t,e)}var q=Pi,$=vt;function Wi(t){return!!(t&&typeof t.then=="function")}var wc=Promise.resolve(!1),qp=Promise.resolve(!0),le=Promise.resolve();function tr(t,e){return t||(t=0),new Promise(function(r){return setTimeout(function(){return r(e)},t)})}function Ki(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function bt(){return Math.random().toString(36).substring(2)}var $i=0,zr=0;function Ee(){var t=new Date().getTime();return t===$i?(zr++,t*1e3+zr):($i=t,zr=0,t*1e3)}var Se=Object.prototype.toString.call(typeof process!="undefined"?process:0)==="[object process]";var xc=Ee,bc="native";function Tc(t){var e={messagesCallback:null,bc:new BroadcastChannel(t),subFns:[]};return e.bc.onmessage=function(r){e.messagesCallback&&e.messagesCallback(r.data)},e}function Ac(t){t.bc.close(),t.subFns=[]}function Rc(t,e){try{return t.bc.postMessage(e,!1),le}catch(r){return Promise.reject(r)}}function Oc(t,e){t.messagesCallback=e}function Cc(){if(Se&&typeof window=="undefined")return!1;if(typeof BroadcastChannel=="function"){if(BroadcastChannel._pubkey)throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");return!0}else return!1}function Pc(){return 150}var Xi={create:Tc,close:Ac,onMessage:Oc,postMessage:Rc,canBeUsed:Cc,type:bc,averageResponseTime:Pc,microSeconds:xc};var rr=function(){function t(e){this.ttl=e,this.set=new Set,this.timeMap=new Map}return t.prototype.has=function(e){return this.set.has(e)},t.prototype.add=function(e){var r=this;this.timeMap.set(e,Yi()),this.set.add(e),setTimeout(function(){Nc(r)},0)},t.prototype.clear=function(){this.set.clear(),this.timeMap.clear()},t}();function Nc(t){for(var e=Yi()-t.ttl,r=t.set[Symbol.iterator]();;){var n=r.next().value;if(!n)return;var i=t.timeMap.get(n);if(i<e)t.timeMap.delete(n),t.set.delete(n);else return}}function Yi(){return new Date().getTime()}function We(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=JSON.parse(JSON.stringify(t));return typeof e.webWorkerSupport=="undefined"&&(e.webWorkerSupport=!0),e.idb||(e.idb={}),e.idb.ttl||(e.idb.ttl=1e3*45),e.idb.fallbackInterval||(e.idb.fallbackInterval=150),t.idb&&typeof t.idb.onclose=="function"&&(e.idb.onclose=t.idb.onclose),e.localstorage||(e.localstorage={}),e.localstorage.removeTimeout||(e.localstorage.removeTimeout=1e3*60),t.methods&&(e.methods=t.methods),e.node||(e.node={}),e.node.ttl||(e.node.ttl=1e3*60*2),e.node.maxParallelWrites||(e.node.maxParallelWrites=2048),typeof e.node.useFastPath=="undefined"&&(e.node.useFastPath=!0),e}var Ic=Ee,_c="pubkey.broadcast-channel-0-",ve="messages",kc="idb";function Qi(){if(typeof indexedDB!="undefined")return indexedDB;if(typeof window!="undefined"){if(typeof window.mozIndexedDB!="undefined")return window.mozIndexedDB;if(typeof window.webkitIndexedDB!="undefined")return window.webkitIndexedDB;if(typeof window.msIndexedDB!="undefined")return window.msIndexedDB}return!1}function qc(t){var e=Qi(),r=_c+t,n=e.open(r,1);n.onupgradeneeded=function(s){var o=s.target.result;o.createObjectStore(ve,{keyPath:"id",autoIncrement:!0})};var i=new Promise(function(s,o){n.onerror=function(a){return o(a)},n.onsuccess=function(){s(n.result)}});return i}function Dc(t,e,r){var n=new Date().getTime(),i={uuid:e,time:n,data:r},s=t.transaction([ve],"readwrite");return new Promise(function(o,a){s.oncomplete=function(){return o()},s.onerror=function(f){return a(f)};var c=s.objectStore(ve);c.add(i)})}function Uc(t,e){var r=t.transaction(ve).objectStore(ve),n=[];function i(){try{var s=IDBKeyRange.bound(e+1,1/0);return r.openCursor(s)}catch{return r.openCursor()}}return new Promise(function(s){i().onsuccess=function(o){var a=o.target.result;a?a.value.id<e+1?a.continue(e+1):(n.push(a.value),a.continue()):s(n)}})}function Mc(t,e){var r=t.transaction([ve],"readwrite").objectStore(ve).delete(e);return new Promise(function(n){r.onsuccess=function(){return n()}})}function Lc(t,e){var r=new Date().getTime()-e,n=t.transaction(ve).objectStore(ve),i=[];return new Promise(function(s){n.openCursor().onsuccess=function(o){var a=o.target.result;if(a){var c=a.value;if(c.time<r)i.push(c),a.continue();else{s(i);return}}else s(i)}})}function jc(t,e){return Lc(t,e).then(function(r){return Promise.all(r.map(function(n){return Mc(t,n.id)}))})}function Bc(t,e){return e=We(e),qc(t).then(function(r){var n={closed:!1,lastCursorId:0,channelName:t,options:e,uuid:bt(),eMIs:new rr(e.idb.ttl*2),writeBlockPromise:le,messagesCallback:null,readQueuePromises:[],db:r};return r.onclose=function(){n.closed=!0,e.idb.onclose&&e.idb.onclose()},Zi(n),n})}function Zi(t){t.closed||es(t).then(function(){return tr(t.options.idb.fallbackInterval)}).then(function(){return Zi(t)})}function Fc(t,e){return!(t.uuid===e.uuid||e.eMIs.has(t.id)||t.data.time<e.messagesCallbackTime)}function es(t){return t.closed?le:t.messagesCallback?Uc(t.db,t.lastCursorId).then(function(e){var r=e.filter(function(n){return!!n}).map(function(n){return n.id>t.lastCursorId&&(t.lastCursorId=n.id),n}).filter(function(n){return Fc(n,t)}).sort(function(n,i){return n.time-i.time});return r.forEach(function(n){t.messagesCallback&&(t.eMIs.add(n.id),t.messagesCallback(n.data))}),le}):le}function Vc(t){t.closed=!0,t.db.close()}function Hc(t,e){return t.writeBlockPromise=t.writeBlockPromise.then(function(){return Dc(t.db,t.uuid,e)}).then(function(){Ki(0,10)===0&&jc(t.db,t.options.idb.ttl)}),t.writeBlockPromise}function Gc(t,e,r){t.messagesCallbackTime=r,t.messagesCallback=e,es(t)}function Jc(){if(Se)return!1;var t=Qi();return!!t}function zc(t){return t.idb.fallbackInterval*2}var ts={create:Bc,close:Vc,onMessage:Gc,postMessage:Hc,canBeUsed:Jc,type:kc,averageResponseTime:zc,microSeconds:Ic};var $c=Ee,Wc="pubkey.broadcastChannel-",Kc="localstorage";function rs(){var t;if(typeof window=="undefined")return null;try{t=window.localStorage,t=window["ie8-eventlistener/storage"]||window.localStorage}catch{}return t}function ns(t){return Wc+t}function Xc(t,e){return new Promise(function(r){tr().then(function(){var n=ns(t.channelName),i={token:bt(),time:new Date().getTime(),data:e,uuid:t.uuid},s=JSON.stringify(i);rs().setItem(n,s);var o=document.createEvent("Event");o.initEvent("storage",!0,!0),o.key=n,o.newValue=s,window.dispatchEvent(o),r()})})}function Yc(t,e){var r=ns(t),n=function(s){s.key===r&&e(JSON.parse(s.newValue))};return window.addEventListener("storage",n),n}function Qc(t){window.removeEventListener("storage",t)}function Zc(t,e){if(e=We(e),!is())throw new Error("BroadcastChannel: localstorage cannot be used");var r=bt(),n=new rr(e.localstorage.removeTimeout),i={channelName:t,uuid:r,eMIs:n};return i.listener=Yc(t,function(s){!i.messagesCallback||s.uuid!==r&&(!s.token||n.has(s.token)||s.data.time&&s.data.time<i.messagesCallbackTime||(n.add(s.token),i.messagesCallback(s.data)))}),i}function ef(t){Qc(t.listener)}function tf(t,e,r){t.messagesCallbackTime=r,t.messagesCallback=e}function is(){if(Se)return!1;var t=rs();if(!t)return!1;try{var e="__broadcastchannel_check";t.setItem(e,"works"),t.removeItem(e)}catch{return!1}return!0}function rf(){var t=120,e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")?t*2:t}var ss={create:Zc,close:ef,onMessage:tf,postMessage:Xc,canBeUsed:is,type:Kc,averageResponseTime:rf,microSeconds:$c};var nf=Ee,sf="simulate",$r=new Set;function of(t){var e={name:t,messagesCallback:null};return $r.add(e),e}function af(t){$r.delete(t)}function uf(t,e){return new Promise(function(r){return setTimeout(function(){var n=Array.from($r);n.filter(function(i){return i.name===t.name}).filter(function(i){return i!==t}).filter(function(i){return!!i.messagesCallback}).forEach(function(i){return i.messagesCallback(e)}),r()},5)})}function cf(t,e){t.messagesCallback=e}function ff(){return!0}function lf(){return 5}var os={create:of,close:af,onMessage:cf,postMessage:uf,canBeUsed:ff,type:sf,averageResponseTime:lf,microSeconds:nf};var as=[Xi,ts,ss];function us(t){var e=[].concat(t.methods,as).filter(Boolean);if(t.type){if(t.type==="simulate")return os;var r=e.find(function(i){return i.type===t.type});if(r)return r;throw new Error("method-type "+t.type+" not found")}!t.webWorkerSupport&&!Se&&(e=e.filter(function(i){return i.type!=="idb"}));var n=e.find(function(i){return i.canBeUsed()});if(n)return n;throw new Error("No useable method found in "+JSON.stringify(as.map(function(i){return i.type})))}var Wr=new Set,df=0,ke=function(e,r){this.id=df++,Wr.add(this),this.name=e,cs&&(r=cs),this.options=We(r),this.method=us(this.options),this._iL=!1,this._onML=null,this._addEL={message:[],internal:[]},this._uMP=new Set,this._befC=[],this._prepP=null,hf(this)};ke._pubkey=!0;var cs;ke.prototype={postMessage:function(e){if(this.closed)throw new Error("BroadcastChannel.postMessage(): Cannot post message after channel has closed "+JSON.stringify(e));return fs(this,"message",e)},postInternal:function(e){return fs(this,"internal",e)},set onmessage(t){var e=this.method.microSeconds(),r={time:e,fn:t};ds(this,"message",this._onML),t&&typeof t=="function"?(this._onML=r,ls(this,"message",r)):this._onML=null},addEventListener:function(e,r){var n=this.method.microSeconds(),i={time:n,fn:r};ls(this,e,i)},removeEventListener:function(e,r){var n=this._addEL[e].find(function(i){return i.fn===r});ds(this,e,n)},close:function(){var e=this;if(!this.closed){Wr.delete(this),this.closed=!0;var r=this._prepP?this._prepP:le;return this._onML=null,this._addEL.message=[],r.then(function(){return Promise.all(Array.from(e._uMP))}).then(function(){return Promise.all(e._befC.map(function(n){return n()}))}).then(function(){return e.method.close(e._state)})}},get type(){return this.method.type},get isClosed(){return this.closed}};function fs(t,e,r){var n=t.method.microSeconds(),i={time:n,type:e,data:r},s=t._prepP?t._prepP:le;return s.then(function(){var o=t.method.postMessage(t._state,i);return t._uMP.add(o),o.catch().then(function(){return t._uMP.delete(o)}),o})}function hf(t){var e=t.method.create(t.name,t.options);Wi(e)?(t._prepP=e,e.then(function(r){t._state=r})):t._state=e}function hs(t){return t._addEL.message.length>0||t._addEL.internal.length>0}function ls(t,e,r){t._addEL[e].push(r),pf(t)}function ds(t,e,r){t._addEL[e]=t._addEL[e].filter(function(n){return n!==r}),mf(t)}function pf(t){if(!t._iL&&hs(t)){var e=function(i){t._addEL[i.type].forEach(function(s){var o=1e5,a=s.time-o;i.time>=a&&s.fn(i.data)})},r=t.method.microSeconds();t._prepP?t._prepP.then(function(){t._iL=!0,t.method.onMessage(t._state,e,r)}):(t._iL=!0,t.method.onMessage(t._state,e,r))}}function mf(t){if(t._iL&&!hs(t)){t._iL=!1;var e=t.method.microSeconds();t.method.onMessage(t._state,null,e)}}var nr="nhostRefreshToken",Tt="nhostRefreshTokenExpiresAt";var qe={status:10,error:"invalid-email",message:"Email is incorrectly formatted"};var At={status:10,error:"invalid-password",message:"Password is incorrectly formatted"},ps={status:10,error:"invalid-phone-number",message:"Phone number is incorrectly formatted"},ms={status:10,error:"no-mfa-ticket",message:"No MFA ticket has been provided"};var To=Lt(bo());var ae=t=>{let e=To.default.create({baseURL:t});return e.interceptors.response.use(r=>r,r=>{var n,i,s,o,a,c,f,u,l,d;return Promise.reject({error:{message:(a=(o=(s=(i=(n=r.response)==null?void 0:n.data)==null?void 0:i.message)!=null?s:r.message)!=null?o:r.request.responseText)!=null?a:JSON.stringify(r),status:(l=(u=(c=r.response)==null?void 0:c.status)!=null?u:(f=r.response)==null?void 0:f.data.statusCode)!=null?l:0,error:((d=r.response)==null?void 0:d.data.error)||r.request.statusText||"network"}})}),e};var Ao=(t,e)=>{let r=e&&Object.entries(e).map(([n,i])=>{let s=Array.isArray(i)?i.join(","):typeof i=="object"?JSON.stringify(i):i;return`${n}=${encodeURIComponent(s)}`}).join("&");return r?`${t}?${r}`:t},ie=(t,e)=>{var r;return e!=null&&e.redirectTo?{...e,redirectTo:(r=e==null?void 0:e.redirectTo)!=null&&r.startsWith("/")?t+e.redirectTo:e==null?void 0:e.redirectTo}:e};var Qe=t=>!!t&&typeof t=="string"&&!!String(t).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),lr=t=>!!t&&typeof t=="string"&&t.length>=3,Ro=t=>!!t&&typeof t=="string";var mn={user:null,mfa:null,accessToken:{value:null,expiresAt:new Date},refreshTimer:{elapsed:0,attempts:0},refreshToken:{value:null},errors:{}};var Oo=({backendUrl:t,clientUrl:e,interpreter:r})=>{let n=ae(t);return oe({schema:{context:{},events:{}},tsTypes:{},preserveActionOrder:!0,id:"changeEmail",initial:"idle",context:{error:null},states:{idle:{on:{REQUEST:[{cond:"invalidEmail",actions:"saveInvalidEmailError",target:".error"},{target:"requesting"}]},initial:"initial",states:{initial:{},success:{},error:{}}},requesting:{invoke:{src:"requestChange",id:"requestChange",onDone:{target:"idle.success",actions:"reportSuccess"},onError:{actions:["saveRequestError","reportError"],target:"idle.error"}}}}},{actions:{saveInvalidEmailError:q({error:i=>qe}),saveRequestError:q({error:(i,{data:{error:s}})=>s}),reportError:$(i=>({type:"ERROR",error:i.error})),reportSuccess:$("SUCCESS")},guards:{invalidEmail:(i,{email:s})=>!Qe(s)},services:{requestChange:async(i,{email:s,options:o})=>(await n.post("/user/email/change",{newEmail:s,options:ie(e,o)},{headers:{authorization:`Bearer ${r==null?void 0:r.state.context.accessToken.value}`}})).data}})};var Co=({backendUrl:t,interpreter:e})=>{let r=ae(t);return oe({schema:{context:{},events:{}},tsTypes:{},preserveActionOrder:!0,id:"changePassword",initial:"idle",context:{error:null},states:{idle:{on:{REQUEST:[{cond:"invalidPassword",actions:"saveInvalidPasswordError",target:".error"},{target:"requesting"}]},initial:"initial",states:{initial:{},success:{},error:{}}},requesting:{invoke:{src:"requestChange",id:"requestChange",onDone:{target:"idle.success",actions:"reportSuccess"},onError:{actions:["saveRequestError","reportError"],target:"idle.error"}}}}},{actions:{saveInvalidPasswordError:q({error:n=>At}),saveRequestError:q({error:(n,{data:{error:i}})=>(console.log(i),i)}),reportError:$(n=>({type:"ERROR",error:n.error})),reportSuccess:$("SUCCESS")},guards:{invalidPassword:(n,{password:i})=>!lr(i)},services:{requestChange:(n,{password:i})=>r.post("/user/password",{newPassword:i},{headers:{authorization:`Bearer ${e==null?void 0:e.state.context.accessToken.value}`}})}})};var Po=({backendUrl:t,clientUrl:e})=>{let r=ae(t);return oe({schema:{context:{},events:{}},tsTypes:{},preserveActionOrder:!0,id:"changePassword",initial:"idle",context:{error:null},states:{idle:{on:{REQUEST:"requesting"},initial:"initial",states:{initial:{},success:{},error:{}}},requesting:{invoke:{src:"requestChange",id:"requestChange",onDone:{target:"idle.success",actions:"reportSuccess"},onError:{actions:["saveRequestError","reportError"],target:"idle.error"}}}}},{actions:{saveRequestError:q({error:(n,{data:{error:i}})=>(console.log(i),i)}),reportError:$(n=>({type:"ERROR",error:n.error})),reportSuccess:$("SUCCESS")},services:{requestChange:(n,{email:i,options:s})=>r.post("/user/password/reset",{email:i,options:ie(e,s)})}})};var No=({backendUrl:t,clientUrl:e,interpreter:r})=>{let n=ae(t);return oe({schema:{context:{},events:{}},tsTypes:{},preserveActionOrder:!0,id:"sendVerificationEmail",initial:"idle",context:{error:null},states:{idle:{on:{REQUEST:[{cond:"invalidEmail",actions:"saveInvalidEmailError",target:".error"},{target:"requesting"}]},initial:"initial",states:{initial:{},success:{},error:{}}},requesting:{invoke:{src:"request",id:"request",onDone:{target:"idle.success",actions:"reportSuccess"},onError:{actions:["saveRequestError","reportError"],target:"idle.error"}}}}},{actions:{saveInvalidEmailError:q({error:i=>qe}),saveRequestError:q({error:(i,{data:{error:s}})=>s}),reportError:$(i=>({type:"ERROR",error:i.error})),reportSuccess:$("SUCCESS")},guards:{invalidEmail:(i,{email:s})=>!Qe(s)},services:{request:async(i,{email:s,options:o})=>(await n.post("/user/email/send-verification-email",{email:s,options:ie(e,o)})).data}})};var Io=({backendUrl:t,clientUrl:e,clientStorageGetter:r,clientStorageSetter:n,refreshIntervalTime:i,autoRefreshToken:s=!0,autoSignIn:o=!0})=>{let a=ae(t),c=async(f,u,l)=>(await a.post(f,u,l)).data;return oe({schema:{context:{},events:{}},tsTypes:{},context:mn,preserveActionOrder:!0,id:"nhost",type:"parallel",states:{authentication:{initial:"checkAutoSignIn",on:{SESSION_UPDATE:[{cond:"hasSession",actions:["saveSession","persist","resetTimer","reportTokenChanged"],target:".signedIn"}]},states:{checkAutoSignIn:{always:[{cond:"isAutoSignInDisabled",target:"importingRefreshToken"}],invoke:{id:"autoSignIn",src:"autoSignIn",onDone:{target:"signedIn",actions:["saveSession","persist","reportTokenChanged"]},onError:"importingRefreshToken"}},importingRefreshToken:{invoke:{id:"importRefreshToken",src:"importRefreshToken",onDone:{actions:"saveRefreshToken",target:"starting"}}},starting:{always:[{cond:"isSignedIn",target:"signedIn"},{cond:"hasRefreshTokenWithoutSession",target:["authenticating.token","#nhost.token.running"]},"signedOut"]},signedOut:{tags:["ready"],initial:"noErrors",entry:"reportSignedOut",states:{noErrors:{},success:{},needsEmailVerification:{},needsSmsOtp:{},needsMfa:{},failed:{exit:"resetAuthenticationError",initial:"server",states:{server:{},validation:{states:{password:{},email:{},phoneNumber:{}}}}},signingOut:{entry:"destroyToken",exit:"clearContext",invoke:{src:"signout",id:"signingOut",onDone:{target:"success"},onError:{target:"failed.server"}}}},on:{SIGNIN_PASSWORD:[{cond:"invalidEmail",actions:["saveInvalidEmail"],target:".failed.validation.email"},{cond:"invalidPassword",actions:["saveInvalidPassword"],target:".failed.validation.password"},"#nhost.authentication.authenticating.password"],SIGNIN_PASSWORDLESS_EMAIL:[{cond:"invalidEmail",actions:"saveInvalidEmail",target:".failed.validation.email"},"#nhost.authentication.authenticating.passwordlessEmail"],SIGNIN_PASSWORDLESS_SMS:[{cond:"invalidPhoneNumber",actions:"saveInvalidPhoneNumber",target:".failed.validation.phoneNumber"},"#nhost.authentication.authenticating.passwordlessSms"],SIGNIN_PASSWORDLESS_SMS_OTP:[{cond:"invalidPhoneNumber",actions:"saveInvalidPhoneNumber",target:".failed.validation.phoneNumber"},"#nhost.authentication.authenticating.passwordlessSmsOtp"],SIGNUP_EMAIL_PASSWORD:[{cond:"invalidEmail",actions:"saveInvalidSignUpEmail",target:".failed.validation.email"},{cond:"invalidPassword",actions:"saveInvalidSignUpPassword",target:".failed.validation.password"},"#nhost.authentication.registering"],SIGNIN_ANONYMOUS:"#nhost.authentication.authenticating.anonymous",SIGNIN_MFA_TOTP:[{cond:"noMfaTicket",actions:["saveNoMfaTicketError"],target:".failed"},"#nhost.authentication.authenticating.mfa.totp"]}},authenticating:{states:{passwordlessEmail:{invoke:{src:"signInPasswordlessEmail",id:"authenticatePasswordlessEmail",onDone:"#nhost.authentication.signedOut.needsEmailVerification",onError:{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed.server"}}},passwordlessSms:{invoke:{src:"signInPasswordlessSms",id:"authenticatePasswordlessSms",onDone:"#nhost.authentication.signedOut.needsSmsOtp",onError:{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed.server"}}},passwordlessSmsOtp:{invoke:{src:"signInPasswordlessSmsOtp",id:"authenticatePasswordlessSmsOtp",onDone:{actions:["saveSession","persist","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed.server"}}},password:{invoke:{src:"signInPassword",id:"authenticateUserWithPassword",onDone:[{cond:"hasMfaTicket",actions:["saveMfaTicket"],target:"#nhost.authentication.signedOut.needsMfa"},{actions:["saveSession","persist","reportTokenChanged"],target:"#nhost.authentication.signedIn"}],onError:[{cond:"unverified",target:"#nhost.authentication.signedOut.needsEmailVerification"},{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed.server"}]}},token:{},anonymous:{invoke:{src:"signInAnonymous",id:"authenticateAnonymously",onDone:{actions:["saveSession","persist","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed.server"}}},mfa:{states:{totp:{invoke:{src:"signInMfaTotp",id:"signInMfaTotp",onDone:{actions:["saveSession","persist","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:{actions:["saveAuthenticationError"],target:"#nhost.authentication.signedOut.failed.server"}}}}}}},registering:{entry:"resetSignUpError",invoke:{src:"registerUser",id:"registerUser",onDone:[{cond:"hasSession",target:"#nhost.authentication.signedIn",actions:["saveSession","persist","reportTokenChanged"]},{target:"#nhost.authentication.signedOut.needsEmailVerification"}],onError:[{cond:"unverified",target:"#nhost.authentication.signedOut.needsEmailVerification"},{actions:"saveRegisrationError",target:"#nhost.authentication.signedOut.failed.server"}]}},signedIn:{tags:["ready"],type:"parallel",entry:"reportSignedIn",on:{SIGNOUT:"#nhost.authentication.signedOut.signingOut",DEANONYMIZE:{target:".deanonymizing"}},states:{refreshTimer:{id:"timer",initial:"idle",states:{disabled:{type:"final"},stopped:{always:{cond:"noToken",target:"idle"}},idle:{always:[{cond:"isAutoRefreshDisabled",target:"disabled"},{cond:"hasRefreshToken",target:"running"}]},running:{initial:"pending",entry:"resetTimer",states:{pending:{after:{"1000":{actions:"tickRefreshTimer",internal:!1,target:"pending"}},always:{cond:"refreshTimerShouldRefresh",target:"refreshing"}},refreshing:{invoke:{src:"refreshToken",id:"refreshToken",onDone:{actions:["saveSession","persist","resetTimer"],target:"pending"},onError:[]}}}}}},deanonymizing:{initial:"error",states:{error:{},success:{}}}}}}},token:{initial:"idle",states:{idle:{on:{TRY_TOKEN:"running"},initial:"noErrors",states:{noErrors:{},error:{}}},running:{invoke:{src:"refreshToken",id:"authenticateWithToken",onDone:{actions:["saveSession","persist","reportTokenChanged"],target:["#nhost.authentication.signedIn","idle.noErrors"]},onError:[{cond:"isSignedIn",target:"idle.error"},{target:["#nhost.authentication.signedOut","idle.error"]}]}}}}}},{actions:{reportSignedIn:$("SIGNED_IN"),reportSignedOut:$("SIGNED_OUT"),reportTokenChanged:$("TOKEN_CHANGED"),clearContext:q(()=>mn),saveSession:q({user:(f,u)=>{var l,d;return(d=(l=u.data)==null?void 0:l.session)==null?void 0:d.user},accessToken:(f,u)=>{var l,d,h,g;return{value:(d=(l=u.data)==null?void 0:l.session)==null?void 0:d.accessToken,expiresAt:new Date(Date.now()+((g=(h=u.data)==null?void 0:h.session)==null?void 0:g.accessTokenExpiresIn)*1e3)}},refreshToken:(f,u)=>{var l,d;return{value:(d=(l=u.data)==null?void 0:l.session)==null?void 0:d.refreshToken}}}),saveMfaTicket:q({mfa:(f,u)=>{var l,d;return(d=(l=u.data)==null?void 0:l.mfa)!=null?d:null}}),resetTimer:q({refreshTimer:(f,u)=>({elapsed:0,attempts:0})}),tickRefreshTimer:q({refreshTimer:(f,u)=>({elapsed:f.refreshTimer.elapsed+1,attempts:f.refreshTimer.attempts})}),saveAuthenticationError:q({errors:({errors:f},{data:{error:u}})=>({...f,authentication:u})}),resetAuthenticationError:q({errors:({errors:{authentication:f,...u}})=>u}),saveInvalidEmail:q({errors:({errors:f})=>({...f,authentication:qe})}),saveInvalidPassword:q({errors:({errors:f})=>({...f,authentication:At})}),saveInvalidPhoneNumber:q({errors:({errors:f})=>({...f,authentication:ps})}),saveRegisrationError:q({errors:({errors:f},{data:{error:u}})=>({...f,registration:u})}),resetSignUpError:q({errors:({errors:{registration:f,...u}})=>u}),saveInvalidSignUpPassword:q({errors:({errors:f})=>({...f,registration:qe})}),saveInvalidSignUpEmail:q({errors:({errors:f})=>({...f,registration:At})}),saveNoMfaTicketError:q({errors:({errors:f})=>({...f,registration:ms})}),saveRefreshToken:q({accessToken:(f,u)=>({...f.accessToken,expiresAt:u.data.expiresAt}),refreshToken:(f,u)=>({...f.refreshToken,value:u.data.refreshToken})}),persist:(f,{data:u})=>{if(n(nr,u.session.refreshToken),u.session.accessTokenExpiresIn){let l=new Date(Date.now()+u.session.accessTokenExpiresIn*1e3).toISOString();n(Tt,l)}else n(Tt,null)},destroyToken:()=>{n(nr,null),n(Tt,null)}},guards:{isSignedIn:f=>!!f.user&&!!f.refreshToken.value&&!!f.accessToken.value,hasRefreshTokenWithoutSession:f=>!!f.refreshToken.value&&!f.user&&!f.accessToken.value,noToken:f=>!f.refreshToken.value,noMfaTicket:(f,{ticket:u})=>{var l;return!u&&!((l=f.mfa)!=null&&l.ticket)},hasRefreshToken:f=>!!f.refreshToken.value,isAutoRefreshDisabled:()=>!s,isAutoSignInDisabled:()=>!o,refreshTimerShouldRefresh:f=>f.refreshTimer.elapsed>Math.max((Date.now()-f.accessToken.expiresAt.getTime())/1e3-900,i),unverified:(f,{data:{error:u}})=>u.status===401&&u.message==="Email is not verified",hasSession:(f,u)=>{var l;return!!((l=u.data)!=null&&l.session)},hasMfaTicket:(f,u)=>{var l;return!!((l=u.data)!=null&&l.mfa)},invalidEmail:(f,{email:u})=>!Qe(u),invalidPassword:(f,{password:u})=>!lr(u),invalidPhoneNumber:(f,{phoneNumber:u})=>!Ro(u)},services:{signInPassword:(f,{email:u,password:l})=>c("/signin/email-password",{email:u,password:l}),signInPasswordlessSms:(f,{phoneNumber:u,options:l})=>c("/signin/passwordless/sms",{phoneNumber:u,options:ie(e,l)}),signInPasswordlessSmsOtp:(f,{phoneNumber:u,otp:l})=>c("/signin/passwordless/sms/otp",{phoneNumber:u,otp:l}),signInPasswordlessEmail:(f,{email:u,options:l})=>c("/signin/passwordless/email",{email:u,options:ie(e,l)}),signInAnonymous:f=>c("/signin/anonymous"),signInMfaTotp:(f,{ticket:u,otp:l})=>{var d;return c("/signin/mfa/totp",{ticket:u||((d=f.mfa)==null?void 0:d.ticket),otp:l})},refreshToken:async(f,u)=>{let l=u.type==="TRY_TOKEN"?u.token:f.refreshToken.value;return{session:await c("/token",{refreshToken:l})}},signout:(f,u)=>c("/signout",{refreshToken:f.refreshToken.value,all:!!u.all}),registerUser:(f,{email:u,password:l,options:d})=>c("/signup/email-password",{email:u,password:l,options:ie(e,d)}),autoSignIn:async()=>{if(typeof window!="undefined"){let f=window.location;if(f.hash){let l=new URLSearchParams(f.hash.slice(1)).get("refreshToken");if(l){let d=await c("/token",{refreshToken:l});return new ke("nhost").postMessage(l),{session:d}}}}throw Error()},importRefreshToken:async()=>{let f=await r(Tt),u=f?new Date(f):null;return{refreshToken:await r(nr),expiresAt:u}}}})};function dr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}var dl={read:function(t){return t[0]==='"'&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function vn(t,e){function r(i,s,o){if(typeof document!="undefined"){o=dr({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),i=encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var c in o)!o[c]||(a+="; "+c,o[c]!==!0&&(a+="="+o[c].split(";")[0]));return document.cookie=i+"="+t.write(s,i)+a}}function n(i){if(!(typeof document=="undefined"||arguments.length&&!i)){for(var s=document.cookie?document.cookie.split("; "):[],o={},a=0;a<s.length;a++){var c=s[a].split("="),f=c.slice(1).join("=");try{var u=decodeURIComponent(c[0]);if(o[u]=t.read(f,u),i===u)break}catch{}}return i?o[i]:o}}return Object.create({set:r,get:n,remove:function(i,s){r(i,"",dr({},s,{expires:-1}))},withAttributes:function(i){return vn(this.converter,dr({},this.attributes,i))},withConverter:function(i){return vn(dr({},this.converter,i),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var Lv=vn(dl,{path:"/"});var _o=typeof window!="undefined",hr=new Map,pr=t=>{var e;return _o&&localStorage?localStorage.getItem(t):(e=hr.get(t))!=null?e:null},mr=(t,e)=>{_o&&localStorage?e?localStorage.setItem(t,e):localStorage.removeItem(t):e?hr.set(t,e):hr.has(t)&&hr.delete(t)};var Pt,Nt,It,_t=class{constructor({backendUrl:e,clientUrl:r=typeof window!="undefined"?window.location.origin:"",clientStorageGetter:n=pr,clientStorageSetter:i=mr,refreshIntervalTime:s=60,autoSignIn:o=!0,autoRefreshToken:a=!0,start:c=!0}){Le(this,Pt,void 0);Le(this,Nt,void 0);Le(this,It,new Set);this.backendUrl=e,this.clientUrl=r,this.machine=Io({backendUrl:e,clientUrl:r,refreshIntervalTime:s,clientStorageGetter:n,clientStorageSetter:i,autoSignIn:o,autoRefreshToken:a}),c&&(this.interpreter=me(this.machine),this.interpreter.start()),typeof window!="undefined"&&o&&(st(this,Nt,new ke("nhost")),_(this,Nt).addEventListener("message",f=>{var l;let u=(l=this.interpreter)==null?void 0:l.state.context.refreshToken;this.interpreter&&f!==u&&this.interpreter.send({type:"TRY_TOKEN",token:f})}))}get interpreter(){return _(this,Pt)}set interpreter(e){st(this,Pt,e),e&&_(this,It).forEach(r=>r(this))}onStart(e){_(this,It).add(e)}};Pt=new WeakMap,Nt=new WeakMap,It=new WeakMap;var ko=()=>typeof window!="undefined",xe=t=>!t||!t.accessToken.value||!t.refreshToken.value?null:{accessToken:t.accessToken.value,accessTokenExpiresIn:(t.accessToken.expiresAt.getTime()-Date.now())/1e3,refreshToken:t.refreshToken.value,user:t.user},Ze=(t,e)=>{e.forEach(r=>{typeof t[r]!="function"&&console.error(`clientStorage.${r} is not a function`)})},qo=(t,e)=>{if(e){if(t==="react-native"||t==="custom")return Ze(e,["getItem"]),r=>{var n;return(n=e.getItem)==null?void 0:n.call(e,r)};if(t==="capacitor")return Ze(e,["get"]),r=>{var n;return(n=e.get)==null?void 0:n.call(e,{key:r})};if(t==="expo-secure-storage")return Ze(e,["getItemAsync"]),r=>{var n;return(n=e.getItemAsync)==null?void 0:n.call(e,r)}}return pr},Do=(t,e)=>{if(e){if(t==="react-native"||t==="custom")return Ze(e,["setItem","removeItem"]),(r,n)=>{var i,s;n?(i=e.setItem)==null||i.call(e,r,n):(s=e.removeItem)==null||s.call(e,r)};if(t==="capacitor")return Ze(e,["set","remove"]),(r,n)=>{var i,s;n?(i=e.set)==null||i.call(e,{key:r,value:n}):(s=e.remove)==null||s.call(e,{key:r})};if(t==="expo-secure-storage")return Ze(e,["setItemAsync","deleteItemAsync"]),async(r,n)=>{var i,s;n?await((i=e.setItemAsync)==null?void 0:i.call(e,r,n)):(s=e.deleteItemAsync)==null||s.call(e,r)}}return mr};var Uo={message:"User is already signed in",status:100},pl={message:"User is not authenticated",status:101},ml={message:"User is not anonymous",status:101},vl={message:"Email needs verification",status:102},M,yn=class{constructor({url:e,autoRefreshToken:r=!0,autoLogin:n=!0,clientStorage:i,clientStorageType:s="web",clientStorageGetter:o,clientStorageSetter:a,refreshIntervalTime:c,start:f=!0,Client:u=_t}){Le(this,M,void 0);this.onTokenChangedSubscriptions=new Set;this.onAuthStateChangedSubscriptions=new Set;st(this,M,new u({backendUrl:e,autoRefreshToken:r,autoSignIn:n,start:f,clientStorageGetter:o||qo(s,i),clientStorageSetter:a||Do(s,i),refreshIntervalTime:c}))}async signUp(e){let r=_(this,M).interpreter;if(!r)throw Error("Auth interpreter not set");let{email:n,password:i,options:s}=e;return this.isAuthenticated()?{session:null,error:Uo}:new Promise(o=>{r.send({type:"SIGNUP_EMAIL_PASSWORD",email:n,password:i,options:s}),r.onTransition(a=>{if(a.matches({authentication:{signedOut:"needsEmailVerification"}}))return o({session:null,error:null});if(a.matches({authentication:{signedOut:"failed"}}))return o({session:null,error:a.context.errors.registration||null});if(a.matches({authentication:"signedIn"}))return o({session:xe(a.context),error:null})})})}async signIn(e){let r=_(this,M).interpreter;if(!r)throw Error("Auth interpreter not set");if(this.isAuthenticated())return{session:null,mfa:null,error:Uo};if("provider"in e){let{provider:n,options:i}=e,s=Ao(`${_(this,M).backendUrl}/v1/auth/signin/provider/${n}`,ie(_(this,M).clientUrl,i));return ko()&&(window.location.href=s),{providerUrl:s,provider:n,session:null,mfa:null,error:null}}return"email"in e&&"password"in e?new Promise(n=>{r.send({type:"SIGNIN_PASSWORD",...e}),r.onTransition(i=>{i.matches({authentication:"signedIn"})?n({session:xe(i.context),mfa:null,error:null}):i.matches({authentication:{signedOut:"needsEmailVerification"}})?n({session:null,mfa:null,error:vl}):i.matches({authentication:{signedOut:"needsMfa"}})?n({session:null,mfa:i.context.mfa,error:null}):i.matches({authentication:{signedOut:"failed"}})&&n({session:null,mfa:null,error:i.context.errors.authentication||null})})}):"email"in e&&!("otp"in e)?new Promise(n=>{r.onTransition(i=>{i.matches({authentication:{signedOut:"needsEmailVerification"}})?n({session:null,mfa:null,error:null}):i.matches({authentication:{signedOut:"failed"}})&&n({session:null,mfa:null,error:i.context.errors.authentication||null})}),r.send({type:"SIGNIN_PASSWORDLESS_EMAIL",...e})}):"phoneNumber"in e&&!("otp"in e)?new Promise(n=>{r.onTransition(i=>{i.matches({authentication:{signedOut:"needsSmsOtp"}})?n({session:null,mfa:null,error:null}):i.matches({authentication:{signedOut:"failed"}})&&n({session:null,mfa:null,error:i.context.errors.authentication||null})}),r.send({type:"SIGNIN_PASSWORDLESS_SMS",...e})}):"otp"in e?new Promise(n=>{r.onTransition(i=>{i.matches({authentication:"signedIn"})?n({session:xe(i.context),mfa:null,error:null}):i.matches({authentication:{signedOut:"failed"}})&&n({session:null,mfa:null,error:i.context.errors.authentication||null})}),r.send({type:"SIGNIN_PASSWORDLESS_SMS_OTP",...e})}):{session:null,mfa:null,error:{message:"Incorrect parameters",status:500}}}async signOut(e){let r=_(this,M).interpreter;if(!r)throw Error("Auth interpreter not set");return this.isAuthenticated()?new Promise(n=>{r.send({type:"SIGNOUT",all:e==null?void 0:e.all}),r.onTransition(i=>{i.matches({authentication:{signedOut:"success"}})?n({error:null}):i.matches({authentication:{signedOut:"failed"}})&&n({error:i.context.errors.signout||null})})}):{error:pl}}async resetPassword({email:e,options:r}){return new Promise(n=>{let i=me(Po(_(this,M)));i.onTransition(({event:s})=>{if(s.type==="ERROR")return n({error:s.error});if(s.type==="SUCCESS")return n({error:null})}),i.start(),i.send({type:"REQUEST",email:e,options:r})})}async changePassword(e){return new Promise(r=>{let n=me(Co(_(this,M)));n.onTransition(({event:i})=>{if(i.type==="ERROR")return r({error:i.error});if(i.type==="SUCCESS")return r({error:null})}),n.start(),n.send({type:"REQUEST",password:e.newPassword})})}async sendVerificationEmail(e){return new Promise(r=>{let n=me(No(_(this,M)));n.onTransition(({event:i})=>{if(i.type==="ERROR")return r({error:i.error});if(i.type==="SUCCESS")return r({error:null})}),n.start(),n.send({type:"REQUEST",email:e.email,options:e.options})})}async changeEmail({newEmail:e,options:r}){return new Promise(n=>{let i=me(Oo(_(this,M)));i.onTransition(({event:s})=>{if(s.type==="ERROR")return n({error:s.error});if(s.type==="SUCCESS")return n({error:null})}),i.start(),i.send({type:"REQUEST",email:e,options:r})})}async deanonymize(e){return new Promise(r=>{var a;let n=_(this,M).interpreter;if(!n)throw Error("Auth interpreter not set");if(!this.isAuthenticated()||!((a=n.state.context.user)!=null&&a.isAnonymous))return{error:ml};n.onTransition(c=>{c.matches({authentication:{signedIn:{deanonymizing:"success"}}})?r({error:null}):c.matches({authentication:{signedIn:{deanonymizing:"error"}}})&&r({error:c.context.errors.authentication||null})}),n.start();let{signInMethod:i,connection:s,...o}=e;n.send({type:"DEANONYMIZE",signInMethod:i,connection:s,options:o})})}onTokenChanged(e){var r;return _(this,M).interpreter?this.onTokenChangedSubscriptions.add((r=_(this,M).interpreter)==null?void 0:r.onTransition(({event:n,context:i})=>{n.type==="TOKEN_CHANGED"&&e(xe(i))})):console.log("onTokenChanged: no interpreter is set yet",e),()=>{this.onTokenChangedSubscriptions.forEach(n=>n.stop())}}onAuthStateChanged(e){var r;return _(this,M).interpreter?this.onAuthStateChangedSubscriptions.add((r=_(this,M).interpreter)==null?void 0:r.onTransition(({event:n,context:i})=>{n.type==="SIGNED_IN"?e("SIGNED_IN",xe(i)):n.type==="SIGNED_OUT"&&e("SIGNED_OUT",xe(i))})):console.log("onAuthStateChanged: no interpreter is set yet",e),()=>{this.onAuthStateChangedSubscriptions.forEach(n=>n.stop())}}isAuthenticated(){var e;return!!((e=_(this,M).interpreter)!=null&&e.state.matches({authentication:"signedIn"}))}async isAuthenticatedAsync(){return new Promise(e=>{this.isReady()&&e(this.isAuthenticated());let r=_(this,M).interpreter;r||e(!1),r==null||r.onTransition(n=>{n.hasTag("ready")&&e(n.matches({authentication:"signedIn"}))})})}getAuthenticationStatus(){return this.isReady()?{isAuthenticated:this.isAuthenticated(),isLoading:!1}:{isAuthenticated:!1,isLoading:!0}}getJWTToken(){return this.getAccessToken()}getAccessToken(){var e,r;return(r=(e=_(this,M).interpreter)==null?void 0:e.state.context.accessToken.value)!=null?r:void 0}async refreshSession(e){return new Promise(r=>{let n=_(this,M).interpreter;if(!n||!n.state.matches({token:"idle"}))return r();let i=e||n.state.context.refreshToken.value;if(!i)return r();n==null||n.onTransition(s=>{(s.matches({token:{idle:"error"}})||s.event.type==="TOKEN_CHANGED")&&r()}),n.send({type:"TRY_TOKEN",token:i})})}getSession(){var e;return xe((e=_(this,M).interpreter)==null?void 0:e.state.context)}getUser(){var e,r;return((r=(e=_(this,M).interpreter)==null?void 0:e.state.context)==null?void 0:r.user)||null}isReady(){var e;return!!((e=_(this,M).interpreter)!=null&&e.state.hasTag("ready"))}get client(){return _(this,M)}};M=new WeakMap;var Ja=Lt(Ga()),Mn=class{constructor({url:e}){this.url=e,this.httpClient=Ja.default.create({baseURL:this.url})}async upload(e){try{return{fileMetadata:(await this.httpClient.post("/files",e.file,{headers:{...this.generateUploadHeaders(e),...this.generateAuthHeaders()}})).data,error:null}}catch(r){return{fileMetadata:null,error:r}}}async getPresignedUrl(e){try{let{fileId:r}=e;return{presignedUrl:(await this.httpClient.get(`/files/${r}/presignedurl`,{headers:{...this.generateAuthHeaders()}})).data,error:null}}catch(r){return{presignedUrl:null,error:r}}}async delete(e){try{let{fileId:r}=e;return await this.httpClient.delete(`/files/${r}`,{headers:{...this.generateAuthHeaders()}}),{error:null}}catch(r){return{error:r}}}setAccessToken(e){return this.accessToken=e,this}setAdminSecret(e){return this.adminSecret=e,this}generateUploadHeaders(e){let{bucketId:r,name:n,id:i}=e,s={};return r&&(s["x-nhost-bucket-id"]=r),i&&(s["x-nhost-file-id"]=i),n&&(s["x-nhost-file-name"]=n),s}generateAuthHeaders(){return!this.adminSecret&&!this.accessToken?null:this.adminSecret?{"x-hasura-admin-secret":this.adminSecret}:{Authorization:`Bearer ${this.accessToken}`}}};var Ln=class{constructor({url:e}){this.url=e,this.api=new Mn({url:e})}async upload(e){let r=new FormData;r.append("file",e.file);let{fileMetadata:n,error:i}=await this.api.upload({...e,file:r});return i?{fileMetadata:null,error:i}:n?{fileMetadata:n,error:null}:{fileMetadata:null,error:new Error("Invalid file returned")}}getUrl(e){return this.getPublicUrl(e)}getPublicUrl(e){let{fileId:r}=e;return`${this.url}/files/${r}`}async getPresignedUrl(e){let{presignedUrl:r,error:n}=await this.api.getPresignedUrl(e);return n?{presignedUrl:null,error:n}:r?{presignedUrl:r,error:null}:{presignedUrl:null,error:new Error("Invalid file id")}}async delete(e){let{error:r}=await this.api.delete(e);return r?{error:r}:{error:null}}setAccessToken(e){return this.api.setAccessToken(e),this}setAdminSecret(e){return this.api.setAdminSecret(e),this}};var Yu=Lt(ii()),si=class{constructor(e){let{url:r}=e;this.accessToken=null,this.instance=Yu.default.create({baseURL:r})}async call(e,r,n){let i={...this.generateAccessTokenHeaders(),...n==null?void 0:n.headers},s;try{s=await this.instance.post(e,r,{...n,headers:i})}catch(o){if(o instanceof Error)return{res:null,error:o}}return s?{res:s,error:null}:{res:null,error:new Error("Unable to make post request to funtion")}}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}};var Qu=Lt(ii()),oi=class{constructor(e){let{url:r}=e;this.url=r,this.accessToken=null,this.instance=Qu.default.create({baseURL:r})}async request(e,r,n){let i={...n==null?void 0:n.headers,...this.generateAccessTokenHeaders()},s="",o;try{o=(await this.instance.post("",{operationName:s||void 0,query:e,variables:r},{...n,headers:i})).data}catch(a){return a instanceof Error?{data:null,error:a}:(console.error(a),{data:null,error:new Error("Unable to get do GraphQL request")})}return typeof o!="object"||Array.isArray(o)||o===null?{data:null,error:new Error("incorrect response data from GraphQL server")}:(o=o,o.errors?{data:null,error:o.errors}:{data:o.data,error:null})}getUrl(){return this.url}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}};var ai=class{constructor({backendUrl:e,refreshIntervalTime:r,clientStorageGetter:n,clientStorageSetter:i,clientStorage:s,clientStorageType:o,autoRefreshToken:a,autoLogin:c,start:f=!0,Client:u}){if(!e)throw new Error("Please specify a `backendUrl`. Docs: [todo]!");this.auth=new yn({url:`${e}/v1/auth`,refreshIntervalTime:r,clientStorageGetter:n,clientStorageSetter:i,clientStorage:s,clientStorageType:o,autoRefreshToken:a,autoLogin:c,start:f,Client:u}),this.storage=new Ln({url:`${e}/v1/storage`}),this.functions=new si({url:`${e}/v1/functions`}),this.graphql=new oi({url:`${e}/v1/graphql`}),this.storage.setAccessToken(this.auth.getAccessToken()),this.functions.setAccessToken(this.auth.getAccessToken()),this.graphql.setAccessToken(this.auth.getAccessToken()),this.auth.client.onStart(()=>{this.auth.onAuthStateChanged((l,d)=>{this.storage.setAccessToken(d==null?void 0:d.accessToken),this.functions.setAccessToken(d==null?void 0:d.accessToken),this.graphql.setAccessToken(d==null?void 0:d.accessToken)}),this.auth.onTokenChanged(l=>{this.storage.setAccessToken(l==null?void 0:l.accessToken),this.functions.setAccessToken(l==null?void 0:l.accessToken),this.graphql.setAccessToken(l==null?void 0:l.accessToken)})})}};var Zg=t=>new ai(t);export{ai as NhostClient,Zg as createClient};
1
+ var tc=Object.create;var _r=Object.defineProperty;var rc=Object.getOwnPropertyDescriptor;var nc=Object.getOwnPropertyNames;var ic=Object.getPrototypeOf,sc=Object.prototype.hasOwnProperty;var oc=t=>_r(t,"__esModule",{value:!0});var m=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ac=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of nc(e))!sc.call(t,i)&&(r||i!=="default")&&_r(t,i,{get:()=>e[i],enumerable:!(n=rc(e,i))||n.enumerable});return t},Lt=(t,e)=>ac(oc(_r(t!=null?tc(ic(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var ui=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var M=(t,e,r)=>(ui(t,e,"read from private field"),r?r.call(t):e.get(t)),Le=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},st=(t,e,r,n)=>(ui(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r);var Kr=m((dm,vs)=>{"use strict";vs.exports=function(e,r){return function(){for(var i=new Array(arguments.length),s=0;s<i.length;s++)i[s]=arguments[s];return e.apply(r,i)}}});var K=m((hm,Ss)=>{"use strict";var vf=Kr(),we=Object.prototype.toString;function Qr(t){return Array.isArray(t)}function Xr(t){return typeof t=="undefined"}function yf(t){return t!==null&&!Xr(t)&&t.constructor!==null&&!Xr(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function ys(t){return we.call(t)==="[object ArrayBuffer]"}function gf(t){return we.call(t)==="[object FormData]"}function Ef(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&ys(t.buffer),e}function Sf(t){return typeof t=="string"}function wf(t){return typeof t=="number"}function gs(t){return t!==null&&typeof t=="object"}function ir(t){if(we.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function xf(t){return we.call(t)==="[object Date]"}function Tf(t){return we.call(t)==="[object File]"}function bf(t){return we.call(t)==="[object Blob]"}function Es(t){return we.call(t)==="[object Function]"}function Rf(t){return gs(t)&&Es(t.pipe)}function Af(t){return we.call(t)==="[object URLSearchParams]"}function Of(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Cf(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function Zr(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),Qr(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}function Yr(){var t={};function e(i,s){ir(t[s])&&ir(i)?t[s]=Yr(t[s],i):ir(i)?t[s]=Yr({},i):Qr(i)?t[s]=i.slice():t[s]=i}for(var r=0,n=arguments.length;r<n;r++)Zr(arguments[r],e);return t}function Pf(t,e,r){return Zr(e,function(i,s){r&&typeof i=="function"?t[s]=vf(i,r):t[s]=i}),t}function Nf(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}Ss.exports={isArray:Qr,isArrayBuffer:ys,isBuffer:yf,isFormData:gf,isArrayBufferView:Ef,isString:Sf,isNumber:wf,isObject:gs,isPlainObject:ir,isUndefined:Xr,isDate:xf,isFile:Tf,isBlob:bf,isFunction:Es,isStream:Rf,isURLSearchParams:Af,isStandardBrowserEnv:Cf,forEach:Zr,merge:Yr,extend:Pf,trim:Of,stripBOM:Nf}});var en=m((pm,xs)=>{"use strict";var Ke=K();function ws(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}xs.exports=function(e,r,n){if(!r)return e;var i;if(n)i=n(r);else if(Ke.isURLSearchParams(r))i=r.toString();else{var s=[];Ke.forEach(r,function(c,f){c===null||typeof c=="undefined"||(Ke.isArray(c)?f=f+"[]":c=[c],Ke.forEach(c,function(d){Ke.isDate(d)?d=d.toISOString():Ke.isObject(d)&&(d=JSON.stringify(d)),s.push(ws(f)+"="+ws(d))}))}),i=s.join("&")}if(i){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}});var bs=m((mm,Ts)=>{"use strict";var If=K();function sr(){this.handlers=[]}sr.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};sr.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};sr.prototype.forEach=function(e){If.forEach(this.handlers,function(n){n!==null&&e(n)})};Ts.exports=sr});var As=m((vm,Rs)=>{"use strict";var _f=K();Rs.exports=function(e,r){_f.forEach(e,function(i,s){s!==r&&s.toUpperCase()===r.toUpperCase()&&(e[r]=i,delete e[s])})}});var tn=m((ym,Os)=>{"use strict";Os.exports=function(e,r,n,i,s){return e.config=r,n&&(e.code=n),e.request=i,e.response=s,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}});var rn=m((gm,Cs)=>{"use strict";var kf=tn();Cs.exports=function(e,r,n,i,s){var o=new Error(e);return kf(o,r,n,i,s)}});var Ns=m((Em,Ps)=>{"use strict";var qf=rn();Ps.exports=function(e,r,n){var i=n.config.validateStatus;!n.status||!i||i(n.status)?e(n):r(qf("Request failed with status code "+n.status,n.config,null,n.request,n))}});var _s=m((Sm,Is)=>{"use strict";var or=K();Is.exports=or.isStandardBrowserEnv()?function(){return{write:function(r,n,i,s,o,a){var c=[];c.push(r+"="+encodeURIComponent(n)),or.isNumber(i)&&c.push("expires="+new Date(i).toGMTString()),or.isString(s)&&c.push("path="+s),or.isString(o)&&c.push("domain="+o),a===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(r){var n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var qs=m((wm,ks)=>{"use strict";ks.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}});var Us=m((xm,Ds)=>{"use strict";Ds.exports=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e}});var Ls=m((Tm,Ms)=>{"use strict";var Df=qs(),Uf=Us();Ms.exports=function(e,r){return e&&!Df(r)?Uf(e,r):r}});var Bs=m((bm,js)=>{"use strict";var nn=K(),Mf=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];js.exports=function(e){var r={},n,i,s;return e&&nn.forEach(e.split(`
2
+ `),function(a){if(s=a.indexOf(":"),n=nn.trim(a.substr(0,s)).toLowerCase(),i=nn.trim(a.substr(s+1)),n){if(r[n]&&Mf.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([i]):r[n]=r[n]?r[n]+", "+i:i}}),r}});var Hs=m((Rm,Vs)=>{"use strict";var Fs=K();Vs.exports=Fs.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function i(s){var o=s;return e&&(r.setAttribute("href",o),o=r.href),r.setAttribute("href",o),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=i(window.location.href),function(o){var a=Fs.isString(o)?i(o):o;return a.protocol===n.protocol&&a.host===n.host}}():function(){return function(){return!0}}()});var At=m((Am,Gs)=>{"use strict";function sn(t){this.message=t}sn.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};sn.prototype.__CANCEL__=!0;Gs.exports=sn});var an=m((Om,Js)=>{"use strict";var ar=K(),Lf=Ns(),jf=_s(),Bf=en(),Ff=Ls(),Vf=Bs(),Hf=Hs(),on=rn(),Gf=Ot(),Jf=At();Js.exports=function(e){return new Promise(function(n,i){var s=e.data,o=e.headers,a=e.responseType,c;function f(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}ar.isFormData(s)&&delete o["Content-Type"];var u=new XMLHttpRequest;if(e.auth){var d=e.auth.username||"",l=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(d+":"+l)}var h=Ff(e.baseURL,e.url);u.open(e.method.toUpperCase(),Bf(h,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function g(){if(!!u){var p="getAllResponseHeaders"in u?Vf(u.getAllResponseHeaders()):null,w=!a||a==="text"||a==="json"?u.responseText:u.response,y={data:w,status:u.status,statusText:u.statusText,headers:p,config:e,request:u};Lf(function(C){n(C),f()},function(C){i(C),f()},y),u=null}}if("onloadend"in u?u.onloadend=g:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(g)},u.onabort=function(){!u||(i(on("Request aborted",e,"ECONNABORTED",u)),u=null)},u.onerror=function(){i(on("Network Error",e,null,u)),u=null},u.ontimeout=function(){var w=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",y=e.transitional||Gf.transitional;e.timeoutErrorMessage&&(w=e.timeoutErrorMessage),i(on(w,e,y.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},ar.isStandardBrowserEnv()){var E=(e.withCredentials||Hf(h))&&e.xsrfCookieName?jf.read(e.xsrfCookieName):void 0;E&&(o[e.xsrfHeaderName]=E)}"setRequestHeader"in u&&ar.forEach(o,function(w,y){typeof s=="undefined"&&y.toLowerCase()==="content-type"?delete o[y]:u.setRequestHeader(y,w)}),ar.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),a&&a!=="json"&&(u.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&u.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(c=function(p){!u||(i(!p||p&&p.type?new Jf("canceled"):p),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c))),s||(s=null),u.send(s)})}});var Ot=m((Cm,Ws)=>{"use strict";var H=K(),zs=As(),zf=tn(),$f={"Content-Type":"application/x-www-form-urlencoded"};function $s(t,e){!H.isUndefined(t)&&H.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Wf(){var t;return typeof XMLHttpRequest!="undefined"?t=an():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(t=an()),t}function Kf(t,e,r){if(H.isString(t))try{return(e||JSON.parse)(t),H.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var ur={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Wf(),transformRequest:[function(e,r){return zs(r,"Accept"),zs(r,"Content-Type"),H.isFormData(e)||H.isArrayBuffer(e)||H.isBuffer(e)||H.isStream(e)||H.isFile(e)||H.isBlob(e)?e:H.isArrayBufferView(e)?e.buffer:H.isURLSearchParams(e)?($s(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):H.isObject(e)||r&&r["Content-Type"]==="application/json"?($s(r,"application/json"),Kf(e)):e}],transformResponse:[function(e){var r=this.transitional||ur.transitional,n=r&&r.silentJSONParsing,i=r&&r.forcedJSONParsing,s=!n&&this.responseType==="json";if(s||i&&H.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(s)throw o.name==="SyntaxError"?zf(o,this,"E_JSON_PARSE"):o}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};H.forEach(["delete","get","head"],function(e){ur.headers[e]={}});H.forEach(["post","put","patch"],function(e){ur.headers[e]=H.merge($f)});Ws.exports=ur});var Xs=m((Pm,Ks)=>{"use strict";var Xf=K(),Yf=Ot();Ks.exports=function(e,r,n){var i=this||Yf;return Xf.forEach(n,function(o){e=o.call(i,e,r)}),e}});var un=m((Nm,Ys)=>{"use strict";Ys.exports=function(e){return!!(e&&e.__CANCEL__)}});var eo=m((Im,Zs)=>{"use strict";var Qs=K(),cn=Xs(),Qf=un(),Zf=Ot(),el=At();function fn(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new el("canceled")}Zs.exports=function(e){fn(e),e.headers=e.headers||{},e.data=cn.call(e,e.data,e.headers,e.transformRequest),e.headers=Qs.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Qs.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var r=e.adapter||Zf.adapter;return r(e).then(function(i){return fn(e),i.data=cn.call(e,i.data,i.headers,e.transformResponse),i},function(i){return Qf(i)||(fn(e),i&&i.response&&(i.response.data=cn.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})}});var ln=m((_m,to)=>{"use strict";var re=K();to.exports=function(e,r){r=r||{};var n={};function i(u,d){return re.isPlainObject(u)&&re.isPlainObject(d)?re.merge(u,d):re.isPlainObject(d)?re.merge({},d):re.isArray(d)?d.slice():d}function s(u){if(re.isUndefined(r[u])){if(!re.isUndefined(e[u]))return i(void 0,e[u])}else return i(e[u],r[u])}function o(u){if(!re.isUndefined(r[u]))return i(void 0,r[u])}function a(u){if(re.isUndefined(r[u])){if(!re.isUndefined(e[u]))return i(void 0,e[u])}else return i(void 0,r[u])}function c(u){if(u in r)return i(e[u],r[u]);if(u in e)return i(void 0,e[u])}var f={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c};return re.forEach(Object.keys(e).concat(Object.keys(r)),function(d){var l=f[d]||s,h=l(d);re.isUndefined(h)&&l!==c||(n[d]=h)}),n}});var dn=m((km,ro)=>{ro.exports={version:"0.25.0"}});var so=m((qm,io)=>{"use strict";var tl=dn().version,hn={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){hn[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var no={};hn.transitional=function(e,r,n){function i(s,o){return"[Axios v"+tl+"] Transitional option '"+s+"'"+o+(n?". "+n:"")}return function(s,o,a){if(e===!1)throw new Error(i(o," has been removed"+(r?" in "+r:"")));return r&&!no[o]&&(no[o]=!0,console.warn(i(o," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(s,o,a):!0}};function rl(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),i=n.length;i-- >0;){var s=n[i],o=e[s];if(o){var a=t[s],c=a===void 0||o(a,s,t);if(c!==!0)throw new TypeError("option "+s+" must be "+c);continue}if(r!==!0)throw Error("Unknown option "+s)}}io.exports={assertOptions:rl,validators:hn}});var lo=m((Dm,fo)=>{"use strict";var uo=K(),nl=en(),oo=bs(),ao=eo(),cr=ln(),co=so(),Xe=co.validators;function Ct(t){this.defaults=t,this.interceptors={request:new oo,response:new oo}}Ct.prototype.request=function(e,r){if(typeof e=="string"?(r=r||{},r.url=e):r=e||{},!r.url)throw new Error("Provided config url is not valid");r=cr(this.defaults,r),r.method?r.method=r.method.toLowerCase():this.defaults.method?r.method=this.defaults.method.toLowerCase():r.method="get";var n=r.transitional;n!==void 0&&co.assertOptions(n,{silentJSONParsing:Xe.transitional(Xe.boolean),forcedJSONParsing:Xe.transitional(Xe.boolean),clarifyTimeoutError:Xe.transitional(Xe.boolean)},!1);var i=[],s=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(s=s&&h.synchronous,i.unshift(h.fulfilled,h.rejected))});var o=[];this.interceptors.response.forEach(function(h){o.push(h.fulfilled,h.rejected)});var a;if(!s){var c=[ao,void 0];for(Array.prototype.unshift.apply(c,i),c=c.concat(o),a=Promise.resolve(r);c.length;)a=a.then(c.shift(),c.shift());return a}for(var f=r;i.length;){var u=i.shift(),d=i.shift();try{f=u(f)}catch(l){d(l);break}}try{a=ao(f)}catch(l){return Promise.reject(l)}for(;o.length;)a=a.then(o.shift(),o.shift());return a};Ct.prototype.getUri=function(e){if(!e.url)throw new Error("Provided config url is not valid");return e=cr(this.defaults,e),nl(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};uo.forEach(["delete","get","head","options"],function(e){Ct.prototype[e]=function(r,n){return this.request(cr(n||{},{method:e,url:r,data:(n||{}).data}))}});uo.forEach(["post","put","patch"],function(e){Ct.prototype[e]=function(r,n,i){return this.request(cr(i||{},{method:e,url:r,data:n}))}});fo.exports=Ct});var po=m((Um,ho)=>{"use strict";var il=At();function Ye(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(i){e=i});var r=this;this.promise.then(function(n){if(!!r._listeners){var i,s=r._listeners.length;for(i=0;i<s;i++)r._listeners[i](n);r._listeners=null}}),this.promise.then=function(n){var i,s=new Promise(function(o){r.subscribe(o),i=o}).then(n);return s.cancel=function(){r.unsubscribe(i)},s},t(function(i){r.reason||(r.reason=new il(i),e(r.reason))})}Ye.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};Ye.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};Ye.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}};Ye.source=function(){var e,r=new Ye(function(i){e=i});return{token:r,cancel:e}};ho.exports=Ye});var vo=m((Mm,mo)=>{"use strict";mo.exports=function(e){return function(n){return e.apply(null,n)}}});var go=m((Lm,yo)=>{"use strict";var sl=K();yo.exports=function(e){return sl.isObject(e)&&e.isAxiosError===!0}});var wo=m((jm,pn)=>{"use strict";var Eo=K(),ol=Kr(),fr=lo(),al=ln(),ul=Ot();function So(t){var e=new fr(t),r=ol(fr.prototype.request,e);return Eo.extend(r,fr.prototype,e),Eo.extend(r,e),r.create=function(i){return So(al(t,i))},r}var de=So(ul);de.Axios=fr;de.Cancel=At();de.CancelToken=po();de.isCancel=un();de.VERSION=dn().version;de.all=function(e){return Promise.all(e)};de.spread=vo();de.isAxiosError=go();pn.exports=de;pn.exports.default=de});var To=m((Bm,xo)=>{xo.exports=wo()});var gn=m((Ry,Mo)=>{"use strict";Mo.exports=function(e,r){return function(){for(var i=new Array(arguments.length),s=0;s<i.length;s++)i[s]=arguments[s];return e.apply(r,i)}}});var X=m((Ay,Bo)=>{"use strict";var yl=gn(),De=Object.prototype.toString;function wn(t){return De.call(t)==="[object Array]"}function En(t){return typeof t=="undefined"}function gl(t){return t!==null&&!En(t)&&t.constructor!==null&&!En(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function El(t){return De.call(t)==="[object ArrayBuffer]"}function Sl(t){return typeof FormData!="undefined"&&t instanceof FormData}function wl(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&t.buffer instanceof ArrayBuffer,e}function xl(t){return typeof t=="string"}function Tl(t){return typeof t=="number"}function Lo(t){return t!==null&&typeof t=="object"}function vr(t){if(De.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function bl(t){return De.call(t)==="[object Date]"}function Rl(t){return De.call(t)==="[object File]"}function Al(t){return De.call(t)==="[object Blob]"}function jo(t){return De.call(t)==="[object Function]"}function Ol(t){return Lo(t)&&jo(t.pipe)}function Cl(t){return typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams}function Pl(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Nl(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function xn(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),wn(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}function Sn(){var t={};function e(i,s){vr(t[s])&&vr(i)?t[s]=Sn(t[s],i):vr(i)?t[s]=Sn({},i):wn(i)?t[s]=i.slice():t[s]=i}for(var r=0,n=arguments.length;r<n;r++)xn(arguments[r],e);return t}function Il(t,e,r){return xn(e,function(i,s){r&&typeof i=="function"?t[s]=yl(i,r):t[s]=i}),t}function _l(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}Bo.exports={isArray:wn,isArrayBuffer:El,isBuffer:gl,isFormData:Sl,isArrayBufferView:wl,isString:xl,isNumber:Tl,isObject:Lo,isPlainObject:vr,isUndefined:En,isDate:bl,isFile:Rl,isBlob:Al,isFunction:jo,isStream:Ol,isURLSearchParams:Cl,isStandardBrowserEnv:Nl,forEach:xn,merge:Sn,extend:Il,trim:Pl,stripBOM:_l}});var Tn=m((Oy,Vo)=>{"use strict";var et=X();function Fo(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}Vo.exports=function(e,r,n){if(!r)return e;var i;if(n)i=n(r);else if(et.isURLSearchParams(r))i=r.toString();else{var s=[];et.forEach(r,function(c,f){c===null||typeof c=="undefined"||(et.isArray(c)?f=f+"[]":c=[c],et.forEach(c,function(d){et.isDate(d)?d=d.toISOString():et.isObject(d)&&(d=JSON.stringify(d)),s.push(Fo(f)+"="+Fo(d))}))}),i=s.join("&")}if(i){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}});var Go=m((Cy,Ho)=>{"use strict";var kl=X();function yr(){this.handlers=[]}yr.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};yr.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};yr.prototype.forEach=function(e){kl.forEach(this.handlers,function(n){n!==null&&e(n)})};Ho.exports=yr});var zo=m((Py,Jo)=>{"use strict";var ql=X();Jo.exports=function(e,r){ql.forEach(e,function(i,s){s!==r&&s.toUpperCase()===r.toUpperCase()&&(e[r]=i,delete e[s])})}});var bn=m((Ny,$o)=>{"use strict";$o.exports=function(e,r,n,i,s){return e.config=r,n&&(e.code=n),e.request=i,e.response=s,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}});var Rn=m((Iy,Wo)=>{"use strict";var Dl=bn();Wo.exports=function(e,r,n,i,s){var o=new Error(e);return Dl(o,r,n,i,s)}});var Xo=m((_y,Ko)=>{"use strict";var Ul=Rn();Ko.exports=function(e,r,n){var i=n.config.validateStatus;!n.status||!i||i(n.status)?e(n):r(Ul("Request failed with status code "+n.status,n.config,null,n.request,n))}});var Qo=m((ky,Yo)=>{"use strict";var gr=X();Yo.exports=gr.isStandardBrowserEnv()?function(){return{write:function(r,n,i,s,o,a){var c=[];c.push(r+"="+encodeURIComponent(n)),gr.isNumber(i)&&c.push("expires="+new Date(i).toGMTString()),gr.isString(s)&&c.push("path="+s),gr.isString(o)&&c.push("domain="+o),a===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(r){var n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var ea=m((qy,Zo)=>{"use strict";Zo.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var ra=m((Dy,ta)=>{"use strict";ta.exports=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e}});var ia=m((Uy,na)=>{"use strict";var Ml=ea(),Ll=ra();na.exports=function(e,r){return e&&!Ml(r)?Ll(e,r):r}});var oa=m((My,sa)=>{"use strict";var An=X(),jl=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];sa.exports=function(e){var r={},n,i,s;return e&&An.forEach(e.split(`
3
+ `),function(a){if(s=a.indexOf(":"),n=An.trim(a.substr(0,s)).toLowerCase(),i=An.trim(a.substr(s+1)),n){if(r[n]&&jl.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([i]):r[n]=r[n]?r[n]+", "+i:i}}),r}});var ca=m((Ly,ua)=>{"use strict";var aa=X();ua.exports=aa.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function i(s){var o=s;return e&&(r.setAttribute("href",o),o=r.href),r.setAttribute("href",o),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=i(window.location.href),function(o){var a=aa.isString(o)?i(o):o;return a.protocol===n.protocol&&a.host===n.host}}():function(){return function(){return!0}}()});var Cn=m((jy,fa)=>{"use strict";var Er=X(),Bl=Xo(),Fl=Qo(),Vl=Tn(),Hl=ia(),Gl=oa(),Jl=ca(),On=Rn();fa.exports=function(e){return new Promise(function(n,i){var s=e.data,o=e.headers,a=e.responseType;Er.isFormData(s)&&delete o["Content-Type"];var c=new XMLHttpRequest;if(e.auth){var f=e.auth.username||"",u=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(f+":"+u)}var d=Hl(e.baseURL,e.url);c.open(e.method.toUpperCase(),Vl(d,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function l(){if(!!c){var g="getAllResponseHeaders"in c?Gl(c.getAllResponseHeaders()):null,E=!a||a==="text"||a==="json"?c.responseText:c.response,p={data:E,status:c.status,statusText:c.statusText,headers:g,config:e,request:c};Bl(n,i,p),c=null}}if("onloadend"in c?c.onloadend=l:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(l)},c.onabort=function(){!c||(i(On("Request aborted",e,"ECONNABORTED",c)),c=null)},c.onerror=function(){i(On("Network Error",e,null,c)),c=null},c.ontimeout=function(){var E="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(E=e.timeoutErrorMessage),i(On(E,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",c)),c=null},Er.isStandardBrowserEnv()){var h=(e.withCredentials||Jl(d))&&e.xsrfCookieName?Fl.read(e.xsrfCookieName):void 0;h&&(o[e.xsrfHeaderName]=h)}"setRequestHeader"in c&&Er.forEach(o,function(E,p){typeof s=="undefined"&&p.toLowerCase()==="content-type"?delete o[p]:c.setRequestHeader(p,E)}),Er.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),a&&a!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(E){!c||(c.abort(),i(E),c=null)}),s||(s=null),c.send(s)})}});var wr=m((By,ha)=>{"use strict";var G=X(),la=zo(),zl=bn(),$l={"Content-Type":"application/x-www-form-urlencoded"};function da(t,e){!G.isUndefined(t)&&G.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Wl(){var t;return typeof XMLHttpRequest!="undefined"?t=Cn():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(t=Cn()),t}function Kl(t,e,r){if(G.isString(t))try{return(e||JSON.parse)(t),G.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var Sr={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Wl(),transformRequest:[function(e,r){return la(r,"Accept"),la(r,"Content-Type"),G.isFormData(e)||G.isArrayBuffer(e)||G.isBuffer(e)||G.isStream(e)||G.isFile(e)||G.isBlob(e)?e:G.isArrayBufferView(e)?e.buffer:G.isURLSearchParams(e)?(da(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):G.isObject(e)||r&&r["Content-Type"]==="application/json"?(da(r,"application/json"),Kl(e)):e}],transformResponse:[function(e){var r=this.transitional,n=r&&r.silentJSONParsing,i=r&&r.forcedJSONParsing,s=!n&&this.responseType==="json";if(s||i&&G.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(s)throw o.name==="SyntaxError"?zl(o,this,"E_JSON_PARSE"):o}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};Sr.headers={common:{Accept:"application/json, text/plain, */*"}};G.forEach(["delete","get","head"],function(e){Sr.headers[e]={}});G.forEach(["post","put","patch"],function(e){Sr.headers[e]=G.merge($l)});ha.exports=Sr});var ma=m((Fy,pa)=>{"use strict";var Xl=X(),Yl=wr();pa.exports=function(e,r,n){var i=this||Yl;return Xl.forEach(n,function(o){e=o.call(i,e,r)}),e}});var Pn=m((Vy,va)=>{"use strict";va.exports=function(e){return!!(e&&e.__CANCEL__)}});var Ea=m((Hy,ga)=>{"use strict";var ya=X(),Nn=ma(),Ql=Pn(),Zl=wr();function In(t){t.cancelToken&&t.cancelToken.throwIfRequested()}ga.exports=function(e){In(e),e.headers=e.headers||{},e.data=Nn.call(e,e.data,e.headers,e.transformRequest),e.headers=ya.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),ya.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var r=e.adapter||Zl.adapter;return r(e).then(function(i){return In(e),i.data=Nn.call(e,i.data,i.headers,e.transformResponse),i},function(i){return Ql(i)||(In(e),i&&i.response&&(i.response.data=Nn.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})}});var _n=m((Gy,Sa)=>{"use strict";var W=X();Sa.exports=function(e,r){r=r||{};var n={},i=["url","method","data"],s=["headers","auth","proxy","params"],o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function c(l,h){return W.isPlainObject(l)&&W.isPlainObject(h)?W.merge(l,h):W.isPlainObject(h)?W.merge({},h):W.isArray(h)?h.slice():h}function f(l){W.isUndefined(r[l])?W.isUndefined(e[l])||(n[l]=c(void 0,e[l])):n[l]=c(e[l],r[l])}W.forEach(i,function(h){W.isUndefined(r[h])||(n[h]=c(void 0,r[h]))}),W.forEach(s,f),W.forEach(o,function(h){W.isUndefined(r[h])?W.isUndefined(e[h])||(n[h]=c(void 0,e[h])):n[h]=c(void 0,r[h])}),W.forEach(a,function(h){h in r?n[h]=c(e[h],r[h]):h in e&&(n[h]=c(void 0,e[h]))});var u=i.concat(s).concat(o).concat(a),d=Object.keys(e).concat(Object.keys(r)).filter(function(h){return u.indexOf(h)===-1});return W.forEach(d,f),n}});var wa=m((Jy,ed)=>{ed.exports={name:"axios",version:"0.21.4",description:"Promise based HTTP client for the browser and node.js",main:"index.js",scripts:{test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},repository:{type:"git",url:"https://github.com/axios/axios.git"},keywords:["xhr","http","ajax","promise","node"],author:"Matt Zabriskie",license:"MIT",bugs:{url:"https://github.com/axios/axios/issues"},homepage:"https://axios-http.com",devDependencies:{coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},browser:{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},jsdelivr:"dist/axios.min.js",unpkg:"dist/axios.min.js",typings:"./index.d.ts",dependencies:{"follow-redirects":"^1.14.0"},bundlesize:[{path:"./dist/axios.min.js",threshold:"5kB"}]}});var Aa=m((zy,Ra)=>{"use strict";var Ta=wa(),kn={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){kn[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var xa={},td=Ta.version.split(".");function ba(t,e){for(var r=e?e.split("."):td,n=t.split("."),i=0;i<3;i++){if(r[i]>n[i])return!0;if(r[i]<n[i])return!1}return!1}kn.transitional=function(e,r,n){var i=r&&ba(r);function s(o,a){return"[Axios v"+Ta.version+"] Transitional option '"+o+"'"+a+(n?". "+n:"")}return function(o,a,c){if(e===!1)throw new Error(s(a," has been removed in "+r));return i&&!xa[a]&&(xa[a]=!0,console.warn(s(a," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(o,a,c):!0}};function rd(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),i=n.length;i-- >0;){var s=n[i],o=e[s];if(o){var a=t[s],c=a===void 0||o(a,s,t);if(c!==!0)throw new TypeError("option "+s+" must be "+c);continue}if(r!==!0)throw Error("Unknown option "+s)}}Ra.exports={isOlderVersion:ba,assertOptions:rd,validators:kn}});var _a=m(($y,Ia)=>{"use strict";var Pa=X(),nd=Tn(),Oa=Go(),Ca=Ea(),xr=_n(),Na=Aa(),tt=Na.validators;function kt(t){this.defaults=t,this.interceptors={request:new Oa,response:new Oa}}kt.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=xr(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;r!==void 0&&Na.assertOptions(r,{silentJSONParsing:tt.transitional(tt.boolean,"1.0.0"),forcedJSONParsing:tt.transitional(tt.boolean,"1.0.0"),clarifyTimeoutError:tt.transitional(tt.boolean,"1.0.0")},!1);var n=[],i=!0;this.interceptors.request.forEach(function(l){typeof l.runWhen=="function"&&l.runWhen(e)===!1||(i=i&&l.synchronous,n.unshift(l.fulfilled,l.rejected))});var s=[];this.interceptors.response.forEach(function(l){s.push(l.fulfilled,l.rejected)});var o;if(!i){var a=[Ca,void 0];for(Array.prototype.unshift.apply(a,n),a=a.concat(s),o=Promise.resolve(e);a.length;)o=o.then(a.shift(),a.shift());return o}for(var c=e;n.length;){var f=n.shift(),u=n.shift();try{c=f(c)}catch(d){u(d);break}}try{o=Ca(c)}catch(d){return Promise.reject(d)}for(;s.length;)o=o.then(s.shift(),s.shift());return o};kt.prototype.getUri=function(e){return e=xr(this.defaults,e),nd(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};Pa.forEach(["delete","get","head","options"],function(e){kt.prototype[e]=function(r,n){return this.request(xr(n||{},{method:e,url:r,data:(n||{}).data}))}});Pa.forEach(["post","put","patch"],function(e){kt.prototype[e]=function(r,n,i){return this.request(xr(i||{},{method:e,url:r,data:n}))}});Ia.exports=kt});var Dn=m((Wy,ka)=>{"use strict";function qn(t){this.message=t}qn.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};qn.prototype.__CANCEL__=!0;ka.exports=qn});var Da=m((Ky,qa)=>{"use strict";var id=Dn();function Tr(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(i){e=i});var r=this;t(function(i){r.reason||(r.reason=new id(i),e(r.reason))})}Tr.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};Tr.source=function(){var e,r=new Tr(function(i){e=i});return{token:r,cancel:e}};qa.exports=Tr});var Ma=m((Xy,Ua)=>{"use strict";Ua.exports=function(e){return function(n){return e.apply(null,n)}}});var ja=m((Yy,La)=>{"use strict";La.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var Va=m((Qy,Un)=>{"use strict";var Ba=X(),sd=gn(),br=_a(),od=_n(),ad=wr();function Fa(t){var e=new br(t),r=sd(br.prototype.request,e);return Ba.extend(r,br.prototype,e),Ba.extend(r,e),r}var ue=Fa(ad);ue.Axios=br;ue.create=function(e){return Fa(od(ue.defaults,e))};ue.Cancel=Dn();ue.CancelToken=Da();ue.isCancel=Pn();ue.all=function(e){return Promise.all(e)};ue.spread=Ma();ue.isAxiosError=ja();Un.exports=ue;Un.exports.default=ue});var Ga=m((Zy,Ha)=>{Ha.exports=Va()});var jn=m((ug,za)=>{"use strict";za.exports=function(e,r){return function(){for(var i=new Array(arguments.length),s=0;s<i.length;s++)i[s]=arguments[s];return e.apply(r,i)}}});var Y=m((cg,Ka)=>{"use strict";var ud=jn(),Ue=Object.prototype.toString;function Vn(t){return Ue.call(t)==="[object Array]"}function Bn(t){return typeof t=="undefined"}function cd(t){return t!==null&&!Bn(t)&&t.constructor!==null&&!Bn(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function fd(t){return Ue.call(t)==="[object ArrayBuffer]"}function ld(t){return typeof FormData!="undefined"&&t instanceof FormData}function dd(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&t.buffer instanceof ArrayBuffer,e}function hd(t){return typeof t=="string"}function pd(t){return typeof t=="number"}function $a(t){return t!==null&&typeof t=="object"}function Rr(t){if(Ue.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function md(t){return Ue.call(t)==="[object Date]"}function vd(t){return Ue.call(t)==="[object File]"}function yd(t){return Ue.call(t)==="[object Blob]"}function Wa(t){return Ue.call(t)==="[object Function]"}function gd(t){return $a(t)&&Wa(t.pipe)}function Ed(t){return typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams}function Sd(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function wd(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function Hn(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),Vn(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}function Fn(){var t={};function e(i,s){Rr(t[s])&&Rr(i)?t[s]=Fn(t[s],i):Rr(i)?t[s]=Fn({},i):Vn(i)?t[s]=i.slice():t[s]=i}for(var r=0,n=arguments.length;r<n;r++)Hn(arguments[r],e);return t}function xd(t,e,r){return Hn(e,function(i,s){r&&typeof i=="function"?t[s]=ud(i,r):t[s]=i}),t}function Td(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}Ka.exports={isArray:Vn,isArrayBuffer:fd,isBuffer:cd,isFormData:ld,isArrayBufferView:dd,isString:hd,isNumber:pd,isObject:$a,isPlainObject:Rr,isUndefined:Bn,isDate:md,isFile:vd,isBlob:yd,isFunction:Wa,isStream:gd,isURLSearchParams:Ed,isStandardBrowserEnv:wd,forEach:Hn,merge:Fn,extend:xd,trim:Sd,stripBOM:Td}});var Gn=m((fg,Ya)=>{"use strict";var rt=Y();function Xa(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}Ya.exports=function(e,r,n){if(!r)return e;var i;if(n)i=n(r);else if(rt.isURLSearchParams(r))i=r.toString();else{var s=[];rt.forEach(r,function(c,f){c===null||typeof c=="undefined"||(rt.isArray(c)?f=f+"[]":c=[c],rt.forEach(c,function(d){rt.isDate(d)?d=d.toISOString():rt.isObject(d)&&(d=JSON.stringify(d)),s.push(Xa(f)+"="+Xa(d))}))}),i=s.join("&")}if(i){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}});var Za=m((lg,Qa)=>{"use strict";var bd=Y();function Ar(){this.handlers=[]}Ar.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};Ar.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};Ar.prototype.forEach=function(e){bd.forEach(this.handlers,function(n){n!==null&&e(n)})};Qa.exports=Ar});var tu=m((dg,eu)=>{"use strict";var Rd=Y();eu.exports=function(e,r){Rd.forEach(e,function(i,s){s!==r&&s.toUpperCase()===r.toUpperCase()&&(e[r]=i,delete e[s])})}});var Jn=m((hg,ru)=>{"use strict";ru.exports=function(e,r,n,i,s){return e.config=r,n&&(e.code=n),e.request=i,e.response=s,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}});var zn=m((pg,nu)=>{"use strict";var Ad=Jn();nu.exports=function(e,r,n,i,s){var o=new Error(e);return Ad(o,r,n,i,s)}});var su=m((mg,iu)=>{"use strict";var Od=zn();iu.exports=function(e,r,n){var i=n.config.validateStatus;!n.status||!i||i(n.status)?e(n):r(Od("Request failed with status code "+n.status,n.config,null,n.request,n))}});var au=m((vg,ou)=>{"use strict";var Or=Y();ou.exports=Or.isStandardBrowserEnv()?function(){return{write:function(r,n,i,s,o,a){var c=[];c.push(r+"="+encodeURIComponent(n)),Or.isNumber(i)&&c.push("expires="+new Date(i).toGMTString()),Or.isString(s)&&c.push("path="+s),Or.isString(o)&&c.push("domain="+o),a===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(r){var n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var cu=m((yg,uu)=>{"use strict";uu.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var lu=m((gg,fu)=>{"use strict";fu.exports=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e}});var hu=m((Eg,du)=>{"use strict";var Cd=cu(),Pd=lu();du.exports=function(e,r){return e&&!Cd(r)?Pd(e,r):r}});var mu=m((Sg,pu)=>{"use strict";var $n=Y(),Nd=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];pu.exports=function(e){var r={},n,i,s;return e&&$n.forEach(e.split(`
4
+ `),function(a){if(s=a.indexOf(":"),n=$n.trim(a.substr(0,s)).toLowerCase(),i=$n.trim(a.substr(s+1)),n){if(r[n]&&Nd.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([i]):r[n]=r[n]?r[n]+", "+i:i}}),r}});var gu=m((wg,yu)=>{"use strict";var vu=Y();yu.exports=vu.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function i(s){var o=s;return e&&(r.setAttribute("href",o),o=r.href),r.setAttribute("href",o),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=i(window.location.href),function(o){var a=vu.isString(o)?i(o):o;return a.protocol===n.protocol&&a.host===n.host}}():function(){return function(){return!0}}()});var qt=m((xg,Eu)=>{"use strict";function Wn(t){this.message=t}Wn.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};Wn.prototype.__CANCEL__=!0;Eu.exports=Wn});var Xn=m((Tg,Su)=>{"use strict";var Cr=Y(),Id=su(),_d=au(),kd=Gn(),qd=hu(),Dd=mu(),Ud=gu(),Kn=zn(),Md=Dt(),Ld=qt();Su.exports=function(e){return new Promise(function(n,i){var s=e.data,o=e.headers,a=e.responseType,c;function f(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}Cr.isFormData(s)&&delete o["Content-Type"];var u=new XMLHttpRequest;if(e.auth){var d=e.auth.username||"",l=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(d+":"+l)}var h=qd(e.baseURL,e.url);u.open(e.method.toUpperCase(),kd(h,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function g(){if(!!u){var p="getAllResponseHeaders"in u?Dd(u.getAllResponseHeaders()):null,w=!a||a==="text"||a==="json"?u.responseText:u.response,y={data:w,status:u.status,statusText:u.statusText,headers:p,config:e,request:u};Id(function(C){n(C),f()},function(C){i(C),f()},y),u=null}}if("onloadend"in u?u.onloadend=g:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(g)},u.onabort=function(){!u||(i(Kn("Request aborted",e,"ECONNABORTED",u)),u=null)},u.onerror=function(){i(Kn("Network Error",e,null,u)),u=null},u.ontimeout=function(){var w=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",y=e.transitional||Md.transitional;e.timeoutErrorMessage&&(w=e.timeoutErrorMessage),i(Kn(w,e,y.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},Cr.isStandardBrowserEnv()){var E=(e.withCredentials||Ud(h))&&e.xsrfCookieName?_d.read(e.xsrfCookieName):void 0;E&&(o[e.xsrfHeaderName]=E)}"setRequestHeader"in u&&Cr.forEach(o,function(w,y){typeof s=="undefined"&&y.toLowerCase()==="content-type"?delete o[y]:u.setRequestHeader(y,w)}),Cr.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),a&&a!=="json"&&(u.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&u.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(c=function(p){!u||(i(!p||p&&p.type?new Ld("canceled"):p),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c))),s||(s=null),u.send(s)})}});var Dt=m((bg,Tu)=>{"use strict";var J=Y(),wu=tu(),jd=Jn(),Bd={"Content-Type":"application/x-www-form-urlencoded"};function xu(t,e){!J.isUndefined(t)&&J.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Fd(){var t;return typeof XMLHttpRequest!="undefined"?t=Xn():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(t=Xn()),t}function Vd(t,e,r){if(J.isString(t))try{return(e||JSON.parse)(t),J.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var Pr={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Fd(),transformRequest:[function(e,r){return wu(r,"Accept"),wu(r,"Content-Type"),J.isFormData(e)||J.isArrayBuffer(e)||J.isBuffer(e)||J.isStream(e)||J.isFile(e)||J.isBlob(e)?e:J.isArrayBufferView(e)?e.buffer:J.isURLSearchParams(e)?(xu(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):J.isObject(e)||r&&r["Content-Type"]==="application/json"?(xu(r,"application/json"),Vd(e)):e}],transformResponse:[function(e){var r=this.transitional||Pr.transitional,n=r&&r.silentJSONParsing,i=r&&r.forcedJSONParsing,s=!n&&this.responseType==="json";if(s||i&&J.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(s)throw o.name==="SyntaxError"?jd(o,this,"E_JSON_PARSE"):o}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};J.forEach(["delete","get","head"],function(e){Pr.headers[e]={}});J.forEach(["post","put","patch"],function(e){Pr.headers[e]=J.merge(Bd)});Tu.exports=Pr});var Ru=m((Rg,bu)=>{"use strict";var Hd=Y(),Gd=Dt();bu.exports=function(e,r,n){var i=this||Gd;return Hd.forEach(n,function(o){e=o.call(i,e,r)}),e}});var Yn=m((Ag,Au)=>{"use strict";Au.exports=function(e){return!!(e&&e.__CANCEL__)}});var Pu=m((Og,Cu)=>{"use strict";var Ou=Y(),Qn=Ru(),Jd=Yn(),zd=Dt(),$d=qt();function Zn(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new $d("canceled")}Cu.exports=function(e){Zn(e),e.headers=e.headers||{},e.data=Qn.call(e,e.data,e.headers,e.transformRequest),e.headers=Ou.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Ou.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var r=e.adapter||zd.adapter;return r(e).then(function(i){return Zn(e),i.data=Qn.call(e,i.data,i.headers,e.transformResponse),i},function(i){return Jd(i)||(Zn(e),i&&i.response&&(i.response.data=Qn.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})}});var ei=m((Cg,Nu)=>{"use strict";var ne=Y();Nu.exports=function(e,r){r=r||{};var n={};function i(u,d){return ne.isPlainObject(u)&&ne.isPlainObject(d)?ne.merge(u,d):ne.isPlainObject(d)?ne.merge({},d):ne.isArray(d)?d.slice():d}function s(u){if(ne.isUndefined(r[u])){if(!ne.isUndefined(e[u]))return i(void 0,e[u])}else return i(e[u],r[u])}function o(u){if(!ne.isUndefined(r[u]))return i(void 0,r[u])}function a(u){if(ne.isUndefined(r[u])){if(!ne.isUndefined(e[u]))return i(void 0,e[u])}else return i(void 0,r[u])}function c(u){if(u in r)return i(e[u],r[u]);if(u in e)return i(void 0,e[u])}var f={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c};return ne.forEach(Object.keys(e).concat(Object.keys(r)),function(d){var l=f[d]||s,h=l(d);ne.isUndefined(h)&&l!==c||(n[d]=h)}),n}});var ti=m((Pg,Iu)=>{Iu.exports={version:"0.23.0"}});var qu=m((Ng,ku)=>{"use strict";var Wd=ti().version,ri={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){ri[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var _u={};ri.transitional=function(e,r,n){function i(s,o){return"[Axios v"+Wd+"] Transitional option '"+s+"'"+o+(n?". "+n:"")}return function(s,o,a){if(e===!1)throw new Error(i(o," has been removed"+(r?" in "+r:"")));return r&&!_u[o]&&(_u[o]=!0,console.warn(i(o," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(s,o,a):!0}};function Kd(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),i=n.length;i-- >0;){var s=n[i],o=e[s];if(o){var a=t[s],c=a===void 0||o(a,s,t);if(c!==!0)throw new TypeError("option "+s+" must be "+c);continue}if(r!==!0)throw Error("Unknown option "+s)}}ku.exports={assertOptions:Kd,validators:ri}});var Bu=m((Ig,ju)=>{"use strict";var Mu=Y(),Xd=Gn(),Du=Za(),Uu=Pu(),Nr=ei(),Lu=qu(),nt=Lu.validators;function Ut(t){this.defaults=t,this.interceptors={request:new Du,response:new Du}}Ut.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=Nr(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;r!==void 0&&Lu.assertOptions(r,{silentJSONParsing:nt.transitional(nt.boolean),forcedJSONParsing:nt.transitional(nt.boolean),clarifyTimeoutError:nt.transitional(nt.boolean)},!1);var n=[],i=!0;this.interceptors.request.forEach(function(l){typeof l.runWhen=="function"&&l.runWhen(e)===!1||(i=i&&l.synchronous,n.unshift(l.fulfilled,l.rejected))});var s=[];this.interceptors.response.forEach(function(l){s.push(l.fulfilled,l.rejected)});var o;if(!i){var a=[Uu,void 0];for(Array.prototype.unshift.apply(a,n),a=a.concat(s),o=Promise.resolve(e);a.length;)o=o.then(a.shift(),a.shift());return o}for(var c=e;n.length;){var f=n.shift(),u=n.shift();try{c=f(c)}catch(d){u(d);break}}try{o=Uu(c)}catch(d){return Promise.reject(d)}for(;s.length;)o=o.then(s.shift(),s.shift());return o};Ut.prototype.getUri=function(e){return e=Nr(this.defaults,e),Xd(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};Mu.forEach(["delete","get","head","options"],function(e){Ut.prototype[e]=function(r,n){return this.request(Nr(n||{},{method:e,url:r,data:(n||{}).data}))}});Mu.forEach(["post","put","patch"],function(e){Ut.prototype[e]=function(r,n,i){return this.request(Nr(i||{},{method:e,url:r,data:n}))}});ju.exports=Ut});var Vu=m((_g,Fu)=>{"use strict";var Yd=qt();function it(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(i){e=i});var r=this;this.promise.then(function(n){if(!!r._listeners){var i,s=r._listeners.length;for(i=0;i<s;i++)r._listeners[i](n);r._listeners=null}}),this.promise.then=function(n){var i,s=new Promise(function(o){r.subscribe(o),i=o}).then(n);return s.cancel=function(){r.unsubscribe(i)},s},t(function(i){r.reason||(r.reason=new Yd(i),e(r.reason))})}it.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};it.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};it.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}};it.source=function(){var e,r=new it(function(i){e=i});return{token:r,cancel:e}};Fu.exports=it});var Gu=m((kg,Hu)=>{"use strict";Hu.exports=function(e){return function(n){return e.apply(null,n)}}});var zu=m((qg,Ju)=>{"use strict";Ju.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var Ku=m((Dg,ni)=>{"use strict";var $u=Y(),Qd=jn(),Ir=Bu(),Zd=ei(),eh=Dt();function Wu(t){var e=new Ir(t),r=Qd(Ir.prototype.request,e);return $u.extend(r,Ir.prototype,e),$u.extend(r,e),r.create=function(i){return Wu(Zd(t,i))},r}var he=Wu(eh);he.Axios=Ir;he.Cancel=qt();he.CancelToken=Vu();he.isCancel=Yn();he.VERSION=ti().version;he.all=function(e){return Promise.all(e)};he.spread=Gu();he.isAxiosError=zu();ni.exports=he;ni.exports.default=he});var ii=m((Ug,Xu)=>{Xu.exports=Ku()});var v=function(){return v=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},v.apply(this,arguments)};function je(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function b(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function R(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function _(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))}var P;(function(t){t.Start="xstate.start",t.Stop="xstate.stop",t.Raise="xstate.raise",t.Send="xstate.send",t.Cancel="xstate.cancel",t.NullEvent="",t.Assign="xstate.assign",t.After="xstate.after",t.DoneState="done.state",t.DoneInvoke="done.invoke",t.Log="xstate.log",t.Init="xstate.init",t.Invoke="xstate.invoke",t.ErrorExecution="error.execution",t.ErrorCommunication="error.communication",t.ErrorPlatform="error.platform",t.ErrorCustom="xstate.error",t.Update="xstate.update",t.Pure="xstate.pure",t.Choose="xstate.choose"})(P||(P={}));var ge;(function(t){t.Parent="#_parent",t.Internal="#_internal"})(ge||(ge={}));var ot=P.Start,Be=P.Stop,Fe=P.Raise,Te=P.Send,jt=P.Cancel,ci=P.NullEvent,Bt=P.Assign,sh=P.After,oh=P.DoneState,Ft=P.Log,fi=P.Init,at=P.Invoke,ah=P.ErrorExecution,kr=P.ErrorPlatform,qr=P.ErrorCustom,ut=P.Update,li=P.Choose,di=P.Pure;var Vt=".",Dr={},Ht="xstate.guard",hi="";var D=!0;var Gt;function ft(t,e,r){r===void 0&&(r=Vt);var n=Ve(t,r),i=Ve(e,r);return A(i)?A(n)?i===n:!1:A(n)?n in i:Object.keys(n).every(function(s){return s in i?ft(n[s],i[s]):!1})}function Jt(t){try{return A(t)||typeof t=="number"?"".concat(t):t.type}catch{throw new Error("Events must be strings or objects with a string event.type property.")}}function zt(t,e){try{return pe(t)?t:t.toString().split(e)}catch{throw new Error("'".concat(t,"' is not a valid state path."))}}function uc(t){return typeof t=="object"&&"value"in t&&"context"in t&&"event"in t&&"_event"in t}function Ve(t,e){if(uc(t))return t.value;if(pe(t))return ct(t);if(typeof t!="string")return t;var r=zt(t,e);return ct(r)}function ct(t){if(t.length===1)return t[0];for(var e={},r=e,n=0;n<t.length-1;n++)n===t.length-2?r[t[n]]=t[n+1]:(r[t[n]]={},r=r[t[n]]);return e}function He(t,e){for(var r={},n=Object.keys(t),i=0;i<n.length;i++){var s=n[i];r[s]=e(t[s],s,t,i)}return r}function Ur(t,e,r){var n,i,s={};try{for(var o=b(Object.keys(t)),a=o.next();!a.done;a=o.next()){var c=a.value,f=t[c];!r(f)||(s[c]=e(f,c,t))}}catch(u){n={error:u}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}var pi=function(t){return function(e){var r,n,i=e;try{for(var s=b(t),o=s.next();!o.done;o=s.next()){var a=o.value;i=i[a]}}catch(c){r={error:c}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return i}};function mi(t,e){return function(r){var n,i,s=r;try{for(var o=b(t),a=o.next();!a.done;a=o.next()){var c=a.value;s=s[e][c]}}catch(f){n={error:f}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}}function lt(t){if(!t)return[[]];if(A(t))return[[t]];var e=q(Object.keys(t).map(function(r){var n=t[r];return typeof n!="string"&&(!n||!Object.keys(n).length)?[[r]]:lt(t[r]).map(function(i){return[r].concat(i)})}));return e}function q(t){var e;return(e=[]).concat.apply(e,_([],R(t),!1))}function vi(t){return pe(t)?t:[t]}function te(t){return t===void 0?[]:vi(t)}function be(t,e,r){var n,i;if(N(t))return t(e,r.data);var s={};try{for(var o=b(Object.keys(t)),a=o.next();!a.done;a=o.next()){var c=a.value,f=t[c];N(f)?s[c]=f(e,r.data):s[c]=f}}catch(u){n={error:u}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}function yi(t){return/^(done|error)\./.test(t)}function Mr(t){return!!(t instanceof Promise||t!==null&&(N(t)||typeof t=="object")&&N(t.then))}function gi(t){return t!==null&&typeof t=="object"&&"transition"in t&&typeof t.transition=="function"}function $t(t,e){var r,n,i=R([[],[]],2),s=i[0],o=i[1];try{for(var a=b(t),c=a.next();!c.done;c=a.next()){var f=c.value;e(f)?s.push(f):o.push(f)}}catch(u){r={error:u}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return[s,o]}function Ei(t,e){return He(t.states,function(r,n){if(!!r){var i=(A(e)?void 0:e[n])||(r?r.current:void 0);if(!!i)return{current:i,states:Ei(r,i)}}})}function Si(t,e){return{current:e,states:Ei(t,e)}}function Lr(t,e,r,n){D||L(!!t,"Attempting to update undefined context");var i=t&&r.reduce(function(s,o){var a,c,f=o.assignment,u={state:n,action:o,_event:e},d={};if(N(f))d=f(s,e.data,u);else try{for(var l=b(Object.keys(f)),h=l.next();!h.done;h=l.next()){var g=h.value,E=f[g];d[g]=N(E)?E(s,e.data,u):E}}catch(p){a={error:p}}finally{try{h&&!h.done&&(c=l.return)&&c.call(l)}finally{if(a)throw a.error}}return Object.assign({},s,d)},t);return i}var L=function(){};D||(L=function(t,e){var r=t instanceof Error?t:void 0;if(!(!r&&t)&&console!==void 0){var n=["Warning: ".concat(e)];r&&n.push(r),console.warn.apply(console,n)}});function pe(t){return Array.isArray(t)}function N(t){return typeof t=="function"}function A(t){return typeof t=="string"}function Wt(t,e){if(!!t)return A(t)?{type:Ht,name:t,predicate:e?e[t]:void 0}:N(t)?{type:Ht,name:t.name,predicate:t}:t}function wi(t){try{return"subscribe"in t&&N(t.subscribe)}catch{return!1}}var ce=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}(),ph=(Gt={},Gt[ce]=function(){return this},Gt[Symbol.observable]=function(){return this},Gt);function fe(t){return!!t&&"__xstatenode"in t}function xi(t){return!!t&&typeof t.send=="function"}function dt(t,e){return A(t)||typeof t=="number"?v({type:t},e):t}function F(t,e){if(!A(t)&&"$$type"in t&&t.$$type==="scxml")return t;var r=dt(t);return v({name:r.type,data:r,$$type:"scxml",type:"external"},e)}function Re(t,e){var r=vi(e).map(function(n){return typeof n=="undefined"||typeof n=="string"||fe(n)?{target:n,event:t}:v(v({},n),{event:t})});return r}function Ti(t){if(!(t===void 0||t===hi))return te(t)}function bi(t,e,r){if(!D){var n=t.stack?" Stacktrace was '".concat(t.stack,"'"):"";if(t===e)console.error("Missing onError handler for invocation '".concat(r,"', error was '").concat(t,"'.").concat(n));else{var i=e.stack?" Stacktrace was '".concat(e.stack,"'"):"";console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '".concat(r,"'. ")+"Original error: '".concat(t,"'. ").concat(n," Current error is '").concat(e,"'.").concat(i))}}}function Kt(t,e,r,n,i){var s=t.options.guards,o={state:i,cond:e,_event:n};if(e.type===Ht)return((s==null?void 0:s[e.name])||e.predicate)(r,n.data,o);var a=s==null?void 0:s[e.type];if(!a)throw new Error("Guard '".concat(e.type,"' is not implemented on machine '").concat(t.id,"'."));return a(r,n.data,o)}function Xt(t){return typeof t=="string"?{type:t}:t}function ht(t,e,r){if(typeof t=="object")return t;var n=function(){};return{next:t,error:e||n,complete:r||n}}function pt(t,e){return"".concat(t,":invocation[").concat(e,"]")}var Ae=F({type:fi});function Yt(t,e){return e&&e[t]||void 0}function Ge(t,e){var r;if(A(t)||typeof t=="number"){var n=Yt(t,e);N(n)?r={type:t,exec:n}:n?r=n:r={type:t,exec:void 0}}else if(N(t))r={type:t.name||t.toString(),exec:t};else{var n=Yt(t.type,e);if(N(n))r=v(v({},t),{exec:n});else if(n){var i=n.type||t.type;r=v(v(v({},n),t),{type:i})}else r=t}return r}var mt=function(t,e){if(!t)return[];var r=pe(t)?t:[t];return r.map(function(n){return Ge(n,e)})};function Zt(t){var e=Ge(t);return v(v({id:A(t)?t:e.id},e),{type:e.type})}function Ri(t){return A(t)?{type:Fe,event:t}:vt(t,{to:ge.Internal})}function cc(t){return{type:Fe,_event:F(t.event)}}function vt(t,e){return{to:e?e.to:void 0,type:Te,event:N(t)?t:dt(t),delay:e?e.delay:void 0,id:e&&e.id!==void 0?e.id:N(t)?t.name:Jt(t)}}function fc(t,e,r,n){var i={_event:r},s=F(N(t.event)?t.event(e,r.data,i):t.event),o;if(A(t.delay)){var a=n&&n[t.delay];o=N(a)?a(e,r.data,i):a}else o=N(t.delay)?t.delay(e,r.data,i):t.delay;var c=N(t.to)?t.to(e,r.data,i):t.to;return v(v({},t),{to:c,_event:s,event:s.data,delay:o})}var lc=function(t,e,r){return v(v({},t),{value:A(t.expr)?t.expr:t.expr(e,r.data,{_event:r})})},Ai=function(t){return{type:jt,sendId:t}};function Oi(t){var e=Zt(t);return{type:P.Start,activity:e,exec:void 0}}function Ci(t){var e=N(t)?t:Zt(t);return{type:P.Stop,activity:e,exec:void 0}}function dc(t,e,r){var n=N(t.activity)?t.activity(e,r.data):t.activity,i=typeof n=="string"?{id:n}:n,s={type:P.Stop,activity:i};return s}var Pi=function(t){return{type:Bt,assignment:t}};function Ni(t,e){var r=e?"#".concat(e):"";return"".concat(P.After,"(").concat(t,")").concat(r)}function yt(t,e){var r="".concat(P.DoneState,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Oe(t,e){var r="".concat(P.DoneInvoke,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Ce(t,e){var r="".concat(P.ErrorPlatform,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Qt(t,e,r,n,i,s){s===void 0&&(s=!1);var o=R(s?[[],i]:$t(i,function(l){return l.type===Bt}),2),a=o[0],c=o[1],f=a.length?Lr(r,n,a,e):r,u=s?[r]:void 0,d=q(c.map(function(l){var h;switch(l.type){case Fe:return cc(l);case Te:var g=fc(l,f,n,t.options.delays);return D||L(!A(l.delay)||typeof g.delay=="number","No delay reference for delay expression '".concat(l.delay,"' was found on machine '").concat(t.id,"'")),g;case Ft:return lc(l,f,n);case li:{var E=l,p=(h=E.conds.find(function(U){var V=Wt(U.cond,t.options.guards);return!V||Kt(t,V,f,n,e)}))===null||h===void 0?void 0:h.actions;if(!p)return[];var w=R(Qt(t,e,f,n,mt(te(p),t.options.actions),s),2),y=w[0],x=w[1];return f=x,u==null||u.push(f),y}case di:{var p=l.get(f,n.data);if(!p)return[];var C=R(Qt(t,e,f,n,mt(te(p),t.options.actions),s),2),I=C[0],B=C[1];return f=B,u==null||u.push(f),I}case Be:return dc(l,f,n);case Bt:{f=Lr(f,n,[l],e),u==null||u.push(f);break}default:var T=Ge(l,t.options.actions),S=T.exec;if(S&&u){var O=u.length-1;T=v(v({},T),{exec:function(U){for(var V=[],Q=1;Q<arguments.length;Q++)V[Q-1]=arguments[Q];S.apply(void 0,_([u[O]],R(V),!1))}})}return T}}).filter(function(l){return!!l}));return[d,f]}var Ii=[],Pe=function(t,e){Ii.push(t);var r=e(t);return Ii.pop(),r};function _i(t){var e;return e={id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},getSnapshot:function(){},toJSON:function(){return{id:t}}},e[ce]=function(){return this},e}function ki(t,e,r,n){var i,s=Xt(t.src),o=(i=e==null?void 0:e.options.services)===null||i===void 0?void 0:i[s.type],a=t.data?be(t.data,r,n):void 0,c=o?qi(o,t.id,a):_i(t.id);return c.meta=t,c}function qi(t,e,r){var n=_i(e);if(n.deferred=!0,fe(t)){var i=n.state=Pe(void 0,function(){return(r?t.withContext(r):t).initialState});n.getSnapshot=function(){return i}}return n}function hc(t){try{return typeof t.send=="function"}catch{return!1}}function Di(t){return hc(t)&&"id"in t}function Ui(t){var e;return v((e={subscribe:function(){return{unsubscribe:function(){}}},id:"anonymous",getSnapshot:function(){}},e[ce]=function(){return this},e),t)}var gt=function(t){return t.type==="atomic"||t.type==="final"};function Ne(t){return Object.keys(t.states).map(function(e){return t.states[e]})}function Br(t){var e=[t];return gt(t)?e:e.concat(q(Ne(t).map(Br)))}function Ie(t,e){var r,n,i,s,o,a,c,f,u=new Set(t),d=jr(u),l=new Set(e);try{for(var h=b(l),g=h.next();!g.done;g=h.next())for(var E=g.value,p=E.parent;p&&!l.has(p);)l.add(p),p=p.parent}catch(O){r={error:O}}finally{try{g&&!g.done&&(n=h.return)&&n.call(h)}finally{if(r)throw r.error}}var w=jr(l);try{for(var y=b(l),x=y.next();!x.done;x=y.next()){var E=x.value;if(E.type==="compound"&&(!w.get(E)||!w.get(E).length))d.get(E)?d.get(E).forEach(function(U){return l.add(U)}):E.initialStateNodes.forEach(function(U){return l.add(U)});else if(E.type==="parallel")try{for(var C=(o=void 0,b(Ne(E))),I=C.next();!I.done;I=C.next()){var B=I.value;B.type!=="history"&&(l.has(B)||(l.add(B),d.get(B)?d.get(B).forEach(function(U){return l.add(U)}):B.initialStateNodes.forEach(function(U){return l.add(U)})))}}catch(U){o={error:U}}finally{try{I&&!I.done&&(a=C.return)&&a.call(C)}finally{if(o)throw o.error}}}}catch(O){i={error:O}}finally{try{x&&!x.done&&(s=y.return)&&s.call(y)}finally{if(i)throw i.error}}try{for(var T=b(l),S=T.next();!S.done;S=T.next())for(var E=S.value,p=E.parent;p&&!l.has(p);)l.add(p),p=p.parent}catch(O){c={error:O}}finally{try{S&&!S.done&&(f=T.return)&&f.call(T)}finally{if(c)throw c.error}}return l}function Mi(t,e){var r=e.get(t);if(!r)return{};if(t.type==="compound"){var n=r[0];if(n){if(gt(n))return n.key}else return{}}var i={};return r.forEach(function(s){i[s.key]=Mi(s,e)}),i}function jr(t){var e,r,n=new Map;try{for(var i=b(t),s=i.next();!s.done;s=i.next()){var o=s.value;n.has(o)||n.set(o,[]),o.parent&&(n.has(o.parent)||n.set(o.parent,[]),n.get(o.parent).push(o))}}catch(a){e={error:a}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return n}function Li(t,e){var r=Ie([t],e);return Mi(t,jr(r))}function Et(t,e){return Array.isArray(t)?t.some(function(r){return r===e}):t instanceof Set?t.has(e):!1}function ji(t){return _([],R(new Set(q(_([],R(t.map(function(e){return e.ownEvents})),!1)))),!1)}function _e(t,e){return e.type==="compound"?Ne(e).some(function(r){return r.type==="final"&&Et(t,r)}):e.type==="parallel"?Ne(e).every(function(r){return _e(t,r)}):!1}function Bi(t){return t===void 0&&(t=[]),t.reduce(function(e,r){return r.meta!==void 0&&(e[r.id]=r.meta),e},{})}function Fr(t){return new Set(q(t.map(function(e){return e.tags})))}function Vr(t,e){if(t===e)return!0;if(t===void 0||e===void 0)return!1;if(A(t)||A(e))return t===e;var r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&r.every(function(i){return Vr(t[i],e[i])})}function Fi(t){return typeof t!="object"||t===null?!1:"value"in t&&"_event"in t}function Vi(t,e){var r=t.exec,n=v(v({},t),{exec:r!==void 0?function(){return r(e.context,e.event,{action:t,state:e,_event:e._event})}:void 0});return n}var se=function(){function t(e){var r=this,n;this.actions=[],this.activities=Dr,this.meta={},this.events=[],this.value=e.value,this.context=e.context,this._event=e._event,this._sessionid=e._sessionid,this.event=this._event.data,this.historyValue=e.historyValue,this.history=e.history,this.actions=e.actions||[],this.activities=e.activities||Dr,this.meta=Bi(e.configuration),this.events=e.events||[],this.matches=this.matches.bind(this),this.toStrings=this.toStrings.bind(this),this.configuration=e.configuration,this.transitions=e.transitions,this.children=e.children,this.done=!!e.done,this.tags=(n=Array.isArray(e.tags)?new Set(e.tags):e.tags)!==null&&n!==void 0?n:new Set,this.machine=e.machine,Object.defineProperty(this,"nextEvents",{get:function(){return ji(r.configuration)}})}return t.from=function(e,r){if(e instanceof t)return e.context!==r?new t({value:e.value,context:r,_event:e._event,_sessionid:null,historyValue:e.historyValue,history:e.history,actions:[],activities:e.activities,meta:{},events:[],configuration:[],transitions:[],children:{}}):e;var n=Ae;return new t({value:e,context:r,_event:n,_sessionid:null,historyValue:void 0,history:void 0,actions:[],activities:void 0,meta:void 0,events:[],configuration:[],transitions:[],children:{}})},t.create=function(e){return new t(e)},t.inert=function(e,r){if(e instanceof t){if(!e.actions.length)return e;var n=Ae;return new t({value:e.value,context:r,_event:n,_sessionid:null,historyValue:e.historyValue,history:e.history,activities:e.activities,configuration:e.configuration,transitions:[],children:{}})}return t.from(e,r)},t.prototype.toStrings=function(e,r){var n=this;if(e===void 0&&(e=this.value),r===void 0&&(r="."),A(e))return[e];var i=Object.keys(e);return i.concat.apply(i,_([],R(i.map(function(s){return n.toStrings(e[s],r).map(function(o){return s+r+o})})),!1))},t.prototype.toJSON=function(){var e=this;e.configuration,e.transitions;var r=e.tags;e.machine;var n=je(e,["configuration","transitions","tags","machine"]);return v(v({},n),{tags:Array.from(r)})},t.prototype.matches=function(e){return ft(e,this.value)},t.prototype.hasTag=function(e){return this.tags.has(e)},t.prototype.can=function(e){var r;D&&L(!!this.machine,"state.can(...) used outside of a machine-created State object; this will always return false.");var n=(r=this.machine)===null||r===void 0?void 0:r.getTransitionData(this,e);return!!(n!=null&&n.transitions.length)&&n.transitions.some(function(i){return i.target!==void 0||i.actions.length})},t}();var pc={deferEvents:!1},Hr=function(){function t(e){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=v(v({},pc),e)}return t.prototype.initialize=function(e){if(this.initialized=!0,e){if(!this.options.deferEvents){this.schedule(e);return}this.process(e)}this.flushEvents()},t.prototype.schedule=function(e){if(!this.initialized||this.processingEvent){this.queue.push(e);return}if(this.queue.length!==0)throw new Error("Event queue should be empty when it is not processing events");this.process(e),this.flushEvents()},t.prototype.clear=function(){this.queue=[]},t.prototype.flushEvents=function(){for(var e=this.queue.shift();e;)this.process(e),e=this.queue.shift()},t.prototype.process=function(e){this.processingEvent=!0;try{e()}catch(r){throw this.clear(),r}finally{this.processingEvent=!1}},t}();var Gr=new Map,mc=0,St={bookId:function(){return"x:".concat(mc++)},register:function(t,e){return Gr.set(t,e),t},get:function(t){return Gr.get(t)},free:function(t){Gr.delete(t)}};function er(){if(typeof globalThis!="undefined")return globalThis;if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;D||console.warn("XState could not find a global object in this environment. Please let the maintainers know and raise an issue here: https://github.com/statelyai/xstate/issues")}function vc(){var t=er();if(t&&"__xstate__"in t)return t.__xstate__}function Hi(t){if(!!er()){var e=vc();e&&e.register(t)}}function Gi(t,e){e===void 0&&(e={});var r=t.initialState,n=new Set,i=[],s=!1,o=function(){if(!s){for(s=!0;i.length>0;){var f=i.shift();r=t.transition(r,f,c),n.forEach(function(u){return u.next(r)})}s=!1}},a=Ui({id:e.id,send:function(f){i.push(f),o()},getSnapshot:function(){return r},subscribe:function(f,u,d){var l=ht(f,u,d);return n.add(l),l.next(r),{unsubscribe:function(){n.delete(l)}}}}),c={parent:e.parent,self:a,id:e.id||"anonymous",observers:n};return r=t.start?t.start(c):r,a}var yc={sync:!1,autoForward:!1},z;(function(t){t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped"})(z||(z={}));var Ji=function(){function t(e,r){var n=this;r===void 0&&(r=t.defaultOptions),this.machine=e,this.scheduler=new Hr,this.delayedEventsMap={},this.listeners=new Set,this.contextListeners=new Set,this.stopListeners=new Set,this.doneListeners=new Set,this.eventListeners=new Set,this.sendListeners=new Set,this.initialized=!1,this.status=z.NotStarted,this.children=new Map,this.forwardTo=new Set,this.init=this.start,this.send=function(u,d){if(pe(u))return n.batch(u),n.state;var l=F(dt(u,d));if(n.status===z.Stopped)return D||L(!1,'Event "'.concat(l.name,'" was sent to stopped service "').concat(n.machine.id,`". This service has already reached its final state, and will not transition.
5
+ Event: `).concat(JSON.stringify(l.data))),n.state;if(n.status!==z.Running&&!n.options.deferEvents)throw new Error('Event "'.concat(l.name,'" was sent to uninitialized service "').concat(n.machine.id,`". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.
6
+ Event: `).concat(JSON.stringify(l.data)));return n.scheduler.schedule(function(){n.forward(l);var h=n.nextState(l);n.update(h,l)}),n._state},this.sendTo=function(u,d){var l=n.parent&&(d===ge.Parent||n.parent.id===d),h=l?n.parent:A(d)?n.children.get(d)||St.get(d):xi(d)?d:void 0;if(!h){if(!l)throw new Error("Unable to send event to child '".concat(d,"' from service '").concat(n.id,"'."));D||L(!1,"Service '".concat(n.id,"' has no parent: unable to send event ").concat(u.type));return}"machine"in h?h.send(v(v({},u),{name:u.name===qr?"".concat(Ce(n.id)):u.name,origin:n.sessionId})):h.send(u.data)};var i=v(v({},t.defaultOptions),r),s=i.clock,o=i.logger,a=i.parent,c=i.id,f=c!==void 0?c:e.id;this.id=f,this.logger=o,this.clock=s,this.parent=a,this.options=i,this.scheduler=new Hr({deferEvents:this.options.deferEvents}),this.sessionId=St.bookId()}return Object.defineProperty(t.prototype,"initialState",{get:function(){var e=this;return this._initialState?this._initialState:Pe(this,function(){return e._initialState=e.machine.initialState,e._initialState})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return D||L(this.status!==z.NotStarted,"Attempted to read state from uninitialized service '".concat(this.id,"'. Make sure the service is started first.")),this._state},enumerable:!1,configurable:!0}),t.prototype.execute=function(e,r){var n,i;try{for(var s=b(e.actions),o=s.next();!o.done;o=s.next()){var a=o.value;this.exec(a,e,r)}}catch(c){n={error:c}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}},t.prototype.update=function(e,r){var n,i,s,o,a,c,f,u,d=this;if(e._sessionid=this.sessionId,this._state=e,this.options.execute&&this.execute(this.state),this.children.forEach(function(O){d.state.children[O.id]=O}),this.devTools&&this.devTools.send(r.data,e),e.event)try{for(var l=b(this.eventListeners),h=l.next();!h.done;h=l.next()){var g=h.value;g(e.event)}}catch(O){n={error:O}}finally{try{h&&!h.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}try{for(var E=b(this.listeners),p=E.next();!p.done;p=E.next()){var g=p.value;g(e,e.event)}}catch(O){s={error:O}}finally{try{p&&!p.done&&(o=E.return)&&o.call(E)}finally{if(s)throw s.error}}try{for(var w=b(this.contextListeners),y=w.next();!y.done;y=w.next()){var x=y.value;x(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(O){a={error:O}}finally{try{y&&!y.done&&(c=w.return)&&c.call(w)}finally{if(a)throw a.error}}var C=_e(e.configuration||[],this.machine);if(this.state.configuration&&C){var I=e.configuration.find(function(O){return O.type==="final"&&O.parent===d.machine}),B=I&&I.doneData?be(I.doneData,e.context,r):void 0;try{for(var T=b(this.doneListeners),S=T.next();!S.done;S=T.next()){var g=S.value;g(Oe(this.id,B))}}catch(O){f={error:O}}finally{try{S&&!S.done&&(u=T.return)&&u.call(T)}finally{if(f)throw f.error}}this.stop()}},t.prototype.onTransition=function(e){return this.listeners.add(e),this.status===z.Running&&e(this.state,this.state.event),this},t.prototype.subscribe=function(e,r,n){var i=this;if(!e)return{unsubscribe:function(){}};var s,o=n;return typeof e=="function"?s=e:(s=e.next.bind(e),o=e.complete.bind(e)),this.listeners.add(s),this.status===z.Running&&s(this.state),o&&this.onDone(o),{unsubscribe:function(){s&&i.listeners.delete(s),o&&i.doneListeners.delete(o)}}},t.prototype.onEvent=function(e){return this.eventListeners.add(e),this},t.prototype.onSend=function(e){return this.sendListeners.add(e),this},t.prototype.onChange=function(e){return this.contextListeners.add(e),this},t.prototype.onStop=function(e){return this.stopListeners.add(e),this},t.prototype.onDone=function(e){return this.doneListeners.add(e),this},t.prototype.off=function(e){return this.listeners.delete(e),this.eventListeners.delete(e),this.sendListeners.delete(e),this.stopListeners.delete(e),this.doneListeners.delete(e),this.contextListeners.delete(e),this},t.prototype.start=function(e){var r=this;if(this.status===z.Running)return this;this.machine._init(),St.register(this.sessionId,this),this.initialized=!0,this.status=z.Running;var n=e===void 0?this.initialState:Pe(this,function(){return Fi(e)?r.machine.resolveState(e):r.machine.resolveState(se.from(e,r.machine.context))});return this.options.devTools&&this.attachDev(),this.scheduler.initialize(function(){r.update(n,Ae)}),this},t.prototype.stop=function(){var e,r,n,i,s,o,a,c,f,u,d=this;try{for(var l=b(this.listeners),h=l.next();!h.done;h=l.next()){var g=h.value;this.listeners.delete(g)}}catch(S){e={error:S}}finally{try{h&&!h.done&&(r=l.return)&&r.call(l)}finally{if(e)throw e.error}}try{for(var E=b(this.stopListeners),p=E.next();!p.done;p=E.next()){var g=p.value;g(),this.stopListeners.delete(g)}}catch(S){n={error:S}}finally{try{p&&!p.done&&(i=E.return)&&i.call(E)}finally{if(n)throw n.error}}try{for(var w=b(this.contextListeners),y=w.next();!y.done;y=w.next()){var g=y.value;this.contextListeners.delete(g)}}catch(S){s={error:S}}finally{try{y&&!y.done&&(o=w.return)&&o.call(w)}finally{if(s)throw s.error}}try{for(var x=b(this.doneListeners),C=x.next();!C.done;C=x.next()){var g=C.value;this.doneListeners.delete(g)}}catch(S){a={error:S}}finally{try{C&&!C.done&&(c=x.return)&&c.call(x)}finally{if(a)throw a.error}}if(!this.initialized)return this;_([],R(this.state.configuration),!1).sort(function(S,O){return O.order-S.order}).forEach(function(S){var O,U;try{for(var V=b(S.definition.exit),Q=V.next();!Q.done;Q=V.next()){var ye=Q.value;d.exec(ye,d.state)}}catch(Mt){O={error:Mt}}finally{try{Q&&!Q.done&&(U=V.return)&&U.call(V)}finally{if(O)throw O.error}}}),this.children.forEach(function(S){N(S.stop)&&S.stop()});try{for(var I=b(Object.keys(this.delayedEventsMap)),B=I.next();!B.done;B=I.next()){var T=B.value;this.clock.clearTimeout(this.delayedEventsMap[T])}}catch(S){f={error:S}}finally{try{B&&!B.done&&(u=I.return)&&u.call(I)}finally{if(f)throw f.error}}return this.scheduler.clear(),this.initialized=!1,this.status=z.Stopped,St.free(this.sessionId),this},t.prototype.batch=function(e){var r=this;if(this.status===z.NotStarted&&this.options.deferEvents)D||L(!1,"".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,`" and are deferred. Make sure .start() is called for this service.
7
+ Event: `).concat(JSON.stringify(event)));else if(this.status!==z.Running)throw new Error("".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.'));this.scheduler.schedule(function(){var n,i,s=r.state,o=!1,a=[],c=function(l){var h=F(l);r.forward(h),s=Pe(r,function(){return r.machine.transition(s,h)}),a.push.apply(a,_([],R(s.actions.map(function(g){return Vi(g,s)})),!1)),o=o||!!s.changed};try{for(var f=b(e),u=f.next();!u.done;u=f.next()){var d=u.value;c(d)}}catch(l){n={error:l}}finally{try{u&&!u.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}s.changed=o,s.actions=a,r.update(s,F(e[e.length-1]))})},t.prototype.sender=function(e){return this.send.bind(this,e)},t.prototype.nextState=function(e){var r=this,n=F(e);if(n.name.indexOf(kr)===0&&!this.state.nextEvents.some(function(s){return s.indexOf(kr)===0}))throw n.data.data;var i=Pe(this,function(){return r.machine.transition(r.state,n)});return i},t.prototype.forward=function(e){var r,n;try{for(var i=b(this.forwardTo),s=i.next();!s.done;s=i.next()){var o=s.value,a=this.children.get(o);if(!a)throw new Error("Unable to forward event '".concat(e,"' from interpreter '").concat(this.id,"' to nonexistant child '").concat(o,"'."));a.send(e)}}catch(c){r={error:c}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}},t.prototype.defer=function(e){var r=this;this.delayedEventsMap[e.id]=this.clock.setTimeout(function(){e.to?r.sendTo(e._event,e.to):r.send(e._event)},e.delay)},t.prototype.cancel=function(e){this.clock.clearTimeout(this.delayedEventsMap[e]),delete this.delayedEventsMap[e]},t.prototype.exec=function(e,r,n){n===void 0&&(n=this.machine.options.actions);var i=r.context,s=r._event,o=e.exec||Yt(e.type,n),a=N(o)?o:o?o.exec:e.exec;if(a)try{return a(i,s.data,{action:e,state:this.state,_event:s})}catch(C){throw this.parent&&this.parent.send({type:"xstate.error",data:C}),C}switch(e.type){case Te:var c=e;if(typeof c.delay=="number"){this.defer(c);return}else c.to?this.sendTo(c._event,c.to):this.send(c._event);break;case jt:this.cancel(e.sendId);break;case ot:{if(this.status!==z.Running)return;var f=e.activity;if(!this.state.activities[f.id||f.type])break;if(f.type===P.Invoke){var u=Xt(f.src),d=this.machine.options.services?this.machine.options.services[u.type]:void 0,l=f.id,h=f.data;D||L(!("forward"in f),"`forward` property is deprecated (found in invocation of '".concat(f.src,"' in in machine '").concat(this.machine.id,"'). ")+"Please use `autoForward` instead.");var g="autoForward"in f?f.autoForward:!!f.forward;if(!d){D||L(!1,"No service found for invocation '".concat(f.src,"' in machine '").concat(this.machine.id,"'."));return}var E=h?be(h,i,s):void 0;if(typeof d=="string")return;var p=N(d)?d(i,s.data,{data:E,src:u,meta:f.meta}):d;if(!p)return;var w=void 0;fe(p)&&(p=E?p.withContext(E):p,w={autoForward:g}),this.spawn(p,l,w)}else this.spawnActivity(f);break}case Be:{this.stopChild(e.activity.id);break}case Ft:var y=e.label,x=e.value;y?this.logger(y,x):this.logger(x);break;default:D||L(!1,"No implementation found for action type '".concat(e.type,"'"));break}},t.prototype.removeChild=function(e){var r;this.children.delete(e),this.forwardTo.delete(e),(r=this.state)===null||r===void 0||delete r.children[e]},t.prototype.stopChild=function(e){var r=this.children.get(e);!r||(this.removeChild(e),N(r.stop)&&r.stop())},t.prototype.spawn=function(e,r,n){if(Mr(e))return this.spawnPromise(Promise.resolve(e),r);if(N(e))return this.spawnCallback(e,r);if(Di(e))return this.spawnActor(e,r);if(wi(e))return this.spawnObservable(e,r);if(fe(e))return this.spawnMachine(e,v(v({},n),{id:r}));if(gi(e))return this.spawnBehavior(e,r);throw new Error('Unable to spawn entity "'.concat(r,'" of type "').concat(typeof e,'".'))},t.prototype.spawnMachine=function(e,r){var n=this;r===void 0&&(r={});var i=new t(e,v(v({},this.options),{parent:this,id:r.id||e.id})),s=v(v({},yc),r);s.sync&&i.onTransition(function(a){n.send(ut,{state:a,id:i.id})});var o=i;return this.children.set(i.id,o),s.autoForward&&this.forwardTo.add(i.id),i.onDone(function(a){n.removeChild(i.id),n.send(F(a,{origin:i.id}))}).start(),o},t.prototype.spawnBehavior=function(e,r){var n=Gi(e,{id:r,parent:this});return this.children.set(r,n),n},t.prototype.spawnPromise=function(e,r){var n,i=this,s=!1,o;e.then(function(c){s||(o=c,i.removeChild(r),i.send(F(Oe(r,c),{origin:r})))},function(c){if(!s){i.removeChild(r);var f=Ce(r,c);try{i.send(F(f,{origin:r}))}catch(u){bi(c,u,r),i.devTools&&i.devTools.send(f,i.state),i.machine.strict&&i.stop()}}});var a=(n={id:r,send:function(){},subscribe:function(c,f,u){var d=ht(c,f,u),l=!1;return e.then(function(h){l||(d.next(h),!l&&d.complete())},function(h){l||d.error(h)}),{unsubscribe:function(){return l=!0}}},stop:function(){s=!0},toJSON:function(){return{id:r}},getSnapshot:function(){return o}},n[ce]=function(){return this},n);return this.children.set(r,a),a},t.prototype.spawnCallback=function(e,r){var n,i=this,s=!1,o=new Set,a=new Set,c,f=function(l){c=l,a.forEach(function(h){return h(l)}),!s&&i.send(F(l,{origin:r}))},u;try{u=e(f,function(l){o.add(l)})}catch(l){this.send(Ce(r,l))}if(Mr(u))return this.spawnPromise(u,r);var d=(n={id:r,send:function(l){return o.forEach(function(h){return h(l)})},subscribe:function(l){var h=ht(l);return a.add(h.next),{unsubscribe:function(){a.delete(h.next)}}},stop:function(){s=!0,N(u)&&u()},toJSON:function(){return{id:r}},getSnapshot:function(){return c}},n[ce]=function(){return this},n);return this.children.set(r,d),d},t.prototype.spawnObservable=function(e,r){var n,i=this,s,o=e.subscribe(function(c){s=c,i.send(F(c,{origin:r}))},function(c){i.removeChild(r),i.send(F(Ce(r,c),{origin:r}))},function(){i.removeChild(r),i.send(F(Oe(r),{origin:r}))}),a=(n={id:r,send:function(){},subscribe:function(c,f,u){return e.subscribe(c,f,u)},stop:function(){return o.unsubscribe()},getSnapshot:function(){return s},toJSON:function(){return{id:r}}},n[ce]=function(){return this},n);return this.children.set(r,a),a},t.prototype.spawnActor=function(e,r){return this.children.set(r,e),e},t.prototype.spawnActivity=function(e){var r=this.machine.options&&this.machine.options.activities?this.machine.options.activities[e.type]:void 0;if(!r){D||L(!1,"No implementation found for activity '".concat(e.type,"'"));return}var n=r(this.state.context,e);this.spawnEffect(e.id,n)},t.prototype.spawnEffect=function(e,r){var n;this.children.set(e,(n={id:e,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},stop:r||void 0,getSnapshot:function(){},toJSON:function(){return{id:e}}},n[ce]=function(){return this},n))},t.prototype.attachDev=function(){var e=er();if(this.options.devTools&&e){if(e.__REDUX_DEVTOOLS_EXTENSION__){var r=typeof this.options.devTools=="object"?this.options.devTools:void 0;this.devTools=e.__REDUX_DEVTOOLS_EXTENSION__.connect(v(v({name:this.id,autoPause:!0,stateSanitizer:function(n){return{value:n.value,context:n.context,actions:n.actions}}},r),{features:v({jump:!1,skip:!1},r?r.features:void 0)}),this.machine),this.devTools.init(this.state)}Hi(this)}},t.prototype.toJSON=function(){return{id:this.id}},t.prototype[ce]=function(){return this},t.prototype.getSnapshot=function(){return this.status===z.NotStarted?this.initialState:this._state},t.defaultOptions={execute:!0,deferEvents:!0,clock:{setTimeout:function(e,r){return setTimeout(e,r)},clearTimeout:function(e){return clearTimeout(e)}},logger:console.log.bind(console),devTools:!1},t.interpret=me,t}();function me(t,e){var r=new Ji(t,e);return r}function gc(t){if(typeof t=="string"){var e={type:t};return e.toString=function(){return t},e}return t}function wt(t){return v(v({type:at},t),{toJSON:function(){t.onDone,t.onError;var e=je(t,["onDone","onError"]);return v(v({},e),{type:at,src:gc(t.src)})}})}var $e="",Jr="#",xt="*",Je={},ze=function(t){return t[0]===Jr},Ec=function(){return{actions:{},guards:{},services:{},activities:{},delays:{}}},Sc=function(t,e,r){var n=r.slice(0,-1).some(function(s){return!("cond"in s)&&!("in"in s)&&(A(s.target)||fe(s.target))}),i=e===$e?"the transient event":"event '".concat(e,"'");L(!n,"One or more transitions for ".concat(i," on state '").concat(t.id,"' are unreachable. ")+"Make sure that the default transition is the last one defined.")},zi=function(){function t(e,r,n,i){var s=this;n===void 0&&(n="context"in e?e.context:void 0);var o;this.config=e,this._context=n,this.order=-1,this.__xstatenode=!0,this.__cache={events:void 0,relativeValue:new Map,initialStateValue:void 0,initialState:void 0,on:void 0,transitions:void 0,candidates:{},delayedTransitions:void 0},this.idMap={},this.tags=[],this.options=Object.assign(Ec(),r),this.parent=i==null?void 0:i.parent,this.key=this.config.key||(i==null?void 0:i.key)||this.config.id||"(machine)",this.machine=this.parent?this.parent.machine:this,this.path=this.parent?this.parent.path.concat(this.key):[],this.delimiter=this.config.delimiter||(this.parent?this.parent.delimiter:Vt),this.id=this.config.id||_([this.machine.key],R(this.path),!1).join(this.delimiter),this.version=this.parent?this.parent.version:this.config.version,this.type=this.config.type||(this.config.parallel?"parallel":this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.schema=this.parent?this.machine.schema:(o=this.config.schema)!==null&&o!==void 0?o:{},this.description=this.config.description,D||L(!("parallel"in this.config),'The "parallel" property is deprecated and will be removed in version 4.1. '.concat(this.config.parallel?"Replace with `type: 'parallel'`":"Use `type: '".concat(this.type,"'`")," in the config for state node '").concat(this.id,"' instead.")),this.initial=this.config.initial,this.states=this.config.states?He(this.config.states,function(f,u){var d,l=new t(f,{},void 0,{parent:s,key:u});return Object.assign(s.idMap,v((d={},d[l.id]=l,d),l.idMap)),l}):Je;var a=0;function c(f){var u,d;f.order=a++;try{for(var l=b(Ne(f)),h=l.next();!h.done;h=l.next()){var g=h.value;c(g)}}catch(E){u={error:E}}finally{try{h&&!h.done&&(d=l.return)&&d.call(l)}finally{if(u)throw u.error}}}c(this),this.history=this.config.history===!0?"shallow":this.config.history||!1,this._transient=!!this.config.always||(this.config.on?Array.isArray(this.config.on)?this.config.on.some(function(f){var u=f.event;return u===$e}):$e in this.config.on:!1),this.strict=!!this.config.strict,this.onEntry=te(this.config.entry||this.config.onEntry).map(function(f){return Ge(f)}),this.onExit=te(this.config.exit||this.config.onExit).map(function(f){return Ge(f)}),this.meta=this.config.meta,this.doneData=this.type==="final"?this.config.data:void 0,this.invoke=te(this.config.invoke).map(function(f,u){var d,l;if(fe(f)){var h=pt(s.id,u);return s.machine.options.services=v((d={},d[h]=f,d),s.machine.options.services),wt({src:h,id:h})}else if(A(f.src)){var h=f.id||pt(s.id,u);return wt(v(v({},f),{id:h,src:f.src}))}else if(fe(f.src)||N(f.src)){var h=f.id||pt(s.id,u);return s.machine.options.services=v((l={},l[h]=f.src,l),s.machine.options.services),wt(v(v({id:h},f),{src:h}))}else{var g=f.src;return wt(v(v({id:pt(s.id,u)},f),{src:g}))}}),this.activities=te(this.config.activities).concat(this.invoke).map(function(f){return Zt(f)}),this.transition=this.transition.bind(this),this.tags=te(this.config.tags)}return t.prototype._init=function(){this.__cache.transitions||Br(this).forEach(function(e){return e.on})},t.prototype.withConfig=function(e,r){var n=this.options,i=n.actions,s=n.activities,o=n.guards,a=n.services,c=n.delays;return new t(this.config,{actions:v(v({},i),e.actions),activities:v(v({},s),e.activities),guards:v(v({},o),e.guards),services:v(v({},a),e.services),delays:v(v({},c),e.delays)},r!=null?r:this.context)},t.prototype.withContext=function(e){return new t(this.config,this.options,e)},Object.defineProperty(t.prototype,"context",{get:function(){return N(this._context)?this._context():this._context},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"definition",{get:function(){return{id:this.id,key:this.key,version:this.version,context:this.context,type:this.type,initial:this.initial,history:this.history,states:He(this.states,function(e){return e.definition}),on:this.on,transitions:this.transitions,entry:this.onEntry,exit:this.onExit,activities:this.activities||[],meta:this.meta,order:this.order||-1,data:this.doneData,invoke:this.invoke,description:this.description,tags:this.tags}},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return this.definition},Object.defineProperty(t.prototype,"on",{get:function(){if(this.__cache.on)return this.__cache.on;var e=this.transitions;return this.__cache.on=e.reduce(function(r,n){return r[n.eventType]=r[n.eventType]||[],r[n.eventType].push(n),r},{})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"after",{get:function(){return this.__cache.delayedTransitions||(this.__cache.delayedTransitions=this.getDelayedTransitions(),this.__cache.delayedTransitions)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transitions",{get:function(){return this.__cache.transitions||(this.__cache.transitions=this.formatTransitions(),this.__cache.transitions)},enumerable:!1,configurable:!0}),t.prototype.getCandidates=function(e){if(this.__cache.candidates[e])return this.__cache.candidates[e];var r=e===$e,n=this.transitions.filter(function(i){var s=i.eventType===e;return r?s:s||i.eventType===xt});return this.__cache.candidates[e]=n,n},t.prototype.getDelayedTransitions=function(){var e=this,r=this.config.after;if(!r)return[];var n=function(s,o){var a=N(s)?"".concat(e.id,":delay[").concat(o,"]"):s,c=Ni(a,e.id);return e.onEntry.push(vt(c,{delay:s})),e.onExit.push(Ai(c)),c},i=pe(r)?r.map(function(s,o){var a=n(s.delay,o);return v(v({},s),{event:a})}):q(Object.keys(r).map(function(s,o){var a=r[s],c=A(a)?{target:a}:a,f=isNaN(+s)?s:+s,u=n(f,o);return te(c).map(function(d){return v(v({},d),{event:u,delay:f})})}));return i.map(function(s){var o=s.delay;return v(v({},e.formatTransition(s)),{delay:o})})},t.prototype.getStateNodes=function(e){var r,n=this;if(!e)return[];var i=e instanceof se?e.value:Ve(e,this.delimiter);if(A(i)){var s=this.getStateNode(i).initial;return s!==void 0?this.getStateNodes((r={},r[i]=s,r)):[this,this.states[i]]}var o=Object.keys(i),a=[this];return a.push.apply(a,_([],R(q(o.map(function(c){return n.getStateNode(c).getStateNodes(i[c])}))),!1)),a},t.prototype.handles=function(e){var r=Jt(e);return this.events.includes(r)},t.prototype.resolveState=function(e){var r=e instanceof se?e:se.create(e),n=Array.from(Ie([],this.getStateNodes(r.value)));return new se(v(v({},r),{value:this.resolve(r.value),configuration:n,done:_e(n,this),tags:Fr(n),machine:this.machine}))},t.prototype.transitionLeafNode=function(e,r,n){var i=this.getStateNode(e),s=i.next(r,n);return!s||!s.transitions.length?this.next(r,n):s},t.prototype.transitionCompoundNode=function(e,r,n){var i=Object.keys(e),s=this.getStateNode(i[0]),o=s._transition(e[i[0]],r,n);return!o||!o.transitions.length?this.next(r,n):o},t.prototype.transitionParallelNode=function(e,r,n){var i,s,o={};try{for(var a=b(Object.keys(e)),c=a.next();!c.done;c=a.next()){var f=c.value,u=e[f];if(!!u){var d=this.getStateNode(f),l=d._transition(u,r,n);l&&(o[f]=l)}}}catch(y){i={error:y}}finally{try{c&&!c.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}var h=Object.keys(o).map(function(y){return o[y]}),g=q(h.map(function(y){return y.transitions})),E=h.some(function(y){return y.transitions.length>0});if(!E)return this.next(r,n);var p=q(h.map(function(y){return y.entrySet})),w=q(Object.keys(o).map(function(y){return o[y].configuration}));return{transitions:g,entrySet:p,exitSet:q(h.map(function(y){return y.exitSet})),configuration:w,source:r,actions:q(Object.keys(o).map(function(y){return o[y].actions}))}},t.prototype._transition=function(e,r,n){return A(e)?this.transitionLeafNode(e,r,n):Object.keys(e).length===1?this.transitionCompoundNode(e,r,n):this.transitionParallelNode(e,r,n)},t.prototype.getTransitionData=function(e,r){return this._transition(e.value,e,F(r))},t.prototype.next=function(e,r){var n,i,s=this,o=r.name,a=[],c=[],f;try{for(var u=b(this.getCandidates(o)),d=u.next();!d.done;d=u.next()){var l=d.value,h=l.cond,g=l.in,E=e.context,p=g?A(g)&&ze(g)?e.matches(Ve(this.getStateNodeById(g).path,this.delimiter)):ft(Ve(g,this.delimiter),pi(this.path.slice(0,-2))(e.value)):!0,w=!1;try{w=!h||Kt(this.machine,h,E,r,e)}catch(I){throw new Error("Unable to evaluate guard '".concat(h.name||h.type,"' in transition for event '").concat(o,"' in state node '").concat(this.id,`':
8
+ `).concat(I.message))}if(w&&p){l.target!==void 0&&(c=l.target),a.push.apply(a,_([],R(l.actions),!1)),f=l;break}}}catch(I){n={error:I}}finally{try{d&&!d.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}if(!!f){if(!c.length)return{transitions:[f],entrySet:[],exitSet:[],configuration:e.value?[this]:[],source:e,actions:a};var y=q(c.map(function(I){return s.getRelativeStateNodes(I,e.historyValue)})),x=!!f.internal,C=x?[]:q(y.map(function(I){return s.nodesFromChild(I)}));return{transitions:[f],entrySet:C,exitSet:x?[]:[this],configuration:y,source:e,actions:a}}},t.prototype.nodesFromChild=function(e){if(e.escapes(this))return[];for(var r=[],n=e;n&&n!==this;)r.push(n),n=n.parent;return r.push(this),r},t.prototype.escapes=function(e){if(this===e)return!1;for(var r=this.parent;r;){if(r===e)return!1;r=r.parent}return!0},t.prototype.getActions=function(e,r,n,i){var s,o,a,c,f=Ie([],i?this.getStateNodes(i.value):[this]),u=e.configuration.length?Ie(f,e.configuration):f;try{for(var d=b(u),l=d.next();!l.done;l=d.next()){var h=l.value;Et(f,h)||e.entrySet.push(h)}}catch(T){s={error:T}}finally{try{l&&!l.done&&(o=d.return)&&o.call(d)}finally{if(s)throw s.error}}try{for(var g=b(f),E=g.next();!E.done;E=g.next()){var h=E.value;(!Et(u,h)||Et(e.exitSet,h.parent))&&e.exitSet.push(h)}}catch(T){a={error:T}}finally{try{E&&!E.done&&(c=g.return)&&c.call(g)}finally{if(a)throw a.error}}var p=q(e.entrySet.map(function(T){var S=[];if(T.type!=="final")return S;var O=T.parent;if(!O.parent)return S;S.push(yt(T.id,T.doneData),yt(O.id,T.doneData?be(T.doneData,r,n):void 0));var U=O.parent;return U.type==="parallel"&&Ne(U).every(function(V){return _e(e.configuration,V)})&&S.push(yt(U.id)),S}));e.exitSet.sort(function(T,S){return S.order-T.order}),e.entrySet.sort(function(T,S){return T.order-S.order});var w=new Set(e.entrySet),y=new Set(e.exitSet),x=R([q(Array.from(w).map(function(T){return _(_([],R(T.activities.map(function(S){return Oi(S)})),!1),R(T.onEntry),!1)})).concat(p.map(Ri)),q(Array.from(y).map(function(T){return _(_([],R(T.onExit),!1),R(T.activities.map(function(S){return Ci(S)})),!1)}))],2),C=x[0],I=x[1],B=mt(I.concat(e.actions).concat(C),this.machine.options.actions);return B},t.prototype.transition=function(e,r,n){e===void 0&&(e=this.initialState);var i=F(r),s;if(e instanceof se)s=n===void 0?e:this.resolveState(se.from(e,n));else{var o=A(e)?this.resolve(ct(this.getResolvedPath(e))):this.resolve(e),a=n!=null?n:this.machine.context;s=this.resolveState(se.from(o,a))}if(!D&&i.name===xt)throw new Error("An event cannot have the wildcard type ('".concat(xt,"')"));if(this.strict&&!this.events.includes(i.name)&&!yi(i.name))throw new Error("Machine '".concat(this.id,"' does not accept event '").concat(i.name,"'"));var c=this._transition(s.value,s,i)||{transitions:[],configuration:[],entrySet:[],exitSet:[],source:s,actions:[]},f=Ie([],this.getStateNodes(s.value)),u=c.configuration.length?Ie(f,c.configuration):f;return c.configuration=_([],R(u),!1),this.resolveTransition(c,s,s.context,i)},t.prototype.resolveRaisedTransition=function(e,r,n){var i,s=e.actions;return e=this.transition(e,r),e._event=n,e.event=n.data,(i=e.actions).unshift.apply(i,_([],R(s),!1)),e},t.prototype.resolveTransition=function(e,r,n,i){var s,o,a=this;i===void 0&&(i=Ae);var c=e.configuration,f=!r||e.transitions.length>0,u=f?Li(this.machine,c):void 0,d=r?r.historyValue?r.historyValue:e.source?this.machine.historyValue(r.value):void 0:void 0,l=this.getActions(e,n,i,r),h=r?v({},r.activities):{};try{for(var g=b(l),E=g.next();!E.done;E=g.next()){var p=E.value;p.type===ot?h[p.activity.id||p.activity.type]=p:p.type===Be&&(h[p.activity.id||p.activity.type]=!1)}}catch(ee){s={error:ee}}finally{try{E&&!E.done&&(o=g.return)&&o.call(g)}finally{if(s)throw s.error}}var w=R(Qt(this,r,n,i,l,this.machine.config.preserveActionOrder),2),y=w[0],x=w[1],C=R($t(y,function(ee){return ee.type===Fe||ee.type===Te&&ee.to===ge.Internal}),2),I=C[0],B=C[1],T=y.filter(function(ee){var Me;return ee.type===ot&&((Me=ee.activity)===null||Me===void 0?void 0:Me.type)===at}),S=T.reduce(function(ee,Me){return ee[Me.activity.id]=ki(Me.activity,a.machine,x,i),ee},r?v({},r.children):{}),O=f?e.configuration:r?r.configuration:[],U=_e(O,this),V=new se({value:u||r.value,context:x,_event:i,_sessionid:r?r._sessionid:null,historyValue:u?d?Si(d,u):void 0:r?r.historyValue:void 0,history:!u||e.source?r:void 0,actions:u?B:[],activities:u?h:r?r.activities:{},events:[],configuration:O,transitions:e.transitions,children:S,done:U,tags:r==null?void 0:r.tags,machine:this}),Q=n!==x;V.changed=i.name===ut||Q;var ye=V.history;ye&&delete ye.history;var Mt=!U&&(this._transient||c.some(function(ee){return ee._transient}));if(!f&&(!Mt||i.name===$e))return V;var Z=V;if(!U)for(Mt&&(Z=this.resolveRaisedTransition(Z,{type:ci},i));I.length;){var Zu=I.shift();Z=this.resolveRaisedTransition(Z,Zu._event,i)}var ec=Z.changed||(ye?!!Z.actions.length||Q||typeof ye.value!=typeof Z.value||!Vr(Z.value,ye.value):void 0);return Z.changed=ec,Z.history=ye,Z.tags=Fr(Z.configuration),Z},t.prototype.getStateNode=function(e){if(ze(e))return this.machine.getStateNodeById(e);if(!this.states)throw new Error("Unable to retrieve child state '".concat(e,"' from '").concat(this.id,"'; no child states exist."));var r=this.states[e];if(!r)throw new Error("Child state '".concat(e,"' does not exist on '").concat(this.id,"'"));return r},t.prototype.getStateNodeById=function(e){var r=ze(e)?e.slice(Jr.length):e;if(r===this.id)return this;var n=this.machine.idMap[r];if(!n)throw new Error("Child state node '#".concat(r,"' does not exist on machine '").concat(this.id,"'"));return n},t.prototype.getStateNodeByPath=function(e){if(typeof e=="string"&&ze(e))try{return this.getStateNodeById(e.slice(1))}catch{}for(var r=zt(e,this.delimiter).slice(),n=this;r.length;){var i=r.shift();if(!i.length)break;n=n.getStateNode(i)}return n},t.prototype.resolve=function(e){var r,n=this;if(!e)return this.initialStateValue||Je;switch(this.type){case"parallel":return He(this.initialStateValue,function(s,o){return s?n.getStateNode(o).resolve(e[o]||s):Je});case"compound":if(A(e)){var i=this.getStateNode(e);return i.type==="parallel"||i.type==="compound"?(r={},r[e]=i.initialStateValue,r):e}return Object.keys(e).length?He(e,function(s,o){return s?n.getStateNode(o).resolve(s):Je}):this.initialStateValue||{};default:return e||Je}},t.prototype.getResolvedPath=function(e){if(ze(e)){var r=this.machine.idMap[e.slice(Jr.length)];if(!r)throw new Error("Unable to find state node '".concat(e,"'"));return r.path}return zt(e,this.delimiter)},Object.defineProperty(t.prototype,"initialStateValue",{get:function(){var e;if(this.__cache.initialStateValue)return this.__cache.initialStateValue;var r;if(this.type==="parallel")r=Ur(this.states,function(n){return n.initialStateValue||Je},function(n){return n.type!=="history"});else if(this.initial!==void 0){if(!this.states[this.initial])throw new Error("Initial state '".concat(this.initial,"' not found on '").concat(this.key,"'"));r=gt(this.states[this.initial])?this.initial:(e={},e[this.initial]=this.states[this.initial].initialStateValue,e)}else r={};return this.__cache.initialStateValue=r,this.__cache.initialStateValue},enumerable:!1,configurable:!0}),t.prototype.getInitialState=function(e,r){this._init();var n=this.getStateNodes(e);return this.resolveTransition({configuration:n,entrySet:n,exitSet:[],transitions:[],source:void 0,actions:[]},void 0,r!=null?r:this.machine.context,void 0)},Object.defineProperty(t.prototype,"initialState",{get:function(){var e=this.initialStateValue;if(!e)throw new Error("Cannot retrieve initial state from simple state '".concat(this.id,"'."));return this.getInitialState(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){var e;if(this.type==="history"){var r=this.config;A(r.target)?e=ze(r.target)?ct(this.machine.getStateNodeById(r.target).path.slice(this.path.length-1)):r.target:e=r.target}return e},enumerable:!1,configurable:!0}),t.prototype.getRelativeStateNodes=function(e,r,n){return n===void 0&&(n=!0),n?e.type==="history"?e.resolveHistory(r):e.initialStateNodes:[e]},Object.defineProperty(t.prototype,"initialStateNodes",{get:function(){var e=this;if(gt(this))return[this];if(this.type==="compound"&&!this.initial)return D||L(!1,"Compound state node '".concat(this.id,"' has no initial state.")),[this];var r=lt(this.initialStateValue);return q(r.map(function(n){return e.getFromRelativePath(n)}))},enumerable:!1,configurable:!0}),t.prototype.getFromRelativePath=function(e){if(!e.length)return[this];var r=R(e),n=r[0],i=r.slice(1);if(!this.states)throw new Error("Cannot retrieve subPath '".concat(n,"' from node with no states"));var s=this.getStateNode(n);if(s.type==="history")return s.resolveHistory();if(!this.states[n])throw new Error("Child state '".concat(n,"' does not exist on '").concat(this.id,"'"));return this.states[n].getFromRelativePath(i)},t.prototype.historyValue=function(e){if(!!Object.keys(this.states).length)return{current:e||this.initialStateValue,states:Ur(this.states,function(r,n){if(!e)return r.historyValue();var i=A(e)?void 0:e[n];return r.historyValue(i||r.initialStateValue)},function(r){return!r.history})}},t.prototype.resolveHistory=function(e){var r=this;if(this.type!=="history")return[this];var n=this.parent;if(!e){var i=this.target;return i?q(lt(i).map(function(o){return n.getFromRelativePath(o)})):n.initialStateNodes}var s=mi(n.path,"states")(e).current;return A(s)?[n.getStateNode(s)]:q(lt(s).map(function(o){return r.history==="deep"?n.getFromRelativePath(o):[n.states[o[0]]]}))},Object.defineProperty(t.prototype,"stateIds",{get:function(){var e=this,r=q(Object.keys(this.states).map(function(n){return e.states[n].stateIds}));return[this.id].concat(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"events",{get:function(){var e,r,n,i;if(this.__cache.events)return this.__cache.events;var s=this.states,o=new Set(this.ownEvents);if(s)try{for(var a=b(Object.keys(s)),c=a.next();!c.done;c=a.next()){var f=c.value,u=s[f];if(u.states)try{for(var d=(n=void 0,b(u.events)),l=d.next();!l.done;l=d.next()){var h=l.value;o.add("".concat(h))}}catch(g){n={error:g}}finally{try{l&&!l.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}}}catch(g){e={error:g}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return this.__cache.events=Array.from(o)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ownEvents",{get:function(){var e=new Set(this.transitions.filter(function(r){return!(!r.target&&!r.actions.length&&r.internal)}).map(function(r){return r.eventType}));return Array.from(e)},enumerable:!1,configurable:!0}),t.prototype.resolveTarget=function(e){var r=this;if(e!==void 0)return e.map(function(n){if(!A(n))return n;var i=n[0]===r.delimiter;if(i&&!r.parent)return r.getStateNodeByPath(n.slice(1));var s=i?r.key+n:n;if(r.parent)try{var o=r.parent.getStateNodeByPath(s);return o}catch(a){throw new Error("Invalid transition definition for state node '".concat(r.id,`':
9
+ `).concat(a.message))}else return r.getStateNodeByPath(s)})},t.prototype.formatTransition=function(e){var r=this,n=Ti(e.target),i="internal"in e?e.internal:n?n.some(function(c){return A(c)&&c[0]===r.delimiter}):!0,s=this.machine.options.guards,o=this.resolveTarget(n),a=v(v({},e),{actions:mt(te(e.actions)),cond:Wt(e.cond,s),target:o,source:this,internal:i,eventType:e.event,toJSON:function(){return v(v({},a),{target:a.target?a.target.map(function(c){return"#".concat(c.id)}):void 0,source:"#".concat(r.id)})}});return a},t.prototype.formatTransitions=function(){var e,r,n=this,i;if(!this.config.on)i=[];else if(Array.isArray(this.config.on))i=this.config.on;else{var s=this.config.on,o=xt,a=s[o],c=a===void 0?[]:a,f=je(s,[typeof o=="symbol"?o:o+""]);i=q(Object.keys(f).map(function(y){!D&&y===$e&&L(!1,"Empty string transition configs (e.g., `{ on: { '': ... }}`) for transient transitions are deprecated. Specify the transition in the `{ always: ... }` property instead. "+'Please check the `on` configuration for "#'.concat(n.id,'".'));var x=Re(y,f[y]);return D||Sc(n,y,x),x}).concat(Re(xt,c)))}var u=this.config.always?Re("",this.config.always):[],d=this.config.onDone?Re(String(yt(this.id)),this.config.onDone):[];D||L(!(this.config.onDone&&!this.parent),'Root nodes cannot have an ".onDone" transition. Please check the config of "'.concat(this.id,'".'));var l=q(this.invoke.map(function(y){var x=[];return y.onDone&&x.push.apply(x,_([],R(Re(String(Oe(y.id)),y.onDone)),!1)),y.onError&&x.push.apply(x,_([],R(Re(String(Ce(y.id)),y.onError)),!1)),x})),h=this.after,g=q(_(_(_(_([],R(d),!1),R(l),!1),R(i),!1),R(u),!1).map(function(y){return te(y).map(function(x){return n.formatTransition(x)})}));try{for(var E=b(h),p=E.next();!p.done;p=E.next()){var w=p.value;g.push(w)}}catch(y){e={error:y}}finally{try{p&&!p.done&&(r=E.return)&&r.call(E)}finally{if(e)throw e.error}}return g},t}();function oe(t,e){return new zi(t,e)}var k=Pi,$=vt;function Wi(t){return!!(t&&typeof t.then=="function")}var wc=Promise.resolve(!1),qp=Promise.resolve(!0),le=Promise.resolve();function tr(t,e){return t||(t=0),new Promise(function(r){return setTimeout(function(){return r(e)},t)})}function Ki(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function Tt(){return Math.random().toString(36).substring(2)}var $i=0,zr=0;function Ee(){var t=new Date().getTime();return t===$i?(zr++,t*1e3+zr):($i=t,zr=0,t*1e3)}var Se=Object.prototype.toString.call(typeof process!="undefined"?process:0)==="[object process]";var xc=Ee,Tc="native";function bc(t){var e={messagesCallback:null,bc:new BroadcastChannel(t),subFns:[]};return e.bc.onmessage=function(r){e.messagesCallback&&e.messagesCallback(r.data)},e}function Rc(t){t.bc.close(),t.subFns=[]}function Ac(t,e){try{return t.bc.postMessage(e,!1),le}catch(r){return Promise.reject(r)}}function Oc(t,e){t.messagesCallback=e}function Cc(){if(Se&&typeof window=="undefined")return!1;if(typeof BroadcastChannel=="function"){if(BroadcastChannel._pubkey)throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");return!0}else return!1}function Pc(){return 150}var Xi={create:bc,close:Rc,onMessage:Oc,postMessage:Ac,canBeUsed:Cc,type:Tc,averageResponseTime:Pc,microSeconds:xc};var rr=function(){function t(e){this.ttl=e,this.set=new Set,this.timeMap=new Map}return t.prototype.has=function(e){return this.set.has(e)},t.prototype.add=function(e){var r=this;this.timeMap.set(e,Yi()),this.set.add(e),setTimeout(function(){Nc(r)},0)},t.prototype.clear=function(){this.set.clear(),this.timeMap.clear()},t}();function Nc(t){for(var e=Yi()-t.ttl,r=t.set[Symbol.iterator]();;){var n=r.next().value;if(!n)return;var i=t.timeMap.get(n);if(i<e)t.timeMap.delete(n),t.set.delete(n);else return}}function Yi(){return new Date().getTime()}function We(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=JSON.parse(JSON.stringify(t));return typeof e.webWorkerSupport=="undefined"&&(e.webWorkerSupport=!0),e.idb||(e.idb={}),e.idb.ttl||(e.idb.ttl=1e3*45),e.idb.fallbackInterval||(e.idb.fallbackInterval=150),t.idb&&typeof t.idb.onclose=="function"&&(e.idb.onclose=t.idb.onclose),e.localstorage||(e.localstorage={}),e.localstorage.removeTimeout||(e.localstorage.removeTimeout=1e3*60),t.methods&&(e.methods=t.methods),e.node||(e.node={}),e.node.ttl||(e.node.ttl=1e3*60*2),e.node.maxParallelWrites||(e.node.maxParallelWrites=2048),typeof e.node.useFastPath=="undefined"&&(e.node.useFastPath=!0),e}var Ic=Ee,_c="pubkey.broadcast-channel-0-",ve="messages",kc="idb";function Qi(){if(typeof indexedDB!="undefined")return indexedDB;if(typeof window!="undefined"){if(typeof window.mozIndexedDB!="undefined")return window.mozIndexedDB;if(typeof window.webkitIndexedDB!="undefined")return window.webkitIndexedDB;if(typeof window.msIndexedDB!="undefined")return window.msIndexedDB}return!1}function qc(t){var e=Qi(),r=_c+t,n=e.open(r,1);n.onupgradeneeded=function(s){var o=s.target.result;o.createObjectStore(ve,{keyPath:"id",autoIncrement:!0})};var i=new Promise(function(s,o){n.onerror=function(a){return o(a)},n.onsuccess=function(){s(n.result)}});return i}function Dc(t,e,r){var n=new Date().getTime(),i={uuid:e,time:n,data:r},s=t.transaction([ve],"readwrite");return new Promise(function(o,a){s.oncomplete=function(){return o()},s.onerror=function(f){return a(f)};var c=s.objectStore(ve);c.add(i)})}function Uc(t,e){var r=t.transaction(ve).objectStore(ve),n=[];function i(){try{var s=IDBKeyRange.bound(e+1,1/0);return r.openCursor(s)}catch{return r.openCursor()}}return new Promise(function(s){i().onsuccess=function(o){var a=o.target.result;a?a.value.id<e+1?a.continue(e+1):(n.push(a.value),a.continue()):s(n)}})}function Mc(t,e){var r=t.transaction([ve],"readwrite").objectStore(ve).delete(e);return new Promise(function(n){r.onsuccess=function(){return n()}})}function Lc(t,e){var r=new Date().getTime()-e,n=t.transaction(ve).objectStore(ve),i=[];return new Promise(function(s){n.openCursor().onsuccess=function(o){var a=o.target.result;if(a){var c=a.value;if(c.time<r)i.push(c),a.continue();else{s(i);return}}else s(i)}})}function jc(t,e){return Lc(t,e).then(function(r){return Promise.all(r.map(function(n){return Mc(t,n.id)}))})}function Bc(t,e){return e=We(e),qc(t).then(function(r){var n={closed:!1,lastCursorId:0,channelName:t,options:e,uuid:Tt(),eMIs:new rr(e.idb.ttl*2),writeBlockPromise:le,messagesCallback:null,readQueuePromises:[],db:r};return r.onclose=function(){n.closed=!0,e.idb.onclose&&e.idb.onclose()},Zi(n),n})}function Zi(t){t.closed||es(t).then(function(){return tr(t.options.idb.fallbackInterval)}).then(function(){return Zi(t)})}function Fc(t,e){return!(t.uuid===e.uuid||e.eMIs.has(t.id)||t.data.time<e.messagesCallbackTime)}function es(t){return t.closed?le:t.messagesCallback?Uc(t.db,t.lastCursorId).then(function(e){var r=e.filter(function(n){return!!n}).map(function(n){return n.id>t.lastCursorId&&(t.lastCursorId=n.id),n}).filter(function(n){return Fc(n,t)}).sort(function(n,i){return n.time-i.time});return r.forEach(function(n){t.messagesCallback&&(t.eMIs.add(n.id),t.messagesCallback(n.data))}),le}):le}function Vc(t){t.closed=!0,t.db.close()}function Hc(t,e){return t.writeBlockPromise=t.writeBlockPromise.then(function(){return Dc(t.db,t.uuid,e)}).then(function(){Ki(0,10)===0&&jc(t.db,t.options.idb.ttl)}),t.writeBlockPromise}function Gc(t,e,r){t.messagesCallbackTime=r,t.messagesCallback=e,es(t)}function Jc(){if(Se)return!1;var t=Qi();return!!t}function zc(t){return t.idb.fallbackInterval*2}var ts={create:Bc,close:Vc,onMessage:Gc,postMessage:Hc,canBeUsed:Jc,type:kc,averageResponseTime:zc,microSeconds:Ic};var $c=Ee,Wc="pubkey.broadcastChannel-",Kc="localstorage";function rs(){var t;if(typeof window=="undefined")return null;try{t=window.localStorage,t=window["ie8-eventlistener/storage"]||window.localStorage}catch{}return t}function ns(t){return Wc+t}function Xc(t,e){return new Promise(function(r){tr().then(function(){var n=ns(t.channelName),i={token:Tt(),time:new Date().getTime(),data:e,uuid:t.uuid},s=JSON.stringify(i);rs().setItem(n,s);var o=document.createEvent("Event");o.initEvent("storage",!0,!0),o.key=n,o.newValue=s,window.dispatchEvent(o),r()})})}function Yc(t,e){var r=ns(t),n=function(s){s.key===r&&e(JSON.parse(s.newValue))};return window.addEventListener("storage",n),n}function Qc(t){window.removeEventListener("storage",t)}function Zc(t,e){if(e=We(e),!is())throw new Error("BroadcastChannel: localstorage cannot be used");var r=Tt(),n=new rr(e.localstorage.removeTimeout),i={channelName:t,uuid:r,eMIs:n};return i.listener=Yc(t,function(s){!i.messagesCallback||s.uuid!==r&&(!s.token||n.has(s.token)||s.data.time&&s.data.time<i.messagesCallbackTime||(n.add(s.token),i.messagesCallback(s.data)))}),i}function ef(t){Qc(t.listener)}function tf(t,e,r){t.messagesCallbackTime=r,t.messagesCallback=e}function is(){if(Se)return!1;var t=rs();if(!t)return!1;try{var e="__broadcastchannel_check";t.setItem(e,"works"),t.removeItem(e)}catch{return!1}return!0}function rf(){var t=120,e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")?t*2:t}var ss={create:Zc,close:ef,onMessage:tf,postMessage:Xc,canBeUsed:is,type:Kc,averageResponseTime:rf,microSeconds:$c};var nf=Ee,sf="simulate",$r=new Set;function of(t){var e={name:t,messagesCallback:null};return $r.add(e),e}function af(t){$r.delete(t)}function uf(t,e){return new Promise(function(r){return setTimeout(function(){var n=Array.from($r);n.filter(function(i){return i.name===t.name}).filter(function(i){return i!==t}).filter(function(i){return!!i.messagesCallback}).forEach(function(i){return i.messagesCallback(e)}),r()},5)})}function cf(t,e){t.messagesCallback=e}function ff(){return!0}function lf(){return 5}var os={create:of,close:af,onMessage:cf,postMessage:uf,canBeUsed:ff,type:sf,averageResponseTime:lf,microSeconds:nf};var as=[Xi,ts,ss];function us(t){var e=[].concat(t.methods,as).filter(Boolean);if(t.type){if(t.type==="simulate")return os;var r=e.find(function(i){return i.type===t.type});if(r)return r;throw new Error("method-type "+t.type+" not found")}!t.webWorkerSupport&&!Se&&(e=e.filter(function(i){return i.type!=="idb"}));var n=e.find(function(i){return i.canBeUsed()});if(n)return n;throw new Error("No useable method found in "+JSON.stringify(as.map(function(i){return i.type})))}var Wr=new Set,df=0,ke=function(e,r){this.id=df++,Wr.add(this),this.name=e,cs&&(r=cs),this.options=We(r),this.method=us(this.options),this._iL=!1,this._onML=null,this._addEL={message:[],internal:[]},this._uMP=new Set,this._befC=[],this._prepP=null,hf(this)};ke._pubkey=!0;var cs;ke.prototype={postMessage:function(e){if(this.closed)throw new Error("BroadcastChannel.postMessage(): Cannot post message after channel has closed "+JSON.stringify(e));return fs(this,"message",e)},postInternal:function(e){return fs(this,"internal",e)},set onmessage(t){var e=this.method.microSeconds(),r={time:e,fn:t};ds(this,"message",this._onML),t&&typeof t=="function"?(this._onML=r,ls(this,"message",r)):this._onML=null},addEventListener:function(e,r){var n=this.method.microSeconds(),i={time:n,fn:r};ls(this,e,i)},removeEventListener:function(e,r){var n=this._addEL[e].find(function(i){return i.fn===r});ds(this,e,n)},close:function(){var e=this;if(!this.closed){Wr.delete(this),this.closed=!0;var r=this._prepP?this._prepP:le;return this._onML=null,this._addEL.message=[],r.then(function(){return Promise.all(Array.from(e._uMP))}).then(function(){return Promise.all(e._befC.map(function(n){return n()}))}).then(function(){return e.method.close(e._state)})}},get type(){return this.method.type},get isClosed(){return this.closed}};function fs(t,e,r){var n=t.method.microSeconds(),i={time:n,type:e,data:r},s=t._prepP?t._prepP:le;return s.then(function(){var o=t.method.postMessage(t._state,i);return t._uMP.add(o),o.catch().then(function(){return t._uMP.delete(o)}),o})}function hf(t){var e=t.method.create(t.name,t.options);Wi(e)?(t._prepP=e,e.then(function(r){t._state=r})):t._state=e}function hs(t){return t._addEL.message.length>0||t._addEL.internal.length>0}function ls(t,e,r){t._addEL[e].push(r),pf(t)}function ds(t,e,r){t._addEL[e]=t._addEL[e].filter(function(n){return n!==r}),mf(t)}function pf(t){if(!t._iL&&hs(t)){var e=function(i){t._addEL[i.type].forEach(function(s){var o=1e5,a=s.time-o;i.time>=a&&s.fn(i.data)})},r=t.method.microSeconds();t._prepP?t._prepP.then(function(){t._iL=!0,t.method.onMessage(t._state,e,r)}):(t._iL=!0,t.method.onMessage(t._state,e,r))}}function mf(t){if(t._iL&&!hs(t)){t._iL=!1;var e=t.method.microSeconds();t.method.onMessage(t._state,null,e)}}var nr="nhostRefreshToken",bt="nhostRefreshTokenExpiresAt";var qe={status:10,error:"invalid-email",message:"Email is incorrectly formatted"};var Rt={status:10,error:"invalid-password",message:"Password is incorrectly formatted"},ps={status:10,error:"invalid-phone-number",message:"Phone number is incorrectly formatted"},ms={status:10,error:"no-mfa-ticket",message:"No MFA ticket has been provided"};var bo=Lt(To());var ae=t=>{let e=bo.default.create({baseURL:t});return e.interceptors.response.use(r=>r,r=>{var n,i,s,o,a,c,f,u,d,l;return Promise.reject({error:{message:(a=(o=(s=(i=(n=r.response)==null?void 0:n.data)==null?void 0:i.message)!=null?s:r.message)!=null?o:r.request.responseText)!=null?a:JSON.stringify(r),status:(d=(u=(c=r.response)==null?void 0:c.status)!=null?u:(f=r.response)==null?void 0:f.data.statusCode)!=null?d:0,error:((l=r.response)==null?void 0:l.data.error)||r.request.statusText||"network"}})}),e};var Ro=(t,e)=>{let r=e&&Object.entries(e).map(([n,i])=>{let s=Array.isArray(i)?i.join(","):typeof i=="object"?JSON.stringify(i):i;return`${n}=${encodeURIComponent(s)}`}).join("&");return r?`${t}?${r}`:t},ie=(t,e)=>{var r;return e!=null&&e.redirectTo?{...e,redirectTo:(r=e==null?void 0:e.redirectTo)!=null&&r.startsWith("/")?t+e.redirectTo:e==null?void 0:e.redirectTo}:e};var Qe=t=>!!t&&typeof t=="string"&&!!String(t).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),lr=t=>!!t&&typeof t=="string"&&t.length>=3,Ao=t=>!!t&&typeof t=="string";var mn={user:null,mfa:null,accessToken:{value:null,expiresAt:new Date},refreshTimer:{elapsed:0,attempts:0},refreshToken:{value:null},errors:{}};var Oo=({backendUrl:t,clientUrl:e,interpreter:r})=>{let n=ae(t);return oe({schema:{context:{},events:{}},tsTypes:{},preserveActionOrder:!0,id:"changeEmail",initial:"idle",context:{error:null},states:{idle:{on:{REQUEST:[{cond:"invalidEmail",actions:"saveInvalidEmailError",target:".error"},{target:"requesting"}]},initial:"initial",states:{initial:{},success:{},error:{}}},requesting:{invoke:{src:"requestChange",id:"requestChange",onDone:{target:"idle.success",actions:"reportSuccess"},onError:{actions:["saveRequestError","reportError"],target:"idle.error"}}}}},{actions:{saveInvalidEmailError:k({error:i=>qe}),saveRequestError:k({error:(i,{data:{error:s}})=>s}),reportError:$(i=>({type:"ERROR",error:i.error})),reportSuccess:$("SUCCESS")},guards:{invalidEmail:(i,{email:s})=>!Qe(s)},services:{requestChange:async(i,{email:s,options:o})=>(await n.post("/user/email/change",{newEmail:s,options:ie(e,o)},{headers:{authorization:`Bearer ${r==null?void 0:r.state.context.accessToken.value}`}})).data}})};var Co=({backendUrl:t,interpreter:e})=>{let r=ae(t);return oe({schema:{context:{},events:{}},tsTypes:{},preserveActionOrder:!0,id:"changePassword",initial:"idle",context:{error:null},states:{idle:{on:{REQUEST:[{cond:"invalidPassword",actions:"saveInvalidPasswordError",target:".error"},{target:"requesting"}]},initial:"initial",states:{initial:{},success:{},error:{}}},requesting:{invoke:{src:"requestChange",id:"requestChange",onDone:{target:"idle.success",actions:"reportSuccess"},onError:{actions:["saveRequestError","reportError"],target:"idle.error"}}}}},{actions:{saveInvalidPasswordError:k({error:n=>Rt}),saveRequestError:k({error:(n,{data:{error:i}})=>(console.log(i),i)}),reportError:$(n=>({type:"ERROR",error:n.error})),reportSuccess:$("SUCCESS")},guards:{invalidPassword:(n,{password:i})=>!lr(i)},services:{requestChange:(n,{password:i})=>r.post("/user/password",{newPassword:i},{headers:{authorization:`Bearer ${e==null?void 0:e.state.context.accessToken.value}`}})}})};var Po=({backendUrl:t,clientUrl:e})=>{let r=ae(t);return oe({schema:{context:{},events:{}},tsTypes:{},preserveActionOrder:!0,id:"changePassword",initial:"idle",context:{error:null},states:{idle:{on:{REQUEST:"requesting"},initial:"initial",states:{initial:{},success:{},error:{}}},requesting:{invoke:{src:"requestChange",id:"requestChange",onDone:{target:"idle.success",actions:"reportSuccess"},onError:{actions:["saveRequestError","reportError"],target:"idle.error"}}}}},{actions:{saveRequestError:k({error:(n,{data:{error:i}})=>(console.log(i),i)}),reportError:$(n=>({type:"ERROR",error:n.error})),reportSuccess:$("SUCCESS")},services:{requestChange:(n,{email:i,options:s})=>r.post("/user/password/reset",{email:i,options:ie(e,s)})}})};var No=({backendUrl:t,clientUrl:e,interpreter:r})=>{let n=ae(t);return oe({schema:{context:{},events:{}},tsTypes:{},preserveActionOrder:!0,id:"sendVerificationEmail",initial:"idle",context:{error:null},states:{idle:{on:{REQUEST:[{cond:"invalidEmail",actions:"saveInvalidEmailError",target:".error"},{target:"requesting"}]},initial:"initial",states:{initial:{},success:{},error:{}}},requesting:{invoke:{src:"request",id:"request",onDone:{target:"idle.success",actions:"reportSuccess"},onError:{actions:["saveRequestError","reportError"],target:"idle.error"}}}}},{actions:{saveInvalidEmailError:k({error:i=>qe}),saveRequestError:k({error:(i,{data:{error:s}})=>s}),reportError:$(i=>({type:"ERROR",error:i.error})),reportSuccess:$("SUCCESS")},guards:{invalidEmail:(i,{email:s})=>!Qe(s)},services:{request:async(i,{email:s,options:o})=>(await n.post("/user/email/send-verification-email",{email:s,options:ie(e,o)})).data}})};var Io=({backendUrl:t,clientUrl:e,clientStorageGetter:r,clientStorageSetter:n,refreshIntervalTime:i,autoRefreshToken:s=!0,autoSignIn:o=!0})=>{let a=ae(t),c=async(f,u,d)=>(await a.post(f,u,d)).data;return oe({schema:{context:{},events:{}},tsTypes:{},context:mn,preserveActionOrder:!0,id:"nhost",type:"parallel",states:{authentication:{initial:"checkAutoSignIn",on:{SESSION_UPDATE:[{cond:"hasSession",actions:["saveSession","persist","resetTimer","reportTokenChanged"],target:".signedIn"}]},states:{checkAutoSignIn:{always:[{cond:"isAutoSignInDisabled",target:"importingRefreshToken"}],invoke:{id:"autoSignIn",src:"autoSignIn",onDone:{target:"signedIn",actions:["saveSession","persist","reportTokenChanged"]},onError:"importingRefreshToken"}},importingRefreshToken:{invoke:{id:"importRefreshToken",src:"importRefreshToken",onDone:{actions:"saveRefreshToken",target:"starting"}}},starting:{always:[{cond:"isSignedIn",target:"signedIn"},{cond:"hasRefreshTokenWithoutSession",target:["authenticating.token","#nhost.token.running"]},"signedOut"]},signedOut:{tags:["ready"],initial:"noErrors",entry:"reportSignedOut",states:{noErrors:{},success:{},needsEmailVerification:{},needsSmsOtp:{},needsMfa:{},failed:{exit:"resetAuthenticationError",initial:"server",states:{server:{},validation:{states:{password:{},email:{},phoneNumber:{}}}}},signingOut:{entry:"destroyToken",exit:"clearContext",invoke:{src:"signout",id:"signingOut",onDone:{target:"success"},onError:{target:"failed.server"}}}},on:{SIGNIN_PASSWORD:[{cond:"invalidEmail",actions:["saveInvalidEmail"],target:".failed.validation.email"},{cond:"invalidPassword",actions:["saveInvalidPassword"],target:".failed.validation.password"},"#nhost.authentication.authenticating.password"],SIGNIN_PASSWORDLESS_EMAIL:[{cond:"invalidEmail",actions:"saveInvalidEmail",target:".failed.validation.email"},"#nhost.authentication.authenticating.passwordlessEmail"],SIGNIN_PASSWORDLESS_SMS:[{cond:"invalidPhoneNumber",actions:"saveInvalidPhoneNumber",target:".failed.validation.phoneNumber"},"#nhost.authentication.authenticating.passwordlessSms"],SIGNIN_PASSWORDLESS_SMS_OTP:[{cond:"invalidPhoneNumber",actions:"saveInvalidPhoneNumber",target:".failed.validation.phoneNumber"},"#nhost.authentication.authenticating.passwordlessSmsOtp"],SIGNUP_EMAIL_PASSWORD:[{cond:"invalidEmail",actions:"saveInvalidSignUpEmail",target:".failed.validation.email"},{cond:"invalidPassword",actions:"saveInvalidSignUpPassword",target:".failed.validation.password"},"#nhost.authentication.registering"],SIGNIN_ANONYMOUS:"#nhost.authentication.authenticating.anonymous",SIGNIN_MFA_TOTP:[{cond:"noMfaTicket",actions:["saveNoMfaTicketError"],target:".failed"},"#nhost.authentication.authenticating.mfa.totp"]}},authenticating:{states:{passwordlessEmail:{invoke:{src:"signInPasswordlessEmail",id:"authenticatePasswordlessEmail",onDone:"#nhost.authentication.signedOut.needsEmailVerification",onError:{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed.server"}}},passwordlessSms:{invoke:{src:"signInPasswordlessSms",id:"authenticatePasswordlessSms",onDone:"#nhost.authentication.signedOut.needsSmsOtp",onError:{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed.server"}}},passwordlessSmsOtp:{invoke:{src:"signInPasswordlessSmsOtp",id:"authenticatePasswordlessSmsOtp",onDone:{actions:["saveSession","persist","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed.server"}}},password:{invoke:{src:"signInPassword",id:"authenticateUserWithPassword",onDone:[{cond:"hasMfaTicket",actions:["saveMfaTicket"],target:"#nhost.authentication.signedOut.needsMfa"},{actions:["saveSession","persist","reportTokenChanged"],target:"#nhost.authentication.signedIn"}],onError:[{cond:"unverified",target:"#nhost.authentication.signedOut.needsEmailVerification"},{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed.server"}]}},token:{},anonymous:{invoke:{src:"signInAnonymous",id:"authenticateAnonymously",onDone:{actions:["saveSession","persist","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed.server"}}},mfa:{states:{totp:{invoke:{src:"signInMfaTotp",id:"signInMfaTotp",onDone:{actions:["saveSession","persist","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:{actions:["saveAuthenticationError"],target:"#nhost.authentication.signedOut.failed.server"}}}}}}},registering:{entry:"resetSignUpError",invoke:{src:"registerUser",id:"registerUser",onDone:[{cond:"hasSession",target:"#nhost.authentication.signedIn",actions:["saveSession","persist","reportTokenChanged"]},{target:"#nhost.authentication.signedOut.needsEmailVerification"}],onError:[{cond:"unverified",target:"#nhost.authentication.signedOut.needsEmailVerification"},{actions:"saveRegisrationError",target:"#nhost.authentication.signedOut.failed.server"}]}},signedIn:{tags:["ready"],type:"parallel",entry:"reportSignedIn",on:{SIGNOUT:"#nhost.authentication.signedOut.signingOut",DEANONYMIZE:{target:".deanonymizing"}},states:{refreshTimer:{id:"timer",initial:"idle",states:{disabled:{type:"final"},stopped:{always:{cond:"noToken",target:"idle"}},idle:{always:[{cond:"isAutoRefreshDisabled",target:"disabled"},{cond:"hasRefreshToken",target:"running"}]},running:{initial:"pending",entry:"resetTimer",states:{pending:{after:{"1000":{actions:"tickRefreshTimer",internal:!1,target:"pending"}},always:{cond:"refreshTimerShouldRefresh",target:"refreshing"}},refreshing:{invoke:{src:"refreshToken",id:"refreshToken",onDone:{actions:["saveSession","persist","resetTimer"],target:"pending"},onError:[]}}}}}},deanonymizing:{initial:"error",states:{error:{},success:{}}}}}}},token:{initial:"idle",states:{idle:{on:{TRY_TOKEN:"running"},initial:"noErrors",states:{noErrors:{},error:{}}},running:{invoke:{src:"refreshToken",id:"authenticateWithToken",onDone:{actions:["saveSession","persist","reportTokenChanged"],target:["#nhost.authentication.signedIn","idle.noErrors"]},onError:[{cond:"isSignedIn",target:"idle.error"},{target:["#nhost.authentication.signedOut","idle.error"]}]}}}}}},{actions:{reportSignedIn:$("SIGNED_IN"),reportSignedOut:$("SIGNED_OUT"),reportTokenChanged:$("TOKEN_CHANGED"),clearContext:k(()=>mn),saveSession:k({user:(f,u)=>{var d,l;return(l=(d=u.data)==null?void 0:d.session)==null?void 0:l.user},accessToken:(f,u)=>{var d,l,h,g;return{value:(l=(d=u.data)==null?void 0:d.session)==null?void 0:l.accessToken,expiresAt:new Date(Date.now()+((g=(h=u.data)==null?void 0:h.session)==null?void 0:g.accessTokenExpiresIn)*1e3)}},refreshToken:(f,u)=>{var d,l;return{value:(l=(d=u.data)==null?void 0:d.session)==null?void 0:l.refreshToken}}}),saveMfaTicket:k({mfa:(f,u)=>{var d,l;return(l=(d=u.data)==null?void 0:d.mfa)!=null?l:null}}),resetTimer:k({refreshTimer:(f,u)=>({elapsed:0,attempts:0})}),tickRefreshTimer:k({refreshTimer:(f,u)=>({elapsed:f.refreshTimer.elapsed+1,attempts:f.refreshTimer.attempts})}),saveAuthenticationError:k({errors:({errors:f},{data:{error:u}})=>({...f,authentication:u})}),resetAuthenticationError:k({errors:({errors:{authentication:f,...u}})=>u}),saveInvalidEmail:k({errors:({errors:f})=>({...f,authentication:qe})}),saveInvalidPassword:k({errors:({errors:f})=>({...f,authentication:Rt})}),saveInvalidPhoneNumber:k({errors:({errors:f})=>({...f,authentication:ps})}),saveRegisrationError:k({errors:({errors:f},{data:{error:u}})=>({...f,registration:u})}),resetSignUpError:k({errors:({errors:{registration:f,...u}})=>u}),saveInvalidSignUpPassword:k({errors:({errors:f})=>({...f,registration:qe})}),saveInvalidSignUpEmail:k({errors:({errors:f})=>({...f,registration:Rt})}),saveNoMfaTicketError:k({errors:({errors:f})=>({...f,registration:ms})}),saveRefreshToken:k({accessToken:(f,u)=>({...f.accessToken,expiresAt:u.data.expiresAt}),refreshToken:(f,u)=>({...f.refreshToken,value:u.data.refreshToken})}),persist:(f,{data:u})=>{if(n(nr,u.session.refreshToken),u.session.accessTokenExpiresIn){let d=new Date(Date.now()+u.session.accessTokenExpiresIn*1e3).toISOString();n(bt,d)}else n(bt,null)},destroyToken:()=>{n(nr,null),n(bt,null)}},guards:{isSignedIn:f=>!!f.user&&!!f.refreshToken.value&&!!f.accessToken.value,hasRefreshTokenWithoutSession:f=>!!f.refreshToken.value&&!f.user&&!f.accessToken.value,noToken:f=>!f.refreshToken.value,noMfaTicket:(f,{ticket:u})=>{var d;return!u&&!((d=f.mfa)!=null&&d.ticket)},hasRefreshToken:f=>!!f.refreshToken.value,isAutoRefreshDisabled:()=>!s,isAutoSignInDisabled:()=>!o,refreshTimerShouldRefresh:f=>f.refreshTimer.elapsed>Math.max((Date.now()-f.accessToken.expiresAt.getTime())/1e3-900,i),unverified:(f,{data:{error:u}})=>u.status===401&&u.message==="Email is not verified",hasSession:(f,u)=>{var d;return!!((d=u.data)!=null&&d.session)},hasMfaTicket:(f,u)=>{var d;return!!((d=u.data)!=null&&d.mfa)},invalidEmail:(f,{email:u})=>!Qe(u),invalidPassword:(f,{password:u})=>!lr(u),invalidPhoneNumber:(f,{phoneNumber:u})=>!Ao(u)},services:{signInPassword:(f,{email:u,password:d})=>c("/signin/email-password",{email:u,password:d}),signInPasswordlessSms:(f,{phoneNumber:u,options:d})=>c("/signin/passwordless/sms",{phoneNumber:u,options:ie(e,d)}),signInPasswordlessSmsOtp:(f,{phoneNumber:u,otp:d})=>c("/signin/passwordless/sms/otp",{phoneNumber:u,otp:d}),signInPasswordlessEmail:(f,{email:u,options:d})=>c("/signin/passwordless/email",{email:u,options:ie(e,d)}),signInAnonymous:f=>c("/signin/anonymous"),signInMfaTotp:(f,{ticket:u,otp:d})=>{var l;return c("/signin/mfa/totp",{ticket:u||((l=f.mfa)==null?void 0:l.ticket),otp:d})},refreshToken:async(f,u)=>{let d=u.type==="TRY_TOKEN"?u.token:f.refreshToken.value;return{session:await c("/token",{refreshToken:d})}},signout:(f,u)=>c("/signout",{refreshToken:f.refreshToken.value,all:!!u.all}),registerUser:(f,{email:u,password:d,options:l})=>c("/signup/email-password",{email:u,password:d,options:ie(e,l)}),autoSignIn:async()=>{if(typeof window=="undefined"||!window.location)throw Error("window is undefined or location does not exist");let{hash:f}=window.location;if(!f)return;let d=new URLSearchParams(f.slice(1)).get("refreshToken");if(d){let l=await c("/token",{refreshToken:d});return new ke("nhost").postMessage(d),{session:l}}},importRefreshToken:async()=>{let f=await r(bt),u=f?new Date(f):null;return{refreshToken:await r(nr),expiresAt:u}}}})};function dr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}var dl={read:function(t){return t[0]==='"'&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function vn(t,e){function r(i,s,o){if(typeof document!="undefined"){o=dr({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),i=encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var c in o)!o[c]||(a+="; "+c,o[c]!==!0&&(a+="="+o[c].split(";")[0]));return document.cookie=i+"="+t.write(s,i)+a}}function n(i){if(!(typeof document=="undefined"||arguments.length&&!i)){for(var s=document.cookie?document.cookie.split("; "):[],o={},a=0;a<s.length;a++){var c=s[a].split("="),f=c.slice(1).join("=");try{var u=decodeURIComponent(c[0]);if(o[u]=t.read(f,u),i===u)break}catch{}}return i?o[i]:o}}return Object.create({set:r,get:n,remove:function(i,s){r(i,"",dr({},s,{expires:-1}))},withAttributes:function(i){return vn(this.converter,dr({},this.attributes,i))},withConverter:function(i){return vn(dr({},this.converter,i),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var Lv=vn(dl,{path:"/"});var _o=typeof window!="undefined",hr=new Map,pr=t=>{var e;return _o&&localStorage?localStorage.getItem(t):(e=hr.get(t))!=null?e:null},mr=(t,e)=>{_o&&localStorage?e?localStorage.setItem(t,e):localStorage.removeItem(t):e?hr.set(t,e):hr.has(t)&&hr.delete(t)};var Pt,Nt,It,_t=class{constructor({backendUrl:e,clientUrl:r=typeof window!="undefined"&&(f=>(f=window.location)==null?void 0:f.origin)()||"",clientStorageGetter:n=pr,clientStorageSetter:i=mr,refreshIntervalTime:s=60,autoSignIn:o=!0,autoRefreshToken:a=!0,start:c=!0}){Le(this,Pt,void 0);Le(this,Nt,void 0);Le(this,It,new Set);this.backendUrl=e,this.clientUrl=r,this.machine=Io({backendUrl:e,clientUrl:r,refreshIntervalTime:s,clientStorageGetter:n,clientStorageSetter:i,autoSignIn:o,autoRefreshToken:a}),c&&(this.interpreter=me(this.machine),this.interpreter.start()),typeof window!="undefined"&&o&&(st(this,Nt,new ke("nhost")),M(this,Nt).addEventListener("message",u=>{var l;let d=(l=this.interpreter)==null?void 0:l.state.context.refreshToken;this.interpreter&&u!==d&&this.interpreter.send({type:"TRY_TOKEN",token:u})}))}get interpreter(){return M(this,Pt)}set interpreter(e){st(this,Pt,e),e&&M(this,It).forEach(r=>r(this))}onStart(e){M(this,It).add(e)}};Pt=new WeakMap,Nt=new WeakMap,It=new WeakMap;var ko=()=>typeof window!="undefined",xe=t=>!t||!t.accessToken.value||!t.refreshToken.value?null:{accessToken:t.accessToken.value,accessTokenExpiresIn:(t.accessToken.expiresAt.getTime()-Date.now())/1e3,refreshToken:t.refreshToken.value,user:t.user},Ze=(t,e)=>{e.forEach(r=>{typeof t[r]!="function"&&console.error(`clientStorage.${r} is not a function`)})},qo=(t,e)=>{if(e){if(t==="react-native"||t==="custom")return Ze(e,["getItem"]),r=>{var n;return(n=e.getItem)==null?void 0:n.call(e,r)};if(t==="capacitor")return Ze(e,["get"]),r=>{var n;return(n=e.get)==null?void 0:n.call(e,{key:r})};if(t==="expo-secure-storage")return Ze(e,["getItemAsync"]),r=>{var n;return(n=e.getItemAsync)==null?void 0:n.call(e,r)}}return pr},Do=(t,e)=>{if(e){if(t==="react-native"||t==="custom")return Ze(e,["setItem","removeItem"]),(r,n)=>{var i,s;n?(i=e.setItem)==null||i.call(e,r,n):(s=e.removeItem)==null||s.call(e,r)};if(t==="capacitor")return Ze(e,["set","remove"]),(r,n)=>{var i,s;n?(i=e.set)==null||i.call(e,{key:r,value:n}):(s=e.remove)==null||s.call(e,{key:r})};if(t==="expo-secure-storage")return Ze(e,["setItemAsync","deleteItemAsync"]),async(r,n)=>{var i,s;n?await((i=e.setItemAsync)==null?void 0:i.call(e,r,n)):(s=e.deleteItemAsync)==null||s.call(e,r)}}return mr};var Uo={message:"User is already signed in",status:100},pl={message:"User is not authenticated",status:101},ml={message:"User is not anonymous",status:101},vl={message:"Email needs verification",status:102},j,yn=class{constructor({url:e,autoRefreshToken:r=!0,autoLogin:n=!0,clientStorage:i,clientStorageType:s="web",clientStorageGetter:o,clientStorageSetter:a,refreshIntervalTime:c,start:f=!0,Client:u=_t}){Le(this,j,void 0);this.onTokenChangedSubscriptions=new Set;this.onAuthStateChangedSubscriptions=new Set;st(this,j,new u({backendUrl:e,autoRefreshToken:r,autoSignIn:n,start:f,clientStorageGetter:o||qo(s,i),clientStorageSetter:a||Do(s,i),refreshIntervalTime:c}))}async signUp(e){let r=await this.waitUntilReady(),{email:n,password:i,options:s}=e;return this.isAuthenticated()?{session:null,error:Uo}:new Promise(o=>{r.send({type:"SIGNUP_EMAIL_PASSWORD",email:n,password:i,options:s}),r.onTransition(a=>{if(a.matches({authentication:{signedOut:"needsEmailVerification"}}))return o({session:null,error:null});if(a.matches({authentication:{signedOut:"failed"}}))return o({session:null,error:a.context.errors.registration||null});if(a.matches({authentication:"signedIn"}))return o({session:xe(a.context),error:null})})})}async signIn(e){let r=await this.waitUntilReady();if(this.isAuthenticated())return{session:null,mfa:null,error:Uo};if("provider"in e){let{provider:n,options:i}=e,s=Ro(`${M(this,j).backendUrl}/v1/auth/signin/provider/${n}`,ie(M(this,j).clientUrl,i));return ko()&&(window.location.href=s),{providerUrl:s,provider:n,session:null,mfa:null,error:null}}return"email"in e&&"password"in e?new Promise(n=>{r.send({type:"SIGNIN_PASSWORD",...e}),r.onTransition(i=>{i.matches({authentication:"signedIn"})?n({session:xe(i.context),mfa:null,error:null}):i.matches({authentication:{signedOut:"needsEmailVerification"}})?n({session:null,mfa:null,error:vl}):i.matches({authentication:{signedOut:"needsMfa"}})?n({session:null,mfa:i.context.mfa,error:null}):i.matches({authentication:{signedOut:"failed"}})&&n({session:null,mfa:null,error:i.context.errors.authentication||null})})}):"email"in e&&!("otp"in e)?new Promise(n=>{r.onTransition(i=>{i.matches({authentication:{signedOut:"needsEmailVerification"}})?n({session:null,mfa:null,error:null}):i.matches({authentication:{signedOut:"failed"}})&&n({session:null,mfa:null,error:i.context.errors.authentication||null})}),r.send({type:"SIGNIN_PASSWORDLESS_EMAIL",...e})}):"phoneNumber"in e&&!("otp"in e)?new Promise(n=>{r.onTransition(i=>{i.matches({authentication:{signedOut:"needsSmsOtp"}})?n({session:null,mfa:null,error:null}):i.matches({authentication:{signedOut:"failed"}})&&n({session:null,mfa:null,error:i.context.errors.authentication||null})}),r.send({type:"SIGNIN_PASSWORDLESS_SMS",...e})}):"otp"in e?new Promise(n=>{r.onTransition(i=>{i.matches({authentication:"signedIn"})?n({session:xe(i.context),mfa:null,error:null}):i.matches({authentication:{signedOut:"failed"}})&&n({session:null,mfa:null,error:i.context.errors.authentication||null})}),r.send({type:"SIGNIN_PASSWORDLESS_SMS_OTP",...e})}):{session:null,mfa:null,error:{message:"Incorrect parameters",status:500}}}async signOut(e){let r=await this.waitUntilReady();return this.isAuthenticated()?new Promise(n=>{r.send({type:"SIGNOUT",all:e==null?void 0:e.all}),r.onTransition(i=>{i.matches({authentication:{signedOut:"success"}})?n({error:null}):i.matches({authentication:{signedOut:"failed"}})&&n({error:i.context.errors.signout||null})})}):{error:pl}}async resetPassword({email:e,options:r}){return new Promise(n=>{let i=me(Po(M(this,j)));i.onTransition(({event:s})=>{if(s.type==="ERROR")return n({error:s.error});if(s.type==="SUCCESS")return n({error:null})}),i.start(),i.send({type:"REQUEST",email:e,options:r})})}async changePassword(e){return new Promise(r=>{let n=me(Co(M(this,j)));n.onTransition(({event:i})=>{if(i.type==="ERROR")return r({error:i.error});if(i.type==="SUCCESS")return r({error:null})}),n.start(),n.send({type:"REQUEST",password:e.newPassword})})}async sendVerificationEmail(e){return new Promise(r=>{let n=me(No(M(this,j)));n.onTransition(({event:i})=>{if(i.type==="ERROR")return r({error:i.error});if(i.type==="SUCCESS")return r({error:null})}),n.start(),n.send({type:"REQUEST",email:e.email,options:e.options})})}async changeEmail({newEmail:e,options:r}){return new Promise(n=>{let i=me(Oo(M(this,j)));i.onTransition(({event:s})=>{if(s.type==="ERROR")return n({error:s.error});if(s.type==="SUCCESS")return n({error:null})}),i.start(),i.send({type:"REQUEST",email:e,options:r})})}async deanonymize(e){let r=await this.waitUntilReady();return new Promise(n=>{var a;if(!this.isAuthenticated()||!((a=r.state.context.user)!=null&&a.isAnonymous))return{error:ml};r.onTransition(c=>{c.matches({authentication:{signedIn:{deanonymizing:"success"}}})?n({error:null}):c.matches({authentication:{signedIn:{deanonymizing:"error"}}})&&n({error:c.context.errors.authentication||null})}),r.start();let{signInMethod:i,connection:s,...o}=e;r.send({type:"DEANONYMIZE",signInMethod:i,connection:s,options:o})})}onTokenChanged(e){var r;return M(this,j).interpreter?this.onTokenChangedSubscriptions.add((r=M(this,j).interpreter)==null?void 0:r.onTransition(({event:n,context:i})=>{n.type==="TOKEN_CHANGED"&&e(xe(i))})):console.log("onTokenChanged: no interpreter is set yet",e),()=>{this.onTokenChangedSubscriptions.forEach(n=>n.stop())}}onAuthStateChanged(e){var r;return M(this,j).interpreter?this.onAuthStateChangedSubscriptions.add((r=M(this,j).interpreter)==null?void 0:r.onTransition(({event:n,context:i})=>{n.type==="SIGNED_IN"?e("SIGNED_IN",xe(i)):n.type==="SIGNED_OUT"&&e("SIGNED_OUT",xe(i))})):console.log("onAuthStateChanged: no interpreter is set yet",e),()=>{this.onAuthStateChangedSubscriptions.forEach(n=>n.stop())}}isAuthenticated(){var e;return!!((e=M(this,j).interpreter)!=null&&e.state.matches({authentication:"signedIn"}))}async isAuthenticatedAsync(){return(await this.waitUntilReady()).state.matches({authentication:"signedIn"})}getAuthenticationStatus(){return this.isReady()?{isAuthenticated:this.isAuthenticated(),isLoading:!1}:{isAuthenticated:!1,isLoading:!0}}getJWTToken(){return this.getAccessToken()}getAccessToken(){var e,r;return(r=(e=M(this,j).interpreter)==null?void 0:e.state.context.accessToken.value)!=null?r:void 0}async refreshSession(e){try{let r=await this.waitUntilReady();return r.state.matches({token:"idle"})?void 0:new Promise(n=>{let i=e||r.state.context.refreshToken.value;if(!i)return n();r==null||r.onTransition(s=>{(s.matches({token:{idle:"error"}})||s.event.type==="TOKEN_CHANGED")&&n()}),r.send({type:"TRY_TOKEN",token:i})})}catch{return}}getSession(){var e,r;return xe((r=(e=M(this,j).interpreter)==null?void 0:e.state)==null?void 0:r.context)}getUser(){var e,r,n;return((n=(r=(e=M(this,j).interpreter)==null?void 0:e.state)==null?void 0:r.context)==null?void 0:n.user)||null}waitUntilReady(){let r=M(this,j).interpreter;if(!r)throw Error("Auth interpreter not set");return r.state.hasTag("ready")?Promise.resolve(r):new Promise((n,i)=>{let s=setTimeout(()=>i(`The state machine is not yet ready after ${15} seconds.`),15e3);r.onTransition(o=>{if(o.hasTag("ready"))return clearTimeout(s),n(r)})})}isReady(){var e,r;return!!((r=(e=M(this,j).interpreter)==null?void 0:e.state)!=null&&r.hasTag("ready"))}get client(){return M(this,j)}};j=new WeakMap;var Ja=Lt(Ga()),Mn=class{constructor({url:e}){this.url=e,this.httpClient=Ja.default.create({baseURL:this.url})}async upload(e){try{return{fileMetadata:(await this.httpClient.post("/files",e.file,{headers:{...this.generateUploadHeaders(e),...this.generateAuthHeaders()}})).data,error:null}}catch(r){return{fileMetadata:null,error:r}}}async getPresignedUrl(e){try{let{fileId:r}=e;return{presignedUrl:(await this.httpClient.get(`/files/${r}/presignedurl`,{headers:{...this.generateAuthHeaders()}})).data,error:null}}catch(r){return{presignedUrl:null,error:r}}}async delete(e){try{let{fileId:r}=e;return await this.httpClient.delete(`/files/${r}`,{headers:{...this.generateAuthHeaders()}}),{error:null}}catch(r){return{error:r}}}setAccessToken(e){return this.accessToken=e,this}setAdminSecret(e){return this.adminSecret=e,this}generateUploadHeaders(e){let{bucketId:r,name:n,id:i}=e,s={};return r&&(s["x-nhost-bucket-id"]=r),i&&(s["x-nhost-file-id"]=i),n&&(s["x-nhost-file-name"]=n),s}generateAuthHeaders(){return!this.adminSecret&&!this.accessToken?null:this.adminSecret?{"x-hasura-admin-secret":this.adminSecret}:{Authorization:`Bearer ${this.accessToken}`}}};var Ln=class{constructor({url:e}){this.url=e,this.api=new Mn({url:e})}async upload(e){let r=new FormData;r.append("file",e.file);let{fileMetadata:n,error:i}=await this.api.upload({...e,file:r});return i?{fileMetadata:null,error:i}:n?{fileMetadata:n,error:null}:{fileMetadata:null,error:new Error("Invalid file returned")}}getUrl(e){return this.getPublicUrl(e)}getPublicUrl(e){let{fileId:r}=e;return`${this.url}/files/${r}`}async getPresignedUrl(e){let{presignedUrl:r,error:n}=await this.api.getPresignedUrl(e);return n?{presignedUrl:null,error:n}:r?{presignedUrl:r,error:null}:{presignedUrl:null,error:new Error("Invalid file id")}}async delete(e){let{error:r}=await this.api.delete(e);return r?{error:r}:{error:null}}setAccessToken(e){return this.api.setAccessToken(e),this}setAdminSecret(e){return this.api.setAdminSecret(e),this}};var Yu=Lt(ii()),si=class{constructor(e){let{url:r}=e;this.accessToken=null,this.instance=Yu.default.create({baseURL:r})}async call(e,r,n){let i={...this.generateAccessTokenHeaders(),...n==null?void 0:n.headers},s;try{s=await this.instance.post(e,r,{...n,headers:i})}catch(o){if(o instanceof Error)return{res:null,error:o}}return s?{res:s,error:null}:{res:null,error:new Error("Unable to make post request to funtion")}}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}};var Qu=Lt(ii()),oi=class{constructor(e){let{url:r}=e;this.url=r,this.accessToken=null,this.instance=Qu.default.create({baseURL:r})}async request(e,r,n){let i={...n==null?void 0:n.headers,...this.generateAccessTokenHeaders()},s="",o;try{o=(await this.instance.post("",{operationName:s||void 0,query:e,variables:r},{...n,headers:i})).data}catch(a){return a instanceof Error?{data:null,error:a}:(console.error(a),{data:null,error:new Error("Unable to get do GraphQL request")})}return typeof o!="object"||Array.isArray(o)||o===null?{data:null,error:new Error("incorrect response data from GraphQL server")}:(o=o,o.errors?{data:null,error:o.errors}:{data:o.data,error:null})}getUrl(){return this.url}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}};var ai=class{constructor({backendUrl:e,refreshIntervalTime:r,clientStorageGetter:n,clientStorageSetter:i,clientStorage:s,clientStorageType:o,autoRefreshToken:a,autoLogin:c,start:f=!0,Client:u}){if(!e)throw new Error("Please specify a `backendUrl`. Docs: [todo]!");this.auth=new yn({url:`${e}/v1/auth`,refreshIntervalTime:r,clientStorageGetter:n,clientStorageSetter:i,clientStorage:s,clientStorageType:o,autoRefreshToken:a,autoLogin:c,start:f,Client:u}),this.storage=new Ln({url:`${e}/v1/storage`}),this.functions=new si({url:`${e}/v1/functions`}),this.graphql=new oi({url:`${e}/v1/graphql`}),this.storage.setAccessToken(this.auth.getAccessToken()),this.functions.setAccessToken(this.auth.getAccessToken()),this.graphql.setAccessToken(this.auth.getAccessToken()),this.auth.client.onStart(()=>{this.auth.onAuthStateChanged((d,l)=>{this.storage.setAccessToken(l==null?void 0:l.accessToken),this.functions.setAccessToken(l==null?void 0:l.accessToken),this.graphql.setAccessToken(l==null?void 0:l.accessToken)}),this.auth.onTokenChanged(d=>{this.storage.setAccessToken(d==null?void 0:d.accessToken),this.functions.setAccessToken(d==null?void 0:d.accessToken),this.graphql.setAccessToken(d==null?void 0:d.accessToken)})})}};var Zg=t=>new ai(t);export{ai as NhostClient,Zg as createClient};
10
10
  /*! *****************************************************************************
11
11
  Copyright (c) Microsoft Corporation.
12
12