diff --git a/.gitignore b/.gitignore index b8dbaa1f48..1c18d37673 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ /tests/ui/test-results /rdf/target/ /src/main/js/graph3d/node_modules +/src/main/js/sparql/node_modules diff --git a/CHANGELOG.md b/CHANGELOG.md index 123111bc18..6496b0a650 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - `PATCH /settings` refuses to change `lds:versioningRepository` too: an owner could otherwise have their dataspace commit, with the deployment's credentials, over another dataspace's versions ### Changed +- The browser parses and generates SPARQL with Traqula instead of SPARQL.js 2.x, and the stylesheets read and rewrite queries in Traqula's AST, with typed terms instead of SPARQL.js's term strings (#429) - A resource a document describes may be left without a type: `PATCH` refuses only to leave the document itself untyped, which it already did, as the document must keep a document hierarchy class. Imported data often describes entities without a type, and a resource that had one could not be given the same shape (#308 held every resource to keeping one) - The `ldh` plugin's skills show how to check which property views a type gets without a browser, with the page's own lookup query against the installed ontology: `ldh get --accept text/html` returns the page before the browser renders its blocks and property views - The stylesheets' `forClass` parameter, variable and context key are `for-class`, as every other name in them is spelled. A package stylesheet that passed `forClass` to a platform template passes `for-class`; `data-for-class` and the lookup query's `?forClass` are unchanged diff --git a/README.md b/README.md index 6109529a69..b9fa968c71 100644 --- a/README.md +++ b/README.md @@ -387,7 +387,7 @@ The models are transcribed from the code, not extracted from it. The `Formal` wo ### Browser * [Saxon-JS](https://www.saxonica.com/saxon-js/) -* [SPARQL.js](https://github.com/RubenVerborgh/SPARQL.js) +* [Traqula](https://github.com/comunica/traqula) * [OpenLayers](https://openlayers.org) * [Google Charts](https://developers.google.com/chart) diff --git a/src/main/java/com/atomgraph/linkeddatahub/writer/function/ParseQuery.java b/src/main/java/com/atomgraph/linkeddatahub/writer/function/ParseQuery.java index 47f67434b4..0d72469d0b 100644 --- a/src/main/java/com/atomgraph/linkeddatahub/writer/function/ParseQuery.java +++ b/src/main/java/com/atomgraph/linkeddatahub/writer/function/ParseQuery.java @@ -37,28 +37,16 @@ import org.apache.jena.sparql.syntax.ElementGroup; /** - * Server-side counterpart of the browser's SPARQL.js 2.x Parser, backing the Saxon - * declaration of the ldh:parse-query stylesheet function so that - * ldh:construct-instance runs identically on both products. + * Server-side counterpart of the browser's Traqula Parser, backing the Saxon + * declaration of the ldh:parse-query stylesheet function for + * ldh:construct-instance. *

- * This is deliberately NOT a full SPARQL.js replacement: it emits only the subset of the parse - * tree that the stylesheets consume — a template array of triple maps and a - * where array whose non-emptiness marks a query that cannot be instantiated as a pure - * template (SPARQL.js puts the actual parsed patterns there; only the emptiness test is shared). - * Term strings follow the SPARQL.js 2.x serialization expected by - * ldh:triples-to-descriptions: bare URIs (no angle brackets), _:label - * blank nodes, ?name variables, and "lex" / - * "lex"@lang / "lex"^^datatypeURI literals with the datatype URI - * unwrapped — a 2.x quirk that the stylesheet regexes depend on. Divergences from SPARQL.js: - * blank node labels are Jena's parser-allocated ones, not the source labels (downstream only needs - * per-query consistency — ldh:instance-term prefixes them per constructor); variables - * are normalized to the ? sigil (SPARQL.js preserves $, and the - * stylesheets accept both); plain literals are emitted without ^^xsd:string to match - * SPARQL.js 2.x, although Jena types them as such per RDF 1.1. - *

- * If SPARQL.js is ever upgraded to 3.x (see the TO-DO in ldh:triples-to-descriptions), - * this function, ldh:triples-to-descriptions and ldh:construct-instance - * must change in lockstep. + * The stylesheet consumes the Traqula query and pattern keys, including typed RDF terms (a blank + * node carries its name as label, as in Traqula). The server only needs the construct + * template and whether the WHERE group is empty; it does not manufacture a second parser AST for + * query patterns, and since nothing generates SPARQL from this tree, its nodes carry no source + * locations. Jena flattens blank-node property lists and collections in the template, which the + * browser's parser shim does as well. * * @author {@literal Martynas Jusevičius } */ @@ -93,25 +81,34 @@ public XdmValue call(XdmValue[] arguments) throws SaxonApiException { Query query = QueryFactory.create(arguments[0].itemAt(0).getStringValue()); JsonObject json = new JsonObject(); - JsonArray template = new JsonArray(); - JsonArray where = new JsonArray(); + JsonObject template = new JsonObject(); + JsonArray triples = new JsonArray(); + JsonObject where = new JsonObject(); + JsonArray patterns = new JsonArray(); if (query.isConstructType()) for (Triple triple : query.getConstructTemplate().getBGP().getList()) { JsonObject map = new JsonObject(); + map.put("type", "triple"); map.put("subject", term(triple.getSubject())); map.put("predicate", term(triple.getPredicate())); map.put("object", term(triple.getObject())); - template.add(map); + triples.add(map); } - else - where.add(new JsonObject()); // not a CONSTRUCT: mark as non-instantiable Element pattern = query.getQueryPattern(); if (pattern != null && !(pattern instanceof ElementGroup && ((ElementGroup)pattern).isEmpty())) - where.add(new JsonObject()); + patterns.add(new JsonObject()); // only emptiness is consumed by construct-instance + template.put("type", "pattern"); + template.put("subType", "bgp"); + template.put("triples", triples); + where.put("type", "pattern"); + where.put("subType", "group"); + where.put("patterns", patterns); + json.put("type", "query"); + json.put("subType", query.isConstructType() ? "construct" : query.isDescribeType() ? "describe" : query.isAskType() ? "ask" : "select"); json.put("template", template); json.put("where", where); return new XdmAtomicValue(json.toString()); @@ -122,18 +119,41 @@ public XdmValue call(XdmValue[] arguments) throws SaxonApiException } } - private String term(Node node) + private JsonObject term(Node node) { - if (node.isVariable()) return "?" + node.getName(); - if (node.isBlank()) return "_:" + node.getBlankNodeLabel(); + JsonObject term = new JsonObject(); + term.put("type", "term"); + if (node.isVariable()) + { + term.put("subType", "variable"); + term.put("value", node.getName()); + } + else if (node.isBlank()) + { + term.put("subType", "blankNode"); + term.put("label", node.getBlankNodeLabel()); + } if (node.isLiteral()) { - String lex = "\"" + node.getLiteralLexicalForm() + "\""; - if (!node.getLiteralLanguage().isEmpty()) return lex + "@" + node.getLiteralLanguage(); - if (node.getLiteralDatatypeURI() != null && !node.getLiteralDatatypeURI().equals(XSDDatatype.XSDstring.getURI())) return lex + "^^" + node.getLiteralDatatypeURI(); - return lex; + term.put("subType", "literal"); + term.put("value", node.getLiteralLexicalForm()); + if (!node.getLiteralLanguage().isEmpty()) term.put("langOrIri", node.getLiteralLanguage()); + else if (node.getLiteralDatatypeURI() != null && !node.getLiteralDatatypeURI().equals(XSDDatatype.XSDstring.getURI())) + { + JsonObject datatype = new JsonObject(); + datatype.put("type", "term"); + datatype.put("subType", "namedNode"); + datatype.put("value", node.getLiteralDatatypeURI()); + term.put("langOrIri", datatype); + } + } + else if (node.isURI()) + { + term.put("subType", "namedNode"); + term.put("value", node.getURI()); } - return node.getURI(); + return term; } + } diff --git a/src/main/js/sparql/index.js b/src/main/js/sparql/index.js new file mode 100644 index 0000000000..7c07bdfe6d --- /dev/null +++ b/src/main/js/sparql/index.js @@ -0,0 +1,168 @@ +import { Parser as TraqulaParser } from '@traqula/parser-sparql-1-1'; +import { Generator as TraqulaGenerator } from '@traqula/generator-sparql-1-1'; + +// The stylesheets read and rewrite Traqula's AST as JSON (json-to-xml / xml-to-json). This shim keeps that AST in +// a shape the stylesheets can compare and edit without knowing Traqula's source-tracking details: +// - parse() expands prefixed names and BASE-relative IRIs to full IRIs, so a predicate compares as the IRI it is; +// - parse() flattens blank-node property lists ([ ... ]) and collections (( ... )) into plain triples, and gives +// every triple a subject and predicate of its own (Traqula marks repeats after ';' and ',' as not printed), so a +// triple can be matched, moved or appended on its own; +// - generate() gives every node the source location the generator needs, wraps union branches in groups, and +// fills the members a query needs (prologue, dataset clause, solution modifiers), so a stylesheet never writes +// them. + +const AUTO = () => ({ sourceLocationType: 'autoGenerate' }); + +function resolveIri(value, base) { + if (!base) return value; + try { + return new URL(value, base).href; + } catch { + return value; + } +} + +function expandIris(node, scope = { prefixes: new Map(), base: undefined }) { + if (Array.isArray(node)) { + node.forEach((value) => expandIris(value, scope)); + return node; + } + if (!node || typeof node !== 'object') return node; + + let inner = scope; + if (Array.isArray(node.context) && node.context.length > 0) { + inner = { prefixes: new Map(scope.prefixes), base: scope.base }; + for (const definition of node.context) { + if (definition.subType === 'base' && definition.value?.value) { + inner.base = resolveIri(definition.value.value, inner.base); + } + if (definition.subType === 'prefix' && definition.key !== undefined && definition.value?.value) { + inner.prefixes.set(definition.key, resolveIri(definition.value.value, inner.base)); + } + } + } + + if (node.type === 'term' && node.subType === 'namedNode') { + if (node.prefix !== undefined) { + const namespace = inner.prefixes.get(node.prefix); + if (namespace === undefined) throw new Error(`Undefined SPARQL prefix: ${node.prefix}`); + node.value = namespace + node.value; + delete node.prefix; + } else { + node.value = resolveIri(node.value, inner.base); + } + } + + for (const [key, value] of Object.entries(node)) { + if (key !== 'context') expandIris(value, inner); + } + return node; +} + +// a graph node as a plain term, emitting the triples of a blank-node property list or collection into out +function flattenNode(node, out) { + if (node && node.type === 'tripleCollection') { + for (const triple of node.triples) flattenTriple(triple, out); + return materialize(node.identifier); + } + return materialize(node); +} + +function flattenTriple(triple, out) { + if (triple.type === 'tripleCollection') { + flattenNode(triple, out); + return; + } + const subject = flattenNode(triple.subject, out); + const object = flattenNode(triple.object, out); + out.push({ ...triple, subject, predicate: materialize(triple.predicate), object, loc: AUTO() }); +} + +function materialize(term) { + return term && typeof term === 'object' ? { ...term, loc: AUTO() } : term; +} + +function flattenBgps(node) { + if (Array.isArray(node)) { + node.forEach(flattenBgps); + return node; + } + if (!node || typeof node !== 'object') return node; + if (node.type === 'pattern' && node.subType === 'bgp' && Array.isArray(node.triples)) { + const out = []; + for (const triple of node.triples) flattenTriple(triple, out); + node.triples = out; + } + for (const value of Object.values(node)) flattenBgps(value); + return node; +} + +function group(patterns) { + return { type: 'pattern', subType: 'group', patterns, loc: AUTO() }; +} + +// the members the generator dereferences, filled where a stylesheet-built node lacks them +function complete(node) { + if (node.type === 'query') { + if (!Array.isArray(node.context)) node.context = []; + if (!node.datasets) node.datasets = { type: 'datasetClauses', clauses: [] }; + if (!node.solutionModifiers) node.solutionModifiers = {}; + if (node.subType !== 'describe' && !node.where) node.where = group([]); + const modifiers = node.solutionModifiers; + const limitOffset = modifiers.limitOffset; + if (limitOffset) { + if (limitOffset.limit === undefined && !limitOffset.offset) delete modifiers.limitOffset; + else Object.assign(limitOffset, { type: 'solutionModifier', subType: 'limitOffset' }); + } + if (modifiers.order && !(modifiers.order.orderDefs?.length > 0)) delete modifiers.order; + if (modifiers.group && !(modifiers.group.groupings?.length > 0)) delete modifiers.group; + } + if (node.type === 'pattern' && node.subType === 'union' && Array.isArray(node.patterns)) { + node.patterns = node.patterns.map(pattern => pattern.type === 'pattern' && pattern.subType === 'group' ? pattern : group([ pattern ])); + } +} + +// every object the generator visits carries a source location; the rows of VALUES are keyed by variable name +// and are not nodes, so they get none (a variable named 'loc' would otherwise be clobbered) +function localize(node, rows = false) { + if (Array.isArray(node)) { + node.forEach(value => localize(value, rows)); + return node; + } + if (!node || typeof node !== 'object') return node; + if (rows) { + for (const value of Object.values(node)) localize(value); + return node; + } + if (typeof node.type === 'string') complete(node); + if (!node.loc) node.loc = AUTO(); + for (const [key, value] of Object.entries(node)) { + if (key === 'loc') continue; + localize(value, key === 'values' && node.subType === 'values'); + } + return node; +} + +export class Parser { + constructor(options) { + this.parser = new TraqulaParser(options); + } + + parse(query) { + return flattenBgps(expandIris(this.parser.parse(query))); + } +} + +export class Generator { + constructor(options) { + this.generator = new TraqulaGenerator(options); + } + + generate(ast, options) { + return this.generator.generate(localize(ast), options); + } +} + +if (typeof window !== 'undefined') { + window.LDH_SPARQL = { Parser, Generator }; +} diff --git a/src/main/js/sparql/package-lock.json b/src/main/js/sparql/package-lock.json new file mode 100644 index 0000000000..6d05be3112 --- /dev/null +++ b/src/main/js/sparql/package-lock.json @@ -0,0 +1,561 @@ +{ + "name": "ldh-traqula-browser", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ldh-traqula-browser", + "dependencies": { + "@traqula/generator-sparql-1-1": "1.4.0", + "@traqula/parser-sparql-1-1": "1.4.0" + }, + "devDependencies": { + "esbuild": "0.25.10" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.10.tgz", + "integrity": "sha512-0NFWnA+7l41irNuaSVlLfgNT12caWJVLzp5eAVhZ0z1qpxbockccEt3s+149rE64VUI3Ml2zt8Nv5JVc4QXTsw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.10.tgz", + "integrity": "sha512-dQAxF1dW1C3zpeCDc5KqIYuZ1tgAdRXNoZP7vkBIRtKZPYe2xVr/d3SkirklCHudW1B45tGiUlz2pUWDfbDD4w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.10.tgz", + "integrity": "sha512-LSQa7eDahypv/VO6WKohZGPSJDq5OVOo3UoFR1E4t4Gj1W7zEQMUhI+lo81H+DtB+kP+tDgBp+M4oNCwp6kffg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.10.tgz", + "integrity": "sha512-MiC9CWdPrfhibcXwr39p9ha1x0lZJ9KaVfvzA0Wxwz9ETX4v5CHfF09bx935nHlhi+MxhA63dKRRQLiVgSUtEg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.10.tgz", + "integrity": "sha512-JC74bdXcQEpW9KkV326WpZZjLguSZ3DfS8wrrvPMHgQOIEIG/sPXEN/V8IssoJhbefLRcRqw6RQH2NnpdprtMA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.10.tgz", + "integrity": "sha512-tguWg1olF6DGqzws97pKZ8G2L7Ig1vjDmGTwcTuYHbuU6TTjJe5FXbgs5C1BBzHbJ2bo1m3WkQDbWO2PvamRcg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.10.tgz", + "integrity": "sha512-3ZioSQSg1HT2N05YxeJWYR+Libe3bREVSdWhEEgExWaDtyFbbXWb49QgPvFH8u03vUPX10JhJPcz7s9t9+boWg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.10.tgz", + "integrity": "sha512-LLgJfHJk014Aa4anGDbh8bmI5Lk+QidDmGzuC2D+vP7mv/GeSN+H39zOf7pN5N8p059FcOfs2bVlrRr4SK9WxA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.10.tgz", + "integrity": "sha512-oR31GtBTFYCqEBALI9r6WxoU/ZofZl962pouZRTEYECvNF/dtXKku8YXcJkhgK/beU+zedXfIzHijSRapJY3vg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.10.tgz", + "integrity": "sha512-5luJWN6YKBsawd5f9i4+c+geYiVEw20FVW5x0v1kEMWNq8UctFjDiMATBxLvmmHA4bf7F6hTRaJgtghFr9iziQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.10.tgz", + "integrity": "sha512-NrSCx2Kim3EnnWgS4Txn0QGt0Xipoumb6z6sUtl5bOEZIVKhzfyp/Lyw4C1DIYvzeW/5mWYPBFJU3a/8Yr75DQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.10.tgz", + "integrity": "sha512-xoSphrd4AZda8+rUDDfD9J6FUMjrkTz8itpTITM4/xgerAZZcFW7Dv+sun7333IfKxGG8gAq+3NbfEMJfiY+Eg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.10.tgz", + "integrity": "sha512-ab6eiuCwoMmYDyTnyptoKkVS3k8fy/1Uvq7Dj5czXI6DF2GqD2ToInBI0SHOp5/X1BdZ26RKc5+qjQNGRBelRA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.10.tgz", + "integrity": "sha512-NLinzzOgZQsGpsTkEbdJTCanwA5/wozN9dSgEl12haXJBzMTpssebuXR42bthOF3z7zXFWH1AmvWunUCkBE4EA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.10.tgz", + "integrity": "sha512-FE557XdZDrtX8NMIeA8LBJX3dC2M8VGXwfrQWU7LB5SLOajfJIxmSdyL/gU1m64Zs9CBKvm4UAuBp5aJ8OgnrA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.10.tgz", + "integrity": "sha512-3BBSbgzuB9ajLoVZk0mGu+EHlBwkusRmeNYdqmznmMc9zGASFjSsxgkNsqmXugpPk00gJ0JNKh/97nxmjctdew==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.10.tgz", + "integrity": "sha512-QSX81KhFoZGwenVyPoberggdW1nrQZSvfVDAIUXr3WqLRZGZqWk/P4T8p2SP+de2Sr5HPcvjhcJzEiulKgnxtA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.10.tgz", + "integrity": "sha512-AKQM3gfYfSW8XRk8DdMCzaLUFB15dTrZfnX8WXQoOUpUBQ+NaAFCP1kPS/ykbbGYz7rxn0WS48/81l9hFl3u4A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.10.tgz", + "integrity": "sha512-7RTytDPGU6fek/hWuN9qQpeGPBZFfB4zZgcz2VK2Z5VpdUxEI8JKYsg3JfO0n/Z1E/6l05n0unDCNc4HnhQGig==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.10.tgz", + "integrity": "sha512-5Se0VM9Wtq797YFn+dLimf2Zx6McttsH2olUBsDml+lm0GOCRVebRWUvDtkY4BWYv/3NgzS8b/UM3jQNh5hYyw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.10.tgz", + "integrity": "sha512-XkA4frq1TLj4bEMB+2HnI0+4RnjbuGZfet2gs/LNs5Hc7D89ZQBHQ0gL2ND6Lzu1+QVkjp3x1gIcPKzRNP8bXw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.10.tgz", + "integrity": "sha512-AVTSBhTX8Y/Fz6OmIVBip9tJzZEUcY8WLh7I59+upa5/GPhh2/aM6bvOMQySspnCCHvFi79kMtdJS1w0DXAeag==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.10.tgz", + "integrity": "sha512-fswk3XT0Uf2pGJmOpDB7yknqhVkJQkAQOcW/ccVOtfx05LkbWOaRAtn5SaqXypeKQra1QaEa841PgrSL9ubSPQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.10.tgz", + "integrity": "sha512-ah+9b59KDTSfpaCg6VdJoOQvKjI33nTaQr4UluQwW7aEwZQsbMCfTmfEO4VyewOxx4RaDT/xCy9ra2GPWmO7Kw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.10.tgz", + "integrity": "sha512-QHPDbKkrGO8/cz9LKVnJU22HOi4pxZnZhhA2HYHez5Pz4JeffhDjf85E57Oyco163GnzNCVkZK0b/n4Y0UHcSw==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.10.tgz", + "integrity": "sha512-9KpxSVFCu0iK1owoez6aC/s/EdUQLDN3adTxGCqxMVhrPDj6bt5dbrHDXUuq+Bs2vATFBBrQS5vdQ/Ed2P+nbw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@traqula/chevrotain": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@traqula/chevrotain/-/chevrotain-1.1.0.tgz", + "integrity": "sha512-VpcoQKb2ZnsOQPlPO2mE9hfR0Aidp7drwTCtaXfpdRHGkXeQ5Nv4rnxmxwUoEDRzu6b/3z4n8oTd+sYhe4fAaA==", + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@traqula/core": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@traqula/core/-/core-1.3.0.tgz", + "integrity": "sha512-xVp6sblElVsZeeXIQQ8KNRiUFqobNT/IfgWNymlUlICi69aLJWydSWsKcH+TnS5Sz7LW2BoFpoQiIcErXaXPfQ==", + "license": "MIT", + "dependencies": { + "@traqula/chevrotain": "^1.1.0" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@traqula/generator-sparql-1-1": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@traqula/generator-sparql-1-1/-/generator-sparql-1-1-1.4.0.tgz", + "integrity": "sha512-4C3UETTYFSe8xRKwxkbddRgmBfMncpgk3lcmbgFaFsVatHpZe2CdKFZc+oW+hF8tOu2biJXc09YUdKeWiFNOzw==", + "license": "MIT", + "dependencies": { + "@traqula/core": "^1.3.0", + "@traqula/rules-sparql-1-1": "^1.4.0" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@traqula/parser-sparql-1-1": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@traqula/parser-sparql-1-1/-/parser-sparql-1-1-1.4.0.tgz", + "integrity": "sha512-+EcGTlk7QzRBJVH81pE8SDNSneD1glYnfcVNkQi4yWXA7Tw0IYfsINKmNawfJxylcjGr44arh3Qn4HBNtB2agg==", + "license": "MIT", + "dependencies": { + "@traqula/core": "^1.3.0", + "@traqula/rules-sparql-1-1": "^1.4.0" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@traqula/rules-sparql-1-1": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@traqula/rules-sparql-1-1/-/rules-sparql-1-1-1.4.0.tgz", + "integrity": "sha512-EuFbKVUOJQGBlRqoG6+aNoZXft3p1H9a4Yn9iHYsxgv5AKlUu8XzweyKh3ouvQk3P+qO2KWnsGwZ8Z3kEPQ/jg==", + "license": "MIT", + "dependencies": { + "@traqula/chevrotain": "^1.1.0", + "@traqula/core": "^1.3.0" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/esbuild": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.10.tgz", + "integrity": "sha512-9RiGKvCwaqxO2owP61uQ4BgNborAQskMR6QusfWzQqv7AZOg5oGehdY2pRJMTKuwxd1IDBP4rSbI5lHzU7SMsQ==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.10", + "@esbuild/android-arm": "0.25.10", + "@esbuild/android-arm64": "0.25.10", + "@esbuild/android-x64": "0.25.10", + "@esbuild/darwin-arm64": "0.25.10", + "@esbuild/darwin-x64": "0.25.10", + "@esbuild/freebsd-arm64": "0.25.10", + "@esbuild/freebsd-x64": "0.25.10", + "@esbuild/linux-arm": "0.25.10", + "@esbuild/linux-arm64": "0.25.10", + "@esbuild/linux-ia32": "0.25.10", + "@esbuild/linux-loong64": "0.25.10", + "@esbuild/linux-mips64el": "0.25.10", + "@esbuild/linux-ppc64": "0.25.10", + "@esbuild/linux-riscv64": "0.25.10", + "@esbuild/linux-s390x": "0.25.10", + "@esbuild/linux-x64": "0.25.10", + "@esbuild/netbsd-arm64": "0.25.10", + "@esbuild/netbsd-x64": "0.25.10", + "@esbuild/openbsd-arm64": "0.25.10", + "@esbuild/openbsd-x64": "0.25.10", + "@esbuild/openharmony-arm64": "0.25.10", + "@esbuild/sunos-x64": "0.25.10", + "@esbuild/win32-arm64": "0.25.10", + "@esbuild/win32-ia32": "0.25.10", + "@esbuild/win32-x64": "0.25.10" + } + } + } +} diff --git a/src/main/js/sparql/package.json b/src/main/js/sparql/package.json new file mode 100644 index 0000000000..287d02185d --- /dev/null +++ b/src/main/js/sparql/package.json @@ -0,0 +1,17 @@ +{ + "name": "ldh-traqula-browser", + "type": "module", + "private": true, + "description": "Traqula SPARQL 1.1 parser and generator bundle for LinkedDataHub", + "scripts": { + "build": "esbuild index.js --bundle --minify --format=iife --legal-comments=none --outfile=../../webapp/static/com/atomgraph/linkeddatahub/js/traqula.min.js", + "test": "node --test" + }, + "dependencies": { + "@traqula/generator-sparql-1-1": "1.4.0", + "@traqula/parser-sparql-1-1": "1.4.0" + }, + "devDependencies": { + "esbuild": "0.25.10" + } +} diff --git a/src/main/js/sparql/test/traqula.test.js b/src/main/js/sparql/test/traqula.test.js new file mode 100644 index 0000000000..6c2450e125 --- /dev/null +++ b/src/main/js/sparql/test/traqula.test.js @@ -0,0 +1,131 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { Generator, Parser } from '../index.js'; + +// what the stylesheets do to an AST: serialise it to JSON and read it back +const roundTrip = ast => JSON.parse(JSON.stringify(ast)); +const loc = () => ({ sourceLocationType: 'autoGenerate' }); +const variable = value => ({ type: 'term', subType: 'variable', value }); +const iri = value => ({ type: 'term', subType: 'namedNode', value }); + +test('parses and generates SELECT queries with the Traqula AST', () => { + const query = 'PREFIX ex: SELECT ?s WHERE { ?s ex:p ?o OPTIONAL { ?s ex:q ?v } FILTER(?o > 2) VALUES ?v { ex:a ex:b } } ORDER BY DESC(?s) LIMIT 5 OFFSET 2'; + const ast = new Parser().parse(query); + + assert.equal(ast.type, 'query'); + assert.equal(ast.subType, 'select'); + assert.equal(ast.variables[0].type, 'term'); + assert.equal(ast.variables[0].subType, 'variable'); + assert.equal(ast.where.subType, 'group'); + assert.equal(ast.where.patterns[0].triples[0].predicate.value, 'https://example.com/p'); + assert.equal('prefix' in ast.where.patterns[0].triples[0].predicate, false); + + const generated = new Generator().generate(roundTrip(ast)); + const reparsed = new Parser().parse(generated); + assert.equal(reparsed.subType, 'select'); + assert.equal(reparsed.where.patterns.length, 4); + assert.equal(reparsed.solutionModifiers.limitOffset.limit, 5); + assert.equal(reparsed.solutionModifiers.limitOffset.offset, 2); + assert.equal(reparsed.solutionModifiers.order.orderDefs[0].descending, true); +}); + +test('resolves BASE-relative IRIs', () => { + const ast = new Parser().parse('BASE SELECT * { ?s

<../o> }'); + const [ triple ] = ast.where.patterns[0].triples; + + assert.equal(triple.predicate.value, 'https://example.com/dir/p'); + assert.equal(triple.object.value, 'https://example.com/o'); +}); + +test('gives every triple of a predicate-object list its own subject and predicate', () => { + const ast = roundTrip(new Parser().parse('SELECT * { ?s ?a, ?b ; ?c }')); + const triples = ast.where.patterns[0].triples; + + assert.equal(triples.length, 3); + assert.ok(triples.every(triple => triple.subject.value === 's' && triple.subject.loc.sourceLocationType === 'autoGenerate')); + assert.ok(triples.every(triple => triple.predicate.loc.sourceLocationType === 'autoGenerate')); + + // a triple moved on its own still prints its subject + ast.where.patterns[0].triples = [ triples[2] ]; + assert.match(new Generator().generate(ast), /\?s\s+\s+\?c/); +}); + +test('flattens blank-node property lists and collections in CONSTRUCT templates', () => { + const ast = new Parser().parse('PREFIX ex: CONSTRUCT { $this ex:p [ a ex:T ] ; ex:list ( 1 2 ) } WHERE {}'); + const triples = ast.template.triples; + + assert.ok(triples.every(triple => triple.type === 'triple')); + assert.ok(triples.every(triple => [ 'variable', 'namedNode', 'blankNode', 'literal' ].includes(triple.subject.subType))); + const link = triples.find(triple => triple.predicate.value === 'https://example.com/p'); + assert.equal(link.subject.value, 'this'); + assert.equal(link.object.subType, 'blankNode'); + assert.ok(triples.some(triple => triple.subject.label === link.object.label && triple.object.value === 'https://example.com/T')); + assert.equal(triples.filter(triple => triple.predicate.value === 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first').length, 2); + + const reparsed = new Parser().parse(new Generator().generate(roundTrip(ast))); + assert.equal(reparsed.template.triples.length, triples.length); +}); + +test('generates nodes built without source locations, query members or grouped union branches', () => { + const bgp = { type: 'pattern', subType: 'bgp', triples: [ { type: 'triple', subject: variable('s'), predicate: iri('https://example.com/p'), object: variable('o') } ] }; + const ast = { + type: 'query', + subType: 'select', + variables: [ variable('s'), { + type: 'pattern', subType: 'bind', + expression: { type: 'expression', subType: 'aggregate', aggregation: 'count', distinct: true, expression: [ { type: 'wildcard' } ] }, + variable: variable('count'), + } ], + where: { type: 'pattern', subType: 'group', patterns: [ + { type: 'pattern', subType: 'union', patterns: [ bgp, { type: 'pattern', subType: 'graph', name: variable('g'), patterns: [ bgp ] } ] }, + { type: 'pattern', subType: 'filter', expression: { type: 'expression', subType: 'patternOperation', operator: 'exists', args: { type: 'pattern', subType: 'group', patterns: [ bgp ] } } }, + { type: 'pattern', subType: 'values', variables: [ variable('loc') ], values: [ { loc: iri('https://example.com/a') } ] }, + ] }, + solutionModifiers: { + group: { type: 'solutionModifier', subType: 'group', groupings: [ variable('s') ] }, + order: { type: 'solutionModifier', subType: 'order', orderDefs: [ { expression: variable('count'), descending: true } ] }, + limitOffset: { limit: 10 }, + }, + }; + + const generated = new Generator().generate(ast); + const reparsed = new Parser().parse(generated); + assert.equal(reparsed.where.patterns[0].subType, 'union'); + assert.equal(reparsed.where.patterns[1].expression.subType, 'patternOperation'); + assert.equal(reparsed.where.patterns[2].values[0].loc.value, 'https://example.com/a'); + assert.equal(reparsed.solutionModifiers.limitOffset.limit, 10); + assert.equal(reparsed.solutionModifiers.order.orderDefs[0].descending, true); +}); + +test('drops empty solution modifiers', () => { + const ast = roundTrip(new Parser().parse('SELECT * { ?s ?p ?o } LIMIT 5')); + ast.solutionModifiers.limitOffset = { type: 'solutionModifier', subType: 'limitOffset', loc: loc() }; + + assert.doesNotMatch(new Generator().generate(ast), /LIMIT/); +}); + +test('preserves language and datatype terms in SPARQL updates', () => { + const ast = new Parser().parse('INSERT DATA { "hello"@en, "7"^^ }'); + const triples = ast.updates[0].operation.data[0].triples; + + assert.equal(ast.type, 'update'); + assert.equal(triples[0].object.subType, 'literal'); + assert.equal(triples[0].object.langOrIri, 'en'); + assert.equal(triples[1].object.langOrIri.value, 'http://www.w3.org/2001/XMLSchema#integer'); + assert.match(new Generator().generate(roundTrip(ast)), /INSERT DATA/); +}); + +test('generates blank nodes from their label', () => { + const ast = { + type: 'update', + updates: [ { context: [], operation: { + type: 'updateOperation', subType: 'modify', graph: undefined, delete: [], from: { type: 'datasetClauses', clauses: [] }, + insert: [ { type: 'pattern', subType: 'bgp', triples: [ { type: 'triple', subject: { type: 'term', subType: 'blankNode', label: 'b1' }, predicate: iri('https://example.com/p'), object: { type: 'term', subType: 'literal', value: 'a "quoted"\nvalue' } } ] } ], + where: { type: 'pattern', subType: 'group', patterns: [] }, + } } ], + }; + + const generated = new Generator().generate(ast); + assert.match(generated, /_:b1/); + assert.equal(new Parser().parse(generated).updates[0].operation.insert[0].triples[0].object.value, 'a "quoted"\nvalue'); +}); diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/SPARQL.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/SPARQL.js deleted file mode 100644 index 067e6db3c4..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/SPARQL.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{var e={734:(e,t,r)=>{var i=r(192).Parser,s=r(55);e.exports={Parser:function(e,t){var r={};for(var s in e||{})r[s]=e[s];var n=new i;return n.parse=function(){return i.base=t||"",i.prefixes=Object.create(r),i.prototype.parse.apply(n,arguments)},n._resetBlanks=i._resetBlanks,n},Generator:s}},55:e=>{function t(e,t){this._options=e=e||{},t=t||{},this._prefixByIri={};var r=[];for(var i in t){var s=t[i];n(s)&&(this._prefixByIri[s]=i,r.push(s))}var a=r.join("|").replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&");this._prefixRegex=new RegExp("^("+a+")([a-zA-Z][\\-_a-zA-Z0-9]*)$"),this._usedPrefixes={},this._indent=n(e.indent)?e.indent:" ",this._newline=n(e.newline)?e.newline:"\n"}t.prototype.toQuery=function(e){var t="";return e.queryType&&(t+=e.queryType.toUpperCase()+" "),e.reduced&&(t+="REDUCED "),e.distinct&&(t+="DISTINCT "),e.variables?t+=a(e.variables,void 0,(function(e){return n(e)?this.toEntity(e):"("+this.toExpression(e.expression)+" AS "+e.variable+")"}),this)+" ":e.template&&(t+=this.group(e.template,!0)+this._newline),e.from&&(t+=a(e.from.default||[],"",(function(e){return"FROM "+this.toEntity(e)+this._newline}),this)+a(e.from.named||[],"",(function(e){return"FROM NAMED "+this.toEntity(e)+this._newline}),this)),e.where&&(t+="WHERE "+this.group(e.where,!0)+this._newline),e.updates&&(t+=a(e.updates,";"+this._newline,this.toUpdate,this)),e.group&&(t+="GROUP BY "+a(e.group,void 0,(function(e){var t=n(e.expression)?e.expression:"("+this.toExpression(e.expression)+")";return e.variable?"("+t+" AS "+e.variable+")":t}),this)+this._newline),e.having&&(t+="HAVING ("+a(e.having,void 0,this.toExpression,this)+")"+this._newline),e.order&&(t+="ORDER BY "+a(e.order,void 0,(function(e){var t="("+this.toExpression(e.expression)+")";return e.descending?"DESC "+t:t}),this)+this._newline),e.offset&&(t+="OFFSET "+e.offset+this._newline),e.limit&&(t+="LIMIT "+e.limit+this._newline),e.values&&(t+=this.values(e)),(t=this.baseAndPrefixes(e)+t).trim()},t.prototype.baseAndPrefixes=function(e){var t=e.base?"BASE <"+e.base+">"+this._newline:"",r="";for(var i in e.prefixes)(this._options.allPrefixes||this._usedPrefixes[i])&&(r+="PREFIX "+i+": <"+e.prefixes[i]+">"+this._newline);return t+r},t.prototype.toPattern=function(e){var t=e.type||e instanceof Array&&"array"||(e.subject&&e.predicate&&e.object?"triple":"");if(!(t in this))throw new Error("Unknown entry type: "+t);return this[t](e)},t.prototype.triple=function(e){return this.toEntity(e.subject)+" "+this.toEntity(e.predicate)+" "+this.toEntity(e.object)+"."},t.prototype.array=function(e){return a(e,this._newline,this.toPattern,this)},t.prototype.bgp=function(e){return this.encodeTriples(e.triples)},t.prototype.encodeTriples=function(e){if(!e.length)return"";for(var t=[],r="",i="",s=0;s":case">=":case"<=":case"&&":case"||":case"=":case"!=":case"+":case"-":case"*":case"/":return(n(r[0])?this.toEntity(r[0]):"("+this.toExpression(r[0])+")")+" "+t+" "+(n(r[1])?this.toEntity(r[1]):"("+this.toExpression(r[1])+")");case"!":return"!("+this.toExpression(r[0])+")";case"notin":t="NOT IN";case"in":return this.toExpression(r[0])+" "+t+"("+(n(r[1])?r[1]:a(r[1],", ",this.toExpression,this))+")";case"notexists":t="NOT EXISTS";case"exists":return t+" "+this.group(r[0],!0);default:return t+"("+a(r,", ",this.toExpression,this)+")"}default:throw new Error("Unknown expression type: "+e.type)}},t.prototype.toEntity=function(e){if(n(e))switch(e[0]){case"?":case"$":case"*":case"_":return e;case'"':var t=e.match(/^"([^]*)"(?:(@.+)|\^\^(.+))?$/)||{},s=t[1]||"",a=t[2]||"",u=t[3];if(e='"'+s.replace(r,i)+'"'+a,u){if("http://www.w3.org/2001/XMLSchema#integer"===u&&/^\d+$/.test(s))return s+" ";e+="^^"+this.encodeIRI(u)}return e;default:return this.encodeIRI(e)}else{var o=e.items.map(this.toEntity,this),c=e.pathType;switch(c){case"^":case"!":return c+o[0];case"*":case"+":case"?":return"("+o[0]+c+")";default:return"("+o.join(c)+")"}}};var r=/["\\\t\n\r\b\f]/g,i=function(e){return s[e]},s={"\\":"\\\\",'"':'\\"',"\t":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};function n(e){return"string"==typeof e}function a(e,t,r,i){return e.map(r,i).join(n(t)?t:" ")}t.prototype.encodeIRI=function(e){var t=this._prefixRegex.exec(e);if(t){var r=this._prefixByIri[t[1]];return this._usedPrefixes[r]=!0,r+":"+t[2]}return"<"+e+">"},t.prototype.toUpdate=function(e){switch(e.type||e.updateType){case"load":return"LOAD"+(e.source?" "+this.toEntity(e.source):"")+(e.destination?" INTO GRAPH "+this.toEntity(e.destination):"");case"insert":return"INSERT DATA "+this.group(e.insert,!0);case"delete":return"DELETE DATA "+this.group(e.delete,!0);case"deletewhere":return"DELETE WHERE "+this.group(e.delete,!0);case"insertdelete":return(e.graph?"WITH "+this.toEntity(e.graph)+this._newline:"")+(e.delete.length?"DELETE "+this.group(e.delete,!0)+this._newline:"")+(e.insert.length?"INSERT "+this.group(e.insert,!0)+this._newline:"")+"WHERE "+this.group(e.where,!0);case"add":case"copy":case"move":return e.type.toUpperCase()+(e.source.default?" DEFAULT ":" ")+"TO "+this.toEntity(e.destination.name);case"clear":case"drop":return e.type.toUpperCase()+(e.silent?" SILENT ":" ")+(e.graph.default?"DEFAULT":e.graph.named?"NAMED":e.graph.all?"ALL":"GRAPH "+this.toEntity(e.graph.name));default:throw new Error("Unknown update query type: "+e.type)}},t.prototype.indent=function(e){return e.replace(/^/gm,this._indent)},e.exports=function(e){return{stringify:function(r){return new t(e,r.prefixes).toQuery(r)}}}},192:(e,t,r)=>{e=r.nmd(e);var i=function(){var e=function(e,t,r,i){for(r=r||{},i=e.length;i--;r[e[i]]=t);return r},t=[6,12,15,24,34,43,48,99,109,112,114,115,124,125,130,298,299,300,301,302],r=[2,196],i=[99,109,112,114,115,124,125,130,298,299,300,301,302],s=[1,18],n=[1,27],a=[6,83],u=[38,39,51],o=[38,51],c=[1,55],p=[1,57],h=[1,53],l=[1,56],F=[28,29,293],E=[13,16,286],y=[111,133,296,303],f=[13,16,111,133,286],_=[1,80],D=[1,84],A=[1,86],g=[111,133,296,297,303],b=[13,16,111,133,286,297],T=[1,92],d=[2,236],C=[1,91],I=[13,16,28,29,80,86,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286],S=[6,38,39,51,61,68,71,79,81,83],N=[6,13,16,28,38,39,51,61,68,71,79,81,83,286],k=[6,13,16,28,29,31,32,38,39,41,51,61,68,71,79,80,81,83,86,92,108,111,124,125,127,132,159,160,162,165,166,183,187,208,213,215,216,218,219,223,227,231,246,251,268,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,293,304,306,307,309,310,311,312,313,314,315,316],R=[1,107],m=[1,108],L=[6,13,16,28,29,39,41,80,83,86,111,159,160,162,165,166,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,304],O=[2,295],$=[1,125],x=[1,123],P=[6,183],v=[2,312],U=[2,300],w=[38,127],G=[6,41,68,71,79,81,83],B=[2,238],M=[1,139],V=[1,141],j=[1,151],H=[1,157],Q=[1,160],z=[1,156],Z=[1,158],Y=[1,154],W=[1,155],X=[1,161],q=[1,162],K=[1,165],J=[1,166],ee=[1,167],te=[1,168],re=[1,169],ie=[1,170],se=[1,171],ne=[1,172],ae=[1,173],ue=[1,174],oe=[1,175],ce=[1,176],pe=[6,61,68,71,79,81,83],he=[28,29,38,39,51],le=[13,16,28,29,80,248,249,250,252,254,255,257,258,261,263,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,316,317,318,319,320,321],Fe=[2,409],Ee=[1,189],ye=[1,190],fe=[1,191],_e=[13,16,41,80,92,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286],De=[41,86],Ae=[28,32],ge=[6,108,183],be=[41,111],Te=[6,41,71,79,81,83],de=[2,324],Ce=[2,316],Ie=[1,226],Se=[1,228],Ne=[41,111,304],ke=[13,16,28,29,32,39,41,80,83,86,111,159,160,162,165,166,183,187,208,213,215,216,218,219,251,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,304],Re=[13,16,28,29,31,32,39,41,80,83,86,92,111,159,160,162,165,166,183,187,208,213,215,216,218,219,223,227,231,246,251,268,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,293,304,307,310,311,312,313,314,315,316],me=[13,16,28,29,31,32,39,41,80,83,86,92,111,159,160,162,165,166,183,187,208,213,215,216,218,219,223,227,231,246,251,268,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,293,304,307,310,311,312,313,314,315,316],Le=[31,32,183,223,251],Oe=[31,32,183,223,227,251],$e=[31,32,183,223,227,231,246,251,268,280,281,282,283,284,285,310,311,312,313,314,315,316],xe=[31,32,183,223,227,231,246,251,268,280,281,282,283,284,285,293,307,310,311,312,313,314,315,316],Pe=[1,260],ve=[1,261],Ue=[1,263],we=[1,264],Ge=[1,265],Be=[1,266],Me=[1,268],Ve=[1,269],je=[2,416],He=[1,271],Qe=[1,272],ze=[1,273],Ze=[1,279],Ye=[1,274],We=[1,275],Xe=[1,276],qe=[1,277],Ke=[1,278],Je=[1,286],et=[1,299],tt=[6,41,79,81,83],rt=[1,316],it=[1,315],st=[39,41,83,111,159,160,162,165,166],nt=[1,324],at=[1,325],ut=[41,111,183,216,304],ot=[2,354],ct=[13,16,28,29,32,80,86,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286],pt=[13,16,28,29,32,39,41,80,83,86,111,159,160,162,165,166,183,215,216,218,219,251,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,304],ht=[13,16,28,29,80,208,246,248,249,250,252,254,255,257,258,261,263,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,310,316,317,318,319,320,321],lt=[1,349],Ft=[1,350],Et=[1,352],yt=[1,351],ft=[6,13,16,28,29,31,32,39,41,68,71,74,76,79,80,81,83,86,111,159,160,162,165,166,183,215,218,219,223,227,231,246,248,249,250,251,252,254,255,257,258,261,263,268,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,293,304,307,310,311,312,313,314,315,316,317,318,319,320,321],_t=[1,360],Dt=[1,359],At=[29,86],gt=[13,16,32,41,80,92,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286],bt=[29,41],Tt=[2,315],dt=[6,41,83],Ct=[6,13,16,29,41,71,79,81,83,248,249,250,252,254,255,257,258,261,263,286,316,317,318,319,320,321],It=[6,13,16,28,29,39,41,71,74,76,79,80,81,83,86,111,159,160,162,165,166,215,218,219,248,249,250,252,254,255,257,258,261,263,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,304,316,317,318,319,320,321],St=[6,13,16,28,29,41,68,71,79,81,83,248,249,250,252,254,255,257,258,261,263,286,316,317,318,319,320,321],Nt=[6,13,16,28,29,31,32,39,41,61,68,71,74,76,79,80,81,83,86,111,159,160,162,165,166,183,215,218,219,223,227,231,246,248,249,250,251,252,254,255,257,258,261,263,268,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,293,304,305,307,310,311,312,313,314,315,316,317,318,319,320,321],kt=[13,16,29,187,208,213,286],Rt=[2,366],mt=[1,401],Lt=[39,41,83,111,159,160,162,165,166,304],Ot=[13,16,28,29,32,39,41,80,83,86,111,159,160,162,165,166,183,187,215,216,218,219,251,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,304],$t=[13,16,28,29,80,208,246,248,249,250,252,254,255,257,258,261,263,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,293,310,316,317,318,319,320,321],xt=[1,450],Pt=[1,447],vt=[1,448],Ut=[13,16,28,29,39,41,80,83,86,111,159,160,162,165,166,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286],wt=[13,16,28,286],Gt=[13,16,28,29,39,41,80,83,86,111,159,160,162,165,166,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,304],Bt=[2,327],Mt=[39,41,83,111,159,160,162,165,166,183,216,304],Vt=[6,13,16,28,29,41,74,76,79,81,83,248,249,250,252,254,255,257,258,261,263,286,316,317,318,319,320,321],jt=[2,322],Ht=[13,16,29,187,208,286],Qt=[13,16,32,80,92,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286],zt=[13,16,28,29,41,80,86,111,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286],Zt=[13,16,28,29,32,80,86,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,306,307],Yt=[13,16,28,29,32,80,86,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,293,306,307,309,310],Wt=[1,561],Xt=[1,562],qt=[2,310],Kt=[13,16,32,187,213,286],Jt={trace:function(){},yy:{},symbols_:{error:2,QueryOrUpdate:3,Prologue:4,QueryOrUpdate_group0:5,EOF:6,Prologue_repetition0:7,Query:8,Query_group0:9,Query_option0:10,BaseDecl:11,BASE:12,IRIREF:13,PrefixDecl:14,PREFIX:15,PNAME_NS:16,SelectQuery:17,SelectClause:18,SelectQuery_repetition0:19,WhereClause:20,SolutionModifier:21,SubSelect:22,SubSelect_option0:23,SELECT:24,SelectClause_option0:25,SelectClause_group0:26,SelectClauseItem:27,VAR:28,"(":29,Expression:30,AS:31,")":32,ConstructQuery:33,CONSTRUCT:34,ConstructTemplate:35,ConstructQuery_repetition0:36,ConstructQuery_repetition1:37,WHERE:38,"{":39,ConstructQuery_option0:40,"}":41,DescribeQuery:42,DESCRIBE:43,DescribeQuery_group0:44,DescribeQuery_repetition0:45,DescribeQuery_option0:46,AskQuery:47,ASK:48,AskQuery_repetition0:49,DatasetClause:50,FROM:51,DatasetClause_option0:52,iri:53,WhereClause_option0:54,GroupGraphPattern:55,SolutionModifier_option0:56,SolutionModifier_option1:57,SolutionModifier_option2:58,SolutionModifier_option3:59,GroupClause:60,GROUP:61,BY:62,GroupClause_repetition_plus0:63,GroupCondition:64,BuiltInCall:65,FunctionCall:66,HavingClause:67,HAVING:68,HavingClause_repetition_plus0:69,OrderClause:70,ORDER:71,OrderClause_repetition_plus0:72,OrderCondition:73,ASC:74,BrackettedExpression:75,DESC:76,Constraint:77,LimitOffsetClauses:78,LIMIT:79,INTEGER:80,OFFSET:81,ValuesClause:82,VALUES:83,InlineData:84,InlineData_repetition0:85,NIL:86,InlineData_repetition1:87,InlineData_repetition_plus2:88,InlineData_repetition3:89,DataBlockValue:90,Literal:91,UNDEF:92,DataBlockValueList:93,DataBlockValueList_repetition_plus0:94,Update:95,Update_repetition0:96,Update1:97,Update_option0:98,LOAD:99,Update1_option0:100,Update1_option1:101,Update1_group0:102,Update1_option2:103,GraphRefAll:104,Update1_group1:105,Update1_option3:106,GraphOrDefault:107,TO:108,CREATE:109,Update1_option4:110,GRAPH:111,INSERTDATA:112,QuadPattern:113,DELETEDATA:114,DELETEWHERE:115,Update1_option5:116,InsertClause:117,Update1_option6:118,Update1_repetition0:119,Update1_option7:120,DeleteClause:121,Update1_option8:122,Update1_repetition1:123,DELETE:124,INSERT:125,UsingClause:126,USING:127,UsingClause_option0:128,WithClause:129,WITH:130,IntoGraphClause:131,INTO:132,DEFAULT:133,GraphOrDefault_option0:134,GraphRefAll_group0:135,QuadPattern_option0:136,QuadPattern_repetition0:137,QuadsNotTriples:138,QuadsNotTriples_group0:139,QuadsNotTriples_option0:140,QuadsNotTriples_option1:141,QuadsNotTriples_option2:142,TriplesTemplate:143,TriplesTemplate_repetition0:144,TriplesSameSubject:145,TriplesTemplate_option0:146,GroupGraphPatternSub:147,GroupGraphPatternSub_option0:148,GroupGraphPatternSub_repetition0:149,GroupGraphPatternSubTail:150,GraphPatternNotTriples:151,GroupGraphPatternSubTail_option0:152,GroupGraphPatternSubTail_option1:153,TriplesBlock:154,TriplesBlock_repetition0:155,TriplesSameSubjectPath:156,TriplesBlock_option0:157,GraphPatternNotTriples_repetition0:158,OPTIONAL:159,MINUS:160,GraphPatternNotTriples_group0:161,SERVICE:162,GraphPatternNotTriples_option0:163,GraphPatternNotTriples_group1:164,FILTER:165,BIND:166,FunctionCall_option0:167,FunctionCall_repetition0:168,ExpressionList:169,ExpressionList_repetition0:170,ConstructTemplate_option0:171,ConstructTriples:172,ConstructTriples_repetition0:173,ConstructTriples_option0:174,VarOrTerm:175,PropertyListNotEmpty:176,TriplesNode:177,PropertyList:178,PropertyList_option0:179,VerbObjectList:180,PropertyListNotEmpty_repetition0:181,SemiOptionalVerbObjectList:182,";":183,SemiOptionalVerbObjectList_option0:184,Verb:185,ObjectList:186,a:187,ObjectList_repetition0:188,GraphNode:189,PropertyListPathNotEmpty:190,TriplesNodePath:191,TriplesSameSubjectPath_option0:192,PropertyListPathNotEmpty_group0:193,PropertyListPathNotEmpty_repetition0:194,GraphNodePath:195,PropertyListPathNotEmpty_repetition1:196,PropertyListPathNotEmptyTail:197,PropertyListPathNotEmptyTail_group0:198,Path:199,Path_repetition0:200,PathSequence:201,PathSequence_repetition0:202,PathEltOrInverse:203,PathElt:204,PathPrimary:205,PathElt_option0:206,PathEltOrInverse_option0:207,"!":208,PathNegatedPropertySet:209,PathOneInPropertySet:210,PathNegatedPropertySet_repetition0:211,PathNegatedPropertySet_option0:212,"^":213,TriplesNode_repetition_plus0:214,"[":215,"]":216,TriplesNodePath_repetition_plus0:217,BLANK_NODE_LABEL:218,ANON:219,ConditionalAndExpression:220,Expression_repetition0:221,ExpressionTail:222,"||":223,RelationalExpression:224,ConditionalAndExpression_repetition0:225,ConditionalAndExpressionTail:226,"&&":227,AdditiveExpression:228,RelationalExpression_group0:229,RelationalExpression_option0:230,IN:231,MultiplicativeExpression:232,AdditiveExpression_repetition0:233,AdditiveExpressionTail:234,AdditiveExpressionTail_group0:235,NumericLiteralPositive:236,AdditiveExpressionTail_repetition0:237,NumericLiteralNegative:238,AdditiveExpressionTail_repetition1:239,UnaryExpression:240,MultiplicativeExpression_repetition0:241,MultiplicativeExpressionTail:242,MultiplicativeExpressionTail_group0:243,UnaryExpression_option0:244,PrimaryExpression:245,"-":246,Aggregate:247,FUNC_ARITY0:248,FUNC_ARITY1:249,FUNC_ARITY2:250,",":251,IF:252,BuiltInCall_group0:253,BOUND:254,BNODE:255,BuiltInCall_option0:256,EXISTS:257,COUNT:258,Aggregate_option0:259,Aggregate_group0:260,FUNC_AGGREGATE:261,Aggregate_option1:262,GROUP_CONCAT:263,Aggregate_option2:264,Aggregate_option3:265,GroupConcatSeparator:266,SEPARATOR:267,"=":268,String:269,LANGTAG:270,"^^":271,DECIMAL:272,DOUBLE:273,true:274,false:275,STRING_LITERAL1:276,STRING_LITERAL2:277,STRING_LITERAL_LONG1:278,STRING_LITERAL_LONG2:279,INTEGER_POSITIVE:280,DECIMAL_POSITIVE:281,DOUBLE_POSITIVE:282,INTEGER_NEGATIVE:283,DECIMAL_NEGATIVE:284,DOUBLE_NEGATIVE:285,PNAME_LN:286,QueryOrUpdate_group0_option0:287,Prologue_repetition0_group0:288,SelectClause_option0_group0:289,DISTINCT:290,REDUCED:291,SelectClause_group0_repetition_plus0:292,"*":293,DescribeQuery_group0_repetition_plus0_group0:294,DescribeQuery_group0_repetition_plus0:295,NAMED:296,SILENT:297,CLEAR:298,DROP:299,ADD:300,MOVE:301,COPY:302,ALL:303,".":304,UNION:305,"|":306,"/":307,PathElt_option0_group0:308,"?":309,"+":310,"!=":311,"<":312,">":313,"<=":314,">=":315,NOT:316,CONCAT:317,COALESCE:318,SUBSTR:319,REGEX:320,REPLACE:321,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",12:"BASE",13:"IRIREF",15:"PREFIX",16:"PNAME_NS",24:"SELECT",28:"VAR",29:"(",31:"AS",32:")",34:"CONSTRUCT",38:"WHERE",39:"{",41:"}",43:"DESCRIBE",48:"ASK",51:"FROM",61:"GROUP",62:"BY",68:"HAVING",71:"ORDER",74:"ASC",76:"DESC",79:"LIMIT",80:"INTEGER",81:"OFFSET",83:"VALUES",86:"NIL",92:"UNDEF",99:"LOAD",108:"TO",109:"CREATE",111:"GRAPH",112:"INSERTDATA",114:"DELETEDATA",115:"DELETEWHERE",124:"DELETE",125:"INSERT",127:"USING",130:"WITH",132:"INTO",133:"DEFAULT",159:"OPTIONAL",160:"MINUS",162:"SERVICE",165:"FILTER",166:"BIND",183:";",187:"a",208:"!",213:"^",215:"[",216:"]",218:"BLANK_NODE_LABEL",219:"ANON",223:"||",227:"&&",231:"IN",246:"-",248:"FUNC_ARITY0",249:"FUNC_ARITY1",250:"FUNC_ARITY2",251:",",252:"IF",254:"BOUND",255:"BNODE",257:"EXISTS",258:"COUNT",261:"FUNC_AGGREGATE",263:"GROUP_CONCAT",267:"SEPARATOR",268:"=",270:"LANGTAG",271:"^^",272:"DECIMAL",273:"DOUBLE",274:"true",275:"false",276:"STRING_LITERAL1",277:"STRING_LITERAL2",278:"STRING_LITERAL_LONG1",279:"STRING_LITERAL_LONG2",280:"INTEGER_POSITIVE",281:"DECIMAL_POSITIVE",282:"DOUBLE_POSITIVE",283:"INTEGER_NEGATIVE",284:"DECIMAL_NEGATIVE",285:"DOUBLE_NEGATIVE",286:"PNAME_LN",290:"DISTINCT",291:"REDUCED",293:"*",296:"NAMED",297:"SILENT",298:"CLEAR",299:"DROP",300:"ADD",301:"MOVE",302:"COPY",303:"ALL",304:".",305:"UNION",306:"|",307:"/",309:"?",310:"+",311:"!=",312:"<",313:">",314:"<=",315:">=",316:"NOT",317:"CONCAT",318:"COALESCE",319:"SUBSTR",320:"REGEX",321:"REPLACE"},productions_:[0,[3,3],[4,1],[8,2],[11,2],[14,3],[17,4],[22,4],[18,3],[27,1],[27,5],[33,5],[33,7],[42,5],[47,4],[50,3],[20,2],[21,4],[60,3],[64,1],[64,1],[64,3],[64,5],[64,1],[67,2],[70,3],[73,2],[73,2],[73,1],[73,1],[78,2],[78,2],[78,4],[78,4],[82,2],[84,4],[84,4],[84,6],[90,1],[90,1],[90,1],[93,3],[95,3],[97,4],[97,3],[97,5],[97,4],[97,2],[97,2],[97,2],[97,6],[97,6],[121,2],[117,2],[126,3],[129,2],[131,3],[107,1],[107,2],[104,2],[104,1],[113,4],[138,7],[143,3],[55,3],[55,3],[147,2],[150,3],[154,3],[151,2],[151,2],[151,2],[151,3],[151,4],[151,2],[151,6],[151,1],[77,1],[77,1],[77,1],[66,2],[66,6],[169,1],[169,4],[35,3],[172,3],[145,2],[145,2],[178,1],[176,2],[182,2],[180,2],[185,1],[185,1],[185,1],[186,2],[156,2],[156,2],[190,4],[197,1],[197,3],[199,2],[201,2],[204,2],[203,2],[205,1],[205,1],[205,2],[205,3],[209,1],[209,1],[209,4],[210,1],[210,1],[210,2],[210,2],[177,3],[177,3],[191,3],[191,3],[189,1],[189,1],[195,1],[195,1],[175,1],[175,1],[175,1],[175,1],[175,1],[175,1],[30,2],[222,2],[220,2],[226,2],[224,1],[224,3],[224,4],[228,2],[234,2],[234,2],[234,2],[232,2],[242,2],[240,2],[240,2],[240,2],[245,1],[245,1],[245,1],[245,1],[245,1],[245,1],[75,3],[65,1],[65,2],[65,4],[65,6],[65,8],[65,2],[65,4],[65,2],[65,4],[65,3],[247,5],[247,5],[247,6],[266,4],[91,1],[91,2],[91,3],[91,1],[91,1],[91,1],[91,1],[91,1],[91,1],[91,1],[269,1],[269,1],[269,1],[269,1],[236,1],[236,1],[236,1],[238,1],[238,1],[238,1],[53,1],[53,1],[53,1],[287,0],[287,1],[5,1],[5,1],[288,1],[288,1],[7,0],[7,2],[9,1],[9,1],[9,1],[9,1],[10,0],[10,1],[19,0],[19,2],[23,0],[23,1],[289,1],[289,1],[25,0],[25,1],[292,1],[292,2],[26,1],[26,1],[36,0],[36,2],[37,0],[37,2],[40,0],[40,1],[294,1],[294,1],[295,1],[295,2],[44,1],[44,1],[45,0],[45,2],[46,0],[46,1],[49,0],[49,2],[52,0],[52,1],[54,0],[54,1],[56,0],[56,1],[57,0],[57,1],[58,0],[58,1],[59,0],[59,1],[63,1],[63,2],[69,1],[69,2],[72,1],[72,2],[85,0],[85,2],[87,0],[87,2],[88,1],[88,2],[89,0],[89,2],[94,1],[94,2],[96,0],[96,4],[98,0],[98,2],[100,0],[100,1],[101,0],[101,1],[102,1],[102,1],[103,0],[103,1],[105,1],[105,1],[105,1],[106,0],[106,1],[110,0],[110,1],[116,0],[116,1],[118,0],[118,1],[119,0],[119,2],[120,0],[120,1],[122,0],[122,1],[123,0],[123,2],[128,0],[128,1],[134,0],[134,1],[135,1],[135,1],[135,1],[136,0],[136,1],[137,0],[137,2],[139,1],[139,1],[140,0],[140,1],[141,0],[141,1],[142,0],[142,1],[144,0],[144,3],[146,0],[146,1],[148,0],[148,1],[149,0],[149,2],[152,0],[152,1],[153,0],[153,1],[155,0],[155,3],[157,0],[157,1],[158,0],[158,3],[161,1],[161,1],[163,0],[163,1],[164,1],[164,1],[167,0],[167,1],[168,0],[168,3],[170,0],[170,3],[171,0],[171,1],[173,0],[173,3],[174,0],[174,1],[179,0],[179,1],[181,0],[181,2],[184,0],[184,1],[188,0],[188,3],[192,0],[192,1],[193,1],[193,1],[194,0],[194,3],[196,0],[196,2],[198,1],[198,1],[200,0],[200,3],[202,0],[202,3],[308,1],[308,1],[308,1],[206,0],[206,1],[207,0],[207,1],[211,0],[211,3],[212,0],[212,1],[214,1],[214,2],[217,1],[217,2],[221,0],[221,2],[225,0],[225,2],[229,1],[229,1],[229,1],[229,1],[229,1],[229,1],[230,0],[230,1],[233,0],[233,2],[235,1],[235,1],[237,0],[237,2],[239,0],[239,2],[241,0],[241,2],[243,1],[243,1],[244,0],[244,1],[253,1],[253,1],[253,1],[253,1],[253,1],[256,0],[256,1],[259,0],[259,1],[260,1],[260,1],[262,0],[262,1],[264,0],[264,1],[265,0],[265,1]],performAction:function(e,t,r,i,s,n,a){var u,o,c=n.length-1;switch(s){case 1:return n[c-1]=n[c-1]||{},Gr.base&&(n[c-1].base=Gr.base),Gr.base=lr=Fr=Er="",n[c-1].prefixes=Gr.prefixes,Gr.prefixes=null,n[c-1];case 3:this.$=Dr(n[c-1],n[c],{type:"query"});break;case 4:Gr.base=gr(n[c]),lr=Fr=Er="";break;case 5:Gr.prefixes||(Gr.prefixes={}),n[c-1]=n[c-1].substr(0,n[c-1].length-1),n[c]=gr(n[c]),Gr.prefixes[n[c-1]]=n[c];break;case 6:this.$=Dr(n[c-3],Sr(n[c-2]),n[c-1],n[c]);break;case 7:this.$=Dr(n[c-3],n[c-2],n[c-1],n[c],{type:"query"});break;case 8:this.$=Dr({queryType:"SELECT",variables:"*"===n[c]?["*"]:n[c]},n[c-1]&&(n[c-2]=yr(n[c-1]),n[c-1]={},n[c-1][n[c-2]]=!0,n[c-1]));break;case 9:case 92:case 124:case 151:this.$=br(n[c]);break;case 10:case 22:this.$=dr(n[c-3],{variable:br(n[c-1])});break;case 11:this.$=Dr({queryType:"CONSTRUCT",template:n[c-3]},Sr(n[c-2]),n[c-1],n[c]);break;case 12:this.$=Dr({queryType:"CONSTRUCT",template:n[c-2]=n[c-2]?n[c-2].triples:[]},Sr(n[c-5]),{where:[{type:"bgp",triples:_r([],n[c-2])}]},n[c]);break;case 13:this.$=Dr({queryType:"DESCRIBE",variables:"*"===n[c-3]?["*"]:n[c-3].map(br)},Sr(n[c-2]),n[c-1],n[c]);break;case 14:this.$=Dr({queryType:"ASK"},Sr(n[c-2]),n[c-1],n[c]);break;case 15:case 54:this.$={iri:n[c],named:!!n[c-1]};break;case 16:this.$={where:n[c].patterns};break;case 17:this.$=Dr(n[c-3],n[c-2],n[c-1],n[c]);break;case 18:this.$={group:n[c]};break;case 19:case 20:case 26:case 28:this.$=dr(n[c]);break;case 21:this.$=dr(n[c-1]);break;case 23:case 29:this.$=dr(br(n[c]));break;case 24:this.$={having:n[c]};break;case 25:this.$={order:n[c]};break;case 27:this.$=dr(n[c],{descending:!0});break;case 30:this.$={limit:Nr(n[c])};break;case 31:this.$={offset:Nr(n[c])};break;case 32:this.$={limit:Nr(n[c-2]),offset:Nr(n[c])};break;case 33:this.$={limit:Nr(n[c]),offset:Nr(n[c-2])};break;case 34:this.$={type:"values",values:n[c]};break;case 35:n[c-3]=br(n[c-3]),this.$=n[c-1].map((function(e){var t={};return t[n[c-3]]=e,t}));break;case 36:this.$=n[c-1].map((function(){return{}}));break;case 37:var p=n[c-4].length;n[c-4]=n[c-4].map(br),this.$=n[c-1].map((function(e){if(e.length!==p)throw Error("Inconsistent VALUES length");for(var t={},r=0;r2&&I.push("'"+this.terminals_[T]+"'");N=h.showPosition?"Parse error on line "+(u+1)+":\n"+h.showPosition()+"\nExpecting "+I.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(u+1)+": Unexpected "+(1==_?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(N,{text:h.match,token:this.terminals_[_]||_,line:h.yylineno,loc:E,expected:I})}if(g[0]instanceof Array&&g.length>1)throw new Error("Parse Error: multiple actions possible at state: "+A+", token: "+_);switch(g[0]){case 1:r.push(_),i.push(h.yytext),s.push(h.yylloc),r.push(g[1]),_=null,D?(_=D,D=null):(o=h.yyleng,a=h.yytext,u=h.yylineno,E=h.yylloc,c>0&&c--);break;case 2:if(d=this.productions_[g[1]][1],S.$=i[i.length-d],S._$={first_line:s[s.length-(d||1)].first_line,last_line:s[s.length-1].last_line,first_column:s[s.length-(d||1)].first_column,last_column:s[s.length-1].last_column},f&&(S._$.range=[s[s.length-(d||1)].range[0],s[s.length-1].range[1]]),void 0!==(b=this.performAction.apply(S,[a,o,u,l.yy,g[1],i,s].concat(p))))return b;d&&(r=r.slice(0,-1*d*2),i=i.slice(0,-1*d),s=s.slice(0,-1*d)),r.push(this.productions_[g[1]][0]),i.push(S.$),s.push(S._$),C=n[r[r.length-2]][r[r.length-1]],r.push(C);break;case 3:return!0}}return!0}},er="http://www.w3.org/1999/02/22-rdf-syntax-ns#",tr=er+"type",rr=er+"first",ir=er+"rest",sr=er+"nil",nr="http://www.w3.org/2001/XMLSchema#",ar=nr+"integer",ur=nr+"decimal",or=nr+"double",cr=nr+"boolean",pr='"true"^^'+cr,hr='"false"^^'+cr,lr="",Fr="",Er="";function yr(e){return e.toLowerCase()}function fr(e,t){return e.push(t),e}function _r(e,t){return e.push.apply(e,t),e}function Dr(e){e||(e={});for(var t,r=1,i=arguments.length;r>10),56320+(1023&s))}var n=xr[i];if(!n)throw new Error;return n}))}catch(e){return""}return'"'+e+'"'}function Ur(e,t,r){var i=[],s=[];return t.forEach((function(t){i.push(mr(null,e,t.entity)),_r(s,t.triples)})),Ar(i,r||[],s)}var wr={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,r=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var i=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var s=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===i.length?this.yylloc.first_column:0)+i[i.length-r.length].length-r[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[s[0],s[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var r,i,s;if(this.options.backtrack_lexer&&(s={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(s.yylloc.range=this.yylloc.range.slice(0))),(i=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=i.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:i?i[i.length-1].length-i[i.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],r=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var n in s)this[n]=s[n];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,r,i;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var s=this._currentRules(),n=0;nt[0].length)){if(t=r,i=n,this.options.backtrack_lexer){if(!1!==(e=this.test_match(r,s[n])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,s[i]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{flex:!0,"case-insensitive":!0},performAction:function(e,t,r,i){switch(r){case 0:break;case 1:return 12;case 2:return 15;case 3:return 24;case 4:return 290;case 5:return 291;case 6:return 29;case 7:return 31;case 8:return 32;case 9:return 293;case 10:return 34;case 11:return 38;case 12:return 39;case 13:return 41;case 14:return 43;case 15:return 48;case 16:return 51;case 17:return 296;case 18:return 61;case 19:return 62;case 20:return 68;case 21:return 71;case 22:return 74;case 23:return 76;case 24:return 79;case 25:return 81;case 26:return 83;case 27:return 183;case 28:return 99;case 29:return 297;case 30:return 132;case 31:return 298;case 32:return 299;case 33:return 109;case 34:return 300;case 35:return 108;case 36:return 301;case 37:return 302;case 38:return 112;case 39:return 114;case 40:return 115;case 41:return 130;case 42:return 124;case 43:return 125;case 44:return 127;case 45:return 133;case 46:return 111;case 47:return 303;case 48:return 304;case 49:return 159;case 50:return 162;case 51:return 166;case 52:return 92;case 53:return 160;case 54:return 305;case 55:return 165;case 56:return 251;case 57:return 187;case 58:return 306;case 59:return 307;case 60:return 213;case 61:return 309;case 62:return 310;case 63:return 208;case 64:return 215;case 65:return 216;case 66:return 223;case 67:return 227;case 68:return 268;case 69:return 311;case 70:return 312;case 71:return 313;case 72:return 314;case 73:return 315;case 74:return 231;case 75:return 316;case 76:return 246;case 77:return 254;case 78:return 255;case 79:return 248;case 80:return 249;case 81:return 250;case 82:return 317;case 83:return 318;case 84:return 252;case 85:return 320;case 86:return 319;case 87:return 321;case 88:return 257;case 89:return 258;case 90:return 261;case 91:return 263;case 92:return 267;case 93:return 271;case 94:return 274;case 95:return 275;case 96:return 13;case 97:return 16;case 98:return 286;case 99:return 218;case 100:return 28;case 101:return 270;case 102:return 80;case 103:return 272;case 104:return 273;case 105:return 280;case 106:return 281;case 107:return 282;case 108:return 283;case 109:return 284;case 110:return 285;case 111:return"EXPONENT";case 112:return 276;case 113:return 277;case 114:return 278;case 115:return 279;case 116:return 86;case 117:return 219;case 118:return 6;case 119:return"INVALID";case 120:console.log(t.yytext)}},rules:[/^(?:\s+|#[^\n\r]*)/i,/^(?:BASE)/i,/^(?:PREFIX)/i,/^(?:SELECT)/i,/^(?:DISTINCT)/i,/^(?:REDUCED)/i,/^(?:\()/i,/^(?:AS)/i,/^(?:\))/i,/^(?:\*)/i,/^(?:CONSTRUCT)/i,/^(?:WHERE)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:DESCRIBE)/i,/^(?:ASK)/i,/^(?:FROM)/i,/^(?:NAMED)/i,/^(?:GROUP)/i,/^(?:BY)/i,/^(?:HAVING)/i,/^(?:ORDER)/i,/^(?:ASC)/i,/^(?:DESC)/i,/^(?:LIMIT)/i,/^(?:OFFSET)/i,/^(?:VALUES)/i,/^(?:;)/i,/^(?:LOAD)/i,/^(?:SILENT)/i,/^(?:INTO)/i,/^(?:CLEAR)/i,/^(?:DROP)/i,/^(?:CREATE)/i,/^(?:ADD)/i,/^(?:TO)/i,/^(?:MOVE)/i,/^(?:COPY)/i,/^(?:INSERT\s+DATA)/i,/^(?:DELETE\s+DATA)/i,/^(?:DELETE\s+WHERE)/i,/^(?:WITH)/i,/^(?:DELETE)/i,/^(?:INSERT)/i,/^(?:USING)/i,/^(?:DEFAULT)/i,/^(?:GRAPH)/i,/^(?:ALL)/i,/^(?:\.)/i,/^(?:OPTIONAL)/i,/^(?:SERVICE)/i,/^(?:BIND)/i,/^(?:UNDEF)/i,/^(?:MINUS)/i,/^(?:UNION)/i,/^(?:FILTER)/i,/^(?:,)/i,/^(?:a)/i,/^(?:\|)/i,/^(?:\/)/i,/^(?:\^)/i,/^(?:\?)/i,/^(?:\+)/i,/^(?:!)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:\|\|)/i,/^(?:&&)/i,/^(?:=)/i,/^(?:!=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:IN)/i,/^(?:NOT)/i,/^(?:-)/i,/^(?:BOUND)/i,/^(?:BNODE)/i,/^(?:(RAND|NOW|UUID|STRUUID))/i,/^(?:(LANG|DATATYPE|IRI|URI|ABS|CEIL|FLOOR|ROUND|STRLEN|STR|UCASE|LCASE|ENCODE_FOR_URI|YEAR|MONTH|DAY|HOURS|MINUTES|SECONDS|TIMEZONE|TZ|MD5|SHA1|SHA256|SHA384|SHA512|isIRI|isURI|isBLANK|isLITERAL|isNUMERIC))/i,/^(?:(LANGMATCHES|CONTAINS|STRSTARTS|STRENDS|STRBEFORE|STRAFTER|STRLANG|STRDT|sameTerm))/i,/^(?:CONCAT)/i,/^(?:COALESCE)/i,/^(?:IF)/i,/^(?:REGEX)/i,/^(?:SUBSTR)/i,/^(?:REPLACE)/i,/^(?:EXISTS)/i,/^(?:COUNT)/i,/^(?:SUM|MIN|MAX|AVG|SAMPLE)/i,/^(?:GROUP_CONCAT)/i,/^(?:SEPARATOR)/i,/^(?:\^\^)/i,/^(?:true)/i,/^(?:false)/i,/^(?:(<([^<>\"\{\}\|\^`\\\u0000-\u0020])*>))/i,/^(?:((([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(((((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])|\.)*(((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040]))?)?:))/i,/^(?:(((([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(((((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])|\.)*(((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040]))?)?:)((((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|:|[0-9]|((%([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))(((((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])|\.|:|((%([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))*((((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])|:|((%([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%)))))?)))/i,/^(?:(_:(((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(((((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])|\.)*(((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040]))?))/i,/^(?:([\?\$]((((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])*)))/i,/^(?:(@[a-zA-Z]+(-[a-zA-Z0-9]+)*))/i,/^(?:([0-9]+))/i,/^(?:([0-9]*\.[0-9]+))/i,/^(?:([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+)))/i,/^(?:(\+([0-9]+)))/i,/^(?:(\+([0-9]*\.[0-9]+)))/i,/^(?:(\+([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:(-([0-9]+)))/i,/^(?:(-([0-9]*\.[0-9]+)))/i,/^(?:(-([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:([eE][+-]?[0-9]+))/i,/^(?:('(([^\u0027\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])|\\U([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])))*'))/i,/^(?:("(([^\u0022\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])|\\U([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])))*"))/i,/^(?:('''(('|'')?([^'\\]|(\\[tbnrf\\\"']|\\u([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])|\\U([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f]))))*'''))/i,/^(?:("""(("|"")?([^\"\\]|(\\[tbnrf\\\"']|\\u([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])|\\U([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f]))))*"""))/i,/^(?:(\((\u0020|\u0009|\u000D|\u000A)*\)))/i,/^(?:(\[(\u0020|\u0009|\u000D|\u000A)*\]))/i,/^(?:$)/i,/^(?:.)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120],inclusive:!0}}};function Gr(){this.yy={}}return Jt.lexer=wr,Gr.prototype=Jt,Jt.Parser=Gr,new Gr}();t.parser=i,t.Parser=i.Parser,t.parse=function(){return i.parse.apply(i,arguments)},t.main=function(e){e[1]||(console.log("Usage: "+e[0]+" FILE"),process.exit(1));var i=r(203).readFileSync(r(783).normalize(e[1]),"utf8");return t.parser.parse(i)},r.c[r.s]===e&&t.main(process.argv.slice(1))},203:()=>{},783:()=>{}},t={};function r(i){var s=t[i];if(void 0!==s)return s.exports;var n=t[i]={id:i,loaded:!1,exports:{}};return e[i](n,n.exports,r),n.loaded=!0,n.exports}r.c=t,r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var i=r(r.s=734);window["SPARQL.js"]=i})(); \ No newline at end of file diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula-chevrotain.LICENSE.txt b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula-chevrotain.LICENSE.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula-chevrotain.LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.LICENSE.txt b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.LICENSE.txt new file mode 100644 index 0000000000..7c47ec05c9 --- /dev/null +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.LICENSE.txt @@ -0,0 +1,22 @@ +The bundled Traqula parser and generator are licensed under the MIT License. + +Copyright © 2024–now Jitse De Smet +Comunica Association and Ghent University – imec, Belgium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.min.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.min.js new file mode 100644 index 0000000000..d2e08423a2 --- /dev/null +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.min.js @@ -0,0 +1,122 @@ +(()=>{var Lm=Object.defineProperty;var Pt=(e,t)=>{for(var r in t)Lm(e,r,{get:t[r],enumerable:!0})};var Bt=class{tracksSourceLocation;constructor(t={}){this.tracksSourceLocation=t.tracksSourceLocation??!0}wrap(t,r){return{val:t,loc:r}}isLocalized(t){return typeof t=="object"&&t!==null&&"loc"in t&&typeof t.loc=="object"&&t.loc!==null&&"sourceLocationType"in t.loc}sourceLocation(...t){if(!this.tracksSourceLocation)return this.gen();let r=t.filter(a=>a!==void 0);if(r.length===0)return this.sourceLocationNoMaterialize();let n=r.filter(a=>!this.isLocalized(a)||this.isSourceLocationSource(a.loc)||this.isSourceLocationStringReplace(a.loc)||this.isSourceLocationNodeReplace(a.loc));if(n.length===0)return this.gen();let i=n.at(0),s=n.at(-1);return{sourceLocationType:"source",start:this.isLocalized(i)?i.loc.start:i.startOffset,end:this.isLocalized(s)?s.loc.end:s.endOffset+1}}sourceLocationNoMaterialize(){return this.tracksSourceLocation?{sourceLocationType:"noMaterialize"}:this.gen()}dematerialized(t){return{...t,loc:this.sourceLocationNoMaterialize()}}safeObjectTransform(t,r){return t&&typeof t=="object"?Array.isArray(t)?t.map(n=>this.safeObjectTransform(n,r)):r(t):t}forcedAutoGenTree(t){let r={...t};for(let[n,i]of Object.entries(r))r[n]=this.safeObjectTransform(i,s=>this.forcedAutoGenTree(s));return this.isLocalized(r)&&(r.loc=this.gen()),r}forceMaterialized(t){return this.isSourceLocationNoMaterialize(t.loc)?this.forcedAutoGenTree(t):{...t}}isSourceLocation(t){return"sourceLocationType"in t}sourceLocationSource(t,r){return{sourceLocationType:"source",start:t,end:r}}sourceLocationInlinedSource(t,r,n,i,s=0,a=t.length){return this.tracksSourceLocation?(this.isSourceLocationSource(r)&&(s=r.start,a=r.end),{sourceLocationType:"inlinedSource",newSource:t,start:n,end:i,loc:r,startOnNew:s,endOnNew:a}):this.gen()}isSourceLocationInlinedSource(t){return this.isSourceLocation(t)&&t.sourceLocationType==="inlinedSource"}gen(){return{sourceLocationType:"autoGenerate"}}isSourceLocationSource(t){return this.isSourceLocation(t)&&t.sourceLocationType==="source"}sourceLocationStringReplace(t,r,n){return this.tracksSourceLocation?{sourceLocationType:"stringReplace",newSource:t,start:r,end:n}:this.gen()}isSourceLocationStringReplace(t){return this.isSourceLocation(t)&&t.sourceLocationType==="stringReplace"}sourceLocationNodeReplaceUnsafe(t){if(this.isSourceLocationSource(t))return this.sourceLocationNodeReplace(t);if(this.isSourceLocationInlinedSource(t))return this.sourceLocationNodeReplaceUnsafe(t.loc);throw new Error(`Cannot convert SourceLocation of type ${t.sourceLocationType} to SourceLocationNodeReplace`)}sourceLocationNodeReplace(t,r){let n,i;return typeof t=="number"?(n=t,i=r):(n=t.start,i=t.end),{sourceLocationType:"nodeReplace",start:n,end:i}}isSourceLocationNodeReplace(t){return this.isSourceLocation(t)&&t.sourceLocationType==="nodeReplace"}isSourceLocationNodeAutoGenerate(t){return this.isSourceLocation(t)&&t.sourceLocationType==="autoGenerate"}isPrintingLoc(t){return this.isSourceLocationNodeReplace(t)||this.isSourceLocationNodeAutoGenerate(t)||this.isSourceLocationInlinedSource(t)&&this.isPrintingLoc(t.loc)}printFilter(t,r){this.isPrintingLoc(t.loc)&&r()}isSourceLocationNoMaterialize(t){return this.isSourceLocation(t)&&t.sourceLocationType==="noMaterialize"}isOfType(t,r){return t.type===r}isOfSubType(t,r,n){let i=t;return i.type===r&&i.subType===n}};var _m=typeof global=="object"&&global&&global.Object===Object&&global,bl=_m,Om=typeof self=="object"&&self&&self.Object===Object&&self,Sm=bl||Om||Function("return this")(),Ue=Sm,Nm=Ue.Symbol,Fe=Nm,xl=Object.prototype,Pm=xl.hasOwnProperty,km=xl.toString,vr=Fe?Fe.toStringTag:void 0;function Rm(e){var t=Pm.call(e,vr),r=e[vr];try{e[vr]=void 0;var n=!0}catch{}var i=km.call(e);return n&&(t?e[vr]=r:delete e[vr]),i}var Fm=Rm,wm=Object.prototype,Cm=wm.toString;function Mm(e){return Cm.call(e)}var Dm=Mm,Gm="[object Null]",$m="[object Undefined]",yc=Fe?Fe.toStringTag:void 0;function jm(e){return e==null?e===void 0?$m:Gm:yc&&yc in Object(e)?Fm(e):Dm(e)}var It=jm;function Vm(e){return e!=null&&typeof e=="object"}var He=Vm,Km="[object Symbol]";function Hm(e){return typeof e=="symbol"||He(e)&&It(e)==Km}var Fn=Hm;function Wm(e,t){for(var r=-1,n=e==null?0:e.length,i=Array(n);++r0){if(++t>=Hg)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Yg=qg;function Xg(e){return function(){return e}}var Bg=Xg,Qg=(function(){try{var e=Dt(Object,"defineProperty");return e({},"",{}),e}catch{}})(),xn=Qg,Zg=xn?function(e,t){return xn(e,"toString",{configurable:!0,enumerable:!1,value:Bg(t),writable:!0})}:wr,Jg=Zg,Ug=Yg(Jg),eT=Ug;function tT(e,t){for(var r=-1,n=e==null?0:e.length;++r-1}var _l=cT,lT=9007199254740991,uT=/^(?:0|[1-9]\d*)$/;function pT(e,t){var r=typeof e;return t=t??lT,!!t&&(r=="number"||r!="symbol"&&uT.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=bT}var ra=xT;function IT(e){return e!=null&&ra(e.length)&&!ft(e)}var et=IT;function ET(e,t,r){if(!we(r))return!1;var n=typeof t;return(n=="number"?et(r)&&wn(t,r.length):n=="string"&&t in r)?Cr(r[t],e):!1}var Mn=ET;function LT(e){return ta(function(t,r){var n=-1,i=r.length,s=i>1?r[i-1]:void 0,a=i>2?r[2]:void 0;for(s=e.length>3&&typeof s=="function"?(i--,s):void 0,a&&Mn(r[0],r[1],a)&&(s=i<3?void 0:s,i=1),t=Object(t);++n-1}var fv=hv;function dv(e,t){var r=this.__data__,n=$n(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var mv=dv;function rr(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t0&&r(o)?t>1?wl(o,t-1,r,n,i):oa(i,o):n||(i[i.length]=o)}return i}var ca=wl;function Bv(e){var t=e==null?0:e.length;return t?ca(e,1):[]}var Ve=Bv,Qv=kl(Object.getPrototypeOf,Object),Cl=Qv;function Zv(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),r=r>i?i:r,r<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var s=Array(i);++n=n?e:la(e,t,r)}var Uv=Jv,eA="\\ud800-\\udfff",tA="\\u0300-\\u036f",rA="\\ufe20-\\ufe2f",nA="\\u20d0-\\u20ff",iA=tA+rA+nA,sA="\\ufe0e\\ufe0f",aA="\\u200d",oA=RegExp("["+aA+eA+iA+sA+"]");function cA(e){return oA.test(e)}var Ml=cA;function lA(e){return e.split("")}var uA=lA,Dl="\\ud800-\\udfff",pA="\\u0300-\\u036f",hA="\\ufe20-\\ufe2f",fA="\\u20d0-\\u20ff",dA=pA+hA+fA,mA="\\ufe0e\\ufe0f",gA="["+Dl+"]",$s="["+dA+"]",js="\\ud83c[\\udffb-\\udfff]",TA="(?:"+$s+"|"+js+")",Gl="[^"+Dl+"]",$l="(?:\\ud83c[\\udde6-\\uddff]){2}",jl="[\\ud800-\\udbff][\\udc00-\\udfff]",yA="\\u200d",Vl=TA+"?",Kl="["+mA+"]?",vA="(?:"+yA+"(?:"+[Gl,$l,jl].join("|")+")"+Kl+Vl+")*",AA=Kl+Vl+vA,bA="(?:"+[Gl+$s+"?",$s,$l,jl,gA].join("|")+")",xA=RegExp(js+"(?="+js+")|"+bA+AA,"g");function IA(e){return e.match(xA)||[]}var EA=IA;function LA(e){return Ml(e)?EA(e):uA(e)}var _A=LA;function OA(e){return function(t){t=Fl(t);var r=Ml(t)?_A(t):void 0,n=r?r[0]:t.charAt(0),i=r?Uv(r,1).join(""):t.slice(1);return n[e]()+i}}var SA=OA,vS=SA("toUpperCase");function NA(e,t,r,n){var i=-1,s=e==null?0:e.length;for(n&&s&&(r=e[++i]);++io))return!1;var l=s.get(e),p=s.get(t);if(l&&p)return l==t&&p==e;var h=-1,d=!0,m=r&Qx?new fa:void 0;for(s.set(e,t),s.set(t,e);++h2?t[2]:void 0;for(i&&Mn(t[0],t[1],i)&&(n=1);++r=gE&&(s=da,a=!1,t=new fa(t));e:for(;++i-1?i[s?t[a]:a]:void 0}}var wE=FE,CE=Math.max;function ME(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var i=r==null?0:Fr(r);return i<0&&(i=CE(n+i,0)),Ll(e,tt(t,3),i)}var DE=ME,GE=wE(DE),Ut=GE;function $E(e){return e&&e.length?e[0]:void 0}var We=$E;function jE(e,t){var r=-1,n=et(e)?Array(e.length):[];return Gt(e,function(i,s,a){n[++r]=t(i,s,a)}),n}var VE=jE;function KE(e,t){var r=D(e)?Rr:VE;return r(e,tt(t,3))}var O=KE;function HE(e,t){return ca(O(e,t),1)}var Re=HE,WE=Object.prototype,zE=WE.hasOwnProperty,qE=pE(function(e,t,r){zE.call(e,r)?e[r].push(t):ea(e,r,[t])}),YE=qE,XE=Object.prototype,BE=XE.hasOwnProperty;function QE(e,t){return e!=null&&BE.call(e,t)}var ZE=QE;function JE(e,t){return e!=null&&nu(e,t,ZE)}var N=JE,UE="[object String]";function eL(e){return typeof e=="string"||!D(e)&&He(e)&&It(e)==UE}var Ie=eL;function tL(e,t){return Rr(t,function(r){return e[r]})}var rL=tL;function nL(e){return e==null?[]:rL(e,Le(e))}var ie=nL,iL=Math.max;function sL(e,t,r,n){e=et(e)?e:ie(e),r=r&&!n?Fr(r):0;var i=e.length;return r<0&&(r=iL(i+r,0)),Ie(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&Us(e,t,r)>-1}var Te=sL,aL=Math.max;function oL(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var i=r==null?0:Fr(r);return i<0&&(i=aL(n+i,0)),Us(e,t,i)}var Qc=oL,cL="[object Map]",lL="[object Set]",uL=Object.prototype,pL=uL.hasOwnProperty;function hL(e){if(e==null)return!0;if(et(e)&&(D(e)||typeof e=="string"||typeof e.splice=="function"||Sr(e)||na(e)||Dn(e)))return!e.length;var t=Jt(e);if(t==cL||t==lL)return!e.size;if(Dr(e))return!Rl(e).length;for(var r in e)if(pL.call(e,r))return!1;return!0}var V=hL,fL="[object RegExp]";function dL(e){return He(e)&&It(e)==fL}var mL=dL,Zc=bt&&bt.isRegExp,gL=Zc?Gr(Zc):mL,ut=gL;function TL(e){return e===void 0}var pt=TL,yL="Expected a function";function vL(e){if(typeof e!="function")throw new TypeError(yL);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}var AL=vL;function bL(e,t,r,n){if(!we(e))return e;t=Hn(t,e);for(var i=-1,s=t.length,a=s-1,o=e;o!=null&&++i=ML){var l=t?null:CL(e);if(l)return ma(l);a=!1,i=da,c=new fa}else c=t?[]:o;e:for(;++n{t.accept(e)})}},Se=class extends rt{constructor(e){super([]),this.idx=1,_e(this,ze(e,t=>t!==void 0))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}},sr=class extends rt{constructor(e){super(e.definition),this.orgText="",_e(this,ze(e,t=>t!==void 0))}},Ee=class extends rt{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,_e(this,ze(e,t=>t!==void 0))}},be=class extends rt{constructor(e){super(e.definition),this.idx=1,_e(this,ze(e,t=>t!==void 0))}},nt=class extends rt{constructor(e){super(e.definition),this.idx=1,_e(this,ze(e,t=>t!==void 0))}},it=class extends rt{constructor(e){super(e.definition),this.idx=1,_e(this,ze(e,t=>t!==void 0))}},se=class extends rt{constructor(e){super(e.definition),this.idx=1,_e(this,ze(e,t=>t!==void 0))}},qe=class extends rt{constructor(e){super(e.definition),this.idx=1,_e(this,ze(e,t=>t!==void 0))}},Ye=class extends rt{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,_e(this,ze(e,t=>t!==void 0))}},B=class{constructor(e){this.idx=1,_e(this,ze(e,t=>t!==void 0))}accept(e){e.visit(this)}};function KL(e){return O(e,Tn)}function Tn(e){function t(r){return O(r,Tn)}if(e instanceof Se){let r={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};return Ie(e.label)&&(r.label=e.label),r}else{if(e instanceof Ee)return{type:"Alternative",definition:t(e.definition)};if(e instanceof be)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof nt)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof it)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:Tn(new B({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof qe)return{type:"RepetitionWithSeparator",idx:e.idx,separator:Tn(new B({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof se)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof Ye)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof B){let r={type:"Terminal",name:e.terminalType.name,label:jL(e.terminalType),idx:e.idx};Ie(e.label)&&(r.terminalLabel=e.label);let n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(r.pattern=ut(n)?n.source:n),r}else{if(e instanceof sr)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match")}}}var ar=class{visit(e){let t=e;switch(t.constructor){case Se:return this.visitNonTerminal(t);case Ee:return this.visitAlternative(t);case be:return this.visitOption(t);case nt:return this.visitRepetitionMandatory(t);case it:return this.visitRepetitionMandatoryWithSeparator(t);case qe:return this.visitRepetitionWithSeparator(t);case se:return this.visitRepetition(t);case Ye:return this.visitAlternation(t);case B:return this.visitTerminal(t);case sr:return this.visitRule(t);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}};function HL(e){return e instanceof Ee||e instanceof be||e instanceof se||e instanceof nt||e instanceof it||e instanceof qe||e instanceof B||e instanceof sr}function Ln(e,t=[]){return e instanceof be||e instanceof se||e instanceof qe?!0:e instanceof Ye?ou(e.definition,n=>Ln(n,t)):e instanceof Se&&Te(t,e)?!1:e instanceof rt?(e instanceof Se&&t.push(e),Ke(e.definition,n=>Ln(n,t))):!1}function WL(e){return e instanceof Ye}function Je(e){if(e instanceof Se)return"SUBRULE";if(e instanceof be)return"OPTION";if(e instanceof Ye)return"OR";if(e instanceof nt)return"AT_LEAST_ONE";if(e instanceof it)return"AT_LEAST_ONE_SEP";if(e instanceof qe)return"MANY_SEP";if(e instanceof se)return"MANY";if(e instanceof B)return"CONSUME";throw Error("non exhaustive match")}var qn=class{walk(e,t=[]){P(e.definition,(r,n)=>{let i=ce(e.definition,n+1);if(r instanceof Se)this.walkProdRef(r,i,t);else if(r instanceof B)this.walkTerminal(r,i,t);else if(r instanceof Ee)this.walkFlat(r,i,t);else if(r instanceof be)this.walkOption(r,i,t);else if(r instanceof nt)this.walkAtLeastOne(r,i,t);else if(r instanceof it)this.walkAtLeastOneSep(r,i,t);else if(r instanceof qe)this.walkManySep(r,i,t);else if(r instanceof se)this.walkMany(r,i,t);else if(r instanceof Ye)this.walkOr(r,i,t);else throw Error("non exhaustive match")})}walkTerminal(e,t,r){}walkProdRef(e,t,r){}walkFlat(e,t,r){let n=t.concat(r);this.walk(e,n)}walkOption(e,t,r){let n=t.concat(r);this.walk(e,n)}walkAtLeastOne(e,t,r){let n=[new be({definition:e.definition})].concat(t,r);this.walk(e,n)}walkAtLeastOneSep(e,t,r){let n=Jc(e,t,r);this.walk(e,n)}walkMany(e,t,r){let n=[new be({definition:e.definition})].concat(t,r);this.walk(e,n)}walkManySep(e,t,r){let n=Jc(e,t,r);this.walk(e,n)}walkOr(e,t,r){let n=t.concat(r);P(e.definition,i=>{let s=new Ee({definition:[i]});this.walk(s,n)})}};function Jc(e,t,r){return[new be({definition:[new B({terminalType:e.separator})].concat(e.definition)})].concat(t,r)}function Vr(e){if(e instanceof Se)return Vr(e.referencedRule);if(e instanceof B)return YL(e);if(HL(e))return zL(e);if(WL(e))return qL(e);throw Error("non exhaustive match")}function zL(e){let t=[],r=e.definition,n=0,i=r.length>n,s,a=!0;for(;i&&a;)s=r[n],a=Ln(s),t=t.concat(Vr(s)),n=n+1,i=r.length>n;return Ta(t)}function qL(e){let t=O(e.definition,r=>Vr(r));return Ta(Ve(t))}function YL(e){return[e.terminalType]}var pu="_~IN~_",XL=class extends qn{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,r){}walkProdRef(e,t,r){let n=QL(e.referencedRule,e.idx)+this.topProd.name,i=t.concat(r),s=new Ee({definition:i}),a=Vr(s);this.follows[n]=a}};function BL(e){let t={};return P(e,r=>{let n=new XL(r).startWalking();_e(t,n)}),t}function QL(e,t){return e.name+t+pu}function k(e){return e.charCodeAt(0)}function Fs(e,t){Array.isArray(e)?e.forEach(function(r){t.push(r)}):t.push(e)}function Ar(e,t){if(e[t]===!0)throw"duplicate flag "+t;let r=e[t];e[t]=!0}function Qt(e){if(e===void 0)throw Error("Internal Error - Should never get here!");return!0}function pn(){throw Error("Internal Error - Should never get here!")}function Uc(e){return e.type==="Character"}var _n=[];for(let e=k("0");e<=k("9");e++)_n.push(e);var On=[k("_")].concat(_n);for(let e=k("a");e<=k("z");e++)On.push(e);for(let e=k("A");e<=k("Z");e++)On.push(e);var el=[k(" "),k("\f"),k(` +`),k("\r"),k(" "),k("\v"),k(" "),k("\xA0"),k("\u1680"),k("\u2000"),k("\u2001"),k("\u2002"),k("\u2003"),k("\u2004"),k("\u2005"),k("\u2006"),k("\u2007"),k("\u2008"),k("\u2009"),k("\u200A"),k("\u2028"),k("\u2029"),k("\u202F"),k("\u205F"),k("\u3000"),k("\uFEFF")],ZL=/[0-9a-fA-F]/,hn=/[0-9]/,JL=/[1-9]/,UL=class{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");let t=this.disjunction();this.consumeChar("/");let r={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":Ar(r,"global");break;case"i":Ar(r,"ignoreCase");break;case"m":Ar(r,"multiLine");break;case"u":Ar(r,"unicode");break;case"y":Ar(r,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:r,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let t;switch(this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":t="Lookbehind";break;case"!":t="NegativeLookbehind"}break}}Qt(t);let r=this.disjunction();return this.consumeChar(")"),{type:t,value:r,loc:this.loc(e)}}return pn()}quantifier(e=!1){let t,r=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":let n=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:n,atMost:n};break;case",":let i;this.isDigit()?(i=this.integerIncludingZero(),t={atLeast:n,atMost:i}):t={atLeast:n,atMost:1/0},this.consumeChar("}");break}if(e===!0&&t===void 0)return;Qt(t);break}if(!(e===!0&&t===void 0)&&Qt(t))return this.peekChar(0)==="?"?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(r),t}atom(){let e,t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group();break}return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),Qt(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):pn()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[k(` +`),k("\r"),k("\u2028"),k("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case"d":e=_n;break;case"D":e=_n,t=!0;break;case"s":e=el;break;case"S":e=el,t=!0;break;case"w":e=On;break;case"W":e=On,t=!0;break}return Qt(e)?{type:"Set",value:e,complement:t}:pn()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=k("\f");break;case"n":e=k(` +`);break;case"r":e=k("\r");break;case"t":e=k(" ");break;case"v":e=k("\v");break}return Qt(e)?{type:"Character",value:e}:pn()}controlLetterEscapeAtom(){this.consumeChar("c");let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:k("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){let e=this.popChar();return{type:"Character",value:k(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case` +`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let e=this.popChar();return{type:"Character",value:k(e)}}}characterClass(){let e=[],t=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),t=!0);this.isClassAtom();){let r=this.classAtom(),n=r.type==="Character";if(Uc(r)&&this.isRangeDash()){this.consumeChar("-");let i=this.classAtom(),s=i.type==="Character";if(Uc(i)){if(i.value=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}},ya=class{visitChildren(e){for(let t in e){let r=e[t];e.hasOwnProperty(t)&&(r.type!==void 0?this.visit(r):Array.isArray(r)&&r.forEach(n=>{this.visit(n)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Lookbehind":this.visitLookbehind(e);break;case"NegativeLookbehind":this.visitNegativeLookbehind(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e);break}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}},yn={},e_=new UL;function Yn(e){let t=e.toString();if(yn.hasOwnProperty(t))return yn[t];{let r=e_.pattern(t);return yn[t]=r,r}}function t_(){yn={}}var hu="Complement Sets are not supported for first char optimization",Sn=`Unable to use "first char" lexer optimizations: +`;function r_(e,t=!1){try{let r=Yn(e);return zs(r.value,{},r.flags.ignoreCase)}catch(r){if(r.message===hu)t&&cu(`${Sn} Unable to optimize: < ${e.toString()} > + Complement Sets cannot be automatically optimized. + This will disable the lexer's first char optimizations. + See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n="";t&&(n=` + This will disable the lexer's first char optimizations. + See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),Ws(`${Sn} + Failed parsing: < ${e.toString()} > + Using the @chevrotain/regexp-to-ast library + Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function zs(e,t,r){switch(e.type){case"Disjunction":for(let i=0;i{if(typeof c=="number")fn(c,t,r);else{let l=c;if(r===!0)for(let p=l.from;p<=l.to;p++)fn(p,t,r);else{for(let p=l.from;p<=l.to&&p=Ir){let p=l.from>=Ir?l.from:Ir,h=l.to,d=xt(p),m=xt(h);for(let A=d;A<=m;A++)t[A]=A}}}});break;case"Group":zs(a.value,t,r);break;default:throw Error("Non Exhaustive Match")}let o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type==="Group"&&qs(a)===!1||a.type!=="Group"&&o===!1)break}break;default:throw Error("non exhaustive match!")}return ie(t)}function fn(e,t,r){let n=xt(e);t[n]=n,r===!0&&n_(e,t)}function n_(e,t){let r=String.fromCharCode(e),n=r.toUpperCase();if(n!==r){let i=xt(n.charCodeAt(0));t[i]=i}else{let i=r.toLowerCase();if(i!==r){let s=xt(i.charCodeAt(0));t[s]=s}}}function tl(e,t){return Ut(e.value,r=>{if(typeof r=="number")return Te(t,r);{let n=r;return Ut(t,i=>n.from<=i&&i<=n.to)!==void 0}})}function qs(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?D(e.value)?Ke(e.value,qs):qs(e.value):!1}var i_=class extends ya{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case"Lookahead":this.visitLookahead(e);return;case"NegativeLookahead":this.visitNegativeLookahead(e);return;case"Lookbehind":this.visitLookbehind(e);return;case"NegativeLookbehind":this.visitNegativeLookbehind(e);return}super.visitChildren(e)}}visitCharacter(e){Te(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?tl(e,this.targetCharCodes)===void 0&&(this.found=!0):tl(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function va(e,t){if(t instanceof RegExp){let r=Yn(t),n=new i_(e);return n.visit(r),n.found}else return Ut(t,r=>Te(e,r.charCodeAt(0)))!==void 0}var wt="PATTERN",xr="defaultMode",dn="modes";function s_(e,t){t=ga(t,{debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",` +`],tracer:(x,T)=>T()});let r=t.tracer;r("initCharCodeToOptimizedIndexMap",()=>{N_()});let n;r("Reject Lexer.NA",()=>{n=zn(e,x=>x[wt]===le.NA)});let i=!1,s;r("Transform Patterns",()=>{i=!1,s=O(n,x=>{let T=x[wt];if(ut(T)){let I=T.source;return I.length===1&&I!=="^"&&I!=="$"&&I!=="."&&!T.ignoreCase?I:I.length===2&&I[0]==="\\"&&!Te(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],I[1])?I[1]:rl(T)}else{if(ft(T))return i=!0,{exec:T};if(typeof T=="object")return i=!0,T;if(typeof T=="string"){if(T.length===1)return T;{let I=T.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),S=new RegExp(I);return rl(S)}}else throw Error("non exhaustive match")}})});let a,o,c,l,p;r("misc mapping",()=>{a=O(n,x=>x.tokenTypeIdx),o=O(n,x=>{let T=x.GROUP;if(T!==le.SKIPPED){if(Ie(T))return T;if(pt(T))return!1;throw Error("non exhaustive match")}}),c=O(n,x=>{let T=x.LONGER_ALT;if(T)return D(T)?O(T,S=>Qc(n,S)):[Qc(n,T)]}),l=O(n,x=>x.PUSH_MODE),p=O(n,x=>N(x,"POP_MODE"))});let h;r("Line Terminator Handling",()=>{let x=mu(t.lineTerminatorCharacters);h=O(n,T=>!1),t.positionTracking!=="onlyOffset"&&(h=O(n,T=>N(T,"LINE_BREAKS")?!!T.LINE_BREAKS:du(T,x)===!1&&va(x,T.PATTERN)))});let d,m,A,b;r("Misc Mapping #2",()=>{d=O(n,fu),m=O(s,__),A=Oe(n,(x,T)=>{let I=T.GROUP;return Ie(I)&&I!==le.SKIPPED&&(x[I]=[]),x},{}),b=O(s,(x,T)=>({pattern:s[T],longerAlt:c[T],canLineTerminator:h[T],isCustom:d[T],short:m[T],group:o[T],push:l[T],pop:p[T],tokenTypeIdx:a[T],tokenType:n[T]}))});let y=!0,v=[];return t.safeMode||r("First Char Optimization",()=>{v=Oe(n,(x,T,I)=>{if(typeof T.PATTERN=="string"){let S=T.PATTERN.charCodeAt(0),C=xt(S);ws(x,C,b[I])}else if(D(T.START_CHARS_HINT)){let S;P(T.START_CHARS_HINT,C=>{let X=typeof C=="string"?C.charCodeAt(0):C,M=xt(X);S!==M&&(S=M,ws(x,M,b[I]))})}else if(ut(T.PATTERN))if(T.PATTERN.unicode)y=!1,t.ensureOptimizations&&Ws(`${Sn} Unable to analyze < ${T.PATTERN.toString()} > pattern. + The regexp unicode flag is not currently supported by the regexp-to-ast library. + This will disable the lexer's first char optimizations. + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let S=r_(T.PATTERN,t.ensureOptimizations);V(S)&&(y=!1),P(S,C=>{ws(x,C,b[I])})}else t.ensureOptimizations&&Ws(`${Sn} TokenType: <${T.name}> is using a custom token pattern without providing parameter. + This will disable the lexer's first char optimizations. + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),y=!1;return x},[])}),{emptyGroups:A,patternIdxToConfig:b,charCodeToPatternIdxToConfig:v,hasCustom:i,canBeOptimized:y}}function a_(e,t){let r=[],n=c_(e);r=r.concat(n.errors);let i=l_(n.valid),s=i.valid;return r=r.concat(i.errors),r=r.concat(o_(s)),r=r.concat(T_(s)),r=r.concat(y_(s,t)),r=r.concat(v_(s)),r}function o_(e){let t=[],r=Ce(e,n=>ut(n[wt]));return t=t.concat(p_(r)),t=t.concat(d_(r)),t=t.concat(m_(r)),t=t.concat(g_(r)),t=t.concat(h_(r)),t}function c_(e){let t=Ce(e,i=>!N(i,wt)),r=O(t,i=>({message:"Token Type: ->"+i.name+"<- missing static 'PATTERN' property",type:Z.MISSING_PATTERN,tokenTypes:[i]})),n=Wn(e,t);return{errors:r,valid:n}}function l_(e){let t=Ce(e,i=>{let s=i[wt];return!ut(s)&&!ft(s)&&!N(s,"exec")&&!Ie(s)}),r=O(t,i=>({message:"Token Type: ->"+i.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:Z.INVALID_PATTERN,tokenTypes:[i]})),n=Wn(e,t);return{errors:r,valid:n}}var u_=/[^\\][$]/;function p_(e){class t extends ya{constructor(){super(...arguments),this.found=!1}visitEndAnchor(s){this.found=!0}}let r=Ce(e,i=>{let s=i.PATTERN;try{let a=Yn(s),o=new t;return o.visit(a),o.found}catch{return u_.test(s.source)}});return O(r,i=>({message:`Unexpected RegExp Anchor Error: + Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain end of input anchor '$' + See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:Z.EOI_ANCHOR_FOUND,tokenTypes:[i]}))}function h_(e){let t=Ce(e,n=>n.PATTERN.test(""));return O(t,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' must not match an empty string",type:Z.EMPTY_MATCH_PATTERN,tokenTypes:[n]}))}var f_=/[^\\[][\^]|^\^/;function d_(e){class t extends ya{constructor(){super(...arguments),this.found=!1}visitStartAnchor(s){this.found=!0}}let r=Ce(e,i=>{let s=i.PATTERN;try{let a=Yn(s),o=new t;return o.visit(a),o.found}catch{return f_.test(s.source)}});return O(r,i=>({message:`Unexpected RegExp Anchor Error: + Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain start of input anchor '^' + See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:Z.SOI_ANCHOR_FOUND,tokenTypes:[i]}))}function m_(e){let t=Ce(e,n=>{let i=n[wt];return i instanceof RegExp&&(i.multiline||i.global)});return O(t,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:Z.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[n]}))}function g_(e){let t=[],r=O(e,s=>Oe(e,(a,o)=>(s.PATTERN.source===o.PATTERN.source&&!Te(t,o)&&o.PATTERN!==le.NA&&(t.push(o),a.push(o)),a),[]));r=jr(r);let n=Ce(r,s=>s.length>1);return O(n,s=>{let a=O(s,c=>c.name);return{message:`The same RegExp pattern ->${We(s).PATTERN}<-has been used in all of the following Token Types: ${a.join(", ")} <-`,type:Z.DUPLICATE_PATTERNS_FOUND,tokenTypes:s}})}function T_(e){let t=Ce(e,n=>{if(!N(n,"GROUP"))return!1;let i=n.GROUP;return i!==le.SKIPPED&&i!==le.NA&&!Ie(i)});return O(t,n=>({message:"Token Type: ->"+n.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:Z.INVALID_GROUP_TYPE_FOUND,tokenTypes:[n]}))}function y_(e,t){let r=Ce(e,i=>i.PUSH_MODE!==void 0&&!Te(t,i.PUSH_MODE));return O(r,i=>({message:`Token Type: ->${i.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${i.PUSH_MODE}<-which does not exist`,type:Z.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[i]}))}function v_(e){let t=[],r=Oe(e,(n,i,s)=>{let a=i.PATTERN;return a===le.NA||(Ie(a)?n.push({str:a,idx:s,tokenType:i}):ut(a)&&b_(a)&&n.push({str:a.source,idx:s,tokenType:i})),n},[]);return P(e,(n,i)=>{P(r,({str:s,idx:a,tokenType:o})=>{if(i${o.name}<- can never be matched. +Because it appears AFTER the Token Type ->${n.name}<-in the lexer's definition. +See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:c,type:Z.UNREACHABLE_PATTERN,tokenTypes:[n,o]})}})}),t}function A_(e,t){if(ut(t)){if(x_(t))return!1;let r=t.exec(e);return r!==null&&r.index===0}else{if(ft(t))return t(e,0,[],{});if(N(t,"exec"))return t.exec(e,0,[],{});if(typeof t=="string")return t===e;throw Error("non exhaustive match")}}function b_(e){return Ut([".","\\","[","]","|","^","$","(",")","?","*","+","{"],r=>e.source.indexOf(r)!==-1)===void 0}function x_(e){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\? property in its definition +`,type:Z.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),N(e,dn)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+dn+`> property in its definition +`,type:Z.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),N(e,dn)&&N(e,xr)&&!N(e.modes,e.defaultMode)&&n.push({message:`A MultiMode Lexer cannot be initialized with a ${xr}: <${e.defaultMode}>which does not exist +`,type:Z.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),N(e,dn)&&P(e.modes,(i,s)=>{P(i,(a,o)=>{if(pt(a))n.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${s}> at index: <${o}> +`,type:Z.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(N(a,"LONGER_ALT")){let c=D(a.LONGER_ALT)?a.LONGER_ALT:[a.LONGER_ALT];P(c,l=>{!pt(l)&&!Te(i,l)&&n.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${l.name}> on token <${a.name}> outside of mode <${s}> +`,type:Z.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),n}function E_(e,t,r){let n=[],i=!1,s=jr(Ve(ie(e.modes))),a=zn(s,c=>c[wt]===le.NA),o=mu(r);return t&&P(a,c=>{let l=du(c,o);if(l!==!1){let h={message:S_(c,l),type:l.issue,tokenType:c};n.push(h)}else N(c,"LINE_BREAKS")?c.LINE_BREAKS===!0&&(i=!0):va(o,c.PATTERN)&&(i=!0)}),t&&!i&&n.push({message:`Warning: No LINE_BREAKS Found. + This Lexer has been defined to track line and column information, + But none of the Token Types can be identified as matching a line terminator. + See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS + for details.`,type:Z.NO_LINE_BREAKS_FLAGS}),n}function L_(e){let t={},r=Le(e);return P(r,n=>{let i=e[n];if(D(i))t[n]=[];else throw Error("non exhaustive match")}),t}function fu(e){let t=e.PATTERN;if(ut(t))return!1;if(ft(t))return!0;if(N(t,"exec"))return!0;if(Ie(t))return!1;throw Error("non exhaustive match")}function __(e){return Ie(e)&&e.length===1?e.charCodeAt(0):!1}var O_={test:function(e){let t=e.length;for(let r=this.lastIndex;r Token Type + Root cause: ${t.errMsg}. + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===Z.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the option. + The problem is in the <${e.name}> Token Type + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function mu(e){return O(e,r=>Ie(r)?r.charCodeAt(0):r)}function ws(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}var Ir=256,vn=[];function xt(e){return e255?255+~~(e/255):e}}function Kr(e,t){let r=e.tokenTypeIdx;return r===t.tokenTypeIdx?!0:t.isParent===!0&&t.categoryMatchesMap[r]===!0}function Nn(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}var nl=1,gu={};function Hr(e){let t=P_(e);k_(t),F_(t),R_(t),P(t,r=>{r.isParent=r.categoryMatches.length>0})}function P_(e){let t=xe(e),r=e,n=!0;for(;n;){r=jr(Ve(O(r,s=>s.CATEGORIES)));let i=Wn(r,t);t=t.concat(i),V(i)?n=!1:r=i}return t}function k_(e){P(e,t=>{yu(t)||(gu[nl]=t,t.tokenTypeIdx=nl++),il(t)&&!D(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),il(t)||(t.CATEGORIES=[]),w_(t)||(t.categoryMatches=[]),C_(t)||(t.categoryMatchesMap={})})}function R_(e){P(e,t=>{t.categoryMatches=[],P(t.categoryMatchesMap,(r,n)=>{t.categoryMatches.push(gu[n].tokenTypeIdx)})})}function F_(e){P(e,t=>{Tu([],t)})}function Tu(e,t){P(e,r=>{t.categoryMatchesMap[r.tokenTypeIdx]=!0}),P(t.CATEGORIES,r=>{let n=e.concat(t);Te(n,r)||Tu(n,r)})}function yu(e){return N(e,"tokenTypeIdx")}function il(e){return N(e,"CATEGORIES")}function w_(e){return N(e,"categoryMatches")}function C_(e){return N(e,"categoryMatchesMap")}function M_(e){return N(e,"tokenTypeIdx")}var D_={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,r,n,i,s){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${r} characters.`}},Z;(function(e){e[e.MISSING_PATTERN=0]="MISSING_PATTERN",e[e.INVALID_PATTERN=1]="INVALID_PATTERN",e[e.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",e[e.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",e[e.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",e[e.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",e[e.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",e[e.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",e[e.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",e[e.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",e[e.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",e[e.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",e[e.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(Z||(Z={}));var Er={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[` +`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:D_,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Er);var le=class{constructor(e,t=Er){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(n,i)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let s=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent <${n}>`);let{time:a,value:o}=lu(i),c=a>10?console.warn:console.log;return this.traceInitIndent time: ${a}ms`),this.traceInitIndent--,o}else return i()},typeof t=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object. +a boolean 2nd argument is no longer supported`);this.config=_e({},Er,t);let r=this.config.traceInitPerf;r===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof r=="number"&&(this.traceInitMaxIdent=r,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let n,i=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===Er.lineTerminatorsPattern)this.config.lineTerminatorsPattern=O_;else if(this.config.lineTerminatorCharacters===Er.lineTerminatorCharacters)throw Error(`Error: Missing property on the Lexer config. + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),D(e)?n={modes:{defaultMode:xe(e)},defaultMode:xr}:(i=!1,n=xe(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(I_(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(E_(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},P(n.modes,(a,o)=>{n.modes[o]=zn(a,c=>pt(c))});let s=Le(n.modes);if(P(n.modes,(a,o)=>{this.TRACE_INIT(`Mode: <${o}> processing`,()=>{if(this.modes.push(o),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(a_(a,s))}),V(this.lexerDefinitionErrors)){Hr(a);let c;this.TRACE_INIT("analyzeTokenTypes",()=>{c=s_(a,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[o]=c.patternIdxToConfig,this.charCodeToPatternIdxToConfig[o]=c.charCodeToPatternIdxToConfig,this.emptyGroups=_e({},this.emptyGroups,c.emptyGroups),this.hasCustom=c.hasCustom||this.hasCustom,this.canModeBeOptimized[o]=c.canBeOptimized}})}),this.defaultMode=n.defaultMode,!V(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let o=O(this.lexerDefinitionErrors,c=>c.message).join(`----------------------- +`);throw new Error(`Errors detected in definition of Lexer: +`+o)}P(this.lexerDefinitionWarning,a=>{cu(a.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(i&&(this.handleModes=oe),this.trackStartLines===!1&&(this.computeNewColumn=wr),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=oe),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{let a=Oe(this.canModeBeOptimized,(o,c,l)=>(c===!1&&o.push(l),o),[]);if(t.ensureOptimizations&&!V(a))throw Error(`Lexer Modes: < ${a.join(", ")} > cannot be optimized. + Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode. + Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{t_()}),this.TRACE_INIT("toFastProperties",()=>{uu(this)})})}tokenize(e,t=this.defaultMode){if(!V(this.lexerDefinitionErrors)){let n=O(this.lexerDefinitionErrors,i=>i.message).join(`----------------------- +`);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer: +`+n)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let r,n,i,s,a,o,c,l,p,h,d,m,A,b,y,v=e,x=v.length,T=0,I=0,S=this.hasCustom?0:Math.floor(e.length/10),C=new Array(S),X=[],M=this.trackStartLines?1:void 0,z=this.trackStartLines?1:void 0,J=L_(this.emptyGroups),fe=this.trackStartLines,de=this.config.lineTerminatorsPattern,ne=0,q=[],ae=[],pe=[],ct=[];Object.freeze(ct);let Ze=!1,ln=Ae=>{if(pe.length===1&&Ae.tokenType.PUSH_MODE===void 0){let Pe=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(Ae);X.push({offset:Ae.startOffset,line:Ae.startLine,column:Ae.startColumn,length:Ae.image.length,message:Pe})}else{pe.pop();let Pe=Ft(pe);q=this.patternIdxToConfig[Pe],ae=this.charCodeToPatternIdxToConfig[Pe],ne=q.length;let Ss=this.canModeBeOptimized[Pe]&&this.config.safeMode===!1;ae&&Ss?Ze=!0:Ze=!1}};function mc(Ae){pe.push(Ae),ae=this.charCodeToPatternIdxToConfig[Ae],q=this.patternIdxToConfig[Ae],ne=q.length,ne=q.length;let Pe=this.canModeBeOptimized[Ae]&&this.config.safeMode===!1;ae&&Pe?Ze=!0:Ze=!1}mc.call(this,t);let je,gc=this.config.recoveryEnabled;for(;To.length){o=s,p=s.length,c=l,je=lt;break}}}break}}if(p!==-1){if(h=je.group,h!==void 0&&(o=o!==null?o:e.substring(T,T+p),d=je.tokenTypeIdx,m=this.createTokenInstance(o,T,d,je.tokenType,M,z,p),this.handlePayload(m,c),h===!1?I=this.addToken(C,I,m):J[h].push(m)),fe===!0&&je.canLineTerminator===!0){let me=0,ke,At;de.lastIndex=0;do o=o!==null?o:e.substring(T,T+p),ke=de.test(o),ke===!0&&(At=de.lastIndex-1,me++);while(ke===!0);me!==0?(M=M+me,z=p-At,this.updateTokenEndLineColumnLocation(m,h,At,me,M,z,p)):z=this.computeNewColumn(z,p)}else z=this.computeNewColumn(z,p);T=T+p,this.handleModes(je,ln,mc,m)}else{let me=T,ke=M,At=z,lt=gc===!1;for(;lt===!1&&T ${Or(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:t}){return"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:r,customUserDescription:n,ruleName:i}){let s="Expecting: ",o=` +but found: '`+We(t).image+"'";if(n)return s+n+o;{let c=Oe(e,(d,m)=>d.concat(m),[]),l=O(c,d=>`[${O(d,m=>Or(m)).join(", ")}]`),h=`one of these possible Token sequences: +${O(l,(d,m)=>` ${m+1}. ${d}`).join(` +`)}`;return s+h+o}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:r,ruleName:n}){let i="Expecting: ",a=` +but found: '`+We(t).image+"'";if(r)return i+r+a;{let c=`expecting at least one iteration which starts with one of these possible Token sequences:: + <${O(e,l=>`[${O(l,p=>Or(p)).join(",")}]`).join(" ,")}>`;return i+c+a}}};Object.freeze(Au);var V_={buildRuleNotFoundError(e,t){return"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+`<- +inside top level rule: ->`+e.name+"<-"}},Rt={buildDuplicateFoundError(e,t){function r(p){return p instanceof B?p.terminalType.name:p instanceof Se?p.nonTerminalName:""}let n=e.name,i=We(t),s=i.idx,a=Je(i),o=r(i),c=s>0,l=`->${a}${c?s:""}<- ${o?`with argument: ->${o}<-`:""} + appears more than once (${t.length} times) in the top level rule: ->${n}<-. + For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES + `;return l=l.replace(/[ \t]+/g," "),l=l.replace(/\s\s+/g,` +`),l},buildNamespaceConflictError(e){return`Namespace conflict found in grammar. +The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>. +To resolve this make sure each Terminal and Non-Terminal names are unique +This is easy to accomplish by using the convention that Terminal names start with an uppercase letter +and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=O(e.prefixPath,i=>Or(i)).join(", "),r=e.alternation.idx===0?"":e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix +in inside <${e.topLevelRule.name}> Rule, +<${t}> may appears as a prefix path in all these alternatives. +See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX +For Further details.`},buildAlternationAmbiguityError(e){let t=e.alternation.idx===0?"":e.alternation.idx,r=e.prefixPath.length===0,n=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(" ,")}> in inside <${e.topLevelRule.name}> Rule, +`;if(r)n+=`These alternatives are all empty (match no tokens), making them indistinguishable. +Only the last alternative may be empty. +`;else{let i=O(e.prefixPath,s=>Or(s)).join(", ");n+=`<${i}> may appears as a prefix path in all these alternatives. +`}return n+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES +For Further details.`,n},buildEmptyRepetitionError(e){let t=Je(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens. +This could lead to an infinite loop.`},buildTokenNameError(e){return"deprecated"},buildEmptyAlternationError(e){return`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in inside <${e.topLevelRule.name}> Rule. +Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(e){return`An Alternation cannot have more than 256 alternatives: + inside <${e.topLevelRule.name}> Rule. + has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name,r=O(e.leftRecursionPath,s=>s.name),n=`${t} --> ${r.concat([t]).join(" --> ")}`;return`Left Recursion found in grammar. +rule: <${t}> can be invoked from itself (directly or indirectly) +without consuming any Tokens. The grammar path that causes this is: + ${n} + To fix this refactor your grammar to remove the left recursion. +see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return"deprecated"},buildDuplicateRuleNameError(e){let t;return e.topLevelRule instanceof sr?t=e.topLevelRule.name:t=e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function K_(e,t){let r=new H_(e,t);return r.resolveRefs(),r.errors}var H_=class extends ar{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){P(ie(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let r=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:r,type:ge.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},W_=class extends qn{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=xe(this.path.ruleStack).reverse(),this.occurrenceStack=xe(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,r){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let n=t.concat(r);this.updateExpectedNext(),this.walk(e.referencedRule,n)}}updateExpectedNext(){V(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},z_=class extends W_{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,r){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let n=t.concat(r),i=new Ee({definition:n});this.possibleTokTypes=Vr(i),this.found=!0}}},Bn=class extends qn{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},q_=class extends Bn{walkMany(e,t,r){if(e.idx===this.occurrence){let n=We(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof B&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkMany(e,t,r)}},fl=class extends Bn{walkManySep(e,t,r){if(e.idx===this.occurrence){let n=We(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof B&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkManySep(e,t,r)}},Y_=class extends Bn{walkAtLeastOne(e,t,r){if(e.idx===this.occurrence){let n=We(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof B&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkAtLeastOne(e,t,r)}},dl=class extends Bn{walkAtLeastOneSep(e,t,r){if(e.idx===this.occurrence){let n=We(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof B&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkAtLeastOneSep(e,t,r)}};function Ys(e,t,r=[]){r=xe(r);let n=[],i=0;function s(o){return o.concat(ce(e,i+1))}function a(o){let c=Ys(s(o),t,r);return n.concat(c)}for(;r.length{V(c.definition)===!1&&(n=a(c.definition))}),n;if(o instanceof B)r.push(o.terminalType);else throw Error("non exhaustive match")}i++}return n.push({partialPath:r,suffixDef:ce(e,i)}),n}function bu(e,t,r,n){let i="EXIT_NONE_TERMINAL",s=[i],a="EXIT_ALTERNATIVE",o=!1,c=t.length,l=c-n-1,p=[],h=[];for(h.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!V(h);){let d=h.pop();if(d===a){o&&Ft(h).idx<=l&&h.pop();continue}let m=d.def,A=d.idx,b=d.ruleStack,y=d.occurrenceStack;if(V(m))continue;let v=m[0];if(v===i){let x={idx:A,def:ce(m),ruleStack:kr(b),occurrenceStack:kr(y)};h.push(x)}else if(v instanceof B)if(A=0;x--){let T=v.definition[x],I={idx:A,def:T.definition.concat(ce(m)),ruleStack:b,occurrenceStack:y};h.push(I),h.push(a)}else if(v instanceof Ee)h.push({idx:A,def:v.definition.concat(ce(m)),ruleStack:b,occurrenceStack:y});else if(v instanceof sr)h.push(X_(v,A,b,y));else throw Error("non exhaustive match")}return p}function X_(e,t,r,n){let i=xe(r);i.push(e.name);let s=xe(n);return s.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:s}}var Q;(function(e){e[e.OPTION=0]="OPTION",e[e.REPETITION=1]="REPETITION",e[e.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",e[e.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",e[e.ALTERNATION=5]="ALTERNATION"})(Q||(Q={}));function xu(e){if(e instanceof be||e==="Option")return Q.OPTION;if(e instanceof se||e==="Repetition")return Q.REPETITION;if(e instanceof nt||e==="RepetitionMandatory")return Q.REPETITION_MANDATORY;if(e instanceof it||e==="RepetitionMandatoryWithSeparator")return Q.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof qe||e==="RepetitionWithSeparator")return Q.REPETITION_WITH_SEPARATOR;if(e instanceof Ye||e==="Alternation")return Q.ALTERNATION;throw Error("non exhaustive match")}function B_(e,t,r,n,i,s){let a=ba(e,t,r),o=Lu(a)?Nn:Kr;return s(a,n,o,i)}function Q_(e,t,r,n,i,s){let a=xa(e,t,i,r),o=Lu(a)?Nn:Kr;return s(a[0],o,n)}function Z_(e,t,r,n){let i=e.length,s=Ke(e,a=>Ke(a,o=>o.length===1));if(t)return function(a){let o=O(a,c=>c.GATE);for(let c=0;cVe(c)),o=Oe(a,(c,l,p)=>(P(l,h=>{N(c,h.tokenTypeIdx)||(c[h.tokenTypeIdx]=p),P(h.categoryMatches,d=>{N(c,d)||(c[d]=p)})}),c),{});return function(){let c=this.LA_FAST(1);return o[c.tokenTypeIdx]}}else return function(){for(let a=0;as.length===1),i=e.length;if(n&&!r){let s=Ve(e);if(s.length===1&&V(s[0].categoryMatches)){let o=s[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===o}}else{let a=Oe(s,(o,c,l)=>(o[c.tokenTypeIdx]=!0,P(c.categoryMatches,p=>{o[p]=!0}),o),[]);return function(){let o=this.LA_FAST(1);return a[o.tokenTypeIdx]===!0}}}else return function(){e:for(let s=0;sYs([a],1)),n=ml(r.length),i=O(r,a=>{let o={};return P(a,c=>{let l=Cs(c.partialPath);P(l,p=>{o[p]=!0})}),o}),s=r;for(let a=1;a<=t;a++){let o=s;s=ml(o.length);for(let c=0;c{let v=Cs(y.partialPath);P(v,x=>{i[c][x]=!0})})}}}}return n}function ba(e,t,r,n){let i=new Iu(e,Q.ALTERNATION,n);return t.accept(i),Eu(i.result,r)}function xa(e,t,r,n){let i=new Iu(e,r);t.accept(i);let s=i.result,o=new U_(t,e,r).startWalking(),c=new Ee({definition:s}),l=new Ee({definition:o});return Eu([c,l],n)}function Xs(e,t){e:for(let r=0;r{let i=t[n];return r===i||i.categoryMatchesMap[r.tokenTypeIdx]})}function Lu(e){return Ke(e,t=>Ke(t,r=>Ke(r,n=>V(n.categoryMatches))))}function rO(e){let t=e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName});return O(t,r=>Object.assign({type:ge.CUSTOM_LOOKAHEAD_VALIDATION},r))}function nO(e,t,r,n){let i=Re(e,c=>iO(c,r)),s=gO(e,t,r),a=Re(e,c=>hO(c,r)),o=Re(e,c=>oO(c,e,n,r));return i.concat(s,a,o)}function iO(e,t){let r=new aO;e.accept(r);let n=r.allProductions,i=YE(n,sO),s=ze(i,o=>o.length>1);return O(ie(s),o=>{let c=We(o),l=t.buildDuplicateFoundError(e,o),p=Je(c),h={message:l,type:ge.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:p,occurrence:c.idx},d=_u(c);return d&&(h.parameter=d),h})}function sO(e){return`${Je(e)}_#_${e.idx}_#_${_u(e)}`}function _u(e){return e instanceof B?e.terminalType.name:e instanceof Se?e.nonTerminalName:""}var aO=class extends ar{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}};function oO(e,t,r,n){let i=[];if(Oe(t,(a,o)=>o.name===e.name?a+1:a,0)>1){let a=n.buildDuplicateRuleNameError({topLevelRule:e,grammarName:r});i.push({message:a,type:ge.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function cO(e,t,r){let n=[],i;return Te(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${r}<-as it is not defined in any of the super grammars `,n.push({message:i,type:ge.INVALID_RULE_OVERRIDE,ruleName:e})),n}function Ou(e,t,r,n=[]){let i=[],s=An(t.definition);if(V(s))return[];{let a=e.name;Te(s,e)&&i.push({message:r.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:n}),type:ge.LEFT_RECURSION,ruleName:a});let c=Wn(s,n.concat([e])),l=Re(c,p=>{let h=xe(n);return h.push(p),Ou(e,p,r,h)});return i.concat(l)}}function An(e){let t=[];if(V(e))return t;let r=We(e);if(r instanceof Se)t.push(r.referencedRule);else if(r instanceof Ee||r instanceof be||r instanceof nt||r instanceof it||r instanceof qe||r instanceof se)t=t.concat(An(r.definition));else if(r instanceof Ye)t=Ve(O(r.definition,s=>An(s.definition)));else if(!(r instanceof B))throw Error("non exhaustive match");let n=Ln(r),i=e.length>1;if(n&&i){let s=ce(e);return t.concat(An(s))}else return t}var Ia=class extends ar{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function lO(e,t){let r=new Ia;e.accept(r);let n=r.alternations;return Re(n,s=>{let a=kr(s.definition);return Re(a,(o,c)=>{let l=bu([o],[],Kr,1);return V(l)?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:s,emptyChoiceIdx:c}),type:ge.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:s.idx,alternative:c+1}]:[]})})}function uO(e,t,r){let n=new Ia;e.accept(n);let i=n.alternations;return i=zn(i,a=>a.ignoreAmbiguities===!0),Re(i,a=>{let o=a.idx,c=a.maxLookahead||t,l=ba(o,e,c,a),p=dO(l,a,e,r),h=mO(l,a,e,r);return p.concat(h)})}var pO=class extends ar{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}};function hO(e,t){let r=new Ia;e.accept(r);let n=r.alternations;return Re(n,s=>s.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:s}),type:ge.TOO_MANY_ALTS,ruleName:e.name,occurrence:s.idx}]:[])}function fO(e,t,r){let n=[];return P(e,i=>{let s=new pO;i.accept(s);let a=s.allProductions;P(a,o=>{let c=xu(o),l=o.maxLookahead||t,p=o.idx,d=xa(p,i,c,l)[0];if(V(Ve(d))){let m=r.buildEmptyRepetitionError({topLevelRule:i,repetition:o});n.push({message:m,type:ge.NO_NON_EMPTY_LOOKAHEAD,ruleName:i.name})}})}),n}function dO(e,t,r,n){let i=[],s=Oe(e,(o,c,l)=>(t.definition[l].ignoreAmbiguities===!0||P(c,p=>{let h=[l];P(e,(d,m)=>{l!==m&&Xs(d,p)&&t.definition[m].ignoreAmbiguities!==!0&&h.push(m)}),h.length>1&&!Xs(i,p)&&(i.push(p),o.push({alts:h,path:p}))}),o),[]);return O(s,o=>{let c=O(o.alts,p=>p+1);return{message:n.buildAlternationAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:c,prefixPath:o.path}),type:ge.AMBIGUOUS_ALTS,ruleName:r.name,occurrence:t.idx,alternatives:o.alts}})}function mO(e,t,r,n){let i=Oe(e,(a,o,c)=>{let l=O(o,p=>({idx:c,path:p}));return a.concat(l)},[]);return jr(Re(i,a=>{if(t.definition[a.idx].ignoreAmbiguities===!0)return[];let c=a.idx,l=a.path,p=Ce(i,d=>t.definition[d.idx].ignoreAmbiguities!==!0&&d.idx{let m=[d.idx+1,c+1],A=t.idx===0?"":t.idx;return{message:n.buildAlternationPrefixAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:m,prefixPath:d.path}),type:ge.AMBIGUOUS_PREFIX_ALTS,ruleName:r.name,occurrence:A,alternatives:m}})}))}function gO(e,t,r){let n=[],i=O(t,s=>s.name);return P(e,s=>{let a=s.name;if(Te(i,a)){let o=r.buildNamespaceConflictError(s);n.push({message:o,type:ge.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:a})}}),n}function TO(e){let t=ga(e,{errMsgProvider:V_}),r={};return P(e.rules,n=>{r[n.name]=n}),K_(r,t.errMsgProvider)}function yO(e){return e=ga(e,{errMsgProvider:Rt}),nO(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}var Su="MismatchedTokenException",Nu="NoViableAltException",Pu="EarlyExitException",ku="NotAllInputParsedException",Ru=[Su,Nu,Pu,ku];Object.freeze(Ru);function Pn(e){return Te(Ru,e.name)}var Qn=class extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Fu=class extends Qn{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=Su}},vO=class extends Qn{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=Nu}},AO=class extends Qn{constructor(e,t){super(e,t),this.name=ku}},bO=class extends Qn{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=Pu}},Ms={},wu="InRuleRecoveryException",xO=class extends Error{constructor(e){super(e),this.name=wu}},IO=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=N(e,"recoveryEnabled")?e.recoveryEnabled:ht.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=EO)}getTokenToInsert(e){let t=Aa(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,r,n){let i=this.findReSyncTokenType(),s=this.exportLexerState(),a=[],o=!1,c=this.LA_FAST(1),l=this.LA_FAST(1),p=()=>{let h=this.LA(0),d=this.errorMessageProvider.buildMismatchTokenMessage({expected:n,actual:c,previous:h,ruleName:this.getCurrRuleFullName()}),m=new Fu(d,c,this.LA(0));m.resyncedTokens=kr(a),this.SAVE_ERROR(m)};for(;!o;)if(this.tokenMatcher(l,n)){p();return}else if(r.call(this)){p(),e.apply(this,t);return}else this.tokenMatcher(l,i)?o=!0:(l=this.SKIP_TOKEN(),this.addToResyncTokens(l,a));this.importLexerState(s)}shouldInRepetitionRecoveryBeTried(e,t,r){return!(r===!1||this.tokenMatcher(this.LA_FAST(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){let r=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(r)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let r=this.SKIP_TOKEN();return this.consumeToken(),r}throw new xO("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||V(t))return!1;let r=this.LA_FAST(1);return Ut(t,i=>this.tokenMatcher(r,i))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey(),r=this.getFollowSetFromFollowKey(t);return Te(r,e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA_FAST(1),r=2;for(;;){let n=Ut(e,i=>j_(t,i));if(n!==void 0)return n;t=this.LA(r),r++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return Ms;let e=this.currRuleShortName,t=this.getLastExplicitRuleOccurrenceIndex(),r=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(r)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK,r=this.RULE_STACK_IDX+1,n=new Array(r);for(let i=0;ithis.getFollowSetFromFollowKey(t));return Ve(e)}getFollowSetFromFollowKey(e){if(e===Ms)return[Ct];let t=e.ruleName+e.idxInCallingRule+pu+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,Ct)||t.push(e),t}reSyncTo(e){let t=[],r=this.LA_FAST(1);for(;this.tokenMatcher(r,e)===!1;)r=this.SKIP_TOKEN(),this.addToResyncTokens(r,t);return kr(t)}attemptInRepetitionRecovery(e,t,r,n,i,s,a){}getCurrentGrammarPath(e,t){let r=this.getHumanReadableRuleStack(),n=this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1);return{ruleStack:r,occurrenceStack:n,lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){let e=this.RULE_STACK_IDX+1,t=new Array(e);for(let r=0;rOu(t,t,Rt))}validateEmptyOrAlternatives(e){return Re(e,t=>lO(t,Rt))}validateAmbiguousAlternationAlternatives(e,t){return Re(e,r=>uO(r,t,Rt))}validateSomeNonEmptyLookaheadPath(e,t){return fO(e,t,Rt)}buildLookaheadForAlternation(e){return B_(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,Z_)}buildLookaheadForOptional(e){return Q_(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,xu(e.prodType),J_)}},SO=class{initLooksAhead(e){this.dynamicTokensEnabled=N(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:ht.dynamicTokensEnabled,this.maxLookahead=N(e,"maxLookahead")?e.maxLookahead:ht.maxLookahead,this.lookaheadStrategy=N(e,"lookaheadStrategy")?e.lookaheadStrategy:new OO({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){P(e,t=>{this.TRACE_INIT(`${t.name} Rule Lookahead`,()=>{let{alternation:r,repetition:n,option:i,repetitionMandatory:s,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:o}=PO(t);P(r,c=>{let l=c.idx===0?"":c.idx;this.TRACE_INIT(`${Je(c)}${l}`,()=>{let p=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:c.idx,rule:t,maxLookahead:c.maxLookahead||this.maxLookahead,hasPredicates:c.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),h=Ds(this.fullRuleNameToShort[t.name],Cu,c.idx);this.setLaFuncCache(h,p)})}),P(n,c=>{this.computeLookaheadFunc(t,c.idx,Bs,"Repetition",c.maxLookahead,Je(c))}),P(i,c=>{this.computeLookaheadFunc(t,c.idx,Mu,"Option",c.maxLookahead,Je(c))}),P(s,c=>{this.computeLookaheadFunc(t,c.idx,Qs,"RepetitionMandatory",c.maxLookahead,Je(c))}),P(a,c=>{this.computeLookaheadFunc(t,c.idx,bn,"RepetitionMandatoryWithSeparator",c.maxLookahead,Je(c))}),P(o,c=>{this.computeLookaheadFunc(t,c.idx,Zs,"RepetitionWithSeparator",c.maxLookahead,Je(c))})})})}computeLookaheadFunc(e,t,r,n,i,s){this.TRACE_INIT(`${s}${t===0?"":t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:n}),o=Ds(this.fullRuleNameToShort[e.name],r,t);this.setLaFuncCache(o,a)})}getKeyForAutomaticLookahead(e,t){return Ds(this.currRuleShortName,e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},NO=class extends ar{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}},mn=new NO;function PO(e){mn.reset(),e.accept(mn);let t=mn.dslMethods;return mn.reset(),t}function gl(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffseta.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>: + ${s.join(` + +`).replace(/\n/g,` + `)}`)}}};return r.prototype=n,r.prototype.constructor=r,r._RULE_NAMES=t,r}function MO(e,t,r){let n=function(){};Du(n,e+"BaseSemanticsWithDefaults");let i=Object.create(r.prototype);return P(t,s=>{i[s]=wO}),n.prototype=i,n.prototype.constructor=n,n}var Js;(function(e){e[e.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",e[e.MISSING_METHOD=1]="MISSING_METHOD"})(Js||(Js={}));function DO(e,t){return GO(e,t)}function GO(e,t){let r=Ce(t,i=>ft(e[i])===!1),n=O(r,i=>({msg:`Missing visitor method: <${i}> on ${e.constructor.name} CST Visitor.`,type:Js.MISSING_METHOD,methodName:i}));return jr(n)}var $O=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=N(e,"nodeLocationTracking")?e.nodeLocationTracking:ht.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=oe,this.cstFinallyStateUpdate=oe,this.cstPostTerminal=oe,this.cstPostNonTerminal=oe,this.cstPostRule=oe;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Tl,this.setNodeLocationFromNode=Tl,this.cstPostRule=oe,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=oe,this.setNodeLocationFromNode=oe,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=gl,this.setNodeLocationFromNode=gl,this.cstPostRule=oe,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=oe,this.setNodeLocationFromNode=oe,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=oe,this.setNodeLocationFromNode=oe,this.cstPostRule=oe,this.setInitialNodeLocation=oe;else throw Error(`Invalid config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA_FAST(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){let t=this.LA_FAST(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),r=e.location;r.startOffset<=t.startOffset?(r.endOffset=t.endOffset,r.endLine=t.endLine,r.endColumn=t.endColumn):(r.startOffset=NaN,r.startLine=NaN,r.startColumn=NaN)}cstPostRuleOnlyOffset(e){let t=this.LA(0),r=e.location;r.startOffset<=t.startOffset?r.endOffset=t.endOffset:r.startOffset=NaN}cstPostTerminal(e,t){let r=this.CST_STACK[this.CST_STACK.length-1];kO(r,t,e),this.setNodeLocationFromToken(r.location,t)}cstPostNonTerminal(e,t){let r=this.CST_STACK[this.CST_STACK.length-1];RO(r,t,e),this.setNodeLocationFromNode(r.location,e.location)}getBaseCstVisitorConstructor(){if(pt(this.baseCstVisitorConstructor)){let e=CO(this.className,Le(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(pt(this.baseCstVisitorWithDefaultsConstructor)){let e=MO(this.className,Le(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getPreviousExplicitRuleShortName(){return this.RULE_STACK[this.RULE_STACK_IDX-1]}getLastExplicitRuleOccurrenceIndex(){return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX]}},jO=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error("Missing invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVectorLength-2?(this.consumeToken(),this.LA_FAST(1)):er}LA_FAST(e){let t=this.currIdx+e;return this.tokVector[t]}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?er:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}},VO=class{ACTION(e){return e.call(this)}consume(e,t,r){return this.consumeInternal(t,e,r)}subrule(e,t,r){return this.subruleInternal(t,e,r)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,r=Rn){if(Te(this.definedRulesNames,e)){let s={message:Rt.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:ge.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(s)}this.definedRulesNames.push(e);let n=this.defineRule(e,t,r);return this[e]=n,n}OVERRIDE_RULE(e,t,r=Rn){let n=cO(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(n);let i=this.defineRule(e,t,r);return this[e]=i,i}BACKTRACK(e,t){var r;let n=(r=e.coreRule)!==null&&r!==void 0?r:e;return function(){this.isBackTrackingStack.push(1);let i=this.saveRecogState();try{return n.apply(this,t),!0}catch(s){if(Pn(s))return!1;throw s}finally{this.reloadRecogState(i),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return KL(ie(this.gastProductionsCache))}},KO=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=Nn,this.subruleIdx=0,this.currRuleShortName=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK=[],this.RULE_OCCURRENCE_STACK_IDX=-1,this.gastProductionsCache={},N(t,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a property. + See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0 + For Further details.`);if(D(e)){if(V(e))throw Error(`A Token Vocabulary cannot be empty. + Note that the first argument for the parser constructor + is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument. + See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0 + For Further details.`)}if(D(e))this.tokensMap=Oe(e,(i,s)=>(i[s.name]=s,i),{});else if(N(e,"modes")&&Ke(Ve(ie(e.modes)),M_)){let i=Ve(ie(e.modes)),s=Ta(i);this.tokensMap=Oe(s,(a,o)=>(a[o.name]=o,a),{})}else if(we(e))this.tokensMap=xe(e);else throw new Error(" argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=Ct;let r=N(e,"modes")?Ve(ie(e.modes)):ie(e),n=Ke(r,i=>V(i.categoryMatches));this.tokenMatcher=n?Nn:Kr,Hr(ie(this.tokensMap))}defineRule(e,t,r){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called' +Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let n=N(r,"resyncEnabled")?r.resyncEnabled:Rn.resyncEnabled,i=N(r,"recoveryValueFunc")?r.recoveryValueFunc:Rn.recoveryValueFunc,s=this.ruleShortNameIdx<s.call(this)&&a.call(this)}}else i=e;if(n.call(this)===!0)return i.call(this)}atLeastOneInternal(e,t){let r=this.getKeyForAutomaticLookahead(Qs,e);return this.atLeastOneInternalLogic(e,t,r)}atLeastOneInternalLogic(e,t,r){let n=this.getLaFuncFromCache(r),i;if(typeof t!="function"){i=t.DEF;let s=t.GATE;if(s!==void 0){let a=n;n=()=>s.call(this)&&a.call(this)}}else i=t;if(n.call(this)===!0){let s=this.doSingleRepetition(i);for(;n.call(this)===!0&&s===!0;)s=this.doSingleRepetition(i)}else throw this.raiseEarlyExitException(e,Q.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],n,Qs,e,Y_)}atLeastOneSepFirstInternal(e,t){let r=this.getKeyForAutomaticLookahead(bn,e);this.atLeastOneSepFirstInternalLogic(e,t,r)}atLeastOneSepFirstInternalLogic(e,t,r){let n=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(r).call(this)===!0){n.call(this);let a=()=>this.tokenMatcher(this.LA_FAST(1),i);for(;this.tokenMatcher(this.LA_FAST(1),i)===!0;)this.CONSUME(i),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,a,n,dl],a,bn,e,dl)}else throw this.raiseEarlyExitException(e,Q.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let r=this.getKeyForAutomaticLookahead(Bs,e);return this.manyInternalLogic(e,t,r)}manyInternalLogic(e,t,r){let n=this.getLaFuncFromCache(r),i;if(typeof t!="function"){i=t.DEF;let a=t.GATE;if(a!==void 0){let o=n;n=()=>a.call(this)&&o.call(this)}}else i=t;let s=!0;for(;n.call(this)===!0&&s===!0;)s=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],n,Bs,e,q_,s)}manySepFirstInternal(e,t){let r=this.getKeyForAutomaticLookahead(Zs,e);this.manySepFirstInternalLogic(e,t,r)}manySepFirstInternalLogic(e,t,r){let n=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(r).call(this)===!0){n.call(this);let a=()=>this.tokenMatcher(this.LA_FAST(1),i);for(;this.tokenMatcher(this.LA_FAST(1),i)===!0;)this.CONSUME(i),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,a,n,fl],a,Zs,e,fl)}}repetitionSepSecondInternal(e,t,r,n,i){for(;r();)this.CONSUME(t),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,r,n,i],r,bn,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let r=this.getKeyForAutomaticLookahead(Cu,t),n=D(e)?e:e.DEF,s=this.getLaFuncFromCache(r).call(this,n);if(s!==void 0)return n[s].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX]),this.cstFinallyStateUpdate()}subruleInternal(e,t,r){let n;try{let i=r!==void 0?r.ARGS:void 0;return this.subruleIdx=t,n=e.coreRule.apply(this,i),this.cstPostNonTerminal(n,r!==void 0&&r.LABEL!==void 0?r.LABEL:e.ruleName),n}catch(i){throw this.subruleInternalError(i,r,e.ruleName)}}subruleInternalError(e,t,r){throw Pn(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:r),delete e.partialCstResult),e}consumeInternal(e,t,r){let n;try{let i=this.LA_FAST(1);this.tokenMatcher(i,e)===!0?(this.consumeToken(),n=i):this.consumeInternalError(e,i,r)}catch(i){n=this.consumeInternalRecovery(e,t,i)}return this.cstPostTerminal(r!==void 0&&r.LABEL!==void 0?r.LABEL:e.name,n),n}consumeInternalError(e,t,r){let n,i=this.LA(0);throw r!==void 0&&r.ERR_MSG?n=r.ERR_MSG:n=this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Fu(n,t,i))}consumeInternalRecovery(e,t,r){if(this.recoveryEnabled&&r.name==="MismatchedTokenException"&&!this.isBackTracking()){let n=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,n)}catch(i){throw i.name===wu?r:i}}else throw r}saveRecogState(){let e=this.errors,t=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState);let t=e.RULE_STACK;for(let r=0;r=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX])}ruleInvocationStateUpdate(e,t,r){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=r,this.RULE_STACK[++this.RULE_STACK_IDX]=e,this.currRuleShortName=e,this.cstInvocationStateUpdate(t)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.currRuleShortName;return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Ct)}reset(){this.resetLexerState(),this.subruleIdx=0,this.currRuleShortName=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK_IDX=-1,this.CST_STACK=[]}onBeforeParse(e){for(let t=0;t${e}<- does not exist in this grammar.`);return bu([r],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let t=We(e.ruleStack),n=this.getGAstProductions()[t];return new z_(n,e).startWalking()}},Zn={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Zn);var yl=!0,vl=Math.pow(2,Et)-1,Gu=Xn({name:"RECORDING_PHASE_TOKEN",pattern:le.NA});Hr([Gu]);var $u=Aa(Gu,`This IToken indicates the Parser is in Recording Phase + See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze($u);var zO={name:`This CSTNode indicates the Parser is in Recording Phase + See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},qO=class{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){let t=e>0?e:"";this[`CONSUME${t}`]=function(r,n){return this.consumeInternalRecord(r,e,n)},this[`SUBRULE${t}`]=function(r,n){return this.subruleInternalRecord(r,e,n)},this[`OPTION${t}`]=function(r){return this.optionInternalRecord(r,e)},this[`OR${t}`]=function(r){return this.orInternalRecord(r,e)},this[`MANY${t}`]=function(r){this.manyInternalRecord(e,r)},this[`MANY_SEP${t}`]=function(r){this.manySepFirstInternalRecord(e,r)},this[`AT_LEAST_ONE${t}`]=function(r){this.atLeastOneInternalRecord(e,r)},this[`AT_LEAST_ONE_SEP${t}`]=function(r){this.atLeastOneSepFirstInternalRecord(e,r)}}this.consume=function(e,t,r){return this.consumeInternalRecord(t,e,r)},this.subrule=function(e,t,r){return this.subruleInternalRecord(t,e,r)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{let e=this;for(let t=0;t<10;t++){let r=t>0?t:"";delete e[`CONSUME${r}`],delete e[`SUBRULE${r}`],delete e[`OPTION${r}`],delete e[`OR${r}`],delete e[`MANY${r}`],delete e[`MANY_SEP${r}`],delete e[`AT_LEAST_ONE${r}`],delete e[`AT_LEAST_ONE_SEP${r}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return er}topLevelRuleRecord(e,t){try{let r=new sr({definition:[],name:e});return r.name=e,this.recordingProdStack.push(r),t.call(this),this.recordingProdStack.pop(),r}catch(r){if(r.KNOWN_RECORDER_ERROR!==!0)try{r.message=r.message+` + This error was thrown during the "grammar recording phase" For more info see: + https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw r}throw r}}optionInternalRecord(e,t){return br.call(this,be,e,t)}atLeastOneInternalRecord(e,t){br.call(this,nt,t,e)}atLeastOneSepFirstInternalRecord(e,t){br.call(this,it,t,e,yl)}manyInternalRecord(e,t){br.call(this,se,t,e)}manySepFirstInternalRecord(e,t){br.call(this,qe,t,e,yl)}orInternalRecord(e,t){return YO.call(this,e,t)}subruleInternalRecord(e,t,r){if(kn(t),!e||N(e,"ruleName")===!1){let a=new Error(` argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}> + inside top level rule: <${this.recordingProdStack[0].name}>`);throw a.KNOWN_RECORDER_ERROR=!0,a}let n=Ft(this.recordingProdStack),i=e.ruleName,s=new Se({idx:t,nonTerminalName:i,label:r?.LABEL,referencedRule:void 0});return n.definition.push(s),this.outputCst?zO:Zn}consumeInternalRecord(e,t,r){if(kn(t),!yu(e)){let s=new Error(` argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}> + inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let n=Ft(this.recordingProdStack),i=new B({idx:t,terminalType:e,label:r?.LABEL});return n.definition.push(i),$u}};function br(e,t,r,n=!1){kn(r);let i=Ft(this.recordingProdStack),s=ft(t)?t:t.DEF,a=new e({definition:[],idx:r});return n&&(a.separator=t.SEP),N(t,"MAX_LOOKAHEAD")&&(a.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(a),s.call(this),i.definition.push(a),this.recordingProdStack.pop(),Zn}function YO(e,t){kn(t);let r=Ft(this.recordingProdStack),n=D(e)===!1,i=n===!1?e:e.DEF,s=new Ye({definition:[],idx:t,ignoreAmbiguities:n&&e.IGNORE_AMBIGUITIES===!0});N(e,"MAX_LOOKAHEAD")&&(s.maxLookahead=e.MAX_LOOKAHEAD);let a=ou(i,o=>ft(o.GATE));return s.hasPredicates=a,r.definition.push(s),P(i,o=>{let c=new Ee({definition:[]});s.definition.push(c),N(o,"IGNORE_AMBIGUITIES")?c.ignoreAmbiguities=o.IGNORE_AMBIGUITIES:N(o,"GATE")&&(c.ignoreAmbiguities=!0),this.recordingProdStack.push(c),o.ALT.call(this),this.recordingProdStack.pop()}),Zn}function Al(e){return e===0?"":`${e}`}function kn(e){if(e<0||e>vl){let t=new Error(`Invalid DSL Method idx value: <${e}> + Idx value must be a none negative value smaller than ${vl+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var XO=class{initPerformanceTracer(e){if(N(e,"traceInitPerf")){let t=e.traceInitPerf,r=typeof t=="number";this.traceInitMaxIdent=r?t:1/0,this.traceInitPerf=r?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=ht.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;let r=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent <${e}>`);let{time:n,value:i}=lu(t),s=n>10?console.warn:console.log;return this.traceInitIndent time: ${n}ms`),this.traceInitIndent--,i}else return t()}};function BO(e,t){t.forEach(r=>{let n=r.prototype;Object.getOwnPropertyNames(n).forEach(i=>{if(i==="constructor")return;let s=Object.getOwnPropertyDescriptor(n,i);s&&(s.get||s.set)?Object.defineProperty(e.prototype,i,s):e.prototype[i]=r.prototype[i]})})}var er=Aa(Ct,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(er);var ht=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:Au,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),Rn=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0}),ge;(function(e){e[e.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",e[e.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",e[e.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",e[e.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",e[e.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",e[e.LEFT_RECURSION=5]="LEFT_RECURSION",e[e.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",e[e.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",e[e.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",e[e.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",e[e.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",e[e.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(ge||(ge={}));var Ea=class ju{static performSelfAnalysis(t){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let t;this.selfAnalysisDone=!0;let r=this.className;this.TRACE_INIT("toFastProps",()=>{uu(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),P(this.definedRulesNames,i=>{let a=this[i].originalGrammarAction,o;this.TRACE_INIT(`${i} Rule`,()=>{o=this.topLevelRuleRecord(i,a)}),this.gastProductionsCache[i]=o})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=TO({rules:ie(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(V(n)&&this.skipValidations===!1){let i=yO({rules:ie(this.gastProductionsCache),tokenTypes:ie(this.tokensMap),errMsgProvider:Rt,grammarName:r}),s=rO({lookaheadStrategy:this.lookaheadStrategy,rules:ie(this.gastProductionsCache),tokenTypes:ie(this.tokensMap),grammarName:r});this.definitionErrors=this.definitionErrors.concat(i,s)}}),V(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{let i=BL(ie(this.gastProductionsCache));this.resyncFollows=i}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var i,s;(s=(i=this.lookaheadStrategy).initialize)===null||s===void 0||s.call(i,{rules:ie(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(ie(this.gastProductionsCache))})),!ju.DEFER_DEFINITION_ERRORS_HANDLING&&!V(this.definitionErrors))throw t=O(this.definitionErrors,i=>i.message),new Error(`Parser Definition Errors detected: + ${t.join(` +------------------------------- +`)}`)})}constructor(t,r){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(r),n.initLexerAdapter(),n.initLooksAhead(r),n.initRecognizerEngine(t,r),n.initRecoverable(r),n.initTreeBuilder(r),n.initContentAssist(),n.initGastRecorder(r),n.initPerformanceTracer(r),N(r,"ignoredIssues"))throw new Error(`The IParserConfig property has been deprecated. + Please use the flag on the relevant DSL method instead. + See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES + For further details.`);this.skipValidations=N(r,"skipValidations")?r.skipValidations:ht.skipValidations}};Ea.DEFER_DEFINITION_ERRORS_HANDLING=!1;BO(Ea,[IO,SO,$O,jO,KO,VO,HO,WO,qO,XO]);var Vu=class extends Ea{constructor(e,t=ht){let r=xe(t);r.outputCst=!1,super(e,r)}};function ee(e){return e.charAt(0).toLowerCase()+e.slice(1)}function f(e){return Xn(e)}var H="When you use this string, you expect traqula to handle indentation after every newline",Wr="When you use this string, you expect that the core generator of Traqula does prints a given string instead of a ewline when NEW_LINE printing is disabled through traqulaIndentation";var Jn=class{rules;factory=new Bt;__context=void 0;origSource="";handledInlineSource;generatedUntil=0;toEnsure=[];stringBuilder=[];constructor(t){this.rules=t;for(let r of Object.values(t))this[r.name]=((n,i,s)=>(this.stringBuilder.length=0,this.toEnsure.length=0,this.origSource=i.origSource,this.generatedUntil=i?.offset??0,this.setContext(i),this.subrule(r,n,s),this.catchup(this.origSource.length),this.handeEnsured(""),this.stringBuilder.join("")))}setContext(t){this.__context=t}getSafeContext(){return this.__context}subrule=(t,r,...n)=>{let i=this.rules[t.name];if(!i)throw new Error(`Rule ${t.name} not found`);let s=()=>i.gImpl({SUBRULE:this.subrule,PRINT:this.print,ENSURE:this.ensure,ENSURE_EITHER:this.ensureEither,NEW_LINE:this.newLine,HANDLE_LOC:this.handleLoc,CATCHUP:this.catchup,PRINT_WORD:this.printWord,PRINT_WORDS:this.printWords,PRINT_ON_EMPTY:this.printOnEmpty,PRINT_ON_OWN_LINE:this.printOnOwnLine})(r,this.getSafeContext(),...n);this.factory.isLocalized(r)?this.handleLoc(r,s):s()};handleLoc=(t,r)=>{if(this.factory.isSourceLocationNoMaterialize(t.loc))return;if(this.factory.isSourceLocationStringReplace(t.loc)){this.catchup(t.loc.start),this.print(t.loc.newSource),this.generatedUntil=t.loc.end;return}if(this.factory.isSourceLocationNodeReplace(t.loc)&&(this.catchup(t.loc.start),this.generatedUntil=t.loc.end),this.factory.isSourceLocationSource(t.loc)&&this.catchup(t.loc.start),this.factory.isSourceLocationInlinedSource(t.loc)&&this.handledInlineSource!==t.loc){this.handledInlineSource=t.loc,this.catchup(t.loc.start);let i=this.origSource,s=this.generatedUntil;this.origSource=t.loc.newSource,this.generatedUntil=0,this.catchup(t.loc.startOnNew);let a=this.handleLoc(t.loc,r);return this.generatedUntil=t.loc.endOnNew,this.catchup(this.origSource.length),this.origSource=i,this.generatedUntil=Math.max(s,t.loc.end),a}let n=r();return this.factory.isSourceLocationSource(t.loc)&&this.catchup(t.loc.end),n};catchup=t=>{let r=this.generatedUntil;r{let r=t.join("");this.handeEnsured(r),this.stringBuilder.push(r)};doesEndWith(t){let r=t.length,n="";for(;n.length0;)n=this.stringBuilder.pop()+n;return this.stringBuilder.push(n),n.endsWith(t)}ensure=(...t)=>{let r=t.join("");this.doesEndWith(r)||this.toEnsure.push(n=>{!n.startsWith(r)&&!this.doesEndWith(r)&&this.stringBuilder.push(r)})};ensureEither=(...t)=>{t.length===1?this.ensure(...t):t.length>1&&!t.some(r=>this.doesEndWith(r))&&this.toEnsure.push(r=>{!t.some(n=>r.startsWith(n))&&!t.some(n=>this.doesEndWith(n))&&this.stringBuilder.push(t[0])})};pruneEndingBlanks(){let t="";for(;/^[ \t]*$/u.test(t)&&this.stringBuilder.length>0;)t=this.stringBuilder.pop()+t;this.print(t.replace(/[\t ]*$/u,""))}newLine=t=>{let r=this.getSafeContext()[H]??0,n=t?.force??!1;if(r<0){let i=this.getSafeContext()[Wr];i!==void 0&&(n||this.stringBuilder.at(-1)!==i)&&this.print(i);return}if(this.pruneEndingBlanks(),n)this.print(` +`," ".repeat(r));else{let i="";for(;!i.includes(` +`)&&this.stringBuilder.length>0;)i=this.stringBuilder.pop()+i;/\n[ \t]*$/u.test(i)?(i=i.replace(/\n[ \t]*$/u,` +${" ".repeat(r)}`),this.print(i)):this.print(i,` +`," ".repeat(r))}};printWord=(...t)=>{this.ensureEither(" ",` +`),this.print(...t),this.ensureEither(" ",` +`)};printWords=(...t)=>{for(let r of t)this.printWord(r)};printOnEmpty=(...t)=>{this.newLine(),this.print(...t)};printOnOwnLine=(...t)=>{this.newLine(),this.print(...t),this.newLine()}};function Ku(e){let t=Object.create(null);for(let r of e)t[r.name]=r;return t}var Un=class e{static create(t){return Array.isArray(t)?new e(Ku(t)):new e({...t.rules})}rules;constructor(t){this.rules=t}widenContext(){return this}typePatch(){return this}patchRule(t){let r=this;return r.rules[t.name]=t,r}addRuleRedundant(t){let r=this,n=r.rules;if(n[t.name]!==void 0&&n[t.name]!==t)throw new Error(`Rule ${t.name} already exists in the GeneratorBuilder`);return n[t.name]=t,r}addRule(t){return this.addRuleRedundant(t)}addMany(...t){return this.rules={...this.rules,...Ku(t)},this}deleteRule(t){return delete this.rules[t],this}deleteMany(...t){for(let r of t)delete this.rules[r];return this}getRule(t){return this.rules[t]}merge(t,r){let n=Object.assign(Object.create(null),t.rules),i=this.rules;for(let s of Object.values(i))if(n[s.name]===void 0)n[s.name]=s;else if(n[s.name]!==s){let o=r.find(c=>c.name===s.name);if(o)n[s.name]=o;else throw new Error(`Rule with name "${s.name}" already exists in the GeneratorBuilder, specify an override to resolve conflict`)}return this.rules=n,this}build(){return new Jn(this.rules)}};var ye=class e{tokens;static create(t){return new e(t)}constructor(t){this.tokens=t?.tokens?[...t.tokens]:[]}merge(t,r=[]){let n=t.tokens.filter(i=>{if(r.find(o=>o.name===i.name))return!1;let a=this.tokens.find(o=>o.name===i.name);if(a){if(a!==i)throw new Error(`Token with name ${i.name} already exists. Implementation is different and no overwrite was provided.`);return!1}return!0});return this.tokens.push(...n),this}add(...t){return this.tokens.push(...t),this}addBefore(t,...r){let n=this.tokens.indexOf(t);if(n===-1)throw new Error("Token not found");return this.tokens.splice(n,0,...r),this}moveBeforeOrAfter(t,r,...n){let i=this.tokens.indexOf(r)+(t==="before"?0:1);if(i===-1)throw new Error("BeforeToken not found");for(let s of n){let a=this.tokens.indexOf(s);if(a===-1)throw new Error("Token not found");this.tokens.splice(a,1),this.tokens.splice(i,0,s)}return this}moveBefore(t,...r){return this.moveBeforeOrAfter("before",t,...r)}moveAfter(t,...r){return this.moveBeforeOrAfter("after",t,...r)}addAfter(t,...r){let n=this.tokens.indexOf(t);if(n===-1)throw new Error("Token not found");return this.tokens.splice(n+1,0,...r),this}delete(...t){for(let r of t){let n=this.tokens.indexOf(r);if(n===-1)throw new Error("Token not found");this.tokens.splice(n,1)}return this}deleteToken(...t){for(let r of t){let n=this.tokens.findIndex(i=>i.name===r);if(n===-1)throw new Error(`Token with name "${r}" not found`);this.tokens.splice(n,1)}return this}replace(t){let r=this.tokens.findIndex(n=>n.name===t.name);if(r===-1)throw new Error(`Token with name "${t.name}" not found`);return this.tokens[r]=t,this}build(t){return new le(this.tokens,{positionTracking:"onlyStart",recoveryEnabled:!1,ensureOptimizations:!0,...t})}get tokenVocabulary(){return this.tokens}};var ei=class extends Vu{context;setContext(t){this.context=t}constructor(t,r,n={}){super(r,{maxLookahead:1,skipValidations:!0,dynamicTokensEnabled:!1,...n}),this.context=void 0;let s={...this.constructSelfRef(),cache:new WeakMap};for(let a of Object.values(t))this[a.name]=this.RULE(a.name,a.impl(s));this.performSelfAnalysis()}constructSelfRef(){let t=r=>((n,...i)=>r(this[n.name],{ARGS:[this.context,...i]}));return{CONSUME:(r,n)=>this.CONSUME(r,n),CONSUME1:(r,n)=>this.CONSUME1(r,n),CONSUME2:(r,n)=>this.CONSUME2(r,n),CONSUME3:(r,n)=>this.CONSUME3(r,n),CONSUME4:(r,n)=>this.CONSUME4(r,n),CONSUME5:(r,n)=>this.CONSUME5(r,n),CONSUME6:(r,n)=>this.CONSUME6(r,n),CONSUME7:(r,n)=>this.CONSUME7(r,n),CONSUME8:(r,n)=>this.CONSUME8(r,n),CONSUME9:(r,n)=>this.CONSUME9(r,n),OPTION:r=>this.OPTION(r),OPTION1:r=>this.OPTION1(r),OPTION2:r=>this.OPTION2(r),OPTION3:r=>this.OPTION3(r),OPTION4:r=>this.OPTION4(r),OPTION5:r=>this.OPTION5(r),OPTION6:r=>this.OPTION6(r),OPTION7:r=>this.OPTION7(r),OPTION8:r=>this.OPTION8(r),OPTION9:r=>this.OPTION9(r),OR:r=>this.OR(r),OR1:r=>this.OR1(r),OR2:r=>this.OR2(r),OR3:r=>this.OR3(r),OR4:r=>this.OR4(r),OR5:r=>this.OR5(r),OR6:r=>this.OR6(r),OR7:r=>this.OR7(r),OR8:r=>this.OR8(r),OR9:r=>this.OR9(r),MANY:r=>this.MANY(r),MANY1:r=>this.MANY1(r),MANY2:r=>this.MANY2(r),MANY3:r=>this.MANY3(r),MANY4:r=>this.MANY4(r),MANY5:r=>this.MANY5(r),MANY6:r=>this.MANY6(r),MANY7:r=>this.MANY7(r),MANY8:r=>this.MANY8(r),MANY9:r=>this.MANY9(r),MANY_SEP:r=>this.MANY_SEP(r),MANY_SEP1:r=>this.MANY_SEP1(r),MANY_SEP2:r=>this.MANY_SEP2(r),MANY_SEP3:r=>this.MANY_SEP3(r),MANY_SEP4:r=>this.MANY_SEP4(r),MANY_SEP5:r=>this.MANY_SEP5(r),MANY_SEP6:r=>this.MANY_SEP6(r),MANY_SEP7:r=>this.MANY_SEP7(r),MANY_SEP8:r=>this.MANY_SEP8(r),MANY_SEP9:r=>this.MANY_SEP9(r),AT_LEAST_ONE:r=>this.AT_LEAST_ONE(r),AT_LEAST_ONE1:r=>this.AT_LEAST_ONE1(r),AT_LEAST_ONE2:r=>this.AT_LEAST_ONE2(r),AT_LEAST_ONE3:r=>this.AT_LEAST_ONE3(r),AT_LEAST_ONE4:r=>this.AT_LEAST_ONE4(r),AT_LEAST_ONE5:r=>this.AT_LEAST_ONE5(r),AT_LEAST_ONE6:r=>this.AT_LEAST_ONE6(r),AT_LEAST_ONE7:r=>this.AT_LEAST_ONE7(r),AT_LEAST_ONE8:r=>this.AT_LEAST_ONE8(r),AT_LEAST_ONE9:r=>this.AT_LEAST_ONE9(r),AT_LEAST_ONE_SEP:r=>this.AT_LEAST_ONE_SEP(r),AT_LEAST_ONE_SEP1:r=>this.AT_LEAST_ONE_SEP1(r),AT_LEAST_ONE_SEP2:r=>this.AT_LEAST_ONE_SEP2(r),AT_LEAST_ONE_SEP3:r=>this.AT_LEAST_ONE_SEP3(r),AT_LEAST_ONE_SEP4:r=>this.AT_LEAST_ONE_SEP4(r),AT_LEAST_ONE_SEP5:r=>this.AT_LEAST_ONE_SEP5(r),AT_LEAST_ONE_SEP6:r=>this.AT_LEAST_ONE_SEP6(r),AT_LEAST_ONE_SEP7:r=>this.AT_LEAST_ONE_SEP7(r),AT_LEAST_ONE_SEP8:r=>this.AT_LEAST_ONE_SEP8(r),AT_LEAST_ONE_SEP9:r=>this.AT_LEAST_ONE_SEP9(r),ACTION:r=>this.ACTION(r),BACKTRACK:(r,...n)=>this.BACKTRACK(this[r.name],{ARGS:n}),SUBRULE:t((r,n)=>this.SUBRULE(r,n)),SUBRULE1:t((r,n)=>this.SUBRULE1(r,n)),SUBRULE2:t((r,n)=>this.SUBRULE2(r,n)),SUBRULE3:t((r,n)=>this.SUBRULE3(r,n)),SUBRULE4:t((r,n)=>this.SUBRULE4(r,n)),SUBRULE5:t((r,n)=>this.SUBRULE5(r,n)),SUBRULE6:t((r,n)=>this.SUBRULE6(r,n)),SUBRULE7:t((r,n)=>this.SUBRULE7(r,n)),SUBRULE8:t((r,n)=>this.SUBRULE8(r,n)),SUBRULE9:t((r,n)=>this.SUBRULE9(r,n))}}};function Hu(e){let t=Object.create(null);for(let r of e)t[r.name]=r;return t}var te=class e{static create(t){return Array.isArray(t)?new e(Hu(t)):new e({...t.rules})}rules;constructor(t){this.rules=t}widenContext(){return this}typePatch(){return this}patchRule(t){let r=this;return r.rules[t.name]=t,r}addRuleRedundant(t){let r=this,n=r.rules;if(n[t.name]!==void 0&&n[t.name]!==t)throw new Error(`Rule ${t.name} already exists in the builder`);return n[t.name]=t,r}addRule(t){return this.addRuleRedundant(t)}addMany(...t){return this.rules={...this.rules,...Hu(t)},this}deleteRule(t){return delete this.rules[t],this}deleteMany(...t){for(let r of t)delete this.rules[r];return this}getRule(t){return this.rules[t]}merge(t,r){let n=Object.assign(Object.create(null),t.rules),i=this.rules;for(let s of Object.values(i))if(n[s.name]===void 0)n[s.name]=s;else if(n[s.name]!==s){let o=r.find(c=>c.name===s.name);if(o)n[s.name]=o;else throw new Error(`Rule with name "${s.name}" already exists in the builder, specify an override to resolve conflict`)}return this.rules=n,this}defaultErrorHandler(t,r){let n=r[0],i=["Parse error"],s=n.token.startLine;if(s!==void 0&&!Number.isNaN(s)){let a=t.split(` +`)[s-1];i.push(` on line ${s} +${a}`);let o=n.token.startColumn;o!==void 0&&i.push(` +${"-".repeat(o-1)}^`)}throw i.push(` +${n.message}`),new Error(i.join(""))}build({tokenVocabulary:t,parserConfig:r={},lexerConfig:n={},queryPreProcessor:i=a=>a,errorHandler:s}){let a=ye.create().add(...t).build({positionTracking:"onlyOffset",recoveryEnabled:!1,ensureOptimizations:!0,safeMode:!1,skipValidations:!0,...n}),o=this.consume({tokenVocabulary:t,config:r}),c={};for(let l of Object.values(this.rules))c[l.name]=((p,h,...d)=>{let m=i(p),A=a.tokenize(m);if(A.errors.length>0)throw new Error(A.errors[0].message);o.input=A.tokens,o.setContext(h);let b=o[l.name](h,...d);return o.errors.length>0&&(s?s(o.errors):this.defaultErrorHandler(m,o.errors)),b});return c}consume({tokenVocabulary:t,config:r={}}){return new ei(this.rules,t,r)}};function dt(e){return e instanceof Promise}var $t=class e{defaultContext;maxStackSize=1e6;maxNodeRewrites=1e3;constructor(t={}){this.defaultContext=t}clone(t={}){return new e({...this.defaultContext,...t})}cloneObj(t){if(t===null||typeof t!="object")return t;let r=Object.getPrototypeOf(t);return r===Object.prototype||r===null?{...t}:Object.assign(Object.create(r),t)}transformObject(t,r,n=()=>({})){return this.runTransformObject(t,r,n,!1)}transformObjectAsync(t,r,n=()=>({})){return Promise.resolve(this.runTransformObject(t,r,n,!0))}runTransformObject(t,r,n,i){let s=this.defaultContext,a=s.copy??!0,o=s.continue??!0,c=s.ignoreKeys,l=s.shallowKeys,p=s.shortcut??!1,h=!1,d={res:t},m=[t],A=[d],b=["res"],y=[],v=[],x=[],T=[],I=[];function S(){for(;m.length===y.at(-1);){y.pop();let M=v.pop(),z=x.pop(),J=T.pop(),fe=I.pop(),de=r(M,z);if(i&&dt(de))return de.then(ne=>(J[fe]=ne,S()));J[fe]=de}}let C=(M,z,J,fe)=>{let de=fe.copy??a,ne=fe.continue??o,q=fe.ignoreKeys??c,ae=fe.shallowKeys??l;h=fe.shortcut??p;let pe=de?this.cloneObj(M):M;if(y.push(m.length),v.push(pe),x.push(M),T.push(z),I.push(J),ne&&!h)for(let ct in pe){if(!Object.hasOwn(pe,ct))continue;let Ze=pe[ct],ln=ae&&ae?.has(ct);ln&&(pe[ct]=this.cloneObj(Ze)),!(q&&q.has(ct))&&!ln&&Ze!==null&&typeof Ze=="object"&&(m.push(Ze),b.push(ct),A.push(pe))}},X=()=>{for(;m.length>0&&m.length=0;ae--){let pe=M[ae];pe!==null&&typeof pe=="object"&&(m.push(pe),A.push(ne),b.push(ae.toString()))}let q=S();if(q)return q.then(X);continue}let de=n(M);if(i&&dt(de))return de.then(ne=>{C(M,z,J,ne);let q=S();return q?q.then(X):X()});C(M,z,J,de)}let fe=S();if(fe)return fe.then(X)}if(m.length>=this.maxStackSize)throw new Error("Transform object stack overflowed");return d.res};return X()}transformObjectPreOrder(t,r){return this.runTransformObjectPreOrder(t,r,!1)}transformObjectPreOrderAsync(t,r){return Promise.resolve(this.runTransformObjectPreOrder(t,r,!0))}runTransformObjectPreOrder(t,r,n){let i=this.defaultContext,s=i.copy??!0,a=i.continue??!0,o=i.ignoreKeys,c=i.shallowKeys,l=i.shortcut??!1,p=i.reTransform??!1,h=!1,d={res:t},m=[t],A=[d],b=["res"],y=[0];function v(I,S){for(let C=I.length-1;C>=0;C--){let X=I[C];X!==null&&typeof X=="object"&&(m.push(X),A.push(I),b.push(C.toString()),y.push(S))}}let x=(I,S,C,X)=>{let M=I.newValue;S[C]=M;let z=I.continue??a,J=I.ignoreKeys??o,fe=I.shallowKeys??c,de=I.reTransform??p;if(h=I.shortcut??l,!z||h||M===null||typeof M!="object")return;if(Array.isArray(M)){v(M,X+1);return}if(de){m.push(M),A.push(S),b.push(C),y.push(X+1);return}let ne=M;for(let q in ne){if(!Object.hasOwn(ne,q)||J?.has(q))continue;let ae=ne[q];ae!==null&&typeof ae=="object"&&(fe?.has(q)?ne[q]=this.cloneObj(ae):(m.push(ae),A.push(ne),b.push(q),y.push(0)))}},T=()=>{for(;!h&&m.length>0&&m.length=this.maxNodeRewrites)throw new Error(`Pre order transform did not converge: rewrote the same position ${this.maxNodeRewrites} times.`,{cause:I});if(Array.isArray(I)){let J=[...I];S[C]=J,v(J,X);continue}let M=s?this.cloneObj(I):I,z=r(M,I);if(n&&dt(z))return z.then(J=>(x(J,S,C,X),T()));x(z,S,C,X)}if(m.length>=this.maxStackSize)throw new Error("Transform object stack overflowed");return d.res};return T()}visitObject(t,r,n=()=>({})){this.runVisitObject(t,r,n,!1)}visitObjectAsync(t,r,n=()=>({})){return Promise.resolve(this.runVisitObject(t,r,n,!0))}runVisitObject(t,r,n,i){let s=this.defaultContext,a=s.continue??!0,o=s.ignoreKeys,c=s.shortcut??!1,l=!1,p=[t],h=[],d=[];function m(){for(;p.length===h.at(-1);){h.pop();let y=d.pop(),v=r(y);if(i&&dt(v))return v.then(()=>m())}}let A=(y,v)=>{l=v.shortcut??c;let x=v.continue??a,T=v.ignoreKeys??o;if(h.push(p.length),d.push(y),x&&!l)for(let I in y){if(!Object.hasOwn(y,I)||T&&T.has(I))continue;let S=y[I];S&&typeof S=="object"&&p.push(S)}},b=()=>{for(;p.length>0&&p.length=0;I--){let S=y[I];S!==null&&typeof S=="object"&&p.push(S)}let T=m();if(T)return T.then(b);continue}let x=n(y);if(i&&dt(x))return x.then(T=>{A(y,T);let I=m();return I?I.then(b):b()});A(y,x)}let v=m();if(v)return v.then(b)}if(p.length>=this.maxStackSize)throw new Error("Transform object stack overflowed")};return b()}};var ti=class e extends $t{defaultNodePreVisitor;constructor(t={},r={}){super(t),this.defaultNodePreVisitor=r}clone(t={},r={}){return new e({...this.defaultContext,...t},{...this.defaultNodePreVisitor,...r})}transformNode(t,r){let n=(a,o)=>{let c,l=a;return l.type&&(c=r[l.type]?.transform),c?c(l,o):a},i=this.defaultNodePreVisitor,s=a=>{let o,c={},l=a;return l.type&&(o=r[l.type]?.preVisitor,c=i[l.type]??c),o?{...c,...o(l)}:c};return this.transformObject(t,n,s)}transformNodeAsync(t,r){let n=(a,o)=>{let c,l=a;return l.type&&(c=r[l.type]?.transform),c?c(l,o):a},i=this.defaultNodePreVisitor,s=a=>{let o,c={},l=a;if(l.type&&(o=r[l.type]?.preVisitor,c=i[l.type]??c),!o)return c;let p=o(l);return dt(p)?p.then(h=>({...c,...h})):{...c,...p}};return this.transformObjectAsync(t,n,s)}transformNodePreOrder(t,r){let n=this.defaultNodePreVisitor,i=(s,a)=>{let o,c={},l=s;return l.type&&(o=r[l.type],c=n[l.type]??c),o?{...c,...o(s,a)}:{...c,newValue:s,reTransform:!1}};return this.transformObjectPreOrder(t,i)}transformNodePreOrderAsync(t,r){let n=this.defaultNodePreVisitor,i=(s,a)=>{let o,c={},l=s;if(l.type&&(o=r[l.type],c=n[l.type]??c),!o)return{...c,newValue:s,reTransform:!1};let p=o(s,a);return dt(p)?p.then(h=>({...c,...h})):{...c,...p}};return this.transformObjectPreOrderAsync(t,i)}visitNode(t,r){let n=a=>{let o=a;if(o.type){let c=r[o.type]?.visitor;c&&c(o)}},i=this.defaultNodePreVisitor,s=a=>{let o,c={},l=a;return l.type&&(o=r[l.type]?.preVisitor,c=i[l.type]??c),o?{...c,...o(l)}:c};return this.visitObject(t,n,s)}visitNodeAsync(t,r){let n=a=>{let o=a;if(o.type){let c=r[o.type]?.visitor;if(c)return c(o)}},i=this.defaultNodePreVisitor,s=a=>{let o,c={},l=a;if(l.type&&(o=r[l.type]?.preVisitor,c=i[l.type]??c),!o)return c;let p=o(l);return dt(p)?p.then(h=>({...c,...h})):{...c,...p}};return this.visitObjectAsync(t,n,s)}};var zr=class e extends ti{constructor(t={},r={}){super(t,r)}clone(t={},r={}){return new e({...this.defaultContext,...t},{...this.defaultNodePreVisitor,...r})}transformNodeSpecific(t,r,n){let i=(a,o)=>{let c,l=a;if(l.type&&l.subType){let p=n[l.type];p&&(c=p[l.subType]?.transform),c||(c=r[l.type]?.transform)}return c?c(l,o):a},s=a=>{let o,c=a;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]?.preVisitor),o||(o=r[c.type]?.preVisitor)}return o?o(c):{}};return this.transformObject(t,i,s)}transformNodeSpecificAsync(t,r,n){let i=(a,o)=>{let c,l=a;if(l.type&&l.subType){let p=n[l.type];p&&(c=p[l.subType]?.transform),c||(c=r[l.type]?.transform)}return c?c(l,o):a},s=a=>{let o,c=a;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]?.preVisitor),o||(o=r[c.type]?.preVisitor)}return o?o(c):{}};return this.transformObjectAsync(t,i,s)}transformNodeSpecificPreOrder(t,r,n){let i=(s,a)=>{let o,c=s;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]),o||(o=r[c.type])}return o?o(s,a):{newValue:s}};return this.transformObjectPreOrder(t,i)}transformNodeSpecificPreOrderAsync(t,r,n){let i=(s,a)=>{let o,c=s;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]),o||(o=r[c.type])}return o?o(s,a):{newValue:s}};return this.transformObjectPreOrderAsync(t,i)}visitNodeSpecific(t,r,n){let i=a=>{let o,c=a;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]?.visitor),o||(o=r[c.type]?.visitor)}o&&o(c)},s=a=>{let o,c=a;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]?.preVisitor),o||(o=r[c.type]?.preVisitor)}return o?o(c):{}};this.visitObject(t,i,s)}visitNodeSpecificAsync(t,r,n){let i=a=>{let o,c=a;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]?.visitor),o||(o=r[c.type]?.visitor)}if(o)return o(c)},s=a=>{let o,c=a;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]?.preVisitor),o||(o=r[c.type]?.preVisitor)}return o?o(c):{}};return this.visitObjectAsync(t,i,s)}};var u={};Pt(u,{add:()=>Xo,additiveExpression:()=>um,aggregate:()=>us,aggregateAvg:()=>Ld,aggregateCount:()=>bd,aggregateGroup_concat:()=>Od,aggregateMax:()=>Ed,aggregateMin:()=>Id,aggregateSample:()=>_d,aggregateSum:()=>xd,argList:()=>dr,askQuery:()=>an,baseAggregateFunc:()=>qt,baseDecl:()=>ro,bind:()=>Eo,blankNode:()=>is,blankNodePropertyList:()=>em,blankNodePropertyListPath:()=>To,booleanLiteral:()=>Wt,brackettedExpression:()=>mr,builtInAbs:()=>Nf,builtInBnodeSparqlJs:()=>Of,builtInBound:()=>Ef,builtInCall:()=>yt,builtInCallList:()=>md,builtInCeil:()=>Pf,builtInCoalesce:()=>sd,builtInConcat:()=>Ff,builtInContains:()=>Gf,builtInDatatype:()=>If,builtInDay:()=>zf,builtInEncode_for_uri:()=>Df,builtInFloor:()=>kf,builtInHours:()=>qf,builtInIf:()=>ad,builtInIri:()=>Lf,builtInIsblank:()=>hd,builtInIsiri:()=>ud,builtInIsliteral:()=>fd,builtInIsnumeric:()=>dd,builtInIsuri:()=>pd,builtInLang:()=>bf,builtInLangmatches:()=>xf,builtInLcase:()=>Mf,builtInMd5:()=>ed,builtInMinutes:()=>Yf,builtInMonth:()=>Wf,builtInNow:()=>Zf,builtInRand:()=>Sf,builtInRound:()=>Rf,builtInSameterm:()=>ld,builtInSeconds:()=>Xf,builtInSha1:()=>td,builtInSha256:()=>rd,builtInSha384:()=>nd,builtInSha512:()=>id,builtInStr:()=>Af,builtInStrafter:()=>Kf,builtInStrbefore:()=>Vf,builtInStrdt:()=>cd,builtInStrends:()=>jf,builtInStrlang:()=>od,builtInStrlen:()=>wf,builtInStrstarts:()=>$f,builtInStruuid:()=>Uf,builtInTimezone:()=>Bf,builtInTz:()=>Qf,builtInUcase:()=>Cf,builtInUri:()=>_f,builtInUuid:()=>Jf,builtInYear:()=>Hf,canCreateBlankNodes:()=>UO,clear:()=>zo,collection:()=>Zd,collectionPath:()=>go,conditionalAndExpression:()=>ko,conditionalOrExpression:()=>cm,constraint:()=>en,constructQuery:()=>nn,constructTemplate:()=>Ho,constructTriples:()=>dm,copy:()=>Qo,create:()=>Yo,dataBlock:()=>im,dataBlockValue:()=>No,datasetClause:()=>gf,datasetClauseStar:()=>Be,datasetClauseUsing:()=>ao,datasetClauseUsingStar:()=>oo,defaultGraphClause:()=>Tf,deleteClause:()=>gm,deleteData:()=>Jo,deleteWhere:()=>Uo,describeQuery:()=>sn,drop:()=>qo,existsFunc:()=>vd,expression:()=>R,expressionList:()=>ls,filter:()=>Oo,funcExpr1:()=>G,funcExpr2:()=>Qe,funcExpr2or3:()=>os,funcExpr3:()=>lo,funcExpr3or4:()=>ho,funcExprList1:()=>as,funcExprOrNil1:()=>po,funcGroupGraphPattern:()=>cs,funcNil1:()=>hr,funcVar1:()=>uo,functionCall:()=>ms,generatePattern:()=>rm,graphGraphPattern:()=>xo,graphNode:()=>Ao,graphNodePath:()=>at,graphOrDefault:()=>rc,graphPatternNotTriples:()=>So,graphRef:()=>cn,graphRefAll:()=>Xt,graphTerm:()=>io,groupClause:()=>Do,groupCondition:()=>pm,groupGraphPattern:()=>Y,groupGraphPatternSub:()=>nm,groupOrUnionGraphPattern:()=>_o,havingClause:()=>Go,havingCondition:()=>hm,inlineData:()=>fr,inlineDataFull:()=>am,inlineDataOneVar:()=>sm,insertClause:()=>tc,insertData:()=>Zo,iri:()=>$,iriFull:()=>pr,iriOrFunction:()=>Mo,limitClause:()=>Vo,limitOffsetClauses:()=>jo,load:()=>Wo,minusGraphPattern:()=>Lo,modify:()=>ec,move:()=>Bo,multiplicativeExpression:()=>wo,namedGraphClause:()=>vf,notExistsFunc:()=>Ad,numericExpression:()=>Fo,numericLiteral:()=>Ht,numericLiteralNegative:()=>rs,numericLiteralPositive:()=>ts,numericLiteralUnsigned:()=>mf,object:()=>Xd,objectList:()=>zd,objectListPath:()=>qd,objectPath:()=>Bd,offsetClause:()=>Ko,optionalGraphPattern:()=>bo,orderClause:()=>$o,orderCondition:()=>fm,path:()=>hs,pathAlternative:()=>Pd,pathChainHelper:()=>mo,pathElt:()=>fo,pathEltOrInverse:()=>Sd,pathGenerator:()=>vt,pathMod:()=>kd,pathNegatedPropertySet:()=>Fd,pathOneInPropertySet:()=>ps,pathPrimary:()=>Rd,pathSequence:()=>Nd,prefixDecl:()=>no,prefixedName:()=>to,primaryExpression:()=>Co,prologue:()=>De,propertyList:()=>$d,propertyListNotEmpty:()=>fs,propertyListPath:()=>jd,propertyListPathNotEmpty:()=>ds,quadData:()=>sc,quadPattern:()=>vs,quads:()=>yr,quadsNotTriples:()=>nc,query:()=>gr,queryOrUpdate:()=>iS,queryUnit:()=>rS,rdfLiteral:()=>St,regexExpression:()=>gd,relationalExpression:()=>lm,selectClause:()=>Ts,selectQuery:()=>rn,serviceGraphPattern:()=>Io,solutionModifier:()=>$e,sourceSelector:()=>co,strReplaceExpression:()=>yd,string:()=>ns,stringEscapedLexical:()=>Ur,subSelect:()=>Po,substringExpression:()=>Td,triplesBlock:()=>ot,triplesNode:()=>yo,triplesNodePath:()=>vo,triplesSameSubject:()=>Md,triplesSameSubjectPath:()=>Dd,triplesTemplate:()=>Yt,unaryExpression:()=>gs,update:()=>ys,update1:()=>Tr,updateUnit:()=>nS,usingClause:()=>yf,usingClauseStar:()=>ss,valueLogical:()=>Ro,valuesClause:()=>on,varOrIri:()=>Tt,varOrTerm:()=>ue,var_:()=>W,verb:()=>so,verbA:()=>zt,verbPath:()=>Kd,verbSimple:()=>Hd,whereClause:()=>Ge});var he={};Pt(he,{a:()=>lr,add:()=>Ni,allBaseTokens:()=>Zh,as:()=>Lt,ask:()=>mi,baseDecl:()=>li,bind:()=>Ki,builtIn:()=>E,by:()=>Jr,clear:()=>_i,construct:()=>fi,copy:()=>Ri,create:()=>Si,deleteClause:()=>Mi,deleteDataClause:()=>wi,deleteWhereClause:()=>Ci,describe:()=>di,distinct:()=>Xe,drop:()=>Oi,false_:()=>Xi,filter:()=>qi,from:()=>gi,graph:()=>ve,groupByGroup:()=>Zr,having:()=>Ti,in_:()=>Bi,insertClause:()=>Gi,insertDataClause:()=>Di,limit:()=>bi,load:()=>Ei,loadInto:()=>Li,minus:()=>Wi,modifyWith:()=>Fi,move:()=>ki,notIn:()=>Qi,offset:()=>xi,optional:()=>ji,order:()=>yi,orderAsc:()=>vi,orderDesc:()=>Ai,patterns:()=>Ya,prefixDecl:()=>ui,reduced:()=>hi,select:()=>pi,separator:()=>Zi,service:()=>Vi,silent:()=>mt,sparql11LexerBuilder:()=>QO,symbols:()=>g,terminals:()=>F,to:()=>Pi,true_:()=>Yi,undef:()=>Hi,union:()=>zi,usingClause:()=>$i,values:()=>Ii,where:()=>_t});var E={};Pt(E,{BuiltInCalls:()=>L,abs:()=>Uu,allBuiltInCalls:()=>La,avg:()=>ri,bnode:()=>Zu,bound:()=>Xu,ceil:()=>ep,coalesce:()=>Np,concat:()=>np,contains:()=>cp,count:()=>Wp,datatype:()=>Yu,day:()=>mp,encode_for_uri:()=>op,exists:()=>Kp,floor:()=>tp,groupConcat:()=>ni,hours:()=>gp,if_:()=>Pp,iri:()=>Bu,isblank:()=>Mp,isiri:()=>wp,isliteral:()=>Dp,isnumeric:()=>Gp,isuri:()=>Cp,lang:()=>zu,langmatches:()=>qu,lcase:()=>ap,max:()=>Yp,md5:()=>Ep,min:()=>qp,minutes:()=>Tp,month:()=>dp,notexists:()=>Hp,now:()=>bp,rand:()=>Ju,regex:()=>$p,replace:()=>Vp,round:()=>rp,sameterm:()=>Fp,sample:()=>Xp,seconds:()=>yp,sha1:()=>Lp,sha256:()=>_p,sha384:()=>Op,sha512:()=>Sp,str:()=>Wu,strafter:()=>hp,strbefore:()=>pp,strdt:()=>Rp,strends:()=>up,strlang:()=>kp,strlen:()=>ip,strstarts:()=>lp,struuid:()=>Ip,substr:()=>jp,sum:()=>zp,timezone:()=>vp,tz:()=>Ap,ucase:()=>sp,uri:()=>Qu,uuid:()=>xp,year:()=>fp});var L;(function(e){e.Str="builtInStr",e.Lang="builtInLang",e.Langmatches="builtInLangmatches",e.Datatype="builtInDatatype",e.Bound="builtInBound",e.Iri="builtInIri",e.Uri="builtInUri",e.Bnode="builtInBnode",e.Rand="builtInRand",e.Abs="builtInAbs",e.Ceil="builtInCeil",e.Floor="builtInFloor",e.Round="builtInRound",e.Concat="builtInConcat",e.Strlen="builtInStrlen",e.Ucase="builtInUcase",e.Lcase="builtInLcase",e.Encode_for_uri="builtInEncode_for_uri",e.Contains="builtInContains",e.Strstarts="builtInStrstarts",e.Strends="builtInStrends",e.Strbefore="builtInStrbefore",e.Strafter="builtInStrafter",e.Year="builtInYear",e.Month="builtInMonth",e.Day="builtInDay",e.Hours="builtInHours",e.Minutes="builtInMinutes",e.Seconds="builtInSeconds",e.Timezone="builtInTimezone",e.Tz="builtInTz",e.Now="builtInNow",e.Uuid="builtInUuid",e.Struuid="builtInStruuid",e.Md5="builtInMd5",e.Sha1="builtInSha1",e.Sha256="builtInSha256",e.Sha384="builtInSha384",e.Sha512="builtInSha512",e.Coalesce="builtInCoalesce",e.If="builtInIf",e.Strlang="builtInStrlang",e.Strdt="builtInStrdt",e.Sameterm="builtInSameterm",e.Isiri="builtInIsiri",e.Isuri="builtInIsuri",e.Isblank="builtInIsblank",e.Isliteral="builtInIsliteral",e.Isnumeric="builtInIsnumeric",e.Regex="builtInRegex",e.Substr="builtInSubstr",e.Replace="builtInReplace",e.Exists="builtInExists",e.Notexists="builtInNotexists",e.Count="builtInCount",e.Sum="builtInSum",e.Min="builtInMin",e.Max="builtInMax",e.Avg="builtInAvg",e.Sample="builtInSample",e.Group_concat="builtInGroup_concat"})(L||(L={}));function _(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Wu=f({name:_(L.Str),pattern:/str/i,label:"STR"}),zu=f({name:_(L.Lang),pattern:/lang/i,label:"LANG"}),qu=f({name:_(L.Langmatches),pattern:/langmatches/i,label:"LANGMATCHES"}),Yu=f({name:_(L.Datatype),pattern:/datatype/i,label:"DATATYPE"}),Xu=f({name:_(L.Bound),pattern:/bound/i,label:"BOUND"}),Bu=f({name:_(L.Iri),pattern:/iri/i,label:"IRI"}),Qu=f({name:_(L.Uri),pattern:/uri/i,label:"URI"}),Zu=f({name:_(L.Bnode),pattern:/bnode/i,label:"BNODE"}),Ju=f({name:_(L.Rand),pattern:/rand/i,label:"RAND"}),Uu=f({name:_(L.Abs),pattern:/abs/i,label:"ABS"}),ep=f({name:_(L.Ceil),pattern:/ceil/i,label:"CEIL"}),tp=f({name:_(L.Floor),pattern:/floor/i,label:"FLOOR"}),rp=f({name:_(L.Round),pattern:/round/i,label:"ROUND"}),np=f({name:_(L.Concat),pattern:/concat/i,label:"CONCAT"}),ip=f({name:_(L.Strlen),pattern:/strlen/i,label:"STRLEN"}),sp=f({name:_(L.Ucase),pattern:/ucase/i,label:"UCASE"}),ap=f({name:_(L.Lcase),pattern:/lcase/i,label:"LCASE"}),op=f({name:_(L.Encode_for_uri),pattern:/encode_for_uri/i,label:"ENCODE_FOR_URI"}),cp=f({name:_(L.Contains),pattern:/contains/i,label:"CONTAINS"}),lp=f({name:_(L.Strstarts),pattern:/strstarts/i,label:"STRSTARTS"}),up=f({name:_(L.Strends),pattern:/strends/i,label:"STRENDS"}),pp=f({name:_(L.Strbefore),pattern:/strbefore/i,label:"STRBEFORE"}),hp=f({name:_(L.Strafter),pattern:/strafter/i,label:"STRAFTER"}),fp=f({name:_(L.Year),pattern:/year/i,label:"YEAR"}),dp=f({name:_(L.Month),pattern:/month/i,label:"MONTH"}),mp=f({name:_(L.Day),pattern:/day/i,label:"DAY"}),gp=f({name:_(L.Hours),pattern:/hours/i,label:"HOURS"}),Tp=f({name:_(L.Minutes),pattern:/minutes/i,label:"MINUTES"}),yp=f({name:_(L.Seconds),pattern:/seconds/i,label:"SECONDS"}),vp=f({name:_(L.Timezone),pattern:/timezone/i,label:"TIMEZONE"}),Ap=f({name:_(L.Tz),pattern:/tz/i,label:"TZ"}),bp=f({name:_(L.Now),pattern:/now/i,label:"NOW"}),xp=f({name:_(L.Uuid),pattern:/uuid/i,label:"UUID"}),Ip=f({name:_(L.Struuid),pattern:/struuid/i,label:"STRUUID"}),Ep=f({name:_(L.Md5),pattern:/md5/i,label:"MD5"}),Lp=f({name:_(L.Sha1),pattern:/sha1/i,label:"SHA1"}),_p=f({name:_(L.Sha256),pattern:/sha256/i,label:"SHA256"}),Op=f({name:_(L.Sha384),pattern:/sha384/i,label:"SHA384"}),Sp=f({name:_(L.Sha512),pattern:/sha512/i,label:"SHA512"}),Np=f({name:_(L.Coalesce),pattern:/coalesce/i,label:"COALESCE"}),Pp=f({name:_(L.If),pattern:/if/i,label:"IF"}),kp=f({name:_(L.Strlang),pattern:/strlang/i,label:"STRLANG"}),Rp=f({name:_(L.Strdt),pattern:/strdt/i,label:"STRDT"}),Fp=f({name:_(L.Sameterm),pattern:/sameterm/i,label:"SAMETERM"}),wp=f({name:_(L.Isiri),pattern:/isiri/i,label:"ISIRI"}),Cp=f({name:_(L.Isuri),pattern:/isuri/i,label:"ISURI"}),Mp=f({name:_(L.Isblank),pattern:/isblank/i,label:"ISBLANK"}),Dp=f({name:_(L.Isliteral),pattern:/isliteral/i,label:"ISLITERAL"}),Gp=f({name:_(L.Isnumeric),pattern:/isnumeric/i,label:"ISNUMERIC"}),$p=f({name:_(L.Regex),pattern:/regex/i,label:"REGEX"}),jp=f({name:_(L.Substr),pattern:/substr/i,label:"SUBSTR"}),Vp=f({name:_(L.Replace),pattern:/replace/i,label:"REPLACE"}),Kp=f({name:_(L.Exists),pattern:/exists/i,label:"EXISTS"}),Hp=f({name:_(L.Notexists),pattern:/not exists/i,label:"NOT EXISTS"}),Wp=f({name:_(L.Count),pattern:/count/i,label:"COUNT"}),zp=f({name:_(L.Sum),pattern:/sum/i,label:"SUM"}),qp=f({name:_(L.Min),pattern:/min/i,label:"MIN"}),Yp=f({name:_(L.Max),pattern:/max/i,label:"MAX"}),ri=f({name:_(L.Avg),pattern:/avg/i,label:"AVG"}),Xp=f({name:_(L.Sample),pattern:/sample/i,label:"SAMPLE"}),ni=f({name:_(L.Group_concat),pattern:/group_concat/i,label:"GROUP_CONCAT"}),La=ye.create().add(qu,Yu,zu,Xu,Bu,Qu,Zu,Ju,Uu,ep,tp,rp,np,ip,sp,ap,op,cp,lp,up,pp,hp,fp,dp,mp,gp,Tp,yp,vp,Ap,bp,xp,Ip,Ep,Lp,_p,Op,Sp,Np,Pp,kp,Rp,Fp,wp,Cp,Mp,Dp,Gp,$p,jp,Vp,Kp,Hp,Wp,zp,qp,Yp,ri,Xp,ni,Wu);var ve={};Pt(ve,{allGraphTokens:()=>_a,default_:()=>Qp,graph:()=>Zp,graphAll:()=>ii,named:()=>Bp});var Bp=f({name:"NamedGraph",pattern:/named/i,label:"NAMED"}),Qp=f({name:"DefaultGraph",pattern:/default/i,label:"DEFAULT"}),Zp=f({name:"Graph",pattern:/graph/i,label:"GRAPH"}),ii=f({name:"GraphAll",pattern:/all/i,label:"ALL"}),_a=ye.create().add(Bp,Qp,Zp,ii);var Ya={};Pt(Ya,{anonPattern:()=>qa,atLeastOneBlankPattern:()=>Qr,blankNodeLabelPattern:()=>ka,commentPattern:()=>ci,decimalNegativePattern:()=>$a,decimalPattern:()=>Yr,decimalPositivePattern:()=>Ma,doubleNegativePattern:()=>ja,doublePattern:()=>Xr,doublePositivePattern:()=>Da,echarPattern:()=>Br,exponentPattern:()=>ai,integerNegativePattern:()=>Ga,integerPattern:()=>qr,integerPositivePattern:()=>Ca,iriRefPattern:()=>Na,langTagPattern:()=>wa,nilPattern:()=>za,pNameLnPattern:()=>Pa,pNameNsPattern:()=>oi,percentPattern:()=>Up,plxPattern:()=>si,pnCharsBasePattern:()=>Oa,pnCharsPattern:()=>jt,pnCharsUPattern:()=>or,pnLocalEscPattern:()=>eh,pnLocalPattern:()=>th,pnPrefixPattern:()=>Jp,stringLiteral1Pattern:()=>Va,stringLiteral2Pattern:()=>Ka,stringLiteralLong1Pattern:()=>Ha,stringLiteralLong2Pattern:()=>Wa,var1Pattern:()=>Ra,var2Pattern:()=>Fa,varNamePattern:()=>Sa,wsPattern:()=>cr});var Oa=/[A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF]/,or=new RegExp(`(${Oa.source})|_`),Sa=new RegExp(`((${or.source})|[0-9])((${or.source})|[0-9]|[\xB7\u0300-\u036F\u203F-\u2040])*`),Na=/<([^\u0000-\u0020"<>\\^`{|}])*>/,jt=new RegExp(`(${or.source})|[\\-0-9\xB7\u0300-\u036F\u203F-\u2040]`),Jp=new RegExp(`(${Oa.source})(((${jt.source})|\\.)*(${jt.source}))?`),oi=new RegExp(`(${Jp.source})?:`),Up=/%[\dA-Fa-f]{2}/,eh=/\\[!#$%&'()*+,./;=?@_~-]/,si=new RegExp(`(${Up.source})|(${eh.source})`),th=new RegExp(`((${or.source})|:|[0-9]|(${si.source}))(((${jt.source})|\\.|:|(${si.source}))*((${jt.source})|:|(${si.source})))?`),Pa=new RegExp(`(${oi.source})(${th.source})`),ka=new RegExp(`_:((${or.source})|[0-9])(((${jt.source})|\\.)*(${jt.source}))?`),Ra=new RegExp(`\\?(${Sa.source})`),Fa=new RegExp(`\\$(${Sa.source})`),wa=/@[A-Za-z]+(-[\dA-Za-z]+)*/,qr=/\d+/,Yr=/\d+\.\d+/,ai=/[Ee][+-]?\d+/,Xr=new RegExp(`([0-9]+\\.[0-9]*(${ai.source}))|(\\.[0-9]+(${ai.source}))|([0-9]+(${ai.source}))`),Ca=new RegExp(`\\+(${qr.source})`),Ma=new RegExp(`\\+(${Yr.source})`),Da=new RegExp(`\\+(${Xr.source})`),Ga=new RegExp(`-(${qr.source})`),$a=new RegExp(`-(${Yr.source})`),ja=new RegExp(`-(${Xr.source})`),Br=/\\["'\\bfnrt]/,Va=new RegExp(`'(([^\\u0027\\u005C\\u000A\r])|(${Br.source}))*'`),Ka=new RegExp(`"(([^\\u0022\\u005C\\u000A\\u000D])|(${Br.source}))*"`),Ha=new RegExp(`'''(('|(''))?([^'\\\\]|(${Br.source})))*'''`),Wa=new RegExp(`"""(("|(""))?([^"\\\\]|(${Br.source})))*"""`),cr=/[\u0009\u000A\u000D ]/,za=new RegExp(`\\((${cr.source})*\\)`),qa=new RegExp(`\\[(${cr.source})*\\]`),ci=/#[^\n]*/,Qr=new RegExp(`(((${cr.source})+)|((${ci.source}) +))+`);var g={};Pt(g,{LCurly:()=>rh,LParen:()=>oh,LSquare:()=>lh,RCurly:()=>nh,RParen:()=>ch,RSquare:()=>uh,allSymbols:()=>Xa,comma:()=>sh,dot:()=>ih,equal:()=>bh,exclamation:()=>yh,greaterThan:()=>Eh,greaterThanEqual:()=>_h,hat:()=>fh,hathat:()=>Oh,lessThan:()=>Ih,lessThanEqual:()=>Lh,logicAnd:()=>vh,logicOr:()=>Ah,notEqual:()=>xh,opMinus:()=>Th,opPlus:()=>gh,pipe:()=>ph,question:()=>dh,semi:()=>ah,slash:()=>hh,star:()=>mh});var rh=f({name:"LCurly",pattern:"{",label:"{"}),nh=f({name:"RCurly",pattern:"}",label:"}"}),ih=f({name:"Dot",pattern:".",label:"."}),sh=f({name:"Comma",pattern:",",label:","}),ah=f({name:"Semi",pattern:";",label:";"}),oh=f({name:"LParen",pattern:"(",label:"("}),ch=f({name:"RParen",pattern:")",label:")"}),lh=f({name:"LSquare",pattern:"[",label:"["}),uh=f({name:"RSquare",pattern:"]",label:"]"}),ph=f({name:"Pipe",pattern:"|",label:"|"}),hh=f({name:"Slash",pattern:"/",label:"/"}),fh=f({name:"Hat",pattern:"^",label:"^"}),dh=f({name:"Question",pattern:"?",label:"?"}),mh=f({name:"Star",pattern:"*",label:"*"}),gh=f({name:"OpPlus",pattern:"+",label:"+"}),Th=f({name:"OpMinus",pattern:"-",label:"-"}),yh=f({name:"Exclamation",pattern:"!",label:"!"}),vh=f({name:"LogicAnd",pattern:"&&",label:"&&"}),Ah=f({name:"LogicOr",pattern:"||",label:"||"}),bh=f({name:"Equal",pattern:"=",label:"="}),xh=f({name:"NotEqual",pattern:"!=",label:"!="}),Ih=f({name:"LessThan",pattern:"<",label:"<"}),Eh=f({name:"GreaterThan",pattern:">",label:">"}),Lh=f({name:"LessThanEqual",pattern:"<=",label:"<="}),_h=f({name:"GreaterThanEqual",pattern:">=",label:">="}),Oh=f({name:"Hathat",pattern:"^^",label:"^^"}),Xa=ye.create().add(vh,Ah,xh,Lh,_h,rh,nh,ih,sh,ah,oh,ch,lh,uh,ph,hh,Oh,fh,dh,mh,gh,Th,yh,bh,Ih,Eh);var F={};Pt(F,{allTerminals:()=>Qa,anon:()=>Qh,blankNodeLabel:()=>Ph,comment:()=>Xh,decimal:()=>Ch,decimalNegative:()=>Vh,decimalPositive:()=>Gh,double:()=>Mh,doubleNegative:()=>Kh,doublePositive:()=>$h,integer:()=>wh,integerNegative:()=>jh,integerPositive:()=>Dh,iriRef:()=>Sh,langTag:()=>Fh,nil:()=>Bh,pNameLn:()=>Ba,pNameNs:()=>Nh,stringLiteral1:()=>Hh,stringLiteral2:()=>Wh,stringLiteralLong1:()=>zh,stringLiteralLong2:()=>qh,var1:()=>kh,var2:()=>Rh,ws:()=>Yh});var Sh=f({name:"IriRef",pattern:Na}),Ba=f({name:"PNameLn",pattern:Pa}),Nh=f({name:"PNameNs",pattern:oi,longer_alt:[Ba]}),Ph=f({name:"BlankNodeLabel",pattern:ka}),kh=f({name:"Var1",pattern:Ra}),Rh=f({name:"Var2",pattern:Fa}),Fh=f({name:"LangTag",pattern:wa}),wh=f({name:"Integer",pattern:qr}),Ch=f({name:"Decimal",pattern:Yr}),Mh=f({name:"Double",pattern:Xr}),Dh=f({name:"IntegerPositive",pattern:Ca}),Gh=f({name:"DecimalPositive",pattern:Ma}),$h=f({name:"DoublePositive",pattern:Da}),jh=f({name:"IntegerNegative",pattern:Ga}),Vh=f({name:"DecimalNegative",pattern:$a}),Kh=f({name:"DoubleNegative",pattern:ja}),Hh=f({name:"StringLiteral1",pattern:Va}),Wh=f({name:"StringLiteral2",pattern:Ka}),zh=f({name:"StringLiteralLong1",pattern:Ha}),qh=f({name:"StringLiteralLong2",pattern:Wa}),Yh=f({name:"Ws",pattern:cr,group:le.SKIPPED}),Xh=f({name:"Comment",pattern:ci,group:le.SKIPPED}),Bh=f({name:"Nil",pattern:za}),Qh=f({name:"Anon",pattern:qa}),Qa=ye.create().add(Sh,Nh,Ba,Ph,kh,Rh,Fh,Mh,Ch,wh,$h,Gh,Dh,Kh,Vh,jh,zh,qh,Hh,Wh,Yh,Xh,Bh,Qh);var li=f({name:"BaseDecl",pattern:/base/i,label:"BASE"}),ui=f({name:"PrefixDecl",pattern:/prefix/i,label:"PREFIX"}),pi=f({name:"Select",pattern:/select/i,label:"SELECT"}),Xe=f({name:"Distinct",pattern:/distinct/i,label:"DISTINCT"}),hi=f({name:"Reduced",pattern:/reduced/i,label:"REDUCED"}),Lt=f({name:"As",pattern:/as/i,label:"AS"}),fi=f({name:"Construct",pattern:/construct/i,label:"CONSTRUCT"}),di=f({name:"Describe",pattern:/describe/i,label:"DESCRIBE"}),mi=f({name:"Ask",pattern:/ask/i,label:"ASK"}),gi=f({name:"From",pattern:/from/i,label:"FROM"}),_t=f({name:"Where",pattern:/where/i,label:"WHERE"}),Zr=f({name:"GroupByGroup",pattern:/group/i,label:"_GROUP_ BY"}),Jr=f({name:"By",pattern:/by/i,label:"BY"}),Ti=f({name:"Having",pattern:/having/i,label:"HAVING"}),yi=f({name:"Order",pattern:/order/i,label:"_ORDER_ BY"}),vi=f({name:"OrderAsc",pattern:/asc/i,label:"ASC"}),Ai=f({name:"OrderDesc",pattern:/desc/i,label:"DESC"}),bi=f({name:"Limit",pattern:/limit/i,label:"LIMIT"}),xi=f({name:"Offset",pattern:/offset/i,label:"OFFSET"}),Ii=f({name:"Values",pattern:/values/i,label:"VALUES"}),Ei=f({name:"Load",pattern:/load/i,label:"LOAD"}),mt=f({name:"Silent",pattern:/silent/i,label:"SILENT"}),Li=f({name:"LoadInto",pattern:/into/i,label:"INTO"}),_i=f({name:"Clear",pattern:/clear/i,label:"CLEAR"}),Oi=f({name:"Drop",pattern:/drop/i,label:"DROP"}),Si=f({name:"Create",pattern:/create/i,label:"CREATE"}),Ni=f({name:"Add",pattern:/add/i,label:"ADD"}),Pi=f({name:"To",pattern:/to/i,label:"TO"}),ki=f({name:"Move",pattern:/move/i,label:"MOVE"}),Ri=f({name:"Copy",pattern:/copy/i,label:"COPY"}),Fi=f({name:"ModifyWith",pattern:/with/i,label:"WITH"}),wi=f({name:"DeleteDataClause",pattern:new RegExp(`delete(${Qr.source})data`,"i"),label:"DELETE DATA"}),Ci=f({name:"DeleteWhereClause",pattern:new RegExp(`delete(${Qr.source})where`,"i"),label:"DELETE WHERE"}),Mi=f({name:"DeleteClause",pattern:/delete/i,label:"DELETE"}),Di=f({name:"InsertDataClause",pattern:new RegExp(`insert(${Qr.source})data`,"i"),label:"INSERT DATA"}),Gi=f({name:"InsertClause",pattern:/insert/i,label:"insert"}),$i=f({name:"UsingClause",pattern:/using/i,label:"USING"}),ji=f({name:"Optional",pattern:/optional/i,label:"OPTIONAL"}),Vi=f({name:"Service",pattern:/service/i,label:"SERVICE"}),Ki=f({name:"Bind",pattern:/bind/i,label:"BIND"}),Hi=f({name:"Undef",pattern:/undef/i,label:"UNDEF"}),Wi=f({name:"Minus",pattern:/minus/i,label:"MINUS"}),zi=f({name:"Union",pattern:/union/i,label:"UNION"}),qi=f({name:"Filter",pattern:/filter/i,label:"FILTER"}),lr=f({name:"a",pattern:"a",label:"type declaration 'a'"}),Yi=f({name:"True",pattern:/true/i,label:"true"}),Xi=f({name:"False",pattern:/false/i,label:"false"}),Bi=f({name:"In",pattern:/in/i,label:"IN"}),Qi=f({name:"NotIn",pattern:/not[\u0020\u0009\u000D\u000A]+in/i,label:"NOT IN"}),Zi=f({name:"Separator",pattern:/separator/i,label:"SEPARATOR"}),Zh=ye.create().add(li,ui,pi,Xe,hi,fi,di,mi,gi,_t,Ti,Zr,Jr,yi,vi,Ai,bi,xi,Ii,Ei,mt,Li,_i,Oi,Si,Ni,Pi,ki,Ri,Fi,Ci,wi,Mi,Di,Gi,$i,ji,Vi,Ki,Hi,Wi,zi,qi,Lt,lr,Yi,Xi,Bi,Qi,Zi),QO=ye.create(Qa).merge(Zh).merge(La).merge(_a).merge(Xa).moveAfter(ri,lr).moveBefore(lr,ii).moveAfter(ni,Zr);var Za="contextDef";function Jh(e){return class extends e{contextDefinitionPrefix(r,n,i){return{type:Za,subType:"prefix",key:n,value:i,loc:r}}isContextDefinitionPrefix(r){return this.isOfSubType(r,Za,"prefix")}contextDefinitionBase(r,n){return{type:"contextDef",subType:"base",value:n,loc:r}}isContextDefinitionBase(r){return this.isOfSubType(r,Za,"base")}}}var st="expression";function Uh(e){return class extends e{isExpressionPure(r){return this.isOfType(r,st)}formatOperator(r){return r.toLowerCase().replaceAll(" ","")}expressionOperation(r,n,i){return{type:st,subType:"operation",operator:this.formatOperator(r),args:n,loc:i}}isExpressionOperator(r){return this.isOfSubType(r,st,"operation")}expressionFunctionCall(r,n,i,s){return{type:"expression",subType:"functionCall",function:r,args:n,distinct:i,loc:s}}isExpressionFunctionCall(r){return this.isOfSubType(r,st,"functionCall")}expressionPatternOperation(r,n,i){return{type:st,subType:"patternOperation",operator:this.formatOperator(r),args:n,loc:i}}isExpressionPatternOperation(r){return this.isOfSubType(r,st,"patternOperation")}aggregate(r,n,i,s,a){let o={type:"expression",subType:"aggregate",aggregation:this.formatOperator(r),distinct:n,loc:a};return this.isOfType(i,"wildcard")?{...o,expression:[i]}:s===void 0?{...o,expression:[i]}:{...o,expression:[i],separator:s}}isExpressionAggregate(r){return this.isOfSubType(r,st,"aggregate")}isExpressionAggregateSeparator(r){return this.isOfSubType(r,st,"aggregate")&&typeof r.separator=="string"}isExpressionAggregateOnWildcard(r){let n=r;return this.isOfSubType(r,st,"aggregate")&&Array.isArray(n.expression)&&n.expression.length===1&&this.isOfType(n.expression[0],"wildcard")}isExpressionAggregateDefault(r){let n=r;return this.isOfSubType(r,st,"operation")&&Array.isArray(n.expression)&&n.expression.length===1&&!this.isOfType(n.expression[0],"wildcard")}}}var gt="graphRef";function ef(e){return class extends e{isGraphRef(r){return this.isOfType(r,gt)}graphRefDefault(r){return{type:gt,subType:"default",loc:r}}isGraphRefDefault(r){return this.isOfSubType(r,gt,"default")}graphRefNamed(r){return{type:gt,subType:"named",loc:r}}isGraphRefNamed(r){return this.isOfSubType(r,gt,"named")}graphRefAll(r){return{type:gt,subType:"all",loc:r}}isGraphRefAll(r){return this.isOfSubType(r,gt,"all")}graphRefSpecific(r,n){return{type:gt,subType:"specific",graph:r,loc:n}}isGraphRefSpecific(r){return this.isOfSubType(r,gt,"specific")}}}function tf(e){return new Ja(e)}var Ja=class{input;constructor(t){this.input=t}call(t){return this.input=t(this.input),this}returns(){return this.input}};var Me="path";function rf(e){return class extends e{isPathPure(r){return this.isOfType(r,Me)}path(r,n,i){let s={type:Me,loc:i,items:n};if(r==="|"||r==="/")return{...s,subType:r};if((r==="?"||r==="*"||r==="+"||r==="^"&&this.isPathPure(n[0]))&&n.length===1)return{...s,subType:r,items:n};if(r==="^"&&n.length===1&&!this.isPathPure(n[0]))return{...s,subType:r,items:n};if(r==="!"&&n.length===1&&(this.isPathAlternativeLimited(n[0])||!this.isPathPure(n[0])||this.isPathNegatedElt(n[0])))return{...s,subType:r,items:n};throw new Error("Invalid path type")}isPathOfType(r,n){return this.isOfType(r,Me)&&n.includes(r.subType)}isPathChain(r){return this.isOfSubType(r,Me,"/")||this.isOfSubType(r,Me,"|")}isPathModified(r){return this.isOfSubType(r,Me,"?")||this.isOfSubType(r,Me,"*")||this.isOfSubType(r,Me,"+")||this.isOfSubType(r,Me,"^")}isPathNegatedElt(r){let n=r;return this.isOfSubType(r,Me,"^")&&Array.isArray(n.items)&&n.items.length===1&&n.items[0]!==null&&typeof n.items[0]=="object"&&!this.isPathPure(n.items[0])}isPathNegated(r){return this.isOfSubType(r,Me,"!")}isPathAlternativeLimited(r){let n=r;return this.isOfSubType(r,Me,"|")&&Array.isArray(n.items)&&n.items.every(i=>!this.isPathPure(i)||this.isPathNegatedElt(i))}}}var U="pattern";function nf(e){return class extends e{isPattern(r){return this.isOfType(r,U)}patternBgp(r,n){return{type:U,subType:"bgp",triples:r,loc:n}}isPatternBgp(r){return this.isOfSubType(r,U,"bgp")}patternGroup(r,n){return{type:U,subType:"group",patterns:r,loc:n}}isPatternGroup(r){return this.isOfSubType(r,U,"group")}patternGraph(r,n,i){return{type:U,subType:"graph",name:r,patterns:n,loc:i}}isPatternGraph(r){return this.isOfSubType(r,U,"graph")}patternOptional(r,n){return{type:U,subType:"optional",patterns:r,loc:n}}isPatternOptional(r){return this.isOfSubType(r,U,"optional")}patternValues(r,n,i){return{type:U,subType:"values",variables:r,values:n,loc:i}}isPatternValues(r){return this.isOfSubType(r,U,"values")}patternFilter(r,n){return{type:U,subType:"filter",expression:r,loc:n}}isPatternFilter(r){return this.isOfSubType(r,U,"filter")}patternBind(r,n,i){return{type:U,subType:"bind",expression:r,variable:n,loc:i}}isPatternBind(r){return this.isOfSubType(r,U,"bind")}patternUnion(r,n){return{type:U,subType:"union",patterns:r,loc:n}}isPatternUnion(r){return this.isOfSubType(r,U,"union")}patternMinus(r,n){return{type:U,subType:"minus",patterns:r,loc:n}}isPatternMinus(r){return this.isOfSubType(r,U,"minus")}patternService(r,n,i,s){return{type:U,subType:"service",silent:i,name:r,patterns:n,loc:s}}isPatternService(r){return this.isOfSubType(r,U,"service")}}}var ur="query";function sf(e){return class extends e{isQuery(r){return this.isOfType(r,ur)}isQuerySelect(r){return this.isOfSubType(r,ur,"select")}queryConstruct(r,n,i,s,a,o,c){return{type:"query",subType:"construct",context:n,template:i,where:s,solutionModifiers:a,datasets:o,values:c,loc:r}}isQueryConstruct(r){return this.isOfSubType(r,ur,"construct")}isQueryDescribe(r){return this.isOfSubType(r,ur,"describe")}isQueryAsk(r){return this.isOfSubType(r,ur,"ask")}querySelect(r,n){return{type:ur,subType:"select",...r,loc:n}}}}var Ot="solutionModifier";function af(e){return class extends e{isSolutionModifier(r){return this.isOfType(r,Ot)}solutionModifierHaving(r,n){return{type:Ot,subType:"having",having:r,loc:n}}isSolutionModifierHaving(r){return this.isOfSubType(r,Ot,"having")}solutionModifierOrder(r,n){return{type:Ot,subType:"order",orderDefs:r,loc:n}}isSolutionModifierOrder(r){return this.isOfSubType(r,Ot,"order")}solutionModifierLimitOffset(r,n,i){return{type:Ot,subType:"limitOffset",limit:r,offset:n,loc:i}}isSolutionModifierLimitOffset(r){return this.isOfSubType(r,Ot,"limitOffset")}solutionModifierGroup(r,n){return{type:"solutionModifier",subType:"group",groupings:r,loc:n}}isSolutionModifierGroup(r){return this.isOfSubType(r,Ot,"group")}}}var Vt="term";function of(e){return class extends e{__blankNodeCounter=0;resetBlankNodeCounter(){this.__blankNodeCounter=0}isTerm(r){return this.isOfType(r,"term")}termBlank(r,n){let i={type:"term",subType:"blankNode",loc:n};return r===void 0?{...i,label:`g_${this.__blankNodeCounter++}`}:{...i,label:`e_${r}`}}isTermBlank(r){return this.isOfSubType(r,Vt,"blankNode")}termLiteral(r,n,i){return{type:Vt,subType:"literal",value:n,langOrIri:i,loc:r}}isTermLiteral(r){return this.isOfSubType(r,Vt,"literal")}isTermLiteralLangStr(r){return this.isTermLiteral(r)&&typeof r.langOrIri=="string"}isTermLiteralStr(r){return this.isTermLiteral(r)&&typeof r.langOrIri>"u"}isTermLiteralTyped(r){let n=r;return this.isTermLiteral(r)&&typeof n.langOrIri=="object"&&n.langOrIri!==null&&this.isTermNamed(n.langOrIri)}termVariable(r,n){return{type:Vt,subType:"variable",value:r,loc:n}}isTermVariable(r){return this.isOfSubType(r,Vt,"variable")}termNamed(r,n,i){let s={type:Vt,subType:"namedNode",value:n,loc:r};return i===void 0?s:{...s,prefix:i}}isTermNamed(r){return this.isOfSubType(r,Vt,"namedNode")}isTermNamedPrefixed(r){let n=r;return this.isTermNamed(r)&&typeof n.prefix=="string"}}}var Ne="updateOperation";function cf(e){return class extends e{isUpdateOperation(r){return this.isOfType(r,Ne)}updateOperationLoad(r,n,i,s){return{type:Ne,subType:"load",silent:i,source:n,...s&&{destination:s},loc:r}}isUpdateOperationLoad(r){return this.isOfSubType(r,Ne,"load")}updateOperationClearDrop(r,n,i,s){return{type:"updateOperation",subType:r,silent:n,destination:i,loc:s}}updateOperationClear(r,n,i){return this.updateOperationClearDrop("clear",n,r,i)}isUpdateOperationClear(r){return this.isOfSubType(r,Ne,"clear")}updateOperationDrop(r,n,i){return this.updateOperationClearDrop("drop",n,r,i)}isUpdateOperationDrop(r){return this.isOfSubType(r,Ne,"drop")}updateOperationCreate(r,n,i){return{type:"updateOperation",subType:"create",silent:n,destination:r,loc:i}}isUpdateOperationCreate(r){return this.isOfSubType(r,Ne,"create")}updateOperationAddMoveCopy(r,n,i,s,a){return{type:"updateOperation",subType:r,silent:s,source:n,destination:i,loc:a}}updateOperationAdd(r,n,i,s){return this.updateOperationAddMoveCopy("add",r,n,i,s)}isUpdateOperationAdd(r){return this.isOfSubType(r,Ne,"add")}updateOperationMove(r,n,i,s){return this.updateOperationAddMoveCopy("move",r,n,i,s)}isUpdateOperationMove(r){return this.isOfSubType(r,Ne,"move")}updateOperationCopy(r,n,i,s){return this.updateOperationAddMoveCopy("copy",r,n,i,s)}isUpdateOperationCopy(r){return this.isOfSubType(r,Ne,"copy")}updateOperationInsDelDataWhere(r,n,i){return{type:"updateOperation",subType:r,data:n,loc:i}}updateOperationInsertData(r,n){return this.updateOperationInsDelDataWhere("insertdata",r,n)}isUpdateOperationInsertData(r){return this.isOfSubType(r,Ne,"insertdata")}updateOperationDeleteData(r,n){return this.updateOperationInsDelDataWhere("deletedata",r,n)}isUpdateOperationDeleteData(r){return this.isOfSubType(r,Ne,"deletedata")}updateOperationDeleteWhere(r,n){return this.updateOperationInsDelDataWhere("deletewhere",r,n)}isUpdateOperationDeleteWhere(r){return this.isOfSubType(r,Ne,"deletewhere")}updateOperationModify(r,n,i,s,a,o){return{type:"updateOperation",subType:"modify",insert:n??[],delete:i??[],graph:o,where:s,from:a,loc:r}}isUpdateOperationModify(r){return this.isOfSubType(r,Ne,"modify")}}}var Kt=class extends tf(Bt).call(Jh).call(Uh).call(ef).call(rf).call(nf).call(sf).call(af).call(of).call(cf).returns(){alwaysSparql11(t){return!0}isPath(t){return this.isPathPure(t)||this.isTermNamed(t)}isExpression(t){return this.isExpressionPure(t)||this.isTermNamed(t)||this.isTermVariable(t)||this.isTermLiteral(t)}graphNodeIdentifier(t){return t.type==="tripleCollection"?t.identifier:t}triple(t,r,n,i){return{type:"triple",subject:t,predicate:r,object:n,loc:i??this.sourceLocation(t,r,n)}}isTriple(t){return this.isOfType(t,"triple")}datasetClauses(t,r){return{type:"datasetClauses",clauses:t,loc:r}}isDatasetClauses(t){return this.isOfType(t,"datasetClauses")}wildcard(t){return{type:"wildcard",loc:t}}isWildcard(t){return this.isOfType(t,"wildcard")}isTripleCollection(t){return this.isOfType(t,"tripleCollection")}tripleCollectionBlankNodeProperties(t,r,n){return{type:"tripleCollection",subType:"blankNodeProperties",identifier:t,triples:r,loc:n}}isTripleCollectionBlankNodeProperties(t){return this.isOfSubType(t,"tripleCollection","blankNodeProperties")}tripleCollectionList(t,r,n){return{type:"tripleCollection",subType:"list",identifier:t,triples:r,loc:n}}isTripleCollectionList(t){return this.isOfSubType(t,"tripleCollection","list")}graphQuads(t,r,n){return{type:"graph",graph:t,triples:r,loc:n}}isGraphQuads(t){return super.isOfType(t,"graph")}isUpdate(t){return super.isOfType(t,"update")}};function lf(e){let t=e.replaceAll(/\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{8})/gu,(r,n,i)=>{if(n){let o=Number.parseInt(n,16);return String.fromCodePoint(o)}let s=Number.parseInt(i,16);if(s<65535)return String.fromCodePoint(s);let a=s-65536;return String.fromCodePoint(55296+(a>>10),56320+(a&1023))});if(/[\uD800-\uDBFF](?:[^\uDC00-\uDFFF]|$)/u.test(t))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint");return t}var re;(function(e){e.BOOLEAN="http://www.w3.org/2001/XMLSchema#boolean",e.INTEGER="http://www.w3.org/2001/XMLSchema#integer",e.DECIMAL="http://www.w3.org/2001/XMLSchema#decimal",e.DOUBLE="http://www.w3.org/2001/XMLSchema#double",e.STRING="http://www.w3.org/2001/XMLSchema#string",e.FIRST="http://www.w3.org/1999/02/22-rdf-syntax-ns#first",e.REST="http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",e.NIL="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil",e.TYPE="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"})(re||(re={}));var Ji=class extends zr{};var w=new Kt,Ui=new Ji;function eo(e){if(w.isExpressionAggregate(e))return[e];if(w.isExpressionOperator(e)){let t=[];for(let r of e.args)t.push(...eo(r));return t}return[]}function Ua(e){return w.isTerm(e)&&w.isTermVariable(e)?e.value:w.isExpression(e)?w.isExpressionAggregate(e)&&w.isTermVariable(e.expression[0])?e.expression[0].value:void 0:e.variable.value}function uf(e,t){if(w.isExpressionOperator(e))for(let r of e.args)uf(r,t);else w.isTerm(e)&&w.isTermVariable(e)&&t.add(e.value)}function pf(e){if(e.variables.length===1&&w.isWildcard(e.variables[0])){if(e.solutionModifiers.group!==void 0)throw new Error("GROUP BY not allowed with wildcard");return}let t=e.variables,r=t.flatMap(s=>w.isTerm(s)?[]:eo(s.expression)).some(s=>s.aggregation==="count"&&!s.expression.some(a=>w.isWildcard(a))),n=e.solutionModifiers.group;if(r||n){for(let s of t)if(w.isTerm(s)){if(!n||!n.groupings.map(a=>Ua(a)).includes(Ua(s)))throw new Error("Variable not allowed in projection")}else if(eo(s.expression).length===0){let a=new Set;uf(s.expression,a);for(let o of a)if(!n||!n.groupings.map(c=>Ua(c)).includes(o))throw new Error(`Use of ungrouped variable in projection of operation (?${o})`)}}let i=e.where.patterns.filter(s=>s.type==="query");if(i.length>0){let s=new Set;for(let c of t)"variable"in c&&s.add(c.variable.value);let a=i.flatMap(c=>c.variables).map(c=>w.isTerm(c)?c.value:w.isWildcard(c)?"*":c.variable.value),o=new Set(a);for(let c of s)if(o.has(c))throw new Error(`Target id of 'AS' (?${c}) already used in subquery`)}}function hf(e,t){function r(n){hf(n,t)}if(e!==void 0)if(Array.isArray(e))for(let n of e)r(n);else if(w.isQuery(e))w.isQuerySelect(e)||w.isQueryDescribe(e)?r([...e.variables.some(n=>w.isWildcard(n))?[e.where]:e.variables,e.solutionModifiers.group,e.values]):r(e.solutionModifiers.group);else if(w.isTriple(e))r([e.subject,e.predicate,e.object]);else if(w.isPathPure(e))r(e.items);else if(w.isTripleCollection(e))r([e.identifier,...e.triples]);else if(w.isSolutionModifierGroup(e))r(e.groupings.filter(n=>"variable"in n).map(n=>n.variable));else if(w.isSolutionModifierHaving(e))r(e.having);else if(w.isSolutionModifierOrder(e))r(e.orderDefs.map(n=>n.expression));else if(w.isPatternValues(e))for(let n of Object.keys(e.values.at(0)??{}))t.add(n);else w.isPatternBgp(e)?r(e.triples):w.isPatternGroup(e)||w.isPatternUnion(e)||w.isPatternOptional(e)?r(e.patterns):w.isPatternService(e)||w.isPatternGraph(e)?r([e.name,...e.patterns]):w.isPatternBind(e)?r(e.variable):w.isTermVariable(e)&&t.add(e.value)}function ff(e){for(let[r,n]of e.entries())if(w.isPatternBind(n)&&r>0&&w.isPatternBgp(e[r-1])){let i=e[r-1],s=[];if(Ui.visitNodeSpecific(i,{},{term:{variable:{visitor:a=>{s.push(a)}}}}),s.some(a=>a.value===n.variable.value))throw new Error(`Variable used to bind is already bound (?${n.variable.value})`)}let t=new Set;for(let r of e)if(w.isPatternBind(r)){if(t.has(r.variable.value))throw new Error(`Variable used to bind is already bound (?${r.variable.value})`)}else hf(r,t)}function es(e){let t=new Set;for(let r of e.updates){if(!r.operation)continue;let n=r.operation;if(n.subType==="insertdata"){let i=new Set;Ui.visitNodeSpecific(n,{},{term:{blankNode:{visitor:s=>{if(i.add(s.label),t.has(s.label))throw new Error("Detected reuse blank node across different INSERT DATA clauses")}}}});for(let s of i)t.add(s)}}}function df(e){let t=new Map,r=[{}],n=()=>r.at(-1);function i(a){let o=new Set;return Ui.visitNodeSpecific(a,{},{term:{blankNode:{visitor:c=>{o.add(c.label)}}}}),o}let s={preVisitor:()=>(r.push({}),{}),visitor:()=>{r.pop(),r[r.length-1]={}}};Ui.visitNodeSpecific(e,{query:{preVisitor:()=>({continue:!1})},pattern:s},{pattern:{bgp:{preVisitor:a=>{let o=n();for(let c of i(a)){let l=t.get(c);if(l!==void 0&&l!==o)throw new Error(`Detected reuse of blank node across two different basic graph patterns (_:${c.replace(/^[eg]_/u,"")})`);t.set(c,o)}return{continue:!1}},visitor:()=>{}},filter:{preVisitor:()=>(r.push({}),{}),visitor:()=>{r.pop()}}}})}var JO={" ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f",'"':'\\"',"\\":"\\\\"};function Ur(e){return`"${e.replaceAll(/["\\\t\n\r\b\f]/gu,r=>JO[r])}"`}var St={name:"rdfLiteral",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n,OR:i})=>s=>{let a=t(ns);return n(()=>i([{ALT:()=>{let o=r(F.langTag);return e(()=>s.astFactory.termLiteral(s.astFactory.sourceLocation(a,o),a.value,o.image.slice(1).toLowerCase()))}},{ALT:()=>{r(g.hathat);let o=t($);return e(()=>s.astFactory.termLiteral(s.astFactory.sourceLocation(a,o),a.value,o))}}]))??a},gImpl:({SUBRULE:e,PRINT:t,PRINT_WORD:r})=>(n,{astFactory:i})=>{!n.langOrIri||typeof n.langOrIri=="string"?(i.printFilter(n,()=>{r(""),t(Ur(n.value))}),typeof n.langOrIri=="string"&&i.printFilter(n,()=>t("@",n.langOrIri))):i.isSourceLocationNoMaterialize(n.langOrIri.loc)?i.printFilter(n,()=>{r(n.value)}):(i.printFilter(n,()=>{r(""),t(Ur(n.value),"^^")}),e($,n.langOrIri))}},Ht={name:"numericLiteral",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(mf)},{ALT:()=>e(ts)},{ALT:()=>e(rs)}])},mf={name:"numericLiteralUnsigned",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>[t(F.integer),re.INTEGER]},{ALT:()=>[t(F.decimal),re.DECIMAL]},{ALT:()=>[t(F.double),re.DOUBLE]}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i[0]),i[0].image,n.astFactory.termNamed(n.astFactory.sourceLocation(),i[1])))}},ts={name:"numericLiteralPositive",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>[t(F.integerPositive),re.INTEGER]},{ALT:()=>[t(F.decimalPositive),re.DECIMAL]},{ALT:()=>[t(F.doublePositive),re.DOUBLE]}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i[0]),i[0].image,n.astFactory.termNamed(n.astFactory.sourceLocation(),i[1])))}},rs={name:"numericLiteralNegative",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>[t(F.integerNegative),re.INTEGER]},{ALT:()=>[t(F.decimalNegative),re.DECIMAL]},{ALT:()=>[t(F.doubleNegative),re.DOUBLE]}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i[0]),i[0].image,n.astFactory.termNamed(n.astFactory.sourceLocation(),i[1])))}},Wt={name:"booleanLiteral",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>t(Yi)},{ALT:()=>t(Xi)}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i),i.image.toLowerCase(),n.astFactory.termNamed(n.astFactory.sourceLocation(),re.BOOLEAN)))}},ns={name:"string",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>{let s=t(F.stringLiteral1);return[s,s.image.slice(1,-1)]}},{ALT:()=>{let s=t(F.stringLiteral2);return[s,s.image.slice(1,-1)]}},{ALT:()=>{let s=t(F.stringLiteralLong1);return[s,s.image.slice(3,-3)]}},{ALT:()=>{let s=t(F.stringLiteralLong2);return[s,s.image.slice(3,-3)]}}]);return e(()=>{let s=n.astFactory,a=i[1].replaceAll(/\\([tnrbf"'\\])/gu,(o,c)=>{switch(c){case"t":return" ";case"n":return` +`;case"r":return"\r";case"b":return"\b";case"f":return"\f";default:return c}});return s.termLiteral(s.sourceLocation(i[0]),a)})}},$={name:"iri",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(pr)},{ALT:()=>e(to)}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>r.isTermNamedPrefixed(t)?e(to,t):e(pr,t)},pr={name:"iriFull",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(F.iriRef);return e(()=>r.astFactory.termNamed(r.astFactory.sourceLocation(n),n.image.slice(1,-1)))},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e("<",t.value,">"))}},to={name:"prefixedName",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{function i(s){if(!n.skipValidation&&n.prefixes[s]===void 0)throw new Error(`Unknown prefix: ${s}`)}return r([{ALT:()=>{let s=t(F.pNameLn);return e(()=>{let a=s.image.indexOf(":"),o=s.image.slice(0,a),c=s.image.slice(a+1);return i(o),n.astFactory.termNamed(n.astFactory.sourceLocation(s),c,o)})}},{ALT:()=>{let s=t(F.pNameNs);return e(()=>{let a=s.image.slice(0,-1);return i(a),n.astFactory.termNamed(n.astFactory.sourceLocation(s),"",a)})}}])},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e(t.prefix,":",t.value))}},UO=Symbol("canCreateBlankNodes"),is={name:"blankNode",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>{let s=t(F.blankNodeLabel);return e(()=>n.astFactory.termBlank(s.image.slice(2),n.astFactory.sourceLocation(s)))}},{ALT:()=>{let s=t(F.anon);return e(()=>n.astFactory.termBlank(void 0,n.astFactory.sourceLocation(s)))}}]);return e(()=>{if(!n.parseMode.has("canCreateBlankNodes"))throw new Error("Blank nodes are not allowed in this context")}),i},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e("_:",t.label.replace(/^e_/u,"")))}},zt={name:"VerbA",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(lr);return e(()=>r.astFactory.termNamed(r.astFactory.sourceLocation(n),re.TYPE,void 0))}};var De={name:"prologue",impl:({SUBRULE:e,MANY:t,OR:r})=>()=>{let n=[];return t(()=>r([{ALT:()=>n.push(e(ro))},{ALT:()=>n.push(e(no))}])),n},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{for(let n of t)r.isContextDefinitionBase(n)?e(ro,n):e(no,n)}},ro={name:"baseDecl",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(li),s=r(pr);return e(()=>n.astFactory.contextDefinitionBase(n.astFactory.sourceLocation(i,s),s))},gImpl:({SUBRULE:e,PRINT_ON_EMPTY:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>t("BASE ")),e($,n.value),i.printFilter(n,()=>r())}},no={name:"prefixDecl",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(ui),s=t(F.pNameNs).image.slice(0,-1),a=r(pr);return e(()=>(n.prefixes[s]=a.value,n.astFactory.contextDefinitionPrefix(n.astFactory.sourceLocation(i,a),s,a)))},gImpl:({SUBRULE:e,PRINT_ON_EMPTY:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{t("PREFIX ",`${n.key}: `)}),e($,n.value),i.printFilter(n,()=>r())}},so={name:"verb",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(Tt)},{ALT:()=>e(zt)}])},ue={name:"varOrTerm",impl:({SUBRULE:e,OR:t})=>r=>t([{GATE:()=>r.parseMode.has("canParseVars"),ALT:()=>e(W)},{ALT:()=>e(io)}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>r.isTermVariable(t)?e(W,t):e(io,t)},Tt={name:"varOrIri",impl:({SUBRULE:e,OR:t})=>r=>t([{GATE:()=>r.parseMode.has("canParseVars"),ALT:()=>e(W)},{ALT:()=>e($)}])},W={name:"var",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>t(F.var1)},{ALT:()=>t(F.var2)}]);return e(()=>n.astFactory.termVariable(i.image.slice(1),n.astFactory.sourceLocation(i)))},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e(`?${t.value}`))}},io={name:"graphTerm",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR:n})=>i=>n([{ALT:()=>t($)},{ALT:()=>t(St)},{ALT:()=>t(Ht)},{ALT:()=>t(Wt)},{GATE:()=>i.parseMode.has("canCreateBlankNodes"),ALT:()=>t(is)},{ALT:()=>{let s=r(F.nil);return e(()=>i.astFactory.termNamed(i.astFactory.sourceLocation(s),re.NIL))}}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{r.isTermNamed(t)?e($,t):r.isTermLiteral(t)?e(St,t):e(is,t)}};function ao(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,CONSUME:i,OR:s})=>a=>{let o=i(t);return s([{ALT:()=>{let c=n(Tf);return r(()=>a.astFactory.wrap({clauseType:"default",value:c},a.astFactory.sourceLocation(o,c)))}},{ALT:()=>{let c=n(vf);return r(()=>a.astFactory.wrap({clauseType:"named",value:c.val},a.astFactory.sourceLocation(o,c)))}}])}}}var gf=ao("datasetClause",gi),Tf={name:"defaultGraphClause",impl:({SUBRULE:e})=>()=>e(co)},yf=ao("usingClause",$i);function oo(e,t,r){return{name:e,impl:({ACTION:n,MANY:i,SUBRULE:s})=>a=>{let o=[];return i(()=>{let c=s(t);o.push(c)}),n(()=>a.astFactory.datasetClauses(o.map(c=>c.val),a.astFactory.sourceLocation(...o)))},gImpl:({SUBRULE:n,PRINT_WORD:i})=>(s,{astFactory:a})=>{for(let o of s.clauses)a.printFilter(s,()=>i(r)),o.clauseType==="named"&&a.printFilter(s,()=>i("NAMED")),n($,o.value)}}}var Be=oo("datasetClauses",gf,"FROM"),ss=oo("usingClauses",yf,"USING"),vf={name:"namedGraphClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ve.named),s=t(co);return e(()=>n.astFactory.wrap(s,n.astFactory.sourceLocation(i,s)))}},co={name:"sourceSelector",impl:({SUBRULE:e})=>()=>e($)};function G(e){return{name:ee(e.name),impl:({ACTION:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(e);n(g.LParen);let a=r(R),o=n(g.RParen);return t(()=>i.astFactory.expressionOperation(s.image,[a],i.astFactory.sourceLocation(s,o)))}}}function Qe(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i})=>s=>{let a=r(e);r(g.LParen);let o=n(R);r(g.comma);let c=i(R),l=r(g.RParen);return t(()=>s.astFactory.expressionOperation(a.image,[o,c],s.astFactory.sourceLocation(a,l)))}}}function lo(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,CONSUME1:n,CONSUME2:i,SUBRULE1:s,SUBRULE2:a,SUBRULE3:o})=>c=>{let l=r(e);r(g.LParen);let p=s(R);n(g.comma);let h=a(R);i(g.comma);let d=o(R),m=r(g.RParen);return t(()=>c.astFactory.expressionOperation(l.image,[p,h,d],c.astFactory.sourceLocation(l,m)))}}}function uo(e){return{name:ee(e.name),impl:({ACTION:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(e);n(g.LParen);let a=r(W),o=n(g.RParen);return t(()=>i.astFactory.expressionOperation(s.image,[a],i.astFactory.sourceLocation(s,o)))}}}function po(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,OR:n,SUBRULE:i})=>s=>{let a=r(e);return n([{ALT:()=>{r(g.LParen);let o=i(R),c=r(g.RParen);return t(()=>s.astFactory.expressionOperation(a.image,[o],s.astFactory.sourceLocation(a,c)))}},{ALT:()=>{let o=r(F.nil);return t(()=>s.astFactory.expressionOperation(a.image,[],s.astFactory.sourceLocation(a,o)))}}])}}}function hr(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r})=>n=>{let i=r(e),s=r(F.nil);return t(()=>n.astFactory.expressionOperation(i.image,[],n.astFactory.sourceLocation(i,s)))}}}function as(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE:n})=>i=>{let s=r(e),a=n(ls);return t(()=>i.astFactory.expressionOperation(s.image,a.val,i.astFactory.sourceLocation(s,a)))}}}function os(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,SUBRULE3:s,CONSUME1:a,OPTION:o,CONSUME2:c})=>l=>{let p=r(e);r(g.LParen);let h=n(R);a(g.comma);let d=i(R),m=o(()=>(c(g.comma),s(R))),A=r(g.RParen);return t(()=>l.astFactory.expressionOperation(p.image,m?[h,d,m]:[h,d],l.astFactory.sourceLocation(p,A)))}}}function ho(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,SUBRULE3:s,SUBRULE4:a,CONSUME1:o,OPTION:c,CONSUME2:l,CONSUME3:p})=>h=>{let d=r(e);r(g.LParen);let m=n(R);o(g.comma);let A=i(R);l(g.comma);let b=s(R),y=c(()=>(p(g.comma),a(R))),v=r(g.RParen);return t(()=>h.astFactory.expressionOperation(d.image,y?[m,A,b,y]:[m,A,b],h.astFactory.sourceLocation(d,v)))}}}function cs(e){return{name:ee(e.name),impl:({ACTION:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(e),a=r(Y);return t(()=>i.astFactory.expressionPatternOperation(s.image,a,i.astFactory.sourceLocation(s,a)))}}}function qt(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE:n,OPTION:i})=>s=>{let a=r(e);r(g.LParen);let o=i(()=>r(Xe)),c=n(R),l=r(g.RParen);return t(()=>s.astFactory.aggregate(a.image,o!==void 0,c,void 0,s.astFactory.sourceLocation(a,l)))}}}var Af=G(E.str),bf=G(E.lang),xf=Qe(E.langmatches),If=G(E.datatype),Ef=uo(E.bound),Lf=G(E.iri),_f=G(E.uri),Of=po(E.bnode),Sf=hr(E.rand),Nf=G(E.abs),Pf=G(E.ceil),kf=G(E.floor),Rf=G(E.round),Ff=as(E.concat),wf=G(E.strlen),Cf=G(E.ucase),Mf=G(E.lcase),Df=G(E.encode_for_uri),Gf=Qe(E.contains),$f=Qe(E.strstarts),jf=Qe(E.strends),Vf=Qe(E.strbefore),Kf=Qe(E.strafter),Hf=G(E.year),Wf=G(E.month),zf=G(E.day),qf=G(E.hours),Yf=G(E.minutes),Xf=G(E.seconds),Bf=G(E.timezone),Qf=G(E.tz),Zf=hr(E.now),Jf=hr(E.uuid),Uf=hr(E.struuid),ed=G(E.md5),td=G(E.sha1),rd=G(E.sha256),nd=G(E.sha384),id=G(E.sha512),sd=as(E.coalesce),ad=lo(E.if_),od=Qe(E.strlang),cd=Qe(E.strdt),ld=Qe(E.sameterm),ud=G(E.isiri),pd=G(E.isuri),hd=G(E.isblank),fd=G(E.isliteral),dd=G(E.isnumeric);function md(e){return[{ALT:()=>e(us)},{ALT:()=>e(Af)},{ALT:()=>e(bf)},{ALT:()=>e(xf)},{ALT:()=>e(If)},{ALT:()=>e(Ef)},{ALT:()=>e(Lf)},{ALT:()=>e(_f)},{ALT:()=>e(Of)},{ALT:()=>e(Sf)},{ALT:()=>e(Nf)},{ALT:()=>e(Pf)},{ALT:()=>e(kf)},{ALT:()=>e(Rf)},{ALT:()=>e(Ff)},{ALT:()=>e(Td)},{ALT:()=>e(wf)},{ALT:()=>e(yd)},{ALT:()=>e(Cf)},{ALT:()=>e(Mf)},{ALT:()=>e(Df)},{ALT:()=>e(Gf)},{ALT:()=>e($f)},{ALT:()=>e(jf)},{ALT:()=>e(Vf)},{ALT:()=>e(Kf)},{ALT:()=>e(Hf)},{ALT:()=>e(Wf)},{ALT:()=>e(zf)},{ALT:()=>e(qf)},{ALT:()=>e(Yf)},{ALT:()=>e(Xf)},{ALT:()=>e(Bf)},{ALT:()=>e(Qf)},{ALT:()=>e(Zf)},{ALT:()=>e(Jf)},{ALT:()=>e(Uf)},{ALT:()=>e(ed)},{ALT:()=>e(td)},{ALT:()=>e(rd)},{ALT:()=>e(nd)},{ALT:()=>e(id)},{ALT:()=>e(sd)},{ALT:()=>e(ad)},{ALT:()=>e(od)},{ALT:()=>e(cd)},{ALT:()=>e(ld)},{ALT:()=>e(ud)},{ALT:()=>e(pd)},{ALT:()=>e(hd)},{ALT:()=>e(fd)},{ALT:()=>e(dd)},{ALT:()=>e(gd)},{ALT:()=>e(vd)},{ALT:()=>e(Ad)}]}var yt={name:"builtInCall",impl:({OR:e,SUBRULE:t,cache:r})=>()=>{let n=r.get(yt);if(n)return e(n);let i=md(t);return r.set(yt,i),e(i)}},gd=os(E.regex),Td=os(E.substr),yd=ho(E.replace),vd=cs(E.exists),Ad=cs(E.notexists),bd={name:ee(E.count.name),impl:({ACTION:e,CONSUME:t,SUBRULE:r,OR:n,OPTION:i})=>s=>{let a=t(E.count);t(g.LParen);let o=i(()=>t(Xe)),c=n([{ALT:()=>{let p=t(g.star);return e(()=>s.astFactory.wildcard(s.astFactory.sourceLocation(p)))}},{ALT:()=>r(R)}]),l=t(g.RParen);return e(()=>{let p=s.astFactory;return s.astFactory.isWildcard(c),p.aggregate(a.image,!!o,c,void 0,s.astFactory.sourceLocation(a,l))})}},xd=qt(E.sum),Id=qt(E.min),Ed=qt(E.max),Ld=qt(E.avg),_d=qt(E.sample),Od={name:ee(E.groupConcat.name),impl:({ACTION:e,CONSUME:t,OPTION1:r,SUBRULE:n,OPTION2:i})=>s=>{let a=t(E.groupConcat);t(g.LParen);let o=r(()=>t(Xe)),c=n(R),l=i(()=>(t(g.semi),t(Zi),t(g.equal),n(ns))),p=t(g.RParen);return e(()=>{let h=s.astFactory;return h.aggregate(a.image,!!o,c,l?.value??" ",h.sourceLocation(a,p))})}},us={name:"aggregate",impl:({ACTION:e,SUBRULE:t,OR:r})=>n=>{let i=e(()=>n.parseMode.has("inAggregate"));e(()=>n.parseMode.add("inAggregate"));let s=r([{ALT:()=>t(bd)},{ALT:()=>t(xd)},{ALT:()=>t(Id)},{ALT:()=>t(Ed)},{ALT:()=>t(Ld)},{ALT:()=>t(_d)},{ALT:()=>t(Od)}]);return e(()=>!i&&n.parseMode.delete("inAggregate")),e(()=>{if(!n.parseMode.has("canParseAggregate"))throw new Error("Aggregates are only allowed in SELECT, HAVING, and ORDER BY clauses.");if(n.parseMode.has("inAggregate"))throw new Error("An aggregate function is not allowed within an aggregate function.")}),s},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t(r.aggregation.toUpperCase(),"("),r.distinct&&t("DISTINCT")});let i=r.expression[0];n.isWildcard(i)?n.printFilter(r,()=>t("*")):e(R,i),n.isExpressionAggregateSeparator(r)&&n.printFilter(r,()=>t(";","SEPARATOR","=",Ur(r.separator))),n.printFilter(r,()=>t(")"))}};var hs={name:"path",impl:({SUBRULE:e})=>()=>e(Pd)},vt={name:"path",gImpl:({PRINT:e,SUBRULE:t})=>(r,{astFactory:n},i=!0)=>{if(n.isTerm(r)&&n.isTermNamed(r))t($,r);else{switch(n.printFilter(r,()=>i&&e("(")),r.subType){case"|":case"/":{let[s,...a]=r.items;t(vt,s,i);for(let o of a)n.printFilter(r,()=>e(r.subType)),t(vt,o,i);break}case"^":n.printFilter(r,()=>e("^")),t(vt,r.items[0],i);break;case"?":case"*":case"+":t(vt,r.items[0],i),n.printFilter(r,()=>e(r.subType));break;case"!":n.printFilter(r,()=>e("!")),n.printFilter(r,()=>e("(")),t(vt,r.items[0],!1),n.printFilter(r,()=>e(")"));break}n.printFilter(r,()=>i&&e(")"))}}};function mo(e,t,r,n){return{name:e,impl:({ACTION:i,CONSUME:s,SUBRULE1:a,SUBRULE2:o,MANY:c})=>l=>{let p=a(n),h=p,d=[];return c(()=>{s(t),h=o(n),d.push(h)}),i(()=>d.length===0?p:l.astFactory.path(r,[p,...d],l.astFactory.sourceLocation(p,h)))}}}var Sd={name:"pathEltOrInverse",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR:i})=>s=>i([{ALT:()=>r(fo)},{ALT:()=>{let a=t(g.hat),o=n(fo);return e(()=>s.astFactory.path("^",[o],s.astFactory.sourceLocation(a,o)))}}])},Nd=mo("pathSequence",g.slash,"/",Sd),Pd=mo("pathAlternative",g.pipe,"|",Nd),fo={name:"pathElt",impl:({ACTION:e,SUBRULE:t,OPTION:r})=>n=>{let i=t(Rd),s=r(()=>t(kd));return e(()=>s===void 0?i:n.astFactory.path(s.image,[i],n.astFactory.sourceLocation(i,s)))}},kd={name:"pathMod",impl:({CONSUME:e,OR:t})=>()=>t([{ALT:()=>e(g.question)},{ALT:()=>e(g.star)},{ALT:()=>e(g.opPlus)}])},Rd={name:"pathPrimary",impl:({SUBRULE:e,CONSUME:t,OR:r})=>()=>r([{ALT:()=>e($)},{ALT:()=>e(zt)},{ALT:()=>e(Fd)},{ALT:()=>{t(g.LParen);let n=e(hs);return t(g.RParen),n}}])},Fd={name:"pathNegatedPropertySet",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,SUBRULE3:i,OR:s,MANY:a})=>o=>{let c=t(g.exclamation);return s([{ALT:()=>{let l=r(ps);return e(()=>o.astFactory.path("!",[l],o.astFactory.sourceLocation(c,l)))}},{ALT:()=>{let l=t(g.LParen),p=n(ps),h=[];a(()=>{t(g.pipe);let m=i(ps);h.push(m)});let d=t(g.RParen);return e(()=>{let m=o.astFactory;return h.length===0?m.path("!",[p],m.sourceLocation(c,d)):m.path("!",[m.path("|",[p,...h],m.sourceLocation(l,d))],m.sourceLocation(c,d))})}}])}},ps={name:"pathOneInPropertySet",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR1:i,OR2:s})=>a=>i([{ALT:()=>r($)},{ALT:()=>r(zt)},{ALT:()=>{let o=t(g.hat),c=s([{ALT:()=>n($)},{ALT:()=>n(zt)}]);return e(()=>a.astFactory.path("^",[c],a.astFactory.sourceLocation(o,c)))}}])};function wd(e){return({ACTION:t,AT_LEAST_ONE:r,SUBRULE:n,CONSUME:i,OPTION:s})=>a=>{let o=[],c=!0,l;return r({GATE:()=>c,DEF:()=>{c=!1;let p=n(e);t(()=>{o.push(...p)}),s(()=>{l=i(g.dot),c=!0})}}),t(()=>a.astFactory.patternBgp(o,a.astFactory.sourceLocation(...o,l)))}}var ot={name:"triplesBlock",impl:e=>t=>wd(Dd)(e)(t),gImpl:({SUBRULE:e,PRINT_WORD:t,HANDLE_LOC:r,NEW_LINE:n})=>(i,{astFactory:s})=>{for(let[a,o]of i.triples.entries())r(o,()=>{let c=i.triples.at(a+1);s.isTripleCollection(o)?(e(at,o),s.printFilter(o,()=>{t("."),n()})):(e(at,o.subject),s.printFilter(o,()=>t("")),s.isTerm(o.predicate)&&s.isTermVariable(o.predicate)?e(ue,o.predicate):e(vt,o.predicate,void 0),s.printFilter(o,()=>t("")),e(at,o.object),c===void 0||s.isTripleCollection(c)||!s.isSourceLocationNoMaterialize(c.subject.loc)?s.printFilter(i,()=>{t("."),n()}):s.isSourceLocationNoMaterialize(c.predicate.loc)?s.printFilter(i,()=>t(",")):s.printFilter(i,()=>{t(";"),n()}))})}};function Cd(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,OR:i})=>s=>i([{ALT:()=>{let a=n(ue),o=n(t?ds:fs,r(()=>s.astFactory.dematerialized(a)));return r(()=>(o[0].subject=a,o[0].loc=s.astFactory.sourceLocation(a,o[0]),o))}},{ALT:()=>{let a=n(t?vo:yo),o=n(t?jd:$d,r(()=>s.astFactory.graphNodeIdentifier(a)));return r(()=>o.length===0?[a]:(o[0].subject=a,o[0].loc=s.astFactory.sourceLocation(a,o[0]),o))}}])}}var Md=Cd("triplesSameSubject",!1),Dd=Cd("triplesSameSubjectPath",!0),Yt={name:"triplesTemplate",impl:wd(Md)};function Gd(e,t){return{name:e,impl:({SUBRULE:r,OPTION:n})=>(i,s)=>n(()=>r(t?ds:fs,s))??[]}}var $d=Gd("propertyList",!1),jd=Gd("propertyListPath",!0);function Vd(e,t){return{name:e,impl:({ACTION:r,CONSUME:n,AT_LEAST_ONE:i,SUBRULE1:s,MANY2:a,OR1:o})=>(c,l)=>{let p=[],h=!0;return i({GATE:()=>h,DEF:()=>{h=!1;let d=t?o([{ALT:()=>s(Kd)},{ALT:()=>s(Hd)}]):s(so),m=s(t?qd:zd,l,d);a(()=>{n(g.semi),h=!0}),r(()=>{p.push(...m)})}}),p}}}var fs=Vd("propertyListNotEmpty",!1),ds=Vd("propertyListPathNotEmpty",!0),Kd={name:"verbPath",impl:({SUBRULE:e})=>()=>e(hs)},Hd={name:"verbSimple",impl:({SUBRULE:e})=>()=>e(W)};function Wd(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,AT_LEAST_ONE_SEP:i})=>(s,a,o)=>{let c=[];return i({SEP:g.comma,DEF:()=>{let l=n(t?Bd:Xd,a,o);r(()=>{c.push(l)})}}),c}}}var zd=Wd("objectList",!1),qd=Wd("objectListPath",!0);function Yd(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n})=>(i,s,a)=>{let o=n(t?at:Ao);return r(()=>i.astFactory.triple(s,a,o))}}}var Xd=Yd("object",!1),Bd=Yd("objectPath",!0);function Qd(e,t){return{name:e,impl:({ACTION:r,AT_LEAST_ONE:n,SUBRULE:i,CONSUME:s})=>a=>{let o=[],c=s(g.LParen);n(()=>{o.push(i(t?at:Ao))});let l=s(g.RParen);return r(()=>{let p=a.astFactory,h=[],d=p.termNamed(p.sourceLocation(),re.FIRST,void 0),m=p.termNamed(p.sourceLocation(),re.REST,void 0),A=p.termNamed(p.sourceLocation(),re.NIL,void 0),b=p.termBlank(void 0,p.sourceLocation()),y=b;for(let[v,x]of o.entries()){let T=v===o.length-1,I=p.triple(y,d,x);if(h.push(I),T){let S=p.triple(y,m,A);h.push(S)}else{let S=p.termBlank(void 0,p.sourceLocation()),C=p.triple(y,m,S);h.push(C),y=S}}return p.tripleCollectionList(b,h,p.sourceLocation(c,l))})},gImpl:({SUBRULE:r,PRINT_WORD:n})=>(i,{astFactory:s})=>{s.printFilter(i,()=>n("("));for(let[a,o]of i.triples.entries())a%2===0&&(s.printFilter(i,()=>n("")),r(at,o.object));s.printFilter(i,()=>n(")"))}}}var Zd=Qd("collection",!1),go=Qd("collectionPath",!0);function Jd(e,t){return{name:e,impl:({SUBRULE:r,OR:n})=>()=>n([{ALT:()=>r(t?go:Zd)},{ALT:()=>r(t?To:em)}]),gImpl:({SUBRULE:r})=>n=>n.subType==="list"?r(go,n):r(To,n)}}var yo=Jd("triplesNode",!1),vo=Jd("triplesNodePath",!0);function Ud(e,t){let r=t?ds:fs;return{name:e,impl:({ACTION:n,SUBRULE:i,CONSUME:s})=>a=>{let o=s(g.LSquare),c=n(()=>a.astFactory.termBlank(void 0,a.astFactory.sourceLocation())),l=i(r,c),p=s(g.RSquare);return n(()=>a.astFactory.tripleCollectionBlankNodeProperties(c,l,a.astFactory.sourceLocation(o,p)))},gImpl:({SUBRULE:n,PRINT:i,PRINT_WORD:s,HANDLE_LOC:a,PRINT_ON_EMPTY:o,NEW_LINE:c})=>(l,p)=>{let{astFactory:h,indentInc:d}=p;h.printFilter(l,()=>{p[H]+=d,i("["),c()});for(let m of l.triples)a(m,()=>{h.isTerm(m.predicate)&&h.isTermVariable(m.predicate)?n(ue,m.predicate):n(vt,m.predicate,void 0),h.printFilter(m,()=>s("")),n(at,m.object),h.printFilter(l,()=>{s(";"),c()})});h.printFilter(l,()=>{p[H]-=d,o("]")})}}}var em=Ud("blankNodePropertyList",!1),To=Ud("blankNodePropertyListPath",!0);function tm(e,t){let r=t?vo:yo;return{name:e,impl:({SUBRULE:n,OR:i})=>s=>i([{ALT:()=>n(ue)},{GATE:()=>s.parseMode.has("canCreateBlankNodes"),ALT:()=>n(r)}]),gImpl:({SUBRULE:n})=>(i,{astFactory:s})=>{s.isTerm(i)?n(ue,i):n(r,i)}}}var Ao=tm("graphNode",!1),at=tm("graphNodePath",!0);var Ge={name:"whereClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OPTION:n})=>i=>{let s=n(()=>r(_t)),a=t(Y);return e(()=>i.astFactory.wrap(a,i.astFactory.sourceLocation(s,a)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("WHERE")),e(Y,r.val)}},Y={name:"groupGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR:n})=>i=>{let s=r(g.LCurly),a=n([{ALT:()=>[t(Po)]},{ALT:()=>t(nm)}]),o=r(g.RCurly);return e(()=>!i.skipValidation&&df(a)),e(()=>i.astFactory.patternGroup(a,i.astFactory.sourceLocation(s,o)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r,PRINT_ON_OWN_LINE:n})=>(i,s)=>{let{astFactory:a,indentInc:o}=s;a.printFilter(i,()=>{s[H]+=o,t("{"),r()});for(let c of i.patterns)e(rm,c);a.printFilter(i,()=>{s[H]-=o,n("}")})}},rm={name:"generatePattern",gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{t.type==="query"?e(gr,r.querySelect({context:[],datasets:r.datasetClauses([],r.sourceLocation()),where:t.where,variables:t.variables,solutionModifiers:t.solutionModifiers,values:t.values,distinct:t.distinct,reduced:t.reduced},t.loc)):t.subType==="group"?e(Y,t):t.subType==="bgp"?e(ot,t):e(So,t)}},nm={name:"groupGraphPatternSub",impl:({ACTION:e,SUBRULE:t,CONSUME:r,MANY:n,SUBRULE1:i,SUBRULE2:s,OPTION1:a,OPTION2:o,OPTION3:c})=>l=>{let p=[],h=a(()=>i(ot));return h&&p.push(h),n(()=>{let d=t(So);p.push(d),o(()=>r(g.dot));let m=c(()=>s(ot));m&&p.push(m)}),e(()=>!l.skipValidation&&ff(p)),p}},So={name:"graphPatternNotTriples",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(_o)},{ALT:()=>e(bo)},{ALT:()=>e(Lo)},{ALT:()=>e(xo)},{ALT:()=>e(Io)},{ALT:()=>e(Oo)},{ALT:()=>e(Eo)},{ALT:()=>e(fr)}]),gImpl:({SUBRULE:e})=>t=>{switch(t.subType){case"group":case"union":e(_o,t);break;case"optional":e(bo,t);break;case"minus":e(Lo,t);break;case"graph":e(xo,t);break;case"service":e(Io,t);break;case"filter":e(Oo,t);break;case"bind":e(Eo,t);break;case"values":e(fr,t);break}}},bo={name:"optionalGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ji),s=t(Y);return e(()=>n.astFactory.patternOptional(s.patterns,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("OPTIONAL")),e(Y,n.patternGroup(r.patterns,r.loc))}},xo={name:"graphGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ve.graph),s=t(Tt),a=t(Y);return e(()=>n.astFactory.patternGraph(s,a.patterns,n.astFactory.sourceLocation(i,a)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("GRAPH")),e(ue,r.name),e(Y,n.patternGroup(r.patterns,r.loc))}},Io={name:"serviceGraphPattern",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(Vi),a=n(()=>(r(mt),!0))??!1,o=t(Tt),c=t(Y);return e(()=>i.astFactory.patternService(o,c.patterns,a,i.astFactory.sourceLocation(s,c)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t("SERVICE"),r.silent&&t("SILENT")}),e(ue,r.name),e(Y,n.patternGroup(r.patterns,r.loc))}},Eo={name:"bind",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Ki);r(g.LParen);let s=t(R);r(Lt);let a=t(W),o=r(g.RParen);return e(()=>n.astFactory.patternBind(s,a,n.astFactory.sourceLocation(i,o)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>t("BIND","(")),e(R,n.expression),i.printFilter(n,()=>t("AS")),e(W,n.variable),i.printFilter(n,()=>{t(")"),r()})}},fr={name:"inlineData",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Ii),s=t(im);return e(()=>(s.loc=n.astFactory.sourceLocation(i,s),s))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r,NEW_LINE:n,PRINT_ON_OWN_LINE:i})=>(s,a)=>{let{astFactory:o,indentInc:c}=a,l=s.variables,p=l.length===1;o.printFilter(s,()=>{r("VALUES",p?"":"( ")});for(let h of l)o.printFilter(s,()=>t("")),e(ue,h),o.printFilter(s,()=>t(""));o.printFilter(s,()=>{a[H]+=c,t(p?"":")","{"),n()});for(let h of s.values){o.printFilter(s,()=>!p&&t("("));for(let d of l){let m=d.value;h[m]===void 0?o.printFilter(s,()=>t("UNDEF")):(e(at,h[m]),o.printFilter(s,()=>t("")))}o.printFilter(s,()=>{t(p?"":")"),n()})}o.printFilter(s,()=>{a[H]-=c,i("}")})}},im={name:"dataBlock",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(sm)},{ALT:()=>e(am)}])},sm={name:"inlineDataOneVar",impl:({ACTION:e,SUBRULE:t,CONSUME:r,MANY:n})=>i=>{let s=[],a=t(W);r(g.LCurly),n(()=>{let c=t(No);e(()=>{s.push(Object.assign(Object.create(null),{[a.value]:c}))})});let o=r(g.RCurly);return e(()=>i.astFactory.patternValues([a],s,i.astFactory.sourceLocation(a,o)))}},am={name:"inlineDataFull",impl:({ACTION:e,OR:t,MANY1:r,MANY2:n,MANY3:i,MANY4:s,SUBRULE:a,CONSUME1:o,CONSUME2:c})=>l=>{let p=[],h=[];return t([{ALT:()=>{let d=o(F.nil);o(g.LCurly),r(()=>{c(F.nil),p.push(Object.create(null))});let m=o(g.RCurly);return e(()=>l.astFactory.patternValues(h,p,l.astFactory.sourceLocation(d,m)))}},{ALT:()=>{let d=o(g.LParen);n(()=>{h.push(a(W))}),o(g.RParen),c(g.LCurly),i(()=>{let A=0,b=Object.create(null);c(g.LParen),s(()=>{e(()=>{if(!l.skipValidation&&A>=h.length)throw new Error("Number of dataBlockValues does not match number of variables. Too much values.")});let y=a(No);e(()=>{b[h[A].value]=y,A++})}),c(g.RParen),e(()=>{if(p.push(b),!l.skipValidation&&h.length!==A)throw new Error("Number of dataBlockValues does not match number of variables. Too few values.")})});let m=c(g.RCurly);return e(()=>l.astFactory.patternValues(h,p,l.astFactory.sourceLocation(d,m)))}}])}},No={name:"dataBlockValue",impl:({SUBRULE:e,CONSUME:t,OR:r})=>()=>r([{ALT:()=>e($)},{ALT:()=>e(St)},{ALT:()=>e(Ht)},{ALT:()=>e(Wt)},{ALT:()=>{t(Hi)}}])},Lo={name:"minusGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Wi),s=t(Y);return e(()=>n.astFactory.patternMinus(s.patterns,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("MINUS")),e(Y,n.patternGroup(r.patterns,r.loc))}},_o={name:"groupOrUnionGraphPattern",impl:({ACTION:e,MANY:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i})=>s=>{let a=[],o=r(Y);return a.push(o),t(()=>{i(zi);let c=n(Y);a.push(c)}),e(()=>a.length===1?a[0]:s.astFactory.patternUnion(a,s.astFactory.sourceLocation(o,a.at(-1))))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{if(n.isPatternUnion(r)){let[i,...s]=r.patterns;e(Y,i);for(let a of s)n.printFilter(r,()=>t("UNION")),e(Y,a)}else e(Y,r)}},Oo={name:"filter",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(qi),s=t(en);return e(()=>n.astFactory.patternFilter(s,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>t("FILTER (")),e(R,n.expression),i.printFilter(n,()=>{t(")"),r()})}},en={name:"constraint",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(mr)},{ALT:()=>e(yt)},{ALT:()=>e(ms)}])},ms={name:"functionCall",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t($),i=t(dr);return e(()=>r.astFactory.expressionFunctionCall(n,i.val.args,i.val.distinct,r.astFactory.sourceLocation(n,i)))}};var dr={name:"argList",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,OPTION:n,OR:i,AT_LEAST_ONE_SEP:s})=>a=>i([{ALT:()=>{let o=t(F.nil);return e(()=>a.astFactory.wrap({args:[],distinct:!1},a.astFactory.sourceLocation(o)))}},{ALT:()=>{let o=[],c=t(g.LParen),l=n(()=>(t(Xe),!0))??!1;s({SEP:g.comma,DEF:()=>{let h=r(R);o.push(h)}});let p=t(g.RParen);return e(()=>a.astFactory.wrap({args:o,distinct:l},a.astFactory.sourceLocation(c,p)))}}]),gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t("("),r.val.distinct&&t("DISTINCT")});let[i,...s]=r.val.args;i&&e(R,i);for(let a of s)n.printFilter(r,()=>t(",")),e(R,a);n.printFilter(r,()=>t(")"))}},ls={name:"expressionList",impl:({ACTION:e,CONSUME:t,MANY:r,OR:n,SUBRULE1:i,SUBRULE2:s})=>a=>n([{ALT:()=>{let o=t(F.nil);return e(()=>a.astFactory.wrap([],a.astFactory.sourceLocation(o)))}},{ALT:()=>{let o=t(g.LParen),l=[i(R)];r(()=>{t(g.comma);let h=s(R);l.push(h)});let p=t(g.RParen);return e(()=>a.astFactory.wrap(l,a.astFactory.sourceLocation(o,p)))}}])},eS=new Set(["||","&&","=","!=","<",">","<=",">=","+","-","*","/"]),tS=new Set(["in","notin","||","&&","=","!=","<",">","<=",">=","+","-","*","/"]),om={"!":"",uplus:"+",uminus:"-"},R={name:"expression",impl:({SUBRULE:e})=>()=>e(cm),gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{if(n.isTerm(r))e(ue,r);else if(n.isExpressionPatternOperation(r)){let i=r.args;n.printFilter(r,()=>t(r.operator==="exists"?"EXISTS":"NOT EXISTS")),e(Y,i)}else if(n.isExpressionFunctionCall(r))e(Mo,r);else if(n.isExpressionAggregate(r))e(us,r);else if(tS.has(r.operator)){let[i,...s]=r.args;n.printFilter(r,()=>t("(")),e(R,i),n.printFilter(r,()=>{r.operator==="notin"?t("NOT IN"):r.operator==="in"?t("IN"):t(r.operator.toUpperCase())}),s.length===1&&eS.has(r.operator)?e(R,s[0]):e(dr,n.wrap({args:s,distinct:!1},r.loc)),n.printFilter(r,()=>t(")"))}else if(typeof om[r.operator]=="string"){let[i]=r.args;n.printFilter(r,()=>t(om[r.operator]||r.operator.toUpperCase())),e(R,i)}else{n.printFilter(r,()=>t(r.operator.toUpperCase(),"("));let[i,...s]=r.args;i&&e(R,i);for(let a of s)n.printFilter(r,()=>t(",")),e(R,a);n.printFilter(r,()=>t(")"))}}};function tn(e,t,r,n){let i=e();return n(()=>{let s=t();r(()=>{i=s(i)})}),i}var cm={name:"conditionalOrExpression",impl:({ACTION:e,MANY:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i})=>s=>tn(()=>n(ko),()=>{r(g.logicOr);let a=i(ko);return o=>e(()=>s.astFactory.expressionOperation("||",[o,a],s.astFactory.sourceLocation(o,a)))},e,t)},ko={name:"conditionalAndExpression",impl:({ACTION:e,MANY:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i})=>s=>tn(()=>r(Ro),()=>{i(g.logicAnd);let a=n(Ro);return o=>e(()=>s.astFactory.expressionOperation("&&",[o,a],s.astFactory.sourceLocation(o,a)))},e,t)},Ro={name:"valueLogical",impl:({SUBRULE:e})=>()=>e(lm)},lm={name:"relationalExpression",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OPTION:i,OR1:s,OR2:a,OR3:o})=>c=>{let l=r(Fo);return i(()=>s([{ALT:()=>{let h=a([{ALT:()=>t(g.equal)},{ALT:()=>t(g.notEqual)},{ALT:()=>t(g.lessThan)},{ALT:()=>t(g.greaterThan)},{ALT:()=>t(g.lessThanEqual)},{ALT:()=>t(g.greaterThanEqual)}]),d=n(Fo);return e(()=>c.astFactory.expressionOperation(h.image,[l,d],c.astFactory.sourceLocation(l,d)))}},{ALT:()=>{let h=o([{ALT:()=>t(Bi)},{ALT:()=>t(Qi)}]),d=r(ls);return e(()=>c.astFactory.expressionOperation(h.image,[l,...d.val],c.astFactory.sourceLocation(l,d)))}}]))??l}},Fo={name:"numericExpression",impl:({SUBRULE:e})=>()=>e(um)},um={name:"additiveExpression",impl:({ACTION:e,SUBRULE:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,MANY1:s,MANY2:a,OR1:o,OR2:c,OR3:l,OR4:p})=>h=>tn(()=>n(wo),()=>o([{ALT:()=>{let d=c([{ALT:()=>r(g.opPlus)},{ALT:()=>r(g.opMinus)}]),m=i(wo);return e(()=>A=>h.astFactory.expressionOperation(d.image,[A,m],h.astFactory.sourceLocation(A,m)))}},{ALT:()=>{let{operator:d,startInt:m}=l([{ALT:()=>{let b=t(ts);return e(()=>(b.value=b.value.replace(/^\+/u,""),{operator:"+",startInt:b}))}},{ALT:()=>{let b=t(rs);return e(()=>(b.value=b.value.replace(/^-/u,""),{operator:"-",startInt:b}))}}]),A=tn(()=>e(()=>m),()=>{let b=p([{ALT:()=>r(g.star)},{ALT:()=>r(g.slash)}]),y=n(gs);return v=>e(()=>h.astFactory.expressionOperation(b.image,[v,y],h.astFactory.sourceLocation(v,y)))},e,a);return b=>h.astFactory.expressionOperation(d,[b,A],h.astFactory.sourceLocation(b,A))}}]),e,s)},wo={name:"multiplicativeExpression",impl:({ACTION:e,CONSUME:t,MANY:r,SUBRULE1:n,SUBRULE2:i,OR:s})=>a=>tn(()=>n(gs),()=>{let o=s([{ALT:()=>t(g.star)},{ALT:()=>t(g.slash)}]),c=i(gs);return l=>({type:"expression",subType:"operation",operator:o.image,args:[l,c],loc:a.astFactory.sourceLocation(l,c)})},e,r)},gs={name:"unaryExpression",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR1:i,OR2:s})=>a=>i([{ALT:()=>r(Co)},{ALT:()=>{let o=s([{ALT:()=>t(g.exclamation)},{ALT:()=>t(g.opPlus)},{ALT:()=>t(g.opMinus)}]),c=n(Co);return e(()=>a.astFactory.expressionOperation(o.image==="!"?"!":o.image==="+"?"UPLUS":"UMINUS",[c],a.astFactory.sourceLocation(o,c)))}}])},Co={name:"primaryExpression",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(mr)},{ALT:()=>e(yt)},{ALT:()=>e(Mo)},{ALT:()=>e(St)},{ALT:()=>e(Ht)},{ALT:()=>e(Wt)},{ALT:()=>e(W)}])},mr={name:"brackettedExpression",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(g.LParen),s=t(R),a=r(g.RParen);return e(()=>(s.loc=n.astFactory.sourceLocation(i,a),s))}},Mo={name:"iriOrFunction",impl:({ACTION:e,SUBRULE:t,OPTION:r})=>n=>{let i=t($);return r(()=>{let a=t(dr);return e(()=>{let o=a.val.distinct;if(!n.parseMode.has("canParseAggregate")&&o)throw new Error("DISTINCT implies that this function is an aggregated function, which is not allowed in this context.");return{type:"expression",subType:"functionCall",function:i,args:a.val.args,distinct:o,loc:n.astFactory.sourceLocation(i,a)}})})??i},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{r.isTermNamed(t)?e($,t):(e($,t.function),e(dr,r.wrap({args:t.args,distinct:t.distinct},t.loc)))}};var $e={name:"solutionModifier",impl:({ACTION:e,SUBRULE:t,OPTION1:r,OPTION2:n,OPTION3:i,OPTION4:s})=>()=>{let a=r(()=>t(Do)),o=n(()=>t(Go)),c=i(()=>t($o)),l=s(()=>t(jo));return e(()=>({...l&&{limitOffset:l},...a&&{group:a},...o&&{having:o},...c&&{order:c}}))},gImpl:({SUBRULE:e})=>t=>{t.group&&e(Do,t.group),t.having&&e(Go,t.having),t.order&&e($o,t.order),t.limitOffset&&e(jo,t.limitOffset)}},Do={name:"groupClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n})=>i=>{let s=[],a=n(Zr);return n(Jr),t(()=>{s.push(r(pm))}),e(()=>({type:"solutionModifier",subType:"group",groupings:s,loc:i.astFactory.sourceLocation(a,s.at(-1))}))},gImpl:({PRINT_WORDS:e,SUBRULE:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("GROUP BY ")});for(let s of n.groupings)i.printFilter(n,()=>e("")),i.isExpression(s)?t(R,s):(i.printFilter(n,()=>e("(")),t(R,s.value),i.printFilter(n,()=>e("AS")),t(W,s.variable),i.printFilter(n,()=>e(")")))}},pm={name:"groupCondition",impl:({ACTION:e,SUBRULE:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,OPTION:s,OR:a})=>o=>a([{ALT:()=>t(yt)},{ALT:()=>t(ms)},{ALT:()=>i(W)},{ALT:()=>{let c=r(g.LParen),l=t(R),p=s(()=>(r(Lt),n(W))),h=r(g.RParen);return e(()=>p!==void 0?{variable:p,value:l,loc:o.astFactory.sourceLocation(c,h)}:l)}}])},Go={name:"havingClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(Ti),a=[],o=e(()=>i.parseMode.has("canParseAggregate")||!i.parseMode.add("canParseAggregate"));return t(()=>{a.push(r(hm))}),e(()=>!o&&i.parseMode.delete("canParseAggregate")),e(()=>i.astFactory.solutionModifierHaving(a,i.astFactory.sourceLocation(s,a.at(-1))))},gImpl:({PRINT_ON_EMPTY:e,SUBRULE:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{e("HAVING ")});for(let i of r.having)t(R,i)}},hm={name:"havingCondition",impl:({SUBRULE:e})=>()=>e(en)},$o={name:"orderClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n})=>i=>{let s=n(yi);n(Jr);let a=[],o=e(()=>i.parseMode.has("canParseAggregate")||!i.parseMode.add("canParseAggregate"));return t(()=>{a.push(r(fm))}),e(()=>!o&&i.parseMode.delete("canParseAggregate")),e(()=>i.astFactory.solutionModifierOrder(a,i.astFactory.sourceLocation(s,a.at(-1))))},gImpl:({PRINT_WORDS:e,PRINT_ON_EMPTY:t,SUBRULE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{t("ORDER BY ")});for(let s of n.orderDefs)s.descending?i.printFilter(n,()=>e("DESC")):i.printFilter(n,()=>e("ASC")),i.printFilter(n,()=>e("(")),r(R,s.expression),i.printFilter(n,()=>e(")"))}},fm={name:"orderCondition",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR1:n,OR2:i})=>s=>n([{ALT:()=>{let a=i([{ALT:()=>[!1,r(vi)]},{ALT:()=>[!0,r(Ai)]}]),o=t(mr);return e(()=>({expression:o,descending:a[0],loc:s.astFactory.sourceLocation(a[1],o)}))}},{ALT:()=>{let a=t(en);return e(()=>({expression:a,descending:!1,loc:a.loc}))}},{ALT:()=>{let a=t(W);return e(()=>({expression:a,descending:!1,loc:a.loc}))}}])},jo={name:"limitOffsetClauses",impl:({ACTION:e,SUBRULE1:t,SUBRULE2:r,OPTION1:n,OPTION2:i,OR:s})=>a=>s([{ALT:()=>{let o=t(Vo),c=n(()=>t(Ko));return e(()=>a.astFactory.solutionModifierLimitOffset(o.val,c?.val,a.astFactory.sourceLocation(o,...c?[c]:[])))}},{ALT:()=>{let o=r(Ko),c=i(()=>r(Vo));return e(()=>a.astFactory.solutionModifierLimitOffset(c?.val,o.val,a.astFactory.sourceLocation(o,c)))}}]),gImpl:({PRINT_WORDS:e,NEW_LINE:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t(),r.limit!==void 0&&e("LIMIT",String(r.limit)),r.offset&&e("OFFSET",String(r.offset))})}},Vo={name:"limitClause",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(bi),i=t(F.integer),s=Number.parseInt(i.image,10);return e(()=>r.astFactory.wrap(s,r.astFactory.sourceLocation(n,i)))}},Ko={name:"offsetClause",impl:({CONSUME:e,ACTION:t})=>r=>{let n=e(xi),i=e(F.integer),s=Number.parseInt(i.image,10);return t(()=>r.astFactory.wrap(s,r.astFactory.sourceLocation(n,i)))}};var rS={name:"queryUnit",impl:({SUBRULE:e})=>()=>e(gr)},gr={name:"query",impl:({ACTION:e,SUBRULE:t,OR:r})=>n=>{let i=t(De),s=r([{ALT:()=>t(rn)},{ALT:()=>t(nn)},{ALT:()=>t(sn)},{ALT:()=>t(an)}]),a=t(on);return e(()=>{let o={context:i,...s,type:"query",loc:n.astFactory.sourceLocation(i.at(0),s,a)};return a&&(o.values=a),o})},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{e(De,t.context),r.isQuerySelect(t)?e(rn,t):r.isQueryConstruct(t)?e(nn,t):r.isQueryDescribe(t)?e(sn,t):e(an,t),t.values&&e(fr,t.values)}},rn={name:"selectQuery",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t(Ts),i=t(Be),s=t(Ge),a=t($e);return e(()=>{let o={subType:"select",where:s.val,solutionModifiers:a,datasets:i,...n.val,loc:r.astFactory.sourceLocation(n,s,a.group,a.having,a.order,a.limitOffset)};return r.skipValidation||pf(o),o})},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{e(Ts,r.wrap({variables:t.variables,distinct:t.distinct,reduced:t.reduced},r.sourceLocation(...t.variables))),e(Be,t.datasets),e(Ge,r.wrap(t.where,t.where.loc)),e($e,t.solutionModifiers)}},Po={name:"subSelect",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t(Ts),i=t(Ge),s=t($e),a=t(on);return e(()=>r.astFactory.querySelect({where:i.val,datasets:r.astFactory.datasetClauses([],r.astFactory.sourceLocation()),context:[],solutionModifiers:s,...n.val,...a&&{values:a}},r.astFactory.sourceLocation(n,i,s.group,s.having,s.order,s.limitOffset,a)))}},Ts={name:"selectClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i,OPTION:s,OR1:a,OR2:o,OR3:c})=>l=>{let p=i(pi),h=e(()=>l.parseMode.has("canParseAggregate")||!l.parseMode.add("canParseAggregate")),d=s(()=>a([{ALT:()=>(i(Xe),[!0,!1])},{ALT:()=>(i(hi),[!1,!0])}]))??[!1,!1],m=e(()=>{let[y,v]=d;return{...y&&{distinct:y},...v&&{reduced:v}}}),A,b=o([{ALT:()=>{let y=i(g.star);return e(()=>(A=y,{variables:[l.astFactory.wildcard(l.astFactory.sourceLocation(y))],...m}))}},{ALT:()=>{let y=[],v=[];return t(()=>c([{ALT:()=>{let x=r(W);e(()=>{if(!l.skipValidation&&y.some(T=>T.value===x.value))throw new Error(`Variable ${x.value} used more than once in SELECT clause`);y.push(x),v.push(x),A=x})}},{ALT:()=>{let x=i(g.LParen),T=r(R);i(Lt);let I=n(W),S=i(g.RParen);e(()=>{if(A=S,!l.skipValidation&&y.some(C=>C.value===I.value))throw new Error(`Variable ${I.value} used more than once in SELECT clause`);y.push(I),v.push(l.astFactory.patternBind(T,I,l.astFactory.sourceLocation(x,A)))})}}])),{variables:v,...m}}}]);return e(()=>!h&&l.parseMode.delete("canParseAggregate")),e(()=>l.astFactory.wrap(b,l.astFactory.sourceLocation(p,A)))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("SELECT "),n.val.distinct?t("DISTINCT"):n.val.reduced&&t("REDUCED")});for(let s of n.val.variables)i.isWildcard(s)?i.printFilter(n,()=>t("*")):i.isTerm(s)?e(W,s):(i.printFilter(n,()=>t("(")),e(R,s.expression),i.printFilter(n,()=>t("AS")),e(W,s.variable),i.printFilter(n,()=>t(")"))),i.printFilter(n,()=>t(""));i.printFilter(n,()=>t(""))}},nn={name:"constructQuery",impl:({ACTION:e,SUBRULE1:t,SUBRULE2:r,CONSUME:n,OR:i})=>s=>{let a=n(fi);return i([{ALT:()=>{let o=t(Ho),c=t(Be),l=t(Ge),p=t($e);return e(()=>({subType:"construct",template:o.val,datasets:c,where:l.val,solutionModifiers:p,loc:s.astFactory.sourceLocation(a,l,p.group,p.having,p.order,p.limitOffset)}))}},{ALT:()=>{let o=r(Be);n(_t);let c=r(Ho),l=r($e);return e(()=>({subType:"construct",template:c.val,datasets:o,where:s.astFactory.patternGroup([c.val],s.astFactory.sourceLocation()),solutionModifiers:l,loc:s.astFactory.sourceLocation(a,c,l.group,l.having,l.order,l.limitOffset)}))}}])},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r,PRINT_ON_OWN_LINE:n,NEW_LINE:i})=>(s,a)=>{let{astFactory:o,indentInc:c}=a;o.printFilter(s,()=>r("CONSTRUCT ")),o.isSourceLocationNoMaterialize(s.where.loc)||(o.printFilter(s,()=>{a[H]+=c,t("{"),i()}),e(ot,s.template),o.printFilter(s,()=>{a[H]-=c,n("}")})),e(Be,s.datasets),o.isSourceLocationNoMaterialize(s.where.loc)?e(Ge,o.wrap(o.patternGroup([s.template],s.template.loc),s.template.loc)):e(Ge,o.wrap(s.where,s.where.loc)),e($e,s.solutionModifiers)}},sn={name:"describeQuery",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n,OPTION:i,OR:s})=>a=>{let o=n(di),c=s([{ALT:()=>{let d=[];return t(()=>{d.push(r(Tt))}),d}},{ALT:()=>{let d=n(g.star);return[e(()=>a.astFactory.wildcard(a.astFactory.sourceLocation(d)))]}}]),l=r(Be),p=i(()=>r(Ge)),h=r($e);return e(()=>({subType:"describe",variables:c,datasets:l,...p&&{where:p.val},solutionModifiers:h,loc:a.astFactory.sourceLocation(o,...c,l,p,h.group,h.having,h.order,h.limitOffset)}))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{if(i.printFilter(n,()=>r("DESCRIBE ")),i.isWildcard(n.variables[0]))i.printFilter(n,()=>t("*"));else for(let s of n.variables)i.printFilter(n,()=>t("")),e(ue,s);e(Be,n.datasets),n.where&&e(Ge,i.wrap(n.where,n.loc)),e($e,n.solutionModifiers)}},an={name:"askQuery",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(mi),s=t(Be),a=t(Ge),o=t($e);return e(()=>({subType:"ask",datasets:s,where:a.val,solutionModifiers:o,loc:n.astFactory.sourceLocation(i,s,a,o.group,o.having,o.order,o.limitOffset)}))},gImpl:({SUBRULE:e,PRINT_ON_EMPTY:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("ASK ")),e(Be,r.datasets),e(Ge,n.wrap(r.where,r.loc)),e($e,r.solutionModifiers)}},on={name:"valuesClause",impl:({OPTION:e,SUBRULE:t})=>()=>e(()=>t(fr))},Ho={name:"constructTemplate",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(g.LCurly),a=n(()=>t(dm)),o=r(g.RCurly);return e(()=>i.astFactory.wrap(a??i.astFactory.patternBgp([],i.astFactory.sourceLocation()),i.astFactory.sourceLocation(s,o)))}},dm={name:"constructTriples",impl:Yt.impl};var nS={name:"updateUnit",impl:({SUBRULE:e})=>()=>e(ys)},ys={name:"update",impl:({ACTION:e,SUBRULE:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i,OPTION1:s,MANY:a})=>o=>{let c=[],l=r(De);c.push({context:l});let p=!0;return a({GATE:()=>p,DEF:()=>{p=!1,c.at(-1).operation=t(Tr),s(()=>{i(g.semi),p=!0;let h=n(De);c.push({context:h})})}}),e(()=>{let h={type:"update",updates:c,loc:o.astFactory.sourceLocation(...c.flatMap(d=>[...d.context,d.operation]))};return o.skipValidation||es(h),h})},gImpl:({SUBRULE:e,PRINT:t,NEW_LINE:r})=>(n,{astFactory:i})=>{let[s,...a]=n.updates;s&&(e(De,s.context),s.operation&&e(Tr,s.operation));for(let o of a)i.printFilter(n,()=>{t(";"),r()}),e(De,o.context),o.operation&&e(Tr,o.operation)}},Tr={name:"update1",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(Wo)},{ALT:()=>e(zo)},{ALT:()=>e(qo)},{ALT:()=>e(Xo)},{ALT:()=>e(Bo)},{ALT:()=>e(Qo)},{ALT:()=>e(Yo)},{ALT:()=>e(Zo)},{ALT:()=>e(Jo)},{ALT:()=>e(Uo)},{ALT:()=>e(ec)}]),gImpl:({SUBRULE:e})=>t=>{switch(t.subType){case"load":e(Wo,t);break;case"clear":e(zo,t);break;case"drop":e(qo,t);break;case"add":e(Xo,t);break;case"move":e(Bo,t);break;case"copy":e(Qo,t);break;case"create":e(Yo,t);break;case"insertdata":e(Zo,t);break;case"deletedata":e(Jo,t);break;case"deletewhere":e(Uo,t);break;case"modify":e(ec,t);break}}},Wo={name:"load",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION1:n,OPTION2:i})=>s=>{let a=r(Ei),o=n(()=>r(mt)),c=t($),l=i(()=>(r(Li),t(cn)));return e(()=>s.astFactory.updateOperationLoad(s.astFactory.sourceLocation(a,c,l),c,!!o,l))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("LOAD "),n.silent&&t("SILENT")}),e($,n.source),n.destination&&(i.printFilter(n,()=>t("INTO")),e(Xt,n.destination))}};function mm(e){return{name:ee(e.name),impl:({ACTION:t,SUBRULE1:r,CONSUME:n,OPTION:i})=>s=>{let a=n(e),o=i(()=>n(mt)),c=r(Xt);return t(()=>s.astFactory.updateOperationClearDrop(ee(e.name),!!o,c,s.astFactory.sourceLocation(a,c)))},gImpl:({SUBRULE:t,PRINT_WORD:r,PRINT_ON_EMPTY:n})=>(i,{astFactory:s})=>{s.printFilter(i,()=>{n(e.name.toUpperCase()," "),i.silent&&r("SILENT")}),t(Xt,i.destination)}}}var zo=mm(_i),qo=mm(Oi),Yo={name:"create",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(Si),a=n(()=>r(mt)),o=t(cn);return e(()=>i.astFactory.updateOperationCreate(o,!!a,i.astFactory.sourceLocation(s,o)))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("CREATE "),n.silent&&t("SILENT")}),e(Xt,n.destination)}};function ic(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,OPTION:s})=>a=>{let o=r(e),c=s(()=>r(mt)),l=n(rc);r(Pi);let p=i(rc);return t(()=>a.astFactory.updateOperationAddMoveCopy(ee(e.name),l,p,!!c,a.astFactory.sourceLocation(o,p)))},gImpl:({SUBRULE:t,PRINT_WORD:r,PRINT_ON_EMPTY:n})=>(i,{astFactory:s})=>{s.printFilter(i,()=>{n(e.name.toUpperCase()," "),i.silent&&r("SILENT")}),t(Xt,i.source),s.printFilter(i,()=>r("TO")),t(Xt,i.destination)}}}var Xo=ic(Ni),Bo=ic(ki),Qo=ic(Ri),vs={name:"quadPattern",impl:({ACTION:e,SUBRULE1:t,CONSUME:r})=>n=>{let i=r(g.LCurly),s=t(yr),a=r(g.RCurly);return e(()=>n.astFactory.wrap(s.val,n.astFactory.sourceLocation(i,a)))}},sc={name:"quadData",impl:({ACTION:e,SUBRULE1:t,CONSUME:r})=>n=>{let i=r(g.LCurly),s=e(()=>n.parseMode.delete("canParseVars")),a=t(yr);e(()=>s&&n.parseMode.add("canParseVars"));let o=r(g.RCurly);return e(()=>n.astFactory.wrap(a.val,n.astFactory.sourceLocation(i,o)))}};function ac(e,t,r,n){return{name:e,impl:({ACTION:i,SUBRULE1:s,CONSUME:a})=>o=>{let c=a(r),l=!0;e!=="insertData"&&(l=i(()=>o.parseMode.delete("canCreateBlankNodes")));let p=s(n);return e!=="insertData"&&i(()=>l&&o.parseMode.add("canCreateBlankNodes")),i(()=>o.astFactory.updateOperationInsDelDataWhere(t,p.val,o.astFactory.sourceLocation(c,p)))},gImpl:({SUBRULE:i,PRINT_WORD:s,PRINT_ON_EMPTY:a,PRINT_ON_OWN_LINE:o,NEW_LINE:c})=>(l,p)=>{let{astFactory:h,indentInc:d}=p;h.printFilter(l,()=>{a(t==="insertdata"?"INSERT DATA ":t==="deletedata"?"DELETE DATA ":"DELETE WHERE "),p[H]+=d,s("{"),c()}),i(yr,h.wrap(l.data,l.loc)),h.printFilter(l,()=>{p[H]-=d,o("}")})}}}var Zo=ac("insertData","insertdata",Di,sc),Jo=ac("deleteData","deletedata",wi,sc),Uo=ac("deleteWhere","deletewhere",Ci,vs),ec={name:"modify",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OPTION1:i,OPTION2:s,OR:a})=>o=>{let c=i(()=>{let m=t(Fi),A=r($);return{withToken:m,graph:A}}),{insert:l,del:p}=a([{ALT:()=>{let m=r(gm),A=s(()=>r(tc));return{del:m,insert:A}}},{ALT:()=>({insert:n(tc),del:void 0})}]),h=r(ss);t(_t);let d=r(Y);return e(()=>o.astFactory.updateOperationModify(o.astFactory.sourceLocation(c?.withToken,p,l,d),l?.val??[],p?.val??[],d,h,c?.graph))},gImpl:({SUBRULE:e,PRINT_WORDS:t,PRINT_ON_EMPTY:r,NEW_LINE:n})=>(i,s)=>{let{astFactory:a,indentInc:o}=s;i.graph&&(a.printFilter(i,()=>t("WITH")),e($,i.graph)),i.delete.length>0&&(a.printFilter(i,()=>{s[H]+=o,t("DELETE","{"),n()}),e(yr,a.wrap(i.delete,i.loc)),a.printFilter(i,()=>{s[H]-=o,r("}"),n()})),i.insert.length>0&&(a.printFilter(i,()=>{s[H]+=o,t("INSERT","{"),n()}),e(yr,a.wrap(i.insert,i.loc)),a.printFilter(i,()=>{s[H]-=o,r("} "),n()})),e(ss,i.from),a.printFilter(i,()=>t("WHERE")),e(Y,i.where)}},gm={name:"deleteClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Mi),s=e(()=>n.parseMode.delete("canCreateBlankNodes")),a=t(vs);return e(()=>s&&n.parseMode.add("canCreateBlankNodes")),e(()=>n.astFactory.wrap(a.val,n.astFactory.sourceLocation(i,a)))}},tc={name:"insertClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Gi),s=t(vs);return e(()=>n.astFactory.wrap(s.val,n.astFactory.sourceLocation(i,s)))}},rc={name:"graphOrDefault",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n,OR:i})=>s=>i([{ALT:()=>{let a=r(ve.default_);return e(()=>s.astFactory.graphRefDefault(s.astFactory.sourceLocation(a)))}},{ALT:()=>{let a=n(()=>r(ve.graph)),o=t($);return e(()=>s.astFactory.graphRefSpecific(o,s.astFactory.sourceLocation(a,o)))}}])},cn={name:"graphRef",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ve.graph),s=t($);return e(()=>n.astFactory.graphRefSpecific(s,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("GRAPH")),e($,r.graph)}},Xt={name:"graphRefAll",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR:n})=>i=>n([{ALT:()=>t(cn)},{ALT:()=>{let s=r(ve.default_);return e(()=>i.astFactory.graphRefDefault(i.astFactory.sourceLocation(s)))}},{ALT:()=>{let s=r(ve.named);return e(()=>i.astFactory.graphRefNamed(i.astFactory.sourceLocation(s)))}},{ALT:()=>{let s=r(ve.graphAll);return e(()=>i.astFactory.graphRefAll(i.astFactory.sourceLocation(s)))}}]),gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.isGraphRefSpecific(r)?e(cn,r):n.isGraphRefDefault(r)?n.printFilter(r,()=>t("DEFAULT")):n.isGraphRefNamed(r)?n.printFilter(r,()=>t("NAMED")):n.printFilter(r,()=>t("ALL"))}},yr={name:"quads",impl:({ACTION:e,SUBRULE:t,CONSUME:r,MANY:n,SUBRULE1:i,SUBRULE2:s,OPTION1:a,OPTION2:o,OPTION3:c})=>l=>{let p=[],h;return a(()=>{let d=i(Yt);h=d,e(()=>p.push(d))}),n(()=>{let d=t(nc);h=d,p.push(d),o(()=>{let m=r(g.dot);return h=m,m}),c(()=>{let m=s(Yt);h=m,e(()=>p.push(m))})}),e(()=>l.astFactory.wrap(p,l.astFactory.sourceLocation(p.at(0),h)))},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{for(let n of t.val)r.isPattern(n)?e(ot,n):e(nc,n)}},nc={name:"quadsNotTriples",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(ve.graph),a=t(Tt);r(g.LCurly);let o=n(()=>t(Yt)),c=r(g.RCurly);return e(()=>i.astFactory.graphQuads(a,o??i.astFactory.patternBgp([],i.astFactory.sourceLocation()),i.astFactory.sourceLocation(s,c)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r,PRINT_ON_OWN_LINE:n})=>(i,s)=>{let{astFactory:a,indentInc:o}=s;a.printFilter(i,()=>t("GRAPH")),e(ue,i.graph),a.printFilter(i,()=>{s[H]+=o,t("{"),r()}),e(ot,i.triples),a.printFilter(i,()=>{s[H]-=o,n("}")})}};var iS={name:"queryOrUpdate",impl:({ACTION:e,SUBRULE:t,OR1:r,OR2:n,MANY:i,OPTION1:s,CONSUME:a,SUBRULE2:o})=>c=>{let l=t(De);return r([{ALT:()=>{let p=n([{ALT:()=>t(rn)},{ALT:()=>t(nn)},{ALT:()=>t(sn)},{ALT:()=>t(an)}]),h=t(on);return e(()=>({context:l,...p,type:"query",...h&&{values:h},loc:c.astFactory.sourceLocation(l.at(0),p,h)}))}},{ALT:()=>{let p=[];p.push({context:l});let h=!0;return i({GATE:()=>h,DEF:()=>{h=!1,p.at(-1).operation=t(Tr),s(()=>{a(g.semi),h=!0;let d=o(De);p.push({context:d})})}}),e(()=>{let d={type:"update",updates:p,loc:c.astFactory.sourceLocation(...p.flatMap(m=>[...m.context,m.operation]))};return c.skipValidation||es(d),d})}}])},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{r.isQuery(t)?e(gr,t):e(ys,t)}};function sS(e){return{astFactory:e.astFactory??new Kt({tracksSourceLocation:!1}),baseIRI:e.baseIRI,prefixes:Object.assign(Object.create(null),e.prefixes),parseMode:e.parseMode?new Set(e.parseMode):new Set(["canParseVars","canCreateBlankNodes"]),skipValidation:e.skipValidation??!1}}function oc(e){return{astFactory:e.astFactory??new Kt,origSource:e.origSource??"",offset:e.offset,[H]:e[H]??0,[Wr]:e[Wr]??" ",indentInc:e.indentInc??2}}function Tm(e){return{...e,prefixes:Object.assign(Object.create(null),e.prefixes),parseMode:new Set(e.parseMode)}}var As=class{parser;defaultContext;coreTransformer=new $t;constructor(t,r={}){this.parser=t,this.defaultContext=sS(r)}parse(t,r={}){let n=this.parser.queryOrUpdate(t,Tm({...this.defaultContext,...r}));return n.loc=this.defaultContext.astFactory.sourceLocationInlinedSource(t,n.loc,0,Number.MAX_SAFE_INTEGER),n}parsePath(t,r={}){let n=this.parser.path(t,Tm({...this.defaultContext,...r}));return n.loc=this.defaultContext.astFactory.sourceLocationInlinedSource(t,n.loc,0,Number.MAX_SAFE_INTEGER),this.defaultContext.astFactory.isPathPure(n)?{...n,prefixes:Object.create(null)}:n}};var aS=[u.expression,u.conditionalOrExpression,u.conditionalAndExpression,u.valueLogical,u.relationalExpression,u.numericExpression,u.expressionList,u.additiveExpression,u.multiplicativeExpression,u.unaryExpression,u.primaryExpression,u.brackettedExpression,u.iriOrFunction,u.rdfLiteral,u.numericLiteral,u.numericLiteralUnsigned,u.numericLiteralPositive,u.numericLiteralNegative,u.booleanLiteral,u.var_,u.builtInStr,u.builtInLang,u.builtInLangmatches,u.builtInDatatype,u.builtInBound,u.builtInIri,u.builtInUri,u.builtInBnodeSparqlJs,u.builtInRand,u.builtInAbs,u.builtInCeil,u.builtInFloor,u.builtInRound,u.builtInConcat,u.builtInStrlen,u.builtInUcase,u.builtInLcase,u.builtInEncode_for_uri],oS={name:"builtInCall",impl:({OR:e,SUBRULE:t})=>()=>e(u.builtInCallList(t).slice(0,-2))},ym=te.create(aS).addMany(u.builtInContains,u.builtInStrstarts,u.builtInStrends,u.builtInStrbefore,u.builtInStrafter,u.builtInYear,u.builtInMonth,u.builtInDay,u.builtInHours,u.builtInMinutes,u.builtInSeconds,u.builtInTimezone,u.builtInTz,u.builtInNow,u.builtInUuid,u.builtInStruuid,u.builtInMd5,u.builtInSha1,u.builtInSha256,u.builtInSha384,u.builtInSha512,u.builtInCoalesce,u.builtInIf,u.builtInStrlang,u.builtInStrdt,u.builtInSameterm,u.builtInIsiri,u.builtInIsuri,u.builtInIsblank,u.builtInIsliteral,u.builtInIsnumeric,u.regexExpression,u.substringExpression,u.strReplaceExpression,u.aggregateCount,u.aggregateSum,u.aggregateMin,u.aggregateMax,u.aggregateAvg,u.aggregateSample,u.aggregateGroup_concat,u.aggregate,u.iri,u.iriFull,u.prefixedName,u.argList,u.string).addRule(oS);var cS=[u.objectList,u.object,u.graphNode,u.varOrTerm,u.triplesNode,u.collection,u.blankNodePropertyList,u.propertyListNotEmpty,u.verb,u.verbA,u.varOrIri,u.var_,u.iri,u.iriFull,u.prefixedName,u.graphTerm,u.rdfLiteral,u.numericLiteral,u.booleanLiteral,u.blankNode,u.string,u.numericLiteralUnsigned,u.numericLiteralPositive,u.numericLiteralNegative],bs=te.create(cS);var vm=te.create([u.triplesBlock,u.triplesSameSubjectPath,u.propertyListPathNotEmpty,u.triplesNodePath,u.propertyListPath,u.verbPath,u.verbSimple,u.objectListPath]).merge(bs,[]).addMany(u.path,u.pathAlternative,u.pathSequence,u.pathEltOrInverse,u.pathElt,u.pathPrimary,u.pathMod,u.pathNegatedPropertySet,u.pathOneInPropertySet,u.objectPath,u.graphNodePath,u.collectionPath,u.blankNodePropertyListPath);var lS=[u.subSelect,u.selectClause,u.whereClause,u.solutionModifier,u.valuesClause],xs=te.create(lS).merge(ym,[]).patchRule(u.builtInCall).addMany(u.existsFunc,u.notExistsFunc,u.groupGraphPattern,u.groupGraphPatternSub).merge(vm,[]).addMany(u.graphPatternNotTriples,u.groupOrUnionGraphPattern,u.optionalGraphPattern,u.minusGraphPattern,u.graphGraphPattern,u.serviceGraphPattern,u.filter,u.bind,u.inlineData,u.constraint,u.functionCall,u.dataBlock,u.inlineDataOneVar,u.inlineDataFull,u.dataBlockValue,u.groupClause,u.havingClause,u.orderClause,u.limitOffsetClauses,u.groupCondition,u.havingCondition,u.orderCondition,u.limitClause,u.offsetClause);var uS=[u.triplesTemplate,u.triplesSameSubject,u.varOrTerm,u.propertyListNotEmpty,u.triplesNode,u.propertyList,u.var_,u.graphTerm,u.iri,u.iriFull,u.prefixedName,u.rdfLiteral,u.string,u.numericLiteral,u.numericLiteralUnsigned,u.numericLiteralPositive,u.numericLiteralNegative,u.booleanLiteral,u.blankNode,u.verb,u.verbA,u.varOrIri,u.objectList,u.object,u.collection,u.blankNodePropertyList,u.graphNode],Is=te.create(uS);var pS=[u.queryUnit,u.query,u.prologue,u.selectQuery,u.constructQuery,u.describeQuery,u.askQuery,u.valuesClause,u.baseDecl,u.prefixDecl],Am=te.create(pS).merge(xs,[]).addRule(u.datasetClause).addRule(u.datasetClauseStar).addRule(u.defaultGraphClause).addRule(u.namedGraphClause).addRule(u.sourceSelector).addRule(u.constructTemplate).merge(Is,[]).addRule(u.constructTriples);var hS={name:"update1",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(u.load)},{ALT:()=>e(u.clear)},{ALT:()=>e(u.drop)},{ALT:()=>e(u.add)},{ALT:()=>e(u.move)},{ALT:()=>e(u.copy)},{ALT:()=>e(u.create)},{ALT:()=>e(u.insertData)},{ALT:()=>e(u.deleteData)},{ALT:()=>e(u.deleteWhere)}]),gImpl:u.update1.gImpl},fS=[u.updateUnit,u.update,u.prologue,u.baseDecl,u.prefixDecl,u.load,u.clear,u.drop,u.add,u.move,u.copy,u.create,u.insertData,u.deleteData,u.deleteWhere,u.iri,u.prefixedName,u.graphRef,u.graphRefAll,u.graphOrDefault,u.quadData,u.quads],bm=te.create(fS).addRule(hS).merge(Is,[]).addRule(u.quadPattern).addRule(u.quadsNotTriples);var xm=te.create(bm).patchRule(u.update1).addMany(u.modify,u.deleteClause,u.insertClause,u.usingClause,u.defaultGraphClause,u.namedGraphClause,u.sourceSelector,u.usingClauseStar,u.groupGraphPattern).merge(bs,[]).merge(xs,[]);var dS=te.create(Am).merge(xm,[]).addRule(u.queryOrUpdate),Es=class extends As{constructor(t={}){let r=dS.build({...t,tokenVocabulary:he.sparql11LexerBuilder.tokenVocabulary,queryPreProcessor:lf});super(r,t.defaultContext)}};var mS=Un.create([u.queryOrUpdate,u.query,u.selectQuery,u.constructQuery,u.describeQuery,u.askQuery,u.selectClause]).addMany(u.update,u.update1,u.load,u.clear,u.drop,u.create,u.copy,u.move,u.add,u.insertData,u.deleteData,u.deleteWhere,u.modify,u.graphRef,u.graphRefAll,u.quads,u.quadsNotTriples).addRule(u.aggregate).addMany(u.datasetClauseStar,u.usingClauseStar).addMany(u.argList,u.expression,u.iriOrFunction).addMany(u.prologue,u.prefixDecl,u.baseDecl,u.varOrTerm,u.var_,u.graphTerm).addMany(u.rdfLiteral,u.iri,u.iriFull,u.prefixedName,u.blankNode).addRule(u.pathGenerator).addMany(u.solutionModifier,u.groupClause,u.havingClause,u.orderClause,u.limitOffsetClauses).addMany(u.triplesBlock,u.collectionPath,u.blankNodePropertyListPath,u.triplesNodePath,u.graphNodePath).addMany(u.whereClause,u.generatePattern,u.groupGraphPattern,u.graphPatternNotTriples,u.optionalGraphPattern,u.graphGraphPattern,u.serviceGraphPattern,u.bind,u.inlineData,u.minusGraphPattern,u.groupOrUnionGraphPattern,u.filter),Ls=class{defaultContext;constructor(t={}){this.defaultContext=oc(t)}generator=mS.build();generate(t,r={}){return this.generator.queryOrUpdate(t,{...this.defaultContext,...r}).trim()}generatePath(t,r={}){return this.generator.path(t,oc({...this.defaultContext,...r}),void 0).trim()}};var Os=()=>({sourceLocationType:"autoGenerate"});function cc(e,t){if(!t)return e;try{return new URL(e,t).href}catch{return e}}function uc(e,t={prefixes:new Map,base:void 0}){if(Array.isArray(e))return e.forEach(n=>uc(n,t)),e;if(!e||typeof e!="object")return e;let r=t;if(Array.isArray(e.context)&&e.context.length>0){r={prefixes:new Map(t.prefixes),base:t.base};for(let n of e.context)n.subType==="base"&&n.value?.value&&(r.base=cc(n.value.value,r.base)),n.subType==="prefix"&&n.key!==void 0&&n.value?.value&&r.prefixes.set(n.key,cc(n.value.value,r.base))}if(e.type==="term"&&e.subType==="namedNode")if(e.prefix!==void 0){let n=r.prefixes.get(e.prefix);if(n===void 0)throw new Error(`Undefined SPARQL prefix: ${e.prefix}`);e.value=n+e.value,delete e.prefix}else e.value=cc(e.value,r.base);for(let[n,i]of Object.entries(e))n!=="context"&&uc(i,r);return e}function lc(e,t){if(e&&e.type==="tripleCollection"){for(let r of e.triples)Em(r,t);return pc(e.identifier)}return pc(e)}function Em(e,t){if(e.type==="tripleCollection"){lc(e,t);return}let r=lc(e.subject,t),n=lc(e.object,t);t.push({...e,subject:r,predicate:pc(e.predicate),object:n,loc:Os()})}function pc(e){return e&&typeof e=="object"?{...e,loc:Os()}:e}function hc(e){if(Array.isArray(e))return e.forEach(hc),e;if(!e||typeof e!="object")return e;if(e.type==="pattern"&&e.subType==="bgp"&&Array.isArray(e.triples)){let t=[];for(let r of e.triples)Em(r,t);e.triples=t}for(let t of Object.values(e))hc(t);return e}function Im(e){return{type:"pattern",subType:"group",patterns:e,loc:Os()}}function gS(e){if(e.type==="query"){Array.isArray(e.context)||(e.context=[]),e.datasets||(e.datasets={type:"datasetClauses",clauses:[]}),e.solutionModifiers||(e.solutionModifiers={}),e.subType!=="describe"&&!e.where&&(e.where=Im([]));let t=e.solutionModifiers,r=t.limitOffset;r&&(r.limit===void 0&&!r.offset?delete t.limitOffset:Object.assign(r,{type:"solutionModifier",subType:"limitOffset"})),t.order&&!(t.order.orderDefs?.length>0)&&delete t.order,t.group&&!(t.group.groupings?.length>0)&&delete t.group}e.type==="pattern"&&e.subType==="union"&&Array.isArray(e.patterns)&&(e.patterns=e.patterns.map(t=>t.type==="pattern"&&t.subType==="group"?t:Im([t])))}function _s(e,t=!1){if(Array.isArray(e))return e.forEach(r=>_s(r,t)),e;if(!e||typeof e!="object")return e;if(t){for(let r of Object.values(e))_s(r);return e}typeof e.type=="string"&&gS(e),e.loc||(e.loc=Os());for(let[r,n]of Object.entries(e))r!=="loc"&&_s(n,r==="values"&&e.subType==="values");return e}var fc=class{constructor(t){this.parser=new Es(t)}parse(t){return hc(uc(this.parser.parse(t)))}},dc=class{constructor(t){this.generator=new Ls(t)}generate(t,r){return this.generator.generate(_s(t),r)}};typeof window<"u"&&(window.LDH_SPARQL={Parser:fc,Generator:dc});})(); diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/admin/signup.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/admin/signup.xsl index 2254d1672f..14137167f9 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/admin/signup.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/admin/signup.xsl @@ -62,7 +62,7 @@ exclude-result-prefixes="#all"> - + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client.xsl index a7c12419c4..a94a3389a1 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client.xsl @@ -102,8 +102,8 @@ extension-element-prefixes="ixsl" - - + + - - - &ldh;chartType - - + - - - - - + - - - - - + - optional + pattern + optional - filter + pattern + filter - operation + expression + operation in - ?p - - &ldh;chartType - &ldh;categoryVarName - &ldh;categoryProperty - &ldh;seriesVarName - &ldh;seriesProperty - + + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl index 99e2c33f68..ba01c1154c 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl @@ -121,14 +121,14 @@ exclude-result-prefixes="#all" "/> - + - - + + - + @@ -381,7 +381,7 @@ exclude-result-prefixes="#all" - + - + - - + + @@ -586,8 +586,8 @@ exclude-result-prefixes="#all" - - + +

@@ -852,7 +852,7 @@ exclude-result-prefixes="#all" - + @@ -894,8 +894,8 @@ exclude-result-prefixes="#all" - - + + @@ -995,8 +995,8 @@ exclude-result-prefixes="#all" - - + + @@ -1105,8 +1105,8 @@ exclude-result-prefixes="#all" - - + + @@ -1396,8 +1396,8 @@ exclude-result-prefixes="#all" - - + + @@ -1469,7 +1469,7 @@ exclude-result-prefixes="#all" - + @@ -1477,11 +1477,11 @@ exclude-result-prefixes="#all" - + - - - + + + @@ -1811,7 +1811,7 @@ exclude-result-prefixes="#all" - + @@ -1847,7 +1847,7 @@ exclude-result-prefixes="#all" - + - + @@ -2199,7 +2199,7 @@ exclude-result-prefixes="#all" - + @@ -2237,8 +2237,8 @@ exclude-result-prefixes="#all" - - + + @@ -2262,7 +2262,7 @@ exclude-result-prefixes="#all" - + @@ -2351,7 +2351,7 @@ exclude-result-prefixes="#all" - + @@ -2394,11 +2394,11 @@ exclude-result-prefixes="#all" - + - + - + @@ -2433,7 +2433,7 @@ exclude-result-prefixes="#all" - + candidate predicate URIs } from BGP triples whose subject is the focus variable; deduped per var. SPARQL ORDER BY uses variables, but the wrapped DESCRIBE returns an unordered RDF graph, so the view sorts by predicates client-side - this map bridges the two. --> - + - + @@ -3084,13 +3084,13 @@ exclude-result-prefixes="#all" - + - - + + - + @@ -3498,7 +3498,7 @@ exclude-result-prefixes="#all" values - a literal, a computed (YEAR(NOW()) AS ?year) - and a view shows resources. Said in the results region, where the empty state would have claimed that nothing matched --> - + @@ -3814,11 +3814,7 @@ exclude-result-prefixes="#all" - - - - - + @@ -3843,11 +3839,7 @@ exclude-result-prefixes="#all" - - - &dct;title - "" - + @@ -4063,4 +4055,4 @@ exclude-result-prefixes="#all" - \ No newline at end of file + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/constructor.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/constructor.xsl index bbaa9ec29d..dbba83dbca 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/constructor.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/constructor.xsl @@ -381,23 +381,24 @@ exclude-result-prefixes="#all" - + +
- + - +
- - + +
@@ -448,9 +449,9 @@ exclude-result-prefixes="#all"
- - - + + + @@ -2533,38 +2533,7 @@ WHERE - - - bgp - - - - ?p - ?o - - - - - - - update - - - insertdelete - - - - - - - - - - - - - - + @@ -2752,4 +2721,4 @@ WHERE - \ No newline at end of file + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/functions.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/functions.xsl index eecead15e3..4949027c90 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/functions.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/functions.xsl @@ -321,7 +321,8 @@ exclude-result-prefixes="#all" - + @@ -434,7 +435,7 @@ exclude-result-prefixes="#all" - + @@ -456,56 +457,57 @@ exclude-result-prefixes="#all" + triple - _: + - + - + - _: + - + - - ""^^ + + - - ""^^ + + - ""@ + - ""@ + - "" + @@ -542,48 +544,50 @@ exclude-result-prefixes="#all" - + + triple - _: + - + - + - _: + - + - ""^^ + + - ""@ + - "" + @@ -596,9 +600,10 @@ exclude-result-prefixes="#all" - - ?p - ?o + triple + + + @@ -608,7 +613,8 @@ exclude-result-prefixes="#all" - bgp + pattern + bgp @@ -622,7 +628,7 @@ exclude-result-prefixes="#all" - + @@ -634,23 +640,29 @@ exclude-result-prefixes="#all" update - insertdelete - - - - - - - - - + + + updateOperation + modify + + + + pattern + group + + + + datasetClauses + + +
- + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/map.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/map.xsl index 8037b8d7dd..13ccc731df 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/map.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/map.xsl @@ -132,7 +132,7 @@ exclude-result-prefixes="#all" - + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/modal.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/modal.xsl index 9b5d49e16a..6178f06c2d 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/modal.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/modal.xsl @@ -999,63 +999,57 @@ LIMIT 10 + + - bgp - - - - ?p - ?o - - - - - filter + pattern + filter - operation + expression + operation notin - ?p - - &dct;created - &dct;modified - &sioc;has_parent - &sioc;has_container - &dct;creator - &acl;owner - + + + - filter + pattern + filter - operation + expression + operation ! - operation + expression + operation strstarts - operation + expression + operation str - ?p + - operation + expression + operation concat - operation + expression + operation str - http://www.w3.org/1999/02/22-rdf-syntax-ns# + - "_" + @@ -1530,7 +1524,7 @@ LIMIT 10 - + - + @@ -878,7 +878,7 @@ ORDER BY DESC(?created) - + @@ -1415,4 +1415,4 @@ ORDER BY DESC(?created) on-failure="ldh:promise-failure($container, 'results-not-loaded', ?)"/> - \ No newline at end of file + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl index 001a69c2b4..d43bc2130f 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl @@ -45,7 +45,7 @@ extension-element-prefixes="ixsl" - ? + @@ -59,21 +59,18 @@ extension-element-prefixes="ixsl" - + - - - - - - - - + + + + + + + - - @@ -84,24 +81,21 @@ extension-element-prefixes="ixsl" - + - - - - - - - - + + + + + + + - - - @@ -109,9 +103,77 @@ extension-element-prefixes="ixsl" - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + wildcard + + + pattern + group + + + + + @@ -168,7 +232,7 @@ extension-element-prefixes="ixsl" - + @@ -180,7 +244,7 @@ extension-element-prefixes="ixsl" - + @@ -192,33 +256,43 @@ extension-element-prefixes="ixsl" - union + pattern + union - bgp + pattern + bgp - - - + triple + + + - graph + pattern + graph - bgp + pattern + bgp - - - + triple + + + - + + term + variable + + @@ -263,20 +337,25 @@ extension-element-prefixes="ixsl" - SELECT + query + select - - + + - - - + + + pattern + group + - union + pattern + union - group + pattern + group @@ -288,8 +367,15 @@ extension-element-prefixes="ixsl" - - + + + + + solutionModifier + limitOffset + + + @@ -304,18 +390,37 @@ extension-element-prefixes="ixsl" query - SELECT + select - + - ""^^&xsd;boolean - + pattern + bind + + term + literal + + + term + namedNode + &xsd;boolean + + + + term + variable + inverse + - + + pattern + group + - group + pattern + group @@ -340,51 +445,58 @@ extension-element-prefixes="ixsl" - - filter + + pattern + filter - operation + expression + operation ! - operation + expression + operation isliteral - + - - filter + + pattern + filter - operation + expression + patternOperation exists - - - group - - - - - - - - - - + + pattern + group + + + + + + + + + - - - - + + + + + solutionModifier + group + - + @@ -398,7 +510,7 @@ extension-element-prefixes="ixsl" - + @@ -432,7 +544,7 @@ extension-element-prefixes="ixsl" - + @@ -449,49 +561,61 @@ extension-element-prefixes="ixsl" - union + pattern + union - bgp + pattern + bgp - ? - - ? + triple + + + - ? - - ? + triple + + + - graph + pattern + graph - bgp + pattern + bgp - ? - - ? + triple + + + - ? - - ? + triple + + + - ? + + term + variable + + @@ -507,24 +631,29 @@ extension-element-prefixes="ixsl" - + - - - ? - - + + solutionModifier + order + + + + false + + + - + @@ -532,9 +661,10 @@ extension-element-prefixes="ixsl" - + - ? + + false @@ -544,10 +674,10 @@ extension-element-prefixes="ixsl" - + - + @@ -555,13 +685,10 @@ extension-element-prefixes="ixsl" - + - - - ? - + @@ -573,27 +700,16 @@ extension-element-prefixes="ixsl" - + + - + - - true - + - - - - - - - - - - @@ -615,26 +731,32 @@ extension-element-prefixes="ixsl" - ? + + pattern + bind - ? - aggregate + expression + aggregate count true + - ? + + pattern + bind - ? - aggregate + expression + aggregate sample false + - ? + @@ -646,28 +768,33 @@ extension-element-prefixes="ixsl" - - - - - - ? + + + + + + solutionModifier + group + - - - - - - ? - + + + solutionModifier + order + + + + + + - - + + - + @@ -679,49 +806,65 @@ extension-element-prefixes="ixsl" predicate bound by VALUES --> - ? - ? - ? + triple + + + - + - optional + pattern + optional - values + pattern + values + - + + term + namedNode + + - union + pattern + union - bgp + pattern + bgp - graph + pattern + graph - bgp + pattern + bgp - ? + + term + variable + + @@ -731,15 +874,16 @@ extension-element-prefixes="ixsl" - + + - + - ? + @@ -754,11 +898,12 @@ extension-element-prefixes="ixsl" - - + + - + @@ -770,15 +915,14 @@ extension-element-prefixes="ixsl" - filter + pattern + filter - operation + expression + operation in - ? - - - + @@ -787,13 +931,21 @@ extension-element-prefixes="ixsl" - + + + + + + + + + @@ -801,57 +953,33 @@ extension-element-prefixes="ixsl" - + + - - + - - + + - - + + + - - - - - - - "" - - - - @ - - - - - ^^ - - - - - - - - - - + + @@ -871,21 +999,27 @@ extension-element-prefixes="ixsl" query - SELECT + select - ? + - + - - - group - - - - - + + pattern + group + + + pattern + group + + + + + + + @@ -901,7 +1035,7 @@ extension-element-prefixes="ixsl" - + @@ -920,23 +1054,25 @@ extension-element-prefixes="ixsl" + pattern + bind - + expression + aggregate + count + true + - ? - + - * + wildcard - - aggregate - count - true + - ? + @@ -969,7 +1105,7 @@ extension-element-prefixes="ixsl" - + @@ -988,7 +1124,7 @@ extension-element-prefixes="ixsl" - + @@ -996,11 +1132,18 @@ extension-element-prefixes="ixsl" - + true - 2 + + + + solutionModifier + limitOffset + 2 + + @@ -1011,13 +1154,13 @@ extension-element-prefixes="ixsl" - ? + - + @@ -1030,38 +1173,44 @@ extension-element-prefixes="ixsl" - graph + pattern + graph - bgp + pattern + bgp - ? - ? - ? + triple + + + - ? + - graph + pattern + graph - bgp + pattern + bgp - ? - &sioc;has_container - ? + triple + + + - ? + @@ -1076,7 +1225,7 @@ extension-element-prefixes="ixsl" - + @@ -1085,14 +1234,16 @@ extension-element-prefixes="ixsl" - - - _: + triple + + + - _: - &rdf;type - + triple + + + @@ -1107,7 +1258,7 @@ extension-element-prefixes="ixsl" - + @@ -1116,16 +1267,18 @@ extension-element-prefixes="ixsl" - filter + pattern + filter - operation + expression + operation regex - ? - "" + + - "" + @@ -1145,8 +1298,9 @@ extension-element-prefixes="ixsl" - + argument has to round-trip through the generator. The literal carries the query text as is: Traqula's + generator escapes it on output --> + @@ -1154,13 +1308,10 @@ extension-element-prefixes="ixsl" - bgp + pattern + bgp - - ? - http://jena.apache.org/text#query - "" - + @@ -1168,7 +1319,7 @@ extension-element-prefixes="ixsl" - + @@ -1176,7 +1327,7 @@ extension-element-prefixes="ixsl" - + @@ -1184,15 +1335,30 @@ extension-element-prefixes="ixsl" - values + pattern + values + + + + + - - - + + + + + + + + + + + + @@ -1201,4 +1367,4 @@ extension-element-prefixes="ixsl" - \ No newline at end of file + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/tree.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/tree.xsl index ec6bc4c6e7..aa94d43992 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/tree.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/tree.xsl @@ -87,8 +87,8 @@ exclude-result-prefixes="#all" concept's. Scoping both to one GRAPH silently drops every child linked from above - measured against a fixture where it returned one top concept of two. --> diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl index c183785c2b..e094755474 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl @@ -469,13 +469,58 @@ exclude-result-prefixes="#all" CONSTRUCT templates are expanded onto a single instance — one bnode prototype typed with all the classes, value-range markers as sibling Descriptions in the same document. --> - - - + + + + + + + + + + + + + + + + + triple + + + + + + + + + + + + + + + + - + + + + + + + + + + + + - + - + @@ -506,57 +553,41 @@ exclude-result-prefixes="#all" - - + + + - + - - - + - - - - - + - - - - - - - - - + + + - - - - - - - - + + + - - + + - - + + - + @@ -579,21 +610,22 @@ exclude-result-prefixes="#all" - + Constructor skipped: a non-empty WHERE clause cannot be instantiated: - - + + - - Constructor template triple skipped: variable predicate + + Constructor template triple skipped: variable predicate - - - + triple + + + @@ -606,18 +638,19 @@ exclude-result-prefixes="#all" - - + + - + - _:instance - &rdf;type - + triple + + + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/layout.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/layout.xsl index bd2f42e1ad..18530b980e 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/layout.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/layout.xsl @@ -312,7 +312,7 @@ exclude-result-prefixes="#all"> - + @@ -397,8 +397,8 @@ exclude-result-prefixes="#all"> - - + + @@ -960,4 +960,4 @@ WHERE
- \ No newline at end of file + diff --git a/src/test/java/com/atomgraph/linkeddatahub/writer/function/ParseQueryTest.java b/src/test/java/com/atomgraph/linkeddatahub/writer/function/ParseQueryTest.java new file mode 100644 index 0000000000..d75c5e99bb --- /dev/null +++ b/src/test/java/com/atomgraph/linkeddatahub/writer/function/ParseQueryTest.java @@ -0,0 +1,67 @@ +/* + * Copyright 2026 Martynas Jusevičius + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.atomgraph.linkeddatahub.writer.function; + +import net.sf.saxon.s9api.SaxonApiException; +import net.sf.saxon.s9api.XdmAtomicValue; +import net.sf.saxon.s9api.XdmValue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Tests the server-side construct subset emitted in the Traqula AST shape. + */ +public class ParseQueryTest +{ + + private String parse(String query) throws SaxonApiException + { + XdmValue result = new ParseQuery().call(new XdmValue[] { new XdmAtomicValue(query) }); + return result.itemAt(0).getStringValue().replaceAll("\\s+", ""); + } + + @Test + public void testConstructTemplateUsesTypedTraqulaTerms() throws SaxonApiException + { + String json = parse("CONSTRUCT { ?s \"hello\"@en } WHERE { }"); + + assertTrue(json.contains("\"subType\":\"construct\"")); + assertTrue(json.contains("\"template\":{\"type\":\"pattern\",\"subType\":\"bgp\"")); + assertTrue(json.contains("\"subType\":\"variable\",\"value\":\"s\"")); + assertTrue(json.contains("\"subType\":\"namedNode\",\"value\":\"https://example.com/p\"")); + assertTrue(json.contains("\"subType\":\"literal\",\"value\":\"hello\",\"langOrIri\":\"en\""), json); + assertTrue(json.contains("\"where\":{\"type\":\"pattern\",\"subType\":\"group\",\"patterns\":[]")); + } + + @Test + public void testNonemptyWhereIsMarkedAsNonInstantiable() throws SaxonApiException + { + String json = parse("CONSTRUCT { ?s ?o } WHERE { ?s ?p ?o }"); + + assertTrue(json.contains("\"where\":{\"type\":\"pattern\",\"subType\":\"group\",\"patterns\":[{}]"), json); + } + + @Test + public void testBlankNodesCarryTheirLabel() throws SaxonApiException + { + String json = parse("CONSTRUCT { ?this [ a ] } WHERE { }"); + + assertTrue(json.contains("\"subType\":\"blankNode\",\"label\":"), json); + assertTrue(!json.contains("\"subType\":\"blankNode\",\"value\":"), json); + assertTrue(!json.contains("\"loc\""), json); + } + +} diff --git a/tests/http/static/content-type-charset.sh b/tests/http/static/content-type-charset.sh index 83aea812a9..b072e781e5 100755 --- a/tests/http/static/content-type-charset.sh +++ b/tests/http/static/content-type-charset.sh @@ -25,7 +25,7 @@ clear_ontology declare -a expectations=( "static/com/atomgraph/linkeddatahub/css/ldh.css|text/css;charset=UTF-8" "static/com/atomgraph/linkeddatahub/xsl/client.xsl|text/xsl;charset=UTF-8" - "static/com/atomgraph/linkeddatahub/js/SPARQL.js|text/javascript;charset=UTF-8" + "static/com/atomgraph/linkeddatahub/js/traqula.min.js|text/javascript;charset=UTF-8" "static/com/atomgraph/linkeddatahub/js/saxon-js/LICENSE.txt|text/plain;charset=UTF-8" "static/com/atomgraph/linkeddatahub/css/ol.css.map|application/json" "AGENTS.md|text/markdown;charset=UTF-8" diff --git a/tests/load/page-load/measure.mjs b/tests/load/page-load/measure.mjs index f953dafb21..0d03184d3f 100644 --- a/tests/load/page-load/measure.mjs +++ b/tests/load/page-load/measure.mjs @@ -101,7 +101,9 @@ async function load(browser, url, exempt) { if (response.status() === 429) refused++; statuses.set(keyOf(request), [...(statuses.get(keyOf(request)) ?? []), response.status()]); }); - page.on('pageerror', () => errors++); + const errorMessages = []; + page.on('pageerror', error => { errors++; errorMessages.push(error.message); }); + page.on('console', message => { if (message.type() === 'error') errorMessages.push(message.text()); }); await page.goto(url, { waitUntil: 'load', timeout: LOAD_TIMEOUT_MS }); const deadline = t0 + LOAD_TIMEOUT_MS; @@ -111,9 +113,10 @@ async function load(browser, url, exempt) { const timedOut = Date.now() >= deadline; const lost = [...statuses.entries()].filter(([, s]) => s.includes(429) && s.at(-1) === 429).map(([key]) => key); - const failures = await page.locator('.ldh-failure').count(); + const failureTexts = await page.locator('.ldh-failure').allTextContents(); + const failures = failureTexts.length; await context.close(); - return { requests, refused, lost: lost.length, lostRequests: lost, failures, errors, timedOut, settleMs: last - t0 }; + return { requests, refused, lost: lost.length, lostRequests: lost, failures, failureTexts, errors, errorMessages, timedOut, settleMs: last - t0 }; } const { exempt, limited } = await nginxAddresses(); @@ -142,6 +145,9 @@ for (let i = 1; i <= LOADS; i++) { console.log(`load ${i}/${LOADS} ${url}`); console.log(` exempt ${e.requests} requests, ${e.refused} refused, ${e.lost} lost, ${e.failures} failures, settled ${e.settleMs} ms`); console.log(` limited ${l.requests} requests, ${l.refused} refused, ${l.lost} lost, ${l.failures} failures, settled ${l.settleMs} ms`); + // what a failure said, so a red run names its cause + for (const text of new Set([...e.failureTexts, ...l.failureTexts])) console.log(` DEBUG failure: ${text.replace(/\s+/g, ' ').trim()}`); + for (const text of new Set([...e.errorMessages, ...l.errorMessages])) console.log(` DEBUG error: ${text}`); } } diff --git a/tests/packages/editor/taxonomy/ns.ttl b/tests/packages/editor/taxonomy/ns.ttl index 7060020cea..6d13933343 100644 --- a/tests/packages/editor/taxonomy/ns.ttl +++ b/tests/packages/editor/taxonomy/ns.ttl @@ -215,8 +215,8 @@ skos:hasTopConcept ldh:view :TopConcepts . # fixture, Hot drinks' Narrower block showed 1 child where the tree showed 3, because Coffee and Tea # assert skos:broader upwards, and Juice's Broader block showed nothing while the tree nested it under # Hot drinks. The union stays INSIDE the link's GRAPH rather than becoming a sibling block, because -# the SPARQL.js parse/serialise round-trip merges sibling GRAPH blocks into one and would scope the child's label to -# the link's document. +# the SPARQL.js parse/serialise round-trip views went through merged sibling GRAPH blocks into one and scoped the +# child's label to the link's document. :SelectTopConcepts a sp:Select ; rdfs:label "Select top concepts" ; dct:title "Select top concepts" ; diff --git a/tests/ui/specs/document/blocks/view/projection.spec.mjs b/tests/ui/specs/document/blocks/view/projection.spec.mjs index bdbe0eb985..93970814db 100644 --- a/tests/ui/specs/document/blocks/view/projection.spec.mjs +++ b/tests/ui/specs/document/blocks/view/projection.spec.mjs @@ -2,7 +2,7 @@ // // A view lists the resources its query's first variable binds: it wraps the SELECT in a DESCRIBE // of that variable, and counts it for the pager. The variable may be projected plain, ?resource, -// or as an expression's alias, (?s AS ?resource) - SPARQL.js gives the two in different shapes, +// or as an expression's alias, (?s AS ?resource) - the parser gives the two in different shapes, // and reading only the plain one left the name empty and the whole block failing to render. An // alias is as good a variable as any. What a view cannot show is a first variable that binds // values rather than resources, (YEAR(NOW()) AS ?year): the count finds rows where the DESCRIBE