n3.js-messages 0.1.2 → 0.2.0

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.
@@ -0,0 +1,27 @@
1
+ var Pr=Object.create;var ct=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var Br=Object.getOwnPropertyNames;var Nr=Object.getPrototypeOf,Ar=Object.prototype.hasOwnProperty;var W=(i,e)=>()=>{try{return e||i((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var Sr=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Br(e))!Ar.call(i,n)&&n!==t&&ct(i,n,{get:()=>e[n],enumerable:!(r=Fr(e,n))||r.enumerable});return i};var ft=(i,e,t)=>(t=i!=null?Pr(Nr(i)):{},Sr(e||!i||!i.__esModule?ct(t,"default",{value:i,enumerable:!0}):t,i));var It=W((gn,je)=>{"use strict";var J=typeof Reflect=="object"?Reflect:null,dt=J&&typeof J.apply=="function"?J.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)},Ee;J&&typeof J.ownKeys=="function"?Ee=J.ownKeys:Object.getOwnPropertySymbols?Ee=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Ee=function(e){return Object.getOwnPropertyNames(e)};function Cr(i){console&&console.warn&&console.warn(i)}var pt=Number.isNaN||function(e){return e!==e};function x(){x.init.call(this)}je.exports=x;je.exports.once=Dr;x.EventEmitter=x;x.prototype._events=void 0;x.prototype._eventsCount=0;x.prototype._maxListeners=void 0;var _t=10;function Ie(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty(x,"defaultMaxListeners",{enumerable:!0,get:function(){return _t},set:function(i){if(typeof i!="number"||i<0||pt(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");_t=i}});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||pt(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 gt(i){return i._maxListeners===void 0?x.defaultMaxListeners:i._maxListeners}x.prototype.getMaxListeners=function(){return gt(this)};x.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n=e==="error",s=this._events;if(s!==void 0)n=n&&s.error===void 0;else if(!n)return!1;if(n){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var h=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw h.context=a,h}var l=s[e];if(l===void 0)return!1;if(typeof l=="function")dt(l,this,t);else for(var f=l.length,c=wt(l,f),r=0;r<f;++r)dt(c[r],this,t);return!0};function xt(i,e,t,r){var n,s,a;if(Ie(t),s=i._events,s===void 0?(s=i._events=Object.create(null),i._eventsCount=0):(s.newListener!==void 0&&(i.emit("newListener",e,t.listener?t.listener:t),s=i._events),a=s[e]),a===void 0)a=s[e]=t,++i._eventsCount;else if(typeof a=="function"?a=s[e]=r?[t,a]:[a,t]:r?a.unshift(t):a.push(t),n=gt(i),n>0&&a.length>n&&!a.warned){a.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=i,h.type=e,h.count=a.length,Cr(h)}return i}x.prototype.addListener=function(e,t){return xt(this,e,t,!1)};x.prototype.on=x.prototype.addListener;x.prototype.prependListener=function(e,t){return xt(this,e,t,!0)};function Lr(){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 mt(i,e,t){var r={fired:!1,wrapFn:void 0,target:i,type:e,listener:t},n=Lr.bind(r);return n.listener=t,r.wrapFn=n,n}x.prototype.once=function(e,t){return Ie(t),this.on(e,mt(this,e,t)),this};x.prototype.prependOnceListener=function(e,t){return Ie(t),this.prependListener(e,mt(this,e,t)),this};x.prototype.removeListener=function(e,t){var r,n,s,a,h;if(Ie(t),n=this._events,n===void 0)return this;if(r=n[e],r===void 0)return this;if(r===t||r.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if(typeof r!="function"){for(s=-1,a=r.length-1;a>=0;a--)if(r[a]===t||r[a].listener===t){h=r[a].listener,s=a;break}if(s<0)return this;s===0?r.shift():jr(r,s),r.length===1&&(n[e]=r[0]),n.removeListener!==void 0&&this.emit("removeListener",e,h||t)}return this};x.prototype.off=x.prototype.removeListener;x.prototype.removeAllListeners=function(e){var t,r,n;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var s=Object.keys(r),a;for(n=0;n<s.length;++n)a=s[n],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=r[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this};function yt(i,e,t){var r=i._events;if(r===void 0)return[];var n=r[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?$r(n):wt(n,n.length)}x.prototype.listeners=function(e){return yt(this,e,!0)};x.prototype.rawListeners=function(e){return yt(this,e,!1)};x.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):bt.call(i,e)};x.prototype.listenerCount=bt;function bt(i){var e=this._events;if(e!==void 0){var t=e[i];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}x.prototype.eventNames=function(){return this._eventsCount>0?Ee(this._events):[]};function wt(i,e){for(var t=new Array(e),r=0;r<e;++r)t[r]=i[r];return t}function jr(i,e){for(;e+1<i.length;e++)i[e]=i[e+1];i.pop()}function $r(i){for(var e=new Array(i.length),t=0;t<e.length;++t)e[t]=i[t].listener||i[t];return e}function Dr(i,e){return new Promise(function(t,r){function n(a){i.removeListener(e,s),r(a)}function s(){typeof i.removeListener=="function"&&i.removeListener("error",n),t([].slice.call(arguments))}Et(i,e,s,{once:!0}),e!=="error"&&Or(i,n,{once:!0})})}function Or(i,e,t){typeof i.on=="function"&&Et(i,"error",e,t)}function Et(i,e,t,r){if(typeof i.on=="function")r.once?i.once(e,t):i.on(e,t);else if(typeof i.addEventListener=="function")i.addEventListener(e,function n(s){r.once&&i.removeEventListener(e,n),t(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof i)}});var Kt=W(Ae=>{"use strict";Ae.byteLength=Ii;Ae.toByteArray=Ri;Ae.fromByteArray=Fi;var A=[],F=[],Ei=typeof Uint8Array<"u"?Uint8Array:Array,Ye="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(G=0,Yt=Ye.length;G<Yt;++G)A[G]=Ye[G],F[Ye.charCodeAt(G)]=G;var G,Yt;F[45]=62;F[95]=63;function Zt(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function Ii(i){var e=Zt(i),t=e[0],r=e[1];return(t+r)*3/4-r}function Ti(i,e,t){return(e+t)*3/4-t}function Ri(i){var e,t=Zt(i),r=t[0],n=t[1],s=new Ei(Ti(i,r,n)),a=0,h=n>0?r-4:r,l;for(l=0;l<h;l+=4)e=F[i.charCodeAt(l)]<<18|F[i.charCodeAt(l+1)]<<12|F[i.charCodeAt(l+2)]<<6|F[i.charCodeAt(l+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=e&255;return n===2&&(e=F[i.charCodeAt(l)]<<2|F[i.charCodeAt(l+1)]>>4,s[a++]=e&255),n===1&&(e=F[i.charCodeAt(l)]<<10|F[i.charCodeAt(l+1)]<<4|F[i.charCodeAt(l+2)]>>2,s[a++]=e>>8&255,s[a++]=e&255),s}function vi(i){return A[i>>18&63]+A[i>>12&63]+A[i>>6&63]+A[i&63]}function Pi(i,e,t){for(var r,n=[],s=e;s<t;s+=3)r=(i[s]<<16&16711680)+(i[s+1]<<8&65280)+(i[s+2]&255),n.push(vi(r));return n.join("")}function Fi(i){for(var e,t=i.length,r=t%3,n=[],s=16383,a=0,h=t-r;a<h;a+=s)n.push(Pi(i,a,a+s>h?h:a+s));return r===1?(e=i[t-1],n.push(A[e>>2]+A[e<<4&63]+"==")):r===2&&(e=(i[t-2]<<8)+i[t-1],n.push(A[e>>10]+A[e>>4&63]+A[e<<2&63]+"=")),n.join("")}});var er=W(Ze=>{Ze.read=function(i,e,t,r,n){var s,a,h=n*8-r-1,l=(1<<h)-1,f=l>>1,c=-7,u=t?n-1:0,p=t?-1:1,g=i[e+u];for(u+=p,s=g&(1<<-c)-1,g>>=-c,c+=h;c>0;s=s*256+i[e+u],u+=p,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=r;c>0;a=a*256+i[e+u],u+=p,c-=8);if(s===0)s=1-f;else{if(s===l)return a?NaN:(g?-1:1)*(1/0);a=a+Math.pow(2,r),s=s-f}return(g?-1:1)*a*Math.pow(2,s-r)};Ze.write=function(i,e,t,r,n,s){var a,h,l,f=s*8-n-1,c=(1<<f)-1,u=c>>1,p=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=r?0:s-1,d=r?1:-1,_=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(h=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+u>=1?e+=p/l:e+=p*Math.pow(2,1-u),e*l>=2&&(a++,l/=2),a+u>=c?(h=0,a=c):a+u>=1?(h=(e*l-1)*Math.pow(2,n),a=a+u):(h=e*Math.pow(2,u-1)*Math.pow(2,n),a=0));n>=8;i[t+g]=h&255,g+=d,h/=256,n-=8);for(a=a<<n|h,f+=n;f>0;i[t+g]=a&255,g+=d,a/=256,f-=8);i[t+g-d]|=_*128}});var xr=W(le=>{"use strict";var Ke=Kt(),oe=er(),tr=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;le.Buffer=o;le.SlowBuffer=Li;le.INSPECT_MAX_BYTES=50;var Se=2147483647;le.kMaxLength=Se;o.TYPED_ARRAY_SUPPORT=Bi();!o.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 Bi(){try{let i=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(i,e),i.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}});Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function j(i){if(i>Se)throw new RangeError('The value "'+i+'" is invalid for option "size"');let e=new Uint8Array(i);return Object.setPrototypeOf(e,o.prototype),e}function o(i,e,t){if(typeof i=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return it(i)}return sr(i,e,t)}o.poolSize=8192;function sr(i,e,t){if(typeof i=="string")return Ai(i,e);if(ArrayBuffer.isView(i))return Si(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(S(i,ArrayBuffer)||i&&S(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(S(i,SharedArrayBuffer)||i&&S(i.buffer,SharedArrayBuffer)))return tt(i,e,t);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let r=i.valueOf&&i.valueOf();if(r!=null&&r!==i)return o.from(r,e,t);let n=Ci(i);if(n)return n;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return o.from(i[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}o.from=function(i,e,t){return sr(i,e,t)};Object.setPrototypeOf(o.prototype,Uint8Array.prototype);Object.setPrototypeOf(o,Uint8Array);function ar(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function Ni(i,e,t){return ar(i),i<=0?j(i):e!==void 0?typeof t=="string"?j(i).fill(e,t):j(i).fill(e):j(i)}o.alloc=function(i,e,t){return Ni(i,e,t)};function it(i){return ar(i),j(i<0?0:nt(i)|0)}o.allocUnsafe=function(i){return it(i)};o.allocUnsafeSlow=function(i){return it(i)};function Ai(i,e){if((typeof e!="string"||e==="")&&(e="utf8"),!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=hr(i,e)|0,r=j(t),n=r.write(i,e);return n!==t&&(r=r.slice(0,n)),r}function et(i){let e=i.length<0?0:nt(i.length)|0,t=j(e);for(let r=0;r<e;r+=1)t[r]=i[r]&255;return t}function Si(i){if(S(i,Uint8Array)){let e=new Uint8Array(i);return tt(e.buffer,e.byteOffset,e.byteLength)}return et(i)}function tt(i,e,t){if(e<0||i.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let r;return e===void 0&&t===void 0?r=new Uint8Array(i):t===void 0?r=new Uint8Array(i,e):r=new Uint8Array(i,e,t),Object.setPrototypeOf(r,o.prototype),r}function Ci(i){if(o.isBuffer(i)){let e=nt(i.length)|0,t=j(e);return t.length===0||i.copy(t,0,0,e),t}if(i.length!==void 0)return typeof i.length!="number"||at(i.length)?j(0):et(i);if(i.type==="Buffer"&&Array.isArray(i.data))return et(i.data)}function nt(i){if(i>=Se)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Se.toString(16)+" bytes");return i|0}function Li(i){return+i!=i&&(i=0),o.alloc(+i)}o.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==o.prototype};o.compare=function(e,t){if(S(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),S(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,n=t.length;for(let s=0,a=Math.min(r,n);s<a;++s)if(e[s]!==t[s]){r=e[s],n=t[s];break}return r<n?-1:n<r?1:0};o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};o.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return o.alloc(0);let r;if(t===void 0)for(t=0,r=0;r<e.length;++r)t+=e[r].length;let n=o.allocUnsafe(t),s=0;for(r=0;r<e.length;++r){let a=e[r];if(S(a,Uint8Array))s+a.length>n.length?(o.isBuffer(a)||(a=o.from(a)),a.copy(n,s)):Uint8Array.prototype.set.call(n,a,s);else if(o.isBuffer(a))a.copy(n,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=a.length}return n};function hr(i,e){if(o.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||S(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);let t=i.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&t===0)return 0;let n=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return rt(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return gr(i).length;default:if(n)return r?-1:rt(i).length;e=(""+e).toLowerCase(),n=!0}}o.byteLength=hr;function ji(i,e,t){let r=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(i||(i="utf8");;)switch(i){case"hex":return qi(this,e,t);case"utf8":case"utf-8":return ur(this,e,t);case"ascii":return Vi(this,e,t);case"latin1":case"binary":return Gi(this,e,t);case"base64":return ki(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return zi(this,e,t);default:if(r)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),r=!0}}o.prototype._isBuffer=!0;function q(i,e,t){let r=i[e];i[e]=i[t],i[t]=r}o.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)q(this,t,t+1);return this};o.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)q(this,t,t+3),q(this,t+1,t+2);return this};o.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)q(this,t,t+7),q(this,t+1,t+6),q(this,t+2,t+5),q(this,t+3,t+4);return this};o.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?ur(this,0,e):ji.apply(this,arguments)};o.prototype.toLocaleString=o.prototype.toString;o.prototype.equals=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:o.compare(this,e)===0};o.prototype.inspect=function(){let e="",t=le.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};tr&&(o.prototype[tr]=o.prototype.inspect);o.prototype.compare=function(e,t,r,n,s){if(S(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),r===void 0&&(r=e?e.length:0),n===void 0&&(n=0),s===void 0&&(s=this.length),t<0||r>e.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&t>=r)return 0;if(n>=s)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,s>>>=0,this===e)return 0;let a=s-n,h=r-t,l=Math.min(a,h),f=this.slice(n,s),c=e.slice(t,r);for(let u=0;u<l;++u)if(f[u]!==c[u]){a=f[u],h=c[u];break}return a<h?-1:h<a?1:0};function or(i,e,t,r,n){if(i.length===0)return-1;if(typeof t=="string"?(r=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,at(t)&&(t=n?0:i.length-1),t<0&&(t=i.length+t),t>=i.length){if(n)return-1;t=i.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof e=="string"&&(e=o.from(e,r)),o.isBuffer(e))return e.length===0?-1:rr(i,e,t,r,n);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(i,e,t):Uint8Array.prototype.lastIndexOf.call(i,e,t):rr(i,[e],t,r,n);throw new TypeError("val must be string, number or Buffer")}function rr(i,e,t,r,n){let s=1,a=i.length,h=e.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(i.length<2||e.length<2)return-1;s=2,a/=2,h/=2,t/=2}function l(c,u){return s===1?c[u]:c.readUInt16BE(u*s)}let f;if(n){let c=-1;for(f=t;f<a;f++)if(l(i,f)===l(e,c===-1?0:f-c)){if(c===-1&&(c=f),f-c+1===h)return c*s}else c!==-1&&(f-=f-c),c=-1}else for(t+h>a&&(t=a-h),f=t;f>=0;f--){let c=!0;for(let u=0;u<h;u++)if(l(i,f+u)!==l(e,u)){c=!1;break}if(c)return f}return-1}o.prototype.includes=function(e,t,r){return this.indexOf(e,t,r)!==-1};o.prototype.indexOf=function(e,t,r){return or(this,e,t,r,!0)};o.prototype.lastIndexOf=function(e,t,r){return or(this,e,t,r,!1)};function $i(i,e,t,r){t=Number(t)||0;let n=i.length-t;r?(r=Number(r),r>n&&(r=n)):r=n;let s=e.length;r>s/2&&(r=s/2);let a;for(a=0;a<r;++a){let h=parseInt(e.substr(a*2,2),16);if(at(h))return a;i[t+a]=h}return a}function Di(i,e,t,r){return Ce(rt(e,i.length-t),i,t,r)}function Oi(i,e,t,r){return Ce(Xi(e),i,t,r)}function Mi(i,e,t,r){return Ce(gr(e),i,t,r)}function Ui(i,e,t,r){return Ce(Yi(e,i.length-t),i,t,r)}o.prototype.write=function(e,t,r,n){if(t===void 0)n="utf8",r=this.length,t=0;else if(r===void 0&&typeof t=="string")n=t,r=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(r)?(r=r>>>0,n===void 0&&(n="utf8")):(n=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-t;if((r===void 0||r>s)&&(r=s),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let a=!1;for(;;)switch(n){case"hex":return $i(this,e,t,r);case"utf8":case"utf-8":return Di(this,e,t,r);case"ascii":case"latin1":case"binary":return Oi(this,e,t,r);case"base64":return Mi(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ui(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}};o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ki(i,e,t){return e===0&&t===i.length?Ke.fromByteArray(i):Ke.fromByteArray(i.slice(e,t))}function ur(i,e,t){t=Math.min(i.length,t);let r=[],n=e;for(;n<t;){let s=i[n],a=null,h=s>239?4:s>223?3:s>191?2:1;if(n+h<=t){let l,f,c,u;switch(h){case 1:s<128&&(a=s);break;case 2:l=i[n+1],(l&192)===128&&(u=(s&31)<<6|l&63,u>127&&(a=u));break;case 3:l=i[n+1],f=i[n+2],(l&192)===128&&(f&192)===128&&(u=(s&15)<<12|(l&63)<<6|f&63,u>2047&&(u<55296||u>57343)&&(a=u));break;case 4:l=i[n+1],f=i[n+2],c=i[n+3],(l&192)===128&&(f&192)===128&&(c&192)===128&&(u=(s&15)<<18|(l&63)<<12|(f&63)<<6|c&63,u>65535&&u<1114112&&(a=u))}}a===null?(a=65533,h=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),n+=h}return Qi(r)}var ir=4096;function Qi(i){let e=i.length;if(e<=ir)return String.fromCharCode.apply(String,i);let t="",r=0;for(;r<e;)t+=String.fromCharCode.apply(String,i.slice(r,r+=ir));return t}function Vi(i,e,t){let r="";t=Math.min(i.length,t);for(let n=e;n<t;++n)r+=String.fromCharCode(i[n]&127);return r}function Gi(i,e,t){let r="";t=Math.min(i.length,t);for(let n=e;n<t;++n)r+=String.fromCharCode(i[n]);return r}function qi(i,e,t){let r=i.length;(!e||e<0)&&(e=0),(!t||t<0||t>r)&&(t=r);let n="";for(let s=e;s<t;++s)n+=Zi[i[s]];return n}function zi(i,e,t){let r=i.slice(e,t),n="";for(let s=0;s<r.length-1;s+=2)n+=String.fromCharCode(r[s]+r[s+1]*256);return n}o.prototype.slice=function(e,t){let r=this.length;e=~~e,t=t===void 0?r:~~t,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),t<e&&(t=e);let n=this.subarray(e,t);return Object.setPrototypeOf(n,o.prototype),n};function b(i,e,t){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+e>t)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(e,t,r){e=e>>>0,t=t>>>0,r||b(e,t,this.length);let n=this[e],s=1,a=0;for(;++a<t&&(s*=256);)n+=this[e+a]*s;return n};o.prototype.readUintBE=o.prototype.readUIntBE=function(e,t,r){e=e>>>0,t=t>>>0,r||b(e,t,this.length);let n=this[e+--t],s=1;for(;t>0&&(s*=256);)n+=this[e+--t]*s;return n};o.prototype.readUint8=o.prototype.readUInt8=function(e,t){return e=e>>>0,t||b(e,1,this.length),this[e]};o.prototype.readUint16LE=o.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||b(e,2,this.length),this[e]|this[e+1]<<8};o.prototype.readUint16BE=o.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||b(e,2,this.length),this[e]<<8|this[e+1]};o.prototype.readUint32LE=o.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||b(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};o.prototype.readUint32BE=o.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||b(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};o.prototype.readBigUInt64LE=D(function(e){e=e>>>0,ue(e,"offset");let t=this[e],r=this[e+7];(t===void 0||r===void 0)&&me(e,this.length-8);let n=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+r*2**24;return BigInt(n)+(BigInt(s)<<BigInt(32))});o.prototype.readBigUInt64BE=D(function(e){e=e>>>0,ue(e,"offset");let t=this[e],r=this[e+7];(t===void 0||r===void 0)&&me(e,this.length-8);let n=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+r;return(BigInt(n)<<BigInt(32))+BigInt(s)});o.prototype.readIntLE=function(e,t,r){e=e>>>0,t=t>>>0,r||b(e,t,this.length);let n=this[e],s=1,a=0;for(;++a<t&&(s*=256);)n+=this[e+a]*s;return s*=128,n>=s&&(n-=Math.pow(2,8*t)),n};o.prototype.readIntBE=function(e,t,r){e=e>>>0,t=t>>>0,r||b(e,t,this.length);let n=t,s=1,a=this[e+--n];for(;n>0&&(s*=256);)a+=this[e+--n]*s;return s*=128,a>=s&&(a-=Math.pow(2,8*t)),a};o.prototype.readInt8=function(e,t){return e=e>>>0,t||b(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};o.prototype.readInt16LE=function(e,t){e=e>>>0,t||b(e,2,this.length);let r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};o.prototype.readInt16BE=function(e,t){e=e>>>0,t||b(e,2,this.length);let r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};o.prototype.readInt32LE=function(e,t){return e=e>>>0,t||b(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};o.prototype.readInt32BE=function(e,t){return e=e>>>0,t||b(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};o.prototype.readBigInt64LE=D(function(e){e=e>>>0,ue(e,"offset");let t=this[e],r=this[e+7];(t===void 0||r===void 0)&&me(e,this.length-8);let n=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});o.prototype.readBigInt64BE=D(function(e){e=e>>>0,ue(e,"offset");let t=this[e],r=this[e+7];(t===void 0||r===void 0)&&me(e,this.length-8);let n=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+r)});o.prototype.readFloatLE=function(e,t){return e=e>>>0,t||b(e,4,this.length),oe.read(this,e,!0,23,4)};o.prototype.readFloatBE=function(e,t){return e=e>>>0,t||b(e,4,this.length),oe.read(this,e,!1,23,4)};o.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||b(e,8,this.length),oe.read(this,e,!0,52,8)};o.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||b(e,8,this.length),oe.read(this,e,!1,52,8)};function T(i,e,t,r,n,s){if(!o.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<s)throw new RangeError('"value" argument is out of bounds');if(t+r>i.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t=t>>>0,r=r>>>0,!n){let h=Math.pow(2,8*r)-1;T(this,e,t,r,h,0)}let s=1,a=0;for(this[t]=e&255;++a<r&&(s*=256);)this[t+a]=e/s&255;return t+r};o.prototype.writeUintBE=o.prototype.writeUIntBE=function(e,t,r,n){if(e=+e,t=t>>>0,r=r>>>0,!n){let h=Math.pow(2,8*r)-1;T(this,e,t,r,h,0)}let s=r-1,a=1;for(this[t+s]=e&255;--s>=0&&(a*=256);)this[t+s]=e/a&255;return t+r};o.prototype.writeUint8=o.prototype.writeUInt8=function(e,t,r){return e=+e,t=t>>>0,r||T(this,e,t,1,255,0),this[t]=e&255,t+1};o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(e,t,r){return e=+e,t=t>>>0,r||T(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(e,t,r){return e=+e,t=t>>>0,r||T(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(e,t,r){return e=+e,t=t>>>0,r||T(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(e,t,r){return e=+e,t=t>>>0,r||T(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function lr(i,e,t,r,n){pr(e,r,n,i,t,7);let s=Number(e&BigInt(4294967295));i[t++]=s,s=s>>8,i[t++]=s,s=s>>8,i[t++]=s,s=s>>8,i[t++]=s;let a=Number(e>>BigInt(32)&BigInt(4294967295));return i[t++]=a,a=a>>8,i[t++]=a,a=a>>8,i[t++]=a,a=a>>8,i[t++]=a,t}function cr(i,e,t,r,n){pr(e,r,n,i,t,7);let s=Number(e&BigInt(4294967295));i[t+7]=s,s=s>>8,i[t+6]=s,s=s>>8,i[t+5]=s,s=s>>8,i[t+4]=s;let a=Number(e>>BigInt(32)&BigInt(4294967295));return i[t+3]=a,a=a>>8,i[t+2]=a,a=a>>8,i[t+1]=a,a=a>>8,i[t]=a,t+8}o.prototype.writeBigUInt64LE=D(function(e,t=0){return lr(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});o.prototype.writeBigUInt64BE=D(function(e,t=0){return cr(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});o.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t=t>>>0,!n){let l=Math.pow(2,8*r-1);T(this,e,t,r,l-1,-l)}let s=0,a=1,h=0;for(this[t]=e&255;++s<r&&(a*=256);)e<0&&h===0&&this[t+s-1]!==0&&(h=1),this[t+s]=(e/a>>0)-h&255;return t+r};o.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t=t>>>0,!n){let l=Math.pow(2,8*r-1);T(this,e,t,r,l-1,-l)}let s=r-1,a=1,h=0;for(this[t+s]=e&255;--s>=0&&(a*=256);)e<0&&h===0&&this[t+s+1]!==0&&(h=1),this[t+s]=(e/a>>0)-h&255;return t+r};o.prototype.writeInt8=function(e,t,r){return e=+e,t=t>>>0,r||T(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};o.prototype.writeInt16LE=function(e,t,r){return e=+e,t=t>>>0,r||T(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};o.prototype.writeInt16BE=function(e,t,r){return e=+e,t=t>>>0,r||T(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};o.prototype.writeInt32LE=function(e,t,r){return e=+e,t=t>>>0,r||T(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};o.prototype.writeInt32BE=function(e,t,r){return e=+e,t=t>>>0,r||T(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};o.prototype.writeBigInt64LE=D(function(e,t=0){return lr(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});o.prototype.writeBigInt64BE=D(function(e,t=0){return cr(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function fr(i,e,t,r,n,s){if(t+r>i.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function dr(i,e,t,r,n){return e=+e,t=t>>>0,n||fr(i,e,t,4,34028234663852886e22,-34028234663852886e22),oe.write(i,e,t,r,23,4),t+4}o.prototype.writeFloatLE=function(e,t,r){return dr(this,e,t,!0,r)};o.prototype.writeFloatBE=function(e,t,r){return dr(this,e,t,!1,r)};function _r(i,e,t,r,n){return e=+e,t=t>>>0,n||fr(i,e,t,8,17976931348623157e292,-17976931348623157e292),oe.write(i,e,t,r,52,8),t+8}o.prototype.writeDoubleLE=function(e,t,r){return _r(this,e,t,!0,r)};o.prototype.writeDoubleBE=function(e,t,r){return _r(this,e,t,!1,r)};o.prototype.copy=function(e,t,r,n){if(!o.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);let s=n-r;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),s};o.prototype.fill=function(e,t,r,n){if(typeof e=="string"){if(typeof t=="string"?(n=t,t=0,r=this.length):typeof r=="string"&&(n=r,r=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!o.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(e.length===1){let a=e.charCodeAt(0);(n==="utf8"&&a<128||n==="latin1")&&(e=a)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;t=t>>>0,r=r===void 0?this.length:r>>>0,e||(e=0);let s;if(typeof e=="number")for(s=t;s<r;++s)this[s]=e;else{let a=o.isBuffer(e)?e:o.from(e,n),h=a.length;if(h===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<r-t;++s)this[s+t]=a[s%h]}return this};var he={};function st(i,e,t){he[i]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${i}]`,this.stack,delete this.name}get code(){return i}set code(n){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:n,writable:!0})}toString(){return`${this.name} [${i}]: ${this.message}`}}}st("ERR_BUFFER_OUT_OF_BOUNDS",function(i){return i?`${i} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);st("ERR_INVALID_ARG_TYPE",function(i,e){return`The "${i}" argument must be of type number. Received type ${typeof e}`},TypeError);st("ERR_OUT_OF_RANGE",function(i,e,t){let r=`The value of "${i}" is out of range.`,n=t;return Number.isInteger(t)&&Math.abs(t)>2**32?n=nr(String(t)):typeof t=="bigint"&&(n=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(n=nr(n)),n+="n"),r+=` It must be ${e}. Received ${n}`,r},RangeError);function nr(i){let e="",t=i.length,r=i[0]==="-"?1:0;for(;t>=r+4;t-=3)e=`_${i.slice(t-3,t)}${e}`;return`${i.slice(0,t)}${e}`}function Hi(i,e,t){ue(e,"offset"),(i[e]===void 0||i[e+t]===void 0)&&me(e,i.length-(t+1))}function pr(i,e,t,r,n,s){if(i>t||i<e){let a=typeof e=="bigint"?"n":"",h;throw s>3?e===0||e===BigInt(0)?h=`>= 0${a} and < 2${a} ** ${(s+1)*8}${a}`:h=`>= -(2${a} ** ${(s+1)*8-1}${a}) and < 2 ** ${(s+1)*8-1}${a}`:h=`>= ${e}${a} and <= ${t}${a}`,new he.ERR_OUT_OF_RANGE("value",h,i)}Hi(r,n,s)}function ue(i,e){if(typeof i!="number")throw new he.ERR_INVALID_ARG_TYPE(e,"number",i)}function me(i,e,t){throw Math.floor(i)!==i?(ue(i,t),new he.ERR_OUT_OF_RANGE(t||"offset","an integer",i)):e<0?new he.ERR_BUFFER_OUT_OF_BOUNDS:new he.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,i)}var Wi=/[^+/0-9A-Za-z-_]/g;function Ji(i){if(i=i.split("=")[0],i=i.trim().replace(Wi,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function rt(i,e){e=e||1/0;let t,r=i.length,n=null,s=[];for(let a=0;a<r;++a){if(t=i.charCodeAt(a),t>55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(a+1===r){(e-=3)>-1&&s.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function Xi(i){let e=[];for(let t=0;t<i.length;++t)e.push(i.charCodeAt(t)&255);return e}function Yi(i,e){let t,r,n,s=[];for(let a=0;a<i.length&&!((e-=2)<0);++a)t=i.charCodeAt(a),r=t>>8,n=t%256,s.push(n),s.push(r);return s}function gr(i){return Ke.toByteArray(Ji(i))}function Ce(i,e,t,r){let n;for(n=0;n<r&&!(n+t>=e.length||n>=i.length);++n)e[n+t]=i[n];return n}function S(i,e){return i instanceof e||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===e.name}function at(i){return i!==i}var Zi=(function(){let i="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let r=t*16;for(let n=0;n<16;++n)e[r+n]=i[t]+i[n]}return e})();function D(i){return typeof BigInt>"u"?Ki:i}function Ki(){throw new Error("BigInt not supported")}});var br=W((ht,yr)=>{var Le=xr(),C=Le.Buffer;function mr(i,e){for(var t in i)e[t]=i[t]}C.from&&C.alloc&&C.allocUnsafe&&C.allocUnsafeSlow?yr.exports=Le:(mr(Le,ht),ht.Buffer=z);function z(i,e,t){return C(i,e,t)}z.prototype=Object.create(C.prototype);mr(C,z);z.from=function(i,e,t){if(typeof i=="number")throw new TypeError("Argument must not be a number");return C(i,e,t)};z.alloc=function(i,e,t){if(typeof i!="number")throw new TypeError("Argument must be a number");var r=C(i);return e!==void 0?typeof t=="string"?r.fill(e,t):r.fill(e):r.fill(0),r};z.allocUnsafe=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return C(i)};z.allocUnsafeSlow=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return Le.SlowBuffer(i)}});var Ir=W(Er=>{"use strict";var ut=br().Buffer,wr=ut.isEncoding||function(i){switch(i=""+i,i&&i.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 en(i){if(!i)return"utf8";for(var e;;)switch(i){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 i;default:if(e)return;i=(""+i).toLowerCase(),e=!0}}function tn(i){var e=en(i);if(typeof e!="string"&&(ut.isEncoding===wr||!wr(i)))throw new Error("Unknown encoding: "+i);return e||i}Er.StringDecoder=ye;function ye(i){this.encoding=tn(i);var e;switch(this.encoding){case"utf16le":this.text=on,this.end=un,e=4;break;case"utf8":this.fillLast=sn,e=4;break;case"base64":this.text=ln,this.end=cn,e=3;break;default:this.write=fn,this.end=dn;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=ut.allocUnsafe(e)}ye.prototype.write=function(i){if(i.length===0)return"";var e,t;if(this.lastNeed){if(e=this.fillLast(i),e===void 0)return"";t=this.lastNeed,this.lastNeed=0}else t=0;return t<i.length?e?e+this.text(i,t):this.text(i,t):e||""};ye.prototype.end=hn;ye.prototype.text=an;ye.prototype.fillLast=function(i){if(this.lastNeed<=i.length)return i.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);i.copy(this.lastChar,this.lastTotal-this.lastNeed,0,i.length),this.lastNeed-=i.length};function ot(i){return i<=127?0:i>>5===6?2:i>>4===14?3:i>>3===30?4:i>>6===2?-1:-2}function rn(i,e,t){var r=e.length-1;if(r<t)return 0;var n=ot(e[r]);return n>=0?(n>0&&(i.lastNeed=n-1),n):--r<t||n===-2?0:(n=ot(e[r]),n>=0?(n>0&&(i.lastNeed=n-2),n):--r<t||n===-2?0:(n=ot(e[r]),n>=0?(n>0&&(n===2?n=0:i.lastNeed=n-3),n):0))}function nn(i,e,t){if((e[0]&192)!==128)return i.lastNeed=0,"\uFFFD";if(i.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return i.lastNeed=1,"\uFFFD";if(i.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return i.lastNeed=2,"\uFFFD"}}function sn(i){var e=this.lastTotal-this.lastNeed,t=nn(this,i,e);if(t!==void 0)return t;if(this.lastNeed<=i.length)return i.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);i.copy(this.lastChar,e,0,i.length),this.lastNeed-=i.length}function an(i,e){var t=rn(this,i,e);if(!this.lastNeed)return i.toString("utf8",e);this.lastTotal=t;var r=i.length-(t-this.lastNeed);return i.copy(this.lastChar,0,r),i.toString("utf8",e,r)}function hn(i){var e=i&&i.length?this.write(i):"";return this.lastNeed?e+"\uFFFD":e}function on(i,e){if((i.length-e)%2===0){var t=i.toString("utf16le",e);if(t){var r=t.charCodeAt(t.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=i[i.length-2],this.lastChar[1]=i[i.length-1],t.slice(0,-1)}return t}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=i[i.length-1],i.toString("utf16le",e,i.length-1)}function un(i){var e=i&&i.length?this.write(i):"";if(this.lastNeed){var t=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,t)}return e}function ln(i,e){var t=(i.length-e)%3;return t===0?i.toString("base64",e):(this.lastNeed=3-t,this.lastTotal=3,t===1?this.lastChar[0]=i[i.length-1]:(this.lastChar[0]=i[i.length-2],this.lastChar[1]=i[i.length-1]),i.toString("base64",e,i.length-t))}function cn(i){var e=i&&i.length?this.write(i):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function fn(i){return i.toString(this.encoding)}function dn(i){return i&&i.length?this.write(i):""}});var Xt=ft(It(),1);var O="http://www.w3.org/1999/02/22-rdf-syntax-ns#",X="http://www.w3.org/2001/XMLSchema#",Te="http://www.w3.org/2000/10/swap/",y={xsd:{decimal:`${X}decimal`,boolean:`${X}boolean`,dateTime:`${X}dateTime`,double:`${X}double`,integer:`${X}integer`,string:`${X}string`},rdf:{type:`${O}type`,nil:`${O}nil`,first:`${O}first`,rest:`${O}rest`,langString:`${O}langString`,dirLangString:`${O}dirLangString`,reifies:`${O}reifies`},owl:{sameAs:"http://www.w3.org/2002/07/owl#sameAs"},r:{forSome:`${Te}reify#forSome`,forAll:`${Te}reify#forAll`},log:{implies:`${Te}log#implies`,isImpliedBy:`${Te}log#isImpliedBy`}};var{xsd:Re}=y,Y=32,Z=9,Oe=10,K=13,Pt=35,Qe=46,Ft=58,Mr=48,Ur=57,kr=37,Qr=92;function Bt(i){return i===Y||i>=Z&&i<=K||i>=160&&(i===160||i===5760||i>=8192&&i<=8202||i===8232||i===8233||i===8239||i===8287||i===12288||i===65279)}var Nt=new Uint8Array(128);for(let i of`,;!^#()[]{}"'<>
2
+ \v\f\r`)Nt[i.charCodeAt(0)]=1;function Vr(i){return i<128?Nt[i]===1:Bt(i)}function Gr(i,e,t){let r=i.charCodeAt(e);return r===Qe&&(r=i.charCodeAt(++e)),e>=i.length?t:Vr(r)}var Tt={"\\":"\\","'":"'",'"':'"',n:`
3
+ `,r:"\r",t:" ",f:"\f",b:"\b"},At={_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","'":"'","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},qr=/[\x00-\x20<>\\"\{\}\|\^\`]/,St=1,Ct=2,ve=4,Me=8,Lt=16,de=new Uint8Array(128);for(let i=0;i<128;i++){let e=String.fromCharCode(i),t=e>="A"&&e<="Z"||e>="a"&&e<="z",r=t||e==="_"||e==="-"||e>="0"&&e<="9";de[i]=(t?St:0)|(r&&e!=="-"||e===":"?Ct:0)|(r?ve:0)|(r||e===":"?Me:0)|(e in At?Lt:0)}function Ue(i,e,t){let r=i.charCodeAt(e);if(r<128)return(de[r]&t)!==0?1:0;if(r>=55296&&r<=56191){let n=i.charCodeAt(e+1);return n>=56320&&n<=57343?2:0}return t>=ve&&(r===183||r>=768&&r<=879||r===8255||r===8256)||r>=192&&r<=8191&&r!==215&&r!==247&&(r<768||r>=880&&r!==894)||r>=8204&&r<=8205||r>=8304&&r<=8591||r>=11264&&r<=12271||r>=12289&&r<=55295||r>=63744&&r<=64975||r>=65008&&r<=65533?1:0}function zr(i){return i<128&&(de[i]&Lt)!==0}function Rt(i){return i>=Mr&&i<=Ur||i>=65&&i<=70||i>=97&&i<=102}function ke(i,e){let t=Ue(i,e,St);for(;t!==0;){e+=t;let r=i.charCodeAt(e)===Qe?e+1:e,n=i.charCodeAt(r);t=n<128?(de[n]&ve)!==0?1:0:Ue(i,r,ve),t!==0&&(e=r)}return e}function Hr(i,e){let t=e,r=Ct;for(;;){let n=i.charCodeAt(e),s=n<128?(de[n]&r)!==0?1:0:Ue(i,e,r);if(s===0&&n===kr&&Rt(i.charCodeAt(e+1))&&Rt(i.charCodeAt(e+2))?s=3:s===0&&n===Qr&&zr(i.charCodeAt(e+1))&&(s=2),s!==0)t=e+=s,r=Me;else if(n===Qe&&r===Me)e++;else return t}}function vt(i,e,t){let r=ke(i,e);if(i.charCodeAt(r)!==Ft)return-1;let n=Hr(i,r+1);return Gr(i,n,t)?n:-1}function Wr(i){return i<=1114111&&(i<55296||i>57343)}var Jr={_iri:!0,_unescapedIri:!0,_simpleQuotedString:!0,_langcode:!0,_blank:!0,_commentLine:!0,_whitespace:!0},Xr=/$0^/,Yr=/\S*/y;function w(i,e,t){return i.lastIndex=t,i.exec(e)}function $e(i,e,t){return i.lastIndex=t,i.test(e)}function De(i,e,t){return i.lastIndex=0,i.exec(`${e.slice(t)} `)}function Zr(i){return i===Y||i===Z||i===Oe||i===K||i===Pt}var Kr=/^(?:prefix|base|version|graph|forsome|forall|iri|a|true|false|has|is|of|id)$/i,ei=1024,ee=class{constructor(e){if(this._iri=/<((?:[^ <>{}\\]|\\[uU])+)>[ \t]*/y,this._unescapedIri=/<([^\x00-\x20<>\\"\{\}\|\^\`]*)>[ \t]*/y,this._simpleQuotedString=/"([^"\\\r\n]*)"(?=[^"])/y,this._simpleApostropheString=/'([^'\\\r\n]*)'(?=[^'])/y,this._langcode=/@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9])/iy,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-9: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#()\[\]\{\}"'<>])/y,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#()\[\]\{\}"'<>]))/y,this._number=/[\-+]?(?:(\d+\.\d*|\.?\d+)[eE][\-+]?\d+|(?=\.?\d)\d*(?:(\.)\d+)?)(?=\.?[,;:!\^\s#()\[\]\{\}"'<>])/y,this._boolean=/(?:true|false)(?=[.,;!\^\s#()\[\]\{\}"'<>])/y,this._atKeyword=/@[a-z]+(?=[\s#<:"'.])/iy,this._keyword=/(?:PREFIX|BASE|VERSION|GRAPH)(?=[\s#<"'])/iy,this._n3Verb=/(?:has|is|of)(?=[\s#()\[\]\{\}"'<>?_+\-0-9])/y,this._n3Id=/id(?=[\s#<])/y,this._shortPredicates=/a(?=[\s#()\[\]\{\}"'<>])/y,this._commentLine=/[ \t]*#([^\n\r]*)(?:\r\n|\n|\r)([ \t]*)/y,this._whitespace=/[ \t]+/y,e=e||{},this._isImpliedBy=e.isImpliedBy,this._lineMode=!!e.lineMode){this._n3Mode=!1;for(let t in this)!(t in Jr)&&this[t]instanceof RegExp&&(this[t]=Xr);this._keyword=/VERSION(?=[\s#<"])/y}else this._n3Mode=e.n3!==!1;if(this._directive=null,e.directives&&e.directives.length!==0){for(let t of e.directives)if(!/^[a-z]+$/i.test(t)||Kr.test(t))throw new Error(`Invalid directive name: "${t}"`);this._directive=new RegExp(`(?:${e.directives.join("|")})(?=[\\s#<])`,"iy"),this._directiveMaxLength=Math.max(...e.directives.map(t=>t.length)),this._directiveStarts=e.directives.map(t=>t[0].toLowerCase()+t[0].toUpperCase()).join("")}this.comments=!!e.comments,this._literalClosingPos=0}_tokenizeToEnd(e,t){let r=this._input,n=0,s=this._linePosition+r.length;for(;;){for(;;){let m=r.charCodeAt(n),E=0;if(m===Y||m===Z){let N=r.charCodeAt(n+1);E=N===Y||N===Z?w(this._whitespace,r,n)[0].length:1,m=r.charCodeAt(n+E)}if(m===Pt){let N=w(this._commentLine,r,n);if(N){let fe=N[0].length;if(!t&&n+fe===r.length&&r.charCodeAt(r.length-1)===K)return this._suspend(r,n,s);this.comments&&a(N[1],this._line,s-(r.length-n)+E),n+=fe,s=r.length-n+N[2].length,this._line++}else{if(n+=E,!t)return this._suspend(r,n,s);this.comments&&a(r.slice(n+1),this._line,s-(r.length-n)),n=r.length;break}}else if(m===Oe||m===K){if(!t&&m===K&&n+E+1===r.length)return this._suspend(r,n,s);E+=m===K&&r.charCodeAt(n+E+1)===Oe?2:1;let N=0,fe=r.charCodeAt(n+E);if(fe===Y||fe===Z){let lt=r.charCodeAt(n+E+1);N=lt===Y||lt===Z?w(this._whitespace,r,n+E)[0].length:1}n+=E+N,s=r.length-n+N,this._line++}else{n+=E;break}}if(n>=r.length)return t&&this._previousMarker==="^^"?l(this,r,n):(this._linePosition=s,t?(h("eof","","",this._line,s,0),this._input=null):this._input="");let f=this._line,c=r[n],u="",p="",g="",d=null,_=0,I=0,R=0,v=!1,B=!1;switch(c){case"^":if(this._previousMarker==="^^")return l(this,r,n);if(r.length-n<3)break;if(r[n+1]==="^"){if(this._previousMarker="^^",n+=2,r[n]!=="<"){if(Zr(r.charCodeAt(n)))continue;v=!0;break}}else{this._n3Mode&&(_=1,u="^");break}case"<":if(d=w(this._unescapedIri,r,n))u="IRI",p=d[1],I=d[1].length+2;else if(d=w(this._iri,r,n)){if(p=this._unescape(d[1],Tt),p===null||qr.test(p))return l(this,r,n);u="IRI",I=d[1].length+2}else r.length-n>2&&r[n+1]==="<"&&r[n+2]==="("?(u="<<(",_=3):!this._lineMode&&r.length-n>(t?1:2)&&r[n+1]==="<"?(u="<<",_=2):this._n3Mode&&r.length-n>1&&r[n+1]==="="?(_=2,this._isImpliedBy?(u="abbreviation",p="<"):(u="inverse",p=">")):this._n3Mode&&r.length-n>1&&r[n+1]==="-"&&(u="inversePredicate",_=2);break;case">":r.length-n>1&&r[n+1]===">"&&(u=">>",_=2);break;case"_":((d=w(this._blank,r,n))||t&&(d=De(this._blank,r,n)))&&(u="blank",g="_",p=d[1],I=d[1].length+2);break;case'"':if(d=w(this._simpleQuotedString,r,n))p=d[1];else if({value:p,matchLength:_,finalLineLength:R,tripleQuoted:B}=this._parseLiteral(r,n),p===null)return l(this,r,n);(d!==null||_!==0)&&(u="literal",this._literalClosingPos=0);break;case"'":if(!this._lineMode){if(d=w(this._simpleApostropheString,r,n))p=d[1];else if({value:p,matchLength:_,finalLineLength:R,tripleQuoted:B}=this._parseLiteral(r,n),p===null)return l(this,r,n);(d!==null||_!==0)&&(u="literal",this._literalClosingPos=0)}break;case"?":this._n3Mode&&(d=w(this._variable,r,n))&&(u="var",p=d[0]);break;case"@":if(this._previousMarker==="literal"&&(d=w(this._langcode,r,n))&&d[1]!=="version"){let m=n+d[0].length;!t&&r[m]==="-"&&r[m+1]!=="-"?d=null:(u="langcode",p=d[1])}else(d=w(this._atKeyword,r,n))&&(u=d[0]);break;case".":if(r.length-n===1?t:r[n+1]<"0"||r[n+1]>"9"){u=".",_=1;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":if(r[n+1]==="-"){this._previousMarker==="langcode"&&(r.startsWith("--ltr",n)?(u="dircode",p="ltr",_=5):r.startsWith("--rtl",n)&&(u="dircode",p="rtl",_=5));break}(d=w(this._number,r,n)||t&&(d=De(this._number,r,n)))&&(u="literal",p=d[0],g=typeof d[1]=="string"?Re.double:typeof d[2]=="string"?Re.decimal:Re.integer);break;case"B":case"b":case"p":case"P":case"G":case"g":case"V":case"v":(d=w(this._keyword,r,n))?u=d[0].toUpperCase():v=!0;break;case"f":case"t":$e(this._boolean,r,n)?(u="literal",p=c==="t"?"true":"false",g=Re.boolean,_=p.length):v=!0;break;case"a":$e(this._shortPredicates,r,n)?(u="abbreviation",p="a",_=1):v=!0;break;case"h":case"o":this._n3Mode&&(d=this._matchN3Verb(r,n,t))?u=d[0]:v=!0;break;case"i":this._n3Mode&&$e(this._n3Id,r,n)?(u="id",_=2):this._n3Mode&&(d=this._matchN3Verb(r,n,t))?u=d[0]:v=!0;break;case"=":this._n3Mode&&r.length-n>1&&(u="abbreviation",r[n+1]!==">"?(_=1,p="="):(_=2,p=">"));break;case"!":if(!this._n3Mode)break;case")":if(!t&&(r.length-n===1||r.length-n===2&&r[n+1]===">"))break;if(r.length-n>2&&r[n+1]===">"&&r[n+2]===">"){u=")>>",_=3;break}case",":case";":case"[":case"]":case"(":case"}":case"~":this._lineMode||(_=1,u=c);break;case"{":!this._lineMode&&r.length-n>=2&&(r[n+1]==="|"?(u="{|",_=2):(u=c,_=1));break;case"|":r.length-n>=2&&r[n+1]==="}"&&(u="|}",_=2);break;default:v=!0}if(v){let m;if((this._previousMarker==="@prefix"||this._previousMarker==="PREFIX")&&r.charCodeAt(m=ke(r,n))===Ft&&m+1<r.length&&(r[m+1]==="#"||r[m+1]==="<"||Bt(r.charCodeAt(m+1))))u="prefix",p=r.slice(n,m),_=m+1-n;else if(this._directive!==null&&this._directiveStarts.includes(c)&&((d=w(this._directive,r,n))||t&&r.length-n<=this._directiveMaxLength&&(d=De(this._directive,r,n))))u=d[0].toUpperCase();else if(!this._lineMode&&(m=vt(r,n,t))>=0){let E=r.indexOf(":",n);u="prefixed",g=r.slice(n,E),p=this._unescape(r.slice(E+1,m),At),_=m-n}}if(this._previousMarker==="^^")switch(u){case"prefixed":u="type";break;case"IRI":u="typeIRI";break;default:u=""}if(!u)return t||!r.startsWith("'''",n)&&!r.startsWith('"""',n)&&/\n|\r/.test(r.slice(n))?l(this,r,n):this._suspend(r,n,s);let ce=_||d[0].length,we=s-(r.length-n),H;R?(H={type:u,value:p,prefix:g,line:f,start:we,end:R,endLine:this._line,tripleQuoted:B},e(null,H)):B?(H={type:u,value:p,prefix:g,line:f,start:we,end:we+ce,tripleQuoted:B},e(null,H)):H=h(u,p,g,f,we,I||ce),this.previousToken=H,this._previousMarker=u==="literal"&&(this._previousMarker==="VERSION"||this._previousMarker==="@version")?"version":u,n=Math.min(n+ce,r.length),R&&(s=r.length-n+R)}function a(f,c,u){e(null,{type:"comment",value:f,prefix:"",line:c,start:u,end:u+f.length+1})}function h(f,c,u,p,g,d){let _={type:f,value:c,prefix:u,line:p,start:g,end:g+d};return e(null,_),_}function l(f,c,u){e(f._syntaxError(w(Yr,c,u)[0]))}}_suspend(e,t,r){return this._linePosition=r-(e.length-t),this._input=e.slice(t)}_matchN3Verb(e,t,r){let n=w(this._n3Verb,e,t);if(!n)return null;let s=e[t+n[0].length];return s!=="-"&&s!=="_"&&(s<"0"||s>"9")&&s!=="\u1680"&&s!=="\uFEFF"?n:vt(e,t,!0)>=0||!r&&ke(e,t)===e.length?null:n}_unescape(e,t){let r=e.indexOf("\\");if(r<0)return e;let n="",s=0;for(;r>=0&&r+1<e.length;){let a=e[r+1],h=r+2,l;if(a==="u"||a==="U"){if(h+=a==="u"?4:8,h>e.length)return null;let f=0;for(let c=r+2;c<h;c++){let u=e.charCodeAt(c);if(u>=48&&u<=57)u-=48;else if(u>=65&&u<=70)u-=55;else if(u>=97&&u<=102)u-=87;else return null;f=f*16+u}if(!Wr(f))return null;l=String.fromCodePoint(f)}else{if(!(a in t))return null;l=t[a]}n+=e.slice(s,r)+l,s=h,r=e.indexOf("\\",s)}return n+e.slice(s)}_parseLiteral(e,t){if(e.length-t>=3){let r=e[t],n=e[t+1]===r&&e[t+2]===r?3:1,s=r;n===3&&(s=r==='"'?'"""':"'''");let a=t+Math.max(this._literalClosingPos,n);for(;(a=e.indexOf(s,a))>t;){let h=0;for(;e[a-h-1]==="\\";)h++;if(h%2===0){let l=e.substring(t+n,a),f=l.split(/\r\n|\r|\n/),c=f.length-1,u=a-t+n;if(n===1&&c!==0||n===3&&this._lineMode)break;this._line+=c;let p=c===0?0:f[f.length-1].length+n;return{value:this._unescape(l,Tt),matchLength:u,finalLineLength:p,tripleQuoted:n===3}}a++}this._literalClosingPos=e.length-t-n+1}return{value:"",matchLength:0,finalLineLength:0,tripleQuoted:!1}}_tryTokenizeToEnd(e,t){let r;try{this._tokenizeToEnd((n,s)=>{try{return e(n,s)}catch(a){throw r=a}},t)}catch(n){if(n===r||!(n instanceof RangeError))throw n;e(this._syntaxError(null,`Token too long on line ${this._line}.`))}}_syntaxError(e,t=`Unexpected "${e}" on line ${this._line}.`){this._input=null;let r=new Error(t);return r.context={token:void 0,line:this._line,previousToken:this.previousToken},r}_startTokenization(){return this._line=1,this._linePosition=0,this._previousMarker=void 0,this.previousToken=void 0,this._literalClosingPos=0,this._input=void 0,this._tokenization={}}_tokenizeString(e,t){this._startTokenization(),this._input=this._readStartingBom(e),this._tryTokenizeToEnd(t,!0)}_readStartingBom(e){return e.startsWith("\uFEFF")?(this._linePosition=1,e.slice(1)):e}tokenize(e,t){let r=this._startTokenization();if(typeof e=="string")if(this._input=this._readStartingBom(e),typeof t=="function")queueMicrotask(()=>{this._tokenization===r&&this._tryTokenizeToEnd(t,!0)});else{let n=[],s;if(this._tryTokenizeToEnd((a,h)=>a?s=a:n.push(h),!0),s)throw s;return n}else{let n,s=0;typeof e.setEncoding=="function"&&e.setEncoding("utf8"),e.on("data",a=>{if(this._tokenization===r&&this._input!==null&&a.length!==0){if(typeof a!="string"&&(n=n||new TextDecoder("utf-8",{ignoreBOM:!0}),!(a=n.decode(a,{stream:!0}))))return;typeof this._input>"u"?this._input=this._readStartingBom(a):this._input+=a,this._input.length>=s&&(this._tryTokenizeToEnd(t,!1),s=this._input!==null&&this._input.length>ei?2*this._input.length:0)}}),e.on("end",()=>{if(this._tokenization===r&&this._input!==null){let a=n?n.decode():"";a&&(this._input=typeof this._input=="string"?this._input+a:a),typeof this._input=="string"&&this._tryTokenizeToEnd(t,!0)}}),e.on("error",a=>{this._tokenization===r&&t(a)})}}};var{rdf:jt,xsd:$}=y,pe,ti=0,ri="<>";var ii={namedNode:$t,blankNode:Dt,variable:Mt,literal:Ot,defaultGraph:ni,quad:ze,triple:ze,fromTerm:_e,fromQuad:Ut},M=ii,P=class i{constructor(e){this.id=e}get value(){return this.id}equals(e){return e instanceof i?this.id===e.id&&this.termType===e.termType:!!e&&this.termType===e.termType&&this.value===e.value}hashCode(){return 0}toJSON(){return{termType:this.termType,value:this.value}}},Pe=class extends P{constructor(e){e!==""?super(e):(super(ri),Object.defineProperty(this,"value",{value:""}))}get termType(){return"NamedNode"}},te=class i extends P{constructor(e){super(e)}get termType(){return"Literal"}get value(){return this.id.substring(1,this.id.lastIndexOf('"'))}get language(){let e=this.id,t=e.lastIndexOf('"')+1,r=e.lastIndexOf("--");return t<e.length&&e[t++]==="@"?(r>t?e.substr(0,r):e).substr(t).toLowerCase():""}get direction(){let e=this.id,t=e.lastIndexOf('"'),r=e[t+1]==="@"?e.lastIndexOf("--"):-1;return r>t&&r+2<e.length?e.substr(r+2).toLowerCase():""}get datatype(){return new Pe(this.datatypeString)}get datatypeString(){let e=this.id,t=e.lastIndexOf('"')+1,r=t<e.length?e[t]:"";return r==="^"?e.substr(t+2):r!=="@"?$.string:e.indexOf("--",t)>0?jt.dirLangString:jt.langString}equals(e){return e instanceof i?this.id===e.id:!!e&&!!e.datatype&&this.termType===e.termType&&this.value===e.value&&this.language===e.language&&(this.direction===e.direction||this.direction===""&&!e.direction)&&this.datatype.value===e.datatype.value}toJSON(){return{termType:this.termType,value:this.value,language:this.language,direction:this.direction,datatype:{termType:"NamedNode",value:this.datatypeString}}}},Ve=class extends P{constructor(e){super(`_:${e}`)}get termType(){return"BlankNode"}get value(){return this.id.substr(2)}},Ge=class extends P{constructor(e){super(`?${e}`)}get termType(){return"Variable"}get value(){return this.id.substr(1)}},qe=class extends P{constructor(){return super(""),pe||this}get termType(){return"DefaultGraph"}equals(e){return this===e||!!e&&this.termType===e.termType}};pe=new qe;var Fe=class extends P{constructor(e,t,r,n){super(""),this._subject=e,this._predicate=t,this._object=r,this._graph=n||pe}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 $t(i){return new Pe(i)}function Dt(i){return new Ve(i||`n3-${ti++}`)}function Ot(i,e){if(typeof e=="string")return new te(`"${i}"@${e.toLowerCase()}`);if(e!==void 0&&!("termType"in e))return new te(`"${i}"@${e.language.toLowerCase()}${e.direction?`--${e.direction.toLowerCase()}`:""}`);let t=e?e.value:"";return t===""&&(typeof i=="boolean"?t=$.boolean:typeof i=="number"?Number.isFinite(i)?t=Number.isInteger(i)&&Math.abs(i)<1e21?$.integer:$.double:(t=$.double,Number.isNaN(i)||(i=i>0?"INF":"-INF")):typeof i=="bigint"?t=$.integer:i instanceof Date&&!Number.isNaN(i.getTime())&&(t=$.dateTime,i=i.toISOString())),t===""||t===$.string?new te(`"${i}"`):new te(`"${i}"^^${t}`)}function Mt(i){return new Ge(i)}function ni(){return pe}function ze(i,e,t,r){return new Fe(i,e,t,r)}function _e(i){if(i instanceof P)return i;switch(i.termType){case"NamedNode":return $t(i.value);case"BlankNode":return Dt(i.value);case"Variable":return Mt(i.value);case"DefaultGraph":return pe;case"Literal":return Ot(i.value,i.language?i.direction?{language:i.language,direction:i.direction}:i.language:i.datatype);case"Quad":return Ut(i);default:throw new Error(`Unexpected termType: ${i.termType}`)}}function Ut(i){if(i instanceof Fe)return i;if(i.termType!=="Quad")throw new Error(`Unexpected termType: ${i.termType}`);return ze(_e(i.subject),_e(i.predicate),_e(i.object),_e(i.graph))}var kt=0,Qt=/(^|\/)\.\.?($|[/#?])/,si=/^[^?#]*(?:^|\/)\.\.?(?:$|[/#?])/,L=class i{constructor(e){this._contextStack=[],this._graph=null,e=e||{},this._setBase(e.baseIRI),e.factory&&Gt(this,e.factory);let t=typeof e.format=="string"?e.format.match(/(?:^|\W)(\w*)$/)[1].toLowerCase():"",r=/turtle/.test(t),n=/trig/.test(t),s=/triple/.test(t),a=/quad/.test(t),h=this._n3Mode=/n3/.test(t),l=s||a;if(this._emitCurrent=this._emit,h&&(this._createQuad=this._createQuadInDirection,this._emit=this._emitInDirection,this._emitCurrent=this._emitCurrentInDirection),(this._supportsNamedGraphs=!(r||h))||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(r||n||s||h),this._isImpliedBy=e.isImpliedBy,this._implicitEmptyPrefix=!!e.implicitEmptyPrefix,this._emptyFormulaAsTrue=!!e.emptyFormulaAsTrue,l&&(this._resolveRelativeIRI=c=>null),this._blankNodePrefix=typeof e.blankNodePrefix!="string"?"":e.blankNodePrefix.replace(/^(?!_:)/,"_:"),this._directives=null,e.directives){this._directives=Object.create(null);for(let c of e.directives)this._directives[`@${c.toLowerCase()}`]=this._directives[c.toUpperCase()]=c}this._lexer=e.lexer||new ee({lineMode:l,n3:h,isImpliedBy:this._isImpliedBy,directives:e.directives}),this._explicitQuantifiers=!!e.explicitQuantifiers,this._formulaScopedBlankNodes=!!e.formulaScopedBlankNodes,this._parseUnsupportedVersions=!!e.parseUnsupportedVersions,this._version=e.version;let f=e.maxTripleTermDepth;this._maxTripleTermDepth=f===1/0||Number.isInteger(f)&&f>=0?f:1024}static _resetBlankNodePrefix(){kt=0}_setBase(e){if(!e)this._base="",this._basePath="",this._basePathHasDotSegments=!1;else{let t=e.indexOf("#");t>=0&&(e=e.substr(0,t)),this._base=e;let r=e.indexOf("?"),n=r<0?e:e.substr(0,r);this._basePath=e.indexOf("/")<0?e:n.substr(0,n.lastIndexOf("/")+1);let s=e;e=e.match(/^(?:([a-z][a-z0-9+.-]*:))?(\/\/[^\/?#]*)?/i),this._baseRoot=e[0],this._baseScheme=e[1],e[2]!==void 0&&(s.length===this._baseRoot.length||s[this._baseRoot.length]==="?")&&(this._basePath=`${this._baseRoot}/`),this._basePathHasDotSegments=Qt.test(this._basePath)}}_enterTripleTerm(e,t,r,n){return this._tripleTermDepth>=this._maxTripleTermDepth?(this._error(`Triple terms nested deeper than ${this._maxTripleTermDepth} level${this._maxTripleTermDepth===1?"":"s"}`,n),!1):(this._tripleTermDepth++,this._saveContext(e,this._graph,t,r,null),this._graph=null,!0)}_saveContext(e,t,r,n,s){if(!this._n3Mode){this._contextStack.push({type:e,subject:r,predicate:n,object:s,graph:t});return}let a={type:e,subject:r,predicate:n,object:s,graph:t,inverse:this._inversePredicate,expectOf:this._expectOf,blankPrefix:this._prefixes._,prefixChanges:this._prefixChanges,quantifiedChanges:this._quantifiedChanges,emptyFormula:this._emptyFormula};e==="formula"&&(a.base=[this._base,this._basePath,this._baseRoot,this._baseScheme,this._basePathHasDotSegments],this._prefixChanges=[]),this._contextStack.push(a),this._inversePredicate=!1,this._expectOf=!1,(!this._formulaScopedBlankNodes||e==="formula")&&(this._prefixes._=this._graph?`${this._graph.value}.`:".",this._quantifiedChanges=[]),e==="formula"&&(this._subject=null,this._emptyFormula=!0)}_restoreContext(e,t){let r=this._contextStack.pop();if(!r||r.type!==e)return this._error(`Unexpected ${t.type}`,t);this._subject=r.subject,this._predicate=r.predicate,this._object=r.object,this._graph=r.graph,this._n3Mode&&(this._inversePredicate=r.inverse,this._expectOf=r.expectOf,e==="formula"&&([this._base,this._basePath,this._baseRoot,this._baseScheme,this._basePathHasDotSegments]=r.base),this._prefixChanges!==r.prefixChanges&&(Vt(this._prefixes,this._prefixChanges),this._prefixChanges=r.prefixChanges),this._prefixes._=r.blankPrefix,this._quantifiedChanges!==r.quantifiedChanges&&(Vt(this._quantified,this._quantifiedChanges),this._quantifiedChanges=r.quantifiedChanges),this._emptyFormula=r.emptyFormula)}_readBeforeTopContext(e){return this._version&&!this._isValidVersion(this._version)?this._error(`Detected unsupported version as media type parameter: "${this._version}"`,e):this._readInTopContext(e)}_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"VERSION":this._sparqlStyle=!0;case"@version":return this._readVersion;case"{":if(this._supportsNamedGraphs)return this._graph="",this._subject=null,this._readSubject;case"GRAPH":if(this._supportsNamedGraphs)return this._readNamedGraphLabel;default:return this._directives!==null&&e.type in this._directives&&this._graph===null?(this._sparqlStyle=e.type[0]!=="@",this._directiveCallback(this._directives[e.type]),this._readDeclarationPunctuation):this._readSubject(e)}}_readInFormulaContext(e){switch(e.type){case"PREFIX":this._sparqlStyle=!0;case"@prefix":return this._readPrefix;case"BASE":this._sparqlStyle=!0;case"@base":return this._readBaseIRI;default:return this._readSubject(e)}}_getStatementReader(){let e=this._contextStack[this._contextStack.length-1];return e&&e.type==="formula"?this._readInFormulaContext:this._readInTopContext}_readEntity(e,t){let r;switch(e.type){case"IRI":case"typeIRI":let n=this._resolveIRI(e.value);if(n===null)return this._error("Invalid IRI",e);r=this._factory.namedNode(n);break;case"type":case"prefixed":let s=this._prefixes[e.prefix];if(s===void 0)return this._error(`Undefined prefix "${e.prefix}:"`,e);r=this._factory.namedNode(s+e.value);break;case"blank":r=this._factory.blankNode(this._prefixes[e.prefix]+e.value);break;case"var":r=this._factory.variable(e.value.substr(1));break;default:return this._error(`Expected entity but got ${e.type}`,e)}return!t&&this._n3Mode&&r.id in this._quantified&&(r=this._quantified[r.id]),r}_readList(e,t,r,n){let s=this._contextStack;return(s.length&&s[s.length-1]).type==="<<"?this._error("Unexpected list in reified triple",e):(this._saveContext("list",this._graph,t,r,n),this._subject=null,this._readListItem)}_readSubject(e){switch(this._predicate=null,e.type!=="}"&&(this._emptyFormula=!1),e.type){case"[":return this._saveContext("blank",this._graph,this._subject=this._factory.blankNode(),null,null),this._readBlankNodeHead;case"(":return this._readList(e,this.RDF_NIL,null,null);case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._graph=this._factory.blankNode(),null,null),this._readInFormulaContext):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":return this._n3Mode?e.prefix.length===0?(this._literalValue=e.value,this._completeSubjectLiteral):(this._subject=this._factory.literal(e.value,this._factory.namedNode(e.prefix)),this._getPathReader(this._readPredicateOrNamedGraph)):this._error("Unexpected literal",e);case"<<(":return this._n3Mode?this._enterTripleTerm("<<(",null,null,e)&&this._readSubject:this._error("Disallowed triple term as subject",e);case"<<":return this._enterTripleTerm("<<",null,null,e)&&this._readSubject;default:if((this._subject=this._readEntity(e))===void 0)return;if(this._n3Mode)return this._getPathReader(this._readPredicateOrNamedGraph)}return this._readPredicateOrNamedGraph}_readPredicate(e){let t=e.type,r=!1;switch(t){case"inverse":this._inversePredicate=!0;case"abbreviation":this._predicate=this.ABBREVIATIONS[e.value];break;case"has":return this._readPredicateAfterVerb;case"is":return this._inversePredicate=!0,this._expectOf=!0,this._readPredicateAfterVerb;case"inversePredicate":return this._inversePredicate=!0,this._readPredicateAfterVerb;case"|}":return this._subject=null,this._readAnnotationBlockPunctuation(e);case".":case"]":case"}":return this._predicate===null&&!this._n3Mode?this._error(`Unexpected ${t}`,e):(this._subject=null,t==="]"?this._readBlankNodeTail(e):this._readPunctuation(e));case";":return this._predicate!==null?this._readPredicate:this._error("Expected predicate but got ;",e);case"literal":if(!this._n3Mode)return this._error("Unexpected literal",e);if(e.prefix.length===0)return this._literalValue=e.value,this._completePredicateLiteral;this._predicate=this._factory.literal(e.value,this._factory.namedNode(e.prefix)),r=!0;break;case"(":return this._n3Mode?this._readList(e,this._subject,this.RDF_NIL,null):this._error(`Expected entity but got ${t}`,e);case"[":return this._n3Mode?(this._saveContext("blank",this._graph,this._subject,this._subject=this._factory.blankNode(),null),this._readBlankNodeHead):this._error("Disallowed blank node as predicate",e);case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._graph=this._factory.blankNode(),null),this._readSubject):this._readEntity(e);case"blank":if(!this._n3Mode)return this._error("Disallowed blank node as predicate",e);default:if((this._predicate=this._readEntity(e))===void 0)return;r=this._n3Mode}return this._validAnnotation=!0,r?this._getPathReader(this._readObject,"predicate"):this._readObject}_readPredicateAfterVerb(e){return e.type==="has"||e.type==="is"||e.type==="of"||e.type==="inversePredicate"?this._error(`Expected expression but got ${e.type}`,e):this._readPredicate(e)}_readObject(e){if(this._expectOf)return e.type!=="of"?this._error(`Expected of but got ${e.type}`,e):(this._expectOf=!1,this._readObject);switch(e.type){case"literal":if(e.prefix.length===0)return this._literalValue=e.value,this._readDataTypeOrLang;if(this._object=this._factory.literal(e.value,this._factory.namedNode(e.prefix)),this._n3Mode)return this._getPathReader(this._getContextEndReader());break;case"[":return this._saveContext("blank",this._graph,this._subject,this._predicate,this._subject=this._factory.blankNode()),this._readBlankNodeHead;case"(":return this._readList(e,this._subject,this._predicate,this.RDF_NIL);case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readInFormulaContext):this._error("Unexpected graph",e);case"<<(":return this._enterTripleTerm("<<(",this._subject,this._predicate,e)&&this._readSubject;case"<<":return this._enterTripleTerm("<<",this._subject,this._predicate,e)&&this._readSubject;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){if(e.type==="]")return this._subject=null,this._readBlankNodeTail(e);{let t=this._contextStack;return(t.length>1&&t[t.length-2]).type==="<<"?this._error("Unexpected compound blank node expression in reified triple",e):e.type==="id"?this._readIriPropertyListId:(this._predicate=null,this._readPredicate(e))}}_readIriPropertyListId(e){let t=this._readEntity(e);if(t===void 0)return;if(t.termType!=="NamedNode")return this._error(`Expected IRI after id but got ${e.type}`,e);let r=this._subject;this._subject=t;let n=this._contextStack[this._contextStack.length-1];return n.subject===r&&(n.subject=t),n.predicate===r&&(n.predicate=t),n.object===r&&(n.object=t),this._predicate=null,this._readIriPropertyListPredicate}_readIriPropertyListPredicate(e){return e.type===";"||e.type==="]"||e.type==="."||e.type==="}"?this._error(`Expected predicate but got ${e.type}`,e):this._readPredicate(e)}_readBlankNodeTail(e){if(e.type!=="]")return this._readBlankNodePunctuation(e);this._subject!==null&&this._emitCurrent(this._subject,this._predicate,this._object,this._graph);let t=this._predicate===null;return this._restoreContext("blank",e),this._object!==null?this._getContextEndReader():this._predicate!==null?this._getPathReader(this._readObject,"predicate"):t?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 t=null,r=null,n=this._readListItem,s=this._subject,a=this._contextStack,h=a[a.length-1];switch(e.type){case"[":this._saveContext("blank",this._graph,r=this._factory.blankNode(),this.RDF_FIRST,this._subject=t=this._factory.blankNode()),n=this._readBlankNodeHead;break;case"(":this._saveContext("list",this._graph,r=this._factory.blankNode(),this.RDF_FIRST,this.RDF_NIL),this._subject=null;break;case")":if(this._restoreContext("list",e),a.length!==0&&a[a.length-1].type==="list"){if(this._n3Mode)return s!==null&&this._emit(s,this.RDF_REST,this.RDF_NIL,this._graph),this._saveContext("item",this._graph,this._subject,this._predicate,this._object),this._subject=this._object,this._predicate=null,this._getPathReader(this._readListItem);this._emit(this._subject,this._predicate,this._object,this._graph)}if(this._predicate===null){if(n=this._n3Mode?this._getPathReader(this._readPredicate):this._readPredicate,this._subject===this.RDF_NIL)return n}else if(this._object===null){if(n=this._getPathReader(this._readObject,"predicate"),this._predicate===this.RDF_NIL)return n}else if(n=this._getContextEndReader(),this._n3Mode&&(n=this._getPathReader(n)),this._object===this.RDF_NIL)return n;r=this.RDF_NIL;break;case"literal":e.prefix.length===0?(this._literalValue=e.value,n=this._readListItemDataTypeOrLang):(t=this._factory.literal(e.value,this._factory.namedNode(e.prefix)),n=this._getContextEndReader());break;case"{":return this._n3Mode?(r=this._factory.blankNode(),t=this._factory.blankNode(),s===null?h.predicate===null?h.subject=r:h.object=r:this._emit(s,this.RDF_REST,r,this._graph),this._emit(r,this.RDF_FIRST,t,this._graph),this._saveContext("formula",this._graph,r,this.RDF_FIRST,this._graph=t),this._subject=null,this._readInFormulaContext):this._error("Unexpected graph",e);case"<<(":case"<<":if(!this._enterTripleTerm(e.type,null,null,e))return;n=this._readSubject;break;default:if((t=this._readEntity(e))===void 0)return}if(r===null&&(this._subject=r=this._factory.blankNode()),(e.type==="<<"||e.type==="<<(")&&(a[a.length-1].subject=this._subject),s===null?h.predicate===null?h.subject=r:h.object===null?h.predicate=r:h.object=r:this._emit(s,this.RDF_REST,r,this._graph),t!==null){if(this._n3Mode&&(e.type==="IRI"||e.type==="prefixed"||e.type==="var"||e.type==="blank"||e.type==="literal"))return this._saveContext("item",this._graph,r,this.RDF_FIRST,t),this._subject=t,this._predicate=null,this._getPathReader(this._readListItem);this._emit(r,this.RDF_FIRST,t,this._graph)}return n}_readDataTypeOrLang(e){return this._completeObjectLiteral(e,!1)}_readListItemDataTypeOrLang(e){return this._completeObjectLiteral(e,!0)}_completeLiteral(e,t){let r,n=!1;switch(e.type){case"type":case"typeIRI":let s=this._readEntity(e);if(s===void 0)return;if(s.value===y.rdf.langString||s.value===y.rdf.dirLangString)return this._error("Detected illegal (directional) languaged-tagged string with explicit datatype",e);r=this._factory.literal(this._literalValue,s),e=null;break;case"langcode":if(e.value.split("-").some(a=>a.length>8))return this._error("Detected language tag with subtag longer than 8 characters",e);r=this._factory.literal(this._literalValue,e.value),this._literalLanguage=e.value,e=null,this._literalComponent=t,n=!0;break;default:r=this._factory.literal(this._literalValue)}return{token:e,literal:r,readCb:n}}_readDirCode(e){let t=this._literalComponent,r=this._literalListItem;if(e.type==="dircode"){let n=this._factory.literal(this._literalValue,{language:this._literalLanguage,direction:e.value});t==="subject"?this._subject=n:t==="predicate"?this._predicate=n:this._object=n,this._literalLanguage=void 0,e=null}if(t==="subject"||t==="predicate"){let n=t==="subject"?this._readPredicateOrNamedGraph:this._readObject;return this._getPathEndReader(e,n,t)||n.call(this,e)}return this._completeObjectLiteralPost(e,r)}_completeTermLiteral(e,t){let r=this._completeLiteral(e,t);if(!r)return;let n;if(t==="subject"?(this._subject=r.literal,n=this._readPredicateOrNamedGraph):(this._predicate=r.literal,this._validAnnotation=!0,n=this._readObject),r.readCb)return this._literalListItem=!1,this._readDirCode;let s=this._getPathEndReader(r.token,n,t);return s||n.call(this,r.token)}_completeSubjectLiteral(e){return this._completeTermLiteral(e,"subject")}_completePredicateLiteral(e){return this._completeTermLiteral(e,"predicate")}_completeObjectLiteral(e,t){let r=this._completeLiteral(e,"object");if(r)return this._object=r.literal,r.readCb?(this._literalListItem=t,this._readDirCode):this._completeObjectLiteralPost(r.token,t)}_completeObjectLiteralPost(e,t){return this._n3Mode&&(e===null||e.type==="!"||e.type==="^")?t?(this._saveContext("item",this._graph,this._subject,this.RDF_FIRST,this._object),this._subject=this._object,this._predicate=null,this._getPathEndReader(e,this._readListItem)):this._getPathEndReader(e,this._getContextEndReader()):(t&&this._emit(this._subject,this.RDF_FIRST,this._object,this._graph),e===null?this._getContextEndReader():(this._readCallback=this._getContextEndReader(),this._readCallback(e)))}_readFormulaTail(e){if(e.type!=="}")return this._readPunctuation(e);this._subject!==null&&this._emitCurrent(this._subject,this._predicate,this._object,this._graph);let t=this._graph,r=this._emptyFormula;return this._restoreContext("formula",e),r&&this._emptyFormulaAsTrue&&(this._subject===t?this._subject=this.N3_TRUE:this._predicate===t?this._predicate=this.N3_TRUE:this._object=this.N3_TRUE),this._object!==null?this._getPathReader(this._getContextEndReader(),"object"):this._predicate!==null?this._getPathReader(this._readObject,"predicate"):this._getPathReader(this._readPredicate,"subject")}_readPunctuation(e){let t,r=this._graph,n=this._subject,s=this._inversePredicate;switch(e.type){case"}":if(this._graph===null)return this._error("Unexpected graph closing",e);if(this._n3Mode)return this._readFormulaTail(e);this._graph=null;case".":this._subject=null,this._tripleTerm=null,t=this._getStatementReader(),s&&(this._inversePredicate=!1);break;case";":s&&(this._inversePredicate=!1),t=this._readPredicate;break;case",":t=this._readObject;break;case"~":case"{|":return this._readAnnotationStart(e);case"|}":return this._error("Unexpected annotation syntax closing",e);default:if(this._supportsQuads&&this._graph===null&&(r=this._readEntity(e))!==void 0){t=this._readQuadPunctuation;break}return this._error(`Expected punctuation to follow "${this._object.id}"`,e)}if(n!==null){let a=this._predicate,h=this._object;this._emit(n,a,h,r,s)}return t}_readBlankNodePunctuation(e){let t,r=!1;switch(e.type){case";":r=this._inversePredicate,t=this._readPredicate;break;case",":t=this._readObject;break;case"~":case"{|":return this._readAnnotationStart(e);case"|}":return this._error("Unexpected annotation syntax closing",e);default:return this._error(`Expected punctuation to follow "${this._object.id}"`,e)}return this._emitCurrent(this._subject,this._predicate,this._object,this._graph),r&&(this._inversePredicate=!1),t}_readQuadPunctuation(e){return e.type!=="."?this._error("Expected dot to follow quad",e):this._readInTopContext}_readPrefix(e){return e.type!=="prefix"?this._error("Expected prefix to follow @prefix",e):(this._prefix=e.value,this._readPrefixIRI)}_readPrefixIRI(e){if(e.type!=="IRI")return this._error(`Expected IRI to follow prefix "${this._prefix}:"`,e);let t=this._readEntity(e);return this._prefixChanges!==null&&this._prefixChanges.push(this._prefix,this._prefixes[this._prefix]),this._prefixes[this._prefix]=t.value,this._prefixCallback(this._prefix,t),this._readDeclarationPunctuation}_readBaseIRI(e){let t=e.type==="IRI"&&this._resolveIRI(e.value);return t?(this._setBase(t),this._readDeclarationPunctuation):this._error("Expected valid IRI to follow base declaration",e)}_isValidVersion(e){return this._parseUnsupportedVersions||i.SUPPORTED_VERSIONS.includes(e)}_readVersion(e){return e.type!=="literal"?this._error("Expected literal to follow version declaration",e):e.prefix!==""||e.tripleQuoted?this._error("Version declarations must use single quotes",e):(this._versionCallback(e.value),this._isValidVersion(e.value)?this._readDeclarationPunctuation:this._error(`Detected unsupported version: "${e.value}"`,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._getStatementReader().call(this,e)):e.type!=="."?this._error("Expected declaration to end with a dot",e):this._getStatementReader()}_readQuantifierList(e){let t;switch(e.type){case"IRI":case"prefixed":if((t=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,t,this.QUANTIFIERS_GRAPH)):(this._quantifiedChanges!==null&&this._quantifiedChanges.push(t.id,this._quantified[t.id]),this._quantified[t.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,t){return this._afterPath=e,this._pathPosition=t||(this._predicate===null?"subject":"object"),this._readPath}_getPathEndReader(e,t,r){if(e!==null&&e.type!=="!"&&e.type!=="^")return null;let n=this._getPathReader(t,r);return e===null?n:n.call(this,e)}_readPath(e){switch(e.type){case"!":return this._readForwardPath;case"^":return this._readBackwardPath;default:let t=this._afterPath,r=this._contextStack,n=r.length&&r[r.length-1];if(n&&n.type==="item"){let s=this._subject;this._restoreContext("item",e),this._emit(this._subject,this.RDF_FIRST,s,this._graph)}return this._afterPath=null,this._pathPosition=null,t.call(this,e)}}_readForwardPath(e){let t,r,n=this._factory.blankNode();if((r=this._readEntity(e))!==void 0)return this._pathPosition==="subject"?(t=this._subject,this._subject=n):this._pathPosition==="predicate"?(t=this._predicate,this._predicate=n):(t=this._object,this._object=n),this._emit(t,r,n,this._graph),this._readPath}_readBackwardPath(e){let t=this._factory.blankNode(),r,n;if((r=this._readEntity(e))!==void 0)return this._pathPosition==="subject"?(n=this._subject,this._subject=t):this._pathPosition==="predicate"?(n=this._predicate,this._predicate=t):(n=this._object,this._object=t),this._emit(t,r,n,this._graph),this._readPath}_readTripleTermTail(e){if(e.type!==")>>")return this._error(`Expected )>> but got ${e.type}`,e);let t=this._createQuad(this._subject,this._predicate,this._object,this._graph,this._inversePredicate);this._restoreContext("<<(",e),this._tripleTermDepth--;let r=this._contextStack,n=r.length&&r[r.length-1];return n&&n.type==="list"?(this._emit(this._subject,this.RDF_FIRST,t,this._graph),this._getContextEndReader()):this._subject===null?(this._subject=t,this._readPredicate):(this._object=t,this._getContextEndReader())}_readReifiedTripleTailOrReifier(e){return e.type==="~"?this._readReifier:this._readReifiedTripleTail(e)}_readReifiedTripleTail(e){if(e.type!==">>")return this._error(`Expected >> but got ${e.type}`,e);this._tripleTerm=null;let t=this._readTripleTerm();this._restoreContext("<<",e),this._tripleTermDepth--;let r=this._contextStack,n=r.length&&r[r.length-1];return n&&n.type==="list"?(this._emit(this._subject,this.RDF_FIRST,t,this._graph),this._getContextEndReader()):this._subject===null?(this._subject=t,this._readPredicateOrReifierTripleEnd):(this._object=t,this._getContextEndReader())}_readPredicateOrReifierTripleEnd(e){return e.type==="."?(this._subject=null,this._readPunctuation(e)):this._readPredicate(e)}_readReifier(e){return e.type===">>"?this._readReifiedTripleTail(e):(this._reifier=this._readEntity(e),this._readReifiedTripleTail)}_readAnnotationStart(e){return this._emitCurrent(this._subject,this._predicate,this._object,this._graph),this._tripleTerm=null,this._readAnnotation(e)}_readAnnotation(e){switch(e.type){case"~":return this._readReifierInAnnotation;case"{|":return this._readAnnotationBlockHead(e)}switch(this._tripleTerm=null,e.type){case";":return this._inversePredicate=!1,this._readPredicate;case",":return this._readObject;default:return this._subject=null,this._getContextEndReader().call(this,e)}}_readReifierInAnnotation(e){switch(e.type){case"IRI":case"typeIRI":case"type":case"prefixed":case"blank":case"var":return this._reifier=this._readEntity(e),this._readAnnotationBlockOrReifier}return this._reifier=this._factory.blankNode(),this._readAnnotationBlockOrReifier(e)}_readAnnotationBlockOrReifier(e){return e.type==="{|"?this._readAnnotationBlockHead(e):(this._readTripleTerm(),this._readAnnotation(e))}_readAnnotationBlockHead(e){let t=this._readTripleTerm();return this._saveContext("annotation",this._graph,this._subject,this._predicate,this._object),this._contextStack[this._contextStack.length-1].tripleTerm=this._tripleTerm,this._subject=t,this._predicate=this._object=this._tripleTerm=null,this._inversePredicate=!1,this._validAnnotation=!1,this._readPredicate}_readAnnotationBlockPunctuation(e){let t=this._contextStack;if(e.type==="|}"){if(!t.length||t[t.length-1].type!=="annotation")return this._error("Unexpected annotation syntax closing",e);if(!this._validAnnotation)return this._error("Annotation block can not be empty",e);this._subject!==null&&this._emitCurrent(this._subject,this._predicate,this._object,this._graph);let{tripleTerm:r}=t[t.length-1];return this._restoreContext("annotation",e),this._tripleTerm=r,this._readAnnotation}return this._readBlankNodePunctuation(e)}_readTripleTerm(){let e=this._contextStack,t=e.length&&e[e.length-1],r=t?t.graph:void 0,n=this._reifier||this._factory.blankNode();return this._reifier=null,this._tripleTerm=this._tripleTerm||this._createQuad(this._subject,this._predicate,this._object,null,this._inversePredicate),this._emit(n,this.RDF_REIFIES,this._tripleTerm,r||this._graph||this.DEFAULTGRAPH),n}_getContextEndReader(){let e=this._contextStack;if(!e.length)return this._readPunctuation;switch(e[e.length-1].type){case"blank":return this._readBlankNodeTail;case"list":return this._readListItem;case"formula":return this._readFormulaTail;case"<<(":return this._readTripleTermTail;case"<<":return this._readReifiedTripleTailOrReifier;case"annotation":return this._readAnnotationBlockPunctuation}}_createQuad(e,t,r,n){return this._factory.quad(e,t,r,n||this.DEFAULTGRAPH)}_createQuadInDirection(e,t,r,n,s){return s?this._factory.quad(r,t,e,n||this.DEFAULTGRAPH):this._factory.quad(e,t,r,n||this.DEFAULTGRAPH)}_emitInDirection(e,t,r,n,s){this._callback(null,this._createQuad(e,t,r,n,s))}_emitCurrentInDirection(e,t,r,n){this._callback(null,this._createQuad(e,t,r,n,this._inversePredicate))}_emit(e,t,r,n){this._callback(null,this._factory.quad(e,t,r,n||this.DEFAULTGRAPH))}_error(e,t){let r=` on line ${t.line}.`;e.length+r.length>200&&(e=`${e.slice(0,199-r.length)}\u2026`);let n=new Error(`${e}${r}`);n.context={token:t,line:t.line,previousToken:this._lexer.previousToken},this._callback(n),this._callback=re}_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"?":{let t=this._base.indexOf("?");return(t<0?this._base:this._base.substr(0,t))+e}case"/":return e[1]!=="/"?this._baseRoot+this._removeDotSegments(e):this._baseScheme?this._removeDotSegments(this._baseScheme+e):this._removeDotSegments(`:${e}`).substr(1);default:return/^[^/:]*:/.test(e)?null:this._basePathHasDotSegments||si.test(e)?this._removeDotSegments(this._basePath+e):this._basePath+e}}_removeDotSegments(e){if(!Qt.test(e))return e;let t=e.length,r="",n=-1,s=-1,a=0,h="/";for(;n<t;){switch(h){case":":if(s<0&&e[++n]==="/"&&e[++n]==="/")for(;(s=n+1)<t&&e[s]!=="/"&&e[s]!=="?"&&e[s]!=="#";)n=s;break;case"?":case"#":n=t;break;case"/":if(e[n+1]===".")switch(h=e[++n+1],h){case"/":r+=e.substring(a,n-1),a=n+1;break;case void 0:case"?":case"#":return r+e.substring(a,n)+e.substr(n+1);case".":if(h=e[++n+1],h===void 0||h==="/"||h==="?"||h==="#"){if(r+=e.substring(a,n-2),(a=r.lastIndexOf("/"))>=s&&(r=r.substr(0,a)),h!=="/")return`${r}/${e.substr(n+1)}`;a=n+1}}}h=e[++n]}return r+e.substring(a)}parse(e,t,r,n){let s,a,h,l,f,c,u;t&&(t.onQuad||t.onPrefix||t.onComment||t.onVersion||t.onDirective||t.onToken||t.onTokenEnd)?(s=t.onQuad,a=t.onPrefix,h=t.onComment,l=t.onVersion,f=t.onDirective,c=t.onToken,u=t.onTokenEnd):(s=t,a=r,l=n),this._readCallback=this._readBeforeTopContext,this._contextStack=[],this._graph=this._subject=this._predicate=this._object=null,this._tripleTerm=this._reifier=null,this._sparqlStyle=!1,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix?this._blankNodePrefix.substr(2):`b${kt++}_`,this._n3Mode&&this._implicitEmptyPrefix&&this._base&&(this._prefixes[""]=this._resolveIRI("#")),this._prefixCallback=a||re,this._versionCallback=l||re,this._directiveCallback=f||re,this._inversePredicate=!1,this._expectOf=!1,this._quantified=Object.create(null),this._prefixChanges=null,this._quantifiedChanges=null,this._emptyFormula=!1,this._tripleTermDepth=0;let p=_=>this._readCallback=this._readCallback(_),g=p;if((h||this._lexer.comments)&&(this._lexer.comments=!0,g=_=>_.type!=="comment"?p(_):(h&&h(_.value),this._readCallback)),c||u){let _=g;g=I=>{try{try{return c&&c(I),_(I)}finally{u&&u(I)}}catch(R){throw this._readCallback=null,R}}}if(!s){let _=[],I;this._callback=(v,B)=>{v?I=v:B&&_.push(B)};let R=this._lexer;if(!a&&!l&&!f&&!h&&!c&&!u&&R.tokenize===ee.prototype.tokenize&&typeof R._tokenizeString=="function"){let v=[this._base,this._basePath,this._baseRoot,this._baseScheme];R._tokenizeString(e,(B,ce)=>{B?([this._base,this._basePath,this._baseRoot,this._baseScheme]=v,this._callback(B),this._callback=re):this._readCallback&&g(ce)})}else R.tokenize(e).every(g);if(I)throw I;return _}let d=(_,I)=>{_!==null?(this._callback(_),this._callback=re):this._readCallback&&g(I)};this._callback=s,this._lexer.tokenize(e,d)}};function Vt(i,e){for(let t=e.length-2;t>=0;t-=2)e[t+1]===void 0?delete i[e[t]]:i[e[t]]=e[t+1]}function re(){}function Gt(i,e){i._factory=e,i.DEFAULTGRAPH=e.defaultGraph(),i.RDF_FIRST=e.namedNode(y.rdf.first),i.RDF_REST=e.namedNode(y.rdf.rest),i.RDF_NIL=e.namedNode(y.rdf.nil),i.RDF_REIFIES=e.namedNode(y.rdf.reifies),i.N3_FORALL=e.namedNode(y.r.forAll),i.N3_FORSOME=e.namedNode(y.r.forSome),i.N3_TRUE=e.literal("true",e.namedNode(y.xsd.boolean)),i.ABBREVIATIONS={a:e.namedNode(y.rdf.type),"=":e.namedNode(y.owl.sameAs),">":e.namedNode(y.log.implies),"<":e.namedNode(y.log.isImpliedBy)},i.QUANTIFIERS_GRAPH=e.namedNode("urn:n3:quantifiers")}L.SUPPORTED_VERSIONS=["1.2","1.2-basic","1.1"];Gt(L.prototype,M);function He(i){return!!i&&i.termType==="DefaultGraph"}function U(i){return i.replace(/[.*+?^${}()|[\]\\/-]/g,"\\$&")}var ai=/^:?[^:?#]*(?:[?#]|$)|^file:|^[^:]*:\/*[^?#]+?\/(?:\.\.?(?:\/|$)|\/)/i,hi=/^(?:(?!\.\.?(?:[/?#]|$))[^/?#]+(?:\/[^/?#]{3,})*\/?)?(?:[?#]|$)/,qt="./",oi="../",We="?",zt="#",ge=class i{constructor(e){this.base=e,this._baseLength=0,this._baseMatcher=null,this._pathReplacements=new Array(e.length+1)}static supports(e){return!ai.test(e)}_getBaseMatcher(){if(this._baseMatcher)return this._baseMatcher;if(!i.supports(this.base))return this._baseMatcher=/.^/;let e=/^[^:]*:\/*/.exec(this.base)[0],t=["^",U(e)],r=[],n=[],s=/[^/?#]*([/?#])/y,a,h=0,l=0,f=s.lastIndex=e.length;for(;!h&&!l&&(a=s.exec(this.base));)a[1]===zt?l=s.lastIndex-1:(t.push(U(a[0]),"(?:"),r.push(")?"),a[1]!==We?n.push(f=s.lastIndex):(h=f=s.lastIndex,l=this.base.indexOf(zt,h),this._pathReplacements[h]=We));for(let c=0;c<n.length;c++)this._pathReplacements[n[c]]=oi.repeat(n.length-c-1);return this._pathReplacements[n[n.length-1]]=qt,this._baseLength=l>0?l:this.base.length,t.push(U(this.base.substring(f,this._baseLength)),h?"(?:#|$)":"(?:[?#]|$)"),this._baseMatcher=new RegExp([...t,...r].join(""))}toRelative(e){let t=this._getBaseMatcher().exec(e);if(!t)return e;let r=t[0].length;if(r===this._baseLength&&r===e.length)return"";let n=this._pathReplacements[r];if(n){let s=e.substring(r);return n!==We&&!hi.test(s)?e:n===qt&&/^[^?#]/.test(s)&&(s.indexOf(":")<0||!/^[^/?#]*:/.test(s))?s:n+s}return e.substring(r-1)}};var ie=M.defaultGraph(),{rdf:ui,xsd:ne}=y,{hasOwnProperty:li}=Object.prototype,ci=/["\\\t\n\r\b\f\u0000-\u0019\ud800-\udbff]/,fi=/["\\\t\n\r\b\f\u0000-\u0019]|[\ud800-\udbff][\udc00-\udfff]/g,di=/[^ !#-\[\]-~\u0080-\uFFFD]/,_i=/[^ !#-\[\]-~\u0080-\uFFFD]/g,Wt={"\\":"\\\\",'"':'\\"'," ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"},pi=/["\\\u0000-\u001f\u007f]|[\ud800-\udbff](?![\udc00-\udfff])|(?:^|[^\ud800-\udbff])[\udc00-\udfff]/,Jt="A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD_:0-9",Ht=`${Jt}\\-\\u00B7\\u0300-\\u036F\\u203F\\u2040`,Je="%[0-9A-Fa-f]{2}",gi=new RegExp(`^(?:(?:[${Jt}]|${Je})(?:(?:[${Ht}.]|${Je})*(?:[${Ht}]|${Je}))?)?$`),k=class extends P{equals(e){return e===this}},se=class{constructor(e,t){if(this._prefixRegex=/$0^/,this._hasPrefixes=!1,e&&typeof e.write!="function"&&(t=e,e=null),t=t||{},this._lists=t.lists,e)this._outputStream=e,this._endStream=t.end===void 0?!0:!!t.end;else{let r="";this._outputStream={write(n,s,a){r+=n,a&&a()},end:n=>{n&&n(null,r)}},this._endStream=!0}if(t.version&&pi.test(t.version))throw new Error(`Invalid version label: ${JSON.stringify(t.version)}`);this._subject=null,/triple|quad/i.test(t.format)?(this._lineMode=!0,this._writeQuad=this._writeQuadLine,this._escape=di,this._escapeAll=_i,this._characterReplacer=mi,t.version&&this._write(`VERSION "${t.version}"
4
+ `)):(this._lineMode=!1,this._escape=ci,this._escapeAll=fi,this._characterReplacer=xi,this._graph=ie,t.version&&this._write(`@version "${t.version}".
5
+ `),this._prefixIRIs=Object.create(null),this._prefixPatterns=Object.create(null),t.baseIRI&&(this._baseIri=new ge(t.baseIRI),t.writeBase&&this._write(`@base <${t.baseIRI}>.
6
+ `)),t.prefixes&&this.addPrefixes(t.prefixes))}get _inDefaultGraph(){return ie.equals(this._graph)}_write(e,t){this._outputStream.write(e,"utf8",t)}_endStatement(){this._subject!==null&&(this._write(this._inDefaultGraph?`.
7
+ `:`
8
+ }
9
+ `),this._subject=null,this._graph=ie)}_writeQuad(e,t,r,n,s){try{n!==this._graph&&(!n.equals(this._graph)||n.termType!==this._graph.termType)&&(this._write((this._subject===null?"":this._inDefaultGraph?`.
10
+ `:`
11
+ }
12
+ `)+(ie.equals(n)?"":`${this._encodeIriOrBlank(n)} {
13
+ `)),this._graph=n,this._subject=null),e===this._subject||e.equals(this._subject)?t===this._predicate||t.equals(this._predicate)?this._write(`, ${this._encodeObject(r)}`,s):this._write(`;
14
+ ${this._encodePredicate(this._predicate=t)} ${this._encodeObject(r)}`,s):this._write(`${(this._subject===null?"":`.
15
+ `)+this._encodeSubject(this._subject=e)} ${this._encodePredicate(this._predicate=t)} ${this._encodeObject(r)}`,s)}catch(a){s&&s(a)}}_writeQuadLine(e,t,r,n,s){delete this._prefixMatch,this._write(this.quadToString(e,t,r,n),s)}quadToString(e,t,r,n){return`${this._encodeSubject(e)} ${t.termType==="Literal"?this._encodeLiteral(t):this._encodeIriOrBlank(t)} ${this._encodeObject(r)}${n&&!He(n)?` ${this._encodeIriOrBlank(n)} .
16
+ `:` .
17
+ `}`}quadsToString(e){let t="";for(let r of e)t+=this.quadToString(r.subject,r.predicate,r.object,r.graph);return t}_encodeSubject(e){switch(e.termType){case"Quad":return this._encodeQuad(e);case"Literal":return this._encodeLiteral(e);default:return this._encodeIriOrBlank(e)}}_encodeIriOrBlank(e){if(e.termType!=="NamedNode")return this._lists&&li.call(this._lists,e.value)&&(e=this.list(this._lists[e.value])),e instanceof P?e.id:e.termType==="Variable"?`?${e.value}`:`_:${e.value}`;let t=e.value;this._baseIri&&(t=this._baseIri.toRelative(t)),this._escape.test(t)&&(t=t.replace(this._escapeAll,this._characterReplacer));let r=this._hasPrefixes?(this._prefixRegex||this._createPrefixRegex()).exec(t):null;return r?r[1]?this._prefixIRIs[r[1]]+r[2]:gi.test(t.slice(r[0].length))?t:`<${t}>`:`<${t}>`}_encodeLiteral(e){let t=e.value;this._escape.test(t)&&(t=t.replace(this._escapeAll,this._characterReplacer));let r=e.language;if(r){let n=e.direction,s=n?`--${n}`:"";return`"${t}"@${r}${s}`}if(this._lineMode){if(e.datatype.value===ne.string)return`"${t}"`}else switch(e.datatype.value){case ne.string:return`"${t}"`;case ne.boolean:if(t==="true"||t==="false")return t;break;case ne.integer:if(/^[+-]?\d+$/.test(t))return t;break;case ne.decimal:if(/^[+-]?\d*\.\d+$/.test(t))return t;break;case ne.double:if(/^[+-]?(?:\d+\.\d*|\.?\d+)[eE][+-]?\d+$/.test(t))return t;break}return`"${t}"^^${this._encodeIriOrBlank(e.datatype)}`}_encodePredicate(e){switch(e.termType){case"NamedNode":return e.value===ui.type?"a":this._encodeIriOrBlank(e);case"Literal":return this._encodeLiteral(e);default:return 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:t,object:r,graph:n}){let s=this._lineMode?" ":"";return`<<(${s}${this._encodeSubject(e)} ${this._encodePredicate(t)} ${this._encodeObject(r)}${He(n)?"":` ${this._encodeIriOrBlank(n)}`}${s})>>`}_blockedWrite(){throw new Error("Cannot write because the writer has been closed.")}addQuad(e,t,r,n,s){r===void 0?this._writeQuad(e.subject,e.predicate,e.object,e.graph,t):typeof n=="function"?this._writeQuad(e,t,r,ie,n):this._writeQuad(e,t,r,n||ie,s)}addQuads(e){for(let t=0;t<e.length;t++)this.addQuad(e[t])}addPrefix(e,t,r){let n={};n[e]=t,this.addPrefixes(n,r)}addPrefixes(e,t){if(!this._prefixIRIs)return t&&t();let r=!1;for(let n in e){let s=e[n];typeof s!="string"&&(s=s.value),r=!0,this._endStatement(),this._prefixIRIs[s]=n+=":",this._prefixPatterns[s]=[U(s),U(n)],this._write(`@prefix ${n} <${s}>.
18
+ `)}r&&(this._hasPrefixes=!0,this._prefixRegex=null),this._write(r?`
19
+ `:"",t)}_createPrefixRegex(){let e="",t="";for(let r in this._prefixPatterns){let[n,s]=this._prefixPatterns[r];e+=e?`|${n}`:n,t+=t?`|${s}`:s}return this._prefixRegex=new RegExp(`^(${e})([_a-zA-Z0-9](?:\\.?[\\-_a-zA-Z0-9])*)$|^(?:${t})`)}blank(e,t){let r=e,n,s;switch(e===void 0?r=[]:e.termType?r=[{predicate:e,object:t}]:"length"in e||(r=[e]),s=r.length){case 0:return new k("[]");case 1:if(n=r[0],!(n.object instanceof k))return new k(`[ ${this._encodePredicate(n.predicate)} ${this._encodeObject(n.object)} ]`);default:let a="[";for(let h=0;h<s;h++)n=r[h],n.predicate.equals(e)?a+=`, ${this._encodeObject(n.object)}`:(a+=`${(h?`;
20
+ `:`
21
+ `)+this._encodePredicate(n.predicate)} ${this._encodeObject(n.object)}`,e=n.predicate);return new k(`${a}
22
+ ]`)}}list(e){let t=e&&e.length||0,r=new Array(t);for(let n=0;n<t;n++)r[n]=this._encodeObject(e[n]);return new k(`(${r.join(" ")})`)}end(e){this._endStatement(),this._write=this._blockedWrite;let t=e&&((r,n)=>{t=null,e(r,n)});if(this._endStream)try{return this._outputStream.end(t)}catch{}t&&t()}};function xi(i){let e=Wt[i];return e===void 0&&(i.length===1?(e=i.charCodeAt(0).toString(16),e="\\u0000".substr(0,6-e.length)+e):(e=((i.charCodeAt(0)-55296)*1024+i.charCodeAt(1)+9216).toString(16),e="\\U00000000".substr(0,10-e.length)+e)),e}function mi(i){let e=Wt[i];return e===void 0&&(e=i.charCodeAt(0).toString(16).toUpperCase(),e="\\u0000".substr(0,6-e.length)+e),e}var yi={turtle:{name:"Turtle",lineMode:!1},trig:{name:"TriG",lineMode:!1},ntriples:{name:"N-Triples",lineMode:!0},nquads:{name:"N-Quads",lineMode:!0}},bi=["1.2","1.2-basic","1.1"];function Be(i="TriG"){let e=String(i).toLowerCase().replace(/;[\s\S]*$/,"").trim().replace(/^(?:text|application)\//,"").replace(/^x-/,"").replace(/[-_ ]/g,""),t=yi[e];if(!t)throw new TypeError(`Unsupported RDF Messages format: "${i}". Supported formats are Turtle, TriG, N-Triples and N-Quads.`);return t}function ae(i){return typeof i=="string"&&i.endsWith("-messages")}function xe(i){return ae(i)?i.slice(0,-9):i}function Ne(i,e=bi){return e.includes(i)}var Q=class{constructor(e,t){e=e||{};let r=Be(e.format);this._sink=t,this._factory=e.factory||M,this._blankNodePrefix=typeof e.blankNodePrefix=="string"?e.blankNodePrefix.replace(/^_:/,""):void 0,this._blankNodeCounter=0,this._supportedVersions=L.SUPPORTED_VERSIONS,this._messages=e.messages===!0||ae(e.version),this._index=0,this._current=null,this._scope=null,this._seenQuad=!1,this._failed=!1,this._finished=!1;let n={format:r.name,factory:this._factory,parseUnsupportedVersions:!0,directives:["message"]};e.baseIRI&&(n.baseIRI=e.baseIRI),e.version&&(this._checkVersion(e.version,!0),n.version=xe(e.version)),this._input=new Xt.EventEmitter,this._lineMode=r.lineMode,this._line=0,this._delimiterLine=0,new L(n).parse(this._input,{onQuad:(s,a,h)=>this._onQuad(s,a,h),onPrefix:(s,a)=>this._failed||t.prefix&&t.prefix(s,a),onVersion:s=>this._failed||this._announce(s),onDirective:()=>this._failed||this._delimiter(),onToken:s=>this._onToken(s)})}write(e){!this._failed&&!this._finished&&e.length>0&&this._input.emit("data",e)}end(){!this._failed&&!this._finished&&this._input.emit("end")}_onToken(e){let t=e.line,r=e.type==="MESSAGE";this._lineMode&&!this._failed&&(r?t===this._line:t===this._delimiterLine&&e.type!=="eof")&&this._fail(new Error(`Unexpected "MESSAGE" on line ${t}.`)),r&&(this._delimiterLine=t),this._line=t}_onQuad(e,t,r){this._failed||this._finished||(e?this._fail(e):t?this._addQuad(t):(this._finished=!0,this._current!==null&&this._emitMessage(),this._sink.end(r)))}_addQuad(e){this._seenQuad=!0,this._messages&&(e=this._scopeQuad(e)),this._current===null&&(this._current=[]),this._current.push(e),this._sink.quad&&this._sink.quad(e,this._index)}_announce(e){let t=this._checkVersion(e);if(t)return this._fail(t);if(ae(e)&&!this._messages){if(this._seenQuad)return this._fail(new Error(`Version "${e}" must be announced before the first statement.`));this._messages=!0}this._sink.version&&this._sink.version(e)}_checkVersion(e,t){if(Ne(xe(e),this._supportedVersions))return null;let r=new Error(`Detected unsupported version: "${e}"`);if(t)throw r;return r}_delimiter(){if(!this._messages)return this._fail(new Error(`Unexpected "MESSAGE" on line ${this._line}: the document did not announce a version with the "-messages" suffix.`));this._emitMessage()}_emitMessage(){let e=this._current||[];this._current=null,this._scope=null,this._sink.message(e,this._index++)}_fail(e){this._failed=!0,this._current=null,this._sink.error(e)}_scopeQuad(e){let t=this._scopeTerm(e.subject),r=this._scopeTerm(e.predicate),n=this._scopeTerm(e.object),s=this._scopeTerm(e.graph);return t===e.subject&&r===e.predicate&&n===e.object&&s===e.graph?e:this._factory.quad(t,r,n,s)}_scopeTerm(e){if(e.termType==="BlankNode"){let t=this._scope||(this._scope=new Map),r=t.get(e.value);return r||(r=this._blankNodePrefix===void 0?this._factory.blankNode():this._factory.blankNode(`${this._blankNodePrefix}${this._blankNodeCounter++}`),t.set(e.value,r)),r}return e.termType==="Quad"?this._scopeQuad(e):e}};var Xe=class extends se{addDelimiter(){this._endStatement(),this._write(this._lineMode?`MESSAGE
23
+ `:`@message .
24
+ `)}},V=class{constructor(e,t){if(e&&typeof e.write!="function"&&(t=e,e=null),t=t||{},this._format=Be(t.format),this._options=t,this._version=t.version===void 0?"1.2-messages":t.version,!ae(this._version)||!Ne(xe(this._version)))throw new TypeError(`Unsupported RDF Messages version: "${this._version}"`);this._output="",this._stream=e,this._endStream=!e||t.end!==!1,this._pending=0,this._waiting=[],this._error=null,this._started=!1,this._ended=!1,this._open=!1,this._count=0,this._declared=Object.assign({},t.prefixes),this._newPrefixes={},this._sink={write:(r,n,s)=>this._write(r,s)},this._writer=null}addMessage(e,t){return this._complete(t,()=>{if(this._open)throw new Error("A message is already open");this._begin();for(let r of e||[])this._add(r);this._close()})}beginMessage(e){return this._complete(e,()=>{if(this._open)throw new Error("A message is already open");this._begin()})}addQuad(e,t,r){return typeof t=="function"&&(r=t,t=void 0),this._complete(r,()=>{t!=null?this._moveTo(t):this._open||this._begin(),this._add(e)})}endMessage(e){return this._complete(e,()=>{this._open||this._begin(),this._close()})}addPrefix(e,t,r){return this._complete(r,()=>{!this._format.lineMode&&this._declared[e]!==(typeof t=="string"?t:t.value)&&(this._newPrefixes[e]=typeof t=="string"?t:t.value)})}end(e){return this._ended?typeof e=="function"?e(null):Promise.resolve():(this._start(),this._open&&this._close(),typeof e=="function"?this._finish(e):new Promise((t,r)=>this._finish((n,s)=>n?r(n):t(s))))}_complete(e,t){if(this._ended)this._error=this._error||new Error("Cannot write after end");else try{t()}catch(r){this._error=this._error||r}return typeof e=="function"?this._whenFlushed(e):new Promise((r,n)=>this._whenFlushed(s=>s?n(s):r()))}_finish(e){this._ended=!0,this._whenFlushed(t=>this._endOutput(t,e))}_endOutput(e,t){if(e||!this._endStream)return t(e);if(!this._stream)return t(null,this._output);try{this._stream.end(r=>t(r))}catch(r){t(r)}}_whenFlushed(e){this._pending===0?this._settle(e):this._waiting.push(e)}_settle(e){let t=this._error;this._error=null,e(t||null)}_write(e,t){if(!this._stream)return this._output+=e,t&&t();this._pending++;try{this._stream.write(e,"utf8",r=>this._written(r,t))}catch(r){this._written(r,t)}}_written(e,t){this._pending--,this._error=this._error||e||null,t&&t(e),this._pending===0&&this._waiting.splice(0).forEach(r=>this._settle(r))}_start(){if(!this._started){this._started=!0;let e=this._options;this._writer=new Xe(this._sink,{format:this._format.name,end:!1,version:this._version,baseIRI:e.baseIRI,writeBase:e.writeBase,prefixes:this._declared})}}_begin(){this._start();let e=this._writer;for(let t of Object.keys(this._newPrefixes)){let r=this._newPrefixes[t];e.addPrefix(t,r),this._declared[t]=r}this._newPrefixes={},this._open=!0,this._count++}_add(e){let t=r=>r&&(this._error=this._error||r);this._writer.addQuad(e.subject,e.predicate,e.object,e.graph,t)}_close(){this._open=!1,this._writer.addDelimiter()}_moveTo(e){let t=this._count-1;if(!Number.isInteger(e)||e<0)throw new RangeError(`Invalid message index: ${e}`);if(!(this._open&&e===t)){if(e<=t)throw new RangeError(`Message index ${e} is lower than the current message index ${t}`);for(this._open&&this._close();this._count<e;)this._begin(),this._close();this._begin()}}};function wi(i,e){let t=new V(e),r=[],n="";function s(a){a&&r.push(a)}for(let a of i)t.addMessage(a,s);if(t.end((a,h)=>(s(a),n=h)),r.length>0)throw r[0];return n}var Tr=ft(Ir(),1);var be=class{constructor(e){this._options=e||{},this._createCore({})}_createCore(e){return new Q(this._options,e)}parse(e,t){typeof t=="function"&&(t={onMessage:t});let r=t?null:[],n=null;t=t||{};let s={message:(l,f)=>t.onMessage?t.onMessage(null,l,void 0,f):r&&r.push(l),end:l=>t.onMessage&&t.onMessage(null,null,l),error:l=>{n=l,t.onMessage&&t.onMessage(l,null),t.onQuad&&t.onQuad(l)}};t.onQuad&&(s.quad=(l,f)=>t.onQuad?.(null,l,f)),t.onPrefix&&(s.prefix=t.onPrefix),t.onVersion&&(s.version=t.onVersion);let a=this._createCore(s);if(typeof e=="string"){if(a.write(e),a.end(),n&&r)throw n;return r||void 0}let h=new Tr.StringDecoder("utf8");e.on("data",l=>a.write(typeof l=="string"?l:h.write(l))),e.on("end",()=>{a.write(h.end()),a.end()}),e.on("error",l=>s.error(l))}};function _n(i,e){return new be(e).parse(i)}var Rr=class extends TransformStream{constructor(e={}){let t=new TextDecoder,r;super({start(n){r=new Q(e,{message:s=>n.enqueue(s),end:()=>{},error:s=>{throw s},prefix:e.onPrefix,version:e.onVersion})},transform(n){r.write(typeof n=="string"?n:t.decode(n,{stream:!0}))},flush(){r.write(t.decode()),r.end()}})}},vr=class extends TransformStream{constructor(e){let t;super({start(r){let n={write:(s,a,h)=>{r.enqueue(s),h()}};t=new V(n,{...e,end:!1})},transform(r){return Array.isArray(r)?t.addMessage(r):t.addQuad(r.quad,r.messageIndex)},flush(){return t.end().then(()=>{})}})}};export{be as MessageParser,Rr as MessageStreamParser,vr as MessageStreamWriter,V as MessageWriter,_n as parseMessages,wi as writeMessages};
25
+ /*! Third-party licenses: ./THIRD-PARTY-LICENSES.txt */
26
+ /*! For license information please see index.js.LEGAL.txt */
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,15 @@
1
+ Bundled license information:
2
+
3
+ ieee754/index.js:
4
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
5
+
6
+ buffer/index.js:
7
+ /*!
8
+ * The buffer module from node.js, for the browser.
9
+ *
10
+ * @author Feross Aboukhadijeh <https://feross.org>
11
+ * @license MIT
12
+ */
13
+
14
+ safe-buffer/index.js:
15
+ /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */