"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[85177],{85177:function(e,t,n){n.d(t,{Oi:function(){return H},jF:function(){return Q},Rc:function(){return G},__:function(){return Z},s:function(){return X},iL:function(){return F},Zy:function(){return z},EW:function(){return U},HD:function(){return J}});var r=n(27573),o=n(3626),i=n(38608),s=n(95565),c=n(93562),a=n(76186),l=n.n(a),u=n(51983);var d=n(6623);function h(e,t){return(!t.actor||e.actor===t.actor)&&((!t.object||e.object===t.object)&&t.name.includes(e.name))}var m,f=n(45734),v=n(97712);!function(e){e[e.Accepted=1]="Accepted",e[e.SoftRejected=0]="SoftRejected",e[e.Rejected=-1]="Rejected"}(m||(m={}));v.z.array(v.z.object({name:v.z.string(),object:v.z.string(),data:v.z.any()})),v.z.array(v.z.number().int().min(-1).max(1));class g{add(e){var t=this;return this.cb&&0===this._listeners.size&&(this._onCleanup=this.cb((function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.emit(...n)}))),this._listeners.add(e),()=>{this._listeners.delete(e),0===this._listeners.size&&this._onCleanup&&this._onCleanup()}}emit(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._listeners.forEach((e=>e(...t)))}constructor(e){this.cb=e,this._listeners=new Set,this._onCleanup=null,this.event=e=>this.add(e),this.once=e=>{const t=this.add((function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];t(),e(...r)}));return t}}}const p="uncommittedEvents";class b{unsubProjection(e,t){this.server.unsubProjection(e,t)}onStateChange(e){return this.server.onStateChange(e)}async getProjection(e){if("offline"===e.source||"race"===e.source){const t=await this.storage.get("".concat(e.name,":").concat((0,o.P)(e.param)));t&&this._onProjection.emit({...e,source:"offline",value:t})}if("server"===e.source||"race"===e.source){const t=await this.server.getProjection(e);if(t){const n="".concat(e.name,":").concat((0,o.P)(e.param));this.storage.put(n,t).catch((e=>{this.l.error({error:(0,s.Xy)(e),key:n},"failed to save item to storage")})),this._onProjection.emit({...e,source:"server",value:t})}}}subProjection(e,t){const n=(0,o.P)(t),r="".concat(e,":").concat(n);this.getProjection({name:e,param:t,source:"offline"}),this.server.subProjection(e,t,(n=>{this.storage.put(r,n).catch((e=>{this.l.error({error:(0,s.Xy)(e),key:r},"failed to save item to storage")})),this._onProjection.emit({name:e,param:t,value:n,source:"server"})}))}async addEvent(e){const t=[...this.uncommittedEvents,e];this.uncommittedEvents=t,this._onUncommittedEventsChanged.emit(),this.uncommittedEvents=await this.storage.upd(p,(t=>[...t||[],e])),l()(this.uncommittedEvents,t)||this._onUncommittedEventsChanged.emit()}async loadUncommittedEvents(){var e;this.uncommittedEvents=null!==(e=await this.storage.get(p))&&void 0!==e?e:[]}async commit(){let e=[];const t={accepted:[],rejected:[],softRejected:[],uncommitted:this.uncommittedEvents};await this.storage.lock(p,{signal:(new AbortController).signal},(async()=>{if(this.loadUncommittedEvents(),0!==this.uncommittedEvents.length){this.l.info({numEvents:this.uncommittedEvents.length},"committing events");try{const n=this.uncommittedEvents.slice(0,48),r=await(0,f.Z)((e=>this.server.addEvents(n,e)),1e3);this.l.info({res:r},"committed events");for(let e=0;e<r.length;e++){const o=n[e],[i,s]=r[e];i===m.Rejected&&t.rejected.push({event:o,reason:s}),i===m.SoftRejected&&t.softRejected.push({event:o,reason:s}),i===m.Accepted&&t.accepted.push(o)}e=n.filter(((e,t)=>r[t][0]===m.Accepted));const o=n.filter(((e,t)=>r[t][0]===m.Accepted||r[t][0]===m.Rejected)).map((e=>e.localId));this.storage.put("rejectedEvents",(e=>[...e||[],...t.rejected])),t.uncommitted=this.uncommittedEvents=await this.storage.upd(p,(e=>(e||[]).filter((e=>!o.includes(e.localId)))))}catch(n){if(n instanceof f.W)return this.l.warn({n:this.uncommittedEvents.length},"committing events timed out"),void this._onError.emit("committing ".concat(this.uncommittedEvents.length," events timed out after 1s."));this.l.error({n:this.uncommittedEvents.length,error:(0,s.Xy)(n)},"failed to commit events"),this._onError.emit("failed to commit ".concat(this.uncommittedEvents.length," events. ").concat(n.message))}}})),this._onUncommittedEventsChanged.emit(),e.length<1||this._onCommitted.emit(t)}async reconnect(){}constructor(e,t){this.server=e,this.storage=t,this.l=c.ZP.child({namespace:"ConnectionWithStorage"}),this._onProjection=new g,this.onProjection=this._onProjection.event,this._onCommitted=new g,this.onCommitted=this._onCommitted.event,this.uncommittedEvents=[],this._onUncommittedEventsChanged=new g((e=>this.storage.sub(((t,n)=>{t===p&&(this.uncommittedEvents=n,e())})))),this.onUncommittedEventsChanged=this._onUncommittedEventsChanged.event,this._onError=new g,this.onError=this._onError.event,this.loadUncommittedEvents()}}class w{static withStorage(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:(new AbortController).signal,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return new w(new b(e,t),n,r,o)}gc(){this.itemCache.forEach((e=>{for(const[n,r]of e.values.entries()){var t;if(0!==r.callbacks.size)return;null===(t=r.unsubscribe)||void 0===t||t.call(r),delete r.unsubscribe,e.values.delete(n)}0===e.values.size&&this.itemCache.delete(e.projection.name)}))}invalidateAllOptimistic(){for(const e of this.itemCache.values())for(const t of e.values.values()){t.optimistic=void 0;for(const e of t.callbacks)e()}}updateOptimistic(e,t,n){var r;const i=(0,o.P)(t),s=this.cacheEntry(e,i);var c;const a=null!==(c=null===(r=s.optimistic)||void 0===r?void 0:r.data)&&void 0!==c?c:s.current.data,u=n(a);if(!l()(a,u)){s.optimistic={...s.current,data:u,isOptimistic:!0};for(const e of s.callbacks)e()}}updateAllOptimistic(e,t){var n,r;for(const[a,u]of null!==(r=null===(n=this.itemCache.get(e.name))||void 0===n?void 0:n.values.entries())&&void 0!==r?r:[]){var i,s,c;const e=null!==(c=null===(i=u.optimistic)||void 0===i?void 0:i.data)&&void 0!==c?c:null===(s=u.current)||void 0===s?void 0:s.data;if(!e)continue;const n=t(e,(0,o.p)(a));if(!l()(e,n)){u.optimistic={...u.current,data:n,isOptimistic:!0};for(const e of u.callbacks)e()}}}refetchAll(e,t){var n;const r=[];var i;for(const[u,d]of null!==(i=null===(n=this.itemCache.get(e.name))||void 0===n?void 0:n.values.entries())&&void 0!==i?i:[]){var c,a,l;t(null!==(l=null===(c=d.optimistic)||void 0===c?void 0:c.data)&&void 0!==l?l:null===(a=d.current)||void 0===a?void 0:a.data,(0,o.p)(u))&&r.push(this.get(e,(0,o.p)(u),"server",!0).catch((e=>{this.l.error({error:(0,s.Xy)(e)},"failed to invalidate item")})))}return Promise.all(r)}refetch(e,t){return this.l.info({proj:e.name,param:t},"refetching projection"),this.get(e,t,"server",!0)}refetchNamed(e,t){const n=this.itemCache.get(e);if(n)return this.refetch(n.projection,t);this.l.error({projName:e,param:t},"projection not found")}refetchAllNamed(e){const t=this.itemCache.get(e);if(t)return this.refetchAll(t.projection,(()=>!0));this.l.error({projName:e},"projection not found")}promise(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"offline";var r,i;const s=(0,o.P)(t),c=this.cacheEntry(e,s);if("offline"===n&&c.offlinePromise)return c.offlinePromise;if("server"===n&&c.serverPromise)return c.serverPromise;let a;return a="server"===(null===(r=c.current)||void 0===r?void 0:r.source)||"offline"===n&&"offline"===(null===(i=c.current)||void 0===i?void 0:i.source)?Promise.resolve(c.current):new Promise((r=>{const o=this._subToEntry(c,(()=>{("server"===c.current.source||"offline"===n&&"offline"===c.current.source)&&(r(c.current),o())}),e,t)})),"offline"===n&&(c.offlinePromise=a),"server"===n&&(c.serverPromise=a),a}async get(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"server",r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(this.l.info({projection:e.name,param:t,mode:n},"get"),(0,u.oF)(e))return{data:await e.compute({get:(e,t)=>this.get(e,t,n,r).then((e=>e.data)),isAdmin:!1,param:t,uid:this.uid,signal:this.signal}),timedOut:!1};const i=this.cacheEntry(e,(0,o.P)(t));if(!i.lastFetch||Date.now()-i.lastFetch>1e4||r)i.lastFetch=Date.now(),this.base.getProjection({name:e.name,param:t,source:n});else{var s,c;if((null===(s=i.current)||void 0===s?void 0:s.source)===n)return Promise.resolve(i.current);if(("offline"===n||"race"===n)&&"server"===(null===(c=i.current)||void 0===c?void 0:c.source))return Promise.resolve(i.current)}return new Promise(((e,t)=>{const r=()=>{var o;(null===(o=i.current)||void 0===o?void 0:o.source)!==n&&"offline"!==n&&"race"!==n||(i.current.error?t(i.current.error):e(i.current),i.callbacks.delete(r),this._cleanupEntry(i))};i.callbacks.add(r)}))}subComputed(e,t,n){let r=[],i=!1,c=!1,a=!1;const l=async()=>{if(c)return;if(i)return void(a=!0);a=!1,i=!0;let u=[];try{const r=[],i=await t.compute({get:(e,t)=>{var n;if(c)return Promise.reject(new Error("canceled"));const i=(0,o.P)(t),s=this.cacheEntry(e,i);return u.push(s),s.callbacks.add(l),s.current?Promise.resolve(null===(n=this.getCached(e,i))||void 0===n?void 0:n.data):new Promise((n=>{const o=this.subscribe(e,t,(()=>{n(s.current.data),r.push(s.current.source),o()}))}))},isAdmin:!1,param:n,uid:this.uid,signal:this.signal});e.current={data:i,source:r.includes("initial")?"initial":r.includes("offline")?"offline":"server",timedOut:!1}}catch(d){this.l.error({error:(0,s.Xy)(d)},"failed to compute projection"),e.current={data:null,source:"initial",timedOut:!1}}for(const t of e.callbacks)t();i=!1;for(const e of r)u.includes(e)||e.callbacks.delete(l);r=u,a&&l()};return l(),()=>{c=!0;for(const e of r)e.callbacks.delete(l),this._cleanupEntry(e)}}subscribe(e,t,n){const r=(0,o.P)(t),i=this.cacheEntry(e,r);return this._subToEntry(i,n,e,t)}_subToEntry(e,t,n,r){var o;return e.callbacks.add(t),e.unsubscribe||this._subToEntryInternal(e,n,r),(null===(o=e.current)||void 0===o?void 0:o.error)&&this.get(n,r,"server"),()=>{e.callbacks.delete(t),this._cleanupEntry(e)}}_subToEntryInternal(e,t,n){(0,u.xo)(t)?this.get(t,n,"race"):(0,u.oF)(t)?e.unsubscribe=this.subComputed(e,t,n):(this.base.subProjection(t.name,n),e.unsubscribe=()=>this.base.unsubProjection(t.name,n))}_cleanupEntry(e){0===e.callbacks.size&&setTimeout((()=>{var t;0===e.callbacks.size&&(null===(t=e.unsubscribe)||void 0===t||t.call(e),e.unsubscribe=void 0)}),5e3)}getCached(e,t,n){var r;let i=null===(r=this.itemCache.get(e.name))||void 0===r?void 0:r.values.get(t);if(n&&!(null===i||void 0===i?void 0:i.current)&&(i||(i=this.cacheEntry(e,t)),i.current={data:n,version:"object"===typeof n&&"version"in n&&"string"===typeof n.version?n.version:void 0,timedOut:!1,source:"initial"}),!(null===i||void 0===i?void 0:i.current)&&"initialState"in e&&(i||(i=this.cacheEntry(e,t)),i.current={data:e.initialState(t),timedOut:!1,source:"initial"}),(null===i||void 0===i?void 0:i.current)&&!i.optimistic&&"reducer"in e){const n=(0,o.p)(t),r=e.filter(n),s=this.base.uncommittedEvents.filter((e=>h(e,r))).reduce(((n,r)=>e.reducer(n,r,t)),structuredClone(i.current.data));i.optimistic={...i.current,data:s,isOptimistic:!0}}var s,c;return null!==(c=null!==(s=null===i||void 0===i?void 0:i.optimistic)&&void 0!==s?s:null===i||void 0===i?void 0:i.current)&&void 0!==c?c:null}cacheEntry(e,t){let n=this.itemCache.get(e.name);n||(n={projection:e,values:new Map},this.itemCache.set(e.name,n));let r=n.values.get(t);return r||(r={current:void 0,callbacks:new Set},n.values.set(t,r),r)}setServerItem(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"server";const o=this.cacheEntry(e,t);if(o.current){if("version"in o.current&&"version"in n&&void 0!==o.current.version&&o.current.version>n.version)return void this.l.error({proj:e.name,param:t,value:n,current:o.current,source:r},"server version older than current version. Ignoring update.");if(l()(o.current.data,n))return void this.l.debug({proj:e.name,param:t},"projection value did not change, no need to update");if("offline"===r&&"server"===o.current.source)return void this.l.warn({proj:e.name,param:t,value:n,current:o.current,source:r},"offline value arrived later than server value. Ignoring it.")}o.current=null!==n&&void 0!==n?n:{},o.current.source=r,o.optimistic=void 0;try{for(const e of o.callbacks)e()}catch(i){this.l.error({error:(0,s.Xy)(i)},"error calling callbacks after setting server item")}this.l.debug({proj:e.name,param:t,value:n,source:r},"server item set")}setInitial(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"initial";const o=this.cacheEntry(e,t);if(!o.current){o.current={data:n instanceof Function?n():n,source:r,timedOut:!1};for(const e of o.callbacks)e()}}add(e,t,n){this.l.info({name:e,object:t,data:n},"adding event");const r=this.genId(),o={name:e,object:t,data:n,localId:r,originalId:r,actor:this.uid};this.base.addEvent(o);const i=new Set;for(const s of this.itemCache.values())if("reducer"in s.projection)for(const[e,t]of s.values.entries()){if("filter"in s.projection){const t=s.projection.filter(e);if(!(0,u.Qd)(t,o))continue}t.optimistic=void 0;for(const e of t.callbacks)i.add(e)}for(const s of i)s();return this.batchCommit(),this._onEventAdded.emit(o),r}async addAndWait(e,t,n,r){const o=new Promise(((o,i)=>{const s=this.add(e,t,n),c=this.base.onCommitted((e=>{for(const t of e.accepted)t.localId===s&&(o(s),l());for(const{event:t}of e.rejected)t.localId===s&&(i(s),l())})),a=(0,d.Z)(null!==r&&void 0!==r?r:this.signal,(()=>{i(s),l()}));function l(){c(),a()}}));return await this.commit(),o}onEventCommitted(e){return this.base.onCommitted((t=>{for(const n of t.accepted)e(n)}))}async commit(){return this.base.commit()}constructor(e,t="",n=(new AbortController).signal,r=!1){this.base=e,this.uid=t,this.signal=n,this.l=c.ZP.child({namespace:"ClientConnection"}),this.connectionsCount=0,this.genId=(0,i.tn)(),this.itemCache=new Map,this._onEventAdded=new g,this.onEventAdded=this._onEventAdded.event,this.batchCommit=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=null;const r=()=>{n||(n=setTimeout((()=>{n=null,e()}),t))};return r.trigger=()=>(n&&clearTimeout(n),n=null,e()),r}((()=>this.commit()),10),this.l.info("created client connection");const a=r?null:setInterval((()=>{this.base.uncommittedEvents.length>0&&this.batchCommit(),this.gc()}),1e4),l=new Set;l.add(e.onStateChange((e=>{if("open"!==e)return this.connectionsCount++,void this.l.info("server connection closed");let t=0;this.itemCache.forEach((e=>{for(const[n,r]of e.values.entries())0===r.callbacks.size?(delete r.unsubscribe,e.values.delete(n)):(this._subToEntryInternal(r,e.projection,(0,o.p)(n)),t++);0===e.values.size&&this.itemCache.delete(e.projection.name)})),this.l.info({numProjections:t},"server connection open, committing and resubscribing"),this.commit()}))),(0,d.Z)(n,(()=>{this.l.info("aborting client connection"),a&&clearInterval(a),l.forEach((e=>e()));for(const[,e]of this.itemCache)e.values.forEach((e=>{var t;return null===(t=e.unsubscribe)||void 0===t?void 0:t.call(e)}))})),l.add(e.onProjection((e=>{const t=(0,o.P)(e.param),n=this.itemCache.get(e.name);n?this.setServerItem(n.projection,t,e.value,e.source):c.ZP.warn({name:e.name,param:t},"projection for result from base not found, ignoring it")}))),l.add(e.onCommitted((e=>{for(const o of this.itemCache.values())if("reducer"in o.projection)for(const[i,c]of o.values.entries()){let a=y;try{if("filter"in o.projection){const t=o.projection.filter(i);if(a=e.accepted.filter((e=>e.originalId&&(void 0===c.current.version||e.originalId>c.current.version)&&(0,u.Qd)(t,e))),0===a.length&&!e.rejected.some((e=>{let{event:n}=e;return(0,u.Qd)(t,n)})))continue}}catch(n){this.l.error({error:(0,s.Xy)(n),projection:o.projection.name,param:i},"error in filter for ".concat(o.projection.name));continue}try{let e=structuredClone(c.current.data);for(const n of a){var t;e=null!==(t=o.projection.reducer(e,n,i))&&void 0!==t?t:c.current}this.setServerItem(o.projection,i,{...c.current,data:e})}catch(r){this.l.error({error:(0,s.Xy)(r),events:a,projection:o.projection.name,param:i},"error in reducer")}}})))}}const y=[];var S=n(7653);function j(e){const t=(0,S.useRef)(e);return l()(e,t.current)||(t.current=e),t.current}class E{async get(e){const t=new Promise(((t,n)=>{this._actions.push({type:"get",key:e,resolve:t,reject:n})}));return await Promise.race([t,this._getOrStartCommit()]),t}async set(e,t){return new Promise(((n,r)=>{this._actions.push({type:"set",key:e,value:t,resolve:n,reject:r}),this._getOrStartCommit()}))}async delete(e){return this._actions.push({type:"delete",key:e}),this._getOrStartCommit()}async destroy(){const e=await this.db;e.close();const t=indexedDB.deleteDatabase(e.name);return this.db=Promise.reject(new Error("This idb-kv instance has been destroyed")),new Promise(((e,n)=>{t.onsuccess=()=>e(),t.onerror=()=>n(t.error)}))}_getOrStartCommit(){return this._commitPromise||(this._commitPromise=this._commit()),this._commitPromise}async _commit(){await new Promise((e=>setTimeout(e,this.batchInterval)));const e=(await this.db).transaction(this.storeName,"readwrite"),t=e.objectStore(this.storeName),n=new Map;for(const s of this._actions)switch(s.type){case"get":{const e=t.get(s.key);e.onsuccess=()=>s.resolve(e.result),e.onerror=()=>s.reject(e.error);break}case"set":try{var r;let e=s.value;if(e instanceof Function){e=e(n.get(s.key)||await new Promise(((e,n)=>{const r=t.get(s.key);r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)})).catch((()=>null)))}n.set(s.key,e),t.put(e,s.key),null===(r=s.resolve)||void 0===r||r.call(s,e)}catch(i){var o;null===(o=s.reject)||void 0===o||o.call(s,i)}break;case"delete":t.delete(s.key)}return this._actions=[],this._commitPromise=null,new Promise(((t,n)=>{e.oncomplete=()=>t(),e.onabort=e=>n(e.target.error),e.onerror=()=>{e.error&&n(e.error)}}))}constructor(e,{batchInterval:t=10}={}){this._actions=[],this._commitPromise=null,this.storeName="idb-kv",this.batchInterval=t,this.db=new Promise(((t,n)=>{const r=indexedDB.open(e,1);r.onsuccess=()=>t(r.result),r.onerror=()=>{n(new Error("error opening the indexedDB database named ".concat(e,": ").concat(r.error)))},r.onupgradeneeded=()=>r.result.createObjectStore(this.storeName)})),this._commitPromise=null}}class k{async get(e){console.log("GET",e);const t=await this.db.get(e);return console.log("GET",t),t}async upd(e,t){console.log("UPD",e);const n=await this.db.set(e,t);return console.log("UPD",n),n}async put(e,t){console.log("PUT",e,t),await this.db.set(e,t)}sub(e){return()=>{}}close(){}lock(e,t,n){let{signal:r}=t;if(!window.navigator.locks)return n();return window.navigator.locks.request(e,{signal:r},n)}constructor(e="offline"){this.db=new E(e)}}var P=n(92196);class C{onError(e,t){return this.worker.addEventListener("error",e,{signal:t}),()=>{this.worker.removeEventListener("error",e)}}onMessage(e,t){return this._onMessageHandlers.add(e),1===this._onMessageHandlers.size&&this._onMessage(((e,t)=>{console.log((new Date).toISOString().slice(11,19),t,"->",e.data),this._onMessageHandlers.forEach((n=>n(e,t)))})),t&&t.addEventListener("abort",(()=>{this._onMessageHandlers.delete(e)})),()=>{this._onMessageHandlers.delete(e)}}_onMessage(e,t){const n=t=>e(t,"port");return this.worker.port.addEventListener("message",n,{signal:t}),()=>{this.worker.port.removeEventListener("message",n)}}start(){this.l.debug("Starting shared worker connection"),this.worker.port.start()}close(){this.l.debug("Closing shared worker connection"),this.worker.port.close()}send(e){console.log((new Date).toISOString().slice(11,19),"sharedWorker <-",e),this.worker.port.postMessage(e)}constructor(e){this.worker=e,this.l=c.ZP.child({namespace:"SharedClyeWorkerConnection"}),this._onMessageHandlers=new Set}}function _(){const e={};return"undefined"!==typeof navigator&&(/iPad|iPhone|iPod/.test(navigator.userAgent||"")||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1)&&(e.is="ios"),/Android/i.test(navigator.userAgent)&&(e.is="android"),"twaPort"in window&&(e.twaPostMessaging=!0),"colorScheme"in window&&(e.colorScheme=window.colorScheme),e.language=navigator.language,e}class O{handleMessageFromWorker(e,t){switch(e.type){case"connected":this._onStateChange.emit(this.state="open");break;case"disconnected":this._onStateChange.emit(this.state="close");break;case"proj":this._onProjection.emit(e);break;case"uncommitted":this.uncommittedEvents=e.events,this._onUncommittedEventsChanged.emit(e.events);break;case"error":this._onError.emit(e.message,e.id);break;case"committed":l()(this.uncommittedEvents,e.uncommitted)||(this.uncommittedEvents=e.uncommitted,this._onUncommittedEventsChanged.emit(e.uncommitted)),this._onCommitted.emit(e);break;case"unpause":this.sendMsgToWorker({type:"tabOpened",id:this.id});break;default:console.warn("Unknown message from shared worker",e)}}onStateChange(e){return e(this.state),this._onStateChange.add(e)}static open(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:(new AbortController).signal;if("undefined"===typeof window.SharedWorker)return console.warn("Your browser does not support SharedWorkers"),null;const t=new SharedWorker("/shared-worker.js?v=15",{type:"module",name:"clye-worker-15"});return console.log("worker",t),window.worker=t,new O(new C(t),e)}sendMsgToWorker(e){this.worker.send(e)}getProjection(e){const t=(0,P.x0)(10),n=(0,o.P)(e.param);return new Promise(((r,i)=>{const s=this.onProjection((t=>{t.name===e.name&&(0,o.P)(t.param)===n&&t.source===e.source&&(r(t.value),s(),c())})),c=this.onError(((e,n)=>{n===t&&(i(e),s(),c())}));this.sendMsgToWorker({type:"getProj",...e,source:e.source,id:t})}))}subProjection(e,t){this.sendMsgToWorker({type:"subProj",name:e,param:t})}unsubProjection(e,t){this.sendMsgToWorker({type:"unsubProj",name:e,param:t})}commit(){this.sendMsgToWorker({type:"commit"})}reconnect(){this.worker.send({type:"reconnect"})}addEvent(e){this.uncommittedEvents.push(e),this.sendMsgToWorker({type:"addEvents",events:[e],id:(0,P.x0)(10)})}constructor(e,t,n=(0,P.x0)(10)){this.worker=e,this.id=n,this._onProjection=new g,this.onProjection=this._onProjection.event,this.state="close",this._onCommitted=new g,this.onCommitted=this._onCommitted.event,this._onStateChange=new g,this._onError=new g,this.onError=this._onError.event,this.webSocketState=WebSocket.CONNECTING,this.uncommittedEvents=[],this._onUncommittedEventsChanged=new g,this.onUncommittedEventsChanged=this._onUncommittedEventsChanged.event,e.onError((e=>{console.error("SharedWorker error",e),this._onError.emit(e.message)}),t),e.onMessage(((e,t)=>{const n=e.data;this.handleMessageFromWorker(n,null!==t&&void 0!==t?t:"port")}),t),e.start(),e.send({type:"tabOpened",id:n});const r=setInterval((()=>{e.send({type:"ping"})}),3e4);window.addEventListener("focus",(()=>{e.send({type:"ping"})}),{signal:t}),window.addEventListener("onbeforeunload",(()=>{e.send({type:"tabClosed",id:n}),e.close(),clearInterval(r)}),{signal:t}),(0,d.Z)(t,(()=>{e.send({type:"tabClosed",id:n}),e.close(),clearInterval(r)}))}}var I=class{get numListeners(){return this.listeners.size+this.listenersOnce.size}constructor(e){this.onFirstListener=e,this.listeners=new Set,this.listenersOnce=new Set,this.onLastListenerRemoved=()=>{},this.on=e=>(this.listeners.add(e),this.onFirstListener&&1===this.listeners.size&&(this.onLastListenerRemoved=this.onFirstListener()||this.onLastListenerRemoved),()=>this.off(e)),this.once=e=>{this.listenersOnce.add(e),this.onFirstListener&&1===this.listeners.size&&(this.onLastListenerRemoved=this.onFirstListener()||this.onLastListenerRemoved)},this.off=e=>{this.listeners.delete(e),0===this.listeners.size&&this.onLastListenerRemoved()},this.emit=e=>{if(this.listeners.forEach((t=>t(e))),this.listenersOnce.size>0)try{this.listenersOnce.forEach((t=>t(e)))}finally{this.listenersOnce.clear()}0===this.listeners.size&&this.onLastListenerRemoved()},this.pipe=e=>this.on((t=>e.emit(t)))}};class T extends Error{}var A=class{getProjection(e){return new Promise(((t,n)=>{this.l.info({name:e.name,param:e.param},"getProjection"),this.send({type:"getProj",name:e.name,param:e.param},e.abort);const r=(0,o.P)(e.param),i="".concat(e.name,":").concat(r);let s=this.getSubs.get(i);var c;s||(s=new Set,this.getSubs.set(i,s));const a=setTimeout((()=>{n(new Error("timeout getting projection ".concat(e.name," ").concat(r))),s.delete(l),0===s.size&&this.getSubs.delete(i),this.debug.emit()}),null!==(c=e.timeout)&&void 0!==c?c:1e4),l=e=>{t(e),clearTimeout(a),s.delete(l),0===s.size&&this.getSubs.delete(i)};s.add(l),e.abort&&(0,d.Z)(e.abort,(()=>{s.delete(l),clearTimeout(a),0===s.size&&this.getSubs.delete(i),n(new T),this.debug.emit()}))}))}subProjection(e,t,n){const r=(0,o.P)(t),i="".concat(e,":").concat(r);let s=this.projSubs.get(i);return s||(s=new Set,this.projSubs.set(i,s),this.sendIfConnected({type:"subProj",name:e,param:t}),this.debug.trace.start("subProj ".concat(e," ").concat(r)),this.debug.emit()),s.add(n),this.debug.emit(),()=>{s.delete(n),0===s.size&&(this.projSubs.delete(i),this.sendIfConnected({type:"unsubProj",name:e,param:t}),this.debug.trace.end("subProj ".concat(e," ").concat(r)),this.debug.emit())}}unsubProjection(e,t){const n=(0,o.P)(t),r="".concat(e,":").concat(n);this.projSubs.get(r)||console.warn("Unsubscribing from projection that had no subscriptions",r),this.projSubs.delete(r),this.sendIfConnected({type:"unsubProj",name:e,param:t}),this.debug.trace.end("subProj ".concat(e," ").concat(n)),this.debug.emit()}addEvents(e,t){const n=(0,P.x0)(10);return this.send({type:"addEvents",events:e,id:n},t),new Promise(((e,r)=>{this.idHandler.set(n,(n=>t&&t.aborted?r(new T):"eventsAdded"!==n.type?("error"===n.type&&r(new Error(n.message)),void r(new Error("Invalid message type"))):(n.ret?e(n.ret):r(new Error("Error adding events")),void this.debug.emit()))),t&&t.addEventListener("abort",(()=>{this.send({type:"abort",id:n}),r(new T)}))}))}get readyState(){var e,t;return null!==(t=null===(e=this.socket)||void 0===e?void 0:e.readyState)&&void 0!==t?t:3}onStateChange(e){return this.readyStateChanged.on((t=>{t===WebSocket.OPEN?e("open"):e("close")}))}get isDead(){return Date.now()-this._lastLiveSignal>this.deadTimeout}notDead(){this._lastLiveSignal=Date.now(),this._deadTimer&&clearTimeout(this._deadTimer),this._deadTimer=setTimeout((()=>{this.l.error("Connection seems dead"),this.close(1e3,"Connection seems dead"),this.connect()}),this.deadTimeout)}async connect(){if(!this.closed)if(this.connecting)this.l.warn("Already connecting");else{this.connecting=!0;try{const e=this.getToken(),t=window.location.origin.replace(/^http/,"ws")+this.url,n=this.socket=new this.WebSocketClass(t);this.notDead();const r=new Promise(((e,t)=>{n.onopen=()=>{this.readyStateChanged.emit(n.readyState),this.l.info("WebSocket connected"),this.notDead(),e()},n.onerror=e=>{this.readyStateChanged.emit(n.readyState),this.l.error({error:(0,s.Xy)(e)},"WebSocket error"),this.reconnect(),t(e)}}));n.onmessage=e=>{if(this.emulateOffline)this.l.warn({data:e.data},"Emulating offline, not processing message");else{this.notDead(),this.l.info({data:e.data},"Message received");try{const t=JSON.parse(e.data);this.handleMessage(t)}catch(t){this.l.error({error:(0,s.Xy)(t)},"Error handling message")}}},n.onclose=e=>{this.readyStateChanged.emit(n.readyState),this.l.info("WebSocket closed: "+e.reason),this.reconnectOnClose(),this.idHandler.forEach((e=>e({type:"error",message:"Connection closed"}))),this.idHandler.clear()};const i=await e;if(await r,n.readyState!==WebSocket.OPEN)return void this.l.error("Socket is not open after connection");n.send(JSON.stringify({type:"init",token:i,..._()})),this._sendBatched();for(const s of this.projSubs.keys()){const e=s.indexOf(":"),t=s.slice(0,e),n=(0,o.p)(s.slice(e+1));this.send({type:"subProj",name:t,param:n}),this.debug.trace.start("subProj ".concat(t," ").concat(s.slice(e+1)))}}catch(e){this.l.error({error:(0,s.Xy)(e)},"Error getting token, or establishing connection")}finally{this.connecting=!1}}}handleMessage(e){switch(e.type){case"ping":this.socket&&this.socket.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify({type:"pong"}));break;case"proj":{this.onAnyProjectionValue.forEach((t=>t(e)));const t=(0,o.P)(e.param),n="".concat(e.name,":").concat(t),r=this.projSubs.get(n);r&&r.forEach((t=>t(e.value)));const i=this.getSubs.get(n);i&&i.forEach((t=>t(e.value))),this.debug.trace.end("subProj ".concat(e.name," ").concat(t)),this.debug.emit();break}case"error":if(e.id){this.debug.emit();const t=this.idHandler.get(e.id);t&&(t(e),this.idHandler.delete(e.id))}this.l.error({msg:e},"Error message");break;default:if("id"in e&&e.id){const t=this.idHandler.get(e.id);if(t){t(e),this.idHandler.delete(e.id),this.debug.emit();break}}this.l.warn({msg:e},"Unknown message")}}async getToken(e){var t;let n="";try{var r;if(n=await async function(e){const t=await fetch("/api/ws/token",{signal:e});return t.ok?(await t.json()).token:""}(e),null===(r=this.idb)||void 0===r||r.set("accessToken",n),n)return n}catch(i){console.error("failed to get token",i,"falling back to offline token")}const o=await(null===(t=this.idb)||void 0===t?void 0:t.get("accessToken"));return"string"===typeof o&&(n=o),n}reconnectOnClose(){this.reconnectTimer||(this.reconnectTimer=setTimeout((()=>{var e,t;this.l.info("Attempting to reconnect..."),this.connect(),this.readyStateChanged.emit(null!==(t=null===(e=this.socket)||void 0===e?void 0:e.readyState)&&void 0!==t?t:WebSocket.CLOSED),this.reconnectTimer=null}),this.reconnectInterval))}reconnect(){this.close(),this.connect()}_sendBatched(e){if(e)return this._sendBatchImmediate();this._sendBatchedTimer||(this._sendBatchedTimer=setTimeout((()=>this._sendBatchImmediate()),10))}_sendBatchImmediate(){var e;if(this.isDead)return this.l.warn({deadForMs:Date.now()-this._lastLiveSignal},"can not send immediately because the connection ist dead, so reconnect"),void this.reconnect();if(this._sendBatchedTimer=null,0!==this.sendBuffer.length){if(!this.socket||this.socket.readyState!==WebSocket.OPEN)return this.l.error({},"Socket not ready to sendBatchImmediate");1!==this.sendBuffer.length||this.sendBufferSignals&&(null===(e=this.sendBufferSignals[0])||void 0===e?void 0:e.aborted)?this.socket.send("["+this.sendBuffer.filter(((e,t)=>!this.sendBufferSignals[t]||!this.sendBufferSignals[t].aborted)).join(",")+"]"):this.socket.send(this.sendBuffer[0]),this.sendBuffer=[],this.sendBufferSignals=[]}}_send(e,t){this.sendBuffer.push(e),this.sendBufferSignals.push(null!==t&&void 0!==t?t:null),this.socket&&this.socket.readyState===WebSocket.OPEN&&this._sendBatched()}sendIfConnected(e){this.socket&&this.socket.readyState===WebSocket.OPEN&&(this.sendBuffer.push(JSON.stringify(e)),this.sendBufferSignals.push(null),this._sendBatched())}send(e,t){this._send(JSON.stringify(e),t)}close(e,t){this.l.info({code:e,reason:t,hasSocket:!this.socket},"close"),this.socket&&this.socket.close(e,t),this.socket=null,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}forceClose(){this.l.info("Force closing websocket"),this.closed=!0,this.close(),this.sendBuffer=[],this.sendBufferSignals=[]}constructor(e,t=(new AbortController).signal,n,r=5e3,o=WebSocket,i=new E("offline")){this.url=e,this.signal=t,this.protocols=n,this.reconnectInterval=r,this.WebSocketClass=o,this.idb=i,this.l=c.ZP.child({namespace:"ReconnectingWebSocket"}),this.socket=null,this.reconnectTimer=null,this.deadTimeout=12e4,this.sendBuffer=[],this.sendBufferSignals=[],this.getSubs=new Map,this.projSubs=new Map,this.onAnyProjectionValue=new Set,this.connectionAuthenticated=!1,this.idHandler=new Map,this.readyStateChanged=new I,this._deadTimer=null,this._lastLiveSignal=Date.now(),this.connecting=!1,this.emulateOffline=!1,this._sendBatchedTimer=null,this.closed=!1,this.debug=new N(this.projSubs),this.connect(),(0,d.Z)(t,(()=>this.forceClose()))}};class N extends I{constructor(e){super(),this.projSubs=e,this.trace=new M}}class M{now(){return performance.now()-this.t0}start(e){this.running[e]&&this.end(e),this.running[e]={start:this.now(),end:-1,label:e}}end(e){const t=this.running[e];t&&(t.end=this.now(),this.traces.push(t),delete this.running[e])}add(e,t,n){this.traces.push({start:t,end:n,label:e})}constructor(){this.t0=performance.now(),this.traces=[],this.running={}}}const L=new WeakMap;function W(e){if(L.has(e)){const t=L.get(e);if("fulfilled"===t.status)return t.value;if("rejected"===t.status)throw t.reason;throw e}throw L.set(e,{status:"pending"}),e.then((t=>{L.set(e,{status:"fulfilled",value:t})}),(t=>{L.set(e,{status:"rejected",reason:t})})),e}const x=[];const B={data:null,isFetching:!0,isLoading:!0,timedOut:!1,version:"",fetchStatus:"idle",source:"initial"};function D(e){return!(0,u.xo)(e)}const R=function(){function e(e,n){let{enabled:r=!0,initial:i,with:s,refetchOnMount:c=D(e)}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a=d();window.cc=a;const l=(0,S.useRef)(),u=j(null!==s&&void 0!==s?s:{});l.current||(l.current=i?{data:i instanceof Function?i():i,isFetching:!1,isLoading:!1,source:"initial"}:B);const h=n?(0,o.P)(n):""===n?"":void 0;return(0,S.useMemo)((()=>{if(null===n||void 0===n||!r||void 0===h){const e=()=>l.current;return[()=>()=>{},e,e,a]}let o=!0;return[t=>{if(c&&o){var r;o=!1;const t=a.getCached(e,h,null===(r=l.current)||void 0===r?void 0:r.data);if(t){const r=Date.now();var i;r-(null!==(i=t.lastFetchedAt)&&void 0!==i?i:0)<1e3&&(a.get(e,n),t.lastFetchedAt=r)}}return a.subscribe(e,n,t)},()=>{var t;const n=a.getCached(e,h,null===(t=l.current)||void 0===t?void 0:t.data);return n||B},()=>{if(!("initialState"in e))return l.current;let r=t.get(e);r||t.set(e,r=new Map);let o=r.get(h);if(o)return o;const i=e.initialState(n);return o={...B,data:i},r.set(h,o),o},a]}),[e,h,a,r,u])}let t=new WeakMap;function n(e,n){let{enabled:r=!0}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=d();window.cc=i;const s=(0,S.useRef)(),c=(0,S.useRef)([]),a=j(n);s.current||(s.current=x);const[l,u,h]=(0,S.useMemo)((()=>{if(0===a.length||!r){const e=()=>s.current;return[()=>()=>{},e,e]}const n=a.map(o.P);return[t=>{const n=a.map((n=>i.subscribe(e,n,t)));return()=>n.forEach((e=>e()))},()=>{const t=a.map(((t,r)=>{var o;const c=i.getCached(e,n[r],null===(o=s.current[r])||void 0===o?void 0:o.data);return c||B}));return function(e,t){if(!e||!t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(c.current,t)?c.current:(c.current=t,t)},()=>a.map(((r,o)=>{if(!("initialState"in e))return B;let i=t.get(e);i||t.set(e,i=new Map);let s=i.get(n[o]);if(s)return s;const c=e.initialState(r);return s={...B,data:c},i.set(n[o],s),s}))]}),[e,a,i,r]);return(0,S.useSyncExternalStore)(l,u,h)}const s=(0,S.createContext)(null);function c(e){let{children:t}=e;const n=function(){const e=d();return(0,S.useCallback)(((t,n,r)=>e.add(t,n,r)),[e])}();return(0,r.jsx)(s.Provider,{value:n,children:t})}function a(){return(0,S.useContext)(s)}const u=(0,S.createContext)(null);function d(){return(0,S.useContext)(u)}const h=function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=new AbortController;let n;if(e){const e=O.open(t.signal);if(e)return{connection:new w(e,"",t.signal),cancel:()=>t.abort()}}const r=new k("offline"),o=new A("/api/ws",t.signal);return n=w.withStorage(o,r,"",t.signal),{connection:n,cancel:()=>t.abort()}}();return{connection:h.connection,Provider:function(e){let{children:t,sharedWorkerEnabled:n,uid:o}=e;return(0,S.useEffect)((()=>{h.connection.uid=null!==o&&void 0!==o?o:""}),[o]),(0,r.jsx)(u.Provider,{value:h.connection,children:(0,r.jsx)(c,{children:t})})},ScopedDispatchEventProvider:function(e){let{children:t,modifyEventData:n}=e;const o=a(),c=d().uid,l=(0,S.useCallback)(((e,t,r)=>{const s=(0,i.SK)(),a=n({actor:null!==c&&void 0!==c?c:"",data:r,name:e,object:t,localId:s});return a?o(a.name,a.object,a.data):null}),[o]);return(0,r.jsx)(s.Provider,{value:l,children:t})},DispatchProvider:c,useProjection:function(t,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const[o,i,s,c]=e(t,n,r);if(r.source&&null!==n&&void 0!==n){W(c.promise(t,n,r.source))}return(0,S.useSyncExternalStore)(o,i,s)},useConnection:d,useProjectionSelector:function(t,n,r){const{selector:o}=r,[i,s,c,a]=e(t,n,r),u=j(r.deps),[d,h,m]=(0,S.useMemo)((()=>{let e=o(s());return[t=>i((()=>{const n=o(s()),r=!l()(n,e);e=n,r&&t()})),()=>e,()=>e]}),[i,s,c,u]);if(r.source&&null!==n&&void 0!==n){W(a.promise(t,n,r.source))}return(0,S.useSyncExternalStore)(d,h,m)},useProjections:n,useDispatchEvent:a,useInfiniteProjections:function(e,t){var r;const[o,i]=(0,S.useState)([null!==(r=t.initialCursor)&&void 0!==r?r:null]),s=o.map(t.param);let c=(0,S.useRef)(s);var a;l()(c.current,s.slice(0,c.current.length))||(i([null!==(a=t.initialCursor)&&void 0!==a?a:null]),c.current=[]),c.current=s;const u=n(e,s);var d;let h=[null!==(d=t.initialCursor)&&void 0!==d?d:null];for(let n=0;n<u.length;n++){const e=u[n].data;if(!e)break;var m;h.push(null!==(m=t.getNextCursor(e))&&void 0!==m?m:null)}const f=Math.min(h.length,o.length);l()(h.slice(0,f),o.slice(0,f))||(console.log("Updating cursors",h,o),i((e=>h.slice(0,f).concat(e.slice(f)))));const v=u[u.length-1],g=(null===v||void 0===v?void 0:v.data)?t.getNextCursor(v.data):void 0,p=void 0===g?void 0:null!==g,b=u.some((e=>!e.data));return{isLoading:u.some((e=>e.isLoading||!e.data)),pages:u,hasNextPage:p,isFetching:b,fetchNextPage:()=>{g&&i((e=>[...e,g]))}}},useInitializeProjection:function(e,t,n){const r=d(),i=t?(0,o.P)(t):""===t?"":void 0;void 0!==i&&n&&r.setInitial(e,i,n)}}}(),z=R.useProjection,F=R.useInitializeProjection,U=R.useProjectionSelector,J=R.useProjections,H=R.ScopedDispatchEventProvider,Z=R.useDispatchEvent,X=R.useInfiniteProjections,G=R.useConnection,Q=R.Provider},93562:function(e,t,n){n.d(t,{ZP:function(){return s},v_:function(){return o}});var r=n(24496);const o=new class{push(e){this.data.length<this.capacity?this.data.push(e):this.data[this.start++]=e}*iter(){for(let e=this.start;e<this.data.length;e++)yield this.data[e];for(let e=0;e<this.start;e++)yield this.data[e]}toJSON(){return this.data}constructor(e=100){this.capacity=e,this.data=[],this.start=0}};let i=!1;try{"nodejs"!==window.name&&(i=window.localStorage&&!0)}catch(c){}!function(){if(i)try{const e=window.sessionStorage.getItem("ring");if(!e)return;JSON.parse(e).forEach((e=>o.push(e)))}catch(c){console.error(c)}}(),r.OM.write=e=>{o.push(e),i&&window.localStorage&&window.localStorage.LOG&&function(e){const t=JSON.parse(e),{logLevel:n,namespace:r,package:o,...i}=t.context;let s=null===n||void 0===n?void 0:n.toString(),c="";switch(n){case 10:s="TRACE";break;case 20:s="DEBUG";break;case 30:s="INFO",c="green";break;case 40:s="WARN",c="yellow";break;case 50:s="ERROR",c="red";break;case 60:s="FATAL",c="red"}console.log("%s %c%s%c%s%c %s %o",new Date(t.time).toLocaleTimeString(),"color: ".concat(c,";"),s,"color: initial; fontWight:bold;",r?" ".concat(r):"","fontWeight: initial;",t.message,i)}(e);try{window.sessionStorage.setItem("ring",JSON.stringify(o.toJSON().slice(-10)))}catch(c){console.error(c)}};var s=r.aw.child({package:"clye.app"})},95565:function(e,t,n){n.d(t,{Xy:function(){return c}});var r=n(46385).Buffer;Error;const o=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],i=Symbol(".toJSON was called"),s=e=>{let{from:t,seen:n,to_:c,forceEnumerable:a,maxDepth:l,depth:u}=e;const d=c||(Array.isArray(t)?[]:{});if(n.push(t),u>=l)return d;if("function"===typeof t.toJSON&&!0!==t[i])return(e=>{e[i]=!0;const t=e.toJSON();return delete e[i],t})(t);for(const[o,i]of Object.entries(t))"function"===typeof r&&r.isBuffer(i)?d[o]="[object Buffer]":"function"!==typeof i&&(i&&"object"===typeof i?n.includes(t[o])?d[o]="[Circular]":(u++,d[o]=s({from:t[o],seen:[...n],forceEnumerable:a,maxDepth:l,depth:u})):d[o]=i);for(const{property:r,enumerable:i}of o)"string"===typeof t[r]&&Object.defineProperty(d,r,{value:t[r],enumerable:!!a||i,configurable:!0,writable:!0});return d};function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{maxDepth:n=Number.POSITIVE_INFINITY}=t;return"object"===typeof e&&null!==e?s({from:e,seen:[],forceEnumerable:!0,maxDepth:n,depth:0}):"function"===typeof e?"[Function: ".concat(e.name||"anonymous","]"):e}},51983:function(e,t,n){function r(e){return"type"in e&&"placeholder"===e.type}function o(e){return"compute"in e}function i(e,t){return!!e.name.includes(t.name)&&((!e.actor||e.actor===t.actor)&&((!e.object||e.object===t.object)&&(!(e.after&&t.originalId&&e.after>t.originalId)&&!(e.before&&t.originalId&&e.before<t.originalId))))}n.d(t,{Qd:function(){return i},oF:function(){return o},xo:function(){return r}})},6623:function(e,t,n){function r(e,t){return e.aborted?(t(),()=>{}):(e.addEventListener("abort",t),()=>e.removeEventListener("abort",t))}n.d(t,{Z:function(){return r}})},3626:function(e,t,n){n.d(t,{P:function(){return i},p:function(){return s}});var r=n(39345),o=n.n(r);function i(e){return"string"===typeof e?"{"===e[0]||"["===e[0]||'"'===e[0]?JSON.stringify(e):e:o()(e)}function s(e){if("{"===e[0]||"["===e[0]||'"'===e[0])try{return JSON.parse(e)}catch(t){return e}return e}},45734:function(e,t,n){n.d(t,{W:function(){return r},Z:function(){return o}});class r extends Error{constructor(){super("timeout")}}function o(e,t,n){return new Promise(((o,i)=>{const s="function"===typeof e?e:t=>e,c=new AbortController,a=setTimeout((()=>{c.abort(),n?o(n()):i(new r)}),t);s(c.signal).then(o,i).finally((()=>clearTimeout(a)))}))}},38608:function(e,t,n){n.d(t,{GP:function(){return a},SK:function(){return b},_k:function(){return u},be:function(){return v},qJ:function(){return l},sO:function(){return m},tn:function(){return p}});class r extends Error{}const o="0123456789ABCDEFGHJKMNPQRSTVWXYZ",i=o.length,s=Math.pow(2,48)-1,c=10,a=16,l=Array.from(Array(a)).map((()=>o[0])).join(""),u=Array.from(Array(a)).map((()=>o[i-1])).join("");Array.from(Array(c+a)).map((()=>o[0])).join(""),Array.from(Array(c+a)).map((()=>o[i-1])).join("");function d(e,t,n){return t>e.length-1?e:e.substr(0,t)+n+e.substr(t+1)}function h(e){let t=Math.floor(e()*i);return t===i&&(t=i-1),o.charAt(t)}function m(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c;if(isNaN(e))throw new Error("".concat(e," must be a number"));if(e>s)throw new r("cannot encode time greater than ".concat(s));if(e<0)throw new r("time must be positive");if(!1===Number.isInteger(e))throw new r("time must be an integer");return function(e,t){let n,r="";for(;e>0;e--)n=t%i,r=o.charAt(n)+r,t=(t-n)/i;return r}(t,e)}function f(e,t){let n="";for(;e>0;e--)n=h(t)+n;return n}function v(e){if(!e||e.length!==c+a)throw new r("malformed ulid ".concat(e," must be ").concat(c+a," characters long"));var t=e.substr(0,c).split("").reverse().reduce(((e,t,n)=>{const s=o.indexOf(t);if(-1===s)throw new r("invalid character found: ".concat(t));return e+s*Math.pow(i,n)}),0);if(t>s)throw new r("malformed ulid, timestamp too large");return t}function g(){const e="undefined"!==typeof crypto?crypto:window.crypto;return e?()=>{const t=new Uint8Array(1);return e.getRandomValues(t),t[0]/255}:()=>Math.random()}function p(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:g(),n=0;return function(s){if(isNaN(s)&&(s=Date.now()),s<=n){const t=e=function(e){let t,n,s,c=e.length;const a=i-1;for(;!t&&c-- >=0;){if(n=e[c],s=o.indexOf(n),-1===s)throw new r("incorrectly encoded string");s!==a?t=d(e,c,o[s+1]):e=d(e,c,o[0])}if("string"===typeof t)return t;throw new r("cannot increment this string")}(e);return m(n,c)+t}n=s;const l=e=f(a,t);return m(s,c)+l}}const b=(w||(w=g()),function(e){return isNaN(e)&&(e=Date.now()),m(e,c)+f(a,w)});var w}}]);