prez-lib 4.0.0 → 4.0.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,29 +1,29 @@
1
- (function(z,Te){typeof exports=="object"&&typeof module<"u"?Te(exports):typeof define=="function"&&define.amd?define(["exports"],Te):(z=typeof globalThis<"u"?globalThis:z||self,Te(z["prez-lib"]={}))})(this,function(z){"use strict";var Tf=Object.defineProperty;var vf=(z,Te,it)=>Te in z?Tf(z,Te,{enumerable:!0,configurable:!0,writable:!0,value:it}):z[Te]=it;var nt=(z,Te,it)=>vf(z,typeof Te!="symbol"?Te+"":Te,it);function Te(t){return t.value!==void 0}function it(t){const e={value:typeof t=="string"?t:t.value,termType:"NamedNode",equals:r=>!!r&&e.termType===r.termType&&e.value===r.value};return typeof t!="string"&&Object.assign(e,t),e}function Ar(t){const e={value:typeof t=="string"?t:t.value,termType:"Literal",equals:r=>r&&e.termType===r.termType&&e.value===r.value?e.language!==r.language?!1:e.datatype===r.datatype:!1};return typeof t!="string"&&Object.assign(e,t),e}function Bn(t){const e={value:typeof t=="string"?t:t.value,properties:{},termType:"BlankNode",equals:r=>!!r&&e.termType===r.termType&&e.value===r.value&&e.properties===r.properties};return typeof t!="string"&&Object.assign(e,t),e}var ao=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function lo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Fe={},Yt={};Yt.byteLength=co,Yt.toByteArray=po,Yt.fromByteArray=yo;for(var ke=[],Pe=[],uo=typeof Uint8Array<"u"?Uint8Array:Array,Tr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",wt=0,fo=Tr.length;wt<fo;++wt)ke[wt]=Tr[wt],Pe[Tr.charCodeAt(wt)]=wt;Pe[45]=62,Pe[95]=63;function Fn(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 co(t){var e=Fn(t),r=e[0],n=e[1];return(r+n)*3/4-n}function ho(t,e,r){return(e+r)*3/4-r}function po(t){var e,r=Fn(t),n=r[0],i=r[1],a=new uo(ho(t,n,i)),l=0,u=i>0?n-4:n,p;for(p=0;p<u;p+=4)e=Pe[t.charCodeAt(p)]<<18|Pe[t.charCodeAt(p+1)]<<12|Pe[t.charCodeAt(p+2)]<<6|Pe[t.charCodeAt(p+3)],a[l++]=e>>16&255,a[l++]=e>>8&255,a[l++]=e&255;return i===2&&(e=Pe[t.charCodeAt(p)]<<2|Pe[t.charCodeAt(p+1)]>>4,a[l++]=e&255),i===1&&(e=Pe[t.charCodeAt(p)]<<10|Pe[t.charCodeAt(p+1)]<<4|Pe[t.charCodeAt(p+2)]>>2,a[l++]=e>>8&255,a[l++]=e&255),a}function _o(t){return ke[t>>18&63]+ke[t>>12&63]+ke[t>>6&63]+ke[t&63]}function bo(t,e,r){for(var n,i=[],a=e;a<r;a+=3)n=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(t[a+2]&255),i.push(_o(n));return i.join("")}function yo(t){for(var e,r=t.length,n=r%3,i=[],a=16383,l=0,u=r-n;l<u;l+=a)i.push(bo(t,l,l+a>u?u:l+a));return n===1?(e=t[r-1],i.push(ke[e>>2]+ke[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(ke[e>>10]+ke[e>>4&63]+ke[e<<2&63]+"=")),i.join("")}var vr={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */vr.read=function(t,e,r,n,i){var a,l,u=i*8-n-1,p=(1<<u)-1,_=p>>1,y=-7,E=r?i-1:0,w=r?-1:1,m=t[e+E];for(E+=w,a=m&(1<<-y)-1,m>>=-y,y+=u;y>0;a=a*256+t[e+E],E+=w,y-=8);for(l=a&(1<<-y)-1,a>>=-y,y+=n;y>0;l=l*256+t[e+E],E+=w,y-=8);if(a===0)a=1-_;else{if(a===p)return l?NaN:(m?-1:1)*(1/0);l=l+Math.pow(2,n),a=a-_}return(m?-1:1)*l*Math.pow(2,a-n)},vr.write=function(t,e,r,n,i,a){var l,u,p,_=a*8-i-1,y=(1<<_)-1,E=y>>1,w=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=n?0:a-1,I=n?1:-1,R=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,l=y):(l=Math.floor(Math.log(e)/Math.LN2),e*(p=Math.pow(2,-l))<1&&(l--,p*=2),l+E>=1?e+=w/p:e+=w*Math.pow(2,1-E),e*p>=2&&(l++,p/=2),l+E>=y?(u=0,l=y):l+E>=1?(u=(e*p-1)*Math.pow(2,i),l=l+E):(u=e*Math.pow(2,E-1)*Math.pow(2,i),l=0));i>=8;t[r+m]=u&255,m+=I,u/=256,i-=8);for(l=l<<i|u,_+=i;_>0;t[r+m]=l&255,m+=I,l/=256,_-=8);t[r+m-I]|=R*128};/*!
1
+ (function(z,Ae){typeof exports=="object"&&typeof module<"u"?Ae(exports):typeof define=="function"&&define.amd?define(["exports"],Ae):(z=typeof globalThis<"u"?globalThis:z||self,Ae(z["prez-lib"]={}))})(this,function(z){"use strict";var Hu=Object.defineProperty;var Qu=(z,Ae,it)=>Ae in z?Hu(z,Ae,{enumerable:!0,configurable:!0,writable:!0,value:it}):z[Ae]=it;var nt=(z,Ae,it)=>Qu(z,typeof Ae!="symbol"?Ae+"":Ae,it);function Ae(t){return t.value!==void 0}function it(t){const e={value:typeof t=="string"?t:t.value,termType:"NamedNode",equals:r=>!!r&&e.termType===r.termType&&e.value===r.value};return typeof t!="string"&&Object.assign(e,t),e}function Ir(t){const e={value:typeof t=="string"?t:t.value,termType:"Literal",equals:r=>r&&e.termType===r.termType&&e.value===r.value?e.language!==r.language?!1:e.datatype===r.datatype:!1};return typeof t!="string"&&Object.assign(e,t),e}function vn(t){const e={value:typeof t=="string"?t:t.value,properties:{},termType:"BlankNode",equals:r=>!!r&&e.termType===r.termType&&e.value===r.value&&e.properties===r.properties};return typeof t!="string"&&Object.assign(e,t),e}var Qs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Fe={},Kt={};Kt.byteLength=Xs,Kt.toByteArray=Js,Kt.fromByteArray=ro;for(var ke=[],ve=[],Ks=typeof Uint8Array<"u"?Uint8Array:Array,Rr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",gt=0,Ys=Rr.length;gt<Ys;++gt)ke[gt]=Rr[gt],ve[Rr.charCodeAt(gt)]=gt;ve[45]=62,ve[95]=63;function Nn(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 Xs(t){var e=Nn(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Zs(t,e,r){return(e+r)*3/4-r}function Js(t){var e,r=Nn(t),n=r[0],i=r[1],a=new Ks(Zs(t,n,i)),l=0,u=i>0?n-4:n,p;for(p=0;p<u;p+=4)e=ve[t.charCodeAt(p)]<<18|ve[t.charCodeAt(p+1)]<<12|ve[t.charCodeAt(p+2)]<<6|ve[t.charCodeAt(p+3)],a[l++]=e>>16&255,a[l++]=e>>8&255,a[l++]=e&255;return i===2&&(e=ve[t.charCodeAt(p)]<<2|ve[t.charCodeAt(p+1)]>>4,a[l++]=e&255),i===1&&(e=ve[t.charCodeAt(p)]<<10|ve[t.charCodeAt(p+1)]<<4|ve[t.charCodeAt(p+2)]>>2,a[l++]=e>>8&255,a[l++]=e&255),a}function eo(t){return ke[t>>18&63]+ke[t>>12&63]+ke[t>>6&63]+ke[t&63]}function to(t,e,r){for(var n,i=[],a=e;a<r;a+=3)n=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(t[a+2]&255),i.push(eo(n));return i.join("")}function ro(t){for(var e,r=t.length,n=r%3,i=[],a=16383,l=0,u=r-n;l<u;l+=a)i.push(to(t,l,l+a>u?u:l+a));return n===1?(e=t[r-1],i.push(ke[e>>2]+ke[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(ke[e>>10]+ke[e>>4&63]+ke[e<<2&63]+"=")),i.join("")}var Ar={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Ar.read=function(t,e,r,n,i){var a,l,u=i*8-n-1,p=(1<<u)-1,_=p>>1,y=-7,x=r?i-1:0,I=r?-1:1,S=t[e+x];for(x+=I,a=S&(1<<-y)-1,S>>=-y,y+=u;y>0;a=a*256+t[e+x],x+=I,y-=8);for(l=a&(1<<-y)-1,a>>=-y,y+=n;y>0;l=l*256+t[e+x],x+=I,y-=8);if(a===0)a=1-_;else{if(a===p)return l?NaN:(S?-1:1)*(1/0);l=l+Math.pow(2,n),a=a-_}return(S?-1:1)*l*Math.pow(2,a-n)},Ar.write=function(t,e,r,n,i,a){var l,u,p,_=a*8-i-1,y=(1<<_)-1,x=y>>1,I=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=n?0:a-1,R=n?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,l=y):(l=Math.floor(Math.log(e)/Math.LN2),e*(p=Math.pow(2,-l))<1&&(l--,p*=2),l+x>=1?e+=I/p:e+=I*Math.pow(2,1-x),e*p>=2&&(l++,p/=2),l+x>=y?(u=0,l=y):l+x>=1?(u=(e*p-1)*Math.pow(2,i),l=l+x):(u=e*Math.pow(2,x-1)*Math.pow(2,i),l=0));i>=8;t[r+S]=u&255,S+=R,u/=256,i-=8);for(l=l<<i|u,_+=i;_>0;t[r+S]=l&255,S+=R,l/=256,_-=8);t[r+S-R]|=m*128};/*!
2
2
  * The buffer module from node.js, for the browser.
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
5
5
  * @license MIT
6
- */(function(t){const e=Yt,r=vr,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=u,t.SlowBuffer=O,t.INSPECT_MAX_BYTES=50;const i=2147483647;t.kMaxLength=i,u.TYPED_ARRAY_SUPPORT=a(),!u.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 a(){try{const f=new Uint8Array(1),s={foo:function(){return 42}};return Object.setPrototypeOf(s,Uint8Array.prototype),Object.setPrototypeOf(f,s),f.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function l(f){if(f>i)throw new RangeError('The value "'+f+'" is invalid for option "size"');const s=new Uint8Array(f);return Object.setPrototypeOf(s,u.prototype),s}function u(f,s,o){if(typeof f=="number"){if(typeof s=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return E(f)}return p(f,s,o)}u.poolSize=8192;function p(f,s,o){if(typeof f=="string")return w(f,s);if(ArrayBuffer.isView(f))return I(f);if(f==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof f);if(C(f,ArrayBuffer)||f&&C(f.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(C(f,SharedArrayBuffer)||f&&C(f.buffer,SharedArrayBuffer)))return R(f,s,o);if(typeof f=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const d=f.valueOf&&f.valueOf();if(d!=null&&d!==f)return u.from(d,s,o);const b=v(f);if(b)return b;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof f[Symbol.toPrimitive]=="function")return u.from(f[Symbol.toPrimitive]("string"),s,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof f)}u.from=function(f,s,o){return p(f,s,o)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function _(f){if(typeof f!="number")throw new TypeError('"size" argument must be of type number');if(f<0)throw new RangeError('The value "'+f+'" is invalid for option "size"')}function y(f,s,o){return _(f),f<=0?l(f):s!==void 0?typeof o=="string"?l(f).fill(s,o):l(f).fill(s):l(f)}u.alloc=function(f,s,o){return y(f,s,o)};function E(f){return _(f),l(f<0?0:k(f)|0)}u.allocUnsafe=function(f){return E(f)},u.allocUnsafeSlow=function(f){return E(f)};function w(f,s){if((typeof s!="string"||s==="")&&(s="utf8"),!u.isEncoding(s))throw new TypeError("Unknown encoding: "+s);const o=T(f,s)|0;let d=l(o);const b=d.write(f,s);return b!==o&&(d=d.slice(0,b)),d}function m(f){const s=f.length<0?0:k(f.length)|0,o=l(s);for(let d=0;d<s;d+=1)o[d]=f[d]&255;return o}function I(f){if(C(f,Uint8Array)){const s=new Uint8Array(f);return R(s.buffer,s.byteOffset,s.byteLength)}return m(f)}function R(f,s,o){if(s<0||f.byteLength<s)throw new RangeError('"offset" is outside of buffer bounds');if(f.byteLength<s+(o||0))throw new RangeError('"length" is outside of buffer bounds');let d;return s===void 0&&o===void 0?d=new Uint8Array(f):o===void 0?d=new Uint8Array(f,s):d=new Uint8Array(f,s,o),Object.setPrototypeOf(d,u.prototype),d}function v(f){if(u.isBuffer(f)){const s=k(f.length)|0,o=l(s);return o.length===0||f.copy(o,0,0,s),o}if(f.length!==void 0)return typeof f.length!="number"||Le(f.length)?l(0):m(f);if(f.type==="Buffer"&&Array.isArray(f.data))return m(f.data)}function k(f){if(f>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return f|0}function O(f){return+f!=f&&(f=0),u.alloc(+f)}u.isBuffer=function(s){return s!=null&&s._isBuffer===!0&&s!==u.prototype},u.compare=function(s,o){if(C(s,Uint8Array)&&(s=u.from(s,s.offset,s.byteLength)),C(o,Uint8Array)&&(o=u.from(o,o.offset,o.byteLength)),!u.isBuffer(s)||!u.isBuffer(o))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(s===o)return 0;let d=s.length,b=o.length;for(let S=0,A=Math.min(d,b);S<A;++S)if(s[S]!==o[S]){d=s[S],b=o[S];break}return d<b?-1:b<d?1:0},u.isEncoding=function(s){switch(String(s).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}},u.concat=function(s,o){if(!Array.isArray(s))throw new TypeError('"list" argument must be an Array of Buffers');if(s.length===0)return u.alloc(0);let d;if(o===void 0)for(o=0,d=0;d<s.length;++d)o+=s[d].length;const b=u.allocUnsafe(o);let S=0;for(d=0;d<s.length;++d){let A=s[d];if(C(A,Uint8Array))S+A.length>b.length?(u.isBuffer(A)||(A=u.from(A)),A.copy(b,S)):Uint8Array.prototype.set.call(b,A,S);else if(u.isBuffer(A))A.copy(b,S);else throw new TypeError('"list" argument must be an Array of Buffers');S+=A.length}return b};function T(f,s){if(u.isBuffer(f))return f.length;if(ArrayBuffer.isView(f)||C(f,ArrayBuffer))return f.byteLength;if(typeof f!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof f);const o=f.length,d=arguments.length>2&&arguments[2]===!0;if(!d&&o===0)return 0;let b=!1;for(;;)switch(s){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return $(f).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o*2;case"hex":return o>>>1;case"base64":return Y(f).length;default:if(b)return d?-1:$(f).length;s=(""+s).toLowerCase(),b=!0}}u.byteLength=T;function q(f,s,o){let d=!1;if((s===void 0||s<0)&&(s=0),s>this.length||((o===void 0||o>this.length)&&(o=this.length),o<=0)||(o>>>=0,s>>>=0,o<=s))return"";for(f||(f="utf8");;)switch(f){case"hex":return re(this,s,o);case"utf8":case"utf-8":return K(this,s,o);case"ascii":return le(this,s,o);case"latin1":case"binary":return ue(this,s,o);case"base64":return P(this,s,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,s,o);default:if(d)throw new TypeError("Unknown encoding: "+f);f=(f+"").toLowerCase(),d=!0}}u.prototype._isBuffer=!0;function U(f,s,o){const d=f[s];f[s]=f[o],f[o]=d}u.prototype.swap16=function(){const s=this.length;if(s%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let o=0;o<s;o+=2)U(this,o,o+1);return this},u.prototype.swap32=function(){const s=this.length;if(s%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let o=0;o<s;o+=4)U(this,o,o+3),U(this,o+1,o+2);return this},u.prototype.swap64=function(){const s=this.length;if(s%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let o=0;o<s;o+=8)U(this,o,o+7),U(this,o+1,o+6),U(this,o+2,o+5),U(this,o+3,o+4);return this},u.prototype.toString=function(){const s=this.length;return s===0?"":arguments.length===0?K(this,0,s):q.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(s){if(!u.isBuffer(s))throw new TypeError("Argument must be a Buffer");return this===s?!0:u.compare(this,s)===0},u.prototype.inspect=function(){let s="";const o=t.INSPECT_MAX_BYTES;return s=this.toString("hex",0,o).replace(/(.{2})/g,"$1 ").trim(),this.length>o&&(s+=" ... "),"<Buffer "+s+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(s,o,d,b,S){if(C(s,Uint8Array)&&(s=u.from(s,s.offset,s.byteLength)),!u.isBuffer(s))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof s);if(o===void 0&&(o=0),d===void 0&&(d=s?s.length:0),b===void 0&&(b=0),S===void 0&&(S=this.length),o<0||d>s.length||b<0||S>this.length)throw new RangeError("out of range index");if(b>=S&&o>=d)return 0;if(b>=S)return-1;if(o>=d)return 1;if(o>>>=0,d>>>=0,b>>>=0,S>>>=0,this===s)return 0;let A=S-b,W=d-o;const ie=Math.min(A,W),J=this.slice(b,S),se=s.slice(o,d);for(let V=0;V<ie;++V)if(J[V]!==se[V]){A=J[V],W=se[V];break}return A<W?-1:W<A?1:0};function oe(f,s,o,d,b){if(f.length===0)return-1;if(typeof o=="string"?(d=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),o=+o,Le(o)&&(o=b?0:f.length-1),o<0&&(o=f.length+o),o>=f.length){if(b)return-1;o=f.length-1}else if(o<0)if(b)o=0;else return-1;if(typeof s=="string"&&(s=u.from(s,d)),u.isBuffer(s))return s.length===0?-1:Se(f,s,o,d,b);if(typeof s=="number")return s=s&255,typeof Uint8Array.prototype.indexOf=="function"?b?Uint8Array.prototype.indexOf.call(f,s,o):Uint8Array.prototype.lastIndexOf.call(f,s,o):Se(f,[s],o,d,b);throw new TypeError("val must be string, number or Buffer")}function Se(f,s,o,d,b){let S=1,A=f.length,W=s.length;if(d!==void 0&&(d=String(d).toLowerCase(),d==="ucs2"||d==="ucs-2"||d==="utf16le"||d==="utf-16le")){if(f.length<2||s.length<2)return-1;S=2,A/=2,W/=2,o/=2}function ie(se,V){return S===1?se[V]:se.readUInt16BE(V*S)}let J;if(b){let se=-1;for(J=o;J<A;J++)if(ie(f,J)===ie(s,se===-1?0:J-se)){if(se===-1&&(se=J),J-se+1===W)return se*S}else se!==-1&&(J-=J-se),se=-1}else for(o+W>A&&(o=A-W),J=o;J>=0;J--){let se=!0;for(let V=0;V<W;V++)if(ie(f,J+V)!==ie(s,V)){se=!1;break}if(se)return J}return-1}u.prototype.includes=function(s,o,d){return this.indexOf(s,o,d)!==-1},u.prototype.indexOf=function(s,o,d){return oe(this,s,o,d,!0)},u.prototype.lastIndexOf=function(s,o,d){return oe(this,s,o,d,!1)};function ee(f,s,o,d){o=Number(o)||0;const b=f.length-o;d?(d=Number(d),d>b&&(d=b)):d=b;const S=s.length;d>S/2&&(d=S/2);let A;for(A=0;A<d;++A){const W=parseInt(s.substr(A*2,2),16);if(Le(W))return A;f[o+A]=W}return A}function ae(f,s,o,d){return Ae($(s,f.length-o),f,o,d)}function we(f,s,o,d){return Ae(Z(s),f,o,d)}function me(f,s,o,d){return Ae(Y(s),f,o,d)}function Q(f,s,o,d){return Ae(te(s,f.length-o),f,o,d)}u.prototype.write=function(s,o,d,b){if(o===void 0)b="utf8",d=this.length,o=0;else if(d===void 0&&typeof o=="string")b=o,d=this.length,o=0;else if(isFinite(o))o=o>>>0,isFinite(d)?(d=d>>>0,b===void 0&&(b="utf8")):(b=d,d=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const S=this.length-o;if((d===void 0||d>S)&&(d=S),s.length>0&&(d<0||o<0)||o>this.length)throw new RangeError("Attempt to write outside buffer bounds");b||(b="utf8");let A=!1;for(;;)switch(b){case"hex":return ee(this,s,o,d);case"utf8":case"utf-8":return ae(this,s,o,d);case"ascii":case"latin1":case"binary":return we(this,s,o,d);case"base64":return me(this,s,o,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,s,o,d);default:if(A)throw new TypeError("Unknown encoding: "+b);b=(""+b).toLowerCase(),A=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function P(f,s,o){return s===0&&o===f.length?e.fromByteArray(f):e.fromByteArray(f.slice(s,o))}function K(f,s,o){o=Math.min(f.length,o);const d=[];let b=s;for(;b<o;){const S=f[b];let A=null,W=S>239?4:S>223?3:S>191?2:1;if(b+W<=o){let ie,J,se,V;switch(W){case 1:S<128&&(A=S);break;case 2:ie=f[b+1],(ie&192)===128&&(V=(S&31)<<6|ie&63,V>127&&(A=V));break;case 3:ie=f[b+1],J=f[b+2],(ie&192)===128&&(J&192)===128&&(V=(S&15)<<12|(ie&63)<<6|J&63,V>2047&&(V<55296||V>57343)&&(A=V));break;case 4:ie=f[b+1],J=f[b+2],se=f[b+3],(ie&192)===128&&(J&192)===128&&(se&192)===128&&(V=(S&15)<<18|(ie&63)<<12|(J&63)<<6|se&63,V>65535&&V<1114112&&(A=V))}}A===null?(A=65533,W=1):A>65535&&(A-=65536,d.push(A>>>10&1023|55296),A=56320|A&1023),d.push(A),b+=W}return H(d)}const G=4096;function H(f){const s=f.length;if(s<=G)return String.fromCharCode.apply(String,f);let o="",d=0;for(;d<s;)o+=String.fromCharCode.apply(String,f.slice(d,d+=G));return o}function le(f,s,o){let d="";o=Math.min(f.length,o);for(let b=s;b<o;++b)d+=String.fromCharCode(f[b]&127);return d}function ue(f,s,o){let d="";o=Math.min(f.length,o);for(let b=s;b<o;++b)d+=String.fromCharCode(f[b]);return d}function re(f,s,o){const d=f.length;(!s||s<0)&&(s=0),(!o||o<0||o>d)&&(o=d);let b="";for(let S=s;S<o;++S)b+=Vt[f[S]];return b}function fe(f,s,o){const d=f.slice(s,o);let b="";for(let S=0;S<d.length-1;S+=2)b+=String.fromCharCode(d[S]+d[S+1]*256);return b}u.prototype.slice=function(s,o){const d=this.length;s=~~s,o=o===void 0?d:~~o,s<0?(s+=d,s<0&&(s=0)):s>d&&(s=d),o<0?(o+=d,o<0&&(o=0)):o>d&&(o=d),o<s&&(o=s);const b=this.subarray(s,o);return Object.setPrototypeOf(b,u.prototype),b};function D(f,s,o){if(f%1!==0||f<0)throw new RangeError("offset is not uint");if(f+s>o)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(s,o,d){s=s>>>0,o=o>>>0,d||D(s,o,this.length);let b=this[s],S=1,A=0;for(;++A<o&&(S*=256);)b+=this[s+A]*S;return b},u.prototype.readUintBE=u.prototype.readUIntBE=function(s,o,d){s=s>>>0,o=o>>>0,d||D(s,o,this.length);let b=this[s+--o],S=1;for(;o>0&&(S*=256);)b+=this[s+--o]*S;return b},u.prototype.readUint8=u.prototype.readUInt8=function(s,o){return s=s>>>0,o||D(s,1,this.length),this[s]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(s,o){return s=s>>>0,o||D(s,2,this.length),this[s]|this[s+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(s,o){return s=s>>>0,o||D(s,2,this.length),this[s]<<8|this[s+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(s,o){return s=s>>>0,o||D(s,4,this.length),(this[s]|this[s+1]<<8|this[s+2]<<16)+this[s+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(s,o){return s=s>>>0,o||D(s,4,this.length),this[s]*16777216+(this[s+1]<<16|this[s+2]<<8|this[s+3])},u.prototype.readBigUInt64LE=Ge(function(s){s=s>>>0,g(s,"offset");const o=this[s],d=this[s+7];(o===void 0||d===void 0)&&x(s,this.length-8);const b=o+this[++s]*2**8+this[++s]*2**16+this[++s]*2**24,S=this[++s]+this[++s]*2**8+this[++s]*2**16+d*2**24;return BigInt(b)+(BigInt(S)<<BigInt(32))}),u.prototype.readBigUInt64BE=Ge(function(s){s=s>>>0,g(s,"offset");const o=this[s],d=this[s+7];(o===void 0||d===void 0)&&x(s,this.length-8);const b=o*2**24+this[++s]*2**16+this[++s]*2**8+this[++s],S=this[++s]*2**24+this[++s]*2**16+this[++s]*2**8+d;return(BigInt(b)<<BigInt(32))+BigInt(S)}),u.prototype.readIntLE=function(s,o,d){s=s>>>0,o=o>>>0,d||D(s,o,this.length);let b=this[s],S=1,A=0;for(;++A<o&&(S*=256);)b+=this[s+A]*S;return S*=128,b>=S&&(b-=Math.pow(2,8*o)),b},u.prototype.readIntBE=function(s,o,d){s=s>>>0,o=o>>>0,d||D(s,o,this.length);let b=o,S=1,A=this[s+--b];for(;b>0&&(S*=256);)A+=this[s+--b]*S;return S*=128,A>=S&&(A-=Math.pow(2,8*o)),A},u.prototype.readInt8=function(s,o){return s=s>>>0,o||D(s,1,this.length),this[s]&128?(255-this[s]+1)*-1:this[s]},u.prototype.readInt16LE=function(s,o){s=s>>>0,o||D(s,2,this.length);const d=this[s]|this[s+1]<<8;return d&32768?d|4294901760:d},u.prototype.readInt16BE=function(s,o){s=s>>>0,o||D(s,2,this.length);const d=this[s+1]|this[s]<<8;return d&32768?d|4294901760:d},u.prototype.readInt32LE=function(s,o){return s=s>>>0,o||D(s,4,this.length),this[s]|this[s+1]<<8|this[s+2]<<16|this[s+3]<<24},u.prototype.readInt32BE=function(s,o){return s=s>>>0,o||D(s,4,this.length),this[s]<<24|this[s+1]<<16|this[s+2]<<8|this[s+3]},u.prototype.readBigInt64LE=Ge(function(s){s=s>>>0,g(s,"offset");const o=this[s],d=this[s+7];(o===void 0||d===void 0)&&x(s,this.length-8);const b=this[s+4]+this[s+5]*2**8+this[s+6]*2**16+(d<<24);return(BigInt(b)<<BigInt(32))+BigInt(o+this[++s]*2**8+this[++s]*2**16+this[++s]*2**24)}),u.prototype.readBigInt64BE=Ge(function(s){s=s>>>0,g(s,"offset");const o=this[s],d=this[s+7];(o===void 0||d===void 0)&&x(s,this.length-8);const b=(o<<24)+this[++s]*2**16+this[++s]*2**8+this[++s];return(BigInt(b)<<BigInt(32))+BigInt(this[++s]*2**24+this[++s]*2**16+this[++s]*2**8+d)}),u.prototype.readFloatLE=function(s,o){return s=s>>>0,o||D(s,4,this.length),r.read(this,s,!0,23,4)},u.prototype.readFloatBE=function(s,o){return s=s>>>0,o||D(s,4,this.length),r.read(this,s,!1,23,4)},u.prototype.readDoubleLE=function(s,o){return s=s>>>0,o||D(s,8,this.length),r.read(this,s,!0,52,8)},u.prototype.readDoubleBE=function(s,o){return s=s>>>0,o||D(s,8,this.length),r.read(this,s,!1,52,8)};function ne(f,s,o,d,b,S){if(!u.isBuffer(f))throw new TypeError('"buffer" argument must be a Buffer instance');if(s>b||s<S)throw new RangeError('"value" argument is out of bounds');if(o+d>f.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(s,o,d,b){if(s=+s,o=o>>>0,d=d>>>0,!b){const W=Math.pow(2,8*d)-1;ne(this,s,o,d,W,0)}let S=1,A=0;for(this[o]=s&255;++A<d&&(S*=256);)this[o+A]=s/S&255;return o+d},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(s,o,d,b){if(s=+s,o=o>>>0,d=d>>>0,!b){const W=Math.pow(2,8*d)-1;ne(this,s,o,d,W,0)}let S=d-1,A=1;for(this[o+S]=s&255;--S>=0&&(A*=256);)this[o+S]=s/A&255;return o+d},u.prototype.writeUint8=u.prototype.writeUInt8=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,1,255,0),this[o]=s&255,o+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,2,65535,0),this[o]=s&255,this[o+1]=s>>>8,o+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,2,65535,0),this[o]=s>>>8,this[o+1]=s&255,o+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,4,4294967295,0),this[o+3]=s>>>24,this[o+2]=s>>>16,this[o+1]=s>>>8,this[o]=s&255,o+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,4,4294967295,0),this[o]=s>>>24,this[o+1]=s>>>16,this[o+2]=s>>>8,this[o+3]=s&255,o+4};function M(f,s,o,d,b){Ze(s,d,b,f,o,7);let S=Number(s&BigInt(4294967295));f[o++]=S,S=S>>8,f[o++]=S,S=S>>8,f[o++]=S,S=S>>8,f[o++]=S;let A=Number(s>>BigInt(32)&BigInt(4294967295));return f[o++]=A,A=A>>8,f[o++]=A,A=A>>8,f[o++]=A,A=A>>8,f[o++]=A,o}function de(f,s,o,d,b){Ze(s,d,b,f,o,7);let S=Number(s&BigInt(4294967295));f[o+7]=S,S=S>>8,f[o+6]=S,S=S>>8,f[o+5]=S,S=S>>8,f[o+4]=S;let A=Number(s>>BigInt(32)&BigInt(4294967295));return f[o+3]=A,A=A>>8,f[o+2]=A,A=A>>8,f[o+1]=A,A=A>>8,f[o]=A,o+8}u.prototype.writeBigUInt64LE=Ge(function(s,o=0){return M(this,s,o,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Ge(function(s,o=0){return de(this,s,o,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(s,o,d,b){if(s=+s,o=o>>>0,!b){const ie=Math.pow(2,8*d-1);ne(this,s,o,d,ie-1,-ie)}let S=0,A=1,W=0;for(this[o]=s&255;++S<d&&(A*=256);)s<0&&W===0&&this[o+S-1]!==0&&(W=1),this[o+S]=(s/A>>0)-W&255;return o+d},u.prototype.writeIntBE=function(s,o,d,b){if(s=+s,o=o>>>0,!b){const ie=Math.pow(2,8*d-1);ne(this,s,o,d,ie-1,-ie)}let S=d-1,A=1,W=0;for(this[o+S]=s&255;--S>=0&&(A*=256);)s<0&&W===0&&this[o+S+1]!==0&&(W=1),this[o+S]=(s/A>>0)-W&255;return o+d},u.prototype.writeInt8=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,1,127,-128),s<0&&(s=255+s+1),this[o]=s&255,o+1},u.prototype.writeInt16LE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,2,32767,-32768),this[o]=s&255,this[o+1]=s>>>8,o+2},u.prototype.writeInt16BE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,2,32767,-32768),this[o]=s>>>8,this[o+1]=s&255,o+2},u.prototype.writeInt32LE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,4,2147483647,-2147483648),this[o]=s&255,this[o+1]=s>>>8,this[o+2]=s>>>16,this[o+3]=s>>>24,o+4},u.prototype.writeInt32BE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,4,2147483647,-2147483648),s<0&&(s=4294967295+s+1),this[o]=s>>>24,this[o+1]=s>>>16,this[o+2]=s>>>8,this[o+3]=s&255,o+4},u.prototype.writeBigInt64LE=Ge(function(s,o=0){return M(this,s,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Ge(function(s,o=0){return de(this,s,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ve(f,s,o,d,b,S){if(o+d>f.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("Index out of range")}function Ke(f,s,o,d,b){return s=+s,o=o>>>0,b||ve(f,s,o,4),r.write(f,s,o,d,23,4),o+4}u.prototype.writeFloatLE=function(s,o,d){return Ke(this,s,o,!0,d)},u.prototype.writeFloatBE=function(s,o,d){return Ke(this,s,o,!1,d)};function Ye(f,s,o,d,b){return s=+s,o=o>>>0,b||ve(f,s,o,8),r.write(f,s,o,d,52,8),o+8}u.prototype.writeDoubleLE=function(s,o,d){return Ye(this,s,o,!0,d)},u.prototype.writeDoubleBE=function(s,o,d){return Ye(this,s,o,!1,d)},u.prototype.copy=function(s,o,d,b){if(!u.isBuffer(s))throw new TypeError("argument should be a Buffer");if(d||(d=0),!b&&b!==0&&(b=this.length),o>=s.length&&(o=s.length),o||(o=0),b>0&&b<d&&(b=d),b===d||s.length===0||this.length===0)return 0;if(o<0)throw new RangeError("targetStart out of bounds");if(d<0||d>=this.length)throw new RangeError("Index out of range");if(b<0)throw new RangeError("sourceEnd out of bounds");b>this.length&&(b=this.length),s.length-o<b-d&&(b=s.length-o+d);const S=b-d;return this===s&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(o,d,b):Uint8Array.prototype.set.call(s,this.subarray(d,b),o),S},u.prototype.fill=function(s,o,d,b){if(typeof s=="string"){if(typeof o=="string"?(b=o,o=0,d=this.length):typeof d=="string"&&(b=d,d=this.length),b!==void 0&&typeof b!="string")throw new TypeError("encoding must be a string");if(typeof b=="string"&&!u.isEncoding(b))throw new TypeError("Unknown encoding: "+b);if(s.length===1){const A=s.charCodeAt(0);(b==="utf8"&&A<128||b==="latin1")&&(s=A)}}else typeof s=="number"?s=s&255:typeof s=="boolean"&&(s=Number(s));if(o<0||this.length<o||this.length<d)throw new RangeError("Out of range index");if(d<=o)return this;o=o>>>0,d=d===void 0?this.length:d>>>0,s||(s=0);let S;if(typeof s=="number")for(S=o;S<d;++S)this[S]=s;else{const A=u.isBuffer(s)?s:u.from(s,b),W=A.length;if(W===0)throw new TypeError('The value "'+s+'" is invalid for argument "value"');for(S=0;S<d-o;++S)this[S+o]=A[S%W]}return this};const Ne={};function Xe(f,s,o){Ne[f]=class extends o{constructor(){super(),Object.defineProperty(this,"message",{value:s.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${f}]`,this.stack,delete this.name}get code(){return f}set code(b){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:b,writable:!0})}toString(){return`${this.name} [${f}]: ${this.message}`}}}Xe("ERR_BUFFER_OUT_OF_BOUNDS",function(f){return f?`${f} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Xe("ERR_INVALID_ARG_TYPE",function(f,s){return`The "${f}" argument must be of type number. Received type ${typeof s}`},TypeError),Xe("ERR_OUT_OF_RANGE",function(f,s,o){let d=`The value of "${f}" is out of range.`,b=o;return Number.isInteger(o)&&Math.abs(o)>2**32?b=jt(String(o)):typeof o=="bigint"&&(b=String(o),(o>BigInt(2)**BigInt(32)||o<-(BigInt(2)**BigInt(32)))&&(b=jt(b)),b+="n"),d+=` It must be ${s}. Received ${b}`,d},RangeError);function jt(f){let s="",o=f.length;const d=f[0]==="-"?1:0;for(;o>=d+4;o-=3)s=`_${f.slice(o-3,o)}${s}`;return`${f.slice(0,o)}${s}`}function bt(f,s,o){g(s,"offset"),(f[s]===void 0||f[s+o]===void 0)&&x(s,f.length-(o+1))}function Ze(f,s,o,d,b,S){if(f>o||f<s){const A=typeof s=="bigint"?"n":"";let W;throw s===0||s===BigInt(0)?W=`>= 0${A} and < 2${A} ** ${(S+1)*8}${A}`:W=`>= -(2${A} ** ${(S+1)*8-1}${A}) and < 2 ** ${(S+1)*8-1}${A}`,new Ne.ERR_OUT_OF_RANGE("value",W,f)}bt(d,b,S)}function g(f,s){if(typeof f!="number")throw new Ne.ERR_INVALID_ARG_TYPE(s,"number",f)}function x(f,s,o){throw Math.floor(f)!==f?(g(f,o),new Ne.ERR_OUT_OF_RANGE("offset","an integer",f)):s<0?new Ne.ERR_BUFFER_OUT_OF_BOUNDS:new Ne.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${s}`,f)}const N=/[^+/0-9A-Za-z-_]/g;function F(f){if(f=f.split("=")[0],f=f.trim().replace(N,""),f.length<2)return"";for(;f.length%4!==0;)f=f+"=";return f}function $(f,s){s=s||1/0;let o;const d=f.length;let b=null;const S=[];for(let A=0;A<d;++A){if(o=f.charCodeAt(A),o>55295&&o<57344){if(!b){if(o>56319){(s-=3)>-1&&S.push(239,191,189);continue}else if(A+1===d){(s-=3)>-1&&S.push(239,191,189);continue}b=o;continue}if(o<56320){(s-=3)>-1&&S.push(239,191,189),b=o;continue}o=(b-55296<<10|o-56320)+65536}else b&&(s-=3)>-1&&S.push(239,191,189);if(b=null,o<128){if((s-=1)<0)break;S.push(o)}else if(o<2048){if((s-=2)<0)break;S.push(o>>6|192,o&63|128)}else if(o<65536){if((s-=3)<0)break;S.push(o>>12|224,o>>6&63|128,o&63|128)}else if(o<1114112){if((s-=4)<0)break;S.push(o>>18|240,o>>12&63|128,o>>6&63|128,o&63|128)}else throw new Error("Invalid code point")}return S}function Z(f){const s=[];for(let o=0;o<f.length;++o)s.push(f.charCodeAt(o)&255);return s}function te(f,s){let o,d,b;const S=[];for(let A=0;A<f.length&&!((s-=2)<0);++A)o=f.charCodeAt(A),d=o>>8,b=o%256,S.push(b),S.push(d);return S}function Y(f){return e.toByteArray(F(f))}function Ae(f,s,o,d){let b;for(b=0;b<d&&!(b+o>=s.length||b>=f.length);++b)s[b+o]=f[b];return b}function C(f,s){return f instanceof s||f!=null&&f.constructor!=null&&f.constructor.name!=null&&f.constructor.name===s.name}function Le(f){return f!==f}const Vt=function(){const f="0123456789abcdef",s=new Array(256);for(let o=0;o<16;++o){const d=o*16;for(let b=0;b<16;++b)s[d+b]=f[o]+f[b]}return s}();function Ge(f){return typeof BigInt>"u"?vn:f}function vn(){throw new Error("BigInt not supported")}})(Fe);/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */let kn;var go=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:ao):t=>(kn||(kn=Promise.resolve())).then(t).catch(e=>setTimeout(()=>{throw e},0));const wo=lo(go),Lt="http://www.w3.org/1999/02/22-rdf-syntax-ns#",$t="http://www.w3.org/2001/XMLSchema#",Nr="http://www.w3.org/2000/10/swap/",ye={xsd:{decimal:`${$t}decimal`,boolean:`${$t}boolean`,double:`${$t}double`,integer:`${$t}integer`,string:`${$t}string`},rdf:{type:`${Lt}type`,nil:`${Lt}nil`,first:`${Lt}first`,rest:`${Lt}rest`,langString:`${Lt}langString`},owl:{sameAs:"http://www.w3.org/2002/07/owl#sameAs"},r:{forSome:`${Nr}reify#forSome`,forAll:`${Nr}reify#forAll`},log:{implies:`${Nr}log#implies`}},{xsd:Xt}=ye,mo=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\([^])/g,Cn={"\\":"\\","'":"'",'"':'"',n:`
7
- `,r:"\r",t:" ",f:"\f",b:"\b",_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},xo=/[\x00-\x20<>\\"\{\}\|\^\`]/,Eo={_iri:!0,_unescapedIri:!0,_simpleQuotedString:!0,_langcode:!0,_blank:!0,_newline:!0,_comment:!0,_whitespace:!0,_endOfFile:!0},So=/$0^/;class Io{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._lineMode=!!e.lineMode){this._n3Mode=!1;for(const r in this)!(r in Eo)&&this[r]instanceof RegExp&&(this[r]=So)}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 u,p;for(;u=this._newline.exec(n);)this.comments&&(p=this._comment.exec(u[0]))&&a("comment",p[1],"",this._line,u[0].length),n=n.substr(u[0].length,n.length),i=n.length,this._line++;if(!u&&(u=this._whitespace.exec(n))&&(n=n.substr(u[0].length,n.length)),this._endOfFile.test(n))return r&&(this.comments&&(p=this._comment.exec(n))&&a("comment",p[1],"",this._line,n.length),n=null,a("eof","","",this._line,0)),this._input=n;const _=this._line,y=n[0];let E="",w="",m="",I=null,R=0,v=!1;switch(y){case"^":if(n.length<3)break;if(n[1]==="^"){if(this._previousMarker="^^",n=n.substr(2),n[0]!=="<"){v=!0;break}}else{this._n3Mode&&(R=1,E="^");break}case"<":if(I=this._unescapedIri.exec(n))E="IRI",w=I[1];else if(I=this._iri.exec(n)){if(w=this._unescape(I[1]),w===null||xo.test(w))return l(this);E="IRI"}else n.length>1&&n[1]==="<"?(E="<<",R=2):this._n3Mode&&n.length>1&&n[1]==="="&&(E="inverse",R=2,w=">");break;case">":n.length>1&&n[1]===">"&&(E=">>",R=2);break;case"_":((I=this._blank.exec(n))||r&&(I=this._blank.exec(`${n} `)))&&(E="blank",m="_",w=I[1]);break;case'"':if(I=this._simpleQuotedString.exec(n))w=I[1];else if({value:w,matchLength:R}=this._parseLiteral(n),w===null)return l(this);(I!==null||R!==0)&&(E="literal",this._literalClosingPos=0);break;case"'":if(!this._lineMode){if(I=this._simpleApostropheString.exec(n))w=I[1];else if({value:w,matchLength:R}=this._parseLiteral(n),w===null)return l(this);(I!==null||R!==0)&&(E="literal",this._literalClosingPos=0)}break;case"?":this._n3Mode&&(I=this._variable.exec(n))&&(E="var",w=I[0]);break;case"@":this._previousMarker==="literal"&&(I=this._langcode.exec(n))?(E="langcode",w=I[1]):(I=this._keyword.exec(n))&&(E=I[0]);break;case".":if(n.length===1?r:n[1]<"0"||n[1]>"9"){E=".",R=1;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":(I=this._number.exec(n)||r&&(I=this._number.exec(`${n} `)))&&(E="literal",w=I[0],m=typeof I[1]=="string"?Xt.double:typeof I[2]=="string"?Xt.decimal:Xt.integer);break;case"B":case"b":case"p":case"P":case"G":case"g":(I=this._sparqlKeyword.exec(n))?E=I[0].toUpperCase():v=!0;break;case"f":case"t":(I=this._boolean.exec(n))?(E="literal",w=I[0],m=Xt.boolean):v=!0;break;case"a":(I=this._shortPredicates.exec(n))?(E="abbreviation",w="a"):v=!0;break;case"=":this._n3Mode&&n.length>1&&(E="abbreviation",n[1]!==">"?(R=1,w="="):(R=2,w=">"));break;case"!":if(!this._n3Mode)break;case",":case";":case"[":case"]":case"(":case")":case"}":this._lineMode||(R=1,E=y);break;case"{":!this._lineMode&&n.length>=2&&(n[1]==="|"?(E="{|",R=2):(E=y,R=1));break;case"|":n.length>=2&&n[1]==="}"&&(E="|}",R=2);break;default:v=!0}if(v&&((this._previousMarker==="@prefix"||this._previousMarker==="PREFIX")&&(I=this._prefix.exec(n))?(E="prefix",w=I[1]||""):((I=this._prefixed.exec(n))||r&&(I=this._prefixed.exec(`${n} `)))&&(E="prefixed",m=I[1]||"",w=this._unescape(I[2]))),this._previousMarker==="^^")switch(E){case"prefixed":E="type";break;case"IRI":E="typeIRI";break;default:E=""}if(!E)return r||!/^'''|^"""/.test(n)&&/\n|\r/.test(n)?l(this):this._input=n;const k=R||I[0].length,O=a(E,w,m,_,k);this.previousToken=O,this._previousMarker=E,n=n.substr(k,n.length)}function a(u,p,_,y,E){const w=n?i-n.length:i,m=w+E,I={type:u,value:p,prefix:_,line:y,start:w,end:m};return e(null,I),I}function l(u){e(u._syntaxError(/^\S*/.exec(n)[0]))}}_unescape(e){let r=!1;const n=e.replace(mo,(i,a,l,u)=>{if(typeof a=="string")return String.fromCharCode(Number.parseInt(a,16));if(typeof l=="string"){let p=Number.parseInt(l,16);return p<=65535?String.fromCharCode(Number.parseInt(l,16)):String.fromCharCode(55296+((p-=65536)>>10),56320+(p&1023))}return u in Cn?Cn[u]:(r=!0,"")});return r?null:n}_parseLiteral(e){if(e.length>=3){const r=e.match(/^(?:"""|"|'''|'|)/)[0],n=r.length;let i=Math.max(this._literalClosingPos,n);for(;(i=e.indexOf(r,i))>0;){let a=0;for(;e[i-a-1]==="\\";)a++;if(a%2===0){const l=e.substring(n,i),u=l.split(/\r\n|\r|\n/).length-1,p=i+n;if(n===1&&u!==0||n===3&&this._lineMode)break;return this._line+=u,{value:this._unescape(l),matchLength:p}}i++}this._literalClosingPos=e.length-n+1}return{value:"",matchLength:0}}_syntaxError(e){this._input=null;const 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")wo(()=>this._tokenizeToEnd(r,!0));else{const n=[];let i;if(this._tokenizeToEnd((a,l)=>a?i=a:n.push(l),!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=Fe.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)}}const{rdf:Ro,xsd:st}=ye;let mt,Ao=0;const ot={namedNode:Mn,blankNode:Dn,variable:Wn,literal:Un,defaultGraph:Po,quad:jr,triple:jr,fromTerm:Ft,fromQuad:Gn};class Be{constructor(e){this.id=e}get value(){return this.id}equals(e){return e instanceof Be?this.id===e.id:!!e&&this.termType===e.termType&&this.value===e.value}hashCode(){return 0}toJSON(){return{termType:this.termType,value:this.value}}}class Pr extends Be{get termType(){return"NamedNode"}}class xt extends Be{get termType(){return"Literal"}get value(){return this.id.substring(1,this.id.lastIndexOf('"'))}get language(){const e=this.id;let r=e.lastIndexOf('"')+1;return r<e.length&&e[r++]==="@"?e.substr(r).toLowerCase():""}get datatype(){return new Pr(this.datatypeString)}get datatypeString(){const e=this.id,r=e.lastIndexOf('"')+1,n=r<e.length?e[r]:"";return n==="^"?e.substr(r+2):n!=="@"?st.string:Ro.langString}equals(e){return e instanceof xt?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}}}}class To extends Be{constructor(e){super(`_:${e}`)}get termType(){return"BlankNode"}get value(){return this.id.substr(2)}}class vo extends Be{constructor(e){super(`?${e}`)}get termType(){return"Variable"}get value(){return this.id.substr(1)}}class No extends Be{constructor(){return super(""),mt||this}get termType(){return"DefaultGraph"}equals(e){return this===e||!!e&&this.termType===e.termType}}mt=new No;function Bt(t,e,r){if(e=e||ot,!t)return e.defaultGraph();switch(t[0]){case"?":return e.variable(t.substr(1));case"_":return e.blankNode(t.substr(2));case'"':if(e===ot)return new xt(t);if(t[t.length-1]==='"')return e.literal(t.substr(1,t.length-2));const 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(Bt(t[0],e,!0),Bt(t[1],e,!0),Bt(t[2],e,!0),t[3]&&Bt(t[3],e,!0))}function Et(t,e){if(typeof t=="string")return t;if(t instanceof Be&&t.termType!=="Quad")return t.id;if(!t)return mt.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!==st.string?`^^${t.datatype.value}`:""}`;case"Quad":const r=[Et(t.subject,!0),Et(t.predicate,!0),Et(t.object,!0)];return t.graph&&t.graph.termType!=="DefaultGraph"&&r.push(Et(t.graph,!0)),e?r:JSON.stringify(r);default:throw new Error(`Unexpected termType: ${t.termType}`)}}class On extends Be{constructor(e,r,n,i){super(""),this._subject=e,this._predicate=r,this._object=n,this._graph=i||mt}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 Mn(t){return new Pr(t)}function Dn(t){return new To(t||`n3-${Ao++}`)}function Un(t,e){if(typeof e=="string")return new xt(`"${t}"@${e.toLowerCase()}`);let r=e?e.value:"";return r===""&&(typeof t=="boolean"?r=st.boolean:typeof t=="number"&&(Number.isFinite(t)?r=Number.isInteger(t)?st.integer:st.double:(r=st.double,Number.isNaN(t)||(t=t>0?"INF":"-INF")))),r===""||r===st.string?new xt(`"${t}"`):new xt(`"${t}"^^${r}`)}function Wn(t){return new vo(t)}function Po(){return mt}function jr(t,e,r,n){return new On(t,e,r,n)}function Ft(t){if(t instanceof Be)return t;switch(t.termType){case"NamedNode":return Mn(t.value);case"BlankNode":return Dn(t.value);case"Variable":return Wn(t.value);case"DefaultGraph":return mt;case"Literal":return Un(t.value,t.language||t.datatype);case"Quad":return Gn(t);default:throw new Error(`Unexpected termType: ${t.termType}`)}}function Gn(t){if(t instanceof On)return t;if(t.termType!=="Quad")throw new Error(`Unexpected termType: ${t.termType}`);return jr(Ft(t.subject),Ft(t.predicate),Ft(t.object),Ft(t.graph))}let zn=0;class qn{constructor(e){this._contextStack=[],this._graph=null,e=e||{},this._setBase(e.baseIRI),e.factory&&Hn(this,e.factory);const r=typeof e.format=="string"?e.format.match(/\w*$/)[0].toLowerCase():"",n=/turtle/.test(r),i=/trig/.test(r),a=/triple/.test(r),l=/quad/.test(r),u=this._n3Mode=/n3/.test(r),p=a||l;(this._supportsNamedGraphs=!(n||u))||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(n||i||a||u),this._supportsRDFStar=r===""||/star|\*$/.test(r),p&&(this._resolveRelativeIRI=_=>null),this._blankNodePrefix=typeof e.blankNodePrefix!="string"?"":e.blankNodePrefix.replace(/^(?!_:)/,"_:"),this._lexer=e.lexer||new Io({lineMode:p,n3:u}),this._explicitQuantifiers=!!e.explicitQuantifiers}static _resetBlankNodePrefix(){zn=0}_setBase(e){if(!e)this._base="",this._basePath="";else{const 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,a){const l=this._n3Mode;this._contextStack.push({type:e,subject:n,predicate:i,object:a,graph:r,inverse:l?this._inversePredicate:!1,blankPrefix:l?this._prefixes._:"",quantified:l?this._quantified:null}),l&&(this._inversePredicate=!1,this._prefixes._=this._graph?`${this._graph.value}.`:".",this._quantified=Object.create(this._quantified))}_restoreContext(e,r){const 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":const i=this._resolveIRI(e.value);if(i===null)return this._error("Invalid IRI",e);n=this._factory.namedNode(i);break;case"type":case"prefixed":const a=this._prefixes[e.prefix];if(a===void 0)return this._error(`Undefined prefix "${e.prefix}:"`,e);n=this._factory.namedNode(a+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){const 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);const 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;const a=this._subject,l=this._contextStack,u=l[l.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),l.length!==0&&l[l.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()),a===null?u.predicate===null?u.subject=n:u.object=n:this._emit(a,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":const 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){const 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;const i=this._subject,a=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,a&&(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);const l=this._predicate,u=this._object;this._subject=this._factory.quad(i,l,u,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){const l=this._predicate,u=this._object;a?this._emit(u,l,i,n):this._emit(i,l,u,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);const r=this._readEntity(e);return this._prefixes[this._prefix]=r.value,this._prefixCallback(this._prefix,r),this._readDeclarationPunctuation}_readBaseIRI(e){const 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:const r=this._contextStack,n=r.length&&r[r.length-1];if(n&&n.type==="item"){const 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;const 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){const r=this._factory.blankNode();let 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);const 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(){const 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){const n=new Error(`${e} on line ${r.line}.`);n.context={token:r,line:r.line,previousToken:this._lexer.previousToken},this._callback(n),this._callback=Zt}_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;const r=e.length;let n="",i=-1,a=-1,l=0,u="/";for(;i<r;){switch(u){case":":if(a<0&&e[++i]==="/"&&e[++i]==="/")for(;(a=i+1)<r&&e[a]!=="/";)i=a;break;case"?":case"#":i=r;break;case"/":if(e[i+1]===".")switch(u=e[++i+1],u){case"/":n+=e.substring(l,i-1),l=i+1;break;case void 0:case"?":case"#":return n+e.substring(l,i)+e.substr(i+1);case".":if(u=e[++i+1],u===void 0||u==="/"||u==="?"||u==="#"){if(n+=e.substring(l,i-2),(l=n.lastIndexOf("/"))>=a&&(n=n.substr(0,l)),u!=="/")return`${n}/${e.substr(i+1)}`;l=i+1}}}u=e[++i]}return n+e.substring(l)}parse(e,r,n){let i,a,l;if(r&&(r.onQuad||r.onPrefix||r.onComment)?(i=r.onQuad,a=r.onPrefix,l=r.onComment):(i=r,a=n),this._readCallback=this._readInTopContext,this._sparqlStyle=!1,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix?this._blankNodePrefix.substr(2):`b${zn++}_`,this._prefixCallback=a||Zt,this._inversePredicate=!1,this._quantified=Object.create(null),!i){const p=[];let _;if(this._callback=(y,E)=>{y?_=y:E&&p.push(E)},this._lexer.tokenize(e).every(y=>this._readCallback=this._readCallback(y)),_)throw _;return p}let u=(p,_)=>{p!==null?(this._callback(p),this._callback=Zt):this._readCallback&&(this._readCallback=this._readCallback(_))};l&&(this._lexer.comments=!0,u=(p,_)=>{p!==null?(this._callback(p),this._callback=Zt):this._readCallback&&(_.type==="comment"?l(_.value):this._readCallback=this._readCallback(_))}),this._callback=i,this._lexer.tokenize(e,u)}}function Zt(){}function Hn(t,e){t._factory=e,t.DEFAULTGRAPH=e.defaultGraph(),t.RDF_FIRST=e.namedNode(ye.rdf.first),t.RDF_REST=e.namedNode(ye.rdf.rest),t.RDF_NIL=e.namedNode(ye.rdf.nil),t.N3_FORALL=e.namedNode(ye.r.forAll),t.N3_FORSOME=e.namedNode(ye.r.forSome),t.ABBREVIATIONS={a:e.namedNode(ye.rdf.type),"=":e.namedNode(ye.owl.sameAs),">":e.namedNode(ye.log.implies)},t.QUANTIFIERS_GRAPH=e.namedNode("urn:n3:quantifiers")}Hn(qn.prototype,ot);function Lr(t){return!!t&&t.termType==="DefaultGraph"}const kt=ot.defaultGraph(),{rdf:jo,xsd:St}=ye,Qn=/["\\\t\n\r\b\f\u0000-\u0019\ud800-\udbff]/,Vn=/["\\\t\n\r\b\f\u0000-\u0019]|[\ud800-\udbff][\udc00-\udfff]/g,Lo={"\\":"\\\\",'"':'\\"'," ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};class Ct extends Be{equals(e){return e===this}}class Kn{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,a,l){n+=i,l&&l()},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=kt,this._prefixIRIs=Object.create(null),r.prefixes&&this.addPrefixes(r.prefixes),r.baseIRI&&(this._baseMatcher=new RegExp(`^${Xn(r.baseIRI)}${r.baseIRI.endsWith("/")?"":"[#?]"}`),this._baseLength=r.baseIRI.length))}get _inDefaultGraph(){return kt.equals(this._graph)}_write(e,r){this._outputStream.write(e,"utf8",r)}_writeQuad(e,r,n,i,a){try{i.equals(this._graph)||(this._write((this._subject===null?"":this._inDefaultGraph?`.
6
+ */(function(t){const e=Kt,r=Ar,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=u,t.SlowBuffer=B,t.INSPECT_MAX_BYTES=50;const i=2147483647;t.kMaxLength=i,u.TYPED_ARRAY_SUPPORT=a(),!u.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 a(){try{const f=new Uint8Array(1),s={foo:function(){return 42}};return Object.setPrototypeOf(s,Uint8Array.prototype),Object.setPrototypeOf(f,s),f.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function l(f){if(f>i)throw new RangeError('The value "'+f+'" is invalid for option "size"');const s=new Uint8Array(f);return Object.setPrototypeOf(s,u.prototype),s}function u(f,s,o){if(typeof f=="number"){if(typeof s=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return x(f)}return p(f,s,o)}u.poolSize=8192;function p(f,s,o){if(typeof f=="string")return I(f,s);if(ArrayBuffer.isView(f))return R(f);if(f==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof f);if(O(f,ArrayBuffer)||f&&O(f.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(O(f,SharedArrayBuffer)||f&&O(f.buffer,SharedArrayBuffer)))return m(f,s,o);if(typeof f=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const d=f.valueOf&&f.valueOf();if(d!=null&&d!==f)return u.from(d,s,o);const b=v(f);if(b)return b;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof f[Symbol.toPrimitive]=="function")return u.from(f[Symbol.toPrimitive]("string"),s,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof f)}u.from=function(f,s,o){return p(f,s,o)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function _(f){if(typeof f!="number")throw new TypeError('"size" argument must be of type number');if(f<0)throw new RangeError('The value "'+f+'" is invalid for option "size"')}function y(f,s,o){return _(f),f<=0?l(f):s!==void 0?typeof o=="string"?l(f).fill(s,o):l(f).fill(s):l(f)}u.alloc=function(f,s,o){return y(f,s,o)};function x(f){return _(f),l(f<0?0:$(f)|0)}u.allocUnsafe=function(f){return x(f)},u.allocUnsafeSlow=function(f){return x(f)};function I(f,s){if((typeof s!="string"||s==="")&&(s="utf8"),!u.isEncoding(s))throw new TypeError("Unknown encoding: "+s);const o=T(f,s)|0;let d=l(o);const b=d.write(f,s);return b!==o&&(d=d.slice(0,b)),d}function S(f){const s=f.length<0?0:$(f.length)|0,o=l(s);for(let d=0;d<s;d+=1)o[d]=f[d]&255;return o}function R(f){if(O(f,Uint8Array)){const s=new Uint8Array(f);return m(s.buffer,s.byteOffset,s.byteLength)}return S(f)}function m(f,s,o){if(s<0||f.byteLength<s)throw new RangeError('"offset" is outside of buffer bounds');if(f.byteLength<s+(o||0))throw new RangeError('"length" is outside of buffer bounds');let d;return s===void 0&&o===void 0?d=new Uint8Array(f):o===void 0?d=new Uint8Array(f,s):d=new Uint8Array(f,s,o),Object.setPrototypeOf(d,u.prototype),d}function v(f){if(u.isBuffer(f)){const s=$(f.length)|0,o=l(s);return o.length===0||f.copy(o,0,0,s),o}if(f.length!==void 0)return typeof f.length!="number"||Le(f.length)?l(0):S(f);if(f.type==="Buffer"&&Array.isArray(f.data))return S(f.data)}function $(f){if(f>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return f|0}function B(f){return+f!=f&&(f=0),u.alloc(+f)}u.isBuffer=function(s){return s!=null&&s._isBuffer===!0&&s!==u.prototype},u.compare=function(s,o){if(O(s,Uint8Array)&&(s=u.from(s,s.offset,s.byteLength)),O(o,Uint8Array)&&(o=u.from(o,o.offset,o.byteLength)),!u.isBuffer(s)||!u.isBuffer(o))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(s===o)return 0;let d=s.length,b=o.length;for(let E=0,A=Math.min(d,b);E<A;++E)if(s[E]!==o[E]){d=s[E],b=o[E];break}return d<b?-1:b<d?1:0},u.isEncoding=function(s){switch(String(s).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}},u.concat=function(s,o){if(!Array.isArray(s))throw new TypeError('"list" argument must be an Array of Buffers');if(s.length===0)return u.alloc(0);let d;if(o===void 0)for(o=0,d=0;d<s.length;++d)o+=s[d].length;const b=u.allocUnsafe(o);let E=0;for(d=0;d<s.length;++d){let A=s[d];if(O(A,Uint8Array))E+A.length>b.length?(u.isBuffer(A)||(A=u.from(A)),A.copy(b,E)):Uint8Array.prototype.set.call(b,A,E);else if(u.isBuffer(A))A.copy(b,E);else throw new TypeError('"list" argument must be an Array of Buffers');E+=A.length}return b};function T(f,s){if(u.isBuffer(f))return f.length;if(ArrayBuffer.isView(f)||O(f,ArrayBuffer))return f.byteLength;if(typeof f!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof f);const o=f.length,d=arguments.length>2&&arguments[2]===!0;if(!d&&o===0)return 0;let b=!1;for(;;)switch(s){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return F(f).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o*2;case"hex":return o>>>1;case"base64":return Y(f).length;default:if(b)return d?-1:F(f).length;s=(""+s).toLowerCase(),b=!0}}u.byteLength=T;function q(f,s,o){let d=!1;if((s===void 0||s<0)&&(s=0),s>this.length||((o===void 0||o>this.length)&&(o=this.length),o<=0)||(o>>>=0,s>>>=0,o<=s))return"";for(f||(f="utf8");;)switch(f){case"hex":return re(this,s,o);case"utf8":case"utf-8":return K(this,s,o);case"ascii":return ue(this,s,o);case"latin1":case"binary":return fe(this,s,o);case"base64":return P(this,s,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ce(this,s,o);default:if(d)throw new TypeError("Unknown encoding: "+f);f=(f+"").toLowerCase(),d=!0}}u.prototype._isBuffer=!0;function U(f,s,o){const d=f[s];f[s]=f[o],f[o]=d}u.prototype.swap16=function(){const s=this.length;if(s%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let o=0;o<s;o+=2)U(this,o,o+1);return this},u.prototype.swap32=function(){const s=this.length;if(s%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let o=0;o<s;o+=4)U(this,o,o+3),U(this,o+1,o+2);return this},u.prototype.swap64=function(){const s=this.length;if(s%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let o=0;o<s;o+=8)U(this,o,o+7),U(this,o+1,o+6),U(this,o+2,o+5),U(this,o+3,o+4);return this},u.prototype.toString=function(){const s=this.length;return s===0?"":arguments.length===0?K(this,0,s):q.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(s){if(!u.isBuffer(s))throw new TypeError("Argument must be a Buffer");return this===s?!0:u.compare(this,s)===0},u.prototype.inspect=function(){let s="";const o=t.INSPECT_MAX_BYTES;return s=this.toString("hex",0,o).replace(/(.{2})/g,"$1 ").trim(),this.length>o&&(s+=" ... "),"<Buffer "+s+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(s,o,d,b,E){if(O(s,Uint8Array)&&(s=u.from(s,s.offset,s.byteLength)),!u.isBuffer(s))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof s);if(o===void 0&&(o=0),d===void 0&&(d=s?s.length:0),b===void 0&&(b=0),E===void 0&&(E=this.length),o<0||d>s.length||b<0||E>this.length)throw new RangeError("out of range index");if(b>=E&&o>=d)return 0;if(b>=E)return-1;if(o>=d)return 1;if(o>>>=0,d>>>=0,b>>>=0,E>>>=0,this===s)return 0;let A=E-b,W=d-o;const ie=Math.min(A,W),J=this.slice(b,E),se=s.slice(o,d);for(let V=0;V<ie;++V)if(J[V]!==se[V]){A=J[V],W=se[V];break}return A<W?-1:W<A?1:0};function ae(f,s,o,d,b){if(f.length===0)return-1;if(typeof o=="string"?(d=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),o=+o,Le(o)&&(o=b?0:f.length-1),o<0&&(o=f.length+o),o>=f.length){if(b)return-1;o=f.length-1}else if(o<0)if(b)o=0;else return-1;if(typeof s=="string"&&(s=u.from(s,d)),u.isBuffer(s))return s.length===0?-1:Ee(f,s,o,d,b);if(typeof s=="number")return s=s&255,typeof Uint8Array.prototype.indexOf=="function"?b?Uint8Array.prototype.indexOf.call(f,s,o):Uint8Array.prototype.lastIndexOf.call(f,s,o):Ee(f,[s],o,d,b);throw new TypeError("val must be string, number or Buffer")}function Ee(f,s,o,d,b){let E=1,A=f.length,W=s.length;if(d!==void 0&&(d=String(d).toLowerCase(),d==="ucs2"||d==="ucs-2"||d==="utf16le"||d==="utf-16le")){if(f.length<2||s.length<2)return-1;E=2,A/=2,W/=2,o/=2}function ie(se,V){return E===1?se[V]:se.readUInt16BE(V*E)}let J;if(b){let se=-1;for(J=o;J<A;J++)if(ie(f,J)===ie(s,se===-1?0:J-se)){if(se===-1&&(se=J),J-se+1===W)return se*E}else se!==-1&&(J-=J-se),se=-1}else for(o+W>A&&(o=A-W),J=o;J>=0;J--){let se=!0;for(let V=0;V<W;V++)if(ie(f,J+V)!==ie(s,V)){se=!1;break}if(se)return J}return-1}u.prototype.includes=function(s,o,d){return this.indexOf(s,o,d)!==-1},u.prototype.indexOf=function(s,o,d){return ae(this,s,o,d,!0)},u.prototype.lastIndexOf=function(s,o,d){return ae(this,s,o,d,!1)};function ee(f,s,o,d){o=Number(o)||0;const b=f.length-o;d?(d=Number(d),d>b&&(d=b)):d=b;const E=s.length;d>E/2&&(d=E/2);let A;for(A=0;A<d;++A){const W=parseInt(s.substr(A*2,2),16);if(Le(W))return A;f[o+A]=W}return A}function le(f,s,o,d){return Re(F(s,f.length-o),f,o,d)}function ge(f,s,o,d){return Re(Z(s),f,o,d)}function we(f,s,o,d){return Re(Y(s),f,o,d)}function Q(f,s,o,d){return Re(te(s,f.length-o),f,o,d)}u.prototype.write=function(s,o,d,b){if(o===void 0)b="utf8",d=this.length,o=0;else if(d===void 0&&typeof o=="string")b=o,d=this.length,o=0;else if(isFinite(o))o=o>>>0,isFinite(d)?(d=d>>>0,b===void 0&&(b="utf8")):(b=d,d=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const E=this.length-o;if((d===void 0||d>E)&&(d=E),s.length>0&&(d<0||o<0)||o>this.length)throw new RangeError("Attempt to write outside buffer bounds");b||(b="utf8");let A=!1;for(;;)switch(b){case"hex":return ee(this,s,o,d);case"utf8":case"utf-8":return le(this,s,o,d);case"ascii":case"latin1":case"binary":return ge(this,s,o,d);case"base64":return we(this,s,o,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,s,o,d);default:if(A)throw new TypeError("Unknown encoding: "+b);b=(""+b).toLowerCase(),A=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function P(f,s,o){return s===0&&o===f.length?e.fromByteArray(f):e.fromByteArray(f.slice(s,o))}function K(f,s,o){o=Math.min(f.length,o);const d=[];let b=s;for(;b<o;){const E=f[b];let A=null,W=E>239?4:E>223?3:E>191?2:1;if(b+W<=o){let ie,J,se,V;switch(W){case 1:E<128&&(A=E);break;case 2:ie=f[b+1],(ie&192)===128&&(V=(E&31)<<6|ie&63,V>127&&(A=V));break;case 3:ie=f[b+1],J=f[b+2],(ie&192)===128&&(J&192)===128&&(V=(E&15)<<12|(ie&63)<<6|J&63,V>2047&&(V<55296||V>57343)&&(A=V));break;case 4:ie=f[b+1],J=f[b+2],se=f[b+3],(ie&192)===128&&(J&192)===128&&(se&192)===128&&(V=(E&15)<<18|(ie&63)<<12|(J&63)<<6|se&63,V>65535&&V<1114112&&(A=V))}}A===null?(A=65533,W=1):A>65535&&(A-=65536,d.push(A>>>10&1023|55296),A=56320|A&1023),d.push(A),b+=W}return H(d)}const G=4096;function H(f){const s=f.length;if(s<=G)return String.fromCharCode.apply(String,f);let o="",d=0;for(;d<s;)o+=String.fromCharCode.apply(String,f.slice(d,d+=G));return o}function ue(f,s,o){let d="";o=Math.min(f.length,o);for(let b=s;b<o;++b)d+=String.fromCharCode(f[b]&127);return d}function fe(f,s,o){let d="";o=Math.min(f.length,o);for(let b=s;b<o;++b)d+=String.fromCharCode(f[b]);return d}function re(f,s,o){const d=f.length;(!s||s<0)&&(s=0),(!o||o<0||o>d)&&(o=d);let b="";for(let E=s;E<o;++E)b+=Qt[f[E]];return b}function ce(f,s,o){const d=f.slice(s,o);let b="";for(let E=0;E<d.length-1;E+=2)b+=String.fromCharCode(d[E]+d[E+1]*256);return b}u.prototype.slice=function(s,o){const d=this.length;s=~~s,o=o===void 0?d:~~o,s<0?(s+=d,s<0&&(s=0)):s>d&&(s=d),o<0?(o+=d,o<0&&(o=0)):o>d&&(o=d),o<s&&(o=s);const b=this.subarray(s,o);return Object.setPrototypeOf(b,u.prototype),b};function D(f,s,o){if(f%1!==0||f<0)throw new RangeError("offset is not uint");if(f+s>o)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(s,o,d){s=s>>>0,o=o>>>0,d||D(s,o,this.length);let b=this[s],E=1,A=0;for(;++A<o&&(E*=256);)b+=this[s+A]*E;return b},u.prototype.readUintBE=u.prototype.readUIntBE=function(s,o,d){s=s>>>0,o=o>>>0,d||D(s,o,this.length);let b=this[s+--o],E=1;for(;o>0&&(E*=256);)b+=this[s+--o]*E;return b},u.prototype.readUint8=u.prototype.readUInt8=function(s,o){return s=s>>>0,o||D(s,1,this.length),this[s]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(s,o){return s=s>>>0,o||D(s,2,this.length),this[s]|this[s+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(s,o){return s=s>>>0,o||D(s,2,this.length),this[s]<<8|this[s+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(s,o){return s=s>>>0,o||D(s,4,this.length),(this[s]|this[s+1]<<8|this[s+2]<<16)+this[s+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(s,o){return s=s>>>0,o||D(s,4,this.length),this[s]*16777216+(this[s+1]<<16|this[s+2]<<8|this[s+3])},u.prototype.readBigUInt64LE=Ge(function(s){s=s>>>0,g(s,"offset");const o=this[s],d=this[s+7];(o===void 0||d===void 0)&&w(s,this.length-8);const b=o+this[++s]*2**8+this[++s]*2**16+this[++s]*2**24,E=this[++s]+this[++s]*2**8+this[++s]*2**16+d*2**24;return BigInt(b)+(BigInt(E)<<BigInt(32))}),u.prototype.readBigUInt64BE=Ge(function(s){s=s>>>0,g(s,"offset");const o=this[s],d=this[s+7];(o===void 0||d===void 0)&&w(s,this.length-8);const b=o*2**24+this[++s]*2**16+this[++s]*2**8+this[++s],E=this[++s]*2**24+this[++s]*2**16+this[++s]*2**8+d;return(BigInt(b)<<BigInt(32))+BigInt(E)}),u.prototype.readIntLE=function(s,o,d){s=s>>>0,o=o>>>0,d||D(s,o,this.length);let b=this[s],E=1,A=0;for(;++A<o&&(E*=256);)b+=this[s+A]*E;return E*=128,b>=E&&(b-=Math.pow(2,8*o)),b},u.prototype.readIntBE=function(s,o,d){s=s>>>0,o=o>>>0,d||D(s,o,this.length);let b=o,E=1,A=this[s+--b];for(;b>0&&(E*=256);)A+=this[s+--b]*E;return E*=128,A>=E&&(A-=Math.pow(2,8*o)),A},u.prototype.readInt8=function(s,o){return s=s>>>0,o||D(s,1,this.length),this[s]&128?(255-this[s]+1)*-1:this[s]},u.prototype.readInt16LE=function(s,o){s=s>>>0,o||D(s,2,this.length);const d=this[s]|this[s+1]<<8;return d&32768?d|4294901760:d},u.prototype.readInt16BE=function(s,o){s=s>>>0,o||D(s,2,this.length);const d=this[s+1]|this[s]<<8;return d&32768?d|4294901760:d},u.prototype.readInt32LE=function(s,o){return s=s>>>0,o||D(s,4,this.length),this[s]|this[s+1]<<8|this[s+2]<<16|this[s+3]<<24},u.prototype.readInt32BE=function(s,o){return s=s>>>0,o||D(s,4,this.length),this[s]<<24|this[s+1]<<16|this[s+2]<<8|this[s+3]},u.prototype.readBigInt64LE=Ge(function(s){s=s>>>0,g(s,"offset");const o=this[s],d=this[s+7];(o===void 0||d===void 0)&&w(s,this.length-8);const b=this[s+4]+this[s+5]*2**8+this[s+6]*2**16+(d<<24);return(BigInt(b)<<BigInt(32))+BigInt(o+this[++s]*2**8+this[++s]*2**16+this[++s]*2**24)}),u.prototype.readBigInt64BE=Ge(function(s){s=s>>>0,g(s,"offset");const o=this[s],d=this[s+7];(o===void 0||d===void 0)&&w(s,this.length-8);const b=(o<<24)+this[++s]*2**16+this[++s]*2**8+this[++s];return(BigInt(b)<<BigInt(32))+BigInt(this[++s]*2**24+this[++s]*2**16+this[++s]*2**8+d)}),u.prototype.readFloatLE=function(s,o){return s=s>>>0,o||D(s,4,this.length),r.read(this,s,!0,23,4)},u.prototype.readFloatBE=function(s,o){return s=s>>>0,o||D(s,4,this.length),r.read(this,s,!1,23,4)},u.prototype.readDoubleLE=function(s,o){return s=s>>>0,o||D(s,8,this.length),r.read(this,s,!0,52,8)},u.prototype.readDoubleBE=function(s,o){return s=s>>>0,o||D(s,8,this.length),r.read(this,s,!1,52,8)};function ne(f,s,o,d,b,E){if(!u.isBuffer(f))throw new TypeError('"buffer" argument must be a Buffer instance');if(s>b||s<E)throw new RangeError('"value" argument is out of bounds');if(o+d>f.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(s,o,d,b){if(s=+s,o=o>>>0,d=d>>>0,!b){const W=Math.pow(2,8*d)-1;ne(this,s,o,d,W,0)}let E=1,A=0;for(this[o]=s&255;++A<d&&(E*=256);)this[o+A]=s/E&255;return o+d},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(s,o,d,b){if(s=+s,o=o>>>0,d=d>>>0,!b){const W=Math.pow(2,8*d)-1;ne(this,s,o,d,W,0)}let E=d-1,A=1;for(this[o+E]=s&255;--E>=0&&(A*=256);)this[o+E]=s/A&255;return o+d},u.prototype.writeUint8=u.prototype.writeUInt8=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,1,255,0),this[o]=s&255,o+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,2,65535,0),this[o]=s&255,this[o+1]=s>>>8,o+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,2,65535,0),this[o]=s>>>8,this[o+1]=s&255,o+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,4,4294967295,0),this[o+3]=s>>>24,this[o+2]=s>>>16,this[o+1]=s>>>8,this[o]=s&255,o+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,4,4294967295,0),this[o]=s>>>24,this[o+1]=s>>>16,this[o+2]=s>>>8,this[o+3]=s&255,o+4};function M(f,s,o,d,b){rt(s,d,b,f,o,7);let E=Number(s&BigInt(4294967295));f[o++]=E,E=E>>8,f[o++]=E,E=E>>8,f[o++]=E,E=E>>8,f[o++]=E;let A=Number(s>>BigInt(32)&BigInt(4294967295));return f[o++]=A,A=A>>8,f[o++]=A,A=A>>8,f[o++]=A,A=A>>8,f[o++]=A,o}function he(f,s,o,d,b){rt(s,d,b,f,o,7);let E=Number(s&BigInt(4294967295));f[o+7]=E,E=E>>8,f[o+6]=E,E=E>>8,f[o+5]=E,E=E>>8,f[o+4]=E;let A=Number(s>>BigInt(32)&BigInt(4294967295));return f[o+3]=A,A=A>>8,f[o+2]=A,A=A>>8,f[o+1]=A,A=A>>8,f[o]=A,o+8}u.prototype.writeBigUInt64LE=Ge(function(s,o=0){return M(this,s,o,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Ge(function(s,o=0){return he(this,s,o,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(s,o,d,b){if(s=+s,o=o>>>0,!b){const ie=Math.pow(2,8*d-1);ne(this,s,o,d,ie-1,-ie)}let E=0,A=1,W=0;for(this[o]=s&255;++E<d&&(A*=256);)s<0&&W===0&&this[o+E-1]!==0&&(W=1),this[o+E]=(s/A>>0)-W&255;return o+d},u.prototype.writeIntBE=function(s,o,d,b){if(s=+s,o=o>>>0,!b){const ie=Math.pow(2,8*d-1);ne(this,s,o,d,ie-1,-ie)}let E=d-1,A=1,W=0;for(this[o+E]=s&255;--E>=0&&(A*=256);)s<0&&W===0&&this[o+E+1]!==0&&(W=1),this[o+E]=(s/A>>0)-W&255;return o+d},u.prototype.writeInt8=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,1,127,-128),s<0&&(s=255+s+1),this[o]=s&255,o+1},u.prototype.writeInt16LE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,2,32767,-32768),this[o]=s&255,this[o+1]=s>>>8,o+2},u.prototype.writeInt16BE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,2,32767,-32768),this[o]=s>>>8,this[o+1]=s&255,o+2},u.prototype.writeInt32LE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,4,2147483647,-2147483648),this[o]=s&255,this[o+1]=s>>>8,this[o+2]=s>>>16,this[o+3]=s>>>24,o+4},u.prototype.writeInt32BE=function(s,o,d){return s=+s,o=o>>>0,d||ne(this,s,o,4,2147483647,-2147483648),s<0&&(s=4294967295+s+1),this[o]=s>>>24,this[o+1]=s>>>16,this[o+2]=s>>>8,this[o+3]=s&255,o+4},u.prototype.writeBigInt64LE=Ge(function(s,o=0){return M(this,s,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Ge(function(s,o=0){return he(this,s,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Te(f,s,o,d,b,E){if(o+d>f.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("Index out of range")}function tt(f,s,o,d,b){return s=+s,o=o>>>0,b||Te(f,s,o,4),r.write(f,s,o,d,23,4),o+4}u.prototype.writeFloatLE=function(s,o,d){return tt(this,s,o,!0,d)},u.prototype.writeFloatBE=function(s,o,d){return tt(this,s,o,!1,d)};function Ke(f,s,o,d,b){return s=+s,o=o>>>0,b||Te(f,s,o,8),r.write(f,s,o,d,52,8),o+8}u.prototype.writeDoubleLE=function(s,o,d){return Ke(this,s,o,!0,d)},u.prototype.writeDoubleBE=function(s,o,d){return Ke(this,s,o,!1,d)},u.prototype.copy=function(s,o,d,b){if(!u.isBuffer(s))throw new TypeError("argument should be a Buffer");if(d||(d=0),!b&&b!==0&&(b=this.length),o>=s.length&&(o=s.length),o||(o=0),b>0&&b<d&&(b=d),b===d||s.length===0||this.length===0)return 0;if(o<0)throw new RangeError("targetStart out of bounds");if(d<0||d>=this.length)throw new RangeError("Index out of range");if(b<0)throw new RangeError("sourceEnd out of bounds");b>this.length&&(b=this.length),s.length-o<b-d&&(b=s.length-o+d);const E=b-d;return this===s&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(o,d,b):Uint8Array.prototype.set.call(s,this.subarray(d,b),o),E},u.prototype.fill=function(s,o,d,b){if(typeof s=="string"){if(typeof o=="string"?(b=o,o=0,d=this.length):typeof d=="string"&&(b=d,d=this.length),b!==void 0&&typeof b!="string")throw new TypeError("encoding must be a string");if(typeof b=="string"&&!u.isEncoding(b))throw new TypeError("Unknown encoding: "+b);if(s.length===1){const A=s.charCodeAt(0);(b==="utf8"&&A<128||b==="latin1")&&(s=A)}}else typeof s=="number"?s=s&255:typeof s=="boolean"&&(s=Number(s));if(o<0||this.length<o||this.length<d)throw new RangeError("Out of range index");if(d<=o)return this;o=o>>>0,d=d===void 0?this.length:d>>>0,s||(s=0);let E;if(typeof s=="number")for(E=o;E<d;++E)this[E]=s;else{const A=u.isBuffer(s)?s:u.from(s,b),W=A.length;if(W===0)throw new TypeError('The value "'+s+'" is invalid for argument "value"');for(E=0;E<d-o;++E)this[E+o]=A[E%W]}return this};const je={};function Ye(f,s,o){je[f]=class extends o{constructor(){super(),Object.defineProperty(this,"message",{value:s.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${f}]`,this.stack,delete this.name}get code(){return f}set code(b){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:b,writable:!0})}toString(){return`${this.name} [${f}]: ${this.message}`}}}Ye("ERR_BUFFER_OUT_OF_BOUNDS",function(f){return f?`${f} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ye("ERR_INVALID_ARG_TYPE",function(f,s){return`The "${f}" argument must be of type number. Received type ${typeof s}`},TypeError),Ye("ERR_OUT_OF_RANGE",function(f,s,o){let d=`The value of "${f}" is out of range.`,b=o;return Number.isInteger(o)&&Math.abs(o)>2**32?b=Pt(String(o)):typeof o=="bigint"&&(b=String(o),(o>BigInt(2)**BigInt(32)||o<-(BigInt(2)**BigInt(32)))&&(b=Pt(b)),b+="n"),d+=` It must be ${s}. Received ${b}`,d},RangeError);function Pt(f){let s="",o=f.length;const d=f[0]==="-"?1:0;for(;o>=d+4;o-=3)s=`_${f.slice(o-3,o)}${s}`;return`${f.slice(0,o)}${s}`}function _t(f,s,o){g(s,"offset"),(f[s]===void 0||f[s+o]===void 0)&&w(s,f.length-(o+1))}function rt(f,s,o,d,b,E){if(f>o||f<s){const A=typeof s=="bigint"?"n":"";let W;throw s===0||s===BigInt(0)?W=`>= 0${A} and < 2${A} ** ${(E+1)*8}${A}`:W=`>= -(2${A} ** ${(E+1)*8-1}${A}) and < 2 ** ${(E+1)*8-1}${A}`,new je.ERR_OUT_OF_RANGE("value",W,f)}_t(d,b,E)}function g(f,s){if(typeof f!="number")throw new je.ERR_INVALID_ARG_TYPE(s,"number",f)}function w(f,s,o){throw Math.floor(f)!==f?(g(f,o),new je.ERR_OUT_OF_RANGE("offset","an integer",f)):s<0?new je.ERR_BUFFER_OUT_OF_BOUNDS:new je.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${s}`,f)}const N=/[^+/0-9A-Za-z-_]/g;function C(f){if(f=f.split("=")[0],f=f.trim().replace(N,""),f.length<2)return"";for(;f.length%4!==0;)f=f+"=";return f}function F(f,s){s=s||1/0;let o;const d=f.length;let b=null;const E=[];for(let A=0;A<d;++A){if(o=f.charCodeAt(A),o>55295&&o<57344){if(!b){if(o>56319){(s-=3)>-1&&E.push(239,191,189);continue}else if(A+1===d){(s-=3)>-1&&E.push(239,191,189);continue}b=o;continue}if(o<56320){(s-=3)>-1&&E.push(239,191,189),b=o;continue}o=(b-55296<<10|o-56320)+65536}else b&&(s-=3)>-1&&E.push(239,191,189);if(b=null,o<128){if((s-=1)<0)break;E.push(o)}else if(o<2048){if((s-=2)<0)break;E.push(o>>6|192,o&63|128)}else if(o<65536){if((s-=3)<0)break;E.push(o>>12|224,o>>6&63|128,o&63|128)}else if(o<1114112){if((s-=4)<0)break;E.push(o>>18|240,o>>12&63|128,o>>6&63|128,o&63|128)}else throw new Error("Invalid code point")}return E}function Z(f){const s=[];for(let o=0;o<f.length;++o)s.push(f.charCodeAt(o)&255);return s}function te(f,s){let o,d,b;const E=[];for(let A=0;A<f.length&&!((s-=2)<0);++A)o=f.charCodeAt(A),d=o>>8,b=o%256,E.push(b),E.push(d);return E}function Y(f){return e.toByteArray(C(f))}function Re(f,s,o,d){let b;for(b=0;b<d&&!(b+o>=s.length||b>=f.length);++b)s[b+o]=f[b];return b}function O(f,s){return f instanceof s||f!=null&&f.constructor!=null&&f.constructor.name!=null&&f.constructor.name===s.name}function Le(f){return f!==f}const Qt=function(){const f="0123456789abcdef",s=new Array(256);for(let o=0;o<16;++o){const d=o*16;for(let b=0;b<16;++b)s[d+b]=f[o]+f[b]}return s}();function Ge(f){return typeof BigInt>"u"?En:f}function En(){throw new Error("BigInt not supported")}})(Fe);/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */let Pn;var no=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:Qs):t=>(Pn||(Pn=Promise.resolve())).then(t).catch(e=>setTimeout(()=>{throw e},0));const io=Vs(no),jt="http://www.w3.org/1999/02/22-rdf-syntax-ns#",Lt="http://www.w3.org/2001/XMLSchema#",Yt="http://www.w3.org/2000/10/swap/",_e={xsd:{decimal:`${Lt}decimal`,boolean:`${Lt}boolean`,double:`${Lt}double`,integer:`${Lt}integer`,string:`${Lt}string`},rdf:{type:`${jt}type`,nil:`${jt}nil`,first:`${jt}first`,rest:`${jt}rest`,langString:`${jt}langString`},owl:{sameAs:"http://www.w3.org/2002/07/owl#sameAs"},r:{forSome:`${Yt}reify#forSome`,forAll:`${Yt}reify#forAll`},log:{implies:`${Yt}log#implies`,isImpliedBy:`${Yt}log#isImpliedBy`}},{xsd:Xt}=_e,so=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\([^])/g,jn={"\\":"\\","'":"'",'"':'"',n:`
7
+ `,r:"\r",t:" ",f:"\f",b:"\b",_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},oo=/[\x00-\x20<>\\"\{\}\|\^\`]/,ao={_iri:!0,_unescapedIri:!0,_simpleQuotedString:!0,_langcode:!0,_blank:!0,_newline:!0,_comment:!0,_whitespace:!0,_endOfFile:!0},lo=/$0^/;class uo{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(const r in this)!(r in ao)&&this[r]instanceof RegExp&&(this[r]=lo)}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 u,p;for(;u=this._newline.exec(n);)this.comments&&(p=this._comment.exec(u[0]))&&a("comment",p[1],"",this._line,u[0].length),n=n.substr(u[0].length,n.length),i=n.length,this._line++;if(!u&&(u=this._whitespace.exec(n))&&(n=n.substr(u[0].length,n.length)),this._endOfFile.test(n))return r&&(this.comments&&(p=this._comment.exec(n))&&a("comment",p[1],"",this._line,n.length),n=null,a("eof","","",this._line,0)),this._input=n;const _=this._line,y=n[0];let x="",I="",S="",R=null,m=0,v=!1;switch(y){case"^":if(n.length<3)break;if(n[1]==="^"){if(this._previousMarker="^^",n=n.substr(2),n[0]!=="<"){v=!0;break}}else{this._n3Mode&&(m=1,x="^");break}case"<":if(R=this._unescapedIri.exec(n))x="IRI",I=R[1];else if(R=this._iri.exec(n)){if(I=this._unescape(R[1]),I===null||oo.test(I))return l(this);x="IRI"}else n.length>1&&n[1]==="<"?(x="<<",m=2):this._n3Mode&&n.length>1&&n[1]==="="&&(m=2,this._isImpliedBy?(x="abbreviation",I="<"):(x="inverse",I=">"));break;case">":n.length>1&&n[1]===">"&&(x=">>",m=2);break;case"_":((R=this._blank.exec(n))||r&&(R=this._blank.exec(`${n} `)))&&(x="blank",S="_",I=R[1]);break;case'"':if(R=this._simpleQuotedString.exec(n))I=R[1];else if({value:I,matchLength:m}=this._parseLiteral(n),I===null)return l(this);(R!==null||m!==0)&&(x="literal",this._literalClosingPos=0);break;case"'":if(!this._lineMode){if(R=this._simpleApostropheString.exec(n))I=R[1];else if({value:I,matchLength:m}=this._parseLiteral(n),I===null)return l(this);(R!==null||m!==0)&&(x="literal",this._literalClosingPos=0)}break;case"?":this._n3Mode&&(R=this._variable.exec(n))&&(x="var",I=R[0]);break;case"@":this._previousMarker==="literal"&&(R=this._langcode.exec(n))?(x="langcode",I=R[1]):(R=this._keyword.exec(n))&&(x=R[0]);break;case".":if(n.length===1?r:n[1]<"0"||n[1]>"9"){x=".",m=1;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":(R=this._number.exec(n)||r&&(R=this._number.exec(`${n} `)))&&(x="literal",I=R[0],S=typeof R[1]=="string"?Xt.double:typeof R[2]=="string"?Xt.decimal:Xt.integer);break;case"B":case"b":case"p":case"P":case"G":case"g":(R=this._sparqlKeyword.exec(n))?x=R[0].toUpperCase():v=!0;break;case"f":case"t":(R=this._boolean.exec(n))?(x="literal",I=R[0],S=Xt.boolean):v=!0;break;case"a":(R=this._shortPredicates.exec(n))?(x="abbreviation",I="a"):v=!0;break;case"=":this._n3Mode&&n.length>1&&(x="abbreviation",n[1]!==">"?(m=1,I="="):(m=2,I=">"));break;case"!":if(!this._n3Mode)break;case",":case";":case"[":case"]":case"(":case")":case"}":this._lineMode||(m=1,x=y);break;case"{":!this._lineMode&&n.length>=2&&(n[1]==="|"?(x="{|",m=2):(x=y,m=1));break;case"|":n.length>=2&&n[1]==="}"&&(x="|}",m=2);break;default:v=!0}if(v&&((this._previousMarker==="@prefix"||this._previousMarker==="PREFIX")&&(R=this._prefix.exec(n))?(x="prefix",I=R[1]||""):((R=this._prefixed.exec(n))||r&&(R=this._prefixed.exec(`${n} `)))&&(x="prefixed",S=R[1]||"",I=this._unescape(R[2]))),this._previousMarker==="^^")switch(x){case"prefixed":x="type";break;case"IRI":x="typeIRI";break;default:x=""}if(!x)return r||!/^'''|^"""/.test(n)&&/\n|\r/.test(n)?l(this):this._input=n;const $=m||R[0].length,B=a(x,I,S,_,$);this.previousToken=B,this._previousMarker=x,n=n.substr($,n.length)}function a(u,p,_,y,x){const I=n?i-n.length:i,S=I+x,R={type:u,value:p,prefix:_,line:y,start:I,end:S};return e(null,R),R}function l(u){e(u._syntaxError(/^\S*/.exec(n)[0]))}}_unescape(e){let r=!1;const n=e.replace(so,(i,a,l,u)=>{if(typeof a=="string")return String.fromCharCode(Number.parseInt(a,16));if(typeof l=="string"){let p=Number.parseInt(l,16);return p<=65535?String.fromCharCode(Number.parseInt(l,16)):String.fromCharCode(55296+((p-=65536)>>10),56320+(p&1023))}return u in jn?jn[u]:(r=!0,"")});return r?null:n}_parseLiteral(e){if(e.length>=3){const r=e.match(/^(?:"""|"|'''|'|)/)[0],n=r.length;let i=Math.max(this._literalClosingPos,n);for(;(i=e.indexOf(r,i))>0;){let a=0;for(;e[i-a-1]==="\\";)a++;if(a%2===0){const l=e.substring(n,i),u=l.split(/\r\n|\r|\n/).length-1,p=i+n;if(n===1&&u!==0||n===3&&this._lineMode)break;return this._line+=u,{value:this._unescape(l),matchLength:p}}i++}this._literalClosingPos=e.length-n+1}return{value:"",matchLength:0}}_syntaxError(e){this._input=null;const 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")io(()=>this._tokenizeToEnd(r,!0));else{const n=[];let i;if(this._tokenizeToEnd((a,l)=>a?i=a:n.push(l),!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=Fe.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)}}const{rdf:fo,xsd:st}=_e;let wt,co=0;const ot={namedNode:$n,blankNode:Bn,variable:kn,literal:Fn,defaultGraph:bo,quad:vr,triple:vr,fromTerm:Bt,fromQuad:Cn};class Be{constructor(e){this.id=e}get value(){return this.id}equals(e){return e instanceof Be?this.id===e.id:!!e&&this.termType===e.termType&&this.value===e.value}hashCode(){return 0}toJSON(){return{termType:this.termType,value:this.value}}}class Tr extends Be{get termType(){return"NamedNode"}}class mt extends Be{get termType(){return"Literal"}get value(){return this.id.substring(1,this.id.lastIndexOf('"'))}get language(){const e=this.id;let r=e.lastIndexOf('"')+1;return r<e.length&&e[r++]==="@"?e.substr(r).toLowerCase():""}get datatype(){return new Tr(this.datatypeString)}get datatypeString(){const e=this.id,r=e.lastIndexOf('"')+1,n=r<e.length?e[r]:"";return n==="^"?e.substr(r+2):n!=="@"?st.string:fo.langString}equals(e){return e instanceof mt?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}}}}class ho extends Be{constructor(e){super(`_:${e}`)}get termType(){return"BlankNode"}get value(){return this.id.substr(2)}}class po extends Be{constructor(e){super(`?${e}`)}get termType(){return"Variable"}get value(){return this.id.substr(1)}}class _o extends Be{constructor(){return super(""),wt||this}get termType(){return"DefaultGraph"}equals(e){return this===e||!!e&&this.termType===e.termType}}wt=new _o;function $t(t,e,r){if(e=e||ot,!t)return e.defaultGraph();switch(t[0]){case"?":return e.variable(t.substr(1));case"_":return e.blankNode(t.substr(2));case'"':if(e===ot)return new mt(t);if(t[t.length-1]==='"')return e.literal(t.substr(1,t.length-2));const 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($t(t[0],e,!0),$t(t[1],e,!0),$t(t[2],e,!0),t[3]&&$t(t[3],e,!0))}function xt(t,e){if(typeof t=="string")return t;if(t instanceof Be&&t.termType!=="Quad")return t.id;if(!t)return wt.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!==st.string?`^^${t.datatype.value}`:""}`;case"Quad":const r=[xt(t.subject,!0),xt(t.predicate,!0),xt(t.object,!0)];return t.graph&&t.graph.termType!=="DefaultGraph"&&r.push(xt(t.graph,!0)),e?r:JSON.stringify(r);default:throw new Error(`Unexpected termType: ${t.termType}`)}}class Ln extends Be{constructor(e,r,n,i){super(""),this._subject=e,this._predicate=r,this._object=n,this._graph=i||wt}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 $n(t){return new Tr(t)}function Bn(t){return new ho(t||`n3-${co++}`)}function Fn(t,e){if(typeof e=="string")return new mt(`"${t}"@${e.toLowerCase()}`);let r=e?e.value:"";return r===""&&(typeof t=="boolean"?r=st.boolean:typeof t=="number"&&(Number.isFinite(t)?r=Number.isInteger(t)?st.integer:st.double:(r=st.double,Number.isNaN(t)||(t=t>0?"INF":"-INF")))),r===""||r===st.string?new mt(`"${t}"`):new mt(`"${t}"^^${r}`)}function kn(t){return new po(t)}function bo(){return wt}function vr(t,e,r,n){return new Ln(t,e,r,n)}function Bt(t){if(t instanceof Be)return t;switch(t.termType){case"NamedNode":return $n(t.value);case"BlankNode":return Bn(t.value);case"Variable":return kn(t.value);case"DefaultGraph":return wt;case"Literal":return Fn(t.value,t.language||t.datatype);case"Quad":return Cn(t);default:throw new Error(`Unexpected termType: ${t.termType}`)}}function Cn(t){if(t instanceof Ln)return t;if(t.termType!=="Quad")throw new Error(`Unexpected termType: ${t.termType}`);return vr(Bt(t.subject),Bt(t.predicate),Bt(t.object),Bt(t.graph))}let On=0;class Mn{constructor(e){this._contextStack=[],this._graph=null,e=e||{},this._setBase(e.baseIRI),e.factory&&Dn(this,e.factory);const r=typeof e.format=="string"?e.format.match(/\w*$/)[0].toLowerCase():"",n=/turtle/.test(r),i=/trig/.test(r),a=/triple/.test(r),l=/quad/.test(r),u=this._n3Mode=/n3/.test(r),p=a||l;(this._supportsNamedGraphs=!(n||u))||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(n||i||a||u),this._isImpliedBy=e.isImpliedBy,this._supportsRDFStar=r===""||/star|\*$/.test(r),p&&(this._resolveRelativeIRI=_=>null),this._blankNodePrefix=typeof e.blankNodePrefix!="string"?"":e.blankNodePrefix.replace(/^(?!_:)/,"_:"),this._lexer=e.lexer||new uo({lineMode:p,n3:u,isImpliedBy:this._isImpliedBy}),this._explicitQuantifiers=!!e.explicitQuantifiers}static _resetBlankNodePrefix(){On=0}_setBase(e){if(!e)this._base="",this._basePath="";else{const 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,a){const l=this._n3Mode;this._contextStack.push({type:e,subject:n,predicate:i,object:a,graph:r,inverse:l?this._inversePredicate:!1,blankPrefix:l?this._prefixes._:"",quantified:l?this._quantified:null}),l&&(this._inversePredicate=!1,this._prefixes._=this._graph?`${this._graph.value}.`:".",this._quantified=Object.create(this._quantified))}_restoreContext(e,r){const 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":const i=this._resolveIRI(e.value);if(i===null)return this._error("Invalid IRI",e);n=this._factory.namedNode(i);break;case"type":case"prefixed":const a=this._prefixes[e.prefix];if(a===void 0)return this._error(`Undefined prefix "${e.prefix}:"`,e);n=this._factory.namedNode(a+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){const 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);const 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;const a=this._subject,l=this._contextStack,u=l[l.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),l.length!==0&&l[l.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()),a===null?u.predicate===null?u.subject=n:u.object=n:this._emit(a,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":const 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){const 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;const i=this._subject,a=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,a&&(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);const l=this._predicate,u=this._object;this._subject=this._factory.quad(i,l,u,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){const l=this._predicate,u=this._object;a?this._emit(u,l,i,n):this._emit(i,l,u,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);const r=this._readEntity(e);return this._prefixes[this._prefix]=r.value,this._prefixCallback(this._prefix,r),this._readDeclarationPunctuation}_readBaseIRI(e){const 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:const r=this._contextStack,n=r.length&&r[r.length-1];if(n&&n.type==="item"){const 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;const 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){const r=this._factory.blankNode();let 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);const 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(){const 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){const n=new Error(`${e} on line ${r.line}.`);n.context={token:r,line:r.line,previousToken:this._lexer.previousToken},this._callback(n),this._callback=Zt}_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;const r=e.length;let n="",i=-1,a=-1,l=0,u="/";for(;i<r;){switch(u){case":":if(a<0&&e[++i]==="/"&&e[++i]==="/")for(;(a=i+1)<r&&e[a]!=="/";)i=a;break;case"?":case"#":i=r;break;case"/":if(e[i+1]===".")switch(u=e[++i+1],u){case"/":n+=e.substring(l,i-1),l=i+1;break;case void 0:case"?":case"#":return n+e.substring(l,i)+e.substr(i+1);case".":if(u=e[++i+1],u===void 0||u==="/"||u==="?"||u==="#"){if(n+=e.substring(l,i-2),(l=n.lastIndexOf("/"))>=a&&(n=n.substr(0,l)),u!=="/")return`${n}/${e.substr(i+1)}`;l=i+1}}}u=e[++i]}return n+e.substring(l)}parse(e,r,n){let i,a,l;if(r&&(r.onQuad||r.onPrefix||r.onComment)?(i=r.onQuad,a=r.onPrefix,l=r.onComment):(i=r,a=n),this._readCallback=this._readInTopContext,this._sparqlStyle=!1,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix?this._blankNodePrefix.substr(2):`b${On++}_`,this._prefixCallback=a||Zt,this._inversePredicate=!1,this._quantified=Object.create(null),!i){const p=[];let _;if(this._callback=(y,x)=>{y?_=y:x&&p.push(x)},this._lexer.tokenize(e).every(y=>this._readCallback=this._readCallback(y)),_)throw _;return p}let u=(p,_)=>{p!==null?(this._callback(p),this._callback=Zt):this._readCallback&&(this._readCallback=this._readCallback(_))};l&&(this._lexer.comments=!0,u=(p,_)=>{p!==null?(this._callback(p),this._callback=Zt):this._readCallback&&(_.type==="comment"?l(_.value):this._readCallback=this._readCallback(_))}),this._callback=i,this._lexer.tokenize(e,u)}}function Zt(){}function Dn(t,e){t._factory=e,t.DEFAULTGRAPH=e.defaultGraph(),t.RDF_FIRST=e.namedNode(_e.rdf.first),t.RDF_REST=e.namedNode(_e.rdf.rest),t.RDF_NIL=e.namedNode(_e.rdf.nil),t.N3_FORALL=e.namedNode(_e.r.forAll),t.N3_FORSOME=e.namedNode(_e.r.forSome),t.ABBREVIATIONS={a:e.namedNode(_e.rdf.type),"=":e.namedNode(_e.owl.sameAs),">":e.namedNode(_e.log.implies),"<":e.namedNode(_e.log.isImpliedBy)},t.QUANTIFIERS_GRAPH=e.namedNode("urn:n3:quantifiers")}Dn(Mn.prototype,ot);function Nr(t){return!!t&&t.termType==="DefaultGraph"}const Ft=ot.defaultGraph(),{rdf:yo,xsd:Et}=_e,Un=/["\\\t\n\r\b\f\u0000-\u0019\ud800-\udbff]/,Wn=/["\\\t\n\r\b\f\u0000-\u0019]|[\ud800-\udbff][\udc00-\udfff]/g,go={"\\":"\\\\",'"':'\\"'," ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};class kt extends Be{equals(e){return e===this}}class Gn{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,a,l){n+=i,l&&l()},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=Ft,this._prefixIRIs=Object.create(null),r.prefixes&&this.addPrefixes(r.prefixes),r.baseIRI&&(this._baseMatcher=new RegExp(`^${qn(r.baseIRI)}${r.baseIRI.endsWith("/")?"":"[#?]"}`),this._baseLength=r.baseIRI.length))}get _inDefaultGraph(){return Ft.equals(this._graph)}_write(e,r){this._outputStream.write(e,"utf8",r)}_writeQuad(e,r,n,i,a){try{i.equals(this._graph)||(this._write((this._subject===null?"":this._inDefaultGraph?`.
8
8
  `:`
9
9
  }
10
- `)+(kt.equals(i)?"":`${this._encodeIriOrBlank(i)} {
10
+ `)+(Ft.equals(i)?"":`${this._encodeIriOrBlank(i)} {
11
11
  `)),this._graph=i,this._subject=null),e.equals(this._subject)?r.equals(this._predicate)?this._write(`, ${this._encodeObject(n)}`,a):this._write(`;
12
12
  ${this._encodePredicate(this._predicate=r)} ${this._encodeObject(n)}`,a):this._write(`${(this._subject===null?"":`.
13
13
  `)+this._encodeSubject(this._subject=e)} ${this._encodePredicate(this._predicate=r)} ${this._encodeObject(n)}`,a)}catch(l){a&&a(l)}}_writeQuadLine(e,r,n,i,a){delete this._prefixMatch,this._write(this.quadToString(e,r,n,i),a)}quadToString(e,r,n,i){return`${this._encodeSubject(e)} ${this._encodeIriOrBlank(r)} ${this._encodeObject(n)}${i&&i.value?` ${this._encodeIriOrBlank(i)} .
14
14
  `:` .
15
- `}`}quadsToString(e){let r="";for(const 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._baseMatcher&&this._baseMatcher.test(r)&&(r=r.substr(this._baseLength)),Qn.test(r)&&(r=r.replace(Vn,Yn));const n=this._prefixRegex.exec(r);return n?n[1]?this._prefixIRIs[n[1]]+n[2]:r:`<${r}>`}_encodeLiteral(e){let r=e.value;if(Qn.test(r)&&(r=r.replace(Vn,Yn)),e.language)return`"${r}"@${e.language}`;if(this._lineMode){if(e.datatype.value===St.string)return`"${r}"`}else switch(e.datatype.value){case St.string:return`"${r}"`;case St.boolean:if(r==="true"||r==="false")return r;break;case St.integer:if(/^[+-]?\d+$/.test(r))return r;break;case St.decimal:if(/^[+-]?\d*\.\d+$/.test(r))return r;break;case St.double:if(/^[+-]?(?:\d+\.\d*|\.?\d+)[eE][+-]?\d+$/.test(r))return r;break}return`"${r}"^^${this._encodeIriOrBlank(e.datatype)}`}_encodePredicate(e){return e.value===jo.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)}${Lr(i)?"":` ${this._encodeIriOrBlank(i)}`}>>`}_blockedWrite(){throw new Error("Cannot write because the writer has been closed.")}addQuad(e,r,n,i,a){n===void 0?this._writeQuad(e.subject,e.predicate,e.object,e.graph,r):typeof i=="function"?this._writeQuad(e,r,n,kt,i):this._writeQuad(e,r,n,i||kt,a)}addQuads(e){for(let r=0;r<e.length;r++)this.addQuad(e[r])}addPrefix(e,r,n){const 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 a=e[i];typeof a!="string"&&(a=a.value),n=!0,this._subject!==null&&(this._write(this._inDefaultGraph?`.
15
+ `}`}quadsToString(e){let r="";for(const 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._baseMatcher&&this._baseMatcher.test(r)&&(r=r.substr(this._baseLength)),Un.test(r)&&(r=r.replace(Wn,zn));const n=this._prefixRegex.exec(r);return n?n[1]?this._prefixIRIs[n[1]]+n[2]:r:`<${r}>`}_encodeLiteral(e){let r=e.value;if(Un.test(r)&&(r=r.replace(Wn,zn)),e.language)return`"${r}"@${e.language}`;if(this._lineMode){if(e.datatype.value===Et.string)return`"${r}"`}else switch(e.datatype.value){case Et.string:return`"${r}"`;case Et.boolean:if(r==="true"||r==="false")return r;break;case Et.integer:if(/^[+-]?\d+$/.test(r))return r;break;case Et.decimal:if(/^[+-]?\d*\.\d+$/.test(r))return r;break;case Et.double:if(/^[+-]?(?:\d+\.\d*|\.?\d+)[eE][+-]?\d+$/.test(r))return r;break}return`"${r}"^^${this._encodeIriOrBlank(e.datatype)}`}_encodePredicate(e){return e.value===yo.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)}${Nr(i)?"":` ${this._encodeIriOrBlank(i)}`}>>`}_blockedWrite(){throw new Error("Cannot write because the writer has been closed.")}addQuad(e,r,n,i,a){n===void 0?this._writeQuad(e.subject,e.predicate,e.object,e.graph,r):typeof i=="function"?this._writeQuad(e,r,n,Ft,i):this._writeQuad(e,r,n,i||Ft,a)}addQuads(e){for(let r=0;r<e.length;r++)this.addQuad(e[r])}addPrefix(e,r,n){const 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 a=e[i];typeof a!="string"&&(a=a.value),n=!0,this._subject!==null&&(this._write(this._inDefaultGraph?`.
16
16
  `:`
17
17
  }
18
18
  `),this._subject=null,this._graph=""),this._prefixIRIs[a]=i+=":",this._write(`@prefix ${i} <${a}>.
19
- `)}if(n){let i="",a="";for(const l in this._prefixIRIs)i+=i?`|${l}`:l,a+=(a?"|":"")+this._prefixIRIs[l];i=Xn(i),this._prefixRegex=new RegExp(`^(?:${a})[^/]*$|^(${i})([_a-zA-Z0-9][\\-_a-zA-Z0-9]*)$`)}this._write(n?`
20
- `:"",r)}blank(e,r){let n=e,i,a;switch(e===void 0?n=[]:e.termType?n=[{predicate:e,object:r}]:"length"in e||(n=[e]),a=n.length){case 0:return new Ct("[]");case 1:if(i=n[0],!(i.object instanceof Ct))return new Ct(`[ ${this._encodePredicate(i.predicate)} ${this._encodeObject(i.object)} ]`);default:let l="[";for(let u=0;u<a;u++)i=n[u],i.predicate.equals(e)?l+=`, ${this._encodeObject(i.object)}`:(l+=`${(u?`;
19
+ `)}if(n){let i="",a="";for(const l in this._prefixIRIs)i+=i?`|${l}`:l,a+=(a?"|":"")+this._prefixIRIs[l];i=qn(i),this._prefixRegex=new RegExp(`^(?:${a})[^/]*$|^(${i})([_a-zA-Z0-9][\\-_a-zA-Z0-9]*)$`)}this._write(n?`
20
+ `:"",r)}blank(e,r){let n=e,i,a;switch(e===void 0?n=[]:e.termType?n=[{predicate:e,object:r}]:"length"in e||(n=[e]),a=n.length){case 0:return new kt("[]");case 1:if(i=n[0],!(i.object instanceof kt))return new kt(`[ ${this._encodePredicate(i.predicate)} ${this._encodeObject(i.object)} ]`);default:let l="[";for(let u=0;u<a;u++)i=n[u],i.predicate.equals(e)?l+=`, ${this._encodeObject(i.object)}`:(l+=`${(u?`;
21
21
  `:`
22
- `)+this._encodePredicate(i.predicate)} ${this._encodeObject(i.object)}`,e=i.predicate);return new Ct(`${l}
23
- ]`)}}list(e){const r=e&&e.length||0,n=new Array(r);for(let i=0;i<r;i++)n[i]=this._encodeObject(e[i]);return new Ct(`(${n.join(" ")})`)}end(e){this._subject!==null&&(this._write(this._inDefaultGraph?`.
22
+ `)+this._encodePredicate(i.predicate)} ${this._encodeObject(i.object)}`,e=i.predicate);return new kt(`${l}
23
+ ]`)}}list(e){const r=e&&e.length||0,n=new Array(r);for(let i=0;i<r;i++)n[i]=this._encodeObject(e[i]);return new kt(`(${n.join(" ")})`)}end(e){this._subject!==null&&(this._write(this._inDefaultGraph?`.
24
24
  `:`
25
25
  }
26
- `),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 Yn(t){let e=Lo[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}function Xn(t){return t.replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&")}var Zn={exports:{}},$r={exports:{}},ce={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},Jn={exports:{}},Ot={exports:{}},ei;function Mt(){if(ei)return Ot.exports;ei=1;const{AbortController:t,AbortSignal:e}=typeof self<"u"?self:typeof window<"u"?window:void 0;return Ot.exports=t,Ot.exports.AbortSignal=e,Ot.exports.default=t,Ot.exports}var Br={exports:{}},It=typeof Reflect=="object"?Reflect:null,ti=It&&typeof It.apply=="function"?It.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Jt;It&&typeof It.ownKeys=="function"?Jt=It.ownKeys:Object.getOwnPropertySymbols?Jt=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Jt=function(e){return Object.getOwnPropertyNames(e)};function $o(t){console&&console.warn&&console.warn(t)}var ri=Number.isNaN||function(e){return e!==e};function X(){X.init.call(this)}Br.exports=X,Br.exports.once=Co,X.EventEmitter=X,X.prototype._events=void 0,X.prototype._eventsCount=0,X.prototype._maxListeners=void 0;var ni=10;function er(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(X,"defaultMaxListeners",{enumerable:!0,get:function(){return ni},set:function(t){if(typeof t!="number"||t<0||ri(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ni=t}}),X.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},X.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||ri(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 ii(t){return t._maxListeners===void 0?X.defaultMaxListeners:t._maxListeners}X.prototype.getMaxListeners=function(){return ii(this)},X.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",a=this._events;if(a!==void 0)i=i&&a.error===void 0;else if(!i)return!1;if(i){var l;if(r.length>0&&(l=r[0]),l instanceof Error)throw l;var u=new Error("Unhandled error."+(l?" ("+l.message+")":""));throw u.context=l,u}var p=a[e];if(p===void 0)return!1;if(typeof p=="function")ti(p,this,r);else for(var _=p.length,y=ui(p,_),n=0;n<_;++n)ti(y[n],this,r);return!0};function si(t,e,r,n){var i,a,l;if(er(r),a=t._events,a===void 0?(a=t._events=Object.create(null),t._eventsCount=0):(a.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),l=a[e]),l===void 0)l=a[e]=r,++t._eventsCount;else if(typeof l=="function"?l=a[e]=n?[r,l]:[l,r]:n?l.unshift(r):l.push(r),i=ii(t),i>0&&l.length>i&&!l.warned){l.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=l.length,$o(u)}return t}X.prototype.addListener=function(e,r){return si(this,e,r,!1)},X.prototype.on=X.prototype.addListener,X.prototype.prependListener=function(e,r){return si(this,e,r,!0)};function Bo(){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 oi(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=Bo.bind(n);return i.listener=r,n.wrapFn=i,i}X.prototype.once=function(e,r){return er(r),this.on(e,oi(this,e,r)),this},X.prototype.prependOnceListener=function(e,r){return er(r),this.prependListener(e,oi(this,e,r)),this},X.prototype.removeListener=function(e,r){var n,i,a,l,u;if(er(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(a=-1,l=n.length-1;l>=0;l--)if(n[l]===r||n[l].listener===r){u=n[l].listener,a=l;break}if(a<0)return this;a===0?n.shift():Fo(n,a),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,u||r)}return this},X.prototype.off=X.prototype.removeListener,X.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 a=Object.keys(n),l;for(i=0;i<a.length;++i)l=a[i],l!=="removeListener"&&this.removeAllListeners(l);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 ai(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?ko(i):ui(i,i.length)}X.prototype.listeners=function(e){return ai(this,e,!0)},X.prototype.rawListeners=function(e){return ai(this,e,!1)},X.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):li.call(t,e)},X.prototype.listenerCount=li;function li(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}X.prototype.eventNames=function(){return this._eventsCount>0?Jt(this._events):[]};function ui(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function Fo(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function ko(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Co(t,e){return new Promise(function(r,n){function i(l){t.removeListener(e,a),n(l)}function a(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}fi(t,e,a,{once:!0}),e!=="error"&&Oo(t,i,{once:!0})})}function Oo(t,e,r){typeof t.on=="function"&&fi(t,"error",e,r)}function fi(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(a){n.once&&t.removeEventListener(e,i),r(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var tr=Br.exports;(function(t){const e=Fe,{kResistStopPropagation:r,SymbolDispose:n}=ce,i=globalThis.AbortSignal||Mt().AbortSignal,a=globalThis.AbortController||Mt().AbortController,l=Object.getPrototypeOf(async function(){}).constructor,u=globalThis.Blob||e.Blob,p=typeof u<"u"?function(m){return m instanceof u}:function(m){return!1},_=(w,m)=>{if(w!==void 0&&(w===null||typeof w!="object"||!("aborted"in w)))throw new ERR_INVALID_ARG_TYPE(m,"AbortSignal",w)},y=(w,m)=>{if(typeof w!="function")throw new ERR_INVALID_ARG_TYPE(m,"Function",w)};class E extends Error{constructor(m){if(!Array.isArray(m))throw new TypeError(`Expected input to be an Array, got ${typeof m}`);let I="";for(let R=0;R<m.length;R++)I+=` ${m[R].stack}
27
- `;super(I),this.name="AggregateError",this.errors=m}}t.exports={AggregateError:E,kEmptyObject:Object.freeze({}),once(w){let m=!1;return function(...I){m||(m=!0,w.apply(this,I))}},createDeferredPromise:function(){let w,m;return{promise:new Promise((R,v)=>{w=R,m=v}),resolve:w,reject:m}},promisify(w){return new Promise((m,I)=>{w((R,...v)=>R?I(R):m(...v))})},debuglog(){return function(){}},format(w,...m){return w.replace(/%([sdifj])/g,function(...[I,R]){const v=m.shift();return R==="f"?v.toFixed(6):R==="j"?JSON.stringify(v):R==="s"&&typeof v=="object"?`${v.constructor!==Object?v.constructor.name:""} {}`.trim():v.toString()})},inspect(w){switch(typeof w){case"string":if(w.includes("'"))if(w.includes('"')){if(!w.includes("`")&&!w.includes("${"))return`\`${w}\``}else return`"${w}"`;return`'${w}'`;case"number":return isNaN(w)?"NaN":Object.is(w,-0)?String(w):w;case"bigint":return`${String(w)}n`;case"boolean":case"undefined":return String(w);case"object":return"{}"}},types:{isAsyncFunction(w){return w instanceof l},isArrayBufferView(w){return ArrayBuffer.isView(w)}},isBlob:p,deprecate(w,m){return w},addAbortListener:tr.addAbortListener||function(m,I){if(m===void 0)throw new ERR_INVALID_ARG_TYPE("signal","AbortSignal",m);_(m,"signal"),y(I,"listener");let R;return m.aborted?queueMicrotask(()=>I()):(m.addEventListener("abort",I,{__proto__:null,once:!0,[r]:!0}),R=()=>{m.removeEventListener("abort",I)}),{__proto__:null,[n](){var v;(v=R)===null||v===void 0||v()}}},AbortSignalAny:i.any||function(m){if(m.length===1)return m[0];const I=new a,R=()=>I.abort();return m.forEach(v=>{_(v,"signals"),v.addEventListener("abort",R,{once:!0})}),I.signal.addEventListener("abort",()=>{m.forEach(v=>v.removeEventListener("abort",R))},{once:!0}),I.signal}},t.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")})(Jn);var Ee=Jn.exports,Fr={};const{format:Mo,inspect:rr,AggregateError:Do}=Ee,Uo=globalThis.AggregateError||Do,Wo=Symbol("kIsNodeError"),Go=["string","function","number","object","Function","Object","boolean","bigint","symbol"],zo=/^([A-Z][a-z0-9]*)+$/,qo="__node_internal_",nr={};function at(t,e){if(!t)throw new nr.ERR_INTERNAL_ASSERTION(e)}function ci(t){let e="",r=t.length;const 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 Ho(t,e,r){if(typeof e=="function")return at(e.length<=r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${e.length}).`),e(...r);const n=(e.match(/%[dfijoOs]/g)||[]).length;return at(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:Mo(e,...r)}function _e(t,e,r){r||(r=Error);class n extends r{constructor(...a){super(Ho(t,e,a))}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[Wo]=!0,nr[t]=n}function di(t){const e=qo+t.name;return Object.defineProperty(t,"name",{value:e}),t}function Qo(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;const r=new Uo([e,t],e.message);return r.code=e.code,r}return t||e}let Vo=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new nr.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};_e("ERR_ASSERTION","%s",Error),_e("ERR_INVALID_ARG_TYPE",(t,e,r)=>{at(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 ";const i=[],a=[],l=[];for(const p of e)at(typeof p=="string","All expected entries have to be of type string"),Go.includes(p)?i.push(p.toLowerCase()):zo.test(p)?a.push(p):(at(p!=="object",'The value "object" should be written as "Object"'),l.push(p));if(a.length>0){const p=i.indexOf("object");p!==-1&&(i.splice(i,p,1),a.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:{const p=i.pop();n+=`one of type ${i.join(", ")}, or ${p}`}}(a.length>0||l.length>0)&&(n+=" or ")}if(a.length>0){switch(a.length){case 1:n+=`an instance of ${a[0]}`;break;case 2:n+=`an instance of ${a[0]} or ${a[1]}`;break;default:{const p=a.pop();n+=`an instance of ${a.join(", ")}, or ${p}`}}l.length>0&&(n+=" or ")}switch(l.length){case 0:break;case 1:l[0].toLowerCase()!==l[0]&&(n+="an "),n+=`${l[0]}`;break;case 2:n+=`one of ${l[0]} or ${l[1]}`;break;default:{const p=l.pop();n+=`one of ${l.join(", ")}, or ${p}`}}if(r==null)n+=`. Received ${r}`;else if(typeof r=="function"&&r.name)n+=`. Received function ${r.name}`;else if(typeof r=="object"){var u;if((u=r.constructor)!==null&&u!==void 0&&u.name)n+=`. Received an instance of ${r.constructor.name}`;else{const p=rr(r,{depth:-1});n+=`. Received ${p}`}}else{let p=rr(r,{colors:!1});p.length>25&&(p=`${p.slice(0,25)}...`),n+=`. Received type ${typeof r} (${p})`}return n},TypeError),_e("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=rr(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError),_e("ERR_INVALID_RETURN_VALUE",(t,e,r)=>{var n;const 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),_e("ERR_MISSING_ARGS",(...t)=>{at(t.length>0,"At least one arg needs to be specified");let e;const 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:{const n=t.pop();e+=`The ${t.join(", ")}, and ${n} arguments`}break}return`${e} must be specified`},TypeError),_e("ERR_OUT_OF_RANGE",(t,e,r)=>{at(e,'Missing "range" argument');let n;return Number.isInteger(r)&&Math.abs(r)>2**32?n=ci(String(r)):typeof r=="bigint"?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=ci(n)),n+="n"):n=rr(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError),_e("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),_e("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),_e("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),_e("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),_e("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),_e("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),_e("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),_e("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),_e("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),_e("ERR_STREAM_WRITE_AFTER_END","write after end",Error),_e("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);var Ie={AbortError:Vo,aggregateTwoErrors:di(Qo),hideStackFrames:di,codes:nr};const{ArrayIsArray:kr,ArrayPrototypeIncludes:hi,ArrayPrototypeJoin:pi,ArrayPrototypeMap:Ko,NumberIsInteger:Cr,NumberIsNaN:Yo,NumberMAX_SAFE_INTEGER:Xo,NumberMIN_SAFE_INTEGER:Zo,NumberParseInt:Jo,ObjectPrototypeHasOwnProperty:ea,RegExpPrototypeExec:_i,String:ta,StringPrototypeToUpperCase:ra,StringPrototypeTrim:na}=ce,{hideStackFrames:je,codes:{ERR_SOCKET_BAD_PORT:ia,ERR_INVALID_ARG_TYPE:ge,ERR_INVALID_ARG_VALUE:Rt,ERR_OUT_OF_RANGE:lt,ERR_UNKNOWN_SIGNAL:bi}}=Ie,{normalizeEncoding:sa}=Ee,{isAsyncFunction:oa,isArrayBufferView:aa}=Ee.types,yi={};function la(t){return t===(t|0)}function ua(t){return t===t>>>0}const fa=/^[0-7]+$/,ca="must be a 32-bit unsigned integer or an octal string";function da(t,e,r){if(typeof t>"u"&&(t=r),typeof t=="string"){if(_i(fa,t)===null)throw new Rt(e,t,ca);t=Jo(t,8)}return gi(t,e),t}const ha=je((t,e,r=Zo,n=Xo)=>{if(typeof t!="number")throw new ge(e,"number",t);if(!Cr(t))throw new lt(e,"an integer",t);if(t<r||t>n)throw new lt(e,`>= ${r} && <= ${n}`,t)}),pa=je((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new ge(e,"number",t);if(!Cr(t))throw new lt(e,"an integer",t);if(t<r||t>n)throw new lt(e,`>= ${r} && <= ${n}`,t)}),gi=je((t,e,r=!1)=>{if(typeof t!="number")throw new ge(e,"number",t);if(!Cr(t))throw new lt(e,"an integer",t);const n=r?1:0,i=4294967295;if(t<n||t>i)throw new lt(e,`>= ${n} && <= ${i}`,t)});function Or(t,e){if(typeof t!="string")throw new ge(e,"string",t)}function _a(t,e,r=void 0,n){if(typeof t!="number")throw new ge(e,"number",t);if(r!=null&&t<r||n!=null&&t>n||(r!=null||n!=null)&&Yo(t))throw new lt(e,`${r!=null?`>= ${r}`:""}${r!=null&&n!=null?" && ":""}${n!=null?`<= ${n}`:""}`,t)}const ba=je((t,e,r)=>{if(!hi(r,t)){const i="must be one of: "+pi(Ko(r,a=>typeof a=="string"?`'${a}'`:ta(a)),", ");throw new Rt(e,t,i)}});function wi(t,e){if(typeof t!="boolean")throw new ge(e,"boolean",t)}function Mr(t,e,r){return t==null||!ea(t,e)?r:t[e]}const ya=je((t,e,r=null)=>{const n=Mr(r,"allowArray",!1),i=Mr(r,"allowFunction",!1);if(!Mr(r,"nullable",!1)&&t===null||!n&&kr(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new ge(e,"Object",t)}),ga=je((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new ge(e,"a dictionary",t)}),ir=je((t,e,r=0)=>{if(!kr(t))throw new ge(e,"Array",t);if(t.length<r){const n=`must be longer than ${r}`;throw new Rt(e,t,n)}});function wa(t,e){ir(t,e);for(let r=0;r<t.length;r++)Or(t[r],`${e}[${r}]`)}function ma(t,e){ir(t,e);for(let r=0;r<t.length;r++)wi(t[r],`${e}[${r}]`)}function xa(t,e){ir(t,e);for(let r=0;r<t.length;r++){const n=t[r],i=`${e}[${r}]`;if(n==null)throw new ge(i,"AbortSignal",n);mi(n,i)}}function Ea(t,e="signal"){if(Or(t,e),yi[t]===void 0)throw yi[ra(t)]!==void 0?new bi(t+" (signals must use all capital letters)"):new bi(t)}const Sa=je((t,e="buffer")=>{if(!aa(t))throw new ge(e,["Buffer","TypedArray","DataView"],t)});function Ia(t,e){const r=sa(e),n=t.length;if(r==="hex"&&n%2!==0)throw new Rt("encoding",e,`is invalid for data of length ${n}`)}function Ra(t,e="Port",r=!0){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&na(t).length===0||+t!==+t>>>0||t>65535||t===0&&!r)throw new ia(e,t,r);return t|0}const mi=je((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new ge(e,"AbortSignal",t)}),Aa=je((t,e)=>{if(typeof t!="function")throw new ge(e,"Function",t)}),Ta=je((t,e)=>{if(typeof t!="function"||oa(t))throw new ge(e,"Function",t)}),va=je((t,e)=>{if(t!==void 0)throw new ge(e,"undefined",t)});function Na(t,e,r){if(!hi(r,t))throw new ge(e,`('${pi(r,"|")}')`,t)}const Pa=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function xi(t,e){if(typeof t>"u"||!_i(Pa,t))throw new Rt(e,t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}function ja(t){if(typeof t=="string")return xi(t,"hints"),t;if(kr(t)){const e=t.length;let r="";if(e===0)return r;for(let n=0;n<e;n++){const i=t[n];xi(i,"hints"),r+=i,n!==e-1&&(r+=", ")}return r}throw new Rt("hints",t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}var Dt={isInt32:la,isUint32:ua,parseFileMode:da,validateArray:ir,validateStringArray:wa,validateBooleanArray:ma,validateAbortSignalArray:xa,validateBoolean:wi,validateBuffer:Sa,validateDictionary:ga,validateEncoding:Ia,validateFunction:Aa,validateInt32:pa,validateInteger:ha,validateNumber:_a,validateObject:ya,validateOneOf:ba,validatePlainFunction:Ta,validatePort:Ra,validateSignalName:Ea,validateString:Or,validateUint32:gi,validateUndefined:va,validateUnion:Na,validateAbortSignal:mi,validateLinkHeaderValue:ja},Dr={exports:{}},Ei={exports:{}},he=Ei.exports={},Ce,Oe;function Ur(){throw new Error("setTimeout has not been defined")}function Wr(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Ce=setTimeout:Ce=Ur}catch{Ce=Ur}try{typeof clearTimeout=="function"?Oe=clearTimeout:Oe=Wr}catch{Oe=Wr}})();function Si(t){if(Ce===setTimeout)return setTimeout(t,0);if((Ce===Ur||!Ce)&&setTimeout)return Ce=setTimeout,setTimeout(t,0);try{return Ce(t,0)}catch{try{return Ce.call(null,t,0)}catch{return Ce.call(this,t,0)}}}function La(t){if(Oe===clearTimeout)return clearTimeout(t);if((Oe===Wr||!Oe)&&clearTimeout)return Oe=clearTimeout,clearTimeout(t);try{return Oe(t)}catch{try{return Oe.call(null,t)}catch{return Oe.call(this,t)}}}var ze=[],At=!1,ut,sr=-1;function $a(){!At||!ut||(At=!1,ut.length?ze=ut.concat(ze):sr=-1,ze.length&&Ii())}function Ii(){if(!At){var t=Si($a);At=!0;for(var e=ze.length;e;){for(ut=ze,ze=[];++sr<e;)ut&&ut[sr].run();sr=-1,e=ze.length}ut=null,At=!1,La(t)}}he.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];ze.push(new Ri(t,e)),ze.length===1&&!At&&Si(Ii)};function Ri(t,e){this.fun=t,this.array=e}Ri.prototype.run=function(){this.fun.apply(null,this.array)},he.title="browser",he.browser=!0,he.env={},he.argv=[],he.version="",he.versions={};function qe(){}he.on=qe,he.addListener=qe,he.once=qe,he.off=qe,he.removeListener=qe,he.removeAllListeners=qe,he.emit=qe,he.prependListener=qe,he.prependOnceListener=qe,he.listeners=function(t){return[]},he.binding=function(t){throw new Error("process.binding is not supported")},he.cwd=function(){return"/"},he.chdir=function(t){throw new Error("process.chdir is not supported")},he.umask=function(){return 0};var ft=Ei.exports;const{SymbolAsyncIterator:Ai,SymbolIterator:Ti,SymbolFor:ct}=ce,vi=ct("nodejs.stream.destroyed"),Ni=ct("nodejs.stream.errored"),Gr=ct("nodejs.stream.readable"),zr=ct("nodejs.stream.writable"),Pi=ct("nodejs.stream.disturbed"),Ba=ct("nodejs.webstream.isClosedPromise"),Fa=ct("nodejs.webstream.controllerErrorFunction");function or(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 ar(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 ka(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function Me(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function ji(t){return!!(t&&!Me(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function Li(t){return!!(t&&!Me(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function $i(t){return!!(t&&!Me(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function Ca(t){return ji(t)||Li(t)||$i(t)}function Oa(t,e){return t==null?!1:e===!0?typeof t[Ai]=="function":e===!1?typeof t[Ti]=="function":typeof t[Ai]=="function"||typeof t[Ti]=="function"}function lr(t){if(!Me(t))return null;const e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[vi]||n!=null&&n.destroyed)}function Bi(t){if(!ar(t))return null;if(t.writableEnded===!0)return!0;const e=t._writableState;return e!=null&&e.errored?!1:typeof(e==null?void 0:e.ended)!="boolean"?null:e.ended}function Ma(t,e){if(!ar(t))return null;if(t.writableFinished===!0)return!0;const r=t._writableState;return r!=null&&r.errored?!1:typeof(r==null?void 0:r.finished)!="boolean"?null:!!(r.finished||e===!1&&r.ended===!0&&r.length===0)}function Da(t){if(!or(t))return null;if(t.readableEnded===!0)return!0;const e=t._readableState;return!e||e.errored?!1:typeof(e==null?void 0:e.ended)!="boolean"?null:e.ended}function Fi(t,e){if(!or(t))return null;const r=t._readableState;return r!=null&&r.errored?!1:typeof(r==null?void 0:r.endEmitted)!="boolean"?null:!!(r.endEmitted||e===!1&&r.ended===!0&&r.length===0)}function ki(t){return t&&t[Gr]!=null?t[Gr]:typeof(t==null?void 0:t.readable)!="boolean"?null:lr(t)?!1:or(t)&&t.readable&&!Fi(t)}function Ci(t){return t&&t[zr]!=null?t[zr]:typeof(t==null?void 0:t.writable)!="boolean"?null:lr(t)?!1:ar(t)&&t.writable&&!Bi(t)}function Ua(t,e){return Me(t)?lr(t)?!0:!((e==null?void 0:e.readable)!==!1&&ki(t)||(e==null?void 0:e.writable)!==!1&&Ci(t)):null}function Wa(t){var e,r;return Me(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 Ga(t){var e,r;return Me(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 za(t){if(!Me(t))return null;if(typeof t.closed=="boolean")return t.closed;const e=t._writableState,r=t._readableState;return typeof(e==null?void 0:e.closed)=="boolean"||typeof(r==null?void 0:r.closed)=="boolean"?(e==null?void 0:e.closed)||(r==null?void 0:r.closed):typeof t._closed=="boolean"&&Oi(t)?t._closed:null}function Oi(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function Mi(t){return typeof t._sent100=="boolean"&&Oi(t)}function qa(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 Ha(t){if(!Me(t))return null;const e=t._writableState,r=t._readableState,n=e||r;return!n&&Mi(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function Qa(t){var e;return!!(t&&((e=t[Pi])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function Va(t){var e,r,n,i,a,l,u,p,_,y;return!!(t&&((e=(r=(n=(i=(a=(l=t[Ni])!==null&&l!==void 0?l:t.readableErrored)!==null&&a!==void 0?a:t.writableErrored)!==null&&i!==void 0?i:(u=t._readableState)===null||u===void 0?void 0:u.errorEmitted)!==null&&n!==void 0?n:(p=t._writableState)===null||p===void 0?void 0:p.errorEmitted)!==null&&r!==void 0?r:(_=t._readableState)===null||_===void 0?void 0:_.errored)!==null&&e!==void 0?e:!((y=t._writableState)===null||y===void 0)&&y.errored))}var He={isDestroyed:lr,kIsDestroyed:vi,isDisturbed:Qa,kIsDisturbed:Pi,isErrored:Va,kIsErrored:Ni,isReadable:ki,kIsReadable:Gr,kIsClosedPromise:Ba,kControllerErrorFunction:Fa,kIsWritable:zr,isClosed:za,isDuplexNodeStream:ka,isFinished:Ua,isIterable:Oa,isReadableNodeStream:or,isReadableStream:ji,isReadableEnded:Da,isReadableFinished:Fi,isReadableErrored:Ga,isNodeStream:Me,isWebStream:Ca,isWritable:Ci,isWritableNodeStream:ar,isWritableStream:Li,isWritableEnded:Bi,isWritableFinished:Ma,isWritableErrored:Wa,isServerRequest:qa,isServerResponse:Mi,willEmitClose:Ha,isTransformStream:$i};const et=ft,{AbortError:Di,codes:Ka}=Ie,{ERR_INVALID_ARG_TYPE:Ya,ERR_STREAM_PREMATURE_CLOSE:Ui}=Ka,{kEmptyObject:qr,once:Hr}=Ee,{validateAbortSignal:Xa,validateFunction:Za,validateObject:Ja,validateBoolean:el}=Dt,{Promise:tl,PromisePrototypeThen:rl,SymbolDispose:Wi}=ce,{isClosed:nl,isReadable:Gi,isReadableNodeStream:Qr,isReadableStream:il,isReadableFinished:zi,isReadableErrored:qi,isWritable:Hi,isWritableNodeStream:Qi,isWritableStream:sl,isWritableFinished:Vi,isWritableErrored:Ki,isNodeStream:ol,willEmitClose:al,kIsClosedPromise:ll}=He;let Tt;function ul(t){return t.setHeader&&typeof t.abort=="function"}const Vr=()=>{};function Yi(t,e,r){var n,i;if(arguments.length===2?(r=e,e=qr):e==null?e=qr:Ja(e,"options"),Za(r,"callback"),Xa(e.signal,"options.signal"),r=Hr(r),il(t)||sl(t))return fl(t,e,r);if(!ol(t))throw new Ya("stream",["ReadableStream","WritableStream","Stream"],t);const a=(n=e.readable)!==null&&n!==void 0?n:Qr(t),l=(i=e.writable)!==null&&i!==void 0?i:Qi(t),u=t._writableState,p=t._readableState,_=()=>{t.writable||w()};let y=al(t)&&Qr(t)===a&&Qi(t)===l,E=Vi(t,!1);const w=()=>{E=!0,t.destroyed&&(y=!1),!(y&&(!t.readable||a))&&(!a||m)&&r.call(t)};let m=zi(t,!1);const I=()=>{m=!0,t.destroyed&&(y=!1),!(y&&(!t.writable||l))&&(!l||E)&&r.call(t)},R=U=>{r.call(t,U)};let v=nl(t);const k=()=>{v=!0;const U=Ki(t)||qi(t);if(U&&typeof U!="boolean")return r.call(t,U);if(a&&!m&&Qr(t,!0)&&!zi(t,!1))return r.call(t,new Ui);if(l&&!E&&!Vi(t,!1))return r.call(t,new Ui);r.call(t)},O=()=>{v=!0;const U=Ki(t)||qi(t);if(U&&typeof U!="boolean")return r.call(t,U);r.call(t)},T=()=>{t.req.on("finish",w)};ul(t)?(t.on("complete",w),y||t.on("abort",k),t.req?T():t.on("request",T)):l&&!u&&(t.on("end",_),t.on("close",_)),!y&&typeof t.aborted=="boolean"&&t.on("aborted",k),t.on("end",I),t.on("finish",w),e.error!==!1&&t.on("error",R),t.on("close",k),v?et.nextTick(k):u!=null&&u.errorEmitted||p!=null&&p.errorEmitted?y||et.nextTick(O):(!a&&(!y||Gi(t))&&(E||Hi(t)===!1)||!l&&(!y||Hi(t))&&(m||Gi(t)===!1)||p&&t.req&&t.aborted)&&et.nextTick(O);const q=()=>{r=Vr,t.removeListener("aborted",k),t.removeListener("complete",w),t.removeListener("abort",k),t.removeListener("request",T),t.req&&t.req.removeListener("finish",w),t.removeListener("end",_),t.removeListener("close",_),t.removeListener("finish",w),t.removeListener("end",I),t.removeListener("error",R),t.removeListener("close",k)};if(e.signal&&!v){const U=()=>{const oe=r;q(),oe.call(t,new Di(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)et.nextTick(U);else{Tt=Tt||Ee.addAbortListener;const oe=Tt(e.signal,U),Se=r;r=Hr((...ee)=>{oe[Wi](),Se.apply(t,ee)})}}return q}function fl(t,e,r){let n=!1,i=Vr;if(e.signal)if(i=()=>{n=!0,r.call(t,new Di(void 0,{cause:e.signal.reason}))},e.signal.aborted)et.nextTick(i);else{Tt=Tt||Ee.addAbortListener;const l=Tt(e.signal,i),u=r;r=Hr((...p)=>{l[Wi](),u.apply(t,p)})}const a=(...l)=>{n||et.nextTick(()=>r.apply(t,l))};return rl(t[ll].promise,a,a),Vr}function cl(t,e){var r;let n=!1;return e===null&&(e=qr),(r=e)!==null&&r!==void 0&&r.cleanup&&(el(e.cleanup,"cleanup"),n=e.cleanup),new tl((i,a)=>{const l=Yi(t,e,u=>{n&&l(),u?a(u):i()})})}Dr.exports=Yi,Dr.exports.finished=cl;var tt=Dr.exports;const De=ft,{aggregateTwoErrors:dl,codes:{ERR_MULTIPLE_CALLBACK:hl},AbortError:pl}=Ie,{Symbol:Xi}=ce,{kIsDestroyed:_l,isDestroyed:bl,isFinished:yl,isServerRequest:gl}=He,Zi=Xi("kDestroy"),Kr=Xi("kConstruct");function Ji(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function wl(t,e){const r=this._readableState,n=this._writableState,i=n||r;return n!=null&&n.destroyed||r!=null&&r.destroyed?(typeof e=="function"&&e(),this):(Ji(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?es(this,t,e):this.once(Zi,function(a){es(this,dl(a,t),e)}),this)}function es(t,e,r){let n=!1;function i(a){if(n)return;n=!0;const l=t._readableState,u=t._writableState;Ji(a,u,l),u&&(u.closed=!0),l&&(l.closed=!0),typeof r=="function"&&r(a),a?De.nextTick(ml,t,a):De.nextTick(ts,t)}try{t._destroy(e||null,i)}catch(a){i(a)}}function ml(t,e){Yr(t,e),ts(t)}function ts(t){const 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 Yr(t,e){const 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 xl(){const 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 Xr(t,e,r){const 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?De.nextTick(Yr,t,e):Yr(t,e))}function El(t,e){if(typeof t._construct!="function")return;const r=t._readableState,n=t._writableState;r&&(r.constructed=!1),n&&(n.constructed=!1),t.once(Kr,e),!(t.listenerCount(Kr)>1)&&De.nextTick(Sl,t)}function Sl(t){let e=!1;function r(n){if(e){Xr(t,n??new hl);return}e=!0;const i=t._readableState,a=t._writableState,l=a||i;i&&(i.constructed=!0),a&&(a.constructed=!0),l.destroyed?t.emit(Zi,n):n?Xr(t,n,!0):De.nextTick(Il,t)}try{t._construct(n=>{De.nextTick(r,n)})}catch(n){De.nextTick(r,n)}}function Il(t){t.emit(Kr)}function rs(t){return(t==null?void 0:t.setHeader)&&typeof t.abort=="function"}function ns(t){t.emit("close")}function Rl(t,e){t.emit("error",e),De.nextTick(ns,t)}function Al(t,e){!t||bl(t)||(!e&&!yl(t)&&(e=new pl),gl(t)?(t.socket=null,t.destroy(e)):rs(t)?t.abort():rs(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?De.nextTick(Rl,t,e):De.nextTick(ns,t),t.destroyed||(t[_l]=!0))}var vt={construct:El,destroyer:Al,destroy:wl,undestroy:xl,errorOrDestroy:Xr};const{ArrayIsArray:Tl,ObjectSetPrototypeOf:is}=ce,{EventEmitter:ur}=tr;function fr(t){ur.call(this,t)}is(fr.prototype,ur.prototype),is(fr,ur),fr.prototype.pipe=function(t,e){const r=this;function n(y){t.writable&&t.write(y)===!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",l),r.on("close",u));let a=!1;function l(){a||(a=!0,t.end())}function u(){a||(a=!0,typeof t.destroy=="function"&&t.destroy())}function p(y){_(),ur.listenerCount(this,"error")===0&&this.emit("error",y)}Zr(r,"error",p),Zr(t,"error",p);function _(){r.removeListener("data",n),t.removeListener("drain",i),r.removeListener("end",l),r.removeListener("close",u),r.removeListener("error",p),t.removeListener("error",p),r.removeListener("end",_),r.removeListener("close",_),t.removeListener("close",_)}return r.on("end",_),r.on("close",_),t.on("close",_),t.emit("pipe",r),t};function Zr(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):Tl(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}var Jr={Stream:fr,prependListener:Zr},ss={exports:{}};(function(t){const{SymbolDispose:e}=ce,{AbortError:r,codes:n}=Ie,{isNodeStream:i,isWebStream:a,kControllerErrorFunction:l}=He,u=tt,{ERR_INVALID_ARG_TYPE:p}=n;let _;const y=(E,w)=>{if(typeof E!="object"||!("aborted"in E))throw new p(w,"AbortSignal",E)};t.exports.addAbortSignal=function(w,m){if(y(w,"signal"),!i(m)&&!a(m))throw new p("stream",["ReadableStream","WritableStream","Stream"],m);return t.exports.addAbortSignalNoValidate(w,m)},t.exports.addAbortSignalNoValidate=function(E,w){if(typeof E!="object"||!("aborted"in E))return w;const m=i(w)?()=>{w.destroy(new r(void 0,{cause:E.reason}))}:()=>{w[l](new r(void 0,{cause:E.reason}))};if(E.aborted)m();else{_=_||Ee.addAbortListener;const I=_(E,m);u(w,I[e])}return w}})(ss);var cr=ss.exports;const{StringPrototypeSlice:os,SymbolIterator:vl,TypedArrayPrototypeSet:dr,Uint8Array:Nl}=ce,{Buffer:en}=Fe,{inspect:Pl}=Ee;var jl=class{constructor(){this.head=null,this.tail=null,this.length=0}push(e){const r={data:e,next:null};this.length>0?this.tail.next=r:this.head=r,this.tail=r,++this.length}unshift(e){const r={data:e,next:this.head};this.length===0&&(this.tail=r),this.head=r,++this.length}shift(){if(this.length===0)return;const 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 en.alloc(0);const r=en.allocUnsafe(e>>>0);let n=this.head,i=0;for(;n;)dr(r,n.data,i),i+=n.data.length,n=n.next;return r}consume(e,r){const n=this.head.data;if(e<n.length){const 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}*[vl](){for(let e=this.head;e;e=e.next)yield e.data}_getString(e){let r="",n=this.head,i=0;do{const a=n.data;if(e>a.length)r+=a,e-=a.length;else{e===a.length?(r+=a,++i,n.next?this.head=n.next:this.head=this.tail=null):(r+=os(a,0,e),this.head=n,n.data=os(a,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){const r=en.allocUnsafe(e),n=e;let i=this.head,a=0;do{const l=i.data;if(e>l.length)dr(r,l,n-e),e-=l.length;else{e===l.length?(dr(r,l,n-e),++a,i.next?this.head=i.next:this.head=this.tail=null):(dr(r,new Nl(l.buffer,l.byteOffset,e),n-e),this.head=i,i.data=l.slice(e));break}++a}while((i=i.next)!==null);return this.length-=a,r}[Symbol.for("nodejs.util.inspect.custom")](e,r){return Pl(this,{...r,depth:0,customInspect:!1})}};const{MathFloor:Ll,NumberIsInteger:$l}=ce,{validateInteger:Bl}=Dt,{ERR_INVALID_ARG_VALUE:Fl}=Ie.codes;let as=16*1024,ls=16;function kl(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function us(t){return t?ls:as}function Cl(t,e){Bl(e,"value",0),t?ls=e:as=e}function Ol(t,e,r,n){const i=kl(e,n,r);if(i!=null){if(!$l(i)||i<0){const a=n?`options.${r}`:"options.highWaterMark";throw new Fl(a,i)}return Ll(i)}return us(t.objectMode)}var hr={getHighWaterMark:Ol,getDefaultHighWaterMark:us,setDefaultHighWaterMark:Cl},fs={},tn={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(t,e){var r=Fe,n=r.Buffer;function i(l,u){for(var p in l)u[p]=l[p]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=r:(i(r,e),e.Buffer=a);function a(l,u,p){return n(l,u,p)}a.prototype=Object.create(n.prototype),i(n,a),a.from=function(l,u,p){if(typeof l=="number")throw new TypeError("Argument must not be a number");return n(l,u,p)},a.alloc=function(l,u,p){if(typeof l!="number")throw new TypeError("Argument must be a number");var _=n(l);return u!==void 0?typeof p=="string"?_.fill(u,p):_.fill(u):_.fill(0),_},a.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return n(l)},a.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(l)}})(tn,tn.exports);var Ml=tn.exports,rn=Ml.Buffer,cs=rn.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 Dl(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 Ul(t){var e=Dl(t);if(typeof e!="string"&&(rn.isEncoding===cs||!cs(t)))throw new Error("Unknown encoding: "+t);return e||t}fs.StringDecoder=Ut;function Ut(t){this.encoding=Ul(t);var e;switch(this.encoding){case"utf16le":this.text=Ql,this.end=Vl,e=4;break;case"utf8":this.fillLast=zl,e=4;break;case"base64":this.text=Kl,this.end=Yl,e=3;break;default:this.write=Xl,this.end=Zl;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=rn.allocUnsafe(e)}Ut.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||""},Ut.prototype.end=Hl,Ut.prototype.text=ql,Ut.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 nn(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function Wl(t,e,r){var n=e.length-1;if(n<r)return 0;var i=nn(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||i===-2?0:(i=nn(e[n]),i>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||i===-2?0:(i=nn(e[n]),i>=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function Gl(t,e,r){if((e[0]&192)!==128)return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"�"}}function zl(t){var e=this.lastTotal-this.lastNeed,r=Gl(this,t);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 ql(t,e){var r=Wl(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 Hl(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e}function Ql(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 Vl(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 Kl(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 Yl(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function Xl(t){return t.toString(this.encoding)}function Zl(t){return t&&t.length?this.write(t):""}const ds=ft,{PromisePrototypeThen:Jl,SymbolAsyncIterator:hs,SymbolIterator:ps}=ce,{Buffer:eu}=Fe,{ERR_INVALID_ARG_TYPE:tu,ERR_STREAM_NULL_VALUES:ru}=Ie.codes;function nu(t,e,r){let n;if(typeof e=="string"||e instanceof eu)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[hs])i=!0,n=e[hs]();else if(e&&e[ps])i=!1,n=e[ps]();else throw new tu("iterable",["Iterable"],e);const a=new t({objectMode:!0,highWaterMark:1,...r});let l=!1;a._read=function(){l||(l=!0,p())},a._destroy=function(_,y){Jl(u(_),()=>ds.nextTick(y,_),E=>ds.nextTick(y,E||_))};async function u(_){const y=_!=null,E=typeof n.throw=="function";if(y&&E){const{value:w,done:m}=await n.throw(_);if(await w,m)return}if(typeof n.return=="function"){const{value:w}=await n.return();await w}}async function p(){for(;;){try{const{value:_,done:y}=i?await n.next():n.next();if(y)a.push(null);else{const E=_&&typeof _.then=="function"?await _:_;if(E===null)throw l=!1,new ru;if(a.push(E))continue;l=!1}}catch(_){a.destroy(_)}break}}return a}var _s=nu,sn,bs;function pr(){if(bs)return sn;bs=1;const t=ft,{ArrayPrototypeIndexOf:e,NumberIsInteger:r,NumberIsNaN:n,NumberParseInt:i,ObjectDefineProperties:a,ObjectKeys:l,ObjectSetPrototypeOf:u,Promise:p,SafeSet:_,SymbolAsyncDispose:y,SymbolAsyncIterator:E,Symbol:w}=ce;sn=C,C.ReadableState=Ae;const{EventEmitter:m}=tr,{Stream:I,prependListener:R}=Jr,{Buffer:v}=Fe,{addAbortSignal:k}=cr,O=tt;let T=Ee.debuglog("stream",c=>{T=c});const q=jl,U=vt,{getHighWaterMark:oe,getDefaultHighWaterMark:Se}=hr,{aggregateTwoErrors:ee,codes:{ERR_INVALID_ARG_TYPE:ae,ERR_METHOD_NOT_IMPLEMENTED:we,ERR_OUT_OF_RANGE:me,ERR_STREAM_PUSH_AFTER_EOF:Q,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:P},AbortError:K}=Ie,{validateObject:G}=Dt,H=w("kPaused"),{StringDecoder:le}=fs,ue=_s;u(C.prototype,I.prototype),u(C,I);const re=()=>{},{errorOrDestroy:fe}=U,D=1,ne=2,M=4,de=8,ve=16,Ke=32,Ye=64,Ne=128,Xe=256,jt=512,bt=1024,Ze=2048,g=4096,x=8192,N=16384,F=32768,$=65536,Z=1<<17,te=1<<18;function Y(c){return{enumerable:!1,get(){return(this.state&c)!==0},set(h){h?this.state|=c:this.state&=~c}}}a(Ae.prototype,{objectMode:Y(D),ended:Y(ne),endEmitted:Y(M),reading:Y(de),constructed:Y(ve),sync:Y(Ke),needReadable:Y(Ye),emittedReadable:Y(Ne),readableListening:Y(Xe),resumeScheduled:Y(jt),errorEmitted:Y(bt),emitClose:Y(Ze),autoDestroy:Y(g),destroyed:Y(x),closed:Y(N),closeEmitted:Y(F),multiAwaitDrain:Y($),readingMore:Y(Z),dataEmitted:Y(te)});function Ae(c,h,j){typeof j!="boolean"&&(j=h instanceof Qe()),this.state=Ze|g|ve|Ke,c&&c.objectMode&&(this.state|=D),j&&c&&c.readableObjectMode&&(this.state|=D),this.highWaterMark=c?oe(this,c,"readableHighWaterMark",j):Se(!1),this.buffer=new q,this.length=0,this.pipes=[],this.flowing=null,this[H]=null,c&&c.emitClose===!1&&(this.state&=~Ze),c&&c.autoDestroy===!1&&(this.state&=~g),this.errored=null,this.defaultEncoding=c&&c.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,c&&c.encoding&&(this.decoder=new le(c.encoding),this.encoding=c.encoding)}function C(c){if(!(this instanceof C))return new C(c);const h=this instanceof Qe();this._readableState=new Ae(c,this,h),c&&(typeof c.read=="function"&&(this._read=c.read),typeof c.destroy=="function"&&(this._destroy=c.destroy),typeof c.construct=="function"&&(this._construct=c.construct),c.signal&&!h&&k(c.signal,this)),I.call(this,c),U.construct(this,()=>{this._readableState.needReadable&&b(this,this._readableState)})}C.prototype.destroy=U.destroy,C.prototype._undestroy=U.undestroy,C.prototype._destroy=function(c,h){h(c)},C.prototype[m.captureRejectionSymbol]=function(c){this.destroy(c)},C.prototype[y]=function(){let c;return this.destroyed||(c=this.readableEnded?null:new K,this.destroy(c)),new p((h,j)=>O(this,L=>L&&L!==c?j(L):h(null)))},C.prototype.push=function(c,h){return Le(this,c,h,!1)},C.prototype.unshift=function(c,h){return Le(this,c,h,!0)};function Le(c,h,j,L){T("readableAddChunk",h);const B=c._readableState;let xe;if(B.state&D||(typeof h=="string"?(j=j||B.defaultEncoding,B.encoding!==j&&(L&&B.encoding?h=v.from(h,j).toString(B.encoding):(h=v.from(h,j),j=""))):h instanceof v?j="":I._isUint8Array(h)?(h=I._uint8ArrayToBuffer(h),j=""):h!=null&&(xe=new ae("chunk",["string","Buffer","Uint8Array"],h))),xe)fe(c,xe);else if(h===null)B.state&=~de,s(c,B);else if(B.state&D||h&&h.length>0)if(L)if(B.state&M)fe(c,new P);else{if(B.destroyed||B.errored)return!1;Vt(c,B,h,!0)}else if(B.ended)fe(c,new Q);else{if(B.destroyed||B.errored)return!1;B.state&=~de,B.decoder&&!j?(h=B.decoder.write(h),B.objectMode||h.length!==0?Vt(c,B,h,!1):b(c,B)):Vt(c,B,h,!1)}else L||(B.state&=~de,b(c,B));return!B.ended&&(B.length<B.highWaterMark||B.length===0)}function Vt(c,h,j,L){h.flowing&&h.length===0&&!h.sync&&c.listenerCount("data")>0?(h.state&$?h.awaitDrainWriters.clear():h.awaitDrainWriters=null,h.dataEmitted=!0,c.emit("data",j)):(h.length+=h.objectMode?1:j.length,L?h.buffer.unshift(j):h.buffer.push(j),h.state&Ye&&o(c)),b(c,h)}C.prototype.isPaused=function(){const c=this._readableState;return c[H]===!0||c.flowing===!1},C.prototype.setEncoding=function(c){const h=new le(c);this._readableState.decoder=h,this._readableState.encoding=this._readableState.decoder.encoding;const j=this._readableState.buffer;let L="";for(const B of j)L+=h.write(B);return j.clear(),L!==""&&j.push(L),this._readableState.length=L.length,this};const Ge=1073741824;function vn(c){if(c>Ge)throw new me("size","<= 1GiB",c);return c--,c|=c>>>1,c|=c>>>2,c|=c>>>4,c|=c>>>8,c|=c>>>16,c++,c}function f(c,h){return c<=0||h.length===0&&h.ended?0:h.state&D?1:n(c)?h.flowing&&h.length?h.buffer.first().length:h.length:c<=h.length?c:h.ended?h.length:0}C.prototype.read=function(c){T("read",c),c===void 0?c=NaN:r(c)||(c=i(c,10));const h=this._readableState,j=c;if(c>h.highWaterMark&&(h.highWaterMark=vn(c)),c!==0&&(h.state&=~Ne),c===0&&h.needReadable&&((h.highWaterMark!==0?h.length>=h.highWaterMark:h.length>0)||h.ended))return T("read: emitReadable",h.length,h.ended),h.length===0&&h.ended?Nn(this):o(this),null;if(c=f(c,h),c===0&&h.ended)return h.length===0&&Nn(this),null;let L=(h.state&Ye)!==0;if(T("need readable",L),(h.length===0||h.length-c<h.highWaterMark)&&(L=!0,T("length less than watermark",L)),h.ended||h.reading||h.destroyed||h.errored||!h.constructed)L=!1,T("reading, ended or constructing",L);else if(L){T("do read"),h.state|=de|Ke,h.length===0&&(h.state|=Ye);try{this._read(h.highWaterMark)}catch(xe){fe(this,xe)}h.state&=~Ke,h.reading||(c=f(j,h))}let B;return c>0?B=to(c,h):B=null,B===null?(h.needReadable=h.length<=h.highWaterMark,c=0):(h.length-=c,h.multiAwaitDrain?h.awaitDrainWriters.clear():h.awaitDrainWriters=null),h.length===0&&(h.ended||(h.needReadable=!0),j!==c&&h.ended&&Nn(this)),B!==null&&!h.errorEmitted&&!h.closeEmitted&&(h.dataEmitted=!0,this.emit("data",B)),B};function s(c,h){if(T("onEofChunk"),!h.ended){if(h.decoder){const j=h.decoder.end();j&&j.length&&(h.buffer.push(j),h.length+=h.objectMode?1:j.length)}h.ended=!0,h.sync?o(c):(h.needReadable=!1,h.emittedReadable=!0,d(c))}}function o(c){const h=c._readableState;T("emitReadable",h.needReadable,h.emittedReadable),h.needReadable=!1,h.emittedReadable||(T("emitReadable",h.flowing),h.emittedReadable=!0,t.nextTick(d,c))}function d(c){const h=c._readableState;T("emitReadable_",h.destroyed,h.length,h.ended),!h.destroyed&&!h.errored&&(h.length||h.ended)&&(c.emit("readable"),h.emittedReadable=!1),h.needReadable=!h.flowing&&!h.ended&&h.length<=h.highWaterMark,V(c)}function b(c,h){!h.readingMore&&h.constructed&&(h.readingMore=!0,t.nextTick(S,c,h))}function S(c,h){for(;!h.reading&&!h.ended&&(h.length<h.highWaterMark||h.flowing&&h.length===0);){const j=h.length;if(T("maybeReadMore read 0"),c.read(0),j===h.length)break}h.readingMore=!1}C.prototype._read=function(c){throw new we("_read()")},C.prototype.pipe=function(c,h){const j=this,L=this._readableState;L.pipes.length===1&&(L.multiAwaitDrain||(L.multiAwaitDrain=!0,L.awaitDrainWriters=new _(L.awaitDrainWriters?[L.awaitDrainWriters]:[]))),L.pipes.push(c),T("pipe count=%d opts=%j",L.pipes.length,h);const xe=(!h||h.end!==!1)&&c!==t.stdout&&c!==t.stderr?no:Kt;L.endEmitted?t.nextTick(xe):j.once("end",xe),c.on("unpipe",$e);function $e(gt,Je){T("onunpipe"),gt===j&&Je&&Je.hasUnpiped===!1&&(Je.hasUnpiped=!0,Af())}function no(){T("onend"),c.end()}let yt,io=!1;function Af(){T("cleanup"),c.removeListener("close",Ln),c.removeListener("finish",$n),yt&&c.removeListener("drain",yt),c.removeListener("error",jn),c.removeListener("unpipe",$e),j.removeListener("end",no),j.removeListener("end",Kt),j.removeListener("data",oo),io=!0,yt&&L.awaitDrainWriters&&(!c._writableState||c._writableState.needDrain)&&yt()}function so(){io||(L.pipes.length===1&&L.pipes[0]===c?(T("false write response, pause",0),L.awaitDrainWriters=c,L.multiAwaitDrain=!1):L.pipes.length>1&&L.pipes.includes(c)&&(T("false write response, pause",L.awaitDrainWriters.size),L.awaitDrainWriters.add(c)),j.pause()),yt||(yt=A(j,c),c.on("drain",yt))}j.on("data",oo);function oo(gt){T("ondata");const Je=c.write(gt);T("dest.write",Je),Je===!1&&so()}function jn(gt){if(T("onerror",gt),Kt(),c.removeListener("error",jn),c.listenerCount("error")===0){const Je=c._writableState||c._readableState;Je&&!Je.errorEmitted?fe(c,gt):c.emit("error",gt)}}R(c,"error",jn);function Ln(){c.removeListener("finish",$n),Kt()}c.once("close",Ln);function $n(){T("onfinish"),c.removeListener("close",Ln),Kt()}c.once("finish",$n);function Kt(){T("unpipe"),j.unpipe(c)}return c.emit("pipe",j),c.writableNeedDrain===!0?so():L.flowing||(T("pipe resume"),j.resume()),c};function A(c,h){return function(){const L=c._readableState;L.awaitDrainWriters===h?(T("pipeOnDrain",1),L.awaitDrainWriters=null):L.multiAwaitDrain&&(T("pipeOnDrain",L.awaitDrainWriters.size),L.awaitDrainWriters.delete(h)),(!L.awaitDrainWriters||L.awaitDrainWriters.size===0)&&c.listenerCount("data")&&c.resume()}}C.prototype.unpipe=function(c){const h=this._readableState,j={hasUnpiped:!1};if(h.pipes.length===0)return this;if(!c){const B=h.pipes;h.pipes=[],this.pause();for(let xe=0;xe<B.length;xe++)B[xe].emit("unpipe",this,{hasUnpiped:!1});return this}const L=e(h.pipes,c);return L===-1?this:(h.pipes.splice(L,1),h.pipes.length===0&&this.pause(),c.emit("unpipe",this,j),this)},C.prototype.on=function(c,h){const j=I.prototype.on.call(this,c,h),L=this._readableState;return c==="data"?(L.readableListening=this.listenerCount("readable")>0,L.flowing!==!1&&this.resume()):c==="readable"&&!L.endEmitted&&!L.readableListening&&(L.readableListening=L.needReadable=!0,L.flowing=!1,L.emittedReadable=!1,T("on readable",L.length,L.reading),L.length?o(this):L.reading||t.nextTick(ie,this)),j},C.prototype.addListener=C.prototype.on,C.prototype.removeListener=function(c,h){const j=I.prototype.removeListener.call(this,c,h);return c==="readable"&&t.nextTick(W,this),j},C.prototype.off=C.prototype.removeListener,C.prototype.removeAllListeners=function(c){const h=I.prototype.removeAllListeners.apply(this,arguments);return(c==="readable"||c===void 0)&&t.nextTick(W,this),h};function W(c){const h=c._readableState;h.readableListening=c.listenerCount("readable")>0,h.resumeScheduled&&h[H]===!1?h.flowing=!0:c.listenerCount("data")>0?c.resume():h.readableListening||(h.flowing=null)}function ie(c){T("readable nexttick read 0"),c.read(0)}C.prototype.resume=function(){const c=this._readableState;return c.flowing||(T("resume"),c.flowing=!c.readableListening,J(this,c)),c[H]=!1,this};function J(c,h){h.resumeScheduled||(h.resumeScheduled=!0,t.nextTick(se,c,h))}function se(c,h){T("resume",h.reading),h.reading||c.read(0),h.resumeScheduled=!1,c.emit("resume"),V(c),h.flowing&&!h.reading&&c.read(0)}C.prototype.pause=function(){return T("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(T("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[H]=!0,this};function V(c){const h=c._readableState;for(T("flow",h.flowing);h.flowing&&c.read()!==null;);}C.prototype.wrap=function(c){let h=!1;c.on("data",L=>{!this.push(L)&&c.pause&&(h=!0,c.pause())}),c.on("end",()=>{this.push(null)}),c.on("error",L=>{fe(this,L)}),c.on("close",()=>{this.destroy()}),c.on("destroy",()=>{this.destroy()}),this._read=()=>{h&&c.resume&&(h=!1,c.resume())};const j=l(c);for(let L=1;L<j.length;L++){const B=j[L];this[B]===void 0&&typeof c[B]=="function"&&(this[B]=c[B].bind(c))}return this},C.prototype[E]=function(){return eo(this)},C.prototype.iterator=function(c){return c!==void 0&&G(c,"options"),eo(this,c)};function eo(c,h){typeof c.read!="function"&&(c=C.wrap(c,{objectMode:!0}));const j=Sf(c,h);return j.stream=c,j}async function*Sf(c,h){let j=re;function L($e){this===c?(j(),j=re):j=$e}c.on("readable",L);let B;const xe=O(c,{writable:!1},$e=>{B=$e?ee(B,$e):null,j(),j=re});try{for(;;){const $e=c.destroyed?null:c.read();if($e!==null)yield $e;else{if(B)throw B;if(B===null)return;await new p(L)}}}catch($e){throw B=ee(B,$e),B}finally{(B||(h==null?void 0:h.destroyOnReturn)!==!1)&&(B===void 0||c._readableState.autoDestroy)?U.destroyer(c,null):(c.off("readable",L),xe())}}a(C.prototype,{readable:{__proto__:null,get(){const c=this._readableState;return!!c&&c.readable!==!1&&!c.destroyed&&!c.errorEmitted&&!c.endEmitted},set(c){this._readableState&&(this._readableState.readable=!!c)}},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(c){this._readableState&&(this._readableState.flowing=c)}},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(c){this._readableState&&(this._readableState.destroyed=c)}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),a(Ae.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[H]!==!1},set(c){this[H]=!!c}}}),C._fromList=to;function to(c,h){if(h.length===0)return null;let j;return h.objectMode?j=h.buffer.shift():!c||c>=h.length?(h.decoder?j=h.buffer.join(""):h.buffer.length===1?j=h.buffer.first():j=h.buffer.concat(h.length),h.buffer.clear()):j=h.buffer.consume(c,h.decoder),j}function Nn(c){const h=c._readableState;T("endReadable",h.endEmitted),h.endEmitted||(h.ended=!0,t.nextTick(If,h,c))}function If(c,h){if(T("endReadableNT",c.endEmitted,c.length),!c.errored&&!c.closeEmitted&&!c.endEmitted&&c.length===0){if(c.endEmitted=!0,h.emit("end"),h.writable&&h.allowHalfOpen===!1)t.nextTick(Rf,h);else if(c.autoDestroy){const j=h._writableState;(!j||j.autoDestroy&&(j.finished||j.writable===!1))&&h.destroy()}}}function Rf(c){c.writable&&!c.writableEnded&&!c.destroyed&&c.end()}C.from=function(c,h){return ue(C,c,h)};let Pn;function ro(){return Pn===void 0&&(Pn={}),Pn}return C.fromWeb=function(c,h){return ro().newStreamReadableFromReadableStream(c,h)},C.toWeb=function(c,h){return ro().newReadableStreamFromStreamReadable(c,h)},C.wrap=function(c,h){var j,L;return new C({objectMode:(j=(L=c.readableObjectMode)!==null&&L!==void 0?L:c.objectMode)!==null&&j!==void 0?j:!0,...h,destroy(B,xe){U.destroyer(c,B),xe(B)}}).wrap(c)},sn}var on,ys;function an(){if(ys)return on;ys=1;const t=ft,{ArrayPrototypeSlice:e,Error:r,FunctionPrototypeSymbolHasInstance:n,ObjectDefineProperty:i,ObjectDefineProperties:a,ObjectSetPrototypeOf:l,StringPrototypeToLowerCase:u,Symbol:p,SymbolHasInstance:_}=ce;on=G,G.WritableState=P;const{EventEmitter:y}=tr,E=Jr.Stream,{Buffer:w}=Fe,m=vt,{addAbortSignal:I}=cr,{getHighWaterMark:R,getDefaultHighWaterMark:v}=hr,{ERR_INVALID_ARG_TYPE:k,ERR_METHOD_NOT_IMPLEMENTED:O,ERR_MULTIPLE_CALLBACK:T,ERR_STREAM_CANNOT_PIPE:q,ERR_STREAM_DESTROYED:U,ERR_STREAM_ALREADY_FINISHED:oe,ERR_STREAM_NULL_VALUES:Se,ERR_STREAM_WRITE_AFTER_END:ee,ERR_UNKNOWN_ENCODING:ae}=Ie.codes,{errorOrDestroy:we}=m;l(G.prototype,E.prototype),l(G,E);function me(){}const Q=p("kOnFinished");function P(g,x,N){typeof N!="boolean"&&(N=x instanceof Qe()),this.objectMode=!!(g&&g.objectMode),N&&(this.objectMode=this.objectMode||!!(g&&g.writableObjectMode)),this.highWaterMark=g?R(this,g,"writableHighWaterMark",N):v(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const F=!!(g&&g.decodeStrings===!1);this.decodeStrings=!F,this.defaultEncoding=g&&g.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=fe.bind(void 0,x),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,K(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!g||g.emitClose!==!1,this.autoDestroy=!g||g.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[Q]=[]}function K(g){g.buffered=[],g.bufferedIndex=0,g.allBuffers=!0,g.allNoop=!0}P.prototype.getBuffer=function(){return e(this.buffered,this.bufferedIndex)},i(P.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function G(g){const x=this instanceof Qe();if(!x&&!n(G,this))return new G(g);this._writableState=new P(g,this,x),g&&(typeof g.write=="function"&&(this._write=g.write),typeof g.writev=="function"&&(this._writev=g.writev),typeof g.destroy=="function"&&(this._destroy=g.destroy),typeof g.final=="function"&&(this._final=g.final),typeof g.construct=="function"&&(this._construct=g.construct),g.signal&&I(g.signal,this)),E.call(this,g),m.construct(this,()=>{const N=this._writableState;N.writing||de(this,N),Ne(this,N)})}i(G,_,{__proto__:null,value:function(g){return n(this,g)?!0:this!==G?!1:g&&g._writableState instanceof P}}),G.prototype.pipe=function(){we(this,new q)};function H(g,x,N,F){const $=g._writableState;if(typeof N=="function")F=N,N=$.defaultEncoding;else{if(!N)N=$.defaultEncoding;else if(N!=="buffer"&&!w.isEncoding(N))throw new ae(N);typeof F!="function"&&(F=me)}if(x===null)throw new Se;if(!$.objectMode)if(typeof x=="string")$.decodeStrings!==!1&&(x=w.from(x,N),N="buffer");else if(x instanceof w)N="buffer";else if(E._isUint8Array(x))x=E._uint8ArrayToBuffer(x),N="buffer";else throw new k("chunk",["string","Buffer","Uint8Array"],x);let Z;return $.ending?Z=new ee:$.destroyed&&(Z=new U("write")),Z?(t.nextTick(F,Z),we(g,Z,!0),Z):($.pendingcb++,le(g,$,x,N,F))}G.prototype.write=function(g,x,N){return H(this,g,x,N)===!0},G.prototype.cork=function(){this._writableState.corked++},G.prototype.uncork=function(){const g=this._writableState;g.corked&&(g.corked--,g.writing||de(this,g))},G.prototype.setDefaultEncoding=function(x){if(typeof x=="string"&&(x=u(x)),!w.isEncoding(x))throw new ae(x);return this._writableState.defaultEncoding=x,this};function le(g,x,N,F,$){const Z=x.objectMode?1:N.length;x.length+=Z;const te=x.length<x.highWaterMark;return te||(x.needDrain=!0),x.writing||x.corked||x.errored||!x.constructed?(x.buffered.push({chunk:N,encoding:F,callback:$}),x.allBuffers&&F!=="buffer"&&(x.allBuffers=!1),x.allNoop&&$!==me&&(x.allNoop=!1)):(x.writelen=Z,x.writecb=$,x.writing=!0,x.sync=!0,g._write(N,F,x.onwrite),x.sync=!1),te&&!x.errored&&!x.destroyed}function ue(g,x,N,F,$,Z,te){x.writelen=F,x.writecb=te,x.writing=!0,x.sync=!0,x.destroyed?x.onwrite(new U("write")):N?g._writev($,x.onwrite):g._write($,Z,x.onwrite),x.sync=!1}function re(g,x,N,F){--x.pendingcb,F(N),M(x),we(g,N)}function fe(g,x){const N=g._writableState,F=N.sync,$=N.writecb;if(typeof $!="function"){we(g,new T);return}N.writing=!1,N.writecb=null,N.length-=N.writelen,N.writelen=0,x?(x.stack,N.errored||(N.errored=x),g._readableState&&!g._readableState.errored&&(g._readableState.errored=x),F?t.nextTick(re,g,N,x,$):re(g,N,x,$)):(N.buffered.length>N.bufferedIndex&&de(g,N),F?N.afterWriteTickInfo!==null&&N.afterWriteTickInfo.cb===$?N.afterWriteTickInfo.count++:(N.afterWriteTickInfo={count:1,cb:$,stream:g,state:N},t.nextTick(D,N.afterWriteTickInfo)):ne(g,N,1,$))}function D({stream:g,state:x,count:N,cb:F}){return x.afterWriteTickInfo=null,ne(g,x,N,F)}function ne(g,x,N,F){for(!x.ending&&!g.destroyed&&x.length===0&&x.needDrain&&(x.needDrain=!1,g.emit("drain"));N-- >0;)x.pendingcb--,F();x.destroyed&&M(x),Ne(g,x)}function M(g){if(g.writing)return;for(let $=g.bufferedIndex;$<g.buffered.length;++$){var x;const{chunk:Z,callback:te}=g.buffered[$],Y=g.objectMode?1:Z.length;g.length-=Y,te((x=g.errored)!==null&&x!==void 0?x:new U("write"))}const N=g[Q].splice(0);for(let $=0;$<N.length;$++){var F;N[$]((F=g.errored)!==null&&F!==void 0?F:new U("end"))}K(g)}function de(g,x){if(x.corked||x.bufferProcessing||x.destroyed||!x.constructed)return;const{buffered:N,bufferedIndex:F,objectMode:$}=x,Z=N.length-F;if(!Z)return;let te=F;if(x.bufferProcessing=!0,Z>1&&g._writev){x.pendingcb-=Z-1;const Y=x.allNoop?me:C=>{for(let Le=te;Le<N.length;++Le)N[Le].callback(C)},Ae=x.allNoop&&te===0?N:e(N,te);Ae.allBuffers=x.allBuffers,ue(g,x,!0,x.length,Ae,"",Y),K(x)}else{do{const{chunk:Y,encoding:Ae,callback:C}=N[te];N[te++]=null;const Le=$?1:Y.length;ue(g,x,!1,Le,Y,Ae,C)}while(te<N.length&&!x.writing);te===N.length?K(x):te>256?(N.splice(0,te),x.bufferedIndex=0):x.bufferedIndex=te}x.bufferProcessing=!1}G.prototype._write=function(g,x,N){if(this._writev)this._writev([{chunk:g,encoding:x}],N);else throw new O("_write()")},G.prototype._writev=null,G.prototype.end=function(g,x,N){const F=this._writableState;typeof g=="function"?(N=g,g=null,x=null):typeof x=="function"&&(N=x,x=null);let $;if(g!=null){const Z=H(this,g,x);Z instanceof r&&($=Z)}return F.corked&&(F.corked=1,this.uncork()),$||(!F.errored&&!F.ending?(F.ending=!0,Ne(this,F,!0),F.ended=!0):F.finished?$=new oe("end"):F.destroyed&&($=new U("end"))),typeof N=="function"&&($||F.finished?t.nextTick(N,$):F[Q].push(N)),this};function ve(g){return g.ending&&!g.destroyed&&g.constructed&&g.length===0&&!g.errored&&g.buffered.length===0&&!g.finished&&!g.writing&&!g.errorEmitted&&!g.closeEmitted}function Ke(g,x){let N=!1;function F($){if(N){we(g,$??T());return}if(N=!0,x.pendingcb--,$){const Z=x[Q].splice(0);for(let te=0;te<Z.length;te++)Z[te]($);we(g,$,x.sync)}else ve(x)&&(x.prefinished=!0,g.emit("prefinish"),x.pendingcb++,t.nextTick(Xe,g,x))}x.sync=!0,x.pendingcb++;try{g._final(F)}catch($){F($)}x.sync=!1}function Ye(g,x){!x.prefinished&&!x.finalCalled&&(typeof g._final=="function"&&!x.destroyed?(x.finalCalled=!0,Ke(g,x)):(x.prefinished=!0,g.emit("prefinish")))}function Ne(g,x,N){ve(x)&&(Ye(g,x),x.pendingcb===0&&(N?(x.pendingcb++,t.nextTick((F,$)=>{ve($)?Xe(F,$):$.pendingcb--},g,x)):ve(x)&&(x.pendingcb++,Xe(g,x))))}function Xe(g,x){x.pendingcb--,x.finished=!0;const N=x[Q].splice(0);for(let F=0;F<N.length;F++)N[F]();if(g.emit("finish"),x.autoDestroy){const F=g._readableState;(!F||F.autoDestroy&&(F.endEmitted||F.readable===!1))&&g.destroy()}}a(G.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(g){this._writableState&&(this._writableState.destroyed=g)}},writable:{__proto__:null,get(){const g=this._writableState;return!!g&&g.writable!==!1&&!g.destroyed&&!g.errored&&!g.ending&&!g.ended},set(g){this._writableState&&(this._writableState.writable=!!g)}},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(){const g=this._writableState;return g?!g.destroyed&&!g.ending&&g.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)}}});const jt=m.destroy;G.prototype.destroy=function(g,x){const N=this._writableState;return!N.destroyed&&(N.bufferedIndex<N.buffered.length||N[Q].length)&&t.nextTick(M,N),jt.call(this,g,x),this},G.prototype._undestroy=m.undestroy,G.prototype._destroy=function(g,x){x(g)},G.prototype[y.captureRejectionSymbol]=function(g){this.destroy(g)};let bt;function Ze(){return bt===void 0&&(bt={}),bt}return G.fromWeb=function(g,x){return Ze().newStreamWritableFromWritableStream(g,x)},G.toWeb=function(g){return Ze().newWritableStreamFromStreamWritable(g)},on}var ln,gs;function iu(){if(gs)return ln;gs=1;const t=ft,e=Fe,{isReadable:r,isWritable:n,isIterable:i,isNodeStream:a,isReadableNodeStream:l,isWritableNodeStream:u,isDuplexNodeStream:p,isReadableStream:_,isWritableStream:y}=He,E=tt,{AbortError:w,codes:{ERR_INVALID_ARG_TYPE:m,ERR_INVALID_RETURN_VALUE:I}}=Ie,{destroyer:R}=vt,v=Qe(),k=pr(),O=an(),{createDeferredPromise:T}=Ee,q=_s,U=globalThis.Blob||e.Blob,oe=typeof U<"u"?function(P){return P instanceof U}:function(P){return!1},Se=globalThis.AbortController||Mt().AbortController,{FunctionPrototypeCall:ee}=ce;class ae extends v{constructor(P){super(P),(P==null?void 0:P.readable)===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),(P==null?void 0:P.writable)===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}}ln=function Q(P,K){if(p(P))return P;if(l(P))return me({readable:P});if(u(P))return me({writable:P});if(a(P))return me({writable:!1,readable:!1});if(_(P))return me({readable:k.fromWeb(P)});if(y(P))return me({writable:O.fromWeb(P)});if(typeof P=="function"){const{value:H,write:le,final:ue,destroy:re}=we(P);if(i(H))return q(ae,H,{objectMode:!0,write:le,final:ue,destroy:re});const fe=H==null?void 0:H.then;if(typeof fe=="function"){let D;const ne=ee(fe,H,M=>{if(M!=null)throw new I("nully","body",M)},M=>{R(D,M)});return D=new ae({objectMode:!0,readable:!1,write:le,final(M){ue(async()=>{try{await ne,t.nextTick(M,null)}catch(de){t.nextTick(M,de)}})},destroy:re})}throw new I("Iterable, AsyncIterable or AsyncFunction",K,H)}if(oe(P))return Q(P.arrayBuffer());if(i(P))return q(ae,P,{objectMode:!0,writable:!1});if(_(P==null?void 0:P.readable)&&y(P==null?void 0:P.writable))return ae.fromWeb(P);if(typeof(P==null?void 0:P.writable)=="object"||typeof(P==null?void 0:P.readable)=="object"){const H=P!=null&&P.readable?l(P==null?void 0:P.readable)?P==null?void 0:P.readable:Q(P.readable):void 0,le=P!=null&&P.writable?u(P==null?void 0:P.writable)?P==null?void 0:P.writable:Q(P.writable):void 0;return me({readable:H,writable:le})}const G=P==null?void 0:P.then;if(typeof G=="function"){let H;return ee(G,P,le=>{le!=null&&H.push(le),H.push(null)},le=>{R(H,le)}),H=new ae({objectMode:!0,writable:!1,read(){}})}throw new m(K,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],P)};function we(Q){let{promise:P,resolve:K}=T();const G=new Se,H=G.signal;return{value:Q(async function*(){for(;;){const ue=P;P=null;const{chunk:re,done:fe,cb:D}=await ue;if(t.nextTick(D),fe)return;if(H.aborted)throw new w(void 0,{cause:H.reason});({promise:P,resolve:K}=T()),yield re}}(),{signal:H}),write(ue,re,fe){const D=K;K=null,D({chunk:ue,done:!1,cb:fe})},final(ue){const re=K;K=null,re({done:!0,cb:ue})},destroy(ue,re){G.abort(),re(ue)}}}function me(Q){const P=Q.readable&&typeof Q.readable.read!="function"?k.wrap(Q.readable):Q.readable,K=Q.writable;let G=!!r(P),H=!!n(K),le,ue,re,fe,D;function ne(M){const de=fe;fe=null,de?de(M):M&&D.destroy(M)}return D=new ae({readableObjectMode:!!(P!=null&&P.readableObjectMode),writableObjectMode:!!(K!=null&&K.writableObjectMode),readable:G,writable:H}),H&&(E(K,M=>{H=!1,M&&R(P,M),ne(M)}),D._write=function(M,de,ve){K.write(M,de)?ve():le=ve},D._final=function(M){K.end(),ue=M},K.on("drain",function(){if(le){const M=le;le=null,M()}}),K.on("finish",function(){if(ue){const M=ue;ue=null,M()}})),G&&(E(P,M=>{G=!1,M&&R(P,M),ne(M)}),P.on("readable",function(){if(re){const M=re;re=null,M()}}),P.on("end",function(){D.push(null)}),D._read=function(){for(;;){const M=P.read();if(M===null){re=D._read;return}if(!D.push(M))return}}),D._destroy=function(M,de){!M&&fe!==null&&(M=new w),re=null,le=null,ue=null,fe===null?de(M):(fe=de,R(K,M),R(P,M))},D}return ln}var un,ws;function Qe(){if(ws)return un;ws=1;const{ObjectDefineProperties:t,ObjectGetOwnPropertyDescriptor:e,ObjectKeys:r,ObjectSetPrototypeOf:n}=ce;un=l;const i=pr(),a=an();n(l.prototype,i.prototype),n(l,i);{const y=r(a.prototype);for(let E=0;E<y.length;E++){const w=y[E];l.prototype[w]||(l.prototype[w]=a.prototype[w])}}function l(y){if(!(this instanceof l))return new l(y);i.call(this,y),a.call(this,y),y?(this.allowHalfOpen=y.allowHalfOpen!==!1,y.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),y.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}t(l.prototype,{writable:{__proto__:null,...e(a.prototype,"writable")},writableHighWaterMark:{__proto__:null,...e(a.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...e(a.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...e(a.prototype,"writableBuffer")},writableLength:{__proto__:null,...e(a.prototype,"writableLength")},writableFinished:{__proto__:null,...e(a.prototype,"writableFinished")},writableCorked:{__proto__:null,...e(a.prototype,"writableCorked")},writableEnded:{__proto__:null,...e(a.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...e(a.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(y){this._readableState&&this._writableState&&(this._readableState.destroyed=y,this._writableState.destroyed=y)}}});let u;function p(){return u===void 0&&(u={}),u}l.fromWeb=function(y,E){return p().newStreamDuplexFromReadableWritablePair(y,E)},l.toWeb=function(y){return p().newReadableWritablePairFromDuplex(y)};let _;return l.from=function(y){return _||(_=iu()),_(y,"body")},un}const{ObjectSetPrototypeOf:ms,Symbol:su}=ce;var xs=Ve;const{ERR_METHOD_NOT_IMPLEMENTED:ou}=Ie.codes,fn=Qe(),{getHighWaterMark:au}=hr;ms(Ve.prototype,fn.prototype),ms(Ve,fn);const Wt=su("kCallback");function Ve(t){if(!(this instanceof Ve))return new Ve(t);const e=t?au(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),fn.call(this,t),this._readableState.sync=!1,this[Wt]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",lu)}function cn(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 lu(){this._final!==cn&&cn.call(this)}Ve.prototype._final=cn,Ve.prototype._transform=function(t,e,r){throw new ou("_transform()")},Ve.prototype._write=function(t,e,r){const n=this._readableState,i=this._writableState,a=n.length;this._transform(t,e,(l,u)=>{if(l){r(l);return}u!=null&&this.push(u),i.ended||a===n.length||n.length<n.highWaterMark?r():this[Wt]=r})},Ve.prototype._read=function(){if(this[Wt]){const t=this[Wt];this[Wt]=null,t()}};const{ObjectSetPrototypeOf:Es}=ce;var Ss=Nt;const dn=xs;Es(Nt.prototype,dn.prototype),Es(Nt,dn);function Nt(t){if(!(this instanceof Nt))return new Nt(t);dn.call(this,t)}Nt.prototype._transform=function(t,e,r){r(null,t)};const Gt=ft,{ArrayIsArray:uu,Promise:fu,SymbolAsyncIterator:cu,SymbolDispose:du}=ce,_r=tt,{once:hu}=Ee,pu=vt,Is=Qe(),{aggregateTwoErrors:_u,codes:{ERR_INVALID_ARG_TYPE:hn,ERR_INVALID_RETURN_VALUE:pn,ERR_MISSING_ARGS:bu,ERR_STREAM_DESTROYED:yu,ERR_STREAM_PREMATURE_CLOSE:gu},AbortError:wu}=Ie,{validateFunction:mu,validateAbortSignal:xu}=Dt,{isIterable:dt,isReadable:_n,isReadableNodeStream:br,isNodeStream:Rs,isTransformStream:Pt,isWebStream:Eu,isReadableStream:bn,isReadableFinished:Su}=He,Iu=globalThis.AbortController||Mt().AbortController;let yn,gn,wn;function As(t,e,r){let n=!1;t.on("close",()=>{n=!0});const i=_r(t,{readable:e,writable:r},a=>{n=!a});return{destroy:a=>{n||(n=!0,pu.destroyer(t,a||new yu("pipe")))},cleanup:i}}function Ru(t){return mu(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function mn(t){if(dt(t))return t;if(br(t))return Au(t);throw new hn("val",["Readable","Iterable","AsyncIterable"],t)}async function*Au(t){gn||(gn=pr()),yield*gn.prototype[cu].call(t)}async function yr(t,e,r,{end:n}){let i,a=null;const l=_=>{if(_&&(i=_),a){const y=a;a=null,y()}},u=()=>new fu((_,y)=>{i?y(i):a=()=>{i?y(i):_()}});e.on("drain",l);const p=_r(e,{readable:!1},l);try{e.writableNeedDrain&&await u();for await(const _ of t)e.write(_)||await u();n&&(e.end(),await u()),r()}catch(_){r(i!==_?_u(i,_):_)}finally{p(),e.off("drain",l)}}async function xn(t,e,r,{end:n}){Pt(e)&&(e=e.writable);const i=e.getWriter();try{for await(const a of t)await i.ready,i.write(a).catch(()=>{});await i.ready,n&&await i.close(),r()}catch(a){try{await i.abort(a),r(a)}catch(l){r(l)}}}function Tu(...t){return Ts(t,hu(Ru(t)))}function Ts(t,e,r){if(t.length===1&&uu(t[0])&&(t=t[0]),t.length<2)throw new bu("streams");const n=new Iu,i=n.signal,a=r==null?void 0:r.signal,l=[];xu(a,"options.signal");function u(){I(new wu)}wn=wn||Ee.addAbortListener;let p;a&&(p=wn(a,u));let _,y;const E=[];let w=0;function m(O){I(O,--w===0)}function I(O,T){var q;if(O&&(!_||_.code==="ERR_STREAM_PREMATURE_CLOSE")&&(_=O),!(!_&&!T)){for(;E.length;)E.shift()(_);(q=p)===null||q===void 0||q[du](),n.abort(),T&&(_||l.forEach(U=>U()),Gt.nextTick(e,_,y))}}let R;for(let O=0;O<t.length;O++){const T=t[O],q=O<t.length-1,U=O>0,oe=q||(r==null?void 0:r.end)!==!1,Se=O===t.length-1;if(Rs(T)){let ee=function(ae){ae&&ae.name!=="AbortError"&&ae.code!=="ERR_STREAM_PREMATURE_CLOSE"&&m(ae)};if(oe){const{destroy:ae,cleanup:we}=As(T,q,U);E.push(ae),_n(T)&&Se&&l.push(we)}T.on("error",ee),_n(T)&&Se&&l.push(()=>{T.removeListener("error",ee)})}if(O===0)if(typeof T=="function"){if(R=T({signal:i}),!dt(R))throw new pn("Iterable, AsyncIterable or Stream","source",R)}else dt(T)||br(T)||Pt(T)?R=T:R=Is.from(T);else if(typeof T=="function"){if(Pt(R)){var v;R=mn((v=R)===null||v===void 0?void 0:v.readable)}else R=mn(R);if(R=T(R,{signal:i}),q){if(!dt(R,!0))throw new pn("AsyncIterable",`transform[${O-1}]`,R)}else{var k;yn||(yn=Ss);const ee=new yn({objectMode:!0}),ae=(k=R)===null||k===void 0?void 0:k.then;if(typeof ae=="function")w++,ae.call(R,Q=>{y=Q,Q!=null&&ee.write(Q),oe&&ee.end(),Gt.nextTick(m)},Q=>{ee.destroy(Q),Gt.nextTick(m,Q)});else if(dt(R,!0))w++,yr(R,ee,m,{end:oe});else if(bn(R)||Pt(R)){const Q=R.readable||R;w++,yr(Q,ee,m,{end:oe})}else throw new pn("AsyncIterable or Promise","destination",R);R=ee;const{destroy:we,cleanup:me}=As(R,!1,!0);E.push(we),Se&&l.push(me)}}else if(Rs(T)){if(br(R)){w+=2;const ee=vu(R,T,m,{end:oe});_n(T)&&Se&&l.push(ee)}else if(Pt(R)||bn(R)){const ee=R.readable||R;w++,yr(ee,T,m,{end:oe})}else if(dt(R))w++,yr(R,T,m,{end:oe});else throw new hn("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],R);R=T}else if(Eu(T)){if(br(R))w++,xn(mn(R),T,m,{end:oe});else if(bn(R)||dt(R))w++,xn(R,T,m,{end:oe});else if(Pt(R))w++,xn(R.readable,T,m,{end:oe});else throw new hn("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],R);R=T}else R=Is.from(T)}return(i!=null&&i.aborted||a!=null&&a.aborted)&&Gt.nextTick(u),R}function vu(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new gu)}),t.pipe(e,{end:!1}),n){let a=function(){i=!0,e.end()};Su(t)?Gt.nextTick(a):t.once("end",a)}else r();return _r(t,{readable:!0,writable:!1},a=>{const l=t._readableState;a&&a.code==="ERR_STREAM_PREMATURE_CLOSE"&&l&&l.ended&&!l.errored&&!l.errorEmitted?t.once("end",r).once("error",r):r(a)}),_r(e,{readable:!1,writable:!0},r)}var En={pipelineImpl:Ts,pipeline:Tu};const{pipeline:Nu}=En,gr=Qe(),{destroyer:Pu}=vt,{isNodeStream:wr,isReadable:vs,isWritable:Ns,isWebStream:Sn,isTransformStream:ht,isWritableStream:Ps,isReadableStream:js}=He,{AbortError:ju,codes:{ERR_INVALID_ARG_VALUE:Ls,ERR_MISSING_ARGS:Lu}}=Ie,$u=tt;var $s=function(...e){if(e.length===0)throw new Lu("streams");if(e.length===1)return gr.from(e[0]);const r=[...e];if(typeof e[0]=="function"&&(e[0]=gr.from(e[0])),typeof e[e.length-1]=="function"){const m=e.length-1;e[m]=gr.from(e[m])}for(let m=0;m<e.length;++m)if(!(!wr(e[m])&&!Sn(e[m]))){if(m<e.length-1&&!(vs(e[m])||js(e[m])||ht(e[m])))throw new Ls(`streams[${m}]`,r[m],"must be readable");if(m>0&&!(Ns(e[m])||Ps(e[m])||ht(e[m])))throw new Ls(`streams[${m}]`,r[m],"must be writable")}let n,i,a,l,u;function p(m){const I=l;l=null,I?I(m):m?u.destroy(m):!w&&!E&&u.destroy()}const _=e[0],y=Nu(e,p),E=!!(Ns(_)||Ps(_)||ht(_)),w=!!(vs(y)||js(y)||ht(y));if(u=new gr({writableObjectMode:!!(_!=null&&_.writableObjectMode),readableObjectMode:!!(y!=null&&y.readableObjectMode),writable:E,readable:w}),E){if(wr(_))u._write=function(I,R,v){_.write(I,R)?v():n=v},u._final=function(I){_.end(),i=I},_.on("drain",function(){if(n){const I=n;n=null,I()}});else if(Sn(_)){const R=(ht(_)?_.writable:_).getWriter();u._write=async function(v,k,O){try{await R.ready,R.write(v).catch(()=>{}),O()}catch(T){O(T)}},u._final=async function(v){try{await R.ready,R.close().catch(()=>{}),i=v}catch(k){v(k)}}}const m=ht(y)?y.readable:y;$u(m,()=>{if(i){const I=i;i=null,I()}})}if(w){if(wr(y))y.on("readable",function(){if(a){const m=a;a=null,m()}}),y.on("end",function(){u.push(null)}),u._read=function(){for(;;){const m=y.read();if(m===null){a=u._read;return}if(!u.push(m))return}};else if(Sn(y)){const I=(ht(y)?y.readable:y).getReader();u._read=async function(){for(;;)try{const{value:R,done:v}=await I.read();if(!u.push(R))return;if(v){u.push(null);return}}catch{return}}}}return u._destroy=function(m,I){!m&&l!==null&&(m=new ju),a=null,n=null,i=null,l===null?I(m):(l=I,wr(y)&&Pu(y,m))},u};const Bu=globalThis.AbortController||Mt().AbortController,{codes:{ERR_INVALID_ARG_VALUE:Fu,ERR_INVALID_ARG_TYPE:zt,ERR_MISSING_ARGS:ku,ERR_OUT_OF_RANGE:Cu},AbortError:Ue}=Ie,{validateAbortSignal:pt,validateInteger:Bs,validateObject:_t}=Dt,Ou=ce.Symbol("kWeak"),Mu=ce.Symbol("kResistStopPropagation"),{finished:Du}=tt,Uu=$s,{addAbortSignalNoValidate:Wu}=cr,{isWritable:Gu,isNodeStream:zu}=He,{deprecate:qu}=Ee,{ArrayPrototypePush:Hu,Boolean:Qu,MathFloor:Fs,Number:Vu,NumberIsNaN:Ku,Promise:ks,PromiseReject:Cs,PromiseResolve:Yu,PromisePrototypeThen:Os,Symbol:Ms}=ce,mr=Ms("kEmpty"),Ds=Ms("kEof");function Xu(t,e){if(e!=null&&_t(e,"options"),(e==null?void 0:e.signal)!=null&&pt(e.signal,"options.signal"),zu(t)&&!Gu(t))throw new Fu("stream",t,"must be writable");const r=Uu(this,t);return e!=null&&e.signal&&Wu(e.signal,r),r}function xr(t,e){if(typeof t!="function")throw new zt("fn",["Function","AsyncFunction"],t);e!=null&&_t(e,"options"),(e==null?void 0:e.signal)!=null&&pt(e.signal,"options.signal");let r=1;(e==null?void 0:e.concurrency)!=null&&(r=Fs(e.concurrency));let n=r-1;return(e==null?void 0:e.highWaterMark)!=null&&(n=Fs(e.highWaterMark)),Bs(r,"options.concurrency",1),Bs(n,"options.highWaterMark",0),n+=r,(async function*(){const a=Ee.AbortSignalAny([e==null?void 0:e.signal].filter(Qu)),l=this,u=[],p={signal:a};let _,y,E=!1,w=0;function m(){E=!0,I()}function I(){w-=1,R()}function R(){y&&!E&&w<r&&u.length<n&&(y(),y=null)}async function v(){try{for await(let k of l){if(E)return;if(a.aborted)throw new Ue;try{if(k=t(k,p),k===mr)continue;k=Yu(k)}catch(O){k=Cs(O)}w+=1,Os(k,I,m),u.push(k),_&&(_(),_=null),!E&&(u.length>=n||w>=r)&&await new ks(O=>{y=O})}u.push(Ds)}catch(k){const O=Cs(k);Os(O,I,m),u.push(O)}finally{E=!0,_&&(_(),_=null)}}v();try{for(;;){for(;u.length>0;){const k=await u[0];if(k===Ds)return;if(a.aborted)throw new Ue;k!==mr&&(yield k),u.shift(),R()}await new ks(k=>{_=k})}}finally{E=!0,y&&(y(),y=null)}}).call(this)}function Zu(t=void 0){return t!=null&&_t(t,"options"),(t==null?void 0:t.signal)!=null&&pt(t.signal,"options.signal"),(async function*(){let r=0;for await(const i of this){var n;if(t!=null&&(n=t.signal)!==null&&n!==void 0&&n.aborted)throw new Ue({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function Us(t,e=void 0){for await(const r of In.call(this,t,e))return!0;return!1}async function Ju(t,e=void 0){if(typeof t!="function")throw new zt("fn",["Function","AsyncFunction"],t);return!await Us.call(this,async(...r)=>!await t(...r),e)}async function ef(t,e){for await(const r of In.call(this,t,e))return r}async function tf(t,e){if(typeof t!="function")throw new zt("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),mr}for await(const n of xr.call(this,r,e));}function In(t,e){if(typeof t!="function")throw new zt("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:mr}return xr.call(this,r,e)}class rf extends ku{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}}async function nf(t,e,r){var n;if(typeof t!="function")throw new zt("reducer",["Function","AsyncFunction"],t);r!=null&&_t(r,"options"),(r==null?void 0:r.signal)!=null&&pt(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){const _=new Ue(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await Du(this.destroy(_)),_}const a=new Bu,l=a.signal;if(r!=null&&r.signal){const _={once:!0,[Ou]:this,[Mu]:!0};r.signal.addEventListener("abort",()=>a.abort(),_)}let u=!1;try{for await(const _ of this){var p;if(u=!0,r!=null&&(p=r.signal)!==null&&p!==void 0&&p.aborted)throw new Ue;i?e=await t(e,_,{signal:l}):(e=_,i=!0)}if(!u&&!i)throw new rf}finally{a.abort()}return e}async function sf(t){t!=null&&_t(t,"options"),(t==null?void 0:t.signal)!=null&&pt(t.signal,"options.signal");const e=[];for await(const n of this){var r;if(t!=null&&(r=t.signal)!==null&&r!==void 0&&r.aborted)throw new Ue(void 0,{cause:t.signal.reason});Hu(e,n)}return e}function of(t,e){const r=xr.call(this,t,e);return(async function*(){for await(const i of r)yield*i}).call(this)}function Ws(t){if(t=Vu(t),Ku(t))return 0;if(t<0)throw new Cu("number",">= 0",t);return t}function af(t,e=void 0){return e!=null&&_t(e,"options"),(e==null?void 0:e.signal)!=null&&pt(e.signal,"options.signal"),t=Ws(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new Ue;for await(const a of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new Ue;t--<=0&&(yield a)}}).call(this)}function lf(t,e=void 0){return e!=null&&_t(e,"options"),(e==null?void 0:e.signal)!=null&&pt(e.signal,"options.signal"),t=Ws(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new Ue;for await(const a of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new Ue;if(t-- >0&&(yield a),t<=0)return}}).call(this)}Fr.streamReturningOperators={asIndexedPairs:qu(Zu,"readable.asIndexedPairs will be removed in a future version."),drop:af,filter:In,flatMap:of,map:xr,take:lf,compose:Xu},Fr.promiseReturningOperators={every:Ju,forEach:tf,reduce:nf,toArray:sf,some:Us,find:ef};var Rn,Gs;function zs(){if(Gs)return Rn;Gs=1;const{ArrayPrototypePop:t,Promise:e}=ce,{isIterable:r,isNodeStream:n,isWebStream:i}=He,{pipelineImpl:a}=En,{finished:l}=tt;Hs();function u(...p){return new e((_,y)=>{let E,w;const m=p[p.length-1];if(m&&typeof m=="object"&&!n(m)&&!r(m)&&!i(m)){const I=t(p);E=I.signal,w=I.end}a(p,(I,R)=>{I?y(I):_(R)},{signal:E,end:w})})}return Rn={finished:l,pipeline:u},Rn}var qs;function Hs(){if(qs)return $r.exports;qs=1;const{Buffer:t}=Fe,{ObjectDefineProperty:e,ObjectKeys:r,ReflectApply:n}=ce,{promisify:{custom:i}}=Ee,{streamReturningOperators:a,promiseReturningOperators:l}=Fr,{codes:{ERR_ILLEGAL_CONSTRUCTOR:u}}=Ie,p=$s,{setDefaultHighWaterMark:_,getDefaultHighWaterMark:y}=hr,{pipeline:E}=En,{destroyer:w}=vt,m=tt,I=zs(),R=He,v=$r.exports=Jr.Stream;v.isDestroyed=R.isDestroyed,v.isDisturbed=R.isDisturbed,v.isErrored=R.isErrored,v.isReadable=R.isReadable,v.isWritable=R.isWritable,v.Readable=pr();for(const O of r(a)){let q=function(...U){if(new.target)throw u();return v.Readable.from(n(T,this,U))};const T=a[O];e(q,"name",{__proto__:null,value:T.name}),e(q,"length",{__proto__:null,value:T.length}),e(v.Readable.prototype,O,{__proto__:null,value:q,enumerable:!1,configurable:!0,writable:!0})}for(const O of r(l)){let q=function(...U){if(new.target)throw u();return n(T,this,U)};const T=l[O];e(q,"name",{__proto__:null,value:T.name}),e(q,"length",{__proto__:null,value:T.length}),e(v.Readable.prototype,O,{__proto__:null,value:q,enumerable:!1,configurable:!0,writable:!0})}v.Writable=an(),v.Duplex=Qe(),v.Transform=xs,v.PassThrough=Ss,v.pipeline=E;const{addAbortSignal:k}=cr;return v.addAbortSignal=k,v.finished=m,v.destroy=w,v.compose=p,v.setDefaultHighWaterMark=_,v.getDefaultHighWaterMark=y,e(v,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return I}}),e(E,i,{__proto__:null,enumerable:!0,get(){return I.pipeline}}),e(m,i,{__proto__:null,enumerable:!0,get(){return I.finished}}),v.Stream=v,v._isUint8Array=function(T){return T instanceof Uint8Array},v._uint8ArrayToBuffer=function(T){return t.from(T.buffer,T.byteOffset,T.byteLength)},$r.exports}(function(t){const e=Hs(),r=zs(),n=e.Readable.destroy;t.exports=e.Readable,t.exports._uint8ArrayToBuffer=e._uint8ArrayToBuffer,t.exports._isUint8Array=e._isUint8Array,t.exports.isDisturbed=e.isDisturbed,t.exports.isErrored=e.isErrored,t.exports.isReadable=e.isReadable,t.exports.Readable=e.Readable,t.exports.Writable=e.Writable,t.exports.Duplex=e.Duplex,t.exports.Transform=e.Transform,t.exports.PassThrough=e.PassThrough,t.exports.addAbortSignal=e.addAbortSignal,t.exports.finished=e.finished,t.exports.destroy=e.destroy,t.exports.destroy=n,t.exports.pipeline=e.pipeline,t.exports.compose=e.compose,Object.defineProperty(e,"promises",{configurable:!0,enumerable:!0,get(){return r}}),t.exports.Stream=e.Stream,t.exports.default=t.exports})(Zn);var Qs=Zn.exports;const An=Symbol("iter");function qt(t,e,r=4){if(r===0)return Object.assign(t,e);for(const n in e)t[n]=qt(t[n]||Object.create(null),e[n],r-1);return t}function Vs(t,e,r=4){let n=!1;for(const i in t)if(i in e){const a=r===0?null:Vs(t[i],e[i],r-1);if(a!==!1)n=n||Object.create(null),n[i]=a;else if(r===3)return!1}return n}function Ks(t,e,r=4){let n=!1;for(const i in t)if(!(i in e))n=n||Object.create(null),n[i]=r===0?null:qt({},t[i],r-1);else if(r!==0){const a=Ks(t[i],e[i],r-1);if(a!==!1)n=n||Object.create(null),n[i]=a;else if(r===3)return!1}return n}class uf{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||ot}_termFromId(e){if(e[0]==="."){const 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 Bt(e,this._factory)}_termToNumericId(e){if(e.termType==="Quad"){const r=this._termToNumericId(e.subject),n=this._termToNumericId(e.predicate),i=this._termToNumericId(e.object);let a;return r&&n&&i&&(Lr(e.graph)||(a=this._termToNumericId(e.graph)))&&this._ids[a?`.${r}.${n}.${i}.${a}`:`.${r}.${n}.${i}`]}return this._ids[Et(e)]}_termToNewNumericId(e){const r=e&&e.termType==="Quad"?`.${this._termToNewNumericId(e.subject)}.${this._termToNewNumericId(e.predicate)}.${this._termToNewNumericId(e.object)}${Lr(e.graph)?"":`.${this._termToNewNumericId(e.graph)}`}`:Et(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))}}class Re{constructor(e,r){this._size=0,this._graphs=Object.create(null),!r&&e&&!e[0]&&(r=e,e=null),r=r||{},this._factory=r.factory||ot,this._entityIndex=r.entityIndex||new uf({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.addQuads(e)}get size(){let e=this._size;if(e!==null)return e;e=0;const r=this._graphs;let n,i;for(const a in r)for(const l in n=r[a].subjects)for(const u in i=n[l])e+=Object.keys(i[u]).length;return this._size=e}_addToIndex(e,r,n,i){const a=e[r]||(e[r]={}),l=a[n]||(a[n]={}),u=i in l;return u||(l[i]=null),!u}_removeFromIndex(e,r,n,i){const a=e[r],l=a[n];delete l[i];for(const u in l)return;delete a[n];for(const u in a)return;delete e[r]}*_findInIndex(e,r,n,i,a,l,u,p){let _,y,E;const w=this._entities,m=this._termFromId(w[p]),I={subject:null,predicate:null,object:null};r&&((_=e,e={})[r]=_[r]);for(const R in e)if(y=e[R]){I[a]=this._termFromId(w[R]),n&&((_=y,y={})[n]=_[n]);for(const v in y)if(E=y[v]){I[l]=this._termFromId(w[v]);const k=i?i in E?[i]:[]:Object.keys(E);for(let O=0;O<k.length;O++)I[u]=this._termFromId(w[k[O]]),yield this._factory.quad(I.subject,I.predicate,I.object,m)}}}_loop(e,r){for(const n in e)r(n)}_loopByKey0(e,r,n){let i,a;if(i=e[r])for(a in i)n(a)}_loopByKey1(e,r,n){let i,a;for(i in e)a=e[i],a[r]&&n(i)}_loopBy2Keys(e,r,n,i){let a,l,u;if((a=e[r])&&(l=a[n]))for(u in l)i(u)}_countInIndex(e,r,n,i){let a=0,l,u,p;r&&((l=e,e={})[r]=l[r]);for(const _ in e)if(u=e[_]){n&&((l=u,u={})[n]=l[n]);for(const y in u)(p=u[y])&&(i?i in p&&a++:a+=Object.keys(p).length)}return a}_getGraphs(e){return e=e===""?1:e&&(this._termToNumericId(e)||-1),typeof e!="number"?this._graphs:{[e]:this._graphs[e]}}_uniqueEntities(e){const 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 a=this._graphs[i];return a||(a=this._graphs[i]={subjects:{},predicates:{},objects:{}},Object.freeze(a)),e=this._termToNewNumericId(e),r=this._termToNewNumericId(r),n=this._termToNewNumericId(n),this._addToIndex(a.subjects,e,r,n)?(this._addToIndex(a.predicates,r,n,e),this._addToIndex(a.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;const a=this._graphs;let l,u,p;if(!(e=e&&this._termToNumericId(e))||!(r=r&&this._termToNumericId(r))||!(n=n&&this._termToNumericId(n))||!(l=a[i])||!(u=l.subjects[e])||!(p=u[r])||!(n in p))return!1;this._removeFromIndex(l.subjects,e,r,n),this._removeFromIndex(l.predicates,r,n,e),this._removeFromIndex(l.objects,n,e,r),this._size!==null&&this._size--;for(e in l.subjects)return!0;return delete a[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){const a=new Qs.Readable({objectMode:!0}),l=this.readQuads(e,r,n,i);return a._read=u=>{for(;--u>=0;){const{done:p,value:_}=l.next();if(p){a.push(null);return}a.push(_)}},this.remove(a)}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){const a=this._getGraphs(i);let l,u,p,_;if(!(e&&!(u=this._termToNumericId(e))||r&&!(p=this._termToNumericId(r))||n&&!(_=this._termToNumericId(n))))for(const y in a)(l=a[y])&&(u?_?yield*this._findInIndex(l.objects,_,u,p,"object","subject","predicate",y):yield*this._findInIndex(l.subjects,u,p,null,"subject","predicate","object",y):p?yield*this._findInIndex(l.predicates,p,_,null,"predicate","object","subject",y):_?yield*this._findInIndex(l.objects,_,null,null,"object","subject","predicate",y):yield*this._findInIndex(l.subjects,null,null,null,"subject","predicate","object",y))}match(e,r,n,i){return new rt(this,e,r,n,i,{entityIndex:this._entityIndex})}countQuads(e,r,n,i){const a=this._getGraphs(i);let l=0,u,p,_,y;if(e&&!(p=this._termToNumericId(e))||r&&!(_=this._termToNumericId(r))||n&&!(y=this._termToNumericId(n)))return 0;for(const E in a)(u=a[E])&&(e?n?l+=this._countInIndex(u.objects,y,p,_):l+=this._countInIndex(u.subjects,p,_,y):r?l+=this._countInIndex(u.predicates,_,y,p):l+=this._countInIndex(u.objects,y,p,_));return l}forEach(e,r,n,i,a){this.some(l=>(e(l,this),!1),r,n,i,a)}every(e,r,n,i,a){return!this.some(l=>!e(l,this),r,n,i,a)}some(e,r,n,i,a){for(const l of this.readQuads(r,n,i,a))if(e(l))return!0;return!1}getSubjects(e,r,n){const i=[];return this.forSubjects(a=>{i.push(a)},e,r,n),i}forSubjects(e,r,n,i){const a=this._getGraphs(i);let l,u,p;if(e=this._uniqueEntities(e),!(r&&!(u=this._termToNumericId(r))||n&&!(p=this._termToNumericId(n))))for(i in a)(l=a[i])&&(u?p?this._loopBy2Keys(l.predicates,u,p,e):this._loopByKey1(l.subjects,u,e):p?this._loopByKey0(l.objects,p,e):this._loop(l.subjects,e))}getPredicates(e,r,n){const i=[];return this.forPredicates(a=>{i.push(a)},e,r,n),i}forPredicates(e,r,n,i){const a=this._getGraphs(i);let l,u,p;if(e=this._uniqueEntities(e),!(r&&!(u=this._termToNumericId(r))||n&&!(p=this._termToNumericId(n))))for(i in a)(l=a[i])&&(u?p?this._loopBy2Keys(l.objects,p,u,e):this._loopByKey0(l.subjects,u,e):p?this._loopByKey1(l.predicates,p,e):this._loop(l.predicates,e))}getObjects(e,r,n){const i=[];return this.forObjects(a=>{i.push(a)},e,r,n),i}forObjects(e,r,n,i){const a=this._getGraphs(i);let l,u,p;if(e=this._uniqueEntities(e),!(r&&!(u=this._termToNumericId(r))||n&&!(p=this._termToNumericId(n))))for(i in a)(l=a[i])&&(u?p?this._loopBy2Keys(l.subjects,u,p,e):this._loopByKey1(l.objects,u,e):p?this._loopByKey0(l.predicates,p,e):this._loop(l.objects,e))}getGraphs(e,r,n){const i=[];return this.forGraphs(a=>{i.push(a)},e,r,n),i}forGraphs(e,r,n,i){for(const a in this._graphs)this.some(l=>(e(l.graph),!0),r,n,i,this._termFromId(this._entities[a]))}createBlankNode(e){return this._entityIndex.createBlankNode(e)}extractLists({remove:e=!1,ignoreErrors:r=!1}={}){const n={},i=r?()=>!0:(u,p)=>{throw new Error(`${u.value} ${p}`)},a=this.getQuads(null,ye.rdf.rest,ye.rdf.nil,null),l=e?[...a]:[];return a.forEach(u=>{const p=[];let _=!1,y,E;const w=u.graph;let m=u.subject;for(;m&&!_;){const I=this.getQuads(null,null,m,null),R=this.getQuads(m,null,null,null);let v,k=null,O=null,T=null;for(let q=0;q<R.length&&!_;q++)v=R[q],v.graph.equals(w)?y?_=i(m,"has non-list arcs out"):v.predicate.value===ye.rdf.first?k?_=i(m,"has multiple rdf:first arcs"):l.push(k=v):v.predicate.value===ye.rdf.rest?O?_=i(m,"has multiple rdf:rest arcs"):l.push(O=v):I.length?_=i(m,"can't be subject and object"):(y=v,E="subject"):_=i(m,"not confined to single graph");for(let q=0;q<I.length&&!_;++q)v=I[q],y?_=i(m,"can't have coreferences"):v.predicate.value===ye.rdf.rest?T?_=i(m,"has incoming rdf:rest arcs"):T=v:(y=v,E="object");k?p.unshift(k.object):_=i(m,"has no list head"),m=T&&T.subject}_?e=!1:y&&(n[y[E].value]=p)}),e&&this.removeQuads(l),n}addAll(e){if(e instanceof rt&&(e=e.filtered),Array.isArray(e))this.addQuads(e);else if(e instanceof Re&&e._entityIndex===this._entityIndex)e._size!==0&&(this._graphs=qt(this._graphs,e._graphs),this._size=null);else for(const r of e)this.add(r);return this}contains(e){if(e instanceof rt&&(e=e.filtered),e===this)return!0;if(!(e instanceof Re)||this._entityIndex!==e._entityIndex)return e.every(_=>this.has(_));const r=this._graphs,n=e._graphs;let i,a,l,u,p;for(const _ in n){if(!(i=r[_]))return!1;i=i.subjects;for(const y in a=n[_].subjects){if(!(l=i[y]))return!1;for(const E in u=a[y]){if(!(p=l[E]))return!1;for(const w in u[E])if(!(w in p))return!1}}}return!0}deleteMatches(e,r,n,i){for(const a of this.match(e,r,n,i))this.removeQuad(a);return this}difference(e){if(e&&e instanceof rt&&(e=e.filtered),e===this)return new Re({entityIndex:this._entityIndex});if(e instanceof Re&&e._entityIndex===this._entityIndex){const r=new Re({entityIndex:this._entityIndex}),n=Ks(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 rt&&(e=e.filtered),e===this||this.size===e.size&&this.contains(e)}filter(e){const r=new Re({entityIndex:this._entityIndex});for(const n of this)e(n,this)&&r.add(n);return r}intersection(e){if(e instanceof rt&&(e=e.filtered),e===this){const r=new Re({entityIndex:this._entityIndex});return r._graphs=qt(Object.create(null),this._graphs),r._size=this._size,r}else if(e instanceof Re&&this._entityIndex===e._entityIndex){const r=new Re({entityIndex:this._entityIndex}),n=Vs(e._graphs,this._graphs);return n&&(r._graphs=n,r._size=null),r}return this.filter(r=>e.has(r))}map(e){const r=new Re({entityIndex:this._entityIndex});for(const n of this)r.add(e(n,this));return r}reduce(e,r){const n=this.readQuads();let i=r===void 0?n.next().value:r;for(const a of n)i=e(i,a,this);return i}toArray(){return this.getQuads()}toCanonical(){throw new Error("not implemented")}toStream(){return this.match()}toString(){return new Kn().quadsToString(this)}union(e){const r=new Re({entityIndex:this._entityIndex});return r._graphs=qt(Object.create(null),this._graphs),r._size=this._size,r.addAll(e),r}*[Symbol.iterator](){yield*this.readQuads()}}function We(t,e,r=0){const n=e[r];if(n&&!(n in t))return!1;let i=!1;for(const a in n?{[n]:t[n]}:t){const l=r===2?null:We(t[a],e,r+1);l!==!1&&(i=i||Object.create(null),i[a]=l)}return i}class rt extends Qs.Readable{constructor(e,r,n,i,a,l){super({objectMode:!0}),Object.assign(this,{n3Store:e,subject:r,predicate:n,object:i,graph:a,options:l})}get filtered(){if(!this._filtered){const{n3Store:e,graph:r,object:n,predicate:i,subject:a}=this,l=this._filtered=new Re({factory:e._factory,entityIndex:this.options.entityIndex});let u,p,_;if(a&&!(u=l._termToNumericId(a))||i&&!(p=l._termToNumericId(i))||n&&!(_=l._termToNumericId(n)))return l;const y=e._getGraphs(r);for(const E in y){let w,m,I;!u&&p?(m=We(y[E].predicates,[p,_,u]))&&(w=We(y[E].subjects,[u,p,_]),I=We(y[E].objects,[_,u,p])):_?(I=We(y[E].objects,[_,u,p]))&&(w=We(y[E].subjects,[u,p,_]),m=We(y[E].predicates,[p,_,u])):(w=We(y[E].subjects,[u,p,_]))&&(m=We(y[E].predicates,[p,_,u]),I=We(y[E].objects,[_,u,p])),w&&(l._graphs[E]={subjects:w,predicates:m,objects:I})}l._size=null}return this._filtered}get size(){return this.filtered.size}_read(e){e>0&&!this[An]&&(this[An]=this[Symbol.iterator]());const r=this[An];for(;--e>=0;){const{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,a){return this.filtered.every(e,r,n,i,a)}filter(e){return this.filtered.filter(e)}forEach(e,r,n,i,a){return this.filtered.forEach(e,r,n,i,a)}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,a){return this.filtered.some(e,r,n,i,a)}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 Kn().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 rt(this.filtered,e,r,n,i,this.options)}*[Symbol.iterator](){yield*this._filtered||this.n3Store.readQuads(this.subject,this.predicate,this.object,this.graph)}}const Er={rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#"},pe={namespace:"https://prez.dev/",label:"https://prez.dev/label",description:"https://prez.dev/description",provenance:"https://prez.dev/provenance",focusNode:"https://prez.dev/FocusNode",link:"https://prez.dev/link",members:"https://prez.dev/members",identifier:"https://prez.dev/identifier",count:"https://prez.dev/count",searchResult:"https://prez.dev/SearchResult",searchResultWeight:"https://prez.dev/searchResultWeight",searchResultPredicate:"https://prez.dev/searchResultPredicate",searchResultURI:"https://prez.dev/searchResultURI",searchResultMatch:"https://prez.dev/searchResultMatch",hasChildren:"https://prez.dev/hasChildren"},be={skosConceptScheme:"http://www.w3.org/2004/02/skos/core#ConceptScheme",skosConcept:"http://www.w3.org/2004/02/skos/core#Concept",a:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",rdfLangString:"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",xmlString:"http://www.w3.org/2001/XMLSchema#string",w3Html:"http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML",w3Markdown:"https://www.w3.org/ns/iana/media-types/text/markdown",shaclAllPredicates:"http://example.com/shacl-extension#allPredicateValues",shaclProperty:"http://www.w3.org/ns/shacl#property",shaclPath:"http://www.w3.org/ns/shacl#path",shaclUnion:"http://www.w3.org/ns/shacl#union"},ff={label:["https://prez.dev/label"],description:["https://prez.dev/description"],provenance:["https://prez.dev/provenance"]};function Ys(t,e=Er){if(t==="a")return e.rdf+"type";{const[r,n]=t.split(":");return r?[r]+n:t}}function Xs(t,e=Er){let r="";return Object.entries(e).forEach(([n,i])=>{t.startsWith(i)&&(r=n+":"+t.split(i)[1])}),r}const Zs=t=>{const e=new URL(t);return`${e.protocol}//${e.hostname}`},cf=t=>new URL(t).pathname,df=(t,e)=>{var n,i;const r=(i=(n=e.identifiers)==null?void 0:n.find(a=>a.value))==null?void 0:i.value;return r?t+`/concept-hierarchy/${r}/narrowers`:""},hf=(t,e)=>{var l;const r=e?Zs(e):"",n=(l=t.identifiers)==null?void 0:l.find(u=>u.value),i=n?n.value:"";return i?r+`/concept-hierarchy/${i}/top-concepts`:""},Sr=t=>t.flatMap(e=>{var r;if(e["@id"])return e["@id"];if(e["@list"]&&e["@list"].length>0){const n=e["@list"][0];return(n==null?void 0:n["@id"])===be.shaclUnion?Sr(((r=e["@list"][1])==null?void 0:r["@list"])||[]).filter(Boolean):Sr(e["@list"]).flat()}return[]}).filter(e=>!!e),pf=t=>t.reduce((e,r)=>{if(be.shaclProperty in r)for(const n of r[be.shaclProperty]){const i=t.find(a=>a["@id"]===n["@id"]);i&&be.shaclPath in i&&(e[r["@id"]]=Sr(i[be.shaclPath]).filter(a=>a!==be.shaclAllPredicates))}return e},{});function Ht(t){if(Array.isArray(t))return t.reduce((e,r)=>{const n=Ht(r);return typeof n=="object"&&!Array.isArray(n)&&Object.assign(e,n),e},{});if(typeof t=="object"&&t!==null){if(t.hasOwnProperty("value"))return t.value;if(t.hasOwnProperty("node")&&t.hasOwnProperty("list")){const e={};return e[t.node.value]=t.list.length>0?Ht(t.list):"",e}else{const e={};for(const r in t)e[r]=Ht(t[r]);return e}}return t}function Tn(t,e=""){let r="";const n=Object.entries(t),i=n.length;return n.forEach(([a,l],u)=>{const p=a.replace(/https?:\/\/(www\.)?/,""),[_,y]=p.split("#"),E=_.split("/"),w=E[E.length-1],m=y?`(${E[0]})/${w}#${y}`:`(${E[0]})/${w}`,I=u===i-1;r+=`${e}${I?"└── ":"├── "}${m}
28
- `,typeof l=="object"&&l!==null&&(r+=Tn(l,e+(I?" ":"│ ")))}),r}function _f(t){return t?Tn(Ht(t)):""}const{namedNode:Qt}=ot;class Ir{constructor(){nt(this,"store");nt(this,"parser");nt(this,"prefixes");nt(this,"basePath");nt(this,"baseUrl");nt(this,"linkedLists");nt(this,"lists");this.store=new Re,this.baseUrl="",this.basePath="",this.parser=new qn,this.prefixes=Er,this.linkedLists={},this.lists={}}load(e){e=`PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
29
- `+e;const r=this.parser.parse(e,null,(n,i)=>{this.prefixes[n]=i.value});this.store.addQuads(r),this.linkedLists=this.store.extractLists(),this.buildLists()}buildSubList(e){const r=[];for(const n of e)if(n.termType=="BlankNode"){const i=n.value;if(i in this.linkedLists){const a=this.buildSubList(this.linkedLists[i]);if(a.length>1){const l=r.find(u=>u.node.value==a[0].node.value);l?(l.list??(l.list=[])).push(...a.slice(1)):r.push({node:a[0].node,list:a.slice(1)})}else r.push(...a)}}else if(n.termType=="NamedNode"&&n.value!=be.shaclUnion){const i=this.toPrezTerm(new Pr(n.value));r.push({node:i,list:[]})}return r}buildLists(){this.lists={};const e=this.linkedLists;for(const r in e){const n=e[r];if(n.find(a=>a.termType=="NamedNode"&&a.value==be.shaclUnion)){const a=n.find(l=>l.termType=="BlankNode");a&&a.value in this.linkedLists&&(this.lists[r]=this.buildSubList(this.linkedLists[a.value]))}}}setBaseUrl(e){this.baseUrl=e,this.basePath=new URL(e).pathname}toIri(e){return Ys(e,this.prefixes)}fromIri(e){return Xs(e,this.prefixes)}getObjectLiteral(e,r){return this.getObjects(e,r).map(n=>this.toPrezTerm(n))[0]||void 0}getProperties(e,r){const n={};return this.store.forEach(i=>{var a;r!=null&&r.excludePrefix&&i.predicate.value.startsWith(r.excludePrefix)||r!=null&&r.includePrefix&&!i.predicate.value.startsWith(r.includePrefix)||(n[a=i.predicate.value]??(n[a]={predicate:this.toPrezTerm(i.predicate),objects:[]}),n[i.predicate.value].objects.push(this.toPrezTerm(i.object)))},e,null,null,null),e.termType,n}getParents(e){e.startsWith(this.basePath)&&(e=e.substring(this.basePath.length));const r=e.split("/"),n=[];let i="";for(const a of r){if(a=="")continue;i+="/"+a;const l={url:i,segment:a};if(a.includes(":")){const u=a.split(":"),p=this.prefixes[u[0]];if(p){const _=this.getObjects(p+u[1],pe.label);_.length>0&&(l.label=Ar(_[0].value))}}n.push(l)}return n}toPrezTerm(e){switch(e.termType){case"NamedNode":const r=it(e.value);r.label=this.getObjectLiteral(e.value,pe.label),r.description=this.getObjectLiteral(e.value,pe.description),r.provenance=this.getObjectLiteral(e.value,pe.provenance);const n=this.getObjects(e.value,pe.identifier);n.length>0&&(r.identifiers=n.map(_=>this.toPrezTerm(_)));const i=this.getObjects(e.value,pe.link);i.length>0&&(r.links=i.map(_=>({value:_.value,parents:this.getParents(_.value)})));const a=this.getObjects(e.value,pe.members);a.length>0&&(r.members={value:a[0].value,parents:this.getParents(a[0].value)});const l=this.getObjects(e.value,be.a);return l.length>0&&(r.rdfTypes=l.map(_=>this.toPrezTerm(_))),r;case"Literal":const u=Ar(e.value);return e.datatype&&(u.datatype=this.toPrezTerm(e.datatype)),e.language&&(u.language=e.language),u;case"BlankNode":const p=Bn(e.value);return p.properties=this.getProperties(e),e.value in this.lists&&(p.list=this.lists[e.value]),p;default:throw"Invalid n3 Term object"}}toPrezFocusNode(e){var n,i,a,l,u;const r=this.toPrezTerm(e);return r.properties=this.getProperties(e,{excludePrefix:pe.namespace}),r.systemProperties=this.getProperties(e,{includePrefix:pe.namespace}),(n=r.rdfTypes)!=null&&n.map(p=>p.value).includes(be.skosConcept)&&(r.hasChildren=((u=(l=(a=(i=r.systemProperties)==null?void 0:i[pe.hasChildren])==null?void 0:a.objects)==null?void 0:l[0])==null?void 0:u.value)=="true"),r}getSubjects(e,r){return this.store.getSubjects(e,r,null)}getObjects(e,r){if(typeof r=="string")return this.store.getObjects(Qt(e),Qt(r),null);{const n=[];return r.forEach(i=>{n.push(...this.store.getObjects(Qt(e),Qt(i),null))}),n}}getMembers(e){this.getObjects(e,this.toIri("prez:members")).forEach(n=>({value:n.value,parents:[]}))}getConcepts(e){const r=this.getSubjects(this.toIri("skos:inScheme"),e.value);function n(_){return r.map(y=>y.value).includes(_.value)}const i=this.getObjects(e.value,this.toIri("skos:hasTopConcept")),a=this.getObjects(e.value,this.toIri("skos:topConceptOf")),l={},u=[...i,...a].filter(_=>n(_));r.forEach(_=>{l[_.value]=[]}),r.forEach(_=>{this.getObjects(_.value,this.toIri("skos:broader")).forEach(w=>{n(w)&&l[w.value].push(_)}),this.getObjects(_.value,this.toIri("skos:narrower")).forEach(w=>{n(w)&&l[_.value].push(w)})});const p=[];return u.forEach(_=>{p.push(this.createHierarchy(_,l))}),p}createHierarchy(e,r){const n=r[e.value].map(i=>this.createHierarchy(i,r));return{...this.toPrezTerm(e),hasChildren:n.length>0,narrowers:n}}getByPrezId(e){const r=[];return this.store.forEach(n=>{r.push(n)},null,null,Qt("https://prez.dev/FocusNode"),null),e?r.find(n=>n.object.value===e).subject:r.map(n=>n.subject)}getCount(){const e=this.store.getObjects(null,pe.count,null);return e.length>0?Number(e[0].value.replace(">","")):0}getMaxReached(){const e=this.store.getObjects(null,pe.count,null);return e.length>0?e[0].value.includes(">"):!1}getList(){const e=[];return this.getByPrezId().forEach(n=>{e.push(this.toPrezFocusNode(n))}),e}getItem(){var n;const e=this.getByPrezId();if(e.length==0)throw new Error("Unable to find item");const r=this.toPrezFocusNode(e[0]);if((n=r.rdfTypes)!=null&&n.map(i=>i.value).includes(be.skosConcept)){const i=this.getConcepts(e[0]);return{...r,topConcepts:{narrowers:i,hasChildren:i.length>0}}}return r}getSubItems(e){const r=this.store.getQuads(null,e,null,null),n=[];return r.forEach(i=>{const a=this.toPrezFocusNode(i.object);a&&n.push(a)}),n}search(){return this.getSubjects(be.a,pe.searchResult).map(n=>({hash:n.value.split("urn:hash:").slice(-1)[0],weight:Number(this.getObjects(n.value,pe.searchResultWeight)[0].value),predicate:this.toPrezTerm(this.getObjects(n.value,pe.searchResultPredicate)[0]),match:this.toPrezTerm(this.getObjects(n.value,pe.searchResultMatch)[0]),resource:this.toPrezFocusNode(this.getObjects(n.value,pe.searchResultURI)[0])}))}}class bf extends Error{constructor(e){super(e),this.name="NetworkError"}}function yf(t){let e={};const r=t.split(",").map(i=>{const[,a,l]=i.trim().match(/<(.+)>; (.+)/),u={uri:a};return l.split("; ").forEach(p=>{const[,_,y]=p.match(/(.+)=[\"<](.+)[\">]/);u[_]=y}),u});r.filter(i=>i.rel==="type").forEach(i=>{e[i.anchor]={default:!1,current:!1,token:i.token,mediatypes:[],title:i.title,description:"",uri:i.anchor}});const n=r.find(i=>i.rel==="self");return n.format in e&&(e[n.format].current=!0),r.filter(i=>i.rel==="alternate"&&i.format).forEach(i=>{e[i.format].mediatypes.map(a=>a.mediatype).includes(i.type)||e[i.format].mediatypes.push({title:"",mediatype:i.type,default:!1})}),Object.values(e)}async function Rr(t){const e=await fetch(t,{method:"GET",headers:{Accept:"text/anot+turtle"}});if(!e.ok)throw new bf(`Network error - status code ${e.status}: ${e.statusText}`);const r=e.headers.get("link")||e.headers.get("Link"),n=r?yf(r):[];return{data:await e.text(),profiles:n}}async function Js(t,e){const r=t+e,n=new URL(r).pathname,{data:i,profiles:a}=await Rr(r),l=new Ir;return l.setBaseUrl(t),l.load(i),{type:"list",data:l.getList(),profiles:a,maxReached:l.getMaxReached(),count:l.getCount(),parents:l.getParents(n)}}async function gf(t,e){const r=t+e,n=new URL(r).pathname,{data:i,profiles:a}=await Rr(r),l=new Ir;return l.setBaseUrl(t),l.load(i),{type:"item",data:l.getItem(),profiles:a,parents:l.getParents(n),store:l}}async function wf(t,e){const r=t+e,n=new URL(r).pathname,{data:i,profiles:a}=await Rr(r),l=new Ir;return l.setBaseUrl(t),l.load(i),{type:"search",data:l.search(),profiles:a,maxReached:l.getMaxReached(),count:l.getCount(),parents:l.getParents(n)}}async function mf(t){var i,a;const e="/profiles?page=1&limit=999&_mediatype=application/anot%2Bturtle",{data:r}=await Js(t,e),n={};for(const l of r)if(n[l.value]=[],l.properties&&((a=(i=l.properties)==null?void 0:i[be.shaclProperty])!=null&&a.objects)){const u=l.properties[be.shaclProperty].objects;for(const p of u){const _=p;if(_.properties&&_.properties[be.shaclPath])for(const y of _.properties[be.shaclPath].objects){const E=y.list;E&&(n[l.value]=E)}}}return n}function xf(t,e){const r={},n=Object.keys(t),i=[...(e||[]).filter(a=>n.includes(a.node.value)).map(a=>a.node.value),...n.filter(a=>!(e||[]).find(l=>l.node.value==a))].filter(a=>a in(t||{})).map(a=>t[a]);for(const a of i)e.find(l=>l.node.value==a.predicate.value&&l.list&&l.list.length>0),r[a.predicate.value]=t[a.predicate.value];return r}function Ef(t,e){t.data.properties=xf(t.data.properties||{},e)}z.ANNOTATION_PREDICATES=ff,z.DEFAULT_PREFIXES=Er,z.PREZ_PREDICATES=pe,z.RDFStore=Ir,z.SYSTEM_PREDICATES=be,z.apiGet=Rr,z.applyProfileToItem=Ef,z.bnode=Bn,z.buildProfiles=pf,z.defaultFromIri=Xs,z.defaultToIri=Ys,z.dumpNodeArray=_f,z.getBaseUrl=Zs,z.getItem=gf,z.getList=Js,z.getNarrowersUrl=df,z.getProfiles=mf,z.getTopConceptsUrl=hf,z.getUrlPath=cf,z.isTypePrezTerm=Te,z.literal=Ar,z.node=it,z.nodeArrayToTree=Tn,z.processShaclPath=Sr,z.search=wf,z.simplifyNodeArray=Ht,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
26
+ `),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 zn(t){let e=go[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}function qn(t){return t.replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&")}var Hn={exports:{}},Pr={exports:{}},oe={AggregateError: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}
27
+ `;super(r),this.name="AggregateError",this.errors=e}},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},Qn={exports:{}},Vn={format(t,...e){return t.replace(/%([sdifj])/g,function(...[r,n]){const 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"{}"}}};const{format:wo,inspect:Jt}=Vn,{AggregateError:mo}=oe,xo=globalThis.AggregateError||mo,Eo=Symbol("kIsNodeError"),So=["string","function","number","object","Function","Object","boolean","bigint","symbol"],Io=/^([A-Z][a-z0-9]*)+$/,Ro="__node_internal_",er={};function at(t,e){if(!t)throw new er.ERR_INTERNAL_ASSERTION(e)}function Kn(t){let e="",r=t.length;const 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 Ao(t,e,r){if(typeof e=="function")return at(e.length<=r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${e.length}).`),e(...r);const n=(e.match(/%[dfijoOs]/g)||[]).length;return at(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:wo(e,...r)}function be(t,e,r){r||(r=Error);class n extends r{constructor(...a){super(Ao(t,e,a))}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[Eo]=!0,er[t]=n}function Yn(t){const e=Ro+t.name;return Object.defineProperty(t,"name",{value:e}),t}function To(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;const r=new xo([e,t],e.message);return r.code=e.code,r}return t||e}let vo=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new er.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};be("ERR_ASSERTION","%s",Error),be("ERR_INVALID_ARG_TYPE",(t,e,r)=>{at(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 ";const i=[],a=[],l=[];for(const p of e)at(typeof p=="string","All expected entries have to be of type string"),So.includes(p)?i.push(p.toLowerCase()):Io.test(p)?a.push(p):(at(p!=="object",'The value "object" should be written as "Object"'),l.push(p));if(a.length>0){const p=i.indexOf("object");p!==-1&&(i.splice(i,p,1),a.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:{const p=i.pop();n+=`one of type ${i.join(", ")}, or ${p}`}}(a.length>0||l.length>0)&&(n+=" or ")}if(a.length>0){switch(a.length){case 1:n+=`an instance of ${a[0]}`;break;case 2:n+=`an instance of ${a[0]} or ${a[1]}`;break;default:{const p=a.pop();n+=`an instance of ${a.join(", ")}, or ${p}`}}l.length>0&&(n+=" or ")}switch(l.length){case 0:break;case 1:l[0].toLowerCase()!==l[0]&&(n+="an "),n+=`${l[0]}`;break;case 2:n+=`one of ${l[0]} or ${l[1]}`;break;default:{const p=l.pop();n+=`one of ${l.join(", ")}, or ${p}`}}if(r==null)n+=`. Received ${r}`;else if(typeof r=="function"&&r.name)n+=`. Received function ${r.name}`;else if(typeof r=="object"){var u;if((u=r.constructor)!==null&&u!==void 0&&u.name)n+=`. Received an instance of ${r.constructor.name}`;else{const p=Jt(r,{depth:-1});n+=`. Received ${p}`}}else{let p=Jt(r,{colors:!1});p.length>25&&(p=`${p.slice(0,25)}...`),n+=`. Received type ${typeof r} (${p})`}return n},TypeError),be("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=Jt(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError),be("ERR_INVALID_RETURN_VALUE",(t,e,r)=>{var n;const 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),be("ERR_MISSING_ARGS",(...t)=>{at(t.length>0,"At least one arg needs to be specified");let e;const 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:{const n=t.pop();e+=`The ${t.join(", ")}, and ${n} arguments`}break}return`${e} must be specified`},TypeError),be("ERR_OUT_OF_RANGE",(t,e,r)=>{at(e,'Missing "range" argument');let n;if(Number.isInteger(r)&&Math.abs(r)>2**32)n=Kn(String(r));else if(typeof r=="bigint"){n=String(r);const i=BigInt(2)**BigInt(32);(r>i||r<-i)&&(n=Kn(n)),n+="n"}else n=Jt(r);return`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError),be("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),be("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),be("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),be("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),be("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),be("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),be("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),be("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),be("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),be("ERR_STREAM_WRITE_AFTER_END","write after end",Error),be("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);var xe={AbortError:vo,aggregateTwoErrors:Yn(To),hideStackFrames:Yn,codes:er},Ct={exports:{}},Xn;function Ot(){if(Xn)return Ct.exports;Xn=1;const{AbortController:t,AbortSignal:e}=typeof self<"u"?self:typeof window<"u"?window:void 0;return Ct.exports=t,Ct.exports.AbortSignal=e,Ct.exports.default=t,Ct.exports}var jr={exports:{}},St=typeof Reflect=="object"?Reflect:null,Zn=St&&typeof St.apply=="function"?St.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},tr;St&&typeof St.ownKeys=="function"?tr=St.ownKeys:Object.getOwnPropertySymbols?tr=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:tr=function(e){return Object.getOwnPropertyNames(e)};function No(t){console&&console.warn&&console.warn(t)}var Jn=Number.isNaN||function(e){return e!==e};function X(){X.init.call(this)}jr.exports=X,jr.exports.once=$o,X.EventEmitter=X,X.prototype._events=void 0,X.prototype._eventsCount=0,X.prototype._maxListeners=void 0;var ei=10;function rr(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(X,"defaultMaxListeners",{enumerable:!0,get:function(){return ei},set:function(t){if(typeof t!="number"||t<0||Jn(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ei=t}}),X.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},X.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Jn(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 ti(t){return t._maxListeners===void 0?X.defaultMaxListeners:t._maxListeners}X.prototype.getMaxListeners=function(){return ti(this)},X.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",a=this._events;if(a!==void 0)i=i&&a.error===void 0;else if(!i)return!1;if(i){var l;if(r.length>0&&(l=r[0]),l instanceof Error)throw l;var u=new Error("Unhandled error."+(l?" ("+l.message+")":""));throw u.context=l,u}var p=a[e];if(p===void 0)return!1;if(typeof p=="function")Zn(p,this,r);else for(var _=p.length,y=oi(p,_),n=0;n<_;++n)Zn(y[n],this,r);return!0};function ri(t,e,r,n){var i,a,l;if(rr(r),a=t._events,a===void 0?(a=t._events=Object.create(null),t._eventsCount=0):(a.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),l=a[e]),l===void 0)l=a[e]=r,++t._eventsCount;else if(typeof l=="function"?l=a[e]=n?[r,l]:[l,r]:n?l.unshift(r):l.push(r),i=ti(t),i>0&&l.length>i&&!l.warned){l.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=l.length,No(u)}return t}X.prototype.addListener=function(e,r){return ri(this,e,r,!1)},X.prototype.on=X.prototype.addListener,X.prototype.prependListener=function(e,r){return ri(this,e,r,!0)};function Po(){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 ni(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=Po.bind(n);return i.listener=r,n.wrapFn=i,i}X.prototype.once=function(e,r){return rr(r),this.on(e,ni(this,e,r)),this},X.prototype.prependOnceListener=function(e,r){return rr(r),this.prependListener(e,ni(this,e,r)),this},X.prototype.removeListener=function(e,r){var n,i,a,l,u;if(rr(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(a=-1,l=n.length-1;l>=0;l--)if(n[l]===r||n[l].listener===r){u=n[l].listener,a=l;break}if(a<0)return this;a===0?n.shift():jo(n,a),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,u||r)}return this},X.prototype.off=X.prototype.removeListener,X.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 a=Object.keys(n),l;for(i=0;i<a.length;++i)l=a[i],l!=="removeListener"&&this.removeAllListeners(l);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 ii(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?Lo(i):oi(i,i.length)}X.prototype.listeners=function(e){return ii(this,e,!0)},X.prototype.rawListeners=function(e){return ii(this,e,!1)},X.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):si.call(t,e)},X.prototype.listenerCount=si;function si(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}X.prototype.eventNames=function(){return this._eventsCount>0?tr(this._events):[]};function oi(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function jo(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Lo(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function $o(t,e){return new Promise(function(r,n){function i(l){t.removeListener(e,a),n(l)}function a(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}ai(t,e,a,{once:!0}),e!=="error"&&Bo(t,i,{once:!0})})}function Bo(t,e,r){typeof t.on=="function"&&ai(t,"error",e,r)}function ai(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(a){n.once&&t.removeEventListener(e,i),r(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var nr=jr.exports;(function(t){const e=Fe,{format:r,inspect:n}=Vn,{codes:{ERR_INVALID_ARG_TYPE:i}}=xe,{kResistStopPropagation:a,AggregateError:l,SymbolDispose:u}=oe,p=globalThis.AbortSignal||Ot().AbortSignal,_=globalThis.AbortController||Ot().AbortController,y=Object.getPrototypeOf(async function(){}).constructor,x=globalThis.Blob||e.Blob,I=typeof x<"u"?function(v){return v instanceof x}:function(v){return!1},S=(m,v)=>{if(m!==void 0&&(m===null||typeof m!="object"||!("aborted"in m)))throw new i(v,"AbortSignal",m)},R=(m,v)=>{if(typeof m!="function")throw new i(v,"Function",m)};t.exports={AggregateError:l,kEmptyObject:Object.freeze({}),once(m){let v=!1;return function(...$){v||(v=!0,m.apply(this,$))}},createDeferredPromise:function(){let m,v;return{promise:new Promise((B,T)=>{m=B,v=T}),resolve:m,reject:v}},promisify(m){return new Promise((v,$)=>{m((B,...T)=>B?$(B):v(...T))})},debuglog(){return function(){}},format:r,inspect:n,types:{isAsyncFunction(m){return m instanceof y},isArrayBufferView(m){return ArrayBuffer.isView(m)}},isBlob:I,deprecate(m,v){return m},addAbortListener:nr.addAbortListener||function(v,$){if(v===void 0)throw new i("signal","AbortSignal",v);S(v,"signal"),R($,"listener");let B;return v.aborted?queueMicrotask(()=>$()):(v.addEventListener("abort",$,{__proto__:null,once:!0,[a]:!0}),B=()=>{v.removeEventListener("abort",$)}),{__proto__:null,[u](){var T;(T=B)===null||T===void 0||T()}}},AbortSignalAny:p.any||function(v){if(v.length===1)return v[0];const $=new _,B=()=>$.abort();return v.forEach(T=>{S(T,"signals"),T.addEventListener("abort",B,{once:!0})}),$.signal.addEventListener("abort",()=>{v.forEach(T=>T.removeEventListener("abort",B))},{once:!0}),$.signal}},t.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")})(Qn);var Se=Qn.exports,Lr={};const{ArrayIsArray:li,ArrayPrototypeIncludes:Fo,ArrayPrototypeJoin:ko,ArrayPrototypeMap:Co,NumberIsInteger:$r,NumberIsNaN:Ku,NumberMAX_SAFE_INTEGER:Oo,NumberMIN_SAFE_INTEGER:Mo,NumberParseInt:Yu,ObjectPrototypeHasOwnProperty:Do,RegExpPrototypeExec:Xu,String:Uo,StringPrototypeToUpperCase:Zu,StringPrototypeTrim:Ju}=oe,{hideStackFrames:Ne,codes:{ERR_SOCKET_BAD_PORT:ef,ERR_INVALID_ARG_TYPE:Pe,ERR_INVALID_ARG_VALUE:ui,ERR_OUT_OF_RANGE:It,ERR_UNKNOWN_SIGNAL:tf}}=xe,{normalizeEncoding:rf}=Se,{isAsyncFunction:Wo,isArrayBufferView:Go}=Se.types,zo=Ne((t,e,r=Mo,n=Oo)=>{if(typeof t!="number")throw new Pe(e,"number",t);if(!$r(t))throw new It(e,"an integer",t);if(t<r||t>n)throw new It(e,`>= ${r} && <= ${n}`,t)});Ne((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new Pe(e,"number",t);if(!$r(t))throw new It(e,"an integer",t);if(t<r||t>n)throw new It(e,`>= ${r} && <= ${n}`,t)}),Ne((t,e,r=!1)=>{if(typeof t!="number")throw new Pe(e,"number",t);if(!$r(t))throw new It(e,"an integer",t);const n=r?1:0,i=4294967295;if(t<n||t>i)throw new It(e,`>= ${n} && <= ${i}`,t)}),Ne((t,e,r)=>{if(!Fo(r,t)){const i="must be one of: "+ko(Co(r,a=>typeof a=="string"?`'${a}'`:Uo(a)),", ");throw new ui(e,t,i)}});function qo(t,e){if(typeof t!="boolean")throw new Pe(e,"boolean",t)}function Br(t,e,r){return t==null||!Do(t,e)?r:t[e]}const Ho=Ne((t,e,r=null)=>{const n=Br(r,"allowArray",!1),i=Br(r,"allowFunction",!1);if(!Br(r,"nullable",!1)&&t===null||!n&&li(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new Pe(e,"Object",t)});Ne((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new Pe(e,"a dictionary",t)}),Ne((t,e,r=0)=>{if(!li(t))throw new Pe(e,"Array",t);if(t.length<r){const n=`must be longer than ${r}`;throw new ui(e,t,n)}}),Ne((t,e="buffer")=>{if(!Go(t))throw new Pe(e,["Buffer","TypedArray","DataView"],t)});const Qo=Ne((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new Pe(e,"AbortSignal",t)}),Vo=Ne((t,e)=>{if(typeof t!="function")throw new Pe(e,"Function",t)});Ne((t,e)=>{if(typeof t!="function"||Wo(t))throw new Pe(e,"Function",t)}),Ne((t,e)=>{if(t!==void 0)throw new Pe(e,"undefined",t)});var Mt={validateBoolean:qo,validateFunction:Vo,validateInteger:zo,validateObject:Ho,validateAbortSignal:Qo},Fr={exports:{}},fi={exports:{}},de=fi.exports={},Ce,Oe;function kr(){throw new Error("setTimeout has not been defined")}function Cr(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Ce=setTimeout:Ce=kr}catch{Ce=kr}try{typeof clearTimeout=="function"?Oe=clearTimeout:Oe=Cr}catch{Oe=Cr}})();function ci(t){if(Ce===setTimeout)return setTimeout(t,0);if((Ce===kr||!Ce)&&setTimeout)return Ce=setTimeout,setTimeout(t,0);try{return Ce(t,0)}catch{try{return Ce.call(null,t,0)}catch{return Ce.call(this,t,0)}}}function Ko(t){if(Oe===clearTimeout)return clearTimeout(t);if((Oe===Cr||!Oe)&&clearTimeout)return Oe=clearTimeout,clearTimeout(t);try{return Oe(t)}catch{try{return Oe.call(null,t)}catch{return Oe.call(this,t)}}}var ze=[],Rt=!1,lt,ir=-1;function Yo(){!Rt||!lt||(Rt=!1,lt.length?ze=lt.concat(ze):ir=-1,ze.length&&di())}function di(){if(!Rt){var t=ci(Yo);Rt=!0;for(var e=ze.length;e;){for(lt=ze,ze=[];++ir<e;)lt&&lt[ir].run();ir=-1,e=ze.length}lt=null,Rt=!1,Ko(t)}}de.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];ze.push(new hi(t,e)),ze.length===1&&!Rt&&ci(di)};function hi(t,e){this.fun=t,this.array=e}hi.prototype.run=function(){this.fun.apply(null,this.array)},de.title="browser",de.browser=!0,de.env={},de.argv=[],de.version="",de.versions={};function qe(){}de.on=qe,de.addListener=qe,de.once=qe,de.off=qe,de.removeListener=qe,de.removeAllListeners=qe,de.emit=qe,de.prependListener=qe,de.prependOnceListener=qe,de.listeners=function(t){return[]},de.binding=function(t){throw new Error("process.binding is not supported")},de.cwd=function(){return"/"},de.chdir=function(t){throw new Error("process.chdir is not supported")},de.umask=function(){return 0};var ut=fi.exports;const{SymbolAsyncIterator:pi,SymbolIterator:_i,SymbolFor:ft}=oe,bi=ft("nodejs.stream.destroyed"),Xo=ft("nodejs.stream.errored"),yi=ft("nodejs.stream.readable"),gi=ft("nodejs.stream.writable"),Zo=ft("nodejs.stream.disturbed"),Jo=ft("nodejs.webstream.isClosedPromise"),ea=ft("nodejs.webstream.controllerErrorFunction");function Or(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 sr(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 ta(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function Me(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function wi(t){return!!(t&&!Me(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function mi(t){return!!(t&&!Me(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function xi(t){return!!(t&&!Me(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function ra(t){return wi(t)||mi(t)||xi(t)}function na(t,e){return t==null?!1:e===!0?typeof t[pi]=="function":e===!1?typeof t[_i]=="function":typeof t[pi]=="function"||typeof t[_i]=="function"}function or(t){if(!Me(t))return null;const e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[bi]||n!=null&&n.destroyed)}function ia(t){if(!sr(t))return null;if(t.writableEnded===!0)return!0;const e=t._writableState;return e!=null&&e.errored?!1:typeof(e==null?void 0:e.ended)!="boolean"?null:e.ended}function sa(t,e){if(!sr(t))return null;if(t.writableFinished===!0)return!0;const r=t._writableState;return r!=null&&r.errored?!1:typeof(r==null?void 0:r.finished)!="boolean"?null:!!(r.finished||e===!1&&r.ended===!0&&r.length===0)}function Ei(t,e){if(!Or(t))return null;const r=t._readableState;return r!=null&&r.errored?!1:typeof(r==null?void 0:r.endEmitted)!="boolean"?null:!!(r.endEmitted||e===!1&&r.ended===!0&&r.length===0)}function Si(t){return t&&t[yi]!=null?t[yi]:typeof(t==null?void 0:t.readable)!="boolean"?null:or(t)?!1:Or(t)&&t.readable&&!Ei(t)}function Ii(t){return t&&t[gi]!=null?t[gi]:typeof(t==null?void 0:t.writable)!="boolean"?null:or(t)?!1:sr(t)&&t.writable&&!ia(t)}function oa(t,e){return Me(t)?or(t)?!0:!((e==null?void 0:e.readable)!==!1&&Si(t)||(e==null?void 0:e.writable)!==!1&&Ii(t)):null}function aa(t){var e,r;return Me(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 la(t){var e,r;return Me(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 ua(t){if(!Me(t))return null;if(typeof t.closed=="boolean")return t.closed;const e=t._writableState,r=t._readableState;return typeof(e==null?void 0:e.closed)=="boolean"||typeof(r==null?void 0:r.closed)=="boolean"?(e==null?void 0:e.closed)||(r==null?void 0:r.closed):typeof t._closed=="boolean"&&Ri(t)?t._closed:null}function Ri(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function fa(t){return typeof t._sent100=="boolean"&&Ri(t)}function ca(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 da(t){if(!Me(t))return null;const e=t._writableState,r=t._readableState,n=e||r;return!n&&fa(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function ha(t){var e;return!!(t&&((e=t[Zo])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function pa(t){var e,r,n,i,a,l,u,p,_,y;return!!(t&&((e=(r=(n=(i=(a=(l=t[Xo])!==null&&l!==void 0?l:t.readableErrored)!==null&&a!==void 0?a:t.writableErrored)!==null&&i!==void 0?i:(u=t._readableState)===null||u===void 0?void 0:u.errorEmitted)!==null&&n!==void 0?n:(p=t._writableState)===null||p===void 0?void 0:p.errorEmitted)!==null&&r!==void 0?r:(_=t._readableState)===null||_===void 0?void 0:_.errored)!==null&&e!==void 0?e:!((y=t._writableState)===null||y===void 0)&&y.errored))}var He={isDestroyed:or,kIsDestroyed:bi,isDisturbed:ha,isErrored:pa,isReadable:Si,kIsClosedPromise:Jo,kControllerErrorFunction:ea,isClosed:ua,isDuplexNodeStream:ta,isFinished:oa,isIterable:na,isReadableNodeStream:Or,isReadableStream:wi,isReadableFinished:Ei,isReadableErrored:la,isNodeStream:Me,isWebStream:ra,isWritable:Ii,isWritableNodeStream:sr,isWritableStream:mi,isWritableFinished:sa,isWritableErrored:aa,isServerRequest:ca,willEmitClose:da,isTransformStream:xi};const Ze=ut,{AbortError:Ai,codes:_a}=xe,{ERR_INVALID_ARG_TYPE:ba,ERR_STREAM_PREMATURE_CLOSE:Ti}=_a,{kEmptyObject:Mr,once:Dr}=Se,{validateAbortSignal:ya,validateFunction:ga,validateObject:wa,validateBoolean:ma}=Mt,{Promise:xa,PromisePrototypeThen:Ea,SymbolDispose:vi}=oe,{isClosed:Sa,isReadable:Ni,isReadableNodeStream:Ur,isReadableStream:Ia,isReadableFinished:Pi,isReadableErrored:ji,isWritable:Li,isWritableNodeStream:$i,isWritableStream:Ra,isWritableFinished:Bi,isWritableErrored:Fi,isNodeStream:Aa,willEmitClose:Ta,kIsClosedPromise:va}=He;let At;function Na(t){return t.setHeader&&typeof t.abort=="function"}const Wr=()=>{};function ki(t,e,r){var n,i;if(arguments.length===2?(r=e,e=Mr):e==null?e=Mr:wa(e,"options"),ga(r,"callback"),ya(e.signal,"options.signal"),r=Dr(r),Ia(t)||Ra(t))return Pa(t,e,r);if(!Aa(t))throw new ba("stream",["ReadableStream","WritableStream","Stream"],t);const a=(n=e.readable)!==null&&n!==void 0?n:Ur(t),l=(i=e.writable)!==null&&i!==void 0?i:$i(t),u=t._writableState,p=t._readableState,_=()=>{t.writable||I()};let y=Ta(t)&&Ur(t)===a&&$i(t)===l,x=Bi(t,!1);const I=()=>{x=!0,t.destroyed&&(y=!1),!(y&&(!t.readable||a))&&(!a||S)&&r.call(t)};let S=Pi(t,!1);const R=()=>{S=!0,t.destroyed&&(y=!1),!(y&&(!t.writable||l))&&(!l||x)&&r.call(t)},m=U=>{r.call(t,U)};let v=Sa(t);const $=()=>{v=!0;const U=Fi(t)||ji(t);if(U&&typeof U!="boolean")return r.call(t,U);if(a&&!S&&Ur(t,!0)&&!Pi(t,!1))return r.call(t,new Ti);if(l&&!x&&!Bi(t,!1))return r.call(t,new Ti);r.call(t)},B=()=>{v=!0;const U=Fi(t)||ji(t);if(U&&typeof U!="boolean")return r.call(t,U);r.call(t)},T=()=>{t.req.on("finish",I)};Na(t)?(t.on("complete",I),y||t.on("abort",$),t.req?T():t.on("request",T)):l&&!u&&(t.on("end",_),t.on("close",_)),!y&&typeof t.aborted=="boolean"&&t.on("aborted",$),t.on("end",R),t.on("finish",I),e.error!==!1&&t.on("error",m),t.on("close",$),v?Ze.nextTick($):u!=null&&u.errorEmitted||p!=null&&p.errorEmitted?y||Ze.nextTick(B):(!a&&(!y||Ni(t))&&(x||Li(t)===!1)||!l&&(!y||Li(t))&&(S||Ni(t)===!1)||p&&t.req&&t.aborted)&&Ze.nextTick(B);const q=()=>{r=Wr,t.removeListener("aborted",$),t.removeListener("complete",I),t.removeListener("abort",$),t.removeListener("request",T),t.req&&t.req.removeListener("finish",I),t.removeListener("end",_),t.removeListener("close",_),t.removeListener("finish",I),t.removeListener("end",R),t.removeListener("error",m),t.removeListener("close",$)};if(e.signal&&!v){const U=()=>{const ae=r;q(),ae.call(t,new Ai(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)Ze.nextTick(U);else{At=At||Se.addAbortListener;const ae=At(e.signal,U),Ee=r;r=Dr((...ee)=>{ae[vi](),Ee.apply(t,ee)})}}return q}function Pa(t,e,r){let n=!1,i=Wr;if(e.signal)if(i=()=>{n=!0,r.call(t,new Ai(void 0,{cause:e.signal.reason}))},e.signal.aborted)Ze.nextTick(i);else{At=At||Se.addAbortListener;const l=At(e.signal,i),u=r;r=Dr((...p)=>{l[vi](),u.apply(t,p)})}const a=(...l)=>{n||Ze.nextTick(()=>r.apply(t,l))};return Ea(t[va].promise,a,a),Wr}function ja(t,e){var r;let n=!1;return e===null&&(e=Mr),(r=e)!==null&&r!==void 0&&r.cleanup&&(ma(e.cleanup,"cleanup"),n=e.cleanup),new xa((i,a)=>{const l=ki(t,e,u=>{n&&l(),u?a(u):i()})})}Fr.exports=ki,Fr.exports.finished=ja;var Je=Fr.exports;const De=ut,{aggregateTwoErrors:La,codes:{ERR_MULTIPLE_CALLBACK:$a},AbortError:Ba}=xe,{Symbol:Ci}=oe,{kIsDestroyed:Fa,isDestroyed:ka,isFinished:Ca,isServerRequest:Oa}=He,Oi=Ci("kDestroy"),Gr=Ci("kConstruct");function Mi(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function Ma(t,e){const r=this._readableState,n=this._writableState,i=n||r;return n!=null&&n.destroyed||r!=null&&r.destroyed?(typeof e=="function"&&e(),this):(Mi(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?Di(this,t,e):this.once(Oi,function(a){Di(this,La(a,t),e)}),this)}function Di(t,e,r){let n=!1;function i(a){if(n)return;n=!0;const l=t._readableState,u=t._writableState;Mi(a,u,l),u&&(u.closed=!0),l&&(l.closed=!0),typeof r=="function"&&r(a),a?De.nextTick(Da,t,a):De.nextTick(Ui,t)}try{t._destroy(e||null,i)}catch(a){i(a)}}function Da(t,e){zr(t,e),Ui(t)}function Ui(t){const 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 zr(t,e){const 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 Ua(){const 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 qr(t,e,r){const 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?De.nextTick(zr,t,e):zr(t,e))}function Wa(t,e){if(typeof t._construct!="function")return;const r=t._readableState,n=t._writableState;r&&(r.constructed=!1),n&&(n.constructed=!1),t.once(Gr,e),!(t.listenerCount(Gr)>1)&&De.nextTick(Ga,t)}function Ga(t){let e=!1;function r(n){if(e){qr(t,n??new $a);return}e=!0;const i=t._readableState,a=t._writableState,l=a||i;i&&(i.constructed=!0),a&&(a.constructed=!0),l.destroyed?t.emit(Oi,n):n?qr(t,n,!0):De.nextTick(za,t)}try{t._construct(n=>{De.nextTick(r,n)})}catch(n){De.nextTick(r,n)}}function za(t){t.emit(Gr)}function Wi(t){return(t==null?void 0:t.setHeader)&&typeof t.abort=="function"}function Gi(t){t.emit("close")}function qa(t,e){t.emit("error",e),De.nextTick(Gi,t)}function Ha(t,e){!t||ka(t)||(!e&&!Ca(t)&&(e=new Ba),Oa(t)?(t.socket=null,t.destroy(e)):Wi(t)?t.abort():Wi(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?De.nextTick(qa,t,e):De.nextTick(Gi,t),t.destroyed||(t[Fa]=!0))}var Tt={construct:Wa,destroyer:Ha,destroy:Ma,undestroy:Ua,errorOrDestroy:qr};const{ArrayIsArray:Qa,ObjectSetPrototypeOf:zi}=oe,{EventEmitter:ar}=nr;function lr(t){ar.call(this,t)}zi(lr.prototype,ar.prototype),zi(lr,ar),lr.prototype.pipe=function(t,e){const r=this;function n(y){t.writable&&t.write(y)===!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",l),r.on("close",u));let a=!1;function l(){a||(a=!0,t.end())}function u(){a||(a=!0,typeof t.destroy=="function"&&t.destroy())}function p(y){_(),ar.listenerCount(this,"error")===0&&this.emit("error",y)}Hr(r,"error",p),Hr(t,"error",p);function _(){r.removeListener("data",n),t.removeListener("drain",i),r.removeListener("end",l),r.removeListener("close",u),r.removeListener("error",p),t.removeListener("error",p),r.removeListener("end",_),r.removeListener("close",_),t.removeListener("close",_)}return r.on("end",_),r.on("close",_),t.on("close",_),t.emit("pipe",r),t};function Hr(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):Qa(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}var Qr={Stream:lr,prependListener:Hr},qi={exports:{}};(function(t){const{SymbolDispose:e}=oe,{AbortError:r,codes:n}=xe,{isNodeStream:i,isWebStream:a,kControllerErrorFunction:l}=He,u=Je,{ERR_INVALID_ARG_TYPE:p}=n;let _;const y=(x,I)=>{if(typeof x!="object"||!("aborted"in x))throw new p(I,"AbortSignal",x)};t.exports.addAbortSignal=function(I,S){if(y(I,"signal"),!i(S)&&!a(S))throw new p("stream",["ReadableStream","WritableStream","Stream"],S);return t.exports.addAbortSignalNoValidate(I,S)},t.exports.addAbortSignalNoValidate=function(x,I){if(typeof x!="object"||!("aborted"in x))return I;const S=i(I)?()=>{I.destroy(new r(void 0,{cause:x.reason}))}:()=>{I[l](new r(void 0,{cause:x.reason}))};if(x.aborted)S();else{_=_||Se.addAbortListener;const R=_(x,S);u(I,R[e])}return I}})(qi);var ur=qi.exports;const{StringPrototypeSlice:Hi,SymbolIterator:Va,TypedArrayPrototypeSet:fr,Uint8Array:Ka}=oe,{Buffer:Vr}=Fe,{inspect:Ya}=Se;var Xa=class{constructor(){this.head=null,this.tail=null,this.length=0}push(e){const r={data:e,next:null};this.length>0?this.tail.next=r:this.head=r,this.tail=r,++this.length}unshift(e){const r={data:e,next:this.head};this.length===0&&(this.tail=r),this.head=r,++this.length}shift(){if(this.length===0)return;const 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 Vr.alloc(0);const r=Vr.allocUnsafe(e>>>0);let n=this.head,i=0;for(;n;)fr(r,n.data,i),i+=n.data.length,n=n.next;return r}consume(e,r){const n=this.head.data;if(e<n.length){const 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}*[Va](){for(let e=this.head;e;e=e.next)yield e.data}_getString(e){let r="",n=this.head,i=0;do{const a=n.data;if(e>a.length)r+=a,e-=a.length;else{e===a.length?(r+=a,++i,n.next?this.head=n.next:this.head=this.tail=null):(r+=Hi(a,0,e),this.head=n,n.data=Hi(a,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){const r=Vr.allocUnsafe(e),n=e;let i=this.head,a=0;do{const l=i.data;if(e>l.length)fr(r,l,n-e),e-=l.length;else{e===l.length?(fr(r,l,n-e),++a,i.next?this.head=i.next:this.head=this.tail=null):(fr(r,new Ka(l.buffer,l.byteOffset,e),n-e),this.head=i,i.data=l.slice(e));break}++a}while((i=i.next)!==null);return this.length-=a,r}[Symbol.for("nodejs.util.inspect.custom")](e,r){return Ya(this,{...r,depth:0,customInspect:!1})}};const{MathFloor:Za,NumberIsInteger:Ja}=oe,{validateInteger:el}=Mt,{ERR_INVALID_ARG_VALUE:tl}=xe.codes;let Qi=16*1024,Vi=16;function rl(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function Ki(t){return t?Vi:Qi}function nl(t,e){el(e,"value",0),t?Vi=e:Qi=e}function il(t,e,r,n){const i=rl(e,n,r);if(i!=null){if(!Ja(i)||i<0){const a=n?`options.${r}`:"options.highWaterMark";throw new tl(a,i)}return Za(i)}return Ki(t.objectMode)}var cr={getHighWaterMark:il,getDefaultHighWaterMark:Ki,setDefaultHighWaterMark:nl},Yi={},Kr={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(t,e){var r=Fe,n=r.Buffer;function i(l,u){for(var p in l)u[p]=l[p]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=r:(i(r,e),e.Buffer=a);function a(l,u,p){return n(l,u,p)}a.prototype=Object.create(n.prototype),i(n,a),a.from=function(l,u,p){if(typeof l=="number")throw new TypeError("Argument must not be a number");return n(l,u,p)},a.alloc=function(l,u,p){if(typeof l!="number")throw new TypeError("Argument must be a number");var _=n(l);return u!==void 0?typeof p=="string"?_.fill(u,p):_.fill(u):_.fill(0),_},a.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return n(l)},a.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(l)}})(Kr,Kr.exports);var sl=Kr.exports,Yr=sl.Buffer,Xi=Yr.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 ol(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 al(t){var e=ol(t);if(typeof e!="string"&&(Yr.isEncoding===Xi||!Xi(t)))throw new Error("Unknown encoding: "+t);return e||t}Yi.StringDecoder=Dt;function Dt(t){this.encoding=al(t);var e;switch(this.encoding){case"utf16le":this.text=hl,this.end=pl,e=4;break;case"utf8":this.fillLast=fl,e=4;break;case"base64":this.text=_l,this.end=bl,e=3;break;default:this.write=yl,this.end=gl;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Yr.allocUnsafe(e)}Dt.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||""},Dt.prototype.end=dl,Dt.prototype.text=cl,Dt.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 Xr(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function ll(t,e,r){var n=e.length-1;if(n<r)return 0;var i=Xr(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||i===-2?0:(i=Xr(e[n]),i>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||i===-2?0:(i=Xr(e[n]),i>=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function ul(t,e,r){if((e[0]&192)!==128)return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"�"}}function fl(t){var e=this.lastTotal-this.lastNeed,r=ul(this,t);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 cl(t,e){var r=ll(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 dl(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e}function hl(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 pl(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 _l(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 bl(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function yl(t){return t.toString(this.encoding)}function gl(t){return t&&t.length?this.write(t):""}const Zi=ut,{PromisePrototypeThen:wl,SymbolAsyncIterator:Ji,SymbolIterator:es}=oe,{Buffer:ml}=Fe,{ERR_INVALID_ARG_TYPE:xl,ERR_STREAM_NULL_VALUES:El}=xe.codes;function Sl(t,e,r){let n;if(typeof e=="string"||e instanceof ml)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[Ji])i=!0,n=e[Ji]();else if(e&&e[es])i=!1,n=e[es]();else throw new xl("iterable",["Iterable"],e);const a=new t({objectMode:!0,highWaterMark:1,...r});let l=!1;a._read=function(){l||(l=!0,p())},a._destroy=function(_,y){wl(u(_),()=>Zi.nextTick(y,_),x=>Zi.nextTick(y,x||_))};async function u(_){const y=_!=null,x=typeof n.throw=="function";if(y&&x){const{value:I,done:S}=await n.throw(_);if(await I,S)return}if(typeof n.return=="function"){const{value:I}=await n.return();await I}}async function p(){for(;;){try{const{value:_,done:y}=i?await n.next():n.next();if(y)a.push(null);else{const x=_&&typeof _.then=="function"?await _:_;if(x===null)throw l=!1,new El;if(a.push(x))continue;l=!1}}catch(_){a.destroy(_)}break}}return a}var ts=Sl,Zr,rs;function dr(){if(rs)return Zr;rs=1;const t=ut,{ArrayPrototypeIndexOf:e,NumberIsInteger:r,NumberIsNaN:n,NumberParseInt:i,ObjectDefineProperties:a,ObjectKeys:l,ObjectSetPrototypeOf:u,Promise:p,SafeSet:_,SymbolAsyncDispose:y,SymbolAsyncIterator:x,Symbol:I}=oe;Zr=O,O.ReadableState=Re;const{EventEmitter:S}=nr,{Stream:R,prependListener:m}=Qr,{Buffer:v}=Fe,{addAbortSignal:$}=ur,B=Je;let T=Se.debuglog("stream",c=>{T=c});const q=Xa,U=Tt,{getHighWaterMark:ae,getDefaultHighWaterMark:Ee}=cr,{aggregateTwoErrors:ee,codes:{ERR_INVALID_ARG_TYPE:le,ERR_METHOD_NOT_IMPLEMENTED:ge,ERR_OUT_OF_RANGE:we,ERR_STREAM_PUSH_AFTER_EOF:Q,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:P},AbortError:K}=xe,{validateObject:G}=Mt,H=I("kPaused"),{StringDecoder:ue}=Yi,fe=ts;u(O.prototype,R.prototype),u(O,R);const re=()=>{},{errorOrDestroy:ce}=U,D=1,ne=2,M=4,he=8,Te=16,tt=32,Ke=64,je=128,Ye=256,Pt=512,_t=1024,rt=2048,g=4096,w=8192,N=16384,C=32768,F=65536,Z=1<<17,te=1<<18;function Y(c){return{enumerable:!1,get(){return(this.state&c)!==0},set(h){h?this.state|=c:this.state&=~c}}}a(Re.prototype,{objectMode:Y(D),ended:Y(ne),endEmitted:Y(M),reading:Y(he),constructed:Y(Te),sync:Y(tt),needReadable:Y(Ke),emittedReadable:Y(je),readableListening:Y(Ye),resumeScheduled:Y(Pt),errorEmitted:Y(_t),emitClose:Y(rt),autoDestroy:Y(g),destroyed:Y(w),closed:Y(N),closeEmitted:Y(C),multiAwaitDrain:Y(F),readingMore:Y(Z),dataEmitted:Y(te)});function Re(c,h,j){typeof j!="boolean"&&(j=h instanceof Qe()),this.state=rt|g|Te|tt,c&&c.objectMode&&(this.state|=D),j&&c&&c.readableObjectMode&&(this.state|=D),this.highWaterMark=c?ae(this,c,"readableHighWaterMark",j):Ee(!1),this.buffer=new q,this.length=0,this.pipes=[],this.flowing=null,this[H]=null,c&&c.emitClose===!1&&(this.state&=-2049),c&&c.autoDestroy===!1&&(this.state&=-4097),this.errored=null,this.defaultEncoding=c&&c.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,c&&c.encoding&&(this.decoder=new ue(c.encoding),this.encoding=c.encoding)}function O(c){if(!(this instanceof O))return new O(c);const h=this instanceof Qe();this._readableState=new Re(c,this,h),c&&(typeof c.read=="function"&&(this._read=c.read),typeof c.destroy=="function"&&(this._destroy=c.destroy),typeof c.construct=="function"&&(this._construct=c.construct),c.signal&&!h&&$(c.signal,this)),R.call(this,c),U.construct(this,()=>{this._readableState.needReadable&&b(this,this._readableState)})}O.prototype.destroy=U.destroy,O.prototype._undestroy=U.undestroy,O.prototype._destroy=function(c,h){h(c)},O.prototype[S.captureRejectionSymbol]=function(c){this.destroy(c)},O.prototype[y]=function(){let c;return this.destroyed||(c=this.readableEnded?null:new K,this.destroy(c)),new p((h,j)=>B(this,L=>L&&L!==c?j(L):h(null)))},O.prototype.push=function(c,h){return Le(this,c,h,!1)},O.prototype.unshift=function(c,h){return Le(this,c,h,!0)};function Le(c,h,j,L){T("readableAddChunk",h);const k=c._readableState;let me;if(k.state&D||(typeof h=="string"?(j=j||k.defaultEncoding,k.encoding!==j&&(L&&k.encoding?h=v.from(h,j).toString(k.encoding):(h=v.from(h,j),j=""))):h instanceof v?j="":R._isUint8Array(h)?(h=R._uint8ArrayToBuffer(h),j=""):h!=null&&(me=new le("chunk",["string","Buffer","Uint8Array"],h))),me)ce(c,me);else if(h===null)k.state&=-9,s(c,k);else if(k.state&D||h&&h.length>0)if(L)if(k.state&M)ce(c,new P);else{if(k.destroyed||k.errored)return!1;Qt(c,k,h,!0)}else if(k.ended)ce(c,new Q);else{if(k.destroyed||k.errored)return!1;k.state&=-9,k.decoder&&!j?(h=k.decoder.write(h),k.objectMode||h.length!==0?Qt(c,k,h,!1):b(c,k)):Qt(c,k,h,!1)}else L||(k.state&=-9,b(c,k));return!k.ended&&(k.length<k.highWaterMark||k.length===0)}function Qt(c,h,j,L){h.flowing&&h.length===0&&!h.sync&&c.listenerCount("data")>0?(h.state&F?h.awaitDrainWriters.clear():h.awaitDrainWriters=null,h.dataEmitted=!0,c.emit("data",j)):(h.length+=h.objectMode?1:j.length,L?h.buffer.unshift(j):h.buffer.push(j),h.state&Ke&&o(c)),b(c,h)}O.prototype.isPaused=function(){const c=this._readableState;return c[H]===!0||c.flowing===!1},O.prototype.setEncoding=function(c){const h=new ue(c);this._readableState.decoder=h,this._readableState.encoding=this._readableState.decoder.encoding;const j=this._readableState.buffer;let L="";for(const k of j)L+=h.write(k);return j.clear(),L!==""&&j.push(L),this._readableState.length=L.length,this};const Ge=1073741824;function En(c){if(c>Ge)throw new we("size","<= 1GiB",c);return c--,c|=c>>>1,c|=c>>>2,c|=c>>>4,c|=c>>>8,c|=c>>>16,c++,c}function f(c,h){return c<=0||h.length===0&&h.ended?0:h.state&D?1:n(c)?h.flowing&&h.length?h.buffer.first().length:h.length:c<=h.length?c:h.ended?h.length:0}O.prototype.read=function(c){T("read",c),c===void 0?c=NaN:r(c)||(c=i(c,10));const h=this._readableState,j=c;if(c>h.highWaterMark&&(h.highWaterMark=En(c)),c!==0&&(h.state&=-129),c===0&&h.needReadable&&((h.highWaterMark!==0?h.length>=h.highWaterMark:h.length>0)||h.ended))return T("read: emitReadable",h.length,h.ended),h.length===0&&h.ended?Sn(this):o(this),null;if(c=f(c,h),c===0&&h.ended)return h.length===0&&Sn(this),null;let L=(h.state&Ke)!==0;if(T("need readable",L),(h.length===0||h.length-c<h.highWaterMark)&&(L=!0,T("length less than watermark",L)),h.ended||h.reading||h.destroyed||h.errored||!h.constructed)L=!1,T("reading, ended or constructing",L);else if(L){T("do read"),h.state|=he|tt,h.length===0&&(h.state|=Ke);try{this._read(h.highWaterMark)}catch(me){ce(this,me)}h.state&=-33,h.reading||(c=f(j,h))}let k;return c>0?k=Us(c,h):k=null,k===null?(h.needReadable=h.length<=h.highWaterMark,c=0):(h.length-=c,h.multiAwaitDrain?h.awaitDrainWriters.clear():h.awaitDrainWriters=null),h.length===0&&(h.ended||(h.needReadable=!0),j!==c&&h.ended&&Sn(this)),k!==null&&!h.errorEmitted&&!h.closeEmitted&&(h.dataEmitted=!0,this.emit("data",k)),k};function s(c,h){if(T("onEofChunk"),!h.ended){if(h.decoder){const j=h.decoder.end();j&&j.length&&(h.buffer.push(j),h.length+=h.objectMode?1:j.length)}h.ended=!0,h.sync?o(c):(h.needReadable=!1,h.emittedReadable=!0,d(c))}}function o(c){const h=c._readableState;T("emitReadable",h.needReadable,h.emittedReadable),h.needReadable=!1,h.emittedReadable||(T("emitReadable",h.flowing),h.emittedReadable=!0,t.nextTick(d,c))}function d(c){const h=c._readableState;T("emitReadable_",h.destroyed,h.length,h.ended),!h.destroyed&&!h.errored&&(h.length||h.ended)&&(c.emit("readable"),h.emittedReadable=!1),h.needReadable=!h.flowing&&!h.ended&&h.length<=h.highWaterMark,V(c)}function b(c,h){!h.readingMore&&h.constructed&&(h.readingMore=!0,t.nextTick(E,c,h))}function E(c,h){for(;!h.reading&&!h.ended&&(h.length<h.highWaterMark||h.flowing&&h.length===0);){const j=h.length;if(T("maybeReadMore read 0"),c.read(0),j===h.length)break}h.readingMore=!1}O.prototype._read=function(c){throw new ge("_read()")},O.prototype.pipe=function(c,h){const j=this,L=this._readableState;L.pipes.length===1&&(L.multiAwaitDrain||(L.multiAwaitDrain=!0,L.awaitDrainWriters=new _(L.awaitDrainWriters?[L.awaitDrainWriters]:[]))),L.pipes.push(c),T("pipe count=%d opts=%j",L.pipes.length,h);const me=(!h||h.end!==!1)&&c!==t.stdout&&c!==t.stderr?Gs:Vt;L.endEmitted?t.nextTick(me):j.once("end",me),c.on("unpipe",$e);function $e(yt,Xe){T("onunpipe"),yt===j&&Xe&&Xe.hasUnpiped===!1&&(Xe.hasUnpiped=!0,qu())}function Gs(){T("onend"),c.end()}let bt,zs=!1;function qu(){T("cleanup"),c.removeListener("close",An),c.removeListener("finish",Tn),bt&&c.removeListener("drain",bt),c.removeListener("error",Rn),c.removeListener("unpipe",$e),j.removeListener("end",Gs),j.removeListener("end",Vt),j.removeListener("data",Hs),zs=!0,bt&&L.awaitDrainWriters&&(!c._writableState||c._writableState.needDrain)&&bt()}function qs(){zs||(L.pipes.length===1&&L.pipes[0]===c?(T("false write response, pause",0),L.awaitDrainWriters=c,L.multiAwaitDrain=!1):L.pipes.length>1&&L.pipes.includes(c)&&(T("false write response, pause",L.awaitDrainWriters.size),L.awaitDrainWriters.add(c)),j.pause()),bt||(bt=A(j,c),c.on("drain",bt))}j.on("data",Hs);function Hs(yt){T("ondata");const Xe=c.write(yt);T("dest.write",Xe),Xe===!1&&qs()}function Rn(yt){if(T("onerror",yt),Vt(),c.removeListener("error",Rn),c.listenerCount("error")===0){const Xe=c._writableState||c._readableState;Xe&&!Xe.errorEmitted?ce(c,yt):c.emit("error",yt)}}m(c,"error",Rn);function An(){c.removeListener("finish",Tn),Vt()}c.once("close",An);function Tn(){T("onfinish"),c.removeListener("close",An),Vt()}c.once("finish",Tn);function Vt(){T("unpipe"),j.unpipe(c)}return c.emit("pipe",j),c.writableNeedDrain===!0?qs():L.flowing||(T("pipe resume"),j.resume()),c};function A(c,h){return function(){const L=c._readableState;L.awaitDrainWriters===h?(T("pipeOnDrain",1),L.awaitDrainWriters=null):L.multiAwaitDrain&&(T("pipeOnDrain",L.awaitDrainWriters.size),L.awaitDrainWriters.delete(h)),(!L.awaitDrainWriters||L.awaitDrainWriters.size===0)&&c.listenerCount("data")&&c.resume()}}O.prototype.unpipe=function(c){const h=this._readableState,j={hasUnpiped:!1};if(h.pipes.length===0)return this;if(!c){const k=h.pipes;h.pipes=[],this.pause();for(let me=0;me<k.length;me++)k[me].emit("unpipe",this,{hasUnpiped:!1});return this}const L=e(h.pipes,c);return L===-1?this:(h.pipes.splice(L,1),h.pipes.length===0&&this.pause(),c.emit("unpipe",this,j),this)},O.prototype.on=function(c,h){const j=R.prototype.on.call(this,c,h),L=this._readableState;return c==="data"?(L.readableListening=this.listenerCount("readable")>0,L.flowing!==!1&&this.resume()):c==="readable"&&!L.endEmitted&&!L.readableListening&&(L.readableListening=L.needReadable=!0,L.flowing=!1,L.emittedReadable=!1,T("on readable",L.length,L.reading),L.length?o(this):L.reading||t.nextTick(ie,this)),j},O.prototype.addListener=O.prototype.on,O.prototype.removeListener=function(c,h){const j=R.prototype.removeListener.call(this,c,h);return c==="readable"&&t.nextTick(W,this),j},O.prototype.off=O.prototype.removeListener,O.prototype.removeAllListeners=function(c){const h=R.prototype.removeAllListeners.apply(this,arguments);return(c==="readable"||c===void 0)&&t.nextTick(W,this),h};function W(c){const h=c._readableState;h.readableListening=c.listenerCount("readable")>0,h.resumeScheduled&&h[H]===!1?h.flowing=!0:c.listenerCount("data")>0?c.resume():h.readableListening||(h.flowing=null)}function ie(c){T("readable nexttick read 0"),c.read(0)}O.prototype.resume=function(){const c=this._readableState;return c.flowing||(T("resume"),c.flowing=!c.readableListening,J(this,c)),c[H]=!1,this};function J(c,h){h.resumeScheduled||(h.resumeScheduled=!0,t.nextTick(se,c,h))}function se(c,h){T("resume",h.reading),h.reading||c.read(0),h.resumeScheduled=!1,c.emit("resume"),V(c),h.flowing&&!h.reading&&c.read(0)}O.prototype.pause=function(){return T("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(T("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[H]=!0,this};function V(c){const h=c._readableState;for(T("flow",h.flowing);h.flowing&&c.read()!==null;);}O.prototype.wrap=function(c){let h=!1;c.on("data",L=>{!this.push(L)&&c.pause&&(h=!0,c.pause())}),c.on("end",()=>{this.push(null)}),c.on("error",L=>{ce(this,L)}),c.on("close",()=>{this.destroy()}),c.on("destroy",()=>{this.destroy()}),this._read=()=>{h&&c.resume&&(h=!1,c.resume())};const j=l(c);for(let L=1;L<j.length;L++){const k=j[L];this[k]===void 0&&typeof c[k]=="function"&&(this[k]=c[k].bind(c))}return this},O.prototype[x]=function(){return Ds(this)},O.prototype.iterator=function(c){return c!==void 0&&G(c,"options"),Ds(this,c)};function Ds(c,h){typeof c.read!="function"&&(c=O.wrap(c,{objectMode:!0}));const j=Wu(c,h);return j.stream=c,j}async function*Wu(c,h){let j=re;function L($e){this===c?(j(),j=re):j=$e}c.on("readable",L);let k;const me=B(c,{writable:!1},$e=>{k=$e?ee(k,$e):null,j(),j=re});try{for(;;){const $e=c.destroyed?null:c.read();if($e!==null)yield $e;else{if(k)throw k;if(k===null)return;await new p(L)}}}catch($e){throw k=ee(k,$e),k}finally{(k||(h==null?void 0:h.destroyOnReturn)!==!1)&&(k===void 0||c._readableState.autoDestroy)?U.destroyer(c,null):(c.off("readable",L),me())}}a(O.prototype,{readable:{__proto__:null,get(){const c=this._readableState;return!!c&&c.readable!==!1&&!c.destroyed&&!c.errorEmitted&&!c.endEmitted},set(c){this._readableState&&(this._readableState.readable=!!c)}},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(c){this._readableState&&(this._readableState.flowing=c)}},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(c){this._readableState&&(this._readableState.destroyed=c)}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),a(Re.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[H]!==!1},set(c){this[H]=!!c}}}),O._fromList=Us;function Us(c,h){if(h.length===0)return null;let j;return h.objectMode?j=h.buffer.shift():!c||c>=h.length?(h.decoder?j=h.buffer.join(""):h.buffer.length===1?j=h.buffer.first():j=h.buffer.concat(h.length),h.buffer.clear()):j=h.buffer.consume(c,h.decoder),j}function Sn(c){const h=c._readableState;T("endReadable",h.endEmitted),h.endEmitted||(h.ended=!0,t.nextTick(Gu,h,c))}function Gu(c,h){if(T("endReadableNT",c.endEmitted,c.length),!c.errored&&!c.closeEmitted&&!c.endEmitted&&c.length===0){if(c.endEmitted=!0,h.emit("end"),h.writable&&h.allowHalfOpen===!1)t.nextTick(zu,h);else if(c.autoDestroy){const j=h._writableState;(!j||j.autoDestroy&&(j.finished||j.writable===!1))&&h.destroy()}}}function zu(c){c.writable&&!c.writableEnded&&!c.destroyed&&c.end()}O.from=function(c,h){return fe(O,c,h)};let In;function Ws(){return In===void 0&&(In={}),In}return O.fromWeb=function(c,h){return Ws().newStreamReadableFromReadableStream(c,h)},O.toWeb=function(c,h){return Ws().newReadableStreamFromStreamReadable(c,h)},O.wrap=function(c,h){var j,L;return new O({objectMode:(j=(L=c.readableObjectMode)!==null&&L!==void 0?L:c.objectMode)!==null&&j!==void 0?j:!0,...h,destroy(k,me){U.destroyer(c,k),me(k)}}).wrap(c)},Zr}var Jr,ns;function en(){if(ns)return Jr;ns=1;const t=ut,{ArrayPrototypeSlice:e,Error:r,FunctionPrototypeSymbolHasInstance:n,ObjectDefineProperty:i,ObjectDefineProperties:a,ObjectSetPrototypeOf:l,StringPrototypeToLowerCase:u,Symbol:p,SymbolHasInstance:_}=oe;Jr=G,G.WritableState=P;const{EventEmitter:y}=nr,x=Qr.Stream,{Buffer:I}=Fe,S=Tt,{addAbortSignal:R}=ur,{getHighWaterMark:m,getDefaultHighWaterMark:v}=cr,{ERR_INVALID_ARG_TYPE:$,ERR_METHOD_NOT_IMPLEMENTED:B,ERR_MULTIPLE_CALLBACK:T,ERR_STREAM_CANNOT_PIPE:q,ERR_STREAM_DESTROYED:U,ERR_STREAM_ALREADY_FINISHED:ae,ERR_STREAM_NULL_VALUES:Ee,ERR_STREAM_WRITE_AFTER_END:ee,ERR_UNKNOWN_ENCODING:le}=xe.codes,{errorOrDestroy:ge}=S;l(G.prototype,x.prototype),l(G,x);function we(){}const Q=p("kOnFinished");function P(g,w,N){typeof N!="boolean"&&(N=w instanceof Qe()),this.objectMode=!!(g&&g.objectMode),N&&(this.objectMode=this.objectMode||!!(g&&g.writableObjectMode)),this.highWaterMark=g?m(this,g,"writableHighWaterMark",N):v(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const C=!!(g&&g.decodeStrings===!1);this.decodeStrings=!C,this.defaultEncoding=g&&g.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=ce.bind(void 0,w),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,K(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!g||g.emitClose!==!1,this.autoDestroy=!g||g.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[Q]=[]}function K(g){g.buffered=[],g.bufferedIndex=0,g.allBuffers=!0,g.allNoop=!0}P.prototype.getBuffer=function(){return e(this.buffered,this.bufferedIndex)},i(P.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function G(g){const w=this instanceof Qe();if(!w&&!n(G,this))return new G(g);this._writableState=new P(g,this,w),g&&(typeof g.write=="function"&&(this._write=g.write),typeof g.writev=="function"&&(this._writev=g.writev),typeof g.destroy=="function"&&(this._destroy=g.destroy),typeof g.final=="function"&&(this._final=g.final),typeof g.construct=="function"&&(this._construct=g.construct),g.signal&&R(g.signal,this)),x.call(this,g),S.construct(this,()=>{const N=this._writableState;N.writing||he(this,N),je(this,N)})}i(G,_,{__proto__:null,value:function(g){return n(this,g)?!0:this!==G?!1:g&&g._writableState instanceof P}}),G.prototype.pipe=function(){ge(this,new q)};function H(g,w,N,C){const F=g._writableState;if(typeof N=="function")C=N,N=F.defaultEncoding;else{if(!N)N=F.defaultEncoding;else if(N!=="buffer"&&!I.isEncoding(N))throw new le(N);typeof C!="function"&&(C=we)}if(w===null)throw new Ee;if(!F.objectMode)if(typeof w=="string")F.decodeStrings!==!1&&(w=I.from(w,N),N="buffer");else if(w instanceof I)N="buffer";else if(x._isUint8Array(w))w=x._uint8ArrayToBuffer(w),N="buffer";else throw new $("chunk",["string","Buffer","Uint8Array"],w);let Z;return F.ending?Z=new ee:F.destroyed&&(Z=new U("write")),Z?(t.nextTick(C,Z),ge(g,Z,!0),Z):(F.pendingcb++,ue(g,F,w,N,C))}G.prototype.write=function(g,w,N){return H(this,g,w,N)===!0},G.prototype.cork=function(){this._writableState.corked++},G.prototype.uncork=function(){const g=this._writableState;g.corked&&(g.corked--,g.writing||he(this,g))},G.prototype.setDefaultEncoding=function(w){if(typeof w=="string"&&(w=u(w)),!I.isEncoding(w))throw new le(w);return this._writableState.defaultEncoding=w,this};function ue(g,w,N,C,F){const Z=w.objectMode?1:N.length;w.length+=Z;const te=w.length<w.highWaterMark;return te||(w.needDrain=!0),w.writing||w.corked||w.errored||!w.constructed?(w.buffered.push({chunk:N,encoding:C,callback:F}),w.allBuffers&&C!=="buffer"&&(w.allBuffers=!1),w.allNoop&&F!==we&&(w.allNoop=!1)):(w.writelen=Z,w.writecb=F,w.writing=!0,w.sync=!0,g._write(N,C,w.onwrite),w.sync=!1),te&&!w.errored&&!w.destroyed}function fe(g,w,N,C,F,Z,te){w.writelen=C,w.writecb=te,w.writing=!0,w.sync=!0,w.destroyed?w.onwrite(new U("write")):N?g._writev(F,w.onwrite):g._write(F,Z,w.onwrite),w.sync=!1}function re(g,w,N,C){--w.pendingcb,C(N),M(w),ge(g,N)}function ce(g,w){const N=g._writableState,C=N.sync,F=N.writecb;if(typeof F!="function"){ge(g,new T);return}N.writing=!1,N.writecb=null,N.length-=N.writelen,N.writelen=0,w?(w.stack,N.errored||(N.errored=w),g._readableState&&!g._readableState.errored&&(g._readableState.errored=w),C?t.nextTick(re,g,N,w,F):re(g,N,w,F)):(N.buffered.length>N.bufferedIndex&&he(g,N),C?N.afterWriteTickInfo!==null&&N.afterWriteTickInfo.cb===F?N.afterWriteTickInfo.count++:(N.afterWriteTickInfo={count:1,cb:F,stream:g,state:N},t.nextTick(D,N.afterWriteTickInfo)):ne(g,N,1,F))}function D({stream:g,state:w,count:N,cb:C}){return w.afterWriteTickInfo=null,ne(g,w,N,C)}function ne(g,w,N,C){for(!w.ending&&!g.destroyed&&w.length===0&&w.needDrain&&(w.needDrain=!1,g.emit("drain"));N-- >0;)w.pendingcb--,C();w.destroyed&&M(w),je(g,w)}function M(g){if(g.writing)return;for(let F=g.bufferedIndex;F<g.buffered.length;++F){var w;const{chunk:Z,callback:te}=g.buffered[F],Y=g.objectMode?1:Z.length;g.length-=Y,te((w=g.errored)!==null&&w!==void 0?w:new U("write"))}const N=g[Q].splice(0);for(let F=0;F<N.length;F++){var C;N[F]((C=g.errored)!==null&&C!==void 0?C:new U("end"))}K(g)}function he(g,w){if(w.corked||w.bufferProcessing||w.destroyed||!w.constructed)return;const{buffered:N,bufferedIndex:C,objectMode:F}=w,Z=N.length-C;if(!Z)return;let te=C;if(w.bufferProcessing=!0,Z>1&&g._writev){w.pendingcb-=Z-1;const Y=w.allNoop?we:O=>{for(let Le=te;Le<N.length;++Le)N[Le].callback(O)},Re=w.allNoop&&te===0?N:e(N,te);Re.allBuffers=w.allBuffers,fe(g,w,!0,w.length,Re,"",Y),K(w)}else{do{const{chunk:Y,encoding:Re,callback:O}=N[te];N[te++]=null;const Le=F?1:Y.length;fe(g,w,!1,Le,Y,Re,O)}while(te<N.length&&!w.writing);te===N.length?K(w):te>256?(N.splice(0,te),w.bufferedIndex=0):w.bufferedIndex=te}w.bufferProcessing=!1}G.prototype._write=function(g,w,N){if(this._writev)this._writev([{chunk:g,encoding:w}],N);else throw new B("_write()")},G.prototype._writev=null,G.prototype.end=function(g,w,N){const C=this._writableState;typeof g=="function"?(N=g,g=null,w=null):typeof w=="function"&&(N=w,w=null);let F;if(g!=null){const Z=H(this,g,w);Z instanceof r&&(F=Z)}return C.corked&&(C.corked=1,this.uncork()),F||(!C.errored&&!C.ending?(C.ending=!0,je(this,C,!0),C.ended=!0):C.finished?F=new ae("end"):C.destroyed&&(F=new U("end"))),typeof N=="function"&&(F||C.finished?t.nextTick(N,F):C[Q].push(N)),this};function Te(g){return g.ending&&!g.destroyed&&g.constructed&&g.length===0&&!g.errored&&g.buffered.length===0&&!g.finished&&!g.writing&&!g.errorEmitted&&!g.closeEmitted}function tt(g,w){let N=!1;function C(F){if(N){ge(g,F??T());return}if(N=!0,w.pendingcb--,F){const Z=w[Q].splice(0);for(let te=0;te<Z.length;te++)Z[te](F);ge(g,F,w.sync)}else Te(w)&&(w.prefinished=!0,g.emit("prefinish"),w.pendingcb++,t.nextTick(Ye,g,w))}w.sync=!0,w.pendingcb++;try{g._final(C)}catch(F){C(F)}w.sync=!1}function Ke(g,w){!w.prefinished&&!w.finalCalled&&(typeof g._final=="function"&&!w.destroyed?(w.finalCalled=!0,tt(g,w)):(w.prefinished=!0,g.emit("prefinish")))}function je(g,w,N){Te(w)&&(Ke(g,w),w.pendingcb===0&&(N?(w.pendingcb++,t.nextTick((C,F)=>{Te(F)?Ye(C,F):F.pendingcb--},g,w)):Te(w)&&(w.pendingcb++,Ye(g,w))))}function Ye(g,w){w.pendingcb--,w.finished=!0;const N=w[Q].splice(0);for(let C=0;C<N.length;C++)N[C]();if(g.emit("finish"),w.autoDestroy){const C=g._readableState;(!C||C.autoDestroy&&(C.endEmitted||C.readable===!1))&&g.destroy()}}a(G.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(g){this._writableState&&(this._writableState.destroyed=g)}},writable:{__proto__:null,get(){const g=this._writableState;return!!g&&g.writable!==!1&&!g.destroyed&&!g.errored&&!g.ending&&!g.ended},set(g){this._writableState&&(this._writableState.writable=!!g)}},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(){const g=this._writableState;return g?!g.destroyed&&!g.ending&&g.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)}}});const Pt=S.destroy;G.prototype.destroy=function(g,w){const N=this._writableState;return!N.destroyed&&(N.bufferedIndex<N.buffered.length||N[Q].length)&&t.nextTick(M,N),Pt.call(this,g,w),this},G.prototype._undestroy=S.undestroy,G.prototype._destroy=function(g,w){w(g)},G.prototype[y.captureRejectionSymbol]=function(g){this.destroy(g)};let _t;function rt(){return _t===void 0&&(_t={}),_t}return G.fromWeb=function(g,w){return rt().newStreamWritableFromWritableStream(g,w)},G.toWeb=function(g){return rt().newWritableStreamFromStreamWritable(g)},Jr}var tn,is;function Il(){if(is)return tn;is=1;const t=ut,e=Fe,{isReadable:r,isWritable:n,isIterable:i,isNodeStream:a,isReadableNodeStream:l,isWritableNodeStream:u,isDuplexNodeStream:p,isReadableStream:_,isWritableStream:y}=He,x=Je,{AbortError:I,codes:{ERR_INVALID_ARG_TYPE:S,ERR_INVALID_RETURN_VALUE:R}}=xe,{destroyer:m}=Tt,v=Qe(),$=dr(),B=en(),{createDeferredPromise:T}=Se,q=ts,U=globalThis.Blob||e.Blob,ae=typeof U<"u"?function(P){return P instanceof U}:function(P){return!1},Ee=globalThis.AbortController||Ot().AbortController,{FunctionPrototypeCall:ee}=oe;class le extends v{constructor(P){super(P),(P==null?void 0:P.readable)===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),(P==null?void 0:P.writable)===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}}tn=function Q(P,K){if(p(P))return P;if(l(P))return we({readable:P});if(u(P))return we({writable:P});if(a(P))return we({writable:!1,readable:!1});if(_(P))return we({readable:$.fromWeb(P)});if(y(P))return we({writable:B.fromWeb(P)});if(typeof P=="function"){const{value:H,write:ue,final:fe,destroy:re}=ge(P);if(i(H))return q(le,H,{objectMode:!0,write:ue,final:fe,destroy:re});const ce=H==null?void 0:H.then;if(typeof ce=="function"){let D;const ne=ee(ce,H,M=>{if(M!=null)throw new R("nully","body",M)},M=>{m(D,M)});return D=new le({objectMode:!0,readable:!1,write:ue,final(M){fe(async()=>{try{await ne,t.nextTick(M,null)}catch(he){t.nextTick(M,he)}})},destroy:re})}throw new R("Iterable, AsyncIterable or AsyncFunction",K,H)}if(ae(P))return Q(P.arrayBuffer());if(i(P))return q(le,P,{objectMode:!0,writable:!1});if(_(P==null?void 0:P.readable)&&y(P==null?void 0:P.writable))return le.fromWeb(P);if(typeof(P==null?void 0:P.writable)=="object"||typeof(P==null?void 0:P.readable)=="object"){const H=P!=null&&P.readable?l(P==null?void 0:P.readable)?P==null?void 0:P.readable:Q(P.readable):void 0,ue=P!=null&&P.writable?u(P==null?void 0:P.writable)?P==null?void 0:P.writable:Q(P.writable):void 0;return we({readable:H,writable:ue})}const G=P==null?void 0:P.then;if(typeof G=="function"){let H;return ee(G,P,ue=>{ue!=null&&H.push(ue),H.push(null)},ue=>{m(H,ue)}),H=new le({objectMode:!0,writable:!1,read(){}})}throw new S(K,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],P)};function ge(Q){let{promise:P,resolve:K}=T();const G=new Ee,H=G.signal;return{value:Q(async function*(){for(;;){const fe=P;P=null;const{chunk:re,done:ce,cb:D}=await fe;if(t.nextTick(D),ce)return;if(H.aborted)throw new I(void 0,{cause:H.reason});({promise:P,resolve:K}=T()),yield re}}(),{signal:H}),write(fe,re,ce){const D=K;K=null,D({chunk:fe,done:!1,cb:ce})},final(fe){const re=K;K=null,re({done:!0,cb:fe})},destroy(fe,re){G.abort(),re(fe)}}}function we(Q){const P=Q.readable&&typeof Q.readable.read!="function"?$.wrap(Q.readable):Q.readable,K=Q.writable;let G=!!r(P),H=!!n(K),ue,fe,re,ce,D;function ne(M){const he=ce;ce=null,he?he(M):M&&D.destroy(M)}return D=new le({readableObjectMode:!!(P!=null&&P.readableObjectMode),writableObjectMode:!!(K!=null&&K.writableObjectMode),readable:G,writable:H}),H&&(x(K,M=>{H=!1,M&&m(P,M),ne(M)}),D._write=function(M,he,Te){K.write(M,he)?Te():ue=Te},D._final=function(M){K.end(),fe=M},K.on("drain",function(){if(ue){const M=ue;ue=null,M()}}),K.on("finish",function(){if(fe){const M=fe;fe=null,M()}})),G&&(x(P,M=>{G=!1,M&&m(P,M),ne(M)}),P.on("readable",function(){if(re){const M=re;re=null,M()}}),P.on("end",function(){D.push(null)}),D._read=function(){for(;;){const M=P.read();if(M===null){re=D._read;return}if(!D.push(M))return}}),D._destroy=function(M,he){!M&&ce!==null&&(M=new I),re=null,ue=null,fe=null,ce===null?he(M):(ce=he,m(K,M),m(P,M))},D}return tn}var rn,ss;function Qe(){if(ss)return rn;ss=1;const{ObjectDefineProperties:t,ObjectGetOwnPropertyDescriptor:e,ObjectKeys:r,ObjectSetPrototypeOf:n}=oe;rn=l;const i=dr(),a=en();n(l.prototype,i.prototype),n(l,i);{const y=r(a.prototype);for(let x=0;x<y.length;x++){const I=y[x];l.prototype[I]||(l.prototype[I]=a.prototype[I])}}function l(y){if(!(this instanceof l))return new l(y);i.call(this,y),a.call(this,y),y?(this.allowHalfOpen=y.allowHalfOpen!==!1,y.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),y.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}t(l.prototype,{writable:{__proto__:null,...e(a.prototype,"writable")},writableHighWaterMark:{__proto__:null,...e(a.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...e(a.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...e(a.prototype,"writableBuffer")},writableLength:{__proto__:null,...e(a.prototype,"writableLength")},writableFinished:{__proto__:null,...e(a.prototype,"writableFinished")},writableCorked:{__proto__:null,...e(a.prototype,"writableCorked")},writableEnded:{__proto__:null,...e(a.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...e(a.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(y){this._readableState&&this._writableState&&(this._readableState.destroyed=y,this._writableState.destroyed=y)}}});let u;function p(){return u===void 0&&(u={}),u}l.fromWeb=function(y,x){return p().newStreamDuplexFromReadableWritablePair(y,x)},l.toWeb=function(y){return p().newReadableWritablePairFromDuplex(y)};let _;return l.from=function(y){return _||(_=Il()),_(y,"body")},rn}const{ObjectSetPrototypeOf:os,Symbol:Rl}=oe;var as=Ve;const{ERR_METHOD_NOT_IMPLEMENTED:Al}=xe.codes,nn=Qe(),{getHighWaterMark:Tl}=cr;os(Ve.prototype,nn.prototype),os(Ve,nn);const Ut=Rl("kCallback");function Ve(t){if(!(this instanceof Ve))return new Ve(t);const e=t?Tl(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),nn.call(this,t),this._readableState.sync=!1,this[Ut]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",vl)}function sn(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 vl(){this._final!==sn&&sn.call(this)}Ve.prototype._final=sn,Ve.prototype._transform=function(t,e,r){throw new Al("_transform()")},Ve.prototype._write=function(t,e,r){const n=this._readableState,i=this._writableState,a=n.length;this._transform(t,e,(l,u)=>{if(l){r(l);return}u!=null&&this.push(u),i.ended||a===n.length||n.length<n.highWaterMark?r():this[Ut]=r})},Ve.prototype._read=function(){if(this[Ut]){const t=this[Ut];this[Ut]=null,t()}};const{ObjectSetPrototypeOf:ls}=oe;var us=vt;const on=as;ls(vt.prototype,on.prototype),ls(vt,on);function vt(t){if(!(this instanceof vt))return new vt(t);on.call(this,t)}vt.prototype._transform=function(t,e,r){r(null,t)};const Wt=ut,{ArrayIsArray:Nl,Promise:Pl,SymbolAsyncIterator:jl,SymbolDispose:Ll}=oe,hr=Je,{once:$l}=Se,Bl=Tt,fs=Qe(),{aggregateTwoErrors:Fl,codes:{ERR_INVALID_ARG_TYPE:an,ERR_INVALID_RETURN_VALUE:ln,ERR_MISSING_ARGS:kl,ERR_STREAM_DESTROYED:Cl,ERR_STREAM_PREMATURE_CLOSE:Ol},AbortError:Ml}=xe,{validateFunction:Dl,validateAbortSignal:Ul}=Mt,{isIterable:ct,isReadable:un,isReadableNodeStream:pr,isNodeStream:cs,isTransformStream:Nt,isWebStream:Wl,isReadableStream:fn,isReadableFinished:Gl}=He,zl=globalThis.AbortController||Ot().AbortController;let cn,dn,hn;function ds(t,e,r){let n=!1;t.on("close",()=>{n=!0});const i=hr(t,{readable:e,writable:r},a=>{n=!a});return{destroy:a=>{n||(n=!0,Bl.destroyer(t,a||new Cl("pipe")))},cleanup:i}}function ql(t){return Dl(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function pn(t){if(ct(t))return t;if(pr(t))return Hl(t);throw new an("val",["Readable","Iterable","AsyncIterable"],t)}async function*Hl(t){dn||(dn=dr()),yield*dn.prototype[jl].call(t)}async function _r(t,e,r,{end:n}){let i,a=null;const l=_=>{if(_&&(i=_),a){const y=a;a=null,y()}},u=()=>new Pl((_,y)=>{i?y(i):a=()=>{i?y(i):_()}});e.on("drain",l);const p=hr(e,{readable:!1},l);try{e.writableNeedDrain&&await u();for await(const _ of t)e.write(_)||await u();n&&(e.end(),await u()),r()}catch(_){r(i!==_?Fl(i,_):_)}finally{p(),e.off("drain",l)}}async function _n(t,e,r,{end:n}){Nt(e)&&(e=e.writable);const i=e.getWriter();try{for await(const a of t)await i.ready,i.write(a).catch(()=>{});await i.ready,n&&await i.close(),r()}catch(a){try{await i.abort(a),r(a)}catch(l){r(l)}}}function Ql(...t){return hs(t,$l(ql(t)))}function hs(t,e,r){if(t.length===1&&Nl(t[0])&&(t=t[0]),t.length<2)throw new kl("streams");const n=new zl,i=n.signal,a=r==null?void 0:r.signal,l=[];Ul(a,"options.signal");function u(){R(new Ml)}hn=hn||Se.addAbortListener;let p;a&&(p=hn(a,u));let _,y;const x=[];let I=0;function S(B){R(B,--I===0)}function R(B,T){var q;if(B&&(!_||_.code==="ERR_STREAM_PREMATURE_CLOSE")&&(_=B),!(!_&&!T)){for(;x.length;)x.shift()(_);(q=p)===null||q===void 0||q[Ll](),n.abort(),T&&(_||l.forEach(U=>U()),Wt.nextTick(e,_,y))}}let m;for(let B=0;B<t.length;B++){const T=t[B],q=B<t.length-1,U=B>0,ae=q||(r==null?void 0:r.end)!==!1,Ee=B===t.length-1;if(cs(T)){let ee=function(le){le&&le.name!=="AbortError"&&le.code!=="ERR_STREAM_PREMATURE_CLOSE"&&S(le)};if(ae){const{destroy:le,cleanup:ge}=ds(T,q,U);x.push(le),un(T)&&Ee&&l.push(ge)}T.on("error",ee),un(T)&&Ee&&l.push(()=>{T.removeListener("error",ee)})}if(B===0)if(typeof T=="function"){if(m=T({signal:i}),!ct(m))throw new ln("Iterable, AsyncIterable or Stream","source",m)}else ct(T)||pr(T)||Nt(T)?m=T:m=fs.from(T);else if(typeof T=="function"){if(Nt(m)){var v;m=pn((v=m)===null||v===void 0?void 0:v.readable)}else m=pn(m);if(m=T(m,{signal:i}),q){if(!ct(m,!0))throw new ln("AsyncIterable",`transform[${B-1}]`,m)}else{var $;cn||(cn=us);const ee=new cn({objectMode:!0}),le=($=m)===null||$===void 0?void 0:$.then;if(typeof le=="function")I++,le.call(m,Q=>{y=Q,Q!=null&&ee.write(Q),ae&&ee.end(),Wt.nextTick(S)},Q=>{ee.destroy(Q),Wt.nextTick(S,Q)});else if(ct(m,!0))I++,_r(m,ee,S,{end:ae});else if(fn(m)||Nt(m)){const Q=m.readable||m;I++,_r(Q,ee,S,{end:ae})}else throw new ln("AsyncIterable or Promise","destination",m);m=ee;const{destroy:ge,cleanup:we}=ds(m,!1,!0);x.push(ge),Ee&&l.push(we)}}else if(cs(T)){if(pr(m)){I+=2;const ee=Vl(m,T,S,{end:ae});un(T)&&Ee&&l.push(ee)}else if(Nt(m)||fn(m)){const ee=m.readable||m;I++,_r(ee,T,S,{end:ae})}else if(ct(m))I++,_r(m,T,S,{end:ae});else throw new an("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],m);m=T}else if(Wl(T)){if(pr(m))I++,_n(pn(m),T,S,{end:ae});else if(fn(m)||ct(m))I++,_n(m,T,S,{end:ae});else if(Nt(m))I++,_n(m.readable,T,S,{end:ae});else throw new an("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],m);m=T}else m=fs.from(T)}return(i!=null&&i.aborted||a!=null&&a.aborted)&&Wt.nextTick(u),m}function Vl(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new Ol)}),t.pipe(e,{end:!1}),n){let a=function(){i=!0,e.end()};Gl(t)?Wt.nextTick(a):t.once("end",a)}else r();return hr(t,{readable:!0,writable:!1},a=>{const l=t._readableState;a&&a.code==="ERR_STREAM_PREMATURE_CLOSE"&&l&&l.ended&&!l.errored&&!l.errorEmitted?t.once("end",r).once("error",r):r(a)}),hr(e,{readable:!1,writable:!0},r)}var bn={pipelineImpl:hs,pipeline:Ql};const{pipeline:Kl}=bn,br=Qe(),{destroyer:Yl}=Tt,{isNodeStream:yr,isReadable:ps,isWritable:_s,isWebStream:yn,isTransformStream:dt,isWritableStream:bs,isReadableStream:ys}=He,{AbortError:Xl,codes:{ERR_INVALID_ARG_VALUE:gs,ERR_MISSING_ARGS:Zl}}=xe,Jl=Je;var ws=function(...e){if(e.length===0)throw new Zl("streams");if(e.length===1)return br.from(e[0]);const r=[...e];if(typeof e[0]=="function"&&(e[0]=br.from(e[0])),typeof e[e.length-1]=="function"){const S=e.length-1;e[S]=br.from(e[S])}for(let S=0;S<e.length;++S)if(!(!yr(e[S])&&!yn(e[S]))){if(S<e.length-1&&!(ps(e[S])||ys(e[S])||dt(e[S])))throw new gs(`streams[${S}]`,r[S],"must be readable");if(S>0&&!(_s(e[S])||bs(e[S])||dt(e[S])))throw new gs(`streams[${S}]`,r[S],"must be writable")}let n,i,a,l,u;function p(S){const R=l;l=null,R?R(S):S?u.destroy(S):!I&&!x&&u.destroy()}const _=e[0],y=Kl(e,p),x=!!(_s(_)||bs(_)||dt(_)),I=!!(ps(y)||ys(y)||dt(y));if(u=new br({writableObjectMode:!!(_!=null&&_.writableObjectMode),readableObjectMode:!!(y!=null&&y.readableObjectMode),writable:x,readable:I}),x){if(yr(_))u._write=function(R,m,v){_.write(R,m)?v():n=v},u._final=function(R){_.end(),i=R},_.on("drain",function(){if(n){const R=n;n=null,R()}});else if(yn(_)){const m=(dt(_)?_.writable:_).getWriter();u._write=async function(v,$,B){try{await m.ready,m.write(v).catch(()=>{}),B()}catch(T){B(T)}},u._final=async function(v){try{await m.ready,m.close().catch(()=>{}),i=v}catch($){v($)}}}const S=dt(y)?y.readable:y;Jl(S,()=>{if(i){const R=i;i=null,R()}})}if(I){if(yr(y))y.on("readable",function(){if(a){const S=a;a=null,S()}}),y.on("end",function(){u.push(null)}),u._read=function(){for(;;){const S=y.read();if(S===null){a=u._read;return}if(!u.push(S))return}};else if(yn(y)){const R=(dt(y)?y.readable:y).getReader();u._read=async function(){for(;;)try{const{value:m,done:v}=await R.read();if(!u.push(m))return;if(v){u.push(null);return}}catch{return}}}}return u._destroy=function(S,R){!S&&l!==null&&(S=new Xl),a=null,n=null,i=null,l===null?R(S):(l=R,yr(y)&&Yl(y,S))},u};const eu=globalThis.AbortController||Ot().AbortController,{codes:{ERR_INVALID_ARG_VALUE:tu,ERR_INVALID_ARG_TYPE:Gt,ERR_MISSING_ARGS:ru,ERR_OUT_OF_RANGE:nu},AbortError:Ue}=xe,{validateAbortSignal:ht,validateInteger:ms,validateObject:pt}=Mt,iu=oe.Symbol("kWeak"),su=oe.Symbol("kResistStopPropagation"),{finished:ou}=Je,au=ws,{addAbortSignalNoValidate:lu}=ur,{isWritable:uu,isNodeStream:fu}=He,{deprecate:cu}=Se,{ArrayPrototypePush:du,Boolean:hu,MathFloor:xs,Number:pu,NumberIsNaN:_u,Promise:Es,PromiseReject:Ss,PromiseResolve:bu,PromisePrototypeThen:Is,Symbol:Rs}=oe,gr=Rs("kEmpty"),As=Rs("kEof");function yu(t,e){if(e!=null&&pt(e,"options"),(e==null?void 0:e.signal)!=null&&ht(e.signal,"options.signal"),fu(t)&&!uu(t))throw new tu("stream",t,"must be writable");const r=au(this,t);return e!=null&&e.signal&&lu(e.signal,r),r}function wr(t,e){if(typeof t!="function")throw new Gt("fn",["Function","AsyncFunction"],t);e!=null&&pt(e,"options"),(e==null?void 0:e.signal)!=null&&ht(e.signal,"options.signal");let r=1;(e==null?void 0:e.concurrency)!=null&&(r=xs(e.concurrency));let n=r-1;return(e==null?void 0:e.highWaterMark)!=null&&(n=xs(e.highWaterMark)),ms(r,"options.concurrency",1),ms(n,"options.highWaterMark",0),n+=r,(async function*(){const a=Se.AbortSignalAny([e==null?void 0:e.signal].filter(hu)),l=this,u=[],p={signal:a};let _,y,x=!1,I=0;function S(){x=!0,R()}function R(){I-=1,m()}function m(){y&&!x&&I<r&&u.length<n&&(y(),y=null)}async function v(){try{for await(let $ of l){if(x)return;if(a.aborted)throw new Ue;try{if($=t($,p),$===gr)continue;$=bu($)}catch(B){$=Ss(B)}I+=1,Is($,R,S),u.push($),_&&(_(),_=null),!x&&(u.length>=n||I>=r)&&await new Es(B=>{y=B})}u.push(As)}catch($){const B=Ss($);Is(B,R,S),u.push(B)}finally{x=!0,_&&(_(),_=null)}}v();try{for(;;){for(;u.length>0;){const $=await u[0];if($===As)return;if(a.aborted)throw new Ue;$!==gr&&(yield $),u.shift(),m()}await new Es($=>{_=$})}}finally{x=!0,y&&(y(),y=null)}}).call(this)}function gu(t=void 0){return t!=null&&pt(t,"options"),(t==null?void 0:t.signal)!=null&&ht(t.signal,"options.signal"),(async function*(){let r=0;for await(const i of this){var n;if(t!=null&&(n=t.signal)!==null&&n!==void 0&&n.aborted)throw new Ue({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function Ts(t,e=void 0){for await(const r of gn.call(this,t,e))return!0;return!1}async function wu(t,e=void 0){if(typeof t!="function")throw new Gt("fn",["Function","AsyncFunction"],t);return!await Ts.call(this,async(...r)=>!await t(...r),e)}async function mu(t,e){for await(const r of gn.call(this,t,e))return r}async function xu(t,e){if(typeof t!="function")throw new Gt("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),gr}for await(const n of wr.call(this,r,e));}function gn(t,e){if(typeof t!="function")throw new Gt("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:gr}return wr.call(this,r,e)}class Eu extends ru{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}}async function Su(t,e,r){var n;if(typeof t!="function")throw new Gt("reducer",["Function","AsyncFunction"],t);r!=null&&pt(r,"options"),(r==null?void 0:r.signal)!=null&&ht(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){const _=new Ue(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await ou(this.destroy(_)),_}const a=new eu,l=a.signal;if(r!=null&&r.signal){const _={once:!0,[iu]:this,[su]:!0};r.signal.addEventListener("abort",()=>a.abort(),_)}let u=!1;try{for await(const _ of this){var p;if(u=!0,r!=null&&(p=r.signal)!==null&&p!==void 0&&p.aborted)throw new Ue;i?e=await t(e,_,{signal:l}):(e=_,i=!0)}if(!u&&!i)throw new Eu}finally{a.abort()}return e}async function Iu(t){t!=null&&pt(t,"options"),(t==null?void 0:t.signal)!=null&&ht(t.signal,"options.signal");const e=[];for await(const n of this){var r;if(t!=null&&(r=t.signal)!==null&&r!==void 0&&r.aborted)throw new Ue(void 0,{cause:t.signal.reason});du(e,n)}return e}function Ru(t,e){const r=wr.call(this,t,e);return(async function*(){for await(const i of r)yield*i}).call(this)}function vs(t){if(t=pu(t),_u(t))return 0;if(t<0)throw new nu("number",">= 0",t);return t}function Au(t,e=void 0){return e!=null&&pt(e,"options"),(e==null?void 0:e.signal)!=null&&ht(e.signal,"options.signal"),t=vs(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new Ue;for await(const a of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new Ue;t--<=0&&(yield a)}}).call(this)}function Tu(t,e=void 0){return e!=null&&pt(e,"options"),(e==null?void 0:e.signal)!=null&&ht(e.signal,"options.signal"),t=vs(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new Ue;for await(const a of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new Ue;if(t-- >0&&(yield a),t<=0)return}}).call(this)}Lr.streamReturningOperators={asIndexedPairs:cu(gu,"readable.asIndexedPairs will be removed in a future version."),drop:Au,filter:gn,flatMap:Ru,map:wr,take:Tu,compose:yu},Lr.promiseReturningOperators={every:wu,forEach:xu,reduce:Su,toArray:Iu,some:Ts,find:mu};var wn,Ns;function Ps(){if(Ns)return wn;Ns=1;const{ArrayPrototypePop:t,Promise:e}=oe,{isIterable:r,isNodeStream:n,isWebStream:i}=He,{pipelineImpl:a}=bn,{finished:l}=Je;Ls();function u(...p){return new e((_,y)=>{let x,I;const S=p[p.length-1];if(S&&typeof S=="object"&&!n(S)&&!r(S)&&!i(S)){const R=t(p);x=R.signal,I=R.end}a(p,(R,m)=>{R?y(R):_(m)},{signal:x,end:I})})}return wn={finished:l,pipeline:u},wn}var js;function Ls(){if(js)return Pr.exports;js=1;const{Buffer:t}=Fe,{ObjectDefineProperty:e,ObjectKeys:r,ReflectApply:n}=oe,{promisify:{custom:i}}=Se,{streamReturningOperators:a,promiseReturningOperators:l}=Lr,{codes:{ERR_ILLEGAL_CONSTRUCTOR:u}}=xe,p=ws,{setDefaultHighWaterMark:_,getDefaultHighWaterMark:y}=cr,{pipeline:x}=bn,{destroyer:I}=Tt,S=Je,R=Ps(),m=He,v=Pr.exports=Qr.Stream;v.isDestroyed=m.isDestroyed,v.isDisturbed=m.isDisturbed,v.isErrored=m.isErrored,v.isReadable=m.isReadable,v.isWritable=m.isWritable,v.Readable=dr();for(const B of r(a)){let q=function(...U){if(new.target)throw u();return v.Readable.from(n(T,this,U))};const T=a[B];e(q,"name",{__proto__:null,value:T.name}),e(q,"length",{__proto__:null,value:T.length}),e(v.Readable.prototype,B,{__proto__:null,value:q,enumerable:!1,configurable:!0,writable:!0})}for(const B of r(l)){let q=function(...U){if(new.target)throw u();return n(T,this,U)};const T=l[B];e(q,"name",{__proto__:null,value:T.name}),e(q,"length",{__proto__:null,value:T.length}),e(v.Readable.prototype,B,{__proto__:null,value:q,enumerable:!1,configurable:!0,writable:!0})}v.Writable=en(),v.Duplex=Qe(),v.Transform=as,v.PassThrough=us,v.pipeline=x;const{addAbortSignal:$}=ur;return v.addAbortSignal=$,v.finished=S,v.destroy=I,v.compose=p,v.setDefaultHighWaterMark=_,v.getDefaultHighWaterMark=y,e(v,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return R}}),e(x,i,{__proto__:null,enumerable:!0,get(){return R.pipeline}}),e(S,i,{__proto__:null,enumerable:!0,get(){return R.finished}}),v.Stream=v,v._isUint8Array=function(T){return T instanceof Uint8Array},v._uint8ArrayToBuffer=function(T){return t.from(T.buffer,T.byteOffset,T.byteLength)},Pr.exports}(function(t){const e=Ls(),r=Ps(),n=e.Readable.destroy;t.exports=e.Readable,t.exports._uint8ArrayToBuffer=e._uint8ArrayToBuffer,t.exports._isUint8Array=e._isUint8Array,t.exports.isDisturbed=e.isDisturbed,t.exports.isErrored=e.isErrored,t.exports.isReadable=e.isReadable,t.exports.Readable=e.Readable,t.exports.Writable=e.Writable,t.exports.Duplex=e.Duplex,t.exports.Transform=e.Transform,t.exports.PassThrough=e.PassThrough,t.exports.addAbortSignal=e.addAbortSignal,t.exports.finished=e.finished,t.exports.destroy=e.destroy,t.exports.destroy=n,t.exports.pipeline=e.pipeline,t.exports.compose=e.compose,Object.defineProperty(e,"promises",{configurable:!0,enumerable:!0,get(){return r}}),t.exports.Stream=e.Stream,t.exports.default=t.exports})(Hn);var $s=Hn.exports;const mn=Symbol("iter");function zt(t,e,r=4){if(r===0)return Object.assign(t,e);for(const n in e)t[n]=zt(t[n]||Object.create(null),e[n],r-1);return t}function Bs(t,e,r=4){let n=!1;for(const i in t)if(i in e){const a=r===0?null:Bs(t[i],e[i],r-1);if(a!==!1)n=n||Object.create(null),n[i]=a;else if(r===3)return!1}return n}function Fs(t,e,r=4){let n=!1;for(const i in t)if(!(i in e))n=n||Object.create(null),n[i]=r===0?null:zt({},t[i],r-1);else if(r!==0){const a=Fs(t[i],e[i],r-1);if(a!==!1)n=n||Object.create(null),n[i]=a;else if(r===3)return!1}return n}class vu{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||ot}_termFromId(e){if(e[0]==="."){const 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 $t(e,this._factory)}_termToNumericId(e){if(e.termType==="Quad"){const r=this._termToNumericId(e.subject),n=this._termToNumericId(e.predicate),i=this._termToNumericId(e.object);let a;return r&&n&&i&&(Nr(e.graph)||(a=this._termToNumericId(e.graph)))&&this._ids[a?`.${r}.${n}.${i}.${a}`:`.${r}.${n}.${i}`]}return this._ids[xt(e)]}_termToNewNumericId(e){const r=e&&e.termType==="Quad"?`.${this._termToNewNumericId(e.subject)}.${this._termToNewNumericId(e.predicate)}.${this._termToNewNumericId(e.object)}${Nr(e.graph)?"":`.${this._termToNewNumericId(e.graph)}`}`:xt(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))}}class Ie{constructor(e,r){this._size=0,this._graphs=Object.create(null),!r&&e&&!e[0]&&(r=e,e=null),r=r||{},this._factory=r.factory||ot,this._entityIndex=r.entityIndex||new vu({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.addQuads(e)}get size(){let e=this._size;if(e!==null)return e;e=0;const r=this._graphs;let n,i;for(const a in r)for(const l in n=r[a].subjects)for(const u in i=n[l])e+=Object.keys(i[u]).length;return this._size=e}_addToIndex(e,r,n,i){const a=e[r]||(e[r]={}),l=a[n]||(a[n]={}),u=i in l;return u||(l[i]=null),!u}_removeFromIndex(e,r,n,i){const a=e[r],l=a[n];delete l[i];for(const u in l)return;delete a[n];for(const u in a)return;delete e[r]}*_findInIndex(e,r,n,i,a,l,u,p){let _,y,x;const I=this._entities,S=this._termFromId(I[p]),R={subject:null,predicate:null,object:null};r&&((_=e,e={})[r]=_[r]);for(const m in e)if(y=e[m]){R[a]=this._termFromId(I[m]),n&&((_=y,y={})[n]=_[n]);for(const v in y)if(x=y[v]){R[l]=this._termFromId(I[v]);const $=i?i in x?[i]:[]:Object.keys(x);for(let B=0;B<$.length;B++)R[u]=this._termFromId(I[$[B]]),yield this._factory.quad(R.subject,R.predicate,R.object,S)}}}_loop(e,r){for(const n in e)r(n)}_loopByKey0(e,r,n){let i,a;if(i=e[r])for(a in i)n(a)}_loopByKey1(e,r,n){let i,a;for(i in e)a=e[i],a[r]&&n(i)}_loopBy2Keys(e,r,n,i){let a,l,u;if((a=e[r])&&(l=a[n]))for(u in l)i(u)}_countInIndex(e,r,n,i){let a=0,l,u,p;r&&((l=e,e={})[r]=l[r]);for(const _ in e)if(u=e[_]){n&&((l=u,u={})[n]=l[n]);for(const y in u)(p=u[y])&&(i?i in p&&a++:a+=Object.keys(p).length)}return a}_getGraphs(e){return e=e===""?1:e&&(this._termToNumericId(e)||-1),typeof e!="number"?this._graphs:{[e]:this._graphs[e]}}_uniqueEntities(e){const 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 a=this._graphs[i];return a||(a=this._graphs[i]={subjects:{},predicates:{},objects:{}},Object.freeze(a)),e=this._termToNewNumericId(e),r=this._termToNewNumericId(r),n=this._termToNewNumericId(n),this._addToIndex(a.subjects,e,r,n)?(this._addToIndex(a.predicates,r,n,e),this._addToIndex(a.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;const a=this._graphs;let l,u,p;if(!(e=e&&this._termToNumericId(e))||!(r=r&&this._termToNumericId(r))||!(n=n&&this._termToNumericId(n))||!(l=a[i])||!(u=l.subjects[e])||!(p=u[r])||!(n in p))return!1;this._removeFromIndex(l.subjects,e,r,n),this._removeFromIndex(l.predicates,r,n,e),this._removeFromIndex(l.objects,n,e,r),this._size!==null&&this._size--;for(e in l.subjects)return!0;return delete a[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){const a=new $s.Readable({objectMode:!0}),l=this.readQuads(e,r,n,i);return a._read=u=>{for(;--u>=0;){const{done:p,value:_}=l.next();if(p){a.push(null);return}a.push(_)}},this.remove(a)}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){const a=this._getGraphs(i);let l,u,p,_;if(!(e&&!(u=this._termToNumericId(e))||r&&!(p=this._termToNumericId(r))||n&&!(_=this._termToNumericId(n))))for(const y in a)(l=a[y])&&(u?_?yield*this._findInIndex(l.objects,_,u,p,"object","subject","predicate",y):yield*this._findInIndex(l.subjects,u,p,null,"subject","predicate","object",y):p?yield*this._findInIndex(l.predicates,p,_,null,"predicate","object","subject",y):_?yield*this._findInIndex(l.objects,_,null,null,"object","subject","predicate",y):yield*this._findInIndex(l.subjects,null,null,null,"subject","predicate","object",y))}match(e,r,n,i){return new et(this,e,r,n,i,{entityIndex:this._entityIndex})}countQuads(e,r,n,i){const a=this._getGraphs(i);let l=0,u,p,_,y;if(e&&!(p=this._termToNumericId(e))||r&&!(_=this._termToNumericId(r))||n&&!(y=this._termToNumericId(n)))return 0;for(const x in a)(u=a[x])&&(e?n?l+=this._countInIndex(u.objects,y,p,_):l+=this._countInIndex(u.subjects,p,_,y):r?l+=this._countInIndex(u.predicates,_,y,p):l+=this._countInIndex(u.objects,y,p,_));return l}forEach(e,r,n,i,a){this.some(l=>(e(l,this),!1),r,n,i,a)}every(e,r,n,i,a){return!this.some(l=>!e(l,this),r,n,i,a)}some(e,r,n,i,a){for(const l of this.readQuads(r,n,i,a))if(e(l))return!0;return!1}getSubjects(e,r,n){const i=[];return this.forSubjects(a=>{i.push(a)},e,r,n),i}forSubjects(e,r,n,i){const a=this._getGraphs(i);let l,u,p;if(e=this._uniqueEntities(e),!(r&&!(u=this._termToNumericId(r))||n&&!(p=this._termToNumericId(n))))for(i in a)(l=a[i])&&(u?p?this._loopBy2Keys(l.predicates,u,p,e):this._loopByKey1(l.subjects,u,e):p?this._loopByKey0(l.objects,p,e):this._loop(l.subjects,e))}getPredicates(e,r,n){const i=[];return this.forPredicates(a=>{i.push(a)},e,r,n),i}forPredicates(e,r,n,i){const a=this._getGraphs(i);let l,u,p;if(e=this._uniqueEntities(e),!(r&&!(u=this._termToNumericId(r))||n&&!(p=this._termToNumericId(n))))for(i in a)(l=a[i])&&(u?p?this._loopBy2Keys(l.objects,p,u,e):this._loopByKey0(l.subjects,u,e):p?this._loopByKey1(l.predicates,p,e):this._loop(l.predicates,e))}getObjects(e,r,n){const i=[];return this.forObjects(a=>{i.push(a)},e,r,n),i}forObjects(e,r,n,i){const a=this._getGraphs(i);let l,u,p;if(e=this._uniqueEntities(e),!(r&&!(u=this._termToNumericId(r))||n&&!(p=this._termToNumericId(n))))for(i in a)(l=a[i])&&(u?p?this._loopBy2Keys(l.subjects,u,p,e):this._loopByKey1(l.objects,u,e):p?this._loopByKey0(l.predicates,p,e):this._loop(l.objects,e))}getGraphs(e,r,n){const i=[];return this.forGraphs(a=>{i.push(a)},e,r,n),i}forGraphs(e,r,n,i){for(const a in this._graphs)this.some(l=>(e(l.graph),!0),r,n,i,this._termFromId(this._entities[a]))}createBlankNode(e){return this._entityIndex.createBlankNode(e)}extractLists({remove:e=!1,ignoreErrors:r=!1}={}){const n={},i=r?()=>!0:(u,p)=>{throw new Error(`${u.value} ${p}`)},a=this.getQuads(null,_e.rdf.rest,_e.rdf.nil,null),l=e?[...a]:[];return a.forEach(u=>{const p=[];let _=!1,y,x;const I=u.graph;let S=u.subject;for(;S&&!_;){const R=this.getQuads(null,null,S,null),m=this.getQuads(S,null,null,null);let v,$=null,B=null,T=null;for(let q=0;q<m.length&&!_;q++)v=m[q],v.graph.equals(I)?y?_=i(S,"has non-list arcs out"):v.predicate.value===_e.rdf.first?$?_=i(S,"has multiple rdf:first arcs"):l.push($=v):v.predicate.value===_e.rdf.rest?B?_=i(S,"has multiple rdf:rest arcs"):l.push(B=v):R.length?_=i(S,"can't be subject and object"):(y=v,x="subject"):_=i(S,"not confined to single graph");for(let q=0;q<R.length&&!_;++q)v=R[q],y?_=i(S,"can't have coreferences"):v.predicate.value===_e.rdf.rest?T?_=i(S,"has incoming rdf:rest arcs"):T=v:(y=v,x="object");$?p.unshift($.object):_=i(S,"has no list head"),S=T&&T.subject}_?e=!1:y&&(n[y[x].value]=p)}),e&&this.removeQuads(l),n}addAll(e){if(e instanceof et&&(e=e.filtered),Array.isArray(e))this.addQuads(e);else if(e instanceof Ie&&e._entityIndex===this._entityIndex)e._size!==0&&(this._graphs=zt(this._graphs,e._graphs),this._size=null);else for(const r of e)this.add(r);return this}contains(e){if(e instanceof et&&(e=e.filtered),e===this)return!0;if(!(e instanceof Ie)||this._entityIndex!==e._entityIndex)return e.every(_=>this.has(_));const r=this._graphs,n=e._graphs;let i,a,l,u,p;for(const _ in n){if(!(i=r[_]))return!1;i=i.subjects;for(const y in a=n[_].subjects){if(!(l=i[y]))return!1;for(const x in u=a[y]){if(!(p=l[x]))return!1;for(const I in u[x])if(!(I in p))return!1}}}return!0}deleteMatches(e,r,n,i){for(const a of this.match(e,r,n,i))this.removeQuad(a);return this}difference(e){if(e&&e instanceof et&&(e=e.filtered),e===this)return new Ie({entityIndex:this._entityIndex});if(e instanceof Ie&&e._entityIndex===this._entityIndex){const r=new Ie({entityIndex:this._entityIndex}),n=Fs(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 et&&(e=e.filtered),e===this||this.size===e.size&&this.contains(e)}filter(e){const r=new Ie({entityIndex:this._entityIndex});for(const n of this)e(n,this)&&r.add(n);return r}intersection(e){if(e instanceof et&&(e=e.filtered),e===this){const r=new Ie({entityIndex:this._entityIndex});return r._graphs=zt(Object.create(null),this._graphs),r._size=this._size,r}else if(e instanceof Ie&&this._entityIndex===e._entityIndex){const r=new Ie({entityIndex:this._entityIndex}),n=Bs(e._graphs,this._graphs);return n&&(r._graphs=n,r._size=null),r}return this.filter(r=>e.has(r))}map(e){const r=new Ie({entityIndex:this._entityIndex});for(const n of this)r.add(e(n,this));return r}reduce(e,r){const n=this.readQuads();let i=r===void 0?n.next().value:r;for(const a of n)i=e(i,a,this);return i}toArray(){return this.getQuads()}toCanonical(){throw new Error("not implemented")}toStream(){return this.match()}toString(){return new Gn().quadsToString(this)}union(e){const r=new Ie({entityIndex:this._entityIndex});return r._graphs=zt(Object.create(null),this._graphs),r._size=this._size,r.addAll(e),r}*[Symbol.iterator](){yield*this.readQuads()}}function We(t,e,r=0){const n=e[r];if(n&&!(n in t))return!1;let i=!1;for(const a in n?{[n]:t[n]}:t){const l=r===2?null:We(t[a],e,r+1);l!==!1&&(i=i||Object.create(null),i[a]=l)}return i}class et extends $s.Readable{constructor(e,r,n,i,a,l){super({objectMode:!0}),Object.assign(this,{n3Store:e,subject:r,predicate:n,object:i,graph:a,options:l})}get filtered(){if(!this._filtered){const{n3Store:e,graph:r,object:n,predicate:i,subject:a}=this,l=this._filtered=new Ie({factory:e._factory,entityIndex:this.options.entityIndex});let u,p,_;if(a&&!(u=l._termToNumericId(a))||i&&!(p=l._termToNumericId(i))||n&&!(_=l._termToNumericId(n)))return l;const y=e._getGraphs(r);for(const x in y){let I,S,R,m;(m=y[x])&&(!u&&p?(S=We(m.predicates,[p,_,u]))&&(I=We(m.subjects,[u,p,_]),R=We(m.objects,[_,u,p])):_?(R=We(m.objects,[_,u,p]))&&(I=We(m.subjects,[u,p,_]),S=We(m.predicates,[p,_,u])):(I=We(m.subjects,[u,p,_]))&&(S=We(m.predicates,[p,_,u]),R=We(m.objects,[_,u,p])),I&&(l._graphs[x]={subjects:I,predicates:S,objects:R}))}l._size=null}return this._filtered}get size(){return this.filtered.size}_read(e){e>0&&!this[mn]&&(this[mn]=this[Symbol.iterator]());const r=this[mn];for(;--e>=0;){const{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,a){return this.filtered.every(e,r,n,i,a)}filter(e){return this.filtered.filter(e)}forEach(e,r,n,i,a){return this.filtered.forEach(e,r,n,i,a)}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,a){return this.filtered.some(e,r,n,i,a)}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 Gn().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 et(this.filtered,e,r,n,i,this.options)}*[Symbol.iterator](){yield*this._filtered||this.n3Store.readQuads(this.subject,this.predicate,this.object,this.graph)}}const mr={rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#"},pe={namespace:"https://prez.dev/",label:"https://prez.dev/label",description:"https://prez.dev/description",provenance:"https://prez.dev/provenance",focusNode:"https://prez.dev/FocusNode",link:"https://prez.dev/link",members:"https://prez.dev/members",identifier:"https://prez.dev/identifier",count:"https://prez.dev/count",searchResult:"https://prez.dev/SearchResult",searchResultWeight:"https://prez.dev/searchResultWeight",searchResultPredicate:"https://prez.dev/searchResultPredicate",searchResultURI:"https://prez.dev/searchResultURI",searchResultMatch:"https://prez.dev/searchResultMatch",hasChildren:"https://prez.dev/hasChildren"},ye={skosConceptScheme:"http://www.w3.org/2004/02/skos/core#ConceptScheme",skosConcept:"http://www.w3.org/2004/02/skos/core#Concept",a:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",rdfLangString:"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",xmlString:"http://www.w3.org/2001/XMLSchema#string",w3Html:"http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML",w3Markdown:"https://www.w3.org/ns/iana/media-types/text/markdown",shaclAllPredicates:"http://example.com/shacl-extension#allPredicateValues",shaclProperty:"http://www.w3.org/ns/shacl#property",shaclPath:"http://www.w3.org/ns/shacl#path",shaclUnion:"http://www.w3.org/ns/shacl#union"},Nu={label:["https://prez.dev/label"],description:["https://prez.dev/description"],provenance:["https://prez.dev/provenance"]};function ks(t,e=mr){if(t==="a")return e.rdf+"type";{const[r,n]=t.split(":");return r?[r]+n:t}}function Cs(t,e=mr){let r="";return Object.entries(e).forEach(([n,i])=>{t.startsWith(i)&&(r=n+":"+t.split(i)[1])}),r}const Os=t=>{const e=new URL(t);return`${e.protocol}//${e.hostname}`},Pu=t=>new URL(t).pathname,ju=(t,e)=>{var n,i;const r=(i=(n=e.identifiers)==null?void 0:n.find(a=>a.value))==null?void 0:i.value;return r?t+`/concept-hierarchy/${r}/narrowers`:""},Lu=(t,e)=>{var l;const r=e?Os(e):"",n=(l=t.identifiers)==null?void 0:l.find(u=>u.value),i=n?n.value:"";return i?r+`/concept-hierarchy/${i}/top-concepts`:""},xr=t=>t.flatMap(e=>{var r;if(e["@id"])return e["@id"];if(e["@list"]&&e["@list"].length>0){const n=e["@list"][0];return(n==null?void 0:n["@id"])===ye.shaclUnion?xr(((r=e["@list"][1])==null?void 0:r["@list"])||[]).filter(Boolean):xr(e["@list"]).flat()}return[]}).filter(e=>!!e),$u=t=>t.reduce((e,r)=>{if(ye.shaclProperty in r)for(const n of r[ye.shaclProperty]){const i=t.find(a=>a["@id"]===n["@id"]);i&&ye.shaclPath in i&&(e[r["@id"]]=xr(i[ye.shaclPath]).filter(a=>a!==ye.shaclAllPredicates))}return e},{});function qt(t){if(Array.isArray(t))return t.reduce((e,r)=>{const n=qt(r);return typeof n=="object"&&!Array.isArray(n)&&Object.assign(e,n),e},{});if(typeof t=="object"&&t!==null){if(t.hasOwnProperty("value"))return t.value;if(t.hasOwnProperty("node")&&t.hasOwnProperty("list")){const e={};return e[t.node.value]=t.list.length>0?qt(t.list):"",e}else{const e={};for(const r in t)e[r]=qt(t[r]);return e}}return t}function xn(t,e=""){let r="";const n=Object.entries(t),i=n.length;return n.forEach(([a,l],u)=>{const p=a.replace(/https?:\/\/(www\.)?/,""),[_,y]=p.split("#"),x=_.split("/"),I=x[x.length-1],S=y?`(${x[0]})/${I}#${y}`:`(${x[0]})/${I}`,R=u===i-1;r+=`${e}${R?"└── ":"├── "}${S}
28
+ `,typeof l=="object"&&l!==null&&(r+=xn(l,e+(R?" ":"│ ")))}),r}function Bu(t){return t?xn(qt(t)):""}const{namedNode:Ht}=ot;class Er{constructor(){nt(this,"store");nt(this,"parser");nt(this,"prefixes");nt(this,"basePath");nt(this,"baseUrl");nt(this,"linkedLists");nt(this,"lists");this.store=new Ie,this.baseUrl="",this.basePath="",this.parser=new Mn,this.prefixes=mr,this.linkedLists={},this.lists={}}load(e){e=`PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
29
+ `+e;const r=this.parser.parse(e,null,(n,i)=>{this.prefixes[n]=i.value});this.store.addQuads(r),this.linkedLists=this.store.extractLists(),this.buildLists()}buildSubList(e){const r=[];for(const n of e)if(n.termType=="BlankNode"){const i=n.value;if(i in this.linkedLists){const a=this.buildSubList(this.linkedLists[i]);if(a.length>1){const l=r.find(u=>u.node.value==a[0].node.value);l?(l.list??(l.list=[])).push(...a.slice(1)):r.push({node:a[0].node,list:a.slice(1)})}else r.push(...a)}}else if(n.termType=="NamedNode"&&n.value!=ye.shaclUnion){const i=this.toPrezTerm(new Tr(n.value));r.push({node:i,list:[]})}return r}buildLists(){this.lists={};const e=this.linkedLists;for(const r in e){const n=e[r];if(n.find(a=>a.termType=="NamedNode"&&a.value==ye.shaclUnion)){const a=n.find(l=>l.termType=="BlankNode");a&&a.value in this.linkedLists&&(this.lists[r]=this.buildSubList(this.linkedLists[a.value]))}}}setBaseUrl(e){this.baseUrl=e,this.basePath=new URL(e).pathname}toIri(e){return ks(e,this.prefixes)}fromIri(e){return Cs(e,this.prefixes)}getObjectLiteral(e,r){return this.getObjects(e,r).map(n=>this.toPrezTerm(n))[0]||void 0}getProperties(e,r){const n={};return this.store.forEach(i=>{var a;r!=null&&r.excludePrefix&&i.predicate.value.startsWith(r.excludePrefix)||r!=null&&r.includePrefix&&!i.predicate.value.startsWith(r.includePrefix)||(n[a=i.predicate.value]??(n[a]={predicate:this.toPrezTerm(i.predicate),objects:[]}),n[i.predicate.value].objects.push(this.toPrezTerm(i.object)))},e,null,null,null),e.termType,n}getParents(e){e.startsWith(this.basePath)&&(e=e.substring(this.basePath.length));const r=e.split("/"),n=[];let i="";for(const a of r){if(a=="")continue;i+="/"+a;const l={url:i,segment:a};if(a.includes(":")){const u=a.split(":"),p=this.prefixes[u[0]];if(p){const _=this.getObjects(p+u[1],pe.label);_.length>0&&(l.label=Ir(_[0].value))}}n.push(l)}return n}toPrezTerm(e){switch(e.termType){case"NamedNode":const r=it(e.value);r.label=this.getObjectLiteral(e.value,pe.label),r.description=this.getObjectLiteral(e.value,pe.description),r.provenance=this.getObjectLiteral(e.value,pe.provenance);const n=this.getObjects(e.value,pe.identifier);n.length>0&&(r.identifiers=n.map(_=>this.toPrezTerm(_)));const i=this.getObjects(e.value,pe.link);i.length>0&&(r.links=i.map(_=>({value:_.value,parents:this.getParents(_.value)})));const a=this.getObjects(e.value,pe.members);a.length>0&&(r.members={value:a[0].value,parents:this.getParents(a[0].value)});const l=this.getObjects(e.value,ye.a);return l.length>0&&(r.rdfTypes=l.map(_=>this.toPrezTerm(_))),r;case"Literal":const u=Ir(e.value);return e.datatype&&(u.datatype=this.toPrezTerm(e.datatype)),e.language&&(u.language=e.language),u;case"BlankNode":const p=vn(e.value);return p.properties=this.getProperties(e),e.value in this.lists&&(p.list=this.lists[e.value]),p;default:throw"Invalid n3 Term object"}}toPrezFocusNode(e){var n,i,a,l,u;const r=this.toPrezTerm(e);return r.properties=this.getProperties(e,{excludePrefix:pe.namespace}),r.systemProperties=this.getProperties(e,{includePrefix:pe.namespace}),(n=r.rdfTypes)!=null&&n.map(p=>p.value).includes(ye.skosConcept)&&(r.hasChildren=((u=(l=(a=(i=r.systemProperties)==null?void 0:i[pe.hasChildren])==null?void 0:a.objects)==null?void 0:l[0])==null?void 0:u.value)=="true"),r}getSubjects(e,r){return this.store.getSubjects(e,r,null)}getObjects(e,r){if(typeof r=="string")return this.store.getObjects(Ht(e),Ht(r),null);{const n=[];return r.forEach(i=>{n.push(...this.store.getObjects(Ht(e),Ht(i),null))}),n}}getMembers(e){this.getObjects(e,this.toIri("prez:members")).forEach(n=>({value:n.value,parents:[]}))}getConcepts(e){const r=this.getSubjects(this.toIri("skos:inScheme"),e.value);function n(_){return r.map(y=>y.value).includes(_.value)}const i=this.getObjects(e.value,this.toIri("skos:hasTopConcept")),a=this.getObjects(e.value,this.toIri("skos:topConceptOf")),l={},u=[...i,...a].filter(_=>n(_));r.forEach(_=>{l[_.value]=[]}),r.forEach(_=>{this.getObjects(_.value,this.toIri("skos:broader")).forEach(I=>{n(I)&&l[I.value].push(_)}),this.getObjects(_.value,this.toIri("skos:narrower")).forEach(I=>{n(I)&&l[_.value].push(I)})});const p=[];return u.forEach(_=>{p.push(this.createHierarchy(_,l))}),p}createHierarchy(e,r){const n=r[e.value].map(i=>this.createHierarchy(i,r));return{...this.toPrezTerm(e),hasChildren:n.length>0,narrowers:n}}getByPrezId(e){const r=[];return this.store.forEach(n=>{r.push(n)},null,null,Ht("https://prez.dev/FocusNode"),null),e?r.find(n=>n.object.value===e).subject:r.map(n=>n.subject)}getCount(){const e=this.store.getObjects(null,pe.count,null);return e.length>0?Number(e[0].value.replace(">","")):0}getMaxReached(){const e=this.store.getObjects(null,pe.count,null);return e.length>0?e[0].value.includes(">"):!1}getList(){const e=[];return this.getByPrezId().forEach(n=>{e.push(this.toPrezFocusNode(n))}),e}getItem(){var n;const e=this.getByPrezId();if(e.length==0)throw new Error("Unable to find item");const r=this.toPrezFocusNode(e[0]);if((n=r.rdfTypes)!=null&&n.map(i=>i.value).includes(ye.skosConcept)){const i=this.getConcepts(e[0]);return{...r,topConcepts:{narrowers:i,hasChildren:i.length>0}}}return r}getSubItems(e){const r=this.store.getQuads(null,e,null,null),n=[];return r.forEach(i=>{const a=this.toPrezFocusNode(i.object);a&&n.push(a)}),n}search(){return this.getSubjects(ye.a,pe.searchResult).map(n=>({hash:n.value.split("urn:hash:").slice(-1)[0],weight:Number(this.getObjects(n.value,pe.searchResultWeight)[0].value),predicate:this.toPrezTerm(this.getObjects(n.value,pe.searchResultPredicate)[0]),match:this.toPrezTerm(this.getObjects(n.value,pe.searchResultMatch)[0]),resource:this.toPrezFocusNode(this.getObjects(n.value,pe.searchResultURI)[0])}))}}class Fu extends Error{constructor(e){super(e),this.name="NetworkError"}}function ku(t){let e={};const r=t.split(",").map(i=>{const[,a,l]=i.trim().match(/<(.+)>; (.+)/),u={uri:a};return l.split("; ").forEach(p=>{const[,_,y]=p.match(/(.+)=[\"<](.+)[\">]/);u[_]=y}),u});r.filter(i=>i.rel==="type").forEach(i=>{e[i.anchor]={default:!1,current:!1,token:i.token,mediatypes:[],title:i.title,description:"",uri:i.anchor}});const n=r.find(i=>i.rel==="self");return n.format in e&&(e[n.format].current=!0),r.filter(i=>i.rel==="alternate"&&i.format).forEach(i=>{e[i.format].mediatypes.map(a=>a.mediatype).includes(i.type)||e[i.format].mediatypes.push({title:"",mediatype:i.type,default:!1})}),Object.values(e)}async function Sr(t){const e=await fetch(t,{method:"GET",headers:{Accept:"text/anot+turtle"}});if(!e.ok)throw new Fu(`Network error - status code ${e.status}: ${e.statusText}`);const r=e.headers.get("link")||e.headers.get("Link"),n=r?ku(r):[];return{data:await e.text(),profiles:n}}async function Ms(t,e){const r=t+e,n=new URL(r).pathname,{data:i,profiles:a}=await Sr(r),l=new Er;return l.setBaseUrl(t),l.load(i),{type:"list",data:l.getList(),profiles:a,maxReached:l.getMaxReached(),count:l.getCount(),parents:l.getParents(n)}}async function Cu(t,e){const r=t+e,n=new URL(r).pathname,{data:i,profiles:a}=await Sr(r),l=new Er;return l.setBaseUrl(t),l.load(i),{type:"item",data:l.getItem(),profiles:a,parents:l.getParents(n),store:l}}async function Ou(t,e){const r=t+e,n=new URL(r).pathname,{data:i,profiles:a}=await Sr(r),l=new Er;return l.setBaseUrl(t),l.load(i),{type:"search",data:l.search(),profiles:a,maxReached:l.getMaxReached(),count:l.getCount(),parents:l.getParents(n)}}async function Mu(t){var i,a;const e="/profiles?page=1&limit=999&_mediatype=application/anot%2Bturtle",{data:r}=await Ms(t,e),n={};for(const l of r)if(n[l.value]=[],l.properties&&((a=(i=l.properties)==null?void 0:i[ye.shaclProperty])!=null&&a.objects)){const u=l.properties[ye.shaclProperty].objects;for(const p of u){const _=p;if(_.properties&&_.properties[ye.shaclPath])for(const y of _.properties[ye.shaclPath].objects){const x=y.list;x&&(n[l.value]=x)}}}return n}function Du(t,e){const r={},n=Object.keys(t),i=[...(e||[]).filter(a=>n.includes(a.node.value)).map(a=>a.node.value),...n.filter(a=>!(e||[]).find(l=>l.node.value==a))].filter(a=>a in(t||{})).map(a=>t[a]);for(const a of i)e.find(l=>l.node.value==a.predicate.value&&l.list&&l.list.length>0),r[a.predicate.value]=t[a.predicate.value];return r}function Uu(t,e){t.data.properties=Du(t.data.properties||{},e)}z.ANNOTATION_PREDICATES=Nu,z.DEFAULT_PREFIXES=mr,z.PREZ_PREDICATES=pe,z.RDFStore=Er,z.SYSTEM_PREDICATES=ye,z.apiGet=Sr,z.applyProfileToItem=Uu,z.bnode=vn,z.buildProfiles=$u,z.defaultFromIri=Cs,z.defaultToIri=ks,z.dumpNodeArray=Bu,z.getBaseUrl=Os,z.getItem=Cu,z.getList=Ms,z.getNarrowersUrl=ju,z.getProfiles=Mu,z.getTopConceptsUrl=Lu,z.getUrlPath=Pu,z.isTypePrezTerm=Ae,z.literal=Ir,z.node=it,z.nodeArrayToTree=xn,z.processShaclPath=xr,z.search=Ou,z.simplifyNodeArray=qt,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});