@ulb-darmstadt/shacl-form 3.2.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{DataFactory as e,Literal as t,NamedNode as n,Store as r,StreamParser as i,Writer as a}from"n3";import{RdfXmlParser as o}from"rdfxml-streaming-parser";import s from"jsonld";import{RokitButton as c,RokitCollapsible as l,RokitDialog as u}from"@ro-kit/ui-widgets";import{v4 as d}from"uuid";var f=`http://www.w3.org/ns/shacl#`,p=`http://datashapes.org/dash#`,m=`http://www.w3.org/2001/XMLSchema#`,h=`http://www.w3.org/1999/02/22-rdf-syntax-ns#`,ee=`http://www.w3.org/2000/01/rdf-schema#`,te=`http://www.w3.org/ns/oa#`,ne=`http://purl.org/dc/terms/`,g=e.namedNode(`loaded-shapes`),_=e.namedNode(`loaded-data`),v=e.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`),y=e.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#langString`),b=e.namedNode(`http://purl.org/dc/terms/conformsTo`),re=e.namedNode(`http://www.w3.org/2000/01/rdf-schema#subClassOf`),x=e.namedNode(`http://www.w3.org/2002/07/owl#imports`),ie=e.namedNode(`http://www.w3.org/2004/02/skos/core#broader`),ae=e.namedNode(`http://www.w3.org/2004/02/skos/core#narrower`),oe=e.namedNode(`http://www.w3.org/ns/shacl#NodeShape`),se=e.namedNode(`http://www.w3.org/ns/shacl#IRI`),S=e.namedNode(`http://www.w3.org/ns/shacl#property`),C=e.namedNode(`http://www.w3.org/ns/shacl#class`),ce=e.namedNode(`http://www.w3.org/ns/shacl#node`),w=e.namedNode(`http://www.w3.org/ns/shacl#targetClass`),le=e.namedNode(`http://www.w3.org/ns/shacl#nodeKind`),ue=e.namedNode(`http://www.w3.org/2001/XMLSchema#string`),de=e.namedNode(`http://www.w3.org/2001/XMLSchema#boolean`),fe=new Set([`http://www.w3.org/2001/XMLSchema#integer`,`http://www.w3.org/2001/XMLSchema#int`,`http://www.w3.org/2001/XMLSchema#short`,`http://www.w3.org/2001/XMLSchema#byte`,`http://www.w3.org/2001/XMLSchema#unsignedInt`,`http://www.w3.org/2001/XMLSchema#unsignedShort`,`http://www.w3.org/2001/XMLSchema#unsignedByte`,`http://www.w3.org/2001/XMLSchema#long`,`http://www.w3.org/2001/XMLSchema#unsignedLong`,`http://www.w3.org/2001/XMLSchema#float`,`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`,`http://www.w3.org/2001/XMLSchema#date`,`http://www.w3.org/2001/XMLSchema#dateTime`]),pe=new Set([`http://www.w3.org/2001/XMLSchema#integer`,`http://www.w3.org/2001/XMLSchema#int`,`http://www.w3.org/2001/XMLSchema#short`,`http://www.w3.org/2001/XMLSchema#byte`,`http://www.w3.org/2001/XMLSchema#unsignedInt`,`http://www.w3.org/2001/XMLSchema#unsignedShort`,`http://www.w3.org/2001/XMLSchema#unsignedByte`,`http://www.w3.org/2001/XMLSchema#long`,`http://www.w3.org/2001/XMLSchema#unsignedLong`,`http://www.w3.org/2001/XMLSchema#float`,`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`]),me=new Set([`http://www.w3.org/2001/XMLSchema#float`,`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`]);function T(e,t,n=f,r){let i=``,a=he(e,t,n,r);return a&&(i=a.value),i}function he(e,t,n=f,r){let i,a=n+t;if(r?.length){for(let t of r)for(let n of e)if(n.predicate.value===a){if(n.object.id.endsWith(`@${t}`))return n.object;n.object.id.indexOf(`@`)<0?i=n.object:i||=n.object}}else for(let t of e)if(t.predicate.value===a)return t.object;return i}function ge(e){e.querySelector(`.editor`)?.focus()}function E(e,t){return T(e,`prefLabel`,`http://www.w3.org/2004/02/skos/core#`,t)||T(e,`label`,`http://www.w3.org/2000/01/rdf-schema#`,t)||T(e,`title`,`http://purl.org/dc/terms/`,t)||T(e,`name`,`http://xmlns.com/foaf/0.1/`,t)}function D(e,t,n){let r=[];for(let i of e)r.push({value:i,label:E(t.getQuads(i,null,null,null),n),children:[]});return r}function O(e,t){for(let n in t){let r=t[n];e.startsWith(r)&&(e=e.slice(r.length))}return e}function _e(e,t,n,r,i=new Set){for(let a of t.owlImports)i.has(a.id)||(i.add(a.id),r.push(...n.getSubjects(v,e,a)));t.parent&&_e(e,t.parent,n,r,i)}function k(e,t){if(t.in){let e=t.config.lists[t.in];return D(e?.length?e:[],t.config.store,t.config.languages)}else{let n=t.config.store.getSubjects(v,e,g);n.push(...t.config.store.getSubjects(v,e,_)),_e(e,t,t.config.store,n);let r=new Map,i=new Map;for(let e of n)r.set(e.id,{value:e,label:E(t.config.store.getQuads(e,null,null,null),t.config.languages),children:[]});for(let e of n){for(let n of t.config.store.getObjects(e,ie,null))r.has(n.id)&&i.set(e.id,n.id);for(let n of t.config.store.getObjects(e,ae,null))r.has(n.id)&&i.set(n.id,e.id);for(let n of t.config.store.getObjects(e,re,null))r.has(n.id)&&i.set(e.id,n.id)}for(let[e,t]of i.entries())r.get(t)?.children?.push(r.get(e));let a=[];for(let[e,t]of r.entries())i.has(e)||a.push(t);for(let n of t.config.store.getSubjects(re,e,null))a.push(...k(n,t));return a}}function A(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`http:`||t.protocol===`https:`}function j(e,t,n){if(t===void 0)return n;if(n===void 0)return t;let r=e.indexOf(t.language);if(r<0)return n;let i=e.indexOf(n.language);return i<0||i>r?t:n}function ve(e,t){let n;for(let r of t)n=j(e,n,r);return n?n.value:``}var M=/^(-?\d{4,}-\d{2}-\d{2})(Z|[+-]\d{2}:\d{2})?$/,ye=/^(-?\d{4,}-\d{2}-\d{2})T(\d{2}:\d{2})(?::(\d{2})(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?$/,be=/^(-?\d{4,}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(\.\d+)?)?$/;function xe(e){let t=e.match(M);if(!t){let t=e.match(ye);return t?{value:t[1],suffix:t[5]||``}:void 0}return{value:t[1],suffix:t[2]||``}}function Se(e){let t=e.match(ye);if(!t){let t=e.match(M);return t?{value:`${t[1]}T00:00:00`,suffix:t[2]||``}:void 0}return{value:`${t[1]}T${t[2]}:${t[3]||`00`}`,suffix:t[5]||``}}function Ce(e,t=``){let n=e.match(M);return n?`${n[1]}${t}`:e}function we(e,t=``){let n=e.match(be);return n?`${n[1]}:${n[2]||`00`}${n[3]||``}${t}`:e}function Te(e){let t=new Set;for(let n of e.getObjects(null,C,g))t.add(n.value);for(let n of e.getObjects(null,w,g))t.add(n.value);return t}function Ee(e,t){return e instanceof Set?[...t].filter(t=>!e.has(t)):[...t].filter(t=>!e.includes(t))}function De(e,{remove:t=!1,ignoreErrors:n=!1}={}){let r={},i=n?()=>!0:(e,t)=>{throw Error(`${e.value} ${t}`)},a=e.getQuads(null,h+`rest`,h+`nil`,null),o=t?[...a]:[];return a.forEach(n=>{let a=[],s=!1,c,l,u=n.graph,d=n.subject;for(;d&&!s;){let t=e.getQuads(null,null,d,null),n=e.getQuads(d,null,null,null).filter(e=>!e.predicate.equals(v)),r,f=null,p=null,m=null;for(let e=0;e<n.length&&!s;e++)r=n[e],r.graph.equals(u)?c?s=i(d,`has non-list arcs out`):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#first`?f?s=i(d,`has multiple rdf:first arcs`):o.push(f=r):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#rest`?p?s=i(d,`has multiple rdf:rest arcs`):o.push(p=r):t.length?s=i(d,`can't be subject and object`):(c=r,l=`subject`):s=i(d,`not confined to single graph`);for(let e=0;e<t.length&&!s;++e)r=t[e],c?s=i(d,`can't have coreferences`):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#rest`?m?s=i(d,`has incoming rdf:rest arcs`):m=r:(c=r,l=`object`);f?a.unshift(f.object):s=i(d,`has no list head`),d=m&&m.subject}s?t=!1:c&&(r[c[l].value]=a)}),t&&e.removeQuads(o),r}var N={},P={};async function F(e){return`rdf`in e?L(e.rdf):e.rdfUrlResolver?L(await e.rdfUrlResolver(e.url)):I(e.url,e.proxy)}async function I(e,t){return e in N||(N[e]=(async()=>{let n=e;t&&(n=t+encodeURIComponent(e));let r=await fetch(n,{headers:{Accept:`text/turtle, application/trig, application/n-triples, application/n-quads, text/n3, application/ld+json`}});return r.ok?L(await r.text()):(console.warn(`failed fetching RDF from`,e),[])})()),N[e]}async function L(t){if(!t.trim())return[];let n=Oe(t);if(n===`json`)try{t=await s.toRDF(JSON.parse(t),{format:`application/n-quads`})}catch(e){console.error(e)}let r=[];return await new Promise((a,s)=>{let c=n===`xml`?new o:new i;c.on(`data`,t=>{r.push(e.quad(t.subject,t.predicate,t.object,t.graph))}).on(`error`,e=>{s(e)}).on(`prefix`,(e,t)=>{e&&(P[e]=t)}).on(`end`,()=>{a(null)}),c.write(t),c.end()}),r}function Oe(e){return/^\s*[\\[{]/.test(e)?`json`:/^\s*<\?xml/.test(e)?`xml`:`ttl`}var ke={[`${f}name`]:(e,t)=>{let n=t;e.name=j(e.config.languages,e.name,n)},[`${f}description`]:(e,t)=>{let n=t;e.description=j(e.config.languages,e.description,n)},[`${f}path`]:(e,t)=>{e.path=t.value},[`${f}group`]:(e,t)=>{e.group=t.id},[`${f}datatype`]:(e,t)=>{e.datatype=t},[`${f}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${f}minCount`]:(e,t)=>{e.minCount=parseInt(t.value)},[`${f}maxCount`]:(e,t)=>{e.maxCount=parseInt(t.value)},[`${f}minLength`]:(e,t)=>{e.minLength=parseInt(t.value)},[`${f}maxLength`]:(e,t)=>{e.maxLength=parseInt(t.value)},[`${f}minInclusive`]:(e,t)=>{e.minInclusive=parseInt(t.value)},[`${f}maxInclusive`]:(e,t)=>{e.maxInclusive=parseInt(t.value)},[`${f}minExclusive`]:(e,t)=>{e.minExclusive=parseInt(t.value)},[`${f}maxExclusive`]:(e,t)=>{e.maxExclusive=parseInt(t.value)},[`${f}pattern`]:(e,t)=>{e.pattern=t.value},[`${f}order`]:(e,t)=>{e.order=parseInt(t.value)},[`${p}singleLine`]:(e,t)=>{e.singleLine=t.value===`true`},[`${p}readonly`]:(e,t)=>{e.readonly=t.value===`true`},[`${te}styleClass`]:(e,t)=>{e.cssClass=t.value},[`${f}in`]:(e,t)=>{e.in=t.value},[`${f}languageIn`]:(e,t)=>{e.languageIn=e.config.lists[t.value],e.datatype=y},[`${f}defaultValue`]:(e,t)=>{e.defaultValue=t},[`${f}hasValue`]:(e,t)=>{e.hasValue=t},[`${f}node`]:(e,t)=>{e.node=t,e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${f}and`]:(e,t)=>{e.and=t.value;let n=e.config.lists[e.and];if(n?.length)for(let t of n)e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${f}qualifiedValueShape`]:(e,t)=>{let n=e.config.getNodeTemplate(t,e);e.qualifiedValueShape=n,e.nodeShapes.add(n)},[`${f}qualifiedMinCount`]:(e,t)=>{e.qualifiedMinCount=parseInt(t.value)},[`${f}qualifiedMaxCount`]:(e,t)=>{e.qualifiedMaxCount=parseInt(t.value)},[x.id]:(e,t)=>{e.owlImports.add(t)},[C.id]:(e,t)=>{e.class=t;let n=e.config.store.getSubjects(w,t,null);n.length>0&&(e.node=n[0])},[`${f}or`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.or=n:console.error(`list for sh:or not found:`,t.value,`existing lists:`,e.config.lists)},[`${f}xone`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.xone=n:console.error(`list for sh:xone not found:`,t.value,`existing lists:`,e.config.lists)}},Ae=class{constructor(e,t){this.label=``,this.nodeShapes=new Set,this.owlImports=new Set,this.id=e,this.parent=t,this.config=t.config,this.config.registerPropertyTemplate(this),B(this,this.config.store.getQuads(e,null,null,null))}};function R(e){return Math.max(e.minCount??0,e.qualifiedMinCount??0)}function je(e){return Math.min(e.maxCount??2**53-1,e.qualifiedMaxCount??2**53-1)}function z(e){let t=Object.assign({},e);return t.nodeShapes=new Set(e.nodeShapes),t.owlImports=new Set(e.owlImports),e.languageIn&&(t.languageIn=[...e.languageIn]),e.or&&(t.or=[...e.or]),e.xone&&(t.xone=[...e.xone]),t}function B(e,t){for(let n of t)ke[n.predicate.id]?.call(e,e,n.object);return e.label=e.name?.value||E(t,e.config.languages),e.label||=e.path?O(e.path,P):`unknown`,e}function Me(e,t){let n=t,r=e;for(let e in t)if(e!==`parent`&&e!==`config`&&e!==`id`){let t=n[e];if(t!==void 0&&t!==``)if(Array.isArray(t)){let n=r[e];Array.isArray(n)?n.push(...t):r[e]=[...t]}else if(t instanceof Set&&t.size){let n=r[e];r[e]=new Set([...n instanceof Set?n:[],...t])}else r[e]=t}}var Ne=`modulepreload`,Pe=function(e){return`/`+e},Fe={},V=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Pe(t,n),t=s(t),t in Fe)return;Fe[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Ne,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function H(e,t,n){let r=document.createElement(`div`);r.classList.add(`shacl-or-constraint`),r.setAttribute(`part`,`constraint`);let i=[];if(t instanceof $){let a=[],o=!1;e.length&&(o=n.store.countQuads(e[0],S,null,null)>0);for(let r=0;r<e.length;r++)if(o){let o=n.store.getObjects(e[r],S,null),s=[],c=``;for(let e of o){let r=new K(n.getPropertyTemplate(e,t.template),t);s.push(r),c+=(c.length>0?` / `:``)+r.template.label}a.push(s),i.push({label:c,value:r.toString()})}else{let o=e[r],s=new K(n.getPropertyTemplate(o,t.template),t);a.push([s]),i.push({label:s.template.label,value:r.toString()})}let s=n.theme.createListEditor(`Please choose`,null,!1,i);s.setAttribute(`part`,`constraint-editor`);let c=s.querySelector(`.editor`);c.onchange=async()=>{if(c.value){let e=a[parseInt(c.value)];if(n.queryMode){let{activateNodeConstraintOption:t}=await V(async()=>{let{activateNodeConstraintOption:e}=await import(`./mode-BriAnl-6.js`);return{activateNodeConstraintOption:e}},[]);await t(e,r);return}let i;if(e.length){for(let n of e)await n.bindValues(t.nodeId,!1);i=e[0],r.replaceWith(e[0]),i.updateControls()}for(let t=1;t<e.length;t++)i.after(e[t]),i=e[t],i.updateControls()}},r.appendChild(s)}else{let a=[];for(let t=0;t<e.length;t++){let r=n.store.getQuads(e[t],null,null,null);if(r.length){a.push(r);let e=E(r,n.languages);for(let t of r)t.predicate.equals(ce)&&(e=E(n.store.getQuads(t.object,null,null,null),n.languages));i.push({label:e||O(r[0].predicate.value,P)+` = `+O(r[0].object.value,P),value:t.toString()})}}let o=n.theme.createListEditor(t.template.label+`?`,null,!1,i,t.template);o.setAttribute(`part`,`constraint-editor`);let s=o.querySelector(`.editor`);s.onchange=async()=>{if(s.value){let e=B(z(t.template),a[parseInt(s.value)]);if(n.queryMode){let{activatePropertyConstraintOption:n}=await V(async()=>{let{activatePropertyConstraintOption:e}=await import(`./mode-BriAnl-6.js`);return{activatePropertyConstraintOption:e}},[]);await n(e,t,r);return}let i=await q(e,void 0,!0),o=i.querySelector(`:scope > label`);o&&o.classList.add(`persistent`),r.replaceWith(i)}},r.appendChild(o)}return r}function Ie(e,t,n){if(t.termType===`Literal`){let r=t.datatype;for(let t of e){let e=n.store.getQuads(t,null,null,null);for(let t of e)if(t.predicate.value===`http://www.w3.org/ns/shacl#datatype`&&t.object.equals(r))return e}}else{let r=n.store.getObjects(t,v,null);for(let t of e){let e=n.store.getQuads(t,null,null,null);for(let t of e)if(r.length>0){if(t.predicate.value===`http://www.w3.org/ns/shacl#node`){for(let i of r)if(n.store.getQuads(t.object,w,i,null).length>0)return e}if(t.predicate.equals(C)){for(let n of r)if(t.object.equals(n))return e}}else if(t.predicate.equals(le)&&t.object.equals(se))return e}}return console.error(`couldn't resolve sh:or/sh:xone on property for value`,t),[]}function Le(e,t,n){for(let r of e){let e=!1,i=n.store.getObjects(r,S,null);for(let r of i){let i=n.store.getObjects(r,`${f}path`,null);for(let r of i)if(e=n.store.countQuads(t,r,null,null)>0,e)break}if(e)return i}return console.error(`couldn't resolve sh:or/sh:xone on node for value`,t),[]}var Re=`:host {
1
+ import{DataFactory as e,Literal as t,NamedNode as n,Store as r,StreamParser as i,Writer as a}from"n3";import{RdfXmlParser as o}from"rdfxml-streaming-parser";import s from"jsonld";import{RokitButton as c,RokitCollapsible as l,RokitDialog as u}from"@ro-kit/ui-widgets";import{v4 as d}from"uuid";var f=`http://www.w3.org/ns/shacl#`,p=`http://datashapes.org/dash#`,m=`http://www.w3.org/2001/XMLSchema#`,h=`http://www.w3.org/1999/02/22-rdf-syntax-ns#`,ee=`http://www.w3.org/2000/01/rdf-schema#`,te=`http://www.w3.org/ns/oa#`,ne=`http://purl.org/dc/terms/`,g=e.namedNode(`loaded-shapes`),_=e.namedNode(`loaded-data`),v=e.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`),y=e.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#langString`),b=e.namedNode(`http://purl.org/dc/terms/conformsTo`),re=e.namedNode(`http://www.w3.org/2000/01/rdf-schema#subClassOf`),x=e.namedNode(`http://www.w3.org/2002/07/owl#imports`),ie=e.namedNode(`http://www.w3.org/2004/02/skos/core#broader`),ae=e.namedNode(`http://www.w3.org/2004/02/skos/core#narrower`),oe=e.namedNode(`http://www.w3.org/ns/shacl#NodeShape`),se=e.namedNode(`http://www.w3.org/ns/shacl#IRI`),S=e.namedNode(`http://www.w3.org/ns/shacl#property`),C=e.namedNode(`http://www.w3.org/ns/shacl#class`),ce=e.namedNode(`http://www.w3.org/ns/shacl#node`),w=e.namedNode(`http://www.w3.org/ns/shacl#targetClass`),le=e.namedNode(`http://www.w3.org/ns/shacl#nodeKind`),ue=e.namedNode(`http://www.w3.org/2001/XMLSchema#string`),de=e.namedNode(`http://www.w3.org/2001/XMLSchema#boolean`),fe=new Set([`http://www.w3.org/2001/XMLSchema#integer`,`http://www.w3.org/2001/XMLSchema#int`,`http://www.w3.org/2001/XMLSchema#short`,`http://www.w3.org/2001/XMLSchema#byte`,`http://www.w3.org/2001/XMLSchema#unsignedInt`,`http://www.w3.org/2001/XMLSchema#unsignedShort`,`http://www.w3.org/2001/XMLSchema#unsignedByte`,`http://www.w3.org/2001/XMLSchema#long`,`http://www.w3.org/2001/XMLSchema#unsignedLong`,`http://www.w3.org/2001/XMLSchema#float`,`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`,`http://www.w3.org/2001/XMLSchema#date`,`http://www.w3.org/2001/XMLSchema#dateTime`]),pe=new Set([`http://www.w3.org/2001/XMLSchema#integer`,`http://www.w3.org/2001/XMLSchema#int`,`http://www.w3.org/2001/XMLSchema#short`,`http://www.w3.org/2001/XMLSchema#byte`,`http://www.w3.org/2001/XMLSchema#unsignedInt`,`http://www.w3.org/2001/XMLSchema#unsignedShort`,`http://www.w3.org/2001/XMLSchema#unsignedByte`,`http://www.w3.org/2001/XMLSchema#long`,`http://www.w3.org/2001/XMLSchema#unsignedLong`,`http://www.w3.org/2001/XMLSchema#float`,`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`]),me=new Set([`http://www.w3.org/2001/XMLSchema#float`,`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`]);function T(e,t,n=f,r){let i=``,a=he(e,t,n,r);return a&&(i=a.value),i}function he(e,t,n=f,r){let i,a=n+t;if(r?.length){for(let t of r)for(let n of e)if(n.predicate.value===a){if(n.object.id.endsWith(`@${t}`))return n.object;n.object.id.indexOf(`@`)<0?i=n.object:i||=n.object}}else for(let t of e)if(t.predicate.value===a)return t.object;return i}function ge(e){e.querySelector(`.editor`)?.focus()}function E(e,t){return T(e,`prefLabel`,`http://www.w3.org/2004/02/skos/core#`,t)||T(e,`label`,`http://www.w3.org/2000/01/rdf-schema#`,t)||T(e,`title`,`http://purl.org/dc/terms/`,t)||T(e,`name`,`http://xmlns.com/foaf/0.1/`,t)}function D(e,t,n){let r=[];for(let i of e)r.push({value:i,label:E(t.getQuads(i,null,null,null),n),children:[]});return r}function O(e,t){for(let n in t){let r=t[n];e.startsWith(r)&&(e=e.slice(r.length))}return e}function _e(e,t,n,r,i=new Set){for(let a of t.owlImports)i.has(a.id)||(i.add(a.id),r.push(...n.getSubjects(v,e,a)));t.parent&&_e(e,t.parent,n,r,i)}function k(e,t){if(t.in){let e=t.config.lists[t.in];return D(e?.length?e:[],t.config.store,t.config.languages)}else{let n=t.config.store.getSubjects(v,e,g);n.push(...t.config.store.getSubjects(v,e,_)),_e(e,t,t.config.store,n);let r=new Map,i=new Map;for(let e of n)r.set(e.id,{value:e,label:E(t.config.store.getQuads(e,null,null,null),t.config.languages),children:[]});for(let e of n){for(let n of t.config.store.getObjects(e,ie,null))r.has(n.id)&&i.set(e.id,n.id);for(let n of t.config.store.getObjects(e,ae,null))r.has(n.id)&&i.set(n.id,e.id);for(let n of t.config.store.getObjects(e,re,null))r.has(n.id)&&i.set(e.id,n.id)}for(let[e,t]of i.entries())r.get(t)?.children?.push(r.get(e));let a=[];for(let[e,t]of r.entries())i.has(e)||a.push(t);for(let n of t.config.store.getSubjects(re,e,null))a.push(...k(n,t));return a}}function A(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`http:`||t.protocol===`https:`}function j(e,t,n){if(t===void 0)return n;if(n===void 0)return t;let r=e.indexOf(t.language);if(r<0)return n;let i=e.indexOf(n.language);return i<0||i>r?t:n}function ve(e,t){let n;for(let r of t)n=j(e,n,r);return n?n.value:``}var M=/^(-?\d{4,}-\d{2}-\d{2})(Z|[+-]\d{2}:\d{2})?$/,ye=/^(-?\d{4,}-\d{2}-\d{2})T(\d{2}:\d{2})(?::(\d{2})(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?$/,be=/^(-?\d{4,}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(\.\d+)?)?$/;function xe(e){let t=e.match(M);if(!t){let t=e.match(ye);return t?{value:t[1],suffix:t[5]||``}:void 0}return{value:t[1],suffix:t[2]||``}}function Se(e){let t=e.match(ye);if(!t){let t=e.match(M);return t?{value:`${t[1]}T00:00:00`,suffix:t[2]||``}:void 0}return{value:`${t[1]}T${t[2]}:${t[3]||`00`}`,suffix:t[5]||``}}function Ce(e,t=``){let n=e.match(M);return n?`${n[1]}${t}`:e}function we(e,t=``){let n=e.match(be);return n?`${n[1]}:${n[2]||`00`}${n[3]||``}${t}`:e}function Te(e){let t=new Set;for(let n of e.getObjects(null,C,g))t.add(n.value);for(let n of e.getObjects(null,w,g))t.add(n.value);return t}function Ee(e,t){return e instanceof Set?[...t].filter(t=>!e.has(t)):[...t].filter(t=>!e.includes(t))}function De(e,{remove:t=!1,ignoreErrors:n=!1}={}){let r={},i=n?()=>!0:(e,t)=>{throw Error(`${e.value} ${t}`)},a=e.getQuads(null,h+`rest`,h+`nil`,null),o=t?[...a]:[];return a.forEach(n=>{let a=[],s=!1,c,l,u=n.graph,d=n.subject;for(;d&&!s;){let t=e.getQuads(null,null,d,null),n=e.getQuads(d,null,null,null).filter(e=>!e.predicate.equals(v)),r,f=null,p=null,m=null;for(let e=0;e<n.length&&!s;e++)r=n[e],r.graph.equals(u)?c?s=i(d,`has non-list arcs out`):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#first`?f?s=i(d,`has multiple rdf:first arcs`):o.push(f=r):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#rest`?p?s=i(d,`has multiple rdf:rest arcs`):o.push(p=r):t.length?s=i(d,`can't be subject and object`):(c=r,l=`subject`):s=i(d,`not confined to single graph`);for(let e=0;e<t.length&&!s;++e)r=t[e],c?s=i(d,`can't have coreferences`):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#rest`?m?s=i(d,`has incoming rdf:rest arcs`):m=r:(c=r,l=`object`);f?a.unshift(f.object):s=i(d,`has no list head`),d=m&&m.subject}s?t=!1:c&&(r[c[l].value]=a)}),t&&e.removeQuads(o),r}var N={},P={};async function F(e){return`rdf`in e?L(e.rdf):e.rdfUrlResolver?L(await e.rdfUrlResolver(e.url)):I(e.url,e.proxy)}async function I(e,t){return e in N||(N[e]=(async()=>{let n=e;t&&(n=t+encodeURIComponent(e));let r=await fetch(n,{headers:{Accept:`text/turtle, application/trig, application/n-triples, application/n-quads, text/n3, application/ld+json`}});return r.ok?L(await r.text()):(console.warn(`failed fetching RDF from`,e),[])})()),N[e]}async function L(t){if(!t.trim())return[];let n=Oe(t);if(n===`json`)try{t=await s.toRDF(JSON.parse(t),{format:`application/n-quads`})}catch(e){console.error(e)}let r=[];return await new Promise((a,s)=>{let c=n===`xml`?new o:new i;c.on(`data`,t=>{r.push(e.quad(t.subject,t.predicate,t.object,t.graph))}).on(`error`,e=>{s(e)}).on(`prefix`,(e,t)=>{e&&(P[e]=t)}).on(`end`,()=>{a(null)}),c.write(t),c.end()}),r}function Oe(e){return/^\s*[\\[{]/.test(e)?`json`:/^\s*<\?xml/.test(e)?`xml`:`ttl`}var ke={[`${f}name`]:(e,t)=>{let n=t;e.name=j(e.config.languages,e.name,n)},[`${f}description`]:(e,t)=>{let n=t;e.description=j(e.config.languages,e.description,n)},[`${f}path`]:(e,t)=>{e.path=t.value},[`${f}group`]:(e,t)=>{e.group=t.id},[`${f}datatype`]:(e,t)=>{e.datatype=t},[`${f}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${f}minCount`]:(e,t)=>{e.minCount=parseInt(t.value)},[`${f}maxCount`]:(e,t)=>{e.maxCount=parseInt(t.value)},[`${f}minLength`]:(e,t)=>{e.minLength=parseInt(t.value)},[`${f}maxLength`]:(e,t)=>{e.maxLength=parseInt(t.value)},[`${f}minInclusive`]:(e,t)=>{e.minInclusive=parseInt(t.value)},[`${f}maxInclusive`]:(e,t)=>{e.maxInclusive=parseInt(t.value)},[`${f}minExclusive`]:(e,t)=>{e.minExclusive=parseInt(t.value)},[`${f}maxExclusive`]:(e,t)=>{e.maxExclusive=parseInt(t.value)},[`${f}pattern`]:(e,t)=>{e.pattern=t.value},[`${f}order`]:(e,t)=>{e.order=parseInt(t.value)},[`${p}singleLine`]:(e,t)=>{e.singleLine=t.value===`true`},[`${p}readonly`]:(e,t)=>{e.readonly=t.value===`true`},[`${te}styleClass`]:(e,t)=>{e.cssClass=t.value},[`${f}in`]:(e,t)=>{e.in=t.value},[`${f}languageIn`]:(e,t)=>{e.languageIn=e.config.lists[t.value],e.datatype=y},[`${f}defaultValue`]:(e,t)=>{e.defaultValue=t},[`${f}hasValue`]:(e,t)=>{e.hasValue=t},[`${f}node`]:(e,t)=>{e.node=t,e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${f}and`]:(e,t)=>{e.and=t.value;let n=e.config.lists[e.and];if(n?.length)for(let t of n)e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${f}qualifiedValueShape`]:(e,t)=>{let n=e.config.getNodeTemplate(t,e);e.qualifiedValueShape=n,e.nodeShapes.add(n)},[`${f}qualifiedMinCount`]:(e,t)=>{e.qualifiedMinCount=parseInt(t.value)},[`${f}qualifiedMaxCount`]:(e,t)=>{e.qualifiedMaxCount=parseInt(t.value)},[x.id]:(e,t)=>{e.owlImports.add(t)},[C.id]:(e,t)=>{e.class=t;let n=e.config.store.getSubjects(w,t,null);n.length>0&&(e.node=n[0])},[`${f}or`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.or=n:console.error(`list for sh:or not found:`,t.value,`existing lists:`,e.config.lists)},[`${f}xone`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.xone=n:console.error(`list for sh:xone not found:`,t.value,`existing lists:`,e.config.lists)}},Ae=class{constructor(e,t){this.label=``,this.nodeShapes=new Set,this.owlImports=new Set,this.id=e,this.parent=t,this.config=t.config,this.config.registerPropertyTemplate(this),B(this,this.config.store.getQuads(e,null,null,null))}};function R(e){return Math.max(e.minCount??0,e.qualifiedMinCount??0)}function je(e){return Math.min(e.maxCount??2**53-1,e.qualifiedMaxCount??2**53-1)}function z(e){let t=Object.assign({},e);return t.nodeShapes=new Set(e.nodeShapes),t.owlImports=new Set(e.owlImports),e.languageIn&&(t.languageIn=[...e.languageIn]),e.or&&(t.or=[...e.or]),e.xone&&(t.xone=[...e.xone]),t}function B(e,t){for(let n of t)ke[n.predicate.id]?.call(e,e,n.object);return e.label=e.name?.value||E(t,e.config.languages),e.label||=e.path?O(e.path,P):`unknown`,e}function Me(e,t){let n=t,r=e;for(let e in t)if(e!==`parent`&&e!==`config`&&e!==`id`){let t=n[e];if(t!==void 0&&t!==``)if(Array.isArray(t)){let n=r[e];Array.isArray(n)?n.push(...t):r[e]=[...t]}else if(t instanceof Set&&t.size){let n=r[e];r[e]=new Set([...n instanceof Set?n:[],...t])}else r[e]=t}}var Ne=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),Pe=function(e){return`/`+e},Fe={},V=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Pe(t,n),t=s(t),t in Fe)return;Fe[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Ne,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function H(e,t,n){let r=document.createElement(`div`);r.classList.add(`shacl-or-constraint`),r.setAttribute(`part`,`constraint`);let i=[];if(t instanceof $){let a=[],o=!1;e.length&&(o=n.store.countQuads(e[0],S,null,null)>0);for(let r=0;r<e.length;r++)if(o){let o=n.store.getObjects(e[r],S,null),s=[],c=``;for(let e of o){let r=new K(n.getPropertyTemplate(e,t.template),t);s.push(r),c+=(c.length>0?` / `:``)+r.template.label}a.push(s),i.push({label:c,value:r.toString()})}else{let o=e[r],s=new K(n.getPropertyTemplate(o,t.template),t);a.push([s]),i.push({label:s.template.label,value:r.toString()})}let s=n.theme.createListEditor(`Please choose`,null,!1,i);s.setAttribute(`part`,`constraint-editor`);let c=s.querySelector(`.editor`);c.onchange=async()=>{if(c.value){let e=a[parseInt(c.value)];if(n.queryMode){let{activateNodeConstraintOption:t}=await V(async()=>{let{activateNodeConstraintOption:e}=await import(`./mode-C0O1k7Tm.js`);return{activateNodeConstraintOption:e}},[]);await t(e,r);return}let i;if(e.length){for(let n of e)await n.bindValues(t.nodeId,!1);i=e[0],r.replaceWith(e[0]),i.updateControls()}for(let t=1;t<e.length;t++)i.after(e[t]),i=e[t],i.updateControls()}},r.appendChild(s)}else{let a=[];for(let t=0;t<e.length;t++){let r=n.store.getQuads(e[t],null,null,null);if(r.length){a.push(r);let e=E(r,n.languages);for(let t of r)t.predicate.equals(ce)&&(e=E(n.store.getQuads(t.object,null,null,null),n.languages));i.push({label:e||O(r[0].predicate.value,P)+` = `+O(r[0].object.value,P),value:t.toString()})}}let o=n.theme.createListEditor(t.template.label+`?`,null,!1,i,t.template);o.setAttribute(`part`,`constraint-editor`);let s=o.querySelector(`.editor`);s.onchange=async()=>{if(s.value){let e=B(z(t.template),a[parseInt(s.value)]);if(n.queryMode){let{activatePropertyConstraintOption:n}=await V(async()=>{let{activatePropertyConstraintOption:e}=await import(`./mode-C0O1k7Tm.js`);return{activatePropertyConstraintOption:e}},[]);await n(e,t,r);return}let i=await q(e,void 0,!0),o=i.querySelector(`:scope > label`);o&&o.classList.add(`persistent`),r.replaceWith(i)}},r.appendChild(o)}return r}function Ie(e,t,n){if(t.termType===`Literal`){let r=t.datatype;for(let t of e){let e=n.store.getQuads(t,null,null,null);for(let t of e)if(t.predicate.value===`http://www.w3.org/ns/shacl#datatype`&&t.object.equals(r))return e}}else{let r=n.store.getObjects(t,v,null);for(let t of e){let e=n.store.getQuads(t,null,null,null);for(let t of e)if(r.length>0){if(t.predicate.value===`http://www.w3.org/ns/shacl#node`){for(let i of r)if(n.store.getQuads(t.object,w,i,null).length>0)return e}if(t.predicate.equals(C)){for(let n of r)if(t.object.equals(n))return e}}else if(t.predicate.equals(le)&&t.object.equals(se))return e}}return console.error(`couldn't resolve sh:or/sh:xone on property for value`,t),[]}function Le(e,t,n){for(let r of e){let e=!1,i=n.store.getObjects(r,S,null);for(let r of i){let i=n.store.getObjects(r,`${f}path`,null);for(let r of i)if(e=n.store.countQuads(t,r,null,null)>0,e)break}if(e)return i}return console.error(`couldn't resolve sh:or/sh:xone on node for value`,t),[]}var Re=`:host {
2
2
  --shacl-font-family: inherit;
3
3
  --shacl-font-size: 14px;
4
4
  --shacl-text-color: #333;
@@ -81,4 +81,4 @@ h3 { margin-top: 0; }
81
81
  rokit-dialog.link-chooser::part(dialog) { min-height: min(434px, 90vh); width: min(90vw, 600px); }
82
82
  rokit-select::part(facet-count)::after { content: attr(data-count); color: var(--shacl-muted-color); display: inline-block; font-family: monospace; margin-left: 7px; font-size: 12px; }
83
83
  `,ze=class{constructor(e){this.dense=!0;let t=Re;e&&(t+=`
84
- `+e),this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t)}apply(e){}setDense(e){this.dense=e}createViewer(e,r,i){let a=document.createElement(`div`),o=document.createElement(`label`);o.textContent=`${e}:`,i.description&&o.setAttribute(`title`,i.description.value),a.appendChild(o);let s=r.value,c=null;if(r instanceof n){let e=i.config.store.getQuads(s,null,null,null);if(e.length){let t=E(e,i.config.languages);t&&(s=t)}}else r instanceof t&&(r.language?(c=document.createElement(`span`),c.classList.add(`lang`),c.innerText=`@${r.language}`):r.datatype.value===`http://www.w3.org/2001/XMLSchema#date`?s=new Date(Date.parse(r.value)).toDateString():r.datatype.value===`http://www.w3.org/2001/XMLSchema#dateTime`&&(s=new Date(Date.parse(r.value)).toLocaleString()));let l;return A(r.value)?(l=document.createElement(`a`),l.setAttribute(`href`,r.value)):l=document.createElement(`div`),l.classList.add(`d-flex`),l.innerText=s,c&&l.appendChild(c),a.appendChild(l),a}};function Be(e,n,r){if(r){let r=R(e)>0;if(e.class&&!e.hasValue)return e.config.theme.createListEditor(e.label,n,r,k(e.class,e),e);if(e.in){let t=e.config.lists[e.in];if(t?.length){let i=D(t,e.config.store,e.config.languages);return e.config.theme.createListEditor(e.label,n,r,i,e)}else console.error(`list not found:`,e.in,`existing lists:`,e.config.lists)}if(e.datatype?.equals(y)||e.languageIn?.length||e.datatype===void 0&&n instanceof t&&n.language)return e.config.theme.createLangStringEditor(e.label,n,r,e);switch(e.datatype?.value.replace(m,``)){case`integer`:case`float`:case`double`:case`decimal`:return e.config.theme.createNumberEditor(e.label,n,r,e);case`date`:case`dateTime`:return e.config.theme.createDateEditor(e.label,n,r,e);case`boolean`:return e.config.theme.createBooleanEditor(e.label,n,r,e);case`base64Binary`:return e.config.theme.createFileEditor(e.label,n,r,e)}return e.config.theme.createTextEditor(e.label,n,r,e)}else return n?e.config.theme.createViewer(e.label,n,e):document.createElement(`div`)}function Ve(e,t,n){if(t===`application/ld+json`)return He(e);{let r=new a({format:t,prefixes:n});r.addQuads(e);let i=``;return r.end((e,t)=>{e&&console.error(e),i=t}),i}}function He(e){let n=[];for(let r of e){let e={"@id":r.subject.id};if(r.predicate===v)e[`@type`]=r.object.id;else{let n=r.object.value;r.object instanceof t?r.object.language?n={"@language":r.object.language,"@value":r.object.value}:r.object.datatype&&r.object.datatype.value!==`http://www.w3.org/2001/XMLSchema##string`&&(n={"@type":r.object.datatype.value,"@value":r.object.value}):n={"@id":r.object.id},e[r.predicate.value]=n}n.push(e)}return JSON.stringify(n)}function Ue(t){let r=t.shaclDatatype,i=t.dataset.value||t.value;if((t.type===`file`||t.getAttribute(`type`)===`file`)&&t.binaryData)i=t.binaryData;else if(t.type===`checkbox`||t.getAttribute(`type`)===`checkbox`)return t.checked||parseInt(t.dataset.minCount||`0`)>0?e.literal(t.checked?`true`:`false`,r):void 0;if(i){if(i.startsWith(`<`)&&i.endsWith(`>`)&&i.indexOf(`:`)>-1)return e.namedNode(i.substring(1,i.length-1));if(t.dataset.class||t.dataset.nodeKind===`http://www.w3.org/ns/shacl#IRI`)return e.namedNode(i);if(t.dataset.link)return JSON.parse(t.dataset.link);if(t.dataset.lang)r=t.dataset.lang;else if(r instanceof n&&me.has(r.value)){let e=We(i);if(e===void 0)return;i=e}else t.type===`number`?i=parseFloat(i):t.type===`datetime-local`?i=we(i,t.dataset.xsdTemporalSuffix):t.type===`date`&&r instanceof n&&r.value===`http://www.w3.org/2001/XMLSchema#date`&&(i=Ce(i,t.dataset.xsdTemporalSuffix));if((!r||r instanceof n&&ue.equals(r))&&typeof i==`string`){let t=i.split(`^^`);t.length===2&&t[0].startsWith(`"`)&&t[0].endsWith(`"`)&&t[1].split(`:`).length===2?(i=t[0].substring(1,t[0].length-1),r=e.namedNode(t[1])):(t=i.split(`@`),t.length===2&&t[0].startsWith(`"`)&&t[0].endsWith(`"`)?(i=t[0].substring(1,t[0].length-1),r=t[1]):i.startsWith(`"`)&&i.endsWith(`"`)&&(i=i.substring(1,i.length-1)))}return e.literal(i,r)}}function We(e){let t=e.replace(`,`,`.`);return/^[-+]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?$/.test(t)?t:void 0}var U={};function Ge(e){e.predicate===void 0&&e.datatype===void 0?console.warn(`not registering plugin because it does neither define "predicate" nor "datatype"`,e):U[`${e.predicate}^${e.datatype}`]=e}function Ke(){return Object.entries(U).map(e=>e[1])}function qe(e,t){let n=U[`${e}^${t}`];return n||(n=U[`${e}^undefined`],n)?n:U[`undefined^${t}`]}var Je=class{constructor(e,t){this.predicate=e.predicate,this.datatype=e.datatype,t&&(this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t))}createViewer(e,t){return e.config.theme.createViewer(e.label,t,e)}};function Ye(e){let t=new Set;for(let n of e.getQuads(null,b,null,_))n.subject.termType===`NamedNode`&&t.add(n.subject.value);if(t.size===1)return t.values().next().value}function Xe(t,n){let r=e.namedNode(n);for(let e of t.getObjects(r,b,_))if(e.termType===`NamedNode`&&t.getQuads(e,v,oe,null).length>0)return e}async function Ze(e){let t={store:new r,importedUrls:[],atts:e},n=[];if(e.shapes?n.push(W(F({rdf:e.shapes}),t,g)):e.shapesUrl&&n.push(W(F({url:e.shapesUrl,proxy:t.atts.proxy,rdfUrlResolver:t.atts.rdfUrlResolver}),t,g)),e.values?n.push(W(F({rdf:e.values}),t,_)):e.valuesUrl&&n.push(W(F({url:e.valuesUrl,proxy:t.atts.proxy,rdfUrlResolver:t.atts.rdfUrlResolver}),t,_)),await Promise.all(n),e.classInstanceProvider)try{let n=Te(t.store),r=await e.classInstanceProvider(n);r&&await W(F({rdf:r}),t,g)}catch(e){console.error(`failed loading class instances`,e)}if(e.valuesSubject||=Ye(t.store)||null,e.valuesSubject&&t.store.countQuads(null,null,null,g)===0){let n=[...t.store.getObjects(e.valuesSubject,v,_),...t.store.getObjects(e.valuesSubject,b,_)],r=[];for(let e of n){let n=Qe(e.value);!n&&e.value.startsWith(`urn:`)&&t.atts.proxy&&(n=e.value),n&&t.importedUrls.indexOf(n)<0&&(t.importedUrls.push(n),r.push(W(F({url:n,proxy:t.atts.proxy,rdfUrlResolver:t.atts.rdfUrlResolver}),t,g)))}try{await Promise.allSettled(r)}catch(e){console.warn(e)}}return t.store}async function W(t,n,r){let i=await t,a=[];for(let t of i){let i=r;if(n.atts.valuesSubject&&_.equals(r)&&t.graph.id&&t.graph.id!==n.atts.valuesSubject&&(i=t.graph),n.store.add(e.quad(t.subject,t.predicate,t.object,i)),n.atts.loadOwlImports&&x.equals(t.predicate)){let r=Qe(t.object.value);r&&n.importedUrls.indexOf(r)<0&&(n.importedUrls.push(r),a.push(W(F({url:r,proxy:n.atts.proxy,rdfUrlResolver:n.atts.rdfUrlResolver}),n,e.namedNode(r))))}}await Promise.allSettled(a)}function Qe(e){if(A(e))return e;let t=e.split(`:`);if(t.length===2){let n=P[t[0]];if(n&&(e=e.replace(`${t[0]}:`,n),A(e)))return e}return null}async function $e(e){if(e.template.nodeShapes.size===0)return;let t=e.template.config.resourceLinkProvider;if((!t||t&&!t.lazyLoad)&&(await rt(e.template),tt(e).length===0))return;let n=e.template.config.theme.createButton(e.template.label,!1);n.title=`Link existing `+e.template.label,n.classList.add(`link-button`),n.setAttribute(`text`,``);let r=n.getAttribute(`part`);return n.setAttribute(`part`,`${r?r+` `:``}link-button`),n.addEventListener(`click`,async()=>{t?.lazyLoad&&(n.classList.add(`loading`),await rt(e.template),n.classList.remove(`loading`));let r=tt(e);if(r.length===0)n.innerText=`No linkable resources found`,n.setAttribute(`disabled`,``),setTimeout(()=>n.remove(),2e3);else{let t=e.template.config.form.querySelector(`#dialog`);t||(t=new u,t.classList.add(`link-chooser`),t.closable=!0,e.template.config.form.appendChild(t)),t.title=`Link existing `+e.template.label,et(t,e,r),t.open=!0}}),n}function et(e,t,n){let r=document.createElement(`div`);for(let i of n){let n=document.createElement(`div`);n.classList.add(`link-option`),n.title=`Link this resource`,n.innerText=i.label||i.value,n.addEventListener(`click`,()=>{nt(i.value,t),e.open=!1}),r.appendChild(n)}e.replaceChildren(r)}function tt(t){let n=[];if(t.template.config.resourceLinkProvider){for(let r of t.template.nodeShapes)if(t.template.config.providedConformingResourceIds[r.id.value])for(let i of t.template.config.providedConformingResourceIds[r.id.value])t.querySelector(`:scope > .property-instance > shacl-node[data-node-id='${i}'], :scope > .collapsible > .property-instance > shacl-node[data-node-id='${i}']`)===null&&n.push({value:i,label:t.template.config.providedResourceLabels[i]||E(t.template.config.store.getQuads(e.namedNode(i),null,null,null),t.template.config.languages),children:[]})}return n}async function nt(t,n){let r=e.namedNode(t);if(n.template.config.providedResources[t]?.length>0){let e={store:n.template.config.store,importedUrls:[],atts:{loadOwlImports:!1}};await W(F({rdf:n.template.config.providedResources[t]}),e,g),n.template.config.providedResources[t]=``}let i=await q(n.template,r,!0,!0);n.container.insertBefore(i,n.querySelector(`:scope > .add-button-wrapper`)),await n.updateControls()}async function rt(e){let t=e.config.resourceLinkProvider;if(!t)return;let n=new Set(Array.from(e.nodeShapes).map(e=>e.id.value));if(n.size===0)return;let r=Ee(Object.keys(e.config.providedConformingResourceIds),n);if(r.length!==0)try{let n=await t.listConformingResources(r,e);if(n){for(let t of Object.keys(n)){let r=new Set(n[t]);e.config.providedConformingResourceIds[t]=r,await it(r,!1,e.config)}for(let t of r)e.config.providedConformingResourceIds[t]||(e.config.providedConformingResourceIds[t]=new Set)}}catch(e){console.error(`failed loading conforming resources`,e)}}async function it(e,t,n){if(n.resourceLinkProvider&&e.size>0){let r=[];for(let t of e)n.providedResources[t]||r.push(t);if(r.length===0)return[];try{let e=await n.resourceLinkProvider.loadResources(r);if(e){let r={store:n.store,importedUrls:[],atts:{loadOwlImports:!1}};for(let i of e){n.providedResources[i.resourceId]=i.resourceRDF;let e=await F({rdf:i.resourceRDF});n.providedResourceLabels[i.resourceId]=E(e.filter(e=>e.subject.value===i.resourceId),n.languages),t&&await W(Promise.resolve(e),r,g)}return e}for(let e of r)n.providedResources[e]||(n.providedResources[e]=``)}catch(e){console.error(`failed loading resources`,e)}}return[]}async function at(e){let t=new Set;for(let n of e.store.getQuads(null,null,null,_))ot(n.object,e.store)&&t.add(n.object.value);await it(t,!0,e)}function ot(e,t){return e.termType===`NamedNode`&&t.countQuads(e,null,null,null)===0}var G=`:scope > .add-button-wrapper, :scope > .collapsible > .add-button-wrapper`,st=`:scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance`,K=class extends HTMLElement{constructor(e,t){if(super(),this.template=e,this.parent=t,this.container=this,this.setAttribute(`part`,`property`),this.template.nodeShapes.size&&this.template.config.attributes.collapse!==null&&(this.template.maxCount===void 0||this.template.maxCount>1)){let t=new l;t.classList.add(`collapsible`,`shacl-group`),t.open=e.config.attributes.collapse===`open`,t.label=this.template.label,t.setAttribute(`part`,`collapsible`),this.container=t,this.appendChild(this.container)}this.template.order!==void 0&&(this.style.order=`${this.template.order}`),this.template.cssClass&&this.classList.add(this.template.cssClass),e.config.editMode&&!t.linked&&this.addEventListener(`change`,async()=>{await this.updateControls()})}async bindValues(e,t){if(this.template.path){let n=!1;if(e){let r=this.template.config.store.getQuads(e,this.template.path,null,this.parent.linked?null:_);t&&(r=await this.filterValidValues(r,e));for(let e of r)this.parent.linked||this.template.config.store.delete(e),await this.addPropertyInstance(e.object,!_.equals(e.graph)||this.template.config.providedResources[e.object.value]!==void 0,this.template.config.providedResources[e.object.value]!==void 0),this.template.hasValue&&e.object.equals(this.template.hasValue)&&(n=!0)}this.template.config.editMode&&this.template.hasValue&&!n&&!this.parent.linked&&await this.addPropertyInstance(this.template.hasValue)}}async initializeQuery(){let{initializeQueryProperty:e}=await V(async()=>{let{initializeQueryProperty:e}=await import(`./mode-BriAnl-6.js`);return{initializeQueryProperty:e}},[]);await e(this)}async addPropertyInstance(e,t,n=!1){let r;if(this.template.or?.length||this.template.xone?.length){let t=this.template.or?.length?this.template.or:this.template.xone,n=!1;if(e){let i=Ie(t,e,this.template.config);i.length&&(r=await q(B(z(this.template),i),e,!this.parent.linked,this.parent.linked,this.parent),n=!0)}!n&&this.template.config.editMode&&(r=H(t,this,this.template.config),ct(r,``,this.template.config.theme.dense,this.template.config.hierarchyColorsStyleSheet!==void 0))}else r=await q(this.template,e,n,t||this.parent.linked,this.parent);return r&&this.container.insertBefore(r,this.querySelector(G)),r}async updateControls(){this.template.config.editMode&&!this.parent.linked&&!this.querySelector(G)&&this.container.appendChild(await this.createAddControls());let e=R(this.template),t=this.template.nodeShapes.size===0,n=this.querySelector(`:scope > .add-button-wrapper > .link-button, :scope > .collapsible > .add-button-wrapper > .link-button`)===null,r=t||!this.hasRecursiveNodeShape(),i=this.instanceCount();i===0&&r&&(t||n&&e>0)&&(await this.addPropertyInstance(),i=1),t||this.querySelector(G)?.classList.toggle(`required`,i<e);let a;a=e>0?i>e:!t||i>1;let o=i<je(this.template);this.classList.toggle(`may-remove`,a),this.classList.toggle(`may-add`,o)}instanceCount(){return this.querySelectorAll(st).length}hasRecursiveNodeShape(){let e=new Set;this.parent.ancestorShapeIds.forEach(t=>e.add(t)),e.add(this.parent.template.id.value);for(let t of this.template.nodeShapes)if(e.has(t.id.value))return!0;return!1}toRDF(t,n){let r=e.namedNode(this.template.path);for(let e of this.querySelectorAll(`:scope > .property-instance, :scope > .collapsible > .property-instance`))if(e.firstChild instanceof $){let i=e.firstChild.toRDF(t);t.addQuad(n,r,i,this.template.config.valuesGraphId)}else if(this.template.config.editMode)for(let i of e.querySelectorAll(`:scope > .editor`)){let e=Ue(i);e&&t.addQuad(n,r,e,this.template.config.valuesGraphId)}else{let i=Ue(e);i&&t.addQuad(n,r,i,this.template.config.valuesGraphId)}}async filterValidValues(e,t){let n=this.template.id,r=[t];if(this.template.qualifiedValueShape){n=this.template.qualifiedValueShape.id,r=[];for(let t of e)r.push(t.object)}let i=await this.template.config.validator.validate({dataset:this.template.config.store,terms:r},[{terms:[n]}]),a=new Set;for(let e of i.results){let t=this.template.qualifiedValueShape?e.focusNode:e.value;t?.ptrs?.length&&a.add(t.ptrs[0]._term.id)}return e.filter(e=>!a.has(e.object.id))}async createAddControls(){let e=document.createElement(`div`);e.classList.add(`add-button-wrapper`),e.setAttribute(`part`,`add-controls`);let t=await $e(this);t&&e.appendChild(t);let n=this.template.config.theme.createButton(this.template.label,!1);n.title=`Add `+this.template.label,n.classList.add(`add-button`),n.setAttribute(`text`,``);let r=n.getAttribute(`part`);return n.setAttribute(`part`,`${r?r+` `:``}add-button`),n.addEventListener(`click`,async()=>{let e=await this.addPropertyInstance();e&&(e.classList.add(`fadeIn`),await this.updateControls(),setTimeout(()=>{ge(e),e.classList.remove(`fadeIn`)},200))}),e.appendChild(n),e}};async function q(e,n,r=!1,i=!1,a){let o;if(e.nodeShapes.size){o=document.createElement(`div`),o.classList.add(`property-instance`),o.setAttribute(`part`,`property-instance`);let t=new Set(a?.ancestorShapeIds??[]);a&&t.add(a.template.id.value);for(let r of e.nodeShapes){let a=new $(r,n,e.nodeKind,e.label,i,t);o.appendChild(a),await a.ready}}else{let t=qe(e.path,e.datatype?.value);o=t?e.config.editMode&&!i?t.createEditor(e,n):t.createViewer(e,n):Be(e,n||null,e.config.editMode&&!i),o.childNodes.length>0&&(o.classList.add(`property-instance`),o.setAttribute(`part`,`property-instance`)),i&&o.classList.add(`linked`)}return e.config.editMode&&(!i||r)?ct(o,e.label,e.config.theme.dense,e.config.hierarchyColorsStyleSheet!==void 0,r):e.config.hierarchyColorsStyleSheet!==void 0&&o.appendChild(J(!0)),n&&!e.config.editMode&&(n instanceof t?(o.dataset.value=n.value,n.language.length>0?o.dataset.lang=n.language:o.shaclDatatype=n.datatype):o.dataset.value=`<`+n.value+`>`),o.dataset.path=e.path,o}function ct(e,t,n,r,i=!1){let a=J(r),o=new c;o.classList.add(`remove-button`,`clear`),o.title=`Remove `+t,o.dense=n,o.icon=!0;let s=o.getAttribute(`part`);o.setAttribute(`part`,`${s?s+` `:``}remove-button`),o.addEventListener(`click`,()=>{e.classList.remove(`fadeIn`),e.classList.add(`fadeOut`),setTimeout(()=>{let t=e.parentElement;e.remove(),t?.dispatchEvent(new Event(`change`,{bubbles:!0,cancelable:!0}))},200)}),i&&o.classList.add(`persistent`),a.appendChild(o),e.appendChild(a)}function J(e){let t=document.createElement(`div`);return t.className=`remove-button-wrapper`,t.setAttribute(`part`,`remove-controls`),e&&t.classList.add(`colorize`),t}window.customElements.define(`shacl-property`,K);function lt(e,t){let n=e,r=t.store.getQuads(e,null,null,null),i=T(r,`label`,ee,t.languages);i&&(n=i);let a;if(t.attributes.collapse!==null)a=new l,a.classList.add(`collapsible`),a.open=t.attributes.collapse===`open`,a.label=n,a.setAttribute(`part`,`group collapsible`);else{a=document.createElement(`div`);let e=document.createElement(`h1`);e.innerText=n,e.setAttribute(`part`,`group-title`),a.appendChild(e),a.setAttribute(`part`,`group`)}a.dataset.subject=e,a.classList.add(`shacl-group`);let o=T(r,`order`);return o&&(a.style.order=o),a}var ut={[`${f}node`]:(e,t)=>{e.extendedShapes.add(new Y(t,e.config,e))},[`${f}and`]:(e,t)=>{for(let n of e.config.lists[t.value])e.extendedShapes.add(new Y(n,e.config,e))},[`${f}property`]:(e,t)=>{let n=e.config.getPropertyTemplate(t,e);if(n.path){let t=e.properties[n.path];if(t||(t=[],e.properties[n.path]=t),n.qualifiedValueShape)t.push(n);else{let r;for(let t=0;t<e.properties[n.path].length&&!r;t++)e.properties[n.path][t].qualifiedValueShape||(r=e.properties[n.path][t]);r?Me(r,n):t.push(n)}}},[`${f}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${f}targetClass`]:(e,t)=>{e.targetClass=t},[`${f}or`]:(e,t)=>{e.or=e.config.lists[t.value]},[`${f}xone`]:(e,t)=>{e.xone=e.config.lists[t.value]},[x.id]:(e,t)=>{e.owlImports.add(t)},[`${ne}title`]:(e,t)=>{let n=t;e.label=j(e.config.languages,e.label,n)},[`${ee}label`]:(e,t)=>{let n=t;e.label=j(e.config.languages,e.label,n)}},Y=class{constructor(e,t,n){this.extendedShapes=new Set,this.properties={},this.owlImports=new Set,this.merged=!1,this.id=e,this.config=t,this.parent=n,t.registerNodeTemplate(this),dt(this,this.config.store.getQuads(e,null,null,null))}};function dt(e,t){for(let n of t)ut[n.predicate.id]?.call(e,e,n.object);return e}function ft(e){if(!e.merged){e.merged=!0;for(let t of Object.values(e.properties))for(let n of t){let[t,r]=Q(e,n.path),i=t.some(e=>e.qualifiedValueShape!==void 0),a=pt(t),o=i?a:r;if(t.length>1&&o){let e=t[t.length-1];for(let n=t.length-2;n>=0;n--){let r=t[n],i=a?e.qualifiedValueShape:void 0;delete r.parent.properties[r.path],Me(e,r),i&&e.nodeShapes.delete(i)}mt(e)}}}}function pt(e){if(e.length<2)return!1;for(let t=0;t<e.length-1;t++){let n=e[t],r=e[t+1];if(!n.qualifiedValueShape||!r.qualifiedValueShape||!X(n.parent,r.parent)||!X(n.qualifiedValueShape,r.qualifiedValueShape))return!1}return!0}function X(e,t){let n=[...e.extendedShapes],r=new Set;for(;n.length;){let e=n.pop();if(e.id.equals(t.id))return!0;r.has(e)||(r.add(e),n.push(...e.extendedShapes))}return!1}function mt(e){for(let t of[`xone`,`or`]){let n=e[t];if(!n?.length)continue;let r=n.filter(t=>ht(t,e));r.length>0&&r.length<n.length&&(r.length===1?(e[t]=void 0,B(e,e.config.store.getQuads(r[0],null,null,null))):e[t]=r)}}function ht(e,t){let n=t.config.store.getQuads(e,null,null,null);return Z(n,`http://www.w3.org/ns/shacl#datatype`,t.datatype)&&Z(n,C.id,t.class)&&Z(n,`http://www.w3.org/ns/shacl#nodeKind`,t.nodeKind)}function Z(e,t,n){if(!n)return!0;let r=!1;for(let i of e)if(i.predicate.value===t&&(r=!0,i.object.equals(n)))return!0;return!r}function Q(e,t,n=new Set,r=[],i=!1){if(!n.has(e.id.value)){n.add(e.id.value);let a=e.properties[t];if(a?.length===1){r.push(a[0]),i||=a[0].maxCount===1;for(let e of a[0].nodeShapes){let[a,o]=Q(e,t,n,r,i);i||=o}}for(let a of e.extendedShapes){let[e,o]=Q(a,t,n,r,i);i||=o}}return[r,i]}var $=class t extends HTMLElement{constructor(n,r,i,a,o,s=new Set,c){super(),this.template=n,this.linked=o??!1,this.ancestorShapeIds=s,this.queryContext=c,this.setAttribute(`part`,`node`);let l=r;l||=(!i&&n.nodeKind&&(i=n.nodeKind),i===void 0&&n.config.attributes.valuesNamespace||i?.value===`http://www.w3.org/ns/shacl#IRI`?e.namedNode(n.config.attributes.valuesNamespace+d()):e.blankNode(d())),this.nodeId=l;let u=JSON.stringify([n.id,r]);if(r&&n.config.renderedNodes.has(u)){a||=`Link`;let e=document.createElement(`label`);e.innerText=a,e.classList.add(`linked`),this.appendChild(e);let t=this.getAttribute(`part`);this.setAttribute(`part`,`${t?t+` `:``}linked-node`),this.dataset.nodeId=this.nodeId.id;let n=document.createElement(`a`),i=r.termType===`BlankNode`?`_:`+r.value:r.value;n.innerText=i,n.classList.add(`ref-link`),n.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${i}']:not([part~='linked-node'])`)?.scrollIntoView()},this.appendChild(n),this.style.flexDirection=`row`,this.ready=Promise.resolve()}else{r&&n.config.renderedNodes.add(u);let e=this.ancestorShapeIds,i=this.template.id.value,s=this.queryContext;if(this.dataset.nodeId=this.nodeId.id,this.template.config.attributes.showNodeIds!==null){let e=document.createElement(`div`);e.innerText=`id: ${this.nodeId.id}`,e.classList.add(`node-id-display`),this.appendChild(e)}ft(n),this.ready=(async()=>{let c=new Set(e);c.add(i);for(let[e,t]of Object.entries(n.properties))for(let e of t)await this.addPropertyInstance(e,r,t.length>1);for(let e of n.extendedShapes){let n=new t(e,r,void 0,void 0,o,c,s);this.prepend(n),await n.ready}if(n.or?.length&&await this.tryResolve(n.or,r,n.config),n.xone?.length&&await this.tryResolve(n.xone,r,n.config),a){let e=document.createElement(`h1`);e.innerText=a,e.setAttribute(`part`,`node-title`),this.prepend(e)}})()}}toRDF(t,n,r=``){if(n||=this.nodeId,!this.linked){for(let e of this.querySelectorAll(`:scope > shacl-node, :scope > .shacl-group > shacl-node, :scope > shacl-property, :scope > .shacl-group > shacl-property`))e.toRDF(t,n);this.template.targetClass&&t.addQuad(n,v,this.template.targetClass,this.template.config.valuesGraphId),r&&t.addQuad(n,e.namedNode(r),this.template.id,this.template.config.valuesGraphId)}return n}async addPropertyInstance(e,t,n){let r=null;if(e.group)if(e.config.groups.indexOf(e.group)>-1){let t=this.querySelector(`:scope > .shacl-group[data-subject='${e.group}']`);t||(t=lt(e.group,e.config),this.appendChild(t)),r=t}else console.warn(`ignoring unknown group reference`,e.group,`existing groups:`,e.config.groups);let i=new K(e,this);e.config.queryMode?await i.initializeQuery():await i.bindValues(t,n),(e.config.editMode||e.config.queryMode||i.instanceCount()>0)&&(r?r.appendChild(i):this.appendChild(i),e.config.queryMode||await i.updateControls())}async tryResolve(e,t,n){let r=!1;if(t){let i=Le(e,t,n);if(i.length){for(let e of i)await this.addPropertyInstance(n.getPropertyTemplate(e,this.template),t);r=!0}}r||this.appendChild(H(e,this,n))}};window.customElements.define(`shacl-node`,$);function gt(e){return e.datatype!==void 0&&fe.has(e.datatype)}export{D as A,pe as B,ke as C,L as D,F as E,Se as F,se as G,m as H,xe as I,g as J,oe as K,_ as L,ve as M,k as N,P as O,E as P,b as R,z as S,I as T,y as U,f as V,v as W,de as Y,ze as _,K as a,Ae as b,Xe as c,Ze as d,Je as f,Ve as g,Ge as h,ft as i,De as j,N as k,Ye as l,Ke as m,$ as n,J as o,qe as p,w as q,Y as r,at as s,gt as t,W as u,H as v,B as w,R as x,V as y,me as z};
84
+ `+e),this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t)}apply(e){}setDense(e){this.dense=e}createViewer(e,r,i){let a=document.createElement(`div`),o=document.createElement(`label`);o.textContent=`${e}:`,i.description&&o.setAttribute(`title`,i.description.value),a.appendChild(o);let s=r.value,c=null;if(r instanceof n){let e=i.config.store.getQuads(s,null,null,null);if(e.length){let t=E(e,i.config.languages);t&&(s=t)}}else r instanceof t&&(r.language?(c=document.createElement(`span`),c.classList.add(`lang`),c.innerText=`@${r.language}`):r.datatype.value===`http://www.w3.org/2001/XMLSchema#date`?s=new Date(Date.parse(r.value)).toDateString():r.datatype.value===`http://www.w3.org/2001/XMLSchema#dateTime`&&(s=new Date(Date.parse(r.value)).toLocaleString()));let l;return A(r.value)?(l=document.createElement(`a`),l.setAttribute(`href`,r.value)):l=document.createElement(`div`),l.classList.add(`d-flex`),l.innerText=s,c&&l.appendChild(c),a.appendChild(l),a}};function Be(e,n,r){if(r){let r=R(e)>0;if(e.class&&!e.hasValue)return e.config.theme.createListEditor(e.label,n,r,k(e.class,e),e);if(e.in){let t=e.config.lists[e.in];if(t?.length){let i=D(t,e.config.store,e.config.languages);return e.config.theme.createListEditor(e.label,n,r,i,e)}else console.error(`list not found:`,e.in,`existing lists:`,e.config.lists)}if(e.datatype?.equals(y)||e.languageIn?.length||e.datatype===void 0&&n instanceof t&&n.language)return e.config.theme.createLangStringEditor(e.label,n,r,e);switch(e.datatype?.value.replace(m,``)){case`integer`:case`float`:case`double`:case`decimal`:return e.config.theme.createNumberEditor(e.label,n,r,e);case`date`:case`dateTime`:return e.config.theme.createDateEditor(e.label,n,r,e);case`boolean`:return e.config.theme.createBooleanEditor(e.label,n,r,e);case`base64Binary`:return e.config.theme.createFileEditor(e.label,n,r,e)}return e.config.theme.createTextEditor(e.label,n,r,e)}else return n?e.config.theme.createViewer(e.label,n,e):document.createElement(`div`)}function Ve(e,t,n){if(t===`application/ld+json`)return He(e);{let r=new a({format:t,prefixes:n});r.addQuads(e);let i=``;return r.end((e,t)=>{e&&console.error(e),i=t}),i}}function He(e){let n=[];for(let r of e){let e={"@id":r.subject.id};if(r.predicate===v)e[`@type`]=r.object.id;else{let n=r.object.value;r.object instanceof t?r.object.language?n={"@language":r.object.language,"@value":r.object.value}:r.object.datatype&&r.object.datatype.value!==`http://www.w3.org/2001/XMLSchema##string`&&(n={"@type":r.object.datatype.value,"@value":r.object.value}):n={"@id":r.object.id},e[r.predicate.value]=n}n.push(e)}return JSON.stringify(n)}function Ue(t){let r=t.shaclDatatype,i=t.dataset.value||t.value;if((t.type===`file`||t.getAttribute(`type`)===`file`)&&t.binaryData)i=t.binaryData;else if(t.type===`checkbox`||t.getAttribute(`type`)===`checkbox`)return t.checked||parseInt(t.dataset.minCount||`0`)>0?e.literal(t.checked?`true`:`false`,r):void 0;if(i){if(i.startsWith(`<`)&&i.endsWith(`>`)&&i.indexOf(`:`)>-1)return e.namedNode(i.substring(1,i.length-1));if(t.dataset.class||t.dataset.nodeKind===`http://www.w3.org/ns/shacl#IRI`)return e.namedNode(i);if(t.dataset.link)return JSON.parse(t.dataset.link);if(t.dataset.lang)r=t.dataset.lang;else if(r instanceof n&&me.has(r.value)){let e=We(i);if(e===void 0)return;i=e}else t.type===`number`?i=parseFloat(i):t.type===`datetime-local`?i=we(i,t.dataset.xsdTemporalSuffix):t.type===`date`&&r instanceof n&&r.value===`http://www.w3.org/2001/XMLSchema#date`&&(i=Ce(i,t.dataset.xsdTemporalSuffix));if((!r||r instanceof n&&ue.equals(r))&&typeof i==`string`){let t=i.split(`^^`);t.length===2&&t[0].startsWith(`"`)&&t[0].endsWith(`"`)&&t[1].split(`:`).length===2?(i=t[0].substring(1,t[0].length-1),r=e.namedNode(t[1])):(t=i.split(`@`),t.length===2&&t[0].startsWith(`"`)&&t[0].endsWith(`"`)?(i=t[0].substring(1,t[0].length-1),r=t[1]):i.startsWith(`"`)&&i.endsWith(`"`)&&(i=i.substring(1,i.length-1)))}return e.literal(i,r)}}function We(e){let t=e.replace(`,`,`.`);return/^[-+]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?$/.test(t)?t:void 0}var U={};function Ge(e){e.predicate===void 0&&e.datatype===void 0?console.warn(`not registering plugin because it does neither define "predicate" nor "datatype"`,e):U[`${e.predicate}^${e.datatype}`]=e}function Ke(){return Object.entries(U).map(e=>e[1])}function qe(e,t){let n=U[`${e}^${t}`];return n||(n=U[`${e}^undefined`],n)?n:U[`undefined^${t}`]}var Je=class{constructor(e,t){this.predicate=e.predicate,this.datatype=e.datatype,t&&(this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t))}createViewer(e,t){return e.config.theme.createViewer(e.label,t,e)}};function Ye(e){let t=new Set;for(let n of e.getQuads(null,b,null,_))n.subject.termType===`NamedNode`&&t.add(n.subject.value);if(t.size===1)return t.values().next().value}function Xe(t,n){let r=e.namedNode(n);for(let e of t.getObjects(r,b,_))if(e.termType===`NamedNode`&&t.getQuads(e,v,oe,null).length>0)return e}async function Ze(e){let t={store:new r,importedUrls:[],atts:e},n=[];if(e.shapes?n.push(W(F({rdf:e.shapes}),t,g)):e.shapesUrl&&n.push(W(F({url:e.shapesUrl,proxy:t.atts.proxy,rdfUrlResolver:t.atts.rdfUrlResolver}),t,g)),e.values?n.push(W(F({rdf:e.values}),t,_)):e.valuesUrl&&n.push(W(F({url:e.valuesUrl,proxy:t.atts.proxy,rdfUrlResolver:t.atts.rdfUrlResolver}),t,_)),await Promise.all(n),e.classInstanceProvider)try{let n=Te(t.store),r=await e.classInstanceProvider(n);r&&await W(F({rdf:r}),t,g)}catch(e){console.error(`failed loading class instances`,e)}if(e.valuesSubject||=Ye(t.store)||null,e.valuesSubject&&t.store.countQuads(null,null,null,g)===0){let n=[...t.store.getObjects(e.valuesSubject,v,_),...t.store.getObjects(e.valuesSubject,b,_)],r=[];for(let e of n){let n=Qe(e.value);!n&&e.value.startsWith(`urn:`)&&t.atts.proxy&&(n=e.value),n&&t.importedUrls.indexOf(n)<0&&(t.importedUrls.push(n),r.push(W(F({url:n,proxy:t.atts.proxy,rdfUrlResolver:t.atts.rdfUrlResolver}),t,g)))}try{await Promise.allSettled(r)}catch(e){console.warn(e)}}return t.store}async function W(t,n,r){let i=await t,a=[];for(let t of i){let i=r;if(n.atts.valuesSubject&&_.equals(r)&&t.graph.id&&t.graph.id!==n.atts.valuesSubject&&(i=t.graph),n.store.add(e.quad(t.subject,t.predicate,t.object,i)),n.atts.loadOwlImports&&x.equals(t.predicate)){let r=Qe(t.object.value);r&&n.importedUrls.indexOf(r)<0&&(n.importedUrls.push(r),a.push(W(F({url:r,proxy:n.atts.proxy,rdfUrlResolver:n.atts.rdfUrlResolver}),n,e.namedNode(r))))}}await Promise.allSettled(a)}function Qe(e){if(A(e))return e;let t=e.split(`:`);if(t.length===2){let n=P[t[0]];if(n&&(e=e.replace(`${t[0]}:`,n),A(e)))return e}return null}async function $e(e){if(e.template.nodeShapes.size===0)return;let t=e.template.config.resourceLinkProvider;if((!t||t&&!t.lazyLoad)&&(await rt(e.template),tt(e).length===0))return;let n=e.template.config.theme.createButton(e.template.label,!1);n.title=`Link existing `+e.template.label,n.classList.add(`link-button`),n.setAttribute(`text`,``);let r=n.getAttribute(`part`);return n.setAttribute(`part`,`${r?r+` `:``}link-button`),n.addEventListener(`click`,async()=>{t?.lazyLoad&&(n.classList.add(`loading`),await rt(e.template),n.classList.remove(`loading`));let r=tt(e);if(r.length===0)n.innerText=`No linkable resources found`,n.setAttribute(`disabled`,``),setTimeout(()=>n.remove(),2e3);else{let t=e.template.config.form.querySelector(`#dialog`);t||(t=new u,t.classList.add(`link-chooser`),t.closable=!0,e.template.config.form.appendChild(t)),t.title=`Link existing `+e.template.label,et(t,e,r),t.open=!0}}),n}function et(e,t,n){let r=document.createElement(`div`);for(let i of n){let n=document.createElement(`div`);n.classList.add(`link-option`),n.title=`Link this resource`,n.innerText=i.label||i.value,n.addEventListener(`click`,()=>{nt(i.value,t),e.open=!1}),r.appendChild(n)}e.replaceChildren(r)}function tt(t){let n=[];if(t.template.config.resourceLinkProvider){for(let r of t.template.nodeShapes)if(t.template.config.providedConformingResourceIds[r.id.value])for(let i of t.template.config.providedConformingResourceIds[r.id.value])t.querySelector(`:scope > .property-instance > shacl-node[data-node-id='${i}'], :scope > .collapsible > .property-instance > shacl-node[data-node-id='${i}']`)===null&&n.push({value:i,label:t.template.config.providedResourceLabels[i]||E(t.template.config.store.getQuads(e.namedNode(i),null,null,null),t.template.config.languages),children:[]})}return n}async function nt(t,n){let r=e.namedNode(t);if(n.template.config.providedResources[t]?.length>0){let e={store:n.template.config.store,importedUrls:[],atts:{loadOwlImports:!1}};await W(F({rdf:n.template.config.providedResources[t]}),e,g),n.template.config.providedResources[t]=``}let i=await q(n.template,r,!0,!0);n.container.insertBefore(i,n.querySelector(`:scope > .add-button-wrapper`)),await n.updateControls()}async function rt(e){let t=e.config.resourceLinkProvider;if(!t)return;let n=new Set(Array.from(e.nodeShapes).map(e=>e.id.value));if(n.size===0)return;let r=Ee(Object.keys(e.config.providedConformingResourceIds),n);if(r.length!==0)try{let n=await t.listConformingResources(r,e);if(n){for(let t of Object.keys(n)){let r=new Set(n[t]);e.config.providedConformingResourceIds[t]=r,await it(r,!1,e.config)}for(let t of r)e.config.providedConformingResourceIds[t]||(e.config.providedConformingResourceIds[t]=new Set)}}catch(e){console.error(`failed loading conforming resources`,e)}}async function it(e,t,n){if(n.resourceLinkProvider&&e.size>0){let r=[];for(let t of e)n.providedResources[t]||r.push(t);if(r.length===0)return[];try{let e=await n.resourceLinkProvider.loadResources(r);if(e){let r={store:n.store,importedUrls:[],atts:{loadOwlImports:!1}};for(let i of e){n.providedResources[i.resourceId]=i.resourceRDF;let e=await F({rdf:i.resourceRDF});n.providedResourceLabels[i.resourceId]=E(e.filter(e=>e.subject.value===i.resourceId),n.languages),t&&await W(Promise.resolve(e),r,g)}return e}for(let e of r)n.providedResources[e]||(n.providedResources[e]=``)}catch(e){console.error(`failed loading resources`,e)}}return[]}async function at(e){let t=new Set;for(let n of e.store.getQuads(null,null,null,_))ot(n.object,e.store)&&t.add(n.object.value);await it(t,!0,e)}function ot(e,t){return e.termType===`NamedNode`&&t.countQuads(e,null,null,null)===0}var G=`:scope > .add-button-wrapper, :scope > .collapsible > .add-button-wrapper`,st=`:scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance`,K=class extends HTMLElement{constructor(e,t){if(super(),this.template=e,this.parent=t,this.container=this,this.setAttribute(`part`,`property`),this.template.nodeShapes.size&&this.template.config.attributes.collapse!==null&&(this.template.maxCount===void 0||this.template.maxCount>1)){let t=new l;t.classList.add(`collapsible`,`shacl-group`),t.open=e.config.attributes.collapse===`open`,t.label=this.template.label,t.setAttribute(`part`,`collapsible`),this.container=t,this.appendChild(this.container)}this.template.order!==void 0&&(this.style.order=`${this.template.order}`),this.template.cssClass&&this.classList.add(this.template.cssClass),e.config.editMode&&!t.linked&&this.addEventListener(`change`,async()=>{await this.updateControls()})}async bindValues(e,t){if(this.template.path){let n=!1;if(e){let r=this.template.config.store.getQuads(e,this.template.path,null,this.parent.linked?null:_);t&&(r=await this.filterValidValues(r,e));for(let e of r)this.parent.linked||this.template.config.store.delete(e),await this.addPropertyInstance(e.object,!_.equals(e.graph)||this.template.config.providedResources[e.object.value]!==void 0,this.template.config.providedResources[e.object.value]!==void 0),this.template.hasValue&&e.object.equals(this.template.hasValue)&&(n=!0)}this.template.config.editMode&&this.template.hasValue&&!n&&!this.parent.linked&&await this.addPropertyInstance(this.template.hasValue)}}async initializeQuery(){let{initializeQueryProperty:e}=await V(async()=>{let{initializeQueryProperty:e}=await import(`./mode-C0O1k7Tm.js`);return{initializeQueryProperty:e}},[]);await e(this)}async addPropertyInstance(e,t,n=!1){let r;if(this.template.or?.length||this.template.xone?.length){let t=this.template.or?.length?this.template.or:this.template.xone,n=!1;if(e){let i=Ie(t,e,this.template.config);i.length&&(r=await q(B(z(this.template),i),e,!this.parent.linked,this.parent.linked,this.parent),n=!0)}!n&&this.template.config.editMode&&(r=H(t,this,this.template.config),ct(r,``,this.template.config.theme.dense,this.template.config.hierarchyColorsStyleSheet!==void 0))}else r=await q(this.template,e,n,t||this.parent.linked,this.parent);return r&&this.container.insertBefore(r,this.querySelector(G)),r}async updateControls(){this.template.config.editMode&&!this.parent.linked&&!this.querySelector(G)&&this.container.appendChild(await this.createAddControls());let e=R(this.template),t=this.template.nodeShapes.size===0,n=this.querySelector(`:scope > .add-button-wrapper > .link-button, :scope > .collapsible > .add-button-wrapper > .link-button`)===null,r=t||!this.hasRecursiveNodeShape(),i=this.instanceCount();i===0&&r&&(t||n&&e>0)&&(await this.addPropertyInstance(),i=1),t||this.querySelector(G)?.classList.toggle(`required`,i<e);let a;a=e>0?i>e:!t||i>1;let o=i<je(this.template);this.classList.toggle(`may-remove`,a),this.classList.toggle(`may-add`,o)}instanceCount(){return this.querySelectorAll(st).length}hasRecursiveNodeShape(){let e=new Set;this.parent.ancestorShapeIds.forEach(t=>e.add(t)),e.add(this.parent.template.id.value);for(let t of this.template.nodeShapes)if(e.has(t.id.value))return!0;return!1}toRDF(t,n){let r=e.namedNode(this.template.path);for(let e of this.querySelectorAll(`:scope > .property-instance, :scope > .collapsible > .property-instance`))if(e.firstChild instanceof $){let i=e.firstChild.toRDF(t);t.addQuad(n,r,i,this.template.config.valuesGraphId)}else if(this.template.config.editMode)for(let i of e.querySelectorAll(`:scope > .editor`)){let e=Ue(i);e&&t.addQuad(n,r,e,this.template.config.valuesGraphId)}else{let i=Ue(e);i&&t.addQuad(n,r,i,this.template.config.valuesGraphId)}}async filterValidValues(e,t){let n=this.template.id,r=[t];if(this.template.qualifiedValueShape){n=this.template.qualifiedValueShape.id,r=[];for(let t of e)r.push(t.object)}let i=await this.template.config.validator.validate({dataset:this.template.config.store,terms:r},[{terms:[n]}]),a=new Set;for(let e of i.results){let t=this.template.qualifiedValueShape?e.focusNode:e.value;t?.ptrs?.length&&a.add(t.ptrs[0]._term.id)}return e.filter(e=>!a.has(e.object.id))}async createAddControls(){let e=document.createElement(`div`);e.classList.add(`add-button-wrapper`),e.setAttribute(`part`,`add-controls`);let t=await $e(this);t&&e.appendChild(t);let n=this.template.config.theme.createButton(this.template.label,!1);n.title=`Add `+this.template.label,n.classList.add(`add-button`),n.setAttribute(`text`,``);let r=n.getAttribute(`part`);return n.setAttribute(`part`,`${r?r+` `:``}add-button`),n.addEventListener(`click`,async()=>{let e=await this.addPropertyInstance();e&&(e.classList.add(`fadeIn`),await this.updateControls(),setTimeout(()=>{ge(e),e.classList.remove(`fadeIn`)},200))}),e.appendChild(n),e}};async function q(e,n,r=!1,i=!1,a){let o;if(e.nodeShapes.size){o=document.createElement(`div`),o.classList.add(`property-instance`),o.setAttribute(`part`,`property-instance`);let t=new Set(a?.ancestorShapeIds??[]);a&&t.add(a.template.id.value);for(let r of e.nodeShapes){let a=new $(r,n,e.nodeKind,e.label,i,t);o.appendChild(a),await a.ready}}else{let t=qe(e.path,e.datatype?.value);o=t?e.config.editMode&&!i?t.createEditor(e,n):t.createViewer(e,n):Be(e,n||null,e.config.editMode&&!i),o.childNodes.length>0&&(o.classList.add(`property-instance`),o.setAttribute(`part`,`property-instance`)),i&&o.classList.add(`linked`)}return e.config.editMode&&(!i||r)?ct(o,e.label,e.config.theme.dense,e.config.hierarchyColorsStyleSheet!==void 0,r):e.config.hierarchyColorsStyleSheet!==void 0&&o.appendChild(J(!0)),n&&!e.config.editMode&&(n instanceof t?(o.dataset.value=n.value,n.language.length>0?o.dataset.lang=n.language:o.shaclDatatype=n.datatype):o.dataset.value=`<`+n.value+`>`),o.dataset.path=e.path,o}function ct(e,t,n,r,i=!1){let a=J(r),o=new c;o.classList.add(`remove-button`,`clear`),o.title=`Remove `+t,o.dense=n,o.icon=!0;let s=o.getAttribute(`part`);o.setAttribute(`part`,`${s?s+` `:``}remove-button`),o.addEventListener(`click`,()=>{e.classList.remove(`fadeIn`),e.classList.add(`fadeOut`),setTimeout(()=>{let t=e.parentElement;e.remove(),t?.dispatchEvent(new Event(`change`,{bubbles:!0,cancelable:!0}))},200)}),i&&o.classList.add(`persistent`),a.appendChild(o),e.appendChild(a)}function J(e){let t=document.createElement(`div`);return t.className=`remove-button-wrapper`,t.setAttribute(`part`,`remove-controls`),e&&t.classList.add(`colorize`),t}window.customElements.define(`shacl-property`,K);function lt(e,t){let n=e,r=t.store.getQuads(e,null,null,null),i=T(r,`label`,ee,t.languages);i&&(n=i);let a;if(t.attributes.collapse!==null)a=new l,a.classList.add(`collapsible`),a.open=t.attributes.collapse===`open`,a.label=n,a.setAttribute(`part`,`group collapsible`);else{a=document.createElement(`div`);let e=document.createElement(`h1`);e.innerText=n,e.setAttribute(`part`,`group-title`),a.appendChild(e),a.setAttribute(`part`,`group`)}a.dataset.subject=e,a.classList.add(`shacl-group`);let o=T(r,`order`);return o&&(a.style.order=o),a}var ut={[`${f}node`]:(e,t)=>{e.extendedShapes.add(new Y(t,e.config,e))},[`${f}and`]:(e,t)=>{for(let n of e.config.lists[t.value])e.extendedShapes.add(new Y(n,e.config,e))},[`${f}property`]:(e,t)=>{let n=e.config.getPropertyTemplate(t,e);if(n.path){let t=e.properties[n.path];if(t||(t=[],e.properties[n.path]=t),n.qualifiedValueShape)t.push(n);else{let r;for(let t=0;t<e.properties[n.path].length&&!r;t++)e.properties[n.path][t].qualifiedValueShape||(r=e.properties[n.path][t]);r?Me(r,n):t.push(n)}}},[`${f}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${f}targetClass`]:(e,t)=>{e.targetClass=t},[`${f}or`]:(e,t)=>{e.or=e.config.lists[t.value]},[`${f}xone`]:(e,t)=>{e.xone=e.config.lists[t.value]},[x.id]:(e,t)=>{e.owlImports.add(t)},[`${ne}title`]:(e,t)=>{let n=t;e.label=j(e.config.languages,e.label,n)},[`${ee}label`]:(e,t)=>{let n=t;e.label=j(e.config.languages,e.label,n)}},Y=class{constructor(e,t,n){this.extendedShapes=new Set,this.properties={},this.owlImports=new Set,this.merged=!1,this.id=e,this.config=t,this.parent=n,t.registerNodeTemplate(this),dt(this,this.config.store.getQuads(e,null,null,null))}};function dt(e,t){for(let n of t)ut[n.predicate.id]?.call(e,e,n.object);return e}function ft(e){if(!e.merged){e.merged=!0;for(let t of Object.values(e.properties))for(let n of t){let[t,r]=Q(e,n.path),i=t.some(e=>e.qualifiedValueShape!==void 0),a=pt(t),o=i?a:r;if(t.length>1&&o){let e=t[t.length-1];for(let n=t.length-2;n>=0;n--){let r=t[n],i=a?e.qualifiedValueShape:void 0;delete r.parent.properties[r.path],Me(e,r),i&&e.nodeShapes.delete(i)}mt(e)}}}}function pt(e){if(e.length<2)return!1;for(let t=0;t<e.length-1;t++){let n=e[t],r=e[t+1];if(!n.qualifiedValueShape||!r.qualifiedValueShape||!X(n.parent,r.parent)||!X(n.qualifiedValueShape,r.qualifiedValueShape))return!1}return!0}function X(e,t){let n=[...e.extendedShapes],r=new Set;for(;n.length;){let e=n.pop();if(e.id.equals(t.id))return!0;r.has(e)||(r.add(e),n.push(...e.extendedShapes))}return!1}function mt(e){for(let t of[`xone`,`or`]){let n=e[t];if(!n?.length)continue;let r=n.filter(t=>ht(t,e));r.length>0&&r.length<n.length&&(r.length===1?(e[t]=void 0,B(e,e.config.store.getQuads(r[0],null,null,null))):e[t]=r)}}function ht(e,t){let n=t.config.store.getQuads(e,null,null,null);return Z(n,`http://www.w3.org/ns/shacl#datatype`,t.datatype)&&Z(n,C.id,t.class)&&Z(n,`http://www.w3.org/ns/shacl#nodeKind`,t.nodeKind)}function Z(e,t,n){if(!n)return!0;let r=!1;for(let i of e)if(i.predicate.value===t&&(r=!0,i.object.equals(n)))return!0;return!r}function Q(e,t,n=new Set,r=[],i=!1){if(!n.has(e.id.value)){n.add(e.id.value);let a=e.properties[t];if(a?.length===1){r.push(a[0]),i||=a[0].maxCount===1;for(let e of a[0].nodeShapes){let[a,o]=Q(e,t,n,r,i);i||=o}}for(let a of e.extendedShapes){let[e,o]=Q(a,t,n,r,i);i||=o}}return[r,i]}var $=class t extends HTMLElement{constructor(n,r,i,a,o,s=new Set,c){super(),this.template=n,this.linked=o??!1,this.ancestorShapeIds=s,this.queryContext=c,this.setAttribute(`part`,`node`);let l=r;l||=(!i&&n.nodeKind&&(i=n.nodeKind),i===void 0&&n.config.attributes.valuesNamespace||i?.value===`http://www.w3.org/ns/shacl#IRI`?e.namedNode(n.config.attributes.valuesNamespace+d()):e.blankNode(d())),this.nodeId=l;let u=JSON.stringify([n.id,r]);if(r&&n.config.renderedNodes.has(u)){a||=`Link`;let e=document.createElement(`label`);e.innerText=a,e.classList.add(`linked`),this.appendChild(e);let t=this.getAttribute(`part`);this.setAttribute(`part`,`${t?t+` `:``}linked-node`),this.dataset.nodeId=this.nodeId.id;let n=document.createElement(`a`),i=r.termType===`BlankNode`?`_:`+r.value:r.value;n.innerText=i,n.classList.add(`ref-link`),n.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${i}']:not([part~='linked-node'])`)?.scrollIntoView()},this.appendChild(n),this.style.flexDirection=`row`,this.ready=Promise.resolve()}else{r&&n.config.renderedNodes.add(u);let e=this.ancestorShapeIds,i=this.template.id.value,s=this.queryContext;if(this.dataset.nodeId=this.nodeId.id,this.template.config.attributes.showNodeIds!==null){let e=document.createElement(`div`);e.innerText=`id: ${this.nodeId.id}`,e.classList.add(`node-id-display`),this.appendChild(e)}ft(n),this.ready=(async()=>{let c=new Set(e);c.add(i);for(let[e,t]of Object.entries(n.properties))for(let e of t)await this.addPropertyInstance(e,r,t.length>1);for(let e of n.extendedShapes){let n=new t(e,r,void 0,void 0,o,c,s);this.prepend(n),await n.ready}if(n.or?.length&&await this.tryResolve(n.or,r,n.config),n.xone?.length&&await this.tryResolve(n.xone,r,n.config),a){let e=document.createElement(`h1`);e.innerText=a,e.setAttribute(`part`,`node-title`),this.prepend(e)}})()}}toRDF(t,n,r=``){if(n||=this.nodeId,!this.linked){for(let e of this.querySelectorAll(`:scope > shacl-node, :scope > .shacl-group > shacl-node, :scope > shacl-property, :scope > .shacl-group > shacl-property`))e.toRDF(t,n);this.template.targetClass&&t.addQuad(n,v,this.template.targetClass,this.template.config.valuesGraphId),r&&t.addQuad(n,e.namedNode(r),this.template.id,this.template.config.valuesGraphId)}return n}async addPropertyInstance(e,t,n){let r=null;if(e.group)if(e.config.groups.indexOf(e.group)>-1){let t=this.querySelector(`:scope > .shacl-group[data-subject='${e.group}']`);t||(t=lt(e.group,e.config),this.appendChild(t)),r=t}else console.warn(`ignoring unknown group reference`,e.group,`existing groups:`,e.config.groups);let i=new K(e,this);e.config.queryMode?await i.initializeQuery():await i.bindValues(t,n),(e.config.editMode||e.config.queryMode||i.instanceCount()>0)&&(r?r.appendChild(i):this.appendChild(i),e.config.queryMode||await i.updateControls())}async tryResolve(e,t,n){let r=!1;if(t){let i=Le(e,t,n);if(i.length){for(let e of i)await this.addPropertyInstance(n.getPropertyTemplate(e,this.template),t);r=!0}}r||this.appendChild(H(e,this,n))}};window.customElements.define(`shacl-node`,$);function gt(e){return e.datatype!==void 0&&fe.has(e.datatype)}export{D as A,pe as B,ke as C,L as D,F as E,Se as F,se as G,m as H,xe as I,g as J,oe as K,_ as L,ve as M,k as N,P as O,E as P,b as R,z as S,I as T,y as U,f as V,v as W,de as Y,ze as _,K as a,Ae as b,Xe as c,Ze as d,Je as f,Ve as g,Ge as h,ft as i,De as j,N as k,Ye as l,Ke as m,$ as n,J as o,qe as p,w as q,Y as r,at as s,gt as t,W as u,H as v,B as w,R as x,V as y,me as z};
package/dist/bundle.js CHANGED
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mode-f6xgDLiM.js","assets/query-CpoZo0uf.js"])))=>i.map(i=>d[i]);
2
- import{$ as e,B as t,C as n,D as r,F as i,G as a,I as o,J as s,K as c,L as l,N as u,O as d,P as f,R as p,S as m,T as ee,U as h,V as g,W as te,X as ne,_ as re,at as ie,c as ae,ct as oe,d as se,dt as _,et as v,f as ce,g as le,h as ue,i as y,it as de,j as b,k as fe,l as x,lt as S,m as C,n as w,nt as T,ot as E,q as D,r as pe,rt as me,s as he,st as ge,t as _e,tt as ve,u as ye,ut as be,w as xe,x as Se,y as Ce}from"./assets/query-CpoZo0uf.js";var we=`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mode-KFvmvNiB.js","assets/query-igazZxn_.js"])))=>i.map(i=>d[i]);
2
+ import{$ as e,B as t,C as n,D as r,F as i,G as a,I as o,J as s,K as c,L as l,N as u,O as d,P as f,R as p,S as m,T as ee,U as h,V as g,W as te,X as ne,_ as re,at as ie,c as ae,ct as oe,d as se,dt as _,et as v,f as ce,g as le,h as ue,i as y,it as de,j as b,k as fe,l as x,lt as S,m as C,n as w,nt as T,ot as E,q as D,r as pe,rt as me,s as he,st as ge,t as _e,tt as ve,u as ye,ut as be,w as xe,x as Se,y as Ce}from"./assets/query-igazZxn_.js";var we=`
3
3
  .editor:not([type='checkbox']) { border: 1px solid var(--shacl-border-color, #DDD); }
4
4
  .property-instance label { display: inline-flex; word-break: break-word; line-height: 1em; padding-top: 0.15em; padding-right: 1em; flex-shrink: 0; position: relative; }
5
5
  .property-instance:not(:first-child) > label:not(.persistent) { visibility: hidden; max-height: 0; }
@@ -7,7 +7,7 @@ import{$ as e,B as t,C as n,D as r,F as i,G as a,I as o,J as s,K as c,L as l,N a
7
7
  `,Te=class extends xe{constructor(e){super(e||we),this.idCtr=0}createDefaultTemplate(e,t,n,r,i){if(r.id=`e${this.idCtr++}`,r.classList.add(`editor`),r.setAttribute(`part`,`editor`),i?.datatype?r.shaclDatatype=i.datatype:t instanceof ge&&(r.shaclDatatype=t.datatype),i&&fe(i)>0&&(r.dataset.minCount=String(fe(i))),i?.class&&(r.dataset.class=i.class.value),i?.nodeKind)r.dataset.nodeKind=i.nodeKind.value;else if(t&&(t instanceof oe||i?.nodeKind?.equals(v))&&(r.dataset.nodeKind=ne+`IRI`,i)){let e=h(i.config.store.getQuads(t,null,null,null),i.config.languages);e&&(r.dataset.value=`<`+t.value+`>`,t=E.literal(e))}(i?.hasValue&&t||i?.readonly)&&(r.disabled=!0);let a=t?.value||i?.defaultValue?.value||``;i?.datatype?.equals(de)?r.checked=t?.value===`true`||i?.defaultValue?.value===`true`:r.type===`file`?r.binaryData=a||void 0:r.value=a;let o=document.createElement(`label`);o.htmlFor=r.id,o.innerText=e,o.setAttribute(`part`,`label`),i?.description&&o.setAttribute(`title`,i.description.value);let s=i?.description?i.description.value:i?.pattern?i.pattern:null;s&&r.setAttribute(`placeholder`,s),n&&(r.setAttribute(`required`,`true`),o.classList.add(`required`));let c=document.createElement(`div`);return c.setAttribute(`part`,`field`),c.appendChild(o),c.appendChild(r),c}createDateEditor(e,t,n,r){let i=new ue;r.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?(i.type=`datetime-local`,i.setAttribute(`step`,`1`)):i.type=`date`,i.clearable=!0,i.dense=this.dense,i.classList.add(`pr-0`);let o=this.createDefaultTemplate(e,null,n,i,r);if(t){let e=r.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?te(t.value):a(t.value);e?(i.value=e.value,e.suffix&&(i.dataset.xsdTemporalSuffix=e.suffix)):console.error(`unable to parse xsd date literal`,t)}return o}createTextEditor(e,t,n,r){let i;return r.singleLine===!1?(i=new ce,i.resize=`auto`):i=new ue,i.dense=this.dense,r.pattern&&(i.pattern=r.pattern),r.minLength&&(i.minLength=r.minLength),r.maxLength&&(i.maxLength=r.maxLength),this.createDefaultTemplate(e,t,n,i,r)}createLangStringEditor(e,t,n,r){let i=this.createTextEditor(e,t,n,r),a=i.querySelector(`:scope .editor`),o;if(r.languageIn?.length){o=document.createElement(`select`);for(let e of r.languageIn){let t=document.createElement(`option`);t.innerText=e.value,o.appendChild(t)}}else o=document.createElement(`input`),o.maxLength=5,o.size=5,o.placeholder=`lang?`;return o.title=`Language of the text`,o.classList.add(`lang-chooser`),o.setAttribute(`part`,`lang-chooser`),o.slot=`suffix`,a.addEventListener(`change`,()=>{o.required=a.value!==``}),o.addEventListener(`change`,e=>{e.stopPropagation(),a&&(a.dataset.lang=o.value,a.dispatchEvent(new Event(`change`,{bubbles:!0})))}),t instanceof ge&&(o.value=t.language),a.dataset.lang=o.value,a.appendChild(o),i}createBooleanEditor(e,t,n,r){let i=document.createElement(`input`);i.type=`checkbox`,i.classList.add(`ml-0`);let a=this.createDefaultTemplate(e,null,n,i,r);return i.removeAttribute(`required`),a.querySelector(`:scope label`)?.classList.remove(`required`),t instanceof ge&&(i.checked=t.value===`true`),a}createFileEditor(e,t,n,r){let i=document.createElement(`input`);return i.type=`file`,i.addEventListener(`change`,e=>{if(i.files?.length){e.stopPropagation();let t=new FileReader;t.readAsDataURL(i.files[0]),t.onload=()=>{i.binaryData=btoa(t.result),i.parentElement?.dispatchEvent(new Event(`change`,{bubbles:!0}))}}else i.binaryData=void 0}),this.createDefaultTemplate(e,t,n,i,r)}createNumberEditor(e,t,n,r){let i=new ue,a=s.has(r.datatype?.value??``);i.type=a?`text`:`number`,a&&(i.pattern=r.datatype?.value===`http://www.w3.org/2001/XMLSchema#decimal`?`[+\\-]?(?:[0-9]+(?:[.,][0-9]*)?|[.,][0-9]+)`:`[+\\-]?(?:[0-9]+(?:[.,][0-9]*)?|[.,][0-9]+)(?:[eE][+\\-]?[0-9]+)?`,i.updateComplete.then(()=>{i.inputElement.inputMode=`decimal`})),i.clearable=!0,i.dense=this.dense,i.classList.add(`pr-0`);let o=r.minInclusive===void 0?r.minExclusive===void 0?void 0:r.minExclusive+1:r.minInclusive,c=r.maxInclusive===void 0?r.maxExclusive===void 0?void 0:r.maxExclusive-1:r.maxInclusive;return o!==void 0&&(i.min=String(o)),c!==void 0&&(i.max=String(c)),!a&&r.datatype?.value!==`http://www.w3.org/2001/XMLSchema#integer`&&(i.step=`any`),this.createDefaultTemplate(e,t,n,i,r)}createListEditor(e,t,n,r,i){let a=new C;a.clearable=!0,a.dense=this.dense;let o=this.createDefaultTemplate(e,null,n,a,i),s=document.createElement(`ul`),c=!0,l=(e,t)=>{let n=document.createElement(`li`);if(typeof e.value==`string`?(n.dataset.value=e.value,n.innerText=e.label?e.label:e.value):(n.dataset.value=e.value.id,e.value instanceof oe&&(n.dataset.value=`<`+n.dataset.value+`>`),n.innerText=e.label?e.label:e.value.value),t.appendChild(n),e.children?.length){c=!1;let t=document.createElement(`ul`);n.appendChild(t);for(let n of e.children)l(n,t)}};for(let e of r)l(e,s);return c||(a.collapse=!0),a.appendChild(s),t=t??i?.defaultValue??null,t&&(a.value=t.id,t instanceof oe&&(a.value=`<`+a.value+`>`)),o}createButton(e,t){let n=new re;return n.dense=this.dense,n.innerHTML=e,t?(n.setAttribute(`primary`,``),n.setAttribute(`part`,`button primary`)):n.setAttribute(`part`,`button`),n}};function Ee(e){return`_:`+e.value}function De(e,t){return[...e].map(e=>t(e)).join(`
8
8
  `)+`
9
9
  `}function Oe(){return``}function ke(e){return`<`+e.value+`>`}var Ae=/["\\\\\n\r]/,je=/["\\\\\n\r]/g,Me={'"':`\\"`,"\\":`\\\\`,"\n":`\\n`,"\r":`\\r`};function Ne(e){return Me[e]}function Pe(e){return Ae.test(e)?e.replace(je,Ne):e}function Fe(e){let t=Pe(e.value);return e.datatype.value===`http://www.w3.org/2001/XMLSchema#string`?`"`+t+`"`:e.datatype.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#langString`?`"`+t+`"@`+e.language:`"`+t+`"^^`+ke(e.datatype)}function Ie(e,t){let n=t(e.subject),r=t(e.predicate),i=t(e.object),a=t(e.graph);return`${n} ${r} ${i} ${a?a+` `:``}.`}function Le(e){return`?`+e.value}function O(e){if(!e)return null;if(e.termType===`BlankNode`)return Ee(e);if(e.termType===`DefaultGraph`)return Oe();if(e.termType===`Literal`)return Fe(e);if(e.termType===`NamedNode`)return ke(e);if(e.termType===`Quad`||e.subject&&e.predicate&&e.object&&e.graph)return Ie(e,O);if(e.termType===`Variable`)return Le(e);if(e[Symbol.iterator])return De(e,O);throw Error(`unknown termType ${e.termType}`)}var Re=class{constructor(e){if(this.index=new Map,e)for(let[t,n]of e)this.set(t,n)}get size(){return this.index.size}clear(){this.index.clear()}delete(e){return this.index.delete(O(e))}*entries(){for(let[,{term:e,value:t}]of this.index)yield[e,t]}forEach(e,t){for(let n of this.entries())e.call(t,n[1],n[0],this)}get(e){let t=this.index.get(O(e));return t&&t.value}has(e){return this.index.has(O(e))}*keys(){for(let[,{term:e}]of this.index)yield e}set(e,t){let n=O(e);return this.index.set(n,{term:e,value:t}),this}*values(){for(let[,{value:e}]of this.index)yield e}[Symbol.iterator](){return this.entries()[Symbol.iterator]()}},ze=class{constructor({dataset:e,end:t,quad:n,start:r}){this.dataset=e,this.end=t,this.quad=n,this.start=r}get term(){return this.quad[this.end]}get graph(){return this.quad.graph}get startTerm(){return this.quad[this.start]}};function Be(e){try{return O(e)}catch{return null}}var k=class{constructor(e){if(this.index=new Map,e)for(let t of e)this.add(t)}get size(){return this.index.size}add(e){let t=O(e);return this.index.has(t)||this.index.set(t,e),this}clear(){this.index.clear()}delete(e){return e?this.index.delete(Be(e)):!1}entries(){return this.values().entries()}forEach(e,t){return this.values().forEach(e,t)}has(e){return e?this.index.has(Be(e)):!1}values(){return new Set(this.index.values())}keys(){return this.values()}[Symbol.iterator](){return this.index.values()}},Ve=class{constructor(e){this.value=e}equals(e){return!!e&&e.termType===this.termType&&e.value===this.value}};Ve.prototype.termType=`BlankNode`;var He=class{equals(e){return!!e&&e.termType===this.termType}};He.prototype.termType=`DefaultGraph`,He.prototype.value=``;function Ue(e,t){if(!t)return null;if(t.termType===`BlankNode`)return e.blankNode(t.value);if(t.termType===`DefaultGraph`)return e.defaultGraph();if(t.termType===`Literal`)return e.literal(t.value,t.language||e.namedNode(t.datatype.value));if(t.termType===`NamedNode`)return e.namedNode(t.value);if(t.termType===`Quad`){let n=e.fromTerm(t.subject),r=e.fromTerm(t.predicate),i=e.fromTerm(t.object),a=e.fromTerm(t.graph);return e.quad(n,r,i,a)}if(t.termType===`Variable`)return e.variable(t.value);throw Error(`unknown termType ${t.termType}`)}var We=class{constructor(e,t,n,r=``){this.value=e,this.language=t,this.datatype=n,this.direction=r}equals(e){return!!e&&e.termType===this.termType&&e.value===this.value&&e.language===this.language&&e.datatype.equals(this.datatype)&&(e.direction||``)===this.direction}};We.prototype.termType=`Literal`;var Ge=class{constructor(e){this.value=e}equals(e){return!!e&&e.termType===this.termType&&e.value===this.value}};Ge.prototype.termType=`NamedNode`;var Ke=class{constructor(e,t,n,r){this.subject=e,this.predicate=t,this.object=n,this.graph=r}equals(e){return!!e&&(e.termType===`Quad`||!e.termType)&&e.subject.equals(this.subject)&&e.predicate.equals(this.predicate)&&e.object.equals(this.object)&&e.graph.equals(this.graph)}};Ke.prototype.termType=`Quad`,Ke.prototype.value=``;var qe=class{constructor(e){this.value=e}equals(e){return!!e&&e.termType===this.termType&&e.value===this.value}};qe.prototype.termType=`Variable`;var Je=new Ge(`http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString`),Ye=new Ge(`http://www.w3.org/1999/02/22-rdf-syntax-ns#langString`),Xe=new Ge(`http://www.w3.org/2001/XMLSchema#string`),Ze=class{constructor(){this.init()}init(){this._data={blankNodeCounter:0,defaultGraph:new He}}namedNode(e){return new Ge(e)}blankNode(e){return e||=`b`+ ++this._data.blankNodeCounter,new Ve(e)}literal(e,t){return typeof t==`string`?new We(e,t,Ye):typeof t?.language==`string`?new We(e,t.language,t.direction?Je:Ye,t.direction):new We(e,``,t||Xe)}variable(e){return new qe(e)}defaultGraph(){return this._data.defaultGraph}quad(e,t,n,r=this.defaultGraph()){return new Ke(e,t,n,r)}fromTerm(e){return Ue(this,e)}fromQuad(e){return Ue(this,e)}};Ze.exports=[`blankNode`,`defaultGraph`,`fromQuad`,`fromTerm`,`literal`,`namedNode`,`quad`,`variable`];var Qe=new Ze,$e={apply:(e,t,n)=>e(n[0]),get:(e,t)=>e(t)};function A(e,{factory:t=Qe}={}){let n=(n=``)=>t.namedNode(`${e}${n.raw||n}`);return typeof Proxy>`u`?n:new Proxy(n,$e)}A(`http://www.w3.org/2001/XMLSchema#`);var et=A(`http://www.w3.org/1999/02/22-rdf-syntax-ns#`);A(`http://www.w3.org/2000/01/rdf-schema#`);var j=class e{static add({ptr:e,start:t,end:n,subjects:r=[null],predicates:i=[null],objects:a=[null],graphs:o,callback:s}={}){if(!e.factory)throw Error(`add operation requires a factory`);let c=()=>{};s&&(c=r=>{s(new ze({dataset:e.dataset,start:t,end:n,quad:r}))});for(let n of r)for(let r of i)for(let i of a)for(let a of o){let o={subject:n,predicate:r,object:i,graph:a};o[t]=e.term;let s=e.factory.quad(o.subject,o.predicate,o.object,o.graph);e.dataset.add(s),c(s)}return e}static addList({ptr:e,predicates:t,items:n,graphs:r}){if(e.isAny())throw Error(`can't attach a list to an any ptr`);for(let i of t)for(let t of r){let r=n.map(()=>e.factory.blankNode());e.dataset.add(e.factory.quad(e.term,i,r[0]||et.nil,t));for(let i=0;i<r.length;i++)e.dataset.add(e.factory.quad(r[i],et.first,n[i],t)),e.dataset.add(e.factory.quad(r[i],et.rest,r[i+1]||et.nil,t))}return e}static delete({ptr:e,start:t,subjects:n=[null],predicates:r=[null],objects:i=[null]}){for(let a of n)for(let n of r)for(let r of i){let i={subject:a,predicate:n,object:r};i[t]=e.term;let o=e.dataset.match(i.subject,i.predicate,i.object);for(let t of o)e.dataset.delete(t)}return e}static deleteList({ptr:e,predicates:t}){let n=[];for(let r of t)for(let t of e.dataset.match(e.term,r)){let r=t.object;for(n.push(t);!et.nil.equals(r);){r=n[n.length-1].object;let t=e.dataset.match(r);if(t.size===0)break;for(let e of t)n.push(e)}}for(let t of n)e.dataset.delete(t);return e}static execute({ptr:t,operation:n=`traverse`,quantifier:r,start:i,end:a,subjects:o,predicates:s,objects:c,graphs:l,items:u,callback:d}={}){if(n===`add`)return e.add({ptr:t,start:i,end:a,subjects:o,predicates:s,objects:c,graphs:l,callback:d});if(n===`addList`)return e.addList({ptr:t,predicates:s,items:u,graphs:l});if(n===`delete`)return e.delete({ptr:t,start:i,subjects:o,predicates:s,objects:c});if(n===`deleteList`)return e.deleteList({ptr:t,predicates:s});if(n===`isList`)return e.isList({ptr:t});if(n===`list`)return e.list({ptr:t});if(n===`traverse`)return e.traverse({ptr:t,quantifier:r,start:i,end:a,subjects:o,predicates:s,objects:c,graphs:l});throw Error(`unknown operation ${n}`)}static isList({ptr:t}){return!t.isAny()&&!!(et.nil.equals(t.term)||e.traverse({ptr:t,predicates:[et.first]}).length===1)}static list({ptr:e}){if(e.isList())return{*[Symbol.iterator](){for(;e&&!e.term.equals(et.nil);){let t=e.out([et.first]);if(t.length!==1)throw Error(`Invalid list: rdf:first count not equals one on ${e.value}`);let n=e.out([et.rest]);if(n.length!==1)throw Error(`Invalid list: rdf:rest count not equals one on ${e.value}`);yield t[0],e=n[0]}}}}static traverse({ptr:t,quantifier:n=`one`,start:r=`subject`,end:i=`object`,subjects:a=[null],predicates:o=[null],objects:s=[null],graphs:c=[null],callback:l}){if(n===`one`)return e.traverseOne({ptr:t,start:r,end:i,subjects:a,predicates:o,objects:s,graphs:c,callback:l});if(n===`oneOrMore`){let n=e.traverse({ptr:t,end:i,start:r,subjects:a,predicates:o,objects:s,graphs:c,callback:l});return e.traverseMore({ptrs:n,end:i,start:r,subjects:a,predicates:o,objects:s,graphs:c,callback:l})}if(n===`zeroOrMore`)return e.traverseMore({ptrs:[t],end:i,start:r,subjects:a,predicates:o,objects:s,graphs:c,callback:l});if(n===`zeroOrOne`)return[t,...e.traverse({ptr:t,end:i,start:r,subjects:a,predicates:o,objects:s,graphs:c,callback:l})];throw Error(`unknown quantifier ${n}`)}static traverseMore({ptrs:t,end:n,start:r,subjects:i,predicates:a,objects:o,graphs:s,callback:c}={}){let l=[...t],u,d;do{u=[];for(let l of t)u=[...u,...e.traverseOne({ptr:l,end:n,start:r,subjects:i,predicates:a,objects:o,graphs:s,callback:c})];d&&(u=u.filter(e=>!d.has(e.term))),t=u,l=[...l,...u],d=new k(l.map(e=>e.term))}while(u.length>0);return l}static traverseOne({ptr:e,start:t,end:n,subjects:r,predicates:i,objects:a,graphs:o,callback:s=(e,t)=>t.extend(e)}={}){let c=[];for(let l of r)for(let r of i)for(let i of a)for(let a of o){let o={subject:l,predicate:r,object:i,graph:a};o[t]=e.term;for(let r of e.dataset.match(o.subject,o.predicate,o.object,o.graph))c.push(s(new ze({dataset:e.dataset,end:n,quad:r,start:t}),e))}return c}};function tt(e,t){return t?n=>t(e.extend(n)):()=>{}}var M=class{constructor({dataset:e,edges:t=[],factory:n,graph:r,term:i}){if(!e&&t.length===0)throw Error(`dataset or edges is required`);if(t.length===0&&i===void 0||t.length>0&&i)throw Error(`edges or term must be given`);this.dataset=e||t[t.length-1].dataset,this.edges=t,this.factory=n,this._graph=r,t.length===0&&(this._term=i)}get edge(){return this.edges[this.edges.length-1]}get graph(){return typeof this._graph==`object`?this._graph:this.edge&&this.edge.graph}get length(){return this._term===void 0?this.edges.length+1:1}get startTerm(){return this._term||this.edges[0].startTerm}get term(){return this._term===void 0?this.edge.term:this._term}get value(){let e=this.term;return e===null?void 0:e.value}addIn(e,t,n){return j.add({ptr:this,start:`object`,end:`subject`,subjects:t,predicates:e,graphs:[this.graph||this.factory.defaultGraph()],callback:tt(this,n)})}addList(e,t){return j.addList({ptr:this,predicates:e,graphs:[this.graph||this.factory.defaultGraph()],items:t})}addOut(e,t,n){return j.add({ptr:this,start:`subject`,end:`object`,predicates:e,objects:t,graphs:[this.graph||this.factory.defaultGraph()],callback:tt(this,n)})}deleteIn(e,t){return j.delete({ptr:this,start:`object`,subjects:t,predicates:e})}deleteList(e){return j.deleteList({ptr:this,predicates:e})}deleteOut(e,t){return j.delete({ptr:this,start:`subject`,predicates:e,objects:t})}execute({operation:e,quantifier:t,start:n,end:r,subjects:i,predicates:a,objects:o,graphs:s,items:c,callback:l}){return j.execute({ptr:this,operation:e,quantifier:t,start:n,end:r,subjects:i,predicates:a,objects:o,graphs:s,items:c,callback:l})}extend(e){return new this.constructor({dataset:this.dataset,edges:[...this.edges,e],factory:this.factory,graph:this._graph})}hasIn(e,t){return j.traverse({ptr:this,start:`object`,end:`object`,subjects:t,predicates:e,graphs:[this.graph]})}hasOut(e,t){return j.traverse({ptr:this,start:`subject`,end:`subject`,predicates:e,objects:t,graphs:[this.graph]})}in(e,t){return j.traverse({ptr:this,start:`object`,end:`subject`,subjects:t,predicates:e,graphs:[this.graph]})}isAny(){return!this.term}isList(){return j.isList({ptr:this})}list(){return j.list({ptr:this})}*nodes(){for(let e=0;e<this.length;e++)this._term===void 0?this.edges.length>e?yield{dataset:this.edges[e].dataset,term:this.edges[e].startTerm}:this.edges.length===e&&(yield{dataset:this.edges[e-1].dataset,term:this.edges[e-1].term}):yield{dataset:this.dataset,term:this._term}}out(e,t){return j.traverse({ptr:this,predicates:e,objects:t,graphs:[this.graph]})}*quads(){for(let{quad:e}of this.edges)yield e}trim(){return new this.constructor({dataset:this.dataset,factory:this.factory,graph:this.graph,term:this.term})}};function N(e,t){return e?e.equals(t):e===t}function nt(e,t){return!(e.dataset!==t.dataset||!N(e.graph,t.graph)||!N(e.term,t.term))}function rt(e,t){return t?n=>t(new e.constructor({factory:e.factory,ptrs:[n]})):()=>{}}var it=class{constructor({dataset:e,factory:t,ptrs:n,terms:r,graphs:i}){if(this.factory=t,n)this.ptrs=[...n];else{this.ptrs=[];for(let n of r||[null])for(let r of i||[null])this.ptrs.push(new M({dataset:e,factory:t,graph:r,term:n}))}}get dataset(){let e=new Set(this.datasets);return e.size===1?e[Symbol.iterator]().next().value:null}get datasets(){return this.ptrs.map(e=>e.dataset)}get term(){let e=new k(this.terms);if(e.size===1)return e[Symbol.iterator]().next().value}get terms(){return this.ptrs.map(e=>e.term)}get value(){return this.term?.value}get values(){return this.ptrs.map(e=>e.value)}addIn(e,t,n){let r=rt(this,n);for(let n of this.ptrs)n.addIn(e,t,r);return this}addList(e,t){if(this.isAny())throw Error(`can't attach a list to an any ptr`);for(let n of this.ptrs)n.addList(e,t);return this}addOut(e,t,n){let r=rt(this,n);for(let n of this.ptrs)n.addOut(e,t,r);return this}clone(e){return new this.constructor({factory:this.factory,ptrs:this.ptrs,...e})}deleteIn(e,t){for(let n of this.ptrs)n.deleteIn(e,t);return this}deleteList(e){for(let t of this.ptrs)t.deleteList(e);return this}deleteOut(e,t){for(let n of this.ptrs)n.deleteOut(e,t);return this}distinct(){let e=this.ptrs.reduce((e,t)=>(e.some(e=>nt(e,t))||e.push(t.trim()),e),[]);return this.clone({ptrs:e})}execute(e){return this.clone({ptrs:this.ptrs.flatMap(t=>t.execute(e))})}executeAll(e){let t=this;for(let n of e)t=t.execute(n);return t}filter(e){return this.clone({ptrs:[...this].filter(e).map(e=>e.ptrs[0])})}hasIn(e,t){return this.clone({ptrs:this.ptrs.flatMap(n=>n.hasIn(e,t))})}hasOut(e,t){return this.clone({ptrs:this.ptrs.flatMap(n=>n.hasOut(e,t))})}in(e,t){return this.clone({ptrs:this.ptrs.flatMap(n=>n.in(e,t))})}isAny(){return this.ptrs.length>0&&this.ptrs.some(e=>e.isAny())}isList(){return this.ptrs.length===1&&this.ptrs[0].isList()}list(){if(!this.isList())return;let e=this.ptrs[0].list(),t=this;return(function*(){for(let n of e)yield t.clone({ptrs:[n]})})()}map(e){return[...this].map(e)}node(e){let t=this.dataset,n=[...e].map(e=>new M({dataset:t,factory:this.factory,term:e}));return this.clone({ptrs:n})}out(e,t){return this.clone({ptrs:this.ptrs.flatMap(n=>n.out(e,t))})}*quads(){for(let{edges:e}of this.ptrs)for(let{quad:t}of e)yield t}trim(){return this.clone({ptrs:this.ptrs.map(e=>e.trim())})}*[Symbol.iterator](){for(let e of this.ptrs)yield this.clone({ptrs:[e]})}};A(`http://www.w3.org/2002/07/owl#`);var at=A(`http://www.w3.org/1999/02/22-rdf-syntax-ns#`),ot=A(`http://www.w3.org/2000/01/rdf-schema#`),P=A(`http://www.w3.org/ns/shacl#`),st=A(`https://schemas.link/shacl-next#`),ct=A(`http://www.w3.org/2001/XMLSchema#`);function lt(e){return e?`{${[...e.quads()].map(e=>O(e)).join(` `)}}`:`{}`}function ut(e){return e?`{${e.map(e=>lt(e)).join(` `)}}`:`{}`}var dt=S(((e,t)=>{var n=/\s/;function r(e){for(var t=e.length;t--&&n.test(e.charAt(t)););return t}t.exports=r})),ft=S(((e,t)=>{var n=dt(),r=/^\s+/;function i(e){return e&&e.slice(0,n(e)+1).replace(r,``)}t.exports=i})),pt=S(((e,t)=>{function n(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}t.exports=n})),mt=S(((e,t)=>{t.exports=typeof global==`object`&&global&&global.Object===Object&&global})),ht=S(((e,t)=>{var n=mt(),r=typeof self==`object`&&self&&self.Object===Object&&self;t.exports=n||r||Function(`return this`)()})),gt=S(((e,t)=>{t.exports=ht().Symbol})),_t=S(((e,t)=>{var n=gt(),r=Object.prototype,i=r.hasOwnProperty,a=r.toString,o=n?n.toStringTag:void 0;function s(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0;var r=!0}catch{}var s=a.call(e);return r&&(t?e[o]=n:delete e[o]),s}t.exports=s})),vt=S(((e,t)=>{var n=Object.prototype.toString;function r(e){return n.call(e)}t.exports=r})),yt=S(((e,t)=>{var n=gt(),r=_t(),i=vt(),a=`[object Null]`,o=`[object Undefined]`,s=n?n.toStringTag:void 0;function c(e){return e==null?e===void 0?o:a:s&&s in Object(e)?r(e):i(e)}t.exports=c})),bt=S(((e,t)=>{function n(e){return typeof e==`object`&&!!e}t.exports=n})),xt=S(((e,t)=>{var n=yt(),r=bt(),i=`[object Symbol]`;function a(e){return typeof e==`symbol`||r(e)&&n(e)==i}t.exports=a})),St=S(((e,t)=>{var n=ft(),r=pt(),i=xt(),a=NaN,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt;function u(e){if(typeof e==`number`)return e;if(i(e))return a;if(r(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=r(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=n(e);var u=s.test(e);return u||c.test(e)?l(e.slice(2),u?2:8):o.test(e)?a:+e}t.exports=u})),Ct=S(((e,t)=>{var n=St(),r=1/0,i=17976931348623157e292;function a(e){return e?(e=n(e),e===r||e===-r?(e<0?-1:1)*i:e===e?e:0):e===0?e:0}t.exports=a})),wt=S(((e,t)=>{var n=Ct();function r(e){var t=n(e),r=t%1;return t===t?r?t-r:t:0}t.exports=r})),Tt=S(((e,t)=>{var n=wt(),r=`Expected a function`;function i(e,t){var i;if(typeof t!=`function`)throw TypeError(r);return e=n(e),function(){return--e>0&&(i=t.apply(this,arguments)),e<=1&&(t=void 0),i}}t.exports=i})),F=_(S(((e,t)=>{var n=Tt();function r(e){return n(2,e)}t.exports=r}))(),1),I=class{constructor({details:e,factory:t,options:n,results:r=[]}={}){this.details=e,this.factory=t,this.options=n,this.results=r,this._conforms=(0,F.default)(()=>!this.results.some(e=>e.severity.equals(P.Info)||e.severity.equals(P.Violation)||e.severity.equals(P.Warning))),this._ptr=(0,F.default)(()=>this.build())}get conforms(){return this._conforms()}get dataset(){return this.ptr.dataset}get ptr(){return this._ptr()}get term(){return this.ptr.term}build(){let e=new it({dataset:this.factory.dataset(),factory:this.factory,terms:[this.factory.blankNode()]});e.addOut([at.type],[P.ValidationReport]).addOut([P.conforms],[this.factory.literal(this.conforms.toString(),ct.boolean)]);for(let t of this.results)e.addOut([P.result],[this.factory.blankNode()],e=>{t.build(e,this.options)});return e}coverage(){return this.results.flatMap(e=>e.coverage())}};function Et(e,t){return Object.entries(t).reduce((e,[t,n])=>(n&&n.termType&&(n=O(n)),e.replace(`{$${t}}`,n).replace(`{?${t}}`,n)),e)}var Dt=class{constructor({args:e={},constraintComponent:t,factory:n,focusNode:r,message:i=[],path:a,results:o=[],severity:s,shape:c,source:l=[],value:u,valuePaths:d=[]}={}){this.args=e,this.constraintComponent=t,this.factory=n,this.focusNode=r,this.path=a||c.path,this.results=o,this.severity=s,this.shape=c,this.source=l,this.value=u,this.valuePaths=d,this._message=(0,F.default)(()=>(this.shape.message.length>0&&(i=this.shape.message),i.length===0&&(i=this.shape.ptr.node([this.constraintComponent]).out([P.message]).terms),i.map(t=>n.literal(Et(t.value,e,n),t.language||void 0))))}get message(){return this._message()}build(e,{details:t}={}){e.addOut([at.type],[P.ValidationResult]).addOut([P.focusNode],this.focusNode.terms).addOut([P.resultSeverity],[this.severity]).addOut([P.sourceConstraint],this.source).addOut([P.sourceConstraintComponent],[this.constraintComponent]).addOut([P.sourceShape],this.shape.ptr.terms),this.message&&e.addOut([P.resultMessage],this.message);let n=t=>{if(t.quantifier===`one`)return t.predicates.length>1?e.node([this.factory.blankNode()]).addList([P.alternativePath],t.predicates):t.start===`object`?e.node([this.factory.blankNode()]).addOut([P.inversePath],[t.predicates[0]]):e.node([t.predicates[0]]);if(t.quantifier===`oneOrMore`)return e.node([this.factory.blankNode()]).addOut([P.oneOrMorePath],[t.predicates[0]]);if(t.quantifier===`zeroOrMore`)return e.node([this.factory.blankNode()]).addOut([P.zeroOrMorePath],[t.predicates[0]]);if(t.quantifier===`zeroOrOne`)return e.node([this.factory.blankNode()]).addOut([P.zeroOrOnePath],[t.predicates[0]])};if(this.path&&(this.path.length===1?e.addOut([P.resultPath],n(this.path[0]).terms):e.addList([P.resultPath],this.path.map(e=>n(e).term))),this.value!==void 0&&e.addOut([P.value],this.value.terms),t)for(let n of this.results)e.addOut([P.detail],[this.factory.blankNode()],e=>{n.build(e,{details:t})})}coverage(){return[...this.valuePaths.flatMap(e=>[...e.quads()]),...this.results.flatMap(e=>e.coverage())]}},Ot=class e{constructor({factory:e,focusNode:t,options:n={debug:!1,details:!1},processed:r=new Set,report:i=new I({factory:e,options:n}),results:a=new Map,shape:o,value:s,valueOrNode:c,valuePaths:l,values:u}={}){this.factory=e,this.focusNode=t,this.options=n,this.processed=r,this.report=i,this.results=a,this.shape=o,this.value=s,this.valuePaths=l,this.valueOrNode=c,this.values=u}create({child:t,focusNode:n=this.focusNode,shape:r=this.shape,value:i=this.value,valueOrNode:a=this.valueOrNode,valuePaths:o=this.valuePaths,values:s=this.values}={}){return new e({factory:this.factory,focusNode:n,options:this.options,processed:this.processed,report:t?new I({factory:this.factory,options:this.options}):this.report,results:this.results,shape:r,value:i,valueOrNode:a,valuePaths:o,values:s})}id({shape:e=this.shape}={}){return`${O(e.ptr.term)} - ${O(this.focusNode.term)} - ${ut(this.valuePaths)}`}result(e){let t=new Dt({factory:this.factory,focusNode:this.focusNode,shape:this.shape,value:this.value,valuePaths:this.valuePaths,...e}),n=this.id();this.results.has(n)?this.results.get(n).add(t):this.results.set(n,new Set([t])),this.report.results.push(t)}debug(e,t){this.options.debug&&this.result({severity:st.Debug,constraintComponent:e,...t})}trace(e,t){this.options.trace&&this.result({severity:st.Trace,constraintComponent:e,...t})}test(e,t,n){e?this.debug(t,n):this.violation(t,n)}violation(e,t){this.result({constraintComponent:e,severity:this.shape.severity||P.Violation,...t})}};function kt(){return{generic:R()}}function R(){return e=>{e.trace(st.TraversalConstraintComponent,{args:{},message:[e.factory.literal(`Traversal`)],value:e.valueOrNode})}}var z=class{constructor(e){this.validations=new Re(e)}compile(e){let t=e.validator.options.coverage;if(e.deactivated)return[];let n=!1,r=new Set;for(let t of e.ptr.execute({start:`subject`,end:`predicate`})){let e=this.validations.get(t.term);e&&(r.add(e),t.term.equals(P.property)&&(n=!0))}return t&&e.isPropertyShape&&!n&&r.add(kt),[...r].map(t=>t(e)).filter(Boolean)}},At=S((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Translator=void 0,e.Translator=class{constructor(){this.supportedRdfDatatypes=[],this.fromRdfHandlers={},this.toRdfHandlers={}}static incorrectRdfDataType(e){throw Error(`Invalid RDF ${e.datatype.value} value: '${e.value}'`)}registerHandler(e,t,n){for(let n of t)this.supportedRdfDatatypes.push(n),this.fromRdfHandlers[n.value]=e;for(let t of n){let n=this.toRdfHandlers[t];n||(this.toRdfHandlers[t]=n=[]),n.push(e)}}fromRdf(e,t){let n=this.fromRdfHandlers[e.datatype.value];return n?n.fromRdf(e,t):e.value}toRdf(e,t){let n=this.toRdfHandlers[typeof e];if(n)for(let r of n){let n=r.toRdf(e,t);if(n)return n}throw Error(`Invalid JavaScript value: '${e}'`)}getSupportedRdfDatatypes(){return this.supportedRdfDatatypes}getSupportedJavaScriptPrimitives(){return Object.keys(this.toRdfHandlers)}}})),jt=S((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TypeHandlerBoolean=void 0;var t=At(),n=class e{fromRdf(e,n){switch(e.value){case`true`:return!0;case`false`:return!1;case`1`:return!0;case`0`:return!1}return n&&t.Translator.incorrectRdfDataType(e),!1}toRdf(t,{datatype:n,dataFactory:r}){return r.literal(t?`true`:`false`,n||r.namedNode(e.TYPE))}};e.TypeHandlerBoolean=n,n.TYPE=`http://www.w3.org/2001/XMLSchema#boolean`})),B=S((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TypeHandlerDate=void 0;var t=At(),n=class e{fromRdf(n,r){switch(r&&!n.value.match(e.VALIDATORS[n.datatype.value.substr(33,n.datatype.value.length)])&&t.Translator.incorrectRdfDataType(n),n.datatype.value){case`http://www.w3.org/2001/XMLSchema#gDay`:return new Date(0,0,parseInt(n.value,10));case`http://www.w3.org/2001/XMLSchema#gMonthDay`:let e=n.value.split(`-`);return new Date(0,parseInt(e[0],10)-1,parseInt(e[1],10));case`http://www.w3.org/2001/XMLSchema#gYear`:return new Date(n.value+`-01-01`);case`http://www.w3.org/2001/XMLSchema#gYearMonth`:return new Date(n.value+`-01`);default:return new Date(n.value)}}toRdf(t,{datatype:n,dataFactory:r}){if(n||=r.namedNode(e.TYPES[0]),!(t instanceof Date))return null;let i=t,a;switch(n.value){case`http://www.w3.org/2001/XMLSchema#gDay`:a=String(i.getUTCDate());break;case`http://www.w3.org/2001/XMLSchema#gMonthDay`:a=i.getUTCMonth()+1+`-`+i.getUTCDate();break;case`http://www.w3.org/2001/XMLSchema#gYear`:a=String(i.getUTCFullYear());break;case`http://www.w3.org/2001/XMLSchema#gYearMonth`:a=i.getUTCFullYear()+`-`+(i.getUTCMonth()+1);break;case`http://www.w3.org/2001/XMLSchema#date`:a=i.toISOString().replace(/T.*$/,``);break;default:a=i.toISOString()}return r.literal(a,n)}};e.TypeHandlerDate=n,n.TYPES=[`http://www.w3.org/2001/XMLSchema#dateTime`,`http://www.w3.org/2001/XMLSchema#date`,`http://www.w3.org/2001/XMLSchema#gDay`,`http://www.w3.org/2001/XMLSchema#gMonthDay`,`http://www.w3.org/2001/XMLSchema#gYear`,`http://www.w3.org/2001/XMLSchema#gYearMonth`],n.VALIDATORS={date:/^[0-9]+-[0-9][0-9]-[0-9][0-9]Z?$/,dateTime:/^[0-9]+-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9](\.[0-9][0-9][0-9])?((Z?)|([\+-][0-9][0-9]:[0-9][0-9]))$/,gDay:/^[0-9]+$/,gMonthDay:/^[0-9]+-[0-9][0-9]$/,gYear:/^[0-9]+$/,gYearMonth:/^[0-9]+-[0-9][0-9]$/}})),Mt=S((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TypeHandlerNumberDouble=void 0;var t=At(),n=class e{fromRdf(e,n){let r=parseFloat(e.value);return n&&isNaN(r)&&t.Translator.incorrectRdfDataType(e),r}toRdf(t,{datatype:n,dataFactory:r}){return n||=r.namedNode(e.TYPES[0]),isNaN(t)?r.literal(`NaN`,n):isFinite(t)?t%1==0?null:r.literal(t.toExponential(15).replace(/(\d)0*e\+?/,`$1E`),n):r.literal(t>0?`INF`:`-INF`,n)}};e.TypeHandlerNumberDouble=n,n.TYPES=[`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`,`http://www.w3.org/2001/XMLSchema#float`]})),Nt=S((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TypeHandlerNumberInteger=void 0;var t=At(),n=class e{fromRdf(e,n){let r=parseInt(e.value,10);return n&&(isNaN(r)||e.value.indexOf(`.`)>=0)&&t.Translator.incorrectRdfDataType(e),r}toRdf(t,{datatype:n,dataFactory:r}){return r.literal(String(t),n||(t<=e.MAX_INT&&t>=e.MIN_INT?r.namedNode(e.TYPES[0]):r.namedNode(e.TYPES[1])))}};e.TypeHandlerNumberInteger=n,n.TYPES=[`http://www.w3.org/2001/XMLSchema#integer`,`http://www.w3.org/2001/XMLSchema#long`,`http://www.w3.org/2001/XMLSchema#int`,`http://www.w3.org/2001/XMLSchema#byte`,`http://www.w3.org/2001/XMLSchema#short`,`http://www.w3.org/2001/XMLSchema#negativeInteger`,`http://www.w3.org/2001/XMLSchema#nonNegativeInteger`,`http://www.w3.org/2001/XMLSchema#nonPositiveInteger`,`http://www.w3.org/2001/XMLSchema#positiveInteger`,`http://www.w3.org/2001/XMLSchema#unsignedByte`,`http://www.w3.org/2001/XMLSchema#unsignedInt`,`http://www.w3.org/2001/XMLSchema#unsignedLong`,`http://www.w3.org/2001/XMLSchema#unsignedShort`],n.MAX_INT=2147483647,n.MIN_INT=-2147483648})),Pt=S((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TypeHandlerString=void 0;var t=class{fromRdf(e){return e.value}toRdf(e,{datatype:t,dataFactory:n}){return n.literal(e,t)}};e.TypeHandlerString=t,t.TYPES=[`http://www.w3.org/2001/XMLSchema#string`,`http://www.w3.org/2001/XMLSchema#normalizedString`,`http://www.w3.org/2001/XMLSchema#anyURI`,`http://www.w3.org/2001/XMLSchema#base64Binary`,`http://www.w3.org/2001/XMLSchema#language`,`http://www.w3.org/2001/XMLSchema#Name`,`http://www.w3.org/2001/XMLSchema#NCName`,`http://www.w3.org/2001/XMLSchema#NMTOKEN`,`http://www.w3.org/2001/XMLSchema#token`,`http://www.w3.org/2001/XMLSchema#hexBinary`,`http://www.w3.org/1999/02/22-rdf-syntax-ns#langString`,`http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString`,`http://www.w3.org/2001/XMLSchema#time`,`http://www.w3.org/2001/XMLSchema#duration`]})),V=S((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(jt(),e),n(B(),e),n(Mt(),e),n(Nt(),e),n(Pt(),e)})),Ft=S((e=>{Object.defineProperty(e,"__esModule",{value:!0})})),It=S((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.fromRdf=c,e.toRdf=l,e.getTermRaw=u,e.getSupportedRdfDatatypes=d,e.getSupportedJavaScriptPrimitives=f;var r=p(),i=V(),a=At();n(V(),e),n(Ft(),e),n(At(),e);var o=new r.DataFactory,s=new a.Translator;s.registerHandler(new i.TypeHandlerString,i.TypeHandlerString.TYPES.map(e=>o.namedNode(e)),[`string`]),s.registerHandler(new i.TypeHandlerBoolean,[i.TypeHandlerBoolean.TYPE].map(e=>o.namedNode(e)),[`boolean`]),s.registerHandler(new i.TypeHandlerNumberDouble,i.TypeHandlerNumberDouble.TYPES.map(e=>o.namedNode(e)),[`number`]),s.registerHandler(new i.TypeHandlerNumberInteger,i.TypeHandlerNumberInteger.TYPES.map(e=>o.namedNode(e)),[`number`]),s.registerHandler(new i.TypeHandlerDate,i.TypeHandlerDate.TYPES.map(e=>o.namedNode(e)),[`object`]);function c(e,t){return s.fromRdf(e,t)}function l(e,t){return t&&`namedNode`in t&&(t={dataFactory:t}),t||={},t&&!t.dataFactory&&(t.dataFactory=o),s.toRdf(e,t)}function u(e,t){return e.termType===`Literal`?c(e,t):e.value}function d(){return s.getSupportedRdfDatatypes()}function f(){return s.getSupportedJavaScriptPrimitives()}}))();function Lt(e){if(e.term.termType!==`BlankNode`)return{quantifier:`one`,start:`subject`,end:`object`,predicates:[e.term]};let t=e.out([P.alternativePath]);if(t.ptrs.length===1&&t.ptrs[0].isList())return{quantifier:`one`,start:`subject`,end:`object`,predicates:[...t.list()].map(e=>e.term)};let n=e.out([P.inversePath]);if(n.term)return{quantifier:`one`,start:`object`,end:`subject`,predicates:[n.term]};let r=e.out([P.oneOrMorePath]);if(r.term)return{quantifier:`oneOrMore`,start:`subject`,end:`object`,predicates:[r.term]};let i=e.out([P.zeroOrMorePath]);if(i.term)return{quantifier:`zeroOrMore`,start:`subject`,end:`object`,predicates:[i.term]};let a=e.out([P.zeroOrOnePath]);if(a.term)return{quantifier:`zeroOrOne`,start:`subject`,end:`object`,predicates:[a.term]}}function Rt(e){return e.terms.length===0?null:e.ptrs[0].isList()?[...e.list()].map(e=>Lt(e)):[Lt(e)]}var zt=class{constructor(e){this.shape=e,this._compiled=(0,F.default)(()=>this.shape.validator.registry.compile(e))}get compiled(){return this._compiled()}async validate(e){return e.focusNode.dataset.size===0||(this.shape.isPropertyShape?await this.validateProperty(e):await this.validateNode(e)),e}async validateNode(e){let t=e.create({shape:this.shape,valueOrNode:e.value||e.focusNode});for(let e of this.compiled)e.node&&await e.node(t),e.generic&&await e.generic(t)}async validateProperty(e){let t;t=this.shape.isSparqlShape?e.focusNode:e.focusNode.executeAll(this.shape.path);let n=t.node(new k(t.terms)),r=[...t].reduce((e,n)=>{let r=n.term,i=t.node([r]);return e.has(r)||e.set(r,{value:i,valuePaths:[]}),e.get(r).valuePaths.push(n),e},new Re).values(),i=e.create({shape:this.shape,values:n});for(let e of this.compiled)e.property&&await e.property(i);for(let{value:t,valuePaths:n}of r){let r=e.create({shape:this.shape,value:t,valueOrNode:t,valuePaths:n});for(let e of this.compiled)e.generic&&await e.generic(r)}}};function Bt(e){let t=new k,n=new it({dataset:e.dataset,terms:e.terms}).execute({quantifier:`zeroOrMore`,start:`object`,end:`subject`,predicates:[ot.subClassOf]});for(let e of n.ptrs)for(let{term:n}of e.nodes())t.add(n);return t}var Vt=class{constructor(e,{registry:t}){this.registry=t,this.targetClass=new k([...Bt(e.hasOut([at.type],[P.NodeShape])),...Bt(e.out([P.targetClass]))]),this.targetNode=e.out([P.targetNode]).terms,this.targetObjectsOf=e.out([P.targetObjectsOf]).terms,this.targetSubjectsOf=e.out([P.targetSubjectsOf]).terms,this.targets=[...e.out([P.target])]}async resolve(e){let t=e.focusNode.node([null]),n=[...e.focusNode.hasOut([at.type],this.targetClass).ptrs,...e.focusNode.node(this.targetNode).ptrs,...t.execute({start:`object`,end:`object`,predicates:this.targetObjectsOf}).ptrs,...t.execute({start:`subject`,end:`subject`,predicates:this.targetSubjectsOf}).ptrs];for(let t of this.targets)for(let[,r]of this.registry.targetResolvers){let i=await r(t,e);n.push(...e.focusNode.node(i).ptrs)}let r=e.focusNode.clone({ptrs:n});return r.node([...new k(r.terms)])}},Ht=class{constructor(e,{validator:t}){this.ptr=e,this.validator=t,this._deactivated=(0,F.default)(()=>{let e=this.ptr.out([P.deactivated]).term;return e&&(0,It.fromRdf)(e)}),this._message=(0,F.default)(()=>this.ptr.out([P.message]).terms),this._path=(0,F.default)(()=>Rt(this.ptr.out([P.path]))),this._severity=(0,F.default)(()=>this.ptr.out([P.severity]).term),this._shapeValidator=(0,F.default)(()=>new zt(this)),this._sparql=(0,F.default)(()=>this.ptr.out([P.sparql])),this._targetResolver=(0,F.default)(()=>new Vt(this.ptr,{registry:this.validator.targetResolverRegistry}))}get deactivated(){return this._deactivated()}get isPropertyShape(){return!!this.path}get isSparqlShape(){return this.sparql.terms.length>0}get path(){return this._path()}get targetResolver(){return this._targetResolver()}get message(){return this._message()}get severity(){return this._severity()}get shapeValidator(){return this._shapeValidator()}get sparql(){return this._sparql()}async resolveTargets(e){return this.targetResolver.resolve(e)}async validate(e){let t=e.id({shape:this});if(e.processed.has(t)){if(e.results.has(t))for(let n of e.results.get(t))e.report.results.push(n);return e}return e.processed.add(t),this.shapeValidator.validate(e)}},Ut=class{constructor(e){this.targetResolvers=new Re(e)}};function Wt(e){return{property:Gt(parseInt(e.ptr.out([P.maxCount]).value))}}function Gt(e){return t=>{t.test(t.values.terms.length<=e,P.MaxCountConstraintComponent,{args:{maxCount:e},message:[t.factory.literal(`More than {$maxCount} values`)]})}}function Kt(e){return{property:qt(parseInt(e.ptr.out([P.minCount]).value))}}function qt(e){return t=>{t.test(t.values.terms.length>=e,P.MinCountConstraintComponent,{args:{minCount:e},message:[t.factory.literal(`Less than {$minCount} values`)]})}}async function Jt(e,t){for(let n of e)if(!await t(n))return!1;return!0}async function H(e,t){return(await Promise.all(e.map(e=>t(e)))).filter(Boolean)}async function U(e,t){return Promise.all(e.map(t))}async function W(e,t){for(let n of e)if(await t(n))return!0;return!1}function Yt(e){return{generic:Xt([...e.ptr.out([P.and])].flatMap(e=>[...e.list()]).map(t=>e.validator.shape(t)))}}function Xt(e){return async t=>{let n=await U(e,async e=>(await e.validate(t.create({child:!0,focusNode:t.valueOrNode}))).report),r=n.every(e=>e.conforms);t.test(r,P.AndConstraintComponent,{results:n.flatMap(e=>e.results),value:t.valueOrNode})}}function Zt(e){return{generic:Qt(e.validator.shape(e.ptr.out([P.not])))}}function Qt(e){return async t=>{let n=(await e.validate(t.create({child:!0,focusNode:t.valueOrNode}))).report,r=!n.conforms;t.test(r,P.NotConstraintComponent,{args:{not:e.ptr.term},message:[t.factory.literal(`Value does have shape {$not}`)],results:n.results,value:t.valueOrNode})}}function $t(e){return{generic:en([...e.ptr.out([P.or])].flatMap(e=>[...e.list()]).map(t=>e.validator.shape(t)))}}function en(e){return async t=>{let n=[],r;if(t.options.debug||t.options.details){let i=await U(e,async e=>(await e.validate(t.create({child:!0,focusNode:t.valueOrNode}))).report);n=i.flatMap(e=>e.results),r=i.some(e=>e.conforms)}else r=await W(e,async e=>(await e.validate(t.create({child:!0,focusNode:t.valueOrNode}))).report.conforms);t.test(r,P.OrConstraintComponent,{results:n,value:t.valueOrNode})}}function tn(e){return{generic:G([...e.ptr.out([P.xone])].flatMap(e=>[...e.list()]).map(t=>e.validator.shape(t)))}}function G(e){return async t=>{let n=await U(e,async e=>(await e.validate(t.create({child:!0,focusNode:t.valueOrNode}))).report),r=n.filter(e=>e.conforms).length===1;t.test(r,P.XoneConstraintComponent,{results:n.flatMap(e=>e.results),value:t.valueOrNode})}}function nn(e){return(0,It.fromRdf)(e.ptr.out([P.closed]).term)?{node:rn(new k(e.ptr.out([P.property]).map(t=>e.validator.shape(t)).filter(e=>!e.deactivated).map(e=>e.path[0].predicates[0])),new k([...e.ptr.out([P.ignoredProperties]).list()||[]].map(e=>e.term)))}:null}function rn(e,t){return n=>{let r=n.focusNode.execute({start:`subject`,end:`predicate`}).filter(n=>!t.has(n.term)&&!e.has(n.term));if(r.ptrs.length>0)for(let e of r)n.violation(P.ClosedConstraintComponent,{message:[n.factory.literal(`Predicate is not allowed (closed shape)`)],path:[{quantifier:`one`,start:`subject`,end:`object`,predicates:[e.term]}],value:n.focusNode.node([[...e.quads()][0].object])});else n.debug(P.ClosedConstraintComponent)}}function an(e){let t=e.ptr.out([P.hasValue]).term;return{node:on(t),property:sn(t)}}function on(e){return t=>{t.test(e.equals(t.valueOrNode.term),P.HasValueConstraintComponent,{args:{hasValue:e},message:[t.factory.literal(`Value must be {$hasValue}`)]})}}function sn(e){return t=>{let n=[...t.values].some(t=>e.equals(t.term));t.test(n,P.HasValueConstraintComponent,{args:{hasValue:e},message:[t.factory.literal(`Missing expected value {$hasValue}`)]})}}function cn(e){return{generic:ln(new k([...e.ptr.out([P.in]).list()].map(e=>e.term)))}}function ln(e){return t=>{t.test(e.has(t.valueOrNode.term),P.InConstraintComponent,{args:{in:[...e].map(e=>e.value).join(`, `)},message:[t.factory.literal(`Value is not in {$in}`)],value:t.valueOrNode})}}function un(e,t){if(!e||e.termType!==`Literal`||!t||t.termType!==`Literal`||K(e)!==K(t))return null;let n=(0,It.fromRdf)(e),r=(0,It.fromRdf)(t);return typeof n==typeof r?typeof n==`string`?n.localeCompare(r):n-r:null}function K(e){return ct.dateTime.equals(e.datatype)&&/^.*(((\+|-)\d{2}:\d{2})|Z)$/.test(e.value)}function dn(e){let t=e.ptr.out([P.disjoint]).term;return{generic:q(t)}}function q(e){return t=>{let n=t.focusNode.dataset.match(t.focusNode.term,e,t.valueOrNode.term);t.test(n.size===0,P.DisjointConstraintComponent,{args:{disjoint:e},message:[t.factory.literal(`Value node must not also be one of the values of {$disjoint}`)],value:t.valueOrNode})}}function fn(e){let t=e.ptr.out([P.equals]).term;return{node:pn(t),property:mn(t)}}function pn(e){return t=>{let n=t.focusNode.out([e]),r=n.filter(e=>!e.term.equals(t.focusNode.term)),i=n.terms.length!==0&&r.terms.length===0;t.test(i,P.EqualsConstraintComponent,{args:{equals:e},message:[t.factory.literal(`Must have same values as {$equals}`)],value:r.terms[0]&&t.focusNode.node([r.terms[0]])||t.focusNode})}}function mn(e){return t=>{let n=new k(t.focusNode.out([e]).terms),r=new k(t.values.terms),i=[...r].filter(e=>!n.has(e)),a=[...n].filter(e=>!r.has(e)),o=[...i,...a];for(let n of o)t.violation(P.EqualsConstraintComponent,{args:{equals:e},message:[t.factory.literal(`Must have same values as {$equals}`)],value:t.focusNode.node([n])});o.length===0&&t.debug(P.EqualsConstraintComponent,{args:{equals:e},message:[t.factory.literal(`Must have same values as {$equals}`)]})}}function hn(e){let t=e.ptr.out([P.lessThan]).term;return{property:gn(t)}}function gn(e){return t=>{let n=t.focusNode.out([e]).terms;for(let r of t.values)for(let i of n){let n=un(r.term,i);n===null||n>=0?t.violation(P.LessThanConstraintComponent,{args:{lessThan:e},message:[t.factory.literal(`Value is not less than value of {$lessThan}`)],value:r}):t.debug(P.LessThanConstraintComponent,{args:{lessThan:e},message:[t.factory.literal(`Value is not less than value of {$lessThan}`)],value:r})}}}function _n(e){let t=e.ptr.out([P.lessThanOrEquals]).term;return{property:vn(t)}}function vn(e){return t=>{let n=t.focusNode.out([e]).terms;for(let r of t.values)for(let i of n){let n=un(r.term,i);n===null||n>0?t.violation(P.LessThanOrEqualsConstraintComponent,{args:{lessThanOrEquals:e},message:[t.factory.literal(`Value is not less than or equal to value of {$lessThanOrEquals}`)],value:r}):t.debug(P.LessThanOrEqualsConstraintComponent,{args:{lessThanOrEquals:e},message:[t.factory.literal(`Value is not less than or equal to value of {$lessThanOrEquals}`)],value:r})}}}function yn(e){let t=e.ptr.out([P.maxExclusive]).term;return{generic:bn(t)}}function bn(e){return t=>{let n=un(t.valueOrNode.term,e);t.test(n!==null&&n<0,P.MaxExclusiveConstraintComponent,{args:{maxExclusive:e},message:[t.factory.literal(`Value is not less than {$maxExclusive}`)],value:t.valueOrNode})}}function xn(e){let t=e.ptr.out([P.maxInclusive]).term;return{generic:Sn(t)}}function Sn(e){return t=>{let n=un(t.valueOrNode.term,e);t.test(n!==null&&n<=0,P.MaxInclusiveConstraintComponent,{args:{maxInclusive:e},message:[t.factory.literal(`Value is not less than or equal to {$maxInclusive}`)],value:t.valueOrNode})}}function Cn(e){let t=e.ptr.out([P.minExclusive]).term;return{generic:wn(t)}}function wn(e){return t=>{let n=un(t.valueOrNode.term,e);t.test(n!==null&&n>0,P.MinExclusiveConstraintComponent,{args:{minExclusive:e},message:[t.factory.literal(`Value is not greater than {$minExclusive}`)],value:t.valueOrNode})}}function Tn(e){let t=e.ptr.out([P.minInclusive]).term;return{generic:En(t)}}function En(e){return t=>{let n=un(t.valueOrNode.term,e);t.test(n!==null&&n>=0,P.MinInclusiveConstraintComponent,{args:{minInclusive:e},message:[t.factory.literal(`Value is not greater than or equal to {$minInclusive}`)],value:t.valueOrNode})}}function Dn(e){return{generic:On([...e.ptr.out([P.node])].map(t=>e.validator.shape(t)))}}function On(e){return async t=>{for(let n of e){let e=await n.validate(t.create({child:!0,focusNode:t.valueOrNode}));t.test(e.report.conforms,P.NodeConstraintComponent,{args:{node:n.ptr.term},message:[t.factory.literal(`Value does not have shape {$node}`)],results:e.report.results,value:t.valueOrNode})}}}function kn(e){return{generic:An([...e.ptr.out([P.property])].map(t=>e.validator.shape(t)))}}function An(e){return async t=>{let n=t.create({focusNode:t.valueOrNode});for(let t of e)await t.validate(n)}}function jn(e){let t=e.validator.shape(e.ptr.out([P.qualifiedValueShape])),n=e.ptr.out([P.qualifiedValueShapesDisjoint]).term,r=n?(0,It.fromRdf)(n):!1,i=e.ptr.out([P.qualifiedMaxCount]).term,a=i?parseInt(i.value):null,o=e.ptr.out([P.qualifiedMinCount]).term;return{property:Mn(t,r,a,o?parseInt(o.value):null)}}function Mn(e,t,n,r){return async i=>{let a=[],o=[];t&&(o=new Set(i.shape.ptr.in([P.property]).out([P.property]).out([P.qualifiedValueShape]).filter(t=>!t.term.equals(e.ptr.term)).map(e=>i.shape.validator.shape(e))));let s=(await H(i.values,async t=>{let n=(await e.validate(i.create({child:!0,focusNode:t}))).report;if(a.push(n.results),!n.conforms)return!1;if(o.length===0)return!0;if(i.options.debug||i.options.details){let e=await U([...o],async e=>(await e.validate(i.create({child:!0,focusNode:t}))).report);return a.push(e.flatMap(e=>e.results)),!e.every(e=>e.conforms)}else return!await Jt([...o],async e=>(await e.validate(i.create({child:!0,focusNode:t}))).report.conforms)})).length;n!==null&&i.test(s<=n,P.QualifiedMaxCountConstraintComponent,{args:{qualifiedMaxCount:n,qualifiedValueShape:e.ptr.term,qualifiedValueShapesDisjoint:t},message:[i.factory.literal(`More than {$qualifiedMaxCount} values have shape {$qualifiedValueShape}`)],results:a.flat()}),r!==null&&i.test(s>=r,P.QualifiedMinCountConstraintComponent,{args:{qualifiedMinCount:r,qualifiedValueShape:e.ptr.term,qualifiedValueShapesDisjoint:t},message:[i.factory.literal(`Less than {$qualifiedMinCount} values have shape {$qualifiedValueShape}`)],results:a.flat()})}}function Nn(e,t){return t?t.slice(0,e.length)===e:!1}function Pn(e){return{generic:Fn([...new Set([...e.ptr.out([P.languageIn]).list()].map(e=>e.value))])}}function Fn(e){return t=>{let n=e.some(e=>Nn(e,t.valueOrNode.term.language));t.test(n,P.LanguageInConstraintComponent,{args:{languageIn:e.join(`, `)},message:[t.factory.literal(`Language does not match any of {$languageIn}`)],value:t.valueOrNode})}}function In(e){return{generic:Ln(parseInt(e.ptr.out([P.maxLength]).value))}}function Ln(e){return t=>{let n=t.valueOrNode.term.termType!==`BlankNode`&&t.valueOrNode.value.length<=e;t.test(n,P.MaxLengthConstraintComponent,{args:{maxLength:e},message:[t.factory.literal(`Value has more than {$maxLength} characters`)],value:t.valueOrNode})}}function Rn(e){return{generic:zn(parseInt(e.ptr.out([P.minLength]).value))}}function zn(e){return t=>{let n=t.valueOrNode.term.termType!==`BlankNode`&&t.valueOrNode.value.length>=e;t.test(n,P.MinLengthConstraintComponent,{args:{minLength:e},message:[t.factory.literal(`Value has less than {$minLength} characters`)],value:t.valueOrNode})}}function J(e){let t=e.ptr.out([P.pattern]).value,n=e.ptr.out([P.flags]).value;return{generic:Bn(t,n,new RegExp(t,n))}}function Bn(e,t,n){return r=>{r.test(n.test(r.valueOrNode.term.value),P.PatternConstraintComponent,{args:{flags:t,pattern:e},message:[r.factory.literal(`Value does not match pattern "{$pattern}"`)],value:r.valueOrNode})}}function Vn(e){let t=e.ptr.out([P.uniqueLang]).term;return t.value===`true`&&ct.boolean.equals(t.datatype)?{property:Hn()}:null}function Hn(){return e=>{let t=Object.entries(e.values.terms.reduce((e,t)=>(t.language&&(e[t.language]=(e[t.language]||0)+1),e),{})).filter(([,e])=>e>1);for(let[n]of t)e.violation(P.UniqueLangConstraintComponent,{args:{lang:n},message:[e.factory.literal(`Language "{?lang}" used more than once`)]});t.length===0&&e.debug(P.UniqueLangConstraintComponent)}}var Un=A(`http://www.w3.org/ns/shacl#`),Wn=A(`https://schemas.link/shacl-next#`),Gn=class{constructor({results:e=[]}={}){this.results=e}get conforms(){return!this.results.some(e=>e.severity.equals(Un.Info)||e.severity.equals(Un.Violation)||e.severity.equals(Un.Warning))}};function Kn(e,t){return Object.entries(t).reduce((e,[t,n])=>(n&&n.termType&&(n=O(n)),e.replace(`{$${t}}`,n).replace(`{?${t}}`,n)),e)}var qn=class{constructor({args:e={},factory:t,message:n=[],severity:r=Un.Violation}={}){this.severity=r,this.message=n.map(n=>t.literal(Kn(n.value,e),n.language||null))}},Jn=class e{constructor({factory:e=Qe}={}){this.factory=e}clone({factory:t}={}){return new e({factory:t||this.factory})}validate(){return new Gn}validateSimple(){return!0}},Y=class e extends Jn{constructor({datatypes:e,factory:t}={}){super({factory:t}),this.datatypes=[];for(let t of Array.isArray(e)?e:[e])t&&this.datatypes.push(this.factory.fromTerm(t))}clone({factory:t}={}){return new e({datatypes:this.datatypes,factory:t||this.factory})}},Yn=class{constructor({factory:e=Qe,validations:t}={}){if(this.factory=e,this.validations=new Re,t)for(let e of Object.values(t)){let t=e.clone({factory:this.factory});for(let e of t.datatypes)this.validations.set(e,t)}}validate(e){let t=this.validations.get(e.datatype);return t?t.validate(e):new Gn}validateSimple(e){let t=this.validations.get(e.datatype);return!t||t.validateSimple(e)}},X=class e extends Y{constructor(e,t,{factory:n}={}){super({datatypes:t,factory:n}),this.message=[this.factory.literal(`term value {$this} matches pattern {$pattern}`)],this.patterns=Array.isArray(e)?e:[e]}clone({factory:t}={}){return new e(this.patterns,this.datatypes,{factory:t||this.factory})}validate(e){return new Gn({results:this.patterns.map(t=>{let n;return t.test(e.value)&&(n=Wn.Debug),new qn({args:{pattern:this.factory.literal(t.toString()),this:e},factory:this.factory,message:this.message,severity:n})})})}validateSimple(e){return this.patterns.every(t=>t.test(e.value))}},Xn=/^([-+]?[0-9]+)$/,Z=class e extends X{constructor(e=null,t=null,n,{factory:r}={}){super(Xn,n,{factory:r}),this.maxInclusive=null,this.minInclusive=null,typeof t==`string`&&(this.maxInclusive=BigInt(t)),typeof e==`string`&&(this.minInclusive=BigInt(e))}clone({factory:t}={}){return new e(this.minInclusive?.toString(),this.maxInclusive?.toString(),this.datatypes,{factory:t||this.factory})}validate(e){let t=super.validate(e).results;if(!Wn.Debug.equals(t[0].severity))return new Gn({results:t});let n=BigInt(e.value);if(this.minInclusive!==null&&n<this.minInclusive){let n=`term value "${e.value}" is less than "${this.minInclusive.toString()}"`,r=[this.factory.literal(n)];t.push(new qn({factory:this.factory,message:r}))}if(this.maxInclusive!==null&&n>this.maxInclusive){let n=`term value "${e.value}" is greater than "${this.maxInclusive.toString()}"`,r=[this.factory.literal(n)];t.push(new qn({factory:this.factory,message:r}))}return new Gn({results:t})}validateSimple(e){if(!super.validateSimple(e))return!1;let t=BigInt(e.value);return!(this.minInclusive!==null&&t<this.minInclusive||this.maxInclusive!==null&&t>this.maxInclusive)}},Zn=class e extends Y{constructor(e,t,{factory:n}={}){super({datatypes:t,factory:n}),this.values=new Set(e)}clone({factory:t}={}){return new e(this.values,this.datatypes,{factory:t||this.factory})}validate(e){let t=[];if(!this.values.has(e.value)){let n=`term value "${e.value}" is not included in the list: ${[...this.values].join(`,`)}`,r=[this.factory.literal(n)];t.push(new qn({factory:this.factory,message:r}))}return new Gn({results:t})}validateSimple(e){return this.values.has(e.value)}},Qn=be({anyAtomicType:()=>er,anySimpleType:()=>$n,anyURI:()=>jr,base64Binary:()=>Ar,boolean:()=>gr,byte:()=>qr,date:()=>Cr,dateTime:()=>xr,dateTimeStamp:()=>ni,dayTimeDuration:()=>ti,decimal:()=>_r,double:()=>yr,duration:()=>br,float:()=>vr,gDay:()=>Dr,gMonth:()=>Or,gMonthDay:()=>Er,gYear:()=>Tr,gYearMonth:()=>wr,hexBinary:()=>kr,int:()=>Gr,integer:()=>Vr,language:()=>Br,long:()=>Wr,negativeInteger:()=>Ur,nonNegativeInteger:()=>Jr,nonPositiveInteger:()=>Hr,normalizedString:()=>Rr,positiveInteger:()=>$r,short:()=>Kr,string:()=>hr,time:()=>Sr,token:()=>zr,unsignedByte:()=>Qr,unsignedInt:()=>Xr,unsignedLong:()=>Yr,unsignedShort:()=>Zr,yearMonthDuration:()=>ei}),Q={xsd:A(`http://www.w3.org/2001/XMLSchema#`)},$n=new Y({datatypes:Q.xsd.anySimpleType}),er=new Y({datatypes:Q.xsd.anyAtomicType}),tr=/^([^\ud8ff-\udfff\ufffe-\uffff]*)$/,nr=/^((\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+))$/,rr=/^((\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)([Ee](\+|-)?[0-9]+)?|(\+|-)?INF|NaN)$/,ir=/^(-?P((([0-9]+Y([0-9]+M)?([0-9]+D)?|([0-9]+M)([0-9]+D)?|([0-9]+D))(T(([0-9]+H)([0-9]+M)?([0-9]+(\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\.[0-9]+)?S)?|([0-9]+(\.[0-9]+)?S)))?)|(T(([0-9]+H)([0-9]+M)?([0-9]+(\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\.[0-9]+)?S)?|([0-9]+(\.[0-9]+)?S)))))$/,ar=/^(-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?|(24:00:00(\.0+)?))(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?)$/,or=/^((([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?|(24:00:00(\.0+)?))(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?)$/,sr=/^(-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?)$/,cr=/^(-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?)$/,lr=/^(-?([1-9][0-9]{3,}|0[0-9]{3})(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?)$/,ur=/^(--(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?)$/,dr=/^(---(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?)$/,fr=/^(--(0[1-9]|1[0-2])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?)$/,pr=/^(([0-9a-fA-F]{2})*)$/,mr=/^(((([A-Za-z0-9+/] ?){4})*(([A-Za-z0-9+/] ?){3}[A-Za-z0-9+/]|([A-Za-z0-9+/] ?){2}[AEIMQUYcgkosw048] ?=|[A-Za-z0-9+/] ?[AQgw] ?= ?=))?)$/,hr=new X(tr,Q.xsd.string),gr=new Zn([`1`,`true`,`0`,`false`],Q.xsd.boolean),_r=new X(nr,Q.xsd.decimal),vr=new X(rr,Q.xsd.float),yr=new X(rr,Q.xsd.double),br=new X(ir,Q.xsd.duration),xr=new X(ar,Q.xsd.dateTime),Sr=new X(or,Q.xsd.time),Cr=new X(sr,Q.xsd.date),wr=new X(cr,Q.xsd.gYearMonth),Tr=new X(lr,Q.xsd.gYear),Er=new X(ur,Q.xsd.gMonthDay),Dr=new X(dr,Q.xsd.gDay),Or=new X(fr,Q.xsd.gMonth),kr=new X(pr,Q.xsd.hexBinary),Ar=new X(mr,Q.xsd.base64Binary),jr=new X(tr,Q.xsd.anyURI),Mr=/^([^\u000d\u000a\u0009]*)$/,Nr=/^([^ ]+( [^ ]+)*)*$/,Pr=/^([a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*)$/,Fr=/^([^DT]*)$/,Ir=/^([^YM]*[DT].*)$/,Lr=/^(.*(Z|(\+|-)[0-9][0-9]:[0-9][0-9]))$/,Rr=new X([tr,Mr],Q.xsd.normalizedString),zr=new X([tr,Mr,Nr],Q.xsd.token),Br=new X(Pr,Q.xsd.language),Vr=new Z(null,null,Q.xsd.integer),Hr=new Z(null,`0`,Q.xsd.nonPositiveInteger),Ur=new Z(null,`-1`,Q.xsd.negativeInteger),Wr=new Z(`-9223372036854775808`,`9223372036854775807`,Q.xsd.long),Gr=new Z(`-2147483648`,`2147483647`,Q.xsd.int),Kr=new Z(`-32768`,`32767`,Q.xsd.short),qr=new Z(`-128`,`127`,Q.xsd.byte),Jr=new Z(`0`,null,Q.xsd.nonNegativeInteger),Yr=new Z(`0`,`18446744073709551615`,Q.xsd.unsignedLong),Xr=new Z(`0`,`4294967295`,Q.xsd.unsignedInt),Zr=new Z(`0`,`65535`,Q.xsd.unsignedShort),Qr=new Z(`0`,`255`,Q.xsd.unsignedByte),$r=new Z(`1`,null,Q.xsd.positiveInteger),ei=new X([ir,Fr],Q.xsd.yearMonthDuration),ti=new X([ir,Ir],Q.xsd.dayTimeDuration),ni=new X([ar,Lr],Q.xsd.dateTimeStamp),ri=class extends Yn{constructor({factory:e}={}){super({factory:e,validations:{...Qn}})}},ii=new Re([[P.BlankNode,new Set([`BlankNode`])],[P.BlankNodeOrIRI,new Set([`BlankNode`,`NamedNode`])],[P.BlankNodeOrLiteral,new Set([`BlankNode`,`Literal`])],[P.IRI,new Set([`NamedNode`])],[P.IRIOrLiteral,new Set([`NamedNode`,`Literal`])],[P.Literal,new Set([`Literal`])]]);function ai(e){return{generic:oi(e.ptr.out([P.class]).map(e=>Bt(e)))}}function oi(e){return t=>{let n=new k(t.valueOrNode.out([at.type]).terms);for(let r of e){let e=[...n].some(e=>r.has(e));t.test(e,P.ClassConstraintComponent,{value:t.valueOrNode})}}}function si(e){let t=e.ptr.out([P.datatype]).term;return{generic:ci(t,new ri)}}function ci(e,t){return n=>{let r=e.equals(n.valueOrNode.term.datatype)&&t.validateSimple(n.valueOrNode.term);n.test(r,P.DatatypeConstraintComponent,{args:{datatype:e},message:[n.factory.literal(`Value does not have datatype {$datatype}`)],value:n.valueOrNode})}}function li(e){let t=e.ptr.out([P.nodeKind]).term;return{generic:ui(t,ii.get(t))}}function ui(e,t){return n=>{n.test(t.has(n.valueOrNode.term.termType),P.NodeKindConstraintComponent,{args:{nodeKind:e},message:[n.factory.literal(`Value does not have node kind {$nodeKind}`)],value:n.valueOrNode})}}var di=new Re([[P.maxCount,Wt],[P.minCount,Kt],[P.and,Yt],[P.not,Zt],[P.or,$t],[P.xone,tn],[P.closed,nn],[P.hasValue,an],[P.in,cn],[P.disjoint,dn],[P.equals,fn],[P.lessThan,hn],[P.lessThanOrEquals,_n],[P.maxExclusive,yn],[P.maxInclusive,xn],[P.minExclusive,Cn],[P.minInclusive,Tn],[P.node,Dn],[P.property,kn],[P.qualifiedValueShape,jn],[P.languageIn,Pn],[P.maxLength,In],[P.minLength,Rn],[P.pattern,J],[P.uniqueLang,Vn],[P.class,ai],[P.datatype,si],[P.nodeKind,li]]),fi=class{constructor(e,{factory:t,...n}){if(this.factory=t,this.options=n,this.registry=new z(di),this.targetResolverRegistry=new Ut(this.options.targetResolvers||[]),this.shapesPtr=new it({dataset:e,factory:t}),this.shapes=new Re,this.options.coverage&&(this.options.debug=!0,this.options.details=!0,this.options.trace=!0),this.options.validations)for(let[e,t]of this.options.validations)this.registry.validations.set(e,t);let r=[...this.shapesPtr.hasOut([P.targetClass]),...this.shapesPtr.hasOut([P.targetNode]),...this.shapesPtr.hasOut([P.targetObjectsOf]),...this.shapesPtr.hasOut([P.targetSubjectsOf]),...this.shapesPtr.hasOut([P.target]),...this.shapesPtr.hasOut([at.type],[P.NodeShape]),...this.shapesPtr.hasOut([at.type],[P.PropertyShape])];for(let e of r)this.shape(e)}shape(e){if(!e.term)return null;let t=this.shapes.get(e.term);return t||(t=new Ht(e,{validator:this}),this.shapes.set(e.term,t)),t}async validate(e,t){let n=new it({...e,factory:this.factory}),r=new Ot({factory:this.factory,focusNode:n,options:this.options,validator:this});t=t?t.map(e=>this.shape(this.shapesPtr.node(e.terms))):this.shapes.values();for(let e of t){let t=r.create({shape:e}),i;i=n.isAny()?await e.resolveTargets(t):n;for(let n of i)await e.validate(t.create({focusNode:n}))}return r.report}},pi=class{constructor(){this.shapes=null,this.shapesUrl=null,this.shapeSubject=null,this.values=null,this.valuesUrl=null,this.valueSubject=null,this.valuesSubject=null,this.valuesNamespace=``,this.valuesGraph=null,this.view=null,this.mode=null,this.language=null,this.loading=`Loading…`,this.proxy=null,this.ignoreOwlImports=null,this.collapse=null,this.hierarchyColors=null,this.submitButton=null,this.generateNodeShapeReference=D.value,this.showNodeIds=null,this.showRootShapeLabel=null,this.dense=`true`,this.useShadowRoot=`true`}},mi=`#4c93d785, #f85e9a85, #00327385, #87001f85`,hi=class{constructor(e){this.attributes=new pi,this.mode=`edit`,this.lists={},this.groups=[],this.renderedNodes=new Set,this._store=new ie,this._nodeTemplates={},this._propertyTemplates={},this.validator=new fi(this._store,{details:!0,factory:E}),this.providedConformingResourceIds={},this.providedResources={},this.providedResourceLabels={},this.form=e,this._theme=new Te,this.languages=[...new Set(navigator.languages.flatMap(e=>e.length>2?[e.toLocaleLowerCase(),e.substring(0,2)]:e)),``]}reset(){this.lists={},this.groups=[],this.renderedNodes.clear(),this.providedConformingResourceIds={},this.providedResources={},this.providedResourceLabels={},this._nodeTemplates={},this._propertyTemplates={}}updateAttributes(e){let t=new pi;if(Object.keys(t).forEach(n=>{let r=e.dataset[n];r!==void 0&&(t[n]=r)}),t.mode!==null&&![`edit`,`view`,`query`].includes(t.mode))throw Error(`invalid shacl-form mode: ${t.mode}`);if(this.mode=t.mode??(t.view===null?`edit`:`view`),this.theme.setDense(t.dense===`true`),this.attributes=t,this.attributes.valueSubject&&!this.attributes.valuesSubject&&(this.attributes.valuesSubject=this.attributes.valueSubject),t.language){let e=this.languages.indexOf(t.language);e>-1&&this.languages.splice(e,1),this.languages.unshift(t.language)}if(t.valuesGraph&&(this.valuesGraphId=E.namedNode(t.valuesGraph)),t.hierarchyColors!=null){let e=t.hierarchyColors.length?t.hierarchyColors:mi,n=`:host { --hierarchy-colors: ${e}; --hierarchy-colors-length: ${e.split(`,`).length} }`;for(let e=8;e>=0;e--){let t=`shacl-property { --hierarchy-level: ${e} }`;for(let n=0;n<e;n++)t=`shacl-property `+t;n=n+`
10
- `+t}this.hierarchyColorsStyleSheet=new CSSStyleSheet,this.hierarchyColorsStyleSheet.replaceSync(n)}}static dataAttributes(){let e=new pi;return Object.keys(e).map(e=>(e=e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase()),`data-`+e))}buildTemplateKey(e,t){let n=e.value;return t&&(t instanceof d?n+=`*`+t.id.value:n+=`*`+this.buildTemplateKey(t.id,t.parent)),n}registerNodeTemplate(e){this._nodeTemplates[this.buildTemplateKey(e.id,e.parent)]=e}registerPropertyTemplate(e){this._propertyTemplates[this.buildTemplateKey(e.id,e.parent)]=e}getNodeTemplateIds(){let e=new Set;for(let t of Object.values(this._nodeTemplates))e.add(t.id.value);return e}getNodeTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._nodeTemplates[n];return r||=new pe(e,this,t),r}getPropertyTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._propertyTemplates[n];return r||=new d(e,t),r}get nodeTemplates(){return Object.values(this._nodeTemplates)}get theme(){return this._theme}set theme(e){this._theme=e,e.setDense(this.attributes.dense===`true`)}get store(){return this._store}get editMode(){return this.mode===`edit`}get queryMode(){return this.mode===`query`}set store(n){this._store=n,this.lists=t(n,{ignoreErrors:!0}),this.groups=[],n.forSubjects(e=>{this.groups.push(e.id)},e,`${ne}PropertyGroup`,null),this.validator=new fi(n,{details:!0,factory:E})}},gi=200,_i=class extends HTMLElement{static get observedAttributes(){return hi.dataAttributes()}constructor(){super(),this.shape=null,this.styleElement=null,this.form=document.createElement(`form`),this.form.setAttribute(`part`,`form`),this.config=new hi(this.form),this.form.addEventListener(`change`,e=>{e.stopPropagation(),this.config.queryMode?this.queryController?.handleChange():this.config.editMode&&this.validate(!0).then(e=>{this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,cancelable:!1,composed:!0,detail:{valid:e.conforms,report:e}}))}).catch(e=>{console.warn(e)})})}connectedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}attributeChangedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}initialize(){clearTimeout(this.initDebounceTimeout),this.queryController?.dispose(),this.queryController=void 0,this.setAttribute(`loading`,``),this.form.replaceChildren(document.createTextNode(this.config.attributes.loading)),this.initDebounceTimeout=setTimeout(async()=>{try{this.config.reset(),this.config.store=await se({shapes:this.config.attributes.shapes,shapesUrl:this.config.attributes.shapesUrl,values:this.config.attributes.values,valuesUrl:this.config.attributes.valuesUrl,valuesSubject:this.config.attributes.valuesSubject,loadOwlImports:this.config.attributes.ignoreOwlImports===null,classInstanceProvider:this.config.classInstanceProvider,rdfUrlResolver:this.config.rdfUrlResolver,proxy:this.config.attributes.proxy}),this.config.resourceLinkProvider&&await he(this.config),this.config.attributes.valuesSubject||(this.config.attributes.valuesSubject=x(this.config.store)||null),this.form.replaceChildren();let e=this.findRootShaclShapeSubject();if(e){if(this.form.classList.forEach(e=>{this.form.classList.remove(e)}),this.form.classList.toggle(`mode-edit`,this.config.editMode),this.form.classList.toggle(`mode-view`,this.config.mode===`view`),this.form.classList.toggle(`mode-query`,this.config.queryMode),this.config.queryMode){let{QueryModeController:e}=await r(async()=>{let{QueryModeController:e}=await import(`./assets/mode-f6xgDLiM.js`);return{QueryModeController:e}},__vite__mapDeps([0,1]));this.queryController=new e(this)}this.config.theme.apply(this.form);let t=[this.config.theme.stylesheet];this.config.hierarchyColorsStyleSheet&&t.push(this.config.hierarchyColorsStyleSheet),this.queryController&&t.push(this.queryController.stylesheet);for(let e of Se())e.stylesheet&&t.push(e.stylesheet);this.applyStyles(t);let n=new pe(e,this.config);for(let e of this.config.nodeTemplates)y(e);if(this.shape=new w(n,this.config.attributes.valuesSubject?E.namedNode(this.config.attributes.valuesSubject):void 0),this.form.appendChild(this.shape),this.config.attributes.showRootShapeLabel!==null&&n.label){let e=document.createElement(`h3`);e.innerText=n.label.value,this.form.prepend(e)}if(this.config.editMode){if(this.config.attributes.submitButton!==null){let e=this.config.theme.createButton(this.config.attributes.submitButton||`Submit`,!0);e.classList.add(`submit-button`);let t=e.getAttribute(`part`);e.setAttribute(`part`,`${t?t+` `:``}submit-button`),e.addEventListener(`click`,e=>{e.preventDefault(),this.form.reportValidity()&&this.validate().then(e=>{if(e?.conforms)this.dispatchEvent(new Event(`submit`,{bubbles:!0,cancelable:!0}));else{let e=this.form.querySelector(`:scope .invalid > .editor`);e?e.focus():this.form.querySelector(`:scope .invalid`)?.scrollIntoView()}})}),this.form.appendChild(e)}(async()=>{await this.shape?.ready,this.config.attributes.valuesSubject&&this.removeFromDataGraph(E.namedNode(this.config.attributes.valuesSubject)),this.validate(!0)})()}else this.config.queryMode&&(await this.shape.ready,await this.queryController?.initialize())}else if(this.config.store.countQuads(null,null,null,me)>0)throw Error(`shacl root node shape not found`)}catch(e){console.error(e);let t=document.createElement(`div`);t.innerText=String(e),this.form.replaceChildren(t)}this.removeAttribute(`loading`),await this.shape?.ready,this.dispatchEvent(new Event(`ready`))},200)}ensureRenderRoot(){this.config.attributes.useShadowRoot===`false`?(this.shadowRoot?.contains(this.form)&&this.shadowRoot.removeChild(this.form),this.contains(this.form)||this.prepend(this.form)):(this.shadowRoot||this.attachShadow({mode:`open`}),this.shadowRoot.contains(this.form)||this.shadowRoot.prepend(this.form))}applyStyles(e){if(this.config.attributes.useShadowRoot!==`false`&&this.shadowRoot){this.shadowRoot.adoptedStyleSheets=e,this.styleElement&&=(this.styleElement.remove(),null);return}let t=e.map(e=>Array.from(e.cssRules).map(e=>e.cssText).join(`
10
+ `+t}this.hierarchyColorsStyleSheet=new CSSStyleSheet,this.hierarchyColorsStyleSheet.replaceSync(n)}}static dataAttributes(){let e=new pi;return Object.keys(e).map(e=>(e=e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase()),`data-`+e))}buildTemplateKey(e,t){let n=e.value;return t&&(t instanceof d?n+=`*`+t.id.value:n+=`*`+this.buildTemplateKey(t.id,t.parent)),n}registerNodeTemplate(e){this._nodeTemplates[this.buildTemplateKey(e.id,e.parent)]=e}registerPropertyTemplate(e){this._propertyTemplates[this.buildTemplateKey(e.id,e.parent)]=e}getNodeTemplateIds(){let e=new Set;for(let t of Object.values(this._nodeTemplates))e.add(t.id.value);return e}getNodeTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._nodeTemplates[n];return r||=new pe(e,this,t),r}getPropertyTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._propertyTemplates[n];return r||=new d(e,t),r}get nodeTemplates(){return Object.values(this._nodeTemplates)}get theme(){return this._theme}set theme(e){this._theme=e,e.setDense(this.attributes.dense===`true`)}get store(){return this._store}get editMode(){return this.mode===`edit`}get queryMode(){return this.mode===`query`}set store(n){this._store=n,this.lists=t(n,{ignoreErrors:!0}),this.groups=[],n.forSubjects(e=>{this.groups.push(e.id)},e,`${ne}PropertyGroup`,null),this.validator=new fi(n,{details:!0,factory:E})}},gi=200,_i=class extends HTMLElement{static get observedAttributes(){return hi.dataAttributes()}constructor(){super(),this.shape=null,this.styleElement=null,this.form=document.createElement(`form`),this.form.setAttribute(`part`,`form`),this.config=new hi(this.form),this.form.addEventListener(`change`,e=>{e.stopPropagation(),this.config.queryMode?this.queryController?.handleChange():this.config.editMode&&this.validate(!0).then(e=>{this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,cancelable:!1,composed:!0,detail:{valid:e.conforms,report:e}}))}).catch(e=>{console.warn(e)})})}connectedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}attributeChangedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}initialize(){clearTimeout(this.initDebounceTimeout),this.queryController?.dispose(),this.queryController=void 0,this.setAttribute(`loading`,``),this.form.replaceChildren(document.createTextNode(this.config.attributes.loading)),this.initDebounceTimeout=setTimeout(async()=>{try{this.config.reset(),this.config.store=await se({shapes:this.config.attributes.shapes,shapesUrl:this.config.attributes.shapesUrl,values:this.config.attributes.values,valuesUrl:this.config.attributes.valuesUrl,valuesSubject:this.config.attributes.valuesSubject,loadOwlImports:this.config.attributes.ignoreOwlImports===null,classInstanceProvider:this.config.classInstanceProvider,rdfUrlResolver:this.config.rdfUrlResolver,proxy:this.config.attributes.proxy}),this.config.resourceLinkProvider&&await he(this.config),this.config.attributes.valuesSubject||(this.config.attributes.valuesSubject=x(this.config.store)||null),this.form.replaceChildren();let e=this.findRootShaclShapeSubject();if(e){if(this.form.classList.forEach(e=>{this.form.classList.remove(e)}),this.form.classList.toggle(`mode-edit`,this.config.editMode),this.form.classList.toggle(`mode-view`,this.config.mode===`view`),this.form.classList.toggle(`mode-query`,this.config.queryMode),this.config.queryMode){let{QueryModeController:e}=await r(async()=>{let{QueryModeController:e}=await import(`./assets/mode-KFvmvNiB.js`);return{QueryModeController:e}},__vite__mapDeps([0,1]));this.queryController=new e(this)}this.config.theme.apply(this.form);let t=[this.config.theme.stylesheet];this.config.hierarchyColorsStyleSheet&&t.push(this.config.hierarchyColorsStyleSheet),this.queryController&&t.push(this.queryController.stylesheet);for(let e of Se())e.stylesheet&&t.push(e.stylesheet);this.applyStyles(t);let n=new pe(e,this.config);for(let e of this.config.nodeTemplates)y(e);if(this.shape=new w(n,this.config.attributes.valuesSubject?E.namedNode(this.config.attributes.valuesSubject):void 0),this.form.appendChild(this.shape),this.config.attributes.showRootShapeLabel!==null&&n.label){let e=document.createElement(`h3`);e.innerText=n.label.value,this.form.prepend(e)}if(this.config.editMode){if(this.config.attributes.submitButton!==null){let e=this.config.theme.createButton(this.config.attributes.submitButton||`Submit`,!0);e.classList.add(`submit-button`);let t=e.getAttribute(`part`);e.setAttribute(`part`,`${t?t+` `:``}submit-button`),e.addEventListener(`click`,e=>{e.preventDefault(),this.form.reportValidity()&&this.validate().then(e=>{if(e?.conforms)this.dispatchEvent(new Event(`submit`,{bubbles:!0,cancelable:!0}));else{let e=this.form.querySelector(`:scope .invalid > .editor`);e?e.focus():this.form.querySelector(`:scope .invalid`)?.scrollIntoView()}})}),this.form.appendChild(e)}(async()=>{await this.shape?.ready,this.config.attributes.valuesSubject&&this.removeFromDataGraph(E.namedNode(this.config.attributes.valuesSubject)),this.validate(!0)})()}else this.config.queryMode&&(await this.shape.ready,await this.queryController?.initialize())}else if(this.config.store.countQuads(null,null,null,me)>0)throw Error(`shacl root node shape not found`)}catch(e){console.error(e);let t=document.createElement(`div`);t.innerText=String(e),this.form.replaceChildren(t)}this.removeAttribute(`loading`),await this.shape?.ready,this.dispatchEvent(new Event(`ready`))},200)}ensureRenderRoot(){this.config.attributes.useShadowRoot===`false`?(this.shadowRoot?.contains(this.form)&&this.shadowRoot.removeChild(this.form),this.contains(this.form)||this.prepend(this.form)):(this.shadowRoot||this.attachShadow({mode:`open`}),this.shadowRoot.contains(this.form)||this.shadowRoot.prepend(this.form))}applyStyles(e){if(this.config.attributes.useShadowRoot!==`false`&&this.shadowRoot){this.shadowRoot.adoptedStyleSheets=e,this.styleElement&&=(this.styleElement.remove(),null);return}let t=e.map(e=>Array.from(e.cssRules).map(e=>e.cssText).join(`
11
11
  `).replace(/:host\b/g,`shacl-form`)).join(`
12
12
  `);this.styleElement||(this.styleElement=document.createElement(`style`),this.prepend(this.styleElement)),this.styleElement.textContent=t}serialize(e=`text/turtle`,t){return this.assertNotQueryMode(`serialize`),t??=this.toRDF(),n(t.getQuads(null,null,null,null),e,o)}toRDF(e=new ie){return this.assertNotQueryMode(`toRDF`),this.shape?.toRDF(e,void 0,this.config.attributes.generateNodeShapeReference),e}registerPlugin(e){m(e),this.initialize()}setTheme(e){this.config.theme=e,this.initialize()}setClassInstanceProvider(e){this.config.classInstanceProvider=e,this.initialize()}setRdfUrlResolver(e){this.config.rdfUrlResolver=e,this.initialize()}setResourceLinkProvider(e){this.config.resourceLinkProvider=e,this.initialize()}setQueryFacetProvider(e){this.config.queryFacetProvider=e,this.queryController?.refreshFacets()}getQuery(){return this.shape?this.queryController?.getQuery()??{rootShapeId:this.shape.template.id.value,targetClass:this.shape.template.targetClass?.value,criteria:[]}:{rootShapeId:``,criteria:[]}}refreshQueryFacets(){this.queryController?.refreshFacets()}async validate(e=!1){this.assertNotQueryMode(`validate`);for(let e of this.form.querySelectorAll(`:scope .validation-error`))e.remove();for(let e of this.form.querySelectorAll(`:scope .property-instance`))e.classList.remove(`invalid`),e.querySelector(`:scope > .editor`)?.value?e.classList.add(`valid`):e.classList.remove(`valid`);for(let e of this.form.querySelectorAll(`.add-button-wrapper`))e.classList.remove(`invalid`,`validation-error`);if(!this.shape)return{conforms:!0,results:[]};if(!e){let e=this.form.querySelectorAll(`.add-button-wrapper.required`);for(let t of e)t.classList.add(`invalid`),t.after(this.createValidationErrorDisplay(`Value is required`,`node`));if(e.length>0)return{conforms:!1,results:[]}}let t=this.shape;return new Promise(n=>{this.config.store.deleteGraph(this.config.valuesGraphId||``).on(`end`,async()=>{t.toRDF(this.config.store,void 0,this.config.attributes.generateNodeShapeReference);try{let r=await this.config.validator.validate({dataset:this.config.store,terms:[t.nodeId]},[{terms:[t.template.id]}]);for(let t of r.results)if(t.focusNode?.ptrs?.length)for(let n of t.focusNode.ptrs){let r=n._term;if(t.path?.length){let n=t.path[0].predicates[0],i=this.form.querySelectorAll(`
13
13
  :scope shacl-node[data-node-id='${r.id}'] > shacl-property > .property-instance[data-path='${n.id}'] > .editor,
package/dist/index.js CHANGED
@@ -1,11 +1,10 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mode-BriAnl-6.js","assets/query-DLp_5-vp.js"])))=>i.map(i=>d[i]);
2
- import{C as e,D as t,E as n,F as r,G as i,I as a,J as o,K as s,L as c,M as l,O as u,P as d,R as f,T as p,V as m,W as h,Y as g,_,b as v,c as y,d as b,f as x,g as S,h as C,i as w,j as T,k as E,l as D,m as O,n as k,q as A,r as j,s as M,t as ee,u as N,x as P,y as F,z as I}from"./assets/query-DLp_5-vp.js";import{DataFactory as L,Literal as R,NamedNode as z,Store as B}from"n3";import{RokitButton as V,RokitCollapsible as H,RokitInput as U,RokitSelect as W,RokitTextArea as G}from"@ro-kit/ui-widgets";import{Validator as K}from"shacl-engine";var q=`
1
+ import{C as e,D as t,E as n,F as r,G as i,I as a,J as o,K as s,L as c,M as l,O as u,P as d,R as f,T as p,V as m,W as h,Y as g,_,b as v,c as y,d as b,f as x,g as S,h as C,i as w,j as T,k as E,l as D,m as O,n as k,q as A,r as j,s as M,t as ee,u as N,x as P,y as F,z as I}from"./assets/query-rxkbsWqy.js";import{DataFactory as L,Literal as R,NamedNode as z,Store as B}from"n3";import{RokitButton as V,RokitCollapsible as H,RokitInput as U,RokitSelect as W,RokitTextArea as G}from"@ro-kit/ui-widgets";import{Validator as K}from"shacl-engine";var q=`
3
2
  .editor:not([type='checkbox']) { border: 1px solid var(--shacl-border-color, #DDD); }
4
3
  .property-instance label { display: inline-flex; word-break: break-word; line-height: 1em; padding-top: 0.15em; padding-right: 1em; flex-shrink: 0; position: relative; }
5
4
  .property-instance:not(:first-child) > label:not(.persistent) { visibility: hidden; max-height: 0; }
6
5
  .mode-edit .property-instance label { width: var(--label-width); }
7
6
  `,J=class extends _{constructor(e){super(e||q),this.idCtr=0}createDefaultTemplate(e,t,n,r,a){if(r.id=`e${this.idCtr++}`,r.classList.add(`editor`),r.setAttribute(`part`,`editor`),a?.datatype?r.shaclDatatype=a.datatype:t instanceof R&&(r.shaclDatatype=t.datatype),a&&P(a)>0&&(r.dataset.minCount=String(P(a))),a?.class&&(r.dataset.class=a.class.value),a?.nodeKind)r.dataset.nodeKind=a.nodeKind.value;else if(t&&(t instanceof z||a?.nodeKind?.equals(i))&&(r.dataset.nodeKind=m+`IRI`,a)){let e=d(a.config.store.getQuads(t,null,null,null),a.config.languages);e&&(r.dataset.value=`<`+t.value+`>`,t=L.literal(e))}(a?.hasValue&&t||a?.readonly)&&(r.disabled=!0);let o=t?.value||a?.defaultValue?.value||``;a?.datatype?.equals(g)?r.checked=t?.value===`true`||a?.defaultValue?.value===`true`:r.type===`file`?r.binaryData=o||void 0:r.value=o;let s=document.createElement(`label`);s.htmlFor=r.id,s.innerText=e,s.setAttribute(`part`,`label`),a?.description&&s.setAttribute(`title`,a.description.value);let c=a?.description?a.description.value:a?.pattern?a.pattern:null;c&&r.setAttribute(`placeholder`,c),n&&(r.setAttribute(`required`,`true`),s.classList.add(`required`));let l=document.createElement(`div`);return l.setAttribute(`part`,`field`),l.appendChild(s),l.appendChild(r),l}createDateEditor(e,t,n,i){let o=new U;i.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?(o.type=`datetime-local`,o.setAttribute(`step`,`1`)):o.type=`date`,o.clearable=!0,o.dense=this.dense,o.classList.add(`pr-0`);let s=this.createDefaultTemplate(e,null,n,o,i);if(t){let e=i.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?r(t.value):a(t.value);e?(o.value=e.value,e.suffix&&(o.dataset.xsdTemporalSuffix=e.suffix)):console.error(`unable to parse xsd date literal`,t)}return s}createTextEditor(e,t,n,r){let i;return r.singleLine===!1?(i=new G,i.resize=`auto`):i=new U,i.dense=this.dense,r.pattern&&(i.pattern=r.pattern),r.minLength&&(i.minLength=r.minLength),r.maxLength&&(i.maxLength=r.maxLength),this.createDefaultTemplate(e,t,n,i,r)}createLangStringEditor(e,t,n,r){let i=this.createTextEditor(e,t,n,r),a=i.querySelector(`:scope .editor`),o;if(r.languageIn?.length){o=document.createElement(`select`);for(let e of r.languageIn){let t=document.createElement(`option`);t.innerText=e.value,o.appendChild(t)}}else o=document.createElement(`input`),o.maxLength=5,o.size=5,o.placeholder=`lang?`;return o.title=`Language of the text`,o.classList.add(`lang-chooser`),o.setAttribute(`part`,`lang-chooser`),o.slot=`suffix`,a.addEventListener(`change`,()=>{o.required=a.value!==``}),o.addEventListener(`change`,e=>{e.stopPropagation(),a&&(a.dataset.lang=o.value,a.dispatchEvent(new Event(`change`,{bubbles:!0})))}),t instanceof R&&(o.value=t.language),a.dataset.lang=o.value,a.appendChild(o),i}createBooleanEditor(e,t,n,r){let i=document.createElement(`input`);i.type=`checkbox`,i.classList.add(`ml-0`);let a=this.createDefaultTemplate(e,null,n,i,r);return i.removeAttribute(`required`),a.querySelector(`:scope label`)?.classList.remove(`required`),t instanceof R&&(i.checked=t.value===`true`),a}createFileEditor(e,t,n,r){let i=document.createElement(`input`);return i.type=`file`,i.addEventListener(`change`,e=>{if(i.files?.length){e.stopPropagation();let t=new FileReader;t.readAsDataURL(i.files[0]),t.onload=()=>{i.binaryData=btoa(t.result),i.parentElement?.dispatchEvent(new Event(`change`,{bubbles:!0}))}}else i.binaryData=void 0}),this.createDefaultTemplate(e,t,n,i,r)}createNumberEditor(e,t,n,r){let i=new U,a=I.has(r.datatype?.value??``);i.type=a?`text`:`number`,a&&(i.pattern=r.datatype?.value===`http://www.w3.org/2001/XMLSchema#decimal`?`[+\\-]?(?:[0-9]+(?:[.,][0-9]*)?|[.,][0-9]+)`:`[+\\-]?(?:[0-9]+(?:[.,][0-9]*)?|[.,][0-9]+)(?:[eE][+\\-]?[0-9]+)?`,i.updateComplete.then(()=>{i.inputElement.inputMode=`decimal`})),i.clearable=!0,i.dense=this.dense,i.classList.add(`pr-0`);let o=r.minInclusive===void 0?r.minExclusive===void 0?void 0:r.minExclusive+1:r.minInclusive,s=r.maxInclusive===void 0?r.maxExclusive===void 0?void 0:r.maxExclusive-1:r.maxInclusive;return o!==void 0&&(i.min=String(o)),s!==void 0&&(i.max=String(s)),!a&&r.datatype?.value!==`http://www.w3.org/2001/XMLSchema#integer`&&(i.step=`any`),this.createDefaultTemplate(e,t,n,i,r)}createListEditor(e,t,n,r,i){let a=new W;a.clearable=!0,a.dense=this.dense;let o=this.createDefaultTemplate(e,null,n,a,i),s=document.createElement(`ul`),c=!0,l=(e,t)=>{let n=document.createElement(`li`);if(typeof e.value==`string`?(n.dataset.value=e.value,n.innerText=e.label?e.label:e.value):(n.dataset.value=e.value.id,e.value instanceof z&&(n.dataset.value=`<`+n.dataset.value+`>`),n.innerText=e.label?e.label:e.value.value),t.appendChild(n),e.children?.length){c=!1;let t=document.createElement(`ul`);n.appendChild(t);for(let n of e.children)l(n,t)}};for(let e of r)l(e,s);return c||(a.collapse=!0),a.appendChild(s),t=t??i?.defaultValue??null,t&&(a.value=t.id,t instanceof z&&(a.value=`<`+a.value+`>`)),o}createButton(e,t){let n=new V;return n.dense=this.dense,n.innerHTML=e,t?(n.setAttribute(`primary`,``),n.setAttribute(`part`,`button primary`)):n.setAttribute(`part`,`button`),n}},Y=class{constructor(){this.shapes=null,this.shapesUrl=null,this.shapeSubject=null,this.values=null,this.valuesUrl=null,this.valueSubject=null,this.valuesSubject=null,this.valuesNamespace=``,this.valuesGraph=null,this.view=null,this.mode=null,this.language=null,this.loading=`Loading…`,this.proxy=null,this.ignoreOwlImports=null,this.collapse=null,this.hierarchyColors=null,this.submitButton=null,this.generateNodeShapeReference=f.value,this.showNodeIds=null,this.showRootShapeLabel=null,this.dense=`true`,this.useShadowRoot=`true`}},X=`#4c93d785, #f85e9a85, #00327385, #87001f85`,Z=class{constructor(e){this.attributes=new Y,this.mode=`edit`,this.lists={},this.groups=[],this.renderedNodes=new Set,this._store=new B,this._nodeTemplates={},this._propertyTemplates={},this.validator=new K(this._store,{details:!0,factory:L}),this.providedConformingResourceIds={},this.providedResources={},this.providedResourceLabels={},this.form=e,this._theme=new J,this.languages=[...new Set(navigator.languages.flatMap(e=>e.length>2?[e.toLocaleLowerCase(),e.substring(0,2)]:e)),``]}reset(){this.lists={},this.groups=[],this.renderedNodes.clear(),this.providedConformingResourceIds={},this.providedResources={},this.providedResourceLabels={},this._nodeTemplates={},this._propertyTemplates={}}updateAttributes(e){let t=new Y;if(Object.keys(t).forEach(n=>{let r=e.dataset[n];r!==void 0&&(t[n]=r)}),t.mode!==null&&![`edit`,`view`,`query`].includes(t.mode))throw Error(`invalid shacl-form mode: ${t.mode}`);if(this.mode=t.mode??(t.view===null?`edit`:`view`),this.theme.setDense(t.dense===`true`),this.attributes=t,this.attributes.valueSubject&&!this.attributes.valuesSubject&&(this.attributes.valuesSubject=this.attributes.valueSubject),t.language){let e=this.languages.indexOf(t.language);e>-1&&this.languages.splice(e,1),this.languages.unshift(t.language)}if(t.valuesGraph&&(this.valuesGraphId=L.namedNode(t.valuesGraph)),t.hierarchyColors!=null){let e=t.hierarchyColors.length?t.hierarchyColors:X,n=`:host { --hierarchy-colors: ${e}; --hierarchy-colors-length: ${e.split(`,`).length} }`;for(let e=8;e>=0;e--){let t=`shacl-property { --hierarchy-level: ${e} }`;for(let n=0;n<e;n++)t=`shacl-property `+t;n=n+`
8
- `+t}this.hierarchyColorsStyleSheet=new CSSStyleSheet,this.hierarchyColorsStyleSheet.replaceSync(n)}}static dataAttributes(){let e=new Y;return Object.keys(e).map(e=>(e=e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase()),`data-`+e))}buildTemplateKey(e,t){let n=e.value;return t&&(t instanceof v?n+=`*`+t.id.value:n+=`*`+this.buildTemplateKey(t.id,t.parent)),n}registerNodeTemplate(e){this._nodeTemplates[this.buildTemplateKey(e.id,e.parent)]=e}registerPropertyTemplate(e){this._propertyTemplates[this.buildTemplateKey(e.id,e.parent)]=e}getNodeTemplateIds(){let e=new Set;for(let t of Object.values(this._nodeTemplates))e.add(t.id.value);return e}getNodeTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._nodeTemplates[n];return r||=new j(e,this,t),r}getPropertyTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._propertyTemplates[n];return r||=new v(e,t),r}get nodeTemplates(){return Object.values(this._nodeTemplates)}get theme(){return this._theme}set theme(e){this._theme=e,e.setDense(this.attributes.dense===`true`)}get store(){return this._store}get editMode(){return this.mode===`edit`}get queryMode(){return this.mode===`query`}set store(e){this._store=e,this.lists=T(e,{ignoreErrors:!0}),this.groups=[],e.forSubjects(e=>{this.groups.push(e.id)},h,`${m}PropertyGroup`,null),this.validator=new K(e,{details:!0,factory:L})}},Q=200,$=class extends HTMLElement{static get observedAttributes(){return Z.dataAttributes()}constructor(){super(),this.shape=null,this.styleElement=null,this.form=document.createElement(`form`),this.form.setAttribute(`part`,`form`),this.config=new Z(this.form),this.form.addEventListener(`change`,e=>{e.stopPropagation(),this.config.queryMode?this.queryController?.handleChange():this.config.editMode&&this.validate(!0).then(e=>{this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,cancelable:!1,composed:!0,detail:{valid:e.conforms,report:e}}))}).catch(e=>{console.warn(e)})})}connectedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}attributeChangedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}initialize(){clearTimeout(this.initDebounceTimeout),this.queryController?.dispose(),this.queryController=void 0,this.setAttribute(`loading`,``),this.form.replaceChildren(document.createTextNode(this.config.attributes.loading)),this.initDebounceTimeout=setTimeout(async()=>{try{this.config.reset(),this.config.store=await b({shapes:this.config.attributes.shapes,shapesUrl:this.config.attributes.shapesUrl,values:this.config.attributes.values,valuesUrl:this.config.attributes.valuesUrl,valuesSubject:this.config.attributes.valuesSubject,loadOwlImports:this.config.attributes.ignoreOwlImports===null,classInstanceProvider:this.config.classInstanceProvider,rdfUrlResolver:this.config.rdfUrlResolver,proxy:this.config.attributes.proxy}),this.config.resourceLinkProvider&&await M(this.config),this.config.attributes.valuesSubject||(this.config.attributes.valuesSubject=D(this.config.store)||null),this.form.replaceChildren();let e=this.findRootShaclShapeSubject();if(e){if(this.form.classList.forEach(e=>{this.form.classList.remove(e)}),this.form.classList.toggle(`mode-edit`,this.config.editMode),this.form.classList.toggle(`mode-view`,this.config.mode===`view`),this.form.classList.toggle(`mode-query`,this.config.queryMode),this.config.queryMode){let{QueryModeController:e}=await F(async()=>{let{QueryModeController:e}=await import(`./assets/mode-BriAnl-6.js`);return{QueryModeController:e}},__vite__mapDeps([0,1]));this.queryController=new e(this)}this.config.theme.apply(this.form);let t=[this.config.theme.stylesheet];this.config.hierarchyColorsStyleSheet&&t.push(this.config.hierarchyColorsStyleSheet),this.queryController&&t.push(this.queryController.stylesheet);for(let e of O())e.stylesheet&&t.push(e.stylesheet);this.applyStyles(t);let n=new j(e,this.config);for(let e of this.config.nodeTemplates)w(e);if(this.shape=new k(n,this.config.attributes.valuesSubject?L.namedNode(this.config.attributes.valuesSubject):void 0),this.form.appendChild(this.shape),this.config.attributes.showRootShapeLabel!==null&&n.label){let e=document.createElement(`h3`);e.innerText=n.label.value,this.form.prepend(e)}if(this.config.editMode){if(this.config.attributes.submitButton!==null){let e=this.config.theme.createButton(this.config.attributes.submitButton||`Submit`,!0);e.classList.add(`submit-button`);let t=e.getAttribute(`part`);e.setAttribute(`part`,`${t?t+` `:``}submit-button`),e.addEventListener(`click`,e=>{e.preventDefault(),this.form.reportValidity()&&this.validate().then(e=>{if(e?.conforms)this.dispatchEvent(new Event(`submit`,{bubbles:!0,cancelable:!0}));else{let e=this.form.querySelector(`:scope .invalid > .editor`);e?e.focus():this.form.querySelector(`:scope .invalid`)?.scrollIntoView()}})}),this.form.appendChild(e)}(async()=>{await this.shape?.ready,this.config.attributes.valuesSubject&&this.removeFromDataGraph(L.namedNode(this.config.attributes.valuesSubject)),this.validate(!0)})()}else this.config.queryMode&&(await this.shape.ready,await this.queryController?.initialize())}else if(this.config.store.countQuads(null,null,null,o)>0)throw Error(`shacl root node shape not found`)}catch(e){console.error(e);let t=document.createElement(`div`);t.innerText=String(e),this.form.replaceChildren(t)}this.removeAttribute(`loading`),await this.shape?.ready,this.dispatchEvent(new Event(`ready`))},200)}ensureRenderRoot(){this.config.attributes.useShadowRoot===`false`?(this.shadowRoot?.contains(this.form)&&this.shadowRoot.removeChild(this.form),this.contains(this.form)||this.prepend(this.form)):(this.shadowRoot||this.attachShadow({mode:`open`}),this.shadowRoot.contains(this.form)||this.shadowRoot.prepend(this.form))}applyStyles(e){if(this.config.attributes.useShadowRoot!==`false`&&this.shadowRoot){this.shadowRoot.adoptedStyleSheets=e,this.styleElement&&=(this.styleElement.remove(),null);return}let t=e.map(e=>Array.from(e.cssRules).map(e=>e.cssText).join(`
7
+ `+t}this.hierarchyColorsStyleSheet=new CSSStyleSheet,this.hierarchyColorsStyleSheet.replaceSync(n)}}static dataAttributes(){let e=new Y;return Object.keys(e).map(e=>(e=e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase()),`data-`+e))}buildTemplateKey(e,t){let n=e.value;return t&&(t instanceof v?n+=`*`+t.id.value:n+=`*`+this.buildTemplateKey(t.id,t.parent)),n}registerNodeTemplate(e){this._nodeTemplates[this.buildTemplateKey(e.id,e.parent)]=e}registerPropertyTemplate(e){this._propertyTemplates[this.buildTemplateKey(e.id,e.parent)]=e}getNodeTemplateIds(){let e=new Set;for(let t of Object.values(this._nodeTemplates))e.add(t.id.value);return e}getNodeTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._nodeTemplates[n];return r||=new j(e,this,t),r}getPropertyTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._propertyTemplates[n];return r||=new v(e,t),r}get nodeTemplates(){return Object.values(this._nodeTemplates)}get theme(){return this._theme}set theme(e){this._theme=e,e.setDense(this.attributes.dense===`true`)}get store(){return this._store}get editMode(){return this.mode===`edit`}get queryMode(){return this.mode===`query`}set store(e){this._store=e,this.lists=T(e,{ignoreErrors:!0}),this.groups=[],e.forSubjects(e=>{this.groups.push(e.id)},h,`${m}PropertyGroup`,null),this.validator=new K(e,{details:!0,factory:L})}},Q=200,$=class extends HTMLElement{static get observedAttributes(){return Z.dataAttributes()}constructor(){super(),this.shape=null,this.styleElement=null,this.form=document.createElement(`form`),this.form.setAttribute(`part`,`form`),this.config=new Z(this.form),this.form.addEventListener(`change`,e=>{e.stopPropagation(),this.config.queryMode?this.queryController?.handleChange():this.config.editMode&&this.validate(!0).then(e=>{this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,cancelable:!1,composed:!0,detail:{valid:e.conforms,report:e}}))}).catch(e=>{console.warn(e)})})}connectedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}attributeChangedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}initialize(){clearTimeout(this.initDebounceTimeout),this.queryController?.dispose(),this.queryController=void 0,this.setAttribute(`loading`,``),this.form.replaceChildren(document.createTextNode(this.config.attributes.loading)),this.initDebounceTimeout=setTimeout(async()=>{try{this.config.reset(),this.config.store=await b({shapes:this.config.attributes.shapes,shapesUrl:this.config.attributes.shapesUrl,values:this.config.attributes.values,valuesUrl:this.config.attributes.valuesUrl,valuesSubject:this.config.attributes.valuesSubject,loadOwlImports:this.config.attributes.ignoreOwlImports===null,classInstanceProvider:this.config.classInstanceProvider,rdfUrlResolver:this.config.rdfUrlResolver,proxy:this.config.attributes.proxy}),this.config.resourceLinkProvider&&await M(this.config),this.config.attributes.valuesSubject||(this.config.attributes.valuesSubject=D(this.config.store)||null),this.form.replaceChildren();let e=this.findRootShaclShapeSubject();if(e){if(this.form.classList.forEach(e=>{this.form.classList.remove(e)}),this.form.classList.toggle(`mode-edit`,this.config.editMode),this.form.classList.toggle(`mode-view`,this.config.mode===`view`),this.form.classList.toggle(`mode-query`,this.config.queryMode),this.config.queryMode){let{QueryModeController:e}=await F(async()=>{let{QueryModeController:e}=await import(`./assets/mode-C0O1k7Tm.js`);return{QueryModeController:e}},[]);this.queryController=new e(this)}this.config.theme.apply(this.form);let t=[this.config.theme.stylesheet];this.config.hierarchyColorsStyleSheet&&t.push(this.config.hierarchyColorsStyleSheet),this.queryController&&t.push(this.queryController.stylesheet);for(let e of O())e.stylesheet&&t.push(e.stylesheet);this.applyStyles(t);let n=new j(e,this.config);for(let e of this.config.nodeTemplates)w(e);if(this.shape=new k(n,this.config.attributes.valuesSubject?L.namedNode(this.config.attributes.valuesSubject):void 0),this.form.appendChild(this.shape),this.config.attributes.showRootShapeLabel!==null&&n.label){let e=document.createElement(`h3`);e.innerText=n.label.value,this.form.prepend(e)}if(this.config.editMode){if(this.config.attributes.submitButton!==null){let e=this.config.theme.createButton(this.config.attributes.submitButton||`Submit`,!0);e.classList.add(`submit-button`);let t=e.getAttribute(`part`);e.setAttribute(`part`,`${t?t+` `:``}submit-button`),e.addEventListener(`click`,e=>{e.preventDefault(),this.form.reportValidity()&&this.validate().then(e=>{if(e?.conforms)this.dispatchEvent(new Event(`submit`,{bubbles:!0,cancelable:!0}));else{let e=this.form.querySelector(`:scope .invalid > .editor`);e?e.focus():this.form.querySelector(`:scope .invalid`)?.scrollIntoView()}})}),this.form.appendChild(e)}(async()=>{await this.shape?.ready,this.config.attributes.valuesSubject&&this.removeFromDataGraph(L.namedNode(this.config.attributes.valuesSubject)),this.validate(!0)})()}else this.config.queryMode&&(await this.shape.ready,await this.queryController?.initialize())}else if(this.config.store.countQuads(null,null,null,o)>0)throw Error(`shacl root node shape not found`)}catch(e){console.error(e);let t=document.createElement(`div`);t.innerText=String(e),this.form.replaceChildren(t)}this.removeAttribute(`loading`),await this.shape?.ready,this.dispatchEvent(new Event(`ready`))},200)}ensureRenderRoot(){this.config.attributes.useShadowRoot===`false`?(this.shadowRoot?.contains(this.form)&&this.shadowRoot.removeChild(this.form),this.contains(this.form)||this.prepend(this.form)):(this.shadowRoot||this.attachShadow({mode:`open`}),this.shadowRoot.contains(this.form)||this.shadowRoot.prepend(this.form))}applyStyles(e){if(this.config.attributes.useShadowRoot!==`false`&&this.shadowRoot){this.shadowRoot.adoptedStyleSheets=e,this.styleElement&&=(this.styleElement.remove(),null);return}let t=e.map(e=>Array.from(e.cssRules).map(e=>e.cssText).join(`
9
8
  `).replace(/:host\b/g,`shacl-form`)).join(`
10
9
  `);this.styleElement||(this.styleElement=document.createElement(`style`),this.prepend(this.styleElement)),this.styleElement.textContent=t}serialize(e=`text/turtle`,t){return this.assertNotQueryMode(`serialize`),t??=this.toRDF(),S(t.getQuads(null,null,null,null),e,u)}toRDF(e=new B){return this.assertNotQueryMode(`toRDF`),this.shape?.toRDF(e,void 0,this.config.attributes.generateNodeShapeReference),e}registerPlugin(e){C(e),this.initialize()}setTheme(e){this.config.theme=e,this.initialize()}setClassInstanceProvider(e){this.config.classInstanceProvider=e,this.initialize()}setRdfUrlResolver(e){this.config.rdfUrlResolver=e,this.initialize()}setResourceLinkProvider(e){this.config.resourceLinkProvider=e,this.initialize()}setQueryFacetProvider(e){this.config.queryFacetProvider=e,this.queryController?.refreshFacets()}getQuery(){return this.shape?this.queryController?.getQuery()??{rootShapeId:this.shape.template.id.value,targetClass:this.shape.template.targetClass?.value,criteria:[]}:{rootShapeId:``,criteria:[]}}refreshQueryFacets(){this.queryController?.refreshFacets()}async validate(e=!1){this.assertNotQueryMode(`validate`);for(let e of this.form.querySelectorAll(`:scope .validation-error`))e.remove();for(let e of this.form.querySelectorAll(`:scope .property-instance`))e.classList.remove(`invalid`),e.querySelector(`:scope > .editor`)?.value?e.classList.add(`valid`):e.classList.remove(`valid`);for(let e of this.form.querySelectorAll(`.add-button-wrapper`))e.classList.remove(`invalid`,`validation-error`);if(!this.shape)return{conforms:!0,results:[]};if(!e){let e=this.form.querySelectorAll(`.add-button-wrapper.required`);for(let t of e)t.classList.add(`invalid`),t.after(this.createValidationErrorDisplay(`Value is required`,`node`));if(e.length>0)return{conforms:!1,results:[]}}let t=this.shape;return new Promise(n=>{this.config.store.deleteGraph(this.config.valuesGraphId||``).on(`end`,async()=>{t.toRDF(this.config.store,void 0,this.config.attributes.generateNodeShapeReference);try{let r=await this.config.validator.validate({dataset:this.config.store,terms:[t.nodeId]},[{terms:[t.template.id]}]);for(let t of r.results)if(t.focusNode?.ptrs?.length)for(let n of t.focusNode.ptrs){let r=n._term;if(t.path?.length){let n=t.path[0].predicates[0],i=this.form.querySelectorAll(`
11
10
  :scope shacl-node[data-node-id='${r.id}'] > shacl-property > .property-instance[data-path='${n.id}'] > .editor,
package/dist/sparql.js CHANGED
@@ -1,9 +1,9 @@
1
- import{DataFactory as e}from"n3";e.namedNode(`loaded-shapes`),e.namedNode(`loaded-data`);var t=e.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`);e.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#langString`);var n=e.namedNode(`http://purl.org/dc/terms/conformsTo`);e.namedNode(`http://www.w3.org/2000/01/rdf-schema#subClassOf`),e.namedNode(`http://www.w3.org/2002/07/owl#imports`),e.namedNode(`http://www.w3.org/2004/02/skos/core#broader`),e.namedNode(`http://www.w3.org/2004/02/skos/core#narrower`),e.namedNode(`http://www.w3.org/ns/shacl#NodeShape`),e.namedNode(`http://www.w3.org/ns/shacl#IRI`),e.namedNode(`http://www.w3.org/ns/shacl#property`),e.namedNode(`http://www.w3.org/ns/shacl#class`),e.namedNode(`http://www.w3.org/ns/shacl#node`),e.namedNode(`http://www.w3.org/ns/shacl#targetClass`),e.namedNode(`http://www.w3.org/ns/shacl#nodeKind`),e.namedNode(`http://www.w3.org/2001/XMLSchema#string`),e.namedNode(`http://www.w3.org/2001/XMLSchema#boolean`);var r=new Set([`http://www.w3.org/2001/XMLSchema#integer`,`http://www.w3.org/2001/XMLSchema#int`,`http://www.w3.org/2001/XMLSchema#short`,`http://www.w3.org/2001/XMLSchema#byte`,`http://www.w3.org/2001/XMLSchema#unsignedInt`,`http://www.w3.org/2001/XMLSchema#unsignedShort`,`http://www.w3.org/2001/XMLSchema#unsignedByte`,`http://www.w3.org/2001/XMLSchema#long`,`http://www.w3.org/2001/XMLSchema#unsignedLong`,`http://www.w3.org/2001/XMLSchema#float`,`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`,`http://www.w3.org/2001/XMLSchema#date`,`http://www.w3.org/2001/XMLSchema#dateTime`]);function i(e){return e.datatype!==void 0&&r.has(e.datatype)}var a=`?root`,o=class{constructor(e={}){this.options=e}buildWhere(e){let t=[this.rootPattern(e),...this.criterionPatterns(e)].filter(Boolean).join(`
2
- `);return this.wrapDataset(t)}buildSelect(e,t={}){let n=t.projection?.length?t.projection.join(` `):a,r=`SELECT ${t.distinct===!1?``:`DISTINCT `}${n} WHERE {\n${g(this.buildWhere(e))}\n}`;return t.orderBy&&(r+=`\nORDER BY ${t.orderBy}`),t.limit!==void 0&&(r+=`\nLIMIT ${v(t.limit,`limit`)}`),t.offset!==void 0&&(r+=`\nOFFSET ${v(t.offset,`offset`)}`),r}buildFacetSelect(e,t,n=100){let r=`?facetValue`,o=[this.rootPattern(e.query),...this.criterionPatterns(e.query),this.pathPattern(t.path,r,`facet_${_(t.id)}`)].filter(Boolean).join(`
3
- `),s=this.wrapDataset(o);return i(t)?`SELECT (COUNT(DISTINCT ${a}) AS ?count) (MIN(${r}) AS ?min) (MAX(${r}) AS ?max) WHERE {\n${g(s)}\n}`:`SELECT ${r} ?count ?total WHERE {\n { SELECT ${r} (COUNT(DISTINCT ${a}) AS ?count) WHERE {\n${g(g(s))}\n } GROUP BY ${r} }\n { SELECT (COUNT(DISTINCT ${a}) AS ?total) WHERE {\n${g(g(s))}\n } }\n}\nORDER BY DESC(?count)\nLIMIT ${v(n,`bucketLimit`)}`}buildFacetsSelect(e,t=100){return`SELECT ?fieldId ?facetValue ?count ?total ?min ?max WHERE {\n${e.fields.map(n=>{let r=`?facetValue`,o=[this.rootPattern(e.query),...this.criterionPatterns(e.query),this.pathPattern(n.path,r,`facet_${_(n.id)}`)].filter(Boolean).join(`
4
- `),s=this.wrapDataset(o),c=`BIND(${p(n.id)} AS ?fieldId)`;return i(n)?`{\n ${c}\n { SELECT (COUNT(DISTINCT ${a}) AS ?count) (MIN(${r}) AS ?min) (MAX(${r}) AS ?max) WHERE {\n${g(g(s))}\n } }\n}`:`{\n ${c}\n { SELECT ${r} (COUNT(DISTINCT ${a}) AS ?count) WHERE {\n${g(g(s))}\n } GROUP BY ${r} ORDER BY DESC(?count) LIMIT ${v(t,`bucketLimit`)} }\n { SELECT (COUNT(DISTINCT ${a}) AS ?total) WHERE {\n${g(g(s))}\n } }\n}`}).map(g).join(`
1
+ var e=`http://www.w3.org/1999/02/22-rdf-syntax-ns#`,t=`http://www.w3.org/2001/XMLSchema#`,n=`http://www.w3.org/2000/10/swap/`,{rdf:r,xsd:i}={xsd:{decimal:`${t}decimal`,boolean:`${t}boolean`,double:`${t}double`,integer:`${t}integer`,string:`${t}string`},rdf:{type:`${e}type`,nil:`${e}nil`,first:`${e}first`,rest:`${e}rest`,langString:`${e}langString`},owl:{sameAs:`http://www.w3.org/2002/07/owl#sameAs`},r:{forSome:`${n}reify#forSome`,forAll:`${n}reify#forAll`},log:{implies:`${n}log#implies`,isImpliedBy:`${n}log#isImpliedBy`}},a,o=0,s={namedNode:m,blankNode:h,variable:_,literal:g,defaultGraph:v,quad:y,triple:y,fromTerm:b,fromQuad:x},c=class e{constructor(e){this.id=e}get value(){return this.id}equals(t){return t instanceof e?this.id===t.id:!!t&&this.termType===t.termType&&this.value===t.value}hashCode(){return 0}toJSON(){return{termType:this.termType,value:this.value}}},l=class extends c{get termType(){return`NamedNode`}},u=class e extends c{get termType(){return`Literal`}get value(){return this.id.substring(1,this.id.lastIndexOf(`"`))}get language(){let e=this.id,t=e.lastIndexOf(`"`)+1;return t<e.length&&e[t++]===`@`?e.substr(t).toLowerCase():``}get datatype(){return new l(this.datatypeString)}get datatypeString(){let e=this.id,t=e.lastIndexOf(`"`)+1,n=t<e.length?e[t]:``;return n===`^`?e.substr(t+2):n===`@`?r.langString:i.string}equals(t){return t instanceof e?this.id===t.id:!!t&&!!t.datatype&&this.termType===t.termType&&this.value===t.value&&this.language===t.language&&this.datatype.value===t.datatype.value}toJSON(){return{termType:this.termType,value:this.value,language:this.language,datatype:{termType:`NamedNode`,value:this.datatypeString}}}},d=class extends c{constructor(e){super(`_:${e}`)}get termType(){return`BlankNode`}get value(){return this.id.substr(2)}},f=class extends c{constructor(e){super(`?${e}`)}get termType(){return`Variable`}get value(){return this.id.substr(1)}};a=new class extends c{constructor(){return super(``),a||this}get termType(){return`DefaultGraph`}equals(e){return this===e||!!e&&this.termType===e.termType}};var p=class extends c{constructor(e,t,n,r){super(``),this._subject=e,this._predicate=t,this._object=n,this._graph=r||a}get termType(){return`Quad`}get subject(){return this._subject}get predicate(){return this._predicate}get object(){return this._object}get graph(){return this._graph}toJSON(){return{termType:this.termType,subject:this._subject.toJSON(),predicate:this._predicate.toJSON(),object:this._object.toJSON(),graph:this._graph.toJSON()}}equals(e){return!!e&&this._subject.equals(e.subject)&&this._predicate.equals(e.predicate)&&this._object.equals(e.object)&&this._graph.equals(e.graph)}};function m(e){return new l(e)}function h(e){return new d(e||`n3-${o++}`)}function g(e,t){if(typeof t==`string`)return new u(`"${e}"@${t.toLowerCase()}`);let n=t?t.value:``;return n===``&&(typeof e==`boolean`?n=i.boolean:typeof e==`number`&&(Number.isFinite(e)?n=Number.isInteger(e)?i.integer:i.double:(n=i.double,Number.isNaN(e)||(e=e>0?`INF`:`-INF`)))),n===``||n===i.string?new u(`"${e}"`):new u(`"${e}"^^${n}`)}function _(e){return new f(e)}function v(){return a}function y(e,t,n,r){return new p(e,t,n,r)}function b(e){if(e instanceof c)return e;switch(e.termType){case`NamedNode`:return m(e.value);case`BlankNode`:return h(e.value);case`Variable`:return _(e.value);case`DefaultGraph`:return a;case`Literal`:return g(e.value,e.language||e.datatype);case`Quad`:return x(e);default:throw Error(`Unexpected termType: ${e.termType}`)}}function x(e){if(e instanceof p)return e;if(e.termType!==`Quad`)throw Error(`Unexpected termType: ${e.termType}`);return y(b(e.subject),b(e.predicate),b(e.object),b(e.graph))}s.namedNode(`loaded-shapes`),s.namedNode(`loaded-data`);var S=s.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`);s.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#langString`);var C=s.namedNode(`http://purl.org/dc/terms/conformsTo`);s.namedNode(`http://www.w3.org/2000/01/rdf-schema#subClassOf`),s.namedNode(`http://www.w3.org/2002/07/owl#imports`),s.namedNode(`http://www.w3.org/2004/02/skos/core#broader`),s.namedNode(`http://www.w3.org/2004/02/skos/core#narrower`),s.namedNode(`http://www.w3.org/ns/shacl#NodeShape`),s.namedNode(`http://www.w3.org/ns/shacl#IRI`),s.namedNode(`http://www.w3.org/ns/shacl#property`),s.namedNode(`http://www.w3.org/ns/shacl#class`),s.namedNode(`http://www.w3.org/ns/shacl#node`),s.namedNode(`http://www.w3.org/ns/shacl#targetClass`),s.namedNode(`http://www.w3.org/ns/shacl#nodeKind`),s.namedNode(`http://www.w3.org/2001/XMLSchema#string`),s.namedNode(`http://www.w3.org/2001/XMLSchema#boolean`);var w=new Set([`http://www.w3.org/2001/XMLSchema#integer`,`http://www.w3.org/2001/XMLSchema#int`,`http://www.w3.org/2001/XMLSchema#short`,`http://www.w3.org/2001/XMLSchema#byte`,`http://www.w3.org/2001/XMLSchema#unsignedInt`,`http://www.w3.org/2001/XMLSchema#unsignedShort`,`http://www.w3.org/2001/XMLSchema#unsignedByte`,`http://www.w3.org/2001/XMLSchema#long`,`http://www.w3.org/2001/XMLSchema#unsignedLong`,`http://www.w3.org/2001/XMLSchema#float`,`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`,`http://www.w3.org/2001/XMLSchema#date`,`http://www.w3.org/2001/XMLSchema#dateTime`]);function T(e){return e.datatype!==void 0&&w.has(e.datatype)}var E=`?root`,D=class{constructor(e={}){this.options=e}buildWhere(e){let t=[this.rootPattern(e),...this.criterionPatterns(e)].filter(Boolean).join(`
2
+ `);return this.wrapDataset(t)}buildSelect(e,t={}){let n=t.projection?.length?t.projection.join(` `):E,r=`SELECT ${t.distinct===!1?``:`DISTINCT `}${n} WHERE {\n${L(this.buildWhere(e))}\n}`;return t.orderBy&&(r+=`\nORDER BY ${t.orderBy}`),t.limit!==void 0&&(r+=`\nLIMIT ${z(t.limit,`limit`)}`),t.offset!==void 0&&(r+=`\nOFFSET ${z(t.offset,`offset`)}`),r}buildFacetSelect(e,t,n=100){let r=`?facetValue`,i=[this.rootPattern(e.query),...this.criterionPatterns(e.query),this.pathPattern(t.path,r,`facet_${R(t.id)}`)].filter(Boolean).join(`
3
+ `),a=this.wrapDataset(i);return T(t)?`SELECT (COUNT(DISTINCT ${E}) AS ?count) (MIN(${r}) AS ?min) (MAX(${r}) AS ?max) WHERE {\n${L(a)}\n}`:`SELECT ${r} ?count ?total WHERE {\n { SELECT ${r} (COUNT(DISTINCT ${E}) AS ?count) WHERE {\n${L(L(a))}\n } GROUP BY ${r} }\n { SELECT (COUNT(DISTINCT ${E}) AS ?total) WHERE {\n${L(L(a))}\n } }\n}\nORDER BY DESC(?count)\nLIMIT ${z(n,`bucketLimit`)}`}buildFacetsSelect(e,t=100){return`SELECT ?fieldId ?facetValue ?count ?total ?min ?max WHERE {\n${e.fields.map(n=>{let r=`?facetValue`,i=[this.rootPattern(e.query),...this.criterionPatterns(e.query),this.pathPattern(n.path,r,`facet_${R(n.id)}`)].filter(Boolean).join(`
4
+ `),a=this.wrapDataset(i),o=`BIND(${P(n.id)} AS ?fieldId)`;return T(n)?`{\n ${o}\n { SELECT (COUNT(DISTINCT ${E}) AS ?count) (MIN(${r}) AS ?min) (MAX(${r}) AS ?max) WHERE {\n${L(L(a))}\n } }\n}`:`{\n ${o}\n { SELECT ${r} (COUNT(DISTINCT ${E}) AS ?count) WHERE {\n${L(L(a))}\n } GROUP BY ${r} ORDER BY DESC(?count) LIMIT ${z(t,`bucketLimit`)} }\n { SELECT (COUNT(DISTINCT ${E}) AS ?total) WHERE {\n${L(L(a))}\n } }\n}`}).map(L).join(`
5
5
  UNION
6
- `)}\n}`}rootPattern(r){return this.options.rootPattern?this.options.rootPattern({query:r,rootVariable:a,graphVariable:this.options.dataset?.type===`named`&&!this.options.dataset.graph?`?graph`:void 0}):r.targetClass?`${a} ${l(t)} ${l(e.namedNode(r.targetClass))} .`:`${a} ${l(n)} ${l(e.namedNode(r.rootShapeId))} .`}criterionPatterns(e){return e.criteria.flatMap((e,t)=>{let n=`?value_${t}`,r=this.pathPattern(e.field.path,n,`criterion_${t}`);if(e.operator===`equals`&&e.value)return[r,`VALUES ${n} { ${l(e.value)} }`];if(e.operator===`contains`&&e.value){let t=p(e.value.value),i=[`FILTER(CONTAINS(${this.options.caseSensitive?`STR(${n})`:`LCASE(STR(${n}))`}, ${this.options.caseSensitive?t:`LCASE(${t})`}))`];return e.value.termType===`Literal`&&e.value.language&&i.push(`FILTER(LANGMATCHES(LANG(${n}), ${p(e.value.language)}))`),[r,...i]}if(e.operator===`range`){let t=[];return e.min&&t.push(`FILTER(${n} >= ${l(e.min)})`),e.max&&t.push(`FILTER(${n} <= ${l(e.max)})`),[r,...t]}return[]})}pathPattern(t,n,r){let i=a;return t.map((a,o)=>{let s=o===t.length-1?n:`?${r}_${o}`,c=`${i} ${l(e.namedNode(a))} ${s} .`;return i=s,c}).join(`
7
- `)}wrapDataset(e){let t=this.options.dataset??{type:`default`};return t.type==="default"?e:`GRAPH ${t.graph?l(t.graph):`?graph`} {\n${g(e)}\n}`}},s=class{constructor(e,t={}){this.builder=new o(t),this.executor=typeof e==`string`?c(e,t.headers):e,this.bucketLimit=Math.max(0,Math.floor(t.bucketLimit??100)),this.onError=t.onError}async getFacets(e){let t=[...e.fields];if(t.length===0)return[];if(e.signal.aborted)throw new DOMException(`Facet request aborted`,`AbortError`);try{let n=this.builder.buildFacetsSelect(e,this.bucketLimit),r=(await this.executor(n,e.signal)).results?.bindings??[],i=new Map;for(let e of r){let t=e.fieldId?.value;if(t){let n=i.get(t)??[];n.push(e),i.set(t,n)}}return t.map(e=>u(e,{results:{bindings:i.get(e.id)??[]}}))}catch(n){if(e.signal.aborted)throw n;return t.map(e=>(this.onError?.(n,e),{fieldId:e.id,count:0,error:!0}))}}async select(e,t={},n=new AbortController().signal){return this.executor(this.builder.buildSelect(e,t),n)}};function c(e,t={}){let n={"content-type":`application/x-www-form-urlencoded`,accept:`application/sparql-results+json`,...t};return async(t,r)=>{let i=await fetch(e,{method:`POST`,signal:r,headers:n,body:new URLSearchParams({query:t})});if(!i.ok)throw Error(`SPARQL request failed: ${i.status}`);return i.json()}}function l(e){if(e.termType===`NamedNode`)return`<${m(e.value)}>`;if(e.termType===`BlankNode`)return`_:${h(e.value)}`;if(e.termType===`Literal`){let t=e,n=p(t.value);return t.language?`${n}@${t.language.replace(/[^A-Za-z0-9-]/g,``)}`:t.datatype?`${n}^^<${m(t.datatype.value)}>`:n}throw Error(`Unsupported RDF term in SPARQL query: ${e.termType}`)}function u(e,t){let n=t.results?.bindings??[];if(i(e)){let t=n[0]??{};return{fieldId:e.id,count:f(t.count),min:t.min?d(t.min):void 0,max:t.max?d(t.max):void 0}}let r=n.flatMap(e=>e.facetValue?[{value:d(e.facetValue),count:f(e.count)}]:[]);return{fieldId:e.id,count:f(n[0]?.total),buckets:r}}function d(t){return t.type===`uri`?e.namedNode(t.value):t.type===`bnode`?e.blankNode(t.value):t[`xml:lang`]?e.literal(t.value,t[`xml:lang`]):t.datatype?e.literal(t.value,e.namedNode(t.datatype)):e.literal(t.value)}function f(e){let t=Number(e?.value??0);return Number.isFinite(t)?t:0}function p(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`)}"`}function m(e){return e.replace(/[^A-Za-z0-9\-._~:/?#[\]@!$&'()*+,;=%]/g,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function h(e){return e.replace(/[^A-Za-z0-9\-_.]/g,e=>`_`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function g(e){return e.split(`
6
+ `)}\n}`}rootPattern(e){return this.options.rootPattern?this.options.rootPattern({query:e,rootVariable:E,graphVariable:this.options.dataset?.type===`named`&&!this.options.dataset.graph?`?graph`:void 0}):e.targetClass?`${E} ${A(S)} ${A(s.namedNode(e.targetClass))} .`:`${E} ${A(C)} ${A(s.namedNode(e.rootShapeId))} .`}criterionPatterns(e){return e.criteria.flatMap((e,t)=>{let n=`?value_${t}`,r=this.pathPattern(e.field.path,n,`criterion_${t}`);if(e.operator===`equals`&&e.value)return[r,`VALUES ${n} { ${A(e.value)} }`];if(e.operator===`contains`&&e.value){let t=P(e.value.value),i=[`FILTER(CONTAINS(${this.options.caseSensitive?`STR(${n})`:`LCASE(STR(${n}))`}, ${this.options.caseSensitive?t:`LCASE(${t})`}))`];return e.value.termType===`Literal`&&e.value.language&&i.push(`FILTER(LANGMATCHES(LANG(${n}), ${P(e.value.language)}))`),[r,...i]}if(e.operator===`range`){let t=[];return e.min&&t.push(`FILTER(${n} >= ${A(e.min)})`),e.max&&t.push(`FILTER(${n} <= ${A(e.max)})`),[r,...t]}return[]})}pathPattern(e,t,n){let r=E;return e.map((i,a)=>{let o=a===e.length-1?t:`?${n}_${a}`,c=`${r} ${A(s.namedNode(i))} ${o} .`;return r=o,c}).join(`
7
+ `)}wrapDataset(e){let t=this.options.dataset??{type:`default`};return t.type==="default"?e:`GRAPH ${t.graph?A(t.graph):`?graph`} {\n${L(e)}\n}`}},O=class{constructor(e,t={}){this.builder=new D(t),this.executor=typeof e==`string`?k(e,t.headers):e,this.bucketLimit=Math.max(0,Math.floor(t.bucketLimit??100)),this.onError=t.onError}async getFacets(e){let t=[...e.fields];if(t.length===0)return[];if(e.signal.aborted)throw new DOMException(`Facet request aborted`,`AbortError`);try{let n=this.builder.buildFacetsSelect(e,this.bucketLimit),r=(await this.executor(n,e.signal)).results?.bindings??[],i=new Map;for(let e of r){let t=e.fieldId?.value;if(t){let n=i.get(t)??[];n.push(e),i.set(t,n)}}return t.map(e=>j(e,{results:{bindings:i.get(e.id)??[]}}))}catch(n){if(e.signal.aborted)throw n;return t.map(e=>(this.onError?.(n,e),{fieldId:e.id,count:0,error:!0}))}}async select(e,t={},n=new AbortController().signal){return this.executor(this.builder.buildSelect(e,t),n)}};function k(e,t={}){let n={"content-type":`application/x-www-form-urlencoded`,accept:`application/sparql-results+json`,...t};return async(t,r)=>{let i=await fetch(e,{method:`POST`,signal:r,headers:n,body:new URLSearchParams({query:t})});if(!i.ok)throw Error(`SPARQL request failed: ${i.status}`);return i.json()}}function A(e){if(e.termType===`NamedNode`)return`<${F(e.value)}>`;if(e.termType===`BlankNode`)return`_:${I(e.value)}`;if(e.termType===`Literal`){let t=e,n=P(t.value);return t.language?`${n}@${t.language.replace(/[^A-Za-z0-9-]/g,``)}`:t.datatype?`${n}^^<${F(t.datatype.value)}>`:n}throw Error(`Unsupported RDF term in SPARQL query: ${e.termType}`)}function j(e,t){let n=t.results?.bindings??[];if(T(e)){let t=n[0]??{};return{fieldId:e.id,count:N(t.count),min:t.min?M(t.min):void 0,max:t.max?M(t.max):void 0}}let r=n.flatMap(e=>e.facetValue?[{value:M(e.facetValue),count:N(e.count)}]:[]);return{fieldId:e.id,count:N(n[0]?.total),buckets:r}}function M(e){return e.type===`uri`?s.namedNode(e.value):e.type===`bnode`?s.blankNode(e.value):e[`xml:lang`]?s.literal(e.value,e[`xml:lang`]):e.datatype?s.literal(e.value,s.namedNode(e.datatype)):s.literal(e.value)}function N(e){let t=Number(e?.value??0);return Number.isFinite(t)?t:0}function P(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`)}"`}function F(e){return e.replace(/[^A-Za-z0-9\-._~:/?#[\]@!$&'()*+,;=%]/g,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function I(e){return e.replace(/[^A-Za-z0-9\-_.]/g,e=>`_`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function L(e){return e.split(`
8
8
  `).map(e=>` ${e}`).join(`
9
- `)}function _(e){return e.replace(/[^A-Za-z0-9_]/g,`_`)}function v(e,t){if(!Number.isInteger(e)||e<0)throw Error(`${t} must be a non-negative integer`);return e}export{o as SparqlQueryBuilder,s as SparqlQueryProvider,l as termToSparql};
9
+ `)}function R(e){return e.replace(/[^A-Za-z0-9_]/g,`_`)}function z(e,t){if(!Number.isInteger(e)||e<0)throw Error(`${t} must be a non-negative integer`);return e}export{D as SparqlQueryBuilder,O as SparqlQueryProvider,A as termToSparql};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulb-darmstadt/shacl-form",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "description": "SHACL form generator",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -85,15 +85,19 @@
85
85
  "vite": "^8.1.5"
86
86
  },
87
87
  "peerDependencies": {
88
- "@ro-kit/ui-widgets": "^1.0.49",
88
+ "@ro-kit/ui-widgets": "^1.0.50",
89
89
  "jsonld": "^9.0.0",
90
90
  "leaflet": "^1.9.4",
91
91
  "leaflet-editable": "^1.3.2",
92
92
  "leaflet.fullscreen": "^5.3.3",
93
93
  "leaflet.heat": "^0.2.0",
94
- "n3": "^1.0.26",
94
+ "n3": "^1.0.26 || ^2.0.0",
95
95
  "rdfxml-streaming-parser": "^3.1.0",
96
96
  "shacl-engine": "^1.1.2",
97
97
  "uuid": "^13.0.0"
98
+ },
99
+ "allowScripts": {
100
+ "puppeteer@24.43.1": true,
101
+ "puppeteer@25.3.0": true
98
102
  }
99
103
  }