n3.js-messages 0.1.4 → 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.
package/README.md CHANGED
@@ -88,6 +88,51 @@ for await (const message of messages)
88
88
  Chunk boundaries may be anywhere (inside `MESSAGE`, inside an IRI, between the bytes of a character, after the CR of a CRLF);
89
89
  the result is identical to parsing the whole string at once.
90
90
 
91
+ ## Browser usage
92
+
93
+ Import the browser entry with a bundler:
94
+
95
+ ```js
96
+ import { parseMessages, MessageStreamParser, MessageStreamWriter } from 'n3.js-messages/browser';
97
+
98
+ const messages = parseMessages('<https://example.org/s> <https://example.org/p> "hello" .');
99
+
100
+ const response = await fetch('/messages.trig');
101
+ await response.body
102
+ .pipeThrough(new MessageStreamParser({
103
+ format: 'TriG',
104
+ onPrefix: (prefix, term) => console.log(prefix, term.value),
105
+ onVersion: version => console.log(version),
106
+ }))
107
+ .pipeTo(new WritableStream({
108
+ write(message) { console.log(message); },
109
+ }));
110
+ ```
111
+
112
+ Browser-aware bundlers can also select this entry through the package's `browser` export condition.
113
+ The explicit `/browser` entry works without changing TypeScript resolution settings. For automatic selection
114
+ in TypeScript, add `"customConditions": ["browser"]` to your browser project's compiler options.
115
+
116
+ `MessageParser`, `parseMessages`, `MessageWriter`, and `writeMessages` retain their string APIs.
117
+ Browser `MessageParser.parse` accepts strings; use `MessageStreamParser` for streams. The browser stream
118
+ classes use native **Web Streams**, with `readable` and `writable` properties and `pipeThrough()`;
119
+ Node's `.on()`, `.pipe()`, and stream-based `MessageParser.parse` remain available from the Node entry.
120
+
121
+ The browser parser accepts strings, `ArrayBuffer`s, and typed array/DataView chunks. It decodes UTF-8
122
+ across chunk boundaries, preserves empty messages and blank node scope, and rejects parse failures
123
+ through the stream. Prefix and version callbacks are passed in its options. Native stream backpressure,
124
+ source errors, and cancellation propagate through `pipeThrough()`; each complete message is emitted
125
+ as an array, so the largest message must fit in memory.
126
+
127
+ `MessageStreamWriter` accepts arrays of quads or `{ quad, messageIndex }` items and emits strings.
128
+ Pipe its output through `new TextEncoderStream()` when UTF-8 bytes are needed. Both stream classes
129
+ require native `TransformStream`; the bundles also work in module workers.
130
+
131
+ For a direct ESM import without a bundler, serve the self-contained `browser/index.js` file from the npm
132
+ tarball. The classic `browser/index.global.js` bundle exposes `globalThis.N3Messages`. Both bundles
133
+ include N3's parser, writer, and factory, with source maps and third-party license notices; the Node
134
+ entry continues to share the installed N3 peer. Keep `THIRD-PARTY-LICENSES.txt` with redistributed bundles.
135
+
91
136
  ## Writing
92
137
 
93
138
  ```js
@@ -213,18 +258,34 @@ These are one machine's numbers from a single process: run `npm run perf` on you
213
258
 
214
259
  ## Development
215
260
 
261
+ The package runtime supports Node.js 18 and later. Development/build tools require a newer Node;
262
+ CI uses Node.js 24 to build and checks packed artifacts separately on Node.js 18, 20, 22, and 24.
263
+
216
264
  ```sh
217
265
  npm ci
218
- npm test # unit, regression, property tests, with coverage (100% required)
219
- npm run lint
220
- npm run test:spec # official RDF Messages test suite
221
- npm run test:types # TypeScript declarations
222
- npm run test:package # packs the tarball and tests it in a clean consumer project (needs network)
266
+ npm run check # lint + unused code, implementation/types, clean builds, tests, conformance
267
+ npm run ci # check + clean consumer install + real browser tests (network/browser binaries)
268
+ npm run typecheck # strict checkJs, noUncheckedIndexedAccess, and implementation API checks
269
+ npm run test:types # positive/negative public declaration tests
270
+ npm run test:package # tarball contents, ESM/CJS consumers and browser types without Node globals
271
+ npx playwright install chromium firefox webkit
272
+ BROWSER_ENGINES=chromium,firefox,webkit npm run test:browser
273
+ npm run hooks:install # optional: install a pre-commit hook running npm run check
223
274
  npm run perf
224
- npm pack --dry-run
275
+ npm run perf:regression # compare against HEAD; PERF_BASE_REF selects another commit
225
276
  ```
226
277
 
278
+ `npm run build` clears old Node and browser output before generating the distributions. `npm pack`
279
+ runs it automatically; consumer checks reject stale generated modules. Installation never changes Git hooks.
280
+ Browser CI validates the packed ESM and global bundles, browser export selection, Web Streams, and module
281
+ workers in Chromium, Firefox, and WebKit with the minimum and latest N3 peers.
282
+
227
283
  `FUZZ_SEED=… FUZZ_ITERATIONS=…` repeats the property test with another seed; a failure prints its seed and a minimized log.
284
+ The grammar suite replays pinned N3.js cases through synchronous and single-character chunked parsing,
285
+ with RDF isomorphism for results and rejection checks for invalid input. It intentionally excludes N3's
286
+ permissive quad extensions to the default grammar, non-string formats, comment callbacks, and accepting
287
+ unsupported versions, which are outside this package's API. The fixture records its upstream commit
288
+ and license; regenerate it with `npm run test:n3-extract -- ../N3.js` and review the resulting changes.
228
289
 
229
290
  ## License
230
291
 
@@ -0,0 +1,172 @@
1
+ base64-js@1.5.1
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) 2014 Jameson Little
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
23
+
24
+
25
+ buffer@6.0.3
26
+ The MIT License (MIT)
27
+
28
+ Copyright (c) Feross Aboukhadijeh, and other contributors.
29
+
30
+ Permission is hereby granted, free of charge, to any person obtaining a copy
31
+ of this software and associated documentation files (the "Software"), to deal
32
+ in the Software without restriction, including without limitation the rights
33
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
34
+ copies of the Software, and to permit persons to whom the Software is
35
+ furnished to do so, subject to the following conditions:
36
+
37
+ The above copyright notice and this permission notice shall be included in
38
+ all copies or substantial portions of the Software.
39
+
40
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
41
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
42
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
43
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
44
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
45
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
46
+ THE SOFTWARE.
47
+
48
+
49
+ events@3.3.0
50
+ MIT
51
+
52
+ Copyright Joyent, Inc. and other Node contributors.
53
+
54
+ Permission is hereby granted, free of charge, to any person obtaining a
55
+ copy of this software and associated documentation files (the
56
+ "Software"), to deal in the Software without restriction, including
57
+ without limitation the rights to use, copy, modify, merge, publish,
58
+ distribute, sublicense, and/or sell copies of the Software, and to permit
59
+ persons to whom the Software is furnished to do so, subject to the
60
+ following conditions:
61
+
62
+ The above copyright notice and this permission notice shall be included
63
+ in all copies or substantial portions of the Software.
64
+
65
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
66
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
67
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
68
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
69
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
70
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
71
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
72
+
73
+
74
+ ieee754@1.2.1
75
+ Copyright 2008 Fair Oaks Labs, Inc.
76
+
77
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
78
+
79
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
80
+
81
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
82
+
83
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
84
+
85
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
86
+
87
+
88
+ n3@2.13.12
89
+ # License
90
+ The MIT License (MIT)
91
+ Copyright ©2012–present N3.js contributors
92
+
93
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
94
+
95
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
96
+
97
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
98
+
99
+
100
+ safe-buffer@5.2.1
101
+ The MIT License (MIT)
102
+
103
+ Copyright (c) Feross Aboukhadijeh
104
+
105
+ Permission is hereby granted, free of charge, to any person obtaining a copy
106
+ of this software and associated documentation files (the "Software"), to deal
107
+ in the Software without restriction, including without limitation the rights
108
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
109
+ copies of the Software, and to permit persons to whom the Software is
110
+ furnished to do so, subject to the following conditions:
111
+
112
+ The above copyright notice and this permission notice shall be included in
113
+ all copies or substantial portions of the Software.
114
+
115
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
116
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
117
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
118
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
119
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
120
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
121
+ THE SOFTWARE.
122
+
123
+
124
+ string_decoder@1.3.0
125
+ Node.js is licensed for use as follows:
126
+
127
+ """
128
+ Copyright Node.js contributors. All rights reserved.
129
+
130
+ Permission is hereby granted, free of charge, to any person obtaining a copy
131
+ of this software and associated documentation files (the "Software"), to
132
+ deal in the Software without restriction, including without limitation the
133
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
134
+ sell copies of the Software, and to permit persons to whom the Software is
135
+ furnished to do so, subject to the following conditions:
136
+
137
+ The above copyright notice and this permission notice shall be included in
138
+ all copies or substantial portions of the Software.
139
+
140
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
141
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
142
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
143
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
144
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
145
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
146
+ IN THE SOFTWARE.
147
+ """
148
+
149
+ This license applies to parts of Node.js originating from the
150
+ https://github.com/joyent/node repository:
151
+
152
+ """
153
+ Copyright Joyent, Inc. and other Node contributors. All rights reserved.
154
+ Permission is hereby granted, free of charge, to any person obtaining a copy
155
+ of this software and associated documentation files (the "Software"), to
156
+ deal in the Software without restriction, including without limitation the
157
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
158
+ sell copies of the Software, and to permit persons to whom the Software is
159
+ furnished to do so, subject to the following conditions:
160
+
161
+ The above copyright notice and this permission notice shall be included in
162
+ all copies or substantial portions of the Software.
163
+
164
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
165
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
166
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
167
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
168
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
169
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
170
+ IN THE SOFTWARE.
171
+ """
172
+
@@ -0,0 +1,27 @@
1
+ "use strict";var N3Messages=(()=>{var Nr=Object.create;var Ee=Object.defineProperty;var Ar=Object.getOwnPropertyDescriptor;var Sr=Object.getOwnPropertyNames;var Cr=Object.getPrototypeOf,Lr=Object.prototype.hasOwnProperty;var W=(i,e)=>()=>{try{return e||i((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},jr=(i,e)=>{for(var t in e)Ee(i,t,{get:e[t],enumerable:!0})},_t=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Sr(e))!Lr.call(i,n)&&n!==t&&Ee(i,n,{get:()=>e[n],enumerable:!(r=Ar(e,n))||r.enumerable});return i};var pt=(i,e,t)=>(t=i!=null?Nr(Cr(i)):{},_t(e||!i||!i.__esModule?Ee(t,"default",{value:i,enumerable:!0}):t,i)),$r=i=>_t(Ee({},"__esModule",{value:!0}),i);var vt=W((yn,$e)=>{"use strict";var J=typeof Reflect=="object"?Reflect:null,gt=J&&typeof J.apply=="function"?J.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)},Ie;J&&typeof J.ownKeys=="function"?Ie=J.ownKeys:Object.getOwnPropertySymbols?Ie=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Ie=function(e){return Object.getOwnPropertyNames(e)};function Dr(i){console&&console.warn&&console.warn(i)}var mt=Number.isNaN||function(e){return e!==e};function x(){x.init.call(this)}$e.exports=x;$e.exports.once=kr;x.EventEmitter=x;x.prototype._events=void 0;x.prototype._eventsCount=0;x.prototype._maxListeners=void 0;var xt=10;function Te(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 xt},set:function(i){if(typeof i!="number"||i<0||mt(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");xt=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||mt(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 yt(i){return i._maxListeners===void 0?x.defaultMaxListeners:i._maxListeners}x.prototype.getMaxListeners=function(){return yt(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")gt(l,this,t);else for(var f=l.length,c=Tt(l,f),r=0;r<f;++r)gt(c[r],this,t);return!0};function bt(i,e,t,r){var n,s,a;if(Te(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=yt(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,Dr(h)}return i}x.prototype.addListener=function(e,t){return bt(this,e,t,!1)};x.prototype.on=x.prototype.addListener;x.prototype.prependListener=function(e,t){return bt(this,e,t,!0)};function Or(){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 wt(i,e,t){var r={fired:!1,wrapFn:void 0,target:i,type:e,listener:t},n=Or.bind(r);return n.listener=t,r.wrapFn=n,n}x.prototype.once=function(e,t){return Te(t),this.on(e,wt(this,e,t)),this};x.prototype.prependOnceListener=function(e,t){return Te(t),this.prependListener(e,wt(this,e,t)),this};x.prototype.removeListener=function(e,t){var r,n,s,a,h;if(Te(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():Mr(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 Et(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?Ur(n):Tt(n,n.length)}x.prototype.listeners=function(e){return Et(this,e,!0)};x.prototype.rawListeners=function(e){return Et(this,e,!1)};x.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):It.call(i,e)};x.prototype.listenerCount=It;function It(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?Ie(this._events):[]};function Tt(i,e){for(var t=new Array(e),r=0;r<e;++r)t[r]=i[r];return t}function Mr(i,e){for(;e+1<i.length;e++)i[e]=i[e+1];i.pop()}function Ur(i){for(var e=new Array(i.length),t=0;t<e.length;++t)e[t]=i[t].listener||i[t];return e}function kr(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))}Rt(i,e,s,{once:!0}),e!=="error"&&Qr(i,n,{once:!0})})}function Qr(i,e,t){typeof i.on=="function"&&Rt(i,"error",e,t)}function Rt(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 ir=W(Se=>{"use strict";Se.byteLength=vi;Se.toByteArray=Fi;Se.fromByteArray=Ai;var A=[],F=[],Ri=typeof Uint8Array<"u"?Uint8Array:Array,Ze="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(G=0,tr=Ze.length;G<tr;++G)A[G]=Ze[G],F[Ze.charCodeAt(G)]=G;var G,tr;F[45]=62;F[95]=63;function rr(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 vi(i){var e=rr(i),t=e[0],r=e[1];return(t+r)*3/4-r}function Pi(i,e,t){return(e+t)*3/4-t}function Fi(i){var e,t=rr(i),r=t[0],n=t[1],s=new Ri(Pi(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 Bi(i){return A[i>>18&63]+A[i>>12&63]+A[i>>6&63]+A[i&63]}function Ni(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(Bi(r));return n.join("")}function Ai(i){for(var e,t=i.length,r=t%3,n=[],s=16383,a=0,h=t-r;a<h;a+=s)n.push(Ni(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 nr=W(Ke=>{Ke.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)};Ke.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 wr=W(le=>{"use strict";var et=ir(),oe=nr(),sr=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;le.Buffer=o;le.SlowBuffer=Di;le.INSPECT_MAX_BYTES=50;var Ce=2147483647;le.kMaxLength=Ce;o.TYPED_ARRAY_SUPPORT=Si();!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 Si(){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>Ce)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 nt(i)}return ur(i,e,t)}o.poolSize=8192;function ur(i,e,t){if(typeof i=="string")return Li(i,e);if(ArrayBuffer.isView(i))return ji(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 rt(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=$i(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 ur(i,e,t)};Object.setPrototypeOf(o.prototype,Uint8Array.prototype);Object.setPrototypeOf(o,Uint8Array);function lr(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 Ci(i,e,t){return lr(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 Ci(i,e,t)};function nt(i){return lr(i),j(i<0?0:st(i)|0)}o.allocUnsafe=function(i){return nt(i)};o.allocUnsafeSlow=function(i){return nt(i)};function Li(i,e){if((typeof e!="string"||e==="")&&(e="utf8"),!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=cr(i,e)|0,r=j(t),n=r.write(i,e);return n!==t&&(r=r.slice(0,n)),r}function tt(i){let e=i.length<0?0:st(i.length)|0,t=j(e);for(let r=0;r<e;r+=1)t[r]=i[r]&255;return t}function ji(i){if(S(i,Uint8Array)){let e=new Uint8Array(i);return rt(e.buffer,e.byteOffset,e.byteLength)}return tt(i)}function rt(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 $i(i){if(o.isBuffer(i)){let e=st(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"||ht(i.length)?j(0):tt(i);if(i.type==="Buffer"&&Array.isArray(i.data))return tt(i.data)}function st(i){if(i>=Ce)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ce.toString(16)+" bytes");return i|0}function Di(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 cr(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 it(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return br(i).length;default:if(n)return r?-1:it(i).length;e=(""+e).toLowerCase(),n=!0}}o.byteLength=cr;function Oi(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 Wi(this,e,t);case"utf8":case"utf-8":return dr(this,e,t);case"ascii":return zi(this,e,t);case"latin1":case"binary":return Hi(this,e,t);case"base64":return Gi(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ji(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?dr(this,0,e):Oi.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+">"};sr&&(o.prototype[sr]=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 fr(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,ht(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:ar(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):ar(i,[e],t,r,n);throw new TypeError("val must be string, number or Buffer")}function ar(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 fr(this,e,t,r,!0)};o.prototype.lastIndexOf=function(e,t,r){return fr(this,e,t,r,!1)};function Mi(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(ht(h))return a;i[t+a]=h}return a}function Ui(i,e,t,r){return Le(it(e,i.length-t),i,t,r)}function ki(i,e,t,r){return Le(Ki(e),i,t,r)}function Qi(i,e,t,r){return Le(br(e),i,t,r)}function Vi(i,e,t,r){return Le(en(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 Mi(this,e,t,r);case"utf8":case"utf-8":return Ui(this,e,t,r);case"ascii":case"latin1":case"binary":return ki(this,e,t,r);case"base64":return Qi(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Vi(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 Gi(i,e,t){return e===0&&t===i.length?et.fromByteArray(i):et.fromByteArray(i.slice(e,t))}function dr(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 hr=4096;function qi(i){let e=i.length;if(e<=hr)return String.fromCharCode.apply(String,i);let t="",r=0;for(;r<e;)t+=String.fromCharCode.apply(String,i.slice(r,r+=hr));return t}function zi(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 Hi(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 Wi(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+=tn[i[s]];return n}function Ji(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=O(function(e){e=e>>>0,ue(e,"offset");let t=this[e],r=this[e+7];(t===void 0||r===void 0)&&ye(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=O(function(e){e=e>>>0,ue(e,"offset");let t=this[e],r=this[e+7];(t===void 0||r===void 0)&&ye(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=O(function(e){e=e>>>0,ue(e,"offset");let t=this[e],r=this[e+7];(t===void 0||r===void 0)&&ye(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=O(function(e){e=e>>>0,ue(e,"offset");let t=this[e],r=this[e+7];(t===void 0||r===void 0)&&ye(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 _r(i,e,t,r,n){yr(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 pr(i,e,t,r,n){yr(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=O(function(e,t=0){return _r(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});o.prototype.writeBigUInt64BE=O(function(e,t=0){return pr(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=O(function(e,t=0){return _r(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});o.prototype.writeBigInt64BE=O(function(e,t=0){return pr(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function gr(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 xr(i,e,t,r,n){return e=+e,t=t>>>0,n||gr(i,e,t,4,34028234663852886e22,-34028234663852886e22),oe.write(i,e,t,r,23,4),t+4}o.prototype.writeFloatLE=function(e,t,r){return xr(this,e,t,!0,r)};o.prototype.writeFloatBE=function(e,t,r){return xr(this,e,t,!1,r)};function mr(i,e,t,r,n){return e=+e,t=t>>>0,n||gr(i,e,t,8,17976931348623157e292,-17976931348623157e292),oe.write(i,e,t,r,52,8),t+8}o.prototype.writeDoubleLE=function(e,t,r){return mr(this,e,t,!0,r)};o.prototype.writeDoubleBE=function(e,t,r){return mr(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 at(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}`}}}at("ERR_BUFFER_OUT_OF_BOUNDS",function(i){return i?`${i} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);at("ERR_INVALID_ARG_TYPE",function(i,e){return`The "${i}" argument must be of type number. Received type ${typeof e}`},TypeError);at("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=or(String(t)):typeof t=="bigint"&&(n=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(n=or(n)),n+="n"),r+=` It must be ${e}. Received ${n}`,r},RangeError);function or(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 Xi(i,e,t){ue(e,"offset"),(i[e]===void 0||i[e+t]===void 0)&&ye(e,i.length-(t+1))}function yr(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)}Xi(r,n,s)}function ue(i,e){if(typeof i!="number")throw new he.ERR_INVALID_ARG_TYPE(e,"number",i)}function ye(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 Yi=/[^+/0-9A-Za-z-_]/g;function Zi(i){if(i=i.split("=")[0],i=i.trim().replace(Yi,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function it(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 Ki(i){let e=[];for(let t=0;t<i.length;++t)e.push(i.charCodeAt(t)&255);return e}function en(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 br(i){return et.toByteArray(Zi(i))}function Le(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 ht(i){return i!==i}var tn=(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 O(i){return typeof BigInt>"u"?rn:i}function rn(){throw new Error("BigInt not supported")}});var Tr=W((ot,Ir)=>{var je=wr(),C=je.Buffer;function Er(i,e){for(var t in i)e[t]=i[t]}C.from&&C.alloc&&C.allocUnsafe&&C.allocUnsafeSlow?Ir.exports=je:(Er(je,ot),ot.Buffer=z);function z(i,e,t){return C(i,e,t)}z.prototype=Object.create(C.prototype);Er(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 je.SlowBuffer(i)}});var Pr=W(vr=>{"use strict";var lt=Tr().Buffer,Rr=lt.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 nn(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 sn(i){var e=nn(i);if(typeof e!="string"&&(lt.isEncoding===Rr||!Rr(i)))throw new Error("Unknown encoding: "+i);return e||i}vr.StringDecoder=be;function be(i){this.encoding=sn(i);var e;switch(this.encoding){case"utf16le":this.text=cn,this.end=fn,e=4;break;case"utf8":this.fillLast=on,e=4;break;case"base64":this.text=dn,this.end=_n,e=3;break;default:this.write=pn,this.end=gn;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=lt.allocUnsafe(e)}be.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||""};be.prototype.end=ln;be.prototype.text=un;be.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 ut(i){return i<=127?0:i>>5===6?2:i>>4===14?3:i>>3===30?4:i>>6===2?-1:-2}function an(i,e,t){var r=e.length-1;if(r<t)return 0;var n=ut(e[r]);return n>=0?(n>0&&(i.lastNeed=n-1),n):--r<t||n===-2?0:(n=ut(e[r]),n>=0?(n>0&&(i.lastNeed=n-2),n):--r<t||n===-2?0:(n=ut(e[r]),n>=0?(n>0&&(n===2?n=0:i.lastNeed=n-3),n):0))}function hn(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 on(i){var e=this.lastTotal-this.lastNeed,t=hn(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 un(i,e){var t=an(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 ln(i){var e=i&&i.length?this.write(i):"";return this.lastNeed?e+"\uFFFD":e}function cn(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 fn(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 dn(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 _n(i){var e=i&&i.length?this.write(i):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function pn(i){return i.toString(this.encoding)}function gn(i){return i&&i.length?this.write(i):""}});var xn={};jr(xn,{MessageParser:()=>ce,MessageStreamParser:()=>ct,MessageStreamWriter:()=>ft,MessageWriter:()=>D,parseMessages:()=>Br,writeMessages:()=>er});var Kt=pt(vt(),1);var M="http://www.w3.org/1999/02/22-rdf-syntax-ns#",X="http://www.w3.org/2001/XMLSchema#",Re="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:`${M}type`,nil:`${M}nil`,first:`${M}first`,rest:`${M}rest`,langString:`${M}langString`,dirLangString:`${M}dirLangString`,reifies:`${M}reifies`},owl:{sameAs:"http://www.w3.org/2002/07/owl#sameAs"},r:{forSome:`${Re}reify#forSome`,forAll:`${Re}reify#forAll`},log:{implies:`${Re}log#implies`,isImpliedBy:`${Re}log#isImpliedBy`}};var{xsd:ve}=y,Y=32,Z=9,Me=10,K=13,Nt=35,Ve=46,At=58,Vr=48,Gr=57,qr=37,zr=92;function St(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 Ct=new Uint8Array(128);for(let i of`,;!^#()[]{}"'<>
2
+ \v\f\r`)Ct[i.charCodeAt(0)]=1;function Hr(i){return i<128?Ct[i]===1:St(i)}function Wr(i,e,t){let r=i.charCodeAt(e);return r===Ve&&(r=i.charCodeAt(++e)),e>=i.length?t:Hr(r)}var Pt={"\\":"\\","'":"'",'"':'"',n:`
3
+ `,r:"\r",t:" ",f:"\f",b:"\b"},Lt={_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","'":"'","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},Jr=/[\x00-\x20<>\\"\{\}\|\^\`]/,jt=1,$t=2,Pe=4,Ue=8,Dt=16,_e=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";_e[i]=(t?jt:0)|(r&&e!=="-"||e===":"?$t:0)|(r?Pe:0)|(r||e===":"?Ue:0)|(e in Lt?Dt:0)}function ke(i,e,t){let r=i.charCodeAt(e);if(r<128)return(_e[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>=Pe&&(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 Xr(i){return i<128&&(_e[i]&Dt)!==0}function Ft(i){return i>=Vr&&i<=Gr||i>=65&&i<=70||i>=97&&i<=102}function Qe(i,e){let t=ke(i,e,jt);for(;t!==0;){e+=t;let r=i.charCodeAt(e)===Ve?e+1:e,n=i.charCodeAt(r);t=n<128?(_e[n]&Pe)!==0?1:0:ke(i,r,Pe),t!==0&&(e=r)}return e}function Yr(i,e){let t=e,r=$t;for(;;){let n=i.charCodeAt(e),s=n<128?(_e[n]&r)!==0?1:0:ke(i,e,r);if(s===0&&n===qr&&Ft(i.charCodeAt(e+1))&&Ft(i.charCodeAt(e+2))?s=3:s===0&&n===zr&&Xr(i.charCodeAt(e+1))&&(s=2),s!==0)t=e+=s,r=Ue;else if(n===Ve&&r===Ue)e++;else return t}}function Bt(i,e,t){let r=Qe(i,e);if(i.charCodeAt(r)!==At)return-1;let n=Yr(i,r+1);return Wr(i,n,t)?n:-1}function Zr(i){return i<=1114111&&(i<55296||i>57343)}var Kr={_iri:!0,_unescapedIri:!0,_simpleQuotedString:!0,_langcode:!0,_blank:!0,_commentLine:!0,_whitespace:!0},ei=/$0^/,ti=/\S*/y;function w(i,e,t){return i.lastIndex=t,i.exec(e)}function De(i,e,t){return i.lastIndex=t,i.test(e)}function Oe(i,e,t){return i.lastIndex=0,i.exec(`${e.slice(t)} `)}function ri(i){return i===Y||i===Z||i===Me||i===K||i===Nt}var ii=/^(?:prefix|base|version|graph|forsome|forall|iri|a|true|false|has|is|of|id)$/i,ni=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 Kr)&&this[t]instanceof RegExp&&(this[t]=ei);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)||ii.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===Nt){let N=w(this._commentLine,r,n);if(N){let de=N[0].length;if(!t&&n+de===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+=de,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===Me||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)===Me?2:1;let N=0,de=r.charCodeAt(n+E);if(de===Y||de===Z){let dt=r.charCodeAt(n+E+1);N=dt===Y||dt===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(ri(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],Pt),p===null||Jr.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=Oe(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=Oe(this._number,r,n)))&&(u="literal",p=d[0],g=typeof d[1]=="string"?ve.double:typeof d[2]=="string"?ve.decimal:ve.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":De(this._boolean,r,n)?(u="literal",p=c==="t"?"true":"false",g=ve.boolean,_=p.length):v=!0;break;case"a":De(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&&De(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=Qe(r,n))===At&&m+1<r.length&&(r[m+1]==="#"||r[m+1]==="<"||St(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=Oe(this._directive,r,n))))u=d[0].toUpperCase();else if(!this._lineMode&&(m=Bt(r,n,t))>=0){let E=r.indexOf(":",n);u="prefixed",g=r.slice(n,E),p=this._unescape(r.slice(E+1,m),Lt),_=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 fe=_||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+fe,tripleQuoted:B},e(null,H)):H=h(u,p,g,f,we,I||fe),this.previousToken=H,this._previousMarker=u==="literal"&&(this._previousMarker==="VERSION"||this._previousMarker==="@version")?"version":u,n=Math.min(n+fe,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(ti,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:Bt(e,t,!0)>=0||!r&&Qe(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(!Zr(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,Pt),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>ni?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:Ot,xsd:$}=y,ge,si=0,ai="<>";var hi={namedNode:Mt,blankNode:Ut,variable:Qt,literal:kt,defaultGraph:oi,quad:He,triple:He,fromTerm:pe,fromQuad:Vt},U=hi,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}}},Fe=class extends P{constructor(e){e!==""?super(e):(super(ai),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 Fe(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?Ot.dirLangString:Ot.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}}}},Ge=class extends P{constructor(e){super(`_:${e}`)}get termType(){return"BlankNode"}get value(){return this.id.substr(2)}},qe=class extends P{constructor(e){super(`?${e}`)}get termType(){return"Variable"}get value(){return this.id.substr(1)}},ze=class extends P{constructor(){return super(""),ge||this}get termType(){return"DefaultGraph"}equals(e){return this===e||!!e&&this.termType===e.termType}};ge=new ze;var Be=class extends P{constructor(e,t,r,n){super(""),this._subject=e,this._predicate=t,this._object=r,this._graph=n||ge}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 Mt(i){return new Fe(i)}function Ut(i){return new Ge(i||`n3-${si++}`)}function kt(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 Qt(i){return new qe(i)}function oi(){return ge}function He(i,e,t,r){return new Be(i,e,t,r)}function pe(i){if(i instanceof P)return i;switch(i.termType){case"NamedNode":return Mt(i.value);case"BlankNode":return Ut(i.value);case"Variable":return Qt(i.value);case"DefaultGraph":return ge;case"Literal":return kt(i.value,i.language?i.direction?{language:i.language,direction:i.direction}:i.language:i.datatype);case"Quad":return Vt(i);default:throw new Error(`Unexpected termType: ${i.termType}`)}}function Vt(i){if(i instanceof Be)return i;if(i.termType!=="Quad")throw new Error(`Unexpected termType: ${i.termType}`);return He(pe(i.subject),pe(i.predicate),pe(i.object),pe(i.graph))}var Gt=0,qt=/(^|\/)\.\.?($|[/#?])/,ui=/^[^?#]*(?:^|\/)\.\.?(?:$|[/#?])/,L=class i{constructor(e){this._contextStack=[],this._graph=null,e=e||{},this._setBase(e.baseIRI),e.factory&&Ht(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(){Gt=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&&(zt(this._prefixes,this._prefixChanges),this._prefixChanges=r.prefixChanges),this._prefixes._=r.blankPrefix,this._quantifiedChanges!==r.quantifiedChanges&&(zt(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||ui.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${Gt++}_`,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,fe)=>{B?([this._base,this._basePath,this._baseRoot,this._baseScheme]=v,this._callback(B),this._callback=re):this._readCallback&&g(fe)})}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 zt(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 Ht(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"];Ht(L.prototype,U);function We(i){return!!i&&i.termType==="DefaultGraph"}function k(i){return i.replace(/[.*+?^${}()|[\]\\/-]/g,"\\$&")}var li=/^:?[^:?#]*(?:[?#]|$)|^file:|^[^:]*:\/*[^?#]+?\/(?:\.\.?(?:\/|$)|\/)/i,ci=/^(?:(?!\.\.?(?:[/?#]|$))[^/?#]+(?:\/[^/?#]{3,})*\/?)?(?:[?#]|$)/,Wt="./",fi="../",Je="?",Jt="#",xe=class i{constructor(e){this.base=e,this._baseLength=0,this._baseMatcher=null,this._pathReplacements=new Array(e.length+1)}static supports(e){return!li.test(e)}_getBaseMatcher(){if(this._baseMatcher)return this._baseMatcher;if(!i.supports(this.base))return this._baseMatcher=/.^/;let e=/^[^:]*:\/*/.exec(this.base)[0],t=["^",k(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]===Jt?l=s.lastIndex-1:(t.push(k(a[0]),"(?:"),r.push(")?"),a[1]!==Je?n.push(f=s.lastIndex):(h=f=s.lastIndex,l=this.base.indexOf(Jt,h),this._pathReplacements[h]=Je));for(let c=0;c<n.length;c++)this._pathReplacements[n[c]]=fi.repeat(n.length-c-1);return this._pathReplacements[n[n.length-1]]=Wt,this._baseLength=l>0?l:this.base.length,t.push(k(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!==Je&&!ci.test(s)?e:n===Wt&&/^[^?#]/.test(s)&&(s.indexOf(":")<0||!/^[^/?#]*:/.test(s))?s:n+s}return e.substring(r-1)}};var ie=U.defaultGraph(),{rdf:di,xsd:ne}=y,{hasOwnProperty:_i}=Object.prototype,pi=/["\\\t\n\r\b\f\u0000-\u0019\ud800-\udbff]/,gi=/["\\\t\n\r\b\f\u0000-\u0019]|[\ud800-\udbff][\udc00-\udfff]/g,xi=/[^ !#-\[\]-~\u0080-\uFFFD]/,mi=/[^ !#-\[\]-~\u0080-\uFFFD]/g,Yt={"\\":"\\\\",'"':'\\"'," ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"},yi=/["\\\u0000-\u001f\u007f]|[\ud800-\udbff](?![\udc00-\udfff])|(?:^|[^\ud800-\udbff])[\udc00-\udfff]/,Zt="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",Xt=`${Zt}\\-\\u00B7\\u0300-\\u036F\\u203F\\u2040`,Xe="%[0-9A-Fa-f]{2}",bi=new RegExp(`^(?:(?:[${Zt}]|${Xe})(?:(?:[${Xt}.]|${Xe})*(?:[${Xt}]|${Xe}))?)?$`),Q=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&&yi.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=xi,this._escapeAll=mi,this._characterReplacer=Ei,t.version&&this._write(`VERSION "${t.version}"
4
+ `)):(this._lineMode=!1,this._escape=pi,this._escapeAll=gi,this._characterReplacer=wi,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 xe(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&&!We(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&&_i.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]:bi.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===di.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)}${We(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]=[k(s),k(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 Q("[]");case 1:if(n=r[0],!(n.object instanceof Q))return new Q(`[ ${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 Q(`${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 Q(`(${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 wi(i){let e=Yt[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 Ei(i){let e=Yt[i];return e===void 0&&(e=i.charCodeAt(0).toString(16).toUpperCase(),e="\\u0000".substr(0,6-e.length)+e),e}var Ii={turtle:{name:"Turtle",lineMode:!1},trig:{name:"TriG",lineMode:!1},ntriples:{name:"N-Triples",lineMode:!0},nquads:{name:"N-Quads",lineMode:!0}},Ti=["1.2","1.2-basic","1.1"];function Ne(i="TriG"){let e=String(i).toLowerCase().replace(/;[\s\S]*$/,"").trim().replace(/^(?:text|application)\//,"").replace(/^x-/,"").replace(/[-_ ]/g,""),t=Ii[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 me(i){return ae(i)?i.slice(0,-9):i}function Ae(i,e=Ti){return e.includes(i)}var V=class{constructor(e,t){e=e||{};let r=Ne(e.format);this._sink=t,this._factory=e.factory||U,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=me(e.version)),this._input=new Kt.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(Ae(me(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 Ye=class extends se{addDelimiter(){this._endStatement(),this._write(this._lineMode?`MESSAGE
23
+ `:`@message .
24
+ `)}},D=class{constructor(e,t){if(e&&typeof e.write!="function"&&(t=e,e=null),t=t||{},this._format=Ne(t.format),this._options=t,this._version=t.version===void 0?"1.2-messages":t.version,!ae(this._version)||!Ae(me(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 Ye(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 er(i,e){let t=new D(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 Fr=pt(Pr(),1);var ce=class{constructor(e){this._options=e||{},this._createCore({})}_createCore(e){return new V(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 Fr.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 Br(i,e){return new ce(e).parse(i)}var ct=class extends TransformStream{constructor(e={}){let t=new TextDecoder,r;super({start(n){r=new V(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()}})}},ft=class extends TransformStream{constructor(e){let t;super({start(r){let n={write:(s,a,h)=>{r.enqueue(s),h()}};t=new D(n,{...e,end:!1})},transform(r){return Array.isArray(r)?t.addMessage(r):t.addQuad(r.quad,r.messageIndex)},flush(){return t.end().then(()=>{})}})}};return $r(xn);})();
25
+ /*! Third-party licenses: ./THIRD-PARTY-LICENSES.txt */
26
+ /*! For license information please see index.global.js.LEGAL.txt */
27
+ //# sourceMappingURL=index.global.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> */