@faubulous/mentor-rdf 0.2.50 → 0.2.51

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/out/index.js CHANGED
@@ -80,7 +80,7 @@ eval("!function(t,e){ true?module.exports=e():0}(\"undefined\"!=typeof self?self
80
80
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
81
81
 
82
82
  "use strict";
83
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\nconst RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n XSD = 'http://www.w3.org/2001/XMLSchema#',\n SWAP = 'http://www.w3.org/2000/10/swap/';\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\n xsd: {\n decimal: `${XSD}decimal`,\n boolean: `${XSD}boolean`,\n double: `${XSD}double`,\n integer: `${XSD}integer`,\n string: `${XSD}string`,\n },\n rdf: {\n type: `${RDF}type`,\n nil: `${RDF}nil`,\n first: `${RDF}first`,\n rest: `${RDF}rest`,\n langString: `${RDF}langString`,\n },\n owl: {\n sameAs: 'http://www.w3.org/2002/07/owl#sameAs',\n },\n r: {\n forSome: `${SWAP}reify#forSome`,\n forAll: `${SWAP}reify#forAll`,\n },\n log: {\n implies: `${SWAP}log#implies`,\n },\n});\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/IRIs.js?");
83
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\nconst RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n XSD = 'http://www.w3.org/2001/XMLSchema#',\n SWAP = 'http://www.w3.org/2000/10/swap/';\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\n xsd: {\n decimal: `${XSD}decimal`,\n boolean: `${XSD}boolean`,\n double: `${XSD}double`,\n integer: `${XSD}integer`,\n string: `${XSD}string`,\n },\n rdf: {\n type: `${RDF}type`,\n nil: `${RDF}nil`,\n first: `${RDF}first`,\n rest: `${RDF}rest`,\n langString: `${RDF}langString`,\n },\n owl: {\n sameAs: 'http://www.w3.org/2002/07/owl#sameAs',\n },\n r: {\n forSome: `${SWAP}reify#forSome`,\n forAll: `${SWAP}reify#forAll`,\n },\n log: {\n implies: `${SWAP}log#implies`,\n isImpliedBy: `${SWAP}log#isImpliedBy`,\n },\n});\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/IRIs.js?");
84
84
 
85
85
  /***/ }),
86
86
 
@@ -91,7 +91,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
91
91
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
92
92
 
93
93
  "use strict";
94
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BlankNode: () => (/* binding */ BlankNode),\n/* harmony export */ DefaultGraph: () => (/* binding */ DefaultGraph),\n/* harmony export */ Literal: () => (/* binding */ Literal),\n/* harmony export */ NamedNode: () => (/* binding */ NamedNode),\n/* harmony export */ Quad: () => (/* binding */ Quad),\n/* harmony export */ Term: () => (/* binding */ Term),\n/* harmony export */ Triple: () => (/* binding */ Quad),\n/* harmony export */ Variable: () => (/* binding */ Variable),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ escapeQuotes: () => (/* binding */ escapeQuotes),\n/* harmony export */ termFromId: () => (/* binding */ termFromId),\n/* harmony export */ termToId: () => (/* binding */ termToId),\n/* harmony export */ unescapeQuotes: () => (/* binding */ unescapeQuotes)\n/* harmony export */ });\n/* harmony import */ var _IRIs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./IRIs */ \"./node_modules/n3/src/IRIs.js\");\n/* harmony import */ var _N3Util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./N3Util */ \"./node_modules/n3/src/N3Util.js\");\n// N3.js implementations of the RDF/JS core data types\n// See https://github.com/rdfjs/representation-task-force/blob/master/interface-spec.md\n\n\n\nconst { rdf, xsd } = _IRIs__WEBPACK_IMPORTED_MODULE_0__[\"default\"];\n\n// eslint-disable-next-line prefer-const\nlet DEFAULTGRAPH;\nlet _blankNodeCounter = 0;\n\nconst escapedLiteral = /^\"(.*\".*)(?=\"[^\"]*$)/;\nconst quadId = /^<<(\"(?:\"\"|[^\"])*\"[^ ]*|[^ ]+) (\"(?:\"\"|[^\"])*\"[^ ]*|[^ ]+) (\"(?:\"\"|[^\"])*\"[^ ]*|[^ ]+) ?(\"(?:\"\"|[^\"])*\"[^ ]*|[^ ]+)?>>$/;\n\n// ## DataFactory singleton\nconst DataFactory = {\n namedNode,\n blankNode,\n variable,\n literal,\n defaultGraph,\n quad,\n triple: quad,\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DataFactory);\n\n// ## Term constructor\nclass Term {\n constructor(id) {\n this.id = id;\n }\n\n // ### The value of this term\n get value() {\n return this.id;\n }\n\n // ### Returns whether this object represents the same term as the other\n equals(other) {\n // If both terms were created by this library,\n // equality can be computed through ids\n if (other instanceof Term)\n return this.id === other.id;\n // Otherwise, compare term type and value\n return !!other && this.termType === other.termType &&\n this.value === other.value;\n }\n\n // ### Implement hashCode for Immutable.js, since we implement `equals`\n // https://immutable-js.com/docs/v4.0.0/ValueObject/#hashCode()\n hashCode() {\n return 0;\n }\n\n // ### Returns a plain object representation of this term\n toJSON() {\n return {\n termType: this.termType,\n value: this.value,\n };\n }\n}\n\n\n// ## NamedNode constructor\nclass NamedNode extends Term {\n // ### The term type of this term\n get termType() {\n return 'NamedNode';\n }\n}\n\n// ## Literal constructor\nclass Literal extends Term {\n // ### The term type of this term\n get termType() {\n return 'Literal';\n }\n\n // ### The text value of this literal\n get value() {\n return this.id.substring(1, this.id.lastIndexOf('\"'));\n }\n\n // ### The language of this literal\n get language() {\n // Find the last quotation mark (e.g., '\"abc\"@en-us')\n const id = this.id;\n let atPos = id.lastIndexOf('\"') + 1;\n // If \"@\" it follows, return the remaining substring; empty otherwise\n return atPos < id.length && id[atPos++] === '@' ? id.substr(atPos).toLowerCase() : '';\n }\n\n // ### The datatype IRI of this literal\n get datatype() {\n return new NamedNode(this.datatypeString);\n }\n\n // ### The datatype string of this literal\n get datatypeString() {\n // Find the last quotation mark (e.g., '\"abc\"^^http://ex.org/types#t')\n const id = this.id, dtPos = id.lastIndexOf('\"') + 1;\n const char = dtPos < id.length ? id[dtPos] : '';\n // If \"^\" it follows, return the remaining substring\n return char === '^' ? id.substr(dtPos + 2) :\n // If \"@\" follows, return rdf:langString; xsd:string otherwise\n (char !== '@' ? xsd.string : rdf.langString);\n }\n\n // ### Returns whether this object represents the same term as the other\n equals(other) {\n // If both literals were created by this library,\n // equality can be computed through ids\n if (other instanceof Literal)\n return this.id === other.id;\n // Otherwise, compare term type, value, language, and datatype\n return !!other && !!other.datatype &&\n this.termType === other.termType &&\n this.value === other.value &&\n this.language === other.language &&\n this.datatype.value === other.datatype.value;\n }\n\n toJSON() {\n return {\n termType: this.termType,\n value: this.value,\n language: this.language,\n datatype: { termType: 'NamedNode', value: this.datatypeString },\n };\n }\n}\n\n// ## BlankNode constructor\nclass BlankNode extends Term {\n constructor(name) {\n super(`_:${name}`);\n }\n\n // ### The term type of this term\n get termType() {\n return 'BlankNode';\n }\n\n // ### The name of this blank node\n get value() {\n return this.id.substr(2);\n }\n}\n\nclass Variable extends Term {\n constructor(name) {\n super(`?${name}`);\n }\n\n // ### The term type of this term\n get termType() {\n return 'Variable';\n }\n\n // ### The name of this variable\n get value() {\n return this.id.substr(1);\n }\n}\n\n// ## DefaultGraph constructor\nclass DefaultGraph extends Term {\n constructor() {\n super('');\n return DEFAULTGRAPH || this;\n }\n\n // ### The term type of this term\n get termType() {\n return 'DefaultGraph';\n }\n\n // ### Returns whether this object represents the same term as the other\n equals(other) {\n // If both terms were created by this library,\n // equality can be computed through strict equality;\n // otherwise, compare term types.\n return (this === other) || (!!other && (this.termType === other.termType));\n }\n}\n\n// ## DefaultGraph singleton\nDEFAULTGRAPH = new DefaultGraph();\n\n\n// ### Constructs a term from the given internal string ID\nfunction termFromId(id, factory) {\n factory = factory || DataFactory;\n\n // Falsy value or empty string indicate the default graph\n if (!id)\n return factory.defaultGraph();\n\n // Identify the term type based on the first character\n switch (id[0]) {\n case '?':\n return factory.variable(id.substr(1));\n case '_':\n return factory.blankNode(id.substr(2));\n case '\"':\n // Shortcut for internal literals\n if (factory === DataFactory)\n return new Literal(id);\n // Literal without datatype or language\n if (id[id.length - 1] === '\"')\n return factory.literal(id.substr(1, id.length - 2));\n // Literal with datatype or language\n const endPos = id.lastIndexOf('\"', id.length - 1);\n return factory.literal(id.substr(1, endPos - 1),\n id[endPos + 1] === '@' ? id.substr(endPos + 2)\n : factory.namedNode(id.substr(endPos + 3)));\n case '<':\n const components = quadId.exec(id);\n return factory.quad(\n termFromId(unescapeQuotes(components[1]), factory),\n termFromId(unescapeQuotes(components[2]), factory),\n termFromId(unescapeQuotes(components[3]), factory),\n components[4] && termFromId(unescapeQuotes(components[4]), factory)\n );\n default:\n return factory.namedNode(id);\n }\n}\n\n// ### Constructs an internal string ID from the given term or ID string\nfunction termToId(term) {\n if (typeof term === 'string')\n return term;\n if (term instanceof Term && term.termType !== 'Quad')\n return term.id;\n if (!term)\n return DEFAULTGRAPH.id;\n\n // Term instantiated with another library\n switch (term.termType) {\n case 'NamedNode': return term.value;\n case 'BlankNode': return `_:${term.value}`;\n case 'Variable': return `?${term.value}`;\n case 'DefaultGraph': return '';\n case 'Literal': return `\"${term.value}\"${\n term.language ? `@${term.language}` :\n (term.datatype && term.datatype.value !== xsd.string ? `^^${term.datatype.value}` : '')}`;\n case 'Quad':\n // To identify RDF* quad components, we escape quotes by doubling them.\n // This avoids the overhead of backslash parsing of Turtle-like syntaxes.\n return `<<${\n escapeQuotes(termToId(term.subject))\n } ${\n escapeQuotes(termToId(term.predicate))\n } ${\n escapeQuotes(termToId(term.object))\n }${\n ((0,_N3Util__WEBPACK_IMPORTED_MODULE_1__.isDefaultGraph)(term.graph)) ? '' : ` ${termToId(term.graph)}`\n }>>`;\n default: throw new Error(`Unexpected termType: ${term.termType}`);\n }\n}\n\n\n// ## Quad constructor\nclass Quad extends Term {\n constructor(subject, predicate, object, graph) {\n super('');\n this._subject = subject;\n this._predicate = predicate;\n this._object = object;\n this._graph = graph || DEFAULTGRAPH;\n }\n\n // ### The term type of this term\n get termType() {\n return 'Quad';\n }\n\n get subject() {\n return this._subject;\n }\n\n get predicate() {\n return this._predicate;\n }\n\n get object() {\n return this._object;\n }\n\n get graph() {\n return this._graph;\n }\n\n // ### Returns a plain object representation of this quad\n toJSON() {\n return {\n termType: this.termType,\n subject: this._subject.toJSON(),\n predicate: this._predicate.toJSON(),\n object: this._object.toJSON(),\n graph: this._graph.toJSON(),\n };\n }\n\n // ### Returns whether this object represents the same quad as the other\n equals(other) {\n return !!other && this._subject.equals(other.subject) &&\n this._predicate.equals(other.predicate) &&\n this._object.equals(other.object) &&\n this._graph.equals(other.graph);\n }\n}\n\n\n// ### Escapes the quotes within the given literal\nfunction escapeQuotes(id) {\n return id.replace(escapedLiteral, (_, quoted) => `\"${quoted.replace(/\"/g, '\"\"')}`);\n}\n\n// ### Unescapes the quotes within the given literal\nfunction unescapeQuotes(id) {\n return id.replace(escapedLiteral, (_, quoted) => `\"${quoted.replace(/\"\"/g, '\"')}`);\n}\n\n// ### Creates an IRI\nfunction namedNode(iri) {\n return new NamedNode(iri);\n}\n\n// ### Creates a blank node\nfunction blankNode(name) {\n return new BlankNode(name || `n3-${_blankNodeCounter++}`);\n}\n\n// ### Creates a literal\nfunction literal(value, languageOrDataType) {\n // Create a language-tagged string\n if (typeof languageOrDataType === 'string')\n return new Literal(`\"${value}\"@${languageOrDataType.toLowerCase()}`);\n\n // Automatically determine datatype for booleans and numbers\n let datatype = languageOrDataType ? languageOrDataType.value : '';\n if (datatype === '') {\n // Convert a boolean\n if (typeof value === 'boolean')\n datatype = xsd.boolean;\n // Convert an integer or double\n else if (typeof value === 'number') {\n if (Number.isFinite(value))\n datatype = Number.isInteger(value) ? xsd.integer : xsd.double;\n else {\n datatype = xsd.double;\n if (!Number.isNaN(value))\n value = value > 0 ? 'INF' : '-INF';\n }\n }\n }\n\n // Create a datatyped literal\n return (datatype === '' || datatype === xsd.string) ?\n new Literal(`\"${value}\"`) :\n new Literal(`\"${value}\"^^${datatype}`);\n}\n\n// ### Creates a variable\nfunction variable(name) {\n return new Variable(name);\n}\n\n// ### Returns the default graph\nfunction defaultGraph() {\n return DEFAULTGRAPH;\n}\n\n// ### Creates a quad\nfunction quad(subject, predicate, object, graph) {\n return new Quad(subject, predicate, object, graph);\n}\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/N3DataFactory.js?");
94
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BlankNode: () => (/* binding */ BlankNode),\n/* harmony export */ DefaultGraph: () => (/* binding */ DefaultGraph),\n/* harmony export */ Literal: () => (/* binding */ Literal),\n/* harmony export */ NamedNode: () => (/* binding */ NamedNode),\n/* harmony export */ Quad: () => (/* binding */ Quad),\n/* harmony export */ Term: () => (/* binding */ Term),\n/* harmony export */ Triple: () => (/* binding */ Quad),\n/* harmony export */ Variable: () => (/* binding */ Variable),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ escapeQuotes: () => (/* binding */ escapeQuotes),\n/* harmony export */ fromQuad: () => (/* binding */ fromQuad),\n/* harmony export */ fromTerm: () => (/* binding */ fromTerm),\n/* harmony export */ termFromId: () => (/* binding */ termFromId),\n/* harmony export */ termToId: () => (/* binding */ termToId),\n/* harmony export */ unescapeQuotes: () => (/* binding */ unescapeQuotes)\n/* harmony export */ });\n/* harmony import */ var _IRIs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./IRIs */ \"./node_modules/n3/src/IRIs.js\");\n// N3.js implementations of the RDF/JS core data types\n// See http://rdf.js.org/data-model-spec/\n\n\n\nconst { rdf, xsd } = _IRIs__WEBPACK_IMPORTED_MODULE_0__[\"default\"];\n\n// eslint-disable-next-line prefer-const\nlet DEFAULTGRAPH;\nlet _blankNodeCounter = 0;\n\nconst escapedLiteral = /^\"(.*\".*)(?=\"[^\"]*$)/;\n\n// ## DataFactory singleton\nconst DataFactory = {\n namedNode,\n blankNode,\n variable,\n literal,\n defaultGraph,\n quad,\n triple: quad,\n fromTerm,\n fromQuad,\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DataFactory);\n\n// ## Term constructor\nclass Term {\n constructor(id) {\n this.id = id;\n }\n\n // ### The value of this term\n get value() {\n return this.id;\n }\n\n // ### Returns whether this object represents the same term as the other\n equals(other) {\n // If both terms were created by this library,\n // equality can be computed through ids\n if (other instanceof Term)\n return this.id === other.id;\n // Otherwise, compare term type and value\n return !!other && this.termType === other.termType &&\n this.value === other.value;\n }\n\n // ### Implement hashCode for Immutable.js, since we implement `equals`\n // https://immutable-js.com/docs/v4.0.0/ValueObject/#hashCode()\n hashCode() {\n return 0;\n }\n\n // ### Returns a plain object representation of this term\n toJSON() {\n return {\n termType: this.termType,\n value: this.value,\n };\n }\n}\n\n\n// ## NamedNode constructor\nclass NamedNode extends Term {\n // ### The term type of this term\n get termType() {\n return 'NamedNode';\n }\n}\n\n// ## Literal constructor\nclass Literal extends Term {\n // ### The term type of this term\n get termType() {\n return 'Literal';\n }\n\n // ### The text value of this literal\n get value() {\n return this.id.substring(1, this.id.lastIndexOf('\"'));\n }\n\n // ### The language of this literal\n get language() {\n // Find the last quotation mark (e.g., '\"abc\"@en-us')\n const id = this.id;\n let atPos = id.lastIndexOf('\"') + 1;\n // If \"@\" it follows, return the remaining substring; empty otherwise\n return atPos < id.length && id[atPos++] === '@' ? id.substr(atPos).toLowerCase() : '';\n }\n\n // ### The datatype IRI of this literal\n get datatype() {\n return new NamedNode(this.datatypeString);\n }\n\n // ### The datatype string of this literal\n get datatypeString() {\n // Find the last quotation mark (e.g., '\"abc\"^^http://ex.org/types#t')\n const id = this.id, dtPos = id.lastIndexOf('\"') + 1;\n const char = dtPos < id.length ? id[dtPos] : '';\n // If \"^\" it follows, return the remaining substring\n return char === '^' ? id.substr(dtPos + 2) :\n // If \"@\" follows, return rdf:langString; xsd:string otherwise\n (char !== '@' ? xsd.string : rdf.langString);\n }\n\n // ### Returns whether this object represents the same term as the other\n equals(other) {\n // If both literals were created by this library,\n // equality can be computed through ids\n if (other instanceof Literal)\n return this.id === other.id;\n // Otherwise, compare term type, value, language, and datatype\n return !!other && !!other.datatype &&\n this.termType === other.termType &&\n this.value === other.value &&\n this.language === other.language &&\n this.datatype.value === other.datatype.value;\n }\n\n toJSON() {\n return {\n termType: this.termType,\n value: this.value,\n language: this.language,\n datatype: { termType: 'NamedNode', value: this.datatypeString },\n };\n }\n}\n\n// ## BlankNode constructor\nclass BlankNode extends Term {\n constructor(name) {\n super(`_:${name}`);\n }\n\n // ### The term type of this term\n get termType() {\n return 'BlankNode';\n }\n\n // ### The name of this blank node\n get value() {\n return this.id.substr(2);\n }\n}\n\nclass Variable extends Term {\n constructor(name) {\n super(`?${name}`);\n }\n\n // ### The term type of this term\n get termType() {\n return 'Variable';\n }\n\n // ### The name of this variable\n get value() {\n return this.id.substr(1);\n }\n}\n\n// ## DefaultGraph constructor\nclass DefaultGraph extends Term {\n constructor() {\n super('');\n return DEFAULTGRAPH || this;\n }\n\n // ### The term type of this term\n get termType() {\n return 'DefaultGraph';\n }\n\n // ### Returns whether this object represents the same term as the other\n equals(other) {\n // If both terms were created by this library,\n // equality can be computed through strict equality;\n // otherwise, compare term types.\n return (this === other) || (!!other && (this.termType === other.termType));\n }\n}\n\n// ## DefaultGraph singleton\nDEFAULTGRAPH = new DefaultGraph();\n\n// ### Constructs a term from the given internal string ID\n// The third 'nested' parameter of this function is to aid\n// with recursion over nested terms. It should not be used\n// by consumers of this library.\n// See https://github.com/rdfjs/N3.js/pull/311#discussion_r1061042725\nfunction termFromId(id, factory, nested) {\n factory = factory || DataFactory;\n\n // Falsy value or empty string indicate the default graph\n if (!id)\n return factory.defaultGraph();\n\n // Identify the term type based on the first character\n switch (id[0]) {\n case '?':\n return factory.variable(id.substr(1));\n case '_':\n return factory.blankNode(id.substr(2));\n case '\"':\n // Shortcut for internal literals\n if (factory === DataFactory)\n return new Literal(id);\n // Literal without datatype or language\n if (id[id.length - 1] === '\"')\n return factory.literal(id.substr(1, id.length - 2));\n // Literal with datatype or language\n const endPos = id.lastIndexOf('\"', id.length - 1);\n return factory.literal(id.substr(1, endPos - 1),\n id[endPos + 1] === '@' ? id.substr(endPos + 2)\n : factory.namedNode(id.substr(endPos + 3)));\n case '[':\n id = JSON.parse(id);\n break;\n default:\n if (!nested || !Array.isArray(id)) {\n return factory.namedNode(id);\n }\n }\n return factory.quad(\n termFromId(id[0], factory, true),\n termFromId(id[1], factory, true),\n termFromId(id[2], factory, true),\n id[3] && termFromId(id[3], factory, true),\n );\n}\n\n// ### Constructs an internal string ID from the given term or ID string\n// The third 'nested' parameter of this function is to aid\n// with recursion over nested terms. It should not be used\n// by consumers of this library.\n// See https://github.com/rdfjs/N3.js/pull/311#discussion_r1061042725\nfunction termToId(term, nested) {\n if (typeof term === 'string')\n return term;\n if (term instanceof Term && term.termType !== 'Quad')\n return term.id;\n if (!term)\n return DEFAULTGRAPH.id;\n\n // Term instantiated with another library\n switch (term.termType) {\n case 'NamedNode': return term.value;\n case 'BlankNode': return `_:${term.value}`;\n case 'Variable': return `?${term.value}`;\n case 'DefaultGraph': return '';\n case 'Literal': return `\"${term.value}\"${\n term.language ? `@${term.language}` :\n (term.datatype && term.datatype.value !== xsd.string ? `^^${term.datatype.value}` : '')}`;\n case 'Quad':\n const res = [\n termToId(term.subject, true),\n termToId(term.predicate, true),\n termToId(term.object, true),\n ];\n if (term.graph && term.graph.termType !== 'DefaultGraph') {\n res.push(termToId(term.graph, true));\n }\n return nested ? res : JSON.stringify(res);\n default: throw new Error(`Unexpected termType: ${term.termType}`);\n }\n}\n\n\n// ## Quad constructor\nclass Quad extends Term {\n constructor(subject, predicate, object, graph) {\n super('');\n this._subject = subject;\n this._predicate = predicate;\n this._object = object;\n this._graph = graph || DEFAULTGRAPH;\n }\n\n // ### The term type of this term\n get termType() {\n return 'Quad';\n }\n\n get subject() {\n return this._subject;\n }\n\n get predicate() {\n return this._predicate;\n }\n\n get object() {\n return this._object;\n }\n\n get graph() {\n return this._graph;\n }\n\n // ### Returns a plain object representation of this quad\n toJSON() {\n return {\n termType: this.termType,\n subject: this._subject.toJSON(),\n predicate: this._predicate.toJSON(),\n object: this._object.toJSON(),\n graph: this._graph.toJSON(),\n };\n }\n\n // ### Returns whether this object represents the same quad as the other\n equals(other) {\n return !!other && this._subject.equals(other.subject) &&\n this._predicate.equals(other.predicate) &&\n this._object.equals(other.object) &&\n this._graph.equals(other.graph);\n }\n}\n\n\n// ### Escapes the quotes within the given literal\nfunction escapeQuotes(id) {\n return id.replace(escapedLiteral, (_, quoted) => `\"${quoted.replace(/\"/g, '\"\"')}`);\n}\n\n// ### Unescapes the quotes within the given literal\nfunction unescapeQuotes(id) {\n return id.replace(escapedLiteral, (_, quoted) => `\"${quoted.replace(/\"\"/g, '\"')}`);\n}\n\n// ### Creates an IRI\nfunction namedNode(iri) {\n return new NamedNode(iri);\n}\n\n// ### Creates a blank node\nfunction blankNode(name) {\n return new BlankNode(name || `n3-${_blankNodeCounter++}`);\n}\n\n// ### Creates a literal\nfunction literal(value, languageOrDataType) {\n // Create a language-tagged string\n if (typeof languageOrDataType === 'string')\n return new Literal(`\"${value}\"@${languageOrDataType.toLowerCase()}`);\n\n // Automatically determine datatype for booleans and numbers\n let datatype = languageOrDataType ? languageOrDataType.value : '';\n if (datatype === '') {\n // Convert a boolean\n if (typeof value === 'boolean')\n datatype = xsd.boolean;\n // Convert an integer or double\n else if (typeof value === 'number') {\n if (Number.isFinite(value))\n datatype = Number.isInteger(value) ? xsd.integer : xsd.double;\n else {\n datatype = xsd.double;\n if (!Number.isNaN(value))\n value = value > 0 ? 'INF' : '-INF';\n }\n }\n }\n\n // Create a datatyped literal\n return (datatype === '' || datatype === xsd.string) ?\n new Literal(`\"${value}\"`) :\n new Literal(`\"${value}\"^^${datatype}`);\n}\n\n// ### Creates a variable\nfunction variable(name) {\n return new Variable(name);\n}\n\n// ### Returns the default graph\nfunction defaultGraph() {\n return DEFAULTGRAPH;\n}\n\n// ### Creates a quad\nfunction quad(subject, predicate, object, graph) {\n return new Quad(subject, predicate, object, graph);\n}\n\nfunction fromTerm(term) {\n if (term instanceof Term)\n return term;\n\n // Term instantiated with another library\n switch (term.termType) {\n case 'NamedNode': return namedNode(term.value);\n case 'BlankNode': return blankNode(term.value);\n case 'Variable': return variable(term.value);\n case 'DefaultGraph': return DEFAULTGRAPH;\n case 'Literal': return literal(term.value, term.language || term.datatype);\n case 'Quad': return fromQuad(term);\n default: throw new Error(`Unexpected termType: ${term.termType}`);\n }\n}\n\nfunction fromQuad(inQuad) {\n if (inQuad instanceof Quad)\n return inQuad;\n\n if (inQuad.termType !== 'Quad')\n throw new Error(`Unexpected termType: ${inQuad.termType}`);\n\n return quad(fromTerm(inQuad.subject), fromTerm(inQuad.predicate), fromTerm(inQuad.object), fromTerm(inQuad.graph));\n}\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/N3DataFactory.js?");
95
95
 
96
96
  /***/ }),
97
97
 
@@ -102,7 +102,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
102
102
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
103
103
 
104
104
  "use strict";
105
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ N3Lexer)\n/* harmony export */ });\n/* harmony import */ var _IRIs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./IRIs */ \"./node_modules/n3/src/IRIs.js\");\n/* harmony import */ var queue_microtask__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! queue-microtask */ \"./node_modules/queue-microtask/index.js\");\n/* harmony import */ var queue_microtask__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(queue_microtask__WEBPACK_IMPORTED_MODULE_0__);\n// **N3Lexer** tokenizes N3 documents.\n\n\n\nconst { xsd } = _IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"];\n\n// Regular expression and replacement string to escape N3 strings\nconst escapeSequence = /\\\\u([a-fA-F0-9]{4})|\\\\U([a-fA-F0-9]{8})|\\\\([^])/g;\nconst escapeReplacements = {\n '\\\\': '\\\\', \"'\": \"'\", '\"': '\"',\n 'n': '\\n', 'r': '\\r', 't': '\\t', 'f': '\\f', 'b': '\\b',\n '_': '_', '~': '~', '.': '.', '-': '-', '!': '!', '$': '$', '&': '&',\n '(': '(', ')': ')', '*': '*', '+': '+', ',': ',', ';': ';', '=': '=',\n '/': '/', '?': '?', '#': '#', '@': '@', '%': '%',\n};\nconst illegalIriChars = /[\\x00-\\x20<>\\\\\"\\{\\}\\|\\^\\`]/;\n\nconst lineModeRegExps = {\n _iri: true,\n _unescapedIri: true,\n _simpleQuotedString: true,\n _langcode: true,\n _blank: true,\n _newline: true,\n _comment: true,\n _whitespace: true,\n _endOfFile: true,\n};\nconst invalidRegExp = /$0^/;\n\n// ## Constructor\nclass N3Lexer {\n constructor(options) {\n // ## Regular expressions\n // It's slightly faster to have these as properties than as in-scope variables\n this._iri = /^<((?:[^ <>{}\\\\]|\\\\[uU])+)>[ \\t]*/; // IRI with escape sequences; needs sanity check after unescaping\n this._unescapedIri = /^<([^\\x00-\\x20<>\\\\\"\\{\\}\\|\\^\\`]*)>[ \\t]*/; // IRI without escape sequences; no unescaping\n this._simpleQuotedString = /^\"([^\"\\\\\\r\\n]*)\"(?=[^\"])/; // string without escape sequences\n this._simpleApostropheString = /^'([^'\\\\\\r\\n]*)'(?=[^'])/;\n this._langcode = /^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9\\-])/i;\n 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<])/;\n 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#()\\[\\]\\{\\}\"'<>]))/;\n 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#()\\[\\]\\{\\}\"'<>])/;\n 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#()\\[\\]\\{\\}\"'<>]))/;\n this._number = /^[\\-+]?(?:(\\d+\\.\\d*|\\.?\\d+)[eE][\\-+]?|\\d*(\\.)?)\\d+(?=\\.?[,;:\\s#()\\[\\]\\{\\}\"'<>])/;\n this._boolean = /^(?:true|false)(?=[.,;\\s#()\\[\\]\\{\\}\"'<>])/;\n this._keyword = /^@[a-z]+(?=[\\s#<:])/i;\n this._sparqlKeyword = /^(?:PREFIX|BASE|GRAPH)(?=[\\s#<])/i;\n this._shortPredicates = /^a(?=[\\s#()\\[\\]\\{\\}\"'<>])/;\n this._newline = /^[ \\t]*(?:#[^\\n\\r]*)?(?:\\r\\n|\\n|\\r)[ \\t]*/;\n this._comment = /#([^\\n\\r]*)/;\n this._whitespace = /^[ \\t]+/;\n this._endOfFile = /^(?:#[^\\n\\r]*)?$/;\n options = options || {};\n\n // In line mode (N-Triples or N-Quads), only simple features may be parsed\n if (this._lineMode = !!options.lineMode) {\n this._n3Mode = false;\n // Don't tokenize special literals\n for (const key in this) {\n if (!(key in lineModeRegExps) && this[key] instanceof RegExp)\n this[key] = invalidRegExp;\n }\n }\n // When not in line mode, enable N3 functionality by default\n else {\n this._n3Mode = options.n3 !== false;\n }\n // Don't output comment tokens by default\n this._comments = !!options.comments;\n // Cache the last tested closing position of long literals\n this._literalClosingPos = 0;\n }\n\n // ## Private methods\n\n // ### `_tokenizeToEnd` tokenizes as for as possible, emitting tokens through the callback\n _tokenizeToEnd(callback, inputFinished) {\n // Continue parsing as far as possible; the loop will return eventually\n let input = this._input;\n let currentLineLength = input.length;\n while (true) {\n // Count and skip whitespace lines\n let whiteSpaceMatch, comment;\n while (whiteSpaceMatch = this._newline.exec(input)) {\n // Try to find a comment\n if (this._comments && (comment = this._comment.exec(whiteSpaceMatch[0])))\n emitToken('comment', comment[1], '', this._line, whiteSpaceMatch[0].length);\n // Advance the input\n input = input.substr(whiteSpaceMatch[0].length, input.length);\n currentLineLength = input.length;\n this._line++;\n }\n // Skip whitespace on current line\n if (!whiteSpaceMatch && (whiteSpaceMatch = this._whitespace.exec(input)))\n input = input.substr(whiteSpaceMatch[0].length, input.length);\n\n // Stop for now if we're at the end\n if (this._endOfFile.test(input)) {\n // If the input is finished, emit EOF\n if (inputFinished) {\n // Try to find a final comment\n if (this._comments && (comment = this._comment.exec(input)))\n emitToken('comment', comment[1], '', this._line, input.length);\n input = null;\n emitToken('eof', '', '', this._line, 0);\n }\n return this._input = input;\n }\n\n // Look for specific token types based on the first character\n const line = this._line, firstChar = input[0];\n let type = '', value = '', prefix = '',\n match = null, matchLength = 0, inconclusive = false;\n switch (firstChar) {\n case '^':\n // We need at least 3 tokens lookahead to distinguish ^^<IRI> and ^^pre:fixed\n if (input.length < 3)\n break;\n // Try to match a type\n else if (input[1] === '^') {\n this._previousMarker = '^^';\n // Move to type IRI or prefixed name\n input = input.substr(2);\n if (input[0] !== '<') {\n inconclusive = true;\n break;\n }\n }\n // If no type, it must be a path expression\n else {\n if (this._n3Mode) {\n matchLength = 1;\n type = '^';\n }\n break;\n }\n // Fall through in case the type is an IRI\n case '<':\n // Try to find a full IRI without escape sequences\n if (match = this._unescapedIri.exec(input))\n type = 'IRI', value = match[1];\n // Try to find a full IRI with escape sequences\n else if (match = this._iri.exec(input)) {\n value = this._unescape(match[1]);\n if (value === null || illegalIriChars.test(value))\n return reportSyntaxError(this);\n type = 'IRI';\n }\n // Try to find a nested triple\n else if (input.length > 1 && input[1] === '<')\n type = '<<', matchLength = 2;\n // Try to find a backwards implication arrow\n else if (this._n3Mode && input.length > 1 && input[1] === '=')\n type = 'inverse', matchLength = 2, value = '>';\n break;\n\n case '>':\n if (input.length > 1 && input[1] === '>')\n type = '>>', matchLength = 2;\n break;\n\n case '_':\n // Try to find a blank node. Since it can contain (but not end with) a dot,\n // we always need a non-dot character before deciding it is a blank node.\n // Therefore, try inserting a space if we're at the end of the input.\n if ((match = this._blank.exec(input)) ||\n inputFinished && (match = this._blank.exec(`${input} `)))\n type = 'blank', prefix = '_', value = match[1];\n break;\n\n case '\"':\n // Try to find a literal without escape sequences\n if (match = this._simpleQuotedString.exec(input))\n value = match[1];\n // Try to find a literal wrapped in three pairs of quotes\n else {\n ({ value, matchLength } = this._parseLiteral(input));\n if (value === null)\n return reportSyntaxError(this);\n }\n if (match !== null || matchLength !== 0) {\n type = 'literal';\n this._literalClosingPos = 0;\n }\n break;\n\n case \"'\":\n if (!this._lineMode) {\n // Try to find a literal without escape sequences\n if (match = this._simpleApostropheString.exec(input))\n value = match[1];\n // Try to find a literal wrapped in three pairs of quotes\n else {\n ({ value, matchLength } = this._parseLiteral(input));\n if (value === null)\n return reportSyntaxError(this);\n }\n if (match !== null || matchLength !== 0) {\n type = 'literal';\n this._literalClosingPos = 0;\n }\n }\n break;\n\n case '?':\n // Try to find a variable\n if (this._n3Mode && (match = this._variable.exec(input)))\n type = 'var', value = match[0];\n break;\n\n case '@':\n // Try to find a language code\n if (this._previousMarker === 'literal' && (match = this._langcode.exec(input)))\n type = 'langcode', value = match[1];\n // Try to find a keyword\n else if (match = this._keyword.exec(input))\n type = match[0];\n break;\n\n case '.':\n // Try to find a dot as punctuation\n if (input.length === 1 ? inputFinished : (input[1] < '0' || input[1] > '9')) {\n type = '.';\n matchLength = 1;\n break;\n }\n // Fall through to numerical case (could be a decimal dot)\n\n case '0':\n case '1':\n case '2':\n case '3':\n case '4':\n case '5':\n case '6':\n case '7':\n case '8':\n case '9':\n case '+':\n case '-':\n // Try to find a number. Since it can contain (but not end with) a dot,\n // we always need a non-dot character before deciding it is a number.\n // Therefore, try inserting a space if we're at the end of the input.\n if (match = this._number.exec(input) ||\n inputFinished && (match = this._number.exec(`${input} `))) {\n type = 'literal', value = match[0];\n prefix = (typeof match[1] === 'string' ? xsd.double :\n (typeof match[2] === 'string' ? xsd.decimal : xsd.integer));\n }\n break;\n\n case 'B':\n case 'b':\n case 'p':\n case 'P':\n case 'G':\n case 'g':\n // Try to find a SPARQL-style keyword\n if (match = this._sparqlKeyword.exec(input))\n type = match[0].toUpperCase();\n else\n inconclusive = true;\n break;\n\n case 'f':\n case 't':\n // Try to match a boolean\n if (match = this._boolean.exec(input))\n type = 'literal', value = match[0], prefix = xsd.boolean;\n else\n inconclusive = true;\n break;\n\n case 'a':\n // Try to find an abbreviated predicate\n if (match = this._shortPredicates.exec(input))\n type = 'abbreviation', value = 'a';\n else\n inconclusive = true;\n break;\n\n case '=':\n // Try to find an implication arrow or equals sign\n if (this._n3Mode && input.length > 1) {\n type = 'abbreviation';\n if (input[1] !== '>')\n matchLength = 1, value = '=';\n else\n matchLength = 2, value = '>';\n }\n break;\n\n case '!':\n if (!this._n3Mode)\n break;\n case ',':\n case ';':\n case '[':\n case ']':\n case '(':\n case ')':\n case '}':\n if (!this._lineMode) {\n matchLength = 1;\n type = firstChar;\n }\n break;\n case '{':\n // We need at least 2 tokens lookahead to distinguish \"{|\" and \"{ \"\n if (!this._lineMode && input.length >= 2) {\n // Try to find a quoted triple annotation start\n if (input[1] === '|')\n type = '{|', matchLength = 2;\n else\n type = firstChar, matchLength = 1;\n }\n break;\n case '|':\n // We need 2 tokens lookahead to parse \"|}\"\n // Try to find a quoted triple annotation end\n if (input.length >= 2 && input[1] === '}')\n type = '|}', matchLength = 2;\n break;\n\n default:\n inconclusive = true;\n }\n\n // Some first characters do not allow an immediate decision, so inspect more\n if (inconclusive) {\n // Try to find a prefix\n if ((this._previousMarker === '@prefix' || this._previousMarker === 'PREFIX') &&\n (match = this._prefix.exec(input)))\n type = 'prefix', value = match[1] || '';\n // Try to find a prefixed name. Since it can contain (but not end with) a dot,\n // we always need a non-dot character before deciding it is a prefixed name.\n // Therefore, try inserting a space if we're at the end of the input.\n else if ((match = this._prefixed.exec(input)) ||\n inputFinished && (match = this._prefixed.exec(`${input} `)))\n type = 'prefixed', prefix = match[1] || '', value = this._unescape(match[2]);\n }\n\n // A type token is special: it can only be emitted after an IRI or prefixed name is read\n if (this._previousMarker === '^^') {\n switch (type) {\n case 'prefixed': type = 'type'; break;\n case 'IRI': type = 'typeIRI'; break;\n default: type = '';\n }\n }\n\n // What if nothing of the above was found?\n if (!type) {\n // We could be in streaming mode, and then we just wait for more input to arrive.\n // Otherwise, a syntax error has occurred in the input.\n // One exception: error on an unaccounted linebreak (= not inside a triple-quoted literal).\n if (inputFinished || (!/^'''|^\"\"\"/.test(input) && /\\n|\\r/.test(input)))\n return reportSyntaxError(this);\n else\n return this._input = input;\n }\n\n // Emit the parsed token\n const length = matchLength || match[0].length;\n const token = emitToken(type, value, prefix, line, length);\n this.previousToken = token;\n this._previousMarker = type;\n\n // Advance to next part to tokenize\n input = input.substr(length, input.length);\n }\n\n // Emits the token through the callback\n function emitToken(type, value, prefix, line, length) {\n const start = input ? currentLineLength - input.length : currentLineLength;\n const end = start + length;\n const token = { type, value, prefix, line, start, end };\n callback(null, token);\n return token;\n }\n // Signals the syntax error through the callback\n function reportSyntaxError(self) { callback(self._syntaxError(/^\\S*/.exec(input)[0])); }\n }\n\n // ### `_unescape` replaces N3 escape codes by their corresponding characters\n _unescape(item) {\n let invalid = false;\n const replaced = item.replace(escapeSequence, (sequence, unicode4, unicode8, escapedChar) => {\n // 4-digit unicode character\n if (typeof unicode4 === 'string')\n return String.fromCharCode(Number.parseInt(unicode4, 16));\n // 8-digit unicode character\n if (typeof unicode8 === 'string') {\n let charCode = Number.parseInt(unicode8, 16);\n return charCode <= 0xFFFF ? String.fromCharCode(Number.parseInt(unicode8, 16)) :\n String.fromCharCode(0xD800 + ((charCode -= 0x10000) >> 10), 0xDC00 + (charCode & 0x3FF));\n }\n // fixed escape sequence\n if (escapedChar in escapeReplacements)\n return escapeReplacements[escapedChar];\n // invalid escape sequence\n invalid = true;\n return '';\n });\n return invalid ? null : replaced;\n }\n\n // ### `_parseLiteral` parses a literal into an unescaped value\n _parseLiteral(input) {\n // Ensure we have enough lookahead to identify triple-quoted strings\n if (input.length >= 3) {\n // Identify the opening quote(s)\n const opening = input.match(/^(?:\"\"\"|\"|'''|'|)/)[0];\n const openingLength = opening.length;\n\n // Find the next candidate closing quotes\n let closingPos = Math.max(this._literalClosingPos, openingLength);\n while ((closingPos = input.indexOf(opening, closingPos)) > 0) {\n // Count backslashes right before the closing quotes\n let backslashCount = 0;\n while (input[closingPos - backslashCount - 1] === '\\\\')\n backslashCount++;\n\n // An even number of backslashes (in particular 0)\n // means these are actual, non-escaped closing quotes\n if (backslashCount % 2 === 0) {\n // Extract and unescape the value\n const raw = input.substring(openingLength, closingPos);\n const lines = raw.split(/\\r\\n|\\r|\\n/).length - 1;\n const matchLength = closingPos + openingLength;\n // Only triple-quoted strings can be multi-line\n if (openingLength === 1 && lines !== 0 ||\n openingLength === 3 && this._lineMode)\n break;\n this._line += lines;\n return { value: this._unescape(raw), matchLength };\n }\n closingPos++;\n }\n this._literalClosingPos = input.length - openingLength + 1;\n }\n return { value: '', matchLength: 0 };\n }\n\n // ### `_syntaxError` creates a syntax error for the given issue\n _syntaxError(issue) {\n this._input = null;\n const err = new Error(`Unexpected \"${issue}\" on line ${this._line}.`);\n err.context = {\n token: undefined,\n line: this._line,\n previousToken: this.previousToken,\n };\n return err;\n }\n\n // ### Strips off any starting UTF BOM mark.\n _readStartingBom(input) {\n return input.startsWith('\\ufeff') ? input.substr(1) : input;\n }\n\n // ## Public methods\n\n // ### `tokenize` starts the transformation of an N3 document into an array of tokens.\n // The input can be a string or a stream.\n tokenize(input, callback) {\n this._line = 1;\n\n // If the input is a string, continuously emit tokens through the callback until the end\n if (typeof input === 'string') {\n this._input = this._readStartingBom(input);\n // If a callback was passed, asynchronously call it\n if (typeof callback === 'function')\n queue_microtask__WEBPACK_IMPORTED_MODULE_0___default()(() => this._tokenizeToEnd(callback, true));\n // If no callback was passed, tokenize synchronously and return\n else {\n const tokens = [];\n let error;\n this._tokenizeToEnd((e, t) => e ? (error = e) : tokens.push(t), true);\n if (error) throw error;\n return tokens;\n }\n }\n // Otherwise, the input must be a stream\n else {\n this._pendingBuffer = null;\n if (typeof input.setEncoding === 'function')\n input.setEncoding('utf8');\n // Adds the data chunk to the buffer and parses as far as possible\n input.on('data', data => {\n if (this._input !== null && data.length !== 0) {\n // Prepend any previous pending writes\n if (this._pendingBuffer) {\n data = Buffer.concat([this._pendingBuffer, data]);\n this._pendingBuffer = null;\n }\n // Hold if the buffer ends in an incomplete unicode sequence\n if (data[data.length - 1] & 0x80) {\n this._pendingBuffer = data;\n }\n // Otherwise, tokenize as far as possible\n else {\n // Only read a BOM at the start\n if (typeof this._input === 'undefined')\n this._input = this._readStartingBom(typeof data === 'string' ? data : data.toString());\n else\n this._input += data;\n this._tokenizeToEnd(callback, false);\n }\n }\n });\n // Parses until the end\n input.on('end', () => {\n if (typeof this._input === 'string')\n this._tokenizeToEnd(callback, true);\n });\n input.on('error', callback);\n }\n }\n}\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/N3Lexer.js?");
105
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ N3Lexer)\n/* harmony export */ });\n/* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! buffer */ \"./node_modules/buffer/index.js\");\n/* harmony import */ var queue_microtask__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! queue-microtask */ \"./node_modules/queue-microtask/index.js\");\n/* harmony import */ var queue_microtask__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(queue_microtask__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _IRIs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./IRIs */ \"./node_modules/n3/src/IRIs.js\");\n// **N3Lexer** tokenizes N3 documents.\n\n\n\n\nconst { xsd } = _IRIs__WEBPACK_IMPORTED_MODULE_2__[\"default\"];\n\n// Regular expression and replacement string to escape N3 strings\nconst escapeSequence = /\\\\u([a-fA-F0-9]{4})|\\\\U([a-fA-F0-9]{8})|\\\\([^])/g;\nconst escapeReplacements = {\n '\\\\': '\\\\', \"'\": \"'\", '\"': '\"',\n 'n': '\\n', 'r': '\\r', 't': '\\t', 'f': '\\f', 'b': '\\b',\n '_': '_', '~': '~', '.': '.', '-': '-', '!': '!', '$': '$', '&': '&',\n '(': '(', ')': ')', '*': '*', '+': '+', ',': ',', ';': ';', '=': '=',\n '/': '/', '?': '?', '#': '#', '@': '@', '%': '%',\n};\nconst illegalIriChars = /[\\x00-\\x20<>\\\\\"\\{\\}\\|\\^\\`]/;\n\nconst lineModeRegExps = {\n _iri: true,\n _unescapedIri: true,\n _simpleQuotedString: true,\n _langcode: true,\n _blank: true,\n _newline: true,\n _comment: true,\n _whitespace: true,\n _endOfFile: true,\n};\nconst invalidRegExp = /$0^/;\n\n// ## Constructor\nclass N3Lexer {\n constructor(options) {\n // ## Regular expressions\n // It's slightly faster to have these as properties than as in-scope variables\n this._iri = /^<((?:[^ <>{}\\\\]|\\\\[uU])+)>[ \\t]*/; // IRI with escape sequences; needs sanity check after unescaping\n this._unescapedIri = /^<([^\\x00-\\x20<>\\\\\"\\{\\}\\|\\^\\`]*)>[ \\t]*/; // IRI without escape sequences; no unescaping\n this._simpleQuotedString = /^\"([^\"\\\\\\r\\n]*)\"(?=[^\"])/; // string without escape sequences\n this._simpleApostropheString = /^'([^'\\\\\\r\\n]*)'(?=[^'])/;\n this._langcode = /^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9\\-])/i;\n 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<])/;\n 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#()\\[\\]\\{\\}\"'<>]))/;\n 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#()\\[\\]\\{\\}\"'<>])/;\n 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#()\\[\\]\\{\\}\"'<>]))/;\n this._number = /^[\\-+]?(?:(\\d+\\.\\d*|\\.?\\d+)[eE][\\-+]?|\\d*(\\.)?)\\d+(?=\\.?[,;:\\s#()\\[\\]\\{\\}\"'<>])/;\n this._boolean = /^(?:true|false)(?=[.,;\\s#()\\[\\]\\{\\}\"'<>])/;\n this._keyword = /^@[a-z]+(?=[\\s#<:])/i;\n this._sparqlKeyword = /^(?:PREFIX|BASE|GRAPH)(?=[\\s#<])/i;\n this._shortPredicates = /^a(?=[\\s#()\\[\\]\\{\\}\"'<>])/;\n this._newline = /^[ \\t]*(?:#[^\\n\\r]*)?(?:\\r\\n|\\n|\\r)[ \\t]*/;\n this._comment = /#([^\\n\\r]*)/;\n this._whitespace = /^[ \\t]+/;\n this._endOfFile = /^(?:#[^\\n\\r]*)?$/;\n options = options || {};\n\n // Whether the log:isImpliedBy predicate is supported\n this._isImpliedBy = options.isImpliedBy;\n\n // In line mode (N-Triples or N-Quads), only simple features may be parsed\n if (this._lineMode = !!options.lineMode) {\n this._n3Mode = false;\n // Don't tokenize special literals\n for (const key in this) {\n if (!(key in lineModeRegExps) && this[key] instanceof RegExp)\n this[key] = invalidRegExp;\n }\n }\n // When not in line mode, enable N3 functionality by default\n else {\n this._n3Mode = options.n3 !== false;\n }\n // Don't output comment tokens by default\n this.comments = !!options.comments;\n // Cache the last tested closing position of long literals\n this._literalClosingPos = 0;\n }\n\n // ## Private methods\n\n // ### `_tokenizeToEnd` tokenizes as for as possible, emitting tokens through the callback\n _tokenizeToEnd(callback, inputFinished) {\n // Continue parsing as far as possible; the loop will return eventually\n let input = this._input;\n let currentLineLength = input.length;\n while (true) {\n // Count and skip whitespace lines\n let whiteSpaceMatch, comment;\n while (whiteSpaceMatch = this._newline.exec(input)) {\n // Try to find a comment\n if (this.comments && (comment = this._comment.exec(whiteSpaceMatch[0])))\n emitToken('comment', comment[1], '', this._line, whiteSpaceMatch[0].length);\n // Advance the input\n input = input.substr(whiteSpaceMatch[0].length, input.length);\n currentLineLength = input.length;\n this._line++;\n }\n // Skip whitespace on current line\n if (!whiteSpaceMatch && (whiteSpaceMatch = this._whitespace.exec(input)))\n input = input.substr(whiteSpaceMatch[0].length, input.length);\n\n // Stop for now if we're at the end\n if (this._endOfFile.test(input)) {\n // If the input is finished, emit EOF\n if (inputFinished) {\n // Try to find a final comment\n if (this.comments && (comment = this._comment.exec(input)))\n emitToken('comment', comment[1], '', this._line, input.length);\n input = null;\n emitToken('eof', '', '', this._line, 0);\n }\n return this._input = input;\n }\n\n // Look for specific token types based on the first character\n const line = this._line, firstChar = input[0];\n let type = '', value = '', prefix = '',\n match = null, matchLength = 0, inconclusive = false;\n switch (firstChar) {\n case '^':\n // We need at least 3 tokens lookahead to distinguish ^^<IRI> and ^^pre:fixed\n if (input.length < 3)\n break;\n // Try to match a type\n else if (input[1] === '^') {\n this._previousMarker = '^^';\n // Move to type IRI or prefixed name\n input = input.substr(2);\n if (input[0] !== '<') {\n inconclusive = true;\n break;\n }\n }\n // If no type, it must be a path expression\n else {\n if (this._n3Mode) {\n matchLength = 1;\n type = '^';\n }\n break;\n }\n // Fall through in case the type is an IRI\n case '<':\n // Try to find a full IRI without escape sequences\n if (match = this._unescapedIri.exec(input))\n type = 'IRI', value = match[1];\n // Try to find a full IRI with escape sequences\n else if (match = this._iri.exec(input)) {\n value = this._unescape(match[1]);\n if (value === null || illegalIriChars.test(value))\n return reportSyntaxError(this);\n type = 'IRI';\n }\n // Try to find a nested triple\n else if (input.length > 1 && input[1] === '<')\n type = '<<', matchLength = 2;\n // Try to find a backwards implication arrow\n else if (this._n3Mode && input.length > 1 && input[1] === '=') {\n matchLength = 2;\n if (this._isImpliedBy) type = 'abbreviation', value = '<';\n else type = 'inverse', value = '>';\n }\n break;\n\n case '>':\n if (input.length > 1 && input[1] === '>')\n type = '>>', matchLength = 2;\n break;\n\n case '_':\n // Try to find a blank node. Since it can contain (but not end with) a dot,\n // we always need a non-dot character before deciding it is a blank node.\n // Therefore, try inserting a space if we're at the end of the input.\n if ((match = this._blank.exec(input)) ||\n inputFinished && (match = this._blank.exec(`${input} `)))\n type = 'blank', prefix = '_', value = match[1];\n break;\n\n case '\"':\n // Try to find a literal without escape sequences\n if (match = this._simpleQuotedString.exec(input))\n value = match[1];\n // Try to find a literal wrapped in three pairs of quotes\n else {\n ({ value, matchLength } = this._parseLiteral(input));\n if (value === null)\n return reportSyntaxError(this);\n }\n if (match !== null || matchLength !== 0) {\n type = 'literal';\n this._literalClosingPos = 0;\n }\n break;\n\n case \"'\":\n if (!this._lineMode) {\n // Try to find a literal without escape sequences\n if (match = this._simpleApostropheString.exec(input))\n value = match[1];\n // Try to find a literal wrapped in three pairs of quotes\n else {\n ({ value, matchLength } = this._parseLiteral(input));\n if (value === null)\n return reportSyntaxError(this);\n }\n if (match !== null || matchLength !== 0) {\n type = 'literal';\n this._literalClosingPos = 0;\n }\n }\n break;\n\n case '?':\n // Try to find a variable\n if (this._n3Mode && (match = this._variable.exec(input)))\n type = 'var', value = match[0];\n break;\n\n case '@':\n // Try to find a language code\n if (this._previousMarker === 'literal' && (match = this._langcode.exec(input)))\n type = 'langcode', value = match[1];\n // Try to find a keyword\n else if (match = this._keyword.exec(input))\n type = match[0];\n break;\n\n case '.':\n // Try to find a dot as punctuation\n if (input.length === 1 ? inputFinished : (input[1] < '0' || input[1] > '9')) {\n type = '.';\n matchLength = 1;\n break;\n }\n // Fall through to numerical case (could be a decimal dot)\n\n case '0':\n case '1':\n case '2':\n case '3':\n case '4':\n case '5':\n case '6':\n case '7':\n case '8':\n case '9':\n case '+':\n case '-':\n // Try to find a number. Since it can contain (but not end with) a dot,\n // we always need a non-dot character before deciding it is a number.\n // Therefore, try inserting a space if we're at the end of the input.\n if (match = this._number.exec(input) ||\n inputFinished && (match = this._number.exec(`${input} `))) {\n type = 'literal', value = match[0];\n prefix = (typeof match[1] === 'string' ? xsd.double :\n (typeof match[2] === 'string' ? xsd.decimal : xsd.integer));\n }\n break;\n\n case 'B':\n case 'b':\n case 'p':\n case 'P':\n case 'G':\n case 'g':\n // Try to find a SPARQL-style keyword\n if (match = this._sparqlKeyword.exec(input))\n type = match[0].toUpperCase();\n else\n inconclusive = true;\n break;\n\n case 'f':\n case 't':\n // Try to match a boolean\n if (match = this._boolean.exec(input))\n type = 'literal', value = match[0], prefix = xsd.boolean;\n else\n inconclusive = true;\n break;\n\n case 'a':\n // Try to find an abbreviated predicate\n if (match = this._shortPredicates.exec(input))\n type = 'abbreviation', value = 'a';\n else\n inconclusive = true;\n break;\n\n case '=':\n // Try to find an implication arrow or equals sign\n if (this._n3Mode && input.length > 1) {\n type = 'abbreviation';\n if (input[1] !== '>')\n matchLength = 1, value = '=';\n else\n matchLength = 2, value = '>';\n }\n break;\n\n case '!':\n if (!this._n3Mode)\n break;\n case ',':\n case ';':\n case '[':\n case ']':\n case '(':\n case ')':\n case '}':\n if (!this._lineMode) {\n matchLength = 1;\n type = firstChar;\n }\n break;\n case '{':\n // We need at least 2 tokens lookahead to distinguish \"{|\" and \"{ \"\n if (!this._lineMode && input.length >= 2) {\n // Try to find a quoted triple annotation start\n if (input[1] === '|')\n type = '{|', matchLength = 2;\n else\n type = firstChar, matchLength = 1;\n }\n break;\n case '|':\n // We need 2 tokens lookahead to parse \"|}\"\n // Try to find a quoted triple annotation end\n if (input.length >= 2 && input[1] === '}')\n type = '|}', matchLength = 2;\n break;\n\n default:\n inconclusive = true;\n }\n\n // Some first characters do not allow an immediate decision, so inspect more\n if (inconclusive) {\n // Try to find a prefix\n if ((this._previousMarker === '@prefix' || this._previousMarker === 'PREFIX') &&\n (match = this._prefix.exec(input)))\n type = 'prefix', value = match[1] || '';\n // Try to find a prefixed name. Since it can contain (but not end with) a dot,\n // we always need a non-dot character before deciding it is a prefixed name.\n // Therefore, try inserting a space if we're at the end of the input.\n else if ((match = this._prefixed.exec(input)) ||\n inputFinished && (match = this._prefixed.exec(`${input} `)))\n type = 'prefixed', prefix = match[1] || '', value = this._unescape(match[2]);\n }\n\n // A type token is special: it can only be emitted after an IRI or prefixed name is read\n if (this._previousMarker === '^^') {\n switch (type) {\n case 'prefixed': type = 'type'; break;\n case 'IRI': type = 'typeIRI'; break;\n default: type = '';\n }\n }\n\n // What if nothing of the above was found?\n if (!type) {\n // We could be in streaming mode, and then we just wait for more input to arrive.\n // Otherwise, a syntax error has occurred in the input.\n // One exception: error on an unaccounted linebreak (= not inside a triple-quoted literal).\n if (inputFinished || (!/^'''|^\"\"\"/.test(input) && /\\n|\\r/.test(input)))\n return reportSyntaxError(this);\n else\n return this._input = input;\n }\n\n // Emit the parsed token\n const length = matchLength || match[0].length;\n const token = emitToken(type, value, prefix, line, length);\n this.previousToken = token;\n this._previousMarker = type;\n\n // Advance to next part to tokenize\n input = input.substr(length, input.length);\n }\n\n // Emits the token through the callback\n function emitToken(type, value, prefix, line, length) {\n const start = input ? currentLineLength - input.length : currentLineLength;\n const end = start + length;\n const token = { type, value, prefix, line, start, end };\n callback(null, token);\n return token;\n }\n // Signals the syntax error through the callback\n function reportSyntaxError(self) { callback(self._syntaxError(/^\\S*/.exec(input)[0])); }\n }\n\n // ### `_unescape` replaces N3 escape codes by their corresponding characters\n _unescape(item) {\n let invalid = false;\n const replaced = item.replace(escapeSequence, (sequence, unicode4, unicode8, escapedChar) => {\n // 4-digit unicode character\n if (typeof unicode4 === 'string')\n return String.fromCharCode(Number.parseInt(unicode4, 16));\n // 8-digit unicode character\n if (typeof unicode8 === 'string') {\n let charCode = Number.parseInt(unicode8, 16);\n return charCode <= 0xFFFF ? String.fromCharCode(Number.parseInt(unicode8, 16)) :\n String.fromCharCode(0xD800 + ((charCode -= 0x10000) >> 10), 0xDC00 + (charCode & 0x3FF));\n }\n // fixed escape sequence\n if (escapedChar in escapeReplacements)\n return escapeReplacements[escapedChar];\n // invalid escape sequence\n invalid = true;\n return '';\n });\n return invalid ? null : replaced;\n }\n\n // ### `_parseLiteral` parses a literal into an unescaped value\n _parseLiteral(input) {\n // Ensure we have enough lookahead to identify triple-quoted strings\n if (input.length >= 3) {\n // Identify the opening quote(s)\n const opening = input.match(/^(?:\"\"\"|\"|'''|'|)/)[0];\n const openingLength = opening.length;\n\n // Find the next candidate closing quotes\n let closingPos = Math.max(this._literalClosingPos, openingLength);\n while ((closingPos = input.indexOf(opening, closingPos)) > 0) {\n // Count backslashes right before the closing quotes\n let backslashCount = 0;\n while (input[closingPos - backslashCount - 1] === '\\\\')\n backslashCount++;\n\n // An even number of backslashes (in particular 0)\n // means these are actual, non-escaped closing quotes\n if (backslashCount % 2 === 0) {\n // Extract and unescape the value\n const raw = input.substring(openingLength, closingPos);\n const lines = raw.split(/\\r\\n|\\r|\\n/).length - 1;\n const matchLength = closingPos + openingLength;\n // Only triple-quoted strings can be multi-line\n if (openingLength === 1 && lines !== 0 ||\n openingLength === 3 && this._lineMode)\n break;\n this._line += lines;\n return { value: this._unescape(raw), matchLength };\n }\n closingPos++;\n }\n this._literalClosingPos = input.length - openingLength + 1;\n }\n return { value: '', matchLength: 0 };\n }\n\n // ### `_syntaxError` creates a syntax error for the given issue\n _syntaxError(issue) {\n this._input = null;\n const err = new Error(`Unexpected \"${issue}\" on line ${this._line}.`);\n err.context = {\n token: undefined,\n line: this._line,\n previousToken: this.previousToken,\n };\n return err;\n }\n\n // ### Strips off any starting UTF BOM mark.\n _readStartingBom(input) {\n return input.startsWith('\\ufeff') ? input.substr(1) : input;\n }\n\n // ## Public methods\n\n // ### `tokenize` starts the transformation of an N3 document into an array of tokens.\n // The input can be a string or a stream.\n tokenize(input, callback) {\n this._line = 1;\n\n // If the input is a string, continuously emit tokens through the callback until the end\n if (typeof input === 'string') {\n this._input = this._readStartingBom(input);\n // If a callback was passed, asynchronously call it\n if (typeof callback === 'function')\n queue_microtask__WEBPACK_IMPORTED_MODULE_1___default()(() => this._tokenizeToEnd(callback, true));\n // If no callback was passed, tokenize synchronously and return\n else {\n const tokens = [];\n let error;\n this._tokenizeToEnd((e, t) => e ? (error = e) : tokens.push(t), true);\n if (error) throw error;\n return tokens;\n }\n }\n // Otherwise, the input must be a stream\n else {\n this._pendingBuffer = null;\n if (typeof input.setEncoding === 'function')\n input.setEncoding('utf8');\n // Adds the data chunk to the buffer and parses as far as possible\n input.on('data', data => {\n if (this._input !== null && data.length !== 0) {\n // Prepend any previous pending writes\n if (this._pendingBuffer) {\n data = buffer__WEBPACK_IMPORTED_MODULE_0__.Buffer.concat([this._pendingBuffer, data]);\n this._pendingBuffer = null;\n }\n // Hold if the buffer ends in an incomplete unicode sequence\n if (data[data.length - 1] & 0x80) {\n this._pendingBuffer = data;\n }\n // Otherwise, tokenize as far as possible\n else {\n // Only read a BOM at the start\n if (typeof this._input === 'undefined')\n this._input = this._readStartingBom(typeof data === 'string' ? data : data.toString());\n else\n this._input += data;\n this._tokenizeToEnd(callback, false);\n }\n }\n });\n // Parses until the end\n input.on('end', () => {\n if (typeof this._input === 'string')\n this._tokenizeToEnd(callback, true);\n });\n input.on('error', callback);\n }\n }\n}\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/N3Lexer.js?");
106
106
 
107
107
  /***/ }),
108
108
 
@@ -113,7 +113,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
113
113
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
114
114
 
115
115
  "use strict";
116
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ N3Parser)\n/* harmony export */ });\n/* harmony import */ var _N3Lexer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./N3Lexer */ \"./node_modules/n3/src/N3Lexer.js\");\n/* harmony import */ var _N3DataFactory__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./N3DataFactory */ \"./node_modules/n3/src/N3DataFactory.js\");\n/* harmony import */ var _IRIs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./IRIs */ \"./node_modules/n3/src/IRIs.js\");\n// **N3Parser** parses N3 documents.\n\n\n\n\nlet blankNodePrefix = 0;\n\n// ## Constructor\nclass N3Parser {\n constructor(options) {\n this._contextStack = [];\n this._graph = null;\n\n // Set the document IRI\n options = options || {};\n this._setBase(options.baseIRI);\n options.factory && initDataFactory(this, options.factory);\n\n // Set supported features depending on the format\n const format = (typeof options.format === 'string') ?\n options.format.match(/\\w*$/)[0].toLowerCase() : '',\n isTurtle = /turtle/.test(format), isTriG = /trig/.test(format),\n isNTriples = /triple/.test(format), isNQuads = /quad/.test(format),\n isN3 = this._n3Mode = /n3/.test(format),\n isLineMode = isNTriples || isNQuads;\n if (!(this._supportsNamedGraphs = !(isTurtle || isN3)))\n this._readPredicateOrNamedGraph = this._readPredicate;\n // Support triples in other graphs\n this._supportsQuads = !(isTurtle || isTriG || isNTriples || isN3);\n // Support nesting of triples\n this._supportsRDFStar = format === '' || /star|\\*$/.test(format);\n // Disable relative IRIs in N-Triples or N-Quads mode\n if (isLineMode)\n this._resolveRelativeIRI = iri => { return null; };\n this._blankNodePrefix = typeof options.blankNodePrefix !== 'string' ? '' :\n options.blankNodePrefix.replace(/^(?!_:)/, '_:');\n this._lexer = options.lexer || new _N3Lexer__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({ lineMode: isLineMode, n3: isN3 });\n // Disable explicit quantifiers by default\n this._explicitQuantifiers = !!options.explicitQuantifiers;\n }\n\n // ## Static class methods\n\n // ### `_resetBlankNodePrefix` restarts blank node prefix identification\n static _resetBlankNodePrefix() {\n blankNodePrefix = 0;\n }\n\n // ## Private methods\n\n // ### `_setBase` sets the base IRI to resolve relative IRIs\n _setBase(baseIRI) {\n if (!baseIRI) {\n this._base = '';\n this._basePath = '';\n }\n else {\n // Remove fragment if present\n const fragmentPos = baseIRI.indexOf('#');\n if (fragmentPos >= 0)\n baseIRI = baseIRI.substr(0, fragmentPos);\n // Set base IRI and its components\n this._base = baseIRI;\n this._basePath = baseIRI.indexOf('/') < 0 ? baseIRI :\n baseIRI.replace(/[^\\/?]*(?:\\?.*)?$/, '');\n baseIRI = baseIRI.match(/^(?:([a-z][a-z0-9+.-]*:))?(?:\\/\\/[^\\/]*)?/i);\n this._baseRoot = baseIRI[0];\n this._baseScheme = baseIRI[1];\n }\n }\n\n // ### `_saveContext` stores the current parsing context\n // when entering a new scope (list, blank node, formula)\n _saveContext(type, graph, subject, predicate, object) {\n const n3Mode = this._n3Mode;\n this._contextStack.push({\n type,\n subject, predicate, object, graph,\n inverse: n3Mode ? this._inversePredicate : false,\n blankPrefix: n3Mode ? this._prefixes._ : '',\n quantified: n3Mode ? this._quantified : null,\n });\n // The settings below only apply to N3 streams\n if (n3Mode) {\n // Every new scope resets the predicate direction\n this._inversePredicate = false;\n // In N3, blank nodes are scoped to a formula\n // (using a dot as separator, as a blank node label cannot start with it)\n this._prefixes._ = (this._graph ? `${this._graph.value}.` : '.');\n // Quantifiers are scoped to a formula\n this._quantified = Object.create(this._quantified);\n }\n }\n\n // ### `_restoreContext` restores the parent context\n // when leaving a scope (list, blank node, formula)\n _restoreContext(type, token) {\n // Obtain the previous context\n const context = this._contextStack.pop();\n if (!context || context.type !== type)\n return this._error(`Unexpected ${token.type}`, token);\n\n // Restore the quad of the previous context\n this._subject = context.subject;\n this._predicate = context.predicate;\n this._object = context.object;\n this._graph = context.graph;\n\n // Restore N3 context settings\n if (this._n3Mode) {\n this._inversePredicate = context.inverse;\n this._prefixes._ = context.blankPrefix;\n this._quantified = context.quantified;\n }\n }\n\n // ### `_readInTopContext` reads a token when in the top context\n _readInTopContext(token) {\n switch (token.type) {\n // If an EOF token arrives in the top context, signal that we're done\n case 'eof':\n if (this._graph !== null)\n return this._error('Unclosed graph', token);\n delete this._prefixes._;\n return this._callback(null, null, this._prefixes);\n // It could be a prefix declaration\n case 'PREFIX':\n this._sparqlStyle = true;\n case '@prefix':\n return this._readPrefix;\n // It could be a base declaration\n case 'BASE':\n this._sparqlStyle = true;\n case '@base':\n return this._readBaseIRI;\n // It could be a graph\n case '{':\n if (this._supportsNamedGraphs) {\n this._graph = '';\n this._subject = null;\n return this._readSubject;\n }\n case 'GRAPH':\n if (this._supportsNamedGraphs)\n return this._readNamedGraphLabel;\n // Otherwise, the next token must be a subject\n default:\n return this._readSubject(token);\n }\n }\n\n // ### `_readEntity` reads an IRI, prefixed name, blank node, or variable\n _readEntity(token, quantifier) {\n let value;\n switch (token.type) {\n // Read a relative or absolute IRI\n case 'IRI':\n case 'typeIRI':\n const iri = this._resolveIRI(token.value);\n if (iri === null)\n return this._error('Invalid IRI', token);\n value = this._namedNode(iri);\n break;\n // Read a prefixed name\n case 'type':\n case 'prefixed':\n const prefix = this._prefixes[token.prefix];\n if (prefix === undefined)\n return this._error(`Undefined prefix \"${token.prefix}:\"`, token);\n value = this._namedNode(prefix + token.value);\n break;\n // Read a blank node\n case 'blank':\n value = this._blankNode(this._prefixes[token.prefix] + token.value);\n break;\n // Read a variable\n case 'var':\n value = this._variable(token.value.substr(1));\n break;\n // Everything else is not an entity\n default:\n return this._error(`Expected entity but got ${token.type}`, token);\n }\n // In N3 mode, replace the entity if it is quantified\n if (!quantifier && this._n3Mode && (value.id in this._quantified))\n value = this._quantified[value.id];\n return value;\n }\n\n // ### `_readSubject` reads a quad's subject\n _readSubject(token) {\n this._predicate = null;\n switch (token.type) {\n case '[':\n // Start a new quad with a new blank node as subject\n this._saveContext('blank', this._graph,\n this._subject = this._blankNode(), null, null);\n return this._readBlankNodeHead;\n case '(':\n // Start a new list\n this._saveContext('list', this._graph, this.RDF_NIL, null, null);\n this._subject = null;\n return this._readListItem;\n case '{':\n // Start a new formula\n if (!this._n3Mode)\n return this._error('Unexpected graph', token);\n this._saveContext('formula', this._graph,\n this._graph = this._blankNode(), null, null);\n return this._readSubject;\n case '}':\n // No subject; the graph in which we are reading is closed instead\n return this._readPunctuation(token);\n case '@forSome':\n if (!this._n3Mode)\n return this._error('Unexpected \"@forSome\"', token);\n this._subject = null;\n this._predicate = this.N3_FORSOME;\n this._quantifier = this._blankNode;\n return this._readQuantifierList;\n case '@forAll':\n if (!this._n3Mode)\n return this._error('Unexpected \"@forAll\"', token);\n this._subject = null;\n this._predicate = this.N3_FORALL;\n this._quantifier = this._variable;\n return this._readQuantifierList;\n case 'literal':\n if (!this._n3Mode)\n return this._error('Unexpected literal', token);\n\n if (token.prefix.length === 0) {\n this._literalValue = token.value;\n return this._completeSubjectLiteral;\n }\n else\n this._subject = this._literal(token.value, this._namedNode(token.prefix));\n\n break;\n case '<<':\n if (!this._supportsRDFStar)\n return this._error('Unexpected RDF* syntax', token);\n this._saveContext('<<', this._graph, null, null, null);\n this._graph = null;\n return this._readSubject;\n default:\n // Read the subject entity\n if ((this._subject = this._readEntity(token)) === undefined)\n return;\n // In N3 mode, the subject might be a path\n if (this._n3Mode)\n return this._getPathReader(this._readPredicateOrNamedGraph);\n }\n\n // The next token must be a predicate,\n // or, if the subject was actually a graph IRI, a named graph\n return this._readPredicateOrNamedGraph;\n }\n\n // ### `_readPredicate` reads a quad's predicate\n _readPredicate(token) {\n const type = token.type;\n switch (type) {\n case 'inverse':\n this._inversePredicate = true;\n case 'abbreviation':\n this._predicate = this.ABBREVIATIONS[token.value];\n break;\n case '.':\n case ']':\n case '}':\n // Expected predicate didn't come, must have been trailing semicolon\n if (this._predicate === null)\n return this._error(`Unexpected ${type}`, token);\n this._subject = null;\n return type === ']' ? this._readBlankNodeTail(token) : this._readPunctuation(token);\n case ';':\n // Additional semicolons can be safely ignored\n return this._predicate !== null ? this._readPredicate :\n this._error('Expected predicate but got ;', token);\n case '[':\n if (this._n3Mode) {\n // Start a new quad with a new blank node as subject\n this._saveContext('blank', this._graph, this._subject,\n this._subject = this._blankNode(), null);\n return this._readBlankNodeHead;\n }\n case 'blank':\n if (!this._n3Mode)\n return this._error('Disallowed blank node as predicate', token);\n default:\n if ((this._predicate = this._readEntity(token)) === undefined)\n return;\n }\n // The next token must be an object\n return this._readObject;\n }\n\n // ### `_readObject` reads a quad's object\n _readObject(token) {\n switch (token.type) {\n case 'literal':\n // Regular literal, can still get a datatype or language\n if (token.prefix.length === 0) {\n this._literalValue = token.value;\n return this._readDataTypeOrLang;\n }\n // Pre-datatyped string literal (prefix stores the datatype)\n else\n this._object = this._literal(token.value, this._namedNode(token.prefix));\n break;\n case '[':\n // Start a new quad with a new blank node as subject\n this._saveContext('blank', this._graph, this._subject, this._predicate,\n this._subject = this._blankNode());\n return this._readBlankNodeHead;\n case '(':\n // Start a new list\n this._saveContext('list', this._graph, this._subject, this._predicate, this.RDF_NIL);\n this._subject = null;\n return this._readListItem;\n case '{':\n // Start a new formula\n if (!this._n3Mode)\n return this._error('Unexpected graph', token);\n this._saveContext('formula', this._graph, this._subject, this._predicate,\n this._graph = this._blankNode());\n return this._readSubject;\n case '<<':\n if (!this._supportsRDFStar)\n return this._error('Unexpected RDF* syntax', token);\n this._saveContext('<<', this._graph, this._subject, this._predicate, null);\n this._graph = null;\n return this._readSubject;\n default:\n // Read the object entity\n if ((this._object = this._readEntity(token)) === undefined)\n return;\n // In N3 mode, the object might be a path\n if (this._n3Mode)\n return this._getPathReader(this._getContextEndReader());\n }\n return this._getContextEndReader();\n }\n\n // ### `_readPredicateOrNamedGraph` reads a quad's predicate, or a named graph\n _readPredicateOrNamedGraph(token) {\n return token.type === '{' ? this._readGraph(token) : this._readPredicate(token);\n }\n\n // ### `_readGraph` reads a graph\n _readGraph(token) {\n if (token.type !== '{')\n return this._error(`Expected graph but got ${token.type}`, token);\n // The \"subject\" we read is actually the GRAPH's label\n this._graph = this._subject, this._subject = null;\n return this._readSubject;\n }\n\n // ### `_readBlankNodeHead` reads the head of a blank node\n _readBlankNodeHead(token) {\n if (token.type === ']') {\n this._subject = null;\n return this._readBlankNodeTail(token);\n }\n else {\n this._predicate = null;\n return this._readPredicate(token);\n }\n }\n\n // ### `_readBlankNodeTail` reads the end of a blank node\n _readBlankNodeTail(token) {\n if (token.type !== ']')\n return this._readBlankNodePunctuation(token);\n\n // Store blank node quad\n if (this._subject !== null)\n this._emit(this._subject, this._predicate, this._object, this._graph);\n\n // Restore the parent context containing this blank node\n const empty = this._predicate === null;\n this._restoreContext('blank', token);\n // If the blank node was the object, restore previous context and read punctuation\n if (this._object !== null)\n return this._getContextEndReader();\n // If the blank node was the predicate, continue reading the object\n else if (this._predicate !== null)\n return this._readObject;\n // If the blank node was the subject, continue reading the predicate\n else\n // If the blank node was empty, it could be a named graph label\n return empty ? this._readPredicateOrNamedGraph : this._readPredicateAfterBlank;\n }\n\n // ### `_readPredicateAfterBlank` reads a predicate after an anonymous blank node\n _readPredicateAfterBlank(token) {\n switch (token.type) {\n case '.':\n case '}':\n // No predicate is coming if the triple is terminated here\n this._subject = null;\n return this._readPunctuation(token);\n default:\n return this._readPredicate(token);\n }\n }\n\n // ### `_readListItem` reads items from a list\n _readListItem(token) {\n let item = null, // The item of the list\n list = null, // The list itself\n next = this._readListItem; // The next function to execute\n const previousList = this._subject, // The previous list that contains this list\n stack = this._contextStack, // The stack of parent contexts\n parent = stack[stack.length - 1]; // The parent containing the current list\n\n switch (token.type) {\n case '[':\n // Stack the current list quad and start a new quad with a blank node as subject\n this._saveContext('blank', this._graph,\n list = this._blankNode(), this.RDF_FIRST,\n this._subject = item = this._blankNode());\n next = this._readBlankNodeHead;\n break;\n case '(':\n // Stack the current list quad and start a new list\n this._saveContext('list', this._graph,\n list = this._blankNode(), this.RDF_FIRST, this.RDF_NIL);\n this._subject = null;\n break;\n case ')':\n // Closing the list; restore the parent context\n this._restoreContext('list', token);\n // If this list is contained within a parent list, return the membership quad here.\n // This will be `<parent list element> rdf:first <this list>.`.\n if (stack.length !== 0 && stack[stack.length - 1].type === 'list')\n this._emit(this._subject, this._predicate, this._object, this._graph);\n // Was this list the parent's subject?\n if (this._predicate === null) {\n // The next token is the predicate\n next = this._readPredicate;\n // No list tail if this was an empty list\n if (this._subject === this.RDF_NIL)\n return next;\n }\n // The list was in the parent context's object\n else {\n next = this._getContextEndReader();\n // No list tail if this was an empty list\n if (this._object === this.RDF_NIL)\n return next;\n }\n // Close the list by making the head nil\n list = this.RDF_NIL;\n break;\n case 'literal':\n // Regular literal, can still get a datatype or language\n if (token.prefix.length === 0) {\n this._literalValue = token.value;\n next = this._readListItemDataTypeOrLang;\n }\n // Pre-datatyped string literal (prefix stores the datatype)\n else {\n item = this._literal(token.value, this._namedNode(token.prefix));\n next = this._getContextEndReader();\n }\n break;\n case '{':\n // Start a new formula\n if (!this._n3Mode)\n return this._error('Unexpected graph', token);\n this._saveContext('formula', this._graph, this._subject, this._predicate,\n this._graph = this._blankNode());\n return this._readSubject;\n default:\n if ((item = this._readEntity(token)) === undefined)\n return;\n }\n\n // Create a new blank node if no item head was assigned yet\n if (list === null)\n this._subject = list = this._blankNode();\n\n // Is this the first element of the list?\n if (previousList === null) {\n // This list is either the subject or the object of its parent\n if (parent.predicate === null)\n parent.subject = list;\n else\n parent.object = list;\n }\n else {\n // Continue the previous list with the current list\n this._emit(previousList, this.RDF_REST, list, this._graph);\n }\n // If an item was read, add it to the list\n if (item !== null) {\n // In N3 mode, the item might be a path\n if (this._n3Mode && (token.type === 'IRI' || token.type === 'prefixed')) {\n // Create a new context to add the item's path\n this._saveContext('item', this._graph, list, this.RDF_FIRST, item);\n this._subject = item, this._predicate = null;\n // _readPath will restore the context and output the item\n return this._getPathReader(this._readListItem);\n }\n // Output the item\n this._emit(list, this.RDF_FIRST, item, this._graph);\n }\n return next;\n }\n\n // ### `_readDataTypeOrLang` reads an _optional_ datatype or language\n _readDataTypeOrLang(token) {\n return this._completeObjectLiteral(token, false);\n }\n\n\n // ### `_readListItemDataTypeOrLang` reads an _optional_ datatype or language in a list\n _readListItemDataTypeOrLang(token) {\n return this._completeObjectLiteral(token, true);\n }\n\n // ### `_completeLiteral` completes a literal with an optional datatype or language\n _completeLiteral(token) {\n // Create a simple string literal by default\n let literal = this._literal(this._literalValue);\n\n switch (token.type) {\n // Create a datatyped literal\n case 'type':\n case 'typeIRI':\n const datatype = this._readEntity(token);\n if (datatype === undefined) return; // No datatype means an error occurred\n literal = this._literal(this._literalValue, datatype);\n token = null;\n break;\n // Create a language-tagged string\n case 'langcode':\n literal = this._literal(this._literalValue, token.value);\n token = null;\n break;\n }\n\n return { token, literal };\n }\n\n // Completes a literal in subject position\n _completeSubjectLiteral(token) {\n this._subject = this._completeLiteral(token).literal;\n return this._readPredicateOrNamedGraph;\n }\n\n // Completes a literal in object position\n _completeObjectLiteral(token, listItem) {\n const completed = this._completeLiteral(token);\n if (!completed)\n return;\n this._object = completed.literal;\n\n // If this literal was part of a list, write the item\n // (we could also check the context stack, but passing in a flag is faster)\n if (listItem)\n this._emit(this._subject, this.RDF_FIRST, this._object, this._graph);\n // If the token was consumed, continue with the rest of the input\n if (completed.token === null)\n return this._getContextEndReader();\n // Otherwise, consume the token now\n else {\n this._readCallback = this._getContextEndReader();\n return this._readCallback(completed.token);\n }\n }\n\n // ### `_readFormulaTail` reads the end of a formula\n _readFormulaTail(token) {\n if (token.type !== '}')\n return this._readPunctuation(token);\n\n // Store the last quad of the formula\n if (this._subject !== null)\n this._emit(this._subject, this._predicate, this._object, this._graph);\n\n // Restore the parent context containing this formula\n this._restoreContext('formula', token);\n // If the formula was the subject, continue reading the predicate.\n // If the formula was the object, read punctuation.\n return this._object === null ? this._readPredicate : this._getContextEndReader();\n }\n\n // ### `_readPunctuation` reads punctuation between quads or quad parts\n _readPunctuation(token) {\n let next, graph = this._graph;\n const subject = this._subject, inversePredicate = this._inversePredicate;\n switch (token.type) {\n // A closing brace ends a graph\n case '}':\n if (this._graph === null)\n return this._error('Unexpected graph closing', token);\n if (this._n3Mode)\n return this._readFormulaTail(token);\n this._graph = null;\n // A dot just ends the statement, without sharing anything with the next\n case '.':\n this._subject = null;\n next = this._contextStack.length ? this._readSubject : this._readInTopContext;\n if (inversePredicate) this._inversePredicate = false;\n break;\n // Semicolon means the subject is shared; predicate and object are different\n case ';':\n next = this._readPredicate;\n break;\n // Comma means both the subject and predicate are shared; the object is different\n case ',':\n next = this._readObject;\n break;\n // {| means that the current triple is annotated with predicate-object pairs.\n case '{|':\n if (!this._supportsRDFStar)\n return this._error('Unexpected RDF* syntax', token);\n // Continue using the last triple as quoted triple subject for the predicate-object pairs.\n const predicate = this._predicate, object = this._object;\n this._subject = this._quad(subject, predicate, object, this.DEFAULTGRAPH);\n next = this._readPredicate;\n break;\n // |} means that the current quoted triple in annotation syntax is finalized.\n case '|}':\n if (this._subject.termType !== 'Quad')\n return this._error('Unexpected asserted triple closing', token);\n this._subject = null;\n next = this._readPunctuation;\n break;\n default:\n // An entity means this is a quad (only allowed if not already inside a graph)\n if (this._supportsQuads && this._graph === null && (graph = this._readEntity(token)) !== undefined) {\n next = this._readQuadPunctuation;\n break;\n }\n return this._error(`Expected punctuation to follow \"${this._object.id}\"`, token);\n }\n // A quad has been completed now, so return it\n if (subject !== null) {\n const predicate = this._predicate, object = this._object;\n if (!inversePredicate)\n this._emit(subject, predicate, object, graph);\n else\n this._emit(object, predicate, subject, graph);\n }\n return next;\n }\n\n // ### `_readBlankNodePunctuation` reads punctuation in a blank node\n _readBlankNodePunctuation(token) {\n let next;\n switch (token.type) {\n // Semicolon means the subject is shared; predicate and object are different\n case ';':\n next = this._readPredicate;\n break;\n // Comma means both the subject and predicate are shared; the object is different\n case ',':\n next = this._readObject;\n break;\n default:\n return this._error(`Expected punctuation to follow \"${this._object.id}\"`, token);\n }\n // A quad has been completed now, so return it\n this._emit(this._subject, this._predicate, this._object, this._graph);\n return next;\n }\n\n // ### `_readQuadPunctuation` reads punctuation after a quad\n _readQuadPunctuation(token) {\n if (token.type !== '.')\n return this._error('Expected dot to follow quad', token);\n return this._readInTopContext;\n }\n\n // ### `_readPrefix` reads the prefix of a prefix declaration\n _readPrefix(token) {\n if (token.type !== 'prefix')\n return this._error('Expected prefix to follow @prefix', token);\n this._prefix = token.value;\n return this._readPrefixIRI;\n }\n\n // ### `_readPrefixIRI` reads the IRI of a prefix declaration\n _readPrefixIRI(token) {\n if (token.type !== 'IRI')\n return this._error(`Expected IRI to follow prefix \"${this._prefix}:\"`, token);\n const prefixNode = this._readEntity(token);\n this._prefixes[this._prefix] = prefixNode.value;\n this._prefixCallback(this._prefix, prefixNode);\n return this._readDeclarationPunctuation;\n }\n\n // ### `_readBaseIRI` reads the IRI of a base declaration\n _readBaseIRI(token) {\n const iri = token.type === 'IRI' && this._resolveIRI(token.value);\n if (!iri)\n return this._error('Expected valid IRI to follow base declaration', token);\n this._setBase(iri);\n return this._readDeclarationPunctuation;\n }\n\n // ### `_readNamedGraphLabel` reads the label of a named graph\n _readNamedGraphLabel(token) {\n switch (token.type) {\n case 'IRI':\n case 'blank':\n case 'prefixed':\n return this._readSubject(token), this._readGraph;\n case '[':\n return this._readNamedGraphBlankLabel;\n default:\n return this._error('Invalid graph label', token);\n }\n }\n\n // ### `_readNamedGraphLabel` reads a blank node label of a named graph\n _readNamedGraphBlankLabel(token) {\n if (token.type !== ']')\n return this._error('Invalid graph label', token);\n this._subject = this._blankNode();\n return this._readGraph;\n }\n\n // ### `_readDeclarationPunctuation` reads the punctuation of a declaration\n _readDeclarationPunctuation(token) {\n // SPARQL-style declarations don't have punctuation\n if (this._sparqlStyle) {\n this._sparqlStyle = false;\n return this._readInTopContext(token);\n }\n\n if (token.type !== '.')\n return this._error('Expected declaration to end with a dot', token);\n return this._readInTopContext;\n }\n\n // Reads a list of quantified symbols from a @forSome or @forAll statement\n _readQuantifierList(token) {\n let entity;\n switch (token.type) {\n case 'IRI':\n case 'prefixed':\n if ((entity = this._readEntity(token, true)) !== undefined)\n break;\n default:\n return this._error(`Unexpected ${token.type}`, token);\n }\n // Without explicit quantifiers, map entities to a quantified entity\n if (!this._explicitQuantifiers)\n this._quantified[entity.id] = this._quantifier(this._blankNode().value);\n // With explicit quantifiers, output the reified quantifier\n else {\n // If this is the first item, start a new quantifier list\n if (this._subject === null)\n this._emit(this._graph || this.DEFAULTGRAPH, this._predicate,\n this._subject = this._blankNode(), this.QUANTIFIERS_GRAPH);\n // Otherwise, continue the previous list\n else\n this._emit(this._subject, this.RDF_REST,\n this._subject = this._blankNode(), this.QUANTIFIERS_GRAPH);\n // Output the list item\n this._emit(this._subject, this.RDF_FIRST, entity, this.QUANTIFIERS_GRAPH);\n }\n return this._readQuantifierPunctuation;\n }\n\n // Reads punctuation from a @forSome or @forAll statement\n _readQuantifierPunctuation(token) {\n // Read more quantifiers\n if (token.type === ',')\n return this._readQuantifierList;\n // End of the quantifier list\n else {\n // With explicit quantifiers, close the quantifier list\n if (this._explicitQuantifiers) {\n this._emit(this._subject, this.RDF_REST, this.RDF_NIL, this.QUANTIFIERS_GRAPH);\n this._subject = null;\n }\n // Read a dot\n this._readCallback = this._getContextEndReader();\n return this._readCallback(token);\n }\n }\n\n // ### `_getPathReader` reads a potential path and then resumes with the given function\n _getPathReader(afterPath) {\n this._afterPath = afterPath;\n return this._readPath;\n }\n\n // ### `_readPath` reads a potential path\n _readPath(token) {\n switch (token.type) {\n // Forward path\n case '!': return this._readForwardPath;\n // Backward path\n case '^': return this._readBackwardPath;\n // Not a path; resume reading where we left off\n default:\n const stack = this._contextStack, parent = stack.length && stack[stack.length - 1];\n // If we were reading a list item, we still need to output it\n if (parent && parent.type === 'item') {\n // The list item is the remaining subejct after reading the path\n const item = this._subject;\n // Switch back to the context of the list\n this._restoreContext('item', token);\n // Output the list item\n this._emit(this._subject, this.RDF_FIRST, item, this._graph);\n }\n return this._afterPath(token);\n }\n }\n\n // ### `_readForwardPath` reads a '!' path\n _readForwardPath(token) {\n let subject, predicate;\n const object = this._blankNode();\n // The next token is the predicate\n if ((predicate = this._readEntity(token)) === undefined)\n return;\n // If we were reading a subject, replace the subject by the path's object\n if (this._predicate === null)\n subject = this._subject, this._subject = object;\n // If we were reading an object, replace the subject by the path's object\n else\n subject = this._object, this._object = object;\n // Emit the path's current quad and read its next section\n this._emit(subject, predicate, object, this._graph);\n return this._readPath;\n }\n\n // ### `_readBackwardPath` reads a '^' path\n _readBackwardPath(token) {\n const subject = this._blankNode();\n let predicate, object;\n // The next token is the predicate\n if ((predicate = this._readEntity(token)) === undefined)\n return;\n // If we were reading a subject, replace the subject by the path's subject\n if (this._predicate === null)\n object = this._subject, this._subject = subject;\n // If we were reading an object, replace the subject by the path's subject\n else\n object = this._object, this._object = subject;\n // Emit the path's current quad and read its next section\n this._emit(subject, predicate, object, this._graph);\n return this._readPath;\n }\n\n // ### `_readRDFStarTailOrGraph` reads the graph of a nested RDF* quad or the end of a nested RDF* triple\n _readRDFStarTailOrGraph(token) {\n if (token.type !== '>>') {\n // An entity means this is a quad (only allowed if not already inside a graph)\n if (this._supportsQuads && this._graph === null && (this._graph = this._readEntity(token)) !== undefined)\n return this._readRDFStarTail;\n return this._error(`Expected >> to follow \"${this._object.id}\"`, token);\n }\n return this._readRDFStarTail(token);\n }\n\n // ### `_readRDFStarTail` reads the end of a nested RDF* triple\n _readRDFStarTail(token) {\n if (token.type !== '>>')\n return this._error(`Expected >> but got ${token.type}`, token);\n // Read the quad and restore the previous context\n const quad = this._quad(this._subject, this._predicate, this._object,\n this._graph || this.DEFAULTGRAPH);\n this._restoreContext('<<', token);\n // If the triple was the subject, continue by reading the predicate.\n if (this._subject === null) {\n this._subject = quad;\n return this._readPredicate;\n }\n // If the triple was the object, read context end.\n else {\n this._object = quad;\n return this._getContextEndReader();\n }\n }\n\n // ### `_getContextEndReader` gets the next reader function at the end of a context\n _getContextEndReader() {\n const contextStack = this._contextStack;\n if (!contextStack.length)\n return this._readPunctuation;\n\n switch (contextStack[contextStack.length - 1].type) {\n case 'blank':\n return this._readBlankNodeTail;\n case 'list':\n return this._readListItem;\n case 'formula':\n return this._readFormulaTail;\n case '<<':\n return this._readRDFStarTailOrGraph;\n }\n }\n\n // ### `_emit` sends a quad through the callback\n _emit(subject, predicate, object, graph) {\n this._callback(null, this._quad(subject, predicate, object, graph || this.DEFAULTGRAPH));\n }\n\n // ### `_error` emits an error message through the callback\n _error(message, token) {\n const err = new Error(`${message} on line ${token.line}.`);\n err.context = {\n token: token,\n line: token.line,\n previousToken: this._lexer.previousToken,\n };\n this._callback(err);\n this._callback = noop;\n }\n\n // ### `_resolveIRI` resolves an IRI against the base path\n _resolveIRI(iri) {\n return /^[a-z][a-z0-9+.-]*:/i.test(iri) ? iri : this._resolveRelativeIRI(iri);\n }\n\n // ### `_resolveRelativeIRI` resolves an IRI against the base path,\n // assuming that a base path has been set and that the IRI is indeed relative\n _resolveRelativeIRI(iri) {\n // An empty relative IRI indicates the base IRI\n if (!iri.length)\n return this._base;\n // Decide resolving strategy based in the first character\n switch (iri[0]) {\n // Resolve relative fragment IRIs against the base IRI\n case '#': return this._base + iri;\n // Resolve relative query string IRIs by replacing the query string\n case '?': return this._base.replace(/(?:\\?.*)?$/, iri);\n // Resolve root-relative IRIs at the root of the base IRI\n case '/':\n // Resolve scheme-relative IRIs to the scheme\n return (iri[1] === '/' ? this._baseScheme : this._baseRoot) + this._removeDotSegments(iri);\n // Resolve all other IRIs at the base IRI's path\n default:\n // Relative IRIs cannot contain a colon in the first path segment\n return (/^[^/:]*:/.test(iri)) ? null : this._removeDotSegments(this._basePath + iri);\n }\n }\n\n // ### `_removeDotSegments` resolves './' and '../' path segments in an IRI as per RFC3986\n _removeDotSegments(iri) {\n // Don't modify the IRI if it does not contain any dot segments\n if (!/(^|\\/)\\.\\.?($|[/#?])/.test(iri))\n return iri;\n\n // Start with an imaginary slash before the IRI in order to resolve trailing './' and '../'\n const length = iri.length;\n let result = '', i = -1, pathStart = -1, segmentStart = 0, next = '/';\n\n while (i < length) {\n switch (next) {\n // The path starts with the first slash after the authority\n case ':':\n if (pathStart < 0) {\n // Skip two slashes before the authority\n if (iri[++i] === '/' && iri[++i] === '/')\n // Skip to slash after the authority\n while ((pathStart = i + 1) < length && iri[pathStart] !== '/')\n i = pathStart;\n }\n break;\n // Don't modify a query string or fragment\n case '?':\n case '#':\n i = length;\n break;\n // Handle '/.' or '/..' path segments\n case '/':\n if (iri[i + 1] === '.') {\n next = iri[++i + 1];\n switch (next) {\n // Remove a '/.' segment\n case '/':\n result += iri.substring(segmentStart, i - 1);\n segmentStart = i + 1;\n break;\n // Remove a trailing '/.' segment\n case undefined:\n case '?':\n case '#':\n return result + iri.substring(segmentStart, i) + iri.substr(i + 1);\n // Remove a '/..' segment\n case '.':\n next = iri[++i + 1];\n if (next === undefined || next === '/' || next === '?' || next === '#') {\n result += iri.substring(segmentStart, i - 2);\n // Try to remove the parent path from result\n if ((segmentStart = result.lastIndexOf('/')) >= pathStart)\n result = result.substr(0, segmentStart);\n // Remove a trailing '/..' segment\n if (next !== '/')\n return `${result}/${iri.substr(i + 1)}`;\n segmentStart = i + 1;\n }\n }\n }\n }\n next = iri[++i];\n }\n return result + iri.substring(segmentStart);\n }\n\n // ## Public methods\n\n // ### `parse` parses the N3 input and emits each parsed quad through the callback\n parse(input, quadCallback, prefixCallback) {\n // The read callback is the next function to be executed when a token arrives.\n // We start reading in the top context.\n this._readCallback = this._readInTopContext;\n this._sparqlStyle = false;\n this._prefixes = Object.create(null);\n this._prefixes._ = this._blankNodePrefix ? this._blankNodePrefix.substr(2)\n : `b${blankNodePrefix++}_`;\n this._prefixCallback = prefixCallback || noop;\n this._inversePredicate = false;\n this._quantified = Object.create(null);\n\n // Parse synchronously if no quad callback is given\n if (!quadCallback) {\n const quads = [];\n let error;\n this._callback = (e, t) => { e ? (error = e) : t && quads.push(t); };\n this._lexer.tokenize(input).every(token => {\n return this._readCallback = this._readCallback(token);\n });\n if (error) throw error;\n return quads;\n }\n\n // Parse asynchronously otherwise, executing the read callback when a token arrives\n this._callback = quadCallback;\n this._lexer.tokenize(input, (error, token) => {\n if (error !== null)\n this._callback(error), this._callback = noop;\n else if (this._readCallback)\n this._readCallback = this._readCallback(token);\n });\n }\n}\n\n// The empty function\nfunction noop() {}\n\n// Initializes the parser with the given data factory\nfunction initDataFactory(parser, factory) {\n // Set factory methods\n const namedNode = factory.namedNode;\n parser._namedNode = namedNode;\n parser._blankNode = factory.blankNode;\n parser._literal = factory.literal;\n parser._variable = factory.variable;\n parser._quad = factory.quad;\n parser.DEFAULTGRAPH = factory.defaultGraph();\n\n // Set common named nodes\n parser.RDF_FIRST = namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].rdf.first);\n parser.RDF_REST = namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].rdf.rest);\n parser.RDF_NIL = namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].rdf.nil);\n parser.N3_FORALL = namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].r.forAll);\n parser.N3_FORSOME = namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].r.forSome);\n parser.ABBREVIATIONS = {\n 'a': namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].rdf.type),\n '=': namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].owl.sameAs),\n '>': namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].log.implies),\n };\n parser.QUANTIFIERS_GRAPH = namedNode('urn:n3:quantifiers');\n}\ninitDataFactory(N3Parser.prototype, _N3DataFactory__WEBPACK_IMPORTED_MODULE_2__[\"default\"]);\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/N3Parser.js?");
116
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ N3Parser)\n/* harmony export */ });\n/* harmony import */ var _N3Lexer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./N3Lexer */ \"./node_modules/n3/src/N3Lexer.js\");\n/* harmony import */ var _N3DataFactory__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./N3DataFactory */ \"./node_modules/n3/src/N3DataFactory.js\");\n/* harmony import */ var _IRIs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./IRIs */ \"./node_modules/n3/src/IRIs.js\");\n// **N3Parser** parses N3 documents.\n\n\n\n\nlet blankNodePrefix = 0;\n\n// ## Constructor\nclass N3Parser {\n constructor(options) {\n this._contextStack = [];\n this._graph = null;\n\n // Set the document IRI\n options = options || {};\n this._setBase(options.baseIRI);\n options.factory && initDataFactory(this, options.factory);\n\n // Set supported features depending on the format\n const format = (typeof options.format === 'string') ?\n options.format.match(/\\w*$/)[0].toLowerCase() : '',\n isTurtle = /turtle/.test(format), isTriG = /trig/.test(format),\n isNTriples = /triple/.test(format), isNQuads = /quad/.test(format),\n isN3 = this._n3Mode = /n3/.test(format),\n isLineMode = isNTriples || isNQuads;\n if (!(this._supportsNamedGraphs = !(isTurtle || isN3)))\n this._readPredicateOrNamedGraph = this._readPredicate;\n // Support triples in other graphs\n this._supportsQuads = !(isTurtle || isTriG || isNTriples || isN3);\n // Whether the log:isImpliedBy predicate is supported\n this._isImpliedBy = options.isImpliedBy;\n // Support nesting of triples\n this._supportsRDFStar = format === '' || /star|\\*$/.test(format);\n // Disable relative IRIs in N-Triples or N-Quads mode\n if (isLineMode)\n this._resolveRelativeIRI = iri => { return null; };\n this._blankNodePrefix = typeof options.blankNodePrefix !== 'string' ? '' :\n options.blankNodePrefix.replace(/^(?!_:)/, '_:');\n this._lexer = options.lexer || new _N3Lexer__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({ lineMode: isLineMode, n3: isN3, isImpliedBy: this._isImpliedBy });\n // Disable explicit quantifiers by default\n this._explicitQuantifiers = !!options.explicitQuantifiers;\n }\n\n // ## Static class methods\n\n // ### `_resetBlankNodePrefix` restarts blank node prefix identification\n static _resetBlankNodePrefix() {\n blankNodePrefix = 0;\n }\n\n // ## Private methods\n\n // ### `_setBase` sets the base IRI to resolve relative IRIs\n _setBase(baseIRI) {\n if (!baseIRI) {\n this._base = '';\n this._basePath = '';\n }\n else {\n // Remove fragment if present\n const fragmentPos = baseIRI.indexOf('#');\n if (fragmentPos >= 0)\n baseIRI = baseIRI.substr(0, fragmentPos);\n // Set base IRI and its components\n this._base = baseIRI;\n this._basePath = baseIRI.indexOf('/') < 0 ? baseIRI :\n baseIRI.replace(/[^\\/?]*(?:\\?.*)?$/, '');\n baseIRI = baseIRI.match(/^(?:([a-z][a-z0-9+.-]*:))?(?:\\/\\/[^\\/]*)?/i);\n this._baseRoot = baseIRI[0];\n this._baseScheme = baseIRI[1];\n }\n }\n\n // ### `_saveContext` stores the current parsing context\n // when entering a new scope (list, blank node, formula)\n _saveContext(type, graph, subject, predicate, object) {\n const n3Mode = this._n3Mode;\n this._contextStack.push({\n type,\n subject, predicate, object, graph,\n inverse: n3Mode ? this._inversePredicate : false,\n blankPrefix: n3Mode ? this._prefixes._ : '',\n quantified: n3Mode ? this._quantified : null,\n });\n // The settings below only apply to N3 streams\n if (n3Mode) {\n // Every new scope resets the predicate direction\n this._inversePredicate = false;\n // In N3, blank nodes are scoped to a formula\n // (using a dot as separator, as a blank node label cannot start with it)\n this._prefixes._ = (this._graph ? `${this._graph.value}.` : '.');\n // Quantifiers are scoped to a formula\n this._quantified = Object.create(this._quantified);\n }\n }\n\n // ### `_restoreContext` restores the parent context\n // when leaving a scope (list, blank node, formula)\n _restoreContext(type, token) {\n // Obtain the previous context\n const context = this._contextStack.pop();\n if (!context || context.type !== type)\n return this._error(`Unexpected ${token.type}`, token);\n\n // Restore the quad of the previous context\n this._subject = context.subject;\n this._predicate = context.predicate;\n this._object = context.object;\n this._graph = context.graph;\n\n // Restore N3 context settings\n if (this._n3Mode) {\n this._inversePredicate = context.inverse;\n this._prefixes._ = context.blankPrefix;\n this._quantified = context.quantified;\n }\n }\n\n // ### `_readInTopContext` reads a token when in the top context\n _readInTopContext(token) {\n switch (token.type) {\n // If an EOF token arrives in the top context, signal that we're done\n case 'eof':\n if (this._graph !== null)\n return this._error('Unclosed graph', token);\n delete this._prefixes._;\n return this._callback(null, null, this._prefixes);\n // It could be a prefix declaration\n case 'PREFIX':\n this._sparqlStyle = true;\n case '@prefix':\n return this._readPrefix;\n // It could be a base declaration\n case 'BASE':\n this._sparqlStyle = true;\n case '@base':\n return this._readBaseIRI;\n // It could be a graph\n case '{':\n if (this._supportsNamedGraphs) {\n this._graph = '';\n this._subject = null;\n return this._readSubject;\n }\n case 'GRAPH':\n if (this._supportsNamedGraphs)\n return this._readNamedGraphLabel;\n // Otherwise, the next token must be a subject\n default:\n return this._readSubject(token);\n }\n }\n\n // ### `_readEntity` reads an IRI, prefixed name, blank node, or variable\n _readEntity(token, quantifier) {\n let value;\n switch (token.type) {\n // Read a relative or absolute IRI\n case 'IRI':\n case 'typeIRI':\n const iri = this._resolveIRI(token.value);\n if (iri === null)\n return this._error('Invalid IRI', token);\n value = this._factory.namedNode(iri);\n break;\n // Read a prefixed name\n case 'type':\n case 'prefixed':\n const prefix = this._prefixes[token.prefix];\n if (prefix === undefined)\n return this._error(`Undefined prefix \"${token.prefix}:\"`, token);\n value = this._factory.namedNode(prefix + token.value);\n break;\n // Read a blank node\n case 'blank':\n value = this._factory.blankNode(this._prefixes[token.prefix] + token.value);\n break;\n // Read a variable\n case 'var':\n value = this._factory.variable(token.value.substr(1));\n break;\n // Everything else is not an entity\n default:\n return this._error(`Expected entity but got ${token.type}`, token);\n }\n // In N3 mode, replace the entity if it is quantified\n if (!quantifier && this._n3Mode && (value.id in this._quantified))\n value = this._quantified[value.id];\n return value;\n }\n\n // ### `_readSubject` reads a quad's subject\n _readSubject(token) {\n this._predicate = null;\n switch (token.type) {\n case '[':\n // Start a new quad with a new blank node as subject\n this._saveContext('blank', this._graph,\n this._subject = this._factory.blankNode(), null, null);\n return this._readBlankNodeHead;\n case '(':\n // Start a new list\n this._saveContext('list', this._graph, this.RDF_NIL, null, null);\n this._subject = null;\n return this._readListItem;\n case '{':\n // Start a new formula\n if (!this._n3Mode)\n return this._error('Unexpected graph', token);\n this._saveContext('formula', this._graph,\n this._graph = this._factory.blankNode(), null, null);\n return this._readSubject;\n case '}':\n // No subject; the graph in which we are reading is closed instead\n return this._readPunctuation(token);\n case '@forSome':\n if (!this._n3Mode)\n return this._error('Unexpected \"@forSome\"', token);\n this._subject = null;\n this._predicate = this.N3_FORSOME;\n this._quantifier = 'blankNode';\n return this._readQuantifierList;\n case '@forAll':\n if (!this._n3Mode)\n return this._error('Unexpected \"@forAll\"', token);\n this._subject = null;\n this._predicate = this.N3_FORALL;\n this._quantifier = 'variable';\n return this._readQuantifierList;\n case 'literal':\n if (!this._n3Mode)\n return this._error('Unexpected literal', token);\n\n if (token.prefix.length === 0) {\n this._literalValue = token.value;\n return this._completeSubjectLiteral;\n }\n else\n this._subject = this._factory.literal(token.value, this._factory.namedNode(token.prefix));\n\n break;\n case '<<':\n if (!this._supportsRDFStar)\n return this._error('Unexpected RDF-star syntax', token);\n this._saveContext('<<', this._graph, null, null, null);\n this._graph = null;\n return this._readSubject;\n default:\n // Read the subject entity\n if ((this._subject = this._readEntity(token)) === undefined)\n return;\n // In N3 mode, the subject might be a path\n if (this._n3Mode)\n return this._getPathReader(this._readPredicateOrNamedGraph);\n }\n\n // The next token must be a predicate,\n // or, if the subject was actually a graph IRI, a named graph\n return this._readPredicateOrNamedGraph;\n }\n\n // ### `_readPredicate` reads a quad's predicate\n _readPredicate(token) {\n const type = token.type;\n switch (type) {\n case 'inverse':\n this._inversePredicate = true;\n case 'abbreviation':\n this._predicate = this.ABBREVIATIONS[token.value];\n break;\n case '.':\n case ']':\n case '}':\n // Expected predicate didn't come, must have been trailing semicolon\n if (this._predicate === null)\n return this._error(`Unexpected ${type}`, token);\n this._subject = null;\n return type === ']' ? this._readBlankNodeTail(token) : this._readPunctuation(token);\n case ';':\n // Additional semicolons can be safely ignored\n return this._predicate !== null ? this._readPredicate :\n this._error('Expected predicate but got ;', token);\n case '[':\n if (this._n3Mode) {\n // Start a new quad with a new blank node as subject\n this._saveContext('blank', this._graph, this._subject,\n this._subject = this._factory.blankNode(), null);\n return this._readBlankNodeHead;\n }\n case 'blank':\n if (!this._n3Mode)\n return this._error('Disallowed blank node as predicate', token);\n default:\n if ((this._predicate = this._readEntity(token)) === undefined)\n return;\n }\n // The next token must be an object\n return this._readObject;\n }\n\n // ### `_readObject` reads a quad's object\n _readObject(token) {\n switch (token.type) {\n case 'literal':\n // Regular literal, can still get a datatype or language\n if (token.prefix.length === 0) {\n this._literalValue = token.value;\n return this._readDataTypeOrLang;\n }\n // Pre-datatyped string literal (prefix stores the datatype)\n else\n this._object = this._factory.literal(token.value, this._factory.namedNode(token.prefix));\n break;\n case '[':\n // Start a new quad with a new blank node as subject\n this._saveContext('blank', this._graph, this._subject, this._predicate,\n this._subject = this._factory.blankNode());\n return this._readBlankNodeHead;\n case '(':\n // Start a new list\n this._saveContext('list', this._graph, this._subject, this._predicate, this.RDF_NIL);\n this._subject = null;\n return this._readListItem;\n case '{':\n // Start a new formula\n if (!this._n3Mode)\n return this._error('Unexpected graph', token);\n this._saveContext('formula', this._graph, this._subject, this._predicate,\n this._graph = this._factory.blankNode());\n return this._readSubject;\n case '<<':\n if (!this._supportsRDFStar)\n return this._error('Unexpected RDF-star syntax', token);\n this._saveContext('<<', this._graph, this._subject, this._predicate, null);\n this._graph = null;\n return this._readSubject;\n default:\n // Read the object entity\n if ((this._object = this._readEntity(token)) === undefined)\n return;\n // In N3 mode, the object might be a path\n if (this._n3Mode)\n return this._getPathReader(this._getContextEndReader());\n }\n return this._getContextEndReader();\n }\n\n // ### `_readPredicateOrNamedGraph` reads a quad's predicate, or a named graph\n _readPredicateOrNamedGraph(token) {\n return token.type === '{' ? this._readGraph(token) : this._readPredicate(token);\n }\n\n // ### `_readGraph` reads a graph\n _readGraph(token) {\n if (token.type !== '{')\n return this._error(`Expected graph but got ${token.type}`, token);\n // The \"subject\" we read is actually the GRAPH's label\n this._graph = this._subject, this._subject = null;\n return this._readSubject;\n }\n\n // ### `_readBlankNodeHead` reads the head of a blank node\n _readBlankNodeHead(token) {\n if (token.type === ']') {\n this._subject = null;\n return this._readBlankNodeTail(token);\n }\n else {\n this._predicate = null;\n return this._readPredicate(token);\n }\n }\n\n // ### `_readBlankNodeTail` reads the end of a blank node\n _readBlankNodeTail(token) {\n if (token.type !== ']')\n return this._readBlankNodePunctuation(token);\n\n // Store blank node quad\n if (this._subject !== null)\n this._emit(this._subject, this._predicate, this._object, this._graph);\n\n // Restore the parent context containing this blank node\n const empty = this._predicate === null;\n this._restoreContext('blank', token);\n // If the blank node was the object, restore previous context and read punctuation\n if (this._object !== null)\n return this._getContextEndReader();\n // If the blank node was the predicate, continue reading the object\n else if (this._predicate !== null)\n return this._readObject;\n // If the blank node was the subject, continue reading the predicate\n else\n // If the blank node was empty, it could be a named graph label\n return empty ? this._readPredicateOrNamedGraph : this._readPredicateAfterBlank;\n }\n\n // ### `_readPredicateAfterBlank` reads a predicate after an anonymous blank node\n _readPredicateAfterBlank(token) {\n switch (token.type) {\n case '.':\n case '}':\n // No predicate is coming if the triple is terminated here\n this._subject = null;\n return this._readPunctuation(token);\n default:\n return this._readPredicate(token);\n }\n }\n\n // ### `_readListItem` reads items from a list\n _readListItem(token) {\n let item = null, // The item of the list\n list = null, // The list itself\n next = this._readListItem; // The next function to execute\n const previousList = this._subject, // The previous list that contains this list\n stack = this._contextStack, // The stack of parent contexts\n parent = stack[stack.length - 1]; // The parent containing the current list\n\n switch (token.type) {\n case '[':\n // Stack the current list quad and start a new quad with a blank node as subject\n this._saveContext('blank', this._graph,\n list = this._factory.blankNode(), this.RDF_FIRST,\n this._subject = item = this._factory.blankNode());\n next = this._readBlankNodeHead;\n break;\n case '(':\n // Stack the current list quad and start a new list\n this._saveContext('list', this._graph,\n list = this._factory.blankNode(), this.RDF_FIRST, this.RDF_NIL);\n this._subject = null;\n break;\n case ')':\n // Closing the list; restore the parent context\n this._restoreContext('list', token);\n // If this list is contained within a parent list, return the membership quad here.\n // This will be `<parent list element> rdf:first <this list>.`.\n if (stack.length !== 0 && stack[stack.length - 1].type === 'list')\n this._emit(this._subject, this._predicate, this._object, this._graph);\n // Was this list the parent's subject?\n if (this._predicate === null) {\n // The next token is the predicate\n next = this._readPredicate;\n // No list tail if this was an empty list\n if (this._subject === this.RDF_NIL)\n return next;\n }\n // The list was in the parent context's object\n else {\n next = this._getContextEndReader();\n // No list tail if this was an empty list\n if (this._object === this.RDF_NIL)\n return next;\n }\n // Close the list by making the head nil\n list = this.RDF_NIL;\n break;\n case 'literal':\n // Regular literal, can still get a datatype or language\n if (token.prefix.length === 0) {\n this._literalValue = token.value;\n next = this._readListItemDataTypeOrLang;\n }\n // Pre-datatyped string literal (prefix stores the datatype)\n else {\n item = this._factory.literal(token.value, this._factory.namedNode(token.prefix));\n next = this._getContextEndReader();\n }\n break;\n case '{':\n // Start a new formula\n if (!this._n3Mode)\n return this._error('Unexpected graph', token);\n this._saveContext('formula', this._graph, this._subject, this._predicate,\n this._graph = this._factory.blankNode());\n return this._readSubject;\n default:\n if ((item = this._readEntity(token)) === undefined)\n return;\n }\n\n // Create a new blank node if no item head was assigned yet\n if (list === null)\n this._subject = list = this._factory.blankNode();\n\n // Is this the first element of the list?\n if (previousList === null) {\n // This list is either the subject or the object of its parent\n if (parent.predicate === null)\n parent.subject = list;\n else\n parent.object = list;\n }\n else {\n // Continue the previous list with the current list\n this._emit(previousList, this.RDF_REST, list, this._graph);\n }\n // If an item was read, add it to the list\n if (item !== null) {\n // In N3 mode, the item might be a path\n if (this._n3Mode && (token.type === 'IRI' || token.type === 'prefixed')) {\n // Create a new context to add the item's path\n this._saveContext('item', this._graph, list, this.RDF_FIRST, item);\n this._subject = item, this._predicate = null;\n // _readPath will restore the context and output the item\n return this._getPathReader(this._readListItem);\n }\n // Output the item\n this._emit(list, this.RDF_FIRST, item, this._graph);\n }\n return next;\n }\n\n // ### `_readDataTypeOrLang` reads an _optional_ datatype or language\n _readDataTypeOrLang(token) {\n return this._completeObjectLiteral(token, false);\n }\n\n\n // ### `_readListItemDataTypeOrLang` reads an _optional_ datatype or language in a list\n _readListItemDataTypeOrLang(token) {\n return this._completeObjectLiteral(token, true);\n }\n\n // ### `_completeLiteral` completes a literal with an optional datatype or language\n _completeLiteral(token) {\n // Create a simple string literal by default\n let literal = this._factory.literal(this._literalValue);\n\n switch (token.type) {\n // Create a datatyped literal\n case 'type':\n case 'typeIRI':\n const datatype = this._readEntity(token);\n if (datatype === undefined) return; // No datatype means an error occurred\n literal = this._factory.literal(this._literalValue, datatype);\n token = null;\n break;\n // Create a language-tagged string\n case 'langcode':\n literal = this._factory.literal(this._literalValue, token.value);\n token = null;\n break;\n }\n\n return { token, literal };\n }\n\n // Completes a literal in subject position\n _completeSubjectLiteral(token) {\n this._subject = this._completeLiteral(token).literal;\n return this._readPredicateOrNamedGraph;\n }\n\n // Completes a literal in object position\n _completeObjectLiteral(token, listItem) {\n const completed = this._completeLiteral(token);\n if (!completed)\n return;\n this._object = completed.literal;\n\n // If this literal was part of a list, write the item\n // (we could also check the context stack, but passing in a flag is faster)\n if (listItem)\n this._emit(this._subject, this.RDF_FIRST, this._object, this._graph);\n // If the token was consumed, continue with the rest of the input\n if (completed.token === null)\n return this._getContextEndReader();\n // Otherwise, consume the token now\n else {\n this._readCallback = this._getContextEndReader();\n return this._readCallback(completed.token);\n }\n }\n\n // ### `_readFormulaTail` reads the end of a formula\n _readFormulaTail(token) {\n if (token.type !== '}')\n return this._readPunctuation(token);\n\n // Store the last quad of the formula\n if (this._subject !== null)\n this._emit(this._subject, this._predicate, this._object, this._graph);\n\n // Restore the parent context containing this formula\n this._restoreContext('formula', token);\n // If the formula was the subject, continue reading the predicate.\n // If the formula was the object, read punctuation.\n return this._object === null ? this._readPredicate : this._getContextEndReader();\n }\n\n // ### `_readPunctuation` reads punctuation between quads or quad parts\n _readPunctuation(token) {\n let next, graph = this._graph;\n const subject = this._subject, inversePredicate = this._inversePredicate;\n switch (token.type) {\n // A closing brace ends a graph\n case '}':\n if (this._graph === null)\n return this._error('Unexpected graph closing', token);\n if (this._n3Mode)\n return this._readFormulaTail(token);\n this._graph = null;\n // A dot just ends the statement, without sharing anything with the next\n case '.':\n this._subject = null;\n next = this._contextStack.length ? this._readSubject : this._readInTopContext;\n if (inversePredicate) this._inversePredicate = false;\n break;\n // Semicolon means the subject is shared; predicate and object are different\n case ';':\n next = this._readPredicate;\n break;\n // Comma means both the subject and predicate are shared; the object is different\n case ',':\n next = this._readObject;\n break;\n // {| means that the current triple is annotated with predicate-object pairs.\n case '{|':\n if (!this._supportsRDFStar)\n return this._error('Unexpected RDF-star syntax', token);\n // Continue using the last triple as quoted triple subject for the predicate-object pairs.\n const predicate = this._predicate, object = this._object;\n this._subject = this._factory.quad(subject, predicate, object, this.DEFAULTGRAPH);\n next = this._readPredicate;\n break;\n // |} means that the current quoted triple in annotation syntax is finalized.\n case '|}':\n if (this._subject.termType !== 'Quad')\n return this._error('Unexpected asserted triple closing', token);\n this._subject = null;\n next = this._readPunctuation;\n break;\n default:\n // An entity means this is a quad (only allowed if not already inside a graph)\n if (this._supportsQuads && this._graph === null && (graph = this._readEntity(token)) !== undefined) {\n next = this._readQuadPunctuation;\n break;\n }\n return this._error(`Expected punctuation to follow \"${this._object.id}\"`, token);\n }\n // A quad has been completed now, so return it\n if (subject !== null) {\n const predicate = this._predicate, object = this._object;\n if (!inversePredicate)\n this._emit(subject, predicate, object, graph);\n else\n this._emit(object, predicate, subject, graph);\n }\n return next;\n }\n\n // ### `_readBlankNodePunctuation` reads punctuation in a blank node\n _readBlankNodePunctuation(token) {\n let next;\n switch (token.type) {\n // Semicolon means the subject is shared; predicate and object are different\n case ';':\n next = this._readPredicate;\n break;\n // Comma means both the subject and predicate are shared; the object is different\n case ',':\n next = this._readObject;\n break;\n default:\n return this._error(`Expected punctuation to follow \"${this._object.id}\"`, token);\n }\n // A quad has been completed now, so return it\n this._emit(this._subject, this._predicate, this._object, this._graph);\n return next;\n }\n\n // ### `_readQuadPunctuation` reads punctuation after a quad\n _readQuadPunctuation(token) {\n if (token.type !== '.')\n return this._error('Expected dot to follow quad', token);\n return this._readInTopContext;\n }\n\n // ### `_readPrefix` reads the prefix of a prefix declaration\n _readPrefix(token) {\n if (token.type !== 'prefix')\n return this._error('Expected prefix to follow @prefix', token);\n this._prefix = token.value;\n return this._readPrefixIRI;\n }\n\n // ### `_readPrefixIRI` reads the IRI of a prefix declaration\n _readPrefixIRI(token) {\n if (token.type !== 'IRI')\n return this._error(`Expected IRI to follow prefix \"${this._prefix}:\"`, token);\n const prefixNode = this._readEntity(token);\n this._prefixes[this._prefix] = prefixNode.value;\n this._prefixCallback(this._prefix, prefixNode);\n return this._readDeclarationPunctuation;\n }\n\n // ### `_readBaseIRI` reads the IRI of a base declaration\n _readBaseIRI(token) {\n const iri = token.type === 'IRI' && this._resolveIRI(token.value);\n if (!iri)\n return this._error('Expected valid IRI to follow base declaration', token);\n this._setBase(iri);\n return this._readDeclarationPunctuation;\n }\n\n // ### `_readNamedGraphLabel` reads the label of a named graph\n _readNamedGraphLabel(token) {\n switch (token.type) {\n case 'IRI':\n case 'blank':\n case 'prefixed':\n return this._readSubject(token), this._readGraph;\n case '[':\n return this._readNamedGraphBlankLabel;\n default:\n return this._error('Invalid graph label', token);\n }\n }\n\n // ### `_readNamedGraphLabel` reads a blank node label of a named graph\n _readNamedGraphBlankLabel(token) {\n if (token.type !== ']')\n return this._error('Invalid graph label', token);\n this._subject = this._factory.blankNode();\n return this._readGraph;\n }\n\n // ### `_readDeclarationPunctuation` reads the punctuation of a declaration\n _readDeclarationPunctuation(token) {\n // SPARQL-style declarations don't have punctuation\n if (this._sparqlStyle) {\n this._sparqlStyle = false;\n return this._readInTopContext(token);\n }\n\n if (token.type !== '.')\n return this._error('Expected declaration to end with a dot', token);\n return this._readInTopContext;\n }\n\n // Reads a list of quantified symbols from a @forSome or @forAll statement\n _readQuantifierList(token) {\n let entity;\n switch (token.type) {\n case 'IRI':\n case 'prefixed':\n if ((entity = this._readEntity(token, true)) !== undefined)\n break;\n default:\n return this._error(`Unexpected ${token.type}`, token);\n }\n // Without explicit quantifiers, map entities to a quantified entity\n if (!this._explicitQuantifiers)\n this._quantified[entity.id] = this._factory[this._quantifier](this._factory.blankNode().value);\n // With explicit quantifiers, output the reified quantifier\n else {\n // If this is the first item, start a new quantifier list\n if (this._subject === null)\n this._emit(this._graph || this.DEFAULTGRAPH, this._predicate,\n this._subject = this._factory.blankNode(), this.QUANTIFIERS_GRAPH);\n // Otherwise, continue the previous list\n else\n this._emit(this._subject, this.RDF_REST,\n this._subject = this._factory.blankNode(), this.QUANTIFIERS_GRAPH);\n // Output the list item\n this._emit(this._subject, this.RDF_FIRST, entity, this.QUANTIFIERS_GRAPH);\n }\n return this._readQuantifierPunctuation;\n }\n\n // Reads punctuation from a @forSome or @forAll statement\n _readQuantifierPunctuation(token) {\n // Read more quantifiers\n if (token.type === ',')\n return this._readQuantifierList;\n // End of the quantifier list\n else {\n // With explicit quantifiers, close the quantifier list\n if (this._explicitQuantifiers) {\n this._emit(this._subject, this.RDF_REST, this.RDF_NIL, this.QUANTIFIERS_GRAPH);\n this._subject = null;\n }\n // Read a dot\n this._readCallback = this._getContextEndReader();\n return this._readCallback(token);\n }\n }\n\n // ### `_getPathReader` reads a potential path and then resumes with the given function\n _getPathReader(afterPath) {\n this._afterPath = afterPath;\n return this._readPath;\n }\n\n // ### `_readPath` reads a potential path\n _readPath(token) {\n switch (token.type) {\n // Forward path\n case '!': return this._readForwardPath;\n // Backward path\n case '^': return this._readBackwardPath;\n // Not a path; resume reading where we left off\n default:\n const stack = this._contextStack, parent = stack.length && stack[stack.length - 1];\n // If we were reading a list item, we still need to output it\n if (parent && parent.type === 'item') {\n // The list item is the remaining subejct after reading the path\n const item = this._subject;\n // Switch back to the context of the list\n this._restoreContext('item', token);\n // Output the list item\n this._emit(this._subject, this.RDF_FIRST, item, this._graph);\n }\n return this._afterPath(token);\n }\n }\n\n // ### `_readForwardPath` reads a '!' path\n _readForwardPath(token) {\n let subject, predicate;\n const object = this._factory.blankNode();\n // The next token is the predicate\n if ((predicate = this._readEntity(token)) === undefined)\n return;\n // If we were reading a subject, replace the subject by the path's object\n if (this._predicate === null)\n subject = this._subject, this._subject = object;\n // If we were reading an object, replace the subject by the path's object\n else\n subject = this._object, this._object = object;\n // Emit the path's current quad and read its next section\n this._emit(subject, predicate, object, this._graph);\n return this._readPath;\n }\n\n // ### `_readBackwardPath` reads a '^' path\n _readBackwardPath(token) {\n const subject = this._factory.blankNode();\n let predicate, object;\n // The next token is the predicate\n if ((predicate = this._readEntity(token)) === undefined)\n return;\n // If we were reading a subject, replace the subject by the path's subject\n if (this._predicate === null)\n object = this._subject, this._subject = subject;\n // If we were reading an object, replace the subject by the path's subject\n else\n object = this._object, this._object = subject;\n // Emit the path's current quad and read its next section\n this._emit(subject, predicate, object, this._graph);\n return this._readPath;\n }\n\n // ### `_readRDFStarTailOrGraph` reads the graph of a nested RDF-star quad or the end of a nested RDF-star triple\n _readRDFStarTailOrGraph(token) {\n if (token.type !== '>>') {\n // An entity means this is a quad (only allowed if not already inside a graph)\n if (this._supportsQuads && this._graph === null && (this._graph = this._readEntity(token)) !== undefined)\n return this._readRDFStarTail;\n return this._error(`Expected >> to follow \"${this._object.id}\"`, token);\n }\n return this._readRDFStarTail(token);\n }\n\n // ### `_readRDFStarTail` reads the end of a nested RDF-star triple\n _readRDFStarTail(token) {\n if (token.type !== '>>')\n return this._error(`Expected >> but got ${token.type}`, token);\n // Read the quad and restore the previous context\n const quad = this._factory.quad(this._subject, this._predicate, this._object,\n this._graph || this.DEFAULTGRAPH);\n this._restoreContext('<<', token);\n // If the triple was the subject, continue by reading the predicate.\n if (this._subject === null) {\n this._subject = quad;\n return this._readPredicate;\n }\n // If the triple was the object, read context end.\n else {\n this._object = quad;\n return this._getContextEndReader();\n }\n }\n\n // ### `_getContextEndReader` gets the next reader function at the end of a context\n _getContextEndReader() {\n const contextStack = this._contextStack;\n if (!contextStack.length)\n return this._readPunctuation;\n\n switch (contextStack[contextStack.length - 1].type) {\n case 'blank':\n return this._readBlankNodeTail;\n case 'list':\n return this._readListItem;\n case 'formula':\n return this._readFormulaTail;\n case '<<':\n return this._readRDFStarTailOrGraph;\n }\n }\n\n // ### `_emit` sends a quad through the callback\n _emit(subject, predicate, object, graph) {\n this._callback(null, this._factory.quad(subject, predicate, object, graph || this.DEFAULTGRAPH));\n }\n\n // ### `_error` emits an error message through the callback\n _error(message, token) {\n const err = new Error(`${message} on line ${token.line}.`);\n err.context = {\n token: token,\n line: token.line,\n previousToken: this._lexer.previousToken,\n };\n this._callback(err);\n this._callback = noop;\n }\n\n // ### `_resolveIRI` resolves an IRI against the base path\n _resolveIRI(iri) {\n return /^[a-z][a-z0-9+.-]*:/i.test(iri) ? iri : this._resolveRelativeIRI(iri);\n }\n\n // ### `_resolveRelativeIRI` resolves an IRI against the base path,\n // assuming that a base path has been set and that the IRI is indeed relative\n _resolveRelativeIRI(iri) {\n // An empty relative IRI indicates the base IRI\n if (!iri.length)\n return this._base;\n // Decide resolving strategy based in the first character\n switch (iri[0]) {\n // Resolve relative fragment IRIs against the base IRI\n case '#': return this._base + iri;\n // Resolve relative query string IRIs by replacing the query string\n case '?': return this._base.replace(/(?:\\?.*)?$/, iri);\n // Resolve root-relative IRIs at the root of the base IRI\n case '/':\n // Resolve scheme-relative IRIs to the scheme\n return (iri[1] === '/' ? this._baseScheme : this._baseRoot) + this._removeDotSegments(iri);\n // Resolve all other IRIs at the base IRI's path\n default:\n // Relative IRIs cannot contain a colon in the first path segment\n return (/^[^/:]*:/.test(iri)) ? null : this._removeDotSegments(this._basePath + iri);\n }\n }\n\n // ### `_removeDotSegments` resolves './' and '../' path segments in an IRI as per RFC3986\n _removeDotSegments(iri) {\n // Don't modify the IRI if it does not contain any dot segments\n if (!/(^|\\/)\\.\\.?($|[/#?])/.test(iri))\n return iri;\n\n // Start with an imaginary slash before the IRI in order to resolve trailing './' and '../'\n const length = iri.length;\n let result = '', i = -1, pathStart = -1, segmentStart = 0, next = '/';\n\n while (i < length) {\n switch (next) {\n // The path starts with the first slash after the authority\n case ':':\n if (pathStart < 0) {\n // Skip two slashes before the authority\n if (iri[++i] === '/' && iri[++i] === '/')\n // Skip to slash after the authority\n while ((pathStart = i + 1) < length && iri[pathStart] !== '/')\n i = pathStart;\n }\n break;\n // Don't modify a query string or fragment\n case '?':\n case '#':\n i = length;\n break;\n // Handle '/.' or '/..' path segments\n case '/':\n if (iri[i + 1] === '.') {\n next = iri[++i + 1];\n switch (next) {\n // Remove a '/.' segment\n case '/':\n result += iri.substring(segmentStart, i - 1);\n segmentStart = i + 1;\n break;\n // Remove a trailing '/.' segment\n case undefined:\n case '?':\n case '#':\n return result + iri.substring(segmentStart, i) + iri.substr(i + 1);\n // Remove a '/..' segment\n case '.':\n next = iri[++i + 1];\n if (next === undefined || next === '/' || next === '?' || next === '#') {\n result += iri.substring(segmentStart, i - 2);\n // Try to remove the parent path from result\n if ((segmentStart = result.lastIndexOf('/')) >= pathStart)\n result = result.substr(0, segmentStart);\n // Remove a trailing '/..' segment\n if (next !== '/')\n return `${result}/${iri.substr(i + 1)}`;\n segmentStart = i + 1;\n }\n }\n }\n }\n next = iri[++i];\n }\n return result + iri.substring(segmentStart);\n }\n\n // ## Public methods\n\n // ### `parse` parses the N3 input and emits each parsed quad through the onQuad callback.\n parse(input, quadCallback, prefixCallback) {\n // The second parameter accepts an object { onQuad: ..., onPrefix: ..., onComment: ...}\n // As a second and third parameter it still accepts a separate quadCallback and prefixCallback for backward compatibility as well\n let onQuad, onPrefix, onComment;\n if (quadCallback && (quadCallback.onQuad || quadCallback.onPrefix || quadCallback.onComment)) {\n onQuad = quadCallback.onQuad;\n onPrefix = quadCallback.onPrefix;\n onComment = quadCallback.onComment;\n }\n else {\n onQuad = quadCallback;\n onPrefix = prefixCallback;\n }\n // The read callback is the next function to be executed when a token arrives.\n // We start reading in the top context.\n this._readCallback = this._readInTopContext;\n this._sparqlStyle = false;\n this._prefixes = Object.create(null);\n this._prefixes._ = this._blankNodePrefix ? this._blankNodePrefix.substr(2)\n : `b${blankNodePrefix++}_`;\n this._prefixCallback = onPrefix || noop;\n this._inversePredicate = false;\n this._quantified = Object.create(null);\n\n // Parse synchronously if no quad callback is given\n if (!onQuad) {\n const quads = [];\n let error;\n this._callback = (e, t) => { e ? (error = e) : t && quads.push(t); };\n this._lexer.tokenize(input).every(token => {\n return this._readCallback = this._readCallback(token);\n });\n if (error) throw error;\n return quads;\n }\n\n let processNextToken = (error, token) => {\n if (error !== null)\n this._callback(error), this._callback = noop;\n else if (this._readCallback)\n this._readCallback = this._readCallback(token);\n };\n\n // Enable checking for comments on every token when a commentCallback has been set\n if (onComment) {\n // Enable the lexer to return comments as tokens first (disabled by default)\n this._lexer.comments = true;\n // Patch the processNextToken function\n processNextToken = (error, token) => {\n if (error !== null)\n this._callback(error), this._callback = noop;\n else if (this._readCallback) {\n if (token.type === 'comment')\n onComment(token.value);\n else\n this._readCallback = this._readCallback(token);\n }\n };\n }\n\n // Parse asynchronously otherwise, executing the read callback when a token arrives\n this._callback = onQuad;\n this._lexer.tokenize(input, processNextToken);\n }\n}\n\n// The empty function\nfunction noop() {}\n\n// Initializes the parser with the given data factory\nfunction initDataFactory(parser, factory) {\n parser._factory = factory;\n\n parser.DEFAULTGRAPH = factory.defaultGraph();\n\n // Set common named nodes\n parser.RDF_FIRST = factory.namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].rdf.first);\n parser.RDF_REST = factory.namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].rdf.rest);\n parser.RDF_NIL = factory.namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].rdf.nil);\n parser.N3_FORALL = factory.namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].r.forAll);\n parser.N3_FORSOME = factory.namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].r.forSome);\n parser.ABBREVIATIONS = {\n 'a': factory.namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].rdf.type),\n '=': factory.namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].owl.sameAs),\n '>': factory.namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].log.implies),\n '<': factory.namedNode(_IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].log.isImpliedBy),\n };\n parser.QUANTIFIERS_GRAPH = factory.namedNode('urn:n3:quantifiers');\n}\ninitDataFactory(N3Parser.prototype, _N3DataFactory__WEBPACK_IMPORTED_MODULE_2__[\"default\"]);\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/N3Parser.js?");
117
+
118
+ /***/ }),
119
+
120
+ /***/ "./node_modules/n3/src/N3Reasoner.js":
121
+ /*!*******************************************!*\
122
+ !*** ./node_modules/n3/src/N3Reasoner.js ***!
123
+ \*******************************************/
124
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
125
+
126
+ "use strict";
127
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ N3Reasoner),\n/* harmony export */ getRulesFromDataset: () => (/* binding */ getRulesFromDataset)\n/* harmony export */ });\n/* harmony import */ var _N3DataFactory__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./N3DataFactory */ \"./node_modules/n3/src/N3DataFactory.js\");\n\n\n/**\n * Gets rules from a dataset. This will only collect horn rules declared using log:implies.\n */\nfunction getRulesFromDataset(dataset) {\n const rules = [];\n for (const { subject, object } of dataset.match(null, _N3DataFactory__WEBPACK_IMPORTED_MODULE_0__[\"default\"].namedNode('http://www.w3.org/2000/10/swap/log#implies'), null, _N3DataFactory__WEBPACK_IMPORTED_MODULE_0__[\"default\"].defaultGraph())) {\n const premise = [...dataset.match(null, null, null, subject)];\n const conclusion = [...dataset.match(null, null, null, object)];\n rules.push({ premise, conclusion });\n }\n return rules;\n}\n\nclass N3Reasoner {\n constructor(store) {\n this._store = store;\n }\n\n _add(subject, predicate, object, graphItem, cb) {\n // Only add to the remaining indexes if there is not already a value in the index\n if (!this._store._addToIndex(graphItem.subjects, subject, predicate, object)) return;\n this._store._addToIndex(graphItem.predicates, predicate, object, subject);\n this._store._addToIndex(graphItem.objects, object, subject, predicate);\n cb();\n }\n\n // eslint-disable-next-line no-warning-comments\n _evaluatePremise(rule, content, cb, i = 0) {\n let v1, v2, value, index1, index2;\n const [val0, val1, val2] = rule.premise[i].value, index = content[rule.premise[i].content];\n const v0 = !(value = val0.value);\n for (value in v0 ? index : { [value]: index[value] }) {\n if (index1 = index[value]) {\n if (v0) val0.value = Number(value);\n v1 = !(value = val1.value);\n for (value in v1 ? index1 : { [value]: index1[value] }) {\n if (index2 = index1[value]) {\n if (v1) val1.value = Number(value);\n v2 = !(value = val2.value);\n for (value in v2 ? index2 : { [value]: index2[value] }) {\n if (v2) val2.value = Number(value);\n\n if (i === rule.premise.length - 1)\n rule.conclusion.forEach(c => {\n // eslint-disable-next-line max-nested-callbacks\n this._add(c.subject.value, c.predicate.value, c.object.value, content, () => { cb(c); });\n });\n else\n this._evaluatePremise(rule, content, cb, i + 1);\n }\n if (v2) val2.value = null;\n }\n }\n if (v1) val1.value = null;\n }\n }\n if (v0) val0.value = null;\n }\n\n _evaluateRules(rules, content, cb) {\n for (let i = 0; i < rules.length; i++) {\n this._evaluatePremise(rules[i], content, cb);\n }\n }\n\n // A naive reasoning algorithm where rules are just applied by repeatedly applying rules\n // until no more evaluations are made\n _reasonGraphNaive(rules, content) {\n const newRules = [];\n\n function addRule(conclusion) {\n if (conclusion.next)\n conclusion.next.forEach(rule => {\n newRules.push([conclusion.subject.value, conclusion.predicate.value, conclusion.object.value, rule]);\n });\n }\n\n // eslint-disable-next-line func-style\n const addConclusions = conclusion => {\n conclusion.forEach(c => {\n // eslint-disable-next-line max-nested-callbacks\n this._add(c.subject.value, c.predicate.value, c.object.value, content, () => { addRule(c); });\n });\n };\n\n this._evaluateRules(rules, content, addRule);\n\n let r;\n while ((r = newRules.pop()) !== undefined) {\n const [subject, predicate, object, rule] = r;\n const v1 = rule.basePremise.subject.value;\n if (!v1) rule.basePremise.subject.value = subject;\n const v2 = rule.basePremise.predicate.value;\n if (!v2) rule.basePremise.predicate.value = predicate;\n const v3 = rule.basePremise.object.value;\n if (!v3) rule.basePremise.object.value = object;\n\n if (rule.premise.length === 0) {\n addConclusions(rule.conclusion);\n }\n else {\n this._evaluatePremise(rule, content, addRule);\n }\n\n if (!v1) rule.basePremise.subject.value = null;\n if (!v2) rule.basePremise.predicate.value = null;\n if (!v3) rule.basePremise.object.value = null;\n }\n }\n\n _createRule({ premise, conclusion }) {\n const varMapping = {};\n\n const toId = value => value.termType === 'Variable' ?\n // If the term is a variable, then create an empty object that values can be placed into\n (varMapping[value.value] = varMapping[value.value] || {}) :\n // If the term is not a variable, then set the ID value\n { value: this._store._termToNewNumericId(value) };\n\n // eslint-disable-next-line func-style\n const t = term => ({ subject: toId(term.subject), predicate: toId(term.predicate), object: toId(term.object) });\n\n return {\n premise: premise.map(p => t(p)),\n conclusion: conclusion.map(p => t(p)),\n variables: Object.values(varMapping),\n };\n }\n\n reason(rules) {\n if (!Array.isArray(rules)) {\n rules = getRulesFromDataset(rules);\n }\n rules = rules.map(rule => this._createRule(rule));\n\n for (const r1 of rules) {\n for (const r2 of rules) {\n for (let i = 0; i < r2.premise.length; i++) {\n const p = r2.premise[i];\n for (const c of r1.conclusion) {\n if (termEq(p.subject, c.subject) && termEq(p.predicate, c.predicate) && termEq(p.object, c.object)) {\n const set = new Set();\n\n const premise = [];\n\n // Since these *will* be substituted when we apply the rule,\n // we need to do this, so that we index correctly in the subsequent section\n p.subject.value = p.subject.value || 1;\n p.object.value = p.object.value || 1;\n p.predicate.value = p.predicate.value || 1;\n\n for (let j = 0; j < r2.premise.length; j++) {\n if (j !== i) {\n premise.push(getIndex(r2.premise[j], set));\n }\n }\n\n // eslint-disable-next-line no-warning-comments\n // TODO: Create new rule, with new indexing\n // Future, 'collapse' the next statements when they share a premise/base-premise\n (c.next = c.next || []).push({\n premise,\n conclusion: r2.conclusion,\n // This is a single premise of the form { subject, predicate, object },\n // which we can use to instantiate the rule using the new data that was emitted\n basePremise: p,\n });\n }\n r2.variables.forEach(v => { v.value = null; });\n }\n }\n }\n }\n\n for (const rule of rules) {\n const set = new Set();\n rule.premise = rule.premise.map(p => getIndex(p, set));\n }\n\n const graphs = this._store._getGraphs();\n for (const graphId in graphs) {\n this._reasonGraphNaive(rules, graphs[graphId]);\n }\n\n this._store._size = null;\n }\n}\n\nfunction getIndex({ subject, predicate, object }, set) {\n const s = subject.value || set.has(subject) || (set.add(subject), false);\n const p = predicate.value || set.has(predicate) || (set.add(predicate), false);\n const o = object.value || set.has(object) || (set.add(object), false);\n\n return (!s && p) ? { content: 'predicates', value: [predicate, object, subject] } :\n o ? { content: 'objects', value: [object, subject, predicate] } :\n { content: 'subjects', value: [subject, predicate, object] };\n}\n\nfunction termEq(t1, t2) {\n if (t1.value === null) {\n t1.value = t2.value;\n }\n return t1.value === t2.value;\n}\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/N3Reasoner.js?");
117
128
 
118
129
  /***/ }),
119
130
 
@@ -124,7 +135,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
124
135
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
125
136
 
126
137
  "use strict";
127
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ N3Store)\n/* harmony export */ });\n/* harmony import */ var _N3DataFactory__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./N3DataFactory */ \"./node_modules/n3/src/N3DataFactory.js\");\n/* harmony import */ var readable_stream__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! readable-stream */ \"./node_modules/readable-stream/lib/ours/browser.js\");\n/* harmony import */ var readable_stream__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(readable_stream__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _IRIs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./IRIs */ \"./node_modules/n3/src/IRIs.js\");\n// **N3Store** objects store N3 quads by graph in memory.\n\n\n\n\n// ## Constructor\nclass N3Store {\n constructor(quads, options) {\n // The number of quads is initially zero\n this._size = 0;\n // `_graphs` contains subject, predicate, and object indexes per graph\n this._graphs = Object.create(null);\n // `_ids` maps entities such as `http://xmlns.com/foaf/0.1/name` to numbers,\n // saving memory by using only numbers as keys in `_graphs`\n this._id = 0;\n this._ids = Object.create(null);\n this._ids['><'] = 0; // dummy entry, so the first actual key is non-zero\n this._entities = Object.create(null); // inverse of `_ids`\n // `_blankNodeIndex` is the index of the last automatically named blank node\n this._blankNodeIndex = 0;\n\n // Shift parameters if `quads` is not given\n if (!options && quads && !quads[0])\n options = quads, quads = null;\n options = options || {};\n this._factory = options.factory || _N3DataFactory__WEBPACK_IMPORTED_MODULE_1__[\"default\"];\n\n // Add quads if passed\n if (quads)\n this.addQuads(quads);\n }\n\n // ## Public properties\n\n // ### `size` returns the number of quads in the store\n get size() {\n // Return the quad count if if was cached\n let size = this._size;\n if (size !== null)\n return size;\n\n // Calculate the number of quads by counting to the deepest level\n size = 0;\n const graphs = this._graphs;\n let subjects, subject;\n for (const graphKey in graphs)\n for (const subjectKey in (subjects = graphs[graphKey].subjects))\n for (const predicateKey in (subject = subjects[subjectKey]))\n size += Object.keys(subject[predicateKey]).length;\n return this._size = size;\n }\n\n // ## Private methods\n\n // ### `_addToIndex` adds a quad to a three-layered index.\n // Returns if the index has changed, if the entry did not already exist.\n _addToIndex(index0, key0, key1, key2) {\n // Create layers as necessary\n const index1 = index0[key0] || (index0[key0] = {});\n const index2 = index1[key1] || (index1[key1] = {});\n // Setting the key to _any_ value signals the presence of the quad\n const existed = key2 in index2;\n if (!existed)\n index2[key2] = null;\n return !existed;\n }\n\n // ### `_removeFromIndex` removes a quad from a three-layered index\n _removeFromIndex(index0, key0, key1, key2) {\n // Remove the quad from the index\n const index1 = index0[key0], index2 = index1[key1];\n delete index2[key2];\n\n // Remove intermediary index layers if they are empty\n for (const key in index2) return;\n delete index1[key1];\n for (const key in index1) return;\n delete index0[key0];\n }\n\n // ### `_findInIndex` finds a set of quads in a three-layered index.\n // The index base is `index0` and the keys at each level are `key0`, `key1`, and `key2`.\n // Any of these keys can be undefined, which is interpreted as a wildcard.\n // `name0`, `name1`, and `name2` are the names of the keys at each level,\n // used when reconstructing the resulting quad\n // (for instance: _subject_, _predicate_, and _object_).\n // Finally, `graphId` will be the graph of the created quads.\n *_findInIndex(index0, key0, key1, key2, name0, name1, name2, graphId) {\n let tmp, index1, index2;\n const entityKeys = this._entities;\n const graph = (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termFromId)(graphId, this._factory);\n const parts = { subject: null, predicate: null, object: null };\n\n // If a key is specified, use only that part of index 0.\n if (key0) (tmp = index0, index0 = {})[key0] = tmp[key0];\n for (const value0 in index0) {\n if (index1 = index0[value0]) {\n parts[name0] = (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termFromId)(entityKeys[value0], this._factory);\n // If a key is specified, use only that part of index 1.\n if (key1) (tmp = index1, index1 = {})[key1] = tmp[key1];\n for (const value1 in index1) {\n if (index2 = index1[value1]) {\n parts[name1] = (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termFromId)(entityKeys[value1], this._factory);\n // If a key is specified, use only that part of index 2, if it exists.\n const values = key2 ? (key2 in index2 ? [key2] : []) : Object.keys(index2);\n // Create quads for all items found in index 2.\n for (let l = 0; l < values.length; l++) {\n parts[name2] = (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termFromId)(entityKeys[values[l]], this._factory);\n yield this._factory.quad(parts.subject, parts.predicate, parts.object, graph);\n }\n }\n }\n }\n }\n }\n\n // ### `_loop` executes the callback on all keys of index 0\n _loop(index0, callback) {\n for (const key0 in index0)\n callback(key0);\n }\n\n // ### `_loopByKey0` executes the callback on all keys of a certain entry in index 0\n _loopByKey0(index0, key0, callback) {\n let index1, key1;\n if (index1 = index0[key0]) {\n for (key1 in index1)\n callback(key1);\n }\n }\n\n // ### `_loopByKey1` executes the callback on given keys of all entries in index 0\n _loopByKey1(index0, key1, callback) {\n let key0, index1;\n for (key0 in index0) {\n index1 = index0[key0];\n if (index1[key1])\n callback(key0);\n }\n }\n\n // ### `_loopBy2Keys` executes the callback on given keys of certain entries in index 2\n _loopBy2Keys(index0, key0, key1, callback) {\n let index1, index2, key2;\n if ((index1 = index0[key0]) && (index2 = index1[key1])) {\n for (key2 in index2)\n callback(key2);\n }\n }\n\n // ### `_countInIndex` counts matching quads in a three-layered index.\n // The index base is `index0` and the keys at each level are `key0`, `key1`, and `key2`.\n // Any of these keys can be undefined, which is interpreted as a wildcard.\n _countInIndex(index0, key0, key1, key2) {\n let count = 0, tmp, index1, index2;\n\n // If a key is specified, count only that part of index 0\n if (key0) (tmp = index0, index0 = {})[key0] = tmp[key0];\n for (const value0 in index0) {\n if (index1 = index0[value0]) {\n // If a key is specified, count only that part of index 1\n if (key1) (tmp = index1, index1 = {})[key1] = tmp[key1];\n for (const value1 in index1) {\n if (index2 = index1[value1]) {\n // If a key is specified, count the quad if it exists\n if (key2) (key2 in index2) && count++;\n // Otherwise, count all quads\n else count += Object.keys(index2).length;\n }\n }\n }\n }\n return count;\n }\n\n // ### `_getGraphs` returns an array with the given graph,\n // or all graphs if the argument is null or undefined.\n _getGraphs(graph) {\n if (!isString(graph))\n return this._graphs;\n const graphs = {};\n graphs[graph] = this._graphs[graph];\n return graphs;\n }\n\n // ### `_uniqueEntities` returns a function that accepts an entity ID\n // and passes the corresponding entity to callback if it hasn't occurred before.\n _uniqueEntities(callback) {\n const uniqueIds = Object.create(null);\n return id => {\n if (!(id in uniqueIds)) {\n uniqueIds[id] = true;\n callback((0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termFromId)(this._entities[id], this._factory));\n }\n };\n }\n\n // ## Public methods\n\n // ### `add` adds the specified quad to the dataset.\n // Returns the dataset instance it was called on.\n // Existing quads, as defined in Quad.equals, will be ignored.\n add(quad) {\n this.addQuad(quad);\n return this;\n }\n\n // ### `addQuad` adds a new quad to the store.\n // Returns if the quad index has changed, if the quad did not already exist.\n addQuad(subject, predicate, object, graph) {\n // Shift arguments if a quad object is given instead of components\n if (!predicate)\n graph = subject.graph, object = subject.object,\n predicate = subject.predicate, subject = subject.subject;\n\n // Convert terms to internal string representation\n subject = (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(subject);\n predicate = (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(predicate);\n object = (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(object);\n graph = (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(graph);\n\n // Find the graph that will contain the triple\n let graphItem = this._graphs[graph];\n // Create the graph if it doesn't exist yet\n if (!graphItem) {\n graphItem = this._graphs[graph] = { subjects: {}, predicates: {}, objects: {} };\n // Freezing a graph helps subsequent `add` performance,\n // and properties will never be modified anyway\n Object.freeze(graphItem);\n }\n\n // Since entities can often be long IRIs, we avoid storing them in every index.\n // Instead, we have a separate index that maps entities to numbers,\n // which are then used as keys in the other indexes.\n const ids = this._ids;\n const entities = this._entities;\n subject = ids[subject] || (ids[entities[++this._id] = subject] = this._id);\n predicate = ids[predicate] || (ids[entities[++this._id] = predicate] = this._id);\n object = ids[object] || (ids[entities[++this._id] = object] = this._id);\n\n const changed = this._addToIndex(graphItem.subjects, subject, predicate, object);\n this._addToIndex(graphItem.predicates, predicate, object, subject);\n this._addToIndex(graphItem.objects, object, subject, predicate);\n\n // The cached quad count is now invalid\n this._size = null;\n return changed;\n }\n\n // ### `addQuads` adds multiple quads to the store\n addQuads(quads) {\n for (let i = 0; i < quads.length; i++)\n this.addQuad(quads[i]);\n }\n\n // ### `delete` removes the specified quad from the dataset.\n // Returns the dataset instance it was called on.\n delete(quad) {\n this.removeQuad(quad);\n return this;\n }\n\n // ### `has` determines whether a dataset includes a certain quad or quad pattern.\n has(subjectOrQuad, predicate, object, graph) {\n if (subjectOrQuad && subjectOrQuad.subject)\n ({ subject: subjectOrQuad, predicate, object, graph } = subjectOrQuad);\n return !this.readQuads(subjectOrQuad, predicate, object, graph).next().done;\n }\n\n // ### `import` adds a stream of quads to the store\n import(stream) {\n stream.on('data', quad => { this.addQuad(quad); });\n return stream;\n }\n\n // ### `removeQuad` removes a quad from the store if it exists\n removeQuad(subject, predicate, object, graph) {\n // Shift arguments if a quad object is given instead of components\n if (!predicate)\n graph = subject.graph, object = subject.object,\n predicate = subject.predicate, subject = subject.subject;\n\n // Convert terms to internal string representation\n subject = (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(subject);\n predicate = (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(predicate);\n object = (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(object);\n graph = (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(graph);\n\n // Find internal identifiers for all components\n // and verify the quad exists.\n const ids = this._ids, graphs = this._graphs;\n let graphItem, subjects, predicates;\n if (!(subject = ids[subject]) || !(predicate = ids[predicate]) ||\n !(object = ids[object]) || !(graphItem = graphs[graph]) ||\n !(subjects = graphItem.subjects[subject]) ||\n !(predicates = subjects[predicate]) ||\n !(object in predicates))\n return false;\n\n // Remove it from all indexes\n this._removeFromIndex(graphItem.subjects, subject, predicate, object);\n this._removeFromIndex(graphItem.predicates, predicate, object, subject);\n this._removeFromIndex(graphItem.objects, object, subject, predicate);\n if (this._size !== null) this._size--;\n\n // Remove the graph if it is empty\n for (subject in graphItem.subjects) return true;\n delete graphs[graph];\n return true;\n }\n\n // ### `removeQuads` removes multiple quads from the store\n removeQuads(quads) {\n for (let i = 0; i < quads.length; i++)\n this.removeQuad(quads[i]);\n }\n\n // ### `remove` removes a stream of quads from the store\n remove(stream) {\n stream.on('data', quad => { this.removeQuad(quad); });\n return stream;\n }\n\n // ### `removeMatches` removes all matching quads from the store\n // Setting any field to `undefined` or `null` indicates a wildcard.\n removeMatches(subject, predicate, object, graph) {\n const stream = new readable_stream__WEBPACK_IMPORTED_MODULE_0__.Readable({ objectMode: true });\n\n stream._read = () => {\n for (const quad of this.readQuads(subject, predicate, object, graph))\n stream.push(quad);\n stream.push(null);\n };\n\n return this.remove(stream);\n }\n\n // ### `deleteGraph` removes all triples with the given graph from the store\n deleteGraph(graph) {\n return this.removeMatches(null, null, null, graph);\n }\n\n // ### `getQuads` returns an array of quads matching a pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n getQuads(subject, predicate, object, graph) {\n return [...this.readQuads(subject, predicate, object, graph)];\n }\n\n // ### `readQuads` returns an generator of quads matching a pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n *readQuads(subject, predicate, object, graph) {\n // Convert terms to internal string representation\n subject = subject && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(subject);\n predicate = predicate && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(predicate);\n object = object && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(object);\n graph = graph && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(graph);\n\n const graphs = this._getGraphs(graph), ids = this._ids;\n let content, subjectId, predicateId, objectId;\n\n // Translate IRIs to internal index keys.\n if (isString(subject) && !(subjectId = ids[subject]) ||\n isString(predicate) && !(predicateId = ids[predicate]) ||\n isString(object) && !(objectId = ids[object]))\n return;\n\n for (const graphId in graphs) {\n // Only if the specified graph contains triples, there can be results\n if (content = graphs[graphId]) {\n // Choose the optimal index, based on what fields are present\n if (subjectId) {\n if (objectId)\n // If subject and object are given, the object index will be the fastest\n yield* this._findInIndex(content.objects, objectId, subjectId, predicateId,\n 'object', 'subject', 'predicate', graphId);\n else\n // If only subject and possibly predicate are given, the subject index will be the fastest\n yield* this._findInIndex(content.subjects, subjectId, predicateId, null,\n 'subject', 'predicate', 'object', graphId);\n }\n else if (predicateId)\n // If only predicate and possibly object are given, the predicate index will be the fastest\n yield* this._findInIndex(content.predicates, predicateId, objectId, null,\n 'predicate', 'object', 'subject', graphId);\n else if (objectId)\n // If only object is given, the object index will be the fastest\n yield* this._findInIndex(content.objects, objectId, null, null,\n 'object', 'subject', 'predicate', graphId);\n else\n // If nothing is given, iterate subjects and predicates first\n yield* this._findInIndex(content.subjects, null, null, null,\n 'subject', 'predicate', 'object', graphId);\n }\n }\n }\n\n // ### `match` returns a new dataset that is comprised of all quads in the current instance matching the given arguments.\n // The logic described in Quad Matching is applied for each quad in this dataset to check if it should be included in the output dataset.\n // Note: This method always returns a new DatasetCore, even if that dataset contains no quads.\n // Note: Since a DatasetCore is an unordered set, the order of the quads within the returned sequence is arbitrary.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n // For backwards compatibility, the object return also implements the Readable stream interface.\n match(subject, predicate, object, graph) {\n return new DatasetCoreAndReadableStream(this, subject, predicate, object, graph);\n }\n\n // ### `countQuads` returns the number of quads matching a pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n countQuads(subject, predicate, object, graph) {\n // Convert terms to internal string representation\n subject = subject && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(subject);\n predicate = predicate && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(predicate);\n object = object && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(object);\n graph = graph && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(graph);\n\n const graphs = this._getGraphs(graph), ids = this._ids;\n let count = 0, content, subjectId, predicateId, objectId;\n\n // Translate IRIs to internal index keys.\n if (isString(subject) && !(subjectId = ids[subject]) ||\n isString(predicate) && !(predicateId = ids[predicate]) ||\n isString(object) && !(objectId = ids[object]))\n return 0;\n\n for (const graphId in graphs) {\n // Only if the specified graph contains triples, there can be results\n if (content = graphs[graphId]) {\n // Choose the optimal index, based on what fields are present\n if (subject) {\n if (object)\n // If subject and object are given, the object index will be the fastest\n count += this._countInIndex(content.objects, objectId, subjectId, predicateId);\n else\n // If only subject and possibly predicate are given, the subject index will be the fastest\n count += this._countInIndex(content.subjects, subjectId, predicateId, objectId);\n }\n else if (predicate) {\n // If only predicate and possibly object are given, the predicate index will be the fastest\n count += this._countInIndex(content.predicates, predicateId, objectId, subjectId);\n }\n else {\n // If only object is possibly given, the object index will be the fastest\n count += this._countInIndex(content.objects, objectId, subjectId, predicateId);\n }\n }\n }\n return count;\n }\n\n // ### `forEach` executes the callback on all quads.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n forEach(callback, subject, predicate, object, graph) {\n this.some(quad => {\n callback(quad);\n return false;\n }, subject, predicate, object, graph);\n }\n\n // ### `every` executes the callback on all quads,\n // and returns `true` if it returns truthy for all them.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n every(callback, subject, predicate, object, graph) {\n let some = false;\n const every = !this.some(quad => {\n some = true;\n return !callback(quad);\n }, subject, predicate, object, graph);\n return some && every;\n }\n\n // ### `some` executes the callback on all quads,\n // and returns `true` if it returns truthy for any of them.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n some(callback, subject, predicate, object, graph) {\n for (const quad of this.readQuads(subject, predicate, object, graph))\n if (callback(quad))\n return true;\n return false;\n }\n\n // ### `getSubjects` returns all subjects that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n getSubjects(predicate, object, graph) {\n const results = [];\n this.forSubjects(s => { results.push(s); }, predicate, object, graph);\n return results;\n }\n\n // ### `forSubjects` executes the callback on all subjects that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n forSubjects(callback, predicate, object, graph) {\n // Convert terms to internal string representation\n predicate = predicate && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(predicate);\n object = object && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(object);\n graph = graph && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(graph);\n\n const ids = this._ids, graphs = this._getGraphs(graph);\n let content, predicateId, objectId;\n callback = this._uniqueEntities(callback);\n\n // Translate IRIs to internal index keys.\n if (isString(predicate) && !(predicateId = ids[predicate]) ||\n isString(object) && !(objectId = ids[object]))\n return;\n\n for (graph in graphs) {\n // Only if the specified graph contains triples, there can be results\n if (content = graphs[graph]) {\n // Choose optimal index based on which fields are wildcards\n if (predicateId) {\n if (objectId)\n // If predicate and object are given, the POS index is best.\n this._loopBy2Keys(content.predicates, predicateId, objectId, callback);\n else\n // If only predicate is given, the SPO index is best.\n this._loopByKey1(content.subjects, predicateId, callback);\n }\n else if (objectId)\n // If only object is given, the OSP index is best.\n this._loopByKey0(content.objects, objectId, callback);\n else\n // If no params given, iterate all the subjects\n this._loop(content.subjects, callback);\n }\n }\n }\n\n // ### `getPredicates` returns all predicates that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n getPredicates(subject, object, graph) {\n const results = [];\n this.forPredicates(p => { results.push(p); }, subject, object, graph);\n return results;\n }\n\n // ### `forPredicates` executes the callback on all predicates that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n forPredicates(callback, subject, object, graph) {\n // Convert terms to internal string representation\n subject = subject && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(subject);\n object = object && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(object);\n graph = graph && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(graph);\n\n const ids = this._ids, graphs = this._getGraphs(graph);\n let content, subjectId, objectId;\n callback = this._uniqueEntities(callback);\n\n // Translate IRIs to internal index keys.\n if (isString(subject) && !(subjectId = ids[subject]) ||\n isString(object) && !(objectId = ids[object]))\n return;\n\n for (graph in graphs) {\n // Only if the specified graph contains triples, there can be results\n if (content = graphs[graph]) {\n // Choose optimal index based on which fields are wildcards\n if (subjectId) {\n if (objectId)\n // If subject and object are given, the OSP index is best.\n this._loopBy2Keys(content.objects, objectId, subjectId, callback);\n else\n // If only subject is given, the SPO index is best.\n this._loopByKey0(content.subjects, subjectId, callback);\n }\n else if (objectId)\n // If only object is given, the POS index is best.\n this._loopByKey1(content.predicates, objectId, callback);\n else\n // If no params given, iterate all the predicates.\n this._loop(content.predicates, callback);\n }\n }\n }\n\n // ### `getObjects` returns all objects that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n getObjects(subject, predicate, graph) {\n const results = [];\n this.forObjects(o => { results.push(o); }, subject, predicate, graph);\n return results;\n }\n\n // ### `forObjects` executes the callback on all objects that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n forObjects(callback, subject, predicate, graph) {\n // Convert terms to internal string representation\n subject = subject && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(subject);\n predicate = predicate && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(predicate);\n graph = graph && (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(graph);\n\n const ids = this._ids, graphs = this._getGraphs(graph);\n let content, subjectId, predicateId;\n callback = this._uniqueEntities(callback);\n\n // Translate IRIs to internal index keys.\n if (isString(subject) && !(subjectId = ids[subject]) ||\n isString(predicate) && !(predicateId = ids[predicate]))\n return;\n\n for (graph in graphs) {\n // Only if the specified graph contains triples, there can be results\n if (content = graphs[graph]) {\n // Choose optimal index based on which fields are wildcards\n if (subjectId) {\n if (predicateId)\n // If subject and predicate are given, the SPO index is best.\n this._loopBy2Keys(content.subjects, subjectId, predicateId, callback);\n else\n // If only subject is given, the OSP index is best.\n this._loopByKey1(content.objects, subjectId, callback);\n }\n else if (predicateId)\n // If only predicate is given, the POS index is best.\n this._loopByKey0(content.predicates, predicateId, callback);\n else\n // If no params given, iterate all the objects.\n this._loop(content.objects, callback);\n }\n }\n }\n\n // ### `getGraphs` returns all graphs that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n getGraphs(subject, predicate, object) {\n const results = [];\n this.forGraphs(g => { results.push(g); }, subject, predicate, object);\n return results;\n }\n\n // ### `forGraphs` executes the callback on all graphs that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n forGraphs(callback, subject, predicate, object) {\n for (const graph in this._graphs) {\n this.some(quad => {\n callback(quad.graph);\n return true; // Halt iteration of some()\n }, subject, predicate, object, graph);\n }\n }\n\n // ### `createBlankNode` creates a new blank node, returning its name\n createBlankNode(suggestedName) {\n let name, index;\n // Generate a name based on the suggested name\n if (suggestedName) {\n name = suggestedName = `_:${suggestedName}`, index = 1;\n while (this._ids[name])\n name = suggestedName + index++;\n }\n // Generate a generic blank node name\n else {\n do { name = `_:b${this._blankNodeIndex++}`; }\n while (this._ids[name]);\n }\n // Add the blank node to the entities, avoiding the generation of duplicates\n this._ids[name] = ++this._id;\n this._entities[this._id] = name;\n return this._factory.blankNode(name.substr(2));\n }\n\n // ### `extractLists` finds and removes all list triples\n // and returns the items per list.\n extractLists({ remove = false, ignoreErrors = false } = {}) {\n const lists = {}; // has scalar keys so could be a simple Object\n const onError = ignoreErrors ? (() => true) :\n ((node, message) => { throw new Error(`${node.value} ${message}`); });\n\n // Traverse each list from its tail\n const tails = this.getQuads(null, _IRIs__WEBPACK_IMPORTED_MODULE_2__[\"default\"].rdf.rest, _IRIs__WEBPACK_IMPORTED_MODULE_2__[\"default\"].rdf.nil, null);\n const toRemove = remove ? [...tails] : [];\n tails.forEach(tailQuad => {\n const items = []; // the members found as objects of rdf:first quads\n let malformed = false; // signals whether the current list is malformed\n let head; // the head of the list (_:b1 in above example)\n let headPos; // set to subject or object when head is set\n const graph = tailQuad.graph; // make sure list is in exactly one graph\n\n // Traverse the list from tail to end\n let current = tailQuad.subject;\n while (current && !malformed) {\n const objectQuads = this.getQuads(null, null, current, null);\n const subjectQuads = this.getQuads(current, null, null, null);\n let quad, first = null, rest = null, parent = null;\n\n // Find the first and rest of this list node\n for (let i = 0; i < subjectQuads.length && !malformed; i++) {\n quad = subjectQuads[i];\n if (!quad.graph.equals(graph))\n malformed = onError(current, 'not confined to single graph');\n else if (head)\n malformed = onError(current, 'has non-list arcs out');\n\n // one rdf:first\n else if (quad.predicate.value === _IRIs__WEBPACK_IMPORTED_MODULE_2__[\"default\"].rdf.first) {\n if (first)\n malformed = onError(current, 'has multiple rdf:first arcs');\n else\n toRemove.push(first = quad);\n }\n\n // one rdf:rest\n else if (quad.predicate.value === _IRIs__WEBPACK_IMPORTED_MODULE_2__[\"default\"].rdf.rest) {\n if (rest)\n malformed = onError(current, 'has multiple rdf:rest arcs');\n else\n toRemove.push(rest = quad);\n }\n\n // alien triple\n else if (objectQuads.length)\n malformed = onError(current, 'can\\'t be subject and object');\n else {\n head = quad; // e.g. { (1 2 3) :p :o }\n headPos = 'subject';\n }\n }\n\n // { :s :p (1 2) } arrives here with no head\n // { (1 2) :p :o } arrives here with head set to the list.\n for (let i = 0; i < objectQuads.length && !malformed; ++i) {\n quad = objectQuads[i];\n if (head)\n malformed = onError(current, 'can\\'t have coreferences');\n // one rdf:rest\n else if (quad.predicate.value === _IRIs__WEBPACK_IMPORTED_MODULE_2__[\"default\"].rdf.rest) {\n if (parent)\n malformed = onError(current, 'has incoming rdf:rest arcs');\n else\n parent = quad;\n }\n else {\n head = quad; // e.g. { :s :p (1 2) }\n headPos = 'object';\n }\n }\n\n // Store the list item and continue with parent\n if (!first)\n malformed = onError(current, 'has no list head');\n else\n items.unshift(first.object);\n current = parent && parent.subject;\n }\n\n // Don't remove any quads if the list is malformed\n if (malformed)\n remove = false;\n // Store the list under the value of its head\n else if (head)\n lists[head[headPos].value] = items;\n });\n\n // Remove list quads if requested\n if (remove)\n this.removeQuads(toRemove);\n return lists;\n }\n\n // ### Store is an iterable.\n // Can be used where iterables are expected: for...of loops, array spread operator,\n // `yield*`, and destructuring assignment (order is not guaranteed).\n *[Symbol.iterator]() {\n yield* this.readQuads();\n }\n}\n\n// Determines whether the argument is a string\nfunction isString(s) {\n return typeof s === 'string' || s instanceof String;\n}\n\n/**\n * A class that implements both DatasetCore and Readable.\n */\nclass DatasetCoreAndReadableStream extends readable_stream__WEBPACK_IMPORTED_MODULE_0__.Readable {\n constructor(n3Store, subject, predicate, object, graph) {\n super({ objectMode: true });\n Object.assign(this, { n3Store, subject, predicate, object, graph });\n }\n\n get filtered() {\n if (!this._filtered) {\n const { n3Store, graph, object, predicate, subject } = this;\n const newStore = this._filtered = new N3Store({ factory: n3Store._factory });\n for (const quad of n3Store.readQuads(subject, predicate, object, graph))\n newStore.addQuad(quad);\n }\n return this._filtered;\n }\n\n get size() {\n return this.filtered.size;\n }\n\n _read() {\n for (const quad of this)\n this.push(quad);\n this.push(null);\n }\n\n add(quad) {\n return this.filtered.add(quad);\n }\n\n delete(quad) {\n return this.filtered.delete(quad);\n }\n\n has(quad) {\n return this.filtered.has(quad);\n }\n\n match(subject, predicate, object, graph) {\n return new DatasetCoreAndReadableStream(this.filtered, subject, predicate, object, graph);\n }\n\n *[Symbol.iterator]() {\n yield* this._filtered || this.n3Store.readQuads(this.subject, this.predicate, this.object, this.graph);\n }\n}\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/N3Store.js?");
138
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ N3EntityIndex: () => (/* binding */ N3EntityIndex),\n/* harmony export */ \"default\": () => (/* binding */ N3Store)\n/* harmony export */ });\n/* harmony import */ var readable_stream__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! readable-stream */ \"./node_modules/readable-stream/lib/ours/browser.js\");\n/* harmony import */ var readable_stream__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(readable_stream__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _N3DataFactory__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./N3DataFactory */ \"./node_modules/n3/src/N3DataFactory.js\");\n/* harmony import */ var _IRIs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./IRIs */ \"./node_modules/n3/src/IRIs.js\");\n/* harmony import */ var _N3Util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./N3Util */ \"./node_modules/n3/src/N3Util.js\");\n/* harmony import */ var _N3Writer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./N3Writer */ \"./node_modules/n3/src/N3Writer.js\");\n// **N3Store** objects store N3 quads by graph in memory.\n\n\n\n\n\n\nconst ITERATOR = Symbol('iter');\n\nfunction merge(target, source, depth = 4) {\n if (depth === 0)\n return Object.assign(target, source);\n\n for (const key in source)\n target[key] = merge(target[key] || Object.create(null), source[key], depth - 1);\n\n return target;\n}\n\n/**\n * Determines the intersection of the `_graphs` index s1 and s2.\n * s1 and s2 *must* belong to Stores that share an `_entityIndex`.\n *\n * False is returned when there is no intersection; this should\n * *not* be set as the value for an index.\n */\nfunction intersect(s1, s2, depth = 4) {\n let target = false;\n\n for (const key in s1) {\n if (key in s2) {\n const intersection = depth === 0 ? null : intersect(s1[key], s2[key], depth - 1);\n if (intersection !== false) {\n target = target || Object.create(null);\n target[key] = intersection;\n }\n // Depth 3 is the 'subjects', 'predicates' and 'objects' keys.\n // If the 'subjects' index is empty, so will the 'predicates' and 'objects' index.\n else if (depth === 3) {\n return false;\n }\n }\n }\n\n return target;\n}\n\n/**\n * Determines the difference of the `_graphs` index s1 and s2.\n * s1 and s2 *must* belong to Stores that share an `_entityIndex`.\n *\n * False is returned when there is no difference; this should\n * *not* be set as the value for an index.\n */\nfunction difference(s1, s2, depth = 4) {\n let target = false;\n\n for (const key in s1) {\n // When the key is not in the index, then none of the triples defined by s1[key] are\n // in s2 and so we want to copy them over to the resultant store.\n if (!(key in s2)) {\n target = target || Object.create(null);\n target[key] = depth === 0 ? null : merge({}, s1[key], depth - 1);\n }\n else if (depth !== 0) {\n const diff = difference(s1[key], s2[key], depth - 1);\n if (diff !== false) {\n target = target || Object.create(null);\n target[key] = diff;\n }\n // Depth 3 is the 'subjects', 'predicates' and 'objects' keys.\n // If the 'subjects' index is empty, so will the 'predicates' and 'objects' index.\n else if (depth === 3) {\n return false;\n }\n }\n }\n\n return target;\n}\n\n// ## Constructor\nclass N3EntityIndex {\n constructor(options = {}) {\n this._id = 1;\n // `_ids` maps entities such as `http://xmlns.com/foaf/0.1/name` to numbers,\n // saving memory by using only numbers as keys in `_graphs`\n this._ids = Object.create(null);\n this._ids[''] = 1;\n // inverse of `_ids`\n this._entities = Object.create(null);\n this._entities[1] = '';\n // `_blankNodeIndex` is the index of the last automatically named blank node\n this._blankNodeIndex = 0;\n this._factory = options.factory || _N3DataFactory__WEBPACK_IMPORTED_MODULE_1__[\"default\"];\n }\n\n _termFromId(id) {\n if (id[0] === '.') {\n const entities = this._entities;\n const terms = id.split('.');\n const q = this._factory.quad(\n this._termFromId(entities[terms[1]]),\n this._termFromId(entities[terms[2]]),\n this._termFromId(entities[terms[3]]),\n terms[4] && this._termFromId(entities[terms[4]]),\n );\n return q;\n }\n return (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termFromId)(id, this._factory);\n }\n\n _termToNumericId(term) {\n if (term.termType === 'Quad') {\n const s = this._termToNumericId(term.subject),\n p = this._termToNumericId(term.predicate),\n o = this._termToNumericId(term.object);\n let g;\n\n return s && p && o && ((0,_N3Util__WEBPACK_IMPORTED_MODULE_2__.isDefaultGraph)(term.graph) || (g = this._termToNumericId(term.graph))) &&\n this._ids[g ? `.${s}.${p}.${o}.${g}` : `.${s}.${p}.${o}`];\n }\n return this._ids[(0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(term)];\n }\n\n _termToNewNumericId(term) {\n // This assumes that no graph term is present - we may wish to error if there is one\n const str = term && term.termType === 'Quad' ?\n `.${this._termToNewNumericId(term.subject)}.${this._termToNewNumericId(term.predicate)}.${this._termToNewNumericId(term.object)}${\n (0,_N3Util__WEBPACK_IMPORTED_MODULE_2__.isDefaultGraph)(term.graph) ? '' : `.${this._termToNewNumericId(term.graph)}`\n }`\n : (0,_N3DataFactory__WEBPACK_IMPORTED_MODULE_1__.termToId)(term);\n\n return this._ids[str] || (this._ids[this._entities[++this._id] = str] = this._id);\n }\n\n createBlankNode(suggestedName) {\n let name, index;\n // Generate a name based on the suggested name\n if (suggestedName) {\n name = suggestedName = `_:${suggestedName}`, index = 1;\n while (this._ids[name])\n name = suggestedName + index++;\n }\n // Generate a generic blank node name\n else {\n do { name = `_:b${this._blankNodeIndex++}`; }\n while (this._ids[name]);\n }\n // Add the blank node to the entities, avoiding the generation of duplicates\n this._ids[name] = ++this._id;\n this._entities[this._id] = name;\n return this._factory.blankNode(name.substr(2));\n }\n}\n\n// ## Constructor\nclass N3Store {\n constructor(quads, options) {\n // The number of quads is initially zero\n this._size = 0;\n // `_graphs` contains subject, predicate, and object indexes per graph\n this._graphs = Object.create(null);\n\n // Shift parameters if `quads` is not given\n if (!options && quads && !quads[0])\n options = quads, quads = null;\n options = options || {};\n this._factory = options.factory || _N3DataFactory__WEBPACK_IMPORTED_MODULE_1__[\"default\"];\n this._entityIndex = options.entityIndex || new N3EntityIndex({ factory: this._factory });\n this._entities = this._entityIndex._entities;\n this._termFromId = this._entityIndex._termFromId.bind(this._entityIndex);\n this._termToNumericId = this._entityIndex._termToNumericId.bind(this._entityIndex);\n this._termToNewNumericId = this._entityIndex._termToNewNumericId.bind(this._entityIndex);\n\n // Add quads if passed\n if (quads)\n this.addQuads(quads);\n }\n\n // ## Public properties\n\n // ### `size` returns the number of quads in the store\n get size() {\n // Return the quad count if if was cached\n let size = this._size;\n if (size !== null)\n return size;\n\n // Calculate the number of quads by counting to the deepest level\n size = 0;\n const graphs = this._graphs;\n let subjects, subject;\n for (const graphKey in graphs)\n for (const subjectKey in (subjects = graphs[graphKey].subjects))\n for (const predicateKey in (subject = subjects[subjectKey]))\n size += Object.keys(subject[predicateKey]).length;\n return this._size = size;\n }\n\n // ## Private methods\n\n // ### `_addToIndex` adds a quad to a three-layered index.\n // Returns if the index has changed, if the entry did not already exist.\n _addToIndex(index0, key0, key1, key2) {\n // Create layers as necessary\n const index1 = index0[key0] || (index0[key0] = {});\n const index2 = index1[key1] || (index1[key1] = {});\n // Setting the key to _any_ value signals the presence of the quad\n const existed = key2 in index2;\n if (!existed)\n index2[key2] = null;\n return !existed;\n }\n\n // ### `_removeFromIndex` removes a quad from a three-layered index\n _removeFromIndex(index0, key0, key1, key2) {\n // Remove the quad from the index\n const index1 = index0[key0], index2 = index1[key1];\n delete index2[key2];\n\n // Remove intermediary index layers if they are empty\n for (const key in index2) return;\n delete index1[key1];\n for (const key in index1) return;\n delete index0[key0];\n }\n\n // ### `_findInIndex` finds a set of quads in a three-layered index.\n // The index base is `index0` and the keys at each level are `key0`, `key1`, and `key2`.\n // Any of these keys can be undefined, which is interpreted as a wildcard.\n // `name0`, `name1`, and `name2` are the names of the keys at each level,\n // used when reconstructing the resulting quad\n // (for instance: _subject_, _predicate_, and _object_).\n // Finally, `graphId` will be the graph of the created quads.\n *_findInIndex(index0, key0, key1, key2, name0, name1, name2, graphId) {\n let tmp, index1, index2;\n const entityKeys = this._entities;\n const graph = this._termFromId(entityKeys[graphId]);\n const parts = { subject: null, predicate: null, object: null };\n\n // If a key is specified, use only that part of index 0.\n if (key0) (tmp = index0, index0 = {})[key0] = tmp[key0];\n for (const value0 in index0) {\n if (index1 = index0[value0]) {\n parts[name0] = this._termFromId(entityKeys[value0]);\n // If a key is specified, use only that part of index 1.\n if (key1) (tmp = index1, index1 = {})[key1] = tmp[key1];\n for (const value1 in index1) {\n if (index2 = index1[value1]) {\n parts[name1] = this._termFromId(entityKeys[value1]);\n // If a key is specified, use only that part of index 2, if it exists.\n const values = key2 ? (key2 in index2 ? [key2] : []) : Object.keys(index2);\n // Create quads for all items found in index 2.\n for (let l = 0; l < values.length; l++) {\n parts[name2] = this._termFromId(entityKeys[values[l]]);\n yield this._factory.quad(parts.subject, parts.predicate, parts.object, graph);\n }\n }\n }\n }\n }\n }\n\n // ### `_loop` executes the callback on all keys of index 0\n _loop(index0, callback) {\n for (const key0 in index0)\n callback(key0);\n }\n\n // ### `_loopByKey0` executes the callback on all keys of a certain entry in index 0\n _loopByKey0(index0, key0, callback) {\n let index1, key1;\n if (index1 = index0[key0]) {\n for (key1 in index1)\n callback(key1);\n }\n }\n\n // ### `_loopByKey1` executes the callback on given keys of all entries in index 0\n _loopByKey1(index0, key1, callback) {\n let key0, index1;\n for (key0 in index0) {\n index1 = index0[key0];\n if (index1[key1])\n callback(key0);\n }\n }\n\n // ### `_loopBy2Keys` executes the callback on given keys of certain entries in index 2\n _loopBy2Keys(index0, key0, key1, callback) {\n let index1, index2, key2;\n if ((index1 = index0[key0]) && (index2 = index1[key1])) {\n for (key2 in index2)\n callback(key2);\n }\n }\n\n // ### `_countInIndex` counts matching quads in a three-layered index.\n // The index base is `index0` and the keys at each level are `key0`, `key1`, and `key2`.\n // Any of these keys can be undefined, which is interpreted as a wildcard.\n _countInIndex(index0, key0, key1, key2) {\n let count = 0, tmp, index1, index2;\n\n // If a key is specified, count only that part of index 0\n if (key0) (tmp = index0, index0 = {})[key0] = tmp[key0];\n for (const value0 in index0) {\n if (index1 = index0[value0]) {\n // If a key is specified, count only that part of index 1\n if (key1) (tmp = index1, index1 = {})[key1] = tmp[key1];\n for (const value1 in index1) {\n if (index2 = index1[value1]) {\n // If a key is specified, count the quad if it exists\n if (key2) (key2 in index2) && count++;\n // Otherwise, count all quads\n else count += Object.keys(index2).length;\n }\n }\n }\n }\n return count;\n }\n\n // ### `_getGraphs` returns an array with the given graph,\n // or all graphs if the argument is null or undefined.\n _getGraphs(graph) {\n graph = graph === '' ? 1 : (graph && (this._termToNumericId(graph) || -1));\n return typeof graph !== 'number' ? this._graphs : { [graph]: this._graphs[graph] };\n }\n\n // ### `_uniqueEntities` returns a function that accepts an entity ID\n // and passes the corresponding entity to callback if it hasn't occurred before.\n _uniqueEntities(callback) {\n const uniqueIds = Object.create(null);\n return id => {\n if (!(id in uniqueIds)) {\n uniqueIds[id] = true;\n callback(this._termFromId(this._entities[id], this._factory));\n }\n };\n }\n\n // ## Public methods\n\n // ### `add` adds the specified quad to the dataset.\n // Returns the dataset instance it was called on.\n // Existing quads, as defined in Quad.equals, will be ignored.\n add(quad) {\n this.addQuad(quad);\n return this;\n }\n\n // ### `addQuad` adds a new quad to the store.\n // Returns if the quad index has changed, if the quad did not already exist.\n addQuad(subject, predicate, object, graph) {\n // Shift arguments if a quad object is given instead of components\n if (!predicate)\n graph = subject.graph, object = subject.object,\n predicate = subject.predicate, subject = subject.subject;\n\n // Convert terms to internal string representation\n graph = graph ? this._termToNewNumericId(graph) : 1;\n\n // Find the graph that will contain the triple\n let graphItem = this._graphs[graph];\n // Create the graph if it doesn't exist yet\n if (!graphItem) {\n graphItem = this._graphs[graph] = { subjects: {}, predicates: {}, objects: {} };\n // Freezing a graph helps subsequent `add` performance,\n // and properties will never be modified anyway\n Object.freeze(graphItem);\n }\n\n // Since entities can often be long IRIs, we avoid storing them in every index.\n // Instead, we have a separate index that maps entities to numbers,\n // which are then used as keys in the other indexes.\n subject = this._termToNewNumericId(subject);\n predicate = this._termToNewNumericId(predicate);\n object = this._termToNewNumericId(object);\n\n if (!this._addToIndex(graphItem.subjects, subject, predicate, object))\n return false;\n this._addToIndex(graphItem.predicates, predicate, object, subject);\n this._addToIndex(graphItem.objects, object, subject, predicate);\n\n // The cached quad count is now invalid\n this._size = null;\n return true;\n }\n\n // ### `addQuads` adds multiple quads to the store\n addQuads(quads) {\n for (let i = 0; i < quads.length; i++)\n this.addQuad(quads[i]);\n }\n\n // ### `delete` removes the specified quad from the dataset.\n // Returns the dataset instance it was called on.\n delete(quad) {\n this.removeQuad(quad);\n return this;\n }\n\n // ### `has` determines whether a dataset includes a certain quad or quad pattern.\n has(subjectOrQuad, predicate, object, graph) {\n if (subjectOrQuad && subjectOrQuad.subject)\n ({ subject: subjectOrQuad, predicate, object, graph } = subjectOrQuad);\n return !this.readQuads(subjectOrQuad, predicate, object, graph).next().done;\n }\n\n // ### `import` adds a stream of quads to the store\n import(stream) {\n stream.on('data', quad => { this.addQuad(quad); });\n return stream;\n }\n\n // ### `removeQuad` removes a quad from the store if it exists\n removeQuad(subject, predicate, object, graph) {\n // Shift arguments if a quad object is given instead of components\n if (!predicate)\n ({ subject, predicate, object, graph } = subject);\n // Convert terms to internal string representation\n graph = graph ? this._termToNumericId(graph) : 1;\n\n // Find internal identifiers for all components\n // and verify the quad exists.\n const graphs = this._graphs;\n let graphItem, subjects, predicates;\n if (!(subject = subject && this._termToNumericId(subject)) || !(predicate = predicate && this._termToNumericId(predicate)) ||\n !(object = object && this._termToNumericId(object)) || !(graphItem = graphs[graph]) ||\n !(subjects = graphItem.subjects[subject]) ||\n !(predicates = subjects[predicate]) ||\n !(object in predicates))\n return false;\n\n // Remove it from all indexes\n this._removeFromIndex(graphItem.subjects, subject, predicate, object);\n this._removeFromIndex(graphItem.predicates, predicate, object, subject);\n this._removeFromIndex(graphItem.objects, object, subject, predicate);\n if (this._size !== null) this._size--;\n\n // Remove the graph if it is empty\n for (subject in graphItem.subjects) return true;\n delete graphs[graph];\n return true;\n }\n\n // ### `removeQuads` removes multiple quads from the store\n removeQuads(quads) {\n for (let i = 0; i < quads.length; i++)\n this.removeQuad(quads[i]);\n }\n\n // ### `remove` removes a stream of quads from the store\n remove(stream) {\n stream.on('data', quad => { this.removeQuad(quad); });\n return stream;\n }\n\n // ### `removeMatches` removes all matching quads from the store\n // Setting any field to `undefined` or `null` indicates a wildcard.\n removeMatches(subject, predicate, object, graph) {\n const stream = new readable_stream__WEBPACK_IMPORTED_MODULE_0__.Readable({ objectMode: true });\n\n const iterable = this.readQuads(subject, predicate, object, graph);\n stream._read = size => {\n while (--size >= 0) {\n const { done, value } = iterable.next();\n if (done) {\n stream.push(null);\n return;\n }\n stream.push(value);\n }\n };\n\n return this.remove(stream);\n }\n\n // ### `deleteGraph` removes all triples with the given graph from the store\n deleteGraph(graph) {\n return this.removeMatches(null, null, null, graph);\n }\n\n // ### `getQuads` returns an array of quads matching a pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n getQuads(subject, predicate, object, graph) {\n return [...this.readQuads(subject, predicate, object, graph)];\n }\n\n /**\n * `readQuads` returns a generator of quads matching a pattern.\n * Setting any field to `undefined` or `null` indicates a wildcard.\n * @deprecated Use `match` instead.\n */\n *readQuads(subject, predicate, object, graph) {\n const graphs = this._getGraphs(graph);\n let content, subjectId, predicateId, objectId;\n\n // Translate IRIs to internal index keys.\n if (subject && !(subjectId = this._termToNumericId(subject)) ||\n predicate && !(predicateId = this._termToNumericId(predicate)) ||\n object && !(objectId = this._termToNumericId(object)))\n return;\n\n for (const graphId in graphs) {\n // Only if the specified graph contains triples, there can be results\n if (content = graphs[graphId]) {\n // Choose the optimal index, based on what fields are present\n if (subjectId) {\n if (objectId)\n // If subject and object are given, the object index will be the fastest\n yield* this._findInIndex(content.objects, objectId, subjectId, predicateId,\n 'object', 'subject', 'predicate', graphId);\n else\n // If only subject and possibly predicate are given, the subject index will be the fastest\n yield* this._findInIndex(content.subjects, subjectId, predicateId, null,\n 'subject', 'predicate', 'object', graphId);\n }\n else if (predicateId)\n // If only predicate and possibly object are given, the predicate index will be the fastest\n yield* this._findInIndex(content.predicates, predicateId, objectId, null,\n 'predicate', 'object', 'subject', graphId);\n else if (objectId)\n // If only object is given, the object index will be the fastest\n yield* this._findInIndex(content.objects, objectId, null, null,\n 'object', 'subject', 'predicate', graphId);\n else\n // If nothing is given, iterate subjects and predicates first\n yield* this._findInIndex(content.subjects, null, null, null,\n 'subject', 'predicate', 'object', graphId);\n }\n }\n }\n\n // ### `match` returns a new dataset that is comprised of all quads in the current instance matching the given arguments.\n // The logic described in Quad Matching is applied for each quad in this dataset to check if it should be included in the output dataset.\n // Note: This method always returns a new DatasetCore, even if that dataset contains no quads.\n // Note: Since a DatasetCore is an unordered set, the order of the quads within the returned sequence is arbitrary.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n // For backwards compatibility, the object return also implements the Readable stream interface.\n match(subject, predicate, object, graph) {\n return new DatasetCoreAndReadableStream(this, subject, predicate, object, graph, { entityIndex: this._entityIndex });\n }\n\n // ### `countQuads` returns the number of quads matching a pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n countQuads(subject, predicate, object, graph) {\n const graphs = this._getGraphs(graph);\n let count = 0, content, subjectId, predicateId, objectId;\n\n // Translate IRIs to internal index keys.\n if (subject && !(subjectId = this._termToNumericId(subject)) ||\n predicate && !(predicateId = this._termToNumericId(predicate)) ||\n object && !(objectId = this._termToNumericId(object)))\n return 0;\n\n for (const graphId in graphs) {\n // Only if the specified graph contains triples, there can be results\n if (content = graphs[graphId]) {\n // Choose the optimal index, based on what fields are present\n if (subject) {\n if (object)\n // If subject and object are given, the object index will be the fastest\n count += this._countInIndex(content.objects, objectId, subjectId, predicateId);\n else\n // If only subject and possibly predicate are given, the subject index will be the fastest\n count += this._countInIndex(content.subjects, subjectId, predicateId, objectId);\n }\n else if (predicate) {\n // If only predicate and possibly object are given, the predicate index will be the fastest\n count += this._countInIndex(content.predicates, predicateId, objectId, subjectId);\n }\n else {\n // If only object is possibly given, the object index will be the fastest\n count += this._countInIndex(content.objects, objectId, subjectId, predicateId);\n }\n }\n }\n return count;\n }\n\n // ### `forEach` executes the callback on all quads.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n forEach(callback, subject, predicate, object, graph) {\n this.some(quad => {\n callback(quad, this);\n return false;\n }, subject, predicate, object, graph);\n }\n\n // ### `every` executes the callback on all quads,\n // and returns `true` if it returns truthy for all them.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n every(callback, subject, predicate, object, graph) {\n return !this.some(quad => !callback(quad, this), subject, predicate, object, graph);\n }\n\n // ### `some` executes the callback on all quads,\n // and returns `true` if it returns truthy for any of them.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n some(callback, subject, predicate, object, graph) {\n for (const quad of this.readQuads(subject, predicate, object, graph))\n if (callback(quad))\n return true;\n return false;\n }\n\n // ### `getSubjects` returns all subjects that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n getSubjects(predicate, object, graph) {\n const results = [];\n this.forSubjects(s => { results.push(s); }, predicate, object, graph);\n return results;\n }\n\n // ### `forSubjects` executes the callback on all subjects that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n forSubjects(callback, predicate, object, graph) {\n const graphs = this._getGraphs(graph);\n let content, predicateId, objectId;\n callback = this._uniqueEntities(callback);\n\n // Translate IRIs to internal index keys.\n if (predicate && !(predicateId = this._termToNumericId(predicate)) ||\n object && !(objectId = this._termToNumericId(object)))\n return;\n\n for (graph in graphs) {\n // Only if the specified graph contains triples, there can be results\n if (content = graphs[graph]) {\n // Choose optimal index based on which fields are wildcards\n if (predicateId) {\n if (objectId)\n // If predicate and object are given, the POS index is best.\n this._loopBy2Keys(content.predicates, predicateId, objectId, callback);\n else\n // If only predicate is given, the SPO index is best.\n this._loopByKey1(content.subjects, predicateId, callback);\n }\n else if (objectId)\n // If only object is given, the OSP index is best.\n this._loopByKey0(content.objects, objectId, callback);\n else\n // If no params given, iterate all the subjects\n this._loop(content.subjects, callback);\n }\n }\n }\n\n // ### `getPredicates` returns all predicates that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n getPredicates(subject, object, graph) {\n const results = [];\n this.forPredicates(p => { results.push(p); }, subject, object, graph);\n return results;\n }\n\n // ### `forPredicates` executes the callback on all predicates that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n forPredicates(callback, subject, object, graph) {\n const graphs = this._getGraphs(graph);\n let content, subjectId, objectId;\n callback = this._uniqueEntities(callback);\n\n // Translate IRIs to internal index keys.\n if (subject && !(subjectId = this._termToNumericId(subject)) ||\n object && !(objectId = this._termToNumericId(object)))\n return;\n\n for (graph in graphs) {\n // Only if the specified graph contains triples, there can be results\n if (content = graphs[graph]) {\n // Choose optimal index based on which fields are wildcards\n if (subjectId) {\n if (objectId)\n // If subject and object are given, the OSP index is best.\n this._loopBy2Keys(content.objects, objectId, subjectId, callback);\n else\n // If only subject is given, the SPO index is best.\n this._loopByKey0(content.subjects, subjectId, callback);\n }\n else if (objectId)\n // If only object is given, the POS index is best.\n this._loopByKey1(content.predicates, objectId, callback);\n else\n // If no params given, iterate all the predicates.\n this._loop(content.predicates, callback);\n }\n }\n }\n\n // ### `getObjects` returns all objects that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n getObjects(subject, predicate, graph) {\n const results = [];\n this.forObjects(o => { results.push(o); }, subject, predicate, graph);\n return results;\n }\n\n // ### `forObjects` executes the callback on all objects that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n forObjects(callback, subject, predicate, graph) {\n const graphs = this._getGraphs(graph);\n let content, subjectId, predicateId;\n callback = this._uniqueEntities(callback);\n\n // Translate IRIs to internal index keys.\n if (subject && !(subjectId = this._termToNumericId(subject)) ||\n predicate && !(predicateId = this._termToNumericId(predicate)))\n return;\n\n for (graph in graphs) {\n // Only if the specified graph contains triples, there can be results\n if (content = graphs[graph]) {\n // Choose optimal index based on which fields are wildcards\n if (subjectId) {\n if (predicateId)\n // If subject and predicate are given, the SPO index is best.\n this._loopBy2Keys(content.subjects, subjectId, predicateId, callback);\n else\n // If only subject is given, the OSP index is best.\n this._loopByKey1(content.objects, subjectId, callback);\n }\n else if (predicateId)\n // If only predicate is given, the POS index is best.\n this._loopByKey0(content.predicates, predicateId, callback);\n else\n // If no params given, iterate all the objects.\n this._loop(content.objects, callback);\n }\n }\n }\n\n // ### `getGraphs` returns all graphs that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n getGraphs(subject, predicate, object) {\n const results = [];\n this.forGraphs(g => { results.push(g); }, subject, predicate, object);\n return results;\n }\n\n // ### `forGraphs` executes the callback on all graphs that match the pattern.\n // Setting any field to `undefined` or `null` indicates a wildcard.\n forGraphs(callback, subject, predicate, object) {\n for (const graph in this._graphs) {\n this.some(quad => {\n callback(quad.graph);\n return true; // Halt iteration of some()\n }, subject, predicate, object, this._termFromId(this._entities[graph]));\n }\n }\n\n // ### `createBlankNode` creates a new blank node, returning its name\n createBlankNode(suggestedName) {\n return this._entityIndex.createBlankNode(suggestedName);\n }\n\n // ### `extractLists` finds and removes all list triples\n // and returns the items per list.\n extractLists({ remove = false, ignoreErrors = false } = {}) {\n const lists = {}; // has scalar keys so could be a simple Object\n const onError = ignoreErrors ? (() => true) :\n ((node, message) => { throw new Error(`${node.value} ${message}`); });\n\n // Traverse each list from its tail\n const tails = this.getQuads(null, _IRIs__WEBPACK_IMPORTED_MODULE_3__[\"default\"].rdf.rest, _IRIs__WEBPACK_IMPORTED_MODULE_3__[\"default\"].rdf.nil, null);\n const toRemove = remove ? [...tails] : [];\n tails.forEach(tailQuad => {\n const items = []; // the members found as objects of rdf:first quads\n let malformed = false; // signals whether the current list is malformed\n let head; // the head of the list (_:b1 in above example)\n let headPos; // set to subject or object when head is set\n const graph = tailQuad.graph; // make sure list is in exactly one graph\n\n // Traverse the list from tail to end\n let current = tailQuad.subject;\n while (current && !malformed) {\n const objectQuads = this.getQuads(null, null, current, null);\n const subjectQuads = this.getQuads(current, null, null, null);\n let quad, first = null, rest = null, parent = null;\n\n // Find the first and rest of this list node\n for (let i = 0; i < subjectQuads.length && !malformed; i++) {\n quad = subjectQuads[i];\n if (!quad.graph.equals(graph))\n malformed = onError(current, 'not confined to single graph');\n else if (head)\n malformed = onError(current, 'has non-list arcs out');\n\n // one rdf:first\n else if (quad.predicate.value === _IRIs__WEBPACK_IMPORTED_MODULE_3__[\"default\"].rdf.first) {\n if (first)\n malformed = onError(current, 'has multiple rdf:first arcs');\n else\n toRemove.push(first = quad);\n }\n\n // one rdf:rest\n else if (quad.predicate.value === _IRIs__WEBPACK_IMPORTED_MODULE_3__[\"default\"].rdf.rest) {\n if (rest)\n malformed = onError(current, 'has multiple rdf:rest arcs');\n else\n toRemove.push(rest = quad);\n }\n\n // alien triple\n else if (objectQuads.length)\n malformed = onError(current, 'can\\'t be subject and object');\n else {\n head = quad; // e.g. { (1 2 3) :p :o }\n headPos = 'subject';\n }\n }\n\n // { :s :p (1 2) } arrives here with no head\n // { (1 2) :p :o } arrives here with head set to the list.\n for (let i = 0; i < objectQuads.length && !malformed; ++i) {\n quad = objectQuads[i];\n if (head)\n malformed = onError(current, 'can\\'t have coreferences');\n // one rdf:rest\n else if (quad.predicate.value === _IRIs__WEBPACK_IMPORTED_MODULE_3__[\"default\"].rdf.rest) {\n if (parent)\n malformed = onError(current, 'has incoming rdf:rest arcs');\n else\n parent = quad;\n }\n else {\n head = quad; // e.g. { :s :p (1 2) }\n headPos = 'object';\n }\n }\n\n // Store the list item and continue with parent\n if (!first)\n malformed = onError(current, 'has no list head');\n else\n items.unshift(first.object);\n current = parent && parent.subject;\n }\n\n // Don't remove any quads if the list is malformed\n if (malformed)\n remove = false;\n // Store the list under the value of its head\n else if (head)\n lists[head[headPos].value] = items;\n });\n\n // Remove list quads if requested\n if (remove)\n this.removeQuads(toRemove);\n return lists;\n }\n\n /**\n * Returns `true` if the current dataset is a superset of the given dataset; in other words, returns `true` if\n * the given dataset is a subset of, i.e., is contained within, the current dataset.\n *\n * Blank Nodes will be normalized.\n */\n addAll(quads) {\n if (quads instanceof DatasetCoreAndReadableStream)\n quads = quads.filtered;\n\n if (Array.isArray(quads))\n this.addQuads(quads);\n else if (quads instanceof N3Store && quads._entityIndex === this._entityIndex) {\n if (quads._size !== 0) {\n this._graphs = merge(this._graphs, quads._graphs);\n this._size = null; // Invalidate the cached size\n }\n }\n else {\n for (const quad of quads)\n this.add(quad);\n }\n return this;\n }\n\n /**\n * Returns `true` if the current dataset is a superset of the given dataset; in other words, returns `true` if\n * the given dataset is a subset of, i.e., is contained within, the current dataset.\n *\n * Blank Nodes will be normalized.\n */\n contains(other) {\n if (other instanceof DatasetCoreAndReadableStream)\n other = other.filtered;\n\n if (other === this)\n return true;\n\n if (!(other instanceof N3Store) || this._entityIndex !== other._entityIndex)\n return other.every(quad => this.has(quad));\n\n const g1 = this._graphs, g2 = other._graphs;\n let s1, s2, p1, p2, o1;\n for (const graph in g2) {\n if (!(s1 = g1[graph])) return false;\n s1 = s1.subjects;\n for (const subject in (s2 = g2[graph].subjects)) {\n if (!(p1 = s1[subject])) return false;\n for (const predicate in (p2 = s2[subject])) {\n if (!(o1 = p1[predicate])) return false;\n for (const object in p2[predicate])\n if (!(object in o1)) return false;\n }\n }\n }\n return true;\n }\n\n /**\n * This method removes the quads in the current dataset that match the given arguments.\n *\n * The logic described in {@link https://rdf.js.org/dataset-spec/#quad-matching|Quad Matching} is applied for each\n * quad in this dataset, to select the quads which will be deleted.\n *\n * @param subject The optional exact subject to match.\n * @param predicate The optional exact predicate to match.\n * @param object The optional exact object to match.\n * @param graph The optional exact graph to match.\n */\n deleteMatches(subject, predicate, object, graph) {\n for (const quad of this.match(subject, predicate, object, graph))\n this.removeQuad(quad);\n return this;\n }\n\n /**\n * Returns a new dataset that contains all quads from the current dataset that are not included in the given dataset.\n */\n difference(other) {\n if (other && other instanceof DatasetCoreAndReadableStream)\n other = other.filtered;\n\n if (other === this)\n return new N3Store({ entityIndex: this._entityIndex });\n\n if ((other instanceof N3Store) && other._entityIndex === this._entityIndex) {\n const store = new N3Store({ entityIndex: this._entityIndex });\n const graphs = difference(this._graphs, other._graphs);\n if (graphs) {\n store._graphs = graphs;\n store._size = null;\n }\n return store;\n }\n\n return this.filter(quad => !other.has(quad));\n }\n\n /**\n * Returns true if the current dataset contains the same graph structure as the given dataset.\n *\n * Blank Nodes will be normalized.\n */\n equals(other) {\n if (other instanceof DatasetCoreAndReadableStream)\n other = other.filtered;\n\n return other === this || (this.size === other.size && this.contains(other));\n }\n\n /**\n * Creates a new dataset with all the quads that pass the test implemented by the provided `iteratee`.\n *\n * This method is aligned with Array.prototype.filter() in ECMAScript-262.\n */\n filter(iteratee) {\n const store = new N3Store({ entityIndex: this._entityIndex });\n for (const quad of this)\n if (iteratee(quad, this))\n store.add(quad);\n return store;\n }\n\n /**\n * Returns a new dataset containing all quads from the current dataset that are also included in the given dataset.\n */\n intersection(other) {\n if (other instanceof DatasetCoreAndReadableStream)\n other = other.filtered;\n\n if (other === this) {\n const store = new N3Store({ entityIndex: this._entityIndex });\n store._graphs = merge(Object.create(null), this._graphs);\n store._size = this._size;\n return store;\n }\n else if ((other instanceof N3Store) && this._entityIndex === other._entityIndex) {\n const store = new N3Store({ entityIndex: this._entityIndex });\n const graphs = intersect(other._graphs, this._graphs);\n if (graphs) {\n store._graphs = graphs;\n store._size = null;\n }\n return store;\n }\n\n return this.filter(quad => other.has(quad));\n }\n\n /**\n * Returns a new dataset containing all quads returned by applying `iteratee` to each quad in the current dataset.\n */\n map(iteratee) {\n const store = new N3Store({ entityIndex: this._entityIndex });\n for (const quad of this)\n store.add(iteratee(quad, this));\n return store;\n }\n\n /**\n * This method calls the `iteratee` method on each `quad` of the `Dataset`. The first time the `iteratee` method\n * is called, the `accumulator` value is the `initialValue`, or, if not given, equals the first quad of the `Dataset`.\n * The return value of each call to the `iteratee` method is used as the `accumulator` value for the next call.\n *\n * This method returns the return value of the last `iteratee` call.\n *\n * This method is aligned with `Array.prototype.reduce()` in ECMAScript-262.\n */\n reduce(callback, initialValue) {\n const iter = this.readQuads();\n let accumulator = initialValue === undefined ? iter.next().value : initialValue;\n for (const quad of iter)\n accumulator = callback(accumulator, quad, this);\n return accumulator;\n }\n\n /**\n * Returns the set of quads within the dataset as a host-language-native sequence, for example an `Array` in\n * ECMAScript-262.\n *\n * Since a `Dataset` is an unordered set, the order of the quads within the returned sequence is arbitrary.\n */\n toArray() {\n return this.getQuads();\n }\n\n /**\n * Returns an N-Quads string representation of the dataset, preprocessed with the\n * {@link https://json-ld.github.io/normalization/spec/|RDF Dataset Normalization} algorithm.\n */\n toCanonical() {\n throw new Error('not implemented');\n }\n\n /**\n * Returns a stream that contains all quads of the dataset.\n */\n toStream() {\n return this.match();\n }\n\n /**\n * Returns an N-Quads string representation of the dataset.\n *\n * No prior normalization is required, therefore the results for the same quads may vary depending on the `Dataset`\n * implementation.\n */\n toString() {\n return (new _N3Writer__WEBPACK_IMPORTED_MODULE_4__[\"default\"]()).quadsToString(this);\n }\n\n /**\n * Returns a new `Dataset` that is a concatenation of this dataset and the quads given as an argument.\n */\n union(quads) {\n const store = new N3Store({ entityIndex: this._entityIndex });\n store._graphs = merge(Object.create(null), this._graphs);\n store._size = this._size;\n\n store.addAll(quads);\n return store;\n }\n\n // ### Store is an iterable.\n // Can be used where iterables are expected: for...of loops, array spread operator,\n // `yield*`, and destructuring assignment (order is not guaranteed).\n *[Symbol.iterator]() {\n yield* this.readQuads();\n }\n}\n\n/**\n * Returns a subset of the `index` with that part of the index\n * matching the `ids` array. `ids` contains 3 elements that are\n * either numerical ids; or `null`.\n *\n * `false` is returned when there are no matching indices; this should\n * *not* be set as the value for an index.\n */\nfunction indexMatch(index, ids, depth = 0) {\n const ind = ids[depth];\n if (ind && !(ind in index))\n return false;\n\n let target = false;\n for (const key in (ind ? { [ind]: index[ind] } : index)) {\n const result = depth === 2 ? null : indexMatch(index[key], ids, depth + 1);\n\n if (result !== false) {\n target = target || Object.create(null);\n target[key] = result;\n }\n }\n return target;\n}\n\n/**\n * A class that implements both DatasetCore and Readable.\n */\nclass DatasetCoreAndReadableStream extends readable_stream__WEBPACK_IMPORTED_MODULE_0__.Readable {\n constructor(n3Store, subject, predicate, object, graph, options) {\n super({ objectMode: true });\n Object.assign(this, { n3Store, subject, predicate, object, graph, options });\n }\n\n get filtered() {\n if (!this._filtered) {\n const { n3Store, graph, object, predicate, subject } = this;\n const newStore = this._filtered = new N3Store({ factory: n3Store._factory, entityIndex: this.options.entityIndex });\n\n let subjectId, predicateId, objectId;\n\n // Translate IRIs to internal index keys.\n if (subject && !(subjectId = newStore._termToNumericId(subject)) ||\n predicate && !(predicateId = newStore._termToNumericId(predicate)) ||\n object && !(objectId = newStore._termToNumericId(object)))\n return newStore;\n\n const graphs = n3Store._getGraphs(graph);\n for (const graphKey in graphs) {\n let subjects, predicates, objects, content;\n if (content = graphs[graphKey]) {\n if (!subjectId && predicateId) {\n if (predicates = indexMatch(content.predicates, [predicateId, objectId, subjectId])) {\n subjects = indexMatch(content.subjects, [subjectId, predicateId, objectId]);\n objects = indexMatch(content.objects, [objectId, subjectId, predicateId]);\n }\n }\n else if (objectId) {\n if (objects = indexMatch(content.objects, [objectId, subjectId, predicateId])) {\n subjects = indexMatch(content.subjects, [subjectId, predicateId, objectId]);\n predicates = indexMatch(content.predicates, [predicateId, objectId, subjectId]);\n }\n }\n else if (subjects = indexMatch(content.subjects, [subjectId, predicateId, objectId])) {\n predicates = indexMatch(content.predicates, [predicateId, objectId, subjectId]);\n objects = indexMatch(content.objects, [objectId, subjectId, predicateId]);\n }\n\n if (subjects)\n newStore._graphs[graphKey] = { subjects, predicates, objects };\n }\n }\n newStore._size = null;\n }\n return this._filtered;\n }\n\n get size() {\n return this.filtered.size;\n }\n\n _read(size) {\n if (size > 0 && !this[ITERATOR])\n this[ITERATOR] = this[Symbol.iterator]();\n const iterable = this[ITERATOR];\n while (--size >= 0) {\n const { done, value } = iterable.next();\n if (done) {\n this.push(null);\n return;\n }\n this.push(value);\n }\n }\n\n addAll(quads) {\n return this.filtered.addAll(quads);\n }\n\n contains(other) {\n return this.filtered.contains(other);\n }\n\n deleteMatches(subject, predicate, object, graph) {\n return this.filtered.deleteMatches(subject, predicate, object, graph);\n }\n\n difference(other) {\n return this.filtered.difference(other);\n }\n\n equals(other) {\n return this.filtered.equals(other);\n }\n\n every(callback, subject, predicate, object, graph) {\n return this.filtered.every(callback, subject, predicate, object, graph);\n }\n\n filter(iteratee) {\n return this.filtered.filter(iteratee);\n }\n\n forEach(callback, subject, predicate, object, graph) {\n return this.filtered.forEach(callback, subject, predicate, object, graph);\n }\n\n import(stream) {\n return this.filtered.import(stream);\n }\n\n intersection(other) {\n return this.filtered.intersection(other);\n }\n\n map(iteratee) {\n return this.filtered.map(iteratee);\n }\n\n some(callback, subject, predicate, object, graph) {\n return this.filtered.some(callback, subject, predicate, object, graph);\n }\n\n toCanonical() {\n return this.filtered.toCanonical();\n }\n\n toStream() {\n return this._filtered ?\n this._filtered.toStream()\n : this.n3Store.match(this.subject, this.predicate, this.object, this.graph);\n }\n\n union(quads) {\n return this._filtered ?\n this._filtered.union(quads)\n : this.n3Store.match(this.subject, this.predicate, this.object, this.graph).addAll(quads);\n }\n\n toArray() {\n return this._filtered ? this._filtered.toArray() : this.n3Store.getQuads(this.subject, this.predicate, this.object, this.graph);\n }\n\n reduce(callback, initialValue) {\n return this.filtered.reduce(callback, initialValue);\n }\n\n toString() {\n return (new _N3Writer__WEBPACK_IMPORTED_MODULE_4__[\"default\"]()).quadsToString(this);\n }\n\n add(quad) {\n return this.filtered.add(quad);\n }\n\n delete(quad) {\n return this.filtered.delete(quad);\n }\n\n has(quad) {\n return this.filtered.has(quad);\n }\n\n match(subject, predicate, object, graph) {\n return new DatasetCoreAndReadableStream(this.filtered, subject, predicate, object, graph, this.options);\n }\n\n *[Symbol.iterator]() {\n yield* this._filtered || this.n3Store.readQuads(this.subject, this.predicate, this.object, this.graph);\n }\n}\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/N3Store.js?");
139
+
140
+ /***/ }),
141
+
142
+ /***/ "./node_modules/n3/src/N3StoreFactory.js":
143
+ /*!***********************************************!*\
144
+ !*** ./node_modules/n3/src/N3StoreFactory.js ***!
145
+ \***********************************************/
146
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
147
+
148
+ "use strict";
149
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ N3DatasetCoreFactory)\n/* harmony export */ });\n/* harmony import */ var _N3Store__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./N3Store */ \"./node_modules/n3/src/N3Store.js\");\n\n\nclass N3DatasetCoreFactory {\n dataset(quads) {\n return new _N3Store__WEBPACK_IMPORTED_MODULE_0__[\"default\"](quads);\n }\n}\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/N3StoreFactory.js?");
128
150
 
129
151
  /***/ }),
130
152
 
@@ -135,7 +157,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
135
157
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
136
158
 
137
159
  "use strict";
138
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ N3StreamParser)\n/* harmony export */ });\n/* harmony import */ var _N3Parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./N3Parser */ \"./node_modules/n3/src/N3Parser.js\");\n/* harmony import */ var readable_stream__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! readable-stream */ \"./node_modules/readable-stream/lib/ours/browser.js\");\n/* harmony import */ var readable_stream__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(readable_stream__WEBPACK_IMPORTED_MODULE_0__);\n// **N3StreamParser** parses a text stream into a quad stream.\n\n\n\n// ## Constructor\nclass N3StreamParser extends readable_stream__WEBPACK_IMPORTED_MODULE_0__.Transform {\n constructor(options) {\n super({ decodeStrings: true });\n this._readableState.objectMode = true;\n\n // Set up parser with dummy stream to obtain `data` and `end` callbacks\n const parser = new _N3Parser__WEBPACK_IMPORTED_MODULE_1__[\"default\"](options);\n let onData, onEnd;\n parser.parse({\n on: (event, callback) => {\n switch (event) {\n case 'data': onData = callback; break;\n case 'end': onEnd = callback; break;\n }\n },\n },\n // Handle quads by pushing them down the pipeline\n (error, quad) => { error && this.emit('error', error) || quad && this.push(quad); },\n // Emit prefixes through the `prefix` event\n (prefix, uri) => { this.emit('prefix', prefix, uri); }\n );\n\n // Implement Transform methods through parser callbacks\n this._transform = (chunk, encoding, done) => { onData(chunk); done(); };\n this._flush = done => { onEnd(); done(); };\n }\n\n // ### Parses a stream of strings\n import(stream) {\n stream.on('data', chunk => { this.write(chunk); });\n stream.on('end', () => { this.end(); });\n stream.on('error', error => { this.emit('error', error); });\n return this;\n }\n}\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/N3StreamParser.js?");
160
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ N3StreamParser)\n/* harmony export */ });\n/* harmony import */ var readable_stream__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! readable-stream */ \"./node_modules/readable-stream/lib/ours/browser.js\");\n/* harmony import */ var readable_stream__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(readable_stream__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _N3Parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./N3Parser */ \"./node_modules/n3/src/N3Parser.js\");\n// **N3StreamParser** parses a text stream into a quad stream.\n\n\n\n// ## Constructor\nclass N3StreamParser extends readable_stream__WEBPACK_IMPORTED_MODULE_0__.Transform {\n constructor(options) {\n super({ decodeStrings: true });\n this._readableState.objectMode = true;\n\n // Set up parser with dummy stream to obtain `data` and `end` callbacks\n const parser = new _N3Parser__WEBPACK_IMPORTED_MODULE_1__[\"default\"](options);\n let onData, onEnd;\n\n const callbacks = {\n // Handle quads by pushing them down the pipeline\n onQuad: (error, quad) => { error && this.emit('error', error) || quad && this.push(quad); },\n // Emit prefixes through the `prefix` event\n onPrefix: (prefix, uri) => { this.emit('prefix', prefix, uri); },\n };\n\n if (options && options.comments)\n callbacks.onComment = comment => { this.emit('comment', comment); };\n\n parser.parse({\n on: (event, callback) => {\n switch (event) {\n case 'data': onData = callback; break;\n case 'end': onEnd = callback; break;\n }\n },\n }, callbacks);\n\n // Implement Transform methods through parser callbacks\n this._transform = (chunk, encoding, done) => { onData(chunk); done(); };\n this._flush = done => { onEnd(); done(); };\n }\n\n // ### Parses a stream of strings\n import(stream) {\n stream.on('data', chunk => { this.write(chunk); });\n stream.on('end', () => { this.end(); });\n stream.on('error', error => { this.emit('error', error); });\n return this;\n }\n}\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/N3StreamParser.js?");
139
161
 
140
162
  /***/ }),
141
163
 
@@ -168,7 +190,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
168
190
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
169
191
 
170
192
  "use strict";
171
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ N3Writer)\n/* harmony export */ });\n/* harmony import */ var _IRIs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./IRIs */ \"./node_modules/n3/src/IRIs.js\");\n/* harmony import */ var _N3DataFactory__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./N3DataFactory */ \"./node_modules/n3/src/N3DataFactory.js\");\n/* harmony import */ var _N3Util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./N3Util */ \"./node_modules/n3/src/N3Util.js\");\n// **N3Writer** writes N3 documents.\n\n\n\n\nconst DEFAULTGRAPH = _N3DataFactory__WEBPACK_IMPORTED_MODULE_0__[\"default\"].defaultGraph();\n\nconst { rdf, xsd } = _IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"];\n\n// Characters in literals that require escaping\nconst escape = /[\"\\\\\\t\\n\\r\\b\\f\\u0000-\\u0019\\ud800-\\udbff]/,\n escapeAll = /[\"\\\\\\t\\n\\r\\b\\f\\u0000-\\u0019]|[\\ud800-\\udbff][\\udc00-\\udfff]/g,\n escapedCharacters = {\n '\\\\': '\\\\\\\\', '\"': '\\\\\"', '\\t': '\\\\t',\n '\\n': '\\\\n', '\\r': '\\\\r', '\\b': '\\\\b', '\\f': '\\\\f',\n };\n\n// ## Placeholder class to represent already pretty-printed terms\nclass SerializedTerm extends _N3DataFactory__WEBPACK_IMPORTED_MODULE_0__.Term {\n // Pretty-printed nodes are not equal to any other node\n // (e.g., [] does not equal [])\n equals(other) {\n return other === this;\n }\n}\n\n// ## Constructor\nclass N3Writer {\n constructor(outputStream, options) {\n // ### `_prefixRegex` matches a prefixed name or IRI that begins with one of the added prefixes\n this._prefixRegex = /$0^/;\n\n // Shift arguments if the first argument is not a stream\n if (outputStream && typeof outputStream.write !== 'function')\n options = outputStream, outputStream = null;\n options = options || {};\n this._lists = options.lists;\n\n // If no output stream given, send the output as string through the end callback\n if (!outputStream) {\n let output = '';\n this._outputStream = {\n write(chunk, encoding, done) { output += chunk; done && done(); },\n end: done => { done && done(null, output); },\n };\n this._endStream = true;\n }\n else {\n this._outputStream = outputStream;\n this._endStream = options.end === undefined ? true : !!options.end;\n }\n\n // Initialize writer, depending on the format\n this._subject = null;\n if (!(/triple|quad/i).test(options.format)) {\n this._lineMode = false;\n this._graph = DEFAULTGRAPH;\n this._prefixIRIs = Object.create(null);\n options.prefixes && this.addPrefixes(options.prefixes);\n if (options.baseIRI) {\n this._baseMatcher = new RegExp(`^${escapeRegex(options.baseIRI)\n }${options.baseIRI.endsWith('/') ? '' : '[#?]'}`);\n this._baseLength = options.baseIRI.length;\n }\n }\n else {\n this._lineMode = true;\n this._writeQuad = this._writeQuadLine;\n }\n }\n\n // ## Private methods\n\n // ### Whether the current graph is the default graph\n get _inDefaultGraph() {\n return DEFAULTGRAPH.equals(this._graph);\n }\n\n // ### `_write` writes the argument to the output stream\n _write(string, callback) {\n this._outputStream.write(string, 'utf8', callback);\n }\n\n // ### `_writeQuad` writes the quad to the output stream\n _writeQuad(subject, predicate, object, graph, done) {\n try {\n // Write the graph's label if it has changed\n if (!graph.equals(this._graph)) {\n // Close the previous graph and start the new one\n this._write((this._subject === null ? '' : (this._inDefaultGraph ? '.\\n' : '\\n}\\n')) +\n (DEFAULTGRAPH.equals(graph) ? '' : `${this._encodeIriOrBlank(graph)} {\\n`));\n this._graph = graph;\n this._subject = null;\n }\n // Don't repeat the subject if it's the same\n if (subject.equals(this._subject)) {\n // Don't repeat the predicate if it's the same\n if (predicate.equals(this._predicate))\n this._write(`, ${this._encodeObject(object)}`, done);\n // Same subject, different predicate\n else\n this._write(`;\\n ${\n this._encodePredicate(this._predicate = predicate)} ${\n this._encodeObject(object)}`, done);\n }\n // Different subject; write the whole quad\n else\n this._write(`${(this._subject === null ? '' : '.\\n') +\n this._encodeSubject(this._subject = subject)} ${\n this._encodePredicate(this._predicate = predicate)} ${\n this._encodeObject(object)}`, done);\n }\n catch (error) { done && done(error); }\n }\n\n // ### `_writeQuadLine` writes the quad to the output stream as a single line\n _writeQuadLine(subject, predicate, object, graph, done) {\n // Write the quad without prefixes\n delete this._prefixMatch;\n this._write(this.quadToString(subject, predicate, object, graph), done);\n }\n\n // ### `quadToString` serializes a quad as a string\n quadToString(subject, predicate, object, graph) {\n return `${this._encodeSubject(subject)} ${\n this._encodeIriOrBlank(predicate)} ${\n this._encodeObject(object)\n }${graph && graph.value ? ` ${this._encodeIriOrBlank(graph)} .\\n` : ' .\\n'}`;\n }\n\n // ### `quadsToString` serializes an array of quads as a string\n quadsToString(quads) {\n return quads.map(t => {\n return this.quadToString(t.subject, t.predicate, t.object, t.graph);\n }).join('');\n }\n\n // ### `_encodeSubject` represents a subject\n _encodeSubject(entity) {\n return entity.termType === 'Quad' ?\n this._encodeQuad(entity) : this._encodeIriOrBlank(entity);\n }\n\n // ### `_encodeIriOrBlank` represents an IRI or blank node\n _encodeIriOrBlank(entity) {\n // A blank node or list is represented as-is\n if (entity.termType !== 'NamedNode') {\n // If it is a list head, pretty-print it\n if (this._lists && (entity.value in this._lists))\n entity = this.list(this._lists[entity.value]);\n return 'id' in entity ? entity.id : `_:${entity.value}`;\n }\n let iri = entity.value;\n // Use relative IRIs if requested and possible\n if (this._baseMatcher && this._baseMatcher.test(iri))\n iri = iri.substr(this._baseLength);\n // Escape special characters\n if (escape.test(iri))\n iri = iri.replace(escapeAll, characterReplacer);\n // Try to represent the IRI as prefixed name\n const prefixMatch = this._prefixRegex.exec(iri);\n return !prefixMatch ? `<${iri}>` :\n (!prefixMatch[1] ? iri : this._prefixIRIs[prefixMatch[1]] + prefixMatch[2]);\n }\n\n // ### `_encodeLiteral` represents a literal\n _encodeLiteral(literal) {\n // Escape special characters\n let value = literal.value;\n if (escape.test(value))\n value = value.replace(escapeAll, characterReplacer);\n\n // Write a language-tagged literal\n if (literal.language)\n return `\"${value}\"@${literal.language}`;\n\n // Write dedicated literals per data type\n if (this._lineMode) {\n // Only abbreviate strings in N-Triples or N-Quads\n if (literal.datatype.value === xsd.string)\n return `\"${value}\"`;\n }\n else {\n // Use common datatype abbreviations in Turtle or TriG\n switch (literal.datatype.value) {\n case xsd.string:\n return `\"${value}\"`;\n case xsd.boolean:\n if (value === 'true' || value === 'false')\n return value;\n break;\n case xsd.integer:\n if (/^[+-]?\\d+$/.test(value))\n return value;\n break;\n case xsd.decimal:\n if (/^[+-]?\\d*\\.\\d+$/.test(value))\n return value;\n break;\n case xsd.double:\n if (/^[+-]?(?:\\d+\\.\\d*|\\.?\\d+)[eE][+-]?\\d+$/.test(value))\n return value;\n break;\n }\n }\n\n // Write a regular datatyped literal\n return `\"${value}\"^^${this._encodeIriOrBlank(literal.datatype)}`;\n }\n\n // ### `_encodePredicate` represents a predicate\n _encodePredicate(predicate) {\n return predicate.value === rdf.type ? 'a' : this._encodeIriOrBlank(predicate);\n }\n\n // ### `_encodeObject` represents an object\n _encodeObject(object) {\n switch (object.termType) {\n case 'Quad':\n return this._encodeQuad(object);\n case 'Literal':\n return this._encodeLiteral(object);\n default:\n return this._encodeIriOrBlank(object);\n }\n }\n\n // ### `_encodeQuad` encodes an RDF* quad\n _encodeQuad({ subject, predicate, object, graph }) {\n return `<<${\n this._encodeSubject(subject)} ${\n this._encodePredicate(predicate)} ${\n this._encodeObject(object)}${\n (0,_N3Util__WEBPACK_IMPORTED_MODULE_2__.isDefaultGraph)(graph) ? '' : ` ${this._encodeIriOrBlank(graph)}`}>>`;\n }\n\n // ### `_blockedWrite` replaces `_write` after the writer has been closed\n _blockedWrite() {\n throw new Error('Cannot write because the writer has been closed.');\n }\n\n // ### `addQuad` adds the quad to the output stream\n addQuad(subject, predicate, object, graph, done) {\n // The quad was given as an object, so shift parameters\n if (object === undefined)\n this._writeQuad(subject.subject, subject.predicate, subject.object, subject.graph, predicate);\n // The optional `graph` parameter was not provided\n else if (typeof graph === 'function')\n this._writeQuad(subject, predicate, object, DEFAULTGRAPH, graph);\n // The `graph` parameter was provided\n else\n this._writeQuad(subject, predicate, object, graph || DEFAULTGRAPH, done);\n }\n\n // ### `addQuads` adds the quads to the output stream\n addQuads(quads) {\n for (let i = 0; i < quads.length; i++)\n this.addQuad(quads[i]);\n }\n\n // ### `addPrefix` adds the prefix to the output stream\n addPrefix(prefix, iri, done) {\n const prefixes = {};\n prefixes[prefix] = iri;\n this.addPrefixes(prefixes, done);\n }\n\n // ### `addPrefixes` adds the prefixes to the output stream\n addPrefixes(prefixes, done) {\n // Ignore prefixes if not supported by the serialization\n if (!this._prefixIRIs)\n return done && done();\n\n // Write all new prefixes\n let hasPrefixes = false;\n for (let prefix in prefixes) {\n let iri = prefixes[prefix];\n if (typeof iri !== 'string')\n iri = iri.value;\n hasPrefixes = true;\n // Finish a possible pending quad\n if (this._subject !== null) {\n this._write(this._inDefaultGraph ? '.\\n' : '\\n}\\n');\n this._subject = null, this._graph = '';\n }\n // Store and write the prefix\n this._prefixIRIs[iri] = (prefix += ':');\n this._write(`@prefix ${prefix} <${iri}>.\\n`);\n }\n // Recreate the prefix matcher\n if (hasPrefixes) {\n let IRIlist = '', prefixList = '';\n for (const prefixIRI in this._prefixIRIs) {\n IRIlist += IRIlist ? `|${prefixIRI}` : prefixIRI;\n prefixList += (prefixList ? '|' : '') + this._prefixIRIs[prefixIRI];\n }\n IRIlist = escapeRegex(IRIlist, /[\\]\\/\\(\\)\\*\\+\\?\\.\\\\\\$]/g, '\\\\$&');\n this._prefixRegex = new RegExp(`^(?:${prefixList})[^\\/]*$|` +\n `^(${IRIlist})([_a-zA-Z][\\\\-_a-zA-Z0-9]*)$`);\n }\n // End a prefix block with a newline\n this._write(hasPrefixes ? '\\n' : '', done);\n }\n\n // ### `blank` creates a blank node with the given content\n blank(predicate, object) {\n let children = predicate, child, length;\n // Empty blank node\n if (predicate === undefined)\n children = [];\n // Blank node passed as blank(Term(\"predicate\"), Term(\"object\"))\n else if (predicate.termType)\n children = [{ predicate: predicate, object: object }];\n // Blank node passed as blank({ predicate: predicate, object: object })\n else if (!('length' in predicate))\n children = [predicate];\n\n switch (length = children.length) {\n // Generate an empty blank node\n case 0:\n return new SerializedTerm('[]');\n // Generate a non-nested one-triple blank node\n case 1:\n child = children[0];\n if (!(child.object instanceof SerializedTerm))\n return new SerializedTerm(`[ ${this._encodePredicate(child.predicate)} ${\n this._encodeObject(child.object)} ]`);\n // Generate a multi-triple or nested blank node\n default:\n let contents = '[';\n // Write all triples in order\n for (let i = 0; i < length; i++) {\n child = children[i];\n // Write only the object is the predicate is the same as the previous\n if (child.predicate.equals(predicate))\n contents += `, ${this._encodeObject(child.object)}`;\n // Otherwise, write the predicate and the object\n else {\n contents += `${(i ? ';\\n ' : '\\n ') +\n this._encodePredicate(child.predicate)} ${\n this._encodeObject(child.object)}`;\n predicate = child.predicate;\n }\n }\n return new SerializedTerm(`${contents}\\n]`);\n }\n }\n\n // ### `list` creates a list node with the given content\n list(elements) {\n const length = elements && elements.length || 0, contents = new Array(length);\n for (let i = 0; i < length; i++)\n contents[i] = this._encodeObject(elements[i]);\n return new SerializedTerm(`(${contents.join(' ')})`);\n }\n\n // ### `end` signals the end of the output stream\n end(done) {\n // Finish a possible pending quad\n if (this._subject !== null) {\n this._write(this._inDefaultGraph ? '.\\n' : '\\n}\\n');\n this._subject = null;\n }\n // Disallow further writing\n this._write = this._blockedWrite;\n\n // Try to end the underlying stream, ensuring done is called exactly one time\n let singleDone = done && ((error, result) => { singleDone = null, done(error, result); });\n if (this._endStream) {\n try { return this._outputStream.end(singleDone); }\n catch (error) { /* error closing stream */ }\n }\n singleDone && singleDone();\n }\n}\n\n// Replaces a character by its escaped version\nfunction characterReplacer(character) {\n // Replace a single character by its escaped version\n let result = escapedCharacters[character];\n if (result === undefined) {\n // Replace a single character with its 4-bit unicode escape sequence\n if (character.length === 1) {\n result = character.charCodeAt(0).toString(16);\n result = '\\\\u0000'.substr(0, 6 - result.length) + result;\n }\n // Replace a surrogate pair with its 8-bit unicode escape sequence\n else {\n result = ((character.charCodeAt(0) - 0xD800) * 0x400 +\n character.charCodeAt(1) + 0x2400).toString(16);\n result = '\\\\U00000000'.substr(0, 10 - result.length) + result;\n }\n }\n return result;\n}\n\nfunction escapeRegex(regex) {\n return regex.replace(/[\\]\\/\\(\\)\\*\\+\\?\\.\\\\\\$]/g, '\\\\$&');\n}\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/N3Writer.js?");
193
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ N3Writer)\n/* harmony export */ });\n/* harmony import */ var _IRIs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./IRIs */ \"./node_modules/n3/src/IRIs.js\");\n/* harmony import */ var _N3DataFactory__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./N3DataFactory */ \"./node_modules/n3/src/N3DataFactory.js\");\n/* harmony import */ var _N3Util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./N3Util */ \"./node_modules/n3/src/N3Util.js\");\n// **N3Writer** writes N3 documents.\n\n\n\n\nconst DEFAULTGRAPH = _N3DataFactory__WEBPACK_IMPORTED_MODULE_0__[\"default\"].defaultGraph();\n\nconst { rdf, xsd } = _IRIs__WEBPACK_IMPORTED_MODULE_1__[\"default\"];\n\n// Characters in literals that require escaping\nconst escape = /[\"\\\\\\t\\n\\r\\b\\f\\u0000-\\u0019\\ud800-\\udbff]/,\n escapeAll = /[\"\\\\\\t\\n\\r\\b\\f\\u0000-\\u0019]|[\\ud800-\\udbff][\\udc00-\\udfff]/g,\n escapedCharacters = {\n '\\\\': '\\\\\\\\', '\"': '\\\\\"', '\\t': '\\\\t',\n '\\n': '\\\\n', '\\r': '\\\\r', '\\b': '\\\\b', '\\f': '\\\\f',\n };\n\n// ## Placeholder class to represent already pretty-printed terms\nclass SerializedTerm extends _N3DataFactory__WEBPACK_IMPORTED_MODULE_0__.Term {\n // Pretty-printed nodes are not equal to any other node\n // (e.g., [] does not equal [])\n equals(other) {\n return other === this;\n }\n}\n\n// ## Constructor\nclass N3Writer {\n constructor(outputStream, options) {\n // ### `_prefixRegex` matches a prefixed name or IRI that begins with one of the added prefixes\n this._prefixRegex = /$0^/;\n\n // Shift arguments if the first argument is not a stream\n if (outputStream && typeof outputStream.write !== 'function')\n options = outputStream, outputStream = null;\n options = options || {};\n this._lists = options.lists;\n\n // If no output stream given, send the output as string through the end callback\n if (!outputStream) {\n let output = '';\n this._outputStream = {\n write(chunk, encoding, done) { output += chunk; done && done(); },\n end: done => { done && done(null, output); },\n };\n this._endStream = true;\n }\n else {\n this._outputStream = outputStream;\n this._endStream = options.end === undefined ? true : !!options.end;\n }\n\n // Initialize writer, depending on the format\n this._subject = null;\n if (!(/triple|quad/i).test(options.format)) {\n this._lineMode = false;\n this._graph = DEFAULTGRAPH;\n this._prefixIRIs = Object.create(null);\n options.prefixes && this.addPrefixes(options.prefixes);\n if (options.baseIRI) {\n this._baseMatcher = new RegExp(`^${escapeRegex(options.baseIRI)\n }${options.baseIRI.endsWith('/') ? '' : '[#?]'}`);\n this._baseLength = options.baseIRI.length;\n }\n }\n else {\n this._lineMode = true;\n this._writeQuad = this._writeQuadLine;\n }\n }\n\n // ## Private methods\n\n // ### Whether the current graph is the default graph\n get _inDefaultGraph() {\n return DEFAULTGRAPH.equals(this._graph);\n }\n\n // ### `_write` writes the argument to the output stream\n _write(string, callback) {\n this._outputStream.write(string, 'utf8', callback);\n }\n\n // ### `_writeQuad` writes the quad to the output stream\n _writeQuad(subject, predicate, object, graph, done) {\n try {\n // Write the graph's label if it has changed\n if (!graph.equals(this._graph)) {\n // Close the previous graph and start the new one\n this._write((this._subject === null ? '' : (this._inDefaultGraph ? '.\\n' : '\\n}\\n')) +\n (DEFAULTGRAPH.equals(graph) ? '' : `${this._encodeIriOrBlank(graph)} {\\n`));\n this._graph = graph;\n this._subject = null;\n }\n // Don't repeat the subject if it's the same\n if (subject.equals(this._subject)) {\n // Don't repeat the predicate if it's the same\n if (predicate.equals(this._predicate))\n this._write(`, ${this._encodeObject(object)}`, done);\n // Same subject, different predicate\n else\n this._write(`;\\n ${\n this._encodePredicate(this._predicate = predicate)} ${\n this._encodeObject(object)}`, done);\n }\n // Different subject; write the whole quad\n else\n this._write(`${(this._subject === null ? '' : '.\\n') +\n this._encodeSubject(this._subject = subject)} ${\n this._encodePredicate(this._predicate = predicate)} ${\n this._encodeObject(object)}`, done);\n }\n catch (error) { done && done(error); }\n }\n\n // ### `_writeQuadLine` writes the quad to the output stream as a single line\n _writeQuadLine(subject, predicate, object, graph, done) {\n // Write the quad without prefixes\n delete this._prefixMatch;\n this._write(this.quadToString(subject, predicate, object, graph), done);\n }\n\n // ### `quadToString` serializes a quad as a string\n quadToString(subject, predicate, object, graph) {\n return `${this._encodeSubject(subject)} ${\n this._encodeIriOrBlank(predicate)} ${\n this._encodeObject(object)\n }${graph && graph.value ? ` ${this._encodeIriOrBlank(graph)} .\\n` : ' .\\n'}`;\n }\n\n // ### `quadsToString` serializes an array of quads as a string\n quadsToString(quads) {\n let quadsString = '';\n for (const quad of quads)\n quadsString += this.quadToString(quad.subject, quad.predicate, quad.object, quad.graph);\n return quadsString;\n }\n\n // ### `_encodeSubject` represents a subject\n _encodeSubject(entity) {\n return entity.termType === 'Quad' ?\n this._encodeQuad(entity) : this._encodeIriOrBlank(entity);\n }\n\n // ### `_encodeIriOrBlank` represents an IRI or blank node\n _encodeIriOrBlank(entity) {\n // A blank node or list is represented as-is\n if (entity.termType !== 'NamedNode') {\n // If it is a list head, pretty-print it\n if (this._lists && (entity.value in this._lists))\n entity = this.list(this._lists[entity.value]);\n return 'id' in entity ? entity.id : `_:${entity.value}`;\n }\n let iri = entity.value;\n // Use relative IRIs if requested and possible\n if (this._baseMatcher && this._baseMatcher.test(iri))\n iri = iri.substr(this._baseLength);\n // Escape special characters\n if (escape.test(iri))\n iri = iri.replace(escapeAll, characterReplacer);\n // Try to represent the IRI as prefixed name\n const prefixMatch = this._prefixRegex.exec(iri);\n return !prefixMatch ? `<${iri}>` :\n (!prefixMatch[1] ? iri : this._prefixIRIs[prefixMatch[1]] + prefixMatch[2]);\n }\n\n // ### `_encodeLiteral` represents a literal\n _encodeLiteral(literal) {\n // Escape special characters\n let value = literal.value;\n if (escape.test(value))\n value = value.replace(escapeAll, characterReplacer);\n\n // Write a language-tagged literal\n if (literal.language)\n return `\"${value}\"@${literal.language}`;\n\n // Write dedicated literals per data type\n if (this._lineMode) {\n // Only abbreviate strings in N-Triples or N-Quads\n if (literal.datatype.value === xsd.string)\n return `\"${value}\"`;\n }\n else {\n // Use common datatype abbreviations in Turtle or TriG\n switch (literal.datatype.value) {\n case xsd.string:\n return `\"${value}\"`;\n case xsd.boolean:\n if (value === 'true' || value === 'false')\n return value;\n break;\n case xsd.integer:\n if (/^[+-]?\\d+$/.test(value))\n return value;\n break;\n case xsd.decimal:\n if (/^[+-]?\\d*\\.\\d+$/.test(value))\n return value;\n break;\n case xsd.double:\n if (/^[+-]?(?:\\d+\\.\\d*|\\.?\\d+)[eE][+-]?\\d+$/.test(value))\n return value;\n break;\n }\n }\n\n // Write a regular datatyped literal\n return `\"${value}\"^^${this._encodeIriOrBlank(literal.datatype)}`;\n }\n\n // ### `_encodePredicate` represents a predicate\n _encodePredicate(predicate) {\n return predicate.value === rdf.type ? 'a' : this._encodeIriOrBlank(predicate);\n }\n\n // ### `_encodeObject` represents an object\n _encodeObject(object) {\n switch (object.termType) {\n case 'Quad':\n return this._encodeQuad(object);\n case 'Literal':\n return this._encodeLiteral(object);\n default:\n return this._encodeIriOrBlank(object);\n }\n }\n\n // ### `_encodeQuad` encodes an RDF-star quad\n _encodeQuad({ subject, predicate, object, graph }) {\n return `<<${\n this._encodeSubject(subject)} ${\n this._encodePredicate(predicate)} ${\n this._encodeObject(object)}${\n (0,_N3Util__WEBPACK_IMPORTED_MODULE_2__.isDefaultGraph)(graph) ? '' : ` ${this._encodeIriOrBlank(graph)}`}>>`;\n }\n\n // ### `_blockedWrite` replaces `_write` after the writer has been closed\n _blockedWrite() {\n throw new Error('Cannot write because the writer has been closed.');\n }\n\n // ### `addQuad` adds the quad to the output stream\n addQuad(subject, predicate, object, graph, done) {\n // The quad was given as an object, so shift parameters\n if (object === undefined)\n this._writeQuad(subject.subject, subject.predicate, subject.object, subject.graph, predicate);\n // The optional `graph` parameter was not provided\n else if (typeof graph === 'function')\n this._writeQuad(subject, predicate, object, DEFAULTGRAPH, graph);\n // The `graph` parameter was provided\n else\n this._writeQuad(subject, predicate, object, graph || DEFAULTGRAPH, done);\n }\n\n // ### `addQuads` adds the quads to the output stream\n addQuads(quads) {\n for (let i = 0; i < quads.length; i++)\n this.addQuad(quads[i]);\n }\n\n // ### `addPrefix` adds the prefix to the output stream\n addPrefix(prefix, iri, done) {\n const prefixes = {};\n prefixes[prefix] = iri;\n this.addPrefixes(prefixes, done);\n }\n\n // ### `addPrefixes` adds the prefixes to the output stream\n addPrefixes(prefixes, done) {\n // Ignore prefixes if not supported by the serialization\n if (!this._prefixIRIs)\n return done && done();\n\n // Write all new prefixes\n let hasPrefixes = false;\n for (let prefix in prefixes) {\n let iri = prefixes[prefix];\n if (typeof iri !== 'string')\n iri = iri.value;\n hasPrefixes = true;\n // Finish a possible pending quad\n if (this._subject !== null) {\n this._write(this._inDefaultGraph ? '.\\n' : '\\n}\\n');\n this._subject = null, this._graph = '';\n }\n // Store and write the prefix\n this._prefixIRIs[iri] = (prefix += ':');\n this._write(`@prefix ${prefix} <${iri}>.\\n`);\n }\n // Recreate the prefix matcher\n if (hasPrefixes) {\n let IRIlist = '', prefixList = '';\n for (const prefixIRI in this._prefixIRIs) {\n IRIlist += IRIlist ? `|${prefixIRI}` : prefixIRI;\n prefixList += (prefixList ? '|' : '') + this._prefixIRIs[prefixIRI];\n }\n IRIlist = escapeRegex(IRIlist, /[\\]\\/\\(\\)\\*\\+\\?\\.\\\\\\$]/g, '\\\\$&');\n this._prefixRegex = new RegExp(`^(?:${prefixList})[^\\/]*$|` +\n `^(${IRIlist})([_a-zA-Z0-9][\\\\-_a-zA-Z0-9]*)$`);\n }\n // End a prefix block with a newline\n this._write(hasPrefixes ? '\\n' : '', done);\n }\n\n // ### `blank` creates a blank node with the given content\n blank(predicate, object) {\n let children = predicate, child, length;\n // Empty blank node\n if (predicate === undefined)\n children = [];\n // Blank node passed as blank(Term(\"predicate\"), Term(\"object\"))\n else if (predicate.termType)\n children = [{ predicate: predicate, object: object }];\n // Blank node passed as blank({ predicate: predicate, object: object })\n else if (!('length' in predicate))\n children = [predicate];\n\n switch (length = children.length) {\n // Generate an empty blank node\n case 0:\n return new SerializedTerm('[]');\n // Generate a non-nested one-triple blank node\n case 1:\n child = children[0];\n if (!(child.object instanceof SerializedTerm))\n return new SerializedTerm(`[ ${this._encodePredicate(child.predicate)} ${\n this._encodeObject(child.object)} ]`);\n // Generate a multi-triple or nested blank node\n default:\n let contents = '[';\n // Write all triples in order\n for (let i = 0; i < length; i++) {\n child = children[i];\n // Write only the object is the predicate is the same as the previous\n if (child.predicate.equals(predicate))\n contents += `, ${this._encodeObject(child.object)}`;\n // Otherwise, write the predicate and the object\n else {\n contents += `${(i ? ';\\n ' : '\\n ') +\n this._encodePredicate(child.predicate)} ${\n this._encodeObject(child.object)}`;\n predicate = child.predicate;\n }\n }\n return new SerializedTerm(`${contents}\\n]`);\n }\n }\n\n // ### `list` creates a list node with the given content\n list(elements) {\n const length = elements && elements.length || 0, contents = new Array(length);\n for (let i = 0; i < length; i++)\n contents[i] = this._encodeObject(elements[i]);\n return new SerializedTerm(`(${contents.join(' ')})`);\n }\n\n // ### `end` signals the end of the output stream\n end(done) {\n // Finish a possible pending quad\n if (this._subject !== null) {\n this._write(this._inDefaultGraph ? '.\\n' : '\\n}\\n');\n this._subject = null;\n }\n // Disallow further writing\n this._write = this._blockedWrite;\n\n // Try to end the underlying stream, ensuring done is called exactly one time\n let singleDone = done && ((error, result) => { singleDone = null, done(error, result); });\n if (this._endStream) {\n try { return this._outputStream.end(singleDone); }\n catch (error) { /* error closing stream */ }\n }\n singleDone && singleDone();\n }\n}\n\n// Replaces a character by its escaped version\nfunction characterReplacer(character) {\n // Replace a single character by its escaped version\n let result = escapedCharacters[character];\n if (result === undefined) {\n // Replace a single character with its 4-bit unicode escape sequence\n if (character.length === 1) {\n result = character.charCodeAt(0).toString(16);\n result = '\\\\u0000'.substr(0, 6 - result.length) + result;\n }\n // Replace a surrogate pair with its 8-bit unicode escape sequence\n else {\n result = ((character.charCodeAt(0) - 0xD800) * 0x400 +\n character.charCodeAt(1) + 0x2400).toString(16);\n result = '\\\\U00000000'.substr(0, 10 - result.length) + result;\n }\n }\n return result;\n}\n\nfunction escapeRegex(regex) {\n return regex.replace(/[\\]\\/\\(\\)\\*\\+\\?\\.\\\\\\$]/g, '\\\\$&');\n}\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/N3Writer.js?");
172
194
 
173
195
  /***/ }),
174
196
 
@@ -179,7 +201,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
179
201
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
180
202
 
181
203
  "use strict";
182
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BlankNode: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.BlankNode),\n/* harmony export */ DataFactory: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__[\"default\"]),\n/* harmony export */ DefaultGraph: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.DefaultGraph),\n/* harmony export */ Lexer: () => (/* reexport safe */ _N3Lexer__WEBPACK_IMPORTED_MODULE_0__[\"default\"]),\n/* harmony export */ Literal: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.Literal),\n/* harmony export */ NamedNode: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.NamedNode),\n/* harmony export */ Parser: () => (/* reexport safe */ _N3Parser__WEBPACK_IMPORTED_MODULE_1__[\"default\"]),\n/* harmony export */ Quad: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.Quad),\n/* harmony export */ Store: () => (/* reexport safe */ _N3Store__WEBPACK_IMPORTED_MODULE_3__[\"default\"]),\n/* harmony export */ StreamParser: () => (/* reexport safe */ _N3StreamParser__WEBPACK_IMPORTED_MODULE_4__[\"default\"]),\n/* harmony export */ StreamWriter: () => (/* reexport safe */ _N3StreamWriter__WEBPACK_IMPORTED_MODULE_5__[\"default\"]),\n/* harmony export */ Term: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.Term),\n/* harmony export */ Triple: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.Triple),\n/* harmony export */ Util: () => (/* reexport module object */ _N3Util__WEBPACK_IMPORTED_MODULE_6__),\n/* harmony export */ Variable: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.Variable),\n/* harmony export */ Writer: () => (/* reexport safe */ _N3Writer__WEBPACK_IMPORTED_MODULE_2__[\"default\"]),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ termFromId: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.termFromId),\n/* harmony export */ termToId: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.termToId)\n/* harmony export */ });\n/* harmony import */ var _N3Lexer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./N3Lexer */ \"./node_modules/n3/src/N3Lexer.js\");\n/* harmony import */ var _N3Parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./N3Parser */ \"./node_modules/n3/src/N3Parser.js\");\n/* harmony import */ var _N3Writer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./N3Writer */ \"./node_modules/n3/src/N3Writer.js\");\n/* harmony import */ var _N3Store__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./N3Store */ \"./node_modules/n3/src/N3Store.js\");\n/* harmony import */ var _N3StreamParser__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./N3StreamParser */ \"./node_modules/n3/src/N3StreamParser.js\");\n/* harmony import */ var _N3StreamWriter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./N3StreamWriter */ \"./node_modules/n3/src/N3StreamWriter.js\");\n/* harmony import */ var _N3Util__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./N3Util */ \"./node_modules/n3/src/N3Util.js\");\n/* harmony import */ var _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./N3DataFactory */ \"./node_modules/n3/src/N3DataFactory.js\");\n\n\n\n\n\n\n\n\n\n\n// Named exports\n\n\n// Export all named exports as a default object for backward compatibility\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\n Lexer: _N3Lexer__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n Parser: _N3Parser__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n Writer: _N3Writer__WEBPACK_IMPORTED_MODULE_2__[\"default\"],\n Store: _N3Store__WEBPACK_IMPORTED_MODULE_3__[\"default\"],\n StreamParser: _N3StreamParser__WEBPACK_IMPORTED_MODULE_4__[\"default\"],\n StreamWriter: _N3StreamWriter__WEBPACK_IMPORTED_MODULE_5__[\"default\"],\n Util: _N3Util__WEBPACK_IMPORTED_MODULE_6__,\n\n DataFactory: _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__[\"default\"],\n\n Term: _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.Term,\n NamedNode: _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.NamedNode,\n Literal: _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.Literal,\n BlankNode: _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.BlankNode,\n Variable: _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.Variable,\n DefaultGraph: _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.DefaultGraph,\n Quad: _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.Quad,\n Triple: _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.Triple,\n\n termFromId: _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.termFromId,\n termToId: _N3DataFactory__WEBPACK_IMPORTED_MODULE_7__.termToId,\n});\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/index.js?");
204
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BlankNode: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.BlankNode),\n/* harmony export */ DataFactory: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__[\"default\"]),\n/* harmony export */ DefaultGraph: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.DefaultGraph),\n/* harmony export */ EntityIndex: () => (/* reexport safe */ _N3Store__WEBPACK_IMPORTED_MODULE_3__.N3EntityIndex),\n/* harmony export */ Lexer: () => (/* reexport safe */ _N3Lexer__WEBPACK_IMPORTED_MODULE_0__[\"default\"]),\n/* harmony export */ Literal: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.Literal),\n/* harmony export */ NamedNode: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.NamedNode),\n/* harmony export */ Parser: () => (/* reexport safe */ _N3Parser__WEBPACK_IMPORTED_MODULE_1__[\"default\"]),\n/* harmony export */ Quad: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.Quad),\n/* harmony export */ Reasoner: () => (/* reexport safe */ _N3Reasoner__WEBPACK_IMPORTED_MODULE_8__[\"default\"]),\n/* harmony export */ Store: () => (/* reexport safe */ _N3Store__WEBPACK_IMPORTED_MODULE_3__[\"default\"]),\n/* harmony export */ StoreFactory: () => (/* reexport safe */ _N3StoreFactory__WEBPACK_IMPORTED_MODULE_4__[\"default\"]),\n/* harmony export */ StreamParser: () => (/* reexport safe */ _N3StreamParser__WEBPACK_IMPORTED_MODULE_5__[\"default\"]),\n/* harmony export */ StreamWriter: () => (/* reexport safe */ _N3StreamWriter__WEBPACK_IMPORTED_MODULE_6__[\"default\"]),\n/* harmony export */ Term: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.Term),\n/* harmony export */ Triple: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.Triple),\n/* harmony export */ Util: () => (/* reexport module object */ _N3Util__WEBPACK_IMPORTED_MODULE_7__),\n/* harmony export */ Variable: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.Variable),\n/* harmony export */ Writer: () => (/* reexport safe */ _N3Writer__WEBPACK_IMPORTED_MODULE_2__[\"default\"]),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ getRulesFromDataset: () => (/* reexport safe */ _N3Reasoner__WEBPACK_IMPORTED_MODULE_8__.getRulesFromDataset),\n/* harmony export */ termFromId: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.termFromId),\n/* harmony export */ termToId: () => (/* reexport safe */ _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.termToId)\n/* harmony export */ });\n/* harmony import */ var _N3Lexer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./N3Lexer */ \"./node_modules/n3/src/N3Lexer.js\");\n/* harmony import */ var _N3Parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./N3Parser */ \"./node_modules/n3/src/N3Parser.js\");\n/* harmony import */ var _N3Writer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./N3Writer */ \"./node_modules/n3/src/N3Writer.js\");\n/* harmony import */ var _N3Store__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./N3Store */ \"./node_modules/n3/src/N3Store.js\");\n/* harmony import */ var _N3StoreFactory__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./N3StoreFactory */ \"./node_modules/n3/src/N3StoreFactory.js\");\n/* harmony import */ var _N3Reasoner__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./N3Reasoner */ \"./node_modules/n3/src/N3Reasoner.js\");\n/* harmony import */ var _N3StreamParser__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./N3StreamParser */ \"./node_modules/n3/src/N3StreamParser.js\");\n/* harmony import */ var _N3StreamWriter__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./N3StreamWriter */ \"./node_modules/n3/src/N3StreamWriter.js\");\n/* harmony import */ var _N3Util__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./N3Util */ \"./node_modules/n3/src/N3Util.js\");\n/* harmony import */ var _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./N3DataFactory */ \"./node_modules/n3/src/N3DataFactory.js\");\n\n\n\n\n\n\n\n\n\n\n\n\n// Named exports\n\n\n// Export all named exports as a default object for backward compatibility\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\n Lexer: _N3Lexer__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n Parser: _N3Parser__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n Writer: _N3Writer__WEBPACK_IMPORTED_MODULE_2__[\"default\"],\n Store: _N3Store__WEBPACK_IMPORTED_MODULE_3__[\"default\"],\n StoreFactory: _N3StoreFactory__WEBPACK_IMPORTED_MODULE_4__[\"default\"],\n EntityIndex: _N3Store__WEBPACK_IMPORTED_MODULE_3__.N3EntityIndex,\n StreamParser: _N3StreamParser__WEBPACK_IMPORTED_MODULE_5__[\"default\"],\n StreamWriter: _N3StreamWriter__WEBPACK_IMPORTED_MODULE_6__[\"default\"],\n Util: _N3Util__WEBPACK_IMPORTED_MODULE_7__,\n Reasoner: _N3Reasoner__WEBPACK_IMPORTED_MODULE_8__[\"default\"],\n\n DataFactory: _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__[\"default\"],\n\n Term: _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.Term,\n NamedNode: _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.NamedNode,\n Literal: _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.Literal,\n BlankNode: _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.BlankNode,\n Variable: _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.Variable,\n DefaultGraph: _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.DefaultGraph,\n Quad: _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.Quad,\n Triple: _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.Triple,\n\n termFromId: _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.termFromId,\n termToId: _N3DataFactory__WEBPACK_IMPORTED_MODULE_9__.termToId,\n});\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/n3/src/index.js?");
183
205
 
184
206
  /***/ }),
185
207
 
@@ -482,6 +504,17 @@ eval("// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission
482
504
 
483
505
  /***/ }),
484
506
 
507
+ /***/ "./node_modules/tslib/tslib.es6.mjs":
508
+ /*!******************************************!*\
509
+ !*** ./node_modules/tslib/tslib.es6.mjs ***!
510
+ \******************************************/
511
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
512
+
513
+ "use strict";
514
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ __addDisposableResource: () => (/* binding */ __addDisposableResource),\n/* harmony export */ __assign: () => (/* binding */ __assign),\n/* harmony export */ __asyncDelegator: () => (/* binding */ __asyncDelegator),\n/* harmony export */ __asyncGenerator: () => (/* binding */ __asyncGenerator),\n/* harmony export */ __asyncValues: () => (/* binding */ __asyncValues),\n/* harmony export */ __await: () => (/* binding */ __await),\n/* harmony export */ __awaiter: () => (/* binding */ __awaiter),\n/* harmony export */ __classPrivateFieldGet: () => (/* binding */ __classPrivateFieldGet),\n/* harmony export */ __classPrivateFieldIn: () => (/* binding */ __classPrivateFieldIn),\n/* harmony export */ __classPrivateFieldSet: () => (/* binding */ __classPrivateFieldSet),\n/* harmony export */ __createBinding: () => (/* binding */ __createBinding),\n/* harmony export */ __decorate: () => (/* binding */ __decorate),\n/* harmony export */ __disposeResources: () => (/* binding */ __disposeResources),\n/* harmony export */ __esDecorate: () => (/* binding */ __esDecorate),\n/* harmony export */ __exportStar: () => (/* binding */ __exportStar),\n/* harmony export */ __extends: () => (/* binding */ __extends),\n/* harmony export */ __generator: () => (/* binding */ __generator),\n/* harmony export */ __importDefault: () => (/* binding */ __importDefault),\n/* harmony export */ __importStar: () => (/* binding */ __importStar),\n/* harmony export */ __makeTemplateObject: () => (/* binding */ __makeTemplateObject),\n/* harmony export */ __metadata: () => (/* binding */ __metadata),\n/* harmony export */ __param: () => (/* binding */ __param),\n/* harmony export */ __propKey: () => (/* binding */ __propKey),\n/* harmony export */ __read: () => (/* binding */ __read),\n/* harmony export */ __rest: () => (/* binding */ __rest),\n/* harmony export */ __rewriteRelativeImportExtension: () => (/* binding */ __rewriteRelativeImportExtension),\n/* harmony export */ __runInitializers: () => (/* binding */ __runInitializers),\n/* harmony export */ __setFunctionName: () => (/* binding */ __setFunctionName),\n/* harmony export */ __spread: () => (/* binding */ __spread),\n/* harmony export */ __spreadArray: () => (/* binding */ __spreadArray),\n/* harmony export */ __spreadArrays: () => (/* binding */ __spreadArrays),\n/* harmony export */ __values: () => (/* binding */ __values),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nfunction __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nvar __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nfunction __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nfunction __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nfunction __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nfunction __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nfunction __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nfunction __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nfunction __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nfunction __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nfunction __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nfunction __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nvar __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nfunction __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nfunction __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nfunction __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nfunction __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nfunction __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nfunction __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nfunction __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nfunction __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nfunction __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nfunction __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nfunction __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nvar ownKeys = function(o) {\n ownKeys = Object.getOwnPropertyNames || function (o) {\n var ar = [];\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n return ar;\n };\n return ownKeys(o);\n};\n\nfunction __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\n __setModuleDefault(result, mod);\n return result;\n}\n\nfunction __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nfunction __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nfunction __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nfunction __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nfunction __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nfunction __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nfunction __rewriteRelativeImportExtension(path, preserveJsx) {\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\n });\n }\n return path;\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __esDecorate,\n __runInitializers,\n __propKey,\n __setFunctionName,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n __rewriteRelativeImportExtension,\n});\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/tslib/tslib.es6.mjs?");
515
+
516
+ /***/ }),
517
+
485
518
  /***/ "./src/index.ts":
486
519
  /*!**********************!*\
487
520
  !*** ./src/index.ts ***!
@@ -720,7 +753,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
720
753
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
721
754
 
722
755
  "use strict";
723
- eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.OwlReasoner = void 0;\nconst ontologies_1 = __webpack_require__(/*! ../../ontologies */ \"./src/ontologies/index.ts\");\nconst shacl_reasoner_1 = __webpack_require__(/*! ./shacl-reasoner */ \"./src/rdf/reasoners/shacl-reasoner.ts\");\n/**\n * A simple OWL reasoner that expands the graph with inferred triples.\n */\nclass OwlReasoner extends shacl_reasoner_1.ShaclReasoner {\n constructor() {\n super();\n this.restrictions = {};\n }\n afterInference() {\n super.afterInference();\n for (let r of Object.values(this.restrictions)) {\n const p = r.onProperty;\n if (!p)\n continue;\n if (r.onDataRange) {\n this.store.addQuad(p, ontologies_1.rdf.type, ontologies_1.owl.DatatypeProperty, this.targetGraph);\n this.store.addQuad(p, ontologies_1.rdfs.range, r.onDataRange, this.targetGraph);\n }\n else if (r.onClass) {\n this.store.addQuad(p, ontologies_1.rdf.type, ontologies_1.owl.ObjectProperty, this.targetGraph);\n this.store.addQuad(p, ontologies_1.rdfs.range, r.onClass, this.targetGraph);\n }\n else if (r.allValuesFrom) {\n this.store.addQuad(p, ontologies_1.rdf.type, ontologies_1.owl.ObjectProperty, this.targetGraph);\n }\n else if (r.someValuesFrom) {\n this.store.addQuad(p, ontologies_1.rdf.type, ontologies_1.owl.ObjectProperty, this.targetGraph);\n }\n }\n this.restrictions = {};\n }\n inferClassAxioms(quad) {\n super.inferClassAxioms(quad);\n let s = quad.subject;\n let p = quad.predicate;\n let o = quad.object.termType != \"Literal\" ? quad.object : undefined;\n if (!o) {\n return;\n }\n // See: https://www.w3.org/TR/owl2-profiles/#Reasoning_in_OWL_2_RL_and_RDF_Graphs_using_Rules\n switch (p.id) {\n case ontologies_1.rdf.type.id: {\n if (o.id == ontologies_1.owl.Restriction.id) {\n this.restrictions[s.value] = {};\n }\n return;\n }\n case ontologies_1.owl.equivalentClass.id: {\n this.assertClass(s);\n if (o && !this.isW3CNode(o)) {\n this.assertClass(o);\n }\n // The opposite is also true.\n if (o.termType == \"NamedNode\") {\n this.store.addQuad(o, ontologies_1.owl.equivalentClass, s, this.targetGraph);\n }\n return;\n }\n case ontologies_1.owl.complementOf.id:\n case ontologies_1.owl.disjointWith.id: {\n this.assertClass(s);\n if (o && !this.isW3CNode(o)) {\n this.assertClass(o);\n }\n return;\n }\n case ontologies_1.owl.intersectionOf.id: {\n let equivalentSubjects = [...this.store.match(null, ontologies_1.owl.equivalentClass, s)]\n .map(q => q.subject)\n .filter(q => q.termType == \"NamedNode\");\n // Rule #scm-int\n let classes = this.getListItems(o.value);\n if (!Array.isArray(classes)) {\n this.errors.push({ quad: quad, message: `Expected an array of classes for ${o.value}` });\n return;\n }\n for (let c of classes) {\n if (c.termType != \"NamedNode\") {\n continue;\n }\n this.store.addQuad(s, ontologies_1.rdfs.subClassOf, c, this.targetGraph);\n for (let es of equivalentSubjects) {\n this.store.addQuad(es, ontologies_1.rdfs.subClassOf, c, this.targetGraph);\n }\n }\n return;\n }\n case ontologies_1.owl.unionOf.id: {\n let equivalentSubjects = [...this.store.match(null, ontologies_1.owl.equivalentClass, s)]\n .map(q => q.subject)\n .filter(q => q.termType == \"NamedNode\");\n // Rule #scm-uni\n let classes = this.getListItems(o.value);\n if (!Array.isArray(classes)) {\n this.errors.push({ quad: quad, message: `Expected an array of classes for ${o.value}` });\n return;\n }\n for (let c of classes) {\n if (c.termType != \"NamedNode\") {\n continue;\n }\n this.store.addQuad(c, ontologies_1.rdfs.subClassOf, s, this.targetGraph);\n for (let es of equivalentSubjects) {\n this.store.addQuad(c, ontologies_1.rdfs.subClassOf, es, this.targetGraph);\n }\n }\n return;\n }\n case ontologies_1.owl.onClass.id: {\n if (o.termType == \"NamedNode\") {\n this.assertClass(o);\n }\n return;\n }\n case ontologies_1.owl.onDataRange.id: {\n if (o.termType == \"NamedNode\") {\n this.store.addQuad(o, ontologies_1.rdf.type, ontologies_1.rdfs.Datatype, this.targetGraph);\n }\n return;\n }\n // Note:\n // e.g. Gist also uses these on xsd:string, so inferring that this is a \n // class is technically true, however, it would lead to undesirable results.\n //\n // case owl.allValuesFrom.id: {\n // if (o.termType == \"NamedNode\") {\n // this.store.addQuad(o, rdf.type, rdfs.Class, this.targetGraph);\n // }\n //\n // return;\n // }\n // case owl.someValuesFrom.id: {\n // if (o.termType == \"NamedNode\") {\n // this.store.addQuad(o, rdf.type, rdfs.Class, this.targetGraph);\n // }\n //\n // break;\n // }\n }\n }\n inferPropertyAxioms(quad) {\n super.inferPropertyAxioms(quad);\n let s = quad.subject;\n let p = quad.predicate;\n let o = quad.object.termType != \"Literal\" ? quad.object : undefined;\n if (!o) {\n return;\n }\n switch (p.id) {\n case ontologies_1.owl.onProperty.id: {\n this.assertProperty(o);\n if (this.restrictions[s.value] && o.termType == \"NamedNode\") {\n this.restrictions[s.value].onProperty = o;\n }\n return;\n }\n case ontologies_1.owl.onClass.id: {\n if (this.restrictions[s.value] && o.termType == \"NamedNode\") {\n this.restrictions[s.value].onClass = o;\n }\n return;\n }\n case ontologies_1.owl.onDataRange.id: {\n if (this.restrictions[s.value] && o.termType == \"NamedNode\") {\n this.restrictions[s.value].onDataRange = o;\n }\n return;\n }\n case ontologies_1.owl.allValuesFrom.id: {\n if (this.restrictions[s.value]) {\n this.restrictions[s.value].allValuesFrom = o;\n }\n return;\n }\n case ontologies_1.owl.someValuesFrom.id: {\n if (this.restrictions[s.value]) {\n this.restrictions[s.value].someValuesFrom = o;\n }\n return;\n }\n case ontologies_1.owl.equivalentProperty.id: {\n this.assertProperty(s);\n this.assertProperty(o);\n // The opposite is also true.\n if (o.termType == \"NamedNode\") {\n this.store.addQuad(o, ontologies_1.owl.equivalentProperty, s, this.targetGraph);\n }\n return;\n }\n case ontologies_1.rdf.type.id: {\n switch (o.id) {\n case ontologies_1.owl.AnnotationProperty.id:\n case ontologies_1.owl.AsymmetricProperty.id:\n case ontologies_1.owl.DatatypeProperty.id:\n case ontologies_1.owl.DeprecatedProperty.id:\n case ontologies_1.owl.FunctionalProperty.id:\n case ontologies_1.owl.InverseFunctionalProperty.id:\n case ontologies_1.owl.IrreflexiveProperty.id:\n case ontologies_1.owl.ObjectProperty.id:\n case ontologies_1.owl.OntologyProperty.id:\n case ontologies_1.owl.ReflexiveProperty.id:\n case ontologies_1.owl.SymmetricProperty.id:\n case ontologies_1.owl.TransitiveProperty.id: {\n this.assertProperty(s);\n }\n }\n return;\n }\n }\n }\n}\nexports.OwlReasoner = OwlReasoner;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/reasoners/owl-reasoner.ts?");
756
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.OwlReasoner = void 0;\nconst ontologies_1 = __webpack_require__(/*! ../../ontologies */ \"./src/ontologies/index.ts\");\nconst shacl_reasoner_1 = __webpack_require__(/*! ./shacl-reasoner */ \"./src/rdf/reasoners/shacl-reasoner.ts\");\n/**\n * A simple OWL reasoner that expands the graph with inferred triples.\n */\nclass OwlReasoner extends shacl_reasoner_1.ShaclReasoner {\n constructor() {\n super();\n this.restrictions = {};\n }\n afterInference() {\n super.afterInference();\n for (let r of Object.values(this.restrictions)) {\n const p = r.onProperty;\n if (!p)\n continue;\n if (r.onDataRange) {\n this.store.addQuad(p, ontologies_1.rdf.type, ontologies_1.owl.DatatypeProperty, this.targetGraph);\n this.store.addQuad(p, ontologies_1.rdfs.range, r.onDataRange, this.targetGraph);\n }\n else if (r.onClass) {\n this.store.addQuad(p, ontologies_1.rdf.type, ontologies_1.owl.ObjectProperty, this.targetGraph);\n this.store.addQuad(p, ontologies_1.rdfs.range, r.onClass, this.targetGraph);\n }\n else if (r.allValuesFrom) {\n this.store.addQuad(p, ontologies_1.rdf.type, ontologies_1.owl.ObjectProperty, this.targetGraph);\n }\n else if (r.someValuesFrom) {\n this.store.addQuad(p, ontologies_1.rdf.type, ontologies_1.owl.ObjectProperty, this.targetGraph);\n }\n }\n this.restrictions = {};\n }\n resetState() {\n super.resetState();\n this.restrictions = {};\n }\n inferClassAxioms(quad) {\n super.inferClassAxioms(quad);\n let s = quad.subject;\n let p = quad.predicate;\n let o = quad.object.termType != \"Literal\" ? quad.object : undefined;\n if (!o) {\n return;\n }\n // See: https://www.w3.org/TR/owl2-profiles/#Reasoning_in_OWL_2_RL_and_RDF_Graphs_using_Rules\n switch (p.id) {\n case ontologies_1.rdf.type.id: {\n if (o.id == ontologies_1.owl.Restriction.id) {\n this.restrictions[s.value] = {};\n }\n return;\n }\n case ontologies_1.owl.equivalentClass.id: {\n this.assertClass(s);\n if (o && !this.isW3CNode(o)) {\n this.assertClass(o);\n }\n // The opposite is also true.\n if (o.termType == \"NamedNode\") {\n this.store.addQuad(o, ontologies_1.owl.equivalentClass, s, this.targetGraph);\n }\n return;\n }\n case ontologies_1.owl.complementOf.id:\n case ontologies_1.owl.disjointWith.id: {\n this.assertClass(s);\n if (o && !this.isW3CNode(o)) {\n this.assertClass(o);\n }\n return;\n }\n case ontologies_1.owl.intersectionOf.id: {\n let equivalentSubjects = [...this.store.match(null, ontologies_1.owl.equivalentClass, s)]\n .map(q => q.subject)\n .filter(q => q.termType == \"NamedNode\");\n // Rule #scm-int\n let classes = this.getListItems(o.value);\n if (!Array.isArray(classes)) {\n this.errors.push({ quad: quad, message: `Expected an array of classes for ${o.value}` });\n return;\n }\n for (let c of classes) {\n if (c.termType != \"NamedNode\") {\n continue;\n }\n this.store.addQuad(s, ontologies_1.rdfs.subClassOf, c, this.targetGraph);\n for (let es of equivalentSubjects) {\n this.store.addQuad(es, ontologies_1.rdfs.subClassOf, c, this.targetGraph);\n }\n }\n return;\n }\n case ontologies_1.owl.unionOf.id: {\n let equivalentSubjects = [...this.store.match(null, ontologies_1.owl.equivalentClass, s)]\n .map(q => q.subject)\n .filter(q => q.termType == \"NamedNode\");\n // Rule #scm-uni\n let classes = this.getListItems(o.value);\n if (!Array.isArray(classes)) {\n this.errors.push({ quad: quad, message: `Expected an array of classes for ${o.value}` });\n return;\n }\n for (let c of classes) {\n if (c.termType != \"NamedNode\") {\n continue;\n }\n this.store.addQuad(c, ontologies_1.rdfs.subClassOf, s, this.targetGraph);\n for (let es of equivalentSubjects) {\n this.store.addQuad(c, ontologies_1.rdfs.subClassOf, es, this.targetGraph);\n }\n }\n return;\n }\n case ontologies_1.owl.onClass.id: {\n if (o.termType == \"NamedNode\") {\n this.assertClass(o);\n }\n return;\n }\n case ontologies_1.owl.onDataRange.id: {\n if (o.termType == \"NamedNode\") {\n this.store.addQuad(o, ontologies_1.rdf.type, ontologies_1.rdfs.Datatype, this.targetGraph);\n }\n return;\n }\n // Note:\n // e.g. Gist also uses these on xsd:string, so inferring that this is a \n // class is technically true, however, it would lead to undesirable results.\n //\n // case owl.allValuesFrom.id: {\n // if (o.termType == \"NamedNode\") {\n // this.store.addQuad(o, rdf.type, rdfs.Class, this.targetGraph);\n // }\n //\n // return;\n // }\n // case owl.someValuesFrom.id: {\n // if (o.termType == \"NamedNode\") {\n // this.store.addQuad(o, rdf.type, rdfs.Class, this.targetGraph);\n // }\n //\n // break;\n // }\n }\n }\n inferPropertyAxioms(quad) {\n super.inferPropertyAxioms(quad);\n let s = quad.subject;\n let p = quad.predicate;\n let o = quad.object.termType != \"Literal\" ? quad.object : undefined;\n if (!o) {\n return;\n }\n switch (p.id) {\n case ontologies_1.owl.onProperty.id: {\n this.assertProperty(o);\n if (this.restrictions[s.value] && o.termType == \"NamedNode\") {\n this.restrictions[s.value].onProperty = o;\n }\n return;\n }\n case ontologies_1.owl.onClass.id: {\n if (this.restrictions[s.value] && o.termType == \"NamedNode\") {\n this.restrictions[s.value].onClass = o;\n }\n return;\n }\n case ontologies_1.owl.onDataRange.id: {\n if (this.restrictions[s.value] && o.termType == \"NamedNode\") {\n this.restrictions[s.value].onDataRange = o;\n }\n return;\n }\n case ontologies_1.owl.allValuesFrom.id: {\n if (this.restrictions[s.value]) {\n this.restrictions[s.value].allValuesFrom = o;\n }\n return;\n }\n case ontologies_1.owl.someValuesFrom.id: {\n if (this.restrictions[s.value]) {\n this.restrictions[s.value].someValuesFrom = o;\n }\n return;\n }\n case ontologies_1.owl.equivalentProperty.id: {\n this.assertProperty(s);\n this.assertProperty(o);\n // The opposite is also true.\n if (o.termType == \"NamedNode\") {\n this.store.addQuad(o, ontologies_1.owl.equivalentProperty, s, this.targetGraph);\n }\n return;\n }\n case ontologies_1.rdf.type.id: {\n switch (o.id) {\n case ontologies_1.owl.AnnotationProperty.id:\n case ontologies_1.owl.AsymmetricProperty.id:\n case ontologies_1.owl.DatatypeProperty.id:\n case ontologies_1.owl.DeprecatedProperty.id:\n case ontologies_1.owl.FunctionalProperty.id:\n case ontologies_1.owl.InverseFunctionalProperty.id:\n case ontologies_1.owl.IrreflexiveProperty.id:\n case ontologies_1.owl.ObjectProperty.id:\n case ontologies_1.owl.OntologyProperty.id:\n case ontologies_1.owl.ReflexiveProperty.id:\n case ontologies_1.owl.SymmetricProperty.id:\n case ontologies_1.owl.TransitiveProperty.id: {\n this.assertProperty(s);\n }\n }\n return;\n }\n }\n }\n}\nexports.OwlReasoner = OwlReasoner;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/reasoners/owl-reasoner.ts?");
724
757
 
725
758
  /***/ }),
726
759
 
@@ -731,7 +764,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
731
764
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
732
765
 
733
766
  "use strict";
734
- eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.RdfsReasoner = void 0;\nconst ontologies_1 = __webpack_require__(/*! ../../ontologies */ \"./src/ontologies/index.ts\");\nconst skos_reasoner_1 = __webpack_require__(/*! ./skos-reasoner */ \"./src/rdf/reasoners/skos-reasoner.ts\");\n/**\n * A simple RDFS reasoner that expands the graph with inferred triples.\n */\nclass RdfsReasoner extends skos_reasoner_1.SkosReasoner {\n constructor() {\n super(...arguments);\n this.ontologies = new Set();\n this.classes = new Set();\n this.properties = new Set();\n this.invididuals = new Set();\n }\n isIgnoredNode(term) {\n switch (term.id) {\n case ontologies_1.skos.Concept.id:\n case ontologies_1.skos.ConceptScheme.id:\n case ontologies_1.skos.Collection.id:\n case ontologies_1.skos.OrderedCollection.id:\n case ontologies_1.sh.Shape.id:\n case ontologies_1.sh.NodeShape.id:\n case ontologies_1.sh.PropertyShape.id:\n return true;\n default:\n return false;\n }\n }\n isClass(id) {\n return super.isClass(id) ||\n this.classes.has(id) ||\n this.properties.has(id) ||\n this.ontologies.has(id);\n }\n afterInference() {\n super.afterInference();\n // After all axioms have been inferred, add the inferred individuals to the graph.\n const individuals = [...this.invididuals].filter(x => !this.isClass(x.id));\n for (let individual of individuals) {\n this.store.addQuad(individual, ontologies_1.rdf.type, ontologies_1.owl.NamedIndividual, this.targetGraph);\n }\n }\n applyInference(quad) {\n super.applyInference(quad);\n // Treat all named nodes with rdf:type definitions as potential individuals.\n if (quad.subject.termType == \"NamedNode\" && quad.predicate.equals(ontologies_1.rdf.type)) {\n // Only consider individuals that are not of a type that is ignored such as skos:Concept.\n if (!this.isIgnoredNode(quad.object)) {\n this.invididuals.add(quad.subject);\n }\n if (quad.object.id == ontologies_1.owl.Ontology.id) {\n this.ontologies.add(quad.subject.id);\n }\n }\n this.inferClassAxioms(quad);\n this.inferPropertyAxioms(quad);\n }\n assertClass(subject) {\n this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.rdfs.Class, this.targetGraph);\n this.classes.add(subject.id);\n }\n inferClassAxioms(quad) {\n let s = quad.subject;\n let p = quad.predicate;\n let o = quad.object.termType != \"Literal\" ? quad.object : undefined;\n if (!o) {\n return;\n }\n switch (p.id) {\n case ontologies_1.rdf.type.id: {\n if (o.equals(ontologies_1.rdfs.Class)) {\n // No need to infer the class type, as it is already asserted.\n this.classes.add(s.id);\n }\n else if (o.equals(ontologies_1.owl.Class)) {\n this.assertClass(s);\n }\n else if (!this.isW3CNode(o)) {\n this.assertClass(o);\n }\n return;\n }\n case ontologies_1.rdfs.subClassOf.id: {\n this.assertClass(s);\n if (!this.isW3CNode(o)) {\n this.assertClass(o);\n }\n else if (o.equals(ontologies_1.rdfs.Resource)) {\n this.store.addQuad(ontologies_1.rdfs.Resource, ontologies_1.rdf.type, ontologies_1.rdfs.Class, this.targetGraph);\n }\n else if (o.equals(ontologies_1.rdfs.Class)) {\n this.store.addQuad(ontologies_1.rdfs.Class, ontologies_1.rdf.type, ontologies_1.rdfs.Class, this.targetGraph);\n this.store.addQuad(ontologies_1.rdfs.Class, ontologies_1.rdfs.subClassOf, ontologies_1.rdfs.Resource, this.targetGraph);\n }\n else if (o.equals(ontologies_1.rdfs.Datatype)) {\n this.store.addQuad(ontologies_1.rdfs.Datatype, ontologies_1.rdf.type, ontologies_1.rdfs.Class, this.targetGraph);\n this.store.addQuad(ontologies_1.rdfs.Datatype, ontologies_1.rdfs.subClassOf, ontologies_1.rdfs.Class, this.targetGraph);\n }\n else if (o.equals(ontologies_1.owl.Class)) {\n this.store.addQuad(ontologies_1.owl.Class, ontologies_1.rdf.type, ontologies_1.rdfs.Class, this.targetGraph);\n this.store.addQuad(ontologies_1.owl.Class, ontologies_1.rdfs.subClassOf, ontologies_1.rdfs.Class, this.targetGraph);\n }\n return;\n }\n case ontologies_1.rdfs.range.id:\n case ontologies_1.rdfs.domain.id: {\n if (!this.isW3CNode(o)) {\n this.assertClass(o);\n }\n return;\n }\n }\n }\n assertProperty(subject) {\n this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.rdf.Property, this.targetGraph);\n this.properties.add(subject.id);\n }\n inferPropertyAxioms(quad) {\n let s = quad.subject;\n let p = quad.predicate;\n let o = quad.object.termType != \"Literal\" ? quad.object : undefined;\n if (!o) {\n return;\n }\n switch (p.id) {\n case ontologies_1.rdf.type.id: {\n if (o.equals(ontologies_1.rdf.Property)) {\n // No need to infer the property type, as it is already asserted.\n this.properties.add(s.id);\n }\n return;\n }\n case ontologies_1.rdfs.range.id:\n case ontologies_1.rdfs.domain.id: {\n this.assertProperty(s);\n return;\n }\n }\n }\n}\nexports.RdfsReasoner = RdfsReasoner;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/reasoners/rdfs-reasoner.ts?");
767
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.RdfsReasoner = void 0;\nconst ontologies_1 = __webpack_require__(/*! ../../ontologies */ \"./src/ontologies/index.ts\");\nconst skos_reasoner_1 = __webpack_require__(/*! ./skos-reasoner */ \"./src/rdf/reasoners/skos-reasoner.ts\");\n/**\n * A simple RDFS reasoner that expands the graph with inferred triples.\n */\nclass RdfsReasoner extends skos_reasoner_1.SkosReasoner {\n constructor() {\n super(...arguments);\n this.ontologies = new Set();\n this.classes = new Set();\n this.properties = new Set();\n this.invididuals = new Set();\n }\n isIgnoredNode(term) {\n switch (term.id) {\n case ontologies_1.skos.Concept.id:\n case ontologies_1.skos.ConceptScheme.id:\n case ontologies_1.skos.Collection.id:\n case ontologies_1.skos.OrderedCollection.id:\n case ontologies_1.sh.Shape.id:\n case ontologies_1.sh.NodeShape.id:\n case ontologies_1.sh.PropertyShape.id:\n return true;\n default:\n return false;\n }\n }\n isClass(id) {\n return super.isClass(id) ||\n this.classes.has(id) ||\n this.properties.has(id) ||\n this.ontologies.has(id);\n }\n afterInference() {\n super.afterInference();\n // After all axioms have been inferred, add the inferred individuals to the graph.\n const individuals = [...this.invididuals].filter(x => !this.isClass(x.id));\n for (let individual of individuals) {\n this.store.addQuad(individual, ontologies_1.rdf.type, ontologies_1.owl.NamedIndividual, this.targetGraph);\n }\n }\n resetState() {\n this.ontologies.clear();\n this.classes.clear();\n this.properties.clear();\n this.invididuals.clear();\n }\n applyInference(quad) {\n super.applyInference(quad);\n // Treat all named nodes with rdf:type definitions as potential individuals.\n if (quad.subject.termType == \"NamedNode\" && quad.predicate.equals(ontologies_1.rdf.type)) {\n // Only consider individuals that are not of a type that is ignored such as skos:Concept.\n if (!this.isIgnoredNode(quad.object)) {\n this.invididuals.add(quad.subject);\n }\n if (quad.object.id == ontologies_1.owl.Ontology.id) {\n this.ontologies.add(quad.subject.id);\n }\n }\n this.inferClassAxioms(quad);\n this.inferPropertyAxioms(quad);\n }\n assertClass(subject) {\n this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.rdfs.Class, this.targetGraph);\n this.classes.add(subject.id);\n }\n inferClassAxioms(quad) {\n let s = quad.subject;\n let p = quad.predicate;\n let o = quad.object.termType != \"Literal\" ? quad.object : undefined;\n if (!o) {\n return;\n }\n switch (p.id) {\n case ontologies_1.rdf.type.id: {\n if (o.equals(ontologies_1.rdfs.Class)) {\n // No need to infer the class type, as it is already asserted.\n this.classes.add(s.id);\n }\n else if (o.equals(ontologies_1.owl.Class)) {\n this.assertClass(s);\n }\n else if (!this.isW3CNode(o)) {\n this.assertClass(o);\n }\n return;\n }\n case ontologies_1.rdfs.subClassOf.id: {\n this.assertClass(s);\n if (!this.isW3CNode(o)) {\n this.assertClass(o);\n }\n else if (o.equals(ontologies_1.rdfs.Resource)) {\n this.store.addQuad(ontologies_1.rdfs.Resource, ontologies_1.rdf.type, ontologies_1.rdfs.Class, this.targetGraph);\n }\n else if (o.equals(ontologies_1.rdfs.Class)) {\n this.store.addQuad(ontologies_1.rdfs.Class, ontologies_1.rdf.type, ontologies_1.rdfs.Class, this.targetGraph);\n this.store.addQuad(ontologies_1.rdfs.Class, ontologies_1.rdfs.subClassOf, ontologies_1.rdfs.Resource, this.targetGraph);\n }\n else if (o.equals(ontologies_1.rdfs.Datatype)) {\n this.store.addQuad(ontologies_1.rdfs.Datatype, ontologies_1.rdf.type, ontologies_1.rdfs.Class, this.targetGraph);\n this.store.addQuad(ontologies_1.rdfs.Datatype, ontologies_1.rdfs.subClassOf, ontologies_1.rdfs.Class, this.targetGraph);\n }\n else if (o.equals(ontologies_1.owl.Class)) {\n this.store.addQuad(ontologies_1.owl.Class, ontologies_1.rdf.type, ontologies_1.rdfs.Class, this.targetGraph);\n this.store.addQuad(ontologies_1.owl.Class, ontologies_1.rdfs.subClassOf, ontologies_1.rdfs.Class, this.targetGraph);\n }\n return;\n }\n case ontologies_1.rdfs.range.id:\n case ontologies_1.rdfs.domain.id: {\n if (!this.isW3CNode(o)) {\n this.assertClass(o);\n }\n return;\n }\n }\n }\n assertProperty(subject) {\n this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.rdf.Property, this.targetGraph);\n this.properties.add(subject.id);\n }\n inferPropertyAxioms(quad) {\n let s = quad.subject;\n let p = quad.predicate;\n let o = quad.object.termType != \"Literal\" ? quad.object : undefined;\n if (!o) {\n return;\n }\n switch (p.id) {\n case ontologies_1.rdf.type.id: {\n if (o.equals(ontologies_1.rdf.Property)) {\n // No need to infer the property type, as it is already asserted.\n this.properties.add(s.id);\n }\n return;\n }\n case ontologies_1.rdfs.range.id:\n case ontologies_1.rdfs.domain.id: {\n this.assertProperty(s);\n return;\n }\n }\n }\n}\nexports.RdfsReasoner = RdfsReasoner;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/reasoners/rdfs-reasoner.ts?");
735
768
 
736
769
  /***/ }),
737
770
 
@@ -742,7 +775,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
742
775
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
743
776
 
744
777
  "use strict";
745
- eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ReasonerBase = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst ontologies_1 = __webpack_require__(/*! ../../ontologies */ \"./src/ontologies/index.ts\");\n/**\n * A base class for reasoners that expand graphs with inferred triples.\n */\nclass ReasonerBase {\n constructor() {\n this.store = new n3.Store();\n this.errors = [];\n }\n getInferenceGraphUri(uri) {\n const u = typeof uri === \"string\" ? uri : uri.value;\n // Let the function throw an error if the URI is not valid.\n return 'mentor:' + u.substring(u.indexOf(':') + 1);\n }\n isInferenceGraphUri(uri) {\n const u = new URL(typeof uri == \"string\" ? uri : uri.value);\n return u.protocol === 'mentor:';\n }\n getGraphNode(graph) {\n if (typeof graph === \"string\") {\n return new n3.NamedNode(graph);\n }\n else {\n return graph;\n }\n }\n isW3CNode(term) {\n return term.value.startsWith(\"http://www.w3.org\");\n }\n /**\n * Get the URIs of ordered list members in the store.\n * @param graphUris Optional graph URI or array of graph URIs to query.\n * @param listUri URI of the list to get the items from.\n * @returns An array of URIs of the items in the list.\n */\n getListItems(listUri) {\n // To do: Fix #10\n const list = listUri.includes(':') ? new n3.NamedNode(listUri) : new n3.BlankNode(listUri);\n return this._getListItems(list);\n }\n _getListItems(subject) {\n if (!this.sourceGraph) {\n return [];\n }\n let first = Array.from(this.match(this.sourceGraph, subject, ontologies_1.rdf.first, null));\n if (!first.length) {\n return [];\n }\n const rest = Array.from(this.match(this.sourceGraph, subject, ontologies_1.rdf.rest, null));\n const firstItem = first[0].object;\n const restList = rest[0]?.object;\n if (restList.value === ontologies_1.RDF.nil) {\n return [firstItem];\n }\n else {\n const restItems = this._getListItems(restList);\n return [firstItem, ...restItems];\n }\n }\n /**\n * Query the store for triples matching the given pattern supporting multiple graphs.\n * @param graphUris Optional graph URI or array of graph URIs to query.\n * @param subject A subject URI or null to match any subject.\n * @param predicate A predicate URI or null to match any predicate.\n * @param object An object URI or null to match any object.\n * @todo Refactor and merge with the same method in the Mentor RDF Store class.\n */\n *match(graph, subject, predicate, object) {\n if (graph !== undefined) {\n yield* this.store.match(subject, predicate, object, graph);\n }\n else {\n yield* this.store.match(subject, predicate, object);\n }\n }\n expand(store, sourceGraph, targetGraph) {\n if (!targetGraph) {\n targetGraph = this.getInferenceGraphUri(sourceGraph);\n }\n this.store = store;\n if (this.store.getGraphs(null, null, null).filter(g => g.id == targetGraph).length > 0) {\n // Ensure the target graph is empty so this function is idempotent and consistent.\n store.deleteGraph(targetGraph);\n }\n this.sourceGraph = this.getGraphNode(sourceGraph);\n this.targetGraph = this.getGraphNode(targetGraph);\n this.beforeInference();\n for (let quad of store.match(null, null, null, this.sourceGraph)) {\n let q = quad;\n this.applyInference(q);\n }\n this.afterInference();\n return store;\n }\n beforeInference() { }\n afterInference() { }\n}\nexports.ReasonerBase = ReasonerBase;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/reasoners/reasoner.ts?");
778
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ReasonerBase = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst ontologies_1 = __webpack_require__(/*! ../../ontologies */ \"./src/ontologies/index.ts\");\n/**\n * A base class for reasoners that expand graphs with inferred triples.\n */\nclass ReasonerBase {\n constructor() {\n this.store = new n3.Store();\n this.errors = [];\n }\n getInferenceGraphUri(uri) {\n const u = typeof uri === \"string\" ? uri : uri.value;\n // Let the function throw an error if the URI is not valid.\n return 'mentor:' + u.substring(u.indexOf(':') + 1);\n }\n isInferenceGraphUri(uri) {\n const u = new URL(typeof uri == \"string\" ? uri : uri.value);\n return u.protocol === 'mentor:';\n }\n getGraphNode(graph) {\n if (typeof graph === \"string\") {\n return new n3.NamedNode(graph);\n }\n else {\n return graph;\n }\n }\n isW3CNode(term) {\n return term.value.startsWith(\"http://www.w3.org\");\n }\n /**\n * Get the URIs of ordered list members in the store.\n * @param graphUris Optional graph URI or array of graph URIs to query.\n * @param listUri URI of the list to get the items from.\n * @returns An array of URIs of the items in the list.\n */\n getListItems(listUri) {\n // To do: Fix #10\n const list = listUri.includes(':') ? new n3.NamedNode(listUri) : new n3.BlankNode(listUri);\n return this._getListItems(list);\n }\n _getListItems(subject) {\n if (!this.sourceGraph) {\n return [];\n }\n let first = Array.from(this.match(this.sourceGraph, subject, ontologies_1.rdf.first, null));\n if (!first.length) {\n return [];\n }\n const rest = Array.from(this.match(this.sourceGraph, subject, ontologies_1.rdf.rest, null));\n const firstItem = first[0].object;\n const restList = rest[0]?.object;\n if (restList.value === ontologies_1.RDF.nil) {\n return [firstItem];\n }\n else {\n const restItems = this._getListItems(restList);\n return [firstItem, ...restItems];\n }\n }\n /**\n * Query the store for triples matching the given pattern supporting multiple graphs.\n * @param graphUris Optional graph URI or array of graph URIs to query.\n * @param subject A subject URI or null to match any subject.\n * @param predicate A predicate URI or null to match any predicate.\n * @param object An object URI or null to match any object.\n * @todo Refactor and merge with the same method in the Mentor RDF Store class.\n */\n *match(graph, subject, predicate, object) {\n if (graph !== undefined) {\n yield* this.store.match(subject, predicate, object, graph);\n }\n else {\n yield* this.store.match(subject, predicate, object);\n }\n }\n expand(store, sourceGraph, targetGraph) {\n if (!targetGraph) {\n targetGraph = this.getInferenceGraphUri(sourceGraph);\n }\n this.store = store;\n if (this.store.getGraphs(null, null, null).filter(g => g.id == targetGraph).length > 0) {\n // Ensure the target graph is empty so this function is idempotent and consistent.\n store.deleteGraph(targetGraph);\n }\n this.sourceGraph = this.getGraphNode(sourceGraph);\n this.targetGraph = this.getGraphNode(targetGraph);\n this.beforeInference();\n for (let quad of store.match(null, null, null, this.sourceGraph)) {\n let q = quad;\n this.applyInference(q);\n }\n this.afterInference();\n this.resetState();\n return store;\n }\n beforeInference() { }\n afterInference() { }\n resetState() { }\n}\nexports.ReasonerBase = ReasonerBase;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/reasoners/reasoner.ts?");
746
779
 
747
780
  /***/ }),
748
781
 
@@ -753,7 +786,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
753
786
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
754
787
 
755
788
  "use strict";
756
- eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ShaclReasoner = void 0;\nconst ontologies_1 = __webpack_require__(/*! ../../ontologies */ \"./src/ontologies/index.ts\");\nconst rdfs_reasoner_1 = __webpack_require__(/*! ./rdfs-reasoner */ \"./src/rdf/reasoners/rdfs-reasoner.ts\");\n/**\n * A simple SKOS reasoner that expands the graph with inferred triples.\n */\nclass ShaclReasoner extends rdfs_reasoner_1.RdfsReasoner {\n constructor() {\n super(...arguments);\n this.classes = new Set();\n }\n isClass(id) {\n return this.classes.has(id) || super.isClass(id);\n }\n applyInference(quad) {\n super.applyInference(quad);\n this.inferShapeAxioms(quad);\n }\n assertShape(subject, type) {\n this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.sh.Shape, this.targetGraph);\n if (type) {\n this.store.addQuad(subject, ontologies_1.rdf.type, type, this.targetGraph);\n }\n this.classes.add(subject.id);\n }\n assertValidator(subject) {\n this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.sh.Validator, this.targetGraph);\n this.classes.add(subject.id);\n }\n assertParameterizable(subject) {\n this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.sh.Parameterizable, this.targetGraph);\n this.classes.add(subject.id);\n }\n assertRule(subject) {\n this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.sh.Rule, this.targetGraph);\n this.classes.add(subject.id);\n }\n isShapeType(subject) {\n switch (subject.id) {\n case ontologies_1.sh.Shape.id:\n case ontologies_1.sh.NodeShape.id:\n case ontologies_1.sh.PropertyShape.id:\n case ontologies_1.sh.Parameter.id: {\n return true;\n }\n default: {\n return false;\n }\n }\n }\n isRuleType(subject) {\n switch (subject.id) {\n case ontologies_1.sh.Rule.id:\n case ontologies_1.sh.JSRule.id:\n case ontologies_1.sh.SPARQLRule.id:\n case ontologies_1.sh.TripleRule.id: {\n return true;\n }\n default: {\n return false;\n }\n }\n }\n isValidatorType(subject) {\n switch (subject.id) {\n case ontologies_1.sh.Validator.id:\n case ontologies_1.sh.JSValidator.id:\n case ontologies_1.sh.SPARQLAskValidator.id:\n case ontologies_1.sh.SPARQLSelectValidator.id: {\n return true;\n }\n default: {\n return false;\n }\n }\n }\n isParameterizableType(subject) {\n switch (subject.id) {\n case ontologies_1.sh.Parameter.id:\n case ontologies_1.sh.ConstraintComponent.id:\n case ontologies_1.sh.Function.id:\n case ontologies_1.sh.JSFunction.id:\n case ontologies_1.sh.SPARQLFunction.id:\n case ontologies_1.sh.TargetType.id:\n case ontologies_1.sh.JSTargetType.id:\n case ontologies_1.sh.SPARQLTargetType.id: {\n return true;\n }\n default: {\n return false;\n }\n }\n }\n inferShapeAxioms(quad) {\n let s = quad.subject;\n let p = quad.predicate;\n let o = quad.object.termType != \"Literal\" ? quad.object : undefined;\n if (!o) {\n return;\n }\n switch (p.id) {\n case ontologies_1.rdf.type.id: {\n if (o.equals(ontologies_1.sh.Shape) || o.equals(ontologies_1.sh.Parameterizable)) {\n // No need to infer the type, as it is already asserted.\n this.classes.add(s.id);\n }\n else if (this.isShapeType(o)) {\n this.assertShape(s, o);\n }\n else if (this.isParameterizableType(o)) {\n this.assertParameterizable(s);\n }\n else if (this.isValidatorType(o)) {\n this.assertValidator(s);\n }\n else if (this.isRuleType(o)) {\n this.assertRule(s);\n }\n return;\n }\n case ontologies_1.sh.targetClass.id: {\n this.assertShape(s, ontologies_1.sh.NodeShape);\n this.assertClass(o);\n return;\n }\n case ontologies_1.sh.class.id: {\n this.assertShape(s, ontologies_1.sh.PropertyShape);\n this.assertClass(o);\n return;\n }\n case ontologies_1.sh.path.id: {\n this.assertShape(s, ontologies_1.sh.PropertyShape);\n this.assertProperty(o);\n return;\n }\n case ontologies_1.sh.property.id: {\n this.assertShape(s, ontologies_1.sh.NodeShape);\n this.assertShape(o, ontologies_1.sh.PropertyShape);\n return;\n }\n case ontologies_1.sh.parameter.id: {\n this.assertShape(o, ontologies_1.sh.Parameter);\n this.assertParameterizable(s);\n return;\n }\n case ontologies_1.sh.labelTemplate.id: {\n this.assertParameterizable(s);\n return;\n }\n case ontologies_1.sh.validator.id: {\n this.assertValidator(o);\n return;\n }\n case ontologies_1.sh.rule.id: {\n this.assertRule(o);\n return;\n }\n case ontologies_1.sh.subject.id:\n case ontologies_1.sh.predicate.id:\n case ontologies_1.sh.object.id: {\n this.assertRule(s);\n return;\n }\n }\n }\n}\nexports.ShaclReasoner = ShaclReasoner;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/reasoners/shacl-reasoner.ts?");
789
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ShaclReasoner = void 0;\nconst ontologies_1 = __webpack_require__(/*! ../../ontologies */ \"./src/ontologies/index.ts\");\nconst rdfs_reasoner_1 = __webpack_require__(/*! ./rdfs-reasoner */ \"./src/rdf/reasoners/rdfs-reasoner.ts\");\n/**\n * A simple SKOS reasoner that expands the graph with inferred triples.\n */\nclass ShaclReasoner extends rdfs_reasoner_1.RdfsReasoner {\n constructor() {\n super(...arguments);\n this.classes = new Set();\n }\n isClass(id) {\n return this.classes.has(id) || super.isClass(id);\n }\n applyInference(quad) {\n super.applyInference(quad);\n this.inferShapeAxioms(quad);\n }\n resetState() {\n super.resetState();\n this.classes.clear();\n }\n assertShape(subject, type) {\n this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.sh.Shape, this.targetGraph);\n if (type) {\n this.store.addQuad(subject, ontologies_1.rdf.type, type, this.targetGraph);\n }\n this.classes.add(subject.id);\n }\n assertValidator(subject) {\n this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.sh.Validator, this.targetGraph);\n this.classes.add(subject.id);\n }\n assertParameterizable(subject) {\n this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.sh.Parameterizable, this.targetGraph);\n this.classes.add(subject.id);\n }\n assertRule(subject) {\n this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.sh.Rule, this.targetGraph);\n this.classes.add(subject.id);\n }\n isShapeType(subject) {\n switch (subject.id) {\n case ontologies_1.sh.Shape.id:\n case ontologies_1.sh.NodeShape.id:\n case ontologies_1.sh.PropertyShape.id:\n case ontologies_1.sh.Parameter.id: {\n return true;\n }\n default: {\n return false;\n }\n }\n }\n isRuleType(subject) {\n switch (subject.id) {\n case ontologies_1.sh.Rule.id:\n case ontologies_1.sh.JSRule.id:\n case ontologies_1.sh.SPARQLRule.id:\n case ontologies_1.sh.TripleRule.id: {\n return true;\n }\n default: {\n return false;\n }\n }\n }\n isValidatorType(subject) {\n switch (subject.id) {\n case ontologies_1.sh.Validator.id:\n case ontologies_1.sh.JSValidator.id:\n case ontologies_1.sh.SPARQLAskValidator.id:\n case ontologies_1.sh.SPARQLSelectValidator.id: {\n return true;\n }\n default: {\n return false;\n }\n }\n }\n isParameterizableType(subject) {\n switch (subject.id) {\n case ontologies_1.sh.Parameter.id:\n case ontologies_1.sh.ConstraintComponent.id:\n case ontologies_1.sh.Function.id:\n case ontologies_1.sh.JSFunction.id:\n case ontologies_1.sh.SPARQLFunction.id:\n case ontologies_1.sh.TargetType.id:\n case ontologies_1.sh.JSTargetType.id:\n case ontologies_1.sh.SPARQLTargetType.id: {\n return true;\n }\n default: {\n return false;\n }\n }\n }\n inferShapeAxioms(quad) {\n let s = quad.subject;\n let p = quad.predicate;\n let o = quad.object.termType != \"Literal\" ? quad.object : undefined;\n if (!o) {\n return;\n }\n switch (p.id) {\n case ontologies_1.rdf.type.id: {\n if (o.equals(ontologies_1.sh.Shape) || o.equals(ontologies_1.sh.Parameterizable)) {\n // No need to infer the type, as it is already asserted.\n this.classes.add(s.id);\n }\n else if (this.isShapeType(o)) {\n this.assertShape(s, o);\n }\n else if (this.isParameterizableType(o)) {\n this.assertParameterizable(s);\n }\n else if (this.isValidatorType(o)) {\n this.assertValidator(s);\n }\n else if (this.isRuleType(o)) {\n this.assertRule(s);\n }\n return;\n }\n case ontologies_1.sh.targetClass.id: {\n this.assertShape(s, ontologies_1.sh.NodeShape);\n this.assertClass(o);\n return;\n }\n case ontologies_1.sh.class.id: {\n this.assertShape(s, ontologies_1.sh.PropertyShape);\n this.assertClass(o);\n return;\n }\n case ontologies_1.sh.path.id: {\n this.assertShape(s, ontologies_1.sh.PropertyShape);\n this.assertProperty(o);\n return;\n }\n case ontologies_1.sh.property.id: {\n this.assertShape(s, ontologies_1.sh.NodeShape);\n this.assertShape(o, ontologies_1.sh.PropertyShape);\n return;\n }\n case ontologies_1.sh.parameter.id: {\n this.assertShape(o, ontologies_1.sh.Parameter);\n this.assertParameterizable(s);\n return;\n }\n case ontologies_1.sh.labelTemplate.id: {\n this.assertParameterizable(s);\n return;\n }\n case ontologies_1.sh.validator.id: {\n this.assertValidator(o);\n return;\n }\n case ontologies_1.sh.rule.id: {\n this.assertRule(o);\n return;\n }\n case ontologies_1.sh.subject.id:\n case ontologies_1.sh.predicate.id:\n case ontologies_1.sh.object.id: {\n this.assertRule(s);\n return;\n }\n }\n }\n}\nexports.ShaclReasoner = ShaclReasoner;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/reasoners/shacl-reasoner.ts?");
757
790
 
758
791
  /***/ }),
759
792
 
@@ -797,7 +830,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
797
830
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
798
831
 
799
832
  "use strict";
800
- eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Store = exports.TripleNotFoundError = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst src = tslib_1.__importStar(__webpack_require__(/*! ../ontologies/src */ \"./src/ontologies/src.ts\"));\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nconst ontologies_2 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\n/**\n * Indicates an error when a triple is not found in the store.\n */\nclass TripleNotFoundError extends Error {\n /**\n * Create a new instance of the error.\n * @param message The error message.\n */\n constructor(subject, predicate, object) {\n super(`No triple was found matching the pattern: ${subject} ${predicate} ${object}`);\n this.name = \"TripleNotFoundError\";\n }\n}\nexports.TripleNotFoundError = TripleNotFoundError;\n/*\n * A store for RDF triples with support for reasoning.\n */\nclass Store {\n /**\n * Return the number of triples in the store.\n */\n get size() {\n return this._store.size;\n }\n /**\n * Create a new RDF triple store.\n * @param reasoner The reasoner to be used for inference.\n */\n constructor(reasoner) {\n /**\n * The N3 triple store implementation.\n */\n this._store = new n3.Store();\n this.reasoner = reasoner;\n }\n /**\n * Loads a set of W3C Standard ontologies into the store (RDF, RDFA, RDFS, OWL, SKOS, SHACL, XSD).\n */\n async loadFrameworkOntologies() {\n await this.loadFromStream(src.rdf, ontologies_2._RDF);\n await this.loadFromStream(src.rdfa, ontologies_2._RDFA);\n await this.loadFromStream(src.rdfs, ontologies_2._RDFS);\n await this.loadFromStream(src.owl, ontologies_2._OWL);\n await this.loadFromStream(src.sh, ontologies_2._SH);\n await this.loadFromStream(src.skos, ontologies_2._SKOS);\n await this.loadFromStream(src.xsd, ontologies_2._XSD);\n }\n /**\n * Get the URIs of the graphs in the triple store.\n * @returns An array of graph URIs in no particular order.\n */\n getGraphs() {\n return this._store.getGraphs(null, null, null).map(g => g.id);\n }\n /**\n * Load a set of triples into the store.\n * @param quads An array of quads to be loaded into the store.\n * @param graphUri The target graph URI.\n * @param executeInference Indicates if inference should be executed after loading the triples.\n * @param clearGraph Indicates if the graph should be cleared before loading.\n * @param onQuad A callback function that will be called for each parsed triple.\n */\n _loadQuads(quads, graphUri, executeInference = true, clearGraph = true, onQuad) {\n const graph = new n3.NamedNode(graphUri.replace('\\\\', '\\/'));\n // Only clear the graph once if there had been no errors.\n if (clearGraph) {\n // Note: Using the match method to clear the graph results in an error because the graph is being modified.\n this.deleteGraphs([graphUri]);\n if (this.reasoner) {\n const inferenceGraph = new n3.NamedNode(this.reasoner.getInferenceGraphUri(graphUri));\n this.deleteGraphs([inferenceGraph.value]);\n }\n }\n for (let q of quads) {\n this._store.add(new n3.Quad(q.subject, q.predicate, q.object, graph));\n if (onQuad) {\n onQuad(q);\n }\n }\n if (this.reasoner && executeInference) {\n this.reasoner.expand(this._store, graphUri);\n }\n }\n /**\n * Create an RDF store from a file.\n * @param input Input data or stream in Turtle format to be parsed.\n * @param graphUri URI of the graph to in which the triples will be created.\n * @param executeInference Indicates if inference should be executed after loading the triples.\n * @param clearGraph Indicates if the graph should be cleared before loading.\n * @param onQuad Callback function that will be called for each parsed triple.\n * @returns A promise that resolves to an RDF store.\n */\n async loadFromStream(input, graphUri, executeInference = true, clearGraph = true, onQuad) {\n return new Promise((resolve, reject) => {\n let quads = [];\n new n3.Parser({}).parse(input, (error, quad, done) => {\n if (error) {\n reject(error);\n }\n else if (quad) {\n quads.push(quad);\n }\n else if (done) {\n this._loadQuads(quads, graphUri, executeInference, clearGraph, onQuad);\n resolve(this);\n }\n });\n });\n }\n /**\n * Indicates if the store contains triples in a given graph.\n * @param graphUri A graph URI.\n * @returns `true` if the store contains triples in the graph URI, `false` otherwise.\n */\n hasGraph(graphUri) {\n const uri = typeof graphUri === 'string' ? new n3.NamedNode(graphUri) : graphUri;\n for (const _ of this._store.match(null, null, null, uri)) {\n return true;\n }\n return false;\n }\n /**\n * Apply inference to the given graph and store the triples in the associated inference graph.\n * @param graphUri A graph URI.\n */\n executeInference(graphUri) {\n if (this.reasoner) {\n this.reasoner.expand(this._store, graphUri);\n }\n }\n /**\n * Delete named graphs from the store.\n * @param graphUris URIs of the graphs to be deleted.\n */\n deleteGraphs(graphUris) {\n for (let graphUri of graphUris) {\n const g = new n3.NamedNode(graphUri);\n for (let q of this._store.match(null, null, null, g)) {\n this._store.removeQuad(q);\n }\n }\n }\n /**\n * Get the URIs of ordered list members in the store.\n * @param graphUris Optional graph URI or array of graph URIs to query.\n * @param listUri URI of the list to get the items from.\n * @returns An array of URIs of the items in the list.\n */\n getListItems(graphUris, listUri) {\n // To do: Fix #10\n const list = listUri.includes(':') ? new n3.NamedNode(listUri) : new n3.BlankNode(listUri);\n return this._getListItems(graphUris, list).map(t => t.value);\n }\n _getListItems(graphUris, subject) {\n const first = Array.from(this.match(graphUris, subject, ontologies_1.rdf.first, null));\n if (!first.length) {\n return [];\n }\n const rest = Array.from(this.match(graphUris, subject, ontologies_1.rdf.rest, null));\n const firstItem = first[0].object;\n const restList = rest[0]?.object;\n if (restList.value === ontologies_1.RDF.nil) {\n return [firstItem];\n }\n else {\n const restItems = this._getListItems(graphUris, restList);\n return [firstItem, ...restItems];\n }\n }\n /**\n * Query the store for triples matching the given pattern supporting multiple graphs.\n * @param graphUris Optional graph URI or array of graph URIs to query.\n * @param subject A subject URI or null to match any subject.\n * @param predicate A predicate URI or null to match any predicate.\n * @param object An object URI or null to match any object.\n */\n *match(graphUris, subject, predicate, object, includeInferred) {\n if (includeInferred && !this.reasoner) {\n throw new Error('Reasoner is not available to include inferred triples.');\n }\n const s = subject;\n const p = predicate;\n const o = object;\n if (graphUris !== undefined) {\n const graphs = Array.isArray(graphUris) ? graphUris : [graphUris];\n for (let graph of graphs.map(g => new n3.NamedNode(g))) {\n yield* this._store.match(s, p, o, graph);\n if (includeInferred !== false && this.reasoner) {\n let inferenceGraph = new n3.NamedNode(this.reasoner.getInferenceGraphUri(graph.value));\n yield* this._store.match(s, p, o, inferenceGraph);\n }\n }\n }\n else {\n yield* this._store.match(s, p, o);\n }\n }\n /**\n * Indicate if there are triples matching the given pattern in the store.\n * @param graphUris Optional graph URI or array of graph URIs to query.\n * @param subject A subject URI or null to match any subject.\n * @param predicate A predicate URI or null to match any predicate.\n * @param object An object URI or null to match any object.\n * @returns `true` if there are triples matching the pattern, `false` otherwise.\n */\n has(graphUris, subject, predicate, object, includeInferred) {\n return this.match(graphUris, subject, predicate, object, includeInferred).next().done === false;\n }\n /**\n * Get the first triple matching the given pattern in the store.\n * @param graphUris Optional graph URI or array of graph URIs to query.\n * @param subject A subject URI or null to match any subject.\n * @param predicate A predicate URI or null to match any predicate.\n * @param object An object URI or null to match any object.\n * @returns The first triple that matches the pattern.\n * @throws {TripleNotFoundError} If no triple is found matching the pattern.\n */\n first(graphUris, subject, predicate, object, includeInferred) {\n const result = this.match(graphUris, subject, predicate, object, includeInferred).next().value;\n if (!result) {\n throw new TripleNotFoundError(subject, predicate, object);\n }\n return result;\n }\n}\nexports.Store = Store;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/store.ts?");
833
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Store = exports.TripleNotFoundError = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst src = tslib_1.__importStar(__webpack_require__(/*! ../ontologies/src */ \"./src/ontologies/src.ts\"));\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nconst ontologies_2 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\n/**\n * Indicates an error when a triple is not found in the store.\n */\nclass TripleNotFoundError extends Error {\n /**\n * Create a new instance of the error.\n * @param message The error message.\n */\n constructor(subject, predicate, object) {\n super(`No triple was found matching the pattern: ${subject} ${predicate} ${object}`);\n this.name = \"TripleNotFoundError\";\n }\n}\nexports.TripleNotFoundError = TripleNotFoundError;\n/*\n * A store for RDF triples with support for reasoning.\n */\nclass Store {\n /**\n * Return the number of triples in the store.\n */\n get size() {\n return this._store.size;\n }\n /**\n * Create a new RDF triple store.\n * @param reasoner The reasoner to be used for inference.\n */\n constructor(reasoner) {\n /**\n * The N3 triple store implementation.\n */\n this._store = new n3.Store();\n this.reasoner = reasoner;\n }\n /**\n * Loads a set of W3C Standard ontologies into the store (RDF, RDFA, RDFS, OWL, SKOS, SHACL, XSD).\n */\n async loadFrameworkOntologies() {\n await this.loadFromStream(src.rdf, ontologies_2._RDF);\n await this.loadFromStream(src.rdfa, ontologies_2._RDFA);\n await this.loadFromStream(src.rdfs, ontologies_2._RDFS);\n await this.loadFromStream(src.owl, ontologies_2._OWL);\n await this.loadFromStream(src.sh, ontologies_2._SH);\n await this.loadFromStream(src.skos, ontologies_2._SKOS);\n await this.loadFromStream(src.xsd, ontologies_2._XSD);\n }\n /**\n * Get the URIs of the graphs in the triple store.\n * @returns An array of graph URIs in no particular order.\n */\n getGraphs() {\n return this._store.getGraphs(null, null, null).map(g => g.id);\n }\n /**\n * Load a set of triples into the store.\n * @param quads An array of quads to be loaded into the store.\n * @param graphUri The target graph URI.\n * @param executeInference Indicates if inference should be executed after loading the triples.\n * @param clearGraph Indicates if the graph should be cleared before loading.\n * @param onQuad A callback function that will be called for each parsed triple.\n */\n _loadQuads(quads, graphUri, executeInference = true, clearGraph = true, onQuad) {\n const graph = new n3.NamedNode(graphUri.replace('\\\\', '\\/'));\n // Only clear the graph once if there had been no errors.\n if (clearGraph) {\n // Note: Using the match method to clear the graph results in an error because the graph is being modified.\n this.deleteGraphs([graphUri]);\n if (this.reasoner) {\n const inferenceGraph = new n3.NamedNode(this.reasoner.getInferenceGraphUri(graphUri));\n this.deleteGraphs([inferenceGraph.value]);\n }\n }\n for (let q of quads) {\n this._store.add(new n3.Quad(q.subject, q.predicate, q.object, graph));\n if (onQuad) {\n onQuad(q);\n }\n }\n if (this.reasoner && executeInference) {\n this.reasoner.expand(this._store, graphUri);\n }\n }\n /**\n * Create an RDF store from a file.\n * @param input Input data or stream in Turtle format to be parsed.\n * @param graphUri URI of the graph to in which the triples will be created.\n * @param executeInference Indicates if inference should be executed after loading the triples.\n * @param clearGraph Indicates if the graph should be cleared before loading.\n * @param onQuad Callback function that will be called for each parsed triple.\n * @returns A promise that resolves to an RDF store.\n */\n async loadFromStream(input, graphUri, executeInference = true, clearGraph = true, onQuad) {\n return new Promise((resolve, reject) => {\n let quads = [];\n new n3.Parser({}).parse(input, (error, quad, done) => {\n if (error) {\n reject(error);\n }\n else if (quad) {\n quads.push(quad);\n }\n else if (done) {\n this._loadQuads(quads, graphUri, executeInference, clearGraph, onQuad);\n resolve(this);\n }\n });\n });\n }\n /**\n * Write the triples in the store into a string in Turtle format.\n * @param graphUri A graph URI.\n * @returns A string serialization of the triples in the graph in Turtle format.\n */\n async serializeGraph(graphUri, prefixes, format) {\n return new Promise((resolve, reject) => {\n const writer = new n3.Writer({\n format: format || 'Turtle',\n prefixes: prefixes\n });\n for (let q of this._store.match(null, null, null, new n3.NamedNode(graphUri))) {\n writer.addQuad(q.subject, q.predicate, q.object);\n }\n writer.end((error, result) => {\n if (error) {\n reject(error);\n }\n else {\n resolve(result);\n }\n });\n });\n }\n /**\n * Indicates if the store contains triples in a given graph.\n * @param graphUri A graph URI.\n * @returns `true` if the store contains triples in the graph URI, `false` otherwise.\n */\n hasGraph(graphUri) {\n const uri = typeof graphUri === 'string' ? new n3.NamedNode(graphUri) : graphUri;\n for (const _ of this._store.match(null, null, null, uri)) {\n return true;\n }\n return false;\n }\n /**\n * Apply inference to the given graph and store the triples in the associated inference graph.\n * @param graphUri A graph URI.\n */\n executeInference(graphUri) {\n if (this.reasoner) {\n this.reasoner.expand(this._store, graphUri);\n }\n }\n /**\n * Delete named graphs from the store.\n * @param graphUris URIs of the graphs to be deleted.\n */\n deleteGraphs(graphUris) {\n for (let graphUri of graphUris) {\n const g = new n3.NamedNode(graphUri);\n for (let q of this._store.match(null, null, null, g)) {\n this._store.removeQuad(q);\n }\n }\n }\n /**\n * Get the URIs of ordered list members in the store.\n * @param graphUris Optional graph URI or array of graph URIs to query.\n * @param listUri URI of the list to get the items from.\n * @returns An array of URIs of the items in the list.\n */\n getListItems(graphUris, listUri) {\n // To do: Fix #10\n const list = listUri.includes(':') ? new n3.NamedNode(listUri) : new n3.BlankNode(listUri);\n return this._getListItems(graphUris, list).map(t => t.value);\n }\n _getListItems(graphUris, subject) {\n const first = Array.from(this.match(graphUris, subject, ontologies_1.rdf.first, null));\n if (!first.length) {\n return [];\n }\n const rest = Array.from(this.match(graphUris, subject, ontologies_1.rdf.rest, null));\n const firstItem = first[0].object;\n const restList = rest[0]?.object;\n if (restList.value === ontologies_1.RDF.nil) {\n return [firstItem];\n }\n else {\n const restItems = this._getListItems(graphUris, restList);\n return [firstItem, ...restItems];\n }\n }\n /**\n * Query the store for triples matching the given pattern supporting multiple graphs.\n * @param graphUris Optional graph URI or array of graph URIs to query.\n * @param subject A subject URI or null to match any subject.\n * @param predicate A predicate URI or null to match any predicate.\n * @param object An object URI or null to match any object.\n */\n *match(graphUris, subject, predicate, object, includeInferred) {\n if (includeInferred && !this.reasoner) {\n throw new Error('Reasoner is not available to include inferred triples.');\n }\n const s = subject;\n const p = predicate;\n const o = object;\n if (graphUris !== undefined) {\n const graphs = Array.isArray(graphUris) ? graphUris : [graphUris];\n for (let graph of graphs.map(g => new n3.NamedNode(g))) {\n for (let q of this._store.match(s, p, o, graph)) {\n yield q;\n }\n if (includeInferred !== false && this.reasoner) {\n let inferenceGraph = new n3.NamedNode(this.reasoner.getInferenceGraphUri(graph.value));\n for (let q of this._store.match(s, p, o, inferenceGraph)) {\n yield q;\n }\n }\n }\n }\n else {\n yield* this._store.match(s, p, o);\n }\n }\n /**\n * Indicate if there are triples matching the given pattern in the store.\n * @param graphUris Optional graph URI or array of graph URIs to query.\n * @param subject A subject URI or null to match any subject.\n * @param predicate A predicate URI or null to match any predicate.\n * @param object An object URI or null to match any object.\n * @returns `true` if there are triples matching the pattern, `false` otherwise.\n */\n has(graphUris, subject, predicate, object, includeInferred) {\n return this.match(graphUris, subject, predicate, object, includeInferred).next().done === false;\n }\n /**\n * Get the first triple matching the given pattern in the store.\n * @param graphUris Optional graph URI or array of graph URIs to query.\n * @param subject A subject URI or null to match any subject.\n * @param predicate A predicate URI or null to match any predicate.\n * @param object An object URI or null to match any object.\n * @returns The first triple that matches the pattern.\n * @throws {TripleNotFoundError} If no triple is found matching the pattern.\n */\n first(graphUris, subject, predicate, object, includeInferred) {\n const result = this.match(graphUris, subject, predicate, object, includeInferred).next().value;\n if (!result) {\n throw new TripleNotFoundError(subject, predicate, object);\n }\n return result;\n }\n}\nexports.Store = Store;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/store.ts?");
801
834
 
802
835
  /***/ }),
803
836
 
@@ -821,17 +854,6 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
821
854
  "use strict";
822
855
  eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.VocabularyRepository = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nconst uri_1 = __webpack_require__(/*! ./uri */ \"./src/rdf/uri.ts\");\nconst shape_repository_1 = __webpack_require__(/*! ./shape-repository */ \"./src/rdf/shape-repository.ts\");\n/**\n * A repository for retrieving ontologies and ontology concepts from graphs.\n */\nclass VocabularyRepository extends shape_repository_1.ShapeRepository {\n /**\n * Get all concept schemes in the repository.\n * @param graphUris URIs of the graphs to search.\n * @returns A list of all concept schemes in the repository.\n */\n getConceptSchemes(graphUris) {\n const result = new Set();\n for (const q of this.store.match(graphUris, null, ontologies_1.rdf.type, ontologies_1.skos.ConceptScheme)) {\n const s = q.subject;\n if (s.termType != \"NamedNode\") {\n continue;\n }\n result.add(s.value);\n }\n return Array.from(result);\n }\n /**\n * Indicates whether the repository contains any concept schemes.\n * @param graphUris URIs of the graphs to search.\n * @returns `true` if the repository contains any concept schemes, `false` otherwise.\n */\n hasConceptSchemes(graphUris) {\n return this.getConceptSchemes(graphUris).length > 0;\n }\n /**\n * Get all ontologies in the repository.\n * @param graphUris URIs of the graphs to search.\n * @returns A list of all ontologies in the repository.\n */\n getOntologies(graphUris) {\n const result = new Set();\n for (const q of this.store.match(graphUris, null, ontologies_1.rdf.type, ontologies_1.owl.Ontology)) {\n const s = q.subject;\n if (s.termType != \"NamedNode\") {\n continue;\n }\n result.add(s.value);\n }\n return Array.from(result);\n }\n /**\n * Indicates whether the repository contains any ontology headers.\n * @param graphUris URIs of the graphs to search.\n * @returns `true` if the repository contains any ontology headers, `false` otherwise.\n */\n hasOntologies(graphUris) {\n return this.getOntologies(graphUris).length > 0;\n }\n /**\n * Get the version (owl:versionInfo) of an ontology. If the version is a date, it is returned as a string in the format \"YYYY-MM-DD\".\n * @param graphUris URIs of the graphs to search.\n * @param ontologyUri URI of the ontology.\n * @returns The version of the ontology, or undefined if it is not found.\n */\n getOntologyVersionInfo(graphUris, ontologyUri) {\n const s = new n3.NamedNode(ontologyUri);\n for (const q of this.store.match(graphUris, s, ontologies_1.owl.versionInfo, null)) {\n // If the version is a date, return it in the format \"YYYY-MM-DD\".\n const match = q.object.value.match(/(\\d{4}[\\/-]\\d{2}[\\/-]\\d{2})/);\n if (match && match.length > 1) {\n return new Date(match[1]).toISOString().substring(0, 10);\n }\n else {\n return q.object.value;\n }\n }\n }\n /**\n * Get the sources of definitions for a given graph. These are ontology definitions\n * or the objects of `rdfs:isDefinedBy` triples. If the rdfs:isDefinedBy object can be\n * matched with an ontology definition, the ontology URI is returned.\n * @param graphUris URIs of the graphs to search.\n * @returns A list of sources of definitions for the given graph.\n */\n getDefinitionSources(graphUris, includeOntologies = false) {\n const result = new Set();\n // Load all ontologies in the graph in a normalized form.\n const ontologies = {};\n // Store the normalized versions of the ontology URI so that we can detect \n // equality even if different namespace seperators ('#' and '/') are used.\n for (let o of this.getOntologies(graphUris)) {\n const uri = uri_1.Uri.getNormalizedUri(o);\n ontologies[uri] = o;\n }\n for (const q of this.store.match(graphUris, null, ontologies_1.rdfs.isDefinedBy, null)) {\n const s = q.subject;\n const o = q.object;\n if (s.termType != \"NamedNode\" || o.termType != \"NamedNode\") {\n continue;\n }\n // Do not include ontologies in the list of sources. However, if there are other\n // terms defined by the object it will be included by subsequent iterations.\n const s_ = uri_1.Uri.getNormalizedUri(s.value);\n const o_ = uri_1.Uri.getNormalizedUri(o.value);\n let isOntology = s_ in ontologies;\n if (!isOntology || includeOntologies) {\n if (o_ in ontologies) {\n result.add(ontologies[o_]);\n }\n else {\n result.add(o.value);\n }\n }\n }\n return Array.from(result);\n }\n}\nexports.VocabularyRepository = VocabularyRepository;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/vocabulary-repository.ts?");
823
856
 
824
- /***/ }),
825
-
826
- /***/ "./node_modules/tslib/tslib.es6.mjs":
827
- /*!******************************************!*\
828
- !*** ./node_modules/tslib/tslib.es6.mjs ***!
829
- \******************************************/
830
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
831
-
832
- "use strict";
833
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ __addDisposableResource: () => (/* binding */ __addDisposableResource),\n/* harmony export */ __assign: () => (/* binding */ __assign),\n/* harmony export */ __asyncDelegator: () => (/* binding */ __asyncDelegator),\n/* harmony export */ __asyncGenerator: () => (/* binding */ __asyncGenerator),\n/* harmony export */ __asyncValues: () => (/* binding */ __asyncValues),\n/* harmony export */ __await: () => (/* binding */ __await),\n/* harmony export */ __awaiter: () => (/* binding */ __awaiter),\n/* harmony export */ __classPrivateFieldGet: () => (/* binding */ __classPrivateFieldGet),\n/* harmony export */ __classPrivateFieldIn: () => (/* binding */ __classPrivateFieldIn),\n/* harmony export */ __classPrivateFieldSet: () => (/* binding */ __classPrivateFieldSet),\n/* harmony export */ __createBinding: () => (/* binding */ __createBinding),\n/* harmony export */ __decorate: () => (/* binding */ __decorate),\n/* harmony export */ __disposeResources: () => (/* binding */ __disposeResources),\n/* harmony export */ __esDecorate: () => (/* binding */ __esDecorate),\n/* harmony export */ __exportStar: () => (/* binding */ __exportStar),\n/* harmony export */ __extends: () => (/* binding */ __extends),\n/* harmony export */ __generator: () => (/* binding */ __generator),\n/* harmony export */ __importDefault: () => (/* binding */ __importDefault),\n/* harmony export */ __importStar: () => (/* binding */ __importStar),\n/* harmony export */ __makeTemplateObject: () => (/* binding */ __makeTemplateObject),\n/* harmony export */ __metadata: () => (/* binding */ __metadata),\n/* harmony export */ __param: () => (/* binding */ __param),\n/* harmony export */ __propKey: () => (/* binding */ __propKey),\n/* harmony export */ __read: () => (/* binding */ __read),\n/* harmony export */ __rest: () => (/* binding */ __rest),\n/* harmony export */ __runInitializers: () => (/* binding */ __runInitializers),\n/* harmony export */ __setFunctionName: () => (/* binding */ __setFunctionName),\n/* harmony export */ __spread: () => (/* binding */ __spread),\n/* harmony export */ __spreadArray: () => (/* binding */ __spreadArray),\n/* harmony export */ __spreadArrays: () => (/* binding */ __spreadArrays),\n/* harmony export */ __values: () => (/* binding */ __values),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nfunction __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nvar __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nfunction __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nfunction __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nfunction __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nfunction __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nfunction __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nfunction __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nfunction __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nfunction __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nfunction __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nfunction __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nvar __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nfunction __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nfunction __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nfunction __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nfunction __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nfunction __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nfunction __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nfunction __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nfunction __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nfunction __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nfunction __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nfunction __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nfunction __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nfunction __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nfunction __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nfunction __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nfunction __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nfunction __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nfunction __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n function next() {\n while (env.stack.length) {\n var rec = env.stack.pop();\n try {\n var result = rec.dispose && rec.dispose.call(rec.value);\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n catch (e) {\n fail(e);\n }\n }\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n});\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./node_modules/tslib/tslib.es6.mjs?");
834
-
835
857
  /***/ })
836
858
 
837
859
  /******/ });