@ulb-darmstadt/shacl-form 3.7.1 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/mode-DQMbYnAU.js +13 -0
- package/dist/assets/{mode-D-xYMD5v.js → mode-DiqnS4uq.js} +2 -2
- package/dist/assets/query-B9ouD_FF.js +92 -0
- package/dist/assets/{query-DHAlonoV.js → query-DXre6-Ec.js} +29 -29
- package/dist/bundle.js +13 -13
- package/dist/index.js +6 -6
- package/dist/util.d.ts +1 -0
- package/package.json +2 -2
- package/dist/assets/mode-bo0QsQ7I.js +0 -13
- package/dist/assets/query-BKMrP7zm.js +0 -92
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{$ as e,A as t,B as n,C as r,D as i,
|
|
1
|
+
import{$ as e,A as t,B as n,C as r,D as i,F as a,G as o,H as s,L as c,M as l,N as u,P as d,Q as f,R as p,T as m,U as h,V as ee,W as g,X as _,Z as v,_ as te,b as y,c as b,d as x,et as S,f as C,g as w,h as T,i as E,j as D,l as O,n as k,nt as A,p as j,q as M,r as N,t as ne,tt as re,u as P,v as F,w as I,x as L,y as R}from"./assets/query-B9ouD_FF.js";import{BlankNode as z,DataFactory as B,Literal as V,NamedNode as H,Store as U}from"n3";import{RokitButton as W,RokitCollapsible as G,RokitInput as K,RokitSelect as q,RokitTextArea as J}from"@ro-kit/ui-widgets";import{Validator as Y}from"shacl-engine";var ie=`
|
|
2
2
|
.editor:not([type='checkbox']) { border: 1px solid var(--shacl-border-color, #DDD); }
|
|
3
3
|
.property-instance label { display: inline-flex; align-self: center; word-break: break-word; line-height: 1em; padding-right: 1em; flex-shrink: 0; position: relative; }
|
|
4
4
|
.property-instance:has(> .editor:is(textarea, rokit-textarea)) > label { align-self: flex-start; padding-top: 0.45em; }
|
|
5
5
|
.property-instance:not(:first-child) > label:not(.persistent) { visibility: hidden; max-height: 0; }
|
|
6
6
|
.mode-edit .property-instance label { width: var(--label-width); }
|
|
7
|
-
`,X=class extends
|
|
8
|
-
`+t}this.hierarchyColorsStyleSheet=new CSSStyleSheet,this.hierarchyColorsStyleSheet.replaceSync(n)}}static dataAttributes(){let e=new Z;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
|
|
7
|
+
`,X=class extends L{constructor(e){super(e||ie),this.idCtr=0}createDefaultTemplate(e,t,r,i,a){let o=t??a?.defaultValue??null;if(i.id=`e${this.idCtr++}`,i.classList.add(`editor`),i.setAttribute(`part`,`editor`),a?.datatype?i.shaclDatatype=a.datatype:t instanceof V&&(i.shaclDatatype=t.datatype),a&&m(a)>0&&(i.dataset.minCount=String(m(a))),a?.class&&(i.dataset.class=a.class.value),a?.nodeKind)i.dataset.nodeKind=a.nodeKind.value;else if(t&&(t instanceof H||a?.nodeKind?.equals(v))&&(i.dataset.nodeKind=M+`IRI`,a)){let e=n(a.config.store.getQuads(t,null,null,null),a.config.languages);e&&(t=B.literal(e))}(a?.hasValue&&t||a?.readonly)&&(i.disabled=!0);let s=t?.value||a?.defaultValue?.value||``;t instanceof z?s=t.id:t instanceof H&&a?.nodeKind?.value===`http://www.w3.org/ns/shacl#IRIOrLiteral`&&(s=`<${t.value}>`),a?.datatype?.equals(A)?i.checked=t?.value===`true`||a?.defaultValue?.value===`true`:i.type===`file`?i.binaryData=s||void 0:i.value=s,F(i,o);let c=document.createElement(`label`);c.htmlFor=i.id,c.innerText=e,c.setAttribute(`part`,`label`),a?.description&&c.setAttribute(`title`,a.description.value);let l=a?.description?a.description.value:a?.pattern?a.pattern:null;l&&i.setAttribute(`placeholder`,l),r&&(i.setAttribute(`required`,`true`),c.classList.add(`required`));let u=document.createElement(`div`);return u.setAttribute(`part`,`field`),u.appendChild(c),u.appendChild(i),u}createDateEditor(e,t,n,r){let i=new K;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 a=this.createDefaultTemplate(e,null,n,i,r);if(t){let e=r.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?ee(t.value):s(t.value);e?(i.value=e.value,e.suffix&&(i.dataset.xsdTemporalSuffix=e.suffix)):console.error(`unable to parse xsd date literal`,t),F(i,t)}return a}createTextEditor(e,t,n,r){let i;return r.singleLine===!1?(i=new J,i.resize=`auto`):i=new K,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 V&&(o.value=t.language),a.dataset.lang=o.value,F(a,t??r.defaultValue),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 V&&(i.checked=t.value===`true`,F(i,t)),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.readAsArrayBuffer(i.files[0]),t.onload=()=>{i.binaryData=a(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 K,a=o.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.addEventListener(`input`,()=>{i.setCustomValidity(i.validity.patternMismatch?`Value does not have datatype <`+r.datatype?.value+`>`:void 0,i.inputElement)})),i.clearable=!0,i.dense=this.dense,i.classList.add(`pr-0`);let s=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 s!==void 0&&(i.min=String(s)),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 q;a.clearable=!0,a.dense=this.dense;let o=this.createDefaultTemplate(e,null,n,a,i),s=document.createElement(`ul`),c=[],l=!0,u=(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=y(e.value),c.push(e.value),n.innerText=e.label?e.label:e.value.value),t.appendChild(n),e.children?.length){l=!1;let t=document.createElement(`ul`);n.appendChild(t);for(let n of e.children)u(n,t)}};for(let e of r)u(e,s);return l||(a.collapse=!0),a.appendChild(s),R(a,c),t=t??i?.defaultValue??null,t&&(a.value=y(t),F(a,t)),o}createButton(e,t){let n=new W;return n.dense=this.dense,n.textContent=e,t?(n.setAttribute(`primary`,``),n.setAttribute(`part`,`button primary`)):n.setAttribute(`part`,`button`),n}},Z=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.preserveUnmappedValues=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=g.value,this.showNodeIds=null,this.showRootShapeLabel=null,this.dense=`true`,this.useShadowRoot=`true`}},ae=`#4c93d785, #f85e9a85, #00327385, #87001f85`,Q=class{constructor(e){this.attributes=new Z,this.mode=`edit`,this.lists={},this.groups=[],this.renderedNodes=new Set,this.originalValues=new U,this._store=new U,this._nodeTemplates={},this._propertyTemplates={},this.validator=new Y(this._store,{details:!0,factory:B}),this.providedConformingResourceIds={},this.providedResources={},this.providedResourceLabels={},this.form=e,this._theme=new X,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.originalValues=new U,this._nodeTemplates={},this._propertyTemplates={}}updateAttributes(e){let t=new Z;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=B.namedNode(t.valuesGraph)),t.hierarchyColors!=null){let e=t.hierarchyColors.length?t.hierarchyColors:ae,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 Z;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 I?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 N(e,this,t),r}getPropertyTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._propertyTemplates[n];return r||=new I(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=c(e,{ignoreErrors:!0}),this.groups=[],e.forSubjects(e=>{this.groups.push(e.id)},_,`${M}PropertyGroup`,null),this.validator=new Y(e,{details:!0,factory:B})}},oe=200,$=class extends HTMLElement{static get observedAttributes(){return Q.dataAttributes()}constructor(){super(),this.shape=null,this.styleElement=null,this.validationQueue=Promise.resolve(),this.validationGeneration=0,this.form=document.createElement(`form`),this.form.setAttribute(`part`,`form`),this.config=new Q(this.form),this.form.addEventListener(`change`,e=>{e.stopPropagation(),this.config.queryMode?this.queryController?.handleChange():this.config.editMode&&this.validate(!0).then(e=>{this.refreshClassInstanceEditors(),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.config.theme.apply(this.form),this.applyStyles([this.config.theme.stylesheet]),this.form.replaceChildren(document.createTextNode(this.config.attributes.loading)),this.initDebounceTimeout=setTimeout(async()=>{try{this.config.reset(),this.config.store=await C({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.originalValues),this.config.resourceLinkProvider&&await b(this.config),this.config.attributes.valuesSubject||(this.config.attributes.valuesSubject=P(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-DiqnS4uq.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 T())e.stylesheet&&t.push(e.stylesheet);this.applyStyles(t);let n=new N(e,this.config);for(let e of this.config.nodeTemplates)E(e);if(this.shape=new k(n,this.config.attributes.valuesSubject?B.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=>{e?.conforms?this.dispatchEvent(new Event(`submit`,{bubbles:!0,cancelable:!0})):this.focusFirstInvalidElement()}):this.validate().then(()=>{this.focusFirstInvalidElement(!0)})}),this.form.appendChild(e)}await this.shape?.ready,this.config.attributes.valuesSubject&&this.removeFromDataGraph(B.namedNode(this.config.attributes.valuesSubject)),await this.validate(!0),this.refreshClassInstanceEditors()}else this.config.queryMode&&(await this.shape.ready,await this.queryController?.initialize())}else if(this.config.store.countQuads(null,null,null,re)>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.config.queryMode&&this.config.queryFacetProvider&&this.queryController||this.removeAttribute(`loading`),await this.shape?.ready,this.dispatchEvent(new Event(`ready`,{bubbles:!0,composed:!0}))},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))}focusFirstInvalidElement(e=!1){let t=this.form.querySelector(`:scope .invalid > .editor`);t?(e&&t.reportValidity?.(),t instanceof q?t.input.inputElement.focus():t.focus()):this.form.querySelector(`:scope .invalid`)?.scrollIntoView()}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
9
|
`).replace(/:host\b/g,`shacl-form`)).join(`
|
|
10
|
-
`);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(),
|
|
10
|
+
`);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(),te(t.getQuads(null,null,null,null),e,u)}toRDF(e=new U){this.assertNotQueryMode(`toRDF`);let t;return this.config.attributes.preserveUnmappedValues!==null&&(t=this.preparePreservedOutput(e)),this.shape?.toRDF(e,void 0,this.config.attributes.generateNodeShapeReference),t?.size&&this.pruneOrphanedBlankNodes(e,t),e}preparePreservedOutput(e){let t=this.config.originalValues,n=new Map;e.addQuads(t.getQuads(null,null,null,null));for(let r of this.form.querySelectorAll(`shacl-property`))if(!r.parent.linked){for(let i of r.template.pathAlternatives??[r.template.path])if(i)for(let a of t.getQuads(r.parent.nodeId,i,null,null))e.delete(a),a.object.termType===`BlankNode`&&n.set(a.object.id,a.object)}for(let n of this.form.querySelectorAll(`shacl-node:not([part~="linked-node"])`))if(n.template.targetClass)for(let r of t.getQuads(n.nodeId,_,n.template.targetClass,null))e.delete(r);let r=this.config.attributes.generateNodeShapeReference;if(this.shape&&r)for(let n of t.getQuads(this.shape.nodeId,B.namedNode(r),this.shape.template.id,null))e.delete(n);return n}pruneOrphanedBlankNodes(e,t){let n=new Map(t),r=[...t.values()];for(;r.length;){let t=r.pop();for(let i of e.getQuads(t,null,null,null))i.object.termType===`BlankNode`&&!n.has(i.object.id)&&(n.set(i.object.id,i.object),r.push(i.object))}let i=new Set,a=[],o=e=>{i.has(e.id)||(i.add(e.id),a.push(e))};for(let e of this.form.querySelectorAll(`shacl-node:not([part~="linked-node"])`))e.nodeId.termType===`BlankNode`&&n.has(e.nodeId.id)&&o(e.nodeId);for(let t of n.values())e.getQuads(null,null,t,null).some(e=>e.subject.termType!==`BlankNode`||!n.has(e.subject.id))&&o(t);for(;a.length;){let t=a.pop();for(let r of e.getQuads(t,null,null,null))r.object.termType===`BlankNode`&&n.has(r.object.id)&&o(r.object)}for(let t of n.values())if(!i.has(t.id))for(let n of e.getQuads(t,null,null,null))e.delete(n)}registerPlugin(e){w(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`);let t=++this.validationGeneration;for(let e of this.form.querySelectorAll(`:scope .validation-error`))e.remove();for(let t of this.form.querySelectorAll(`:scope .property-instance`)){let n=t.querySelector(`:scope > .editor`),r=!!n?.value,i=n?.validity?.valid===!1&&(r||!e);t.classList.toggle(`invalid`,i),r&&!i?t.classList.add(`valid`):t.classList.remove(`valid`),i&&n?.validationMessage&&this.appendValidationErrorDisplay(t,n.validationMessage)}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 n=this.shape,r=()=>new Promise(r=>{this.config.store.deleteGraph(this.config.valuesGraphId||``).on(`end`,async()=>{n.toRDF(this.config.store,void 0,this.config.attributes.generateNodeShapeReference);try{let i=await this.config.validator.validate({dataset:this.config.store,terms:[n.nodeId]},[{terms:[n.template.id]}]);if(t!==this.validationGeneration){r(i);return}let a=[...i.results];for(let t=0;t<a.length;t++){let n=a[t];if(a.push(...n.results??[]),n.focusNode?.ptrs?.length)for(let t of n.focusNode.ptrs){let r=t._term;if(n.path?.length){let t=n.path[0].predicates[0],i=e=>`
|
|
11
11
|
:scope shacl-node[data-node-id='${r.id}'] > shacl-property > .property-instance[${e}='${t.id}'] > .editor,
|
|
12
12
|
:scope shacl-node[data-node-id='${r.id}'] > shacl-property > .shacl-group > .property-instance[${e}='${t.id}'] > .editor,
|
|
13
13
|
:scope shacl-node[data-node-id='${r.id}'] > .shacl-group > shacl-property > .property-instance[${e}='${t.id}'] > .editor,
|
|
@@ -17,5 +17,5 @@ import{$ as e,A as t,B as n,C as r,D as i,H as a,I as o,K as s,L as c,M as l,N a
|
|
|
17
17
|
:scope [data-node-id='${r.id}'] > shacl-property > .alternative-path-constraint[data-path='${t.id}'],
|
|
18
18
|
:scope [data-node-id='${r.id}'] > shacl-property > .shacl-group > .alternative-path-constraint[data-path='${t.id}']`)),a.length===0&&(a=this.form.querySelectorAll(`
|
|
19
19
|
:scope [data-node-id='${r.id}'] > shacl-property > .property-instance[data-predicate='${t.id}'],
|
|
20
|
-
:scope [data-node-id='${r.id}'] > shacl-property > .shacl-group > .property-instance[data-predicate='${t.id}']`));for(let t of a)if(t.classList.contains(`editor`)){if(!e||t.value){let e=t.parentElement;e.classList.add(`invalid`),e.classList.remove(`valid`),this.appendValidationErrorDisplay(e,n);do e instanceof
|
|
21
|
-
`).includes(r.title)&&(i.title=i.title?`${i.title}\n${r.title}`:r.title)}hasExplicitShaclMessage(
|
|
20
|
+
:scope [data-node-id='${r.id}'] > shacl-property > .shacl-group > .property-instance[data-predicate='${t.id}']`));for(let t of a)if(t.classList.contains(`editor`)){if(!e||t.value){let e=t.parentElement;e.classList.add(`invalid`),e.classList.remove(`valid`),this.appendValidationErrorDisplay(e,n);do e instanceof G&&(e.open=!0),e=e.parentElement;while(e)}}else e||(t.classList.add(`invalid`),t.classList.remove(`valid`),t.appendChild(this.createValidationErrorDisplay(n,`node`)))}else e||this.form.querySelector(`:scope [data-node-id='${r.id}']:not([part~='linked-node'])`)?.prepend(this.createValidationErrorDisplay(n,`node`))}}r(i)}catch(e){console.error(e),r({conforms:!1,results:[]})}})}),i=this.validationQueue.then(r,r);return this.validationQueue=i.then(()=>void 0,()=>void 0),i}assertNotQueryMode(e){if(this.config.queryMode)throw Error(`${e}() is not available in query mode; use getQuery()`)}refreshClassInstanceEditors(){if(!(!this.shape||!this.config.editMode))for(let e of this.form.querySelectorAll(`shacl-property`))e.refreshClassInstances()}appendValidationErrorDisplay(e,t,n){let r=this.createValidationErrorDisplay(t,n),i=e.querySelector(`:scope > .validation-error`);if(!i){e.appendChild(r);return}if(r.title&&this.hasExplicitShaclMessage(t)){i.title=r.title;return}r.title&&!i.title.split(`
|
|
21
|
+
`).includes(r.title)&&(i.title=i.title?`${i.title}\n${r.title}`:r.title)}hasExplicitShaclMessage(t){if(typeof t!=`object`||!t)return!1;let n=t;return n.shape?.message?.length?!0:[...n.shape?.ptr?.terms??[],...n.source??[]].some(t=>this.config.store.countQuads(t,e,null,null)>0)}createValidationErrorDisplay(e,t){let n=document.createElement(`span`);n.classList.add(`validation-error`),t&&n.classList.add(t);let r=typeof e==`object`&&e?e:null;return r?r.message?.length?n.title+=p(this.config.languages,r.message):r.sourceConstraintComponent?.value&&(n.title=r.sourceConstraintComponent.value):typeof e==`string`&&(n.title=e),n}findRootShaclShapeSubject(){if(this.config.attributes.shapeSubject){let e=B.namedNode(this.config.attributes.shapeSubject);if(this.config.store.getQuads(e,_,f,null).length===0){console.warn(`shapes graph does not contain requested node shape ${this.config.attributes.shapeSubject}`);return}else return e}else{if(this.config.attributes.valuesSubject&&this.config.store.countQuads(null,null,null,h)>0){let e=B.namedNode(this.config.attributes.valuesSubject),t=O(this.config.store,this.config.attributes.valuesSubject),n=this.config.store.getQuads(e,_,null,h);if(n.length===0&&console.warn(`value subject '${this.config.attributes.valuesSubject}' has neither ${_.id} nor ${g.id} statement`),t)return t;for(let e of n)if(this.config.store.getQuads(e.object,_,f,null).length>0)return e.object;let r=this.config.store.getObjects(e,_,h);for(let e of r)for(let t of this.config.store.getQuads(null,S,e,null))return t.subject}let e=this.config.store.getQuads(null,_,f,null);if(e.length==0){console.warn(`shapes graph does not contain any node shapes`);return}return e.length>1&&(console.warn(`shapes graph contains`,e.length,`node shapes. choosing first found which is`,e[0].subject.value),console.info(`hint: set the node shape to use with element attribute "data-shape-subject"`)),e[0].subject}}removeFromDataGraph(e){for(let t of this.config.store.getQuads(e,null,null,h))this.config.store.delete(t),(t.object.termType===`NamedNode`||t.object.termType===`BlankNode`)&&this.removeFromDataGraph(t.object)}};window.customElements.define(`shacl-form`,$);export{Q as Config,X as DefaultTheme,j as Plugin,$ as ShaclForm,I as ShaclPropertyTemplate,L as Theme,t as fetchRDF,O as findConformsToShapeSubject,P as findConformsToValuesSubject,n as findLabel,x as importRDF,oe as initTimeout,ne as isRangeQueryField,C as loadGraphs,D as loadRDF,l as parseRDF,u as prefixes,i as propertyMappers,d as rdfCache,w as registerPlugin};
|
package/dist/util.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare function createInputListEntries(subjects: Term[], store: Store, l
|
|
|
10
10
|
export declare function removePrefixes(id: string, prefixes: Prefixes): string;
|
|
11
11
|
export declare function findInstancesOf(clazz: NamedNode, template: ShaclPropertyTemplate): InputListEntry[];
|
|
12
12
|
export declare function isURL(input: string): boolean;
|
|
13
|
+
export declare function arrayBufferToBase64(buffer: ArrayBuffer): string;
|
|
13
14
|
export declare function prioritizeByLanguage(languages: string[], text1?: Literal, text2?: Literal): Literal | undefined;
|
|
14
15
|
export declare function findBestMatchingLiteral(languages: string[], literals: Literal[]): string;
|
|
15
16
|
export declare function formatXsdDateValueForInput(value: string): {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ulb-darmstadt/shacl-form",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.3",
|
|
4
4
|
"description": "SHACL form generator",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"vite": "^8.1.5"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
|
-
"@ro-kit/ui-widgets": "^1.0.
|
|
89
|
+
"@ro-kit/ui-widgets": "^1.0.64",
|
|
90
90
|
"jsonld": "^9.0.0",
|
|
91
91
|
"leaflet": "^1.9.4",
|
|
92
92
|
"leaflet-editable": "^1.3.2",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{$ as e,A as t,I as n,L as r,P as i,W as a,a as o,at as s,et as c,g as l,h as u,m as d,n as f,o as p,pt as m,q as h,rt as g,s as _,t as v,ut as y,x as b,y as x}from"./query-DHAlonoV.js";function S(e,t){let n=document.createElement(`div`),r=!!(t.facet||t.in||t.class||t.datatype?.equals(y));n.classList.add(`query-editor`),n.dataset.queryFieldId=e.id,n.setAttribute(`part`,`query-editor`);let i=document.createElement(`label`);i.textContent=t.label,t.description&&(i.title=t.description.value),n.appendChild(i);let a=document.createElement(`div`);a.classList.add(`query-controls`),n.appendChild(a);let o,s=j(t),c,d,f=(e=``)=>{let n=document.createElement(`div`);n.classList.add(`query-value-row`);let r=new u;r.classList.add(`editor`,`query-choice`),r.clearable=!0,r.dense=t.config.theme.dense,r.placeholder=``,r.setAttribute(`exportparts`,`facet-count`);let i=document.createElement(`ul`);for(let e of s){let t=document.createElement(`li`);if(t.dataset.value=I(e.term),t.textContent=e.label,e.count!==void 0){let n=document.createElement(`span`);n.classList.add(`facet-count`),n.setAttribute(`part`,`facet-count`),n.dataset.count=String(e.count),t.append(` `,n)}i.appendChild(t)}return r.appendChild(i),r.value=e,n.appendChild(r),n},p=(e=[])=>{a.replaceChildren(),a.appendChild(f(e[0]??``))},m=(e,n=``)=>{let r=new l;return r.classList.add(`editor`,`query-range-bound`),r.type=F(t),r.label=e,r.clearable=!0,r.dense=t.config.theme.dense,r.value=n,r},h=e=>{a.replaceChildren();let r=C(t,o);r&&r[0]<r[1]&&(c=r);let i=d??A(r,e&&c);if(n.unavailable=!!(i&&i[0]===i[1]),n.unavailable)return;if(!i){a.append(m(`Minimum`,e?.min?.value),m(`Maximum`,e?.max?.value));return}(e?.min||e?.max)&&(d??=i);let s=new x;s.classList.add(`editor`,`query-range-slider`),s.dense=t.config.theme.dense,s.clearable=!0,s.range=``,s.setAttribute(`range`,``),s.min=String(i[0]),s.max=String(i[1]),s.step=String(w(t,i)),s.labelFormatter=e=>T(e,t);let l=e?.min?E(e.min,t):i[0],u=e?.max?E(e.max,t):i[1];s.value=JSON.stringify([k(l??i[0],i[0],i[1]),k(u??i[1],i[0],i[1])]),s.dataset.active=e?.min||e?.max?`true`:`false`,s.addEventListener(`change`,()=>{s.dataset.active=`true`,d??=[Number(s.min),Number(s.max)]}),a.appendChild(s)};return n.getQueryCriteria=()=>{if(v(e)){let n=a.querySelector(`rokit-slider`);if(n){if(n.dataset.active!==`true`)return[];let r=O(n.value);return r?[{field:e,operator:`range`,min:D(r[0],t),max:D(r[1],t)}]:[]}let r=a.querySelectorAll(`rokit-input`),i=N(r[0]?.value,t),o=N(r[1]?.value,t);return i||o?[{field:e,operator:`range`,min:i,max:o}]:[]}if(r)return Array.from(a.querySelectorAll(`rokit-select`)).flatMap(t=>{if(!t.value)return[];let n=s.find(e=>I(e.term)===t.value)?.term;return n?[{field:e,operator:`equals`,value:n}]:[]});let n=P(t)&&!t.class&&!t.nodeKind?.value.endsWith(`#IRI`)?`contains`:`equals`;return Array.from(a.querySelectorAll(`.query-value-row`)).flatMap(r=>{let i=r.querySelector(`.query-value`),a=r.querySelector(`.query-language`)?.value,o=N(i?.value,t,a);return o?[{field:e,operator:n,value:o}]:[]})},n.clearQueryCriteria=()=>{if(v(e)){d=void 0,c=void 0;let e=a.querySelector(`rokit-slider`);if(e)e.dataset.active=`false`,e.value=JSON.stringify([Number(e.min),Number(e.max)]);else for(let e of a.querySelectorAll(`rokit-input`))e.value=``}else if(r)for(let e of a.querySelectorAll(`rokit-select`))e.value=``;else for(let e of a.querySelectorAll(`.query-value`))e.value=``},n.setQueryFacet=i=>{let c=n.getQueryCriteria();if(o=i,r&&o?.buckets){let e=new Map(j(t).map(e=>[I(e.term),e])),n=new Map(c.flatMap(e=>e.value?[[I(e.value),e.value]]:[]));s=o.buckets.flatMap(n=>{let r=e.get(I(n.value));return t.in&&!r?[]:[{term:n.value,label:n.label??r?.label??n.value.value,count:n.count}]});for(let[t,r]of n)s.some(e=>I(e.term)===t)||s.push({term:r,label:e.get(t)?.label??r.value,count:0});let r=!1;if(n.size===0&&o.initialValue){let e=I(o.initialValue);s.some(t=>I(t.term)===e)&&(n.set(e,o.initialValue),r=!0)}return p([...n.keys()]),r}else if(v(e)){let e=c[0];h(e?{min:e.min,max:e.max}:void 0)}else if(!i)for(let e of a.querySelectorAll(`.query-value`))e.value=``;return!1},v(e)?h():r?p():(a.replaceChildren(),a.appendChild((()=>{let e=document.createElement(`div`);e.classList.add(`query-value-row`);let r=new l;r.classList.add(`editor`,`query-value`),r.type=F(t),r.clearable=!0,r.dense=t.config.theme.dense;let i;if(r.addEventListener(`input`,()=>{clearTimeout(i),i=setTimeout(()=>{n.dispatchEvent(new Event(`change`,{bubbles:!0}))},300)}),e.appendChild(r),t.datatype?.equals(g)){let n=t.languageIn?.length?document.createElement(`select`):document.createElement(`input`);if(n.classList.add(`lang-chooser`,`query-language`),n.title=`Language of the text`,n.setAttribute(`aria-label`,`Language of the text`),n instanceof HTMLSelectElement)for(let e of t.languageIn??[]){let t=document.createElement(`option`);t.value=e.value,t.textContent=e.value,n.appendChild(t)}else n.maxLength=35,n.placeholder=`lang?`,n.value=t.config.languages.find(e=>e.length>0)??``;e.appendChild(n)}return e})())),n}function C(e,t){let n=t?.min?E(t.min,e):void 0,r=t?.max?E(t.max,e):void 0,i=e.minInclusive??(e.minExclusive===void 0?void 0:e.minExclusive+1),a=e.maxInclusive??(e.maxExclusive===void 0?void 0:e.maxExclusive-1),o=n!==void 0&&r!==void 0,s=o?n:n===void 0?i:i===void 0?n:Math.max(n,i),c=o?r:r===void 0?a:a===void 0?r:Math.min(r,a);return s!==void 0&&c!==void 0&&Number.isFinite(s)&&Number.isFinite(c)&&s<=c?[s,c]:void 0}function w(e,t){return e.datatype?.value===`http://www.w3.org/2001/XMLSchema#integer`?1:e.datatype?.value===`http://www.w3.org/2001/XMLSchema#date`?86400:e.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?1:Math.max((t[1]-t[0])/1e3,2**-52)}function T(e,t){return t.datatype?.value===`http://www.w3.org/2001/XMLSchema#date`?d(e,!0):t.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?d(e):String(Math.round(e*1e3)/1e3)}function E(e,t){if(t.datatype?.value===`http://www.w3.org/2001/XMLSchema#date`||t.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`){let t=Date.parse(e.value);return Number.isFinite(t)?t/1e3:void 0}let n=Number(e.value);return Number.isFinite(n)?n:void 0}function D(e,t){let n=t.datatype;return n?.value===`http://www.w3.org/2001/XMLSchema#date`?m.literal(d(e,!0),n):n?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?m.literal(d(e),n):m.literal(String(e),n)}function O(e){try{let t=JSON.parse(e);return Array.isArray(t)&&t.length===2&&t.every(Number.isFinite)?[Number(t[0]),Number(t[1])]:void 0}catch{return}}function k(e,t,n){return Math.min(n,Math.max(t,e))}function A(e,t){return e&&e[0]<e[1]?e:t||e}function j(e){if(e.datatype?.equals(y))return[{term:m.literal(`true`,y),label:`true`},{term:m.literal(`false`,y),label:`false`}];let t=[];return e.in?t=a(e.config.lists[e.in]??[],e.config.store,e.config.languages):e.class&&(t=h(e.class,e)),M(t)}function M(e){return e.flatMap(e=>[...typeof e.value==`string`?[]:[{term:e.value,label:e.label||e.value.value}],...M(e.children??[])])}function N(e,t,n){if(e)return t.class||t.nodeKind?.value.endsWith(`#IRI`)?m.namedNode(e):t.datatype?.equals(g)?n?m.literal(e,n):void 0:t.datatype?m.literal(e,t.datatype):m.literal(e)}function P(e){return!e.datatype||e.datatype.value===`http://www.w3.org/2001/XMLSchema#string`||e.datatype.equals(g)}function F(e){let t=e.datatype?.value;return[`http://www.w3.org/2001/XMLSchema#integer`,`http://www.w3.org/2001/XMLSchema#float`,`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`].includes(t??``)?`number`:t===`http://www.w3.org/2001/XMLSchema#date`?`date`:t===`http://www.w3.org/2001/XMLSchema#dateTime`?`datetime-local`:`text`}function I(e){if(e.termType===`Literal`){let t=e;return`${e.termType}:${e.value}:${t.language}:${t.datatype?.value}`}return`${e.termType}:${e.value}`}var L=`form.mode-query { padding: 0; }
|
|
2
|
-
:host([loading]) form.mode-query > shacl-node { display: none; }
|
|
3
|
-
.mode-query shacl-property.query-unavailable { display: none; }
|
|
4
|
-
.mode-query .shacl-group:not(:has(shacl-property:not(.query-unavailable))), .mode-query shacl-node:not(:has(shacl-property:not(.query-unavailable))) { display: none; }
|
|
5
|
-
.query-editor { display: flex; align-items: center; width: 100%; padding: 3px 0; }
|
|
6
|
-
.query-editor > label { width: var(--label-width); flex-shrink: 0; padding-right: 1em; word-break: break-word; }
|
|
7
|
-
.query-controls { display: flex; flex: 1; min-width: 0; }
|
|
8
|
-
.query-controls > rokit-input, .query-controls > rokit-slider, .query-value-row > rokit-input, .query-value-row > rokit-select { min-height: 28px; width: 100%; flex-grow: 1; }
|
|
9
|
-
.query-value-row { display: flex; flex: 1; width: 100%; min-width: 0; gap: 4px; }
|
|
10
|
-
.query-language { min-height: 28px; flex: 0 0 auto; }
|
|
11
|
-
.query-range-slider[data-active='false'] { opacity: 0.7; }
|
|
12
|
-
.query-facet-error .query-editor > label { color: var(--shacl-error-color); }
|
|
13
|
-
`,R=0,z=class{constructor(e){this.stylesheet=new CSSStyleSheet,this.facetRequest=0,this.facetsApplied=!1,this.host=e,this.stylesheet.replaceSync(L),e.config.queryFacetProvider&&this.setFacetsPending(!0)}async initialize(){await this.emitQueryAndRefreshFacets()}handleChange(){this.emitQueryAndRefreshFacets()}getQuery(){let e=this.host.shape;return e?{rootShapeId:e.template.id.value,targetClass:e.template.targetClass?.value,criteria:Array.from(this.host.form.querySelectorAll(`.query-editor`)).flatMap(e=>e.getQueryCriteria())}:{rootShapeId:``,criteria:[]}}refreshFacets(){this.host.shape&&this.requestFacets(this.getQuery())}dispose(){this.facetAbortController?.abort(),this.setFacetsPending(!1),this.host.classList.remove(`query-facets-empty`)}async emitQueryAndRefreshFacets(){if(!this.host.shape)return;let e=Array.from(this.host.form.querySelectorAll(`.query-editor`)).map(e=>e.queryField),t=this.getQuery(),n=this.host.config.queryFacetProvider;if(this.previousQuery&&n?.invalidatedFields){let r=new Set(n.invalidatedFields({previousQuery:this.previousQuery,query:t,fields:e}));for(let e of this.host.form.querySelectorAll(`.query-editor`))r.has(e.queryField.id)&&e.clearQueryCriteria?.();t=this.getQuery()}this.previousQuery=t,this.host.dispatchEvent(new CustomEvent(`query`,{bubbles:!0,composed:!0,detail:t})),await this.requestFacets(t)}async requestFacets(e){let t=this.host.config.queryFacetProvider;if(!t)return;this.facetAbortController?.abort();let n=new AbortController;this.facetAbortController=n;let r=++this.facetRequest;this.facetsApplied||this.setFacetsPending(!0);try{let i=Array.from(this.host.form.querySelectorAll(`.query-editor`)).map(e=>e.queryField),a=await t.getFacets({query:e,fields:i,signal:n.signal});if(n.signal.aborted||r!==this.facetRequest)return;let o=this.applyFacets(a,!this.facetsApplied);this.facetsApplied=!0,this.setFacetsPending(!1),o&&(await new Promise(e=>setTimeout(e,0)),await this.emitQueryAndRefreshFacets())}catch(e){if(n.signal.aborted)return;this.setFacetsPending(!1),this.host.dispatchEvent(new CustomEvent(`queryerror`,{bubbles:!0,composed:!0,detail:e}))}}applyFacets(e,t){let n=new Map(e.map(e=>[e.fieldId,e])),r=!1;for(let e of Array.from(this.host.form.querySelectorAll(`.query-editor`))){let i=n.get(e.queryField.id);i?.initialValue&&!t&&(i={...i,initialValue:void 0});let a=e.setQueryFacet(i)===!0;r||=a;let o=a||e.getQueryCriteria().length>0,s=e.closest(`shacl-property`);s?.classList.toggle(`query-unavailable`,e.unavailable||i?.unavailable===!0||i?.count===0&&!o),s?.classList.toggle(`query-facet-error`,i?.error===!0)}let i=Array.from(this.host.form.querySelectorAll(`shacl-property`)).reverse();for(let e of i){if(e.querySelector(`:scope > .query-editor, :scope > .collapsible > .query-editor`))continue;let t=Array.from(e.querySelectorAll(`.query-editor`)).some(e=>!e.closest(`shacl-property`)?.classList.contains(`query-unavailable`));e.classList.toggle(`query-unavailable`,!t)}let a=Array.from(this.host.form.querySelectorAll(`.query-editor`)).some(e=>!e.closest(`shacl-property`)?.classList.contains(`query-unavailable`));return this.host.classList.toggle(`query-facets-empty`,!a),r}setFacetsPending(e){this.host.toggleAttribute(`loading`,e);let t=this.host.form.querySelector(`[part~="loading"]`);if(!e)t?.remove();else if(!t){let e=document.createElement(`div`);e.setAttribute(`part`,`loading`),e.textContent=this.host.config.attributes.loading,this.host.form.prepend(e)}}};async function B(e){let n=t=>{e.container.appendChild(t),t.unavailable&&e.classList.add(`query-unavailable`)},a=e.template;if(a.or?.length||a.xone?.length){let r=G(a);if(r){n(H(r,e.parent));return}let i=a.or?.length?a.or:a.xone;e.container.appendChild(t(i,e,a.config));return}let o=_(a);if(o){let t=e.parent.queryContext??{path:[],shapePath:[]},s=i(o);s.label=a.label,n(H(s,{queryContext:{path:[...t.path,r(a)],shapePath:[...t.shapePath,K(a)]}}));return}if(!a.nodeShapes.size){n(H(a,e.parent));return}if(V(a)){let t=i(a);t.facet=!0,t.nodeShapes=new Set;for(let e of a.nodeShapes)if(e.targetClass){t.class=e.targetClass;break}t.nodeKind??=s,n(H(t,e.parent));return}for(let t of a.nodeShapes){let n=new Set(e.parent.ancestorShapeIds);if(n.add(e.parent.template.id.value),n.has(t.id.value))continue;let i=e.parent.queryContext??{path:[],shapePath:[]},o=new f(t,void 0,a.nodeKind,a.label,!1,n,{path:[...i.path,r(a)],shapePath:[...i.shapePath,K(a)]}),s=document.createElement(`div`);s.classList.add(`property-instance`,`query-structure`),s.setAttribute(`part`,`property-instance`),a.config.hierarchyColorsStyleSheet!==void 0&&s.appendChild(p(!0)),s.appendChild(o),e.container.appendChild(s),await o.ready}}function V(e){return e.facet===void 0?Array.from(e.nodeShapes).some(e=>e.facet===!0):e.facet}function H(e,t){let n=t.queryContext??{path:[],shapePath:[]},i={id:`qf${(R++).toString(36)}`,path:[...n.path,r(e)],shapePath:[...n.shapePath,K(e)],fixedValue:e.hasValue,datatype:e.datatype?.value,discrete:e.facet===!0},a=b(e.path,e.datatype?.value)?.createQueryEditor?.(i,e)??S(i,e);return a.queryField=i,a.classList.add(`property-instance`,`query-editor`),a.dataset.path=e.path,a}async function U(e,t){if(!e.length)return;for(let t of e)await t.initializeQuery();let n=e[0];t.replaceWith(n);for(let t=1;t<e.length;t++)n.after(e[t]),n=e[t];n.dispatchEvent(new Event(`change`,{bubbles:!0}))}async function W(e,t,n){e.or=void 0,e.xone=void 0;let r=new o(e,t.parent);await r.initializeQuery(),n.replaceWith(r),r.dispatchEvent(new Event(`change`,{bubbles:!0}))}function G(t){let r=t.or??t.xone;if(!r?.length)return;let a=r.map(e=>{let r=i(t);return r.or=void 0,r.xone=void 0,n(r,t.config.store.getQuads(e,null,null,null)),r.nodeShapes.size===0?r.datatype:void 0});if(a.some(e=>!e||!c.has(e.value)))return;let o=i(t);return o.or=void 0,o.xone=void 0,o.datatype=a.find(t=>t&&e.has(t.value))??a[0],o}function K(e){return e.qualifiedValueShape||e.pathAlternatives?e.queryShapePathId??e.id.value:e.path}export{z as QueryModeController,U as activateNodeConstraintOption,W as activatePropertyConstraintOption,B as initializeQueryProperty};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import{BlankNode as e,DataFactory as t,Literal as n,NamedNode as r,Store as i,StreamParser as a,Writer as o,termFromId as s,termToId as c}from"n3";import{RdfXmlParser as l}from"rdfxml-streaming-parser";import u from"jsonld";import{RokitButton as d,RokitCollapsible as f,RokitDialog as p}from"@ro-kit/ui-widgets";import{v4 as m}from"uuid";var h=`http://www.w3.org/ns/shacl#`,g=`http://datashapes.org/dash#`,ee=`http://www.w3.org/2001/XMLSchema#`,te=`http://www.w3.org/1999/02/22-rdf-syntax-ns#`,ne=`http://www.w3.org/2000/01/rdf-schema#`,re=`http://www.w3.org/ns/oa#`,ie=`http://purl.org/dc/terms/`,_=t.namedNode(`loaded-shapes`),v=t.namedNode(`loaded-data`),y=t.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`),b=t.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#first`),x=t.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#rest`),S=t.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#nil`),C=t.namedNode(`http://www.w3.org/1999/02/22-rdf-syntax-ns#langString`),w=t.namedNode(`http://purl.org/dc/terms/conformsTo`),ae=t.namedNode(`http://www.w3.org/2000/01/rdf-schema#subClassOf`),T=t.namedNode(`http://www.w3.org/2002/07/owl#imports`),oe=t.namedNode(`http://www.w3.org/2004/02/skos/core#broader`),se=t.namedNode(`http://www.w3.org/2004/02/skos/core#narrower`),ce=t.namedNode(`http://www.w3.org/ns/shacl#NodeShape`),le=t.namedNode(`http://www.w3.org/ns/shacl#IRI`),ue=t.namedNode(`http://www.w3.org/ns/shacl#property`),E=t.namedNode(`http://www.w3.org/ns/shacl#class`),de=t.namedNode(`http://www.w3.org/ns/shacl#node`),fe=t.namedNode(`http://www.w3.org/ns/shacl#message`),D=t.namedNode(`http://www.w3.org/ns/shacl#targetClass`),pe=t.namedNode(`http://www.w3.org/ns/shacl#nodeKind`),me=t.namedNode(`http://www.w3.org/2001/XMLSchema#string`),he=t.namedNode(`http://www.w3.org/2001/XMLSchema#boolean`),ge=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`]),_e=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`]),ve=new Set([`http://www.w3.org/2001/XMLSchema#float`,`http://www.w3.org/2001/XMLSchema#double`,`http://www.w3.org/2001/XMLSchema#decimal`]);function O(e,t,n=h,r){let i=``,a=ye(e,t,n,r);return a&&(i=a.value),i}function ye(e,t,n=h,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 be(e){e.querySelector(`.editor`)?.focus()}function k(e,t){return O(e,`prefLabel`,`http://www.w3.org/2004/02/skos/core#`,t)||O(e,`label`,`http://www.w3.org/2000/01/rdf-schema#`,t)||O(e,`title`,`http://purl.org/dc/terms/`,t)||O(e,`name`,`http://xmlns.com/foaf/0.1/`,t)}function A(e,t,n){let r=[];for(let i of e)r.push({value:i,label:k(t.getQuads(i,null,null,null),n),children:[]});return r}function j(e,t){for(let n in t){let r=t[n];e.startsWith(r)&&(e=e.slice(r.length))}return e}function xe(e,n,r=new Map){r.set(_.id,_),r.set(v.id,v);let i=e.config.valuesGraphId??t.defaultGraph();r.set(i.id,i);for(let t of e.owlImports)Se(t,n,r);return e.parent&&xe(e.parent,n,r),[...r.values()]}function Se(e,t,n){if(!n.has(e.id)){n.set(e.id,e);for(let r of t.getObjects(null,T,e))r.termType===`NamedNode`&&Se(r,t,n)}}function Ce(e,t,n,r){return r.flatMap(r=>e.getSubjects(t,n,r))}function M(e,t,n,r){return r.flatMap(r=>e.getObjects(t,n,r))}function N(e,t){if(t.in){let e=t.config.lists[t.in];return A(e?.length?e:[],t.config.store,t.config.languages)}else{let n=xe(t,t.config.store),r=Ce(t.config.store,y,e,n),i=new Map,a=new Map;for(let e of r)i.set(e.id,{value:e,label:k(t.config.store.getQuads(e,null,null,null),t.config.languages),children:[]});for(let e of r){for(let r of M(t.config.store,e,oe,n))i.has(r.id)&&a.set(e.id,r.id);for(let r of M(t.config.store,e,se,n))i.has(r.id)&&a.set(r.id,e.id);for(let r of M(t.config.store,e,ae,n))i.has(r.id)&&a.set(e.id,r.id)}for(let[e,t]of a.entries())i.get(t)?.children?.push(i.get(e));let o=[];for(let[e,t]of i.entries())a.has(e)||o.push(t);for(let r of Ce(t.config.store,ae,e,n))o.push(...N(r,t));return o}}function P(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`http:`||t.protocol===`https:`}function F(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 we(e,t){let n;for(let r of t)n=F(e,n,r);return n?n.value:``}var I=/^(-?\d{4,}-\d{2}-\d{2})(Z|[+-]\d{2}:\d{2})?$/,Te=/^(-?\d{4,}-\d{2}-\d{2})T(\d{2}:\d{2})(?::(\d{2})(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?$/,Ee=/^(-?\d{4,}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(\.\d+)?)?$/;function De(e){let t=e.match(I);if(!t){let t=e.match(Te);return t?{value:t[1],suffix:t[5]||``}:void 0}return{value:t[1],suffix:t[2]||``}}function Oe(e){let t=e.match(Te);if(!t){let t=e.match(I);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 ke(e,t=``){let n=e.match(I);return n?`${n[1]}${t}`:e}function Ae(e,t=``){let n=e.match(Ee);return n?`${n[1]}:${n[2]||`00`}${n[3]||``}${t}`:e}function je(e){let t=new Set;for(let n of e.getObjects(null,E,_))t.add(n.value);for(let n of e.getObjects(null,D,_))t.add(n.value);return t}function Me(e,t){return e instanceof Set?[...t].filter(t=>!e.has(t)):[...t].filter(t=>!e.includes(t))}function Ne(e,{remove:t=!1,ignoreErrors:n=!1}={}){let r={},i=n?()=>!0:(e,t)=>{throw Error(`${e.value} ${t}`)},a=e.getQuads(null,te+`rest`,te+`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(y)),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 L={},R={};async function z(e){return`rdf`in e?B(e.rdf):e.rdfUrlResolver?B(await e.rdfUrlResolver(e.url)):Pe(e.url,e.proxy)}async function Pe(e,t){return e in L||(L[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?B(await r.text()):(console.warn(`failed fetching RDF from`,e),[])})()),L[e]}async function B(e){if(!e.trim())return[];let n=Fe(e);if(n===`json`)try{e=await u.toRDF(JSON.parse(e),{format:`application/n-quads`})}catch(e){console.error(e)}let r=[];return await new Promise((i,o)=>{let s=n===`xml`?new l:new a;s.on(`data`,e=>{r.push(t.quad(e.subject,e.predicate,e.object,e.graph))}).on(`error`,e=>{o(e)}).on(`prefix`,(e,t)=>{e&&(R[e]=t)}).on(`end`,()=>{i(null)}),s.write(e),s.end()}),r}function Fe(e){return/^\s*[\\[{]/.test(e)?`json`:/^\s*<\?xml/.test(e)?`xml`:`ttl`}var Ie={[`${h}name`]:(e,t)=>{let n=t;e.name=F(e.config.languages,e.name,n)},[`${h}description`]:(e,t)=>{let n=t;e.description=F(e.config.languages,e.description,n)},[`${h}path`]:(e,t)=>{if(t.termType===`NamedNode`){e.path=t.value;return}let n=e.config.store.getQuads(t,null,null,null),r=n.filter(e=>e.predicate.value===`${h}alternativePath`);if(n.length!==1||r.length!==1){console.warn(`ignoring unsupported or malformed SHACL property path`,t.value);return}let i=e.config.lists[r[0].object.value];if(!i||i.length<2||i.some(e=>e.termType!==`NamedNode`)){console.warn(`ignoring sh:alternativePath without at least two predicate IRI members`,t.value);return}e.pathAlternatives=i.map(e=>e.value),e.path=e.pathAlternatives[0]},[`${h}group`]:(e,t)=>{e.group=t.id},[`${h}datatype`]:(e,t)=>{e.datatype=t},[`${h}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${h}minCount`]:(e,t)=>{e.minCount=parseInt(t.value)},[`${h}maxCount`]:(e,t)=>{e.maxCount=parseInt(t.value)},[`${h}minLength`]:(e,t)=>{e.minLength=parseInt(t.value)},[`${h}maxLength`]:(e,t)=>{e.maxLength=parseInt(t.value)},[`${h}minInclusive`]:(e,t)=>{e.minInclusive=parseInt(t.value)},[`${h}maxInclusive`]:(e,t)=>{e.maxInclusive=parseInt(t.value)},[`${h}minExclusive`]:(e,t)=>{e.minExclusive=parseInt(t.value)},[`${h}maxExclusive`]:(e,t)=>{e.maxExclusive=parseInt(t.value)},[`${h}pattern`]:(e,t)=>{e.pattern=t.value},[`${h}order`]:(e,t)=>{e.order=parseInt(t.value)},[`${g}singleLine`]:(e,t)=>{e.singleLine=t.value===`true`},[`${g}readonly`]:(e,t)=>{e.readonly=t.value===`true`},[`${g}facet`]:(e,t)=>{e.facet=t.value===`true`||t.value===`1`},[`${re}styleClass`]:(e,t)=>{e.cssClass=t.value},[`${h}in`]:(e,t)=>{e.in=t.value},[`${h}languageIn`]:(e,t)=>{e.languageIn=e.config.lists[t.value],e.datatype=C},[`${h}defaultValue`]:(e,t)=>{e.defaultValue=t},[`${h}hasValue`]:(e,t)=>{e.hasValue=t},[`${h}node`]:(e,t)=>{e.node=t,e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${h}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))},[`${h}qualifiedValueShape`]:(e,t)=>{let n=e.config.getNodeTemplate(t,e);e.qualifiedValueShape=n,e.nodeShapes.add(n)},[`${h}qualifiedMinCount`]:(e,t)=>{e.qualifiedMinCount=parseInt(t.value)},[`${h}qualifiedMaxCount`]:(e,t)=>{e.qualifiedMaxCount=parseInt(t.value)},[T.id]:(e,t)=>{e.owlImports.add(t)},[E.id]:(e,t)=>{e.class=t;let n=e.config.store.getSubjects(D,t,null);n.length>0&&(e.node=n[0])},[`${h}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)},[`${h}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)}},Le=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),U(this,this.config.store.getQuads(e,null,null,null))}};function V(e){return Math.max(e.minCount??0,e.qualifiedMinCount??0)}function Re(e){return Math.min(e.maxCount??2**53-1,e.qualifiedMaxCount??2**53-1)}function H(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.pathAlternatives&&(t.pathAlternatives=[...e.pathAlternatives]),e.pathAlternativeBranches&&(t.pathAlternativeBranches={...e.pathAlternativeBranches}),e.or&&(t.or=[...e.or]),e.xone&&(t.xone=[...e.xone]),t}function U(e,t){for(let n of t)Ie[n.predicate.id]?.call(e,e,n.object);return e.label=e.name?.value||k(t,e.config.languages),e.label||=e.pathAlternatives?e.pathAlternatives.map(e=>j(e,R)).join(` / `):e.path?j(e.path,R):`unknown`,e}function ze(e,t,n=!1){let r=t,i=e,a=He(e),o=He(t),s=a&&Ue(t),c=o&&Ue(e);s&&(e.nodeShapes.clear(),e.node=void 0);for(let a in t)if(a!==`parent`&&a!==`config`&&a!==`id`){let o=r[a];if(o!==void 0&&o!==``){if(a===`label`)continue;if(a===`name`||a===`description`||a===`group`||a===`order`)(n||i[a]===void 0||i[a]===``)&&(i[a]=o);else if(a===`minCount`)e.minCount=Math.max(e.minCount??0,t.minCount);else if(a===`maxCount`)e.maxCount=Math.min(e.maxCount??2**53-1,t.maxCount);else if(a===`qualifiedMinCount`)e.qualifiedMinCount=Math.max(e.qualifiedMinCount??0,t.qualifiedMinCount);else if(a===`qualifiedMaxCount`)e.qualifiedMaxCount=Math.min(e.qualifiedMaxCount??2**53-1,t.qualifiedMaxCount);else if(a===`nodeShapes`&&c)continue;else if(a===`node`&&c)continue;else if(a===`pathAlternatives`)continue;else if(Array.isArray(o)){let e=i[a];Array.isArray(e)?e.push(...o):i[a]=[...o]}else if(o instanceof Set&&o.size){let e=i[a];i[a]=new Set([...e instanceof Set?e:[],...o])}else i[a]=o}}e.name&&(e.label=e.name.value)}function Be(e){return e.pathAlternatives?`alternative:${JSON.stringify(e.pathAlternatives)}`:e.path}function Ve(e){return e.pathAlternatives?[...e.pathAlternatives]:e.path}function He(e){return e.nodeShapes.size>0&&e.qualifiedValueShape===void 0&&e.name===void 0&&e.description===void 0&&!Ue(e)}function Ue(e){return e.in!==void 0||e.datatype!==void 0||e.languageIn!==void 0||e.class!==void 0||e.hasValue!==void 0||e.defaultValue!==void 0}var We=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),Ge=function(e){return`/`+e},Ke={},W=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=Ge(t,n),t=s(t),t in Ke)return;Ke[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`:We,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 qe(e,t,n,r,i){let a=document.createElement(`div`);a.classList.add(`shacl-or-constraint`),a.setAttribute(`part`,`constraint`);let o=[];if(t instanceof $){let r=[],i=!1;e.length&&(i=n.store.countQuads(e[0],ue,null,null)>0);for(let a=0;a<e.length;a++)if(i){let i=n.store.getObjects(e[a],ue,null),s=[],c=``;for(let e of i){let r=new Y(n.getPropertyTemplate(e,t.template),t);s.push(r),c+=(c.length>0?` / `:``)+r.template.label}r.push(s),o.push({label:c,value:a.toString()})}else{let i=e[a],s=new Y(n.getPropertyTemplate(i,t.template),t);r.push([s]),o.push({label:s.template.label,value:a.toString()})}let s=n.theme.createListEditor(`Please choose`,null,!1,o);s.setAttribute(`part`,`constraint-editor`);let c=s.querySelector(`.editor`);c.onchange=async()=>{if(c.value){let e=r[parseInt(c.value)];if(n.queryMode){let{activateNodeConstraintOption:t}=await W(async()=>{let{activateNodeConstraintOption:e}=await import(`./mode-D-xYMD5v.js`);return{activateNodeConstraintOption:e}},[]);await t(e,a);return}let i;if(e.length){for(let n of e)await n.bindValues(t.nodeId,!1);i=e[0],a.replaceWith(e[0]),i.updateControls()}for(let t=1;t<e.length;t++)i.after(e[t]),i=e[t],i.updateControls()}},a.appendChild(s)}else{let s=[];for(let t=0;t<e.length;t++){let r=n.store.getQuads(e[t],null,null,null);if(r.length){s.push(r);let e=k(r,n.languages);for(let t of r)t.predicate.equals(de)&&(e||=k(n.store.getQuads(t.object,null,null,null),n.languages));o.push({label:e||j(r[0].predicate.value,R)+` = `+j(r[0].object.value,R),value:(s.length-1).toString()})}}let c=n.theme.createListEditor(t.template.label+`?`,null,!1,o,t.template);c.setAttribute(`part`,`constraint-editor`);let l=c.querySelector(`.editor`);l.onchange=async()=>{if(l.value){let e=U(H(i??t.template),s[parseInt(l.value)]);if(e.or=void 0,e.xone=void 0,n.queryMode){let{activatePropertyConstraintOption:n}=await W(async()=>{let{activatePropertyConstraintOption:e}=await import(`./mode-D-xYMD5v.js`);return{activatePropertyConstraintOption:e}},[]);await n(e,t,a);return}if(r||Re(t.template)>1){let n=await Z(e,void 0,!0,!1,t.parent);n.dataset.path=t.template.path,r&&(n.dataset.predicate=r),a.replaceWith(n),n.dispatchEvent(new Event(`change`,{bubbles:!0,cancelable:!0}));return}e.pathAlternatives=void 0;let o=new Y(e,t.parent);t.replaceWith(o),await o.updateControls()}},a.appendChild(c)}return a}function Je(e,t,n,r=!1){let i=document.createElement(`div`);i.classList.add(`alternative-path-constraint`),i.setAttribute(`part`,`constraint`),i.dataset.path=e.template.path;let a=e.template.pathAlternatives.map((e,t)=>({label:j(e,R),value:t.toString()})),o=e.template.config.theme.createListEditor(`${e.template.label}: path`,null,!1,a,e.template);o.setAttribute(`part`,`constraint-editor`);let s=o.querySelector(`.editor`);return s.onchange=async()=>{if(s.value===``)return;let r=e.template.pathAlternatives[parseInt(s.value)],a=await e.addPropertyInstance(t,n,!0,r,!1);a&&(i.replaceWith(a),a.dispatchEvent(new Event(`change`,{bubbles:!0,cancelable:!0})))},i.appendChild(o),It(i,e.template.label,e.template.config.theme.dense,e.template.config.hierarchyColorsStyleSheet!==void 0,r),i}function Ye(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,y,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,D,i,null).length>0)return e}if(t.predicate.equals(E)){for(let n of r)if(t.object.equals(n))return e}}else if(t.predicate.equals(pe)&&t.object.equals(le))return e}}return console.error(`couldn't resolve sh:or/sh:xone on property for value`,t),[]}function Xe(e,t,n){for(let r of e){let e=!1,i=n.store.getObjects(r,ue,null);for(let r of i){let i=n.store.getObjects(r,`${h}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 Ze=`:host {
|
|
2
|
-
--shacl-font-family: inherit;
|
|
3
|
-
--shacl-font-size: 14px;
|
|
4
|
-
--shacl-text-color: #333;
|
|
5
|
-
--shacl-muted-color: #555;
|
|
6
|
-
--shacl-border-color: #DDD;
|
|
7
|
-
--shacl-bg: #FFF;
|
|
8
|
-
--shacl-row-alt-bg: #F8F8F8;
|
|
9
|
-
--shacl-error-color: #C00;
|
|
10
|
-
--shacl-label-width: 8em;
|
|
11
|
-
--linked-icon: url('data:image/svg+xml;utf8,<svg viewBox="-1 -1 18 18" xmlns="http://www.w3.org/2000/svg"><path d="m13.4 7.6-6.3 6.3a4 4 0 0 1-5.7-5.7l6.6-6.6a2.75 2.75 0 0 1 3.9 3.9l-6.6 6.6a1.5 1.5 0 0 1-2.1-2.1l6-6" fill="none" stroke="black" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg>');
|
|
12
|
-
}
|
|
13
|
-
form { display:block; --label-width: var(--shacl-label-width, 8em); --caret-size: 10px; font-family: var(--shacl-font-family); font-size: var(--shacl-font-size); color: var(--shacl-text-color); background-color: var(--shacl-bg); }
|
|
14
|
-
form.mode-edit { padding-left: 1em; }
|
|
15
|
-
form, form * { box-sizing: border-box; }
|
|
16
|
-
shacl-node, .collapsible::part(content) { display: flex; flex-direction: column; width: 100%; position: relative; }
|
|
17
|
-
shacl-node .remove-button { margin-top: 1px; }
|
|
18
|
-
shacl-node .add-button-wrapper { display: flex; width: 100%; justify-content: flex-end; gap: 20px; padding-right: 24px; color: var(--shacl-muted-color); font-size: 14px; }
|
|
19
|
-
shacl-node .add-button::part(button)::before { content: '+ ' }
|
|
20
|
-
shacl-node .link-button::part(button)::before { content: ''; display: inline-block; width: 1em; height: 1em; background-color: currentColor; -webkit-mask: var(--linked-icon) center / contain no-repeat; mask: var(--linked-icon) center / contain no-repeat; }
|
|
21
|
-
shacl-node h1 { font-size: 16px; border-bottom: 1px solid #AAA; margin-top: 4px; color: var(--shacl-muted-color); }
|
|
22
|
-
shacl-property:not(:has(>.collapsible)), shacl-property>.collapsible::part(content) { display: flex; flex-direction: column; align-items: end; position: relative; }
|
|
23
|
-
shacl-property:not(.may-add) > .add-button-wrapper, shacl-property:not(.may-add) > .collapsible > .add-button-wrapper { display: none; }
|
|
24
|
-
shacl-property:not(.may-remove) > .property-instance > .remove-button-wrapper > .remove-button:not(.persistent) { visibility: hidden; }
|
|
25
|
-
shacl-property:not(.may-remove) > .collapsible > .property-instance > .remove-button-wrapper > .remove-button:not(.persistent) { visibility: hidden; }
|
|
26
|
-
shacl-property:not(.may-remove) > .shacl-or-constraint > .remove-button-wrapper > .remove-button:not(.persistent),
|
|
27
|
-
shacl-property:not(.may-remove) > .alternative-path-constraint > .remove-button-wrapper > .remove-button:not(.persistent),
|
|
28
|
-
shacl-property:not(.may-remove) > .collapsible > .alternative-path-constraint > .remove-button-wrapper > .remove-button:not(.persistent) { visibility: hidden; }
|
|
29
|
-
.mode-view .shacl-group:not(:has(shacl-property)) { display: none; }
|
|
30
|
-
.property-instance, .shacl-or-constraint, .alternative-path-constraint { display: flex; align-items: center; padding: 4px 0; width: 100%; position: relative; }
|
|
31
|
-
.shacl-or-constraint > div, .alternative-path-constraint > div { display: flex; align-items: flex-start; }
|
|
32
|
-
.shacl-or-constraint > div:first-child, .alternative-path-constraint > div:first-child { flex-grow: 1 }
|
|
33
|
-
.shacl-or-constraint label, .alternative-path-constraint label { display: inline-block; word-break: break-word; width: var(--label-width); line-height: 1em; padding-top: 0.15em; padding-right: 1em; flex-shrink: 0; position: relative; }
|
|
34
|
-
.property-instance label[title] { cursor: help; text-decoration: underline dashed #AAA; }
|
|
35
|
-
.property-instance.linked label:after, label.linked:after { content: ''; position: absolute; top: 50%; right: 2px; width: 1.1em; height: 1.1em; transform: translateY(-50%); background-color: currentColor; -webkit-mask: var(--linked-icon) center / contain no-repeat; mask: var(--linked-icon) center / contain no-repeat; }
|
|
36
|
-
.mode-edit .property-instance label.required::before, .add-button-wrapper.required > .add-button::before, .add-button-wrapper.required > .link-button::before { color: var(--shacl-error-color); content: '\\2736'; font-size: 0.6rem; position: absolute; left: -1.4em; }
|
|
37
|
-
.mode-edit .add-button-wrapper.required > .add-button::before, .add-button-wrapper.required > .link-button::before { left: -0.5em; }
|
|
38
|
-
.property-instance.valid::before { content: ''; position: absolute; left: calc(var(--label-width) - 1em); top: 50%; transform: translateY(-50%); width: 0.9em; height: 0.9em; background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1024 1024" fill="green" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M866.133333 258.133333L362.666667 761.6l-204.8-204.8L98.133333 618.666667 362.666667 881.066667l563.2-563.2z"/></svg>'); }
|
|
39
|
-
.editor:not([type='checkbox']) { flex-grow: 1; }
|
|
40
|
-
textarea.editor { resize: vertical; }
|
|
41
|
-
.lang-chooser { border: 0; background-color: #e9e9ed; padding: 2px 4px; align-self: flex-start; }
|
|
42
|
-
.validation-error { position: absolute; left: calc(var(--label-width) - 1em); top: 50%; transform: translateY(-50%); color: var(--shacl-error-color); cursor: help; }
|
|
43
|
-
.validation-error::before { content: '\\26a0' }
|
|
44
|
-
.validation-error.node { left: -1em; top: calc(4px + 0.45em); transform: none; }
|
|
45
|
-
.property-instance:has(> .editor:is(textarea, rokit-textarea)).valid::before,
|
|
46
|
-
.property-instance:has(> .editor:is(textarea, rokit-textarea)) > .validation-error {
|
|
47
|
-
top: calc(4px + 0.45em);
|
|
48
|
-
transform: none;
|
|
49
|
-
}
|
|
50
|
-
.invalid > .editor { border-color: red !important; }
|
|
51
|
-
.ml-0 { margin-left: 0 !important; }
|
|
52
|
-
.pr-0 { padding-right: 0 !important; }
|
|
53
|
-
.mode-view .property-instance:not(:first-child) > label { visibility: hidden; }
|
|
54
|
-
.mode-view .property-instance label { width: var(--label-width); }
|
|
55
|
-
|
|
56
|
-
.d-flex { display: flex; }
|
|
57
|
-
.lang { opacity: 0.65; font-size: 0.6em; }
|
|
58
|
-
a, a:visited { color: inherit; }
|
|
59
|
-
h3 { margin-top: 0; }
|
|
60
|
-
|
|
61
|
-
.fadeIn, .fadeOut { animation: fadeIn 0.2s ease-out; }
|
|
62
|
-
.fadeOut { animation-direction: reverse; animation-timing-function: ease-out;}
|
|
63
|
-
@keyframes fadeIn {
|
|
64
|
-
0% { opacity: 0; transform: scaleY(0.8); }
|
|
65
|
-
100% { opacity: 1; transform: scaleY(1); }
|
|
66
|
-
}
|
|
67
|
-
.collapsible::part(label) { font-weight: 600; }
|
|
68
|
-
.collapsible > .property-instance:nth-child(even) { background-color: var(--shacl-row-alt-bg); }
|
|
69
|
-
.collapsible > .property-instance > shacl-node > h1 { display: none; }
|
|
70
|
-
.ref-link { cursor: pointer; }
|
|
71
|
-
.ref-link:hover { text-decoration: underline; }
|
|
72
|
-
.node-id-display { color: var(--shacl-muted-color); font-size: 11px; }
|
|
73
|
-
/* hierarchy colors */
|
|
74
|
-
.colorize { --hierarchy-color-width: 3px; padding: 0 1px 0 calc(1px + var(--hierarchy-color-width)); align-self: stretch; position: relative; }
|
|
75
|
-
.colorize::before {
|
|
76
|
-
content: '';
|
|
77
|
-
position: absolute;
|
|
78
|
-
width: var(--hierarchy-color-width);
|
|
79
|
-
top: 0; bottom: 0; left: 0;
|
|
80
|
-
--index: mod(var(--hierarchy-level), var(--hierarchy-colors-length));
|
|
81
|
-
background: linear-gradient(var(--hierarchy-colors)) no-repeat 0 calc(var(--index) * 100% / (var(--hierarchy-colors-length) - 1)) / 100% calc(1px * infinity);
|
|
82
|
-
}
|
|
83
|
-
.property-instance:not(:has(shacl-node)) > .colorize::before { background: 0; }
|
|
84
|
-
.colorize:not(:has(.remove-button)) { padding-left: calc(8px + var(--hierarchy-color-width)); }
|
|
85
|
-
.mode-view .property-instance > .colorize { order: -1; }
|
|
86
|
-
.link-option { padding: 10px; }
|
|
87
|
-
.link-option:hover { background-color: #F5F5F5; cursor: pointer; }
|
|
88
|
-
rokit-dialog.link-chooser::part(dialog) { min-height: min(434px, 90vh); width: min(90vw, 600px); }
|
|
89
|
-
rokit-select::part(facet-count) { color: var(--shacl-muted-color); }
|
|
90
|
-
rokit-select::part(facet-count)::after { content: attr(data-count); color: inherit; display: inline-block; font-family: monospace; margin-left: 7px; font-size: 12px; }
|
|
91
|
-
`,Qe=class{constructor(e){this.dense=!0;let t=Ze;e&&(t+=`
|
|
92
|
-
`+e),this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t)}apply(e){}setDense(e){this.dense=e}createViewer(e,t,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=t.value,c=null;if(t instanceof r){let e=i.config.store.getQuads(s,null,null,null);if(e.length){let t=k(e,i.config.languages);t&&(s=t)}}else t instanceof n&&(t.language?(c=document.createElement(`span`),c.classList.add(`lang`),c.innerText=`@${t.language}`):t.datatype.value===`http://www.w3.org/2001/XMLSchema#date`?s=new Date(Date.parse(t.value)).toDateString():t.datatype.value===`http://www.w3.org/2001/XMLSchema#dateTime`&&(s=new Date(Date.parse(t.value)).toLocaleString()));let l;return P(t.value)?(l=document.createElement(`a`),l.setAttribute(`href`,t.value)):l=document.createElement(`div`),l.classList.add(`d-flex`),l.innerText=s,c&&l.appendChild(c),a.appendChild(l),a}};function $e(e,t,r){if(r){let r=V(e)>0;if(e.class&&!e.hasValue)return e.config.theme.createListEditor(e.label,t,r,N(e.class,e),e);if(e.in){let n=e.config.lists[e.in];if(n?.length){let i=A(n,e.config.store,e.config.languages);return e.config.theme.createListEditor(e.label,t,r,i,e)}else console.error(`list not found:`,e.in,`existing lists:`,e.config.lists)}if(e.datatype?.equals(C)||e.languageIn?.length||e.datatype===void 0&&t instanceof n&&t.language)return e.config.theme.createLangStringEditor(e.label,t,r,e);switch(e.datatype?.value.replace(ee,``)){case`integer`:case`float`:case`double`:case`decimal`:return e.config.theme.createNumberEditor(e.label,t,r,e);case`date`:case`dateTime`:return e.config.theme.createDateEditor(e.label,t,r,e);case`boolean`:return e.config.theme.createBooleanEditor(e.label,t,r,e);case`base64Binary`:return e.config.theme.createFileEditor(e.label,t,r,e)}return e.config.theme.createTextEditor(e.label,t,r,e)}else return t?e.config.theme.createViewer(e.label,t,e):document.createElement(`div`)}function et(e,t){e.rdfTerm=t??void 0,e.rdfTermState=t?ot(e):void 0}function tt(e,t){e.rdfTerms=new Map;for(let n of t)e.rdfTerms.set(nt(n),n)}function nt(e){return c(e)}function rt(e){let t=e.rdfTerms?.get(e.value);if(t)return t;if(!(!e.rdfTerm||!st(e.rdfTermState,ot(e))))return e.rdfTerm}function G(i){let a=rt(i);if(a)return a;let o=i.shaclDatatype,s=i.dataset.value||i.value;if((i.type===`file`||i.getAttribute(`type`)===`file`)&&i.binaryData)s=i.binaryData;else if(i.type===`checkbox`||i.getAttribute(`type`)===`checkbox`)return i.checked||parseInt(i.dataset.minCount||`0`)>0?t.literal(i.checked?`true`:`false`,o):void 0;if(!s)return;let c=i.dataset.nodeKind,l=it(s);if(i.dataset.link)return t.fromTerm(JSON.parse(i.dataset.link));if(i.dataset.class)return l instanceof r||l instanceof e?l:t.namedNode(s);if(c===`http://www.w3.org/ns/shacl#IRI`)return l instanceof r?l:t.namedNode(s);if(c===`http://www.w3.org/ns/shacl#BlankNode`)return l instanceof e?l:t.blankNode(s);if(c===`http://www.w3.org/ns/shacl#BlankNodeOrIRI`)return l instanceof r||l instanceof e?l:t.namedNode(s);if(l instanceof r||l instanceof e||l instanceof n&&!i.dataset.lang&&(!o||o instanceof r&&me.equals(o)))return l;if(i.dataset.lang)o=i.dataset.lang;else if(o instanceof r&&ve.has(o.value)){let e=at(s,o.value);if(e===void 0)return;s=e}else i.type===`number`?s=parseFloat(s):i.type===`datetime-local`?s=Ae(s,i.dataset.xsdTemporalSuffix):i.type===`date`&&o instanceof r&&o.value===`http://www.w3.org/2001/XMLSchema#date`&&(s=ke(s,i.dataset.xsdTemporalSuffix));return t.literal(s,o)}function it(i){let a=i;if(i.startsWith(`<`)&&i.endsWith(`>`))a=i.slice(1,-1);else if(!i.startsWith(`_:`)&&!i.startsWith(`"`))return;let o=s(a,t);return o instanceof r||o instanceof e||o instanceof n?o:void 0}function at(e,t){let n=e.replace(`,`,`.`);return(t===`http://www.w3.org/2001/XMLSchema#decimal`?/^[-+]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)$/:/^[-+]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?$/).test(n)?n:void 0}function ot(e){return{value:e.value,language:e.dataset.lang,checked:e.checked,binaryData:e.binaryData}}function st(e,t){return e?.value===t.value&&e.language===t.language&&e.checked===t.checked&&e.binaryData===t.binaryData}function ct(e,t,n){if(t===`application/ld+json`)return lt(e);{let r=new o({format:t,prefixes:n});r.addQuads(e);let i=``;return r.end((e,t)=>{e&&console.error(e),i=t}),i}}function lt(e){let t=[];for(let r of e){let e={"@id":r.subject.id};if(r.predicate.equals(y))e[`@type`]=r.object.id;else{let t=r.object.value;r.object instanceof n?r.object.language?t={"@language":r.object.language,"@value":r.object.value}:r.object.datatype&&r.object.datatype.value!==`http://www.w3.org/2001/XMLSchema##string`&&(t={"@type":r.object.datatype.value,"@value":r.object.value}):t={"@id":r.object.id},e[r.predicate.value]=t}t.push(e)}return JSON.stringify(t)}var K={};function ut(e){e.predicate===void 0&&e.datatype===void 0?console.warn(`not registering plugin because it does neither define "predicate" nor "datatype"`,e):K[`${e.predicate}^${e.datatype}`]=e}function dt(){return Object.entries(K).map(e=>e[1])}function ft(e,t){let n=K[`${e}^${t}`];return n||(n=K[`${e}^undefined`],n)?n:K[`undefined^${t}`]}var pt=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 mt(e){let t=new Set;for(let n of e.getQuads(null,w,null,v))n.subject.termType===`NamedNode`&&t.add(n.subject.value);if(t.size===1)return t.values().next().value}function ht(e,n){let r=t.namedNode(n);for(let t of e.getObjects(r,w,v))if(t.termType===`NamedNode`&&e.getQuads(t,y,ce,null).length>0)return t}async function gt(e,t){let n={store:new i,importedUrls:[],atts:e},r=[];if(e.shapes?r.push(q(z({rdf:e.shapes}),n,_)):e.shapesUrl&&r.push(q(z({url:e.shapesUrl,proxy:n.atts.proxy,rdfUrlResolver:n.atts.rdfUrlResolver}),n,_)),e.values?r.push(q(z({rdf:e.values}),n,v,t)):e.valuesUrl&&r.push(q(z({url:e.valuesUrl,proxy:n.atts.proxy,rdfUrlResolver:n.atts.rdfUrlResolver}),n,v,t)),await Promise.all(r),e.classInstanceProvider)try{let t=je(n.store),r=await e.classInstanceProvider(t);r&&await q(z({rdf:r}),n,_)}catch(e){console.error(`failed loading class instances`,e)}if(e.valuesSubject||=mt(n.store)||null,e.valuesSubject&&n.store.countQuads(null,null,null,_)===0){let t=[...n.store.getObjects(e.valuesSubject,y,v),...n.store.getObjects(e.valuesSubject,w,v)],r=[];for(let e of t){let t=_t(e.value);!t&&e.value.startsWith(`urn:`)&&n.atts.proxy&&(t=e.value),t&&n.importedUrls.indexOf(t)<0&&(n.importedUrls.push(t),r.push(q(z({url:t,proxy:n.atts.proxy,rdfUrlResolver:n.atts.rdfUrlResolver}),n,_)))}try{await Promise.allSettled(r)}catch(e){console.warn(e)}}return n.store}async function q(e,n,r,i){let a=await e,o=[];for(let e of a){i?.add(e);let a=r;if(n.atts.valuesSubject&&v.equals(r)&&e.graph.id&&e.graph.id!==n.atts.valuesSubject&&(a=e.graph),n.store.add(t.quad(e.subject,e.predicate,e.object,a)),n.atts.loadOwlImports&&T.equals(e.predicate)){let r=_t(e.object.value);r&&n.importedUrls.indexOf(r)<0&&(n.importedUrls.push(r),o.push(q(z({url:r,proxy:n.atts.proxy,rdfUrlResolver:n.atts.rdfUrlResolver}),n,t.namedNode(r))))}}await Promise.allSettled(o)}function _t(e){if(P(e))return e;let t=e.split(`:`);if(t.length===2){let n=R[t[0]];if(n&&(e=e.replace(`${t[0]}:`,n),P(e)))return e}return null}async function vt(e){if(e.template.nodeShapes.size===0)return;let t=e.template.config.resourceLinkProvider;if((!t||t&&!t.lazyLoad)&&(await Ct(e.template),bt(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 Ct(e.template),n.classList.remove(`loading`));let r=bt(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 p,t.classList.add(`link-chooser`),t.closable=!0,e.template.config.form.appendChild(t)),t.title=`Link existing `+e.template.label,yt(t,e,r),t.open=!0}}),n}function yt(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.value,n.addEventListener(`click`,async()=>{await xt(i,t),e.open=!1}),r.appendChild(n)}e.replaceChildren(r)}function bt(e){let n=e.template.config,r=St(e.template),a=new Set(Array.from(e.querySelectorAll(`:scope > .property-instance > shacl-node, :scope > .collapsible > .property-instance > shacl-node`)).map(e=>e.nodeId.id)),o=new Map;for(let t of n.form.querySelectorAll(`shacl-node:not([part~="linked-node"])`)){if(!r.has(t.template.id.value)||a.has(t.nodeId.id))continue;let s=new i;t.toRDF(s),o.set(t.nodeId.id,{value:t.nodeId,label:k([...s.getQuads(t.nodeId,null,null,null),...n.store.getQuads(t.nodeId,null,null,null)],n.languages)||n.providedResourceLabels[t.nodeId.value],template:e.template})}if(n.resourceLinkProvider)for(let i of r)for(let r of n.providedConformingResourceIds[i]??[]){let i=t.namedNode(r);!a.has(i.id)&&!o.has(i.id)&&o.set(i.id,{value:i,label:n.providedResourceLabels[r]||k(n.store.getQuads(i,null,null,null),n.languages),template:e.template})}return[...o.values()]}async function xt(e,t){let n=e.value.value;if(e.value.termType===`NamedNode`&&e.template.config.providedResources[n]?.length>0){let t={store:e.template.config.store,importedUrls:[],atts:{loadOwlImports:!1}};await q(z({rdf:e.template.config.providedResources[n]}),t,_),e.template.config.providedResources[n]=``}let r=await Z(e.template,e.value,!0,!0);t.container.insertBefore(r,t.querySelector(`:scope > .add-button-wrapper`)),await t.updateControls()}function St(e){return new Set(Array.from(e.nodeShapes,e=>e.id.value))}async function Ct(e){let t=e.config.resourceLinkProvider;if(!t)return;let n=St(e);if(n.size===0)return;let r=Me(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 wt(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 wt(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 z({rdf:i.resourceRDF});n.providedResourceLabels[i.resourceId]=k(e.filter(e=>e.subject.value===i.resourceId),n.languages),t&&await q(Promise.resolve(e),r,_)}return e}for(let e of r)n.providedResources[e]||(n.providedResources[e]=``)}catch(e){console.error(`failed loading resources`,e)}}return[]}async function Tt(e){let t=new Set;for(let n of e.store.getQuads(null,null,null,v))Et(n.object,e.store)&&t.add(n.object.value);await wt(t,!0,e)}function Et(e,t){return e.termType===`NamedNode`&&t.countQuads(e,null,null,null)===0}var J=`:scope > .add-button-wrapper, :scope > .collapsible > .add-button-wrapper`,Dt=`:scope > .property-instance, :scope > .shacl-or-constraint, :scope > .alternative-path-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance, :scope > .collapsible > .alternative-path-constraint`,Y=class extends HTMLElement{constructor(e,t){if(super(),this.rdfListNodes=new WeakMap,this.rdfListGroups=new WeakMap,this.template=e,this.parent=t,this.rdfListItemTemplate=At(e),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 f;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.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.pathAlternatives??[this.template.path]).flatMap(t=>this.template.config.store.getQuads(e,t,null,this.parent.linked?null:v));t&&(r=await this.filterValidValues(r,e)),r=r.filter(e=>this.parent.shouldBindPropertyValue(e));for(let e of r){this.parent.linked||this.template.config.store.delete(e);let t=!v.equals(e.graph)||this.template.config.providedResources[e.object.value]!==void 0;(this.rdfListItemTemplate?await this.bindRdfList(e.object,t):await this.addPropertyInstance(e.object,t,this.template.config.providedResources[e.object.value]!==void 0,e.predicate.value))&&this.parent.recordBoundPropertyValue(e),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 W(async()=>{let{initializeQueryProperty:e}=await import(`./mode-D-xYMD5v.js`);return{initializeQueryProperty:e}},[]);await e(this)}async addPropertyInstance(e,t,n=!1,r,i=!0){if(this.rdfListItemTemplate)return this.addRdfListItem(e,t,n,i);let a;if(this.template.pathAlternatives&&!r)this.template.config.editMode&&(a=Je(this,e,t,n));else{let i=r?this.template.pathAlternativeBranches?.[r]:void 0,o=r&&(r!==this.template.path||i)?H(this.template):this.template;if(r&&(o.path=r),i&&(ze(o,i,!0),o.label=i.name?.value||i.label||o.label),o.or?.length||o.xone?.length){let t=o.or?.length?o.or:o.xone,i=!1;if(e){let n=Ye(t,e,o.config);n.length&&(a=await Z(U(H(o),n),e,!this.parent.linked,this.parent.linked,this.parent),i=!0)}!i&&o.config.editMode&&(a=qe(t,this,o.config,r,o),It(a,``,o.config.theme.dense,o.config.hierarchyColorsStyleSheet!==void 0,n))}else a=await Z(o,e,n,t||this.parent.linked,this.parent)}return a&&(a.dataset.path=this.template.path,r&&(a.dataset.predicate=r),i&&this.container.insertBefore(a,this.querySelector(J))),a}async updateControls(){this.template.config.editMode&&!this.parent.linked&&!this.querySelector(J)&&this.container.appendChild(await this.createAddControls());let e=this.rdfListItemTemplate?+(V(this.template)>0):V(this.template),t=this.rdfListItemTemplate?this.rdfListItemTemplate.nodeShapes.size===0: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(J)?.classList.toggle(`required`,i<e);let a;a=e>0?i>e:!t||i>1;let o=this.rdfListItemTemplate!==void 0&&this.querySelector(`:scope > .property-instance.linked, :scope > .collapsible > .property-instance.linked`)!==null,s=new Set(Ot(this).map(e=>this.rdfListGroups.get(e))).size,c=this.rdfListItemTemplate!==void 0&&!o&&s<=1||i<Re(this.template);this.classList.toggle(`may-remove`,a),this.classList.toggle(`may-add`,c)}instanceCount(){return this.querySelectorAll(Dt).length}refreshClassInstances(){if(!(!this.template.class||this.template.hasValue||!this.template.config.editMode))for(let e of this.querySelectorAll(`:scope > .property-instance, :scope > .collapsible > .property-instance`)){let t=e.querySelector(`:scope > .editor`);if(!t||t.dataset.class!==this.template.class.value)continue;let n=G(t),r=N(this.template.class,this.template);n&&!Pt(r,n)&&r.push({value:n,children:[]});let i=Ft(r);if(t.dataset.classInstances===i)continue;let a=this.template.config.theme.createListEditor(this.template.label,n??null,V(this.template)>0,r,this.template).querySelector(`.editor`);a.dataset.classInstances=i,t.replaceWith(a)}}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(e,n){if(this.rdfListItemTemplate){this.rdfListToRDF(e,n);return}for(let r of this.querySelectorAll(`:scope > .property-instance, :scope > .collapsible > .property-instance`)){let i=t.namedNode(r.dataset.predicate??this.template.path);if(r.firstChild instanceof $){let t=r.firstChild.toRDF(e);e.addQuad(n,i,t,this.template.config.valuesGraphId)}else if(this.template.config.editMode)for(let t of r.querySelectorAll(`:scope > .editor`)){let r=G(t);r&&e.addQuad(n,i,r,this.template.config.valuesGraphId)}else{let t=G(r);t&&e.addQuad(n,i,t,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=this.rdfListItemTemplate?void 0:await vt(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(),this.template.nodeShapes.size&&this.dispatchEvent(new Event(`change`,{bubbles:!0,cancelable:!0})),setTimeout(()=>{be(e),e.classList.remove(`fadeIn`)},200))}),e.appendChild(n),e}async bindRdfList(e,t){if(e.termType!==`NamedNode`&&e.termType!==`BlankNode`)return;let n=e,r=new Set,i;for(;!n.equals(S)&&!r.has(n.id);){r.add(n.id);let a=t?null:v,o=this.template.config.store.getQuads(n,b,null,a)[0];if(!o)break;let s=this.template.config.store.getQuads(n,x,null,a)[0];t||(this.template.config.store.delete(o),s&&this.template.config.store.delete(s));let c=await this.addRdfListItem(o.object,t,!1,!0,n,X(e));if(i||=c,!s||s.object.termType!==`NamedNode`&&s.object.termType!==`BlankNode`)break;n=s.object}return i}async addRdfListItem(e,t=!1,n=!1,r=!0,i,a){let o=H(this.rdfListItemTemplate);o.label=this.template.label;let s=await Z(o,e,n,t||this.parent.linked,this.parent);s.dataset.path=this.template.path;let c=Ot(this).map(e=>this.rdfListGroups.get(e)).find(e=>e!==void 0),l=i??this.createRdfListNode(c===void 0);return this.rdfListNodes.set(s,l),this.rdfListGroups.set(s,a??c??X(l)),r&&this.container.insertBefore(s,this.querySelector(J)),s}createRdfListNode(e){return e&&this.template.nodeKind?.value===`http://www.w3.org/ns/shacl#IRI`?t.namedNode(this.template.config.attributes.valuesNamespace+m()):t.blankNode()}rdfListToRDF(e,n){let r=new Map;for(let n of Ot(this)){let i=this.rdfListNodes.get(n)??t.blankNode(),a=this.rdfListGroups.get(n)??X(i),o=n.classList.contains(`linked`),s;if(!o&&n.firstChild instanceof $)s=n.firstChild.toRDF(e);else if(!o&&this.template.config.editMode){let e=n.querySelector(`:scope > .editor`);s=e?G(e):void 0}else o||(s=G(n));if(o||s){let e=r.get(a)??[];e.push({instance:n,node:i,value:s,linked:o}),r.set(a,e)}}let i=new Set([...r.values()].flatMap(e=>e.map(e=>X(e.node)))),a=new Map([...r.values()].flatMap(e=>e.filter(e=>!e.linked&&e.value).map(e=>[X(e.node),X(e.value)]))),o=new Set([...r.values()].filter(e=>e[0]?.linked).map(e=>X(e[0].node)));this.removePreservedRdfList(e,n,i,a,o);for(let i of r.values())e.addQuad(n,t.namedNode(this.template.path),i[0].node,this.template.config.valuesGraphId),!i[0].linked&&(this.template.class&&e.addQuad(i[0].node,y,this.template.class,this.template.config.valuesGraphId),i.forEach(({node:t,value:n},r)=>{e.addQuad(t,b,n,this.template.config.valuesGraphId),e.addQuad(t,x,i[r+1]?.node??S,this.template.config.valuesGraphId)}))}removePreservedRdfList(e,n,r,i,a){if(this.template.config.attributes.preserveUnmappedValues===null)return;let o=this.template.config.originalValues,s=o.getObjects(n,t.namedNode(this.template.path),null),c=new Map,l=[];for(let t of s){if(t.termType!==`NamedNode`&&t.termType!==`BlankNode`||a.has(X(t)))continue;let n=t,r=new Set;for(;!n.equals(S)&&!r.has(n.id);){r.add(n.id),c.set(X(n),n);let t=o.getQuads(n,x,null,null)[0];for(let t of e.getQuads(n,b,null,null)){e.delete(t);let r=i.get(X(n));t.object.termType===`BlankNode`&&X(t.object)!==r&&l.push(t.object)}for(let t of e.getQuads(n,x,null,null))e.delete(t);if(!t||t.object.termType!==`NamedNode`&&t.object.termType!==`BlankNode`)break;n=t.object}}for(let t of c.values())if(t.termType===`BlankNode`&&!r.has(X(t))&&e.countQuads(null,null,t,null)===0)for(let n of e.getQuads(t,null,null,null))e.delete(n),n.object.termType===`BlankNode`&&l.push(n.object);kt(e,l)}};function Ot(e){return Array.from(e.querySelectorAll(`:scope > .property-instance, :scope > .collapsible > .property-instance`))}function X(e){return`${e.termType}:${e.value}`}function kt(e,t){let n=new Set;for(;t.length;){let r=t.pop();if(!(n.has(r.id)||e.countQuads(null,null,r,null)>0)){n.add(r.id);for(let n of e.getQuads(r,null,null,null))e.delete(n),n.object.termType===`BlankNode`&&t.push(n.object)}}}function At(e){if(e.maxCount!==1||e.nodeShapes.size!==1||!jt(e.nodeKind)||!Nt(e.config.store,e.id,[`path`,`minCount`,`maxCount`,`node`,`nodeKind`,`class`]))return;let t=[...e.nodeShapes][0],n=e.config.store.countQuads(t.id,`${h}property`,null,null),r=e.config.store.getObjects(e.id,`${h}node`,null);if(r.length!==1||!r[0].equals(t.id)||n!==2||Object.keys(t.properties).length!==2||t.extendedShapes.size||t.or?.length||t.xone?.length||t.nodeKind||t.targetClass||!Nt(e.config.store,t.id,[`property`]))return;let i=t.properties[b.value],a=t.properties[x.value];if(i?.length!==1||a?.length!==1||i[0].minCount!==1||i[0].maxCount!==1||a[0].minCount!==1||a[0].maxCount!==1||i[0].or?.length||i[0].xone?.length||i[0].hasValue||!Nt(e.config.store,a[0].id,[`path`,`minCount`,`maxCount`,`or`]))return;let o=a[0].or;if(o?.length!==2)return;let s=!1,c=!1;for(let n of o){let r=e.config.store.getQuads(n,null,null,null).filter(e=>e.predicate.value.startsWith(`http://www.w3.org/ns/shacl#`)&&!Mt.has(e.predicate.value));s||=r.length===1&&r[0].predicate.value===`http://www.w3.org/ns/shacl#hasValue`&&r[0].object.equals(S),c||=r.length===1&&r[0].predicate.value===`http://www.w3.org/ns/shacl#node`&&r[0].object.equals(t.id)}return s&&c?i[0]:void 0}function jt(e){return e===void 0||[`http://www.w3.org/ns/shacl#IRI`,`http://www.w3.org/ns/shacl#BlankNode`,`http://www.w3.org/ns/shacl#BlankNodeOrIRI`].includes(e.value)}var Mt=new Set([`${h}name`,`${h}description`,`${h}order`,`${h}group`,`${h}message`,`${h}severity`]);function Nt(e,t,n){let r=new Set(n.map(e=>h+e));return e.getQuads(t,null,null,null).every(e=>!e.predicate.value.startsWith(`http://www.w3.org/ns/shacl#`)||r.has(e.predicate.value)||Mt.has(e.predicate.value))}function Pt(e,t){return e.some(e=>typeof e.value!=`string`&&e.value.equals(t)||Pt(e.children??[],t))}function Ft(e){return JSON.stringify(e.map(e=>[typeof e.value==`string`?e.value:`${e.value.termType}:${e.value.value}`,e.label,Ft(e.children??[])]))}async function Z(e,t,n=!1,r=!1,i){let a;if(e.nodeShapes.size){a=document.createElement(`div`),a.classList.add(`property-instance`),a.setAttribute(`part`,`property-instance`);let n=new Set(i?.ancestorShapeIds??[]);i&&n.add(i.template.id.value);for(let i of e.nodeShapes){let o=new $(i,t,e.nodeKind,e.label,r,n);a.appendChild(o),await o.ready}}else{let n=ft(e.path,e.datatype?.value);a=n?e.config.editMode&&!r?n.createEditor(e,t):n.createViewer(e,t):$e(e,t||null,e.config.editMode&&!r),a.childNodes.length>0&&(a.classList.add(`property-instance`),a.setAttribute(`part`,`property-instance`)),r&&a.classList.add(`linked`)}return e.config.editMode&&(!r||n)?It(a,e.label,e.config.theme.dense,e.config.hierarchyColorsStyleSheet!==void 0,n):e.config.hierarchyColorsStyleSheet!==void 0&&a.appendChild(Lt(!0)),t&&!e.config.editMode&&et(a,t),a.dataset.path=e.path,a}function It(e,t,n,r,i=!1){let a=Lt(r),o=new d;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 Lt(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`,Y);function Rt(e,t){let n=e,r=t.store.getQuads(e,null,null,null),i=O(r,`label`,ne,t.languages);i&&(n=i);let a;if(t.attributes.collapse!==null)a=new f,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=parseInt(O(r,`order`)??``)||0;return{element:a,order:o}}var zt={[`${h}node`]:(e,t)=>{e.extendedShapes.add(new Bt(t,e.config,e))},[`${h}and`]:(e,t)=>{for(let n of e.config.lists[t.value])e.extendedShapes.add(new Bt(n,e.config,e))},[`${h}property`]:(e,t)=>{let n=e.config.getPropertyTemplate(t,e),r=Be(n);if(r){let t=e.properties[r];if(t||(t=[],e.properties[r]=t),n.qualifiedValueShape)t.push(n);else{let i;for(let t=0;t<e.properties[r].length&&!i;t++)e.properties[r][t].qualifiedValueShape||(i=e.properties[r][t]);i?ze(i,n):t.push(n)}}},[`${h}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${h}targetClass`]:(e,t)=>{e.targetClass=t},[`${g}facet`]:(e,t)=>{e.facet=t.value===`true`||t.value===`1`},[`${h}or`]:(e,t)=>{e.or=e.config.lists[t.value]},[`${h}xone`]:(e,t)=>{e.xone=e.config.lists[t.value]},[T.id]:(e,t)=>{e.owlImports.add(t)},[`${ie}title`]:(e,t)=>{let n=t;e.label=F(e.config.languages,e.label,n)},[`${ne}label`]:(e,t)=>{let n=t;e.label=F(e.config.languages,e.label,n)}},Bt=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),Vt(this,this.config.store.getQuads(e,null,null,null))}};function Vt(e,t){for(let n of t)zt[n.predicate.id]?.call(e,e,n.object);return Ht(e),e}function Ht(e){let t=Object.values(e.properties).flat().filter(e=>e.pathAlternatives?.length),n=new Set;for(let r of t){let t={};r.pathAlternatives.every(n=>{let r=e.properties[n];return r?.length!==1||Ut(r[0])?!1:(t[n]=r[0],!0)})&&(r.pathAlternativeBranches=t,r.pathAlternatives.forEach(e=>n.add(e)))}for(let t of n)delete e.properties[t]}function Ut(e){return e.minCount!==void 0||e.maxCount!==void 0||e.qualifiedMinCount!==void 0||e.qualifiedMaxCount!==void 0||e.qualifiedValueShape!==void 0}function Wt(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,Be(n)),i=t.some(e=>e.qualifiedValueShape!==void 0),a=Gt(t),o=i?a:r;if(t.length>1&&o){let e=t[t.length-1];a&&(e.queryShapePathId=t[0].id.value);for(let n=t.length-2;n>=0;n--){let r=t[n],i=a?e.qualifiedValueShape:void 0;delete r.parent.properties[Be(r)],ze(e,r,!0),i&&e.nodeShapes.delete(i)}qt(e)}}}}function Gt(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||!Kt(n.parent,r.parent)||!Kt(n.qualifiedValueShape,r.qualifiedValueShape))return!1}return!0}function Kt(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 qt(e){for(let t of[`xone`,`or`]){let n=e[t];if(!n?.length)continue;let r=n.filter(t=>Jt(t,e));r.length>0&&r.length<n.length&&(r.length===1?(e[t]=void 0,U(e,e.config.store.getQuads(r[0],null,null,null))):e[t]=r)}}function Jt(e,t){let n=t.config.store.getQuads(e,null,null,null);return Yt(n,`http://www.w3.org/ns/shacl#datatype`,t.datatype)&&Yt(n,E.id,t.class)&&Yt(n,`http://www.w3.org/ns/shacl#nodeKind`,t.nodeKind)}function Yt(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 e extends HTMLElement{constructor(n,r,a,o,s,c=new Set,l,u=Xt.create()){super(),this.template=n,this.linked=s??!1,this.ancestorShapeIds=c,this.queryContext=l,this.bindingContext=u,this.setAttribute(`part`,`node`);let d=r;d||=(!a&&n.nodeKind&&(a=n.nodeKind),a===void 0&&n.config.attributes.valuesNamespace||a?.value===`http://www.w3.org/ns/shacl#IRI`?t.namedNode(n.config.attributes.valuesNamespace+m()):t.blankNode(m())),this.nodeId=d;let f=JSON.stringify([n.id,this.nodeId]);if(r&&n.config.renderedNodes.has(f)){o||=`Link`;let e=document.createElement(`label`);e.innerText=o,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`),a=r.termType===`BlankNode`?`_:`+r.value:r.value,s=Array.from(this.template.config.form.querySelectorAll(`shacl-node:not([part~="linked-node"])`)).find(e=>e.nodeId.equals(r)),c=new i;s?.toRDF(c),n.innerText=k([...c.getQuads(r,null,null,null),...this.template.config.store.getQuads(r,null,null,null)],this.template.config.languages)||a,n.classList.add(`ref-link`),n.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${a}']:not([part~='linked-node'])`)?.scrollIntoView()},this.appendChild(n),this.style.flexDirection=`row`,this.ready=Promise.resolve()}else{n.config.renderedNodes.add(f);let t=this.ancestorShapeIds,i=this.template.id.value,a=this.queryContext,c=this.bindingContext;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)}Wt(n),this.ready=(async()=>{let l=new Set(t);l.add(i);for(let e of Object.values(n.properties))for(let t of e)await this.addPropertyInstance(t,r,e.length>1);for(let t of n.extendedShapes){let n=new e(t,r,void 0,void 0,s,l,a,c.forInheritedShape());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),o){let e=document.createElement(`h1`);e.innerText=o,e.setAttribute(`part`,`node-title`),this.prepend(e)}})()}}shouldBindPropertyValue(e){return!this.linked||!this.bindingContext.wasBoundByDescendant(e)}recordBoundPropertyValue(e){this.linked&&this.bindingContext.record(e)}toRDF(e,n,r=``){if(n||=this.nodeId,!this.linked){for(let t of this.querySelectorAll(`:scope > shacl-node, :scope > .shacl-group > shacl-node, :scope > shacl-property, :scope > .shacl-group > shacl-property`))t.toRDF(e,n);this.template.targetClass&&e.addQuad(n,y,this.template.targetClass,this.template.config.valuesGraphId),r&&e.addQuad(n,t.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}']`);if(!t){let n=Rt(e.group,e.config);t=n.element,Qt(this,t,n.order)}r=t}else console.warn(`ignoring unknown group reference`,e.group,`existing groups:`,e.config.groups);let i=new Y(e,this);e.config.queryMode?await i.initializeQuery():await i.bindValues(t,n),(e.config.editMode&&!this.linked||e.config.queryMode||i.instanceCount()>0)&&(Qt(r||this,i,e.order),!e.config.queryMode&&!this.linked&&await i.updateControls())}async tryResolve(e,t,n){let r=!1;if(t){let i=Xe(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(qe(e,this,n))}},Xt=class e{constructor(e){this.boundValues=new Set,this.inheritedValues=new Set(e)}static create(){return new e([])}wasBoundByDescendant(e){return this.inheritedValues.has(this.key(e))}record(e){this.boundValues.add(this.key(e))}forInheritedShape(){return new e([...this.inheritedValues,...this.boundValues])}key(e){return`${e.predicate.id}\0${e.object.id}`}},Zt=new WeakMap;function Qt(e,t,n=0){Zt.set(t,n);let r=Array.from(e.children).find(e=>e!==t&&(Zt.get(e)??0)>n);e.insertBefore(t,r??null)}window.customElements.define(`shacl-node`,$);function $t(e){return e.discrete!==!0&&e.datatype!==void 0&&ge.has(e.datatype)}export{D as $,Pe as A,Oe as B,W as C,Ie as D,H as E,A as F,_e as G,v as H,Ne as I,C as J,h as K,we as L,B as M,R as N,U as O,L as P,fe as Q,N as R,qe as S,V as T,w as U,De as V,ve as W,le as X,y as Y,ce as Z,ct as _,Y as a,nt as b,Tt as c,q as d,_ as et,gt as f,ut as g,dt as h,Wt as i,z as j,Ve as k,ht as l,ft as m,$ as n,Lt as o,pt as p,ee as q,Bt as r,At as s,$t as t,he as tt,mt as u,et as v,Le as w,Qe as x,tt as y,k as z};
|