@abi-software/flatmapvuer 1.9.3-beta.4 → 1.9.3-beta.5

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.
@@ -101615,13 +101615,6 @@ const QA = new RDt(), DDt = "cannot be found on the map.", NDt = (e) => {
101615
101615
  return t || (t = z3(new stt(`${e.flatmapAPI}annotator`)), i1("$annotator", t)), { annotator: t };
101616
101616
  },
101617
101617
  methods: {
101618
- /**
101619
- *
101620
- * @param filter format should follow #makeStyleFilter (flatmap-viewer)
101621
- */
101622
- setVisibilityFilter: function(e) {
101623
- this.mapImp && (e ? this.mapImp.setVisibilityFilter(e) : this.mapImp.clearVisibilityFilter());
101624
- },
101625
101618
  /**
101626
101619
  * @public
101627
101620
  * Function to manually send aborted signal when annotation tooltip popup or sidebar tab closed.
@@ -101819,6 +101812,12 @@ const QA = new RDt(), DDt = "cannot be found on the map.", NDt = (e) => {
101819
101812
  setAnnotationFrom: function(e) {
101820
101813
  this.annotationFrom = e, this.mapImp && (this.manualAbortedOnClose(), this.addAnnotationFeature());
101821
101814
  },
101815
+ /**
101816
+ * Function to emit offline annotation enabled status
101817
+ */
101818
+ emitOfflineAnnotationUpdate: function() {
101819
+ this.$emit("update-offline-annotation-enabled", this.offlineAnnotationEnabled);
101820
+ },
101822
101821
  /**
101823
101822
  * @public
101824
101823
  * Function to switch from 2D to 3D
@@ -103332,7 +103331,7 @@ const QA = new RDt(), DDt = "cannot be found on the map.", NDt = (e) => {
103332
103331
  },
103333
103332
  viewingMode: function(e) {
103334
103333
  this.clearAnnotationFeature(), e === "Annotation" && (this.loading = !0, this.annotator.authenticate(this.userToken).then((t) => {
103335
- t.name && t.email && t.canUpdate ? (this.authorisedUser = t, this.offlineAnnotationEnabled = !1) : (this.authorisedUser = void 0, this.offlineAnnotationEnabled = !0), this.setFeatureAnnotated(), this.addAnnotationFeature(), this.loading = !1;
103334
+ t.name && t.email && t.canUpdate ? (this.authorisedUser = t, this.offlineAnnotationEnabled = !1) : (this.authorisedUser = void 0, this.offlineAnnotationEnabled = !0), this.emitOfflineAnnotationUpdate(), this.setFeatureAnnotated(), this.addAnnotationFeature(), this.loading = !1;
103336
103335
  }));
103337
103336
  },
103338
103337
  disableUI: function(e) {
@@ -104089,7 +104088,7 @@ function JDt(e, t, n, r, i, o) {
104089
104088
  [ft, e.loading]
104090
104089
  ]);
104091
104090
  }
104092
- const rY = /* @__PURE__ */ Vv(BDt, [["render", JDt], ["__scopeId", "data-v-a05c1762"]]), Aj = {
104091
+ const rY = /* @__PURE__ */ Vv(BDt, [["render", JDt], ["__scopeId", "data-v-04264bd7"]]), Aj = {
104093
104092
  "NCBITaxon:10114": "01fedbf9-d783-509c-a10c-827941ab13da",
104094
104093
  "NCBITaxon:9823": "a336ac04-24db-561f-a25f-1c994fe17410",
104095
104094
  "NCBITaxon:9606": "42ed6323-f645-5fbe-bada-9581819cf689",
@@ -104200,6 +104199,9 @@ const rY = /* @__PURE__ */ Vv(BDt, [["render", JDt], ["__scopeId", "data-v-a05c1
104200
104199
  onAnnotationOpen: function(e) {
104201
104200
  this.$emit("annotation-open", e);
104202
104201
  },
104202
+ updateOfflineAnnotationEnabled: function(e) {
104203
+ this.$emit("update-offline-annotation-enabled", e);
104204
+ },
104203
104205
  onConnectivityInfoClose: function() {
104204
104206
  this.$emit("connectivity-info-close");
104205
104207
  },
@@ -104726,6 +104728,7 @@ function iNt(e, t, n, r, i, o) {
104726
104728
  annotationSidebar: n.annotationSidebar,
104727
104729
  onAnnotationOpen: o.onAnnotationOpen,
104728
104730
  onAnnotationClose: o.onAnnotationClose,
104731
+ onUpdateOfflineAnnotationEnabled: o.updateOfflineAnnotationEnabled,
104729
104732
  connectivityInfoSidebar: n.connectivityInfoSidebar,
104730
104733
  onConnectivityInfoOpen: o.onConnectivityInfoOpen,
104731
104734
  onConnectivityInfoClose: o.onConnectivityInfoClose,
@@ -104750,12 +104753,12 @@ function iNt(e, t, n, r, i, o) {
104750
104753
  showLocalSettings: n.showLocalSettings,
104751
104754
  showOpenMapButton: n.showOpenMapButton,
104752
104755
  showPathwayFilter: n.showPathwayFilter
104753
- }, null, 8, ["entry", "uuid", "biologicalSex", "displayWarning", "displayLatestChanges", "isLegacy", "enableOpenMapUI", "openMapOptions", "disableUI", "onViewLatestMap", "onResourceSelected", "onReady", "onPanZoomCallback", "annotationSidebar", "onAnnotationOpen", "onAnnotationClose", "connectivityInfoSidebar", "onConnectivityInfoOpen", "onConnectivityInfoClose", "onConnectivityError", "onPathwaySelectionChanged", "minZoom", "helpMode", "helpModeActiveItem", "helpModeDialog", "onHelpModeLastItem", "onShownTooltip", "onShownMapTooltip", "renderAtMounted", "displayMinimap", "showStarInLegend", "mapManager", "flatmapAPI", "sparcAPI", "showLocalSettings", "showOpenMapButton", "showPathwayFilter"])), [
104756
+ }, null, 8, ["entry", "uuid", "biologicalSex", "displayWarning", "displayLatestChanges", "isLegacy", "enableOpenMapUI", "openMapOptions", "disableUI", "onViewLatestMap", "onResourceSelected", "onReady", "onPanZoomCallback", "annotationSidebar", "onAnnotationOpen", "onAnnotationClose", "onUpdateOfflineAnnotationEnabled", "connectivityInfoSidebar", "onConnectivityInfoOpen", "onConnectivityInfoClose", "onConnectivityError", "onPathwaySelectionChanged", "minZoom", "helpMode", "helpModeActiveItem", "helpModeDialog", "onHelpModeLastItem", "onShownTooltip", "onShownMapTooltip", "renderAtMounted", "displayMinimap", "showStarInLegend", "mapManager", "flatmapAPI", "sparcAPI", "showLocalSettings", "showOpenMapButton", "showPathwayFilter"])), [
104754
104757
  [As, e.activeSpecies == Q]
104755
104758
  ])), 128))
104756
104759
  ], 512);
104757
104760
  }
104758
- const hNt = /* @__PURE__ */ Vv(tNt, [["render", iNt], ["__scopeId", "data-v-32137bc4"]]);
104761
+ const hNt = /* @__PURE__ */ Vv(tNt, [["render", iNt], ["__scopeId", "data-v-fd1ba441"]]);
104759
104762
  export {
104760
104763
  rY as FlatmapVuer,
104761
104764
  hNt as MultiFlatmapVuer
@@ -2379,4 +2379,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
2379
2379
  order by entity, source desc`,[C(this,v3),...r]);let o=null;for(const a of i)if(a[1]!==o){const s=JSON.parse(a[2]);n.push({entity:a[1],label:s.label||a[1]}),o=a[1]}}else return(await C(this,us).queryKnowledge(`select entity, label from labels
2380
2380
  where entity in (?${", ?".repeat(r.length-1)})`,r)).map(i=>({entity:i[0],label:i[1]}));return n}async queryKnowledge(t){const n=C(this,us).knowledgeSchema>=HC?await C(this,us).queryKnowledge("select knowledge from knowledge where (source=? or source is null) and entity=? order by source desc",[C(this,v3),t]):await C(this,us).queryKnowledge("select knowledge from knowledge where entity=?",[t]);return n.length?JSON.parse(n[0]):{}}async queryPathsForFeatures(t){const n=Array.isArray(t)?t:t?[t]:[],r=[];for(const i of n)r.push(...this.modelFeatureIds(i));return await this.getPathsForGeoJsonFeatures(r)}async getPathsForGeoJsonFeatures(t){if(C(this,us).knowledgeSchema<HC)return[];const n=Array.isArray(t)?t:t?[t]:[],r=new Pa(n),i=new Pa;for(const o of r){const a=C(this,v0).get(+o);if(a&&"anatomical-nodes"in a)for(const s of a["anatomical-nodes"])i.add(s)}if(i.size>0){const o=await C(this,us).queryKnowledge(`select path from connectivity_nodes
2381
2381
  where source=? and node in (?${", ?".repeat(i.size-1)})
2382
- order by node, path, source desc`,[C(this,v3),...i.values()]);return[...new Pa(o.map(a=>a[0])).values()]}return[]}addCloseControl(){C(this,Ee)!==null&&C(this,Ee).addCloseControl()}removeCloseControl(){C(this,Ee)!==null&&C(this,Ee).removeCloseControl()}}Op=new WeakMap,kp=new WeakMap,Pp=new WeakMap,Cs=new WeakMap,Ip=new WeakMap,Vp=new WeakMap,Pv=new WeakMap,Xu=new WeakMap,Ku=new WeakMap,Ol=new WeakMap,Iv=new WeakMap,Rp=new WeakMap,Vv=new WeakMap,v0=new WeakMap,v3=new WeakMap,Ar=new WeakMap,Rv=new WeakMap,us=new WeakMap,Np=new WeakMap,Dp=new WeakMap,Bp=new WeakMap,Y4=new WeakMap,s2=new WeakMap,kl=new WeakMap,Nv=new WeakMap,Fp=new WeakMap,J4=new WeakMap,Yu=new WeakMap,Ju=new WeakMap,jp=new WeakMap,Ee=new WeakMap,a2=new WeakMap,f1=new WeakSet,YZ=async function(){await Vt(this,f1,OC).call(this,C(this,Yu));for(const t of this.taxonIdentifiers)await Vt(this,f1,OC).call(this,t);for(const t of C(this,kl).images||[])await Vt(this,f1,eq).call(this,t.id,t.url,"",t.options);await b7t(C(this,Ar));const e=await C(this,us).mapTermGraph(C(this,a2));C(this,Dp).load(e),_t(this,Ee,new pIt(this)),_t(this,J4,1)},JZ=async function(e){return(await C(this,Ar).loadImage(e)).data},tq=function(e){return new Promise((t,n)=>{const r=new Image;r.src=e,r.onload=i=>t(i.target)})},eq=async function(e,t,n,r={}){if(!C(this,Ar).hasImage(e)){const i=await(t.startsWith("data:image")?Vt(this,f1,tq).call(this,t):Vt(this,f1,JZ).call(this,t.startsWith("/")?this.makeServerUrl(t):new URL(t,n).href));C(this,Ar).addImage(e,i,r)}},Dv=function(e,t,n){if(n){const r=eQ(e),i=t.get(r);i?i.push(n):t.set(r,[n])}},zp=function(e,t,n,r=null){if(!(this.options.style!==bi.CENTRELINE&&n.centreline))if(e in n&&n[e].length){const i=n[e];if(Array.isArray(i))for(const o of i)Vt(this,f1,Dv).call(this,o,t,n.featureId);else Vt(this,f1,Dv).call(this,i,t,n.featureId)}else r!==null&&"models"in n&&n.models.startsWith(u7t)&&Vt(this,f1,Dv).call(this,r,t,n.featureId)},nq=function(e,t){t.featureId=e,C(this,v0).set(+e,t),Vt(this,f1,zp).call(this,"dataset",C(this,Xu),t),Vt(this,f1,zp).call(this,"models",C(this,Bp),t),Vt(this,f1,zp).call(this,"source",C(this,Np),t),Vt(this,f1,zp).call(this,"taxons",C(this,jp),t,KZ);for(const[n,r]of Object.entries(t))if(!mIt.includes(n)){C(this,Ol).has(n)||C(this,Ol).set(n,new Pa);const i=C(this,Ol).get(n);Array.isArray(r)?C(this,Ol).set(n,i.union(new Pa(r.map(o=>`${o}`)))):i.add(`${r}`)}C(this,Op).set(t.id,e),this.options.style===bi.CENTRELINE&&t.centreline&&(t.lineString=fR(t.coordinates),t.lineLength=Mct(t.lineString))},OC=async function(e){if(e&&!C(this,Ju).has(e)){const t=await this.queryLabels(e);if(t.length&&"label"in t[0])return C(this,Ju).set(e,t[0].label)}};const vIt="4.2.3",bIt=1.4;var kC,Bv,t8,E1,Fv,jv,Pl,PC,IC,rq;class VC{constructor(t,n=null){yt(this,Pl),yt(this,kC,new s7t),yt(this,Bv,!1),yt(this,t8,[]),yt(this,E1),yt(this,Fv),yt(this,jv,new g8t),pt(this,"mapServerUrl"),this.mapServerUrl=t,_t(this,E1,new fIt(t)),_t(this,Fv,n?n.images||[]:[])}get mapServer(){return C(this,E1)}async allMaps(){await Vt(this,Pl,PC).call(this);const t={};for(const n of C(this,t8)){const r=n.uuid||n.id;t[r]=n}return t}async findMap(t){return await Vt(this,Pl,PC).call(this),Vt(this,Pl,rq).call(this,t)}async loadMap(t,n,r={}){const i=await this.findMap(t);if(i===null)throw new Error(`Unknown map: ${JSON.stringify(t)}`);const o=i.uuid||i.id,a=await C(this,E1).mapIndex(o),s="uuid"in a?a.uuid:a.id;if(o!==s)throw new Error(`Map '${o}' has wrong ID in index`);const u=Object.assign({images:C(this,Fv)},r);!("bounds"in r)&&"bounds"in a&&(u.bounds=a.bounds),"style"in a?u.style=a.style:u.style=bi.GENERIC,!("image-layers"in u)&&"image_layer"in a&&(u["image-layers"]=a.image_layer),"max-zoom"in a&&(u.maxZoom=a["max-zoom"]),"min-zoom"in a&&(u.minZoom=a["min-zoom"]);let h=[];if(!("version"in a)||a.version<=1)for(const H of a.layers||[])typeof H=="string"?h.push({id:H,description:H.charAt(0).toUpperCase()+H.slice(1)}):h.push(H);else h=await C(this,E1).mapLayers(o);const d=await C(this,E1).mapStyle(o);"glyphs"in d||(d.glyphs="https://fonts.openmaptiles.org/{fontstack}/{range}.pbf");const Q=r.pathsDisabled?p7t:await C(this,E1).mapPathways(o),m=await C(this,E1).mapAnnotations(o),_=await C(this,E1).mapMetadata(o);if("vector-tiles"in d.sources){const H=d.sources["vector-tiles"];"minZoom"in u||(u.minZoom=H.minzoom),"maxZoom"in u||(u.maxZoom=H.maxzoom)}u.layerOptions?("coloured"in u.layerOptions||(u.layerOptions.coloured=!0),"outlined"in u.layerOptions||(u.layerOptions.outlined=!0)):u.layerOptions={coloured:!0,outlined:!0},u.layerOptions.authoring="authoring"in a?a.authoring:!1,u.separateLayers=!!i.separateLayers;const x=r.container||"";if(x==="")return null;const w=new _It(x,C(this,E1),{id:i.id,uuid:o,details:a,taxon:i.taxon||null,biologicalSex:i.biologicalSex||null,style:d,options:u,layers:h,sparcTermGraph:C(this,jv),annotations:m,callback:n,pathways:Q,mapMetadata:_});return await w.mapLoaded(),w}}kC=new WeakMap,Bv=new WeakMap,t8=new WeakMap,E1=new WeakMap,Fv=new WeakMap,jv=new WeakMap,Pl=new WeakSet,PC=async function(){return await C(this,kC).dispatch(async()=>{if(!C(this,Bv)){await C(this,E1).initialise(),_t(this,t8,[]);let e;try{e=await C(this,E1).flatMaps()}catch{window.alert(`Cannot connect to flatmap server at ${C(this,E1).url()}`);return}for(const t of e)t.separateLayers="version"in t&&t.version>=bIt,C(this,t8).push(t);await C(this,jv).load(C(this,E1)),_t(this,Bv,!0)}})},IC=function(e){const t=typeof e=="string"||e instanceof String?e:e.uuid||e.taxon||null;if(t===null)return null;const n=typeof e=="string"||e instanceof String?null:e.biologicalSex||null;let r=null,i="";for(const o of C(this,t8))if(("uuid"in o&&t===o.uuid||t===o.id||"taxon"in o&&t===o.taxon||t===o.source)&&(n===null||"biologicalSex"in o&&n===o.biologicalSex))if("created"in o)i<o.created&&(i=o.created,r=o);else{r=o;break}return r},rq=function(e){return typeof e=="object"?Vt(this,Pl,IC).call(this,e):Vt(this,Pl,IC).call(this,{uuid:e})},pt(VC,"version",vIt);const xIt=FH.defineStore("main",{state:()=>({userProfile:{token:""}}),getters:{userToken(e){return e.userProfile.token}},actions:{setUserToken(e){this.userProfile.token=e}}});function LIt(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(i){i(n)}),(r=e.get("*"))&&r.slice().map(function(i){i(t,n)})}}}const RC=new LIt,wIt="cannot be found on the map.",MIt=e=>{let t={lng:0,lat:0},n;return e.type==="Polygon"?e.coordinates.length&&(n=e.coordinates[0]):n=e.coordinates,n&&(e.type!=="Point"?(n.map(r=>{t.lng+=parseFloat(r[0]),t.lat+=parseFloat(r[1])}),t.lng=t.lng/n.length,t.lat=t.lat/n.length):(t.lng+=parseFloat(n[0]),t.lat+=parseFloat(n[1]))),t},iq=(e,t)=>{const n=[];let r=e.organs?e.organs:e.ftus;const i=r?r.filter((o,a)=>r.findIndex(s=>s.label===o.label)===a):void 0;return i&&i.forEach(o=>{const a={label:o.label,models:o.models,key:`${t}.${o.label}`},s=iq(o,a.key);s.length>0&&(a.children=s),n.push(a)}),n},EIt={name:"FlatmapVuer",components:{Button:lP,Col:ah,Loading:k1t,Radio:xP,Icon:P2,RadioGroup:LP,Row:sh,Select:TT,Dialog:Yot,MapSvgIcon:BH.MapSvgIcon,MapSvgSpriteColor:BH.MapSvgSpriteColor,Tooltip:Ab.Tooltip,TreeControls:Ab.TreeControls,SelectionsGroup:IP,SvgLegends:VP,ElIconWarningFilled:Fi.WarningFilled,ElIconArrowDown:Fi.ArrowDown,ElIconArrowLeft:Fi.ArrowLeft,DrawToolbar:Ab.DrawToolbar},beforeCreate:function(){this.setStateRequired=!1},setup(e){let t=L.inject("$annotator");return t||(t=L.markRaw(new lK.AnnotationService(`${e.flatmapAPI}annotator`)),L.provide("$annotator",t)),{annotator:t}},methods:{setVisibilityFilter:function(e){this.mapImp&&(e?this.mapImp.setVisibilityFilter(e):this.mapImp.clearVisibilityFilter())},manualAbortedOnClose:function(){this.annotationSidebar&&this.$emit("annotation-close"),this.closeTooltip(),this.annotationEventCallback({},{type:"aborted"}),this.initialiseDrawing()},initialiseDrawing:function(){this.connectionEntry={},this.activeDrawTool=void 0,this.activeDrawMode=void 0,this.drawnCreatedEvent={}},cancelDrawnFeature:function(){this.isValidDrawnCreated&&(this.annotationSidebar&&this.$emit("annotation-close"),this.closeTooltip(),this.annotationEntry=[{...this.drawnCreatedEvent.feature,resourceId:this.serverURL}],this.rollbackAnnotationEvent(),this.initialiseDrawing())},connectedFeatureTooltip:function(e){if(this.mapImp)if(e){const t=Number(e);let r={feature:t?this.mapImp.featureProperties(t):{feature:this.existDrawnFeatures.find(i=>i.id===e.trim())}};this.checkAndCreatePopups([r])}else this.closeTooltip()},confirmDrawnFeature:function(){this.isValidDrawnCreated&&(this.checkAndCreatePopups([this.drawnCreatedEvent]),Object.keys(this.connectionEntry).length>0&&(this.annotationEntry[0].feature.connection=this.connectionEntry),this.initialiseDrawing())},toolbarEvent:function(e,t){if(!this.isValidDrawnCreated){if(this.manualAbortedOnClose(),this.doubleClickedFeature=!1,this.changeAnnotationDrawMode({mode:"simple_select"}),e==="mode")this.activeDrawMode=t;else if(e==="tool"){if(this.cancelDrawnFeature(),t){const n=t.replace(/[A-Z]/g,r=>`_${r.toLowerCase()}`);this.changeAnnotationDrawMode({mode:`draw${n}`})}this.activeDrawTool=t}}},annotationDrawModeEvent:function(e){this.activeDrawMode==="Edit"?this.doubleClickedFeature&&(e.feature.feature.geometry.type!=="Point"&&(this.changeAnnotationDrawMode({mode:"direct_select",options:{featureId:e.feature.feature.id}}),this.modifyAnnotationFeature()),this.doubleClickedFeature=!1):this.activeDrawMode==="Delete"&&(this.changeAnnotationDrawMode({mode:"simple_select",options:{featureIds:[e.feature.feature.id]}}),this.modifyAnnotationFeature())},createConnectivityBody:function(){if(Object.keys(this.connectionEntry).length>0){const e=Object.values(this.connectionEntry),t={type:"connectivity",source:e[0],target:e[e.length-1],intermediates:e.filter((n,r)=>r!==0&&r!==e.length-1)};this.annotationEntry[0].body=t}},changeAnnotationDrawMode:function(e){this.mapImp&&this.mapImp.changeAnnotationDrawMode(e)},clearAnnotationFeature:function(){this.mapImp&&this.mapImp.clearAnnotationFeature()},modifyAnnotationFeature:function(){this.mapImp&&this.mapImp.removeAnnotationFeature()},rollbackAnnotationEvent:function(){this.mapImp&&this.annotationEntry.length>0&&["created","updated","deleted"].includes(this.annotationEntry[0].type)&&(this.mapImp.rollbackAnnotationEvent(this.annotationEntry[0]),this.annotationEntry=[])},commitAnnotationEvent:function(e){this.mapImp&&(this.offlineAnnotationEnabled&&(this.offlineAnnotations=JSON.parse(sessionStorage.getItem("anonymous-annotation"))||[],this.offlineAnnotations.push(e),this.annotationEntry[0].type==="deleted"&&(this.offlineAnnotations=this.offlineAnnotations.filter(t=>t.resource!==this.serverURL||t.item.id!==e.item.id)),sessionStorage.setItem("anonymous-annotation",JSON.stringify(this.offlineAnnotations))),["created","updated","deleted"].includes(this.annotationEntry[0].type)&&(this.featureAnnotationSubmitted=!0,this.mapImp.commitAnnotationEvent(this.annotationEntry[0]),e.body.comment==="Position Updated"?this.annotationEntry[0].positionUpdated=!1:this.annotationEntry[0].type==="deleted"&&(this.annotationSidebar&&this.$emit("annotation-close"),this.closeTooltip(),this.annotationEntry=[]),this.addAnnotationFeature()))},fetchAnnotatedItemIds:async function(e=void 0,t=void 0){let n;return this.offlineAnnotationEnabled?(this.offlineAnnotations=JSON.parse(sessionStorage.getItem("anonymous-annotation"))||[],n=this.offlineAnnotations.filter(r=>r.resource===this.serverURL).map(r=>r.item.id)):(n=await this.annotator.annotatedItemIds(this.userToken,this.serverURL,e,t),"resource"in n&&(n=n.itemIds)),n},setFeatureAnnotated:async function(){if(this.mapImp){const e=await this.fetchAnnotatedItemIds();for(const t of e)this.mapImp.setFeatureAnnotated(t)}},fetchDrawnFeatures:async function(e,t){let n;if(this.offlineAnnotationEnabled)this.offlineAnnotations=JSON.parse(sessionStorage.getItem("anonymous-annotation"))||[],n=this.offlineAnnotations.filter(r=>r.feature&&r.resource===this.serverURL).map(r=>r.feature);else{const r=await this.fetchAnnotatedItemIds(e,t);n=await this.annotator.drawnFeatures(this.userToken,this.serverURL,r),"resource"in n&&(n=n.features)}return n},addAnnotationFeature:async function(){if(this.mapImp){this.featureAnnotationSubmitted||(this.clearAnnotationFeature(),this.loading=!0);const e=this.annotationFrom==="Anyone"?void 0:this.authorisedUser.orcid?this.authorisedUser.orcid:"0000-0000-0000-0000",t=this.annotationFrom==="Anyone"?void 0:this.annotationFrom==="Me",n=await this.fetchDrawnFeatures(e,t);if(this.existDrawnFeatures=n,this.loading=!1,!this.featureAnnotationSubmitted)for(const r of n)this.mapImp.addAnnotationFeature(r)}},showAnnotator:function(e){this.mapImp&&(this.mapImp.showAnnotator(e),this.$el.querySelector(".maplibregl-ctrl-group").style.display="none")},setAnnotationFrom:function(e){this.annotationFrom=e,this.mapImp&&(this.manualAbortedOnClose(),this.addAnnotationFeature())},setFlightPath3D:function(e){this.flightPath3DRadio=e,this.mapImp&&this.mapImp.enableFlightPaths(e)},viewLatestMap:function(){let e=this.biologicalSex?this.biologicalSex:void 0;this.entry==="NCBITaxon:9606"&&(e="PATO:0000384");const t={entry:this.entry,biologicalSex:e,viewport:this.mapImp.getState()};this.$emit("view-latest-map",t)},backgroundChangeCallback:function(e){this.currentBackground=e,this.mapImp&&this.mapImp.setBackgroundColour(this.currentBackground,1)},processSystems:function(e){if(this.systems.length=0,e&&e.length>0){const t={label:"All",key:"All",children:[]};e.forEach(n=>{const r={colour:n.colour,enabled:n.enabled,label:n.id,key:n.id},i=iq(n,r.key);i.length>0&&(r.children=i),t.children.push(r)}),this.systems.push(t)}},processTaxon:function(e,t){this.taxonConnectivity.length=0,_T(this.mapImp,e).then(n=>{n.length&&n.forEach(r=>{let i=!0;t&&(i=t.checkAll?!0:t.checked.includes(r.taxon)),this.taxonConnectivity.push({...r,enabled:i}),this.mapImp&&this.mapImp.enableConnectivityByTaxonIds(r.taxon,i)})})},toggleDrawer:function(){this.drawerOpen=!this.drawerOpen},setColour:function(e){this.colourRadio=e,this.mapImp&&this.mapImp.setPaint({colour:e,outline:this.outlinesRadio})},setOutlines:function(e){this.outlinesRadio=e,this.mapImp&&this.mapImp.setPaint({colour:this.colourRadio,outline:e})},setInitMapState:function(){if(this.mapImp){const e=this.mapImp.map,t=this.mapImp.options.bounds,n=[[t[0],t[1]],[t[2],t[3]]];e.setMaxBounds(null),e.setRenderWorldCopies(!1),this.initMapState=L.markRaw({initBounds:n})}},resetView:function(){if(this.mapImp){const e=this.mapImp.map,{initBounds:t}=this.initMapState;e.resetNorthPitch({animate:!1}),t&&e.fitBounds(t,{animate:!1}),this.$refs.skcanSelection&&this.$refs.skcanSelection.reset(),this.$refs.layersSelection&&this.$refs.layersSelection.reset(),this.$refs.systemsSelection&&this.$refs.pathwaysSelection.reset(),this.$refs.pathwaysSelection&&this.$refs.pathwaysSelection.reset()}},zoomIn:function(){this.mapImp&&this.mapImp.zoomIn()},zoomOut:function(){this.mapImp&&this.mapImp.zoomOut()},onSelectionsDataChanged:function(e){this.$emit("pathway-selection-changed",e)},sckanSelected:function(e){this.mapImp&&this.mapImp.enableSckanPath(e.key,e.value)},checkAllSCKAN:function(e){this.mapImp&&e.keys.forEach(t=>this.mapImp.enableSckanPath(t,e.value))},zoomToFeatures:function(e){this.mapImp&&this.mapImp.zoomToFeatures(e)},retrieveConnectedPaths:async function(e,t={}){var n,r,i,o,a;if(this.mapImp){let s=[],u=(n=t.target)!=null&&n.length?t.target:[];const h=[...this.mapImp.pathModelNodes(e)],d=await this.mapImp.queryPathsForFeatures(e);if(h.length){if(!u.length){const Q=(r=t.type)!=null&&r.length?t.type:["all"],m=await this.flatmapQueries.queryForConnectivityNew(this.mapImp,e[0]),_=(i=m==null?void 0:m.ids)==null?void 0:i.dendrites.flat(1/0),x=(o=m==null?void 0:m.ids)==null?void 0:o.components.flat(1/0),w=(a=m==null?void 0:m.ids)==null?void 0:a.axons.flat(1/0);let H=[];Q.includes("origins")&&H.push(..._),Q.includes("components")&&H.push(...x),Q.includes("destinations")&&H.push(...w),Q.includes("all")&&H.push(..._,...x,...w),u=[...new Set(H)]}h.forEach(Q=>{this.mapImp.nodePathModels(Q).forEach(_=>{const w=this.mapImp.pathModelNodes(_).map(S=>this.mapImp.featureProperties(S).models);u.filter(S=>w.includes(S)).length&&!s.includes(_)&&s.push(_)})})}else d.length&&(u.length?d.forEach(Q=>{const _=this.mapImp.pathModelNodes(Q).map(w=>this.mapImp.featureProperties(w).models);u.filter(w=>_.includes(w)).length&&!s.includes(Q)&&s.push(Q)}):s=d);return s=[...new Set([...s,...e])],s}},resetMapFilter:function(){const e=this.mapFilters.alert;let t;e.with?e.without||(t={HAS:"alert"}):e.without?t={NOT:{HAS:"alert"}}:t={AND:[{NOT:{HAS:"alert"}},{HAS:"alert"}]},t?this.mapImp.setVisibilityFilter(t):this.mapImp.clearVisibilityFilter()},alertMouseEnterEmitted:function(e){if(this.mapImp)if(e.value){let t;e.key==="alert"?t={HAS:"alert"}:e.key==="withoutAlert"&&(t={NOT:{HAS:"alert"}}),this.mapImp.setVisibilityFilter(t)}else this.resetMapFilter()},alertSelected:function(e){this.mapImp&&(e.key==="alert"?e.value?this.mapFilters.alert.with=!0:this.mapFilters.alert.with=!1:e.key==="withoutAlert"&&(e.value?this.mapFilters.alert.without=!0:this.mapFilters.alert.without=!1),this.resetMapFilter())},checkAllAlerts:function(e){this.mapImp&&(e.value?(this.mapFilters.alert.without=!0,this.mapFilters.alert.with=!0):(this.mapFilters.alert.without=!1,this.mapFilters.alert.with=!1),this.resetMapFilter())},systemSelected:function(e){this.mapImp&&this.mapImp.enableSystem(e.key,e.value)},checkAllSystems:function(e){this.mapImp&&this.systems[0].children.forEach(t=>this.mapImp.enableSystem(t.label,e))},ftuSelected:function(e){this.searchAndShowResult(e,!0)},layersSelected:function(e){this.mapImp&&this.mapImp.enableLayer(e.key,e.value)},checkAllLayers:function(e){this.mapImp&&e.keys.forEach(t=>this.mapImp.enableLayer(t,e.value))},taxonsSelected:function(e){this.mapImp&&this.mapImp.enableConnectivityByTaxonIds(e.key,e.value)},taxonMouseEnterEmitted:function(e){if(this.mapImp)if(e.value){clearTimeout(this.taxonLeaveDelay);let t=this.mapImp.taxonFeatureIds(e.key);this.mapImp.enableConnectivityByTaxonIds(e.key,e.value),this.mapImp.zoomToGeoJSONFeatures(t,{noZoomIn:!0})}else this.taxonLeaveDelay=setTimeout(()=>{this.mapImp.unselectGeoJSONFeatures(),e.selections.forEach(t=>{let n=e.checked.includes(t.taxon);this.mapImp.enableConnectivityByTaxonIds(t.taxon,n)})},1e3)},checkAllTaxons:function(e){this.mapImp&&this.mapImp.enableConnectivityByTaxonIds(e.keys,e.value)},pathwaysSelected:function(e){this.mapImp&&this.mapImp.enablePath(e.key,e.value)},checkAllPathways:function(e){this.mapImp&&e.keys.forEach(t=>this.mapImp.enablePath(t,e.value))},enablePanZoomEvents:function(e){this.mapImp.enablePanZoomEvents(e)},annotationEventCallback:function(e,t){if(t.type==="aborted")this.featureAnnotationSubmitted?this.featureAnnotationSubmitted=!1:this.rollbackAnnotationEvent(),this.annotationEntry=[];else if(t.type==="modeChanged")t.feature.mode==="direct_select"&&(this.doubleClickedFeature=!0),this.annotationSidebar&&t.feature.mode==="simple_select"&&this.activeDrawMode==="Deleted"&&this.annotationEventCallback({},{type:"aborted"});else if(t.type==="selectionChanged"){if(this.selectedDrawnFeature=t.feature.features.length===0?void 0:t.feature.features[0],e.feature.feature=this.selectedDrawnFeature,!this.activeDrawTool)if(this.connectionEntry={},this.selectedDrawnFeature){const n=this.existDrawnFeatures.find(r=>r.id===this.selectedDrawnFeature.id);n&&n.connection&&(this.connectionEntry=n.connection),this.annotationDrawModeEvent(e)}else this.annotationSidebar&&this.previousEditEvent.type==="updated"&&(this.annotationEntry=[{...this.previousEditEvent,resourceId:this.serverURL}],this.annotationEventCallback({},{type:"aborted"})),this.previousEditEvent={}}else{if(t.type==="created"||t.type==="updated"){t.type==="updated"&&t.feature.action&&(t.positionUpdated=t.feature.action==="move");const n=this.mapImp.refreshAnnotationFeatureGeometry(t.feature);e.feature.feature=n}t.type==="created"?this.drawnCreatedEvent=e:this.checkAndCreatePopups([e])}t.type==="updated"&&(this.previousEditEvent=t),t.type==="deleted"?this.previousDeletedEvent=t:this.previousDeletedEvent={}},eventCallback:function(){return(e,t,...n)=>{if(e==="annotation"){const r={feature:t,userData:n,eventType:e};this.annotationEventCallback(r,t)}else if(e!=="pan-zoom"){const r=t.label,i=[t.models],o=this.entry,a=this.biologicalSex,s=t.alert;let u;t.taxons&&(typeof t.taxons!="object"?u=JSON.parse(t.taxons):u=t.taxons);let h=[{dataset:t.dataset,biologicalSex:a,taxonomy:o,resource:i,label:r,feature:t,userData:n,eventType:e,provenanceTaxonomy:u,alert:s}];if(e==="click"){const d=Object.keys(t).includes("id");if(!d){h=[];const m=t.mapUUID,_=new Set;for(let[x,w]of Object.entries(t))if(x!=="mapUUID"){const H=w.id,S=w.label,P=[w.models];let V;if(w.taxons&&(typeof w.taxons!="object"?V=JSON.parse(w.taxons):V=w.taxons),_.has(H))continue;_.add(H),h.push({dataset:w.dataset,biologicalSex:a,taxonomy:o,resource:P,label:S,feature:w,userData:n,eventType:e,provenanceTaxonomy:V,alert:w.alert,mapUUID:m})}}const Q=d?t:t[0];if(this.setConnectivityDataSource(this.viewingMode,Q),this.viewingMode==="Neuron Connection")this.retrieveConnectedPaths([Q.models]).then(m=>{this.zoomToFeatures(m)});else if(this.currentActive=Q.models?Q.models:"",this.activeDrawTool&&!this.isValidDrawnCreated){const m=Q.featureId||this.existDrawnFeatures.find(_=>_.id===Q.id);if(this.activeDrawTool==="LineString"&&m){const _=Q.featureId?Q.featureId:Q.id,x=Q.label?Q.label:`Feature ${Q.id}`;this.connectionEntry[` ${_}`]=Object.assign({label:x},Object.fromEntries(Object.entries(Q).filter(([w])=>["featureId","models"].includes(w)).map(([w,H])=>[w==="featureId"?"id":w,H])))}}}else e==="mouseenter"&&this.viewingMode!=="Neuron Connection"&&(this.currentHover=t.models?t.models:"");t&&t.type!=="marker"&&e==="click"&&this.viewingMode!=="Neuron Connection"&&!this.activeDrawTool&&this.checkAndCreatePopups(h),this.$emit("resource-selected",h)}else this.$emit("pan-zoom-callback",t)}},setConnectivityDataSource:function(e,t){this.connectivityDataSource=t.source,(e==="Neuron Connection"||e==="Annotation")&&(this.connectivityDataSource=t.featureId)},changeViewingMode:function(e){e&&(this.viewingMode=e),this.manualAbortedOnClose()},removeActiveTooltips:function(){this.mapImp&&this.mapImp.removePopup(),this.$el.querySelectorAll(".flatmap-tooltip-popup").forEach(t=>t.remove())},createTooltipForConnectivity:function(e,t){const n=document.createElement("div");n.classList.add("flatmap-feature-label"),e.forEach((r,i)=>{const{label:o}=r;if(n.append(NP(o)),i+1<e.length){const a=document.createElement("hr");n.appendChild(a)}}),this.mapImp.showPopup(t,n,{className:"custom-popup flatmap-tooltip-popup",positionAtLastClick:!1,preserveSelection:!0})},showConnectivityTooltips:function(e){const{connectivityInfo:t,data:n}=e,r=[],i=[],o=[],a=[];if(t&&t.featureId&&r.push(...t.featureId),this.mapImp){if(n.forEach(h=>{const d=this.mapImp.search(h.id);if(d!=null&&d.results.length){const Q=d==null?void 0:d.results[0].featureId;o.push({featureId:Q,...h})}else a.push(h)}),o.length){let h=o[0].featureId;this.mapImp.annotations.forEach(d=>{const Q=d["anatomical-nodes"];if(Q){const m=Q.join("");o.every(x=>m.indexOf(x.id)!==-1)&&(h=d.featureId,i.push(h))}}),this.createTooltipForConnectivity(o,h)}else this.removeActiveTooltips();this.emitConnectivityError(a);const u=[...this.mapImp.modelFeatureIdList(r),...i];this.mapImp.selectGeoJSONFeatures(u)}},showConnectivitiesByReference:function(e){this.searchConnectivitiesByReference(e).then(t=>{this.mapImp.selectFeatures(t)})},searchConnectivitiesByReference:async function(e){const t=sessionStorage.getItem("flatmap-knowledge");let n=[];return t?n=await W1t(e):n=await Z1t(this.mapImp,e,this.flatmapQueries),n},emitConnectivityError:function(e){this.$emit("connectivity-error",{data:{errorData:e,errorMessage:wIt}})},checkConnectivityTooltipEntry:function(e){return e!=null&&e.length?e.find(t=>{var n,r;return((n=t==null?void 0:t.destinations)==null?void 0:n.length)||((r=t==null?void 0:t.components)==null?void 0:r.length)})!==void 0:!1},changeConnectivitySource:async function(e){const{entry:t,connectivitySource:n}=e;t.mapId===this.mapImp.id&&(await this.flatmapQueries.queryForConnectivityNew(this.mapImp,t.featureId[0],n),this.tooltipEntry=this.tooltipEntry.map(r=>r.featureId[0]===t.featureId[0]?this.flatmapQueries.updateTooltipData(r):r),this.checkConnectivityTooltipEntry(this.tooltipEntry)&&this.$emit("connectivity-info-open",this.tooltipEntry))},checkAndCreatePopups:async function(e){if(this.viewingMode==="Annotation"){const t=e.filter(n=>n.feature).map(n=>n.feature);if(t.length>0)if(this.annotationSidebar&&this.previousDeletedEvent.type==="deleted"&&(this.annotationEntry=[{...this.previousDeletedEvent,resourceId:this.serverURL}],this.annotationEventCallback({},{type:"aborted"})),this.annotationEntry=[],t.forEach(n=>{var r;this.annotationEntry.push({...n,resourceId:this.serverURL,featureId:n.featureId?n.featureId:(r=n.feature)==null?void 0:r.id,offline:this.offlineAnnotationEnabled})}),t[0].feature)this.activeDrawTool||this.activeDrawMode||this.isValidDrawnCreated?(this.featureAnnotationSubmitted=!1,this.activeDrawTool&&this.createConnectivityBody(),this.displayTooltip(t[0].feature.id,MIt(t[0].feature.geometry))):this.rollbackAnnotationEvent();else{const n=this.annotationEntry.filter(r=>r.featureId&&r.models).map(r=>r.models);n.length>0&&this.displayTooltip(n)}else this.annotation={}}else{X1t(this.mapImp,this.flatmapQueries);let t=[];if(this.tooltipEntry=e.filter(n=>n.resource[0]&&this.mapImp.pathModelNodes(n.resource).length>0).map(n=>({title:n.label,featureId:n.resource,ready:!1})),this.tooltipEntry.length){this.$emit("connectivity-info-open",this.tooltipEntry);for(let r=0;r<e.length;r++)t.push(await this.getKnowledgeTooltip(e[r]));this.tooltipEntry=await Promise.all(t);const n=this.tooltipEntry.map(r=>r.featureId[0]);n.length>0&&this.displayTooltip(n)}}},getKnowledgeTooltip:async function(e){const t=await this.flatmapQueries.retrieveFlatmapKnowledgeForEvent(this.mapImp,e);let n=await this.flatmapQueries.createTooltipData(this.mapImp,e);return(t&&t[0]||e.feature.hyperlinks&&e.feature.hyperlinks.length>0)&&(n.featuresAlert=e.alert,n.knowledgeSource=Px(this.mapImp),n.mapId=this.mapImp.provenance.id,n.mapuuid=this.mapImp.provenance.uuid),n.ready=!0,n},popUpCssHacks:function(){const e=document.querySelector(".flatmap-tooltip-popup"),t=document.querySelector(".maplibregl-popup-close-button");e&&(e.style.display="none"),t.style.display="block",this.$refs.tooltip.$el.style.display="flex",t.onclick=()=>{this.$emit("connectivity-info-close"),e&&(e.style.display="block")}},closeTooltip:function(){this.$refs.tooltip&&(this.$refs.tooltip.$el.style.display="none"),document.querySelectorAll(".maplibregl-popup").forEach(e=>{e.style.display="none"})},showPopup:function(e,t,n){let r=n;this.mapImp&&(r?r.className||(r.className="custom-popup"):r={className:"custom-popup",positionAtLastClick:!0},this.mapImp.showPopup(e,t,r))},showMarkerPopup:function(e,t,n){this.mapImp&&this.mapImp.showMarkerPopup(e,t,n)},closeMinimap:function(){let e=this.$refs.flatmapContainer.querySelector(".maplibregl-ctrl-minimap");this.minimapSmall?(e.classList.add("enlarge"),e.classList.remove("shrink")):(e.classList.add("shrink"),e.classList.remove("enlarge")),this.minimapSmall=!this.minimapSmall},addResizeButtonToMinimap:function(){let e=this.$refs.flatmapContainer.querySelector(".maplibregl-ctrl-minimap");e&&(this.$refs.minimapResize&&this.$refs.minimapResize.$el.parentNode&&this.$refs.minimapResize.$el.parentNode.removeChild(this.$refs.minimapResize.$el),e.appendChild(this.$refs.minimapResize.$el),this.minimapResizeShow=!0)},setHelpMode:function(e){const t=this.hoverVisibilities.length,n=t-1,r=this.hoverVisibilities[this.helpModeActiveIndex];if(r){const i=r==null?void 0:r.refs,o=r==null?void 0:r.ref,a=this.$refs[i||o];if(a){const{parentElement:s,nextElementSibling:u}=a.$el,h=d=>d&&(d.classList.contains("pathway-container")||d.classList.contains("pathway-location"));(h(s)||h(u))&&(this.requiresDrawer?this.drawerOpen=!0:this.helpModeActiveIndex+=1)}else this.helpModeActiveIndex+=1}e||(this.helpModeActiveIndex=this.helpModeInitialIndex),this.viewingMode!=="Annotation"&&this.helpModeActiveIndex>9&&(this.helpModeActiveIndex=n),e&&this.helpModeActiveIndex>=n&&this.$emit("help-mode-last-item",!0),e&&!this.helpModeDialog?(this.inHelp=!0,this.hoverVisibilities.forEach(i=>{i.value=!0})):e&&this.helpModeDialog&&t>this.helpModeActiveIndex?this.helpModeActiveIndex>-1?(this.closeFlatmapHelpPopup(),setTimeout(()=>{this.inHelp=!1,this.hoverVisibilities.forEach(i=>{i.value=!1}),this.showTooltip(this.helpModeActiveIndex,200)},300)):this.helpModeActiveIndex===-1&&this.openFlatmapHelpPopup():(this.inHelp=!1,this.hoverVisibilities.forEach(i=>{i.value=!1}),this.closeFlatmapHelpPopup())},showTooltip:function(e,t=500){this.inHelp||(clearTimeout(this.tooltipWait[e]),this.tooltipWait[e]=setTimeout(()=>{this.hoverVisibilities[e].value=!0,this.$emit("shown-tooltip")},t))},hideTooltip:function(e,t=500){this.inHelp||(clearTimeout(this.tooltipWait[e]),this.tooltipWait[e]=setTimeout(()=>{this.hoverVisibilities[e].value=!1},t))},displayTooltip:function(e,t=void 0){let n,r={className:"flatmapvuer-popover"};if(t)n=e,r.annotationFeatureGeometry=t;else{const i=Array.isArray(e)?e[0]:e;i&&(n=this.mapImp.modelFeatureIds(i)[0]),this.activeDrawTool||(r.positionAtLastClick=!0)}this.connectivityInfoSidebar&&this.tooltipEntry.length&&this.viewingMode!=="Annotation"&&this.checkConnectivityTooltipEntry(this.tooltipEntry)&&this.$emit("connectivity-info-open",this.tooltipEntry),this.annotationSidebar&&this.viewingMode==="Annotation"&&this.$emit("annotation-open",{annotationEntry:this.annotationEntry,commitCallback:this.commitAnnotationEvent}),n&&!this.disableUI&&(this.viewingMode==="Annotation"&&!this.annotationSidebar||this.viewingMode==="Exploration"&&!this.connectivityInfoSidebar)&&(this.tooltipDisplay=!0,this.$nextTick(()=>{this.mapImp.showPopup(n,this.$refs.tooltip.$el,r),this.popUpCssHacks()}))},moveMap:function(e,t={}){if(this.mapImp){const{offsetX:n=0,offsetY:r=0,zoom:i=4}=t,o=this.mapImp.map,a=this.mapImp.bounds.toArray();this.mapImp.zoomToFeatures(e,{noZoomIn:!0}),this.showPathwaysDrawer(!1),a!=null&&a.length&&setTimeout(()=>{o.fitBounds(a,{offset:[n,r],zoom:i,animate:!0})})}},openFlatmapHelpPopup:function(){if(this.mapImp){let e=this.mapImp.modelFeatureIds("UBERON:0000948");e&&e.length>0&&(this.mapImp.showPopup(e[0],"Click for more information",{anchor:"top",className:"flatmap-popup-popper"}),this.$emit("shown-map-tooltip"))}},closeFlatmapHelpPopup:function(){this.$el.querySelectorAll(".maplibregl-popup-close-button").forEach(e=>{e.click()})},getLabels:function(){let e=[];if(this.mapImp){let t=this.mapImp.annotations;for(let n of t.values())n.label&&e.push(n.label);return Array.from(new Set(e))}},getVisibilityState:function(e){if(["alertSelection","pathwaysSelection","taxonSelection"].forEach(n=>{let r=this.$refs[n];r&&(e[n]=r.getState())}),this.$refs.treeControls){const n=this.$refs.treeControls.$refs.regionTree.getCheckedKeys();e.systemsSelection=n.filter(r=>!r.includes("."))}},setVisibilityState:function(e){["alertSelection","pathwaysSelection","taxonSelection"].forEach(n=>{const r=e[n];if(r){const i=this.$refs[n];i&&i.setState(r)}}),"systemsSelection"in e&&this.$refs.treeControls&&(this.$refs.treeControls.$refs.regionTree.setCheckedKeys(e.systemsSelection),this.systems[0].children.forEach(n=>{this.mapImp.enableSystem(n.key,e.systemsSelection.includes(n.key))}))},getState:function(){if(this.mapImp){let e={entry:this.entry,viewport:this.mapImp.getState()};const t=this.mapImp.getIdentifier();return this.biologicalSex?e.biologicalSex=this.biologicalSex:t&&t.biologicalSex&&(e.biologicalSex=t.biologicalSex),t&&t.uuid&&(e.uuid=t.uuid),e.viewingMode=this.viewingMode,e.searchTerm=this.searchTerm,e.flightPath3D=this.flightPath3DRadio,e.colour=this.colourRadio,e.outlines=this.outlinesRadio,e.background=this.currentBackground,this.offlineAnnotationEnabled&&(e.offlineAnnotations=sessionStorage.getItem("anonymous-annotation")),this.getVisibilityState(e),e}},setState:function(e){e&&(this.mapImp&&e.entry&&this.entry==e.entry&&(!e.biologicalSex||e.biologicalSex===this.biologicalSex)?this.restoreMapState(e):this.createFlatmap(e),this.setStateRequired=!1)},restoreMapState:function(e){if(e){if(e.viewport&&this.mapImp.setState(e.viewport),e.offlineAnnotations&&sessionStorage.setItem("anonymous-annotation",e.offlineAnnotations),e.viewingMode&&this.changeViewingMode(e.viewingMode),"flightPath3D"in e&&this.setFlightPath3D(e.flightPath3D),"colour"in e&&this.setColour(e.colour),"outlines"in e&&this.setOutlines(e.outlines),e.background&&this.backgroundChangeCallback(e.background),e.searchTerm){const t=e.searchTerm;this.searchAndShowResult(t,!0)}this.setVisibilityState(e)}},setFlightPathInfo:function(e){(e===1.6||e>1.6)&&(this.displayFlightPathOption=!0,this.setFlightPath3D(!1))},createFlatmap:function(e){if(!this.mapImp&&!this.loading){this.loading=!0;let t=!1;this.displayMinimap&&(t={position:"top-right"});let n={taxon:this.entry};this.uuid&&(n.uuid=this.uuid),e?(e.uuid?n={uuid:e.uuid}:e.entry&&(n.taxon=e.entry),e.biologicalSex?n.biologicalSex=e.biologicalSex:n.taxon==="NCBITaxon:9606"&&(n.biologicalSex="PATO:0000384")):this.biologicalSex&&(n.biologicalSex=this.biologicalSex),this.mapManagerRef.loadMap(n,this.eventCallback(),{minZoom:this.minZoom,tooltips:this.tooltips,minimap:t,container:this.$refs.display}).then(i=>{this.mapImp=i,this.serverURL=this.mapImp.makeServerUrl("").slice(0,-1);let o=this.mapImp.details.version;this.setFlightPathInfo(o);const a=this._stateToBeSet?this._stateToBeSet:e;this.onFlatmapReady(a),this.$nextTick(()=>this.restoreMapState(a))})}else e&&(this._stateToBeSet={...e},this.mapImp&&!this.loading&&this.restoreMapState(this._stateToBeSet))},computePathControlsMaximumHeight(){const e=this.$refs.display;if(e){const t=getComputedStyle(e),n=parseInt(t.paddingTop)+parseInt(t.paddingBottom),r=e.clientHeight-n;this.pathwaysMaxHeight=r-170}},mapResize:function(){try{this.computePathControlsMaximumHeight(),this.mapImp&&(this.mapImp.resize(),this.showMinimap(this.displayMinimap))}catch{console.error("Map resize error")}},getFilterSources:function(){const e=["kind","taxons"];let t=new Set,n=new Set,r=new Map;for(const o of this.mapImp.annotations.values())if(o.source){"alert"in o?t.add(o.source):n.add(o.source);for(const[a,s]of Object.entries(o))if(e.includes(a)){r.has(a)||r.set(a,new Map);const u=r.get(a),h=d=>{const Q=d;u.has(Q)||u.set(Q,new Set),u.get(Q).add(`${o.source}`)};Array.isArray(s)?s.forEach(h):h(s)}}let i={alert:{with:[...t],without:[...n]}};for(const[o,a]of r.entries()){i[o]={};for(const[s,u]of a.entries())i[o][s]=[...u.values()]}return i},getFilterOptions:async function(){if(this.mapImp){let e=[];const t=this.mapImp.featureFilterRanges();for(const[n,r]of Object.entries(t)){let i={key:`flatmap.connectivity.${n}`,label:"",children:[]};if(n==="kind"){i.label="Pathways";for(const o of r){const a=this.pathways.find(s=>s.type!=="centreline"&&s.type===o);a&&i.children.push({key:`${i.key}.${o}`,label:a.label})}}else if(n==="taxons"){i.label="Studied in";const o=await _T(this.mapImp,this.mapImp.taxonIdentifiers);if(o.length)for(const a of r){const s=o.find(u=>u.taxon===a);s&&i.children.push({key:`${i.key}.${a}`,label:s.label})}}else if(n==="alert"){i.label="Alert";for(const o of["with","without"])i.children.push({key:`${i.key}.${o}`,label:`${o} alerts`})}i.label&&i.children.length&&e.push(i)}return e}},onFlatmapReady:function(e){var t;this.sensor=L.markRaw(new est(this.$refs.display,this.mapResize)),((t=this.mapImp.options)==null?void 0:t.style)==="functional"&&(this.isFC=!0),this.mapImp.setBackgroundOpacity(1),this.backgroundChangeCallback(this.currentBackground),this.pathways=this.mapImp.pathTypes(),this.processSystems(this.mapImp.getSystems()),this.processTaxon(this.mapImp.taxonIdentifiers,e?e.taxonSelection:void 0),this.containsAlert="alert"in this.mapImp.featureFilterRanges(),this.addResizeButtonToMinimap(),this.loading=!1,this.computePathControlsMaximumHeight(),this.mapResize(),this.handleMapClick(),this.setInitMapState(),this.$emit("ready",this)},handleMapClick:function(){const e=this.mapImp.map;e&&e.on("click",t=>{this.connectivityDataSource||this.$emit("connectivity-info-close"),this.connectivityDataSource=""})},showMinimap:function(e){this.mapImp&&this.mapImp.showMinimap(e)},showPathwaysDrawer:function(e){this.drawerOpen=e},searchAndShowResult:function(e,t){var n;if(this.mapImp){if(e===void 0||e==="")return this.mapImp.clearSearchResults(),this.viewingMode==="Exploration"?this.$emit("connectivity-info-close"):this.viewingMode==="Annotation"&&this.manualAbortedOnClose(),this.searchTerm="",!0;{const r=this.mapImp.search(e);if((n=r==null?void 0:r.results)!=null&&n.length){if(this.mapImp.showSearchResults(r),t){let i;for(let o=0;o<r.results.length;o++){i=r.results[o].featureId;const a=this.mapImp.annotation(i);if(i&&(a!=null&&a.label))break}if(i){const o=this.mapImp.featureProperties(i),a={resource:[o.models],feature:o,label:o.label,provenanceTaxonomy:o.taxons,alert:o.alert};this.viewingMode==="Exploration"||this.viewingMode==="Annotation"?this.checkAndCreatePopups([a]):this.viewingMode==="Neuron Connection"&&this.retrieveConnectedPaths(a.resource).then(s=>{this.zoomToFeatures(s)}),this.mapImp.showPopup(i,NP(o.label),{className:"custom-popup",positionAtLastClick:!1,preserveSelection:!0})}}return this.searchTerm=e,!0}else this.mapImp.clearSearchResults()}}return!1},searchSuggestions:function(e){return this.mapImp?this.mapImp.search(e):[]},onActionClick:function(e){RC.emit("onActionClick",e)}},props:{entry:{type:String,required:!0},uuid:String,biologicalSex:{type:String,default:""},minZoom:{type:Number,default:1},tooltips:{type:Boolean,default:!0},helpMode:{type:Boolean,default:!1},helpModeActiveItem:{type:Number,default:0},helpModeDialog:{type:Boolean,default:!1},helpModeLastItem:{type:Boolean,default:!1},helpModeInitialIndex:{type:Number,default:0},renderAtMounted:{type:Boolean,default:!0},displayMinimap:{type:Boolean,default:!1},displayWarning:{type:Boolean,default:!1},enableOpenMapUI:{type:Boolean,default:!1},openMapOptions:{type:Array,default:function(){return[{display:"Open AC Map",key:"AC"},{display:"Open FC Map",key:"FC"},{display:"Open 3D Human Map",key:"3D"}]}},showStarInLegend:{type:Boolean,default:!1},isLegacy:{type:Boolean,default:!1},displayLatestChanges:{type:Boolean,default:!1},state:{type:Object,default:void 0},mapManager:{type:Object,default:void 0},flatmapAPI:{type:String,default:"https://mapcore-demo.org/current/flatmap/v3/"},sparcAPI:{type:String,default:"https://api.sparc.science/"},disableUI:{type:Boolean,default:!1},connectivityInfoSidebar:{type:Boolean,default:!1},annotationSidebar:{type:Boolean,default:!1},showLocalSettings:{type:Boolean,default:!0},showOpenMapButton:{type:Boolean,default:!0},showPathwayFilter:{type:Boolean,default:!0}},provide(){return{flatmapAPI:this.flatmapAPI,sparcAPI:this.sparcAPI,userApiKey:this.userToken}},data:function(){return{sensor:null,mapManagerRef:void 0,flatmapQueries:void 0,annotationEntry:[],tooltipDisplay:!1,serverURL:void 0,layers:[],pathways:[],initMapState:L.markRaw({}),sckanDisplay:[{label:"Display Path with SCKAN",key:"VALID"}],systems:[],taxonConnectivity:[],pathwaysMaxHeight:1e3,tooltipWait:L.markRaw([]),hoverVisibilities:[{value:!1,ref:"markerPopover"},{value:!1,ref:"zoomInPopover"},{value:!1,ref:"zoomOutPopover"},{value:!1,ref:"zoomFitPopover"},{value:!1,ref:"openMapPopover"},{value:!1,ref:"settingsPopover"},{value:!1,ref:"checkBoxPopover"},{value:!1,ref:"warningPopover"},{value:!1,ref:"whatsNewPopover"},{value:!1,ref:"featuredMarkerPopover"},{value:!1,refs:"toolbarPopover",ref:"editPopover"},{value:!1,refs:"toolbarPopover",ref:"deletePopover"},{value:!1,refs:"toolbarPopover",ref:"pointPopover"},{value:!1,refs:"toolbarPopover",ref:"lineStringPopover"},{value:!1,refs:"toolbarPopover",ref:"polygonPopover"},{value:!1,refs:"toolbarPopover",ref:"connectionPopover"}],helpModeActiveIndex:this.helpModeInitialIndex,yellowstar:J1t,isFC:!1,inHelp:!1,currentBackground:"white",availableBackground:["white","lightskyblue","black"],loading:!1,flatmapMarker:G1t,tooltipEntry:[],connectivityDataSource:"",connectivityTooltipVisible:!1,drawerOpen:!1,flightPath3DRadio:!1,displayFlightPathOption:!1,colourRadio:!0,outlinesRadio:!0,minimapResizeShow:!1,minimapSmall:!1,currentActive:"",selectedDrawnFeature:void 0,currentHover:"",viewingMode:"Exploration",viewingModes:{Exploration:"Find relevant research and view detail of neural pathways by selecting a pathway to view its connections and data sources","Neuron Connection":"Discover Neuron connections by selecting a neuron and viewing its associated network connections",Annotation:["View feature annotations","Add, comment on and view feature annotations"]},offlineAnnotationEnabled:!1,offlineAnnotations:[],annotationFrom:"Anyone",annotatedSource:["Anyone","Me","Others"],openMapRef:void 0,backgroundIconRef:void 0,toolbarOptions:["Edit","Delete","Point","LineString","Polygon","Connection"],annotator:void 0,authorisedUser:void 0,activeDrawMode:void 0,activeDrawTool:void 0,featureAnnotationSubmitted:!1,drawnCreatedEvent:{},previousEditEvent:{},previousDeletedEvent:{},connectionEntry:{},existDrawnFeatures:[],doubleClickedFeature:!1,containsAlert:!1,alertOptions:[{label:"Display Path With Alerts",key:"alert",enabled:!0},{label:"Display Path Without Alerts",key:"withoutAlert",enabled:!0}],mapFilters:L.markRaw({alert:{with:!0,without:!0}}),searchTerm:"",taxonLeaveDelay:void 0}},computed:{...FH.mapState(xIt,["userToken"]),isValidDrawnCreated:function(){return Object.keys(this.drawnCreatedEvent).length>0},requiresDrawer:function(){var e,t,n;if(this.loading)return this.drawerOpen=!1,!1;if(this.isFC){if(((e=this.systems)==null?void 0:e.length)>0||this.containsAlert&&this.alertOptions||((t=this.pathways)==null?void 0:t.length)>0||((n=this.taxonConnectivity)==null?void 0:n.length)>0)return this.drawerOpen=!0,!0}else return this.drawerOpen=!0,!0;return this.drawerOpen=!1,!0},modeDescription:function(){let e=this.viewingModes[this.viewingMode];return this.viewingMode==="Annotation"?this.authorisedUser?e[1]:e[0]:e}},watch:{entry:function(){this.state||this.createFlatmap()},helpMode:function(e,t){e!==t&&this.setHelpMode(e)},helpModeActiveItem:function(){this.helpMode&&(this.helpModeActiveIndex+=1,this.setHelpMode(this.helpMode))},state:{handler:function(e,t){e!==t&&(this.mapManagerRef?this.setState(e):this.setStateRequired=!0)},immediate:!0,deep:!0},viewingMode:function(e){this.clearAnnotationFeature(),e==="Annotation"&&(this.loading=!0,this.annotator.authenticate(this.userToken).then(t=>{t.name&&t.email&&t.canUpdate?(this.authorisedUser=t,this.offlineAnnotationEnabled=!1):(this.authorisedUser=void 0,this.offlineAnnotationEnabled=!0),this.setFeatureAnnotated(),this.addAnnotationFeature(),this.loading=!1}))},disableUI:function(e){e&&this.closeTooltip()},activeDrawTool:function(e){let t=[],n={x:null,y:null};const r=this.$el.querySelector(".maplibregl-canvas"),i=()=>{r.removeEventListener("keydown",o),r.removeEventListener("click",a)},o=s=>{if(!["Escape","Enter"].includes(s.key))return;const u=e==="Point"&&t.length===1||e==="LineString"&&t.length>=2||e==="Polygon"&&t.length>=3;(s.key==="Escape"||s.key==="Enter"&&!u)&&(this.activeDrawTool=void 0),i()},a=s=>{const u=r.getBoundingClientRect(),h=s.clientX-u.left,d=s.clientY-u.top;if(Math.sqrt((h-n.x)**2+(d-n.y)**2)<8){this.isValidDrawnCreated||(this.activeDrawTool=void 0),i();return}n={x:h,y:d},t.push(n)};e&&(i(),r.addEventListener("keydown",o),r.addEventListener("click",a))}},created:function(){this.mapManager?this.mapManagerRef=this.mapManager:(this.mapManagerRef=L.markRaw(new VC(this.flatmapAPI,{container:void 0})),this.$emit("mapmanager-loaded",this.mapManagerRef))},mounted:function(){this.openMapRef=L.shallowRef(this.$refs.openMapRef),this.backgroundIconRef=L.shallowRef(this.$refs.backgroundIconRef),this.tooltipWait.length=this.hoverVisibilities.length,this.flatmapQueries=L.markRaw(new $1t),this.flatmapQueries.initialise(this.flatmapAPI),this.state?this.setStateRequired&&this.setState(this.state):this.renderAtMounted&&this.createFlatmap(),RP()}},SIt={class:"flatmap-container",ref:"flatmapContainer","element-loading-text":"Loading...","element-loading-background":"rgba(0, 0, 0, 0.3)"},AIt={style:{height:"100%",width:"100%",position:"relative","overflow-y":"none"}},CIt={style:{height:"100%",width:"100%"},ref:"display"},HIt={class:"beta-popovers"},OIt={key:2,class:"warning-text"},kIt={class:"bottom-right-control"},PIt=["innerHTML"],IIt=["innerHTML"],VIt={style:{"margin-bottom":"2px"}},RIt={key:0,class:"viewing-mode-title"},NIt=["onClick"],DIt=["onClick"];function BIt(e,t,n,r,i,o){const a=L.resolveComponent("map-svg-sprite-color"),s=Fi.WarningFilled,u=P2,h=QT,d=Fi.ArrowDown,Q=L.resolveComponent("DrawToolbar"),m=L.resolveComponent("map-svg-icon"),_=VP,x=L.resolveComponent("tree-controls"),w=IP,H=Fi.ArrowLeft,S=lP,P=sh,V=ah,B=Ax,U=TT,W=xP,X=LP,nt=L.resolveComponent("Tooltip"),st=OP,Tt=Hx;return L.withDirectives((L.openBlock(),L.createElementBlock("div",SIt,[L.createVNode(a),L.createElementVNode("div",AIt,[L.createElementVNode("div",CIt,null,512),L.withDirectives(L.createElementVNode("div",HIt,[L.createElementVNode("div",null,[L.createVNode(h,{placement:"right","popper-class":"warning-popper flatmap-popper",teleported:!1,visible:e.hoverVisibilities[7].value,ref:"warningPopover"},{reference:L.withCtx(()=>[L.createElementVNode("div",{class:"warning-icon",onMouseover:t[7]||(t[7]=dt=>o.showTooltip(7)),onMouseout:t[8]||(t[8]=dt=>o.hideTooltip(7))},[n.displayWarning||n.isLegacy?(L.openBlock(),L.createBlock(u,{key:0},{default:L.withCtx(()=>[L.createVNode(s)]),_:1})):L.createCommentVNode("",!0),n.isLegacy?(L.openBlock(),L.createElementBlock(L.Fragment,{key:1},[t[33]||(t[33]=L.createElementVNode("span",{class:"warning-text"},"Legacy Map",-1)),L.createElementVNode("div",{class:"latest-map-text",onClick:t[6]||(t[6]=(...dt)=>o.viewLatestMap&&o.viewLatestMap(...dt))}," Click here for the latest map ")],64)):n.displayWarning?(L.openBlock(),L.createElementBlock("span",OIt,"Beta")):L.createCommentVNode("",!0)],32)]),default:L.withCtx(()=>[n.isLegacy?(L.openBlock(),L.createElementBlock("p",{key:0,onMouseover:t[0]||(t[0]=dt=>o.showTooltip(7)),onMouseout:t[1]||(t[1]=dt=>o.hideTooltip(7))}," This is a legacy map, you may view the latest map instead. ",32)):e.isFC?(L.openBlock(),L.createElementBlock("p",{key:1,onMouseover:t[2]||(t[2]=dt=>o.showTooltip(7)),onMouseout:t[3]||(t[3]=dt=>o.hideTooltip(7))},t[31]||(t[31]=[L.createTextVNode(" This map displays the connectivity of individual neurons. Specifically, those which align with (parts of) the neuron populations from the "),L.createElementVNode("a",{href:"https://sparc.science/resources/1ZUKXU2YmLcn2reCyXjlew",target:"_blank"}," ApiNATOMY ",-1),L.createTextVNode(" models available in "),L.createElementVNode("a",{href:"https://sparc.science/resources/6eg3VpJbwQR4B84CjrvmyD",target:"_blank"}," SCKAN ",-1),L.createTextVNode(". ")]),32)):(L.openBlock(),L.createElementBlock("p",{key:2,onMouseover:t[4]||(t[4]=dt=>o.showTooltip(7)),onMouseout:t[5]||(t[5]=dt=>o.hideTooltip(7))},t[32]||(t[32]=[L.createTextVNode(" This map displays the connectivity of neuron populations. Specifically, those from the primarily rat-based "),L.createElementVNode("a",{href:"https://sparc.science/resources/1ZUKXU2YmLcn2reCyXjlew",target:"_blank"}," ApiNATOMY ",-1),L.createTextVNode(" models available in "),L.createElementVNode("a",{href:"https://sparc.science/resources/6eg3VpJbwQR4B84CjrvmyD",target:"_blank"}," SCKAN ",-1),L.createTextVNode(". New connectivity and species specificity will be added as the SPARC program progresses. ")]),32))]),_:1},8,["visible"])]),n.displayLatestChanges?(L.openBlock(),L.createBlock(h,{key:0,placement:"right",teleported:!1,trigger:"manual","popper-class":"warning-popper flatmap-popper",visible:e.hoverVisibilities[8].value,ref:"whatsNewPopover"},{reference:L.withCtx(()=>[n.displayLatestChanges?(L.openBlock(),L.createElementBlock("div",{key:0,class:"latest-changesicon",onMouseover:t[9]||(t[9]=dt=>o.showTooltip(8)),onMouseout:t[10]||(t[10]=dt=>o.hideTooltip(8))},[L.createVNode(u,null,{default:L.withCtx(()=>[L.createVNode(s)]),_:1}),t[34]||(t[34]=L.createElementVNode("span",{class:"warning-text"},"What's new?",-1))],32)):L.createCommentVNode("",!0)]),default:L.withCtx(()=>t[35]||(t[35]=[L.createElementVNode("b",null,"Connectivity References",-1),L.createElementVNode("p",null," Connectivity references have been improved and available in various formats. ",-1),L.createElementVNode("b",null,"Improved state storing",-1),L.createElementVNode("p",null," Current selection and visibility filters are now stored when creating a permalink. ",-1)])),_:1},8,["visible"])):L.createCommentVNode("",!0)],512),[[L.vShow,!n.disableUI]]),L.withDirectives(L.createVNode(u,{class:L.normalizeClass(["minimap-resize",{enlarge:e.minimapSmall,shrink:!e.minimapSmall}]),ref:"minimapResize",onClick:o.closeMinimap},{default:L.withCtx(()=>[L.createVNode(d)]),_:1},8,["class","onClick"]),[[L.vShow,e.minimapResizeShow]]),e.viewingMode==="Annotation"&&(e.authorisedUser||e.offlineAnnotationEnabled)&&!n.disableUI?(L.openBlock(),L.createBlock(Q,{key:0,mapCanvas:{containerHTML:this.$el,class:".maplibregl-canvas"},toolbarOptions:e.toolbarOptions,activeDrawTool:e.activeDrawTool,activeDrawMode:e.activeDrawMode,newlyDrawnEntry:e.drawnCreatedEvent,connectionEntry:e.connectionEntry,hoverVisibilities:e.hoverVisibilities,onClickToolbar:o.toolbarEvent,onFeatureTooltip:o.connectedFeatureTooltip,onConfirmDrawn:o.confirmDrawnFeature,onCancelDrawn:o.cancelDrawnFeature,onShowTooltip:o.showTooltip,onHideTooltip:o.hideTooltip,ref:"toolbarPopover"},null,8,["mapCanvas","toolbarOptions","activeDrawTool","activeDrawMode","newlyDrawnEntry","connectionEntry","hoverVisibilities","onClickToolbar","onFeatureTooltip","onConfirmDrawn","onCancelDrawn","onShowTooltip","onHideTooltip"])):L.createCommentVNode("",!0),L.withDirectives(L.createElementVNode("div",kIt,[L.createVNode(h,{content:"Zoom in",placement:"left",teleported:!1,trigger:"manual",width:"70","popper-class":"flatmap-popper",visible:e.hoverVisibilities[1].value,ref:"zoomInPopover"},{reference:L.withCtx(()=>[L.createElementVNode("div",{class:"icon-button-container",onClick:t[11]||(t[11]=dt=>o.zoomIn()),onMouseover:t[12]||(t[12]=dt=>o.showTooltip(1)),onMouseout:t[13]||(t[13]=dt=>o.hideTooltip(1))},[L.createVNode(m,{class:"icon-button zoomIn",icon:"zoomIn"})],32)]),_:1},8,["visible"]),L.createVNode(h,{content:"Zoom out",placement:"top-end",teleported:!1,trigger:"manual",width:"70","popper-class":"flatmap-popper",visible:e.hoverVisibilities[2].value,ref:"zoomOutPopover"},{reference:L.withCtx(()=>[L.createElementVNode("div",{class:"icon-button-container",onClick:t[14]||(t[14]=dt=>o.zoomOut()),onMouseover:t[15]||(t[15]=dt=>o.showTooltip(2)),onMouseout:t[16]||(t[16]=dt=>o.hideTooltip(2))},[L.createVNode(m,{class:"icon-button zoomOut",icon:"zoomOut"})],32)]),_:1},8,["visible"]),L.createVNode(h,{content:"Reset",placement:"top",teleported:!1,trigger:"manual",width:"70","popper-class":"flatmap-popper",visible:e.hoverVisibilities[3].value,ref:"zoomFitPopover"},{reference:L.withCtx(()=>[L.createElementVNode("div",{class:"icon-button-container",onClick:t[17]||(t[17]=dt=>o.resetView()),onMouseover:t[18]||(t[18]=dt=>o.showTooltip(3)),onMouseout:t[19]||(t[19]=dt=>o.hideTooltip(3))},[L.createVNode(m,{class:"icon-button fitWindow",icon:"fitWindow"})],32)]),default:L.withCtx(()=>[t[36]||(t[36]=L.createElementVNode("div",null,[L.createTextVNode(" Fit to "),L.createElementVNode("br"),L.createTextVNode(" window ")],-1))]),_:1},8,["visible"])],512),[[L.vShow,!n.disableUI]]),L.createVNode(h,{content:"Change pathway visibility",placement:"right",teleported:!1,trigger:"manual",offset:-18,"popper-class":"flatmap-popper",visible:e.hoverVisibilities[6].value,ref:"checkBoxPopover"},{reference:L.withCtx(()=>[L.withDirectives(L.createElementVNode("div",{class:L.normalizeClass(["pathway-location",{open:e.drawerOpen,close:!e.drawerOpen}])},[L.withDirectives((L.openBlock(),L.createElementBlock("div",{class:L.normalizeClass(["pathway-container",{open:e.drawerOpen,close:!e.drawerOpen}]),style:L.normalizeStyle({"max-height":e.pathwaysMaxHeight+"px"})},[e.isFC?L.createCommentVNode("",!0):(L.openBlock(),L.createBlock(_,{key:0,class:"svg-legends-container"})),n.showStarInLegend?(L.openBlock(),L.createBlock(h,{key:1,content:"Location of the featured dataset",placement:"right",teleported:!0,trigger:"manual",width:"max-content",offset:-10,"popper-class":"flatmap-popper flatmap-teleport-popper",visible:e.hoverVisibilities[9].value,ref:"featuredMarkerPopover"},{reference:L.withCtx(()=>[L.withDirectives(L.createElementVNode("div",{class:"yellow-star-legend",innerHTML:e.yellowstar,onMouseover:t[20]||(t[20]=dt=>o.showTooltip(9)),onMouseout:t[21]||(t[21]=dt=>o.hideTooltip(9))},null,40,PIt),[[st,void 0,"featuredMarkerPopover"]])]),_:1},8,["visible"])):L.createCommentVNode("",!0),L.createVNode(h,{content:"Find these markers for data. The number inside the markers is the number of datasets available for each marker.",placement:"right",teleported:!1,width:"200",trigger:"manual","popper-class":"flatmap-popper flatmap-marker-popper",visible:e.hoverVisibilities[0].value,ref:"markerPopover"},{reference:L.withCtx(()=>[L.withDirectives(L.createElementVNode("div",{class:"flatmap-marker-help",innerHTML:e.flatmapMarker},null,8,IIt),[[L.vShow,e.hoverVisibilities[0].value],[st,void 0,"markerPopover"]])]),_:1},8,["visible"]),e.isFC&&e.systems&&e.systems.length>0?(L.openBlock(),L.createBlock(x,{key:2,class:"treeControls",mapType:"flatmap",title:"Systems",treeData:e.systems,active:e.currentActive,hover:e.currentHover,onCheckChanged:o.systemSelected,onCheckAll:o.checkAllSystems,onChangeActive:o.ftuSelected,ref:"treeControls"},null,8,["treeData","active","hover","onCheckChanged","onCheckAll","onChangeActive"])):L.createCommentVNode("",!0),e.containsAlert&&e.alertOptions&&n.showPathwayFilter?(L.openBlock(),L.createBlock(w,{title:"Alert",labelKey:"label",identifierKey:"key",selections:e.alertOptions,onChanged:o.alertSelected,onCheckboxMouseEnter:o.alertMouseEnterEmitted,onSelectionsDataChanged:o.onSelectionsDataChanged,onCheckAll:o.checkAllAlerts,ref:"alertSelection",key:"alertSelection"},null,8,["selections","onChanged","onCheckboxMouseEnter","onSelectionsDataChanged","onCheckAll"])):L.createCommentVNode("",!0),e.pathways&&e.pathways.length>0&n.showPathwayFilter?(L.openBlock(),L.createBlock(w,{title:"Pathways",labelKey:"label",identifierKey:"type",colourStyle:"line",selections:e.pathways,onChanged:o.pathwaysSelected,onSelectionsDataChanged:o.onSelectionsDataChanged,onCheckAll:o.checkAllPathways,ref:"pathwaysSelection",key:"pathwaysSelection"},null,8,["selections","onChanged","onSelectionsDataChanged","onCheckAll"])):L.createCommentVNode("",!0),e.taxonConnectivity&&e.taxonConnectivity.length>0&&n.showPathwayFilter?(L.openBlock(),L.createBlock(w,{title:"Studied in",labelKey:"label",identifierKey:"taxon",helpMessage:"Evidence exists that this set of neuron populations have been studied in the given species.",selections:e.taxonConnectivity,onChanged:o.taxonsSelected,onCheckboxMouseEnter:o.taxonMouseEnterEmitted,onSelectionsDataChanged:o.onSelectionsDataChanged,onCheckAll:o.checkAllTaxons,ref:"taxonSelection",key:"taxonSelection"},null,8,["selections","onChanged","onCheckboxMouseEnter","onSelectionsDataChanged","onCheckAll"])):L.createCommentVNode("",!0)],6)),[[st,void 0,"checkBoxPopover"]]),L.createElementVNode("div",{onClick:t[22]||(t[22]=(...dt)=>o.toggleDrawer&&o.toggleDrawer(...dt)),class:L.normalizeClass(["drawer-button",{open:e.drawerOpen,close:!e.drawerOpen}])},[L.createVNode(u,null,{default:L.withCtx(()=>[L.createVNode(H)]),_:1})],2)],2),[[L.vShow,!n.disableUI&&o.requiresDrawer]])]),_:1},8,["visible"]),e.openMapRef?(L.openBlock(),L.createBlock(h,{key:1,ref:"open-map-popover","virtual-ref":e.openMapRef,placement:"top-start",width:"136",teleported:!1,trigger:"click","popper-class":"open-map-popper non-selectable","virtual-triggering":""},{default:L.withCtx(()=>[(L.openBlock(!0),L.createElementBlock(L.Fragment,null,L.renderList(n.openMapOptions,dt=>(L.openBlock(),L.createBlock(P,{key:dt.key},{default:L.withCtx(()=>[L.createVNode(S,{type:"primary",plain:"",onClick:At=>e.$emit("open-map",dt.key)},{default:L.withCtx(()=>[L.createTextVNode(L.toDisplayString(dt.display),1)]),_:2},1032,["onClick"])]),_:2},1024))),128))]),_:1},8,["virtual-ref"])):L.createCommentVNode("",!0),L.createVNode(h,{ref:"backgroundPopover","virtual-ref":e.backgroundIconRef,placement:"top-start",width:"320",teleported:!1,trigger:"click","popper-class":"background-popper h-auto","virtual-triggering":""},{default:L.withCtx(()=>[L.createElementVNode("div",null,[L.createVNode(P,{class:"backgroundText"},{default:L.withCtx(()=>t[37]||(t[37]=[L.createTextVNode("Viewing Mode")])),_:1}),L.createVNode(P,{class:"backgroundControl"},{default:L.withCtx(()=>[L.createElementVNode("div",VIt,[(L.openBlock(!0),L.createElementBlock(L.Fragment,null,L.renderList(e.viewingModes,(dt,At,Zt)=>(L.openBlock(),L.createElementBlock(L.Fragment,{key:At},[At===e.viewingMode?(L.openBlock(),L.createElementBlock("span",RIt,[L.createElementVNode("b",null,L.toDisplayString(At),1)])):(L.openBlock(),L.createElementBlock("span",{key:1,class:"viewing-mode-unselected",onClick:ce=>o.changeViewingMode(At)},L.toDisplayString(At),9,NIt))],64))),128))]),L.createVNode(P,{class:"viewing-mode-description"},{default:L.withCtx(()=>[L.createTextVNode(L.toDisplayString(o.modeDescription),1)]),_:1}),e.viewingMode==="Annotation"&&e.offlineAnnotationEnabled?(L.openBlock(),L.createBlock(P,{key:0,class:"viewing-mode-description"},{default:L.withCtx(()=>t[38]||(t[38]=[L.createTextVNode(" (Anonymous annotate) ")])),_:1})):L.createCommentVNode("",!0)]),_:1}),e.viewingMode==="Annotation"&&e.authorisedUser?(L.openBlock(),L.createElementBlock(L.Fragment,{key:0},[L.createVNode(P,{class:"backgroundText"},{default:L.withCtx(()=>t[39]||(t[39]=[L.createTextVNode("Annotations From")])),_:1}),L.createVNode(P,{class:"backgroundControl"},{default:L.withCtx(()=>[L.createVNode(U,{teleported:!1,modelValue:e.annotationFrom,"onUpdate:modelValue":t[23]||(t[23]=dt=>e.annotationFrom=dt),placeholder:"Select",class:"select-box","popper-class":"flatmap_dropdown",onChange:o.setAnnotationFrom},{default:L.withCtx(()=>[(L.openBlock(!0),L.createElementBlock(L.Fragment,null,L.renderList(e.annotatedSource,dt=>(L.openBlock(),L.createBlock(B,{key:dt,label:dt,value:dt},{default:L.withCtx(()=>[L.createVNode(P,null,{default:L.withCtx(()=>[L.createVNode(V,{span:12},{default:L.withCtx(()=>[L.createTextVNode(L.toDisplayString(dt),1)]),_:2},1024)]),_:2},1024)]),_:2},1032,["label","value"]))),128))]),_:1},8,["modelValue","onChange"])]),_:1})],64)):L.createCommentVNode("",!0),e.displayFlightPathOption?(L.openBlock(),L.createBlock(P,{key:1,class:"backgroundSpacer"})):L.createCommentVNode("",!0),e.displayFlightPathOption?(L.openBlock(),L.createBlock(P,{key:2,class:"backgroundText"},{default:L.withCtx(()=>t[40]||(t[40]=[L.createTextVNode("Flight path display")])),_:1})):L.createCommentVNode("",!0),e.displayFlightPathOption?(L.openBlock(),L.createBlock(P,{key:3,class:"backgroundControl"},{default:L.withCtx(()=>[L.createVNode(X,{modelValue:e.flightPath3DRadio,"onUpdate:modelValue":t[24]||(t[24]=dt=>e.flightPath3DRadio=dt),class:"flatmap-radio",onChange:o.setFlightPath3D},{default:L.withCtx(()=>[L.createVNode(W,{value:!1},{default:L.withCtx(()=>t[41]||(t[41]=[L.createTextVNode("2D")])),_:1}),L.createVNode(W,{value:!0},{default:L.withCtx(()=>t[42]||(t[42]=[L.createTextVNode("3D")])),_:1})]),_:1},8,["modelValue","onChange"])]),_:1})):L.createCommentVNode("",!0),L.createVNode(P,{class:"backgroundSpacer"}),L.createVNode(P,{class:"backgroundText"},{default:L.withCtx(()=>t[43]||(t[43]=[L.createTextVNode("Organs display")])),_:1}),L.createVNode(P,{class:"backgroundControl"},{default:L.withCtx(()=>[L.createVNode(X,{modelValue:e.colourRadio,"onUpdate:modelValue":t[25]||(t[25]=dt=>e.colourRadio=dt),class:"flatmap-radio",onChange:o.setColour},{default:L.withCtx(()=>[L.createVNode(W,{value:!0},{default:L.withCtx(()=>t[44]||(t[44]=[L.createTextVNode("Colour")])),_:1}),L.createVNode(W,{value:!1},{default:L.withCtx(()=>t[45]||(t[45]=[L.createTextVNode("Greyscale")])),_:1})]),_:1},8,["modelValue","onChange"])]),_:1}),L.createVNode(P,{class:"backgroundSpacer"}),L.createVNode(P,{class:"backgroundText"},{default:L.withCtx(()=>t[46]||(t[46]=[L.createTextVNode("Outlines display")])),_:1}),L.createVNode(P,{class:"backgroundControl"},{default:L.withCtx(()=>[L.createVNode(X,{modelValue:e.outlinesRadio,"onUpdate:modelValue":t[26]||(t[26]=dt=>e.outlinesRadio=dt),class:"flatmap-radio",onChange:o.setOutlines},{default:L.withCtx(()=>[L.createVNode(W,{value:!0},{default:L.withCtx(()=>t[47]||(t[47]=[L.createTextVNode("Show")])),_:1}),L.createVNode(W,{value:!1},{default:L.withCtx(()=>t[48]||(t[48]=[L.createTextVNode("Hide")])),_:1})]),_:1},8,["modelValue","onChange"])]),_:1}),L.createVNode(P,{class:"backgroundSpacer"}),L.createVNode(P,{class:"backgroundText"},{default:L.withCtx(()=>t[49]||(t[49]=[L.createTextVNode("Change background")])),_:1}),L.createVNode(P,{class:"backgroundControl"},{default:L.withCtx(()=>[(L.openBlock(!0),L.createElementBlock(L.Fragment,null,L.renderList(e.availableBackground,dt=>(L.openBlock(),L.createElementBlock("div",{key:dt,class:L.normalizeClass(["backgroundChoice",dt,dt==e.currentBackground?"active":""]),onClick:At=>o.backgroundChangeCallback(dt)},null,10,DIt))),128))]),_:1})])]),_:1},8,["virtual-ref"]),L.withDirectives(L.createElementVNode("div",{class:L.normalizeClass(["settings-group",{open:e.drawerOpen,close:!e.drawerOpen}])},[n.showOpenMapButton?(L.openBlock(),L.createBlock(P,{key:0},{default:L.withCtx(()=>[L.createVNode(h,{visible:e.hoverVisibilities[4].value,content:"Open new map",placement:"right",teleported:!1,"popper-class":"flatmap-popper",ref:"openMapPopover"},{reference:L.withCtx(()=>[n.enableOpenMapUI&&n.openMapOptions.length>0?(L.openBlock(),L.createElementBlock("div",{key:0,ref:"openMapRef",class:"icon-button-container",onMouseover:t[27]||(t[27]=dt=>o.showTooltip(4)),onMouseout:t[28]||(t[28]=dt=>o.hideTooltip(4))},[L.createVNode(m,{icon:"openMap",class:"icon-button open-map-button"})],544)):L.createCommentVNode("",!0)]),_:1},8,["visible"])]),_:1})):L.createCommentVNode("",!0),n.showLocalSettings?(L.openBlock(),L.createBlock(P,{key:1},{default:L.withCtx(()=>[L.createVNode(h,{content:"Change settings",placement:"right",visible:e.hoverVisibilities[5].value,teleported:!1,trigger:"manual","popper-class":"flatmap-popper",ref:"settingsPopover"},{reference:L.withCtx(()=>[L.createElementVNode("div",{ref:"backgroundIconRef",class:"icon-button-container",onMouseover:t[29]||(t[29]=dt=>o.showTooltip(5)),onMouseout:t[30]||(t[30]=dt=>o.hideTooltip(5))},[L.createVNode(m,{icon:"changeBckgd",class:"icon-button"})],544)]),_:1},8,["visible"])]),_:1})):L.createCommentVNode("",!0)],2),[[L.vShow,!n.disableUI]]),e.tooltipDisplay?(L.openBlock(),L.createBlock(nt,{key:2,ref:"tooltip",class:"tooltip",annotationEntry:e.annotationEntry,tooltipEntry:e.tooltipEntry,annotationDisplay:e.viewingMode==="Annotation",onAnnotation:o.commitAnnotationEvent,onOnActionClick:o.onActionClick},null,8,["annotationEntry","tooltipEntry","annotationDisplay","onAnnotation","onOnActionClick"])):L.createCommentVNode("",!0)])])),[[Tt,e.loading]])}const NC=yT(EIt,[["render",BIt],["__scopeId","data-v-a05c1762"]]),oq={"NCBITaxon:10114":"01fedbf9-d783-509c-a10c-827941ab13da","NCBITaxon:9823":"a336ac04-24db-561f-a25f-1c994fe17410","NCBITaxon:9606":"42ed6323-f645-5fbe-bada-9581819cf689","NCBITaxon:10090":"25285fab-48a0-5620-a6a0-f9a0374837d5","NCBITaxon:9685":"73060497-46a6-52bf-b975-cac511c127cb"},FIt={name:"MultiFlatmapVuer",components:{Col:ah,Row:sh,Option:Ax,Select:TT,Popover:QT,FlatmapVuer:NC},created:function(){this.loadMapManager()},mounted:function(){this.initialise(),RC.on("onActionClick",e=>{this.resourceSelected(e)}),RC.on("open-pubmed-url",e=>{this.$emit("open-pubmed-url",e)})},methods:{initialise:function(){return new Promise(e=>{this.requireInitialisation?(this.requireInitialisation=!1,fetch(this.flatmapAPI).then(t=>t.json()).then(t=>{Object.keys(this.availableSpecies).forEach(r=>{const i=this.availableSpecies[r].uuid;if(i&&t.map(o=>o.uuid).indexOf(i)>0)this.speciesList[r]=this.availableSpecies[r];else for(let o=0;o<t.length;o++)if(this.availableSpecies[r].taxo===t[o].taxon)if(this.availableSpecies[r].biologicalSex){if(t[o].biologicalSex&&t[o].biologicalSex===this.availableSpecies[r].biologicalSex){this.speciesList[r]=this.availableSpecies[r];break}}else{this.speciesList[r]=this.availableSpecies[r];break}});let n=this.initial;if(this.state){const r=this.state.state;(!r||!r.uuid&&!r.entry)&&this.state.species?n=this.state.species:n=void 0}n&&(n&&this.speciesList[n]!==void 0?this.activeSpecies=n:this.activeSpecies=Object.keys(this.speciesList)[0],this.setSpecies(this.activeSpecies,this.state?this.state.state:void 0,5)),this.initialised=!0,e(),this.resolveList.forEach(r=>{r()})})):this.initialised?e():this.resolveList.push(e)})},loadMapManager:function(){this.mapManagerRef||(this.mapManager?this.mapManagerRef=this.mapManager:(this.mapManagerRef=L.markRaw(new VC(this.flatmapAPI,{container:void 0})),this.$emit("mapmanager-loaded",this.mapManagerRef)))},resourceSelected:function(e){this.$emit("resource-selected",e)},FlatmapReady:function(e){this.$emit("ready",e)},getCurrentFlatmap:function(){return this.$refs[this.activeSpecies][0]},panZoomCallback:function(e){this.$emit("pan-zoom-callback",e)},onAnnotationClose:function(){this.$emit("annotation-close")},onAnnotationOpen:function(e){this.$emit("annotation-open",e)},onConnectivityInfoClose:function(){this.$emit("connectivity-info-close")},onConnectivityInfoOpen:function(e){this.$emit("connectivity-info-open",e)},onConnectivityError:function(e){this.$emit("connectivity-error",e)},onSelectionsDataChanged:function(e){this.$emit("pathway-selection-changed",e)},showPopup:function(e,t,n){this.getCurrentFlatmap().showPopup(e,t,n)},showMarkerPopup:function(e,t,n){this.getCurrentFlatmap().showMarkerPopup(e,t,n)},setSpecies:function(e,t,n){if(this.$refs&&e in this.$refs)this.activeSpecies=e,this.$refs[this.activeSpecies][0].createFlatmap(t),this.$emit("flatmapChanged",this.activeSpecies);else if(n){const r=n-1;r>=0&&this.$nextTick(()=>{this.setSpecies(e,t,r)})}},viewLatestMap:function(e){const t=Object.keys(this.speciesList);for(let n=0;n<t.length;n++){const r=this.speciesList[t[n]];if(!r.isLegacy&&r.taxo===e.entry&&r.biologicalSex===e.biologicalSex){this.setSpecies(t[n],e,0);return}}},createLegacyEntry:function(e,t,n){if(n&&t){let r="Legacy";return e.species&&(e.species.slice(0,6)==="Legacy"?r=e.species:r=r+` ${e.species}`),this.speciesList[r]={taxo:t,isLegacy:!0,displayWarning:!0},{species:r,state:{entry:t,uuid:n,viewport:e.state.viewport,searchTerm:e.state.searchTerm}}}},updateState:function(e){return new Promise(t=>{if(e&&e.state){const n=e.state;if(n.uuid){if(n.entry)return new Promise(()=>{const r={taxon:n.entry};n.biologicalSex&&(r.biologicalSex=n.biologicalSex),this.mapManagerRef.findMap(r).then(i=>{if(i.uuid!==n.uuid)return this.createLegacyEntry(e,n.entry,n.uuid)}).then(i=>{t(i||e)}).catch(()=>{t(e)})})}else if(n.entry){const r=n.entry in oq?oq[n.entry]:void 0,i=this.createLegacyEntry(e,n.entry,r);t(i||e)}}t(e)})},getState:function(){let e={species:this.activeSpecies,state:void 0},t=this.getCurrentFlatmap();return e.state=t.getState(),e},setState:function(e){e&&(this.loadMapManager(),this.updateState(e).then(t=>{this.initialise().then(()=>{t.species&&t.species!==this.activeSpecies?this.setSpecies(t.species,t.state,5):t.state&&this.getCurrentFlatmap().setState(t.state)})}))},activateTooltipByIndex:function(e){return e===this.helpModeActiveItem&&this.helpMode},onHelpModeLastItem:function(e){e&&this.$emit("help-mode-last-item",!0)},onTooltipShown:function(){this.$emit("shown-tooltip")},onMapTooltipShown:function(){this.$emit("shown-map-tooltip")},changeViewingMode:function(e){this.getCurrentFlatmap().changeViewingMode(e)}},props:{initial:{type:String,default:""},minZoom:{type:Number,default:1},renderAtMounted:{type:Boolean,default:!1},helpMode:{type:Boolean,default:!1},helpModeActiveItem:{type:Number,default:0},helpModeDialog:{type:Boolean,default:!1},helpModeLastItem:{type:Boolean,default:!1},displayMinimap:{type:Boolean,default:!1},showStarInLegend:{type:Boolean,default:!1},enableOpenMapUI:{type:Boolean,default:!1},openMapOptions:{type:Array},availableSpecies:{type:Object,default:function(){return{"Human Female":{taxo:"NCBITaxon:9606",biologicalSex:"PATO:0000383",iconClass:"mapicon-icon_human",displayWarning:!0},"Human Male":{taxo:"NCBITaxon:9606",biologicalSex:"PATO:0000384",iconClass:"mapicon-icon_human",displayWarning:!0},Rat:{taxo:"NCBITaxon:10114",iconClass:"mapicon-icon_rat",displayLatestChanges:!0},Mouse:{taxo:"NCBITaxon:10090",iconClass:"mapicon-icon_mouse",displayWarning:!0},Pig:{taxo:"NCBITaxon:9823",iconClass:"mapicon-icon_pig",displayWarning:!0},Cat:{taxo:"NCBITaxon:9685",iconClass:"mapicon-icon_cat",displayWarning:!0}}}},state:{type:Object,default:void 0},mapManager:{type:Object,default:void 0},flatmapAPI:{type:String,default:"https://mapcore-demo.org/current/flatmap/v3/"},sparcAPI:{type:String,default:"https://api.sparc.science/"},disableUI:{type:Boolean,default:!1},connectivityInfoSidebar:{type:Boolean,default:!1},annotationSidebar:{type:Boolean,default:!1},showLocalSettings:{type:Boolean,default:!0},showOpenMapButton:{type:Boolean,default:!0},showPathwayFilter:{type:Boolean,default:!0}},data:function(){return{activeSpecies:void 0,speciesList:{},requireInitialisation:!0,resolveList:L.markRaw([]),initialised:!1,mapManagerRef:void 0}},watch:{state:{handler:function(e){this.setState(e)},immediate:!0,deep:!0}}},jIt={class:"multi-container",ref:"multiContainer"},zIt={key:0,style:{position:"absolute","z-index":"100"}},UIt={class:"select-box-icon"};function GIt(e,t,n,r,i,o){const a=Ax,s=TT,u=QT,h=NC;return L.openBlock(),L.createElementBlock("div",jIt,[n.disableUI?L.createCommentVNode("",!0):(L.openBlock(),L.createElementBlock("div",zIt,[t[2]||(t[2]=L.createElementVNode("div",{class:"species-display-text"},"Species",-1)),L.createVNode(u,{content:"Select a species",placement:"right",trigger:"manual","popper-class":"flatmap-popper flatmap-teleport-popper right-popper",width:"max-content",visible:o.activateTooltipByIndex(0),teleported:!1,ref:"selectPopover"},{reference:L.withCtx(()=>[L.createVNode(s,{id:"flatmap-select",teleported:!1,modelValue:e.activeSpecies,"onUpdate:modelValue":t[0]||(t[0]=d=>e.activeSpecies=d),placeholder:"Select",class:"select-box","popper-class":"flatmap-dropdown",onChange:o.setSpecies},{default:L.withCtx(()=>[(L.openBlock(!0),L.createElementBlock(L.Fragment,null,L.renderList(e.speciesList,(d,Q)=>(L.openBlock(),L.createBlock(a,{key:Q,label:Q,value:Q},{default:L.withCtx(()=>[L.createElementVNode("span",UIt,[L.createElementVNode("i",{class:L.normalizeClass(d.iconClass)},null,2)]),L.createTextVNode(" "+L.toDisplayString(Q),1)]),_:2},1032,["label","value"]))),128))]),_:1},8,["modelValue","onChange"])]),_:1},8,["visible"])])),(L.openBlock(!0),L.createElementBlock(L.Fragment,null,L.renderList(e.speciesList,(d,Q)=>L.withDirectives((L.openBlock(),L.createBlock(h,{key:Q,entry:d.taxo,uuid:d.uuid,biologicalSex:d.biologicalSex,displayWarning:d.displayWarning,displayLatestChanges:d.displayLatestChanges,isLegacy:d.isLegacy,ref_for:!0,ref:Q,enableOpenMapUI:n.enableOpenMapUI,openMapOptions:n.openMapOptions,disableUI:n.disableUI,onViewLatestMap:o.viewLatestMap,onResourceSelected:o.resourceSelected,onReady:o.FlatmapReady,onPanZoomCallback:o.panZoomCallback,annotationSidebar:n.annotationSidebar,onAnnotationOpen:o.onAnnotationOpen,onAnnotationClose:o.onAnnotationClose,connectivityInfoSidebar:n.connectivityInfoSidebar,onConnectivityInfoOpen:o.onConnectivityInfoOpen,onConnectivityInfoClose:o.onConnectivityInfoClose,onConnectivityError:o.onConnectivityError,onOpenMap:t[1]||(t[1]=m=>e.$emit("open-map",m)),onPathwaySelectionChanged:o.onSelectionsDataChanged,minZoom:n.minZoom,helpMode:e.activeSpecies==Q&&n.helpMode,helpModeActiveItem:n.helpModeActiveItem,helpModeDialog:n.helpModeDialog,helpModeInitialIndex:-2,onHelpModeLastItem:o.onHelpModeLastItem,onShownTooltip:o.onTooltipShown,onShownMapTooltip:o.onMapTooltipShown,renderAtMounted:n.renderAtMounted,displayMinimap:n.displayMinimap,showStarInLegend:n.showStarInLegend,style:{height:"100%"},mapManager:e.mapManagerRef,flatmapAPI:n.flatmapAPI,sparcAPI:n.sparcAPI,showLocalSettings:n.showLocalSettings,showOpenMapButton:n.showOpenMapButton,showPathwayFilter:n.showPathwayFilter},null,8,["entry","uuid","biologicalSex","displayWarning","displayLatestChanges","isLegacy","enableOpenMapUI","openMapOptions","disableUI","onViewLatestMap","onResourceSelected","onReady","onPanZoomCallback","annotationSidebar","onAnnotationOpen","onAnnotationClose","connectivityInfoSidebar","onConnectivityInfoOpen","onConnectivityInfoClose","onConnectivityError","onPathwaySelectionChanged","minZoom","helpMode","helpModeActiveItem","helpModeDialog","onHelpModeLastItem","onShownTooltip","onShownMapTooltip","renderAtMounted","displayMinimap","showStarInLegend","mapManager","flatmapAPI","sparcAPI","showLocalSettings","showOpenMapButton","showPathwayFilter"])),[[L.vShow,e.activeSpecies==Q]])),128))],512)}const $It=yT(FIt,[["render",GIt],["__scopeId","data-v-32137bc4"]]);Bi.FlatmapVuer=NC,Bi.MultiFlatmapVuer=$It,Object.defineProperty(Bi,Symbol.toStringTag,{value:"Module"})});
2382
+ order by node, path, source desc`,[C(this,v3),...i.values()]);return[...new Pa(o.map(a=>a[0])).values()]}return[]}addCloseControl(){C(this,Ee)!==null&&C(this,Ee).addCloseControl()}removeCloseControl(){C(this,Ee)!==null&&C(this,Ee).removeCloseControl()}}Op=new WeakMap,kp=new WeakMap,Pp=new WeakMap,Cs=new WeakMap,Ip=new WeakMap,Vp=new WeakMap,Pv=new WeakMap,Xu=new WeakMap,Ku=new WeakMap,Ol=new WeakMap,Iv=new WeakMap,Rp=new WeakMap,Vv=new WeakMap,v0=new WeakMap,v3=new WeakMap,Ar=new WeakMap,Rv=new WeakMap,us=new WeakMap,Np=new WeakMap,Dp=new WeakMap,Bp=new WeakMap,Y4=new WeakMap,s2=new WeakMap,kl=new WeakMap,Nv=new WeakMap,Fp=new WeakMap,J4=new WeakMap,Yu=new WeakMap,Ju=new WeakMap,jp=new WeakMap,Ee=new WeakMap,a2=new WeakMap,f1=new WeakSet,YZ=async function(){await Vt(this,f1,OC).call(this,C(this,Yu));for(const t of this.taxonIdentifiers)await Vt(this,f1,OC).call(this,t);for(const t of C(this,kl).images||[])await Vt(this,f1,eq).call(this,t.id,t.url,"",t.options);await b7t(C(this,Ar));const e=await C(this,us).mapTermGraph(C(this,a2));C(this,Dp).load(e),_t(this,Ee,new pIt(this)),_t(this,J4,1)},JZ=async function(e){return(await C(this,Ar).loadImage(e)).data},tq=function(e){return new Promise((t,n)=>{const r=new Image;r.src=e,r.onload=i=>t(i.target)})},eq=async function(e,t,n,r={}){if(!C(this,Ar).hasImage(e)){const i=await(t.startsWith("data:image")?Vt(this,f1,tq).call(this,t):Vt(this,f1,JZ).call(this,t.startsWith("/")?this.makeServerUrl(t):new URL(t,n).href));C(this,Ar).addImage(e,i,r)}},Dv=function(e,t,n){if(n){const r=eQ(e),i=t.get(r);i?i.push(n):t.set(r,[n])}},zp=function(e,t,n,r=null){if(!(this.options.style!==bi.CENTRELINE&&n.centreline))if(e in n&&n[e].length){const i=n[e];if(Array.isArray(i))for(const o of i)Vt(this,f1,Dv).call(this,o,t,n.featureId);else Vt(this,f1,Dv).call(this,i,t,n.featureId)}else r!==null&&"models"in n&&n.models.startsWith(u7t)&&Vt(this,f1,Dv).call(this,r,t,n.featureId)},nq=function(e,t){t.featureId=e,C(this,v0).set(+e,t),Vt(this,f1,zp).call(this,"dataset",C(this,Xu),t),Vt(this,f1,zp).call(this,"models",C(this,Bp),t),Vt(this,f1,zp).call(this,"source",C(this,Np),t),Vt(this,f1,zp).call(this,"taxons",C(this,jp),t,KZ);for(const[n,r]of Object.entries(t))if(!mIt.includes(n)){C(this,Ol).has(n)||C(this,Ol).set(n,new Pa);const i=C(this,Ol).get(n);Array.isArray(r)?C(this,Ol).set(n,i.union(new Pa(r.map(o=>`${o}`)))):i.add(`${r}`)}C(this,Op).set(t.id,e),this.options.style===bi.CENTRELINE&&t.centreline&&(t.lineString=fR(t.coordinates),t.lineLength=Mct(t.lineString))},OC=async function(e){if(e&&!C(this,Ju).has(e)){const t=await this.queryLabels(e);if(t.length&&"label"in t[0])return C(this,Ju).set(e,t[0].label)}};const vIt="4.2.3",bIt=1.4;var kC,Bv,t8,E1,Fv,jv,Pl,PC,IC,rq;class VC{constructor(t,n=null){yt(this,Pl),yt(this,kC,new s7t),yt(this,Bv,!1),yt(this,t8,[]),yt(this,E1),yt(this,Fv),yt(this,jv,new g8t),pt(this,"mapServerUrl"),this.mapServerUrl=t,_t(this,E1,new fIt(t)),_t(this,Fv,n?n.images||[]:[])}get mapServer(){return C(this,E1)}async allMaps(){await Vt(this,Pl,PC).call(this);const t={};for(const n of C(this,t8)){const r=n.uuid||n.id;t[r]=n}return t}async findMap(t){return await Vt(this,Pl,PC).call(this),Vt(this,Pl,rq).call(this,t)}async loadMap(t,n,r={}){const i=await this.findMap(t);if(i===null)throw new Error(`Unknown map: ${JSON.stringify(t)}`);const o=i.uuid||i.id,a=await C(this,E1).mapIndex(o),s="uuid"in a?a.uuid:a.id;if(o!==s)throw new Error(`Map '${o}' has wrong ID in index`);const u=Object.assign({images:C(this,Fv)},r);!("bounds"in r)&&"bounds"in a&&(u.bounds=a.bounds),"style"in a?u.style=a.style:u.style=bi.GENERIC,!("image-layers"in u)&&"image_layer"in a&&(u["image-layers"]=a.image_layer),"max-zoom"in a&&(u.maxZoom=a["max-zoom"]),"min-zoom"in a&&(u.minZoom=a["min-zoom"]);let h=[];if(!("version"in a)||a.version<=1)for(const H of a.layers||[])typeof H=="string"?h.push({id:H,description:H.charAt(0).toUpperCase()+H.slice(1)}):h.push(H);else h=await C(this,E1).mapLayers(o);const d=await C(this,E1).mapStyle(o);"glyphs"in d||(d.glyphs="https://fonts.openmaptiles.org/{fontstack}/{range}.pbf");const Q=r.pathsDisabled?p7t:await C(this,E1).mapPathways(o),m=await C(this,E1).mapAnnotations(o),_=await C(this,E1).mapMetadata(o);if("vector-tiles"in d.sources){const H=d.sources["vector-tiles"];"minZoom"in u||(u.minZoom=H.minzoom),"maxZoom"in u||(u.maxZoom=H.maxzoom)}u.layerOptions?("coloured"in u.layerOptions||(u.layerOptions.coloured=!0),"outlined"in u.layerOptions||(u.layerOptions.outlined=!0)):u.layerOptions={coloured:!0,outlined:!0},u.layerOptions.authoring="authoring"in a?a.authoring:!1,u.separateLayers=!!i.separateLayers;const x=r.container||"";if(x==="")return null;const w=new _It(x,C(this,E1),{id:i.id,uuid:o,details:a,taxon:i.taxon||null,biologicalSex:i.biologicalSex||null,style:d,options:u,layers:h,sparcTermGraph:C(this,jv),annotations:m,callback:n,pathways:Q,mapMetadata:_});return await w.mapLoaded(),w}}kC=new WeakMap,Bv=new WeakMap,t8=new WeakMap,E1=new WeakMap,Fv=new WeakMap,jv=new WeakMap,Pl=new WeakSet,PC=async function(){return await C(this,kC).dispatch(async()=>{if(!C(this,Bv)){await C(this,E1).initialise(),_t(this,t8,[]);let e;try{e=await C(this,E1).flatMaps()}catch{window.alert(`Cannot connect to flatmap server at ${C(this,E1).url()}`);return}for(const t of e)t.separateLayers="version"in t&&t.version>=bIt,C(this,t8).push(t);await C(this,jv).load(C(this,E1)),_t(this,Bv,!0)}})},IC=function(e){const t=typeof e=="string"||e instanceof String?e:e.uuid||e.taxon||null;if(t===null)return null;const n=typeof e=="string"||e instanceof String?null:e.biologicalSex||null;let r=null,i="";for(const o of C(this,t8))if(("uuid"in o&&t===o.uuid||t===o.id||"taxon"in o&&t===o.taxon||t===o.source)&&(n===null||"biologicalSex"in o&&n===o.biologicalSex))if("created"in o)i<o.created&&(i=o.created,r=o);else{r=o;break}return r},rq=function(e){return typeof e=="object"?Vt(this,Pl,IC).call(this,e):Vt(this,Pl,IC).call(this,{uuid:e})},pt(VC,"version",vIt);const xIt=FH.defineStore("main",{state:()=>({userProfile:{token:""}}),getters:{userToken(e){return e.userProfile.token}},actions:{setUserToken(e){this.userProfile.token=e}}});function LIt(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(i){i(n)}),(r=e.get("*"))&&r.slice().map(function(i){i(t,n)})}}}const RC=new LIt,wIt="cannot be found on the map.",MIt=e=>{let t={lng:0,lat:0},n;return e.type==="Polygon"?e.coordinates.length&&(n=e.coordinates[0]):n=e.coordinates,n&&(e.type!=="Point"?(n.map(r=>{t.lng+=parseFloat(r[0]),t.lat+=parseFloat(r[1])}),t.lng=t.lng/n.length,t.lat=t.lat/n.length):(t.lng+=parseFloat(n[0]),t.lat+=parseFloat(n[1]))),t},iq=(e,t)=>{const n=[];let r=e.organs?e.organs:e.ftus;const i=r?r.filter((o,a)=>r.findIndex(s=>s.label===o.label)===a):void 0;return i&&i.forEach(o=>{const a={label:o.label,models:o.models,key:`${t}.${o.label}`},s=iq(o,a.key);s.length>0&&(a.children=s),n.push(a)}),n},EIt={name:"FlatmapVuer",components:{Button:lP,Col:ah,Loading:k1t,Radio:xP,Icon:P2,RadioGroup:LP,Row:sh,Select:TT,Dialog:Yot,MapSvgIcon:BH.MapSvgIcon,MapSvgSpriteColor:BH.MapSvgSpriteColor,Tooltip:Ab.Tooltip,TreeControls:Ab.TreeControls,SelectionsGroup:IP,SvgLegends:VP,ElIconWarningFilled:Fi.WarningFilled,ElIconArrowDown:Fi.ArrowDown,ElIconArrowLeft:Fi.ArrowLeft,DrawToolbar:Ab.DrawToolbar},beforeCreate:function(){this.setStateRequired=!1},setup(e){let t=L.inject("$annotator");return t||(t=L.markRaw(new lK.AnnotationService(`${e.flatmapAPI}annotator`)),L.provide("$annotator",t)),{annotator:t}},methods:{manualAbortedOnClose:function(){this.annotationSidebar&&this.$emit("annotation-close"),this.closeTooltip(),this.annotationEventCallback({},{type:"aborted"}),this.initialiseDrawing()},initialiseDrawing:function(){this.connectionEntry={},this.activeDrawTool=void 0,this.activeDrawMode=void 0,this.drawnCreatedEvent={}},cancelDrawnFeature:function(){this.isValidDrawnCreated&&(this.annotationSidebar&&this.$emit("annotation-close"),this.closeTooltip(),this.annotationEntry=[{...this.drawnCreatedEvent.feature,resourceId:this.serverURL}],this.rollbackAnnotationEvent(),this.initialiseDrawing())},connectedFeatureTooltip:function(e){if(this.mapImp)if(e){const t=Number(e);let r={feature:t?this.mapImp.featureProperties(t):{feature:this.existDrawnFeatures.find(i=>i.id===e.trim())}};this.checkAndCreatePopups([r])}else this.closeTooltip()},confirmDrawnFeature:function(){this.isValidDrawnCreated&&(this.checkAndCreatePopups([this.drawnCreatedEvent]),Object.keys(this.connectionEntry).length>0&&(this.annotationEntry[0].feature.connection=this.connectionEntry),this.initialiseDrawing())},toolbarEvent:function(e,t){if(!this.isValidDrawnCreated){if(this.manualAbortedOnClose(),this.doubleClickedFeature=!1,this.changeAnnotationDrawMode({mode:"simple_select"}),e==="mode")this.activeDrawMode=t;else if(e==="tool"){if(this.cancelDrawnFeature(),t){const n=t.replace(/[A-Z]/g,r=>`_${r.toLowerCase()}`);this.changeAnnotationDrawMode({mode:`draw${n}`})}this.activeDrawTool=t}}},annotationDrawModeEvent:function(e){this.activeDrawMode==="Edit"?this.doubleClickedFeature&&(e.feature.feature.geometry.type!=="Point"&&(this.changeAnnotationDrawMode({mode:"direct_select",options:{featureId:e.feature.feature.id}}),this.modifyAnnotationFeature()),this.doubleClickedFeature=!1):this.activeDrawMode==="Delete"&&(this.changeAnnotationDrawMode({mode:"simple_select",options:{featureIds:[e.feature.feature.id]}}),this.modifyAnnotationFeature())},createConnectivityBody:function(){if(Object.keys(this.connectionEntry).length>0){const e=Object.values(this.connectionEntry),t={type:"connectivity",source:e[0],target:e[e.length-1],intermediates:e.filter((n,r)=>r!==0&&r!==e.length-1)};this.annotationEntry[0].body=t}},changeAnnotationDrawMode:function(e){this.mapImp&&this.mapImp.changeAnnotationDrawMode(e)},clearAnnotationFeature:function(){this.mapImp&&this.mapImp.clearAnnotationFeature()},modifyAnnotationFeature:function(){this.mapImp&&this.mapImp.removeAnnotationFeature()},rollbackAnnotationEvent:function(){this.mapImp&&this.annotationEntry.length>0&&["created","updated","deleted"].includes(this.annotationEntry[0].type)&&(this.mapImp.rollbackAnnotationEvent(this.annotationEntry[0]),this.annotationEntry=[])},commitAnnotationEvent:function(e){this.mapImp&&(this.offlineAnnotationEnabled&&(this.offlineAnnotations=JSON.parse(sessionStorage.getItem("anonymous-annotation"))||[],this.offlineAnnotations.push(e),this.annotationEntry[0].type==="deleted"&&(this.offlineAnnotations=this.offlineAnnotations.filter(t=>t.resource!==this.serverURL||t.item.id!==e.item.id)),sessionStorage.setItem("anonymous-annotation",JSON.stringify(this.offlineAnnotations))),["created","updated","deleted"].includes(this.annotationEntry[0].type)&&(this.featureAnnotationSubmitted=!0,this.mapImp.commitAnnotationEvent(this.annotationEntry[0]),e.body.comment==="Position Updated"?this.annotationEntry[0].positionUpdated=!1:this.annotationEntry[0].type==="deleted"&&(this.annotationSidebar&&this.$emit("annotation-close"),this.closeTooltip(),this.annotationEntry=[]),this.addAnnotationFeature()))},fetchAnnotatedItemIds:async function(e=void 0,t=void 0){let n;return this.offlineAnnotationEnabled?(this.offlineAnnotations=JSON.parse(sessionStorage.getItem("anonymous-annotation"))||[],n=this.offlineAnnotations.filter(r=>r.resource===this.serverURL).map(r=>r.item.id)):(n=await this.annotator.annotatedItemIds(this.userToken,this.serverURL,e,t),"resource"in n&&(n=n.itemIds)),n},setFeatureAnnotated:async function(){if(this.mapImp){const e=await this.fetchAnnotatedItemIds();for(const t of e)this.mapImp.setFeatureAnnotated(t)}},fetchDrawnFeatures:async function(e,t){let n;if(this.offlineAnnotationEnabled)this.offlineAnnotations=JSON.parse(sessionStorage.getItem("anonymous-annotation"))||[],n=this.offlineAnnotations.filter(r=>r.feature&&r.resource===this.serverURL).map(r=>r.feature);else{const r=await this.fetchAnnotatedItemIds(e,t);n=await this.annotator.drawnFeatures(this.userToken,this.serverURL,r),"resource"in n&&(n=n.features)}return n},addAnnotationFeature:async function(){if(this.mapImp){this.featureAnnotationSubmitted||(this.clearAnnotationFeature(),this.loading=!0);const e=this.annotationFrom==="Anyone"?void 0:this.authorisedUser.orcid?this.authorisedUser.orcid:"0000-0000-0000-0000",t=this.annotationFrom==="Anyone"?void 0:this.annotationFrom==="Me",n=await this.fetchDrawnFeatures(e,t);if(this.existDrawnFeatures=n,this.loading=!1,!this.featureAnnotationSubmitted)for(const r of n)this.mapImp.addAnnotationFeature(r)}},showAnnotator:function(e){this.mapImp&&(this.mapImp.showAnnotator(e),this.$el.querySelector(".maplibregl-ctrl-group").style.display="none")},setAnnotationFrom:function(e){this.annotationFrom=e,this.mapImp&&(this.manualAbortedOnClose(),this.addAnnotationFeature())},emitOfflineAnnotationUpdate:function(){this.$emit("update-offline-annotation-enabled",this.offlineAnnotationEnabled)},setFlightPath3D:function(e){this.flightPath3DRadio=e,this.mapImp&&this.mapImp.enableFlightPaths(e)},viewLatestMap:function(){let e=this.biologicalSex?this.biologicalSex:void 0;this.entry==="NCBITaxon:9606"&&(e="PATO:0000384");const t={entry:this.entry,biologicalSex:e,viewport:this.mapImp.getState()};this.$emit("view-latest-map",t)},backgroundChangeCallback:function(e){this.currentBackground=e,this.mapImp&&this.mapImp.setBackgroundColour(this.currentBackground,1)},processSystems:function(e){if(this.systems.length=0,e&&e.length>0){const t={label:"All",key:"All",children:[]};e.forEach(n=>{const r={colour:n.colour,enabled:n.enabled,label:n.id,key:n.id},i=iq(n,r.key);i.length>0&&(r.children=i),t.children.push(r)}),this.systems.push(t)}},processTaxon:function(e,t){this.taxonConnectivity.length=0,_T(this.mapImp,e).then(n=>{n.length&&n.forEach(r=>{let i=!0;t&&(i=t.checkAll?!0:t.checked.includes(r.taxon)),this.taxonConnectivity.push({...r,enabled:i}),this.mapImp&&this.mapImp.enableConnectivityByTaxonIds(r.taxon,i)})})},toggleDrawer:function(){this.drawerOpen=!this.drawerOpen},setColour:function(e){this.colourRadio=e,this.mapImp&&this.mapImp.setPaint({colour:e,outline:this.outlinesRadio})},setOutlines:function(e){this.outlinesRadio=e,this.mapImp&&this.mapImp.setPaint({colour:this.colourRadio,outline:e})},setInitMapState:function(){if(this.mapImp){const e=this.mapImp.map,t=this.mapImp.options.bounds,n=[[t[0],t[1]],[t[2],t[3]]];e.setMaxBounds(null),e.setRenderWorldCopies(!1),this.initMapState=L.markRaw({initBounds:n})}},resetView:function(){if(this.mapImp){const e=this.mapImp.map,{initBounds:t}=this.initMapState;e.resetNorthPitch({animate:!1}),t&&e.fitBounds(t,{animate:!1}),this.$refs.skcanSelection&&this.$refs.skcanSelection.reset(),this.$refs.layersSelection&&this.$refs.layersSelection.reset(),this.$refs.systemsSelection&&this.$refs.pathwaysSelection.reset(),this.$refs.pathwaysSelection&&this.$refs.pathwaysSelection.reset()}},zoomIn:function(){this.mapImp&&this.mapImp.zoomIn()},zoomOut:function(){this.mapImp&&this.mapImp.zoomOut()},onSelectionsDataChanged:function(e){this.$emit("pathway-selection-changed",e)},sckanSelected:function(e){this.mapImp&&this.mapImp.enableSckanPath(e.key,e.value)},checkAllSCKAN:function(e){this.mapImp&&e.keys.forEach(t=>this.mapImp.enableSckanPath(t,e.value))},zoomToFeatures:function(e){this.mapImp&&this.mapImp.zoomToFeatures(e)},retrieveConnectedPaths:async function(e,t={}){var n,r,i,o,a;if(this.mapImp){let s=[],u=(n=t.target)!=null&&n.length?t.target:[];const h=[...this.mapImp.pathModelNodes(e)],d=await this.mapImp.queryPathsForFeatures(e);if(h.length){if(!u.length){const Q=(r=t.type)!=null&&r.length?t.type:["all"],m=await this.flatmapQueries.queryForConnectivityNew(this.mapImp,e[0]),_=(i=m==null?void 0:m.ids)==null?void 0:i.dendrites.flat(1/0),x=(o=m==null?void 0:m.ids)==null?void 0:o.components.flat(1/0),w=(a=m==null?void 0:m.ids)==null?void 0:a.axons.flat(1/0);let H=[];Q.includes("origins")&&H.push(..._),Q.includes("components")&&H.push(...x),Q.includes("destinations")&&H.push(...w),Q.includes("all")&&H.push(..._,...x,...w),u=[...new Set(H)]}h.forEach(Q=>{this.mapImp.nodePathModels(Q).forEach(_=>{const w=this.mapImp.pathModelNodes(_).map(S=>this.mapImp.featureProperties(S).models);u.filter(S=>w.includes(S)).length&&!s.includes(_)&&s.push(_)})})}else d.length&&(u.length?d.forEach(Q=>{const _=this.mapImp.pathModelNodes(Q).map(w=>this.mapImp.featureProperties(w).models);u.filter(w=>_.includes(w)).length&&!s.includes(Q)&&s.push(Q)}):s=d);return s=[...new Set([...s,...e])],s}},resetMapFilter:function(){const e=this.mapFilters.alert;let t;e.with?e.without||(t={HAS:"alert"}):e.without?t={NOT:{HAS:"alert"}}:t={AND:[{NOT:{HAS:"alert"}},{HAS:"alert"}]},t?this.mapImp.setVisibilityFilter(t):this.mapImp.clearVisibilityFilter()},alertMouseEnterEmitted:function(e){if(this.mapImp)if(e.value){let t;e.key==="alert"?t={HAS:"alert"}:e.key==="withoutAlert"&&(t={NOT:{HAS:"alert"}}),this.mapImp.setVisibilityFilter(t)}else this.resetMapFilter()},alertSelected:function(e){this.mapImp&&(e.key==="alert"?e.value?this.mapFilters.alert.with=!0:this.mapFilters.alert.with=!1:e.key==="withoutAlert"&&(e.value?this.mapFilters.alert.without=!0:this.mapFilters.alert.without=!1),this.resetMapFilter())},checkAllAlerts:function(e){this.mapImp&&(e.value?(this.mapFilters.alert.without=!0,this.mapFilters.alert.with=!0):(this.mapFilters.alert.without=!1,this.mapFilters.alert.with=!1),this.resetMapFilter())},systemSelected:function(e){this.mapImp&&this.mapImp.enableSystem(e.key,e.value)},checkAllSystems:function(e){this.mapImp&&this.systems[0].children.forEach(t=>this.mapImp.enableSystem(t.label,e))},ftuSelected:function(e){this.searchAndShowResult(e,!0)},layersSelected:function(e){this.mapImp&&this.mapImp.enableLayer(e.key,e.value)},checkAllLayers:function(e){this.mapImp&&e.keys.forEach(t=>this.mapImp.enableLayer(t,e.value))},taxonsSelected:function(e){this.mapImp&&this.mapImp.enableConnectivityByTaxonIds(e.key,e.value)},taxonMouseEnterEmitted:function(e){if(this.mapImp)if(e.value){clearTimeout(this.taxonLeaveDelay);let t=this.mapImp.taxonFeatureIds(e.key);this.mapImp.enableConnectivityByTaxonIds(e.key,e.value),this.mapImp.zoomToGeoJSONFeatures(t,{noZoomIn:!0})}else this.taxonLeaveDelay=setTimeout(()=>{this.mapImp.unselectGeoJSONFeatures(),e.selections.forEach(t=>{let n=e.checked.includes(t.taxon);this.mapImp.enableConnectivityByTaxonIds(t.taxon,n)})},1e3)},checkAllTaxons:function(e){this.mapImp&&this.mapImp.enableConnectivityByTaxonIds(e.keys,e.value)},pathwaysSelected:function(e){this.mapImp&&this.mapImp.enablePath(e.key,e.value)},checkAllPathways:function(e){this.mapImp&&e.keys.forEach(t=>this.mapImp.enablePath(t,e.value))},enablePanZoomEvents:function(e){this.mapImp.enablePanZoomEvents(e)},annotationEventCallback:function(e,t){if(t.type==="aborted")this.featureAnnotationSubmitted?this.featureAnnotationSubmitted=!1:this.rollbackAnnotationEvent(),this.annotationEntry=[];else if(t.type==="modeChanged")t.feature.mode==="direct_select"&&(this.doubleClickedFeature=!0),this.annotationSidebar&&t.feature.mode==="simple_select"&&this.activeDrawMode==="Deleted"&&this.annotationEventCallback({},{type:"aborted"});else if(t.type==="selectionChanged"){if(this.selectedDrawnFeature=t.feature.features.length===0?void 0:t.feature.features[0],e.feature.feature=this.selectedDrawnFeature,!this.activeDrawTool)if(this.connectionEntry={},this.selectedDrawnFeature){const n=this.existDrawnFeatures.find(r=>r.id===this.selectedDrawnFeature.id);n&&n.connection&&(this.connectionEntry=n.connection),this.annotationDrawModeEvent(e)}else this.annotationSidebar&&this.previousEditEvent.type==="updated"&&(this.annotationEntry=[{...this.previousEditEvent,resourceId:this.serverURL}],this.annotationEventCallback({},{type:"aborted"})),this.previousEditEvent={}}else{if(t.type==="created"||t.type==="updated"){t.type==="updated"&&t.feature.action&&(t.positionUpdated=t.feature.action==="move");const n=this.mapImp.refreshAnnotationFeatureGeometry(t.feature);e.feature.feature=n}t.type==="created"?this.drawnCreatedEvent=e:this.checkAndCreatePopups([e])}t.type==="updated"&&(this.previousEditEvent=t),t.type==="deleted"?this.previousDeletedEvent=t:this.previousDeletedEvent={}},eventCallback:function(){return(e,t,...n)=>{if(e==="annotation"){const r={feature:t,userData:n,eventType:e};this.annotationEventCallback(r,t)}else if(e!=="pan-zoom"){const r=t.label,i=[t.models],o=this.entry,a=this.biologicalSex,s=t.alert;let u;t.taxons&&(typeof t.taxons!="object"?u=JSON.parse(t.taxons):u=t.taxons);let h=[{dataset:t.dataset,biologicalSex:a,taxonomy:o,resource:i,label:r,feature:t,userData:n,eventType:e,provenanceTaxonomy:u,alert:s}];if(e==="click"){const d=Object.keys(t).includes("id");if(!d){h=[];const m=t.mapUUID,_=new Set;for(let[x,w]of Object.entries(t))if(x!=="mapUUID"){const H=w.id,S=w.label,P=[w.models];let V;if(w.taxons&&(typeof w.taxons!="object"?V=JSON.parse(w.taxons):V=w.taxons),_.has(H))continue;_.add(H),h.push({dataset:w.dataset,biologicalSex:a,taxonomy:o,resource:P,label:S,feature:w,userData:n,eventType:e,provenanceTaxonomy:V,alert:w.alert,mapUUID:m})}}const Q=d?t:t[0];if(this.setConnectivityDataSource(this.viewingMode,Q),this.viewingMode==="Neuron Connection")this.retrieveConnectedPaths([Q.models]).then(m=>{this.zoomToFeatures(m)});else if(this.currentActive=Q.models?Q.models:"",this.activeDrawTool&&!this.isValidDrawnCreated){const m=Q.featureId||this.existDrawnFeatures.find(_=>_.id===Q.id);if(this.activeDrawTool==="LineString"&&m){const _=Q.featureId?Q.featureId:Q.id,x=Q.label?Q.label:`Feature ${Q.id}`;this.connectionEntry[` ${_}`]=Object.assign({label:x},Object.fromEntries(Object.entries(Q).filter(([w])=>["featureId","models"].includes(w)).map(([w,H])=>[w==="featureId"?"id":w,H])))}}}else e==="mouseenter"&&this.viewingMode!=="Neuron Connection"&&(this.currentHover=t.models?t.models:"");t&&t.type!=="marker"&&e==="click"&&this.viewingMode!=="Neuron Connection"&&!this.activeDrawTool&&this.checkAndCreatePopups(h),this.$emit("resource-selected",h)}else this.$emit("pan-zoom-callback",t)}},setConnectivityDataSource:function(e,t){this.connectivityDataSource=t.source,(e==="Neuron Connection"||e==="Annotation")&&(this.connectivityDataSource=t.featureId)},changeViewingMode:function(e){e&&(this.viewingMode=e),this.manualAbortedOnClose()},removeActiveTooltips:function(){this.mapImp&&this.mapImp.removePopup(),this.$el.querySelectorAll(".flatmap-tooltip-popup").forEach(t=>t.remove())},createTooltipForConnectivity:function(e,t){const n=document.createElement("div");n.classList.add("flatmap-feature-label"),e.forEach((r,i)=>{const{label:o}=r;if(n.append(NP(o)),i+1<e.length){const a=document.createElement("hr");n.appendChild(a)}}),this.mapImp.showPopup(t,n,{className:"custom-popup flatmap-tooltip-popup",positionAtLastClick:!1,preserveSelection:!0})},showConnectivityTooltips:function(e){const{connectivityInfo:t,data:n}=e,r=[],i=[],o=[],a=[];if(t&&t.featureId&&r.push(...t.featureId),this.mapImp){if(n.forEach(h=>{const d=this.mapImp.search(h.id);if(d!=null&&d.results.length){const Q=d==null?void 0:d.results[0].featureId;o.push({featureId:Q,...h})}else a.push(h)}),o.length){let h=o[0].featureId;this.mapImp.annotations.forEach(d=>{const Q=d["anatomical-nodes"];if(Q){const m=Q.join("");o.every(x=>m.indexOf(x.id)!==-1)&&(h=d.featureId,i.push(h))}}),this.createTooltipForConnectivity(o,h)}else this.removeActiveTooltips();this.emitConnectivityError(a);const u=[...this.mapImp.modelFeatureIdList(r),...i];this.mapImp.selectGeoJSONFeatures(u)}},showConnectivitiesByReference:function(e){this.searchConnectivitiesByReference(e).then(t=>{this.mapImp.selectFeatures(t)})},searchConnectivitiesByReference:async function(e){const t=sessionStorage.getItem("flatmap-knowledge");let n=[];return t?n=await W1t(e):n=await Z1t(this.mapImp,e,this.flatmapQueries),n},emitConnectivityError:function(e){this.$emit("connectivity-error",{data:{errorData:e,errorMessage:wIt}})},checkConnectivityTooltipEntry:function(e){return e!=null&&e.length?e.find(t=>{var n,r;return((n=t==null?void 0:t.destinations)==null?void 0:n.length)||((r=t==null?void 0:t.components)==null?void 0:r.length)})!==void 0:!1},changeConnectivitySource:async function(e){const{entry:t,connectivitySource:n}=e;t.mapId===this.mapImp.id&&(await this.flatmapQueries.queryForConnectivityNew(this.mapImp,t.featureId[0],n),this.tooltipEntry=this.tooltipEntry.map(r=>r.featureId[0]===t.featureId[0]?this.flatmapQueries.updateTooltipData(r):r),this.checkConnectivityTooltipEntry(this.tooltipEntry)&&this.$emit("connectivity-info-open",this.tooltipEntry))},checkAndCreatePopups:async function(e){if(this.viewingMode==="Annotation"){const t=e.filter(n=>n.feature).map(n=>n.feature);if(t.length>0)if(this.annotationSidebar&&this.previousDeletedEvent.type==="deleted"&&(this.annotationEntry=[{...this.previousDeletedEvent,resourceId:this.serverURL}],this.annotationEventCallback({},{type:"aborted"})),this.annotationEntry=[],t.forEach(n=>{var r;this.annotationEntry.push({...n,resourceId:this.serverURL,featureId:n.featureId?n.featureId:(r=n.feature)==null?void 0:r.id,offline:this.offlineAnnotationEnabled})}),t[0].feature)this.activeDrawTool||this.activeDrawMode||this.isValidDrawnCreated?(this.featureAnnotationSubmitted=!1,this.activeDrawTool&&this.createConnectivityBody(),this.displayTooltip(t[0].feature.id,MIt(t[0].feature.geometry))):this.rollbackAnnotationEvent();else{const n=this.annotationEntry.filter(r=>r.featureId&&r.models).map(r=>r.models);n.length>0&&this.displayTooltip(n)}else this.annotation={}}else{X1t(this.mapImp,this.flatmapQueries);let t=[];if(this.tooltipEntry=e.filter(n=>n.resource[0]&&this.mapImp.pathModelNodes(n.resource).length>0).map(n=>({title:n.label,featureId:n.resource,ready:!1})),this.tooltipEntry.length){this.$emit("connectivity-info-open",this.tooltipEntry);for(let r=0;r<e.length;r++)t.push(await this.getKnowledgeTooltip(e[r]));this.tooltipEntry=await Promise.all(t);const n=this.tooltipEntry.map(r=>r.featureId[0]);n.length>0&&this.displayTooltip(n)}}},getKnowledgeTooltip:async function(e){const t=await this.flatmapQueries.retrieveFlatmapKnowledgeForEvent(this.mapImp,e);let n=await this.flatmapQueries.createTooltipData(this.mapImp,e);return(t&&t[0]||e.feature.hyperlinks&&e.feature.hyperlinks.length>0)&&(n.featuresAlert=e.alert,n.knowledgeSource=Px(this.mapImp),n.mapId=this.mapImp.provenance.id,n.mapuuid=this.mapImp.provenance.uuid),n.ready=!0,n},popUpCssHacks:function(){const e=document.querySelector(".flatmap-tooltip-popup"),t=document.querySelector(".maplibregl-popup-close-button");e&&(e.style.display="none"),t.style.display="block",this.$refs.tooltip.$el.style.display="flex",t.onclick=()=>{this.$emit("connectivity-info-close"),e&&(e.style.display="block")}},closeTooltip:function(){this.$refs.tooltip&&(this.$refs.tooltip.$el.style.display="none"),document.querySelectorAll(".maplibregl-popup").forEach(e=>{e.style.display="none"})},showPopup:function(e,t,n){let r=n;this.mapImp&&(r?r.className||(r.className="custom-popup"):r={className:"custom-popup",positionAtLastClick:!0},this.mapImp.showPopup(e,t,r))},showMarkerPopup:function(e,t,n){this.mapImp&&this.mapImp.showMarkerPopup(e,t,n)},closeMinimap:function(){let e=this.$refs.flatmapContainer.querySelector(".maplibregl-ctrl-minimap");this.minimapSmall?(e.classList.add("enlarge"),e.classList.remove("shrink")):(e.classList.add("shrink"),e.classList.remove("enlarge")),this.minimapSmall=!this.minimapSmall},addResizeButtonToMinimap:function(){let e=this.$refs.flatmapContainer.querySelector(".maplibregl-ctrl-minimap");e&&(this.$refs.minimapResize&&this.$refs.minimapResize.$el.parentNode&&this.$refs.minimapResize.$el.parentNode.removeChild(this.$refs.minimapResize.$el),e.appendChild(this.$refs.minimapResize.$el),this.minimapResizeShow=!0)},setHelpMode:function(e){const t=this.hoverVisibilities.length,n=t-1,r=this.hoverVisibilities[this.helpModeActiveIndex];if(r){const i=r==null?void 0:r.refs,o=r==null?void 0:r.ref,a=this.$refs[i||o];if(a){const{parentElement:s,nextElementSibling:u}=a.$el,h=d=>d&&(d.classList.contains("pathway-container")||d.classList.contains("pathway-location"));(h(s)||h(u))&&(this.requiresDrawer?this.drawerOpen=!0:this.helpModeActiveIndex+=1)}else this.helpModeActiveIndex+=1}e||(this.helpModeActiveIndex=this.helpModeInitialIndex),this.viewingMode!=="Annotation"&&this.helpModeActiveIndex>9&&(this.helpModeActiveIndex=n),e&&this.helpModeActiveIndex>=n&&this.$emit("help-mode-last-item",!0),e&&!this.helpModeDialog?(this.inHelp=!0,this.hoverVisibilities.forEach(i=>{i.value=!0})):e&&this.helpModeDialog&&t>this.helpModeActiveIndex?this.helpModeActiveIndex>-1?(this.closeFlatmapHelpPopup(),setTimeout(()=>{this.inHelp=!1,this.hoverVisibilities.forEach(i=>{i.value=!1}),this.showTooltip(this.helpModeActiveIndex,200)},300)):this.helpModeActiveIndex===-1&&this.openFlatmapHelpPopup():(this.inHelp=!1,this.hoverVisibilities.forEach(i=>{i.value=!1}),this.closeFlatmapHelpPopup())},showTooltip:function(e,t=500){this.inHelp||(clearTimeout(this.tooltipWait[e]),this.tooltipWait[e]=setTimeout(()=>{this.hoverVisibilities[e].value=!0,this.$emit("shown-tooltip")},t))},hideTooltip:function(e,t=500){this.inHelp||(clearTimeout(this.tooltipWait[e]),this.tooltipWait[e]=setTimeout(()=>{this.hoverVisibilities[e].value=!1},t))},displayTooltip:function(e,t=void 0){let n,r={className:"flatmapvuer-popover"};if(t)n=e,r.annotationFeatureGeometry=t;else{const i=Array.isArray(e)?e[0]:e;i&&(n=this.mapImp.modelFeatureIds(i)[0]),this.activeDrawTool||(r.positionAtLastClick=!0)}this.connectivityInfoSidebar&&this.tooltipEntry.length&&this.viewingMode!=="Annotation"&&this.checkConnectivityTooltipEntry(this.tooltipEntry)&&this.$emit("connectivity-info-open",this.tooltipEntry),this.annotationSidebar&&this.viewingMode==="Annotation"&&this.$emit("annotation-open",{annotationEntry:this.annotationEntry,commitCallback:this.commitAnnotationEvent}),n&&!this.disableUI&&(this.viewingMode==="Annotation"&&!this.annotationSidebar||this.viewingMode==="Exploration"&&!this.connectivityInfoSidebar)&&(this.tooltipDisplay=!0,this.$nextTick(()=>{this.mapImp.showPopup(n,this.$refs.tooltip.$el,r),this.popUpCssHacks()}))},moveMap:function(e,t={}){if(this.mapImp){const{offsetX:n=0,offsetY:r=0,zoom:i=4}=t,o=this.mapImp.map,a=this.mapImp.bounds.toArray();this.mapImp.zoomToFeatures(e,{noZoomIn:!0}),this.showPathwaysDrawer(!1),a!=null&&a.length&&setTimeout(()=>{o.fitBounds(a,{offset:[n,r],zoom:i,animate:!0})})}},openFlatmapHelpPopup:function(){if(this.mapImp){let e=this.mapImp.modelFeatureIds("UBERON:0000948");e&&e.length>0&&(this.mapImp.showPopup(e[0],"Click for more information",{anchor:"top",className:"flatmap-popup-popper"}),this.$emit("shown-map-tooltip"))}},closeFlatmapHelpPopup:function(){this.$el.querySelectorAll(".maplibregl-popup-close-button").forEach(e=>{e.click()})},getLabels:function(){let e=[];if(this.mapImp){let t=this.mapImp.annotations;for(let n of t.values())n.label&&e.push(n.label);return Array.from(new Set(e))}},getVisibilityState:function(e){if(["alertSelection","pathwaysSelection","taxonSelection"].forEach(n=>{let r=this.$refs[n];r&&(e[n]=r.getState())}),this.$refs.treeControls){const n=this.$refs.treeControls.$refs.regionTree.getCheckedKeys();e.systemsSelection=n.filter(r=>!r.includes("."))}},setVisibilityState:function(e){["alertSelection","pathwaysSelection","taxonSelection"].forEach(n=>{const r=e[n];if(r){const i=this.$refs[n];i&&i.setState(r)}}),"systemsSelection"in e&&this.$refs.treeControls&&(this.$refs.treeControls.$refs.regionTree.setCheckedKeys(e.systemsSelection),this.systems[0].children.forEach(n=>{this.mapImp.enableSystem(n.key,e.systemsSelection.includes(n.key))}))},getState:function(){if(this.mapImp){let e={entry:this.entry,viewport:this.mapImp.getState()};const t=this.mapImp.getIdentifier();return this.biologicalSex?e.biologicalSex=this.biologicalSex:t&&t.biologicalSex&&(e.biologicalSex=t.biologicalSex),t&&t.uuid&&(e.uuid=t.uuid),e.viewingMode=this.viewingMode,e.searchTerm=this.searchTerm,e.flightPath3D=this.flightPath3DRadio,e.colour=this.colourRadio,e.outlines=this.outlinesRadio,e.background=this.currentBackground,this.offlineAnnotationEnabled&&(e.offlineAnnotations=sessionStorage.getItem("anonymous-annotation")),this.getVisibilityState(e),e}},setState:function(e){e&&(this.mapImp&&e.entry&&this.entry==e.entry&&(!e.biologicalSex||e.biologicalSex===this.biologicalSex)?this.restoreMapState(e):this.createFlatmap(e),this.setStateRequired=!1)},restoreMapState:function(e){if(e){if(e.viewport&&this.mapImp.setState(e.viewport),e.offlineAnnotations&&sessionStorage.setItem("anonymous-annotation",e.offlineAnnotations),e.viewingMode&&this.changeViewingMode(e.viewingMode),"flightPath3D"in e&&this.setFlightPath3D(e.flightPath3D),"colour"in e&&this.setColour(e.colour),"outlines"in e&&this.setOutlines(e.outlines),e.background&&this.backgroundChangeCallback(e.background),e.searchTerm){const t=e.searchTerm;this.searchAndShowResult(t,!0)}this.setVisibilityState(e)}},setFlightPathInfo:function(e){(e===1.6||e>1.6)&&(this.displayFlightPathOption=!0,this.setFlightPath3D(!1))},createFlatmap:function(e){if(!this.mapImp&&!this.loading){this.loading=!0;let t=!1;this.displayMinimap&&(t={position:"top-right"});let n={taxon:this.entry};this.uuid&&(n.uuid=this.uuid),e?(e.uuid?n={uuid:e.uuid}:e.entry&&(n.taxon=e.entry),e.biologicalSex?n.biologicalSex=e.biologicalSex:n.taxon==="NCBITaxon:9606"&&(n.biologicalSex="PATO:0000384")):this.biologicalSex&&(n.biologicalSex=this.biologicalSex),this.mapManagerRef.loadMap(n,this.eventCallback(),{minZoom:this.minZoom,tooltips:this.tooltips,minimap:t,container:this.$refs.display}).then(i=>{this.mapImp=i,this.serverURL=this.mapImp.makeServerUrl("").slice(0,-1);let o=this.mapImp.details.version;this.setFlightPathInfo(o);const a=this._stateToBeSet?this._stateToBeSet:e;this.onFlatmapReady(a),this.$nextTick(()=>this.restoreMapState(a))})}else e&&(this._stateToBeSet={...e},this.mapImp&&!this.loading&&this.restoreMapState(this._stateToBeSet))},computePathControlsMaximumHeight(){const e=this.$refs.display;if(e){const t=getComputedStyle(e),n=parseInt(t.paddingTop)+parseInt(t.paddingBottom),r=e.clientHeight-n;this.pathwaysMaxHeight=r-170}},mapResize:function(){try{this.computePathControlsMaximumHeight(),this.mapImp&&(this.mapImp.resize(),this.showMinimap(this.displayMinimap))}catch{console.error("Map resize error")}},getFilterSources:function(){const e=["kind","taxons"];let t=new Set,n=new Set,r=new Map;for(const o of this.mapImp.annotations.values())if(o.source){"alert"in o?t.add(o.source):n.add(o.source);for(const[a,s]of Object.entries(o))if(e.includes(a)){r.has(a)||r.set(a,new Map);const u=r.get(a),h=d=>{const Q=d;u.has(Q)||u.set(Q,new Set),u.get(Q).add(`${o.source}`)};Array.isArray(s)?s.forEach(h):h(s)}}let i={alert:{with:[...t],without:[...n]}};for(const[o,a]of r.entries()){i[o]={};for(const[s,u]of a.entries())i[o][s]=[...u.values()]}return i},getFilterOptions:async function(){if(this.mapImp){let e=[];const t=this.mapImp.featureFilterRanges();for(const[n,r]of Object.entries(t)){let i={key:`flatmap.connectivity.${n}`,label:"",children:[]};if(n==="kind"){i.label="Pathways";for(const o of r){const a=this.pathways.find(s=>s.type!=="centreline"&&s.type===o);a&&i.children.push({key:`${i.key}.${o}`,label:a.label})}}else if(n==="taxons"){i.label="Studied in";const o=await _T(this.mapImp,this.mapImp.taxonIdentifiers);if(o.length)for(const a of r){const s=o.find(u=>u.taxon===a);s&&i.children.push({key:`${i.key}.${a}`,label:s.label})}}else if(n==="alert"){i.label="Alert";for(const o of["with","without"])i.children.push({key:`${i.key}.${o}`,label:`${o} alerts`})}i.label&&i.children.length&&e.push(i)}return e}},onFlatmapReady:function(e){var t;this.sensor=L.markRaw(new est(this.$refs.display,this.mapResize)),((t=this.mapImp.options)==null?void 0:t.style)==="functional"&&(this.isFC=!0),this.mapImp.setBackgroundOpacity(1),this.backgroundChangeCallback(this.currentBackground),this.pathways=this.mapImp.pathTypes(),this.processSystems(this.mapImp.getSystems()),this.processTaxon(this.mapImp.taxonIdentifiers,e?e.taxonSelection:void 0),this.containsAlert="alert"in this.mapImp.featureFilterRanges(),this.addResizeButtonToMinimap(),this.loading=!1,this.computePathControlsMaximumHeight(),this.mapResize(),this.handleMapClick(),this.setInitMapState(),this.$emit("ready",this)},handleMapClick:function(){const e=this.mapImp.map;e&&e.on("click",t=>{this.connectivityDataSource||this.$emit("connectivity-info-close"),this.connectivityDataSource=""})},showMinimap:function(e){this.mapImp&&this.mapImp.showMinimap(e)},showPathwaysDrawer:function(e){this.drawerOpen=e},searchAndShowResult:function(e,t){var n;if(this.mapImp){if(e===void 0||e==="")return this.mapImp.clearSearchResults(),this.viewingMode==="Exploration"?this.$emit("connectivity-info-close"):this.viewingMode==="Annotation"&&this.manualAbortedOnClose(),this.searchTerm="",!0;{const r=this.mapImp.search(e);if((n=r==null?void 0:r.results)!=null&&n.length){if(this.mapImp.showSearchResults(r),t){let i;for(let o=0;o<r.results.length;o++){i=r.results[o].featureId;const a=this.mapImp.annotation(i);if(i&&(a!=null&&a.label))break}if(i){const o=this.mapImp.featureProperties(i),a={resource:[o.models],feature:o,label:o.label,provenanceTaxonomy:o.taxons,alert:o.alert};this.viewingMode==="Exploration"||this.viewingMode==="Annotation"?this.checkAndCreatePopups([a]):this.viewingMode==="Neuron Connection"&&this.retrieveConnectedPaths(a.resource).then(s=>{this.zoomToFeatures(s)}),this.mapImp.showPopup(i,NP(o.label),{className:"custom-popup",positionAtLastClick:!1,preserveSelection:!0})}}return this.searchTerm=e,!0}else this.mapImp.clearSearchResults()}}return!1},searchSuggestions:function(e){return this.mapImp?this.mapImp.search(e):[]},onActionClick:function(e){RC.emit("onActionClick",e)}},props:{entry:{type:String,required:!0},uuid:String,biologicalSex:{type:String,default:""},minZoom:{type:Number,default:1},tooltips:{type:Boolean,default:!0},helpMode:{type:Boolean,default:!1},helpModeActiveItem:{type:Number,default:0},helpModeDialog:{type:Boolean,default:!1},helpModeLastItem:{type:Boolean,default:!1},helpModeInitialIndex:{type:Number,default:0},renderAtMounted:{type:Boolean,default:!0},displayMinimap:{type:Boolean,default:!1},displayWarning:{type:Boolean,default:!1},enableOpenMapUI:{type:Boolean,default:!1},openMapOptions:{type:Array,default:function(){return[{display:"Open AC Map",key:"AC"},{display:"Open FC Map",key:"FC"},{display:"Open 3D Human Map",key:"3D"}]}},showStarInLegend:{type:Boolean,default:!1},isLegacy:{type:Boolean,default:!1},displayLatestChanges:{type:Boolean,default:!1},state:{type:Object,default:void 0},mapManager:{type:Object,default:void 0},flatmapAPI:{type:String,default:"https://mapcore-demo.org/current/flatmap/v3/"},sparcAPI:{type:String,default:"https://api.sparc.science/"},disableUI:{type:Boolean,default:!1},connectivityInfoSidebar:{type:Boolean,default:!1},annotationSidebar:{type:Boolean,default:!1},showLocalSettings:{type:Boolean,default:!0},showOpenMapButton:{type:Boolean,default:!0},showPathwayFilter:{type:Boolean,default:!0}},provide(){return{flatmapAPI:this.flatmapAPI,sparcAPI:this.sparcAPI,userApiKey:this.userToken}},data:function(){return{sensor:null,mapManagerRef:void 0,flatmapQueries:void 0,annotationEntry:[],tooltipDisplay:!1,serverURL:void 0,layers:[],pathways:[],initMapState:L.markRaw({}),sckanDisplay:[{label:"Display Path with SCKAN",key:"VALID"}],systems:[],taxonConnectivity:[],pathwaysMaxHeight:1e3,tooltipWait:L.markRaw([]),hoverVisibilities:[{value:!1,ref:"markerPopover"},{value:!1,ref:"zoomInPopover"},{value:!1,ref:"zoomOutPopover"},{value:!1,ref:"zoomFitPopover"},{value:!1,ref:"openMapPopover"},{value:!1,ref:"settingsPopover"},{value:!1,ref:"checkBoxPopover"},{value:!1,ref:"warningPopover"},{value:!1,ref:"whatsNewPopover"},{value:!1,ref:"featuredMarkerPopover"},{value:!1,refs:"toolbarPopover",ref:"editPopover"},{value:!1,refs:"toolbarPopover",ref:"deletePopover"},{value:!1,refs:"toolbarPopover",ref:"pointPopover"},{value:!1,refs:"toolbarPopover",ref:"lineStringPopover"},{value:!1,refs:"toolbarPopover",ref:"polygonPopover"},{value:!1,refs:"toolbarPopover",ref:"connectionPopover"}],helpModeActiveIndex:this.helpModeInitialIndex,yellowstar:J1t,isFC:!1,inHelp:!1,currentBackground:"white",availableBackground:["white","lightskyblue","black"],loading:!1,flatmapMarker:G1t,tooltipEntry:[],connectivityDataSource:"",connectivityTooltipVisible:!1,drawerOpen:!1,flightPath3DRadio:!1,displayFlightPathOption:!1,colourRadio:!0,outlinesRadio:!0,minimapResizeShow:!1,minimapSmall:!1,currentActive:"",selectedDrawnFeature:void 0,currentHover:"",viewingMode:"Exploration",viewingModes:{Exploration:"Find relevant research and view detail of neural pathways by selecting a pathway to view its connections and data sources","Neuron Connection":"Discover Neuron connections by selecting a neuron and viewing its associated network connections",Annotation:["View feature annotations","Add, comment on and view feature annotations"]},offlineAnnotationEnabled:!1,offlineAnnotations:[],annotationFrom:"Anyone",annotatedSource:["Anyone","Me","Others"],openMapRef:void 0,backgroundIconRef:void 0,toolbarOptions:["Edit","Delete","Point","LineString","Polygon","Connection"],annotator:void 0,authorisedUser:void 0,activeDrawMode:void 0,activeDrawTool:void 0,featureAnnotationSubmitted:!1,drawnCreatedEvent:{},previousEditEvent:{},previousDeletedEvent:{},connectionEntry:{},existDrawnFeatures:[],doubleClickedFeature:!1,containsAlert:!1,alertOptions:[{label:"Display Path With Alerts",key:"alert",enabled:!0},{label:"Display Path Without Alerts",key:"withoutAlert",enabled:!0}],mapFilters:L.markRaw({alert:{with:!0,without:!0}}),searchTerm:"",taxonLeaveDelay:void 0}},computed:{...FH.mapState(xIt,["userToken"]),isValidDrawnCreated:function(){return Object.keys(this.drawnCreatedEvent).length>0},requiresDrawer:function(){var e,t,n;if(this.loading)return this.drawerOpen=!1,!1;if(this.isFC){if(((e=this.systems)==null?void 0:e.length)>0||this.containsAlert&&this.alertOptions||((t=this.pathways)==null?void 0:t.length)>0||((n=this.taxonConnectivity)==null?void 0:n.length)>0)return this.drawerOpen=!0,!0}else return this.drawerOpen=!0,!0;return this.drawerOpen=!1,!0},modeDescription:function(){let e=this.viewingModes[this.viewingMode];return this.viewingMode==="Annotation"?this.authorisedUser?e[1]:e[0]:e}},watch:{entry:function(){this.state||this.createFlatmap()},helpMode:function(e,t){e!==t&&this.setHelpMode(e)},helpModeActiveItem:function(){this.helpMode&&(this.helpModeActiveIndex+=1,this.setHelpMode(this.helpMode))},state:{handler:function(e,t){e!==t&&(this.mapManagerRef?this.setState(e):this.setStateRequired=!0)},immediate:!0,deep:!0},viewingMode:function(e){this.clearAnnotationFeature(),e==="Annotation"&&(this.loading=!0,this.annotator.authenticate(this.userToken).then(t=>{t.name&&t.email&&t.canUpdate?(this.authorisedUser=t,this.offlineAnnotationEnabled=!1):(this.authorisedUser=void 0,this.offlineAnnotationEnabled=!0),this.emitOfflineAnnotationUpdate(),this.setFeatureAnnotated(),this.addAnnotationFeature(),this.loading=!1}))},disableUI:function(e){e&&this.closeTooltip()},activeDrawTool:function(e){let t=[],n={x:null,y:null};const r=this.$el.querySelector(".maplibregl-canvas"),i=()=>{r.removeEventListener("keydown",o),r.removeEventListener("click",a)},o=s=>{if(!["Escape","Enter"].includes(s.key))return;const u=e==="Point"&&t.length===1||e==="LineString"&&t.length>=2||e==="Polygon"&&t.length>=3;(s.key==="Escape"||s.key==="Enter"&&!u)&&(this.activeDrawTool=void 0),i()},a=s=>{const u=r.getBoundingClientRect(),h=s.clientX-u.left,d=s.clientY-u.top;if(Math.sqrt((h-n.x)**2+(d-n.y)**2)<8){this.isValidDrawnCreated||(this.activeDrawTool=void 0),i();return}n={x:h,y:d},t.push(n)};e&&(i(),r.addEventListener("keydown",o),r.addEventListener("click",a))}},created:function(){this.mapManager?this.mapManagerRef=this.mapManager:(this.mapManagerRef=L.markRaw(new VC(this.flatmapAPI,{container:void 0})),this.$emit("mapmanager-loaded",this.mapManagerRef))},mounted:function(){this.openMapRef=L.shallowRef(this.$refs.openMapRef),this.backgroundIconRef=L.shallowRef(this.$refs.backgroundIconRef),this.tooltipWait.length=this.hoverVisibilities.length,this.flatmapQueries=L.markRaw(new $1t),this.flatmapQueries.initialise(this.flatmapAPI),this.state?this.setStateRequired&&this.setState(this.state):this.renderAtMounted&&this.createFlatmap(),RP()}},SIt={class:"flatmap-container",ref:"flatmapContainer","element-loading-text":"Loading...","element-loading-background":"rgba(0, 0, 0, 0.3)"},AIt={style:{height:"100%",width:"100%",position:"relative","overflow-y":"none"}},CIt={style:{height:"100%",width:"100%"},ref:"display"},HIt={class:"beta-popovers"},OIt={key:2,class:"warning-text"},kIt={class:"bottom-right-control"},PIt=["innerHTML"],IIt=["innerHTML"],VIt={style:{"margin-bottom":"2px"}},RIt={key:0,class:"viewing-mode-title"},NIt=["onClick"],DIt=["onClick"];function BIt(e,t,n,r,i,o){const a=L.resolveComponent("map-svg-sprite-color"),s=Fi.WarningFilled,u=P2,h=QT,d=Fi.ArrowDown,Q=L.resolveComponent("DrawToolbar"),m=L.resolveComponent("map-svg-icon"),_=VP,x=L.resolveComponent("tree-controls"),w=IP,H=Fi.ArrowLeft,S=lP,P=sh,V=ah,B=Ax,U=TT,W=xP,X=LP,nt=L.resolveComponent("Tooltip"),st=OP,Tt=Hx;return L.withDirectives((L.openBlock(),L.createElementBlock("div",SIt,[L.createVNode(a),L.createElementVNode("div",AIt,[L.createElementVNode("div",CIt,null,512),L.withDirectives(L.createElementVNode("div",HIt,[L.createElementVNode("div",null,[L.createVNode(h,{placement:"right","popper-class":"warning-popper flatmap-popper",teleported:!1,visible:e.hoverVisibilities[7].value,ref:"warningPopover"},{reference:L.withCtx(()=>[L.createElementVNode("div",{class:"warning-icon",onMouseover:t[7]||(t[7]=dt=>o.showTooltip(7)),onMouseout:t[8]||(t[8]=dt=>o.hideTooltip(7))},[n.displayWarning||n.isLegacy?(L.openBlock(),L.createBlock(u,{key:0},{default:L.withCtx(()=>[L.createVNode(s)]),_:1})):L.createCommentVNode("",!0),n.isLegacy?(L.openBlock(),L.createElementBlock(L.Fragment,{key:1},[t[33]||(t[33]=L.createElementVNode("span",{class:"warning-text"},"Legacy Map",-1)),L.createElementVNode("div",{class:"latest-map-text",onClick:t[6]||(t[6]=(...dt)=>o.viewLatestMap&&o.viewLatestMap(...dt))}," Click here for the latest map ")],64)):n.displayWarning?(L.openBlock(),L.createElementBlock("span",OIt,"Beta")):L.createCommentVNode("",!0)],32)]),default:L.withCtx(()=>[n.isLegacy?(L.openBlock(),L.createElementBlock("p",{key:0,onMouseover:t[0]||(t[0]=dt=>o.showTooltip(7)),onMouseout:t[1]||(t[1]=dt=>o.hideTooltip(7))}," This is a legacy map, you may view the latest map instead. ",32)):e.isFC?(L.openBlock(),L.createElementBlock("p",{key:1,onMouseover:t[2]||(t[2]=dt=>o.showTooltip(7)),onMouseout:t[3]||(t[3]=dt=>o.hideTooltip(7))},t[31]||(t[31]=[L.createTextVNode(" This map displays the connectivity of individual neurons. Specifically, those which align with (parts of) the neuron populations from the "),L.createElementVNode("a",{href:"https://sparc.science/resources/1ZUKXU2YmLcn2reCyXjlew",target:"_blank"}," ApiNATOMY ",-1),L.createTextVNode(" models available in "),L.createElementVNode("a",{href:"https://sparc.science/resources/6eg3VpJbwQR4B84CjrvmyD",target:"_blank"}," SCKAN ",-1),L.createTextVNode(". ")]),32)):(L.openBlock(),L.createElementBlock("p",{key:2,onMouseover:t[4]||(t[4]=dt=>o.showTooltip(7)),onMouseout:t[5]||(t[5]=dt=>o.hideTooltip(7))},t[32]||(t[32]=[L.createTextVNode(" This map displays the connectivity of neuron populations. Specifically, those from the primarily rat-based "),L.createElementVNode("a",{href:"https://sparc.science/resources/1ZUKXU2YmLcn2reCyXjlew",target:"_blank"}," ApiNATOMY ",-1),L.createTextVNode(" models available in "),L.createElementVNode("a",{href:"https://sparc.science/resources/6eg3VpJbwQR4B84CjrvmyD",target:"_blank"}," SCKAN ",-1),L.createTextVNode(". New connectivity and species specificity will be added as the SPARC program progresses. ")]),32))]),_:1},8,["visible"])]),n.displayLatestChanges?(L.openBlock(),L.createBlock(h,{key:0,placement:"right",teleported:!1,trigger:"manual","popper-class":"warning-popper flatmap-popper",visible:e.hoverVisibilities[8].value,ref:"whatsNewPopover"},{reference:L.withCtx(()=>[n.displayLatestChanges?(L.openBlock(),L.createElementBlock("div",{key:0,class:"latest-changesicon",onMouseover:t[9]||(t[9]=dt=>o.showTooltip(8)),onMouseout:t[10]||(t[10]=dt=>o.hideTooltip(8))},[L.createVNode(u,null,{default:L.withCtx(()=>[L.createVNode(s)]),_:1}),t[34]||(t[34]=L.createElementVNode("span",{class:"warning-text"},"What's new?",-1))],32)):L.createCommentVNode("",!0)]),default:L.withCtx(()=>t[35]||(t[35]=[L.createElementVNode("b",null,"Connectivity References",-1),L.createElementVNode("p",null," Connectivity references have been improved and available in various formats. ",-1),L.createElementVNode("b",null,"Improved state storing",-1),L.createElementVNode("p",null," Current selection and visibility filters are now stored when creating a permalink. ",-1)])),_:1},8,["visible"])):L.createCommentVNode("",!0)],512),[[L.vShow,!n.disableUI]]),L.withDirectives(L.createVNode(u,{class:L.normalizeClass(["minimap-resize",{enlarge:e.minimapSmall,shrink:!e.minimapSmall}]),ref:"minimapResize",onClick:o.closeMinimap},{default:L.withCtx(()=>[L.createVNode(d)]),_:1},8,["class","onClick"]),[[L.vShow,e.minimapResizeShow]]),e.viewingMode==="Annotation"&&(e.authorisedUser||e.offlineAnnotationEnabled)&&!n.disableUI?(L.openBlock(),L.createBlock(Q,{key:0,mapCanvas:{containerHTML:this.$el,class:".maplibregl-canvas"},toolbarOptions:e.toolbarOptions,activeDrawTool:e.activeDrawTool,activeDrawMode:e.activeDrawMode,newlyDrawnEntry:e.drawnCreatedEvent,connectionEntry:e.connectionEntry,hoverVisibilities:e.hoverVisibilities,onClickToolbar:o.toolbarEvent,onFeatureTooltip:o.connectedFeatureTooltip,onConfirmDrawn:o.confirmDrawnFeature,onCancelDrawn:o.cancelDrawnFeature,onShowTooltip:o.showTooltip,onHideTooltip:o.hideTooltip,ref:"toolbarPopover"},null,8,["mapCanvas","toolbarOptions","activeDrawTool","activeDrawMode","newlyDrawnEntry","connectionEntry","hoverVisibilities","onClickToolbar","onFeatureTooltip","onConfirmDrawn","onCancelDrawn","onShowTooltip","onHideTooltip"])):L.createCommentVNode("",!0),L.withDirectives(L.createElementVNode("div",kIt,[L.createVNode(h,{content:"Zoom in",placement:"left",teleported:!1,trigger:"manual",width:"70","popper-class":"flatmap-popper",visible:e.hoverVisibilities[1].value,ref:"zoomInPopover"},{reference:L.withCtx(()=>[L.createElementVNode("div",{class:"icon-button-container",onClick:t[11]||(t[11]=dt=>o.zoomIn()),onMouseover:t[12]||(t[12]=dt=>o.showTooltip(1)),onMouseout:t[13]||(t[13]=dt=>o.hideTooltip(1))},[L.createVNode(m,{class:"icon-button zoomIn",icon:"zoomIn"})],32)]),_:1},8,["visible"]),L.createVNode(h,{content:"Zoom out",placement:"top-end",teleported:!1,trigger:"manual",width:"70","popper-class":"flatmap-popper",visible:e.hoverVisibilities[2].value,ref:"zoomOutPopover"},{reference:L.withCtx(()=>[L.createElementVNode("div",{class:"icon-button-container",onClick:t[14]||(t[14]=dt=>o.zoomOut()),onMouseover:t[15]||(t[15]=dt=>o.showTooltip(2)),onMouseout:t[16]||(t[16]=dt=>o.hideTooltip(2))},[L.createVNode(m,{class:"icon-button zoomOut",icon:"zoomOut"})],32)]),_:1},8,["visible"]),L.createVNode(h,{content:"Reset",placement:"top",teleported:!1,trigger:"manual",width:"70","popper-class":"flatmap-popper",visible:e.hoverVisibilities[3].value,ref:"zoomFitPopover"},{reference:L.withCtx(()=>[L.createElementVNode("div",{class:"icon-button-container",onClick:t[17]||(t[17]=dt=>o.resetView()),onMouseover:t[18]||(t[18]=dt=>o.showTooltip(3)),onMouseout:t[19]||(t[19]=dt=>o.hideTooltip(3))},[L.createVNode(m,{class:"icon-button fitWindow",icon:"fitWindow"})],32)]),default:L.withCtx(()=>[t[36]||(t[36]=L.createElementVNode("div",null,[L.createTextVNode(" Fit to "),L.createElementVNode("br"),L.createTextVNode(" window ")],-1))]),_:1},8,["visible"])],512),[[L.vShow,!n.disableUI]]),L.createVNode(h,{content:"Change pathway visibility",placement:"right",teleported:!1,trigger:"manual",offset:-18,"popper-class":"flatmap-popper",visible:e.hoverVisibilities[6].value,ref:"checkBoxPopover"},{reference:L.withCtx(()=>[L.withDirectives(L.createElementVNode("div",{class:L.normalizeClass(["pathway-location",{open:e.drawerOpen,close:!e.drawerOpen}])},[L.withDirectives((L.openBlock(),L.createElementBlock("div",{class:L.normalizeClass(["pathway-container",{open:e.drawerOpen,close:!e.drawerOpen}]),style:L.normalizeStyle({"max-height":e.pathwaysMaxHeight+"px"})},[e.isFC?L.createCommentVNode("",!0):(L.openBlock(),L.createBlock(_,{key:0,class:"svg-legends-container"})),n.showStarInLegend?(L.openBlock(),L.createBlock(h,{key:1,content:"Location of the featured dataset",placement:"right",teleported:!0,trigger:"manual",width:"max-content",offset:-10,"popper-class":"flatmap-popper flatmap-teleport-popper",visible:e.hoverVisibilities[9].value,ref:"featuredMarkerPopover"},{reference:L.withCtx(()=>[L.withDirectives(L.createElementVNode("div",{class:"yellow-star-legend",innerHTML:e.yellowstar,onMouseover:t[20]||(t[20]=dt=>o.showTooltip(9)),onMouseout:t[21]||(t[21]=dt=>o.hideTooltip(9))},null,40,PIt),[[st,void 0,"featuredMarkerPopover"]])]),_:1},8,["visible"])):L.createCommentVNode("",!0),L.createVNode(h,{content:"Find these markers for data. The number inside the markers is the number of datasets available for each marker.",placement:"right",teleported:!1,width:"200",trigger:"manual","popper-class":"flatmap-popper flatmap-marker-popper",visible:e.hoverVisibilities[0].value,ref:"markerPopover"},{reference:L.withCtx(()=>[L.withDirectives(L.createElementVNode("div",{class:"flatmap-marker-help",innerHTML:e.flatmapMarker},null,8,IIt),[[L.vShow,e.hoverVisibilities[0].value],[st,void 0,"markerPopover"]])]),_:1},8,["visible"]),e.isFC&&e.systems&&e.systems.length>0?(L.openBlock(),L.createBlock(x,{key:2,class:"treeControls",mapType:"flatmap",title:"Systems",treeData:e.systems,active:e.currentActive,hover:e.currentHover,onCheckChanged:o.systemSelected,onCheckAll:o.checkAllSystems,onChangeActive:o.ftuSelected,ref:"treeControls"},null,8,["treeData","active","hover","onCheckChanged","onCheckAll","onChangeActive"])):L.createCommentVNode("",!0),e.containsAlert&&e.alertOptions&&n.showPathwayFilter?(L.openBlock(),L.createBlock(w,{title:"Alert",labelKey:"label",identifierKey:"key",selections:e.alertOptions,onChanged:o.alertSelected,onCheckboxMouseEnter:o.alertMouseEnterEmitted,onSelectionsDataChanged:o.onSelectionsDataChanged,onCheckAll:o.checkAllAlerts,ref:"alertSelection",key:"alertSelection"},null,8,["selections","onChanged","onCheckboxMouseEnter","onSelectionsDataChanged","onCheckAll"])):L.createCommentVNode("",!0),e.pathways&&e.pathways.length>0&n.showPathwayFilter?(L.openBlock(),L.createBlock(w,{title:"Pathways",labelKey:"label",identifierKey:"type",colourStyle:"line",selections:e.pathways,onChanged:o.pathwaysSelected,onSelectionsDataChanged:o.onSelectionsDataChanged,onCheckAll:o.checkAllPathways,ref:"pathwaysSelection",key:"pathwaysSelection"},null,8,["selections","onChanged","onSelectionsDataChanged","onCheckAll"])):L.createCommentVNode("",!0),e.taxonConnectivity&&e.taxonConnectivity.length>0&&n.showPathwayFilter?(L.openBlock(),L.createBlock(w,{title:"Studied in",labelKey:"label",identifierKey:"taxon",helpMessage:"Evidence exists that this set of neuron populations have been studied in the given species.",selections:e.taxonConnectivity,onChanged:o.taxonsSelected,onCheckboxMouseEnter:o.taxonMouseEnterEmitted,onSelectionsDataChanged:o.onSelectionsDataChanged,onCheckAll:o.checkAllTaxons,ref:"taxonSelection",key:"taxonSelection"},null,8,["selections","onChanged","onCheckboxMouseEnter","onSelectionsDataChanged","onCheckAll"])):L.createCommentVNode("",!0)],6)),[[st,void 0,"checkBoxPopover"]]),L.createElementVNode("div",{onClick:t[22]||(t[22]=(...dt)=>o.toggleDrawer&&o.toggleDrawer(...dt)),class:L.normalizeClass(["drawer-button",{open:e.drawerOpen,close:!e.drawerOpen}])},[L.createVNode(u,null,{default:L.withCtx(()=>[L.createVNode(H)]),_:1})],2)],2),[[L.vShow,!n.disableUI&&o.requiresDrawer]])]),_:1},8,["visible"]),e.openMapRef?(L.openBlock(),L.createBlock(h,{key:1,ref:"open-map-popover","virtual-ref":e.openMapRef,placement:"top-start",width:"136",teleported:!1,trigger:"click","popper-class":"open-map-popper non-selectable","virtual-triggering":""},{default:L.withCtx(()=>[(L.openBlock(!0),L.createElementBlock(L.Fragment,null,L.renderList(n.openMapOptions,dt=>(L.openBlock(),L.createBlock(P,{key:dt.key},{default:L.withCtx(()=>[L.createVNode(S,{type:"primary",plain:"",onClick:At=>e.$emit("open-map",dt.key)},{default:L.withCtx(()=>[L.createTextVNode(L.toDisplayString(dt.display),1)]),_:2},1032,["onClick"])]),_:2},1024))),128))]),_:1},8,["virtual-ref"])):L.createCommentVNode("",!0),L.createVNode(h,{ref:"backgroundPopover","virtual-ref":e.backgroundIconRef,placement:"top-start",width:"320",teleported:!1,trigger:"click","popper-class":"background-popper h-auto","virtual-triggering":""},{default:L.withCtx(()=>[L.createElementVNode("div",null,[L.createVNode(P,{class:"backgroundText"},{default:L.withCtx(()=>t[37]||(t[37]=[L.createTextVNode("Viewing Mode")])),_:1}),L.createVNode(P,{class:"backgroundControl"},{default:L.withCtx(()=>[L.createElementVNode("div",VIt,[(L.openBlock(!0),L.createElementBlock(L.Fragment,null,L.renderList(e.viewingModes,(dt,At,Zt)=>(L.openBlock(),L.createElementBlock(L.Fragment,{key:At},[At===e.viewingMode?(L.openBlock(),L.createElementBlock("span",RIt,[L.createElementVNode("b",null,L.toDisplayString(At),1)])):(L.openBlock(),L.createElementBlock("span",{key:1,class:"viewing-mode-unselected",onClick:ce=>o.changeViewingMode(At)},L.toDisplayString(At),9,NIt))],64))),128))]),L.createVNode(P,{class:"viewing-mode-description"},{default:L.withCtx(()=>[L.createTextVNode(L.toDisplayString(o.modeDescription),1)]),_:1}),e.viewingMode==="Annotation"&&e.offlineAnnotationEnabled?(L.openBlock(),L.createBlock(P,{key:0,class:"viewing-mode-description"},{default:L.withCtx(()=>t[38]||(t[38]=[L.createTextVNode(" (Anonymous annotate) ")])),_:1})):L.createCommentVNode("",!0)]),_:1}),e.viewingMode==="Annotation"&&e.authorisedUser?(L.openBlock(),L.createElementBlock(L.Fragment,{key:0},[L.createVNode(P,{class:"backgroundText"},{default:L.withCtx(()=>t[39]||(t[39]=[L.createTextVNode("Annotations From")])),_:1}),L.createVNode(P,{class:"backgroundControl"},{default:L.withCtx(()=>[L.createVNode(U,{teleported:!1,modelValue:e.annotationFrom,"onUpdate:modelValue":t[23]||(t[23]=dt=>e.annotationFrom=dt),placeholder:"Select",class:"select-box","popper-class":"flatmap_dropdown",onChange:o.setAnnotationFrom},{default:L.withCtx(()=>[(L.openBlock(!0),L.createElementBlock(L.Fragment,null,L.renderList(e.annotatedSource,dt=>(L.openBlock(),L.createBlock(B,{key:dt,label:dt,value:dt},{default:L.withCtx(()=>[L.createVNode(P,null,{default:L.withCtx(()=>[L.createVNode(V,{span:12},{default:L.withCtx(()=>[L.createTextVNode(L.toDisplayString(dt),1)]),_:2},1024)]),_:2},1024)]),_:2},1032,["label","value"]))),128))]),_:1},8,["modelValue","onChange"])]),_:1})],64)):L.createCommentVNode("",!0),e.displayFlightPathOption?(L.openBlock(),L.createBlock(P,{key:1,class:"backgroundSpacer"})):L.createCommentVNode("",!0),e.displayFlightPathOption?(L.openBlock(),L.createBlock(P,{key:2,class:"backgroundText"},{default:L.withCtx(()=>t[40]||(t[40]=[L.createTextVNode("Flight path display")])),_:1})):L.createCommentVNode("",!0),e.displayFlightPathOption?(L.openBlock(),L.createBlock(P,{key:3,class:"backgroundControl"},{default:L.withCtx(()=>[L.createVNode(X,{modelValue:e.flightPath3DRadio,"onUpdate:modelValue":t[24]||(t[24]=dt=>e.flightPath3DRadio=dt),class:"flatmap-radio",onChange:o.setFlightPath3D},{default:L.withCtx(()=>[L.createVNode(W,{value:!1},{default:L.withCtx(()=>t[41]||(t[41]=[L.createTextVNode("2D")])),_:1}),L.createVNode(W,{value:!0},{default:L.withCtx(()=>t[42]||(t[42]=[L.createTextVNode("3D")])),_:1})]),_:1},8,["modelValue","onChange"])]),_:1})):L.createCommentVNode("",!0),L.createVNode(P,{class:"backgroundSpacer"}),L.createVNode(P,{class:"backgroundText"},{default:L.withCtx(()=>t[43]||(t[43]=[L.createTextVNode("Organs display")])),_:1}),L.createVNode(P,{class:"backgroundControl"},{default:L.withCtx(()=>[L.createVNode(X,{modelValue:e.colourRadio,"onUpdate:modelValue":t[25]||(t[25]=dt=>e.colourRadio=dt),class:"flatmap-radio",onChange:o.setColour},{default:L.withCtx(()=>[L.createVNode(W,{value:!0},{default:L.withCtx(()=>t[44]||(t[44]=[L.createTextVNode("Colour")])),_:1}),L.createVNode(W,{value:!1},{default:L.withCtx(()=>t[45]||(t[45]=[L.createTextVNode("Greyscale")])),_:1})]),_:1},8,["modelValue","onChange"])]),_:1}),L.createVNode(P,{class:"backgroundSpacer"}),L.createVNode(P,{class:"backgroundText"},{default:L.withCtx(()=>t[46]||(t[46]=[L.createTextVNode("Outlines display")])),_:1}),L.createVNode(P,{class:"backgroundControl"},{default:L.withCtx(()=>[L.createVNode(X,{modelValue:e.outlinesRadio,"onUpdate:modelValue":t[26]||(t[26]=dt=>e.outlinesRadio=dt),class:"flatmap-radio",onChange:o.setOutlines},{default:L.withCtx(()=>[L.createVNode(W,{value:!0},{default:L.withCtx(()=>t[47]||(t[47]=[L.createTextVNode("Show")])),_:1}),L.createVNode(W,{value:!1},{default:L.withCtx(()=>t[48]||(t[48]=[L.createTextVNode("Hide")])),_:1})]),_:1},8,["modelValue","onChange"])]),_:1}),L.createVNode(P,{class:"backgroundSpacer"}),L.createVNode(P,{class:"backgroundText"},{default:L.withCtx(()=>t[49]||(t[49]=[L.createTextVNode("Change background")])),_:1}),L.createVNode(P,{class:"backgroundControl"},{default:L.withCtx(()=>[(L.openBlock(!0),L.createElementBlock(L.Fragment,null,L.renderList(e.availableBackground,dt=>(L.openBlock(),L.createElementBlock("div",{key:dt,class:L.normalizeClass(["backgroundChoice",dt,dt==e.currentBackground?"active":""]),onClick:At=>o.backgroundChangeCallback(dt)},null,10,DIt))),128))]),_:1})])]),_:1},8,["virtual-ref"]),L.withDirectives(L.createElementVNode("div",{class:L.normalizeClass(["settings-group",{open:e.drawerOpen,close:!e.drawerOpen}])},[n.showOpenMapButton?(L.openBlock(),L.createBlock(P,{key:0},{default:L.withCtx(()=>[L.createVNode(h,{visible:e.hoverVisibilities[4].value,content:"Open new map",placement:"right",teleported:!1,"popper-class":"flatmap-popper",ref:"openMapPopover"},{reference:L.withCtx(()=>[n.enableOpenMapUI&&n.openMapOptions.length>0?(L.openBlock(),L.createElementBlock("div",{key:0,ref:"openMapRef",class:"icon-button-container",onMouseover:t[27]||(t[27]=dt=>o.showTooltip(4)),onMouseout:t[28]||(t[28]=dt=>o.hideTooltip(4))},[L.createVNode(m,{icon:"openMap",class:"icon-button open-map-button"})],544)):L.createCommentVNode("",!0)]),_:1},8,["visible"])]),_:1})):L.createCommentVNode("",!0),n.showLocalSettings?(L.openBlock(),L.createBlock(P,{key:1},{default:L.withCtx(()=>[L.createVNode(h,{content:"Change settings",placement:"right",visible:e.hoverVisibilities[5].value,teleported:!1,trigger:"manual","popper-class":"flatmap-popper",ref:"settingsPopover"},{reference:L.withCtx(()=>[L.createElementVNode("div",{ref:"backgroundIconRef",class:"icon-button-container",onMouseover:t[29]||(t[29]=dt=>o.showTooltip(5)),onMouseout:t[30]||(t[30]=dt=>o.hideTooltip(5))},[L.createVNode(m,{icon:"changeBckgd",class:"icon-button"})],544)]),_:1},8,["visible"])]),_:1})):L.createCommentVNode("",!0)],2),[[L.vShow,!n.disableUI]]),e.tooltipDisplay?(L.openBlock(),L.createBlock(nt,{key:2,ref:"tooltip",class:"tooltip",annotationEntry:e.annotationEntry,tooltipEntry:e.tooltipEntry,annotationDisplay:e.viewingMode==="Annotation",onAnnotation:o.commitAnnotationEvent,onOnActionClick:o.onActionClick},null,8,["annotationEntry","tooltipEntry","annotationDisplay","onAnnotation","onOnActionClick"])):L.createCommentVNode("",!0)])])),[[Tt,e.loading]])}const NC=yT(EIt,[["render",BIt],["__scopeId","data-v-04264bd7"]]),oq={"NCBITaxon:10114":"01fedbf9-d783-509c-a10c-827941ab13da","NCBITaxon:9823":"a336ac04-24db-561f-a25f-1c994fe17410","NCBITaxon:9606":"42ed6323-f645-5fbe-bada-9581819cf689","NCBITaxon:10090":"25285fab-48a0-5620-a6a0-f9a0374837d5","NCBITaxon:9685":"73060497-46a6-52bf-b975-cac511c127cb"},FIt={name:"MultiFlatmapVuer",components:{Col:ah,Row:sh,Option:Ax,Select:TT,Popover:QT,FlatmapVuer:NC},created:function(){this.loadMapManager()},mounted:function(){this.initialise(),RC.on("onActionClick",e=>{this.resourceSelected(e)}),RC.on("open-pubmed-url",e=>{this.$emit("open-pubmed-url",e)})},methods:{initialise:function(){return new Promise(e=>{this.requireInitialisation?(this.requireInitialisation=!1,fetch(this.flatmapAPI).then(t=>t.json()).then(t=>{Object.keys(this.availableSpecies).forEach(r=>{const i=this.availableSpecies[r].uuid;if(i&&t.map(o=>o.uuid).indexOf(i)>0)this.speciesList[r]=this.availableSpecies[r];else for(let o=0;o<t.length;o++)if(this.availableSpecies[r].taxo===t[o].taxon)if(this.availableSpecies[r].biologicalSex){if(t[o].biologicalSex&&t[o].biologicalSex===this.availableSpecies[r].biologicalSex){this.speciesList[r]=this.availableSpecies[r];break}}else{this.speciesList[r]=this.availableSpecies[r];break}});let n=this.initial;if(this.state){const r=this.state.state;(!r||!r.uuid&&!r.entry)&&this.state.species?n=this.state.species:n=void 0}n&&(n&&this.speciesList[n]!==void 0?this.activeSpecies=n:this.activeSpecies=Object.keys(this.speciesList)[0],this.setSpecies(this.activeSpecies,this.state?this.state.state:void 0,5)),this.initialised=!0,e(),this.resolveList.forEach(r=>{r()})})):this.initialised?e():this.resolveList.push(e)})},loadMapManager:function(){this.mapManagerRef||(this.mapManager?this.mapManagerRef=this.mapManager:(this.mapManagerRef=L.markRaw(new VC(this.flatmapAPI,{container:void 0})),this.$emit("mapmanager-loaded",this.mapManagerRef)))},resourceSelected:function(e){this.$emit("resource-selected",e)},FlatmapReady:function(e){this.$emit("ready",e)},getCurrentFlatmap:function(){return this.$refs[this.activeSpecies][0]},panZoomCallback:function(e){this.$emit("pan-zoom-callback",e)},onAnnotationClose:function(){this.$emit("annotation-close")},onAnnotationOpen:function(e){this.$emit("annotation-open",e)},updateOfflineAnnotationEnabled:function(e){this.$emit("update-offline-annotation-enabled",e)},onConnectivityInfoClose:function(){this.$emit("connectivity-info-close")},onConnectivityInfoOpen:function(e){this.$emit("connectivity-info-open",e)},onConnectivityError:function(e){this.$emit("connectivity-error",e)},onSelectionsDataChanged:function(e){this.$emit("pathway-selection-changed",e)},showPopup:function(e,t,n){this.getCurrentFlatmap().showPopup(e,t,n)},showMarkerPopup:function(e,t,n){this.getCurrentFlatmap().showMarkerPopup(e,t,n)},setSpecies:function(e,t,n){if(this.$refs&&e in this.$refs)this.activeSpecies=e,this.$refs[this.activeSpecies][0].createFlatmap(t),this.$emit("flatmapChanged",this.activeSpecies);else if(n){const r=n-1;r>=0&&this.$nextTick(()=>{this.setSpecies(e,t,r)})}},viewLatestMap:function(e){const t=Object.keys(this.speciesList);for(let n=0;n<t.length;n++){const r=this.speciesList[t[n]];if(!r.isLegacy&&r.taxo===e.entry&&r.biologicalSex===e.biologicalSex){this.setSpecies(t[n],e,0);return}}},createLegacyEntry:function(e,t,n){if(n&&t){let r="Legacy";return e.species&&(e.species.slice(0,6)==="Legacy"?r=e.species:r=r+` ${e.species}`),this.speciesList[r]={taxo:t,isLegacy:!0,displayWarning:!0},{species:r,state:{entry:t,uuid:n,viewport:e.state.viewport,searchTerm:e.state.searchTerm}}}},updateState:function(e){return new Promise(t=>{if(e&&e.state){const n=e.state;if(n.uuid){if(n.entry)return new Promise(()=>{const r={taxon:n.entry};n.biologicalSex&&(r.biologicalSex=n.biologicalSex),this.mapManagerRef.findMap(r).then(i=>{if(i.uuid!==n.uuid)return this.createLegacyEntry(e,n.entry,n.uuid)}).then(i=>{t(i||e)}).catch(()=>{t(e)})})}else if(n.entry){const r=n.entry in oq?oq[n.entry]:void 0,i=this.createLegacyEntry(e,n.entry,r);t(i||e)}}t(e)})},getState:function(){let e={species:this.activeSpecies,state:void 0},t=this.getCurrentFlatmap();return e.state=t.getState(),e},setState:function(e){e&&(this.loadMapManager(),this.updateState(e).then(t=>{this.initialise().then(()=>{t.species&&t.species!==this.activeSpecies?this.setSpecies(t.species,t.state,5):t.state&&this.getCurrentFlatmap().setState(t.state)})}))},activateTooltipByIndex:function(e){return e===this.helpModeActiveItem&&this.helpMode},onHelpModeLastItem:function(e){e&&this.$emit("help-mode-last-item",!0)},onTooltipShown:function(){this.$emit("shown-tooltip")},onMapTooltipShown:function(){this.$emit("shown-map-tooltip")},changeViewingMode:function(e){this.getCurrentFlatmap().changeViewingMode(e)}},props:{initial:{type:String,default:""},minZoom:{type:Number,default:1},renderAtMounted:{type:Boolean,default:!1},helpMode:{type:Boolean,default:!1},helpModeActiveItem:{type:Number,default:0},helpModeDialog:{type:Boolean,default:!1},helpModeLastItem:{type:Boolean,default:!1},displayMinimap:{type:Boolean,default:!1},showStarInLegend:{type:Boolean,default:!1},enableOpenMapUI:{type:Boolean,default:!1},openMapOptions:{type:Array},availableSpecies:{type:Object,default:function(){return{"Human Female":{taxo:"NCBITaxon:9606",biologicalSex:"PATO:0000383",iconClass:"mapicon-icon_human",displayWarning:!0},"Human Male":{taxo:"NCBITaxon:9606",biologicalSex:"PATO:0000384",iconClass:"mapicon-icon_human",displayWarning:!0},Rat:{taxo:"NCBITaxon:10114",iconClass:"mapicon-icon_rat",displayLatestChanges:!0},Mouse:{taxo:"NCBITaxon:10090",iconClass:"mapicon-icon_mouse",displayWarning:!0},Pig:{taxo:"NCBITaxon:9823",iconClass:"mapicon-icon_pig",displayWarning:!0},Cat:{taxo:"NCBITaxon:9685",iconClass:"mapicon-icon_cat",displayWarning:!0}}}},state:{type:Object,default:void 0},mapManager:{type:Object,default:void 0},flatmapAPI:{type:String,default:"https://mapcore-demo.org/current/flatmap/v3/"},sparcAPI:{type:String,default:"https://api.sparc.science/"},disableUI:{type:Boolean,default:!1},connectivityInfoSidebar:{type:Boolean,default:!1},annotationSidebar:{type:Boolean,default:!1},showLocalSettings:{type:Boolean,default:!0},showOpenMapButton:{type:Boolean,default:!0},showPathwayFilter:{type:Boolean,default:!0}},data:function(){return{activeSpecies:void 0,speciesList:{},requireInitialisation:!0,resolveList:L.markRaw([]),initialised:!1,mapManagerRef:void 0}},watch:{state:{handler:function(e){this.setState(e)},immediate:!0,deep:!0}}},jIt={class:"multi-container",ref:"multiContainer"},zIt={key:0,style:{position:"absolute","z-index":"100"}},UIt={class:"select-box-icon"};function GIt(e,t,n,r,i,o){const a=Ax,s=TT,u=QT,h=NC;return L.openBlock(),L.createElementBlock("div",jIt,[n.disableUI?L.createCommentVNode("",!0):(L.openBlock(),L.createElementBlock("div",zIt,[t[2]||(t[2]=L.createElementVNode("div",{class:"species-display-text"},"Species",-1)),L.createVNode(u,{content:"Select a species",placement:"right",trigger:"manual","popper-class":"flatmap-popper flatmap-teleport-popper right-popper",width:"max-content",visible:o.activateTooltipByIndex(0),teleported:!1,ref:"selectPopover"},{reference:L.withCtx(()=>[L.createVNode(s,{id:"flatmap-select",teleported:!1,modelValue:e.activeSpecies,"onUpdate:modelValue":t[0]||(t[0]=d=>e.activeSpecies=d),placeholder:"Select",class:"select-box","popper-class":"flatmap-dropdown",onChange:o.setSpecies},{default:L.withCtx(()=>[(L.openBlock(!0),L.createElementBlock(L.Fragment,null,L.renderList(e.speciesList,(d,Q)=>(L.openBlock(),L.createBlock(a,{key:Q,label:Q,value:Q},{default:L.withCtx(()=>[L.createElementVNode("span",UIt,[L.createElementVNode("i",{class:L.normalizeClass(d.iconClass)},null,2)]),L.createTextVNode(" "+L.toDisplayString(Q),1)]),_:2},1032,["label","value"]))),128))]),_:1},8,["modelValue","onChange"])]),_:1},8,["visible"])])),(L.openBlock(!0),L.createElementBlock(L.Fragment,null,L.renderList(e.speciesList,(d,Q)=>L.withDirectives((L.openBlock(),L.createBlock(h,{key:Q,entry:d.taxo,uuid:d.uuid,biologicalSex:d.biologicalSex,displayWarning:d.displayWarning,displayLatestChanges:d.displayLatestChanges,isLegacy:d.isLegacy,ref_for:!0,ref:Q,enableOpenMapUI:n.enableOpenMapUI,openMapOptions:n.openMapOptions,disableUI:n.disableUI,onViewLatestMap:o.viewLatestMap,onResourceSelected:o.resourceSelected,onReady:o.FlatmapReady,onPanZoomCallback:o.panZoomCallback,annotationSidebar:n.annotationSidebar,onAnnotationOpen:o.onAnnotationOpen,onAnnotationClose:o.onAnnotationClose,onUpdateOfflineAnnotationEnabled:o.updateOfflineAnnotationEnabled,connectivityInfoSidebar:n.connectivityInfoSidebar,onConnectivityInfoOpen:o.onConnectivityInfoOpen,onConnectivityInfoClose:o.onConnectivityInfoClose,onConnectivityError:o.onConnectivityError,onOpenMap:t[1]||(t[1]=m=>e.$emit("open-map",m)),onPathwaySelectionChanged:o.onSelectionsDataChanged,minZoom:n.minZoom,helpMode:e.activeSpecies==Q&&n.helpMode,helpModeActiveItem:n.helpModeActiveItem,helpModeDialog:n.helpModeDialog,helpModeInitialIndex:-2,onHelpModeLastItem:o.onHelpModeLastItem,onShownTooltip:o.onTooltipShown,onShownMapTooltip:o.onMapTooltipShown,renderAtMounted:n.renderAtMounted,displayMinimap:n.displayMinimap,showStarInLegend:n.showStarInLegend,style:{height:"100%"},mapManager:e.mapManagerRef,flatmapAPI:n.flatmapAPI,sparcAPI:n.sparcAPI,showLocalSettings:n.showLocalSettings,showOpenMapButton:n.showOpenMapButton,showPathwayFilter:n.showPathwayFilter},null,8,["entry","uuid","biologicalSex","displayWarning","displayLatestChanges","isLegacy","enableOpenMapUI","openMapOptions","disableUI","onViewLatestMap","onResourceSelected","onReady","onPanZoomCallback","annotationSidebar","onAnnotationOpen","onAnnotationClose","onUpdateOfflineAnnotationEnabled","connectivityInfoSidebar","onConnectivityInfoOpen","onConnectivityInfoClose","onConnectivityError","onPathwaySelectionChanged","minZoom","helpMode","helpModeActiveItem","helpModeDialog","onHelpModeLastItem","onShownTooltip","onShownMapTooltip","renderAtMounted","displayMinimap","showStarInLegend","mapManager","flatmapAPI","sparcAPI","showLocalSettings","showOpenMapButton","showPathwayFilter"])),[[L.vShow,e.activeSpecies==Q]])),128))],512)}const $It=yT(FIt,[["render",GIt],["__scopeId","data-v-fd1ba441"]]);Bi.FlatmapVuer=NC,Bi.MultiFlatmapVuer=$It,Object.defineProperty(Bi,Symbol.toStringTag,{value:"Module"})});