@webqit/fetch-plus 0.1.32 → 0.1.33

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