@muze-nl/jsfs-solid 0.1.0 → 0.1.2

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.
@@ -1,2 +1,39 @@
1
- (()=>{var Ze=Object.defineProperty;var Qe=(e,t)=>{for(var r in t)Ze(e,r,{get:t[r],enumerable:!0})};var x=class e{#e;constructor(t){this.#e=e.collapse(t)}get value(){return this.#e}toString(){return this.#e}get length(){return this.#e.length}static collapse(t,r=""){if(t instanceof e)return t.value;if(typeof t!="string")throw new TypeError("path argument must be a string or an instance of Path");if(r&&!(r instanceof e)&&(r=new e(r)),t=t.trim(),t.length===0)return r.value;e.isRelative(t)&&(t=r+t);let n=e.reduce(t,(i,s)=>(s==".."?i.pop():s!=="."&&i.push(s),i),[]),o="/";return n.length&&(o+=n.join("/"),e.isFolder(t)&&(o+="/")),o}static isAbsolute(t){return t instanceof e?!0:t.length&&t[0]==="/"}static isRelative(t){return!e.isAbsolute(t)}static isFolder(t){return t instanceof e&&(t=t.value),t.length&&t[t.length-1]=="/"}static isPath(t){return t instanceof e?!0:typeof t!="string"?!1:(t=t.trim(),new URL(t,document.location).pathname==t)}static reduce(t,r,n){return t instanceof e&&(t=t.value),t.split("/").filter(Boolean).reduce(r,n)}static map(t,r){return t instanceof e&&(t=t.value),t.split("/").filter(Boolean).map(r)}static parent(t){t instanceof e&&(t=t.value),t=t.split("/").filter(Boolean),t.pop();let r="/";return t.length&&(r+=t.join("/")+"/"),r}static filename(t){return t instanceof e&&(t=t.value),t.split("/").filter(Boolean).pop()}static head(t){return t instanceof e&&(t=t.value),t.split("/").filter(Boolean).shift()}static tail(t){t instanceof e&&(t=t.value),t=t.split("/").filter(Boolean),t.shift();let r="/";return t.length&&(r+=t.join("/")+"/"),r}};var V=class e{#e;#r;#o;#t;constructor(t,r="/",n=null,o={}){this.#e=new URL(t,window.location.href),this.#r=new x(r),this.#o=n,this.#t=o}get name(){return"HttpAdapter"}get path(){return this.#r}supportsWrite(){return!0}supportsStreamingWrite(){return Xe}supportsStreamingRead(){return!0}cd(t){if(!x.isPath(t))throw new TypeError(t+" is not a valid path");return new e(this.#e.href,t)}async write(t,r,n=null){let o=Object.assign({},this.#t,{method:"PUT",body:r});return this.#n(t,o)}writeStream(t,r,n=null){throw new Error("Not yet implemented")}async read(t){let r=Object.assign({},this.#t,{method:"GET"}),n=await this.#n(t,r),o={type:this.#s(n),name:x.filename(t),http:{headers:n.headers,status:n.status,url:n.url}};return o.type.match(/text\/.*/)?o.contents=await n.text():o.type.match(/application\/json.*/)?o.contents=await n.json():o.contents=await n.blob(),o}readStream(t,r){throw new Error("Not yet implemented")}async exists(t){let r=Object.assign({},this.#t,{method:"HEAD"});return this.#n(t,r)}async delete(t){let r=Object.assign({},this.#t,{method:"DELETE"});return this.#n(t,r)}async list(t){let r=["text/html","text/xhtml","text/xhtml+xml","text/xml"],n=await this.read(t);if(r.includes(n.type.split(";")[0]))var o=n.contents;else{let d=this.#i(t);throw new TypeError("URL "+d+" is not of a supported content type",{cause:n})}let i=x.collapse(this.#e.pathname),s=this.#i(t),a=document.createElement("template");a.innerHTML=o;let p=a.content.querySelectorAll("a[href]");return Array.from(p).map(d=>{let u=new URL(d.getAttribute("href"),s.href);return d.href=u.href,{filename:x.filename(d.pathname),path:d.pathname,name:d.innerText,href:d.href}}).filter(d=>{let u=new URL(d.href);return u.pathname=x.parent(u.pathname),u.href===s.href}).map(d=>({filename:d.filename,path:d.path.substring(i.length-1),name:d.name}))}#i(t){return t=x.collapse(this.#e.pathname+x.collapse(t)),new URL(t,this.#e)}async#n(t,r){return fetch(this.#i(t),r).catch(n=>{if(!this.#o||!this.#o(url,r,n))throw n})}#s(t){return t.headers.has("Content-Type")?t.headers.get("Content-Type"):null}},Xe=(async()=>new Request("",{body:new ReadableStream,method:"POST",duplex:"half"}).headers.has("Content-Type")?!1:fetch("data:a/a;charset=utf-8,",{method:"POST",body:new ReadableStream,duplex:"half"}).then(()=>!0,()=>!1))();var B={};Qe(B,{Client:()=>v,client:()=>T,deepClone:()=>z,formdata:()=>Pe,metroError:()=>g,request:()=>F,response:()=>I,trace:()=>et,url:()=>_});var D="https://metro.muze.nl/details/";Symbol.metroProxy||(Symbol.metroProxy=Symbol("isProxy"));Symbol.metroSource||(Symbol.metroSource=Symbol("source"));var v=class e{clientOptions={url:_(typeof window<"u"?window.location:"https://localhost"),verbs:["get","post","put","delete","patch","head","options","query"]};static tracers={};constructor(...t){for(let r of t)if(typeof r=="string"||r instanceof String)this.clientOptions.url=_(this.clientOptions.url.href,r);else if(r instanceof Function)this.#e([r]);else if(r&&typeof r=="object")for(let n in r)n=="middlewares"?this.#e(r[n]):n=="url"?this.clientOptions.url=_(this.clientOptions.url.href,r[n]):typeof r[n]=="function"?this.clientOptions[n]=r[n](this.clientOptions[n],this.clientOptions):this.clientOptions[n]=r[n];for(let r of this.clientOptions.verbs)this[r]=async function(...n){return this.fetch(F(this.clientOptions,...n,{method:r.toUpperCase()}))}}#e(t){typeof t=="function"&&(t=[t]);let r=t.findIndex(n=>typeof n!="function");if(r>=0)throw g("metro.client: middlewares must be a function or an array of functions "+D+"client/invalid-middlewares/",t[r]);Array.isArray(this.clientOptions.middlewares)||(this.clientOptions.middlewares=[]),this.clientOptions.middlewares=this.clientOptions.middlewares.concat(t)}fetch(t,r){if(t=F(t,r),!t.url)throw g("metro.client."+t.method.toLowerCase()+": Missing url parameter "+D+"client/fetch-missing-url/",t);if(r||(r={}),typeof r!="object"||r instanceof String)throw g("metro.client.fetch: Invalid options parameter "+D+"client/fetch-invalid-options/",r);let o=[async function(a){a[Symbol.metroProxy]&&(a=a[Symbol.metroSource]);let p=await fetch(a);return I(p)}].concat(this.clientOptions?.middlewares?.slice()||[]);r=Object.assign({},this.clientOptions,r);let i;for(let s of o)i=(function(a,p){return async function(d){let u,f=Object.values(e.tracers);for(let l of f)l.request&&l.request.call(l,d,p);u=await p(d,a);for(let l of f)l.response&&l.response.call(l,u,p);return u}})(i,s);return i(t)}with(...t){return new e(z(this.clientOptions),...t)}get location(){return this.clientOptions.url}};function T(...e){return new v(...z(e))}function qe(e,t){let r=t||{};!r.url&&t.url&&(r.url=t.url);for(let n of["method","headers","body","mode","credentials","cache","redirect","referrer","referrerPolicy","integrity","keepalive","signal","priority","url"]){let o=e[n];if(!(typeof o>"u"||o==null))if(o?.[Symbol.metroProxy]&&(o=o[Symbol.metroSource]),typeof o=="function")r[n]=o(r[n],r);else if(n=="url")r.url=_(r.url,o);else if(n=="headers"){r.headers=new Headers(t.headers),o instanceof Headers||(o=new Headers(e.headers));for(let[i,s]of o.entries())r.headers.set(i,s)}else r[n]=o}return e instanceof Request&&e.data&&(r.body=e.data),r}function F(...e){let t={url:_(typeof window<"u"?window.location:"https://localhost/"),duplex:"half"};for(let o of e)typeof o=="string"||o instanceof URL||o instanceof URLSearchParams?t.url=_(t.url,o):o&&(o instanceof FormData||o instanceof ReadableStream||o instanceof Blob||o instanceof ArrayBuffer||o instanceof DataView)?t.body=o:o&&typeof o=="object"&&Object.assign(t,qe(o,t));let r=new Request(t.url,t),n=t.body;return n&&typeof n=="object"&&!(n instanceof String)&&!(n instanceof ReadableStream)&&!(n instanceof Blob)&&!(n instanceof ArrayBuffer)&&!(n instanceof DataView)&&!(n instanceof FormData)&&!(n instanceof URLSearchParams)&&(typeof globalThis.TypedArray>"u"||!(n instanceof globalThis.TypedArray))&&typeof n.toString=="function"&&(t.body=n.toString({headers:r.headers}),r=new Request(t.url,t)),Object.freeze(r),new Proxy(r,{get(o,i){let s;switch(i){case Symbol.metroSource:s=o;break;case Symbol.metroProxy:s=!0;break;case"with":s=function(...a){return n&&a.unshift({body:n}),F(o,...a)};break;case"data":s=n;break;default:o[i]instanceof Function?s=o[i].bind(o):s=o[i];break}return s}})}function Ae(e,t){let r=t||{};!r.url&&t.url&&(r.url=t.url);for(let n of["status","statusText","headers","body","url","type","redirected"]){let o=e[n];typeof o>"u"||o==null||(o?.[Symbol.metroProxy]&&(o=o[Symbol.metroSource]),typeof o=="function"?r[n]=o(r[n],r):n=="url"?r.url=new URL(o,r.url||"https://localhost/"):r[n]=o)}return e instanceof Response&&e.data&&(r.body=e.data),r}function I(...e){let t={};for(let o of e)typeof o=="string"?t.body=o:o instanceof Response?Object.assign(t,Ae(o,t)):o&&typeof o=="object"&&(o instanceof FormData||o instanceof Blob||o instanceof ArrayBuffer||o instanceof DataView||o instanceof ReadableStream||o instanceof URLSearchParams||o instanceof String||typeof globalThis.TypedArray<"u"&&o instanceof globalThis.TypedArray?t.body=o:Object.assign(t,Ae(o,t)));let r;t.body&&(r=t.body),[101,204,205,304].includes(t.status)&&(t.body=null);let n=new Response(t.body,t);return Object.freeze(n),new Proxy(n,{get(o,i){let s;switch(i){case Symbol.metroProxy:s=!0;break;case Symbol.metroSource:s=o;break;case"with":s=function(...a){return I(o,...a)};break;case"data":s=r;break;case"ok":s=o.status>=200&&o.status<400;break;default:typeof o[i]=="function"?s=o[i].bind(o):s=o[i];break}return s}})}function ve(e,t){typeof t=="function"?t(e.searchParams,e):(t=new URLSearchParams(t),t.forEach((r,n)=>{e.searchParams.append(n,r)}))}function _(...e){let t=["hash","host","hostname","href","password","pathname","port","protocol","username","search","searchParams"],r=new URL("https://localhost/");for(let n of e)if(typeof n=="string"||n instanceof String)r=new URL(n,r);else if(n instanceof URL||typeof Location<"u"&&n instanceof Location)r=new URL(n);else if(n instanceof URLSearchParams)ve(r,n);else if(n&&typeof n=="object")for(let o in n)switch(o){case"search":typeof n.search=="function"?n.search(r.search,r):r.search=new URLSearchParams(n.search);break;case"searchParams":ve(r,n.searchParams);break;default:if(!t.includes(o))throw g("metro.url: unknown url parameter "+D+"url/unknown-param-name/",o);if(typeof n[o]=="function")n[o](r[o],r);else if(typeof n[o]=="string"||n[o]instanceof String||typeof n[o]=="number"||n[o]instanceof Number||typeof n[o]=="boolean"||n[o]instanceof Boolean)r[o]=""+n[o];else if(typeof n[o]=="object"&&n[o].toString)r[o]=n[o].toString();else throw g("metro.url: unsupported value for "+o+" "+D+"url/unsupported-param-value/",e[o]);break}else throw g("metro.url: unsupported option value "+D+"url/unsupported-option-value/",n);return Object.freeze(r),new Proxy(r,{get(n,o){let i;switch(o){case Symbol.metroProxy:i=!0;break;case Symbol.metroSource:i=n;break;case"with":i=function(...s){return _(n,...s)};break;case"filename":i=n.pathname.split("/").pop();break;case"folderpath":i=n.pathname.substring(0,n.pathname.lastIndexOf("\\")+1);break;case"authority":i=n.username??"",i+=n.password?":"+n.password:"",i+=i?"@":"",i+=n.hostname,i+=n.port?":"+n.port:"",i+="/",i=n.protocol+"//"+i;break;case"origin":i=n.protocol+"//"+n.hostname,i+=n.port?":"+n.port:"",i+="/";break;case"fragment":i=n.hash.substring(1);break;case"scheme":n.protocol?i=n.protocol.substring(0,n.protocol.length-1):i="";break;default:n[o]instanceof Function?i=n[o].bind(n):i=n[o];break}return i}})}function Pe(...e){var t=new FormData;for(let r of e)if(r instanceof HTMLFormElement&&(r=new FormData(r)),r instanceof FormData)for(let n of r.entries())t.append(n[0],n[1]);else if(r&&typeof r=="object")for(let n of Object.entries(r))if(Array.isArray(n[1]))for(let o of n[1])t.append(n[0],o);else t.append(n[0],n[1]);else throw new g("metro.formdata: unknown option type "+D+"formdata/unknown-option-value/",r);return Object.freeze(t),new Proxy(t,{get(r,n){let o;switch(n){case Symbol.metroProxy:o=!0;break;case Symbol.metroSource:o=r;break;case"with":o=function(...i){return Pe(r,...i)};break;default:r[n]instanceof Function?o=r[n].bind(r):o=r[n];break}return o}})}var W={error:(e,...t)=>{console.error("\u24C2\uFE0F ",e,...t)},info:(e,...t)=>{console.info("\u24C2\uFE0F ",e,...t)},group:e=>{console.group("\u24C2\uFE0F "+e)},groupEnd:e=>{console.groupEnd("\u24C2\uFE0F "+e)}};function g(e,...t){return W.error(e,...t),new Error(e,...t)}var et={add(e,t){v.tracers[e]=t},delete(e){delete v.tracers[e]},clear(){v.tracers={}},group(){let e=0;return{request:(t,r)=>{e++,W.group(e),W.info(t?.url,t,r)},response:(t,r)=>{W.info(t?.body?t.body[Symbol.metroSource]:null,t,r),W.groupEnd(e),e--}}}};function z(e){if(Array.isArray(e))return e.slice().map(z);if(e&&typeof e=="object")if(e.__proto__.constructor==Object||!e.__proto__){let t=Object.assign({},e);return Object.keys(t).forEach(r=>{t[r]=z(e[r])}),t}else return e;return e}function re(){return async function(t,r){let n=await r(t);return n.ok&&n.data?n.data:n}}function R(e){return e=Object.assign({contentType:"application/json",reviver:null,replacer:null,space:""},e),async function(r,n){if(r.headers.get("Accept")||(r=r.with({headers:{Accept:e.accept??e.contentType}})),r.method!=="GET"&&r.method!=="HEAD"&&r.data&&typeof r.data=="object"&&!(r.data instanceof ReadableStream)){let i=r.headers.get("Content-Type");(!i||rt(i))&&(r=r.with({headers:{"Content-Type":e.contentType}})),je(r.headers.get("Content-Type"))&&(r=r.with({body:JSON.stringify(r.data,e.replacer,e.space)}))}let o=await n(r);if(je(o.headers.get("Content-Type"))){let s=await o.clone().text();try{let a=JSON.parse(s,e.reviver);return o.with({body:a})}catch{}}return o}}var tt=/^application\/([a-zA-Z0-9\-_]+\+)?json\b/;function je(e){return tt.exec(e)}function rt(e){return/^text\/plain\b/.exec(e)}function O(e){return async function(r,n){let o=await n(r);if(!o.ok)if(e&&typeof e[o.status]=="function")o=e[o.status].apply(o,r);else throw new Error(o.status+": "+o.statusText,{cause:o});return o}}var ne=class extends v{constructor(t,r,n=null){t instanceof v?super(t.clientOptions,O(),re()):super(t,O(),re()),n||(n=this);for(let o in r)typeof r[o]=="function"?this[o]=r[o].bind(n):r[o]&&typeof r[o]=="object"?this[o]=new this.constructor(t,r[o],n):this[o]=r[o]}},fe=class extends ne{constructor(t,r,n=null){t instanceof v?super(t.with(R()),r,n):super(T(t,R()),r,n)}};function Te(...e){return new ne(...z(e))}function Re(...e){return new fe(...z(e))}var Oe=Object.assign({},B,{mw:{jsonmw:R,thrower:O},api:Te,jsonApi:Re});globalThis.metro||(globalThis.metro=Oe);var E=Oe;globalThis.assertEnabled=!1;function b(e,t){if(globalThis.assertEnabled){let r=A(e,t);if(r)throw console.error("\u{1F170}\uFE0F Assertions failed because of:",r,"in this source:",e),new Error("Assertions failed",{cause:{problems:r,source:e}})}}function c(e){return function(r,n,o){if(typeof r<"u"&&r!=null&&typeof e<"u")return A(r,e,n,o)}}function m(e){return function(r,n,o){return r==null||typeof r>"u"?w("data is required",r,e||"any value",o):typeof e<"u"?A(r,e,n,o):!1}}function $(e){return function(r,n,o){return r==null||typeof r>"u"?(nt("data does not contain recommended value",r,e,o),!1):A(r,e,n,o)}}function S(...e){return function(r,n,o){for(let i of e)if(!A(r,i,n,o))return!1;return w("data does not match oneOf patterns",r,e,o)}}function H(...e){return function(r,n,o){if(!Array.isArray(r))return w("data is not an array",r,"anyOf",o);for(let i of r)if(S(...e)(i))return w("data does not match anyOf patterns",i,e,o);return!1}}function Ee(...e){return function(r,n,o){let i=[];for(let s of e)i=i.concat(A(r,s,n,o));if(i=i.filter(Boolean),i.length)return w("data does not match all given patterns",r,e,o,i)}}function h(e,t,r){try{e instanceof URL&&(e=e.href);let n=new URL(e);if(n.href!=e&&!(n.href+"/"==e||n.href==e+"/"))return w("data is not a valid url",e,"validURL",r)}catch{return w("data is not a valid url",e,"validURL",r)}}function Le(e,t,r){if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))return w("data is not a valid email",e,"validEmail",r)}function K(e){return function(r,n,o){if(!(r instanceof e))return w("data is not an instanceof pattern",r,e,o)}}function G(e){return function(r,n,o){if(!A(r,e,n,o))return w("data matches pattern, when required not to",r,e,o)}}function A(e,t,r,n=""){r||(r=e);let o=[];if(t===Boolean)typeof e!="boolean"&&!(e instanceof Boolean)&&o.push(w("data is not a boolean",e,t,n));else if(t===Number)typeof e!="number"&&!(e instanceof Number)&&o.push(w("data is not a number",e,t,n));else if(t===String)typeof e!="string"&&!(e instanceof String)&&o.push(w("data is not a string",e,t,n)),e==""&&o.push(w("data is an empty string, which is not allowed",e,t,n));else if(t instanceof RegExp)if(Array.isArray(e)){let i=e.findIndex((s,a)=>A(s,t,r,n+"["+a+"]"));i>-1&&o.push(w("data["+i+"] does not match pattern",e[i],t,n+"["+i+"]"))}else typeof e>"u"?o.push(w("data is undefined, should match pattern",e,t,n)):t.test(e)||o.push(w("data does not match pattern",e,t,n));else if(t instanceof Function){let i=t(e,r,n);i&&(Array.isArray(i)?o=o.concat(i):o.push(i))}else if(Array.isArray(t)){Array.isArray(e)||o.push(w("data is not an array",e,[],n));for(let i of t)for(let s of e.keys()){let a=A(e[s],i,r,n+"["+s+"]");Array.isArray(a)?o=o.concat(a):a&&o.push(a)}}else if(t&&typeof t=="object")if(Array.isArray(e)){let i=e.findIndex((s,a)=>A(s,t,r,n+"["+a+"]"));i>-1&&o.push(w("data["+i+"] does not match pattern",e[i],t,n+"["+i+"]"))}else if(!e||typeof e!="object")o.push(w("data is not an object, pattern is",e,t,n));else if(e instanceof URLSearchParams&&(e=Object.fromEntries(e)),t instanceof Function){let i=A(e,t,r,n);i&&(o=o.concat(i))}else for(let[i,s]of Object.entries(t)){let a=A(e[i],s,r,n+"."+i);a&&(o=o.concat(a))}else t!=e&&o.push(w("data and pattern are not equal",e,t,n));return o.length?o:!1}function w(e,t,r,n,o){let i={path:n,message:e,found:t,expected:r};return o&&(i.problems=o),i}function nt(e,t,r,n){console.warn("\u{1F170}\uFE0F Assert: "+n,e,r,t)}function Ue(e){let t,r;if(typeof localStorage<"u")t={get:()=>localStorage.getItem("metro/state:"+e),set:n=>localStorage.setItem("metro/state:"+e,n),has:()=>localStorage.getItem("metro/state:"+e)!==null,delete:()=>localStorage.remoteItem("metro/state:"+e)},r={get:n=>JSON.parse(localStorage.getItem(e+":"+n)),set:(n,o)=>localStorage.setItem(e+":"+n,JSON.stringify(o)),has:n=>localStorage.getItem(e+":"+n)!==null,delete:n=>localStorage.removeItem(e+":"+n)};else{let n=new Map;t={get:()=>n.get("metro/state:"+e),set:o=>n.set("metro/state:"+e,o),has:()=>n.has("metro/state:"+e),delete:()=>n.delete("metro/state:"+e)},r=new Map}return{state:t,tokens:r}}function de(e){let t={client:T(),force_authorization:!1,site:"default",oauth2_configuration:{authorization_endpoint:"/authorize",token_endpoint:"/token",redirect_uri:globalThis.document?.location.href,grant_type:"authorization_code",code_verifier:it(64)},authorize_callback:async u=>(window.location.href!=u.href&&window.location.replace(u.href),!1)};b(e,{});let r=Object.assign({},t.oauth2_configuration,e?.oauth2_configuration);e=Object.assign({},t,e),e.oauth2_configuration=r;let n=Ue(e.site);e.tokens||(e.tokens=n.tokens),e.state||(e.state=n.state),b(e,{oauth2_configuration:{client_id:m(/.+/),grant_type:"authorization_code",authorization_endpoint:m(h),token_endpoint:m(h),redirect_uri:m(h)}});for(let u in r)switch(u){case"access_token":case"authorization_code":case"refresh_token":e.tokens.set(u,r[u]);break}return async function(u,f){if(e.force_authorization)return o(u,f);let l;try{if(l=await f(u),l.ok)return l}catch(y){switch(l?.status){case 400:case 401:return o(u,f)}throw y}if(!l.ok)switch(l.status){case 400:case 401:return o(u,f)}return l};async function o(u,f){i();let l=e.tokens.get("access_token"),y=e.tokens.get("refresh_token"),k=ot(l);if(!l||k&&!y){try{if(!await s())return I("false")}catch(j){throw j}return o(u,f)}else if(k&&y){try{if(!await a())return I("false")}catch(j){throw j}return o(u,f)}else return u=F(u,{headers:{Authorization:l.type+" "+l.value}}),f(u)}function i(){if(typeof window<"u"&&window?.location){let u=_(window.location),f,l,y;if(u.searchParams.has("code"))y=u.searchParams,u=u.with({search:""}),history.pushState({},"",u.href);else if(u.hash){let k=u.hash.substr(1);y=new URLSearchParams("?"+k),u=u.with({hash:""}),history.pushState({},"",u.href)}if(y){f=y.get("code"),l=y.get("state");let k=e.state.get("metro/state");if(!l||l!==k)return;f&&e.tokens.set("authorization_code",f)}}}async function s(){if(r.grant_type==="authorization_code"&&!e.tokens.has("authorization_code")){let y=await p();if(!e.authorize_callback||typeof e.authorize_callback!="function")throw g("oauth2mw: oauth2 with grant_type:authorization_code requires a callback function in client options.authorize_callback");let k=await e.authorize_callback(y);if(k)e.tokens.set("authorization_code",k);else return!1}let u=d(),f=await e.client.post(u);if(!f.ok){let y=await f.text();throw g("OAuth2mw: fetch access_token: "+f.status+": "+f.statusText,{cause:u})}let l=await f.json();if(e.tokens.set("access_token",{value:l.access_token,expires:ze(l.expires_in),type:l.token_type,scope:l.scope}),l.refresh_token){let y={value:l.refresh_token};e.tokens.set("refresh_token",y)}return e.tokens.delete("authorization_code"),l}async function a(){let u=d("refresh_token"),f=await e.client.post(u);if(!f.ok)throw g("OAuth2mw: refresh access_token: "+f.status+": "+f.statusText,{cause:u});let l=await f.json();if(e.tokens.set("access_token",{value:l.access_token,expires:ze(l.expires_in),type:l.token_type,scope:l.scope}),l.refresh_token){let y={value:l.refresh_token};e.tokens.set("refresh_token",y)}else return!1;return l}async function p(){if(!r.authorization_endpoint)throw g("oauth2mw: Missing options.oauth2_configuration.authorization_endpoint");let u=_(r.authorization_endpoint,{hash:""});b(r,{client_id:/.+/,redirect_uri:/.+/,scope:/.*/});let f={response_type:"code",client_id:r.client_id,redirect_uri:r.redirect_uri,state:r.state||at(40)};return r.response_type&&(f.response_type=r.response_type),r.response_mode&&(f.response_mode=r.response_mode),e.state.set(f.state),r.client_secret&&(f.client_secret=r.client_secret),r.code_verifier&&(e.tokens.set("code_verifier",r.code_verifier),f.code_challenge=await st(r.code_verifier),f.code_challenge_method="S256"),r.scope&&(f.scope=r.scope),r.prompt&&(f.prompt=r.prompt),_(u,{search:f})}function d(u=null){if(b(r,{client_id:/.+/,redirect_uri:/.+/}),!r.token_endpoint)throw g("oauth2mw: Missing options.endpoints.token url");let f=_(r.token_endpoint,{hash:""}),l={grant_type:u||r.grant_type,client_id:r.client_id};switch(r.client_secret&&(l.client_secret=r.client_secret),r.scope&&(l.scope=r.scope),l.grant_type){case"authorization_code":l.redirect_uri=r.redirect_uri,l.code=e.tokens.get("authorization_code");let y=e.tokens.get("code_verifier");y&&(l.code_verifier=y);break;case"client_credentials":break;case"refresh_token":let k=e.tokens.get("refresh_token");l.refresh_token=k.value;break;default:throw new Error("Unknown grant_type: ".oauth2.grant_type)}return F(f,{method:"POST",body:new URLSearchParams(l)})}}function ot(e){if(!e)return!0;let t=new Date(e.expires);return new Date().getTime()>t.getTime()}function ze(e){if(e instanceof Date)return new Date(e.getTime());if(typeof e=="number"){let t=new Date;return t.setSeconds(t.getSeconds()+e),t}throw new TypeError("Unknown expires type "+e)}function it(e=64){let t=new Uint8Array(e);return globalThis.crypto.getRandomValues(t),Ce(t)}async function st(e){let r=new TextEncoder().encode(e),n=await globalThis.crypto.subtle.digest("SHA-256",r);return Ce(n)}function Ce(e){let t=Array.from(new Uint8Array(e),r=>String.fromCharCode(r)).join("");return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function at(e){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r="",n=0;for(;n<e;)r+=t.charAt(Math.floor(Math.random()*t.length)),n++;return r}function Ne(){let e=new URL(document.location.href);if(!e.searchParams.has("code")){if(e.hash){let t=e.hash.substr(1);if(params=new URLSearchParams("?"+t),params.has("code"))return!0}return!1}return!0}function pe(){return new Promise((e,t)=>{let r=globalThis.indexedDB.open("metro",1);r.onupgradeneeded=()=>r.result.createObjectStore("keyPairs",{keyPath:"domain"}),r.onerror=n=>{t(n)},r.onsuccess=n=>{let o=n.target.result;e({set:function(i,s){return new Promise((a,p)=>{let d=o.transaction("keyPairs","readwrite",{durability:"strict"}),u=d.objectStore("keyPairs");d.oncomplete=()=>{a()},d.onerror=p,u.put(i,s)})},get:function(i){return new Promise((s,a)=>{let p=o.transaction("keyPairs","readonly"),u=p.objectStore("keyPairs").get(i);u.onsuccess=()=>{s(u.result)},u.onerror=a,p.onerror=a})},clear:function(){return new Promise((i,s)=>{let a=o.transaction("keyPairs","readwrite"),d=a.objectStore("keyPairs").clear();d.onsuccess=()=>{i()},d.onerror=s,a.onerror=s})}})}})}var ut=new TextEncoder,lt=new TextDecoder;function oe(e){return typeof e=="string"?ut.encode(e):lt.decode(e)}function De(e){if(typeof e.modulusLength!="number"||e.modulusLength<2048)throw new he(`${e.name} modulusLength must be at least 2048 bits`)}function ft(e){switch(e.algorithm.name){case"ECDSA":return{name:e.algorithm.name,hash:"SHA-256"};case"RSA-PSS":return De(e.algorithm),{name:e.algorithm.name,saltLength:32};case"RSASSA-PKCS1-v1_5":return De(e.algorithm),{name:e.algorithm.name};case"Ed25519":return{name:e.algorithm.name}}throw new C}async function dt(e,t,r){if(r.usages.includes("sign")===!1)throw new TypeError('private CryptoKey instances used for signing assertions must include "sign" in their "usages"');let n=`${Y(oe(JSON.stringify(e)))}.${Y(oe(JSON.stringify(t)))}`,o=Y(await crypto.subtle.sign(ft(r),r,oe(n)));return`${n}.${o}`}var Fe=32768;function pt(e){e instanceof ArrayBuffer&&(e=new Uint8Array(e));let t=[];for(let r=0;r<e.byteLength;r+=Fe)t.push(String.fromCharCode.apply(null,e.subarray(r,r+Fe)));return btoa(t.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function Y(e){return pt(e)}function ht(){return Y(crypto.getRandomValues(new Uint8Array(32)))}var C=class extends Error{constructor(t){super(t??"operation not supported"),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}},he=class extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};function mt(e){switch(e.algorithm.hash.name){case"SHA-256":return"PS256";default:throw new C("unsupported RsaHashedKeyAlgorithm hash name")}}function yt(e){switch(e.algorithm.hash.name){case"SHA-256":return"RS256";default:throw new C("unsupported RsaHashedKeyAlgorithm hash name")}}function wt(e){switch(e.algorithm.namedCurve){case"P-256":return"ES256";default:throw new C("unsupported EcKeyAlgorithm namedCurve")}}function gt(e){switch(e.algorithm.name){case"RSA-PSS":return mt(e);case"RSASSA-PKCS1-v1_5":return yt(e);case"ECDSA":return wt(e);case"Ed25519":return"EdDSA";default:throw new C("unsupported CryptoKey algorithm name")}}function Ie(e){return e instanceof CryptoKey}function _t(e){return Ie(e)&&e.type==="private"}function bt(e){return Ie(e)&&e.type==="public"}function xt(){return Math.floor(Date.now()/1e3)}async function ie(e,t,r,n,o,i){let s=e?.privateKey,a=e?.publicKey;if(!_t(s))throw new TypeError('"keypair.privateKey" must be a private CryptoKey');if(!bt(a))throw new TypeError('"keypair.publicKey" must be a public CryptoKey');if(a.extractable!==!0)throw new TypeError('"keypair.publicKey.extractable" must be true');if(typeof t!="string")throw new TypeError('"htu" must be a string');if(typeof r!="string")throw new TypeError('"htm" must be a string');if(n!==void 0&&typeof n!="string")throw new TypeError('"nonce" must be a string or undefined');if(o!==void 0&&typeof o!="string")throw new TypeError('"accessToken" must be a string or undefined');if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))throw new TypeError('"additional" must be an object');return dt({alg:gt(s),typ:"dpop+jwt",jwk:await St(a)},{...i,iat:xt(),jti:ht(),htm:r,nonce:n,htu:t,ath:o?Y(await crypto.subtle.digest("SHA-256",oe(o))):void 0},s)}async function St(e){let{kty:t,e:r,n,x:o,y:i,crv:s}=await crypto.subtle.exportKey("jwk",e);return{kty:t,crv:s,e:r,n,x:o,y:i}}async function Be(e,t){let r;if(typeof e!="string"||e.length===0)throw new TypeError('"alg" must be a non-empty string');switch(e){case"PS256":r={name:"RSA-PSS",hash:"SHA-256",modulusLength:t?.modulusLength??2048,publicExponent:new Uint8Array([1,0,1])};break;case"RS256":r={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",modulusLength:t?.modulusLength??2048,publicExponent:new Uint8Array([1,0,1])};break;case"ES256":r={name:"ECDSA",namedCurve:"P-256"};break;case"EdDSA":r={name:"Ed25519"};break;default:throw new C}return crypto.subtle.generateKey(r,t?.extractable??!1,["sign","verify"])}function me(e){return b(e,{site:m(h),authorization_endpoint:m(h),token_endpoint:m(h),dpop_signing_alg_values_supported:c([])}),async(t,r)=>{let n=await pe(),o=await n.get(e.site);if(!o){let a=await Be("ES256");o={domain:e.site,keyPair:a},await n.set(o)}let i=E.url(t.url);if(t.url.startsWith(e.authorization_endpoint)){let a=t.body;a instanceof URLSearchParams||a instanceof FormData?a.set("dpop_jkt",o.keyPair.publicKey):a.dpop_jkt=o.keyPair.publicKey}else if(t.url.startsWith(e.token_endpoint)){let a=await ie(o.keyPair,t.url,t.method);t=t.with({headers:{DPoP:a}})}else if(t.headers.has("Authorization")){let a=localStorage.getItem(i.host+":nonce")||void 0,p=t.headers.get("Authorization").split(" ")[1],d=await ie(o.keyPair,t.url,t.method,a,p);t=t.with({headers:{Authorization:"DPoP "+p,DPoP:d}})}let s=await r(t);return s.headers.get("DPoP-Nonce")&&localStorage.setItem(i.host+":nonce",s.headers.get("DPoP-Nonce")),s}}var Z=(...e)=>(t,r)=>e.filter(n=>r.hasOwnKey(n)).length>0?!1:w("root data must have all of",r,e),N=(...e)=>t=>Array.isArray(t)&&e.filter(r=>!t.includes(r)).length==0?!1:w("data must be an array which includes",t,e);var P=["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512"],se=["client_secret_post","client_secret_basic","client_secret_jwt","private_key_jwt"];async function Q(e={}){b(e,{client:c(K(E.client().constructor)),issuer:m(h)});let t={client:E.client().with(O()).with(R()),requireDynamicRegistration:!1};e=Object.assign({},t,e);let r=!1;function n(p){return r}let o={issuer:m(Ee(e.issuer,n)),authorization_endpoint:m(h),token_endpoint:m(h),userinfo_endpoint:$(h),jwks_uri:m(h),registration_endpoint:e.requireDynamicRegistration?m(h):$(h),scopes_supported:$(N("openid")),response_types_supported:e.requireDynamicRegistration?m(N("code","id_token","id_token token")):m([]),response_modes_supported:c([]),grant_types_supported:e.requireDynamicRegistration?c(N("authorization_code")):c([]),acr_values_supported:c([]),subject_types_supported:m([]),id_token_signing_alg_values_supported:m(N("RS256")),id_token_encryption_alg_values_supported:c([]),id_token_encryption_enc_values_supported:c([]),userinfo_signing_alg_values_supported:c([]),userinfo_encryption_alg_values_supported:c([]),userinfo_encryption_enc_values_supported:c([]),request_object_signing_alg_values_supported:c(N("RS256")),request_object_encryption_alg_values_supported:c([]),request_object_encryption_enc_values_supported:c([]),token_endpoint_auth_methods_supported:c(H(...se)),token_endpoint_auth_signing_alg_values_supported:c(N("RS256"),G(N("none"))),display_values_supported:c(H("page","popup","touch","wap")),claim_types_supported:c(H("normal","aggregated","distributed")),claims_supported:$([]),service_documentation:c(h),claims_locales_supported:c([]),ui_locales_supported:c([]),claims_parameter_supported:c(Boolean),request_parameter_supported:c(Boolean),request_uri_parameter_supported:c(Boolean),op_policy_uri:c(h),op_tos_uri:c(h)},i=E.url(e.issuer,".well-known/openid-configuration"),a=(await e.client.get(i)).data;return b(a,o),b(a.issuer,e.issuer),a}async function X(e){let t={redirect_uris:m([h]),response_types:c([]),grant_types:c(H("authorization_code","refresh_token")),application_type:c(S("native","web")),contacts:c([Le]),client_name:c(String),logo_uri:c(h),client_uri:c(h),policy_uri:c(h),tos_uri:c(h),jwks_uri:c(h,G(Z("jwks"))),jwks:c(h,G(Z("jwks_uri"))),sector_identifier_uri:c(h),subject_type:c(String),id_token_signed_response_alg:c(S(...P)),id_token_encrypted_response_alg:c(S(...P)),id_token_encrypted_response_enc:c(S(...P),Z("id_token_encrypted_response_alg")),userinfo_signed_response_alg:c(S(...P)),userinfo_encrypted_response_alg:c(S(...P)),userinfo_encrypted_response_enc:c(S(...P),Z("userinfo_encrypted_response_alg")),request_object_signing_alg:c(S(...P)),request_object_encryption_alg:c(S(...P)),request_object_encryption_enc:c(S(...P)),token_endpoint_auth_method:c(S(...se)),token_endpoint_auth_signing_alg:c(S(...P)),default_max_age:c(Number),require_auth_time:c(Boolean),default_acr_values:c([String]),initiate_login_uri:c([h]),request_uris:c([h])};b(e,{client:c(K(E.client().constructor)),registration_endpoint:h,client_info:t});let r={client:E.client().with(O()).with(R()),client_info:{redirect_uris:[globalThis.document?.location.href]}};e=Object.assign({},r,e),e.client_info||(e.client_info={}),e.client_info.redirect_uris||(e.client_info.redirect_uris=[globalThis.document?.location.href]);let n=await e.client.post(e.registration_endpoint,{body:e.client_info}),o=n.data;if(!o.client_id||!o.client_secret)throw E.metroError("metro.oidc: Error: dynamic registration of client failed, no client_id or client_secret returned",n);return e.client_info=Object.assign(e.client_info,o),e.client_info}function ae(e){let t;if(typeof localStorage<"u")t={get:r=>JSON.parse(localStorage.getItem("metro/oidc:"+e+":"+r)),set:(r,n)=>localStorage.setItem("metro/oidc:"+e+":"+r,JSON.stringify(n)),has:r=>localStorage.getItem("metro/oidc:"+e+":"+r)!==null};else{let r=new Map;t={get:n=>JSON.parse(r.get("metro/oidc:"+e+":"+n)||null),set:(n,o)=>r.set("metro/oidc:"+e+":"+n,JSON.stringify(o)),has:n=>r.has("metro/oidc:"+e+":"+n)}}return t}function ye(e={}){let t={client:T(),force_authorization:!1,use_dpop:!0,authorize_callback:async r=>(window.location.href!=r.href&&window.location.replace(r.href),!1)};return e=Object.assign({},t,e),b(e,{client:m(K(T().constructor)),client_info:m(),issuer:m(h),oauth2:c({}),openid_configuration:c()}),e.store||(e.store=ae(e.issuer)),!e.openid_configuration&&e.store.has("openid_configuration")&&(e.openid_configuration=e.store.get("openid_configuration")),!e.client_info?.client_id&&e.store.has("client_info")&&(e.client_info=e.store.get("client_info")),async(r,n)=>{let o;if(!e.force_authorization){try{o=await n(r)}catch(d){if(o.status!=401&&o.status!=403)throw d}if(o.ok||o.status!=401&&o.status!=403)return o}if(e.openid_configuration||(e.openid_configuration=await Q({issuer:e.issuer}),e.store.set("openid_configuration",e.openid_configuration)),!e.client_info?.client_id){if(!e.openid_configuration.registration_endpoint)throw g("metro.oidcmw: Error: issuer "+e.issuer+" does not support dynamic client registration, but you haven't specified a client_id");e.client_info=await X({registration_endpoint:e.openid_configuration.registration_endpoint,client_info:e.client_info}),e.store.set("client_info",e.client_info)}let i=e.scope||"openid",s=Object.assign({site:e.issuer,client:e.client,force_authorization:!0,authorize_callback:e.authorize_callback,oauth2_configuration:{client_id:e.client_info?.client_id,client_secret:e.client_info?.client_secret,grant_type:"authorization_code",response_type:"code",response_mode:"query",authorization_endpoint:e.openid_configuration.authorization_endpoint,token_endpoint:e.openid_configuration.token_endpoint,scope:i,redirect_uri:e.client_info.redirect_uris[0]}}),a=async(d,u)=>{let f=await u(d);if(f.headers.get("content-type")?.startsWith("application/json")){let y=f.data?.id_token;if(!y){let k=f.clone();try{let j=await k.json();j&&j.id_token&&(y=j.id_token)}catch{}}y&&e.store.set("id_token",y)}return f},p=e.client.with(e.issuer).with(a);if(e.use_dpop){let d={site:e.issuer,authorization_endpoint:e.openid_configuration.authorization_endpoint,token_endpoint:e.openid_configuration.token_endpoint,dpop_signing_alg_values_supported:e.openid_configuration.dpop_signing_alg_values_supported};p=p.with(me(d)),s.client=p}return p=p.with(de(s)),o=await p.fetch(r),o}}function He(){return Ne()}function Ke(e){if(!e.store){if(!e.issuer)throw g("Must supply options.issuer or options.store to get the id_token");e.store=ae(e.issuer)}return e.store.get("id_token")}var Me={oidcmw:ye,discover:Q,register:X,isRedirected:He,idToken:Ke};globalThis.metro.oidc||(globalThis.metro.oidc=Me);var Je=Me;function q(e){return new we(e)}var kt="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",At={rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",solid:"http://www.w3.org/ns/solid/terms#",schema:"http://schema.org/",vcard:"http://www.w3.org/2006/vcard/ns#"},we=class{constructor(t){this.prefixes={...At,...t?.prefixes},this.prefixes.xsd||(this.prefixes.xsd="http://www.w3.org/2001/XMLSchema#"),this.parser=t?.parser,this.writer=t?.writer,this.sources=Object.create(null),this.separator=t?.separator??"$"}parse(t,r,n){let{quads:o,prefixes:i}=this.parser(t,r,n);if(i)for(let s in i){let a=i[s];if(a.match(/^http(s?):\/\/$/i))a+=r.substring(a.length);else try{a=new URL(i[s],r).href}catch(p){console.error("Could not parse prefix",i[s],p.message)}this.prefixes[s]||(this.prefixes[s]=a)}return this.sources[r]=new ge(o,r,n,i,this),this.sources[r]}setType(t,r){if(!r)return t;if(typeof t=="string"?t=new String(t):typeof result=="number"&&(t=new Number(t)),typeof t!="object")throw new Error("cannot set type on ",t,r);return t.type=r,t}getType(t){return t&&typeof t=="object"?t.type:null}},ge=class{#e=Object.create(null);constructor(t,r,n,o,i){this.mimetype=n,this.url=r,this.prefixes=o,this.context=i,this.subjects=Object.create(null);for(let s of t){let a;if(s.subject.termType=="BlankNode"){let p=this.shortURI(s.predicate.id,":"),d;switch(p){case"rdf:first":if(a=this.addCollection(s.subject.id),d=this.shortURI(s.object.id,":"),d!="rdf:nil"){let u=this.getValue(s.object);u&&a.push(u)}continue;case"rdf:rest":this.#e[s.object.id]=this.#e[s.subject.id];continue;default:a=this.addBlankNode(s.subject.id);break}}else a=this.addNamedNode(s.subject.id);a.addPredicate(s.predicate.id,s.object)}this.subjects[r]?this.primary=this.subjects[r]:this.primary=null,Object.defineProperty(this,"data",{get(){return Object.values(this.subjects)}})}addNamedNode(t){let r=new URL(t,this.url).href;return this.subjects[r]||(this.subjects[r]=new _e(r,this)),this.subjects[r]}addBlankNode(t){return this.#e[t]||(this.#e[t]=new ce(this)),this.#e[t]}addCollection(t){return this.#e[t]||(this.#e[t]=new be(this)),this.#e[t]}write(){return this.context.writer(this)}get(t){return this.subjects[this.fullURI(t)]}fullURI(t,r=null){r||(r=this.context.separator);let[n,o]=t.split(r);return o?this.prefixes[n]+o:t}shortURI(t,r=null){r||(r=this.context.separator);for(let n in this.context.prefixes)if(t.startsWith(this.context.prefixes[n]))return n+r+t.substring(this.context.prefixes[n].length);return this.url&&t.startsWith(this.url)?t.substring(this.url.length):t}setType(t,r){let n=this.shortURI(r);return this.context.setType(t,n)}getType(t){return this.context.getType(t)}setLanguage(t,r){if(typeof t=="string"?t=new String(t):typeof result=="number"&&(t=new Number(t)),typeof t!="object")throw new Error("cannot set language on ",t);return t.language=r,t}getValue(t){let r;if(t.termType=="Literal"){r=t.value;let n=t.datatype?.id;n&&(r=this.setType(r,n));let o=t.language;o&&(r=this.setLanguage(r,o))}else t.termType=="BlankNode"?r=this.addBlankNode(t.id):r=this.addNamedNode(t.id);return r}},ce=class{constructor(t){Object.defineProperty(this,"graph",{value:t,writable:!1,enumerable:!1})}addPredicate(t,r){if(t.id&&(t=t.id),t==kt){let n=this.graph.shortURI(r.id);this.addType(n)}else{let n=this.graph.getValue(r);t=this.graph.shortURI(t),this[t]?Array.isArray(this[t])?this[t].push(n):this[t]=[this[t],n]:this[t]=n}}addType(t){this.a?(Array.isArray(this.a)||(this.a=[this.a]),this.a.push(t)):this.a=t}},_e=class extends ce{constructor(t,r){super(r),Object.defineProperty(this,"id",{value:t,writable:!1,enumerable:!0})}},be=class extends Array{constructor(t,r){super(),Object.defineProperty(this,"graph",{value:r,writable:!1,enumerable:!1})}};function ue(e){e=Object.assign({contentType:"text/turtle",prefixes:{ldp:"http://www.w3.org/ns/ldp#",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",dct:"http://purl.org/dc/terms/",stat:"http://www.w3.org/ns/posix/stat#",turtle:"http://www.w3.org/ns/iana/media-types/text/turtle#",schem:"https://schema.org/",solid:"http://www.w3.org/ns/solid/terms#",acl:"http://www.w3.org/ns/auth/acl#",pims:"http://www.w3.org/ns/pim/space#",vcard:"http://www.w3.org/2006/vcard/ns#",foaf:"http://xmlns.com/foaf/0.1/"},parser:q.n3Parser,writer:q.n3Writer},e),e.prefixes.ldp||(e.prefixes.ldp="http://www.w3.org/ns/ldp#");let t=q(e);return async function(n,o){if(n.headers.get("Accept")||(n=n.with({headers:{Accept:e.accept??e.contentType}})),n.method!=="GET"&&n.method!=="HEAD"&&n.data&&typeof n.data=="object"&&!(n.data instanceof ReadableStream)){let s=n.headers.get("Content-Type");(!s||isPlainText(s))&&(n=n.with({headers:{"Content-Type":e.contentType}})),isLinkedData(n.headers.get("Content-Type"))&&(n=n.with({body:await t.writer(n.data)}))}let i=await o(n)}}globalThis.oldmmw=ue;var Ve=ue;function L(e){return[String,Boolean,Number,BigInt].includes(e?.constructor)}function xe(e){let t=[];if(e instanceof Function)t.push(e);else for(let[r,n]of Object.entries(e))n instanceof Function?t.push(o=>({[r]:n(o,r,"select")})):L(n)?t.push(()=>({[r]:n})):t.push(o=>({[r]:te(o[r]).select(n)}));return t.length==1?t[0]:r=>{let n={};for(let o of t)Object.assign(n,o(r));return n}}function Se(e){let t=[];if(Array.isArray(e))t.push(Tt(...e));else if(e instanceof RegExp)t.push(r=>e.test(r));else if(e instanceof Function)t.push(r=>e(r));else if(L(e))t.push(r=>Array.isArray(r)?r.filter(n=>e==n).length>0:e==r);else{let r={};for(let[o,i]of Object.entries(e))r[o]=Se(i);let n=o=>{if(Array.isArray(o))return o.filter(i=>n(i)).length>0;if(L(o))return!1;for(let i in r){let s=r[i];if(!s(o?.[i]))return!1}return!0};t.push(n)}return t.length==1?t[0]:r=>{for(let n of t)if(!n(r))return!1;return!0}}var vt=Symbol("asc"),Pt=Symbol("desc");function We(e){let t=Object.entries(e),r=[];for(let[n,o]of t)if(o instanceof Function)r.push(o);else if(o===vt)r.push((i,s)=>i[n]>s[n]?1:i[n]<s[n]?-1:0);else if(o===Pt)r.push((i,s)=>i[n]<s[n]?1:i[n]>s[n]?-1:0);else{if(L(o))throw new Error("Unknown sort order",o);{let i=We(o);r.push((s,a)=>i(s[n],a[n]))}}return r.length==1?r[0]:(n,o)=>{for(let i of r){let s=i(n,o);if(s!==0)return s}return 0}}function $e(e){let t=[];if(e instanceof Function)t.push(e);else for(let[r,n]of Object.entries(e))n instanceof Function?t.push((o,i,s,a)=>(L(o)&&(o={}),i.reduce?o[r]=i.reduce(n,o[r]||[]):o[r]=n(o[r]||[],i,s,a),o)):L(n)?t.push(o=>(L(o)&&(o={}),o[r]=n,o)):t.push((o,i)=>(L(o)&&(o={}),o[r]=te(i[r]).reduce(n,[]),o));return t.length==1?t[0]:(r,n,o,i)=>{let s={};for(let a of t)Object.assign(s,a(r,n,o,i));return s}}function jt(e,t){let r={};for(let n of e){let o=t(n);Array.isArray(o)||(o=[o]);for(let i of o){if(typeof i!="string"&&!(i instanceof String)){console.warn("JAQT: groupBy(selector) can only handle string values, got:",i);continue}r[i]||(r[i]=[]),r[i].push(n)}}return r}function Ge(e,t){let r=t.shift(),n=jt(e,r);if(t.length)for(let o in n)n[o]=Ge(n[o],t);return n}function Tt(...e){let t=e.map(r=>Se(r));return r=>t.some(n=>n(r))}var Rt={apply(e,t,r){let n=e.apply(t,r);return typeof n=="object"?new Proxy(n,U):n}},U={get(e,t){let r=null;if(typeof t=="symbol"&&(r=e[t]),Array.isArray(e))switch(t){case"where":r=function(n){let o=Se(n);return new Proxy(e.filter(i=>o(i)),U)};break;case"select":r=function(n){let o=xe(n);return new Proxy(e.map(o),U)};break;case"reduce":r=function(n,o=[]){let i=$e(n),s=e.reduce(i,o);return Array.isArray(s)?new Proxy(s,U):L(s)?s:new Proxy(s,ee)};break;case"orderBy":r=function(n){let o=We(n);return new Proxy(e.toSorted(o),U)};break;case"groupBy":r=function(...n){let o=Ge(e,n);return new Proxy(o,ee)};break}return!r&&e&&typeof e=="object"&&t==="select"&&(r=function(n){let o=xe(n);return new Proxy(o(e),U)}),!r&&e&&typeof e[t]=="function"&&(r=new Proxy(e[t],Rt)),r||(r=e[t]),r}},ee={get(e,t){let r=null;switch(t){case"select":r=function(n){let o=xe(n),i={};for(let s in e)Array.isArray(e[s])?i[s]=new Proxy(e[s].map(o),U):i[s]=new Proxy(e[s],ee);return i};break;case"reduce":r=function(n,o=[]){let i=$e(n),s={};for(let a in e)if(Array.isArray(e[a])){let p=e[a].reduce(i,o);Array.isArray(p)?s[a]=new Proxy(p,U):L(p)?s[a]=p:s[a]=new Proxy(p,ee)}else s[a]=new Proxy(e[a],ee);return s};break;default:Array.isArray(e[t])?r=te(e[t]):r=e[t];break}return r}},le={get(e,t){let r=null;switch(t){case"where":r=function(){return new Proxy(new M,le)};break;case"reduce":case"select":r=function(){return null};break;case"orderBy":r=function(){return new Proxy(new M,le)};break;case"groupBy":r=function(){return new Proxy(new M,le)};break}return!r&&typeof e?.[t]=="function"&&(r=e[t]),r}},M=class{toJSON(){return null}};function te(e){return!e||typeof e!="object"?new Proxy(new M,le):new Proxy(e,U)}function ke(e){return(t,r)=>{if(e?.length>0){let n=e.slice(),o=n.shift();for(;o;){if(Array.isArray(t)&&parseInt(o)!=o)return n.unshift(o),t.map(ke(n));typeof t?.[o]<"u"?t=t[o]:t=null,o=n.shift()}return t}else return r?typeof t?.[r]<"u"?t[r]:null:t}}var Ye=e=>(e||(e=[]),{get(t,r){if(r=="constructor"||typeof r=="symbol")return t[r];let n=e.concat([r]);return new Proxy(ke(n),Ye(n))},apply(t,r,n){let o=t(...n);return Array.isArray(o)&&(o=o.flat(1/0)),o}}),Nr=new Proxy(ke(),Ye());var J=class extends V{#e;#r;constructor(t,r="/",n={}){this.#e=T(t).with(Je.oidcmw(n)).with(Ve(n)),this.#r=new x(r)}get name(){return"SolidAdapter"}async list(t){let r=["text/turtle"],n=await this.read(t);if(n.data)te(n.data).where({a:"ldp$Resource"}).select({filename:o=>jsfs.path.filename(metro.url(o.id).pathname),path:o=>metro.url(o.id).pathname,type:o=>o.a.includes("ldp$Container")?"folder":"file"});else throw new Error(t+" could not be parsed",{cause:n})}};var Zr=J;globalThis.SolidAdapter=J;})();
1
+ (()=>{var ef=Object.create;var Bn=Object.defineProperty;var tf=Object.getOwnPropertyDescriptor;var rf=Object.getOwnPropertyNames;var nf=Object.getPrototypeOf,sf=Object.prototype.hasOwnProperty;var A=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Fn=(t,e)=>{for(var r in e)Bn(t,r,{get:e[r],enumerable:!0})},of=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of rf(e))!sf.call(t,i)&&i!==r&&Bn(t,i,{get:()=>e[i],enumerable:!(n=tf(e,i))||n.enumerable});return t};var Br=(t,e,r)=>(r=t!=null?ef(nf(t)):{},of(e||!t||!t.__esModule?Bn(r,"default",{value:t,enumerable:!0}):r,t));var Zs=A(qr=>{"use strict";qr.byteLength=Of;qr.toByteArray=Ff;qr.fromByteArray=Mf;var de=[],te=[],Lf=typeof Uint8Array<"u"?Uint8Array:Array,Qn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(tt=0,Js=Qn.length;tt<Js;++tt)de[tt]=Qn[tt],te[Qn.charCodeAt(tt)]=tt;var tt,Js;te[45]=62;te[95]=63;function Ys(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Of(t){var e=Ys(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Bf(t,e,r){return(e+r)*3/4-r}function Ff(t){var e,r=Ys(t),n=r[0],i=r[1],s=new Lf(Bf(t,n,i)),o=0,a=i>0?n-4:n,l;for(l=0;l<a;l+=4)e=te[t.charCodeAt(l)]<<18|te[t.charCodeAt(l+1)]<<12|te[t.charCodeAt(l+2)]<<6|te[t.charCodeAt(l+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=te[t.charCodeAt(l)]<<2|te[t.charCodeAt(l+1)]>>4,s[o++]=e&255),i===1&&(e=te[t.charCodeAt(l)]<<10|te[t.charCodeAt(l+1)]<<4|te[t.charCodeAt(l+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function Cf(t){return de[t>>18&63]+de[t>>12&63]+de[t>>6&63]+de[t&63]}function Df(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(Cf(n));return i.join("")}function Mf(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(Df(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(de[e>>2]+de[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(de[e>>10]+de[e>>4&63]+de[e<<2&63]+"=")),i.join("")}});var Xs=A(Kn=>{Kn.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,l=(1<<a)-1,u=l>>1,f=-7,c=r?i-1:0,d=r?-1:1,h=t[e+c];for(c+=d,s=h&(1<<-f)-1,h>>=-f,f+=a;f>0;s=s*256+t[e+c],c+=d,f-=8);for(o=s&(1<<-f)-1,s>>=-f,f+=n;f>0;o=o*256+t[e+c],c+=d,f-=8);if(s===0)s=1-u;else{if(s===l)return o?NaN:(h?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-u}return(h?-1:1)*o*Math.pow(2,s-n)};Kn.write=function(t,e,r,n,i,s){var o,a,l,u=s*8-i-1,f=(1<<u)-1,c=f>>1,d=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:s-1,y=n?1:-1,_=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=f):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+c>=1?e+=d/l:e+=d*Math.pow(2,1-c),e*l>=2&&(o++,l/=2),o+c>=f?(a=0,o=f):o+c>=1?(a=(e*l-1)*Math.pow(2,i),o=o+c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),o=0));i>=8;t[r+h]=a&255,h+=y,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;t[r+h]=o&255,h+=y,o/=256,u-=8);t[r+h-y]|=_*128}});var pe=A(jt=>{"use strict";var Vn=Zs(),vt=Xs(),eo=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;jt.Buffer=p;jt.SlowBuffer=zf;jt.INSPECT_MAX_BYTES=50;var Wr=2147483647;jt.kMaxLength=Wr;p.TYPED_ARRAY_SUPPORT=Uf();!p.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Uf(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(p.prototype,"parent",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.buffer}});Object.defineProperty(p.prototype,"offset",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.byteOffset}});function ve(t){if(t>Wr)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,p.prototype),e}function p(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Xn(t)}return io(t,e,r)}p.poolSize=8192;function io(t,e,r){if(typeof t=="string")return qf(t,e);if(ArrayBuffer.isView(t))return Wf(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(he(t,ArrayBuffer)||t&&he(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(he(t,SharedArrayBuffer)||t&&he(t.buffer,SharedArrayBuffer)))return Yn(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return p.from(n,e,r);let i=Gf(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return p.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}p.from=function(t,e,r){return io(t,e,r)};Object.setPrototypeOf(p.prototype,Uint8Array.prototype);Object.setPrototypeOf(p,Uint8Array);function so(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function $f(t,e,r){return so(t),t<=0?ve(t):e!==void 0?typeof r=="string"?ve(t).fill(e,r):ve(t).fill(e):ve(t)}p.alloc=function(t,e,r){return $f(t,e,r)};function Xn(t){return so(t),ve(t<0?0:ei(t)|0)}p.allocUnsafe=function(t){return Xn(t)};p.allocUnsafeSlow=function(t){return Xn(t)};function qf(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!p.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=oo(t,e)|0,n=ve(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Jn(t){let e=t.length<0?0:ei(t.length)|0,r=ve(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Wf(t){if(he(t,Uint8Array)){let e=new Uint8Array(t);return Yn(e.buffer,e.byteOffset,e.byteLength)}return Jn(t)}function Yn(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,p.prototype),n}function Gf(t){if(p.isBuffer(t)){let e=ei(t.length)|0,r=ve(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||ri(t.length)?ve(0):Jn(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Jn(t.data)}function ei(t){if(t>=Wr)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Wr.toString(16)+" bytes");return t|0}function zf(t){return+t!=t&&(t=0),p.alloc(+t)}p.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==p.prototype};p.compare=function(e,r){if(he(e,Uint8Array)&&(e=p.from(e,e.offset,e.byteLength)),he(r,Uint8Array)&&(r=p.from(r,r.offset,r.byteLength)),!p.isBuffer(e)||!p.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};p.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};p.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return p.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=p.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(he(o,Uint8Array))s+o.length>i.length?(p.isBuffer(o)||(o=p.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(p.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function oo(t,e){if(p.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||he(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Zn(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return yo(t).length;default:if(i)return n?-1:Zn(t).length;e=(""+e).toLowerCase(),i=!0}}p.byteLength=oo;function Hf(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return rc(this,e,r);case"utf8":case"utf-8":return lo(this,e,r);case"ascii":return ec(this,e,r);case"latin1":case"binary":return tc(this,e,r);case"base64":return Zf(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return nc(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}p.prototype._isBuffer=!0;function rt(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}p.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)rt(this,r,r+1);return this};p.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)rt(this,r,r+3),rt(this,r+1,r+2);return this};p.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)rt(this,r,r+7),rt(this,r+1,r+6),rt(this,r+2,r+5),rt(this,r+3,r+4);return this};p.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?lo(this,0,e):Hf.apply(this,arguments)};p.prototype.toLocaleString=p.prototype.toString;p.prototype.equals=function(e){if(!p.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:p.compare(this,e)===0};p.prototype.inspect=function(){let e="",r=jt.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};eo&&(p.prototype[eo]=p.prototype.inspect);p.prototype.compare=function(e,r,n,i,s){if(he(e,Uint8Array)&&(e=p.from(e,e.offset,e.byteLength)),!p.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,a=n-r,l=Math.min(o,a),u=this.slice(i,s),f=e.slice(r,n);for(let c=0;c<l;++c)if(u[c]!==f[c]){o=u[c],a=f[c];break}return o<a?-1:a<o?1:0};function ao(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,ri(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=p.from(e,n)),p.isBuffer(e))return e.length===0?-1:to(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):to(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function to(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function l(f,c){return s===1?f[c]:f.readUInt16BE(c*s)}let u;if(i){let f=-1;for(u=r;u<o;u++)if(l(t,u)===l(e,f===-1?0:u-f)){if(f===-1&&(f=u),u-f+1===a)return f*s}else f!==-1&&(u-=u-f),f=-1}else for(r+a>o&&(r=o-a),u=r;u>=0;u--){let f=!0;for(let c=0;c<a;c++)if(l(t,u+c)!==l(e,c)){f=!1;break}if(f)return u}return-1}p.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};p.prototype.indexOf=function(e,r,n){return ao(this,e,r,n,!0)};p.prototype.lastIndexOf=function(e,r,n){return ao(this,e,r,n,!1)};function Qf(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(ri(a))return o;t[r+o]=a}return o}function Kf(t,e,r,n){return Gr(Zn(e,t.length-r),t,r,n)}function Vf(t,e,r,n){return Gr(ac(e),t,r,n)}function Jf(t,e,r,n){return Gr(yo(e),t,r,n)}function Yf(t,e,r,n){return Gr(lc(e,t.length-r),t,r,n)}p.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return Qf(this,e,r,n);case"utf8":case"utf-8":return Kf(this,e,r,n);case"ascii":case"latin1":case"binary":return Vf(this,e,r,n);case"base64":return Jf(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Yf(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Zf(t,e,r){return e===0&&r===t.length?Vn.fromByteArray(t):Vn.fromByteArray(t.slice(e,r))}function lo(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let l,u,f,c;switch(a){case 1:s<128&&(o=s);break;case 2:l=t[i+1],(l&192)===128&&(c=(s&31)<<6|l&63,c>127&&(o=c));break;case 3:l=t[i+1],u=t[i+2],(l&192)===128&&(u&192)===128&&(c=(s&15)<<12|(l&63)<<6|u&63,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:l=t[i+1],u=t[i+2],f=t[i+3],(l&192)===128&&(u&192)===128&&(f&192)===128&&(c=(s&15)<<18|(l&63)<<12|(u&63)<<6|f&63,c>65535&&c<1114112&&(o=c))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return Xf(n)}var ro=4096;function Xf(t){let e=t.length;if(e<=ro)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=ro));return r}function ec(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function tc(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function rc(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=e;s<r;++s)i+=uc[t[s]];return i}function nc(t,e,r){let n=t.slice(e,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}p.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,p.prototype),i};function U(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}p.prototype.readUintLE=p.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||U(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};p.prototype.readUintBE=p.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||U(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};p.prototype.readUint8=p.prototype.readUInt8=function(e,r){return e=e>>>0,r||U(e,1,this.length),this[e]};p.prototype.readUint16LE=p.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||U(e,2,this.length),this[e]|this[e+1]<<8};p.prototype.readUint16BE=p.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||U(e,2,this.length),this[e]<<8|this[e+1]};p.prototype.readUint32LE=p.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};p.prototype.readUint32BE=p.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||U(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};p.prototype.readBigUInt64LE=$e(function(e){e=e>>>0,Nt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&or(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});p.prototype.readBigUInt64BE=$e(function(e){e=e>>>0,Nt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&or(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});p.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||U(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};p.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||U(e,r,this.length);let i=r,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};p.prototype.readInt8=function(e,r){return e=e>>>0,r||U(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};p.prototype.readInt16LE=function(e,r){e=e>>>0,r||U(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};p.prototype.readInt16BE=function(e,r){e=e>>>0,r||U(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};p.prototype.readInt32LE=function(e,r){return e=e>>>0,r||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};p.prototype.readInt32BE=function(e,r){return e=e>>>0,r||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};p.prototype.readBigInt64LE=$e(function(e){e=e>>>0,Nt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&or(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});p.prototype.readBigInt64BE=$e(function(e){e=e>>>0,Nt(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&or(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});p.prototype.readFloatLE=function(e,r){return e=e>>>0,r||U(e,4,this.length),vt.read(this,e,!0,23,4)};p.prototype.readFloatBE=function(e,r){return e=e>>>0,r||U(e,4,this.length),vt.read(this,e,!1,23,4)};p.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||U(e,8,this.length),vt.read(this,e,!0,52,8)};p.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||U(e,8,this.length),vt.read(this,e,!1,52,8)};function Y(t,e,r,n,i,s){if(!p.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}p.prototype.writeUintLE=p.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Y(this,e,r,n,a,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};p.prototype.writeUintBE=p.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Y(this,e,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};p.prototype.writeUint8=p.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,1,255,0),this[r]=e&255,r+1};p.prototype.writeUint16LE=p.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};p.prototype.writeUint16BE=p.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};p.prototype.writeUint32LE=p.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};p.prototype.writeUint32BE=p.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function uo(t,e,r,n,i){_o(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function fo(t,e,r,n,i){_o(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s=s>>8,t[r+6]=s,s=s>>8,t[r+5]=s,s=s>>8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}p.prototype.writeBigUInt64LE=$e(function(e,r=0){return uo(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});p.prototype.writeBigUInt64BE=$e(function(e,r=0){return fo(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});p.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);Y(this,e,r,n,l-1,-l)}let s=0,o=1,a=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};p.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let l=Math.pow(2,8*n-1);Y(this,e,r,n,l-1,-l)}let s=n-1,o=1,a=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};p.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};p.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};p.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};p.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};p.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Y(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};p.prototype.writeBigInt64LE=$e(function(e,r=0){return uo(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});p.prototype.writeBigInt64BE=$e(function(e,r=0){return fo(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function co(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function ho(t,e,r,n,i){return e=+e,r=r>>>0,i||co(t,e,r,4,34028234663852886e22,-34028234663852886e22),vt.write(t,e,r,n,23,4),r+4}p.prototype.writeFloatLE=function(e,r,n){return ho(this,e,r,!0,n)};p.prototype.writeFloatBE=function(e,r,n){return ho(this,e,r,!1,n)};function po(t,e,r,n,i){return e=+e,r=r>>>0,i||co(t,e,r,8,17976931348623157e292,-17976931348623157e292),vt.write(t,e,r,n,52,8),r+8}p.prototype.writeDoubleLE=function(e,r,n){return po(this,e,r,!0,n)};p.prototype.writeDoubleBE=function(e,r,n){return po(this,e,r,!1,n)};p.prototype.copy=function(e,r,n,i){if(!p.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),s};p.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!p.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=r;s<n;++s)this[s]=e;else{let o=p.isBuffer(e)?e:p.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var Tt={};function ti(t,e,r){Tt[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}ti("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ti("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);ti("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=no(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=no(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function no(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function ic(t,e,r){Nt(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&or(e,t.length-(r+1))}function _o(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${r}${o}`,new Tt.ERR_OUT_OF_RANGE("value",a,t)}ic(n,i,s)}function Nt(t,e){if(typeof t!="number")throw new Tt.ERR_INVALID_ARG_TYPE(e,"number",t)}function or(t,e,r){throw Math.floor(t)!==t?(Nt(t,r),new Tt.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Tt.ERR_BUFFER_OUT_OF_BOUNDS:new Tt.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var sc=/[^+/0-9A-Za-z-_]/g;function oc(t){if(t=t.split("=")[0],t=t.trim().replace(sc,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Zn(t,e){e=e||1/0;let r,n=t.length,i=null,s=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function ac(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function lc(t,e){let r,n,i,s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function yo(t){return Vn.toByteArray(oc(t))}function Gr(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function he(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function ri(t){return t!==t}var uc=(function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e})();function $e(t){return typeof BigInt>"u"?fc:t}function fc(){throw new Error("BigInt not supported")}});var P=A((Bg,Po)=>{"use strict";var ai=class extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError(`Expected input to be an Array, got ${typeof e}`);let r="";for(let n=0;n<e.length;n++)r+=` ${e[n].stack}
2
+ `;super(r),this.name="AggregateError",this.errors=e}};Po.exports={AggregateError:ai,ArrayIsArray(t){return Array.isArray(t)},ArrayPrototypeIncludes(t,e){return t.includes(e)},ArrayPrototypeIndexOf(t,e){return t.indexOf(e)},ArrayPrototypeJoin(t,e){return t.join(e)},ArrayPrototypeMap(t,e){return t.map(e)},ArrayPrototypePop(t,e){return t.pop(e)},ArrayPrototypePush(t,e){return t.push(e)},ArrayPrototypeSlice(t,e,r){return t.slice(e,r)},Error,FunctionPrototypeCall(t,e,...r){return t.call(e,...r)},FunctionPrototypeSymbolHasInstance(t,e){return Function.prototype[Symbol.hasInstance].call(t,e)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(t,e){return Object.defineProperties(t,e)},ObjectDefineProperty(t,e,r){return Object.defineProperty(t,e,r)},ObjectGetOwnPropertyDescriptor(t,e){return Object.getOwnPropertyDescriptor(t,e)},ObjectKeys(t){return Object.keys(t)},ObjectSetPrototypeOf(t,e){return Object.setPrototypeOf(t,e)},Promise,PromisePrototypeCatch(t,e){return t.catch(e)},PromisePrototypeThen(t,e,r){return t.then(e,r)},PromiseReject(t){return Promise.reject(t)},PromiseResolve(t){return Promise.resolve(t)},ReflectApply:Reflect.apply,RegExpPrototypeTest(t,e){return t.test(e)},SafeSet:Set,String,StringPrototypeSlice(t,e,r){return t.slice(e,r)},StringPrototypeToLowerCase(t){return t.toLowerCase()},StringPrototypeToUpperCase(t){return t.toUpperCase()},StringPrototypeTrim(t){return t.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet(t,e,r){return t.set(e,r)},Boolean,Uint8Array}});var li=A((Fg,Lo)=>{"use strict";Lo.exports={format(t,...e){return t.replace(/%([sdifj])/g,function(...[r,n]){let i=e.shift();return n==="f"?i.toFixed(6):n==="j"?JSON.stringify(i):n==="s"&&typeof i=="object"?`${i.constructor!==Object?i.constructor.name:""} {}`.trim():i.toString()})},inspect(t){switch(typeof t){case"string":if(t.includes("'"))if(t.includes('"')){if(!t.includes("`")&&!t.includes("${"))return`\`${t}\``}else return`"${t}"`;return`'${t}'`;case"number":return isNaN(t)?"NaN":Object.is(t,-0)?String(t):t;case"bigint":return`${String(t)}n`;case"boolean":case"undefined":return String(t);case"object":return"{}"}}}});var W=A((Cg,Fo)=>{"use strict";var{format:jc,inspect:Kr}=li(),{AggregateError:kc}=P(),Pc=globalThis.AggregateError||kc,Lc=Symbol("kIsNodeError"),Oc=["string","function","number","object","Function","Object","boolean","bigint","symbol"],Bc=/^([A-Z][a-z0-9]*)+$/,Fc="__node_internal_",Vr={};function lt(t,e){if(!t)throw new Vr.ERR_INTERNAL_ASSERTION(e)}function Oo(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function Cc(t,e,r){if(typeof e=="function")return lt(e.length<=r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${e.length}).`),e(...r);let n=(e.match(/%[dfijoOs]/g)||[]).length;return lt(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:jc(e,...r)}function q(t,e,r){r||(r=Error);class n extends r{constructor(...s){super(Cc(t,e,s))}toString(){return`${this.name} [${t}]: ${this.message}`}}Object.defineProperties(n.prototype,{name:{value:r.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),n.prototype.code=t,n.prototype[Lc]=!0,Vr[t]=n}function Bo(t){let e=Fc+t.name;return Object.defineProperty(t,"name",{value:e}),t}function Dc(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new Pc([e,t],e.message);return r.code=e.code,r}return t||e}var ui=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new Vr.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};q("ERR_ASSERTION","%s",Error);q("ERR_INVALID_ARG_TYPE",(t,e,r)=>{lt(typeof t=="string","'name' must be a string"),Array.isArray(e)||(e=[e]);let n="The ";t.endsWith(" argument")?n+=`${t} `:n+=`"${t}" ${t.includes(".")?"property":"argument"} `,n+="must be ";let i=[],s=[],o=[];for(let l of e)lt(typeof l=="string","All expected entries have to be of type string"),Oc.includes(l)?i.push(l.toLowerCase()):Bc.test(l)?s.push(l):(lt(l!=="object",'The value "object" should be written as "Object"'),o.push(l));if(s.length>0){let l=i.indexOf("object");l!==-1&&(i.splice(i,l,1),s.push("Object"))}if(i.length>0){switch(i.length){case 1:n+=`of type ${i[0]}`;break;case 2:n+=`one of type ${i[0]} or ${i[1]}`;break;default:{let l=i.pop();n+=`one of type ${i.join(", ")}, or ${l}`}}(s.length>0||o.length>0)&&(n+=" or ")}if(s.length>0){switch(s.length){case 1:n+=`an instance of ${s[0]}`;break;case 2:n+=`an instance of ${s[0]} or ${s[1]}`;break;default:{let l=s.pop();n+=`an instance of ${s.join(", ")}, or ${l}`}}o.length>0&&(n+=" or ")}switch(o.length){case 0:break;case 1:o[0].toLowerCase()!==o[0]&&(n+="an "),n+=`${o[0]}`;break;case 2:n+=`one of ${o[0]} or ${o[1]}`;break;default:{let l=o.pop();n+=`one of ${o.join(", ")}, or ${l}`}}if(r==null)n+=`. Received ${r}`;else if(typeof r=="function"&&r.name)n+=`. Received function ${r.name}`;else if(typeof r=="object"){var a;if((a=r.constructor)!==null&&a!==void 0&&a.name)n+=`. Received an instance of ${r.constructor.name}`;else{let l=Kr(r,{depth:-1});n+=`. Received ${l}`}}else{let l=Kr(r,{colors:!1});l.length>25&&(l=`${l.slice(0,25)}...`),n+=`. Received type ${typeof r} (${l})`}return n},TypeError);q("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=Kr(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError);q("ERR_INVALID_RETURN_VALUE",(t,e,r)=>{var n;let i=r!=null&&(n=r.constructor)!==null&&n!==void 0&&n.name?`instance of ${r.constructor.name}`:`type ${typeof r}`;return`Expected ${t} to be returned from the "${e}" function but got ${i}.`},TypeError);q("ERR_MISSING_ARGS",(...t)=>{lt(t.length>0,"At least one arg needs to be specified");let e,r=t.length;switch(t=(Array.isArray(t)?t:[t]).map(n=>`"${n}"`).join(" or "),r){case 1:e+=`The ${t[0]} argument`;break;case 2:e+=`The ${t[0]} and ${t[1]} arguments`;break;default:{let n=t.pop();e+=`The ${t.join(", ")}, and ${n} arguments`}break}return`${e} must be specified`},TypeError);q("ERR_OUT_OF_RANGE",(t,e,r)=>{lt(e,'Missing "range" argument');let n;if(Number.isInteger(r)&&Math.abs(r)>2**32)n=Oo(String(r));else if(typeof r=="bigint"){n=String(r);let i=BigInt(2)**BigInt(32);(r>i||r<-i)&&(n=Oo(n)),n+="n"}else n=Kr(r);return`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError);q("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error);q("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error);q("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error);q("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error);q("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error);q("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);q("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error);q("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error);q("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error);q("ERR_STREAM_WRITE_AFTER_END","write after end",Error);q("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);Fo.exports={AbortError:ui,aggregateTwoErrors:Bo(Dc),hideStackFrames:Bo,codes:Vr}});var Bt=A((Dg,Jr)=>{"use strict";var{AbortController:Co,AbortSignal:Mc}=typeof self<"u"?self:typeof window<"u"?window:void 0;Jr.exports=Co;Jr.exports.AbortSignal=Mc;Jr.exports.default=Co});var pr=A((Mg,fi)=>{"use strict";var Ft=typeof Reflect=="object"?Reflect:null,Do=Ft&&typeof Ft.apply=="function"?Ft.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Yr;Ft&&typeof Ft.ownKeys=="function"?Yr=Ft.ownKeys:Object.getOwnPropertySymbols?Yr=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Yr=function(e){return Object.getOwnPropertyNames(e)};function Uc(t){console&&console.warn&&console.warn(t)}var Uo=Number.isNaN||function(e){return e!==e};function v(){v.init.call(this)}fi.exports=v;fi.exports.once=Gc;v.EventEmitter=v;v.prototype._events=void 0;v.prototype._eventsCount=0;v.prototype._maxListeners=void 0;var Mo=10;function Zr(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(v,"defaultMaxListeners",{enumerable:!0,get:function(){return Mo},set:function(t){if(typeof t!="number"||t<0||Uo(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Mo=t}});v.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};v.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Uo(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function $o(t){return t._maxListeners===void 0?v.defaultMaxListeners:t._maxListeners}v.prototype.getMaxListeners=function(){return $o(this)};v.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=s[e];if(l===void 0)return!1;if(typeof l=="function")Do(l,this,r);else for(var u=l.length,f=Ho(l,u),n=0;n<u;++n)Do(f[n],this,r);return!0};function qo(t,e,r,n){var i,s,o;if(Zr(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=$o(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,Uc(a)}return t}v.prototype.addListener=function(e,r){return qo(this,e,r,!1)};v.prototype.on=v.prototype.addListener;v.prototype.prependListener=function(e,r){return qo(this,e,r,!0)};function $c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Wo(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=$c.bind(n);return i.listener=r,n.wrapFn=i,i}v.prototype.once=function(e,r){return Zr(r),this.on(e,Wo(this,e,r)),this};v.prototype.prependOnceListener=function(e,r){return Zr(r),this.prependListener(e,Wo(this,e,r)),this};v.prototype.removeListener=function(e,r){var n,i,s,o,a;if(Zr(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():qc(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};v.prototype.off=v.prototype.removeListener;v.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function Go(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?Wc(i):Ho(i,i.length)}v.prototype.listeners=function(e){return Go(this,e,!0)};v.prototype.rawListeners=function(e){return Go(this,e,!1)};v.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):zo.call(t,e)};v.prototype.listenerCount=zo;function zo(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}v.prototype.eventNames=function(){return this._eventsCount>0?Yr(this._events):[]};function Ho(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function qc(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Wc(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Gc(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}Qo(t,e,s,{once:!0}),e!=="error"&&zc(t,i,{once:!0})})}function zc(t,e,r){typeof t.on=="function"&&Qo(t,"error",e,r)}function Qo(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var Q=A((Ug,di)=>{"use strict";var Hc=pe(),{format:Qc,inspect:Kc}=li(),{codes:{ERR_INVALID_ARG_TYPE:ci}}=W(),{kResistStopPropagation:Vc,AggregateError:Jc,SymbolDispose:Yc}=P(),Zc=globalThis.AbortSignal||Bt().AbortSignal,Xc=globalThis.AbortController||Bt().AbortController,ed=Object.getPrototypeOf(async function(){}).constructor,Ko=globalThis.Blob||Hc.Blob,td=typeof Ko<"u"?function(e){return e instanceof Ko}:function(e){return!1},Vo=(t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new ci(e,"AbortSignal",t)},rd=(t,e)=>{if(typeof t!="function")throw new ci(e,"Function",t)};di.exports={AggregateError:Jc,kEmptyObject:Object.freeze({}),once(t){let e=!1;return function(...r){e||(e=!0,t.apply(this,r))}},createDeferredPromise:function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}},promisify(t){return new Promise((e,r)=>{t((n,...i)=>n?r(n):e(...i))})},debuglog(){return function(){}},format:Qc,inspect:Kc,types:{isAsyncFunction(t){return t instanceof ed},isArrayBufferView(t){return ArrayBuffer.isView(t)}},isBlob:td,deprecate(t,e){return t},addAbortListener:pr().addAbortListener||function(e,r){if(e===void 0)throw new ci("signal","AbortSignal",e);Vo(e,"signal"),rd(r,"listener");let n;return e.aborted?queueMicrotask(()=>r()):(e.addEventListener("abort",r,{__proto__:null,once:!0,[Vc]:!0}),n=()=>{e.removeEventListener("abort",r)}),{__proto__:null,[Yc](){var i;(i=n)===null||i===void 0||i()}}},AbortSignalAny:Zc.any||function(e){if(e.length===1)return e[0];let r=new Xc,n=()=>r.abort();return e.forEach(i=>{Vo(i,"signals"),i.addEventListener("abort",n,{once:!0})}),r.signal.addEventListener("abort",()=>{e.forEach(i=>i.removeEventListener("abort",n))},{once:!0}),r.signal}};di.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")});var Dt=A(($g,sa)=>{"use strict";var{ArrayIsArray:pi,ArrayPrototypeIncludes:Xo,ArrayPrototypeJoin:ea,ArrayPrototypeMap:nd,NumberIsInteger:_i,NumberIsNaN:id,NumberMAX_SAFE_INTEGER:sd,NumberMIN_SAFE_INTEGER:od,NumberParseInt:ad,ObjectPrototypeHasOwnProperty:ld,RegExpPrototypeExec:ta,String:ud,StringPrototypeToUpperCase:fd,StringPrototypeTrim:cd}=P(),{hideStackFrames:re,codes:{ERR_SOCKET_BAD_PORT:dd,ERR_INVALID_ARG_TYPE:G,ERR_INVALID_ARG_VALUE:Ct,ERR_OUT_OF_RANGE:ut,ERR_UNKNOWN_SIGNAL:Jo}}=W(),{normalizeEncoding:hd}=Q(),{isAsyncFunction:pd,isArrayBufferView:_d}=Q().types,Yo={};function yd(t){return t===(t|0)}function bd(t){return t===t>>>0}var gd=/^[0-7]+$/,md="must be a 32-bit unsigned integer or an octal string";function wd(t,e,r){if(typeof t>"u"&&(t=r),typeof t=="string"){if(ta(gd,t)===null)throw new Ct(e,t,md);t=ad(t,8)}return ra(t,e),t}var xd=re((t,e,r=od,n=sd)=>{if(typeof t!="number")throw new G(e,"number",t);if(!_i(t))throw new ut(e,"an integer",t);if(t<r||t>n)throw new ut(e,`>= ${r} && <= ${n}`,t)}),Sd=re((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new G(e,"number",t);if(!_i(t))throw new ut(e,"an integer",t);if(t<r||t>n)throw new ut(e,`>= ${r} && <= ${n}`,t)}),ra=re((t,e,r=!1)=>{if(typeof t!="number")throw new G(e,"number",t);if(!_i(t))throw new ut(e,"an integer",t);let n=r?1:0,i=4294967295;if(t<n||t>i)throw new ut(e,`>= ${n} && <= ${i}`,t)});function yi(t,e){if(typeof t!="string")throw new G(e,"string",t)}function Ed(t,e,r=void 0,n){if(typeof t!="number")throw new G(e,"number",t);if(r!=null&&t<r||n!=null&&t>n||(r!=null||n!=null)&&id(t))throw new ut(e,`${r!=null?`>= ${r}`:""}${r!=null&&n!=null?" && ":""}${n!=null?`<= ${n}`:""}`,t)}var Rd=re((t,e,r)=>{if(!Xo(r,t)){let i="must be one of: "+ea(nd(r,s=>typeof s=="string"?`'${s}'`:ud(s)),", ");throw new Ct(e,t,i)}});function na(t,e){if(typeof t!="boolean")throw new G(e,"boolean",t)}function hi(t,e,r){return t==null||!ld(t,e)?r:t[e]}var Id=re((t,e,r=null)=>{let n=hi(r,"allowArray",!1),i=hi(r,"allowFunction",!1);if(!hi(r,"nullable",!1)&&t===null||!n&&pi(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new G(e,"Object",t)}),Ad=re((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new G(e,"a dictionary",t)}),Xr=re((t,e,r=0)=>{if(!pi(t))throw new G(e,"Array",t);if(t.length<r){let n=`must be longer than ${r}`;throw new Ct(e,t,n)}});function Td(t,e){Xr(t,e);for(let r=0;r<t.length;r++)yi(t[r],`${e}[${r}]`)}function vd(t,e){Xr(t,e);for(let r=0;r<t.length;r++)na(t[r],`${e}[${r}]`)}function Nd(t,e){Xr(t,e);for(let r=0;r<t.length;r++){let n=t[r],i=`${e}[${r}]`;if(n==null)throw new G(i,"AbortSignal",n);ia(n,i)}}function jd(t,e="signal"){if(yi(t,e),Yo[t]===void 0)throw Yo[fd(t)]!==void 0?new Jo(t+" (signals must use all capital letters)"):new Jo(t)}var kd=re((t,e="buffer")=>{if(!_d(t))throw new G(e,["Buffer","TypedArray","DataView"],t)});function Pd(t,e){let r=hd(e),n=t.length;if(r==="hex"&&n%2!==0)throw new Ct("encoding",e,`is invalid for data of length ${n}`)}function Ld(t,e="Port",r=!0){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&cd(t).length===0||+t!==+t>>>0||t>65535||t===0&&!r)throw new dd(e,t,r);return t|0}var ia=re((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new G(e,"AbortSignal",t)}),Od=re((t,e)=>{if(typeof t!="function")throw new G(e,"Function",t)}),Bd=re((t,e)=>{if(typeof t!="function"||pd(t))throw new G(e,"Function",t)}),Fd=re((t,e)=>{if(t!==void 0)throw new G(e,"undefined",t)});function Cd(t,e,r){if(!Xo(r,t))throw new G(e,`('${ea(r,"|")}')`,t)}var Dd=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function Zo(t,e){if(typeof t>"u"||!ta(Dd,t))throw new Ct(e,t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}function Md(t){if(typeof t=="string")return Zo(t,"hints"),t;if(pi(t)){let e=t.length,r="";if(e===0)return r;for(let n=0;n<e;n++){let i=t[n];Zo(i,"hints"),r+=i,n!==e-1&&(r+=", ")}return r}throw new Ct("hints",t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}sa.exports={isInt32:yd,isUint32:bd,parseFileMode:wd,validateArray:Xr,validateStringArray:Td,validateBooleanArray:vd,validateAbortSignalArray:Nd,validateBoolean:na,validateBuffer:kd,validateDictionary:Ad,validateEncoding:Pd,validateFunction:Od,validateInt32:Sd,validateInteger:xd,validateNumber:Ed,validateObject:Id,validateOneOf:Rd,validatePlainFunction:Bd,validatePort:Ld,validateSignalName:jd,validateString:yi,validateUint32:ra,validateUndefined:Fd,validateUnion:Cd,validateAbortSignal:ia,validateLinkHeaderValue:Md}});var He=A((qg,ua)=>{var B=ua.exports={},ye,be;function bi(){throw new Error("setTimeout has not been defined")}function gi(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?ye=setTimeout:ye=bi}catch{ye=bi}try{typeof clearTimeout=="function"?be=clearTimeout:be=gi}catch{be=gi}})();function oa(t){if(ye===setTimeout)return setTimeout(t,0);if((ye===bi||!ye)&&setTimeout)return ye=setTimeout,setTimeout(t,0);try{return ye(t,0)}catch{try{return ye.call(null,t,0)}catch{return ye.call(this,t,0)}}}function Ud(t){if(be===clearTimeout)return clearTimeout(t);if((be===gi||!be)&&clearTimeout)return be=clearTimeout,clearTimeout(t);try{return be(t)}catch{try{return be.call(null,t)}catch{return be.call(this,t)}}}var je=[],Mt=!1,ft,en=-1;function $d(){!Mt||!ft||(Mt=!1,ft.length?je=ft.concat(je):en=-1,je.length&&aa())}function aa(){if(!Mt){var t=oa($d);Mt=!0;for(var e=je.length;e;){for(ft=je,je=[];++en<e;)ft&&ft[en].run();en=-1,e=je.length}ft=null,Mt=!1,Ud(t)}}B.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];je.push(new la(t,e)),je.length===1&&!Mt&&oa(aa)};function la(t,e){this.fun=t,this.array=e}la.prototype.run=function(){this.fun.apply(null,this.array)};B.title="browser";B.browser=!0;B.env={};B.argv=[];B.version="";B.versions={};function ke(){}B.on=ke;B.addListener=ke;B.once=ke;B.off=ke;B.removeListener=ke;B.removeAllListeners=ke;B.emit=ke;B.prependListener=ke;B.prependOnceListener=ke;B.listeners=function(t){return[]};B.binding=function(t){throw new Error("process.binding is not supported")};B.cwd=function(){return"/"};B.chdir=function(t){throw new Error("process.chdir is not supported")};B.umask=function(){return 0}});var me=A((Wg,Ra)=>{"use strict";var{SymbolAsyncIterator:fa,SymbolIterator:ca,SymbolFor:ct}=P(),da=ct("nodejs.stream.destroyed"),ha=ct("nodejs.stream.errored"),mi=ct("nodejs.stream.readable"),wi=ct("nodejs.stream.writable"),pa=ct("nodejs.stream.disturbed"),qd=ct("nodejs.webstream.isClosedPromise"),Wd=ct("nodejs.webstream.controllerErrorFunction");function tn(t,e=!1){var r;return!!(t&&typeof t.pipe=="function"&&typeof t.on=="function"&&(!e||typeof t.pause=="function"&&typeof t.resume=="function")&&(!t._writableState||((r=t._readableState)===null||r===void 0?void 0:r.readable)!==!1)&&(!t._writableState||t._readableState))}function rn(t){var e;return!!(t&&typeof t.write=="function"&&typeof t.on=="function"&&(!t._readableState||((e=t._writableState)===null||e===void 0?void 0:e.writable)!==!1))}function Gd(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function ge(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function _a(t){return!!(t&&!ge(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function ya(t){return!!(t&&!ge(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function ba(t){return!!(t&&!ge(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function zd(t){return _a(t)||ya(t)||ba(t)}function Hd(t,e){return t==null?!1:e===!0?typeof t[fa]=="function":e===!1?typeof t[ca]=="function":typeof t[fa]=="function"||typeof t[ca]=="function"}function nn(t){if(!ge(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[da]||n!=null&&n.destroyed)}function ga(t){if(!rn(t))return null;if(t.writableEnded===!0)return!0;let e=t._writableState;return e!=null&&e.errored?!1:typeof e?.ended!="boolean"?null:e.ended}function Qd(t,e){if(!rn(t))return null;if(t.writableFinished===!0)return!0;let r=t._writableState;return r!=null&&r.errored?!1:typeof r?.finished!="boolean"?null:!!(r.finished||e===!1&&r.ended===!0&&r.length===0)}function Kd(t){if(!tn(t))return null;if(t.readableEnded===!0)return!0;let e=t._readableState;return!e||e.errored?!1:typeof e?.ended!="boolean"?null:e.ended}function ma(t,e){if(!tn(t))return null;let r=t._readableState;return r!=null&&r.errored?!1:typeof r?.endEmitted!="boolean"?null:!!(r.endEmitted||e===!1&&r.ended===!0&&r.length===0)}function wa(t){return t&&t[mi]!=null?t[mi]:typeof t?.readable!="boolean"?null:nn(t)?!1:tn(t)&&t.readable&&!ma(t)}function xa(t){return t&&t[wi]!=null?t[wi]:typeof t?.writable!="boolean"?null:nn(t)?!1:rn(t)&&t.writable&&!ga(t)}function Vd(t,e){return ge(t)?nn(t)?!0:!(e?.readable!==!1&&wa(t)||e?.writable!==!1&&xa(t)):null}function Jd(t){var e,r;return ge(t)?t.writableErrored?t.writableErrored:(e=(r=t._writableState)===null||r===void 0?void 0:r.errored)!==null&&e!==void 0?e:null:null}function Yd(t){var e,r;return ge(t)?t.readableErrored?t.readableErrored:(e=(r=t._readableState)===null||r===void 0?void 0:r.errored)!==null&&e!==void 0?e:null:null}function Zd(t){if(!ge(t))return null;if(typeof t.closed=="boolean")return t.closed;let e=t._writableState,r=t._readableState;return typeof e?.closed=="boolean"||typeof r?.closed=="boolean"?e?.closed||r?.closed:typeof t._closed=="boolean"&&Sa(t)?t._closed:null}function Sa(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function Ea(t){return typeof t._sent100=="boolean"&&Sa(t)}function Xd(t){var e;return typeof t._consuming=="boolean"&&typeof t._dumped=="boolean"&&((e=t.req)===null||e===void 0?void 0:e.upgradeOrConnect)===void 0}function eh(t){if(!ge(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!n&&Ea(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function th(t){var e;return!!(t&&((e=t[pa])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function rh(t){var e,r,n,i,s,o,a,l,u,f;return!!(t&&((e=(r=(n=(i=(s=(o=t[ha])!==null&&o!==void 0?o:t.readableErrored)!==null&&s!==void 0?s:t.writableErrored)!==null&&i!==void 0?i:(a=t._readableState)===null||a===void 0?void 0:a.errorEmitted)!==null&&n!==void 0?n:(l=t._writableState)===null||l===void 0?void 0:l.errorEmitted)!==null&&r!==void 0?r:(u=t._readableState)===null||u===void 0?void 0:u.errored)!==null&&e!==void 0?e:!((f=t._writableState)===null||f===void 0)&&f.errored))}Ra.exports={isDestroyed:nn,kIsDestroyed:da,isDisturbed:th,kIsDisturbed:pa,isErrored:rh,kIsErrored:ha,isReadable:wa,kIsReadable:mi,kIsClosedPromise:qd,kControllerErrorFunction:Wd,kIsWritable:wi,isClosed:Zd,isDuplexNodeStream:Gd,isFinished:Vd,isIterable:Hd,isReadableNodeStream:tn,isReadableStream:_a,isReadableEnded:Kd,isReadableFinished:ma,isReadableErrored:Yd,isNodeStream:ge,isWebStream:zd,isWritable:xa,isWritableNodeStream:rn,isWritableStream:ya,isWritableEnded:ga,isWritableFinished:Qd,isWritableErrored:Jd,isServerRequest:Xd,isServerResponse:Ea,willEmitClose:eh,isTransformStream:ba}});var Pe=A((Gg,Ii)=>{"use strict";var Qe=He(),{AbortError:La,codes:nh}=W(),{ERR_INVALID_ARG_TYPE:ih,ERR_STREAM_PREMATURE_CLOSE:Ia}=nh,{kEmptyObject:Si,once:Ei}=Q(),{validateAbortSignal:sh,validateFunction:oh,validateObject:ah,validateBoolean:lh}=Dt(),{Promise:uh,PromisePrototypeThen:fh,SymbolDispose:Oa}=P(),{isClosed:ch,isReadable:Aa,isReadableNodeStream:xi,isReadableStream:dh,isReadableFinished:Ta,isReadableErrored:va,isWritable:Na,isWritableNodeStream:ja,isWritableStream:hh,isWritableFinished:ka,isWritableErrored:Pa,isNodeStream:ph,willEmitClose:_h,kIsClosedPromise:yh}=me(),Ut;function bh(t){return t.setHeader&&typeof t.abort=="function"}var Ri=()=>{};function Ba(t,e,r){var n,i;if(arguments.length===2?(r=e,e=Si):e==null?e=Si:ah(e,"options"),oh(r,"callback"),sh(e.signal,"options.signal"),r=Ei(r),dh(t)||hh(t))return gh(t,e,r);if(!ph(t))throw new ih("stream",["ReadableStream","WritableStream","Stream"],t);let s=(n=e.readable)!==null&&n!==void 0?n:xi(t),o=(i=e.writable)!==null&&i!==void 0?i:ja(t),a=t._writableState,l=t._readableState,u=()=>{t.writable||d()},f=_h(t)&&xi(t)===s&&ja(t)===o,c=ka(t,!1),d=()=>{c=!0,t.destroyed&&(f=!1),!(f&&(!t.readable||s))&&(!s||h)&&r.call(t)},h=Ta(t,!1),y=()=>{h=!0,t.destroyed&&(f=!1),!(f&&(!t.writable||o))&&(!o||c)&&r.call(t)},_=I=>{r.call(t,I)},x=ch(t),b=()=>{x=!0;let I=Pa(t)||va(t);if(I&&typeof I!="boolean")return r.call(t,I);if(s&&!h&&xi(t,!0)&&!Ta(t,!1))return r.call(t,new Ia);if(o&&!c&&!ka(t,!1))return r.call(t,new Ia);r.call(t)},g=()=>{x=!0;let I=Pa(t)||va(t);if(I&&typeof I!="boolean")return r.call(t,I);r.call(t)},S=()=>{t.req.on("finish",d)};bh(t)?(t.on("complete",d),f||t.on("abort",b),t.req?S():t.on("request",S)):o&&!a&&(t.on("end",u),t.on("close",u)),!f&&typeof t.aborted=="boolean"&&t.on("aborted",b),t.on("end",y),t.on("finish",d),e.error!==!1&&t.on("error",_),t.on("close",b),x?Qe.nextTick(b):a!=null&&a.errorEmitted||l!=null&&l.errorEmitted?f||Qe.nextTick(g):(!s&&(!f||Aa(t))&&(c||Na(t)===!1)||!o&&(!f||Na(t))&&(h||Aa(t)===!1)||l&&t.req&&t.aborted)&&Qe.nextTick(g);let m=()=>{r=Ri,t.removeListener("aborted",b),t.removeListener("complete",d),t.removeListener("abort",b),t.removeListener("request",S),t.req&&t.req.removeListener("finish",d),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",d),t.removeListener("end",y),t.removeListener("error",_),t.removeListener("close",b)};if(e.signal&&!x){let I=()=>{let Ae=r;m(),Ae.call(t,new La(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)Qe.nextTick(I);else{Ut=Ut||Q().addAbortListener;let Ae=Ut(e.signal,I),C=r;r=Ei((...wt)=>{Ae[Oa](),C.apply(t,wt)})}}return m}function gh(t,e,r){let n=!1,i=Ri;if(e.signal)if(i=()=>{n=!0,r.call(t,new La(void 0,{cause:e.signal.reason}))},e.signal.aborted)Qe.nextTick(i);else{Ut=Ut||Q().addAbortListener;let o=Ut(e.signal,i),a=r;r=Ei((...l)=>{o[Oa](),a.apply(t,l)})}let s=(...o)=>{n||Qe.nextTick(()=>r.apply(t,o))};return fh(t[yh].promise,s,s),Ri}function mh(t,e){var r;let n=!1;return e===null&&(e=Si),(r=e)!==null&&r!==void 0&&r.cleanup&&(lh(e.cleanup,"cleanup"),n=e.cleanup),new uh((i,s)=>{let o=Ba(t,e,a=>{n&&o(),a?s(a):i()})})}Ii.exports=Ba;Ii.exports.finished=mh});var dt=A((zg,Wa)=>{"use strict";var we=He(),{aggregateTwoErrors:wh,codes:{ERR_MULTIPLE_CALLBACK:xh},AbortError:Sh}=W(),{Symbol:Da}=P(),{kIsDestroyed:Eh,isDestroyed:Rh,isFinished:Ih,isServerRequest:Ah}=me(),Ma=Da("kDestroy"),Ai=Da("kConstruct");function Ua(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function Th(t,e){let r=this._readableState,n=this._writableState,i=n||r;return n!=null&&n.destroyed||r!=null&&r.destroyed?(typeof e=="function"&&e(),this):(Ua(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?Fa(this,t,e):this.once(Ma,function(s){Fa(this,wh(s,t),e)}),this)}function Fa(t,e,r){let n=!1;function i(s){if(n)return;n=!0;let o=t._readableState,a=t._writableState;Ua(s,a,o),a&&(a.closed=!0),o&&(o.closed=!0),typeof r=="function"&&r(s),s?we.nextTick(vh,t,s):we.nextTick($a,t)}try{t._destroy(e||null,i)}catch(s){i(s)}}function vh(t,e){Ti(t,e),$a(t)}function $a(t){let e=t._readableState,r=t._writableState;r&&(r.closeEmitted=!0),e&&(e.closeEmitted=!0),(r!=null&&r.emitClose||e!=null&&e.emitClose)&&t.emit("close")}function Ti(t,e){let r=t._readableState,n=t._writableState;n!=null&&n.errorEmitted||r!=null&&r.errorEmitted||(n&&(n.errorEmitted=!0),r&&(r.errorEmitted=!0),t.emit("error",e))}function Nh(){let t=this._readableState,e=this._writableState;t&&(t.constructed=!0,t.closed=!1,t.closeEmitted=!1,t.destroyed=!1,t.errored=null,t.errorEmitted=!1,t.reading=!1,t.ended=t.readable===!1,t.endEmitted=t.readable===!1),e&&(e.constructed=!0,e.destroyed=!1,e.closed=!1,e.closeEmitted=!1,e.errored=null,e.errorEmitted=!1,e.finalCalled=!1,e.prefinished=!1,e.ended=e.writable===!1,e.ending=e.writable===!1,e.finished=e.writable===!1)}function vi(t,e,r){let n=t._readableState,i=t._writableState;if(i!=null&&i.destroyed||n!=null&&n.destroyed)return this;n!=null&&n.autoDestroy||i!=null&&i.autoDestroy?t.destroy(e):e&&(e.stack,i&&!i.errored&&(i.errored=e),n&&!n.errored&&(n.errored=e),r?we.nextTick(Ti,t,e):Ti(t,e))}function jh(t,e){if(typeof t._construct!="function")return;let r=t._readableState,n=t._writableState;r&&(r.constructed=!1),n&&(n.constructed=!1),t.once(Ai,e),!(t.listenerCount(Ai)>1)&&we.nextTick(kh,t)}function kh(t){let e=!1;function r(n){if(e){vi(t,n??new xh);return}e=!0;let i=t._readableState,s=t._writableState,o=s||i;i&&(i.constructed=!0),s&&(s.constructed=!0),o.destroyed?t.emit(Ma,n):n?vi(t,n,!0):we.nextTick(Ph,t)}try{t._construct(n=>{we.nextTick(r,n)})}catch(n){we.nextTick(r,n)}}function Ph(t){t.emit(Ai)}function Ca(t){return t?.setHeader&&typeof t.abort=="function"}function qa(t){t.emit("close")}function Lh(t,e){t.emit("error",e),we.nextTick(qa,t)}function Oh(t,e){!t||Rh(t)||(!e&&!Ih(t)&&(e=new Sh),Ah(t)?(t.socket=null,t.destroy(e)):Ca(t)?t.abort():Ca(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?we.nextTick(Lh,t,e):we.nextTick(qa,t),t.destroyed||(t[Eh]=!0))}Wa.exports={construct:jh,destroyer:Oh,destroy:Th,undestroy:Nh,errorOrDestroy:vi}});var an=A((Hg,za)=>{"use strict";var{ArrayIsArray:Bh,ObjectSetPrototypeOf:Ga}=P(),{EventEmitter:sn}=pr();function on(t){sn.call(this,t)}Ga(on.prototype,sn.prototype);Ga(on,sn);on.prototype.pipe=function(t,e){let r=this;function n(f){t.writable&&t.write(f)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}t.on("drain",i),!t._isStdio&&(!e||e.end!==!1)&&(r.on("end",o),r.on("close",a));let s=!1;function o(){s||(s=!0,t.end())}function a(){s||(s=!0,typeof t.destroy=="function"&&t.destroy())}function l(f){u(),sn.listenerCount(this,"error")===0&&this.emit("error",f)}Ni(r,"error",l),Ni(t,"error",l);function u(){r.removeListener("data",n),t.removeListener("drain",i),r.removeListener("end",o),r.removeListener("close",a),r.removeListener("error",l),t.removeListener("error",l),r.removeListener("end",u),r.removeListener("close",u),t.removeListener("close",u)}return r.on("end",u),r.on("close",u),t.on("close",u),t.emit("pipe",r),t};function Ni(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):Bh(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}za.exports={Stream:on,prependListener:Ni}});var _r=A((Qg,ln)=>{"use strict";var{SymbolDispose:Fh}=P(),{AbortError:Ha,codes:Ch}=W(),{isNodeStream:Qa,isWebStream:Dh,kControllerErrorFunction:Mh}=me(),Uh=Pe(),{ERR_INVALID_ARG_TYPE:Ka}=Ch,ji,$h=(t,e)=>{if(typeof t!="object"||!("aborted"in t))throw new Ka(e,"AbortSignal",t)};ln.exports.addAbortSignal=function(e,r){if($h(e,"signal"),!Qa(r)&&!Dh(r))throw new Ka("stream",["ReadableStream","WritableStream","Stream"],r);return ln.exports.addAbortSignalNoValidate(e,r)};ln.exports.addAbortSignalNoValidate=function(t,e){if(typeof t!="object"||!("aborted"in t))return e;let r=Qa(e)?()=>{e.destroy(new Ha(void 0,{cause:t.reason}))}:()=>{e[Mh](new Ha(void 0,{cause:t.reason}))};if(t.aborted)r();else{ji=ji||Q().addAbortListener;let n=ji(t,r);Uh(e,n[Fh])}return e}});var Ya=A((Vg,Ja)=>{"use strict";var{StringPrototypeSlice:Va,SymbolIterator:qh,TypedArrayPrototypeSet:un,Uint8Array:Wh}=P(),{Buffer:ki}=pe(),{inspect:Gh}=Q();Ja.exports=class{constructor(){this.head=null,this.tail=null,this.length=0}push(e){let r={data:e,next:null};this.length>0?this.tail.next=r:this.head=r,this.tail=r,++this.length}unshift(e){let r={data:e,next:this.head};this.length===0&&(this.tail=r),this.head=r,++this.length}shift(){if(this.length===0)return;let e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}clear(){this.head=this.tail=null,this.length=0}join(e){if(this.length===0)return"";let r=this.head,n=""+r.data;for(;(r=r.next)!==null;)n+=e+r.data;return n}concat(e){if(this.length===0)return ki.alloc(0);let r=ki.allocUnsafe(e>>>0),n=this.head,i=0;for(;n;)un(r,n.data,i),i+=n.data.length,n=n.next;return r}consume(e,r){let n=this.head.data;if(e<n.length){let i=n.slice(0,e);return this.head.data=n.slice(e),i}return e===n.length?this.shift():r?this._getString(e):this._getBuffer(e)}first(){return this.head.data}*[qh](){for(let e=this.head;e;e=e.next)yield e.data}_getString(e){let r="",n=this.head,i=0;do{let s=n.data;if(e>s.length)r+=s,e-=s.length;else{e===s.length?(r+=s,++i,n.next?this.head=n.next:this.head=this.tail=null):(r+=Va(s,0,e),this.head=n,n.data=Va(s,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){let r=ki.allocUnsafe(e),n=e,i=this.head,s=0;do{let o=i.data;if(e>o.length)un(r,o,n-e),e-=o.length;else{e===o.length?(un(r,o,n-e),++s,i.next?this.head=i.next:this.head=this.tail=null):(un(r,new Wh(o.buffer,o.byteOffset,e),n-e),this.head=i,i.data=o.slice(e));break}++s}while((i=i.next)!==null);return this.length-=s,r}[Symbol.for("nodejs.util.inspect.custom")](e,r){return Gh(this,{...r,depth:0,customInspect:!1})}}});var yr=A((Jg,tl)=>{"use strict";var{MathFloor:zh,NumberIsInteger:Hh}=P(),{validateInteger:Qh}=Dt(),{ERR_INVALID_ARG_VALUE:Kh}=W().codes,Za=16*1024,Xa=16;function Vh(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function el(t){return t?Xa:Za}function Jh(t,e){Qh(e,"value",0),t?Xa=e:Za=e}function Yh(t,e,r,n){let i=Vh(e,n,r);if(i!=null){if(!Hh(i)||i<0){let s=n?`options.${r}`:"options.highWaterMark";throw new Kh(s,i)}return zh(i)}return el(t.objectMode)}tl.exports={getHighWaterMark:Yh,getDefaultHighWaterMark:el,setDefaultHighWaterMark:Jh}});var il=A((Pi,nl)=>{var fn=pe(),xe=fn.Buffer;function rl(t,e){for(var r in t)e[r]=t[r]}xe.from&&xe.alloc&&xe.allocUnsafe&&xe.allocUnsafeSlow?nl.exports=fn:(rl(fn,Pi),Pi.Buffer=ht);function ht(t,e,r){return xe(t,e,r)}ht.prototype=Object.create(xe.prototype);rl(xe,ht);ht.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return xe(t,e,r)};ht.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=xe(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};ht.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return xe(t)};ht.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return fn.SlowBuffer(t)}});var al=A(ol=>{"use strict";var Oi=il().Buffer,sl=Oi.isEncoding||function(t){switch(t=""+t,t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Zh(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function Xh(t){var e=Zh(t);if(typeof e!="string"&&(Oi.isEncoding===sl||!sl(t)))throw new Error("Unknown encoding: "+t);return e||t}ol.StringDecoder=br;function br(t){this.encoding=Xh(t);var e;switch(this.encoding){case"utf16le":this.text=sp,this.end=op,e=4;break;case"utf8":this.fillLast=rp,e=4;break;case"base64":this.text=ap,this.end=lp,e=3;break;default:this.write=up,this.end=fp;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Oi.allocUnsafe(e)}br.prototype.write=function(t){if(t.length===0)return"";var e,r;if(this.lastNeed){if(e=this.fillLast(t),e===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""};br.prototype.end=ip;br.prototype.text=np;br.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length};function Li(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function ep(t,e,r){var n=e.length-1;if(n<r)return 0;var i=Li(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||i===-2?0:(i=Li(e[n]),i>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||i===-2?0:(i=Li(e[n]),i>=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function tp(t,e,r){if((e[0]&192)!==128)return t.lastNeed=0,"\uFFFD";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"\uFFFD";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"\uFFFD"}}function rp(t){var e=this.lastTotal-this.lastNeed,r=tp(this,t,e);if(r!==void 0)return r;if(this.lastNeed<=t.length)return t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,e,0,t.length),this.lastNeed-=t.length}function np(t,e){var r=ep(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)}function ip(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function sp(t,e){if((t.length-e)%2===0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function op(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function ap(t,e){var r=(t.length-e)%3;return r===0?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function lp(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function up(t){return t.toString(this.encoding)}function fp(t){return t&&t.length?this.write(t):""}});var Bi=A((Zg,cl)=>{"use strict";var ll=He(),{PromisePrototypeThen:cp,SymbolAsyncIterator:ul,SymbolIterator:fl}=P(),{Buffer:dp}=pe(),{ERR_INVALID_ARG_TYPE:hp,ERR_STREAM_NULL_VALUES:pp}=W().codes;function _p(t,e,r){let n;if(typeof e=="string"||e instanceof dp)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[ul])i=!0,n=e[ul]();else if(e&&e[fl])i=!1,n=e[fl]();else throw new hp("iterable",["Iterable"],e);let s=new t({objectMode:!0,highWaterMark:1,...r}),o=!1;s._read=function(){o||(o=!0,l())},s._destroy=function(u,f){cp(a(u),()=>ll.nextTick(f,u),c=>ll.nextTick(f,c||u))};async function a(u){let f=u!=null,c=typeof n.throw=="function";if(f&&c){let{value:d,done:h}=await n.throw(u);if(await d,h)return}if(typeof n.return=="function"){let{value:d}=await n.return();await d}}async function l(){for(;;){try{let{value:u,done:f}=i?await n.next():n.next();if(f)s.push(null);else{let c=u&&typeof u.then=="function"?await u:u;if(c===null)throw o=!1,new pp;if(s.push(c))continue;o=!1}}catch(u){s.destroy(u)}break}}return s}cl.exports=_p});var mr=A((Xg,Nl)=>{"use strict";var oe=He(),{ArrayPrototypeIndexOf:yp,NumberIsInteger:bp,NumberIsNaN:gp,NumberParseInt:mp,ObjectDefineProperties:Wi,ObjectKeys:wp,ObjectSetPrototypeOf:pl,Promise:_l,SafeSet:xp,SymbolAsyncDispose:Sp,SymbolAsyncIterator:Ep,Symbol:Rp}=P();Nl.exports=E;E.ReadableState=pn;var{EventEmitter:Ip}=pr(),{Stream:Ke,prependListener:Ap}=an(),{Buffer:Fi}=pe(),{addAbortSignal:Tp}=_r(),yl=Pe(),R=Q().debuglog("stream",t=>{R=t}),vp=Ya(),Wt=dt(),{getHighWaterMark:Np,getDefaultHighWaterMark:jp}=yr(),{aggregateTwoErrors:dl,codes:{ERR_INVALID_ARG_TYPE:kp,ERR_METHOD_NOT_IMPLEMENTED:Pp,ERR_OUT_OF_RANGE:Lp,ERR_STREAM_PUSH_AFTER_EOF:Op,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:Bp},AbortError:Fp}=W(),{validateObject:Cp}=Dt(),pt=Rp("kPaused"),{StringDecoder:bl}=al(),Dp=Bi();pl(E.prototype,Ke.prototype);pl(E,Ke);var Ci=()=>{},{errorOrDestroy:$t}=Wt,qt=1,Mp=2,gl=4,gr=8,ml=16,cn=32,dn=64,wl=128,Up=256,$p=512,qp=1024,$i=2048,qi=4096,Wp=8192,Gp=16384,zp=32768,xl=65536,Hp=1<<17,Qp=1<<18;function D(t){return{enumerable:!1,get(){return(this.state&t)!==0},set(e){e?this.state|=t:this.state&=~t}}}Wi(pn.prototype,{objectMode:D(qt),ended:D(Mp),endEmitted:D(gl),reading:D(gr),constructed:D(ml),sync:D(cn),needReadable:D(dn),emittedReadable:D(wl),readableListening:D(Up),resumeScheduled:D($p),errorEmitted:D(qp),emitClose:D($i),autoDestroy:D(qi),destroyed:D(Wp),closed:D(Gp),closeEmitted:D(zp),multiAwaitDrain:D(xl),readingMore:D(Hp),dataEmitted:D(Qp)});function pn(t,e,r){typeof r!="boolean"&&(r=e instanceof Se()),this.state=$i|qi|ml|cn,t&&t.objectMode&&(this.state|=qt),r&&t&&t.readableObjectMode&&(this.state|=qt),this.highWaterMark=t?Np(this,t,"readableHighWaterMark",r):jp(!1),this.buffer=new vp,this.length=0,this.pipes=[],this.flowing=null,this[pt]=null,t&&t.emitClose===!1&&(this.state&=~$i),t&&t.autoDestroy===!1&&(this.state&=~qi),this.errored=null,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,t&&t.encoding&&(this.decoder=new bl(t.encoding),this.encoding=t.encoding)}function E(t){if(!(this instanceof E))return new E(t);let e=this instanceof Se();this._readableState=new pn(t,this,e),t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.construct=="function"&&(this._construct=t.construct),t.signal&&!e&&Tp(t.signal,this)),Ke.call(this,t),Wt.construct(this,()=>{this._readableState.needReadable&&hn(this,this._readableState)})}E.prototype.destroy=Wt.destroy;E.prototype._undestroy=Wt.undestroy;E.prototype._destroy=function(t,e){e(t)};E.prototype[Ip.captureRejectionSymbol]=function(t){this.destroy(t)};E.prototype[Sp]=function(){let t;return this.destroyed||(t=this.readableEnded?null:new Fp,this.destroy(t)),new _l((e,r)=>yl(this,n=>n&&n!==t?r(n):e(null)))};E.prototype.push=function(t,e){return Sl(this,t,e,!1)};E.prototype.unshift=function(t,e){return Sl(this,t,e,!0)};function Sl(t,e,r,n){R("readableAddChunk",e);let i=t._readableState,s;if((i.state&qt)===0&&(typeof e=="string"?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?e=Fi.from(e,r).toString(i.encoding):(e=Fi.from(e,r),r=""))):e instanceof Fi?r="":Ke._isUint8Array(e)?(e=Ke._uint8ArrayToBuffer(e),r=""):e!=null&&(s=new kp("chunk",["string","Buffer","Uint8Array"],e))),s)$t(t,s);else if(e===null)i.state&=~gr,Jp(t,i);else if((i.state&qt)!==0||e&&e.length>0)if(n)if((i.state&gl)!==0)$t(t,new Bp);else{if(i.destroyed||i.errored)return!1;Di(t,i,e,!0)}else if(i.ended)$t(t,new Op);else{if(i.destroyed||i.errored)return!1;i.state&=~gr,i.decoder&&!r?(e=i.decoder.write(e),i.objectMode||e.length!==0?Di(t,i,e,!1):hn(t,i)):Di(t,i,e,!1)}else n||(i.state&=~gr,hn(t,i));return!i.ended&&(i.length<i.highWaterMark||i.length===0)}function Di(t,e,r,n){e.flowing&&e.length===0&&!e.sync&&t.listenerCount("data")>0?((e.state&xl)!==0?e.awaitDrainWriters.clear():e.awaitDrainWriters=null,e.dataEmitted=!0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),(e.state&dn)!==0&&_n(t)),hn(t,e)}E.prototype.isPaused=function(){let t=this._readableState;return t[pt]===!0||t.flowing===!1};E.prototype.setEncoding=function(t){let e=new bl(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;let r=this._readableState.buffer,n="";for(let i of r)n+=e.write(i);return r.clear(),n!==""&&r.push(n),this._readableState.length=n.length,this};var Kp=1073741824;function Vp(t){if(t>Kp)throw new Lp("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++,t}function hl(t,e){return t<=0||e.length===0&&e.ended?0:(e.state&qt)!==0?1:gp(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}E.prototype.read=function(t){R("read",t),t===void 0?t=NaN:bp(t)||(t=mp(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=Vp(t)),t!==0&&(e.state&=~wl),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return R("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?Mi(this):_n(this),null;if(t=hl(t,e),t===0&&e.ended)return e.length===0&&Mi(this),null;let n=(e.state&dn)!==0;if(R("need readable",n),(e.length===0||e.length-t<e.highWaterMark)&&(n=!0,R("length less than watermark",n)),e.ended||e.reading||e.destroyed||e.errored||!e.constructed)n=!1,R("reading, ended or constructing",n);else if(n){R("do read"),e.state|=gr|cn,e.length===0&&(e.state|=dn);try{this._read(e.highWaterMark)}catch(s){$t(this,s)}e.state&=~cn,e.reading||(t=hl(r,e))}let i;return t>0?i=Tl(t,e):i=null,i===null?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.multiAwaitDrain?e.awaitDrainWriters.clear():e.awaitDrainWriters=null),e.length===0&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&Mi(this)),i!==null&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit("data",i)),i};function Jp(t,e){if(R("onEofChunk"),!e.ended){if(e.decoder){let r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?_n(t):(e.needReadable=!1,e.emittedReadable=!0,El(t))}}function _n(t){let e=t._readableState;R("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(R("emitReadable",e.flowing),e.emittedReadable=!0,oe.nextTick(El,t))}function El(t){let e=t._readableState;R("emitReadable_",e.destroyed,e.length,e.ended),!e.destroyed&&!e.errored&&(e.length||e.ended)&&(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,Il(t)}function hn(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,oe.nextTick(Yp,t,e))}function Yp(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&e.length===0);){let r=e.length;if(R("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}E.prototype._read=function(t){throw new Pp("_read()")};E.prototype.pipe=function(t,e){let r=this,n=this._readableState;n.pipes.length===1&&(n.multiAwaitDrain||(n.multiAwaitDrain=!0,n.awaitDrainWriters=new xp(n.awaitDrainWriters?[n.awaitDrainWriters]:[]))),n.pipes.push(t),R("pipe count=%d opts=%j",n.pipes.length,e);let s=(!e||e.end!==!1)&&t!==oe.stdout&&t!==oe.stderr?a:x;n.endEmitted?oe.nextTick(s):r.once("end",s),t.on("unpipe",o);function o(b,g){R("onunpipe"),b===r&&g&&g.hasUnpiped===!1&&(g.hasUnpiped=!0,f())}function a(){R("onend"),t.end()}let l,u=!1;function f(){R("cleanup"),t.removeListener("close",y),t.removeListener("finish",_),l&&t.removeListener("drain",l),t.removeListener("error",h),t.removeListener("unpipe",o),r.removeListener("end",a),r.removeListener("end",x),r.removeListener("data",d),u=!0,l&&n.awaitDrainWriters&&(!t._writableState||t._writableState.needDrain)&&l()}function c(){u||(n.pipes.length===1&&n.pipes[0]===t?(R("false write response, pause",0),n.awaitDrainWriters=t,n.multiAwaitDrain=!1):n.pipes.length>1&&n.pipes.includes(t)&&(R("false write response, pause",n.awaitDrainWriters.size),n.awaitDrainWriters.add(t)),r.pause()),l||(l=Zp(r,t),t.on("drain",l))}r.on("data",d);function d(b){R("ondata");let g=t.write(b);R("dest.write",g),g===!1&&c()}function h(b){if(R("onerror",b),x(),t.removeListener("error",h),t.listenerCount("error")===0){let g=t._writableState||t._readableState;g&&!g.errorEmitted?$t(t,b):t.emit("error",b)}}Ap(t,"error",h);function y(){t.removeListener("finish",_),x()}t.once("close",y);function _(){R("onfinish"),t.removeListener("close",y),x()}t.once("finish",_);function x(){R("unpipe"),r.unpipe(t)}return t.emit("pipe",r),t.writableNeedDrain===!0?c():n.flowing||(R("pipe resume"),r.resume()),t};function Zp(t,e){return function(){let n=t._readableState;n.awaitDrainWriters===e?(R("pipeOnDrain",1),n.awaitDrainWriters=null):n.multiAwaitDrain&&(R("pipeOnDrain",n.awaitDrainWriters.size),n.awaitDrainWriters.delete(e)),(!n.awaitDrainWriters||n.awaitDrainWriters.size===0)&&t.listenerCount("data")&&t.resume()}}E.prototype.unpipe=function(t){let e=this._readableState,r={hasUnpiped:!1};if(e.pipes.length===0)return this;if(!t){let i=e.pipes;e.pipes=[],this.pause();for(let s=0;s<i.length;s++)i[s].emit("unpipe",this,{hasUnpiped:!1});return this}let n=yp(e.pipes,t);return n===-1?this:(e.pipes.splice(n,1),e.pipes.length===0&&this.pause(),t.emit("unpipe",this,r),this)};E.prototype.on=function(t,e){let r=Ke.prototype.on.call(this,t,e),n=this._readableState;return t==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,R("on readable",n.length,n.reading),n.length?_n(this):n.reading||oe.nextTick(Xp,this)),r};E.prototype.addListener=E.prototype.on;E.prototype.removeListener=function(t,e){let r=Ke.prototype.removeListener.call(this,t,e);return t==="readable"&&oe.nextTick(Rl,this),r};E.prototype.off=E.prototype.removeListener;E.prototype.removeAllListeners=function(t){let e=Ke.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&oe.nextTick(Rl,this),e};function Rl(t){let e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&e[pt]===!1?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function Xp(t){R("readable nexttick read 0"),t.read(0)}E.prototype.resume=function(){let t=this._readableState;return t.flowing||(R("resume"),t.flowing=!t.readableListening,e_(this,t)),t[pt]=!1,this};function e_(t,e){e.resumeScheduled||(e.resumeScheduled=!0,oe.nextTick(t_,t,e))}function t_(t,e){R("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Il(t),e.flowing&&!e.reading&&t.read(0)}E.prototype.pause=function(){return R("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(R("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[pt]=!0,this};function Il(t){let e=t._readableState;for(R("flow",e.flowing);e.flowing&&t.read()!==null;);}E.prototype.wrap=function(t){let e=!1;t.on("data",n=>{!this.push(n)&&t.pause&&(e=!0,t.pause())}),t.on("end",()=>{this.push(null)}),t.on("error",n=>{$t(this,n)}),t.on("close",()=>{this.destroy()}),t.on("destroy",()=>{this.destroy()}),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};let r=wp(t);for(let n=1;n<r.length;n++){let i=r[n];this[i]===void 0&&typeof t[i]=="function"&&(this[i]=t[i].bind(t))}return this};E.prototype[Ep]=function(){return Al(this)};E.prototype.iterator=function(t){return t!==void 0&&Cp(t,"options"),Al(this,t)};function Al(t,e){typeof t.read!="function"&&(t=E.wrap(t,{objectMode:!0}));let r=r_(t,e);return r.stream=t,r}async function*r_(t,e){let r=Ci;function n(o){this===t?(r(),r=Ci):r=o}t.on("readable",n);let i,s=yl(t,{writable:!1},o=>{i=o?dl(i,o):null,r(),r=Ci});try{for(;;){let o=t.destroyed?null:t.read();if(o!==null)yield o;else{if(i)throw i;if(i===null)return;await new _l(n)}}}catch(o){throw i=dl(i,o),i}finally{(i||e?.destroyOnReturn!==!1)&&(i===void 0||t._readableState.autoDestroy)?Wt.destroyer(t,null):(t.off("readable",n),s())}}Wi(E.prototype,{readable:{__proto__:null,get(){let t=this._readableState;return!!t&&t.readable!==!1&&!t.destroyed&&!t.errorEmitted&&!t.endEmitted},set(t){this._readableState&&(this._readableState.readable=!!t)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return this._readableState?this._readableState.closed:!1}},destroyed:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(t){this._readableState&&(this._readableState.destroyed=t)}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}});Wi(pn.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[pt]!==!1},set(t){this[pt]=!!t}}});E._fromList=Tl;function Tl(t,e){if(e.length===0)return null;let r;return e.objectMode?r=e.buffer.shift():!t||t>=e.length?(e.decoder?r=e.buffer.join(""):e.buffer.length===1?r=e.buffer.first():r=e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r}function Mi(t){let e=t._readableState;R("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,oe.nextTick(n_,e,t))}function n_(t,e){if(R("endReadableNT",t.endEmitted,t.length),!t.errored&&!t.closeEmitted&&!t.endEmitted&&t.length===0){if(t.endEmitted=!0,e.emit("end"),e.writable&&e.allowHalfOpen===!1)oe.nextTick(i_,e);else if(t.autoDestroy){let r=e._writableState;(!r||r.autoDestroy&&(r.finished||r.writable===!1))&&e.destroy()}}}function i_(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}E.from=function(t,e){return Dp(E,t,e)};var Ui;function vl(){return Ui===void 0&&(Ui={}),Ui}E.fromWeb=function(t,e){return vl().newStreamReadableFromReadableStream(t,e)};E.toWeb=function(t,e){return vl().newReadableStreamFromStreamReadable(t,e)};E.wrap=function(t,e){var r,n;return new E({objectMode:(r=(n=t.readableObjectMode)!==null&&n!==void 0?n:t.objectMode)!==null&&r!==void 0?r:!0,...e,destroy(i,s){Wt.destroyer(t,i),s(i)}}).wrap(t)}});var wn=A((em,$l)=>{"use strict";var _t=He(),{ArrayPrototypeSlice:Pl,Error:s_,FunctionPrototypeSymbolHasInstance:Ll,ObjectDefineProperty:Ol,ObjectDefineProperties:o_,ObjectSetPrototypeOf:Bl,StringPrototypeToLowerCase:a_,Symbol:l_,SymbolHasInstance:u_}=P();$l.exports=L;L.WritableState=Sr;var{EventEmitter:f_}=pr(),wr=an().Stream,{Buffer:yn}=pe(),mn=dt(),{addAbortSignal:c_}=_r(),{getHighWaterMark:d_,getDefaultHighWaterMark:h_}=yr(),{ERR_INVALID_ARG_TYPE:p_,ERR_METHOD_NOT_IMPLEMENTED:__,ERR_MULTIPLE_CALLBACK:Fl,ERR_STREAM_CANNOT_PIPE:y_,ERR_STREAM_DESTROYED:xr,ERR_STREAM_ALREADY_FINISHED:b_,ERR_STREAM_NULL_VALUES:g_,ERR_STREAM_WRITE_AFTER_END:m_,ERR_UNKNOWN_ENCODING:Cl}=W().codes,{errorOrDestroy:Gt}=mn;Bl(L.prototype,wr.prototype);Bl(L,wr);function Hi(){}var zt=l_("kOnFinished");function Sr(t,e,r){typeof r!="boolean"&&(r=e instanceof Se()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.writableObjectMode)),this.highWaterMark=t?d_(this,t,"writableHighWaterMark",r):h_(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;let n=!!(t&&t.decodeStrings===!1);this.decodeStrings=!n,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=x_.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,gn(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!t||t.emitClose!==!1,this.autoDestroy=!t||t.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[zt]=[]}function gn(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}Sr.prototype.getBuffer=function(){return Pl(this.buffered,this.bufferedIndex)};Ol(Sr.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function L(t){let e=this instanceof Se();if(!e&&!Ll(L,this))return new L(t);this._writableState=new Sr(t,this,e),t&&(typeof t.write=="function"&&(this._write=t.write),typeof t.writev=="function"&&(this._writev=t.writev),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.final=="function"&&(this._final=t.final),typeof t.construct=="function"&&(this._construct=t.construct),t.signal&&c_(t.signal,this)),wr.call(this,t),mn.construct(this,()=>{let r=this._writableState;r.writing||Ki(this,r),Vi(this,r)})}Ol(L,u_,{__proto__:null,value:function(t){return Ll(this,t)?!0:this!==L?!1:t&&t._writableState instanceof Sr}});L.prototype.pipe=function(){Gt(this,new y_)};function Dl(t,e,r,n){let i=t._writableState;if(typeof r=="function")n=r,r=i.defaultEncoding;else{if(!r)r=i.defaultEncoding;else if(r!=="buffer"&&!yn.isEncoding(r))throw new Cl(r);typeof n!="function"&&(n=Hi)}if(e===null)throw new g_;if(!i.objectMode)if(typeof e=="string")i.decodeStrings!==!1&&(e=yn.from(e,r),r="buffer");else if(e instanceof yn)r="buffer";else if(wr._isUint8Array(e))e=wr._uint8ArrayToBuffer(e),r="buffer";else throw new p_("chunk",["string","Buffer","Uint8Array"],e);let s;return i.ending?s=new m_:i.destroyed&&(s=new xr("write")),s?(_t.nextTick(n,s),Gt(t,s,!0),s):(i.pendingcb++,w_(t,i,e,r,n))}L.prototype.write=function(t,e,r){return Dl(this,t,e,r)===!0};L.prototype.cork=function(){this._writableState.corked++};L.prototype.uncork=function(){let t=this._writableState;t.corked&&(t.corked--,t.writing||Ki(this,t))};L.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=a_(e)),!yn.isEncoding(e))throw new Cl(e);return this._writableState.defaultEncoding=e,this};function w_(t,e,r,n,i){let s=e.objectMode?1:r.length;e.length+=s;let o=e.length<e.highWaterMark;return o||(e.needDrain=!0),e.writing||e.corked||e.errored||!e.constructed?(e.buffered.push({chunk:r,encoding:n,callback:i}),e.allBuffers&&n!=="buffer"&&(e.allBuffers=!1),e.allNoop&&i!==Hi&&(e.allNoop=!1)):(e.writelen=s,e.writecb=i,e.writing=!0,e.sync=!0,t._write(r,n,e.onwrite),e.sync=!1),o&&!e.errored&&!e.destroyed}function jl(t,e,r,n,i,s,o){e.writelen=n,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new xr("write")):r?t._writev(i,e.onwrite):t._write(i,s,e.onwrite),e.sync=!1}function kl(t,e,r,n){--e.pendingcb,n(r),Qi(e),Gt(t,r)}function x_(t,e){let r=t._writableState,n=r.sync,i=r.writecb;if(typeof i!="function"){Gt(t,new Fl);return}r.writing=!1,r.writecb=null,r.length-=r.writelen,r.writelen=0,e?(e.stack,r.errored||(r.errored=e),t._readableState&&!t._readableState.errored&&(t._readableState.errored=e),n?_t.nextTick(kl,t,r,e,i):kl(t,r,e,i)):(r.buffered.length>r.bufferedIndex&&Ki(t,r),n?r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===i?r.afterWriteTickInfo.count++:(r.afterWriteTickInfo={count:1,cb:i,stream:t,state:r},_t.nextTick(S_,r.afterWriteTickInfo)):Ml(t,r,1,i))}function S_({stream:t,state:e,count:r,cb:n}){return e.afterWriteTickInfo=null,Ml(t,e,r,n)}function Ml(t,e,r,n){for(!e.ending&&!t.destroyed&&e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"));r-- >0;)e.pendingcb--,n();e.destroyed&&Qi(e),Vi(t,e)}function Qi(t){if(t.writing)return;for(let i=t.bufferedIndex;i<t.buffered.length;++i){var e;let{chunk:s,callback:o}=t.buffered[i],a=t.objectMode?1:s.length;t.length-=a,o((e=t.errored)!==null&&e!==void 0?e:new xr("write"))}let r=t[zt].splice(0);for(let i=0;i<r.length;i++){var n;r[i]((n=t.errored)!==null&&n!==void 0?n:new xr("end"))}gn(t)}function Ki(t,e){if(e.corked||e.bufferProcessing||e.destroyed||!e.constructed)return;let{buffered:r,bufferedIndex:n,objectMode:i}=e,s=r.length-n;if(!s)return;let o=n;if(e.bufferProcessing=!0,s>1&&t._writev){e.pendingcb-=s-1;let a=e.allNoop?Hi:u=>{for(let f=o;f<r.length;++f)r[f].callback(u)},l=e.allNoop&&o===0?r:Pl(r,o);l.allBuffers=e.allBuffers,jl(t,e,!0,e.length,l,"",a),gn(e)}else{do{let{chunk:a,encoding:l,callback:u}=r[o];r[o++]=null;let f=i?1:a.length;jl(t,e,!1,f,a,l,u)}while(o<r.length&&!e.writing);o===r.length?gn(e):o>256?(r.splice(0,o),e.bufferedIndex=0):e.bufferedIndex=o}e.bufferProcessing=!1}L.prototype._write=function(t,e,r){if(this._writev)this._writev([{chunk:t,encoding:e}],r);else throw new __("_write()")};L.prototype._writev=null;L.prototype.end=function(t,e,r){let n=this._writableState;typeof t=="function"?(r=t,t=null,e=null):typeof e=="function"&&(r=e,e=null);let i;if(t!=null){let s=Dl(this,t,e);s instanceof s_&&(i=s)}return n.corked&&(n.corked=1,this.uncork()),i||(!n.errored&&!n.ending?(n.ending=!0,Vi(this,n,!0),n.ended=!0):n.finished?i=new b_("end"):n.destroyed&&(i=new xr("end"))),typeof r=="function"&&(i||n.finished?_t.nextTick(r,i):n[zt].push(r)),this};function bn(t){return t.ending&&!t.destroyed&&t.constructed&&t.length===0&&!t.errored&&t.buffered.length===0&&!t.finished&&!t.writing&&!t.errorEmitted&&!t.closeEmitted}function E_(t,e){let r=!1;function n(i){if(r){Gt(t,i??Fl());return}if(r=!0,e.pendingcb--,i){let s=e[zt].splice(0);for(let o=0;o<s.length;o++)s[o](i);Gt(t,i,e.sync)}else bn(e)&&(e.prefinished=!0,t.emit("prefinish"),e.pendingcb++,_t.nextTick(zi,t,e))}e.sync=!0,e.pendingcb++;try{t._final(n)}catch(i){n(i)}e.sync=!1}function R_(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.finalCalled=!0,E_(t,e)):(e.prefinished=!0,t.emit("prefinish")))}function Vi(t,e,r){bn(e)&&(R_(t,e),e.pendingcb===0&&(r?(e.pendingcb++,_t.nextTick((n,i)=>{bn(i)?zi(n,i):i.pendingcb--},t,e)):bn(e)&&(e.pendingcb++,zi(t,e))))}function zi(t,e){e.pendingcb--,e.finished=!0;let r=e[zt].splice(0);for(let n=0;n<r.length;n++)r[n]();if(t.emit("finish"),e.autoDestroy){let n=t._readableState;(!n||n.autoDestroy&&(n.endEmitted||n.readable===!1))&&t.destroy()}}o_(L.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(t){this._writableState&&(this._writableState.destroyed=t)}},writable:{__proto__:null,get(){let t=this._writableState;return!!t&&t.writable!==!1&&!t.destroyed&&!t.errored&&!t.ending&&!t.ended},set(t){this._writableState&&(this._writableState.writable=!!t)}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){let t=this._writableState;return t?!t.destroyed&&!t.ending&&t.needDrain:!1}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)}}});var I_=mn.destroy;L.prototype.destroy=function(t,e){let r=this._writableState;return!r.destroyed&&(r.bufferedIndex<r.buffered.length||r[zt].length)&&_t.nextTick(Qi,r),I_.call(this,t,e),this};L.prototype._undestroy=mn.undestroy;L.prototype._destroy=function(t,e){e(t)};L.prototype[f_.captureRejectionSymbol]=function(t){this.destroy(t)};var Gi;function Ul(){return Gi===void 0&&(Gi={}),Gi}L.fromWeb=function(t,e){return Ul().newStreamWritableFromWritableStream(t,e)};L.toWeb=function(t){return Ul().newWritableStreamFromStreamWritable(t)}});var ru=A((tm,tu)=>{var Ji=He(),A_=pe(),{isReadable:T_,isWritable:v_,isIterable:ql,isNodeStream:N_,isReadableNodeStream:Wl,isWritableNodeStream:Gl,isDuplexNodeStream:j_,isReadableStream:zl,isWritableStream:Hl}=me(),Ql=Pe(),{AbortError:Xl,codes:{ERR_INVALID_ARG_TYPE:k_,ERR_INVALID_RETURN_VALUE:Kl}}=W(),{destroyer:Qt}=dt(),P_=Se(),eu=mr(),L_=wn(),{createDeferredPromise:Vl}=Q(),Jl=Bi(),Yl=globalThis.Blob||A_.Blob,O_=typeof Yl<"u"?function(e){return e instanceof Yl}:function(e){return!1},B_=globalThis.AbortController||Bt().AbortController,{FunctionPrototypeCall:Zl}=P(),Ve=class extends P_{constructor(e){super(e),e?.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),e?.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}};tu.exports=function t(e,r){if(j_(e))return e;if(Wl(e))return Ht({readable:e});if(Gl(e))return Ht({writable:e});if(N_(e))return Ht({writable:!1,readable:!1});if(zl(e))return Ht({readable:eu.fromWeb(e)});if(Hl(e))return Ht({writable:L_.fromWeb(e)});if(typeof e=="function"){let{value:i,write:s,final:o,destroy:a}=F_(e);if(ql(i))return Jl(Ve,i,{objectMode:!0,write:s,final:o,destroy:a});let l=i?.then;if(typeof l=="function"){let u,f=Zl(l,i,c=>{if(c!=null)throw new Kl("nully","body",c)},c=>{Qt(u,c)});return u=new Ve({objectMode:!0,readable:!1,write:s,final(c){o(async()=>{try{await f,Ji.nextTick(c,null)}catch(d){Ji.nextTick(c,d)}})},destroy:a})}throw new Kl("Iterable, AsyncIterable or AsyncFunction",r,i)}if(O_(e))return t(e.arrayBuffer());if(ql(e))return Jl(Ve,e,{objectMode:!0,writable:!1});if(zl(e?.readable)&&Hl(e?.writable))return Ve.fromWeb(e);if(typeof e?.writable=="object"||typeof e?.readable=="object"){let i=e!=null&&e.readable?Wl(e?.readable)?e?.readable:t(e.readable):void 0,s=e!=null&&e.writable?Gl(e?.writable)?e?.writable:t(e.writable):void 0;return Ht({readable:i,writable:s})}let n=e?.then;if(typeof n=="function"){let i;return Zl(n,e,s=>{s!=null&&i.push(s),i.push(null)},s=>{Qt(i,s)}),i=new Ve({objectMode:!0,writable:!1,read(){}})}throw new k_(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)};function F_(t){let{promise:e,resolve:r}=Vl(),n=new B_,i=n.signal;return{value:t((async function*(){for(;;){let o=e;e=null;let{chunk:a,done:l,cb:u}=await o;if(Ji.nextTick(u),l)return;if(i.aborted)throw new Xl(void 0,{cause:i.reason});({promise:e,resolve:r}=Vl()),yield a}})(),{signal:i}),write(o,a,l){let u=r;r=null,u({chunk:o,done:!1,cb:l})},final(o){let a=r;r=null,a({done:!0,cb:o})},destroy(o,a){n.abort(),a(o)}}}function Ht(t){let e=t.readable&&typeof t.readable.read!="function"?eu.wrap(t.readable):t.readable,r=t.writable,n=!!T_(e),i=!!v_(r),s,o,a,l,u;function f(c){let d=l;l=null,d?d(c):c&&u.destroy(c)}return u=new Ve({readableObjectMode:!!(e!=null&&e.readableObjectMode),writableObjectMode:!!(r!=null&&r.writableObjectMode),readable:n,writable:i}),i&&(Ql(r,c=>{i=!1,c&&Qt(e,c),f(c)}),u._write=function(c,d,h){r.write(c,d)?h():s=h},u._final=function(c){r.end(),o=c},r.on("drain",function(){if(s){let c=s;s=null,c()}}),r.on("finish",function(){if(o){let c=o;o=null,c()}})),n&&(Ql(e,c=>{n=!1,c&&Qt(e,c),f(c)}),e.on("readable",function(){if(a){let c=a;a=null,c()}}),e.on("end",function(){u.push(null)}),u._read=function(){for(;;){let c=e.read();if(c===null){a=u._read;return}if(!u.push(c))return}}),u._destroy=function(c,d){!c&&l!==null&&(c=new Xl),a=null,s=null,o=null,l===null?d(c):(l=d,Qt(r,c),Qt(e,c))},u}});var Se=A((rm,su)=>{"use strict";var{ObjectDefineProperties:C_,ObjectGetOwnPropertyDescriptor:Le,ObjectKeys:D_,ObjectSetPrototypeOf:nu}=P();su.exports=ae;var Xi=mr(),ne=wn();nu(ae.prototype,Xi.prototype);nu(ae,Xi);{let t=D_(ne.prototype);for(let e=0;e<t.length;e++){let r=t[e];ae.prototype[r]||(ae.prototype[r]=ne.prototype[r])}}function ae(t){if(!(this instanceof ae))return new ae(t);Xi.call(this,t),ne.call(this,t),t?(this.allowHalfOpen=t.allowHalfOpen!==!1,t.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),t.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}C_(ae.prototype,{writable:{__proto__:null,...Le(ne.prototype,"writable")},writableHighWaterMark:{__proto__:null,...Le(ne.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...Le(ne.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...Le(ne.prototype,"writableBuffer")},writableLength:{__proto__:null,...Le(ne.prototype,"writableLength")},writableFinished:{__proto__:null,...Le(ne.prototype,"writableFinished")},writableCorked:{__proto__:null,...Le(ne.prototype,"writableCorked")},writableEnded:{__proto__:null,...Le(ne.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...Le(ne.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(t){this._readableState&&this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}});var Yi;function iu(){return Yi===void 0&&(Yi={}),Yi}ae.fromWeb=function(t,e){return iu().newStreamDuplexFromReadableWritablePair(t,e)};ae.toWeb=function(t){return iu().newReadableWritablePairFromDuplex(t)};var Zi;ae.from=function(t){return Zi||(Zi=ru()),Zi(t,"body")}});var rs=A((nm,au)=>{"use strict";var{ObjectSetPrototypeOf:ou,Symbol:M_}=P();au.exports=Oe;var{ERR_METHOD_NOT_IMPLEMENTED:U_}=W().codes,ts=Se(),{getHighWaterMark:$_}=yr();ou(Oe.prototype,ts.prototype);ou(Oe,ts);var Er=M_("kCallback");function Oe(t){if(!(this instanceof Oe))return new Oe(t);let e=t?$_(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),ts.call(this,t),this._readableState.sync=!1,this[Er]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",q_)}function es(t){typeof this._flush=="function"&&!this.destroyed?this._flush((e,r)=>{if(e){t?t(e):this.destroy(e);return}r!=null&&this.push(r),this.push(null),t&&t()}):(this.push(null),t&&t())}function q_(){this._final!==es&&es.call(this)}Oe.prototype._final=es;Oe.prototype._transform=function(t,e,r){throw new U_("_transform()")};Oe.prototype._write=function(t,e,r){let n=this._readableState,i=this._writableState,s=n.length;this._transform(t,e,(o,a)=>{if(o){r(o);return}a!=null&&this.push(a),i.ended||s===n.length||n.length<n.highWaterMark?r():this[Er]=r})};Oe.prototype._read=function(){if(this[Er]){let t=this[Er];this[Er]=null,t()}}});var is=A((im,uu)=>{"use strict";var{ObjectSetPrototypeOf:lu}=P();uu.exports=Kt;var ns=rs();lu(Kt.prototype,ns.prototype);lu(Kt,ns);function Kt(t){if(!(this instanceof Kt))return new Kt(t);ns.call(this,t)}Kt.prototype._transform=function(t,e,r){r(null,t)}});var Rn=A((sm,pu)=>{var Rr=He(),{ArrayIsArray:W_,Promise:G_,SymbolAsyncIterator:z_,SymbolDispose:H_}=P(),En=Pe(),{once:Q_}=Q(),K_=dt(),fu=Se(),{aggregateTwoErrors:V_,codes:{ERR_INVALID_ARG_TYPE:hs,ERR_INVALID_RETURN_VALUE:ss,ERR_MISSING_ARGS:J_,ERR_STREAM_DESTROYED:Y_,ERR_STREAM_PREMATURE_CLOSE:Z_},AbortError:X_}=W(),{validateFunction:ey,validateAbortSignal:ty}=Dt(),{isIterable:yt,isReadable:os,isReadableNodeStream:Sn,isNodeStream:cu,isTransformStream:Vt,isWebStream:ry,isReadableStream:as,isReadableFinished:ny}=me(),iy=globalThis.AbortController||Bt().AbortController,ls,us,fs;function du(t,e,r){let n=!1;t.on("close",()=>{n=!0});let i=En(t,{readable:e,writable:r},s=>{n=!s});return{destroy:s=>{n||(n=!0,K_.destroyer(t,s||new Y_("pipe")))},cleanup:i}}function sy(t){return ey(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function cs(t){if(yt(t))return t;if(Sn(t))return oy(t);throw new hs("val",["Readable","Iterable","AsyncIterable"],t)}async function*oy(t){us||(us=mr()),yield*us.prototype[z_].call(t)}async function xn(t,e,r,{end:n}){let i,s=null,o=u=>{if(u&&(i=u),s){let f=s;s=null,f()}},a=()=>new G_((u,f)=>{i?f(i):s=()=>{i?f(i):u()}});e.on("drain",o);let l=En(e,{readable:!1},o);try{e.writableNeedDrain&&await a();for await(let u of t)e.write(u)||await a();n&&(e.end(),await a()),r()}catch(u){r(i!==u?V_(i,u):u)}finally{l(),e.off("drain",o)}}async function ds(t,e,r,{end:n}){Vt(e)&&(e=e.writable);let i=e.getWriter();try{for await(let s of t)await i.ready,i.write(s).catch(()=>{});await i.ready,n&&await i.close(),r()}catch(s){try{await i.abort(s),r(s)}catch(o){r(o)}}}function ay(...t){return hu(t,Q_(sy(t)))}function hu(t,e,r){if(t.length===1&&W_(t[0])&&(t=t[0]),t.length<2)throw new J_("streams");let n=new iy,i=n.signal,s=r?.signal,o=[];ty(s,"options.signal");function a(){y(new X_)}fs=fs||Q().addAbortListener;let l;s&&(l=fs(s,a));let u,f,c=[],d=0;function h(S){y(S,--d===0)}function y(S,m){var I;if(S&&(!u||u.code==="ERR_STREAM_PREMATURE_CLOSE")&&(u=S),!(!u&&!m)){for(;c.length;)c.shift()(u);(I=l)===null||I===void 0||I[H_](),n.abort(),m&&(u||o.forEach(Ae=>Ae()),Rr.nextTick(e,u,f))}}let _;for(let S=0;S<t.length;S++){let m=t[S],I=S<t.length-1,Ae=S>0,C=I||r?.end!==!1,wt=S===t.length-1;if(cu(m)){let K=function(Te){Te&&Te.name!=="AbortError"&&Te.code!=="ERR_STREAM_PREMATURE_CLOSE"&&h(Te)};var g=K;if(C){let{destroy:Te,cleanup:On}=du(m,I,Ae);c.push(Te),os(m)&&wt&&o.push(On)}m.on("error",K),os(m)&&wt&&o.push(()=>{m.removeListener("error",K)})}if(S===0)if(typeof m=="function"){if(_=m({signal:i}),!yt(_))throw new ss("Iterable, AsyncIterable or Stream","source",_)}else yt(m)||Sn(m)||Vt(m)?_=m:_=fu.from(m);else if(typeof m=="function"){if(Vt(_)){var x;_=cs((x=_)===null||x===void 0?void 0:x.readable)}else _=cs(_);if(_=m(_,{signal:i}),I){if(!yt(_,!0))throw new ss("AsyncIterable",`transform[${S-1}]`,_)}else{var b;ls||(ls=is());let K=new ls({objectMode:!0}),Te=(b=_)===null||b===void 0?void 0:b.then;if(typeof Te=="function")d++,Te.call(_,Ce=>{f=Ce,Ce!=null&&K.write(Ce),C&&K.end(),Rr.nextTick(h)},Ce=>{K.destroy(Ce),Rr.nextTick(h,Ce)});else if(yt(_,!0))d++,xn(_,K,h,{end:C});else if(as(_)||Vt(_)){let Ce=_.readable||_;d++,xn(Ce,K,h,{end:C})}else throw new ss("AsyncIterable or Promise","destination",_);_=K;let{destroy:On,cleanup:Xu}=du(_,!1,!0);c.push(On),wt&&o.push(Xu)}}else if(cu(m)){if(Sn(_)){d+=2;let K=ly(_,m,h,{end:C});os(m)&&wt&&o.push(K)}else if(Vt(_)||as(_)){let K=_.readable||_;d++,xn(K,m,h,{end:C})}else if(yt(_))d++,xn(_,m,h,{end:C});else throw new hs("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],_);_=m}else if(ry(m)){if(Sn(_))d++,ds(cs(_),m,h,{end:C});else if(as(_)||yt(_))d++,ds(_,m,h,{end:C});else if(Vt(_))d++,ds(_.readable,m,h,{end:C});else throw new hs("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],_);_=m}else _=fu.from(m)}return(i!=null&&i.aborted||s!=null&&s.aborted)&&Rr.nextTick(a),_}function ly(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new Z_)}),t.pipe(e,{end:!1}),n){let o=function(){i=!0,e.end()};var s=o;ny(t)?Rr.nextTick(o):t.once("end",o)}else r();return En(t,{readable:!0,writable:!1},o=>{let a=t._readableState;o&&o.code==="ERR_STREAM_PREMATURE_CLOSE"&&a&&a.ended&&!a.errored&&!a.errorEmitted?t.once("end",r).once("error",r):r(o)}),En(e,{readable:!1,writable:!0},r)}pu.exports={pipelineImpl:hu,pipeline:ay}});var _s=A((om,wu)=>{"use strict";var{pipeline:uy}=Rn(),In=Se(),{destroyer:fy}=dt(),{isNodeStream:An,isReadable:_u,isWritable:yu,isWebStream:ps,isTransformStream:bt,isWritableStream:bu,isReadableStream:gu}=me(),{AbortError:cy,codes:{ERR_INVALID_ARG_VALUE:mu,ERR_MISSING_ARGS:dy}}=W(),hy=Pe();wu.exports=function(...e){if(e.length===0)throw new dy("streams");if(e.length===1)return In.from(e[0]);let r=[...e];if(typeof e[0]=="function"&&(e[0]=In.from(e[0])),typeof e[e.length-1]=="function"){let h=e.length-1;e[h]=In.from(e[h])}for(let h=0;h<e.length;++h)if(!(!An(e[h])&&!ps(e[h]))){if(h<e.length-1&&!(_u(e[h])||gu(e[h])||bt(e[h])))throw new mu(`streams[${h}]`,r[h],"must be readable");if(h>0&&!(yu(e[h])||bu(e[h])||bt(e[h])))throw new mu(`streams[${h}]`,r[h],"must be writable")}let n,i,s,o,a;function l(h){let y=o;o=null,y?y(h):h?a.destroy(h):!d&&!c&&a.destroy()}let u=e[0],f=uy(e,l),c=!!(yu(u)||bu(u)||bt(u)),d=!!(_u(f)||gu(f)||bt(f));if(a=new In({writableObjectMode:!!(u!=null&&u.writableObjectMode),readableObjectMode:!!(f!=null&&f.readableObjectMode),writable:c,readable:d}),c){if(An(u))a._write=function(y,_,x){u.write(y,_)?x():n=x},a._final=function(y){u.end(),i=y},u.on("drain",function(){if(n){let y=n;n=null,y()}});else if(ps(u)){let _=(bt(u)?u.writable:u).getWriter();a._write=async function(x,b,g){try{await _.ready,_.write(x).catch(()=>{}),g()}catch(S){g(S)}},a._final=async function(x){try{await _.ready,_.close().catch(()=>{}),i=x}catch(b){x(b)}}}let h=bt(f)?f.readable:f;hy(h,()=>{if(i){let y=i;i=null,y()}})}if(d){if(An(f))f.on("readable",function(){if(s){let h=s;s=null,h()}}),f.on("end",function(){a.push(null)}),a._read=function(){for(;;){let h=f.read();if(h===null){s=a._read;return}if(!a.push(h))return}};else if(ps(f)){let y=(bt(f)?f.readable:f).getReader();a._read=async function(){for(;;)try{let{value:_,done:x}=await y.read();if(!a.push(_))return;if(x){a.push(null);return}}catch{return}}}}return a._destroy=function(h,y){!h&&o!==null&&(h=new cy),s=null,n=null,i=null,o===null?y(h):(o=y,An(f)&&fy(f,h))},a}});var ju=A((am,gs)=>{"use strict";var py=globalThis.AbortController||Bt().AbortController,{codes:{ERR_INVALID_ARG_VALUE:_y,ERR_INVALID_ARG_TYPE:Ir,ERR_MISSING_ARGS:yy,ERR_OUT_OF_RANGE:by},AbortError:Ee}=W(),{validateAbortSignal:gt,validateInteger:xu,validateObject:mt}=Dt(),gy=P().Symbol("kWeak"),my=P().Symbol("kResistStopPropagation"),{finished:wy}=Pe(),xy=_s(),{addAbortSignalNoValidate:Sy}=_r(),{isWritable:Ey,isNodeStream:Ry}=me(),{deprecate:Iy}=Q(),{ArrayPrototypePush:Ay,Boolean:Ty,MathFloor:Su,Number:vy,NumberIsNaN:Ny,Promise:Eu,PromiseReject:Ru,PromiseResolve:jy,PromisePrototypeThen:Iu,Symbol:Tu}=P(),Tn=Tu("kEmpty"),Au=Tu("kEof");function ky(t,e){if(e!=null&&mt(e,"options"),e?.signal!=null&&gt(e.signal,"options.signal"),Ry(t)&&!Ey(t))throw new _y("stream",t,"must be writable");let r=xy(this,t);return e!=null&&e.signal&&Sy(e.signal,r),r}function vn(t,e){if(typeof t!="function")throw new Ir("fn",["Function","AsyncFunction"],t);e!=null&&mt(e,"options"),e?.signal!=null&&gt(e.signal,"options.signal");let r=1;e?.concurrency!=null&&(r=Su(e.concurrency));let n=r-1;return e?.highWaterMark!=null&&(n=Su(e.highWaterMark)),xu(r,"options.concurrency",1),xu(n,"options.highWaterMark",0),n+=r,async function*(){let s=Q().AbortSignalAny([e?.signal].filter(Ty)),o=this,a=[],l={signal:s},u,f,c=!1,d=0;function h(){c=!0,y()}function y(){d-=1,_()}function _(){f&&!c&&d<r&&a.length<n&&(f(),f=null)}async function x(){try{for await(let b of o){if(c)return;if(s.aborted)throw new Ee;try{if(b=t(b,l),b===Tn)continue;b=jy(b)}catch(g){b=Ru(g)}d+=1,Iu(b,y,h),a.push(b),u&&(u(),u=null),!c&&(a.length>=n||d>=r)&&await new Eu(g=>{f=g})}a.push(Au)}catch(b){let g=Ru(b);Iu(g,y,h),a.push(g)}finally{c=!0,u&&(u(),u=null)}}x();try{for(;;){for(;a.length>0;){let b=await a[0];if(b===Au)return;if(s.aborted)throw new Ee;b!==Tn&&(yield b),a.shift(),_()}await new Eu(b=>{u=b})}}finally{c=!0,f&&(f(),f=null)}}.call(this)}function Py(t=void 0){return t!=null&&mt(t,"options"),t?.signal!=null&&gt(t.signal,"options.signal"),async function*(){let r=0;for await(let i of this){var n;if(t!=null&&(n=t.signal)!==null&&n!==void 0&&n.aborted)throw new Ee({cause:t.signal.reason});yield[r++,i]}}.call(this)}async function vu(t,e=void 0){for await(let r of bs.call(this,t,e))return!0;return!1}async function Ly(t,e=void 0){if(typeof t!="function")throw new Ir("fn",["Function","AsyncFunction"],t);return!await vu.call(this,async(...r)=>!await t(...r),e)}async function Oy(t,e){for await(let r of bs.call(this,t,e))return r}async function By(t,e){if(typeof t!="function")throw new Ir("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),Tn}for await(let n of vn.call(this,r,e));}function bs(t,e){if(typeof t!="function")throw new Ir("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:Tn}return vn.call(this,r,e)}var ys=class extends yy{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function Fy(t,e,r){var n;if(typeof t!="function")throw new Ir("reducer",["Function","AsyncFunction"],t);r!=null&&mt(r,"options"),r?.signal!=null&&gt(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){let u=new Ee(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await wy(this.destroy(u)),u}let s=new py,o=s.signal;if(r!=null&&r.signal){let u={once:!0,[gy]:this,[my]:!0};r.signal.addEventListener("abort",()=>s.abort(),u)}let a=!1;try{for await(let u of this){var l;if(a=!0,r!=null&&(l=r.signal)!==null&&l!==void 0&&l.aborted)throw new Ee;i?e=await t(e,u,{signal:o}):(e=u,i=!0)}if(!a&&!i)throw new ys}finally{s.abort()}return e}async function Cy(t){t!=null&&mt(t,"options"),t?.signal!=null&&gt(t.signal,"options.signal");let e=[];for await(let n of this){var r;if(t!=null&&(r=t.signal)!==null&&r!==void 0&&r.aborted)throw new Ee(void 0,{cause:t.signal.reason});Ay(e,n)}return e}function Dy(t,e){let r=vn.call(this,t,e);return async function*(){for await(let i of r)yield*i}.call(this)}function Nu(t){if(t=vy(t),Ny(t))return 0;if(t<0)throw new by("number",">= 0",t);return t}function My(t,e=void 0){return e!=null&&mt(e,"options"),e?.signal!=null&&gt(e.signal,"options.signal"),t=Nu(t),async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new Ee;for await(let s of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new Ee;t--<=0&&(yield s)}}.call(this)}function Uy(t,e=void 0){return e!=null&&mt(e,"options"),e?.signal!=null&&gt(e.signal,"options.signal"),t=Nu(t),async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new Ee;for await(let s of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new Ee;if(t-- >0&&(yield s),t<=0)return}}.call(this)}gs.exports.streamReturningOperators={asIndexedPairs:Iy(Py,"readable.asIndexedPairs will be removed in a future version."),drop:My,filter:bs,flatMap:Dy,map:vn,take:Uy,compose:ky};gs.exports.promiseReturningOperators={every:Ly,forEach:By,reduce:Fy,toArray:Cy,some:vu,find:Oy}});var ms=A((lm,ku)=>{"use strict";var{ArrayPrototypePop:$y,Promise:qy}=P(),{isIterable:Wy,isNodeStream:Gy,isWebStream:zy}=me(),{pipelineImpl:Hy}=Rn(),{finished:Qy}=Pe();ws();function Ky(...t){return new qy((e,r)=>{let n,i,s=t[t.length-1];if(s&&typeof s=="object"&&!Gy(s)&&!Wy(s)&&!zy(s)){let o=$y(t);n=o.signal,i=o.end}Hy(t,(o,a)=>{o?r(o):e(a)},{signal:n,end:i})})}ku.exports={finished:Qy,pipeline:Ky}});var ws=A((um,Uu)=>{"use strict";var{Buffer:Vy}=pe(),{ObjectDefineProperty:Be,ObjectKeys:Ou,ReflectApply:Bu}=P(),{promisify:{custom:Fu}}=Q(),{streamReturningOperators:Pu,promiseReturningOperators:Lu}=ju(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:Cu}}=W(),Jy=_s(),{setDefaultHighWaterMark:Yy,getDefaultHighWaterMark:Zy}=yr(),{pipeline:Du}=Rn(),{destroyer:Xy}=dt(),Mu=Pe(),xs=ms(),Ar=me(),j=Uu.exports=an().Stream;j.isDestroyed=Ar.isDestroyed;j.isDisturbed=Ar.isDisturbed;j.isErrored=Ar.isErrored;j.isReadable=Ar.isReadable;j.isWritable=Ar.isWritable;j.Readable=mr();for(let t of Ou(Pu)){let r=function(...n){if(new.target)throw Cu();return j.Readable.from(Bu(e,this,n))},e=Pu[t];Be(r,"name",{__proto__:null,value:e.name}),Be(r,"length",{__proto__:null,value:e.length}),Be(j.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}for(let t of Ou(Lu)){let r=function(...n){if(new.target)throw Cu();return Bu(e,this,n)},e=Lu[t];Be(r,"name",{__proto__:null,value:e.name}),Be(r,"length",{__proto__:null,value:e.length}),Be(j.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}j.Writable=wn();j.Duplex=Se();j.Transform=rs();j.PassThrough=is();j.pipeline=Du;var{addAbortSignal:eb}=_r();j.addAbortSignal=eb;j.finished=Mu;j.destroy=Xy;j.compose=Jy;j.setDefaultHighWaterMark=Yy;j.getDefaultHighWaterMark=Zy;Be(j,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return xs}});Be(Du,Fu,{__proto__:null,enumerable:!0,get(){return xs.pipeline}});Be(Mu,Fu,{__proto__:null,enumerable:!0,get(){return xs.finished}});j.Stream=j;j._isUint8Array=function(e){return e instanceof Uint8Array};j._uint8ArrayToBuffer=function(e){return Vy.from(e.buffer,e.byteOffset,e.byteLength)}});var Nn=A((fm,F)=>{"use strict";var M=ws(),tb=ms(),rb=M.Readable.destroy;F.exports=M.Readable;F.exports._uint8ArrayToBuffer=M._uint8ArrayToBuffer;F.exports._isUint8Array=M._isUint8Array;F.exports.isDisturbed=M.isDisturbed;F.exports.isErrored=M.isErrored;F.exports.isReadable=M.isReadable;F.exports.Readable=M.Readable;F.exports.Writable=M.Writable;F.exports.Duplex=M.Duplex;F.exports.Transform=M.Transform;F.exports.PassThrough=M.PassThrough;F.exports.addAbortSignal=M.addAbortSignal;F.exports.finished=M.finished;F.exports.destroy=M.destroy;F.exports.destroy=rb;F.exports.pipeline=M.pipeline;F.exports.compose=M.compose;Object.defineProperty(M,"promises",{configurable:!0,enumerable:!0,get(){return tb}});F.exports.Stream=M.Stream;F.exports.default=F.exports});var V=class t{#e;constructor(e){this.#e=t.collapse(e)}get value(){return this.#e}toString(){return this.#e}get length(){return this.#e.length}static collapse(e,r=""){if(e instanceof t)return e.value;if(typeof e!="string")throw new TypeError("path argument must be a string or an instance of Path");if(r&&!(r instanceof t)&&(r=new t(r)),e=e.trim(),e.length===0)return r.value;t.isRelative(e)&&(e=r+e);let n=t.reduce(e,(s,o)=>(o==".."?s.pop():o!=="."&&s.push(o),s),[]),i="/";return n.length&&(i+=n.join("/"),t.isFolder(e)&&(i+="/")),i}static isAbsolute(e){return e instanceof t?!0:e.length&&e[0]==="/"}static isRelative(e){return!t.isAbsolute(e)}static isFolder(e){return e instanceof t&&(e=e.value),e.length&&e[e.length-1]=="/"}static isPath(e){return e instanceof t?!0:typeof e!="string"?!1:(e=e.trim(),new URL(e,document.location).pathname==e)}static reduce(e,r,n){return e instanceof t&&(e=e.value),e.split("/").filter(Boolean).reduce(r,n)}static map(e,r){return e instanceof t&&(e=e.value),e.split("/").filter(Boolean).map(r)}static parent(e){e instanceof t&&(e=e.value),e=e.split("/").filter(Boolean),e.pop();let r="/";return e.length&&(r+=e.join("/")+"/"),r}static filename(e){return e instanceof t&&(e=e.value),e.split("/").filter(Boolean).pop()}static head(e){return e instanceof t&&(e=e.value),e.split("/").filter(Boolean).shift()}static tail(e){e instanceof t&&(e=e.value),e=e.split("/").filter(Boolean),e.shift();let r="/";return e.length&&(r+=e.join("/")+"/"),r}};var Zt=class t{#e;#r;#i;#t;constructor(e,r="/",n=null,i={}){this.#e=new URL(e,window.location.href),this.#r=new V(r),this.#i=n,this.#t=i}get name(){return"HttpAdapter"}get path(){return this.#r}supportsWrite(){return!0}supportsStreamingWrite(){return af}supportsStreamingRead(){return!0}cd(e){if(!V.isPath(e))throw new TypeError(e+" is not a valid path");return new t(this.#e.href,e)}async write(e,r,n=null){let i=Object.assign({},this.#t,{method:"PUT",body:r});return this.#n(e,i)}writeStream(e,r,n=null){throw new Error("Not yet implemented")}async read(e){let r=Object.assign({},this.#t,{method:"GET"}),n=await this.#n(e,r),i={type:this.#o(n),name:V.filename(e),http:{headers:n.headers,status:n.status,url:n.url}};return i.type.match(/text\/.*/)?i.contents=await n.text():i.type.match(/application\/json.*/)?i.contents=await n.json():i.contents=await n.blob(),i}readStream(e,r){throw new Error("Not yet implemented")}async exists(e){let r=Object.assign({},this.#t,{method:"HEAD"});return this.#n(e,r)}async delete(e){let r=Object.assign({},this.#t,{method:"DELETE"});return this.#n(e,r)}async list(e){let r=["text/html","text/xhtml","text/xhtml+xml","text/xml"],n=await this.read(e);if(r.includes(n.type.split(";")[0]))var i=n.contents;else{let u=this.#s(e);throw new TypeError("URL "+u+" is not of a supported content type",{cause:n})}let s=V.collapse(this.#e.pathname),o=this.#s(e),a=document.createElement("template");a.innerHTML=i;let l=a.content.querySelectorAll("a[href]");return Array.from(l).map(u=>{let f=new URL(u.getAttribute("href"),o.href);return u.href=f.href,{filename:V.filename(u.pathname),path:u.pathname,name:u.innerText,href:u.href}}).filter(u=>{let f=new URL(u.href);return f.pathname=V.parent(f.pathname),f.href===o.href}).map(u=>({filename:u.filename,path:u.path.substring(s.length-1),name:u.name}))}#s(e){return e=V.collapse(this.#e.pathname+V.collapse(e)),new URL(e,this.#e)}async#n(e,r){return fetch(this.#s(e),r).catch(n=>{if(!this.#i||!this.#i(url,r,n))throw n})}#o(e){return e.headers.has("Content-Type")?e.headers.get("Content-Type"):null}},af=(async()=>new Request("",{body:new ReadableStream,method:"POST",duplex:"half"}).headers.has("Content-Type")?!1:fetch("data:a/a;charset=utf-8,",{method:"POST",body:new ReadableStream,duplex:"half"}).then(()=>!0,()=>!1))();var St={};Fn(St,{Client:()=>ie,client:()=>le,deepClone:()=>De,formdata:()=>ks,metroError:()=>$,request:()=>Xe,response:()=>xt,trace:()=>uf,url:()=>z});var Ze="https://metro.muze.nl/details/";Symbol.metroProxy||(Symbol.metroProxy=Symbol("isProxy"));Symbol.metroSource||(Symbol.metroSource=Symbol("source"));var ie=class t{clientOptions={url:z(typeof window<"u"?window.location:"https://localhost"),verbs:["get","post","put","delete","patch","head","options","query"]};static tracers={};constructor(...e){for(let r of e)if(typeof r=="string"||r instanceof String)this.clientOptions.url=z(this.clientOptions.url.href,r);else if(r instanceof Function)this.#e([r]);else if(r&&typeof r=="object")for(let n in r)n=="middlewares"?this.#e(r[n]):n=="url"?this.clientOptions.url=z(this.clientOptions.url.href,r[n]):typeof r[n]=="function"?this.clientOptions[n]=r[n](this.clientOptions[n],this.clientOptions):this.clientOptions[n]=r[n];for(let r of this.clientOptions.verbs)this[r]=async function(...n){return this.fetch(Xe(this.clientOptions,...n,{method:r.toUpperCase()}))}}#e(e){typeof e=="function"&&(e=[e]);let r=e.findIndex(n=>typeof n!="function");if(r>=0)throw $("metro.client: middlewares must be a function or an array of functions "+Ze+"client/invalid-middlewares/",e[r]);Array.isArray(this.clientOptions.middlewares)||(this.clientOptions.middlewares=[]),this.clientOptions.middlewares=this.clientOptions.middlewares.concat(e)}fetch(e,r){if(e=Xe(e,r),!e.url)throw $("metro.client."+e.method.toLowerCase()+": Missing url parameter "+Ze+"client/fetch-missing-url/",e);if(r||(r={}),typeof r!="object"||r instanceof String)throw $("metro.client.fetch: Invalid options parameter "+Ze+"client/fetch-invalid-options/",r);let i=[async function(a){a[Symbol.metroProxy]&&(a=a[Symbol.metroSource]);let l=await fetch(a);return xt(l)}].concat(this.clientOptions?.middlewares?.slice()||[]);r=Object.assign({},this.clientOptions,r);let s;for(let o of i)s=(function(a,l){return async function(u){let f,c=Object.values(t.tracers);for(let d of c)d.request&&d.request.call(d,u,l);f=await l(u,a);for(let d of c)d.response&&d.response.call(d,f,l);return f}})(s,o);return s(e)}with(...e){return new t(De(this.clientOptions),...e)}get location(){return this.clientOptions.url}};function le(...t){return new ie(...De(t))}function lf(t,e){let r=e||{};!r.url&&e.url&&(r.url=e.url);for(let n of["method","headers","body","mode","credentials","cache","redirect","referrer","referrerPolicy","integrity","keepalive","signal","priority","url"]){let i=t[n];if(!(typeof i>"u"||i==null))if(i?.[Symbol.metroProxy]&&(i=i[Symbol.metroSource]),typeof i=="function")r[n]=i(r[n],r);else if(n=="url")r.url=z(r.url,i);else if(n=="headers"){r.headers=new Headers(e.headers),i instanceof Headers||(i=new Headers(t.headers));for(let[s,o]of i.entries())r.headers.set(s,o)}else r[n]=i}return t instanceof Request&&t.data&&(r.body=t.data),r}function Xe(...t){let e={url:z(typeof window<"u"?window.location:"https://localhost/"),duplex:"half"};for(let i of t)typeof i=="string"||i instanceof URL||i instanceof URLSearchParams?e.url=z(e.url,i):i&&(i instanceof FormData||i instanceof ReadableStream||i instanceof Blob||i instanceof ArrayBuffer||i instanceof DataView)?e.body=i:i&&typeof i=="object"&&Object.assign(e,lf(i,e));let r=new Request(e.url,e),n=e.body;return n&&typeof n=="object"&&!(n instanceof String)&&!(n instanceof ReadableStream)&&!(n instanceof Blob)&&!(n instanceof ArrayBuffer)&&!(n instanceof DataView)&&!(n instanceof FormData)&&!(n instanceof URLSearchParams)&&(typeof globalThis.TypedArray>"u"||!(n instanceof globalThis.TypedArray))&&typeof n.toString=="function"&&(e.body=n.toString({headers:r.headers}),r=new Request(e.url,e)),Object.freeze(r),new Proxy(r,{get(i,s){let o;switch(s){case Symbol.metroSource:o=i;break;case Symbol.metroProxy:o=!0;break;case"with":o=function(...a){return n&&a.unshift({body:n}),Xe(i,...a)};break;case"data":o=n;break;default:i[s]instanceof Function?o=i[s].bind(i):o=i[s];break}return o}})}function Ns(t,e){let r=e||{};!r.url&&e.url&&(r.url=e.url);for(let n of["status","statusText","headers","body","url","type","redirected"]){let i=t[n];typeof i>"u"||i==null||(i?.[Symbol.metroProxy]&&(i=i[Symbol.metroSource]),typeof i=="function"?r[n]=i(r[n],r):n=="url"?r.url=new URL(i,r.url||"https://localhost/"):r[n]=i)}return t instanceof Response&&t.data&&(r.body=t.data),r}function xt(...t){let e={};for(let i of t)typeof i=="string"?e.body=i:i instanceof Response?Object.assign(e,Ns(i,e)):i&&typeof i=="object"&&(i instanceof FormData||i instanceof Blob||i instanceof ArrayBuffer||i instanceof DataView||i instanceof ReadableStream||i instanceof URLSearchParams||i instanceof String||typeof globalThis.TypedArray<"u"&&i instanceof globalThis.TypedArray?e.body=i:Object.assign(e,Ns(i,e)));let r;e.body&&(r=e.body),[101,204,205,304].includes(e.status)&&(e.body=null);let n=new Response(e.body,e);return Object.freeze(n),new Proxy(n,{get(i,s){let o;switch(s){case Symbol.metroProxy:o=!0;break;case Symbol.metroSource:o=i;break;case"with":o=function(...a){return xt(i,...a)};break;case"data":o=r;break;case"ok":o=i.status>=200&&i.status<400;break;default:typeof i[s]=="function"?o=i[s].bind(i):o=i[s];break}return o}})}function js(t,e){typeof e=="function"?e(t.searchParams,t):(e=new URLSearchParams(e),e.forEach((r,n)=>{t.searchParams.append(n,r)}))}function z(...t){let e=["hash","host","hostname","href","password","pathname","port","protocol","username","search","searchParams"],r=new URL("https://localhost/");for(let n of t)if(typeof n=="string"||n instanceof String)r=new URL(n,r);else if(n instanceof URL||typeof Location<"u"&&n instanceof Location)r=new URL(n);else if(n instanceof URLSearchParams)js(r,n);else if(n&&typeof n=="object")for(let i in n)switch(i){case"search":typeof n.search=="function"?n.search(r.search,r):r.search=new URLSearchParams(n.search);break;case"searchParams":js(r,n.searchParams);break;default:if(!e.includes(i))throw $("metro.url: unknown url parameter "+Ze+"url/unknown-param-name/",i);if(typeof n[i]=="function")n[i](r[i],r);else if(typeof n[i]=="string"||n[i]instanceof String||typeof n[i]=="number"||n[i]instanceof Number||typeof n[i]=="boolean"||n[i]instanceof Boolean)r[i]=""+n[i];else if(typeof n[i]=="object"&&n[i].toString)r[i]=n[i].toString();else throw $("metro.url: unsupported value for "+i+" "+Ze+"url/unsupported-param-value/",t[i]);break}else throw $("metro.url: unsupported option value "+Ze+"url/unsupported-option-value/",n);return Object.freeze(r),new Proxy(r,{get(n,i){let s;switch(i){case Symbol.metroProxy:s=!0;break;case Symbol.metroSource:s=n;break;case"with":s=function(...o){return z(n,...o)};break;case"filename":s=n.pathname.split("/").pop();break;case"folderpath":s=n.pathname.substring(0,n.pathname.lastIndexOf("\\")+1);break;case"authority":s=n.username??"",s+=n.password?":"+n.password:"",s+=s?"@":"",s+=n.hostname,s+=n.port?":"+n.port:"",s+="/",s=n.protocol+"//"+s;break;case"origin":s=n.protocol+"//"+n.hostname,s+=n.port?":"+n.port:"",s+="/";break;case"fragment":s=n.hash.substring(1);break;case"scheme":n.protocol?s=n.protocol.substring(0,n.protocol.length-1):s="";break;default:n[i]instanceof Function?s=n[i].bind(n):s=n[i];break}return s}})}function ks(...t){var e=new FormData;for(let r of t)if(r instanceof HTMLFormElement&&(r=new FormData(r)),r instanceof FormData)for(let n of r.entries())e.append(n[0],n[1]);else if(r&&typeof r=="object")for(let n of Object.entries(r))if(Array.isArray(n[1]))for(let i of n[1])e.append(n[0],i);else e.append(n[0],n[1]);else throw new $("metro.formdata: unknown option type "+Ze+"formdata/unknown-option-value/",r);return Object.freeze(e),new Proxy(e,{get(r,n){let i;switch(n){case Symbol.metroProxy:i=!0;break;case Symbol.metroSource:i=r;break;case"with":i=function(...s){return ks(r,...s)};break;default:r[n]instanceof Function?i=r[n].bind(r):i=r[n];break}return i}})}var Xt={error:(t,...e)=>{console.error("\u24C2\uFE0F ",t,...e)},info:(t,...e)=>{console.info("\u24C2\uFE0F ",t,...e)},group:t=>{console.group("\u24C2\uFE0F "+t)},groupEnd:t=>{console.groupEnd("\u24C2\uFE0F "+t)}};function $(t,...e){return Xt.error(t,...e),new Error(t,...e)}var uf={add(t,e){ie.tracers[t]=e},delete(t){delete ie.tracers[t]},clear(){ie.tracers={}},group(){let t=0;return{request:(e,r)=>{t++,Xt.group(t),Xt.info(e?.url,e,r)},response:(e,r)=>{Xt.info(e?.body?e.body[Symbol.metroSource]:null,e,r),Xt.groupEnd(t),t--}}}};function De(t){if(Array.isArray(t))return t.slice().map(De);if(t&&typeof t=="object")if(t.__proto__.constructor==Object||!t.__proto__){let e=Object.assign({},t);return Object.keys(e).forEach(r=>{e[r]=De(t[r])}),e}else return t;return t}function Fr(){return async function(e,r){let n=await r(e);return n.ok&&n.data?n.data:n}}function ue(t){return t=Object.assign({contentType:"application/json",reviver:null,replacer:null,space:""},t),async function(r,n){if(r.headers.get("Accept")||(r=r.with({headers:{Accept:t.accept??t.contentType}})),r.method!=="GET"&&r.method!=="HEAD"&&r.data&&typeof r.data=="object"&&!(r.data instanceof ReadableStream)){let s=r.headers.get("Content-Type");(!s||cf(s))&&(r=r.with({headers:{"Content-Type":t.contentType}})),Ps(r.headers.get("Content-Type"))&&(r=r.with({body:JSON.stringify(r.data,t.replacer,t.space)}))}let i=await n(r);if(Ps(i.headers.get("Content-Type"))){let o=await i.clone().text();try{let a=JSON.parse(o,t.reviver);return i.with({body:a})}catch{}}return i}}var ff=/^application\/([a-zA-Z0-9\-_]+\+)?json\b/;function Ps(t){return ff.exec(t)}function cf(t){return/^text\/plain\b/.exec(t)}function fe(t){return async function(r,n){let i=await n(r);if(!i.ok)if(t&&typeof t[i.status]=="function")i=t[i.status].apply(i,r);else throw new Error(i.status+": "+i.statusText,{cause:i});return i}}var Cr=class extends ie{constructor(e,r,n=null){e instanceof ie?super(e.clientOptions,fe(),Fr()):super(e,fe(),Fr()),n||(n=this);for(let i in r)typeof r[i]=="function"?this[i]=r[i].bind(n):r[i]&&typeof r[i]=="object"?this[i]=new this.constructor(e,r[i],n):this[i]=r[i]}},Cn=class extends Cr{constructor(e,r,n=null){e instanceof ie?super(e.with(ue()),r,n):super(le(e,ue()),r,n)}};function Ls(...t){return new Cr(...De(t))}function Os(...t){return new Cn(...De(t))}var Bs=Object.assign({},St,{mw:{json:ue,thrower:fe,gedata},api:Ls,jsonApi:Os});globalThis.metro||(globalThis.metro=Bs);var ce=Bs;globalThis.assertEnabled=!1;function H(t,e){if(globalThis.assertEnabled){let r=ee(t,e);if(r)throw console.error("\u{1F170}\uFE0F Assertions failed because of:",r,"in this source:",t),new Error("Assertions failed",{cause:{problems:r,source:t}})}}function w(t){return function(r,n,i){if(typeof r<"u"&&r!=null&&typeof t<"u")return ee(r,t,n,i)}}function N(t){return function(r,n,i){return r==null||typeof r>"u"?k("data is required",r,t||"any value",i):typeof t<"u"?ee(r,t,n,i):!1}}function er(t){return function(r,n,i){return r==null||typeof r>"u"?(df("data does not contain recommended value",r,t,i),!1):ee(r,t,n,i)}}function J(...t){return function(r,n,i){for(let s of t)if(!ee(r,s,n,i))return!1;return k("data does not match oneOf patterns",r,t,i)}}function Et(...t){return function(r,n,i){if(!Array.isArray(r))return k("data is not an array",r,"anyOf",i);for(let s of r)if(J(...t)(s))return k("data does not match anyOf patterns",s,t,i);return!1}}function Fs(...t){return function(r,n,i){let s=[];for(let o of t)s=s.concat(ee(r,o,n,i));if(s=s.filter(Boolean),s.length)return k("data does not match all given patterns",r,t,i,s)}}function T(t,e,r){try{t instanceof URL&&(t=t.href);let n=new URL(t);if(n.href!=t&&!(n.href+"/"==t||n.href==t+"/"))return k("data is not a valid url",t,"validURL",r)}catch{return k("data is not a valid url",t,"validURL",r)}}function Cs(t,e,r){if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t))return k("data is not a valid email",t,"validEmail",r)}function Rt(t){return function(r,n,i){if(!(r instanceof t))return k("data is not an instanceof pattern",r,t,i)}}function tr(t){return function(r,n,i){if(!ee(r,t,n,i))return k("data matches pattern, when required not to",r,t,i)}}function ee(t,e,r,n=""){r||(r=t);let i=[];if(e===Boolean)typeof t!="boolean"&&!(t instanceof Boolean)&&i.push(k("data is not a boolean",t,e,n));else if(e===Number)typeof t!="number"&&!(t instanceof Number)&&i.push(k("data is not a number",t,e,n));else if(e===String)typeof t!="string"&&!(t instanceof String)&&i.push(k("data is not a string",t,e,n)),t==""&&i.push(k("data is an empty string, which is not allowed",t,e,n));else if(e instanceof RegExp)if(Array.isArray(t)){let s=t.findIndex((o,a)=>ee(o,e,r,n+"["+a+"]"));s>-1&&i.push(k("data["+s+"] does not match pattern",t[s],e,n+"["+s+"]"))}else typeof t>"u"?i.push(k("data is undefined, should match pattern",t,e,n)):e.test(t)||i.push(k("data does not match pattern",t,e,n));else if(e instanceof Function){let s=e(t,r,n);s&&(Array.isArray(s)?i=i.concat(s):i.push(s))}else if(Array.isArray(e)){Array.isArray(t)||i.push(k("data is not an array",t,[],n));for(let s of e)for(let o of t.keys()){let a=ee(t[o],s,r,n+"["+o+"]");Array.isArray(a)?i=i.concat(a):a&&i.push(a)}}else if(e&&typeof e=="object")if(Array.isArray(t)){let s=t.findIndex((o,a)=>ee(o,e,r,n+"["+a+"]"));s>-1&&i.push(k("data["+s+"] does not match pattern",t[s],e,n+"["+s+"]"))}else if(!t||typeof t!="object")i.push(k("data is not an object, pattern is",t,e,n));else if(t instanceof URLSearchParams&&(t=Object.fromEntries(t)),e instanceof Function){let s=ee(t,e,r,n);s&&(i=i.concat(s))}else for(let[s,o]of Object.entries(e)){let a=ee(t[s],o,r,n+"."+s);a&&(i=i.concat(a))}else e!=t&&i.push(k("data and pattern are not equal",t,e,n));return i.length?i:!1}function k(t,e,r,n,i){let s={path:n,message:t,found:e,expected:r};return i&&(s.problems=i),s}function df(t,e,r,n){console.warn("\u{1F170}\uFE0F Assert: "+n,t,r,e)}function Ds(t){let e,r;if(typeof localStorage<"u")e={get:()=>localStorage.getItem("metro/state:"+t),set:n=>localStorage.setItem("metro/state:"+t,n),has:()=>localStorage.getItem("metro/state:"+t)!==null,delete:()=>localStorage.remoteItem("metro/state:"+t)},r={get:n=>JSON.parse(localStorage.getItem(t+":"+n)),set:(n,i)=>localStorage.setItem(t+":"+n,JSON.stringify(i)),has:n=>localStorage.getItem(t+":"+n)!==null,delete:n=>localStorage.removeItem(t+":"+n)};else{let n=new Map;e={get:()=>n.get("metro/state:"+t),set:i=>n.set("metro/state:"+t,i),has:()=>n.has("metro/state:"+t),delete:()=>n.delete("metro/state:"+t)},r=new Map}return{state:e,tokens:r}}function Dn(t){let e={client:le(),force_authorization:!1,site:"default",oauth2_configuration:{authorization_endpoint:"/authorize",token_endpoint:"/token",redirect_uri:globalThis.document?.location.href,grant_type:"authorization_code",code_verifier:pf(64)},authorize_callback:async f=>(window.location.href!=f.href&&window.location.replace(f.href),!1)};H(t,{});let r=Object.assign({},e.oauth2_configuration,t?.oauth2_configuration);t=Object.assign({},e,t),t.oauth2_configuration=r;let n=Ds(t.site);t.tokens||(t.tokens=n.tokens),t.state||(t.state=n.state),H(t,{oauth2_configuration:{client_id:N(/.+/),grant_type:"authorization_code",authorization_endpoint:N(T),token_endpoint:N(T),redirect_uri:N(T)}});for(let f in r)switch(f){case"access_token":case"authorization_code":case"refresh_token":t.tokens.set(f,r[f]);break}return async function(f,c){if(t.force_authorization)return i(f,c);let d;try{if(d=await c(f),d.ok)return d}catch(h){switch(d?.status){case 400:case 401:return i(f,c)}throw h}if(!d.ok)switch(d.status){case 400:case 401:return i(f,c)}return d};async function i(f,c){s();let d=t.tokens.get("access_token"),h=t.tokens.get("refresh_token"),y=hf(d);if(!d||y&&!h){try{if(!await o())return xt("false")}catch(_){throw _}return i(f,c)}else if(y&&h){try{if(!await a())return xt("false")}catch(_){throw _}return i(f,c)}else return f=Xe(f,{headers:{Authorization:d.type+" "+d.value}}),c(f)}function s(){if(typeof window<"u"&&window?.location){let f=z(window.location),c,d,h;if(f.searchParams.has("code"))h=f.searchParams,f=f.with({search:""}),history.pushState({},"",f.href);else if(f.hash){let y=f.hash.substr(1);h=new URLSearchParams("?"+y),f=f.with({hash:""}),history.pushState({},"",f.href)}if(h){c=h.get("code"),d=h.get("state");let y=t.state.get("metro/state");if(!d||d!==y)return;c&&t.tokens.set("authorization_code",c)}}}async function o(){if(r.grant_type==="authorization_code"&&!t.tokens.has("authorization_code")){let h=await l();if(!t.authorize_callback||typeof t.authorize_callback!="function")throw $("oauth2mw: oauth2 with grant_type:authorization_code requires a callback function in client options.authorize_callback");let y=await t.authorize_callback(h);if(y)t.tokens.set("authorization_code",y);else return!1}let f=u(),c=await t.client.post(f);if(!c.ok){let h=await c.text();throw $("OAuth2mw: fetch access_token: "+c.status+": "+c.statusText,{cause:f})}let d=await c.json();if(t.tokens.set("access_token",{value:d.access_token,expires:Ms(d.expires_in),type:d.token_type,scope:d.scope}),d.refresh_token){let h={value:d.refresh_token};t.tokens.set("refresh_token",h)}return t.tokens.delete("authorization_code"),d}async function a(){let f=u("refresh_token"),c=await t.client.post(f);if(!c.ok)throw $("OAuth2mw: refresh access_token: "+c.status+": "+c.statusText,{cause:f});let d=await c.json();if(t.tokens.set("access_token",{value:d.access_token,expires:Ms(d.expires_in),type:d.token_type,scope:d.scope}),d.refresh_token){let h={value:d.refresh_token};t.tokens.set("refresh_token",h)}else return!1;return d}async function l(){if(!r.authorization_endpoint)throw $("oauth2mw: Missing options.oauth2_configuration.authorization_endpoint");let f=z(r.authorization_endpoint,{hash:""});H(r,{client_id:/.+/,redirect_uri:/.+/,scope:/.*/});let c={response_type:"code",client_id:r.client_id,redirect_uri:r.redirect_uri,state:r.state||yf(40)};return r.response_type&&(c.response_type=r.response_type),r.response_mode&&(c.response_mode=r.response_mode),t.state.set(c.state),r.client_secret&&(c.client_secret=r.client_secret),r.code_verifier&&(t.tokens.set("code_verifier",r.code_verifier),c.code_challenge=await _f(r.code_verifier),c.code_challenge_method="S256"),r.scope&&(c.scope=r.scope),r.prompt&&(c.prompt=r.prompt),z(f,{search:c})}function u(f=null){if(H(r,{client_id:/.+/,redirect_uri:/.+/}),!r.token_endpoint)throw $("oauth2mw: Missing options.endpoints.token url");let c=z(r.token_endpoint,{hash:""}),d={grant_type:f||r.grant_type,client_id:r.client_id};switch(r.client_secret&&(d.client_secret=r.client_secret),r.scope&&(d.scope=r.scope),d.grant_type){case"authorization_code":d.redirect_uri=r.redirect_uri,d.code=t.tokens.get("authorization_code");let h=t.tokens.get("code_verifier");h&&(d.code_verifier=h);break;case"client_credentials":break;case"refresh_token":let y=t.tokens.get("refresh_token");d.refresh_token=y.value;break;default:throw new Error("Unknown grant_type: ".oauth2.grant_type)}return Xe(c,{method:"POST",body:new URLSearchParams(d)})}}function hf(t){if(!t)return!0;let e=new Date(t.expires);return new Date().getTime()>e.getTime()}function Ms(t){if(t instanceof Date)return new Date(t.getTime());if(typeof t=="number"){let e=new Date;return e.setSeconds(e.getSeconds()+t),e}throw new TypeError("Unknown expires type "+t)}function pf(t=64){let e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),Us(e)}async function _f(t){let r=new TextEncoder().encode(t),n=await globalThis.crypto.subtle.digest("SHA-256",r);return Us(n)}function Us(t){let e=Array.from(new Uint8Array(t),r=>String.fromCharCode(r)).join("");return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function yf(t){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r="",n=0;for(;n<t;)r+=e.charAt(Math.floor(Math.random()*e.length)),n++;return r}function $s(){let t=new URL(document.location.href);if(!t.searchParams.has("code")){if(t.hash){let e=t.hash.substr(1);if(params=new URLSearchParams("?"+e),params.has("code"))return!0}return!1}return!0}function Mn(){return new Promise((t,e)=>{let r=globalThis.indexedDB.open("metro",1);r.onupgradeneeded=()=>r.result.createObjectStore("keyPairs",{keyPath:"domain"}),r.onerror=n=>{e(n)},r.onsuccess=n=>{let i=n.target.result;t({set:function(s,o){return new Promise((a,l)=>{let u=i.transaction("keyPairs","readwrite",{durability:"strict"}),f=u.objectStore("keyPairs");u.oncomplete=()=>{a()},u.onerror=l,f.put(s,o)})},get:function(s){return new Promise((o,a)=>{let l=i.transaction("keyPairs","readonly"),f=l.objectStore("keyPairs").get(s);f.onsuccess=()=>{o(f.result)},f.onerror=a,l.onerror=a})},clear:function(){return new Promise((s,o)=>{let a=i.transaction("keyPairs","readwrite"),u=a.objectStore("keyPairs").clear();u.onsuccess=()=>{s()},u.onerror=o,a.onerror=o})}})}})}var gf=new TextEncoder,mf=new TextDecoder;function Dr(t){return typeof t=="string"?gf.encode(t):mf.decode(t)}function qs(t){if(typeof t.modulusLength!="number"||t.modulusLength<2048)throw new Un(`${t.name} modulusLength must be at least 2048 bits`)}function wf(t){switch(t.algorithm.name){case"ECDSA":return{name:t.algorithm.name,hash:"SHA-256"};case"RSA-PSS":return qs(t.algorithm),{name:t.algorithm.name,saltLength:32};case"RSASSA-PKCS1-v1_5":return qs(t.algorithm),{name:t.algorithm.name};case"Ed25519":return{name:t.algorithm.name}}throw new Me}async function xf(t,e,r){if(r.usages.includes("sign")===!1)throw new TypeError('private CryptoKey instances used for signing assertions must include "sign" in their "usages"');let n=`${rr(Dr(JSON.stringify(t)))}.${rr(Dr(JSON.stringify(e)))}`,i=rr(await crypto.subtle.sign(wf(r),r,Dr(n)));return`${n}.${i}`}var Ws=32768;function Sf(t){t instanceof ArrayBuffer&&(t=new Uint8Array(t));let e=[];for(let r=0;r<t.byteLength;r+=Ws)e.push(String.fromCharCode.apply(null,t.subarray(r,r+Ws)));return btoa(e.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function rr(t){return Sf(t)}function Ef(){return rr(crypto.getRandomValues(new Uint8Array(32)))}var Me=class extends Error{constructor(e){super(e??"operation not supported"),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}},Un=class extends Error{constructor(e){super(e),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};function Rf(t){switch(t.algorithm.hash.name){case"SHA-256":return"PS256";default:throw new Me("unsupported RsaHashedKeyAlgorithm hash name")}}function If(t){switch(t.algorithm.hash.name){case"SHA-256":return"RS256";default:throw new Me("unsupported RsaHashedKeyAlgorithm hash name")}}function Af(t){switch(t.algorithm.namedCurve){case"P-256":return"ES256";default:throw new Me("unsupported EcKeyAlgorithm namedCurve")}}function Tf(t){switch(t.algorithm.name){case"RSA-PSS":return Rf(t);case"RSASSA-PKCS1-v1_5":return If(t);case"ECDSA":return Af(t);case"Ed25519":return"EdDSA";default:throw new Me("unsupported CryptoKey algorithm name")}}function Gs(t){return t instanceof CryptoKey}function vf(t){return Gs(t)&&t.type==="private"}function Nf(t){return Gs(t)&&t.type==="public"}function jf(){return Math.floor(Date.now()/1e3)}async function Mr(t,e,r,n,i,s){let o=t?.privateKey,a=t?.publicKey;if(!vf(o))throw new TypeError('"keypair.privateKey" must be a private CryptoKey');if(!Nf(a))throw new TypeError('"keypair.publicKey" must be a public CryptoKey');if(a.extractable!==!0)throw new TypeError('"keypair.publicKey.extractable" must be true');if(typeof e!="string")throw new TypeError('"htu" must be a string');if(typeof r!="string")throw new TypeError('"htm" must be a string');if(n!==void 0&&typeof n!="string")throw new TypeError('"nonce" must be a string or undefined');if(i!==void 0&&typeof i!="string")throw new TypeError('"accessToken" must be a string or undefined');if(s!==void 0&&(typeof s!="object"||s===null||Array.isArray(s)))throw new TypeError('"additional" must be an object');return xf({alg:Tf(o),typ:"dpop+jwt",jwk:await kf(a)},{...s,iat:jf(),jti:Ef(),htm:r,nonce:n,htu:e,ath:i?rr(await crypto.subtle.digest("SHA-256",Dr(i))):void 0},o)}async function kf(t){let{kty:e,e:r,n,x:i,y:s,crv:o}=await crypto.subtle.exportKey("jwk",t);return{kty:e,crv:o,e:r,n,x:i,y:s}}async function zs(t,e){let r;if(typeof t!="string"||t.length===0)throw new TypeError('"alg" must be a non-empty string');switch(t){case"PS256":r={name:"RSA-PSS",hash:"SHA-256",modulusLength:e?.modulusLength??2048,publicExponent:new Uint8Array([1,0,1])};break;case"RS256":r={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",modulusLength:e?.modulusLength??2048,publicExponent:new Uint8Array([1,0,1])};break;case"ES256":r={name:"ECDSA",namedCurve:"P-256"};break;case"EdDSA":r={name:"Ed25519"};break;default:throw new Me}return crypto.subtle.generateKey(r,e?.extractable??!1,["sign","verify"])}function $n(t){return H(t,{site:N(T),authorization_endpoint:N(T),token_endpoint:N(T),dpop_signing_alg_values_supported:w([])}),async(e,r)=>{let n=await Mn(),i=await n.get(t.site);if(!i){let a=await zs("ES256");i={domain:t.site,keyPair:a},await n.set(i)}let s=ce.url(e.url);if(e.url.startsWith(t.authorization_endpoint)){let a=e.body;a instanceof URLSearchParams||a instanceof FormData?a.set("dpop_jkt",i.keyPair.publicKey):a.dpop_jkt=i.keyPair.publicKey}else if(e.url.startsWith(t.token_endpoint)){let a=await Mr(i.keyPair,e.url,e.method);e=e.with({headers:{DPoP:a}})}else if(e.headers.has("Authorization")){let a=localStorage.getItem(s.host+":nonce")||void 0,l=e.headers.get("Authorization").split(" ")[1],u=await Mr(i.keyPair,e.url,e.method,a,l);e=e.with({headers:{Authorization:"DPoP "+l,DPoP:u}})}let o=await r(e);return o.headers.get("DPoP-Nonce")&&localStorage.setItem(s.host+":nonce",o.headers.get("DPoP-Nonce")),o}}var nr=(...t)=>(e,r)=>t.filter(n=>r.hasOwnKey(n)).length>0?!1:k("root data must have all of",r,t),Ue=(...t)=>e=>Array.isArray(e)&&t.filter(r=>!e.includes(r)).length==0?!1:k("data must be an array which includes",e,t);var se=["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512"],Ur=["client_secret_post","client_secret_basic","client_secret_jwt","private_key_jwt"];async function ir(t={}){H(t,{client:w(Rt(ce.client().constructor)),issuer:N(T)});let e={client:ce.client().with(fe()).with(ue()),requireDynamicRegistration:!1};t=Object.assign({},e,t);let r=!1;function n(l){return r}let i={issuer:N(Fs(t.issuer,n)),authorization_endpoint:N(T),token_endpoint:N(T),userinfo_endpoint:er(T),jwks_uri:N(T),registration_endpoint:t.requireDynamicRegistration?N(T):er(T),scopes_supported:er(Ue("openid")),response_types_supported:t.requireDynamicRegistration?N(Ue("code","id_token","id_token token")):N([]),response_modes_supported:w([]),grant_types_supported:t.requireDynamicRegistration?w(Ue("authorization_code")):w([]),acr_values_supported:w([]),subject_types_supported:N([]),id_token_signing_alg_values_supported:N(Ue("RS256")),id_token_encryption_alg_values_supported:w([]),id_token_encryption_enc_values_supported:w([]),userinfo_signing_alg_values_supported:w([]),userinfo_encryption_alg_values_supported:w([]),userinfo_encryption_enc_values_supported:w([]),request_object_signing_alg_values_supported:w(Ue("RS256")),request_object_encryption_alg_values_supported:w([]),request_object_encryption_enc_values_supported:w([]),token_endpoint_auth_methods_supported:w(Et(...Ur)),token_endpoint_auth_signing_alg_values_supported:w(Ue("RS256"),tr(Ue("none"))),display_values_supported:w(Et("page","popup","touch","wap")),claim_types_supported:w(Et("normal","aggregated","distributed")),claims_supported:er([]),service_documentation:w(T),claims_locales_supported:w([]),ui_locales_supported:w([]),claims_parameter_supported:w(Boolean),request_parameter_supported:w(Boolean),request_uri_parameter_supported:w(Boolean),op_policy_uri:w(T),op_tos_uri:w(T)},s=ce.url(t.issuer,".well-known/openid-configuration"),a=(await t.client.get(s)).data;return H(a,i),H(a.issuer,t.issuer),a}async function sr(t){let e={redirect_uris:N([T]),response_types:w([]),grant_types:w(Et("authorization_code","refresh_token")),application_type:w(J("native","web")),contacts:w([Cs]),client_name:w(String),logo_uri:w(T),client_uri:w(T),policy_uri:w(T),tos_uri:w(T),jwks_uri:w(T,tr(nr("jwks"))),jwks:w(T,tr(nr("jwks_uri"))),sector_identifier_uri:w(T),subject_type:w(String),id_token_signed_response_alg:w(J(...se)),id_token_encrypted_response_alg:w(J(...se)),id_token_encrypted_response_enc:w(J(...se),nr("id_token_encrypted_response_alg")),userinfo_signed_response_alg:w(J(...se)),userinfo_encrypted_response_alg:w(J(...se)),userinfo_encrypted_response_enc:w(J(...se),nr("userinfo_encrypted_response_alg")),request_object_signing_alg:w(J(...se)),request_object_encryption_alg:w(J(...se)),request_object_encryption_enc:w(J(...se)),token_endpoint_auth_method:w(J(...Ur)),token_endpoint_auth_signing_alg:w(J(...se)),default_max_age:w(Number),require_auth_time:w(Boolean),default_acr_values:w([String]),initiate_login_uri:w([T]),request_uris:w([T])};H(t,{client:w(Rt(ce.client().constructor)),registration_endpoint:T,client_info:e});let r={client:ce.client().with(fe()).with(ue()),client_info:{redirect_uris:[globalThis.document?.location.href]}};t=Object.assign({},r,t),t.client_info||(t.client_info={}),t.client_info.redirect_uris||(t.client_info.redirect_uris=[globalThis.document?.location.href]);let n=await t.client.post(t.registration_endpoint,{body:t.client_info}),i=n.data;if(!i.client_id||!i.client_secret)throw ce.metroError("metro.oidc: Error: dynamic registration of client failed, no client_id or client_secret returned",n);return t.client_info=Object.assign(t.client_info,i),t.client_info}function $r(t){let e;if(typeof localStorage<"u")e={get:r=>JSON.parse(localStorage.getItem("metro/oidc:"+t+":"+r)),set:(r,n)=>localStorage.setItem("metro/oidc:"+t+":"+r,JSON.stringify(n)),has:r=>localStorage.getItem("metro/oidc:"+t+":"+r)!==null};else{let r=new Map;e={get:n=>JSON.parse(r.get("metro/oidc:"+t+":"+n)||null),set:(n,i)=>r.set("metro/oidc:"+t+":"+n,JSON.stringify(i)),has:n=>r.has("metro/oidc:"+t+":"+n)}}return e}function qn(t={}){let e={client:le(),force_authorization:!1,use_dpop:!0,authorize_callback:async r=>(window.location.href!=r.href&&window.location.replace(r.href),!1)};return t=Object.assign({},e,t),H(t,{client:N(Rt(le().constructor)),client_info:N(),issuer:N(T),oauth2:w({}),openid_configuration:w()}),t.store||(t.store=$r(t.issuer)),!t.openid_configuration&&t.store.has("openid_configuration")&&(t.openid_configuration=t.store.get("openid_configuration")),!t.client_info?.client_id&&t.store.has("client_info")&&(t.client_info=t.store.get("client_info")),async(r,n)=>{let i;if(!t.force_authorization){try{i=await n(r)}catch(u){if(i.status!=401&&i.status!=403)throw u}if(i.ok||i.status!=401&&i.status!=403)return i}if(t.openid_configuration||(t.openid_configuration=await ir({issuer:t.issuer}),t.store.set("openid_configuration",t.openid_configuration)),!t.client_info?.client_id){if(!t.openid_configuration.registration_endpoint)throw $("metro.oidcmw: Error: issuer "+t.issuer+" does not support dynamic client registration, but you haven't specified a client_id");t.client_info=await sr({registration_endpoint:t.openid_configuration.registration_endpoint,client_info:t.client_info}),t.store.set("client_info",t.client_info)}let s=t.scope||"openid",o=Object.assign({site:t.issuer,client:t.client,force_authorization:!0,authorize_callback:t.authorize_callback,oauth2_configuration:{client_id:t.client_info?.client_id,client_secret:t.client_info?.client_secret,grant_type:"authorization_code",response_type:"code",response_mode:"query",authorization_endpoint:t.openid_configuration.authorization_endpoint,token_endpoint:t.openid_configuration.token_endpoint,scope:s,redirect_uri:t.client_info.redirect_uris[0]}}),a=async(u,f)=>{let c=await f(u);if(c.headers.get("content-type")?.startsWith("application/json")){let h=c.data?.id_token;if(!h){let y=c.clone();try{let _=await y.json();_&&_.id_token&&(h=_.id_token)}catch{}}h&&t.store.set("id_token",h)}return c},l=t.client.with(t.issuer).with(a);if(t.use_dpop){let u={site:t.issuer,authorization_endpoint:t.openid_configuration.authorization_endpoint,token_endpoint:t.openid_configuration.token_endpoint,dpop_signing_alg_values_supported:t.openid_configuration.dpop_signing_alg_values_supported};l=l.with($n(u)),o.client=l}return l=l.with(Dn(o)),i=await l.fetch(r),i}}function Hs(){return $s()}function Qs(t){if(!t.store){if(!t.issuer)throw $("Must supply options.issuer or options.store to get the id_token");t.store=$r(t.issuer)}return t.store.get("id_token")}var Ks={oidcmw:qn,discover:ir,register:sr,isRedirected:Hs,idToken:Qs};globalThis.metro.oidc||(globalThis.metro.oidc=Ks);var Vs=Ks;function zn(t){return new Wn(t)}var Hn="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",Pf={rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",solid:"http://www.w3.org/ns/solid/terms#",schema:"http://schema.org/",vcard:"http://www.w3.org/2006/vcard/ns#"},Wn=class{constructor(e){this.prefixes={...Pf,...e?.prefixes},this.prefixes.xsd||(this.prefixes.xsd="http://www.w3.org/2001/XMLSchema#"),this.parser=e?.parser,this.writer=e?.writer,this.sources=Object.create(null),this.separator=e?.separator??"$"}parse(e,r,n){let{quads:i,prefixes:s}=this.parser(e,r,n);if(s)for(let o in s){let a=s[o];if(a.match(/^http(s?):\/\/$/i))a+=r.substring(a.length);else try{a=new URL(s[o],r).href}catch(l){console.error("Could not parse prefix",s[o],l.message)}this.prefixes[o]||(this.prefixes[o]=a)}return this.sources[r]=new Gn(i,r,n,s,this),this.sources[r]}setType(e,r){if(!r)return e;if(typeof e=="string"?e=new String(e):typeof result=="number"&&(e=new Number(e)),typeof e!="object")throw new Error("cannot set type on ",e,r);return e.type=r,e}getType(e){return e&&typeof e=="object"?e.type:null}},Gn=class{#e=Object.create(null);constructor(e,r,n,i,s){this.mimetype=n,this.url=r,this.prefixes=i,this.context=s,this.subjects=Object.create(null);for(let o of e){let a;if(o.subject.termType=="BlankNode"){let l=this.shortURI(o.predicate.id,":"),u;switch(l){case"rdf:first":if(a=this.addCollection(o.subject.id),u=this.shortURI(o.object.id,":"),u!="rdf:nil"){let f=this.getValue(o.object);f&&a.push(f)}continue;case"rdf:rest":this.#e[o.object.id]=this.#e[o.subject.id];continue;default:a=this.addBlankNode(o.subject.id);break}}else a=this.addNamedNode(o.subject.id);a.addPredicate(o.predicate.id,o.object)}this.subjects[r]?this.primary=this.subjects[r]:this.primary=null,Object.defineProperty(this,"data",{get(){return Object.values(this.subjects)}})}addNamedNode(e){let r=new URL(e,this.url).href;return this.subjects[r]||(this.subjects[r]=new It(r,this)),this.subjects[r]}addBlankNode(e){return this.#e[e]||(this.#e[e]=new et(this)),this.#e[e]}addCollection(e){return this.#e[e]||(this.#e[e]=new At(this)),this.#e[e]}write(){return this.context.writer(this)}get(e){return this.subjects[this.fullURI(e)]}fullURI(e,r=null){r||(r=this.context.separator);let[n,i]=e.split(r);return i?this.prefixes[n]+i:e}shortURI(e,r=null){r||(r=this.context.separator);for(let n in this.context.prefixes)if(e.startsWith(this.context.prefixes[n]))return n+r+e.substring(this.context.prefixes[n].length);return this.url&&e.startsWith(this.url)?e.substring(this.url.length):e}setType(e,r){let n=this.shortURI(r);return this.context.setType(e,n)}getType(e){return this.context.getType(e)}setLanguage(e,r){if(typeof e=="string"?e=new String(e):typeof result=="number"&&(e=new Number(e)),typeof e!="object")throw new Error("cannot set language on ",e);return e.language=r,e}getValue(e){let r;if(e.termType=="Literal"){r=e.value;let n=e.datatype?.id;n&&(r=this.setType(r,n));let i=e.language;i&&(r=this.setLanguage(r,i))}else e.termType=="BlankNode"?r=this.addBlankNode(e.id):r=this.addNamedNode(e.id);return r}},et=class{constructor(e){Object.defineProperty(this,"graph",{value:e,writable:!1,enumerable:!1})}addPredicate(e,r){if(e.id&&(e=e.id),e==Hn){let n=this.graph.shortURI(r.id);this.addType(n)}else{let n=this.graph.getValue(r);e=this.graph.shortURI(e),this[e]?Array.isArray(this[e])?this[e].push(n):this[e]=[this[e],n]:this[e]=n}}addType(e){this.a?(Array.isArray(this.a)||(this.a=[this.a]),this.a.push(e)):this.a=e}},It=class extends et{constructor(e,r){super(r),Object.defineProperty(this,"id",{value:e,writable:!1,enumerable:!0})}},At=class extends Array{constructor(e,r){super(),Object.defineProperty(this,"graph",{value:r,writable:!1,enumerable:!1})}};var Is={};Fn(Is,{n3Parser:()=>nb,n3Writer:()=>ib});var go=Br(pe());var ar="http://www.w3.org/1999/02/22-rdf-syntax-ns#",lr="http://www.w3.org/2001/XMLSchema#",zr="http://www.w3.org/2000/10/swap/",O={xsd:{decimal:`${lr}decimal`,boolean:`${lr}boolean`,double:`${lr}double`,integer:`${lr}integer`,string:`${lr}string`},rdf:{type:`${ar}type`,nil:`${ar}nil`,first:`${ar}first`,rest:`${ar}rest`,langString:`${ar}langString`},owl:{sameAs:"http://www.w3.org/2002/07/owl#sameAs"},r:{forSome:`${zr}reify#forSome`,forAll:`${zr}reify#forAll`},log:{implies:`${zr}log#implies`,isImpliedBy:`${zr}log#isImpliedBy`}};var{xsd:Hr}=O,cc=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\([^])/g,bo={"\\":"\\","'":"'",'"':'"',n:`
3
+ `,r:"\r",t:" ",f:"\f",b:"\b",_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},dc=/[\x00-\x20<>\\"\{\}\|\^\`]/,hc={_iri:!0,_unescapedIri:!0,_simpleQuotedString:!0,_langcode:!0,_blank:!0,_newline:!0,_comment:!0,_whitespace:!0,_endOfFile:!0},pc=/$0^/,nt=class{constructor(e){if(this._iri=/^<((?:[^ <>{}\\]|\\[uU])+)>[ \t]*/,this._unescapedIri=/^<([^\x00-\x20<>\\"\{\}\|\^\`]*)>[ \t]*/,this._simpleQuotedString=/^"([^"\\\r\n]*)"(?=[^"])/,this._simpleApostropheString=/^'([^'\\\r\n]*)'(?=[^'])/,this._langcode=/^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9\-])/i,this._prefix=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:(?=[#\s<])/,this._prefixed=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:((?:(?:[0-:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])(?:(?:[\.\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])*(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~]))?)?)(?:[ \t]+|(?=\.?[,;!\^\s#()\[\]\{\}"'<>]))/,this._variable=/^\?(?:(?:[A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?=[.,;!\^\s#()\[\]\{\}"'<>])/,this._blank=/^_:((?:[0-9A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?:[ \t]+|(?=\.?[,;:\s#()\[\]\{\}"'<>]))/,this._number=/^[\-+]?(?:(\d+\.\d*|\.?\d+)[eE][\-+]?|\d*(\.)?)\d+(?=\.?[,;:\s#()\[\]\{\}"'<>])/,this._boolean=/^(?:true|false)(?=[.,;\s#()\[\]\{\}"'<>])/,this._keyword=/^@[a-z]+(?=[\s#<:])/i,this._sparqlKeyword=/^(?:PREFIX|BASE|GRAPH)(?=[\s#<])/i,this._shortPredicates=/^a(?=[\s#()\[\]\{\}"'<>])/,this._newline=/^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/,this._comment=/#([^\n\r]*)/,this._whitespace=/^[ \t]+/,this._endOfFile=/^(?:#[^\n\r]*)?$/,e=e||{},this._isImpliedBy=e.isImpliedBy,this._lineMode=!!e.lineMode){this._n3Mode=!1;for(let r in this)!(r in hc)&&this[r]instanceof RegExp&&(this[r]=pc)}else this._n3Mode=e.n3!==!1;this.comments=!!e.comments,this._literalClosingPos=0}_tokenizeToEnd(e,r){let n=this._input,i=n.length;for(;;){let a,l;for(;a=this._newline.exec(n);)this.comments&&(l=this._comment.exec(a[0]))&&s("comment",l[1],"",this._line,a[0].length),n=n.substr(a[0].length,n.length),i=n.length,this._line++;if(!a&&(a=this._whitespace.exec(n))&&(n=n.substr(a[0].length,n.length)),this._endOfFile.test(n))return r&&(this.comments&&(l=this._comment.exec(n))&&s("comment",l[1],"",this._line,n.length),n=null,s("eof","","",this._line,0)),this._input=n;let u=this._line,f=n[0],c="",d="",h="",y=null,_=0,x=!1;switch(f){case"^":if(n.length<3)break;if(n[1]==="^"){if(this._previousMarker="^^",n=n.substr(2),n[0]!=="<"){x=!0;break}}else{this._n3Mode&&(_=1,c="^");break}case"<":if(y=this._unescapedIri.exec(n))c="IRI",d=y[1];else if(y=this._iri.exec(n)){if(d=this._unescape(y[1]),d===null||dc.test(d))return o(this);c="IRI"}else n.length>1&&n[1]==="<"?(c="<<",_=2):this._n3Mode&&n.length>1&&n[1]==="="&&(_=2,this._isImpliedBy?(c="abbreviation",d="<"):(c="inverse",d=">"));break;case">":n.length>1&&n[1]===">"&&(c=">>",_=2);break;case"_":((y=this._blank.exec(n))||r&&(y=this._blank.exec(`${n} `)))&&(c="blank",h="_",d=y[1]);break;case'"':if(y=this._simpleQuotedString.exec(n))d=y[1];else if({value:d,matchLength:_}=this._parseLiteral(n),d===null)return o(this);(y!==null||_!==0)&&(c="literal",this._literalClosingPos=0);break;case"'":if(!this._lineMode){if(y=this._simpleApostropheString.exec(n))d=y[1];else if({value:d,matchLength:_}=this._parseLiteral(n),d===null)return o(this);(y!==null||_!==0)&&(c="literal",this._literalClosingPos=0)}break;case"?":this._n3Mode&&(y=this._variable.exec(n))&&(c="var",d=y[0]);break;case"@":this._previousMarker==="literal"&&(y=this._langcode.exec(n))?(c="langcode",d=y[1]):(y=this._keyword.exec(n))&&(c=y[0]);break;case".":if(n.length===1?r:n[1]<"0"||n[1]>"9"){c=".",_=1;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":(y=this._number.exec(n)||r&&(y=this._number.exec(`${n} `)))&&(c="literal",d=y[0],h=typeof y[1]=="string"?Hr.double:typeof y[2]=="string"?Hr.decimal:Hr.integer);break;case"B":case"b":case"p":case"P":case"G":case"g":(y=this._sparqlKeyword.exec(n))?c=y[0].toUpperCase():x=!0;break;case"f":case"t":(y=this._boolean.exec(n))?(c="literal",d=y[0],h=Hr.boolean):x=!0;break;case"a":(y=this._shortPredicates.exec(n))?(c="abbreviation",d="a"):x=!0;break;case"=":this._n3Mode&&n.length>1&&(c="abbreviation",n[1]!==">"?(_=1,d="="):(_=2,d=">"));break;case"!":if(!this._n3Mode)break;case",":case";":case"[":case"]":case"(":case")":case"}":this._lineMode||(_=1,c=f);break;case"{":!this._lineMode&&n.length>=2&&(n[1]==="|"?(c="{|",_=2):(c=f,_=1));break;case"|":n.length>=2&&n[1]==="}"&&(c="|}",_=2);break;default:x=!0}if(x&&((this._previousMarker==="@prefix"||this._previousMarker==="PREFIX")&&(y=this._prefix.exec(n))?(c="prefix",d=y[1]||""):((y=this._prefixed.exec(n))||r&&(y=this._prefixed.exec(`${n} `)))&&(c="prefixed",h=y[1]||"",d=this._unescape(y[2]))),this._previousMarker==="^^")switch(c){case"prefixed":c="type";break;case"IRI":c="typeIRI";break;default:c=""}if(!c)return r||!/^'''|^"""/.test(n)&&/\n|\r/.test(n)?o(this):this._input=n;let b=_||y[0].length,g=s(c,d,h,u,b);this.previousToken=g,this._previousMarker=c,n=n.substr(b,n.length)}function s(a,l,u,f,c){let d=n?i-n.length:i,h=d+c,y={type:a,value:l,prefix:u,line:f,start:d,end:h};return e(null,y),y}function o(a){e(a._syntaxError(/^\S*/.exec(n)[0]))}}_unescape(e){let r=!1,n=e.replace(cc,(i,s,o,a)=>{if(typeof s=="string")return String.fromCharCode(Number.parseInt(s,16));if(typeof o=="string"){let l=Number.parseInt(o,16);return l<=65535?String.fromCharCode(Number.parseInt(o,16)):String.fromCharCode(55296+((l-=65536)>>10),56320+(l&1023))}return a in bo?bo[a]:(r=!0,"")});return r?null:n}_parseLiteral(e){if(e.length>=3){let r=e.match(/^(?:"""|"|'''|'|)/)[0],n=r.length,i=Math.max(this._literalClosingPos,n);for(;(i=e.indexOf(r,i))>0;){let s=0;for(;e[i-s-1]==="\\";)s++;if(s%2===0){let o=e.substring(n,i),a=o.split(/\r\n|\r|\n/).length-1,l=i+n;if(n===1&&a!==0||n===3&&this._lineMode)break;return this._line+=a,{value:this._unescape(o),matchLength:l}}i++}this._literalClosingPos=e.length-n+1}return{value:"",matchLength:0}}_syntaxError(e){this._input=null;let r=new Error(`Unexpected "${e}" on line ${this._line}.`);return r.context={token:void 0,line:this._line,previousToken:this.previousToken},r}_readStartingBom(e){return e.startsWith("\uFEFF")?e.substr(1):e}tokenize(e,r){if(this._line=1,typeof e=="string")if(this._input=this._readStartingBom(e),typeof r=="function")queueMicrotask(()=>this._tokenizeToEnd(r,!0));else{let n=[],i;if(this._tokenizeToEnd((s,o)=>s?i=s:n.push(o),!0),i)throw i;return n}else this._pendingBuffer=null,typeof e.setEncoding=="function"&&e.setEncoding("utf8"),e.on("data",n=>{this._input!==null&&n.length!==0&&(this._pendingBuffer&&(n=go.Buffer.concat([this._pendingBuffer,n]),this._pendingBuffer=null),n[n.length-1]&128?this._pendingBuffer=n:(typeof this._input>"u"?this._input=this._readStartingBom(typeof n=="string"?n:n.toString()):this._input+=n,this._tokenizeToEnd(r,!1)))}),e.on("end",()=>{typeof this._input=="string"&&this._tokenizeToEnd(r,!0)}),e.on("error",r)}};var{rdf:_c,xsd:it}=O,Pt,yc=0;var ni={namedNode:mo,blankNode:wo,variable:So,literal:xo,defaultGraph:bc,quad:ii,triple:ii,fromTerm:ur,fromQuad:Eo},X=ni,Z=class t{constructor(e){this.id=e}get value(){return this.id}equals(e){return e instanceof t?this.id===e.id:!!e&&this.termType===e.termType&&this.value===e.value}hashCode(){return 0}toJSON(){return{termType:this.termType,value:this.value}}},kt=class extends Z{get termType(){return"NamedNode"}},We=class t extends Z{get termType(){return"Literal"}get value(){return this.id.substring(1,this.id.lastIndexOf('"'))}get language(){let e=this.id,r=e.lastIndexOf('"')+1;return r<e.length&&e[r++]==="@"?e.substr(r).toLowerCase():""}get datatype(){return new kt(this.datatypeString)}get datatypeString(){let e=this.id,r=e.lastIndexOf('"')+1,n=r<e.length?e[r]:"";return n==="^"?e.substr(r+2):n!=="@"?it.string:_c.langString}equals(e){return e instanceof t?this.id===e.id:!!e&&!!e.datatype&&this.termType===e.termType&&this.value===e.value&&this.language===e.language&&this.datatype.value===e.datatype.value}toJSON(){return{termType:this.termType,value:this.value,language:this.language,datatype:{termType:"NamedNode",value:this.datatypeString}}}},fr=class extends Z{constructor(e){super(`_:${e}`)}get termType(){return"BlankNode"}get value(){return this.id.substr(2)}},cr=class extends Z{constructor(e){super(`?${e}`)}get termType(){return"Variable"}get value(){return this.id.substr(1)}},dr=class extends Z{constructor(){return super(""),Pt||this}get termType(){return"DefaultGraph"}equals(e){return this===e||!!e&&this.termType===e.termType}};Pt=new dr;function qe(t,e,r){if(e=e||ni,!t)return e.defaultGraph();switch(t[0]){case"?":return e.variable(t.substr(1));case"_":return e.blankNode(t.substr(2));case'"':if(e===ni)return new We(t);if(t[t.length-1]==='"')return e.literal(t.substr(1,t.length-2));let n=t.lastIndexOf('"',t.length-1);return e.literal(t.substr(1,n-1),t[n+1]==="@"?t.substr(n+2):e.namedNode(t.substr(n+3)));case"[":t=JSON.parse(t);break;default:if(!r||!Array.isArray(t))return e.namedNode(t)}return e.quad(qe(t[0],e,!0),qe(t[1],e,!0),qe(t[2],e,!0),t[3]&&qe(t[3],e,!0))}function Ne(t,e){if(typeof t=="string")return t;if(t instanceof Z&&t.termType!=="Quad")return t.id;if(!t)return Pt.id;switch(t.termType){case"NamedNode":return t.value;case"BlankNode":return`_:${t.value}`;case"Variable":return`?${t.value}`;case"DefaultGraph":return"";case"Literal":return`"${t.value}"${t.language?`@${t.language}`:t.datatype&&t.datatype.value!==it.string?`^^${t.datatype.value}`:""}`;case"Quad":let r=[Ne(t.subject,!0),Ne(t.predicate,!0),Ne(t.object,!0)];return t.graph&&t.graph.termType!=="DefaultGraph"&&r.push(Ne(t.graph,!0)),e?r:JSON.stringify(r);default:throw new Error(`Unexpected termType: ${t.termType}`)}}var Ge=class extends Z{constructor(e,r,n,i){super(""),this._subject=e,this._predicate=r,this._object=n,this._graph=i||Pt}get termType(){return"Quad"}get subject(){return this._subject}get predicate(){return this._predicate}get object(){return this._object}get graph(){return this._graph}toJSON(){return{termType:this.termType,subject:this._subject.toJSON(),predicate:this._predicate.toJSON(),object:this._object.toJSON(),graph:this._graph.toJSON()}}equals(e){return!!e&&this._subject.equals(e.subject)&&this._predicate.equals(e.predicate)&&this._object.equals(e.object)&&this._graph.equals(e.graph)}};function mo(t){return new kt(t)}function wo(t){return new fr(t||`n3-${yc++}`)}function xo(t,e){if(typeof e=="string")return new We(`"${t}"@${e.toLowerCase()}`);let r=e?e.value:"";return r===""&&(typeof t=="boolean"?r=it.boolean:typeof t=="number"&&(Number.isFinite(t)?r=Number.isInteger(t)?it.integer:it.double:(r=it.double,Number.isNaN(t)||(t=t>0?"INF":"-INF")))),r===""||r===it.string?new We(`"${t}"`):new We(`"${t}"^^${r}`)}function So(t){return new cr(t)}function bc(){return Pt}function ii(t,e,r,n){return new Ge(t,e,r,n)}function ur(t){if(t instanceof Z)return t;switch(t.termType){case"NamedNode":return mo(t.value);case"BlankNode":return wo(t.value);case"Variable":return So(t.value);case"DefaultGraph":return Pt;case"Literal":return xo(t.value,t.language||t.datatype);case"Quad":return Eo(t);default:throw new Error(`Unexpected termType: ${t.termType}`)}}function Eo(t){if(t instanceof Ge)return t;if(t.termType!=="Quad")throw new Error(`Unexpected termType: ${t.termType}`);return ii(ur(t.subject),ur(t.predicate),ur(t.object),ur(t.graph))}var Ro=0,ze=class{constructor(e){this._contextStack=[],this._graph=null,e=e||{},this._setBase(e.baseIRI),e.factory&&Io(this,e.factory);let r=typeof e.format=="string"?e.format.match(/\w*$/)[0].toLowerCase():"",n=/turtle/.test(r),i=/trig/.test(r),s=/triple/.test(r),o=/quad/.test(r),a=this._n3Mode=/n3/.test(r),l=s||o;(this._supportsNamedGraphs=!(n||a))||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(n||i||s||a),this._isImpliedBy=e.isImpliedBy,this._supportsRDFStar=r===""||/star|\*$/.test(r),l&&(this._resolveRelativeIRI=u=>null),this._blankNodePrefix=typeof e.blankNodePrefix!="string"?"":e.blankNodePrefix.replace(/^(?!_:)/,"_:"),this._lexer=e.lexer||new nt({lineMode:l,n3:a,isImpliedBy:this._isImpliedBy}),this._explicitQuantifiers=!!e.explicitQuantifiers}static _resetBlankNodePrefix(){Ro=0}_setBase(e){if(!e)this._base="",this._basePath="";else{let r=e.indexOf("#");r>=0&&(e=e.substr(0,r)),this._base=e,this._basePath=e.indexOf("/")<0?e:e.replace(/[^\/?]*(?:\?.*)?$/,""),e=e.match(/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i),this._baseRoot=e[0],this._baseScheme=e[1]}}_saveContext(e,r,n,i,s){let o=this._n3Mode;this._contextStack.push({type:e,subject:n,predicate:i,object:s,graph:r,inverse:o?this._inversePredicate:!1,blankPrefix:o?this._prefixes._:"",quantified:o?this._quantified:null}),o&&(this._inversePredicate=!1,this._prefixes._=this._graph?`${this._graph.value}.`:".",this._quantified=Object.create(this._quantified))}_restoreContext(e,r){let n=this._contextStack.pop();if(!n||n.type!==e)return this._error(`Unexpected ${r.type}`,r);this._subject=n.subject,this._predicate=n.predicate,this._object=n.object,this._graph=n.graph,this._n3Mode&&(this._inversePredicate=n.inverse,this._prefixes._=n.blankPrefix,this._quantified=n.quantified)}_readInTopContext(e){switch(e.type){case"eof":return this._graph!==null?this._error("Unclosed graph",e):(delete this._prefixes._,this._callback(null,null,this._prefixes));case"PREFIX":this._sparqlStyle=!0;case"@prefix":return this._readPrefix;case"BASE":this._sparqlStyle=!0;case"@base":return this._readBaseIRI;case"{":if(this._supportsNamedGraphs)return this._graph="",this._subject=null,this._readSubject;case"GRAPH":if(this._supportsNamedGraphs)return this._readNamedGraphLabel;default:return this._readSubject(e)}}_readEntity(e,r){let n;switch(e.type){case"IRI":case"typeIRI":let i=this._resolveIRI(e.value);if(i===null)return this._error("Invalid IRI",e);n=this._factory.namedNode(i);break;case"type":case"prefixed":let s=this._prefixes[e.prefix];if(s===void 0)return this._error(`Undefined prefix "${e.prefix}:"`,e);n=this._factory.namedNode(s+e.value);break;case"blank":n=this._factory.blankNode(this._prefixes[e.prefix]+e.value);break;case"var":n=this._factory.variable(e.value.substr(1));break;default:return this._error(`Expected entity but got ${e.type}`,e)}return!r&&this._n3Mode&&n.id in this._quantified&&(n=this._quantified[n.id]),n}_readSubject(e){switch(this._predicate=null,e.type){case"[":return this._saveContext("blank",this._graph,this._subject=this._factory.blankNode(),null,null),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this.RDF_NIL,null,null),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._graph=this._factory.blankNode(),null,null),this._readSubject):this._error("Unexpected graph",e);case"}":return this._readPunctuation(e);case"@forSome":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORSOME,this._quantifier="blankNode",this._readQuantifierList):this._error('Unexpected "@forSome"',e);case"@forAll":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORALL,this._quantifier="variable",this._readQuantifierList):this._error('Unexpected "@forAll"',e);case"literal":if(!this._n3Mode)return this._error("Unexpected literal",e);if(e.prefix.length===0)return this._literalValue=e.value,this._completeSubjectLiteral;this._subject=this._factory.literal(e.value,this._factory.namedNode(e.prefix));break;case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,null,null,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",e);default:if((this._subject=this._readEntity(e))===void 0)return;if(this._n3Mode)return this._getPathReader(this._readPredicateOrNamedGraph)}return this._readPredicateOrNamedGraph}_readPredicate(e){let r=e.type;switch(r){case"inverse":this._inversePredicate=!0;case"abbreviation":this._predicate=this.ABBREVIATIONS[e.value];break;case".":case"]":case"}":return this._predicate===null?this._error(`Unexpected ${r}`,e):(this._subject=null,r==="]"?this._readBlankNodeTail(e):this._readPunctuation(e));case";":return this._predicate!==null?this._readPredicate:this._error("Expected predicate but got ;",e);case"[":if(this._n3Mode)return this._saveContext("blank",this._graph,this._subject,this._subject=this._factory.blankNode(),null),this._readBlankNodeHead;case"blank":if(!this._n3Mode)return this._error("Disallowed blank node as predicate",e);default:if((this._predicate=this._readEntity(e))===void 0)return}return this._readObject}_readObject(e){switch(e.type){case"literal":if(e.prefix.length===0)return this._literalValue=e.value,this._readDataTypeOrLang;this._object=this._factory.literal(e.value,this._factory.namedNode(e.prefix));break;case"[":return this._saveContext("blank",this._graph,this._subject,this._predicate,this._subject=this._factory.blankNode()),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this._subject,this._predicate,this.RDF_NIL),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",e);case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,this._subject,this._predicate,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",e);default:if((this._object=this._readEntity(e))===void 0)return;if(this._n3Mode)return this._getPathReader(this._getContextEndReader())}return this._getContextEndReader()}_readPredicateOrNamedGraph(e){return e.type==="{"?this._readGraph(e):this._readPredicate(e)}_readGraph(e){return e.type!=="{"?this._error(`Expected graph but got ${e.type}`,e):(this._graph=this._subject,this._subject=null,this._readSubject)}_readBlankNodeHead(e){return e.type==="]"?(this._subject=null,this._readBlankNodeTail(e)):(this._predicate=null,this._readPredicate(e))}_readBlankNodeTail(e){if(e.type!=="]")return this._readBlankNodePunctuation(e);this._subject!==null&&this._emit(this._subject,this._predicate,this._object,this._graph);let r=this._predicate===null;return this._restoreContext("blank",e),this._object!==null?this._getContextEndReader():this._predicate!==null?this._readObject:r?this._readPredicateOrNamedGraph:this._readPredicateAfterBlank}_readPredicateAfterBlank(e){switch(e.type){case".":case"}":return this._subject=null,this._readPunctuation(e);default:return this._readPredicate(e)}}_readListItem(e){let r=null,n=null,i=this._readListItem,s=this._subject,o=this._contextStack,a=o[o.length-1];switch(e.type){case"[":this._saveContext("blank",this._graph,n=this._factory.blankNode(),this.RDF_FIRST,this._subject=r=this._factory.blankNode()),i=this._readBlankNodeHead;break;case"(":this._saveContext("list",this._graph,n=this._factory.blankNode(),this.RDF_FIRST,this.RDF_NIL),this._subject=null;break;case")":if(this._restoreContext("list",e),o.length!==0&&o[o.length-1].type==="list"&&this._emit(this._subject,this._predicate,this._object,this._graph),this._predicate===null){if(i=this._readPredicate,this._subject===this.RDF_NIL)return i}else if(i=this._getContextEndReader(),this._object===this.RDF_NIL)return i;n=this.RDF_NIL;break;case"literal":e.prefix.length===0?(this._literalValue=e.value,i=this._readListItemDataTypeOrLang):(r=this._factory.literal(e.value,this._factory.namedNode(e.prefix)),i=this._getContextEndReader());break;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",e);default:if((r=this._readEntity(e))===void 0)return}if(n===null&&(this._subject=n=this._factory.blankNode()),s===null?a.predicate===null?a.subject=n:a.object=n:this._emit(s,this.RDF_REST,n,this._graph),r!==null){if(this._n3Mode&&(e.type==="IRI"||e.type==="prefixed"))return this._saveContext("item",this._graph,n,this.RDF_FIRST,r),this._subject=r,this._predicate=null,this._getPathReader(this._readListItem);this._emit(n,this.RDF_FIRST,r,this._graph)}return i}_readDataTypeOrLang(e){return this._completeObjectLiteral(e,!1)}_readListItemDataTypeOrLang(e){return this._completeObjectLiteral(e,!0)}_completeLiteral(e){let r=this._factory.literal(this._literalValue);switch(e.type){case"type":case"typeIRI":let n=this._readEntity(e);if(n===void 0)return;r=this._factory.literal(this._literalValue,n),e=null;break;case"langcode":r=this._factory.literal(this._literalValue,e.value),e=null;break}return{token:e,literal:r}}_completeSubjectLiteral(e){return this._subject=this._completeLiteral(e).literal,this._readPredicateOrNamedGraph}_completeObjectLiteral(e,r){let n=this._completeLiteral(e);if(n)return this._object=n.literal,r&&this._emit(this._subject,this.RDF_FIRST,this._object,this._graph),n.token===null?this._getContextEndReader():(this._readCallback=this._getContextEndReader(),this._readCallback(n.token))}_readFormulaTail(e){return e.type!=="}"?this._readPunctuation(e):(this._subject!==null&&this._emit(this._subject,this._predicate,this._object,this._graph),this._restoreContext("formula",e),this._object===null?this._readPredicate:this._getContextEndReader())}_readPunctuation(e){let r,n=this._graph,i=this._subject,s=this._inversePredicate;switch(e.type){case"}":if(this._graph===null)return this._error("Unexpected graph closing",e);if(this._n3Mode)return this._readFormulaTail(e);this._graph=null;case".":this._subject=null,r=this._contextStack.length?this._readSubject:this._readInTopContext,s&&(this._inversePredicate=!1);break;case";":r=this._readPredicate;break;case",":r=this._readObject;break;case"{|":if(!this._supportsRDFStar)return this._error("Unexpected RDF-star syntax",e);let o=this._predicate,a=this._object;this._subject=this._factory.quad(i,o,a,this.DEFAULTGRAPH),r=this._readPredicate;break;case"|}":if(this._subject.termType!=="Quad")return this._error("Unexpected asserted triple closing",e);this._subject=null,r=this._readPunctuation;break;default:if(this._supportsQuads&&this._graph===null&&(n=this._readEntity(e))!==void 0){r=this._readQuadPunctuation;break}return this._error(`Expected punctuation to follow "${this._object.id}"`,e)}if(i!==null){let o=this._predicate,a=this._object;s?this._emit(a,o,i,n):this._emit(i,o,a,n)}return r}_readBlankNodePunctuation(e){let r;switch(e.type){case";":r=this._readPredicate;break;case",":r=this._readObject;break;default:return this._error(`Expected punctuation to follow "${this._object.id}"`,e)}return this._emit(this._subject,this._predicate,this._object,this._graph),r}_readQuadPunctuation(e){return e.type!=="."?this._error("Expected dot to follow quad",e):this._readInTopContext}_readPrefix(e){return e.type!=="prefix"?this._error("Expected prefix to follow @prefix",e):(this._prefix=e.value,this._readPrefixIRI)}_readPrefixIRI(e){if(e.type!=="IRI")return this._error(`Expected IRI to follow prefix "${this._prefix}:"`,e);let r=this._readEntity(e);return this._prefixes[this._prefix]=r.value,this._prefixCallback(this._prefix,r),this._readDeclarationPunctuation}_readBaseIRI(e){let r=e.type==="IRI"&&this._resolveIRI(e.value);return r?(this._setBase(r),this._readDeclarationPunctuation):this._error("Expected valid IRI to follow base declaration",e)}_readNamedGraphLabel(e){switch(e.type){case"IRI":case"blank":case"prefixed":return this._readSubject(e),this._readGraph;case"[":return this._readNamedGraphBlankLabel;default:return this._error("Invalid graph label",e)}}_readNamedGraphBlankLabel(e){return e.type!=="]"?this._error("Invalid graph label",e):(this._subject=this._factory.blankNode(),this._readGraph)}_readDeclarationPunctuation(e){return this._sparqlStyle?(this._sparqlStyle=!1,this._readInTopContext(e)):e.type!=="."?this._error("Expected declaration to end with a dot",e):this._readInTopContext}_readQuantifierList(e){let r;switch(e.type){case"IRI":case"prefixed":if((r=this._readEntity(e,!0))!==void 0)break;default:return this._error(`Unexpected ${e.type}`,e)}return this._explicitQuantifiers?(this._subject===null?this._emit(this._graph||this.DEFAULTGRAPH,this._predicate,this._subject=this._factory.blankNode(),this.QUANTIFIERS_GRAPH):this._emit(this._subject,this.RDF_REST,this._subject=this._factory.blankNode(),this.QUANTIFIERS_GRAPH),this._emit(this._subject,this.RDF_FIRST,r,this.QUANTIFIERS_GRAPH)):this._quantified[r.id]=this._factory[this._quantifier](this._factory.blankNode().value),this._readQuantifierPunctuation}_readQuantifierPunctuation(e){return e.type===","?this._readQuantifierList:(this._explicitQuantifiers&&(this._emit(this._subject,this.RDF_REST,this.RDF_NIL,this.QUANTIFIERS_GRAPH),this._subject=null),this._readCallback=this._getContextEndReader(),this._readCallback(e))}_getPathReader(e){return this._afterPath=e,this._readPath}_readPath(e){switch(e.type){case"!":return this._readForwardPath;case"^":return this._readBackwardPath;default:let r=this._contextStack,n=r.length&&r[r.length-1];if(n&&n.type==="item"){let i=this._subject;this._restoreContext("item",e),this._emit(this._subject,this.RDF_FIRST,i,this._graph)}return this._afterPath(e)}}_readForwardPath(e){let r,n,i=this._factory.blankNode();if((n=this._readEntity(e))!==void 0)return this._predicate===null?(r=this._subject,this._subject=i):(r=this._object,this._object=i),this._emit(r,n,i,this._graph),this._readPath}_readBackwardPath(e){let r=this._factory.blankNode(),n,i;if((n=this._readEntity(e))!==void 0)return this._predicate===null?(i=this._subject,this._subject=r):(i=this._object,this._object=r),this._emit(r,n,i,this._graph),this._readPath}_readRDFStarTailOrGraph(e){return e.type!==">>"?this._supportsQuads&&this._graph===null&&(this._graph=this._readEntity(e))!==void 0?this._readRDFStarTail:this._error(`Expected >> to follow "${this._object.id}"`,e):this._readRDFStarTail(e)}_readRDFStarTail(e){if(e.type!==">>")return this._error(`Expected >> but got ${e.type}`,e);let r=this._factory.quad(this._subject,this._predicate,this._object,this._graph||this.DEFAULTGRAPH);return this._restoreContext("<<",e),this._subject===null?(this._subject=r,this._readPredicate):(this._object=r,this._getContextEndReader())}_getContextEndReader(){let e=this._contextStack;if(!e.length)return this._readPunctuation;switch(e[e.length-1].type){case"blank":return this._readBlankNodeTail;case"list":return this._readListItem;case"formula":return this._readFormulaTail;case"<<":return this._readRDFStarTailOrGraph}}_emit(e,r,n,i){this._callback(null,this._factory.quad(e,r,n,i||this.DEFAULTGRAPH))}_error(e,r){let n=new Error(`${e} on line ${r.line}.`);n.context={token:r,line:r.line,previousToken:this._lexer.previousToken},this._callback(n),this._callback=Qr}_resolveIRI(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)?e:this._resolveRelativeIRI(e)}_resolveRelativeIRI(e){if(!e.length)return this._base;switch(e[0]){case"#":return this._base+e;case"?":return this._base.replace(/(?:\?.*)?$/,e);case"/":return(e[1]==="/"?this._baseScheme:this._baseRoot)+this._removeDotSegments(e);default:return/^[^/:]*:/.test(e)?null:this._removeDotSegments(this._basePath+e)}}_removeDotSegments(e){if(!/(^|\/)\.\.?($|[/#?])/.test(e))return e;let r=e.length,n="",i=-1,s=-1,o=0,a="/";for(;i<r;){switch(a){case":":if(s<0&&e[++i]==="/"&&e[++i]==="/")for(;(s=i+1)<r&&e[s]!=="/";)i=s;break;case"?":case"#":i=r;break;case"/":if(e[i+1]===".")switch(a=e[++i+1],a){case"/":n+=e.substring(o,i-1),o=i+1;break;case void 0:case"?":case"#":return n+e.substring(o,i)+e.substr(i+1);case".":if(a=e[++i+1],a===void 0||a==="/"||a==="?"||a==="#"){if(n+=e.substring(o,i-2),(o=n.lastIndexOf("/"))>=s&&(n=n.substr(0,o)),a!=="/")return`${n}/${e.substr(i+1)}`;o=i+1}}}a=e[++i]}return n+e.substring(o)}parse(e,r,n){let i,s,o;if(r&&(r.onQuad||r.onPrefix||r.onComment)?(i=r.onQuad,s=r.onPrefix,o=r.onComment):(i=r,s=n),this._readCallback=this._readInTopContext,this._sparqlStyle=!1,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix?this._blankNodePrefix.substr(2):`b${Ro++}_`,this._prefixCallback=s||Qr,this._inversePredicate=!1,this._quantified=Object.create(null),!i){let l=[],u;if(this._callback=(f,c)=>{f?u=f:c&&l.push(c)},this._lexer.tokenize(e).every(f=>this._readCallback=this._readCallback(f)),u)throw u;return l}let a=(l,u)=>{l!==null?(this._callback(l),this._callback=Qr):this._readCallback&&(this._readCallback=this._readCallback(u))};o&&(this._lexer.comments=!0,a=(l,u)=>{l!==null?(this._callback(l),this._callback=Qr):this._readCallback&&(u.type==="comment"?o(u.value):this._readCallback=this._readCallback(u))}),this._callback=i,this._lexer.tokenize(e,a)}};function Qr(){}function Io(t,e){t._factory=e,t.DEFAULTGRAPH=e.defaultGraph(),t.RDF_FIRST=e.namedNode(O.rdf.first),t.RDF_REST=e.namedNode(O.rdf.rest),t.RDF_NIL=e.namedNode(O.rdf.nil),t.N3_FORALL=e.namedNode(O.r.forAll),t.N3_FORSOME=e.namedNode(O.r.forSome),t.ABBREVIATIONS={a:e.namedNode(O.rdf.type),"=":e.namedNode(O.owl.sameAs),">":e.namedNode(O.log.implies),"<":e.namedNode(O.log.isImpliedBy)},t.QUANTIFIERS_GRAPH=e.namedNode("urn:n3:quantifiers")}Io(ze.prototype,X);var si={};Fn(si,{inDefaultGraph:()=>Ec,isBlankNode:()=>mc,isDefaultGraph:()=>st,isLiteral:()=>wc,isNamedNode:()=>gc,isQuad:()=>Sc,isVariable:()=>xc,prefix:()=>Rc,prefixes:()=>Ao});function gc(t){return!!t&&t.termType==="NamedNode"}function mc(t){return!!t&&t.termType==="BlankNode"}function wc(t){return!!t&&t.termType==="Literal"}function xc(t){return!!t&&t.termType==="Variable"}function Sc(t){return!!t&&t.termType==="Quad"}function st(t){return!!t&&t.termType==="DefaultGraph"}function Ec(t){return st(t.graph)}function Rc(t,e){return Ao({"":t.value||t},e)("")}function Ao(t,e){let r=Object.create(null);for(let i in t)n(i,t[i]);e=e||X;function n(i,s){if(typeof s=="string"){let o=Object.create(null);r[i]=a=>o[a]||(o[a]=e.namedNode(s+a))}else if(!(i in r))throw new Error(`Unknown prefix: ${i}`);return r[i]}return n}function Lt(t){return t.replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&")}var Ic=/^:?[^:?#]*(?:[?#]|$)|^file:|^[^:]*:\/*[^?#]+?\/(?:\.\.?(?:\/|$)|\/)/i,Ac=/^(?:(?:[^/?#]{3,}|\.?[^/?#.]\.?)(?:\/[^/?#]{3,}|\.?[^/?#.]\.?)*\/?)?(?:[?#]|$)/,To="./",Tc="../",oi="?",vo="#",ot=class t{constructor(e){this.base=e,this._baseLength=0,this._baseMatcher=null,this._pathReplacements=new Array(e.length+1)}static supports(e){return!Ic.test(e)}_getBaseMatcher(){if(this._baseMatcher)return this._baseMatcher;if(!t.supports(this.base))return this._baseMatcher=/.^/;let e=/^[^:]*:\/*/.exec(this.base)[0],r=["^",Lt(e)],n=[],i=[],s=/[^/?#]*([/?#])/y,o,a=0,l=0,u=s.lastIndex=e.length;for(;!a&&!l&&(o=s.exec(this.base));)o[1]===vo?l=s.lastIndex-1:(r.push(Lt(o[0]),"(?:"),n.push(")?"),o[1]!==oi?i.push(u=s.lastIndex):(a=u=s.lastIndex,l=this.base.indexOf(vo,a),this._pathReplacements[a]=oi));for(let f=0;f<i.length;f++)this._pathReplacements[i[f]]=Tc.repeat(i.length-f-1);return this._pathReplacements[i[i.length-1]]=To,this._baseLength=l>0?l:this.base.length,r.push(Lt(this.base.substring(u,this._baseLength)),a?"(?:#|$)":"(?:[?#]|$)"),this._baseMatcher=new RegExp([...r,...n].join(""))}toRelative(e){let r=this._getBaseMatcher().exec(e);if(!r)return e;let n=r[0].length;if(n===this._baseLength&&n===e.length)return"";let i=this._pathReplacements[n];if(i){let s=e.substring(n);return i!==oi&&!Ac.test(s)?e:i===To&&/^[^?#]/.test(s)?s:i+s}return e.substring(n-1)}};var hr=X.defaultGraph(),{rdf:vc,xsd:Ot}=O,No=/["\\\t\n\r\b\f\u0000-\u0019\ud800-\udbff]/,jo=/["\\\t\n\r\b\f\u0000-\u0019]|[\ud800-\udbff][\udc00-\udfff]/g,Nc={"\\":"\\\\",'"':'\\"'," ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"},at=class extends Z{equals(e){return e===this}},_e=class{constructor(e,r){if(this._prefixRegex=/$0^/,e&&typeof e.write!="function"&&(r=e,e=null),r=r||{},this._lists=r.lists,e)this._outputStream=e,this._endStream=r.end===void 0?!0:!!r.end;else{let n="";this._outputStream={write(i,s,o){n+=i,o&&o()},end:i=>{i&&i(null,n)}},this._endStream=!0}this._subject=null,/triple|quad/i.test(r.format)?(this._lineMode=!0,this._writeQuad=this._writeQuadLine):(this._lineMode=!1,this._graph=hr,this._prefixIRIs=Object.create(null),r.prefixes&&this.addPrefixes(r.prefixes),r.baseIRI&&(this._baseIri=new ot(r.baseIRI)))}get _inDefaultGraph(){return hr.equals(this._graph)}_write(e,r){this._outputStream.write(e,"utf8",r)}_writeQuad(e,r,n,i,s){try{i.equals(this._graph)||(this._write((this._subject===null?"":this._inDefaultGraph?`.
4
+ `:`
5
+ }
6
+ `)+(hr.equals(i)?"":`${this._encodeIriOrBlank(i)} {
7
+ `)),this._graph=i,this._subject=null),e.equals(this._subject)?r.equals(this._predicate)?this._write(`, ${this._encodeObject(n)}`,s):this._write(`;
8
+ ${this._encodePredicate(this._predicate=r)} ${this._encodeObject(n)}`,s):this._write(`${(this._subject===null?"":`.
9
+ `)+this._encodeSubject(this._subject=e)} ${this._encodePredicate(this._predicate=r)} ${this._encodeObject(n)}`,s)}catch(o){s&&s(o)}}_writeQuadLine(e,r,n,i,s){delete this._prefixMatch,this._write(this.quadToString(e,r,n,i),s)}quadToString(e,r,n,i){return`${this._encodeSubject(e)} ${this._encodeIriOrBlank(r)} ${this._encodeObject(n)}${i&&i.value?` ${this._encodeIriOrBlank(i)} .
10
+ `:` .
11
+ `}`}quadsToString(e){let r="";for(let n of e)r+=this.quadToString(n.subject,n.predicate,n.object,n.graph);return r}_encodeSubject(e){return e.termType==="Quad"?this._encodeQuad(e):this._encodeIriOrBlank(e)}_encodeIriOrBlank(e){if(e.termType!=="NamedNode")return this._lists&&e.value in this._lists&&(e=this.list(this._lists[e.value])),"id"in e?e.id:`_:${e.value}`;let r=e.value;this._baseIri&&(r=this._baseIri.toRelative(r)),No.test(r)&&(r=r.replace(jo,ko));let n=this._prefixRegex.exec(r);return n?n[1]?this._prefixIRIs[n[1]]+n[2]:r:`<${r}>`}_encodeLiteral(e){let r=e.value;if(No.test(r)&&(r=r.replace(jo,ko)),e.language)return`"${r}"@${e.language}`;if(this._lineMode){if(e.datatype.value===Ot.string)return`"${r}"`}else switch(e.datatype.value){case Ot.string:return`"${r}"`;case Ot.boolean:if(r==="true"||r==="false")return r;break;case Ot.integer:if(/^[+-]?\d+$/.test(r))return r;break;case Ot.decimal:if(/^[+-]?\d*\.\d+$/.test(r))return r;break;case Ot.double:if(/^[+-]?(?:\d+\.\d*|\.?\d+)[eE][+-]?\d+$/.test(r))return r;break}return`"${r}"^^${this._encodeIriOrBlank(e.datatype)}`}_encodePredicate(e){return e.value===vc.type?"a":this._encodeIriOrBlank(e)}_encodeObject(e){switch(e.termType){case"Quad":return this._encodeQuad(e);case"Literal":return this._encodeLiteral(e);default:return this._encodeIriOrBlank(e)}}_encodeQuad({subject:e,predicate:r,object:n,graph:i}){return`<<${this._encodeSubject(e)} ${this._encodePredicate(r)} ${this._encodeObject(n)}${st(i)?"":` ${this._encodeIriOrBlank(i)}`}>>`}_blockedWrite(){throw new Error("Cannot write because the writer has been closed.")}addQuad(e,r,n,i,s){n===void 0?this._writeQuad(e.subject,e.predicate,e.object,e.graph,r):typeof i=="function"?this._writeQuad(e,r,n,hr,i):this._writeQuad(e,r,n,i||hr,s)}addQuads(e){for(let r=0;r<e.length;r++)this.addQuad(e[r])}addPrefix(e,r,n){let i={};i[e]=r,this.addPrefixes(i,n)}addPrefixes(e,r){if(!this._prefixIRIs)return r&&r();let n=!1;for(let i in e){let s=e[i];typeof s!="string"&&(s=s.value),n=!0,this._subject!==null&&(this._write(this._inDefaultGraph?`.
12
+ `:`
13
+ }
14
+ `),this._subject=null,this._graph=""),this._prefixIRIs[s]=i+=":",this._write(`@prefix ${i} <${s}>.
15
+ `)}if(n){let i="",s="";for(let o in this._prefixIRIs)i+=i?`|${o}`:o,s+=(s?"|":"")+this._prefixIRIs[o];i=Lt(i,/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&"),this._prefixRegex=new RegExp(`^(?:${s})[^/]*$|^(${i})([_a-zA-Z0-9][\\-_a-zA-Z0-9]*)$`)}this._write(n?`
16
+ `:"",r)}blank(e,r){let n=e,i,s;switch(e===void 0?n=[]:e.termType?n=[{predicate:e,object:r}]:"length"in e||(n=[e]),s=n.length){case 0:return new at("[]");case 1:if(i=n[0],!(i.object instanceof at))return new at(`[ ${this._encodePredicate(i.predicate)} ${this._encodeObject(i.object)} ]`);default:let o="[";for(let a=0;a<s;a++)i=n[a],i.predicate.equals(e)?o+=`, ${this._encodeObject(i.object)}`:(o+=`${(a?`;
17
+ `:`
18
+ `)+this._encodePredicate(i.predicate)} ${this._encodeObject(i.object)}`,e=i.predicate);return new at(`${o}
19
+ ]`)}}list(e){let r=e&&e.length||0,n=new Array(r);for(let i=0;i<r;i++)n[i]=this._encodeObject(e[i]);return new at(`(${n.join(" ")})`)}end(e){this._subject!==null&&(this._write(this._inDefaultGraph?`.
20
+ `:`
21
+ }
22
+ `),this._subject=null),this._write=this._blockedWrite;let r=e&&((n,i)=>{r=null,e(n,i)});if(this._endStream)try{return this._outputStream.end(r)}catch{}r&&r()}};function ko(t){let e=Nc[t];return e===void 0&&(t.length===1?(e=t.charCodeAt(0).toString(16),e="\\u0000".substr(0,6-e.length)+e):(e=((t.charCodeAt(0)-55296)*1024+t.charCodeAt(1)+9216).toString(16),e="\\U00000000".substr(0,10-e.length)+e)),e}var Es=Br(Nn());var Ss=Symbol("iter");function Tr(t,e,r=4){if(r===0)return Object.assign(t,e);for(let n in e)t[n]=Tr(t[n]||Object.create(null),e[n],r-1);return t}function $u(t,e,r=4){let n=!1;for(let i in t)if(i in e){let s=r===0?null:$u(t[i],e[i],r-1);if(s!==!1)n=n||Object.create(null),n[i]=s;else if(r===3)return!1}return n}function qu(t,e,r=4){let n=!1;for(let i in t)if(!(i in e))n=n||Object.create(null),n[i]=r===0?null:Tr({},t[i],r-1);else if(r!==0){let s=qu(t[i],e[i],r-1);if(s!==!1)n=n||Object.create(null),n[i]=s;else if(r===3)return!1}return n}var vr=class{constructor(e={}){this._id=1,this._ids=Object.create(null),this._ids[""]=1,this._entities=Object.create(null),this._entities[1]="",this._blankNodeIndex=0,this._factory=e.factory||X}_termFromId(e){if(e[0]==="."){let r=this._entities,n=e.split(".");return this._factory.quad(this._termFromId(r[n[1]]),this._termFromId(r[n[2]]),this._termFromId(r[n[3]]),n[4]&&this._termFromId(r[n[4]]))}return qe(e,this._factory)}_termToNumericId(e){if(e.termType==="Quad"){let r=this._termToNumericId(e.subject),n=this._termToNumericId(e.predicate),i=this._termToNumericId(e.object),s;return r&&n&&i&&(st(e.graph)||(s=this._termToNumericId(e.graph)))&&this._ids[s?`.${r}.${n}.${i}.${s}`:`.${r}.${n}.${i}`]}return this._ids[Ne(e)]}_termToNewNumericId(e){let r=e&&e.termType==="Quad"?`.${this._termToNewNumericId(e.subject)}.${this._termToNewNumericId(e.predicate)}.${this._termToNewNumericId(e.object)}${st(e.graph)?"":`.${this._termToNewNumericId(e.graph)}`}`:Ne(e);return this._ids[r]||(this._ids[this._entities[++this._id]=r]=this._id)}createBlankNode(e){let r,n;if(e)for(r=e=`_:${e}`,n=1;this._ids[r];)r=e+n++;else do r=`_:b${this._blankNodeIndex++}`;while(this._ids[r]);return this._ids[r]=++this._id,this._entities[this._id]=r,this._factory.blankNode(r.substr(2))}},Ye=class t{constructor(e,r){this._size=0,this._graphs=Object.create(null),!r&&e&&!e[0]&&typeof e.match!="function"&&(r=e,e=null),r=r||{},this._factory=r.factory||X,this._entityIndex=r.entityIndex||new vr({factory:this._factory}),this._entities=this._entityIndex._entities,this._termFromId=this._entityIndex._termFromId.bind(this._entityIndex),this._termToNumericId=this._entityIndex._termToNumericId.bind(this._entityIndex),this._termToNewNumericId=this._entityIndex._termToNewNumericId.bind(this._entityIndex),e&&this.addAll(e)}get size(){let e=this._size;if(e!==null)return e;e=0;let r=this._graphs,n,i;for(let s in r)for(let o in n=r[s].subjects)for(let a in i=n[o])e+=Object.keys(i[a]).length;return this._size=e}_addToIndex(e,r,n,i){let s=e[r]||(e[r]={}),o=s[n]||(s[n]={}),a=i in o;return a||(o[i]=null),!a}_removeFromIndex(e,r,n,i){let s=e[r],o=s[n];delete o[i];for(let a in o)return;delete s[n];for(let a in s)return;delete e[r]}*_findInIndex(e,r,n,i,s,o,a,l){let u,f,c,d=this._entities,h=this._termFromId(d[l]),y={subject:null,predicate:null,object:null};r&&((u=e,e={})[r]=u[r]);for(let _ in e)if(f=e[_]){y[s]=this._termFromId(d[_]),n&&((u=f,f={})[n]=u[n]);for(let x in f)if(c=f[x]){y[o]=this._termFromId(d[x]);let b=i?i in c?[i]:[]:Object.keys(c);for(let g=0;g<b.length;g++)y[a]=this._termFromId(d[b[g]]),yield this._factory.quad(y.subject,y.predicate,y.object,h)}}}_loop(e,r){for(let n in e)r(n)}_loopByKey0(e,r,n){let i,s;if(i=e[r])for(s in i)n(s)}_loopByKey1(e,r,n){let i,s;for(i in e)s=e[i],s[r]&&n(i)}_loopBy2Keys(e,r,n,i){let s,o,a;if((s=e[r])&&(o=s[n]))for(a in o)i(a)}_countInIndex(e,r,n,i){let s=0,o,a,l;r&&((o=e,e={})[r]=o[r]);for(let u in e)if(a=e[u]){n&&((o=a,a={})[n]=o[n]);for(let f in a)(l=a[f])&&(i?i in l&&s++:s+=Object.keys(l).length)}return s}_getGraphs(e){return e=e===""?1:e&&(this._termToNumericId(e)||-1),typeof e!="number"?this._graphs:{[e]:this._graphs[e]}}_uniqueEntities(e){let r=Object.create(null);return n=>{n in r||(r[n]=!0,e(this._termFromId(this._entities[n],this._factory)))}}add(e){return this.addQuad(e),this}addQuad(e,r,n,i){r||(i=e.graph,n=e.object,r=e.predicate,e=e.subject),i=i?this._termToNewNumericId(i):1;let s=this._graphs[i];return s||(s=this._graphs[i]={subjects:{},predicates:{},objects:{}},Object.freeze(s)),e=this._termToNewNumericId(e),r=this._termToNewNumericId(r),n=this._termToNewNumericId(n),this._addToIndex(s.subjects,e,r,n)?(this._addToIndex(s.predicates,r,n,e),this._addToIndex(s.objects,n,e,r),this._size=null,!0):!1}addQuads(e){for(let r=0;r<e.length;r++)this.addQuad(e[r])}delete(e){return this.removeQuad(e),this}has(e,r,n,i){return e&&e.subject&&({subject:e,predicate:r,object:n,graph:i}=e),!this.readQuads(e,r,n,i).next().done}import(e){return e.on("data",r=>{this.addQuad(r)}),e}removeQuad(e,r,n,i){r||({subject:e,predicate:r,object:n,graph:i}=e),i=i?this._termToNumericId(i):1;let s=this._graphs,o,a,l;if(!(e=e&&this._termToNumericId(e))||!(r=r&&this._termToNumericId(r))||!(n=n&&this._termToNumericId(n))||!(o=s[i])||!(a=o.subjects[e])||!(l=a[r])||!(n in l))return!1;this._removeFromIndex(o.subjects,e,r,n),this._removeFromIndex(o.predicates,r,n,e),this._removeFromIndex(o.objects,n,e,r),this._size!==null&&this._size--;for(e in o.subjects)return!0;return delete s[i],!0}removeQuads(e){for(let r=0;r<e.length;r++)this.removeQuad(e[r])}remove(e){return e.on("data",r=>{this.removeQuad(r)}),e}removeMatches(e,r,n,i){let s=new Es.Readable({objectMode:!0}),o=this.readQuads(e,r,n,i);return s._read=a=>{for(;--a>=0;){let{done:l,value:u}=o.next();if(l){s.push(null);return}s.push(u)}},this.remove(s)}deleteGraph(e){return this.removeMatches(null,null,null,e)}getQuads(e,r,n,i){return[...this.readQuads(e,r,n,i)]}*readQuads(e,r,n,i){let s=this._getGraphs(i),o,a,l,u;if(!(e&&!(a=this._termToNumericId(e))||r&&!(l=this._termToNumericId(r))||n&&!(u=this._termToNumericId(n))))for(let f in s)(o=s[f])&&(a?u?yield*this._findInIndex(o.objects,u,a,l,"object","subject","predicate",f):yield*this._findInIndex(o.subjects,a,l,null,"subject","predicate","object",f):l?yield*this._findInIndex(o.predicates,l,u,null,"predicate","object","subject",f):u?yield*this._findInIndex(o.objects,u,null,null,"object","subject","predicate",f):yield*this._findInIndex(o.subjects,null,null,null,"subject","predicate","object",f))}match(e,r,n,i){return new Je(this,e,r,n,i,{entityIndex:this._entityIndex})}countQuads(e,r,n,i){let s=this._getGraphs(i),o=0,a,l,u,f;if(e&&!(l=this._termToNumericId(e))||r&&!(u=this._termToNumericId(r))||n&&!(f=this._termToNumericId(n)))return 0;for(let c in s)(a=s[c])&&(e?n?o+=this._countInIndex(a.objects,f,l,u):o+=this._countInIndex(a.subjects,l,u,f):r?o+=this._countInIndex(a.predicates,u,f,l):o+=this._countInIndex(a.objects,f,l,u));return o}forEach(e,r,n,i,s){this.some(o=>(e(o,this),!1),r,n,i,s)}every(e,r,n,i,s){return!this.some(o=>!e(o,this),r,n,i,s)}some(e,r,n,i,s){for(let o of this.readQuads(r,n,i,s))if(e(o,this))return!0;return!1}getSubjects(e,r,n){let i=[];return this.forSubjects(s=>{i.push(s)},e,r,n),i}forSubjects(e,r,n,i){let s=this._getGraphs(i),o,a,l;if(e=this._uniqueEntities(e),!(r&&!(a=this._termToNumericId(r))||n&&!(l=this._termToNumericId(n))))for(i in s)(o=s[i])&&(a?l?this._loopBy2Keys(o.predicates,a,l,e):this._loopByKey1(o.subjects,a,e):l?this._loopByKey0(o.objects,l,e):this._loop(o.subjects,e))}getPredicates(e,r,n){let i=[];return this.forPredicates(s=>{i.push(s)},e,r,n),i}forPredicates(e,r,n,i){let s=this._getGraphs(i),o,a,l;if(e=this._uniqueEntities(e),!(r&&!(a=this._termToNumericId(r))||n&&!(l=this._termToNumericId(n))))for(i in s)(o=s[i])&&(a?l?this._loopBy2Keys(o.objects,l,a,e):this._loopByKey0(o.subjects,a,e):l?this._loopByKey1(o.predicates,l,e):this._loop(o.predicates,e))}getObjects(e,r,n){let i=[];return this.forObjects(s=>{i.push(s)},e,r,n),i}forObjects(e,r,n,i){let s=this._getGraphs(i),o,a,l;if(e=this._uniqueEntities(e),!(r&&!(a=this._termToNumericId(r))||n&&!(l=this._termToNumericId(n))))for(i in s)(o=s[i])&&(a?l?this._loopBy2Keys(o.subjects,a,l,e):this._loopByKey1(o.objects,a,e):l?this._loopByKey0(o.predicates,l,e):this._loop(o.objects,e))}getGraphs(e,r,n){let i=[];return this.forGraphs(s=>{i.push(s)},e,r,n),i}forGraphs(e,r,n,i){for(let s in this._graphs)this.some(o=>(e(o.graph),!0),r,n,i,this._termFromId(this._entities[s]))}createBlankNode(e){return this._entityIndex.createBlankNode(e)}extractLists({remove:e=!1,ignoreErrors:r=!1}={}){let n={},i=r?(()=>!0):((a,l)=>{throw new Error(`${a.value} ${l}`)}),s=this.getQuads(null,O.rdf.rest,O.rdf.nil,null),o=e?[...s]:[];return s.forEach(a=>{let l=[],u=!1,f,c,d=a.graph,h=a.subject;for(;h&&!u;){let y=this.getQuads(null,null,h,null),_=this.getQuads(h,null,null,null),x,b=null,g=null,S=null;for(let m=0;m<_.length&&!u;m++)x=_[m],x.graph.equals(d)?f?u=i(h,"has non-list arcs out"):x.predicate.value===O.rdf.first?b?u=i(h,"has multiple rdf:first arcs"):o.push(b=x):x.predicate.value===O.rdf.rest?g?u=i(h,"has multiple rdf:rest arcs"):o.push(g=x):y.length?u=i(h,"can't be subject and object"):(f=x,c="subject"):u=i(h,"not confined to single graph");for(let m=0;m<y.length&&!u;++m)x=y[m],f?u=i(h,"can't have coreferences"):x.predicate.value===O.rdf.rest?S?u=i(h,"has incoming rdf:rest arcs"):S=x:(f=x,c="object");b?l.unshift(b.object):u=i(h,"has no list head"),h=S&&S.subject}u?e=!1:f&&(n[f[c].value]=l)}),e&&this.removeQuads(o),n}addAll(e){if(e instanceof Je&&(e=e.filtered),Array.isArray(e))this.addQuads(e);else if(e instanceof t&&e._entityIndex===this._entityIndex)e._size!==0&&(this._graphs=Tr(this._graphs,e._graphs),this._size=null);else for(let r of e)this.add(r);return this}contains(e){if(e instanceof Je&&(e=e.filtered),e===this)return!0;if(!(e instanceof t)||this._entityIndex!==e._entityIndex)return e.every(u=>this.has(u));let r=this._graphs,n=e._graphs,i,s,o,a,l;for(let u in n){if(!(i=r[u]))return!1;i=i.subjects;for(let f in s=n[u].subjects){if(!(o=i[f]))return!1;for(let c in a=s[f]){if(!(l=o[c]))return!1;for(let d in a[c])if(!(d in l))return!1}}}return!0}deleteMatches(e,r,n,i){for(let s of this.match(e,r,n,i))this.removeQuad(s);return this}difference(e){if(e&&e instanceof Je&&(e=e.filtered),e===this)return new t({entityIndex:this._entityIndex});if(e instanceof t&&e._entityIndex===this._entityIndex){let r=new t({entityIndex:this._entityIndex}),n=qu(this._graphs,e._graphs);return n&&(r._graphs=n,r._size=null),r}return this.filter(r=>!e.has(r))}equals(e){return e instanceof Je&&(e=e.filtered),e===this||this.size===e.size&&this.contains(e)}filter(e){let r=new t({entityIndex:this._entityIndex});for(let n of this)e(n,this)&&r.add(n);return r}intersection(e){if(e instanceof Je&&(e=e.filtered),e===this){let r=new t({entityIndex:this._entityIndex});return r._graphs=Tr(Object.create(null),this._graphs),r._size=this._size,r}else if(e instanceof t&&this._entityIndex===e._entityIndex){let r=new t({entityIndex:this._entityIndex}),n=$u(e._graphs,this._graphs);return n&&(r._graphs=n,r._size=null),r}return this.filter(r=>e.has(r))}map(e){let r=new t({entityIndex:this._entityIndex});for(let n of this)r.add(e(n,this));return r}reduce(e,r){let n=this.readQuads(),i=r===void 0?n.next().value:r;for(let s of n)i=e(i,s,this);return i}toArray(){return this.getQuads()}toCanonical(){throw new Error("not implemented")}toStream(){return this.match()}toString(){return new _e().quadsToString(this)}union(e){let r=new t({entityIndex:this._entityIndex});return r._graphs=Tr(Object.create(null),this._graphs),r._size=this._size,r.addAll(e),r}*[Symbol.iterator](){yield*this.readQuads()}};function Re(t,e,r=0){let n=e[r];if(n&&!(n in t))return!1;let i=!1;for(let s in n?{[n]:t[n]}:t){let o=r===2?null:Re(t[s],e,r+1);o!==!1&&(i=i||Object.create(null),i[s]=o)}return i}var Je=class t extends Es.Readable{constructor(e,r,n,i,s,o){super({objectMode:!0}),Object.assign(this,{n3Store:e,subject:r,predicate:n,object:i,graph:s,options:o})}get filtered(){if(!this._filtered){let{n3Store:e,graph:r,object:n,predicate:i,subject:s}=this,o=this._filtered=new Ye({factory:e._factory,entityIndex:this.options.entityIndex}),a,l,u;if(s&&!(a=o._termToNumericId(s))||i&&!(l=o._termToNumericId(i))||n&&!(u=o._termToNumericId(n)))return o;let f=e._getGraphs(r);for(let c in f){let d,h,y,_;(_=f[c])&&(!a&&l?(h=Re(_.predicates,[l,u,a]))&&(d=Re(_.subjects,[a,l,u]),y=Re(_.objects,[u,a,l])):u?(y=Re(_.objects,[u,a,l]))&&(d=Re(_.subjects,[a,l,u]),h=Re(_.predicates,[l,u,a])):(d=Re(_.subjects,[a,l,u]))&&(h=Re(_.predicates,[l,u,a]),y=Re(_.objects,[u,a,l])),d&&(o._graphs[c]={subjects:d,predicates:h,objects:y}))}o._size=null}return this._filtered}get size(){return this.filtered.size}_read(e){e>0&&!this[Ss]&&(this[Ss]=this[Symbol.iterator]());let r=this[Ss];for(;--e>=0;){let{done:n,value:i}=r.next();if(n){this.push(null);return}this.push(i)}}addAll(e){return this.filtered.addAll(e)}contains(e){return this.filtered.contains(e)}deleteMatches(e,r,n,i){return this.filtered.deleteMatches(e,r,n,i)}difference(e){return this.filtered.difference(e)}equals(e){return this.filtered.equals(e)}every(e,r,n,i,s){return this.filtered.every(e,r,n,i,s)}filter(e){return this.filtered.filter(e)}forEach(e,r,n,i,s){return this.filtered.forEach(e,r,n,i,s)}import(e){return this.filtered.import(e)}intersection(e){return this.filtered.intersection(e)}map(e){return this.filtered.map(e)}some(e,r,n,i,s){return this.filtered.some(e,r,n,i,s)}toCanonical(){return this.filtered.toCanonical()}toStream(){return this._filtered?this._filtered.toStream():this.n3Store.match(this.subject,this.predicate,this.object,this.graph)}union(e){return this._filtered?this._filtered.union(e):this.n3Store.match(this.subject,this.predicate,this.object,this.graph).addAll(e)}toArray(){return this._filtered?this._filtered.toArray():this.n3Store.getQuads(this.subject,this.predicate,this.object,this.graph)}reduce(e,r){return this.filtered.reduce(e,r)}toString(){return new _e().quadsToString(this)}add(e){return this.filtered.add(e)}delete(e){return this.filtered.delete(e)}has(e){return this.filtered.has(e)}match(e,r,n,i){return new t(this.filtered,e,r,n,i,this.options)}*[Symbol.iterator](){yield*this._filtered||this.n3Store.readQuads(this.subject,this.predicate,this.object,this.graph)}};var Nr=class{dataset(e){return new Ye(e)}};function Gu(t){let e=[];for(let{subject:r,object:n}of t.match(null,X.namedNode("http://www.w3.org/2000/10/swap/log#implies"),null,X.defaultGraph())){let i=[...t.match(null,null,null,r)],s=[...t.match(null,null,null,n)];e.push({premise:i,conclusion:s})}return e}var jr=class{constructor(e){this._store=e}_add(e,r,n,i,s){this._store._addToIndex(i.subjects,e,r,n)&&(this._store._addToIndex(i.predicates,r,n,e),this._store._addToIndex(i.objects,n,e,r),s())}_evaluatePremise(e,r,n,i=0){let s,o,a,l,u,[f,c,d]=e.premise[i].value,h=r[e.premise[i].content],y=!(a=f.value);for(a in y?h:{[a]:h[a]})if(l=h[a]){y&&(f.value=Number(a)),s=!(a=c.value);for(a in s?l:{[a]:l[a]})if(u=l[a]){s&&(c.value=Number(a)),o=!(a=d.value);for(a in o?u:{[a]:u[a]})o&&(d.value=Number(a)),i===e.premise.length-1?e.conclusion.forEach(_=>{this._add(_.subject.value,_.predicate.value,_.object.value,r,()=>{n(_)})}):this._evaluatePremise(e,r,n,i+1);o&&(d.value=null)}s&&(c.value=null)}y&&(f.value=null)}_evaluateRules(e,r,n){for(let i=0;i<e.length;i++)this._evaluatePremise(e[i],r,n)}_reasonGraphNaive(e,r){let n=[];function i(a){a.next&&a.next.forEach(l=>{n.push([a.subject.value,a.predicate.value,a.object.value,l])})}let s=a=>{a.forEach(l=>{this._add(l.subject.value,l.predicate.value,l.object.value,r,()=>{i(l)})})};this._evaluateRules(e,r,i);let o;for(;(o=n.pop())!==void 0;){let[a,l,u,f]=o,c=f.basePremise.subject.value;c||(f.basePremise.subject.value=a);let d=f.basePremise.predicate.value;d||(f.basePremise.predicate.value=l);let h=f.basePremise.object.value;h||(f.basePremise.object.value=u),f.premise.length===0?s(f.conclusion):this._evaluatePremise(f,r,i),c||(f.basePremise.subject.value=null),d||(f.basePremise.predicate.value=null),h||(f.basePremise.object.value=null)}}_createRule({premise:e,conclusion:r}){let n={},i=o=>o.termType==="Variable"?n[o.value]=n[o.value]||{}:{value:this._store._termToNewNumericId(o)},s=o=>({subject:i(o.subject),predicate:i(o.predicate),object:i(o.object)});return{premise:e.map(o=>s(o)),conclusion:r.map(o=>s(o)),variables:Object.values(n)}}reason(e){Array.isArray(e)||(e=Gu(e)),e=e.map(n=>this._createRule(n));for(let n of e)for(let i of e)for(let s=0;s<i.premise.length;s++){let o=i.premise[s];for(let a of n.conclusion){if(Rs(o.subject,a.subject)&&Rs(o.predicate,a.predicate)&&Rs(o.object,a.object)){let l=new Set,u=[];o.subject.value=o.subject.value||1,o.object.value=o.object.value||1,o.predicate.value=o.predicate.value||1;for(let f=0;f<i.premise.length;f++)f!==s&&u.push(Wu(i.premise[f],l));(a.next=a.next||[]).push({premise:u,conclusion:i.conclusion,basePremise:o})}i.variables.forEach(l=>{l.value=null})}}for(let n of e){let i=new Set;n.premise=n.premise.map(s=>Wu(s,i))}let r=this._store._getGraphs();for(let n in r)this._reasonGraphNaive(e,r[n]);this._store._size=null}};function Wu({subject:t,predicate:e,object:r},n){let i=t.value||n.has(t)||(n.add(t),!1),s=e.value||n.has(e)||(n.add(e),!1),o=r.value||n.has(r)||(n.add(r),!1);return!i&&s?{content:"predicates",value:[e,r,t]}:o?{content:"objects",value:[r,t,e]}:{content:"subjects",value:[t,e,r]}}function Rs(t,e){return t.value===null&&(t.value=e.value),t.value===e.value}var zu=Br(Nn());var kr=class extends zu.Transform{constructor(e){super({decodeStrings:!0}),this._readableState.objectMode=!0;let r=new ze(e),n,i,s={onQuad:(o,a)=>{o&&this.emit("error",o)||a&&this.push(a)},onPrefix:(o,a)=>{this.emit("prefix",o,a)}};e&&e.comments&&(s.onComment=o=>{this.emit("comment",o)}),r.parse({on:(o,a)=>{switch(o){case"data":n=a;break;case"end":i=a;break}}},s),this._transform=(o,a,l)=>{n(o),l()},this._flush=o=>{i(),o()}}import(e){return e.on("data",r=>{this.write(r)}),e.on("end",()=>{this.end()}),e.on("error",r=>{this.emit("error",r)}),this}};var Hu=Br(Nn());var Pr=class extends Hu.Transform{constructor(e){super({encoding:"utf8",writableObjectMode:!0});let r=this._writer=new _e({write:(n,i,s)=>{this.push(n),s&&s()},end:n=>{this.push(null),n&&n()}},e);this._transform=(n,i,s)=>{r.addQuad(n,s)},this._flush=n=>{r.end(n)}}import(e){return e.on("data",r=>{this.write(r)}),e.on("end",()=>{this.end()}),e.on("error",r=>{this.emit("error",r)}),e.on("prefix",(r,n)=>{this._writer.addPrefix(r,n)}),this}};var jn={Lexer:nt,Parser:ze,Writer:_e,Store:Ye,StoreFactory:Nr,EntityIndex:vr,StreamParser:kr,StreamWriter:Pr,Util:si,Reasoner:jr,BaseIRI:ot,DataFactory:X,Term:Z,NamedNode:kt,Literal:We,BlankNode:fr,Variable:cr,DefaultGraph:dr,Quad:Ge,Triple:Ge,termFromId:qe,termToId:Ne};var nb=(t,e,r)=>{let n=new jn.Parser({blankNodePrefix:"",format:r}),i=Object.create(null);return{quads:n.parse(t,null,(o,a)=>{i[o]=a.id}),prefixes:i}},ib=t=>new Promise((e,r)=>{let n=new jn.Writer({format:t.type,prefixes:{...t.prefixes}}),i=t.prefixes.xsd,{quad:s,namedNode:o,literal:a,blankNode:l}=jn.DataFactory,u=(b,g)=>{let S=g.a;if(Array.isArray(S)||(S=[S]),S?.length)for(let m of S)m=t.fullURI(m),n.addQuad(s(o(b),o(Hn),o(m)))},f=(b,g)=>{if(!g)return;let S=c(g);for(let m of S){Array.isArray(m.object)||(m.object=[m.object]);for(let I of m.object)n.addQuad(s(o(b),m.predicate,I))}},c=b=>{let g=[];return Object.entries(b).forEach(S=>{let m=S[0],I=S[1],Ae=t.fullURI(m),C={predicate:o(Ae)};I instanceof At?C.object=y(I):Array.isArray(I)?C.object=x(I):I instanceof It?C.object=o(I.id):I instanceof et?C.object=_(I):h(I)?C.object=d(I):console.log("weird object",I,m),g.push(C)}),g},d=b=>{let g=t.getType(b)||null;if(g)g==i+t.context.separator+"string"||g==i+t.context.separator+"number"?g=null:g=t.fullURI(g),g=o(g);else{let S=b?.language;S&&(g=S)}return b instanceof String?b=""+b:b instanceof Number&&(b=+b),a(b,g)},h=b=>b instanceof String||b instanceof Number||typeof b=="boolean"||typeof b=="string"||typeof b=="number",y=b=>{let g=[];for(let S of b)h(S)?g.push(d(S)):S.id?g.push(o(S.id)):g.push(_(S));return n.list(g)},_=b=>n.blank(c(b)),x=(b,g)=>{let S=[];for(let m of g)h(m)?S.push(d(m)):m instanceof It?S.push(o(m.id)):m instanceof et?S.push(_(m)):m instanceof At&&S.push(y(m));return S};Object.entries(t.subjects).forEach(([b,g])=>{b=t.shortURI(b,":"),u(b,g),f(b,g)}),n.end((b,g)=>{g?e(g):r(b)})});var Qu={context:zn,...Is};globalThis.oldm=Qu;var kn=Qu;function Pn(t){t=Object.assign({contentType:"text/turtle",prefixes:{ldp:"http://www.w3.org/ns/ldp#",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",dct:"http://purl.org/dc/terms/",stat:"http://www.w3.org/ns/posix/stat#",turtle:"http://www.w3.org/ns/iana/media-types/text/turtle#",schem:"https://schema.org/",solid:"http://www.w3.org/ns/solid/terms#",acl:"http://www.w3.org/ns/auth/acl#",pims:"http://www.w3.org/ns/pim/space#",vcard:"http://www.w3.org/2006/vcard/ns#",foaf:"http://xmlns.com/foaf/0.1/"},parser:kn.n3Parser,writer:kn.n3Writer},t),t.prefixes.ldp||(t.prefixes.ldp="http://www.w3.org/ns/ldp#");let e=kn.context(t);return async function(n,i){if(n.headers.get("Accept")||(n=n.with({headers:{Accept:t.accept??t.contentType}})),n.method!=="GET"&&n.method!=="HEAD"&&n.data&&typeof n.data=="object"&&!(n.data instanceof ReadableStream)){let o=n.headers.get("Content-Type");(!o||isPlainText(o))&&(n=n.with({headers:{"Content-Type":t.contentType}})),isLinkedData(n.headers.get("Content-Type"))&&(n=n.with({body:await e.writer(n.data)}))}let s=await i(n)}}globalThis.oldmmw=Pn;var Ku=Pn;function Ie(t){return[String,Boolean,Number,BigInt].includes(t?.constructor)}function As(t){let e=[];if(t instanceof Function)e.push(t);else for(let[r,n]of Object.entries(t))n instanceof Function?e.push(i=>({[r]:n(i,r,"select")})):Ie(n)?e.push(()=>({[r]:n})):e.push(i=>({[r]:Or(i[r]).select(n)}));return e.length==1?e[0]:r=>{let n={};for(let i of e)Object.assign(n,i(r));return n}}function Ts(t){let e=[];if(Array.isArray(t))e.push(lb(...t));else if(t instanceof RegExp)e.push(r=>t.test(r));else if(t instanceof Function)e.push(r=>t(r));else if(Ie(t))e.push(r=>Array.isArray(r)?r.filter(n=>t==n).length>0:t==r);else{let r={};for(let[i,s]of Object.entries(t))r[i]=Ts(s);let n=i=>{if(Array.isArray(i))return i.filter(s=>n(s)).length>0;if(Ie(i))return!1;for(let s in r){let o=r[s];if(!o(i?.[s]))return!1}return!0};e.push(n)}return e.length==1?e[0]:r=>{for(let n of e)if(!n(r))return!1;return!0}}var sb=Symbol("asc"),ob=Symbol("desc");function Vu(t){let e=Object.entries(t),r=[];for(let[n,i]of e)if(i instanceof Function)r.push(i);else if(i===sb)r.push((s,o)=>s[n]>o[n]?1:s[n]<o[n]?-1:0);else if(i===ob)r.push((s,o)=>s[n]<o[n]?1:s[n]>o[n]?-1:0);else{if(Ie(i))throw new Error("Unknown sort order",i);{let s=Vu(i);r.push((o,a)=>s(o[n],a[n]))}}return r.length==1?r[0]:(n,i)=>{for(let s of r){let o=s(n,i);if(o!==0)return o}return 0}}function Ju(t){let e=[];if(t instanceof Function)e.push(t);else for(let[r,n]of Object.entries(t))n instanceof Function?e.push((i,s,o,a)=>(Ie(i)&&(i={}),s.reduce?i[r]=s.reduce(n,i[r]||[]):i[r]=n(i[r]||[],s,o,a),i)):Ie(n)?e.push(i=>(Ie(i)&&(i={}),i[r]=n,i)):e.push((i,s)=>(Ie(i)&&(i={}),i[r]=Or(s[r]).reduce(n,[]),i));return e.length==1?e[0]:(r,n,i,s)=>{let o={};for(let a of e)Object.assign(o,a(r,n,i,s));return o}}function ab(t,e){let r={};for(let n of t){let i=e(n);Array.isArray(i)||(i=[i]);for(let s of i){if(typeof s!="string"&&!(s instanceof String)){console.warn("JAQT: groupBy(selector) can only handle string values, got:",s);continue}r[s]||(r[s]=[]),r[s].push(n)}}return r}function Yu(t,e){let r=e.shift(),n=ab(t,r);if(e.length)for(let i in n)n[i]=Yu(n[i],e);return n}function lb(...t){let e=t.map(r=>Ts(r));return r=>e.some(n=>n(r))}var ub={apply(t,e,r){let n=t.apply(e,r);return typeof n=="object"?new Proxy(n,Fe):n}},Fe={get(t,e){let r=null;if(typeof e=="symbol"&&(r=t[e]),Array.isArray(t))switch(e){case"where":r=function(n){let i=Ts(n);return new Proxy(t.filter(s=>i(s)),Fe)};break;case"select":r=function(n){let i=As(n);return new Proxy(t.map(i),Fe)};break;case"reduce":r=function(n,i=[]){let s=Ju(n),o=t.reduce(s,i);return Array.isArray(o)?new Proxy(o,Fe):Ie(o)?o:new Proxy(o,Lr)};break;case"orderBy":r=function(n){let i=Vu(n);return new Proxy(t.toSorted(i),Fe)};break;case"groupBy":r=function(...n){let i=Yu(t,n);return new Proxy(i,Lr)};break}return!r&&t&&typeof t=="object"&&e==="select"&&(r=function(n){let i=As(n);return new Proxy(i(t),Fe)}),!r&&t&&typeof t[e]=="function"&&(r=new Proxy(t[e],ub)),r||(r=t[e]),r}},Lr={get(t,e){let r=null;switch(e){case"select":r=function(n){let i=As(n),s={};for(let o in t)Array.isArray(t[o])?s[o]=new Proxy(t[o].map(i),Fe):s[o]=new Proxy(t[o],Lr);return s};break;case"reduce":r=function(n,i=[]){let s=Ju(n),o={};for(let a in t)if(Array.isArray(t[a])){let l=t[a].reduce(s,i);Array.isArray(l)?o[a]=new Proxy(l,Fe):Ie(l)?o[a]=l:o[a]=new Proxy(l,Lr)}else o[a]=new Proxy(t[a],Lr);return o};break;default:Array.isArray(t[e])?r=Or(t[e]):r=t[e];break}return r}},Ln={get(t,e){let r=null;switch(e){case"where":r=function(){return new Proxy(new Jt,Ln)};break;case"reduce":case"select":r=function(){return null};break;case"orderBy":r=function(){return new Proxy(new Jt,Ln)};break;case"groupBy":r=function(){return new Proxy(new Jt,Ln)};break}return!r&&typeof t?.[e]=="function"&&(r=t[e]),r}},Jt=class{toJSON(){return null}};function Or(t){return!t||typeof t!="object"?new Proxy(new Jt,Ln):new Proxy(t,Fe)}function vs(t){return(e,r)=>{if(t?.length>0){let n=t.slice(),i=n.shift();for(;i;){if(Array.isArray(e)&&parseInt(i)!=i)return n.unshift(i),e.map(vs(n));typeof e?.[i]<"u"?e=e[i]:e=null,i=n.shift()}return e}else return r?typeof e?.[r]<"u"?e[r]:null:e}}var Zu=t=>(t||(t=[]),{get(e,r){if(r=="constructor"||typeof r=="symbol")return e[r];let n=t.concat([r]);return new Proxy(vs(n),Zu(n))},apply(e,r,n){let i=e(...n);return Array.isArray(i)&&(i=i.flat(1/0)),i}}),Wm=new Proxy(vs(),Zu());var Yt=class extends Zt{#e;#r;constructor(e,r="/",n={}){this.#e=le(e).with(Vs.oidcmw(n)).with(Ku(n)),this.#r=new V(r)}get name(){return"SolidAdapter"}async list(e){let r=["text/turtle"],n=await this.read(e);if(n.data)Or(n.data).where({a:"ldp$Resource"}).select({filename:i=>jsfs.path.filename(metro.url(i.id).pathname),path:i=>metro.url(i.id).pathname,type:i=>i.a.includes("ldp$Container")?"folder":"file"});else throw new Error(e+" could not be parsed",{cause:n})}};var nw=Yt;globalThis.SolidAdapter=Yt;})();
23
+ /*! Bundled license information:
24
+
25
+ ieee754/index.js:
26
+ (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
27
+
28
+ buffer/index.js:
29
+ (*!
30
+ * The buffer module from node.js, for the browser.
31
+ *
32
+ * @author Feross Aboukhadijeh <https://feross.org>
33
+ * @license MIT
34
+ *)
35
+
36
+ safe-buffer/index.js:
37
+ (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
38
+ */
2
39
  //# sourceMappingURL=browser.min.js.map