@webqit/fetch-plus 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1,2 +1,2 @@
1
- (()=>{var pt=Object.defineProperty;var Ae=(n,e)=>{for(var t in e)pt(n,t,{get:e[t],enumerable:!0})};var Ze={};Ae(Ze,{FormDataPlus:()=>V,HeadersPlus:()=>T,LiveResponse:()=>Me,Observer:()=>P,RequestPlus:()=>_e,ResponsePlus:()=>N,URLSearchParamsPlus:()=>G,fetchPlus:()=>rt});function b(n){return!Array.isArray(n)&&typeof n=="object"&&n}function te(n){return typeof n}function C(n){return Array.isArray(n)}function me(n){return n===!0||n===!1}function re(n){return typeof n=="function"}function je(n){return n===null||n===""}function z(n){return arguments.length&&(n===void 0||typeof n>"u")}function g(n){return Array.isArray(n)||typeof n=="object"&&n||re(n)}function Te(n){return je(n)||z(n)||n===!1||n===0||g(n)&&!Object.keys(n).length}function B(n){return re(n)||n&&{}.toString.call(n)==="[object function]"}function ne(n){return n instanceof Number||typeof n=="number"}function $(n){return ne(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function U(n){return n instanceof String||typeof n=="string"&&n!==null}function Ie(n){return!U(n)&&!z(n.length)}function D(n,...e){if(!n||!["object","function"].includes(typeof n))throw new Error("Argument #1 must be of type object");let t=n[Symbol.for("wq")];if(t||(t=new ge,Object.defineProperty(n,Symbol.for("wq"),{value:t,enumerable:!1,configurable:!1,writable:!1})),!e.length)return t;let r,s;for(;r=e.shift();)(s=t)&&!(t=t.get(r))&&(t=new ge,s.set(r,t));return t}var ge=class extends Map{};function se(n,e,t=!1){if(e=="")return n;var r=t?n.lastIndexOf(e):n.indexOf(e);return r===-1?"":n.substr(r+e.length)}function ye(n,e,t=!1){if(e=="")return n;var r=t?n.lastIndexOf(e):n.indexOf(e);return r===-1?n:n.substr(0,r)}var G=class extends URLSearchParams{static eval(e,t,r="&"){return t=t||"",(t.startsWith("?")?t.substr(1):t).split(r).filter(s=>s).map(s=>s.split("=").map(o=>o.trim())).forEach(s=>this.set(e,s[0],decodeURIComponent(s[1]))),e}static stringify(e,t="&"){let r=[];return Object.keys(e).forEach(s=>{this.reduceValue(e[s],s,(o,a,f=void 0)=>{if(f)return f;r.push(`${a}=${encodeURIComponent(o)}`)})}),r.join(t)}static get(e,t){return this.reducePath(t,e,(r,s)=>{if(!(!s&&s!==0))return s[r]})}static set(e,t,r){this.reducePath(t,e,function(s,o,a=void 0){let f=r;return a&&(f=a),s===""&&Array.isArray(o)?o.push(f):o[s]=f,f})}static reduceValue(e,t,r){if(g(e)){let s=Object.keys(e),o=r(e,t,s);if(Array.isArray(o))return o.forEach(a=>{this.reduceValue(e[a],t?`${t}[${a}]`:a,r)})}r(e,t)}static reducePath(e,t,r){if(U(e)&&e.endsWith("]")&&g(t)){let[s,...o]=e.split("[");$(s)&&(s=parseInt(s)),o=o.join("[").replace("]","");let a;if(s in t)a=t[s];else{let f=o===""||$(o.split("[")[0])?[]:{};a=r(s,t,f)}return this.reducePath(o,a,r)}return $(e)&&(e=parseInt(e)),r(e,t)}};var V=class n extends FormData{static upgradeInPlace(e){Object.setPrototypeOf(e,n.prototype)}static json(e={},{recursive:t=!0,getIsJsonfiable:r=!1}={}){let s=new n,o=!0;return G.reduceValue(e,"",(a,f,i=void 0)=>{if(i){let u=we(a)==="json";return o=o&&u,u&&i}t&&[!0,!1,null].includes(a)&&(a=new Blob([a+""],{type:"application/json"})),s.append(f,a)}),r?[s,o]:s}async json({recursive:e=!0,getIsJsonfiable:t=!1}={}){let r=!0,s;for(let[o,a]of this.entries()){s||(s=$(ye(o,"["))?[]:{});let f=we(a);if(e&&["Blob","File"].includes(f)&&a.type==="application/json"){let i=await a.text();a=JSON.parse(i),f="json"}r=r&&f==="json",G.set(s,o,a)}return t?[s,r]:s}};var J=(n,...e)=>D(n,"fetch+",...e),A=n=>D(n,"fetch+","meta");function be(n){return class extends n{static from(e){let t=e.headers instanceof Headers?[...e.headers.entries()].reduce((o,[a,f])=>{let i=a.toLowerCase();return o[i]=o[i]?[].concat(o[i],f):f,o},{}):Object.keys(e.headers||{}).reduce((o,a)=>(o[a.toLowerCase()]=e.headers[a],o),{}),r=e.body,s=we(r);if(["Blob","File"].includes(s))t["content-type"]??=r.type,t["content-length"]??=r.size;else if(["Uint8Array","Uint16Array","Uint32Array","ArrayBuffer"].includes(s))t["content-length"]??=r.byteLength;else if(s==="json"&&g(r)){let[o,a]=V.json(r,{recursive:!0,getIsJsonfiable:!0});a?(r=JSON.stringify(r,(f,i)=>i instanceof Error?{...i,message:i.message}:i),t["content-type"]="application/json",t["content-length"]=new Blob([r]).size):(r=o,s="FormData")}else s==="json"&&!t["content-length"]&&(t["content-length"]=(r+"").length);return{body:r,headers:t,$type:s}}async parse({to:e=null,memoize:t=!1}={}){let r=A(this,"cache"),s=["text","arrayBuffer","blob","bytes"].includes(e),o=(this.headers.get("Content-Type")||"").split(";")[0].trim(),a,f=()=>{throw new Error(`Can't convert response of type ${o} to: ${e}`)};if(!s&&["multipart/form-data","application/x-www-form-urlencoded"].includes(o)){if(e&&!["formData","json"].includes(e)&&f(),t&&r.has(e||"formData"))return r.get(e||"formData");let i=await this.formData();i&&(i=V.upgradeInPlace(i),t&&r.set("formData",i),e==="json"&&(i=await i.json({recursive:!0}),t&&r.set("json",{...i}))),a=i}else if(!s&&o==="application/json"){if(e&&!["json","formData"].includes(e)&&f(),t&&r.has(e||"json"))return r.get(e||"json");let i=await this.json();i&&(t&&r.set("json",{...i}),e==="formData"&&(i=V.json(i,{recursive:!0}),t&&r.set("formData",i))),a=i}else{if(e&&!s&&f(),t){let i=r.get(e||"text")||r.get("original");if(i)return i}a=await this[e||"text"](),t&&r.set(e||"text",a)}return a}}}function we(n){if(n instanceof FormData)return"FormData";if(n===null||ne(n)||me(n))return"json";if(U(n)||g(n)&&"toString"in n)return"text";if(!g(n))return null;let e=n[Symbol.toStringTag],t=["Uint8Array","Uint16Array","Uint32Array","ArrayBuffer","Blob","File","FormData","Stream","ReadableStream"].reduce((r,s)=>r||(e===s?s:null),null);return t||(b(n)||Array.isArray(n)?"json":null)}function _t(n){return n!==null&&typeof n=="object"&&typeof n.read=="function"&&typeof n.pipe=="function"&&typeof n.on=="function"}function Ce(n){return n instanceof ReadableStream||_t(n)}function L(n,e=!0){return C(n)?n:!e&&b(n)?[n]:n!==!1&&n!==0&&Te(n)?[]:Ie(n)?Array.prototype.slice.call(n):b(n)?Object.values(n):[n]}var T=class n extends upgradeMixin(Headers){static upgradeInPlace(e){Object.setPrototypeOf(e,n.prototype)}set(e,t){if(/^Set-Cookie$/i.test(e)&&b(t)&&(t=Re(t)),/Cookie/i.test(e)&&g(t)&&(t=[].concat(t).map(Re).join(";")),/^Content-Range$/i.test(e)&&Array.isArray(t)){if(t.length<2||!t[0].includes("-"))throw new Error("A Content-Range array must be in the format: [ 'start-end', 'total' ]");t=`bytes ${t.join("/")}`}if(/^Range$/i.test(e)){let r=[];L(t).forEach((s,o)=>{let a=Array.isArray(s)?s.join("-"):s+"";o===0&&!a.includes("bytes=")&&(a=`bytes=${a}`),r.push(a)}),t=r.join(", ")}return/^Accept$/i.test(e)&&Array.isArray(t)&&(t=t.join(",")),super.set(e,t)}append(e,t){return/^Set-Cookie$/i.test(e)&&b(t)&&(t=Re(t)),super.append(e,t)}get(e,t=!1){let r=super.get(e);if(/^Set-Cookie$/i.test(e)&&t&&(r=this.getSetCookie().map(s=>{let[o,a]=s.split(";"),[f,i]=o.split("=").map(c=>c.trim()),u={name:f,value:i};return a&&a.split(/\;/g).map(c=>c.trim().split("=")).forEach(c=>{u[c[0][0].toLowerCase()+c[0].substring(1).replace("-","")]=c.length===1?!0:c[1]}),u})),/^Cookie$/i.test(e)&&t&&(r=r?.split(";").map(s=>{let[o,a]=s.split("=").map(f=>f.trim());return{name:o,value:a}})||[]),/^Content-Range$/i.test(e)&&r&&t&&(r=se(r,"bytes ").split("/")),/^Range$/i.test(e)&&t&&(r=r?se(r,"bytes=").split(",").map(s=>{let o=s.trim().split("-").map(a=>a?parseInt(a,10):null);return o.render=a=>(o[1]===null&&(o[1]=a-1),o[0]===null&&(o[0]=o[1]?a-o[1]-1:0),o),o.isValid=(a,f)=>!(o[0]>o[1]||o[1]<o[0]||o[0]<a||o[1]>f),o}):[]),/^Accept$/i.test(e)&&r&&t){let s=f=>{let[i,u]=f.trim().split(";").map(c=>c.trim());return[i,parseFloat((u||"q=1").replace("q=",""))]},o=r.split(",").map(f=>s(f)).sort((f,i)=>f[1]>i[1]?-1:1)||[],a=r;r={match(f){if(!f)return 0;let i=c=>c.split("/").map(l=>l.trim()),u=i(f+"");return o.reduce((c,[l,d])=>{if(c)return c;let h=i(l);return[0,1].every(p=>u[p]===h[p]||u[p]==="*"||h[p]==="*")?d:0},0)},toString(){return a}}}return r}};function Re(n){let e=[`${n.name}=${n.value}`];for(let t in n){if(["name","value"].includes(t))continue;let r=t[0].toUpperCase()+t.substring(1);r==="MaxAge"&&(r="Max-Age"),e.push(n[t]===!0?r:`${r}=${n[t]}`)}return e.join("; ")}var N=class n extends be(Response){constructor(e,t={}){super(e,t),T.upgradeInPlace(this.headers)}static upgradeInPlace(e){Object.setPrototypeOf(e,n.prototype),T.upgradeInPlace(e.headers)}static from(e,{memoize:t=!1,...r}={}){if(e instanceof Response)return e;let s,o=e;if(e||e===0){let f;({body:e,headers:f,$type:s}=super.from({body:e,headers:r.headers})),r={...r,headers:f}}let a=new this.constructor(e,r);if(t){let f=A(a,"cache"),i={json:"json",FormData:"formData",text:"text",ArrayBuffer:"arrayBuffer",Blob:"blob",Bytes:"bytes"};f.set(i[s]||"original",e)}return a}get status(){return A(this).get("status")??super.status}clone(){let e=super.clone();n.upgradeInPlace(e);let t=A(this);return J(e).set("meta",new Map(t)),t.has("cache")&&t.set("cache",new Map(t.get("cache"))),e}};async function rt(n,e={}){let t=await fetch(n,e);return N.upgradeInPlace(t),t}var _e=class n extends be(Request){constructor(e,t={}){super(e,t),T.upgradeInPlace(this.headers)}static upgradeInPlace(e){Object.setPrototypeOf(e,n.prototype),T.upgradeInPlace(e.headers)}static from(e,{memoize:t=!1,...r}={}){if(e instanceof Request)return e;let s,o=r.body;if("body"in r){let{body:f,headers:i,$type:u}=super.from(r);r={...r,body:f,headers:i},s=u}let a=new this.constructor(e,r);if(t){let f=A(a,"cache"),i={json:"json",FormData:"formData",text:"text",ArrayBuffer:"arrayBuffer",Blob:"blob",Bytes:"bytes"};f.set(i[s]||"original",o)}return a}static async copy(e,t={}){let s=["method","headers","mode","credentials","cache","redirect","referrer","integrity"].reduce((o,a)=>({...o,[a]:a in t?t[a]:a==="headers"?new Headers(e[a]):e[a]}),{});return["GET","HEAD"].includes(t.method?.toUpperCase()||e.method)||("body"in t?(s.body=t.body,"headers"in t||(s.headers.delete("Content-Type"),s.headers.delete("Content-Length"))):s.body=await e.clone().arrayBuffer()),s.mode==="navigate"&&(s.mode="cors"),{url:e.url,...s}}clone(){let e=super.clone();n.upgradeInPlace(e);let t=A(this);return J(e).set("meta",new Map(t)),t.has("cache")&&t.set("cache",new Map(t.get("cache"))),e}};var j=class extends MessageEvent{#t;get originalTarget(){return this.#t}#s;get eventID(){return this.#s}#n;get data(){return this.#n}#i;get live(){return this.#i}#u;get bubbles(){return this.#u}#c;get forwarded(){return this.#c}#a;get honourDoneMutationFlags(){return this.#a}#e=[];get ports(){return this.#e}constructor(e,{originalTarget:t=null,type:r="message",eventID:s,live:o=!1,honourDoneMutationFlags:a=!1,bubbles:f=!1,forwarded:i=!1,ports:u=[]}={}){if(r&&typeof r!="string")throw new TypeError("Where specified, wqEventOptions.type must be a string");super(r),this.#n=e,this.#t=t,this.#s=s,this.#i=o,this.#u=f,this.#c=i,this.#a=a,this.#e=u;let c=this.#t&&q(this.#t)||{};if(this.#e.forEach(l=>S.upgradeInPlace(l,{autoStart:c.autoStart,postAwaitsOpen:c.postAwaitsOpen})),g(this.#n)&&this.#i){if(typeof s!="string")throw new TypeError("eventID must be a non-empty string");$e.call(t,this.#n,this.#s,{honourDoneMutationFlags:this.#a})}}#o=!1;get immediatePropagationStopped(){return this.#o}stopImmediatePropagation(){this.#o=!0,this.#f=!0,super.stopImmediatePropagation()}#f=!1;get propagationStopped(){return this.#f}stopPropagation(){this.#f=!0,super.stopPropagation()}#r=!1;get defaultPrevented(){return this.#r}preventDefault(){this.#r=!0,super.preventDefault()}respondWith(e,t=[]){for(let r of this.#e)r.postMessage(e,t);return!!this.#e.length}};var Ke={};Ae(Ke,{any:()=>Rt,apply:()=>He,batch:()=>Je,construct:()=>We,defineProperties:()=>Ft,defineProperty:()=>ce,deleteProperties:()=>Bt,deleteProperty:()=>le,get:()=>H,getOwnPropertyDescriptor:()=>ve,getOwnPropertyDescriptors:()=>Lt,getPrototypeOf:()=>Be,has:()=>Pe,intercept:()=>$t,isExtensible:()=>Ne,map:()=>qt,observe:()=>Ge,ownKeys:()=>ke,path:()=>Ct,preventExtensions:()=>Ve,reduce:()=>ze,set:()=>Z,setPrototypeOf:()=>Ue,subtree:()=>Dt});var v=(n,...e)=>D(n,"observerAPI",...e),oe=(n,e)=>n instanceof Promise?n.then(e):e(n),xe={};var K=class{constructor(e,t){this.registry=e,Object.assign(this,{...t,target:e.target}),this.params.signal&&this.params.signal.addEventListener("abort",()=>this.remove())}remove(){return this.removed=!0,this.registry.removeRegistration(this)}};var ae=class extends K{constructor(){super(...arguments),this.emit.currentRegistration=this,Object.defineProperty(this,"abortController",{value:new AbortController}),Object.defineProperty(this,"signal",{value:this.abortController.signal}),xe.setMaxListeners?.(0,this.signal)}remove(){this.abortController.abort(),super.remove()}fire(e){if(this.emit.recursionTarget&&!["inject","force-async","force-sync"].includes(this.params.recursions))return;let t=e,r=this.filter;if(r!==1/0&&(r=L(r,!1))&&(t=e.filter(o=>r.includes(o.key))),this.params.diff&&(t=t.filter(o=>o.type!=="set"||o.value!==o.oldValue)),!t.length)return;if(["inject","defer"].includes(this.params.recursions)){if(this.emit.recursionTarget){this.emit.recursionTarget.push(...t);return}this.emit.recursionTarget=this.params.recursions==="inject"?t:[]}let s=this.filter===1/0||Array.isArray(this.filter)?this.emit(t,this):this.emit(t[0],this);return oe(s,o=>{let a=this.emit.recursionTarget;return delete this.emit.recursionTarget,this.params.recursions==="defer"&&a?.length?this.emit.currentRegistration.fire(a):o})}};var Q=class{constructor(e){this.target=e,this.entries=[]}addRegistration(e){return this.entries.push(e),e}removeRegistration(e){this.entries=this.entries.filter(t=>t!==e)}static _getInstance(e,t,r=!0,s=this.__namespace){if(!g(t))throw new Error(`Subject must be of type object; "${te(t)}" given!`);let o=this;return s&&v(globalThis,"observerAPI","namespaces").has(e+"-"+s)&&(o=v(globalThis,"observerAPI","namespaces").get(e+"-"+s),e+="-"+s),!v(t,"registry").has(e)&&r&&v(t,"registry").set(e,new o(t)),v(t,"registry").get(e)}static _namespace(e,t,r=null){if(e+="-"+t,arguments.length===2)return v(globalThis,"observerAPI","namespaces").get(e);if(!(r.prototype instanceof this))throw new Error(`The implementation of the namespace ${this.name}.${t} must be a subclass of ${this.name}.`);v(globalThis,"observerAPI","namespaces").set(e,r),r.__namespace=t}};var E=class{constructor(e,t){if(this.target=e,!t.operation)throw new Error("Descriptor operation must be given in definition!");Object.assign(this,t)}};var k=class extends Q{static getInstance(e,t=!0,r=null){return super._getInstance("listeners",...arguments)}static namespace(e,t=null){return super._namespace("listeners",...arguments)}constructor(e){super(e),this.batches=[]}addRegistration(e,t,r){return super.addRegistration(new ae(this,{filter:e,emit:t,params:r}))}emit(e,{eventsArePropertyDescriptors:t=!1,eventIsArrayMethodDescriptor:r=!1}={}){if(this.batches.length){let s=this.batches[0].params.arrayMethodName;this.batches[0].snapshots.push({events:[...e],arrayMethodName:s,eventsArePropertyDescriptors:t,eventIsArrayMethodDescriptor:r});return}this.$emit(this.entries,[{events:e,eventsArePropertyDescriptors:t,eventIsArrayMethodDescriptor:r}])}$emit(e,t){let r=0,s=0,o=0;for(let c of e)r+=1,c.params.withPropertyDescriptors&&(s+=1),c.params.withArrayMethodDescriptors&&(o+=1);let a=[],f=[],i=[],u=[];for(let c of t){let l=c.arrayMethodName,d=c.eventsArePropertyDescriptors,h=c.eventIsArrayMethodDescriptor;for(let p of c.events)if(l&&(p.operation=l),s&&(o&&a.push(p),h||o!==r&&f.push(p)),s!==r){let m=p;if(d){let{target:w,type:x,..._}=p;m=new E(w,{type:"set",..._}),Object.defineProperty(m,"value","get"in _.value?{get:()=>_.value.get()}:{value:_.value.value}),_.oldValue&&Object.defineProperty(m,"oldValue","get"in _.oldValue?{get:()=>_.oldValue.get()}:{value:_.oldValue.value})}o&&i.push(m),h||o!==r&&u.push(m)}}for(let c of e)c.params.withPropertyDescriptors?c.params.withArrayMethodDescriptors?a.length&&c.fire(a):f.length&&c.fire(f):c.params.withArrayMethodDescriptors?i.length&&c.fire(i):u.length&&c.fire(u)}batch(e,t={}){this.batches.unshift({entries:[...this.entries],snapshots:[],params:t});let r=e();return oe(r,s=>{let o=this.batches.shift();return o.snapshots.length&&this.$emit(o.entries,o.snapshots),s})}};var fe=class extends K{exec(e,t,r){return this.running||!this.traps[e.operation]?t(...Array.prototype.slice.call(arguments,2)):(this.running=!0,this.traps[e.operation](e,r,(...s)=>(this.running=!1,t(...s))))}};var W=class extends Q{static getInstance(e,t=!0,r=null){return super._getInstance("traps",...arguments)}static namespace(e,t=null){return super._namespace("traps",...arguments)}addRegistration(e){return super.addRegistration(new fe(this,e))}emit(e,t=null){let r=this;return function s(o,...a){let f=r.entries[o];return f?f.exec(e,(...i)=>s(o+1,...i),...a):t?t(e,...a):a[0]}(0)}};var Fe={};Ae(Fe,{accessorize:()=>Tt,proxy:()=>Le,unaccessorize:()=>It,unproxy:()=>ue});var nt=Symbol("wqOriginal");function Tt(n,e,t={}){n=qe(n);let r=v(n,"accessorizedProps");function s(i){let u,c=n;do u=Object.getOwnPropertyDescriptor(c,i);while(!u&&(c=Object.getPrototypeOf(c)));return u?{proto:c,descriptor:u}:{descriptor:{value:void 0,configurable:!0,enumerable:!0,writable:!0}}}function o(i){if(r.has(i+""))return!0;let u=s(i);u.getValue=function(d=!1){return d?this.descriptor:this.descriptor.get?this.descriptor.get():this.descriptor.value},u.setValue=function(d,h=!1){if(this.dirty=!0,h){this.descriptor=d;return}return this.descriptor.set?this.descriptor.set(d)!==!1:(this.descriptor.value=d,!0)},u.intact=function(){let d=Object.getOwnPropertyDescriptor(n,i);return d?.get===l.get&&d?.set===l.set&&r.get(i+"")===this},u.restore=function(){return this.intact()?(this.proto&&this.proto!==n||!this.proto&&!this.dirty?delete n[i]:Object.defineProperty(n,i,this.descriptor),r.delete(i+""),!0):!1},r.set(isNaN(i)?i:parseInt(i),u);let{enumerable:c=!0}=u.descriptor,l={enumerable:c,configurable:!0};("value"in u.descriptor||u.descriptor.set)&&(l.set=function(d){return Z(this,i,d,t)}),("value"in u.descriptor||u.descriptor.get)&&(l.get=function(){return H(this,i,t)});try{return Object.defineProperty(n,i,l),!0}catch{return r.delete(i+""),!1}}let f=(Array.isArray(e)?e:e===void 0?Object.keys(n):[e]).map(o);return e===void 0||Array.isArray(e)?f:f[0]}function It(n,e,t={}){n=qe(n);let r=v(n,"accessorizedProps");function s(f){return r.has(f+"")?r.get(f+"").restore():!0}let a=(Array.isArray(e)?e:e===void 0?Object.keys(n):[e]).map(s);return e===void 0||Array.isArray(e)?a:a[0]}function Le(n,e={},t=void 0){let r=qe(n);if(typeof e.membrane=="boolean")throw new Error("The params.membrane parameter cannot be of type boolean.");if(e.membrane&&v(r,"membraneRef").has(e.membrane))return v(r,"membraneRef").get(e.membrane);let s={apply:(f,i,u)=>He(f,i,u,void 0,e),construct:(f,i,u=null)=>We(f,i,u,e),defineProperty:(f,i,u)=>ce(f,i,u,e),deleteProperty:(f,i)=>le(f,i,e),get:(f,i,u=null)=>{if(i===nt)return r;let c={...e,receiver:u},l=H(f,i,c);return Array.isArray(f)&&typeof l=="function"&&!/^class\s?/.test(Function.prototype.toString.call(l))?Le(l,{...e,arrayMethodName:i,membrane:u},t):e.chainable&&g(l)&&i!=="prototype"&&!(typeof l=="function"&&/^class\s?|\{\s\[native\scode\]\s\}$/.test(Function.prototype.toString.call(l)))?Le(l,e,t):l},getOwnPropertyDescriptor:(f,i)=>ve(f,i,e),getPrototypeOf:f=>Be(f,e),has:(f,i)=>Pe(f,i,e),isExtensible:f=>Ne(f,e),ownKeys:f=>ke(f,e),preventExtensions:f=>Ve(f,e),set:(f,i,u,c=null)=>Z(f,i,u,{...e,receiver:c}),setPrototypeOf:(f,i)=>Ue(f,i,e)},o=t?.(s)||s,a=new Proxy(r,o);return e.membrane&&v(r,"membraneRef").set(e.membrane,a),a}function ue(n){return n&&n[nt]||n}function qe(n){if(!n||!g(n))throw new Error("Target must be of type object!");return ue(n)}var pe=class extends Array{};function Ct(...n){return new pe(...n)}var X=class extends Array{};function Dt(){return new X}function Rt(){return 1/0}function ze(n,e,t,r=o=>o,s={}){let o=e instanceof X;if(!(!o&&!e?.length))return function a(f,i,u,c){let l=c||i[u.level]instanceof X,d=l?1/0:i[u.level],h=l?!1:u.level===i.length-1;return f instanceof E&&f.operation!=="get"?u={...u,probe:"always"}:u.probe!=="always"&&(u={...u,probe:!h}),t(f,d,(p,...m)=>{let w=y=>{y instanceof E&&(y.path="key"in y?[y.key]:[],f instanceof E&&(y.path="key"in y?f.path.concat(y.key):f.path.slice(0),Object.defineProperty(y,"context",{get:()=>f,configurable:!0})))},x=m[0]||{},_=y=>{if(y instanceof E&&"argumentsList"in y)return;let I=F(y,!1);return oe(I,M=>(y instanceof E?y.value=M:y=M,a(y,i,{...u,...x,keyInParent:y.key,level:u.level+1},l)))};if(de(d)&&Array.isArray(p)){if(p.forEach(w),h)return r(p,...m);l&&p[0]instanceof E&&(p[0].operation!=="get"||s.asGet)&&r(p,...m);for(let y of p)_(y);return}return w(p),h?r(p,...m):_(p)},u)}(n,e.slice(0),{...s,level:0},o)}function Ge(n,e,t,r={}){let s=F(n,!r.level);if(B(arguments[1])&&([,t,r={}]=arguments,e=1/0),!B(t))throw new Error(`Handler must be a function; "${te(t)}" given!`);if(e instanceof pe||e instanceof X)return ze(s,e,Ge,t,r);if(r={...r,descripted:!0},delete r.live,!g(s))return r.probe&&H(s,e,t,r)||void 0;let o=st(s,e,t,r);return r.probe?H(s,e,o,r):o()}function $t(n,e,t={}){let r=F(n);return b(e)||([,,,t={}]=arguments,e={[arguments[1]]:arguments[2]}),W.getInstance(r,!0,t.namespace).addRegistration({traps:e,params:t})}function ve(n,e,t=s=>s,r={}){return R(n,"getOwnPropertyDescriptor",{key:e},t,r)}function Lt(n,e,t=s=>s,r={}){return R(n,"getOwnPropertyDescriptors",{key:e},t,r)}function Be(n,e=r=>r,t={}){return R(n,"getPrototypeOf",{},e,t)}function Ne(n,e=r=>r,t={}){return R(n,"isExtensible",{},e,t)}function ke(n,e=r=>r,t={}){return R(n,"ownKeys",{},e,t)}function Pe(n,e,t=s=>s,r={}){return R(n,"has",{key:e},t,r)}function H(n,e,t=s=>s,r={}){let s,o=F(n,!r.level);return b(t)?[r,t]=[t,a=>a]:r.live&&(s=!0),e instanceof pe||e instanceof X?ze(o,e,H,t,{...r,asGet:!0}):Nt(o,e,a=>{let f=[...a];return function i(u,c,l){if(!c.length)return l(u);let d=c.shift();if(!["string","number","symbol"].includes(typeof d))throw new Error(`Property name/key ${d} invalid.`);function h(w,x=void 0){let _=M=>(w.value=M,i([...u,r.live||r.descripted?w:M],c,l));if(arguments.length>1)return _(x);if(!g(o))return _(o?.[w.key]);let y=v(o,"accessorizedProps",!1),I=y&&y.get(w.key);if(I&&I.intact())return _(I.getValue(r.withPropertyDescriptors));if(r.withPropertyDescriptors){let M=Object.getOwnPropertyDescriptor(o,w.key);return _(M)}return _(Reflect.get(o,w.key))}let p=new E(o,{type:"get",key:d,value:void 0,operation:"get",related:f});if(!g(o))return h(p);let m=W.getInstance(o,!1,r.namespace);return m?m.emit(p,h):h(p)}([],a.slice(0),i=>{let u=de(e)?i:i[0];return s&&g(o)?st(o,e,t,r,n.key)(u):t(u)})},r)}function Je(n,e,t={}){let r=F(n);return k.getInstance(r,!0,t.namespace).batch(e,t)}function qt(n,e,t={}){e=F(e),n=F(n);let r=(t.only||[]).slice(0),s=(t.except||[]).slice(0),o=Object.keys(t.spread?[...n]:n).map(u=>isNaN(u)?u:parseInt(u)),a=r.length?r.filter(u=>o.includes(u)):o.filter(u=>!s.includes(u)),f=u=>!Array.isArray(e)||isNaN(u)?u:u-s.filter(c=>c<u).length,i=u=>{let c=ve(n,u,t);"value"in c&&c.writable&&c.enumerable&&c.configurable?Z(e,f(u),c.value,t):(c.enumerable||t.onlyEnumerable===!1)&&ce(e,u,{...c,configurable:!0},t)};return Je(e,()=>{a.forEach(i)}),Ge(n,u=>{u.filter(c=>r.length?r.includes(c.key):!s.includes(c.key)).forEach(c=>{if(c.type==="delete")return le(e,f(c.key),t);if(c.type==="def"){(c.value.enumerable||t.onlyEnumerable===!1)&&ce(e,f(c.key),{...c.value,configurable:!0},t);return}i(c.key)})},{...t,withPropertyDescriptors:!0})}function Z(n,e,t,r=a=>a,s={},o=!1){let a=F(n),f=[[e,t]];b(e)&&([,,r=u=>u,s={},o=!1]=arguments,f=Object.entries(e)),b(r)&&([o,s,r]=[typeof s=="boolean"?s:o,r,u=>u]);let i=f.map(([u])=>u);return function u(c,l,d){if(!l.length)return d(c);let[h,p]=l.shift();function m(x,_=void 0){let y=lt=>(x.status=lt,u(c.concat(x),l,d));if(arguments.length>1)return y(x,_);let I=v(a,"accessorizedProps",!1),M=I&&I.get(x.key);return x.type==="def"?(M&&!M.restore()&&y(!1),Object.defineProperty(a,x.key,x.value),y(!0)):M&&M.intact()?y(M.setValue(x.value)):y(Reflect.set(a,x.key,x.value))}function w(x,_){if(s.diff&&p===_)return u(c,l,d);let y=new E(a,{type:o?"def":"set",key:h,value:p,isUpdate:x,oldValue:_,related:[...i],operation:o?"defineProperty":"set",detail:s.detail}),I=W.getInstance(a,!1,s.namespace);return I?I.emit(y,m):m(y)}return Pe(a,h,x=>{if(!x)return w(x);if(h==="length"&&Array.isArray(a)&&v(a).has("$length"))return w(!0,v(a).get("$length"));let _={...s,withPropertyDescriptors:o};return H(a,h,y=>w(x,y),_)},s)}([],f.slice(0),u=>{let c=k.getInstance(a,!1,s.namespace);return c&&c.emit(u,{eventsArePropertyDescriptors:!!o}),r(de(e)?u.map(l=>l.status):u[0]?.status)})}function ce(n,e,t,r=o=>o,s={}){return Z(n,e,t,r,s,!0)}function Ft(n,e,t=s=>s,r={}){return Z(n,e,t,r,!0)}function le(n,e,t=s=>s,r={}){let s=F(n);b(t)&&([r,t]=[t,f=>f]);let o=L(e,!1),a=[...o];return function f(i,u,c){if(!u.length)return c(i);let l=u.shift();function d(p,m=void 0){let w=y=>(p.status=y,f(i.concat(p),u,c));if(arguments.length>1)return w(p,m);let x=v(s,"accessorizedProps",!1),_=x&&x.get(p.key);return _&&!_.restore()&&w(!1),w(Reflect.deleteProperty(s,p.key))}function h(p){let m=new E(s,{type:"delete",key:l,oldValue:p,related:[...a],operation:"deleteProperty",detail:r.detail}),w=W.getInstance(s,!1,r.namespace);return w?w.emit(m,d):d(m)}return H(s,l,h,r)}([],o.slice(0),f=>{let i=k.getInstance(s,!1,r.namespace);return i&&i.emit(f),t(de(e)?f.map(u=>u.status):f[0].status)})}function Bt(n,e,t=s=>s,r={}){return le(...arguments)}function We(n,e,t=null,r=o=>o,s={}){return R(n,"construct",arguments.length>2?{argumentsList:e,newTarget:t}:{argumentsList:e},r,s)}function He(n,e,t,r=o=>o,s={}){let o=ue(e),a;if(Array.isArray(e)){if(s.arrayMethodName){let f=new E(o,{operation:s.arrayMethodName,argumentsList:t});k.getInstance(o,!1,s.namespace)?.emit([f],{eventIsArrayMethodDescriptor:!0})}v(o).set("$length",o.length),a=Je(o,()=>R(n,"apply",{thisArgument:e,argumentsList:t},r,s),s),v(o).delete("$length")}else a=R(n,"apply",{thisArgument:o,argumentsList:t},r,s);return a}function Ue(n,e,t=s=>s,r={}){return R(n,"setPrototypeOf",{proto:e},t,r)}function Ve(n,e=r=>r,t={}){return R(n,"preventExtensions",{},e,t)}function st(n,e,t,r={}){let s=new AbortController;xe.setMaxListeners?.(0,s.signal),r.signal&&r.signal.addEventListener("abort",()=>s.abort());let o={...r,signal:s.signal},a=k.getInstance(n,!0,o.namespace),f=new Map;return function i(u=[],c=null){let l,d,h;if(de(e)){if(c){h=!0,d=c;for(let p of u)f.get(p.key)?.remove(),f.delete(p.key)}else d=a.addRegistration(e,i,o);l={signal:d.signal,childRegistrations:f}}else c?.remove(),d=a.addRegistration(e,i,o),l={signal:d.signal};if(o.childRegistrations&&o.keyInParent&&o.childRegistrations.set(o.keyInParent,d),arguments.length){let p=t(u,l);if(arguments.length>1)return p}return s}}function R(n,e,t={},r=o=>o,s={}){n=F(n),b(r)&&([s,r]=[r,i=>i]);function o(i,u){return arguments.length>1?r(u):r((Reflect[e]||Object[e])(n,...Object.values(t)))}let a=new E(n,{operation:e,...t}),f=W.getInstance(n,!1,s.namespace);return f?f.emit(a,o):o(a)}function de(n){return n===1/0||Array.isArray(n)}function F(n,e=!0,t=!0){if((!n||!g(n))&&e)throw new Error(`Object must be of type object or array! "${te(n)}" given.`);return n instanceof E&&(n.type==="def"&&t?n=typeof n.value.get=="function"?n.value.get():n.value.value:n=n.value),n&&ue(n)}function Nt(n,e,t,r={}){return e===1/0?r.level&&!g(n)?t([]):t(Object.entries(Object.getOwnPropertyDescriptors(n)).filter(([,s])=>s.writable!==!1&&!s.get&&!s.set).map(([s])=>s)):t(L(e,!1))}var kt={...Ke,...Fe},P=kt;var Y=class extends Ee(EventTarget){#t;constructor(e,{autoStart:t=!0,naturalOpen:r=!0,postAwaitsOpen:s=!1}={}){if(super(),this.#t=typeof e=="string"?new WebSocket(e):e,O(this).set("options",{autoStart:t,naturalOpen:r,postAwaitsOpen:s}),this.constructor.upgradeEvents(this.#t,this),r&&t&&this.#t.readyState===WebSocket.OPEN&&this.start(),this.#t.readyState===WebSocket.CLOSED)try{this.close()}catch{}}static _hydrateMessage(e,t){try{let r;if(typeof t.data=="string"&&b(r=JSON.parse(t.data))&&r[".wq"])return Object.defineProperty(t,"data",{value:r,configurable:!0}),super._hydrateMessage(e,t)}catch{}return t}__postMessage(e,t){this.#t.send(JSON.stringify(e),t)}};var ot=(n,...e)=>D(n,"port+",...e),q=n=>D(n,"port+","meta").get("options")||{},O=n=>D(n,"port+","meta"),it=["addEventListener","addRequestListener","postMessage","postRequest","dispatchEvent","relay","start","readyStateChange","removeEventListener","close"],at=["options","readyState","onmessage","onmessageerror"],S=class extends ft(EventTarget){constructor(e={}){super(),ot(this,"meta").set("options",e)}static[Symbol.hasInstance](e){return Function.prototype[Symbol.hasInstance].call(this,e)?!0:it.every(t=>typeof e[t]=="function")||at.every(t=>t in e)}};function ft(n){return class extends n{static upgradeInPlace(e,t={}){if(e instanceof S)return e;let r=this.prototype;for(let o of it){let a=e[o],f=r[o];a&&Object.defineProperty(e,`_${o}`,{value:a.bind(e),configurable:!0}),Object.defineProperty(e,o,{value:f.bind(e),configurable:!0})}for(let o of at){let a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),o),f=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(r),o);a&&Object.defineProperty(e,`_${o}`,{...a,configurable:!0}),Object.defineProperty(e,o,{...f,configurable:!0})}ot(e,"meta").set("options",t),this.upgradeEvents(e)}static upgradeEvents(e,t=null){t||(t=e);let r=O(e);if(r.get("events+"))return;let s=O(t),o=q(t),a=ee.call(t),f=ie.call(t);e instanceof BroadcastChannel&&(o.clientServerMode==="server"?s.set("clients",new Set):o.clientServerMode==="client"&&s.set("client_id",`client-${(0|Math.random()*9e6).toString(36)}`));let i=l=>{if(l instanceof j)return;if(e===t&&l.stopImmediatePropagation?.(),l=this._hydrateMessage?.(t,l)||l,l.data.ping==="connect"&&typeof l.data?.[".wq"]?.eventID=="string"&&(!(e instanceof WebSocket)||!o.naturalOpen)){let m=!0;e instanceof BroadcastChannel&&(o.clientServerMode==="server"&&typeof l.data.id=="string"?(s.get("clients").add(l.data.id),m="server"):l.data.id==="server"&&s.has("client_id")&&(m=s.get("client_id"))),l.ports?.forEach(w=>w.postMessage(m)),s.set("remote.start.called",!0),t.start();return}if(l.data.ping==="disconnect"&&typeof l.data?.[".wq"]?.eventID=="string"){let m=()=>{s.set("remote.close.called",!0),t.close()};e instanceof BroadcastChannel?o.clientServerMode==="server"&&typeof l.data.id=="string"?(s.get("clients").delete(l.data.id),!s.get("clients").size&&o.autoClose&&!f.close.state&&m()):o.clientServerMode==="client"&&l.data.id==="server"&&m():e instanceof MessagePort&&m();return}let d=l.data,h={};typeof l.data?.[".wq"]?.eventID=="string"&&({message:d,".wq":h}=l.data);let p=new j(d,{originalTarget:e,...h,ports:l.ports});t.dispatchEvent(p)},u=l=>{e instanceof WebSocket&&o.naturalOpen&&!(l instanceof j)&&(s.set("remote.start.called",!0),t.start())},c=l=>{(e instanceof WebSocket||e instanceof MessagePort)&&!(l instanceof j)&&(s.set("remote.close.called",!0),t.close())};r.set("internal_call",!0),e.addEventListener("message",i),e.addEventListener("error",i),e.addEventListener("open",u),e.addEventListener("close",c),r.delete("internal_call"),r.set("events+",!0),a.add(()=>{e.removeEventListener("message",i),e.removeEventListener("error",i),e.removeEventListener("open",u),e.removeEventListener("close",c),r.set("events+",!1)})}get options(){return{...q(this)}}get onmessageerror(){return typeof super.onmessageerror<"u"?super.onmessageerror:typeof this._onmessageerror<"u"?this._onmessageerror:null}set onmessageerror(e){if(typeof super.onmessageerror<"u"){super.onmessageerror=e;return}if(e!==null&&typeof e!="function")throw new TypeError("onmessageerror must be a function");if(Object.getOwnPropertyDescriptor(this,"_onmessageerror")?.set){this._onmessageerror=e;return}this._onmessageerror&&this.removeEventListener("messageerror",this._onmessageerror),this.addEventListener("messageerror",e),this._onmessageerror=e}get onmessage(){return typeof super.onmessage<"u"?super.onmessage:typeof this._onmessage<"u"?this._onmessage:null}set onmessage(e){let t=O(this),r=q(this);if(!t.get("internal_call")&&r.autoStart&&this.start(),typeof super.onmessage<"u"){super.onmessage=e;return}if(e!==null&&typeof e!="function")throw new TypeError("onmessage must be a function");if(Object.getOwnPropertyDescriptor(this,"_onmessage")?.set){this._onmessage=e;return}this._onmessage&&this.removeEventListener("message",this._onmessage),this.addEventListener("message",e),this._onmessage=e}addEventListener(...e){let t=O(this),r=q(this);return!t.get("internal_call")&&r.autoStart&&this.start(),ee.call(this).add(()=>{this._removeEventListener?this._removeEventListener(...e):super.removeEventListener(...e)}),this._addEventListener?this._addEventListener(...e):super.addEventListener(...e)}dispatchEvent(e){let t=this._dispatchEvent?this._dispatchEvent(e):super.dispatchEvent(e);return e instanceof j&&Wt.call(this,e),t}postMessage(e,t={}){let r=O(this),s=q(this);!r.get("internal_call")&&s.autoStart&&this.start();let o=ie.call(this);o.messaging.state=!0,o.messaging.resolve();let a,{portOptions:f,wqOptions:{relayedFrom:i,...u}}=Oe.call(this,e,t);(u.type!=="message"||u.live||u.bubbles||f.transfer?.length&&(this instanceof BroadcastChannel||this instanceof Y))&&(e={message:e,".wq":u}),t=f,a=i;let c=()=>{this._postMessage?this._postMessage(e,t,a):super.postMessage(e,t)};s.postAwaitsOpen?o.open.promise.then(c):c()}addRequestListener(e,t,r={}){let s=async o=>{let a=await t(o);for(let f of o.ports)f.postMessage(a)};this.addEventListener(e,s,r)}postRequest(e,t,r={}){let s;b(t)&&(r={once:!0,...t},s=new Promise(c=>{t=c}));let o=new MessageChannel;this.constructor.upgradeEvents(o.port1),o.port1.start();let{signal:a=null,once:f=!1,transfer:i=[],...u}=r;return o.port1.addEventListener("message",c=>t(c),{signal:a,once:f}),a?.addEventListener("abort",()=>{o.port1.close(),o.port2.close()}),this.postMessage(e,{...u,transfer:[o.port2].concat(i)}),s}relay({to:e,from:t,types:r="*",channel:s=null,resolveMessage:o=null,bidirectional:a=!1}={}){if(e&&t)throw new Error('Only one of "to" and "from" may be specified');if(t?e=this:t=this,e===t)throw new Error("Source and target ports cannot be the same");if(!(t instanceof S)||!(e instanceof S))throw new Error("Both source and target ports must be instance of MessagePortPlus.");if(typeof r!="function"&&!(r=[].concat(r)).length)throw new Error("Event types must be specified.");if(typeof s=="string")s={from:s};else if(b(s)){if(Object.keys(s).filter(c=>!["from","to"].includes(c)).length)throw new Error('Channel must be a string or an object of "from"/"to" members')}else if(s)throw new Error("Invalid channel parameter");let f=ut.call(t),i={targetPort:e,types:r,channel:s,resolveMessage:o};f.add(i);let u;return a&&(u=e.relay({to:t,types:r,channel:s&&{to:s.from,from:s.to},resolveMessage:o,bidirectional:!1})),()=>{f.delete(i),u?.()}}channel(e,t=null){let r=new MessageChannel;return S.upgradeInPlace(r.port1,{autoStart:this.options.autoStart,postAwaitsOpen:this.options.postAwaitsOpen}),S.upgradeInPlace(r.port2,{autoStart:this.options.autoStart,postAwaitsOpen:this.options.postAwaitsOpen}),ee.call(this).add(this.relay({channel:e,to:r.port1,bidirectional:!0,resolveMessage:t})),r.port1.start(),this.readyStateChange("close").then(()=>{r.port1.close()}),r.port2}projectMutations({from:e,to:t,...r}){if(!e||!t||typeof e=="string"&&typeof t=="string"||g(e)&&g(t))throw new Error('Invalid "from"/"to" parameters');if(typeof e=="string"){if(!g(t))throw new Error('Invalid "to" parameter. Object/array expected');return $e.call(this,t,e,r)}if(typeof t=="string"){if(!g(e))throw new Error('Invalid "from" parameter. Object/array expected');return ct.call(this,e,t,r)}throw new Error('Invalid "from"/"to" parameters')}get readyState(){let e=ie.call(this);return e.close.state?"closed":e.open.state?"open":"connecting"}readyStateChange(e){if(!["open","messaging","error","close"].includes(e))throw new Error(`Invalid readyState query "${e}"`);return ie.call(this)[e].promise}start(){let e=ie.call(this);if(e.open.state)return;let t,r=()=>{if(e.open.state)return;e.open.state=!0,e.open.resolve();let u=new j(null,{type:"open"});this._dispatchEvent?this._dispatchEvent(u):super.dispatchEvent(u),t?.port1.close(),t?.port2.close()},s=O(this),o=q(this);if(s.get("remote.start.called")){r();return}if(s.get("start.called"))return;s.set("start.called",!0),this._start?this._start():super.start?.(),t=new MessageChannel,t.port1.onmessage=u=>{this instanceof BroadcastChannel&&o.clientServerMode==="server"&&typeof u.data=="string"&&s.get("clients").add(u.data),r()};let{wqOptions:a}=Oe.call(this),f=o.clientServerMode==="server"?"server":o.clientServerMode==="client"?s.get("client_id"):null,i={".wq":a,ping:"connect",id:f};this._postMessage?this._postMessage(i,{transfer:[t.port2]}):super.postMessage(i,{transfer:[t.port2]})}close(...e){let t=ie.call(this);if(t.close.state)return;t.close.state=!0;let r=O(this),s=q(this);if(!r.get("remote.close.called")&&(this instanceof BroadcastChannel||this instanceof MessagePort)){let{wqOptions:a}=Oe.call(this),f=s.clientServerMode==="server"?"server":s.clientServerMode==="client"?r.get("client_id"):null,i={".wq":a,ping:"disconnect",id:f};this._postMessage?this._postMessage(i):super.postMessage(i)}this._close?this._close(...e):super.close(...e),t.close.resolve();let o=new j(null,{type:"close"});this._dispatchEvent?this._dispatchEvent(o):super.dispatchEvent(o),Ht.call(this)}}}function Ee(n){return class extends ft(n){static _hydrateMessage(e,t){if(typeof t.data?.[".wq"]?.numPorts!="number"||typeof t.data[".wq"].eventID!="string")return t;let r=ee.call(e),s=t.data[".wq"].numPorts;Object.defineProperty(t,"ports",{value:[],configurable:!0});for(let o=0;o<s;o++){let a=e.channel(`${t.data[".wq"].eventID}:${o}`);t.ports.push(a)}return t}_postMessage(e,t={}){let{transfer:r=[],...s}=t;if(typeof e?.[".wq"]?.eventID=="string"){let o=ee.call(this),a=r.filter(i=>i instanceof MessagePort),f=a.length;for(let i=0;i<f;i++)S.upgradeInPlace(a[i]),o.add(this.relay({channel:`${e[".wq"].eventID}:${i}`,to:a[i],bidirectional:!0})),a[i].start(),a[i].readyStateChange("close").then(()=>{let{wqOptions:u}=Oe.call(this),c={".wq":u,ping:"disconnect"};this.postMessage(c,{type:`${e[".wq"].eventID}:${i}:message`})});e[".wq"].numPorts=f}return this.__postMessage(e,s)}}}function Wt(n){if(n.propagationStopped)return;let e=O(this);e.get("parentNode")instanceof EventTarget&&(n.bubbles||e.get("parentNode")?.findPort?.(r=>r===this)&&n instanceof j)&&e.get("parentNode").dispatchEvent(n);let t=ut.call(this);if(t.size&&n instanceof j){let{type:r,eventID:s,data:o,live:a,bubbles:f,ports:i}=n,u=new WeakSet;for(let{targetPort:c,types:l,channel:d,resolveMessage:h}of t){if(u.has(c))continue;let p=r;d.from&&([,p]=new RegExp(`^${d.from.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}:([^:]+)$`).exec(r)||[],!p)||!(typeof l=="function"?l(p,this,c,d):[].concat(l).find(w=>w===p||w==="*"))||(u.add(c),c.postMessage(h?h(o,this,c,d):o,{transfer:i,type:d.to?`${d.to}:${p}`:p,eventID:s,bubbles:f,live:a,forwarded:!0,relayedFrom:this}))}}}function ee(){let n=O(this);return n.has("garbage_collection")||n.set("garbage_collection",new Set),n.get("garbage_collection")}function ut(){let n=O(this);return n.has("downstream_registry")||n.set("downstream_registry",new Set),n.get("downstream_registry")}function ie(){let n=O(this);if(!n.has("readystate_registry")){let e=t=>(t.promise=new Promise((r,s)=>(t.resolve=r,t.reject=s)),t);n.set("readystate_registry",{open:e({}),messaging:e({}),error:e({}),close:e({})})}return n.get("readystate_registry")}function Ht(){let n=O(this);for(let e of n.get("garbage_collection")||[])e instanceof AbortController?e.abort():typeof e=="function"&&e();n.get("garbage_collection")?.clear(),n.get("downstream_registry")?.clear()}function Oe(n=void 0,e={}){if(Array.isArray(e))e={transfer:e};else if(!e||typeof e!="object")throw new TypeError("transferOrOptions must be an array or an object");let{type:t="message",eventID:r=null,live:s=!1,observing:o=!1,bubbles:a=!1,forwarded:f=!1,relayedFrom:i=null,signal:u=null,withArrayMethodDescriptors:c=!1,honourDoneMutationFlags:l=!1,...d}=e;return r||(r=`${t}-${(0|Math.random()*9e6).toString(36)}`),!o&&!f&&g(n)&&s&&!t?.endsWith(".mutate")&&(ct.call(this,n,r,{signal:u,withArrayMethodDescriptors:c,honourDoneMutationFlags:l}),o=!0),{portOptions:d,wqOptions:{type:t,eventID:r,live:s,observing:o,honourDoneMutationFlags:l,bubbles:a,forwarded:f,relayedFrom:i}}}function ct(n,e,{signal:t,withArrayMethodDescriptors:r=!0,honourDoneMutationFlags:s=!1}={}){if(!g(n))throw new TypeError("data must be a plain object and not a stream");if(typeof e!="string")throw new TypeError("eventID must be a non-empty string");let o=i=>{let u;r&&Array.isArray(i[0].target)&&!i[0].argumentsList&&!["set","defineProperty","deleteProperty"].includes(i[0].operation)||(this.postMessage(i.map(c=>(u=!u&&s&&c.detail?.done,{...c,target:void 0})),{type:`${e}.mutate`}),u&&a.abort())},a=P.observe(n,P.subtree(),o,{signal:t,withArrayMethodDescriptors:r});return ee.call(this).add(a),a}function $e(n,e,{signal:t,honourDoneMutationFlags:r=!1}={}){if(!g(n))throw new TypeError("data must be a plain object and not a stream");if(typeof e!="string")throw new TypeError("eventID must be a non-empty string");let s=f=>{if(!f.data?.length)return;let i;P.batch(n,()=>{for(let u of f.data){if(i=!i&&r&&u.detail?.done,u.argumentsList){let c=u.path.length?P.get(n,P.path(...u.path)):n;P.proxy(c)[u.operation](...u.argumentsList);continue}if(u.key!=="length"||["set","defineProperty","deleteProperty"].includes(u.operation)){let c=u.path.length===1?n:P.get(n,P.path(...u.path.slice(0,-1)));u.type==="delete"?P.deleteProperty(c,u.key):P.set(c,u.key,u.value)}}}),i&&o()};this.addEventListener(`${e}.mutate`,s,{signal:t});let o=()=>this.removeEventListener(`${e}.mutate`,s);return ee.call(this).add(o),o}var he=class extends Ee(BroadcastChannel){constructor(e,{autoStart:t=!0,postAwaitsOpen:r=!1,clientServerMode:s=null,autoClose:o=!0}={}){super(e);let a=O(this);if(s&&!["server","client"].includes(s))throw new Error('clientServerMode must be "server" or "client"');a.set("options",{autoStart:t,postAwaitsOpen:r,clientServerMode:s,autoClose:o}),this.constructor.upgradeEvents(this)}__postMessage(e,t){BroadcastChannel.prototype.postMessage.call(this,e)}};var Me=class n extends EventTarget{static get xHeaderName(){return"X-Background-Messaging-Port"}static test(e){return e instanceof n||e?.[Symbol.toStringTag]==="LiveResponse"?"LiveResponse":e?.[Symbol.toStringTag]==="LiveProgramHandle"?"LiveProgramHandle":e instanceof Response?"Response":Vt(e)?"Generator":"Default"}static hasBackgroundPort(e){return!!e.headers?.get?.(this.xHeaderName)?.trim()}static getBackgroundPort(e){if(!/Response/.test(this.test(e)))return;let t=A(e);if(!t.has("background_port")){let r=e.headers.get(this.xHeaderName)?.trim();if(!r)return;let[s,o]=r.split(":");if(!["ws","br"].includes(s))throw new Error(`Unknown background messaging protocol: ${r}`);let a=s==="br"?new he(o,{autoStart:!1,postAwaitsOpen:!0,clientServerMode:"client"}):new Y(o,{autoStart:!1,naturalOpen:!1,postAwaitsOpen:!0});t.set("background_port",a)}return t.get("background_port")}static from(e,...t){return this.test(e)==="LiveResponse"?e.clone(...t):new this(e,...t)}[Symbol.toStringTag]="LiveResponse";constructor(e,...t){super(),this.#r(e,...t)}#t=null;get body(){return this.#t}get bodyUsed(){return!1}#s=new T;get headers(){return this.#s}#n=200;get status(){return this.#n}#i="";get statusText(){return this.#i}#u="basic";get type(){return this.#u}#c=!1;get redirected(){return this.#c}#a=null;get url(){return this.#a}get ok(){return this.#n>=200&&this.#n<299}async arrayBuffer(){throw new Error("LiveResponse does not support the arrayBuffer() method.")}async formData(){throw new Error("LiveResponse does not support the formData() method.")}async json(){throw new Error("LiveResponse does not support the json() method.")}async text(){throw new Error("LiveResponse does not support the text() method.")}async blob(){throw new Error("LiveResponse does not support the blob() method.")}async bytes(){throw new Error("LiveResponse does not support the bytes() method.")}get background(){return this.constructor.getBackgroundPort(this)}#e=new AbortController;get signal(){return this.#e.signal}get readyState(){let e=Se.call(this);return e.done.state?"done":e.live.state?"live":"waiting"}readyStateChange(e){if(!["live","done"].includes(e))throw new Error(`Invalid readyState query "${e}"`);return Se.call(this)[e].promise}disconnect(){this.#e.abort(),this.#e=new AbortController}#o;#f(e){let t=Se.call(this);if(t.done.state)throw new Error("Response already done.");this.#o=e,e.then(r=>{this.#o===e&&(this.#o=null,t.done.state=!0,t.done.resolve(r))}).catch(r=>{this.#o===e&&(this.#o=null,t.done.state=!0,t.done.reject(r))})}async replaceWith(e,...t){if(this.readyState==="done")throw new Error("Response already done.");this.disconnect(),await this.#r(e,...t)}async#r(e,...t){if(e instanceof Promise)return this.#f(e),await new Promise((l,d)=>{let h=!1;this.#e.signal.addEventListener("abort",()=>{h=!0,l()}),e.then(async p=>{h||(await this.#r(p,...t),l())}),e.catch(p=>d(p))});let r=l=>{let d=l.body;this.#n=l.status,this.#i=l.statusText;for(let[p]of[...this.#s.entries()])this.#s.delete(p);for(let[p,m]of l.headers.entries())this.#s.append(p,m);this.#u=l.type,this.#c=l.redirected,this.#a=l.url,this.#t=d,P.defineProperty(this,"body",{get:()=>this.#t,enumerable:!0,configurable:!0});let h=Se.call(this);h.live.state=!0,h.live.resolve(),this.dispatchEvent(new Event("replace"))},s=async(l,d)=>{r({body:l,status:200,statusText:"",headers:new Headers,...d,type:"basic",redirected:!1,url:null})},o=async(l,d)=>{let h,p=!1;try{h=l instanceof Response?await N.prototype.parse.call(l,{to:"json"}):l.body,p=!0}catch{h=l.body}if(r({body:h,status:l.status,statusText:l.statusText,headers:l.headers,...d,type:l.type,redirected:l.redirected,url:l.url}),this.constructor.test(l)==="LiveResponse")return l.addEventListener("replace",()=>{r(l)},{signal:this.#e.signal}),await l.readyStateChange("done");if(this.hasBackgroundPort(l)){let m=this.constructor.getBackgroundPort(l),w;return p&&(w=c.projectMutations({from:"initial_response",to:h,signal:this.#e.signal})),m.addEventListener("response.replace",x=>{w?.(),w=null,r(x.data)},{signal:this.#e.signal}),await m.readyStateChange("close")}return Promise.resolve()},a=async(l,d)=>{let h=await l.next(),p=await h.value;await this.#r(p,{done:h.done,...d});let m=h,w=p;for(;!m.done&&!this.#e.signal.aborted;)m=await l.next(),w=await m.value,this.#e.signal.aborted||await this.#r(w,{done:d.done===!1?!1:m.done})},f=async(l,d)=>(await this.#r(l.value,d),P.observe(l,"value",h=>this.#r(h.value,{done:!1}),{signal:this.#e.signal}),new Promise(()=>{})),i=b(t[0])?{...t.shift()}:{},u=typeof t[0]=="function"?t.shift():null;if("status"in i&&(i.status=parseInt(i.status),i.status<200||i.status>599))throw new Error(`The status provided (${i.status}) is outside the range [200, 599].`);"statusText"in i&&(i.statusText=String(i.statusText)),i.headers&&!(i.headers instanceof Headers)&&(i.headers=new Headers(i.headers));let c;if(/Response/.test(this.constructor.test(e))){if(u)throw new Error("frameClosure is not supported for responses.");c=await o(e,i)}else if(this.constructor.test(e)==="Generator"){if(u)throw new Error("frameClosure is not supported for generators.");c=await a(e,i)}else if(this.constructor.test(e)==="LiveProgramHandle"){if(u)throw new Error("frameClosure is not supported for live program handles.");c=await f(e,i)}else if(c=s(e,i),u){let l=g(e)&&!Ce(e)?P.proxy(e,{chainable:!0,membrane:e}):e;c=Promise.resolve(u.call(this,l))}return this.#f(i.done===!1?new Promise(()=>{}):c),await new Promise((l,d)=>{this.#e.signal.addEventListener("abort",l),c.then(()=>l()),c.catch(h=>d(h))})}toResponse({client:e,signal:t}={}){if(e&&!(e instanceof S))throw new Error("Client must be a MessagePortPlus interface");let r=N.from(this.body,{status:this.status,statusText:this.statusText,headers:this.headers}),s=A(this);if(J(r).set("meta",s),e&&this.readyState==="live"){let o;g(this.body)&&!Ce(this.body)&&(o=e.projectMutations({from:this.body,to:"initial_response",signal:t}));let a=()=>{o?.(),o=null;let f=Object.fromEntries([...this.headers.entries()]);f?.["set-cookie"]&&(delete f["set-cookie"],console.warn('Warning: The "set-cookie" header is not supported for security reasons and has been removed from the response.')),e.postMessage({body:this.body,status:this.status,statusText:this.statusText,headers:f,done:this.readyState==="done"},{type:"response.replace",live:!0,signal:this.#e.signal})};this.addEventListener("replace",a,{signal:t})}return r}async*toGenerator({signal:e}={}){do yield this.body;while(await new Promise(t=>{this.addEventListener("replace",()=>t(!0),{once:!0,signal:e}),this.readyStateChange("done").then(()=>t(!1))}))}toLiveProgramHandle({signal:e}={}){let t=new Qe,r=()=>P.defineProperty(t,"value",{value:this.body,enumerable:!0,configurable:!0});return this.addEventListener("replace",r,{signal:e}),r(),t}clone(e={}){let t=new this.constructor,r=A(this);return J(t).set("meta",r),t.replaceWith(this,e),t}},Vt=n=>typeof n?.next=="function"&&typeof n?.throw=="function"&&typeof n?.return=="function";function Se(){let n=A(this);if(!n.has("readystate_registry")){let e=t=>(t.promise=new Promise((r,s)=>(t.resolve=r,t.reject=s)),t);n.set("readystate_registry",{live:e({}),done:e({})})}return n.get("readystate_registry")}var Qe=class{[Symbol.toStringTag]="LiveProgramHandle";abort(){}};globalThis.webqit||(globalThis.webqit={});Object.assign(globalThis.webqit,Ze);})();
1
+ (()=>{var Pr=Object.defineProperty;var Tt=(t,e)=>()=>(t&&(e=t(t=0)),e);var je=(t,e)=>{for(var r in e)Pr(t,r,{get:e[r],enumerable:!0})};function Dt(t,e){return(e?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(t)}function tt(t,e=!1){let r=[],n=0;for(;n<t.length;){let s=t[n],i=y(function(a){if(!e)throw new TypeError(a);r.push({type:"INVALID_CHAR",index:n,value:t[n++]})},"ErrorOrInvalid");if(s==="*"){r.push({type:"ASTERISK",index:n,value:t[n++]});continue}if(s==="+"||s==="?"){r.push({type:"OTHER_MODIFIER",index:n,value:t[n++]});continue}if(s==="\\"){r.push({type:"ESCAPED_CHAR",index:n++,value:t[n++]});continue}if(s==="{"){r.push({type:"OPEN",index:n,value:t[n++]});continue}if(s==="}"){r.push({type:"CLOSE",index:n,value:t[n++]});continue}if(s===":"){let a="",o=n+1;for(;o<t.length;){let f=t.substr(o,1);if(o===n+1&&Rr.test(f)||o!==n+1&&Tr.test(f)){a+=t[o++];continue}break}if(!a){i(`Missing parameter name at ${n}`);continue}r.push({type:"NAME",index:n,value:a}),n=o;continue}if(s==="("){let a=1,o="",f=n+1,c=!1;if(t[f]==="?"){i(`Pattern cannot start with "?" at ${f}`);continue}for(;f<t.length;){if(!Dt(t[f],!1)){i(`Invalid character '${t[f]}' at ${f}.`),c=!0;break}if(t[f]==="\\"){o+=t[f++]+t[f++];continue}if(t[f]===")"){if(a--,a===0){f++;break}}else if(t[f]==="("&&(a++,t[f+1]!=="?")){i(`Capturing groups are not allowed at ${f}`),c=!0;break}o+=t[f++]}if(c)continue;if(a){i(`Unbalanced pattern at ${n}`);continue}if(!o){i(`Missing pattern at ${n}`);continue}r.push({type:"REGEX",index:n,value:o}),n=f;continue}r.push({type:"CHAR",index:n,value:t[n++]})}return r.push({type:"END",index:n,value:""}),r}function rt(t,e={}){let r=tt(t);e.delimiter??="/#?",e.prefixes??="./";let n=`[^${j(e.delimiter)}]+?`,s=[],i=0,a=0,o="",f=new Set,c=y(d=>{if(a<r.length&&r[a].type===d)return r[a++].value},"tryConsume"),u=y(()=>c("OTHER_MODIFIER")??c("ASTERISK"),"tryConsumeModifier"),l=y(d=>{let P=c(d);if(P!==void 0)return P;let{type:E,index:U}=r[a];throw new TypeError(`Unexpected ${E} at ${U}, expected ${d}`)},"mustConsume"),p=y(()=>{let d="",P;for(;P=c("CHAR")??c("ESCAPED_CHAR");)d+=P;return d},"consumeText"),m=y(d=>d,"DefaultEncodePart"),h=e.encodePart||m,g="",b=y(d=>{g+=d},"appendToPendingFixedValue"),_=y(()=>{g.length&&(s.push(new we(3,"","",h(g),"",3)),g="")},"maybeAddPartFromPendingFixedValue"),w=y((d,P,E,U,N)=>{let D=3;switch(N){case"?":D=1;break;case"*":D=0;break;case"+":D=2;break}if(!P&&!E&&D===3){b(d);return}if(_(),!P&&!E){if(!d)return;s.push(new we(3,"","",h(d),"",D));return}let T;E?E==="*"?T=Ze:T=E:T=n;let ve=2;T===n?(ve=1,T=""):T===Ze&&(ve=0,T="");let Y;if(P?Y=P:E&&(Y=i++),f.has(Y))throw new TypeError(`Duplicate name '${Y}'.`);f.add(Y),s.push(new we(ve,Y,h(d),T,h(U),D))},"addPart");for(;a<r.length;){let d=c("CHAR"),P=c("NAME"),E=c("REGEX");if(!P&&!E&&(E=c("ASTERISK")),P||E){let N=d??"";e.prefixes.indexOf(N)===-1&&(b(N),N=""),_();let D=u();w(N,P,E,"",D);continue}let U=d??c("ESCAPED_CHAR");if(U){b(U);continue}if(c("OPEN")){let N=p(),D=c("NAME"),T=c("REGEX");!D&&!T&&(T=c("ASTERISK"));let ve=p();l("CLOSE");let Y=u();w(N,D,T,ve,Y);continue}_(),l("END")}return s}function j(t){return t.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function Ye(t){return t&&t.ignoreCase?"ui":"u"}function kt(t,e,r){return nt(rt(t,r),e,r)}function ne(t){switch(t){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}function nt(t,e,r={}){r.delimiter??="/#?",r.prefixes??="./",r.sensitive??=!1,r.strict??=!1,r.end??=!0,r.start??=!0,r.endsWith="";let n=r.start?"^":"";for(let o of t){if(o.type===3){o.modifier===3?n+=j(o.value):n+=`(?:${j(o.value)})${ne(o.modifier)}`;continue}e&&e.push(o.name);let f=`[^${j(r.delimiter)}]+?`,c=o.value;if(o.type===1?c=f:o.type===0&&(c=Ze),!o.prefix.length&&!o.suffix.length){o.modifier===3||o.modifier===1?n+=`(${c})${ne(o.modifier)}`:n+=`((?:${c})${ne(o.modifier)})`;continue}if(o.modifier===3||o.modifier===1){n+=`(?:${j(o.prefix)}(${c})${j(o.suffix)})`,n+=ne(o.modifier);continue}n+=`(?:${j(o.prefix)}`,n+=`((?:${c})(?:`,n+=j(o.suffix),n+=j(o.prefix),n+=`(?:${c}))*)${j(o.suffix)})`,o.modifier===0&&(n+="?")}let s=`[${j(r.endsWith)}]|$`,i=`[${j(r.delimiter)}]`;if(r.end)return r.strict||(n+=`${i}?`),r.endsWith.length?n+=`(?=${s})`:n+="$",new RegExp(n,Ye(r));r.strict||(n+=`(?:${i}(?=${s}))?`);let a=!1;if(t.length){let o=t[t.length-1];o.type===3&&o.modifier===3&&(a=r.delimiter.indexOf(o)>-1)}return a||(n+=`(?=${i}|${s})`),new RegExp(n,Ye(r))}function qt(t,e){return t.length?t[0]==="/"?!0:!e||t.length<2?!1:(t[0]=="\\"||t[0]=="{")&&t[1]=="/":!1}function st(t,e){return t.startsWith(e)?t.substring(e.length,t.length):t}function Ut(t,e){return t.endsWith(e)?t.substr(0,t.length-e.length):t}function ot(t){return!t||t.length<2?!1:t[0]==="["||(t[0]==="\\"||t[0]==="{")&&t[1]==="["}function it(t){if(!t)return!0;for(let e of Nt)if(t.test(e))return!0;return!1}function Ft(t,e){if(t=st(t,"#"),e||t==="")return t;let r=new URL("https://example.com");return r.hash=t,r.hash?r.hash.substring(1,r.hash.length):""}function Ht(t,e){if(t=st(t,"?"),e||t==="")return t;let r=new URL("https://example.com");return r.search=t,r.search?r.search.substring(1,r.search.length):""}function Bt(t,e){return e||t===""?t:ot(t)?ft(t):ct(t)}function Wt(t,e){if(e||t==="")return t;let r=new URL("https://example.com");return r.password=t,r.password}function zt(t,e){if(e||t==="")return t;let r=new URL("https://example.com");return r.username=t,r.username}function Vt(t,e,r){if(r||t==="")return t;if(e&&!Nt.includes(e))return new URL(`${e}:${t}`).pathname;let n=t[0]=="/";return t=new URL(n?t:"/-"+t,"https://example.com").pathname,n||(t=t.substring(2,t.length)),t}function Gt(t,e,r){return at(e)===t&&(t=""),r||t===""?t:ut(t)}function Jt(t,e){return t=Ut(t,":"),e||t===""?t:Le(t)}function at(t){switch(t){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}function Le(t){if(t==="")return t;if(/^[-+.A-Za-z0-9]*$/.test(t))return t.toLowerCase();throw new TypeError(`Invalid protocol '${t}'.`)}function Kt(t){if(t==="")return t;let e=new URL("https://example.com");return e.username=t,e.username}function Xt(t){if(t==="")return t;let e=new URL("https://example.com");return e.password=t,e.password}function ct(t){if(t==="")return t;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(t))throw new TypeError(`Invalid hostname '${t}'`);let e=new URL("https://example.com");return e.hostname=t,e.hostname}function ft(t){if(t==="")return t;if(/[^0-9a-fA-F[\]:]/g.test(t))throw new TypeError(`Invalid IPv6 hostname '${t}'`);return t.toLowerCase()}function ut(t){if(t===""||/^[0-9]*$/.test(t)&&parseInt(t)<=65535)return t;throw new TypeError(`Invalid port '${t}'.`)}function Qt(t){if(t==="")return t;let e=new URL("https://example.com");return e.pathname=t[0]!=="/"?"/-"+t:t,t[0]!=="/"?e.pathname.substring(2,e.pathname.length):e.pathname}function Zt(t){return t===""?t:new URL(`data:${t}`).pathname}function Yt(t){if(t==="")return t;let e=new URL("https://example.com");return e.search=t,e.search.substring(1,e.search.length)}function er(t){if(t==="")return t;let e=new URL("https://example.com");return e.hash=t,e.hash.substring(1,e.hash.length)}function et(t,e){if(typeof t!="string")throw new TypeError("parameter 1 is not of type 'string'.");let r=new URL(t,e);return{protocol:r.protocol.substring(0,r.protocol.length-1),username:r.username,password:r.password,hostname:r.hostname,port:r.port,pathname:r.pathname,search:r.search!==""?r.search.substring(1,r.search.length):void 0,hash:r.hash!==""?r.hash.substring(1,r.hash.length):void 0}}function F(t,e){return e?ye(t):t}function ge(t,e,r){let n;if(typeof e.baseURL=="string")try{n=new URL(e.baseURL),e.protocol===void 0&&(t.protocol=F(n.protocol.substring(0,n.protocol.length-1),r)),!r&&e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&e.username===void 0&&(t.username=F(n.username,r)),!r&&e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&e.username===void 0&&e.password===void 0&&(t.password=F(n.password,r)),e.protocol===void 0&&e.hostname===void 0&&(t.hostname=F(n.hostname,r)),e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&(t.port=F(n.port,r)),e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&e.pathname===void 0&&(t.pathname=F(n.pathname,r)),e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&e.pathname===void 0&&e.search===void 0&&(t.search=F(n.search.substring(1,n.search.length),r)),e.protocol===void 0&&e.hostname===void 0&&e.port===void 0&&e.pathname===void 0&&e.search===void 0&&e.hash===void 0&&(t.hash=F(n.hash.substring(1,n.hash.length),r))}catch{throw new TypeError(`invalid baseURL '${e.baseURL}'.`)}if(typeof e.protocol=="string"&&(t.protocol=Jt(e.protocol,r)),typeof e.username=="string"&&(t.username=zt(e.username,r)),typeof e.password=="string"&&(t.password=Wt(e.password,r)),typeof e.hostname=="string"&&(t.hostname=Bt(e.hostname,r)),typeof e.port=="string"&&(t.port=Gt(e.port,t.protocol,r)),typeof e.pathname=="string"){if(t.pathname=e.pathname,n&&!qt(t.pathname,r)){let s=n.pathname.lastIndexOf("/");s>=0&&(t.pathname=F(n.pathname.substring(0,s+1),r)+t.pathname)}t.pathname=Vt(t.pathname,t.protocol,r)}return typeof e.search=="string"&&(t.search=Ht(e.search,r)),typeof e.hash=="string"&&(t.hash=Ft(e.hash,r)),t}function ye(t){return t.replace(/([+*?:{}()\\])/g,"\\$1")}function rr(t){return t.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function nr(t,e){e.delimiter??="/#?",e.prefixes??="./",e.sensitive??=!1,e.strict??=!1,e.end??=!0,e.start??=!0,e.endsWith="";let r=".*",n=`[^${rr(e.delimiter)}]+?`,s=/[$_\u200C\u200D\p{ID_Continue}]/u,i="";for(let a=0;a<t.length;++a){let o=t[a];if(o.type===3){if(o.modifier===3){i+=ye(o.value);continue}i+=`{${ye(o.value)}}${ne(o.modifier)}`;continue}let f=o.hasCustomName(),c=!!o.suffix.length||!!o.prefix.length&&(o.prefix.length!==1||!e.prefixes.includes(o.prefix)),u=a>0?t[a-1]:null,l=a<t.length-1?t[a+1]:null;if(!c&&f&&o.type===1&&o.modifier===3&&l&&!l.prefix.length&&!l.suffix.length)if(l.type===3){let p=l.value.length>0?l.value[0]:"";c=s.test(p)}else c=!l.hasCustomName();if(!c&&!o.prefix.length&&u&&u.type===3){let p=u.value[u.value.length-1];c=e.prefixes.includes(p)}c&&(i+="{"),i+=ye(o.prefix),f&&(i+=`:${o.name}`),o.type===2?i+=`(${o.value})`:o.type===1?f||(i+=`(${n})`):o.type===0&&(!f&&(!u||u.type===3||u.modifier!==3||c||o.prefix!=="")?i+="*":i+=`(${r})`),o.type===1&&f&&o.suffix.length&&s.test(o.suffix[0])&&(i+="\\"),i+=ye(o.suffix),c&&(i+="}"),o.modifier!==3&&(i+=ne(o.modifier))}return i}var jr,y,we,Rr,Tr,Ze,te,Ir,Lr,Nt,tr,Qe,ee,De,sr=Tt(()=>{jr=Object.defineProperty,y=(t,e)=>jr(t,"name",{value:e,configurable:!0}),we=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(t,e,r,n,s,i){this.type=t,this.name=e,this.prefix=r,this.value=n,this.suffix=s,this.modifier=i}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};y(we,"Part");Rr=/[$_\p{ID_Start}]/u,Tr=/[$_\u200C\u200D\p{ID_Continue}]/u,Ze=".*";y(Dt,"isASCII");y(tt,"lexer");y(rt,"parse");y(j,"escapeString");y(Ye,"flags");y(kt,"stringToRegexp");y(ne,"modifierToString");y(nt,"partsToRegexp");te={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Ir={delimiter:".",prefixes:"",sensitive:!0,strict:!0},Lr={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};y(qt,"isAbsolutePathname");y(st,"maybeStripPrefix");y(Ut,"maybeStripSuffix");y(ot,"treatAsIPv6Hostname");Nt=["ftp","file","http","https","ws","wss"];y(it,"isSpecialScheme");y(Ft,"canonicalizeHash");y(Ht,"canonicalizeSearch");y(Bt,"canonicalizeHostname");y(Wt,"canonicalizePassword");y(zt,"canonicalizeUsername");y(Vt,"canonicalizePathname");y(Gt,"canonicalizePort");y(Jt,"canonicalizeProtocol");y(at,"defaultPortForProtocol");y(Le,"protocolEncodeCallback");y(Kt,"usernameEncodeCallback");y(Xt,"passwordEncodeCallback");y(ct,"hostnameEncodeCallback");y(ft,"ipv6HostnameEncodeCallback");y(ut,"portEncodeCallback");y(Qt,"standardURLPathnameEncodeCallback");y(Zt,"pathURLPathnameEncodeCallback");y(Yt,"searchEncodeCallback");y(er,"hashEncodeCallback");tr=class{#n;#t=[];#r={};#e=0;#o=1;#a=0;#i=0;#f=0;#h=0;#c=!1;constructor(t){this.#n=t}get result(){return this.#r}parse(){for(this.#t=tt(this.#n,!0);this.#e<this.#t.length;this.#e+=this.#o){if(this.#o=1,this.#t[this.#e].type==="END"){if(this.#i===0){this.#g(),this.#m()?this.#s(9,1):this.#y()?this.#s(8,1):this.#s(7,0);continue}else if(this.#i===2){this.#u(5);continue}this.#s(10,0);break}if(this.#f>0)if(this.#S())this.#f-=1;else continue;if(this.#O()){this.#f+=1;continue}switch(this.#i){case 0:this.#_()&&this.#u(1);break;case 1:if(this.#_()){this.#M();let t=7,e=1;this.#v()?(t=2,e=3):this.#c&&(t=2),this.#s(t,e)}break;case 2:this.#b()?this.#u(3):(this.#x()||this.#y()||this.#m())&&this.#u(5);break;case 3:this.#P()?this.#s(4,1):this.#b()&&this.#s(5,1);break;case 4:this.#b()&&this.#s(5,1);break;case 5:this.#A()?this.#h+=1:this.#C()&&(this.#h-=1),this.#E()&&!this.#h?this.#s(6,1):this.#x()?this.#s(7,0):this.#y()?this.#s(8,1):this.#m()&&this.#s(9,1);break;case 6:this.#x()?this.#s(7,0):this.#y()?this.#s(8,1):this.#m()&&this.#s(9,1);break;case 7:this.#y()?this.#s(8,1):this.#m()&&this.#s(9,1);break;case 8:this.#m()&&this.#s(9,1);break;case 9:break;case 10:break}}this.#r.hostname!==void 0&&this.#r.port===void 0&&(this.#r.port="")}#s(t,e){switch(this.#i){case 0:break;case 1:this.#r.protocol=this.#p();break;case 2:break;case 3:this.#r.username=this.#p();break;case 4:this.#r.password=this.#p();break;case 5:this.#r.hostname=this.#p();break;case 6:this.#r.port=this.#p();break;case 7:this.#r.pathname=this.#p();break;case 8:this.#r.search=this.#p();break;case 9:this.#r.hash=this.#p();break;case 10:break}this.#i!==0&&t!==10&&([1,2,3,4].includes(this.#i)&&[6,7,8,9].includes(t)&&(this.#r.hostname??=""),[1,2,3,4,5,6].includes(this.#i)&&[8,9].includes(t)&&(this.#r.pathname??=this.#c?"/":""),[1,2,3,4,5,6,7].includes(this.#i)&&t===9&&(this.#r.search??="")),this.#d(t,e)}#d(t,e){this.#i=t,this.#a=this.#e+e,this.#e+=e,this.#o=0}#g(){this.#e=this.#a,this.#o=0}#u(t){this.#g(),this.#i=t}#w(t){return t<0&&(t=this.#t.length-t),t<this.#t.length?this.#t[t]:this.#t[this.#t.length-1]}#l(t,e){let r=this.#w(t);return r.value===e&&(r.type==="CHAR"||r.type==="ESCAPED_CHAR"||r.type==="INVALID_CHAR")}#_(){return this.#l(this.#e,":")}#v(){return this.#l(this.#e+1,"/")&&this.#l(this.#e+2,"/")}#b(){return this.#l(this.#e,"@")}#P(){return this.#l(this.#e,":")}#E(){return this.#l(this.#e,":")}#x(){return this.#l(this.#e,"/")}#y(){if(this.#l(this.#e,"?"))return!0;if(this.#t[this.#e].value!=="?")return!1;let t=this.#w(this.#e-1);return t.type!=="NAME"&&t.type!=="REGEX"&&t.type!=="CLOSE"&&t.type!=="ASTERISK"}#m(){return this.#l(this.#e,"#")}#O(){return this.#t[this.#e].type=="OPEN"}#S(){return this.#t[this.#e].type=="CLOSE"}#A(){return this.#l(this.#e,"[")}#C(){return this.#l(this.#e,"]")}#p(){let t=this.#t[this.#e],e=this.#w(this.#a).index;return this.#n.substring(e,t.index)}#M(){let t={};Object.assign(t,te),t.encodePart=Le;let e=kt(this.#p(),void 0,t);this.#c=it(e)}};y(tr,"Parser");Qe=["protocol","username","password","hostname","port","pathname","search","hash"],ee="*";y(et,"extractValues");y(F,"processBaseURLString");y(ge,"applyInit");y(ye,"escapePatternString");y(rr,"escapeRegexpString");y(nr,"partsToPattern");De=class{#n;#t={};#r={};#e={};#o={};#a=!1;constructor(t={},e,r){try{let n;if(typeof e=="string"?n=e:r=e,typeof t=="string"){let o=new tr(t);if(o.parse(),t=o.result,n===void 0&&typeof t.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");t.baseURL=n}else{if(!t||typeof t!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(n)throw new TypeError("parameter 1 is not of type 'string'.")}typeof r>"u"&&(r={ignoreCase:!1});let s={ignoreCase:r.ignoreCase===!0},i={pathname:ee,protocol:ee,username:ee,password:ee,hostname:ee,port:ee,search:ee,hash:ee};this.#n=ge(i,t,!0),at(this.#n.protocol)===this.#n.port&&(this.#n.port="");let a;for(a of Qe){if(!(a in this.#n))continue;let o={},f=this.#n[a];switch(this.#r[a]=[],a){case"protocol":Object.assign(o,te),o.encodePart=Le;break;case"username":Object.assign(o,te),o.encodePart=Kt;break;case"password":Object.assign(o,te),o.encodePart=Xt;break;case"hostname":Object.assign(o,Ir),ot(f)?o.encodePart=ft:o.encodePart=ct;break;case"port":Object.assign(o,te),o.encodePart=ut;break;case"pathname":it(this.#t.protocol)?(Object.assign(o,Lr,s),o.encodePart=Qt):(Object.assign(o,te,s),o.encodePart=Zt);break;case"search":Object.assign(o,te,s),o.encodePart=Yt;break;case"hash":Object.assign(o,te,s),o.encodePart=er;break}try{this.#o[a]=rt(f,o),this.#t[a]=nt(this.#o[a],this.#r[a],o),this.#e[a]=nr(this.#o[a],o),this.#a=this.#a||this.#o[a].some(c=>c.type===2)}catch{throw new TypeError(`invalid ${a} pattern '${this.#n[a]}'.`)}}}catch(n){throw new TypeError(`Failed to construct 'URLPattern': ${n.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test(t={},e){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof t!="string"&&e)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof t>"u")return!1;try{typeof t=="object"?r=ge(r,t,!1):r=ge(r,et(t,e),!1)}catch{return!1}let n;for(n of Qe)if(!this.#t[n].exec(r[n]))return!1;return!0}exec(t={},e){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof t!="string"&&e)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof t>"u")return;try{typeof t=="object"?r=ge(r,t,!1):r=ge(r,et(t,e),!1)}catch{return null}let n={};e?n.inputs=[t,e]:n.inputs=[t];let s;for(s of Qe){let i=this.#t[s].exec(r[s]);if(!i)return null;let a={};for(let[o,f]of this.#r[s].entries())if(typeof f=="string"||typeof f=="number"){let c=i[o+1];a[f]=c}n[s]={input:r[s]??"",groups:a}}return n}static compareComponent(t,e,r){let n=y((o,f)=>{for(let c of["type","modifier","prefix","value","suffix"]){if(o[c]<f[c])return-1;if(o[c]!==f[c])return 1}return 0},"comparePart"),s=new we(3,"","","","",3),i=new we(0,"","","","",3),a=y((o,f)=>{let c=0;for(;c<Math.min(o.length,f.length);++c){let u=n(o[c],f[c]);if(u)return u}return o.length===f.length?0:n(o[c]??s,f[c]??s)},"comparePartList");return!e.#e[t]&&!r.#e[t]?0:e.#e[t]&&!r.#e[t]?a(e.#o[t],[i]):!e.#e[t]&&r.#e[t]?a([i],r.#o[t]):a(e.#o[t],r.#o[t])}get protocol(){return this.#e.protocol}get username(){return this.#e.username}get password(){return this.#e.password}get hostname(){return this.#e.hostname}get port(){return this.#e.port}get pathname(){return this.#e.pathname}get search(){return this.#e.search}get hash(){return this.#e.hash}get hasRegExpGroups(){return this.#a}};y(De,"URLPattern")});var or={};je(or,{URLPattern:()=>De});var ir=Tt(()=>{sr();globalThis.URLPattern||(globalThis.URLPattern=De)});var Rt={};je(Rt,{FormDataPlus:()=>W,HeadersPlus:()=>z,LiveResponse:()=>ze,Observer:()=>lr,RequestPlus:()=>He,ResponsePlus:()=>V,fetchPlus:()=>gr});function v(t){return!Array.isArray(t)&&typeof t=="object"&&t}function he(t){return typeof t}function I(t){return Array.isArray(t)}function Re(t){return t===!0||t===!1}function pe(t){return typeof t=="function"}function Ve(t){return t===null||t===""}function re(t){return arguments.length&&(t===void 0||typeof t>"u")}function x(t){return Array.isArray(t)||typeof t=="object"&&t||pe(t)}function Ge(t){return Ve(t)||re(t)||t===!1||t===0||x(t)&&!Object.keys(t).length}function J(t){return pe(t)||t&&{}.toString.call(t)==="[object function]"}function de(t){return t instanceof Number||typeof t=="number"}function K(t){return de(t)||t!==!0&&t!==!1&&t!==null&&t!==""&&!isNaN(t*1)}function Je(t){return I(t)&&Object.getPrototypeOf(t)===Array.prototype}function Ke(t){return v(t)&&Object.getPrototypeOf(t)===Object.prototype}function X(t){return t instanceof String||typeof t=="string"&&t!==null}function Xe(t){return!X(t)&&!re(t.length)}function k(t,...e){if(!t||!["object","function"].includes(typeof t))throw new Error("Argument #1 must be of type object");let r=t[Symbol.for("wq")];if(r||(r=new Te,Object.defineProperty(t,Symbol.for("wq"),{value:r,enumerable:!1,configurable:!1,writable:!1})),!e.length)return r;let n,s;for(;n=e.shift();)(s=r)&&!(r=r.get(n))&&(r=new Te,s.set(n,r));return r}var Te=class extends Map{};function me(t,e,r=!1){if(e=="")return t;var n=r?t.lastIndexOf(e):t.indexOf(e);return n===-1?"":t.substr(n+e.length)}function Ie(t,e,r=!1){if(e=="")return t;var n=r?t.lastIndexOf(e):t.indexOf(e);return n===-1?t:t.substr(0,n)}(async()=>typeof URLPattern>"u"&&await Promise.resolve().then(()=>(ir(),or)))();var lt=class extends URLPattern{#n;constructor(e,r=null){typeof e=="object"&&e?.baseURL&&({baseURL:r,...e}=e),super(e,r),this.#n=new URL(e,r)}isPattern(){let e=(s,i)=>{if(!s)return!1;let a=!1;for(let o of s){if(a){a=!1;continue}if(o==="\\"){a=!0;continue}if(i.has(o))return!0}return!1},r={protocol:new Set(["*"]),username:new Set(["*"]),password:new Set(["*"]),hostname:new Set(["*","{"]),port:new Set(["*","{"]),pathname:new Set(["*",":","{","("]),search:new Set(["*","{"]),hash:new Set(["*","{"])},n=this.#n;return e(n.protocol,r.protocol)||e(n.username,r.username)||e(n.password,r.password)||e(n.hostname,r.hostname)||e(n.port,r.port)||e(n.pathname,r.pathname)||e(n.search,r.search)||e(n.hash,r.hash)}exec(...e){let r=super.exec(...e);if(!r)return;let n={};for(let a of Object.values(r))a?.groups&&Object.assign(n,a.groups);let s={named:n};return{...r,vars:s,render:a=>a.replace(/\$(\$|[A-Z0-9_]+)/gi,(o,f)=>f==="$"?"$":s.named[f]??"")}}};var St={};je(St,{any:()=>Kr,apply:()=>xt,batch:()=>Ot,construct:()=>bt,defineProperties:()=>Yr,defineProperty:()=>Se,deleteProperties:()=>en,deleteProperty:()=>Ae,get:()=>Z,getOwnPropertyDescriptor:()=>qe,getOwnPropertyDescriptors:()=>Qr,getPrototypeOf:()=>gt,has:()=>Ue,intercept:()=>Xr,isExtensible:()=>yt,map:()=>Zr,observe:()=>Et,ownKeys:()=>wt,path:()=>Gr,preventExtensions:()=>vt,reduce:()=>Pt,set:()=>ie,setPrototypeOf:()=>_t,subtree:()=>Jr});function H(t,e=!0){return I(t)?t:!e&&v(t)?[t]:t!==!1&&t!==0&&Ge(t)?[]:Xe(t)?Array.prototype.slice.call(t):v(t)?Object.values(t):[t]}var S=(t,...e)=>k(t,"observerAPI",...e),be=(t,e)=>t instanceof Promise?t.then(e):e(t),ke={};var se=class{constructor(e,r){this.registry=e,Object.assign(this,{...r,target:e.target}),this.params.signal&&this.params.signal.addEventListener("abort",()=>this.remove())}remove(){return this.removed=!0,this.registry.removeRegistration(this)}};var Pe=class extends se{constructor(){super(...arguments),this.emit.currentRegistration=this,Object.defineProperty(this,"abortController",{value:new AbortController}),Object.defineProperty(this,"signal",{value:this.abortController.signal}),ke.setMaxListeners?.(0,this.signal)}remove(){this.abortController.abort(),super.remove()}fire(e){if(this.emit.recursionTarget&&!["inject","force-async","force-sync"].includes(this.params.recursions))return;let r=e,n=this.filter;if(n!==1/0&&(n=H(n,!1))&&(r=e.filter(i=>n.includes(i.key))),this.params.diff&&(r=r.filter(i=>i.type!=="set"||i.value!==i.oldValue)),!r.length)return;if(["inject","defer"].includes(this.params.recursions)){if(this.emit.recursionTarget){this.emit.recursionTarget.push(...r);return}this.emit.recursionTarget=this.params.recursions==="inject"?r:[]}let s=this.filter===1/0||Array.isArray(this.filter)?this.emit(r,this):this.emit(r[0],this);return be(s,i=>{let a=this.emit.recursionTarget;return delete this.emit.recursionTarget,this.params.recursions==="defer"&&a?.length?this.emit.currentRegistration.fire(a):i})}};var oe=class{constructor(e){this.target=e,this.entries=[]}addRegistration(e){return this.entries.push(e),e}removeRegistration(e){this.entries=this.entries.filter(r=>r!==e)}static _getInstance(e,r,n=!0,s=this.__namespace){if(!x(r))throw new Error(`Subject must be of type object; "${he(r)}" given!`);let i=this;return s&&S(globalThis,"observerAPI","namespaces").has(e+"-"+s)&&(i=S(globalThis,"observerAPI","namespaces").get(e+"-"+s),e+="-"+s),!S(r,"registry").has(e)&&n&&S(r,"registry").set(e,new i(r)),S(r,"registry").get(e)}static _namespace(e,r,n=null){if(e+="-"+r,arguments.length===2)return S(globalThis,"observerAPI","namespaces").get(e);if(!(n.prototype instanceof this))throw new Error(`The implementation of the namespace ${this.name}.${r} must be a subclass of ${this.name}.`);S(globalThis,"observerAPI","namespaces").set(e,n),n.__namespace=r}};var A=class{constructor(e,r){if(this.target=e,!r.operation)throw new Error("Descriptor operation must be given in definition!");Object.assign(this,r)}};var L=class extends oe{static getInstance(e,r=!0,n=null){return super._getInstance("listeners",...arguments)}static namespace(e,r=null){return super._namespace("listeners",...arguments)}constructor(e){super(e),this.batches=[]}addRegistration(e,r,n){return super.addRegistration(new Pe(this,{filter:e,emit:r,params:n}))}emit(e,{eventsArePropertyDescriptors:r=!1,eventIsArrayMethodDescriptor:n=!1}={}){if(this.batches.length){let s=this.batches[0].params.arrayMethodName;this.batches[0].snapshots.push({events:[...e],arrayMethodName:s,eventsArePropertyDescriptors:r,eventIsArrayMethodDescriptor:n});return}this.$emit(this.entries,[{events:e,eventsArePropertyDescriptors:r,eventIsArrayMethodDescriptor:n}])}$emit(e,r){let n=0,s=0,i=0;for(let u of e)n+=1,u.params.withPropertyDescriptors&&(s+=1),u.params.withArrayMethodDescriptors&&(i+=1);let a=[],o=[],f=[],c=[];for(let u of r){let l=u.arrayMethodName,p=u.eventsArePropertyDescriptors,m=u.eventIsArrayMethodDescriptor;for(let h of u.events)if(l&&(h.operation=l),s&&(i&&a.push(h),m||i!==n&&o.push(h)),s!==n){let g=h;if(p){let{target:b,type:_,...w}=h;g=new A(b,{type:"set",...w}),Object.defineProperty(g,"value","get"in w.value?{get:()=>w.value.get()}:{value:w.value.value}),w.oldValue&&Object.defineProperty(g,"oldValue","get"in w.oldValue?{get:()=>w.oldValue.get()}:{value:w.oldValue.value})}i&&f.push(g),m||i!==n&&c.push(g)}}for(let u of e)u.params.withPropertyDescriptors?u.params.withArrayMethodDescriptors?a.length&&u.fire(a):o.length&&u.fire(o):u.params.withArrayMethodDescriptors?f.length&&u.fire(f):c.length&&u.fire(c)}batch(e,r={}){this.batches.unshift({entries:[...this.entries],snapshots:[],params:r});let n=e();return be(n,s=>{let i=this.batches.shift();return i.snapshots.length&&this.$emit(i.entries,i.snapshots),s})}};var Ee=class extends se{exec(e,r,n){return this.running||!this.traps[e.operation]?r(...Array.prototype.slice.call(arguments,2)):(this.running=!0,this.traps[e.operation](e,n,(...s)=>(this.running=!1,r(...s))))}};var Q=class extends oe{static getInstance(e,r=!0,n=null){return super._getInstance("traps",...arguments)}static namespace(e,r=null){return super._namespace("traps",...arguments)}addRegistration(e){return super.addRegistration(new Ee(this,e))}emit(e,r=null){let n=this;return function s(i,...a){let o=n.entries[i];return o?o.exec(e,(...f)=>s(i+1,...f),...a):r?r(e,...a):a[0]}(0)}};var mt={};je(mt,{accessorize:()=>zr,proxy:()=>pt,unaccessorize:()=>Vr,unproxy:()=>Oe});var fr=Symbol("wqOriginal");function zr(t,e,r={}){t=dt(t);let n=S(t,"accessorizedProps");function s(f){let c,u=t;do c=Object.getOwnPropertyDescriptor(u,f);while(!c&&(u=Object.getPrototypeOf(u)));return c?{proto:u,descriptor:c}:{descriptor:{value:void 0,configurable:!0,enumerable:!0,writable:!0}}}function i(f){if(n.has(f+""))return!0;let c=s(f);c.getValue=function(p=!1){return p?this.descriptor:this.descriptor.get?this.descriptor.get():this.descriptor.value},c.setValue=function(p,m=!1){if(this.dirty=!0,m){this.descriptor=p;return}return this.descriptor.set?this.descriptor.set(p)!==!1:(this.descriptor.value=p,!0)},c.intact=function(){let p=Object.getOwnPropertyDescriptor(t,f);return p?.get===l.get&&p?.set===l.set&&n.get(f+"")===this},c.restore=function(){return this.intact()?(this.proto&&this.proto!==t||!this.proto&&!this.dirty?delete t[f]:Object.defineProperty(t,f,this.descriptor),n.delete(f+""),!0):!1},n.set(isNaN(f)?f:parseInt(f),c);let{enumerable:u=!0}=c.descriptor,l={enumerable:u,configurable:!0};("value"in c.descriptor||c.descriptor.set)&&(l.set=function(p){return ie(this,f,p,r)}),("value"in c.descriptor||c.descriptor.get)&&(l.get=function(){return Z(this,f,r)});try{return Object.defineProperty(t,f,l),!0}catch{return n.delete(f+""),!1}}let o=(Array.isArray(e)?e:e===void 0?Object.keys(t):[e]).map(i);return e===void 0||Array.isArray(e)?o:o[0]}function Vr(t,e,r={}){t=dt(t);let n=S(t,"accessorizedProps");function s(o){return n.has(o+"")?n.get(o+"").restore():!0}let a=(Array.isArray(e)?e:e===void 0?Object.keys(t):[e]).map(s);return e===void 0||Array.isArray(e)?a:a[0]}function pt(t,e={},r=void 0){let n=dt(t);if(typeof e.membrane=="boolean")throw new Error("The params.membrane parameter cannot be of type boolean.");if(e.membrane&&S(n,"membraneRef").has(e.membrane))return S(n,"membraneRef").get(e.membrane);let s={apply:(o,f,c)=>xt(o,f,c,void 0,e),construct:(o,f,c=null)=>bt(o,f,c,e),defineProperty:(o,f,c)=>Se(o,f,c,e),deleteProperty:(o,f)=>Ae(o,f,e),get:(o,f,c=null)=>{if(f===fr)return n;let u={...e,receiver:c},l=Z(o,f,u);return Array.isArray(o)&&typeof l=="function"&&!/^class\s?/.test(Function.prototype.toString.call(l))?pt(l,{...e,arrayMethodName:f,membrane:c},r):e.chainable&&x(l)&&f!=="prototype"&&!(typeof l=="function"&&/^class\s?|\{\s\[native\scode\]\s\}$/.test(Function.prototype.toString.call(l)))?pt(l,e,r):l},getOwnPropertyDescriptor:(o,f)=>qe(o,f,e),getPrototypeOf:o=>gt(o,e),has:(o,f)=>Ue(o,f,e),isExtensible:o=>yt(o,e),ownKeys:o=>wt(o,e),preventExtensions:o=>vt(o,e),set:(o,f,c,u=null)=>ie(o,f,c,{...e,receiver:u}),setPrototypeOf:(o,f)=>_t(o,f,e)},i=r?.(s)||s,a=new Proxy(n,i);return e.membrane&&S(n,"membraneRef").set(e.membrane,a),a}function Oe(t){return t&&t[fr]||t}function dt(t){if(!t||!x(t))throw new Error("Target must be of type object!");return Oe(t)}var Ce=class extends Array{};function Gr(...t){return new Ce(...t)}var ae=class extends Array{};function Jr(){return new ae}function Kr(){return 1/0}function Pt(t,e,r,n=i=>i,s={}){let i=e instanceof ae;if(!(!i&&!e?.length))return function a(o,f,c,u){let l=u||f[c.level]instanceof ae,p=l?1/0:f[c.level],m=l?!1:c.level===f.length-1;return o instanceof A&&o.operation!=="get"?c={...c,probe:"always"}:c.probe!=="always"&&(c={...c,probe:!m}),r(o,p,(h,...g)=>{let b=d=>{d instanceof A&&(d.path="key"in d?[d.key]:[],o instanceof A&&(d.path="key"in d?o.path.concat(d.key):o.path.slice(0),Object.defineProperty(d,"context",{get:()=>o,configurable:!0})))},_=g[0]||{},w=d=>{if(d instanceof A&&"argumentsList"in d)return;let P=B(d,!1);return be(P,E=>(d instanceof A?d.value=E:d=E,a(d,f,{...c,..._,keyInParent:d.key,level:c.level+1},l)))};if(Me(p)&&Array.isArray(h)){if(h.forEach(b),m)return n(h,...g);l&&h[0]instanceof A&&(h[0].operation!=="get"||s.asGet)&&n(h,...g);for(let d of h)w(d);return}return b(h),m?n(h,...g):w(h)},c)}(t,e.slice(0),{...s,level:0},i)}function Et(t,e,r,n={}){let s=B(t,!n.level);if(J(arguments[1])&&([,r,n={}]=arguments,e=1/0),!J(r))throw new Error(`Handler must be a function; "${he(r)}" given!`);if(e instanceof Ce||e instanceof ae)return Pt(s,e,Et,r,n);if(n={...n,descripted:!0},delete n.live,!x(s))return n.probe&&Z(s,e,r,n)||void 0;let i=ur(s,e,r,n);return n.probe?Z(s,e,i,n):i()}function Xr(t,e,r={}){let n=B(t);return v(e)||([,,,r={}]=arguments,e={[arguments[1]]:arguments[2]}),Q.getInstance(n,!0,r.namespace).addRegistration({traps:e,params:r})}function qe(t,e,r=s=>s,n={}){return q(t,"getOwnPropertyDescriptor",{key:e},r,n)}function Qr(t,e,r=s=>s,n={}){return q(t,"getOwnPropertyDescriptors",{key:e},r,n)}function gt(t,e=n=>n,r={}){return q(t,"getPrototypeOf",{},e,r)}function yt(t,e=n=>n,r={}){return q(t,"isExtensible",{},e,r)}function wt(t,e=n=>n,r={}){return q(t,"ownKeys",{},e,r)}function Ue(t,e,r=s=>s,n={}){return q(t,"has",{key:e},r,n)}function Z(t,e,r=s=>s,n={}){let s,i=B(t,!n.level);return v(r)?[n,r]=[r,a=>a]:n.live&&(s=!0),e instanceof Ce||e instanceof ae?Pt(i,e,Z,r,{...n,asGet:!0}):tn(i,e,a=>{let o=[...a];return function f(c,u,l){if(!u.length)return l(c);let p=u.shift();if(!["string","number","symbol"].includes(typeof p))throw new Error(`Property name/key ${p} invalid.`);function m(b,_=void 0){let w=E=>(b.value=E,f([...c,n.live||n.descripted?b:E],u,l));if(arguments.length>1)return w(_);if(!x(i))return w(i?.[b.key]);let d=S(i,"accessorizedProps",!1),P=d&&d.get(b.key);if(P&&P.intact())return w(P.getValue(n.withPropertyDescriptors));if(n.withPropertyDescriptors){let E=Object.getOwnPropertyDescriptor(i,b.key);return w(E)}return w(Reflect.get(i,b.key))}let h=new A(i,{type:"get",key:p,value:void 0,operation:"get",related:o});if(!x(i))return m(h);let g=Q.getInstance(i,!1,n.namespace);return g?g.emit(h,m):m(h)}([],a.slice(0),f=>{let c=Me(e)?f:f[0];return s&&x(i)?ur(i,e,r,n,t.key)(c):r(c)})},n)}function Ot(t,e,r={}){let n=B(t);return L.getInstance(n,!0,r.namespace).batch(e,r)}function Zr(t,e,r={}){e=B(e),t=B(t);let n=(r.only||[]).slice(0),s=(r.except||[]).slice(0),i=Object.keys(r.spread?[...t]:t).map(c=>isNaN(c)?c:parseInt(c)),a=n.length?n.filter(c=>i.includes(c)):i.filter(c=>!s.includes(c)),o=c=>!Array.isArray(e)||isNaN(c)?c:c-s.filter(u=>u<c).length,f=c=>{let u=qe(t,c,r);"value"in u&&u.writable&&u.enumerable&&u.configurable?ie(e,o(c),u.value,r):(u.enumerable||r.onlyEnumerable===!1)&&Se(e,c,{...u,configurable:!0},r)};return Ot(e,()=>{a.forEach(f)}),Et(t,c=>{c.filter(u=>n.length?n.includes(u.key):!s.includes(u.key)).forEach(u=>{if(u.type==="delete")return Ae(e,o(u.key),r);if(u.type==="def"){(u.value.enumerable||r.onlyEnumerable===!1)&&Se(e,o(u.key),{...u.value,configurable:!0},r);return}f(u.key)})},{...r,withPropertyDescriptors:!0})}function ie(t,e,r,n=a=>a,s={},i=!1){let a=B(t),o=[[e,r]];v(e)&&([,,n=c=>c,s={},i=!1]=arguments,o=Object.entries(e)),v(n)&&([i,s,n]=[typeof s=="boolean"?s:i,n,c=>c]);let f=o.map(([c])=>c);return function c(u,l,p){if(!l.length)return p(u);let[m,h]=l.shift();function g(_,w=void 0){let d=U=>(_.status=U,c(u.concat(_),l,p));if(arguments.length>1)return d(_,w);let P=S(a,"accessorizedProps",!1),E=P&&P.get(_.key);return _.type==="def"?(E&&!E.restore()&&d(!1),Object.defineProperty(a,_.key,_.value),d(!0)):E&&E.intact()?d(E.setValue(_.value)):d(Reflect.set(a,_.key,_.value))}function b(_,w){if(s.diff&&h===w)return c(u,l,p);let d=new A(a,{type:i?"def":"set",key:m,value:h,isUpdate:_,oldValue:w,related:[...f],operation:i?"defineProperty":"set",detail:s.detail}),P=Q.getInstance(a,!1,s.namespace);return P?P.emit(d,g):g(d)}return Ue(a,m,_=>{if(!_)return b(_);if(m==="length"&&Array.isArray(a)&&S(a).has("$length"))return b(!0,S(a).get("$length"));let w={...s,withPropertyDescriptors:i};return Z(a,m,d=>b(_,d),w)},s)}([],o.slice(0),c=>{let u=L.getInstance(a,!1,s.namespace);return u&&u.emit(c,{eventsArePropertyDescriptors:!!i}),n(Me(e)?c.map(l=>l.status):c[0]?.status)})}function Se(t,e,r,n=i=>i,s={}){return ie(t,e,r,n,s,!0)}function Yr(t,e,r=s=>s,n={}){return ie(t,e,r,n,!0)}function Ae(t,e,r=s=>s,n={}){let s=B(t);v(r)&&([n,r]=[r,o=>o]);let i=H(e,!1),a=[...i];return function o(f,c,u){if(!c.length)return u(f);let l=c.shift();function p(h,g=void 0){let b=d=>(h.status=d,o(f.concat(h),c,u));if(arguments.length>1)return b(h,g);let _=S(s,"accessorizedProps",!1),w=_&&_.get(h.key);return w&&!w.restore()&&b(!1),b(Reflect.deleteProperty(s,h.key))}function m(h){let g=new A(s,{type:"delete",key:l,oldValue:h,related:[...a],operation:"deleteProperty",detail:n.detail}),b=Q.getInstance(s,!1,n.namespace);return b?b.emit(g,p):p(g)}return Z(s,l,m,n)}([],i.slice(0),o=>{let f=L.getInstance(s,!1,n.namespace);return f&&f.emit(o),r(Me(e)?o.map(c=>c.status):o[0].status)})}function en(t,e,r=s=>s,n={}){return Ae(...arguments)}function bt(t,e,r=null,n=i=>i,s={}){return q(t,"construct",arguments.length>2?{argumentsList:e,newTarget:r}:{argumentsList:e},n,s)}function xt(t,e,r,n=i=>i,s={}){let i=Oe(e),a;if(Array.isArray(e)){if(s.arrayMethodName){let o=new A(i,{operation:s.arrayMethodName,argumentsList:r});L.getInstance(i,!1,s.namespace)?.emit([o],{eventIsArrayMethodDescriptor:!0})}S(i).set("$length",i.length),a=Ot(i,()=>q(t,"apply",{thisArgument:e,argumentsList:r},n,s),s),S(i).delete("$length")}else a=q(t,"apply",{thisArgument:i,argumentsList:r},n,s);return a}function _t(t,e,r=s=>s,n={}){return q(t,"setPrototypeOf",{proto:e},r,n)}function vt(t,e=n=>n,r={}){return q(t,"preventExtensions",{},e,r)}function ur(t,e,r,n={}){let s=new AbortController;ke.setMaxListeners?.(0,s.signal),n.signal&&n.signal.addEventListener("abort",()=>s.abort());let i={...n,signal:s.signal},a=L.getInstance(t,!0,i.namespace),o=new Map;return function f(c=[],u=null){let l,p,m;if(Me(e)){if(u){m=!0,p=u;for(let h of c)o.get(h.key)?.remove(),o.delete(h.key)}else p=a.addRegistration(e,f,i);l={signal:p.signal,childRegistrations:o}}else u?.remove(),p=a.addRegistration(e,f,i),l={signal:p.signal};if(i.childRegistrations&&i.keyInParent&&i.childRegistrations.set(i.keyInParent,p),arguments.length){let h=r(c,l);if(arguments.length>1)return h}return s}}function q(t,e,r={},n=i=>i,s={}){t=B(t),v(n)&&([s,n]=[n,f=>f]);function i(f,c){return arguments.length>1?n(c):n((Reflect[e]||Object[e])(t,...Object.values(r)))}let a=new A(t,{operation:e,...r}),o=Q.getInstance(t,!1,s.namespace);return o?o.emit(a,i):i(a)}function Me(t){return t===1/0||Array.isArray(t)}function B(t,e=!0,r=!0){if((!t||!x(t))&&e)throw new Error(`Object must be of type object or array! "${he(t)}" given.`);return t instanceof A&&(t.type==="def"&&r?t=typeof t.value.get=="function"?t.value.get():t.value.value:t=t.value),t&&Oe(t)}function tn(t,e,r,n={}){return e===1/0?n.level&&!x(t)?r([]):r(Object.entries(Object.getOwnPropertyDescriptors(t)).filter(([,s])=>s.writable!==!1&&!s.get&&!s.set).map(([s])=>s)):r(H(e,!1))}var O={...St,...mt},lr=O;var ce=class t extends URLSearchParams{#n;#t;get compatMode(){return this.#t}#r=new Set;#e;#o=!1;#a;_changeCallbackGC;constructor(e={},{compatMode:r=!0,prettyPrint:n=!1,changeCallback:s=null}={}){super(),this.#t=r,this.#e=n;let i;e instanceof t?(i=structuredClone(e.json()),r&&(this.#r=new Set(e.keys()))):e instanceof URLSearchParams||e instanceof FormData?(i=Object.fromEntries(e),r&&(this.#r=new Set(e.keys()))):X(e)?(e=decodeURIComponent(e.replace(/^\?/,"")),i=this.constructor.parse(e,!r),r&&(this.#r=new Set(e.split("&").map(a=>a.split("=")[0])))):Array.isArray(e)?(i=this.constructor.fromEntries(e),r&&(this.#r=new Set(e.map(([a])=>a)))):v(e)?(i=e,r&&this.constructor.reduceValue(e,"",(a,o,f)=>{if(f)return f;/\[\d+\]$/.test(o)&&([,o]=/^(.*)\[\d+\]$/.exec(o)),this.#r.add(o)})):i={},this._changeCallback=s,this._resetJson(i)}_resetJson(e){this.#n=O.proxy(e),this.#a&&(this._changeCallbackGC?.abort(),this._changeCallbackGC=O.observe(this.#n,O.subtree(),this.#a))}get(e){let r=this.#i(e);return this.#t&&Array.isArray(r)?r[0]:r}#i(e,r=!1){if(this.#t&&!this.#r.has(e))return null;let n=this.constructor.get(this.#n,e,r);return n===void 0?null:Array.isArray(n)?this.#t?n.map(s=>typeof s=="number"?s+"":s):n.map(s=>v(s)?new t(s,{compatMode:this.#t}):s):!this.#t&&v(n)?new t(n,{compatMode:this.#t}):this.#t&&typeof n=="number"?n+"":n}getAll(e){let r=this.#i(e,!0);return r===null?[]:Array.isArray(r)?r:[r]}set(e,r){return this.#t&&this.#r.add(e),this.constructor.set(this.#n,e,r),this}append(e,r){return this.#t&&this.#r.add(e),this.constructor.set(this.#n,e,r,!0),this}has(e){return this.#t&&!this.#r.has(e)?!1:this.constructor.get(this.#n,e)!==void 0}delete(e){if(this.#t&&!this.#r.has(e))return;let r=this.constructor.parsePath(e),n=r.pop(),s=r.length?this.constructor.get(this.#n,r):this.#n;v(s)&&O.deleteProperty(s,n)}sort(){return this.#o=!0,this}json(){return O.unproxy(this.#n)}stringify({prettyPrint:e=this.#e}={}){return this.constructor.stringify(this.#n,{only:this.#t&&this.#r,sorted:this.#o,prettyPrint:e})}toString(){return this.stringify()}entries(){let e=[];return this.constructor.reduceValue(this.#n,"",(r,n,s)=>{if(s)return s;if(this.#t&&!this.#r.has(n))if(/\[\d+\]$/.test(n)){if([,n]=/^(.*)\[\d+\]$/.exec(n),!this.#r.has(n)&&!this.#r.has(n=`${n}[]`))return}else return;this.#t&&typeof r=="number"&&(r=r+""),e.push([n,r])}),e[Symbol.iterator]()}keys(){return Array.from(this.entries(),([e])=>e)[Symbol.iterator]()}values(){return Array.from(this.entries(),([,e])=>e)[Symbol.iterator]()}forEach(e,r){for(let[n,s]of this.entries())e.call(r,s,n,this)}[Symbol.iterator](){return this.entries()}get size(){let e=0;return this.forEach(()=>e++),e}static parse(e,r=!1,n="&"){let s={};return(e.startsWith("?")?e.slice(1):e).split(n).filter(Boolean).forEach(i=>{let a=i.indexOf("="),o=a===-1?i:i.slice(0,a),f=a===-1?"":i.slice(a+1);this.set(s,o,f,!0,r)}),s}static fromEntries(e){let r={};for(let[n,s]of e)this.set(r,n,s,!0);return r}static stringify(e,{sorted:r=!1,only:n=null,prettyPrint:s=!1,delim:i="&"}={}){let a=[],o=Object.keys(e);return r&&o.sort(),o.forEach(f=>{this.reduceValue(e[f],f,(c,u,l)=>{if(l)return r?[...l].sort():l;if(n&&!n.has(u))if(/\[\d+\]$/.test(u)){if([,u]=/^(.*)\[\d+\]$/.exec(u),!n.has(u)&&!n.has(u=`${u}[]`))return}else return;s||(u=encodeURIComponent(u)),a.push(u+"="+encodeURIComponent(c))},!!s)}),a.join(i)}static get(e,r,n=!1){return this.reducePath(r,e,(s,i,a)=>a||(s===""?n?i:i?.[0]:i?.[s]))}static set(e,r,n,s=!1,i=!1){this.reducePath(r,e,(a,o,f)=>{let c=f??n;return i&&/^-?\d+(\.\d+)?$/.test(c+"")&&(c=parseFloat(c)),a===""&&Array.isArray(o)?O.proxy(o).push(c):s&&o?.[a]?Array.isArray(o[a])?O.proxy(o[a]).push(c):O.set(o,a,[o[a],c]):O.set(o,a,c),c})}static reduceValue(e,r,n,s=!1){if(x(e)){let i=Object.keys(e),a=n(e,r,i);if(Array.isArray(a)){a.forEach(o=>{s&&(o=encodeURIComponent(o)),this.reduceValue(e[o],r?`${r}[${o}]`:o,n,s)});return}}n(e,r)}static reducePath(e,r,n){let s=this.parsePath(e),i=r;for(let a=0;a<s.length;a++){let o=s[a];if(K(o)&&(o=+o),a===s.length-1)return n(o,i);if(!x(i))return;if(!x(i[o])){let f=s[a+1];i[o]=n(o,i,K(f)||f===""?[]:{})}i=i[o]}}static parsePath(e){if(Array.isArray(e))return e;if(!X(e))return[];let r=[];return e.replace(/\[([^\]]*)\]|([^[\]]+)/g,(n,s,i)=>{r.push(s??i)}),r}};var W=class t extends FormData{static upgradeInPlace(e){return e instanceof t?e:Object.setPrototypeOf(e,t.prototype)}static json(e={},{encodeLiterals:r=!0,meta:n=!1}={}){let s=new t,i=!0;return ce.reduceValue(e,"",(a,o,f=void 0)=>{if(f){let c=Ne(a)==="json";return i=i&&c,c&&f}r&&[!0,!1,null].includes(a)&&(a=new Blob([a+""],{type:"application/json"})),s.append(o,a)}),n?{result:s,isDirectlySerializable:i}:s}async json({decodeLiterals:e=!0,meta:r=!1}={}){let n=!0,s;for(let[i,a]of this.entries()){s||(s=K(Ie(i,"["))?[]:{});let o=Ne(a);if(e&&["Blob","File"].includes(o)&&a.type==="application/json"&&[4,5].includes(a.size)){let f=JSON.parse(await a.text());[null,!0,!1].includes(f)&&(a=f,o="json")}n=n&&o==="json",/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/.test(a)&&(a=Number(a)),ce.set(s,i,a)}return r?{result:s,isDirectlySerializable:n}:s}};var fe=(t,...e)=>k(t,"fetch+",...e),C=(t,...e)=>k(t,"fetch+","meta",...e);function Fe(t){return class extends t{static from(e){let r=e.headers instanceof Headers?[...e.headers.entries()].reduce((i,[a,o])=>{let f=a.toLowerCase();return i[f]=i[f]?[].concat(i[f],o):o,i},{}):Object.keys(e.headers||{}).reduce((i,a)=>(i[a.toLowerCase()]=e.headers[a],i),{}),n=e.body,s=Ne(n);if(["Blob","File"].includes(s))r["content-type"]??=n.type,r["content-length"]??=n.size;else if(["Uint8Array","Uint16Array","Uint32Array","ArrayBuffer"].includes(s))r["content-length"]??=n.byteLength;else if(s==="json"&&x(n)){let{result:i,isDirectlySerializable:a}=W.json(n,{encodeLiterals:!0,meta:!0});a?(n=JSON.stringify(n,(o,f)=>f instanceof Error?{...f,message:f.message}:f),r["content-type"]="application/json",r["content-length"]=new Blob([n]).size):(n=i,s="FormData")}else["text","json"].includes(s)&&!r["content-length"]&&(r["content-length"]=new Blob([n]).size);return!["FormData"].includes(s)&&!["function"].includes(typeof n)&&!r["content-type"]&&(r["content-type"]="application/octet-stream"),{body:n,headers:new Headers(r),$type:s}}async formData(){let e=await super.formData();return W.upgradeInPlace(e),e}async any({to:e=null,memo:r=!1}={}){if(e&&!["blob","text","json","arrayBuffer","bytes","formData"].includes(e))throw new Error(`Invalid target type specified: ${e}`);let n=C(this,"cache"),s=async o=>{if(!r)return await this[o||"bytes"]();let f=u=>{if(u instanceof FormData){let l=new W;for(let[p,m]of u.entries())l.append(p,m);return l}return(!o||o==="json")&&(Ke(u)||Je(u))?structuredClone(u):u};if(!o&&n.has("original"))return f(n.has("original"));if(o??="bytes",n.has(o))return f(n.get(o));let c;return n.has("memo")?c=n.get("memo").clone()[o]():(n.set("memo",this.clone()),c=await this[o]()),n.set(o,c),f(c)},i=(this.headers.get("Content-Type")||"").split(";")[0].trim(),a;if((!e||["formData","json"].includes(e))&&["multipart/form-data","application/x-www-form-urlencoded"].includes(i)){let o=await s("formData");W.upgradeInPlace(o),e==="json"&&(o=await o.json({decodeLiterals:!0})),a=o}else if((!e||["formData","json"].includes(e))&&i==="application/json"){let o=await s("json");e==="formData"&&(o=W.json(o,{encodeLiterals:!0})),a=o}else if(!e&&(i.startsWith("image/")||i.startsWith("video/")||i.startsWith("audio/")||i.startsWith("application/")&&!["xml","json","javascript","x-www-form-urlencoded"].some(o=>i.includes(o))))a=await s("blob");else if(!e&&(i.startsWith("text/")||i.startsWith("application/")&&["xml","javascript"].some(o=>i.includes(o))))a=await s("text");else{if(["json","formData"].includes(e))throw new Error(`Cannot convert body of type ${i} to ${e}`);a=await s(e)}return a}forget(){C(this,"cache").clear()}}}function Ne(t){if(t instanceof FormData)return"FormData";if(t===null||de(t)||Re(t))return"json";if(X(t))return"text";if(x(t)){let e=t[Symbol.toStringTag],r=["Uint8Array","Uint16Array","Uint32Array","ArrayBuffer","Blob","File","FormData","Stream","ReadableStream"].reduce((n,s)=>n||(e===s?s:null),null);if(r)return r;if(v(t)||Array.isArray(t))return"json";if("toString"in t)return"text"}return null}function nn(t){return t!==null&&typeof t=="object"&&typeof t.read=="function"&&typeof t.pipe=="function"&&typeof t.on=="function"}function At(t){return t instanceof ReadableStream||nn(t)}var z=class t extends Headers{static upgradeInPlace(e){return e instanceof t?e:Object.setPrototypeOf(e,t.prototype)}set(e,r){if(/^Set-Cookie$/i.test(e)){if(Array.isArray(r)){this.delete(e);for(let n of r)this.append(e,n);return}v(r)&&(r=Ct(r))}return/Cookie/i.test(e)&&(r=hr(r)),/^Content-Range$/i.test(e)&&(r=dr(r)),/^Range$/i.test(e)&&(r=pr(r)),/^Accept$/i.test(e)&&(r=mr(r)),super.set(e,r)}append(e,r){if(/^Set-Cookie$/i.test(e)){if(Array.isArray(r)){for(let n of r)this.append(e,n);return}v(r)&&(r=Ct(r))}return/Cookie/i.test(e)&&(r=hr(r)),/^Content-Range$/i.test(e)&&(r=dr(r)),/^Range$/i.test(e)&&(r=pr(r)),/^Accept$/i.test(e)&&(r=mr(r)),super.append(e,r)}get(e,r=!1){let n=super.get(e);if(/^Set-Cookie$/i.test(e)&&r&&(n=this.getSetCookie().map(s=>{let[i,...a]=s.split(";"),[o,f]=i.split("=").map(u=>u.trim()),c={name:o,value:f};return a.map(u=>u.trim().split("=")).forEach(u=>{c[u[0][0].toLowerCase()+u[0].substring(1).replace("-","")]=u.length===1?!0:u[1]}),c})),/^Cookie$/i.test(e)&&r&&(n=n?.split(";").map(s=>{let[i,a]=s.split("=").map(o=>o.trim());return{name:i,value:a}})||[]),/^Content-Range$/i.test(e)&&n&&r&&(n=me(n,"bytes ").split("/")),/^Range$/i.test(e)&&r&&(n=n?me(n,"bytes=").split(",").map(s=>{let i=s.trim().split("-").map(a=>a?parseInt(a,10):null);return i.resolveAgainst=a=>{let o=[...i];return o[1]===null?o[1]=a-1:o[1]=Math.min(o[1],a)-1,o[0]===null&&(o[0]=o[1]?a-o[1]-1:0),o},i.canResolveAgainst=(a,o)=>{let f=[typeof i[0]=="number"?i[0]:a,typeof i[1]=="number"?i[1]:o-1];return!(f[0]>f[1]||f[0]<a||f[1]>=o)},i.toString=()=>s,i}):[]),/^Accept$/i.test(e)&&n&&r){let s=a=>{let[o,f]=a.trim().split(";").map(c=>c.trim());return[o,parseFloat((f||"q=1").replace("q=",""))]},i=n;n=n.split(",").map(a=>s(a)).sort((a,o)=>a[1]>o[1]?-1:1)||[],n.match=a=>{if(!a)return 0;let o=c=>c.split("/").map(u=>u.trim()),f=o(a+"");return n.reduce((c,[u,l])=>{if(c)return c;let p=o(u);return[0,1].every(m=>f[m]===p[m]||f[m]==="*"||p[m]==="*")?l:0},0)},n.toString=()=>i}return n}};function Ct(t){let e=[`${t.name}=${t.value}`];for(let r in t){if(["name","value"].includes(r))continue;let n=r[0].toUpperCase()+r.substring(1);n==="MaxAge"&&(n="Max-Age"),e.push(t[r]===!0?n:`${n}=${t[r]}`)}return e.join("; ")}function hr(t){return x(t)&&(t=[].concat(t).map(Ct).join("; ")),t}function pr(t){let e=[];return H(t).forEach((r,n)=>{let s=Array.isArray(r)?r.map(i=>[null,void 0].includes(i)?"":i).join("-"):r+"";n===0&&!s.includes("bytes=")&&(s=`bytes=${s}`),e.push(s)}),e.join(", ")}function dr(t){if(Array.isArray(t)){if(t.length<2||!t[0].includes("-"))throw new Error("A Content-Range array must be in the format: [ 'start-end', 'total' ]");t=`bytes ${t.join("/")}`}return t}function mr(t){return Array.isArray(t)&&(t=t.map(e=>Array.isArray(e)?e.map((r,n)=>n===1&&(r=parseFloat(r),!0)?r===1?"":`;q=${r}`:r.trim()).join(""):e.trim()).join(",")),t}var V=class t extends Fe(Response){constructor(e,r={}){super(e,r),z.upgradeInPlace(this.headers)}static upgradeInPlace(e){return e instanceof t||(Object.setPrototypeOf(e,t.prototype),z.upgradeInPlace(e.headers)),e}static from(e,{memoize:r=!1,...n}={}){if(e instanceof Response)return e;let s;if(typeof e<"u"){let a;({body:e,headers:a,$type:s}=super.from({body:e,headers:n.headers})),n={...n,headers:a}}let i=new this(e,n);if(r){let a=C(i,"cache"),o={json:"json",FormData:"formData",text:"text",ArrayBuffer:"arrayBuffer",Blob:"blob",Bytes:"bytes"};a.set(o[s]||"original",e)}return i}get status(){return C(this).get("status")??super.status}clone(){let e=super.clone();t.upgradeInPlace(e);let r=C(this);return fe(e).set("meta",new Map(r)),C(e).has("cache")&&C(e).set("cache",new Map(r.get("cache"))),e}};async function gr(t,e={}){let r=await fetch(t,e);return V.upgradeInPlace(r),r}var He=class t extends Fe(Request){constructor(e,r={}){super(e,r),z.upgradeInPlace(this.headers)}static upgradeInPlace(e){return e instanceof t||(Object.setPrototypeOf(e,t.prototype),z.upgradeInPlace(e.headers)),e}static from(e,{memoize:r=!1,...n}={}){if(e instanceof Request)return e;let s,i=n.body;if("body"in n){let{body:o,headers:f,$type:c}=super.from(n);n={...n,body:o,headers:f},s=c}let a=new this(e,n);if(r){let o=C(a,"cache"),f={json:"json",FormData:"formData",text:"text",ArrayBuffer:"arrayBuffer",Blob:"blob",Bytes:"bytes"};o.set(f[s]||"original",i)}return a}static async copy(e,r={}){let s=["method","headers","mode","credentials","cache","redirect","referrer","integrity"].reduce((i,a)=>({...i,[a]:a in r?r[a]:a==="headers"?new Headers(e[a]):e[a]}),{});return["GET","HEAD"].includes(s.method.toUpperCase())?s.body=null:"body"in r?(s.body=r.body,"headers"in r||(s.headers.delete("Content-Type"),s.headers.delete("Content-Length"))):s.body=await e.clone().arrayBuffer(),s.mode==="navigate"&&(s.mode="cors"),{url:r.url||e.url,...s}}clone(){let e=super.clone();t.upgradeInPlace(e);let r=C(this);return fe(e).set("meta",new Map(r)),C(e).has("cache")&&C(e).set("cache",new Map(r.get("cache"))),e}};var R=class extends MessageEvent{#n;get originalTarget(){return this.#n}#t;get eventID(){return this.#t}#r;get data(){return this.#r}#e;get live(){return this.#e}#o;get bubbles(){return this.#o}#a;get forwarded(){return this.#a}#i;get honourDoneMutationFlags(){return this.#i}#f=[];get ports(){return this.#f}constructor(e,{originalTarget:r=null,type:n="message",eventID:s,live:i=!1,honourDoneMutationFlags:a=!1,bubbles:o=!1,forwarded:f=!1,ports:c=[]}={}){if(n&&typeof n!="string")throw new TypeError("Where specified, wqEventOptions.type must be a string");super(n),this.#r=e,this.#n=r,this.#t=s,this.#e=i,this.#o=o,this.#a=f,this.#i=a,this.#f=c;let u=this.#n&&G(this.#n)||{};if(this.#f.forEach(l=>$.upgradeInPlace(l,{autoStart:u.autoStart,postAwaitsOpen:u.postAwaitsOpen})),x(this.#r)&&this.#e){if(typeof s!="string")throw new TypeError("eventID must be a non-empty string");Mt.call(r,this.#r,this.#t,{honourDoneMutationFlags:this.#i})}}#h=!1;get immediatePropagationStopped(){return this.#h}stopImmediatePropagation(){this.#h=!0,this.#c=!0,super.stopImmediatePropagation()}#c=!1;get propagationStopped(){return this.#c}stopPropagation(){this.#c=!0,super.stopPropagation()}#s=!1;get defaultPrevented(){return this.#s}preventDefault(){this.#s=!0,super.preventDefault()}respondWith(e,r=[]){for(let n of this.#f)n.postMessage(e,r);return!!this.#f.length}};var ue=class extends Be(EventTarget){#n;constructor(e,{autoStart:r=!0,naturalOpen:n=!0,postAwaitsOpen:s=!1}={}){if(super(),this.#n=typeof e=="string"?new WebSocket(e):e,M(this).set("options",{autoStart:r,naturalOpen:n,postAwaitsOpen:s}),this.constructor.upgradeEvents(this.#n,this),n&&r&&this.#n.readyState===WebSocket.OPEN&&this.start(),this.#n.readyState===WebSocket.CLOSED)try{this.close()}catch{}}static _hydrateMessage(e,r){try{let n;if(typeof r.data=="string"&&v(n=JSON.parse(r.data))&&n[".wq"])return Object.defineProperty(r,"data",{value:n,configurable:!0}),super._hydrateMessage(e,r)}catch{}return r}__postMessage(e,r){this.#n.send(JSON.stringify(e),r)}};var yr=(t,...e)=>k(t,"port+",...e),M=(t,...e)=>k(t,"port+","meta",...e),G=t=>k(t,"port+","meta").get("options")||{},wr=["addEventListener","addRequestListener","postMessage","postRequest","dispatchEvent","relay","start","readyStateChange","removeEventListener","close"],br=["options","readyState","onmessage","onmessageerror"],$=class extends xr(EventTarget){constructor(e={}){super(),yr(this,"meta").set("options",e)}static[Symbol.hasInstance](e){return Function.prototype[Symbol.hasInstance].call(this,e)?!0:wr.every(r=>typeof e[r]=="function")||br.every(r=>r in e)}};function xr(t){return class extends t{static upgradeInPlace(e,r={}){if(e instanceof $)return e;let n=this.prototype;for(let i of wr){let a=e[i],o=n[i];a&&Object.defineProperty(e,`_${i}`,{value:a.bind(e),configurable:!0}),Object.defineProperty(e,i,{value:o.bind(e),configurable:!0})}for(let i of br){let a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),i),o=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(n),i);a&&Object.defineProperty(e,`_${i}`,{...a,configurable:!0}),Object.defineProperty(e,i,{...o,configurable:!0})}return yr(e,"meta").set("options",r),this.upgradeEvents(e),e}static upgradeEvents(e,r=null){r||(r=e);let n=M(e);if(n.get("events+"))return;let s=M(r),i=G(r),a=le.call(r),o=xe.call(r);e instanceof BroadcastChannel&&(i.clientServerMode==="server"?s.set("clients",new Set):i.clientServerMode==="client"&&s.set("client_id",`client-${(0|Math.random()*9e6).toString(36)}`));let f=l=>{if(l instanceof R)return;if(e===r&&l.stopImmediatePropagation?.(),l=this._hydrateMessage?.(r,l)||l,l.data.ping==="connect"&&typeof l.data?.[".wq"]?.eventID=="string"&&(!(e instanceof WebSocket)||!i.naturalOpen)){let g=!0;e instanceof BroadcastChannel&&(i.clientServerMode==="server"&&typeof l.data.id=="string"?(s.get("clients").add(l.data.id),g="server"):l.data.id==="server"&&s.has("client_id")&&(g=s.get("client_id"))),l.ports?.forEach(b=>b.postMessage(g)),s.set("remote.start.called",!0),r.start();return}if(l.data.ping==="disconnect"&&typeof l.data?.[".wq"]?.eventID=="string"){let g=()=>{s.set("remote.close.called",!0),r.close()};e instanceof BroadcastChannel?i.clientServerMode==="server"&&typeof l.data.id=="string"?(s.get("clients").delete(l.data.id),!s.get("clients").size&&i.autoClose&&!o.close.state&&g()):i.clientServerMode==="client"&&l.data.id==="server"&&g():e instanceof MessagePort&&g();return}let p=l.data,m={};typeof l.data?.[".wq"]?.eventID=="string"&&({message:p,".wq":m}=l.data);let h=new R(p,{originalTarget:e,...m,ports:l.ports});r.dispatchEvent(h)},c=l=>{e instanceof WebSocket&&i.naturalOpen&&!(l instanceof R)&&(s.set("remote.start.called",!0),r.start())},u=l=>{(e instanceof WebSocket||e instanceof MessagePort)&&!(l instanceof R)&&(s.set("remote.close.called",!0),r.close())};n.set("internal_call",!0),e.addEventListener("message",f),e.addEventListener("error",f),e.addEventListener("open",c),e.addEventListener("close",u),n.delete("internal_call"),n.set("events+",!0),a.add(()=>{e.removeEventListener("message",f),e.removeEventListener("error",f),e.removeEventListener("open",c),e.removeEventListener("close",u),n.set("events+",!1)})}get options(){return{...G(this)}}get onmessageerror(){return typeof super.onmessageerror<"u"?super.onmessageerror:typeof this._onmessageerror<"u"?this._onmessageerror:null}set onmessageerror(e){if(typeof super.onmessageerror<"u"){super.onmessageerror=e;return}if(e!==null&&typeof e!="function")throw new TypeError("onmessageerror must be a function");if(Object.getOwnPropertyDescriptor(this,"_onmessageerror")?.set){this._onmessageerror=e;return}this._onmessageerror&&this.removeEventListener("messageerror",this._onmessageerror),this.addEventListener("messageerror",e),this._onmessageerror=e}get onmessage(){return typeof super.onmessage<"u"?super.onmessage:typeof this._onmessage<"u"?this._onmessage:null}set onmessage(e){let r=M(this),n=G(this);if(!r.get("internal_call")&&n.autoStart&&this.start(),typeof super.onmessage<"u"){super.onmessage=e;return}if(e!==null&&typeof e!="function")throw new TypeError("onmessage must be a function");if(Object.getOwnPropertyDescriptor(this,"_onmessage")?.set){this._onmessage=e;return}this._onmessage&&this.removeEventListener("message",this._onmessage),this.addEventListener("message",e),this._onmessage=e}addEventListener(...e){let r=M(this),n=G(this);return!r.get("internal_call")&&n.autoStart&&this.start(),le.call(this).add(()=>{this._removeEventListener?this._removeEventListener(...e):super.removeEventListener(...e)}),this._addEventListener?this._addEventListener(...e):super.addEventListener(...e)}dispatchEvent(e){let r=this._dispatchEvent?this._dispatchEvent(e):super.dispatchEvent(e);return e instanceof R&&sn.call(this,e),r}postMessage(e,r={}){let n=M(this),s=G(this);!n.get("internal_call")&&s.autoStart&&this.start();let i=xe.call(this);i.messaging.state=!0,i.messaging.resolve(this);let a,{portOptions:o,wqOptions:{relayedFrom:f,...c}}=We.call(this,e,r);(c.type!=="message"||c.live||c.bubbles||o.transfer?.length&&(this instanceof BroadcastChannel||this instanceof ue))&&(e={message:e,".wq":c}),r=o,a=f;let u=()=>{this._postMessage?this._postMessage(e,r,a):super.postMessage(e,r)};s.postAwaitsOpen?i.open.promise.then(u):u()}addRequestListener(e,r,n={}){let s=async i=>{let a=await r(i);for(let o of i.ports)o.postMessage(a)};this.addEventListener(e,s,n)}postRequest(e,r,n={}){let s;v(r)&&(n={once:!0,...r},s=new Promise(u=>{r=u}));let i=new MessageChannel;this.constructor.upgradeEvents(i.port1),i.port1.start();let{signal:a=null,once:o=!1,transfer:f=[],...c}=n;return i.port1.addEventListener("message",u=>r(u),{signal:a,once:o}),a?.addEventListener("abort",()=>{i.port1.close(),i.port2.close()}),this.postMessage(e,{...c,transfer:[i.port2].concat(f)}),s}relay({to:e,from:r,types:n="*",channel:s=null,resolveMessage:i=null,bidirectional:a=!1}={}){if(e&&r)throw new Error('Only one of "to" and "from" may be specified');if(r?e=this:r=this,e===r)throw new Error("Source and target ports cannot be the same");if(!(r instanceof $)||!(e instanceof $))throw new Error("Both source and target ports must be instance of MessagePortPlus.");if(typeof n!="function"&&!(n=[].concat(n)).length)throw new Error("Event types must be specified.");if(typeof s=="string")s={from:s};else if(v(s)){if(Object.keys(s).filter(u=>!["from","to"].includes(u)).length)throw new Error('Channel must be a string or an object of "from"/"to" members')}else if(s)throw new Error("Invalid channel parameter");let o=_r.call(r),f={targetPort:e,types:n,channel:s,resolveMessage:i};o.add(f);let c;return a&&(c=e.relay({to:r,types:n,channel:s&&{to:s.from,from:s.to},resolveMessage:i,bidirectional:!1})),()=>{o.delete(f),c?.()}}channel(e,r=null){let n=new MessageChannel;return $.upgradeInPlace(n.port1,{autoStart:this.options.autoStart,postAwaitsOpen:this.options.postAwaitsOpen}),$.upgradeInPlace(n.port2,{autoStart:this.options.autoStart,postAwaitsOpen:this.options.postAwaitsOpen}),le.call(this).add(this.relay({channel:e,to:n.port1,bidirectional:!0,resolveMessage:r})),n.port1.start(),this.readyStateChange("close").then(()=>{n.port1.close()}),n.port2}projectMutations({from:e,to:r,...n}){if(!e||!r||typeof e=="string"&&typeof r=="string"||x(e)&&x(r))throw new Error('Invalid "from"/"to" parameters');if(typeof e=="string"){if(!x(r))throw new Error('Invalid "to" parameter. Object/array expected');return Mt.call(this,r,e,n)}if(typeof r=="string"){if(!x(e))throw new Error('Invalid "from" parameter. Object/array expected');return vr.call(this,e,r,n)}throw new Error('Invalid "from"/"to" parameters')}get readyState(){let e=xe.call(this);return e.close.state?"closed":e.open.state?"open":"connecting"}readyStateChange(e){if(!["open","messaging","close"].includes(e))throw new Error(`Invalid readyState query "${e}"`);return xe.call(this)[e].promise}start(){let e=xe.call(this);if(e.open.state)return;let r,n=()=>{if(e.open.state)return;e.open.state=!0,e.open.resolve(this);let c=new R(null,{type:"open"});this._dispatchEvent?this._dispatchEvent(c):super.dispatchEvent(c),r?.port1.close(),r?.port2.close()},s=M(this),i=G(this);if(s.get("remote.start.called")){n();return}if(s.get("start.called"))return;s.set("start.called",!0),this._start?this._start():super.start?.(),r=new MessageChannel,r.port1.onmessage=c=>{this instanceof BroadcastChannel&&i.clientServerMode==="server"&&typeof c.data=="string"&&s.get("clients").add(c.data),n()};let{wqOptions:a}=We.call(this),o=i.clientServerMode==="server"?"server":i.clientServerMode==="client"?s.get("client_id"):null,f={".wq":a,ping:"connect",id:o};this._postMessage?this._postMessage(f,{transfer:[r.port2]}):super.postMessage(f,{transfer:[r.port2]})}close(...e){let r=xe.call(this);if(r.close.state)return;r.close.state=!0;let n=M(this),s=G(this);if(!n.get("remote.close.called")&&(this instanceof BroadcastChannel||this instanceof MessagePort)){let{wqOptions:a}=We.call(this),o=s.clientServerMode==="server"?"server":s.clientServerMode==="client"?n.get("client_id"):null,f={".wq":a,ping:"disconnect",id:o};this._postMessage?this._postMessage(f):super.postMessage(f)}this._close?this._close(...e):super.close(...e),r.close.resolve(this);let i=new R(null,{type:"close"});this._dispatchEvent?this._dispatchEvent(i):super.dispatchEvent(i),on.call(this)}}}function Be(t){return class extends xr(t){static _hydrateMessage(e,r){if(typeof r.data?.[".wq"]?.numPorts!="number"||typeof r.data[".wq"].eventID!="string")return r;let n=le.call(e),s=r.data[".wq"].numPorts;Object.defineProperty(r,"ports",{value:[],configurable:!0});for(let i=0;i<s;i++){let a=e.channel(`${r.data[".wq"].eventID}:${i}`);r.ports.push(a)}return r}_postMessage(e,r={}){let{transfer:n=[],...s}=r;if(typeof e?.[".wq"]?.eventID=="string"){let i=le.call(this),a=n.filter(f=>f instanceof MessagePort),o=a.length;for(let f=0;f<o;f++)$.upgradeInPlace(a[f]),i.add(this.relay({channel:`${e[".wq"].eventID}:${f}`,to:a[f],bidirectional:!0})),a[f].start(),a[f].readyStateChange("close").then(()=>{let{wqOptions:c}=We.call(this),u={".wq":c,ping:"disconnect"};this.postMessage(u,{type:`${e[".wq"].eventID}:${f}:message`})});e[".wq"].numPorts=o}return this.__postMessage(e,s)}}}function sn(t){if(t.propagationStopped)return;let e=M(this);e.get("parentNode")instanceof EventTarget&&(t.bubbles||e.get("parentNode")?.findPort?.(n=>n===this)&&t instanceof R)&&e.get("parentNode").dispatchEvent(t);let r=_r.call(this);if(r.size&&t instanceof R){let{type:n,eventID:s,data:i,live:a,bubbles:o,ports:f}=t,c=new WeakSet;for(let{targetPort:u,types:l,channel:p,resolveMessage:m}of r){if(c.has(u))continue;let h=n;p.from&&([,h]=new RegExp(`^${p.from.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}:([^:]+)$`).exec(n)||[],!h)||!(typeof l=="function"?l(h,this,u,p):[].concat(l).find(b=>b===h||b==="*"))||(c.add(u),u.postMessage(m?m(i,this,u,p):i,{transfer:f,type:p.to?`${p.to}:${h}`:h,eventID:s,bubbles:o,live:a,forwarded:!0,relayedFrom:this}))}}}function le(){let t=M(this);return t.has("garbage_collection")||t.set("garbage_collection",new Set),t.get("garbage_collection")}function _r(){let t=M(this);return t.has("downstream_registry")||t.set("downstream_registry",new Set),t.get("downstream_registry")}function xe(){let t=M(this);if(!t.has("readystate_registry")){let e=r=>(r.promise=new Promise((n,s)=>(r.resolve=n,r.reject=s)),r);t.set("readystate_registry",{open:e({}),messaging:e({}),close:e({})})}return t.get("readystate_registry")}function on(){let t=M(this);for(let e of t.get("garbage_collection")||[])e instanceof AbortController?e.abort():typeof e=="function"&&e();t.get("garbage_collection")?.clear(),t.get("downstream_registry")?.clear()}function We(t=void 0,e={}){if(Array.isArray(e))e={transfer:e};else if(!e||typeof e!="object")throw new TypeError("transferOrOptions must be an array or an object");let{type:r="message",eventID:n=null,live:s=!1,observing:i=!1,bubbles:a=!1,forwarded:o=!1,relayedFrom:f=null,signal:c=null,withArrayMethodDescriptors:u=!1,honourDoneMutationFlags:l=!1,...p}=e;return n||(n=`${r}-${(0|Math.random()*9e6).toString(36)}`),!i&&!o&&x(t)&&s&&!r?.endsWith(".mutate")&&(vr.call(this,t,n,{signal:c,withArrayMethodDescriptors:u,honourDoneMutationFlags:l}),i=!0),{portOptions:p,wqOptions:{type:r,eventID:n,live:s,observing:i,honourDoneMutationFlags:l,bubbles:a,forwarded:o,relayedFrom:f}}}function vr(t,e,{signal:r,withArrayMethodDescriptors:n=!0,honourDoneMutationFlags:s=!1}={}){if(!x(t))throw new TypeError("data must be a plain object and not a stream");if(typeof e!="string")throw new TypeError("eventID must be a non-empty string");let i=f=>{let c;n&&Array.isArray(f[0].target)&&!f[0].argumentsList&&!["set","defineProperty","deleteProperty"].includes(f[0].operation)||(this.postMessage(f.map(u=>(c=!c&&s&&u.detail?.done,{...u,target:void 0})),{type:`${e}.mutate`}),c&&a.abort())},a=O.observe(t,O.subtree(),i,{signal:r,withArrayMethodDescriptors:n});return le.call(this).add(a),a}function Mt(t,e,{signal:r,honourDoneMutationFlags:n=!1}={}){if(!x(t))throw new TypeError("data must be a plain object and not a stream");if(typeof e!="string")throw new TypeError("eventID must be a non-empty string");let s=o=>{if(!o.data?.length)return;let f;O.batch(t,()=>{for(let c of o.data){if(f=!f&&n&&c.detail?.done,c.argumentsList){let u=c.path.length?O.get(t,O.path(...c.path)):t;O.proxy(u)[c.operation](...c.argumentsList);continue}if(c.key!=="length"||["set","defineProperty","deleteProperty"].includes(c.operation)){let u=c.path.length===1?t:O.get(t,O.path(...c.path.slice(0,-1)));c.type==="delete"?O.deleteProperty(u,c.key):O.set(u,c.key,c.value)}}}),f&&i()};this.addEventListener(`${e}.mutate`,s,{signal:r});let i=()=>this.removeEventListener(`${e}.mutate`,s);return le.call(this).add(i),i}var $e=class extends Be(BroadcastChannel){constructor(e,{autoStart:r=!0,postAwaitsOpen:n=!1,clientServerMode:s=null,autoClose:i=!0}={}){super(e);let a=M(this);if(s&&!["server","client"].includes(s))throw new Error('clientServerMode must be "server" or "client"');a.set("options",{autoStart:r,postAwaitsOpen:n,clientServerMode:s,autoClose:i}),this.constructor.upgradeEvents(this)}__postMessage(e,r){BroadcastChannel.prototype.postMessage.call(this,e)}};var ze=class t extends EventTarget{static get xHeaderName(){return"X-Message-Port"}static test(e){return e instanceof t||e?.[Symbol.toStringTag]==="LiveResponse"?"LiveResponse":e?.[Symbol.toStringTag]==="LiveProgramHandle"?"LiveProgramHandle":e instanceof Response?"Response":cn(e)?"Generator":"Default"}static hasPort(e){return!!e.headers?.get?.(this.xHeaderName)?.trim()}static getPort(e,r=!1){if(!/Response/.test(this.test(e)))return;let n=C(e);if(!n.has("port")){let s=e.headers.get(this.xHeaderName)?.trim();if(!s)return;let[,i,a]=/^(socket|channel):\/\/(.*)$/.exec(s)||[];if(!i||!a)throw new Error(`Unknown port messaging protocol: ${s}`);let o=i==="channel"?new $e(a,{autoStart:r,postAwaitsOpen:!0,clientServerMode:"client"}):new ue(a,{autoStart:r,naturalOpen:!1,postAwaitsOpen:!0});n.set("port",o)}return n.get("port")}static attachPort(e,r){if(!(r instanceof $))throw new Error("Client must be a MessagePortPlus interface");C(e).set("port",r)}static from(e,...r){return this.test(e)==="LiveResponse"?e.clone(...r):new this(e,...r)}[Symbol.toStringTag]="LiveResponse";#n;constructor(e,...r){super(),this.#n=L.getInstance(this,!0);let s=_e.call(this).now;this.#u(s,e,...r).catch(i=>{s.reject(i)})}#t=null;get body(){return this.#t}#r=!1;get concurrent(){return this.#r}get bodyUsed(){return!0}#e=new Headers;get headers(){return this.#e}#o=200;get status(){return this.#o}#a="";get statusText(){return this.#a}#i="basic";get type(){return this.#i}#f=!1;get redirected(){return this.#f}#h=null;get url(){return this.#h}get ok(){return this.#o>=200&&this.#o<299}async now(){return _e.call(this).now.promise}get port(){return this.constructor.getPort(this,!0)}#c=new AbortController;#s=new AbortController;get readyState(){let e=_e.call(this);return e.done.state?"done":e.live.state?"live":"waiting"}readyStateChange(e){if(!["live","now","done"].includes(e))throw new Error(`Invalid readyState query "${e}"`);return _e.call(this)[e].promise}disconnect(e=!1){this.#c.abort(),this.#c=new AbortController,e&&(this.#s.abort(),this.#s=new AbortController)}#d;#g(e){let r=_e.call(this);if(r.done.state)throw new Error("Response already done.");return this.#d=e,e.then(n=>{this.#d===e&&(this.#d=null,r.done.state=!0,r.done.resolve(n))}).catch(n=>{this.#d===e&&(this.#d=null,r.done.state=!0,r.done.reject(n))}),e}async replaceWith(e,...r){if(this.readyState==="done")throw new Error("Response already done.");this.disconnect(),await this.#u(null,e,...r)}async#u(e,r,...n){let s=_e.call(this),i=e||s.now.refresh();if(r instanceof Promise)return this.#g(new Promise((m,h)=>{this.#c.signal.addEventListener("abort",()=>{i.aborted=!0,m()}),r.then(async g=>{await this.#u(i,g,...n),m()}).catch(g=>h(g))}));let a=(m,h)=>{if(h=Object.freeze({...h,ok:h.status>=200&&h.status<299,bodyUsed:!0}),m?.aborted){m.resolve(h);return}let g=m||s.now.refresh(),b=h.body;this.#o=h.status,this.#a=h.statusText;for(let[d]of[...this.#e.entries()])this.#e.delete(d);for(let[d,P]of h.headers.entries())this.#e.append(d,P);this.#i=h.type,this.#f=h.redirected,this.#h=h.url;let _=this.#t;this.#t=b,this.#r=!!h.concurrent,this.#r||(this.#s.abort(),this.#s=new AbortController);let w=new A(this,{type:"set",key:"body",value:b,oldValue:_,isUpdate:!0,related:[],operation:"set",detail:null});s.live.state=!0,s.live.resolve(this),g.resolve(h),this.#n.emit([w]),this.dispatchEvent(new $t(h))},o=(m,h,g)=>{a(m,{body:h,status:200,statusText:"",...g,headers:g.headers instanceof Headers?g.headers:new Headers(g.headers||{}),type:"basic",redirected:!1,url:null})},f=async(m,h,g)=>{let b,_=!1;try{b=h instanceof Response?await V.prototype.any.call(h,{to:"json"}):(await h.readyStateChange("live")).body,_=!0}catch{b=await V.prototype.any.call(h)}if(a(m,{body:b,status:h.status,statusText:h.statusText,headers:h.headers,concurrent:h.concurrent,...g,type:h.type,redirected:h.redirected,url:h.url}),this.constructor.test(h)==="LiveResponse"){let w=()=>{o(null,h.body,h)};return h.addEventListener("replace",w,{signal:this.#c.signal}),await h.readyStateChange("done"),h.removeEventListener("replace",w),h}if(this.constructor.hasPort(h)){let w=this.constructor.getPort(h);return w.start(),_&&w.projectMutations({from:"initial_response",to:b,signal:this.#s.signal}),new Promise(d=>{let P=E=>{let{body:U,...N}=E.data;o(null,U,{...N})};w.addEventListener("response.replace",P,{signal:this.#c.signal}),w.addEventListener("response.done",()=>{w.removeEventListener("response.replace",P),d(this)},{once:!0}),w.readyStateChange("close").then(d)})}},c=async(m,h,g)=>{let b=await h.next(),_=await b.value;await this.#u(m,_,{done:b.done,...g});let w=b,d=_;for(;!w.done&&!this.#c.signal.aborted;)w=await h.next(),d=await w.value,this.#c.signal.aborted||await this.#u(null,d,{concurrent:g.concurrent,done:g.done===!1?!1:w.done})},u=async(m,h,g)=>(await this.#u(m,h.value,g),O.observe(h,"value",b=>this.#u(null,b.value,{concurrent:g.concurrent,done:!1}),{signal:this.#c.signal}),new Promise(()=>{})),l=typeof n[0]=="function"?n.shift():null,p=v(n[0])?{...n.shift()}:{};if("status"in p&&(p.status=parseInt(p.status),p.status<200||p.status>599))throw new Error(`The status provided (${p.status}) is outside the range [200, 599].`);if("statusText"in p&&(p.statusText=String(p.statusText)),p.headers&&!(p.headers instanceof Headers)&&(p.headers=new Headers(p.headers)),"concurrent"in p&&(p.concurrent=!!p.concurrent),/Response/.test(this.constructor.test(r))){if(l)throw new Error("frameClosure is not supported for responses.");i.donePromise=f(i,r,p)}else if(this.constructor.test(r)==="Generator"){if(l)throw new Error("frameClosure is not supported for generators.");i.donePromise=c(i,r,p)}else if(this.constructor.test(r)==="LiveProgramHandle"){if(l)throw new Error("frameClosure is not supported for live program handles.");i.donePromise=u(i,r,p)}else if(i.donePromise=Promise.resolve(o(i,r,p)),l){let m=x(r)&&!At(r)?O.proxy(r,{chainable:!0,membrane:r}):r;i.donePromise=Promise.resolve(l.call(this,m,this.#s.signal))}return this.#g(p.done===!1?new Promise(()=>{}):i.donePromise),await new Promise((m,h)=>{this.#c.signal.addEventListener("abort",()=>m(!1)),i.donePromise.then(()=>m(!0)).catch(h)})}toResponse({port:e,signal:r}={}){if(e&&!(e instanceof $))throw new Error("Client must be a MessagePortPlus interface");let n=V.from(this.body,{status:this.#o,statusText:this.#a,headers:this.#e}),s=C(this);if(fe(n).set("meta",s),!e)return n;x(this.#t)&&!At(this.#t)&&e.projectMutations({from:this.#t,to:"initial_response",signal:AbortSignal.any([this.#s.signal].concat(r||[]))});let i=()=>{let a=Object.fromEntries([...this.headers.entries()]);a?.["set-cookie"]&&(delete a["set-cookie"],console.warn('Warning: The "set-cookie" header is not supported for security reasons and has been removed from the response.')),e.postMessage({body:this.#t,status:this.#o,statusText:this.#a,headers:a,concurrent:this.#r},{type:"response.replace",live:!0,signal:AbortSignal.any([this.#s.signal].concat(r||[]))})};return this.addEventListener("replace",i,{signal:r}),this.readyStateChange("done").then(()=>{e.postMessage(null,{type:"response.done"})}),n}async*toGenerator({signal:e}={}){do yield this.body;while(await new Promise(r=>{this.addEventListener("replace",()=>r(!0),{once:!0,signal:e}),this.readyStateChange("done").then(()=>r(!1))}))}toLiveProgramHandle({signal:e}={}){let r=new jt,n=()=>O.defineProperty(r,"value",{value:this.body,enumerable:!1,configurable:!0});return this.addEventListener("replace",n,{signal:e}),n(),r}clone(e={}){let r=new this.constructor,n=C(this);return fe(r).set("meta",new Map(n)),r.replaceWith(this,e),r}},cn=t=>typeof t?.next=="function"&&typeof t?.throw=="function"&&typeof t?.return=="function";function _e(){let t=C(this);if(!t.has("readystate_registry")){let e=n=>(n.promise=new Promise((s,i)=>(n.resolve=s,n.reject=i)),n),r={live:e({}),done:e({})};(function n(){return r.now=e({}),r.now.refresh=n,r.now})(),t.set("readystate_registry",r)}return t.get("readystate_registry")}var $t=class extends Event{#n;get data(){return this.#n}constructor(e){super("replace"),this.#n=e}},jt=class{[Symbol.toStringTag]="LiveProgramHandle";abort(){}};globalThis.webqit||(globalThis.webqit={});Object.assign(globalThis.webqit,Rt);})();
2
2
  //# sourceMappingURL=main.js.map