@abi-software/map-utilities 1.8.1 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36981,11 +36981,11 @@ async function eW(t, e, r, n) {
36981
36981
  });
36982
36982
  }
36983
36983
  } else if (v === "alert") {
36984
- g.label = "Alert";
36984
+ g.label = "Notes";
36985
36985
  for (const m of ["with", "without"])
36986
36986
  y.push({
36987
36987
  key: `${g.key}.${m}`,
36988
- label: `${m} alerts`
36988
+ label: `${m} notes`
36989
36989
  });
36990
36990
  }
36991
36991
  g.children = y.sort((m, b) => m.label.localeCompare(b.label)), g.label && g.children.length && a.push(g);
@@ -471,4 +471,4 @@ Licensed under The MIT License (http://opensource.org/licenses/MIT)
471
471
  `)}</ul>`,i="<div><strong>References</strong></div>";this.referecesListContent=i+`
472
472
  `+a}this.$emit("references-loaded",{style:e,list:r})},replaceLinkInText:function(t){const e="https://";let r=t.split(e)[1];if(r){r=r.split(" ")[0],r=r.trim(),r.endsWith(".")&&(r=r.substring(0,r.length-1));const n=e+r,a=`<a href="${n}" target="_blank">${n}</a>`;return t.replace(n,a)}return t},searchPMID:async function(t){const e=`https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=${t}&format=json`;return await this.fetchData(e)},getCitationTextByDOI:async function(t){const e=`${this.crosscite_host}/format?doi=${t}&style=${this.citationType}&lang=en-US`;return await this.fetchData(e,"text")},getDOIFromPubMedID:async function(t){const e=`https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=pubmed&id=${t}&format=json`;return await this.fetchData(e)},formatOpenLibReferences:function(){this.openLibReferences.forEach(t=>{const{bookId:e}=t;this.getBookData(e).then(r=>{const{title:n,authors:a,publish_date:i}=r;n&&(t.title=n),i&&(t.date=i),a&&(t.authors=[],a.forEach(o=>{this.getBookAuthor(o.key).then(l=>{const{name:u}=l;u&&(t.authors.push(u),this.updateCopyContents())})})),this.updateCopyContents()})})},getBookData:async function(t){const e=`https://openlibrary.org/books/${t}.json`;return await this.fetchData(e)},getBookAuthor:async function(t){const e=`https://openlibrary.org${t}.json`;return await this.fetchData(e)},formatCopyReference:function(t){const e=[],{title:r,date:n,authors:a,url:i}=t;return r&&e.push(r),n&&e.push(`(${n})`),a&&e.push(`- ${a.join(", ")}`),e.push(`<div><a href="${i}" target="_blank">${i}</a></div>`),e.join(" ")},fetchData:async function(t,e){try{const r=await fetch(t);if(!r.ok)throw new Error(`Response status: ${r.status}`);return e==="text"?await r.text():await r.json()}catch(r){throw new Error(r)}},onCopied:function(t,e){let r="Reference List",n="",a=this.citationType;e?(r=e.resource,n=e.type==="doi"?e.id:""):r=[...this.pubMedReferences,...this.openLibReferences,...this.isbnDBReferences].map(u=>u.type==="doi"?u.id:u.resource).join(", ");const i={event:"interaction_event",event_name:"portal_maps_copy_citation",category:r,doi:n,citation_type:a,location:"map_connectivity_references"};this.$emit("trackEvent",i)}}},ga=t=>(s.pushScopeId("data-v-e4259096"),t=t(),s.popScopeId(),t),XK={class:"resource-container"},JK={class:"attribute-title-container"},QK=ga(()=>s.createElementVNode("div",{class:"attribute-title"},"References",-1)),eG={class:"copy-button"},tG={key:0,class:"citation-tabs"},rG={class:"citation-list"},nG=ga(()=>s.createElementVNode("span",null,"Internal Server Error",-1)),aG=ga(()=>s.createElementVNode("br",null,null,-1)),iG=ga(()=>s.createElementVNode("br",null,null,-1)),oG=["href"],sG=ga(()=>s.createElementVNode("br",null,null,-1)),lG=ga(()=>s.createElementVNode("span",null,"Sorry, something went wrong.",-1)),cG=ga(()=>s.createElementVNode("br",null,null,-1)),uG=["onClick"],dG=["innerHTML"],fG=["innerHTML"],hG=["href"];function pG(t,e,r,n,a,i){const o=fs,l=Dt,u=H_;return s.openBlock(),s.createElementBlock("div",XK,[s.createElementVNode("div",JK,[QK,s.createElementVNode("div",eG,[s.createVNode(o,{onCopied:e[0]||(e[0]=c=>i.onCopied(c,"")),label:"Copy list to clipboard",content:t.referecesListContent},null,8,["content"])])]),i.referencesWithDOI?(s.openBlock(),s.createElementBlock("div",tG,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(t.citationOptions,c=>(s.openBlock(),s.createBlock(l,{link:"",key:c.value,type:t.citationType===c.value?"primary":"",onClick:d=>i.onCitationFormatChange(c.value)},{default:s.withCtx(()=>[s.createTextVNode(s.toDisplayString(c.label),1)]),_:2},1032,["type","onClick"]))),128))])):s.createCommentVNode("",!0),s.createElementVNode("ul",rG,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(t.pubMedReferences,c=>{var d,f,h,v;return s.openBlock(),s.createElementBlock("li",{key:c.id,class:s.normalizeClass({loading:i.isCitationLoading(c.citation),error:i.isCitationError(c.citation)})},[c.citation?(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[((d=c.citation.error)==null?void 0:d.ref)==="doi"&&((f=c.citation.error)==null?void 0:f.type)===t.citationType?(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[nG,aG,s.createTextVNode(" Sorry, something went wrong."),iG,s.createTextVNode(" The dataset citation generator ("),s.createElementVNode("a",{href:t.crosscite_host,target:"_blank"},s.toDisplayString(t.crosscite_host),9,oG),s.createTextVNode(") encountered an internal error and was unable to complete your request."),sG,s.createTextVNode(" Please come back later. ")],64)):((h=c.citation.error)==null?void 0:h.ref)==="pubmed"&&((v=c.citation.error)==null?void 0:v.type)===t.citationType?(s.openBlock(),s.createElementBlock(s.Fragment,{key:1},[lG,cG,s.createTextVNode(" Please try again. "),s.createElementVNode("span",{class:"reload-button",onClick:p=>i.reloadCitation(c)},"Reload",8,uG)],64)):(s.openBlock(),s.createElementBlock(s.Fragment,{key:2},[s.createElementVNode("span",{innerHTML:c.citation[t.citationType]},null,8,dG),s.createVNode(u,{resource:c.resource,onShowRelatedConnectivities:i.showRelatedConnectivities},null,8,["resource","onShowRelatedConnectivities"]),s.createVNode(o,{onCopied:p=>i.onCopied(p,c),content:c.citation[t.citationType]},null,8,["onCopied","content"])],64))],64)):s.createCommentVNode("",!0)],2)}),128)),(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(t.openLibReferences,c=>(s.openBlock(),s.createElementBlock("li",{key:c.id},[s.createElementVNode("div",{innerHTML:i.formatCopyReference(c)},null,8,fG),s.createVNode(u,{resource:c.resource,onShowRelatedConnectivities:i.showRelatedConnectivities},null,8,["resource","onShowRelatedConnectivities"]),s.createVNode(o,{onCopied:d=>i.onCopied(d,c),content:i.formatCopyReference(c)},null,8,["onCopied","content"])]))),128)),(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(t.isbnDBReferences,c=>(s.openBlock(),s.createElementBlock("li",{key:c.id},[s.createElementVNode("a",{href:c.url,target:"_blank"},s.toDisplayString(c.url),9,hG),s.createVNode(u,{resource:c.resource,onShowRelatedConnectivities:i.showRelatedConnectivities},null,8,["resource","onShowRelatedConnectivities"]),s.createVNode(o,{onCopied:d=>i.onCopied(d,c),content:c.url},null,8,["onCopied","content"])]))),128))])])}const Sg=zt(ZK,[["render",pG],["__scopeId","data-v-e4259096"]]);function vG(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(a){a(r)}),(n=t.get("*"))&&n.slice().map(function(a){a(e,r)})}}}const K_=new vG,gG={name:"ProvenancePopup",components:{ElIconArrowUp:xe.ArrowUp,ElIconArrowDown:xe.ArrowDown,ElIconWarning:xe.Warning,ConnectivityList:wg,ExternalResourceCard:Sg},props:{tooltipEntry:{type:Array,default:[]}},data:function(){return{loading:!1,showDetails:!1,originDescriptions:{motor:"is the location of the initial cell body of the circuit",sensory:"is the location of the initial cell body in the PNS circuit"},entryIndex:0,availableAnatomyFacets:[],connectivityError:{}}},computed:{entry:function(){return this.tooltipEntry[this.entryIndex]},previousLabel:function(){var t;return this.entryIndex===0?"This is the first item. Click 'Next' to see more information.":(t=this.tooltipEntry[this.entryIndex-1])==null?void 0:t.title},nextLabel:function(){var t;return this.entryIndex===this.tooltipEntry.length-1?"This is the last item. Click 'Previous' to see more information.":(t=this.tooltipEntry[this.entryIndex+1])==null?void 0:t.title},provSpeciesDescription:function(){let t="Studied in";return this.entry.provenanceTaxonomyLabel.forEach(e=>{t+=` ${e},`}),t=t.slice(0,-1),t+=" species",t},origins:function(){return this.entry.origins},components:function(){return this.entry.components},destinations:function(){return this.entry.destinations},originsWithDatasets:function(){return this.entry.originsWithDatasets},componentsWithDatasets:function(){return this.entry.componentsWithDatasets},destinationsWithDatasets:function(){return this.entry.destinationsWithDatasets},resources:function(){return this.entry.hyperlinks||[]}},watch:{tooltipEntry:{deep:!0,immediate:!0,handler:function(t,e){t!==e&&(this.entryIndex=0)}}},mounted:function(){this.loadAvailableAnatomyFacets()},methods:{previous:function(){this.entryIndex!==0&&(this.entryIndex=this.entryIndex-1)},next:function(){this.entryIndex!==this.tooltipEntry.length-1&&(this.entryIndex=this.entryIndex+1)},titleCase:function(t){return dH(t)},capitalise:function(t){return bg(t)},onConnectivityActionClick:function(t){K_.emit("onActionClick",t)},loadAvailableAnatomyFacets:function(){const t=localStorage.getItem("available-anatomy-facets");t&&(this.availableAnatomyFacets=JSON.parse(t))}}},mG=t=>(s.pushScopeId("data-v-dc8d1ad3"),t=t(),s.popScopeId(),t),yG={key:0,class:"main"},bG={key:0,class:"toggle-button"},wG={key:1,class:"block"},CG={class:"title"},EG={key:0,class:"subtitle"},xG={key:2,class:"block"},kG={class:"title"},SG={key:3,class:"attribute-title-container"},_G=mG(()=>s.createElementVNode("span",{class:"attribute-title"},"Alert",-1)),TG={style:{"word-break":"keep-all"}},NG={class:"content-container scrollbar"};function IG(t,e,r,n,a,i){const o=Dt,l=mn,u=xe.Warning,c=Xe,d=xe.ArrowUp,f=xe.ArrowDown,h=wg,v=Sg,p=Ac;return i.entry?s.withDirectives((s.openBlock(),s.createElementBlock("div",yG,[r.tooltipEntry.length>1?(s.openBlock(),s.createElementBlock("div",bG,[s.createVNode(l,{width:"auto",trigger:"hover",teleported:!1},{reference:s.withCtx(()=>[s.createVNode(o,{class:"button",onClick:i.previous,disabled:this.entryIndex===0},{default:s.withCtx(()=>[s.createTextVNode(" Previous ")]),_:1},8,["onClick","disabled"])]),default:s.withCtx(()=>[s.createElementVNode("span",null,s.toDisplayString(i.previousLabel),1)]),_:1}),s.createVNode(l,{width:"auto",trigger:"hover",teleported:!1},{reference:s.withCtx(()=>[s.createVNode(o,{class:"button",onClick:i.next,disabled:this.entryIndex===this.tooltipEntry.length-1},{default:s.withCtx(()=>[s.createTextVNode(" Next ")]),_:1},8,["onClick","disabled"])]),default:s.withCtx(()=>[s.createElementVNode("span",null,s.toDisplayString(i.nextLabel),1)]),_:1})])):s.createCommentVNode("",!0),i.entry.title?(s.openBlock(),s.createElementBlock("div",wG,[s.createElementVNode("div",CG,s.toDisplayString(i.capitalise(i.entry.title)),1),i.entry.provenanceTaxonomyLabel&&i.entry.provenanceTaxonomyLabel.length>0?(s.openBlock(),s.createElementBlock("div",EG,s.toDisplayString(i.provSpeciesDescription),1)):s.createCommentVNode("",!0)])):(s.openBlock(),s.createElementBlock("div",xG,[s.createElementVNode("div",kG,s.toDisplayString(i.entry.featureId),1)])),i.entry.featuresAlert?(s.openBlock(),s.createElementBlock("div",SG,[_G,s.createVNode(l,{width:"250",trigger:"hover",teleported:!1,"popper-class":"popover-origin-help"},{reference:s.withCtx(()=>[s.createVNode(c,{class:"info"},{default:s.withCtx(()=>[s.createVNode(u)]),_:1})]),default:s.withCtx(()=>[s.createElementVNode("span",TG,s.toDisplayString(i.entry.featuresAlert),1)]),_:1})])):s.createCommentVNode("",!0),s.withDirectives(s.createElementVNode("div",{class:"hide",id:"hide-path-info",onClick:e[0]||(e[0]=g=>t.showDetails=!1)},[s.createTextVNode(" Hide path information "),s.createVNode(c,null,{default:s.withCtx(()=>[s.createVNode(d)]),_:1})],512),[[s.vShow,t.showDetails]]),s.withDirectives(s.createElementVNode("div",{class:"hide",id:"show-path-info",onClick:e[1]||(e[1]=g=>t.showDetails=!0)},[s.createTextVNode(" Show path information "),s.createVNode(c,null,{default:s.withCtx(()=>[s.createVNode(f)]),_:1})],512),[[s.vShow,!t.showDetails]]),s.createVNode(s.Transition,{name:"slide-fade"},{default:s.withCtx(()=>[s.withDirectives(s.createElementVNode("div",NG,[(s.openBlock(),s.createBlock(h,{key:i.entry.featureId[0],entry:i.entry,origins:i.origins,components:i.components,destinations:i.destinations,originsWithDatasets:i.originsWithDatasets,componentsWithDatasets:i.componentsWithDatasets,destinationsWithDatasets:i.destinationsWithDatasets,availableAnatomyFacets:t.availableAnatomyFacets,connectivityError:t.connectivityError,onConnectivityActionClick:i.onConnectivityActionClick},null,8,["entry","origins","components","destinations","originsWithDatasets","componentsWithDatasets","destinationsWithDatasets","availableAnatomyFacets","connectivityError","onConnectivityActionClick"])),i.resources.length?(s.openBlock(),s.createBlock(v,{key:0,resources:i.resources},null,8,["resources"])):s.createCommentVNode("",!0)],512),[[s.vShow,t.showDetails]])]),_:1})])),[[p,t.loading]]):s.createCommentVNode("",!0)}const BG=zt(gG,[["render",IG],["__scopeId","data-v-dc8d1ad3"]]),DG={name:"Tooltip",props:{tooltipEntry:{type:Array},annotationDisplay:{type:Boolean,default:!1},annotationEntry:{type:Array}},mounted:function(){K_.on("onActionClick",t=>{this.$emit("onActionClick",t)})}},OG={class:"tooltip-container",id:"tooltip-container"};function AG(t,e,r,n,a,i){const o=T0,l=BG;return s.openBlock(),s.createElementBlock("div",OG,[r.annotationDisplay?(s.openBlock(),s.createBlock(o,{key:0,annotationEntry:r.annotationEntry,onAnnotation:e[0]||(e[0]=u=>t.$emit("annotation",u))},null,8,["annotationEntry"])):(s.openBlock(),s.createBlock(l,{key:1,tooltipEntry:r.tooltipEntry},null,8,["tooltipEntry"]))])}const PG=zt(DG,[["render",AG],["__scopeId","data-v-d1e37cc2"]]),LG={name:"TreeControls",props:{mapType:{type:String,required:!0},isReady:{type:Boolean,default:!0},title:{type:String},treeData:{type:Array,default:function(){return[]}},showColourPicker:{type:Boolean,default:!1},active:{type:[String,Array],required:!0},hover:{type:[String,Array],required:!0},enableFilter:{type:Boolean,default:!0}},data:function(){return{defaultExpandedKeys:["All"],filterText:"",tooltipVisible:!1,tooltipLabel:"",tooltipAtBottom:!1}},computed:{isFlatmap:function(){return this.mapType==="flatmap"},isScaffold:function(){return this.mapType==="scaffold"},nodeKey:function(){if(this.isFlatmap)return"key";if(this.isScaffold)return"id"},expandedKeys:function(){if(this.isFlatmap)return this.defaultExpandedKeys;if(this.isScaffold)return[]}},watch:{filterText:{handler:function(t){this.$refs.regionTree&&this.$refs.regionTree.filter(t)}}},methods:{filterNode:function(t,e){return t?e.label?e.label.toLowerCase().includes(t.toLowerCase()):!1:!0},setColour:function(t,e){this.$emit("setColour",t,e)},getBackgroundStyles:function(t){return"colour"in t?{background:t.colour}:{}},nodeIsActive:function(t){return this.active===t.models},nodeIsHover:function(t){return this.hover===t.models},changeActiveByNode:function(t,e=!1){this.isFlatmap?t.models&&this.$emit("changeActive",t.models):this.isScaffold&&(t.isPrimitives||t.isRegion)&&this.$emit("changeActive",t,e)},changeHoverByNode:function(t,e=!1){this.isFlatmap?t.models&&this.$emit("changeHover",t.models):this.isScaffold&&t.isPrimitives&&this.$emit("changeHover",t,e)},checkChanged:function(t,e){if(this.isFlatmap){const r=e.checkedKeys.includes(t.key);t.key==="All"?this.$emit("checkAll",r):this.$emit("checkChanged",{key:t.key,value:r})}else this.isScaffold&&this.$emit("checkChanged",t,e)},displayTooltip:function(t,e,r){const a=r.target.closest(".el-tree-node__content"),i=a.clientWidth,o=a.getBoundingClientRect().x,l=a.querySelector(".lastChildInItem");let u=0;if(l){const d=l.getBoundingClientRect();u=d.x+d.width-o}const c=u>i;this.tooltipVisible=c&&e,this.tooltipLabel=t,this.tooltipAtBottom=.5>r.layerY/this.$refs.treeContainer.clientHeight}},unmounted:function(){this.sortedPrimitiveGroups=void 0},mounted:function(){this.$refs.regionTree&&this.$refs.regionTree.filter(this.filterText)}},RG={class:"selections-container"},MG={class:"title-text"},FG={class:"tree-container",ref:"treeContainer"},$G={class:"tooltip-text"},VG=["onClick","onMouseover","onMouseenter"],qG=["onClick","onMouseover","onMouseenter"],zG={class:"lastChildInItem"},HG={key:0,class:"node-options"};function KG(t,e,r,n,a,i){const o=Mi,l=Pi,u=os,c=mn,d=tR,f=aM,h=Ac;return s.openBlock(),s.createElementBlock("div",RG,[r.title?(s.openBlock(),s.createBlock(u,{key:0},{default:s.withCtx(()=>[s.createVNode(o,{span:12},{default:s.withCtx(()=>[s.createElementVNode("div",MG,s.toDisplayString(r.title),1)]),_:1}),r.enableFilter?(s.openBlock(),s.createBlock(o,{key:0,span:12},{default:s.withCtx(()=>[s.createElementVNode("div",null,[s.createVNode(l,{class:"tree-filter-input",modelValue:t.filterText,"onUpdate:modelValue":e[0]||(e[0]=v=>t.filterText=v),placeholder:"Filter "+r.title},null,8,["modelValue","placeholder"])])]),_:1})):s.createCommentVNode("",!0)]),_:1})):s.createCommentVNode("",!0),s.createElementVNode("div",FG,[s.createElementVNode("div",{class:s.normalizeClass(["tree-tooltip",t.tooltipAtBottom?"bottom":""])},[s.createVNode(c,{ref:"tooltip",visible:t.tooltipVisible&&t.tooltipLabel!=="",placement:"top","show-arrow":!1,teleported:!1,trigger:"manual","popper-class":"tree-tooltip-popper","virtual-triggering":"",width:260},{default:s.withCtx(()=>[s.createElementVNode("div",$G,s.toDisplayString(t.tooltipLabel),1)]),_:1},8,["visible"])],2),s.withDirectives((s.openBlock(),s.createBlock(f,{ref:"regionTree","element-loading-background":"rgba(0, 0, 0, 0.3)","show-checkbox":"","node-key":i.nodeKey,data:r.treeData,"check-strictly":!1,"expand-on-click-node":!1,"render-after-expand":!1,"default-expanded-keys":i.expandedKeys,onCheck:i.checkChanged,indent:8,"filter-node-method":i.filterNode,class:s.normalizeClass([r.mapType==="flatmap"?"hide_grandchildren_checkbox":""])},{default:s.withCtx(({node:v,data:p})=>[r.mapType==="flatmap"?(s.openBlock(),s.createElementBlock("span",{key:0,class:s.normalizeClass(["region-tree-node",{activeItem:i.nodeIsActive(p),hoverItem:i.nodeIsHover(p)}]),onClick:g=>i.changeActiveByNode(p),onMouseover:g=>i.changeHoverByNode(p,!1),onMouseenter:g=>i.displayTooltip(v.label,!0,g),onMouseleave:e[1]||(e[1]=g=>i.displayTooltip("",!1,g))},[s.createElementVNode("div",{style:s.normalizeStyle(i.getBackgroundStyles(p)),class:"lastChildInItem"},s.toDisplayString(v.label),5)],42,VG)):r.mapType==="scaffold"?(s.openBlock(),s.createElementBlock("span",{key:1,class:s.normalizeClass(["region-tree-node",{activeItem:r.active.includes(p.id),hoverItem:r.hover.includes(p.id)}]),onClick:g=>i.changeActiveByNode(p,!0),onMouseover:g=>i.changeHoverByNode(p,!0,g),onMouseenter:g=>i.displayTooltip(v.label,!0,g),onMouseleave:e[2]||(e[2]=g=>i.displayTooltip("",!1,g))},[p.isPrimitives?(s.openBlock(),s.createBlock(d,{key:0,class:s.normalizeClass({"show-picker":r.showColourPicker}),modelValue:p.activeColour,"onUpdate:modelValue":g=>p.activeColour=g,size:"small",onChange:g=>i.setColour(p,g)},null,8,["class","modelValue","onUpdate:modelValue","onChange"])):s.createCommentVNode("",!0),s.createElementVNode("div",zG,[s.createElementVNode("span",null,s.toDisplayString(v.label),1),p.isTextureSlides?(s.openBlock(),s.createElementBlock("span",HG," (Texture) ")):s.createCommentVNode("",!0)])],42,qG)):s.createCommentVNode("",!0)]),_:1},8,["node-key","data","default-expanded-keys","onCheck","filter-node-method","class"])),[[h,!r.isReady]])],512)])}const GG=zt(LG,[["render",KG],["__scopeId","data-v-e1dbd1e9"]]);async function UG(t,e){try{const r=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(`API Error: ${r.status} ${r.statusText}`);return await r.json()}catch(r){throw console.error("Request failed:",r),r}}async function WG(t,e,r){var a;const n=await Rr({flatmapAPI:t,knowledgeSource:e,queryId:27,parameters:[{column:"path_id",value:r}]});if((a=n==null?void 0:n.results)!=null&&a.values){const i=n.results.values.map(o=>({sckanId:o[0],mapUUID:o[4],pathId:o[1],sckanNodeId:o[2]?JSON.parse(o[2]):[],sckanNodeLabel:o[3]||"",mapNodeId:o[5]?JSON.parse(o[5]):[],mapNodeLabel:o[6]||""}));return hH(i)}return[]}async function Rr(t){const{flatmapAPI:e,knowledgeSource:r,queryId:n,parameters:a,orderId:i}=t,o=`${e}competency/query`,l=Array.isArray(a)?[...a]:[];l.push({column:"source_id",value:r});let u;if(typeof n=="number")u=n.toString();else if(typeof n=="string")u=n;else throw new TypeError("queryId must be a string or a number convertible to string.");const c={query_id:u,parameters:l};return i&&(c.order=[i]),UG(o,c)}async function jG(t,e,r){const n=Array.isArray(r)?r:[r],a=n.filter(h=>h.startsWith("ilxtr:")),i=n.filter(h=>!h.startsWith("ilxtr:")),o=[];a.length>0&&o.push(Rr({flatmapAPI:t,knowledgeSource:e,queryId:23,parameters:[{column:"path_id",value:a}]})),i.length>0&&o.push(Rr({flatmapAPI:t,knowledgeSource:e,queryId:1,parameters:[{column:"feature_id",value:i}]}));const l=await Promise.all(o);let u=[...a];l.forEach(h=>{var p,g;const v=((g=(p=h==null?void 0:h.results)==null?void 0:p.values)==null?void 0:g.map(m=>m[1]))||[];u.push(...v)});const c=[...new Set(u)];let d=[];return c.length&&(d=await Tg(t,e,c)),[...new Set([...c,...d])]}async function YG(t,e,r){var a;const n=await Rr({flatmapAPI:t,knowledgeSource:e,queryId:1,parameters:[{column:"feature_id",value:r}]});if((a=n==null?void 0:n.results)!=null&&a.values){const i=n.results.values.map(o=>o[1]);return[...new Set(i)]}return[]}async function ZG(t,e,r){var a;const n=await Rr({flatmapAPI:t,knowledgeSource:e,queryId:1,parameters:[{column:"feature_id",value:r}]});if((a=n==null?void 0:n.results)!=null&&a.values){const i=n.results.values.map(o=>o[1]);return[...new Set(i)]}return[]}async function XG(t,e,r){var a;const n=await Rr({flatmapAPI:t,knowledgeSource:e,queryId:2,parameters:[{column:"feature_id",value:r}]});if((a=n==null?void 0:n.results)!=null&&a.values){const i=n.results.values.map(o=>o[1]);return[...new Set(i)]}return[]}function _g(t){const e=[];for(const r of t){const n=JSON.parse(r);Array.isArray(n)&&n.length>=2&&Array.isArray(n[1])&&n[1].length===0&&e.push(n[0])}return e}async function Tg(t,e,r){var a;const n=await Rr({flatmapAPI:t,knowledgeSource:e,queryId:26,parameters:[{column:"path_id",value:r}]});if((a=n==null?void 0:n.results)!=null&&a.values){const i=n.results.values.map(o=>o[2]);return[...new Set(i)]}return[]}async function JG({flatmapAPI:t,knowledgeSource:e,origins:r,destinations:n,vias:a}){var w,C,x,k;const i=_g(r),o=_g(n),l=_g(a),u=[{column:"source_feature_id",value:i},{column:"via_feature_id",value:l},{column:"dest_feature_id",value:o}],c=[{column:"source_node_id",value:r},{column:"via_node_id",value:a},{column:"dest_node_id",value:n}],d=u.some(E=>Array.isArray(E.value)&&E.value.length>0),f=[Rr({flatmapAPI:t,knowledgeSource:e,queryId:24,parameters:c})];d&&f.push(Rr({flatmapAPI:t,knowledgeSource:e,queryId:25,parameters:u}));const h=await Promise.all(f);let v=[],p;if(d){const E=h[0];p=h[1],v=((C=(w=E==null?void 0:E.results)==null?void 0:w.values)==null?void 0:C.map(_=>_[1]))||[]}else p=h[0];const g=((k=(x=p==null?void 0:p.results)==null?void 0:x.values)==null?void 0:k.map(E=>E[1]))||[],m=[...new Set([...v,...g])];let y=[];return m.length&&(y=await Tg(t,e,m)),[...new Set([...m,...y])]}const Ng=[];async function QG(t,e){const r=e.filter(i=>Ng.some(o=>o.taxon===i)),n=Ng.filter(i=>r.includes(i.taxon)),a=e.filter(i=>!r.includes(i));if(a.length){const i=await t.queryLabels(a);if(i.length)return i.forEach(o=>{let{entity:l,label:u}=o;u==="Mammalia"&&(u="Mammalia not otherwise specified");const c={taxon:l,label:u};n.push(c),Ng.push(c)}),n}else return n}async function e7(t,e,r){const n=`${t}knowledge/query/`,a={sql:e,params:r};try{const i=await fetch(n,{method:"POST",headers:{Accept:"application/json; charset=utf-8","Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok)throw new Error(`Cannot access ${n}`);return await i.json()}catch{return{values:[]}}}async function G_(t,e){return e.length?await(await e7(t,`select entity, knowledge from knowledge
473
473
  where entity in (?${", ?".repeat(e.length-1)})
474
- order by source desc`,[...e])).values:[]}function t7(t){var r;const e=(r=t["node-phenotypes"])==null?void 0:r["ilxtr:hasSomaLocatedIn"];return Array.isArray(t.connectivity)&&t.connectivity.length>0&&Array.isArray(e)&&e.length>0}function r7(t){var a,i;const e=(a=t["node-phenotypes"])==null?void 0:a["ilxtr:hasAxonPresynapticElementIn"],r=(i=t["node-phenotypes"])==null?void 0:i["ilxtr:hasAxonSensorySubcellularElementIn"],n=Array.isArray(e)&&e.length>0||Array.isArray(r)&&r.length>0;return Array.isArray(t.connectivity)&&t.connectivity.length>0&&n}function n7(t){var n,a,i;if(!Array.isArray(t.connectivity)||t.connectivity.length===0)return!1;const e=new Set((((n=t["node-phenotypes"])==null?void 0:n["ilxtr:hasSomaLocatedIn"])||[]).map(o=>o[0])),r=new Set([...(((a=t["node-phenotypes"])==null?void 0:a["ilxtr:hasAxonPresynapticElementIn"])||[]).map(o=>o[0]),...(((i=t["node-phenotypes"])==null?void 0:i["ilxtr:hasAxonSensorySubcellularElementIn"])||[]).map(o=>o[0])]);return t.connectivity.some(o=>{const[l,u]=o,c=l[0],d=u[0];return!e.has(c)&&!r.has(d)})}function Ig(t){if(!Array.isArray(t.connectivity))return[];const e=new Set;return t.connectivity.forEach(r=>{Array.isArray(r)&&r.length&&r.forEach(n=>{if(Array.isArray(n)&&typeof n[0]=="string"){const a=JSON.stringify(n);e.add(a)}})}),Array.from(e)}function Mr(t,e){var n;const r=(n=t["node-phenotypes"])==null?void 0:n[e];return Array.isArray(r)?r:[]}async function Bg(t,e,r){const n=Array.from(new Map(r.map(f=>[JSON.stringify(f),f])).values()),a=n.flat(1/0),i=[...new Set(a)],l=(await G_(t,i)).reduce((f,h)=>{const v=h[0],p=JSON.parse(h[1]);return f.push({id:v,label:p.label,source:p.source}),f},[]);l.sort((f,h)=>f.id===h.id?f.source===e&&h.source!==e?-1:f.source!==e&&h.source===e?1:0:f.id.localeCompare(h.id));const u=[];return[...n.map(f=>{const h=f.flat(),v=[];for(let p=0;p<h.length;p++){const g=l.find(m=>m.id===h[p]);g&&(v.push(g.label),p>0&&u.push({key:[h[p],[]],label:g.label}))}return{key:f,label:v.join(", ")}}),...u].filter((f,h,v)=>h===v.findIndex(p=>p.label===f.label))}async function U_(t,e,r){const n=[];return r.forEach(a=>{if(!Array.isArray(a.connectivity)||a.connectivity.length===0)return;const i=new Set(Ig(a));Mr(a,"ilxtr:hasSomaLocatedIn").forEach(o=>{const l=JSON.stringify(o);i.has(l)&&n.push(o)})}),await Bg(t,e,n)}async function W_(t,e,r){const n=[];return r.forEach(a=>{if(!Array.isArray(a.connectivity)||a.connectivity.length===0)return;const i=new Set(Ig(a));[...Mr(a,"ilxtr:hasAxonPresynapticElementIn"),...Mr(a,"ilxtr:hasAxonSensorySubcellularElementIn")].forEach(o=>{const l=JSON.stringify(o);i.has(l)&&n.push(o)})}),await Bg(t,e,n)}async function j_(t,e,r){const n=[];return r.forEach(a=>{if(!Array.isArray(a.connectivity)||a.connectivity.length===0)return;const i=new Set(Ig(a));[...Mr(a,"ilxtr:hasAxonLeadingToSensorySubcellularElementIn"),...Mr(a,"ilxtr:hasAxonLocatedIn")].forEach(o=>{const l=JSON.stringify(o);i.has(l)&&n.push(o)})}),await Bg(t,e,n)}function Y_(t,e){return t.filter(r=>!Array.isArray(r.connectivity)||r.connectivity.length===0?!1:Mr(r,"ilxtr:hasSomaLocatedIn").some(a=>e.map(i=>JSON.stringify(i)).includes(JSON.stringify(a))))}function Z_(t,e){return t.filter(r=>!Array.isArray(r.connectivity)||r.connectivity.length===0?!1:[...Mr(r,"ilxtr:hasAxonPresynapticElementIn"),...Mr(r,"ilxtr:hasAxonSensorySubcellularElementIn")].some(a=>e.map(i=>JSON.stringify(i)).includes(JSON.stringify(a))))}function X_(t,e){return t.filter(r=>!Array.isArray(r.connectivity)||r.connectivity.length===0?!1:[...Mr(r,"ilxtr:hasAxonLeadingToSensorySubcellularElementIn"),...Mr(r,"ilxtr:hasAxonLocatedIn")].some(a=>e.map(i=>JSON.stringify(i)).includes(JSON.stringify(a))))}async function a7({knowledge:t,origins:e,destinations:r,vias:n}){let a=t;return e.length&&(a=Y_(a,e)),r.length&&(a=Z_(a,r)),n.length&&(a=X_(a,n)),a}async function i7(t,e,r,n){let a=[];const i=[];if(e){if(e&&typeof e.featureFilterRanges=="function"){const v=e.featureFilterRanges();for(const[p,g]of Object.entries(v)){let m={key:`flatmap.connectivity.${p}`,label:"",children:[]},y=[];if(p==="kind"){m.label="Pathways";for(const b of g){const w=n.find(C=>C.type===b);w&&y.push({key:`${m.key}.${b}`,label:w.label,colour:w.colour,colourStyle:"line",dashed:w.dashed})}}else if(p==="taxons"){m.label="Studied in";const b=await QG(e,e.taxonIdentifiers);if(b.length)for(const w of g){const C=b.find(x=>x.taxon===w);C&&y.push({key:`${m.key}.${w}`,label:`${C.label} `})}}else if(p==="alert"){m.label="Alert";for(const b of["with","without"])y.push({key:`${m.key}.${b}`,label:`${b} alerts`})}m.children=y.sort((b,w)=>b.label.localeCompare(w.label)),m.label&&m.children.length&&a.push(m)}}const o=e.pathways.paths,l=[];for(const v of r){const p=v.id;if(p){const g=o[p];if(g&&g.connectivity&&g["node-phenotypes"]){const m=g.connectivity,y=g["node-phenotypes"],b={};for(let w in v["node-phenotypes"])y[w]&&(b[w]=[...y[w]]);l.push({...v,connectivity:[...m],"node-phenotypes":b})}}}const u=e.knowledgeSource,c=await U_(t,u,l),d=await j_(t,u,l),f=await W_(t,u,l),h=(v,p)=>{const g=JSON.stringify(p.key);return{key:`flatmap.connectivity.source.${v}.${g}`,label:p.label||g}};for(const v of["origin","via","destination","all"]){let p=[];if(v==="origin")p=c.map(g=>h(v,g));else if(v==="via")p=d.map(g=>h(v,g));else if(v==="destination")p=f.map(g=>h(v,g));else{const g=[...c.map(y=>h(v,y)),...d.map(y=>h(v,y)),...f.map(y=>h(v,y))],m=new Set;p=g.filter(y=>m.has(y.key)?!1:(m.add(y.key),!0))}p=p.sort((g,m)=>{const y=C=>/^[a-zA-Z]/.test(C),b=y(g.label),w=y(m.label);return b&&!w?-1:!b&&w?1:g.label.localeCompare(m.label)}),p.length&&i.push({key:`flatmap.connectivity.source.${v}`,label:v,children:p})}i.length&&a.push(...i)}return a}_e.AnnotationPopup=T0,_e.ConnectivityGraph=uH,_e.ConnectivityList=wg,_e.ConnectivityReconciliationList=dK,_e.CopyToClipboard=fs,_e.CreateTooltipContent=VM,_e.DrawToolbar=MK,_e.ExternalResourceCard=Sg,_e.HelpModeDialog=HK,_e.Tooltip=PG,_e.TreeControls=GG,_e.competencyQuery=Rr,_e.extractDestinationItems=W_,_e.extractOriginItems=U_,_e.extractViaItems=j_,_e.fetchLabels=G_,_e.filterDestinations=r7,_e.filterOrigins=t7,_e.filterViaLocations=n7,_e.findPathsByDestinationItem=Z_,_e.findPathsByOriginItem=Y_,_e.findPathsByViaItem=X_,_e.getFlatmapFilterOptions=i7,_e.queryAllConnectedPaths=jG,_e.queryForwardBackwardConnections=Tg,_e.queryPathsByDestination=XG,_e.queryPathsByOrigin=YG,_e.queryPathsByRoute=JG,_e.queryPathsByRouteFromKnowledge=a7,_e.queryPathsByViaLocation=ZG,_e.querySingleConnectivityList=WG,Object.defineProperty(_e,Symbol.toStringTag,{value:"Module"})});
474
+ order by source desc`,[...e])).values:[]}function t7(t){var r;const e=(r=t["node-phenotypes"])==null?void 0:r["ilxtr:hasSomaLocatedIn"];return Array.isArray(t.connectivity)&&t.connectivity.length>0&&Array.isArray(e)&&e.length>0}function r7(t){var a,i;const e=(a=t["node-phenotypes"])==null?void 0:a["ilxtr:hasAxonPresynapticElementIn"],r=(i=t["node-phenotypes"])==null?void 0:i["ilxtr:hasAxonSensorySubcellularElementIn"],n=Array.isArray(e)&&e.length>0||Array.isArray(r)&&r.length>0;return Array.isArray(t.connectivity)&&t.connectivity.length>0&&n}function n7(t){var n,a,i;if(!Array.isArray(t.connectivity)||t.connectivity.length===0)return!1;const e=new Set((((n=t["node-phenotypes"])==null?void 0:n["ilxtr:hasSomaLocatedIn"])||[]).map(o=>o[0])),r=new Set([...(((a=t["node-phenotypes"])==null?void 0:a["ilxtr:hasAxonPresynapticElementIn"])||[]).map(o=>o[0]),...(((i=t["node-phenotypes"])==null?void 0:i["ilxtr:hasAxonSensorySubcellularElementIn"])||[]).map(o=>o[0])]);return t.connectivity.some(o=>{const[l,u]=o,c=l[0],d=u[0];return!e.has(c)&&!r.has(d)})}function Ig(t){if(!Array.isArray(t.connectivity))return[];const e=new Set;return t.connectivity.forEach(r=>{Array.isArray(r)&&r.length&&r.forEach(n=>{if(Array.isArray(n)&&typeof n[0]=="string"){const a=JSON.stringify(n);e.add(a)}})}),Array.from(e)}function Mr(t,e){var n;const r=(n=t["node-phenotypes"])==null?void 0:n[e];return Array.isArray(r)?r:[]}async function Bg(t,e,r){const n=Array.from(new Map(r.map(f=>[JSON.stringify(f),f])).values()),a=n.flat(1/0),i=[...new Set(a)],l=(await G_(t,i)).reduce((f,h)=>{const v=h[0],p=JSON.parse(h[1]);return f.push({id:v,label:p.label,source:p.source}),f},[]);l.sort((f,h)=>f.id===h.id?f.source===e&&h.source!==e?-1:f.source!==e&&h.source===e?1:0:f.id.localeCompare(h.id));const u=[];return[...n.map(f=>{const h=f.flat(),v=[];for(let p=0;p<h.length;p++){const g=l.find(m=>m.id===h[p]);g&&(v.push(g.label),p>0&&u.push({key:[h[p],[]],label:g.label}))}return{key:f,label:v.join(", ")}}),...u].filter((f,h,v)=>h===v.findIndex(p=>p.label===f.label))}async function U_(t,e,r){const n=[];return r.forEach(a=>{if(!Array.isArray(a.connectivity)||a.connectivity.length===0)return;const i=new Set(Ig(a));Mr(a,"ilxtr:hasSomaLocatedIn").forEach(o=>{const l=JSON.stringify(o);i.has(l)&&n.push(o)})}),await Bg(t,e,n)}async function W_(t,e,r){const n=[];return r.forEach(a=>{if(!Array.isArray(a.connectivity)||a.connectivity.length===0)return;const i=new Set(Ig(a));[...Mr(a,"ilxtr:hasAxonPresynapticElementIn"),...Mr(a,"ilxtr:hasAxonSensorySubcellularElementIn")].forEach(o=>{const l=JSON.stringify(o);i.has(l)&&n.push(o)})}),await Bg(t,e,n)}async function j_(t,e,r){const n=[];return r.forEach(a=>{if(!Array.isArray(a.connectivity)||a.connectivity.length===0)return;const i=new Set(Ig(a));[...Mr(a,"ilxtr:hasAxonLeadingToSensorySubcellularElementIn"),...Mr(a,"ilxtr:hasAxonLocatedIn")].forEach(o=>{const l=JSON.stringify(o);i.has(l)&&n.push(o)})}),await Bg(t,e,n)}function Y_(t,e){return t.filter(r=>!Array.isArray(r.connectivity)||r.connectivity.length===0?!1:Mr(r,"ilxtr:hasSomaLocatedIn").some(a=>e.map(i=>JSON.stringify(i)).includes(JSON.stringify(a))))}function Z_(t,e){return t.filter(r=>!Array.isArray(r.connectivity)||r.connectivity.length===0?!1:[...Mr(r,"ilxtr:hasAxonPresynapticElementIn"),...Mr(r,"ilxtr:hasAxonSensorySubcellularElementIn")].some(a=>e.map(i=>JSON.stringify(i)).includes(JSON.stringify(a))))}function X_(t,e){return t.filter(r=>!Array.isArray(r.connectivity)||r.connectivity.length===0?!1:[...Mr(r,"ilxtr:hasAxonLeadingToSensorySubcellularElementIn"),...Mr(r,"ilxtr:hasAxonLocatedIn")].some(a=>e.map(i=>JSON.stringify(i)).includes(JSON.stringify(a))))}async function a7({knowledge:t,origins:e,destinations:r,vias:n}){let a=t;return e.length&&(a=Y_(a,e)),r.length&&(a=Z_(a,r)),n.length&&(a=X_(a,n)),a}async function i7(t,e,r,n){let a=[];const i=[];if(e){if(e&&typeof e.featureFilterRanges=="function"){const v=e.featureFilterRanges();for(const[p,g]of Object.entries(v)){let m={key:`flatmap.connectivity.${p}`,label:"",children:[]},y=[];if(p==="kind"){m.label="Pathways";for(const b of g){const w=n.find(C=>C.type===b);w&&y.push({key:`${m.key}.${b}`,label:w.label,colour:w.colour,colourStyle:"line",dashed:w.dashed})}}else if(p==="taxons"){m.label="Studied in";const b=await QG(e,e.taxonIdentifiers);if(b.length)for(const w of g){const C=b.find(x=>x.taxon===w);C&&y.push({key:`${m.key}.${w}`,label:`${C.label} `})}}else if(p==="alert"){m.label="Notes";for(const b of["with","without"])y.push({key:`${m.key}.${b}`,label:`${b} notes`})}m.children=y.sort((b,w)=>b.label.localeCompare(w.label)),m.label&&m.children.length&&a.push(m)}}const o=e.pathways.paths,l=[];for(const v of r){const p=v.id;if(p){const g=o[p];if(g&&g.connectivity&&g["node-phenotypes"]){const m=g.connectivity,y=g["node-phenotypes"],b={};for(let w in v["node-phenotypes"])y[w]&&(b[w]=[...y[w]]);l.push({...v,connectivity:[...m],"node-phenotypes":b})}}}const u=e.knowledgeSource,c=await U_(t,u,l),d=await j_(t,u,l),f=await W_(t,u,l),h=(v,p)=>{const g=JSON.stringify(p.key);return{key:`flatmap.connectivity.source.${v}.${g}`,label:p.label||g}};for(const v of["origin","via","destination","all"]){let p=[];if(v==="origin")p=c.map(g=>h(v,g));else if(v==="via")p=d.map(g=>h(v,g));else if(v==="destination")p=f.map(g=>h(v,g));else{const g=[...c.map(y=>h(v,y)),...d.map(y=>h(v,y)),...f.map(y=>h(v,y))],m=new Set;p=g.filter(y=>m.has(y.key)?!1:(m.add(y.key),!0))}p=p.sort((g,m)=>{const y=C=>/^[a-zA-Z]/.test(C),b=y(g.label),w=y(m.label);return b&&!w?-1:!b&&w?1:g.label.localeCompare(m.label)}),p.length&&i.push({key:`flatmap.connectivity.source.${v}`,label:v,children:p})}i.length&&a.push(...i)}return a}_e.AnnotationPopup=T0,_e.ConnectivityGraph=uH,_e.ConnectivityList=wg,_e.ConnectivityReconciliationList=dK,_e.CopyToClipboard=fs,_e.CreateTooltipContent=VM,_e.DrawToolbar=MK,_e.ExternalResourceCard=Sg,_e.HelpModeDialog=HK,_e.Tooltip=PG,_e.TreeControls=GG,_e.competencyQuery=Rr,_e.extractDestinationItems=W_,_e.extractOriginItems=U_,_e.extractViaItems=j_,_e.fetchLabels=G_,_e.filterDestinations=r7,_e.filterOrigins=t7,_e.filterViaLocations=n7,_e.findPathsByDestinationItem=Z_,_e.findPathsByOriginItem=Y_,_e.findPathsByViaItem=X_,_e.getFlatmapFilterOptions=i7,_e.queryAllConnectedPaths=jG,_e.queryForwardBackwardConnections=Tg,_e.queryPathsByDestination=XG,_e.queryPathsByOrigin=YG,_e.queryPathsByRoute=JG,_e.queryPathsByRouteFromKnowledge=a7,_e.queryPathsByViaLocation=ZG,_e.querySingleConnectivityList=WG,Object.defineProperty(_e,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/map-utilities",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -299,11 +299,11 @@ async function getFlatmapFilterOptions (flatmapAPI, mapImp, providedKnowledge, p
299
299
  }
300
300
  }
301
301
  } else if (key === "alert") {
302
- main.label = "Alert"
302
+ main.label = "Notes"
303
303
  for (const facet of ["with", "without"]) {
304
304
  children.push({
305
305
  key: `${main.key}.${facet}`,
306
- label: `${facet} alerts`
306
+ label: `${facet} notes`
307
307
  })
308
308
  }
309
309
  }