zeed 0.8.21 → 0.8.22

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.
@@ -4,5 +4,5 @@ var It=Object.defineProperty;var o=(e,t)=>It(e,"name",{value:t,configurable:!0})
4
4
  `;return r}o(Rn,"csv");function Gt(){return crypto.getRandomValues(new Uint32Array(1))[0]/4294967295}o(Gt,"getSecureRandom");function R(){return typeof crypto<"u"?Gt():Math.random()}o(R,"getSecureRandomIfPossible");function Sn(e=.25){return R()<e}o(Sn,"randomBoolean");function kn(e=100,t=0){return t+Math.floor(R()*(e-t))}o(kn,"randomInt");function On(e=100,t=0){return t+R()*(e-t)}o(On,"randomFloat");function Fn(e,t,r){return Math.max(e,Math.min(r,t))}o(Fn,"between");function qt(e){return e.reduce((t,r)=>t+r,0)}o(qt,"sum");function $n(e){return qt(e)/e.length}o($n,"avg");function Bn(e){return!/^1?$|^(11+?)\1+$/.test("1".repeat(e))}o(Bn,"isPrimeRX");function Hn(e){for(var t=2;t<e;t++)if(e%t===0)return!1;return e>1}o(Hn,"isPrime");var we=6;function Nn(e=0,t=1,r){we=((r??we)*9301+49297)%233280;let n=we/233280;return t+n*(e-t)}o(Nn,"seededRandom");function _t(e=""){let[t="",r="asc"]=e.split(" ");return r=r.toLowerCase(),{field:t,orderby:r,asc:r!=="desc",desc:r==="desc"}}o(_t,"parseOrderby");function Vn(e,t=!0){return`${e} ${t?"asc":"desc"}`}o(Vn,"composeOrderby");function Le(e,t,r=!0){let n=e||0,i=t||0;return n>i?r?1:-1:n<i?r?-1:1:0}o(Le,"cmp");function zn(e,...t){if(t.length>0){let r=t.map(_t),n=Array.from(e);return n.sort((i,s)=>{for(let{field:u,asc:a}of r){let l=Le(i[u],s[u],a);if(l!==0)return l}return 0}),n}return e}o(zn,"sortedOrderby");function Ae(e){return e.filter((t,r)=>e.indexOf(t)===r)}o(Ae,"arrayUnique");function Jt(e,t){return Ae(e.filter(r=>!t.includes(r)))}o(Jt,"arrayMinus");function Zt(...e){return Ae(e.reduce((t=[],r)=>t.concat(r),[]))}o(Zt,"arrayUnion");function k(...e){return e.flat(1/0)}o(k,"arrayFlatten");function Wt(e,t){return Ae(e).filter(r=>t.includes(r))}o(Wt,"arrayIntersection");function Jn(e,t){return Jt(Zt(e,t),Wt(e,t))}o(Jn,"arraySymmetricDifference");function Zn(e,t){if(e&&Array.isArray(e)){let r;for(;(r=e.indexOf(t))!==-1;)e.splice(r,1);return e}return[]}o(Zn,"arrayRemoveElement");function Wn(e,t){return e.includes(t)||e.push(t),e}o(Wn,"arraySetElement");function ve(e,t){return e.splice(0,e.length,...e.filter(t)),e}o(ve,"arrayFilterInPlace");function Kn(e,t){let r=e.findIndex(n=>n===t);return r>=0?e.splice(r,1):e.push(t),e}o(Kn,"arrayToggleInPlace");function Yn(e){return e.splice(0,e.length),e}o(Yn,"arrayEmptyInPlace");function Kt(e,t=Le){return Array.from(e).sort(t)}o(Kt,"arraySorted");function Qn(e){return Kt(e,(t,r)=>t-r)}o(Qn,"arraySortedNumbers");function Yt(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}o(Yt,"arrayIsEqual");function nt(e){return e.sort(()=>R()>.5?1:-1),e}o(nt,"arrayShuffleInPlace");function Xn(e){return nt(Array.from(e))}o(Xn,"arrayShuffle");function eo(e){for(;e.length>1;){let t=Array.from(e);if(nt(t),!Yt(e,t))return t}return e}o(eo,"arrayShuffleForce");function to(e){return e[Math.floor(R()*e.length)]}o(to,"arrayRandomElement");function ro(...e){return k(e).reduce((t,r)=>t!=null?r>t?r:t:r,void 0)}o(ro,"arrayMax");function no(...e){return k(e).reduce((t,r)=>t!=null?r<t?r:t:r,void 0)}o(no,"arrayMin");function oo(...e){return k(e).reduce((t,r)=>t+r,0)}o(oo,"arraySum");function io(...e){let t=k(e);return t.reduce((r,n)=>r+n,0)/t.length}o(io,"arrayAvg");function so(e,t){let r=[],n=0,i=e.length;for(;n<i;)r.push(e.slice(n,n+=t));return r}o(so,"arrayBatches");function ao(e=0,t){if(e<=0)return[];let r=new Array(e);for(let n=0;n<e;n++)r[n]=t instanceof Function?t(n):t;return r}o(ao,"createArray");var Qt=A("zeed:basex"),Xt={2:"01",8:"01234567",11:"0123456789a",16:"0123456789abcdef",32:"0123456789ABCDEFGHJKMNPQRSTVWXYZ","32-rfc":"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567","32-hex":"0123456789ABCDEFGHIJKLMNOPQRSTUV","32-zbase":"ybndrfg8ejkmcpqxot1uwisza345h769",36:"0123456789abcdefghijklmnopqrstuvwxyz",58:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",62:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",64:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/","64-url":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",66:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.!~",85:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"};function O(e){let t;if(typeof e=="string")t=e;else if(t=Xt[String(e)],t==null)throw new Error(`Unknown base ${e}`);if(t.length>=255)throw new TypeError("Alphabet too long");let r=new Uint8Array(256);for(let c=0;c<r.length;c++)r[c]=255;for(let c=0;c<t.length;c++){let f=t.charAt(c),g=f.charCodeAt(0);if(r[g]!==255)throw new TypeError(f+" is ambiguous");r[g]=c}let n=t.length,i=t.charAt(0),s=Math.log(n)/Math.log(256),u=Math.log(256)/Math.log(n);function a(c,f=-1){let g=E(c);if(g.byteLength===0)return"";let p=0,y=0,T=g.byteLength;for(;y!==T&&g[y]===0;)y++;let m=(T-y)*u+1>>>0,d=new Uint8Array(m);for(;y!==T;){let x=g[y],w=0;for(let D=m-1;(x!==0||w<p)&&D!==-1;D--,w++)x+=256*d[D]>>>0,d[D]=x%n>>>0,x=x/n>>>0;if(x!==0)throw Qt.warn("Non-zero carry",g,f,w,m),new Error("Non-zero carry");p=w,y++}let h=m-p;for(;h!==m&&d[h]===0;)h++;let b="";for(;h<m;++h)b+=t.charAt(d[h]);return f>0?b.padStart(f,i):b}o(a,"encode");function l(c,f=-1){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;c=c.replace(/\s+/gi,"");let g=0,p=0;for(;c[g]===i;)g++;let y=(c.length-g)*s+1>>>0,T=new Uint8Array(y);for(;c[g];){let d=r[c.charCodeAt(g)];if(d===255)throw new Error(`Unsupported character "${c[g]}"`);let h=0;for(let b=y-1;(d!==0||h<p)&&b!==-1;b--,h++)d+=n*T[b]>>>0,T[b]=d%256>>>0,d=d/256>>>0;if(d!==0)throw new Error("Non-zero carry");p=h,g++}let m=y-p;for(;m!==y&&T[m]===0;)m++;return f>0?new Uint8Array([...new Uint8Array(f-T.length+m),...T.slice(m)]):T.slice(m)}return o(l,"decode"),{encode:a,decode:l}}o(O,"useBase");var{encode:po,decode:go}=O(16),{encode:mo,decode:yo}=O(32),{encode:ho,decode:xo}=O(58),{encode:bo,decode:To}=O(62),{encode:wo,decode:Lo}=O(62);var vo=o(e=>(e.length>0&&(/^[A-Z0-9_\-\ ]*$/g.test(e)&&(e=e.toLowerCase()),e=e.replace(/^[-_\ ]+/gi,"").replace(/[-_\ ]+$/gi,"").replace(/[-_\ ]+([a-z0-9])/gi,(t,r)=>r.toUpperCase()),e=e[0].toLowerCase()+e.substring(1)),e),"toCamelCase");function er(e){return e.charAt(0).toUpperCase()+e.toLowerCase().slice(1)}o(er,"toCapitalize");function Do(e){return e.replace(/\w\S*/g,er)}o(Do,"toCapitalizeWords");function Po(e,t="-"){return t=typeof t>"u"?"_":t,e.replace(/([a-z\d])([A-Z])/g,"$1"+t+"$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g,"$1"+t+"$2").toLowerCase()}o(Po,"fromCamelCase");var ot=o((e,t)=>t instanceof Object&&!(t instanceof Array)?Object.keys(t).sort().reduce((r,n)=>(r[n]=t[n],r),{}):t,"_sortedReplacer");function Mo(e,t=void 0){return JSON.stringify(e,ot,t)}o(Mo,"jsonStringifySorted");function tr(e,t){var r=[],n=[];return t==null&&(t=o(function(i,s){return r[0]===s?"[Circular ~]":"[Circular ~."+n.slice(0,r.indexOf(s)).join(".")+"]"},"cycleReplacer")),function(i,s){if(r.length>0){var u=r.indexOf(this);~u?r.splice(u+1):r.push(this),~u?n.splice(u,1/0,i):n.push(i),~r.indexOf(s)&&(s=t==null?void 0:t.call(this,i,s))}else r.push(s);return s=ot(i,s),e==null?s:e.call(this,i,s)}}o(tr,"serializer");function rr(e,t,r,n){return JSON.stringify(e,tr(t,n),r)}o(rr,"jsonStringifySafe");var De=rr;var it=["1","true","yes","y","on"];function Io(e,t=!1){return e==null||typeof e!="string"?t:it.includes(String(e).trim().toLowerCase())}o(Io,"stringToBoolean");function So(e,t=0){return e==null||typeof e!="string"?t:parseInt(e.trim(),10)??t}o(So,"stringToInteger");function ko(e,t=0){return e==null||typeof e!="string"?t:parseFloat(e.trim())??t}o(ko,"stringToFloat");function nr(e,t=!1){return e==null?t:typeof e=="boolean"?e:typeof e=="number"?e!==0:it.includes(String(e).trim().toLowerCase())}o(nr,"valueToBoolean");function or(e,t=0){return e==null?t:typeof e=="boolean"?e?1:0:typeof e=="number"?Math.floor(e):parseInt(String(e).trim(),10)??t}o(or,"valueToInteger");function ir(e,t=0){return e==null?t:typeof e=="boolean"?e?1:0:typeof e=="number"?Math.floor(e):parseFloat(String(e).trim())??t}o(ir,"valueToFloat");function Pe(e,t=""){return e==null?t:String(e)??t}o(Pe,"valueToString");var Oo=ir,Fo=or,$o=Pe,Bo=nr;function sr(e,t={}){let{trace:r=!0,pretty:n=!0}=t;return e.map(i=>i&&typeof i=="object"?n&&(i instanceof Uint8Array||i instanceof ArrayBuffer)?`
5
5
  `+Ye(i)+`
6
6
  `:i instanceof Error?r?`${i.name||"Error"}: ${i.message}
7
- ${i.stack}`:`${i.name||"Error"}: ${i.message}`:n?De(i,null,2):De(i):String(i))}o(sr,"formatMessages");function Ho(e,t={}){return sr(e,t).join(" ")}o(Ho,"renderMessages");function No(e){try{return decodeURIComponent(escape(e))}catch{}return e}o(No,"fixBrokenUth8String");var ar={symbol:"$",separator:",",decimal:".",errorOnInvalid:!1,precision:2,pattern:"!#",negativePattern:"-!#",format:fr,fromCents:!1},st=o(e=>Math.round(e),"round"),Ee=o(e=>Math.pow(10,e),"pow"),ur=o((e,t)=>st(e/t)*t,"rounding"),lr=/(\d)(?=(\d{3})+\b)/g,cr=/(\d)(?=(\d\d)+\d\b)/g;function N(e,t={}){return new I(e,t)}o(N,"currency");var X=class{constructor(t,r={}){let n=Object.assign({},ar,r),i=Ee(n.precision??2),s=fe(t,n);this.intValue=s,this.value=s/i,n.increment=n.increment||1/i,n.useVedic?n.groups=cr:n.groups=lr,this._settings=n,this._precision=i}add(t){let{intValue:r,_settings:n,_precision:i}=this;return N((r+=fe(t,n))/(n.fromCents?1:i),n)}subtract(t){let{intValue:r,_settings:n,_precision:i}=this;return N((r-=fe(t,n))/(n.fromCents?1:i),n)}multiply(t){let{intValue:r,_settings:n,_precision:i}=this;return N((r*=t)/(n.fromCents?1:Ee(i)),n)}divide(t){let{intValue:r,_settings:n}=this;return N(r/=fe(t,n,!1),n)}distribute(t){let{intValue:r,_precision:n,_settings:i}=this,s=[],u=Math[r>=0?"floor":"ceil"](r/t),a=Math.abs(r-u*t),l=i.fromCents?1:n;for(;t!==0;t--){let c=N(u/l,i);a-- >0&&(c=c[r>=0?"add":"subtract"](1/l)),s.push(c)}return s}dollars(){return~~this.value}cents(){let{intValue:t,_precision:r}=this;return~~(t%r)}format(t){let{_settings:r}=this;return typeof t=="function"?t(this,r):r.format(this,Object.assign({},r,t))}toString(){let{intValue:t,_precision:r,_settings:n}=this;return ur(t/r,n.increment).toFixed(n.precision)}toJSON(){return this.value}static sum(...t){return k(t).reduce((r,n)=>N(r).add(n),this.zero)}static avg(...t){let r=k(t);return r.reduce((n,i)=>N(n).add(i),this.zero).divide(r.length)}},I=X;o(I,"Currency"),I.zero=new X(0),I.one=new X(1),I.hundred=new X(100);function fe(e,t,r=!0){let n=0,{decimal:i,errorOnInvalid:s,precision:u,fromCents:a}=t,l=Ee(u),c=typeof e=="number";if(e instanceof I&&a)return e.intValue;if(c||e instanceof I)n=e instanceof I?e.value:e;else if(typeof e=="string"){let f=new RegExp("[^-\\d"+i+"]","g"),g=new RegExp("\\"+i,"g");n=e.replace(/\((.*)\)/,"-$1").replace(f,"").replace(g,"."),n=n||0}else{if(s)throw Error("Invalid Input");n=0}return a||(n*=l,n=n.toFixed(4)),r?st(n):n}o(fe,"parse");function fr(e,t){let{pattern:r,negativePattern:n,symbol:i,separator:s,decimal:u,groups:a}=t,l=(""+e).replace(/^-/,"").split("."),c=l[0],f=l[1];return(e.value>=0?r:n).replace("!",i).replace("#",c.replace(a,"$1"+s)+(f?u+f:""))}o(fr,"format");var Ue=864e5;function Ce(e){return Math.floor(e/1e4)}o(Ce,"dayYear");function at(e){return Math.floor(e/100%100)}o(at,"dayMonth");function pr(e){return Math.floor(e%100)}o(pr,"dayDay");function Go(e){return[Ce(e),at(e),pr(e)]}o(Go,"dayToParts");function ut(e,t=!1){return t?new Date(`${gr(e)}T00:00:00.000Z`):new Date(e/1e4,e/100%100-1,e%100)}o(ut,"dayToDate");function qo(){return pe(new Date)}o(qo,"dayFromToday");function _o(e,t=!1){if(typeof e=="number")return e<100?void 0:e;if(typeof e=="string")return lt(e);if(Array.isArray(e)&&e.length===3){let[r,n,i]=e;return Re(r,n,i)}else if(e instanceof Date)return pe(e,t)}o(_o,"dayFromAny");function Jo(e){return ut(e,!0)}o(Jo,"dayToDateGMT");function pe(e,t=!1){return t?lt(e.toISOString()):e.getFullYear()*1e4+(e.getMonth()+1)*100+e.getDate()}o(pe,"dayFromDate");function Zo(e){return pe(e,!0)}o(Zo,"dayFromDateGMT");function Me(e,t=!0){return ut(e,t).getTime()}o(Me,"dayToTimestamp");function dr(e,t=!0){return pe(new Date(e),t)}o(dr,"dayFromTimestamp");function gr(e,t="-"){let r=String(e);return r.slice(0,4)+t+r.slice(4,6)+t+r.slice(6,8)}o(gr,"dayToString");function Re(e,t=1,r=1){if(!(t<1||t>12||r<1||r>31))return e*1e4+t*100+r}o(Re,"dayFromParts");function lt(e){let t=String(e).replace(/[^0-9]/g,"").slice(0,8);if(t.length===8)return+t}o(lt,"dayFromString");function Wo(e,t=0){let r=Ce(e),n=at(e);return t!==0&&(n+=t,r+=Math.floor((n-1)/12),n=Math.floor((n-1)%12)+1,n===0&&(n=12)),Re(r,n,1)}o(Wo,"dayMonthStart");function Ko(e,t=0){let r=Ce(e);return Re(r+t,1,1)}o(Ko,"dayYearStart");function Yo(e,t){return dr(Me(e)+t*864e5)}o(Yo,"dayOffset");function Qo(e,t){return Math.round((Me(t)-Me(e))/864e5)}o(Qo,"dayDiff");var{warn:ct}=A("zeed:promise");function ft(){let e,t;return[new Promise((n,i)=>{e=n,t=i}),e,t]}o(ft,"createPromise");async function ti(e){return new Promise(t=>setTimeout(t,e))}o(ti,"sleep");async function ri(){return new Promise(e=>setTimeout(e,0))}o(ri,"immediate");var pt=Symbol("timeout");async function ni(e,t,r=pt){return new Promise(async(n,i)=>{let s=!1,u=setTimeout(()=>{s=!0,n(r)},t);try{let a=await e;clearTimeout(u),s||n(a)}catch(a){clearTimeout(u),s||i(a)}})}o(ni,"timeout");var dt=new Error("Timeout reached");function oi(e){return e===pt||e===dt}o(oi,"isTimeout");async function gt(e,t){return t<=0?await e:new Promise(async(r,n)=>{let i=!1,s=setTimeout(()=>{i=!0,n(dt)},t);try{let u=await e;clearTimeout(s),i||r(u)}catch(u){clearTimeout(s),i||n(u)}})}o(gt,"tryTimeout");function ii(e,t,r=1e3){return new Promise((n,i)=>{let s=o(l=>{a&&(clearTimeout(a),u(),n(l))},"fn"),u=o(()=>{a=null,e.off?e.off(t,s):e.removeEventListener?e.removeEventListener(t,s):ct("No remove listener method found for",e,t)},"done"),a=setTimeout(()=>{u(),i(new Error("Did not response in time"))},r);e.on?e.on(t,s):e.addEventListener?e.addEventListener(t,s):ct("No listener method found for",e)})}o(ii,"waitOn");function M(e){return Boolean(e&&(e instanceof Promise||typeof e.then=="function"))}o(M,"isPromise");function j(e){return Promise.resolve(e)}o(j,"promisify");var L=class{get value(){return this.days}constructor(t){var r;if(typeof t=="number"){this.days=t;return}if(t!=null&&(t=(r=L.from(t))==null?void 0:r.days),t==null){let n=new Date;this.days=n.getFullYear()*1e4+(n.getMonth()+1)*100+n.getDate()}else this.days=t}static fromNumber(t){return new L(t)}static fromString(t){return L.from(+t.replace(/[^0-9]/g,"").slice(0,8))}static fromDate(t,r=!1){return r?L.fromString(t.toISOString().substr(0,10)):L.from(t.getFullYear()*1e4+(t.getMonth()+1)*100+t.getDate())}static fromDateGMT(t){return L.fromDate(t,!0)}static from(t,r=!1){if(typeof t=="number")return t<100?void 0:new L(t);if(typeof t=="string")return L.fromString(t);if(Array.isArray(t)&&t.length===3){let[n,i=1,s=1]=t;return i<1||i>12||s<1||s>31?void 0:new L(n*1e4+i*100+s)}else{if(t instanceof Date)return L.fromDate(t,r);if(t instanceof L)return t}}toNumber(){return this.days}toJson(){return this.days}toString(t="-"){let r=String(this.days);return r.slice(0,4)+t+r.slice(4,6)+t+r.slice(6,8)}toDate(t=!1){return t?new Date(`${this.toString()}T00:00:00.000Z`):new Date(this.days/1e4,this.days/100%100-1,this.days%100)}toDateGMT(){return this.toDate(!0)}get year(){return Math.floor(this.days/1e4)}get month(){return Math.floor(this.days/100%100)}get day(){return Math.floor(this.days%100)}dayOffset(t){return L.fromDateGMT(new Date(this.toDateGMT().getTime()+t*864e5))}monthStart(){return L.from([this.year,this.month,1])}yearStart(){return L.from([this.year,1,1])}monthOffset(t){let r=this.month+t,n=Math.floor((r-1)%12)+1;n===0&&(n=12);let i=Math.floor((r-1)/12);return L.from([this.year+i,n,this.day])}daysUntil(t){var r;return Math.round((((r=new L(t))==null?void 0:r.toDateGMT().getTime())-this.toDateGMT().getTime())/864e5)}yesterday(){return this.dayOffset(-1)}tomorrow(){return this.dayOffset(1)}};o(L,"Day");async function fi(e,t,r){let n=L.from(e),i=L.from(t);for(;n&&i&&(n==null?void 0:n.days)<=(i==null?void 0:i.days);){let s=r(n);M(s)&&await s,n=n.dayOffset(1)}}o(fi,"forEachDay");function pi(){return new L}o(pi,"today");function di(e){return new L(e)}o(di,"day");function gi(e){return L.fromDate(new Date(e)).days}o(gi,"dateStringToDays");function mr(e,t=2){return+(+e).toFixed(t)}o(mr,"decimal");function yi(e,t=2){return+(+e/Math.pow(10,t)).toFixed(t)}o(yi,"decimalFromCents");function hi(e,t=2){return Math.round(+e*Math.pow(10,t))}o(hi,"decimalToCents");function xi(e,t=2){return t*(mr(e,t)%1)}o(xi,"decimalCentsPart");var mt=o(e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;"),"escapeHTML"),Ti=o(e=>e.replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,'"').replace(/&apos;/gi,"'").replace(/&amp;/gi,"&"),"unescapeHTML");function Ai(e,t){return S(e)?Object.fromEntries(Object.entries(e).map(([r,n])=>{let i=t(r,n);return B(i)&&i.length===2?i:[r,i]}).filter(r=>r!=null)):{}}o(Ai,"objectMap");function vi(e,t){return t.dispose&&e.dispose&&t.dispose.add(e.dispose),Object.assign(e,t)}o(vi,"objectMergeDisposable");var yt=/[\u0000-\u001F\u0080-\u009F]/g,yr=/^\.+/,hr=/\.+$/;function ht(){return/[<>:"/\\|?*\u0000-\u001F]/g}o(ht,"filenameReservedRegex");function xr(){return/^(con|prn|aux|nul|com\d|lpt\d)$/i}o(xr,"windowsReservedNameRegex");function Pi(e,t="_"){if(typeof e!="string")throw new TypeError("Expected a string");if(ht().test(t)&&yt.test(t))throw new Error("Replacement string cannot contain reserved filename characters");return e=e.replace(ht(),t).replace(yt,t).replace(yr,t).replace(hr,""),e=xr().test(e)?e+t:e,e.slice(0,100)}o(Pi,"toValidFilename");var br=/[\\\-\[\]\/{}()*+?.^$|]/g;function Mi(e){return e?e instanceof RegExp?e.source:e.replace(br,"\\$&"):""}o(Mi,"escapeRegExp");var ee=o(e=>Math.abs(e)%1===.5,"isHalf"),xt=o(e=>e%2===0,"isEven"),Ci=o(e=>Math.ceil(e),"roundUp"),Ri=o(e=>Math.floor(e),"roundDown"),Ii=o(e=>Math.round(e),"roundHalfUp"),Si=o(e=>{let t=Math.round(e);return ee(e)&&xt(t)?t-1:t},"roundHalfOdd"),ki=o(e=>ee(e)?Math.sign(e)*Math.ceil(Math.abs(e)):Math.round(e),"roundHalfAwayFromZero"),Oi=o(e=>ee(e)?Math.floor(e):Math.round(e),"roundHalfDown"),Fi=o(e=>{let t=Math.round(e);return ee(e)?xt(t)?t:t-1:t},"roundHalfEven"),$i=o(e=>ee(e)?Math.sign(e)*Math.floor(Math.abs(e)):Math.round(e),"roundHalfTowardsZero");function bt(e){return e.reduce((t,r)=>Math.min(t,r.sort_weight||0),0)-1-R()}o(bt,"startSortWeight");function Tt(e){return e.reduce((t,r)=>Math.max(t,r.sort_weight||0),0)+1+R()}o(Tt,"endSortWeight");function Ni(e,t,r){let n=r.length,i=e<t;if(n<=0||e>=n-1)return Tt(r);if(e<=0)return bt(r);r=Tr([...r]);let s=i?-1:0,u=r[e+s].sort_weight||0,l=(r[e+s+1].sort_weight||0)-u;if(l===0)return i?bt(r):Tt(r);let c=u+l/2,f=l*.01*(R()-.5);return c+f}o(Ni,"moveSortWeight");function Tr(e){return e.sort((t,r)=>(t.sort_weight||0)-(r.sort_weight||0)),e}o(Tr,"sortedItems");var wr=/((?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?)/gim;function zi(e){return e.split(wr).map((t,r)=>{let n=mt(t);return r%2?`<a target="_blank" href="${n}">${Lr(n)}</a>`:n}).join("")}o(zi,"linkifyPlainText");function Lr(e){return e.replace(/^https?:\/\/(www\.)?/,"").replace(/\/$/,"")}o(Lr,"toHumanReadableUrl");function wt(e){let t=[];for(let[r,n]of Object.entries(e))if(n!=null){Array.isArray(n)||(n=[n]);for(let i of n)i!=null&&t.push(encodeURIComponent(r)+"="+encodeURIComponent(String(i)))}return t.join("&")}o(wt,"encodeQuery");function Gi(e){let t={},r=(e[0]==="?"?e.substr(1):e).split("&");for(let n=0;n<r.length;n++){let i=r[n].split("="),s=decodeURIComponent(i[0]),u=decodeURIComponent(i[1]||"");t[s]!=null?(Array.isArray(t[s])||(t[s]=[t[s]]),t[s].push(u)):t[s]=u}return t}o(Gi,"parseQuery");function _i(e,t,r){let n=e[t];return n===void 0&&(n=r(t,e),e[t]=n),n}o(_i,"ensureKey");async function Ji(e,t,r){let n=e[t];return n===void 0&&(n=await r(t,e),e[t]=n),n}o(Ji,"ensureKeyAsync");function Zi(e){return e!=null?e.size!=null?e.size:e.length!=null?e.length:Object.keys(e).length:0}o(Zi,"size");function Wi(e){return e!=null&&e.length>0?e[e.length-1]:void 0}o(Wi,"last");function Ki(e){try{if(e!=null)return Array.isArray(e)||typeof e=="string"?e.length<=0:(e==null?void 0:e.size)!=null?e.size<=0:Object.keys(e).length<=0}catch(t){console.warn("Failed to check if empty for",e,t)}return!0}o(Ki,"empty");function Ie(e){return Object(e)!==e?e:JSON.parse(JSON.stringify(e))}o(Ie,"cloneObject");function Yi(e){return Object(e)!==e?e:JSON.parse(JSON.stringify(e))}o(Yi,"cloneJsonObject");function Qi(e){let t=new Map;return r=>{if(t.has(r))return t.get(r);let n=e(r);return t.set(r,n),n}}o(Qi,"memoize");function Xi(e){let t=new Map;return async(...r)=>{let n=JSON.stringify(r);if(t.has(n))return t.get(n);let i=await e(...r);return t.set(n,i),i}}o(Xi,"memoizeAsync");function es(e,t){let r=[];for(let n=0;n<e;n++)r.push(t(n,e));return r}o(es,"forTimes");var Ar=/\\\s|\s+|#[^\n]*\n?/gm,vr=/\(\?P?<(\w[\w\d_]+)>|\((?!\?(:|\!|=|<=|<\!))/gm,Lt=/^((?:\(\?[\w$]+\))?)\(\?<([=!])([\s\S]*?)\)/gm,Dr=A("zeed:xrx");function Pr(e){return typeof e=="string"?e:e.source||""}o(Pr,"regExpString");function ns(e){return e.replace(/[-\[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}o(ns,"regExpEscape");var Se=class{constructor(t,r){this.namedGroups={};this.names=[];let n=r??"",i;if(t instanceof RegExp?(r==null&&(n=t.flags),i=t.source):i=t,n&&n.indexOf("x")!==-1&&(n=n.replace("x",""),i=i.replace(Ar,a=>a[0]==="\\"?a:"")),!(t instanceof RegExp)){let a=0;i=i.replace(vr,(l,c)=>(a+=1,c?(c!=="index"&&c!=="length"&&!this.namedGroups[c]?this.namedGroups[c]=a:Dr.error(`Unallowed or duplicate group name: ${c}`),"("):l)),this.names=Object.keys(this.namedGroups)}i=Pr(i),Lt.lastIndex=0;let u=Lt.exec(i);u&&(this.lookBehind={rx:new RegExp(`${u[3]}$(?!\\s)`),expect:u?u[2]==="=":!u},i=i.substr(u[0].length)),this.rx=new RegExp(i,n)}get lastIndex(){return this.rx.lastIndex}set lastIndex(t){this.rx.lastIndex=t}_handleMatch(t){if(this.lookBehind){let r=t.input.slice(0,t.index);if(this.lookBehind.expect!==this.lookBehind.rx.test(r))return null}for(let r of this.names)t[r]=t[this.namedGroups[r]];return t}exec(t){let r;for(;r=this.rx.exec(t);)if(this.rx.lastIndex===r.index&&this.rx.lastIndex++,r=this._handleMatch(r),r!=null)return r}execAll(t){let r=[],n;for(this.rx.lastIndex=0;n=this.exec(t);)r.push(n);return this.rx.lastIndex=0,r}replace(t,r){let n=typeof r=="function"?r:()=>r;return t.replace(this.rx,i=>n(i))}};o(Se,"XRX");var Er=A("zeed:dispose");async function Mr(e){typeof e=="function"?await j(e()):M(e)?await e:typeof e.dispose=="function"?await j(e.dispose()):M(e.dispose)?await e.dispose:typeof e.cleanup=="function"?await j(e.cleanup()):M(e.cleanup)&&await e.cleanup}o(Mr,"callDisposer");function ke(e){let{name:t}=typeof e=="string"?{name:e}:e??{},r=[],n=o(async u=>{u!=null&&r.includes(u)&&(ve(r,a=>a!==u),await Mr(u))},"untrack"),i=o(async()=>{for(t&&Er.debug(`dispose ${t}: ${r.length} entries`);r.length>0;)await n(r[0])},"dispose"),s=o(u=>{if(u!=null)return r.unshift(u),()=>n(u)},"track");return Object.assign(i,{track:s,add:s,untrack:n,dispose:i,exec:i,getSize(){return r.length}})}o(ke,"useDispose");var us=ke;function ls(e={}){let{mode:t="fifo"}=e,r=[],n=o(async(s=!1)=>{for(;r.length>0;){let u=r[0];if(ve(r,a=>a!==u),typeof u=="function"){let a=u();if(M(a)){if(s)throw new Error(`Expected sync only function, but found async: ${u}`);await a}}else if(M(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(n,{add:o(s=>{t==="lifo"?r.unshift(s):r.push(s)},"add"),exec:n,getSize(){return r.length}})}o(ls,"useDefer");function cs(e,t=0){let r=setTimeout(e,t);return()=>{r&&(clearTimeout(r),r=void 0)}}o(cs,"useTimeout");function fs(e,t){let r=setInterval(e,t);return()=>{r&&(clearInterval(r),r=void 0)}}o(fs,"useInterval");function ps(e,t,r,...n){return e==null?()=>{}:(e.on?e.on(t,r,...n):e.addEventListener&&e.addEventListener(t,r,...n),()=>{e.off?e.off(t,r,...n):e.removeEventListener&&e.removeEventListener(t,r,...n)})}o(ps,"useEventListener");function ms(){let e=!0;return(t,r)=>{let n=!1;if(e){e=!1;try{t(),n=!0}finally{e=!0}}else r!==void 0&&r();return n}}o(ms,"useMutex");function ys(){let e=!0;return async(t,r)=>{let n=!1;if(e){e=!1;try{let i=t();M(i)&&await i,n=!0}finally{e=!0}}else if(r!==void 0){let i=r();M(i)&&await i}return n}}o(ys,"useAsyncMutex");var Z=A("zeed:emitter"),U=class{constructor(){this.subscribers={};this.subscribersOnAny=[];this.dispose=ke();this.call=new Proxy({},{get:(t,r)=>(...n)=>this.emit(r,...n)})}async emit(t,...r){let n=!1;this.dispose.add(()=>{this.subscribers={},this.subscribersOnAny=[]});try{let i=this.subscribers[t]||[];if(this.subscribersOnAny.forEach(s=>s(t,...r)),i.length>0){let s=i.map(u=>{try{return j(u(...r))}catch(a){Z.warn("emit warning:",a)}});n=!0,await Promise.all(s)}}catch(i){Z.error("emit exception",i)}return n}onAny(t){this.subscribersOnAny.push(t)}on(t,r){let n=this.subscribers[t]||[];return n.push(r),this.subscribers[t]=n,()=>{this.off(t,r)}}onCall(t){for(let[r,n]of Object.entries(t))this.on(r,n)}once(t,r){let n=o(async(...i)=>(this.off(t,n),await j(r(...i))),"onceListener");return this.on(t,n),()=>{this.off(t,r)}}off(t,r){return this.subscribers[t]=(this.subscribers[t]||[]).filter(n=>r&&n!==r),this}removeAllListeners(){return this.subscribers={},this}};o(U,"Emitter");function Ds(){let e=Q().emitter;return e||(e=new U,Q().emitter=e),e}o(Ds,"getGlobalEmitter");var Ps=new U;function Es(e,t){let r=Math.round(R()*100);var n=[],i;let s=o((a,l)=>{let c={key:a,obj:l};n.push(c),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(r,"Cannot listen to key"):e.onAny?e.onAny((a,l)=>{s(a,l)}):Z.error(r,"cannot listen to all for",e),o((a,l=!0)=>new Promise((c,f)=>{a||(a=t,a||n.length&&(a=n[0].key)),i=o(()=>{for(;n.length>0;){let g=n.shift();if(g.key===a)i=void 0,c(g.obj);else{if(l){Z.warn(r,`Unhandled event ${a} with value: ${g.obj}`);continue}f(`Expected ${a}, but found ${g.key} with value=${g.obj}`),Z.error(r,`Unhandled event ${a} with value: ${g.obj}`)}break}},"lazyResolve"),i()}),"on")}o(Es,"lazyListener");var At=o(()=>Date.now(),"getTimestamp");function Us(e){return e>999?(e/1e3).toFixed(1)+"s":e.toFixed(2)+"ms"}o(Us,"formatMilliseconds");function Cs(...e){for(let t of e){if(t instanceof Date)return t;if(typeof t=="string"){let r=null;if(t.includes(":"))try{r=new Date(t)}catch{}if(!(r instanceof Date)){let n=/(\d\d\d\d)-(\d\d)-(\d\d)/.exec(t);n&&(r=new Date(+n[1],+n[2]-1,+n[3],12,0))}if(r instanceof Date)return r}}}o(Cs,"parseDate");var{encode:Fe,decode:vt}=O(62),{encode:Dt,decode:Ur}=O(32);function Pt(){return J(16)}o(Pt,"uuidBytes");var sa=o(()=>new Uint32Array(J(4))[0],"uuid32bit");function V(){return Fe(Pt(),22)}o(V,"uuid");function aa(e){return Fe(e,22)}o(aa,"uuidEncode");function ua(e){let t=Je(e);return 1e7-1e3-4e3-8e3-1e11,`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16)}`}o(ua,"uuidEncodeV4");function la(e){return vt(e,16)}o(la,"uuidDecode");function ca(e){return Ze(e.replaceAll("-",""))}o(ca,"uuidDecodeV4");function fa(){return Dt(Pt(),26)}o(fa,"uuidB32");function pa(e){return Dt(e,26)}o(pa,"uuid32Encode");function da(e){return Ur(e,16)}o(da,"uuid32Decode");var Oe={};function z(e="id"){return Oe[e]==null&&(Oe[e]=0),`${e}-${Oe[e]++}`}o(z,"uname");var Cr=0;function ga(){return`id-${Cr++}`}o(ga,"qid");var Rr="10000000-1000-4000-8000-100000000000",ma=typeof crypto<"u"&&crypto.randomUUID!=null?crypto.randomUUID():()=>Rr.replace(/[018]/g,e=>(e^J(1)[0]&15>>e/4).toString(16)),Et=16e11;function Ir(e){var t=new Uint8Array([0,0,0,0,0,0]);let r=t.length-1;for(var n=0;n<t.length;n++){var i=e&255;t[r-n]=i,e=(e-i)/256}return t}o(Ir,"longToByteArray");function Sr(){let e=At()-Et;return new Uint8Array([...Ir(e),...J(10)])}o(Sr,"suidBytes");function ya(){return Fe(Sr(),22)}o(ya,"suid");function ha(e){return kr(vt(e,16))}o(ha,"suidDate");function kr(e){return new Date(Et+e.slice(0,6).reduce((t,r)=>t*256+r,0))}o(kr,"suidBytesDate");var Or=(n=>(n[n.waiting=0]="waiting",n[n.running=1]="running",n[n.finished=2]="finished",n))(Or||{}),Fr=(n=>(n[n.replace=0]="replace",n[n.memoize=1]="memoize",n[n.error=2]="error",n))(Fr||{});function La(e={}){let{maxParallel:t=3}=e,r=new U,n=0,i=0,s=0,u=0,a={};async function l(){if(n>0){let[m,d]=ft();return r.once("didFinish",d),m}}o(l,"waitFinishAll");function c(){r.emit("didFinish"),n=0,i=0}o(c,"didFinish");function f(){let m=0,d=0;for(let{max:h,resolved:b,state:x}of Object.values(a))m+=h,d+=x===2?h:Math.min(h,b);r.emit("didUpdate",n,i,m,d)}o(f,"didUpdate");function g(){if(f(),n>0&&n===i&&c(),s>=t)return;let m=Object.values(a).filter(d=>d.state===0);if(m.length>0){let d;for(let h of m)h.group!=null&&Object.values(a).some(b=>b.state===1&&b.id!==h.id&&b.group===h.group)||(d==null||h.priority<d.priority)&&(d=h);if(d!=null){let h=d.id,b=d.done;d.state=1,++s,r.emit("didStart",h);let x=o(w=>{d&&(d.result=w,d.state=2,d.resolved=d.max),--s,++i,g()},"taskFinished");d.task(d).then(w=>{b(w),r.emit("didResolve",h,w),x(w)}).catch(w=>{b(),r.emit("didReject",h,w),x()})}}}o(g,"performNext");function p(m){let d=a[m];d&&d.state===0&&(a[m].state=2,++i,r.emit("didCancel",m),f())}o(p,"cancel");function y(){Object.keys(a).forEach(p)}o(y,"cancelAll");function T(m,d={}){let h,b=new Promise(w=>h=w),x=d.id??V();if(a[x]!=null){let w=d.idConflictResolution??1;if(w===0)p(x);else if(w===1){let D=a[x];return{id:x,promise:(async()=>{if(D.state===2)return a[x].result})(),dispose:()=>p(x),cancel:()=>p(x)}}else throw new Error(`Pool task with id=${x} already exists!`)}return a[x]={id:x,task:m,priority:++u,group:d.group,state:0,max:d.max??1,resolved:d.resolved??0,done:h,payload:d.payload,setMax(w){a[x].max=w,f()},setResolved(w){a[x].resolved=w,f()},incResolved(w=1){a[x].resolved+=w,f()}},++n,g(),{id:x,promise:b,dispose:()=>p(x),cancel:()=>p(x)}}return o(T,"enqueue"),{events:r,cancel:p,cancelAll:y,enqueue:T,dispose:y,waitFinishAll:l}}o(La,"usePool");var $e=class extends U{constructor(r={}){super();this.queue=[];this.waitToFinish=[];this.countMax=0;this.countResolved=0;this.paused=!1;let{name:n=z("queue"),logLevel:i}=r;this.name=n,this.log=A(`zeed:queue:${n}`,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 r=this.queue.shift();if(this.log(`performNext => ${r==null?void 0:r.name}`),r==null)break;this.countResolved===0&&this.emit("didStart",this.countMax);let{name:n,task:i,resolve:s}=r;this.currentTask=i();let u;try{this.log.info(`start task ${n}`),u=await this.currentTask,this.log(`finished task ${n} 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(r,n={}){let{immediate:i=!1,name:s=z(this.name)}=n;return i?(this.log.info(`immediate execution ${s}`),await r()):(this.log(`enqueue ${s}`),new Promise(u=>{this.queue.push({name:s,task:r,resolve:u}),this.countMax+=1,this.emit("didUpdate",this.countMax,this.countResolved),this.performNext()}))}async enqueueReentrant(r,n={}){return this.enqueue(r,{immediate:this.currentTask!=null,name:n.name})}async cancelAll(r=!0){this.log("cancelAll"),this.emit("didCancel");let n=this.queue.map(i=>i.resolve);this.queue=[],n.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(r=>{this.waitToFinish.push(r)})}get isPaused(){return this.paused}get hasTasks(){return this.queue.length!==0}};o($e,"SerialQueue");var K=!1,W=K?A("zeed:throttle"):()=>{};function Ra(e,t={}){let{delay:r=100,trailing:n=!0,leading:i=!0}=t,s=0,u=0,a=0,l,c=Date.now();function f(){s&&(clearTimeout(s),s=void 0)}o(f,"clearExistingTimeout");function g(...p){let y=Date.now(),T=this,m=y-u;function d(){let b=Date.now();return`total ${(b-c).toFixed(1)}ms - elapsed ${(b-u).toFixed(1)}ms - visited ${a}x`}o(d,"debugElapsed");function h(){a=0,u=Date.now(),e.apply(T,p)}if(o(h,"exec"),l=h,m>r||!s){K&&W("elapsed",d()),i&&(m>r?(K&&W("\u{1F680} leading",d()),h()):++a);let b=m>r?r:r-m;W(`\u23F1 start timeout with ${b.toFixed(1)}ms`,d()),f(),u=y,s=setTimeout(()=>{K&&W("\u23F1 reached timeout",d()),s=0,n&&(!i||a>0)&&(K&&W("\u{1F680} trailing",d()),l==null||l())},b)}else++a,K&&W("visited",d())}return o(g,"wrapper"),g.cancel=f,g.dispose=f,g}o(Ra,"throttle");function Ia(e,t={}){let{delay:r=100}=t,n=0;function i(){n&&(clearTimeout(n),n=0)}o(i,"clearExistingTimeout");function s(...u){let a=this;i(),n=setTimeout(()=>{n=0,e.apply(a,u)},r)}return o(s,"wrapper"),s.cancel=i,s.dispose=i,s}o(Ia,"debounce");function ka(e=(t=>(t=globalThis==null?void 0:globalThis.location)==null?void 0:t.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")}o(ka,"isLocalHost");function $a(e){let{level:t=void 0,filter:r=void 0,messages:n=[]}=e,i=_(r),s=ie(t);return u=>{!s(u.level)||!i(u.name)||n.push(u)}}o($a,"LoggerMemoryHandler");var de=class extends U{constructor(){super(...arguments);this.id=V()}close(){this.dispose()}};o(de,"Channel");var te=class extends de{constructor(){super(...arguments);this.isConnected=!0}postMessage(r){var n;(n=this.other)==null||n.emit("message",{data:r,origin:"local",lastEventId:V()})}};o(te,"LocalChannel");function ja(){let e=new te,t=new te;return e.other=t,t.other=e,[e,t]}o(ja,"createLocalChannelPair");var Be=class{async encode(t){return t}async decode(t){return t}};o(Be,"NoopEncoder");var G=class{async encode(t){return xe(t)}async decode(t){return be(t)}};o(G,"JsonEncoder");var He=class{constructor(t){this.key=t}async encode(t){let r=xe(t);return await et(r,this.key)}async decode(t){let r=await tt(t,this.key);return be(r)}};o(He,"CryptoEncoder");var Mt=o((e,t,r={})=>new Proxy(r,{get:(n,i)=>i in n?n[i]:(...s)=>e(i,s,t)}),"createPromiseProxy");function Qa(e={}){let{name:t=z("hub"),encoder:r=new G,retryAfter:n=1e3,ignoreUnhandled:i=!0,logLevel:s=!1}=e,u=A(t,s),a={},l,c=[],f,g={},p=o(()=>{clearTimeout(f)},"dispose"),y=o(async()=>{if(clearTimeout(f),l){if(l.isConnected)for(;c.length;){let h=c[0];try{l.postMessage(await r.encode(h)),c.shift()}catch(b){u.warn("postMessage",b);break}}c.length>0&&n>0&&(f=setTimeout(y,n))}},"postNext"),T=o(async h=>{u("enqueue postMessage",h),c.push(h),await y()},"postMessage"),m=o(async h=>{l=h,l.on("connect",y),l.on("message",async b=>{u("onmessage",typeof b);let{name:x,args:w,id:D,result:q,error:F}=await r.decode(b.data);if(x){u(`name ${x} id ${D}`);try{if(a[x]==null)throw new Error(`handler for ${x} was not found`);let C=a[x](...w);M(C)&&(C=await C),u(`result ${C}`),D&&T({id:D,result:C})}catch(C){let $=C instanceof Error?C:new Error(Pe(C));u.warn("execution error",$.name),T({id:D,error:{message:$.message,stack:$.stack,name:$.name}})}}else if(D)if(u(`response for id=${D}: result=${q}, error=${F}`),g[D]==null)q===void 0?u(`skip response for ${D}`):u.warn(`no response hook for ${D}`);else{let[C,$]=g[D];if(C&&$)if(delete g[D],F){let re=new Error(F.message);re.stack=F.stack,re.name=F.name,u.warn("reject",re.name),$(re)}else u("resolve",q),C(q)}else i||u.warn("Unhandled message",b)}),y()},"connect"),d=o(async(h,b,x={})=>{let{timeout:w=5e3}=x,D=V();return T({name:h,args:b,id:D}),gt(new Promise((q,F)=>g[D]=[q,F]),w)},"fetchMessage");return e.channel&&m(e.channel),{dispose:p,connect:m,listen(h){Object.assign(a,h)},send(){return Mt(d,{},{options(h){return Mt(d,{...h})}})}}}o(Qa,"useMessageHub");var ge=class extends U{constructor(r){super();this.publish=this.emit;this.subscribe=this.on;let{name:n,encoder:i=new G,channel:s,debug:u=!1}=r;this.channel=s,this.encoder=i,this.debug=u,this.name=n??this.channel.id??z("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 l=await this.encoder.decode(a);if(this.debug?this.log(`channel message, event=${l==null?void 0:l.event}, info=`,l):this.log(`channel message, event=${l==null?void 0:l.event}`),l){let{event:c,args:f}=l;await this.emitSuper(c,...f)}})}get shortId(){return this.name.substr(0,6)}async emitSuper(r,...n){return await super.emit(r,...n)}async emit(r,...n){try{if(this.debug?this.log(`emit(${String(r)})`,r):this.log(`emit(${String(r)})`,n.length),!this.channel.isConnected)return this.log.warn("channel not connected"),!1;let i=await this.encoder.encode({event:r,args:n});return this.channel.postMessage(i),!0}catch(i){this.log.warn(`emit(${String(r)})`,i)}return!1}};o(ge,"PubSub");function au(e){return new ge(e)}o(au,"usePubSub");var $r=1;var Ut=o(e=>e,"defaultSerialize"),Br=Ut;function lu(e,t){let{post:r,on:n,eventNames:i=[],serialize:s=Ut,deserialize:u=Br}=t,a=new Map;return n(async l=>{let c=u(l),[f,g,p,y]=c;if(f===1||f===2){let T,m;if(y!=null)try{T=await e[y](...g)}catch(d){m=String(d)}else m="Method implementation missing";f===1&&p&&r(s(m?[4,m,p]:[3,T,p]))}else if(p){let T=a.get(p);T!=null&&(f===4?T.reject(g):T.resolve(g)),a.delete(p)}}),new Proxy({},{get(l,c){let f=o((...p)=>{r(s([2,p,null,c]))},"sendEvent");if(t.onlyEvents||i.includes(c))return f.asEvent=f,f;let g=o((...p)=>new Promise((y,T)=>{let m=$r++;a.set(m,{resolve:y,reject:T}),r(s([1,p,m,c]))}),"sendCall");return g.asEvent=f,g}})}o(lu,"useRPC");var Y=A("zeed:network"),Ne={cache:"no-cache",redirect:"follow",headers:{}};function Hr(e){let t=/:\/\/([^@]*)@/gi.exec(e);if(t&&t[1]){let[r,n]=t[1].split(":",2);return{url:e.replace(t[1]+"@",""),username:r,password:n}}}o(Hr,"parseBasicAuth");async function Ct(e,t={},r=fetch){try{B(t)&&(t=oe({},...k(t)));let n=Hr(String(e));n&&(e=n.url,t=oe({},t,Nr(n.username,n.password))),t.headers!=null&&!(t.headers instanceof Headers)&&(t.headers=new Headers(t.headers));let i=await r(String(e),t);if(i.status<400)return i;try{Y.warn(`Fetch of ${e} with ${t} returned status=${i.status}`),Y.warn(`Response: ${await i.text()}`)}catch(s){Y.error("Exception:",s)}}catch(n){Y.error("fetchBasic",n)}}o(Ct,"fetchBasic");async function gu(e,t={},r=fetch){try{let n=await Ct(e,[{method:"GET",headers:{Accept:"application/json"}},t],r);if(n)return await n.json()}catch(n){Y.error("fetchJSON error:",n)}}o(gu,"fetchJson");async function mu(e,t={},r=fetch){try{let n=await Ct(e,[Ne,{method:"GET"},t],r);if(n)return await n.text()}catch(n){Y.error("fetchHTML error:",n)}}o(mu,"fetchText");function yu(e,t="POST"){return{method:t,...Ne,headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:wt(e)}}o(yu,"fetchOptionsFormURLEncoded");function hu(e,t="POST"){return{method:t,...Ne,headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(e)}}o(hu,"fetchOptionsJson");function Nr(e,t){return{headers:{Authorization:"Basic "+We(e+":"+t)}}}o(Nr,"fetchOptionsBasicAuth");function Rt(){if(typeof window<"u")return window}o(Rt,"getWindow");function jr(){if(typeof navigator<"u")return navigator}o(jr,"getNavigator");function bu(){return Rt()??typeof WorkerGlobalScope<"u"?self:typeof global<"u"?global:Function("return this;")()}o(bu,"getGlobal");var v=jr(),P=Rt();function Vr(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}){var t,r,n,i,s,u,a,l,c;return e.ios=((t=v==null?void 0:v.platform)==null?void 0:t.match(/(iPhone|iPod|iPad)/i))!=null,e.macos=!!((r=v==null?void 0:v.platform)!=null&&r.startsWith("Mac")),e.windows=!!((n=v==null?void 0:v.platform)!=null&&n.startsWith("Win")),e.beaker=(P==null?void 0:P.beaker)!=null,e.electron=(((s=(i=v==null?void 0:v.userAgent)==null?void 0:i.toLowerCase())==null?void 0:s.indexOf(" electron/"))||-1)>-1&&!e.beaker,e.wkwebview=((u=P==null?void 0:P.webkit)==null?void 0:u.messageHandlers)!=null,e.pwa=(v==null?void 0:v.serviceWorker)!=null,e.pwaInstalled=(v==null?void 0:v.standalone)||((l=(a=P==null?void 0:P.matchMedia)==null?void 0:a.call(P,"(display-mode: standalone)"))==null?void 0:l.matches),e.node=typeof process<"u"&&((c=process==null?void 0:process.release)==null?void 0:c.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=P&&"ontouchstart"in P||((v==null?void 0:v.maxTouchPoints)||0)>1||(v==null?void 0:v.msPointerEnabled)&&(P==null?void 0:P.MSGesture)||(P==null?void 0:P.DocumentTouch)&&document instanceof DocumentTouch,e}o(Vr,"detect");var zr=o(()=>typeof window<"u"&&globalThis===window,"isBrowser"),Tu=Vr();function wu(e){zr()?window.addEventListener("beforeunload",e):typeof process<"u"&&process.on("exit",()=>e)}o(wu,"useExitHandler");var Du=A("zeed:memstorage"),je=class{constructor(t={}){this.store={}}setItem(t,r){this.store[t]=Ie(r)}getItem(t){if(this.store.hasOwnProperty(t))return Ie(this.store[t])}removeItem(t){delete this.store[t]}clear(){this.store={}}allKeys(){return Object.keys(this.store)}};o(je,"MemStorage");export{o as a,Q as b,S as c,me as d,B as e,Ve as f,_r as g,Jr as h,Zr as i,Wr as j,Kr as k,Yr as l,Qr as m,ne as n,kt as o,oe as p,Ot as q,_ as r,ye as s,ie as t,se as u,ae as v,ze as w,Ge as x,Bt as y,A as z,Ht as A,Nt as B,_e as C,jt as D,E,Ln as F,Je as G,Ze as H,We as I,An as J,vn as K,Ke as L,xe as M,be as N,Ye as O,J as P,Mn as Q,Un as R,et as S,tt as T,Rn as U,Gt as V,R as W,Sn as X,kn as Y,On as Z,Fn as _,qt as $,$n as aa,Bn as ba,Hn as ca,Nn as da,_t as ea,Vn as fa,Le as ga,zn as ha,Ae as ia,Jt as ja,Zt as ka,k as la,Wt as ma,Jn as na,Zn as oa,Wn as pa,ve as qa,Kn as ra,Yn as sa,Kt as ta,Qn as ua,Yt as va,nt as wa,Xn as xa,eo as ya,to as za,ro as Aa,no as Ba,oo as Ca,io as Da,so as Ea,ao as Fa,O as Ga,po as Ha,go as Ia,mo as Ja,yo as Ka,ho as La,xo as Ma,bo as Na,To as Oa,wo as Pa,Lo as Qa,vo as Ra,er as Sa,Do as Ta,Po as Ua,Mo as Va,rr as Wa,De as Xa,Io as Ya,So as Za,ko as _a,nr as $a,or as ab,ir as bb,Pe as cb,Oo as db,Fo as eb,$o as fb,Bo as gb,sr as hb,Ho as ib,No as jb,N as kb,I as lb,Ue as mb,Ce as nb,at as ob,pr as pb,Go as qb,ut as rb,qo as sb,_o as tb,Jo as ub,pe as vb,Zo as wb,Me as xb,dr as yb,gr as zb,Re as Ab,lt as Bb,Wo as Cb,Ko as Db,Yo as Eb,Qo as Fb,ft as Gb,ti as Hb,ri as Ib,pt as Jb,ni as Kb,dt as Lb,oi as Mb,gt as Nb,ii as Ob,M as Pb,j as Qb,L as Rb,fi as Sb,pi as Tb,di as Ub,gi as Vb,mr as Wb,yi as Xb,hi as Yb,xi as Zb,mt as _b,Ti as $b,Ai as ac,vi as bc,Pi as cc,Mi as dc,ee as ec,xt as fc,Ci as gc,Ri as hc,Ii as ic,Si as jc,ki as kc,Oi as lc,Fi as mc,$i as nc,bt as oc,Tt as pc,Ni as qc,Tr as rc,zi as sc,Lr as tc,wt as uc,Gi as vc,_i as wc,Ji as xc,Zi as yc,Wi as zc,Ki as Ac,Ie as Bc,Yi as Cc,Qi as Dc,Xi as Ec,es as Fc,Pr as Gc,ns as Hc,Se as Ic,ke as Jc,us as Kc,ls as Lc,cs as Mc,fs as Nc,ps as Oc,ms as Pc,ys as Qc,U as Rc,Ds as Sc,Ps as Tc,Es as Uc,At as Vc,Us as Wc,Cs as Xc,Pt as Yc,sa as Zc,V as _c,aa as $c,ua as ad,la as bd,ca as cd,fa as dd,pa as ed,da as fd,z as gd,ga as hd,ma as id,Sr as jd,ya as kd,ha as ld,kr as md,Or as nd,Fr as od,La as pd,$e as qd,Ra as rd,Ia as sd,ka as td,$a as ud,de as vd,te as wd,ja as xd,Be as yd,G as zd,He as Ad,Mt as Bd,Qa as Cd,ge as Dd,au as Ed,lu as Fd,Hr as Gd,Ct as Hd,gu as Id,mu as Jd,yu as Kd,hu as Ld,Nr as Md,Rt as Nd,jr as Od,bu as Pd,Vr as Qd,zr as Rd,Tu as Sd,wu as Td,je as Ud};
8
- //# sourceMappingURL=chunk-ACYVDJ4S.js.map
7
+ ${i.stack}`:`${i.name||"Error"}: ${i.message}`:n?De(i,null,2):De(i):String(i))}o(sr,"formatMessages");function Ho(e,t={}){return sr(e,t).join(" ")}o(Ho,"renderMessages");function No(e){try{return decodeURIComponent(escape(e))}catch{}return e}o(No,"fixBrokenUth8String");var ar={symbol:"$",separator:",",decimal:".",errorOnInvalid:!1,precision:2,pattern:"!#",negativePattern:"-!#",format:fr,fromCents:!1},st=o(e=>Math.round(e),"round"),Ee=o(e=>Math.pow(10,e),"pow"),ur=o((e,t)=>st(e/t)*t,"rounding"),lr=/(\d)(?=(\d{3})+\b)/g,cr=/(\d)(?=(\d\d)+\d\b)/g;function N(e,t={}){return new I(e,t)}o(N,"currency");var X=class{constructor(t,r={}){let n=Object.assign({},ar,r),i=Ee(n.precision??2),s=fe(t,n);this.intValue=s,this.value=s/i,n.increment=n.increment||1/i,n.useVedic?n.groups=cr:n.groups=lr,this._settings=n,this._precision=i}add(t){let{intValue:r,_settings:n,_precision:i}=this;return N((r+=fe(t,n))/(n.fromCents?1:i),n)}subtract(t){let{intValue:r,_settings:n,_precision:i}=this;return N((r-=fe(t,n))/(n.fromCents?1:i),n)}multiply(t){let{intValue:r,_settings:n,_precision:i}=this;return N((r*=t)/(n.fromCents?1:Ee(i)),n)}divide(t){let{intValue:r,_settings:n}=this;return N(r/=fe(t,n,!1),n)}distribute(t){let{intValue:r,_precision:n,_settings:i}=this,s=[],u=Math[r>=0?"floor":"ceil"](r/t),a=Math.abs(r-u*t),l=i.fromCents?1:n;for(;t!==0;t--){let c=N(u/l,i);a-- >0&&(c=c[r>=0?"add":"subtract"](1/l)),s.push(c)}return s}dollars(){return~~this.value}cents(){let{intValue:t,_precision:r}=this;return~~(t%r)}format(t){let{_settings:r}=this;return typeof t=="function"?t(this,r):r.format(this,Object.assign({},r,t))}toString(){let{intValue:t,_precision:r,_settings:n}=this;return ur(t/r,n.increment).toFixed(n.precision)}toJSON(){return this.value}static sum(...t){return k(t).reduce((r,n)=>N(r).add(n),this.zero)}static avg(...t){let r=k(t);return r.reduce((n,i)=>N(n).add(i),this.zero).divide(r.length)}},I=X;o(I,"Currency"),I.zero=new X(0),I.one=new X(1),I.hundred=new X(100);function fe(e,t,r=!0){let n=0,{decimal:i,errorOnInvalid:s,precision:u,fromCents:a}=t,l=Ee(u),c=typeof e=="number";if(e instanceof I&&a)return e.intValue;if(c||e instanceof I)n=e instanceof I?e.value:e;else if(typeof e=="string"){let f=new RegExp("[^-\\d"+i+"]","g"),g=new RegExp("\\"+i,"g");n=e.replace(/\((.*)\)/,"-$1").replace(f,"").replace(g,"."),n=n||0}else{if(s)throw Error("Invalid Input");n=0}return a||(n*=l,n=n.toFixed(4)),r?st(n):n}o(fe,"parse");function fr(e,t){let{pattern:r,negativePattern:n,symbol:i,separator:s,decimal:u,groups:a}=t,l=(""+e).replace(/^-/,"").split("."),c=l[0],f=l[1];return(e.value>=0?r:n).replace("!",i).replace("#",c.replace(a,"$1"+s)+(f?u+f:""))}o(fr,"format");var Ue=864e5;function Ce(e){return Math.floor(e/1e4)}o(Ce,"dayYear");function at(e){return Math.floor(e/100%100)}o(at,"dayMonth");function pr(e){return Math.floor(e%100)}o(pr,"dayDay");function Go(e){return[Ce(e),at(e),pr(e)]}o(Go,"dayToParts");function ut(e,t=!1){return t?new Date(`${gr(e)}T00:00:00.000Z`):new Date(e/1e4,e/100%100-1,e%100)}o(ut,"dayToDate");function qo(){return pe(new Date)}o(qo,"dayFromToday");function _o(e,t=!1){if(typeof e=="number")return e<100?void 0:e;if(typeof e=="string")return lt(e);if(Array.isArray(e)&&e.length===3){let[r,n,i]=e;return Re(r,n,i)}else if(e instanceof Date)return pe(e,t)}o(_o,"dayFromAny");function Jo(e){return ut(e,!0)}o(Jo,"dayToDateGMT");function pe(e,t=!1){return t?lt(e.toISOString()):e.getFullYear()*1e4+(e.getMonth()+1)*100+e.getDate()}o(pe,"dayFromDate");function Zo(e){return pe(e,!0)}o(Zo,"dayFromDateGMT");function Me(e,t=!0){return ut(e,t).getTime()}o(Me,"dayToTimestamp");function dr(e,t=!0){return pe(new Date(e),t)}o(dr,"dayFromTimestamp");function gr(e,t="-"){let r=String(e);return r.slice(0,4)+t+r.slice(4,6)+t+r.slice(6,8)}o(gr,"dayToString");function Re(e,t=1,r=1){if(!(t<1||t>12||r<1||r>31))return e*1e4+t*100+r}o(Re,"dayFromParts");function lt(e){let t=String(e).replace(/[^0-9]/g,"").slice(0,8);if(t.length===8)return+t}o(lt,"dayFromString");function Wo(e,t=0){let r=Ce(e),n=at(e);return t!==0&&(n+=t,r+=Math.floor((n-1)/12),n=Math.floor((n-1)%12)+1,n===0&&(n=12)),Re(r,n,1)}o(Wo,"dayMonthStart");function Ko(e,t=0){let r=Ce(e);return Re(r+t,1,1)}o(Ko,"dayYearStart");function Yo(e,t){return dr(Me(e)+t*864e5)}o(Yo,"dayOffset");function Qo(e,t){return Math.round((Me(t)-Me(e))/864e5)}o(Qo,"dayDiff");var{warn:ct}=A("zeed:promise");function ft(){let e,t;return[new Promise((n,i)=>{e=n,t=i}),e,t]}o(ft,"createPromise");async function ti(e){return new Promise(t=>setTimeout(t,e))}o(ti,"sleep");async function ri(){return new Promise(e=>setTimeout(e,0))}o(ri,"immediate");var pt=Symbol("timeout");async function ni(e,t,r=pt){return new Promise(async(n,i)=>{let s=!1,u=setTimeout(()=>{s=!0,n(r)},t);try{let a=await e;clearTimeout(u),s||n(a)}catch(a){clearTimeout(u),s||i(a)}})}o(ni,"timeout");var dt=new Error("Timeout reached");function oi(e){return e===pt||e===dt}o(oi,"isTimeout");async function gt(e,t){return t<=0?await e:new Promise(async(r,n)=>{let i=!1,s=setTimeout(()=>{i=!0,n(dt)},t);try{let u=await e;clearTimeout(s),i||r(u)}catch(u){clearTimeout(s),i||n(u)}})}o(gt,"tryTimeout");function ii(e,t,r=1e3){return new Promise((n,i)=>{let s=o(l=>{a&&(clearTimeout(a),u(),n(l))},"fn"),u=o(()=>{a=null,e.off?e.off(t,s):e.removeEventListener?e.removeEventListener(t,s):ct("No remove listener method found for",e,t)},"done"),a=setTimeout(()=>{u(),i(new Error("Did not response in time"))},r);e.on?e.on(t,s):e.addEventListener?e.addEventListener(t,s):ct("No listener method found for",e)})}o(ii,"waitOn");function M(e){return Boolean(e&&(e instanceof Promise||typeof e.then=="function"))}o(M,"isPromise");function j(e){return Promise.resolve(e)}o(j,"promisify");var L=class{get value(){return this.days}constructor(t){var r;if(typeof t=="number"){this.days=t;return}if(t!=null&&(t=(r=L.from(t))==null?void 0:r.days),t==null){let n=new Date;this.days=n.getFullYear()*1e4+(n.getMonth()+1)*100+n.getDate()}else this.days=t}static fromNumber(t){return new L(t)}static fromString(t){return L.from(+t.replace(/[^0-9]/g,"").slice(0,8))}static fromDate(t,r=!1){return r?L.fromString(t.toISOString().substr(0,10)):L.from(t.getFullYear()*1e4+(t.getMonth()+1)*100+t.getDate())}static fromDateGMT(t){return L.fromDate(t,!0)}static from(t,r=!1){if(typeof t=="number")return t<100?void 0:new L(t);if(typeof t=="string")return L.fromString(t);if(Array.isArray(t)&&t.length===3){let[n,i=1,s=1]=t;return i<1||i>12||s<1||s>31?void 0:new L(n*1e4+i*100+s)}else{if(t instanceof Date)return L.fromDate(t,r);if(t instanceof L)return t}}toNumber(){return this.days}toJson(){return this.days}toString(t="-"){let r=String(this.days);return r.slice(0,4)+t+r.slice(4,6)+t+r.slice(6,8)}toDate(t=!1){return t?new Date(`${this.toString()}T00:00:00.000Z`):new Date(this.days/1e4,this.days/100%100-1,this.days%100)}toDateGMT(){return this.toDate(!0)}get year(){return Math.floor(this.days/1e4)}get month(){return Math.floor(this.days/100%100)}get day(){return Math.floor(this.days%100)}dayOffset(t){return L.fromDateGMT(new Date(this.toDateGMT().getTime()+t*864e5))}monthStart(){return L.from([this.year,this.month,1])}yearStart(){return L.from([this.year,1,1])}monthOffset(t){let r=this.month+t,n=Math.floor((r-1)%12)+1;n===0&&(n=12);let i=Math.floor((r-1)/12);return L.from([this.year+i,n,this.day])}daysUntil(t){var r;return Math.round((((r=new L(t))==null?void 0:r.toDateGMT().getTime())-this.toDateGMT().getTime())/864e5)}yesterday(){return this.dayOffset(-1)}tomorrow(){return this.dayOffset(1)}};o(L,"Day");async function fi(e,t,r){let n=L.from(e),i=L.from(t);for(;n&&i&&(n==null?void 0:n.days)<=(i==null?void 0:i.days);){let s=r(n);M(s)&&await s,n=n.dayOffset(1)}}o(fi,"forEachDay");function pi(){return new L}o(pi,"today");function di(e){return new L(e)}o(di,"day");function gi(e){return L.fromDate(new Date(e)).days}o(gi,"dateStringToDays");function mr(e,t=2){return+(+e).toFixed(t)}o(mr,"decimal");function yi(e,t=2){return+(+e/Math.pow(10,t)).toFixed(t)}o(yi,"decimalFromCents");function hi(e,t=2){return Math.round(+e*Math.pow(10,t))}o(hi,"decimalToCents");function xi(e,t=2){return t*(mr(e,t)%1)}o(xi,"decimalCentsPart");var mt=o(e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;"),"escapeHTML"),Ti=o(e=>e.replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,'"').replace(/&apos;/gi,"'").replace(/&amp;/gi,"&"),"unescapeHTML");function Ai(e,t){return S(e)?Object.fromEntries(Object.entries(e).map(([r,n])=>{let i=t(r,n);return B(i)&&i.length===2?i:[r,i]}).filter(r=>r!=null)):{}}o(Ai,"objectMap");function vi(e,t){return t.dispose&&e.dispose&&t.dispose.add(e.dispose),Object.assign(e,t)}o(vi,"objectMergeDisposable");var yt=/[\u0000-\u001F\u0080-\u009F]/g,yr=/^\.+/,hr=/\.+$/;function ht(){return/[<>:"/\\|?*\u0000-\u001F]/g}o(ht,"filenameReservedRegex");function xr(){return/^(con|prn|aux|nul|com\d|lpt\d)$/i}o(xr,"windowsReservedNameRegex");function Pi(e,t="_"){if(typeof e!="string")throw new TypeError("Expected a string");if(ht().test(t)&&yt.test(t))throw new Error("Replacement string cannot contain reserved filename characters");return e=e.replace(ht(),t).replace(yt,t).replace(yr,t).replace(hr,""),e=xr().test(e)?e+t:e,e.slice(0,100)}o(Pi,"toValidFilename");var br=/[\\\-\[\]\/{}()*+?.^$|]/g;function Mi(e){return e?e instanceof RegExp?e.source:e.replace(br,"\\$&"):""}o(Mi,"escapeRegExp");var ee=o(e=>Math.abs(e)%1===.5,"isHalf"),xt=o(e=>e%2===0,"isEven"),Ci=o(e=>Math.ceil(e),"roundUp"),Ri=o(e=>Math.floor(e),"roundDown"),Ii=o(e=>Math.round(e),"roundHalfUp"),Si=o(e=>{let t=Math.round(e);return ee(e)&&xt(t)?t-1:t},"roundHalfOdd"),ki=o(e=>ee(e)?Math.sign(e)*Math.ceil(Math.abs(e)):Math.round(e),"roundHalfAwayFromZero"),Oi=o(e=>ee(e)?Math.floor(e):Math.round(e),"roundHalfDown"),Fi=o(e=>{let t=Math.round(e);return ee(e)?xt(t)?t:t-1:t},"roundHalfEven"),$i=o(e=>ee(e)?Math.sign(e)*Math.floor(Math.abs(e)):Math.round(e),"roundHalfTowardsZero");function bt(e){return e.reduce((t,r)=>Math.min(t,r.sort_weight||0),0)-1-R()}o(bt,"startSortWeight");function Tt(e){return e.reduce((t,r)=>Math.max(t,r.sort_weight||0),0)+1+R()}o(Tt,"endSortWeight");function Ni(e,t,r){let n=r.length,i=e<t;if(n<=0||e>=n-1)return Tt(r);if(e<=0)return bt(r);r=Tr([...r]);let s=i?-1:0,u=r[e+s].sort_weight||0,l=(r[e+s+1].sort_weight||0)-u;if(l===0)return i?bt(r):Tt(r);let c=u+l/2,f=l*.01*(R()-.5);return c+f}o(Ni,"moveSortWeight");function Tr(e){return e.sort((t,r)=>(t.sort_weight||0)-(r.sort_weight||0)),e}o(Tr,"sortedItems");var wr=/((?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?)/gim;function zi(e){return e.split(wr).map((t,r)=>{let n=mt(t);return r%2?`<a target="_blank" href="${n}">${Lr(n)}</a>`:n}).join("")}o(zi,"linkifyPlainText");function Lr(e){return e.replace(/^https?:\/\/(www\.)?/,"").replace(/\/$/,"")}o(Lr,"toHumanReadableUrl");function wt(e){let t=[];for(let[r,n]of Object.entries(e))if(n!=null){Array.isArray(n)||(n=[n]);for(let i of n)i!=null&&t.push(encodeURIComponent(r)+"="+encodeURIComponent(String(i)))}return t.join("&")}o(wt,"encodeQuery");function Gi(e){let t={},r=(e[0]==="?"?e.substr(1):e).split("&");for(let n=0;n<r.length;n++){let i=r[n].split("="),s=decodeURIComponent(i[0]),u=decodeURIComponent(i[1]||"");t[s]!=null?(Array.isArray(t[s])||(t[s]=[t[s]]),t[s].push(u)):t[s]=u}return t}o(Gi,"parseQuery");function _i(e,t,r){let n=e[t];return n===void 0&&(n=r(t,e),e[t]=n),n}o(_i,"ensureKey");async function Ji(e,t,r){let n=e[t];return n===void 0&&(n=await r(t,e),e[t]=n),n}o(Ji,"ensureKeyAsync");function Zi(e){return e!=null?e.size!=null?e.size:e.length!=null?e.length:Object.keys(e).length:0}o(Zi,"size");function Wi(e){return e!=null&&e.length>0?e[e.length-1]:void 0}o(Wi,"last");function Ki(e){try{if(e!=null)return Array.isArray(e)||typeof e=="string"?e.length<=0:(e==null?void 0:e.size)!=null?e.size<=0:Object.keys(e).length<=0}catch(t){console.warn("Failed to check if empty for",e,t)}return!0}o(Ki,"empty");function Ie(e){return Object(e)!==e?e:JSON.parse(JSON.stringify(e))}o(Ie,"cloneObject");function Yi(e){return Object(e)!==e?e:JSON.parse(JSON.stringify(e))}o(Yi,"cloneJsonObject");function Qi(e){let t=new Map;return r=>{if(t.has(r))return t.get(r);let n=e(r);return t.set(r,n),n}}o(Qi,"memoize");function Xi(e){let t=new Map;return async(...r)=>{let n=JSON.stringify(r);if(t.has(n))return t.get(n);let i=await e(...r);return t.set(n,i),i}}o(Xi,"memoizeAsync");function es(e,t){let r=[];for(let n=0;n<e;n++)r.push(t(n,e));return r}o(es,"forTimes");var Ar=/\\\s|\s+|#[^\n]*\n?/gm,vr=/\(\?P?<(\w[\w\d_]+)>|\((?!\?(:|\!|=|<=|<\!))/gm,Lt=/^((?:\(\?[\w$]+\))?)\(\?<([=!])([\s\S]*?)\)/gm,Dr=A("zeed:xrx");function Pr(e){return typeof e=="string"?e:e.source||""}o(Pr,"regExpString");function ns(e){return e.replace(/[-\[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}o(ns,"regExpEscape");var Se=class{constructor(t,r){this.namedGroups={};this.names=[];let n=r??"",i;if(t instanceof RegExp?(r==null&&(n=t.flags),i=t.source):i=t,n&&n.indexOf("x")!==-1&&(n=n.replace("x",""),i=i.replace(Ar,a=>a[0]==="\\"?a:"")),!(t instanceof RegExp)){let a=0;i=i.replace(vr,(l,c)=>(a+=1,c?(c!=="index"&&c!=="length"&&!this.namedGroups[c]?this.namedGroups[c]=a:Dr.error(`Unallowed or duplicate group name: ${c}`),"("):l)),this.names=Object.keys(this.namedGroups)}i=Pr(i),Lt.lastIndex=0;let u=Lt.exec(i);u&&(this.lookBehind={rx:new RegExp(`${u[3]}$(?!\\s)`),expect:u?u[2]==="=":!u},i=i.substr(u[0].length)),this.rx=new RegExp(i,n)}get lastIndex(){return this.rx.lastIndex}set lastIndex(t){this.rx.lastIndex=t}_handleMatch(t){if(this.lookBehind){let r=t.input.slice(0,t.index);if(this.lookBehind.expect!==this.lookBehind.rx.test(r))return null}for(let r of this.names)t[r]=t[this.namedGroups[r]];return t}exec(t){let r;for(;r=this.rx.exec(t);)if(this.rx.lastIndex===r.index&&this.rx.lastIndex++,r=this._handleMatch(r),r!=null)return r}execAll(t){let r=[],n;for(this.rx.lastIndex=0;n=this.exec(t);)r.push(n);return this.rx.lastIndex=0,r}replace(t,r){let n=typeof r=="function"?r:()=>r;return t.replace(this.rx,i=>n(i))}};o(Se,"XRX");var Er=A("zeed:dispose");async function Mr(e){typeof e=="function"?await j(e()):M(e)?await e:typeof e.dispose=="function"?await j(e.dispose()):M(e.dispose)?await e.dispose:typeof e.cleanup=="function"?await j(e.cleanup()):M(e.cleanup)&&await e.cleanup}o(Mr,"callDisposer");function ke(e){let{name:t}=typeof e=="string"?{name:e}:e??{},r=[],n=o(async u=>{u!=null&&r.includes(u)&&(ve(r,a=>a!==u),await Mr(u))},"untrack"),i=o(async()=>{for(t&&Er.debug(`dispose ${t}: ${r.length} entries`);r.length>0;)await n(r[0])},"dispose"),s=o(u=>{if(u!=null)return r.unshift(u),()=>n(u)},"track");return Object.assign(i,{track:s,add:s,untrack:n,dispose:i,exec:i,getSize(){return r.length}})}o(ke,"useDispose");var us=ke;function ls(e={}){let{mode:t="fifo"}=e,r=[],n=o(async(s=!1)=>{for(;r.length>0;){let u=r[0];if(ve(r,a=>a!==u),typeof u=="function"){let a=u();if(M(a)){if(s)throw new Error(`Expected sync only function, but found async: ${u}`);await a}}else if(M(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(n,{add:o(s=>{t==="lifo"?r.unshift(s):r.push(s)},"add"),exec:n,getSize(){return r.length}})}o(ls,"useDefer");function cs(e,t=0){let r=setTimeout(e,t);return()=>{r&&(clearTimeout(r),r=void 0)}}o(cs,"useTimeout");function fs(e,t){let r=setInterval(e,t);return()=>{r&&(clearInterval(r),r=void 0)}}o(fs,"useInterval");function ps(e,t,r,...n){return e==null?()=>{}:(e.on?e.on(t,r,...n):e.addEventListener&&e.addEventListener(t,r,...n),()=>{e.off?e.off(t,r,...n):e.removeEventListener&&e.removeEventListener(t,r,...n)})}o(ps,"useEventListener");function ms(){let e=!0;return(t,r)=>{let n=!1;if(e){e=!1;try{t(),n=!0}finally{e=!0}}else r!==void 0&&r();return n}}o(ms,"useMutex");function ys(){let e=!0;return async(t,r)=>{let n=!1;if(e){e=!1;try{let i=t();M(i)&&await i,n=!0}finally{e=!0}}else if(r!==void 0){let i=r();M(i)&&await i}return n}}o(ys,"useAsyncMutex");var Z=A("zeed:emitter"),U=class{constructor(){this.subscribers={};this.subscribersOnAny=[];this.dispose=ke();this.call=new Proxy({},{get:(t,r)=>(...n)=>this.emit(r,...n)})}async emit(t,...r){let n=!1;this.dispose.add(()=>{this.subscribers={},this.subscribersOnAny=[]});try{let i=this.subscribers[t]||[];if(this.subscribersOnAny.forEach(s=>s(t,...r)),i.length>0){let s=i.map(u=>{try{return j(u(...r))}catch(a){Z.warn("emit warning:",a)}});n=!0,await Promise.all(s)}}catch(i){Z.error("emit exception",i)}return n}onAny(t){this.subscribersOnAny.push(t)}on(t,r){let n=this.subscribers[t]||[];return n.push(r),this.subscribers[t]=n,()=>{this.off(t,r)}}onCall(t){for(let[r,n]of Object.entries(t))this.on(r,n)}once(t,r){let n=o(async(...i)=>(this.off(t,n),await j(r(...i))),"onceListener");return this.on(t,n),()=>{this.off(t,r)}}off(t,r){return this.subscribers[t]=(this.subscribers[t]||[]).filter(n=>r&&n!==r),this}removeAllListeners(){return this.subscribers={},this}};o(U,"Emitter");function Ds(){let e=Q().emitter;return e||(e=new U,Q().emitter=e),e}o(Ds,"getGlobalEmitter");var Ps=new U;function Es(e,t){let r=Math.round(R()*100);var n=[],i;let s=o((a,l)=>{let c={key:a,obj:l};n.push(c),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(r,"Cannot listen to key"):e.onAny?e.onAny((a,l)=>{s(a,l)}):Z.error(r,"cannot listen to all for",e),o((a,l=!0)=>new Promise((c,f)=>{a||(a=t,a||n.length&&(a=n[0].key)),i=o(()=>{for(;n.length>0;){let g=n.shift();if(g.key===a)i=void 0,c(g.obj);else{if(l){Z.warn(r,`Unhandled event ${a} with value: ${g.obj}`);continue}f(`Expected ${a}, but found ${g.key} with value=${g.obj}`),Z.error(r,`Unhandled event ${a} with value: ${g.obj}`)}break}},"lazyResolve"),i()}),"on")}o(Es,"lazyListener");var At=o(()=>Date.now(),"getTimestamp");function Us(e){return e>999?(e/1e3).toFixed(1)+"s":e.toFixed(2)+"ms"}o(Us,"formatMilliseconds");function Cs(...e){for(let t of e){if(t instanceof Date)return t;if(typeof t=="string"){let r=null;if(t.includes(":"))try{r=new Date(t)}catch{}if(!(r instanceof Date)){let n=/(\d\d\d\d)-(\d\d)-(\d\d)/.exec(t);n&&(r=new Date(+n[1],+n[2]-1,+n[3],12,0))}if(r instanceof Date)return r}}}o(Cs,"parseDate");var{encode:Fe,decode:vt}=O(62),{encode:Dt,decode:Ur}=O(32);function Pt(){return J(16)}o(Pt,"uuidBytes");var sa=o(()=>new Uint32Array(J(4))[0],"uuid32bit");function V(){return Fe(Pt(),22)}o(V,"uuid");function aa(e){return Fe(e,22)}o(aa,"uuidEncode");function ua(e){let t=Je(e);return 1e7-1e3-4e3-8e3-1e11,`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16)}`}o(ua,"uuidEncodeV4");function la(e){return vt(e,16)}o(la,"uuidDecode");function ca(e){return Ze(e.replaceAll("-",""))}o(ca,"uuidDecodeV4");function fa(){return Dt(Pt(),26)}o(fa,"uuidB32");function pa(e){return Dt(e,26)}o(pa,"uuid32Encode");function da(e){return Ur(e,16)}o(da,"uuid32Decode");var Oe={};function z(e="id"){return Oe[e]==null&&(Oe[e]=0),`${e}-${Oe[e]++}`}o(z,"uname");var Cr=0;function ga(){return`id-${Cr++}`}o(ga,"qid");var Rr="10000000-1000-4000-8000-100000000000",ma=typeof crypto<"u"&&crypto.randomUUID!=null?crypto.randomUUID.bind(crypto):()=>Rr.replace(/[018]/g,e=>(e^J(1)[0]&15>>e/4).toString(16)),Et=16e11;function Ir(e){var t=new Uint8Array([0,0,0,0,0,0]);let r=t.length-1;for(var n=0;n<t.length;n++){var i=e&255;t[r-n]=i,e=(e-i)/256}return t}o(Ir,"longToByteArray");function Sr(){let e=At()-Et;return new Uint8Array([...Ir(e),...J(10)])}o(Sr,"suidBytes");function ya(){return Fe(Sr(),22)}o(ya,"suid");function ha(e){return kr(vt(e,16))}o(ha,"suidDate");function kr(e){return new Date(Et+e.slice(0,6).reduce((t,r)=>t*256+r,0))}o(kr,"suidBytesDate");var Or=(n=>(n[n.waiting=0]="waiting",n[n.running=1]="running",n[n.finished=2]="finished",n))(Or||{}),Fr=(n=>(n[n.replace=0]="replace",n[n.memoize=1]="memoize",n[n.error=2]="error",n))(Fr||{});function La(e={}){let{maxParallel:t=3}=e,r=new U,n=0,i=0,s=0,u=0,a={};async function l(){if(n>0){let[m,d]=ft();return r.once("didFinish",d),m}}o(l,"waitFinishAll");function c(){r.emit("didFinish"),n=0,i=0}o(c,"didFinish");function f(){let m=0,d=0;for(let{max:h,resolved:b,state:x}of Object.values(a))m+=h,d+=x===2?h:Math.min(h,b);r.emit("didUpdate",n,i,m,d)}o(f,"didUpdate");function g(){if(f(),n>0&&n===i&&c(),s>=t)return;let m=Object.values(a).filter(d=>d.state===0);if(m.length>0){let d;for(let h of m)h.group!=null&&Object.values(a).some(b=>b.state===1&&b.id!==h.id&&b.group===h.group)||(d==null||h.priority<d.priority)&&(d=h);if(d!=null){let h=d.id,b=d.done;d.state=1,++s,r.emit("didStart",h);let x=o(w=>{d&&(d.result=w,d.state=2,d.resolved=d.max),--s,++i,g()},"taskFinished");d.task(d).then(w=>{b(w),r.emit("didResolve",h,w),x(w)}).catch(w=>{b(),r.emit("didReject",h,w),x()})}}}o(g,"performNext");function p(m){let d=a[m];d&&d.state===0&&(a[m].state=2,++i,r.emit("didCancel",m),f())}o(p,"cancel");function y(){Object.keys(a).forEach(p)}o(y,"cancelAll");function T(m,d={}){let h,b=new Promise(w=>h=w),x=d.id??V();if(a[x]!=null){let w=d.idConflictResolution??1;if(w===0)p(x);else if(w===1){let D=a[x];return{id:x,promise:(async()=>{if(D.state===2)return a[x].result})(),dispose:()=>p(x),cancel:()=>p(x)}}else throw new Error(`Pool task with id=${x} already exists!`)}return a[x]={id:x,task:m,priority:++u,group:d.group,state:0,max:d.max??1,resolved:d.resolved??0,done:h,payload:d.payload,setMax(w){a[x].max=w,f()},setResolved(w){a[x].resolved=w,f()},incResolved(w=1){a[x].resolved+=w,f()}},++n,g(),{id:x,promise:b,dispose:()=>p(x),cancel:()=>p(x)}}return o(T,"enqueue"),{events:r,cancel:p,cancelAll:y,enqueue:T,dispose:y,waitFinishAll:l}}o(La,"usePool");var $e=class extends U{constructor(r={}){super();this.queue=[];this.waitToFinish=[];this.countMax=0;this.countResolved=0;this.paused=!1;let{name:n=z("queue"),logLevel:i}=r;this.name=n,this.log=A(`zeed:queue:${n}`,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 r=this.queue.shift();if(this.log(`performNext => ${r==null?void 0:r.name}`),r==null)break;this.countResolved===0&&this.emit("didStart",this.countMax);let{name:n,task:i,resolve:s}=r;this.currentTask=i();let u;try{this.log.info(`start task ${n}`),u=await this.currentTask,this.log(`finished task ${n} 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(r,n={}){let{immediate:i=!1,name:s=z(this.name)}=n;return i?(this.log.info(`immediate execution ${s}`),await r()):(this.log(`enqueue ${s}`),new Promise(u=>{this.queue.push({name:s,task:r,resolve:u}),this.countMax+=1,this.emit("didUpdate",this.countMax,this.countResolved),this.performNext()}))}async enqueueReentrant(r,n={}){return this.enqueue(r,{immediate:this.currentTask!=null,name:n.name})}async cancelAll(r=!0){this.log("cancelAll"),this.emit("didCancel");let n=this.queue.map(i=>i.resolve);this.queue=[],n.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(r=>{this.waitToFinish.push(r)})}get isPaused(){return this.paused}get hasTasks(){return this.queue.length!==0}};o($e,"SerialQueue");var K=!1,W=K?A("zeed:throttle"):()=>{};function Ra(e,t={}){let{delay:r=100,trailing:n=!0,leading:i=!0}=t,s=0,u=0,a=0,l,c=Date.now();function f(){s&&(clearTimeout(s),s=void 0)}o(f,"clearExistingTimeout");function g(...p){let y=Date.now(),T=this,m=y-u;function d(){let b=Date.now();return`total ${(b-c).toFixed(1)}ms - elapsed ${(b-u).toFixed(1)}ms - visited ${a}x`}o(d,"debugElapsed");function h(){a=0,u=Date.now(),e.apply(T,p)}if(o(h,"exec"),l=h,m>r||!s){K&&W("elapsed",d()),i&&(m>r?(K&&W("\u{1F680} leading",d()),h()):++a);let b=m>r?r:r-m;W(`\u23F1 start timeout with ${b.toFixed(1)}ms`,d()),f(),u=y,s=setTimeout(()=>{K&&W("\u23F1 reached timeout",d()),s=0,n&&(!i||a>0)&&(K&&W("\u{1F680} trailing",d()),l==null||l())},b)}else++a,K&&W("visited",d())}return o(g,"wrapper"),g.cancel=f,g.dispose=f,g}o(Ra,"throttle");function Ia(e,t={}){let{delay:r=100}=t,n=0;function i(){n&&(clearTimeout(n),n=0)}o(i,"clearExistingTimeout");function s(...u){let a=this;i(),n=setTimeout(()=>{n=0,e.apply(a,u)},r)}return o(s,"wrapper"),s.cancel=i,s.dispose=i,s}o(Ia,"debounce");function ka(e=(t=>(t=globalThis==null?void 0:globalThis.location)==null?void 0:t.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")}o(ka,"isLocalHost");function $a(e){let{level:t=void 0,filter:r=void 0,messages:n=[]}=e,i=_(r),s=ie(t);return u=>{!s(u.level)||!i(u.name)||n.push(u)}}o($a,"LoggerMemoryHandler");var de=class extends U{constructor(){super(...arguments);this.id=V()}close(){this.dispose()}};o(de,"Channel");var te=class extends de{constructor(){super(...arguments);this.isConnected=!0}postMessage(r){var n;(n=this.other)==null||n.emit("message",{data:r,origin:"local",lastEventId:V()})}};o(te,"LocalChannel");function ja(){let e=new te,t=new te;return e.other=t,t.other=e,[e,t]}o(ja,"createLocalChannelPair");var Be=class{async encode(t){return t}async decode(t){return t}};o(Be,"NoopEncoder");var G=class{async encode(t){return xe(t)}async decode(t){return be(t)}};o(G,"JsonEncoder");var He=class{constructor(t){this.key=t}async encode(t){let r=xe(t);return await et(r,this.key)}async decode(t){let r=await tt(t,this.key);return be(r)}};o(He,"CryptoEncoder");var Mt=o((e,t,r={})=>new Proxy(r,{get:(n,i)=>i in n?n[i]:(...s)=>e(i,s,t)}),"createPromiseProxy");function Qa(e={}){let{name:t=z("hub"),encoder:r=new G,retryAfter:n=1e3,ignoreUnhandled:i=!0,logLevel:s=!1}=e,u=A(t,s),a={},l,c=[],f,g={},p=o(()=>{clearTimeout(f)},"dispose"),y=o(async()=>{if(clearTimeout(f),l){if(l.isConnected)for(;c.length;){let h=c[0];try{l.postMessage(await r.encode(h)),c.shift()}catch(b){u.warn("postMessage",b);break}}c.length>0&&n>0&&(f=setTimeout(y,n))}},"postNext"),T=o(async h=>{u("enqueue postMessage",h),c.push(h),await y()},"postMessage"),m=o(async h=>{l=h,l.on("connect",y),l.on("message",async b=>{u("onmessage",typeof b);let{name:x,args:w,id:D,result:q,error:F}=await r.decode(b.data);if(x){u(`name ${x} id ${D}`);try{if(a[x]==null)throw new Error(`handler for ${x} was not found`);let C=a[x](...w);M(C)&&(C=await C),u(`result ${C}`),D&&T({id:D,result:C})}catch(C){let $=C instanceof Error?C:new Error(Pe(C));u.warn("execution error",$.name),T({id:D,error:{message:$.message,stack:$.stack,name:$.name}})}}else if(D)if(u(`response for id=${D}: result=${q}, error=${F}`),g[D]==null)q===void 0?u(`skip response for ${D}`):u.warn(`no response hook for ${D}`);else{let[C,$]=g[D];if(C&&$)if(delete g[D],F){let re=new Error(F.message);re.stack=F.stack,re.name=F.name,u.warn("reject",re.name),$(re)}else u("resolve",q),C(q)}else i||u.warn("Unhandled message",b)}),y()},"connect"),d=o(async(h,b,x={})=>{let{timeout:w=5e3}=x,D=V();return T({name:h,args:b,id:D}),gt(new Promise((q,F)=>g[D]=[q,F]),w)},"fetchMessage");return e.channel&&m(e.channel),{dispose:p,connect:m,listen(h){Object.assign(a,h)},send(){return Mt(d,{},{options(h){return Mt(d,{...h})}})}}}o(Qa,"useMessageHub");var ge=class extends U{constructor(r){super();this.publish=this.emit;this.subscribe=this.on;let{name:n,encoder:i=new G,channel:s,debug:u=!1}=r;this.channel=s,this.encoder=i,this.debug=u,this.name=n??this.channel.id??z("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 l=await this.encoder.decode(a);if(this.debug?this.log(`channel message, event=${l==null?void 0:l.event}, info=`,l):this.log(`channel message, event=${l==null?void 0:l.event}`),l){let{event:c,args:f}=l;await this.emitSuper(c,...f)}})}get shortId(){return this.name.substr(0,6)}async emitSuper(r,...n){return await super.emit(r,...n)}async emit(r,...n){try{if(this.debug?this.log(`emit(${String(r)})`,r):this.log(`emit(${String(r)})`,n.length),!this.channel.isConnected)return this.log.warn("channel not connected"),!1;let i=await this.encoder.encode({event:r,args:n});return this.channel.postMessage(i),!0}catch(i){this.log.warn(`emit(${String(r)})`,i)}return!1}};o(ge,"PubSub");function au(e){return new ge(e)}o(au,"usePubSub");var $r=1;var Ut=o(e=>e,"defaultSerialize"),Br=Ut;function lu(e,t){let{post:r,on:n,eventNames:i=[],serialize:s=Ut,deserialize:u=Br}=t,a=new Map;return n(async l=>{let c=u(l),[f,g,p,y]=c;if(f===1||f===2){let T,m;if(y!=null)try{T=await e[y](...g)}catch(d){m=String(d)}else m="Method implementation missing";f===1&&p&&r(s(m?[4,m,p]:[3,T,p]))}else if(p){let T=a.get(p);T!=null&&(f===4?T.reject(g):T.resolve(g)),a.delete(p)}}),new Proxy({},{get(l,c){let f=o((...p)=>{r(s([2,p,null,c]))},"sendEvent");if(t.onlyEvents||i.includes(c))return f.asEvent=f,f;let g=o((...p)=>new Promise((y,T)=>{let m=$r++;a.set(m,{resolve:y,reject:T}),r(s([1,p,m,c]))}),"sendCall");return g.asEvent=f,g}})}o(lu,"useRPC");var Y=A("zeed:network"),Ne={cache:"no-cache",redirect:"follow",headers:{}};function Hr(e){let t=/:\/\/([^@]*)@/gi.exec(e);if(t&&t[1]){let[r,n]=t[1].split(":",2);return{url:e.replace(t[1]+"@",""),username:r,password:n}}}o(Hr,"parseBasicAuth");async function Ct(e,t={},r=fetch){try{B(t)&&(t=oe({},...k(t)));let n=Hr(String(e));n&&(e=n.url,t=oe({},t,Nr(n.username,n.password))),t.headers!=null&&!(t.headers instanceof Headers)&&(t.headers=new Headers(t.headers));let i=await r(String(e),t);if(i.status<400)return i;try{Y.warn(`Fetch of ${e} with ${t} returned status=${i.status}`),Y.warn(`Response: ${await i.text()}`)}catch(s){Y.error("Exception:",s)}}catch(n){Y.error("fetchBasic",n)}}o(Ct,"fetchBasic");async function gu(e,t={},r=fetch){try{let n=await Ct(e,[{method:"GET",headers:{Accept:"application/json"}},t],r);if(n)return await n.json()}catch(n){Y.error("fetchJSON error:",n)}}o(gu,"fetchJson");async function mu(e,t={},r=fetch){try{let n=await Ct(e,[Ne,{method:"GET"},t],r);if(n)return await n.text()}catch(n){Y.error("fetchHTML error:",n)}}o(mu,"fetchText");function yu(e,t="POST"){return{method:t,...Ne,headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:wt(e)}}o(yu,"fetchOptionsFormURLEncoded");function hu(e,t="POST"){return{method:t,...Ne,headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(e)}}o(hu,"fetchOptionsJson");function Nr(e,t){return{headers:{Authorization:"Basic "+We(e+":"+t)}}}o(Nr,"fetchOptionsBasicAuth");function Rt(){if(typeof window<"u")return window}o(Rt,"getWindow");function jr(){if(typeof navigator<"u")return navigator}o(jr,"getNavigator");function bu(){return Rt()??typeof WorkerGlobalScope<"u"?self:typeof global<"u"?global:Function("return this;")()}o(bu,"getGlobal");var v=jr(),P=Rt();function Vr(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}){var t,r,n,i,s,u,a,l,c;return e.ios=((t=v==null?void 0:v.platform)==null?void 0:t.match(/(iPhone|iPod|iPad)/i))!=null,e.macos=!!((r=v==null?void 0:v.platform)!=null&&r.startsWith("Mac")),e.windows=!!((n=v==null?void 0:v.platform)!=null&&n.startsWith("Win")),e.beaker=(P==null?void 0:P.beaker)!=null,e.electron=(((s=(i=v==null?void 0:v.userAgent)==null?void 0:i.toLowerCase())==null?void 0:s.indexOf(" electron/"))||-1)>-1&&!e.beaker,e.wkwebview=((u=P==null?void 0:P.webkit)==null?void 0:u.messageHandlers)!=null,e.pwa=(v==null?void 0:v.serviceWorker)!=null,e.pwaInstalled=(v==null?void 0:v.standalone)||((l=(a=P==null?void 0:P.matchMedia)==null?void 0:a.call(P,"(display-mode: standalone)"))==null?void 0:l.matches),e.node=typeof process<"u"&&((c=process==null?void 0:process.release)==null?void 0:c.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=P&&"ontouchstart"in P||((v==null?void 0:v.maxTouchPoints)||0)>1||(v==null?void 0:v.msPointerEnabled)&&(P==null?void 0:P.MSGesture)||(P==null?void 0:P.DocumentTouch)&&document instanceof DocumentTouch,e}o(Vr,"detect");var zr=o(()=>typeof window<"u"&&globalThis===window,"isBrowser"),Tu=Vr();function wu(e){zr()?window.addEventListener("beforeunload",e):typeof process<"u"&&process.on("exit",()=>e)}o(wu,"useExitHandler");var Du=A("zeed:memstorage"),je=class{constructor(t={}){this.store={}}setItem(t,r){this.store[t]=Ie(r)}getItem(t){if(this.store.hasOwnProperty(t))return Ie(this.store[t])}removeItem(t){delete this.store[t]}clear(){this.store={}}allKeys(){return Object.keys(this.store)}};o(je,"MemStorage");export{o as a,Q as b,S as c,me as d,B as e,Ve as f,_r as g,Jr as h,Zr as i,Wr as j,Kr as k,Yr as l,Qr as m,ne as n,kt as o,oe as p,Ot as q,_ as r,ye as s,ie as t,se as u,ae as v,ze as w,Ge as x,Bt as y,A as z,Ht as A,Nt as B,_e as C,jt as D,E,Ln as F,Je as G,Ze as H,We as I,An as J,vn as K,Ke as L,xe as M,be as N,Ye as O,J as P,Mn as Q,Un as R,et as S,tt as T,Rn as U,Gt as V,R as W,Sn as X,kn as Y,On as Z,Fn as _,qt as $,$n as aa,Bn as ba,Hn as ca,Nn as da,_t as ea,Vn as fa,Le as ga,zn as ha,Ae as ia,Jt as ja,Zt as ka,k as la,Wt as ma,Jn as na,Zn as oa,Wn as pa,ve as qa,Kn as ra,Yn as sa,Kt as ta,Qn as ua,Yt as va,nt as wa,Xn as xa,eo as ya,to as za,ro as Aa,no as Ba,oo as Ca,io as Da,so as Ea,ao as Fa,O as Ga,po as Ha,go as Ia,mo as Ja,yo as Ka,ho as La,xo as Ma,bo as Na,To as Oa,wo as Pa,Lo as Qa,vo as Ra,er as Sa,Do as Ta,Po as Ua,Mo as Va,rr as Wa,De as Xa,Io as Ya,So as Za,ko as _a,nr as $a,or as ab,ir as bb,Pe as cb,Oo as db,Fo as eb,$o as fb,Bo as gb,sr as hb,Ho as ib,No as jb,N as kb,I as lb,Ue as mb,Ce as nb,at as ob,pr as pb,Go as qb,ut as rb,qo as sb,_o as tb,Jo as ub,pe as vb,Zo as wb,Me as xb,dr as yb,gr as zb,Re as Ab,lt as Bb,Wo as Cb,Ko as Db,Yo as Eb,Qo as Fb,ft as Gb,ti as Hb,ri as Ib,pt as Jb,ni as Kb,dt as Lb,oi as Mb,gt as Nb,ii as Ob,M as Pb,j as Qb,L as Rb,fi as Sb,pi as Tb,di as Ub,gi as Vb,mr as Wb,yi as Xb,hi as Yb,xi as Zb,mt as _b,Ti as $b,Ai as ac,vi as bc,Pi as cc,Mi as dc,ee as ec,xt as fc,Ci as gc,Ri as hc,Ii as ic,Si as jc,ki as kc,Oi as lc,Fi as mc,$i as nc,bt as oc,Tt as pc,Ni as qc,Tr as rc,zi as sc,Lr as tc,wt as uc,Gi as vc,_i as wc,Ji as xc,Zi as yc,Wi as zc,Ki as Ac,Ie as Bc,Yi as Cc,Qi as Dc,Xi as Ec,es as Fc,Pr as Gc,ns as Hc,Se as Ic,ke as Jc,us as Kc,ls as Lc,cs as Mc,fs as Nc,ps as Oc,ms as Pc,ys as Qc,U as Rc,Ds as Sc,Ps as Tc,Es as Uc,At as Vc,Us as Wc,Cs as Xc,Pt as Yc,sa as Zc,V as _c,aa as $c,ua as ad,la as bd,ca as cd,fa as dd,pa as ed,da as fd,z as gd,ga as hd,ma as id,Sr as jd,ya as kd,ha as ld,kr as md,Or as nd,Fr as od,La as pd,$e as qd,Ra as rd,Ia as sd,ka as td,$a as ud,de as vd,te as wd,ja as xd,Be as yd,G as zd,He as Ad,Mt as Bd,Qa as Cd,ge as Dd,au as Ed,lu as Fd,Hr as Gd,Ct as Hd,gu as Id,mu as Jd,yu as Kd,hu as Ld,Nr as Md,Rt as Nd,jr as Od,bu as Pd,Vr as Qd,zr as Rd,Tu as Sd,wu as Td,je as Ud};
8
+ //# sourceMappingURL=chunk-TLTZX552.js.map