From 6b72ed9e072d40ffac7896fecefbfa30e09e5d9e Mon Sep 17 00:00:00 2001 From: Gianluca Pepe <37369540+gianluca-pepe@users.noreply.github.com> Date: Tue, 16 May 2023 18:03:18 +0200 Subject: [PATCH] 3.2.5 --- dist/grapholscape.esm.js | 44 ++++++++++++++++++++++++------------ dist/grapholscape.esm.min.js | 16 ++++++------- dist/grapholscape.min.js | 16 ++++++------- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 49 insertions(+), 33 deletions(-) diff --git a/dist/grapholscape.esm.js b/dist/grapholscape.esm.js index cd1e775b..21b0ba9d 100644 --- a/dist/grapholscape.esm.js +++ b/dist/grapholscape.esm.js @@ -5357,7 +5357,7 @@ function getEntityOccurrencesTemplate(occurrences, onNodeNavigation) { return y ` ${Array.from(occurrences).map(([diagram, occurrencesIds]) => { return y ` -
+
${diagram.name} ${occurrencesIds.map(occurrenceId => y ` grapholscape.showDiagram(diagram); - grapholscape.on(LifecycleEvent.DiagramChange, diagram => diagramSelectorComponent.currentDiagramId = diagram.id); + grapholscape.on(LifecycleEvent.DiagramChange, diagram => { + if (diagramSelectorComponent.diagrams.includes(diagram)) + diagramSelectorComponent.currentDiagramId = diagram.id; + }); } /** @@ -7831,12 +7834,14 @@ class GscapeEntityDetails extends DropPanelMixin(BaseMixin(s)) { constructor() { super(...arguments); this.title = 'Entity Details'; + this.showOccurrences = true; this.onNodeNavigation = () => { }; } static get properties() { return { grapholEntity: { type: Object, attribute: false }, occurrences: { type: Object, attribute: false }, + showOccurrences: { type: Boolean }, language: { type: String, attribute: false }, _isPanelClosed: { type: Boolean, attribute: false }, incrementalSection: { type: Object, attribute: false } @@ -7874,7 +7879,7 @@ class GscapeEntityDetails extends DropPanelMixin(BaseMixin(s)) { ${annotationsTemplate(this.grapholEntity.getAnnotations())} - ${!this.incrementalSection && this.occurrences.size > 0 ? this.occurrencesTemplate() : null} + ${this.showOccurrences && this.occurrences.size > 0 ? this.occurrencesTemplate() : null} ${this.grapholEntity.getComments().length > 0 ? y ` @@ -8071,8 +8076,9 @@ function init$6 (entityDetailsComponent, grapholscape) { entityDetailsComponent.language = language; }); grapholscape.on(LifecycleEvent.RendererChange, _ => { - if (entityDetailsComponent.grapholEntity) + if (entityDetailsComponent.grapholEntity && grapholscape.renderState !== RendererStatesEnum.INCREMENTAL) entityDetailsComponent.occurrences = getEntityViewOccurrences(entityDetailsComponent.grapholEntity, grapholscape); + entityDetailsComponent.showOccurrences = grapholscape.renderState !== RendererStatesEnum.INCREMENTAL; }); function setGrapholEntity(entity) { entityDetailsComponent.grapholEntity = entity; @@ -9565,7 +9571,7 @@ class GscapeSettings extends DropPanelMixin(BaseMixin(s)) {
Version: - ${"3.2.4"} + ${"3.2.5"}
@@ -13568,12 +13574,15 @@ class GscapeInstanceExplorer extends ContextualWidgetMixin(BaseMixin(s)) { this.requestUpdate(); } clear() { + var _a, _b; this.instances = new Map(); this.numberOfPagesShown = 1; this.numberOfInstancesReceived = 0; this.areInstancesLoading = false; this.propertiesFilterList = []; + (_a = this.propertyFilterSelect) === null || _a === void 0 ? void 0 : _a.clear(); this.classTypeFilterList = []; + (_b = this.classTypeFilterSelect) === null || _b === void 0 ? void 0 : _b.clear(); this.referenceEntity = undefined; this.referencePropertyEntity = undefined; this.popperRef = undefined; @@ -13836,7 +13845,9 @@ function CommandsWidgetFactory(ic) { ic.grapholscape.on(LifecycleEvent.ContextClick, event => { var _a, _b; const commands = []; - if (event.target === ic.grapholscape.renderer.cy || !event.target.data().iri) + if (event.target === ic.grapholscape.renderer.cy || + !event.target.data().iri || + ic.grapholscape.renderState !== RendererStatesEnum.INCREMENTAL) return; const entity = ic.classInstanceEntities.get(event.target.data().iri) || ic.grapholscape.ontology.getEntity(event.target.data().iri); if (!entity) @@ -15135,7 +15146,7 @@ class IncrementalController { /** @internal */ function initIncremental(grapholscape) { - var _a; + var _a, _b; let incrementalController = new IncrementalController(grapholscape); grapholscape.incremental = incrementalController; // Create and initialize UI components @@ -15163,7 +15174,8 @@ function initIncremental(grapholscape) { entitySelector.closePanel(); }); if (grapholscape.renderState === RendererStatesEnum.INCREMENTAL) { - onIncrementalStartup(grapholscape, incrementalController); + grapholscape.renderer.unselect(); + manageWidgetsOnActivation(grapholscape.widgets, (_b = grapholscape.renderer.cy) === null || _b === void 0 ? void 0 : _b.elements().empty(), incrementalController.endpointController !== undefined); } else { manageWidgetsOnDeactivation(grapholscape.widgets); @@ -15207,13 +15219,13 @@ function initIncremental(grapholscape) { function onIncrementalStartup(grapholscape, incrementalController) { var _a; grapholscape.renderer.unselect(); - if (!incrementalController) { - incrementalController = new IncrementalController(grapholscape); - } + // if (!incrementalController) { + // incrementalController = new IncrementalController(grapholscape) + // } manageWidgetsOnActivation(grapholscape.widgets, (_a = grapholscape.renderer.cy) === null || _a === void 0 ? void 0 : _a.elements().empty(), incrementalController.endpointController !== undefined); - if (grapholscape.renderer.diagram) - setGraphEventHandlers(grapholscape.renderer.diagram, grapholscape.lifecycle, grapholscape.ontology); - incrementalController.setIncrementalEventHandlers(); + // if (grapholscape.renderer.diagram) + // setGraphEventHandlers(grapholscape.renderer.diagram, grapholscape.lifecycle, grapholscape.ontology) + // incrementalController.setIncrementalEventHandlers() } function manageWidgetsOnActivation(widgets, isCanvasEmpty = false, isReasonerAvailable) { const filtersWidget = widgets.get(WidgetEnum.FILTERS); @@ -15221,6 +15233,8 @@ function manageWidgetsOnActivation(widgets, isCanvasEmpty = false, isReasonerAva const entitySelector = widgets.get(WidgetEnum.ENTITY_SELECTOR); const classInstanceDetails = widgets.get(WidgetEnum.CLASS_INSTANCE_DETAILS); const vkgPreferences = widgets.get(WidgetEnum.VKG_PREFERENCES); + const entityDetails = widgets.get(WidgetEnum.ENTITY_DETAILS); + entityDetails.showOccurrences = false; classInstanceDetails === null || classInstanceDetails === void 0 ? void 0 : classInstanceDetails.enable(); diagramSelector === null || diagramSelector === void 0 ? void 0 : diagramSelector.disable(); entitySelector === null || entitySelector === void 0 ? void 0 : entitySelector.show(); @@ -15238,6 +15252,8 @@ function manageWidgetsOnDeactivation(widgets) { const entitySelector = widgets.get(WidgetEnum.ENTITY_SELECTOR); const classInstanceDetails = widgets.get(WidgetEnum.CLASS_INSTANCE_DETAILS); const vkgPreferences = widgets.get(WidgetEnum.VKG_PREFERENCES); + const entityDetails = widgets.get(WidgetEnum.ENTITY_DETAILS); + entityDetails.showOccurrences = true; classInstanceDetails === null || classInstanceDetails === void 0 ? void 0 : classInstanceDetails.disable(); vkgPreferences === null || vkgPreferences === void 0 ? void 0 : vkgPreferences.disable(); diagramSelector === null || diagramSelector === void 0 ? void 0 : diagramSelector.enable(); diff --git a/dist/grapholscape.esm.min.js b/dist/grapholscape.esm.min.js index 8627afa6..ce5e50b5 100644 --- a/dist/grapholscape.esm.min.js +++ b/dist/grapholscape.esm.min.js @@ -1363,7 +1363,7 @@ input { } `],customElements.define("gscape-select",fb);var mb=Object.freeze({__proto__:null,capitalizeFirstChar:cb,grapholEntityToEntityViewData:vb,getEntityViewDataUnfolding:yb});function bb(e,t){var n,i;const r=new Map;return null===(n=e.occurrences.get(Dg.GRAPHOL))||void 0===n||n.forEach((e=>{o(e)})),t.renderState&&t.renderState!==Dg.GRAPHOL&&(null===(i=e.occurrences.get(t.renderState))||void 0===i||i.forEach((e=>{o(e)}))),r;function o(e){var n,i,o;if(!t.renderState)return;const a=t.ontology.getDiagram(e.diagramId)||t.renderer.diagram,s=null===(i=null===(n=null==a?void 0:a.representations.get(t.renderState))||void 0===n?void 0:n.cy)||void 0===i?void 0:i.$id(e.elementId);if(a&&s&&!s.empty()){const t={realId:e.elementId,originalId:s.data().originalId},n=Array.from(r).find((([e,t])=>e.id===a.id));let i;n?i=n[0]:(i={id:a.id,name:a.name},r.set(i,[])),null===(o=r.get(i))||void 0===o||o.push(t)}}}function xb(e,t){function n(e){var n;const i=e.target,r=null===(n=i.parentElement)||void 0===n?void 0:n.getAttribute("diagram-id"),o=i.getAttribute("real-id");r&&o&&t({diagramId:parseInt(r),elementId:o})}return Nv` ${Array.from(e).map((([e,t])=>Nv` -
+
${e.name} ${t.map((e=>Nv` - `}diagramSelectionHandler(e){const t=parseInt(e.target.getAttribute("diagram-id")||"");this.onDiagramSelection(t)}get currentDiagram(){return this.diagrams.find((e=>e.id===this.currentDiagramId))}}function Yb(e){const t=new Gb;!function(e,t){e.diagrams=t.ontology.diagrams,(t.diagramId||0===t.diagramId)&&(e.currentDiagramId=t.diagramId),e.onDiagramSelection=e=>t.showDiagram(e),t.on(_f.DiagramChange,(t=>e.currentDiagramId=t.id))}(t,e),e.widgets.set(Vg.DIAGRAM_SELECTOR,t)}function Qb(e,t){return Nv` + `}diagramSelectionHandler(e){const t=parseInt(e.target.getAttribute("diagram-id")||"");this.onDiagramSelection(t)}get currentDiagram(){return this.diagrams.find((e=>e.id===this.currentDiagramId))}}function Yb(e){const t=new Gb;!function(e,t){e.diagrams=t.ontology.diagrams,(t.diagramId||0===t.diagramId)&&(e.currentDiagramId=t.diagramId),e.onDiagramSelection=e=>t.showDiagram(e),t.on(_f.DiagramChange,(t=>{e.diagrams.includes(t)&&(e.currentDiagramId=t.id)}))}(t,e),e.widgets.set(Vg.DIAGRAM_SELECTOR,t)}function Qb(e,t){return Nv`
{}}static get properties(){return{grapholEntity:{type:Object,attribute:!1},occurrences:{type:Object,attribute:!1},language:{type:String,attribute:!1},_isPanelClosed:{type:Boolean,attribute:!1},incrementalSection:{type:Object,attribute:!1}}}render(){if(this.grapholEntity)return Nv` +`;class Kb extends(lm(sm(Kv))){constructor(){super(...arguments),this.title="Entity Details",this.showOccurrences=!0,this.onNodeNavigation=()=>{}}static get properties(){return{grapholEntity:{type:Object,attribute:!1},occurrences:{type:Object,attribute:!1},showOccurrences:{type:Boolean},language:{type:String,attribute:!1},_isPanelClosed:{type:Boolean,attribute:!1},incrementalSection:{type:Object,attribute:!1}}}render(){if(this.grapholEntity)return Nv`
${this.grapholEntity.is(Pg.CLASS_INSTANCE)?Qb(this.entityForTemplate):Qb(this.entityForTemplate,this.onWikiLinkClick)} @@ -1700,7 +1700,7 @@ input { ${Wb(this.grapholEntity.getAnnotations())} - ${!this.incrementalSection&&this.occurrences.size>0?this.occurrencesTemplate():null} + ${this.showOccurrences&&this.occurrences.size>0?this.occurrencesTemplate():null} ${this.grapholEntity.getComments().length>0?Nv`
@@ -1746,7 +1746,7 @@ input { ${xb(this.occurrences,this.onNodeNavigation)}
- `}blur(){}setGrapholEntity(e){}languageSelectionHandler(e){this.language=e.target.value}get entityForTemplate(){return{name:this.grapholEntity.iri.remainder,typeOrVersion:this.grapholEntity.type.toString(),iri:this.grapholEntity.iri.fullIri}}get commentsLanguages(){return Array.from(new Set(this.grapholEntity.getComments().map((e=>e.language))))}updated(){var e;const t=null===(e=this.grapholEntity)||void 0===e?void 0:e.getComments();if(!t||0===t.length)return;0===this.grapholEntity.getComments(this.language).length&&(this.language=t[0].language)}}function Jb(e){const t=new Kb;!function(e,t){function n(n){e.grapholEntity=n,e.occurrences=bb(n,t),e.language=t.language,e.show(),t.lifecycle.entityWikiLinkClick.length>0&&!e.onWikiLinkClick&&(e.onWikiLinkClick=e=>{t.lifecycle.trigger(_f.EntityWikiLinkClick,e)})}e.onNodeNavigation=e=>{t.centerOnElement(e.elementId,e.diagramId,1.2),t.selectElement(e.elementId)},e.language=t.language,e.setGrapholEntity=n,t.on(_f.EntitySelection,n),t.on(_f.NodeSelection,(t=>{t.isEntity()||e.hide()})),t.on(_f.EdgeSelection,(t=>{t.isEntity()||e.hide()})),t.on(_f.LanguageChange,(t=>{e.language=t})),t.on(_f.RendererChange,(n=>{e.grapholEntity&&(e.occurrences=bb(e.grapholEntity,t))}))}(t,e),e.widgets.set(Vg.ENTITY_DETAILS,t)}Kb.styles=[rm,Xb,Zb,om,nv` + `}blur(){}setGrapholEntity(e){}languageSelectionHandler(e){this.language=e.target.value}get entityForTemplate(){return{name:this.grapholEntity.iri.remainder,typeOrVersion:this.grapholEntity.type.toString(),iri:this.grapholEntity.iri.fullIri}}get commentsLanguages(){return Array.from(new Set(this.grapholEntity.getComments().map((e=>e.language))))}updated(){var e;const t=null===(e=this.grapholEntity)||void 0===e?void 0:e.getComments();if(!t||0===t.length)return;0===this.grapholEntity.getComments(this.language).length&&(this.language=t[0].language)}}function Jb(e){const t=new Kb;!function(e,t){function n(n){e.grapholEntity=n,e.occurrences=bb(n,t),e.language=t.language,e.show(),t.lifecycle.entityWikiLinkClick.length>0&&!e.onWikiLinkClick&&(e.onWikiLinkClick=e=>{t.lifecycle.trigger(_f.EntityWikiLinkClick,e)})}e.onNodeNavigation=e=>{t.centerOnElement(e.elementId,e.diagramId,1.2),t.selectElement(e.elementId)},e.language=t.language,e.setGrapholEntity=n,t.on(_f.EntitySelection,n),t.on(_f.NodeSelection,(t=>{t.isEntity()||e.hide()})),t.on(_f.EdgeSelection,(t=>{t.isEntity()||e.hide()})),t.on(_f.LanguageChange,(t=>{e.language=t})),t.on(_f.RendererChange,(n=>{e.grapholEntity&&t.renderState!==Dg.INCREMENTAL&&(e.occurrences=bb(e.grapholEntity,t)),e.showOccurrences=t.renderState!==Dg.INCREMENTAL}))}(t,e),e.widgets.set(Vg.ENTITY_DETAILS,t)}Kb.styles=[rm,Xb,Zb,om,nv` :host { position: absolute; top:10px; @@ -2267,7 +2267,7 @@ input {
Version: - ${"3.2.4"} + ${"3.2.5"}
@@ -2727,7 +2727,7 @@ gscape-entity-list-item:hover > .hover-btn { `:this.numberOfPagesShown>1?Nv`No more data`:null}
- `}handleFilter(e){var t,n,i,r;const o=this.instancesSearchInput;if(!o)return;const a=new CustomEvent("instances-filter",{bubbles:!0,composed:!0,detail:{filterText:o.value.length>0?o.value:void 0,filterByProperty:void 0,filterByType:void 0}});if((null===(t=this.propertyFilterSelect)||void 0===t?void 0:t.selectedOptionId)&&"id"!==this.propertyFilterSelect.selectedOptionId&&"label"!==this.propertyFilterSelect.selectedOptionId&&a.detail.filterText){a.detail.filterByProperty=this.propertyFilterSelect.selectedOptionId;const e=this.propertiesFilterList.find((e=>{var t;return(null===(t=this.propertyFilterSelect)||void 0===t?void 0:t.selectedOptionId)&&e.entityViewData.value.iri.equals(this.propertyFilterSelect.selectedOptionId)}));e&&(a.detail.propertyType=e.entityViewData.value.type,e.entityViewData.value.type===Pg.OBJECT_PROPERTY&&(a.detail.direct=e.direct))}1===(null===(n=this.classTypeFilterList)||void 0===n?void 0:n.length)?a.detail.filterByType=this.classTypeFilterList[0].entityViewData.value.iri.fullIri:this.classTypeFilterSelect&&(a.detail.filterByType=this.classTypeFilterSelect.selectedOptionId),void 0!==this.shouldAskForLabels&&(a.detail.shouldAskForLabels=this.shouldAskForLabels&&"id"!==(null===(i=this.propertyFilterSelect)||void 0===i?void 0:i.selectedOptionId)),"id"===(null===(r=this.propertyFilterSelect)||void 0===r?void 0:r.selectedOptionId)&&(a.detail.shouldAskForLabels=!1),this.lastSearchedText=a.detail.filterText||"",this.numberOfPagesShown=1,this.dispatchEvent(a)}handleInputKeypress(e){const t=e.target;"Escape"===e.key&&(t.blur(),t.value=""),clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((()=>{this.handleFilter()}),500)}handleFilterChange(){var e,t;null===(t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#instances-search"))||void 0===t||t.focus()}handleClassTypeFilterChange(e){var t;(null===(t=this.classTypeFilterSelect)||void 0===t?void 0:t.selectedOptionId)||(this.propertiesFilterList=[]),this.handleFilter(e)}handleInsertInGraph(t){var n,i,r,o,a,s,l,c;return e(this,void 0,void 0,(function*(){const e=null===(n=t.currentTarget.parentElement)||void 0===n?void 0:n.parentElement;if(e){const t=this.instances.get(e.iri);if(t){let e,n;if((null===(i=this.referenceEntity)||void 0===i?void 0:i.value.type)===Pg.CLASS)e=null===(r=this.referenceEntity)||void 0===r?void 0:r.value.iri.fullIri;else{if((null===(o=this.referenceEntity)||void 0===o?void 0:o.value.type)!==Pg.CLASS_INSTANCE)return;if(1===(null===(a=this.classTypeFilterList)||void 0===a?void 0:a.length))e=this.classTypeFilterList[0].entityViewData.value.iri.fullIri;else if(null===(s=this.classTypeFilterSelect)||void 0===s?void 0:s.selectedOptionId)e=this.classTypeFilterSelect.selectedOptionId;else{if(!this.classTypeFilterList)return;e=this.classTypeFilterList.map((e=>e.entityViewData.value.iri.fullIri))}}(null===(l=this.propertyFilterSelect)||void 0===l?void 0:l.selectedOptionId)&&"id"!==this.propertyFilterSelect.selectedOptionId&&"label"!==this.propertyFilterSelect.selectedOptionId&&(null===(c=this.instancesSearchInput)||void 0===c?void 0:c.value)&&(n=this.propertyFilterSelect.selectedOptionId),this.requestUpdate(),yield this.updateComplete,this.dispatchEvent(new CustomEvent("instanceselection",{bubbles:!0,composed:!0,detail:{parentClassIris:e,instance:t,filterByProperty:n}}))}}}))}handleShowMore(e){this.dispatchEvent(new CustomEvent("showmoreinstances",{bubbles:!0,composed:!0})),this.numberOfPagesShown+=1}addInstances(e){this.numberOfInstancesReceived+=e.length,e.forEach((e=>{const t=e.connectedInstance?`${e.iri}-${e.connectedInstance.iri}`:e.iri;this.instances.has(t)||this.instances.set(t,e)})),this.requestUpdate()}clear(){this.instances=new Map,this.numberOfPagesShown=1,this.numberOfInstancesReceived=0,this.areInstancesLoading=!1,this.propertiesFilterList=[],this.classTypeFilterList=[],this.referenceEntity=void 0,this.referencePropertyEntity=void 0,this.popperRef=void 0,this.shouldAskForLabels=void 0,this.numberResultsAvailable=0,this.lastSearchedText="",this.instancesSearchInput&&(this.instancesSearchInput.value="")}updated(){this.popperRef&&this.attachTo(this.popperRef)}attachTo(e){this.popperRef=e,super.attachTo(e)}getHighlightInSearchMatch(e){if(this.lastSearchedText.length>0&&" "!==this.lastSearchedText){const t=e.toLowerCase().search(this.lastSearchedText.toLowerCase());if(t>=0){const n=t+this.lastSearchedText.length-1;return{preString:e.substring(0,t),highlightString:e.substring(t,n+1),postString:e.substring(n+1,e.length)}}}return{preString:e,highlightString:void 0,postString:void 0}}get canShowMore(){return this.numberResultsAvailable?this.numberOfInstancesReceived0}get propertyFilterSelect(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#property-filter-select")}get classTypeFilterSelect(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#classtype-filter-select")}get instancesSearchInput(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#instances-search")}hide(){this.style.display="none"}}function sw(e,t){return{content:(e?"Hide":"Show")+" Super Hierarchies",icon:$y,select:t}}function lw(e,t){return{content:(e?"Hide":"Show")+" Super Classes",icon:$y,select:t}}function cw(e,t){return{content:(e?"Hide":"Show")+" Sub Hierarchies",icon:By,select:t}}function uw(e,t){return{content:(e?"Hide":"Show")+" Sub Classes",icon:By,select:t}}function dw(e,t){return{content:(e?"Hide":"Show")+" Equivalent Classes",icon:jy,select:t}}function hw(t){const n=new Zm;t.grapholscape.on(_f.ContextClick,(i=>{var r,o;const a=[];if(i.target===t.grapholscape.renderer.cy||!i.target.data().iri)return;const s=t.classInstanceEntities.get(i.target.data().iri)||t.grapholscape.ontology.getEntity(i.target.data().iri);if(!s)return;var l;s.is(Pg.CLASS_INSTANCE)&&!s.isRDFTypeUnknown&&(a.push((l=()=>e(this,void 0,void 0,(function*(){var e;const n=t.grapholscape.ontology.getEntitiesByType(Pg.CLASS).map((e=>e.iri.fullIri)),i=yield null===(e=t.endpointController)||void 0===e?void 0:e.instanceCheck(s.iri.fullIri,n);null==i||i.forEach((e=>{const n=t.grapholscape.ontology.getEntity(e);n&&s.addParentClass(n.iri)})),pw(t,s)})),{content:"Compute and Show Parent Classes",icon:ey,select:l})),a.push(function(e){return{content:"Show Current Parent Classes",icon:ey,select:e}}((()=>pw(t,s)))));const c=s.iri.fullIri;if(s.is(Pg.CLASS)){const e=t.grapholscape.ontology.hierarchiesBySubclassMap.get(c),n=t.grapholscape.ontology.hierarchiesBySuperclassMap.get(c);if(e&&e.length>0){const n=t.areHierarchiesVisible(e);a.push(sw(n,(()=>{n?t.hideSuperHierarchiesOf(c):t.showSuperHierarchiesOf(c)})))}if(n&&n.length>0){const e=t.areHierarchiesVisible(n);a.push(cw(e,(()=>{e?t.hideSubHierarchiesOf(c):t.showSubHierarchiesOf(c)})))}const i=t.neighbourhoodFinder.getSubclassesIris(c),o=t.neighbourhoodFinder.getSuperclassesIris(c),l=t.neighbourhoodFinder.getEquivalentClassesIris(c);if(i.length>0){const e=t.areAllConnectedClassesVisibleForClass(c,i,"sub");a.push(uw(e,(()=>{e?i.forEach((e=>t.removeEntity(e,[c]))):t.showSubClassesOf(c,i)})))}if(o.length>0){const e=t.areAllConnectedClassesVisibleForClass(c,o,"super");a.push(lw(e,(()=>{e?o.forEach((e=>t.removeEntity(e,[c]))):t.showSuperClassesOf(c,o)})))}if(l.length>0){const e=t.areAllConnectedClassesVisibleForClass(c,l,"equivalent");a.push(dw(e,(()=>{e?l.forEach((e=>t.removeEntity(e,[c]))):t.showEquivalentClassesOf(c,l)})))}(null===(r=t.endpointController)||void 0===r?void 0:r.isReasonerAvailable())&&t.countersEnabled&&a.push({icon:Gy,content:"Count Instances",select:()=>{var e;null===(e=t.endpointController)||void 0===e||e.requestCountForClass(s.iri.fullIri)}})}!s.is(Pg.CLASS_INSTANCE)&&(null===(o=t.endpointController)||void 0===o?void 0:o.isReasonerAvailable())&&a.push({content:"Data Lineage",icon:Wy,select:()=>t.onShowDataLineage(s.iri.fullIri)}),a.push(function(e){return{content:"Remove",icon:zy,select:e}}((()=>{s.is(Pg.OBJECT_PROPERTY)?(t.diagram.removeElement(i.target.id()),s.removeOccurrence(i.target.id(),t.diagram.id,Dg.INCREMENTAL),t.lifecycle.trigger(Zx.DiagramUpdated)):t.removeEntity(s.iri.fullIri)})));try{if(i.target.isEdge()&&t.grapholscape.uiContainer)n.attachToPosition(i.renderedPosition,t.grapholscape.uiContainer,a);else{const e=i.target.popperRef();e&&a.length>0&&n.attachTo(e,a)}}catch(e){console.error(e)}}))}function pw(e,t){const n=t.parentClassIris;e.performActionWithBlockedGraph((()=>{null==n||n.forEach((n=>{e.addEntity(n.fullIri,!1),e.addEdge(t.iri.fullIri,n.fullIri,Pg.INSTANCE_OF)}))})),1===(null==n?void 0:n.length)&&setTimeout((()=>{e.grapholscape.centerOnElement(n[0].fullIri)}),250)}function gw(e,t){if(e.referenceEntity){const n=t.grapholscape.renderer.cy;if(n){const i=n.$id(e.referenceEntity.value.iri.fullIri);i&&(e.attachTo(i.popperRef()),e.show(),i.data().pinned||(i.scratch("should-unpin",!0),t.pinNode(i)))}}}function fw(t){const n=new mx(ty);n.title="Search instances";const i=new mx(ry);i.title="Navigate through object properties";const r=new Map;r.set(Pg.CLASS,[i]),r.set(Pg.CLASS_INSTANCE,[i]),n.onclick=n=>function(t,n){var i,r,o,a,s,l;return e(this,void 0,void 0,(function*(){const c=t.currentTarget,u=n.grapholscape.widgets.get(Vg.INSTANCES_EXPLORER);if(u&&c.node&&c.node.data().iri){const t=n.grapholscape.ontology.getEntity(c.node.data().iri);if(t&&t.type===Pg.CLASS&&(!u.referenceEntity||!u.referenceEntity.value.iri.equals(t.iri)||0===u.numberOfInstancesReceived)){u.clear(),u.areInstancesLoading=!0,u.referenceEntity=vb(t,n.grapholscape);const c=null===(r=null===(i=n.endpointController)||void 0===i?void 0:i.highlightsManager)||void 0===r?void 0:r.hasUnfoldings.bind(null===(o=n.endpointController)||void 0===o?void 0:o.highlightsManager),d=yield n.getDataPropertiesByClasses([t.iri.fullIri]),h=yield n.getObjectPropertiesByClasses([t.iri.fullIri]),p=Array.from(h).map((([e,t])=>{let i=yb(e,n.grapholscape,c);return{entityViewData:i.entityViewData,loading:i.loading,hasUnfolding:i.hasUnfolding,connectedClasses:[],direct:t.direct}}));u.propertiesFilterList=d.map((e=>yb(e,n.grapholscape,c))).concat(p).sort(((e,t)=>e.entityViewData.displayedName.localeCompare(t.entityViewData.displayedName))),u.requestId=yield null===(a=n.endpointController)||void 0===a?void 0:a.requestInstancesForClass(t.iri.fullIri),u.requestId&&(null===(l=null===(s=n.endpointController)||void 0===s?void 0:s.shouldQueryUseLabels(u.requestId))||void 0===l||l.then((i=>e(this,void 0,void 0,(function*(){var e;i||(u.shouldAskForLabels=i,u.areInstancesLoading=!0,u.requestId=yield null===(e=n.endpointController)||void 0===e?void 0:e.requestInstancesForClass(t.iri.fullIri,i))})))))}c.node&&gw(u,n)}}))}(n,t),i.onclick=n=>function(t,n){var i,r,o;return e(this,void 0,void 0,(function*(){const e=t.currentTarget,a=n.grapholscape.widgets.get(Vg.NAVIGATION_MENU);if(a&&e.node&&e.node.data().iri){let t,s=new Map;if(e.node.data().type===Pg.CLASS){if(t=n.grapholscape.ontology.getEntity(e.node.data().iri),!t)return;a.referenceEntity=vb(t,n.grapholscape),a.canShowObjectPropertiesRanges=!0,s=yield n.getObjectPropertiesByClasses([e.node.data().iri])}else if(e.node.data().type===Pg.CLASS_INSTANCE){if(t=n.classInstanceEntities.get(e.node.data().iri),!t)return;a.referenceEntity=vb(t,n.grapholscape),a.canShowObjectPropertiesRanges=!1;const i=t.parentClassIris.map((e=>e.fullIri));s=yield n.getObjectPropertiesByClasses(i)}const l=null===(r=null===(i=n.endpointController)||void 0===i?void 0:i.highlightsManager)||void 0===r?void 0:r.hasUnfoldings.bind(null===(o=n.endpointController)||void 0===o?void 0:o.highlightsManager);a.objectProperties=Array.from(s).map((e=>{const t=yb(e[0],n.grapholscape,l);return t.connectedClasses=e[1].list.map((e=>yb(e,n.grapholscape,l))),t.direct=e[1].direct,t})),e.node&&gw(a,n)}}))}(n,t),t.grapholscape.renderState===Dg.INCREMENTAL&&t.diagram.representation&&vw(t.diagram.representation.cy,r),t.grapholscape.on(_f.RendererChange,(e=>{e===Dg.INCREMENTAL&&t.diagram.representation&&vw(t.diagram.representation.cy,r)})),t.on(Zx.Reset,(()=>{t.grapholscape.renderState===Dg.INCREMENTAL&&t.diagram.representation&&(vw(t.diagram.representation.cy,r),t.grapholscape.container.querySelectorAll("[data-tippy-root]").forEach((e=>e.remove())))})),t.on(Zx.EndpointChange,(()=>{var e,t;(null===(e=r.get(Pg.CLASS))||void 0===e?void 0:e.includes(n))||null===(t=r.get(Pg.CLASS))||void 0===t||t.push(n)})),t.on(Zx.InstanceCheckingStarted,(e=>{var n;const i=null===(n=t.diagram.representation)||void 0===n?void 0:n.cy.$id(e);i&&(i.addClass("unknown-parent-class"),bw(i,nb(),"loading-badge"))})),t.on(Zx.InstanceCheckingFinished,(e=>{var n;const i=null===(n=t.diagram.representation)||void 0===n?void 0:n.cy.$id(e);i&&i.scratch("loading-badge")&&mw(i,"loading-badge")})),t.on(Zx.CountStarted,(e=>{var n;const i=null===(n=t.diagram.representation)||void 0===n?void 0:n.cy.$id(e);i&&!i.empty()&&(mw(i,"instance-count"),bw(i,nb(),"instance-count","bottom"))})),t.on(Zx.NewCountResult,((e,n)=>{var i;const r=null===(i=t.grapholscape.renderer.cy)||void 0===i?void 0:i.$id(e);if(r&&r.nonempty()&&r.scratch("instance-count")){const i=r.scratch("instance-count");i.contentType="template",n=n||t.counts.get(e),i.content=void 0!==(null==n?void 0:n.value)?(new Intl.NumberFormat).format(n.value):"n/a",i.highlighted=!(null==n?void 0:n.materialized),(null==n?void 0:n.date)?i.title=`Date: ${n.date}`:i.title="Fresh Value";const o=r.scratch("update-instance-count-position");o&&o(),setTimeout((()=>i.hide()),1e3),r.on("mouseover",(()=>{t.countersEnabled&&i.tippyWidget.show()})),r.on("mouseout",(()=>i.tippyWidget.hide())),n&&!n.materialized&&t.counts.set(e,n)}}))}function vw(e,t){e.scratch("_gscape-graph-incremental-handlers-set")||(e.on("mouseover","node",(e=>{var n;const i=e.target,r=i.data().type;i.hasClass("unknown-parent-class")||r!==Pg.CLASS&&r!==Pg.CLASS_INSTANCE||null===(n=t.get(r))||void 0===n||n.forEach(((e,n)=>{e.cxtWidgetProps.offset=e=>yw(e,n,t.get(r).length),e.node=i,i.scratch(`place-node-button-${n}`,(()=>e.attachTo(i.popperRef()))),i.on("position",i.scratch(`place-node-button-${n}`)),e.attachTo(i.popperRef())}))})),e.on("mouseout","node",(e=>{const n=e.target;t.forEach(((e,t)=>e.forEach(((e,t)=>{e.hide();const i=n.scratch(`place-node-button-${t}`);i&&(n.removeListener("position",void 0,i),n.removeScratch(`place-node-button-${t}`))}))))})),e.scratch("_gscape-graph-incremental-handlers-set",!0))}function yw(e,t=0,n=1){const i=e.popper.height+4;return[-i/2-t*i+i*(n/2),-e.popper.width/2]}function mw(e,t){e.scratch(t)&&(e.scratch(t).tippyWidget.destroy(),e.removeClass("unknown-parent-class"),e.removeScratch(t),e.removeAllListeners(),e.cy().removeListener("pan",e.scratch(`update-${t}-position`)),e.removeScratch(`update-${t}-position`))}function bw(e,t,n,i="bottom",r=!1){const o=r?new mx(t):new mx(t,"template");return o.cxtWidgetProps.placement=i,e.scratch(n,o),e.scratch(`update-${n}-position`,(()=>{o.attachToSilently(e.popperRef())})),o.cxtWidgetProps.offset=e=>yw(e),o.attachTo(e.popperRef()),e.on("position",e.scratch(`update-${n}-position`)),e.cy().on("pan",e.scratch(`update-${n}-position`)),e.scratch(`update-${n}-position`),e.on("remove",(e=>mw(e.target,n))),o}aw.properties={areInstancesLoading:{type:Boolean},instances:{type:Object},referenceEntity:{type:Object},searchFilterList:{type:Object},referencePropertyEntity:{type:Object},classTypeFilterList:{type:Object},canShowMore:{type:Boolean},lastSearchedText:{type:String,state:!0}},aw.styles=[rm,ow,ob,ib,nv` + `}handleFilter(e){var t,n,i,r;const o=this.instancesSearchInput;if(!o)return;const a=new CustomEvent("instances-filter",{bubbles:!0,composed:!0,detail:{filterText:o.value.length>0?o.value:void 0,filterByProperty:void 0,filterByType:void 0}});if((null===(t=this.propertyFilterSelect)||void 0===t?void 0:t.selectedOptionId)&&"id"!==this.propertyFilterSelect.selectedOptionId&&"label"!==this.propertyFilterSelect.selectedOptionId&&a.detail.filterText){a.detail.filterByProperty=this.propertyFilterSelect.selectedOptionId;const e=this.propertiesFilterList.find((e=>{var t;return(null===(t=this.propertyFilterSelect)||void 0===t?void 0:t.selectedOptionId)&&e.entityViewData.value.iri.equals(this.propertyFilterSelect.selectedOptionId)}));e&&(a.detail.propertyType=e.entityViewData.value.type,e.entityViewData.value.type===Pg.OBJECT_PROPERTY&&(a.detail.direct=e.direct))}1===(null===(n=this.classTypeFilterList)||void 0===n?void 0:n.length)?a.detail.filterByType=this.classTypeFilterList[0].entityViewData.value.iri.fullIri:this.classTypeFilterSelect&&(a.detail.filterByType=this.classTypeFilterSelect.selectedOptionId),void 0!==this.shouldAskForLabels&&(a.detail.shouldAskForLabels=this.shouldAskForLabels&&"id"!==(null===(i=this.propertyFilterSelect)||void 0===i?void 0:i.selectedOptionId)),"id"===(null===(r=this.propertyFilterSelect)||void 0===r?void 0:r.selectedOptionId)&&(a.detail.shouldAskForLabels=!1),this.lastSearchedText=a.detail.filterText||"",this.numberOfPagesShown=1,this.dispatchEvent(a)}handleInputKeypress(e){const t=e.target;"Escape"===e.key&&(t.blur(),t.value=""),clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((()=>{this.handleFilter()}),500)}handleFilterChange(){var e,t;null===(t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#instances-search"))||void 0===t||t.focus()}handleClassTypeFilterChange(e){var t;(null===(t=this.classTypeFilterSelect)||void 0===t?void 0:t.selectedOptionId)||(this.propertiesFilterList=[]),this.handleFilter(e)}handleInsertInGraph(t){var n,i,r,o,a,s,l,c;return e(this,void 0,void 0,(function*(){const e=null===(n=t.currentTarget.parentElement)||void 0===n?void 0:n.parentElement;if(e){const t=this.instances.get(e.iri);if(t){let e,n;if((null===(i=this.referenceEntity)||void 0===i?void 0:i.value.type)===Pg.CLASS)e=null===(r=this.referenceEntity)||void 0===r?void 0:r.value.iri.fullIri;else{if((null===(o=this.referenceEntity)||void 0===o?void 0:o.value.type)!==Pg.CLASS_INSTANCE)return;if(1===(null===(a=this.classTypeFilterList)||void 0===a?void 0:a.length))e=this.classTypeFilterList[0].entityViewData.value.iri.fullIri;else if(null===(s=this.classTypeFilterSelect)||void 0===s?void 0:s.selectedOptionId)e=this.classTypeFilterSelect.selectedOptionId;else{if(!this.classTypeFilterList)return;e=this.classTypeFilterList.map((e=>e.entityViewData.value.iri.fullIri))}}(null===(l=this.propertyFilterSelect)||void 0===l?void 0:l.selectedOptionId)&&"id"!==this.propertyFilterSelect.selectedOptionId&&"label"!==this.propertyFilterSelect.selectedOptionId&&(null===(c=this.instancesSearchInput)||void 0===c?void 0:c.value)&&(n=this.propertyFilterSelect.selectedOptionId),this.requestUpdate(),yield this.updateComplete,this.dispatchEvent(new CustomEvent("instanceselection",{bubbles:!0,composed:!0,detail:{parentClassIris:e,instance:t,filterByProperty:n}}))}}}))}handleShowMore(e){this.dispatchEvent(new CustomEvent("showmoreinstances",{bubbles:!0,composed:!0})),this.numberOfPagesShown+=1}addInstances(e){this.numberOfInstancesReceived+=e.length,e.forEach((e=>{const t=e.connectedInstance?`${e.iri}-${e.connectedInstance.iri}`:e.iri;this.instances.has(t)||this.instances.set(t,e)})),this.requestUpdate()}clear(){var e,t;this.instances=new Map,this.numberOfPagesShown=1,this.numberOfInstancesReceived=0,this.areInstancesLoading=!1,this.propertiesFilterList=[],null===(e=this.propertyFilterSelect)||void 0===e||e.clear(),this.classTypeFilterList=[],null===(t=this.classTypeFilterSelect)||void 0===t||t.clear(),this.referenceEntity=void 0,this.referencePropertyEntity=void 0,this.popperRef=void 0,this.shouldAskForLabels=void 0,this.numberResultsAvailable=0,this.lastSearchedText="",this.instancesSearchInput&&(this.instancesSearchInput.value="")}updated(){this.popperRef&&this.attachTo(this.popperRef)}attachTo(e){this.popperRef=e,super.attachTo(e)}getHighlightInSearchMatch(e){if(this.lastSearchedText.length>0&&" "!==this.lastSearchedText){const t=e.toLowerCase().search(this.lastSearchedText.toLowerCase());if(t>=0){const n=t+this.lastSearchedText.length-1;return{preString:e.substring(0,t),highlightString:e.substring(t,n+1),postString:e.substring(n+1,e.length)}}}return{preString:e,highlightString:void 0,postString:void 0}}get canShowMore(){return this.numberResultsAvailable?this.numberOfInstancesReceived0}get propertyFilterSelect(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#property-filter-select")}get classTypeFilterSelect(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#classtype-filter-select")}get instancesSearchInput(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#instances-search")}hide(){this.style.display="none"}}function sw(e,t){return{content:(e?"Hide":"Show")+" Super Hierarchies",icon:$y,select:t}}function lw(e,t){return{content:(e?"Hide":"Show")+" Super Classes",icon:$y,select:t}}function cw(e,t){return{content:(e?"Hide":"Show")+" Sub Hierarchies",icon:By,select:t}}function uw(e,t){return{content:(e?"Hide":"Show")+" Sub Classes",icon:By,select:t}}function dw(e,t){return{content:(e?"Hide":"Show")+" Equivalent Classes",icon:jy,select:t}}function hw(t){const n=new Zm;t.grapholscape.on(_f.ContextClick,(i=>{var r,o;const a=[];if(i.target===t.grapholscape.renderer.cy||!i.target.data().iri||t.grapholscape.renderState!==Dg.INCREMENTAL)return;const s=t.classInstanceEntities.get(i.target.data().iri)||t.grapholscape.ontology.getEntity(i.target.data().iri);if(!s)return;var l;s.is(Pg.CLASS_INSTANCE)&&!s.isRDFTypeUnknown&&(a.push((l=()=>e(this,void 0,void 0,(function*(){var e;const n=t.grapholscape.ontology.getEntitiesByType(Pg.CLASS).map((e=>e.iri.fullIri)),i=yield null===(e=t.endpointController)||void 0===e?void 0:e.instanceCheck(s.iri.fullIri,n);null==i||i.forEach((e=>{const n=t.grapholscape.ontology.getEntity(e);n&&s.addParentClass(n.iri)})),pw(t,s)})),{content:"Compute and Show Parent Classes",icon:ey,select:l})),a.push(function(e){return{content:"Show Current Parent Classes",icon:ey,select:e}}((()=>pw(t,s)))));const c=s.iri.fullIri;if(s.is(Pg.CLASS)){const e=t.grapholscape.ontology.hierarchiesBySubclassMap.get(c),n=t.grapholscape.ontology.hierarchiesBySuperclassMap.get(c);if(e&&e.length>0){const n=t.areHierarchiesVisible(e);a.push(sw(n,(()=>{n?t.hideSuperHierarchiesOf(c):t.showSuperHierarchiesOf(c)})))}if(n&&n.length>0){const e=t.areHierarchiesVisible(n);a.push(cw(e,(()=>{e?t.hideSubHierarchiesOf(c):t.showSubHierarchiesOf(c)})))}const i=t.neighbourhoodFinder.getSubclassesIris(c),o=t.neighbourhoodFinder.getSuperclassesIris(c),l=t.neighbourhoodFinder.getEquivalentClassesIris(c);if(i.length>0){const e=t.areAllConnectedClassesVisibleForClass(c,i,"sub");a.push(uw(e,(()=>{e?i.forEach((e=>t.removeEntity(e,[c]))):t.showSubClassesOf(c,i)})))}if(o.length>0){const e=t.areAllConnectedClassesVisibleForClass(c,o,"super");a.push(lw(e,(()=>{e?o.forEach((e=>t.removeEntity(e,[c]))):t.showSuperClassesOf(c,o)})))}if(l.length>0){const e=t.areAllConnectedClassesVisibleForClass(c,l,"equivalent");a.push(dw(e,(()=>{e?l.forEach((e=>t.removeEntity(e,[c]))):t.showEquivalentClassesOf(c,l)})))}(null===(r=t.endpointController)||void 0===r?void 0:r.isReasonerAvailable())&&t.countersEnabled&&a.push({icon:Gy,content:"Count Instances",select:()=>{var e;null===(e=t.endpointController)||void 0===e||e.requestCountForClass(s.iri.fullIri)}})}!s.is(Pg.CLASS_INSTANCE)&&(null===(o=t.endpointController)||void 0===o?void 0:o.isReasonerAvailable())&&a.push({content:"Data Lineage",icon:Wy,select:()=>t.onShowDataLineage(s.iri.fullIri)}),a.push(function(e){return{content:"Remove",icon:zy,select:e}}((()=>{s.is(Pg.OBJECT_PROPERTY)?(t.diagram.removeElement(i.target.id()),s.removeOccurrence(i.target.id(),t.diagram.id,Dg.INCREMENTAL),t.lifecycle.trigger(Zx.DiagramUpdated)):t.removeEntity(s.iri.fullIri)})));try{if(i.target.isEdge()&&t.grapholscape.uiContainer)n.attachToPosition(i.renderedPosition,t.grapholscape.uiContainer,a);else{const e=i.target.popperRef();e&&a.length>0&&n.attachTo(e,a)}}catch(e){console.error(e)}}))}function pw(e,t){const n=t.parentClassIris;e.performActionWithBlockedGraph((()=>{null==n||n.forEach((n=>{e.addEntity(n.fullIri,!1),e.addEdge(t.iri.fullIri,n.fullIri,Pg.INSTANCE_OF)}))})),1===(null==n?void 0:n.length)&&setTimeout((()=>{e.grapholscape.centerOnElement(n[0].fullIri)}),250)}function gw(e,t){if(e.referenceEntity){const n=t.grapholscape.renderer.cy;if(n){const i=n.$id(e.referenceEntity.value.iri.fullIri);i&&(e.attachTo(i.popperRef()),e.show(),i.data().pinned||(i.scratch("should-unpin",!0),t.pinNode(i)))}}}function fw(t){const n=new mx(ty);n.title="Search instances";const i=new mx(ry);i.title="Navigate through object properties";const r=new Map;r.set(Pg.CLASS,[i]),r.set(Pg.CLASS_INSTANCE,[i]),n.onclick=n=>function(t,n){var i,r,o,a,s,l;return e(this,void 0,void 0,(function*(){const c=t.currentTarget,u=n.grapholscape.widgets.get(Vg.INSTANCES_EXPLORER);if(u&&c.node&&c.node.data().iri){const t=n.grapholscape.ontology.getEntity(c.node.data().iri);if(t&&t.type===Pg.CLASS&&(!u.referenceEntity||!u.referenceEntity.value.iri.equals(t.iri)||0===u.numberOfInstancesReceived)){u.clear(),u.areInstancesLoading=!0,u.referenceEntity=vb(t,n.grapholscape);const c=null===(r=null===(i=n.endpointController)||void 0===i?void 0:i.highlightsManager)||void 0===r?void 0:r.hasUnfoldings.bind(null===(o=n.endpointController)||void 0===o?void 0:o.highlightsManager),d=yield n.getDataPropertiesByClasses([t.iri.fullIri]),h=yield n.getObjectPropertiesByClasses([t.iri.fullIri]),p=Array.from(h).map((([e,t])=>{let i=yb(e,n.grapholscape,c);return{entityViewData:i.entityViewData,loading:i.loading,hasUnfolding:i.hasUnfolding,connectedClasses:[],direct:t.direct}}));u.propertiesFilterList=d.map((e=>yb(e,n.grapholscape,c))).concat(p).sort(((e,t)=>e.entityViewData.displayedName.localeCompare(t.entityViewData.displayedName))),u.requestId=yield null===(a=n.endpointController)||void 0===a?void 0:a.requestInstancesForClass(t.iri.fullIri),u.requestId&&(null===(l=null===(s=n.endpointController)||void 0===s?void 0:s.shouldQueryUseLabels(u.requestId))||void 0===l||l.then((i=>e(this,void 0,void 0,(function*(){var e;i||(u.shouldAskForLabels=i,u.areInstancesLoading=!0,u.requestId=yield null===(e=n.endpointController)||void 0===e?void 0:e.requestInstancesForClass(t.iri.fullIri,i))})))))}c.node&&gw(u,n)}}))}(n,t),i.onclick=n=>function(t,n){var i,r,o;return e(this,void 0,void 0,(function*(){const e=t.currentTarget,a=n.grapholscape.widgets.get(Vg.NAVIGATION_MENU);if(a&&e.node&&e.node.data().iri){let t,s=new Map;if(e.node.data().type===Pg.CLASS){if(t=n.grapholscape.ontology.getEntity(e.node.data().iri),!t)return;a.referenceEntity=vb(t,n.grapholscape),a.canShowObjectPropertiesRanges=!0,s=yield n.getObjectPropertiesByClasses([e.node.data().iri])}else if(e.node.data().type===Pg.CLASS_INSTANCE){if(t=n.classInstanceEntities.get(e.node.data().iri),!t)return;a.referenceEntity=vb(t,n.grapholscape),a.canShowObjectPropertiesRanges=!1;const i=t.parentClassIris.map((e=>e.fullIri));s=yield n.getObjectPropertiesByClasses(i)}const l=null===(r=null===(i=n.endpointController)||void 0===i?void 0:i.highlightsManager)||void 0===r?void 0:r.hasUnfoldings.bind(null===(o=n.endpointController)||void 0===o?void 0:o.highlightsManager);a.objectProperties=Array.from(s).map((e=>{const t=yb(e[0],n.grapholscape,l);return t.connectedClasses=e[1].list.map((e=>yb(e,n.grapholscape,l))),t.direct=e[1].direct,t})),e.node&&gw(a,n)}}))}(n,t),t.grapholscape.renderState===Dg.INCREMENTAL&&t.diagram.representation&&vw(t.diagram.representation.cy,r),t.grapholscape.on(_f.RendererChange,(e=>{e===Dg.INCREMENTAL&&t.diagram.representation&&vw(t.diagram.representation.cy,r)})),t.on(Zx.Reset,(()=>{t.grapholscape.renderState===Dg.INCREMENTAL&&t.diagram.representation&&(vw(t.diagram.representation.cy,r),t.grapholscape.container.querySelectorAll("[data-tippy-root]").forEach((e=>e.remove())))})),t.on(Zx.EndpointChange,(()=>{var e,t;(null===(e=r.get(Pg.CLASS))||void 0===e?void 0:e.includes(n))||null===(t=r.get(Pg.CLASS))||void 0===t||t.push(n)})),t.on(Zx.InstanceCheckingStarted,(e=>{var n;const i=null===(n=t.diagram.representation)||void 0===n?void 0:n.cy.$id(e);i&&(i.addClass("unknown-parent-class"),bw(i,nb(),"loading-badge"))})),t.on(Zx.InstanceCheckingFinished,(e=>{var n;const i=null===(n=t.diagram.representation)||void 0===n?void 0:n.cy.$id(e);i&&i.scratch("loading-badge")&&mw(i,"loading-badge")})),t.on(Zx.CountStarted,(e=>{var n;const i=null===(n=t.diagram.representation)||void 0===n?void 0:n.cy.$id(e);i&&!i.empty()&&(mw(i,"instance-count"),bw(i,nb(),"instance-count","bottom"))})),t.on(Zx.NewCountResult,((e,n)=>{var i;const r=null===(i=t.grapholscape.renderer.cy)||void 0===i?void 0:i.$id(e);if(r&&r.nonempty()&&r.scratch("instance-count")){const i=r.scratch("instance-count");i.contentType="template",n=n||t.counts.get(e),i.content=void 0!==(null==n?void 0:n.value)?(new Intl.NumberFormat).format(n.value):"n/a",i.highlighted=!(null==n?void 0:n.materialized),(null==n?void 0:n.date)?i.title=`Date: ${n.date}`:i.title="Fresh Value";const o=r.scratch("update-instance-count-position");o&&o(),setTimeout((()=>i.hide()),1e3),r.on("mouseover",(()=>{t.countersEnabled&&i.tippyWidget.show()})),r.on("mouseout",(()=>i.tippyWidget.hide())),n&&!n.materialized&&t.counts.set(e,n)}}))}function vw(e,t){e.scratch("_gscape-graph-incremental-handlers-set")||(e.on("mouseover","node",(e=>{var n;const i=e.target,r=i.data().type;i.hasClass("unknown-parent-class")||r!==Pg.CLASS&&r!==Pg.CLASS_INSTANCE||null===(n=t.get(r))||void 0===n||n.forEach(((e,n)=>{e.cxtWidgetProps.offset=e=>yw(e,n,t.get(r).length),e.node=i,i.scratch(`place-node-button-${n}`,(()=>e.attachTo(i.popperRef()))),i.on("position",i.scratch(`place-node-button-${n}`)),e.attachTo(i.popperRef())}))})),e.on("mouseout","node",(e=>{const n=e.target;t.forEach(((e,t)=>e.forEach(((e,t)=>{e.hide();const i=n.scratch(`place-node-button-${t}`);i&&(n.removeListener("position",void 0,i),n.removeScratch(`place-node-button-${t}`))}))))})),e.scratch("_gscape-graph-incremental-handlers-set",!0))}function yw(e,t=0,n=1){const i=e.popper.height+4;return[-i/2-t*i+i*(n/2),-e.popper.width/2]}function mw(e,t){e.scratch(t)&&(e.scratch(t).tippyWidget.destroy(),e.removeClass("unknown-parent-class"),e.removeScratch(t),e.removeAllListeners(),e.cy().removeListener("pan",e.scratch(`update-${t}-position`)),e.removeScratch(`update-${t}-position`))}function bw(e,t,n,i="bottom",r=!1){const o=r?new mx(t):new mx(t,"template");return o.cxtWidgetProps.placement=i,e.scratch(n,o),e.scratch(`update-${n}-position`,(()=>{o.attachToSilently(e.popperRef())})),o.cxtWidgetProps.offset=e=>yw(e),o.attachTo(e.popperRef()),e.on("position",e.scratch(`update-${n}-position`)),e.cy().on("pan",e.scratch(`update-${n}-position`)),e.scratch(`update-${n}-position`),e.on("remove",(e=>mw(e.target,n))),o}aw.properties={areInstancesLoading:{type:Boolean},instances:{type:Object},referenceEntity:{type:Object},searchFilterList:{type:Object},referencePropertyEntity:{type:Object},classTypeFilterList:{type:Object},canShowMore:{type:Boolean},lastSearchedText:{type:String,state:!0}},aw.styles=[rm,ow,ob,ib,nv` :host { min-height: 450px; } @@ -2848,4 +2848,4 @@ gscape-entity-list-item:hover > .hover-btn { display: flex; justify-content: space-between; } - `],customElements.define("gscape-navigation-menu",xw);class _w{constructor(e){this.grapholscape=e,this.classInstanceEntities=new Map,this.diagram=new rf,this.counts=new Map,this.countersEnabled=!0,this.lifecycle=new Kx,this.on=this.lifecycle.on,this.onShowDataLineage=()=>{},this.runLayout=()=>{var e;return null===(e=this.incrementalRenderer)||void 0===e?void 0:e.runLayout()},this.pinNode=e=>{var t;return null===(t=this.incrementalRenderer)||void 0===t?void 0:t.pinNode(e)},this.unpinNode=e=>{var t;return null===(t=this.incrementalRenderer)||void 0===t?void 0:t.unpinNode(e)},this.diagramBuilder=new $x(this.diagram),this.addEdge=this.diagramBuilder.addEdge.bind(this.diagramBuilder),this.neighbourhoodFinder=new ew(this.ontology),e.on(_f.EntityNameTypeChange,(e=>{this.classInstanceEntities.forEach((e=>this.updateEntityNameType(e.iri)))})),e.on(_f.LanguageChange,(t=>{var n;null===(n=this.endpointController)||void 0===n||n.setLanguage(t),e.entityNameType===Yg.LABEL&&this.classInstanceEntities.forEach((e=>this.updateEntityNameType(e.iri)))}))}showDiagram(e){e&&(this.diagram.lastViewportState=e),Ax(this.diagram,this.grapholscape.lifecycle,this.grapholscape.ontology),this.grapholscape.renderer.render(this.diagram)}performActionWithBlockedGraph(t){var n;return e(this,void 0,void 0,(function*(){const e=this.numberOfElements;null===(n=this.incrementalRenderer)||void 0===n||n.freezeGraph(),yield t(),this.postDiagramEdit(e)}))}setMastroConnection(e){this.reset(),e.onError||(e.onError=e=>console.error(e)),this.endpointController=new Jx(e,this.lifecycle),this.endpointController.setLanguage(this.grapholscape.language),this.lifecycle.trigger(Zx.ReasonerSet)}addEntity(e,t=!0,n){const i=this.grapholscape.ontology.getEntity(e);i&&this.diagramBuilder.diagram.representation&&(n&&i.is(Pg.CLASS)?this.diagramBuilder.addClass(i,n):this.diagramBuilder.addEntity(i),this.updateEntityNameType(i.iri),t&&this.grapholscape.centerOnElement(e),i.is(Pg.CLASS)&&this.countInstancesForClass(e))}areHierarchiesVisible(e){var t;let n=!0;for(let i of e)if(i.id&&(null===(t=this.grapholscape.renderer.cy)||void 0===t?void 0:t.$id(i.id).empty())){n=!1;break}return n}areAllConnectedClassesVisibleForClass(e,t,n){var i;for(let r of t){const t=null===(i=this.grapholscape.renderer.cy)||void 0===i?void 0:i.$id(r).connectedEdges(`[ type ="${"equivalent"===n?Pg.EQUIVALENCE:Pg.INCLUSION}" ]`);if(t){if("sub"===n&&t.targets(`[id = "${e}"]`).empty())return!1;if("super"===n&&t.sources(`[id = "${e}"]`).empty())return!1;if("equivalent"===n&&t.connectedNodes(`[id = "${e}"]`).empty())return!1}}return!0}reset(){var e;null===(e=this.incrementalRenderer)||void 0===e||e.reset(),this.classInstanceEntities.clear(),this.diagram.clear(),this.clearState(),this.lifecycle.trigger(Zx.Reset)}clearState(){var e;null===(e=this.endpointController)||void 0===e||e.clear()}updateEntityNameType(e){var t,n;let i;i="string"!=typeof e?e.fullIri:e;const r=this.classInstanceEntities.get(i)||this.ontology.getEntity(i);let o,a=null===(t=this.diagram.representation)||void 0===t?void 0:t.grapholElements.get(i);r&&!a?o=null===(n=r.occurrences.get(Dg.INCREMENTAL))||void 0===n?void 0:n.map((e=>{var t,n;return null===(n=null===(t=this.diagram)||void 0===t?void 0:t.representation)||void 0===n?void 0:n.grapholElements.get(e.elementId)})).filter((e=>void 0!==e)):a&&(o=[a]),r&&o&&o.forEach((e=>{var t,n;e.displayedName=r.getDisplayedName(this.grapholscape.entityNameType,this.grapholscape.language),null===(n=null===(t=this.diagram)||void 0===t?void 0:t.representation)||void 0===n||n.updateElement(e,!1)}))}removeEntity(e,t=[]){let n;n="string"==typeof e?this.classInstanceEntities.get(e)||this.ontology.getEntity(e):e,this.performActionWithBlockedGraph((()=>{var e;null===(e=this.grapholscape.renderer.cy)||void 0===e||e.$(`[iri = "${null==n?void 0:n.iri.fullIri}"]`).forEach((e=>{var i,r;e.connectedEdges(`[type = "${Pg.OBJECT_PROPERTY}"]`).forEach((e=>{const t=this.ontology.getEntity(e.data().iri);t&&t.removeOccurrence(e.id(),this.diagram.id,Dg.INCREMENTAL)})),e.data().type===Pg.CLASS&&(e.neighborhood().forEach((e=>{e.isNode()?1!==e.degree(!1)||t.includes(e.id())||(e.data().iri?(t.push((null==n?void 0:n.iri.fullIri)||""),this.removeEntity(e.data().iri,t)):this.diagram.removeElement(e.id())):this.diagram.removeElement(e.id())})),null===(i=this.ontology.hierarchiesBySubclassMap.get(n.iri.fullIri))||void 0===i||i.forEach((e=>{this.removeHierarchy(e)})),null===(r=this.ontology.hierarchiesBySuperclassMap.get(n.iri.fullIri))||void 0===r||r.forEach((e=>{this.removeHierarchy(e)}))),this.diagram.removeElement(e.id()),null==n||n.removeOccurrence(e.id(),this.diagram.id,Dg.INCREMENTAL),(null==n?void 0:n.is(Pg.CLASS_INSTANCE))&&this.classInstanceEntities.delete(n.iri.fullIri)}))}))}addInstance(e,t){var n,i;let r=this.classInstanceEntities.get(e.iri);if(!r){const t=new af(e.iri,this.ontology.namespaces,e.shortIri);r=new bf(t),e.label&&r.addAnnotation(new sf(Ig.label,e.label.value,e.label.language)),null===(n=this.endpointController)||void 0===n||n.requestLabels(e.iri).then((e=>{null==e||e.forEach((e=>{r.addAnnotation(new sf(Ig.label,e.value,e.language))})),this.updateEntityNameType(r.iri)})),this.diagramBuilder.addClassInstance(r),this.classInstanceEntities.set(e.iri,r)}if("string"!=typeof t)t||(t=this.ontology.getEntitiesByType(Pg.CLASS).map((e=>e.iri.fullIri))),null===(i=this.endpointController)||void 0===i||i.instanceCheck(e.iri,t).then((e=>{e.forEach((e=>{const t=this.ontology.getEntity(e);t&&r&&r.addParentClass(t.iri)}))}));else{const e=this.ontology.getEntity(t);e&&r.addParentClass(e.iri)}return this.updateEntityNameType(r.iri),this.lifecycle.trigger(Zx.DiagramUpdated),r}addIntensionalObjectProperty(e,t,n){const i=this.ontology.getEntity(e),r=this.ontology.getEntity(t),o=this.ontology.getEntity(n);i&&r&&o&&(this.performActionWithBlockedGraph((()=>{this.diagramBuilder.addObjectProperty(i,r,o),this.updateEntityNameType(i.iri),this.updateEntityNameType(t),this.updateEntityNameType(n)})),this.countInstancesForClass(t),this.countInstancesForClass(n))}addExtensionalObjectProperty(e,t,n){const i=this.ontology.getEntity(e),r=this.classInstanceEntities.get(t),o=this.classInstanceEntities.get(n);i&&r&&o&&this.performActionWithBlockedGraph((()=>{this.diagramBuilder.addObjectProperty(i,r,o),this.updateEntityNameType(i.iri),this.updateEntityNameType(r.iri),this.updateEntityNameType(o.iri)}))}showSuperHierarchiesOf(e){this.showOrHideHierarchies(e,"super","show")}showSubHierarchiesOf(e){this.showOrHideHierarchies(e,"sub","show")}hideSuperHierarchiesOf(e){this.showOrHideHierarchies(e,"super","hide")}hideSubHierarchiesOf(e){this.showOrHideHierarchies(e,"sub","hide")}showOrHideHierarchies(e,t,n){if(!this.ontology.getEntity(e))return;let i;const r=this.ontology.hierarchiesBySuperclassMap.get(e),o=this.ontology.hierarchiesBySubclassMap.get(e);switch(t){case"super":i=o;break;case"sub":i=r;break;case"any":i=[],r&&i.concat(r),o&&i.concat(o);break;default:return}i&&i.length>0&&this.performActionWithBlockedGraph((()=>{var t;const r=null===(t=this.grapholscape.renderer.cy)||void 0===t?void 0:t.$id(e).position();"show"===n?null==i||i.forEach((e=>this.addHierarchy(e,r))):null==i||i.forEach((t=>this.removeHierarchy(t,[e])))}))}addHierarchy(e,t){var n,i;const r=e.getUnionGrapholNode(t),o=e.getInputGrapholEdges(),a=e.getInclusionEdges();if(r&&o&&a){this.diagram.addElement(r);for(const t of e.inputs)this.addEntity(t,!1);for(const t of e.superclasses)this.addEntity(t.classIri,!1);null===(n=e.getInputGrapholEdges())||void 0===n||n.forEach((e=>this.diagram.addElement(e))),null===(i=e.getInclusionEdges())||void 0===i||i.forEach((e=>this.diagram.addElement(e)))}}removeHierarchy(e,t=[]){var n,i,r;if(!this.incrementalRenderer||!e.id||e.id&&(null===(n=this.grapholscape.renderer.cy)||void 0===n?void 0:n.$id(e.id).empty()))return;let o;this.diagram.removeElement(e.id),null===(i=e.getInputGrapholEdges())||void 0===i||i.forEach((e=>{var t;null===(t=this.diagram)||void 0===t||t.removeElement(e.id)})),null===(r=e.getInclusionEdges())||void 0===r||r.forEach((e=>{var t;null===(t=this.diagram)||void 0===t||t.removeElement(e.id)})),e.inputs.forEach((e=>{var n;0!==(null===(n=this.grapholscape.renderer.cy)||void 0===n?void 0:n.$id(e).degree(!1))||t.includes(e)||(o=this.ontology.getEntity(e),o&&this.removeEntity(o))})),e.superclasses.forEach((e=>{var n;0!==(null===(n=this.grapholscape.renderer.cy)||void 0===n?void 0:n.$id(e.classIri).degree(!1))||t.includes(e.classIri)||(o=this.ontology.getEntity(e.classIri),o&&this.removeEntity(o))}))}showSubClassesOf(e,t){t||(t=this.neighbourhoodFinder.getSubclassesIris(e)),this.showClassesInIsa(e,t,Pg.INCLUSION)}showSuperClassesOf(e,t){t||(t=this.neighbourhoodFinder.getSuperclassesIris(e)),this.showClassesInIsa(e,t,Pg.INCLUSION,"super")}showEquivalentClassesOf(e,t){t||(t=this.neighbourhoodFinder.getEquivalentClassesIris(e)),this.showClassesInIsa(e,t,Pg.EQUIVALENCE)}showClassesInIsa(e,t,n,i="sub"){this.performActionWithBlockedGraph((()=>{t.forEach((t=>{this.addEntity(t,!1),"super"===i?this.diagramBuilder.addEdge(e,t,n):this.diagramBuilder.addEdge(t,e,n)}))}))}getObjectPropertiesByClasses(t){var n,i,r;return e(this,void 0,void 0,(function*(){if(null===(n=this.endpointController)||void 0===n?void 0:n.isReasonerAvailable()){null===(i=this.endpointController.highlightsManager)||void 0===i||i.computeHighlights(t);const e=yield null===(r=this.endpointController.highlightsManager)||void 0===r?void 0:r.objectProperties(),n=new Map;return null==e||e.forEach((e=>{var t;if(!e.objectPropertyIRI)return;const i=this.ontology.getEntity(e.objectPropertyIRI);if(!i)return;const r={list:[],direct:e.direct||!1};null===(t=e.relatedClasses)||void 0===t||t.forEach((e=>{const t=this.ontology.getEntity(e);t&&r.list.push(t)})),n.set(i,r)})),n}return this.neighbourhoodFinder.getObjectProperties(t[0])}))}getDataPropertiesByClasses(t){var n,i,r;return e(this,void 0,void 0,(function*(){if(null===(n=this.endpointController)||void 0===n?void 0:n.isReasonerAvailable()){null===(i=this.endpointController.highlightsManager)||void 0===i||i.computeHighlights(t);const e=yield null===(r=this.endpointController.highlightsManager)||void 0===r?void 0:r.dataProperties();return(null==e?void 0:e.map((e=>this.ontology.getEntity(e))).filter((e=>null!==e)))||[]}return this.neighbourhoodFinder.getDataProperties(t[0])}))}getDataPropertiesByClassInstance(t){var n;return e(this,void 0,void 0,(function*(){const e=this.classInstanceEntities.get(t);return e&&(null===(n=this.endpointController)||void 0===n?void 0:n.highlightsManager)?(this.endpointController.highlightsManager.computeHighlights(e.parentClassIris.map((e=>e.fullIri))),(yield this.endpointController.highlightsManager.dataProperties()).map((e=>this.ontology.getEntity(e))).filter((e=>null!==e))):[]}))}postDiagramEdit(e){var t;this.numberOfElements!==e?(this.runLayout(),this.lifecycle.trigger(Zx.DiagramUpdated)):null===(t=this.incrementalRenderer)||void 0===t||t.unFreezeGraph()}countInstancesForClass(t){var n,i,r,o;return e(this,void 0,void 0,(function*(){if(!this.countersEnabled||!(null===(n=this.endpointController)||void 0===n?void 0:n.isReasonerAvailable()))return;const e=null===(r=null===(i=this.diagram)||void 0===i?void 0:i.representation)||void 0===r?void 0:r.cy.$id(t);if(e&&!e.empty())if(yield this.updateMaterializedCounts(),void 0===this.counts.get(t))null===(o=this.endpointController)||void 0===o||o.requestCountForClass(t);else{let n;const i=this.counts.get(t);e.scratch("instance-count")?(n=e.scratch("instance-count"),n.content=i.value):(n=bw(e,i.value,"instance-count","bottom"),setTimeout((()=>n.hide()),1e3),e.on("mouseover",(()=>{this.countersEnabled&&n.tippyWidget.show()})),e.on("mouseout",(()=>n.tippyWidget.hide()))),i.materialized?(n.highlighted=!1,n.title=`Date: ${i.date}`):(n.highlighted=!0,n.title="Fresh Value")}}))}updateMaterializedCounts(){var t;return e(this,void 0,void 0,(function*(){const e=yield null===(t=this.endpointController)||void 0===t?void 0:t.getMaterializedCounts();e&&e.countsMap.forEach((t=>{var n;if(t.state===Lx.FINISHED){const i=this.counts.get(t.entity.entityIRI);i&&!i.materialized||(this.counts.set(t.entity.entityIRI,{value:t.count,materialized:!0,date:0!==e.endTime?new Date(e.endTime).toDateString():new Date(e.startTime).toDateString()}),this.lifecycle.trigger(Zx.NewCountResult,t.entity.entityIRI,{value:t.count,materialized:!0,date:null===(n=this.counts.get(t.entity.entityIRI))||void 0===n?void 0:n.date}))}}))}))}setIncrementalEventHandlers(){var e,t,n,i;(null===(e=this.diagram.representation)||void 0===e?void 0:e.hasEverBeenRendered)||(null===(t=this.diagram.representation)||void 0===t?void 0:t.cy.scratch("_gscape-incremental-graph-handlers-set"))||(null===(n=this.diagram.representation)||void 0===n||n.cy.on("tap",(e=>{const t=e.target.data().type;if(t===Pg.CLASS||t===Pg.CLASS_INSTANCE){const n=()=>{var n,i;const r=e.target.data().iri;if(t===Pg.CLASS_INSTANCE){const e=this.classInstanceEntities.get(r);e&&(r!==this.lastInstanceIri&&(null===(n=this.endpointController)||void 0===n||n.stopRequests("instances")),this.lifecycle.trigger(Zx.ClassInstanceSelection,e))}else{r!==this.lastClassIri&&(null===(i=this.endpointController)||void 0===i||i.stopRequests("instances"));const e=this.grapholscape.ontology.getEntity(r);e&&this.lifecycle.trigger(Zx.ClassSelection,e)}};this.endpointController?(clearTimeout(this.entitySelectionTimeout),this.entitySelectionTimeout=setTimeout(n,400)):n()}})),null===(i=this.diagram.representation)||void 0===i||i.cy.scratch("_gscape-incremental-graph-handlers-set",!0))}get ontology(){return this.grapholscape.ontology}get incrementalRenderer(){if(this.grapholscape.renderState===Dg.INCREMENTAL)return this.grapholscape.renderer.renderState}get numberOfElements(){var e;return(null===(e=this.grapholscape.renderer.cy)||void 0===e?void 0:e.elements().size())||0}}function Cw(t){var n;let i,r=new _w(t);t.incremental=r,function(t){const n=new nw,i=t.grapholscape.widgets.get(Vg.ENTITY_DETAILS);i&&(i.incrementalSection=n),t.grapholscape.widgets.set(Vg.CLASS_INSTANCE_DETAILS,n),t.grapholscape.on(_f.EntitySelection,(i=>e(this,void 0,void 0,(function*(){let e;i.is(Pg.CLASS)&&t.grapholscape.renderState===Dg.INCREMENTAL?(e=yield t.getDataPropertiesByClasses([i.iri.fullIri]),n.dataProperties=e.map((e=>vb(e,t.grapholscape))),n.parentClasses=void 0,n.canShowDataPropertiesValues=!1,n.show()):n.hide()})))),t.on(Zx.ClassInstanceSelection,(r=>e(this,void 0,void 0,(function*(){var e;if(!(null==i?void 0:i.grapholEntity)||!(null==i?void 0:i.grapholEntity.iri.equals(r.iri))){null===(e=t.endpointController)||void 0===e||e.stopRequests("instances");const i=r.parentClassIris.map((e=>e.fullIri)),o=yield t.getDataPropertiesByClasses(i);n.dataProperties=o.map((e=>vb(e,t.grapholscape))),n.parentClasses=i.map((e=>{const n=t.grapholscape.ontology.getEntity(e);if(n)return vb(n,t.grapholscape)})).filter((e=>void 0!==e)),o.forEach((e=>{var n;null===(n=t.endpointController)||void 0===n||n.requestDataPropertyValues(r.iri.fullIri,e.iri.fullIri)}))}n.canShowDataPropertiesValues=!0,null==i||i.setGrapholEntity(r),n.show()})))),t.on(Zx.NewDataPropertyValues,((e,t,r)=>{(null==i?void 0:i.grapholEntity.iri.equals(e))&&r.forEach((e=>n.addDataPropertyValue(t,e)))})),t.on(Zx.DataPropertyValuesLoadingFinished,((e,t)=>{(null==i?void 0:i.grapholEntity.iri.equals(e))&&n.setDataPropertyLoading(t,!1)}))}(r),function(t){var n,i;const r=new iw;function o(){var e;null===(e=t.endpointController)||void 0===e||e.getRunningEndpoints().then((e=>{var n,i;r.endpoints=e.map((e=>({name:e.name}))).sort(((e,t)=>e.name.localeCompare(t.name))),e.length>=1&&!r.selectedEndpointName&&(null===(n=t.endpointController)||void 0===n||n.setEndpoint(e[0]),null===(i=t.endpointController)||void 0===i||i.setLanguage(t.grapholscape.language))}))}r.showCounters=t.countersEnabled,t.grapholscape.widgets.set(Vg.VKG_PREFERENCES,r),null===(i=null===(n=t.grapholscape.uiContainer)||void 0===n?void 0:n.querySelector(".gscape-ui-buttons-tray"))||void 0===i||i.appendChild(r),t.grapholscape.renderState===Dg.INCREMENTAL&&t.endpointController||r.disable(),t.endpointController&&o(),t.on(Zx.EndpointChange,(e=>{r.selectedEndpointName=e.name})),t.on(Zx.LimitChange,(e=>{r.pageSize=e})),t.on(Zx.ReasonerSet,(()=>{t.grapholscape.renderState===Dg.INCREMENTAL&&r.enable(),o(),t.endpointController&&(r.pageSize=t.endpointController.pageSize)})),r.onTogglePanel=()=>o(),r.onEndpointChange((n=>{var i;const r=new pb("Are you sure? \nIf you change the current endpoint, your exploration will be reset.");null===(i=t.grapholscape.uiContainer)||void 0===i||i.appendChild(r),r.show(),r.onConfirm=()=>e(this,void 0,void 0,(function*(){var e,i;t.reset(),null===(e=t.endpointController)||void 0===e||e.setEndpoint(n),null===(i=t.endpointController)||void 0===i||i.setLanguage(t.grapholscape.language)}))})),r.onPageSizeChange((e=>{var n;null===(n=t.endpointController)||void 0===n||n.setPageSize(e)})),r.onShowCountersChange((e=>{t.countersEnabled=e})),r.onStopRequests((()=>{var e;return null===(e=t.endpointController)||void 0===e?void 0:e.stopRequests()}))}(r),function(t){const n=new aw;t.grapholscape.widgets.set(Vg.INSTANCES_EXPLORER,n),t.on(Zx.NewInstances,((e,t)=>{n.addInstances(e.map((e=>{var t;return e[1]&&(e[0].searchMatch=null===(t=e[1].label)||void 0===t?void 0:t.value),e[0].connectedInstance=e[1],e[0]}))),!n.numberResultsAvailable&&t&&(n.numberResultsAvailable=t)})),t.on(Zx.InstancesSearchFinished,(()=>n.areInstancesLoading=!1)),t.on(Zx.Reset,(()=>{n.clear()})),n.addEventListener("instanceselection",(i=>e(this,void 0,void 0,(function*(){var e,r,o,a;let s;if(s=t.addInstance(i.detail.instance,i.detail.parentClassIris),s.parentClassIris.forEach((e=>{t.addEdge(i.detail.instance.iri,e.fullIri,Pg.INSTANCE_OF)})),i.detail.instance.connectedInstance&&i.detail.filterByProperty){t.addInstance(i.detail.instance.connectedInstance);const n=null===(a=null===(o=yield null===(r=null===(e=t.endpointController)||void 0===e?void 0:e.highlightsManager)||void 0===r?void 0:r.objectProperties())||void 0===o?void 0:o.find((e=>e.objectPropertyIRI===i.detail.filterByProperty)))||void 0===a?void 0:a.direct;void 0!==n&&(n?t.addExtensionalObjectProperty(i.detail.filterByProperty,i.detail.instance.iri,i.detail.instance.connectedInstance.iri):t.addExtensionalObjectProperty(i.detail.filterByProperty,i.detail.instance.connectedInstance.iri,i.detail.instance.iri))}if(n.referenceEntity&&n.referencePropertyEntity&&s){const e=n.referenceEntity.value.iri.fullIri,i=n.referencePropertyEntity.value.iri.fullIri;n.isPropertyDirect?t.addExtensionalObjectProperty(i,e,s.iri.fullIri):t.addExtensionalObjectProperty(i,s.iri.fullIri,e)}t.runLayout()})))),n.addEventListener("instances-filter",(i=>e(this,void 0,void 0,(function*(){var e,r,o,a;null===(e=t.endpointController)||void 0===e||e.stopRequests("instances"),n.instances=new Map,n.numberOfInstancesReceived=0,n.numberResultsAvailable=0,n.numberOfPagesShown=1,n.areInstancesLoading=!0,n.referenceEntity&&(n.referenceEntity.value.type===Pg.CLASS?n.requestId=yield null===(r=t.endpointController)||void 0===r?void 0:r.requestInstancesForClass(null===(o=n.referenceEntity)||void 0===o?void 0:o.value.iri.fullIri,i.detail.shouldAskForLabels,i.detail.filterText,i.detail.filterByProperty,i.detail.propertyType,i.detail.direct):n.referenceEntity.value.type===Pg.CLASS_INSTANCE&&n.referencePropertyEntity&&(n.requestId=yield null===(a=t.endpointController)||void 0===a?void 0:a.requestInstancesThroughObjectProperty(n.referenceEntity.value.iri.fullIri,n.referencePropertyEntity.value.iri.fullIri,n.isPropertyDirect,i.detail.shouldAskForLabels,i.detail.filterByType,i.detail.filterByProperty,i.detail.filterText)))})))),n.addEventListener("showmoreinstances",(i=>e(this,void 0,void 0,(function*(){var e,i;null===(e=t.endpointController)||void 0===e||e.stopRequests("instances"),n.areInstancesLoading=!0,n.requestId&&(null===(i=t.endpointController)||void 0===i||i.requestNewInstances(n.requestId,n.numberOfPagesShown+1))})))),n.tippyWidget.setProps({onHide:()=>{n.hide(),rw(n,t)}})}(r),hw(r),fw(r),function(t){const n=new xw;t.grapholscape.widgets.set(Vg.NAVIGATION_MENU,n),n.requestUpdate(),n.addEventListener("onclassselection",(e=>{e.detail.rangeClassIri&&(e.detail.direct?t.addIntensionalObjectProperty(e.detail.objectPropertyIri,e.detail.referenceClassIri,e.detail.rangeClassIri):t.addIntensionalObjectProperty(e.detail.objectPropertyIri,e.detail.rangeClassIri,e.detail.referenceClassIri),setTimeout((()=>{t.grapholscape.centerOnElement(e.detail.rangeClassIri)}),250),n.popperRef=void 0,n.hide())})),n.addEventListener("onobjectpropertyselection",(i=>e(this,void 0,void 0,(function*(){var r,o,a,s,l,c,u,d,h;const p=t.grapholscape.widgets.get(Vg.INSTANCES_EXPLORER);if(p){const g=t.classInstanceEntities.get(i.detail.referenceClassIri),f=t.grapholscape.ontology.getEntity(i.detail.objectPropertyIri);if(g&&f&&(!(null===(r=p.referenceEntity)||void 0===r?void 0:r.value.iri.equals(g.iri))||!(null===(o=p.referencePropertyEntity)||void 0===o?void 0:o.value.iri.equals(f.iri)))){if(n.hide(),p.clear(),p.areInstancesLoading=!0,p.referenceEntity=n.referenceEntity,p.referencePropertyEntity=vb(f,t.grapholscape),p.isPropertyDirect=i.detail.direct,p.classTypeFilterList=null===(a=n.objectProperties.find((e=>e.entityViewData.value.iri.equals(i.detail.objectPropertyIri))))||void 0===a?void 0:a.connectedClasses,1===(null===(s=p.classTypeFilterList)||void 0===s?void 0:s.length)){const e=null===(c=null===(l=t.endpointController)||void 0===l?void 0:l.highlightsManager)||void 0===c?void 0:c.hasUnfoldings.bind(t.endpointController.highlightsManager);p.propertiesFilterList=(yield t.getDataPropertiesByClasses([p.classTypeFilterList[0].entityViewData.value.iri.fullIri])).map((n=>yb(n,t.grapholscape,e)))}p.requestId=yield null===(u=t.endpointController)||void 0===u?void 0:u.requestInstancesThroughObjectProperty(g.iri.fullIri,i.detail.objectPropertyIri,i.detail.direct,!0,i.detail.rangeClassIri),p.requestId&&(null===(h=null===(d=t.endpointController)||void 0===d?void 0:d.shouldQueryUseLabels(p.requestId))||void 0===h||h.then((n=>e(this,void 0,void 0,(function*(){var e;n||(p.shouldAskForLabels=n,p.areInstancesLoading=!0,p.requestId=yield null===(e=t.endpointController)||void 0===e?void 0:e.requestInstancesThroughObjectProperty(g.iri.fullIri,i.detail.objectPropertyIri,i.detail.direct,n,i.detail.rangeClassIri))})))))}n.popperRef&&gw(p,t)}})))),n.tippyWidget.setProps({onHide:()=>rw(n,t)})}(r),r.grapholscape.widgets.get(Vg.ENTITY_SELECTOR)||Tb(r.grapholscape),i=t.widgets.get(Vg.ENTITY_SELECTOR),null===(n=r.grapholscape.uiContainer)||void 0===n||n.appendChild(i),i.hide(),i.onClassSelection((e=>{const n={x:200*Math.random(),y:200*Math.random()};r.addEntity(e,!0,n),t.selectElement(e),ww(i),i.closePanel()})),t.renderState===Dg.INCREMENTAL?Sw(t,r):Iw(t.widgets),t.on(_f.RendererChange,(e=>{e===Dg.INCREMENTAL?Sw(t,r):Iw(t.widgets)})),r.on(Zx.DiagramUpdated,(()=>{var e,n;const i=t.widgets.get(Vg.ENTITY_SELECTOR);(null===(e=t.renderer.cy)||void 0===e?void 0:e.elements().empty())?(null===(n=t.widgets.get(Vg.ENTITY_DETAILS))||void 0===n||n.hide(),i&&(Ew(i),i.focusInputSearch())):i&&ww(i);const r=t.widgets.get(Vg.ONTOLOGY_EXPLORER);r&&(r.entities=wb(t,r.searchEntityComponent))})),r.on(Zx.Reset,(()=>{var e;r.grapholscape.renderState===Dg.INCREMENTAL&&Tw(t.widgets,null===(e=t.renderer.cy)||void 0===e?void 0:e.elements().empty(),void 0!==r.endpointController)}))}function Sw(e,t){var n;e.renderer.unselect(),t||(t=new _w(e)),Tw(e.widgets,null===(n=e.renderer.cy)||void 0===n?void 0:n.elements().empty(),void 0!==t.endpointController),e.renderer.diagram&&Ax(e.renderer.diagram,e.lifecycle,e.ontology),t.setIncrementalEventHandlers()}function Tw(e,t=!1,n){const i=e.get(Vg.FILTERS),r=e.get(Vg.DIAGRAM_SELECTOR),o=e.get(Vg.ENTITY_SELECTOR),a=e.get(Vg.CLASS_INSTANCE_DETAILS),s=e.get(Vg.VKG_PREFERENCES);null==a||a.enable(),null==r||r.disable(),null==o||o.show(),t&&o&&(Ew(o),o.focusInputSearch()),n&&(null==s||s.enable()),null==i||i.disable()}function Iw(e){const t=e.get(Vg.FILTERS),n=e.get(Vg.DIAGRAM_SELECTOR),i=e.get(Vg.ENTITY_SELECTOR),r=e.get(Vg.CLASS_INSTANCE_DETAILS),o=e.get(Vg.VKG_PREFERENCES);null==r||r.disable(),null==o||o.disable(),null==n||n.enable(),null==i||i.hide(),null==t||t.enable()}function Pw(t,n,i){return e(this,void 0,void 0,(function*(){const e=yield Aw(t,n,i);return e&&(yx(e),(!1===(null==i?void 0:i.initialRendererSelection)||e.renderState)&&e.widgets.get(Vg.INITIAL_RENDERER_SELECTOR).hide(),e.renderers.includes(Dg.INCREMENTAL)&&Cw(e)),e}))}function kw(t,n,i){return e(this,void 0,void 0,(function*(){const e=yield Aw(t,n,i);return(null==e?void 0:e.renderers.includes(Dg.INCREMENTAL))&&Cw(e),e}))}function Aw(t,n,i){return e(this,void 0,void 0,(function*(){if(!t||!n)return void console.error("Please specify an ontology and a container for Grapholscape");const e=jg();return i=Object.assign(i||{},e),new Promise(((e,o)=>{let a;if("object"==typeof t){let e=new FileReader;e.onloadend=()=>{try{a=r(e.result),s()}catch(e){o(e)}},e.readAsText(t),setTimeout((()=>{o("Error: timeout expired")}),1e4)}else"string"==typeof t?(a=r(t),s()):o("Err: Grapholscape needs a Graphol File or the corresponding string to be initialized");function s(){try{const t=new Nx(a,n,i);e(t)}catch(e){console.error(e)}}}));function r(e){return new Wf(e).parseGraphol()}}))}Hd.use(Ag),Hd.use(Uh),Hd.warnings(!1);export{Og as AnnotatedElement,sf as Annotation,Ig as AnnotationsKind,xf as BaseFilterManager,Ef as BaseRenderer,Sf as Breakpoint,ff as CSS_PROPERTY_NAMESPACE,bf as ClassInstanceEntity,cf as ColoursNames,Rg as ConstructorLabelsEnum,yf as DefaultFilterKeyEnum,gf as DefaultThemes,uf as DefaultThemesEnum,nf as Diagram,tf as DiagramRepresentation,Yg as EntityNameType,vf as Filter,Db as FloatyRendererState,Qg as FunctionalityEnum,Zg as GrapholEdge,Wg as GrapholElement,Xg as GrapholEntity,Jg as GrapholNode,Lg as GrapholNodesEnum,$b as GrapholRendererState,Pg as GrapholTypesEnum,Nx as Grapholscape,lf as GrapholscapeTheme,If as Hierarchy,_w as IncrementalController,rf as IncrementalDiagram,zb as IncrementalRendererState,af as Iri,Gg as Language,Cf as Lifecycle,_f as LifecycleEvent,Fb as LiteRendererState,of as Namespace,Mg as Ontology,Ng as POLYGON_POINTS,kx as Renderer,Dg as RendererStatesEnum,kg as Shape,kw as bareGrapholscape,hf as classicColourMap,Ug as clearLocalStorage,pf as darkColourMap,zg as floatyOptions,Pw as fullGrapholscape,mf as getDefaultFilters,$g as grapholOptions,df as gscapeColourMap,Cw as initIncremental,Kg as isGrapholEdge,ef as isGrapholNode,Bg as liteOptions,jg as loadConfig,Ax as setGraphEventHandlers,qg as storeConfigEntry,Cx as toPNG,Sx as toSVG,bx as ui,mb as util}; + `],customElements.define("gscape-navigation-menu",xw);class _w{constructor(e){this.grapholscape=e,this.classInstanceEntities=new Map,this.diagram=new rf,this.counts=new Map,this.countersEnabled=!0,this.lifecycle=new Kx,this.on=this.lifecycle.on,this.onShowDataLineage=()=>{},this.runLayout=()=>{var e;return null===(e=this.incrementalRenderer)||void 0===e?void 0:e.runLayout()},this.pinNode=e=>{var t;return null===(t=this.incrementalRenderer)||void 0===t?void 0:t.pinNode(e)},this.unpinNode=e=>{var t;return null===(t=this.incrementalRenderer)||void 0===t?void 0:t.unpinNode(e)},this.diagramBuilder=new $x(this.diagram),this.addEdge=this.diagramBuilder.addEdge.bind(this.diagramBuilder),this.neighbourhoodFinder=new ew(this.ontology),e.on(_f.EntityNameTypeChange,(e=>{this.classInstanceEntities.forEach((e=>this.updateEntityNameType(e.iri)))})),e.on(_f.LanguageChange,(t=>{var n;null===(n=this.endpointController)||void 0===n||n.setLanguage(t),e.entityNameType===Yg.LABEL&&this.classInstanceEntities.forEach((e=>this.updateEntityNameType(e.iri)))}))}showDiagram(e){e&&(this.diagram.lastViewportState=e),Ax(this.diagram,this.grapholscape.lifecycle,this.grapholscape.ontology),this.grapholscape.renderer.render(this.diagram)}performActionWithBlockedGraph(t){var n;return e(this,void 0,void 0,(function*(){const e=this.numberOfElements;null===(n=this.incrementalRenderer)||void 0===n||n.freezeGraph(),yield t(),this.postDiagramEdit(e)}))}setMastroConnection(e){this.reset(),e.onError||(e.onError=e=>console.error(e)),this.endpointController=new Jx(e,this.lifecycle),this.endpointController.setLanguage(this.grapholscape.language),this.lifecycle.trigger(Zx.ReasonerSet)}addEntity(e,t=!0,n){const i=this.grapholscape.ontology.getEntity(e);i&&this.diagramBuilder.diagram.representation&&(n&&i.is(Pg.CLASS)?this.diagramBuilder.addClass(i,n):this.diagramBuilder.addEntity(i),this.updateEntityNameType(i.iri),t&&this.grapholscape.centerOnElement(e),i.is(Pg.CLASS)&&this.countInstancesForClass(e))}areHierarchiesVisible(e){var t;let n=!0;for(let i of e)if(i.id&&(null===(t=this.grapholscape.renderer.cy)||void 0===t?void 0:t.$id(i.id).empty())){n=!1;break}return n}areAllConnectedClassesVisibleForClass(e,t,n){var i;for(let r of t){const t=null===(i=this.grapholscape.renderer.cy)||void 0===i?void 0:i.$id(r).connectedEdges(`[ type ="${"equivalent"===n?Pg.EQUIVALENCE:Pg.INCLUSION}" ]`);if(t){if("sub"===n&&t.targets(`[id = "${e}"]`).empty())return!1;if("super"===n&&t.sources(`[id = "${e}"]`).empty())return!1;if("equivalent"===n&&t.connectedNodes(`[id = "${e}"]`).empty())return!1}}return!0}reset(){var e;null===(e=this.incrementalRenderer)||void 0===e||e.reset(),this.classInstanceEntities.clear(),this.diagram.clear(),this.clearState(),this.lifecycle.trigger(Zx.Reset)}clearState(){var e;null===(e=this.endpointController)||void 0===e||e.clear()}updateEntityNameType(e){var t,n;let i;i="string"!=typeof e?e.fullIri:e;const r=this.classInstanceEntities.get(i)||this.ontology.getEntity(i);let o,a=null===(t=this.diagram.representation)||void 0===t?void 0:t.grapholElements.get(i);r&&!a?o=null===(n=r.occurrences.get(Dg.INCREMENTAL))||void 0===n?void 0:n.map((e=>{var t,n;return null===(n=null===(t=this.diagram)||void 0===t?void 0:t.representation)||void 0===n?void 0:n.grapholElements.get(e.elementId)})).filter((e=>void 0!==e)):a&&(o=[a]),r&&o&&o.forEach((e=>{var t,n;e.displayedName=r.getDisplayedName(this.grapholscape.entityNameType,this.grapholscape.language),null===(n=null===(t=this.diagram)||void 0===t?void 0:t.representation)||void 0===n||n.updateElement(e,!1)}))}removeEntity(e,t=[]){let n;n="string"==typeof e?this.classInstanceEntities.get(e)||this.ontology.getEntity(e):e,this.performActionWithBlockedGraph((()=>{var e;null===(e=this.grapholscape.renderer.cy)||void 0===e||e.$(`[iri = "${null==n?void 0:n.iri.fullIri}"]`).forEach((e=>{var i,r;e.connectedEdges(`[type = "${Pg.OBJECT_PROPERTY}"]`).forEach((e=>{const t=this.ontology.getEntity(e.data().iri);t&&t.removeOccurrence(e.id(),this.diagram.id,Dg.INCREMENTAL)})),e.data().type===Pg.CLASS&&(e.neighborhood().forEach((e=>{e.isNode()?1!==e.degree(!1)||t.includes(e.id())||(e.data().iri?(t.push((null==n?void 0:n.iri.fullIri)||""),this.removeEntity(e.data().iri,t)):this.diagram.removeElement(e.id())):this.diagram.removeElement(e.id())})),null===(i=this.ontology.hierarchiesBySubclassMap.get(n.iri.fullIri))||void 0===i||i.forEach((e=>{this.removeHierarchy(e)})),null===(r=this.ontology.hierarchiesBySuperclassMap.get(n.iri.fullIri))||void 0===r||r.forEach((e=>{this.removeHierarchy(e)}))),this.diagram.removeElement(e.id()),null==n||n.removeOccurrence(e.id(),this.diagram.id,Dg.INCREMENTAL),(null==n?void 0:n.is(Pg.CLASS_INSTANCE))&&this.classInstanceEntities.delete(n.iri.fullIri)}))}))}addInstance(e,t){var n,i;let r=this.classInstanceEntities.get(e.iri);if(!r){const t=new af(e.iri,this.ontology.namespaces,e.shortIri);r=new bf(t),e.label&&r.addAnnotation(new sf(Ig.label,e.label.value,e.label.language)),null===(n=this.endpointController)||void 0===n||n.requestLabels(e.iri).then((e=>{null==e||e.forEach((e=>{r.addAnnotation(new sf(Ig.label,e.value,e.language))})),this.updateEntityNameType(r.iri)})),this.diagramBuilder.addClassInstance(r),this.classInstanceEntities.set(e.iri,r)}if("string"!=typeof t)t||(t=this.ontology.getEntitiesByType(Pg.CLASS).map((e=>e.iri.fullIri))),null===(i=this.endpointController)||void 0===i||i.instanceCheck(e.iri,t).then((e=>{e.forEach((e=>{const t=this.ontology.getEntity(e);t&&r&&r.addParentClass(t.iri)}))}));else{const e=this.ontology.getEntity(t);e&&r.addParentClass(e.iri)}return this.updateEntityNameType(r.iri),this.lifecycle.trigger(Zx.DiagramUpdated),r}addIntensionalObjectProperty(e,t,n){const i=this.ontology.getEntity(e),r=this.ontology.getEntity(t),o=this.ontology.getEntity(n);i&&r&&o&&(this.performActionWithBlockedGraph((()=>{this.diagramBuilder.addObjectProperty(i,r,o),this.updateEntityNameType(i.iri),this.updateEntityNameType(t),this.updateEntityNameType(n)})),this.countInstancesForClass(t),this.countInstancesForClass(n))}addExtensionalObjectProperty(e,t,n){const i=this.ontology.getEntity(e),r=this.classInstanceEntities.get(t),o=this.classInstanceEntities.get(n);i&&r&&o&&this.performActionWithBlockedGraph((()=>{this.diagramBuilder.addObjectProperty(i,r,o),this.updateEntityNameType(i.iri),this.updateEntityNameType(r.iri),this.updateEntityNameType(o.iri)}))}showSuperHierarchiesOf(e){this.showOrHideHierarchies(e,"super","show")}showSubHierarchiesOf(e){this.showOrHideHierarchies(e,"sub","show")}hideSuperHierarchiesOf(e){this.showOrHideHierarchies(e,"super","hide")}hideSubHierarchiesOf(e){this.showOrHideHierarchies(e,"sub","hide")}showOrHideHierarchies(e,t,n){if(!this.ontology.getEntity(e))return;let i;const r=this.ontology.hierarchiesBySuperclassMap.get(e),o=this.ontology.hierarchiesBySubclassMap.get(e);switch(t){case"super":i=o;break;case"sub":i=r;break;case"any":i=[],r&&i.concat(r),o&&i.concat(o);break;default:return}i&&i.length>0&&this.performActionWithBlockedGraph((()=>{var t;const r=null===(t=this.grapholscape.renderer.cy)||void 0===t?void 0:t.$id(e).position();"show"===n?null==i||i.forEach((e=>this.addHierarchy(e,r))):null==i||i.forEach((t=>this.removeHierarchy(t,[e])))}))}addHierarchy(e,t){var n,i;const r=e.getUnionGrapholNode(t),o=e.getInputGrapholEdges(),a=e.getInclusionEdges();if(r&&o&&a){this.diagram.addElement(r);for(const t of e.inputs)this.addEntity(t,!1);for(const t of e.superclasses)this.addEntity(t.classIri,!1);null===(n=e.getInputGrapholEdges())||void 0===n||n.forEach((e=>this.diagram.addElement(e))),null===(i=e.getInclusionEdges())||void 0===i||i.forEach((e=>this.diagram.addElement(e)))}}removeHierarchy(e,t=[]){var n,i,r;if(!this.incrementalRenderer||!e.id||e.id&&(null===(n=this.grapholscape.renderer.cy)||void 0===n?void 0:n.$id(e.id).empty()))return;let o;this.diagram.removeElement(e.id),null===(i=e.getInputGrapholEdges())||void 0===i||i.forEach((e=>{var t;null===(t=this.diagram)||void 0===t||t.removeElement(e.id)})),null===(r=e.getInclusionEdges())||void 0===r||r.forEach((e=>{var t;null===(t=this.diagram)||void 0===t||t.removeElement(e.id)})),e.inputs.forEach((e=>{var n;0!==(null===(n=this.grapholscape.renderer.cy)||void 0===n?void 0:n.$id(e).degree(!1))||t.includes(e)||(o=this.ontology.getEntity(e),o&&this.removeEntity(o))})),e.superclasses.forEach((e=>{var n;0!==(null===(n=this.grapholscape.renderer.cy)||void 0===n?void 0:n.$id(e.classIri).degree(!1))||t.includes(e.classIri)||(o=this.ontology.getEntity(e.classIri),o&&this.removeEntity(o))}))}showSubClassesOf(e,t){t||(t=this.neighbourhoodFinder.getSubclassesIris(e)),this.showClassesInIsa(e,t,Pg.INCLUSION)}showSuperClassesOf(e,t){t||(t=this.neighbourhoodFinder.getSuperclassesIris(e)),this.showClassesInIsa(e,t,Pg.INCLUSION,"super")}showEquivalentClassesOf(e,t){t||(t=this.neighbourhoodFinder.getEquivalentClassesIris(e)),this.showClassesInIsa(e,t,Pg.EQUIVALENCE)}showClassesInIsa(e,t,n,i="sub"){this.performActionWithBlockedGraph((()=>{t.forEach((t=>{this.addEntity(t,!1),"super"===i?this.diagramBuilder.addEdge(e,t,n):this.diagramBuilder.addEdge(t,e,n)}))}))}getObjectPropertiesByClasses(t){var n,i,r;return e(this,void 0,void 0,(function*(){if(null===(n=this.endpointController)||void 0===n?void 0:n.isReasonerAvailable()){null===(i=this.endpointController.highlightsManager)||void 0===i||i.computeHighlights(t);const e=yield null===(r=this.endpointController.highlightsManager)||void 0===r?void 0:r.objectProperties(),n=new Map;return null==e||e.forEach((e=>{var t;if(!e.objectPropertyIRI)return;const i=this.ontology.getEntity(e.objectPropertyIRI);if(!i)return;const r={list:[],direct:e.direct||!1};null===(t=e.relatedClasses)||void 0===t||t.forEach((e=>{const t=this.ontology.getEntity(e);t&&r.list.push(t)})),n.set(i,r)})),n}return this.neighbourhoodFinder.getObjectProperties(t[0])}))}getDataPropertiesByClasses(t){var n,i,r;return e(this,void 0,void 0,(function*(){if(null===(n=this.endpointController)||void 0===n?void 0:n.isReasonerAvailable()){null===(i=this.endpointController.highlightsManager)||void 0===i||i.computeHighlights(t);const e=yield null===(r=this.endpointController.highlightsManager)||void 0===r?void 0:r.dataProperties();return(null==e?void 0:e.map((e=>this.ontology.getEntity(e))).filter((e=>null!==e)))||[]}return this.neighbourhoodFinder.getDataProperties(t[0])}))}getDataPropertiesByClassInstance(t){var n;return e(this,void 0,void 0,(function*(){const e=this.classInstanceEntities.get(t);return e&&(null===(n=this.endpointController)||void 0===n?void 0:n.highlightsManager)?(this.endpointController.highlightsManager.computeHighlights(e.parentClassIris.map((e=>e.fullIri))),(yield this.endpointController.highlightsManager.dataProperties()).map((e=>this.ontology.getEntity(e))).filter((e=>null!==e))):[]}))}postDiagramEdit(e){var t;this.numberOfElements!==e?(this.runLayout(),this.lifecycle.trigger(Zx.DiagramUpdated)):null===(t=this.incrementalRenderer)||void 0===t||t.unFreezeGraph()}countInstancesForClass(t){var n,i,r,o;return e(this,void 0,void 0,(function*(){if(!this.countersEnabled||!(null===(n=this.endpointController)||void 0===n?void 0:n.isReasonerAvailable()))return;const e=null===(r=null===(i=this.diagram)||void 0===i?void 0:i.representation)||void 0===r?void 0:r.cy.$id(t);if(e&&!e.empty())if(yield this.updateMaterializedCounts(),void 0===this.counts.get(t))null===(o=this.endpointController)||void 0===o||o.requestCountForClass(t);else{let n;const i=this.counts.get(t);e.scratch("instance-count")?(n=e.scratch("instance-count"),n.content=i.value):(n=bw(e,i.value,"instance-count","bottom"),setTimeout((()=>n.hide()),1e3),e.on("mouseover",(()=>{this.countersEnabled&&n.tippyWidget.show()})),e.on("mouseout",(()=>n.tippyWidget.hide()))),i.materialized?(n.highlighted=!1,n.title=`Date: ${i.date}`):(n.highlighted=!0,n.title="Fresh Value")}}))}updateMaterializedCounts(){var t;return e(this,void 0,void 0,(function*(){const e=yield null===(t=this.endpointController)||void 0===t?void 0:t.getMaterializedCounts();e&&e.countsMap.forEach((t=>{var n;if(t.state===Lx.FINISHED){const i=this.counts.get(t.entity.entityIRI);i&&!i.materialized||(this.counts.set(t.entity.entityIRI,{value:t.count,materialized:!0,date:0!==e.endTime?new Date(e.endTime).toDateString():new Date(e.startTime).toDateString()}),this.lifecycle.trigger(Zx.NewCountResult,t.entity.entityIRI,{value:t.count,materialized:!0,date:null===(n=this.counts.get(t.entity.entityIRI))||void 0===n?void 0:n.date}))}}))}))}setIncrementalEventHandlers(){var e,t,n,i;(null===(e=this.diagram.representation)||void 0===e?void 0:e.hasEverBeenRendered)||(null===(t=this.diagram.representation)||void 0===t?void 0:t.cy.scratch("_gscape-incremental-graph-handlers-set"))||(null===(n=this.diagram.representation)||void 0===n||n.cy.on("tap",(e=>{const t=e.target.data().type;if(t===Pg.CLASS||t===Pg.CLASS_INSTANCE){const n=()=>{var n,i;const r=e.target.data().iri;if(t===Pg.CLASS_INSTANCE){const e=this.classInstanceEntities.get(r);e&&(r!==this.lastInstanceIri&&(null===(n=this.endpointController)||void 0===n||n.stopRequests("instances")),this.lifecycle.trigger(Zx.ClassInstanceSelection,e))}else{r!==this.lastClassIri&&(null===(i=this.endpointController)||void 0===i||i.stopRequests("instances"));const e=this.grapholscape.ontology.getEntity(r);e&&this.lifecycle.trigger(Zx.ClassSelection,e)}};this.endpointController?(clearTimeout(this.entitySelectionTimeout),this.entitySelectionTimeout=setTimeout(n,400)):n()}})),null===(i=this.diagram.representation)||void 0===i||i.cy.scratch("_gscape-incremental-graph-handlers-set",!0))}get ontology(){return this.grapholscape.ontology}get incrementalRenderer(){if(this.grapholscape.renderState===Dg.INCREMENTAL)return this.grapholscape.renderer.renderState}get numberOfElements(){var e;return(null===(e=this.grapholscape.renderer.cy)||void 0===e?void 0:e.elements().size())||0}}function Cw(t){var n,i;let r,o=new _w(t);t.incremental=o,function(t){const n=new nw,i=t.grapholscape.widgets.get(Vg.ENTITY_DETAILS);i&&(i.incrementalSection=n),t.grapholscape.widgets.set(Vg.CLASS_INSTANCE_DETAILS,n),t.grapholscape.on(_f.EntitySelection,(i=>e(this,void 0,void 0,(function*(){let e;i.is(Pg.CLASS)&&t.grapholscape.renderState===Dg.INCREMENTAL?(e=yield t.getDataPropertiesByClasses([i.iri.fullIri]),n.dataProperties=e.map((e=>vb(e,t.grapholscape))),n.parentClasses=void 0,n.canShowDataPropertiesValues=!1,n.show()):n.hide()})))),t.on(Zx.ClassInstanceSelection,(r=>e(this,void 0,void 0,(function*(){var e;if(!(null==i?void 0:i.grapholEntity)||!(null==i?void 0:i.grapholEntity.iri.equals(r.iri))){null===(e=t.endpointController)||void 0===e||e.stopRequests("instances");const i=r.parentClassIris.map((e=>e.fullIri)),o=yield t.getDataPropertiesByClasses(i);n.dataProperties=o.map((e=>vb(e,t.grapholscape))),n.parentClasses=i.map((e=>{const n=t.grapholscape.ontology.getEntity(e);if(n)return vb(n,t.grapholscape)})).filter((e=>void 0!==e)),o.forEach((e=>{var n;null===(n=t.endpointController)||void 0===n||n.requestDataPropertyValues(r.iri.fullIri,e.iri.fullIri)}))}n.canShowDataPropertiesValues=!0,null==i||i.setGrapholEntity(r),n.show()})))),t.on(Zx.NewDataPropertyValues,((e,t,r)=>{(null==i?void 0:i.grapholEntity.iri.equals(e))&&r.forEach((e=>n.addDataPropertyValue(t,e)))})),t.on(Zx.DataPropertyValuesLoadingFinished,((e,t)=>{(null==i?void 0:i.grapholEntity.iri.equals(e))&&n.setDataPropertyLoading(t,!1)}))}(o),function(t){var n,i;const r=new iw;function o(){var e;null===(e=t.endpointController)||void 0===e||e.getRunningEndpoints().then((e=>{var n,i;r.endpoints=e.map((e=>({name:e.name}))).sort(((e,t)=>e.name.localeCompare(t.name))),e.length>=1&&!r.selectedEndpointName&&(null===(n=t.endpointController)||void 0===n||n.setEndpoint(e[0]),null===(i=t.endpointController)||void 0===i||i.setLanguage(t.grapholscape.language))}))}r.showCounters=t.countersEnabled,t.grapholscape.widgets.set(Vg.VKG_PREFERENCES,r),null===(i=null===(n=t.grapholscape.uiContainer)||void 0===n?void 0:n.querySelector(".gscape-ui-buttons-tray"))||void 0===i||i.appendChild(r),t.grapholscape.renderState===Dg.INCREMENTAL&&t.endpointController||r.disable(),t.endpointController&&o(),t.on(Zx.EndpointChange,(e=>{r.selectedEndpointName=e.name})),t.on(Zx.LimitChange,(e=>{r.pageSize=e})),t.on(Zx.ReasonerSet,(()=>{t.grapholscape.renderState===Dg.INCREMENTAL&&r.enable(),o(),t.endpointController&&(r.pageSize=t.endpointController.pageSize)})),r.onTogglePanel=()=>o(),r.onEndpointChange((n=>{var i;const r=new pb("Are you sure? \nIf you change the current endpoint, your exploration will be reset.");null===(i=t.grapholscape.uiContainer)||void 0===i||i.appendChild(r),r.show(),r.onConfirm=()=>e(this,void 0,void 0,(function*(){var e,i;t.reset(),null===(e=t.endpointController)||void 0===e||e.setEndpoint(n),null===(i=t.endpointController)||void 0===i||i.setLanguage(t.grapholscape.language)}))})),r.onPageSizeChange((e=>{var n;null===(n=t.endpointController)||void 0===n||n.setPageSize(e)})),r.onShowCountersChange((e=>{t.countersEnabled=e})),r.onStopRequests((()=>{var e;return null===(e=t.endpointController)||void 0===e?void 0:e.stopRequests()}))}(o),function(t){const n=new aw;t.grapholscape.widgets.set(Vg.INSTANCES_EXPLORER,n),t.on(Zx.NewInstances,((e,t)=>{n.addInstances(e.map((e=>{var t;return e[1]&&(e[0].searchMatch=null===(t=e[1].label)||void 0===t?void 0:t.value),e[0].connectedInstance=e[1],e[0]}))),!n.numberResultsAvailable&&t&&(n.numberResultsAvailable=t)})),t.on(Zx.InstancesSearchFinished,(()=>n.areInstancesLoading=!1)),t.on(Zx.Reset,(()=>{n.clear()})),n.addEventListener("instanceselection",(i=>e(this,void 0,void 0,(function*(){var e,r,o,a;let s;if(s=t.addInstance(i.detail.instance,i.detail.parentClassIris),s.parentClassIris.forEach((e=>{t.addEdge(i.detail.instance.iri,e.fullIri,Pg.INSTANCE_OF)})),i.detail.instance.connectedInstance&&i.detail.filterByProperty){t.addInstance(i.detail.instance.connectedInstance);const n=null===(a=null===(o=yield null===(r=null===(e=t.endpointController)||void 0===e?void 0:e.highlightsManager)||void 0===r?void 0:r.objectProperties())||void 0===o?void 0:o.find((e=>e.objectPropertyIRI===i.detail.filterByProperty)))||void 0===a?void 0:a.direct;void 0!==n&&(n?t.addExtensionalObjectProperty(i.detail.filterByProperty,i.detail.instance.iri,i.detail.instance.connectedInstance.iri):t.addExtensionalObjectProperty(i.detail.filterByProperty,i.detail.instance.connectedInstance.iri,i.detail.instance.iri))}if(n.referenceEntity&&n.referencePropertyEntity&&s){const e=n.referenceEntity.value.iri.fullIri,i=n.referencePropertyEntity.value.iri.fullIri;n.isPropertyDirect?t.addExtensionalObjectProperty(i,e,s.iri.fullIri):t.addExtensionalObjectProperty(i,s.iri.fullIri,e)}t.runLayout()})))),n.addEventListener("instances-filter",(i=>e(this,void 0,void 0,(function*(){var e,r,o,a;null===(e=t.endpointController)||void 0===e||e.stopRequests("instances"),n.instances=new Map,n.numberOfInstancesReceived=0,n.numberResultsAvailable=0,n.numberOfPagesShown=1,n.areInstancesLoading=!0,n.referenceEntity&&(n.referenceEntity.value.type===Pg.CLASS?n.requestId=yield null===(r=t.endpointController)||void 0===r?void 0:r.requestInstancesForClass(null===(o=n.referenceEntity)||void 0===o?void 0:o.value.iri.fullIri,i.detail.shouldAskForLabels,i.detail.filterText,i.detail.filterByProperty,i.detail.propertyType,i.detail.direct):n.referenceEntity.value.type===Pg.CLASS_INSTANCE&&n.referencePropertyEntity&&(n.requestId=yield null===(a=t.endpointController)||void 0===a?void 0:a.requestInstancesThroughObjectProperty(n.referenceEntity.value.iri.fullIri,n.referencePropertyEntity.value.iri.fullIri,n.isPropertyDirect,i.detail.shouldAskForLabels,i.detail.filterByType,i.detail.filterByProperty,i.detail.filterText)))})))),n.addEventListener("showmoreinstances",(i=>e(this,void 0,void 0,(function*(){var e,i;null===(e=t.endpointController)||void 0===e||e.stopRequests("instances"),n.areInstancesLoading=!0,n.requestId&&(null===(i=t.endpointController)||void 0===i||i.requestNewInstances(n.requestId,n.numberOfPagesShown+1))})))),n.tippyWidget.setProps({onHide:()=>{n.hide(),rw(n,t)}})}(o),hw(o),fw(o),function(t){const n=new xw;t.grapholscape.widgets.set(Vg.NAVIGATION_MENU,n),n.requestUpdate(),n.addEventListener("onclassselection",(e=>{e.detail.rangeClassIri&&(e.detail.direct?t.addIntensionalObjectProperty(e.detail.objectPropertyIri,e.detail.referenceClassIri,e.detail.rangeClassIri):t.addIntensionalObjectProperty(e.detail.objectPropertyIri,e.detail.rangeClassIri,e.detail.referenceClassIri),setTimeout((()=>{t.grapholscape.centerOnElement(e.detail.rangeClassIri)}),250),n.popperRef=void 0,n.hide())})),n.addEventListener("onobjectpropertyselection",(i=>e(this,void 0,void 0,(function*(){var r,o,a,s,l,c,u,d,h;const p=t.grapholscape.widgets.get(Vg.INSTANCES_EXPLORER);if(p){const g=t.classInstanceEntities.get(i.detail.referenceClassIri),f=t.grapholscape.ontology.getEntity(i.detail.objectPropertyIri);if(g&&f&&(!(null===(r=p.referenceEntity)||void 0===r?void 0:r.value.iri.equals(g.iri))||!(null===(o=p.referencePropertyEntity)||void 0===o?void 0:o.value.iri.equals(f.iri)))){if(n.hide(),p.clear(),p.areInstancesLoading=!0,p.referenceEntity=n.referenceEntity,p.referencePropertyEntity=vb(f,t.grapholscape),p.isPropertyDirect=i.detail.direct,p.classTypeFilterList=null===(a=n.objectProperties.find((e=>e.entityViewData.value.iri.equals(i.detail.objectPropertyIri))))||void 0===a?void 0:a.connectedClasses,1===(null===(s=p.classTypeFilterList)||void 0===s?void 0:s.length)){const e=null===(c=null===(l=t.endpointController)||void 0===l?void 0:l.highlightsManager)||void 0===c?void 0:c.hasUnfoldings.bind(t.endpointController.highlightsManager);p.propertiesFilterList=(yield t.getDataPropertiesByClasses([p.classTypeFilterList[0].entityViewData.value.iri.fullIri])).map((n=>yb(n,t.grapholscape,e)))}p.requestId=yield null===(u=t.endpointController)||void 0===u?void 0:u.requestInstancesThroughObjectProperty(g.iri.fullIri,i.detail.objectPropertyIri,i.detail.direct,!0,i.detail.rangeClassIri),p.requestId&&(null===(h=null===(d=t.endpointController)||void 0===d?void 0:d.shouldQueryUseLabels(p.requestId))||void 0===h||h.then((n=>e(this,void 0,void 0,(function*(){var e;n||(p.shouldAskForLabels=n,p.areInstancesLoading=!0,p.requestId=yield null===(e=t.endpointController)||void 0===e?void 0:e.requestInstancesThroughObjectProperty(g.iri.fullIri,i.detail.objectPropertyIri,i.detail.direct,n,i.detail.rangeClassIri))})))))}n.popperRef&&gw(p,t)}})))),n.tippyWidget.setProps({onHide:()=>rw(n,t)})}(o),o.grapholscape.widgets.get(Vg.ENTITY_SELECTOR)||Tb(o.grapholscape),r=t.widgets.get(Vg.ENTITY_SELECTOR),null===(n=o.grapholscape.uiContainer)||void 0===n||n.appendChild(r),r.hide(),r.onClassSelection((e=>{const n={x:200*Math.random(),y:200*Math.random()};o.addEntity(e,!0,n),t.selectElement(e),ww(r),r.closePanel()})),t.renderState===Dg.INCREMENTAL?(t.renderer.unselect(),Sw(t.widgets,null===(i=t.renderer.cy)||void 0===i?void 0:i.elements().empty(),void 0!==o.endpointController)):Tw(t.widgets),t.on(_f.RendererChange,(e=>{e===Dg.INCREMENTAL?function(e,t){var n;e.renderer.unselect(),Sw(e.widgets,null===(n=e.renderer.cy)||void 0===n?void 0:n.elements().empty(),void 0!==t.endpointController)}(t,o):Tw(t.widgets)})),o.on(Zx.DiagramUpdated,(()=>{var e,n;const i=t.widgets.get(Vg.ENTITY_SELECTOR);(null===(e=t.renderer.cy)||void 0===e?void 0:e.elements().empty())?(null===(n=t.widgets.get(Vg.ENTITY_DETAILS))||void 0===n||n.hide(),i&&(Ew(i),i.focusInputSearch())):i&&ww(i);const r=t.widgets.get(Vg.ONTOLOGY_EXPLORER);r&&(r.entities=wb(t,r.searchEntityComponent))})),o.on(Zx.Reset,(()=>{var e;o.grapholscape.renderState===Dg.INCREMENTAL&&Sw(t.widgets,null===(e=t.renderer.cy)||void 0===e?void 0:e.elements().empty(),void 0!==o.endpointController)}))}function Sw(e,t=!1,n){const i=e.get(Vg.FILTERS),r=e.get(Vg.DIAGRAM_SELECTOR),o=e.get(Vg.ENTITY_SELECTOR),a=e.get(Vg.CLASS_INSTANCE_DETAILS),s=e.get(Vg.VKG_PREFERENCES);e.get(Vg.ENTITY_DETAILS).showOccurrences=!1,null==a||a.enable(),null==r||r.disable(),null==o||o.show(),t&&o&&(Ew(o),o.focusInputSearch()),n&&(null==s||s.enable()),null==i||i.disable()}function Tw(e){const t=e.get(Vg.FILTERS),n=e.get(Vg.DIAGRAM_SELECTOR),i=e.get(Vg.ENTITY_SELECTOR),r=e.get(Vg.CLASS_INSTANCE_DETAILS),o=e.get(Vg.VKG_PREFERENCES);e.get(Vg.ENTITY_DETAILS).showOccurrences=!0,null==r||r.disable(),null==o||o.disable(),null==n||n.enable(),null==i||i.hide(),null==t||t.enable()}function Iw(t,n,i){return e(this,void 0,void 0,(function*(){const e=yield kw(t,n,i);return e&&(yx(e),(!1===(null==i?void 0:i.initialRendererSelection)||e.renderState)&&e.widgets.get(Vg.INITIAL_RENDERER_SELECTOR).hide(),e.renderers.includes(Dg.INCREMENTAL)&&Cw(e)),e}))}function Pw(t,n,i){return e(this,void 0,void 0,(function*(){const e=yield kw(t,n,i);return(null==e?void 0:e.renderers.includes(Dg.INCREMENTAL))&&Cw(e),e}))}function kw(t,n,i){return e(this,void 0,void 0,(function*(){if(!t||!n)return void console.error("Please specify an ontology and a container for Grapholscape");const e=jg();return i=Object.assign(i||{},e),new Promise(((e,o)=>{let a;if("object"==typeof t){let e=new FileReader;e.onloadend=()=>{try{a=r(e.result),s()}catch(e){o(e)}},e.readAsText(t),setTimeout((()=>{o("Error: timeout expired")}),1e4)}else"string"==typeof t?(a=r(t),s()):o("Err: Grapholscape needs a Graphol File or the corresponding string to be initialized");function s(){try{const t=new Nx(a,n,i);e(t)}catch(e){console.error(e)}}}));function r(e){return new Wf(e).parseGraphol()}}))}Hd.use(Ag),Hd.use(Uh),Hd.warnings(!1);export{Og as AnnotatedElement,sf as Annotation,Ig as AnnotationsKind,xf as BaseFilterManager,Ef as BaseRenderer,Sf as Breakpoint,ff as CSS_PROPERTY_NAMESPACE,bf as ClassInstanceEntity,cf as ColoursNames,Rg as ConstructorLabelsEnum,yf as DefaultFilterKeyEnum,gf as DefaultThemes,uf as DefaultThemesEnum,nf as Diagram,tf as DiagramRepresentation,Yg as EntityNameType,vf as Filter,Db as FloatyRendererState,Qg as FunctionalityEnum,Zg as GrapholEdge,Wg as GrapholElement,Xg as GrapholEntity,Jg as GrapholNode,Lg as GrapholNodesEnum,$b as GrapholRendererState,Pg as GrapholTypesEnum,Nx as Grapholscape,lf as GrapholscapeTheme,If as Hierarchy,_w as IncrementalController,rf as IncrementalDiagram,zb as IncrementalRendererState,af as Iri,Gg as Language,Cf as Lifecycle,_f as LifecycleEvent,Fb as LiteRendererState,of as Namespace,Mg as Ontology,Ng as POLYGON_POINTS,kx as Renderer,Dg as RendererStatesEnum,kg as Shape,Pw as bareGrapholscape,hf as classicColourMap,Ug as clearLocalStorage,pf as darkColourMap,zg as floatyOptions,Iw as fullGrapholscape,mf as getDefaultFilters,$g as grapholOptions,df as gscapeColourMap,Cw as initIncremental,Kg as isGrapholEdge,ef as isGrapholNode,Bg as liteOptions,jg as loadConfig,Ax as setGraphEventHandlers,qg as storeConfigEntry,Cx as toPNG,Sx as toSVG,bx as ui,mb as util}; diff --git a/dist/grapholscape.min.js b/dist/grapholscape.min.js index 46ce6422..1985c2af 100644 --- a/dist/grapholscape.min.js +++ b/dist/grapholscape.min.js @@ -1363,7 +1363,7 @@ input { } `],customElements.define("gscape-select",gb);var yb=Object.freeze({__proto__:null,capitalizeFirstChar:lb,grapholEntityToEntityViewData:fb,getEntityViewDataUnfolding:vb});function mb(t,n){var r,i;const o=new Map;return null===(r=t.occurrences.get(e.RendererStatesEnum.GRAPHOL))||void 0===r||r.forEach((e=>{a(e)})),n.renderState&&n.renderState!==e.RendererStatesEnum.GRAPHOL&&(null===(i=t.occurrences.get(n.renderState))||void 0===i||i.forEach((e=>{a(e)}))),o;function a(e){var t,r,i;if(!n.renderState)return;const a=n.ontology.getDiagram(e.diagramId)||n.renderer.diagram,s=null===(r=null===(t=null==a?void 0:a.representations.get(n.renderState))||void 0===t?void 0:t.cy)||void 0===r?void 0:r.$id(e.elementId);if(a&&s&&!s.empty()){const t={realId:e.elementId,originalId:s.data().originalId},n=Array.from(o).find((([e,t])=>e.id===a.id));let r;n?r=n[0]:(r={id:a.id,name:a.name},o.set(r,[])),null===(i=o.get(r))||void 0===i||i.push(t)}}}function bb(e,t){function n(e){var n;const r=e.target,i=null===(n=r.parentElement)||void 0===n?void 0:n.getAttribute("diagram-id"),o=r.getAttribute("real-id");i&&o&&t({diagramId:parseInt(i),elementId:o})}return kv` ${Array.from(e).map((([e,t])=>kv` -
+
${e.name} ${t.map((e=>kv` - `}diagramSelectionHandler(e){const t=parseInt(e.target.getAttribute("diagram-id")||"");this.onDiagramSelection(t)}get currentDiagram(){return this.diagrams.find((e=>e.id===this.currentDiagramId))}}function Ub(t){const n=new Hb;!function(t,n){t.diagrams=n.ontology.diagrams,(n.diagramId||0===n.diagramId)&&(t.currentDiagramId=n.diagramId),t.onDiagramSelection=e=>n.showDiagram(e),n.on(e.LifecycleEvent.DiagramChange,(e=>t.currentDiagramId=e.id))}(n,t),t.widgets.set(Fg.DIAGRAM_SELECTOR,n)}function Yb(t,n){return kv` + `}diagramSelectionHandler(e){const t=parseInt(e.target.getAttribute("diagram-id")||"");this.onDiagramSelection(t)}get currentDiagram(){return this.diagrams.find((e=>e.id===this.currentDiagramId))}}function Ub(t){const n=new Hb;!function(t,n){t.diagrams=n.ontology.diagrams,(n.diagramId||0===n.diagramId)&&(t.currentDiagramId=n.diagramId),t.onDiagramSelection=e=>n.showDiagram(e),n.on(e.LifecycleEvent.DiagramChange,(e=>{t.diagrams.includes(e)&&(t.currentDiagramId=e.id)}))}(n,t),t.widgets.set(Fg.DIAGRAM_SELECTOR,n)}function Yb(t,n){return kv`
{}}static get properties(){return{grapholEntity:{type:Object,attribute:!1},occurrences:{type:Object,attribute:!1},language:{type:String,attribute:!1},_isPanelClosed:{type:Boolean,attribute:!1},incrementalSection:{type:Object,attribute:!1}}}render(){if(this.grapholEntity)return kv` +`;class Zb extends(sm(am(Zv))){constructor(){super(...arguments),this.title="Entity Details",this.showOccurrences=!0,this.onNodeNavigation=()=>{}}static get properties(){return{grapholEntity:{type:Object,attribute:!1},occurrences:{type:Object,attribute:!1},showOccurrences:{type:Boolean},language:{type:String,attribute:!1},_isPanelClosed:{type:Boolean,attribute:!1},incrementalSection:{type:Object,attribute:!1}}}render(){if(this.grapholEntity)return kv`
${this.grapholEntity.is(e.GrapholTypesEnum.CLASS_INSTANCE)?Yb(this.entityForTemplate):Yb(this.entityForTemplate,this.onWikiLinkClick)} @@ -1700,7 +1700,7 @@ input { ${Xb(this.grapholEntity.getAnnotations())} - ${!this.incrementalSection&&this.occurrences.size>0?this.occurrencesTemplate():null} + ${this.showOccurrences&&this.occurrences.size>0?this.occurrencesTemplate():null} ${this.grapholEntity.getComments().length>0?kv`
@@ -1746,7 +1746,7 @@ input { ${bb(this.occurrences,this.onNodeNavigation)}
- `}blur(){}setGrapholEntity(e){}languageSelectionHandler(e){this.language=e.target.value}get entityForTemplate(){return{name:this.grapholEntity.iri.remainder,typeOrVersion:this.grapholEntity.type.toString(),iri:this.grapholEntity.iri.fullIri}}get commentsLanguages(){return Array.from(new Set(this.grapholEntity.getComments().map((e=>e.language))))}updated(){var e;const t=null===(e=this.grapholEntity)||void 0===e?void 0:e.getComments();if(!t||0===t.length)return;0===this.grapholEntity.getComments(this.language).length&&(this.language=t[0].language)}}function Kb(t){const n=new Zb;!function(t,n){function r(r){t.grapholEntity=r,t.occurrences=mb(r,n),t.language=n.language,t.show(),n.lifecycle.entityWikiLinkClick.length>0&&!t.onWikiLinkClick&&(t.onWikiLinkClick=t=>{n.lifecycle.trigger(e.LifecycleEvent.EntityWikiLinkClick,t)})}t.onNodeNavigation=e=>{n.centerOnElement(e.elementId,e.diagramId,1.2),n.selectElement(e.elementId)},t.language=n.language,t.setGrapholEntity=r,n.on(e.LifecycleEvent.EntitySelection,r),n.on(e.LifecycleEvent.NodeSelection,(e=>{e.isEntity()||t.hide()})),n.on(e.LifecycleEvent.EdgeSelection,(e=>{e.isEntity()||t.hide()})),n.on(e.LifecycleEvent.LanguageChange,(e=>{t.language=e})),n.on(e.LifecycleEvent.RendererChange,(e=>{t.grapholEntity&&(t.occurrences=mb(t.grapholEntity,n))}))}(n,t),t.widgets.set(Fg.ENTITY_DETAILS,n)}Zb.styles=[rm,Qb,Wb,im,tv` + `}blur(){}setGrapholEntity(e){}languageSelectionHandler(e){this.language=e.target.value}get entityForTemplate(){return{name:this.grapholEntity.iri.remainder,typeOrVersion:this.grapholEntity.type.toString(),iri:this.grapholEntity.iri.fullIri}}get commentsLanguages(){return Array.from(new Set(this.grapholEntity.getComments().map((e=>e.language))))}updated(){var e;const t=null===(e=this.grapholEntity)||void 0===e?void 0:e.getComments();if(!t||0===t.length)return;0===this.grapholEntity.getComments(this.language).length&&(this.language=t[0].language)}}function Kb(t){const n=new Zb;!function(t,n){function r(r){t.grapholEntity=r,t.occurrences=mb(r,n),t.language=n.language,t.show(),n.lifecycle.entityWikiLinkClick.length>0&&!t.onWikiLinkClick&&(t.onWikiLinkClick=t=>{n.lifecycle.trigger(e.LifecycleEvent.EntityWikiLinkClick,t)})}t.onNodeNavigation=e=>{n.centerOnElement(e.elementId,e.diagramId,1.2),n.selectElement(e.elementId)},t.language=n.language,t.setGrapholEntity=r,n.on(e.LifecycleEvent.EntitySelection,r),n.on(e.LifecycleEvent.NodeSelection,(e=>{e.isEntity()||t.hide()})),n.on(e.LifecycleEvent.EdgeSelection,(e=>{e.isEntity()||t.hide()})),n.on(e.LifecycleEvent.LanguageChange,(e=>{t.language=e})),n.on(e.LifecycleEvent.RendererChange,(r=>{t.grapholEntity&&n.renderState!==e.RendererStatesEnum.INCREMENTAL&&(t.occurrences=mb(t.grapholEntity,n)),t.showOccurrences=n.renderState!==e.RendererStatesEnum.INCREMENTAL}))}(n,t),t.widgets.set(Fg.ENTITY_DETAILS,n)}Zb.styles=[rm,Qb,Wb,im,tv` :host { position: absolute; top:10px; @@ -2267,7 +2267,7 @@ input {
Version: - ${"3.2.4"} + ${"3.2.5"}
@@ -2727,7 +2727,7 @@ gscape-entity-list-item:hover > .hover-btn { `:this.numberOfPagesShown>1?kv`No more data`:null}
- `}handleFilter(t){var n,r,i,o;const a=this.instancesSearchInput;if(!a)return;const s=new CustomEvent("instances-filter",{bubbles:!0,composed:!0,detail:{filterText:a.value.length>0?a.value:void 0,filterByProperty:void 0,filterByType:void 0}});if((null===(n=this.propertyFilterSelect)||void 0===n?void 0:n.selectedOptionId)&&"id"!==this.propertyFilterSelect.selectedOptionId&&"label"!==this.propertyFilterSelect.selectedOptionId&&s.detail.filterText){s.detail.filterByProperty=this.propertyFilterSelect.selectedOptionId;const t=this.propertiesFilterList.find((e=>{var t;return(null===(t=this.propertyFilterSelect)||void 0===t?void 0:t.selectedOptionId)&&e.entityViewData.value.iri.equals(this.propertyFilterSelect.selectedOptionId)}));t&&(s.detail.propertyType=t.entityViewData.value.type,t.entityViewData.value.type===e.GrapholTypesEnum.OBJECT_PROPERTY&&(s.detail.direct=t.direct))}1===(null===(r=this.classTypeFilterList)||void 0===r?void 0:r.length)?s.detail.filterByType=this.classTypeFilterList[0].entityViewData.value.iri.fullIri:this.classTypeFilterSelect&&(s.detail.filterByType=this.classTypeFilterSelect.selectedOptionId),void 0!==this.shouldAskForLabels&&(s.detail.shouldAskForLabels=this.shouldAskForLabels&&"id"!==(null===(i=this.propertyFilterSelect)||void 0===i?void 0:i.selectedOptionId)),"id"===(null===(o=this.propertyFilterSelect)||void 0===o?void 0:o.selectedOptionId)&&(s.detail.shouldAskForLabels=!1),this.lastSearchedText=s.detail.filterText||"",this.numberOfPagesShown=1,this.dispatchEvent(s)}handleInputKeypress(e){const t=e.target;"Escape"===e.key&&(t.blur(),t.value=""),clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((()=>{this.handleFilter()}),500)}handleFilterChange(){var e,t;null===(t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#instances-search"))||void 0===t||t.focus()}handleClassTypeFilterChange(e){var t;(null===(t=this.classTypeFilterSelect)||void 0===t?void 0:t.selectedOptionId)||(this.propertiesFilterList=[]),this.handleFilter(e)}handleInsertInGraph(n){var r,i,o,a,s,l,u,c;return t(this,void 0,void 0,(function*(){const t=null===(r=n.currentTarget.parentElement)||void 0===r?void 0:r.parentElement;if(t){const n=this.instances.get(t.iri);if(n){let t,r;if((null===(i=this.referenceEntity)||void 0===i?void 0:i.value.type)===e.GrapholTypesEnum.CLASS)t=null===(o=this.referenceEntity)||void 0===o?void 0:o.value.iri.fullIri;else{if((null===(a=this.referenceEntity)||void 0===a?void 0:a.value.type)!==e.GrapholTypesEnum.CLASS_INSTANCE)return;if(1===(null===(s=this.classTypeFilterList)||void 0===s?void 0:s.length))t=this.classTypeFilterList[0].entityViewData.value.iri.fullIri;else if(null===(l=this.classTypeFilterSelect)||void 0===l?void 0:l.selectedOptionId)t=this.classTypeFilterSelect.selectedOptionId;else{if(!this.classTypeFilterList)return;t=this.classTypeFilterList.map((e=>e.entityViewData.value.iri.fullIri))}}(null===(u=this.propertyFilterSelect)||void 0===u?void 0:u.selectedOptionId)&&"id"!==this.propertyFilterSelect.selectedOptionId&&"label"!==this.propertyFilterSelect.selectedOptionId&&(null===(c=this.instancesSearchInput)||void 0===c?void 0:c.value)&&(r=this.propertyFilterSelect.selectedOptionId),this.requestUpdate(),yield this.updateComplete,this.dispatchEvent(new CustomEvent("instanceselection",{bubbles:!0,composed:!0,detail:{parentClassIris:t,instance:n,filterByProperty:r}}))}}}))}handleShowMore(e){this.dispatchEvent(new CustomEvent("showmoreinstances",{bubbles:!0,composed:!0})),this.numberOfPagesShown+=1}addInstances(e){this.numberOfInstancesReceived+=e.length,e.forEach((e=>{const t=e.connectedInstance?`${e.iri}-${e.connectedInstance.iri}`:e.iri;this.instances.has(t)||this.instances.set(t,e)})),this.requestUpdate()}clear(){this.instances=new Map,this.numberOfPagesShown=1,this.numberOfInstancesReceived=0,this.areInstancesLoading=!1,this.propertiesFilterList=[],this.classTypeFilterList=[],this.referenceEntity=void 0,this.referencePropertyEntity=void 0,this.popperRef=void 0,this.shouldAskForLabels=void 0,this.numberResultsAvailable=0,this.lastSearchedText="",this.instancesSearchInput&&(this.instancesSearchInput.value="")}updated(){this.popperRef&&this.attachTo(this.popperRef)}attachTo(e){this.popperRef=e,super.attachTo(e)}getHighlightInSearchMatch(e){if(this.lastSearchedText.length>0&&" "!==this.lastSearchedText){const t=e.toLowerCase().search(this.lastSearchedText.toLowerCase());if(t>=0){const n=t+this.lastSearchedText.length-1;return{preString:e.substring(0,t),highlightString:e.substring(t,n+1),postString:e.substring(n+1,e.length)}}}return{preString:e,highlightString:void 0,postString:void 0}}get canShowMore(){return this.numberResultsAvailable?this.numberOfInstancesReceived0}get propertyFilterSelect(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#property-filter-select")}get classTypeFilterSelect(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#classtype-filter-select")}get instancesSearchInput(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#instances-search")}hide(){this.style.display="none"}}function ax(e,t){return{content:(e?"Hide":"Show")+" Super Hierarchies",icon:My,select:t}}function sx(e,t){return{content:(e?"Hide":"Show")+" Super Classes",icon:My,select:t}}function lx(e,t){return{content:(e?"Hide":"Show")+" Sub Hierarchies",icon:$y,select:t}}function ux(e,t){return{content:(e?"Hide":"Show")+" Sub Classes",icon:$y,select:t}}function cx(e,t){return{content:(e?"Hide":"Show")+" Equivalent Classes",icon:zy,select:t}}function dx(n){const r=new Wm;n.grapholscape.on(e.LifecycleEvent.ContextClick,(i=>{var o,a;const s=[];if(i.target===n.grapholscape.renderer.cy||!i.target.data().iri)return;const l=n.classInstanceEntities.get(i.target.data().iri)||n.grapholscape.ontology.getEntity(i.target.data().iri);if(!l)return;var u;l.is(e.GrapholTypesEnum.CLASS_INSTANCE)&&!l.isRDFTypeUnknown&&(s.push((u=()=>t(this,void 0,void 0,(function*(){var t;const r=n.grapholscape.ontology.getEntitiesByType(e.GrapholTypesEnum.CLASS).map((e=>e.iri.fullIri)),i=yield null===(t=n.endpointController)||void 0===t?void 0:t.instanceCheck(l.iri.fullIri,r);null==i||i.forEach((e=>{const t=n.grapholscape.ontology.getEntity(e);t&&l.addParentClass(t.iri)})),hx(n,l)})),{content:"Compute and Show Parent Classes",icon:Jv,select:u})),s.push(function(e){return{content:"Show Current Parent Classes",icon:Jv,select:e}}((()=>hx(n,l)))));const c=l.iri.fullIri;if(l.is(e.GrapholTypesEnum.CLASS)){const e=n.grapholscape.ontology.hierarchiesBySubclassMap.get(c),t=n.grapholscape.ontology.hierarchiesBySuperclassMap.get(c);if(e&&e.length>0){const t=n.areHierarchiesVisible(e);s.push(ax(t,(()=>{t?n.hideSuperHierarchiesOf(c):n.showSuperHierarchiesOf(c)})))}if(t&&t.length>0){const e=n.areHierarchiesVisible(t);s.push(lx(e,(()=>{e?n.hideSubHierarchiesOf(c):n.showSubHierarchiesOf(c)})))}const r=n.neighbourhoodFinder.getSubclassesIris(c),i=n.neighbourhoodFinder.getSuperclassesIris(c),a=n.neighbourhoodFinder.getEquivalentClassesIris(c);if(r.length>0){const e=n.areAllConnectedClassesVisibleForClass(c,r,"sub");s.push(ux(e,(()=>{e?r.forEach((e=>n.removeEntity(e,[c]))):n.showSubClassesOf(c,r)})))}if(i.length>0){const e=n.areAllConnectedClassesVisibleForClass(c,i,"super");s.push(sx(e,(()=>{e?i.forEach((e=>n.removeEntity(e,[c]))):n.showSuperClassesOf(c,i)})))}if(a.length>0){const e=n.areAllConnectedClassesVisibleForClass(c,a,"equivalent");s.push(cx(e,(()=>{e?a.forEach((e=>n.removeEntity(e,[c]))):n.showEquivalentClassesOf(c,a)})))}(null===(o=n.endpointController)||void 0===o?void 0:o.isReasonerAvailable())&&n.countersEnabled&&s.push({icon:Hy,content:"Count Instances",select:()=>{var e;null===(e=n.endpointController)||void 0===e||e.requestCountForClass(l.iri.fullIri)}})}!l.is(e.GrapholTypesEnum.CLASS_INSTANCE)&&(null===(a=n.endpointController)||void 0===a?void 0:a.isReasonerAvailable())&&s.push({content:"Data Lineage",icon:Xy,select:()=>n.onShowDataLineage(l.iri.fullIri)}),s.push(function(e){return{content:"Remove",icon:By,select:e}}((()=>{l.is(e.GrapholTypesEnum.OBJECT_PROPERTY)?(n.diagram.removeElement(i.target.id()),l.removeOccurrence(i.target.id(),n.diagram.id,e.RendererStatesEnum.INCREMENTAL),n.lifecycle.trigger(WE.DiagramUpdated)):n.removeEntity(l.iri.fullIri)})));try{if(i.target.isEdge()&&n.grapholscape.uiContainer)r.attachToPosition(i.renderedPosition,n.grapholscape.uiContainer,s);else{const e=i.target.popperRef();e&&s.length>0&&r.attachTo(e,s)}}catch(e){console.error(e)}}))}function hx(t,n){const r=n.parentClassIris;t.performActionWithBlockedGraph((()=>{null==r||r.forEach((r=>{t.addEntity(r.fullIri,!1),t.addEdge(n.iri.fullIri,r.fullIri,e.GrapholTypesEnum.INSTANCE_OF)}))})),1===(null==r?void 0:r.length)&&setTimeout((()=>{t.grapholscape.centerOnElement(r[0].fullIri)}),250)}function px(e,t){if(e.referenceEntity){const n=t.grapholscape.renderer.cy;if(n){const r=n.$id(e.referenceEntity.value.iri.fullIri);r&&(e.attachTo(r.popperRef()),e.show(),r.data().pinned||(r.scratch("should-unpin",!0),t.pinNode(r)))}}}function gx(n){const r=new yE(ey);r.title="Search instances";const i=new yE(ry);i.title="Navigate through object properties";const o=new Map;o.set(e.GrapholTypesEnum.CLASS,[i]),o.set(e.GrapholTypesEnum.CLASS_INSTANCE,[i]),r.onclick=r=>function(n,r){var i,o,a,s,l,u;return t(this,void 0,void 0,(function*(){const c=n.currentTarget,d=r.grapholscape.widgets.get(Fg.INSTANCES_EXPLORER);if(d&&c.node&&c.node.data().iri){const n=r.grapholscape.ontology.getEntity(c.node.data().iri);if(n&&n.type===e.GrapholTypesEnum.CLASS&&(!d.referenceEntity||!d.referenceEntity.value.iri.equals(n.iri)||0===d.numberOfInstancesReceived)){d.clear(),d.areInstancesLoading=!0,d.referenceEntity=fb(n,r.grapholscape);const e=null===(o=null===(i=r.endpointController)||void 0===i?void 0:i.highlightsManager)||void 0===o?void 0:o.hasUnfoldings.bind(null===(a=r.endpointController)||void 0===a?void 0:a.highlightsManager),c=yield r.getDataPropertiesByClasses([n.iri.fullIri]),h=yield r.getObjectPropertiesByClasses([n.iri.fullIri]),p=Array.from(h).map((([t,n])=>{let i=vb(t,r.grapholscape,e);return{entityViewData:i.entityViewData,loading:i.loading,hasUnfolding:i.hasUnfolding,connectedClasses:[],direct:n.direct}}));d.propertiesFilterList=c.map((t=>vb(t,r.grapholscape,e))).concat(p).sort(((e,t)=>e.entityViewData.displayedName.localeCompare(t.entityViewData.displayedName))),d.requestId=yield null===(s=r.endpointController)||void 0===s?void 0:s.requestInstancesForClass(n.iri.fullIri),d.requestId&&(null===(u=null===(l=r.endpointController)||void 0===l?void 0:l.shouldQueryUseLabels(d.requestId))||void 0===u||u.then((e=>t(this,void 0,void 0,(function*(){var t;e||(d.shouldAskForLabels=e,d.areInstancesLoading=!0,d.requestId=yield null===(t=r.endpointController)||void 0===t?void 0:t.requestInstancesForClass(n.iri.fullIri,e))})))))}c.node&&px(d,r)}}))}(r,n),i.onclick=r=>function(n,r){var i,o,a;return t(this,void 0,void 0,(function*(){const t=n.currentTarget,s=r.grapholscape.widgets.get(Fg.NAVIGATION_MENU);if(s&&t.node&&t.node.data().iri){let n,l=new Map;if(t.node.data().type===e.GrapholTypesEnum.CLASS){if(n=r.grapholscape.ontology.getEntity(t.node.data().iri),!n)return;s.referenceEntity=fb(n,r.grapholscape),s.canShowObjectPropertiesRanges=!0,l=yield r.getObjectPropertiesByClasses([t.node.data().iri])}else if(t.node.data().type===e.GrapholTypesEnum.CLASS_INSTANCE){if(n=r.classInstanceEntities.get(t.node.data().iri),!n)return;s.referenceEntity=fb(n,r.grapholscape),s.canShowObjectPropertiesRanges=!1;const e=n.parentClassIris.map((e=>e.fullIri));l=yield r.getObjectPropertiesByClasses(e)}const u=null===(o=null===(i=r.endpointController)||void 0===i?void 0:i.highlightsManager)||void 0===o?void 0:o.hasUnfoldings.bind(null===(a=r.endpointController)||void 0===a?void 0:a.highlightsManager);s.objectProperties=Array.from(l).map((e=>{const t=vb(e[0],r.grapholscape,u);return t.connectedClasses=e[1].list.map((e=>vb(e,r.grapholscape,u))),t.direct=e[1].direct,t})),t.node&&px(s,r)}}))}(r,n),n.grapholscape.renderState===e.RendererStatesEnum.INCREMENTAL&&n.diagram.representation&&fx(n.diagram.representation.cy,o),n.grapholscape.on(e.LifecycleEvent.RendererChange,(t=>{t===e.RendererStatesEnum.INCREMENTAL&&n.diagram.representation&&fx(n.diagram.representation.cy,o)})),n.on(WE.Reset,(()=>{n.grapholscape.renderState===e.RendererStatesEnum.INCREMENTAL&&n.diagram.representation&&(fx(n.diagram.representation.cy,o),n.grapholscape.container.querySelectorAll("[data-tippy-root]").forEach((e=>e.remove())))})),n.on(WE.EndpointChange,(()=>{var t,n;(null===(t=o.get(e.GrapholTypesEnum.CLASS))||void 0===t?void 0:t.includes(r))||null===(n=o.get(e.GrapholTypesEnum.CLASS))||void 0===n||n.push(r)})),n.on(WE.InstanceCheckingStarted,(e=>{var t;const r=null===(t=n.diagram.representation)||void 0===t?void 0:t.cy.$id(e);r&&(r.addClass("unknown-parent-class"),mx(r,tb(),"loading-badge"))})),n.on(WE.InstanceCheckingFinished,(e=>{var t;const r=null===(t=n.diagram.representation)||void 0===t?void 0:t.cy.$id(e);r&&r.scratch("loading-badge")&&yx(r,"loading-badge")})),n.on(WE.CountStarted,(e=>{var t;const r=null===(t=n.diagram.representation)||void 0===t?void 0:t.cy.$id(e);r&&!r.empty()&&(yx(r,"instance-count"),mx(r,tb(),"instance-count","bottom"))})),n.on(WE.NewCountResult,((e,t)=>{var r;const i=null===(r=n.grapholscape.renderer.cy)||void 0===r?void 0:r.$id(e);if(i&&i.nonempty()&&i.scratch("instance-count")){const r=i.scratch("instance-count");r.contentType="template",t=t||n.counts.get(e),r.content=void 0!==(null==t?void 0:t.value)?(new Intl.NumberFormat).format(t.value):"n/a",r.highlighted=!(null==t?void 0:t.materialized),(null==t?void 0:t.date)?r.title=`Date: ${t.date}`:r.title="Fresh Value";const o=i.scratch("update-instance-count-position");o&&o(),setTimeout((()=>r.hide()),1e3),i.on("mouseover",(()=>{n.countersEnabled&&r.tippyWidget.show()})),i.on("mouseout",(()=>r.tippyWidget.hide())),t&&!t.materialized&&n.counts.set(e,t)}}))}function fx(t,n){t.scratch("_gscape-graph-incremental-handlers-set")||(t.on("mouseover","node",(t=>{var r;const i=t.target,o=i.data().type;i.hasClass("unknown-parent-class")||o!==e.GrapholTypesEnum.CLASS&&o!==e.GrapholTypesEnum.CLASS_INSTANCE||null===(r=n.get(o))||void 0===r||r.forEach(((e,t)=>{e.cxtWidgetProps.offset=e=>vx(e,t,n.get(o).length),e.node=i,i.scratch(`place-node-button-${t}`,(()=>e.attachTo(i.popperRef()))),i.on("position",i.scratch(`place-node-button-${t}`)),e.attachTo(i.popperRef())}))})),t.on("mouseout","node",(e=>{const t=e.target;n.forEach(((e,n)=>e.forEach(((e,n)=>{e.hide();const r=t.scratch(`place-node-button-${n}`);r&&(t.removeListener("position",void 0,r),t.removeScratch(`place-node-button-${n}`))}))))})),t.scratch("_gscape-graph-incremental-handlers-set",!0))}function vx(e,t=0,n=1){const r=e.popper.height+4;return[-r/2-t*r+r*(n/2),-e.popper.width/2]}function yx(e,t){e.scratch(t)&&(e.scratch(t).tippyWidget.destroy(),e.removeClass("unknown-parent-class"),e.removeScratch(t),e.removeAllListeners(),e.cy().removeListener("pan",e.scratch(`update-${t}-position`)),e.removeScratch(`update-${t}-position`))}function mx(e,t,n,r="bottom",i=!1){const o=i?new yE(t):new yE(t,"template");return o.cxtWidgetProps.placement=r,e.scratch(n,o),e.scratch(`update-${n}-position`,(()=>{o.attachToSilently(e.popperRef())})),o.cxtWidgetProps.offset=e=>vx(e),o.attachTo(e.popperRef()),e.on("position",e.scratch(`update-${n}-position`)),e.cy().on("pan",e.scratch(`update-${n}-position`)),e.scratch(`update-${n}-position`),e.on("remove",(e=>yx(e.target,n))),o}ox.properties={areInstancesLoading:{type:Boolean},instances:{type:Object},referenceEntity:{type:Object},searchFilterList:{type:Object},referencePropertyEntity:{type:Object},classTypeFilterList:{type:Object},canShowMore:{type:Boolean},lastSearchedText:{type:String,state:!0}},ox.styles=[rm,ix,ib,nb,tv` + `}handleFilter(t){var n,r,i,o;const a=this.instancesSearchInput;if(!a)return;const s=new CustomEvent("instances-filter",{bubbles:!0,composed:!0,detail:{filterText:a.value.length>0?a.value:void 0,filterByProperty:void 0,filterByType:void 0}});if((null===(n=this.propertyFilterSelect)||void 0===n?void 0:n.selectedOptionId)&&"id"!==this.propertyFilterSelect.selectedOptionId&&"label"!==this.propertyFilterSelect.selectedOptionId&&s.detail.filterText){s.detail.filterByProperty=this.propertyFilterSelect.selectedOptionId;const t=this.propertiesFilterList.find((e=>{var t;return(null===(t=this.propertyFilterSelect)||void 0===t?void 0:t.selectedOptionId)&&e.entityViewData.value.iri.equals(this.propertyFilterSelect.selectedOptionId)}));t&&(s.detail.propertyType=t.entityViewData.value.type,t.entityViewData.value.type===e.GrapholTypesEnum.OBJECT_PROPERTY&&(s.detail.direct=t.direct))}1===(null===(r=this.classTypeFilterList)||void 0===r?void 0:r.length)?s.detail.filterByType=this.classTypeFilterList[0].entityViewData.value.iri.fullIri:this.classTypeFilterSelect&&(s.detail.filterByType=this.classTypeFilterSelect.selectedOptionId),void 0!==this.shouldAskForLabels&&(s.detail.shouldAskForLabels=this.shouldAskForLabels&&"id"!==(null===(i=this.propertyFilterSelect)||void 0===i?void 0:i.selectedOptionId)),"id"===(null===(o=this.propertyFilterSelect)||void 0===o?void 0:o.selectedOptionId)&&(s.detail.shouldAskForLabels=!1),this.lastSearchedText=s.detail.filterText||"",this.numberOfPagesShown=1,this.dispatchEvent(s)}handleInputKeypress(e){const t=e.target;"Escape"===e.key&&(t.blur(),t.value=""),clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((()=>{this.handleFilter()}),500)}handleFilterChange(){var e,t;null===(t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#instances-search"))||void 0===t||t.focus()}handleClassTypeFilterChange(e){var t;(null===(t=this.classTypeFilterSelect)||void 0===t?void 0:t.selectedOptionId)||(this.propertiesFilterList=[]),this.handleFilter(e)}handleInsertInGraph(n){var r,i,o,a,s,l,u,c;return t(this,void 0,void 0,(function*(){const t=null===(r=n.currentTarget.parentElement)||void 0===r?void 0:r.parentElement;if(t){const n=this.instances.get(t.iri);if(n){let t,r;if((null===(i=this.referenceEntity)||void 0===i?void 0:i.value.type)===e.GrapholTypesEnum.CLASS)t=null===(o=this.referenceEntity)||void 0===o?void 0:o.value.iri.fullIri;else{if((null===(a=this.referenceEntity)||void 0===a?void 0:a.value.type)!==e.GrapholTypesEnum.CLASS_INSTANCE)return;if(1===(null===(s=this.classTypeFilterList)||void 0===s?void 0:s.length))t=this.classTypeFilterList[0].entityViewData.value.iri.fullIri;else if(null===(l=this.classTypeFilterSelect)||void 0===l?void 0:l.selectedOptionId)t=this.classTypeFilterSelect.selectedOptionId;else{if(!this.classTypeFilterList)return;t=this.classTypeFilterList.map((e=>e.entityViewData.value.iri.fullIri))}}(null===(u=this.propertyFilterSelect)||void 0===u?void 0:u.selectedOptionId)&&"id"!==this.propertyFilterSelect.selectedOptionId&&"label"!==this.propertyFilterSelect.selectedOptionId&&(null===(c=this.instancesSearchInput)||void 0===c?void 0:c.value)&&(r=this.propertyFilterSelect.selectedOptionId),this.requestUpdate(),yield this.updateComplete,this.dispatchEvent(new CustomEvent("instanceselection",{bubbles:!0,composed:!0,detail:{parentClassIris:t,instance:n,filterByProperty:r}}))}}}))}handleShowMore(e){this.dispatchEvent(new CustomEvent("showmoreinstances",{bubbles:!0,composed:!0})),this.numberOfPagesShown+=1}addInstances(e){this.numberOfInstancesReceived+=e.length,e.forEach((e=>{const t=e.connectedInstance?`${e.iri}-${e.connectedInstance.iri}`:e.iri;this.instances.has(t)||this.instances.set(t,e)})),this.requestUpdate()}clear(){var e,t;this.instances=new Map,this.numberOfPagesShown=1,this.numberOfInstancesReceived=0,this.areInstancesLoading=!1,this.propertiesFilterList=[],null===(e=this.propertyFilterSelect)||void 0===e||e.clear(),this.classTypeFilterList=[],null===(t=this.classTypeFilterSelect)||void 0===t||t.clear(),this.referenceEntity=void 0,this.referencePropertyEntity=void 0,this.popperRef=void 0,this.shouldAskForLabels=void 0,this.numberResultsAvailable=0,this.lastSearchedText="",this.instancesSearchInput&&(this.instancesSearchInput.value="")}updated(){this.popperRef&&this.attachTo(this.popperRef)}attachTo(e){this.popperRef=e,super.attachTo(e)}getHighlightInSearchMatch(e){if(this.lastSearchedText.length>0&&" "!==this.lastSearchedText){const t=e.toLowerCase().search(this.lastSearchedText.toLowerCase());if(t>=0){const n=t+this.lastSearchedText.length-1;return{preString:e.substring(0,t),highlightString:e.substring(t,n+1),postString:e.substring(n+1,e.length)}}}return{preString:e,highlightString:void 0,postString:void 0}}get canShowMore(){return this.numberResultsAvailable?this.numberOfInstancesReceived0}get propertyFilterSelect(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#property-filter-select")}get classTypeFilterSelect(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#classtype-filter-select")}get instancesSearchInput(){var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("#instances-search")}hide(){this.style.display="none"}}function ax(e,t){return{content:(e?"Hide":"Show")+" Super Hierarchies",icon:My,select:t}}function sx(e,t){return{content:(e?"Hide":"Show")+" Super Classes",icon:My,select:t}}function lx(e,t){return{content:(e?"Hide":"Show")+" Sub Hierarchies",icon:$y,select:t}}function ux(e,t){return{content:(e?"Hide":"Show")+" Sub Classes",icon:$y,select:t}}function cx(e,t){return{content:(e?"Hide":"Show")+" Equivalent Classes",icon:zy,select:t}}function dx(n){const r=new Wm;n.grapholscape.on(e.LifecycleEvent.ContextClick,(i=>{var o,a;const s=[];if(i.target===n.grapholscape.renderer.cy||!i.target.data().iri||n.grapholscape.renderState!==e.RendererStatesEnum.INCREMENTAL)return;const l=n.classInstanceEntities.get(i.target.data().iri)||n.grapholscape.ontology.getEntity(i.target.data().iri);if(!l)return;var u;l.is(e.GrapholTypesEnum.CLASS_INSTANCE)&&!l.isRDFTypeUnknown&&(s.push((u=()=>t(this,void 0,void 0,(function*(){var t;const r=n.grapholscape.ontology.getEntitiesByType(e.GrapholTypesEnum.CLASS).map((e=>e.iri.fullIri)),i=yield null===(t=n.endpointController)||void 0===t?void 0:t.instanceCheck(l.iri.fullIri,r);null==i||i.forEach((e=>{const t=n.grapholscape.ontology.getEntity(e);t&&l.addParentClass(t.iri)})),hx(n,l)})),{content:"Compute and Show Parent Classes",icon:Jv,select:u})),s.push(function(e){return{content:"Show Current Parent Classes",icon:Jv,select:e}}((()=>hx(n,l)))));const c=l.iri.fullIri;if(l.is(e.GrapholTypesEnum.CLASS)){const e=n.grapholscape.ontology.hierarchiesBySubclassMap.get(c),t=n.grapholscape.ontology.hierarchiesBySuperclassMap.get(c);if(e&&e.length>0){const t=n.areHierarchiesVisible(e);s.push(ax(t,(()=>{t?n.hideSuperHierarchiesOf(c):n.showSuperHierarchiesOf(c)})))}if(t&&t.length>0){const e=n.areHierarchiesVisible(t);s.push(lx(e,(()=>{e?n.hideSubHierarchiesOf(c):n.showSubHierarchiesOf(c)})))}const r=n.neighbourhoodFinder.getSubclassesIris(c),i=n.neighbourhoodFinder.getSuperclassesIris(c),a=n.neighbourhoodFinder.getEquivalentClassesIris(c);if(r.length>0){const e=n.areAllConnectedClassesVisibleForClass(c,r,"sub");s.push(ux(e,(()=>{e?r.forEach((e=>n.removeEntity(e,[c]))):n.showSubClassesOf(c,r)})))}if(i.length>0){const e=n.areAllConnectedClassesVisibleForClass(c,i,"super");s.push(sx(e,(()=>{e?i.forEach((e=>n.removeEntity(e,[c]))):n.showSuperClassesOf(c,i)})))}if(a.length>0){const e=n.areAllConnectedClassesVisibleForClass(c,a,"equivalent");s.push(cx(e,(()=>{e?a.forEach((e=>n.removeEntity(e,[c]))):n.showEquivalentClassesOf(c,a)})))}(null===(o=n.endpointController)||void 0===o?void 0:o.isReasonerAvailable())&&n.countersEnabled&&s.push({icon:Hy,content:"Count Instances",select:()=>{var e;null===(e=n.endpointController)||void 0===e||e.requestCountForClass(l.iri.fullIri)}})}!l.is(e.GrapholTypesEnum.CLASS_INSTANCE)&&(null===(a=n.endpointController)||void 0===a?void 0:a.isReasonerAvailable())&&s.push({content:"Data Lineage",icon:Xy,select:()=>n.onShowDataLineage(l.iri.fullIri)}),s.push(function(e){return{content:"Remove",icon:By,select:e}}((()=>{l.is(e.GrapholTypesEnum.OBJECT_PROPERTY)?(n.diagram.removeElement(i.target.id()),l.removeOccurrence(i.target.id(),n.diagram.id,e.RendererStatesEnum.INCREMENTAL),n.lifecycle.trigger(WE.DiagramUpdated)):n.removeEntity(l.iri.fullIri)})));try{if(i.target.isEdge()&&n.grapholscape.uiContainer)r.attachToPosition(i.renderedPosition,n.grapholscape.uiContainer,s);else{const e=i.target.popperRef();e&&s.length>0&&r.attachTo(e,s)}}catch(e){console.error(e)}}))}function hx(t,n){const r=n.parentClassIris;t.performActionWithBlockedGraph((()=>{null==r||r.forEach((r=>{t.addEntity(r.fullIri,!1),t.addEdge(n.iri.fullIri,r.fullIri,e.GrapholTypesEnum.INSTANCE_OF)}))})),1===(null==r?void 0:r.length)&&setTimeout((()=>{t.grapholscape.centerOnElement(r[0].fullIri)}),250)}function px(e,t){if(e.referenceEntity){const n=t.grapholscape.renderer.cy;if(n){const r=n.$id(e.referenceEntity.value.iri.fullIri);r&&(e.attachTo(r.popperRef()),e.show(),r.data().pinned||(r.scratch("should-unpin",!0),t.pinNode(r)))}}}function gx(n){const r=new yE(ey);r.title="Search instances";const i=new yE(ry);i.title="Navigate through object properties";const o=new Map;o.set(e.GrapholTypesEnum.CLASS,[i]),o.set(e.GrapholTypesEnum.CLASS_INSTANCE,[i]),r.onclick=r=>function(n,r){var i,o,a,s,l,u;return t(this,void 0,void 0,(function*(){const c=n.currentTarget,d=r.grapholscape.widgets.get(Fg.INSTANCES_EXPLORER);if(d&&c.node&&c.node.data().iri){const n=r.grapholscape.ontology.getEntity(c.node.data().iri);if(n&&n.type===e.GrapholTypesEnum.CLASS&&(!d.referenceEntity||!d.referenceEntity.value.iri.equals(n.iri)||0===d.numberOfInstancesReceived)){d.clear(),d.areInstancesLoading=!0,d.referenceEntity=fb(n,r.grapholscape);const e=null===(o=null===(i=r.endpointController)||void 0===i?void 0:i.highlightsManager)||void 0===o?void 0:o.hasUnfoldings.bind(null===(a=r.endpointController)||void 0===a?void 0:a.highlightsManager),c=yield r.getDataPropertiesByClasses([n.iri.fullIri]),h=yield r.getObjectPropertiesByClasses([n.iri.fullIri]),p=Array.from(h).map((([t,n])=>{let i=vb(t,r.grapholscape,e);return{entityViewData:i.entityViewData,loading:i.loading,hasUnfolding:i.hasUnfolding,connectedClasses:[],direct:n.direct}}));d.propertiesFilterList=c.map((t=>vb(t,r.grapholscape,e))).concat(p).sort(((e,t)=>e.entityViewData.displayedName.localeCompare(t.entityViewData.displayedName))),d.requestId=yield null===(s=r.endpointController)||void 0===s?void 0:s.requestInstancesForClass(n.iri.fullIri),d.requestId&&(null===(u=null===(l=r.endpointController)||void 0===l?void 0:l.shouldQueryUseLabels(d.requestId))||void 0===u||u.then((e=>t(this,void 0,void 0,(function*(){var t;e||(d.shouldAskForLabels=e,d.areInstancesLoading=!0,d.requestId=yield null===(t=r.endpointController)||void 0===t?void 0:t.requestInstancesForClass(n.iri.fullIri,e))})))))}c.node&&px(d,r)}}))}(r,n),i.onclick=r=>function(n,r){var i,o,a;return t(this,void 0,void 0,(function*(){const t=n.currentTarget,s=r.grapholscape.widgets.get(Fg.NAVIGATION_MENU);if(s&&t.node&&t.node.data().iri){let n,l=new Map;if(t.node.data().type===e.GrapholTypesEnum.CLASS){if(n=r.grapholscape.ontology.getEntity(t.node.data().iri),!n)return;s.referenceEntity=fb(n,r.grapholscape),s.canShowObjectPropertiesRanges=!0,l=yield r.getObjectPropertiesByClasses([t.node.data().iri])}else if(t.node.data().type===e.GrapholTypesEnum.CLASS_INSTANCE){if(n=r.classInstanceEntities.get(t.node.data().iri),!n)return;s.referenceEntity=fb(n,r.grapholscape),s.canShowObjectPropertiesRanges=!1;const e=n.parentClassIris.map((e=>e.fullIri));l=yield r.getObjectPropertiesByClasses(e)}const u=null===(o=null===(i=r.endpointController)||void 0===i?void 0:i.highlightsManager)||void 0===o?void 0:o.hasUnfoldings.bind(null===(a=r.endpointController)||void 0===a?void 0:a.highlightsManager);s.objectProperties=Array.from(l).map((e=>{const t=vb(e[0],r.grapholscape,u);return t.connectedClasses=e[1].list.map((e=>vb(e,r.grapholscape,u))),t.direct=e[1].direct,t})),t.node&&px(s,r)}}))}(r,n),n.grapholscape.renderState===e.RendererStatesEnum.INCREMENTAL&&n.diagram.representation&&fx(n.diagram.representation.cy,o),n.grapholscape.on(e.LifecycleEvent.RendererChange,(t=>{t===e.RendererStatesEnum.INCREMENTAL&&n.diagram.representation&&fx(n.diagram.representation.cy,o)})),n.on(WE.Reset,(()=>{n.grapholscape.renderState===e.RendererStatesEnum.INCREMENTAL&&n.diagram.representation&&(fx(n.diagram.representation.cy,o),n.grapholscape.container.querySelectorAll("[data-tippy-root]").forEach((e=>e.remove())))})),n.on(WE.EndpointChange,(()=>{var t,n;(null===(t=o.get(e.GrapholTypesEnum.CLASS))||void 0===t?void 0:t.includes(r))||null===(n=o.get(e.GrapholTypesEnum.CLASS))||void 0===n||n.push(r)})),n.on(WE.InstanceCheckingStarted,(e=>{var t;const r=null===(t=n.diagram.representation)||void 0===t?void 0:t.cy.$id(e);r&&(r.addClass("unknown-parent-class"),mx(r,tb(),"loading-badge"))})),n.on(WE.InstanceCheckingFinished,(e=>{var t;const r=null===(t=n.diagram.representation)||void 0===t?void 0:t.cy.$id(e);r&&r.scratch("loading-badge")&&yx(r,"loading-badge")})),n.on(WE.CountStarted,(e=>{var t;const r=null===(t=n.diagram.representation)||void 0===t?void 0:t.cy.$id(e);r&&!r.empty()&&(yx(r,"instance-count"),mx(r,tb(),"instance-count","bottom"))})),n.on(WE.NewCountResult,((e,t)=>{var r;const i=null===(r=n.grapholscape.renderer.cy)||void 0===r?void 0:r.$id(e);if(i&&i.nonempty()&&i.scratch("instance-count")){const r=i.scratch("instance-count");r.contentType="template",t=t||n.counts.get(e),r.content=void 0!==(null==t?void 0:t.value)?(new Intl.NumberFormat).format(t.value):"n/a",r.highlighted=!(null==t?void 0:t.materialized),(null==t?void 0:t.date)?r.title=`Date: ${t.date}`:r.title="Fresh Value";const o=i.scratch("update-instance-count-position");o&&o(),setTimeout((()=>r.hide()),1e3),i.on("mouseover",(()=>{n.countersEnabled&&r.tippyWidget.show()})),i.on("mouseout",(()=>r.tippyWidget.hide())),t&&!t.materialized&&n.counts.set(e,t)}}))}function fx(t,n){t.scratch("_gscape-graph-incremental-handlers-set")||(t.on("mouseover","node",(t=>{var r;const i=t.target,o=i.data().type;i.hasClass("unknown-parent-class")||o!==e.GrapholTypesEnum.CLASS&&o!==e.GrapholTypesEnum.CLASS_INSTANCE||null===(r=n.get(o))||void 0===r||r.forEach(((e,t)=>{e.cxtWidgetProps.offset=e=>vx(e,t,n.get(o).length),e.node=i,i.scratch(`place-node-button-${t}`,(()=>e.attachTo(i.popperRef()))),i.on("position",i.scratch(`place-node-button-${t}`)),e.attachTo(i.popperRef())}))})),t.on("mouseout","node",(e=>{const t=e.target;n.forEach(((e,n)=>e.forEach(((e,n)=>{e.hide();const r=t.scratch(`place-node-button-${n}`);r&&(t.removeListener("position",void 0,r),t.removeScratch(`place-node-button-${n}`))}))))})),t.scratch("_gscape-graph-incremental-handlers-set",!0))}function vx(e,t=0,n=1){const r=e.popper.height+4;return[-r/2-t*r+r*(n/2),-e.popper.width/2]}function yx(e,t){e.scratch(t)&&(e.scratch(t).tippyWidget.destroy(),e.removeClass("unknown-parent-class"),e.removeScratch(t),e.removeAllListeners(),e.cy().removeListener("pan",e.scratch(`update-${t}-position`)),e.removeScratch(`update-${t}-position`))}function mx(e,t,n,r="bottom",i=!1){const o=i?new yE(t):new yE(t,"template");return o.cxtWidgetProps.placement=r,e.scratch(n,o),e.scratch(`update-${n}-position`,(()=>{o.attachToSilently(e.popperRef())})),o.cxtWidgetProps.offset=e=>vx(e),o.attachTo(e.popperRef()),e.on("position",e.scratch(`update-${n}-position`)),e.cy().on("pan",e.scratch(`update-${n}-position`)),e.scratch(`update-${n}-position`),e.on("remove",(e=>yx(e.target,n))),o}ox.properties={areInstancesLoading:{type:Boolean},instances:{type:Object},referenceEntity:{type:Object},searchFilterList:{type:Object},referencePropertyEntity:{type:Object},classTypeFilterList:{type:Object},canShowMore:{type:Boolean},lastSearchedText:{type:String,state:!0}},ox.styles=[rm,ix,ib,nb,tv` :host { min-height: 450px; } @@ -2848,4 +2848,4 @@ gscape-entity-list-item:hover > .hover-btn { display: flex; justify-content: space-between; } - `],customElements.define("gscape-navigation-menu",bx);class wx{constructor(t){this.grapholscape=t,this.classInstanceEntities=new Map,this.diagram=new nf,this.counts=new Map,this.countersEnabled=!0,this.lifecycle=new ZE,this.on=this.lifecycle.on,this.onShowDataLineage=()=>{},this.runLayout=()=>{var e;return null===(e=this.incrementalRenderer)||void 0===e?void 0:e.runLayout()},this.pinNode=e=>{var t;return null===(t=this.incrementalRenderer)||void 0===t?void 0:t.pinNode(e)},this.unpinNode=e=>{var t;return null===(t=this.incrementalRenderer)||void 0===t?void 0:t.unpinNode(e)},this.diagramBuilder=new ME(this.diagram),this.addEdge=this.diagramBuilder.addEdge.bind(this.diagramBuilder),this.neighbourhoodFinder=new JE(this.ontology),t.on(e.LifecycleEvent.EntityNameTypeChange,(e=>{this.classInstanceEntities.forEach((e=>this.updateEntityNameType(e.iri)))})),t.on(e.LifecycleEvent.LanguageChange,(n=>{var r;null===(r=this.endpointController)||void 0===r||r.setLanguage(n),t.entityNameType===e.EntityNameType.LABEL&&this.classInstanceEntities.forEach((e=>this.updateEntityNameType(e.iri)))}))}showDiagram(e){e&&(this.diagram.lastViewportState=e),PE(this.diagram,this.grapholscape.lifecycle,this.grapholscape.ontology),this.grapholscape.renderer.render(this.diagram)}performActionWithBlockedGraph(e){var n;return t(this,void 0,void 0,(function*(){const t=this.numberOfElements;null===(n=this.incrementalRenderer)||void 0===n||n.freezeGraph(),yield e(),this.postDiagramEdit(t)}))}setMastroConnection(e){this.reset(),e.onError||(e.onError=e=>console.error(e)),this.endpointController=new KE(e,this.lifecycle),this.endpointController.setLanguage(this.grapholscape.language),this.lifecycle.trigger(WE.ReasonerSet)}addEntity(t,n=!0,r){const i=this.grapholscape.ontology.getEntity(t);i&&this.diagramBuilder.diagram.representation&&(r&&i.is(e.GrapholTypesEnum.CLASS)?this.diagramBuilder.addClass(i,r):this.diagramBuilder.addEntity(i),this.updateEntityNameType(i.iri),n&&this.grapholscape.centerOnElement(t),i.is(e.GrapholTypesEnum.CLASS)&&this.countInstancesForClass(t))}areHierarchiesVisible(e){var t;let n=!0;for(let r of e)if(r.id&&(null===(t=this.grapholscape.renderer.cy)||void 0===t?void 0:t.$id(r.id).empty())){n=!1;break}return n}areAllConnectedClassesVisibleForClass(t,n,r){var i;for(let o of n){const n=null===(i=this.grapholscape.renderer.cy)||void 0===i?void 0:i.$id(o).connectedEdges(`[ type ="${"equivalent"===r?e.GrapholTypesEnum.EQUIVALENCE:e.GrapholTypesEnum.INCLUSION}" ]`);if(n){if("sub"===r&&n.targets(`[id = "${t}"]`).empty())return!1;if("super"===r&&n.sources(`[id = "${t}"]`).empty())return!1;if("equivalent"===r&&n.connectedNodes(`[id = "${t}"]`).empty())return!1}}return!0}reset(){var e;null===(e=this.incrementalRenderer)||void 0===e||e.reset(),this.classInstanceEntities.clear(),this.diagram.clear(),this.clearState(),this.lifecycle.trigger(WE.Reset)}clearState(){var e;null===(e=this.endpointController)||void 0===e||e.clear()}updateEntityNameType(t){var n,r;let i;i="string"!=typeof t?t.fullIri:t;const o=this.classInstanceEntities.get(i)||this.ontology.getEntity(i);let a,s=null===(n=this.diagram.representation)||void 0===n?void 0:n.grapholElements.get(i);o&&!s?a=null===(r=o.occurrences.get(e.RendererStatesEnum.INCREMENTAL))||void 0===r?void 0:r.map((e=>{var t,n;return null===(n=null===(t=this.diagram)||void 0===t?void 0:t.representation)||void 0===n?void 0:n.grapholElements.get(e.elementId)})).filter((e=>void 0!==e)):s&&(a=[s]),o&&a&&a.forEach((e=>{var t,n;e.displayedName=o.getDisplayedName(this.grapholscape.entityNameType,this.grapholscape.language),null===(n=null===(t=this.diagram)||void 0===t?void 0:t.representation)||void 0===n||n.updateElement(e,!1)}))}removeEntity(t,n=[]){let r;r="string"==typeof t?this.classInstanceEntities.get(t)||this.ontology.getEntity(t):t,this.performActionWithBlockedGraph((()=>{var t;null===(t=this.grapholscape.renderer.cy)||void 0===t||t.$(`[iri = "${null==r?void 0:r.iri.fullIri}"]`).forEach((t=>{var i,o;t.connectedEdges(`[type = "${e.GrapholTypesEnum.OBJECT_PROPERTY}"]`).forEach((t=>{const n=this.ontology.getEntity(t.data().iri);n&&n.removeOccurrence(t.id(),this.diagram.id,e.RendererStatesEnum.INCREMENTAL)})),t.data().type===e.GrapholTypesEnum.CLASS&&(t.neighborhood().forEach((e=>{e.isNode()?1!==e.degree(!1)||n.includes(e.id())||(e.data().iri?(n.push((null==r?void 0:r.iri.fullIri)||""),this.removeEntity(e.data().iri,n)):this.diagram.removeElement(e.id())):this.diagram.removeElement(e.id())})),null===(i=this.ontology.hierarchiesBySubclassMap.get(r.iri.fullIri))||void 0===i||i.forEach((e=>{this.removeHierarchy(e)})),null===(o=this.ontology.hierarchiesBySuperclassMap.get(r.iri.fullIri))||void 0===o||o.forEach((e=>{this.removeHierarchy(e)}))),this.diagram.removeElement(t.id()),null==r||r.removeOccurrence(t.id(),this.diagram.id,e.RendererStatesEnum.INCREMENTAL),(null==r?void 0:r.is(e.GrapholTypesEnum.CLASS_INSTANCE))&&this.classInstanceEntities.delete(r.iri.fullIri)}))}))}addInstance(t,n){var r,i;let o=this.classInstanceEntities.get(t.iri);if(!o){const n=new of(t.iri,this.ontology.namespaces,t.shortIri);o=new mf(n),t.label&&o.addAnnotation(new af(e.AnnotationsKind.label,t.label.value,t.label.language)),null===(r=this.endpointController)||void 0===r||r.requestLabels(t.iri).then((t=>{null==t||t.forEach((t=>{o.addAnnotation(new af(e.AnnotationsKind.label,t.value,t.language))})),this.updateEntityNameType(o.iri)})),this.diagramBuilder.addClassInstance(o),this.classInstanceEntities.set(t.iri,o)}if("string"!=typeof n)n||(n=this.ontology.getEntitiesByType(e.GrapholTypesEnum.CLASS).map((e=>e.iri.fullIri))),null===(i=this.endpointController)||void 0===i||i.instanceCheck(t.iri,n).then((e=>{e.forEach((e=>{const t=this.ontology.getEntity(e);t&&o&&o.addParentClass(t.iri)}))}));else{const e=this.ontology.getEntity(n);e&&o.addParentClass(e.iri)}return this.updateEntityNameType(o.iri),this.lifecycle.trigger(WE.DiagramUpdated),o}addIntensionalObjectProperty(e,t,n){const r=this.ontology.getEntity(e),i=this.ontology.getEntity(t),o=this.ontology.getEntity(n);r&&i&&o&&(this.performActionWithBlockedGraph((()=>{this.diagramBuilder.addObjectProperty(r,i,o),this.updateEntityNameType(r.iri),this.updateEntityNameType(t),this.updateEntityNameType(n)})),this.countInstancesForClass(t),this.countInstancesForClass(n))}addExtensionalObjectProperty(e,t,n){const r=this.ontology.getEntity(e),i=this.classInstanceEntities.get(t),o=this.classInstanceEntities.get(n);r&&i&&o&&this.performActionWithBlockedGraph((()=>{this.diagramBuilder.addObjectProperty(r,i,o),this.updateEntityNameType(r.iri),this.updateEntityNameType(i.iri),this.updateEntityNameType(o.iri)}))}showSuperHierarchiesOf(e){this.showOrHideHierarchies(e,"super","show")}showSubHierarchiesOf(e){this.showOrHideHierarchies(e,"sub","show")}hideSuperHierarchiesOf(e){this.showOrHideHierarchies(e,"super","hide")}hideSubHierarchiesOf(e){this.showOrHideHierarchies(e,"sub","hide")}showOrHideHierarchies(e,t,n){if(!this.ontology.getEntity(e))return;let r;const i=this.ontology.hierarchiesBySuperclassMap.get(e),o=this.ontology.hierarchiesBySubclassMap.get(e);switch(t){case"super":r=o;break;case"sub":r=i;break;case"any":r=[],i&&r.concat(i),o&&r.concat(o);break;default:return}r&&r.length>0&&this.performActionWithBlockedGraph((()=>{var t;const i=null===(t=this.grapholscape.renderer.cy)||void 0===t?void 0:t.$id(e).position();"show"===n?null==r||r.forEach((e=>this.addHierarchy(e,i))):null==r||r.forEach((t=>this.removeHierarchy(t,[e])))}))}addHierarchy(e,t){var n,r;const i=e.getUnionGrapholNode(t),o=e.getInputGrapholEdges(),a=e.getInclusionEdges();if(i&&o&&a){this.diagram.addElement(i);for(const t of e.inputs)this.addEntity(t,!1);for(const t of e.superclasses)this.addEntity(t.classIri,!1);null===(n=e.getInputGrapholEdges())||void 0===n||n.forEach((e=>this.diagram.addElement(e))),null===(r=e.getInclusionEdges())||void 0===r||r.forEach((e=>this.diagram.addElement(e)))}}removeHierarchy(e,t=[]){var n,r,i;if(!this.incrementalRenderer||!e.id||e.id&&(null===(n=this.grapholscape.renderer.cy)||void 0===n?void 0:n.$id(e.id).empty()))return;let o;this.diagram.removeElement(e.id),null===(r=e.getInputGrapholEdges())||void 0===r||r.forEach((e=>{var t;null===(t=this.diagram)||void 0===t||t.removeElement(e.id)})),null===(i=e.getInclusionEdges())||void 0===i||i.forEach((e=>{var t;null===(t=this.diagram)||void 0===t||t.removeElement(e.id)})),e.inputs.forEach((e=>{var n;0!==(null===(n=this.grapholscape.renderer.cy)||void 0===n?void 0:n.$id(e).degree(!1))||t.includes(e)||(o=this.ontology.getEntity(e),o&&this.removeEntity(o))})),e.superclasses.forEach((e=>{var n;0!==(null===(n=this.grapholscape.renderer.cy)||void 0===n?void 0:n.$id(e.classIri).degree(!1))||t.includes(e.classIri)||(o=this.ontology.getEntity(e.classIri),o&&this.removeEntity(o))}))}showSubClassesOf(t,n){n||(n=this.neighbourhoodFinder.getSubclassesIris(t)),this.showClassesInIsa(t,n,e.GrapholTypesEnum.INCLUSION)}showSuperClassesOf(t,n){n||(n=this.neighbourhoodFinder.getSuperclassesIris(t)),this.showClassesInIsa(t,n,e.GrapholTypesEnum.INCLUSION,"super")}showEquivalentClassesOf(t,n){n||(n=this.neighbourhoodFinder.getEquivalentClassesIris(t)),this.showClassesInIsa(t,n,e.GrapholTypesEnum.EQUIVALENCE)}showClassesInIsa(e,t,n,r="sub"){this.performActionWithBlockedGraph((()=>{t.forEach((t=>{this.addEntity(t,!1),"super"===r?this.diagramBuilder.addEdge(e,t,n):this.diagramBuilder.addEdge(t,e,n)}))}))}getObjectPropertiesByClasses(e){var n,r,i;return t(this,void 0,void 0,(function*(){if(null===(n=this.endpointController)||void 0===n?void 0:n.isReasonerAvailable()){null===(r=this.endpointController.highlightsManager)||void 0===r||r.computeHighlights(e);const t=yield null===(i=this.endpointController.highlightsManager)||void 0===i?void 0:i.objectProperties(),n=new Map;return null==t||t.forEach((e=>{var t;if(!e.objectPropertyIRI)return;const r=this.ontology.getEntity(e.objectPropertyIRI);if(!r)return;const i={list:[],direct:e.direct||!1};null===(t=e.relatedClasses)||void 0===t||t.forEach((e=>{const t=this.ontology.getEntity(e);t&&i.list.push(t)})),n.set(r,i)})),n}return this.neighbourhoodFinder.getObjectProperties(e[0])}))}getDataPropertiesByClasses(e){var n,r,i;return t(this,void 0,void 0,(function*(){if(null===(n=this.endpointController)||void 0===n?void 0:n.isReasonerAvailable()){null===(r=this.endpointController.highlightsManager)||void 0===r||r.computeHighlights(e);const t=yield null===(i=this.endpointController.highlightsManager)||void 0===i?void 0:i.dataProperties();return(null==t?void 0:t.map((e=>this.ontology.getEntity(e))).filter((e=>null!==e)))||[]}return this.neighbourhoodFinder.getDataProperties(e[0])}))}getDataPropertiesByClassInstance(e){var n;return t(this,void 0,void 0,(function*(){const t=this.classInstanceEntities.get(e);return t&&(null===(n=this.endpointController)||void 0===n?void 0:n.highlightsManager)?(this.endpointController.highlightsManager.computeHighlights(t.parentClassIris.map((e=>e.fullIri))),(yield this.endpointController.highlightsManager.dataProperties()).map((e=>this.ontology.getEntity(e))).filter((e=>null!==e))):[]}))}postDiagramEdit(e){var t;this.numberOfElements!==e?(this.runLayout(),this.lifecycle.trigger(WE.DiagramUpdated)):null===(t=this.incrementalRenderer)||void 0===t||t.unFreezeGraph()}countInstancesForClass(e){var n,r,i,o;return t(this,void 0,void 0,(function*(){if(!this.countersEnabled||!(null===(n=this.endpointController)||void 0===n?void 0:n.isReasonerAvailable()))return;const t=null===(i=null===(r=this.diagram)||void 0===r?void 0:r.representation)||void 0===i?void 0:i.cy.$id(e);if(t&&!t.empty())if(yield this.updateMaterializedCounts(),void 0===this.counts.get(e))null===(o=this.endpointController)||void 0===o||o.requestCountForClass(e);else{let n;const r=this.counts.get(e);t.scratch("instance-count")?(n=t.scratch("instance-count"),n.content=r.value):(n=mx(t,r.value,"instance-count","bottom"),setTimeout((()=>n.hide()),1e3),t.on("mouseover",(()=>{this.countersEnabled&&n.tippyWidget.show()})),t.on("mouseout",(()=>n.tippyWidget.hide()))),r.materialized?(n.highlighted=!1,n.title=`Date: ${r.date}`):(n.highlighted=!0,n.title="Fresh Value")}}))}updateMaterializedCounts(){var e;return t(this,void 0,void 0,(function*(){const t=yield null===(e=this.endpointController)||void 0===e?void 0:e.getMaterializedCounts();t&&t.countsMap.forEach((e=>{var n;if(e.state===OE.FINISHED){const r=this.counts.get(e.entity.entityIRI);r&&!r.materialized||(this.counts.set(e.entity.entityIRI,{value:e.count,materialized:!0,date:0!==t.endTime?new Date(t.endTime).toDateString():new Date(t.startTime).toDateString()}),this.lifecycle.trigger(WE.NewCountResult,e.entity.entityIRI,{value:e.count,materialized:!0,date:null===(n=this.counts.get(e.entity.entityIRI))||void 0===n?void 0:n.date}))}}))}))}setIncrementalEventHandlers(){var t,n,r,i;(null===(t=this.diagram.representation)||void 0===t?void 0:t.hasEverBeenRendered)||(null===(n=this.diagram.representation)||void 0===n?void 0:n.cy.scratch("_gscape-incremental-graph-handlers-set"))||(null===(r=this.diagram.representation)||void 0===r||r.cy.on("tap",(t=>{const n=t.target.data().type;if(n===e.GrapholTypesEnum.CLASS||n===e.GrapholTypesEnum.CLASS_INSTANCE){const r=()=>{var r,i;const o=t.target.data().iri;if(n===e.GrapholTypesEnum.CLASS_INSTANCE){const e=this.classInstanceEntities.get(o);e&&(o!==this.lastInstanceIri&&(null===(r=this.endpointController)||void 0===r||r.stopRequests("instances")),this.lifecycle.trigger(WE.ClassInstanceSelection,e))}else{o!==this.lastClassIri&&(null===(i=this.endpointController)||void 0===i||i.stopRequests("instances"));const e=this.grapholscape.ontology.getEntity(o);e&&this.lifecycle.trigger(WE.ClassSelection,e)}};this.endpointController?(clearTimeout(this.entitySelectionTimeout),this.entitySelectionTimeout=setTimeout(r,400)):r()}})),null===(i=this.diagram.representation)||void 0===i||i.cy.scratch("_gscape-incremental-graph-handlers-set",!0))}get ontology(){return this.grapholscape.ontology}get incrementalRenderer(){if(this.grapholscape.renderState===e.RendererStatesEnum.INCREMENTAL)return this.grapholscape.renderer.renderState}get numberOfElements(){var e;return(null===(e=this.grapholscape.renderer.cy)||void 0===e?void 0:e.elements().size())||0}}function _x(n){var r;let i,o=new wx(n);n.incremental=o,function(n){const r=new tx,i=n.grapholscape.widgets.get(Fg.ENTITY_DETAILS);i&&(i.incrementalSection=r),n.grapholscape.widgets.set(Fg.CLASS_INSTANCE_DETAILS,r),n.grapholscape.on(e.LifecycleEvent.EntitySelection,(i=>t(this,void 0,void 0,(function*(){let t;i.is(e.GrapholTypesEnum.CLASS)&&n.grapholscape.renderState===e.RendererStatesEnum.INCREMENTAL?(t=yield n.getDataPropertiesByClasses([i.iri.fullIri]),r.dataProperties=t.map((e=>fb(e,n.grapholscape))),r.parentClasses=void 0,r.canShowDataPropertiesValues=!1,r.show()):r.hide()})))),n.on(WE.ClassInstanceSelection,(e=>t(this,void 0,void 0,(function*(){var t;if(!(null==i?void 0:i.grapholEntity)||!(null==i?void 0:i.grapholEntity.iri.equals(e.iri))){null===(t=n.endpointController)||void 0===t||t.stopRequests("instances");const i=e.parentClassIris.map((e=>e.fullIri)),o=yield n.getDataPropertiesByClasses(i);r.dataProperties=o.map((e=>fb(e,n.grapholscape))),r.parentClasses=i.map((e=>{const t=n.grapholscape.ontology.getEntity(e);if(t)return fb(t,n.grapholscape)})).filter((e=>void 0!==e)),o.forEach((t=>{var r;null===(r=n.endpointController)||void 0===r||r.requestDataPropertyValues(e.iri.fullIri,t.iri.fullIri)}))}r.canShowDataPropertiesValues=!0,null==i||i.setGrapholEntity(e),r.show()})))),n.on(WE.NewDataPropertyValues,((e,t,n)=>{(null==i?void 0:i.grapholEntity.iri.equals(e))&&n.forEach((e=>r.addDataPropertyValue(t,e)))})),n.on(WE.DataPropertyValuesLoadingFinished,((e,t)=>{(null==i?void 0:i.grapholEntity.iri.equals(e))&&r.setDataPropertyLoading(t,!1)}))}(o),function(n){var r,i;const o=new nx;function a(){var e;null===(e=n.endpointController)||void 0===e||e.getRunningEndpoints().then((e=>{var t,r;o.endpoints=e.map((e=>({name:e.name}))).sort(((e,t)=>e.name.localeCompare(t.name))),e.length>=1&&!o.selectedEndpointName&&(null===(t=n.endpointController)||void 0===t||t.setEndpoint(e[0]),null===(r=n.endpointController)||void 0===r||r.setLanguage(n.grapholscape.language))}))}o.showCounters=n.countersEnabled,n.grapholscape.widgets.set(Fg.VKG_PREFERENCES,o),null===(i=null===(r=n.grapholscape.uiContainer)||void 0===r?void 0:r.querySelector(".gscape-ui-buttons-tray"))||void 0===i||i.appendChild(o),n.grapholscape.renderState===e.RendererStatesEnum.INCREMENTAL&&n.endpointController||o.disable(),n.endpointController&&a(),n.on(WE.EndpointChange,(e=>{o.selectedEndpointName=e.name})),n.on(WE.LimitChange,(e=>{o.pageSize=e})),n.on(WE.ReasonerSet,(()=>{n.grapholscape.renderState===e.RendererStatesEnum.INCREMENTAL&&o.enable(),a(),n.endpointController&&(o.pageSize=n.endpointController.pageSize)})),o.onTogglePanel=()=>a(),o.onEndpointChange((e=>{var r;const i=new hb("Are you sure? \nIf you change the current endpoint, your exploration will be reset.");null===(r=n.grapholscape.uiContainer)||void 0===r||r.appendChild(i),i.show(),i.onConfirm=()=>t(this,void 0,void 0,(function*(){var t,r;n.reset(),null===(t=n.endpointController)||void 0===t||t.setEndpoint(e),null===(r=n.endpointController)||void 0===r||r.setLanguage(n.grapholscape.language)}))})),o.onPageSizeChange((e=>{var t;null===(t=n.endpointController)||void 0===t||t.setPageSize(e)})),o.onShowCountersChange((e=>{n.countersEnabled=e})),o.onStopRequests((()=>{var e;return null===(e=n.endpointController)||void 0===e?void 0:e.stopRequests()}))}(o),function(n){const r=new ox;n.grapholscape.widgets.set(Fg.INSTANCES_EXPLORER,r),n.on(WE.NewInstances,((e,t)=>{r.addInstances(e.map((e=>{var t;return e[1]&&(e[0].searchMatch=null===(t=e[1].label)||void 0===t?void 0:t.value),e[0].connectedInstance=e[1],e[0]}))),!r.numberResultsAvailable&&t&&(r.numberResultsAvailable=t)})),n.on(WE.InstancesSearchFinished,(()=>r.areInstancesLoading=!1)),n.on(WE.Reset,(()=>{r.clear()})),r.addEventListener("instanceselection",(i=>t(this,void 0,void 0,(function*(){var t,o,a,s;let l;if(l=n.addInstance(i.detail.instance,i.detail.parentClassIris),l.parentClassIris.forEach((t=>{n.addEdge(i.detail.instance.iri,t.fullIri,e.GrapholTypesEnum.INSTANCE_OF)})),i.detail.instance.connectedInstance&&i.detail.filterByProperty){n.addInstance(i.detail.instance.connectedInstance);const e=null===(s=null===(a=yield null===(o=null===(t=n.endpointController)||void 0===t?void 0:t.highlightsManager)||void 0===o?void 0:o.objectProperties())||void 0===a?void 0:a.find((e=>e.objectPropertyIRI===i.detail.filterByProperty)))||void 0===s?void 0:s.direct;void 0!==e&&(e?n.addExtensionalObjectProperty(i.detail.filterByProperty,i.detail.instance.iri,i.detail.instance.connectedInstance.iri):n.addExtensionalObjectProperty(i.detail.filterByProperty,i.detail.instance.connectedInstance.iri,i.detail.instance.iri))}if(r.referenceEntity&&r.referencePropertyEntity&&l){const e=r.referenceEntity.value.iri.fullIri,t=r.referencePropertyEntity.value.iri.fullIri;r.isPropertyDirect?n.addExtensionalObjectProperty(t,e,l.iri.fullIri):n.addExtensionalObjectProperty(t,l.iri.fullIri,e)}n.runLayout()})))),r.addEventListener("instances-filter",(i=>t(this,void 0,void 0,(function*(){var t,o,a,s;null===(t=n.endpointController)||void 0===t||t.stopRequests("instances"),r.instances=new Map,r.numberOfInstancesReceived=0,r.numberResultsAvailable=0,r.numberOfPagesShown=1,r.areInstancesLoading=!0,r.referenceEntity&&(r.referenceEntity.value.type===e.GrapholTypesEnum.CLASS?r.requestId=yield null===(o=n.endpointController)||void 0===o?void 0:o.requestInstancesForClass(null===(a=r.referenceEntity)||void 0===a?void 0:a.value.iri.fullIri,i.detail.shouldAskForLabels,i.detail.filterText,i.detail.filterByProperty,i.detail.propertyType,i.detail.direct):r.referenceEntity.value.type===e.GrapholTypesEnum.CLASS_INSTANCE&&r.referencePropertyEntity&&(r.requestId=yield null===(s=n.endpointController)||void 0===s?void 0:s.requestInstancesThroughObjectProperty(r.referenceEntity.value.iri.fullIri,r.referencePropertyEntity.value.iri.fullIri,r.isPropertyDirect,i.detail.shouldAskForLabels,i.detail.filterByType,i.detail.filterByProperty,i.detail.filterText)))})))),r.addEventListener("showmoreinstances",(e=>t(this,void 0,void 0,(function*(){var e,t;null===(e=n.endpointController)||void 0===e||e.stopRequests("instances"),r.areInstancesLoading=!0,r.requestId&&(null===(t=n.endpointController)||void 0===t||t.requestNewInstances(r.requestId,r.numberOfPagesShown+1))})))),r.tippyWidget.setProps({onHide:()=>{r.hide(),rx(r,n)}})}(o),dx(o),gx(o),function(e){const n=new bx;e.grapholscape.widgets.set(Fg.NAVIGATION_MENU,n),n.requestUpdate(),n.addEventListener("onclassselection",(t=>{t.detail.rangeClassIri&&(t.detail.direct?e.addIntensionalObjectProperty(t.detail.objectPropertyIri,t.detail.referenceClassIri,t.detail.rangeClassIri):e.addIntensionalObjectProperty(t.detail.objectPropertyIri,t.detail.rangeClassIri,t.detail.referenceClassIri),setTimeout((()=>{e.grapholscape.centerOnElement(t.detail.rangeClassIri)}),250),n.popperRef=void 0,n.hide())})),n.addEventListener("onobjectpropertyselection",(r=>t(this,void 0,void 0,(function*(){var i,o,a,s,l,u,c,d,h;const p=e.grapholscape.widgets.get(Fg.INSTANCES_EXPLORER);if(p){const g=e.classInstanceEntities.get(r.detail.referenceClassIri),f=e.grapholscape.ontology.getEntity(r.detail.objectPropertyIri);if(g&&f&&(!(null===(i=p.referenceEntity)||void 0===i?void 0:i.value.iri.equals(g.iri))||!(null===(o=p.referencePropertyEntity)||void 0===o?void 0:o.value.iri.equals(f.iri)))){if(n.hide(),p.clear(),p.areInstancesLoading=!0,p.referenceEntity=n.referenceEntity,p.referencePropertyEntity=fb(f,e.grapholscape),p.isPropertyDirect=r.detail.direct,p.classTypeFilterList=null===(a=n.objectProperties.find((e=>e.entityViewData.value.iri.equals(r.detail.objectPropertyIri))))||void 0===a?void 0:a.connectedClasses,1===(null===(s=p.classTypeFilterList)||void 0===s?void 0:s.length)){const t=null===(u=null===(l=e.endpointController)||void 0===l?void 0:l.highlightsManager)||void 0===u?void 0:u.hasUnfoldings.bind(e.endpointController.highlightsManager);p.propertiesFilterList=(yield e.getDataPropertiesByClasses([p.classTypeFilterList[0].entityViewData.value.iri.fullIri])).map((n=>vb(n,e.grapholscape,t)))}p.requestId=yield null===(c=e.endpointController)||void 0===c?void 0:c.requestInstancesThroughObjectProperty(g.iri.fullIri,r.detail.objectPropertyIri,r.detail.direct,!0,r.detail.rangeClassIri),p.requestId&&(null===(h=null===(d=e.endpointController)||void 0===d?void 0:d.shouldQueryUseLabels(p.requestId))||void 0===h||h.then((n=>t(this,void 0,void 0,(function*(){var t;n||(p.shouldAskForLabels=n,p.areInstancesLoading=!0,p.requestId=yield null===(t=e.endpointController)||void 0===t?void 0:t.requestInstancesThroughObjectProperty(g.iri.fullIri,r.detail.objectPropertyIri,r.detail.direct,n,r.detail.rangeClassIri))})))))}n.popperRef&&px(p,e)}})))),n.tippyWidget.setProps({onHide:()=>rx(n,e)})}(o),o.grapholscape.widgets.get(Fg.ENTITY_SELECTOR)||Cb(o.grapholscape),i=n.widgets.get(Fg.ENTITY_SELECTOR),null===(r=o.grapholscape.uiContainer)||void 0===r||r.appendChild(i),i.hide(),i.onClassSelection((e=>{const t={x:200*Math.random(),y:200*Math.random()};o.addEntity(e,!0,t),n.selectElement(e),Ex(i),i.closePanel()})),n.renderState===e.RendererStatesEnum.INCREMENTAL?Tx(n,o):Sx(n.widgets),n.on(e.LifecycleEvent.RendererChange,(t=>{t===e.RendererStatesEnum.INCREMENTAL?Tx(n,o):Sx(n.widgets)})),o.on(WE.DiagramUpdated,(()=>{var e,t;const r=n.widgets.get(Fg.ENTITY_SELECTOR);(null===(e=n.renderer.cy)||void 0===e?void 0:e.elements().empty())?(null===(t=n.widgets.get(Fg.ENTITY_DETAILS))||void 0===t||t.hide(),r&&(xx(r),r.focusInputSearch())):r&&Ex(r);const i=n.widgets.get(Fg.ONTOLOGY_EXPLORER);i&&(i.entities=Eb(n,i.searchEntityComponent))})),o.on(WE.Reset,(()=>{var t;o.grapholscape.renderState===e.RendererStatesEnum.INCREMENTAL&&Cx(n.widgets,null===(t=n.renderer.cy)||void 0===t?void 0:t.elements().empty(),void 0!==o.endpointController)}))}function Tx(e,t){var n;e.renderer.unselect(),t||(t=new wx(e)),Cx(e.widgets,null===(n=e.renderer.cy)||void 0===n?void 0:n.elements().empty(),void 0!==t.endpointController),e.renderer.diagram&&PE(e.renderer.diagram,e.lifecycle,e.ontology),t.setIncrementalEventHandlers()}function Cx(e,t=!1,n){const r=e.get(Fg.FILTERS),i=e.get(Fg.DIAGRAM_SELECTOR),o=e.get(Fg.ENTITY_SELECTOR),a=e.get(Fg.CLASS_INSTANCE_DETAILS),s=e.get(Fg.VKG_PREFERENCES);null==a||a.enable(),null==i||i.disable(),null==o||o.show(),t&&o&&(xx(o),o.focusInputSearch()),n&&(null==s||s.enable()),null==r||r.disable()}function Sx(e){const t=e.get(Fg.FILTERS),n=e.get(Fg.DIAGRAM_SELECTOR),r=e.get(Fg.ENTITY_SELECTOR),i=e.get(Fg.CLASS_INSTANCE_DETAILS),o=e.get(Fg.VKG_PREFERENCES);null==i||i.disable(),null==o||o.disable(),null==n||n.enable(),null==r||r.hide(),null==t||t.enable()}function Ix(e,n,r){return t(this,void 0,void 0,(function*(){if(!e||!n)return void console.error("Please specify an ontology and a container for Grapholscape");const t=Vg();return r=Object.assign(r||{},t),new Promise(((t,o)=>{let a;if("object"==typeof e){let t=new FileReader;t.onloadend=()=>{try{a=i(t.result),s()}catch(e){o(e)}},t.readAsText(e),setTimeout((()=>{o("Error: timeout expired")}),1e4)}else"string"==typeof e?(a=i(e),s()):o("Err: Grapholscape needs a Graphol File or the corresponding string to be initialized");function s(){try{const e=new kE(a,n,r);t(e)}catch(e){console.error(e)}}}));function i(e){return new Xf(e).parseGraphol()}}))}return Hd.use(Ag),Hd.use(Hh),Hd.warnings(!1),e.AnnotatedElement=kg,e.Annotation=af,e.BaseFilterManager=bf,e.BaseRenderer=xf,e.Breakpoint=Tf,e.CSS_PROPERTY_NAMESPACE=gf,e.ClassInstanceEntity=mf,e.DefaultThemes=pf,e.Diagram=tf,e.DiagramRepresentation=ef,e.Filter=ff,e.FloatyRendererState=Lb,e.GrapholEdge=Wg,e.GrapholElement=Xg,e.GrapholEntity=Qg,e.GrapholNode=Kg,e.GrapholNodesEnum=Rg,e.GrapholRendererState=Mb,e.Grapholscape=kE,e.GrapholscapeTheme=sf,e.Hierarchy=Sf,e.IncrementalController=wx,e.IncrementalDiagram=nf,e.IncrementalRendererState=Bb,e.Iri=of,e.Lifecycle=_f,e.LiteRendererState=Fb,e.Namespace=rf,e.Ontology=Mg,e.POLYGON_POINTS=Og,e.Renderer=NE,e.bareGrapholscape=function(n,r,i){return t(this,void 0,void 0,(function*(){const t=yield Ix(n,r,i);return(null==t?void 0:t.renderers.includes(e.RendererStatesEnum.INCREMENTAL))&&_x(t),t}))},e.classicColourMap=df,e.clearLocalStorage=function(){Object.keys(window.localStorage).filter((e=>e.startsWith(zg))).forEach((e=>window.localStorage.removeItem(e)))},e.darkColourMap=hf,e.floatyOptions=Gg,e.fullGrapholscape=function(n,r,i){return t(this,void 0,void 0,(function*(){const t=yield Ix(n,r,i);return t&&(vE(t),(!1===(null==i?void 0:i.initialRendererSelection)||t.renderState)&&t.widgets.get(Fg.INITIAL_RENDERER_SELECTOR).hide(),t.renderers.includes(e.RendererStatesEnum.INCREMENTAL)&&_x(t)),t}))},e.getDefaultFilters=yf,e.grapholOptions=$g,e.gscapeColourMap=cf,e.initIncremental=_x,e.isGrapholEdge=Zg,e.isGrapholNode=Jg,e.liteOptions=Bg,e.loadConfig=Vg,e.setGraphEventHandlers=PE,e.storeConfigEntry=jg,e.toPNG=_E,e.toSVG=TE,e.ui=mE,e.util=yb,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); + `],customElements.define("gscape-navigation-menu",bx);class wx{constructor(t){this.grapholscape=t,this.classInstanceEntities=new Map,this.diagram=new nf,this.counts=new Map,this.countersEnabled=!0,this.lifecycle=new ZE,this.on=this.lifecycle.on,this.onShowDataLineage=()=>{},this.runLayout=()=>{var e;return null===(e=this.incrementalRenderer)||void 0===e?void 0:e.runLayout()},this.pinNode=e=>{var t;return null===(t=this.incrementalRenderer)||void 0===t?void 0:t.pinNode(e)},this.unpinNode=e=>{var t;return null===(t=this.incrementalRenderer)||void 0===t?void 0:t.unpinNode(e)},this.diagramBuilder=new ME(this.diagram),this.addEdge=this.diagramBuilder.addEdge.bind(this.diagramBuilder),this.neighbourhoodFinder=new JE(this.ontology),t.on(e.LifecycleEvent.EntityNameTypeChange,(e=>{this.classInstanceEntities.forEach((e=>this.updateEntityNameType(e.iri)))})),t.on(e.LifecycleEvent.LanguageChange,(n=>{var r;null===(r=this.endpointController)||void 0===r||r.setLanguage(n),t.entityNameType===e.EntityNameType.LABEL&&this.classInstanceEntities.forEach((e=>this.updateEntityNameType(e.iri)))}))}showDiagram(e){e&&(this.diagram.lastViewportState=e),PE(this.diagram,this.grapholscape.lifecycle,this.grapholscape.ontology),this.grapholscape.renderer.render(this.diagram)}performActionWithBlockedGraph(e){var n;return t(this,void 0,void 0,(function*(){const t=this.numberOfElements;null===(n=this.incrementalRenderer)||void 0===n||n.freezeGraph(),yield e(),this.postDiagramEdit(t)}))}setMastroConnection(e){this.reset(),e.onError||(e.onError=e=>console.error(e)),this.endpointController=new KE(e,this.lifecycle),this.endpointController.setLanguage(this.grapholscape.language),this.lifecycle.trigger(WE.ReasonerSet)}addEntity(t,n=!0,r){const i=this.grapholscape.ontology.getEntity(t);i&&this.diagramBuilder.diagram.representation&&(r&&i.is(e.GrapholTypesEnum.CLASS)?this.diagramBuilder.addClass(i,r):this.diagramBuilder.addEntity(i),this.updateEntityNameType(i.iri),n&&this.grapholscape.centerOnElement(t),i.is(e.GrapholTypesEnum.CLASS)&&this.countInstancesForClass(t))}areHierarchiesVisible(e){var t;let n=!0;for(let r of e)if(r.id&&(null===(t=this.grapholscape.renderer.cy)||void 0===t?void 0:t.$id(r.id).empty())){n=!1;break}return n}areAllConnectedClassesVisibleForClass(t,n,r){var i;for(let o of n){const n=null===(i=this.grapholscape.renderer.cy)||void 0===i?void 0:i.$id(o).connectedEdges(`[ type ="${"equivalent"===r?e.GrapholTypesEnum.EQUIVALENCE:e.GrapholTypesEnum.INCLUSION}" ]`);if(n){if("sub"===r&&n.targets(`[id = "${t}"]`).empty())return!1;if("super"===r&&n.sources(`[id = "${t}"]`).empty())return!1;if("equivalent"===r&&n.connectedNodes(`[id = "${t}"]`).empty())return!1}}return!0}reset(){var e;null===(e=this.incrementalRenderer)||void 0===e||e.reset(),this.classInstanceEntities.clear(),this.diagram.clear(),this.clearState(),this.lifecycle.trigger(WE.Reset)}clearState(){var e;null===(e=this.endpointController)||void 0===e||e.clear()}updateEntityNameType(t){var n,r;let i;i="string"!=typeof t?t.fullIri:t;const o=this.classInstanceEntities.get(i)||this.ontology.getEntity(i);let a,s=null===(n=this.diagram.representation)||void 0===n?void 0:n.grapholElements.get(i);o&&!s?a=null===(r=o.occurrences.get(e.RendererStatesEnum.INCREMENTAL))||void 0===r?void 0:r.map((e=>{var t,n;return null===(n=null===(t=this.diagram)||void 0===t?void 0:t.representation)||void 0===n?void 0:n.grapholElements.get(e.elementId)})).filter((e=>void 0!==e)):s&&(a=[s]),o&&a&&a.forEach((e=>{var t,n;e.displayedName=o.getDisplayedName(this.grapholscape.entityNameType,this.grapholscape.language),null===(n=null===(t=this.diagram)||void 0===t?void 0:t.representation)||void 0===n||n.updateElement(e,!1)}))}removeEntity(t,n=[]){let r;r="string"==typeof t?this.classInstanceEntities.get(t)||this.ontology.getEntity(t):t,this.performActionWithBlockedGraph((()=>{var t;null===(t=this.grapholscape.renderer.cy)||void 0===t||t.$(`[iri = "${null==r?void 0:r.iri.fullIri}"]`).forEach((t=>{var i,o;t.connectedEdges(`[type = "${e.GrapholTypesEnum.OBJECT_PROPERTY}"]`).forEach((t=>{const n=this.ontology.getEntity(t.data().iri);n&&n.removeOccurrence(t.id(),this.diagram.id,e.RendererStatesEnum.INCREMENTAL)})),t.data().type===e.GrapholTypesEnum.CLASS&&(t.neighborhood().forEach((e=>{e.isNode()?1!==e.degree(!1)||n.includes(e.id())||(e.data().iri?(n.push((null==r?void 0:r.iri.fullIri)||""),this.removeEntity(e.data().iri,n)):this.diagram.removeElement(e.id())):this.diagram.removeElement(e.id())})),null===(i=this.ontology.hierarchiesBySubclassMap.get(r.iri.fullIri))||void 0===i||i.forEach((e=>{this.removeHierarchy(e)})),null===(o=this.ontology.hierarchiesBySuperclassMap.get(r.iri.fullIri))||void 0===o||o.forEach((e=>{this.removeHierarchy(e)}))),this.diagram.removeElement(t.id()),null==r||r.removeOccurrence(t.id(),this.diagram.id,e.RendererStatesEnum.INCREMENTAL),(null==r?void 0:r.is(e.GrapholTypesEnum.CLASS_INSTANCE))&&this.classInstanceEntities.delete(r.iri.fullIri)}))}))}addInstance(t,n){var r,i;let o=this.classInstanceEntities.get(t.iri);if(!o){const n=new of(t.iri,this.ontology.namespaces,t.shortIri);o=new mf(n),t.label&&o.addAnnotation(new af(e.AnnotationsKind.label,t.label.value,t.label.language)),null===(r=this.endpointController)||void 0===r||r.requestLabels(t.iri).then((t=>{null==t||t.forEach((t=>{o.addAnnotation(new af(e.AnnotationsKind.label,t.value,t.language))})),this.updateEntityNameType(o.iri)})),this.diagramBuilder.addClassInstance(o),this.classInstanceEntities.set(t.iri,o)}if("string"!=typeof n)n||(n=this.ontology.getEntitiesByType(e.GrapholTypesEnum.CLASS).map((e=>e.iri.fullIri))),null===(i=this.endpointController)||void 0===i||i.instanceCheck(t.iri,n).then((e=>{e.forEach((e=>{const t=this.ontology.getEntity(e);t&&o&&o.addParentClass(t.iri)}))}));else{const e=this.ontology.getEntity(n);e&&o.addParentClass(e.iri)}return this.updateEntityNameType(o.iri),this.lifecycle.trigger(WE.DiagramUpdated),o}addIntensionalObjectProperty(e,t,n){const r=this.ontology.getEntity(e),i=this.ontology.getEntity(t),o=this.ontology.getEntity(n);r&&i&&o&&(this.performActionWithBlockedGraph((()=>{this.diagramBuilder.addObjectProperty(r,i,o),this.updateEntityNameType(r.iri),this.updateEntityNameType(t),this.updateEntityNameType(n)})),this.countInstancesForClass(t),this.countInstancesForClass(n))}addExtensionalObjectProperty(e,t,n){const r=this.ontology.getEntity(e),i=this.classInstanceEntities.get(t),o=this.classInstanceEntities.get(n);r&&i&&o&&this.performActionWithBlockedGraph((()=>{this.diagramBuilder.addObjectProperty(r,i,o),this.updateEntityNameType(r.iri),this.updateEntityNameType(i.iri),this.updateEntityNameType(o.iri)}))}showSuperHierarchiesOf(e){this.showOrHideHierarchies(e,"super","show")}showSubHierarchiesOf(e){this.showOrHideHierarchies(e,"sub","show")}hideSuperHierarchiesOf(e){this.showOrHideHierarchies(e,"super","hide")}hideSubHierarchiesOf(e){this.showOrHideHierarchies(e,"sub","hide")}showOrHideHierarchies(e,t,n){if(!this.ontology.getEntity(e))return;let r;const i=this.ontology.hierarchiesBySuperclassMap.get(e),o=this.ontology.hierarchiesBySubclassMap.get(e);switch(t){case"super":r=o;break;case"sub":r=i;break;case"any":r=[],i&&r.concat(i),o&&r.concat(o);break;default:return}r&&r.length>0&&this.performActionWithBlockedGraph((()=>{var t;const i=null===(t=this.grapholscape.renderer.cy)||void 0===t?void 0:t.$id(e).position();"show"===n?null==r||r.forEach((e=>this.addHierarchy(e,i))):null==r||r.forEach((t=>this.removeHierarchy(t,[e])))}))}addHierarchy(e,t){var n,r;const i=e.getUnionGrapholNode(t),o=e.getInputGrapholEdges(),a=e.getInclusionEdges();if(i&&o&&a){this.diagram.addElement(i);for(const t of e.inputs)this.addEntity(t,!1);for(const t of e.superclasses)this.addEntity(t.classIri,!1);null===(n=e.getInputGrapholEdges())||void 0===n||n.forEach((e=>this.diagram.addElement(e))),null===(r=e.getInclusionEdges())||void 0===r||r.forEach((e=>this.diagram.addElement(e)))}}removeHierarchy(e,t=[]){var n,r,i;if(!this.incrementalRenderer||!e.id||e.id&&(null===(n=this.grapholscape.renderer.cy)||void 0===n?void 0:n.$id(e.id).empty()))return;let o;this.diagram.removeElement(e.id),null===(r=e.getInputGrapholEdges())||void 0===r||r.forEach((e=>{var t;null===(t=this.diagram)||void 0===t||t.removeElement(e.id)})),null===(i=e.getInclusionEdges())||void 0===i||i.forEach((e=>{var t;null===(t=this.diagram)||void 0===t||t.removeElement(e.id)})),e.inputs.forEach((e=>{var n;0!==(null===(n=this.grapholscape.renderer.cy)||void 0===n?void 0:n.$id(e).degree(!1))||t.includes(e)||(o=this.ontology.getEntity(e),o&&this.removeEntity(o))})),e.superclasses.forEach((e=>{var n;0!==(null===(n=this.grapholscape.renderer.cy)||void 0===n?void 0:n.$id(e.classIri).degree(!1))||t.includes(e.classIri)||(o=this.ontology.getEntity(e.classIri),o&&this.removeEntity(o))}))}showSubClassesOf(t,n){n||(n=this.neighbourhoodFinder.getSubclassesIris(t)),this.showClassesInIsa(t,n,e.GrapholTypesEnum.INCLUSION)}showSuperClassesOf(t,n){n||(n=this.neighbourhoodFinder.getSuperclassesIris(t)),this.showClassesInIsa(t,n,e.GrapholTypesEnum.INCLUSION,"super")}showEquivalentClassesOf(t,n){n||(n=this.neighbourhoodFinder.getEquivalentClassesIris(t)),this.showClassesInIsa(t,n,e.GrapholTypesEnum.EQUIVALENCE)}showClassesInIsa(e,t,n,r="sub"){this.performActionWithBlockedGraph((()=>{t.forEach((t=>{this.addEntity(t,!1),"super"===r?this.diagramBuilder.addEdge(e,t,n):this.diagramBuilder.addEdge(t,e,n)}))}))}getObjectPropertiesByClasses(e){var n,r,i;return t(this,void 0,void 0,(function*(){if(null===(n=this.endpointController)||void 0===n?void 0:n.isReasonerAvailable()){null===(r=this.endpointController.highlightsManager)||void 0===r||r.computeHighlights(e);const t=yield null===(i=this.endpointController.highlightsManager)||void 0===i?void 0:i.objectProperties(),n=new Map;return null==t||t.forEach((e=>{var t;if(!e.objectPropertyIRI)return;const r=this.ontology.getEntity(e.objectPropertyIRI);if(!r)return;const i={list:[],direct:e.direct||!1};null===(t=e.relatedClasses)||void 0===t||t.forEach((e=>{const t=this.ontology.getEntity(e);t&&i.list.push(t)})),n.set(r,i)})),n}return this.neighbourhoodFinder.getObjectProperties(e[0])}))}getDataPropertiesByClasses(e){var n,r,i;return t(this,void 0,void 0,(function*(){if(null===(n=this.endpointController)||void 0===n?void 0:n.isReasonerAvailable()){null===(r=this.endpointController.highlightsManager)||void 0===r||r.computeHighlights(e);const t=yield null===(i=this.endpointController.highlightsManager)||void 0===i?void 0:i.dataProperties();return(null==t?void 0:t.map((e=>this.ontology.getEntity(e))).filter((e=>null!==e)))||[]}return this.neighbourhoodFinder.getDataProperties(e[0])}))}getDataPropertiesByClassInstance(e){var n;return t(this,void 0,void 0,(function*(){const t=this.classInstanceEntities.get(e);return t&&(null===(n=this.endpointController)||void 0===n?void 0:n.highlightsManager)?(this.endpointController.highlightsManager.computeHighlights(t.parentClassIris.map((e=>e.fullIri))),(yield this.endpointController.highlightsManager.dataProperties()).map((e=>this.ontology.getEntity(e))).filter((e=>null!==e))):[]}))}postDiagramEdit(e){var t;this.numberOfElements!==e?(this.runLayout(),this.lifecycle.trigger(WE.DiagramUpdated)):null===(t=this.incrementalRenderer)||void 0===t||t.unFreezeGraph()}countInstancesForClass(e){var n,r,i,o;return t(this,void 0,void 0,(function*(){if(!this.countersEnabled||!(null===(n=this.endpointController)||void 0===n?void 0:n.isReasonerAvailable()))return;const t=null===(i=null===(r=this.diagram)||void 0===r?void 0:r.representation)||void 0===i?void 0:i.cy.$id(e);if(t&&!t.empty())if(yield this.updateMaterializedCounts(),void 0===this.counts.get(e))null===(o=this.endpointController)||void 0===o||o.requestCountForClass(e);else{let n;const r=this.counts.get(e);t.scratch("instance-count")?(n=t.scratch("instance-count"),n.content=r.value):(n=mx(t,r.value,"instance-count","bottom"),setTimeout((()=>n.hide()),1e3),t.on("mouseover",(()=>{this.countersEnabled&&n.tippyWidget.show()})),t.on("mouseout",(()=>n.tippyWidget.hide()))),r.materialized?(n.highlighted=!1,n.title=`Date: ${r.date}`):(n.highlighted=!0,n.title="Fresh Value")}}))}updateMaterializedCounts(){var e;return t(this,void 0,void 0,(function*(){const t=yield null===(e=this.endpointController)||void 0===e?void 0:e.getMaterializedCounts();t&&t.countsMap.forEach((e=>{var n;if(e.state===OE.FINISHED){const r=this.counts.get(e.entity.entityIRI);r&&!r.materialized||(this.counts.set(e.entity.entityIRI,{value:e.count,materialized:!0,date:0!==t.endTime?new Date(t.endTime).toDateString():new Date(t.startTime).toDateString()}),this.lifecycle.trigger(WE.NewCountResult,e.entity.entityIRI,{value:e.count,materialized:!0,date:null===(n=this.counts.get(e.entity.entityIRI))||void 0===n?void 0:n.date}))}}))}))}setIncrementalEventHandlers(){var t,n,r,i;(null===(t=this.diagram.representation)||void 0===t?void 0:t.hasEverBeenRendered)||(null===(n=this.diagram.representation)||void 0===n?void 0:n.cy.scratch("_gscape-incremental-graph-handlers-set"))||(null===(r=this.diagram.representation)||void 0===r||r.cy.on("tap",(t=>{const n=t.target.data().type;if(n===e.GrapholTypesEnum.CLASS||n===e.GrapholTypesEnum.CLASS_INSTANCE){const r=()=>{var r,i;const o=t.target.data().iri;if(n===e.GrapholTypesEnum.CLASS_INSTANCE){const e=this.classInstanceEntities.get(o);e&&(o!==this.lastInstanceIri&&(null===(r=this.endpointController)||void 0===r||r.stopRequests("instances")),this.lifecycle.trigger(WE.ClassInstanceSelection,e))}else{o!==this.lastClassIri&&(null===(i=this.endpointController)||void 0===i||i.stopRequests("instances"));const e=this.grapholscape.ontology.getEntity(o);e&&this.lifecycle.trigger(WE.ClassSelection,e)}};this.endpointController?(clearTimeout(this.entitySelectionTimeout),this.entitySelectionTimeout=setTimeout(r,400)):r()}})),null===(i=this.diagram.representation)||void 0===i||i.cy.scratch("_gscape-incremental-graph-handlers-set",!0))}get ontology(){return this.grapholscape.ontology}get incrementalRenderer(){if(this.grapholscape.renderState===e.RendererStatesEnum.INCREMENTAL)return this.grapholscape.renderer.renderState}get numberOfElements(){var e;return(null===(e=this.grapholscape.renderer.cy)||void 0===e?void 0:e.elements().size())||0}}function _x(n){var r,i;let o,a=new wx(n);n.incremental=a,function(n){const r=new tx,i=n.grapholscape.widgets.get(Fg.ENTITY_DETAILS);i&&(i.incrementalSection=r),n.grapholscape.widgets.set(Fg.CLASS_INSTANCE_DETAILS,r),n.grapholscape.on(e.LifecycleEvent.EntitySelection,(i=>t(this,void 0,void 0,(function*(){let t;i.is(e.GrapholTypesEnum.CLASS)&&n.grapholscape.renderState===e.RendererStatesEnum.INCREMENTAL?(t=yield n.getDataPropertiesByClasses([i.iri.fullIri]),r.dataProperties=t.map((e=>fb(e,n.grapholscape))),r.parentClasses=void 0,r.canShowDataPropertiesValues=!1,r.show()):r.hide()})))),n.on(WE.ClassInstanceSelection,(e=>t(this,void 0,void 0,(function*(){var t;if(!(null==i?void 0:i.grapholEntity)||!(null==i?void 0:i.grapholEntity.iri.equals(e.iri))){null===(t=n.endpointController)||void 0===t||t.stopRequests("instances");const i=e.parentClassIris.map((e=>e.fullIri)),o=yield n.getDataPropertiesByClasses(i);r.dataProperties=o.map((e=>fb(e,n.grapholscape))),r.parentClasses=i.map((e=>{const t=n.grapholscape.ontology.getEntity(e);if(t)return fb(t,n.grapholscape)})).filter((e=>void 0!==e)),o.forEach((t=>{var r;null===(r=n.endpointController)||void 0===r||r.requestDataPropertyValues(e.iri.fullIri,t.iri.fullIri)}))}r.canShowDataPropertiesValues=!0,null==i||i.setGrapholEntity(e),r.show()})))),n.on(WE.NewDataPropertyValues,((e,t,n)=>{(null==i?void 0:i.grapholEntity.iri.equals(e))&&n.forEach((e=>r.addDataPropertyValue(t,e)))})),n.on(WE.DataPropertyValuesLoadingFinished,((e,t)=>{(null==i?void 0:i.grapholEntity.iri.equals(e))&&r.setDataPropertyLoading(t,!1)}))}(a),function(n){var r,i;const o=new nx;function a(){var e;null===(e=n.endpointController)||void 0===e||e.getRunningEndpoints().then((e=>{var t,r;o.endpoints=e.map((e=>({name:e.name}))).sort(((e,t)=>e.name.localeCompare(t.name))),e.length>=1&&!o.selectedEndpointName&&(null===(t=n.endpointController)||void 0===t||t.setEndpoint(e[0]),null===(r=n.endpointController)||void 0===r||r.setLanguage(n.grapholscape.language))}))}o.showCounters=n.countersEnabled,n.grapholscape.widgets.set(Fg.VKG_PREFERENCES,o),null===(i=null===(r=n.grapholscape.uiContainer)||void 0===r?void 0:r.querySelector(".gscape-ui-buttons-tray"))||void 0===i||i.appendChild(o),n.grapholscape.renderState===e.RendererStatesEnum.INCREMENTAL&&n.endpointController||o.disable(),n.endpointController&&a(),n.on(WE.EndpointChange,(e=>{o.selectedEndpointName=e.name})),n.on(WE.LimitChange,(e=>{o.pageSize=e})),n.on(WE.ReasonerSet,(()=>{n.grapholscape.renderState===e.RendererStatesEnum.INCREMENTAL&&o.enable(),a(),n.endpointController&&(o.pageSize=n.endpointController.pageSize)})),o.onTogglePanel=()=>a(),o.onEndpointChange((e=>{var r;const i=new hb("Are you sure? \nIf you change the current endpoint, your exploration will be reset.");null===(r=n.grapholscape.uiContainer)||void 0===r||r.appendChild(i),i.show(),i.onConfirm=()=>t(this,void 0,void 0,(function*(){var t,r;n.reset(),null===(t=n.endpointController)||void 0===t||t.setEndpoint(e),null===(r=n.endpointController)||void 0===r||r.setLanguage(n.grapholscape.language)}))})),o.onPageSizeChange((e=>{var t;null===(t=n.endpointController)||void 0===t||t.setPageSize(e)})),o.onShowCountersChange((e=>{n.countersEnabled=e})),o.onStopRequests((()=>{var e;return null===(e=n.endpointController)||void 0===e?void 0:e.stopRequests()}))}(a),function(n){const r=new ox;n.grapholscape.widgets.set(Fg.INSTANCES_EXPLORER,r),n.on(WE.NewInstances,((e,t)=>{r.addInstances(e.map((e=>{var t;return e[1]&&(e[0].searchMatch=null===(t=e[1].label)||void 0===t?void 0:t.value),e[0].connectedInstance=e[1],e[0]}))),!r.numberResultsAvailable&&t&&(r.numberResultsAvailable=t)})),n.on(WE.InstancesSearchFinished,(()=>r.areInstancesLoading=!1)),n.on(WE.Reset,(()=>{r.clear()})),r.addEventListener("instanceselection",(i=>t(this,void 0,void 0,(function*(){var t,o,a,s;let l;if(l=n.addInstance(i.detail.instance,i.detail.parentClassIris),l.parentClassIris.forEach((t=>{n.addEdge(i.detail.instance.iri,t.fullIri,e.GrapholTypesEnum.INSTANCE_OF)})),i.detail.instance.connectedInstance&&i.detail.filterByProperty){n.addInstance(i.detail.instance.connectedInstance);const e=null===(s=null===(a=yield null===(o=null===(t=n.endpointController)||void 0===t?void 0:t.highlightsManager)||void 0===o?void 0:o.objectProperties())||void 0===a?void 0:a.find((e=>e.objectPropertyIRI===i.detail.filterByProperty)))||void 0===s?void 0:s.direct;void 0!==e&&(e?n.addExtensionalObjectProperty(i.detail.filterByProperty,i.detail.instance.iri,i.detail.instance.connectedInstance.iri):n.addExtensionalObjectProperty(i.detail.filterByProperty,i.detail.instance.connectedInstance.iri,i.detail.instance.iri))}if(r.referenceEntity&&r.referencePropertyEntity&&l){const e=r.referenceEntity.value.iri.fullIri,t=r.referencePropertyEntity.value.iri.fullIri;r.isPropertyDirect?n.addExtensionalObjectProperty(t,e,l.iri.fullIri):n.addExtensionalObjectProperty(t,l.iri.fullIri,e)}n.runLayout()})))),r.addEventListener("instances-filter",(i=>t(this,void 0,void 0,(function*(){var t,o,a,s;null===(t=n.endpointController)||void 0===t||t.stopRequests("instances"),r.instances=new Map,r.numberOfInstancesReceived=0,r.numberResultsAvailable=0,r.numberOfPagesShown=1,r.areInstancesLoading=!0,r.referenceEntity&&(r.referenceEntity.value.type===e.GrapholTypesEnum.CLASS?r.requestId=yield null===(o=n.endpointController)||void 0===o?void 0:o.requestInstancesForClass(null===(a=r.referenceEntity)||void 0===a?void 0:a.value.iri.fullIri,i.detail.shouldAskForLabels,i.detail.filterText,i.detail.filterByProperty,i.detail.propertyType,i.detail.direct):r.referenceEntity.value.type===e.GrapholTypesEnum.CLASS_INSTANCE&&r.referencePropertyEntity&&(r.requestId=yield null===(s=n.endpointController)||void 0===s?void 0:s.requestInstancesThroughObjectProperty(r.referenceEntity.value.iri.fullIri,r.referencePropertyEntity.value.iri.fullIri,r.isPropertyDirect,i.detail.shouldAskForLabels,i.detail.filterByType,i.detail.filterByProperty,i.detail.filterText)))})))),r.addEventListener("showmoreinstances",(e=>t(this,void 0,void 0,(function*(){var e,t;null===(e=n.endpointController)||void 0===e||e.stopRequests("instances"),r.areInstancesLoading=!0,r.requestId&&(null===(t=n.endpointController)||void 0===t||t.requestNewInstances(r.requestId,r.numberOfPagesShown+1))})))),r.tippyWidget.setProps({onHide:()=>{r.hide(),rx(r,n)}})}(a),dx(a),gx(a),function(e){const n=new bx;e.grapholscape.widgets.set(Fg.NAVIGATION_MENU,n),n.requestUpdate(),n.addEventListener("onclassselection",(t=>{t.detail.rangeClassIri&&(t.detail.direct?e.addIntensionalObjectProperty(t.detail.objectPropertyIri,t.detail.referenceClassIri,t.detail.rangeClassIri):e.addIntensionalObjectProperty(t.detail.objectPropertyIri,t.detail.rangeClassIri,t.detail.referenceClassIri),setTimeout((()=>{e.grapholscape.centerOnElement(t.detail.rangeClassIri)}),250),n.popperRef=void 0,n.hide())})),n.addEventListener("onobjectpropertyselection",(r=>t(this,void 0,void 0,(function*(){var i,o,a,s,l,u,c,d,h;const p=e.grapholscape.widgets.get(Fg.INSTANCES_EXPLORER);if(p){const g=e.classInstanceEntities.get(r.detail.referenceClassIri),f=e.grapholscape.ontology.getEntity(r.detail.objectPropertyIri);if(g&&f&&(!(null===(i=p.referenceEntity)||void 0===i?void 0:i.value.iri.equals(g.iri))||!(null===(o=p.referencePropertyEntity)||void 0===o?void 0:o.value.iri.equals(f.iri)))){if(n.hide(),p.clear(),p.areInstancesLoading=!0,p.referenceEntity=n.referenceEntity,p.referencePropertyEntity=fb(f,e.grapholscape),p.isPropertyDirect=r.detail.direct,p.classTypeFilterList=null===(a=n.objectProperties.find((e=>e.entityViewData.value.iri.equals(r.detail.objectPropertyIri))))||void 0===a?void 0:a.connectedClasses,1===(null===(s=p.classTypeFilterList)||void 0===s?void 0:s.length)){const t=null===(u=null===(l=e.endpointController)||void 0===l?void 0:l.highlightsManager)||void 0===u?void 0:u.hasUnfoldings.bind(e.endpointController.highlightsManager);p.propertiesFilterList=(yield e.getDataPropertiesByClasses([p.classTypeFilterList[0].entityViewData.value.iri.fullIri])).map((n=>vb(n,e.grapholscape,t)))}p.requestId=yield null===(c=e.endpointController)||void 0===c?void 0:c.requestInstancesThroughObjectProperty(g.iri.fullIri,r.detail.objectPropertyIri,r.detail.direct,!0,r.detail.rangeClassIri),p.requestId&&(null===(h=null===(d=e.endpointController)||void 0===d?void 0:d.shouldQueryUseLabels(p.requestId))||void 0===h||h.then((n=>t(this,void 0,void 0,(function*(){var t;n||(p.shouldAskForLabels=n,p.areInstancesLoading=!0,p.requestId=yield null===(t=e.endpointController)||void 0===t?void 0:t.requestInstancesThroughObjectProperty(g.iri.fullIri,r.detail.objectPropertyIri,r.detail.direct,n,r.detail.rangeClassIri))})))))}n.popperRef&&px(p,e)}})))),n.tippyWidget.setProps({onHide:()=>rx(n,e)})}(a),a.grapholscape.widgets.get(Fg.ENTITY_SELECTOR)||Cb(a.grapholscape),o=n.widgets.get(Fg.ENTITY_SELECTOR),null===(r=a.grapholscape.uiContainer)||void 0===r||r.appendChild(o),o.hide(),o.onClassSelection((e=>{const t={x:200*Math.random(),y:200*Math.random()};a.addEntity(e,!0,t),n.selectElement(e),Ex(o),o.closePanel()})),n.renderState===e.RendererStatesEnum.INCREMENTAL?(n.renderer.unselect(),Tx(n.widgets,null===(i=n.renderer.cy)||void 0===i?void 0:i.elements().empty(),void 0!==a.endpointController)):Cx(n.widgets),n.on(e.LifecycleEvent.RendererChange,(t=>{t===e.RendererStatesEnum.INCREMENTAL?function(e,t){var n;e.renderer.unselect(),Tx(e.widgets,null===(n=e.renderer.cy)||void 0===n?void 0:n.elements().empty(),void 0!==t.endpointController)}(n,a):Cx(n.widgets)})),a.on(WE.DiagramUpdated,(()=>{var e,t;const r=n.widgets.get(Fg.ENTITY_SELECTOR);(null===(e=n.renderer.cy)||void 0===e?void 0:e.elements().empty())?(null===(t=n.widgets.get(Fg.ENTITY_DETAILS))||void 0===t||t.hide(),r&&(xx(r),r.focusInputSearch())):r&&Ex(r);const i=n.widgets.get(Fg.ONTOLOGY_EXPLORER);i&&(i.entities=Eb(n,i.searchEntityComponent))})),a.on(WE.Reset,(()=>{var t;a.grapholscape.renderState===e.RendererStatesEnum.INCREMENTAL&&Tx(n.widgets,null===(t=n.renderer.cy)||void 0===t?void 0:t.elements().empty(),void 0!==a.endpointController)}))}function Tx(e,t=!1,n){const r=e.get(Fg.FILTERS),i=e.get(Fg.DIAGRAM_SELECTOR),o=e.get(Fg.ENTITY_SELECTOR),a=e.get(Fg.CLASS_INSTANCE_DETAILS),s=e.get(Fg.VKG_PREFERENCES);e.get(Fg.ENTITY_DETAILS).showOccurrences=!1,null==a||a.enable(),null==i||i.disable(),null==o||o.show(),t&&o&&(xx(o),o.focusInputSearch()),n&&(null==s||s.enable()),null==r||r.disable()}function Cx(e){const t=e.get(Fg.FILTERS),n=e.get(Fg.DIAGRAM_SELECTOR),r=e.get(Fg.ENTITY_SELECTOR),i=e.get(Fg.CLASS_INSTANCE_DETAILS),o=e.get(Fg.VKG_PREFERENCES);e.get(Fg.ENTITY_DETAILS).showOccurrences=!0,null==i||i.disable(),null==o||o.disable(),null==n||n.enable(),null==r||r.hide(),null==t||t.enable()}function Sx(e,n,r){return t(this,void 0,void 0,(function*(){if(!e||!n)return void console.error("Please specify an ontology and a container for Grapholscape");const t=Vg();return r=Object.assign(r||{},t),new Promise(((t,o)=>{let a;if("object"==typeof e){let t=new FileReader;t.onloadend=()=>{try{a=i(t.result),s()}catch(e){o(e)}},t.readAsText(e),setTimeout((()=>{o("Error: timeout expired")}),1e4)}else"string"==typeof e?(a=i(e),s()):o("Err: Grapholscape needs a Graphol File or the corresponding string to be initialized");function s(){try{const e=new kE(a,n,r);t(e)}catch(e){console.error(e)}}}));function i(e){return new Xf(e).parseGraphol()}}))}return Hd.use(Ag),Hd.use(Hh),Hd.warnings(!1),e.AnnotatedElement=kg,e.Annotation=af,e.BaseFilterManager=bf,e.BaseRenderer=xf,e.Breakpoint=Tf,e.CSS_PROPERTY_NAMESPACE=gf,e.ClassInstanceEntity=mf,e.DefaultThemes=pf,e.Diagram=tf,e.DiagramRepresentation=ef,e.Filter=ff,e.FloatyRendererState=Lb,e.GrapholEdge=Wg,e.GrapholElement=Xg,e.GrapholEntity=Qg,e.GrapholNode=Kg,e.GrapholNodesEnum=Rg,e.GrapholRendererState=Mb,e.Grapholscape=kE,e.GrapholscapeTheme=sf,e.Hierarchy=Sf,e.IncrementalController=wx,e.IncrementalDiagram=nf,e.IncrementalRendererState=Bb,e.Iri=of,e.Lifecycle=_f,e.LiteRendererState=Fb,e.Namespace=rf,e.Ontology=Mg,e.POLYGON_POINTS=Og,e.Renderer=NE,e.bareGrapholscape=function(n,r,i){return t(this,void 0,void 0,(function*(){const t=yield Sx(n,r,i);return(null==t?void 0:t.renderers.includes(e.RendererStatesEnum.INCREMENTAL))&&_x(t),t}))},e.classicColourMap=df,e.clearLocalStorage=function(){Object.keys(window.localStorage).filter((e=>e.startsWith(zg))).forEach((e=>window.localStorage.removeItem(e)))},e.darkColourMap=hf,e.floatyOptions=Gg,e.fullGrapholscape=function(n,r,i){return t(this,void 0,void 0,(function*(){const t=yield Sx(n,r,i);return t&&(vE(t),(!1===(null==i?void 0:i.initialRendererSelection)||t.renderState)&&t.widgets.get(Fg.INITIAL_RENDERER_SELECTOR).hide(),t.renderers.includes(e.RendererStatesEnum.INCREMENTAL)&&_x(t)),t}))},e.getDefaultFilters=yf,e.grapholOptions=$g,e.gscapeColourMap=cf,e.initIncremental=_x,e.isGrapholEdge=Zg,e.isGrapholNode=Jg,e.liteOptions=Bg,e.loadConfig=Vg,e.setGraphEventHandlers=PE,e.storeConfigEntry=jg,e.toPNG=_E,e.toSVG=TE,e.ui=mE,e.util=yb,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); diff --git a/package-lock.json b/package-lock.json index a7a730f9..ec4341c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "grapholscape", - "version": "3.2.4", + "version": "3.2.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "grapholscape", - "version": "3.2.4", + "version": "3.2.5", "license": "MIT", "dependencies": { "cytoscape": "^3.22.1", diff --git a/package.json b/package.json index 4054f03f..a403cc7a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grapholscape", - "version": "3.2.4", + "version": "3.2.5", "description": "ontology visualization", "module": "dist/grapholscape.esm.js", "main": "dist/grapholscape.esm.js",