zeed 0.9.2 → 0.9.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.
@@ -8,5 +8,5 @@ ${i.stack}`:`${i.name||"Error"}: ${i.message}`;try{return o?JSON.stringify(i,nul
8
8
  `,`
9
9
  `).trim()}
10
10
  `;for(;s=n.exec(u);){let a=s[2]??s[3]??"";a=a.replaceAll('""','"'),i.push(a),s[4]===`
11
- `&&(o.push(i),i=[])}return o}r(Pn,"csvParse");function ya(e,t={}){let n=Pn(e,t),o=n[0];return n.slice(1).map(i=>Object.fromEntries(i.map((s,u)=>[o[u],s])))}r(ya,"csvParseToObjects");var En=A("zeed:dispose","error");async function Mn(e){typeof e=="function"?await k(e()):E(e)?await e:typeof e.dispose=="function"?await k(e.dispose()):E(e.dispose)?await e.dispose:typeof e.cleanup=="function"?await k(e.cleanup()):E(e.cleanup)&&await e.cleanup}r(Mn,"callDisposer");function ke(e){let{name:t}=typeof e=="string"?{name:e}:e??{},n=[],o=r(async u=>{u!=null&&n.includes(u)&&(Ae(n,a=>a!==u),await Mn(u))},"untrack"),i=r(async()=>{for(t&&En.debug(`dispose ${t}: ${n.length} entries`);n.length>0;)await o(n[0])},"dispose"),s=r(u=>{if(u!=null)return n.unshift(u),()=>o(u)},"track");return Object.assign(i,{track:s,add:s,untrack:o,dispose:i,exec:i,getSize(){return n.length}})}r(ke,"useDispose");var La=ke;function Aa(e={}){let{mode:t="fifo"}=e,n=[],o=r(async(s=!1)=>{for(;n.length>0;){let u=n[0];if(Ae(n,a=>a!==u),typeof u=="function"){let a=u();if(E(a)){if(s)throw new Error(`Expected sync only function, but found async: ${u}`);await a}}else if(E(u)){if(s)throw new Error(`Expected sync only function, but found async: ${u}`);await u}else throw new Error(`Unhandled disposable: ${u}`)}},"exec");return Object.assign(o,{add:r(s=>{t==="lifo"?n.unshift(s):n.push(s)},"add"),exec:o,getSize(){return n.length}})}r(Aa,"useDefer");function va(e,t=0){let n=setTimeout(e,t);return()=>{n&&(clearTimeout(n),n=void 0)}}r(va,"useTimeout");function Da(e,t){let n=setInterval(e,t);return()=>{n&&(clearInterval(n),n=void 0)}}r(Da,"useInterval");function Pa(e,t,n,...o){return e==null?()=>{}:(e.on?e.on(t,n,...o):e.addEventListener&&e.addEventListener(t,n,...o),()=>{e.off?e.off(t,n,...o):e.removeEventListener&&e.removeEventListener(t,n,...o)})}r(Pa,"useEventListener");function Sa(){let e=!0;return(t,n)=>{let o=!1;if(e){e=!1;try{t(),o=!0}finally{e=!0}}else n!==void 0&&n();return o}}r(Sa,"useMutex");function Ua(){let e=!0;return async(t,n)=>{let o=!1;if(e){e=!1;try{let i=t();E(i)&&await i,o=!0}finally{e=!0}}else if(n!==void 0){let i=n();E(i)&&await i}return o}}r(Ua,"useAsyncMutex");var Z=A("zeed:emitter","error"),M=class{constructor(){this.subscribers={};this.subscribersOnAny=[];this.dispose=ke();this.call=new Proxy({},{get:(t,n)=>async(...o)=>await this.emit(n,...o)})}async emit(t,...n){let o=!1;this.dispose.add(()=>{this.subscribers={},this.subscribersOnAny=[]});try{let i=this.subscribers[t]||[];if(this.subscribersOnAny.forEach(s=>s(t,...n)),i.length>0){let s=i.map(u=>{try{return k(u(...n))}catch(a){Z.warn("emit warning:",a)}return null}).filter(u=>u!=null);o=!0,await Promise.all(s)}}catch(i){Z.error("emit exception",i)}return o}onAny(t){this.subscribersOnAny.push(t)}on(t,n){let o=this.subscribers[t]||[];return o.push(n),this.subscribers[t]=o,()=>{this.off(t,n)}}onCall(t){for(let[n,o]of Object.entries(t))this.on(n,o)}once(t,n){let o=r(async(...i)=>(this.off(t,o),await k(n(...i))),"onceListener");return this.on(t,o),()=>{this.off(t,n)}}off(t,n){return this.subscribers[t]=(this.subscribers[t]||[]).filter(o=>n&&o!==n),this}removeAllListeners(){return this.subscribers={},this}};r(M,"Emitter");function ja(){let e=Y().emitter;return e||(e=new M,Y().emitter=e),e}r(ja,"getGlobalEmitter");var Ha=new M;function _a(e,t){let n=Math.round(D()*100),o=[],i,s=r((a,c)=>{let l={key:a,obj:c};o.push(l),i&&i()},"incoming");return t?e.on?e.on(t,a=>{s(t,a)}):e.addEventListener?e.addEventListener(t,a=>{s(t,a)}):Z.error(n,"Cannot listen to key"):e.onAny?e.onAny((a,c)=>{s(a,c)}):Z.error(n,"cannot listen to all for",e),r((a,c=!0)=>new Promise((l,f)=>{a||(a=t,a||o.length&&(a=o[0].key)),i=r(()=>{for(;o.length>0;){let d=o.shift();if(d.key===a)i=void 0,l(d.obj);else{if(c){Z.warn(n,`Unhandled event ${a} with value: ${d.obj}`);continue}f(new Error(`Expected ${a}, but found ${d.key} with value=${d.obj}`)),Z.error(n,`Unhandled event ${a} with value: ${d.obj}`)}break}},"lazyResolve"),i()}),"on")}r(_a,"lazyListener");var At=r(()=>Date.now(),"getTimestamp");function Ga(e){return e>999?`${(e/1e3).toFixed(1)}s`:`${e.toFixed(2)}ms`}r(Ga,"formatMilliseconds");function Va(...e){for(let t of e){if(t instanceof Date)return t;if(typeof t=="string"){let n=null;if(t.includes(":"))try{n=new Date(t)}catch{}if(!(n instanceof Date)){let o=/(\d\d\d\d)-(\d\d)-(\d\d)/.exec(t);o&&(n=new Date(+o[1],+o[2]-1,+o[3],12,0))}if(n instanceof Date)return n}}}r(Va,"parseDate");var{encode:vt,decode:Rn}=j(62),{encode:Dt,decode:Sn}=j(32),fe=16;function Ie(){return q(fe)}r(Ie,"uuidBytes");function Un(e=Ie()){return vt(e,22)}r(Un,"uuidB62");function kn(e){return vt(e,22)}r(kn,"uuidEncodeB62");function Fn(e){return Rn(e,fe)}r(Fn,"uuidDecodeB62");function In(e=Ie()){return Dt(e,26)}r(In,"uuidB32");function Cn(e){return Dt(e,26)}r(Cn,"uuidEncodeB32");function On(e){return Sn(e,fe)}r(On,"uuidDecodeB32");var $n="10000000-1000-4000-8000-100000000000",Bn=typeof crypto<"u"&&crypto.randomUUID!=null?crypto.randomUUID.bind(crypto):()=>$n.replace(/[018]/g,e=>(e^q(1)[0]&15>>e/4).toString(16));function jn(e){let t=Je(e);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16)}`}r(jn,"uuidEncodeV4");function Hn(e){return Ze(e.replaceAll("-",""))}r(Hn,"uuidDecodeV4");var Pt=16e11;function _n(e){let t=new Uint8Array([0,0,0,0,0,0]),n=t.length-1;for(let o=0;o<t.length;o++){let i=e&255;t[n-o]=i,e=(e-i)/256}return t}r(_n,"longToByteArray");function Et(){let e=At()-Pt;return new Uint8Array([..._n(e),...q(10)])}r(Et,"suidBytes");function Qa(){return Nn(Et())}r(Qa,"suid");function Xa(e){return zn(Rt(e))}r(Xa,"suidDate");function zn(e){return new Date(Pt+e.slice(0,6).reduce((t,n)=>t*256+n,0))}r(zn,"suidBytesDate");var eu=r(()=>new Uint32Array(q(4))[0],"uuid32bit"),Ce={base62:{uuid:Un,uuidDecode:Fn,uuidEncode:kn},base32:{uuid:In,uuidDecode:On,uuidEncode:Cn},uuidv4:{uuid:Bn,uuidDecode:Hn,uuidEncode:jn}},de="base62",Mt=!1;function tu(e,t=!1){de=e,Mt=t}r(tu,"setUuidDefaultEncoding");function H(){return Ce[de].uuid(Mt?Et():Ie())}r(H,"uuid");function Rt(e){return Ce[de].uuidDecode(e)}r(Rt,"uuidDecode");function Nn(e){return Ce[de].uuidEncode(e)}r(Nn,"uuidEncode");function nu(e){try{return Rt(e).length===fe}catch{}return!1}r(nu,"uuidIsValid");var Fe={};function _(e="id"){return Fe[e]==null&&(Fe[e]=0),`${e}-${Fe[e]++}`}r(_,"uname");var Gn=0;function ru(){return`id-${Gn++}`}r(ru,"qid");var Vn=(o=>(o[o.waiting=0]="waiting",o[o.running=1]="running",o[o.finished=2]="finished",o))(Vn||{}),qn=(o=>(o[o.replace=0]="replace",o[o.memoize=1]="memoize",o[o.error=2]="error",o))(qn||{});function cu(e={}){let{maxParallel:t=3}=e,n=new M,o=0,i=0,s=0,u=0,a={};async function c(){if(o>0){let[p,g]=ct();return n.once("didFinish",g),p}}r(c,"waitFinishAll");function l(){n.emit("didFinish"),o=0,i=0}r(l,"didFinish");function f(){let p=0,g=0;for(let{max:y,resolved:T,state:b}of Object.values(a))p+=y,g+=b===2?y:Math.min(y,T);n.emit("didUpdate",o,i,p,g)}r(f,"didUpdate");function d(){if(f(),o>0&&o===i&&l(),s>=t)return;let p=Object.values(a).filter(g=>g.state===0);if(p.length>0){let g;for(let y of p)y.group!=null&&Object.values(a).some(T=>T.state===1&&T.id!==y.id&&T.group===y.group)||(g==null||y.priority<g.priority)&&(g=y);if(g!=null){let y=g.id,T=g.done;g.state=1,++s,n.emit("didStart",y);let b=r(w=>{g&&(g.result=w,g.state=2,g.resolved=g.max),--s,++i,d()},"taskFinished");g.task(g).then(w=>{T(w),n.emit("didResolve",y,w),b(w)}).catch(w=>{T(),n.emit("didReject",y,w),b()})}}}r(d,"performNext");function h(p){let g=a[p];g&&g.state===0&&(a[p].state=2,++i,n.emit("didCancel",p),f())}r(h,"cancel");function x(){Object.keys(a).forEach(h)}r(x,"cancelAll");function m(p,g={}){let y,T=new Promise(w=>y=w),b=g.id??H();if(a[b]!=null){let w=g.idConflictResolution??1;if(w===0)h(b);else if(w===1){let v=a[b];return{id:b,promise:(async()=>{if(v.state===2)return a[b].result})(),dispose:()=>h(b),cancel:()=>h(b)}}else throw new Error(`Pool task with id=${b} already exists!`)}return a[b]={id:b,task:p,priority:++u,group:g.group,state:0,max:g.max??1,resolved:g.resolved??0,done:y,payload:g.payload,setMax(w){a[b].max=w,f()},setResolved(w){a[b].resolved=w,f()},incResolved(w=1){a[b].resolved+=w,f()}},++o,d(),{id:b,promise:T,dispose:()=>h(b),cancel:()=>h(b)}}return r(m,"enqueue"),{events:n,cancel:h,cancelAll:x,enqueue:m,dispose:x,waitFinishAll:c}}r(cu,"usePool");var Oe=class extends M{constructor(n={}){super();this.queue=[];this.waitToFinish=[];this.countMax=0;this.countResolved=0;this.paused=!1;let{name:o=_("queue"),logLevel:i}=n;this.name=o,this.log=A(`zeed:queue:${o}`,i??1/0)}async performNext(){if(this.log("performNext, queue.length =",this.queue.length),this.currentTask!=null){this.log("performNext => skip while another task is running");return}if(this.paused){this.log("performNext => skip while is paused");return}for(;this.currentTask==null&&!this.paused;){let n=this.queue.shift();if(this.log(`performNext => ${n?.name}`),n==null)break;this.countResolved===0&&this.emit("didStart",this.countMax);let{name:o,task:i,resolve:s}=n;this.currentTask=i();let u;try{this.log.info(`start task ${o}`),u=await this.currentTask,this.log(`finished task ${o} with result =`,u)}catch(a){this.log.warn("Error performing task",a)}s(u),this.currentTask=void 0,this.countResolved+=1,this.emit("didUpdate",this.countMax,this.countResolved)}for(this.queue.length===0&&(this.emit("didFinish"),this.countMax=0,this.countResolved=0);this.waitToFinish.length>0;)this.waitToFinish.shift()()}async enqueue(n,o={}){let{immediate:i=!1,name:s=_(this.name)}=o;return i?(this.log.info(`immediate execution ${s}`),await n()):(this.log(`enqueue ${s}`),new Promise(u=>{this.queue.push({name:s,task:n,resolve:u}),this.countMax+=1,this.emit("didUpdate",this.countMax,this.countResolved),this.performNext()}))}async enqueueReentrant(n,o={}){return this.enqueue(n,{immediate:this.currentTask!=null,name:o.name})}async cancelAll(n=!0){this.log("cancelAll"),this.emit("didCancel");let o=this.queue.map(i=>i.resolve);this.queue=[],o.forEach(i=>i(void 0)),await this.wait()}async pause(){this.log("pause"),this.paused=!0,await this.wait()}resume(){this.log("resume"),this.paused=!1,this.performNext()}async wait(){if(this.log("wait"),!(this.currentTask==null&&(this.queue.length===0||this.paused)))return new Promise(n=>{this.waitToFinish.push(n)})}get isPaused(){return this.paused}get hasTasks(){return this.queue.length!==0}};r(Oe,"SerialQueue");var W=!1,U=W?A("zeed:throttle","error"):()=>{};function Tu(e,t={}){let{delay:n=100,trailing:o=!0,leading:i=!0}=t,s=0,u=0,a=0,c,l=Date.now();function f(){return s?(clearTimeout(s),s=void 0,!0):!1}r(f,"clearExistingTimeout");function d(...h){let x=Date.now(),m=x-u;function p(){let y=Date.now();return`total ${(y-l).toFixed(1)}ms - elapsed ${(y-u).toFixed(1)}ms - visited ${a}x`}r(p,"debugElapsed");let g=r(()=>{a=0,u=Date.now(),e.apply(this,h)},"exec");if(c=g,m>n||!s){W&&U("elapsed",p()),i&&(m>n?(W&&U("\u{1F680} leading",p()),g()):++a);let y=m>n?n:n-m;U(`\u23F1 start timeout with ${y.toFixed(1)}ms`,p()),f(),u=x,s=setTimeout(()=>{W&&U("\u23F1 reached timeout",p()),s=0,o&&(!i||a>0)&&(W&&U("\u{1F680} trailing",p()),c?.())},y)}else++a,W&&U("visited",p())}return r(d,"wrapper"),d.cancel=f,d.stop=()=>{f()&&c&&c()},d.immediate=r(async function(...x){f(),u=Date.now(),e.apply(this,x)},"immediate"),d.dispose=()=>d.stop(),d}r(Tu,"throttle");function wu(e,t={}){let{delay:n=100}=t,o=0,i=!1,s;function u(){o&&(U("clear"),clearTimeout(o),o=0)}r(u,"clearExistingTimeout");async function a(){try{if(u(),s!=null){U("exec");let f=[...s];s=void 0,i=!0,await k(e(...f)),i=!1,U("exec done"),s!=null&&(u(),U("exec trigger next"),o=setTimeout(a,n))}}catch{}}r(a,"exec");function c(...f){s=[...f],u(),U("trigger"),i===!1&&(o=setTimeout(a,n))}r(c,"wrapper");async function l(...f){u(),s=[...f],await a()}return r(l,"immediate"),c.cancel=u,c.dispose=u,c.immediate=l,c}r(wu,"debounce");function vu(e=globalThis?.location?.hostname??""){return["::ffff:127.0.0.1","localhost","127.0.0.1","","::1","::"].includes(e)||e.startsWith("192.168.")||e.startsWith("10.0.")||e.endsWith(".local")}r(vu,"isLocalHost");function Mu(e){let{level:t=void 0,filter:n=void 0,messages:o=[]}=e,i=V(n),s=ne(t);return u=>{!s(u.level)||!i(u.name)||o.push(u)}}r(Mu,"LoggerMemoryHandler");var pe=class extends M{constructor(){super(...arguments);this.id=H()}close(){this.dispose()}};r(pe,"Channel");var ee=class extends pe{constructor(){super(...arguments);this.isConnected=!0}postMessage(n){this.other?.emit("message",{data:n,origin:"local",lastEventId:H()})}};r(ee,"LocalChannel");function Fu(){let e=new ee,t=new ee;return e.other=t,t.other=e,[e,t]}r(Fu,"createLocalChannelPair");var $e=class{async encode(t){return t}async decode(t){return t}};r($e,"NoopEncoder");var z=class{async encode(t){return he(t)}async decode(t){return xe(t)}};r(z,"JsonEncoder");var Be=class{constructor(t){this.key=t}async encode(t){let n=he(t);return await et(n,this.key)}async decode(t){let n=await tt(t,this.key);return xe(n)}};r(Be,"CryptoEncoder");var St=r((e,t,n={})=>new Proxy(n,{get:(o,i)=>i in o?o[i]:(...s)=>e(i,s,t)}),"createPromiseProxy");function Vu(e={}){let{name:t=_("hub"),encoder:n=new z,retryAfter:o=1e3,ignoreUnhandled:i=!0,logLevel:s=!1}=e,u=A(t,s),a={},c,l=[],f,d={},h=r(()=>{clearTimeout(f)},"dispose"),x=r(async()=>{if(clearTimeout(f),c){if(c.isConnected)for(;l.length;){let y=l[0];try{c.postMessage(await n.encode(y)),l.shift()}catch(T){u.warn("postMessage",T);break}}l.length>0&&o>0&&(f=setTimeout(x,o))}},"postNext"),m=r(async y=>{u("enqueue postMessage",y),l.push(y),await x()},"postMessage"),p=r(async y=>{c=y,c.on("connect",x),c.on("message",async T=>{u("onmessage",typeof T);let{name:b,args:w,id:v,result:G,error:O}=await n.decode(T.data);if(b){u(`name ${b} id ${v}`);try{if(a[b]==null)throw new Error(`handler for ${b} was not found`);let R=a[b](...w);E(R)&&(R=await R),u(`result ${R}`),v&&await m({id:v,result:R})}catch(R){let $=R instanceof Error?R:new Error(ve(R));u.warn("execution error",$.name),await m({id:v,error:{message:$.message,stack:$.stack,name:$.name}})}}else if(v)if(u(`response for id=${v}: result=${G}, error=${O}`),d[v]==null)G===void 0?u(`skip response for ${v}`):u.warn(`no response hook for ${v}`);else{let[R,$]=d[v];if(R&&$)if(delete d[v],O){let te=new Error(O.message);te.stack=O.stack,te.name=O.name,u.warn("reject",te.name),$(te)}else u("resolve",G),R(G)}else i||u.warn("Unhandled message",T)}),await x()},"connect"),g=r(async(y,T,b={})=>{let{timeout:w=5e3}=b,v=H();return await m({name:y,args:T,id:v}),dt(new Promise((G,O)=>d[v]=[G,O]),w)},"fetchMessage");return e.channel&&p(e.channel),{dispose:h,connect:p,listen(y){Object.assign(a,y)},send(){return St(g,{},{options(y){return St(g,{...y})}})}}}r(Vu,"useMessageHub");var ge=class extends M{constructor(n){super();this.publish=this.emit.bind(this);this.subscribe=this.on.bind(this);let{name:o,encoder:i=new z,channel:s,debug:u=!1}=n;this.channel=s,this.encoder=i,this.debug=u,this.name=o??this.channel.id??_("pubsub"),this.log=A(`${this.shortId}`),this.debug&&(this.channel.on("connect",()=>{this.log("channel connected")}),this.channel.on("disconnect",()=>{this.log("channel disconnected")})),this.channel.on("message",async({data:a})=>{let c=await this.encoder.decode(a);if(this.debug?this.log(`channel message, event=${c?.event}, info=`,c):this.log(`channel message, event=${c?.event}`),c){let{event:l,args:f}=c;await this.emitSuper(l,...f)}})}get shortId(){return this.name.substr(0,6)}async emitSuper(n,...o){return await super.emit(n,...o)}async emit(n,...o){try{if(this.debug?this.log(`emit(${String(n)})`,n):this.log(`emit(${String(n)})`,o.length),!this.channel.isConnected)return this.log.warn("channel not connected"),!1;let i=await this.encoder.encode({event:n,args:o});return this.channel.postMessage(i),!0}catch(i){this.log.warn(`emit(${String(n)})`,i)}return!1}};r(ge,"PubSub");function Qu(e){return new ge(e)}r(Qu,"usePubSub");var Jn=1;var Ut=r(e=>e,"defaultSerialize"),Zn=Ut;function tc(e,t){let{post:n,on:o,eventNames:i=[],serialize:s=Ut,deserialize:u=Zn}=t,a=new Map;return o(async c=>{let l=u(c),[f,d,h,x]=l;if(f===1||f===2){let m,p;if(x!=null)try{let g=e[x];m=await g(...d)}catch(g){p=String(g)}else p="Method implementation missing";f===1&&h&&n(s(p?[4,p,h]:[3,m,h]))}else if(h){let m=a.get(h);m!=null&&(f===4?m.reject(d):m.resolve(d)),a.delete(h)}}),new Proxy({},{get(c,l){let f=r((...h)=>{n(s([2,h,null,l]))},"sendEvent");if(t.onlyEvents||i.includes(l))return f.asEvent=f,f;let d=r((...h)=>new Promise((x,m)=>{let p=Jn++;a.set(p,{resolve:x,reject:m}),n(s([1,h,p,l]))}),"sendCall");return d.asEvent=f,d}})}r(tc,"useRPC");var K=A("zeed:network","error"),je={cache:"no-cache",redirect:"follow",headers:{}};function Wn(e){let t=/:\/\/([^@]*)@/gi.exec(e);if(t&&t[1]){let[n,o]=t[1].split(":",2);return{url:e.replace(`${t[1]}@`,""),username:n,password:o}}}r(Wn,"parseBasicAuth");async function kt(e,t={},n=fetch){try{I(t)&&(t=le({},...J(t)));let o=Wn(String(e));o&&(e=o.url,t=le({},t,Kn(o.username,o.password))),t.headers!=null&&!(t.headers instanceof Headers)&&(t.headers=new Headers(t.headers));let i=await n(String(e),t);if(i.status<400)return i;try{K.warn(`Fetch of ${String(e)} returned status=${i.status}. Options:`,t),K.warn(`Response: ${await i.text()}`)}catch(s){K.error("Exception:",s)}}catch(o){K.error("fetchBasic",o)}}r(kt,"fetchBasic");async function ac(e,t={},n=fetch){try{let o=await kt(e,[{method:"GET",headers:{Accept:"application/json"}},t],n);if(o)return await o.json()}catch(o){K.error("fetchJSON error:",o)}}r(ac,"fetchJson");async function uc(e,t={},n=fetch){try{let o=await kt(e,[je,{method:"GET"},t],n);if(o)return await o.text()}catch(o){K.error("fetchHTML error:",o)}}r(uc,"fetchText");function cc(e,t="POST"){return{method:t,...je,headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:wt(e)}}r(cc,"fetchOptionsFormURLEncoded");function lc(e,t="POST"){return{method:t,...je,headers:{"Content-Type":"application/json; charset=utf-8"},body:S(e)}}r(lc,"fetchOptionsJson");function Kn(e,t){return{headers:{Authorization:`Basic ${We(`${e}:${t}`)}`}}}r(Kn,"fetchOptionsBasicAuth");function Ft(){if(typeof window<"u")return window}r(Ft,"getWindow");function Yn(){if(typeof navigator<"u")return navigator}r(Yn,"getNavigator");function pc(){return Ft()??typeof WorkerGlobalScope<"u"?self:typeof global<"u"?global:Function("return this;")()}r(pc,"getGlobal");var C=Yn(),N=Ft();function Qn(e={ios:!1,macos:!1,windows:!1,beaker:!1,electron:!1,wkwebview:!1,pwa:!1,pwaInstalled:!1,browser:!1,node:!1,worker:!1,test:!1,jest:!1,macosNative:!1,iosNative:!1,appleNative:!1,touch:!1}){return e.ios=C?.platform?.match(/(iPhone|iPod|iPad)/i)!=null,e.macos=!!C?.platform?.startsWith("Mac"),e.windows=!!C?.platform?.startsWith("Win"),e.beaker=N?.beaker!=null,e.electron=(C?.userAgent?.toLowerCase()?.indexOf(" electron/")||-1)>-1&&!e.beaker,e.wkwebview=N?.webkit?.messageHandlers!=null,e.pwa=C?.serviceWorker!=null,e.pwaInstalled=C?.standalone||N?.matchMedia?.("(display-mode: standalone)")?.matches,e.node=typeof process<"u"&&process?.release?.name==="node",e.browser=!e.electron&&!e.wkwebview&&!e.node,e.worker=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,e.jest=typeof jest<"u"||typeof vitest<"u",e.test=e.jest,e.macosNative=e.wkwebview&&e.macos,e.iosNative=e.wkwebview&&e.ios,e.appleNative=e.wkwebview,e.touch=N&&"ontouchstart"in N||(C?.maxTouchPoints||0)>1||C?.msPointerEnabled&&N?.MSGesture||N?.DocumentTouch&&document instanceof DocumentTouch,e}r(Qn,"detect");var Xn=r(()=>typeof window<"u"&&globalThis===window,"isBrowser"),gc=Qn();function mc(e){Xn()?window.addEventListener("beforeunload",e):typeof process<"u"&&process.on("exit",()=>e)}r(mc,"useExitHandler");var He=class{constructor(t={}){this.store={}}setItem(t,n){this.store[t]=Se(n)}getItem(t){return Se(this.store[t])}removeItem(t){delete this.store[t]}clear(){this.store={}}allKeys(){return Object.keys(this.store)}};r(He,"MemStorage");var wc=r(()=>{},"noop");export{r as a,Y as b,Ot as c,V as d,me as e,ne as f,re as g,Q as h,_e as i,ze as j,jt as k,A as l,br as m,S as n,Tr as o,_t as p,zt as q,Ve as r,qe as s,P as t,Dr as u,Je as v,Ze as w,We as x,Pr as y,Nt as z,Er as A,Ke as B,he as C,xe as D,Ye as E,q as F,Xe as G,be as H,Qe as I,Gt as J,Ur as K,kr as L,et as M,tt as N,Vt as O,D as P,Cr as Q,Or as R,$r as S,Br as T,qt as U,jr as V,Hr as W,_r as X,zr as Y,Jt as Z,Vr as _,we as $,qr as aa,Le as ba,Zt as ca,Wt as da,J as ea,Kt as fa,Yr as ga,Qr as ha,Xr as ia,Ae as ja,eo as ka,to as la,Yt as ma,no as na,Qt as oa,nt as pa,ro as qa,oo as ra,io as sa,so as ta,ao as ua,uo as va,co as wa,lo as xa,fo as ya,j as za,ho as Aa,xo as Ba,bo as Ca,To as Da,wo as Ea,Lo as Fa,Ao as Ga,vo as Ha,Do as Ia,Mo as Ja,nn as Ka,Ro as La,So as Ma,Io as Na,Co as Oa,Oo as Pa,rn as Qa,on as Ra,sn as Sa,ve as Ta,$o as Ua,Bo as Va,jo as Wa,Ho as Xa,an as Ya,_o as Za,zo as _a,Pe as $a,Ee as ab,ot as bb,un as cb,Vo as db,it as eb,st as fb,qo as gb,Jo as hb,ue as ib,Zo as jb,De as kb,cn as lb,ln as mb,Me as nb,at as ob,Wo as pb,Ko as qb,ae as rb,Yo as sb,Qo as tb,Xo as ub,ct as vb,ri as wb,oi as xb,lt as yb,ii as zb,ft as Ab,si as Bb,dt as Cb,ai as Db,E as Eb,k as Fb,L as Gb,di as Hb,pi as Ib,gi as Jb,mi as Kb,fn as Lb,xi as Mb,bi as Nb,Ti as Ob,F as Pb,Re as Qb,I as Rb,ce as Sb,Ai as Tb,vi as Ub,Di as Vb,Pi as Wb,Ei as Xb,pt as Yb,Mi as Zb,Ri as _b,Si as $b,Ui as ac,ki as bc,dn as cc,pn as dc,le as ec,gt as fc,Bi as gc,_i as hc,zi as ic,Ni as jc,Gi as kc,Zi as lc,Wi as mc,Ki as nc,Xi as oc,ht as pc,X as qc,xt as rc,os as sc,is as tc,ss as uc,as as vc,us as wc,cs as xc,ls as yc,fs as zc,bt as Ac,Tt as Bc,ms as Cc,xn as Dc,bs as Ec,As as Fc,Tn as Gc,wt as Hc,vs as Ic,Ms as Jc,Rs as Kc,Ss as Lc,Us as Mc,ks as Nc,Se as Oc,Fs as Pc,Is as Qc,Cs as Rc,Os as Sc,vn as Tc,Hs as Uc,Ue as Vc,ma as Wc,Pn as Xc,ya as Yc,ke as Zc,La as _c,Aa as $c,va as ad,Da as bd,Pa as cd,Sa as dd,Ua as ed,M as fd,ja as gd,Ha as hd,_a as id,At as jd,Ga as kd,Va as ld,Ie as md,Un as nd,kn as od,Fn as pd,In as qd,Cn as rd,On as sd,Bn as td,jn as ud,Hn as vd,Et as wd,Qa as xd,Xa as yd,zn as zd,eu as Ad,tu as Bd,H as Cd,Rt as Dd,Nn as Ed,nu as Fd,_ as Gd,ru as Hd,Vn as Id,qn as Jd,cu as Kd,Oe as Ld,Tu as Md,wu as Nd,vu as Od,Mu as Pd,pe as Qd,ee as Rd,Fu as Sd,$e as Td,z as Ud,Be as Vd,St as Wd,Vu as Xd,ge as Yd,Qu as Zd,tc as _d,Wn as $d,kt as ae,ac as be,uc as ce,cc as de,lc as ee,Kn as fe,Ft as ge,Yn as he,pc as ie,Qn as je,Xn as ke,gc as le,mc as me,He as ne,wc as oe};
12
- //# sourceMappingURL=chunk-5KHLXHN6.js.map
11
+ `&&(o.push(i),i=[])}return o}r(Pn,"csvParse");function ya(e,t={}){let n=Pn(e,t),o=n[0];return n.slice(1).map(i=>Object.fromEntries(i.map((s,u)=>[o[u],s])))}r(ya,"csvParseToObjects");var En=A("zeed:dispose","error");async function Mn(e){typeof e=="function"?await k(e()):E(e)?await e:typeof e.dispose=="function"?await k(e.dispose()):E(e.dispose)?await e.dispose:typeof e.cleanup=="function"?await k(e.cleanup()):E(e.cleanup)&&await e.cleanup}r(Mn,"callDisposer");function ke(e){let{name:t}=typeof e=="string"?{name:e}:e??{},n=[],o=r(async u=>{u!=null&&n.includes(u)&&(Ae(n,a=>a!==u),await Mn(u))},"untrack"),i=r(async()=>{for(t&&En.debug(`dispose ${t}: ${n.length} entries`);n.length>0;)await o(n[0])},"dispose"),s=r(u=>{if(u!=null)return n.unshift(u),()=>o(u)},"track");return Object.assign(i,{track:s,add:s,untrack:o,dispose:i,exec:i,getSize(){return n.length},isDisposed(){return n.length<=0}})}r(ke,"useDispose");var La=ke;function Aa(e={}){let{mode:t="fifo"}=e,n=[],o=r(async(s=!1)=>{for(;n.length>0;){let u=n[0];if(Ae(n,a=>a!==u),typeof u=="function"){let a=u();if(E(a)){if(s)throw new Error(`Expected sync only function, but found async: ${u}`);await a}}else if(E(u)){if(s)throw new Error(`Expected sync only function, but found async: ${u}`);await u}else throw new Error(`Unhandled disposable: ${u}`)}},"exec");return Object.assign(o,{add:r(s=>{t==="lifo"?n.unshift(s):n.push(s)},"add"),exec:o,getSize(){return n.length}})}r(Aa,"useDefer");function va(e,t=0){let n=setTimeout(e,t);return()=>{n&&(clearTimeout(n),n=void 0)}}r(va,"useTimeout");function Da(e,t){let n=setInterval(e,t);return()=>{n&&(clearInterval(n),n=void 0)}}r(Da,"useInterval");function Pa(e,t,n,...o){return e==null?()=>{}:(e.on?e.on(t,n,...o):e.addEventListener&&e.addEventListener(t,n,...o),()=>{e.off?e.off(t,n,...o):e.removeEventListener&&e.removeEventListener(t,n,...o)})}r(Pa,"useEventListener");function Sa(){let e=!0;return(t,n)=>{let o=!1;if(e){e=!1;try{t(),o=!0}finally{e=!0}}else n!==void 0&&n();return o}}r(Sa,"useMutex");function Ua(){let e=!0;return async(t,n)=>{let o=!1;if(e){e=!1;try{let i=t();E(i)&&await i,o=!0}finally{e=!0}}else if(n!==void 0){let i=n();E(i)&&await i}return o}}r(Ua,"useAsyncMutex");var Z=A("zeed:emitter","error"),M=class{constructor(){this.subscribers={};this.subscribersOnAny=[];this.dispose=ke();this.call=new Proxy({},{get:(t,n)=>async(...o)=>await this.emit(n,...o)})}async emit(t,...n){let o=!1;try{let i=this.subscribers[t]||[];if(this.subscribersOnAny.forEach(s=>s(t,...n)),i.length>0){let s=i.map(u=>{try{return k(u(...n))}catch(a){Z.warn("emit warning:",a)}return null}).filter(u=>u!=null);o=!0,await Promise.all(s)}}catch(i){Z.error("emit exception",i)}return o}onAny(t){this.subscribersOnAny.push(t)}on(t,n){let o=this.subscribers[t]||[];return o.push(n),this.subscribers[t]=o,()=>{this.off(t,n)}}onCall(t){for(let[n,o]of Object.entries(t))this.on(n,o)}once(t,n){let o=r(async(...i)=>(this.off(t,o),await k(n(...i))),"onceListener");return this.on(t,o),()=>{this.off(t,n)}}off(t,n){return this.subscribers[t]=(this.subscribers[t]||[]).filter(o=>n&&o!==n),this}removeAllListeners(){return this.subscribers={},this}};r(M,"Emitter");function ja(){let e=Y().emitter;return e||(e=new M,Y().emitter=e),e}r(ja,"getGlobalEmitter");var Ha=new M;function _a(e,t){let n=Math.round(D()*100),o=[],i,s=r((a,c)=>{let l={key:a,obj:c};o.push(l),i&&i()},"incoming");return t?e.on?e.on(t,a=>{s(t,a)}):e.addEventListener?e.addEventListener(t,a=>{s(t,a)}):Z.error(n,"Cannot listen to key"):e.onAny?e.onAny((a,c)=>{s(a,c)}):Z.error(n,"cannot listen to all for",e),r((a,c=!0)=>new Promise((l,f)=>{a||(a=t,a||o.length&&(a=o[0].key)),i=r(()=>{for(;o.length>0;){let d=o.shift();if(d.key===a)i=void 0,l(d.obj);else{if(c){Z.warn(n,`Unhandled event ${a} with value: ${d.obj}`);continue}f(new Error(`Expected ${a}, but found ${d.key} with value=${d.obj}`)),Z.error(n,`Unhandled event ${a} with value: ${d.obj}`)}break}},"lazyResolve"),i()}),"on")}r(_a,"lazyListener");var At=r(()=>Date.now(),"getTimestamp");function Ga(e){return e>999?`${(e/1e3).toFixed(1)}s`:`${e.toFixed(2)}ms`}r(Ga,"formatMilliseconds");function Va(...e){for(let t of e){if(t instanceof Date)return t;if(typeof t=="string"){let n=null;if(t.includes(":"))try{n=new Date(t)}catch{}if(!(n instanceof Date)){let o=/(\d\d\d\d)-(\d\d)-(\d\d)/.exec(t);o&&(n=new Date(+o[1],+o[2]-1,+o[3],12,0))}if(n instanceof Date)return n}}}r(Va,"parseDate");var{encode:vt,decode:Rn}=j(62),{encode:Dt,decode:Sn}=j(32),fe=16;function Ie(){return q(fe)}r(Ie,"uuidBytes");function Un(e=Ie()){return vt(e,22)}r(Un,"uuidB62");function kn(e){return vt(e,22)}r(kn,"uuidEncodeB62");function Fn(e){return Rn(e,fe)}r(Fn,"uuidDecodeB62");function In(e=Ie()){return Dt(e,26)}r(In,"uuidB32");function Cn(e){return Dt(e,26)}r(Cn,"uuidEncodeB32");function On(e){return Sn(e,fe)}r(On,"uuidDecodeB32");var $n="10000000-1000-4000-8000-100000000000",Bn=typeof crypto<"u"&&crypto.randomUUID!=null?crypto.randomUUID.bind(crypto):()=>$n.replace(/[018]/g,e=>(e^q(1)[0]&15>>e/4).toString(16));function jn(e){let t=Je(e);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16)}`}r(jn,"uuidEncodeV4");function Hn(e){return Ze(e.replaceAll("-",""))}r(Hn,"uuidDecodeV4");var Pt=16e11;function _n(e){let t=new Uint8Array([0,0,0,0,0,0]),n=t.length-1;for(let o=0;o<t.length;o++){let i=e&255;t[n-o]=i,e=(e-i)/256}return t}r(_n,"longToByteArray");function Et(){let e=At()-Pt;return new Uint8Array([..._n(e),...q(10)])}r(Et,"suidBytes");function Qa(){return Nn(Et())}r(Qa,"suid");function Xa(e){return zn(Rt(e))}r(Xa,"suidDate");function zn(e){return new Date(Pt+e.slice(0,6).reduce((t,n)=>t*256+n,0))}r(zn,"suidBytesDate");var eu=r(()=>new Uint32Array(q(4))[0],"uuid32bit"),Ce={base62:{uuid:Un,uuidDecode:Fn,uuidEncode:kn},base32:{uuid:In,uuidDecode:On,uuidEncode:Cn},uuidv4:{uuid:Bn,uuidDecode:Hn,uuidEncode:jn}},de="base62",Mt=!1;function tu(e,t=!1){de=e,Mt=t}r(tu,"setUuidDefaultEncoding");function H(){return Ce[de].uuid(Mt?Et():Ie())}r(H,"uuid");function Rt(e){return Ce[de].uuidDecode(e)}r(Rt,"uuidDecode");function Nn(e){return Ce[de].uuidEncode(e)}r(Nn,"uuidEncode");function nu(e){try{return Rt(e).length===fe}catch{}return!1}r(nu,"uuidIsValid");var Fe={};function _(e="id"){return Fe[e]==null&&(Fe[e]=0),`${e}-${Fe[e]++}`}r(_,"uname");var Gn=0;function ru(){return`id-${Gn++}`}r(ru,"qid");var Vn=(o=>(o[o.waiting=0]="waiting",o[o.running=1]="running",o[o.finished=2]="finished",o))(Vn||{}),qn=(o=>(o[o.replace=0]="replace",o[o.memoize=1]="memoize",o[o.error=2]="error",o))(qn||{});function cu(e={}){let{maxParallel:t=3}=e,n=new M,o=0,i=0,s=0,u=0,a={};async function c(){if(o>0){let[p,g]=ct();return n.once("didFinish",g),p}}r(c,"waitFinishAll");function l(){n.emit("didFinish"),o=0,i=0}r(l,"didFinish");function f(){let p=0,g=0;for(let{max:y,resolved:T,state:b}of Object.values(a))p+=y,g+=b===2?y:Math.min(y,T);n.emit("didUpdate",o,i,p,g)}r(f,"didUpdate");function d(){if(f(),o>0&&o===i&&l(),s>=t)return;let p=Object.values(a).filter(g=>g.state===0);if(p.length>0){let g;for(let y of p)y.group!=null&&Object.values(a).some(T=>T.state===1&&T.id!==y.id&&T.group===y.group)||(g==null||y.priority<g.priority)&&(g=y);if(g!=null){let y=g.id,T=g.done;g.state=1,++s,n.emit("didStart",y);let b=r(w=>{g&&(g.result=w,g.state=2,g.resolved=g.max),--s,++i,d()},"taskFinished");g.task(g).then(w=>{T(w),n.emit("didResolve",y,w),b(w)}).catch(w=>{T(),n.emit("didReject",y,w),b()})}}}r(d,"performNext");function h(p){let g=a[p];g&&g.state===0&&(a[p].state=2,++i,n.emit("didCancel",p),f())}r(h,"cancel");function x(){Object.keys(a).forEach(h)}r(x,"cancelAll");function m(p,g={}){let y,T=new Promise(w=>y=w),b=g.id??H();if(a[b]!=null){let w=g.idConflictResolution??1;if(w===0)h(b);else if(w===1){let v=a[b];return{id:b,promise:(async()=>{if(v.state===2)return a[b].result})(),dispose:()=>h(b),cancel:()=>h(b)}}else throw new Error(`Pool task with id=${b} already exists!`)}return a[b]={id:b,task:p,priority:++u,group:g.group,state:0,max:g.max??1,resolved:g.resolved??0,done:y,payload:g.payload,setMax(w){a[b].max=w,f()},setResolved(w){a[b].resolved=w,f()},incResolved(w=1){a[b].resolved+=w,f()}},++o,d(),{id:b,promise:T,dispose:()=>h(b),cancel:()=>h(b)}}return r(m,"enqueue"),{events:n,cancel:h,cancelAll:x,enqueue:m,dispose:x,waitFinishAll:c}}r(cu,"usePool");var Oe=class extends M{constructor(n={}){super();this.queue=[];this.waitToFinish=[];this.countMax=0;this.countResolved=0;this.paused=!1;let{name:o=_("queue"),logLevel:i}=n;this.name=o,this.log=A(`zeed:queue:${o}`,i??1/0)}async performNext(){if(this.log("performNext, queue.length =",this.queue.length),this.currentTask!=null){this.log("performNext => skip while another task is running");return}if(this.paused){this.log("performNext => skip while is paused");return}for(;this.currentTask==null&&!this.paused;){let n=this.queue.shift();if(this.log(`performNext => ${n?.name}`),n==null)break;this.countResolved===0&&this.emit("didStart",this.countMax);let{name:o,task:i,resolve:s}=n;this.currentTask=i();let u;try{this.log.info(`start task ${o}`),u=await this.currentTask,this.log(`finished task ${o} with result =`,u)}catch(a){this.log.warn("Error performing task",a)}s(u),this.currentTask=void 0,this.countResolved+=1,this.emit("didUpdate",this.countMax,this.countResolved)}for(this.queue.length===0&&(this.emit("didFinish"),this.countMax=0,this.countResolved=0);this.waitToFinish.length>0;)this.waitToFinish.shift()()}async enqueue(n,o={}){let{immediate:i=!1,name:s=_(this.name)}=o;return i?(this.log.info(`immediate execution ${s}`),await n()):(this.log(`enqueue ${s}`),new Promise(u=>{this.queue.push({name:s,task:n,resolve:u}),this.countMax+=1,this.emit("didUpdate",this.countMax,this.countResolved),this.performNext()}))}async enqueueReentrant(n,o={}){return this.enqueue(n,{immediate:this.currentTask!=null,name:o.name})}async cancelAll(n=!0){this.log("cancelAll"),this.emit("didCancel");let o=this.queue.map(i=>i.resolve);this.queue=[],o.forEach(i=>i(void 0)),await this.wait()}async pause(){this.log("pause"),this.paused=!0,await this.wait()}resume(){this.log("resume"),this.paused=!1,this.performNext()}async wait(){if(this.log("wait"),!(this.currentTask==null&&(this.queue.length===0||this.paused)))return new Promise(n=>{this.waitToFinish.push(n)})}get isPaused(){return this.paused}get hasTasks(){return this.queue.length!==0}};r(Oe,"SerialQueue");var W=!1,U=W?A("zeed:throttle","error"):()=>{};function Tu(e,t={}){let{delay:n=100,trailing:o=!0,leading:i=!0}=t,s=0,u=0,a=0,c,l=Date.now();function f(){return s?(clearTimeout(s),s=void 0,!0):!1}r(f,"clearExistingTimeout");function d(...h){let x=Date.now(),m=x-u;function p(){let y=Date.now();return`total ${(y-l).toFixed(1)}ms - elapsed ${(y-u).toFixed(1)}ms - visited ${a}x`}r(p,"debugElapsed");let g=r(()=>{a=0,u=Date.now(),e.apply(this,h)},"exec");if(c=g,m>n||!s){W&&U("elapsed",p()),i&&(m>n?(W&&U("\u{1F680} leading",p()),g()):++a);let y=m>n?n:n-m;U(`\u23F1 start timeout with ${y.toFixed(1)}ms`,p()),f(),u=x,s=setTimeout(()=>{W&&U("\u23F1 reached timeout",p()),s=0,o&&(!i||a>0)&&(W&&U("\u{1F680} trailing",p()),c?.())},y)}else++a,W&&U("visited",p())}return r(d,"wrapper"),d.cancel=f,d.stop=()=>{f()&&c&&c()},d.immediate=r(async function(...x){f(),u=Date.now(),e.apply(this,x)},"immediate"),d.dispose=()=>d.stop(),d}r(Tu,"throttle");function wu(e,t={}){let{delay:n=100}=t,o=0,i=!1,s;function u(){o&&(U("clear"),clearTimeout(o),o=0)}r(u,"clearExistingTimeout");async function a(){try{if(u(),s!=null){U("exec");let f=[...s];s=void 0,i=!0,await k(e(...f)),i=!1,U("exec done"),s!=null&&(u(),U("exec trigger next"),o=setTimeout(a,n))}}catch{}}r(a,"exec");function c(...f){s=[...f],u(),U("trigger"),i===!1&&(o=setTimeout(a,n))}r(c,"wrapper");async function l(...f){u(),s=[...f],await a()}return r(l,"immediate"),c.cancel=u,c.dispose=u,c.immediate=l,c}r(wu,"debounce");function vu(e=globalThis?.location?.hostname??""){return["::ffff:127.0.0.1","localhost","127.0.0.1","","::1","::"].includes(e)||e.startsWith("192.168.")||e.startsWith("10.0.")||e.endsWith(".local")}r(vu,"isLocalHost");function Mu(e){let{level:t=void 0,filter:n=void 0,messages:o=[]}=e,i=V(n),s=ne(t);return u=>{!s(u.level)||!i(u.name)||o.push(u)}}r(Mu,"LoggerMemoryHandler");var pe=class extends M{constructor(){super(...arguments);this.id=H()}close(){this.dispose()}};r(pe,"Channel");var ee=class extends pe{constructor(){super(...arguments);this.isConnected=!0}postMessage(n){this.other?.emit("message",{data:n,origin:"local",lastEventId:H()})}};r(ee,"LocalChannel");function Fu(){let e=new ee,t=new ee;return e.other=t,t.other=e,[e,t]}r(Fu,"createLocalChannelPair");var $e=class{async encode(t){return t}async decode(t){return t}};r($e,"NoopEncoder");var z=class{async encode(t){return he(t)}async decode(t){return xe(t)}};r(z,"JsonEncoder");var Be=class{constructor(t){this.key=t}async encode(t){let n=he(t);return await et(n,this.key)}async decode(t){let n=await tt(t,this.key);return xe(n)}};r(Be,"CryptoEncoder");var St=r((e,t,n={})=>new Proxy(n,{get:(o,i)=>i in o?o[i]:(...s)=>e(i,s,t)}),"createPromiseProxy");function Vu(e={}){let{name:t=_("hub"),encoder:n=new z,retryAfter:o=1e3,ignoreUnhandled:i=!0,logLevel:s=!1}=e,u=A(t,s),a={},c,l=[],f,d={},h=r(()=>{clearTimeout(f)},"dispose"),x=r(async()=>{if(clearTimeout(f),c){if(c.isConnected)for(;l.length;){let y=l[0];try{c.postMessage(await n.encode(y)),l.shift()}catch(T){u.warn("postMessage",T);break}}l.length>0&&o>0&&(f=setTimeout(x,o))}},"postNext"),m=r(async y=>{u("enqueue postMessage",y),l.push(y),await x()},"postMessage"),p=r(async y=>{c=y,c.on("connect",x),c.on("message",async T=>{u("onmessage",typeof T);let{name:b,args:w,id:v,result:G,error:O}=await n.decode(T.data);if(b){u(`name ${b} id ${v}`);try{if(a[b]==null)throw new Error(`handler for ${b} was not found`);let R=a[b](...w);E(R)&&(R=await R),u(`result ${R}`),v&&await m({id:v,result:R})}catch(R){let $=R instanceof Error?R:new Error(ve(R));u.warn("execution error",$.name),await m({id:v,error:{message:$.message,stack:$.stack,name:$.name}})}}else if(v)if(u(`response for id=${v}: result=${G}, error=${O}`),d[v]==null)G===void 0?u(`skip response for ${v}`):u.warn(`no response hook for ${v}`);else{let[R,$]=d[v];if(R&&$)if(delete d[v],O){let te=new Error(O.message);te.stack=O.stack,te.name=O.name,u.warn("reject",te.name),$(te)}else u("resolve",G),R(G)}else i||u.warn("Unhandled message",T)}),await x()},"connect"),g=r(async(y,T,b={})=>{let{timeout:w=5e3}=b,v=H();return await m({name:y,args:T,id:v}),dt(new Promise((G,O)=>d[v]=[G,O]),w)},"fetchMessage");return e.channel&&p(e.channel),{dispose:h,connect:p,listen(y){Object.assign(a,y)},send(){return St(g,{},{options(y){return St(g,{...y})}})}}}r(Vu,"useMessageHub");var ge=class extends M{constructor(n){super();this.publish=this.emit.bind(this);this.subscribe=this.on.bind(this);let{name:o,encoder:i=new z,channel:s,debug:u=!1}=n;this.channel=s,this.encoder=i,this.debug=u,this.name=o??this.channel.id??_("pubsub"),this.log=A(`${this.shortId}`),this.debug&&(this.channel.on("connect",()=>{this.log("channel connected")}),this.channel.on("disconnect",()=>{this.log("channel disconnected")})),this.channel.on("message",async({data:a})=>{let c=await this.encoder.decode(a);if(this.debug?this.log(`channel message, event=${c?.event}, info=`,c):this.log(`channel message, event=${c?.event}`),c){let{event:l,args:f}=c;await this.emitSuper(l,...f)}})}get shortId(){return this.name.substr(0,6)}async emitSuper(n,...o){return await super.emit(n,...o)}async emit(n,...o){try{if(this.debug?this.log(`emit(${String(n)})`,n):this.log(`emit(${String(n)})`,o.length),!this.channel.isConnected)return this.log.warn("channel not connected"),!1;let i=await this.encoder.encode({event:n,args:o});return this.channel.postMessage(i),!0}catch(i){this.log.warn(`emit(${String(n)})`,i)}return!1}};r(ge,"PubSub");function Qu(e){return new ge(e)}r(Qu,"usePubSub");var Jn=1;var Ut=r(e=>e,"defaultSerialize"),Zn=Ut;function tc(e,t){let{post:n,on:o,eventNames:i=[],serialize:s=Ut,deserialize:u=Zn}=t,a=new Map;return o(async c=>{let l=u(c),[f,d,h,x]=l;if(f===1||f===2){let m,p;if(x!=null)try{let g=e[x];m=await g(...d)}catch(g){p=String(g)}else p="Method implementation missing";f===1&&h&&n(s(p?[4,p,h]:[3,m,h]))}else if(h){let m=a.get(h);m!=null&&(f===4?m.reject(d):m.resolve(d)),a.delete(h)}}),new Proxy({},{get(c,l){let f=r((...h)=>{n(s([2,h,null,l]))},"sendEvent");if(t.onlyEvents||i.includes(l))return f.asEvent=f,f;let d=r((...h)=>new Promise((x,m)=>{let p=Jn++;a.set(p,{resolve:x,reject:m}),n(s([1,h,p,l]))}),"sendCall");return d.asEvent=f,d}})}r(tc,"useRPC");var K=A("zeed:network","error"),je={cache:"no-cache",redirect:"follow",headers:{}};function Wn(e){let t=/:\/\/([^@]*)@/gi.exec(e);if(t&&t[1]){let[n,o]=t[1].split(":",2);return{url:e.replace(`${t[1]}@`,""),username:n,password:o}}}r(Wn,"parseBasicAuth");async function kt(e,t={},n=fetch){try{I(t)&&(t=le({},...J(t)));let o=Wn(String(e));o&&(e=o.url,t=le({},t,Kn(o.username,o.password))),t.headers!=null&&!(t.headers instanceof Headers)&&(t.headers=new Headers(t.headers));let i=await n(String(e),t);if(i.status<400)return i;try{K.warn(`Fetch of ${String(e)} returned status=${i.status}. Options:`,t),K.warn(`Response: ${await i.text()}`)}catch(s){K.error("Exception:",s)}}catch(o){K.error("fetchBasic",o)}}r(kt,"fetchBasic");async function ac(e,t={},n=fetch){try{let o=await kt(e,[{method:"GET",headers:{Accept:"application/json"}},t],n);if(o)return await o.json()}catch(o){K.error("fetchJSON error:",o)}}r(ac,"fetchJson");async function uc(e,t={},n=fetch){try{let o=await kt(e,[je,{method:"GET"},t],n);if(o)return await o.text()}catch(o){K.error("fetchHTML error:",o)}}r(uc,"fetchText");function cc(e,t="POST"){return{method:t,...je,headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:wt(e)}}r(cc,"fetchOptionsFormURLEncoded");function lc(e,t="POST"){return{method:t,...je,headers:{"Content-Type":"application/json; charset=utf-8"},body:S(e)}}r(lc,"fetchOptionsJson");function Kn(e,t){return{headers:{Authorization:`Basic ${We(`${e}:${t}`)}`}}}r(Kn,"fetchOptionsBasicAuth");function Ft(){if(typeof window<"u")return window}r(Ft,"getWindow");function Yn(){if(typeof navigator<"u")return navigator}r(Yn,"getNavigator");function pc(){return Ft()??typeof WorkerGlobalScope<"u"?self:typeof global<"u"?global:Function("return this;")()}r(pc,"getGlobal");var C=Yn(),N=Ft();function Qn(e={ios:!1,macos:!1,windows:!1,beaker:!1,electron:!1,wkwebview:!1,pwa:!1,pwaInstalled:!1,browser:!1,node:!1,worker:!1,test:!1,jest:!1,macosNative:!1,iosNative:!1,appleNative:!1,touch:!1}){return e.ios=C?.platform?.match(/(iPhone|iPod|iPad)/i)!=null,e.macos=!!C?.platform?.startsWith("Mac"),e.windows=!!C?.platform?.startsWith("Win"),e.beaker=N?.beaker!=null,e.electron=(C?.userAgent?.toLowerCase()?.indexOf(" electron/")||-1)>-1&&!e.beaker,e.wkwebview=N?.webkit?.messageHandlers!=null,e.pwa=C?.serviceWorker!=null,e.pwaInstalled=C?.standalone||N?.matchMedia?.("(display-mode: standalone)")?.matches,e.node=typeof process<"u"&&process?.release?.name==="node",e.browser=!e.electron&&!e.wkwebview&&!e.node,e.worker=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,e.jest=typeof jest<"u"||typeof vitest<"u",e.test=e.jest,e.macosNative=e.wkwebview&&e.macos,e.iosNative=e.wkwebview&&e.ios,e.appleNative=e.wkwebview,e.touch=N&&"ontouchstart"in N||(C?.maxTouchPoints||0)>1||C?.msPointerEnabled&&N?.MSGesture||N?.DocumentTouch&&document instanceof DocumentTouch,e}r(Qn,"detect");var Xn=r(()=>typeof window<"u"&&globalThis===window,"isBrowser"),gc=Qn();function mc(e){Xn()?window.addEventListener("beforeunload",e):typeof process<"u"&&process.on("exit",()=>e)}r(mc,"useExitHandler");var He=class{constructor(t={}){this.store={}}setItem(t,n){this.store[t]=Se(n)}getItem(t){return Se(this.store[t])}removeItem(t){delete this.store[t]}clear(){this.store={}}allKeys(){return Object.keys(this.store)}};r(He,"MemStorage");var wc=r(()=>{},"noop");export{r as a,Y as b,Ot as c,V as d,me as e,ne as f,re as g,Q as h,_e as i,ze as j,jt as k,A as l,br as m,S as n,Tr as o,_t as p,zt as q,Ve as r,qe as s,P as t,Dr as u,Je as v,Ze as w,We as x,Pr as y,Nt as z,Er as A,Ke as B,he as C,xe as D,Ye as E,q as F,Xe as G,be as H,Qe as I,Gt as J,Ur as K,kr as L,et as M,tt as N,Vt as O,D as P,Cr as Q,Or as R,$r as S,Br as T,qt as U,jr as V,Hr as W,_r as X,zr as Y,Jt as Z,Vr as _,we as $,qr as aa,Le as ba,Zt as ca,Wt as da,J as ea,Kt as fa,Yr as ga,Qr as ha,Xr as ia,Ae as ja,eo as ka,to as la,Yt as ma,no as na,Qt as oa,nt as pa,ro as qa,oo as ra,io as sa,so as ta,ao as ua,uo as va,co as wa,lo as xa,fo as ya,j as za,ho as Aa,xo as Ba,bo as Ca,To as Da,wo as Ea,Lo as Fa,Ao as Ga,vo as Ha,Do as Ia,Mo as Ja,nn as Ka,Ro as La,So as Ma,Io as Na,Co as Oa,Oo as Pa,rn as Qa,on as Ra,sn as Sa,ve as Ta,$o as Ua,Bo as Va,jo as Wa,Ho as Xa,an as Ya,_o as Za,zo as _a,Pe as $a,Ee as ab,ot as bb,un as cb,Vo as db,it as eb,st as fb,qo as gb,Jo as hb,ue as ib,Zo as jb,De as kb,cn as lb,ln as mb,Me as nb,at as ob,Wo as pb,Ko as qb,ae as rb,Yo as sb,Qo as tb,Xo as ub,ct as vb,ri as wb,oi as xb,lt as yb,ii as zb,ft as Ab,si as Bb,dt as Cb,ai as Db,E as Eb,k as Fb,L as Gb,di as Hb,pi as Ib,gi as Jb,mi as Kb,fn as Lb,xi as Mb,bi as Nb,Ti as Ob,F as Pb,Re as Qb,I as Rb,ce as Sb,Ai as Tb,vi as Ub,Di as Vb,Pi as Wb,Ei as Xb,pt as Yb,Mi as Zb,Ri as _b,Si as $b,Ui as ac,ki as bc,dn as cc,pn as dc,le as ec,gt as fc,Bi as gc,_i as hc,zi as ic,Ni as jc,Gi as kc,Zi as lc,Wi as mc,Ki as nc,Xi as oc,ht as pc,X as qc,xt as rc,os as sc,is as tc,ss as uc,as as vc,us as wc,cs as xc,ls as yc,fs as zc,bt as Ac,Tt as Bc,ms as Cc,xn as Dc,bs as Ec,As as Fc,Tn as Gc,wt as Hc,vs as Ic,Ms as Jc,Rs as Kc,Ss as Lc,Us as Mc,ks as Nc,Se as Oc,Fs as Pc,Is as Qc,Cs as Rc,Os as Sc,vn as Tc,Hs as Uc,Ue as Vc,ma as Wc,Pn as Xc,ya as Yc,ke as Zc,La as _c,Aa as $c,va as ad,Da as bd,Pa as cd,Sa as dd,Ua as ed,M as fd,ja as gd,Ha as hd,_a as id,At as jd,Ga as kd,Va as ld,Ie as md,Un as nd,kn as od,Fn as pd,In as qd,Cn as rd,On as sd,Bn as td,jn as ud,Hn as vd,Et as wd,Qa as xd,Xa as yd,zn as zd,eu as Ad,tu as Bd,H as Cd,Rt as Dd,Nn as Ed,nu as Fd,_ as Gd,ru as Hd,Vn as Id,qn as Jd,cu as Kd,Oe as Ld,Tu as Md,wu as Nd,vu as Od,Mu as Pd,pe as Qd,ee as Rd,Fu as Sd,$e as Td,z as Ud,Be as Vd,St as Wd,Vu as Xd,ge as Yd,Qu as Zd,tc as _d,Wn as $d,kt as ae,ac as be,uc as ce,cc as de,lc as ee,Kn as fe,Ft as ge,Yn as he,pc as ie,Qn as je,Xn as ke,gc as le,mc as me,He as ne,wc as oe};
12
+ //# sourceMappingURL=chunk-5KHM3AZX.js.map