rdflib 2.3.2-2bc27df4 → 2.3.2-dd04a8c3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rdflib.min.js +1 -1
- package/dist/rdflib.min.js.map +1 -1
- package/esm/n3parser.js +1 -2
- package/lib/n3parser.js +1 -2
- package/package.json +1 -1
- package/src/n3parser.js +1 -2
package/dist/rdflib.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see rdflib.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("window")):"function"==typeof define&&define.amd?define(["window"],e):"object"==typeof exports?exports.$rdf=e(require("window")):t.$rdf=e(t.window)}(self,(t=>(()=>{var e,r,i,n,s={362:(t,e,r)=>{"use strict";function i(t){return"string"==typeof t?t:t.value}r.d(e,{E:()=>i})},546:(t,e,r)=>{"use strict";r.d(e,{CZ:()=>h,D0:()=>c,DJ:()=>o,DZ:()=>u,GE:()=>y,P3:()=>a,RN:()=>b,SH:()=>n,Y2:()=>p,YC:()=>w,aF:()=>d,c$:()=>f,fY:()=>l,hr:()=>m,jt:()=>g,ok:()=>s});var i=r(6866);function n(t){return"object"==typeof t&&null!==t&&"subject"in t}function s(t){return"object"==typeof t&&null!==t&&"statements"in t}function a(t){return c(t)&&t.termType===i.r0}function o(t){return t&&Object.prototype.hasOwnProperty.call(t,"termType")&&(t.termType===i.Kk||t.termType===i.P2||t.termType===i.$Q||t.termType===i.r0||t.termType===i.QW||t.termType===i.bD)}function h(t){return t&&Object.prototype.hasOwnProperty.call(t,"termType")&&(t.termType===i.Kk||t.termType===i.P2||t.termType===i.$Q||t.termType===i.r0||t.termType===i.QW||t.termType===i.bD)}function l(t){return c(t)&&(t.termType===i.Kk||t.termType===i.$Q||t.termType===i.P2)}function u(t){return c(t)&&t.termType===i.P2}function c(t){return"object"==typeof t&&null!==t&&"termType"in t}function f(t){return t.termType===i.QW}function d(t){return"object"==typeof t&&null!==t&&"subject"in t&&"predicate"in t&&"object"in t}function p(t){return c(t)&&"NamedNode"===t.termType}function g(t){return c(t)&&"termType"in t&&"BlankNode"===t.termType}function m(t){return c(t)&&(t.termType===i.Kk||t.termType===i.P2||t.termType===i.$Q)}function w(t){return c(t)&&(t.termType===i.Kk||t.termType===i.P2)}function y(t){return c(t)&&(t.termType===i.Kk||t.termType===i.P2||t.termType===i.$Q||t.termType===i.QW)}function b(t){return c(t)&&(t.termType===i.Kk||t.termType===i.P2||t.termType===i.$Q||t.termType===i.ic)}},939:(t,e,r)=>{"use strict";function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function n(t,e,r){return(e=function(t){var e=function(t){if("object"!=i(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==i(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}r.d(e,{A:()=>n})},1147:(t,e,r)=>{var i="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==r.g&&r.g,n=function(){function t(){this.fetch=!1,this.DOMException=i.DOMException}return t.prototype=i,new t}();!function(t){!function(e){var i=void 0!==t&&t||"undefined"!=typeof self&&self||void 0!==r.g&&r.g||{},n="URLSearchParams"in i,s="Symbol"in i&&"iterator"in Symbol,a="FileReader"in i&&"Blob"in i&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in i,h="ArrayBuffer"in i;if(h)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&l.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function f(t){return"string"!=typeof t&&(t=String(t)),t}function d(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return s&&(e[Symbol.iterator]=function(){return e}),e}function p(t){this.map={},t instanceof p?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function g(t){if(!t._noBody)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function m(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function w(t){var e=new FileReader,r=m(e);return e.readAsArrayBuffer(t),r}function y(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){var e;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:a&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():h&&a&&(e=t)&&DataView.prototype.isPrototypeOf(e)?(this._bodyArrayBuffer=y(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):h&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=y(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a&&(this.blob=function(){var t=g(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer)return g(this)||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer));if(a)return this.blob().then(w);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,e,r,i,n,s=g(this);if(s)return s;if(this._bodyBlob)return t=this._bodyBlob,r=m(e=new FileReader),n=(i=/charset=([A-Za-z0-9_-]+)/.exec(t.type))?i[1]:"utf-8",e.readAsText(t,n),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),i=0;i<e.length;i++)r[i]=String.fromCharCode(e[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(x)}),this.json=function(){return this.text().then(JSON.parse)},this}p.prototype.append=function(t,e){t=c(t),e=f(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},p.prototype.delete=function(t){delete this.map[c(t)]},p.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},p.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},p.prototype.set=function(t,e){this.map[c(t)]=f(e)},p.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},p.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),d(t)},p.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),d(t)},p.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),d(t)},s&&(p.prototype[Symbol.iterator]=p.prototype.entries);var v=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function _(t,e){if(!(this instanceof _))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,n,s=(e=e||{}).body;if(t instanceof _){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new p(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,s||null==t._bodyInit||(s=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new p(e.headers)),this.method=(n=(r=e.method||this.method||"GET").toUpperCase(),v.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||function(){if("AbortController"in i)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(s),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==e.cache&&"no-cache"!==e.cache)){var a=/([?&])_=[^&]*/;a.test(this.url)?this.url=this.url.replace(a,"$1_="+(new Date).getTime()):this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}function x(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),i=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(n))}})),e}function T(t,e){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new p(e.headers),this.url=e.url||"",this._initBody(t)}_.prototype.clone=function(){return new _(this,{body:this._bodyInit})},b.call(_.prototype),b.call(T.prototype),T.prototype.clone=function(){return new T(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},T.error=function(){var t=new T(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var A=[301,302,303,307,308];T.redirect=function(t,e){if(-1===A.indexOf(e))throw new RangeError("Invalid status code");return new T(null,{status:e,headers:{location:t}})},e.DOMException=i.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function N(t,r){return new Promise((function(n,s){var o=new _(t,r);if(o.signal&&o.signal.aborted)return s(new e.DOMException("Aborted","AbortError"));var l=new XMLHttpRequest;function u(){l.abort()}if(l.onload=function(){var t,e,r={statusText:l.statusText,headers:(t=l.getAllResponseHeaders()||"",e=new p,t.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var r=t.split(":"),i=r.shift().trim();if(i){var n=r.join(":").trim();try{e.append(i,n)}catch(t){console.warn("Response "+t.message)}}})),e)};0===o.url.indexOf("file://")&&(l.status<200||l.status>599)?r.status=200:r.status=l.status,r.url="responseURL"in l?l.responseURL:r.headers.get("X-Request-URL");var i="response"in l?l.response:l.responseText;setTimeout((function(){n(new T(i,r))}),0)},l.onerror=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},l.ontimeout=function(){setTimeout((function(){s(new TypeError("Network request timed out"))}),0)},l.onabort=function(){setTimeout((function(){s(new e.DOMException("Aborted","AbortError"))}),0)},l.open(o.method,function(t){try{return""===t&&i.location.href?i.location.href:t}catch(e){return t}}(o.url),!0),"include"===o.credentials?l.withCredentials=!0:"omit"===o.credentials&&(l.withCredentials=!1),"responseType"in l&&(a?l.responseType="blob":h&&(l.responseType="arraybuffer")),r&&"object"==typeof r.headers&&!(r.headers instanceof p||i.Headers&&r.headers instanceof i.Headers)){var d=[];Object.getOwnPropertyNames(r.headers).forEach((function(t){d.push(c(t)),l.setRequestHeader(t,f(r.headers[t]))})),o.headers.forEach((function(t,e){-1===d.indexOf(e)&&l.setRequestHeader(e,t)}))}else o.headers.forEach((function(t,e){l.setRequestHeader(e,t)}));o.signal&&(o.signal.addEventListener("abort",u),l.onreadystatechange=function(){4===l.readyState&&o.signal.removeEventListener("abort",u)}),l.send(void 0===o._bodyInit?null:o._bodyInit)}))}N.polyfill=!0,i.fetch||(i.fetch=N,i.Headers=p,i.Request=_,i.Response=T),e.Headers=p,e.Request=_,e.Response=T,e.fetch=N}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var s=i.fetch?i:n;(e=s.fetch).default=s.fetch,e.fetch=s.fetch,e.Headers=s.Headers,e.Request=s.Request,e.Response=s.Response,t.exports=e},1605:(t,e,r)=>{"use strict";r.d(e,{A:()=>n});var i=r(939);class n{constructor(t){(0,i.A)(this,"termType",void 0),(0,i.A)(this,"classOrder",void 0),(0,i.A)(this,"value",void 0),this.value=t}substitute(t){return this}compareTerm(t){return this.classOrder<t.classOrder?-1:this.classOrder>t.classOrder?1:this.value<t.value?-1:this.value>t.value?1:0}equals(t){return!!t&&this.termType===t.termType&&this.value===t.value}hashString(){return this.toCanonical()}sameTerm(t){return this.equals(t)}toCanonical(){return this.toNT()}toNT(){return this.toString()}toNQ(){return this.toNT()}toString(){throw new Error("Node.toString() is abstract - see the subclasses instead")}}(0,i.A)(n,"fromValue",void 0),(0,i.A)(n,"toJS",void 0)},2312:function(t,e){var r,i;void 0===(i="function"==typeof(r=function(){"use strict";function t(e,r,i,n){this.message=e,this.expected=r,this.found=i,this.location=n,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}return function(t,e){function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r}(t,Error),t.buildMessage=function(t,e){var r={literal:function(t){return'"'+n(t.text)+'"'},class:function(t){var e,r="";for(e=0;e<t.parts.length;e++)r+=t.parts[e]instanceof Array?s(t.parts[e][0])+"-"+s(t.parts[e][1]):s(t.parts[e]);return"["+(t.inverted?"^":"")+r+"]"},any:function(t){return"any character"},end:function(t){return"end of input"},other:function(t){return t.description}};function i(t){return t.charCodeAt(0).toString(16).toUpperCase()}function n(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+i(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+i(t)}))}function s(t){return t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+i(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+i(t)}))}return"Expected "+function(t){var e,i,n,s=new Array(t.length);for(e=0;e<t.length;e++)s[e]=(n=t[e],r[n.type](n));if(s.sort(),s.length>0){for(e=1,i=1;e<s.length;e++)s[e-1]!==s[e]&&(s[i]=s[e],i++);s.length=i}switch(s.length){case 1:return s[0];case 2:return s[0]+" or "+s[1];default:return s.slice(0,-1).join(", ")+", or "+s[s.length-1]}}(t)+" but "+function(t){return t?'"'+n(t)+'"':"end of input"}(e)+" found."},{SyntaxError:t,parse:function(e,r){r=void 0!==r?r:{};var i,n={},s={turtleDoc:Gr},a=Gr,o=function(t){var e=Ti.toJSON();return e["@graph"]=[],t.filter((t=>Array.isArray(t))).forEach((t=>{t.forEach((t=>{e["@graph"].push(t)}))})),1===e["@graph"].length&&(Object.assign(e,e["@graph"][0]),delete e["@graph"]),e},h="\ufeff",l=Hr("\ufeff",!1),u=".",c=Hr(".",!1),f=function(t){return t},d="#",p=Hr("#",!1),g=/^[^\n]/,m=Xr(["\n"],!0,!1),w="\n",y=Hr("\n",!1),b=function(t){return t.join("")},v="@prefix",_=Hr("@prefix",!1),x=function(t,e){return Ti.addPrefix(""===t?"0":t,e),{}},T="@base",A=Hr("@base",!1),N=function(t){return Ti.addBase(t),{}},E=/^[Bb]/,R=Xr(["B","b"],!1,!1),k=/^[Aa]/,I=Xr(["A","a"],!1,!1),C=/^[Ss]/,O=Xr(["S","s"],!1,!1),j=/^[Ee]/,S=Xr(["E","e"],!1,!1),F=/^[Pp]/,U=Xr(["P","p"],!1,!1),D=/^[Rr]/,L=Xr(["R","r"],!1,!1),M=/^[Ff]/,P=Xr(["F","f"],!1,!1),B=/^[Ii]/,q=Xr(["I","i"],!1,!1),$=/^[Xx]/,H=Xr(["X","x"],!1,!1),X=function(t,e){var r={};return"string"==typeof t&&"[]"!==t?r["@id"]=t:"object"==typeof t&&Object.assign(r,t),e&&Object.assign(r,e),[r]},z=function(t,e){var r={};return t&&Object.assign(r,t),e&&Object.assign(r,e),[r]},Q=";",V=Hr(";",!1),G=function(t,e,r,i){var n={};return n[r]=i,n},W=function(t,e,r){return r},Y=function(t,e,r){var i={};return r.unshift(function(t,e){var r={};return r[t]=e,r}(t,e)),r.forEach((t=>{t&&Object.keys(t).forEach((e=>{t[e].forEach((t=>{"@type"===e&&void 0!==t["@id"]&&(t=t["@id"]),void 0===i[e]?i[e]=t:Array.isArray(i[e])?i[e].push(t):i[e]=[i[e],t]}))}))})),i},Z=",",J=Hr(",",!1),K=function(t,e){return e},tt=function(t,e){return e.unshift(t),e},et="a",rt=Hr("a",!1),it=function(){return"@type"},nt=function(t){return Ai(t,!0)},st=function(t){return Ai(t,!1)},at=function(t){return"[]"===t?{}:{"@id":t}},ot=function(t){return{"@id":t}},ht="[",lt=Hr("[",!1),ut="]",ct=Hr("]",!1),ft="(",dt=Hr("(",!1),pt=")",gt=Hr(")",!1),mt=function(t){return{"@list":t}},wt=function(t,e){return{"@value":t,"@language":e}},yt="^^",bt=Hr("^^",!1),vt=function(t,e){if("http://www.w3.org/2001/XMLSchema#boolean"===e&&"true"===t)return!0;if("http://www.w3.org/2001/XMLSchema#boolean"===e&&"false"===t)return!1;if("http://www.w3.org/2001/XMLSchema#integer"===e)return parseInt(t);if("http://www.w3.org/2001/XMLSchema#double"===e)return parseFloat(t);const r=Ti.resolve(e,!0);if(r){const i=e.split(":")[0];if("http://www.w3.org/2001/XMLSchema#boolean"===r&&"true"===t)return Ti.decrement(i),!0;if("http://www.w3.org/2001/XMLSchema#boolean"===r&&"false"===t)return Ti.decrement(i),!1;if("http://www.w3.org/2001/XMLSchema#integer"===r)return Ti.decrement(i),parseInt(t);if("http://www.w3.org/2001/XMLSchema#double"===r)return Ti.decrement(i),parseFloat(t)}return{"@value":t,"@type":e}},_t="true",xt=Hr("true",!1),Tt=function(){return!0},At="false",Nt=Hr("false",!1),Et=function(){return!1},Rt=function(t){return t+":"},kt="<",It=Hr("<",!1),Ct=/^[^\0- <>"{}|\^`\\]/,Ot=Xr([["\0"," "],"<",">",'"',"{","}","|","^","`","\\"],!0,!1),jt=">",St=Hr(">",!1),Ft=function(t){const e=t.map((t=>65536<=t.codePointAt(0)&&t.codePointAt(0)<=983039?"a":1===t.length?t:6===t.length?String.fromCharCode("0x"+t.substring(2)):10===t.length?String.fromCodePoint("0x"+t.substring(2)):t)).join("");if(e.match(/^[^\u0000-\u0020<>"{}|^`\\]*$/)){var r=t.join("");try{return Ti.resolve(r)}catch(t){$r("Invalid IRIREF "+r)}}else $r("Invalid IRIREF "+t.join("")+" / "+e)},Ut=":",Dt=Hr(":",!1),Lt=function(t){return t=t||"0",!1===Ti.hasPrefix(t)&&$r("undefined prefix "+t),t},Mt=function(t){return t||""},Pt=function(t,e){return Ti.increment(t),Ti.resolve(t+":"+e)},Bt="_:",qt=Hr("_:",!1),$t=/^[0-9]/,Ht=Xr([["0","9"]],!1,!1),Xt="@",zt=Hr("@",!1),Qt=/^[a-zA-Z]/,Vt=Xr([["a","z"],["A","Z"]],!1,!1),Gt="-",Wt=Hr("-",!1),Yt=/^[a-zA-Z0-9]/,Zt=Xr([["a","z"],["A","Z"],["0","9"]],!1,!1),Jt=function(t,e){return"-"+e.join("")},Kt=function(t,e){return t.join("")+e.join("")},te=/^[+\-]/,ee=Xr(["+","-"],!1,!1),re=function(t){return t.match(/^[0+][0-9]+$/)?{"@value":t,"@type":"http://www.w3.org/2001/XMLSchema#integer"}:parseInt(t)},ie=function(t){return{"@value":t,"@type":"http://www.w3.org/2001/XMLSchema#decimal"}},ne=function(t){return{"@value":t,"@type":"http://www.w3.org/2001/XMLSchema#double"}},se=/^[eE]/,ae=Xr(["e","E"],!1,!1),oe='"',he=Hr('"',!1),le=/^[^"\\\n\r]/,ue=Xr(['"',"\\","\n","\r"],!0,!1),ce="'",fe=Hr("'",!1),de=/^[^'\\\n\r]/,pe=Xr(["'","\\","\n","\r"],!0,!1),ge="'''",me=Hr("'''",!1),we=/^[^'\\]/,ye=Xr(["'","\\"],!0,!1),be="''",ve=Hr("''",!1),_e=function(t,e){return"''"+e.join("")},xe=function(t,e){return"'"+e.join("")},Te=function(t,e){return t.join("")+e.join("")},Ae='"""',Ne=Hr('"""',!1),Ee=/^[^"\\]/,Re=Xr(['"',"\\"],!0,!1),ke='""',Ie=Hr('""',!1),Ce=function(t,e){return'""'+e.join("")},Oe=function(t,e){return'"'+e.join("")},je="\\U",Se=Hr("\\U",!1),Fe=function(t){return String.fromCodePoint(parseInt(t.join(""),16))},Ue="\\u",De=Hr("\\u",!1),Le=function(t){return String.fromCharCode(parseInt(t.join(""),16))},Me="\\t",Pe=Hr("\\t",!1),Be=function(){return"\t"},qe="\\b",$e=Hr("\\b",!1),He=function(){return"\b"},Xe="\\n",ze=Hr("\\n",!1),Qe=function(){return"\n"},Ve="\\r",Ge=Hr("\\r",!1),We=function(){return"\r"},Ye="\\f",Ze=Hr("\\f",!1),Je=function(){return"\f"},Ke='\\"',tr=Hr('\\"',!1),er=function(){return'"'},rr="\\'",ir=Hr("\\'",!1),nr=function(){return"'"},sr="\\\\",ar=Hr("\\\\",!1),or=function(){return"\\"},hr=/^[ \t\r\n]/,lr=Xr([" ","\t","\r","\n"],!1,!1),ur=function(){return"[]"},cr=/^[\uD800-\uDBFF]/,fr=Xr([["\ud800","\udbff"]],!1,!1),dr=/^[\uDC00-\uDFFF]/,pr=Xr([["\udc00","\udfff"]],!1,!1),gr=function(t,e){return t+e},mr=/^[A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,wr=Xr([["A","Z"],["a","z"],["À","Ö"],["Ø","ö"],["ø","˿"],["Ͱ","ͽ"],["Ϳ",""],["",""],["⁰",""],["Ⰰ",""],["、",""],["豈","﷏"],["ﷰ","�"]],!1,!1),yr="_",br=Hr("_",!1),vr="·",_r=Hr("·",!1),xr=/^[\u0300-\u036F]/,Tr=Xr([["̀","ͯ"]],!1,!1),Ar=/^[\u203F-\u2040]/,Nr=Xr([["‿","⁀"]],!1,!1),Er=function(t,e,r,i){return r.join("")+i.join("")},Rr=function(t,e,r){return t+e.join("")+r.join("")},kr="%",Ir=Hr("%",!1),Cr=/^[0-9A-Fa-f]/,Or=Xr([["0","9"],["A","F"],["a","f"]],!1,!1),jr="\\",Sr=Hr("\\",!1),Fr=/^[_~.!$&'()*+,;=\/?#@%\-]/,Ur=Xr(["_","~",".","!","$","&","'","(",")","*","+",",",";","=","/","?","#","@","%","-"],!1,!1),Dr=0,Lr=0,Mr=[{line:1,column:1}],Pr=0,Br=[],qr=0;if("startRule"in r){if(!(r.startRule in s))throw new Error("Can't start parsing from rule \""+r.startRule+'".');a=s[r.startRule]}function $r(e,r){throw function(e,r){return new t(e,null,null,r)}(e,r=void 0!==r?r:Qr(Lr,Dr))}function Hr(t,e){return{type:"literal",text:t,ignoreCase:e}}function Xr(t,e,r){return{type:"class",parts:t,inverted:e,ignoreCase:r}}function zr(t){var r,i=Mr[t];if(i)return i;for(r=t-1;!Mr[r];)r--;for(i={line:(i=Mr[r]).line,column:i.column};r<t;)10===e.charCodeAt(r)?(i.line++,i.column=1):i.column++,r++;return Mr[t]=i,i}function Qr(t,e){var r=zr(t),i=zr(e);return{start:{offset:t,line:r.line,column:r.column},end:{offset:e,line:i.line,column:i.column}}}function Vr(t){Dr<Pr||(Dr>Pr&&(Pr=Dr,Br=[]),Br.push(t))}function Gr(){var t,e,r,i,s;for(t=Dr,e=[],r=Wr();r!==n;)e.push(r),r=Wr();if(e!==n){for(r=[],i=Yr();i!==n;)r.push(i),i=Yr();if(r!==n){for(i=[],s=Zr();s!==n;)i.push(s),s=Zr();i!==n?(Lr=t,t=e=o(r)):(Dr=t,t=n)}else Dr=t,t=n}else Dr=t,t=n;return t}function Wr(){var t;return 65279===e.charCodeAt(Dr)?(t=h,Dr++):(t=n,0===qr&&Vr(l)),t}function Yr(){var t,r,i,s;if((t=function(){var t;return(t=function(){var t,r,i,s,a,o,h,l,f;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if(e.substr(Dr,7)===v?(i=v,Dr+=7):(i=n,0===qr&&Vr(_)),i!==n){for(s=[],a=Zr();a!==n;)s.push(a),a=Zr();if(s!==n)if((a=li())!==n){for(o=[],h=Zr();h!==n;)o.push(h),h=Zr();if(o!==n)if((h=oi())!==n){for(l=[],f=Zr();f!==n;)l.push(f),f=Zr();l!==n?(46===e.charCodeAt(Dr)?(f=u,Dr++):(f=n,0===qr&&Vr(c)),f!==n?(Lr=t,t=r=x(a,h)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n}else Dr=t,t=n;else Dr=t,t=n}else Dr=t,t=n;else Dr=t,t=n;return t}())===n&&(t=function(){var t,r,i,s,a,o,h;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if(e.substr(Dr,5)===T?(i=T,Dr+=5):(i=n,0===qr&&Vr(A)),i!==n){for(s=[],a=Zr();a!==n;)s.push(a),a=Zr();if(s!==n)if((a=oi())!==n){for(o=[],h=Zr();h!==n;)o.push(h),h=Zr();o!==n?(46===e.charCodeAt(Dr)?(h=u,Dr++):(h=n,0===qr&&Vr(c)),h!==n?(Lr=t,t=r=N(a)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n}else Dr=t,t=n;else Dr=t,t=n;return t}())===n&&(t=function(){var t,r,i,s,a,o,h,l,u,c,f,d;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if(F.test(e.charAt(Dr))?(i=e.charAt(Dr),Dr++):(i=n,0===qr&&Vr(U)),i!==n)if(D.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(L)),s!==n)if(j.test(e.charAt(Dr))?(a=e.charAt(Dr),Dr++):(a=n,0===qr&&Vr(S)),a!==n)if(M.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(P)),o!==n)if(B.test(e.charAt(Dr))?(h=e.charAt(Dr),Dr++):(h=n,0===qr&&Vr(q)),h!==n)if($.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(H)),l!==n){for(u=[],c=Zr();c!==n;)u.push(c),c=Zr();if(u!==n)if((c=li())!==n){for(f=[],d=Zr();d!==n;)f.push(d),d=Zr();f!==n&&(d=oi())!==n?(Lr=t,t=r=x(c,d)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n}else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;return t}())===n&&(t=function(){var t,r,i,s,a,o,h,l;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if(E.test(e.charAt(Dr))?(i=e.charAt(Dr),Dr++):(i=n,0===qr&&Vr(R)),i!==n)if(k.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(I)),s!==n)if(C.test(e.charAt(Dr))?(a=e.charAt(Dr),Dr++):(a=n,0===qr&&Vr(O)),a!==n)if(j.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(S)),o!==n){for(h=[],l=Zr();l!==n;)h.push(l),l=Zr();h!==n&&(l=oi())!==n?(Lr=t,t=r=N(l)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;return t}()),t}())===n)if(t=Dr,(r=function(){var t,e,r;return t=Dr,(e=function(){var t,e;return t=Dr,(e=ii())!==n&&(Lr=t,e=nt(e)),(t=e)===n&&(t=ai())===n&&(t=si()),t}())!==n&&(r=Jr())!==n?(Lr=t,t=e=X(e,r)):(Dr=t,t=n),t===n&&(t=Dr,(e=ri())!==n?((r=Jr())===n&&(r=null),r!==n?(Lr=t,t=e=z(e,r)):(Dr=t,t=n)):(Dr=t,t=n)),t}())!==n){for(i=[],s=Zr();s!==n;)i.push(s),s=Zr();i!==n?(46===e.charCodeAt(Dr)?(s=u,Dr++):(s=n,0===qr&&Vr(c)),s!==n?(Lr=t,t=r=f(r)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;return t}function Zr(){var t;return(t=function(){var t;return hr.test(e.charAt(Dr))?(t=e.charAt(Dr),Dr++):(t=n,0===qr&&Vr(lr)),t}())===n&&(t=function(){var t,r,i,s;if(t=Dr,35===e.charCodeAt(Dr)?(r=d,Dr++):(r=n,0===qr&&Vr(p)),r!==n){for(i=[],g.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(m));s!==n;)i.push(s),g.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(m));i!==n?(10===e.charCodeAt(Dr)?(s=w,Dr++):(s=n,0===qr&&Vr(y)),s!==n?(Lr=t,t=r=b(i)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;return t}()),t}function Jr(){var t,r,i,s,a,o,h,l,u,c;if(t=Dr,(r=ti())!==n)if((i=Kr())!==n){for(s=[],a=Dr,o=[],h=Zr();h!==n;)o.push(h),h=Zr();for(o!==n?(59===e.charCodeAt(Dr)?(h=Q,Dr++):(h=n,0===qr&&Vr(V)),h!==n?(l=Dr,(u=ti())!==n&&(c=Kr())!==n?(Lr=l,l=u=G(r,i,u,c)):(Dr=l,l=n),l===n&&(l=null),l!==n?(Lr=a,a=o=W(r,i,l)):(Dr=a,a=n)):(Dr=a,a=n)):(Dr=a,a=n);a!==n;){for(s.push(a),a=Dr,o=[],h=Zr();h!==n;)o.push(h),h=Zr();o!==n?(59===e.charCodeAt(Dr)?(h=Q,Dr++):(h=n,0===qr&&Vr(V)),h!==n?(l=Dr,(u=ti())!==n&&(c=Kr())!==n?(Lr=l,l=u=G(r,i,u,c)):(Dr=l,l=n),l===n&&(l=null),l!==n?(Lr=a,a=o=W(r,i,l)):(Dr=a,a=n)):(Dr=a,a=n)):(Dr=a,a=n)}s!==n?(Lr=t,t=r=Y(r,i,s)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n;return t}function Kr(){var t,r,i,s,a,o,h;if(t=Dr,(r=ei())!==n){for(i=[],s=Dr,a=[],o=Zr();o!==n;)a.push(o),o=Zr();for(a!==n?(44===e.charCodeAt(Dr)?(o=Z,Dr++):(o=n,0===qr&&Vr(J)),o!==n&&(h=ei())!==n?(Lr=s,s=a=K(r,h)):(Dr=s,s=n)):(Dr=s,s=n);s!==n;){for(i.push(s),s=Dr,a=[],o=Zr();o!==n;)a.push(o),o=Zr();a!==n?(44===e.charCodeAt(Dr)?(o=Z,Dr++):(o=n,0===qr&&Vr(J)),o!==n&&(h=ei())!==n?(Lr=s,s=a=K(r,h)):(Dr=s,s=n)):(Dr=s,s=n)}i!==n?(Lr=t,t=r=tt(r,i)):(Dr=t,t=n)}else Dr=t,t=n;return t}function ti(){var t,r,i;if(t=Dr,(r=function(){var t,e,r;for(t=Dr,e=[],r=Zr();r!==n;)e.push(r),r=Zr();return e!==n&&(r=si())!==n?(Lr=t,t=e=f(r)):(Dr=t,t=n),t}())!==n&&(Lr=t,r=f(r)),(t=r)===n){for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();r!==n?(97===e.charCodeAt(Dr)?(i=et,Dr++):(i=n,0===qr&&Vr(rt)),i!==n?(Lr=t,t=r=it()):(Dr=t,t=n)):(Dr=t,t=n)}return t}function ei(){var t,r;return(t=function(){var t;return(t=function(){var t,r,i,s,a,o,h;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if((i=ni())!==n){for(s=[],a=Zr();a!==n;)s.push(a),a=Zr();s!==n&&(a=function(){var t,r,i,s,a,o,h,l;if(t=Dr,64===e.charCodeAt(Dr)?(r=Xt,Dr++):(r=n,0===qr&&Vr(zt)),r!==n){if(i=[],Qt.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(Vt)),s!==n)for(;s!==n;)i.push(s),Qt.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(Vt));else i=n;if(i!==n){if(s=[],a=Dr,45===e.charCodeAt(Dr)?(o=Gt,Dr++):(o=n,0===qr&&Vr(Wt)),o!==n){if(h=[],Yt.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Zt)),l!==n)for(;l!==n;)h.push(l),Yt.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Zt));else h=n;h!==n?(Lr=a,a=o=Jt(i,h)):(Dr=a,a=n)}else Dr=a,a=n;for(;a!==n;)if(s.push(a),a=Dr,45===e.charCodeAt(Dr)?(o=Gt,Dr++):(o=n,0===qr&&Vr(Wt)),o!==n){if(h=[],Yt.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Zt)),l!==n)for(;l!==n;)h.push(l),Yt.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Zt));else h=n;h!==n?(Lr=a,a=o=Jt(i,h)):(Dr=a,a=n)}else Dr=a,a=n;s!==n?(Lr=t,t=r=Kt(i,s)):(Dr=t,t=n)}else Dr=t,t=n}else Dr=t,t=n;return t}())!==n?(Lr=t,t=r=wt(i,a)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n;if(t===n){for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if((i=ni())!==n){for(s=[],a=Zr();a!==n;)s.push(a),a=Zr();if(s!==n)if(e.substr(Dr,2)===yt?(a=yt,Dr+=2):(a=n,0===qr&&Vr(bt)),a!==n){for(o=[],h=Zr();h!==n;)o.push(h),h=Zr();o!==n&&(h=si())!==n?(Lr=t,t=r=vt(i,h)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n}else Dr=t,t=n;else Dr=t,t=n;if(t===n){for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();r!==n&&(i=ni())!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n)}}return t}())===n&&(t=function(){var t,r,i;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();return r!==n?((i=function(){var t,r,i,s,a,o,h,l,f;if(t=Dr,r=Dr,i=Dr,te.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ee)),s===n&&(s=null),s!==n){if(a=Dr,o=[],$t.test(e.charAt(Dr))?(h=e.charAt(Dr),Dr++):(h=n,0===qr&&Vr(Ht)),h!==n)for(;h!==n;)o.push(h),$t.test(e.charAt(Dr))?(h=e.charAt(Dr),Dr++):(h=n,0===qr&&Vr(Ht));else o=n;if(o!==n)if(46===e.charCodeAt(Dr)?(h=u,Dr++):(h=n,0===qr&&Vr(c)),h!==n){for(l=[],$t.test(e.charAt(Dr))?(f=e.charAt(Dr),Dr++):(f=n,0===qr&&Vr(Ht));f!==n;)l.push(f),$t.test(e.charAt(Dr))?(f=e.charAt(Dr),Dr++):(f=n,0===qr&&Vr(Ht));l!==n&&(f=ui())!==n?a=o=[o,h,l,f]:(Dr=a,a=n)}else Dr=a,a=n;else Dr=a,a=n;if(a===n){if(a=Dr,46===e.charCodeAt(Dr)?(o=u,Dr++):(o=n,0===qr&&Vr(c)),o!==n){if(h=[],$t.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Ht)),l!==n)for(;l!==n;)h.push(l),$t.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Ht));else h=n;h!==n&&(l=ui())!==n?a=o=[o,h,l]:(Dr=a,a=n)}else Dr=a,a=n;if(a===n){if(a=Dr,o=[],$t.test(e.charAt(Dr))?(h=e.charAt(Dr),Dr++):(h=n,0===qr&&Vr(Ht)),h!==n)for(;h!==n;)o.push(h),$t.test(e.charAt(Dr))?(h=e.charAt(Dr),Dr++):(h=n,0===qr&&Vr(Ht));else o=n;o!==n&&(h=ui())!==n?a=o=[o,h]:(Dr=a,a=n)}}a!==n?i=s=[s,a]:(Dr=i,i=n)}else Dr=i,i=n;return(r=i!==n?e.substring(r,Dr):i)!==n&&(Lr=t,r=ne(r)),r}())===n&&(i=function(){var t,r,i,s,a,o,h,l;if(t=Dr,r=Dr,i=Dr,te.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ee)),s===n&&(s=null),s!==n){for(a=[],$t.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(Ht));o!==n;)a.push(o),$t.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(Ht));if(a!==n)if(46===e.charCodeAt(Dr)?(o=u,Dr++):(o=n,0===qr&&Vr(c)),o!==n){if(h=[],$t.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Ht)),l!==n)for(;l!==n;)h.push(l),$t.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Ht));else h=n;h!==n?i=s=[s,a,o,h]:(Dr=i,i=n)}else Dr=i,i=n;else Dr=i,i=n}else Dr=i,i=n;return(r=i!==n?e.substring(r,Dr):i)!==n&&(Lr=t,r=ie(r)),r}())===n&&(i=function(){var t,r,i,s,a,o;if(t=Dr,r=Dr,i=Dr,te.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ee)),s===n&&(s=null),s!==n){if(a=[],$t.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(Ht)),o!==n)for(;o!==n;)a.push(o),$t.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(Ht));else a=n;a!==n?i=s=[s,a]:(Dr=i,i=n)}else Dr=i,i=n;return(r=i!==n?e.substring(r,Dr):i)!==n&&(Lr=t,r=re(r)),r}()),i!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n)):(Dr=t,t=n),t}())===n&&(t=function(){var t,r,i;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n?(e.substr(Dr,4)===_t?(i=_t,Dr+=4):(i=n,0===qr&&Vr(xt)),i!==n?(Lr=t,t=r=Tt()):(Dr=t,t=n)):(Dr=t,t=n),t===n){for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();r!==n?(e.substr(Dr,5)===At?(i=At,Dr+=5):(i=n,0===qr&&Vr(Nt)),i!==n?(Lr=t,t=r=Et()):(Dr=t,t=n)):(Dr=t,t=n)}return t}()),t}())===n&&(t=Dr,(r=ii())!==n&&(Lr=t,r=st(r)),(t=r)===n&&(t=Dr,(r=ai())!==n&&(Lr=t,r=at(r)),(t=r)===n&&(t=Dr,(r=ri())!==n&&(Lr=t,r=f(r)),(t=r)===n&&(t=Dr,(r=si())!==n&&(Lr=t,r=ot(r)),t=r)))),t}function ri(){var t,r,i,s,a,o;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if(91===e.charCodeAt(Dr)?(i=ht,Dr++):(i=n,0===qr&&Vr(lt)),i!==n)if((s=Jr())!==n){for(a=[],o=Zr();o!==n;)a.push(o),o=Zr();a!==n?(93===e.charCodeAt(Dr)?(o=ut,Dr++):(o=n,0===qr&&Vr(ct)),o!==n?(Lr=t,t=r=f(s)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;return t}function ii(){var t,r,i,s,a,o;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if(40===e.charCodeAt(Dr)?(i=ft,Dr++):(i=n,0===qr&&Vr(dt)),i!==n){for(s=[],a=ei();a!==n;)s.push(a),a=ei();if(s!==n){for(a=[],o=Zr();o!==n;)a.push(o),o=Zr();a!==n?(41===e.charCodeAt(Dr)?(o=pt,Dr++):(o=n,0===qr&&Vr(gt)),o!==n?(Lr=t,t=r=mt(s)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n}else Dr=t,t=n;else Dr=t,t=n;return t}function ni(){var t,r,i;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();return r!==n?((i=function(){var t,r,i,s,a,o,h,l;if(t=Dr,e.substr(Dr,3)===ge?(r=ge,Dr+=3):(r=n,0===qr&&Vr(me)),r!==n){for(i=[],we.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ye)),s===n&&(s=fi())===n&&(s=ci());s!==n;)i.push(s),we.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ye)),s===n&&(s=fi())===n&&(s=ci());if(i!==n){if(s=[],a=Dr,e.substr(Dr,2)===be?(o=be,Dr+=2):(o=n,0===qr&&Vr(ve)),o!==n){if(h=[],we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=_e(i,h)):(Dr=a,a=n)}else Dr=a,a=n;if(a===n)if(a=Dr,39===e.charCodeAt(Dr)?(o=ce,Dr++):(o=n,0===qr&&Vr(fe)),o!==n){if(h=[],we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=xe(i,h)):(Dr=a,a=n)}else Dr=a,a=n;for(;a!==n;){if(s.push(a),a=Dr,e.substr(Dr,2)===be?(o=be,Dr+=2):(o=n,0===qr&&Vr(ve)),o!==n){if(h=[],we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=_e(i,h)):(Dr=a,a=n)}else Dr=a,a=n;if(a===n)if(a=Dr,39===e.charCodeAt(Dr)?(o=ce,Dr++):(o=n,0===qr&&Vr(fe)),o!==n){if(h=[],we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=xe(i,h)):(Dr=a,a=n)}else Dr=a,a=n}s!==n?(e.substr(Dr,3)===ge?(a=ge,Dr+=3):(a=n,0===qr&&Vr(me)),a!==n?(Lr=t,t=r=Te(i,s)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n}else Dr=t,t=n;return t}())===n&&(i=function(){var t,r,i,s,a,o,h,l;if(t=Dr,e.substr(Dr,3)===Ae?(r=Ae,Dr+=3):(r=n,0===qr&&Vr(Ne)),r!==n){for(i=[],Ee.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(Re)),s===n&&(s=fi())===n&&(s=ci());s!==n;)i.push(s),Ee.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(Re)),s===n&&(s=fi())===n&&(s=ci());if(i!==n){if(s=[],a=Dr,e.substr(Dr,2)===ke?(o=ke,Dr+=2):(o=n,0===qr&&Vr(Ie)),o!==n){if(h=[],Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=Ce(i,h)):(Dr=a,a=n)}else Dr=a,a=n;if(a===n)if(a=Dr,34===e.charCodeAt(Dr)?(o=oe,Dr++):(o=n,0===qr&&Vr(he)),o!==n){if(h=[],Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=Oe(i,h)):(Dr=a,a=n)}else Dr=a,a=n;for(;a!==n;){if(s.push(a),a=Dr,e.substr(Dr,2)===ke?(o=ke,Dr+=2):(o=n,0===qr&&Vr(Ie)),o!==n){if(h=[],Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=Ce(i,h)):(Dr=a,a=n)}else Dr=a,a=n;if(a===n)if(a=Dr,34===e.charCodeAt(Dr)?(o=oe,Dr++):(o=n,0===qr&&Vr(he)),o!==n){if(h=[],Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=Oe(i,h)):(Dr=a,a=n)}else Dr=a,a=n}s!==n?(e.substr(Dr,3)===Ae?(a=Ae,Dr+=3):(a=n,0===qr&&Vr(Ne)),a!==n?(Lr=t,t=r=Te(i,s)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n}else Dr=t,t=n;return t}())===n&&(i=function(){var t,r,i,s;if(t=Dr,39===e.charCodeAt(Dr)?(r=ce,Dr++):(r=n,0===qr&&Vr(fe)),r!==n){for(i=[],de.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(pe)),s===n&&(s=fi())===n&&(s=ci());s!==n;)i.push(s),de.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(pe)),s===n&&(s=fi())===n&&(s=ci());i!==n?(39===e.charCodeAt(Dr)?(s=ce,Dr++):(s=n,0===qr&&Vr(fe)),s!==n?(Lr=t,t=r=b(i)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;return t}())===n&&(i=function(){var t,r,i,s;if(t=Dr,34===e.charCodeAt(Dr)?(r=oe,Dr++):(r=n,0===qr&&Vr(he)),r!==n){for(i=[],le.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ue)),s===n&&(s=fi())===n&&(s=ci());s!==n;)i.push(s),le.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ue)),s===n&&(s=fi())===n&&(s=ci());i!==n?(34===e.charCodeAt(Dr)?(s=oe,Dr++):(s=n,0===qr&&Vr(he)),s!==n?(Lr=t,t=r=b(i)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;return t}()),i!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n)):(Dr=t,t=n),t}function si(){var t,r,i;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n&&(i=oi())!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n),t===n){for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();r!==n&&(i=function(){var t,r;return(t=function(){var t,r,i;return t=Dr,(r=hi())!==n&&(i=function(){var t,r,i,s,a,o,h,l;if(t=Dr,(r=pi())===n&&(58===e.charCodeAt(Dr)?(r=Ut,Dr++):(r=n,0===qr&&Vr(Dt)),r===n&&($t.test(e.charAt(Dr))?(r=e.charAt(Dr),Dr++):(r=n,0===qr&&Vr(Ht)),r===n&&(r=wi()))),r!==n){for(i=[],(s=gi())===n&&(58===e.charCodeAt(Dr)?(s=Ut,Dr++):(s=n,0===qr&&Vr(Dt)),s===n&&(s=wi()));s!==n;)i.push(s),(s=gi())===n&&(58===e.charCodeAt(Dr)?(s=Ut,Dr++):(s=n,0===qr&&Vr(Dt)),s===n&&(s=wi()));if(i!==n){if(s=[],a=Dr,o=[],46===e.charCodeAt(Dr)?(h=u,Dr++):(h=n,0===qr&&Vr(c)),h!==n)for(;h!==n;)o.push(h),46===e.charCodeAt(Dr)?(h=u,Dr++):(h=n,0===qr&&Vr(c));else o=n;if(o!==n){if(h=[],(l=gi())===n&&(58===e.charCodeAt(Dr)?(l=Ut,Dr++):(l=n,0===qr&&Vr(Dt)),l===n&&(l=wi())),l!==n)for(;l!==n;)h.push(l),(l=gi())===n&&(58===e.charCodeAt(Dr)?(l=Ut,Dr++):(l=n,0===qr&&Vr(Dt)),l===n&&(l=wi()));else h=n;h!==n?(Lr=a,a=o=Er(r,i,o,h)):(Dr=a,a=n)}else Dr=a,a=n;for(;a!==n;){if(s.push(a),a=Dr,o=[],46===e.charCodeAt(Dr)?(h=u,Dr++):(h=n,0===qr&&Vr(c)),h!==n)for(;h!==n;)o.push(h),46===e.charCodeAt(Dr)?(h=u,Dr++):(h=n,0===qr&&Vr(c));else o=n;if(o!==n){if(h=[],(l=gi())===n&&(58===e.charCodeAt(Dr)?(l=Ut,Dr++):(l=n,0===qr&&Vr(Dt)),l===n&&(l=wi())),l!==n)for(;l!==n;)h.push(l),(l=gi())===n&&(58===e.charCodeAt(Dr)?(l=Ut,Dr++):(l=n,0===qr&&Vr(Dt)),l===n&&(l=wi()));else h=n;h!==n?(Lr=a,a=o=Er(r,i,o,h)):(Dr=a,a=n)}else Dr=a,a=n}s!==n?(Lr=t,t=r=Rr(r,i,s)):(Dr=t,t=n)}else Dr=t,t=n}else Dr=t,t=n;return t}())!==n?(Lr=t,t=r=Pt(r,i)):(Dr=t,t=n),t}())===n&&(t=Dr,(r=hi())!==n&&(Lr=t,r=Rt(r)),t=r),t}())!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n)}return t}function ai(){var t,r,i;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n&&(i=function(){var t,r,i,s,a,o,h,l,f,d;if(t=Dr,r=Dr,e.substr(Dr,2)===Bt?(i=Bt,Dr+=2):(i=n,0===qr&&Vr(qt)),i!==n)if((s=pi())===n&&($t.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(Ht))),s!==n){for(a=[],o=gi();o!==n;)a.push(o),o=gi();if(a!==n){if(o=[],h=Dr,l=[],46===e.charCodeAt(Dr)?(f=u,Dr++):(f=n,0===qr&&Vr(c)),f!==n)for(;f!==n;)l.push(f),46===e.charCodeAt(Dr)?(f=u,Dr++):(f=n,0===qr&&Vr(c));else l=n;if(l!==n){if(f=[],(d=gi())!==n)for(;d!==n;)f.push(d),d=gi();else f=n;f!==n?h=l=[l,f]:(Dr=h,h=n)}else Dr=h,h=n;for(;h!==n;){if(o.push(h),h=Dr,l=[],46===e.charCodeAt(Dr)?(f=u,Dr++):(f=n,0===qr&&Vr(c)),f!==n)for(;f!==n;)l.push(f),46===e.charCodeAt(Dr)?(f=u,Dr++):(f=n,0===qr&&Vr(c));else l=n;if(l!==n){if(f=[],(d=gi())!==n)for(;d!==n;)f.push(d),d=gi();else f=n;f!==n?h=l=[l,f]:(Dr=h,h=n)}else Dr=h,h=n}o!==n?r=i=[i,s,a,o]:(Dr=r,r=n)}else Dr=r,r=n}else Dr=r,r=n;else Dr=r,r=n;return r!==n?e.substring(t,Dr):r}())!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n),t===n){for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();r!==n&&(i=function(){var t,r,i,s;if(t=Dr,91===e.charCodeAt(Dr)?(r=ht,Dr++):(r=n,0===qr&&Vr(lt)),r!==n){for(i=[],s=Zr();s!==n;)i.push(s),s=Zr();i!==n?(93===e.charCodeAt(Dr)?(s=ut,Dr++):(s=n,0===qr&&Vr(ct)),s!==n?(Lr=t,t=r=ur()):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;return t}())!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n)}return t}function oi(){var t,r,i,s;if(t=Dr,60===e.charCodeAt(Dr)?(r=kt,Dr++):(r=n,0===qr&&Vr(It)),r!==n){for(i=[],Ct.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(Ot)),s===n&&(s=ci());s!==n;)i.push(s),Ct.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(Ot)),s===n&&(s=ci());i!==n?(62===e.charCodeAt(Dr)?(s=jt,Dr++):(s=n,0===qr&&Vr(St)),s!==n?(Lr=t,t=r=Ft(i)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;return t}function hi(){var t,r,i;return t=Dr,(r=mi())===n&&(r=null),r!==n?(58===e.charCodeAt(Dr)?(i=Ut,Dr++):(i=n,0===qr&&Vr(Dt)),i!==n?(Lr=t,t=r=Lt(r)):(Dr=t,t=n)):(Dr=t,t=n),t}function li(){var t,r,i;return t=Dr,(r=mi())===n&&(r=null),r!==n?(58===e.charCodeAt(Dr)?(i=Ut,Dr++):(i=n,0===qr&&Vr(Dt)),i!==n?(Lr=t,t=r=Mt(r)):(Dr=t,t=n)):(Dr=t,t=n),t}function ui(){var t,r,i,s,a,o;if(t=Dr,r=Dr,se.test(e.charAt(Dr))?(i=e.charAt(Dr),Dr++):(i=n,0===qr&&Vr(ae)),i!==n)if(te.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ee)),s===n&&(s=null),s!==n){if(a=[],$t.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(Ht)),o!==n)for(;o!==n;)a.push(o),$t.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(Ht));else a=n;a!==n?r=i=[i,s,a]:(Dr=r,r=n)}else Dr=r,r=n;else Dr=r,r=n;return r!==n?e.substring(t,Dr):r}function ci(){var t,r,i,s,a,o,h,l,u,c,f;return t=Dr,e.substr(Dr,2)===je?(r=je,Dr+=2):(r=n,0===qr&&Vr(Se)),r!==n?(i=Dr,(s=yi())!==n&&(a=yi())!==n&&(o=yi())!==n&&(h=yi())!==n&&(l=yi())!==n&&(u=yi())!==n&&(c=yi())!==n&&(f=yi())!==n?i=s=[s,a,o,h,l,u,c,f]:(Dr=i,i=n),i!==n?(Lr=t,t=r=Fe(i)):(Dr=t,t=n)):(Dr=t,t=n),t===n&&(t=Dr,e.substr(Dr,2)===Ue?(r=Ue,Dr+=2):(r=n,0===qr&&Vr(De)),r!==n?(i=Dr,(s=yi())!==n&&(a=yi())!==n&&(o=yi())!==n&&(h=yi())!==n?i=s=[s,a,o,h]:(Dr=i,i=n),i!==n?(Lr=t,t=r=Le(i)):(Dr=t,t=n)):(Dr=t,t=n)),t}function fi(){var t,r;return t=Dr,e.substr(Dr,2)===Me?(r=Me,Dr+=2):(r=n,0===qr&&Vr(Pe)),r!==n&&(Lr=t,r=Be()),(t=r)===n&&(t=Dr,e.substr(Dr,2)===qe?(r=qe,Dr+=2):(r=n,0===qr&&Vr($e)),r!==n&&(Lr=t,r=He()),(t=r)===n&&(t=Dr,e.substr(Dr,2)===Xe?(r=Xe,Dr+=2):(r=n,0===qr&&Vr(ze)),r!==n&&(Lr=t,r=Qe()),(t=r)===n&&(t=Dr,e.substr(Dr,2)===Ve?(r=Ve,Dr+=2):(r=n,0===qr&&Vr(Ge)),r!==n&&(Lr=t,r=We()),(t=r)===n&&(t=Dr,e.substr(Dr,2)===Ye?(r=Ye,Dr+=2):(r=n,0===qr&&Vr(Ze)),r!==n&&(Lr=t,r=Je()),(t=r)===n&&(t=Dr,e.substr(Dr,2)===Ke?(r=Ke,Dr+=2):(r=n,0===qr&&Vr(tr)),r!==n&&(Lr=t,r=er()),(t=r)===n&&(t=Dr,e.substr(Dr,2)===rr?(r=rr,Dr+=2):(r=n,0===qr&&Vr(ir)),r!==n&&(Lr=t,r=nr()),(t=r)===n&&(t=Dr,e.substr(Dr,2)===sr?(r=sr,Dr+=2):(r=n,0===qr&&Vr(ar)),r!==n&&(Lr=t,r=or()),t=r))))))),t}function di(){var t,r,i;return t=Dr,cr.test(e.charAt(Dr))?(r=e.charAt(Dr),Dr++):(r=n,0===qr&&Vr(fr)),r!==n?(dr.test(e.charAt(Dr))?(i=e.charAt(Dr),Dr++):(i=n,0===qr&&Vr(pr)),i!==n?(Lr=t,t=r=gr(r,i)):(Dr=t,t=n)):(Dr=t,t=n),t===n&&(mr.test(e.charAt(Dr))?(t=e.charAt(Dr),Dr++):(t=n,0===qr&&Vr(wr))),t}function pi(){var t;return(t=di())===n&&(95===e.charCodeAt(Dr)?(t=yr,Dr++):(t=n,0===qr&&Vr(br))),t}function gi(){var t;return(t=pi())===n&&(45===e.charCodeAt(Dr)?(t=Gt,Dr++):(t=n,0===qr&&Vr(Wt)),t===n&&($t.test(e.charAt(Dr))?(t=e.charAt(Dr),Dr++):(t=n,0===qr&&Vr(Ht)),t===n&&(183===e.charCodeAt(Dr)?(t=vr,Dr++):(t=n,0===qr&&Vr(_r)),t===n&&(xr.test(e.charAt(Dr))?(t=e.charAt(Dr),Dr++):(t=n,0===qr&&Vr(Tr)),t===n&&(Ar.test(e.charAt(Dr))?(t=e.charAt(Dr),Dr++):(t=n,0===qr&&Vr(Nr))))))),t}function mi(){var t,r,i,s,a,o,h,l,f;if(t=Dr,r=Dr,(i=di())!==n){for(s=[],a=gi();a!==n;)s.push(a),a=gi();if(s!==n){if(a=[],o=Dr,h=[],46===e.charCodeAt(Dr)?(l=u,Dr++):(l=n,0===qr&&Vr(c)),l!==n)for(;l!==n;)h.push(l),46===e.charCodeAt(Dr)?(l=u,Dr++):(l=n,0===qr&&Vr(c));else h=n;if(h!==n){if(l=[],(f=gi())!==n)for(;f!==n;)l.push(f),f=gi();else l=n;l!==n?o=h=[h,l]:(Dr=o,o=n)}else Dr=o,o=n;for(;o!==n;){if(a.push(o),o=Dr,h=[],46===e.charCodeAt(Dr)?(l=u,Dr++):(l=n,0===qr&&Vr(c)),l!==n)for(;l!==n;)h.push(l),46===e.charCodeAt(Dr)?(l=u,Dr++):(l=n,0===qr&&Vr(c));else h=n;if(h!==n){if(l=[],(f=gi())!==n)for(;f!==n;)l.push(f),f=gi();else l=n;l!==n?o=h=[h,l]:(Dr=o,o=n)}else Dr=o,o=n}a!==n?r=i=[i,s,a]:(Dr=r,r=n)}else Dr=r,r=n}else Dr=r,r=n;return r!==n?e.substring(t,Dr):r}function wi(){var t;return(t=function(){var t,r,i,s,a;return t=Dr,r=Dr,37===e.charCodeAt(Dr)?(i=kr,Dr++):(i=n,0===qr&&Vr(Ir)),i!==n&&(s=yi())!==n&&(a=yi())!==n?r=i=[i,s,a]:(Dr=r,r=n),r!==n?e.substring(t,Dr):r}())===n&&(t=function(){var t,r,i;return t=Dr,92===e.charCodeAt(Dr)?(r=jr,Dr++):(r=n,0===qr&&Vr(Sr)),r!==n?(Fr.test(e.charAt(Dr))?(i=e.charAt(Dr),Dr++):(i=n,0===qr&&Vr(Ur)),i!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n)):(Dr=t,t=n),t}()),t}function yi(){var t;return Cr.test(e.charAt(Dr))?(t=e.charAt(Dr),Dr++):(t=n,0===qr&&Vr(Or)),t}var bi,vi,_i,xi=function(t){return t.match(/^[a-z](.*?):(.+?)/g)},Ti={base:[],data:{},addBase:function(t){if(0===Ti.base.length)return void Ti.base.push(t);const e=Ti.base[Ti.base.length-1];e!==t&&Ti.base.push(new URL(t,e).toString())},addPrefix:function(t,e){const r=Ti.data[t];void 0===r?Ti.data[t]=[{uri:e,count:0}]:r[r.length-1].uri!==e&&r.push({uri:e,count:0})},hasPrefix:function(t){return void 0!==this.data[t]},resolve:function(t,e){const i=Object.keys(Ti.data).find((e=>0===t.indexOf(e+":")));if(void 0!==i){const r=Ti.data[i];if(1===r.length&&!0!==e&&xi(r[0].uri))return t;const n=r[r.length-1].uri;return t.replace(i+":",n)}var n=0===Ti.base.length?r.baseIRI:Ti.base[Ti.base.length-1];return!n||t.match(/^(http:|https:|urn:|file:)/)?t:0===t.indexOf("//")&&n?n.split("//")[0]+t:new URL(t,n).toString()},increment:function(t){const e=Ti.data[t];void 0!==e&&e[e.length-1].count++},decrement:function(t){const e=Ti.data[t];void 0!==e&&e[e.length-1].count--},toJSON:function(){const t={};return Ti.base.length>0&&(void 0===t["@context"]&&(t["@context"]={}),t["@context"]["@base"]=Ti.base[0]),Object.keys(Ti.data).forEach((e=>{const r=Ti.data[e][0];"http://www.w3.org/2001/XMLSchema#"===r.uri&&r.count<1||xi(r.uri)&&(void 0===t["@context"]&&(t["@context"]={}),t["@context"][e]=r.uri)})),t}};function Ai(t,e){if(void 0===t["@list"])return t;if(!e&&!t["@list"].find((t=>void 0!==t["@list"])))return t;if(0===t["@list"].length)return{"@id":"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"};var r={},i=null;return t["@list"].forEach((t=>{null===i?i=r:(i["http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"]={},i=i["http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"]),i["http://www.w3.org/1999/02/22-rdf-syntax-ns#first"]=Ai(t,!0),i["http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"]={"@id":"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"}})),r}if((i=a())!==n&&Dr===e.length)return i;throw i!==n&&Dr<e.length&&Vr({type:"end"}),bi=Br,vi=Pr<e.length?e.charAt(Pr):null,_i=Pr<e.length?Qr(Pr,Pr+1):Qr(Pr,Pr),new t(t.buildMessage(bi,vi),bi,vi,_i)}}})?r.apply(e,[]):r)||(t.exports=i)},2313:(t,e,r)=>{"use strict";const i=r(2504),n=r(9029),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.hp=h,e.IS=50;const a=2147483647;function o(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,h.prototype),e}function h(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return l(t,e,r)}function l(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!h.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|g(t,e);let i=o(r);const n=i.write(t,e);return n!==r&&(i=i.slice(0,n)),i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(W(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(W(t,ArrayBuffer)||t&&W(t.buffer,ArrayBuffer))return d(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(W(t,SharedArrayBuffer)||t&&W(t.buffer,SharedArrayBuffer)))return d(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return h.from(i,e,r);const n=function(t){if(h.isBuffer(t)){const e=0|p(t.length),r=o(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Y(t.length)?o(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return h.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return u(t),o(t<0?0:0|p(t))}function f(t){const e=t.length<0?0:0|p(t.length),r=o(e);for(let i=0;i<e;i+=1)r[i]=255&t[i];return r}function d(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let i;return i=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(i,h.prototype),i}function p(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||W(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;let n=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(t).length;default:if(n)return i?-1:Q(t).length;e=(""+e).toLowerCase(),n=!0}}function m(t,e,r){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return I(this,e,r);case"base64":return N(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,r);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function w(t,e,r){const i=t[e];t[e]=t[r],t[r]=i}function y(t,e,r,i,n){if(0===t.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof e&&(e=h.from(e,i)),h.isBuffer(e))return 0===e.length?-1:b(t,e,r,i,n);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,i,n);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,i,n){let s,a=1,o=t.length,h=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;a=2,o/=2,h/=2,r/=2}function l(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(n){let i=-1;for(s=r;s<o;s++)if(l(t,s)===l(e,-1===i?0:s-i)){if(-1===i&&(i=s),s-i+1===h)return i*a}else-1!==i&&(s-=s-i),i=-1}else for(r+h>o&&(r=o-h),s=r;s>=0;s--){let r=!0;for(let i=0;i<h;i++)if(l(t,s+i)!==l(e,i)){r=!1;break}if(r)return s}return-1}function v(t,e,r,i){r=Number(r)||0;const n=t.length-r;i?(i=Number(i))>n&&(i=n):i=n;const s=e.length;let a;for(i>s/2&&(i=s/2),a=0;a<i;++a){const i=parseInt(e.substr(2*a,2),16);if(Y(i))return a;t[r+a]=i}return a}function _(t,e,r,i){return G(Q(e,t.length-r),t,r,i)}function x(t,e,r,i){return G(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,i)}function T(t,e,r,i){return G(V(e),t,r,i)}function A(t,e,r,i){return G(function(t,e){let r,i,n;const s=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),i=r>>8,n=r%256,s.push(n),s.push(i);return s}(e,t.length-r),t,r,i)}function N(t,e,r){return 0===e&&r===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);const i=[];let n=e;for(;n<r;){const e=t[n];let s=null,a=e>239?4:e>223?3:e>191?2:1;if(n+a<=r){let r,i,o,h;switch(a){case 1:e<128&&(s=e);break;case 2:r=t[n+1],128==(192&r)&&(h=(31&e)<<6|63&r,h>127&&(s=h));break;case 3:r=t[n+1],i=t[n+2],128==(192&r)&&128==(192&i)&&(h=(15&e)<<12|(63&r)<<6|63&i,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:r=t[n+1],i=t[n+2],o=t[n+3],128==(192&r)&&128==(192&i)&&128==(192&o)&&(h=(15&e)<<18|(63&r)<<12|(63&i)<<6|63&o,h>65535&&h<1114112&&(s=h))}}null===s?(s=65533,a=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|1023&s),i.push(s),n+=a}return function(t){const e=t.length;if(e<=R)return String.fromCharCode.apply(String,t);let r="",i=0;for(;i<e;)r+=String.fromCharCode.apply(String,t.slice(i,i+=R));return r}(i)}h.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),h.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||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."),Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}}),h.poolSize=8192,h.from=function(t,e,r){return l(t,e,r)},Object.setPrototypeOf(h.prototype,Uint8Array.prototype),Object.setPrototypeOf(h,Uint8Array),h.alloc=function(t,e,r){return function(t,e,r){return u(t),t<=0?o(t):void 0!==e?"string"==typeof r?o(t).fill(e,r):o(t).fill(e):o(t)}(t,e,r)},h.allocUnsafe=function(t){return c(t)},h.allocUnsafeSlow=function(t){return c(t)},h.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==h.prototype},h.compare=function(t,e){if(W(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),W(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),!h.isBuffer(t)||!h.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,i=e.length;for(let n=0,s=Math.min(r,i);n<s;++n)if(t[n]!==e[n]){r=t[n],i=e[n];break}return r<i?-1:i<r?1:0},h.isEncoding=function(t){switch(String(t).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}},h.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return h.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const i=h.allocUnsafe(e);let n=0;for(r=0;r<t.length;++r){let e=t[r];if(W(e,Uint8Array))n+e.length>i.length?(h.isBuffer(e)||(e=h.from(e)),e.copy(i,n)):Uint8Array.prototype.set.call(i,e,n);else{if(!h.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(i,n)}n+=e.length}return i},h.byteLength=g,h.prototype._isBuffer=!0,h.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)w(this,e,e+1);return this},h.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)w(this,e,e+3),w(this,e+1,e+2);return this},h.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},h.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?E(this,0,t):m.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){let t="";const r=e.IS;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},s&&(h.prototype[s]=h.prototype.inspect),h.prototype.compare=function(t,e,r,i,n){if(W(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),e<0||r>t.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&e>=r)return 0;if(i>=n)return-1;if(e>=r)return 1;if(this===t)return 0;let s=(n>>>=0)-(i>>>=0),a=(r>>>=0)-(e>>>=0);const o=Math.min(s,a),l=this.slice(i,n),u=t.slice(e,r);for(let t=0;t<o;++t)if(l[t]!==u[t]){s=l[t],a=u[t];break}return s<a?-1:a<s?1:0},h.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},h.prototype.indexOf=function(t,e,r){return y(this,t,e,r,!0)},h.prototype.lastIndexOf=function(t,e,r){return y(this,t,e,r,!1)},h.prototype.write=function(t,e,r,i){if(void 0===e)i="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)i=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}const n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return T(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const R=4096;function k(t,e,r){let i="";r=Math.min(t.length,r);for(let n=e;n<r;++n)i+=String.fromCharCode(127&t[n]);return i}function I(t,e,r){let i="";r=Math.min(t.length,r);for(let n=e;n<r;++n)i+=String.fromCharCode(t[n]);return i}function C(t,e,r){const i=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>i)&&(r=i);let n="";for(let i=e;i<r;++i)n+=Z[t[i]];return n}function O(t,e,r){const i=t.slice(e,r);let n="";for(let t=0;t<i.length-1;t+=2)n+=String.fromCharCode(i[t]+256*i[t+1]);return n}function j(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function S(t,e,r,i,n,s){if(!h.isBuffer(t))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(r+i>t.length)throw new RangeError("Index out of range")}function F(t,e,r,i,n){$(e,i,n,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function U(t,e,r,i,n){$(e,i,n,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s>>=8,t[r+6]=s,s>>=8,t[r+5]=s,s>>=8,t[r+4]=s;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function D(t,e,r,i,n,s){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,r,i,s){return e=+e,r>>>=0,s||D(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function M(t,e,r,i,s){return e=+e,r>>>=0,s||D(t,0,r,8),n.write(t,e,r,i,52,8),r+8}h.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const i=this.subarray(t,e);return Object.setPrototypeOf(i,h.prototype),i},h.prototype.readUintLE=h.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||j(t,e,this.length);let i=this[t],n=1,s=0;for(;++s<e&&(n*=256);)i+=this[t+s]*n;return i},h.prototype.readUintBE=h.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||j(t,e,this.length);let i=this[t+--e],n=1;for(;e>0&&(n*=256);)i+=this[t+--e]*n;return i},h.prototype.readUint8=h.prototype.readUInt8=function(t,e){return t>>>=0,e||j(t,1,this.length),this[t]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||j(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||j(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||j(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||j(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readBigUInt64LE=J((function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||X(t,this.length-8);const i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,n=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(i)+(BigInt(n)<<BigInt(32))})),h.prototype.readBigUInt64BE=J((function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||X(t,this.length-8);const i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],n=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(i)<<BigInt(32))+BigInt(n)})),h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||j(t,e,this.length);let i=this[t],n=1,s=0;for(;++s<e&&(n*=256);)i+=this[t+s]*n;return n*=128,i>=n&&(i-=Math.pow(2,8*e)),i},h.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||j(t,e,this.length);let i=e,n=1,s=this[t+--i];for(;i>0&&(n*=256);)s+=this[t+--i]*n;return n*=128,s>=n&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return t>>>=0,e||j(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||j(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||j(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||j(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||j(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readBigInt64LE=J((function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||X(t,this.length-8);const i=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),h.prototype.readBigInt64BE=J((function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||X(t,this.length-8);const i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),h.prototype.readFloatLE=function(t,e){return t>>>=0,e||j(t,4,this.length),n.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||j(t,4,this.length),n.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||j(t,8,this.length),n.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||j(t,8,this.length),n.read(this,t,!1,52,8)},h.prototype.writeUintLE=h.prototype.writeUIntLE=function(t,e,r,i){t=+t,e>>>=0,r>>>=0,i||S(this,t,e,r,Math.pow(2,8*r)-1,0);let n=1,s=0;for(this[e]=255&t;++s<r&&(n*=256);)this[e+s]=t/n&255;return e+r},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(t,e,r,i){t=+t,e>>>=0,r>>>=0,i||S(this,t,e,r,Math.pow(2,8*r)-1,0);let n=r-1,s=1;for(this[e+n]=255&t;--n>=0&&(s*=256);)this[e+n]=t/s&255;return e+r},h.prototype.writeUint8=h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigUInt64LE=J((function(t,e=0){return F(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeBigUInt64BE=J((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*r-1);S(this,t,e,r,i-1,-i)}let n=0,s=1,a=0;for(this[e]=255&t;++n<r&&(s*=256);)t<0&&0===a&&0!==this[e+n-1]&&(a=1),this[e+n]=(t/s|0)-a&255;return e+r},h.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*r-1);S(this,t,e,r,i-1,-i)}let n=r-1,s=1,a=0;for(this[e+n]=255&t;--n>=0&&(s*=256);)t<0&&0===a&&0!==this[e+n+1]&&(a=1),this[e+n]=(t/s|0)-a&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigInt64LE=J((function(t,e=0){return F(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeBigInt64BE=J((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,i){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);const n=i-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,i):Uint8Array.prototype.set.call(t,this.subarray(r,i),e),n},h.prototype.fill=function(t,e,r,i){if("string"==typeof t){if("string"==typeof e?(i=e,e=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!h.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){const e=t.charCodeAt(0);("utf8"===i&&e<128||"latin1"===i)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let n;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(n=e;n<r;++n)this[n]=t;else{const s=h.isBuffer(t)?t:h.from(t,i),a=s.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(n=0;n<r-e;++n)this[n+e]=s[n%a]}return this};const P={};function B(t,e,r){P[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function q(t){let e="",r=t.length;const i="-"===t[0]?1:0;for(;r>=i+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function $(t,e,r,i,n,s){if(t>r||t<e){const i="bigint"==typeof e?"n":"";let n;throw n=s>3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(s+1)}${i}`:`>= -(2${i} ** ${8*(s+1)-1}${i}) and < 2 ** ${8*(s+1)-1}${i}`:`>= ${e}${i} and <= ${r}${i}`,new P.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){H(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||X(e,t.length-(r+1))}(i,n,s)}function H(t,e){if("number"!=typeof t)throw new P.ERR_INVALID_ARG_TYPE(e,"number",t)}function X(t,e,r){if(Math.floor(t)!==t)throw H(t,r),new P.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new P.ERR_BUFFER_OUT_OF_BOUNDS;throw new P.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}B("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),B("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),B("ERR_OUT_OF_RANGE",(function(t,e,r){let i=`The value of "${t}" is out of range.`,n=r;return Number.isInteger(r)&&Math.abs(r)>2**32?n=q(String(r)):"bigint"==typeof r&&(n=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(n=q(n)),n+="n"),i+=` It must be ${e}. Received ${n}`,i}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function Q(t,e){let r;e=e||1/0;const i=t.length;let n=null;const s=[];for(let a=0;a<i;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(a+1===i){(e-=3)>-1&&s.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function V(t){return i.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,r,i){let n;for(n=0;n<i&&!(n+r>=e.length||n>=t.length);++n)e[n+r]=t[n];return n}function W(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const Z=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const i=16*r;for(let n=0;n<16;++n)e[i+n]=t[r]+t[n]}return e}();function J(t){return"undefined"==typeof BigInt?K:t}function K(){throw new Error("BigInt not supported")}},2504:(t,e)=>{"use strict";e.byteLength=function(t){var e=o(t),r=e[0],i=e[1];return 3*(r+i)/4-i},e.toByteArray=function(t){var e,r,s=o(t),a=s[0],h=s[1],l=new n(function(t,e,r){return 3*(e+r)/4-r}(0,a,h)),u=0,c=h>0?a-4:a;for(r=0;r<c;r+=4)e=i[t.charCodeAt(r)]<<18|i[t.charCodeAt(r+1)]<<12|i[t.charCodeAt(r+2)]<<6|i[t.charCodeAt(r+3)],l[u++]=e>>16&255,l[u++]=e>>8&255,l[u++]=255&e;return 2===h&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,l[u++]=255&e),1===h&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,l[u++]=e>>8&255,l[u++]=255&e),l},e.fromByteArray=function(t){for(var e,i=t.length,n=i%3,s=[],a=16383,o=0,l=i-n;o<l;o+=a)s.push(h(t,o,o+a>l?l:o+a));return 1===n?(e=t[i-1],s.push(r[e>>2]+r[e<<4&63]+"==")):2===n&&(e=(t[i-2]<<8)+t[i-1],s.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),s.join("")};for(var r=[],i=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)r[a]=s[a],i[s.charCodeAt(a)]=a;function o(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,i){for(var n,s,a=[],o=e;o<i;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),a.push(r[(s=n)>>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},3627:(t,e,r)=>{"use strict";r.d(e,{A:()=>l});var i=r(939),n=r(9390),s=r(1605),a=r(6866),o=r(362),h=r(546);class l extends s.A{constructor(t){if(super((0,o.E)(t)),(0,i.A)(this,"termType",a.Kk),(0,i.A)(this,"classOrder",n.A.NamedNode),!this.value)throw new Error("Missing IRI for NamedNode");if(!this.value.includes(":"))throw new Error('NamedNode IRI "'+t+'" must be absolute.');if(this.value.includes(" "))throw new Error('Error: NamedNode IRI "'+t+'" must not contain unencoded spaces.')}dir(){var t=this.value.split("#")[0],e=t.slice(0,-1).lastIndexOf("/"),r=t.indexOf("//");return r>=0&&e<r+2||e<0?null:new l(t.slice(0,e+1))}site(){var t=this.value.split("#")[0],e=t.indexOf("//");if(e<0)throw new Error("This URI does not have a web site part (origin)");var r=t.indexOf("/",e+2);return new l(r<0?t.slice(0)+"/":t.slice(0,r+1))}doc(){return this.value.indexOf("#")<0?this:new l(this.value.split("#")[0])}toString(){return"<"+this.value+">"}id(){return this.value.split("#")[1]}get uri(){return this.value}set uri(t){this.value=t}static fromValue(t){return null==t||(0,h.D0)(t)?t:new l(t)}}},3787:(t,e,r)=>{"use strict";r.d(e,{A:()=>i});const i={debug(t){},warn(t){},info(t){},error(t){},success(t){},msg(t){}}},4221:(t,e,r)=>{"use strict";r.r(e),r.d(e,{docpart:()=>s,document:()=>a,hostpart:()=>o,join:()=>h,protocol:()=>l,refTo:()=>u});var i=r(3627),n=n||console.log;function s(t){var e;return(e=t.indexOf("#"))<0?t:t.slice(0,e)}function a(t){return new i.A(s(t))}function o(t){var e=/[^\/]*\/\/([^\/]*)\//.exec(t);return e?e[1]:""}function h(t,e){var r,i,s,a,o,h=e.indexOf("#");if(h>0&&(e=e.slice(0,h)),0===t.length)return e;if(0===t.indexOf("#"))return e+t;if(t.indexOf(":")>=0)return t;if(r=e.indexOf(":"),0===e.length)return t;if(r<0)return n("Invalid base: "+e+" in join with given: "+t),t;if(i=e.slice(0,+r+1||9e9),0===t.indexOf("//"))return i+t;if(e.indexOf("//",r)===r+1){if((s=e.indexOf("/",r+3))<0)return e.length-r-3>0?e+"/"+t:i+t}else if((s=e.indexOf("/",r+1))<0)return e.length-r-1>0?e+"/"+t:i+t;if(0===t.indexOf("/"))return e.slice(0,s)+t;if((a=(o=e.slice(s)).lastIndexOf("/"))<0)return i+t;for(a>=0&&a<o.length-1&&(o=o.slice(0,+a+1||9e9)),o+=t;o.match(/[^\/]*\/\.\.\//);)o=o.replace(/[^\/]*\/\.\.\//,"");return o=(o=o.replace(/\.\//g,"")).replace(/\/\.$/,"/"),e.slice(0,s)+o}function l(t){const e=t.indexOf(":");return e<0?null:t.slice(0,e)}function u(t,e){var r,i,n,s,a,o,h,l,u,c,f,d,p=new RegExp("^[-_a-zA-Z0-9.]+:(//[^/]*)?/[^/]*$");if(!t)return e;if(t===e)return"";for(r=h=0,s=e.length;h<s&&e[r]===t[r];r=++h);if(t.slice(0,r).match(p)&&((i=e.indexOf("//"))<0&&(i=-2),n=e.indexOf("/",i+2),"/"!==e[n+1]&&"/"!==t[n+1]&&e.slice(0,n)===t.slice(0,n)))return e.slice(n);if("#"===e[r]&&t.length===r)return e.slice(r);for(;r>0&&"/"!==e[r-1];)r--;if(r<3)return e;if(t.indexOf("//",r-2)>0||e.indexOf("//",r-2)>0)return e;if(t.indexOf(":",r)>0)return e;for(o=0,l=0,a=(c=t.slice(r)).length;l<a;l++)"/"===c[l]&&o++;if(0===o&&r<e.length&&"#"===e[r])return"./"+e.slice(r);if(0===o&&r===e.length)return"./";if(d="",o>0)for(u=1,f=o;f>=1?u<=f:u>=f;f>=1?++u:--u)d+="../";return d+e.slice(r)}},6866:(t,e,r)=>{"use strict";r.d(e,{$Q:()=>n,BR:()=>g,Fn:()=>v,H:()=>T,JG:()=>y,K9:()=>b,Kk:()=>i,MG:()=>p,P2:()=>a,QW:()=>s,S:()=>l,_0:()=>m,bD:()=>u,bM:()=>w,hu:()=>x,i2:()=>f,ic:()=>o,lc:()=>c,ny:()=>d,r0:()=>h,sT:()=>_});const i="NamedNode",n="BlankNode",s="Literal",a="Variable",o="DefaultGraph",h="Collection",l="Empty",u="Graph",c="text/html",f="application/ld+json",d="text/n3",p="application/n3",g="application/nquads",m="application/n-quads",w="application/n-triples",y="application/rdf+xml",b="application/sparql-update",v="application/sparql-update-single-match",_="text/turtle",x="application/x-turtle",T="application/xhtml+xml"},7114:(t,e,r)=>{"use strict";r.r(e),r.d(e,{DOMParserFactory:()=>c,RDFArrayRemove:()=>b,callbackify:()=>u,domToString:()=>f,dtstamp:()=>p,dumpNode:()=>d,heavyCompare:()=>g,heavyCompareSPO:()=>m,linkRelationProperty:()=>l,log:()=>i.A,mediaTypeClass:()=>h,output:()=>w,parseXML:()=>y,stackString:()=>_,string:()=>o,string_startswith:()=>v,uri:()=>n});var i=r(3787),n=r(4221),s=r(3627),a=r(8392);t=r.hmd(t);const o={template:function(t,e){for(var r=t.split("%s"),i="",n=0;n<e.length;n++)e[n]+="",i+=r[n]+e[n];return i+r.slice(e.length).join()}};function h(t){return t=t.split(";")[0].trim(),new s.A("http://www.w3.org/ns/iana/media-types/"+t+"#Resource")}function l(t){return new s.A("http://www.w3.org/ns/iana/link-relations/relation#"+t.trim())}function u(t,e){t.callbacks={};for(var r=e.length-1;r>=0;r--)t.callbacks[e[r]]=[];t.addHook=function(e){t.callbacks[e]||(t.callbacks[e]=[])},t.addCallback=function(e,r){t.callbacks[e].push(r)},t.removeCallback=function(e,r){for(var i=0;i<t.callbacks[e].length;i++)if(t.callbacks[e][i].name===r)return t.callbacks[e].splice(i,1),!0;return!1},t.insertCallback=function(e,r){t.callbacks[e].unshift(r)},t.fireCallbacks=function(e,r){var i,n=[],s=[],a=t.callbacks[e].length;let o;for(i=a-1;i>=0;i--)o=t.callbacks[e][i],o&&o.apply(t,r)&&n.push(o);for(i=n.length-1;i>=0;i--)s.push(n[i]);for(i=a;i<t.callbacks[e].length;i++)s.push(t.callbacks[e][i]);t.callbacks[e]=s}}function c(){return window.DOMParser?new a.DOMParser:!!window.ActiveXObject&&new ActiveXObject("Microsoft.XMLDOM")}function f(t,e){var r=[];(e=e||{})&&e.selfClosing&&e.selfClosing.split(" ").forEach((function(t){r[t]=!0}));var i=[];return e&&e.skipAttributes&&e.skipAttributes.split(" ").forEach((function(t){i[t]=!0})),d(t,e,r,i)}function d(t,e,r,i){var n,s="",a=[!1];if(void 0===t.nodeType)return s;if(1===t.nodeType){if(t.hasAttribute("class")&&e&&e.classWithChildText&&t.matches(e.classWithChildText.class))s+=t.querySelector(e.classWithChildText.element).textContent;else if(!(e&&e.skipNodeWithClass&&t.matches("."+e.skipNodeWithClass))){var o=t.nodeName.toLowerCase();s+="<"+o;var h=[];for(n=t.attributes.length-1;n>=0;n--){var l=t.attributes[n];if(!(i&&i.length>0&&i[l.name]||/^\d+$/.test(l.name))){if("class"===l.name&&e&&e.replaceClassItemWith&&l.value.split(" ").indexOf(e.replaceClassItemWith.source)>-1){var u=new RegExp(e.replaceClassItemWith.source,"g");l.value=l.value.replace(u,e.replaceClassItemWith.target).trim()}"class"===l.name&&e&&e.skipClassWithValue&&e.skipClassWithValue===l.value||h.push(l.name+"='"+l.value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,""")+"'")}}if(h.length>0&&(e&&e.sortAttributes&&h.sort((function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())})),s+=" "+h.join(" ")),r&&r.ename)s+=" />";else{for(s+=">",s+="html"===o?"\n ":"",a.push("style"===o||"script"===o),n=0;n<t.childNodes.length;n++)s+=d(t.childNodes[n]);a.pop(),s+="body"===o?"</"+o+">\n":"</"+o+">"}}}else if(8===t.nodeType)s+="\x3c!--"+t.nodeValue+"--\x3e";else if(3===t.nodeType||4===t.nodeType){var c=t.nodeValue.replace(/\n+$/,"");s+=a[a.length-1]?c:c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}else console.log("Warning; Cannot handle serialising nodes of type: "+t.nodeType),console.log(t);return s}function p(){var t=new Date,e=t.getYear()+1900,r=t.getMonth()+1,i=t.getDate(),n=t.getUTCHours(),s=t.getUTCMinutes(),a=t.getSeconds();return r<10&&(r="0"+r),i<10&&(i="0"+i),n<10&&(n="0"+n),s<10&&(s="0"+s),a<10&&(a="0"+a),e+"-"+r+"-"+i+"T"+n+":"+s+":"+a+"Z"}function g(t,e,r,i){var n=function(t){return"BlankNode"===t.termType?null:t},s=function(t){var e=r.statementsMatching(t).map((function(t){return n(t.subject)+" "+n(t.predicate)+" "+n(t.object)})).concat(r.statementsMatching(void 0,void 0,t).map((function(t){return n(t.subject)+" "+n(t.predicate)+" "+n(t.object)})));return e.sort(),e.join("\n")};const a=Object.prototype.hasOwnProperty.call(r,"compareTerms")?r.compareTerms(t,e):t.compareTerm(e);return"BlankNode"===t.termType&&"BlankNode"===e.termType?0===a?0:s(t)>s(e)?1:s(t)<s(e)?-1:a:i&&t.uri&&e.uri?(i[t.uri]||t.uri).localeCompare(i[e.uri]||e.uri):a}function m(t,e,r,i){return g(t.subject,e.subject,r,i)||g(t.predicate,e.predicate,r,i)||g(t.object,e.object,r,i)}function w(t){var e=document.createElement("div");e.textContent=t,document.body.appendChild(e)}function y(e,r){return r=r||{},t&&t.exports?(new a.DOMParser).parseFromString(e,r.contentType||"application/xhtml+xml"):("undefined"!=typeof window&&window.DOMParser?new window.DOMParser:new a.DOMParser).parseFromString(e,"application/xml")}function b(t,e){for(var r=0;r<t.length;r++)if(t[r].subject.equals(e.subject)&&t[r].predicate.equals(e.predicate)&&t[r].object.equals(e.object)&&t[r].why.equals(e.why))return void t.splice(r,1);throw new Error("RDFArrayRemove: Array did not contain "+e+" "+e.why)}function v(t,e){return t.slice(0,e.length)===e}function _(t){var e=t+"\n";if(!t.stack)return e+"No stack available.\n";for(var r=t.stack.toString().split("\n"),i=[],n=0;n<r.length;n++){var s=r[n];if(s.indexOf("ecmaunit.js")>-1)break;"("==s.charAt(0)&&(s="function"+s);var a=s.split("@");i.push(a)}for(n=0;n<i.length;n++)e+=" "+i[n][1]+"\n "+i[n][0];return e}},8392:e=>{"use strict";e.exports=t},8540:t=>{const e={acl:"http://www.w3.org/ns/auth/acl#",arg:"http://www.w3.org/ns/pim/arg#",as:"https://www.w3.org/ns/activitystreams#",bookmark:"http://www.w3.org/2002/01/bookmark#",cal:"http://www.w3.org/2002/12/cal/ical#",cco:"http://www.ontologyrepository.com/CommonCoreOntologies/",cert:"http://www.w3.org/ns/auth/cert#",contact:"http://www.w3.org/2000/10/swap/pim/contact#",dc:"http://purl.org/dc/elements/1.1/",dct:"http://purl.org/dc/terms/",doap:"http://usefulinc.com/ns/doap#",foaf:"http://xmlns.com/foaf/0.1/",geo:"http://www.w3.org/2003/01/geo/wgs84_pos#",gpx:"http://www.w3.org/ns/pim/gpx#",gr:"http://purl.org/goodrelations/v1#",http:"http://www.w3.org/2007/ont/http#",httph:"http://www.w3.org/2007/ont/httph#",icalTZ:"http://www.w3.org/2002/12/cal/icaltzd#",ldp:"http://www.w3.org/ns/ldp#",link:"http://www.w3.org/2007/ont/link#",log:"http://www.w3.org/2000/10/swap/log#",meeting:"http://www.w3.org/ns/pim/meeting#",mo:"http://purl.org/ontology/mo/",org:"http://www.w3.org/ns/org#",owl:"http://www.w3.org/2002/07/owl#",pad:"http://www.w3.org/ns/pim/pad#",patch:"http://www.w3.org/ns/pim/patch#",prov:"http://www.w3.org/ns/prov#",pto:"http://www.productontology.org/id/",qu:"http://www.w3.org/2000/10/swap/pim/qif#",trip:"http://www.w3.org/ns/pim/trip#",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",rss:"http://purl.org/rss/1.0/",sched:"http://www.w3.org/ns/pim/schedule#",schema:"http://schema.org/",sioc:"http://rdfs.org/sioc/ns#",skos:"http://www.w3.org/2004/02/skos/core#",solid:"http://www.w3.org/ns/solid/terms#",space:"http://www.w3.org/ns/pim/space#",stat:"http://www.w3.org/ns/posix/stat#",tab:"http://www.w3.org/2007/ont/link#",tabont:"http://www.w3.org/2007/ont/link#",ui:"http://www.w3.org/ns/ui#",vann:"http://purl.org/vocab/vann/",vcard:"http://www.w3.org/2006/vcard/ns#",wf:"http://www.w3.org/2005/01/wf/flow#",xsd:"http://www.w3.org/2001/XMLSchema#"};t.exports=function(t={namedNode:t=>t}){const r={};for(const i in e){const n=e[i];r[i]=function(e=""){return t.namedNode(n+e)}}return r}},9029:(t,e)=>{e.read=function(t,e,r,i,n){var s,a,o=8*n-i-1,h=(1<<o)-1,l=h>>1,u=-7,c=r?n-1:0,f=r?-1:1,d=t[e+c];for(c+=f,s=d&(1<<-u)-1,d>>=-u,u+=o;u>0;s=256*s+t[e+c],c+=f,u-=8);for(a=s&(1<<-u)-1,s>>=-u,u+=i;u>0;a=256*a+t[e+c],c+=f,u-=8);if(0===s)s=1-l;else{if(s===h)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,i),s-=l}return(d?-1:1)*a*Math.pow(2,s-i)},e.write=function(t,e,r,i,n,s){var a,o,h,l=8*s-n-1,u=(1<<l)-1,c=u>>1,f=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:s-1,p=i?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=u):(a=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-a))<1&&(a--,h*=2),(e+=a+c>=1?f/h:f*Math.pow(2,1-c))*h>=2&&(a++,h/=2),a+c>=u?(o=0,a=u):a+c>=1?(o=(e*h-1)*Math.pow(2,n),a+=c):(o=e*Math.pow(2,c-1)*Math.pow(2,n),a=0));n>=8;t[r+d]=255&o,d+=p,o/=256,n-=8);for(a=a<<n|o,l+=n;l>0;t[r+d]=255&a,d+=p,a/=256,l-=8);t[r+d-p]|=128*g}},9390:(t,e,r)=>{"use strict";r.d(e,{A:()=>i});const i={Literal:1,Collection:3,Graph:4,NamedNode:5,BlankNode:6,Variable:7}}},a={};function o(t){var e=a[t];if(void 0!==e)return e.exports;var r=a[t]={id:t,loaded:!1,exports:{}};return s[t].call(r.exports,r,r.exports,o),r.loaded=!0,r.exports}o.m=s,o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},r=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,o.t=function(t,i){if(1&i&&(t=this(t)),8&i)return t;if("object"==typeof t&&t){if(4&i&&t.__esModule)return t;if(16&i&&"function"==typeof t.then)return t}var n=Object.create(null);o.r(n);var s={};e=e||[null,r({}),r([]),r(r)];for(var a=2&i&&t;("object"==typeof a||"function"==typeof a)&&!~e.indexOf(a);a=r(a))Object.getOwnPropertyNames(a).forEach((e=>s[e]=()=>t[e]));return s.default=()=>t,o.d(n,s),n},o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.f={},o.e=t=>Promise.all(Object.keys(o.f).reduce(((e,r)=>(o.f[r](t,e),e)),[])),o.u=t=>t+".rdflib.min.js",o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i={},n="$rdf:",o.l=(t,e,r,s)=>{if(i[t])i[t].push(e);else{var a,h;if(void 0!==r)for(var l=document.getElementsByTagName("script"),u=0;u<l.length;u++){var c=l[u];if(c.getAttribute("src")==t||c.getAttribute("data-webpack")==n+r){a=c;break}}a||(h=!0,(a=document.createElement("script")).charset="utf-8",o.nc&&a.setAttribute("nonce",o.nc),a.setAttribute("data-webpack",n+r),a.src=t),i[t]=[e];var f=(e,r)=>{a.onerror=a.onload=null,clearTimeout(d);var n=i[t];if(delete i[t],a.parentNode&&a.parentNode.removeChild(a),n&&n.forEach((t=>t(r))),e)return e(r)},d=setTimeout(f.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=f.bind(null,a.onerror),a.onload=f.bind(null,a.onload),h&&document.head.appendChild(a)}},o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;o.g.importScripts&&(t=o.g.location+"");var e=o.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var i=r.length-1;i>-1&&(!t||!/^http(s?):/.test(t));)t=r[i--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=t})(),(()=>{var t={792:0};o.f.j=(e,r)=>{var i=o.o(t,e)?t[e]:void 0;if(0!==i)if(i)r.push(i[2]);else{var n=new Promise(((r,n)=>i=t[e]=[r,n]));r.push(i[2]=n);var s=o.p+o.u(e),a=new Error;o.l(s,(r=>{if(o.o(t,e)&&(0!==(i=t[e])&&(t[e]=void 0),i)){var n=r&&("load"===r.type?"missing":r.type),s=r&&r.target&&r.target.src;a.message="Loading chunk "+e+" failed.\n("+n+": "+s+")",a.name="ChunkLoadError",a.type=n,a.request=s,i[1](a)}}),"chunk-"+e,e)}};var e=(e,r)=>{var i,n,[s,a,h]=r,l=0;if(s.some((e=>0!==t[e]))){for(i in a)o.o(a,i)&&(o.m[i]=a[i]);h&&h(o)}for(e&&e(r);l<s.length;l++)n=s[l],o.o(t,n)&&t[n]&&t[n][0](),t[n]=0},r=self.webpackChunk$rdf=self.webpackChunk$rdf||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))})();var h={};return(()=>{"use strict";o.r(h),o.d(h,{BlankNode:()=>n,Collection:()=>f,ConnectedStore:()=>rr,DataFactory:()=>Le,Empty:()=>d,Fetcher:()=>Oe,Formula:()=>P,IndexedFormula:()=>G,Literal:()=>u,LiveStore:()=>ir,N3Parser:()=>yt,NamedNode:()=>s.A,Namespace:()=>E,NextId:()=>er,Node:()=>B,Query:()=>$,RDFParser:()=>ce,RDFaProcessor:()=>le,SPARQLToQuery:()=>Fe,Serializer:()=>j,Statement:()=>y,Store:()=>G,UpdateManager:()=>Ue,UpdatesSocket:()=>Me,UpdatesVia:()=>Pe,Util:()=>C,Variable:()=>v,blankNode:()=>Ve,defaultGraph:()=>Ge,fetcher:()=>qe,fromNT:()=>Ke,graph:()=>$e,isBlankNode:()=>a.jt,isCollection:()=>a.P3,isGraph:()=>a.RN,isLiteral:()=>a.c$,isNamedNode:()=>a.Y2,isPredicate:()=>a.YC,isQuad:()=>a.aF,isRDFObject:()=>a.GE,isRDFlibObject:()=>a.DJ,isRDFlibPredicate:()=>a.fY,isRDFlibSubject:()=>a.CZ,isStatement:()=>a.SH,isStore:()=>a.ok,isSubject:()=>a.hr,isTerm:()=>a.D0,isVariable:()=>a.DZ,jsonParser:()=>je,lit:()=>He,literal:()=>We,log:()=>N.A,namedNode:()=>ze,parse:()=>de,quad:()=>Ye,queryToSPARQL:()=>Se,serialize:()=>F,sparqlUpdateParser:()=>fe,st:()=>Xe,sym:()=>ze,term:()=>tr,termValue:()=>me.E,triple:()=>Ze,uri:()=>b,variable:()=>Qe});var t=o(939),e=o(9390),r=o(1605),i=o(6866);class n extends r.A{static getId(t){if(t){if("string"!=typeof t)throw new Error("Bad id argument to new blank node: "+t);if(t.includes("#")){let e=t.split("#");return e[e.length-1]}return t}return"n"+n.nextId++}constructor(r){super(n.getId(r)),(0,t.A)(this,"termType",i.$Q),(0,t.A)(this,"classOrder",e.A.BlankNode),(0,t.A)(this,"isBlank",1),(0,t.A)(this,"isVar",1)}get id(){return this.value}set id(t){this.value=t}compareTerm(t){return this.classOrder<t.classOrder?-1:this.classOrder>t.classOrder?1:this.id<t.id?-1:this.id>t.id?1:0}copy(t){var e=new n;return t.copyTo(this,e),e}toCanonical(){return n.NTAnonymousNodePrefix+this.value}toString(){return n.NTAnonymousNodePrefix+this.id}}(0,t.A)(n,"nextId",0),(0,t.A)(n,"NTAnonymousNodePrefix","_:");var s=o(3627),a=o(546);const l={boolean:new s.A("http://www.w3.org/2001/XMLSchema#boolean"),dateTime:new s.A("http://www.w3.org/2001/XMLSchema#dateTime"),decimal:new s.A("http://www.w3.org/2001/XMLSchema#decimal"),double:new s.A("http://www.w3.org/2001/XMLSchema#double"),integer:new s.A("http://www.w3.org/2001/XMLSchema#integer"),langString:new s.A("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),string:new s.A("http://www.w3.org/2001/XMLSchema#string")};class u extends r.A{constructor(r,n,a){super(r),(0,t.A)(this,"termType",i.QW),(0,t.A)(this,"classOrder",e.A.Literal),(0,t.A)(this,"datatype",l.string),(0,t.A)(this,"isVar",0),(0,t.A)(this,"language",""),n?(this.language=n,this.datatype=l.langString):this.datatype=a?s.A.fromValue(a):l.string}copy(){return new u(this.value,this.lang,this.datatype)}equals(t){return!!t&&this.termType===t.termType&&this.value===t.value&&this.language===t.language&&(!this.datatype&&!t.datatype||this.datatype&&this.datatype.equals(t.datatype))}get lang(){return this.language}set lang(t){this.language=t||""}toNT(){return u.toNT(this)}static toNT(t){if("number"==typeof t.value)return""+t.value;if("string"!=typeof t.value)throw new Error("Value of RDF literal is not string or number: "+t.value);var e=t.value;return e='"'+(e=(e=(e=(e=e.replace(/\\/g,"\\\\")).replace(/\"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r"))+'"',t.language?e+="@"+t.language:t.datatype.equals(l.string)||(e+="^^"+t.datatype.toCanonical()),e}toString(){return""+this.value}static fromBoolean(t){return new u(t?"1":"0",null,l.boolean)}static fromDate(t){if(!(t instanceof Date))throw new TypeError("Invalid argument to Literal.fromDate()");let e=function(t){return(""+(100+t)).slice(1,3)},r=t.getUTCFullYear()+"-"+e(t.getUTCMonth()+1)+"-"+e(t.getUTCDate())+"T"+e(t.getUTCHours())+":"+e(t.getUTCMinutes())+":"+e(t.getUTCSeconds())+"Z";return new u(r,null,l.dateTime)}static fromNumber(t){if("number"!=typeof t)throw new TypeError("Invalid argument to Literal.fromNumber()");let e;const r=t.toString();return e=r.indexOf("e")<0&&Math.abs(t)<=Number.MAX_SAFE_INTEGER?Number.isInteger(t)?l.integer:l.decimal:l.double,new u(r,null,e)}static fromValue(t){if((0,a.c$)(t))return t;switch(typeof t){case"object":if(t instanceof Date)return u.fromDate(t);case"boolean":return u.fromBoolean(t);case"number":return u.fromNumber(t);case"string":return new u(t)}throw new Error("Can't make literal from "+t+" of type "+typeof t)}}function c(t){return null==t||(0,a.D0)(t)?t:Array.isArray(t)?new f(t):u.fromValue(t)}class f extends r.A{constructor(r){super((n.nextId++).toString()),(0,t.A)(this,"termType",i.r0),(0,t.A)(this,"classOrder",e.A.Collection),(0,t.A)(this,"closed",!1),(0,t.A)(this,"compareTerm",n.prototype.compareTerm),(0,t.A)(this,"elements",[]),(0,t.A)(this,"isVar",0),r&&r.length>0&&r.forEach((t=>{this.elements.push(c(t))}))}get id(){return this.value}set id(t){this.value=t}append(t){return this.elements.push(t)}close(){return this.closed=!0,this.closed}shift(){return this.elements.shift()}substitute(t){const e=this.elements.map((e=>e.substitute(t)));return new f(e)}toNT(){return f.toNT(this)}static toNT(t){return n.NTAnonymousNodePrefix+t.id}toString(){return"("+this.elements.join(" ")+")"}unshift(t){return this.elements.unshift(t)}}(0,t.A)(f,"termType",i.r0);class d extends r.A{constructor(){super(""),(0,t.A)(this,"termType",i.S)}toString(){return"()"}}const p="chrome:theSession";new s.A(p);class g extends r.A{constructor(){super(""),(0,t.A)(this,"value",""),(0,t.A)(this,"termType",i.ic),(0,t.A)(this,"uri",p)}toCanonical(){return this.value}toString(){return"DefaultGraph"}}function m(t){return!!t&&t.termType===i.ic}const w=new g;class y{constructor(e,i,n,s){(0,t.A)(this,"subject",void 0),(0,t.A)(this,"predicate",void 0),(0,t.A)(this,"object",void 0),(0,t.A)(this,"graph",void 0),this.subject=r.A.fromValue(e),this.predicate=r.A.fromValue(i),this.object=r.A.fromValue(n),this.graph=null==s?w:r.A.fromValue(s)}get why(){return this.graph}set why(t){this.graph=t}equals(t){return t.subject.equals(this.subject)&&t.predicate.equals(this.predicate)&&t.object.equals(this.object)&&t.graph.equals(this.graph)}substitute(t){return new y(this.subject.substitute(t),this.predicate.substitute(t),this.object.substitute(t),m(this.graph)?this.graph:this.graph.substitute(t))}toCanonical(){let t=[this.subject.toCanonical(),this.predicate.toCanonical(),this.object.toCanonical()];return this.graph&&this.graph.termType!==i.ic&&t.push(this.graph.toCanonical()),t.join(" ")+" ."}toNT(){return[this.subject.toNT(),this.predicate.toNT(),this.object.toNT()].join(" ")+" ."}toNQ(){return[this.subject.toNT(),this.predicate.toNT(),this.object.toNT(),m(this.graph)?"":this.graph.toNT()].join(" ")+" ."}toString(){return this.toNT()}}var b=o(4221);class v extends r.A{constructor(r=""){super(r),(0,t.A)(this,"termType",i.P2),(0,t.A)(this,"base","varid:"),(0,t.A)(this,"classOrder",e.A.Variable),(0,t.A)(this,"isVar",1),(0,t.A)(this,"uri",void 0),this.base="varid:",this.uri=b.join(r,this.base)}equals(t){return!!t&&this.termType===t.termType&&this.value===t.value}hashString(){return this.toString()}substitute(t){var e;return null!=(e=t[this.toNT()])?e:this}toString(){return v.toString(this)}static toString(t){return t.uri.slice(0,t.base.length)===t.base?`?${t.uri.slice(t.base.length)}`:`?${t.uri}`}}let _=function(t){return t.collections="COLLECTIONS",t.defaultGraphType="DEFAULT_GRAPH_TYPE",t.equalsMethod="EQUALS_METHOD",t.id="ID",t.identity="IDENTITY",t.reversibleId="REVERSIBLE_ID",t.variableType="VARIABLE_TYPE",t}({});const x=new g,T={supports:{[_.collections]:!1,[_.defaultGraphType]:!1,[_.equalsMethod]:!0,[_.identity]:!1,[_.id]:!0,[_.reversibleId]:!1,[_.variableType]:!0},blankNode:t=>new n(t),defaultGraph:()=>x,equals(t,e){return t===e||!t||!e||((0,a.aF)(t)||(0,a.aF)(e)?!(!(0,a.aF)(t)||!(0,a.aF)(e))&&this.equals(t.subject,e.subject)&&this.equals(t.predicate,e.predicate)&&this.equals(t.object,e.object)&&this.equals(t.graph,e.graph):!(!(0,a.D0)(t)||!(0,a.D0)(e))&&this.id(t)===this.id(e))},id(t){if(!t)return"undefined";if((0,a.aF)(t))return this.quadToNQ(t);switch(t.termType){case i.ic:return"defaultGraph";case i.P2:return v.toString(t);default:const e=this.termToNQ(t);if(e)return e;throw new Error(`Can't id term with type '${t.termType}'`)}},isQuad:t=>t instanceof y,literal(t,e){if("string"!=typeof t&&!e)return u.fromValue(t);const r="string"==typeof t?t:""+t;return"string"==typeof e?-1===e.indexOf(":")?new u(r,e):new u(r,null,this.namedNode(e)):new u(r,null,e)},namedNode:t=>new s.A(t),quad:(t,e,r,i)=>new y(t,e,r,i||x),triple(t,e,r,i){return this.quad(t,e,r,i)},quadToNQ(t){return`${this.termToNQ(t.subject)} ${this.termToNQ(t.predicate)} ${this.termToNQ(t.object)} ${this.termToNQ(t.graph)} .`},termToNQ(t){switch(t.termType){case i.$Q:return"_:"+t.value;case i.ic:return"";case i.S:return"<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>";case i.QW:return u.toNT(t);case i.bD:case i.Kk:return"<"+t.value+">";case i.r0:return"("+t.elements.map((t=>this.termToNQ(t))).join(" ")+")";default:throw new Error(`Can't serialize nonstandard term type (was '${t.termType}')`)}},toNQ(t){return this.isQuad(t)?this.quadToNQ(t):this.termToNQ(t)},variable:t=>new v(t)},A=T;var N=o(3787);function E(t,e){const r=e||{namedNode:t=>new s.A(t)};return function(e){return r.namedNode(t+(e||""))}}var R=o(2312),k=o(8540),I=o.n(k),C=o(7114);function O(t=A){return{boolean:t.namedNode("http://www.w3.org/2001/XMLSchema#boolean"),dateTime:t.namedNode("http://www.w3.org/2001/XMLSchema#dateTime"),decimal:t.namedNode("http://www.w3.org/2001/XMLSchema#decimal"),double:t.namedNode("http://www.w3.org/2001/XMLSchema#double"),integer:t.namedNode("http://www.w3.org/2001/XMLSchema#integer"),langString:t.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),string:t.namedNode("http://www.w3.org/2001/XMLSchema#string")}}function j(t){return new S(t)}O(A);class S{constructor(e){(0,t.A)(this,"_notQNameChars","\t\r\n !\"#$%&'()*,+/;<=>?@[\\]^`{|}~"),(0,t.A)(this,"_notNameChars",this._notQNameChars+":"),(0,t.A)(this,"validPrefix",new RegExp(/^[a-zA-Z][a-zA-Z0-9]*$/)),(0,t.A)(this,"forbidden1",new RegExp(/[\\"\b\f\r\v\t\n\u0080-\uffff]/gm)),(0,t.A)(this,"forbidden3",new RegExp(/[\\"\b\f\r\v\u0080-\uffff]/gm)),this.flags="",this.base=null,this.prefixes=[],this.namespaces=[];const r=Object.keys(I()());for(const t in r){const e=I()()[r[t]](""),i=r[t];this.prefixes[e]=i,this.namespaces[i]=e}this.suggestPrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#"),this.suggestPrefix("xml","reserved:reservedForFutureUse"),this.namespacesUsed=[],this.keywords=["a"],this.prefixchars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",this.incoming=null,this.formulas=[],this.store=e,this.rdfFactory=e.rdfFactory||A,this.xsd=O(this.rdfFactory)}setBase(t){return this.base=t,this}setFlags(t){return this.flags=t||"",this}toStr(t){var e=t.toNT();return"Graph"===t.termType&&(this.formulas[e]=t),e}fromStr(t){if("{"===t[0]){var e=this.formulas[t];return e||console.log("No formula object for "+t),e}return this.store.fromNT(t)}setNamespaces(t){for(var e in t)this.setPrefix(e,t[e]);return this}setPrefix(t,e){if("default"!==t.slice(0,7)&&"ns"!==t.slice(0,2)&&t&&e){for(let e in this.prefixes)this.prefixes[e]==t&&delete this.prefixes[e];this.prefixes[e]=t,this.namespaces[t]=e}}suggestPrefix(t,e){"default"!==t.slice(0,7)&&"ns"!==t.slice(0,2)&&t&&e&&(t in this.namespaces||e in this.prefixes||(this.prefixes[e]=t,this.namespaces[t]=e))}suggestNamespaces(t){for(var e in t)this.suggestPrefix(e,t[e]);return this}checkIntegrity(){var t,e;for(t in this.namespaces)if(this.prefixes[this.namespaces[t]]!==t)throw new Error("Serializer integity error 1: "+t+", "+this.namespaces[t]+", "+this.prefixes[this.namespaces[t]]+"!");for(e in this.prefixes)if(this.namespaces[this.prefixes[e]]!==e)throw new Error("Serializer integity error 2: "+e+", "+this.prefixs[e]+", "+this.namespaces[this.prefixes[e]]+"!")}makeUpPrefix(t){var e=t,r=function(e){return!!this.validPrefix.test(e)&&"ns"!==e&&!(e in this.namespaces)&&(this.prefixes[t]=e,this.namespaces[e]=t,e)}.bind(this);"#/".indexOf(e[e.length-1])>=0&&(e=e.slice(0,-1));var i=e.lastIndexOf("/");i>=0&&(e=e.slice(i+1));for(var n=0;n<e.length&&this.prefixchars.indexOf(e[n])>=0;)n++;if((e=e.slice(0,n)).length<6&&r(e))return e;if(r(e.slice(0,3)))return e.slice(0,3);if(r(e.slice(0,2)))return e.slice(0,2);if(r(e.slice(0,4)))return e.slice(0,4);if(r(e.slice(0,1)))return e.slice(0,1);if(r(e.slice(0,5)))return e.slice(0,5);this.validPrefix.test(e)||(e="n");for(var s=0;;s++)if(r(e.slice(0,3)+s))return e.slice(0,3)+s}rootSubjects(t){for(var e={},r={},i={},n=0;n<t.length;n++){var s=t[n],a=function(t){e.hasOwnProperty(t)||(e[t]=[]),e[t].push(s.subject)};[s.subject,s.predicate,s.object].map((function(t){"BlankNode"===t.termType?i[t.toNT()]=!0:"Collection"===t.termType&&t.elements.forEach((function(t){a(t)}))})),a(t[n].object);var o=r[this.toStr(s.subject)];o||(o=[]),o.push(s),r[this.toStr(s.subject)]=o}var h=[];for(var l in r)if(r.hasOwnProperty(l)){var u=this.fromStr(l);"BlankNode"===u.termType&&e[u]&&1===e[u].length||h.push(u)}this.incoming=e;for(var c={},f=0;f<h.length;f++)c[h[f].toNT()]=!0;return{roots:h,subjects:r,rootsHash:c,incoming:e}}toN3(t){return this.statementsToN3(t.statements)}isValidPNLocal(t){if(0===t.length)return!0;if("."===t[t.length-1])return!1;for(var e=0;e<t.length;e++){var r=t[e];if("."!==r&&this._notNameChars.indexOf(r)>=0)return!1}return!0}explicitURI(t){var e;return this.flags.indexOf("r")<0&&this.base?t=b.refTo(this.base,t):this.flags.indexOf("u")>=0?t=function(t){for(var e,r="",i=0;i<t.length;i++)r+=(e=t.charCodeAt(i))>65535?"\\U"+("00000000"+e.toString(16)).slice(-8):e>126?"\\u"+("0000"+e.toString(16)).slice(-4):t[i];return r}(t):(e=decodeURI(t),t=encodeURI(e)),"<"+t+">"}statementsToNTriples(t){var e=t.slice();e.sort();for(var r="",i="http://www.w3.org/1999/02/22-rdf-syntax-ns#",n=this,s=this.store,a=this.rdfFactory,o=function(t){if("Collection"!==t.termType)return n.atomicTermToN3(t);for(var e=t.elements,h=s.sym(i+"nill"),l=e.length-1;l>=0;l--){var u=a.blankNode();r+=o(u)+" "+o(s.sym(i+"first"))+" "+o(e[l])+".\n",r+=o(u)+" "+o(s.sym(i+"rest"))+" "+o(h)+".\n",h=u}return n.atomicTermToN3(h)},h=0;h<e.length;h++){var l=e[h],u="";u+=o(l.subject)+" ",u+=o(l.predicate)+" ",u+=o(l.object)+" ",this.flags.indexOf("q")>=0&&(u+=o(l.why)+" "),r+=u+=".\n"}return r}statementsToN3(t){var e=this.store,r={"http://www.w3.org/1999/02/22-rdf-syntax-ns#type":"aaa:00"};t.sort((function(t,i){return C.heavyCompareSPO(t,i,e,r)})),this.base&&!this.defaultNamespace&&(this.defaultNamespace=this.base+"#");var i={};this.flags.indexOf("s")<0&&(i["http://www.w3.org/2002/07/owl#sameAs"]="="),this.flags.indexOf("t")<0&&(i["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]="a"),this.flags.indexOf("i")<0&&(i["http://www.w3.org/2000/10/swap/log#implies"]="=>");var n=function(t){for(var e="",r=0;r<t;r++)e+=" ";return e},s=function(t){for(var e="",r=0;r<t.length;r++){var i=t[r],n="string"==typeof i?i:s(i);if(0!==r){var a=e.slice(-1)||" ";","===n||";"===n||("."!==n||"0123456789.:".includes(a))&&(e+=" ")}e+=n}return e},a=function(t,e){var r="",i=1e5;void 0===e&&(e=-1);for(var o=0;o<t.length;o++){var h=t[o];if("string"!=typeof h){var l=a(h,e+1);if(l.length<10*(80-4*e)&&l.indexOf('"""')<0){var u=s(h);u.length<80-4*e&&(h=u,l="")}l&&(i=1e4),r+=l}if("string"==typeof h){if(1===h.length&&"\n"===r.slice(-1)&&",.;".indexOf(h)>=0){r=r.slice(0,-1),"."==h&&"0123456789.:".includes(r.charAt(r.length-1))&&(r+=" ",i+=1),r+=h+"\n",i+=1;continue}if(i<4*e+4||i+h.length+1<80&&";.".indexOf(r[r.length-2])<0)r=r.slice(0,-1)+" "+h+"\n",i+=h.length+1;else{let t=n(4*e)+h;r+=t+"\n",i=t.length,e<0&&(r+="\n",i=1e5)}}}return r},o=function(t){for(var e=this.rootSubjects(t),r=e.roots,i=[],n=0;n<r.length;n++){var s=r[n];i.push(h(s,e))}return i}.bind(this);function h(t,e){return"BlankNode"!==t.termType||e.incoming[t]?[c(t,e)].concat([l(t,e)]).concat(["."]):u(t,e,!0).concat(["."])}var l=function(t,e){var r=[],n=null,s=e.subjects[this.toStr(t)]||[];if(void 0===s)throw new Error("Cant find statements for "+t);for(var a=[],o=0;o<s.length;o++){var h=s[o];h.predicate.uri===n?a.push(","):(n&&(r=r.concat([a]).concat([";"]),a=[]),r.push(i[h.predicate.uri]?i[h.predicate.uri]:c(h.predicate,e))),n=h.predicate.uri,a.push(u(h.object,e))}return r.concat([a])}.bind(this),u=function(t,e,r){return"BlankNode"!==t.termType||!r&&void 0!==e.rootsHash[t.toNT()]?c(t,e):e.subjects[this.toStr(t)]?["[",l(t,e),"]"]:"[]"}.bind(this);S.prototype.termToN3=c;var c=function(t,e){var r,i;switch(t.termType){case"Graph":return(i=(i=["{"]).concat(o(t.statements))).concat(["}"]);case"Collection":for(i=["("],r=0;r<t.elements.length;r++)i.push([u(t.elements[r],e)]);return i.push(")"),i;default:return this.atomicTermToN3(t)}}.bind(this),f=function(){var t="";for(var e in this.flags.indexOf("d")<0&&this.defaultNamespace&&(t+="@prefix : "+this.explicitURI(this.defaultNamespace)+".\n"),this.prefixes)this.prefixes.hasOwnProperty(e)&&this.namespacesUsed[e]&&(t+="@prefix "+this.prefixes[e]+": "+this.explicitURI(e)+".\n");return t+"\n"}.bind(this),d=o(t);return f()+a(d)}atomicTermToN3(t,e){switch(t.termType){case"BlankNode":case"Variable":return t.toNT();case"Literal":var r=t.value;if("string"!=typeof r)throw new TypeError("Value of RDF literal node must be a string");if(t.datatype&&this.flags.indexOf("x")<0)switch(t.datatype.uri){case"http://www.w3.org/2001/XMLSchema#integer":return r;case"http://www.w3.org/2001/XMLSchema#decimal":return r.indexOf(".")<0&&(r+=".0"),r;case"http://www.w3.org/2001/XMLSchema#double":{const t=r.toLowerCase().indexOf("e")>0;return r.indexOf(".")<0&&!t&&(r+=".0"),t||(r+="e0"),r}case"http://www.w3.org/2001/XMLSchema#boolean":return"1"===t.value?"true":"false"}var i=this.stringToN3(t.value,this.flags);return t.language?i+="@"+t.language:t.datatype.equals(this.xsd.string)||(i+="^^"+this.atomicTermToN3(t.datatype,e)),i;case"NamedNode":return this.symbolToN3(t);case"DefaultGraph":return"";default:throw new Error("Internal: atomicTermToN3 cannot handle "+t+" of termType: "+t.termType)}}stringToN3(t,e){e||(e="e");var r,i,n,s,a,o="";for(t.length>20&&'"'!==t.slice(-1)&&e.indexOf("n")<0&&(t.indexOf("\n")>0||t.indexOf('"')>0)?(s='"""',a=this.forbidden3):(s='"',a=this.forbidden1),r=0;r<t.length&&(a.lastIndex=0,null!=a.exec(t.slice(r)));){i=r+a.lastIndex-1,o+=t.slice(r,i);var h=t[i];'"'===h&&'"""'===s&&'"""'!==t.slice(i,i+3)?o+=h:(n='\b\f\r\t\v\n\\"'.indexOf(h))>=0?o+="\\"+'bfrtvn\\"'[n]:e.indexOf("e")>=0?o+="\\u"+("000"+h.charCodeAt(0).toString(16).toLowerCase()).slice(-4):o+=h,r=i+1}return s+o+t.slice(r)+s}symbolToN3(t){var e=t.uri,r=e.indexOf("#");if(r<0&&this.flags.indexOf("/")<0&&(r=e.lastIndexOf("/")),r>=0&&this.flags.indexOf("p")<0&&(0===e.indexOf("http")||0===e.indexOf("ws")||0===e.indexOf("file"))){var i=e.slice(r+1),n=e.slice(0,r+1),s=e.indexOf("://")+4,a=this.base?this.base.slice(0,Math.max(this.base.lastIndexOf("/"),this.base.lastIndexOf("#"))+1):null,o=a&&n===a,h=this.flags.indexOf("o")>=0&&i.indexOf(".")>=0;if(!o&&!h&&n.length>s&&this.isValidPNLocal(i)){if(this.defaultNamespace&&this.defaultNamespace===n&&this.flags.indexOf("d")<0)return this.flags.indexOf("k")>=0&&this.keyords.indexOf(i)<0?i:":"+i;var l=this.prefixes[n];if(l||(l=this.makeUpPrefix(n)),l)return this.namespacesUsed[n]=!0,l+":"+i}}return this.explicitURI(e)}writeStore(t){var e=this.store,r=e.fetcher,i=r&&r.appNode,n=this.store.index[3];for(var s in n){var a=e.fromNT(s);i&&a.equals(i)||t("\n"+this.atomicTermToN3(a)+" "+this.atomicTermToN3(e.sym("http://www.w3.org/2000/10/swap/log#semantics"))+" { "+this.statementsToN3(e.statementsMatching(void 0,void 0,void 0,a))+" }.\n")}e.statementsMatching(void 0,e.sym("http://www.w3.org/2007/ont/link#requestedURI")).map((function(r){t("\n<"+r.object.value+"> log:metadata {\n");var i=e.statementsMatching(void 0,void 0,void 0,r.subject);t(this.statementsToN3(this.statementsToN3(i))),t("}.\n")}));var o=[];i&&o.push(i);var h=[];o.map((function(t){h=h.concat(e.statementsMatching(void 0,void 0,void 0,t))})),t(this.statementsToN3(h))}statementsToXML(t){var e=[];e["http://www.w3.org/1999/02/22-rdf-syntax-ns#"]=!0;var r="http://www.w3.org/1999/02/22-rdf-syntax-ns#_",i=function(t){for(var e="",r=0;r<t;r++)e+=" ";return e},n=function(t){for(var e="",r=0;r<t.length;r++){var i=t[r];e+="string"==typeof i?i:n(i)}return e},s=function(t,e){var r,a="",o=1e5;e||(e=0);for(var h=0;h<t.length;h++){var l=t[h];if("string"!=typeof l){var u=s(l,e+1);u.length<10*(80-4*e)&&u.indexOf('"""')<0&&(r=n(l)).length<80-4*e&&(l=" "+r,u=""),u&&(o=1e4),a+=u}"string"==typeof l&&(o<4*e+4?(a=a.slice(0,-1)+" "+l+"\n",o+=l.length+1):(a+=(r=i(4*e)+l)+"\n",o=r.length))}return a},a=function(t){this.suggestPrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");for(var e=this.rootSubjects(t),r=e.roots,i=[],n=0;n<r.length;n++){var s=r[n];i.push(l(s,e))}return i}.bind(this);function o(t){return void 0===t?"@@@undefined@@@@":t.replace(/[&<"]/g,(function(t){switch(t[0]){case"&":return"&";case"<":return"<";case'"':return"""}}))}var h=function(t){return o(this.base?b.refTo(this.base,t.uri):t.uri)}.bind(this),l=function(t,e){var i,n,s,a,d=[],p=e.subjects[this.toStr(t)];if(void 0===p)return c(t,e);p.sort((function(t,e){var i=t.predicate.uri,n=e.predicate.uri;if(i.substring(0,44)===r||n.substring(0,44)===r)return i.localeCompare(n);var s=i.substring(44),a=n.substring(44),o=parseInt(s,10),h=parseInt(a,10);return isNaN(o)||isNaN(h)||o!==s||h!==a?i.localeCompare(n):o-h}));for(var g=0;g<p.length;g++)if("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"!==(s=p[g]).predicate.uri||i||"NamedNode"!==s.object.termType){if((a=s.predicate).uri.substr(0,44)===r){var m=a.uri.substr(44);m===parseInt(m,10).toString()&&(a=this.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#li"))}switch(n=f(a),s.object.termType){case"BlankNode":d=1===e.incoming[s.object].length?d.concat(["<"+n+' rdf:parseType="Resource">',l(s.object,e),"</"+n+">"]):d.concat(["<"+n+' rdf:nodeID="'+s.object.toNT().slice(2)+'"/>']);break;case"NamedNode":d=d.concat(["<"+n+' rdf:resource="'+h(s.object)+'"/>']);break;case"Literal":d=d.concat(["<"+n+(s.object.language?' xml:lang="'+s.object.language+'"':s.object.datatype.equals(this.xsd.string)?"":' rdf:datatype="'+o(s.object.datatype.uri)+'"')+">"+o(s.object.value)+"</"+n+">"]);break;case"Collection":d=d.concat(["<"+n+' rdf:parseType="Collection">',u(s.object,e),"</"+n+">"]);break;default:throw new Error("Can't serialize object of type "+s.object.termType+" into XML")}}else i=s.object;var w=i?f(i):"rdf:Description",y="";return"BlankNode"===t.termType?e.incoming[t]&&1===e.incoming[t].length||(y=' rdf:nodeID="'+t.toNT().slice(2)+'"'):y=' rdf:about="'+h(t)+'"',["<"+w+y+">"].concat([d]).concat(["</"+w+">"])}.bind(this);function u(t,e){for(var r=[],i=0;i<t.elements.length;i++)r.push(l(t.elements[i],e));return r}var c=function(t,e){var r=[],i=e.subjects[this.toStr(t)];if(!i)return r;i.sort();for(var n=0;n<i.length;n++){var s=i[n];switch(s.object.termType){case"BlankNode":r=e.rootsHash[s.object.toNT()]?r.concat(["<"+f(s.predicate)+' rdf:nodeID="'+s.object.toNT().slice(2)+'">',"</"+f(s.predicate)+">"]):r.concat(["<"+f(s.predicate)+' rdf:parseType="Resource">',c(s.object,e),"</"+f(s.predicate)+">"]);break;case"NamedNode":r=r.concat(["<"+f(s.predicate)+' rdf:resource="'+h(s.object)+'"/>']);break;case"Literal":r=r.concat(["<"+f(s.predicate)+(s.object.language?' xml:lang="'+s.object.language+'"':s.object.datatype.equals(this.xsd.string)?"":' rdf:datatype="'+o(s.object.datatype.value)+'"')+">"+o(s.object.value)+"</"+f(s.predicate)+">"]);break;case"Collection":r=r.concat(["<"+f(s.predicate)+' rdf:parseType="Collection">',u(s.object,e),"</"+f(s.predicate)+">"]);break;default:throw new Error("Can't serialize object of type "+s.object.termType+" into XML")}}return r}.bind(this),f=function(t){var r=t.uri,i=r.indexOf("#");if(i<0&&this.flags.indexOf("/")<0&&(i=r.lastIndexOf("/")),i<0)throw new Error("Cannot make qname out of <"+r+">");for(var n=i+1;n<r.length;n++)if(this._notNameChars.indexOf(r[n])>=0)throw new Error('Invalid character "'+r[n]+'" cannot be in XML qname for URI: '+r);var s=r.slice(i+1),a=r.slice(0,i+1);if(this.defaultNamespace&&this.defaultNamespace===a&&this.flags.indexOf("d")<0)return s;var o=this.prefixes[a];return o||(o=this.makeUpPrefix(a)),e[a]=!0,o+":"+s}.bind(this),d=a(t),p="<rdf:RDF";for(var g in this.defaultNamespace&&(p+=' xmlns="'+o(this.defaultNamespace)+'"'),e)if(e.hasOwnProperty(g)){var m=this.base&&this.flags.includes("z")?b.refTo(this.base,g):g;p+="\n xmlns:"+this.prefixes[g]+'="'+o(m)+'"'}return s([p+=">",d,"</rdf:RDF>"],-1)}statementsToJsonld(t){const e=this.statementsToN3(t),r=R.parse(e);return JSON.stringify(r,null,2)}}function F(t,e,r,n,s,a){r=r||t?.value;const o=a||{};n=n||i.sT;try{var h=j(e);o.flags&&h.setFlags(o.flags);var l=e.statementsMatching(void 0,void 0,void 0,t);switch("namespaces"in e&&h.suggestNamespaces(e.namespaces),o.namespaces&&h.setNamespaces(o.namespaces),h.setBase(r),n){case i.JG:return u(null,h.statementsToXML(l));case i.ny:case i.MG:return u(null,h.statementsToN3(l));case i.sT:case i.hu:return h.setFlags("si"+(o.flags?" "+o.flags:"")),u(null,h.statementsToN3(l));case i.bM:return h.setFlags("deinprstux"),u(null,h.statementsToNTriples(l));case i.i2:return h.setFlags("si dr"+(o.flags?" "+o.flags:"")),u(null,h.statementsToJsonld(l));case i._0:case i.BR:return h.setFlags("deinprstux q"),u(null,h.statementsToNTriples(l));default:throw new Error("Serialize: Content-type "+n+" not supported for data write.")}}catch(t){if(s)return s(t,void 0);throw t}function u(t,e){return s?void s(t,e):e}}const U=["blankNode","defaultGraph","literal","namedNode","quad","variable","supports"],D={first:"http://www.w3.org/1999/02/22-rdf-syntax-ns#first",rest:"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",nil:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"};function L(t,e,r){const i=[];return r.reduce(((e,r,n,s)=>{let a;return i.push(t.quad(e,t.namedNode(D.first),s[n])),n<s.length-1?(a=t.blankNode(),i.push(t.quad(e,t.namedNode(D.rest),a))):i.push(t.quad(e,t.namedNode(D.rest),t.namedNode(D.nil))),a}),e),i}function M(t,e,r=0){var i=t.length;for(r<0&&(r=i+r);r<i;r++)if(t[r]===e)return r;return-1}class P extends r.A{constructor(r=[],n=[],s=[],a=[],o={}){super(""),this.statements=r,this.constraints=n,this.initBindings=s,this.optional=a,(0,t.A)(this,"termType",i.bD),(0,t.A)(this,"classOrder",e.A.Graph),(0,t.A)(this,"fetcher",void 0),(0,t.A)(this,"isVar",0),(0,t.A)(this,"ns",E),(0,t.A)(this,"rdfFactory",void 0),this.rdfFactory=o&&o.rdfFactory||A;for(const t of U)this[t]=(...e)=>this.rdfFactory[t](...e)}add(t,e,r,i){return 1===arguments.length&&t.forEach((t=>this.add(t.subject,t.predicate,t.object,t.graph))),this.statements.push(this.rdfFactory.quad(t,e,r,i))}addStatement(t){return this.add(t)}bnode(t){return this.rdfFactory.blankNode(t)}addAll(t){t.forEach((t=>{this.add(t.subject,t.predicate,t.object,t.graph)}))}any(t,e,r,i){const n=this.anyStatementMatching(t,e,r,i);return null==n?null:null==t?n.subject:null==e?n.predicate:null==r?n.object:null}anyValue(t,e,r,i){const n=this.any(t,e,r,i);return n?n.value:void 0}anyJS(t,e,i,n){const s=this.any(t,e,i,n);return s?r.A.toJS(s):void 0}anyStatementMatching(t,e,r,i){let n=this.statementsMatching(t,e,r,i,!0);if(n&&0!==n.length)return n[0]}id(t){return this.rdfFactory.id(t)}statementsMatching(t,e,r,i,n){const s=this.statements.filter((n=>(!t||t.equals(n.subject))&&(!e||e.equals(n.predicate))&&(!r||r.equals(n.object))&&(!i||i.equals(n.graph))));return n?0===s.length?[]:[s[0]]:s}bottomTypeURIs(t){let e,r,i,n,s,a,o,h;e=[];for(let l in t)if(t.hasOwnProperty(l)){for(h=t[l],o=this.each(void 0,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),this.rdfFactory.namedNode(l)),r=!0,n=0,s=o.length;n<s;n++)if(i=o[n],a=i.uri,a in t){r=!1;break}r&&(e[l]=h)}return e}collection(){return new f}each(t,e,r,i){const n=[];let a=this.statementsMatching(t,e,r,i,!1);if(null==t)for(let t=0,e=a.length;t<e;t++)n.push(a[t].subject);else if(null==e)for(let t=0,e=a.length;t<e;t++)n.push(a[t].predicate);else if(null==r)for(let t=0,e=a.length;t<e;t++)n.push(a[t].object);else if(null==i)for(let t=0,e=a.length;t<e;t++)n.push(new s.A(a[t].graph.value));return n}equals(t){return!!t&&this.hashString()===t.hashString()}findMembersNT(t){let e,r,i,n,s,a,o,h,l,u,c,f,d,p;f={},f[t.toNT()]=!0,n={},a=this.transitiveClosure(f,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!0);for(let t in a)if(a.hasOwnProperty(t)){o=this.statementsMatching(void 0,this.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),this.fromNT(t));for(let t=0,e=o.length;t<e;t++)d=o[t],n[d.subject.toNT()]=d;h=this.each(void 0,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#domain"),this.fromNT(t));for(let t=0,r=h.length;t<r;t++)for(s=h[t],l=this.statementsMatching(void 0,s),i=0,e=l.length;i<e;i++)d=l[i],n[d.subject.toNT()]=d;u=this.each(void 0,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#range"),this.fromNT(t));for(let t=0,e=u.length;t<e;t++)for(s=u[t],c=this.statementsMatching(void 0,s),p=0,r=c.length;p<r;p++)d=c[p],n[d.object.toNT()]=d}return n}findMemberURIs(t){return this.NTtoURI(this.findMembersNT(t))}findSubClassesNT(t){let e={};return e[t.toNT()]=!0,this.transitiveClosure(e,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!0)}findSuperClassesNT(t){let e={};return e[t.toNT()]=!0,this.transitiveClosure(e,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!1)}findTypesNT(t){let e,r,i,n,s,a,o,h,l;i="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",l=[],n=this.statementsMatching(t,void 0,void 0);for(let t=0,e=n.length;t<e;t++)if(h=n[t],"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"===h.predicate.uri)l[h.object.toNT()]=h;else{s=this.each(h.predicate,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#domain"));for(let t=0,e=s.length;t<e;t++)r=s[t],l[r.toNT()]=h}a=this.statementsMatching(void 0,void 0,t);for(let t=0,r=a.length;t<r;t++){h=a[t],o=this.each(h.predicate,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#range"));for(let t=0,r=o.length;t<r;t++)e=o[t],l[e.toNT()]=h}return this.transitiveClosure(l,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!1)}findTypeURIs(t){return this.NTtoURI(this.findTypesNT(t))}connectedStatements(t,e,r){r=r||[];let i=[t],n={},s={},a=[],o=this,h=function(t){let h=function(t){"BlankNode"!==t.termType||n[t.value]||(n[t.value]=!0,i.push(t))},l=o.statementsMatching(null,null,t,e).concat(o.statementsMatching(t,null,null,e));l=l.filter((function(t){if(r[t.predicate.value])return!1;let e=t.toNT();return!s[e]&&(s[e]=!0,!0)})),l.forEach((function(t){h(t.subject),h(t.object)})),a=a.concat(l)};for(;i.length;)h(i.shift());return a}formula(t){return new P}fromNT(t){let e,r,i;switch(t[0]){case"<":return this.sym(t.slice(1,-1));case'"':if(i=void 0,e=void 0,r=t.lastIndexOf('"'),r<t.length-1)if("@"===t[r+1])i=t.slice(r+2);else{if("^^"!==t.slice(r+1,r+3))throw new Error("Can't convert string from NT: "+t);e=this.fromNT(t.slice(r+3))}return t=(t=(t=(t=t.slice(1,r)).replace(/\\"/g,'"')).replace(/\\n/g,"\n")).replace(/\\\\/g,"\\"),this.rdfFactory.literal(t,i||e);case"_":return this.rdfFactory.blankNode(t.slice(2));case"?":return new v(t.slice(1))}throw new Error("Can't convert from NT: "+t)}holds(t,e,r,i){let n;if(1===arguments.length){if(!t)return!0;if(t instanceof Array){for(n=0;n<t.length;n++)if(!this.holds(t[n]))return!1;return!0}if((0,a.SH)(t))return this.holds(t.subject,t.predicate,t.object,t.graph);if(t.statements)return this.holds(t.statements)}return null!=this.anyStatementMatching(t,e,r,i)}holdsStatement(t){return this.holds(t.subject,t.predicate,t.object,t.graph)}list(t,e){if(e.rdfFactory.supports.COLLECTIONS){const r=e.rdfFactory.collection();return t.forEach((function(t){r.append(t)})),r}{const r=e.rdfFactory.blankNode(),i=L(e.rdfFactory,r,t);return e.addAll(i),r}}NTtoURI(t){let e,r,i={};for(e in t)t.hasOwnProperty(e)&&(r=t[e],"<"===e[0]&&(i[e.slice(1,-1)]=r));return i}serialize(t,e,r,i){return F(r,this,t,e,void 0,i)}substitute(t){let e=this.statements.map((function(e){return e.substitute(t)}));const r=new P;return r.addAll(e),r}sym(t,e){if(e)throw new Error("This feature (kb.sym with 2 args) is removed. Do not assume prefix mappings.");return this.rdfFactory.namedNode(t)}the(t,e,r,i){let n=this.any(t,e,r,i);return null==n&&N.A.error("No value found for the() {"+t+" "+e+" "+r+"}."),n}transitiveClosure(t,e,r){let i,n,s,a,o,h,l={};Object.assign(l,t);let u={};for(;;){if(h=function(){for(let t in l)if(l.hasOwnProperty(t))return t}(),null==h)return u;for(o=r?this.each(void 0,e,this.fromNT(h)):this.each(this.fromNT(h),e),n=0,s=o.length;n<s;n++)i=o[n],a=i.toNT(),a in u||a in l||(l[a]=l[h]);u[h]=l[h],delete l[h]}}topTypeURIs(t){let e,r,i,n,s,a,o,h;for(i in o=[],t)if(t.hasOwnProperty(i)){for(h=t[i],s=0,a=this.each(this.rdfFactory.namedNode(i),this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf")),e=0,n=a.length;e<n;e++)if(r=a[e],"http://www.w3.org/2000/01/rdf-schema#Resource"!==r.uri){s++;break}s||(o[i]=h)}return o["http://www.w3.org/2000/01/rdf-schema#Resource"]&&delete o["http://www.w3.org/2000/01/rdf-schema#Resource"],o["http://www.w3.org/2002/07/owl#Thing"]&&delete o["http://www.w3.org/2002/07/owl#Thing"],o}toString(){return"{"+this.statements.join("\n")+"}"}variable(t){return new v(t)}whether(t,e,r,i){return this.statementsMatching(t,e,r,i,!1).length}}r.A.fromValue=c;const B=r.A,q={xsd:E("http://www.w3.org/2001/XMLSchema#")};r.A.toJS=function(t){return(0,a.P3)(t)?t.elements.map(r.A.toJS):(0,a.c$)(t)?t.datatype.equals(q.xsd("boolean"))?"1"===t.value||"true"===t.value:t.datatype.equals(q.xsd("dateTime"))||t.datatype.equals(q.xsd("date"))?new Date(t.value):t.datatype.equals(q.xsd("integer"))||t.datatype.equals(q.xsd("float"))||t.datatype.equals(q.xsd("decimal"))?Number(t.value):t.value:t};class ${constructor(t,e){this.pat=new G,this.vars=[],this.name=t,this.id=e}}function H(t,e,r,i){function n(t){var e,r="";for(e in t)t.hasOwnProperty(e)&&(r+=" "+e+" -> "+t[e]);return r}function s(t){var e,r="Bindings: ",i=t.length;for(e=0;e<i;e++)r+=n(t[e][0])+";\n\t";return r}function a(t,e,r,i){var n;if(t.length!==e.length)return[];if(!t.length)return[[[],null]];var s=function(t,e,r,i){var n=r[t];if(void 0===n){if(t.isVar){var s=[];return s[t]=e,[[s,null]]}n=t}if(!n.complexType)return i.redirections[n]&&(n=i.redirections[n]),i.redirections[e]&&(e=i.redirections[e]),n.equals(e)||n.uri&&n.uri===p?[[[],null]]:[];if(t instanceof Array)return e instanceof Array?a(t,e,r):[];throw new Error("query.js: oops - code not written yet")}(t[0],e[0],r,i);if(0===s.length)return s;var o,h,l,u,c,f,d,g=[],m=s.length;for(o=0;o<m;o++){for(c in d=[],h=s[o][0])h.hasOwnProperty(c)&&(d[c]=h[c]);for(c in r)r.hasOwnProperty(c)&&(d[c]=r[c]);for(u=(n=a(t.slice(1),e.slice(1),d,i)).length,l=0;l<u;l++){for(c in f=n[l][0],h)h.hasOwnProperty(c)&&(f[c]=h[c]);g.push([f,null])}}return g}function o(t,e){var r,i={};for(r in t)t.hasOwnProperty(r)&&(i[r]=t[r]);for(r in e)e.hasOwnProperty(r)&&(i[r]=e[r]);return i}function h(t,e){return this.trunkBindings=e,this.originalCallback=t,this.branches=[],this}function l(t,e){return this.count=0,this.success=!1,this.done=!1,this.callback=t,this.onDone=e,this}h.prototype.checkAllDone=function(){var t;for(t=0;t<this.branches.length;t++)if(!this.branches[t].done)return;N.A.debug("OPTIONAL BIDNINGS ALL DONE:"),this.doCallBacks(this.branches.length-1,this.trunkBindings)},h.prototype.doCallBacks=function(t,e){var r;if(t<0)return this.originalCallback(e);for(r=0;r<this.branches[t].results.length;r++)this.doCallBacks(t-1,o(e,this.branches[t].results[r]))},l.prototype.reportMatch=function(t){this.callback(t),this.success=!0},l.prototype.reportDone=function(){this.done=!0,N.A.info("Mandatory query branch finished.***"),void 0!==this.onDone&&this.onDone()};var u=function(t){return this.count=0,this.done=!1,this.results=[],this.junction=t,t.branches.push(this),this};function c(t,e,r){var i,n,s,a,o,h;for(e.nvars=0,e.index=null,i=[e.subject,e.predicate,e.object,e.why],a=[t.subjectIndex,t.predicateIndex,t.objectIndex,t.whyIndex],s=0;s<4;s++){let l=i[s];if(l.uri&&l.uri===p);else if(l.isVar&&void 0===r[l])e.nvars++;else{if(void 0,l=void 0===(h=r[o=i[s]])?o:h,t.redirections[t.id(l)]&&(l=t.redirections[t.id(l)]),!(n=a[s][t.id(l)]))return e.index=[],!1;(null===e.index||e.index.length>n.length)&&(e.index=n)}}return null===e.index&&(e.index=t.statements),!0}function f(t,e){return t.nvars!==e.nvars?t.nvars-e.nvars:t.index.length-e.index.length}u.prototype.reportMatch=function(t){this.results.push(t)},u.prototype.reportDone=function(){N.A.debug("Optional branch finished - results.length = "+this.results.length),0===this.results.length&&(this.results.push({}),N.A.debug("Optional branch FAILED - that's OK.")),this.done=!0,this.junction.checkAllDone()};var d=function(t,r,i,s,a,o,l){N.A.debug("Match begins, Branch count now: "+l.count+" for "+l.pattern_debug);var c,f,p=r.statements;if(0===p.length){if(N.A.debug("FOUND MATCH WITH BINDINGS:"+n(i)),0===r.optional.length)l.reportMatch(i);else{N.A.debug("OPTIONAL: "+r.optional);var g,w=new h(e,i),y=[];for(g=0;g<r.optional.length;g++)y[g]=new u(w),y[g].pattern_debug=r.optional[g];for(g=0;g<r.optional.length;g++)y[g].count=y[g].count+1,d(t,r.optional[g],i,"",a,e,y[g])}return l.count--,void N.A.debug("Match ends -- success , Branch count now: "+l.count+" for "+l.pattern_debug)}var v=p.length;if(a){var _=function(e,n){var h=e.uri.split("#")[0];a.nowOrWhenFetched(h,void 0,(function(n,h,u){n||console.log("Error following link to <"+e.uri+"> in query: "+h),d(t,r,i,s,a,o,l)}))};for(f=0;f<v;f++){if(c=p[f],void 0!==i[c.subject]&&i[c.subject].uri&&a&&"unrequested"===a.getState((0,b.docpart)(i[c.subject].uri)))return void _(i[c.subject]);if(void 0!==i[c.object]&&i[c.object].uri&&a&&"unrequested"===a.getState((0,b.docpart)(i[c.object].uri)))return void _(i[c.object])}}m(t,r,i,s,a,o,l)},g=function(t,e){var r,i,n=!0;for(r in t)t.hasOwnProperty(r)&&e[r]&&(i=e[r].test)&&!i(t[r])&&(n=!1);return n},m=function(t,e,r,i,o,h,l){var u,p,m,w,y,b,v,_=e.statements,x=_.length;for(u=0;u<x;u++)c(t,v=_[u],r);_.sort(f),v=_[0];var T,A=t.formula();A.optional=e.optional,A.constraints=e.constraints,A.statements=_.slice(1),N.A.debug(i+"match2 searching "+v.index.length+" for "+v+"; bindings so far="+n(r));var E,R,k=v.index.length,I=0;for(T=0;T<k;T++)for(R=v.index[T],E=a([v.subject,v.predicate,v.object,v.why],[R.subject,R.predicate,R.object,R.why],r,t),N.A.info(i+" From first: "+E.length+": "+s(E)),m=E.length,p=0;p<m;p++)if(y=[],b=E[p][0],g(b,e.constraints)){for(w in b)b.hasOwnProperty(w)&&(y[w]=b[w]);for(w in r)r.hasOwnProperty(w)&&(y[w]=r[w]);l.count++,I++,d(t,A,y,i+" ",o,h,l)}else N.A.debug("Branch count CS: "+l.count);l.count--,0===I&&N.A.debug("Match2 fails completely on "+v),N.A.debug("Match2 ends, Branch count: "+l.count+" for "+l.pattern_debug),0===l.count&&(N.A.debug("Branch finished."),l.reportDone())},w=this;N.A.debug("Query on "+this.statements.length);var y=new l(e,i);y.count++,t.sync?d(w,t.pat,t.pat.initBindings,"",r,e,y):setTimeout((function(){d(w,t.pat,t.pat.initBindings,"",r,e,y)}),0)}const X="http://www.w3.org/2002/07/owl#";function z(t,e,r,i){var n=t.any(e,r,void 0);return!!n&&(t.equate(n,i),!0)}function Q(t,e,r,i){var n=t.any(void 0,r,i);return!!n&&(t.equate(n,e),!0)}function V(t,e,r,i,n){t.typeCallback&&t.typeCallback(t,i,n);var s=t.classActions[t.id(i)],a=!1;if(s)for(var o=0;o<s.length;o++)a=a||s[o](t,e,r,i,n);return a}class G extends P{constructor(e,r={}){super(void 0,void 0,void 0,void 0,r),(0,t.A)(this,"updater",void 0),(0,t.A)(this,"namespaces",void 0),(0,t.A)(this,"classActions",void 0),(0,t.A)(this,"propertyActions",void 0),(0,t.A)(this,"redirections",void 0),(0,t.A)(this,"aliases",void 0),(0,t.A)(this,"HTTPRedirects",void 0),(0,t.A)(this,"subjectIndex",void 0),(0,t.A)(this,"predicateIndex",void 0),(0,t.A)(this,"objectIndex",void 0),(0,t.A)(this,"whyIndex",void 0),(0,t.A)(this,"index",void 0),(0,t.A)(this,"features",void 0),(0,t.A)(this,"_universalVariables",void 0),(0,t.A)(this,"_existentialVariables",void 0),(0,t.A)(this,"rdfArrayRemove",void 0),(0,t.A)(this,"dataCallbacks",[]),(0,t.A)(this,"dataRemovalCallbacks",[]),this.propertyActions={},this.classActions={},this.redirections=[],this.aliases=[],this.HTTPRedirects=[],this.subjectIndex=[],this.predicateIndex=[],this.objectIndex=[],this.whyIndex=[],this.index=[this.subjectIndex,this.predicateIndex,this.objectIndex,this.whyIndex],this.namespaces={},this.features=e||[],this.rdfArrayRemove=r.rdfArrayRemove||C.RDFArrayRemove,r.dataCallback&&(this.dataCallbacks=[r.dataCallback]),r.dataRemovalCallback&&(this.dataRemovalCallbacks=[r.dataRemovalCallback]),this.initPropertyActions(this.features)}static get defaultGraphURI(){return p}substitute(t){var e=this.statements.map((function(e){return e.substitute(t)})),r=new G;return r.add(e),r}addDataCallback(t){this.dataCallbacks.push(t)}addDataRemovalCallback(t){this.dataRemovalCallbacks.push(t)}applyPatch(t,e,r){var i,n=this,s=null;function a(a){if(t.delete){i=t.delete,s&&(i=i.substitute(s)),i=i.statements;var o=[],h=i.map((function(t){var r=n.statementsMatching(t.subject,t.predicate,t.object,e);return 0===r.length?(o.push(t),null):r[0]}));if(o.length)return r("Could not find to delete: "+o.join("\n or "));h.map((function(t){n.remove(t)}))}t.insert&&(i=t.insert,s&&(i=i.substitute(s)),(i=i.statements).map((function(t){t.graph=e,n.add(t.subject,t.predicate,t.object,t.graph)}))),a()}if(t.where){var o=new $("patch");o.pat=t.where,o.pat.statements.map((function(t){t.graph=ze(e.value)})),o.sync=!0;var h=[];n.query(o,(function(t){h.push(t)}),n.fetcher,(function(){return 0===h.length?r("No match found to be patched:"+t.where):h.length>1?r("Patch ambiguous. No patch done."):(s=h[0],void a(r))}))}else a(r)}declareExistential(t){return this._existentialVariables||(this._existentialVariables=[]),this._existentialVariables.push(t),t}initPropertyActions(t){this.propertyActions[this.rdfFactory.id(this.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))]=[V],M(t,"sameAs")>=0&&(this.propertyActions[this.rdfFactory.id(this.rdfFactory.namedNode(`${X}sameAs`))]=[function(t,e,r,i,n){return t.equate(e,i),!0}]),M(t,"InverseFunctionalProperty")>=0&&(this.classActions[this.rdfFactory.id(this.rdfFactory.namedNode(`${X}InverseFunctionalProperty`))]=[function(t,e,r,i,n){return t.newPropertyAction(e,Q)}]),M(t,"FunctionalProperty")>=0&&(this.classActions[this.rdfFactory.id(this.rdfFactory.namedNode(`${X}FunctionalProperty`))]=[function(t,e,r,i,n){return t.newPropertyAction(e,z)}])}addStatement(t){return this.add(t.subject,t.predicate,t.object,t.graph),this.statements.length}add(t,e,r,i){var n,s,o;if(1===arguments.length){if(t instanceof Array)for(n=0;n<t.length;n++)this.add(t[n]);else(0,a.aF)(t)?this.add(t.subject,t.predicate,t.object,t.graph):(0,a.ok)(t)&&this.add(t.statements);return this}i||(i=this.fetcher?this.fetcher.appNode:this.rdfFactory.defaultGraph()),"string"==typeof t&&(t=this.rdfFactory.namedNode(t)),e=B.fromValue(e);const h=B.fromValue(r);if(i=B.fromValue(i),!(0,a.CZ)(t))throw new Error("Subject is not a subject type");if(!(0,a.fY)(e))throw new Error(`Predicate ${e} is not a predicate type`);if(!(0,a.DJ)(h))throw new Error(`Object ${h} is not an object type`);if(!(0,a.RN)(i))throw new Error("Why is not a graph type");this.predicateCallback&&this.predicateCallback(this,e,i);var l=this.id(this.canon(e)),u=!1;if(s=this.propertyActions[l])for(n=0;n<s.length;n++)u=u||s[n](this,t,e,h,i);if(this.holds(t,e,h,i))return null;var c=[this.id(this.canon(t)),l,this.id(this.canon(h)),this.id(this.canon(i))];for(o=this.rdfFactory.quad(t,e,h,i),n=0;n<4;n++){var f=this.index[n],d=c[n];f[d]||(f[d]=[]),f[d].push(o)}this.statements.push(o);for(const t of this.dataCallbacks)t(o);return o}canon(t){if(!t)return t;const e=this.redirections[this.id(t)];if(e)return e;switch(t.termType){case i.$Q:return new n(t.value);case i.r0:return t;case i.ic:return new g;case i.S:case i.bD:return t;case i.QW:return new u(t.value,t.language,t.datatype);case i.Kk:return new s.A(t.value);case i.P2:return new v(t.value);default:throw new Error(`Term Type not recognized for canonization: ${t.termType}`)}}check(){this.checkStatementList(this.statements);for(var t=0;t<4;t++){var e=this.index[t];for(var r in e)e.hasOwnProperty(r)&&this.checkStatementList(e[r],t)}}checkStatementList(t,e){void 0===e&&(e=0);for(var r,i=" found in "+["subject","predicate","object","why"][e]+" index.",n=0;n<t.length;n++){for(var s=[(r=t[n]).subject,r.predicate,r.object,r.graph],a=function(t,e){for(var r=0;r<t.length;r++)if(t[r].subject.equals(e.subject)&&t[r].predicate.equals(e.predicate)&&t[r].object.equals(e.object)&&t[r].why.equals(e.graph))return!0},o=0;o<4;o++){var h=this.canon(s[o]),l=this.id(h);this.index[o][l]&&a(this.index[o][l],r)}if(!a(this.statements,r))throw new Error("Statement list does not statement "+r+"@"+r.graph+i)}}close(){return this}compareTerms(t,r){return Object.prototype.hasOwnProperty.call(t,"compareTerm")?t.compareTerm(r):e.A[t.termType]<e.A[r.termType]?-1:e.A[t.termType]>e.A[r.termType]?1:t.value<r.value?-1:t.value>r.value?1:0}copyTo(t,e,r){r||(r=[]);var i=this.statementsMatching(t);-1!==M(r,"two-direction")&&i.concat(this.statementsMatching(void 0,void 0,t));for(var n=0;n<i.length;n++){var s=i[n];switch(s.object.termType){case"NamedNode":this.add(e,s.predicate,s.object);break;case"Literal":case"BlankNode":case"Collection":this.add(e,s.predicate,s.object.copy(this))}-1!==M(r,"delete")&&this.remove(s)}}equate(t,e){const r=this.canon(t),i=this.canon(e);var n=this.compareTerms(r,i);return!n||(n<0?this.replaceWith(i,r):this.replaceWith(r,i))}formula(t){return new G(t)}get length(){return this.statements.length}match(t,e,r,i){return this.statementsMatching(B.fromValue(t),B.fromValue(e),B.fromValue(r),B.fromValue(i))}mentionsURI(t){var e="<"+t+">";return!!this.subjectIndex[e]||!!this.objectIndex[e]||!!this.predicateIndex[e]}newExistential(t){if(!t)return this.bnode();var e=this.sym(t);return this.declareExistential(e)}newPropertyAction(t,e){var r=this.id(t);this.propertyActions[r]||(this.propertyActions[r]=[]),this.propertyActions[r].push(e);for(var i=this.statementsMatching(void 0,t,void 0),n=!1,s=0;s<i.length;s++)n=n||e(this,i[s].subject,t,i[s].object);return n}newUniversal(t){var e=this.sym(t);return this._universalVariables||(this._universalVariables=[]),this._universalVariables.push(e),e}variable(t){return new v(t)}nextSymbol(t){for(var e=0;;e++){var r=t.value+"#n"+e;if(!this.mentionsURI(r))return this.sym(r)}}query(t,e,r,i){return H.call(this,t,e,r,i)}querySync(t){var e=[],r=!1;if(t.sync=!0,H.call(this,t,(function(t){e.push(t)}),null,(function(){r=!0})),!r)throw new Error("Sync query should have called done function");return e}remove(t){if(t instanceof Array){for(var e=0;e<t.length;e++)this.remove(t[e]);return this}if((0,a.ok)(t))return this.remove(t.statements);var r=this.statementsMatching(t.subject,t.predicate,t.object,t.graph);if(!r.length)throw new Error("Statement to be removed is not on store: "+t);return this.removeStatement(r[0]),this}removeDocument(t){this.removeMetadata(t);for(var e=this.statementsMatching(void 0,void 0,void 0,t).slice(),r=0;r<e.length;r++)this.removeStatement(e[r]);return this.removeMatches(t,null,null),this}removeMetadata(t){const e=this.sym("chrome://TheCurrentSession"),r="http://www.w3.org/2007/ont/link#",i=this.statementsMatching(void 0,this.sym(`${r}requestedURI`),this.rdfFactory.literal(t.value),e).map((t=>t.subject));for(var n=0;n<i.length;n++){const t=i[n];if(null!=t){let i;const n=this.any(t,this.sym(`${r}status`),null,e);if(null!=n){i=this.statementsMatching(n,this.sym(`${r}status`),null,e).slice();for(var s=0;s<i.length;s++)this.removeStatement(i[s])}const a=this.any(t,this.sym(`${r}response`),null,e);if(null!=a)for(i=this.statementsMatching(a,null,null,e).slice(),s=0;s<i.length;s++)this.removeStatement(i[s]);for(i=this.statementsMatching(t,null,null,e).slice(),s=0;s<i.length;s++)this.removeStatement(i[s])}}return this.removeMatches(this.sym(t.value),null,null,e),this}removeMany(t,e,r,i,n){for(var s=this.statementsMatching(t,e,r,i,!1),a=[],o=0;o<s.length;o++)a.push(s[o]);for(n&&(a=a.slice(0,n)),o=0;o<a.length;o++)this.remove(a[o])}removeMatches(t,e,r,i){return this.removeMany(t,e,r,i),this}removeStatement(t){for(var e=[t.subject,t.predicate,t.object,t.graph],r=0;r<4;r++){var i=this.canon(e[r]),n=this.id(i);this.index[r][n]&&this.rdfArrayRemove(this.index[r][n],t)}this.rdfArrayRemove(this.statements,t);for(const e of this.dataRemovalCallbacks)e(t);return this}removeStatements(t){for(var e=0;e<t.length;e++)this.remove(t[e]);return this}replaceWith(t,e){for(var r=this.id(t),i=this.id(e),n=function(t){var e=t[r];if(e){var n=t[i];t[i]=n?e.concat(n):e,delete t[r]}},s=0;s<4;s++)n(this.index[s]);if(this.redirections[r]=e,t.value){if(this.aliases[i]||(this.aliases[i]=[]),this.aliases[i].push(t),this.aliases[r])for(s=0;s<this.aliases[r].length;s++)this.redirections[this.id(this.aliases[r][s])]=e,this.aliases[i].push(this.aliases[r][s]);this.add(e,this.sym("http://www.w3.org/2007/ont/link#uri"),t),this.fetcher&&this.fetcher.nowKnownAs(t,e)}return n(this.classActions),n(this.propertyActions),!0}allAliases(t){var e=this.aliases[this.id(this.canon(t))]||[];return e.push(this.canon(t)),e}sameThings(t,e){if(t.equals(e))return!0;var r=this.canon(t);if(!r)return!1;var i=this.canon(e);return!!i&&r.value===i.value}setPrefixForURI(t,e){if(("tab"!==t||!this.namespaces.tab)&&"ns"!==t.slice(0,2)&&"default"!==t.slice(0,7)){for(let t in this.namespaces)this.namespaces[t]==e&&delete this.namespaces[t];this.namespaces[t]=e}}statementsMatching(t,e,r,i,n){var s,a,o=[t,e,r,i],h=[],l=[],u=[],c=[];for(s=0;s<4;s++)h[s]=this.canon(B.fromValue(o[s])),h[s]?(c.push(s),l[s]=this.id(h[s])):u.push(s);if(0===c.length)return this.statements;if(1===c.length)return s=c[0],(a=this.index[s][l[s]])&&n&&a.length>1&&(a=a.slice(0,1)),a||[];var f,d,p=1e10;for(d=0;d<c.length;d++){if(s=c[d],!(a=this.index[s][l[s]]))return[];a.length<p&&(p=a.length,f=d)}for(var g=c[f],m=this.index[g][l[g]],w=c.slice(0,f).concat(c.slice(f+1)),y=[],b=["subject","predicate","object","why"],v=0;v<m.length;v++){var _=m[v];for(d=0;d<w.length;d++)if(s=w[d],!this.canon(_[b[s]]).equals(h[s])){_=null;break}if(null!=_&&(y.push(_),n))break}return y}uris(t){var e=this.canon(t),r=this.aliases[this.id(e)];if(!e.value)return[];var i=[e.value];if(r)for(var n=0;n<r.length;n++)i.push(r[n].uri);return i}serialize(t,e,r,i){return F(r,this,t,e,void 0,i={...i||{},namespaces:i?.namespaces?{...this.namespaces,...i.namespaces}:{...this.namespaces}})}}(0,t.A)(G,"handleRDFType",void 0),G.handleRDFType=V;const W=E("http://www.w3.org/1999/02/22-rdf-syntax-ns#");function Y(t,e){function r(i,n,s){const a=t.statementsMatching(i,W("rest"),null,e);if(1!==a.length)throw new Error(`Bad list structure: no rest at ${i}`);const o=t.statementsMatching(i,W("first"),null,e);if(1!==o.length)throw new Error(`Bad list structure: rest but ${o.length} firsts at ${i}`);const h=[o[0].object].concat(n),l=s.concat(a).concat(o),u=t.statementsMatching(null,W("rest"),i,e);if(0===u.length){const r=new f(h);return t.remove(l),void function(t,e,r,i){for(const n of t.statementsMatching(r,null,null,i)){const r=new y(e,n.predicate,n.object,i);t.remove(n),t.add(r)}for(const n of t.statementsMatching(null,r,null,i))t.remove(n),t.add(new y(n.subject,e,n.object,i));for(const n of t.statementsMatching(null,null,r,i))t.remove(n),t.add(new y(n.subject,n.predicate,e,i))}(t,r,i,e)}if(1!==u.length)throw new Error(`Bad list structure: ${u.length} pres at ${i}`);const c=u[0].subject;if("BlankNode"!==c.termType)throw new Error(`Bad list element node ${c} type: ${c.termType} `);r(c,h,l)}!function(t,e){const r=W("nil");for(const i of t.statementsMatching(r,null,null,e)){t.remove(i);const r=new f;t.add(new y(r,i.predicate,i.object,e))}for(const i of t.statementsMatching(null,null,r,e))if(!i.predicate.sameTerm(W("rest"))){t.remove(i);const r=new f;t.add(new y(i.subject,i.predicate,r,e))}}(t,e),t.statementsMatching(null,W("rest"),W("nil"),e).forEach((t=>{if("BlankNode"!==t.subject.termType)throw new Error(`Bad list element node ${t.subject} type: ${t.subject.termType} `);r(t.subject,[],[])}))}var Z="http://www.w3.org/2000/10/swap/log#",J=function(t){return t},K=function(t){return t},tt=function(t){if(t.length>0)throw"missing.js: oops nnonempty dict not imp";return[]},et=function(t){return t.length},rt=function(t,e,r){if(void 0===t.slice)throw"@@ mising.js: No .slice function for "+t+" of type "+typeof t;return void 0===r||null==r?t.slice(e):t.slice(e,r)},it=Error("dummy error stop iteration"),nt=function(t){return this.last=0,this.li=t,this.next=function(){if(this.last==this.li.length)throw it;return this.li[this.last++]},this},st=function(t,e){return t.indexOf(e)},at=function(t,e){if(!t){if(e)throw"python Assertion failed: "+e;throw"(python) Assertion failed."}};String.prototype.encode=function(t){if("utf-8"!=t)throw"UTF8_converter: can only do utf-8";return function(t){t=t.replace(/\r\n/g,"\n");for(var e="",r=0;r<t.length;r++){var i=t.charCodeAt(r);i<128?e+=String.fromCharCode(i):i>127&&i<2048?(e+=String.fromCharCode(i>>6|192),e+=String.fromCharCode(63&i|128)):(e+=String.fromCharCode(i>>12|224),e+=String.fromCharCode(i>>6&63|128),e+=String.fromCharCode(63&i|128))}return e}(this)},String.prototype.decode=function(t){if("utf-8"!=t)throw"UTF8_converter: can only do utf-8";return this};var ot=function(t,e){return b.join(e,t)},ht="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil",lt="http://www.w3.org/2002/07/owl#sameAs",ut="\t\r\n !\"#$%&'()*.,+/;<=>?@[\\]^`{|}~",ct=ut+":",ft=new RegExp("^([-+]?[0-9]+)(\\.[0-9]+)?([eE][-+]?[0-9]+)?","g"),dt=new RegExp("^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9](T[0-9][0-9]:[0-9][0-9](:[0-9][0-9](\\.[0-9]*)?)?)?Z?"),pt=new RegExp("[\\s#]"),gt=new RegExp('[\\\\\\r\\n\\"]',"g"),mt=new RegExp("^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*","g");function wt(t,e){var r=t.charAt(e+1);return""===r||pt.test(r)}const yt=function(t,e,r,i,n,s,a,o){return new bt(t,e,r,i,n,s,a,o)};class bt{constructor(t,e,r,i,n,s,a,o){void 0===e&&(e=null),void 0===r&&(r=""),void 0===i&&(i=null),void 0===n&&(n=""),void 0===s&&(s=null),void 0===a&&(a=""),void 0===o&&(o=null),this._bindings=new tt([]),this._flags=a,""!=r&&(at(r.indexOf(":")>=0,"Document URI not absolute: "+r),this._bindings[""]=r+"#"),this._store=t,n&&t.setGenPrefix(n),this._thisDoc=r,this.source=t.sym(r),this.lines=0,this.statementCount=0,this.hasNil=!1,this.startOfLine=0,this.previousLine=0,this._genPrefix=n,this.keywords=new K(["a","this","bind","has","is","of","true","false"]),this.keywordsSet=0,this._anonymousNodes=new tt([]),this._variables=new tt([]),this._parentVariables=new tt([]),this._reason=o,this._reason2=null,this._baseURI=i||r||null,at(!this._baseURI||this._baseURI.indexOf(":")>=0),this._genPrefix||(this._thisDoc?this._genPrefix=this._thisDoc+"#_g":this._genPrefix=RDFSink_uniqueURI()),null==e?this._thisDoc?this._formula=t.formula(r+"#_formula"):this._formula=t.formula():this._formula=e,this._context=this._formula,this._parentContext=null}here(t){return this._genPrefix+"_L"+this.lines+"C"+(t-this.startOfLine+1)}formula(){return this._formula}loadStream(t){return this.loadBuf(t.read())}loadBuf(t){return this.startDoc(),this.feed(t),this.endDoc()}feed(t){for(var e=t.decode("utf-8"),r=0;r>=0;){var i=this.skipSpace(e,r);if(i<0)return;if((r=this.directiveOrStatement(e,i))<0)throw vt(this._thisDoc,this.lines,e,i,"expected directive or statement")}}directiveOrStatement(t,e){var r,i=this.skipSpace(t,e);return i<0?i:(r=this.directive(t,i))>=0||(r=this.statement(t,i))>=0?this.checkDot(t,r):r}tok(t,e,r){if("@"==e.slice(r,r+1))r+=1;else if(M(this.keywords,t)<0)return-1;var i=r+et(t);return e.slice(r,i)==t&&ut.indexOf(e.charAt(i))>=0?i:-1}directive(t,e){if((s=this.skipSpace(t,e))<0)return s;var r=new K([]);if((s=this.tok("bind",t,e))>0)throw vt(this._thisDoc,this.lines,t,e,"keyword bind is obsolete: use @prefix");if((s=this.tok("keywords",t,e))>0){if((e=this.commaSeparatedList(t,s,r,!1))<0)throw vt(this._thisDoc,this.lines,t,e,"'@keywords' needs comma separated list of words");return this.setKeywords(rt(r,null,null)),e}if((s=this.tok("forAll",t,e))>0){if((e=this.commaSeparatedList(t,s,r,!0))<0)throw vt(this._thisDoc,this.lines,t,e,"Bad variable list after @forAll");var i=new nt(r);try{for(;;){var n=i.next();(M(this._variables,n)<0||M(this._parentVariables,n)>=0)&&(this._variables[n]=this._context.newUniversal(n))}}catch(t){if(t!=it)throw t}return e}if((s=this.tok("forSome",t,e))>0){if((e=this.commaSeparatedList(t,s,r,this.uri_ref2))<0)throw vt(this._thisDoc,this.lines,t,e,"Bad variable list after @forSome");i=new nt(r);try{for(;;)n=i.next(),this._context.declareExistential(n)}catch(t){if(t!=it)throw t}return e}if((s=this.tok("prefix",t,e))>=0){var s,a=new K([]);if((e=this.qname(t,s,a))<0)throw vt(this._thisDoc,this.lines,t,s,"expected qname after @prefix");if((s=this.uri_ref2(t,e,a))<0)throw vt(this._thisDoc,this.lines,t,e,"expected <uriref> after @prefix _qname_");var o=a[1].uri;return this._baseURI?o=ot(this._baseURI,o):at(o.indexOf(":")>=0,"With no base URI, cannot handle relative URI for NS"),at(o.indexOf(":")>=0),this._bindings[a[0][0]]=o,this.bind(a[0][0],function(t){return encodeURI(t)}(o)),s}if((s=this.tok("base",t,e))>=0){if(a=new K([]),(e=this.uri_ref2(t,s,a))<0)throw vt(this._thisDoc,this.lines,t,s,"expected <uri> after @base ");if(o=a[0].uri,!this._baseURI)throw vt(this._thisDoc,this.lines,t,s,"With no previous base URI, cannot use relative URI in @base <"+o+">");return o=ot(this._baseURI,o),at(o.indexOf(":")>=0),this._baseURI=o,e}return-1}bind(t,e){""==t||this._store.setPrefixForURI(t,e)}setKeywords(t){null==t?this.keywordsSet=0:(this.keywords=t,this.keywordsSet=1)}startDoc(){}endDoc(){return this.hasNil&&this._store.rdfFactory.supports.COLLECTIONS&&Y(this._store,this.source),this._formula}makeStatement(t){t[0].add(t[2],t[1],t[3],this.source),(t[2].uri&&t[2].uri===ht||t[3].uri&&t[3].uri===ht)&&(this.hasNil=!0),this.statementCount+=1}statement(t,e){var r=new K([]);if((e=this.object(t,e,r))<0)return e;var i=this.property_list(t,e,r[0]);if(i<0)throw vt(this._thisDoc,this.lines,t,e,"expected propertylist");return i}subject(t,e,r){return this.item(t,e,r)}verb(t,e,r){if((n=this.skipSpace(t,e))<0)return n;var i=new K([]);if((n=this.tok("has",t,e))>=0){if((e=this.prop(t,n,i))<0)throw vt(this._thisDoc,this.lines,t,n,"expected property after 'has'");return r.push(new J(["->",i[0]])),e}if((n=this.tok("is",t,e))>=0){if((e=this.prop(t,n,i))<0)throw vt(this._thisDoc,this.lines,t,n,"expected <property> after 'is'");if((n=this.skipSpace(t,e))<0)throw vt(this._thisDoc,this.lines,t,e,"End of file found, expected property after 'is'");var n;if(e=n,(n=this.tok("of",t,e))<0)throw vt(this._thisDoc,this.lines,t,e,"expected 'of' after 'is' <prop>");return r.push(new J(["<-",i[0]])),n}if((n=this.tok("a",t,e))>=0)return r.push(new J(["->",this._store.sym("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")])),n;if("<="==t.slice(e,e+2))return r.push(new J(["<-",this._store.sym(Z+"implies")])),e+2;if("="==t.slice(e,e+1))return">"==t.slice(e+1,e+2)?(r.push(new J(["->",this._store.sym(Z+"implies")])),e+2):(r.push(new J(["->",this._store.sym(lt)])),e+1);if(":="==t.slice(e,e+2))return r.push(new J(["->",Z+"becomes"])),e+2;if((n=this.prop(t,e,i))>=0)return r.push(new J(["->",i[0]])),n;if(">-"==t.slice(e,e+2)||"<-"==t.slice(e,e+2))throw vt(this._thisDoc,this.lines,t,n,">- ... -> syntax is obsolete.");return-1}prop(t,e,r){return this.item(t,e,r)}item(t,e,r){return this.path(t,e,r)}blankNode(t){return this._context.bnode(t,this._reason2)}path(t,e,r){if((s=this.nodeOrLiteral(t,e,r))<0)return s;for(;"!^.".indexOf(t.slice(s,s+1))>=0;){var i=t.slice(s,s+1);if("."==i){var n=t.slice(s+1,s+2);if(!n||ct.indexOf(n)>=0&&":?<[{(".indexOf(n)<0)break}var s,a=r.pop(),o=this.blankNode(this.here(s));if((s=this.node(t,s+1,r))<0)throw vt(this._thisDoc,this.lines,t,s,"EOF found in middle of path syntax");var h=r.pop();"^"==i?this.makeStatement(new J([this._context,h,o,a])):this.makeStatement(new J([this._context,h,a,o])),r.push(o)}return s}anonymousNode(t){if(e=this._anonymousNodes[t])return e;var e=this._store.bnode(t);return this._anonymousNodes[t]=e,e}node(t,e,r,i){void 0===i&&(i=null);var n=i;if((u=this.skipSpace(t,e))<0)return u;e=u;var s=t.slice(e,e+1);if("["==s){var a=this.here(e);if((u=this.skipSpace(t,e+1))<0)throw vt(this._thisDoc,this.lines,t,e,"EOF after '['");if("="==t.slice(u,u+1)){e=u+1;var o=new K([]);if(!((u=this.objectList(t,e,o))>=0))throw vt(this._thisDoc,this.lines,t,e,"objectList expected after [= ");if(n=o[0],et(o)>1){var h=new nt(o);try{for(;;){var l=h.next();this.makeStatement(new J([this._context,this._store.sym(lt),n,l]))}}catch(t){if(t!=it)throw t}}if((u=this.skipSpace(t,u))<0)throw vt(this._thisDoc,this.lines,t,e,"EOF when objectList expected after [ = ");if(";"==t.slice(u,u+1))var u=u+1}if(null==n&&(n=this.blankNode(a)),(e=this.property_list(t,u,n))<0)throw vt(this._thisDoc,this.lines,t,u,"property_list expected");if((u=this.skipSpace(t,e))<0)throw vt(this._thisDoc,this.lines,t,e,"EOF when ']' expected after [ <propertyList>");if("."==t.slice(u,u+1))return r.push(n),u;if("]"!=t.slice(u,u+1))throw vt(this._thisDoc,this.lines,t,u,"']' expected");return r.push(n),u+1}if("{"==s){if("$"==t.slice(e+1,e+2)){u=(e+=1)+1;for(var c=new K([]),f=!0;;){if((e=this.skipSpace(t,u))<0)throw vt(this._thisDoc,this.lines,t,e,"needed '$}', found end.");if("$}"==t.slice(e,e+2)){u=e+2;break}if(f)f=!1;else{if(","!=t.slice(e,e+1))throw vt(this._thisDoc,this.lines,t,e,"expected: ','");e+=1}var d=new K([]);if((u=this.item(t,e,d))<0)throw vt(this._thisDoc,this.lines,t,e,"expected item in set or '$}'");c.push(d[0])}return r.push(this._store.newSet(c,this._context)),u}u=e+1;var p=this._parentContext;this._parentContext=this._context;var g=this._anonymousNodes,m=this._parentVariables;this._parentVariables=this._variables,this._anonymousNodes=new tt([]),this._variables=this._variables.slice();var w=this._reason2;for(this._reason2=null,null==n&&(n=this._store.formula()),this._context=n;;){if((e=this.skipSpace(t,u))<0)throw vt(this._thisDoc,this.lines,t,e,"needed '}', found end.");if("}"==t.slice(e,e+1)){u=e+1;break}if((u=this.directiveOrStatement(t,e))<0)throw vt(this._thisDoc,this.lines,t,e,"expected statement or '}'")}return this._anonymousNodes=g,this._variables=this._parentVariables,this._parentVariables=m,this._context=this._parentContext,this._reason2=w,this._parentContext=p,r.push(n.close()),u}if("("==s){var y=this._store.list;for("$"==t.slice(e+1,e+2)&&(y=this._store.newSet,e+=1),u=e+1,c=new K([]);;){if((e=this.skipSpace(t,u))<0)throw vt(this._thisDoc,this.lines,t,e,"needed ')', found end.");if(")"==t.slice(e,e+1)){u=e+1;break}if(d=new K([]),(u=this.item(t,e,d))<0)throw vt(this._thisDoc,this.lines,t,e,"expected item in list or ')'");c.push(d[0])}return r.push(y(c,this._context)),u}if((u=this.tok("this",t,e))>=0)throw vt(this._thisDoc,this.lines,t,e,"Keyword 'this' was ancient N3. Now use @forSome and @forAll keywords.");return(u=this.tok("true",t,e))>=0?(r.push(!0),u):(u=this.tok("false",t,e))>=0?(r.push(!1),u):null==n&&(u=this.uri_ref2(t,e,r))>=0?u:-1}property_list(t,e,r){for(;;){if((u=this.skipSpace(t,e))<0)throw vt(this._thisDoc,this.lines,t,e,"EOF found when expected verb in property list");if(":-"!=t.slice(u,u+2)){e=u;var i=new K([]);if((u=this.verb(t,e,i))<=0)return e;var n=new K([]);if((e=this.objectList(t,u,n))<0)throw vt(this._thisDoc,this.lines,t,u,"objectList expected");var s=new nt(n);try{for(;;){var a=s.next(),o=i[0],h=o[0],l=o[1];"->"==h?this.makeStatement(new J([this._context,l,r,a])):this.makeStatement(new J([this._context,l,a,r]))}}catch(t){if(t!=it)throw t}if((u=this.skipSpace(t,e))<0)throw vt(this._thisDoc,this.lines,t,u,"EOF found in list of objects");if(";"!=t.slice(e,e+1))return e;e+=1}else{e=u+2;var u,c=new K([]);if((u=this.node(t,e,c,r))<0)throw vt(this._thisDoc,this.lines,t,e,"bad {} or () or [] node after :- ");e=u}}}commaSeparatedList(t,e,r,i){if((n=this.skipSpace(t,e))<0)throw vt(this._thisDoc,this.lines,t,n,"EOF found expecting comma sep list");if("."==t.charAt(n))return e;if(i)var n=this.uri_ref2(t,n,r);else n=this.bareWord(t,n,r);if(n<0)return-1;for(;;){if((e=this.skipSpace(t,n))<0)return e;var s=t.slice(e,e+1);if(","!=s)return"."!=s?-1:e;if((n=i?this.uri_ref2(t,e+1,r):this.bareWord(t,e+1,r))<0)throw vt(this._thisDoc,this.lines,t,n,"bad list content")}}objectList(t,e,r){if((e=this.object(t,e,r))<0)return-1;for(;;){var i=this.skipSpace(t,e);if(i<0)throw vt(this._thisDoc,this.lines,t,i,"EOF found after object");if(","!=t.slice(i,i+1))return i;if((e=this.object(t,i+1,r))<0)return e}}checkDot(t,e){var r=this.skipSpace(t,e);if(r<0)return r;if("."==t.slice(r,r+1))return r+1;if("}"==t.slice(r,r+1))return r;if("]"==t.slice(r,r+1))return r;throw vt(this._thisDoc,this.lines,t,r,"expected '.' or '}' or ']' at end of statement")}uri_ref2(t,e,r){var i=new K([]);if((f=this.qname(t,e,i))>=0){var n=i[0],s=n[0],a=n[1];if(null==s){at(0,"not used?");var o=this._baseURI+"#"}else if(!(o=this._bindings[s])){if("_"==s)return r.push(this.anonymousNode(a)),f;throw vt(this._thisDoc,this.lines,t,e,"Prefix "+s+" not bound.")}var h=this._store.sym(o+a);return M(this._variables,h)>=0?r.push(this._variables[h]):r.push(h),f}if((e=this.skipSpace(t,e))<0)return-1;if("?"==t.charAt(e)){var l=new K([]);return(f=this.variable(t,e,l))>0?(r.push(l[0]),f):-1}if("<"==t.charAt(e)){for(var u=e+=1;e<et(t);){if(">"==t.charAt(e)){var c=t.slice(u,e);return this._baseURI?c=ot(this._baseURI,c):at(c.indexOf(":")>=0,"With no base URI, cannot deal with relative URIs"),"#"==t.slice(e-1,e)&&"#"!=rt(c,-1,null)&&(c+="#"),h=this._store.sym(c),M(this._variables,h)>=0?r.push(this._variables[h]):r.push(h),e+1}e+=1}throw vt(this._thisDoc,this.lines,t,f,"unterminated URI reference")}if(this.keywordsSet){var f;if(l=new K([]),(f=this.bareWord(t,e,l))<0)return-1;if(M(this.keywords,l[0])>=0)throw vt(this._thisDoc,this.lines,t,e,'Keyword "'+l[0]+'" not allowed here.');return r.push(this._store.sym(this._bindings[""]+l[0])),f}return-1}skipSpace(t,e){for(var r=e||0;r<t.length;r++){var i=t.charAt(r);if(" \n\r\t\f\v \u2028\u2029 ".indexOf(i)<0){if("#"!==t.charAt(r))return r;for(;;r++){if(r===t.length)return-1;if("\n"===t.charAt(r)){this.lines=this.lines+1;break}}}else"\n"===t.charAt(r)&&(this.lines=this.lines+1)}return-1}variable(t,e,r){if((i=this.skipSpace(t,e))<0)return-1;if("?"!=t.slice(i,i+1))return-1;var i;if(e=i+=1,"0123456789-".indexOf(t.charAt(i))>=0)throw vt(this._thisDoc,this.lines,t,i,"Varible name can't start with '"+t.charAt(i)+"s'");for(;e<et(t)&&ct.indexOf(t.charAt(e))<0;)e+=1;if(null==this._parentContext)throw vt(this._thisDoc,this.lines,t,i,"Can't use ?xxx syntax for variable in outermost level: "+t.slice(i-1,e));return r.push(this._store.variable(t.slice(i,e))),e}bareWord(t,e,r){var i=this.skipSpace(t,e);if(i<0)return-1;var n=t.charAt(i);if("0123456789-".indexOf(n)>=0)return-1;if(ct.indexOf(n)>=0)return-1;for(e=i;e<et(t);){var s=t.charAt(e);if("."===s){if(wt(t,e))break}else if(ct.indexOf(s)>=0)break;e+=1}return r.push(t.slice(i,e)),e}qname(t,e,r){if((e=this.skipSpace(t,e))<0)return-1;var i=t.charAt(e);if("0123456789-+".indexOf(i)>=0)return-1;if(ct.indexOf(i)<0){var n=i;for(e+=1;e<et(t);){if("."===(i=t.charAt(e))){if(wt(t,e))break}else if(ct.indexOf(i)>=0)break;n+=i,e+=1}}else n="";if(e<et(t)&&":"==t.charAt(e)){var s=n;for(e+=1,n="";e<et(t);){if("."===(i=t.charAt(e))){if(wt(t,e))break}else if(ct.indexOf(i)>=0)break;n+=i,e+=1}return r.push(new J([s,n])),e}return n&&this.keywordsSet&&M(this.keywords,n)<0?(r.push(new J(["",n])),e):-1}object(t,e,r){if((s=this.subject(t,e,r))>=0)return s;{if((s=this.skipSpace(t,e))<0)return-1;e=s;var i=null;let o=t.charAt(e);if('"'==o||"'"==o){i=t.slice(e,e+3==o+o)?o+o+o:o,e+=et(i);var n=this.strconst(t,e,i),s=n[0],a=n[1];return r.push(this._store.literal(a)),s}return-1}}nodeOrLiteral(t,e,r){if((h=this.node(t,e,r))>=0)return h;if((h=this.skipSpace(t,e))<0)return-1;e=h;var i=t.charAt(e);if("-+0987654321".indexOf(i)>=0){if(dt.lastIndex=0,null!=(c=dt.exec(t.slice(e))))h=e+(n=c[0]).length,n.indexOf("T")>=0?r.push(this._store.literal(n,this._store.sym("http://www.w3.org/2001/XMLSchema#dateTime"))):r.push(this._store.literal(n,this._store.sym("http://www.w3.org/2001/XMLSchema#date")));else{var n;if(ft.lastIndex=0,null==(c=ft.exec(t.slice(e))))throw vt(this._thisDoc,this.lines,t,e,"Bad number or date syntax");h=e+ft.lastIndex,(n=t.slice(e,h)).indexOf("e")>=0?r.push(this._store.literal(parseFloat(n),this._store.sym("http://www.w3.org/2001/XMLSchema#double"))):t.slice(e,h).indexOf(".")>=0?r.push(this._store.literal(parseFloat(n),this._store.sym("http://www.w3.org/2001/XMLSchema#decimal"))):r.push(this._store.literal(parseInt(n),this._store.sym("http://www.w3.org/2001/XMLSchema#integer")))}return h}if('"'==t.charAt(e)){if('"""'==t.slice(e,e+3))var s='"""';else s='"';e+=et(s);var a=null,o=this.strconst(t,e,s),h=o[0],l=o[1],u=null;if("@"==t.slice(h,h+1)){var c;if(mt.lastIndex=0,null==(c=mt.exec(t.slice(h+1))))throw vt(this._thisDoc,startline,t,e,"Bad language code syntax on string literal, after @");e=mt.lastIndex+h+1,u=t.slice(h+1,e),h=e}if("^^"==t.slice(h,h+2)){var f=new K([]);h=this.uri_ref2(t,h+2,f),a=f[0]}return r.push(this._store.literal(l,u||a)),h}return-1}strconst(t,e,r){for(var i=e,n="",s=this.lines;i<et(t);){if(e=i+et(r),t.slice(i,e)==r)return new J([e,n]);if('"'!=t.charAt(i)){if(gt.lastIndex=0,!gt.exec(t.slice(i)))throw vt(this._thisDoc,s,t,i,"Closing quote missing in string at ^ in "+t.slice(i-20,i)+"^"+t.slice(i,i+20));if(e=i+gt.lastIndex-1,n+=t.slice(i,e),'"'!=(h=t.charAt(e)))if("\r"!=h){if("\n"==h){if('"'==r)throw vt(this._thisDoc,s,t,e,"newline found in string literal");this.lines=this.lines+1,n+=h,i=e+1,this.previousLine=this.startOfLine,this.startOfLine=i}else if("\\"==h){if(i=e+1,!(h=t.slice(i,i+1)))throw vt(this._thisDoc,s,t,e,"unterminated string literal (2)");var a=st('abfrtvn\\"',h);if(a>=0)n+='a\b\f\r\t\v\n\\"'.charAt(a),i+=1;else if("u"==h)i=(o=this.uEscape(t,i+1,s))[0],n+=h=o[1];else{if("U"!=h)throw vt(this._thisDoc,this.lines,t,e,"bad escape");var o,h;i=(o=this.UEscape(t,i+1,s))[0],n+=h=o[1]}}}else i=e+1;else i=e}else n=n+'"',i=i+1}throw vt(this._thisDoc,this.lines,t,e,"unterminated string literal")}uEscape(t,e,r){for(var i=e,n=0,s=0;n<4;){var a=t.slice(i,i+1).toLowerCase();if(i+=1,""==a)throw vt(this._thisDoc,r,t,e,"unterminated string literal(3)");var o=st("0123456789abcdef",a);if(o<0)throw vt(this._thisDoc,r,t,e,"bad string literal hex escape");s=16*s+o,n+=1}var h=String.fromCharCode(s);return new J([i,h])}UEscape(t,e,r){for(var i=e,n=0,s="\\U";n<8;){var a=t.slice(i,i+1).toLowerCase();if(i+=1,""==a)throw vt(this._thisDoc,r,t,e,"unterminated string literal(3)");if(st("0123456789abcdef",a)<0)throw vt(this._thisDoc,r,t,e,"bad string literal hex escape");s+=a,n+=1}var o,h=(o="0x"+rt(s,2,10)-0,String.fromCharCode(o));return new J([i,h])}}function vt(t,e,r,i,n){let s=e+1,a="Line "+s+" of <"+t+">: Bad syntax: "+n+'\nat: "'+r.slice(i,i+30)+'"',o=new SyntaxError(a,t,s);return o.lineNo=s,o.characterInFile=i,o.syntaxProblem=n,o}const _t={...A,supports:{[_.collections]:!0,[_.defaultGraphType]:!1,[_.equalsMethod]:!0,[_.identity]:!1,[_.id]:!0,[_.reversibleId]:!1,[_.variableType]:!0},collection:t=>new f(t),id(t){return(0,a.P3)(t)?`( ${t.elements.map((t=>this.id(t))).join(", ")} )`:(0,a.DZ)(t)?v.toString(t):A.id(t)},termToNQ:t=>t.termType===i.r0?f.toNT(t):A.termToNQ(t)},xt=_t;function Tt(t,e){return"string"==typeof e?t.rdfFactory.literal(e):Object.prototype.hasOwnProperty.call(e,"@list")?!0===t.rdfFactory.supports.COLLECTIONS?function(t,e){if(!Array.isArray(e))throw new TypeError("Object must be an array");return t.rdfFactory.collection(e.map((e=>Tt(t,e))))}(t,e["@list"]):function(t,e){const r=e["@id"]?Nt(t,e):t.rdfFactory.blankNode(),i=e["@list"].map((e=>Tt(t,e))),n=L(t.rdfFactory,r,i);return t.addAll(n),r}(t,e):Object.prototype.hasOwnProperty.call(e,"@id")?Nt(t,e):Object.prototype.hasOwnProperty.call(e,"@language")?t.rdfFactory.literal(e["@value"],e["@language"]):Object.prototype.hasOwnProperty.call(e,"@type")?t.rdfFactory.literal(e["@value"],t.rdfFactory.namedNode(e["@type"])):Object.prototype.hasOwnProperty.call(e,"@value")?t.rdfFactory.literal(e["@value"]):t.rdfFactory.literal(e)}async function At(t,e,r){const i=r&&Object.prototype.hasOwnProperty.call(r,"termType")?r.value:r,n=await o.e(515).then(o.t.bind(o,8515,23));return(await n.default.flatten(JSON.parse(t),null,{base:i})).reduce(((t,e)=>Et(t,r,e)),e)}function Nt(t,e){return e["@id"].startsWith("_:")?t.rdfFactory.blankNode(e["@id"].substring(2)):t.rdfFactory.namedNode(e["@id"])}function Et(t,e,r){const i=r["@id"]?Nt(t,r):t.rdfFactory.blankNode();for(const n of Object.keys(r)){if("@id"===n)continue;if("@graph"==n){const e=i,s=r[n];for(let r=0;r<s.length;r++)t=Et(t,e,s[r])}const s=r[n];if(Array.isArray(s))for(let r=0;r<s.length;r++)t.addStatement(Rt(t,i,n,s[r],e));else t.addStatement(Rt(t,i,n,s,e))}return t}function Rt(t,e,r,i,n){let s,a;return"@type"===r?(s=t.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),a=t.rdfFactory.namedNode(i)):(s=t.rdfFactory.namedNode(r),a=Tt(t,i)),t.rdfFactory.quad(e,s,a,t.rdfFactory.namedNode(n))}var kt=o(2313);const It="http://www.w3.org/1999/02/22-rdf-syntax-ns#",Ct="http://www.w3.org/2001/XMLSchema#",Ot="http://www.w3.org/2000/10/swap/",jt={xsd:{decimal:`${Ct}decimal`,boolean:`${Ct}boolean`,double:`${Ct}double`,integer:`${Ct}integer`,string:`${Ct}string`},rdf:{type:`${It}type`,nil:`${It}nil`,first:`${It}first`,rest:`${It}rest`,langString:`${It}langString`},owl:{sameAs:"http://www.w3.org/2002/07/owl#sameAs"},r:{forSome:`${Ot}reify#forSome`,forAll:`${Ot}reify#forAll`},log:{implies:`${Ot}log#implies`,isImpliedBy:`${Ot}log#isImpliedBy`}},{xsd:St}=jt,Ft=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\([^])/g,Ut={"\\":"\\","'":"'",'"':'"',n:"\n",r:"\r",t:"\t",f:"\f",b:"\b",_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},Dt=/[\x00-\x20<>\\"\{\}\|\^\`]/,Lt={_iri:!0,_unescapedIri:!0,_simpleQuotedString:!0,_langcode:!0,_blank:!0,_newline:!0,_comment:!0,_whitespace:!0,_endOfFile:!0},Mt=/$0^/;class Pt{constructor(t){if(this._iri=/^<((?:[^ <>{}\\]|\\[uU])+)>[ \t]*/,this._unescapedIri=/^<([^\x00-\x20<>\\"\{\}\|\^\`]*)>[ \t]*/,this._simpleQuotedString=/^"([^"\\\r\n]*)"(?=[^"])/,this._simpleApostropheString=/^'([^'\\\r\n]*)'(?=[^'])/,this._langcode=/^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9\-])/i,this._prefix=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:(?=[#\s<])/,this._prefixed=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:((?:(?:[0-:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])(?:(?:[\.\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])*(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~]))?)?)(?:[ \t]+|(?=\.?[,;!\^\s#()\[\]\{\}"'<>]))/,this._variable=/^\?(?:(?:[A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?=[.,;!\^\s#()\[\]\{\}"'<>])/,this._blank=/^_:((?:[0-9A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?:[ \t]+|(?=\.?[,;:\s#()\[\]\{\}"'<>]))/,this._number=/^[\-+]?(?:(\d+\.\d*|\.?\d+)[eE][\-+]?|\d*(\.)?)\d+(?=\.?[,;:\s#()\[\]\{\}"'<>])/,this._boolean=/^(?:true|false)(?=[.,;\s#()\[\]\{\}"'<>])/,this._keyword=/^@[a-z]+(?=[\s#<:])/i,this._sparqlKeyword=/^(?:PREFIX|BASE|GRAPH)(?=[\s#<])/i,this._shortPredicates=/^a(?=[\s#()\[\]\{\}"'<>])/,this._newline=/^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/,this._comment=/#([^\n\r]*)/,this._whitespace=/^[ \t]+/,this._endOfFile=/^(?:#[^\n\r]*)?$/,t=t||{},this._isImpliedBy=t.isImpliedBy,this._lineMode=!!t.lineMode){this._n3Mode=!1;for(const t in this)!(t in Lt)&&this[t]instanceof RegExp&&(this[t]=Mt)}else this._n3Mode=!1!==t.n3;this.comments=!!t.comments,this._literalClosingPos=0}_tokenizeToEnd(t,e){let r=this._input,i=r.length;for(;;){let t,a;for(;t=this._newline.exec(r);)this.comments&&(a=this._comment.exec(t[0]))&&n("comment",a[1],"",this._line,t[0].length),r=r.substr(t[0].length,r.length),i=r.length,this._line++;if(!t&&(t=this._whitespace.exec(r))&&(r=r.substr(t[0].length,r.length)),this._endOfFile.test(r))return e&&(this.comments&&(a=this._comment.exec(r))&&n("comment",a[1],"",this._line,r.length),r=null,n("eof","","",this._line,0)),this._input=r;const o=this._line,h=r[0];let l="",u="",c="",f=null,d=0,p=!1;switch(h){case"^":if(r.length<3)break;if("^"!==r[1]){this._n3Mode&&(d=1,l="^");break}if(this._previousMarker="^^",r=r.substr(2),"<"!==r[0]){p=!0;break}case"<":if(f=this._unescapedIri.exec(r))l="IRI",u=f[1];else if(f=this._iri.exec(r)){if(u=this._unescape(f[1]),null===u||Dt.test(u))return s(this);l="IRI"}else r.length>1&&"<"===r[1]?(l="<<",d=2):this._n3Mode&&r.length>1&&"="===r[1]&&(d=2,this._isImpliedBy?(l="abbreviation",u="<"):(l="inverse",u=">"));break;case">":r.length>1&&">"===r[1]&&(l=">>",d=2);break;case"_":((f=this._blank.exec(r))||e&&(f=this._blank.exec(`${r} `)))&&(l="blank",c="_",u=f[1]);break;case'"':if(f=this._simpleQuotedString.exec(r))u=f[1];else if(({value:u,matchLength:d}=this._parseLiteral(r)),null===u)return s(this);null===f&&0===d||(l="literal",this._literalClosingPos=0);break;case"'":if(!this._lineMode){if(f=this._simpleApostropheString.exec(r))u=f[1];else if(({value:u,matchLength:d}=this._parseLiteral(r)),null===u)return s(this);null===f&&0===d||(l="literal",this._literalClosingPos=0)}break;case"?":this._n3Mode&&(f=this._variable.exec(r))&&(l="var",u=f[0]);break;case"@":"literal"===this._previousMarker&&(f=this._langcode.exec(r))?(l="langcode",u=f[1]):(f=this._keyword.exec(r))&&(l=f[0]);break;case".":if(1===r.length?e:r[1]<"0"||r[1]>"9"){l=".",d=1;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":(f=this._number.exec(r)||e&&(f=this._number.exec(`${r} `)))&&(l="literal",u=f[0],c="string"==typeof f[1]?St.double:"string"==typeof f[2]?St.decimal:St.integer);break;case"B":case"b":case"p":case"P":case"G":case"g":(f=this._sparqlKeyword.exec(r))?l=f[0].toUpperCase():p=!0;break;case"f":case"t":(f=this._boolean.exec(r))?(l="literal",u=f[0],c=St.boolean):p=!0;break;case"a":(f=this._shortPredicates.exec(r))?(l="abbreviation",u="a"):p=!0;break;case"=":this._n3Mode&&r.length>1&&(l="abbreviation",">"!==r[1]?(d=1,u="="):(d=2,u=">"));break;case"!":if(!this._n3Mode)break;case",":case";":case"[":case"]":case"(":case")":case"}":this._lineMode||(d=1,l=h);break;case"{":!this._lineMode&&r.length>=2&&("|"===r[1]?(l="{|",d=2):(l=h,d=1));break;case"|":r.length>=2&&"}"===r[1]&&(l="|}",d=2);break;default:p=!0}if(p&&("@prefix"!==this._previousMarker&&"PREFIX"!==this._previousMarker||!(f=this._prefix.exec(r))?((f=this._prefixed.exec(r))||e&&(f=this._prefixed.exec(`${r} `)))&&(l="prefixed",c=f[1]||"",u=this._unescape(f[2])):(l="prefix",u=f[1]||"")),"^^"===this._previousMarker)switch(l){case"prefixed":l="type";break;case"IRI":l="typeIRI";break;default:l=""}if(!l)return e||!/^'''|^"""/.test(r)&&/\n|\r/.test(r)?s(this):this._input=r;const g=d||f[0].length,m=n(l,u,c,o,g);this.previousToken=m,this._previousMarker=l,r=r.substr(g,r.length)}function n(e,n,s,a,o){const h=r?i-r.length:i,l={type:e,value:n,prefix:s,line:a,start:h,end:h+o};return t(null,l),l}function s(e){t(e._syntaxError(/^\S*/.exec(r)[0]))}}_unescape(t){let e=!1;const r=t.replace(Ft,((t,r,i,n)=>{if("string"==typeof r)return String.fromCharCode(Number.parseInt(r,16));if("string"==typeof i){let t=Number.parseInt(i,16);return t<=65535?String.fromCharCode(Number.parseInt(i,16)):String.fromCharCode(55296+((t-=65536)>>10),56320+(1023&t))}return n in Ut?Ut[n]:(e=!0,"")}));return e?null:r}_parseLiteral(t){if(t.length>=3){const e=t.match(/^(?:"""|"|'''|'|)/)[0],r=e.length;let i=Math.max(this._literalClosingPos,r);for(;(i=t.indexOf(e,i))>0;){let e=0;for(;"\\"===t[i-e-1];)e++;if(e%2==0){const e=t.substring(r,i),n=e.split(/\r\n|\r|\n/).length-1,s=i+r;if(1===r&&0!==n||3===r&&this._lineMode)break;return this._line+=n,{value:this._unescape(e),matchLength:s}}i++}this._literalClosingPos=t.length-r+1}return{value:"",matchLength:0}}_syntaxError(t){this._input=null;const e=new Error(`Unexpected "${t}" on line ${this._line}.`);return e.context={token:void 0,line:this._line,previousToken:this.previousToken},e}_readStartingBom(t){return t.startsWith("\ufeff")?t.substr(1):t}tokenize(t,e){if(this._line=1,"string"==typeof t){if(this._input=this._readStartingBom(t),"function"!=typeof e){const t=[];let e;if(this._tokenizeToEnd(((r,i)=>r?e=r:t.push(i)),!0),e)throw e;return t}queueMicrotask((()=>this._tokenizeToEnd(e,!0)))}else this._pendingBuffer=null,"function"==typeof t.setEncoding&&t.setEncoding("utf8"),t.on("data",(t=>{null!==this._input&&0!==t.length&&(this._pendingBuffer&&(t=kt.hp.concat([this._pendingBuffer,t]),this._pendingBuffer=null),128&t[t.length-1]?this._pendingBuffer=t:(void 0===this._input?this._input=this._readStartingBom("string"==typeof t?t:t.toString()):this._input+=t,this._tokenizeToEnd(e,!1)))})),t.on("end",(()=>{"string"==typeof this._input&&this._tokenizeToEnd(e,!0)})),t.on("error",e)}}const{rdf:Bt,xsd:qt}=jt;let $t,Ht=0;const Xt={namedNode:Zt,blankNode:Jt,variable:te,literal:Kt,defaultGraph:function(){return $t},quad:ee,triple:ee,fromTerm:re,fromQuad:ie};class zt{constructor(t){this.id=t}get value(){return this.id}equals(t){return t instanceof zt?this.id===t.id:!!t&&this.termType===t.termType&&this.value===t.value}hashCode(){return 0}toJSON(){return{termType:this.termType,value:this.value}}}class Qt extends zt{get termType(){return"NamedNode"}}class Vt extends zt{get termType(){return"Literal"}get value(){return this.id.substring(1,this.id.lastIndexOf('"'))}get language(){const t=this.id;let e=t.lastIndexOf('"')+1;return e<t.length&&"@"===t[e++]?t.substr(e).toLowerCase():""}get datatype(){return new Qt(this.datatypeString)}get datatypeString(){const t=this.id,e=t.lastIndexOf('"')+1,r=e<t.length?t[e]:"";return"^"===r?t.substr(e+2):"@"!==r?qt.string:Bt.langString}equals(t){return t instanceof Vt?this.id===t.id:!!t&&!!t.datatype&&this.termType===t.termType&&this.value===t.value&&this.language===t.language&&this.datatype.value===t.datatype.value}toJSON(){return{termType:this.termType,value:this.value,language:this.language,datatype:{termType:"NamedNode",value:this.datatypeString}}}}class Gt extends zt{constructor(t){super(`_:${t}`)}get termType(){return"BlankNode"}get value(){return this.id.substr(2)}}class Wt extends zt{constructor(t){super(`?${t}`)}get termType(){return"Variable"}get value(){return this.id.substr(1)}}$t=new class extends zt{constructor(){return super(""),$t||this}get termType(){return"DefaultGraph"}equals(t){return this===t||!!t&&this.termType===t.termType}};class Yt extends zt{constructor(t,e,r,i){super(""),this._subject=t,this._predicate=e,this._object=r,this._graph=i||$t}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(t){return!!t&&this._subject.equals(t.subject)&&this._predicate.equals(t.predicate)&&this._object.equals(t.object)&&this._graph.equals(t.graph)}}function Zt(t){return new Qt(t)}function Jt(t){return new Gt(t||"n3-"+Ht++)}function Kt(t,e){if("string"==typeof e)return new Vt(`"${t}"@${e.toLowerCase()}`);let r=e?e.value:"";return""===r&&("boolean"==typeof t?r=qt.boolean:"number"==typeof t&&(Number.isFinite(t)?r=Number.isInteger(t)?qt.integer:qt.double:(r=qt.double,Number.isNaN(t)||(t=t>0?"INF":"-INF")))),""===r||r===qt.string?new Vt(`"${t}"`):new Vt(`"${t}"^^${r}`)}function te(t){return new Wt(t)}function ee(t,e,r,i){return new Yt(t,e,r,i)}function re(t){if(t instanceof zt)return t;switch(t.termType){case"NamedNode":return Zt(t.value);case"BlankNode":return Jt(t.value);case"Variable":return te(t.value);case"DefaultGraph":return $t;case"Literal":return Kt(t.value,t.language||t.datatype);case"Quad":return ie(t);default:throw new Error(`Unexpected termType: ${t.termType}`)}}function ie(t){if(t instanceof Yt)return t;if("Quad"!==t.termType)throw new Error(`Unexpected termType: ${t.termType}`);return ee(re(t.subject),re(t.predicate),re(t.object),re(t.graph))}let ne=0;class se{constructor(t){this._contextStack=[],this._graph=null,t=t||{},this._setBase(t.baseIRI),t.factory&&oe(this,t.factory);const e="string"==typeof t.format?t.format.match(/\w*$/)[0].toLowerCase():"",r=/turtle/.test(e),i=/trig/.test(e),n=/triple/.test(e),s=/quad/.test(e),a=this._n3Mode=/n3/.test(e),o=n||s;(this._supportsNamedGraphs=!(r||a))||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(r||i||n||a),this._isImpliedBy=t.isImpliedBy,this._supportsRDFStar=""===e||/star|\*$/.test(e),o&&(this._resolveRelativeIRI=t=>null),this._blankNodePrefix="string"!=typeof t.blankNodePrefix?"":t.blankNodePrefix.replace(/^(?!_:)/,"_:"),this._lexer=t.lexer||new Pt({lineMode:o,n3:a,isImpliedBy:this._isImpliedBy}),this._explicitQuantifiers=!!t.explicitQuantifiers}static _resetBlankNodePrefix(){ne=0}_setBase(t){if(t){const e=t.indexOf("#");e>=0&&(t=t.substr(0,e)),this._base=t,this._basePath=t.indexOf("/")<0?t:t.replace(/[^\/?]*(?:\?.*)?$/,""),t=t.match(/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i),this._baseRoot=t[0],this._baseScheme=t[1]}else this._base="",this._basePath=""}_saveContext(t,e,r,i,n){const s=this._n3Mode;this._contextStack.push({type:t,subject:r,predicate:i,object:n,graph:e,inverse:!!s&&this._inversePredicate,blankPrefix:s?this._prefixes._:"",quantified:s?this._quantified:null}),s&&(this._inversePredicate=!1,this._prefixes._=this._graph?`${this._graph.value}.`:".",this._quantified=Object.create(this._quantified))}_restoreContext(t,e){const r=this._contextStack.pop();if(!r||r.type!==t)return this._error(`Unexpected ${e.type}`,e);this._subject=r.subject,this._predicate=r.predicate,this._object=r.object,this._graph=r.graph,this._n3Mode&&(this._inversePredicate=r.inverse,this._prefixes._=r.blankPrefix,this._quantified=r.quantified)}_readInTopContext(t){switch(t.type){case"eof":return null!==this._graph?this._error("Unclosed graph",t):(delete this._prefixes._,this._callback(null,null,this._prefixes));case"PREFIX":this._sparqlStyle=!0;case"@prefix":return this._readPrefix;case"BASE":this._sparqlStyle=!0;case"@base":return this._readBaseIRI;case"{":if(this._supportsNamedGraphs)return this._graph="",this._subject=null,this._readSubject;case"GRAPH":if(this._supportsNamedGraphs)return this._readNamedGraphLabel;default:return this._readSubject(t)}}_readEntity(t,e){let r;switch(t.type){case"IRI":case"typeIRI":const e=this._resolveIRI(t.value);if(null===e)return this._error("Invalid IRI",t);r=this._factory.namedNode(e);break;case"type":case"prefixed":const i=this._prefixes[t.prefix];if(void 0===i)return this._error(`Undefined prefix "${t.prefix}:"`,t);r=this._factory.namedNode(i+t.value);break;case"blank":r=this._factory.blankNode(this._prefixes[t.prefix]+t.value);break;case"var":r=this._factory.variable(t.value.substr(1));break;default:return this._error(`Expected entity but got ${t.type}`,t)}return!e&&this._n3Mode&&r.id in this._quantified&&(r=this._quantified[r.id]),r}_readSubject(t){switch(this._predicate=null,t.type){case"[":return this._saveContext("blank",this._graph,this._subject=this._factory.blankNode(),null,null),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this.RDF_NIL,null,null),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._graph=this._factory.blankNode(),null,null),this._readSubject):this._error("Unexpected graph",t);case"}":return this._readPunctuation(t);case"@forSome":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORSOME,this._quantifier="blankNode",this._readQuantifierList):this._error('Unexpected "@forSome"',t);case"@forAll":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORALL,this._quantifier="variable",this._readQuantifierList):this._error('Unexpected "@forAll"',t);case"literal":if(!this._n3Mode)return this._error("Unexpected literal",t);if(0===t.prefix.length)return this._literalValue=t.value,this._completeSubjectLiteral;this._subject=this._factory.literal(t.value,this._factory.namedNode(t.prefix));break;case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,null,null,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",t);default:if(void 0===(this._subject=this._readEntity(t)))return;if(this._n3Mode)return this._getPathReader(this._readPredicateOrNamedGraph)}return this._readPredicateOrNamedGraph}_readPredicate(t){const e=t.type;switch(e){case"inverse":this._inversePredicate=!0;case"abbreviation":this._predicate=this.ABBREVIATIONS[t.value];break;case".":case"]":case"}":return null===this._predicate?this._error(`Unexpected ${e}`,t):(this._subject=null,"]"===e?this._readBlankNodeTail(t):this._readPunctuation(t));case";":return null!==this._predicate?this._readPredicate:this._error("Expected predicate but got ;",t);case"[":if(this._n3Mode)return this._saveContext("blank",this._graph,this._subject,this._subject=this._factory.blankNode(),null),this._readBlankNodeHead;case"blank":if(!this._n3Mode)return this._error("Disallowed blank node as predicate",t);default:if(void 0===(this._predicate=this._readEntity(t)))return}return this._readObject}_readObject(t){switch(t.type){case"literal":if(0===t.prefix.length)return this._literalValue=t.value,this._readDataTypeOrLang;this._object=this._factory.literal(t.value,this._factory.namedNode(t.prefix));break;case"[":return this._saveContext("blank",this._graph,this._subject,this._predicate,this._subject=this._factory.blankNode()),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this._subject,this._predicate,this.RDF_NIL),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",t);case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,this._subject,this._predicate,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",t);default:if(void 0===(this._object=this._readEntity(t)))return;if(this._n3Mode)return this._getPathReader(this._getContextEndReader())}return this._getContextEndReader()}_readPredicateOrNamedGraph(t){return"{"===t.type?this._readGraph(t):this._readPredicate(t)}_readGraph(t){return"{"!==t.type?this._error(`Expected graph but got ${t.type}`,t):(this._graph=this._subject,this._subject=null,this._readSubject)}_readBlankNodeHead(t){return"]"===t.type?(this._subject=null,this._readBlankNodeTail(t)):(this._predicate=null,this._readPredicate(t))}_readBlankNodeTail(t){if("]"!==t.type)return this._readBlankNodePunctuation(t);null!==this._subject&&this._emit(this._subject,this._predicate,this._object,this._graph);const e=null===this._predicate;return this._restoreContext("blank",t),null!==this._object?this._getContextEndReader():null!==this._predicate?this._readObject:e?this._readPredicateOrNamedGraph:this._readPredicateAfterBlank}_readPredicateAfterBlank(t){switch(t.type){case".":case"}":return this._subject=null,this._readPunctuation(t);default:return this._readPredicate(t)}}_readListItem(t){let e=null,r=null,i=this._readListItem;const n=this._subject,s=this._contextStack,a=s[s.length-1];switch(t.type){case"[":this._saveContext("blank",this._graph,r=this._factory.blankNode(),this.RDF_FIRST,this._subject=e=this._factory.blankNode()),i=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",t),0!==s.length&&"list"===s[s.length-1].type&&this._emit(this._subject,this._predicate,this._object,this._graph),null===this._predicate){if(i=this._readPredicate,this._subject===this.RDF_NIL)return i}else if(i=this._getContextEndReader(),this._object===this.RDF_NIL)return i;r=this.RDF_NIL;break;case"literal":0===t.prefix.length?(this._literalValue=t.value,i=this._readListItemDataTypeOrLang):(e=this._factory.literal(t.value,this._factory.namedNode(t.prefix)),i=this._getContextEndReader());break;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",t);default:if(void 0===(e=this._readEntity(t)))return}if(null===r&&(this._subject=r=this._factory.blankNode()),null===n?null===a.predicate?a.subject=r:a.object=r:this._emit(n,this.RDF_REST,r,this._graph),null!==e){if(this._n3Mode&&("IRI"===t.type||"prefixed"===t.type))return this._saveContext("item",this._graph,r,this.RDF_FIRST,e),this._subject=e,this._predicate=null,this._getPathReader(this._readListItem);this._emit(r,this.RDF_FIRST,e,this._graph)}return i}_readDataTypeOrLang(t){return this._completeObjectLiteral(t,!1)}_readListItemDataTypeOrLang(t){return this._completeObjectLiteral(t,!0)}_completeLiteral(t){let e=this._factory.literal(this._literalValue);switch(t.type){case"type":case"typeIRI":const r=this._readEntity(t);if(void 0===r)return;e=this._factory.literal(this._literalValue,r),t=null;break;case"langcode":e=this._factory.literal(this._literalValue,t.value),t=null}return{token:t,literal:e}}_completeSubjectLiteral(t){return this._subject=this._completeLiteral(t).literal,this._readPredicateOrNamedGraph}_completeObjectLiteral(t,e){const r=this._completeLiteral(t);if(r)return this._object=r.literal,e&&this._emit(this._subject,this.RDF_FIRST,this._object,this._graph),null===r.token?this._getContextEndReader():(this._readCallback=this._getContextEndReader(),this._readCallback(r.token))}_readFormulaTail(t){return"}"!==t.type?this._readPunctuation(t):(null!==this._subject&&this._emit(this._subject,this._predicate,this._object,this._graph),this._restoreContext("formula",t),null===this._object?this._readPredicate:this._getContextEndReader())}_readPunctuation(t){let e,r=this._graph;const i=this._subject,n=this._inversePredicate;switch(t.type){case"}":if(null===this._graph)return this._error("Unexpected graph closing",t);if(this._n3Mode)return this._readFormulaTail(t);this._graph=null;case".":this._subject=null,e=this._contextStack.length?this._readSubject:this._readInTopContext,n&&(this._inversePredicate=!1);break;case";":e=this._readPredicate;break;case",":e=this._readObject;break;case"{|":if(!this._supportsRDFStar)return this._error("Unexpected RDF-star syntax",t);const s=this._predicate,a=this._object;this._subject=this._factory.quad(i,s,a,this.DEFAULTGRAPH),e=this._readPredicate;break;case"|}":if("Quad"!==this._subject.termType)return this._error("Unexpected asserted triple closing",t);this._subject=null,e=this._readPunctuation;break;default:if(this._supportsQuads&&null===this._graph&&void 0!==(r=this._readEntity(t))){e=this._readQuadPunctuation;break}return this._error(`Expected punctuation to follow "${this._object.id}"`,t)}if(null!==i){const t=this._predicate,e=this._object;n?this._emit(e,t,i,r):this._emit(i,t,e,r)}return e}_readBlankNodePunctuation(t){let e;switch(t.type){case";":e=this._readPredicate;break;case",":e=this._readObject;break;default:return this._error(`Expected punctuation to follow "${this._object.id}"`,t)}return this._emit(this._subject,this._predicate,this._object,this._graph),e}_readQuadPunctuation(t){return"."!==t.type?this._error("Expected dot to follow quad",t):this._readInTopContext}_readPrefix(t){return"prefix"!==t.type?this._error("Expected prefix to follow @prefix",t):(this._prefix=t.value,this._readPrefixIRI)}_readPrefixIRI(t){if("IRI"!==t.type)return this._error(`Expected IRI to follow prefix "${this._prefix}:"`,t);const e=this._readEntity(t);return this._prefixes[this._prefix]=e.value,this._prefixCallback(this._prefix,e),this._readDeclarationPunctuation}_readBaseIRI(t){const e="IRI"===t.type&&this._resolveIRI(t.value);return e?(this._setBase(e),this._readDeclarationPunctuation):this._error("Expected valid IRI to follow base declaration",t)}_readNamedGraphLabel(t){switch(t.type){case"IRI":case"blank":case"prefixed":return this._readSubject(t),this._readGraph;case"[":return this._readNamedGraphBlankLabel;default:return this._error("Invalid graph label",t)}}_readNamedGraphBlankLabel(t){return"]"!==t.type?this._error("Invalid graph label",t):(this._subject=this._factory.blankNode(),this._readGraph)}_readDeclarationPunctuation(t){return this._sparqlStyle?(this._sparqlStyle=!1,this._readInTopContext(t)):"."!==t.type?this._error("Expected declaration to end with a dot",t):this._readInTopContext}_readQuantifierList(t){let e;switch(t.type){case"IRI":case"prefixed":if(void 0!==(e=this._readEntity(t,!0)))break;default:return this._error(`Unexpected ${t.type}`,t)}return this._explicitQuantifiers?(null===this._subject?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,e,this.QUANTIFIERS_GRAPH)):this._quantified[e.id]=this._factory[this._quantifier](this._factory.blankNode().value),this._readQuantifierPunctuation}_readQuantifierPunctuation(t){return","===t.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(t))}_getPathReader(t){return this._afterPath=t,this._readPath}_readPath(t){switch(t.type){case"!":return this._readForwardPath;case"^":return this._readBackwardPath;default:const e=this._contextStack,r=e.length&&e[e.length-1];if(r&&"item"===r.type){const e=this._subject;this._restoreContext("item",t),this._emit(this._subject,this.RDF_FIRST,e,this._graph)}return this._afterPath(t)}}_readForwardPath(t){let e,r;const i=this._factory.blankNode();if(void 0!==(r=this._readEntity(t)))return null===this._predicate?(e=this._subject,this._subject=i):(e=this._object,this._object=i),this._emit(e,r,i,this._graph),this._readPath}_readBackwardPath(t){const e=this._factory.blankNode();let r,i;if(void 0!==(r=this._readEntity(t)))return null===this._predicate?(i=this._subject,this._subject=e):(i=this._object,this._object=e),this._emit(e,r,i,this._graph),this._readPath}_readRDFStarTailOrGraph(t){return">>"!==t.type?this._supportsQuads&&null===this._graph&&void 0!==(this._graph=this._readEntity(t))?this._readRDFStarTail:this._error(`Expected >> to follow "${this._object.id}"`,t):this._readRDFStarTail(t)}_readRDFStarTail(t){if(">>"!==t.type)return this._error(`Expected >> but got ${t.type}`,t);const e=this._factory.quad(this._subject,this._predicate,this._object,this._graph||this.DEFAULTGRAPH);return this._restoreContext("<<",t),null===this._subject?(this._subject=e,this._readPredicate):(this._object=e,this._getContextEndReader())}_getContextEndReader(){const t=this._contextStack;if(!t.length)return this._readPunctuation;switch(t[t.length-1].type){case"blank":return this._readBlankNodeTail;case"list":return this._readListItem;case"formula":return this._readFormulaTail;case"<<":return this._readRDFStarTailOrGraph}}_emit(t,e,r,i){this._callback(null,this._factory.quad(t,e,r,i||this.DEFAULTGRAPH))}_error(t,e){const r=new Error(`${t} on line ${e.line}.`);r.context={token:e,line:e.line,previousToken:this._lexer.previousToken},this._callback(r),this._callback=ae}_resolveIRI(t){return/^[a-z][a-z0-9+.-]*:/i.test(t)?t:this._resolveRelativeIRI(t)}_resolveRelativeIRI(t){if(!t.length)return this._base;switch(t[0]){case"#":return this._base+t;case"?":return this._base.replace(/(?:\?.*)?$/,t);case"/":return("/"===t[1]?this._baseScheme:this._baseRoot)+this._removeDotSegments(t);default:return/^[^/:]*:/.test(t)?null:this._removeDotSegments(this._basePath+t)}}_removeDotSegments(t){if(!/(^|\/)\.\.?($|[/#?])/.test(t))return t;const e=t.length;let r="",i=-1,n=-1,s=0,a="/";for(;i<e;){switch(a){case":":if(n<0&&"/"===t[++i]&&"/"===t[++i])for(;(n=i+1)<e&&"/"!==t[n];)i=n;break;case"?":case"#":i=e;break;case"/":if("."===t[i+1])switch(a=t[1+ ++i],a){case"/":r+=t.substring(s,i-1),s=i+1;break;case void 0:case"?":case"#":return r+t.substring(s,i)+t.substr(i+1);case".":if(a=t[1+ ++i],void 0===a||"/"===a||"?"===a||"#"===a){if(r+=t.substring(s,i-2),(s=r.lastIndexOf("/"))>=n&&(r=r.substr(0,s)),"/"!==a)return`${r}/${t.substr(i+1)}`;s=i+1}}}a=t[++i]}return r+t.substring(s)}parse(t,e,r){let i,n,s;if(e&&(e.onQuad||e.onPrefix||e.onComment)?(i=e.onQuad,n=e.onPrefix,s=e.onComment):(i=e,n=r),this._readCallback=this._readInTopContext,this._sparqlStyle=!1,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix?this._blankNodePrefix.substr(2):`b${ne++}_`,this._prefixCallback=n||ae,this._inversePredicate=!1,this._quantified=Object.create(null),!i){const e=[];let r;if(this._callback=(t,i)=>{t?r=t:i&&e.push(i)},this._lexer.tokenize(t).every((t=>this._readCallback=this._readCallback(t))),r)throw r;return e}let a=(t,e)=>{null!==t?(this._callback(t),this._callback=ae):this._readCallback&&(this._readCallback=this._readCallback(e))};s&&(this._lexer.comments=!0,a=(t,e)=>{null!==t?(this._callback(t),this._callback=ae):this._readCallback&&("comment"===e.type?s(e.value):this._readCallback=this._readCallback(e))}),this._callback=i,this._lexer.tokenize(t,a)}}function ae(){}function oe(t,e){t._factory=e,t.DEFAULTGRAPH=e.defaultGraph(),t.RDF_FIRST=e.namedNode(jt.rdf.first),t.RDF_REST=e.namedNode(jt.rdf.rest),t.RDF_NIL=e.namedNode(jt.rdf.nil),t.N3_FORALL=e.namedNode(jt.r.forAll),t.N3_FORSOME=e.namedNode(jt.r.forSome),t.ABBREVIATIONS={a:e.namedNode(jt.rdf.type),"=":e.namedNode(jt.owl.sameAs),">":e.namedNode(jt.log.implies),"<":e.namedNode(jt.log.isImpliedBy)},t.QUANTIFIERS_GRAPH=e.namedNode("urn:n3:quantifiers")}if(oe(se.prototype,Xt),void 0===he)var he={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12};class le{constructor(t,e){this.options=e||{},this.kb=t,this.target=e.target||{graph:{subjects:{},prefixes:{},terms:{}}},this.blankNodes=[],this.htmlOptions={selfClosing:"br img input area base basefont col colgroup source wbr isindex link meta param hr"},this.theOne="_:"+(new Date).getTime(),this.language=null,this.vocabulary=null,this.blankCounter=0,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"}],this.inXHTMLMode=!1,this.absURIRE=/[\w\_\-]+:\S+/,this.finishedHandlers=[],this.init()}addTriple(t,e,r,i){var n,s,a,o;n=void 0===e?A.namedNode(this.options.base):this.toRDFNodeObject(e),a=this.toRDFNodeObject(r),s=this.toRDFNodeObject(i),o=A.namedNode(this.options.base),this.kb.add(n,a,s,o)}ancestorPath(t){for(var e="";t&&t.nodeType!==he.DOCUMENT_NODE;)e="/"+t.localName+e,t=t.parentNode;return e}copyMappings(t){var e={};for(var r in t)e[r]=t[r];return e}copyProperties(){}deriveDateTimeType(t){for(var e=0;e<le.dateTimeTypes.length;e++){var r=le.dateTimeTypes[e].pattern.exec(t);if(r&&r[0].length===t.length)return le.dateTimeTypes[e].type}return null}init(){}newBlankNode(){return this.blankCounter++,"_:"+this.blankCounter}newSubjectOrigin(t,e){}parseCURIE(t,e,r){var i,n=t.indexOf(":");if(n>=0){var s=t.substring(0,n);if(""===s)return(i=e[""])?i+t.substring(n+1):null;if("_"===s)return"_:"+t.substring(n+1);if(le.NCNAME.test(s)&&(i=e[s]))return i+t.substring(n+1)}return null}parseCURIEOrURI(t,e,r){return this.parseCURIE(t,e,r)||this.resolveAndNormalize(r,t)}parsePredicate(t,e,r,i,n,s){if(""===t)return null;var a=this.parseTermOrCURIEOrAbsURI(t,e,s?null:r,i,n);return a&&0===a.indexOf("_:")?null:a}parsePrefixMappings(t,e){for(var r=this.tokenize(t),i=null,n=0;n<r.length;n++)":"===r[n][r[n].length-1]?i=r[n].substring(0,r[n].length-1):i&&(e[i]=this.options.base?b.join(r[n],this.options.base):r[n],i=null)}static parseRDFaDOM(t,e,r){var i=new le(e,{base:r});t.baseURI||(t.baseURI=r),i.process(t,{baseURI:r})}parseSafeCURIEOrCURIEOrURI(t,e,r){return"["===(t=this.trim(t)).charAt(0)&&"]"===t.charAt(t.length-1)?0===(t=(t=t.substring(1,t.length-1)).trim(t)).length?null:"_:"===t?this.theOne:this.parseCURIE(t,e,r):this.parseCURIEOrURI(t,e,r)}parseTermOrCURIEOrAbsURI(t,e,r,i,n){t=this.trim(t);var s=this.parseCURIE(t,i,n);if(s)return s;if(r){if(e&&!this.absURIRE.exec(t))return e+t;var a=r[t];if(a)return a;if(a=r[t.toLowerCase()])return a}return this.absURIRE.exec(t)?this.resolveAndNormalize(n,t):null}parseTermOrCURIEOrURI(t,e,r,i,n){t=this.trim(t);var s=this.parseCURIE(t,i,n);if(s)return s;var a=r[t];return a||((a=r[t.toLowerCase()])?a:e&&!this.absURIRE.exec(t)?e+t:this.resolveAndNormalize(n,t))}parseURI(t){return t}process(t,e){var r;e=e||{},t.nodeType===he.DOCUMENT_NODE?(t.baseURI&&!e.baseURI&&(e.baseURI=t.baseURI),r=t.baseURI,(t=t.documentElement).baseURI||(t.baseURI=r),this.setContext(t)):t.parentNode.nodeType===he.DOCUMENT_NODE&&this.setContext(t);var i=[],n=function(t){if(!t&&e&&e.baseURI)return e.baseURI;var r=t.indexOf("#");return r>=0&&(t=t.substring(0,r)),e&&e.baseURIMap&&(t=e.baseURIMap(t)),t};for(i.push({current:t,context:this.push(null,n(t.baseURI))});i.length>0;){var s=i.shift();if(s.parent){if(s.context.parent&&s.context.parent.listMapping===s.listMapping)continue;for(let t in s.listMapping){var a=s.listMapping[t];if(0!==a.length){var o=[];for(let t=0;t<a.length;t++)o.push(this.newBlankNode());for(let t=0;t<o.length;t++)this.addTriple(s.parent,o[t],"http://www.w3.org/1999/02/22-rdf-syntax-ns#first",a[t]),this.addTriple(s.parent,o[t],"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",{type:le.objectURI,value:t+1<o.length?o[t+1]:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"});this.addTriple(s.parent,s.subject,t,{type:le.objectURI,value:o[0]})}else this.addTriple(s.parent,s.subject,t,{type:le.objectURI,value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"})}}else{var h=s.current,l=s.context,u=!1,c=null,f=null,d=null,p=l.prefixes,g=!1,m=[],w=l.listMapping,y=!l.parent,v=l.language,_=l.vocabulary;r=this.parseURI(n(h.baseURI)),h.item=null;var x=h.getAttributeNode("vocab");if(x){let t=this.trim(x.value);if(t.length>0){_=t;var T=r.spec;this.addTriple(h,T,"http://www.w3.org/ns/rdfa#usesVocabulary",{type:le.objectURI,value:_})}else _=this.vocabulary}for(var A=0;A<h.attributes.length;A++){var N=h.attributes[A];if("x"===N.nodeName.charAt(0)&&0===N.nodeName.indexOf("xmlns:")){g||(p=this.copyMappings(p),g=!0);var E=N.nodeName.substring(6),R=le.trim(N.value);p[E]=this.options.base?b.join(R,this.options.base):R}}var k=h.getAttributeNode("prefix");k&&(g||(p=this.copyMappings(p),g=!0),this.parsePrefixMappings(k.value,p));var I=null;for(let t=0;!I&&t<this.langAttributes.length;t++)I=h.getAttributeNodeNS(this.langAttributes[t].namespaceURI,this.langAttributes[t].localName);if(I){let t=le.trim(I.value);v=t.length>0?t:null}var C,O,j=h.getAttributeNode("rel"),S=h.getAttributeNode("rev"),F=h.getAttributeNode("typeof"),U=h.getAttributeNode("property"),D=h.getAttributeNode("datatype"),L=this.inHTMLMode?h.getAttributeNode("datetime"):null,M=h.getAttributeNode("content"),P=h.getAttributeNode("about"),B=h.getAttributeNode("src"),q=h.getAttributeNode("resource"),$=h.getAttributeNode("href"),H=h.getAttributeNode("inlist"),X=[];if(j){O=this.tokenize(j.value);for(let t=0;t<O.length;t++)(C=this.parsePredicate(O[t],_,l.terms,p,r,this.inHTMLMode&&null!==U))&&X.push(C)}var z=[];if(S){O=this.tokenize(S.value);for(let t=0;t<O.length;t++)(C=this.parsePredicate(O[t],_,l.terms,p,r,this.inHTMLMode&&U))&&z.push(C)}if(this.inHTMLMode&&(j||S)&&U&&(0===X.length&&(j=null),0===z.length&&(S=null)),j||S?(P&&(c=this.parseSafeCURIEOrCURIEOrURI(P.value,p,r)),F&&(d=c),c||(h.parentNode.nodeType===he.DOCUMENT_NODE?c=n(h.baseURI):l.parentObject&&(c=n(h.parentNode.baseURI)===l.parentObject?n(h.baseURI):l.parentObject)),q&&(f=this.parseSafeCURIEOrCURIEOrURI(q.value,p,r)),f||($?f=this.resolveAndNormalize(r,encodeURI($.value)):B?f=this.resolveAndNormalize(r,encodeURI(B.value)):!F||P||this.inXHTMLMode&&("head"===h.localName||"body"===h.localName)||(f=this.newBlankNode())),!F||P||!this.inXHTMLMode||"head"!==h.localName&&"body"!==h.localName?F&&!P&&(d=f):d=c):!U||M||D?(P&&(c=this.parseSafeCURIEOrCURIEOrURI(P.value,p,r)),!c&&q&&(c=this.parseSafeCURIEOrCURIEOrURI(q.value,p,r)),!c&&$&&(c=this.resolveAndNormalize(r,encodeURI($.value))),!c&&B&&(c=this.resolveAndNormalize(r,encodeURI(B.value))),c||(h.parentNode.nodeType===he.DOCUMENT_NODE?c=n(h.baseURI):!this.inXHTMLMode&&!this.inHTMLMode||"head"!==h.localName&&"body"!==h.localName?F?c=this.newBlankNode():l.parentObject&&(c=n(h.parentNode.baseURI)===l.parentObject?n(h.baseURI):l.parentObject,U||(u=!0)):c=n(h.parentNode.baseURI)===l.parentObject?n(h.baseURI):l.parentObject),F&&(d=c)):(P&&(c=this.parseSafeCURIEOrCURIEOrURI(P.value,p,r),F&&(d=c)),c||h.parentNode.nodeType!==he.DOCUMENT_NODE?!c&&l.parentObject&&(c=n(h.parentNode.baseURI)===l.parentObject?n(h.baseURI):l.parentObject):(c=n(h.baseURI),F&&(d=c)),F&&!d&&(q&&(d=this.parseSafeCURIEOrCURIEOrURI(q.value,p,r)),!d&&$&&(d=this.resolveAndNormalize(r,encodeURI($.value))),!d&&B&&(d=this.resolveAndNormalize(r,encodeURI(B.value))),d||!this.inXHTMLMode&&!this.inHTMLMode||"head"!==h.localName&&"body"!==h.localName||(d=c),d||(d=this.newBlankNode()),f=d)),c&&(P||q||d)){var Q=c;F&&!P&&!q&&f&&(Q=f),this.newSubjectOrigin(h,Q)}if(d){O=this.tokenize(F.value);for(let t=0;t<O.length;t++){var V=this.parseTermOrCURIEOrAbsURI(O[t],_,l.terms,p,r);V&&this.addTriple(h,d,le.typeURI,{type:le.objectURI,value:V})}}if(c&&c!==l.parentObject&&(w={},y=!0),f){if(j&&H)for(let t=0;t<X.length;t++){let e=w[X[t]];e||(e=[],w[X[t]]=e),e.push({type:le.objectURI,value:f})}else if(j)for(let t=0;t<X.length;t++)this.addTriple(h,c,X[t],{type:le.objectURI,value:f});if(S)for(let t=0;t<z.length;t++)this.addTriple(h,f,z[t],{type:le.objectURI,value:c})}else{if(c&&!f&&(j||S)&&(f=this.newBlankNode()),j&&H)for(let t=0;t<X.length;t++){let e=w[X[t]];e||(e=[],w[C]=e),m.push({predicate:X[t],list:e})}else if(j)for(let t=0;t<X.length;t++)m.push({predicate:X[t],forward:!0});if(S)for(let t=0;t<z.length;t++)m.push({predicate:z[t],forward:!1})}if(U){var G=null,W=null;D?(G=""===D.value?le.PlainLiteralURI:this.parseTermOrCURIEOrAbsURI(D.value,_,l.terms,p,r),W=L&&!M?L.value:G===le.XMLLiteralURI||G===le.HTMLLiteralURI?null:M?M.value:h.textContent):M?(G=le.PlainLiteralURI,W=M.value):L?(W=L.value,(G=le.deriveDateTimeType(W))||(G=le.PlainLiteralURI)):j||S||(q&&(W=this.parseSafeCURIEOrCURIEOrURI(q.value,p,r)),!W&&$?W=this.resolveAndNormalize(r,encodeURI($.value)):!W&&B&&(W=this.resolveAndNormalize(r,encodeURI(B.value))),W&&(G=le.objectURI)),G||(F&&!P?(G=le.objectURI,W=d):(W=h.textContent,this.inHTMLMode&&"time"===h.localName&&(G=le.deriveDateTimeType(W)),G||(G=le.PlainLiteralURI))),O=this.tokenize(U.value);for(let t=0;t<O.length;t++){let e=this.parsePredicate(O[t],_,l.terms,p,r);if(e)if(H){let t=w[e];t||(t=[],w[e]=t),t.push(G===le.XMLLiteralURI||G===le.HTMLLiteralURI?{type:G,value:h.childNodes}:{type:G||le.PlainLiteralURI,value:W,language:v})}else G===le.XMLLiteralURI||G===le.HTMLLiteralURI?this.addTriple(h,c,e,{type:G,value:h.childNodes}):this.addTriple(h,c,e,{type:G||le.PlainLiteralURI,value:W,language:v})}}if(c&&!u)for(let t=0;t<l.incomplete.length;t++)l.incomplete[t].list?l.incomplete[t].list.push({type:le.objectURI,value:c}):l.incomplete[t].forward?this.addTriple(h,l.subject,l.incomplete[t].predicate,{type:le.objectURI,value:c}):this.addTriple(h,c,l.incomplete[t].predicate,{type:le.objectURI,value:l.subject});var Y=null,Z=c;u?((Y=this.push(l,l.subject)).parentObject=n(h.parentNode.baseURI)===l.parentObject?n(h.baseURI):l.parentObject,Y.incomplete=l.incomplete,Y.language=v,Y.prefixes=p,Y.vocabulary=_):((Y=this.push(l,c)).parentObject=f||c||l.subject,Y.prefixes=p,Y.incomplete=m,f&&(Z=f,w={},y=!0),Y.listMapping=w,Y.language=v,Y.vocabulary=_),y&&i.unshift({parent:h,context:l,subject:Z,listMapping:w});for(var J=h.lastChild;J;J=J.previousSibling)J.nodeType===he.ELEMENT_NODE&&i.unshift({current:J,context:Y})}}this.inHTMLMode&&this.copyProperties();for(let e=0;e<this.finishedHandlers.length;e++)this.finishedHandlers[e](t)}push(t,e){return{parent:t,subject:e||(t?t.subject:null),parentObject:null,incomplete:[],listMapping:t?t.listMapping:{},language:t?t.language:this.language,prefixes:t?t.prefixes:this.target.graph.prefixes,terms:t?t.terms:this.target.graph.terms,vocabulary:t?t.vocabulary:this.vocabulary}}resolveAndNormalize(t,e){return b.join(e,t)}setContext(t){"html"===t.localName&&"XHTML+RDFa 1.1"===t.getAttribute("version")?this.setXHTMLContext():"html"===t.localName||"http://www.w3.org/1999/xhtml"===t.namespaceURI?"undefined"!=typeof document&&document.doctype?"-//W3C//DTD XHTML+RDFa 1.0//EN"===document.doctype.publicId&&"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"===document.doctype.systemId?(console.log("WARNING: RDF 1.0 is not supported. Defaulting to HTML5 mode."),this.setHTMLContext()):"-//W3C//DTD XHTML+RDFa 1.1//EN"===document.doctype.publicId&&"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd"===document.doctype.systemId?this.setXHTMLContext():this.setHTMLContext():this.setHTMLContext():this.setXMLContext()}setHTMLContext(){this.setInitialContext(),this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"},{namespaceURI:null,localName:"lang"}],this.inXHTMLMode=!1,this.inHTMLMode=!0}setInitialContext(){this.vocabulary=null,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"}]}setXHTMLContext(){this.setInitialContext(),this.inXHTMLMode=!0,this.inHTMLMode=!1,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"},{namespaceURI:null,localName:"lang"}],this.target.graph.terms.alternate="http://www.w3.org/1999/xhtml/vocab#alternate",this.target.graph.terms.appendix="http://www.w3.org/1999/xhtml/vocab#appendix",this.target.graph.terms.bookmark="http://www.w3.org/1999/xhtml/vocab#bookmark",this.target.graph.terms.cite="http://www.w3.org/1999/xhtml/vocab#cite",this.target.graph.terms.chapter="http://www.w3.org/1999/xhtml/vocab#chapter",this.target.graph.terms.contents="http://www.w3.org/1999/xhtml/vocab#contents",this.target.graph.terms.copyright="http://www.w3.org/1999/xhtml/vocab#copyright",this.target.graph.terms.first="http://www.w3.org/1999/xhtml/vocab#first",this.target.graph.terms.glossary="http://www.w3.org/1999/xhtml/vocab#glossary",this.target.graph.terms.help="http://www.w3.org/1999/xhtml/vocab#help",this.target.graph.terms.icon="http://www.w3.org/1999/xhtml/vocab#icon",this.target.graph.terms.index="http://www.w3.org/1999/xhtml/vocab#index",this.target.graph.terms.last="http://www.w3.org/1999/xhtml/vocab#last",this.target.graph.terms.license="http://www.w3.org/1999/xhtml/vocab#license",this.target.graph.terms.meta="http://www.w3.org/1999/xhtml/vocab#meta",this.target.graph.terms.next="http://www.w3.org/1999/xhtml/vocab#next",this.target.graph.terms.prev="http://www.w3.org/1999/xhtml/vocab#prev",this.target.graph.terms.previous="http://www.w3.org/1999/xhtml/vocab#previous",this.target.graph.terms.section="http://www.w3.org/1999/xhtml/vocab#section",this.target.graph.terms.stylesheet="http://www.w3.org/1999/xhtml/vocab#stylesheet",this.target.graph.terms.subsection="http://www.w3.org/1999/xhtml/vocab#subsection",this.target.graph.terms.start="http://www.w3.org/1999/xhtml/vocab#start",this.target.graph.terms.top="http://www.w3.org/1999/xhtml/vocab#top",this.target.graph.terms.up="http://www.w3.org/1999/xhtml/vocab#up",this.target.graph.terms.p3pv1="http://www.w3.org/1999/xhtml/vocab#p3pv1",this.target.graph.terms.related="http://www.w3.org/1999/xhtml/vocab#related",this.target.graph.terms.role="http://www.w3.org/1999/xhtml/vocab#role",this.target.graph.terms.transformation="http://www.w3.org/1999/xhtml/vocab#transformation"}setXMLContext(){this.setInitialContext(),this.inXHTMLMode=!1,this.inHTMLMode=!1}tokenize(t){return this.trim(t).split(/\s+/)}static tokenize(t){return this.trim(t).split(/\s+/)}toRDFNodeObject(t){if(void 0!==t){if("string"==typeof t)return"_:"===t.substring(0,2)?(void 0===this.blankNodes[t.substring(2)]&&(this.blankNodes[t.substring(2)]=new n(t.substring(2))),this.blankNodes[t.substring(2)]):A.namedNode(t);switch(t.type){case le.objectURI:return"_:"===t.value.substring(0,2)?(void 0===this.blankNodes[t.value.substring(2)]&&(this.blankNodes[t.value.substring(2)]=new n(t.value.substring(2))),this.blankNodes[t.value.substring(2)]):A.namedNode(t.value);case le.PlainLiteralURI:return new u(t.value,t.language||"");case le.XMLLiteralURI:case le.HTMLLiteralURI:var e="";return Object.keys(t.value).forEach((r=>{e+=C.domToString(t.value[r],this.htmlOptions)})),new u(e,"",new s.A(t.type));default:return new u(t.value,"",new s.A(t.type))}}}trim(t){return t.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}static trim(t){return t.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}}le.XMLLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",le.HTMLLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML",le.PlainLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral",le.objectURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#object",le.typeURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",le.nameChar="[-A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ--⁰-Ⰰ-、-豈-﷏ﷰ-�က0-F.0-9·̀-ͯ‿-⁀]",le.nameStartChar="[A-Za-zÀ-ÖØ-öø-ÿĀ-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁΆΈ-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁҐ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆא-תװ-ײء-غف-يٱ-ڷں-ھۀ-ێې-ۓەۥ-ۦअ-हऽक़-ॡঅ-ঌএ-ঐও-নপ-রলশ-হড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઋઍએ-ઑઓ-નપ-રલ-ળવ-હઽૠଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଶ-ହଽଡ଼-ଢ଼ୟ-ୡஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-வஷ-ஹఅ-ఌఎ-ఐఒ-నప-ళవ-హౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹೞೠ-ೡഅ-ഌഎ-ഐഒ-നപ-ഹൠ-ൡก-ฮะา-ำเ-ๅກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ຮະາ-ຳຽເ-ໄཀ-ཇཉ-ཀྵႠ-Ⴥა-ჶᄀᄂ-ᄃᄅ-ᄇᄉᄋ-ᄌᄎ-ᄒᄼᄾᅀᅌᅎᅐᅔ-ᅕᅙᅟ-ᅡᅣᅥᅧᅩᅭ-ᅮᅲ-ᅳᅵᆞᆨᆫᆮ-ᆯᆷ-ᆸᆺᆼ-ᇂᇫᇰᇹḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼΩK-Å℮ↀ-ↂぁ-ゔァ-ヺㄅ-ㄬ가-힣一-龥〇〡-〩_]",le.NCNAME=new RegExp("^"+le.nameStartChar+le.nameChar+"*$"),le.dateTimeTypes=[{pattern:/-?P(?:[0-9]+Y)?(?:[0-9]+M)?(?:[0-9]+D)?(?:T(?:[0-9]+H)?(?:[0-9]+M)?(?:[0-9]+(?:\.[0-9]+)?S)?)?/,type:"http://www.w3.org/2001/XMLSchema#duration"},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]-[0-9][0-9]T(?:[0-1][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:"http://www.w3.org/2001/XMLSchema#dateTime"},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]-[0-9][0-9](?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:"http://www.w3.org/2001/XMLSchema#date"},{pattern:/(?:[0-1][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:"http://www.w3.org/2001/XMLSchema#time"},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]/,type:"http://www.w3.org/2001/XMLSchema#gYearMonth"},{pattern:/-?[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9]/,type:"http://www.w3.org/2001/XMLSchema#gYear"}];const ue=le.parseRDFaDOM;class ce{constructor(t){this.store=t,this.bnodes={},this.why=null,this.reify=!1}frameFactory(t,e,r){return{NODE:1,ARC:2,parent:e,parser:t,store:t.store,element:r,lastChild:0,base:null,lang:null,node:null,nodeType:null,listIndex:1,rdfid:null,datatype:null,collection:!1,terminateFrame:function(){this.collection&&this.node.close()},addSymbol:function(t,e){e=b.join(e,this.base),this.node=this.store.sym(e),this.nodeType=t},loadTriple:function(){if(this.parent.parent.collection?this.parent.parent.node.append(this.node):this.store.add(this.parent.parent.node,this.parent.node,this.node,this.parser.why),null!=this.parent.rdfid){var t=this.store.sym(b.join("#"+this.parent.rdfid,this.base));this.store.add(t,this.store.sym(ce.ns.RDF+"type"),this.store.sym(ce.ns.RDF+"Statement"),this.parser.why),this.store.add(t,this.store.sym(ce.ns.RDF+"subject"),this.parent.parent.node,this.parser.why),this.store.add(t,this.store.sym(ce.ns.RDF+"predicate"),this.parent.node,this.parser.why),this.store.add(t,this.store.sym(ce.ns.RDF+"object"),this.node,this.parser.why)}},isTripleToLoad:function(){return null!=this.parent&&null!=this.parent.parent&&this.nodeType===this.NODE&&this.parent.nodeType===this.ARC&&this.parent.parent.nodeType===this.NODE},addNode:function(t){this.addSymbol(this.NODE,t),this.isTripleToLoad()&&this.loadTriple()},addCollection:function(){this.nodeType=this.NODE,this.node=this.store.collection(),this.collection=!0,this.isTripleToLoad()&&this.loadTriple()},addCollectionArc:function(){this.nodeType=this.ARC},addBNode:function(t){null!=t?null!=this.parser.bnodes[t]?this.node=this.parser.bnodes[t]:this.node=this.parser.bnodes[t]=this.store.bnode():this.node=this.store.bnode(),this.nodeType=this.NODE,this.isTripleToLoad()&&this.loadTriple()},addArc:function(t){t===ce.ns.RDF+"li"&&(t=ce.ns.RDF+"_"+this.parent.listIndex,this.parent.listIndex++),this.addSymbol(this.ARC,t)},addLiteral:function(t){this.parent.datatype&&this.parent.datatype!==ce.ns.RDF+"langString"?this.node=this.store.literal(t,this.store.sym(this.parent.datatype)):this.node=this.store.literal(t,this.lang),this.nodeType=this.NODE,this.isTripleToLoad()&&this.loadTriple()}}}getAttributeNodeNS(t,e,r){var i=null;if(t.getAttributeNodeNS)i=t.getAttributeNodeNS(e,r);else for(var n,s=t.attributes,a=0;a<s.length;++a)if((n=s[a]).namespaceURI===e&&(n.prefix?n.prefix+":"+r:r)===n.nodeName){i=n;break}return i}parse(t,e,r){var i,n=t.childNodes;if(this.cleanParser(),t.nodeType===ce.nodeType.DOCUMENT){for(var s=0;s<n.length;s++)if(n[s].nodeType===ce.nodeType.ELEMENT){i=n[s];break}}else{if(t.nodeType!==ce.nodeType.ELEMENT)throw new Error("RDFParser: can't find root in "+e+". Halting. ");i=t}this.why=r;var a=this.frameFactory(this);return this.base=e,a.base=e,a.lang=null,this.parseDOM(this.buildFrame(a,i)),!0}parseDOM(t){for(var e,r=function(t){var e="";if(null==t.namespaceURI)throw new Error("RDF/XML syntax error: No namespace for "+t.localName+" in "+this.base);return t.namespaceURI&&(e+=t.namespaceURI),t.localName?e+=t.localName:t.nodeName&&(t.nodeName.indexOf(":")>=0?e+=t.nodeName.split(":")[1]:e+=t.nodeName),e}.bind(this),i=!0;t.parent;){var n=t.element,s=n.attributes;if(n.nodeType===ce.nodeType.TEXT||n.nodeType===ce.nodeType.CDATA_SECTION)t.parent.nodeType===t.NODE&&(t.addArc(ce.ns.RDF+"value"),t=this.buildFrame(t)),t.addLiteral(n.nodeValue);else if(r(n)!==ce.ns.RDF+"RDF")if(t.parent&&t.parent.collection&&(t.addCollectionArc(),(t=this.buildFrame(t,t.element)).parent.element=null),t.parent&&t.parent.nodeType&&t.parent.nodeType!==t.ARC){t.addArc(r(n)),this.reify&&(e=this.getAttributeNodeNS(n,ce.ns.RDF,"ID"))&&(t.rdfid=e.nodeValue,n.removeAttributeNode(e));var a=this.getAttributeNodeNS(n,ce.ns.RDF,"parseType"),o=this.getAttributeNodeNS(n,ce.ns.RDF,"datatype");if(o&&(t.datatype=o.nodeValue,n.removeAttributeNode(o)),a){var h=a.nodeValue;"Literal"===h?(t.datatype=ce.ns.RDF+"XMLLiteral",(t=this.buildFrame(t)).addLiteral(n.innerHTML||n.childNodes),i=!1):"Resource"===h?((t=this.buildFrame(t,t.element)).parent.element=null,t.addBNode()):"Collection"===h&&((t=this.buildFrame(t,t.element)).parent.element=null,t.addCollection()),n.removeAttributeNode(a)}if(0!==s.length){var l=this.getAttributeNodeNS(n,ce.ns.RDF,"resource"),u=this.getAttributeNodeNS(n,ce.ns.RDF,"nodeID");t=this.buildFrame(t),l?(t.addNode(l.nodeValue),n.removeAttributeNode(l)):u?(t.addBNode(u.nodeValue),n.removeAttributeNode(u)):t.addBNode();for(var c=s.length-1;c>=0;c--){var f=this.buildFrame(t);f.addArc(r(s[c])),r(s[c])===ce.ns.RDF+"type"?this.buildFrame(f).addNode(s[c].nodeValue):this.buildFrame(f).addLiteral(s[c].nodeValue)}}else 0===n.childNodes.length&&this.buildFrame(t).addLiteral("")}else{var d=this.getAttributeNodeNS(n,ce.ns.RDF,"about");if(e=this.getAttributeNodeNS(n,ce.ns.RDF,"ID"),d&&e)throw new Error("RDFParser: "+n.nodeName+" has both rdf:id and rdf:about. Halting. Only one of these properties may be specified on a node.");if(!d&&e)t.addNode("#"+e.nodeValue),n.removeAttributeNode(e);else if(null==d&&null==e){var p=this.getAttributeNodeNS(n,ce.ns.RDF,"nodeID");p?(t.addBNode(p.nodeValue),n.removeAttributeNode(p)):t.addBNode()}else t.addNode(d.nodeValue),n.removeAttributeNode(d);var g=this.getAttributeNodeNS(n,ce.ns.RDF,"type");ce.ns.RDF+"Description"!==r(n)&&(g={nodeValue:r(n)}),null!=g&&(this.store.add(t.node,this.store.sym(ce.ns.RDF+"type"),this.store.sym(b.join(g.nodeValue,t.base)),this.why),g.nodeName&&n.removeAttributeNode(g));for(var m=s.length-1;m>=0;m--)this.store.add(t.node,this.store.sym(r(s[m])),this.store.literal(s[m].nodeValue,t.lang),this.why)}for(n=t.element;t.parent;){for(var w=t;null==n;)n=(t=t.parent).element;var y=n.childNodes&&n.childNodes[t.lastChild];if(y&&i){if((y.nodeType===ce.nodeType.ELEMENT||y.nodeType===ce.nodeType.TEXT||y.nodeType===ce.nodeType.CDATA_SECTION)&&(y.nodeType!==ce.nodeType.TEXT&&y.nodeType!==ce.nodeType.CDATA_SECTION||1===n.childNodes.length)){t.lastChild++,t=this.buildFrame(w,n.childNodes[t.lastChild-1]);break}t.lastChild++}else{if(t.terminateFrame(),!(t=t.parent))break;n=t.element,i=!0}}}}cleanParser(){this.bnodes={},this.why=null}buildFrame(t,e){var r=this.frameFactory(this,t,e);if(t&&(r.base=t.base,r.lang=t.lang),!e||e.nodeType===ce.nodeType.TEXT||e.nodeType===ce.nodeType.CDATA_SECTION)return r;var i=e.attributes,n=e.getAttributeNode("xml:base");null!=n&&(r.base=n.nodeValue,e.removeAttribute("xml:base"));var s=e.getAttributeNode("xml:lang");null!=s&&(r.lang=s.nodeValue,e.removeAttribute("xml:lang"));for(var a=i.length-1;a>=0;a--)if("xml"===i[a].nodeName.substr(0,3)){if("xmlns:"===i[a].name.slice(0,6)){var o=i[a].nodeValue;this.base&&(o=b.join(o,this.base)),this.store.setPrefixForURI(i[a].name.slice(6),o)}e.removeAttributeNode(i[a])}return r}}function fe(t,e,r){var i,n,s,a=["INSERT","DELETE","WHERE"],o=E("http://www.w3.org/ns/pim/patch#"),h=yt(e,e,r,r,null,null,"",null),l={},u=function(t,e,r,i,n){return"Line "+(e+1)+" of <"+t+">: Bad syntax:\n "+n+'\n at: "'+r.slice(i,i+30)+'"'};i=0;var c=e.sym(r+"#query");for(l.query=c;;){if((n=h.skipSpace(t,i))<0)return l;if(";"===t[n]){if((i=h.skipSpace(t,n+1))<0)return l;n=i}var f=!1;for(s=0;s<a.length;s++){var d=a[s];if(t.slice(n,n+d.length)===d){if((i=h.skipSpace(t,n+d.length))<0)throw u(h._thisDoc,h.lines,t,n+d.length,"found EOF, needed {...} after "+d);if(("INSERT"===d||"DELETE"===d)&&"DATA"===t.slice(i,i+4)){if((n=h.skipSpace(t,i+4))<0)throw u(h._thisDoc,h.lines,t,i+4,"needed {...} after INSERT DATA "+d);i=n}var p=[];if((n=h.node(t,i,p))<0)throw u(h._thisDoc,h.lines,t,i,"bad syntax or EOF in {...} after "+d);l[d.toLowerCase()]=p[0],e.add(c,o(d.toLowerCase()),p[0]),f=!0,i=n}}if(!f&&"@prefix"===t.slice(n,n+7)){if((i=h.directive(t,n))<0)throw u(h._thisDoc,h.lines,t,i,"bad syntax or EOF after @prefix ");i=h.checkDot(t,i),f=!0}if(!f)throw u(h._thisDoc,h.lines,t,n,"Unknown syntax at start of statememt: '"+t.slice(n).slice(0,20)+"'")}}function de(t,e,r,n="text/turtle",s){n=(n=n||i.sT).split(";")[0];try{if(n===i.ny||n===i.sT)yt(e,e,r,r,null,null,"",null).loadBuf(t),o();else if(n===i.JG)new ce(e).parse(C.parseXML(t),r,e.sym(r)),o();else if(n===i.H)ue(C.parseXML(t,{contentType:i.H}),e,r),o();else if(n===i.lc)ue(C.parseXML(t,{contentType:i.lc}),e,r),o();else if(n===i.K9||n===i.Fn)fe(t,e,r),o();else if(n===i.i2)At(t,e,r).then(o).catch(h);else{if(n!==i._0&&n!==i.BR)throw void 0===n?new Error("contentType is undefined"):new Error("Don't know how to parse "+n+" yet");var a=new se({factory:xt});!function(t,r){try{a.parse(r,l)}catch(t){s(t,e)}}(null,t)}}catch(t){h(t)}function o(){s&&s(null,e)}function h(t){if(n!==i.i2||n!==i._0||n!==i.BR){if(!s){let e=new Error(t+" while trying to parse <"+r+"> as "+n);throw e.cause=t,e}s(t,e)}}function l(t,r){r?e.add(r.subject,r.predicate,r.object,r.graph):s(t,e)}de.handled={"text/n3":!0,"text/turtle":!0,"application/rdf+xml":!0,"application/xhtml+xml":!0,"text/html":!0,"application/sparql-update":!0,"application/sparql-update-single-match":!0,"application/ld+json":!0,"application/nquads":!0,"application/n-quads":!0}}(0,t.A)(ce,"ns",{RDF:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",RDFS:"http://www.w3.org/2000/01/rdf-schema#"}),(0,t.A)(ce,"nodeType",{ELEMENT:1,ATTRIBUTE:2,TEXT:3,CDATA_SECTION:4,ENTITY_REFERENCE:5,ENTITY:6,PROCESSING_INSTRUCTION:7,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,NOTATION:12});var pe=o(1147),ge=o.n(pe),me=o(362);const we={"text/n3":!0,"text/turtle":!0,"application/rdf+xml":!0,"application/xhtml+xml":!0,"text/html":!0,"application/ld+json":!0},ye={rdf:i.JG,owl:i.JG,n3:"text/n3",ttl:"text/turtle",nt:"text/n3",acl:"text/n3",html:"text/html",xml:"text/xml"},be=t=>({link:E("http://www.w3.org/2007/ont/link#",t),http:E("http://www.w3.org/2007/ont/http#",t),httph:E("http://www.w3.org/2007/ont/httph#",t),rdf:E("http://www.w3.org/1999/02/22-rdf-syntax-ns#",t),rdfs:E("http://www.w3.org/2000/01/rdf-schema#",t),dc:E("http://purl.org/dc/elements/1.1/",t),ldp:E("http://www.w3.org/ns/ldp#",t)}),ve=be();class _e{constructor(e,r){(0,t.A)(this,"response",void 0),(0,t.A)(this,"dom",void 0),this.response=e,this.dom=r}}(0,t.A)(_e,"pattern",void 0);class xe extends _e{static toString(){return"RDFXMLHandler"}static register(t){t.mediatypes[i.JG]={q:.9}}parse(t,e,r){let i=t.store;if(this.dom||(this.dom=C.parseXML(e)),"parsererror"===this.dom.documentElement.nodeName)return t.failFetch(r,"Badly formed XML in "+r.resource.value,"parse_error");let n=new ce(i);try{n.parse(this.dom,r.original.value,r.original)}catch(e){return t.failFetch(r,"Syntax error parsing RDF/XML! "+e,"parse_error")}return r.noMeta||i.add(r.original,ve.rdf("type"),ve.link("RDFDocument"),t.appNode),t.doneFetch(r,this.response)}}xe.pattern=new RegExp("application/rdf\\+xml");class Te extends _e{static toString(){return"XHTMLHandler"}static register(t){t.mediatypes[i.H]={q:.8}}parse(t,e,r){let i,n;this.dom||(this.dom=C.parseXML(e));let s=t.store,a=this.dom.getElementsByTagName("title");a.length>0&&s.add(r.resource,ve.dc("title"),s.rdfFactory.literal(a[0].textContent),r.resource);let o=this.dom.getElementsByTagName("link");for(let e=o.length-1;e>=0;e--)i=o[e].getAttribute("rel"),n=!1,i||(i=o[e].getAttribute("rev"),n=!0),i&&t.linkData(r.original,i,o[e].getAttribute("href"),r.resource,n);let h=this.dom.getElementsByTagName("script");for(let t=0;t<h.length;t++){let e=h[t].getAttribute("type");we[e]&&(de(h[t].textContent,s,r.original.value,e),de(h[t].textContent,s,r.original.value,e))}if(r.noMeta||s.add(r.resource,ve.rdf("type"),ve.link("WebPage"),t.appNode),!r.noRDFa&&ue)try{ue(this.dom,s,r.original.value)}catch(e){let i="Error trying to parse "+r.resource+" as RDFa:\n"+e+":\n"+e.stack;return t.failFetch(r,i,"parse_error")}return t.doneFetch(r,this.response)}}Te.pattern=new RegExp("application/xhtml");class Ae extends _e{static toString(){return"XMLHandler"}static register(t){t.mediatypes["text/xml"]={q:.5},t.mediatypes["application/xml"]={q:.5}}static isElement(t){return t.nodeType===Node.ELEMENT_NODE}parse(t,e,r){let i=C.parseXML(e);for(let n=0;n<i.childNodes.length;n++){const s=i.childNodes[n];if(Ae.isElement(s)){let n=s.namespaceURI;if(n&&n===n.rdf)return t.addStatus(r.req,"Has XML root element in the RDF namespace, so assume RDF/XML."),new xe(this.response,i).parse(t,e,r);break}}if(i.doctype&&"html"===i.doctype.name&&i.doctype.publicId.match(/^-\/\/W3C\/\/DTD XHTML/)&&i.doctype.systemId.match(/http:\/\/www.w3.org\/TR\/xhtml/))return t.addStatus(r.req,"Has XHTML DOCTYPE. Switching to XHTML Handler.\n"),new Te(this.response,i).parse(t,e,r);let n=i.getElementsByTagName("html")[0];if(n){let s=n.getAttribute("xmlns");if(s&&s.match(/^http:\/\/www.w3.org\/1999\/xhtml/))return t.addStatus(r.req,"Has a default namespace for XHTML. Switching to XHTMLHandler.\n"),new Te(this.response,i).parse(t,e,r)}return t.failFetch(r,"Unsupported dialect of XML: not RDF or XHTML namespace, etc.\n"+e.slice(0,80),901)}}Ae.pattern=new RegExp("(text|application)/(.*)xml");class Ne extends _e{static toString(){return"HTMLHandler"}static register(t){t.mediatypes["text/html"]={q:.8}}parse(t,e,r){let i=t.store;if(Ce(e))return t.addStatus(r.req,"Has an XML declaration. We'll assume it's XHTML as the content-type was text/html.\n"),new Te(this.response).parse(t,e,r);if(function(t){const e=t.indexOf("<!DOCTYPE html"),r=t.indexOf(">");return!(-1===e||-1===r||e>r)&&-1!==t.substr(e,r-e).indexOf("XHTML")}(e))return t.addStatus(r.req,"Has XHTML DOCTYPE. Switching to XHTMLHandler.\n"),new Te(this.response).parse(t,e,r);if(function(t){return!!t.match(/[^(<html)]*<html\s+[^<]*xmlns=['"]http:\/\/www.w3.org\/1999\/xhtml["'][^<]*>/)}(e))return t.addStatus(r.req,"Has default namespace for XHTML, so switching to XHTMLHandler.\n"),new Te(this.response).parse(t,e,r);let n=new RegExp("<title>([\\s\\S]+?)</title>","im").exec(e);return n&&i.add(r.resource,ve.dc("title"),i.rdfFactory.literal(n[1]),r.resource),i.add(r.resource,ve.rdf("type"),ve.link("WebPage"),t.appNode),t.addStatus(r.req,"non-XML HTML document, not parsed for data."),t.doneFetch(r,this.response)}}Ne.pattern=new RegExp("text/html");class Ee extends _e{static toString(){return"JsonLdHandler"}static register(t){t.mediatypes["application/ld+json"]={q:.9}}async parse(t,e,r,i){const n=t.store;try{return await At(e,n,r.original.value),t.store.add(r.original,ve.rdf("type"),ve.link("RDFDocument"),t.appNode),t.doneFetch(r,i)}catch(e){const n="Error trying to parse "+r.resource+" as JSON-LD:\n"+e;return t.failFetch(r,n,"parse_error",i)}}}Ee.pattern=/application\/(ld\+json|activity\+json)/;class Re extends _e{static toString(){return"TextHandler"}static register(t){t.mediatypes["text/plain"]={q:.5}}parse(t,e,r){return Ce(e)?(t.addStatus(r.req,"Warning: "+r.resource+" has an XML declaration. We'll assume it's XML but its content-type wasn't XML.\n"),new Ae(this.response).parse(t,e,r)):e.slice(0,500).match(/xmlns:/)?(t.addStatus(r.req,"May have an XML namespace. We'll assume it's XML but its content-type wasn't XML.\n"),new Ae(this.response).parse(t,e,r)):(t.addStatus(r.req,"Plain text document, no known RDF semantics."),t.doneFetch(r,this.response))}}Re.pattern=new RegExp("text/plain");class ke extends _e{static toString(){return"N3Handler"}static register(t){t.mediatypes["text/n3"]={},t.mediatypes["text/turtle"]={}}parse(t,e,r,i){let n=t.store,s=yt(n,n,r.original.value,r.original.value,null,null,"",null);try{s.loadBuf(e)}catch(e){let n="Error trying to parse "+r.resource+" as Notation3:\n"+e;return t.failFetch(r,n,"parse_error",i)}return t.addStatus(r.req,"N3 parsed: "+s.statementCount+" triples in "+s.lines+" lines."),t.store.add(r.original,ve.rdf("type"),ve.link("RDFDocument"),t.appNode),t.doneFetch(r,this.response)}}ke.pattern=new RegExp("(application|text)/(x-)?(rdf\\+)?(n3|turtle)");const Ie={RDFXMLHandler:xe,XHTMLHandler:Te,XMLHandler:Ae,HTMLHandler:Ne,TextHandler:Re,N3Handler:ke,JsonLdHandler:Ee};function Ce(t){return!!t.match(/\s*<\?xml\s+version\s*=[^<>]+\?>/)}class Oe{constructor(e,r={}){if((0,t.A)(this,"store",void 0),(0,t.A)(this,"timeout",void 0),(0,t.A)(this,"_fetch",void 0),(0,t.A)(this,"mediatypes",void 0),(0,t.A)(this,"appNode",void 0),(0,t.A)(this,"requested",void 0),(0,t.A)(this,"timeouts",void 0),(0,t.A)(this,"redirectedTo",void 0),(0,t.A)(this,"fetchQueue",void 0),(0,t.A)(this,"fetchCallbacks",void 0),(0,t.A)(this,"nonexistent",void 0),(0,t.A)(this,"lookedUp",void 0),(0,t.A)(this,"handlers",void 0),(0,t.A)(this,"ns",void 0),(0,t.A)(this,"fireCallbacks",void 0),this.store=e||new G,this.ns=be(this.store.rdfFactory),this.timeout=r.timeout||3e4,this._fetch=r.fetch||void 0!==o.g&&(o.g.solidFetcher||o.g.solidFetch)||"undefined"!=typeof window&&(window.solidFetcher||window.solidFetch)||ge(),!this._fetch)throw new Error("No _fetch function available for Fetcher");this.appNode=this.store.sym("chrome://TheCurrentSession"),this.store.fetcher=this,this.requested={},this.timeouts={},this.redirectedTo={},this.fetchQueue={},this.fetchCallbacks={},this.nonexistent={},this.lookedUp={},this.handlers=[],this.mediatypes={"image/*":{q:.9},"*/*":{q:.1}},C.callbackify(this,["request","fail","refresh","retract","done"]),Object.keys(r.handlers||Ie).map((t=>this.addHandler(Ie[t])))}static crossSiteProxy(t){return Oe.crossSiteProxyTemplate?Oe.crossSiteProxyTemplate.replace("{uri}",encodeURIComponent(t)):void 0}static offlineOverride(t){let e=t;var r;return"undefined"!=typeof window&&window.panes&&(r=window.panes.UI)&&r.preferences&&r.preferences.get("offlineModeUsingLocalhost")&&"http://"===e.slice(0,7)&&"localhost/"!==e.slice(7,17)&&(e="http://localhost/"+e.slice(7),N.A.warn("Localhost kludge for offline use: actually getting <"+e+">")),e}static proxyIfNecessary(t){var e;if("undefined"!=typeof window&&window.panes&&(e=window.panes.UI)&&e.isExtension)return t;if("undefined"!=typeof $SolidTestEnvironment&&$SolidTestEnvironment.localSiteMap){let e=t.split("/").slice(2);const r=(t,e)=>{let i=e[t.shift()];return i?"string"==typeof i?i+t.join("/"):t?r(t,i):null:null},i=r(e,$SolidTestEnvironment.localSiteMap);if(i)return i}return Oe.crossSiteProxyTemplate&&"undefined"!=typeof document&&document.location&&"https:"===(""+document.location).slice(0,6)&&"http:"===t.slice(0,5)?Oe.crossSiteProxyTemplate.replace("{uri}",encodeURIComponent(t)):t}static unsupportedProtocol(t){let e=b.protocol(t);return"tel"===e||"mailto"===e||"urn"===e}static setCredentials(t,e={}){void 0===e.credentials&&(void 0!==e.withCredentials?e.credentials=e.withCredentials?"include":"omit":e.credentials="include")}load(t,e={}){if(e=Object.assign({},e),t instanceof Array)return Promise.all(t.map((t=>this.load(t,Object.assign({},e)))));const r=t;let i=(0,me.E)(r);i=i.split("#")[0],e=this.initFetchOptions(i,e);const n=this.appNode,s=this.store,a=s.statementsMatching(void 0,this.ns.link("requestedURI"),s.sym(i),n).map((t=>t.subject));for(const t of a){const r=s.any(t,this.ns.link("response"),null,n);if(null!=r){const t=s.statementsMatching(r,this.ns.link("outOfDate"),!0,n);s.remove(t),e.force=!0,e.clearPreviousData=!0}}const o=this.initFetchOptions(i,e);return this.pendingFetchPromise(i,o.baseURI,o)}async pendingFetchPromise(t,e,r){let i;return!r.force&&await this.fetchQueue[e]?i=this.fetchQueue[e]:(i=Promise.race([this.setRequestTimeout(t,r),this.fetchUri(t,r)]),this.fetchQueue[e]=i,this.cleanupFetchRequest(e,void 0,this.timeout)),i.then((e=>(t in this.timeouts&&(this.timeouts[t].forEach(clearTimeout),delete this.timeouts[t]),e)))}cleanupFetchRequest(t,e,r){void 0!==e&&console.warn("_options is deprecated"),this.timeouts[t]=(this.timeouts[t]||[]).concat(setTimeout((()=>{this.isPending(t)||delete this.fetchQueue[t]}),r))}initFetchOptions(t,e){let r=this.store;!e.method||"GET"===e.method.toUpperCase()||(e.force=!0),e.resource=r.rdfFactory.namedNode(t),e.baseURI=e.baseURI||t,e.original=r.rdfFactory.namedNode(e.baseURI),e.req=r.bnode(),e.headers=e.headers||{},e.contentType&&(e.headers["content-type"]=e.contentType),e.force&&(e.cache="no-cache");let i=this.acceptString();e.headers.accept=i;let n=Oe.offlineOverride(t);e.requestedURI=n,Oe.setCredentials(n,e);let s=Oe.proxyIfNecessary(n);return n!==s&&(e.proxyUsed=!0),e.actualProxyURI=s,e}fetchUri(t,e){if(!t)return Promise.reject(new Error("Cannot fetch an empty uri"));if(Oe.unsupportedProtocol(t))return this.failFetch(e,"fetcher: Unsupported protocol","unsupported_protocol");let r=this.getState(t);if(e.force)delete this.nonexistent[t];else{if("fetched"===r)return Promise.resolve(this.doneFetch(e,{status:200,ok:!0,statusText:"Already loaded into quadstore."}));if("failed"===r&&404===this.requested[t]){let r="Previously failed: "+this.requested[t],i={url:t,status:this.requested[t],statusText:r,responseText:r,headers:new pe.Headers,ok:!1,body:null,bodyUsed:!1,size:0,timeout:0};return this.failFetch(e,r,this.requested[t],i)}}this.fireCallbacks("request",[t]),this.requested[t]=!0,e.noMeta||this.saveRequestMetadata(t,e);let{actualProxyURI:i}=e;return this._fetch(i,e).then((r=>this.handleResponse(r,t,e)),(r=>{let n={url:i,status:999,statusText:(r.name||"network failure")+": "+(r.errno||r.code||r.type),responseText:r.message,headers:new pe.Headers,ok:!1,body:null,bodyUsed:!1,size:0,timeout:0};return this.handleError(n,t,e)}))}nowOrWhenFetched(t,e,r,i={}){const n=(0,me.E)(t);"function"==typeof e?r=e:void 0===e||((0,a.Y2)(e)?i.referringTerm=e:i=e),this.load(n,i).then((t=>{if(r)if(t)if(t.ok)r(!0,"OK",t);else{let e="HTTP error: Status "+t.status+" ("+t.statusText+")";t.responseText&&(e+=" "+t.responseText),r(!1,e,t)}else r(!1,"@@ nowOrWhenFetched: no response object!")}),(function(t){var e=t.message||t.statusText;e="Failed to load <"+n+"> "+e,t.response&&t.response.status&&(e+=" status: "+t.response.status),r(!1,e,t.response)}))}addStatus(t,e){let r=new Date;e="["+r.getHours()+":"+r.getMinutes()+":"+r.getSeconds()+"."+r.getMilliseconds()+"] "+e;let i=this.store;const n=i.the(t,this.ns.link("status"));(0,a.P3)(n)?n.append(i.rdfFactory.literal(e)):N.A.warn("web.js: No list to add to: "+n+","+e)}failFetch(t,e,r,i){this.addStatus(t.req,e),t.noMeta||this.store.add(t.original,this.ns.link("error"),this.store.rdfFactory.literal(e));let n=(t.method||"GET").toUpperCase();("GET"===n||"HEAD"===n)&&(t.resource.equals(t.original),this.requested[b.docpart(t.original.value)]=r,this.fireCallbacks("fail",[t.original.value,e]));var s=new Error("Fetcher: "+e);return s.status=r,s.statusText=e,s.response=i,Promise.reject(s)}linkData(t,e,r,i,n){if(!r)return;let s,a=this.store,o=a.rdfFactory.namedNode(b.join(r,t.value));if("alternate"===e||"seeAlso"===e||"meta"===e||"describedby"===e){if(o.value===t.value)return;s=this.ns.rdfs("seeAlso")}else s="type"===e?a.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"):a.rdfFactory.namedNode(b.join(encodeURIComponent(e),"http://www.iana.org/assignments/link-relations/"));n?a.add(o,s,t,i):a.add(t,s,o,i)}parseLinkHeader(t,e,r){if(!t)return;const i=/[^\(\)<>@,;:"\/\[\]\?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*"))/g,n=t.match(/<[^>]*>\s*(\s*;\s*[^()<>@,;:"/[\]?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*")))*(,|$)/g);if(null!=n)for(let t=0;t<n.length;t++){let s=n[t].split(">"),a=s[0].substring(1),o=s[1].match(i);if(null==o)return;for(let t=0;t<o.length;t++){let i=o[t].split("=")[1].replace(/["']/g,"");this.linkData(e,i,a,r)}}}doneFetch(t,e){return this.addStatus(t.req,"Done."),this.requested[t.original.value]="done",this.fireCallbacks("done",[t.original.value]),e.req=t.req,e}nowKnownAs(t,e){this.lookedUp[t.value]?this.lookedUp[e.value]||this.lookUpThing(e,t):this.lookedUp[e.value]&&(this.lookedUp[t.value]||this.lookUpThing(t,e))}putBack(t,e={}){const r=(0,me.E)(t);let n=new s.A(r).doc();return e.contentType=e["content-type"]||e["Content-Type"]||e.contentType||i.sT,"application/ld+json"===e.contentType?new Promise(((r,i)=>{F(n,this.store,n.uri,e.contentType,((n,s)=>{n?i(n):(e.data=s,this.webOperation("PUT",t,e).then((t=>r(t))).catch((t=>i(t))))}))})):(e.data=F(n,this.store,n.value,e.contentType),this.webOperation("PUT",r,e))}webCopy(t,e,r){return this.webOperation("GET",t).then((t=>this.webOperation("PUT",e,{data:t.responseText,contentType:r})))}delete(t,e){return this.webOperation("DELETE",t,e).then((e=>(this.requested[t]=404,this.nonexistent[t]=!0,this.unload(this.store.rdfFactory.namedNode(t)),e)))}async createIfNotExists(t,e=i.sT,r=""){const n=this;try{var s=await n.load(t)}catch(i){if(404===i.response.status){try{s=await n.webOperation("PUT",t.value,{data:r,contentType:e})}catch(t){throw t}return delete n.requested[t.value],s}throw i}return s}createContainer(t,e,r){let n={"content-type":i.sT,link:this.ns.ldp("BasicContainer")+'; rel="type"'};e&&(n.slug=e);let s={headers:n};return r&&(s.body=r),this.webOperation("POST",t,s)}invalidateCache(t){const e=(0,me.E)(t),r=this;if(r.fetchQueue&&r.fetchQueue[e]&&(r.fetchQueue[e].PromiseStatus,delete r.fetchQueue[e]),r.requested[e]&&"done"!==r.requested[e]&&"failed"!==r.requested[e]&&404!==r.requested[e]){let t=`Rdflib: fetcher: Destructive operation on <${r.requested[e]}> file being fetched! `+e;console.error(t)}else delete r.requested[e],delete r.nonexistent[e]}webOperation(t,e,r={}){const i=(0,me.E)(e);r.method=t,r.body=r.data||r.body,r.force=!0;const n=this;if(r.body&&!r.contentType)throw new Error("Web operation sending data must have a defined contentType.");return r.contentType&&(r.headers=r.headers||{},r.headers["content-type"]=r.contentType),Oe.setCredentials(i,r),new Promise((function(e,s){n._fetch(i,r).then((r=>{if(r.ok)"PUT"!==t&&"PATCH"!==t&&"POST"!==t&&"DELETE"!==t||n.invalidateCache(i),r.text?r.text().then((t=>{r.responseText=t,e(r)})):e(r);else{let e="Web error: "+r.status;r.statusText&&(e+=" ("+r.statusText+")"),e+=" on "+t+" of <"+i+">",r.responseText&&(e+=": "+r.responseText);let n=new Error(e);n.response=r,s(n)}}),(e=>{s(new Error("Fetch error for "+t+" of <"+i+">:"+e))}))}))}lookUpThing(t,e){let r=this.store.uris(t);return r=r.map((t=>b.docpart(t))),r.forEach((t=>{this.lookedUp[t]=!0})),this.load(r,{referringTerm:e})}getHeader(t,e){const r=this.store,i=t.value,n=r.each(void 0,this.ns.link("requestedURI"),r.rdfFactory.literal(i));for(let t=0;t<n.length;t++){let i=n[t];if(void 0!==i){let t=r.any(i,this.ns.link("response"));if(void 0!==t&&r.anyValue(t,this.ns.http("status"))&&r.anyValue(t,this.ns.http("status")).startsWith("2")){let i=r.each(t,this.ns.httph(e.toLowerCase()));return i.length?i.map((t=>t.value)):[]}}}}saveRequestMetadata(t,e){let r=e.req,i=this.store,n=e.referringTerm;this.addStatus(e.req,"Accept: "+e.headers.accept),(0,a.Y2)(n)&&i.add(i.rdfFactory.namedNode(t),this.ns.link("requestedBy"),n,this.appNode),e.original&&e.original.value!==t&&i.add(r,this.ns.link("orginalURI"),i.rdfFactory.literal(e.original.value),this.appNode);const s=new Date,o="["+s.getHours()+":"+s.getMinutes()+":"+s.getSeconds()+"] ";i.add(r,this.ns.rdfs("label"),i.rdfFactory.literal(o+" Request for "+t),this.appNode),i.add(r,this.ns.link("requestedURI"),i.rdfFactory.literal(t),this.appNode),i.add(r,this.ns.link("status"),i.collection(),this.appNode)}saveResponseMetadata(t,e){const r=this.store;let i=r.bnode();return r.add(e.req,this.ns.link("response"),i,this.appNode),r.add(i,this.ns.http("status"),r.rdfFactory.literal(t.status),this.appNode),r.add(i,this.ns.http("statusText"),r.rdfFactory.literal(t.statusText),this.appNode),t.headers.forEach(((t,n)=>{r.add(i,this.ns.httph(n),this.store.rdfFactory.literal(t),this.appNode),"content-type"===n&&r.add(e.resource,this.ns.rdf("type"),r.rdfFactory.namedNode(C.mediaTypeClass(t).value),this.appNode)})),i}objectRefresh(t){let e=this.store.uris(t);if(void 0!==e)for(let t=0;t<e.length;t++)this.refresh(this.store.rdfFactory.namedNode(b.docpart(e[t])))}refresh(t,e){this.fireCallbacks("refresh",arguments),this.nowOrWhenFetched(t,{force:!0,clearPreviousData:!0},e)}refreshIfExpired(t,e){let r=this.getHeader(t,"Expires");!r||new Date(r[0]).getTime()<=(new Date).getTime()?this.refresh(t,e):e(!0,"Not expired",{})}retract(t){this.store.removeMany(void 0,void 0,void 0,t),t.value&&delete this.requested[b.docpart(t.value)],this.fireCallbacks("retract",arguments)}getState(t){return void 0===this.requested[t]?"unrequested":!0===this.requested[t]?"requested":"done"===this.requested[t]?"fetched":"redirected"===this.requested[t]?this.getState(this.redirectedTo[t]):"failed"}isPending(t){return!0===this.requested[t]}unload(t){this.store.removeDocument(t),delete this.requested[t.value]}addHandler(t){this.handlers.push(t),t.register(this)}retryNoCredentials(t,e){e.retriedWithNoCredentials=!0,delete this.requested[t],delete this.fetchQueue[t];let r=Object.assign({},e,{credentials:"omit"});return this.addStatus(e.req,"Abort: Will retry with credentials SUPPRESSED to see if that helps"),this.load(t,r)}isCrossSite(t){if("undefined"==typeof document||!document.location)return!1;const e=b.hostpart,r=""+document.location;return(e(r)&&e(t)&&e(r))!==e(t)}handleError(t,e,r){if(this.isCrossSite(e)){if(r.credentials&&"include"===r.credentials&&!r.retriedWithNoCredentials)return this.retryNoCredentials(e,r);let t=Oe.crossSiteProxy(e);if(t&&!r.proxyUsed)return this.redirectToProxy(t,r)}var i;return t instanceof Error?i="Fetch error: "+t.message:(i=t.statusText,t.responseText&&(i+=` ${t.responseText}`)),this.failFetch(r,i,t.status||998,t)}addType(t,e,r,i){let n=e;if(i){var s=r.any(n,this.ns.link("requestedURI"));s&&s.value!==i&&r.add(r.rdfFactory.namedNode(i),this.ns.rdf("type"),t,this.appNode)}for(;;){const e=r.any(n,this.ns.link("requestedURI"));if(e&&e.value&&r.add(r.rdfFactory.namedNode(e.value),this.ns.rdf("type"),t,this.appNode),n=r.any(void 0,r.rdfFactory.namedNode("http://www.w3.org/2007/ont/link#redirectedRequest"),n),!n)break;var a=r.any(n,r.rdfFactory.namedNode("http://www.w3.org/2007/ont/link#response"));if(!a)break;var o=r.any(a,r.rdfFactory.namedNode("http://www.w3.org/2007/ont/http#status"));if(!o)break;if("301"!==o&&"302"!==o)break}}handleResponse(t,e,r){const i=this.store,n=t.headers,s=r.req,a=this.saveResponseMetadata(t,r),o=this.normalizedContentType(r,n)||"";let h=n.get("content-location");if(0===t.status)return this.handleError(t,e,r);if(t.status>=400)return 404===t.status&&(this.nonexistent[r.original.value]=!0,this.nonexistent[e]=!0),this.saveErrorResponse(t,a).then((()=>{let e=r.resource+" "+t.statusText;return this.failFetch(r,e,t.status,t)}));var l=null,u=null;if(h&&(u=b.join(h,e))!==e&&(l=u),200===t.status){if(this.addType(this.ns.link("Document"),s,i,e),l&&this.addType(this.ns.link("Document"),s,i,l),r.clearPreviousData){const t=i.statementsMatching(void 0,void 0,void 0,r.resource).slice();for(let e=0;e<t.length;e++)i.removeStatement(t[e])}let t=o.includes("image/")||o.includes("application/pdf");o&&t&&(this.addType(i.rdfFactory.namedNode("http://purl.org/dc/terms/Image"),s,i,e),l&&this.addType(i.rdfFactory.namedNode("http://purl.org/dc/terms/Image"),s,i,l))}if(h){if(!r.force&&l&&"done"===this.requested[u])return this.doneFetch(r,t);this.requested[u]=!0}this.parseLinkHeader(n.get("link"),r.original,s);let c=this.handlerForContentType(o,t);return c?t.text().then((e=>(t.responseText=e,c.parse(this,e,r,t)))):(this.addStatus(s,"Fetch over. No data handled."),this.doneFetch(r,t))}saveErrorResponse(t,e){let r=this.store;return t.text().then((t=>{t.length>10&&r.add(e,this.ns.http("content"),r.rdfFactory.literal(t),e)}))}handlerForContentType(t,e){if(!t)return null;let r=this.handlers.find((e=>t.match(e.pattern)));return r?new r(e):null}guessContentType(t){return ye[t.split(".").pop()]}normalizedContentType(t,e){if(t.forceContentType)return t.forceContentType;let r=e.get("content-type");if(!r||r.includes("application/octet-stream")){let e=this.guessContentType(t.resource.value);if(e)return e}let i=b.protocol(t.resource.value);return!r&&["file","chrome"].includes(i)?"text/xml":r}redirectToProxy(t,e){this.addStatus(e.req,"BLOCKED -> Cross-site Proxy to <"+t+">"),e.proxyUsed=!0;const r=this.store,i=e.req;e.noMeta||(r.add(i,this.ns.link("redirectedTo"),r.rdfFactory.namedNode(t),i),this.addStatus(i,"redirected to new request")),this.requested[e.resource.value]="redirected",this.redirectedTo[e.resource.value]=t;let n=Object.assign({},e);return n.baseURI=e.resource.value,this.fetchUri(t,n).then((t=>(n.noMeta||r.add(i,this.ns.link("redirectedRequest"),n.req,this.appNode),t)))}setRequestTimeout(t,e){return new Promise((r=>{this.timeouts[t]=(this.timeouts[t]||[]).concat(setTimeout((()=>{!this.isPending(t)||e.retriedWithNoCredentials||e.proxyUsed||r(this.failFetch(e,`Request to ${t} timed out`,"timeout"))}),this.timeout))}))}addFetchCallback(t,e){this.fetchCallbacks[t]?this.fetchCallbacks[t].push(e):this.fetchCallbacks[t]=[e]}acceptString(){let t="";for(let e in this.mediatypes){""!==t&&(t+=", "),t+=e;for(let r in this.mediatypes[e])t+=";"+r+"="+this.mediatypes[e][r]}return t}}(0,t.A)(Oe,"HANDLERS",void 0),(0,t.A)(Oe,"CONTENT_TYPE_BY_EXT",void 0),(0,t.A)(Oe,"crossSiteProxyTemplate",void 0),Oe.HANDLERS=Ie,Oe.CONTENT_TYPE_BY_EXT=ye;const je={parseJSON:function(t,e,r){var i,n,s,a={},o=r.sym(e);for(var h in t){0===h.indexOf("_:")?a[h]?i=a[h]:(i=r.bnode(h),a[h]=i):i=r.sym(h);var l=t[h];for(var u in l){var c=l[u];for(var f in n=r.sym(u),c){var d=c[f];if("uri"===d.type)s=r.sym(d.value),r.add(i,n,s,o);else if("BlankNode"===d.type)a[d.value]?s=a[d.value]:(s=r.bnode(d.value),a[d.value]=s),r.add(i,n,s,o);else{if("Literal"!==d.type)throw new Error("error: unexpected termtype: "+f.type);s=d.datatype?r.literal(d.value,void 0,r.sym(d.datatype)):d.lang?r.literal(d.value,d.lang):r.literal(d.value),r.add(i,n,s,o)}}}}}};function Se(t){var e=0;function r(t){var e="",r=t.statements;for(var i in r)N.A.debug("Found statement: "+r),e+=a()+r[i]+"\n";return e}function i(t){var e="";for(var r in t.constraints){var i=t.constraints[r];e+=a()+"FILTER ( "+i.describe(r)+" ) \n"}return e}function n(t){for(var s="",o=0;o<t.optional.length;o++)N.A.debug("Found optional query"),s+=a()+"OPTIONAL { \n",e++,s+=r(t.optional[o]),s+=i(t.optional[o]),s+=n(t.optional[o]),e--,s+=a()+"}\n";return s}function s(t){var s=a()+"WHERE \n{ \n";return e++,s+=r(t),s+=i(t),s+=n(t),e--,s+"}"}function a(){for(var t="",r=0;r<e;r++)t+=" ";return t}return function(t){return function(t){for(var e=a()+"SELECT ",r=0;r<t.vars.length;r++)e+=t.vars[r]+" ";return e+"\n"}(t)+s(t.pat)}(t)}function Fe(t,e,r){var i=[];function n(t){if(i[t])return i[t];var e=r.variable(t);return i[t]=e,e}function s(t){return"string"==typeof t&&t.match(/[^ \n\t]/)}function a(t){return"string"==typeof t&&t.match(/^[\?\$]/)}function o(t){return"string"==typeof t?t.replace(/^</,"<").replace(/>$/,">"):t}function h(t){return"string"==typeof t&&t.match(/^<[^>]*>$/)}function l(t){return"string"==typeof t&&(t.match(/^_:/)||t.match(/^$/))}function u(t){return"string"==typeof t&&t.match(/:$/)}function c(t){return"string"==typeof t&&t.match(/^:|^[^_][^:]*:/)}function f(t){return t.split(":")[0]}function d(t){return t.split(":")[1]}function p(t){return h(t)?t.slice(1,t.length-1):t}function g(t){var e=-1===t.indexOf("'")?null:t.indexOf("'"),i=-1===t.indexOf('"')?null:t.indexOf('"');if(!e&&!i){var n=new Array(1);return n[0]=t,n}var s,a,o=new Array(2);if(!e||i&&i<e)s='"',a=i;else{if(i&&!(e&&e<i))return N.A.error("SQARQL QUERY OOPS!"),o;s="'",a=e}o[0]=t.slice(0,a);var h,l=t.slice(a+1).indexOf(s);return-1===l?(N.A.error("SPARQL parsing error: no matching parentheses in literal "+t),t):(t.slice(l+a+2).match(/^\^\^/)?(h=t.slice(l+a+2).indexOf(" "),o[1]=r.literal(t.slice(a+1,a+1+l),r.sym(p(t.slice(a+4+l,a+2+l+h)))),o=o.concat(g(t.slice(l+a+3+h)))):t.slice(l+a+2).match(/^@/)?(h=t.slice(l+a+2).indexOf(" "),o[1]=r.literal(t.slice(a+1,a+1+l),t.slice(a+3+l,a+2+l+h),null),o=o.concat(g(t.slice(l+a+2+h)))):(o[1]=r.literal(t.slice(a+1,a+1+l)),N.A.info("Literal found: "+o[1]),o=o.concat(g(t.slice(l+a+2)))),o)}function m(t){t=t.replace(/\(/g," ( ").replace(/\)/g," ) ").replace(/</g," <").replace(/>/g,"> ").replace(/{/g," { ").replace(/}/g," } ").replace(/[\t\n\r]/g," ").replace(/; /g," ; ").replace(/\. /g," . ").replace(/, /g," , "),N.A.info("New str into spaceDelimit: \n"+t);var e=[],r=t.split(" ");for(var i in r)s(r[i])&&(e=e.concat(r[i]));return e}function w(t,e){for(var r=0;r<e.length;r++)if("string"==typeof e[r]&&e[r].toLowerCase()===t.toLowerCase())return r;return null}function y(t,e){for(var r=[],i=0;i<e.length;i++)"string"==typeof e[i]&&e[i].toLowerCase()===t.toLowerCase()&&r.push(i);return r}function b(t,e,r){N.A.info("Looking for a close bracket of type "+r+" in "+t);for(var i=0,n=0;n<t.length;n++)if(t[n]===e&&i++,t[n]===r&&i--,i<0)return n;return N.A.error("Statement had no close parenthesis in SPARQL query"),0}function v(t){return this.describe=function(e){return e+" = "+t.toNT()},this.test=function(e){return t.equals(e)},this}function _(t){this.describe=function(e){return"REGEXP( '"+t+"' , "+e+" )"},this.test=function(e){var r=new RegExp(t);return!!e.value&&r.test(e.value)}}function x(t,e){3!==t.length||"Variable"!==t[0].termType||"NamedNode"!==t[2].termType&&"Literal"!==t[2].termType?6===t.length&&"string"==typeof t[0]&&"regexp"===t[0].toLowerCase()&&"("===t[1]&&")"===t[5]&&","===t[3]&&"Variable"===t[4].termType&&"Literal"===t[2].termType&&(N.A.debug("Constraint added: "+t),e.constraints[t[4]]=new _(t[2].value)):"="===t[1]||">"===t[1]||"<"===t[1]?(N.A.debug("Constraint added: "+t),e.constraints[t[0]]=new v(t[2])):N.A.warn("I don't know how to handle the constraint: "+t)}function T(t,e){N.A.debug("Optional query: "+t+" not yet implemented.");var i=r.formula();A(t,i),e.optional.push(i)}function A(t,e){var i,s,u=function(t){for(var e=[],i=0;i<t.length;i++)"string"==typeof t[i]?(t[i]=o(t[i]),a(t[i])?e[i]=n(t[i].slice(1)):l(t[i])?(N.A.info(t[i]+" was identified as a bnode."),e[i]=r.bnode()):h(t[i])?(N.A.info(t[i]+" was identified as a symbol."),e[i]=r.sym(p(t[i]))):c(t[i])?(N.A.info(t[i]+" was identified as a prefixed symbol"),k[f(t[i])]?e[i]=r.sym(t[i]=k[f(t[i])]+d(t[i])):(N.A.error("SPARQL error: "+t[i]+" with prefix "+f(t[i])+" does not have a correct prefix entry."),e[i]=t[i])):e[i]=t[i]):e[i]=t[i];return e}(t);for(N.A.debug("WHERE: "+u);w("OPTIONAL",u);)s=w("OPTIONAL",u),N.A.debug("OPT: "+s+" "+u[s]+" in "+u),"{"!==u[s+1]&&N.A.warn("Bad optional opening bracket in word "+s),-1===(i=b(u.slice(s+2),"{","}"))?N.A.error("No matching bracket in word "+s):(T(u.slice(s+2,s+2+i),e),s=w("OPTIONAL",u),i=b(u.slice(s+2),"{","}"),u.splice(s,i+3));for(N.A.debug("WHERE after optionals: "+u);w("FILTER",u);){var g=w("FILTER",u);"("!==u[g+1]&&N.A.warn("Bad filter opening bracket in word "+g),-1===(i=b(u.slice(g+2),"(",")"))?N.A.error("No matching bracket in word "+g):(x(u.slice(g+2,g+2+i),e),g=w("FILTER",u),i=b(u.slice(g+2),"(",")"),u.splice(g,i+3))}N.A.debug("WHERE after filters and optionals: "+u),function(t,e){var r=new Array(1);r[0]=-1;for(var i=r.concat(y(".",t)),n=[],s=0;s<i.length-1;s++)n[s]=t.slice(i[s]+1,i[s+1]);for(s in n){N.A.info("s+p+o "+s+" = "+n[s]);var a=n[s][0];n[s].splice(0,1);var o=r.concat(y(";",n[s]));o.push(n[s].length);for(var h=[],l=0;l<o.length-1;l++)h[l]=n[s].slice(o[l]+1,o[l+1]);for(s in h){N.A.info("p+o "+s+" = "+n[s]);var u=h[s][0];h[s].splice(0,1);var c=r.concat(y(",",h[s]));c.push(h[s].length);var f=[];for(l=0;l<c.length-1;l++)f[l]=h[s].slice(c[l]+1,c[l+1]);for(s in f){var d=f[s][0];N.A.info("Subj="+a+" Pred="+u+" Obj="+d),e.add(a,u,d)}}}}(u,e)}N.A.info("SPARQL input: \n"+t);var E=new $,R=function(t){var e=g(t),r=[];for(var i in e)r="string"==typeof e[i]?r.concat(m(e[i])):r.concat(e[i]);return r=function(t){for(var e=t,r=0;r<e.length;r++)if("a"===e[r]&&(e[r]="<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>"),"is"===e[r]&&"of"===e[r+2]){e.splice(r,1),e.splice(r+1,1);var i=e[r-1];e[r-1]=e[r+1],e[r+1]=i}return e}(r),N.A.info("SPARQL Tokens: "+r),r}(t),k=function(t){var e=y("PREFIX",t),r=[];for(var i in e){var n=t[e[i]+1],s=t[e[i]+2];if(u(n))if(h(s)){N.A.info("Prefix found: "+n+" -> "+s);var a=f(n),o=p(s);r[a]=o}else N.A.error("Invalid SPARQL symbol: "+s);else N.A.error("Invalid SPARQL prefix: "+n)}return r}(R);k.rdf||(k.rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"),k.rdfs||(k.rdfs="http://www.w3.org/2000/01/rdf-schema#");var I=w("SELECT",R),C=w("WHERE",R);if(I<0||C<0||I>C)return N.A.error("Invalid or nonexistent SELECT and WHERE tags in SPARQL query"),!1;if(function(t,e){for(var r in N.A.info("SPARQL vars: "+t),t)if(a(t[r])){N.A.info("Added "+t[r]+" to query variables from SPARQL");var i=n(t[r].slice(1));e.vars.push(i),i.label=t[r].slice(1)}else N.A.warn("Incorrect SPARQL variable in SELECT: "+t[r])}(R.slice(I+1,C),E),A(R.slice(C+2,R.length-1),E.pat),e)return E;for(var O in E.pat.statements){var j=E.pat.statements[O];"NamedNode"===j.subject.termType&&r.fetcher&&r.fetcher.lookUpThing(j.subject,"sparql:"+j.subject),"NamedNode"===j.object.termType&&r.fetcher&&r.fetcher.lookUpThing(j.object,"sparql:"+j.object)}return E}class Ue{constructor(e){if((0,t.A)(this,"store",void 0),(0,t.A)(this,"ifps",void 0),(0,t.A)(this,"fps",void 0),(0,t.A)(this,"patchControl",void 0),(0,t.A)(this,"ns",void 0),(e=e||new G).updater)throw new Error("You can't have two UpdateManagers for the same store");e.fetcher||(e.fetcher=new Oe(e)),this.store=e,e.updater=this,this.ifps={},this.fps={},this.ns={},this.ns.link=E("http://www.w3.org/2007/ont/link#"),this.ns.http=E("http://www.w3.org/2007/ont/http#"),this.ns.httph=E("http://www.w3.org/2007/ont/httph#"),this.ns.ldp=E("http://www.w3.org/ns/ldp#"),this.ns.rdf=E("http://www.w3.org/1999/02/22-rdf-syntax-ns#"),this.ns.rdfs=E("http://www.w3.org/2000/01/rdf-schema#"),this.ns.rdf=E("http://www.w3.org/1999/02/22-rdf-syntax-ns#"),this.ns.owl=E("http://www.w3.org/2002/07/owl#"),this.patchControl=[]}patchControlFor(t){return this.patchControl[t.value]||(this.patchControl[t.value]=[]),this.patchControl[t.value]}isHttpUri(t){return"http"===t.slice(0,4)}flagAuthorizationMetadata(t){t||(t=this.store);const e=t.fetcher?.appNode,r=t.statementsMatching(void 0,this.ns.link("requestedURI"),void 0,e).map((t=>t.subject));for(const i of r){const r=t.any(i,this.ns.link("response"),null,e);null!=r&&t.add(r,this.ns.link("outOfDate"),!0,e)}}async checkEditable(t,e){if(!t)return!1;e||(e=this.store);const r=this.editable(t,e);return void 0!==r?r:(await(e.fetcher?.load(t)),this.editable(t,e))}editable(t,e){if(!t)return!1;if(e||(e=this.store),t=(0,me.E)(t),!this.isHttpUri(t)&&e.holds(e.rdfFactory.namedNode(t),e.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),e.rdfFactory.namedNode("http://www.w3.org/2007/ont/link#MachineEditableDocument")))return"LOCALFILE";var r,i=!1;const n=e.fetcher?.appNode;for(var s,a=e.each(void 0,this.ns.link("requestedURI"),(0,b.docpart)(t),n),o=0;o<a.length;o++)if(void 0!==(r=a[o])){const a=e.any(r,this.ns.link("response"),null,n);if(void 0!==a){if(e.anyJS(a,this.ns.link("outOfDate"),null,n))continue;var h=e.anyValue(a,this.ns.httph("wac-allow"));if(h)for(var l of h.split(",")){var u=l.split("=");if(u[0].includes("user")&&!u[1].includes("write")&&!u[1].includes("append"))return!1}var c=e.each(a,this.ns.httph("accept-patch"));if(c.length)for(let t=0;t<c.length;t++){if((s=c[t].value.trim()).indexOf("application/sparql-update")>=0)return"SPARQL";if(s.indexOf("application/sparql-update-single-match")>=0)return"SPARQL";if(s.indexOf("text/n3")>=0)return"N3PATCH"}var f=e.each(a,this.ns.httph("ms-author-via"));if(f.length)for(let t=0;t<f.length;t++){if((s=f[t].value.trim()).indexOf("SPARQL")>=0)return"SPARQL";if(s.indexOf("DAV")>=0)return"DAV"}if(!this.isHttpUri(t))return!!h&&"LOCALFILE";var d=e.each(a,this.ns.http("status"));if(d.length)for(let t=0;t<d.length;t++)200!==d[t]&&404!==d[t]||(i=!0)}}if(0===a.length);else if(i)return!1}anonymize(t){return"_:"===t.toNT().substr(0,2)&&this.mentioned(t)?"?"+t.toNT().substr(2):t.toNT()}anonymizeNT(t){return this.anonymize(t.subject)+" "+this.anonymize(t.predicate)+" "+this.anonymize(t.object)+" ."}nTriples(t){return`${t.subject.toNT()} ${t.predicate.toNT()} ${t.object.toNT()} .`}statementBnodes(t){return[t.subject,t.predicate,t.object].filter((function(t){return(0,a.jt)(t)}))}statementArrayBnodes(t){var e=[];for(let r=0;r<t.length;r++)e=e.concat(this.statementBnodes(t[r]));e.sort();var r=[];for(let t=0;t<e.length;t++)0!==t&&e[t].equals(e[t-1])||r.push(e[t]);return r}cacheIfps(){this.ifps={};var t=this.store.each(void 0,this.ns.rdf("type"),this.ns.owl("InverseFunctionalProperty"));for(let e=0;e<t.length;e++)this.ifps[t[e].value]=!0;this.fps={},t=this.store.each(void 0,this.ns.rdf("type"),this.ns.owl("FunctionalProperty"));for(let e=0;e<t.length;e++)this.fps[t[e].value]=!0}bnodeContext2(t,e,r){var i,n,s=this.store.statementsMatching(void 0,void 0,t,e);for(let t=0;t<s.length;t++)if(this.fps[s[t].predicate.value]){if(!(i=s[t].subject).isBlank)return[s[t]];if(r&&(n=this.bnodeContext2(i,e,r-1)))return n.concat([s[t]])}s=this.store.statementsMatching(t,void 0,void 0,e);for(let t=0;t<s.length;t++)if(this.ifps[s[t].predicate.value]){if(!(i=s[t].object).isBlank)return[s[t]];if(r&&(n=this.bnodeContext2(i,e,r-1)))return n.concat([s[t]])}return null}bnodeContext1(t,e){for(var r=0;r<3;r++){var i=this.bnodeContext2(t,e,r);if(null!==i)return i}return this.store.connectedStatements(t,e)}mentioned(t){return 0!==this.store.statementsMatching(t,null,null,null).length||0!==this.store.statementsMatching(null,t).length||0!==this.store.statementsMatching(null,null,t).length}bnodeContext(t,e){var r=[];if(t.length){this.cacheIfps();for(let n=0;n<t.length;n++){var i=t[n];this.mentioned(i)&&(r=r.concat(this.bnodeContext1(i,e)))}}return r}statementContext(t){var e=this.statementBnodes(t);return this.bnodeContext(e,t.graph)}contextWhere(t){var e=this;return t&&0!==t.length?"WHERE { "+t.map((function(t){return e.anonymizeNT(t)})).join("\n")+" }\n":""}fire(t,e,r,i={}){return Promise.resolve().then((()=>{if(!t)throw new Error("No URI given for remote editing operation: "+e);return i.noMeta=!0,i.contentType=i.contentType||"application/sparql-update",i.body=e,this.store.fetcher.webOperation("PATCH",t,i)})).then((i=>{if(!i.ok){let r="UpdateManager: update failed for <"+t+"> status="+i.status+", "+i.statusText+"\n for query: "+e;throw new Error(r)}r(t,i.ok,i.responseText,i)})).catch((e=>{r(t,!1,e.message,e)}))}update_statement(t){if(!t||t.graph){var e=this,r=this.statementContext(t);return{statement:t?[t.subject,t.predicate,t.object,t.graph]:void 0,statementNT:t?this.anonymizeNT(t):void 0,where:e.contextWhere(r),set_object:function(t,r){var i=this.where;i+="DELETE DATA { "+this.statementNT+" } ;\n",i+="INSERT DATA { "+this.anonymize(this.statement[0])+" "+this.anonymize(this.statement[1])+" "+this.anonymize(t)+" . }\n",e.fire(this.statement[3].value,i,r)}}}}insert_statement(t,e){var r=t instanceof Array?t[0]:t,i=this.contextWhere(this.statementContext(r));if(t instanceof Array){var n="";for(let e=0;e<t.length;e++)n+=t[e]+"\n";i+="INSERT DATA { "+n+" }\n"}else i+="INSERT DATA { "+this.anonymize(t.subject)+" "+this.anonymize(t.predicate)+" "+this.anonymize(t.object)+" . }\n";this.fire(r.graph.value,i,e)}delete_statement(t,e){var r=t instanceof Array?t[0]:t,i=this.contextWhere(this.statementContext(r));if(t instanceof Array){var n="";for(let e=0;e<t.length;e++)n+=t[e]+"\n";i+="DELETE DATA { "+n+" }\n"}else i+="DELETE DATA { "+this.anonymize(t.subject)+" "+this.anonymize(t.predicate)+" "+this.anonymize(t.object)+" . }\n";this.fire(r.graph.value,i,e)}requestDownstreamAction(t,e){var r=this.patchControlFor(t);if(r.pendingUpstream)if(r.downstreamAction){if(""+r.downstreamAction!=""+e)throw new Error("Can't wait for > 1 different downstream actions")}else r.downstreamAction=e;else e(t)}clearUpstreamCount(t){this.patchControlFor(t).upstreamCount=0}getUpdatesVia(t){var e=this.store.fetcher.getHeader(t,"updates-via");return e&&e.length?e[0].trim():null}addDownstreamChangeListener(t,e){var r=this.patchControlFor(t);r.downstreamChangeListeners||(r.downstreamChangeListeners=[]),r.downstreamChangeListeners.push(e),this.setRefreshHandler(t,(t=>{this.reloadAndSync(t)}))}reloadAndSync(t){var e=this.patchControlFor(t),r=this;if(e.reloading)e.outOfDate=!0;else{e.reloading=!0;var i=1e3,n=function(){r.reload(r.store,t,(function(t,r,s){if(t){if(e.downstreamChangeListeners)for(let t=0;t<e.downstreamChangeListeners.length;t++)e.downstreamChangeListeners[t]();e.reloading=!1,e.outOfDate&&(e.outOfDate=!1,n())}else e.reloading=!1,s&&0===s.status&&(e.reloading=!0,setTimeout(n,i*=2))}))};n()}}setRefreshHandler(t,e){let r=this.getUpdatesVia(t);var i=e,n=this,s=this,a=1500,o=0;if(!r)return!1;r=(0,b.join)(r,t.value);const h=r.replace(/^http:/,"ws:").replace(/^https:/,"wss:");var l=function(){var e;if("undefined"!=typeof WebSocket)e=new WebSocket(h);else{if("undefined"==typeof window||!window.WebSocket)return;e=window.WebSocket(h)}e.onopen=function(){a=1500,this.send("sub "+t.value),o&&s.requestDownstreamAction(t,i)};var r=n.patchControlFor(t);r.upstreamCount=0,e.onerror=function(t){},e.onclose=function(t){a*=2,o+=1,setTimeout((function(){l()}),a)},e.onmessage=function(e){if(e.data&&"pub"===e.data.slice(0,3)){if("upstreamCount"in r&&(r.upstreamCount-=1,r.upstreamCount>=0))return;r.upstreamCount=0,n.requestDownstreamAction(t,i)}}};return l(),!0}updateMany(t,e=[]){const r=t.concat(e).map((t=>t.why)),i=this,n=[];r.forEach((t=>{n.find((e=>e.equals(t)))||n.push(t)}));const s=n.map((r=>i.update(t.filter((t=>t.why.equals(r))),e.filter((t=>t.why.equals(r))))));return s.length,Promise.all(s)}constructSparqlUpdateQuery(t,e,r){var i=this.contextWhere(r),n="";if(i.length){if(t.length){n+="DELETE { ";for(let e=0;e<t.length;e++)n+=this.anonymizeNT(t[e])+"\n";n+=" }\n"}if(e.length){n+="INSERT { ";for(let t=0;t<e.length;t++)n+=this.anonymizeNT(e[t])+"\n";n+=" }\n"}n+=i}else{if(t.length){n+="DELETE DATA { ";for(let e=0;e<t.length;e++)n+=this.anonymizeNT(t[e])+"\n";n+=" } \n"}if(e.length){t.length&&(n+=" ; "),n+="INSERT DATA { ";for(let t=0;t<e.length;t++)n+=this.nTriples(e[t])+"\n";n+=" }\n"}}return n}constructN3PatchQuery(t,e,r){var i="\n@prefix solid: <http://www.w3.org/ns/solid/terms#>.\n@prefix ex: <http://www.example.org/terms#>.\n\n_:patch\n";return r&&r.length>0&&(i+=`\n solid:where {\n ${r.map((t=>this.anonymizeNT(t))).join("\n ")}\n };`),t.length>0&&(i+=`\n solid:deletes {\n ${t.map((t=>this.anonymizeNT(t))).join("\n ")}\n };`),e.length>0&&(i+=`\n solid:inserts {\n ${e.map((t=>this.anonymizeNT(t))).join("\n ")}\n };`),i+" a solid:InsertDeletePatch .\n"}update(t,e,r,i,n={}){if(!r){var s=this;return new Promise((function(r,a){s.update(t,e,(function(t,e,i){e?r():a(new Error(i))}),i,n)}))}try{var o=this.store,h=t?(0,a.ok)(t)?t.statements:t instanceof Array?t:[t]:[],l=e?(0,a.ok)(e)?e.statements:e instanceof Array?e:[e]:[];if(!(h instanceof Array))throw new Error("Type Error "+typeof h+": "+h);if(!(l instanceof Array))throw new Error("Type Error "+typeof l+": "+l);if(0===h.length&&0===l.length)return r(null,!0);var u=h.length?h[0].graph:l[0].graph;if(!u){let t="Error patching: statement does not specify which document to patch:"+h[0]+", "+l[0];throw new Error(t)}if("NamedNode"!==u.termType){let t="Error patching: document not a NamedNode:"+h[0]+", "+l[0];throw new Error(t)}var c=this.patchControlFor(u),f=Date.now(),d=["subject","predicate","object","why"],p={delete:h,insert:l};["insert","delete"].map((function(t){p[t].map((function(t){if(!u.equals(t.graph))throw new Error("update: destination "+u+" inconsistent with delete quad "+t.graph);d.map((function(e){if(void 0===t[e])throw new Error("update: undefined "+e+" of statement.")}))}))}));var g=this.editable(u.value,o);if(!1===g)throw new Error("Update: Can't make changes in uneditable "+u);if(void 0===g){if(i)throw new Error("Update: Loaded "+u+"but still can't figure out what editing protocol it supports.");return void this.store.fetcher.load(u).then((i=>{this.update(t,e,r,!0,n)}),(i=>{if(404!==i.response.status)throw new Error(`Update: Can't get updatability status ${u} before patching: ${i}`);this.update(t,e,r,!0,n)}))}if(g.indexOf("SPARQL")>=0||g.indexOf("N3PATCH")>=0){var m=g.indexOf("SPARQL")>=0,w=[];h.length&&(w=this.statementArrayBnodes(h)),l.length&&(w=w.concat(this.statementArrayBnodes(l)));var y=this.bnodeContext(w,u),b=m?this.constructSparqlUpdateQuery(h,l,y):this.constructN3PatchQuery(h,l,y);n.contentType=m?"application/sparql-update":"text/n3",c.pendingUpstream=c.pendingUpstream?c.pendingUpstream+1:1,"upstreamCount"in c&&(c.upstreamCount+=1),this.fire(u.value,b,((t,e,i,n)=>{if(n.elapsedTimeMs=Date.now()-f,e){try{o.remove(h)}catch(t){e=!1,i="Remote Ok BUT error deleting "+h.length+" from store!!! "+t}for(let t=0;t<l.length;t++)o.add(l[t].subject,l[t].predicate,l[t].object,u)}if(r(t,e,i,n),c.pendingUpstream-=1,0===c.pendingUpstream&&c.downstreamAction){var s=c.downstreamAction;delete c.downstreamAction,s(u)}}),n)}else if(g.indexOf("DAV")>=0)this.updateDav(u,h,l,r,n);else{if(!(g.indexOf("LOCALFILE")>=0))throw new Error("Unhandled edit method: '"+g+"' for "+u);try{this.updateLocalFile(u,h,l,r,n)}catch(t){r(u.value,!1,"Exception trying to write back file <"+u.value+">\n")}}}catch(t){r(void 0,!1,"Exception in update: "+t+"\n"+C.stackString(t))}}updateDav(t,e,r,i,n={}){let s=this.store;var a=s.any(t,this.ns.link("request"));if(!a)throw new Error("No record of our HTTP GET request for document: "+t);var o=s.any(a,this.ns.link("response"));if(!o)return null;var h=s.the(o,this.ns.httph("content-type")).value;let l=s.statementsMatching(void 0,void 0,void 0,t).slice();for(let t=0;t<e.length;t++)C.RDFArrayRemove(l,e[t]);for(let t=0;t<r.length;t++)l.push(r[t]);const u=this.serialize(t.value,l,h);var c,f=s.the(o,this.ns.httph("content-location"));return f&&(c=(0,b.join)(f.value,c)),n.contentType=h,n.noMeta=!0,n.body=u,s.fetcher.webOperation("PUT",c,n).then((n=>{if(!n.ok)throw new Error(n.error);for(let t=0;t<e.length;t++)s.remove(e[t]);for(let e=0;e<r.length;e++)s.add(r[e].subject,r[e].predicate,r[e].object,t);i(t.value,n.ok,n.responseText,n)})).catch((e=>{i(t.value,!1,e.message,e)}))}updateLocalFile(t,e,r,i,n={}){const s=this.store;let a=s.statementsMatching(void 0,void 0,void 0,t).slice();for(let t=0;t<e.length;t++)C.RDFArrayRemove(a,e[t]);for(let t=0;t<r.length;t++)a.push(r[t]);var o=t.value.lastIndexOf(".");if(o<1)throw new Error("Rewriting file: No filename extension: "+t.value);var h=t.value.slice(o+1);let l=Oe.CONTENT_TYPE_BY_EXT[h];if(!l)throw new Error("File extension ."+h+" not supported for data write");n.body=this.serialize(t.value,a,l),n.contentType=l,s.fetcher.webOperation("PUT",t.value,n).then((n=>{if(!n.ok)return i(t.value,!1,n.error);for(let t=0;t<e.length;t++)s.remove(e[t]);for(let e=0;e<r.length;e++)s.add(r[e].subject,r[e].predicate,r[e].object,t);i(t.value,!0,"")}))}serialize(t,e,r){const i=this.store;let n;if("string"==typeof e)return e;var s=j(i);switch(s.suggestNamespaces(i.namespaces),s.setBase(t),r){case"text/xml":case"application/rdf+xml":n=s.statementsToXML(e);break;case"text/n3":case"text/turtle":case"application/x-turtle":case"application/n3":n=s.statementsToN3(e);break;default:throw new Error("Content-type "+r+" not supported for data serialization")}return n}put(t,e,r,i){const n=this.store;let s;return Promise.resolve().then((()=>(s=this.serialize(t.value,e,r),n.fetcher.webOperation("PUT",t.value,{contentType:r,body:s})))).then((r=>{if(!r.ok)return i(t.value,r.ok,r.error,r);delete n.fetcher.nonexistent[t.value],delete n.fetcher.requested[t.value],"string"!=typeof e&&e.map((t=>{n.addStatement(t)})),i(t.value,r.ok,"",r)})).catch((e=>{i(t.value,!1,e.message)}))}reload(t,e,r){var i=Date.now();t.fetcher.nowOrWhenFetched(e.value,{force:!0,noMeta:!0,clearPreviousData:!0},(function(t,n,s){if(t)if(s.onErrorWasCalled||200!==s.status)r(!1,"Non-HTTP error reloading data: "+n,s);else{var a=Date.now()-i;e.reloadTimeTotal||(e.reloadTimeTotal=0),e.reloadTimeCount||(e.reloadTimeCount=0),e.reloadTimeTotal+=a,e.reloadTimeCount+=1,r(!0)}else r(!1,"Error reloading data: "+n,s)}))}}const De={...xt,fetcher:(t,e)=>new Oe(t,e),graph:(t=void 0,e=void 0)=>new G(t,e||{rdfFactory:xt}),lit(t,e,r){return this.literal(""+t,e||r)},st(t,e,r,i){return this.quad(t,e,r,i)}},Le=De;class Me{constructor(t,e){this.parent=t,this.via=e,this.connected=!1,this.pending={},this.subscribed={},this.socket={};try{this.socket=new WebSocket(e),this.socket.onopen=this.onOpen,this.socket.onclose=this.onClose,this.socket.onmessage=this.onMessage,this.socket.onerror=this.onError}catch(t){this.onError(t)}}_decode(t){var e,r,i,n,s,a,o;for(r in n={},s=function(){var r,i,n,s;for(s=[],r=0,i=(n=t.split("&")).length;r<i;r++)e=n[r],s.push(e.split("="));return s}())e=s[r],o=(a=[decodeURIComponent(e[0]),decodeURIComponent(e[1])])[1],null==n[i=a[0]]&&(n[i]=[]),n[i].push(o);return n}_send(t,e,r){var i,n;return n=[t,e,r].join(" "),"function"==typeof(i=this.socket).send?i.send(n):void 0}_subscribe(t){return this._send("sub",t,""),this.subscribed[t]=!0,this.subscribed[t]}onClose(t){var e;for(e in this.connected=!1,this.subscribed)this.pending[e]=!0;return this.subscribed={},this.subscribed}onError(t){throw new Error("onError"+t)}onMessage(t){var e,r;return"ping"===(r=t.data.split(" "))[0]?"function"==typeof(e=this.socket).send?e.send("pong "+r.slice(1).join(" ")):void 0:"pub"===r[0]?this.parent.onUpdate(r[1],this._decode(r[2])):void 0}onOpen(t){var e,r;for(r in this.connected=!0,e=[],this.pending)delete this.pending[r],e.push(this._subscribe(r));return e}subscribe(t){return this.connected?this._subscribe(t):(this.pending[t]=!0,this.pending[t])}}class Pe{constructor(t){this.fetcher=t,this.graph={},this.via={},this.fetcher.addCallback("headers",this.onHeaders)}onHeaders(t){var e,r,i;return null==t.headers||"undefined"==typeof WebSocket||null===WebSocket||(e=t.headers.etag,i=t.headers["updates-via"],r=t.uri,e&&i&&(this.graph[r]={etag:e,via:i},this.register(i,r))),!0}onUpdate(t,e){return this.fetcher.refresh(Le.namedNode(t))}register(t,e){return null==this.via[t]&&(this.via[t]=new Me(this,t)),this.via[t].subscribe(e)}}const Be={};for(const t in Le)"function"==typeof Le[t]&&(Be[t]=Le[t].bind(Le));const{fetcher:qe,graph:$e,lit:He,st:Xe,namedNode:ze,variable:Qe,blankNode:Ve,defaultGraph:Ge,literal:We,quad:Ye,triple:Ze}=Be,Je=new P,Ke=t=>Je.fromNT(t),tr=B.fromValue,er=n.nextId;class rr extends G{constructor(e){super(e),(0,t.A)(this,"fetcher",void 0),this.fetcher=new Oe(this,{})}}class ir extends rr{constructor(e){super(e),(0,t.A)(this,"updater",void 0),this.updater=new Ue(this)}}})(),h})()));
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("window")):"function"==typeof define&&define.amd?define(["window"],e):"object"==typeof exports?exports.$rdf=e(require("window")):t.$rdf=e(t.window)}(self,(t=>(()=>{var e,r,i,n,s={362:(t,e,r)=>{"use strict";function i(t){return"string"==typeof t?t:t.value}r.d(e,{E:()=>i})},546:(t,e,r)=>{"use strict";r.d(e,{CZ:()=>h,D0:()=>c,DJ:()=>o,DZ:()=>u,GE:()=>y,P3:()=>a,RN:()=>b,SH:()=>n,Y2:()=>p,YC:()=>w,aF:()=>d,c$:()=>f,fY:()=>l,hr:()=>m,jt:()=>g,ok:()=>s});var i=r(6866);function n(t){return"object"==typeof t&&null!==t&&"subject"in t}function s(t){return"object"==typeof t&&null!==t&&"statements"in t}function a(t){return c(t)&&t.termType===i.r0}function o(t){return t&&Object.prototype.hasOwnProperty.call(t,"termType")&&(t.termType===i.Kk||t.termType===i.P2||t.termType===i.$Q||t.termType===i.r0||t.termType===i.QW||t.termType===i.bD)}function h(t){return t&&Object.prototype.hasOwnProperty.call(t,"termType")&&(t.termType===i.Kk||t.termType===i.P2||t.termType===i.$Q||t.termType===i.r0||t.termType===i.QW||t.termType===i.bD)}function l(t){return c(t)&&(t.termType===i.Kk||t.termType===i.$Q||t.termType===i.P2)}function u(t){return c(t)&&t.termType===i.P2}function c(t){return"object"==typeof t&&null!==t&&"termType"in t}function f(t){return t.termType===i.QW}function d(t){return"object"==typeof t&&null!==t&&"subject"in t&&"predicate"in t&&"object"in t}function p(t){return c(t)&&"NamedNode"===t.termType}function g(t){return c(t)&&"termType"in t&&"BlankNode"===t.termType}function m(t){return c(t)&&(t.termType===i.Kk||t.termType===i.P2||t.termType===i.$Q)}function w(t){return c(t)&&(t.termType===i.Kk||t.termType===i.P2)}function y(t){return c(t)&&(t.termType===i.Kk||t.termType===i.P2||t.termType===i.$Q||t.termType===i.QW)}function b(t){return c(t)&&(t.termType===i.Kk||t.termType===i.P2||t.termType===i.$Q||t.termType===i.ic)}},939:(t,e,r)=>{"use strict";function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function n(t,e,r){return(e=function(t){var e=function(t){if("object"!=i(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==i(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}r.d(e,{A:()=>n})},1147:(t,e,r)=>{var i="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==r.g&&r.g,n=function(){function t(){this.fetch=!1,this.DOMException=i.DOMException}return t.prototype=i,new t}();!function(t){!function(e){var i=void 0!==t&&t||"undefined"!=typeof self&&self||void 0!==r.g&&r.g||{},n="URLSearchParams"in i,s="Symbol"in i&&"iterator"in Symbol,a="FileReader"in i&&"Blob"in i&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in i,h="ArrayBuffer"in i;if(h)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&l.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function f(t){return"string"!=typeof t&&(t=String(t)),t}function d(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return s&&(e[Symbol.iterator]=function(){return e}),e}function p(t){this.map={},t instanceof p?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function g(t){if(!t._noBody)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function m(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function w(t){var e=new FileReader,r=m(e);return e.readAsArrayBuffer(t),r}function y(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){var e;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:a&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():h&&a&&(e=t)&&DataView.prototype.isPrototypeOf(e)?(this._bodyArrayBuffer=y(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):h&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=y(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a&&(this.blob=function(){var t=g(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer)return g(this)||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer));if(a)return this.blob().then(w);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,e,r,i,n,s=g(this);if(s)return s;if(this._bodyBlob)return t=this._bodyBlob,r=m(e=new FileReader),n=(i=/charset=([A-Za-z0-9_-]+)/.exec(t.type))?i[1]:"utf-8",e.readAsText(t,n),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),i=0;i<e.length;i++)r[i]=String.fromCharCode(e[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(x)}),this.json=function(){return this.text().then(JSON.parse)},this}p.prototype.append=function(t,e){t=c(t),e=f(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},p.prototype.delete=function(t){delete this.map[c(t)]},p.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},p.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},p.prototype.set=function(t,e){this.map[c(t)]=f(e)},p.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},p.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),d(t)},p.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),d(t)},p.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),d(t)},s&&(p.prototype[Symbol.iterator]=p.prototype.entries);var v=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function _(t,e){if(!(this instanceof _))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,n,s=(e=e||{}).body;if(t instanceof _){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new p(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,s||null==t._bodyInit||(s=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new p(e.headers)),this.method=(n=(r=e.method||this.method||"GET").toUpperCase(),v.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||function(){if("AbortController"in i)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(s),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==e.cache&&"no-cache"!==e.cache)){var a=/([?&])_=[^&]*/;a.test(this.url)?this.url=this.url.replace(a,"$1_="+(new Date).getTime()):this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}function x(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),i=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(n))}})),e}function T(t,e){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new p(e.headers),this.url=e.url||"",this._initBody(t)}_.prototype.clone=function(){return new _(this,{body:this._bodyInit})},b.call(_.prototype),b.call(T.prototype),T.prototype.clone=function(){return new T(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},T.error=function(){var t=new T(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var A=[301,302,303,307,308];T.redirect=function(t,e){if(-1===A.indexOf(e))throw new RangeError("Invalid status code");return new T(null,{status:e,headers:{location:t}})},e.DOMException=i.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function N(t,r){return new Promise((function(n,s){var o=new _(t,r);if(o.signal&&o.signal.aborted)return s(new e.DOMException("Aborted","AbortError"));var l=new XMLHttpRequest;function u(){l.abort()}if(l.onload=function(){var t,e,r={statusText:l.statusText,headers:(t=l.getAllResponseHeaders()||"",e=new p,t.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var r=t.split(":"),i=r.shift().trim();if(i){var n=r.join(":").trim();try{e.append(i,n)}catch(t){console.warn("Response "+t.message)}}})),e)};0===o.url.indexOf("file://")&&(l.status<200||l.status>599)?r.status=200:r.status=l.status,r.url="responseURL"in l?l.responseURL:r.headers.get("X-Request-URL");var i="response"in l?l.response:l.responseText;setTimeout((function(){n(new T(i,r))}),0)},l.onerror=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},l.ontimeout=function(){setTimeout((function(){s(new TypeError("Network request timed out"))}),0)},l.onabort=function(){setTimeout((function(){s(new e.DOMException("Aborted","AbortError"))}),0)},l.open(o.method,function(t){try{return""===t&&i.location.href?i.location.href:t}catch(e){return t}}(o.url),!0),"include"===o.credentials?l.withCredentials=!0:"omit"===o.credentials&&(l.withCredentials=!1),"responseType"in l&&(a?l.responseType="blob":h&&(l.responseType="arraybuffer")),r&&"object"==typeof r.headers&&!(r.headers instanceof p||i.Headers&&r.headers instanceof i.Headers)){var d=[];Object.getOwnPropertyNames(r.headers).forEach((function(t){d.push(c(t)),l.setRequestHeader(t,f(r.headers[t]))})),o.headers.forEach((function(t,e){-1===d.indexOf(e)&&l.setRequestHeader(e,t)}))}else o.headers.forEach((function(t,e){l.setRequestHeader(e,t)}));o.signal&&(o.signal.addEventListener("abort",u),l.onreadystatechange=function(){4===l.readyState&&o.signal.removeEventListener("abort",u)}),l.send(void 0===o._bodyInit?null:o._bodyInit)}))}N.polyfill=!0,i.fetch||(i.fetch=N,i.Headers=p,i.Request=_,i.Response=T),e.Headers=p,e.Request=_,e.Response=T,e.fetch=N}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var s=i.fetch?i:n;(e=s.fetch).default=s.fetch,e.fetch=s.fetch,e.Headers=s.Headers,e.Request=s.Request,e.Response=s.Response,t.exports=e},1605:(t,e,r)=>{"use strict";r.d(e,{A:()=>n});var i=r(939);class n{constructor(t){(0,i.A)(this,"termType",void 0),(0,i.A)(this,"classOrder",void 0),(0,i.A)(this,"value",void 0),this.value=t}substitute(t){return this}compareTerm(t){return this.classOrder<t.classOrder?-1:this.classOrder>t.classOrder?1:this.value<t.value?-1:this.value>t.value?1:0}equals(t){return!!t&&this.termType===t.termType&&this.value===t.value}hashString(){return this.toCanonical()}sameTerm(t){return this.equals(t)}toCanonical(){return this.toNT()}toNT(){return this.toString()}toNQ(){return this.toNT()}toString(){throw new Error("Node.toString() is abstract - see the subclasses instead")}}(0,i.A)(n,"fromValue",void 0),(0,i.A)(n,"toJS",void 0)},2312:function(t,e){var r,i;void 0===(i="function"==typeof(r=function(){"use strict";function t(e,r,i,n){this.message=e,this.expected=r,this.found=i,this.location=n,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}return function(t,e){function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r}(t,Error),t.buildMessage=function(t,e){var r={literal:function(t){return'"'+n(t.text)+'"'},class:function(t){var e,r="";for(e=0;e<t.parts.length;e++)r+=t.parts[e]instanceof Array?s(t.parts[e][0])+"-"+s(t.parts[e][1]):s(t.parts[e]);return"["+(t.inverted?"^":"")+r+"]"},any:function(t){return"any character"},end:function(t){return"end of input"},other:function(t){return t.description}};function i(t){return t.charCodeAt(0).toString(16).toUpperCase()}function n(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+i(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+i(t)}))}function s(t){return t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+i(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+i(t)}))}return"Expected "+function(t){var e,i,n,s=new Array(t.length);for(e=0;e<t.length;e++)s[e]=(n=t[e],r[n.type](n));if(s.sort(),s.length>0){for(e=1,i=1;e<s.length;e++)s[e-1]!==s[e]&&(s[i]=s[e],i++);s.length=i}switch(s.length){case 1:return s[0];case 2:return s[0]+" or "+s[1];default:return s.slice(0,-1).join(", ")+", or "+s[s.length-1]}}(t)+" but "+function(t){return t?'"'+n(t)+'"':"end of input"}(e)+" found."},{SyntaxError:t,parse:function(e,r){r=void 0!==r?r:{};var i,n={},s={turtleDoc:Gr},a=Gr,o=function(t){var e=Ti.toJSON();return e["@graph"]=[],t.filter((t=>Array.isArray(t))).forEach((t=>{t.forEach((t=>{e["@graph"].push(t)}))})),1===e["@graph"].length&&(Object.assign(e,e["@graph"][0]),delete e["@graph"]),e},h="\ufeff",l=Hr("\ufeff",!1),u=".",c=Hr(".",!1),f=function(t){return t},d="#",p=Hr("#",!1),g=/^[^\n]/,m=Xr(["\n"],!0,!1),w="\n",y=Hr("\n",!1),b=function(t){return t.join("")},v="@prefix",_=Hr("@prefix",!1),x=function(t,e){return Ti.addPrefix(""===t?"0":t,e),{}},T="@base",A=Hr("@base",!1),N=function(t){return Ti.addBase(t),{}},E=/^[Bb]/,R=Xr(["B","b"],!1,!1),k=/^[Aa]/,I=Xr(["A","a"],!1,!1),C=/^[Ss]/,O=Xr(["S","s"],!1,!1),j=/^[Ee]/,S=Xr(["E","e"],!1,!1),F=/^[Pp]/,U=Xr(["P","p"],!1,!1),D=/^[Rr]/,L=Xr(["R","r"],!1,!1),M=/^[Ff]/,P=Xr(["F","f"],!1,!1),B=/^[Ii]/,q=Xr(["I","i"],!1,!1),$=/^[Xx]/,H=Xr(["X","x"],!1,!1),X=function(t,e){var r={};return"string"==typeof t&&"[]"!==t?r["@id"]=t:"object"==typeof t&&Object.assign(r,t),e&&Object.assign(r,e),[r]},z=function(t,e){var r={};return t&&Object.assign(r,t),e&&Object.assign(r,e),[r]},Q=";",V=Hr(";",!1),G=function(t,e,r,i){var n={};return n[r]=i,n},W=function(t,e,r){return r},Y=function(t,e,r){var i={};return r.unshift(function(t,e){var r={};return r[t]=e,r}(t,e)),r.forEach((t=>{t&&Object.keys(t).forEach((e=>{t[e].forEach((t=>{"@type"===e&&void 0!==t["@id"]&&(t=t["@id"]),void 0===i[e]?i[e]=t:Array.isArray(i[e])?i[e].push(t):i[e]=[i[e],t]}))}))})),i},Z=",",J=Hr(",",!1),K=function(t,e){return e},tt=function(t,e){return e.unshift(t),e},et="a",rt=Hr("a",!1),it=function(){return"@type"},nt=function(t){return Ai(t,!0)},st=function(t){return Ai(t,!1)},at=function(t){return"[]"===t?{}:{"@id":t}},ot=function(t){return{"@id":t}},ht="[",lt=Hr("[",!1),ut="]",ct=Hr("]",!1),ft="(",dt=Hr("(",!1),pt=")",gt=Hr(")",!1),mt=function(t){return{"@list":t}},wt=function(t,e){return{"@value":t,"@language":e}},yt="^^",bt=Hr("^^",!1),vt=function(t,e){if("http://www.w3.org/2001/XMLSchema#boolean"===e&&"true"===t)return!0;if("http://www.w3.org/2001/XMLSchema#boolean"===e&&"false"===t)return!1;if("http://www.w3.org/2001/XMLSchema#integer"===e)return parseInt(t);if("http://www.w3.org/2001/XMLSchema#double"===e)return parseFloat(t);const r=Ti.resolve(e,!0);if(r){const i=e.split(":")[0];if("http://www.w3.org/2001/XMLSchema#boolean"===r&&"true"===t)return Ti.decrement(i),!0;if("http://www.w3.org/2001/XMLSchema#boolean"===r&&"false"===t)return Ti.decrement(i),!1;if("http://www.w3.org/2001/XMLSchema#integer"===r)return Ti.decrement(i),parseInt(t);if("http://www.w3.org/2001/XMLSchema#double"===r)return Ti.decrement(i),parseFloat(t)}return{"@value":t,"@type":e}},_t="true",xt=Hr("true",!1),Tt=function(){return!0},At="false",Nt=Hr("false",!1),Et=function(){return!1},Rt=function(t){return t+":"},kt="<",It=Hr("<",!1),Ct=/^[^\0- <>"{}|\^`\\]/,Ot=Xr([["\0"," "],"<",">",'"',"{","}","|","^","`","\\"],!0,!1),jt=">",St=Hr(">",!1),Ft=function(t){const e=t.map((t=>65536<=t.codePointAt(0)&&t.codePointAt(0)<=983039?"a":1===t.length?t:6===t.length?String.fromCharCode("0x"+t.substring(2)):10===t.length?String.fromCodePoint("0x"+t.substring(2)):t)).join("");if(e.match(/^[^\u0000-\u0020<>"{}|^`\\]*$/)){var r=t.join("");try{return Ti.resolve(r)}catch(t){$r("Invalid IRIREF "+r)}}else $r("Invalid IRIREF "+t.join("")+" / "+e)},Ut=":",Dt=Hr(":",!1),Lt=function(t){return t=t||"0",!1===Ti.hasPrefix(t)&&$r("undefined prefix "+t),t},Mt=function(t){return t||""},Pt=function(t,e){return Ti.increment(t),Ti.resolve(t+":"+e)},Bt="_:",qt=Hr("_:",!1),$t=/^[0-9]/,Ht=Xr([["0","9"]],!1,!1),Xt="@",zt=Hr("@",!1),Qt=/^[a-zA-Z]/,Vt=Xr([["a","z"],["A","Z"]],!1,!1),Gt="-",Wt=Hr("-",!1),Yt=/^[a-zA-Z0-9]/,Zt=Xr([["a","z"],["A","Z"],["0","9"]],!1,!1),Jt=function(t,e){return"-"+e.join("")},Kt=function(t,e){return t.join("")+e.join("")},te=/^[+\-]/,ee=Xr(["+","-"],!1,!1),re=function(t){return t.match(/^[0+][0-9]+$/)?{"@value":t,"@type":"http://www.w3.org/2001/XMLSchema#integer"}:parseInt(t)},ie=function(t){return{"@value":t,"@type":"http://www.w3.org/2001/XMLSchema#decimal"}},ne=function(t){return{"@value":t,"@type":"http://www.w3.org/2001/XMLSchema#double"}},se=/^[eE]/,ae=Xr(["e","E"],!1,!1),oe='"',he=Hr('"',!1),le=/^[^"\\\n\r]/,ue=Xr(['"',"\\","\n","\r"],!0,!1),ce="'",fe=Hr("'",!1),de=/^[^'\\\n\r]/,pe=Xr(["'","\\","\n","\r"],!0,!1),ge="'''",me=Hr("'''",!1),we=/^[^'\\]/,ye=Xr(["'","\\"],!0,!1),be="''",ve=Hr("''",!1),_e=function(t,e){return"''"+e.join("")},xe=function(t,e){return"'"+e.join("")},Te=function(t,e){return t.join("")+e.join("")},Ae='"""',Ne=Hr('"""',!1),Ee=/^[^"\\]/,Re=Xr(['"',"\\"],!0,!1),ke='""',Ie=Hr('""',!1),Ce=function(t,e){return'""'+e.join("")},Oe=function(t,e){return'"'+e.join("")},je="\\U",Se=Hr("\\U",!1),Fe=function(t){return String.fromCodePoint(parseInt(t.join(""),16))},Ue="\\u",De=Hr("\\u",!1),Le=function(t){return String.fromCharCode(parseInt(t.join(""),16))},Me="\\t",Pe=Hr("\\t",!1),Be=function(){return"\t"},qe="\\b",$e=Hr("\\b",!1),He=function(){return"\b"},Xe="\\n",ze=Hr("\\n",!1),Qe=function(){return"\n"},Ve="\\r",Ge=Hr("\\r",!1),We=function(){return"\r"},Ye="\\f",Ze=Hr("\\f",!1),Je=function(){return"\f"},Ke='\\"',tr=Hr('\\"',!1),er=function(){return'"'},rr="\\'",ir=Hr("\\'",!1),nr=function(){return"'"},sr="\\\\",ar=Hr("\\\\",!1),or=function(){return"\\"},hr=/^[ \t\r\n]/,lr=Xr([" ","\t","\r","\n"],!1,!1),ur=function(){return"[]"},cr=/^[\uD800-\uDBFF]/,fr=Xr([["\ud800","\udbff"]],!1,!1),dr=/^[\uDC00-\uDFFF]/,pr=Xr([["\udc00","\udfff"]],!1,!1),gr=function(t,e){return t+e},mr=/^[A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,wr=Xr([["A","Z"],["a","z"],["À","Ö"],["Ø","ö"],["ø","˿"],["Ͱ","ͽ"],["Ϳ",""],["",""],["⁰",""],["Ⰰ",""],["、",""],["豈","﷏"],["ﷰ","�"]],!1,!1),yr="_",br=Hr("_",!1),vr="·",_r=Hr("·",!1),xr=/^[\u0300-\u036F]/,Tr=Xr([["̀","ͯ"]],!1,!1),Ar=/^[\u203F-\u2040]/,Nr=Xr([["‿","⁀"]],!1,!1),Er=function(t,e,r,i){return r.join("")+i.join("")},Rr=function(t,e,r){return t+e.join("")+r.join("")},kr="%",Ir=Hr("%",!1),Cr=/^[0-9A-Fa-f]/,Or=Xr([["0","9"],["A","F"],["a","f"]],!1,!1),jr="\\",Sr=Hr("\\",!1),Fr=/^[_~.!$&'()*+,;=\/?#@%\-]/,Ur=Xr(["_","~",".","!","$","&","'","(",")","*","+",",",";","=","/","?","#","@","%","-"],!1,!1),Dr=0,Lr=0,Mr=[{line:1,column:1}],Pr=0,Br=[],qr=0;if("startRule"in r){if(!(r.startRule in s))throw new Error("Can't start parsing from rule \""+r.startRule+'".');a=s[r.startRule]}function $r(e,r){throw function(e,r){return new t(e,null,null,r)}(e,r=void 0!==r?r:Qr(Lr,Dr))}function Hr(t,e){return{type:"literal",text:t,ignoreCase:e}}function Xr(t,e,r){return{type:"class",parts:t,inverted:e,ignoreCase:r}}function zr(t){var r,i=Mr[t];if(i)return i;for(r=t-1;!Mr[r];)r--;for(i={line:(i=Mr[r]).line,column:i.column};r<t;)10===e.charCodeAt(r)?(i.line++,i.column=1):i.column++,r++;return Mr[t]=i,i}function Qr(t,e){var r=zr(t),i=zr(e);return{start:{offset:t,line:r.line,column:r.column},end:{offset:e,line:i.line,column:i.column}}}function Vr(t){Dr<Pr||(Dr>Pr&&(Pr=Dr,Br=[]),Br.push(t))}function Gr(){var t,e,r,i,s;for(t=Dr,e=[],r=Wr();r!==n;)e.push(r),r=Wr();if(e!==n){for(r=[],i=Yr();i!==n;)r.push(i),i=Yr();if(r!==n){for(i=[],s=Zr();s!==n;)i.push(s),s=Zr();i!==n?(Lr=t,t=e=o(r)):(Dr=t,t=n)}else Dr=t,t=n}else Dr=t,t=n;return t}function Wr(){var t;return 65279===e.charCodeAt(Dr)?(t=h,Dr++):(t=n,0===qr&&Vr(l)),t}function Yr(){var t,r,i,s;if((t=function(){var t;return(t=function(){var t,r,i,s,a,o,h,l,f;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if(e.substr(Dr,7)===v?(i=v,Dr+=7):(i=n,0===qr&&Vr(_)),i!==n){for(s=[],a=Zr();a!==n;)s.push(a),a=Zr();if(s!==n)if((a=li())!==n){for(o=[],h=Zr();h!==n;)o.push(h),h=Zr();if(o!==n)if((h=oi())!==n){for(l=[],f=Zr();f!==n;)l.push(f),f=Zr();l!==n?(46===e.charCodeAt(Dr)?(f=u,Dr++):(f=n,0===qr&&Vr(c)),f!==n?(Lr=t,t=r=x(a,h)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n}else Dr=t,t=n;else Dr=t,t=n}else Dr=t,t=n;else Dr=t,t=n;return t}())===n&&(t=function(){var t,r,i,s,a,o,h;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if(e.substr(Dr,5)===T?(i=T,Dr+=5):(i=n,0===qr&&Vr(A)),i!==n){for(s=[],a=Zr();a!==n;)s.push(a),a=Zr();if(s!==n)if((a=oi())!==n){for(o=[],h=Zr();h!==n;)o.push(h),h=Zr();o!==n?(46===e.charCodeAt(Dr)?(h=u,Dr++):(h=n,0===qr&&Vr(c)),h!==n?(Lr=t,t=r=N(a)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n}else Dr=t,t=n;else Dr=t,t=n;return t}())===n&&(t=function(){var t,r,i,s,a,o,h,l,u,c,f,d;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if(F.test(e.charAt(Dr))?(i=e.charAt(Dr),Dr++):(i=n,0===qr&&Vr(U)),i!==n)if(D.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(L)),s!==n)if(j.test(e.charAt(Dr))?(a=e.charAt(Dr),Dr++):(a=n,0===qr&&Vr(S)),a!==n)if(M.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(P)),o!==n)if(B.test(e.charAt(Dr))?(h=e.charAt(Dr),Dr++):(h=n,0===qr&&Vr(q)),h!==n)if($.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(H)),l!==n){for(u=[],c=Zr();c!==n;)u.push(c),c=Zr();if(u!==n)if((c=li())!==n){for(f=[],d=Zr();d!==n;)f.push(d),d=Zr();f!==n&&(d=oi())!==n?(Lr=t,t=r=x(c,d)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n}else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;return t}())===n&&(t=function(){var t,r,i,s,a,o,h,l;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if(E.test(e.charAt(Dr))?(i=e.charAt(Dr),Dr++):(i=n,0===qr&&Vr(R)),i!==n)if(k.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(I)),s!==n)if(C.test(e.charAt(Dr))?(a=e.charAt(Dr),Dr++):(a=n,0===qr&&Vr(O)),a!==n)if(j.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(S)),o!==n){for(h=[],l=Zr();l!==n;)h.push(l),l=Zr();h!==n&&(l=oi())!==n?(Lr=t,t=r=N(l)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;return t}()),t}())===n)if(t=Dr,(r=function(){var t,e,r;return t=Dr,(e=function(){var t,e;return t=Dr,(e=ii())!==n&&(Lr=t,e=nt(e)),(t=e)===n&&(t=ai())===n&&(t=si()),t}())!==n&&(r=Jr())!==n?(Lr=t,t=e=X(e,r)):(Dr=t,t=n),t===n&&(t=Dr,(e=ri())!==n?((r=Jr())===n&&(r=null),r!==n?(Lr=t,t=e=z(e,r)):(Dr=t,t=n)):(Dr=t,t=n)),t}())!==n){for(i=[],s=Zr();s!==n;)i.push(s),s=Zr();i!==n?(46===e.charCodeAt(Dr)?(s=u,Dr++):(s=n,0===qr&&Vr(c)),s!==n?(Lr=t,t=r=f(r)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;return t}function Zr(){var t;return(t=function(){var t;return hr.test(e.charAt(Dr))?(t=e.charAt(Dr),Dr++):(t=n,0===qr&&Vr(lr)),t}())===n&&(t=function(){var t,r,i,s;if(t=Dr,35===e.charCodeAt(Dr)?(r=d,Dr++):(r=n,0===qr&&Vr(p)),r!==n){for(i=[],g.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(m));s!==n;)i.push(s),g.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(m));i!==n?(10===e.charCodeAt(Dr)?(s=w,Dr++):(s=n,0===qr&&Vr(y)),s!==n?(Lr=t,t=r=b(i)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;return t}()),t}function Jr(){var t,r,i,s,a,o,h,l,u,c;if(t=Dr,(r=ti())!==n)if((i=Kr())!==n){for(s=[],a=Dr,o=[],h=Zr();h!==n;)o.push(h),h=Zr();for(o!==n?(59===e.charCodeAt(Dr)?(h=Q,Dr++):(h=n,0===qr&&Vr(V)),h!==n?(l=Dr,(u=ti())!==n&&(c=Kr())!==n?(Lr=l,l=u=G(r,i,u,c)):(Dr=l,l=n),l===n&&(l=null),l!==n?(Lr=a,a=o=W(r,i,l)):(Dr=a,a=n)):(Dr=a,a=n)):(Dr=a,a=n);a!==n;){for(s.push(a),a=Dr,o=[],h=Zr();h!==n;)o.push(h),h=Zr();o!==n?(59===e.charCodeAt(Dr)?(h=Q,Dr++):(h=n,0===qr&&Vr(V)),h!==n?(l=Dr,(u=ti())!==n&&(c=Kr())!==n?(Lr=l,l=u=G(r,i,u,c)):(Dr=l,l=n),l===n&&(l=null),l!==n?(Lr=a,a=o=W(r,i,l)):(Dr=a,a=n)):(Dr=a,a=n)):(Dr=a,a=n)}s!==n?(Lr=t,t=r=Y(r,i,s)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n;return t}function Kr(){var t,r,i,s,a,o,h;if(t=Dr,(r=ei())!==n){for(i=[],s=Dr,a=[],o=Zr();o!==n;)a.push(o),o=Zr();for(a!==n?(44===e.charCodeAt(Dr)?(o=Z,Dr++):(o=n,0===qr&&Vr(J)),o!==n&&(h=ei())!==n?(Lr=s,s=a=K(r,h)):(Dr=s,s=n)):(Dr=s,s=n);s!==n;){for(i.push(s),s=Dr,a=[],o=Zr();o!==n;)a.push(o),o=Zr();a!==n?(44===e.charCodeAt(Dr)?(o=Z,Dr++):(o=n,0===qr&&Vr(J)),o!==n&&(h=ei())!==n?(Lr=s,s=a=K(r,h)):(Dr=s,s=n)):(Dr=s,s=n)}i!==n?(Lr=t,t=r=tt(r,i)):(Dr=t,t=n)}else Dr=t,t=n;return t}function ti(){var t,r,i;if(t=Dr,(r=function(){var t,e,r;for(t=Dr,e=[],r=Zr();r!==n;)e.push(r),r=Zr();return e!==n&&(r=si())!==n?(Lr=t,t=e=f(r)):(Dr=t,t=n),t}())!==n&&(Lr=t,r=f(r)),(t=r)===n){for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();r!==n?(97===e.charCodeAt(Dr)?(i=et,Dr++):(i=n,0===qr&&Vr(rt)),i!==n?(Lr=t,t=r=it()):(Dr=t,t=n)):(Dr=t,t=n)}return t}function ei(){var t,r;return(t=function(){var t;return(t=function(){var t,r,i,s,a,o,h;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if((i=ni())!==n){for(s=[],a=Zr();a!==n;)s.push(a),a=Zr();s!==n&&(a=function(){var t,r,i,s,a,o,h,l;if(t=Dr,64===e.charCodeAt(Dr)?(r=Xt,Dr++):(r=n,0===qr&&Vr(zt)),r!==n){if(i=[],Qt.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(Vt)),s!==n)for(;s!==n;)i.push(s),Qt.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(Vt));else i=n;if(i!==n){if(s=[],a=Dr,45===e.charCodeAt(Dr)?(o=Gt,Dr++):(o=n,0===qr&&Vr(Wt)),o!==n){if(h=[],Yt.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Zt)),l!==n)for(;l!==n;)h.push(l),Yt.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Zt));else h=n;h!==n?(Lr=a,a=o=Jt(i,h)):(Dr=a,a=n)}else Dr=a,a=n;for(;a!==n;)if(s.push(a),a=Dr,45===e.charCodeAt(Dr)?(o=Gt,Dr++):(o=n,0===qr&&Vr(Wt)),o!==n){if(h=[],Yt.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Zt)),l!==n)for(;l!==n;)h.push(l),Yt.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Zt));else h=n;h!==n?(Lr=a,a=o=Jt(i,h)):(Dr=a,a=n)}else Dr=a,a=n;s!==n?(Lr=t,t=r=Kt(i,s)):(Dr=t,t=n)}else Dr=t,t=n}else Dr=t,t=n;return t}())!==n?(Lr=t,t=r=wt(i,a)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n;if(t===n){for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if((i=ni())!==n){for(s=[],a=Zr();a!==n;)s.push(a),a=Zr();if(s!==n)if(e.substr(Dr,2)===yt?(a=yt,Dr+=2):(a=n,0===qr&&Vr(bt)),a!==n){for(o=[],h=Zr();h!==n;)o.push(h),h=Zr();o!==n&&(h=si())!==n?(Lr=t,t=r=vt(i,h)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n}else Dr=t,t=n;else Dr=t,t=n;if(t===n){for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();r!==n&&(i=ni())!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n)}}return t}())===n&&(t=function(){var t,r,i;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();return r!==n?((i=function(){var t,r,i,s,a,o,h,l,f;if(t=Dr,r=Dr,i=Dr,te.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ee)),s===n&&(s=null),s!==n){if(a=Dr,o=[],$t.test(e.charAt(Dr))?(h=e.charAt(Dr),Dr++):(h=n,0===qr&&Vr(Ht)),h!==n)for(;h!==n;)o.push(h),$t.test(e.charAt(Dr))?(h=e.charAt(Dr),Dr++):(h=n,0===qr&&Vr(Ht));else o=n;if(o!==n)if(46===e.charCodeAt(Dr)?(h=u,Dr++):(h=n,0===qr&&Vr(c)),h!==n){for(l=[],$t.test(e.charAt(Dr))?(f=e.charAt(Dr),Dr++):(f=n,0===qr&&Vr(Ht));f!==n;)l.push(f),$t.test(e.charAt(Dr))?(f=e.charAt(Dr),Dr++):(f=n,0===qr&&Vr(Ht));l!==n&&(f=ui())!==n?a=o=[o,h,l,f]:(Dr=a,a=n)}else Dr=a,a=n;else Dr=a,a=n;if(a===n){if(a=Dr,46===e.charCodeAt(Dr)?(o=u,Dr++):(o=n,0===qr&&Vr(c)),o!==n){if(h=[],$t.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Ht)),l!==n)for(;l!==n;)h.push(l),$t.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Ht));else h=n;h!==n&&(l=ui())!==n?a=o=[o,h,l]:(Dr=a,a=n)}else Dr=a,a=n;if(a===n){if(a=Dr,o=[],$t.test(e.charAt(Dr))?(h=e.charAt(Dr),Dr++):(h=n,0===qr&&Vr(Ht)),h!==n)for(;h!==n;)o.push(h),$t.test(e.charAt(Dr))?(h=e.charAt(Dr),Dr++):(h=n,0===qr&&Vr(Ht));else o=n;o!==n&&(h=ui())!==n?a=o=[o,h]:(Dr=a,a=n)}}a!==n?i=s=[s,a]:(Dr=i,i=n)}else Dr=i,i=n;return(r=i!==n?e.substring(r,Dr):i)!==n&&(Lr=t,r=ne(r)),r}())===n&&(i=function(){var t,r,i,s,a,o,h,l;if(t=Dr,r=Dr,i=Dr,te.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ee)),s===n&&(s=null),s!==n){for(a=[],$t.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(Ht));o!==n;)a.push(o),$t.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(Ht));if(a!==n)if(46===e.charCodeAt(Dr)?(o=u,Dr++):(o=n,0===qr&&Vr(c)),o!==n){if(h=[],$t.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Ht)),l!==n)for(;l!==n;)h.push(l),$t.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Ht));else h=n;h!==n?i=s=[s,a,o,h]:(Dr=i,i=n)}else Dr=i,i=n;else Dr=i,i=n}else Dr=i,i=n;return(r=i!==n?e.substring(r,Dr):i)!==n&&(Lr=t,r=ie(r)),r}())===n&&(i=function(){var t,r,i,s,a,o;if(t=Dr,r=Dr,i=Dr,te.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ee)),s===n&&(s=null),s!==n){if(a=[],$t.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(Ht)),o!==n)for(;o!==n;)a.push(o),$t.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(Ht));else a=n;a!==n?i=s=[s,a]:(Dr=i,i=n)}else Dr=i,i=n;return(r=i!==n?e.substring(r,Dr):i)!==n&&(Lr=t,r=re(r)),r}()),i!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n)):(Dr=t,t=n),t}())===n&&(t=function(){var t,r,i;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n?(e.substr(Dr,4)===_t?(i=_t,Dr+=4):(i=n,0===qr&&Vr(xt)),i!==n?(Lr=t,t=r=Tt()):(Dr=t,t=n)):(Dr=t,t=n),t===n){for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();r!==n?(e.substr(Dr,5)===At?(i=At,Dr+=5):(i=n,0===qr&&Vr(Nt)),i!==n?(Lr=t,t=r=Et()):(Dr=t,t=n)):(Dr=t,t=n)}return t}()),t}())===n&&(t=Dr,(r=ii())!==n&&(Lr=t,r=st(r)),(t=r)===n&&(t=Dr,(r=ai())!==n&&(Lr=t,r=at(r)),(t=r)===n&&(t=Dr,(r=ri())!==n&&(Lr=t,r=f(r)),(t=r)===n&&(t=Dr,(r=si())!==n&&(Lr=t,r=ot(r)),t=r)))),t}function ri(){var t,r,i,s,a,o;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if(91===e.charCodeAt(Dr)?(i=ht,Dr++):(i=n,0===qr&&Vr(lt)),i!==n)if((s=Jr())!==n){for(a=[],o=Zr();o!==n;)a.push(o),o=Zr();a!==n?(93===e.charCodeAt(Dr)?(o=ut,Dr++):(o=n,0===qr&&Vr(ct)),o!==n?(Lr=t,t=r=f(s)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;else Dr=t,t=n;else Dr=t,t=n;return t}function ii(){var t,r,i,s,a,o;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n)if(40===e.charCodeAt(Dr)?(i=ft,Dr++):(i=n,0===qr&&Vr(dt)),i!==n){for(s=[],a=ei();a!==n;)s.push(a),a=ei();if(s!==n){for(a=[],o=Zr();o!==n;)a.push(o),o=Zr();a!==n?(41===e.charCodeAt(Dr)?(o=pt,Dr++):(o=n,0===qr&&Vr(gt)),o!==n?(Lr=t,t=r=mt(s)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n}else Dr=t,t=n;else Dr=t,t=n;return t}function ni(){var t,r,i;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();return r!==n?((i=function(){var t,r,i,s,a,o,h,l;if(t=Dr,e.substr(Dr,3)===ge?(r=ge,Dr+=3):(r=n,0===qr&&Vr(me)),r!==n){for(i=[],we.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ye)),s===n&&(s=fi())===n&&(s=ci());s!==n;)i.push(s),we.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ye)),s===n&&(s=fi())===n&&(s=ci());if(i!==n){if(s=[],a=Dr,e.substr(Dr,2)===be?(o=be,Dr+=2):(o=n,0===qr&&Vr(ve)),o!==n){if(h=[],we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=_e(i,h)):(Dr=a,a=n)}else Dr=a,a=n;if(a===n)if(a=Dr,39===e.charCodeAt(Dr)?(o=ce,Dr++):(o=n,0===qr&&Vr(fe)),o!==n){if(h=[],we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=xe(i,h)):(Dr=a,a=n)}else Dr=a,a=n;for(;a!==n;){if(s.push(a),a=Dr,e.substr(Dr,2)===be?(o=be,Dr+=2):(o=n,0===qr&&Vr(ve)),o!==n){if(h=[],we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=_e(i,h)):(Dr=a,a=n)}else Dr=a,a=n;if(a===n)if(a=Dr,39===e.charCodeAt(Dr)?(o=ce,Dr++):(o=n,0===qr&&Vr(fe)),o!==n){if(h=[],we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),we.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(ye)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=xe(i,h)):(Dr=a,a=n)}else Dr=a,a=n}s!==n?(e.substr(Dr,3)===ge?(a=ge,Dr+=3):(a=n,0===qr&&Vr(me)),a!==n?(Lr=t,t=r=Te(i,s)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n}else Dr=t,t=n;return t}())===n&&(i=function(){var t,r,i,s,a,o,h,l;if(t=Dr,e.substr(Dr,3)===Ae?(r=Ae,Dr+=3):(r=n,0===qr&&Vr(Ne)),r!==n){for(i=[],Ee.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(Re)),s===n&&(s=fi())===n&&(s=ci());s!==n;)i.push(s),Ee.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(Re)),s===n&&(s=fi())===n&&(s=ci());if(i!==n){if(s=[],a=Dr,e.substr(Dr,2)===ke?(o=ke,Dr+=2):(o=n,0===qr&&Vr(Ie)),o!==n){if(h=[],Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=Ce(i,h)):(Dr=a,a=n)}else Dr=a,a=n;if(a===n)if(a=Dr,34===e.charCodeAt(Dr)?(o=oe,Dr++):(o=n,0===qr&&Vr(he)),o!==n){if(h=[],Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=Oe(i,h)):(Dr=a,a=n)}else Dr=a,a=n;for(;a!==n;){if(s.push(a),a=Dr,e.substr(Dr,2)===ke?(o=ke,Dr+=2):(o=n,0===qr&&Vr(Ie)),o!==n){if(h=[],Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=Ce(i,h)):(Dr=a,a=n)}else Dr=a,a=n;if(a===n)if(a=Dr,34===e.charCodeAt(Dr)?(o=oe,Dr++):(o=n,0===qr&&Vr(he)),o!==n){if(h=[],Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci()),l!==n)for(;l!==n;)h.push(l),Ee.test(e.charAt(Dr))?(l=e.charAt(Dr),Dr++):(l=n,0===qr&&Vr(Re)),l===n&&(l=fi())===n&&(l=ci());else h=n;h!==n?(Lr=a,a=o=Oe(i,h)):(Dr=a,a=n)}else Dr=a,a=n}s!==n?(e.substr(Dr,3)===Ae?(a=Ae,Dr+=3):(a=n,0===qr&&Vr(Ne)),a!==n?(Lr=t,t=r=Te(i,s)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n}else Dr=t,t=n;return t}())===n&&(i=function(){var t,r,i,s;if(t=Dr,39===e.charCodeAt(Dr)?(r=ce,Dr++):(r=n,0===qr&&Vr(fe)),r!==n){for(i=[],de.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(pe)),s===n&&(s=fi())===n&&(s=ci());s!==n;)i.push(s),de.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(pe)),s===n&&(s=fi())===n&&(s=ci());i!==n?(39===e.charCodeAt(Dr)?(s=ce,Dr++):(s=n,0===qr&&Vr(fe)),s!==n?(Lr=t,t=r=b(i)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;return t}())===n&&(i=function(){var t,r,i,s;if(t=Dr,34===e.charCodeAt(Dr)?(r=oe,Dr++):(r=n,0===qr&&Vr(he)),r!==n){for(i=[],le.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ue)),s===n&&(s=fi())===n&&(s=ci());s!==n;)i.push(s),le.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ue)),s===n&&(s=fi())===n&&(s=ci());i!==n?(34===e.charCodeAt(Dr)?(s=oe,Dr++):(s=n,0===qr&&Vr(he)),s!==n?(Lr=t,t=r=b(i)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;return t}()),i!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n)):(Dr=t,t=n),t}function si(){var t,r,i;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n&&(i=oi())!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n),t===n){for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();r!==n&&(i=function(){var t,r;return(t=function(){var t,r,i;return t=Dr,(r=hi())!==n&&(i=function(){var t,r,i,s,a,o,h,l;if(t=Dr,(r=pi())===n&&(58===e.charCodeAt(Dr)?(r=Ut,Dr++):(r=n,0===qr&&Vr(Dt)),r===n&&($t.test(e.charAt(Dr))?(r=e.charAt(Dr),Dr++):(r=n,0===qr&&Vr(Ht)),r===n&&(r=wi()))),r!==n){for(i=[],(s=gi())===n&&(58===e.charCodeAt(Dr)?(s=Ut,Dr++):(s=n,0===qr&&Vr(Dt)),s===n&&(s=wi()));s!==n;)i.push(s),(s=gi())===n&&(58===e.charCodeAt(Dr)?(s=Ut,Dr++):(s=n,0===qr&&Vr(Dt)),s===n&&(s=wi()));if(i!==n){if(s=[],a=Dr,o=[],46===e.charCodeAt(Dr)?(h=u,Dr++):(h=n,0===qr&&Vr(c)),h!==n)for(;h!==n;)o.push(h),46===e.charCodeAt(Dr)?(h=u,Dr++):(h=n,0===qr&&Vr(c));else o=n;if(o!==n){if(h=[],(l=gi())===n&&(58===e.charCodeAt(Dr)?(l=Ut,Dr++):(l=n,0===qr&&Vr(Dt)),l===n&&(l=wi())),l!==n)for(;l!==n;)h.push(l),(l=gi())===n&&(58===e.charCodeAt(Dr)?(l=Ut,Dr++):(l=n,0===qr&&Vr(Dt)),l===n&&(l=wi()));else h=n;h!==n?(Lr=a,a=o=Er(r,i,o,h)):(Dr=a,a=n)}else Dr=a,a=n;for(;a!==n;){if(s.push(a),a=Dr,o=[],46===e.charCodeAt(Dr)?(h=u,Dr++):(h=n,0===qr&&Vr(c)),h!==n)for(;h!==n;)o.push(h),46===e.charCodeAt(Dr)?(h=u,Dr++):(h=n,0===qr&&Vr(c));else o=n;if(o!==n){if(h=[],(l=gi())===n&&(58===e.charCodeAt(Dr)?(l=Ut,Dr++):(l=n,0===qr&&Vr(Dt)),l===n&&(l=wi())),l!==n)for(;l!==n;)h.push(l),(l=gi())===n&&(58===e.charCodeAt(Dr)?(l=Ut,Dr++):(l=n,0===qr&&Vr(Dt)),l===n&&(l=wi()));else h=n;h!==n?(Lr=a,a=o=Er(r,i,o,h)):(Dr=a,a=n)}else Dr=a,a=n}s!==n?(Lr=t,t=r=Rr(r,i,s)):(Dr=t,t=n)}else Dr=t,t=n}else Dr=t,t=n;return t}())!==n?(Lr=t,t=r=Pt(r,i)):(Dr=t,t=n),t}())===n&&(t=Dr,(r=hi())!==n&&(Lr=t,r=Rt(r)),t=r),t}())!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n)}return t}function ai(){var t,r,i;for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();if(r!==n&&(i=function(){var t,r,i,s,a,o,h,l,f,d;if(t=Dr,r=Dr,e.substr(Dr,2)===Bt?(i=Bt,Dr+=2):(i=n,0===qr&&Vr(qt)),i!==n)if((s=pi())===n&&($t.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(Ht))),s!==n){for(a=[],o=gi();o!==n;)a.push(o),o=gi();if(a!==n){if(o=[],h=Dr,l=[],46===e.charCodeAt(Dr)?(f=u,Dr++):(f=n,0===qr&&Vr(c)),f!==n)for(;f!==n;)l.push(f),46===e.charCodeAt(Dr)?(f=u,Dr++):(f=n,0===qr&&Vr(c));else l=n;if(l!==n){if(f=[],(d=gi())!==n)for(;d!==n;)f.push(d),d=gi();else f=n;f!==n?h=l=[l,f]:(Dr=h,h=n)}else Dr=h,h=n;for(;h!==n;){if(o.push(h),h=Dr,l=[],46===e.charCodeAt(Dr)?(f=u,Dr++):(f=n,0===qr&&Vr(c)),f!==n)for(;f!==n;)l.push(f),46===e.charCodeAt(Dr)?(f=u,Dr++):(f=n,0===qr&&Vr(c));else l=n;if(l!==n){if(f=[],(d=gi())!==n)for(;d!==n;)f.push(d),d=gi();else f=n;f!==n?h=l=[l,f]:(Dr=h,h=n)}else Dr=h,h=n}o!==n?r=i=[i,s,a,o]:(Dr=r,r=n)}else Dr=r,r=n}else Dr=r,r=n;else Dr=r,r=n;return r!==n?e.substring(t,Dr):r}())!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n),t===n){for(t=Dr,r=[],i=Zr();i!==n;)r.push(i),i=Zr();r!==n&&(i=function(){var t,r,i,s;if(t=Dr,91===e.charCodeAt(Dr)?(r=ht,Dr++):(r=n,0===qr&&Vr(lt)),r!==n){for(i=[],s=Zr();s!==n;)i.push(s),s=Zr();i!==n?(93===e.charCodeAt(Dr)?(s=ut,Dr++):(s=n,0===qr&&Vr(ct)),s!==n?(Lr=t,t=r=ur()):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;return t}())!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n)}return t}function oi(){var t,r,i,s;if(t=Dr,60===e.charCodeAt(Dr)?(r=kt,Dr++):(r=n,0===qr&&Vr(It)),r!==n){for(i=[],Ct.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(Ot)),s===n&&(s=ci());s!==n;)i.push(s),Ct.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(Ot)),s===n&&(s=ci());i!==n?(62===e.charCodeAt(Dr)?(s=jt,Dr++):(s=n,0===qr&&Vr(St)),s!==n?(Lr=t,t=r=Ft(i)):(Dr=t,t=n)):(Dr=t,t=n)}else Dr=t,t=n;return t}function hi(){var t,r,i;return t=Dr,(r=mi())===n&&(r=null),r!==n?(58===e.charCodeAt(Dr)?(i=Ut,Dr++):(i=n,0===qr&&Vr(Dt)),i!==n?(Lr=t,t=r=Lt(r)):(Dr=t,t=n)):(Dr=t,t=n),t}function li(){var t,r,i;return t=Dr,(r=mi())===n&&(r=null),r!==n?(58===e.charCodeAt(Dr)?(i=Ut,Dr++):(i=n,0===qr&&Vr(Dt)),i!==n?(Lr=t,t=r=Mt(r)):(Dr=t,t=n)):(Dr=t,t=n),t}function ui(){var t,r,i,s,a,o;if(t=Dr,r=Dr,se.test(e.charAt(Dr))?(i=e.charAt(Dr),Dr++):(i=n,0===qr&&Vr(ae)),i!==n)if(te.test(e.charAt(Dr))?(s=e.charAt(Dr),Dr++):(s=n,0===qr&&Vr(ee)),s===n&&(s=null),s!==n){if(a=[],$t.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(Ht)),o!==n)for(;o!==n;)a.push(o),$t.test(e.charAt(Dr))?(o=e.charAt(Dr),Dr++):(o=n,0===qr&&Vr(Ht));else a=n;a!==n?r=i=[i,s,a]:(Dr=r,r=n)}else Dr=r,r=n;else Dr=r,r=n;return r!==n?e.substring(t,Dr):r}function ci(){var t,r,i,s,a,o,h,l,u,c,f;return t=Dr,e.substr(Dr,2)===je?(r=je,Dr+=2):(r=n,0===qr&&Vr(Se)),r!==n?(i=Dr,(s=yi())!==n&&(a=yi())!==n&&(o=yi())!==n&&(h=yi())!==n&&(l=yi())!==n&&(u=yi())!==n&&(c=yi())!==n&&(f=yi())!==n?i=s=[s,a,o,h,l,u,c,f]:(Dr=i,i=n),i!==n?(Lr=t,t=r=Fe(i)):(Dr=t,t=n)):(Dr=t,t=n),t===n&&(t=Dr,e.substr(Dr,2)===Ue?(r=Ue,Dr+=2):(r=n,0===qr&&Vr(De)),r!==n?(i=Dr,(s=yi())!==n&&(a=yi())!==n&&(o=yi())!==n&&(h=yi())!==n?i=s=[s,a,o,h]:(Dr=i,i=n),i!==n?(Lr=t,t=r=Le(i)):(Dr=t,t=n)):(Dr=t,t=n)),t}function fi(){var t,r;return t=Dr,e.substr(Dr,2)===Me?(r=Me,Dr+=2):(r=n,0===qr&&Vr(Pe)),r!==n&&(Lr=t,r=Be()),(t=r)===n&&(t=Dr,e.substr(Dr,2)===qe?(r=qe,Dr+=2):(r=n,0===qr&&Vr($e)),r!==n&&(Lr=t,r=He()),(t=r)===n&&(t=Dr,e.substr(Dr,2)===Xe?(r=Xe,Dr+=2):(r=n,0===qr&&Vr(ze)),r!==n&&(Lr=t,r=Qe()),(t=r)===n&&(t=Dr,e.substr(Dr,2)===Ve?(r=Ve,Dr+=2):(r=n,0===qr&&Vr(Ge)),r!==n&&(Lr=t,r=We()),(t=r)===n&&(t=Dr,e.substr(Dr,2)===Ye?(r=Ye,Dr+=2):(r=n,0===qr&&Vr(Ze)),r!==n&&(Lr=t,r=Je()),(t=r)===n&&(t=Dr,e.substr(Dr,2)===Ke?(r=Ke,Dr+=2):(r=n,0===qr&&Vr(tr)),r!==n&&(Lr=t,r=er()),(t=r)===n&&(t=Dr,e.substr(Dr,2)===rr?(r=rr,Dr+=2):(r=n,0===qr&&Vr(ir)),r!==n&&(Lr=t,r=nr()),(t=r)===n&&(t=Dr,e.substr(Dr,2)===sr?(r=sr,Dr+=2):(r=n,0===qr&&Vr(ar)),r!==n&&(Lr=t,r=or()),t=r))))))),t}function di(){var t,r,i;return t=Dr,cr.test(e.charAt(Dr))?(r=e.charAt(Dr),Dr++):(r=n,0===qr&&Vr(fr)),r!==n?(dr.test(e.charAt(Dr))?(i=e.charAt(Dr),Dr++):(i=n,0===qr&&Vr(pr)),i!==n?(Lr=t,t=r=gr(r,i)):(Dr=t,t=n)):(Dr=t,t=n),t===n&&(mr.test(e.charAt(Dr))?(t=e.charAt(Dr),Dr++):(t=n,0===qr&&Vr(wr))),t}function pi(){var t;return(t=di())===n&&(95===e.charCodeAt(Dr)?(t=yr,Dr++):(t=n,0===qr&&Vr(br))),t}function gi(){var t;return(t=pi())===n&&(45===e.charCodeAt(Dr)?(t=Gt,Dr++):(t=n,0===qr&&Vr(Wt)),t===n&&($t.test(e.charAt(Dr))?(t=e.charAt(Dr),Dr++):(t=n,0===qr&&Vr(Ht)),t===n&&(183===e.charCodeAt(Dr)?(t=vr,Dr++):(t=n,0===qr&&Vr(_r)),t===n&&(xr.test(e.charAt(Dr))?(t=e.charAt(Dr),Dr++):(t=n,0===qr&&Vr(Tr)),t===n&&(Ar.test(e.charAt(Dr))?(t=e.charAt(Dr),Dr++):(t=n,0===qr&&Vr(Nr))))))),t}function mi(){var t,r,i,s,a,o,h,l,f;if(t=Dr,r=Dr,(i=di())!==n){for(s=[],a=gi();a!==n;)s.push(a),a=gi();if(s!==n){if(a=[],o=Dr,h=[],46===e.charCodeAt(Dr)?(l=u,Dr++):(l=n,0===qr&&Vr(c)),l!==n)for(;l!==n;)h.push(l),46===e.charCodeAt(Dr)?(l=u,Dr++):(l=n,0===qr&&Vr(c));else h=n;if(h!==n){if(l=[],(f=gi())!==n)for(;f!==n;)l.push(f),f=gi();else l=n;l!==n?o=h=[h,l]:(Dr=o,o=n)}else Dr=o,o=n;for(;o!==n;){if(a.push(o),o=Dr,h=[],46===e.charCodeAt(Dr)?(l=u,Dr++):(l=n,0===qr&&Vr(c)),l!==n)for(;l!==n;)h.push(l),46===e.charCodeAt(Dr)?(l=u,Dr++):(l=n,0===qr&&Vr(c));else h=n;if(h!==n){if(l=[],(f=gi())!==n)for(;f!==n;)l.push(f),f=gi();else l=n;l!==n?o=h=[h,l]:(Dr=o,o=n)}else Dr=o,o=n}a!==n?r=i=[i,s,a]:(Dr=r,r=n)}else Dr=r,r=n}else Dr=r,r=n;return r!==n?e.substring(t,Dr):r}function wi(){var t;return(t=function(){var t,r,i,s,a;return t=Dr,r=Dr,37===e.charCodeAt(Dr)?(i=kr,Dr++):(i=n,0===qr&&Vr(Ir)),i!==n&&(s=yi())!==n&&(a=yi())!==n?r=i=[i,s,a]:(Dr=r,r=n),r!==n?e.substring(t,Dr):r}())===n&&(t=function(){var t,r,i;return t=Dr,92===e.charCodeAt(Dr)?(r=jr,Dr++):(r=n,0===qr&&Vr(Sr)),r!==n?(Fr.test(e.charAt(Dr))?(i=e.charAt(Dr),Dr++):(i=n,0===qr&&Vr(Ur)),i!==n?(Lr=t,t=r=f(i)):(Dr=t,t=n)):(Dr=t,t=n),t}()),t}function yi(){var t;return Cr.test(e.charAt(Dr))?(t=e.charAt(Dr),Dr++):(t=n,0===qr&&Vr(Or)),t}var bi,vi,_i,xi=function(t){return t.match(/^[a-z](.*?):(.+?)/g)},Ti={base:[],data:{},addBase:function(t){if(0===Ti.base.length)return void Ti.base.push(t);const e=Ti.base[Ti.base.length-1];e!==t&&Ti.base.push(new URL(t,e).toString())},addPrefix:function(t,e){const r=Ti.data[t];void 0===r?Ti.data[t]=[{uri:e,count:0}]:r[r.length-1].uri!==e&&r.push({uri:e,count:0})},hasPrefix:function(t){return void 0!==this.data[t]},resolve:function(t,e){const i=Object.keys(Ti.data).find((e=>0===t.indexOf(e+":")));if(void 0!==i){const r=Ti.data[i];if(1===r.length&&!0!==e&&xi(r[0].uri))return t;const n=r[r.length-1].uri;return t.replace(i+":",n)}var n=0===Ti.base.length?r.baseIRI:Ti.base[Ti.base.length-1];return!n||t.match(/^(http:|https:|urn:|file:)/)?t:0===t.indexOf("//")&&n?n.split("//")[0]+t:new URL(t,n).toString()},increment:function(t){const e=Ti.data[t];void 0!==e&&e[e.length-1].count++},decrement:function(t){const e=Ti.data[t];void 0!==e&&e[e.length-1].count--},toJSON:function(){const t={};return Ti.base.length>0&&(void 0===t["@context"]&&(t["@context"]={}),t["@context"]["@base"]=Ti.base[0]),Object.keys(Ti.data).forEach((e=>{const r=Ti.data[e][0];"http://www.w3.org/2001/XMLSchema#"===r.uri&&r.count<1||xi(r.uri)&&(void 0===t["@context"]&&(t["@context"]={}),t["@context"][e]=r.uri)})),t}};function Ai(t,e){if(void 0===t["@list"])return t;if(!e&&!t["@list"].find((t=>void 0!==t["@list"])))return t;if(0===t["@list"].length)return{"@id":"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"};var r={},i=null;return t["@list"].forEach((t=>{null===i?i=r:(i["http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"]={},i=i["http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"]),i["http://www.w3.org/1999/02/22-rdf-syntax-ns#first"]=Ai(t,!0),i["http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"]={"@id":"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"}})),r}if((i=a())!==n&&Dr===e.length)return i;throw i!==n&&Dr<e.length&&Vr({type:"end"}),bi=Br,vi=Pr<e.length?e.charAt(Pr):null,_i=Pr<e.length?Qr(Pr,Pr+1):Qr(Pr,Pr),new t(t.buildMessage(bi,vi),bi,vi,_i)}}})?r.apply(e,[]):r)||(t.exports=i)},2313:(t,e,r)=>{"use strict";const i=r(2504),n=r(9029),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.hp=h,e.IS=50;const a=2147483647;function o(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,h.prototype),e}function h(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return l(t,e,r)}function l(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!h.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|g(t,e);let i=o(r);const n=i.write(t,e);return n!==r&&(i=i.slice(0,n)),i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(W(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(W(t,ArrayBuffer)||t&&W(t.buffer,ArrayBuffer))return d(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(W(t,SharedArrayBuffer)||t&&W(t.buffer,SharedArrayBuffer)))return d(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return h.from(i,e,r);const n=function(t){if(h.isBuffer(t)){const e=0|p(t.length),r=o(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Y(t.length)?o(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return h.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return u(t),o(t<0?0:0|p(t))}function f(t){const e=t.length<0?0:0|p(t.length),r=o(e);for(let i=0;i<e;i+=1)r[i]=255&t[i];return r}function d(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let i;return i=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(i,h.prototype),i}function p(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||W(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;let n=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(t).length;default:if(n)return i?-1:Q(t).length;e=(""+e).toLowerCase(),n=!0}}function m(t,e,r){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return I(this,e,r);case"base64":return N(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,r);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function w(t,e,r){const i=t[e];t[e]=t[r],t[r]=i}function y(t,e,r,i,n){if(0===t.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof e&&(e=h.from(e,i)),h.isBuffer(e))return 0===e.length?-1:b(t,e,r,i,n);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,i,n);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,i,n){let s,a=1,o=t.length,h=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;a=2,o/=2,h/=2,r/=2}function l(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(n){let i=-1;for(s=r;s<o;s++)if(l(t,s)===l(e,-1===i?0:s-i)){if(-1===i&&(i=s),s-i+1===h)return i*a}else-1!==i&&(s-=s-i),i=-1}else for(r+h>o&&(r=o-h),s=r;s>=0;s--){let r=!0;for(let i=0;i<h;i++)if(l(t,s+i)!==l(e,i)){r=!1;break}if(r)return s}return-1}function v(t,e,r,i){r=Number(r)||0;const n=t.length-r;i?(i=Number(i))>n&&(i=n):i=n;const s=e.length;let a;for(i>s/2&&(i=s/2),a=0;a<i;++a){const i=parseInt(e.substr(2*a,2),16);if(Y(i))return a;t[r+a]=i}return a}function _(t,e,r,i){return G(Q(e,t.length-r),t,r,i)}function x(t,e,r,i){return G(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,i)}function T(t,e,r,i){return G(V(e),t,r,i)}function A(t,e,r,i){return G(function(t,e){let r,i,n;const s=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),i=r>>8,n=r%256,s.push(n),s.push(i);return s}(e,t.length-r),t,r,i)}function N(t,e,r){return 0===e&&r===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);const i=[];let n=e;for(;n<r;){const e=t[n];let s=null,a=e>239?4:e>223?3:e>191?2:1;if(n+a<=r){let r,i,o,h;switch(a){case 1:e<128&&(s=e);break;case 2:r=t[n+1],128==(192&r)&&(h=(31&e)<<6|63&r,h>127&&(s=h));break;case 3:r=t[n+1],i=t[n+2],128==(192&r)&&128==(192&i)&&(h=(15&e)<<12|(63&r)<<6|63&i,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:r=t[n+1],i=t[n+2],o=t[n+3],128==(192&r)&&128==(192&i)&&128==(192&o)&&(h=(15&e)<<18|(63&r)<<12|(63&i)<<6|63&o,h>65535&&h<1114112&&(s=h))}}null===s?(s=65533,a=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|1023&s),i.push(s),n+=a}return function(t){const e=t.length;if(e<=R)return String.fromCharCode.apply(String,t);let r="",i=0;for(;i<e;)r+=String.fromCharCode.apply(String,t.slice(i,i+=R));return r}(i)}h.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),h.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||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."),Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}}),h.poolSize=8192,h.from=function(t,e,r){return l(t,e,r)},Object.setPrototypeOf(h.prototype,Uint8Array.prototype),Object.setPrototypeOf(h,Uint8Array),h.alloc=function(t,e,r){return function(t,e,r){return u(t),t<=0?o(t):void 0!==e?"string"==typeof r?o(t).fill(e,r):o(t).fill(e):o(t)}(t,e,r)},h.allocUnsafe=function(t){return c(t)},h.allocUnsafeSlow=function(t){return c(t)},h.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==h.prototype},h.compare=function(t,e){if(W(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),W(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),!h.isBuffer(t)||!h.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,i=e.length;for(let n=0,s=Math.min(r,i);n<s;++n)if(t[n]!==e[n]){r=t[n],i=e[n];break}return r<i?-1:i<r?1:0},h.isEncoding=function(t){switch(String(t).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}},h.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return h.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const i=h.allocUnsafe(e);let n=0;for(r=0;r<t.length;++r){let e=t[r];if(W(e,Uint8Array))n+e.length>i.length?(h.isBuffer(e)||(e=h.from(e)),e.copy(i,n)):Uint8Array.prototype.set.call(i,e,n);else{if(!h.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(i,n)}n+=e.length}return i},h.byteLength=g,h.prototype._isBuffer=!0,h.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)w(this,e,e+1);return this},h.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)w(this,e,e+3),w(this,e+1,e+2);return this},h.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},h.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?E(this,0,t):m.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){let t="";const r=e.IS;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},s&&(h.prototype[s]=h.prototype.inspect),h.prototype.compare=function(t,e,r,i,n){if(W(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),e<0||r>t.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&e>=r)return 0;if(i>=n)return-1;if(e>=r)return 1;if(this===t)return 0;let s=(n>>>=0)-(i>>>=0),a=(r>>>=0)-(e>>>=0);const o=Math.min(s,a),l=this.slice(i,n),u=t.slice(e,r);for(let t=0;t<o;++t)if(l[t]!==u[t]){s=l[t],a=u[t];break}return s<a?-1:a<s?1:0},h.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},h.prototype.indexOf=function(t,e,r){return y(this,t,e,r,!0)},h.prototype.lastIndexOf=function(t,e,r){return y(this,t,e,r,!1)},h.prototype.write=function(t,e,r,i){if(void 0===e)i="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)i=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}const n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return T(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const R=4096;function k(t,e,r){let i="";r=Math.min(t.length,r);for(let n=e;n<r;++n)i+=String.fromCharCode(127&t[n]);return i}function I(t,e,r){let i="";r=Math.min(t.length,r);for(let n=e;n<r;++n)i+=String.fromCharCode(t[n]);return i}function C(t,e,r){const i=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>i)&&(r=i);let n="";for(let i=e;i<r;++i)n+=Z[t[i]];return n}function O(t,e,r){const i=t.slice(e,r);let n="";for(let t=0;t<i.length-1;t+=2)n+=String.fromCharCode(i[t]+256*i[t+1]);return n}function j(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function S(t,e,r,i,n,s){if(!h.isBuffer(t))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(r+i>t.length)throw new RangeError("Index out of range")}function F(t,e,r,i,n){$(e,i,n,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function U(t,e,r,i,n){$(e,i,n,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s>>=8,t[r+6]=s,s>>=8,t[r+5]=s,s>>=8,t[r+4]=s;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function D(t,e,r,i,n,s){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,r,i,s){return e=+e,r>>>=0,s||D(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function M(t,e,r,i,s){return e=+e,r>>>=0,s||D(t,0,r,8),n.write(t,e,r,i,52,8),r+8}h.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const i=this.subarray(t,e);return Object.setPrototypeOf(i,h.prototype),i},h.prototype.readUintLE=h.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||j(t,e,this.length);let i=this[t],n=1,s=0;for(;++s<e&&(n*=256);)i+=this[t+s]*n;return i},h.prototype.readUintBE=h.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||j(t,e,this.length);let i=this[t+--e],n=1;for(;e>0&&(n*=256);)i+=this[t+--e]*n;return i},h.prototype.readUint8=h.prototype.readUInt8=function(t,e){return t>>>=0,e||j(t,1,this.length),this[t]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||j(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||j(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||j(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||j(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readBigUInt64LE=J((function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||X(t,this.length-8);const i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,n=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(i)+(BigInt(n)<<BigInt(32))})),h.prototype.readBigUInt64BE=J((function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||X(t,this.length-8);const i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],n=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(i)<<BigInt(32))+BigInt(n)})),h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||j(t,e,this.length);let i=this[t],n=1,s=0;for(;++s<e&&(n*=256);)i+=this[t+s]*n;return n*=128,i>=n&&(i-=Math.pow(2,8*e)),i},h.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||j(t,e,this.length);let i=e,n=1,s=this[t+--i];for(;i>0&&(n*=256);)s+=this[t+--i]*n;return n*=128,s>=n&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return t>>>=0,e||j(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||j(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||j(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||j(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||j(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readBigInt64LE=J((function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||X(t,this.length-8);const i=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),h.prototype.readBigInt64BE=J((function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||X(t,this.length-8);const i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),h.prototype.readFloatLE=function(t,e){return t>>>=0,e||j(t,4,this.length),n.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||j(t,4,this.length),n.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||j(t,8,this.length),n.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||j(t,8,this.length),n.read(this,t,!1,52,8)},h.prototype.writeUintLE=h.prototype.writeUIntLE=function(t,e,r,i){t=+t,e>>>=0,r>>>=0,i||S(this,t,e,r,Math.pow(2,8*r)-1,0);let n=1,s=0;for(this[e]=255&t;++s<r&&(n*=256);)this[e+s]=t/n&255;return e+r},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(t,e,r,i){t=+t,e>>>=0,r>>>=0,i||S(this,t,e,r,Math.pow(2,8*r)-1,0);let n=r-1,s=1;for(this[e+n]=255&t;--n>=0&&(s*=256);)this[e+n]=t/s&255;return e+r},h.prototype.writeUint8=h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigUInt64LE=J((function(t,e=0){return F(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeBigUInt64BE=J((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*r-1);S(this,t,e,r,i-1,-i)}let n=0,s=1,a=0;for(this[e]=255&t;++n<r&&(s*=256);)t<0&&0===a&&0!==this[e+n-1]&&(a=1),this[e+n]=(t/s|0)-a&255;return e+r},h.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*r-1);S(this,t,e,r,i-1,-i)}let n=r-1,s=1,a=0;for(this[e+n]=255&t;--n>=0&&(s*=256);)t<0&&0===a&&0!==this[e+n+1]&&(a=1),this[e+n]=(t/s|0)-a&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigInt64LE=J((function(t,e=0){return F(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeBigInt64BE=J((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,i){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);const n=i-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,i):Uint8Array.prototype.set.call(t,this.subarray(r,i),e),n},h.prototype.fill=function(t,e,r,i){if("string"==typeof t){if("string"==typeof e?(i=e,e=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!h.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){const e=t.charCodeAt(0);("utf8"===i&&e<128||"latin1"===i)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let n;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(n=e;n<r;++n)this[n]=t;else{const s=h.isBuffer(t)?t:h.from(t,i),a=s.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(n=0;n<r-e;++n)this[n+e]=s[n%a]}return this};const P={};function B(t,e,r){P[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function q(t){let e="",r=t.length;const i="-"===t[0]?1:0;for(;r>=i+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function $(t,e,r,i,n,s){if(t>r||t<e){const i="bigint"==typeof e?"n":"";let n;throw n=s>3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(s+1)}${i}`:`>= -(2${i} ** ${8*(s+1)-1}${i}) and < 2 ** ${8*(s+1)-1}${i}`:`>= ${e}${i} and <= ${r}${i}`,new P.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){H(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||X(e,t.length-(r+1))}(i,n,s)}function H(t,e){if("number"!=typeof t)throw new P.ERR_INVALID_ARG_TYPE(e,"number",t)}function X(t,e,r){if(Math.floor(t)!==t)throw H(t,r),new P.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new P.ERR_BUFFER_OUT_OF_BOUNDS;throw new P.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}B("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),B("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),B("ERR_OUT_OF_RANGE",(function(t,e,r){let i=`The value of "${t}" is out of range.`,n=r;return Number.isInteger(r)&&Math.abs(r)>2**32?n=q(String(r)):"bigint"==typeof r&&(n=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(n=q(n)),n+="n"),i+=` It must be ${e}. Received ${n}`,i}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function Q(t,e){let r;e=e||1/0;const i=t.length;let n=null;const s=[];for(let a=0;a<i;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(a+1===i){(e-=3)>-1&&s.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function V(t){return i.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,r,i){let n;for(n=0;n<i&&!(n+r>=e.length||n>=t.length);++n)e[n+r]=t[n];return n}function W(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const Z=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const i=16*r;for(let n=0;n<16;++n)e[i+n]=t[r]+t[n]}return e}();function J(t){return"undefined"==typeof BigInt?K:t}function K(){throw new Error("BigInt not supported")}},2504:(t,e)=>{"use strict";e.byteLength=function(t){var e=o(t),r=e[0],i=e[1];return 3*(r+i)/4-i},e.toByteArray=function(t){var e,r,s=o(t),a=s[0],h=s[1],l=new n(function(t,e,r){return 3*(e+r)/4-r}(0,a,h)),u=0,c=h>0?a-4:a;for(r=0;r<c;r+=4)e=i[t.charCodeAt(r)]<<18|i[t.charCodeAt(r+1)]<<12|i[t.charCodeAt(r+2)]<<6|i[t.charCodeAt(r+3)],l[u++]=e>>16&255,l[u++]=e>>8&255,l[u++]=255&e;return 2===h&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,l[u++]=255&e),1===h&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,l[u++]=e>>8&255,l[u++]=255&e),l},e.fromByteArray=function(t){for(var e,i=t.length,n=i%3,s=[],a=16383,o=0,l=i-n;o<l;o+=a)s.push(h(t,o,o+a>l?l:o+a));return 1===n?(e=t[i-1],s.push(r[e>>2]+r[e<<4&63]+"==")):2===n&&(e=(t[i-2]<<8)+t[i-1],s.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),s.join("")};for(var r=[],i=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)r[a]=s[a],i[s.charCodeAt(a)]=a;function o(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,i){for(var n,s,a=[],o=e;o<i;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),a.push(r[(s=n)>>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},3627:(t,e,r)=>{"use strict";r.d(e,{A:()=>l});var i=r(939),n=r(9390),s=r(1605),a=r(6866),o=r(362),h=r(546);class l extends s.A{constructor(t){if(super((0,o.E)(t)),(0,i.A)(this,"termType",a.Kk),(0,i.A)(this,"classOrder",n.A.NamedNode),!this.value)throw new Error("Missing IRI for NamedNode");if(!this.value.includes(":"))throw new Error('NamedNode IRI "'+t+'" must be absolute.');if(this.value.includes(" "))throw new Error('Error: NamedNode IRI "'+t+'" must not contain unencoded spaces.')}dir(){var t=this.value.split("#")[0],e=t.slice(0,-1).lastIndexOf("/"),r=t.indexOf("//");return r>=0&&e<r+2||e<0?null:new l(t.slice(0,e+1))}site(){var t=this.value.split("#")[0],e=t.indexOf("//");if(e<0)throw new Error("This URI does not have a web site part (origin)");var r=t.indexOf("/",e+2);return new l(r<0?t.slice(0)+"/":t.slice(0,r+1))}doc(){return this.value.indexOf("#")<0?this:new l(this.value.split("#")[0])}toString(){return"<"+this.value+">"}id(){return this.value.split("#")[1]}get uri(){return this.value}set uri(t){this.value=t}static fromValue(t){return null==t||(0,h.D0)(t)?t:new l(t)}}},3787:(t,e,r)=>{"use strict";r.d(e,{A:()=>i});const i={debug(t){},warn(t){},info(t){},error(t){},success(t){},msg(t){}}},4221:(t,e,r)=>{"use strict";r.r(e),r.d(e,{docpart:()=>s,document:()=>a,hostpart:()=>o,join:()=>h,protocol:()=>l,refTo:()=>u});var i=r(3627),n=n||console.log;function s(t){var e;return(e=t.indexOf("#"))<0?t:t.slice(0,e)}function a(t){return new i.A(s(t))}function o(t){var e=/[^\/]*\/\/([^\/]*)\//.exec(t);return e?e[1]:""}function h(t,e){var r,i,s,a,o,h=e.indexOf("#");if(h>0&&(e=e.slice(0,h)),0===t.length)return e;if(0===t.indexOf("#"))return e+t;if(t.indexOf(":")>=0)return t;if(r=e.indexOf(":"),0===e.length)return t;if(r<0)return n("Invalid base: "+e+" in join with given: "+t),t;if(i=e.slice(0,+r+1||9e9),0===t.indexOf("//"))return i+t;if(e.indexOf("//",r)===r+1){if((s=e.indexOf("/",r+3))<0)return e.length-r-3>0?e+"/"+t:i+t}else if((s=e.indexOf("/",r+1))<0)return e.length-r-1>0?e+"/"+t:i+t;if(0===t.indexOf("/"))return e.slice(0,s)+t;if((a=(o=e.slice(s)).lastIndexOf("/"))<0)return i+t;for(a>=0&&a<o.length-1&&(o=o.slice(0,+a+1||9e9)),o+=t;o.match(/[^\/]*\/\.\.\//);)o=o.replace(/[^\/]*\/\.\.\//,"");return o=(o=o.replace(/\.\//g,"")).replace(/\/\.$/,"/"),e.slice(0,s)+o}function l(t){const e=t.indexOf(":");return e<0?null:t.slice(0,e)}function u(t,e){var r,i,n,s,a,o,h,l,u,c,f,d,p=new RegExp("^[-_a-zA-Z0-9.]+:(//[^/]*)?/[^/]*$");if(!t)return e;if(t===e)return"";for(r=h=0,s=e.length;h<s&&e[r]===t[r];r=++h);if(t.slice(0,r).match(p)&&((i=e.indexOf("//"))<0&&(i=-2),n=e.indexOf("/",i+2),"/"!==e[n+1]&&"/"!==t[n+1]&&e.slice(0,n)===t.slice(0,n)))return e.slice(n);if("#"===e[r]&&t.length===r)return e.slice(r);for(;r>0&&"/"!==e[r-1];)r--;if(r<3)return e;if(t.indexOf("//",r-2)>0||e.indexOf("//",r-2)>0)return e;if(t.indexOf(":",r)>0)return e;for(o=0,l=0,a=(c=t.slice(r)).length;l<a;l++)"/"===c[l]&&o++;if(0===o&&r<e.length&&"#"===e[r])return"./"+e.slice(r);if(0===o&&r===e.length)return"./";if(d="",o>0)for(u=1,f=o;f>=1?u<=f:u>=f;f>=1?++u:--u)d+="../";return d+e.slice(r)}},6866:(t,e,r)=>{"use strict";r.d(e,{$Q:()=>n,BR:()=>g,Fn:()=>v,H:()=>T,JG:()=>y,K9:()=>b,Kk:()=>i,MG:()=>p,P2:()=>a,QW:()=>s,S:()=>l,_0:()=>m,bD:()=>u,bM:()=>w,hu:()=>x,i2:()=>f,ic:()=>o,lc:()=>c,ny:()=>d,r0:()=>h,sT:()=>_});const i="NamedNode",n="BlankNode",s="Literal",a="Variable",o="DefaultGraph",h="Collection",l="Empty",u="Graph",c="text/html",f="application/ld+json",d="text/n3",p="application/n3",g="application/nquads",m="application/n-quads",w="application/n-triples",y="application/rdf+xml",b="application/sparql-update",v="application/sparql-update-single-match",_="text/turtle",x="application/x-turtle",T="application/xhtml+xml"},7114:(t,e,r)=>{"use strict";r.r(e),r.d(e,{DOMParserFactory:()=>c,RDFArrayRemove:()=>b,callbackify:()=>u,domToString:()=>f,dtstamp:()=>p,dumpNode:()=>d,heavyCompare:()=>g,heavyCompareSPO:()=>m,linkRelationProperty:()=>l,log:()=>i.A,mediaTypeClass:()=>h,output:()=>w,parseXML:()=>y,stackString:()=>_,string:()=>o,string_startswith:()=>v,uri:()=>n});var i=r(3787),n=r(4221),s=r(3627),a=r(8392);t=r.hmd(t);const o={template:function(t,e){for(var r=t.split("%s"),i="",n=0;n<e.length;n++)e[n]+="",i+=r[n]+e[n];return i+r.slice(e.length).join()}};function h(t){return t=t.split(";")[0].trim(),new s.A("http://www.w3.org/ns/iana/media-types/"+t+"#Resource")}function l(t){return new s.A("http://www.w3.org/ns/iana/link-relations/relation#"+t.trim())}function u(t,e){t.callbacks={};for(var r=e.length-1;r>=0;r--)t.callbacks[e[r]]=[];t.addHook=function(e){t.callbacks[e]||(t.callbacks[e]=[])},t.addCallback=function(e,r){t.callbacks[e].push(r)},t.removeCallback=function(e,r){for(var i=0;i<t.callbacks[e].length;i++)if(t.callbacks[e][i].name===r)return t.callbacks[e].splice(i,1),!0;return!1},t.insertCallback=function(e,r){t.callbacks[e].unshift(r)},t.fireCallbacks=function(e,r){var i,n=[],s=[],a=t.callbacks[e].length;let o;for(i=a-1;i>=0;i--)o=t.callbacks[e][i],o&&o.apply(t,r)&&n.push(o);for(i=n.length-1;i>=0;i--)s.push(n[i]);for(i=a;i<t.callbacks[e].length;i++)s.push(t.callbacks[e][i]);t.callbacks[e]=s}}function c(){return window.DOMParser?new a.DOMParser:!!window.ActiveXObject&&new ActiveXObject("Microsoft.XMLDOM")}function f(t,e){var r=[];(e=e||{})&&e.selfClosing&&e.selfClosing.split(" ").forEach((function(t){r[t]=!0}));var i=[];return e&&e.skipAttributes&&e.skipAttributes.split(" ").forEach((function(t){i[t]=!0})),d(t,e,r,i)}function d(t,e,r,i){var n,s="",a=[!1];if(void 0===t.nodeType)return s;if(1===t.nodeType){if(t.hasAttribute("class")&&e&&e.classWithChildText&&t.matches(e.classWithChildText.class))s+=t.querySelector(e.classWithChildText.element).textContent;else if(!(e&&e.skipNodeWithClass&&t.matches("."+e.skipNodeWithClass))){var o=t.nodeName.toLowerCase();s+="<"+o;var h=[];for(n=t.attributes.length-1;n>=0;n--){var l=t.attributes[n];if(!(i&&i.length>0&&i[l.name]||/^\d+$/.test(l.name))){if("class"===l.name&&e&&e.replaceClassItemWith&&l.value.split(" ").indexOf(e.replaceClassItemWith.source)>-1){var u=new RegExp(e.replaceClassItemWith.source,"g");l.value=l.value.replace(u,e.replaceClassItemWith.target).trim()}"class"===l.name&&e&&e.skipClassWithValue&&e.skipClassWithValue===l.value||h.push(l.name+"='"+l.value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,""")+"'")}}if(h.length>0&&(e&&e.sortAttributes&&h.sort((function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())})),s+=" "+h.join(" ")),r&&r.ename)s+=" />";else{for(s+=">",s+="html"===o?"\n ":"",a.push("style"===o||"script"===o),n=0;n<t.childNodes.length;n++)s+=d(t.childNodes[n]);a.pop(),s+="body"===o?"</"+o+">\n":"</"+o+">"}}}else if(8===t.nodeType)s+="\x3c!--"+t.nodeValue+"--\x3e";else if(3===t.nodeType||4===t.nodeType){var c=t.nodeValue.replace(/\n+$/,"");s+=a[a.length-1]?c:c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}else console.log("Warning; Cannot handle serialising nodes of type: "+t.nodeType),console.log(t);return s}function p(){var t=new Date,e=t.getYear()+1900,r=t.getMonth()+1,i=t.getDate(),n=t.getUTCHours(),s=t.getUTCMinutes(),a=t.getSeconds();return r<10&&(r="0"+r),i<10&&(i="0"+i),n<10&&(n="0"+n),s<10&&(s="0"+s),a<10&&(a="0"+a),e+"-"+r+"-"+i+"T"+n+":"+s+":"+a+"Z"}function g(t,e,r,i){var n=function(t){return"BlankNode"===t.termType?null:t},s=function(t){var e=r.statementsMatching(t).map((function(t){return n(t.subject)+" "+n(t.predicate)+" "+n(t.object)})).concat(r.statementsMatching(void 0,void 0,t).map((function(t){return n(t.subject)+" "+n(t.predicate)+" "+n(t.object)})));return e.sort(),e.join("\n")};const a=Object.prototype.hasOwnProperty.call(r,"compareTerms")?r.compareTerms(t,e):t.compareTerm(e);return"BlankNode"===t.termType&&"BlankNode"===e.termType?0===a?0:s(t)>s(e)?1:s(t)<s(e)?-1:a:i&&t.uri&&e.uri?(i[t.uri]||t.uri).localeCompare(i[e.uri]||e.uri):a}function m(t,e,r,i){return g(t.subject,e.subject,r,i)||g(t.predicate,e.predicate,r,i)||g(t.object,e.object,r,i)}function w(t){var e=document.createElement("div");e.textContent=t,document.body.appendChild(e)}function y(e,r){return r=r||{},t&&t.exports?(new a.DOMParser).parseFromString(e,r.contentType||"application/xhtml+xml"):("undefined"!=typeof window&&window.DOMParser?new window.DOMParser:new a.DOMParser).parseFromString(e,"application/xml")}function b(t,e){for(var r=0;r<t.length;r++)if(t[r].subject.equals(e.subject)&&t[r].predicate.equals(e.predicate)&&t[r].object.equals(e.object)&&t[r].why.equals(e.why))return void t.splice(r,1);throw new Error("RDFArrayRemove: Array did not contain "+e+" "+e.why)}function v(t,e){return t.slice(0,e.length)===e}function _(t){var e=t+"\n";if(!t.stack)return e+"No stack available.\n";for(var r=t.stack.toString().split("\n"),i=[],n=0;n<r.length;n++){var s=r[n];if(s.indexOf("ecmaunit.js")>-1)break;"("==s.charAt(0)&&(s="function"+s);var a=s.split("@");i.push(a)}for(n=0;n<i.length;n++)e+=" "+i[n][1]+"\n "+i[n][0];return e}},8392:e=>{"use strict";e.exports=t},8540:t=>{const e={acl:"http://www.w3.org/ns/auth/acl#",arg:"http://www.w3.org/ns/pim/arg#",as:"https://www.w3.org/ns/activitystreams#",bookmark:"http://www.w3.org/2002/01/bookmark#",cal:"http://www.w3.org/2002/12/cal/ical#",cco:"http://www.ontologyrepository.com/CommonCoreOntologies/",cert:"http://www.w3.org/ns/auth/cert#",contact:"http://www.w3.org/2000/10/swap/pim/contact#",dc:"http://purl.org/dc/elements/1.1/",dct:"http://purl.org/dc/terms/",doap:"http://usefulinc.com/ns/doap#",foaf:"http://xmlns.com/foaf/0.1/",geo:"http://www.w3.org/2003/01/geo/wgs84_pos#",gpx:"http://www.w3.org/ns/pim/gpx#",gr:"http://purl.org/goodrelations/v1#",http:"http://www.w3.org/2007/ont/http#",httph:"http://www.w3.org/2007/ont/httph#",icalTZ:"http://www.w3.org/2002/12/cal/icaltzd#",ldp:"http://www.w3.org/ns/ldp#",link:"http://www.w3.org/2007/ont/link#",log:"http://www.w3.org/2000/10/swap/log#",meeting:"http://www.w3.org/ns/pim/meeting#",mo:"http://purl.org/ontology/mo/",org:"http://www.w3.org/ns/org#",owl:"http://www.w3.org/2002/07/owl#",pad:"http://www.w3.org/ns/pim/pad#",patch:"http://www.w3.org/ns/pim/patch#",prov:"http://www.w3.org/ns/prov#",pto:"http://www.productontology.org/id/",qu:"http://www.w3.org/2000/10/swap/pim/qif#",trip:"http://www.w3.org/ns/pim/trip#",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",rss:"http://purl.org/rss/1.0/",sched:"http://www.w3.org/ns/pim/schedule#",schema:"http://schema.org/",sioc:"http://rdfs.org/sioc/ns#",skos:"http://www.w3.org/2004/02/skos/core#",solid:"http://www.w3.org/ns/solid/terms#",space:"http://www.w3.org/ns/pim/space#",stat:"http://www.w3.org/ns/posix/stat#",tab:"http://www.w3.org/2007/ont/link#",tabont:"http://www.w3.org/2007/ont/link#",ui:"http://www.w3.org/ns/ui#",vann:"http://purl.org/vocab/vann/",vcard:"http://www.w3.org/2006/vcard/ns#",wf:"http://www.w3.org/2005/01/wf/flow#",xsd:"http://www.w3.org/2001/XMLSchema#"};t.exports=function(t={namedNode:t=>t}){const r={};for(const i in e){const n=e[i];r[i]=function(e=""){return t.namedNode(n+e)}}return r}},9029:(t,e)=>{e.read=function(t,e,r,i,n){var s,a,o=8*n-i-1,h=(1<<o)-1,l=h>>1,u=-7,c=r?n-1:0,f=r?-1:1,d=t[e+c];for(c+=f,s=d&(1<<-u)-1,d>>=-u,u+=o;u>0;s=256*s+t[e+c],c+=f,u-=8);for(a=s&(1<<-u)-1,s>>=-u,u+=i;u>0;a=256*a+t[e+c],c+=f,u-=8);if(0===s)s=1-l;else{if(s===h)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,i),s-=l}return(d?-1:1)*a*Math.pow(2,s-i)},e.write=function(t,e,r,i,n,s){var a,o,h,l=8*s-n-1,u=(1<<l)-1,c=u>>1,f=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:s-1,p=i?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=u):(a=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-a))<1&&(a--,h*=2),(e+=a+c>=1?f/h:f*Math.pow(2,1-c))*h>=2&&(a++,h/=2),a+c>=u?(o=0,a=u):a+c>=1?(o=(e*h-1)*Math.pow(2,n),a+=c):(o=e*Math.pow(2,c-1)*Math.pow(2,n),a=0));n>=8;t[r+d]=255&o,d+=p,o/=256,n-=8);for(a=a<<n|o,l+=n;l>0;t[r+d]=255&a,d+=p,a/=256,l-=8);t[r+d-p]|=128*g}},9390:(t,e,r)=>{"use strict";r.d(e,{A:()=>i});const i={Literal:1,Collection:3,Graph:4,NamedNode:5,BlankNode:6,Variable:7}}},a={};function o(t){var e=a[t];if(void 0!==e)return e.exports;var r=a[t]={id:t,loaded:!1,exports:{}};return s[t].call(r.exports,r,r.exports,o),r.loaded=!0,r.exports}o.m=s,o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},r=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,o.t=function(t,i){if(1&i&&(t=this(t)),8&i)return t;if("object"==typeof t&&t){if(4&i&&t.__esModule)return t;if(16&i&&"function"==typeof t.then)return t}var n=Object.create(null);o.r(n);var s={};e=e||[null,r({}),r([]),r(r)];for(var a=2&i&&t;("object"==typeof a||"function"==typeof a)&&!~e.indexOf(a);a=r(a))Object.getOwnPropertyNames(a).forEach((e=>s[e]=()=>t[e]));return s.default=()=>t,o.d(n,s),n},o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.f={},o.e=t=>Promise.all(Object.keys(o.f).reduce(((e,r)=>(o.f[r](t,e),e)),[])),o.u=t=>t+".rdflib.min.js",o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i={},n="$rdf:",o.l=(t,e,r,s)=>{if(i[t])i[t].push(e);else{var a,h;if(void 0!==r)for(var l=document.getElementsByTagName("script"),u=0;u<l.length;u++){var c=l[u];if(c.getAttribute("src")==t||c.getAttribute("data-webpack")==n+r){a=c;break}}a||(h=!0,(a=document.createElement("script")).charset="utf-8",o.nc&&a.setAttribute("nonce",o.nc),a.setAttribute("data-webpack",n+r),a.src=t),i[t]=[e];var f=(e,r)=>{a.onerror=a.onload=null,clearTimeout(d);var n=i[t];if(delete i[t],a.parentNode&&a.parentNode.removeChild(a),n&&n.forEach((t=>t(r))),e)return e(r)},d=setTimeout(f.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=f.bind(null,a.onerror),a.onload=f.bind(null,a.onload),h&&document.head.appendChild(a)}},o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;o.g.importScripts&&(t=o.g.location+"");var e=o.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var i=r.length-1;i>-1&&(!t||!/^http(s?):/.test(t));)t=r[i--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=t})(),(()=>{var t={792:0};o.f.j=(e,r)=>{var i=o.o(t,e)?t[e]:void 0;if(0!==i)if(i)r.push(i[2]);else{var n=new Promise(((r,n)=>i=t[e]=[r,n]));r.push(i[2]=n);var s=o.p+o.u(e),a=new Error;o.l(s,(r=>{if(o.o(t,e)&&(0!==(i=t[e])&&(t[e]=void 0),i)){var n=r&&("load"===r.type?"missing":r.type),s=r&&r.target&&r.target.src;a.message="Loading chunk "+e+" failed.\n("+n+": "+s+")",a.name="ChunkLoadError",a.type=n,a.request=s,i[1](a)}}),"chunk-"+e,e)}};var e=(e,r)=>{var i,n,[s,a,h]=r,l=0;if(s.some((e=>0!==t[e]))){for(i in a)o.o(a,i)&&(o.m[i]=a[i]);h&&h(o)}for(e&&e(r);l<s.length;l++)n=s[l],o.o(t,n)&&t[n]&&t[n][0](),t[n]=0},r=self.webpackChunk$rdf=self.webpackChunk$rdf||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))})();var h={};return(()=>{"use strict";o.r(h),o.d(h,{BlankNode:()=>n,Collection:()=>f,ConnectedStore:()=>rr,DataFactory:()=>Le,Empty:()=>d,Fetcher:()=>Oe,Formula:()=>P,IndexedFormula:()=>G,Literal:()=>u,LiveStore:()=>ir,N3Parser:()=>yt,NamedNode:()=>s.A,Namespace:()=>E,NextId:()=>er,Node:()=>B,Query:()=>$,RDFParser:()=>ce,RDFaProcessor:()=>le,SPARQLToQuery:()=>Fe,Serializer:()=>j,Statement:()=>y,Store:()=>G,UpdateManager:()=>Ue,UpdatesSocket:()=>Me,UpdatesVia:()=>Pe,Util:()=>C,Variable:()=>v,blankNode:()=>Ve,defaultGraph:()=>Ge,fetcher:()=>qe,fromNT:()=>Ke,graph:()=>$e,isBlankNode:()=>a.jt,isCollection:()=>a.P3,isGraph:()=>a.RN,isLiteral:()=>a.c$,isNamedNode:()=>a.Y2,isPredicate:()=>a.YC,isQuad:()=>a.aF,isRDFObject:()=>a.GE,isRDFlibObject:()=>a.DJ,isRDFlibPredicate:()=>a.fY,isRDFlibSubject:()=>a.CZ,isStatement:()=>a.SH,isStore:()=>a.ok,isSubject:()=>a.hr,isTerm:()=>a.D0,isVariable:()=>a.DZ,jsonParser:()=>je,lit:()=>He,literal:()=>We,log:()=>N.A,namedNode:()=>ze,parse:()=>de,quad:()=>Ye,queryToSPARQL:()=>Se,serialize:()=>F,sparqlUpdateParser:()=>fe,st:()=>Xe,sym:()=>ze,term:()=>tr,termValue:()=>me.E,triple:()=>Ze,uri:()=>b,variable:()=>Qe});var t=o(939),e=o(9390),r=o(1605),i=o(6866);class n extends r.A{static getId(t){if(t){if("string"!=typeof t)throw new Error("Bad id argument to new blank node: "+t);if(t.includes("#")){let e=t.split("#");return e[e.length-1]}return t}return"n"+n.nextId++}constructor(r){super(n.getId(r)),(0,t.A)(this,"termType",i.$Q),(0,t.A)(this,"classOrder",e.A.BlankNode),(0,t.A)(this,"isBlank",1),(0,t.A)(this,"isVar",1)}get id(){return this.value}set id(t){this.value=t}compareTerm(t){return this.classOrder<t.classOrder?-1:this.classOrder>t.classOrder?1:this.id<t.id?-1:this.id>t.id?1:0}copy(t){var e=new n;return t.copyTo(this,e),e}toCanonical(){return n.NTAnonymousNodePrefix+this.value}toString(){return n.NTAnonymousNodePrefix+this.id}}(0,t.A)(n,"nextId",0),(0,t.A)(n,"NTAnonymousNodePrefix","_:");var s=o(3627),a=o(546);const l={boolean:new s.A("http://www.w3.org/2001/XMLSchema#boolean"),dateTime:new s.A("http://www.w3.org/2001/XMLSchema#dateTime"),decimal:new s.A("http://www.w3.org/2001/XMLSchema#decimal"),double:new s.A("http://www.w3.org/2001/XMLSchema#double"),integer:new s.A("http://www.w3.org/2001/XMLSchema#integer"),langString:new s.A("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),string:new s.A("http://www.w3.org/2001/XMLSchema#string")};class u extends r.A{constructor(r,n,a){super(r),(0,t.A)(this,"termType",i.QW),(0,t.A)(this,"classOrder",e.A.Literal),(0,t.A)(this,"datatype",l.string),(0,t.A)(this,"isVar",0),(0,t.A)(this,"language",""),n?(this.language=n,this.datatype=l.langString):this.datatype=a?s.A.fromValue(a):l.string}copy(){return new u(this.value,this.lang,this.datatype)}equals(t){return!!t&&this.termType===t.termType&&this.value===t.value&&this.language===t.language&&(!this.datatype&&!t.datatype||this.datatype&&this.datatype.equals(t.datatype))}get lang(){return this.language}set lang(t){this.language=t||""}toNT(){return u.toNT(this)}static toNT(t){if("number"==typeof t.value)return""+t.value;if("string"!=typeof t.value)throw new Error("Value of RDF literal is not string or number: "+t.value);var e=t.value;return e='"'+(e=(e=(e=(e=e.replace(/\\/g,"\\\\")).replace(/\"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r"))+'"',t.language?e+="@"+t.language:t.datatype.equals(l.string)||(e+="^^"+t.datatype.toCanonical()),e}toString(){return""+this.value}static fromBoolean(t){return new u(t?"1":"0",null,l.boolean)}static fromDate(t){if(!(t instanceof Date))throw new TypeError("Invalid argument to Literal.fromDate()");let e=function(t){return(""+(100+t)).slice(1,3)},r=t.getUTCFullYear()+"-"+e(t.getUTCMonth()+1)+"-"+e(t.getUTCDate())+"T"+e(t.getUTCHours())+":"+e(t.getUTCMinutes())+":"+e(t.getUTCSeconds())+"Z";return new u(r,null,l.dateTime)}static fromNumber(t){if("number"!=typeof t)throw new TypeError("Invalid argument to Literal.fromNumber()");let e;const r=t.toString();return e=r.indexOf("e")<0&&Math.abs(t)<=Number.MAX_SAFE_INTEGER?Number.isInteger(t)?l.integer:l.decimal:l.double,new u(r,null,e)}static fromValue(t){if((0,a.c$)(t))return t;switch(typeof t){case"object":if(t instanceof Date)return u.fromDate(t);case"boolean":return u.fromBoolean(t);case"number":return u.fromNumber(t);case"string":return new u(t)}throw new Error("Can't make literal from "+t+" of type "+typeof t)}}function c(t){return null==t||(0,a.D0)(t)?t:Array.isArray(t)?new f(t):u.fromValue(t)}class f extends r.A{constructor(r){super((n.nextId++).toString()),(0,t.A)(this,"termType",i.r0),(0,t.A)(this,"classOrder",e.A.Collection),(0,t.A)(this,"closed",!1),(0,t.A)(this,"compareTerm",n.prototype.compareTerm),(0,t.A)(this,"elements",[]),(0,t.A)(this,"isVar",0),r&&r.length>0&&r.forEach((t=>{this.elements.push(c(t))}))}get id(){return this.value}set id(t){this.value=t}append(t){return this.elements.push(t)}close(){return this.closed=!0,this.closed}shift(){return this.elements.shift()}substitute(t){const e=this.elements.map((e=>e.substitute(t)));return new f(e)}toNT(){return f.toNT(this)}static toNT(t){return n.NTAnonymousNodePrefix+t.id}toString(){return"("+this.elements.join(" ")+")"}unshift(t){return this.elements.unshift(t)}}(0,t.A)(f,"termType",i.r0);class d extends r.A{constructor(){super(""),(0,t.A)(this,"termType",i.S)}toString(){return"()"}}const p="chrome:theSession";new s.A(p);class g extends r.A{constructor(){super(""),(0,t.A)(this,"value",""),(0,t.A)(this,"termType",i.ic),(0,t.A)(this,"uri",p)}toCanonical(){return this.value}toString(){return"DefaultGraph"}}function m(t){return!!t&&t.termType===i.ic}const w=new g;class y{constructor(e,i,n,s){(0,t.A)(this,"subject",void 0),(0,t.A)(this,"predicate",void 0),(0,t.A)(this,"object",void 0),(0,t.A)(this,"graph",void 0),this.subject=r.A.fromValue(e),this.predicate=r.A.fromValue(i),this.object=r.A.fromValue(n),this.graph=null==s?w:r.A.fromValue(s)}get why(){return this.graph}set why(t){this.graph=t}equals(t){return t.subject.equals(this.subject)&&t.predicate.equals(this.predicate)&&t.object.equals(this.object)&&t.graph.equals(this.graph)}substitute(t){return new y(this.subject.substitute(t),this.predicate.substitute(t),this.object.substitute(t),m(this.graph)?this.graph:this.graph.substitute(t))}toCanonical(){let t=[this.subject.toCanonical(),this.predicate.toCanonical(),this.object.toCanonical()];return this.graph&&this.graph.termType!==i.ic&&t.push(this.graph.toCanonical()),t.join(" ")+" ."}toNT(){return[this.subject.toNT(),this.predicate.toNT(),this.object.toNT()].join(" ")+" ."}toNQ(){return[this.subject.toNT(),this.predicate.toNT(),this.object.toNT(),m(this.graph)?"":this.graph.toNT()].join(" ")+" ."}toString(){return this.toNT()}}var b=o(4221);class v extends r.A{constructor(r=""){super(r),(0,t.A)(this,"termType",i.P2),(0,t.A)(this,"base","varid:"),(0,t.A)(this,"classOrder",e.A.Variable),(0,t.A)(this,"isVar",1),(0,t.A)(this,"uri",void 0),this.base="varid:",this.uri=b.join(r,this.base)}equals(t){return!!t&&this.termType===t.termType&&this.value===t.value}hashString(){return this.toString()}substitute(t){var e;return null!=(e=t[this.toNT()])?e:this}toString(){return v.toString(this)}static toString(t){return t.uri.slice(0,t.base.length)===t.base?`?${t.uri.slice(t.base.length)}`:`?${t.uri}`}}let _=function(t){return t.collections="COLLECTIONS",t.defaultGraphType="DEFAULT_GRAPH_TYPE",t.equalsMethod="EQUALS_METHOD",t.id="ID",t.identity="IDENTITY",t.reversibleId="REVERSIBLE_ID",t.variableType="VARIABLE_TYPE",t}({});const x=new g,T={supports:{[_.collections]:!1,[_.defaultGraphType]:!1,[_.equalsMethod]:!0,[_.identity]:!1,[_.id]:!0,[_.reversibleId]:!1,[_.variableType]:!0},blankNode:t=>new n(t),defaultGraph:()=>x,equals(t,e){return t===e||!t||!e||((0,a.aF)(t)||(0,a.aF)(e)?!(!(0,a.aF)(t)||!(0,a.aF)(e))&&this.equals(t.subject,e.subject)&&this.equals(t.predicate,e.predicate)&&this.equals(t.object,e.object)&&this.equals(t.graph,e.graph):!(!(0,a.D0)(t)||!(0,a.D0)(e))&&this.id(t)===this.id(e))},id(t){if(!t)return"undefined";if((0,a.aF)(t))return this.quadToNQ(t);switch(t.termType){case i.ic:return"defaultGraph";case i.P2:return v.toString(t);default:const e=this.termToNQ(t);if(e)return e;throw new Error(`Can't id term with type '${t.termType}'`)}},isQuad:t=>t instanceof y,literal(t,e){if("string"!=typeof t&&!e)return u.fromValue(t);const r="string"==typeof t?t:""+t;return"string"==typeof e?-1===e.indexOf(":")?new u(r,e):new u(r,null,this.namedNode(e)):new u(r,null,e)},namedNode:t=>new s.A(t),quad:(t,e,r,i)=>new y(t,e,r,i||x),triple(t,e,r,i){return this.quad(t,e,r,i)},quadToNQ(t){return`${this.termToNQ(t.subject)} ${this.termToNQ(t.predicate)} ${this.termToNQ(t.object)} ${this.termToNQ(t.graph)} .`},termToNQ(t){switch(t.termType){case i.$Q:return"_:"+t.value;case i.ic:return"";case i.S:return"<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>";case i.QW:return u.toNT(t);case i.bD:case i.Kk:return"<"+t.value+">";case i.r0:return"("+t.elements.map((t=>this.termToNQ(t))).join(" ")+")";default:throw new Error(`Can't serialize nonstandard term type (was '${t.termType}')`)}},toNQ(t){return this.isQuad(t)?this.quadToNQ(t):this.termToNQ(t)},variable:t=>new v(t)},A=T;var N=o(3787);function E(t,e){const r=e||{namedNode:t=>new s.A(t)};return function(e){return r.namedNode(t+(e||""))}}var R=o(2312),k=o(8540),I=o.n(k),C=o(7114);function O(t=A){return{boolean:t.namedNode("http://www.w3.org/2001/XMLSchema#boolean"),dateTime:t.namedNode("http://www.w3.org/2001/XMLSchema#dateTime"),decimal:t.namedNode("http://www.w3.org/2001/XMLSchema#decimal"),double:t.namedNode("http://www.w3.org/2001/XMLSchema#double"),integer:t.namedNode("http://www.w3.org/2001/XMLSchema#integer"),langString:t.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),string:t.namedNode("http://www.w3.org/2001/XMLSchema#string")}}function j(t){return new S(t)}O(A);class S{constructor(e){(0,t.A)(this,"_notQNameChars","\t\r\n !\"#$%&'()*,+/;<=>?@[\\]^`{|}~"),(0,t.A)(this,"_notNameChars",this._notQNameChars+":"),(0,t.A)(this,"validPrefix",new RegExp(/^[a-zA-Z][a-zA-Z0-9]*$/)),(0,t.A)(this,"forbidden1",new RegExp(/[\\"\b\f\r\v\t\n\u0080-\uffff]/gm)),(0,t.A)(this,"forbidden3",new RegExp(/[\\"\b\f\r\v\u0080-\uffff]/gm)),this.flags="",this.base=null,this.prefixes=[],this.namespaces=[];const r=Object.keys(I()());for(const t in r){const e=I()()[r[t]](""),i=r[t];this.prefixes[e]=i,this.namespaces[i]=e}this.suggestPrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#"),this.suggestPrefix("xml","reserved:reservedForFutureUse"),this.namespacesUsed=[],this.keywords=["a"],this.prefixchars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",this.incoming=null,this.formulas=[],this.store=e,this.rdfFactory=e.rdfFactory||A,this.xsd=O(this.rdfFactory)}setBase(t){return this.base=t,this}setFlags(t){return this.flags=t||"",this}toStr(t){var e=t.toNT();return"Graph"===t.termType&&(this.formulas[e]=t),e}fromStr(t){if("{"===t[0]){var e=this.formulas[t];return e||console.log("No formula object for "+t),e}return this.store.fromNT(t)}setNamespaces(t){for(var e in t)this.setPrefix(e,t[e]);return this}setPrefix(t,e){if("default"!==t.slice(0,7)&&"ns"!==t.slice(0,2)&&t&&e){for(let e in this.prefixes)this.prefixes[e]==t&&delete this.prefixes[e];this.prefixes[e]=t,this.namespaces[t]=e}}suggestPrefix(t,e){"default"!==t.slice(0,7)&&"ns"!==t.slice(0,2)&&t&&e&&(t in this.namespaces||e in this.prefixes||(this.prefixes[e]=t,this.namespaces[t]=e))}suggestNamespaces(t){for(var e in t)this.suggestPrefix(e,t[e]);return this}checkIntegrity(){var t,e;for(t in this.namespaces)if(this.prefixes[this.namespaces[t]]!==t)throw new Error("Serializer integity error 1: "+t+", "+this.namespaces[t]+", "+this.prefixes[this.namespaces[t]]+"!");for(e in this.prefixes)if(this.namespaces[this.prefixes[e]]!==e)throw new Error("Serializer integity error 2: "+e+", "+this.prefixs[e]+", "+this.namespaces[this.prefixes[e]]+"!")}makeUpPrefix(t){var e=t,r=function(e){return!!this.validPrefix.test(e)&&"ns"!==e&&!(e in this.namespaces)&&(this.prefixes[t]=e,this.namespaces[e]=t,e)}.bind(this);"#/".indexOf(e[e.length-1])>=0&&(e=e.slice(0,-1));var i=e.lastIndexOf("/");i>=0&&(e=e.slice(i+1));for(var n=0;n<e.length&&this.prefixchars.indexOf(e[n])>=0;)n++;if((e=e.slice(0,n)).length<6&&r(e))return e;if(r(e.slice(0,3)))return e.slice(0,3);if(r(e.slice(0,2)))return e.slice(0,2);if(r(e.slice(0,4)))return e.slice(0,4);if(r(e.slice(0,1)))return e.slice(0,1);if(r(e.slice(0,5)))return e.slice(0,5);this.validPrefix.test(e)||(e="n");for(var s=0;;s++)if(r(e.slice(0,3)+s))return e.slice(0,3)+s}rootSubjects(t){for(var e={},r={},i={},n=0;n<t.length;n++){var s=t[n],a=function(t){e.hasOwnProperty(t)||(e[t]=[]),e[t].push(s.subject)};[s.subject,s.predicate,s.object].map((function(t){"BlankNode"===t.termType?i[t.toNT()]=!0:"Collection"===t.termType&&t.elements.forEach((function(t){a(t)}))})),a(t[n].object);var o=r[this.toStr(s.subject)];o||(o=[]),o.push(s),r[this.toStr(s.subject)]=o}var h=[];for(var l in r)if(r.hasOwnProperty(l)){var u=this.fromStr(l);"BlankNode"===u.termType&&e[u]&&1===e[u].length||h.push(u)}this.incoming=e;for(var c={},f=0;f<h.length;f++)c[h[f].toNT()]=!0;return{roots:h,subjects:r,rootsHash:c,incoming:e}}toN3(t){return this.statementsToN3(t.statements)}isValidPNLocal(t){if(0===t.length)return!0;if("."===t[t.length-1])return!1;for(var e=0;e<t.length;e++){var r=t[e];if("."!==r&&this._notNameChars.indexOf(r)>=0)return!1}return!0}explicitURI(t){var e;return this.flags.indexOf("r")<0&&this.base?t=b.refTo(this.base,t):this.flags.indexOf("u")>=0?t=function(t){for(var e,r="",i=0;i<t.length;i++)r+=(e=t.charCodeAt(i))>65535?"\\U"+("00000000"+e.toString(16)).slice(-8):e>126?"\\u"+("0000"+e.toString(16)).slice(-4):t[i];return r}(t):(e=decodeURI(t),t=encodeURI(e)),"<"+t+">"}statementsToNTriples(t){var e=t.slice();e.sort();for(var r="",i="http://www.w3.org/1999/02/22-rdf-syntax-ns#",n=this,s=this.store,a=this.rdfFactory,o=function(t){if("Collection"!==t.termType)return n.atomicTermToN3(t);for(var e=t.elements,h=s.sym(i+"nill"),l=e.length-1;l>=0;l--){var u=a.blankNode();r+=o(u)+" "+o(s.sym(i+"first"))+" "+o(e[l])+".\n",r+=o(u)+" "+o(s.sym(i+"rest"))+" "+o(h)+".\n",h=u}return n.atomicTermToN3(h)},h=0;h<e.length;h++){var l=e[h],u="";u+=o(l.subject)+" ",u+=o(l.predicate)+" ",u+=o(l.object)+" ",this.flags.indexOf("q")>=0&&(u+=o(l.why)+" "),r+=u+=".\n"}return r}statementsToN3(t){var e=this.store,r={"http://www.w3.org/1999/02/22-rdf-syntax-ns#type":"aaa:00"};t.sort((function(t,i){return C.heavyCompareSPO(t,i,e,r)})),this.base&&!this.defaultNamespace&&(this.defaultNamespace=this.base+"#");var i={};this.flags.indexOf("s")<0&&(i["http://www.w3.org/2002/07/owl#sameAs"]="="),this.flags.indexOf("t")<0&&(i["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]="a"),this.flags.indexOf("i")<0&&(i["http://www.w3.org/2000/10/swap/log#implies"]="=>");var n=function(t){for(var e="",r=0;r<t;r++)e+=" ";return e},s=function(t){for(var e="",r=0;r<t.length;r++){var i=t[r],n="string"==typeof i?i:s(i);if(0!==r){var a=e.slice(-1)||" ";","===n||";"===n||("."!==n||"0123456789.:".includes(a))&&(e+=" ")}e+=n}return e},a=function(t,e){var r="",i=1e5;void 0===e&&(e=-1);for(var o=0;o<t.length;o++){var h=t[o];if("string"!=typeof h){var l=a(h,e+1);if(l.length<10*(80-4*e)&&l.indexOf('"""')<0){var u=s(h);u.length<80-4*e&&(h=u,l="")}l&&(i=1e4),r+=l}if("string"==typeof h){if(1===h.length&&"\n"===r.slice(-1)&&",.;".indexOf(h)>=0){r=r.slice(0,-1),"."==h&&"0123456789.:".includes(r.charAt(r.length-1))&&(r+=" ",i+=1),r+=h+"\n",i+=1;continue}if(i<4*e+4||i+h.length+1<80&&";.".indexOf(r[r.length-2])<0)r=r.slice(0,-1)+" "+h+"\n",i+=h.length+1;else{let t=n(4*e)+h;r+=t+"\n",i=t.length,e<0&&(r+="\n",i=1e5)}}}return r},o=function(t){for(var e=this.rootSubjects(t),r=e.roots,i=[],n=0;n<r.length;n++){var s=r[n];i.push(h(s,e))}return i}.bind(this);function h(t,e){return"BlankNode"!==t.termType||e.incoming[t]?[c(t,e)].concat([l(t,e)]).concat(["."]):u(t,e,!0).concat(["."])}var l=function(t,e){var r=[],n=null,s=e.subjects[this.toStr(t)]||[];if(void 0===s)throw new Error("Cant find statements for "+t);for(var a=[],o=0;o<s.length;o++){var h=s[o];h.predicate.uri===n?a.push(","):(n&&(r=r.concat([a]).concat([";"]),a=[]),r.push(i[h.predicate.uri]?i[h.predicate.uri]:c(h.predicate,e))),n=h.predicate.uri,a.push(u(h.object,e))}return r.concat([a])}.bind(this),u=function(t,e,r){return"BlankNode"!==t.termType||!r&&void 0!==e.rootsHash[t.toNT()]?c(t,e):e.subjects[this.toStr(t)]?["[",l(t,e),"]"]:"[]"}.bind(this);S.prototype.termToN3=c;var c=function(t,e){var r,i;switch(t.termType){case"Graph":return(i=(i=["{"]).concat(o(t.statements))).concat(["}"]);case"Collection":for(i=["("],r=0;r<t.elements.length;r++)i.push([u(t.elements[r],e)]);return i.push(")"),i;default:return this.atomicTermToN3(t)}}.bind(this),f=function(){var t="";for(var e in this.flags.indexOf("d")<0&&this.defaultNamespace&&(t+="@prefix : "+this.explicitURI(this.defaultNamespace)+".\n"),this.prefixes)this.prefixes.hasOwnProperty(e)&&this.namespacesUsed[e]&&(t+="@prefix "+this.prefixes[e]+": "+this.explicitURI(e)+".\n");return t+"\n"}.bind(this),d=o(t);return f()+a(d)}atomicTermToN3(t,e){switch(t.termType){case"BlankNode":case"Variable":return t.toNT();case"Literal":var r=t.value;if("string"!=typeof r)throw new TypeError("Value of RDF literal node must be a string");if(t.datatype&&this.flags.indexOf("x")<0)switch(t.datatype.uri){case"http://www.w3.org/2001/XMLSchema#integer":return r;case"http://www.w3.org/2001/XMLSchema#decimal":return r.indexOf(".")<0&&(r+=".0"),r;case"http://www.w3.org/2001/XMLSchema#double":{const t=r.toLowerCase().indexOf("e")>0;return r.indexOf(".")<0&&!t&&(r+=".0"),t||(r+="e0"),r}case"http://www.w3.org/2001/XMLSchema#boolean":return"1"===t.value?"true":"false"}var i=this.stringToN3(t.value,this.flags);return t.language?i+="@"+t.language:t.datatype.equals(this.xsd.string)||(i+="^^"+this.atomicTermToN3(t.datatype,e)),i;case"NamedNode":return this.symbolToN3(t);case"DefaultGraph":return"";default:throw new Error("Internal: atomicTermToN3 cannot handle "+t+" of termType: "+t.termType)}}stringToN3(t,e){e||(e="e");var r,i,n,s,a,o="";for(t.length>20&&'"'!==t.slice(-1)&&e.indexOf("n")<0&&(t.indexOf("\n")>0||t.indexOf('"')>0)?(s='"""',a=this.forbidden3):(s='"',a=this.forbidden1),r=0;r<t.length&&(a.lastIndex=0,null!=a.exec(t.slice(r)));){i=r+a.lastIndex-1,o+=t.slice(r,i);var h=t[i];'"'===h&&'"""'===s&&'"""'!==t.slice(i,i+3)?o+=h:(n='\b\f\r\t\v\n\\"'.indexOf(h))>=0?o+="\\"+'bfrtvn\\"'[n]:e.indexOf("e")>=0?o+="\\u"+("000"+h.charCodeAt(0).toString(16).toLowerCase()).slice(-4):o+=h,r=i+1}return s+o+t.slice(r)+s}symbolToN3(t){var e=t.uri,r=e.indexOf("#");if(r<0&&this.flags.indexOf("/")<0&&(r=e.lastIndexOf("/")),r>=0&&this.flags.indexOf("p")<0&&(0===e.indexOf("http")||0===e.indexOf("ws")||0===e.indexOf("file"))){var i=e.slice(r+1),n=e.slice(0,r+1),s=e.indexOf("://")+4,a=this.base?this.base.slice(0,Math.max(this.base.lastIndexOf("/"),this.base.lastIndexOf("#"))+1):null,o=a&&n===a,h=this.flags.indexOf("o")>=0&&i.indexOf(".")>=0;if(!o&&!h&&n.length>s&&this.isValidPNLocal(i)){if(this.defaultNamespace&&this.defaultNamespace===n&&this.flags.indexOf("d")<0)return this.flags.indexOf("k")>=0&&this.keyords.indexOf(i)<0?i:":"+i;var l=this.prefixes[n];if(l||(l=this.makeUpPrefix(n)),l)return this.namespacesUsed[n]=!0,l+":"+i}}return this.explicitURI(e)}writeStore(t){var e=this.store,r=e.fetcher,i=r&&r.appNode,n=this.store.index[3];for(var s in n){var a=e.fromNT(s);i&&a.equals(i)||t("\n"+this.atomicTermToN3(a)+" "+this.atomicTermToN3(e.sym("http://www.w3.org/2000/10/swap/log#semantics"))+" { "+this.statementsToN3(e.statementsMatching(void 0,void 0,void 0,a))+" }.\n")}e.statementsMatching(void 0,e.sym("http://www.w3.org/2007/ont/link#requestedURI")).map((function(r){t("\n<"+r.object.value+"> log:metadata {\n");var i=e.statementsMatching(void 0,void 0,void 0,r.subject);t(this.statementsToN3(this.statementsToN3(i))),t("}.\n")}));var o=[];i&&o.push(i);var h=[];o.map((function(t){h=h.concat(e.statementsMatching(void 0,void 0,void 0,t))})),t(this.statementsToN3(h))}statementsToXML(t){var e=[];e["http://www.w3.org/1999/02/22-rdf-syntax-ns#"]=!0;var r="http://www.w3.org/1999/02/22-rdf-syntax-ns#_",i=function(t){for(var e="",r=0;r<t;r++)e+=" ";return e},n=function(t){for(var e="",r=0;r<t.length;r++){var i=t[r];e+="string"==typeof i?i:n(i)}return e},s=function(t,e){var r,a="",o=1e5;e||(e=0);for(var h=0;h<t.length;h++){var l=t[h];if("string"!=typeof l){var u=s(l,e+1);u.length<10*(80-4*e)&&u.indexOf('"""')<0&&(r=n(l)).length<80-4*e&&(l=" "+r,u=""),u&&(o=1e4),a+=u}"string"==typeof l&&(o<4*e+4?(a=a.slice(0,-1)+" "+l+"\n",o+=l.length+1):(a+=(r=i(4*e)+l)+"\n",o=r.length))}return a},a=function(t){this.suggestPrefix("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");for(var e=this.rootSubjects(t),r=e.roots,i=[],n=0;n<r.length;n++){var s=r[n];i.push(l(s,e))}return i}.bind(this);function o(t){return void 0===t?"@@@undefined@@@@":t.replace(/[&<"]/g,(function(t){switch(t[0]){case"&":return"&";case"<":return"<";case'"':return"""}}))}var h=function(t){return o(this.base?b.refTo(this.base,t.uri):t.uri)}.bind(this),l=function(t,e){var i,n,s,a,d=[],p=e.subjects[this.toStr(t)];if(void 0===p)return c(t,e);p.sort((function(t,e){var i=t.predicate.uri,n=e.predicate.uri;if(i.substring(0,44)===r||n.substring(0,44)===r)return i.localeCompare(n);var s=i.substring(44),a=n.substring(44),o=parseInt(s,10),h=parseInt(a,10);return isNaN(o)||isNaN(h)||o!==s||h!==a?i.localeCompare(n):o-h}));for(var g=0;g<p.length;g++)if("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"!==(s=p[g]).predicate.uri||i||"NamedNode"!==s.object.termType){if((a=s.predicate).uri.substr(0,44)===r){var m=a.uri.substr(44);m===parseInt(m,10).toString()&&(a=this.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#li"))}switch(n=f(a),s.object.termType){case"BlankNode":d=1===e.incoming[s.object].length?d.concat(["<"+n+' rdf:parseType="Resource">',l(s.object,e),"</"+n+">"]):d.concat(["<"+n+' rdf:nodeID="'+s.object.toNT().slice(2)+'"/>']);break;case"NamedNode":d=d.concat(["<"+n+' rdf:resource="'+h(s.object)+'"/>']);break;case"Literal":d=d.concat(["<"+n+(s.object.language?' xml:lang="'+s.object.language+'"':s.object.datatype.equals(this.xsd.string)?"":' rdf:datatype="'+o(s.object.datatype.uri)+'"')+">"+o(s.object.value)+"</"+n+">"]);break;case"Collection":d=d.concat(["<"+n+' rdf:parseType="Collection">',u(s.object,e),"</"+n+">"]);break;default:throw new Error("Can't serialize object of type "+s.object.termType+" into XML")}}else i=s.object;var w=i?f(i):"rdf:Description",y="";return"BlankNode"===t.termType?e.incoming[t]&&1===e.incoming[t].length||(y=' rdf:nodeID="'+t.toNT().slice(2)+'"'):y=' rdf:about="'+h(t)+'"',["<"+w+y+">"].concat([d]).concat(["</"+w+">"])}.bind(this);function u(t,e){for(var r=[],i=0;i<t.elements.length;i++)r.push(l(t.elements[i],e));return r}var c=function(t,e){var r=[],i=e.subjects[this.toStr(t)];if(!i)return r;i.sort();for(var n=0;n<i.length;n++){var s=i[n];switch(s.object.termType){case"BlankNode":r=e.rootsHash[s.object.toNT()]?r.concat(["<"+f(s.predicate)+' rdf:nodeID="'+s.object.toNT().slice(2)+'">',"</"+f(s.predicate)+">"]):r.concat(["<"+f(s.predicate)+' rdf:parseType="Resource">',c(s.object,e),"</"+f(s.predicate)+">"]);break;case"NamedNode":r=r.concat(["<"+f(s.predicate)+' rdf:resource="'+h(s.object)+'"/>']);break;case"Literal":r=r.concat(["<"+f(s.predicate)+(s.object.language?' xml:lang="'+s.object.language+'"':s.object.datatype.equals(this.xsd.string)?"":' rdf:datatype="'+o(s.object.datatype.value)+'"')+">"+o(s.object.value)+"</"+f(s.predicate)+">"]);break;case"Collection":r=r.concat(["<"+f(s.predicate)+' rdf:parseType="Collection">',u(s.object,e),"</"+f(s.predicate)+">"]);break;default:throw new Error("Can't serialize object of type "+s.object.termType+" into XML")}}return r}.bind(this),f=function(t){var r=t.uri,i=r.indexOf("#");if(i<0&&this.flags.indexOf("/")<0&&(i=r.lastIndexOf("/")),i<0)throw new Error("Cannot make qname out of <"+r+">");for(var n=i+1;n<r.length;n++)if(this._notNameChars.indexOf(r[n])>=0)throw new Error('Invalid character "'+r[n]+'" cannot be in XML qname for URI: '+r);var s=r.slice(i+1),a=r.slice(0,i+1);if(this.defaultNamespace&&this.defaultNamespace===a&&this.flags.indexOf("d")<0)return s;var o=this.prefixes[a];return o||(o=this.makeUpPrefix(a)),e[a]=!0,o+":"+s}.bind(this),d=a(t),p="<rdf:RDF";for(var g in this.defaultNamespace&&(p+=' xmlns="'+o(this.defaultNamespace)+'"'),e)if(e.hasOwnProperty(g)){var m=this.base&&this.flags.includes("z")?b.refTo(this.base,g):g;p+="\n xmlns:"+this.prefixes[g]+'="'+o(m)+'"'}return s([p+=">",d,"</rdf:RDF>"],-1)}statementsToJsonld(t){const e=this.statementsToN3(t),r=R.parse(e);return JSON.stringify(r,null,2)}}function F(t,e,r,n,s,a){r=r||t?.value;const o=a||{};n=n||i.sT;try{var h=j(e);o.flags&&h.setFlags(o.flags);var l=e.statementsMatching(void 0,void 0,void 0,t);switch("namespaces"in e&&h.suggestNamespaces(e.namespaces),o.namespaces&&h.setNamespaces(o.namespaces),h.setBase(r),n){case i.JG:return u(null,h.statementsToXML(l));case i.ny:case i.MG:return u(null,h.statementsToN3(l));case i.sT:case i.hu:return h.setFlags("si"+(o.flags?" "+o.flags:"")),u(null,h.statementsToN3(l));case i.bM:return h.setFlags("deinprstux"),u(null,h.statementsToNTriples(l));case i.i2:return h.setFlags("si dr"+(o.flags?" "+o.flags:"")),u(null,h.statementsToJsonld(l));case i._0:case i.BR:return h.setFlags("deinprstux q"),u(null,h.statementsToNTriples(l));default:throw new Error("Serialize: Content-type "+n+" not supported for data write.")}}catch(t){if(s)return s(t,void 0);throw t}function u(t,e){return s?void s(t,e):e}}const U=["blankNode","defaultGraph","literal","namedNode","quad","variable","supports"],D={first:"http://www.w3.org/1999/02/22-rdf-syntax-ns#first",rest:"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",nil:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"};function L(t,e,r){const i=[];return r.reduce(((e,r,n,s)=>{let a;return i.push(t.quad(e,t.namedNode(D.first),s[n])),n<s.length-1?(a=t.blankNode(),i.push(t.quad(e,t.namedNode(D.rest),a))):i.push(t.quad(e,t.namedNode(D.rest),t.namedNode(D.nil))),a}),e),i}function M(t,e,r=0){var i=t.length;for(r<0&&(r=i+r);r<i;r++)if(t[r]===e)return r;return-1}class P extends r.A{constructor(r=[],n=[],s=[],a=[],o={}){super(""),this.statements=r,this.constraints=n,this.initBindings=s,this.optional=a,(0,t.A)(this,"termType",i.bD),(0,t.A)(this,"classOrder",e.A.Graph),(0,t.A)(this,"fetcher",void 0),(0,t.A)(this,"isVar",0),(0,t.A)(this,"ns",E),(0,t.A)(this,"rdfFactory",void 0),this.rdfFactory=o&&o.rdfFactory||A;for(const t of U)this[t]=(...e)=>this.rdfFactory[t](...e)}add(t,e,r,i){return 1===arguments.length&&t.forEach((t=>this.add(t.subject,t.predicate,t.object,t.graph))),this.statements.push(this.rdfFactory.quad(t,e,r,i))}addStatement(t){return this.add(t)}bnode(t){return this.rdfFactory.blankNode(t)}addAll(t){t.forEach((t=>{this.add(t.subject,t.predicate,t.object,t.graph)}))}any(t,e,r,i){const n=this.anyStatementMatching(t,e,r,i);return null==n?null:null==t?n.subject:null==e?n.predicate:null==r?n.object:null}anyValue(t,e,r,i){const n=this.any(t,e,r,i);return n?n.value:void 0}anyJS(t,e,i,n){const s=this.any(t,e,i,n);return s?r.A.toJS(s):void 0}anyStatementMatching(t,e,r,i){let n=this.statementsMatching(t,e,r,i,!0);if(n&&0!==n.length)return n[0]}id(t){return this.rdfFactory.id(t)}statementsMatching(t,e,r,i,n){const s=this.statements.filter((n=>(!t||t.equals(n.subject))&&(!e||e.equals(n.predicate))&&(!r||r.equals(n.object))&&(!i||i.equals(n.graph))));return n?0===s.length?[]:[s[0]]:s}bottomTypeURIs(t){let e,r,i,n,s,a,o,h;e=[];for(let l in t)if(t.hasOwnProperty(l)){for(h=t[l],o=this.each(void 0,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),this.rdfFactory.namedNode(l)),r=!0,n=0,s=o.length;n<s;n++)if(i=o[n],a=i.uri,a in t){r=!1;break}r&&(e[l]=h)}return e}collection(){return new f}each(t,e,r,i){const n=[];let a=this.statementsMatching(t,e,r,i,!1);if(null==t)for(let t=0,e=a.length;t<e;t++)n.push(a[t].subject);else if(null==e)for(let t=0,e=a.length;t<e;t++)n.push(a[t].predicate);else if(null==r)for(let t=0,e=a.length;t<e;t++)n.push(a[t].object);else if(null==i)for(let t=0,e=a.length;t<e;t++)n.push(new s.A(a[t].graph.value));return n}equals(t){return!!t&&this.hashString()===t.hashString()}findMembersNT(t){let e,r,i,n,s,a,o,h,l,u,c,f,d,p;f={},f[t.toNT()]=!0,n={},a=this.transitiveClosure(f,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!0);for(let t in a)if(a.hasOwnProperty(t)){o=this.statementsMatching(void 0,this.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),this.fromNT(t));for(let t=0,e=o.length;t<e;t++)d=o[t],n[d.subject.toNT()]=d;h=this.each(void 0,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#domain"),this.fromNT(t));for(let t=0,r=h.length;t<r;t++)for(s=h[t],l=this.statementsMatching(void 0,s),i=0,e=l.length;i<e;i++)d=l[i],n[d.subject.toNT()]=d;u=this.each(void 0,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#range"),this.fromNT(t));for(let t=0,e=u.length;t<e;t++)for(s=u[t],c=this.statementsMatching(void 0,s),p=0,r=c.length;p<r;p++)d=c[p],n[d.object.toNT()]=d}return n}findMemberURIs(t){return this.NTtoURI(this.findMembersNT(t))}findSubClassesNT(t){let e={};return e[t.toNT()]=!0,this.transitiveClosure(e,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!0)}findSuperClassesNT(t){let e={};return e[t.toNT()]=!0,this.transitiveClosure(e,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!1)}findTypesNT(t){let e,r,i,n,s,a,o,h,l;i="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",l=[],n=this.statementsMatching(t,void 0,void 0);for(let t=0,e=n.length;t<e;t++)if(h=n[t],"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"===h.predicate.uri)l[h.object.toNT()]=h;else{s=this.each(h.predicate,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#domain"));for(let t=0,e=s.length;t<e;t++)r=s[t],l[r.toNT()]=h}a=this.statementsMatching(void 0,void 0,t);for(let t=0,r=a.length;t<r;t++){h=a[t],o=this.each(h.predicate,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#range"));for(let t=0,r=o.length;t<r;t++)e=o[t],l[e.toNT()]=h}return this.transitiveClosure(l,this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf"),!1)}findTypeURIs(t){return this.NTtoURI(this.findTypesNT(t))}connectedStatements(t,e,r){r=r||[];let i=[t],n={},s={},a=[],o=this,h=function(t){let h=function(t){"BlankNode"!==t.termType||n[t.value]||(n[t.value]=!0,i.push(t))},l=o.statementsMatching(null,null,t,e).concat(o.statementsMatching(t,null,null,e));l=l.filter((function(t){if(r[t.predicate.value])return!1;let e=t.toNT();return!s[e]&&(s[e]=!0,!0)})),l.forEach((function(t){h(t.subject),h(t.object)})),a=a.concat(l)};for(;i.length;)h(i.shift());return a}formula(t){return new P}fromNT(t){let e,r,i;switch(t[0]){case"<":return this.sym(t.slice(1,-1));case'"':if(i=void 0,e=void 0,r=t.lastIndexOf('"'),r<t.length-1)if("@"===t[r+1])i=t.slice(r+2);else{if("^^"!==t.slice(r+1,r+3))throw new Error("Can't convert string from NT: "+t);e=this.fromNT(t.slice(r+3))}return t=(t=(t=(t=t.slice(1,r)).replace(/\\"/g,'"')).replace(/\\n/g,"\n")).replace(/\\\\/g,"\\"),this.rdfFactory.literal(t,i||e);case"_":return this.rdfFactory.blankNode(t.slice(2));case"?":return new v(t.slice(1))}throw new Error("Can't convert from NT: "+t)}holds(t,e,r,i){let n;if(1===arguments.length){if(!t)return!0;if(t instanceof Array){for(n=0;n<t.length;n++)if(!this.holds(t[n]))return!1;return!0}if((0,a.SH)(t))return this.holds(t.subject,t.predicate,t.object,t.graph);if(t.statements)return this.holds(t.statements)}return null!=this.anyStatementMatching(t,e,r,i)}holdsStatement(t){return this.holds(t.subject,t.predicate,t.object,t.graph)}list(t,e){if(e.rdfFactory.supports.COLLECTIONS){const r=e.rdfFactory.collection();return t.forEach((function(t){r.append(t)})),r}{const r=e.rdfFactory.blankNode(),i=L(e.rdfFactory,r,t);return e.addAll(i),r}}NTtoURI(t){let e,r,i={};for(e in t)t.hasOwnProperty(e)&&(r=t[e],"<"===e[0]&&(i[e.slice(1,-1)]=r));return i}serialize(t,e,r,i){return F(r,this,t,e,void 0,i)}substitute(t){let e=this.statements.map((function(e){return e.substitute(t)}));const r=new P;return r.addAll(e),r}sym(t,e){if(e)throw new Error("This feature (kb.sym with 2 args) is removed. Do not assume prefix mappings.");return this.rdfFactory.namedNode(t)}the(t,e,r,i){let n=this.any(t,e,r,i);return null==n&&N.A.error("No value found for the() {"+t+" "+e+" "+r+"}."),n}transitiveClosure(t,e,r){let i,n,s,a,o,h,l={};Object.assign(l,t);let u={};for(;;){if(h=function(){for(let t in l)if(l.hasOwnProperty(t))return t}(),null==h)return u;for(o=r?this.each(void 0,e,this.fromNT(h)):this.each(this.fromNT(h),e),n=0,s=o.length;n<s;n++)i=o[n],a=i.toNT(),a in u||a in l||(l[a]=l[h]);u[h]=l[h],delete l[h]}}topTypeURIs(t){let e,r,i,n,s,a,o,h;for(i in o=[],t)if(t.hasOwnProperty(i)){for(h=t[i],s=0,a=this.each(this.rdfFactory.namedNode(i),this.rdfFactory.namedNode("http://www.w3.org/2000/01/rdf-schema#subClassOf")),e=0,n=a.length;e<n;e++)if(r=a[e],"http://www.w3.org/2000/01/rdf-schema#Resource"!==r.uri){s++;break}s||(o[i]=h)}return o["http://www.w3.org/2000/01/rdf-schema#Resource"]&&delete o["http://www.w3.org/2000/01/rdf-schema#Resource"],o["http://www.w3.org/2002/07/owl#Thing"]&&delete o["http://www.w3.org/2002/07/owl#Thing"],o}toString(){return"{"+this.statements.join("\n")+"}"}variable(t){return new v(t)}whether(t,e,r,i){return this.statementsMatching(t,e,r,i,!1).length}}r.A.fromValue=c;const B=r.A,q={xsd:E("http://www.w3.org/2001/XMLSchema#")};r.A.toJS=function(t){return(0,a.P3)(t)?t.elements.map(r.A.toJS):(0,a.c$)(t)?t.datatype.equals(q.xsd("boolean"))?"1"===t.value||"true"===t.value:t.datatype.equals(q.xsd("dateTime"))||t.datatype.equals(q.xsd("date"))?new Date(t.value):t.datatype.equals(q.xsd("integer"))||t.datatype.equals(q.xsd("float"))||t.datatype.equals(q.xsd("decimal"))?Number(t.value):t.value:t};class ${constructor(t,e){this.pat=new G,this.vars=[],this.name=t,this.id=e}}function H(t,e,r,i){function n(t){var e,r="";for(e in t)t.hasOwnProperty(e)&&(r+=" "+e+" -> "+t[e]);return r}function s(t){var e,r="Bindings: ",i=t.length;for(e=0;e<i;e++)r+=n(t[e][0])+";\n\t";return r}function a(t,e,r,i){var n;if(t.length!==e.length)return[];if(!t.length)return[[[],null]];var s=function(t,e,r,i){var n=r[t];if(void 0===n){if(t.isVar){var s=[];return s[t]=e,[[s,null]]}n=t}if(!n.complexType)return i.redirections[n]&&(n=i.redirections[n]),i.redirections[e]&&(e=i.redirections[e]),n.equals(e)||n.uri&&n.uri===p?[[[],null]]:[];if(t instanceof Array)return e instanceof Array?a(t,e,r):[];throw new Error("query.js: oops - code not written yet")}(t[0],e[0],r,i);if(0===s.length)return s;var o,h,l,u,c,f,d,g=[],m=s.length;for(o=0;o<m;o++){for(c in d=[],h=s[o][0])h.hasOwnProperty(c)&&(d[c]=h[c]);for(c in r)r.hasOwnProperty(c)&&(d[c]=r[c]);for(u=(n=a(t.slice(1),e.slice(1),d,i)).length,l=0;l<u;l++){for(c in f=n[l][0],h)h.hasOwnProperty(c)&&(f[c]=h[c]);g.push([f,null])}}return g}function o(t,e){var r,i={};for(r in t)t.hasOwnProperty(r)&&(i[r]=t[r]);for(r in e)e.hasOwnProperty(r)&&(i[r]=e[r]);return i}function h(t,e){return this.trunkBindings=e,this.originalCallback=t,this.branches=[],this}function l(t,e){return this.count=0,this.success=!1,this.done=!1,this.callback=t,this.onDone=e,this}h.prototype.checkAllDone=function(){var t;for(t=0;t<this.branches.length;t++)if(!this.branches[t].done)return;N.A.debug("OPTIONAL BIDNINGS ALL DONE:"),this.doCallBacks(this.branches.length-1,this.trunkBindings)},h.prototype.doCallBacks=function(t,e){var r;if(t<0)return this.originalCallback(e);for(r=0;r<this.branches[t].results.length;r++)this.doCallBacks(t-1,o(e,this.branches[t].results[r]))},l.prototype.reportMatch=function(t){this.callback(t),this.success=!0},l.prototype.reportDone=function(){this.done=!0,N.A.info("Mandatory query branch finished.***"),void 0!==this.onDone&&this.onDone()};var u=function(t){return this.count=0,this.done=!1,this.results=[],this.junction=t,t.branches.push(this),this};function c(t,e,r){var i,n,s,a,o,h;for(e.nvars=0,e.index=null,i=[e.subject,e.predicate,e.object,e.why],a=[t.subjectIndex,t.predicateIndex,t.objectIndex,t.whyIndex],s=0;s<4;s++){let l=i[s];if(l.uri&&l.uri===p);else if(l.isVar&&void 0===r[l])e.nvars++;else{if(void 0,l=void 0===(h=r[o=i[s]])?o:h,t.redirections[t.id(l)]&&(l=t.redirections[t.id(l)]),!(n=a[s][t.id(l)]))return e.index=[],!1;(null===e.index||e.index.length>n.length)&&(e.index=n)}}return null===e.index&&(e.index=t.statements),!0}function f(t,e){return t.nvars!==e.nvars?t.nvars-e.nvars:t.index.length-e.index.length}u.prototype.reportMatch=function(t){this.results.push(t)},u.prototype.reportDone=function(){N.A.debug("Optional branch finished - results.length = "+this.results.length),0===this.results.length&&(this.results.push({}),N.A.debug("Optional branch FAILED - that's OK.")),this.done=!0,this.junction.checkAllDone()};var d=function(t,r,i,s,a,o,l){N.A.debug("Match begins, Branch count now: "+l.count+" for "+l.pattern_debug);var c,f,p=r.statements;if(0===p.length){if(N.A.debug("FOUND MATCH WITH BINDINGS:"+n(i)),0===r.optional.length)l.reportMatch(i);else{N.A.debug("OPTIONAL: "+r.optional);var g,w=new h(e,i),y=[];for(g=0;g<r.optional.length;g++)y[g]=new u(w),y[g].pattern_debug=r.optional[g];for(g=0;g<r.optional.length;g++)y[g].count=y[g].count+1,d(t,r.optional[g],i,"",a,e,y[g])}return l.count--,void N.A.debug("Match ends -- success , Branch count now: "+l.count+" for "+l.pattern_debug)}var v=p.length;if(a){var _=function(e,n){var h=e.uri.split("#")[0];a.nowOrWhenFetched(h,void 0,(function(n,h,u){n||console.log("Error following link to <"+e.uri+"> in query: "+h),d(t,r,i,s,a,o,l)}))};for(f=0;f<v;f++){if(c=p[f],void 0!==i[c.subject]&&i[c.subject].uri&&a&&"unrequested"===a.getState((0,b.docpart)(i[c.subject].uri)))return void _(i[c.subject]);if(void 0!==i[c.object]&&i[c.object].uri&&a&&"unrequested"===a.getState((0,b.docpart)(i[c.object].uri)))return void _(i[c.object])}}m(t,r,i,s,a,o,l)},g=function(t,e){var r,i,n=!0;for(r in t)t.hasOwnProperty(r)&&e[r]&&(i=e[r].test)&&!i(t[r])&&(n=!1);return n},m=function(t,e,r,i,o,h,l){var u,p,m,w,y,b,v,_=e.statements,x=_.length;for(u=0;u<x;u++)c(t,v=_[u],r);_.sort(f),v=_[0];var T,A=t.formula();A.optional=e.optional,A.constraints=e.constraints,A.statements=_.slice(1),N.A.debug(i+"match2 searching "+v.index.length+" for "+v+"; bindings so far="+n(r));var E,R,k=v.index.length,I=0;for(T=0;T<k;T++)for(R=v.index[T],E=a([v.subject,v.predicate,v.object,v.why],[R.subject,R.predicate,R.object,R.why],r,t),N.A.info(i+" From first: "+E.length+": "+s(E)),m=E.length,p=0;p<m;p++)if(y=[],b=E[p][0],g(b,e.constraints)){for(w in b)b.hasOwnProperty(w)&&(y[w]=b[w]);for(w in r)r.hasOwnProperty(w)&&(y[w]=r[w]);l.count++,I++,d(t,A,y,i+" ",o,h,l)}else N.A.debug("Branch count CS: "+l.count);l.count--,0===I&&N.A.debug("Match2 fails completely on "+v),N.A.debug("Match2 ends, Branch count: "+l.count+" for "+l.pattern_debug),0===l.count&&(N.A.debug("Branch finished."),l.reportDone())},w=this;N.A.debug("Query on "+this.statements.length);var y=new l(e,i);y.count++,t.sync?d(w,t.pat,t.pat.initBindings,"",r,e,y):setTimeout((function(){d(w,t.pat,t.pat.initBindings,"",r,e,y)}),0)}const X="http://www.w3.org/2002/07/owl#";function z(t,e,r,i){var n=t.any(e,r,void 0);return!!n&&(t.equate(n,i),!0)}function Q(t,e,r,i){var n=t.any(void 0,r,i);return!!n&&(t.equate(n,e),!0)}function V(t,e,r,i,n){t.typeCallback&&t.typeCallback(t,i,n);var s=t.classActions[t.id(i)],a=!1;if(s)for(var o=0;o<s.length;o++)a=a||s[o](t,e,r,i,n);return a}class G extends P{constructor(e,r={}){super(void 0,void 0,void 0,void 0,r),(0,t.A)(this,"updater",void 0),(0,t.A)(this,"namespaces",void 0),(0,t.A)(this,"classActions",void 0),(0,t.A)(this,"propertyActions",void 0),(0,t.A)(this,"redirections",void 0),(0,t.A)(this,"aliases",void 0),(0,t.A)(this,"HTTPRedirects",void 0),(0,t.A)(this,"subjectIndex",void 0),(0,t.A)(this,"predicateIndex",void 0),(0,t.A)(this,"objectIndex",void 0),(0,t.A)(this,"whyIndex",void 0),(0,t.A)(this,"index",void 0),(0,t.A)(this,"features",void 0),(0,t.A)(this,"_universalVariables",void 0),(0,t.A)(this,"_existentialVariables",void 0),(0,t.A)(this,"rdfArrayRemove",void 0),(0,t.A)(this,"dataCallbacks",[]),(0,t.A)(this,"dataRemovalCallbacks",[]),this.propertyActions={},this.classActions={},this.redirections=[],this.aliases=[],this.HTTPRedirects=[],this.subjectIndex=[],this.predicateIndex=[],this.objectIndex=[],this.whyIndex=[],this.index=[this.subjectIndex,this.predicateIndex,this.objectIndex,this.whyIndex],this.namespaces={},this.features=e||[],this.rdfArrayRemove=r.rdfArrayRemove||C.RDFArrayRemove,r.dataCallback&&(this.dataCallbacks=[r.dataCallback]),r.dataRemovalCallback&&(this.dataRemovalCallbacks=[r.dataRemovalCallback]),this.initPropertyActions(this.features)}static get defaultGraphURI(){return p}substitute(t){var e=this.statements.map((function(e){return e.substitute(t)})),r=new G;return r.add(e),r}addDataCallback(t){this.dataCallbacks.push(t)}addDataRemovalCallback(t){this.dataRemovalCallbacks.push(t)}applyPatch(t,e,r){var i,n=this,s=null;function a(a){if(t.delete){i=t.delete,s&&(i=i.substitute(s)),i=i.statements;var o=[],h=i.map((function(t){var r=n.statementsMatching(t.subject,t.predicate,t.object,e);return 0===r.length?(o.push(t),null):r[0]}));if(o.length)return r("Could not find to delete: "+o.join("\n or "));h.map((function(t){n.remove(t)}))}t.insert&&(i=t.insert,s&&(i=i.substitute(s)),(i=i.statements).map((function(t){t.graph=e,n.add(t.subject,t.predicate,t.object,t.graph)}))),a()}if(t.where){var o=new $("patch");o.pat=t.where,o.pat.statements.map((function(t){t.graph=ze(e.value)})),o.sync=!0;var h=[];n.query(o,(function(t){h.push(t)}),n.fetcher,(function(){return 0===h.length?r("No match found to be patched:"+t.where):h.length>1?r("Patch ambiguous. No patch done."):(s=h[0],void a(r))}))}else a(r)}declareExistential(t){return this._existentialVariables||(this._existentialVariables=[]),this._existentialVariables.push(t),t}initPropertyActions(t){this.propertyActions[this.rdfFactory.id(this.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))]=[V],M(t,"sameAs")>=0&&(this.propertyActions[this.rdfFactory.id(this.rdfFactory.namedNode(`${X}sameAs`))]=[function(t,e,r,i,n){return t.equate(e,i),!0}]),M(t,"InverseFunctionalProperty")>=0&&(this.classActions[this.rdfFactory.id(this.rdfFactory.namedNode(`${X}InverseFunctionalProperty`))]=[function(t,e,r,i,n){return t.newPropertyAction(e,Q)}]),M(t,"FunctionalProperty")>=0&&(this.classActions[this.rdfFactory.id(this.rdfFactory.namedNode(`${X}FunctionalProperty`))]=[function(t,e,r,i,n){return t.newPropertyAction(e,z)}])}addStatement(t){return this.add(t.subject,t.predicate,t.object,t.graph),this.statements.length}add(t,e,r,i){var n,s,o;if(1===arguments.length){if(t instanceof Array)for(n=0;n<t.length;n++)this.add(t[n]);else(0,a.aF)(t)?this.add(t.subject,t.predicate,t.object,t.graph):(0,a.ok)(t)&&this.add(t.statements);return this}i||(i=this.fetcher?this.fetcher.appNode:this.rdfFactory.defaultGraph()),"string"==typeof t&&(t=this.rdfFactory.namedNode(t)),e=B.fromValue(e);const h=B.fromValue(r);if(i=B.fromValue(i),!(0,a.CZ)(t))throw new Error("Subject is not a subject type");if(!(0,a.fY)(e))throw new Error(`Predicate ${e} is not a predicate type`);if(!(0,a.DJ)(h))throw new Error(`Object ${h} is not an object type`);if(!(0,a.RN)(i))throw new Error("Why is not a graph type");this.predicateCallback&&this.predicateCallback(this,e,i);var l=this.id(this.canon(e)),u=!1;if(s=this.propertyActions[l])for(n=0;n<s.length;n++)u=u||s[n](this,t,e,h,i);if(this.holds(t,e,h,i))return null;var c=[this.id(this.canon(t)),l,this.id(this.canon(h)),this.id(this.canon(i))];for(o=this.rdfFactory.quad(t,e,h,i),n=0;n<4;n++){var f=this.index[n],d=c[n];f[d]||(f[d]=[]),f[d].push(o)}this.statements.push(o);for(const t of this.dataCallbacks)t(o);return o}canon(t){if(!t)return t;const e=this.redirections[this.id(t)];if(e)return e;switch(t.termType){case i.$Q:return new n(t.value);case i.r0:return t;case i.ic:return new g;case i.S:case i.bD:return t;case i.QW:return new u(t.value,t.language,t.datatype);case i.Kk:return new s.A(t.value);case i.P2:return new v(t.value);default:throw new Error(`Term Type not recognized for canonization: ${t.termType}`)}}check(){this.checkStatementList(this.statements);for(var t=0;t<4;t++){var e=this.index[t];for(var r in e)e.hasOwnProperty(r)&&this.checkStatementList(e[r],t)}}checkStatementList(t,e){void 0===e&&(e=0);for(var r,i=" found in "+["subject","predicate","object","why"][e]+" index.",n=0;n<t.length;n++){for(var s=[(r=t[n]).subject,r.predicate,r.object,r.graph],a=function(t,e){for(var r=0;r<t.length;r++)if(t[r].subject.equals(e.subject)&&t[r].predicate.equals(e.predicate)&&t[r].object.equals(e.object)&&t[r].why.equals(e.graph))return!0},o=0;o<4;o++){var h=this.canon(s[o]),l=this.id(h);this.index[o][l]&&a(this.index[o][l],r)}if(!a(this.statements,r))throw new Error("Statement list does not statement "+r+"@"+r.graph+i)}}close(){return this}compareTerms(t,r){return Object.prototype.hasOwnProperty.call(t,"compareTerm")?t.compareTerm(r):e.A[t.termType]<e.A[r.termType]?-1:e.A[t.termType]>e.A[r.termType]?1:t.value<r.value?-1:t.value>r.value?1:0}copyTo(t,e,r){r||(r=[]);var i=this.statementsMatching(t);-1!==M(r,"two-direction")&&i.concat(this.statementsMatching(void 0,void 0,t));for(var n=0;n<i.length;n++){var s=i[n];switch(s.object.termType){case"NamedNode":this.add(e,s.predicate,s.object);break;case"Literal":case"BlankNode":case"Collection":this.add(e,s.predicate,s.object.copy(this))}-1!==M(r,"delete")&&this.remove(s)}}equate(t,e){const r=this.canon(t),i=this.canon(e);var n=this.compareTerms(r,i);return!n||(n<0?this.replaceWith(i,r):this.replaceWith(r,i))}formula(t){return new G(t)}get length(){return this.statements.length}match(t,e,r,i){return this.statementsMatching(B.fromValue(t),B.fromValue(e),B.fromValue(r),B.fromValue(i))}mentionsURI(t){var e="<"+t+">";return!!this.subjectIndex[e]||!!this.objectIndex[e]||!!this.predicateIndex[e]}newExistential(t){if(!t)return this.bnode();var e=this.sym(t);return this.declareExistential(e)}newPropertyAction(t,e){var r=this.id(t);this.propertyActions[r]||(this.propertyActions[r]=[]),this.propertyActions[r].push(e);for(var i=this.statementsMatching(void 0,t,void 0),n=!1,s=0;s<i.length;s++)n=n||e(this,i[s].subject,t,i[s].object);return n}newUniversal(t){var e=this.sym(t);return this._universalVariables||(this._universalVariables=[]),this._universalVariables.push(e),e}variable(t){return new v(t)}nextSymbol(t){for(var e=0;;e++){var r=t.value+"#n"+e;if(!this.mentionsURI(r))return this.sym(r)}}query(t,e,r,i){return H.call(this,t,e,r,i)}querySync(t){var e=[],r=!1;if(t.sync=!0,H.call(this,t,(function(t){e.push(t)}),null,(function(){r=!0})),!r)throw new Error("Sync query should have called done function");return e}remove(t){if(t instanceof Array){for(var e=0;e<t.length;e++)this.remove(t[e]);return this}if((0,a.ok)(t))return this.remove(t.statements);var r=this.statementsMatching(t.subject,t.predicate,t.object,t.graph);if(!r.length)throw new Error("Statement to be removed is not on store: "+t);return this.removeStatement(r[0]),this}removeDocument(t){this.removeMetadata(t);for(var e=this.statementsMatching(void 0,void 0,void 0,t).slice(),r=0;r<e.length;r++)this.removeStatement(e[r]);return this.removeMatches(t,null,null),this}removeMetadata(t){const e=this.sym("chrome://TheCurrentSession"),r="http://www.w3.org/2007/ont/link#",i=this.statementsMatching(void 0,this.sym(`${r}requestedURI`),this.rdfFactory.literal(t.value),e).map((t=>t.subject));for(var n=0;n<i.length;n++){const t=i[n];if(null!=t){let i;const n=this.any(t,this.sym(`${r}status`),null,e);if(null!=n){i=this.statementsMatching(n,this.sym(`${r}status`),null,e).slice();for(var s=0;s<i.length;s++)this.removeStatement(i[s])}const a=this.any(t,this.sym(`${r}response`),null,e);if(null!=a)for(i=this.statementsMatching(a,null,null,e).slice(),s=0;s<i.length;s++)this.removeStatement(i[s]);for(i=this.statementsMatching(t,null,null,e).slice(),s=0;s<i.length;s++)this.removeStatement(i[s])}}return this.removeMatches(this.sym(t.value),null,null,e),this}removeMany(t,e,r,i,n){for(var s=this.statementsMatching(t,e,r,i,!1),a=[],o=0;o<s.length;o++)a.push(s[o]);for(n&&(a=a.slice(0,n)),o=0;o<a.length;o++)this.remove(a[o])}removeMatches(t,e,r,i){return this.removeMany(t,e,r,i),this}removeStatement(t){for(var e=[t.subject,t.predicate,t.object,t.graph],r=0;r<4;r++){var i=this.canon(e[r]),n=this.id(i);this.index[r][n]&&this.rdfArrayRemove(this.index[r][n],t)}this.rdfArrayRemove(this.statements,t);for(const e of this.dataRemovalCallbacks)e(t);return this}removeStatements(t){for(var e=0;e<t.length;e++)this.remove(t[e]);return this}replaceWith(t,e){for(var r=this.id(t),i=this.id(e),n=function(t){var e=t[r];if(e){var n=t[i];t[i]=n?e.concat(n):e,delete t[r]}},s=0;s<4;s++)n(this.index[s]);if(this.redirections[r]=e,t.value){if(this.aliases[i]||(this.aliases[i]=[]),this.aliases[i].push(t),this.aliases[r])for(s=0;s<this.aliases[r].length;s++)this.redirections[this.id(this.aliases[r][s])]=e,this.aliases[i].push(this.aliases[r][s]);this.add(e,this.sym("http://www.w3.org/2007/ont/link#uri"),t),this.fetcher&&this.fetcher.nowKnownAs(t,e)}return n(this.classActions),n(this.propertyActions),!0}allAliases(t){var e=this.aliases[this.id(this.canon(t))]||[];return e.push(this.canon(t)),e}sameThings(t,e){if(t.equals(e))return!0;var r=this.canon(t);if(!r)return!1;var i=this.canon(e);return!!i&&r.value===i.value}setPrefixForURI(t,e){if(("tab"!==t||!this.namespaces.tab)&&"ns"!==t.slice(0,2)&&"default"!==t.slice(0,7)){for(let t in this.namespaces)this.namespaces[t]==e&&delete this.namespaces[t];this.namespaces[t]=e}}statementsMatching(t,e,r,i,n){var s,a,o=[t,e,r,i],h=[],l=[],u=[],c=[];for(s=0;s<4;s++)h[s]=this.canon(B.fromValue(o[s])),h[s]?(c.push(s),l[s]=this.id(h[s])):u.push(s);if(0===c.length)return this.statements;if(1===c.length)return s=c[0],(a=this.index[s][l[s]])&&n&&a.length>1&&(a=a.slice(0,1)),a||[];var f,d,p=1e10;for(d=0;d<c.length;d++){if(s=c[d],!(a=this.index[s][l[s]]))return[];a.length<p&&(p=a.length,f=d)}for(var g=c[f],m=this.index[g][l[g]],w=c.slice(0,f).concat(c.slice(f+1)),y=[],b=["subject","predicate","object","why"],v=0;v<m.length;v++){var _=m[v];for(d=0;d<w.length;d++)if(s=w[d],!this.canon(_[b[s]]).equals(h[s])){_=null;break}if(null!=_&&(y.push(_),n))break}return y}uris(t){var e=this.canon(t),r=this.aliases[this.id(e)];if(!e.value)return[];var i=[e.value];if(r)for(var n=0;n<r.length;n++)i.push(r[n].uri);return i}serialize(t,e,r,i){return F(r,this,t,e,void 0,i={...i||{},namespaces:i?.namespaces?{...this.namespaces,...i.namespaces}:{...this.namespaces}})}}(0,t.A)(G,"handleRDFType",void 0),G.handleRDFType=V;const W=E("http://www.w3.org/1999/02/22-rdf-syntax-ns#");function Y(t,e){function r(i,n,s){const a=t.statementsMatching(i,W("rest"),null,e);if(1!==a.length)throw new Error(`Bad list structure: no rest at ${i}`);const o=t.statementsMatching(i,W("first"),null,e);if(1!==o.length)throw new Error(`Bad list structure: rest but ${o.length} firsts at ${i}`);const h=[o[0].object].concat(n),l=s.concat(a).concat(o),u=t.statementsMatching(null,W("rest"),i,e);if(0===u.length){const r=new f(h);return t.remove(l),void function(t,e,r,i){for(const n of t.statementsMatching(r,null,null,i)){const r=new y(e,n.predicate,n.object,i);t.remove(n),t.add(r)}for(const n of t.statementsMatching(null,r,null,i))t.remove(n),t.add(new y(n.subject,e,n.object,i));for(const n of t.statementsMatching(null,null,r,i))t.remove(n),t.add(new y(n.subject,n.predicate,e,i))}(t,r,i,e)}if(1!==u.length)throw new Error(`Bad list structure: ${u.length} pres at ${i}`);const c=u[0].subject;if("BlankNode"!==c.termType)throw new Error(`Bad list element node ${c} type: ${c.termType} `);r(c,h,l)}!function(t,e){const r=W("nil");for(const i of t.statementsMatching(r,null,null,e)){t.remove(i);const r=new f;t.add(new y(r,i.predicate,i.object,e))}for(const i of t.statementsMatching(null,null,r,e))if(!i.predicate.sameTerm(W("rest"))){t.remove(i);const r=new f;t.add(new y(i.subject,i.predicate,r,e))}}(t,e),t.statementsMatching(null,W("rest"),W("nil"),e).forEach((t=>{if("BlankNode"!==t.subject.termType)throw new Error(`Bad list element node ${t.subject} type: ${t.subject.termType} `);r(t.subject,[],[])}))}var Z="http://www.w3.org/2000/10/swap/log#",J=function(t){return t},K=function(t){return t},tt=function(t){if(t.length>0)throw"missing.js: oops nnonempty dict not imp";return[]},et=function(t){return t.length},rt=function(t,e,r){if(void 0===t.slice)throw"@@ mising.js: No .slice function for "+t+" of type "+typeof t;return void 0===r||null==r?t.slice(e):t.slice(e,r)},it=Error("dummy error stop iteration"),nt=function(t){return this.last=0,this.li=t,this.next=function(){if(this.last==this.li.length)throw it;return this.li[this.last++]},this},st=function(t,e){return t.indexOf(e)},at=function(t,e){if(!t){if(e)throw"python Assertion failed: "+e;throw"(python) Assertion failed."}};String.prototype.encode=function(t){if("utf-8"!=t)throw"UTF8_converter: can only do utf-8";return function(t){t=t.replace(/\r\n/g,"\n");for(var e="",r=0;r<t.length;r++){var i=t.charCodeAt(r);i<128?e+=String.fromCharCode(i):i>127&&i<2048?(e+=String.fromCharCode(i>>6|192),e+=String.fromCharCode(63&i|128)):(e+=String.fromCharCode(i>>12|224),e+=String.fromCharCode(i>>6&63|128),e+=String.fromCharCode(63&i|128))}return e}(this)},String.prototype.decode=function(t){if("utf-8"!=t)throw"UTF8_converter: can only do utf-8";return this};var ot=function(t,e){return b.join(e,t)},ht="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil",lt="http://www.w3.org/2002/07/owl#sameAs",ut="\t\r\n !\"#$%&'()*.,+/;<=>?@[\\]^`{|}~",ct=ut+":",ft=new RegExp("^([-+]?[0-9]+)(\\.[0-9]+)?([eE][-+]?[0-9]+)?","g"),dt=new RegExp("^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9](T[0-9][0-9]:[0-9][0-9](:[0-9][0-9](\\.[0-9]*)?)?)?Z?"),pt=new RegExp("[\\s#]"),gt=new RegExp('[\\\\\\r\\n\\"]',"g"),mt=new RegExp("^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*","g");function wt(t,e){var r=t.charAt(e+1);return""===r||pt.test(r)}const yt=function(t,e,r,i,n,s,a,o){return new bt(t,e,r,i,n,s,a,o)};class bt{constructor(t,e,r,i,n,s,a,o){void 0===e&&(e=null),void 0===r&&(r=""),void 0===i&&(i=null),void 0===n&&(n=""),void 0===s&&(s=null),void 0===a&&(a=""),void 0===o&&(o=null),this._bindings=new tt([]),this._flags=a,""!=r&&(at(r.indexOf(":")>=0,"Document URI not absolute: "+r),this._bindings[""]=r+"#"),this._store=t,n&&t.setGenPrefix(n),this._thisDoc=r,this.source=t.sym(r),this.lines=0,this.statementCount=0,this.hasNil=!1,this.startOfLine=0,this.previousLine=0,this._genPrefix=n,this.keywords=new K(["a","this","bind","has","is","of","true","false"]),this.keywordsSet=0,this._anonymousNodes=new tt([]),this._variables=new tt([]),this._parentVariables=new tt([]),this._reason=o,this._reason2=null,this._baseURI=i||r||null,at(!this._baseURI||this._baseURI.indexOf(":")>=0),this._genPrefix||(this._thisDoc?this._genPrefix=this._thisDoc+"#_g":this._genPrefix=RDFSink_uniqueURI()),null==e?this._thisDoc?this._formula=t.formula(r+"#_formula"):this._formula=t.formula():this._formula=e,this._context=this._formula,this._parentContext=null}here(t){return this._genPrefix+"_L"+this.lines+"C"+(t-this.startOfLine+1)}formula(){return this._formula}loadStream(t){return this.loadBuf(t.read())}loadBuf(t){return this.startDoc(),this.feed(t),this.endDoc()}feed(t){for(var e=t.decode("utf-8"),r=0;r>=0;){var i=this.skipSpace(e,r);if(i<0)return;if((r=this.directiveOrStatement(e,i))<0)throw vt(this._thisDoc,this.lines,e,i,"expected directive or statement")}}directiveOrStatement(t,e){var r,i=this.skipSpace(t,e);return i<0?i:(r=this.directive(t,i))>=0||(r=this.statement(t,i))>=0?this.checkDot(t,r):r}tok(t,e,r){if("@"==e.slice(r,r+1))r+=1;else if(M(this.keywords,t)<0)return-1;var i=r+et(t);return e.slice(r,i)==t&&ut.indexOf(e.charAt(i))>=0?i:-1}directive(t,e){if((s=this.skipSpace(t,e))<0)return s;var r=new K([]);if((s=this.tok("bind",t,e))>0)throw vt(this._thisDoc,this.lines,t,e,"keyword bind is obsolete: use @prefix");if((s=this.tok("keywords",t,e))>0){if((e=this.commaSeparatedList(t,s,r,!1))<0)throw vt(this._thisDoc,this.lines,t,e,"'@keywords' needs comma separated list of words");return this.setKeywords(rt(r,null,null)),e}if((s=this.tok("forAll",t,e))>0){if((e=this.commaSeparatedList(t,s,r,!0))<0)throw vt(this._thisDoc,this.lines,t,e,"Bad variable list after @forAll");var i=new nt(r);try{for(;;){var n=i.next();(M(this._variables,n)<0||M(this._parentVariables,n)>=0)&&(this._variables[n]=this._context.newUniversal(n))}}catch(t){if(t!=it)throw t}return e}if((s=this.tok("forSome",t,e))>0){if((e=this.commaSeparatedList(t,s,r,this.uri_ref2))<0)throw vt(this._thisDoc,this.lines,t,e,"Bad variable list after @forSome");i=new nt(r);try{for(;;)n=i.next(),this._context.declareExistential(n)}catch(t){if(t!=it)throw t}return e}if((s=this.tok("prefix",t,e))>=0){var s,a=new K([]);if((e=this.qname(t,s,a))<0)throw vt(this._thisDoc,this.lines,t,s,"expected qname after @prefix");if((s=this.uri_ref2(t,e,a))<0)throw vt(this._thisDoc,this.lines,t,e,"expected <uriref> after @prefix _qname_");var o=a[1].uri;return this._baseURI?o=ot(this._baseURI,o):at(o.indexOf(":")>=0,"With no base URI, cannot handle relative URI for NS"),at(o.indexOf(":")>=0),this._bindings[a[0][0]]=o,this.bind(a[0][0],function(t){return encodeURI(t)}(o)),s}if((s=this.tok("base",t,e))>=0){if(a=new K([]),(e=this.uri_ref2(t,s,a))<0)throw vt(this._thisDoc,this.lines,t,s,"expected <uri> after @base ");if(o=a[0].uri,!this._baseURI)throw vt(this._thisDoc,this.lines,t,s,"With no previous base URI, cannot use relative URI in @base <"+o+">");return o=ot(this._baseURI,o),at(o.indexOf(":")>=0),this._baseURI=o,e}return-1}bind(t,e){""==t||this._store.setPrefixForURI(t,e)}setKeywords(t){null==t?this.keywordsSet=0:(this.keywords=t,this.keywordsSet=1)}startDoc(){}endDoc(){return this.hasNil&&this._store.rdfFactory.supports.COLLECTIONS&&Y(this._store,this.source),this._formula}makeStatement(t){t[0].add(t[2],t[1],t[3],this.source),(t[2].uri&&t[2].uri===ht||t[3].uri&&t[3].uri===ht)&&(this.hasNil=!0),this.statementCount+=1}statement(t,e){var r=new K([]);if((e=this.object(t,e,r))<0)return e;var i=this.property_list(t,e,r[0]);if(i<0)throw vt(this._thisDoc,this.lines,t,e,"expected propertylist");return i}subject(t,e,r){return this.item(t,e,r)}verb(t,e,r){if((n=this.skipSpace(t,e))<0)return n;var i=new K([]);if((n=this.tok("has",t,e))>=0){if((e=this.prop(t,n,i))<0)throw vt(this._thisDoc,this.lines,t,n,"expected property after 'has'");return r.push(new J(["->",i[0]])),e}if((n=this.tok("is",t,e))>=0){if((e=this.prop(t,n,i))<0)throw vt(this._thisDoc,this.lines,t,n,"expected <property> after 'is'");if((n=this.skipSpace(t,e))<0)throw vt(this._thisDoc,this.lines,t,e,"End of file found, expected property after 'is'");var n;if(e=n,(n=this.tok("of",t,e))<0)throw vt(this._thisDoc,this.lines,t,e,"expected 'of' after 'is' <prop>");return r.push(new J(["<-",i[0]])),n}if((n=this.tok("a",t,e))>=0)return r.push(new J(["->",this._store.sym("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")])),n;if("<="==t.slice(e,e+2))return r.push(new J(["<-",this._store.sym(Z+"implies")])),e+2;if("="==t.slice(e,e+1))return">"==t.slice(e+1,e+2)?(r.push(new J(["->",this._store.sym(Z+"implies")])),e+2):(r.push(new J(["->",this._store.sym(lt)])),e+1);if(":="==t.slice(e,e+2))return r.push(new J(["->",Z+"becomes"])),e+2;if((n=this.prop(t,e,i))>=0)return r.push(new J(["->",i[0]])),n;if(">-"==t.slice(e,e+2)||"<-"==t.slice(e,e+2))throw vt(this._thisDoc,this.lines,t,n,">- ... -> syntax is obsolete.");return-1}prop(t,e,r){return this.item(t,e,r)}item(t,e,r){return this.path(t,e,r)}blankNode(t){return this._context.bnode(t,this._reason2)}path(t,e,r){if((n=this.nodeOrLiteral(t,e,r))<0)return n;for(;"!^.".indexOf(t.slice(n,n+1))>=0;){var i=t.slice(n,n+1);if("."==i&&wt(t,n))break;var n,s=r.pop(),a=this.blankNode(this.here(n));if((n=this.node(t,n+1,r))<0)throw vt(this._thisDoc,this.lines,t,n,"EOF found in middle of path syntax");var o=r.pop();"^"==i?this.makeStatement(new J([this._context,o,a,s])):this.makeStatement(new J([this._context,o,s,a])),r.push(a)}return n}anonymousNode(t){if(e=this._anonymousNodes[t])return e;var e=this._store.bnode(t);return this._anonymousNodes[t]=e,e}node(t,e,r,i){void 0===i&&(i=null);var n=i;if((u=this.skipSpace(t,e))<0)return u;e=u;var s=t.slice(e,e+1);if("["==s){var a=this.here(e);if((u=this.skipSpace(t,e+1))<0)throw vt(this._thisDoc,this.lines,t,e,"EOF after '['");if("="==t.slice(u,u+1)){e=u+1;var o=new K([]);if(!((u=this.objectList(t,e,o))>=0))throw vt(this._thisDoc,this.lines,t,e,"objectList expected after [= ");if(n=o[0],et(o)>1){var h=new nt(o);try{for(;;){var l=h.next();this.makeStatement(new J([this._context,this._store.sym(lt),n,l]))}}catch(t){if(t!=it)throw t}}if((u=this.skipSpace(t,u))<0)throw vt(this._thisDoc,this.lines,t,e,"EOF when objectList expected after [ = ");if(";"==t.slice(u,u+1))var u=u+1}if(null==n&&(n=this.blankNode(a)),(e=this.property_list(t,u,n))<0)throw vt(this._thisDoc,this.lines,t,u,"property_list expected");if((u=this.skipSpace(t,e))<0)throw vt(this._thisDoc,this.lines,t,e,"EOF when ']' expected after [ <propertyList>");if("."==t.slice(u,u+1))return r.push(n),u;if("]"!=t.slice(u,u+1))throw vt(this._thisDoc,this.lines,t,u,"']' expected");return r.push(n),u+1}if("{"==s){if("$"==t.slice(e+1,e+2)){u=(e+=1)+1;for(var c=new K([]),f=!0;;){if((e=this.skipSpace(t,u))<0)throw vt(this._thisDoc,this.lines,t,e,"needed '$}', found end.");if("$}"==t.slice(e,e+2)){u=e+2;break}if(f)f=!1;else{if(","!=t.slice(e,e+1))throw vt(this._thisDoc,this.lines,t,e,"expected: ','");e+=1}var d=new K([]);if((u=this.item(t,e,d))<0)throw vt(this._thisDoc,this.lines,t,e,"expected item in set or '$}'");c.push(d[0])}return r.push(this._store.newSet(c,this._context)),u}u=e+1;var p=this._parentContext;this._parentContext=this._context;var g=this._anonymousNodes,m=this._parentVariables;this._parentVariables=this._variables,this._anonymousNodes=new tt([]),this._variables=this._variables.slice();var w=this._reason2;for(this._reason2=null,null==n&&(n=this._store.formula()),this._context=n;;){if((e=this.skipSpace(t,u))<0)throw vt(this._thisDoc,this.lines,t,e,"needed '}', found end.");if("}"==t.slice(e,e+1)){u=e+1;break}if((u=this.directiveOrStatement(t,e))<0)throw vt(this._thisDoc,this.lines,t,e,"expected statement or '}'")}return this._anonymousNodes=g,this._variables=this._parentVariables,this._parentVariables=m,this._context=this._parentContext,this._reason2=w,this._parentContext=p,r.push(n.close()),u}if("("==s){var y=this._store.list;for("$"==t.slice(e+1,e+2)&&(y=this._store.newSet,e+=1),u=e+1,c=new K([]);;){if((e=this.skipSpace(t,u))<0)throw vt(this._thisDoc,this.lines,t,e,"needed ')', found end.");if(")"==t.slice(e,e+1)){u=e+1;break}if(d=new K([]),(u=this.item(t,e,d))<0)throw vt(this._thisDoc,this.lines,t,e,"expected item in list or ')'");c.push(d[0])}return r.push(y(c,this._context)),u}if((u=this.tok("this",t,e))>=0)throw vt(this._thisDoc,this.lines,t,e,"Keyword 'this' was ancient N3. Now use @forSome and @forAll keywords.");return(u=this.tok("true",t,e))>=0?(r.push(!0),u):(u=this.tok("false",t,e))>=0?(r.push(!1),u):null==n&&(u=this.uri_ref2(t,e,r))>=0?u:-1}property_list(t,e,r){for(;;){if((u=this.skipSpace(t,e))<0)throw vt(this._thisDoc,this.lines,t,e,"EOF found when expected verb in property list");if(":-"!=t.slice(u,u+2)){e=u;var i=new K([]);if((u=this.verb(t,e,i))<=0)return e;var n=new K([]);if((e=this.objectList(t,u,n))<0)throw vt(this._thisDoc,this.lines,t,u,"objectList expected");var s=new nt(n);try{for(;;){var a=s.next(),o=i[0],h=o[0],l=o[1];"->"==h?this.makeStatement(new J([this._context,l,r,a])):this.makeStatement(new J([this._context,l,a,r]))}}catch(t){if(t!=it)throw t}if((u=this.skipSpace(t,e))<0)throw vt(this._thisDoc,this.lines,t,u,"EOF found in list of objects");if(";"!=t.slice(e,e+1))return e;e+=1}else{e=u+2;var u,c=new K([]);if((u=this.node(t,e,c,r))<0)throw vt(this._thisDoc,this.lines,t,e,"bad {} or () or [] node after :- ");e=u}}}commaSeparatedList(t,e,r,i){if((n=this.skipSpace(t,e))<0)throw vt(this._thisDoc,this.lines,t,n,"EOF found expecting comma sep list");if("."==t.charAt(n))return e;if(i)var n=this.uri_ref2(t,n,r);else n=this.bareWord(t,n,r);if(n<0)return-1;for(;;){if((e=this.skipSpace(t,n))<0)return e;var s=t.slice(e,e+1);if(","!=s)return"."!=s?-1:e;if((n=i?this.uri_ref2(t,e+1,r):this.bareWord(t,e+1,r))<0)throw vt(this._thisDoc,this.lines,t,n,"bad list content")}}objectList(t,e,r){if((e=this.object(t,e,r))<0)return-1;for(;;){var i=this.skipSpace(t,e);if(i<0)throw vt(this._thisDoc,this.lines,t,i,"EOF found after object");if(","!=t.slice(i,i+1))return i;if((e=this.object(t,i+1,r))<0)return e}}checkDot(t,e){var r=this.skipSpace(t,e);if(r<0)return r;if("."==t.slice(r,r+1))return r+1;if("}"==t.slice(r,r+1))return r;if("]"==t.slice(r,r+1))return r;throw vt(this._thisDoc,this.lines,t,r,"expected '.' or '}' or ']' at end of statement")}uri_ref2(t,e,r){var i=new K([]);if((f=this.qname(t,e,i))>=0){var n=i[0],s=n[0],a=n[1];if(null==s){at(0,"not used?");var o=this._baseURI+"#"}else if(!(o=this._bindings[s])){if("_"==s)return r.push(this.anonymousNode(a)),f;throw vt(this._thisDoc,this.lines,t,e,"Prefix "+s+" not bound.")}var h=this._store.sym(o+a);return M(this._variables,h)>=0?r.push(this._variables[h]):r.push(h),f}if((e=this.skipSpace(t,e))<0)return-1;if("?"==t.charAt(e)){var l=new K([]);return(f=this.variable(t,e,l))>0?(r.push(l[0]),f):-1}if("<"==t.charAt(e)){for(var u=e+=1;e<et(t);){if(">"==t.charAt(e)){var c=t.slice(u,e);return this._baseURI?c=ot(this._baseURI,c):at(c.indexOf(":")>=0,"With no base URI, cannot deal with relative URIs"),"#"==t.slice(e-1,e)&&"#"!=rt(c,-1,null)&&(c+="#"),h=this._store.sym(c),M(this._variables,h)>=0?r.push(this._variables[h]):r.push(h),e+1}e+=1}throw vt(this._thisDoc,this.lines,t,f,"unterminated URI reference")}if(this.keywordsSet){var f;if(l=new K([]),(f=this.bareWord(t,e,l))<0)return-1;if(M(this.keywords,l[0])>=0)throw vt(this._thisDoc,this.lines,t,e,'Keyword "'+l[0]+'" not allowed here.');return r.push(this._store.sym(this._bindings[""]+l[0])),f}return-1}skipSpace(t,e){for(var r=e||0;r<t.length;r++){var i=t.charAt(r);if(" \n\r\t\f\v \u2028\u2029 ".indexOf(i)<0){if("#"!==t.charAt(r))return r;for(;;r++){if(r===t.length)return-1;if("\n"===t.charAt(r)){this.lines=this.lines+1;break}}}else"\n"===t.charAt(r)&&(this.lines=this.lines+1)}return-1}variable(t,e,r){if((i=this.skipSpace(t,e))<0)return-1;if("?"!=t.slice(i,i+1))return-1;var i;if(e=i+=1,"0123456789-".indexOf(t.charAt(i))>=0)throw vt(this._thisDoc,this.lines,t,i,"Varible name can't start with '"+t.charAt(i)+"s'");for(;e<et(t)&&ct.indexOf(t.charAt(e))<0;)e+=1;if(null==this._parentContext)throw vt(this._thisDoc,this.lines,t,i,"Can't use ?xxx syntax for variable in outermost level: "+t.slice(i-1,e));return r.push(this._store.variable(t.slice(i,e))),e}bareWord(t,e,r){var i=this.skipSpace(t,e);if(i<0)return-1;var n=t.charAt(i);if("0123456789-".indexOf(n)>=0)return-1;if(ct.indexOf(n)>=0)return-1;for(e=i;e<et(t);){var s=t.charAt(e);if("."===s){if(wt(t,e))break}else if(ct.indexOf(s)>=0)break;e+=1}return r.push(t.slice(i,e)),e}qname(t,e,r){if((e=this.skipSpace(t,e))<0)return-1;var i=t.charAt(e);if("0123456789-+".indexOf(i)>=0)return-1;if(ct.indexOf(i)<0){var n=i;for(e+=1;e<et(t);){if("."===(i=t.charAt(e))){if(wt(t,e))break}else if(ct.indexOf(i)>=0)break;n+=i,e+=1}}else n="";if(e<et(t)&&":"==t.charAt(e)){var s=n;for(e+=1,n="";e<et(t);){if("."===(i=t.charAt(e))){if(wt(t,e))break}else if(ct.indexOf(i)>=0)break;n+=i,e+=1}return r.push(new J([s,n])),e}return n&&this.keywordsSet&&M(this.keywords,n)<0?(r.push(new J(["",n])),e):-1}object(t,e,r){if((s=this.subject(t,e,r))>=0)return s;{if((s=this.skipSpace(t,e))<0)return-1;e=s;var i=null;let o=t.charAt(e);if('"'==o||"'"==o){i=t.slice(e,e+3==o+o)?o+o+o:o,e+=et(i);var n=this.strconst(t,e,i),s=n[0],a=n[1];return r.push(this._store.literal(a)),s}return-1}}nodeOrLiteral(t,e,r){if((h=this.node(t,e,r))>=0)return h;if((h=this.skipSpace(t,e))<0)return-1;e=h;var i=t.charAt(e);if("-+0987654321".indexOf(i)>=0){if(dt.lastIndex=0,null!=(c=dt.exec(t.slice(e))))h=e+(n=c[0]).length,n.indexOf("T")>=0?r.push(this._store.literal(n,this._store.sym("http://www.w3.org/2001/XMLSchema#dateTime"))):r.push(this._store.literal(n,this._store.sym("http://www.w3.org/2001/XMLSchema#date")));else{var n;if(ft.lastIndex=0,null==(c=ft.exec(t.slice(e))))throw vt(this._thisDoc,this.lines,t,e,"Bad number or date syntax");h=e+ft.lastIndex,(n=t.slice(e,h)).indexOf("e")>=0?r.push(this._store.literal(parseFloat(n),this._store.sym("http://www.w3.org/2001/XMLSchema#double"))):t.slice(e,h).indexOf(".")>=0?r.push(this._store.literal(parseFloat(n),this._store.sym("http://www.w3.org/2001/XMLSchema#decimal"))):r.push(this._store.literal(parseInt(n),this._store.sym("http://www.w3.org/2001/XMLSchema#integer")))}return h}if('"'==t.charAt(e)){if('"""'==t.slice(e,e+3))var s='"""';else s='"';e+=et(s);var a=null,o=this.strconst(t,e,s),h=o[0],l=o[1],u=null;if("@"==t.slice(h,h+1)){var c;if(mt.lastIndex=0,null==(c=mt.exec(t.slice(h+1))))throw vt(this._thisDoc,startline,t,e,"Bad language code syntax on string literal, after @");e=mt.lastIndex+h+1,u=t.slice(h+1,e),h=e}if("^^"==t.slice(h,h+2)){var f=new K([]);h=this.uri_ref2(t,h+2,f),a=f[0]}return r.push(this._store.literal(l,u||a)),h}return-1}strconst(t,e,r){for(var i=e,n="",s=this.lines;i<et(t);){if(e=i+et(r),t.slice(i,e)==r)return new J([e,n]);if('"'!=t.charAt(i)){if(gt.lastIndex=0,!gt.exec(t.slice(i)))throw vt(this._thisDoc,s,t,i,"Closing quote missing in string at ^ in "+t.slice(i-20,i)+"^"+t.slice(i,i+20));if(e=i+gt.lastIndex-1,n+=t.slice(i,e),'"'!=(h=t.charAt(e)))if("\r"!=h){if("\n"==h){if('"'==r)throw vt(this._thisDoc,s,t,e,"newline found in string literal");this.lines=this.lines+1,n+=h,i=e+1,this.previousLine=this.startOfLine,this.startOfLine=i}else if("\\"==h){if(i=e+1,!(h=t.slice(i,i+1)))throw vt(this._thisDoc,s,t,e,"unterminated string literal (2)");var a=st('abfrtvn\\"',h);if(a>=0)n+='a\b\f\r\t\v\n\\"'.charAt(a),i+=1;else if("u"==h)i=(o=this.uEscape(t,i+1,s))[0],n+=h=o[1];else{if("U"!=h)throw vt(this._thisDoc,this.lines,t,e,"bad escape");var o,h;i=(o=this.UEscape(t,i+1,s))[0],n+=h=o[1]}}}else i=e+1;else i=e}else n=n+'"',i=i+1}throw vt(this._thisDoc,this.lines,t,e,"unterminated string literal")}uEscape(t,e,r){for(var i=e,n=0,s=0;n<4;){var a=t.slice(i,i+1).toLowerCase();if(i+=1,""==a)throw vt(this._thisDoc,r,t,e,"unterminated string literal(3)");var o=st("0123456789abcdef",a);if(o<0)throw vt(this._thisDoc,r,t,e,"bad string literal hex escape");s=16*s+o,n+=1}var h=String.fromCharCode(s);return new J([i,h])}UEscape(t,e,r){for(var i=e,n=0,s="\\U";n<8;){var a=t.slice(i,i+1).toLowerCase();if(i+=1,""==a)throw vt(this._thisDoc,r,t,e,"unterminated string literal(3)");if(st("0123456789abcdef",a)<0)throw vt(this._thisDoc,r,t,e,"bad string literal hex escape");s+=a,n+=1}var o,h=(o="0x"+rt(s,2,10)-0,String.fromCharCode(o));return new J([i,h])}}function vt(t,e,r,i,n){let s=e+1,a="Line "+s+" of <"+t+">: Bad syntax: "+n+'\nat: "'+r.slice(i,i+30)+'"',o=new SyntaxError(a,t,s);return o.lineNo=s,o.characterInFile=i,o.syntaxProblem=n,o}const _t={...A,supports:{[_.collections]:!0,[_.defaultGraphType]:!1,[_.equalsMethod]:!0,[_.identity]:!1,[_.id]:!0,[_.reversibleId]:!1,[_.variableType]:!0},collection:t=>new f(t),id(t){return(0,a.P3)(t)?`( ${t.elements.map((t=>this.id(t))).join(", ")} )`:(0,a.DZ)(t)?v.toString(t):A.id(t)},termToNQ:t=>t.termType===i.r0?f.toNT(t):A.termToNQ(t)},xt=_t;function Tt(t,e){return"string"==typeof e?t.rdfFactory.literal(e):Object.prototype.hasOwnProperty.call(e,"@list")?!0===t.rdfFactory.supports.COLLECTIONS?function(t,e){if(!Array.isArray(e))throw new TypeError("Object must be an array");return t.rdfFactory.collection(e.map((e=>Tt(t,e))))}(t,e["@list"]):function(t,e){const r=e["@id"]?Nt(t,e):t.rdfFactory.blankNode(),i=e["@list"].map((e=>Tt(t,e))),n=L(t.rdfFactory,r,i);return t.addAll(n),r}(t,e):Object.prototype.hasOwnProperty.call(e,"@id")?Nt(t,e):Object.prototype.hasOwnProperty.call(e,"@language")?t.rdfFactory.literal(e["@value"],e["@language"]):Object.prototype.hasOwnProperty.call(e,"@type")?t.rdfFactory.literal(e["@value"],t.rdfFactory.namedNode(e["@type"])):Object.prototype.hasOwnProperty.call(e,"@value")?t.rdfFactory.literal(e["@value"]):t.rdfFactory.literal(e)}async function At(t,e,r){const i=r&&Object.prototype.hasOwnProperty.call(r,"termType")?r.value:r,n=await o.e(515).then(o.t.bind(o,8515,23));return(await n.default.flatten(JSON.parse(t),null,{base:i})).reduce(((t,e)=>Et(t,r,e)),e)}function Nt(t,e){return e["@id"].startsWith("_:")?t.rdfFactory.blankNode(e["@id"].substring(2)):t.rdfFactory.namedNode(e["@id"])}function Et(t,e,r){const i=r["@id"]?Nt(t,r):t.rdfFactory.blankNode();for(const n of Object.keys(r)){if("@id"===n)continue;if("@graph"==n){const e=i,s=r[n];for(let r=0;r<s.length;r++)t=Et(t,e,s[r])}const s=r[n];if(Array.isArray(s))for(let r=0;r<s.length;r++)t.addStatement(Rt(t,i,n,s[r],e));else t.addStatement(Rt(t,i,n,s,e))}return t}function Rt(t,e,r,i,n){let s,a;return"@type"===r?(s=t.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),a=t.rdfFactory.namedNode(i)):(s=t.rdfFactory.namedNode(r),a=Tt(t,i)),t.rdfFactory.quad(e,s,a,t.rdfFactory.namedNode(n))}var kt=o(2313);const It="http://www.w3.org/1999/02/22-rdf-syntax-ns#",Ct="http://www.w3.org/2001/XMLSchema#",Ot="http://www.w3.org/2000/10/swap/",jt={xsd:{decimal:`${Ct}decimal`,boolean:`${Ct}boolean`,double:`${Ct}double`,integer:`${Ct}integer`,string:`${Ct}string`},rdf:{type:`${It}type`,nil:`${It}nil`,first:`${It}first`,rest:`${It}rest`,langString:`${It}langString`},owl:{sameAs:"http://www.w3.org/2002/07/owl#sameAs"},r:{forSome:`${Ot}reify#forSome`,forAll:`${Ot}reify#forAll`},log:{implies:`${Ot}log#implies`,isImpliedBy:`${Ot}log#isImpliedBy`}},{xsd:St}=jt,Ft=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\([^])/g,Ut={"\\":"\\","'":"'",'"':'"',n:"\n",r:"\r",t:"\t",f:"\f",b:"\b",_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},Dt=/[\x00-\x20<>\\"\{\}\|\^\`]/,Lt={_iri:!0,_unescapedIri:!0,_simpleQuotedString:!0,_langcode:!0,_blank:!0,_newline:!0,_comment:!0,_whitespace:!0,_endOfFile:!0},Mt=/$0^/;class Pt{constructor(t){if(this._iri=/^<((?:[^ <>{}\\]|\\[uU])+)>[ \t]*/,this._unescapedIri=/^<([^\x00-\x20<>\\"\{\}\|\^\`]*)>[ \t]*/,this._simpleQuotedString=/^"([^"\\\r\n]*)"(?=[^"])/,this._simpleApostropheString=/^'([^'\\\r\n]*)'(?=[^'])/,this._langcode=/^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9\-])/i,this._prefix=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:(?=[#\s<])/,this._prefixed=/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:((?:(?:[0-:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])(?:(?:[\.\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])*(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~]))?)?)(?:[ \t]+|(?=\.?[,;!\^\s#()\[\]\{\}"'<>]))/,this._variable=/^\?(?:(?:[A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?=[.,;!\^\s#()\[\]\{\}"'<>])/,this._blank=/^_:((?:[0-9A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?:[ \t]+|(?=\.?[,;:\s#()\[\]\{\}"'<>]))/,this._number=/^[\-+]?(?:(\d+\.\d*|\.?\d+)[eE][\-+]?|\d*(\.)?)\d+(?=\.?[,;:\s#()\[\]\{\}"'<>])/,this._boolean=/^(?:true|false)(?=[.,;\s#()\[\]\{\}"'<>])/,this._keyword=/^@[a-z]+(?=[\s#<:])/i,this._sparqlKeyword=/^(?:PREFIX|BASE|GRAPH)(?=[\s#<])/i,this._shortPredicates=/^a(?=[\s#()\[\]\{\}"'<>])/,this._newline=/^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/,this._comment=/#([^\n\r]*)/,this._whitespace=/^[ \t]+/,this._endOfFile=/^(?:#[^\n\r]*)?$/,t=t||{},this._isImpliedBy=t.isImpliedBy,this._lineMode=!!t.lineMode){this._n3Mode=!1;for(const t in this)!(t in Lt)&&this[t]instanceof RegExp&&(this[t]=Mt)}else this._n3Mode=!1!==t.n3;this.comments=!!t.comments,this._literalClosingPos=0}_tokenizeToEnd(t,e){let r=this._input,i=r.length;for(;;){let t,a;for(;t=this._newline.exec(r);)this.comments&&(a=this._comment.exec(t[0]))&&n("comment",a[1],"",this._line,t[0].length),r=r.substr(t[0].length,r.length),i=r.length,this._line++;if(!t&&(t=this._whitespace.exec(r))&&(r=r.substr(t[0].length,r.length)),this._endOfFile.test(r))return e&&(this.comments&&(a=this._comment.exec(r))&&n("comment",a[1],"",this._line,r.length),r=null,n("eof","","",this._line,0)),this._input=r;const o=this._line,h=r[0];let l="",u="",c="",f=null,d=0,p=!1;switch(h){case"^":if(r.length<3)break;if("^"!==r[1]){this._n3Mode&&(d=1,l="^");break}if(this._previousMarker="^^",r=r.substr(2),"<"!==r[0]){p=!0;break}case"<":if(f=this._unescapedIri.exec(r))l="IRI",u=f[1];else if(f=this._iri.exec(r)){if(u=this._unescape(f[1]),null===u||Dt.test(u))return s(this);l="IRI"}else r.length>1&&"<"===r[1]?(l="<<",d=2):this._n3Mode&&r.length>1&&"="===r[1]&&(d=2,this._isImpliedBy?(l="abbreviation",u="<"):(l="inverse",u=">"));break;case">":r.length>1&&">"===r[1]&&(l=">>",d=2);break;case"_":((f=this._blank.exec(r))||e&&(f=this._blank.exec(`${r} `)))&&(l="blank",c="_",u=f[1]);break;case'"':if(f=this._simpleQuotedString.exec(r))u=f[1];else if(({value:u,matchLength:d}=this._parseLiteral(r)),null===u)return s(this);null===f&&0===d||(l="literal",this._literalClosingPos=0);break;case"'":if(!this._lineMode){if(f=this._simpleApostropheString.exec(r))u=f[1];else if(({value:u,matchLength:d}=this._parseLiteral(r)),null===u)return s(this);null===f&&0===d||(l="literal",this._literalClosingPos=0)}break;case"?":this._n3Mode&&(f=this._variable.exec(r))&&(l="var",u=f[0]);break;case"@":"literal"===this._previousMarker&&(f=this._langcode.exec(r))?(l="langcode",u=f[1]):(f=this._keyword.exec(r))&&(l=f[0]);break;case".":if(1===r.length?e:r[1]<"0"||r[1]>"9"){l=".",d=1;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":(f=this._number.exec(r)||e&&(f=this._number.exec(`${r} `)))&&(l="literal",u=f[0],c="string"==typeof f[1]?St.double:"string"==typeof f[2]?St.decimal:St.integer);break;case"B":case"b":case"p":case"P":case"G":case"g":(f=this._sparqlKeyword.exec(r))?l=f[0].toUpperCase():p=!0;break;case"f":case"t":(f=this._boolean.exec(r))?(l="literal",u=f[0],c=St.boolean):p=!0;break;case"a":(f=this._shortPredicates.exec(r))?(l="abbreviation",u="a"):p=!0;break;case"=":this._n3Mode&&r.length>1&&(l="abbreviation",">"!==r[1]?(d=1,u="="):(d=2,u=">"));break;case"!":if(!this._n3Mode)break;case",":case";":case"[":case"]":case"(":case")":case"}":this._lineMode||(d=1,l=h);break;case"{":!this._lineMode&&r.length>=2&&("|"===r[1]?(l="{|",d=2):(l=h,d=1));break;case"|":r.length>=2&&"}"===r[1]&&(l="|}",d=2);break;default:p=!0}if(p&&("@prefix"!==this._previousMarker&&"PREFIX"!==this._previousMarker||!(f=this._prefix.exec(r))?((f=this._prefixed.exec(r))||e&&(f=this._prefixed.exec(`${r} `)))&&(l="prefixed",c=f[1]||"",u=this._unescape(f[2])):(l="prefix",u=f[1]||"")),"^^"===this._previousMarker)switch(l){case"prefixed":l="type";break;case"IRI":l="typeIRI";break;default:l=""}if(!l)return e||!/^'''|^"""/.test(r)&&/\n|\r/.test(r)?s(this):this._input=r;const g=d||f[0].length,m=n(l,u,c,o,g);this.previousToken=m,this._previousMarker=l,r=r.substr(g,r.length)}function n(e,n,s,a,o){const h=r?i-r.length:i,l={type:e,value:n,prefix:s,line:a,start:h,end:h+o};return t(null,l),l}function s(e){t(e._syntaxError(/^\S*/.exec(r)[0]))}}_unescape(t){let e=!1;const r=t.replace(Ft,((t,r,i,n)=>{if("string"==typeof r)return String.fromCharCode(Number.parseInt(r,16));if("string"==typeof i){let t=Number.parseInt(i,16);return t<=65535?String.fromCharCode(Number.parseInt(i,16)):String.fromCharCode(55296+((t-=65536)>>10),56320+(1023&t))}return n in Ut?Ut[n]:(e=!0,"")}));return e?null:r}_parseLiteral(t){if(t.length>=3){const e=t.match(/^(?:"""|"|'''|'|)/)[0],r=e.length;let i=Math.max(this._literalClosingPos,r);for(;(i=t.indexOf(e,i))>0;){let e=0;for(;"\\"===t[i-e-1];)e++;if(e%2==0){const e=t.substring(r,i),n=e.split(/\r\n|\r|\n/).length-1,s=i+r;if(1===r&&0!==n||3===r&&this._lineMode)break;return this._line+=n,{value:this._unescape(e),matchLength:s}}i++}this._literalClosingPos=t.length-r+1}return{value:"",matchLength:0}}_syntaxError(t){this._input=null;const e=new Error(`Unexpected "${t}" on line ${this._line}.`);return e.context={token:void 0,line:this._line,previousToken:this.previousToken},e}_readStartingBom(t){return t.startsWith("\ufeff")?t.substr(1):t}tokenize(t,e){if(this._line=1,"string"==typeof t){if(this._input=this._readStartingBom(t),"function"!=typeof e){const t=[];let e;if(this._tokenizeToEnd(((r,i)=>r?e=r:t.push(i)),!0),e)throw e;return t}queueMicrotask((()=>this._tokenizeToEnd(e,!0)))}else this._pendingBuffer=null,"function"==typeof t.setEncoding&&t.setEncoding("utf8"),t.on("data",(t=>{null!==this._input&&0!==t.length&&(this._pendingBuffer&&(t=kt.hp.concat([this._pendingBuffer,t]),this._pendingBuffer=null),128&t[t.length-1]?this._pendingBuffer=t:(void 0===this._input?this._input=this._readStartingBom("string"==typeof t?t:t.toString()):this._input+=t,this._tokenizeToEnd(e,!1)))})),t.on("end",(()=>{"string"==typeof this._input&&this._tokenizeToEnd(e,!0)})),t.on("error",e)}}const{rdf:Bt,xsd:qt}=jt;let $t,Ht=0;const Xt={namedNode:Zt,blankNode:Jt,variable:te,literal:Kt,defaultGraph:function(){return $t},quad:ee,triple:ee,fromTerm:re,fromQuad:ie};class zt{constructor(t){this.id=t}get value(){return this.id}equals(t){return t instanceof zt?this.id===t.id:!!t&&this.termType===t.termType&&this.value===t.value}hashCode(){return 0}toJSON(){return{termType:this.termType,value:this.value}}}class Qt extends zt{get termType(){return"NamedNode"}}class Vt extends zt{get termType(){return"Literal"}get value(){return this.id.substring(1,this.id.lastIndexOf('"'))}get language(){const t=this.id;let e=t.lastIndexOf('"')+1;return e<t.length&&"@"===t[e++]?t.substr(e).toLowerCase():""}get datatype(){return new Qt(this.datatypeString)}get datatypeString(){const t=this.id,e=t.lastIndexOf('"')+1,r=e<t.length?t[e]:"";return"^"===r?t.substr(e+2):"@"!==r?qt.string:Bt.langString}equals(t){return t instanceof Vt?this.id===t.id:!!t&&!!t.datatype&&this.termType===t.termType&&this.value===t.value&&this.language===t.language&&this.datatype.value===t.datatype.value}toJSON(){return{termType:this.termType,value:this.value,language:this.language,datatype:{termType:"NamedNode",value:this.datatypeString}}}}class Gt extends zt{constructor(t){super(`_:${t}`)}get termType(){return"BlankNode"}get value(){return this.id.substr(2)}}class Wt extends zt{constructor(t){super(`?${t}`)}get termType(){return"Variable"}get value(){return this.id.substr(1)}}$t=new class extends zt{constructor(){return super(""),$t||this}get termType(){return"DefaultGraph"}equals(t){return this===t||!!t&&this.termType===t.termType}};class Yt extends zt{constructor(t,e,r,i){super(""),this._subject=t,this._predicate=e,this._object=r,this._graph=i||$t}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(t){return!!t&&this._subject.equals(t.subject)&&this._predicate.equals(t.predicate)&&this._object.equals(t.object)&&this._graph.equals(t.graph)}}function Zt(t){return new Qt(t)}function Jt(t){return new Gt(t||"n3-"+Ht++)}function Kt(t,e){if("string"==typeof e)return new Vt(`"${t}"@${e.toLowerCase()}`);let r=e?e.value:"";return""===r&&("boolean"==typeof t?r=qt.boolean:"number"==typeof t&&(Number.isFinite(t)?r=Number.isInteger(t)?qt.integer:qt.double:(r=qt.double,Number.isNaN(t)||(t=t>0?"INF":"-INF")))),""===r||r===qt.string?new Vt(`"${t}"`):new Vt(`"${t}"^^${r}`)}function te(t){return new Wt(t)}function ee(t,e,r,i){return new Yt(t,e,r,i)}function re(t){if(t instanceof zt)return t;switch(t.termType){case"NamedNode":return Zt(t.value);case"BlankNode":return Jt(t.value);case"Variable":return te(t.value);case"DefaultGraph":return $t;case"Literal":return Kt(t.value,t.language||t.datatype);case"Quad":return ie(t);default:throw new Error(`Unexpected termType: ${t.termType}`)}}function ie(t){if(t instanceof Yt)return t;if("Quad"!==t.termType)throw new Error(`Unexpected termType: ${t.termType}`);return ee(re(t.subject),re(t.predicate),re(t.object),re(t.graph))}let ne=0;class se{constructor(t){this._contextStack=[],this._graph=null,t=t||{},this._setBase(t.baseIRI),t.factory&&oe(this,t.factory);const e="string"==typeof t.format?t.format.match(/\w*$/)[0].toLowerCase():"",r=/turtle/.test(e),i=/trig/.test(e),n=/triple/.test(e),s=/quad/.test(e),a=this._n3Mode=/n3/.test(e),o=n||s;(this._supportsNamedGraphs=!(r||a))||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(r||i||n||a),this._isImpliedBy=t.isImpliedBy,this._supportsRDFStar=""===e||/star|\*$/.test(e),o&&(this._resolveRelativeIRI=t=>null),this._blankNodePrefix="string"!=typeof t.blankNodePrefix?"":t.blankNodePrefix.replace(/^(?!_:)/,"_:"),this._lexer=t.lexer||new Pt({lineMode:o,n3:a,isImpliedBy:this._isImpliedBy}),this._explicitQuantifiers=!!t.explicitQuantifiers}static _resetBlankNodePrefix(){ne=0}_setBase(t){if(t){const e=t.indexOf("#");e>=0&&(t=t.substr(0,e)),this._base=t,this._basePath=t.indexOf("/")<0?t:t.replace(/[^\/?]*(?:\?.*)?$/,""),t=t.match(/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i),this._baseRoot=t[0],this._baseScheme=t[1]}else this._base="",this._basePath=""}_saveContext(t,e,r,i,n){const s=this._n3Mode;this._contextStack.push({type:t,subject:r,predicate:i,object:n,graph:e,inverse:!!s&&this._inversePredicate,blankPrefix:s?this._prefixes._:"",quantified:s?this._quantified:null}),s&&(this._inversePredicate=!1,this._prefixes._=this._graph?`${this._graph.value}.`:".",this._quantified=Object.create(this._quantified))}_restoreContext(t,e){const r=this._contextStack.pop();if(!r||r.type!==t)return this._error(`Unexpected ${e.type}`,e);this._subject=r.subject,this._predicate=r.predicate,this._object=r.object,this._graph=r.graph,this._n3Mode&&(this._inversePredicate=r.inverse,this._prefixes._=r.blankPrefix,this._quantified=r.quantified)}_readInTopContext(t){switch(t.type){case"eof":return null!==this._graph?this._error("Unclosed graph",t):(delete this._prefixes._,this._callback(null,null,this._prefixes));case"PREFIX":this._sparqlStyle=!0;case"@prefix":return this._readPrefix;case"BASE":this._sparqlStyle=!0;case"@base":return this._readBaseIRI;case"{":if(this._supportsNamedGraphs)return this._graph="",this._subject=null,this._readSubject;case"GRAPH":if(this._supportsNamedGraphs)return this._readNamedGraphLabel;default:return this._readSubject(t)}}_readEntity(t,e){let r;switch(t.type){case"IRI":case"typeIRI":const e=this._resolveIRI(t.value);if(null===e)return this._error("Invalid IRI",t);r=this._factory.namedNode(e);break;case"type":case"prefixed":const i=this._prefixes[t.prefix];if(void 0===i)return this._error(`Undefined prefix "${t.prefix}:"`,t);r=this._factory.namedNode(i+t.value);break;case"blank":r=this._factory.blankNode(this._prefixes[t.prefix]+t.value);break;case"var":r=this._factory.variable(t.value.substr(1));break;default:return this._error(`Expected entity but got ${t.type}`,t)}return!e&&this._n3Mode&&r.id in this._quantified&&(r=this._quantified[r.id]),r}_readSubject(t){switch(this._predicate=null,t.type){case"[":return this._saveContext("blank",this._graph,this._subject=this._factory.blankNode(),null,null),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this.RDF_NIL,null,null),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._graph=this._factory.blankNode(),null,null),this._readSubject):this._error("Unexpected graph",t);case"}":return this._readPunctuation(t);case"@forSome":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORSOME,this._quantifier="blankNode",this._readQuantifierList):this._error('Unexpected "@forSome"',t);case"@forAll":return this._n3Mode?(this._subject=null,this._predicate=this.N3_FORALL,this._quantifier="variable",this._readQuantifierList):this._error('Unexpected "@forAll"',t);case"literal":if(!this._n3Mode)return this._error("Unexpected literal",t);if(0===t.prefix.length)return this._literalValue=t.value,this._completeSubjectLiteral;this._subject=this._factory.literal(t.value,this._factory.namedNode(t.prefix));break;case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,null,null,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",t);default:if(void 0===(this._subject=this._readEntity(t)))return;if(this._n3Mode)return this._getPathReader(this._readPredicateOrNamedGraph)}return this._readPredicateOrNamedGraph}_readPredicate(t){const e=t.type;switch(e){case"inverse":this._inversePredicate=!0;case"abbreviation":this._predicate=this.ABBREVIATIONS[t.value];break;case".":case"]":case"}":return null===this._predicate?this._error(`Unexpected ${e}`,t):(this._subject=null,"]"===e?this._readBlankNodeTail(t):this._readPunctuation(t));case";":return null!==this._predicate?this._readPredicate:this._error("Expected predicate but got ;",t);case"[":if(this._n3Mode)return this._saveContext("blank",this._graph,this._subject,this._subject=this._factory.blankNode(),null),this._readBlankNodeHead;case"blank":if(!this._n3Mode)return this._error("Disallowed blank node as predicate",t);default:if(void 0===(this._predicate=this._readEntity(t)))return}return this._readObject}_readObject(t){switch(t.type){case"literal":if(0===t.prefix.length)return this._literalValue=t.value,this._readDataTypeOrLang;this._object=this._factory.literal(t.value,this._factory.namedNode(t.prefix));break;case"[":return this._saveContext("blank",this._graph,this._subject,this._predicate,this._subject=this._factory.blankNode()),this._readBlankNodeHead;case"(":return this._saveContext("list",this._graph,this._subject,this._predicate,this.RDF_NIL),this._subject=null,this._readListItem;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",t);case"<<":return this._supportsRDFStar?(this._saveContext("<<",this._graph,this._subject,this._predicate,null),this._graph=null,this._readSubject):this._error("Unexpected RDF-star syntax",t);default:if(void 0===(this._object=this._readEntity(t)))return;if(this._n3Mode)return this._getPathReader(this._getContextEndReader())}return this._getContextEndReader()}_readPredicateOrNamedGraph(t){return"{"===t.type?this._readGraph(t):this._readPredicate(t)}_readGraph(t){return"{"!==t.type?this._error(`Expected graph but got ${t.type}`,t):(this._graph=this._subject,this._subject=null,this._readSubject)}_readBlankNodeHead(t){return"]"===t.type?(this._subject=null,this._readBlankNodeTail(t)):(this._predicate=null,this._readPredicate(t))}_readBlankNodeTail(t){if("]"!==t.type)return this._readBlankNodePunctuation(t);null!==this._subject&&this._emit(this._subject,this._predicate,this._object,this._graph);const e=null===this._predicate;return this._restoreContext("blank",t),null!==this._object?this._getContextEndReader():null!==this._predicate?this._readObject:e?this._readPredicateOrNamedGraph:this._readPredicateAfterBlank}_readPredicateAfterBlank(t){switch(t.type){case".":case"}":return this._subject=null,this._readPunctuation(t);default:return this._readPredicate(t)}}_readListItem(t){let e=null,r=null,i=this._readListItem;const n=this._subject,s=this._contextStack,a=s[s.length-1];switch(t.type){case"[":this._saveContext("blank",this._graph,r=this._factory.blankNode(),this.RDF_FIRST,this._subject=e=this._factory.blankNode()),i=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",t),0!==s.length&&"list"===s[s.length-1].type&&this._emit(this._subject,this._predicate,this._object,this._graph),null===this._predicate){if(i=this._readPredicate,this._subject===this.RDF_NIL)return i}else if(i=this._getContextEndReader(),this._object===this.RDF_NIL)return i;r=this.RDF_NIL;break;case"literal":0===t.prefix.length?(this._literalValue=t.value,i=this._readListItemDataTypeOrLang):(e=this._factory.literal(t.value,this._factory.namedNode(t.prefix)),i=this._getContextEndReader());break;case"{":return this._n3Mode?(this._saveContext("formula",this._graph,this._subject,this._predicate,this._graph=this._factory.blankNode()),this._readSubject):this._error("Unexpected graph",t);default:if(void 0===(e=this._readEntity(t)))return}if(null===r&&(this._subject=r=this._factory.blankNode()),null===n?null===a.predicate?a.subject=r:a.object=r:this._emit(n,this.RDF_REST,r,this._graph),null!==e){if(this._n3Mode&&("IRI"===t.type||"prefixed"===t.type))return this._saveContext("item",this._graph,r,this.RDF_FIRST,e),this._subject=e,this._predicate=null,this._getPathReader(this._readListItem);this._emit(r,this.RDF_FIRST,e,this._graph)}return i}_readDataTypeOrLang(t){return this._completeObjectLiteral(t,!1)}_readListItemDataTypeOrLang(t){return this._completeObjectLiteral(t,!0)}_completeLiteral(t){let e=this._factory.literal(this._literalValue);switch(t.type){case"type":case"typeIRI":const r=this._readEntity(t);if(void 0===r)return;e=this._factory.literal(this._literalValue,r),t=null;break;case"langcode":e=this._factory.literal(this._literalValue,t.value),t=null}return{token:t,literal:e}}_completeSubjectLiteral(t){return this._subject=this._completeLiteral(t).literal,this._readPredicateOrNamedGraph}_completeObjectLiteral(t,e){const r=this._completeLiteral(t);if(r)return this._object=r.literal,e&&this._emit(this._subject,this.RDF_FIRST,this._object,this._graph),null===r.token?this._getContextEndReader():(this._readCallback=this._getContextEndReader(),this._readCallback(r.token))}_readFormulaTail(t){return"}"!==t.type?this._readPunctuation(t):(null!==this._subject&&this._emit(this._subject,this._predicate,this._object,this._graph),this._restoreContext("formula",t),null===this._object?this._readPredicate:this._getContextEndReader())}_readPunctuation(t){let e,r=this._graph;const i=this._subject,n=this._inversePredicate;switch(t.type){case"}":if(null===this._graph)return this._error("Unexpected graph closing",t);if(this._n3Mode)return this._readFormulaTail(t);this._graph=null;case".":this._subject=null,e=this._contextStack.length?this._readSubject:this._readInTopContext,n&&(this._inversePredicate=!1);break;case";":e=this._readPredicate;break;case",":e=this._readObject;break;case"{|":if(!this._supportsRDFStar)return this._error("Unexpected RDF-star syntax",t);const s=this._predicate,a=this._object;this._subject=this._factory.quad(i,s,a,this.DEFAULTGRAPH),e=this._readPredicate;break;case"|}":if("Quad"!==this._subject.termType)return this._error("Unexpected asserted triple closing",t);this._subject=null,e=this._readPunctuation;break;default:if(this._supportsQuads&&null===this._graph&&void 0!==(r=this._readEntity(t))){e=this._readQuadPunctuation;break}return this._error(`Expected punctuation to follow "${this._object.id}"`,t)}if(null!==i){const t=this._predicate,e=this._object;n?this._emit(e,t,i,r):this._emit(i,t,e,r)}return e}_readBlankNodePunctuation(t){let e;switch(t.type){case";":e=this._readPredicate;break;case",":e=this._readObject;break;default:return this._error(`Expected punctuation to follow "${this._object.id}"`,t)}return this._emit(this._subject,this._predicate,this._object,this._graph),e}_readQuadPunctuation(t){return"."!==t.type?this._error("Expected dot to follow quad",t):this._readInTopContext}_readPrefix(t){return"prefix"!==t.type?this._error("Expected prefix to follow @prefix",t):(this._prefix=t.value,this._readPrefixIRI)}_readPrefixIRI(t){if("IRI"!==t.type)return this._error(`Expected IRI to follow prefix "${this._prefix}:"`,t);const e=this._readEntity(t);return this._prefixes[this._prefix]=e.value,this._prefixCallback(this._prefix,e),this._readDeclarationPunctuation}_readBaseIRI(t){const e="IRI"===t.type&&this._resolveIRI(t.value);return e?(this._setBase(e),this._readDeclarationPunctuation):this._error("Expected valid IRI to follow base declaration",t)}_readNamedGraphLabel(t){switch(t.type){case"IRI":case"blank":case"prefixed":return this._readSubject(t),this._readGraph;case"[":return this._readNamedGraphBlankLabel;default:return this._error("Invalid graph label",t)}}_readNamedGraphBlankLabel(t){return"]"!==t.type?this._error("Invalid graph label",t):(this._subject=this._factory.blankNode(),this._readGraph)}_readDeclarationPunctuation(t){return this._sparqlStyle?(this._sparqlStyle=!1,this._readInTopContext(t)):"."!==t.type?this._error("Expected declaration to end with a dot",t):this._readInTopContext}_readQuantifierList(t){let e;switch(t.type){case"IRI":case"prefixed":if(void 0!==(e=this._readEntity(t,!0)))break;default:return this._error(`Unexpected ${t.type}`,t)}return this._explicitQuantifiers?(null===this._subject?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,e,this.QUANTIFIERS_GRAPH)):this._quantified[e.id]=this._factory[this._quantifier](this._factory.blankNode().value),this._readQuantifierPunctuation}_readQuantifierPunctuation(t){return","===t.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(t))}_getPathReader(t){return this._afterPath=t,this._readPath}_readPath(t){switch(t.type){case"!":return this._readForwardPath;case"^":return this._readBackwardPath;default:const e=this._contextStack,r=e.length&&e[e.length-1];if(r&&"item"===r.type){const e=this._subject;this._restoreContext("item",t),this._emit(this._subject,this.RDF_FIRST,e,this._graph)}return this._afterPath(t)}}_readForwardPath(t){let e,r;const i=this._factory.blankNode();if(void 0!==(r=this._readEntity(t)))return null===this._predicate?(e=this._subject,this._subject=i):(e=this._object,this._object=i),this._emit(e,r,i,this._graph),this._readPath}_readBackwardPath(t){const e=this._factory.blankNode();let r,i;if(void 0!==(r=this._readEntity(t)))return null===this._predicate?(i=this._subject,this._subject=e):(i=this._object,this._object=e),this._emit(e,r,i,this._graph),this._readPath}_readRDFStarTailOrGraph(t){return">>"!==t.type?this._supportsQuads&&null===this._graph&&void 0!==(this._graph=this._readEntity(t))?this._readRDFStarTail:this._error(`Expected >> to follow "${this._object.id}"`,t):this._readRDFStarTail(t)}_readRDFStarTail(t){if(">>"!==t.type)return this._error(`Expected >> but got ${t.type}`,t);const e=this._factory.quad(this._subject,this._predicate,this._object,this._graph||this.DEFAULTGRAPH);return this._restoreContext("<<",t),null===this._subject?(this._subject=e,this._readPredicate):(this._object=e,this._getContextEndReader())}_getContextEndReader(){const t=this._contextStack;if(!t.length)return this._readPunctuation;switch(t[t.length-1].type){case"blank":return this._readBlankNodeTail;case"list":return this._readListItem;case"formula":return this._readFormulaTail;case"<<":return this._readRDFStarTailOrGraph}}_emit(t,e,r,i){this._callback(null,this._factory.quad(t,e,r,i||this.DEFAULTGRAPH))}_error(t,e){const r=new Error(`${t} on line ${e.line}.`);r.context={token:e,line:e.line,previousToken:this._lexer.previousToken},this._callback(r),this._callback=ae}_resolveIRI(t){return/^[a-z][a-z0-9+.-]*:/i.test(t)?t:this._resolveRelativeIRI(t)}_resolveRelativeIRI(t){if(!t.length)return this._base;switch(t[0]){case"#":return this._base+t;case"?":return this._base.replace(/(?:\?.*)?$/,t);case"/":return("/"===t[1]?this._baseScheme:this._baseRoot)+this._removeDotSegments(t);default:return/^[^/:]*:/.test(t)?null:this._removeDotSegments(this._basePath+t)}}_removeDotSegments(t){if(!/(^|\/)\.\.?($|[/#?])/.test(t))return t;const e=t.length;let r="",i=-1,n=-1,s=0,a="/";for(;i<e;){switch(a){case":":if(n<0&&"/"===t[++i]&&"/"===t[++i])for(;(n=i+1)<e&&"/"!==t[n];)i=n;break;case"?":case"#":i=e;break;case"/":if("."===t[i+1])switch(a=t[1+ ++i],a){case"/":r+=t.substring(s,i-1),s=i+1;break;case void 0:case"?":case"#":return r+t.substring(s,i)+t.substr(i+1);case".":if(a=t[1+ ++i],void 0===a||"/"===a||"?"===a||"#"===a){if(r+=t.substring(s,i-2),(s=r.lastIndexOf("/"))>=n&&(r=r.substr(0,s)),"/"!==a)return`${r}/${t.substr(i+1)}`;s=i+1}}}a=t[++i]}return r+t.substring(s)}parse(t,e,r){let i,n,s;if(e&&(e.onQuad||e.onPrefix||e.onComment)?(i=e.onQuad,n=e.onPrefix,s=e.onComment):(i=e,n=r),this._readCallback=this._readInTopContext,this._sparqlStyle=!1,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix?this._blankNodePrefix.substr(2):`b${ne++}_`,this._prefixCallback=n||ae,this._inversePredicate=!1,this._quantified=Object.create(null),!i){const e=[];let r;if(this._callback=(t,i)=>{t?r=t:i&&e.push(i)},this._lexer.tokenize(t).every((t=>this._readCallback=this._readCallback(t))),r)throw r;return e}let a=(t,e)=>{null!==t?(this._callback(t),this._callback=ae):this._readCallback&&(this._readCallback=this._readCallback(e))};s&&(this._lexer.comments=!0,a=(t,e)=>{null!==t?(this._callback(t),this._callback=ae):this._readCallback&&("comment"===e.type?s(e.value):this._readCallback=this._readCallback(e))}),this._callback=i,this._lexer.tokenize(t,a)}}function ae(){}function oe(t,e){t._factory=e,t.DEFAULTGRAPH=e.defaultGraph(),t.RDF_FIRST=e.namedNode(jt.rdf.first),t.RDF_REST=e.namedNode(jt.rdf.rest),t.RDF_NIL=e.namedNode(jt.rdf.nil),t.N3_FORALL=e.namedNode(jt.r.forAll),t.N3_FORSOME=e.namedNode(jt.r.forSome),t.ABBREVIATIONS={a:e.namedNode(jt.rdf.type),"=":e.namedNode(jt.owl.sameAs),">":e.namedNode(jt.log.implies),"<":e.namedNode(jt.log.isImpliedBy)},t.QUANTIFIERS_GRAPH=e.namedNode("urn:n3:quantifiers")}if(oe(se.prototype,Xt),void 0===he)var he={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12};class le{constructor(t,e){this.options=e||{},this.kb=t,this.target=e.target||{graph:{subjects:{},prefixes:{},terms:{}}},this.blankNodes=[],this.htmlOptions={selfClosing:"br img input area base basefont col colgroup source wbr isindex link meta param hr"},this.theOne="_:"+(new Date).getTime(),this.language=null,this.vocabulary=null,this.blankCounter=0,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"}],this.inXHTMLMode=!1,this.absURIRE=/[\w\_\-]+:\S+/,this.finishedHandlers=[],this.init()}addTriple(t,e,r,i){var n,s,a,o;n=void 0===e?A.namedNode(this.options.base):this.toRDFNodeObject(e),a=this.toRDFNodeObject(r),s=this.toRDFNodeObject(i),o=A.namedNode(this.options.base),this.kb.add(n,a,s,o)}ancestorPath(t){for(var e="";t&&t.nodeType!==he.DOCUMENT_NODE;)e="/"+t.localName+e,t=t.parentNode;return e}copyMappings(t){var e={};for(var r in t)e[r]=t[r];return e}copyProperties(){}deriveDateTimeType(t){for(var e=0;e<le.dateTimeTypes.length;e++){var r=le.dateTimeTypes[e].pattern.exec(t);if(r&&r[0].length===t.length)return le.dateTimeTypes[e].type}return null}init(){}newBlankNode(){return this.blankCounter++,"_:"+this.blankCounter}newSubjectOrigin(t,e){}parseCURIE(t,e,r){var i,n=t.indexOf(":");if(n>=0){var s=t.substring(0,n);if(""===s)return(i=e[""])?i+t.substring(n+1):null;if("_"===s)return"_:"+t.substring(n+1);if(le.NCNAME.test(s)&&(i=e[s]))return i+t.substring(n+1)}return null}parseCURIEOrURI(t,e,r){return this.parseCURIE(t,e,r)||this.resolveAndNormalize(r,t)}parsePredicate(t,e,r,i,n,s){if(""===t)return null;var a=this.parseTermOrCURIEOrAbsURI(t,e,s?null:r,i,n);return a&&0===a.indexOf("_:")?null:a}parsePrefixMappings(t,e){for(var r=this.tokenize(t),i=null,n=0;n<r.length;n++)":"===r[n][r[n].length-1]?i=r[n].substring(0,r[n].length-1):i&&(e[i]=this.options.base?b.join(r[n],this.options.base):r[n],i=null)}static parseRDFaDOM(t,e,r){var i=new le(e,{base:r});t.baseURI||(t.baseURI=r),i.process(t,{baseURI:r})}parseSafeCURIEOrCURIEOrURI(t,e,r){return"["===(t=this.trim(t)).charAt(0)&&"]"===t.charAt(t.length-1)?0===(t=(t=t.substring(1,t.length-1)).trim(t)).length?null:"_:"===t?this.theOne:this.parseCURIE(t,e,r):this.parseCURIEOrURI(t,e,r)}parseTermOrCURIEOrAbsURI(t,e,r,i,n){t=this.trim(t);var s=this.parseCURIE(t,i,n);if(s)return s;if(r){if(e&&!this.absURIRE.exec(t))return e+t;var a=r[t];if(a)return a;if(a=r[t.toLowerCase()])return a}return this.absURIRE.exec(t)?this.resolveAndNormalize(n,t):null}parseTermOrCURIEOrURI(t,e,r,i,n){t=this.trim(t);var s=this.parseCURIE(t,i,n);if(s)return s;var a=r[t];return a||((a=r[t.toLowerCase()])?a:e&&!this.absURIRE.exec(t)?e+t:this.resolveAndNormalize(n,t))}parseURI(t){return t}process(t,e){var r;e=e||{},t.nodeType===he.DOCUMENT_NODE?(t.baseURI&&!e.baseURI&&(e.baseURI=t.baseURI),r=t.baseURI,(t=t.documentElement).baseURI||(t.baseURI=r),this.setContext(t)):t.parentNode.nodeType===he.DOCUMENT_NODE&&this.setContext(t);var i=[],n=function(t){if(!t&&e&&e.baseURI)return e.baseURI;var r=t.indexOf("#");return r>=0&&(t=t.substring(0,r)),e&&e.baseURIMap&&(t=e.baseURIMap(t)),t};for(i.push({current:t,context:this.push(null,n(t.baseURI))});i.length>0;){var s=i.shift();if(s.parent){if(s.context.parent&&s.context.parent.listMapping===s.listMapping)continue;for(let t in s.listMapping){var a=s.listMapping[t];if(0!==a.length){var o=[];for(let t=0;t<a.length;t++)o.push(this.newBlankNode());for(let t=0;t<o.length;t++)this.addTriple(s.parent,o[t],"http://www.w3.org/1999/02/22-rdf-syntax-ns#first",a[t]),this.addTriple(s.parent,o[t],"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",{type:le.objectURI,value:t+1<o.length?o[t+1]:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"});this.addTriple(s.parent,s.subject,t,{type:le.objectURI,value:o[0]})}else this.addTriple(s.parent,s.subject,t,{type:le.objectURI,value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"})}}else{var h=s.current,l=s.context,u=!1,c=null,f=null,d=null,p=l.prefixes,g=!1,m=[],w=l.listMapping,y=!l.parent,v=l.language,_=l.vocabulary;r=this.parseURI(n(h.baseURI)),h.item=null;var x=h.getAttributeNode("vocab");if(x){let t=this.trim(x.value);if(t.length>0){_=t;var T=r.spec;this.addTriple(h,T,"http://www.w3.org/ns/rdfa#usesVocabulary",{type:le.objectURI,value:_})}else _=this.vocabulary}for(var A=0;A<h.attributes.length;A++){var N=h.attributes[A];if("x"===N.nodeName.charAt(0)&&0===N.nodeName.indexOf("xmlns:")){g||(p=this.copyMappings(p),g=!0);var E=N.nodeName.substring(6),R=le.trim(N.value);p[E]=this.options.base?b.join(R,this.options.base):R}}var k=h.getAttributeNode("prefix");k&&(g||(p=this.copyMappings(p),g=!0),this.parsePrefixMappings(k.value,p));var I=null;for(let t=0;!I&&t<this.langAttributes.length;t++)I=h.getAttributeNodeNS(this.langAttributes[t].namespaceURI,this.langAttributes[t].localName);if(I){let t=le.trim(I.value);v=t.length>0?t:null}var C,O,j=h.getAttributeNode("rel"),S=h.getAttributeNode("rev"),F=h.getAttributeNode("typeof"),U=h.getAttributeNode("property"),D=h.getAttributeNode("datatype"),L=this.inHTMLMode?h.getAttributeNode("datetime"):null,M=h.getAttributeNode("content"),P=h.getAttributeNode("about"),B=h.getAttributeNode("src"),q=h.getAttributeNode("resource"),$=h.getAttributeNode("href"),H=h.getAttributeNode("inlist"),X=[];if(j){O=this.tokenize(j.value);for(let t=0;t<O.length;t++)(C=this.parsePredicate(O[t],_,l.terms,p,r,this.inHTMLMode&&null!==U))&&X.push(C)}var z=[];if(S){O=this.tokenize(S.value);for(let t=0;t<O.length;t++)(C=this.parsePredicate(O[t],_,l.terms,p,r,this.inHTMLMode&&U))&&z.push(C)}if(this.inHTMLMode&&(j||S)&&U&&(0===X.length&&(j=null),0===z.length&&(S=null)),j||S?(P&&(c=this.parseSafeCURIEOrCURIEOrURI(P.value,p,r)),F&&(d=c),c||(h.parentNode.nodeType===he.DOCUMENT_NODE?c=n(h.baseURI):l.parentObject&&(c=n(h.parentNode.baseURI)===l.parentObject?n(h.baseURI):l.parentObject)),q&&(f=this.parseSafeCURIEOrCURIEOrURI(q.value,p,r)),f||($?f=this.resolveAndNormalize(r,encodeURI($.value)):B?f=this.resolveAndNormalize(r,encodeURI(B.value)):!F||P||this.inXHTMLMode&&("head"===h.localName||"body"===h.localName)||(f=this.newBlankNode())),!F||P||!this.inXHTMLMode||"head"!==h.localName&&"body"!==h.localName?F&&!P&&(d=f):d=c):!U||M||D?(P&&(c=this.parseSafeCURIEOrCURIEOrURI(P.value,p,r)),!c&&q&&(c=this.parseSafeCURIEOrCURIEOrURI(q.value,p,r)),!c&&$&&(c=this.resolveAndNormalize(r,encodeURI($.value))),!c&&B&&(c=this.resolveAndNormalize(r,encodeURI(B.value))),c||(h.parentNode.nodeType===he.DOCUMENT_NODE?c=n(h.baseURI):!this.inXHTMLMode&&!this.inHTMLMode||"head"!==h.localName&&"body"!==h.localName?F?c=this.newBlankNode():l.parentObject&&(c=n(h.parentNode.baseURI)===l.parentObject?n(h.baseURI):l.parentObject,U||(u=!0)):c=n(h.parentNode.baseURI)===l.parentObject?n(h.baseURI):l.parentObject),F&&(d=c)):(P&&(c=this.parseSafeCURIEOrCURIEOrURI(P.value,p,r),F&&(d=c)),c||h.parentNode.nodeType!==he.DOCUMENT_NODE?!c&&l.parentObject&&(c=n(h.parentNode.baseURI)===l.parentObject?n(h.baseURI):l.parentObject):(c=n(h.baseURI),F&&(d=c)),F&&!d&&(q&&(d=this.parseSafeCURIEOrCURIEOrURI(q.value,p,r)),!d&&$&&(d=this.resolveAndNormalize(r,encodeURI($.value))),!d&&B&&(d=this.resolveAndNormalize(r,encodeURI(B.value))),d||!this.inXHTMLMode&&!this.inHTMLMode||"head"!==h.localName&&"body"!==h.localName||(d=c),d||(d=this.newBlankNode()),f=d)),c&&(P||q||d)){var Q=c;F&&!P&&!q&&f&&(Q=f),this.newSubjectOrigin(h,Q)}if(d){O=this.tokenize(F.value);for(let t=0;t<O.length;t++){var V=this.parseTermOrCURIEOrAbsURI(O[t],_,l.terms,p,r);V&&this.addTriple(h,d,le.typeURI,{type:le.objectURI,value:V})}}if(c&&c!==l.parentObject&&(w={},y=!0),f){if(j&&H)for(let t=0;t<X.length;t++){let e=w[X[t]];e||(e=[],w[X[t]]=e),e.push({type:le.objectURI,value:f})}else if(j)for(let t=0;t<X.length;t++)this.addTriple(h,c,X[t],{type:le.objectURI,value:f});if(S)for(let t=0;t<z.length;t++)this.addTriple(h,f,z[t],{type:le.objectURI,value:c})}else{if(c&&!f&&(j||S)&&(f=this.newBlankNode()),j&&H)for(let t=0;t<X.length;t++){let e=w[X[t]];e||(e=[],w[C]=e),m.push({predicate:X[t],list:e})}else if(j)for(let t=0;t<X.length;t++)m.push({predicate:X[t],forward:!0});if(S)for(let t=0;t<z.length;t++)m.push({predicate:z[t],forward:!1})}if(U){var G=null,W=null;D?(G=""===D.value?le.PlainLiteralURI:this.parseTermOrCURIEOrAbsURI(D.value,_,l.terms,p,r),W=L&&!M?L.value:G===le.XMLLiteralURI||G===le.HTMLLiteralURI?null:M?M.value:h.textContent):M?(G=le.PlainLiteralURI,W=M.value):L?(W=L.value,(G=le.deriveDateTimeType(W))||(G=le.PlainLiteralURI)):j||S||(q&&(W=this.parseSafeCURIEOrCURIEOrURI(q.value,p,r)),!W&&$?W=this.resolveAndNormalize(r,encodeURI($.value)):!W&&B&&(W=this.resolveAndNormalize(r,encodeURI(B.value))),W&&(G=le.objectURI)),G||(F&&!P?(G=le.objectURI,W=d):(W=h.textContent,this.inHTMLMode&&"time"===h.localName&&(G=le.deriveDateTimeType(W)),G||(G=le.PlainLiteralURI))),O=this.tokenize(U.value);for(let t=0;t<O.length;t++){let e=this.parsePredicate(O[t],_,l.terms,p,r);if(e)if(H){let t=w[e];t||(t=[],w[e]=t),t.push(G===le.XMLLiteralURI||G===le.HTMLLiteralURI?{type:G,value:h.childNodes}:{type:G||le.PlainLiteralURI,value:W,language:v})}else G===le.XMLLiteralURI||G===le.HTMLLiteralURI?this.addTriple(h,c,e,{type:G,value:h.childNodes}):this.addTriple(h,c,e,{type:G||le.PlainLiteralURI,value:W,language:v})}}if(c&&!u)for(let t=0;t<l.incomplete.length;t++)l.incomplete[t].list?l.incomplete[t].list.push({type:le.objectURI,value:c}):l.incomplete[t].forward?this.addTriple(h,l.subject,l.incomplete[t].predicate,{type:le.objectURI,value:c}):this.addTriple(h,c,l.incomplete[t].predicate,{type:le.objectURI,value:l.subject});var Y=null,Z=c;u?((Y=this.push(l,l.subject)).parentObject=n(h.parentNode.baseURI)===l.parentObject?n(h.baseURI):l.parentObject,Y.incomplete=l.incomplete,Y.language=v,Y.prefixes=p,Y.vocabulary=_):((Y=this.push(l,c)).parentObject=f||c||l.subject,Y.prefixes=p,Y.incomplete=m,f&&(Z=f,w={},y=!0),Y.listMapping=w,Y.language=v,Y.vocabulary=_),y&&i.unshift({parent:h,context:l,subject:Z,listMapping:w});for(var J=h.lastChild;J;J=J.previousSibling)J.nodeType===he.ELEMENT_NODE&&i.unshift({current:J,context:Y})}}this.inHTMLMode&&this.copyProperties();for(let e=0;e<this.finishedHandlers.length;e++)this.finishedHandlers[e](t)}push(t,e){return{parent:t,subject:e||(t?t.subject:null),parentObject:null,incomplete:[],listMapping:t?t.listMapping:{},language:t?t.language:this.language,prefixes:t?t.prefixes:this.target.graph.prefixes,terms:t?t.terms:this.target.graph.terms,vocabulary:t?t.vocabulary:this.vocabulary}}resolveAndNormalize(t,e){return b.join(e,t)}setContext(t){"html"===t.localName&&"XHTML+RDFa 1.1"===t.getAttribute("version")?this.setXHTMLContext():"html"===t.localName||"http://www.w3.org/1999/xhtml"===t.namespaceURI?"undefined"!=typeof document&&document.doctype?"-//W3C//DTD XHTML+RDFa 1.0//EN"===document.doctype.publicId&&"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"===document.doctype.systemId?(console.log("WARNING: RDF 1.0 is not supported. Defaulting to HTML5 mode."),this.setHTMLContext()):"-//W3C//DTD XHTML+RDFa 1.1//EN"===document.doctype.publicId&&"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd"===document.doctype.systemId?this.setXHTMLContext():this.setHTMLContext():this.setHTMLContext():this.setXMLContext()}setHTMLContext(){this.setInitialContext(),this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"},{namespaceURI:null,localName:"lang"}],this.inXHTMLMode=!1,this.inHTMLMode=!0}setInitialContext(){this.vocabulary=null,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"}]}setXHTMLContext(){this.setInitialContext(),this.inXHTMLMode=!0,this.inHTMLMode=!1,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"},{namespaceURI:null,localName:"lang"}],this.target.graph.terms.alternate="http://www.w3.org/1999/xhtml/vocab#alternate",this.target.graph.terms.appendix="http://www.w3.org/1999/xhtml/vocab#appendix",this.target.graph.terms.bookmark="http://www.w3.org/1999/xhtml/vocab#bookmark",this.target.graph.terms.cite="http://www.w3.org/1999/xhtml/vocab#cite",this.target.graph.terms.chapter="http://www.w3.org/1999/xhtml/vocab#chapter",this.target.graph.terms.contents="http://www.w3.org/1999/xhtml/vocab#contents",this.target.graph.terms.copyright="http://www.w3.org/1999/xhtml/vocab#copyright",this.target.graph.terms.first="http://www.w3.org/1999/xhtml/vocab#first",this.target.graph.terms.glossary="http://www.w3.org/1999/xhtml/vocab#glossary",this.target.graph.terms.help="http://www.w3.org/1999/xhtml/vocab#help",this.target.graph.terms.icon="http://www.w3.org/1999/xhtml/vocab#icon",this.target.graph.terms.index="http://www.w3.org/1999/xhtml/vocab#index",this.target.graph.terms.last="http://www.w3.org/1999/xhtml/vocab#last",this.target.graph.terms.license="http://www.w3.org/1999/xhtml/vocab#license",this.target.graph.terms.meta="http://www.w3.org/1999/xhtml/vocab#meta",this.target.graph.terms.next="http://www.w3.org/1999/xhtml/vocab#next",this.target.graph.terms.prev="http://www.w3.org/1999/xhtml/vocab#prev",this.target.graph.terms.previous="http://www.w3.org/1999/xhtml/vocab#previous",this.target.graph.terms.section="http://www.w3.org/1999/xhtml/vocab#section",this.target.graph.terms.stylesheet="http://www.w3.org/1999/xhtml/vocab#stylesheet",this.target.graph.terms.subsection="http://www.w3.org/1999/xhtml/vocab#subsection",this.target.graph.terms.start="http://www.w3.org/1999/xhtml/vocab#start",this.target.graph.terms.top="http://www.w3.org/1999/xhtml/vocab#top",this.target.graph.terms.up="http://www.w3.org/1999/xhtml/vocab#up",this.target.graph.terms.p3pv1="http://www.w3.org/1999/xhtml/vocab#p3pv1",this.target.graph.terms.related="http://www.w3.org/1999/xhtml/vocab#related",this.target.graph.terms.role="http://www.w3.org/1999/xhtml/vocab#role",this.target.graph.terms.transformation="http://www.w3.org/1999/xhtml/vocab#transformation"}setXMLContext(){this.setInitialContext(),this.inXHTMLMode=!1,this.inHTMLMode=!1}tokenize(t){return this.trim(t).split(/\s+/)}static tokenize(t){return this.trim(t).split(/\s+/)}toRDFNodeObject(t){if(void 0!==t){if("string"==typeof t)return"_:"===t.substring(0,2)?(void 0===this.blankNodes[t.substring(2)]&&(this.blankNodes[t.substring(2)]=new n(t.substring(2))),this.blankNodes[t.substring(2)]):A.namedNode(t);switch(t.type){case le.objectURI:return"_:"===t.value.substring(0,2)?(void 0===this.blankNodes[t.value.substring(2)]&&(this.blankNodes[t.value.substring(2)]=new n(t.value.substring(2))),this.blankNodes[t.value.substring(2)]):A.namedNode(t.value);case le.PlainLiteralURI:return new u(t.value,t.language||"");case le.XMLLiteralURI:case le.HTMLLiteralURI:var e="";return Object.keys(t.value).forEach((r=>{e+=C.domToString(t.value[r],this.htmlOptions)})),new u(e,"",new s.A(t.type));default:return new u(t.value,"",new s.A(t.type))}}}trim(t){return t.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}static trim(t){return t.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}}le.XMLLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",le.HTMLLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML",le.PlainLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral",le.objectURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#object",le.typeURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",le.nameChar="[-A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ--⁰-Ⰰ-、-豈-﷏ﷰ-�က0-F.0-9·̀-ͯ‿-⁀]",le.nameStartChar="[A-Za-zÀ-ÖØ-öø-ÿĀ-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁΆΈ-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁҐ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆא-תװ-ײء-غف-يٱ-ڷں-ھۀ-ێې-ۓەۥ-ۦअ-हऽक़-ॡঅ-ঌএ-ঐও-নপ-রলশ-হড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઋઍએ-ઑઓ-નપ-રલ-ળવ-હઽૠଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଶ-ହଽଡ଼-ଢ଼ୟ-ୡஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-வஷ-ஹఅ-ఌఎ-ఐఒ-నప-ళవ-హౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹೞೠ-ೡഅ-ഌഎ-ഐഒ-നപ-ഹൠ-ൡก-ฮะา-ำเ-ๅກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ຮະາ-ຳຽເ-ໄཀ-ཇཉ-ཀྵႠ-Ⴥა-ჶᄀᄂ-ᄃᄅ-ᄇᄉᄋ-ᄌᄎ-ᄒᄼᄾᅀᅌᅎᅐᅔ-ᅕᅙᅟ-ᅡᅣᅥᅧᅩᅭ-ᅮᅲ-ᅳᅵᆞᆨᆫᆮ-ᆯᆷ-ᆸᆺᆼ-ᇂᇫᇰᇹḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼΩK-Å℮ↀ-ↂぁ-ゔァ-ヺㄅ-ㄬ가-힣一-龥〇〡-〩_]",le.NCNAME=new RegExp("^"+le.nameStartChar+le.nameChar+"*$"),le.dateTimeTypes=[{pattern:/-?P(?:[0-9]+Y)?(?:[0-9]+M)?(?:[0-9]+D)?(?:T(?:[0-9]+H)?(?:[0-9]+M)?(?:[0-9]+(?:\.[0-9]+)?S)?)?/,type:"http://www.w3.org/2001/XMLSchema#duration"},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]-[0-9][0-9]T(?:[0-1][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:"http://www.w3.org/2001/XMLSchema#dateTime"},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]-[0-9][0-9](?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:"http://www.w3.org/2001/XMLSchema#date"},{pattern:/(?:[0-1][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:"http://www.w3.org/2001/XMLSchema#time"},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]/,type:"http://www.w3.org/2001/XMLSchema#gYearMonth"},{pattern:/-?[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9]/,type:"http://www.w3.org/2001/XMLSchema#gYear"}];const ue=le.parseRDFaDOM;class ce{constructor(t){this.store=t,this.bnodes={},this.why=null,this.reify=!1}frameFactory(t,e,r){return{NODE:1,ARC:2,parent:e,parser:t,store:t.store,element:r,lastChild:0,base:null,lang:null,node:null,nodeType:null,listIndex:1,rdfid:null,datatype:null,collection:!1,terminateFrame:function(){this.collection&&this.node.close()},addSymbol:function(t,e){e=b.join(e,this.base),this.node=this.store.sym(e),this.nodeType=t},loadTriple:function(){if(this.parent.parent.collection?this.parent.parent.node.append(this.node):this.store.add(this.parent.parent.node,this.parent.node,this.node,this.parser.why),null!=this.parent.rdfid){var t=this.store.sym(b.join("#"+this.parent.rdfid,this.base));this.store.add(t,this.store.sym(ce.ns.RDF+"type"),this.store.sym(ce.ns.RDF+"Statement"),this.parser.why),this.store.add(t,this.store.sym(ce.ns.RDF+"subject"),this.parent.parent.node,this.parser.why),this.store.add(t,this.store.sym(ce.ns.RDF+"predicate"),this.parent.node,this.parser.why),this.store.add(t,this.store.sym(ce.ns.RDF+"object"),this.node,this.parser.why)}},isTripleToLoad:function(){return null!=this.parent&&null!=this.parent.parent&&this.nodeType===this.NODE&&this.parent.nodeType===this.ARC&&this.parent.parent.nodeType===this.NODE},addNode:function(t){this.addSymbol(this.NODE,t),this.isTripleToLoad()&&this.loadTriple()},addCollection:function(){this.nodeType=this.NODE,this.node=this.store.collection(),this.collection=!0,this.isTripleToLoad()&&this.loadTriple()},addCollectionArc:function(){this.nodeType=this.ARC},addBNode:function(t){null!=t?null!=this.parser.bnodes[t]?this.node=this.parser.bnodes[t]:this.node=this.parser.bnodes[t]=this.store.bnode():this.node=this.store.bnode(),this.nodeType=this.NODE,this.isTripleToLoad()&&this.loadTriple()},addArc:function(t){t===ce.ns.RDF+"li"&&(t=ce.ns.RDF+"_"+this.parent.listIndex,this.parent.listIndex++),this.addSymbol(this.ARC,t)},addLiteral:function(t){this.parent.datatype&&this.parent.datatype!==ce.ns.RDF+"langString"?this.node=this.store.literal(t,this.store.sym(this.parent.datatype)):this.node=this.store.literal(t,this.lang),this.nodeType=this.NODE,this.isTripleToLoad()&&this.loadTriple()}}}getAttributeNodeNS(t,e,r){var i=null;if(t.getAttributeNodeNS)i=t.getAttributeNodeNS(e,r);else for(var n,s=t.attributes,a=0;a<s.length;++a)if((n=s[a]).namespaceURI===e&&(n.prefix?n.prefix+":"+r:r)===n.nodeName){i=n;break}return i}parse(t,e,r){var i,n=t.childNodes;if(this.cleanParser(),t.nodeType===ce.nodeType.DOCUMENT){for(var s=0;s<n.length;s++)if(n[s].nodeType===ce.nodeType.ELEMENT){i=n[s];break}}else{if(t.nodeType!==ce.nodeType.ELEMENT)throw new Error("RDFParser: can't find root in "+e+". Halting. ");i=t}this.why=r;var a=this.frameFactory(this);return this.base=e,a.base=e,a.lang=null,this.parseDOM(this.buildFrame(a,i)),!0}parseDOM(t){for(var e,r=function(t){var e="";if(null==t.namespaceURI)throw new Error("RDF/XML syntax error: No namespace for "+t.localName+" in "+this.base);return t.namespaceURI&&(e+=t.namespaceURI),t.localName?e+=t.localName:t.nodeName&&(t.nodeName.indexOf(":")>=0?e+=t.nodeName.split(":")[1]:e+=t.nodeName),e}.bind(this),i=!0;t.parent;){var n=t.element,s=n.attributes;if(n.nodeType===ce.nodeType.TEXT||n.nodeType===ce.nodeType.CDATA_SECTION)t.parent.nodeType===t.NODE&&(t.addArc(ce.ns.RDF+"value"),t=this.buildFrame(t)),t.addLiteral(n.nodeValue);else if(r(n)!==ce.ns.RDF+"RDF")if(t.parent&&t.parent.collection&&(t.addCollectionArc(),(t=this.buildFrame(t,t.element)).parent.element=null),t.parent&&t.parent.nodeType&&t.parent.nodeType!==t.ARC){t.addArc(r(n)),this.reify&&(e=this.getAttributeNodeNS(n,ce.ns.RDF,"ID"))&&(t.rdfid=e.nodeValue,n.removeAttributeNode(e));var a=this.getAttributeNodeNS(n,ce.ns.RDF,"parseType"),o=this.getAttributeNodeNS(n,ce.ns.RDF,"datatype");if(o&&(t.datatype=o.nodeValue,n.removeAttributeNode(o)),a){var h=a.nodeValue;"Literal"===h?(t.datatype=ce.ns.RDF+"XMLLiteral",(t=this.buildFrame(t)).addLiteral(n.innerHTML||n.childNodes),i=!1):"Resource"===h?((t=this.buildFrame(t,t.element)).parent.element=null,t.addBNode()):"Collection"===h&&((t=this.buildFrame(t,t.element)).parent.element=null,t.addCollection()),n.removeAttributeNode(a)}if(0!==s.length){var l=this.getAttributeNodeNS(n,ce.ns.RDF,"resource"),u=this.getAttributeNodeNS(n,ce.ns.RDF,"nodeID");t=this.buildFrame(t),l?(t.addNode(l.nodeValue),n.removeAttributeNode(l)):u?(t.addBNode(u.nodeValue),n.removeAttributeNode(u)):t.addBNode();for(var c=s.length-1;c>=0;c--){var f=this.buildFrame(t);f.addArc(r(s[c])),r(s[c])===ce.ns.RDF+"type"?this.buildFrame(f).addNode(s[c].nodeValue):this.buildFrame(f).addLiteral(s[c].nodeValue)}}else 0===n.childNodes.length&&this.buildFrame(t).addLiteral("")}else{var d=this.getAttributeNodeNS(n,ce.ns.RDF,"about");if(e=this.getAttributeNodeNS(n,ce.ns.RDF,"ID"),d&&e)throw new Error("RDFParser: "+n.nodeName+" has both rdf:id and rdf:about. Halting. Only one of these properties may be specified on a node.");if(!d&&e)t.addNode("#"+e.nodeValue),n.removeAttributeNode(e);else if(null==d&&null==e){var p=this.getAttributeNodeNS(n,ce.ns.RDF,"nodeID");p?(t.addBNode(p.nodeValue),n.removeAttributeNode(p)):t.addBNode()}else t.addNode(d.nodeValue),n.removeAttributeNode(d);var g=this.getAttributeNodeNS(n,ce.ns.RDF,"type");ce.ns.RDF+"Description"!==r(n)&&(g={nodeValue:r(n)}),null!=g&&(this.store.add(t.node,this.store.sym(ce.ns.RDF+"type"),this.store.sym(b.join(g.nodeValue,t.base)),this.why),g.nodeName&&n.removeAttributeNode(g));for(var m=s.length-1;m>=0;m--)this.store.add(t.node,this.store.sym(r(s[m])),this.store.literal(s[m].nodeValue,t.lang),this.why)}for(n=t.element;t.parent;){for(var w=t;null==n;)n=(t=t.parent).element;var y=n.childNodes&&n.childNodes[t.lastChild];if(y&&i){if((y.nodeType===ce.nodeType.ELEMENT||y.nodeType===ce.nodeType.TEXT||y.nodeType===ce.nodeType.CDATA_SECTION)&&(y.nodeType!==ce.nodeType.TEXT&&y.nodeType!==ce.nodeType.CDATA_SECTION||1===n.childNodes.length)){t.lastChild++,t=this.buildFrame(w,n.childNodes[t.lastChild-1]);break}t.lastChild++}else{if(t.terminateFrame(),!(t=t.parent))break;n=t.element,i=!0}}}}cleanParser(){this.bnodes={},this.why=null}buildFrame(t,e){var r=this.frameFactory(this,t,e);if(t&&(r.base=t.base,r.lang=t.lang),!e||e.nodeType===ce.nodeType.TEXT||e.nodeType===ce.nodeType.CDATA_SECTION)return r;var i=e.attributes,n=e.getAttributeNode("xml:base");null!=n&&(r.base=n.nodeValue,e.removeAttribute("xml:base"));var s=e.getAttributeNode("xml:lang");null!=s&&(r.lang=s.nodeValue,e.removeAttribute("xml:lang"));for(var a=i.length-1;a>=0;a--)if("xml"===i[a].nodeName.substr(0,3)){if("xmlns:"===i[a].name.slice(0,6)){var o=i[a].nodeValue;this.base&&(o=b.join(o,this.base)),this.store.setPrefixForURI(i[a].name.slice(6),o)}e.removeAttributeNode(i[a])}return r}}function fe(t,e,r){var i,n,s,a=["INSERT","DELETE","WHERE"],o=E("http://www.w3.org/ns/pim/patch#"),h=yt(e,e,r,r,null,null,"",null),l={},u=function(t,e,r,i,n){return"Line "+(e+1)+" of <"+t+">: Bad syntax:\n "+n+'\n at: "'+r.slice(i,i+30)+'"'};i=0;var c=e.sym(r+"#query");for(l.query=c;;){if((n=h.skipSpace(t,i))<0)return l;if(";"===t[n]){if((i=h.skipSpace(t,n+1))<0)return l;n=i}var f=!1;for(s=0;s<a.length;s++){var d=a[s];if(t.slice(n,n+d.length)===d){if((i=h.skipSpace(t,n+d.length))<0)throw u(h._thisDoc,h.lines,t,n+d.length,"found EOF, needed {...} after "+d);if(("INSERT"===d||"DELETE"===d)&&"DATA"===t.slice(i,i+4)){if((n=h.skipSpace(t,i+4))<0)throw u(h._thisDoc,h.lines,t,i+4,"needed {...} after INSERT DATA "+d);i=n}var p=[];if((n=h.node(t,i,p))<0)throw u(h._thisDoc,h.lines,t,i,"bad syntax or EOF in {...} after "+d);l[d.toLowerCase()]=p[0],e.add(c,o(d.toLowerCase()),p[0]),f=!0,i=n}}if(!f&&"@prefix"===t.slice(n,n+7)){if((i=h.directive(t,n))<0)throw u(h._thisDoc,h.lines,t,i,"bad syntax or EOF after @prefix ");i=h.checkDot(t,i),f=!0}if(!f)throw u(h._thisDoc,h.lines,t,n,"Unknown syntax at start of statememt: '"+t.slice(n).slice(0,20)+"'")}}function de(t,e,r,n="text/turtle",s){n=(n=n||i.sT).split(";")[0];try{if(n===i.ny||n===i.sT)yt(e,e,r,r,null,null,"",null).loadBuf(t),o();else if(n===i.JG)new ce(e).parse(C.parseXML(t),r,e.sym(r)),o();else if(n===i.H)ue(C.parseXML(t,{contentType:i.H}),e,r),o();else if(n===i.lc)ue(C.parseXML(t,{contentType:i.lc}),e,r),o();else if(n===i.K9||n===i.Fn)fe(t,e,r),o();else if(n===i.i2)At(t,e,r).then(o).catch(h);else{if(n!==i._0&&n!==i.BR)throw void 0===n?new Error("contentType is undefined"):new Error("Don't know how to parse "+n+" yet");var a=new se({factory:xt});!function(t,r){try{a.parse(r,l)}catch(t){s(t,e)}}(null,t)}}catch(t){h(t)}function o(){s&&s(null,e)}function h(t){if(n!==i.i2||n!==i._0||n!==i.BR){if(!s){let e=new Error(t+" while trying to parse <"+r+"> as "+n);throw e.cause=t,e}s(t,e)}}function l(t,r){r?e.add(r.subject,r.predicate,r.object,r.graph):s(t,e)}de.handled={"text/n3":!0,"text/turtle":!0,"application/rdf+xml":!0,"application/xhtml+xml":!0,"text/html":!0,"application/sparql-update":!0,"application/sparql-update-single-match":!0,"application/ld+json":!0,"application/nquads":!0,"application/n-quads":!0}}(0,t.A)(ce,"ns",{RDF:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",RDFS:"http://www.w3.org/2000/01/rdf-schema#"}),(0,t.A)(ce,"nodeType",{ELEMENT:1,ATTRIBUTE:2,TEXT:3,CDATA_SECTION:4,ENTITY_REFERENCE:5,ENTITY:6,PROCESSING_INSTRUCTION:7,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,NOTATION:12});var pe=o(1147),ge=o.n(pe),me=o(362);const we={"text/n3":!0,"text/turtle":!0,"application/rdf+xml":!0,"application/xhtml+xml":!0,"text/html":!0,"application/ld+json":!0},ye={rdf:i.JG,owl:i.JG,n3:"text/n3",ttl:"text/turtle",nt:"text/n3",acl:"text/n3",html:"text/html",xml:"text/xml"},be=t=>({link:E("http://www.w3.org/2007/ont/link#",t),http:E("http://www.w3.org/2007/ont/http#",t),httph:E("http://www.w3.org/2007/ont/httph#",t),rdf:E("http://www.w3.org/1999/02/22-rdf-syntax-ns#",t),rdfs:E("http://www.w3.org/2000/01/rdf-schema#",t),dc:E("http://purl.org/dc/elements/1.1/",t),ldp:E("http://www.w3.org/ns/ldp#",t)}),ve=be();class _e{constructor(e,r){(0,t.A)(this,"response",void 0),(0,t.A)(this,"dom",void 0),this.response=e,this.dom=r}}(0,t.A)(_e,"pattern",void 0);class xe extends _e{static toString(){return"RDFXMLHandler"}static register(t){t.mediatypes[i.JG]={q:.9}}parse(t,e,r){let i=t.store;if(this.dom||(this.dom=C.parseXML(e)),"parsererror"===this.dom.documentElement.nodeName)return t.failFetch(r,"Badly formed XML in "+r.resource.value,"parse_error");let n=new ce(i);try{n.parse(this.dom,r.original.value,r.original)}catch(e){return t.failFetch(r,"Syntax error parsing RDF/XML! "+e,"parse_error")}return r.noMeta||i.add(r.original,ve.rdf("type"),ve.link("RDFDocument"),t.appNode),t.doneFetch(r,this.response)}}xe.pattern=new RegExp("application/rdf\\+xml");class Te extends _e{static toString(){return"XHTMLHandler"}static register(t){t.mediatypes[i.H]={q:.8}}parse(t,e,r){let i,n;this.dom||(this.dom=C.parseXML(e));let s=t.store,a=this.dom.getElementsByTagName("title");a.length>0&&s.add(r.resource,ve.dc("title"),s.rdfFactory.literal(a[0].textContent),r.resource);let o=this.dom.getElementsByTagName("link");for(let e=o.length-1;e>=0;e--)i=o[e].getAttribute("rel"),n=!1,i||(i=o[e].getAttribute("rev"),n=!0),i&&t.linkData(r.original,i,o[e].getAttribute("href"),r.resource,n);let h=this.dom.getElementsByTagName("script");for(let t=0;t<h.length;t++){let e=h[t].getAttribute("type");we[e]&&(de(h[t].textContent,s,r.original.value,e),de(h[t].textContent,s,r.original.value,e))}if(r.noMeta||s.add(r.resource,ve.rdf("type"),ve.link("WebPage"),t.appNode),!r.noRDFa&&ue)try{ue(this.dom,s,r.original.value)}catch(e){let i="Error trying to parse "+r.resource+" as RDFa:\n"+e+":\n"+e.stack;return t.failFetch(r,i,"parse_error")}return t.doneFetch(r,this.response)}}Te.pattern=new RegExp("application/xhtml");class Ae extends _e{static toString(){return"XMLHandler"}static register(t){t.mediatypes["text/xml"]={q:.5},t.mediatypes["application/xml"]={q:.5}}static isElement(t){return t.nodeType===Node.ELEMENT_NODE}parse(t,e,r){let i=C.parseXML(e);for(let n=0;n<i.childNodes.length;n++){const s=i.childNodes[n];if(Ae.isElement(s)){let n=s.namespaceURI;if(n&&n===n.rdf)return t.addStatus(r.req,"Has XML root element in the RDF namespace, so assume RDF/XML."),new xe(this.response,i).parse(t,e,r);break}}if(i.doctype&&"html"===i.doctype.name&&i.doctype.publicId.match(/^-\/\/W3C\/\/DTD XHTML/)&&i.doctype.systemId.match(/http:\/\/www.w3.org\/TR\/xhtml/))return t.addStatus(r.req,"Has XHTML DOCTYPE. Switching to XHTML Handler.\n"),new Te(this.response,i).parse(t,e,r);let n=i.getElementsByTagName("html")[0];if(n){let s=n.getAttribute("xmlns");if(s&&s.match(/^http:\/\/www.w3.org\/1999\/xhtml/))return t.addStatus(r.req,"Has a default namespace for XHTML. Switching to XHTMLHandler.\n"),new Te(this.response,i).parse(t,e,r)}return t.failFetch(r,"Unsupported dialect of XML: not RDF or XHTML namespace, etc.\n"+e.slice(0,80),901)}}Ae.pattern=new RegExp("(text|application)/(.*)xml");class Ne extends _e{static toString(){return"HTMLHandler"}static register(t){t.mediatypes["text/html"]={q:.8}}parse(t,e,r){let i=t.store;if(Ce(e))return t.addStatus(r.req,"Has an XML declaration. We'll assume it's XHTML as the content-type was text/html.\n"),new Te(this.response).parse(t,e,r);if(function(t){const e=t.indexOf("<!DOCTYPE html"),r=t.indexOf(">");return!(-1===e||-1===r||e>r)&&-1!==t.substr(e,r-e).indexOf("XHTML")}(e))return t.addStatus(r.req,"Has XHTML DOCTYPE. Switching to XHTMLHandler.\n"),new Te(this.response).parse(t,e,r);if(function(t){return!!t.match(/[^(<html)]*<html\s+[^<]*xmlns=['"]http:\/\/www.w3.org\/1999\/xhtml["'][^<]*>/)}(e))return t.addStatus(r.req,"Has default namespace for XHTML, so switching to XHTMLHandler.\n"),new Te(this.response).parse(t,e,r);let n=new RegExp("<title>([\\s\\S]+?)</title>","im").exec(e);return n&&i.add(r.resource,ve.dc("title"),i.rdfFactory.literal(n[1]),r.resource),i.add(r.resource,ve.rdf("type"),ve.link("WebPage"),t.appNode),t.addStatus(r.req,"non-XML HTML document, not parsed for data."),t.doneFetch(r,this.response)}}Ne.pattern=new RegExp("text/html");class Ee extends _e{static toString(){return"JsonLdHandler"}static register(t){t.mediatypes["application/ld+json"]={q:.9}}async parse(t,e,r,i){const n=t.store;try{return await At(e,n,r.original.value),t.store.add(r.original,ve.rdf("type"),ve.link("RDFDocument"),t.appNode),t.doneFetch(r,i)}catch(e){const n="Error trying to parse "+r.resource+" as JSON-LD:\n"+e;return t.failFetch(r,n,"parse_error",i)}}}Ee.pattern=/application\/(ld\+json|activity\+json)/;class Re extends _e{static toString(){return"TextHandler"}static register(t){t.mediatypes["text/plain"]={q:.5}}parse(t,e,r){return Ce(e)?(t.addStatus(r.req,"Warning: "+r.resource+" has an XML declaration. We'll assume it's XML but its content-type wasn't XML.\n"),new Ae(this.response).parse(t,e,r)):e.slice(0,500).match(/xmlns:/)?(t.addStatus(r.req,"May have an XML namespace. We'll assume it's XML but its content-type wasn't XML.\n"),new Ae(this.response).parse(t,e,r)):(t.addStatus(r.req,"Plain text document, no known RDF semantics."),t.doneFetch(r,this.response))}}Re.pattern=new RegExp("text/plain");class ke extends _e{static toString(){return"N3Handler"}static register(t){t.mediatypes["text/n3"]={},t.mediatypes["text/turtle"]={}}parse(t,e,r,i){let n=t.store,s=yt(n,n,r.original.value,r.original.value,null,null,"",null);try{s.loadBuf(e)}catch(e){let n="Error trying to parse "+r.resource+" as Notation3:\n"+e;return t.failFetch(r,n,"parse_error",i)}return t.addStatus(r.req,"N3 parsed: "+s.statementCount+" triples in "+s.lines+" lines."),t.store.add(r.original,ve.rdf("type"),ve.link("RDFDocument"),t.appNode),t.doneFetch(r,this.response)}}ke.pattern=new RegExp("(application|text)/(x-)?(rdf\\+)?(n3|turtle)");const Ie={RDFXMLHandler:xe,XHTMLHandler:Te,XMLHandler:Ae,HTMLHandler:Ne,TextHandler:Re,N3Handler:ke,JsonLdHandler:Ee};function Ce(t){return!!t.match(/\s*<\?xml\s+version\s*=[^<>]+\?>/)}class Oe{constructor(e,r={}){if((0,t.A)(this,"store",void 0),(0,t.A)(this,"timeout",void 0),(0,t.A)(this,"_fetch",void 0),(0,t.A)(this,"mediatypes",void 0),(0,t.A)(this,"appNode",void 0),(0,t.A)(this,"requested",void 0),(0,t.A)(this,"timeouts",void 0),(0,t.A)(this,"redirectedTo",void 0),(0,t.A)(this,"fetchQueue",void 0),(0,t.A)(this,"fetchCallbacks",void 0),(0,t.A)(this,"nonexistent",void 0),(0,t.A)(this,"lookedUp",void 0),(0,t.A)(this,"handlers",void 0),(0,t.A)(this,"ns",void 0),(0,t.A)(this,"fireCallbacks",void 0),this.store=e||new G,this.ns=be(this.store.rdfFactory),this.timeout=r.timeout||3e4,this._fetch=r.fetch||void 0!==o.g&&(o.g.solidFetcher||o.g.solidFetch)||"undefined"!=typeof window&&(window.solidFetcher||window.solidFetch)||ge(),!this._fetch)throw new Error("No _fetch function available for Fetcher");this.appNode=this.store.sym("chrome://TheCurrentSession"),this.store.fetcher=this,this.requested={},this.timeouts={},this.redirectedTo={},this.fetchQueue={},this.fetchCallbacks={},this.nonexistent={},this.lookedUp={},this.handlers=[],this.mediatypes={"image/*":{q:.9},"*/*":{q:.1}},C.callbackify(this,["request","fail","refresh","retract","done"]),Object.keys(r.handlers||Ie).map((t=>this.addHandler(Ie[t])))}static crossSiteProxy(t){return Oe.crossSiteProxyTemplate?Oe.crossSiteProxyTemplate.replace("{uri}",encodeURIComponent(t)):void 0}static offlineOverride(t){let e=t;var r;return"undefined"!=typeof window&&window.panes&&(r=window.panes.UI)&&r.preferences&&r.preferences.get("offlineModeUsingLocalhost")&&"http://"===e.slice(0,7)&&"localhost/"!==e.slice(7,17)&&(e="http://localhost/"+e.slice(7),N.A.warn("Localhost kludge for offline use: actually getting <"+e+">")),e}static proxyIfNecessary(t){var e;if("undefined"!=typeof window&&window.panes&&(e=window.panes.UI)&&e.isExtension)return t;if("undefined"!=typeof $SolidTestEnvironment&&$SolidTestEnvironment.localSiteMap){let e=t.split("/").slice(2);const r=(t,e)=>{let i=e[t.shift()];return i?"string"==typeof i?i+t.join("/"):t?r(t,i):null:null},i=r(e,$SolidTestEnvironment.localSiteMap);if(i)return i}return Oe.crossSiteProxyTemplate&&"undefined"!=typeof document&&document.location&&"https:"===(""+document.location).slice(0,6)&&"http:"===t.slice(0,5)?Oe.crossSiteProxyTemplate.replace("{uri}",encodeURIComponent(t)):t}static unsupportedProtocol(t){let e=b.protocol(t);return"tel"===e||"mailto"===e||"urn"===e}static setCredentials(t,e={}){void 0===e.credentials&&(void 0!==e.withCredentials?e.credentials=e.withCredentials?"include":"omit":e.credentials="include")}load(t,e={}){if(e=Object.assign({},e),t instanceof Array)return Promise.all(t.map((t=>this.load(t,Object.assign({},e)))));const r=t;let i=(0,me.E)(r);i=i.split("#")[0],e=this.initFetchOptions(i,e);const n=this.appNode,s=this.store,a=s.statementsMatching(void 0,this.ns.link("requestedURI"),s.sym(i),n).map((t=>t.subject));for(const t of a){const r=s.any(t,this.ns.link("response"),null,n);if(null!=r){const t=s.statementsMatching(r,this.ns.link("outOfDate"),!0,n);s.remove(t),e.force=!0,e.clearPreviousData=!0}}const o=this.initFetchOptions(i,e);return this.pendingFetchPromise(i,o.baseURI,o)}async pendingFetchPromise(t,e,r){let i;return!r.force&&await this.fetchQueue[e]?i=this.fetchQueue[e]:(i=Promise.race([this.setRequestTimeout(t,r),this.fetchUri(t,r)]),this.fetchQueue[e]=i,this.cleanupFetchRequest(e,void 0,this.timeout)),i.then((e=>(t in this.timeouts&&(this.timeouts[t].forEach(clearTimeout),delete this.timeouts[t]),e)))}cleanupFetchRequest(t,e,r){void 0!==e&&console.warn("_options is deprecated"),this.timeouts[t]=(this.timeouts[t]||[]).concat(setTimeout((()=>{this.isPending(t)||delete this.fetchQueue[t]}),r))}initFetchOptions(t,e){let r=this.store;!e.method||"GET"===e.method.toUpperCase()||(e.force=!0),e.resource=r.rdfFactory.namedNode(t),e.baseURI=e.baseURI||t,e.original=r.rdfFactory.namedNode(e.baseURI),e.req=r.bnode(),e.headers=e.headers||{},e.contentType&&(e.headers["content-type"]=e.contentType),e.force&&(e.cache="no-cache");let i=this.acceptString();e.headers.accept=i;let n=Oe.offlineOverride(t);e.requestedURI=n,Oe.setCredentials(n,e);let s=Oe.proxyIfNecessary(n);return n!==s&&(e.proxyUsed=!0),e.actualProxyURI=s,e}fetchUri(t,e){if(!t)return Promise.reject(new Error("Cannot fetch an empty uri"));if(Oe.unsupportedProtocol(t))return this.failFetch(e,"fetcher: Unsupported protocol","unsupported_protocol");let r=this.getState(t);if(e.force)delete this.nonexistent[t];else{if("fetched"===r)return Promise.resolve(this.doneFetch(e,{status:200,ok:!0,statusText:"Already loaded into quadstore."}));if("failed"===r&&404===this.requested[t]){let r="Previously failed: "+this.requested[t],i={url:t,status:this.requested[t],statusText:r,responseText:r,headers:new pe.Headers,ok:!1,body:null,bodyUsed:!1,size:0,timeout:0};return this.failFetch(e,r,this.requested[t],i)}}this.fireCallbacks("request",[t]),this.requested[t]=!0,e.noMeta||this.saveRequestMetadata(t,e);let{actualProxyURI:i}=e;return this._fetch(i,e).then((r=>this.handleResponse(r,t,e)),(r=>{let n={url:i,status:999,statusText:(r.name||"network failure")+": "+(r.errno||r.code||r.type),responseText:r.message,headers:new pe.Headers,ok:!1,body:null,bodyUsed:!1,size:0,timeout:0};return this.handleError(n,t,e)}))}nowOrWhenFetched(t,e,r,i={}){const n=(0,me.E)(t);"function"==typeof e?r=e:void 0===e||((0,a.Y2)(e)?i.referringTerm=e:i=e),this.load(n,i).then((t=>{if(r)if(t)if(t.ok)r(!0,"OK",t);else{let e="HTTP error: Status "+t.status+" ("+t.statusText+")";t.responseText&&(e+=" "+t.responseText),r(!1,e,t)}else r(!1,"@@ nowOrWhenFetched: no response object!")}),(function(t){var e=t.message||t.statusText;e="Failed to load <"+n+"> "+e,t.response&&t.response.status&&(e+=" status: "+t.response.status),r(!1,e,t.response)}))}addStatus(t,e){let r=new Date;e="["+r.getHours()+":"+r.getMinutes()+":"+r.getSeconds()+"."+r.getMilliseconds()+"] "+e;let i=this.store;const n=i.the(t,this.ns.link("status"));(0,a.P3)(n)?n.append(i.rdfFactory.literal(e)):N.A.warn("web.js: No list to add to: "+n+","+e)}failFetch(t,e,r,i){this.addStatus(t.req,e),t.noMeta||this.store.add(t.original,this.ns.link("error"),this.store.rdfFactory.literal(e));let n=(t.method||"GET").toUpperCase();("GET"===n||"HEAD"===n)&&(t.resource.equals(t.original),this.requested[b.docpart(t.original.value)]=r,this.fireCallbacks("fail",[t.original.value,e]));var s=new Error("Fetcher: "+e);return s.status=r,s.statusText=e,s.response=i,Promise.reject(s)}linkData(t,e,r,i,n){if(!r)return;let s,a=this.store,o=a.rdfFactory.namedNode(b.join(r,t.value));if("alternate"===e||"seeAlso"===e||"meta"===e||"describedby"===e){if(o.value===t.value)return;s=this.ns.rdfs("seeAlso")}else s="type"===e?a.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"):a.rdfFactory.namedNode(b.join(encodeURIComponent(e),"http://www.iana.org/assignments/link-relations/"));n?a.add(o,s,t,i):a.add(t,s,o,i)}parseLinkHeader(t,e,r){if(!t)return;const i=/[^\(\)<>@,;:"\/\[\]\?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*"))/g,n=t.match(/<[^>]*>\s*(\s*;\s*[^()<>@,;:"/[\]?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*")))*(,|$)/g);if(null!=n)for(let t=0;t<n.length;t++){let s=n[t].split(">"),a=s[0].substring(1),o=s[1].match(i);if(null==o)return;for(let t=0;t<o.length;t++){let i=o[t].split("=")[1].replace(/["']/g,"");this.linkData(e,i,a,r)}}}doneFetch(t,e){return this.addStatus(t.req,"Done."),this.requested[t.original.value]="done",this.fireCallbacks("done",[t.original.value]),e.req=t.req,e}nowKnownAs(t,e){this.lookedUp[t.value]?this.lookedUp[e.value]||this.lookUpThing(e,t):this.lookedUp[e.value]&&(this.lookedUp[t.value]||this.lookUpThing(t,e))}putBack(t,e={}){const r=(0,me.E)(t);let n=new s.A(r).doc();return e.contentType=e["content-type"]||e["Content-Type"]||e.contentType||i.sT,"application/ld+json"===e.contentType?new Promise(((r,i)=>{F(n,this.store,n.uri,e.contentType,((n,s)=>{n?i(n):(e.data=s,this.webOperation("PUT",t,e).then((t=>r(t))).catch((t=>i(t))))}))})):(e.data=F(n,this.store,n.value,e.contentType),this.webOperation("PUT",r,e))}webCopy(t,e,r){return this.webOperation("GET",t).then((t=>this.webOperation("PUT",e,{data:t.responseText,contentType:r})))}delete(t,e){return this.webOperation("DELETE",t,e).then((e=>(this.requested[t]=404,this.nonexistent[t]=!0,this.unload(this.store.rdfFactory.namedNode(t)),e)))}async createIfNotExists(t,e=i.sT,r=""){const n=this;try{var s=await n.load(t)}catch(i){if(404===i.response.status){try{s=await n.webOperation("PUT",t.value,{data:r,contentType:e})}catch(t){throw t}return delete n.requested[t.value],s}throw i}return s}createContainer(t,e,r){let n={"content-type":i.sT,link:this.ns.ldp("BasicContainer")+'; rel="type"'};e&&(n.slug=e);let s={headers:n};return r&&(s.body=r),this.webOperation("POST",t,s)}invalidateCache(t){const e=(0,me.E)(t),r=this;if(r.fetchQueue&&r.fetchQueue[e]&&(r.fetchQueue[e].PromiseStatus,delete r.fetchQueue[e]),r.requested[e]&&"done"!==r.requested[e]&&"failed"!==r.requested[e]&&404!==r.requested[e]){let t=`Rdflib: fetcher: Destructive operation on <${r.requested[e]}> file being fetched! `+e;console.error(t)}else delete r.requested[e],delete r.nonexistent[e]}webOperation(t,e,r={}){const i=(0,me.E)(e);r.method=t,r.body=r.data||r.body,r.force=!0;const n=this;if(r.body&&!r.contentType)throw new Error("Web operation sending data must have a defined contentType.");return r.contentType&&(r.headers=r.headers||{},r.headers["content-type"]=r.contentType),Oe.setCredentials(i,r),new Promise((function(e,s){n._fetch(i,r).then((r=>{if(r.ok)"PUT"!==t&&"PATCH"!==t&&"POST"!==t&&"DELETE"!==t||n.invalidateCache(i),r.text?r.text().then((t=>{r.responseText=t,e(r)})):e(r);else{let e="Web error: "+r.status;r.statusText&&(e+=" ("+r.statusText+")"),e+=" on "+t+" of <"+i+">",r.responseText&&(e+=": "+r.responseText);let n=new Error(e);n.response=r,s(n)}}),(e=>{s(new Error("Fetch error for "+t+" of <"+i+">:"+e))}))}))}lookUpThing(t,e){let r=this.store.uris(t);return r=r.map((t=>b.docpart(t))),r.forEach((t=>{this.lookedUp[t]=!0})),this.load(r,{referringTerm:e})}getHeader(t,e){const r=this.store,i=t.value,n=r.each(void 0,this.ns.link("requestedURI"),r.rdfFactory.literal(i));for(let t=0;t<n.length;t++){let i=n[t];if(void 0!==i){let t=r.any(i,this.ns.link("response"));if(void 0!==t&&r.anyValue(t,this.ns.http("status"))&&r.anyValue(t,this.ns.http("status")).startsWith("2")){let i=r.each(t,this.ns.httph(e.toLowerCase()));return i.length?i.map((t=>t.value)):[]}}}}saveRequestMetadata(t,e){let r=e.req,i=this.store,n=e.referringTerm;this.addStatus(e.req,"Accept: "+e.headers.accept),(0,a.Y2)(n)&&i.add(i.rdfFactory.namedNode(t),this.ns.link("requestedBy"),n,this.appNode),e.original&&e.original.value!==t&&i.add(r,this.ns.link("orginalURI"),i.rdfFactory.literal(e.original.value),this.appNode);const s=new Date,o="["+s.getHours()+":"+s.getMinutes()+":"+s.getSeconds()+"] ";i.add(r,this.ns.rdfs("label"),i.rdfFactory.literal(o+" Request for "+t),this.appNode),i.add(r,this.ns.link("requestedURI"),i.rdfFactory.literal(t),this.appNode),i.add(r,this.ns.link("status"),i.collection(),this.appNode)}saveResponseMetadata(t,e){const r=this.store;let i=r.bnode();return r.add(e.req,this.ns.link("response"),i,this.appNode),r.add(i,this.ns.http("status"),r.rdfFactory.literal(t.status),this.appNode),r.add(i,this.ns.http("statusText"),r.rdfFactory.literal(t.statusText),this.appNode),t.headers.forEach(((t,n)=>{r.add(i,this.ns.httph(n),this.store.rdfFactory.literal(t),this.appNode),"content-type"===n&&r.add(e.resource,this.ns.rdf("type"),r.rdfFactory.namedNode(C.mediaTypeClass(t).value),this.appNode)})),i}objectRefresh(t){let e=this.store.uris(t);if(void 0!==e)for(let t=0;t<e.length;t++)this.refresh(this.store.rdfFactory.namedNode(b.docpart(e[t])))}refresh(t,e){this.fireCallbacks("refresh",arguments),this.nowOrWhenFetched(t,{force:!0,clearPreviousData:!0},e)}refreshIfExpired(t,e){let r=this.getHeader(t,"Expires");!r||new Date(r[0]).getTime()<=(new Date).getTime()?this.refresh(t,e):e(!0,"Not expired",{})}retract(t){this.store.removeMany(void 0,void 0,void 0,t),t.value&&delete this.requested[b.docpart(t.value)],this.fireCallbacks("retract",arguments)}getState(t){return void 0===this.requested[t]?"unrequested":!0===this.requested[t]?"requested":"done"===this.requested[t]?"fetched":"redirected"===this.requested[t]?this.getState(this.redirectedTo[t]):"failed"}isPending(t){return!0===this.requested[t]}unload(t){this.store.removeDocument(t),delete this.requested[t.value]}addHandler(t){this.handlers.push(t),t.register(this)}retryNoCredentials(t,e){e.retriedWithNoCredentials=!0,delete this.requested[t],delete this.fetchQueue[t];let r=Object.assign({},e,{credentials:"omit"});return this.addStatus(e.req,"Abort: Will retry with credentials SUPPRESSED to see if that helps"),this.load(t,r)}isCrossSite(t){if("undefined"==typeof document||!document.location)return!1;const e=b.hostpart,r=""+document.location;return(e(r)&&e(t)&&e(r))!==e(t)}handleError(t,e,r){if(this.isCrossSite(e)){if(r.credentials&&"include"===r.credentials&&!r.retriedWithNoCredentials)return this.retryNoCredentials(e,r);let t=Oe.crossSiteProxy(e);if(t&&!r.proxyUsed)return this.redirectToProxy(t,r)}var i;return t instanceof Error?i="Fetch error: "+t.message:(i=t.statusText,t.responseText&&(i+=` ${t.responseText}`)),this.failFetch(r,i,t.status||998,t)}addType(t,e,r,i){let n=e;if(i){var s=r.any(n,this.ns.link("requestedURI"));s&&s.value!==i&&r.add(r.rdfFactory.namedNode(i),this.ns.rdf("type"),t,this.appNode)}for(;;){const e=r.any(n,this.ns.link("requestedURI"));if(e&&e.value&&r.add(r.rdfFactory.namedNode(e.value),this.ns.rdf("type"),t,this.appNode),n=r.any(void 0,r.rdfFactory.namedNode("http://www.w3.org/2007/ont/link#redirectedRequest"),n),!n)break;var a=r.any(n,r.rdfFactory.namedNode("http://www.w3.org/2007/ont/link#response"));if(!a)break;var o=r.any(a,r.rdfFactory.namedNode("http://www.w3.org/2007/ont/http#status"));if(!o)break;if("301"!==o&&"302"!==o)break}}handleResponse(t,e,r){const i=this.store,n=t.headers,s=r.req,a=this.saveResponseMetadata(t,r),o=this.normalizedContentType(r,n)||"";let h=n.get("content-location");if(0===t.status)return this.handleError(t,e,r);if(t.status>=400)return 404===t.status&&(this.nonexistent[r.original.value]=!0,this.nonexistent[e]=!0),this.saveErrorResponse(t,a).then((()=>{let e=r.resource+" "+t.statusText;return this.failFetch(r,e,t.status,t)}));var l=null,u=null;if(h&&(u=b.join(h,e))!==e&&(l=u),200===t.status){if(this.addType(this.ns.link("Document"),s,i,e),l&&this.addType(this.ns.link("Document"),s,i,l),r.clearPreviousData){const t=i.statementsMatching(void 0,void 0,void 0,r.resource).slice();for(let e=0;e<t.length;e++)i.removeStatement(t[e])}let t=o.includes("image/")||o.includes("application/pdf");o&&t&&(this.addType(i.rdfFactory.namedNode("http://purl.org/dc/terms/Image"),s,i,e),l&&this.addType(i.rdfFactory.namedNode("http://purl.org/dc/terms/Image"),s,i,l))}if(h){if(!r.force&&l&&"done"===this.requested[u])return this.doneFetch(r,t);this.requested[u]=!0}this.parseLinkHeader(n.get("link"),r.original,s);let c=this.handlerForContentType(o,t);return c?t.text().then((e=>(t.responseText=e,c.parse(this,e,r,t)))):(this.addStatus(s,"Fetch over. No data handled."),this.doneFetch(r,t))}saveErrorResponse(t,e){let r=this.store;return t.text().then((t=>{t.length>10&&r.add(e,this.ns.http("content"),r.rdfFactory.literal(t),e)}))}handlerForContentType(t,e){if(!t)return null;let r=this.handlers.find((e=>t.match(e.pattern)));return r?new r(e):null}guessContentType(t){return ye[t.split(".").pop()]}normalizedContentType(t,e){if(t.forceContentType)return t.forceContentType;let r=e.get("content-type");if(!r||r.includes("application/octet-stream")){let e=this.guessContentType(t.resource.value);if(e)return e}let i=b.protocol(t.resource.value);return!r&&["file","chrome"].includes(i)?"text/xml":r}redirectToProxy(t,e){this.addStatus(e.req,"BLOCKED -> Cross-site Proxy to <"+t+">"),e.proxyUsed=!0;const r=this.store,i=e.req;e.noMeta||(r.add(i,this.ns.link("redirectedTo"),r.rdfFactory.namedNode(t),i),this.addStatus(i,"redirected to new request")),this.requested[e.resource.value]="redirected",this.redirectedTo[e.resource.value]=t;let n=Object.assign({},e);return n.baseURI=e.resource.value,this.fetchUri(t,n).then((t=>(n.noMeta||r.add(i,this.ns.link("redirectedRequest"),n.req,this.appNode),t)))}setRequestTimeout(t,e){return new Promise((r=>{this.timeouts[t]=(this.timeouts[t]||[]).concat(setTimeout((()=>{!this.isPending(t)||e.retriedWithNoCredentials||e.proxyUsed||r(this.failFetch(e,`Request to ${t} timed out`,"timeout"))}),this.timeout))}))}addFetchCallback(t,e){this.fetchCallbacks[t]?this.fetchCallbacks[t].push(e):this.fetchCallbacks[t]=[e]}acceptString(){let t="";for(let e in this.mediatypes){""!==t&&(t+=", "),t+=e;for(let r in this.mediatypes[e])t+=";"+r+"="+this.mediatypes[e][r]}return t}}(0,t.A)(Oe,"HANDLERS",void 0),(0,t.A)(Oe,"CONTENT_TYPE_BY_EXT",void 0),(0,t.A)(Oe,"crossSiteProxyTemplate",void 0),Oe.HANDLERS=Ie,Oe.CONTENT_TYPE_BY_EXT=ye;const je={parseJSON:function(t,e,r){var i,n,s,a={},o=r.sym(e);for(var h in t){0===h.indexOf("_:")?a[h]?i=a[h]:(i=r.bnode(h),a[h]=i):i=r.sym(h);var l=t[h];for(var u in l){var c=l[u];for(var f in n=r.sym(u),c){var d=c[f];if("uri"===d.type)s=r.sym(d.value),r.add(i,n,s,o);else if("BlankNode"===d.type)a[d.value]?s=a[d.value]:(s=r.bnode(d.value),a[d.value]=s),r.add(i,n,s,o);else{if("Literal"!==d.type)throw new Error("error: unexpected termtype: "+f.type);s=d.datatype?r.literal(d.value,void 0,r.sym(d.datatype)):d.lang?r.literal(d.value,d.lang):r.literal(d.value),r.add(i,n,s,o)}}}}}};function Se(t){var e=0;function r(t){var e="",r=t.statements;for(var i in r)N.A.debug("Found statement: "+r),e+=a()+r[i]+"\n";return e}function i(t){var e="";for(var r in t.constraints){var i=t.constraints[r];e+=a()+"FILTER ( "+i.describe(r)+" ) \n"}return e}function n(t){for(var s="",o=0;o<t.optional.length;o++)N.A.debug("Found optional query"),s+=a()+"OPTIONAL { \n",e++,s+=r(t.optional[o]),s+=i(t.optional[o]),s+=n(t.optional[o]),e--,s+=a()+"}\n";return s}function s(t){var s=a()+"WHERE \n{ \n";return e++,s+=r(t),s+=i(t),s+=n(t),e--,s+"}"}function a(){for(var t="",r=0;r<e;r++)t+=" ";return t}return function(t){return function(t){for(var e=a()+"SELECT ",r=0;r<t.vars.length;r++)e+=t.vars[r]+" ";return e+"\n"}(t)+s(t.pat)}(t)}function Fe(t,e,r){var i=[];function n(t){if(i[t])return i[t];var e=r.variable(t);return i[t]=e,e}function s(t){return"string"==typeof t&&t.match(/[^ \n\t]/)}function a(t){return"string"==typeof t&&t.match(/^[\?\$]/)}function o(t){return"string"==typeof t?t.replace(/^</,"<").replace(/>$/,">"):t}function h(t){return"string"==typeof t&&t.match(/^<[^>]*>$/)}function l(t){return"string"==typeof t&&(t.match(/^_:/)||t.match(/^$/))}function u(t){return"string"==typeof t&&t.match(/:$/)}function c(t){return"string"==typeof t&&t.match(/^:|^[^_][^:]*:/)}function f(t){return t.split(":")[0]}function d(t){return t.split(":")[1]}function p(t){return h(t)?t.slice(1,t.length-1):t}function g(t){var e=-1===t.indexOf("'")?null:t.indexOf("'"),i=-1===t.indexOf('"')?null:t.indexOf('"');if(!e&&!i){var n=new Array(1);return n[0]=t,n}var s,a,o=new Array(2);if(!e||i&&i<e)s='"',a=i;else{if(i&&!(e&&e<i))return N.A.error("SQARQL QUERY OOPS!"),o;s="'",a=e}o[0]=t.slice(0,a);var h,l=t.slice(a+1).indexOf(s);return-1===l?(N.A.error("SPARQL parsing error: no matching parentheses in literal "+t),t):(t.slice(l+a+2).match(/^\^\^/)?(h=t.slice(l+a+2).indexOf(" "),o[1]=r.literal(t.slice(a+1,a+1+l),r.sym(p(t.slice(a+4+l,a+2+l+h)))),o=o.concat(g(t.slice(l+a+3+h)))):t.slice(l+a+2).match(/^@/)?(h=t.slice(l+a+2).indexOf(" "),o[1]=r.literal(t.slice(a+1,a+1+l),t.slice(a+3+l,a+2+l+h),null),o=o.concat(g(t.slice(l+a+2+h)))):(o[1]=r.literal(t.slice(a+1,a+1+l)),N.A.info("Literal found: "+o[1]),o=o.concat(g(t.slice(l+a+2)))),o)}function m(t){t=t.replace(/\(/g," ( ").replace(/\)/g," ) ").replace(/</g," <").replace(/>/g,"> ").replace(/{/g," { ").replace(/}/g," } ").replace(/[\t\n\r]/g," ").replace(/; /g," ; ").replace(/\. /g," . ").replace(/, /g," , "),N.A.info("New str into spaceDelimit: \n"+t);var e=[],r=t.split(" ");for(var i in r)s(r[i])&&(e=e.concat(r[i]));return e}function w(t,e){for(var r=0;r<e.length;r++)if("string"==typeof e[r]&&e[r].toLowerCase()===t.toLowerCase())return r;return null}function y(t,e){for(var r=[],i=0;i<e.length;i++)"string"==typeof e[i]&&e[i].toLowerCase()===t.toLowerCase()&&r.push(i);return r}function b(t,e,r){N.A.info("Looking for a close bracket of type "+r+" in "+t);for(var i=0,n=0;n<t.length;n++)if(t[n]===e&&i++,t[n]===r&&i--,i<0)return n;return N.A.error("Statement had no close parenthesis in SPARQL query"),0}function v(t){return this.describe=function(e){return e+" = "+t.toNT()},this.test=function(e){return t.equals(e)},this}function _(t){this.describe=function(e){return"REGEXP( '"+t+"' , "+e+" )"},this.test=function(e){var r=new RegExp(t);return!!e.value&&r.test(e.value)}}function x(t,e){3!==t.length||"Variable"!==t[0].termType||"NamedNode"!==t[2].termType&&"Literal"!==t[2].termType?6===t.length&&"string"==typeof t[0]&&"regexp"===t[0].toLowerCase()&&"("===t[1]&&")"===t[5]&&","===t[3]&&"Variable"===t[4].termType&&"Literal"===t[2].termType&&(N.A.debug("Constraint added: "+t),e.constraints[t[4]]=new _(t[2].value)):"="===t[1]||">"===t[1]||"<"===t[1]?(N.A.debug("Constraint added: "+t),e.constraints[t[0]]=new v(t[2])):N.A.warn("I don't know how to handle the constraint: "+t)}function T(t,e){N.A.debug("Optional query: "+t+" not yet implemented.");var i=r.formula();A(t,i),e.optional.push(i)}function A(t,e){var i,s,u=function(t){for(var e=[],i=0;i<t.length;i++)"string"==typeof t[i]?(t[i]=o(t[i]),a(t[i])?e[i]=n(t[i].slice(1)):l(t[i])?(N.A.info(t[i]+" was identified as a bnode."),e[i]=r.bnode()):h(t[i])?(N.A.info(t[i]+" was identified as a symbol."),e[i]=r.sym(p(t[i]))):c(t[i])?(N.A.info(t[i]+" was identified as a prefixed symbol"),k[f(t[i])]?e[i]=r.sym(t[i]=k[f(t[i])]+d(t[i])):(N.A.error("SPARQL error: "+t[i]+" with prefix "+f(t[i])+" does not have a correct prefix entry."),e[i]=t[i])):e[i]=t[i]):e[i]=t[i];return e}(t);for(N.A.debug("WHERE: "+u);w("OPTIONAL",u);)s=w("OPTIONAL",u),N.A.debug("OPT: "+s+" "+u[s]+" in "+u),"{"!==u[s+1]&&N.A.warn("Bad optional opening bracket in word "+s),-1===(i=b(u.slice(s+2),"{","}"))?N.A.error("No matching bracket in word "+s):(T(u.slice(s+2,s+2+i),e),s=w("OPTIONAL",u),i=b(u.slice(s+2),"{","}"),u.splice(s,i+3));for(N.A.debug("WHERE after optionals: "+u);w("FILTER",u);){var g=w("FILTER",u);"("!==u[g+1]&&N.A.warn("Bad filter opening bracket in word "+g),-1===(i=b(u.slice(g+2),"(",")"))?N.A.error("No matching bracket in word "+g):(x(u.slice(g+2,g+2+i),e),g=w("FILTER",u),i=b(u.slice(g+2),"(",")"),u.splice(g,i+3))}N.A.debug("WHERE after filters and optionals: "+u),function(t,e){var r=new Array(1);r[0]=-1;for(var i=r.concat(y(".",t)),n=[],s=0;s<i.length-1;s++)n[s]=t.slice(i[s]+1,i[s+1]);for(s in n){N.A.info("s+p+o "+s+" = "+n[s]);var a=n[s][0];n[s].splice(0,1);var o=r.concat(y(";",n[s]));o.push(n[s].length);for(var h=[],l=0;l<o.length-1;l++)h[l]=n[s].slice(o[l]+1,o[l+1]);for(s in h){N.A.info("p+o "+s+" = "+n[s]);var u=h[s][0];h[s].splice(0,1);var c=r.concat(y(",",h[s]));c.push(h[s].length);var f=[];for(l=0;l<c.length-1;l++)f[l]=h[s].slice(c[l]+1,c[l+1]);for(s in f){var d=f[s][0];N.A.info("Subj="+a+" Pred="+u+" Obj="+d),e.add(a,u,d)}}}}(u,e)}N.A.info("SPARQL input: \n"+t);var E=new $,R=function(t){var e=g(t),r=[];for(var i in e)r="string"==typeof e[i]?r.concat(m(e[i])):r.concat(e[i]);return r=function(t){for(var e=t,r=0;r<e.length;r++)if("a"===e[r]&&(e[r]="<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>"),"is"===e[r]&&"of"===e[r+2]){e.splice(r,1),e.splice(r+1,1);var i=e[r-1];e[r-1]=e[r+1],e[r+1]=i}return e}(r),N.A.info("SPARQL Tokens: "+r),r}(t),k=function(t){var e=y("PREFIX",t),r=[];for(var i in e){var n=t[e[i]+1],s=t[e[i]+2];if(u(n))if(h(s)){N.A.info("Prefix found: "+n+" -> "+s);var a=f(n),o=p(s);r[a]=o}else N.A.error("Invalid SPARQL symbol: "+s);else N.A.error("Invalid SPARQL prefix: "+n)}return r}(R);k.rdf||(k.rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"),k.rdfs||(k.rdfs="http://www.w3.org/2000/01/rdf-schema#");var I=w("SELECT",R),C=w("WHERE",R);if(I<0||C<0||I>C)return N.A.error("Invalid or nonexistent SELECT and WHERE tags in SPARQL query"),!1;if(function(t,e){for(var r in N.A.info("SPARQL vars: "+t),t)if(a(t[r])){N.A.info("Added "+t[r]+" to query variables from SPARQL");var i=n(t[r].slice(1));e.vars.push(i),i.label=t[r].slice(1)}else N.A.warn("Incorrect SPARQL variable in SELECT: "+t[r])}(R.slice(I+1,C),E),A(R.slice(C+2,R.length-1),E.pat),e)return E;for(var O in E.pat.statements){var j=E.pat.statements[O];"NamedNode"===j.subject.termType&&r.fetcher&&r.fetcher.lookUpThing(j.subject,"sparql:"+j.subject),"NamedNode"===j.object.termType&&r.fetcher&&r.fetcher.lookUpThing(j.object,"sparql:"+j.object)}return E}class Ue{constructor(e){if((0,t.A)(this,"store",void 0),(0,t.A)(this,"ifps",void 0),(0,t.A)(this,"fps",void 0),(0,t.A)(this,"patchControl",void 0),(0,t.A)(this,"ns",void 0),(e=e||new G).updater)throw new Error("You can't have two UpdateManagers for the same store");e.fetcher||(e.fetcher=new Oe(e)),this.store=e,e.updater=this,this.ifps={},this.fps={},this.ns={},this.ns.link=E("http://www.w3.org/2007/ont/link#"),this.ns.http=E("http://www.w3.org/2007/ont/http#"),this.ns.httph=E("http://www.w3.org/2007/ont/httph#"),this.ns.ldp=E("http://www.w3.org/ns/ldp#"),this.ns.rdf=E("http://www.w3.org/1999/02/22-rdf-syntax-ns#"),this.ns.rdfs=E("http://www.w3.org/2000/01/rdf-schema#"),this.ns.rdf=E("http://www.w3.org/1999/02/22-rdf-syntax-ns#"),this.ns.owl=E("http://www.w3.org/2002/07/owl#"),this.patchControl=[]}patchControlFor(t){return this.patchControl[t.value]||(this.patchControl[t.value]=[]),this.patchControl[t.value]}isHttpUri(t){return"http"===t.slice(0,4)}flagAuthorizationMetadata(t){t||(t=this.store);const e=t.fetcher?.appNode,r=t.statementsMatching(void 0,this.ns.link("requestedURI"),void 0,e).map((t=>t.subject));for(const i of r){const r=t.any(i,this.ns.link("response"),null,e);null!=r&&t.add(r,this.ns.link("outOfDate"),!0,e)}}async checkEditable(t,e){if(!t)return!1;e||(e=this.store);const r=this.editable(t,e);return void 0!==r?r:(await(e.fetcher?.load(t)),this.editable(t,e))}editable(t,e){if(!t)return!1;if(e||(e=this.store),t=(0,me.E)(t),!this.isHttpUri(t)&&e.holds(e.rdfFactory.namedNode(t),e.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),e.rdfFactory.namedNode("http://www.w3.org/2007/ont/link#MachineEditableDocument")))return"LOCALFILE";var r,i=!1;const n=e.fetcher?.appNode;for(var s,a=e.each(void 0,this.ns.link("requestedURI"),(0,b.docpart)(t),n),o=0;o<a.length;o++)if(void 0!==(r=a[o])){const a=e.any(r,this.ns.link("response"),null,n);if(void 0!==a){if(e.anyJS(a,this.ns.link("outOfDate"),null,n))continue;var h=e.anyValue(a,this.ns.httph("wac-allow"));if(h)for(var l of h.split(",")){var u=l.split("=");if(u[0].includes("user")&&!u[1].includes("write")&&!u[1].includes("append"))return!1}var c=e.each(a,this.ns.httph("accept-patch"));if(c.length)for(let t=0;t<c.length;t++){if((s=c[t].value.trim()).indexOf("application/sparql-update")>=0)return"SPARQL";if(s.indexOf("application/sparql-update-single-match")>=0)return"SPARQL";if(s.indexOf("text/n3")>=0)return"N3PATCH"}var f=e.each(a,this.ns.httph("ms-author-via"));if(f.length)for(let t=0;t<f.length;t++){if((s=f[t].value.trim()).indexOf("SPARQL")>=0)return"SPARQL";if(s.indexOf("DAV")>=0)return"DAV"}if(!this.isHttpUri(t))return!!h&&"LOCALFILE";var d=e.each(a,this.ns.http("status"));if(d.length)for(let t=0;t<d.length;t++)200!==d[t]&&404!==d[t]||(i=!0)}}if(0===a.length);else if(i)return!1}anonymize(t){return"_:"===t.toNT().substr(0,2)&&this.mentioned(t)?"?"+t.toNT().substr(2):t.toNT()}anonymizeNT(t){return this.anonymize(t.subject)+" "+this.anonymize(t.predicate)+" "+this.anonymize(t.object)+" ."}nTriples(t){return`${t.subject.toNT()} ${t.predicate.toNT()} ${t.object.toNT()} .`}statementBnodes(t){return[t.subject,t.predicate,t.object].filter((function(t){return(0,a.jt)(t)}))}statementArrayBnodes(t){var e=[];for(let r=0;r<t.length;r++)e=e.concat(this.statementBnodes(t[r]));e.sort();var r=[];for(let t=0;t<e.length;t++)0!==t&&e[t].equals(e[t-1])||r.push(e[t]);return r}cacheIfps(){this.ifps={};var t=this.store.each(void 0,this.ns.rdf("type"),this.ns.owl("InverseFunctionalProperty"));for(let e=0;e<t.length;e++)this.ifps[t[e].value]=!0;this.fps={},t=this.store.each(void 0,this.ns.rdf("type"),this.ns.owl("FunctionalProperty"));for(let e=0;e<t.length;e++)this.fps[t[e].value]=!0}bnodeContext2(t,e,r){var i,n,s=this.store.statementsMatching(void 0,void 0,t,e);for(let t=0;t<s.length;t++)if(this.fps[s[t].predicate.value]){if(!(i=s[t].subject).isBlank)return[s[t]];if(r&&(n=this.bnodeContext2(i,e,r-1)))return n.concat([s[t]])}s=this.store.statementsMatching(t,void 0,void 0,e);for(let t=0;t<s.length;t++)if(this.ifps[s[t].predicate.value]){if(!(i=s[t].object).isBlank)return[s[t]];if(r&&(n=this.bnodeContext2(i,e,r-1)))return n.concat([s[t]])}return null}bnodeContext1(t,e){for(var r=0;r<3;r++){var i=this.bnodeContext2(t,e,r);if(null!==i)return i}return this.store.connectedStatements(t,e)}mentioned(t){return 0!==this.store.statementsMatching(t,null,null,null).length||0!==this.store.statementsMatching(null,t).length||0!==this.store.statementsMatching(null,null,t).length}bnodeContext(t,e){var r=[];if(t.length){this.cacheIfps();for(let n=0;n<t.length;n++){var i=t[n];this.mentioned(i)&&(r=r.concat(this.bnodeContext1(i,e)))}}return r}statementContext(t){var e=this.statementBnodes(t);return this.bnodeContext(e,t.graph)}contextWhere(t){var e=this;return t&&0!==t.length?"WHERE { "+t.map((function(t){return e.anonymizeNT(t)})).join("\n")+" }\n":""}fire(t,e,r,i={}){return Promise.resolve().then((()=>{if(!t)throw new Error("No URI given for remote editing operation: "+e);return i.noMeta=!0,i.contentType=i.contentType||"application/sparql-update",i.body=e,this.store.fetcher.webOperation("PATCH",t,i)})).then((i=>{if(!i.ok){let r="UpdateManager: update failed for <"+t+"> status="+i.status+", "+i.statusText+"\n for query: "+e;throw new Error(r)}r(t,i.ok,i.responseText,i)})).catch((e=>{r(t,!1,e.message,e)}))}update_statement(t){if(!t||t.graph){var e=this,r=this.statementContext(t);return{statement:t?[t.subject,t.predicate,t.object,t.graph]:void 0,statementNT:t?this.anonymizeNT(t):void 0,where:e.contextWhere(r),set_object:function(t,r){var i=this.where;i+="DELETE DATA { "+this.statementNT+" } ;\n",i+="INSERT DATA { "+this.anonymize(this.statement[0])+" "+this.anonymize(this.statement[1])+" "+this.anonymize(t)+" . }\n",e.fire(this.statement[3].value,i,r)}}}}insert_statement(t,e){var r=t instanceof Array?t[0]:t,i=this.contextWhere(this.statementContext(r));if(t instanceof Array){var n="";for(let e=0;e<t.length;e++)n+=t[e]+"\n";i+="INSERT DATA { "+n+" }\n"}else i+="INSERT DATA { "+this.anonymize(t.subject)+" "+this.anonymize(t.predicate)+" "+this.anonymize(t.object)+" . }\n";this.fire(r.graph.value,i,e)}delete_statement(t,e){var r=t instanceof Array?t[0]:t,i=this.contextWhere(this.statementContext(r));if(t instanceof Array){var n="";for(let e=0;e<t.length;e++)n+=t[e]+"\n";i+="DELETE DATA { "+n+" }\n"}else i+="DELETE DATA { "+this.anonymize(t.subject)+" "+this.anonymize(t.predicate)+" "+this.anonymize(t.object)+" . }\n";this.fire(r.graph.value,i,e)}requestDownstreamAction(t,e){var r=this.patchControlFor(t);if(r.pendingUpstream)if(r.downstreamAction){if(""+r.downstreamAction!=""+e)throw new Error("Can't wait for > 1 different downstream actions")}else r.downstreamAction=e;else e(t)}clearUpstreamCount(t){this.patchControlFor(t).upstreamCount=0}getUpdatesVia(t){var e=this.store.fetcher.getHeader(t,"updates-via");return e&&e.length?e[0].trim():null}addDownstreamChangeListener(t,e){var r=this.patchControlFor(t);r.downstreamChangeListeners||(r.downstreamChangeListeners=[]),r.downstreamChangeListeners.push(e),this.setRefreshHandler(t,(t=>{this.reloadAndSync(t)}))}reloadAndSync(t){var e=this.patchControlFor(t),r=this;if(e.reloading)e.outOfDate=!0;else{e.reloading=!0;var i=1e3,n=function(){r.reload(r.store,t,(function(t,r,s){if(t){if(e.downstreamChangeListeners)for(let t=0;t<e.downstreamChangeListeners.length;t++)e.downstreamChangeListeners[t]();e.reloading=!1,e.outOfDate&&(e.outOfDate=!1,n())}else e.reloading=!1,s&&0===s.status&&(e.reloading=!0,setTimeout(n,i*=2))}))};n()}}setRefreshHandler(t,e){let r=this.getUpdatesVia(t);var i=e,n=this,s=this,a=1500,o=0;if(!r)return!1;r=(0,b.join)(r,t.value);const h=r.replace(/^http:/,"ws:").replace(/^https:/,"wss:");var l=function(){var e;if("undefined"!=typeof WebSocket)e=new WebSocket(h);else{if("undefined"==typeof window||!window.WebSocket)return;e=window.WebSocket(h)}e.onopen=function(){a=1500,this.send("sub "+t.value),o&&s.requestDownstreamAction(t,i)};var r=n.patchControlFor(t);r.upstreamCount=0,e.onerror=function(t){},e.onclose=function(t){a*=2,o+=1,setTimeout((function(){l()}),a)},e.onmessage=function(e){if(e.data&&"pub"===e.data.slice(0,3)){if("upstreamCount"in r&&(r.upstreamCount-=1,r.upstreamCount>=0))return;r.upstreamCount=0,n.requestDownstreamAction(t,i)}}};return l(),!0}updateMany(t,e=[]){const r=t.concat(e).map((t=>t.why)),i=this,n=[];r.forEach((t=>{n.find((e=>e.equals(t)))||n.push(t)}));const s=n.map((r=>i.update(t.filter((t=>t.why.equals(r))),e.filter((t=>t.why.equals(r))))));return s.length,Promise.all(s)}constructSparqlUpdateQuery(t,e,r){var i=this.contextWhere(r),n="";if(i.length){if(t.length){n+="DELETE { ";for(let e=0;e<t.length;e++)n+=this.anonymizeNT(t[e])+"\n";n+=" }\n"}if(e.length){n+="INSERT { ";for(let t=0;t<e.length;t++)n+=this.anonymizeNT(e[t])+"\n";n+=" }\n"}n+=i}else{if(t.length){n+="DELETE DATA { ";for(let e=0;e<t.length;e++)n+=this.anonymizeNT(t[e])+"\n";n+=" } \n"}if(e.length){t.length&&(n+=" ; "),n+="INSERT DATA { ";for(let t=0;t<e.length;t++)n+=this.nTriples(e[t])+"\n";n+=" }\n"}}return n}constructN3PatchQuery(t,e,r){var i="\n@prefix solid: <http://www.w3.org/ns/solid/terms#>.\n@prefix ex: <http://www.example.org/terms#>.\n\n_:patch\n";return r&&r.length>0&&(i+=`\n solid:where {\n ${r.map((t=>this.anonymizeNT(t))).join("\n ")}\n };`),t.length>0&&(i+=`\n solid:deletes {\n ${t.map((t=>this.anonymizeNT(t))).join("\n ")}\n };`),e.length>0&&(i+=`\n solid:inserts {\n ${e.map((t=>this.anonymizeNT(t))).join("\n ")}\n };`),i+" a solid:InsertDeletePatch .\n"}update(t,e,r,i,n={}){if(!r){var s=this;return new Promise((function(r,a){s.update(t,e,(function(t,e,i){e?r():a(new Error(i))}),i,n)}))}try{var o=this.store,h=t?(0,a.ok)(t)?t.statements:t instanceof Array?t:[t]:[],l=e?(0,a.ok)(e)?e.statements:e instanceof Array?e:[e]:[];if(!(h instanceof Array))throw new Error("Type Error "+typeof h+": "+h);if(!(l instanceof Array))throw new Error("Type Error "+typeof l+": "+l);if(0===h.length&&0===l.length)return r(null,!0);var u=h.length?h[0].graph:l[0].graph;if(!u){let t="Error patching: statement does not specify which document to patch:"+h[0]+", "+l[0];throw new Error(t)}if("NamedNode"!==u.termType){let t="Error patching: document not a NamedNode:"+h[0]+", "+l[0];throw new Error(t)}var c=this.patchControlFor(u),f=Date.now(),d=["subject","predicate","object","why"],p={delete:h,insert:l};["insert","delete"].map((function(t){p[t].map((function(t){if(!u.equals(t.graph))throw new Error("update: destination "+u+" inconsistent with delete quad "+t.graph);d.map((function(e){if(void 0===t[e])throw new Error("update: undefined "+e+" of statement.")}))}))}));var g=this.editable(u.value,o);if(!1===g)throw new Error("Update: Can't make changes in uneditable "+u);if(void 0===g){if(i)throw new Error("Update: Loaded "+u+"but still can't figure out what editing protocol it supports.");return void this.store.fetcher.load(u).then((i=>{this.update(t,e,r,!0,n)}),(i=>{if(404!==i.response.status)throw new Error(`Update: Can't get updatability status ${u} before patching: ${i}`);this.update(t,e,r,!0,n)}))}if(g.indexOf("SPARQL")>=0||g.indexOf("N3PATCH")>=0){var m=g.indexOf("SPARQL")>=0,w=[];h.length&&(w=this.statementArrayBnodes(h)),l.length&&(w=w.concat(this.statementArrayBnodes(l)));var y=this.bnodeContext(w,u),b=m?this.constructSparqlUpdateQuery(h,l,y):this.constructN3PatchQuery(h,l,y);n.contentType=m?"application/sparql-update":"text/n3",c.pendingUpstream=c.pendingUpstream?c.pendingUpstream+1:1,"upstreamCount"in c&&(c.upstreamCount+=1),this.fire(u.value,b,((t,e,i,n)=>{if(n.elapsedTimeMs=Date.now()-f,e){try{o.remove(h)}catch(t){e=!1,i="Remote Ok BUT error deleting "+h.length+" from store!!! "+t}for(let t=0;t<l.length;t++)o.add(l[t].subject,l[t].predicate,l[t].object,u)}if(r(t,e,i,n),c.pendingUpstream-=1,0===c.pendingUpstream&&c.downstreamAction){var s=c.downstreamAction;delete c.downstreamAction,s(u)}}),n)}else if(g.indexOf("DAV")>=0)this.updateDav(u,h,l,r,n);else{if(!(g.indexOf("LOCALFILE")>=0))throw new Error("Unhandled edit method: '"+g+"' for "+u);try{this.updateLocalFile(u,h,l,r,n)}catch(t){r(u.value,!1,"Exception trying to write back file <"+u.value+">\n")}}}catch(t){r(void 0,!1,"Exception in update: "+t+"\n"+C.stackString(t))}}updateDav(t,e,r,i,n={}){let s=this.store;var a=s.any(t,this.ns.link("request"));if(!a)throw new Error("No record of our HTTP GET request for document: "+t);var o=s.any(a,this.ns.link("response"));if(!o)return null;var h=s.the(o,this.ns.httph("content-type")).value;let l=s.statementsMatching(void 0,void 0,void 0,t).slice();for(let t=0;t<e.length;t++)C.RDFArrayRemove(l,e[t]);for(let t=0;t<r.length;t++)l.push(r[t]);const u=this.serialize(t.value,l,h);var c,f=s.the(o,this.ns.httph("content-location"));return f&&(c=(0,b.join)(f.value,c)),n.contentType=h,n.noMeta=!0,n.body=u,s.fetcher.webOperation("PUT",c,n).then((n=>{if(!n.ok)throw new Error(n.error);for(let t=0;t<e.length;t++)s.remove(e[t]);for(let e=0;e<r.length;e++)s.add(r[e].subject,r[e].predicate,r[e].object,t);i(t.value,n.ok,n.responseText,n)})).catch((e=>{i(t.value,!1,e.message,e)}))}updateLocalFile(t,e,r,i,n={}){const s=this.store;let a=s.statementsMatching(void 0,void 0,void 0,t).slice();for(let t=0;t<e.length;t++)C.RDFArrayRemove(a,e[t]);for(let t=0;t<r.length;t++)a.push(r[t]);var o=t.value.lastIndexOf(".");if(o<1)throw new Error("Rewriting file: No filename extension: "+t.value);var h=t.value.slice(o+1);let l=Oe.CONTENT_TYPE_BY_EXT[h];if(!l)throw new Error("File extension ."+h+" not supported for data write");n.body=this.serialize(t.value,a,l),n.contentType=l,s.fetcher.webOperation("PUT",t.value,n).then((n=>{if(!n.ok)return i(t.value,!1,n.error);for(let t=0;t<e.length;t++)s.remove(e[t]);for(let e=0;e<r.length;e++)s.add(r[e].subject,r[e].predicate,r[e].object,t);i(t.value,!0,"")}))}serialize(t,e,r){const i=this.store;let n;if("string"==typeof e)return e;var s=j(i);switch(s.suggestNamespaces(i.namespaces),s.setBase(t),r){case"text/xml":case"application/rdf+xml":n=s.statementsToXML(e);break;case"text/n3":case"text/turtle":case"application/x-turtle":case"application/n3":n=s.statementsToN3(e);break;default:throw new Error("Content-type "+r+" not supported for data serialization")}return n}put(t,e,r,i){const n=this.store;let s;return Promise.resolve().then((()=>(s=this.serialize(t.value,e,r),n.fetcher.webOperation("PUT",t.value,{contentType:r,body:s})))).then((r=>{if(!r.ok)return i(t.value,r.ok,r.error,r);delete n.fetcher.nonexistent[t.value],delete n.fetcher.requested[t.value],"string"!=typeof e&&e.map((t=>{n.addStatement(t)})),i(t.value,r.ok,"",r)})).catch((e=>{i(t.value,!1,e.message)}))}reload(t,e,r){var i=Date.now();t.fetcher.nowOrWhenFetched(e.value,{force:!0,noMeta:!0,clearPreviousData:!0},(function(t,n,s){if(t)if(s.onErrorWasCalled||200!==s.status)r(!1,"Non-HTTP error reloading data: "+n,s);else{var a=Date.now()-i;e.reloadTimeTotal||(e.reloadTimeTotal=0),e.reloadTimeCount||(e.reloadTimeCount=0),e.reloadTimeTotal+=a,e.reloadTimeCount+=1,r(!0)}else r(!1,"Error reloading data: "+n,s)}))}}const De={...xt,fetcher:(t,e)=>new Oe(t,e),graph:(t=void 0,e=void 0)=>new G(t,e||{rdfFactory:xt}),lit(t,e,r){return this.literal(""+t,e||r)},st(t,e,r,i){return this.quad(t,e,r,i)}},Le=De;class Me{constructor(t,e){this.parent=t,this.via=e,this.connected=!1,this.pending={},this.subscribed={},this.socket={};try{this.socket=new WebSocket(e),this.socket.onopen=this.onOpen,this.socket.onclose=this.onClose,this.socket.onmessage=this.onMessage,this.socket.onerror=this.onError}catch(t){this.onError(t)}}_decode(t){var e,r,i,n,s,a,o;for(r in n={},s=function(){var r,i,n,s;for(s=[],r=0,i=(n=t.split("&")).length;r<i;r++)e=n[r],s.push(e.split("="));return s}())e=s[r],o=(a=[decodeURIComponent(e[0]),decodeURIComponent(e[1])])[1],null==n[i=a[0]]&&(n[i]=[]),n[i].push(o);return n}_send(t,e,r){var i,n;return n=[t,e,r].join(" "),"function"==typeof(i=this.socket).send?i.send(n):void 0}_subscribe(t){return this._send("sub",t,""),this.subscribed[t]=!0,this.subscribed[t]}onClose(t){var e;for(e in this.connected=!1,this.subscribed)this.pending[e]=!0;return this.subscribed={},this.subscribed}onError(t){throw new Error("onError"+t)}onMessage(t){var e,r;return"ping"===(r=t.data.split(" "))[0]?"function"==typeof(e=this.socket).send?e.send("pong "+r.slice(1).join(" ")):void 0:"pub"===r[0]?this.parent.onUpdate(r[1],this._decode(r[2])):void 0}onOpen(t){var e,r;for(r in this.connected=!0,e=[],this.pending)delete this.pending[r],e.push(this._subscribe(r));return e}subscribe(t){return this.connected?this._subscribe(t):(this.pending[t]=!0,this.pending[t])}}class Pe{constructor(t){this.fetcher=t,this.graph={},this.via={},this.fetcher.addCallback("headers",this.onHeaders)}onHeaders(t){var e,r,i;return null==t.headers||"undefined"==typeof WebSocket||null===WebSocket||(e=t.headers.etag,i=t.headers["updates-via"],r=t.uri,e&&i&&(this.graph[r]={etag:e,via:i},this.register(i,r))),!0}onUpdate(t,e){return this.fetcher.refresh(Le.namedNode(t))}register(t,e){return null==this.via[t]&&(this.via[t]=new Me(this,t)),this.via[t].subscribe(e)}}const Be={};for(const t in Le)"function"==typeof Le[t]&&(Be[t]=Le[t].bind(Le));const{fetcher:qe,graph:$e,lit:He,st:Xe,namedNode:ze,variable:Qe,blankNode:Ve,defaultGraph:Ge,literal:We,quad:Ye,triple:Ze}=Be,Je=new P,Ke=t=>Je.fromNT(t),tr=B.fromValue,er=n.nextId;class rr extends G{constructor(e){super(e),(0,t.A)(this,"fetcher",void 0),this.fetcher=new Oe(this,{})}}class ir extends rr{constructor(e){super(e),(0,t.A)(this,"updater",void 0),this.updater=new Ue(this)}}})(),h})()));
|
|
3
3
|
//# sourceMappingURL=rdflib.min.js.map
|