@fnndsc/argus 0.16.4 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{Settings-RsdfmMXh.js → Settings-CKApE3sg.js} +1 -1
- package/dist/assets/{Texture-Ggh33DNM.js → Texture-CFUfIEub.js} +1 -1
- package/dist/assets/{addVolumesToViewports-vXgAymDY.js → addVolumesToViewports-CkTaWHv-.js} +1 -1
- package/dist/assets/cornerstoneEngine-CAd9z_EH.js +2 -0
- package/dist/assets/{index-Cgb7V21b.js → index-BFg_Vgc2.js} +1 -1
- package/dist/assets/{index-k2VKaE20.js → index-Bk-4Cj4d.js} +1 -1
- package/dist/assets/{index-D_zKI1-l.js → index-BwXaD9bz.js} +1 -1
- package/dist/assets/{index-6f7rprvr.js → index-C9XrSjdk.js} +1 -1
- package/dist/assets/index-CVUcpNtC.css +1 -0
- package/dist/assets/{index-C84JjmPo.js → index-DSCJS0dw.js} +1 -1
- package/dist/assets/index-DfT-vEKx.js +4255 -0
- package/dist/assets/{index-BVBGi2sJ.js → index-DjJppD5u.js} +1 -1
- package/dist/assets/layoutWorker-S-M8lwVB.js +1 -0
- package/dist/assets/{niivueEngine-A63Q8k2b.js → niivueEngine-B8EopR_P.js} +2 -2
- package/dist/assets/{slabScene-4YWTyxxU.js → slabScene-BbagJ9Kt.js} +1 -1
- package/dist/index.html +6 -3
- package/package.json +3 -2
- package/dist/assets/cornerstoneEngine-qfeli3aA.js +0 -2
- package/dist/assets/index-CwMYsWsk.css +0 -1
- package/dist/assets/index-DqpQZLU4.js +0 -4236
- package/dist/assets/layoutWorker-DqMRqv-I.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as T,E as R,e as M,B as We,v as Ae,a as ne,b as F,s as ke,c as Fe,f as oe,cw as ue,c8 as Ne,bW as P,aK as z,cx as fe,aJ as Y,ag as se,V as G,cy as ge,cz as D,cA as Ue,cB as Ge,cC as Be,bL as He,at as O,aO as ze,bi as B,cD as me,bN as je,cE as he,bt as $e,b_ as qe,cF as ie,cG as E,cH as H,cI as J,cJ as L,cK as re,cL as Je,cM as Ke,cN as Ze,bC as pe,am as Q,b8 as ee,cO as Xe,cP as Ye,ai as Qe,ar as we,bm as te,i as Ie,L as Ve,bK as Se,cQ as be,bA as Z,bG as et,bc as ve,bz as N,cR as ae,cS as Ee,bP as ye,cT as tt,cr as nt,K as ot,cU as st,cV as it,c1 as rt,cW as at,cX as ct,bf as lt,cY as dt,cZ as ut,c_ as ft,c$ as gt,bp as mt,d0 as ht,d1 as pt,d2 as wt,d3 as It,d4 as Vt,d5 as St,d6 as bt,d7 as vt,bg as Et,d8 as yt,av as Rt,d9 as Ct,da as Pt,H as Tt,b7 as xt,bk as Mt,db as Dt,dc as Ot,J as _t,dd as Lt,bo as Wt,de as At,df as kt,bq as Ft,dg as Nt,bs as Ut,dh as Gt,bR as Bt,di as Ht,dj as zt,bF as jt,bj as $t,dk as qt,bh as Jt,bn as Kt,dl as Zt,dm as Xt,dn as Yt,dp as Qt,dq as en,dr as tn,ds as nn,dt as on,bl as sn,bZ as rn,du as an,bT as cn,dv as ln,bS as dn,bv as un,br as fn,ct as gn,dw as mn,dx as hn,bI as pn,dy as wn,M as In,dz as Vn,dA as Sn,bw as bn,dB as vn,bD as En,bJ as yn,dC as Rn,dD as Cn,bM as Pn,dE as Tn,dF as xn,dG as Mn,bY as Dn}from"./Settings-RsdfmMXh.js";import"./Texture-Ggh33DNM.js";import"./cornerstoneEngine-qfeli3aA.js";function On(e){return!!(e&&typeof e.setVolumes=="function"&&typeof e.addVolumes=="function")}async function _n(e,t,n,o=!1,i=!1){const s=n.map(r=>{const a=e.getViewport(r);if(!a)throw new Error(`Viewport with Id ${r} does not exist`);if(!On(a))throw new Error("setVolumesForViewports only supports viewports that implement setVolumes");return a});await Promise.all(s.map(r=>r.setVolumes(t,o,i)))}function Ln(e,t,n=0){const o=e.getOpenGLRenderWindow?.()?.getCanvas?.();o&&(o.addEventListener("webglcontextlost",()=>{console.warn(`CornerstoneRender: WebGL context lost (renderingEngine=${t}, context=${n})`),T(M,R.WEBGL_CONTEXT_LOST,{renderingEngineId:t,contextIndex:n})}),o.addEventListener("webglcontextrestored",()=>{T(M,R.WEBGL_CONTEXT_RESTORED,{renderingEngineId:t,contextIndex:n})}))}class Wn extends We{constructor(t){super(t),this._renderFlaggedViewports=()=>{this._throwIfDestroyed(),this.offscreenMultiRenderWindow&&this.performVtkDrawCall();const n=this._getViewportsAsArray(),o=[];for(let i=0;i<n.length;i++){const s=n[i];if(this._needsRender.has(s.id)){const r=this.renderViewportUsingCustomOrVtkPipeline(s);if(o.push(r),s.setRendered(),this._needsRender.delete(s.id),this._needsRender.size===0)break}}this._animationFrameSet=!1,this._animationFrameHandle=null,o.forEach(i=>{i?.element&&T(i.element,R.IMAGE_RENDERED,i)})},this.useCPURendering||this.ensureOffscreenResources()}ensureOffscreenResources(){this.offscreenMultiRenderWindow||(this.offscreenMultiRenderWindow=Ae.newInstance(),this.offScreenCanvasContainer=document.createElement("div"),this.offscreenMultiRenderWindow.setContainer(this.offScreenCanvasContainer),Ln(this.offscreenMultiRenderWindow,this.id))}enableVTKjsDrivenViewport(t){this.ensureOffscreenResources();const o=this._getViewportsAsArray().filter(l=>ne(l.type)===!1),i=o.map(l=>l.canvas),s=F(t.element);i.push(s);const{offScreenCanvasWidth:r,offScreenCanvasHeight:a}=this._resizeOffScreenCanvas(i),c=this._resize(o,r,a),d={...t,canvas:s};this.addVtkjsDrivenViewport(d,{offScreenCanvasWidth:r,offScreenCanvasHeight:a,xOffset:c})}addVtkjsDrivenViewport(t,n){this.ensureOffscreenResources();const{element:o,canvas:i,viewportId:s,type:r,defaultOptions:a}=t;o.tabIndex=-1,ke(o);const{offScreenCanvasWidth:c,offScreenCanvasHeight:d,xOffset:l}=n,{sxStartDisplayCoords:u,syStartDisplayCoords:f,sxEndDisplayCoords:m,syEndDisplayCoords:w,sx:V,sy:h,sWidth:g,sHeight:b}=this._getViewportCoordsOnOffScreenCanvas(t,c,d,l);this.offscreenMultiRenderWindow.addRenderer({viewport:[u,f,m,w],id:s,background:a.background?a.background:[0,0,0]});const S={id:s,element:o,renderingEngineId:this.id,type:r,canvas:i,sx:V,sy:h,sWidth:g,sHeight:b,defaultOptions:a||{}},v=Fe(t);if(!v)throw new Error(`Viewport Type ${r} is not supported`);const p=new v(S);p.requestedType=t.requestedType??r,this._viewports.set(s,p);const y={element:o,viewportId:s,renderingEngineId:this.id};p.suppressEvents||T(M,R.ELEMENT_ENABLED,y)}setVtkjsDrivenViewports(t){if(t.length){const n=t.map(r=>F(r.element));n.forEach(r=>{const a=window.devicePixelRatio||1,c=r.getBoundingClientRect();r.width=c.width*a,r.height=c.height*a});const{offScreenCanvasWidth:o,offScreenCanvasHeight:i}=this._resizeOffScreenCanvas(n);let s=0;for(let r=0;r<t.length;r++){const a=t[r],c=n[r],d={...a,canvas:c};this.addVtkjsDrivenViewport(d,{offScreenCanvasWidth:o,offScreenCanvasHeight:i,xOffset:s}),s+=c.width}}}_resizeVTKViewports(t,n=!0,o=!0){const i=t.map(s=>F(s.element));if(i.forEach(s=>{const r=window.devicePixelRatio||1;s.width=s.clientWidth*r,s.height=s.clientHeight*r}),i.length){const{offScreenCanvasWidth:s,offScreenCanvasHeight:r}=this._resizeOffScreenCanvas(i);this._resize(t,s,r)}t.forEach(s=>{const r=s.getCamera(),a=s.getRotation(),{flipHorizontal:c}=r,d=s;d.resetViewStateForResize?d.resetViewStateForResize():d.resetCameraForResize();const l=s.getDisplayArea();n&&(l?(c&&s.setCamera({flipHorizontal:c}),a&&s.setViewPresentation({rotation:a})):s.setCamera(r))}),o&&this.render()}performVtkDrawCall(){const{offscreenMultiRenderWindow:t}=this,n=t.getRenderWindow(),o=t.getRenderers();if(o.length){for(let i=0;i<o.length;i++){const{renderer:s,id:r}=o[i],a=r.split("::")[0];this._needsRender.has(a)?s.setDraw(!0):s.setDraw(!1)}n.render();for(let i=0;i<o.length;i++)o[i].renderer.setDraw(!1)}}renderViewportUsingCustomOrVtkPipeline(t){let n;if(t.sWidth<oe||t.sHeight<oe){console.warn("Viewport is too small",t.sWidth,t.sHeight);return}if(ne(t.type)===!0)n=t.customRenderViewportToCanvas();else{if(!this.offscreenMultiRenderWindow)throw new Error("GPU not available, and using a viewport with no custom render pipeline.");const{offscreenMultiRenderWindow:o}=this,r=o.getOpenGLRenderWindow().get3DContext().canvas;n=this._renderViewportFromVtkCanvasToOnscreenCanvas(t,r)}return n}_renderViewportFromVtkCanvasToOnscreenCanvas(t,n){const{element:o,canvas:i,sx:s,sy:r,sWidth:a,sHeight:c,id:d,renderingEngineId:l,suppressEvents:u}=t,{width:f,height:m}=i;return i.getContext("2d").drawImage(n,s,r,a,c,0,0,f,m),{element:o,suppressEvents:u,viewportId:d,renderingEngineId:l,viewportStatus:t.viewportStatus}}_resizeOffScreenCanvas(t){const{offScreenCanvasContainer:n,offscreenMultiRenderWindow:o}=this,i=Math.max(...t.map(r=>r.height));let s=0;return t.forEach(r=>{s+=r.width}),n.width=s,n.height=i,o.resize(),{offScreenCanvasWidth:s,offScreenCanvasHeight:i}}_resize(t,n,o){let i=0;for(let s=0;s<t.length;s++){const r=t[s],{sxStartDisplayCoords:a,syStartDisplayCoords:c,sxEndDisplayCoords:d,syEndDisplayCoords:l,sx:u,sy:f,sWidth:m,sHeight:w}=this._getViewportCoordsOnOffScreenCanvas(r,n,o,i);i+=r.canvas.width,r.sx=u,r.sy=f,r.sWidth=m,r.sHeight=w,this.offscreenMultiRenderWindow.getRenderer(r.id).setViewport(a,c,d,l)}return i}_getViewportCoordsOnOffScreenCanvas(t,n,o,i){const{canvas:s}=t,{width:r,height:a}=s,c=i,d=0,l=c/n,u=d+(o-a)/o,f=r/n,m=a/o;return{sxStartDisplayCoords:l,syStartDisplayCoords:u,sxEndDisplayCoords:l+f,syEndDisplayCoords:u+m,sx:c,sy:d,sWidth:r,sHeight:a}}}function No(e){return!!(e&&typeof e.canvasToWorld=="function"&&typeof e.worldToCanvas=="function")}function Uo(e){return!!(e&&typeof e.getZoom=="function"&&typeof e.setZoom=="function")}function Go(e){return!!(e&&typeof e.getPan=="function"&&typeof e.setPan=="function")}function An(e){return!!(e&&typeof e.getFrameOfReferenceUID=="function")}class kn{constructor(){this._targetsEventListeners=new Map}addEventListener(t,n,o,i){let s=this._targetsEventListeners.get(t);s||(s=new ue(t),this._targetsEventListeners.set(t,s)),s.addEventListener(n,o,i)}removeEventListener(t,n,o,i){const s=this._targetsEventListeners.get(t);s&&(s.removeEventListener(n,o,i),s.isEmpty&&this._targetsEventListeners.delete(t))}reset(){Array.from(this._targetsEventListeners.entries()).forEach(([t,n])=>{n.reset(),this._targetsEventListeners.delete(t)})}}const Fn=Object.freeze(Object.defineProperty({__proto__:null,MultiTargetEventListenerManager:kn,TargetEventListeners:ue},Symbol.toStringTag,{value:"Module"}));function Nn(e,t){const n=e.getSize();for(let o=0;o<n;o++){const i=[];e.getNodeValue(o,i),i[1]=i[1]*t,i[2]=i[2]*t,i[3]=i[3]*t,e.setNodeValue(o,i)}}const Un=Symbol("LastRuntimeId"),Gn={},Bn=4294967295,Hn="-";function zn(e,t,n){return jn(e!==null&&typeof e=="object"?e:Gn,Un,(typeof n=="number"&&n>0?n:Bn)>>>0).join(typeof t=="string"?t:Hn)}function jn(e,t,n){let o=e[t];o instanceof Array||(o=[0],Object.defineProperty(e,t,{value:o}));for(let i=!0,s=0;i&&s<o.length;++s){let r=o[s]|0;r<n?(i=!1,r=r+1):(r=0,s+1===o.length&&o.push(0)),o[s]=r}return o}const $n=Ne;function qn(e,t,n=1e-5){return Math.abs(e[0]+t[0])<n&&Math.abs(e[1]+t[1])<n&&Math.abs(e[2]+t[2])<n}function Jn(e,t){return!(e[0]<0||e[0]>=t[0]||e[1]<0||e[1]>=t[1]||e[2]<0||e[2]>=t[2])}function Kn(e,t){return!(e[0]<-P||e[0]>=t[0]+P||e[1]<-P||e[1]>=t[1]+P||e[2]<-P||e[2]>=t[2]+P)}function Zn(e,t){let n;t?n=[Y(t)]:n=z();const o=[];return n.forEach(i=>{const s=e.getActors(),r=i.getViewports().filter(fe);for(const a of r){const c=a.getActors();if(c.length!==s.length)continue;s.every(({uid:l})=>c.find(u=>l===u.uid))&&o.push(a)}}),o}function Re(e,t,n=void 0,o="_thumbnails",i={displayArea:{imageArea:[1,1]}}){if(!e||!(e instanceof HTMLCanvasElement))throw new Error("canvas element is required");const s=!t.imageId,r=!s&&t,a=s&&t,d=`renderGPUViewport-${r.imageId||a.volumeId}`,l=document.createElement("div"),u=window.devicePixelRatio||1;i.displayArea||(i.displayArea={imageArea:[1,1]});const f=e.width,m=e.height;l.style.width=`${f/u+se}px`,l.style.height=`${m/u+se}px`,l.style.visibility="hidden",l.style.position="absolute",document.body.appendChild(l);const w=d.split(":").join("-");l.setAttribute("viewport-id-for-remove",w);const V=F(l),h=Y(o)||new Wn(o);let g=h.getViewport(d);if(!g){const b={viewportId:d,type:s?G.ORTHOGRAPHIC:G.STACK,element:l,defaultOptions:{...i,suppressEvents:!0}};h.enableElement(b),g=h.getViewport(d)}return new Promise(b=>{let S=!1,{viewReference:v}=i;const p=y=>{if(S)return;if(v){const A=v;v=null,g.setViewReference(A),g.render();return}e.getContext("2d").drawImage(V,0,0,V.width,V.height,0,0,e.width,e.height);const I=g.canvasToWorld([0,0]),C=g.canvasToWorld([V.width/u,0]),$=g.canvasToWorld([0,V.height/u]),_=D([0,0,0],g.canvasToWorld([1/u,0]),I),W=D([0,0,0],g.canvasToWorld([0,1/u]),I),q=1;S=!0,l.removeEventListener(R.IMAGE_RENDERED,p),setTimeout(()=>{h.disableElement(d),document.querySelectorAll(`[viewport-id-for-remove="${w}"]`).forEach(Le=>{Le.remove()})},0),b({origin:I,bottomLeft:$,topRight:C,thicknessMm:q,rightVector:_,downVector:W})};l.addEventListener(R.IMAGE_RENDERED,p),s?g.setVolumes([a],!1,!0):g.renderImageObject(t),g.resetCamera(),n==="PT"&&!ge(r)&&g.setProperties({voiRange:{lower:r.minPixelValue,upper:r.maxPixelValue}}),g.render()})}function Ce(e,t,n,o,i){if(t.volumeId)throw new Error("Unsupported volume rendering for CPU");const r=t,a=Ue(e,r,n),c={canvas:e,viewport:a,image:r,renderingTools:{}};c.transform=Ge(c);const d=!0;return new Promise((l,u)=>{Be(c,d),l(null)})}function Xn(e){const{canvas:t,imageId:n,viewReference:o,requestType:i=He.Thumbnail,priority:s=-5,renderingEngineId:r="_thumbnails",useCPURendering:a=!1,thumbnail:c=!1,imageAspect:d=!1,viewportOptions:l}=e,u=o?.volumeId,f=u&&!n,m=o&&l?{...l,viewReference:o}:l,w=a?Ce:Re;return new Promise((V,h)=>{function g(p,y){const{modality:x}=B(me.GENERAL_SERIES,y)||{},I=!f&&p,C=f&&p;I&&(I.isPreScaled=I.isPreScaled||I.preScale?.scaled),c&&(t.height=256,t.width=256),d&&I&&(t.width=I&&t.height*I.width/I.height),t.style.width=`${t.width/devicePixelRatio}px`,t.style.height=`${t.height/devicePixelRatio}px`,C&&a&&h(new Error("CPU rendering of volume not supported")),w(t,p,x,r,m).then(V)}function b(p,y){console.error(p,y),h(p)}function S(p,y,x){return je(p,x).then(I=>{g.call(this,I,p)},I=>{b.call(this,I,p)})}const v={useRGBA:!!a,requestType:i};if(u){const p=O.getVolume(u);p||h(new Error(`Volume id ${u} not found in cache`));const y=p.imageIds[0];g(p,y)}else ze.addRequest(S.bind(null,n,null,v),i,{imageId:n},s)})}function Yn(e){const t=z(),n=[];return t.forEach(o=>{o.getViewports().filter(he).forEach(s=>{s.hasImageURI(e)&&n.push(s)})}),n}function Qn(e,t){const n=eo(e,t);return n?n.index:null}function eo(e,t){const n=t.getImageIds(),o=t.getCurrentImageIdIndex();if(n.length===0)return null;const i=c=>{const d=to(c);if(!d)return null;const l=$e(d.planeNormal,d.imagePositionPatient);return qe(l,e)},s={distance:i(n[o])??1/0,index:o},r=n.slice(o+1);for(let c=0;c<r.length;c++){const d=r[c],l=i(d);if(l!==null)if(l<=s.distance)s.distance=l,s.index=c+o+1;else break}const a=n.slice(0,o);for(let c=a.length-1;c>=0;c--){const d=a[c],l=i(d);if(!(l===null||l===s.distance))if(l<s.distance)s.distance=l,s.index=c;else break}return s.distance===1/0?null:s}function to(e){const t=B(me.IMAGE_PLANE,e);if(!t||!(t.rowCosines instanceof Array&&t.rowCosines.length===3)||!(t.columnCosines instanceof Array&&t.columnCosines.length===3)||!(t.imagePositionPatient instanceof Array&&t.imagePositionPatient.length===3))return null;const{rowCosines:n,columnCosines:o,imagePositionPatient:i}=t,s=ie(E(),...n),r=ie(E(),...o),a=H(E(),s,r);return{rowCosines:n,columnCosines:o,imagePositionPatient:i,planeNormal:a}}function no(e){const{width:t,height:n}=e.getCanvas(),{sliceToIndexMatrix:o,indexToSliceMatrix:i}=e.getSliceViewInfo(),s=J(e,[0,0]),r=J(e,[t-1,0]),a=J(e,[0,n-1]),c=D(E(),r,s),d=D(E(),a,s),l=H(E(),c,d);L(c,c),L(d,d),L(l,l);const u=Math.max(Math.abs(c[0]),Math.abs(c[1]),Math.abs(c[2])),f=Math.max(Math.abs(d[0]),Math.abs(d[1]),Math.abs(d[2]));if(!re(1,u)||!re(1,f))throw new Error("getCurrentVolumeViewportSlice is not available for rotate/oblique viewports");const{voxelManager:m}=e.getImageData(),w=e.getSliceViewInfo(),V=m.getSliceData(w);return{width:w.width,height:w.height,scalarData:V,sliceToIndexMatrix:o,indexToSliceMatrix:i}}const oo=.05;function so(e,t){const n=e.getSliceIndex(),o=t.getSliceIndex(),i=B("imagePlaneModule",n.toString()),s=B("imagePlaneModule",o.toString());if(!i||!s){console.log("Viewport spatial registration requires image plane module");return}const{imageOrientationPatient:r}=s;if(!i.imageOrientationPatient.every((f,m)=>Math.abs(f-r[m])<oo)){console.log("Viewport spatial registration only supported for same orientation (hence translation only) for now",i?.imageOrientationPatient,s?.imageOrientationPatient);return}const c=i.imagePositionPatient,d=s.imagePositionPatient,l=Je(E(),c,d),u=Ke(Ze(),l);pe.add([e.id,t.id],u)}function io(e){const{imageData:t,dimensions:n}=e.getImageData()||{};if(!t||!n)return[];const{canvas:o}=e,i=window.devicePixelRatio,s=[0,0],r=[o.width/i,0],a=[o.width/i,o.height/i],c=[0,o.height/i],d=e.canvasToWorld(s),l=e.canvasToWorld(r),u=e.canvasToWorld(a),f=e.canvasToWorld(c),m=t.worldToIndex(d),w=t.worldToIndex(l),V=t.worldToIndex(u),h=t.worldToIndex(f);return ro({dimensions:n,imageData:t,topLeftImage:m,topRightImage:w,bottomRightImage:V,bottomLeftImage:h,topLeftWorld:d,topRightWorld:l,bottomRightWorld:u,bottomLeftWorld:f})}function ro({dimensions:e,imageData:t,topLeftImage:n,topRightImage:o,bottomRightImage:i,bottomLeftImage:s,topLeftWorld:r,topRightWorld:a,bottomRightWorld:c,bottomLeftWorld:d}){const l=k(n,e)?r:t.indexToWorld([0,0,0]),u=k(o,e)?a:t.indexToWorld([e[0]-1,0,0]),f=k(i,e)?c:t.indexToWorld([e[0]-1,e[1]-1,0]),m=k(s,e)?d:t.indexToWorld([0,e[1]-1,0]);return[l,u,m,f]}function k(e,t){return e[0]>0||e[0]<t[0]-1||e[1]>0||e[1]<t[1]-1||e[2]>0||e[2]<t[2]-1}function j(e){if(!e)return;const{viewportUid:t,renderingEngineUid:n}=e.dataset;return Pe(t,n)}function Pe(e,t){if(!t||!e)return;const n=Y(t);if(!n||n.hasBeenDestroyed)return;const o=n.getViewport(e);if(!o)return;const i=An(o)?o.getFrameOfReferenceUID():void 0;return{viewport:o,renderingEngine:n,viewportId:e,renderingEngineId:t,FrameOfReferenceUID:i}}function Bo(e){const t=z();for(let n=0;n<t.length;n++){const o=t[n];if(o.getViewport(e))return Pe(e,o.id)}}function Ho(){const e=[];return z().forEach(n=>{n.getViewports().forEach(({element:i})=>{e.push(j(i))})}),e}function ao(e){const t=j(e);if(!t)return;const{viewport:n}=t;if(!(n instanceof Q))throw new Error(`An image can only be fetched for a stack viewport and not for a viewport of type: ${n.type}`);return n.getCornerstoneImage()}async function co({viewport:e,options:t={}}){const n=e.getRenderingEngine();let o=t.volumeId||`${ee()}`;o.split(":").length===0&&(o=`${Xe()}:${o}`);const{id:i,element:s}=e,r=t.viewportId||i,a=e.getImageIds(),c=e.getViewPresentation(),d=e.getViewReference();n.enableElement({viewportId:r,type:G.ORTHOGRAPHIC,element:s,defaultOptions:{background:t.background,orientation:t.orientation}}),(await Ye(o,{imageIds:a})).load();const u=n.getViewport(r);await _n(n,[{volumeId:o}],[r]);const f=()=>{u.render(),s.removeEventListener(R.VOLUME_VIEWPORT_NEW_VOLUME,f)};return s.addEventListener(R.VOLUME_VIEWPORT_NEW_VOLUME,f),u.setViewPresentation(c),u.setViewReference(d),u.render(),u}async function lo({viewport:e,options:t}){const n=e,{id:o,element:i}=n,s=e.getRenderingEngine(),{background:r}=t,a=t.viewportId||o,c=O.getVolume(n.getVolumeId());if(!(c instanceof Qe))throw new Error("Currently, you cannot decache a volume that is not an ImageVolume. So, unfortunately, volumes such as nifti (which are basic Volume, without imageIds) cannot be decached.");const d={viewportId:a,type:G.STACK,element:i,defaultOptions:{background:r}},l=n.getViewReference();s.enableElement(d);const u=s.getViewport(a);return await u.setStack(c.imageIds),u.setViewReference(l),u.render(),u}function Te(e,t=2){if(Array.isArray(e))return e.map(i=>Te(i,t)).join(", ");if(e==null||e==="")return"NaN";e=Number(e);const n=Math.abs(e);if(n<1e-4)return`${e}`;const o=n>=100?t-2:n>=10?t-1:n>=1?t:n>=.1?t+1:n>=.01?t+2:n>=.001?t+3:t+4;return e.toFixed(o)}function uo(e){return Math.round(e/P)*P}function fo(e,t,n){const o=e.length===t*n*4,i=e.length===t*n*3;if(o||i){const s=new Float32Array(t*n);let r=0,a=0;const c=o?4:3;for(let d=0;d<t;d++)for(let l=0;l<n;l++){const u=e[r],f=e[r+1],m=e[r+2];s[a]=(u+f+m)/3,r+=c,a++}return s}else return e}function go(e){if(e instanceof we)return O.getVolume(e.getVolumeId()).imageIds;if(e.getImageIds)return e.getImageIds()}function mo(e,t){const n=[...e];return t>=n.length?(ce(n),n):(ce(n),n.slice(0,t))}function ce(e){for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}}function K(e){const t=e.toString(16);return t.length==1?"0"+t:t}function ho(e,t,n){return"#"+K(e)+K(t)+K(n)}function po(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}const wo=Object.freeze(Object.defineProperty({__proto__:null,hexToRgb:po,rgbToHex:ho},Symbol.toStringTag,{value:"Module"}));function Io(e,t){if(e===t)return!0;if(e==null||t==null)return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch(n){return console.debug("Error in JSON.stringify during deep comparison:",n),e===t}}function xe(e,t){const n=e,o=n.getActors?.()??[];return(t?o.find(s=>s.referencedId===t)??o.find(s=>s.referencedId?.endsWith(`:${t}`)):void 0)?.referencedId??(t?te(t):void 0)??n.getDefaultActor?.()?.referencedId}function Me(e,t,n){if(!n)throw new Error("getVolume is required, use the utilities export instead");if(Ie(e)){const o=xe(e,t),i=o?n(o):void 0,s=e.getImageData?.();return{modality:i?.metadata?.Modality??s?.metadata?.Modality,isPreScaled:le(i?.scaling)}}if(typeof e.setVolumes=="function"){const i=t?te(t):e.getVolumeId(),s=i?n(i):void 0;return{modality:s?.metadata?.Modality,isPreScaled:le(s?.scaling)}}if(typeof e.setStack=="function"){const o=e,{preScale:i}=o.getImageData()||{};return{modality:o.modality,isPreScaled:!!i?.scaled}}}function le(e){return!!e&&Object.keys(e).length>0}function Vo(e,t,n){const o=Me(e,t,n);if(!o)throw new Error("Invalid viewport type");return o.modality}function So(e){const{imageIdGroups:t,splittingTag:n}=Ve(e);return{isDynamicVolume:t.length>1,timePoints:t,splittingTag:n}}function bo(e,t){const n=e.length,{rescaleSlope:o,rescaleIntercept:i,suvbw:s}=t;if(t.modality==="PT"&&typeof s=="number")for(let r=0;r<n;r++)e[r]=s*(e[r]*o+i);else for(let r=0;r<n;r++)e[r]=e[r]*o+i;return e}function De(e,t,n){return Math.min(Math.max(t,e),n)}function Oe(e,t){if(!j(e.element))throw new Error("Scroll::Viewport is not enabled (it might be disabled)");if(e instanceof Q&&e.getImageIds().length===0)throw new Error("Scroll::Stack Viewport has no images");const{volumeId:o,delta:i,scrollSlabs:s}=t;if(e instanceof we)vo(e,o,i,s);else{if(typeof e.getCurrentImageIdIndex!="function"||typeof e.scroll!="function")return;const r=e.getCurrentImageIdIndex();if(r+i>e.getImageIds().length-1||r+i<0){const a={imageIdIndex:r,direction:i};T(M,R.STACK_SCROLL_OUT_OF_BOUNDS,a)}e.scroll(i,t.debounceLoading,t.loop)}}function vo(e,t,n,o=!1){const i=o,{numScrollSteps:s,currentStepIndex:r,sliceRangeInfo:a}=Se(e,t,i);if(s===0||!a)return;const{sliceRange:c,spacingInNormalDirection:d,camera:l}=a,{focalPoint:u,viewPlaneNormal:f,position:m}=l,{newFocalPoint:w,newPosition:V}=be(u,m,c,f,d,n);e.setCamera({focalPoint:w,position:V}),e.render();const h=r+n,g={volumeId:t,viewport:e,delta:n,desiredStepIndex:h,currentStepIndex:r,numScrollSteps:s,currentImageId:e.getCurrentImageId()};(h>s||h<0)&&e.getCurrentImageId()?T(M,R.VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS,g):T(M,R.VOLUME_VIEWPORT_SCROLL,g)}async function Eo(e,t={}){const{imageIndex:n,debounceLoading:o,volumeId:i}=t,s=j(e);if(!s)throw new Error("Element has been disabled");const{viewport:r}=s,{imageIndex:a,numberOfSlices:c}=yo(r,o),l=Ro(c,n)-a;Oe(r,{delta:l,debounceLoading:o,volumeId:i})}function yo(e,t){return e instanceof Q?{numberOfSlices:e.getImageIds().length,imageIndex:t?e.getTargetImageIdIndex():e.getCurrentImageIdIndex()}:{numberOfSlices:e.getNumberOfSlices(),imageIndex:e.getSliceIndex()}}function Ro(e,t){const n=e-1;return De(t,0,n)}function Co(e,t,n={}){const o=O.getVolume(e);if(!o)throw new Error(`Referenced volume with id ${e} does not exist.`);const{metadata:i,spacing:s,direction:r,dimensions:a}=o,{minX:c,maxX:d,minY:l,maxY:u,minZ:f,maxZ:m}=t,w=[Math.min(c,d),Math.min(l,u),Math.min(f,m)],V=Z(o.imageData,w),h=[Math.abs(d-c)+1,Math.abs(u-l)+1,Math.abs(m-f)+1],{targetBuffer:g}=n,b={metadata:i,dimensions:h,spacing:s,origin:V,direction:r,targetBuffer:g,scalarData:g?.type==="Float32Array"?new Float32Array(h[0]*h[1]*h[2]):void 0},S=et(ee(),b),v=S.voxelManager.getCompleteScalarDataArray(),p=h[0]*h[1],y=a[0]*a[1],x=o.voxelManager.getCompleteScalarDataArray();for(let I=0;I<h[2];I++)for(let C=0;C<h[1];C++){const $=Z(S.imageData,[0,C,I]),_=ve(o.imageData,$),W=_[2]*y+_[1]*a[0]+_[0],q=x.slice(W,W+h[0]),A=I*p+C*h[0];v.set(q,A)}return S.voxelManager.setCompleteScalarDataArray(v),S}function Po(e,t){const{viewUp:n,viewPlaneNormal:o}=t,i=N(e,[0,0,0]),s=ae(E(),n),r=ae(E(),o),a=H(E(),s,r),c=D(E(),N(e,s),i),d=D(E(),N(e,r),i);L(c,c),L(d,d);const l=H(E(),c,d);return{worldVecRowDir:a,worldVecColDir:s,worldVecSliceDir:r,ijkVecRowDir:l,ijkVecColDir:c,ijkVecSliceDir:d}}function To(e,t,n,o){const[i,s,r]=t,a=i*s;let c=0,d=0,l=0;const[u,f,m]=n.map(Math.round);for(let g=m-o;g<=m+o;g++)if(!(g<0||g>=r)){for(let b=f-o;b<=f+o;b++)if(!(b<0||b>=s))for(let S=u-o;S<=u+o;S++){if(S<0||S>=i)continue;const v=g*a+b*i+S,p=e[v];c+=p,d+=p*p,l++}}if(l===0){const g=m*a+f*i+u;return g>=0&&g<e.length?{mean:e[g],stdDev:0,count:1}:{mean:0,stdDev:0,count:0}}const w=c/l,V=d/l-w*w,h=Math.sqrt(Math.max(0,V));return{mean:w,stdDev:h,count:l}}const de=1e-6;function xo(e,t){const{lower:n,upper:o}=t.voiRange,i=o-n,s=t.VOILUTFunction,r=a=>t.invert===!0?1-a:a;if(s===Ee.SAMPLED_SIGMOID||s==="SIGMOID"){const{windowCenter:a,windowWidth:c}=ye(n,o),d=Math.max(Math.abs(c),1e-12);return r(1/(1+Math.exp(-4*(e-a)/d)))}return i===0||!Number.isFinite(i)?r(0):r(U((e-n)/i))}function X(e,t){const{lower:n,upper:o}=t.voiRange,i=t.VOILUTFunction,s=t.invert===!0?U(1-U(e)):U(e);if(i===Ee.SAMPLED_SIGMOID||i==="SIGMOID"){const{windowCenter:a,windowWidth:c}=ye(n,o),d=_e(s,de,1-de);return tt(d,a,c)}const r=o-n;return r===0||!Number.isFinite(r)?n:n+s*r}function Mo(e,t,n){const o=Math.min(e,t),i=Math.max(e,t),s=X(o,n),r=X(i,n);return{rawMin:Math.min(s,r),rawMax:Math.max(s,r)}}function U(e){return Number.isFinite(e)?_e(e,0,1):0}function _e(e,t,n){return Math.min(n,Math.max(t,e))}const{getPixelSpacingInformation:Do,calculateRadiographicPixelSpacing:Oo,getERMF:_o}=nt,Lo=(e,t)=>Vo(e,t,O.getVolume),Wo=(e,t)=>Me(e,t,O.getVolume),zo=Object.freeze(Object.defineProperty({__proto__:null,ECGUtilities:ft,FrameRange:gt,HistoryMemo:mt,PointsManager:at,ProgressiveIterator:it,RLEVoxelMap:st,VideoUtilities:ht,VoxelManager:ot,WSIUtilities:pt,actorIsA:wt,applyPreset:It,asArray:Vt,autoLoad:St,buildMetadata:bt,calculateNeighborhoodStats:To,calculateRadiographicPixelSpacing:Oo,calculateSpacingBetweenImageIds:vt,calculateViewportsSpatialRegistration:so,calibratedPixelSpacingMetadataProvider:$n,clamp:ut,clip:De,clonePoint3:Et,color:wo,colormap:yt,convertColorArrayToRgbString:Rt,convertStackToVolumeViewport:co,convertToGrayscale:fo,convertVolumeToStackViewport:lo,createLinearRGBTransferFunction:Ct,createSigmoidRGBTransferFunction:Pt,createSubVolume:Co,decimate:Tt,deepClone:xt,deepEqual:Io,deepMerge:Mt,eventListener:Fn,fnv1aHash:Dt,generateFrameImageId:Ot,generateVolumePropsFromImageIds:_t,genericMetadataProvider:Lt,genericViewportDisplaySetMetadataProvider:Wt,getAcquisitionPlaneOrientation:At,getBufferConfiguration:kt,getClosestImageId:Ft,getClosestStackImageIndexForPoint:Qn,getCubeSizeInView:Nt,getCurrentVolumeViewportSlice:no,getDynamicVolumeInfo:So,getERMF:_o,getImageDataMetadata:Ut,getImageLegacy:ao,getImageSliceDataForVolumeViewport:Gt,getMinMax:Bt,getNormalizedAspectRatio:dt,getPixelSpacingInformation:Do,getRandomSampleFromArray:mo,getRuntimeId:zn,getScalingDescriptor:Wo,getScalingParameters:Ht,getSliceRange:zt,getSpacingInNormalDirection:jt,getTargetVolumeAndSpacingInNormalDir:$t,getVOIRangeFromWindowLevel:qt,getViewportContentMode:Jt,getViewportImageCornersInWorld:io,getViewportImageIds:go,getViewportModality:Lo,getViewportsWithImageURI:Yn,getViewportsWithVolumeId:Kt,getVoiFromSigmoidRGBTransferFunction:Zt,getVolumeActorCorners:Xt,getVolumeDirectionVectors:Po,getVolumeId:te,getVolumeSliceRangeInfo:Yt,getVolumeViewReferenceId:Qt,getVolumeViewportScrollInfo:Se,getVolumeViewportsContainingSameVolumes:Zn,handleMultiframe4D:en,hasFloatScalingParameters:tn,hasNaNValues:nn,hasOwn:on,imageIdToURI:sn,imageRetrieveMetadataProvider:ct,imageToWorldCoords:rn,indexAlmostWithinDimensions:Kn,indexWithinDimensions:Jn,invertRgbTransferFunction:an,isEqual:lt,isEqualAbs:cn,isEqualNegative:ln,isGenericViewport:Ie,isImageActor:dn,isNumber:un,isOpposite:qn,isPTPrescaledWithSUV:ge,isValidVolume:fn,isVideoTransferSyntax:gn,jumpToSlice:Eo,loadImageToCanvas:Xn,logger:rt,makeVolumeMetadata:mn,mapMappedBandToRawRange:Mo,mapScalarToViewportVoiIntensity:xo,mapViewportVoiIntensityToScalar:X,planar:hn,pointInShapeCallback:pn,renderToCanvasCPU:Ce,renderToCanvasGPU:Re,resolveGenericViewportVolumeId:xe,rotateToViewCoordinates:wn,roundNumber:Te,roundToPrecision:uo,scaleArray:bo,scaleRgbTransferFunction:Nn,scroll:Oe,snapFocalPointToSlice:be,sortImageIdsAndGetSpacing:In,spatialRegistrationMetadataProvider:pe,splitImageIdsBy4DTags:Ve,transferFunctionUtils:Vn,transformIndexToWorld:Z,transformWorldToIndex:ve,transformWorldToIndexContinuous:N,triggerEvent:T,updatePlaneRestriction:Sn,updateVTKImageDataWithCornerstoneImage:bn,uuidv4:ee,viewportIsInStackMode:vn,viewportIsInVolumeMode:En,viewportSupportsDisplaySetPresentation:yn,viewportSupportsImageSlices:he,viewportSupportsStackCalibration:Rn,viewportSupportsStackCompatibility:Cn,viewportSupportsVolumeActors:fe,viewportSupportsVolumeCompatibility:Pn,viewportSupportsVolumeId:Tn,viewportSupportsVolumeURI:xn,windowLevel:Mn,worldToImageCoords:Dn},Symbol.toStringTag,{value:"Module"}));export{Oe as A,no as B,De as C,qn as D,io as E,fo as F,On as G,kn as M,Wn as T,Ln as a,Pe as b,Bo as c,Ho as d,An as e,Go as f,j as g,Uo as h,zn as i,Io as j,mo as k,Wo as l,Yn as m,Kn as n,Qn as o,so as p,Eo as q,Te as r,_n as s,Jn as t,zo as u,No as v,uo as w,Po as x,Co as y,To as z};
|
|
1
|
+
import{t as T,E as R,e as M,B as We,v as Ae,a as ne,b as F,s as ke,c as Fe,f as oe,cw as ue,c8 as Ne,bW as P,aK as z,cx as fe,aJ as Y,ag as se,V as G,cy as ge,cz as D,cA as Ue,cB as Ge,cC as Be,bL as He,at as O,aO as ze,bi as B,cD as me,bN as je,cE as he,bt as $e,b_ as qe,cF as ie,cG as E,cH as H,cI as J,cJ as L,cK as re,cL as Je,cM as Ke,cN as Ze,bC as pe,am as Q,b8 as ee,cO as Xe,cP as Ye,ai as Qe,ar as we,bm as te,i as Ie,L as Ve,bK as Se,cQ as be,bA as Z,bG as et,bc as ve,bz as N,cR as ae,cS as Ee,bP as ye,cT as tt,cr as nt,K as ot,cU as st,cV as it,c1 as rt,cW as at,cX as ct,bf as lt,cY as dt,cZ as ut,c_ as ft,c$ as gt,bp as mt,d0 as ht,d1 as pt,d2 as wt,d3 as It,d4 as Vt,d5 as St,d6 as bt,d7 as vt,bg as Et,d8 as yt,av as Rt,d9 as Ct,da as Pt,H as Tt,b7 as xt,bk as Mt,db as Dt,dc as Ot,J as _t,dd as Lt,bo as Wt,de as At,df as kt,bq as Ft,dg as Nt,bs as Ut,dh as Gt,bR as Bt,di as Ht,dj as zt,bF as jt,bj as $t,dk as qt,bh as Jt,bn as Kt,dl as Zt,dm as Xt,dn as Yt,dp as Qt,dq as en,dr as tn,ds as nn,dt as on,bl as sn,bZ as rn,du as an,bT as cn,dv as ln,bS as dn,bv as un,br as fn,ct as gn,dw as mn,dx as hn,bI as pn,dy as wn,M as In,dz as Vn,dA as Sn,bw as bn,dB as vn,bD as En,bJ as yn,dC as Rn,dD as Cn,bM as Pn,dE as Tn,dF as xn,dG as Mn,bY as Dn}from"./Settings-CKApE3sg.js";import"./Texture-CFUfIEub.js";import"./cornerstoneEngine-CAd9z_EH.js";function On(e){return!!(e&&typeof e.setVolumes=="function"&&typeof e.addVolumes=="function")}async function _n(e,t,n,o=!1,i=!1){const s=n.map(r=>{const a=e.getViewport(r);if(!a)throw new Error(`Viewport with Id ${r} does not exist`);if(!On(a))throw new Error("setVolumesForViewports only supports viewports that implement setVolumes");return a});await Promise.all(s.map(r=>r.setVolumes(t,o,i)))}function Ln(e,t,n=0){const o=e.getOpenGLRenderWindow?.()?.getCanvas?.();o&&(o.addEventListener("webglcontextlost",()=>{console.warn(`CornerstoneRender: WebGL context lost (renderingEngine=${t}, context=${n})`),T(M,R.WEBGL_CONTEXT_LOST,{renderingEngineId:t,contextIndex:n})}),o.addEventListener("webglcontextrestored",()=>{T(M,R.WEBGL_CONTEXT_RESTORED,{renderingEngineId:t,contextIndex:n})}))}class Wn extends We{constructor(t){super(t),this._renderFlaggedViewports=()=>{this._throwIfDestroyed(),this.offscreenMultiRenderWindow&&this.performVtkDrawCall();const n=this._getViewportsAsArray(),o=[];for(let i=0;i<n.length;i++){const s=n[i];if(this._needsRender.has(s.id)){const r=this.renderViewportUsingCustomOrVtkPipeline(s);if(o.push(r),s.setRendered(),this._needsRender.delete(s.id),this._needsRender.size===0)break}}this._animationFrameSet=!1,this._animationFrameHandle=null,o.forEach(i=>{i?.element&&T(i.element,R.IMAGE_RENDERED,i)})},this.useCPURendering||this.ensureOffscreenResources()}ensureOffscreenResources(){this.offscreenMultiRenderWindow||(this.offscreenMultiRenderWindow=Ae.newInstance(),this.offScreenCanvasContainer=document.createElement("div"),this.offscreenMultiRenderWindow.setContainer(this.offScreenCanvasContainer),Ln(this.offscreenMultiRenderWindow,this.id))}enableVTKjsDrivenViewport(t){this.ensureOffscreenResources();const o=this._getViewportsAsArray().filter(l=>ne(l.type)===!1),i=o.map(l=>l.canvas),s=F(t.element);i.push(s);const{offScreenCanvasWidth:r,offScreenCanvasHeight:a}=this._resizeOffScreenCanvas(i),c=this._resize(o,r,a),d={...t,canvas:s};this.addVtkjsDrivenViewport(d,{offScreenCanvasWidth:r,offScreenCanvasHeight:a,xOffset:c})}addVtkjsDrivenViewport(t,n){this.ensureOffscreenResources();const{element:o,canvas:i,viewportId:s,type:r,defaultOptions:a}=t;o.tabIndex=-1,ke(o);const{offScreenCanvasWidth:c,offScreenCanvasHeight:d,xOffset:l}=n,{sxStartDisplayCoords:u,syStartDisplayCoords:f,sxEndDisplayCoords:m,syEndDisplayCoords:w,sx:V,sy:h,sWidth:g,sHeight:b}=this._getViewportCoordsOnOffScreenCanvas(t,c,d,l);this.offscreenMultiRenderWindow.addRenderer({viewport:[u,f,m,w],id:s,background:a.background?a.background:[0,0,0]});const S={id:s,element:o,renderingEngineId:this.id,type:r,canvas:i,sx:V,sy:h,sWidth:g,sHeight:b,defaultOptions:a||{}},v=Fe(t);if(!v)throw new Error(`Viewport Type ${r} is not supported`);const p=new v(S);p.requestedType=t.requestedType??r,this._viewports.set(s,p);const y={element:o,viewportId:s,renderingEngineId:this.id};p.suppressEvents||T(M,R.ELEMENT_ENABLED,y)}setVtkjsDrivenViewports(t){if(t.length){const n=t.map(r=>F(r.element));n.forEach(r=>{const a=window.devicePixelRatio||1,c=r.getBoundingClientRect();r.width=c.width*a,r.height=c.height*a});const{offScreenCanvasWidth:o,offScreenCanvasHeight:i}=this._resizeOffScreenCanvas(n);let s=0;for(let r=0;r<t.length;r++){const a=t[r],c=n[r],d={...a,canvas:c};this.addVtkjsDrivenViewport(d,{offScreenCanvasWidth:o,offScreenCanvasHeight:i,xOffset:s}),s+=c.width}}}_resizeVTKViewports(t,n=!0,o=!0){const i=t.map(s=>F(s.element));if(i.forEach(s=>{const r=window.devicePixelRatio||1;s.width=s.clientWidth*r,s.height=s.clientHeight*r}),i.length){const{offScreenCanvasWidth:s,offScreenCanvasHeight:r}=this._resizeOffScreenCanvas(i);this._resize(t,s,r)}t.forEach(s=>{const r=s.getCamera(),a=s.getRotation(),{flipHorizontal:c}=r,d=s;d.resetViewStateForResize?d.resetViewStateForResize():d.resetCameraForResize();const l=s.getDisplayArea();n&&(l?(c&&s.setCamera({flipHorizontal:c}),a&&s.setViewPresentation({rotation:a})):s.setCamera(r))}),o&&this.render()}performVtkDrawCall(){const{offscreenMultiRenderWindow:t}=this,n=t.getRenderWindow(),o=t.getRenderers();if(o.length){for(let i=0;i<o.length;i++){const{renderer:s,id:r}=o[i],a=r.split("::")[0];this._needsRender.has(a)?s.setDraw(!0):s.setDraw(!1)}n.render();for(let i=0;i<o.length;i++)o[i].renderer.setDraw(!1)}}renderViewportUsingCustomOrVtkPipeline(t){let n;if(t.sWidth<oe||t.sHeight<oe){console.warn("Viewport is too small",t.sWidth,t.sHeight);return}if(ne(t.type)===!0)n=t.customRenderViewportToCanvas();else{if(!this.offscreenMultiRenderWindow)throw new Error("GPU not available, and using a viewport with no custom render pipeline.");const{offscreenMultiRenderWindow:o}=this,r=o.getOpenGLRenderWindow().get3DContext().canvas;n=this._renderViewportFromVtkCanvasToOnscreenCanvas(t,r)}return n}_renderViewportFromVtkCanvasToOnscreenCanvas(t,n){const{element:o,canvas:i,sx:s,sy:r,sWidth:a,sHeight:c,id:d,renderingEngineId:l,suppressEvents:u}=t,{width:f,height:m}=i;return i.getContext("2d").drawImage(n,s,r,a,c,0,0,f,m),{element:o,suppressEvents:u,viewportId:d,renderingEngineId:l,viewportStatus:t.viewportStatus}}_resizeOffScreenCanvas(t){const{offScreenCanvasContainer:n,offscreenMultiRenderWindow:o}=this,i=Math.max(...t.map(r=>r.height));let s=0;return t.forEach(r=>{s+=r.width}),n.width=s,n.height=i,o.resize(),{offScreenCanvasWidth:s,offScreenCanvasHeight:i}}_resize(t,n,o){let i=0;for(let s=0;s<t.length;s++){const r=t[s],{sxStartDisplayCoords:a,syStartDisplayCoords:c,sxEndDisplayCoords:d,syEndDisplayCoords:l,sx:u,sy:f,sWidth:m,sHeight:w}=this._getViewportCoordsOnOffScreenCanvas(r,n,o,i);i+=r.canvas.width,r.sx=u,r.sy=f,r.sWidth=m,r.sHeight=w,this.offscreenMultiRenderWindow.getRenderer(r.id).setViewport(a,c,d,l)}return i}_getViewportCoordsOnOffScreenCanvas(t,n,o,i){const{canvas:s}=t,{width:r,height:a}=s,c=i,d=0,l=c/n,u=d+(o-a)/o,f=r/n,m=a/o;return{sxStartDisplayCoords:l,syStartDisplayCoords:u,sxEndDisplayCoords:l+f,syEndDisplayCoords:u+m,sx:c,sy:d,sWidth:r,sHeight:a}}}function No(e){return!!(e&&typeof e.canvasToWorld=="function"&&typeof e.worldToCanvas=="function")}function Uo(e){return!!(e&&typeof e.getZoom=="function"&&typeof e.setZoom=="function")}function Go(e){return!!(e&&typeof e.getPan=="function"&&typeof e.setPan=="function")}function An(e){return!!(e&&typeof e.getFrameOfReferenceUID=="function")}class kn{constructor(){this._targetsEventListeners=new Map}addEventListener(t,n,o,i){let s=this._targetsEventListeners.get(t);s||(s=new ue(t),this._targetsEventListeners.set(t,s)),s.addEventListener(n,o,i)}removeEventListener(t,n,o,i){const s=this._targetsEventListeners.get(t);s&&(s.removeEventListener(n,o,i),s.isEmpty&&this._targetsEventListeners.delete(t))}reset(){Array.from(this._targetsEventListeners.entries()).forEach(([t,n])=>{n.reset(),this._targetsEventListeners.delete(t)})}}const Fn=Object.freeze(Object.defineProperty({__proto__:null,MultiTargetEventListenerManager:kn,TargetEventListeners:ue},Symbol.toStringTag,{value:"Module"}));function Nn(e,t){const n=e.getSize();for(let o=0;o<n;o++){const i=[];e.getNodeValue(o,i),i[1]=i[1]*t,i[2]=i[2]*t,i[3]=i[3]*t,e.setNodeValue(o,i)}}const Un=Symbol("LastRuntimeId"),Gn={},Bn=4294967295,Hn="-";function zn(e,t,n){return jn(e!==null&&typeof e=="object"?e:Gn,Un,(typeof n=="number"&&n>0?n:Bn)>>>0).join(typeof t=="string"?t:Hn)}function jn(e,t,n){let o=e[t];o instanceof Array||(o=[0],Object.defineProperty(e,t,{value:o}));for(let i=!0,s=0;i&&s<o.length;++s){let r=o[s]|0;r<n?(i=!1,r=r+1):(r=0,s+1===o.length&&o.push(0)),o[s]=r}return o}const $n=Ne;function qn(e,t,n=1e-5){return Math.abs(e[0]+t[0])<n&&Math.abs(e[1]+t[1])<n&&Math.abs(e[2]+t[2])<n}function Jn(e,t){return!(e[0]<0||e[0]>=t[0]||e[1]<0||e[1]>=t[1]||e[2]<0||e[2]>=t[2])}function Kn(e,t){return!(e[0]<-P||e[0]>=t[0]+P||e[1]<-P||e[1]>=t[1]+P||e[2]<-P||e[2]>=t[2]+P)}function Zn(e,t){let n;t?n=[Y(t)]:n=z();const o=[];return n.forEach(i=>{const s=e.getActors(),r=i.getViewports().filter(fe);for(const a of r){const c=a.getActors();if(c.length!==s.length)continue;s.every(({uid:l})=>c.find(u=>l===u.uid))&&o.push(a)}}),o}function Re(e,t,n=void 0,o="_thumbnails",i={displayArea:{imageArea:[1,1]}}){if(!e||!(e instanceof HTMLCanvasElement))throw new Error("canvas element is required");const s=!t.imageId,r=!s&&t,a=s&&t,d=`renderGPUViewport-${r.imageId||a.volumeId}`,l=document.createElement("div"),u=window.devicePixelRatio||1;i.displayArea||(i.displayArea={imageArea:[1,1]});const f=e.width,m=e.height;l.style.width=`${f/u+se}px`,l.style.height=`${m/u+se}px`,l.style.visibility="hidden",l.style.position="absolute",document.body.appendChild(l);const w=d.split(":").join("-");l.setAttribute("viewport-id-for-remove",w);const V=F(l),h=Y(o)||new Wn(o);let g=h.getViewport(d);if(!g){const b={viewportId:d,type:s?G.ORTHOGRAPHIC:G.STACK,element:l,defaultOptions:{...i,suppressEvents:!0}};h.enableElement(b),g=h.getViewport(d)}return new Promise(b=>{let S=!1,{viewReference:v}=i;const p=y=>{if(S)return;if(v){const A=v;v=null,g.setViewReference(A),g.render();return}e.getContext("2d").drawImage(V,0,0,V.width,V.height,0,0,e.width,e.height);const I=g.canvasToWorld([0,0]),C=g.canvasToWorld([V.width/u,0]),$=g.canvasToWorld([0,V.height/u]),_=D([0,0,0],g.canvasToWorld([1/u,0]),I),W=D([0,0,0],g.canvasToWorld([0,1/u]),I),q=1;S=!0,l.removeEventListener(R.IMAGE_RENDERED,p),setTimeout(()=>{h.disableElement(d),document.querySelectorAll(`[viewport-id-for-remove="${w}"]`).forEach(Le=>{Le.remove()})},0),b({origin:I,bottomLeft:$,topRight:C,thicknessMm:q,rightVector:_,downVector:W})};l.addEventListener(R.IMAGE_RENDERED,p),s?g.setVolumes([a],!1,!0):g.renderImageObject(t),g.resetCamera(),n==="PT"&&!ge(r)&&g.setProperties({voiRange:{lower:r.minPixelValue,upper:r.maxPixelValue}}),g.render()})}function Ce(e,t,n,o,i){if(t.volumeId)throw new Error("Unsupported volume rendering for CPU");const r=t,a=Ue(e,r,n),c={canvas:e,viewport:a,image:r,renderingTools:{}};c.transform=Ge(c);const d=!0;return new Promise((l,u)=>{Be(c,d),l(null)})}function Xn(e){const{canvas:t,imageId:n,viewReference:o,requestType:i=He.Thumbnail,priority:s=-5,renderingEngineId:r="_thumbnails",useCPURendering:a=!1,thumbnail:c=!1,imageAspect:d=!1,viewportOptions:l}=e,u=o?.volumeId,f=u&&!n,m=o&&l?{...l,viewReference:o}:l,w=a?Ce:Re;return new Promise((V,h)=>{function g(p,y){const{modality:x}=B(me.GENERAL_SERIES,y)||{},I=!f&&p,C=f&&p;I&&(I.isPreScaled=I.isPreScaled||I.preScale?.scaled),c&&(t.height=256,t.width=256),d&&I&&(t.width=I&&t.height*I.width/I.height),t.style.width=`${t.width/devicePixelRatio}px`,t.style.height=`${t.height/devicePixelRatio}px`,C&&a&&h(new Error("CPU rendering of volume not supported")),w(t,p,x,r,m).then(V)}function b(p,y){console.error(p,y),h(p)}function S(p,y,x){return je(p,x).then(I=>{g.call(this,I,p)},I=>{b.call(this,I,p)})}const v={useRGBA:!!a,requestType:i};if(u){const p=O.getVolume(u);p||h(new Error(`Volume id ${u} not found in cache`));const y=p.imageIds[0];g(p,y)}else ze.addRequest(S.bind(null,n,null,v),i,{imageId:n},s)})}function Yn(e){const t=z(),n=[];return t.forEach(o=>{o.getViewports().filter(he).forEach(s=>{s.hasImageURI(e)&&n.push(s)})}),n}function Qn(e,t){const n=eo(e,t);return n?n.index:null}function eo(e,t){const n=t.getImageIds(),o=t.getCurrentImageIdIndex();if(n.length===0)return null;const i=c=>{const d=to(c);if(!d)return null;const l=$e(d.planeNormal,d.imagePositionPatient);return qe(l,e)},s={distance:i(n[o])??1/0,index:o},r=n.slice(o+1);for(let c=0;c<r.length;c++){const d=r[c],l=i(d);if(l!==null)if(l<=s.distance)s.distance=l,s.index=c+o+1;else break}const a=n.slice(0,o);for(let c=a.length-1;c>=0;c--){const d=a[c],l=i(d);if(!(l===null||l===s.distance))if(l<s.distance)s.distance=l,s.index=c;else break}return s.distance===1/0?null:s}function to(e){const t=B(me.IMAGE_PLANE,e);if(!t||!(t.rowCosines instanceof Array&&t.rowCosines.length===3)||!(t.columnCosines instanceof Array&&t.columnCosines.length===3)||!(t.imagePositionPatient instanceof Array&&t.imagePositionPatient.length===3))return null;const{rowCosines:n,columnCosines:o,imagePositionPatient:i}=t,s=ie(E(),...n),r=ie(E(),...o),a=H(E(),s,r);return{rowCosines:n,columnCosines:o,imagePositionPatient:i,planeNormal:a}}function no(e){const{width:t,height:n}=e.getCanvas(),{sliceToIndexMatrix:o,indexToSliceMatrix:i}=e.getSliceViewInfo(),s=J(e,[0,0]),r=J(e,[t-1,0]),a=J(e,[0,n-1]),c=D(E(),r,s),d=D(E(),a,s),l=H(E(),c,d);L(c,c),L(d,d),L(l,l);const u=Math.max(Math.abs(c[0]),Math.abs(c[1]),Math.abs(c[2])),f=Math.max(Math.abs(d[0]),Math.abs(d[1]),Math.abs(d[2]));if(!re(1,u)||!re(1,f))throw new Error("getCurrentVolumeViewportSlice is not available for rotate/oblique viewports");const{voxelManager:m}=e.getImageData(),w=e.getSliceViewInfo(),V=m.getSliceData(w);return{width:w.width,height:w.height,scalarData:V,sliceToIndexMatrix:o,indexToSliceMatrix:i}}const oo=.05;function so(e,t){const n=e.getSliceIndex(),o=t.getSliceIndex(),i=B("imagePlaneModule",n.toString()),s=B("imagePlaneModule",o.toString());if(!i||!s){console.log("Viewport spatial registration requires image plane module");return}const{imageOrientationPatient:r}=s;if(!i.imageOrientationPatient.every((f,m)=>Math.abs(f-r[m])<oo)){console.log("Viewport spatial registration only supported for same orientation (hence translation only) for now",i?.imageOrientationPatient,s?.imageOrientationPatient);return}const c=i.imagePositionPatient,d=s.imagePositionPatient,l=Je(E(),c,d),u=Ke(Ze(),l);pe.add([e.id,t.id],u)}function io(e){const{imageData:t,dimensions:n}=e.getImageData()||{};if(!t||!n)return[];const{canvas:o}=e,i=window.devicePixelRatio,s=[0,0],r=[o.width/i,0],a=[o.width/i,o.height/i],c=[0,o.height/i],d=e.canvasToWorld(s),l=e.canvasToWorld(r),u=e.canvasToWorld(a),f=e.canvasToWorld(c),m=t.worldToIndex(d),w=t.worldToIndex(l),V=t.worldToIndex(u),h=t.worldToIndex(f);return ro({dimensions:n,imageData:t,topLeftImage:m,topRightImage:w,bottomRightImage:V,bottomLeftImage:h,topLeftWorld:d,topRightWorld:l,bottomRightWorld:u,bottomLeftWorld:f})}function ro({dimensions:e,imageData:t,topLeftImage:n,topRightImage:o,bottomRightImage:i,bottomLeftImage:s,topLeftWorld:r,topRightWorld:a,bottomRightWorld:c,bottomLeftWorld:d}){const l=k(n,e)?r:t.indexToWorld([0,0,0]),u=k(o,e)?a:t.indexToWorld([e[0]-1,0,0]),f=k(i,e)?c:t.indexToWorld([e[0]-1,e[1]-1,0]),m=k(s,e)?d:t.indexToWorld([0,e[1]-1,0]);return[l,u,m,f]}function k(e,t){return e[0]>0||e[0]<t[0]-1||e[1]>0||e[1]<t[1]-1||e[2]>0||e[2]<t[2]-1}function j(e){if(!e)return;const{viewportUid:t,renderingEngineUid:n}=e.dataset;return Pe(t,n)}function Pe(e,t){if(!t||!e)return;const n=Y(t);if(!n||n.hasBeenDestroyed)return;const o=n.getViewport(e);if(!o)return;const i=An(o)?o.getFrameOfReferenceUID():void 0;return{viewport:o,renderingEngine:n,viewportId:e,renderingEngineId:t,FrameOfReferenceUID:i}}function Bo(e){const t=z();for(let n=0;n<t.length;n++){const o=t[n];if(o.getViewport(e))return Pe(e,o.id)}}function Ho(){const e=[];return z().forEach(n=>{n.getViewports().forEach(({element:i})=>{e.push(j(i))})}),e}function ao(e){const t=j(e);if(!t)return;const{viewport:n}=t;if(!(n instanceof Q))throw new Error(`An image can only be fetched for a stack viewport and not for a viewport of type: ${n.type}`);return n.getCornerstoneImage()}async function co({viewport:e,options:t={}}){const n=e.getRenderingEngine();let o=t.volumeId||`${ee()}`;o.split(":").length===0&&(o=`${Xe()}:${o}`);const{id:i,element:s}=e,r=t.viewportId||i,a=e.getImageIds(),c=e.getViewPresentation(),d=e.getViewReference();n.enableElement({viewportId:r,type:G.ORTHOGRAPHIC,element:s,defaultOptions:{background:t.background,orientation:t.orientation}}),(await Ye(o,{imageIds:a})).load();const u=n.getViewport(r);await _n(n,[{volumeId:o}],[r]);const f=()=>{u.render(),s.removeEventListener(R.VOLUME_VIEWPORT_NEW_VOLUME,f)};return s.addEventListener(R.VOLUME_VIEWPORT_NEW_VOLUME,f),u.setViewPresentation(c),u.setViewReference(d),u.render(),u}async function lo({viewport:e,options:t}){const n=e,{id:o,element:i}=n,s=e.getRenderingEngine(),{background:r}=t,a=t.viewportId||o,c=O.getVolume(n.getVolumeId());if(!(c instanceof Qe))throw new Error("Currently, you cannot decache a volume that is not an ImageVolume. So, unfortunately, volumes such as nifti (which are basic Volume, without imageIds) cannot be decached.");const d={viewportId:a,type:G.STACK,element:i,defaultOptions:{background:r}},l=n.getViewReference();s.enableElement(d);const u=s.getViewport(a);return await u.setStack(c.imageIds),u.setViewReference(l),u.render(),u}function Te(e,t=2){if(Array.isArray(e))return e.map(i=>Te(i,t)).join(", ");if(e==null||e==="")return"NaN";e=Number(e);const n=Math.abs(e);if(n<1e-4)return`${e}`;const o=n>=100?t-2:n>=10?t-1:n>=1?t:n>=.1?t+1:n>=.01?t+2:n>=.001?t+3:t+4;return e.toFixed(o)}function uo(e){return Math.round(e/P)*P}function fo(e,t,n){const o=e.length===t*n*4,i=e.length===t*n*3;if(o||i){const s=new Float32Array(t*n);let r=0,a=0;const c=o?4:3;for(let d=0;d<t;d++)for(let l=0;l<n;l++){const u=e[r],f=e[r+1],m=e[r+2];s[a]=(u+f+m)/3,r+=c,a++}return s}else return e}function go(e){if(e instanceof we)return O.getVolume(e.getVolumeId()).imageIds;if(e.getImageIds)return e.getImageIds()}function mo(e,t){const n=[...e];return t>=n.length?(ce(n),n):(ce(n),n.slice(0,t))}function ce(e){for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}}function K(e){const t=e.toString(16);return t.length==1?"0"+t:t}function ho(e,t,n){return"#"+K(e)+K(t)+K(n)}function po(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}const wo=Object.freeze(Object.defineProperty({__proto__:null,hexToRgb:po,rgbToHex:ho},Symbol.toStringTag,{value:"Module"}));function Io(e,t){if(e===t)return!0;if(e==null||t==null)return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch(n){return console.debug("Error in JSON.stringify during deep comparison:",n),e===t}}function xe(e,t){const n=e,o=n.getActors?.()??[];return(t?o.find(s=>s.referencedId===t)??o.find(s=>s.referencedId?.endsWith(`:${t}`)):void 0)?.referencedId??(t?te(t):void 0)??n.getDefaultActor?.()?.referencedId}function Me(e,t,n){if(!n)throw new Error("getVolume is required, use the utilities export instead");if(Ie(e)){const o=xe(e,t),i=o?n(o):void 0,s=e.getImageData?.();return{modality:i?.metadata?.Modality??s?.metadata?.Modality,isPreScaled:le(i?.scaling)}}if(typeof e.setVolumes=="function"){const i=t?te(t):e.getVolumeId(),s=i?n(i):void 0;return{modality:s?.metadata?.Modality,isPreScaled:le(s?.scaling)}}if(typeof e.setStack=="function"){const o=e,{preScale:i}=o.getImageData()||{};return{modality:o.modality,isPreScaled:!!i?.scaled}}}function le(e){return!!e&&Object.keys(e).length>0}function Vo(e,t,n){const o=Me(e,t,n);if(!o)throw new Error("Invalid viewport type");return o.modality}function So(e){const{imageIdGroups:t,splittingTag:n}=Ve(e);return{isDynamicVolume:t.length>1,timePoints:t,splittingTag:n}}function bo(e,t){const n=e.length,{rescaleSlope:o,rescaleIntercept:i,suvbw:s}=t;if(t.modality==="PT"&&typeof s=="number")for(let r=0;r<n;r++)e[r]=s*(e[r]*o+i);else for(let r=0;r<n;r++)e[r]=e[r]*o+i;return e}function De(e,t,n){return Math.min(Math.max(t,e),n)}function Oe(e,t){if(!j(e.element))throw new Error("Scroll::Viewport is not enabled (it might be disabled)");if(e instanceof Q&&e.getImageIds().length===0)throw new Error("Scroll::Stack Viewport has no images");const{volumeId:o,delta:i,scrollSlabs:s}=t;if(e instanceof we)vo(e,o,i,s);else{if(typeof e.getCurrentImageIdIndex!="function"||typeof e.scroll!="function")return;const r=e.getCurrentImageIdIndex();if(r+i>e.getImageIds().length-1||r+i<0){const a={imageIdIndex:r,direction:i};T(M,R.STACK_SCROLL_OUT_OF_BOUNDS,a)}e.scroll(i,t.debounceLoading,t.loop)}}function vo(e,t,n,o=!1){const i=o,{numScrollSteps:s,currentStepIndex:r,sliceRangeInfo:a}=Se(e,t,i);if(s===0||!a)return;const{sliceRange:c,spacingInNormalDirection:d,camera:l}=a,{focalPoint:u,viewPlaneNormal:f,position:m}=l,{newFocalPoint:w,newPosition:V}=be(u,m,c,f,d,n);e.setCamera({focalPoint:w,position:V}),e.render();const h=r+n,g={volumeId:t,viewport:e,delta:n,desiredStepIndex:h,currentStepIndex:r,numScrollSteps:s,currentImageId:e.getCurrentImageId()};(h>s||h<0)&&e.getCurrentImageId()?T(M,R.VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS,g):T(M,R.VOLUME_VIEWPORT_SCROLL,g)}async function Eo(e,t={}){const{imageIndex:n,debounceLoading:o,volumeId:i}=t,s=j(e);if(!s)throw new Error("Element has been disabled");const{viewport:r}=s,{imageIndex:a,numberOfSlices:c}=yo(r,o),l=Ro(c,n)-a;Oe(r,{delta:l,debounceLoading:o,volumeId:i})}function yo(e,t){return e instanceof Q?{numberOfSlices:e.getImageIds().length,imageIndex:t?e.getTargetImageIdIndex():e.getCurrentImageIdIndex()}:{numberOfSlices:e.getNumberOfSlices(),imageIndex:e.getSliceIndex()}}function Ro(e,t){const n=e-1;return De(t,0,n)}function Co(e,t,n={}){const o=O.getVolume(e);if(!o)throw new Error(`Referenced volume with id ${e} does not exist.`);const{metadata:i,spacing:s,direction:r,dimensions:a}=o,{minX:c,maxX:d,minY:l,maxY:u,minZ:f,maxZ:m}=t,w=[Math.min(c,d),Math.min(l,u),Math.min(f,m)],V=Z(o.imageData,w),h=[Math.abs(d-c)+1,Math.abs(u-l)+1,Math.abs(m-f)+1],{targetBuffer:g}=n,b={metadata:i,dimensions:h,spacing:s,origin:V,direction:r,targetBuffer:g,scalarData:g?.type==="Float32Array"?new Float32Array(h[0]*h[1]*h[2]):void 0},S=et(ee(),b),v=S.voxelManager.getCompleteScalarDataArray(),p=h[0]*h[1],y=a[0]*a[1],x=o.voxelManager.getCompleteScalarDataArray();for(let I=0;I<h[2];I++)for(let C=0;C<h[1];C++){const $=Z(S.imageData,[0,C,I]),_=ve(o.imageData,$),W=_[2]*y+_[1]*a[0]+_[0],q=x.slice(W,W+h[0]),A=I*p+C*h[0];v.set(q,A)}return S.voxelManager.setCompleteScalarDataArray(v),S}function Po(e,t){const{viewUp:n,viewPlaneNormal:o}=t,i=N(e,[0,0,0]),s=ae(E(),n),r=ae(E(),o),a=H(E(),s,r),c=D(E(),N(e,s),i),d=D(E(),N(e,r),i);L(c,c),L(d,d);const l=H(E(),c,d);return{worldVecRowDir:a,worldVecColDir:s,worldVecSliceDir:r,ijkVecRowDir:l,ijkVecColDir:c,ijkVecSliceDir:d}}function To(e,t,n,o){const[i,s,r]=t,a=i*s;let c=0,d=0,l=0;const[u,f,m]=n.map(Math.round);for(let g=m-o;g<=m+o;g++)if(!(g<0||g>=r)){for(let b=f-o;b<=f+o;b++)if(!(b<0||b>=s))for(let S=u-o;S<=u+o;S++){if(S<0||S>=i)continue;const v=g*a+b*i+S,p=e[v];c+=p,d+=p*p,l++}}if(l===0){const g=m*a+f*i+u;return g>=0&&g<e.length?{mean:e[g],stdDev:0,count:1}:{mean:0,stdDev:0,count:0}}const w=c/l,V=d/l-w*w,h=Math.sqrt(Math.max(0,V));return{mean:w,stdDev:h,count:l}}const de=1e-6;function xo(e,t){const{lower:n,upper:o}=t.voiRange,i=o-n,s=t.VOILUTFunction,r=a=>t.invert===!0?1-a:a;if(s===Ee.SAMPLED_SIGMOID||s==="SIGMOID"){const{windowCenter:a,windowWidth:c}=ye(n,o),d=Math.max(Math.abs(c),1e-12);return r(1/(1+Math.exp(-4*(e-a)/d)))}return i===0||!Number.isFinite(i)?r(0):r(U((e-n)/i))}function X(e,t){const{lower:n,upper:o}=t.voiRange,i=t.VOILUTFunction,s=t.invert===!0?U(1-U(e)):U(e);if(i===Ee.SAMPLED_SIGMOID||i==="SIGMOID"){const{windowCenter:a,windowWidth:c}=ye(n,o),d=_e(s,de,1-de);return tt(d,a,c)}const r=o-n;return r===0||!Number.isFinite(r)?n:n+s*r}function Mo(e,t,n){const o=Math.min(e,t),i=Math.max(e,t),s=X(o,n),r=X(i,n);return{rawMin:Math.min(s,r),rawMax:Math.max(s,r)}}function U(e){return Number.isFinite(e)?_e(e,0,1):0}function _e(e,t,n){return Math.min(n,Math.max(t,e))}const{getPixelSpacingInformation:Do,calculateRadiographicPixelSpacing:Oo,getERMF:_o}=nt,Lo=(e,t)=>Vo(e,t,O.getVolume),Wo=(e,t)=>Me(e,t,O.getVolume),zo=Object.freeze(Object.defineProperty({__proto__:null,ECGUtilities:ft,FrameRange:gt,HistoryMemo:mt,PointsManager:at,ProgressiveIterator:it,RLEVoxelMap:st,VideoUtilities:ht,VoxelManager:ot,WSIUtilities:pt,actorIsA:wt,applyPreset:It,asArray:Vt,autoLoad:St,buildMetadata:bt,calculateNeighborhoodStats:To,calculateRadiographicPixelSpacing:Oo,calculateSpacingBetweenImageIds:vt,calculateViewportsSpatialRegistration:so,calibratedPixelSpacingMetadataProvider:$n,clamp:ut,clip:De,clonePoint3:Et,color:wo,colormap:yt,convertColorArrayToRgbString:Rt,convertStackToVolumeViewport:co,convertToGrayscale:fo,convertVolumeToStackViewport:lo,createLinearRGBTransferFunction:Ct,createSigmoidRGBTransferFunction:Pt,createSubVolume:Co,decimate:Tt,deepClone:xt,deepEqual:Io,deepMerge:Mt,eventListener:Fn,fnv1aHash:Dt,generateFrameImageId:Ot,generateVolumePropsFromImageIds:_t,genericMetadataProvider:Lt,genericViewportDisplaySetMetadataProvider:Wt,getAcquisitionPlaneOrientation:At,getBufferConfiguration:kt,getClosestImageId:Ft,getClosestStackImageIndexForPoint:Qn,getCubeSizeInView:Nt,getCurrentVolumeViewportSlice:no,getDynamicVolumeInfo:So,getERMF:_o,getImageDataMetadata:Ut,getImageLegacy:ao,getImageSliceDataForVolumeViewport:Gt,getMinMax:Bt,getNormalizedAspectRatio:dt,getPixelSpacingInformation:Do,getRandomSampleFromArray:mo,getRuntimeId:zn,getScalingDescriptor:Wo,getScalingParameters:Ht,getSliceRange:zt,getSpacingInNormalDirection:jt,getTargetVolumeAndSpacingInNormalDir:$t,getVOIRangeFromWindowLevel:qt,getViewportContentMode:Jt,getViewportImageCornersInWorld:io,getViewportImageIds:go,getViewportModality:Lo,getViewportsWithImageURI:Yn,getViewportsWithVolumeId:Kt,getVoiFromSigmoidRGBTransferFunction:Zt,getVolumeActorCorners:Xt,getVolumeDirectionVectors:Po,getVolumeId:te,getVolumeSliceRangeInfo:Yt,getVolumeViewReferenceId:Qt,getVolumeViewportScrollInfo:Se,getVolumeViewportsContainingSameVolumes:Zn,handleMultiframe4D:en,hasFloatScalingParameters:tn,hasNaNValues:nn,hasOwn:on,imageIdToURI:sn,imageRetrieveMetadataProvider:ct,imageToWorldCoords:rn,indexAlmostWithinDimensions:Kn,indexWithinDimensions:Jn,invertRgbTransferFunction:an,isEqual:lt,isEqualAbs:cn,isEqualNegative:ln,isGenericViewport:Ie,isImageActor:dn,isNumber:un,isOpposite:qn,isPTPrescaledWithSUV:ge,isValidVolume:fn,isVideoTransferSyntax:gn,jumpToSlice:Eo,loadImageToCanvas:Xn,logger:rt,makeVolumeMetadata:mn,mapMappedBandToRawRange:Mo,mapScalarToViewportVoiIntensity:xo,mapViewportVoiIntensityToScalar:X,planar:hn,pointInShapeCallback:pn,renderToCanvasCPU:Ce,renderToCanvasGPU:Re,resolveGenericViewportVolumeId:xe,rotateToViewCoordinates:wn,roundNumber:Te,roundToPrecision:uo,scaleArray:bo,scaleRgbTransferFunction:Nn,scroll:Oe,snapFocalPointToSlice:be,sortImageIdsAndGetSpacing:In,spatialRegistrationMetadataProvider:pe,splitImageIdsBy4DTags:Ve,transferFunctionUtils:Vn,transformIndexToWorld:Z,transformWorldToIndex:ve,transformWorldToIndexContinuous:N,triggerEvent:T,updatePlaneRestriction:Sn,updateVTKImageDataWithCornerstoneImage:bn,uuidv4:ee,viewportIsInStackMode:vn,viewportIsInVolumeMode:En,viewportSupportsDisplaySetPresentation:yn,viewportSupportsImageSlices:he,viewportSupportsStackCalibration:Rn,viewportSupportsStackCompatibility:Cn,viewportSupportsVolumeActors:fe,viewportSupportsVolumeCompatibility:Pn,viewportSupportsVolumeId:Tn,viewportSupportsVolumeURI:xn,windowLevel:Mn,worldToImageCoords:Dn},Symbol.toStringTag,{value:"Module"}));export{Oe as A,no as B,De as C,qn as D,io as E,fo as F,On as G,kn as M,Wn as T,Ln as a,Pe as b,Bo as c,Ho as d,An as e,Go as f,j as g,Uo as h,zn as i,Io as j,mo as k,Wo as l,Yn as m,Kn as n,Qn as o,so as p,Eo as q,Te as r,_n as s,Jn as t,zo as u,No as v,uo as w,Po as x,Co as y,To as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const rn={charge:!0,link:!0,collide:!0,gravity:!1},U=.55;function nt(t,n,e){var i,r=1;t==null&&(t=0),n==null&&(n=0),e==null&&(e=0);function s(){var o,a=i.length,u,h=0,c=0,d=0;for(o=0;o<a;++o)u=i[o],h+=u.x||0,c+=u.y||0,d+=u.z||0;for(h=(h/a-t)*r,c=(c/a-n)*r,d=(d/a-e)*r,o=0;o<a;++o)u=i[o],h&&(u.x-=h),c&&(u.y-=c),d&&(u.z-=d)}return s.initialize=function(o){i=o},s.x=function(o){return arguments.length?(t=+o,s):t},s.y=function(o){return arguments.length?(n=+o,s):n},s.z=function(o){return arguments.length?(e=+o,s):e},s.strength=function(o){return arguments.length?(r=+o,s):r},s}function wn(t){const n=+this._x.call(null,t);return sn(this.cover(n),n,t)}function sn(t,n,e){if(isNaN(n))return t;var i,r=t._root,s={data:e},o=t._x0,a=t._x1,u,h,c,d,g;if(!r)return t._root=s,t;for(;r.length;)if((c=n>=(u=(o+a)/2))?o=u:a=u,i=r,!(r=r[d=+c]))return i[d]=s,t;if(h=+t._x.call(null,r.data),n===h)return s.next=r,i?i[d]=s:t._root=s,t;do i=i?i[d]=new Array(2):t._root=new Array(2),(c=n>=(u=(o+a)/2))?o=u:a=u;while((d=+c)==(g=+(h>=u)));return i[g]=r,i[d]=s,t}function vn(t){Array.isArray(t)||(t=Array.from(t));const n=t.length,e=new Float64Array(n);let i=1/0,r=-1/0;for(let s=0,o;s<n;++s)isNaN(o=+this._x.call(null,t[s]))||(e[s]=o,o<i&&(i=o),o>r&&(r=o));if(i>r)return this;this.cover(i).cover(r);for(let s=0;s<n;++s)sn(this,e[s],t[s]);return this}function Mn(t){if(isNaN(t=+t))return this;var n=this._x0,e=this._x1;if(isNaN(n))e=(n=Math.floor(t))+1;else{for(var i=e-n||1,r=this._root,s,o;n>t||t>=e;)switch(o=+(t<n),s=new Array(2),s[o]=r,r=s,i*=2,o){case 0:e=n+i;break;case 1:n=e-i;break}this._root&&this._root.length&&(this._root=r)}return this._x0=n,this._x1=e,this}function mn(){var t=[];return this.visit(function(n){if(!n.length)do t.push(n.data);while(n=n.next)}),t}function zn(t){return arguments.length?this.cover(+t[0][0]).cover(+t[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function tt(t,n,e){this.node=t,this.x0=n,this.x1=e}function Nn(t,n){var e,i=this._x0,r,s,o=this._x1,a=[],u=this._root,h,c;for(u&&a.push(new tt(u,i,o)),n==null?n=1/0:(i=t-n,o=t+n);h=a.pop();)if(!(!(u=h.node)||(r=h.x0)>o||(s=h.x1)<i))if(u.length){var d=(r+s)/2;a.push(new tt(u[1],d,s),new tt(u[0],r,d)),(c=+(t>=d))&&(h=a[a.length-1],a[a.length-1]=a[a.length-1-c],a[a.length-1-c]=h)}else{var g=Math.abs(t-+this._x.call(null,u.data));g<n&&(n=g,i=t-g,o=t+g,e=u.data)}return e}function An(t){if(isNaN(u=+this._x.call(null,t)))return this;var n,e=this._root,i,r,s,o=this._x0,a=this._x1,u,h,c,d,g;if(!e)return this;if(e.length)for(;;){if((c=u>=(h=(o+a)/2))?o=h:a=h,n=e,!(e=e[d=+c]))return this;if(!e.length)break;n[d+1&1]&&(i=n,g=d)}for(;e.data!==t;)if(r=e,!(e=e.next))return this;return(s=e.next)&&delete e.next,r?(s?r.next=s:delete r.next,this):n?(s?n[d]=s:delete n[d],(e=n[0]||n[1])&&e===(n[1]||n[0])&&!e.length&&(i?i[g]=e:this._root=e),this):(this._root=s,this)}function In(t){for(var n=0,e=t.length;n<e;++n)this.remove(t[n]);return this}function kn(){return this._root}function Sn(){var t=0;return this.visit(function(n){if(!n.length)do++t;while(n=n.next)}),t}function $n(t){var n=[],e,i=this._root,r,s,o;for(i&&n.push(new tt(i,this._x0,this._x1));e=n.pop();)if(!t(i=e.node,s=e.x0,o=e.x1)&&i.length){var a=(s+o)/2;(r=i[1])&&n.push(new tt(r,a,o)),(r=i[0])&&n.push(new tt(r,s,a))}return this}function bn(t){var n=[],e=[],i;for(this._root&&n.push(new tt(this._root,this._x0,this._x1));i=n.pop();){var r=i.node;if(r.length){var s,o=i.x0,a=i.x1,u=(o+a)/2;(s=r[0])&&n.push(new tt(s,o,u)),(s=r[1])&&n.push(new tt(s,u,a))}e.push(i)}for(;i=e.pop();)t(i.node,i.x0,i.x1);return this}function En(t){return t[0]}function qn(t){return arguments.length?(this._x=t,this):this._x}function kt(t,n){var e=new St(n??En,NaN,NaN);return t==null?e:e.addAll(t)}function St(t,n,e){this._x=t,this._x0=n,this._x1=e,this._root=void 0}function Lt(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var X=kt.prototype=St.prototype;X.copy=function(){var t=new St(this._x,this._x0,this._x1),n=this._root,e,i;if(!n)return t;if(!n.length)return t._root=Lt(n),t;for(e=[{source:n,target:t._root=new Array(2)}];n=e.pop();)for(var r=0;r<2;++r)(i=n.source[r])&&(i.length?e.push({source:i,target:n.target[r]=new Array(2)}):n.target[r]=Lt(i));return t};X.add=wn;X.addAll=vn;X.cover=Mn;X.data=mn;X.extent=zn;X.find=Nn;X.remove=An;X.removeAll=In;X.root=kn;X.size=Sn;X.visit=$n;X.visitAfter=bn;X.x=qn;function Tn(t){const n=+this._x.call(null,t),e=+this._y.call(null,t);return on(this.cover(n,e),n,e,t)}function on(t,n,e,i){if(isNaN(n)||isNaN(e))return t;var r,s=t._root,o={data:i},a=t._x0,u=t._y0,h=t._x1,c=t._y1,d,g,_,f,M,y,l,x;if(!s)return t._root=o,t;for(;s.length;)if((M=n>=(d=(a+h)/2))?a=d:h=d,(y=e>=(g=(u+c)/2))?u=g:c=g,r=s,!(s=s[l=y<<1|M]))return r[l]=o,t;if(_=+t._x.call(null,s.data),f=+t._y.call(null,s.data),n===_&&e===f)return o.next=s,r?r[l]=o:t._root=o,t;do r=r?r[l]=new Array(4):t._root=new Array(4),(M=n>=(d=(a+h)/2))?a=d:h=d,(y=e>=(g=(u+c)/2))?u=g:c=g;while((l=y<<1|M)===(x=(f>=g)<<1|_>=d));return r[x]=s,r[l]=o,t}function On(t){var n,e,i=t.length,r,s,o=new Array(i),a=new Array(i),u=1/0,h=1/0,c=-1/0,d=-1/0;for(e=0;e<i;++e)isNaN(r=+this._x.call(null,n=t[e]))||isNaN(s=+this._y.call(null,n))||(o[e]=r,a[e]=s,r<u&&(u=r),r>c&&(c=r),s<h&&(h=s),s>d&&(d=s));if(u>c||h>d)return this;for(this.cover(u,h).cover(c,d),e=0;e<i;++e)on(this,o[e],a[e],t[e]);return this}function Cn(t,n){if(isNaN(t=+t)||isNaN(n=+n))return this;var e=this._x0,i=this._y0,r=this._x1,s=this._y1;if(isNaN(e))r=(e=Math.floor(t))+1,s=(i=Math.floor(n))+1;else{for(var o=r-e||1,a=this._root,u,h;e>t||t>=r||i>n||n>=s;)switch(h=(n<i)<<1|t<e,u=new Array(4),u[h]=a,a=u,o*=2,h){case 0:r=e+o,s=i+o;break;case 1:e=r-o,s=i+o;break;case 2:r=e+o,i=s-o;break;case 3:e=r-o,i=s-o;break}this._root&&this._root.length&&(this._root=a)}return this._x0=e,this._y0=i,this._x1=r,this._y1=s,this}function Fn(){var t=[];return this.visit(function(n){if(!n.length)do t.push(n.data);while(n=n.next)}),t}function Ln(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function B(t,n,e,i,r){this.node=t,this.x0=n,this.y0=e,this.x1=i,this.y1=r}function Dn(t,n,e){var i,r=this._x0,s=this._y0,o,a,u,h,c=this._x1,d=this._y1,g=[],_=this._root,f,M;for(_&&g.push(new B(_,r,s,c,d)),e==null?e=1/0:(r=t-e,s=n-e,c=t+e,d=n+e,e*=e);f=g.pop();)if(!(!(_=f.node)||(o=f.x0)>c||(a=f.y0)>d||(u=f.x1)<r||(h=f.y1)<s))if(_.length){var y=(o+u)/2,l=(a+h)/2;g.push(new B(_[3],y,l,u,h),new B(_[2],o,l,y,h),new B(_[1],y,a,u,l),new B(_[0],o,a,y,l)),(M=(n>=l)<<1|t>=y)&&(f=g[g.length-1],g[g.length-1]=g[g.length-1-M],g[g.length-1-M]=f)}else{var x=t-+this._x.call(null,_.data),v=n-+this._y.call(null,_.data),m=x*x+v*v;if(m<e){var w=Math.sqrt(e=m);r=t-w,s=n-w,c=t+w,d=n+w,i=_.data}}return i}function Rn(t){if(isNaN(c=+this._x.call(null,t))||isNaN(d=+this._y.call(null,t)))return this;var n,e=this._root,i,r,s,o=this._x0,a=this._y0,u=this._x1,h=this._y1,c,d,g,_,f,M,y,l;if(!e)return this;if(e.length)for(;;){if((f=c>=(g=(o+u)/2))?o=g:u=g,(M=d>=(_=(a+h)/2))?a=_:h=_,n=e,!(e=e[y=M<<1|f]))return this;if(!e.length)break;(n[y+1&3]||n[y+2&3]||n[y+3&3])&&(i=n,l=y)}for(;e.data!==t;)if(r=e,!(e=e.next))return this;return(s=e.next)&&delete e.next,r?(s?r.next=s:delete r.next,this):n?(s?n[y]=s:delete n[y],(e=n[0]||n[1]||n[2]||n[3])&&e===(n[3]||n[2]||n[1]||n[0])&&!e.length&&(i?i[l]=e:this._root=e),this):(this._root=s,this)}function Gn(t){for(var n=0,e=t.length;n<e;++n)this.remove(t[n]);return this}function Pn(){return this._root}function jn(){var t=0;return this.visit(function(n){if(!n.length)do++t;while(n=n.next)}),t}function Un(t){var n=[],e,i=this._root,r,s,o,a,u;for(i&&n.push(new B(i,this._x0,this._y0,this._x1,this._y1));e=n.pop();)if(!t(i=e.node,s=e.x0,o=e.y0,a=e.x1,u=e.y1)&&i.length){var h=(s+a)/2,c=(o+u)/2;(r=i[3])&&n.push(new B(r,h,c,a,u)),(r=i[2])&&n.push(new B(r,s,c,h,u)),(r=i[1])&&n.push(new B(r,h,o,a,c)),(r=i[0])&&n.push(new B(r,s,o,h,c))}return this}function Wn(t){var n=[],e=[],i;for(this._root&&n.push(new B(this._root,this._x0,this._y0,this._x1,this._y1));i=n.pop();){var r=i.node;if(r.length){var s,o=i.x0,a=i.y0,u=i.x1,h=i.y1,c=(o+u)/2,d=(a+h)/2;(s=r[0])&&n.push(new B(s,o,a,c,d)),(s=r[1])&&n.push(new B(s,c,a,u,d)),(s=r[2])&&n.push(new B(s,o,d,c,h)),(s=r[3])&&n.push(new B(s,c,d,u,h))}e.push(i)}for(;i=e.pop();)t(i.node,i.x0,i.y0,i.x1,i.y1);return this}function Yn(t){return t[0]}function Kn(t){return arguments.length?(this._x=t,this):this._x}function Bn(t){return t[1]}function Hn(t){return arguments.length?(this._y=t,this):this._y}function $t(t,n,e){var i=new bt(n??Yn,e??Bn,NaN,NaN,NaN,NaN);return t==null?i:i.addAll(t)}function bt(t,n,e,i,r,s){this._x=t,this._y=n,this._x0=e,this._y0=i,this._x1=r,this._y1=s,this._root=void 0}function Dt(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var H=$t.prototype=bt.prototype;H.copy=function(){var t=new bt(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root,e,i;if(!n)return t;if(!n.length)return t._root=Dt(n),t;for(e=[{source:n,target:t._root=new Array(4)}];n=e.pop();)for(var r=0;r<4;++r)(i=n.source[r])&&(i.length?e.push({source:i,target:n.target[r]=new Array(4)}):n.target[r]=Dt(i));return t};H.add=Tn;H.addAll=On;H.cover=Cn;H.data=Fn;H.extent=Ln;H.find=Dn;H.remove=Rn;H.removeAll=Gn;H.root=Pn;H.size=jn;H.visit=Un;H.visitAfter=Wn;H.x=Kn;H.y=Hn;function Xn(t){const n=+this._x.call(null,t),e=+this._y.call(null,t),i=+this._z.call(null,t);return an(this.cover(n,e,i),n,e,i,t)}function an(t,n,e,i,r){if(isNaN(n)||isNaN(e)||isNaN(i))return t;var s,o=t._root,a={data:r},u=t._x0,h=t._y0,c=t._z0,d=t._x1,g=t._y1,_=t._z1,f,M,y,l,x,v,m,w,A,$,p;if(!o)return t._root=a,t;for(;o.length;)if((m=n>=(f=(u+d)/2))?u=f:d=f,(w=e>=(M=(h+g)/2))?h=M:g=M,(A=i>=(y=(c+_)/2))?c=y:_=y,s=o,!(o=o[$=A<<2|w<<1|m]))return s[$]=a,t;if(l=+t._x.call(null,o.data),x=+t._y.call(null,o.data),v=+t._z.call(null,o.data),n===l&&e===x&&i===v)return a.next=o,s?s[$]=a:t._root=a,t;do s=s?s[$]=new Array(8):t._root=new Array(8),(m=n>=(f=(u+d)/2))?u=f:d=f,(w=e>=(M=(h+g)/2))?h=M:g=M,(A=i>=(y=(c+_)/2))?c=y:_=y;while(($=A<<2|w<<1|m)===(p=(v>=y)<<2|(x>=M)<<1|l>=f));return s[p]=o,s[$]=a,t}function Vn(t){Array.isArray(t)||(t=Array.from(t));const n=t.length,e=new Float64Array(n),i=new Float64Array(n),r=new Float64Array(n);let s=1/0,o=1/0,a=1/0,u=-1/0,h=-1/0,c=-1/0;for(let d=0,g,_,f,M;d<n;++d)isNaN(_=+this._x.call(null,g=t[d]))||isNaN(f=+this._y.call(null,g))||isNaN(M=+this._z.call(null,g))||(e[d]=_,i[d]=f,r[d]=M,_<s&&(s=_),_>u&&(u=_),f<o&&(o=f),f>h&&(h=f),M<a&&(a=M),M>c&&(c=M));if(s>u||o>h||a>c)return this;this.cover(s,o,a).cover(u,h,c);for(let d=0;d<n;++d)an(this,e[d],i[d],r[d],t[d]);return this}function Qn(t,n,e){if(isNaN(t=+t)||isNaN(n=+n)||isNaN(e=+e))return this;var i=this._x0,r=this._y0,s=this._z0,o=this._x1,a=this._y1,u=this._z1;if(isNaN(i))o=(i=Math.floor(t))+1,a=(r=Math.floor(n))+1,u=(s=Math.floor(e))+1;else{for(var h=o-i||1,c=this._root,d,g;i>t||t>=o||r>n||n>=a||s>e||e>=u;)switch(g=(e<s)<<2|(n<r)<<1|t<i,d=new Array(8),d[g]=c,c=d,h*=2,g){case 0:o=i+h,a=r+h,u=s+h;break;case 1:i=o-h,a=r+h,u=s+h;break;case 2:o=i+h,r=a-h,u=s+h;break;case 3:i=o-h,r=a-h,u=s+h;break;case 4:o=i+h,a=r+h,s=u-h;break;case 5:i=o-h,a=r+h,s=u-h;break;case 6:o=i+h,r=a-h,s=u-h;break;case 7:i=o-h,r=a-h,s=u-h;break}this._root&&this._root.length&&(this._root=c)}return this._x0=i,this._y0=r,this._z0=s,this._x1=o,this._y1=a,this._z1=u,this}function Zn(){var t=[];return this.visit(function(n){if(!n.length)do t.push(n.data);while(n=n.next)}),t}function Jn(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function D(t,n,e,i,r,s,o){this.node=t,this.x0=n,this.y0=e,this.z0=i,this.x1=r,this.y1=s,this.z1=o}function te(t,n,e,i){var r,s=this._x0,o=this._y0,a=this._z0,u,h,c,d,g,_,f=this._x1,M=this._y1,y=this._z1,l=[],x=this._root,v,m;for(x&&l.push(new D(x,s,o,a,f,M,y)),i==null?i=1/0:(s=t-i,o=n-i,a=e-i,f=t+i,M=n+i,y=e+i,i*=i);v=l.pop();)if(!(!(x=v.node)||(u=v.x0)>f||(h=v.y0)>M||(c=v.z0)>y||(d=v.x1)<s||(g=v.y1)<o||(_=v.z1)<a))if(x.length){var w=(u+d)/2,A=(h+g)/2,$=(c+_)/2;l.push(new D(x[7],w,A,$,d,g,_),new D(x[6],u,A,$,w,g,_),new D(x[5],w,h,$,d,A,_),new D(x[4],u,h,$,w,A,_),new D(x[3],w,A,c,d,g,$),new D(x[2],u,A,c,w,g,$),new D(x[1],w,h,c,d,A,$),new D(x[0],u,h,c,w,A,$)),(m=(e>=$)<<2|(n>=A)<<1|t>=w)&&(v=l[l.length-1],l[l.length-1]=l[l.length-1-m],l[l.length-1-m]=v)}else{var p=t-+this._x.call(null,x.data),S=n-+this._y.call(null,x.data),q=e-+this._z.call(null,x.data),C=p*p+S*S+q*q;if(C<i){var O=Math.sqrt(i=C);s=t-O,o=n-O,a=e-O,f=t+O,M=n+O,y=e+O,r=x.data}}return r}const ne=(t,n,e,i,r,s)=>Math.sqrt((t-i)**2+(n-r)**2+(e-s)**2);function ee(t,n,e,i){const r=[],s=t-i,o=n-i,a=e-i,u=t+i,h=n+i,c=e+i;return this.visit((d,g,_,f,M,y,l)=>{if(!d.length)do{const x=d.data;ne(t,n,e,this._x(x),this._y(x),this._z(x))<=i&&r.push(x)}while(d=d.next);return g>u||_>h||f>c||M<s||y<o||l<a}),r}function ie(t){if(isNaN(g=+this._x.call(null,t))||isNaN(_=+this._y.call(null,t))||isNaN(f=+this._z.call(null,t)))return this;var n,e=this._root,i,r,s,o=this._x0,a=this._y0,u=this._z0,h=this._x1,c=this._y1,d=this._z1,g,_,f,M,y,l,x,v,m,w,A;if(!e)return this;if(e.length)for(;;){if((x=g>=(M=(o+h)/2))?o=M:h=M,(v=_>=(y=(a+c)/2))?a=y:c=y,(m=f>=(l=(u+d)/2))?u=l:d=l,n=e,!(e=e[w=m<<2|v<<1|x]))return this;if(!e.length)break;(n[w+1&7]||n[w+2&7]||n[w+3&7]||n[w+4&7]||n[w+5&7]||n[w+6&7]||n[w+7&7])&&(i=n,A=w)}for(;e.data!==t;)if(r=e,!(e=e.next))return this;return(s=e.next)&&delete e.next,r?(s?r.next=s:delete r.next,this):n?(s?n[w]=s:delete n[w],(e=n[0]||n[1]||n[2]||n[3]||n[4]||n[5]||n[6]||n[7])&&e===(n[7]||n[6]||n[5]||n[4]||n[3]||n[2]||n[1]||n[0])&&!e.length&&(i?i[A]=e:this._root=e),this):(this._root=s,this)}function re(t){for(var n=0,e=t.length;n<e;++n)this.remove(t[n]);return this}function se(){return this._root}function oe(){var t=0;return this.visit(function(n){if(!n.length)do++t;while(n=n.next)}),t}function ae(t){var n=[],e,i=this._root,r,s,o,a,u,h,c;for(i&&n.push(new D(i,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=n.pop();)if(!t(i=e.node,s=e.x0,o=e.y0,a=e.z0,u=e.x1,h=e.y1,c=e.z1)&&i.length){var d=(s+u)/2,g=(o+h)/2,_=(a+c)/2;(r=i[7])&&n.push(new D(r,d,g,_,u,h,c)),(r=i[6])&&n.push(new D(r,s,g,_,d,h,c)),(r=i[5])&&n.push(new D(r,d,o,_,u,g,c)),(r=i[4])&&n.push(new D(r,s,o,_,d,g,c)),(r=i[3])&&n.push(new D(r,d,g,a,u,h,_)),(r=i[2])&&n.push(new D(r,s,g,a,d,h,_)),(r=i[1])&&n.push(new D(r,d,o,a,u,g,_)),(r=i[0])&&n.push(new D(r,s,o,a,d,g,_))}return this}function fe(t){var n=[],e=[],i;for(this._root&&n.push(new D(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));i=n.pop();){var r=i.node;if(r.length){var s,o=i.x0,a=i.y0,u=i.z0,h=i.x1,c=i.y1,d=i.z1,g=(o+h)/2,_=(a+c)/2,f=(u+d)/2;(s=r[0])&&n.push(new D(s,o,a,u,g,_,f)),(s=r[1])&&n.push(new D(s,g,a,u,h,_,f)),(s=r[2])&&n.push(new D(s,o,_,u,g,c,f)),(s=r[3])&&n.push(new D(s,g,_,u,h,c,f)),(s=r[4])&&n.push(new D(s,o,a,f,g,_,d)),(s=r[5])&&n.push(new D(s,g,a,f,h,_,d)),(s=r[6])&&n.push(new D(s,o,_,f,g,c,d)),(s=r[7])&&n.push(new D(s,g,_,f,h,c,d))}e.push(i)}for(;i=e.pop();)t(i.node,i.x0,i.y0,i.z0,i.x1,i.y1,i.z1);return this}function ce(t){return t[0]}function ue(t){return arguments.length?(this._x=t,this):this._x}function he(t){return t[1]}function le(t){return arguments.length?(this._y=t,this):this._y}function de(t){return t[2]}function ge(t){return arguments.length?(this._z=t,this):this._z}function Et(t,n,e,i){var r=new qt(n??ce,e??he,i??de,NaN,NaN,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function qt(t,n,e,i,r,s,o,a,u){this._x=t,this._y=n,this._z=e,this._x0=i,this._y0=r,this._z0=s,this._x1=o,this._y1=a,this._z1=u,this._root=void 0}function Rt(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var K=Et.prototype=qt.prototype;K.copy=function(){var t=new qt(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),n=this._root,e,i;if(!n)return t;if(!n.length)return t._root=Rt(n),t;for(e=[{source:n,target:t._root=new Array(8)}];n=e.pop();)for(var r=0;r<8;++r)(i=n.source[r])&&(i.length?e.push({source:i,target:n.target[r]=new Array(8)}):n.target[r]=Rt(i));return t};K.add=Xn;K.addAll=Vn;K.cover=Qn;K.data=Zn;K.extent=Jn;K.find=te;K.findAllWithinRadius=ee;K.remove=ie;K.removeAll=re;K.root=se;K.size=oe;K.visit=ae;K.visitAfter=fe;K.x=ue;K.y=le;K.z=ge;function Y(t){return function(){return t}}function Q(t){return(t()-.5)*1e-6}function Mt(t){return t.x+t.vx}function Gt(t){return t.y+t.vy}function pe(t){return t.z+t.vz}function et(t){var n,e,i,r,s=1,o=1;typeof t!="function"&&(t=Y(t==null?1:+t));function a(){for(var c,d=n.length,g,_,f,M,y,l,x,v=0;v<o;++v)for(g=(e===1?kt(n,Mt):e===2?$t(n,Mt,Gt):e===3?Et(n,Mt,Gt,pe):null).visitAfter(u),c=0;c<d;++c)_=n[c],l=i[_.index],x=l*l,f=_.x+_.vx,e>1&&(M=_.y+_.vy),e>2&&(y=_.z+_.vz),g.visit(m);function m(w,A,$,p,S,q,C){var O=[A,$,p,S,q,C],z=O[0],k=O[1],I=O[2],N=O[e],E=O[e+1],T=O[e+2],L=w.data,R=w.r,b=l+R;if(L){if(L.index>_.index){var G=f-L.x-L.vx,W=e>1?M-L.y-L.vy:0,P=e>2?y-L.z-L.vz:0,j=G*G+W*W+P*P;j<b*b&&(G===0&&(G=Q(r),j+=G*G),e>1&&W===0&&(W=Q(r),j+=W*W),e>2&&P===0&&(P=Q(r),j+=P*P),j=(b-(j=Math.sqrt(j)))/j*s,_.vx+=(G*=j)*(b=(R*=R)/(x+R)),e>1&&(_.vy+=(W*=j)*b),e>2&&(_.vz+=(P*=j)*b),L.vx-=G*(b=1-b),e>1&&(L.vy-=W*b),e>2&&(L.vz-=P*b))}return}return z>f+b||N<f-b||e>1&&(k>M+b||E<M-b)||e>2&&(I>y+b||T<y-b)}}function u(c){if(c.data)return c.r=i[c.data.index];for(var d=c.r=0;d<Math.pow(2,e);++d)c[d]&&c[d].r>c.r&&(c.r=c[d].r)}function h(){if(n){var c,d=n.length,g;for(i=new Array(d),c=0;c<d;++c)g=n[c],i[g.index]=+t(g,c,n)}}return a.initialize=function(c,...d){n=c,r=d.find(g=>typeof g=="function")||Math.random,e=d.find(g=>[1,2,3].includes(g))||2,h()},a.iterations=function(c){return arguments.length?(o=+c,a):o},a.strength=function(c){return arguments.length?(s=+c,a):s},a.radius=function(c){return arguments.length?(t=typeof c=="function"?c:Y(+c),h(),a):t},a}function _e(t){return t.index}function Pt(t,n){var e=t.get(n);if(!e)throw new Error("node not found: "+n);return e}function ft(t){var n=_e,e=g,i,r=Y(30),s,o,a,u,h,c,d=1;t==null&&(t=[]);function g(l){return 1/Math.min(u[l.source.index],u[l.target.index])}function _(l){for(var x=0,v=t.length;x<d;++x)for(var m=0,w,A,$,p=0,S=0,q=0,C,O;m<v;++m)w=t[m],A=w.source,$=w.target,p=$.x+$.vx-A.x-A.vx||Q(c),a>1&&(S=$.y+$.vy-A.y-A.vy||Q(c)),a>2&&(q=$.z+$.vz-A.z-A.vz||Q(c)),C=Math.sqrt(p*p+S*S+q*q),C=(C-s[m])/C*l*i[m],p*=C,S*=C,q*=C,$.vx-=p*(O=h[m]),a>1&&($.vy-=S*O),a>2&&($.vz-=q*O),A.vx+=p*(O=1-O),a>1&&(A.vy+=S*O),a>2&&(A.vz+=q*O)}function f(){if(o){var l,x=o.length,v=t.length,m=new Map(o.map((A,$)=>[n(A,$,o),A])),w;for(l=0,u=new Array(x);l<v;++l)w=t[l],w.index=l,typeof w.source!="object"&&(w.source=Pt(m,w.source)),typeof w.target!="object"&&(w.target=Pt(m,w.target)),u[w.source.index]=(u[w.source.index]||0)+1,u[w.target.index]=(u[w.target.index]||0)+1;for(l=0,h=new Array(v);l<v;++l)w=t[l],h[l]=u[w.source.index]/(u[w.source.index]+u[w.target.index]);i=new Array(v),M(),s=new Array(v),y()}}function M(){if(o)for(var l=0,x=t.length;l<x;++l)i[l]=+e(t[l],l,t)}function y(){if(o)for(var l=0,x=t.length;l<x;++l)s[l]=+r(t[l],l,t)}return _.initialize=function(l,...x){o=l,c=x.find(v=>typeof v=="function")||Math.random,a=x.find(v=>[1,2,3].includes(v))||2,f()},_.links=function(l){return arguments.length?(t=l,f(),_):t},_.id=function(l){return arguments.length?(n=l,_):n},_.iterations=function(l){return arguments.length?(d=+l,_):d},_.strength=function(l){return arguments.length?(e=typeof l=="function"?l:Y(+l),M(),_):e},_.distance=function(l){return arguments.length?(r=typeof l=="function"?l:Y(+l),y(),_):r},_}var xe={value:()=>{}};function fn(){for(var t=0,n=arguments.length,e={},i;t<n;++t){if(!(i=arguments[t]+"")||i in e||/[\s.]/.test(i))throw new Error("illegal type: "+i);e[i]=[]}return new _t(e)}function _t(t){this._=t}function ye(t,n){return t.trim().split(/^|\s+/).map(function(e){var i="",r=e.indexOf(".");if(r>=0&&(i=e.slice(r+1),e=e.slice(0,r)),e&&!n.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:i}})}_t.prototype=fn.prototype={constructor:_t,on:function(t,n){var e=this._,i=ye(t+"",e),r,s=-1,o=i.length;if(arguments.length<2){for(;++s<o;)if((r=(t=i[s]).type)&&(r=we(e[r],t.name)))return r;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++s<o;)if(r=(t=i[s]).type)e[r]=jt(e[r],t.name,n);else if(n==null)for(r in e)e[r]=jt(e[r],t.name,null);return this},copy:function(){var t={},n=this._;for(var e in n)t[e]=n[e].slice();return new _t(t)},call:function(t,n){if((r=arguments.length-2)>0)for(var e=new Array(r),i=0,r,s;i<r;++i)e[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(s=this._[t],i=0,r=s.length;i<r;++i)s[i].value.apply(n,e)},apply:function(t,n,e){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var i=this._[t],r=0,s=i.length;r<s;++r)i[r].value.apply(n,e)}};function we(t,n){for(var e=0,i=t.length,r;e<i;++e)if((r=t[e]).name===n)return r.value}function jt(t,n,e){for(var i=0,r=t.length;i<r;++i)if(t[i].name===n){t[i]=xe,t=t.slice(0,i).concat(t.slice(i+1));break}return e!=null&&t.push({name:n,value:e}),t}var ct=0,dt=0,lt=0,cn=1e3,xt,gt,yt=0,ot=0,wt=0,pt=typeof performance=="object"&&performance.now?performance:Date,un=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function hn(){return ot||(un(ve),ot=pt.now()+wt)}function ve(){ot=0}function At(){this._call=this._time=this._next=null}At.prototype=ln.prototype={constructor:At,restart:function(t,n,e){if(typeof t!="function")throw new TypeError("callback is not a function");e=(e==null?hn():+e)+(n==null?0:+n),!this._next&>!==this&&(gt?gt._next=this:xt=this,gt=this),this._call=t,this._time=e,It()},stop:function(){this._call&&(this._call=null,this._time=1/0,It())}};function ln(t,n,e){var i=new At;return i.restart(t,n,e),i}function Me(){hn(),++ct;for(var t=xt,n;t;)(n=ot-t._time)>=0&&t._call.call(void 0,n),t=t._next;--ct}function Ut(){ot=(yt=pt.now())+wt,ct=dt=0;try{Me()}finally{ct=0,ze(),ot=0}}function me(){var t=pt.now(),n=t-yt;n>cn&&(wt-=n,yt=t)}function ze(){for(var t,n=xt,e,i=1/0;n;)n._call?(i>n._time&&(i=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:xt=e);gt=t,It(i)}function It(t){if(!ct){dt&&(dt=clearTimeout(dt));var n=t-ot;n>24?(t<1/0&&(dt=setTimeout(Ut,t-pt.now()-wt)),lt&&(lt=clearInterval(lt))):(lt||(yt=pt.now(),lt=setInterval(me,cn)),ct=1,un(Ut))}}const Ne=1664525,Ae=1013904223,Wt=4294967296;function Ie(){let t=1;return()=>(t=(Ne*t+Ae)%Wt)/Wt}var Yt=3;function mt(t){return t.x}function Kt(t){return t.y}function ke(t){return t.z}var Se=10,$e=Math.PI*(3-Math.sqrt(5)),be=Math.PI*20/(9+Math.sqrt(221));function it(t,n){n=n||2;var e=Math.min(Yt,Math.max(1,Math.round(n))),i,r=1,s=.001,o=1-Math.pow(s,1/300),a=0,u=.6,h=new Map,c=ln(_),d=fn("tick","end"),g=Ie();t==null&&(t=[]);function _(){f(),d.call("tick",i),r<s&&(c.stop(),d.call("end",i))}function f(l){var x,v=t.length,m;l===void 0&&(l=1);for(var w=0;w<l;++w)for(r+=(a-r)*o,h.forEach(function(A){A(r)}),x=0;x<v;++x)m=t[x],m.fx==null?m.x+=m.vx*=u:(m.x=m.fx,m.vx=0),e>1&&(m.fy==null?m.y+=m.vy*=u:(m.y=m.fy,m.vy=0)),e>2&&(m.fz==null?m.z+=m.vz*=u:(m.z=m.fz,m.vz=0));return i}function M(){for(var l=0,x=t.length,v;l<x;++l){if(v=t[l],v.index=l,v.fx!=null&&(v.x=v.fx),v.fy!=null&&(v.y=v.fy),v.fz!=null&&(v.z=v.fz),isNaN(v.x)||e>1&&isNaN(v.y)||e>2&&isNaN(v.z)){var m=Se*(e>2?Math.cbrt(.5+l):e>1?Math.sqrt(.5+l):l),w=l*$e,A=l*be;e===1?v.x=m:e===2?(v.x=m*Math.cos(w),v.y=m*Math.sin(w)):(v.x=m*Math.sin(w)*Math.cos(A),v.y=m*Math.cos(w),v.z=m*Math.sin(w)*Math.sin(A))}(isNaN(v.vx)||e>1&&isNaN(v.vy)||e>2&&isNaN(v.vz))&&(v.vx=0,e>1&&(v.vy=0),e>2&&(v.vz=0))}}function y(l){return l.initialize&&l.initialize(t,g,e),l}return M(),i={tick:f,restart:function(){return c.restart(_),i},stop:function(){return c.stop(),i},numDimensions:function(l){return arguments.length?(e=Math.min(Yt,Math.max(1,Math.round(l))),h.forEach(y),i):e},nodes:function(l){return arguments.length?(t=l,M(),h.forEach(y),i):t},alpha:function(l){return arguments.length?(r=+l,i):r},alphaMin:function(l){return arguments.length?(s=+l,i):s},alphaDecay:function(l){return arguments.length?(o=+l,i):+o},alphaTarget:function(l){return arguments.length?(a=+l,i):a},velocityDecay:function(l){return arguments.length?(u=1-l,i):1-u},randomSource:function(l){return arguments.length?(g=l,h.forEach(y),i):g},force:function(l,x){return arguments.length>1?(x==null?h.delete(l):h.set(l,y(x)),i):h.get(l)},find:function(){var l=Array.prototype.slice.call(arguments),x=l.shift()||0,v=(e>1?l.shift():null)||0,m=(e>2?l.shift():null)||0,w=l.shift()||1/0,A=0,$=t.length,p,S,q,C,O,z;for(w*=w,A=0;A<$;++A)O=t[A],p=x-O.x,S=v-(O.y||0),q=m-(O.z||0),C=p*p+S*S+q*q,C<w&&(z=O,w=C);return z},on:function(l,x){return arguments.length>1?(d.on(l,x),i):d.on(l)}}}function rt(){var t,n,e,i,r,s=Y(-30),o,a=1,u=1/0,h=.81;function c(f){var M,y=t.length,l=(n===1?kt(t,mt):n===2?$t(t,mt,Kt):n===3?Et(t,mt,Kt,ke):null).visitAfter(g);for(r=f,M=0;M<y;++M)e=t[M],l.visit(_)}function d(){if(t){var f,M=t.length,y;for(o=new Array(M),f=0;f<M;++f)y=t[f],o[y.index]=+s(y,f,t)}}function g(f){var M=0,y,l,x=0,v,m,w,A,$=f.length;if($){for(v=m=w=A=0;A<$;++A)(y=f[A])&&(l=Math.abs(y.value))&&(M+=y.value,x+=l,v+=l*(y.x||0),m+=l*(y.y||0),w+=l*(y.z||0));M*=Math.sqrt(4/$),f.x=v/x,n>1&&(f.y=m/x),n>2&&(f.z=w/x)}else{y=f,y.x=y.data.x,n>1&&(y.y=y.data.y),n>2&&(y.z=y.data.z);do M+=o[y.data.index];while(y=y.next)}f.value=M}function _(f,M,y,l,x){if(!f.value)return!0;var v=[y,l,x][n-1],m=f.x-e.x,w=n>1?f.y-e.y:0,A=n>2?f.z-e.z:0,$=v-M,p=m*m+w*w+A*A;if($*$/h<p)return p<u&&(m===0&&(m=Q(i),p+=m*m),n>1&&w===0&&(w=Q(i),p+=w*w),n>2&&A===0&&(A=Q(i),p+=A*A),p<a&&(p=Math.sqrt(a*p)),e.vx+=m*f.value*r/p,n>1&&(e.vy+=w*f.value*r/p),n>2&&(e.vz+=A*f.value*r/p)),!0;if(f.length||p>=u)return;(f.data!==e||f.next)&&(m===0&&(m=Q(i),p+=m*m),n>1&&w===0&&(w=Q(i),p+=w*w),n>2&&A===0&&(A=Q(i),p+=A*A),p<a&&(p=Math.sqrt(a*p)));do f.data!==e&&($=o[f.data.index]*r/p,e.vx+=m*$,n>1&&(e.vy+=w*$),n>2&&(e.vz+=A*$));while(f=f.next)}return c.initialize=function(f,...M){t=f,i=M.find(y=>typeof y=="function")||Math.random,n=M.find(y=>[1,2,3].includes(y))||2,d()},c.strength=function(f){return arguments.length?(s=typeof f=="function"?f:Y(+f),d(),c):s},c.distanceMin=function(f){return arguments.length?(a=f*f,c):Math.sqrt(a)},c.distanceMax=function(f){return arguments.length?(u=f*f,c):Math.sqrt(u)},c.theta=function(f){return arguments.length?(h=f*f,c):Math.sqrt(h)},c}function Tt(t){var n=Y(.1),e,i,r;typeof t!="function"&&(t=Y(t==null?0:+t));function s(a){for(var u=0,h=e.length,c;u<h;++u)c=e[u],c.vx+=(r[u]-c.x)*i[u]*a}function o(){if(e){var a,u=e.length;for(i=new Array(u),r=new Array(u),a=0;a<u;++a)i[a]=isNaN(r[a]=+t(e[a],a,e))?0:+n(e[a],a,e)}}return s.initialize=function(a){e=a,o()},s.strength=function(a){return arguments.length?(n=typeof a=="function"?a:Y(+a),o(),s):n},s.x=function(a){return arguments.length?(t=typeof a=="function"?a:Y(+a),o(),s):t},s}function Ot(t){var n=Y(.1),e,i,r;typeof t!="function"&&(t=Y(t==null?0:+t));function s(a){for(var u=0,h=e.length,c;u<h;++u)c=e[u],c.vy+=(r[u]-c.y)*i[u]*a}function o(){if(e){var a,u=e.length;for(i=new Array(u),r=new Array(u),a=0;a<u;++a)i[a]=isNaN(r[a]=+t(e[a],a,e))?0:+n(e[a],a,e)}}return s.initialize=function(a){e=a,o()},s.strength=function(a){return arguments.length?(n=typeof a=="function"?a:Y(+a),o(),s):n},s.y=function(a){return arguments.length?(t=typeof a=="function"?a:Y(+a),o(),s):t},s}function Ct(t){var n=Y(.1),e,i,r;typeof t!="function"&&(t=Y(t==null?0:+t));function s(a){for(var u=0,h=e.length,c;u<h;++u)c=e[u],c.vz+=(r[u]-c.z)*i[u]*a}function o(){if(e){var a,u=e.length;for(i=new Array(u),r=new Array(u),a=0;a<u;++a)i[a]=isNaN(r[a]=+t(e[a],a,e))?0:+n(e[a],a,e)}}return s.initialize=function(a){e=a,o()},s.strength=function(a){return arguments.length?(n=typeof a=="function"?a:Y(+a),o(),s):n},s.z=function(a){return arguments.length?(t=typeof a=="function"?a:Y(+a),o(),s):t},s}function Ee(t){let n=2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return n>>>0}function qe(t){let n=t>>>0;return()=>(n=Math.imul(n,1664525)+1013904223>>>0,n/4294967296)}function ut(t){return qe(Ee(t))}const Z=.55,Te=12,Oe=60,zt=60;function Ce(t){const n=new Map(t.map((e,i)=>[e.id,i]));return t.map(e=>`${e.parents.map(r=>n.get(r)??-1).join(".")}:${e.radius.toFixed(2)}`).join("|")}function Fe(t,n,e){const[i,r,s]=t,o=i*Math.cos(n)+s*Math.sin(n),a=-i*Math.sin(n)+s*Math.cos(n),u=r*Math.cos(e)-a*Math.sin(e),h=r*Math.sin(e)+a*Math.cos(e);return[o,u,h]}function Le(t,n,e){const i=f=>Math.hypot(f[0],f[1],f[2]),r=i(n),s=i(e);if(r<1e-9||s<1e-9)return t;const o=[n[0]/r,n[1]/r,n[2]/r],a=[e[0]/s,e[1]/s,e[2]/s],u=[o[1]*a[2]-o[2]*a[1],o[2]*a[0]-o[0]*a[2],o[0]*a[1]-o[1]*a[0]],h=i(u),c=o[0]*a[0]+o[1]*a[1]+o[2]*a[2];if(h<1e-9)return c>0?t:[-t[0],-t[1],-t[2]];const d=[u[0]/h,u[1]/h,u[2]/h],g=d[0]*t[0]+d[1]*t[1]+d[2]*t[2],_=[d[1]*t[2]-d[2]*t[1],d[2]*t[0]-d[0]*t[2],d[0]*t[1]-d[1]*t[0]];return[t[0]*c+_[0]*h+d[0]*g*(1-c),t[1]*c+_[1]*h+d[1]*g*(1-c),t[2]*c+_[2]*h+d[2]*g*(1-c)]}function Bt(t,n,e){if(n.length===0)return t;let i=0;for(const r of n)i+=e.get(r.id.slice(6))??Z;return i/=n.length,Math.max(t+2,Math.sqrt(n.length)*i*1.6)}function Nt(t,n,e){const i=n<=1?0:1-2*(t+.5)/n,r=Math.sqrt(Math.max(0,1-i*i)),s=t*Math.PI*(3-Math.sqrt(5));return[Math.cos(s)*r*e,i*e,Math.sin(s)*r*e]}function Ft(t,n,e=()=>{},i="clumps",r=ut){const s=new Map(t.map(z=>[z.id,z])),o=new Map,a=[];for(const z of t)z.group===null?a.push(z):o.set(z.group,[...o.get(z.group)??[],z]);const u=new Map,h=new Map,c=new Map,d=new Set;let g=0;const _=Math.max(1,o.size),f=new Map;for(const[z,k]of o){const I=k.filter(b=>b.seed!==void 0),N=[0,0,0];for(const b of I)N[0]+=b.seed[0],N[1]+=b.seed[1],N[2]+=b.seed[2];I.length>0&&(N[0]/=I.length,N[1]/=I.length,N[2]/=I.length,c.set(z,N)),k.every(b=>b.frozen===!0&&b.seed!==void 0)&&d.add(z);const E=new Map,T=I.length===0?Ce(k):null,L=T===null?void 0:f.get(T);if(I.length===k.length)for(const b of k)E.set(b.id,[b.seed[0]-N[0],b.seed[1]-N[1],b.seed[2]-N[2]]);else if(L!==void 0){const b=r(z),G=b()*Math.PI*2,W=(b()-.5)*Math.PI;k.forEach((P,j)=>{E.set(P.id,Fe(L[j]??[0,0,0],G,W))})}else{const b=k.map(F=>{const V={id:F.id,r:F.radius};return F.seed!==void 0&&(V.x=F.seed[0]-N[0],V.y=F.seed[1]-N[1],V.z=F.seed[2]-N[2],F.frozen===!0&&(V.fx=V.x,V.fy=V.y,V.fz=V.z)),V}),G=new Set(k.map(F=>F.id)),W=[];for(const F of k)for(const V of F.parents)G.has(V)&&W.push({source:V,target:F.id});const P=new Map(k.map(F=>[F.id,F.radius])),j=it(b,3).force("link",ft(W).id(F=>F.id).distance(n.link?F=>(P.get(F.source.id)??Z)+(P.get(F.target.id)??Z)+1.4:2.2)).force("charge",rt().strength(F=>n.charge?-6*(F.r/Z)**2:-6).distanceMax(Te)).force("center",nt(0,0,0)).stop();n.collide&&j.force("collide",et().radius(F=>F.r*1.2));for(let F=0;F<Oe;F++)j.tick();const J=[0,0,0];for(const F of b)J[0]+=F.x??0,J[1]+=F.y??0,J[2]+=F.z??0;J[0]/=b.length,J[1]/=b.length,J[2]/=b.length;for(const F of b)E.set(F.id,[(F.x??0)-J[0],(F.y??0)-J[1],(F.z??0)-J[2]]);T!==null&&f.set(T,k.map(F=>E.get(F.id)??[0,0,0]))}let R=Z;for(const b of k){const G=E.get(b.id)??[0,0,0];u.set(b.id,G),R=Math.max(R,Math.hypot(G[0],G[1],G[2])+b.radius)}h.set(z,R),g+=1,g%50===0&&e(.3*(g/_))}e(.3);const M=z=>{const k=s.get(z);return k!==void 0&&k.group!==null?`group:${k.group}`:z},y=[],l=new Map;let x=!1;for(const[z]of o){const k=`group:${z}`,I=h.get(z)??Z,N={id:k,r:I},E=c.get(z);E!==void 0&&(N.x=E[0],N.y=E[1],N.z=E[2],d.has(z)&&(N.fx=E[0],N.fy=E[1],N.fz=E[2],x=!0)),l.set(k,I),y.push(N)}for(const z of a){const k={id:z.id,r:z.radius};z.seed!==void 0&&(k.x=z.seed[0],k.y=z.seed[1],k.z=z.seed[2],z.frozen===!0&&(k.fx=z.seed[0],k.fy=z.seed[1],k.fz=z.seed[2],x=!0)),l.set(z.id,z.radius),y.push(k)}const v=new Set,m=[];for(const z of t)for(const k of z.parents){if(!s.has(k))continue;const I=M(k),N=M(z.id);if(I===N)continue;const E=`${I}\0${N}`;v.has(E)||(v.add(E),m.push({source:I,target:N}))}const w=new Map;for(const z of m)if(z.source.startsWith("group:")!==z.target.startsWith("group:")){const k=z.source.startsWith("group:")?z.source:z.target,I=z.source.startsWith("group:")?z.target:z.source;w.has(k)||w.set(k,I)}const A=new Map;for(const z of y){const k=w.get(z.id);k!==void 0&&A.set(k,[...A.get(k)??[],z])}const $=y.reduce((z,k)=>z+k.r*k.r,0),p=y.filter(z=>!z.id.startsWith("group:"));p.forEach((z,k)=>{if(z.x!==void 0)return;const[I,N,E]=Nt(k,p.length,Math.sqrt($)*1.2+10);z.x=I,z.y=N,z.z=E});for(const[z,k]of A){const I=y.find(E=>E.id===z),N=Math.sqrt(k.reduce((E,T)=>E+T.r*T.r,0))*1.4+2;k.forEach((E,T)=>{if(E.x!==void 0)return;const[L,R,b]=Nt(T,k.length,N);E.x=(I?.x??0)+L,E.y=(I?.y??0)+R,E.z=(I?.z??0)+b})}const S=new Set;if(i==="spokes"){const z=I=>{const N=o.get(I)??[],E=new Set(N.map(L=>L.id)),T=N.find(L=>L.parents.some(R=>!E.has(R)))??N[0];return T===void 0?[0,0,0]:u.get(T.id)??[0,0,0]},k=[];for(const I of y){if(I.id.startsWith("group:")&&w.has(I.id)){S.add(I.id);continue}if(I.id.startsWith("group:"))k.push(I);else{const N=A.get(I.id)??[];let E=I.r;const T=Bt(I.r,N,h);for(const L of N){const R=L.id.slice(6),b=z(R);E=Math.max(E,T+Math.hypot(b[0],b[1],b[2])+2*(h.get(R)??Z))}k.push({id:I.id,r:E,x:I.x,y:I.y,z:I.z,...I.fx!==void 0?{fx:I.fx,fy:I.fy,fz:I.fz}:{}})}}if(!k.every(I=>I.fx!==void 0)){const I=it(k,3).force("charge",rt().strength(N=>-1.5*N.r)).force("collide",et().radius(N=>N.r*.9)).stop();x||I.force("center",nt(0,0,0));for(let N=0;N<zt;N++)I.tick(),N%5===0&&e(.3+.7*(N/zt))}for(const I of k){const N=y.find(E=>E.id===I.id);N!==void 0&&N!==I&&(N.x=I.x,N.y=I.y,N.z=I.z)}for(const I of y){if(I.id.startsWith("group:")||!A.has(I.id))continue;const N=A.get(I.id)??[],E=Bt(I.r,N,h);N.forEach((T,L)=>{if(T.fx!==void 0||c.has(T.id.slice(6)))return;const R=z(T.id.slice(6)),b=Nt(L,N.length,1),G=.35+.65*(L*.6180339887%1),W=I.r+1.4+E*G+Math.hypot(R[0],R[1],R[2]);T.x=(I.x??0)+b[0]*W,T.y=(I.y??0)+b[1]*W,T.z=(I.z??0)+b[2]*W})}}if(!y.every(z=>z.fx!==void 0)&&i!=="spokes"){const z=it(y,3).force("link",ft(m).id(N=>N.id).distance(n.link?N=>(l.get(N.source.id)??Z)+(l.get(N.target.id)??Z)+1.4:2.2)).stop(),k=rt().strength(N=>n.charge?-6*(N.r/Z)**2:-6);if(n.reach!==void 0&&k.distanceMax(n.reach),z.force("charge",k),x||z.force("center",nt(0,0,0)),n.collide&&z.force("collide",et().radius(N=>N.r*1.05)),n.gravity){const N=E=>Math.min(1,(E.r/Z)**2*.08);z.force("gx",Tt(0).strength(N)).force("gy",Ot(0).strength(N)).force("gz",Ct(0).strength(N))}const I=zt;for(let N=0;N<I;N++)z.tick(),N%5===0&&e(.3+.7*(N/I))}const C=new Map(y.map(z=>[z.id,z]));if(i==="spokes")for(const[z,k]of o){if(k.some(P=>P.seed!==void 0))continue;const I=`group:${z}`,N=C.get(I),E=w.get(I),T=E===void 0?void 0:C.get(E);if(N===void 0||T===void 0)continue;const L=[(N.x??0)-(T.x??0),(N.y??0)-(T.y??0),(N.z??0)-(T.z??0)],R=new Set(k.map(P=>P.id)),b=k.find(P=>P.parents.some(j=>!R.has(j)))??k[0],G=u.get(b.id)??[0,0,0],W=[-G[0],-G[1],-G[2]];for(const P of k){const j=u.get(P.id)??[0,0,0];u.set(P.id,Le(j,W,L))}}const O={};for(const z of t){const k=C.get(M(z.id)),I=[k?.x??0,k?.y??0,k?.z??0],N=z.group===null?[0,0,0]:u.get(z.id)??[0,0,0];O[z.id]=[I[0]+N[0],I[1]+N[1],I[2]+N[2]]}return e(1),O}const Ht=80;function dn(t,n,e=()=>{},i=ut){const r=t.some(g=>g.seed===void 0),s=r?Ft(t,n,g=>e(.05*g),"spokes",i):{};e(.05);const o=t.map(g=>{const _=g.seed??s[g.id],f={id:g.id,r:g.radius};return _!==void 0&&(f.x=_[0],f.y=_[1],f.z=_[2],g.frozen===!0&&g.seed!==void 0&&(f.fx=_[0],f.fy=_[1],f.fz=_[2])),f}),a=new Set(t.map(g=>g.id)),u=[];for(const g of t)for(const _ of g.parents)a.has(_)&&u.push({source:_,target:g.id});const h=new Map(t.map(g=>[g.id,g.radius])),c=o.some(g=>g.fx!==void 0);if(!o.every(g=>g.fx!==void 0)){const g=it(o,3).force("link",ft(u).id(f=>f.id).distance(n.link?f=>(h.get(f.source.id)??U)+(h.get(f.target.id)??U)+1.4:2.2)).stop(),_=rt().strength(f=>n.charge?-6*(f.r/U)**2:-6);if(n.reach!==void 0&&_.distanceMax(n.reach),g.force("charge",_),c||g.force("center",nt(0,0,0)),n.collide&&g.force("collide",et().radius(f=>f.r*1.2)),n.gravity){const f=M=>(M.r/U)**2*.08;g.force("gx",Tt(0).strength(f)).force("gy",Ot(0).strength(f)).force("gz",Ct(0).strength(f))}r&&g.alpha(.6);for(let f=0;f<Ht;f++)g.tick(),f%2===0&&e(.05+.95*(f/Ht))}const d={};for(const g of o)d[g.id]=[g.x??0,g.y??0,g.z??0];return e(1),d}const Xt=160,Vt=120,Qt=5,De=.9,Zt=.3,Re=.9;function gn(t,n){const e=new Map;for(const[i,r]of t)e.set(i,n===0||r/n>Re?0:Math.log(n/Math.max(1,r)));return e}function Ge(t,n,e=()=>{}){const i=p=>typeof p.attrs?.plugin=="string"?p.attrs.plugin:null,r=p=>p.attrs?.kind==="star"&&i(p)!==null,s=t.filter(r),o=new Map(s.map(p=>[i(p),p])),a=t.filter(p=>!r(p)),u=new Map;for(const p of a){const S=i(p);p.group===null||S===null||!o.has(S)||u.set(p.group,(u.get(p.group)??new Set).add(S))}const h=new Map;for(const p of u.values())for(const S of p)h.set(S,(h.get(S)??0)+1);const c=gn(h,u.size),d=Math.max(1e-9,...c.values()),g=new Map;for(const p of u.values()){const S=[...p].sort();for(let q=0;q<S.length;q++)for(let C=q+1;C<S.length;C++){const O=`${S[q]}\0${S[C]}`;g.set(O,(g.get(O)??0)+1)}}const _=Math.max(6,Math.sqrt(s.length)*4,Math.sqrt(a.length)*1.6),f=s.map(p=>Jt(p,_,ut(`star:${p.id}`))),M=[];for(const[p,S]of g){const[q,C]=p.split("\0"),O=Math.min(h.get(q)??1,h.get(C)??1);M.push({source:o.get(q).id,target:o.get(C).id,share:S/Math.max(1,O)})}if(f.length>0&&f.some(p=>p.fx===void 0)){const p=it(f,3).force("link",ft(M).id(S=>S.id).distance(S=>_*(1.1-Number(S.share))).strength(S=>.05+.6*Number(S.share))).force("charge",rt().strength(-30).distanceMax(_*3)).force("collide",et().radius(S=>S.r*3)).force("center",nt(0,0,0)).stop();for(let S=0;S<Xt;S++)p.tick(),S%4===0&&e(.4*(S/Xt))}const y=new Map(f.map(p=>[p.id,[p.x??0,p.y??0,p.z??0]]));e(.4);const l=[...f.map(p=>({...p,fx:p.x??0,fy:p.y??0,fz:p.z??0})),...a.map(p=>{const S=i(p),q=S===null?void 0:o.get(S),C=q===void 0?void 0:y.get(q.id);return Jt(p,2,ut(`stage:${p.id}`),C)})],x=new Set(t.map(p=>p.id)),v=new Map(t.map(p=>[p.id,p.radius])),m=[];for(const p of a){for(const z of p.parents)x.has(z)&&m.push({source:z,target:p.id,strength:1,length:(v.get(z)??U)+p.radius+1.4});const S=i(p),q=S===null?void 0:o.get(S),C=S===null?0:c.get(S)??0,O=p.group===null?1:Math.max(1,u.get(p.group)?.size??1);if(q!==void 0&&C>0){const z=C/d,k=(Zt+(De-Zt)*z)/Math.sqrt(O);m.push({source:q.id,target:p.id,strength:k,length:q.radius+p.radius+1})}}const w=it(l,3).force("link",ft(m).id(p=>p.id).distance(p=>Number(p.length)).strength(p=>Number(p.strength))).stop();if(n.charge){const p=rt().strength(S=>-6*(S.r/U)**2);p.distanceMax(Math.min(n.reach??Qt,Qt)),w.force("charge",p)}n.collide&&w.force("collide",et().radius(p=>p.r*1.2));const A=l.some(p=>p.fx===void 0);for(let p=0;A&&p<Vt;p++)w.tick(),p%4===0&&e(.4+.6*(p/Vt));const $={};for(const p of l)$[p.id]=[p.x??0,p.y??0,p.z??0];return e(1),$}function Jt(t,n,e,i=[0,0,0]){const r={id:t.id,r:t.radius},s=t.seed??[i[0]+(e()-.5)*2*n,i[1]+(e()-.5)*2*n,i[2]+(e()-.5)*2*n];return r.x=s[0],r.y=s[1],r.z=s[2],t.frozen===!0&&t.seed!==void 0&&(r.fx=s[0],r.fy=s[1],r.fz=s[2]),r}const ht=.4,Pe=400,at=.35,je=.01,Ue=3;function tn(t,n,e){let i=0,r=0;for(const s of new Set([...t,...n])){const o=e.get(s)??0;r+=o,t.has(s)&&n.has(s)&&(i+=o)}return r===0?0:i/r}const nn=1.4,We=Math.PI/3;function Ye(t,n){const e=new Map,i=new Map(t.map(c=>[c.id,c])),r=new Map,s=[];for(const c of t){const d=c.parents.find(g=>i.has(g));d===void 0?s.push(c):r.set(d,[...r.get(d)??[],c])}const o=new Map,a=[];s.forEach((c,d)=>{const g=st(n),_=d===0?0:c.radius*2+nn;e.set(c.id,[g[0]*_,g[1]*_,g[2]*_]),o.set(c.id,g),a.push(c)});for(let c=a.shift();c!==void 0;c=a.shift()){const d=e.get(c.id),g=o.get(c.id);for(const _ of r.get(c.id)??[]){if(e.has(_.id))continue;const f=n()*We,M=Ke(g,n),y=pn([g[0]*Math.cos(f)+M[0]*Math.sin(f),g[1]*Math.cos(f)+M[1]*Math.sin(f),g[2]*Math.cos(f)+M[2]*Math.sin(f)]),l=c.radius+_.radius+nn;e.set(_.id,[d[0]+y[0]*l,d[1]+y[1]*l,d[2]+y[2]*l]),o.set(_.id,y),a.push(_)}}for(const c of t)e.has(c.id)||e.set(c.id,[0,0,0]);const u=[0,0,0];for(const c of e.values())u[0]+=c[0]/e.size,u[1]+=c[1]/e.size,u[2]+=c[2]/e.size;let h=U;for(const c of t){const d=e.get(c.id),g=[d[0]-u[0],d[1]-u[1],d[2]-u[2]];e.set(c.id,g),h=Math.max(h,Math.hypot(g[0],g[1],g[2])+c.radius)}return{local:e,radius:h}}function pn(t){const n=Math.max(1e-9,Math.hypot(t[0],t[1],t[2]));return[t[0]/n,t[1]/n,t[2]/n]}function Ke(t,n){const e=Math.abs(t[0])<.9?[1,0,0]:[0,1,0],i=pn([t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]),r=[t[1]*i[2]-t[2]*i[1],t[2]*i[0]-t[0]*i[2],t[0]*i[1]-t[1]*i[0]],s=n()*Math.PI*2;return[i[0]*Math.cos(s)+r[0]*Math.sin(s),i[1]*Math.cos(s)+r[1]*Math.sin(s),i[2]*Math.cos(s)+r[2]*Math.sin(s)]}function st(t){const n=t()*2-1,e=t()*Math.PI*2,i=Math.sqrt(1-n*n);return[i*Math.cos(e),i*Math.sin(e),n]}class Be{size;cells=new Map;constructor(n){this.size=n}key(n){return`${Math.floor(n[0]/this.size)},${Math.floor(n[1]/this.size)},${Math.floor(n[2]/this.size)}`}add(n){const e=this.key(n.centre);this.cells.set(e,[...this.cells.get(e)??[],n])}touching(n,e){const i=[],[r,s,o]=[Math.floor(n[0]/this.size),Math.floor(n[1]/this.size),Math.floor(n[2]/this.size)];for(let a=-1;a<=1;a++)for(let u=-1;u<=1;u++)for(let h=-1;h<=1;h++)for(const c of this.cells.get(`${r+a},${s+u},${o+h}`)??[]){const d=e+c.particle.radius+ht;Math.hypot(n[0]-c.centre[0],n[1]-c.centre[1],n[2]-c.centre[2])<d&&i.push(c)}return i}}function en(t,n,e,i){let r=[n[0]-t.centre[0],n[1]-t.centre[1],n[2]-t.centre[2]];const s=Math.hypot(r[0],r[1],r[2]);r=s<1e-9?st(i):[r[0]/s,r[1]/s,r[2]/s];const o=e+t.particle.radius+ht;return[t.centre[0]+r[0]*o,t.centre[1]+r[1]*o,t.centre[2]+r[2]*o]}function He(t,n,e=()=>{}){const i={},r={};if(t.length>0&&t.every(f=>f.frozen===!0&&f.seed!==void 0)){for(const f of t)i[f.id]=f.seed;return e(1),{positions:i,arrival:r}}const s=new Map;for(const f of t){if(f.group===null){i[f.id]=[0,0,0];continue}s.set(f.group,[...s.get(f.group)??[],f])}const o=[...s].map(([f,M])=>{const y=new Set;let l=Number.POSITIVE_INFINITY;for(const m of M){const w=m.attrs?.plugin;typeof w=="string"&&y.add(w);const A=m.attrs?.createdAt;typeof A=="number"&&A<l&&(l=A)}if(M.every(m=>m.frozen===!0&&m.seed!==void 0)){const m=M.map(p=>p.seed),w=[0,1,2].map(p=>m.reduce((S,q)=>S+q[p],0)/m.length),A=new Map;let $=U;for(const p of M){const S=p.seed,q=[S[0]-w[0],S[1]-w[1],S[2]-w[2]];A.set(p.id,q),$=Math.max($,Math.hypot(q[0],q[1],q[2])+p.radius)}return{key:f,nodes:M,plugins:y,created:l,local:A,radius:$,held:!0,centre:w}}const{local:x,radius:v}=Ye(M,ut(`turn:${f}`));return{key:f,nodes:M,plugins:y,created:l,local:x,radius:v,held:!1}});o.sort((f,M)=>f.created-M.created||(f.key<M.key?-1:f.key>M.key?1:0));const a=new Map;for(const f of o)for(const M of f.plugins)a.set(M,(a.get(M)??0)+1);const u=gn(a,o.length),h=Math.max(U,...o.map(f=>f.radius)),c=new Be(2*h+ht),d=[];let g=0;const _=(f,M,y)=>{const l={particle:f,centre:y};d.push(l),c.add(l),g=Math.max(g,Math.hypot(y[0],y[1],y[2])+f.radius);for(const x of f.nodes){const v=f.local.get(x.id)??[0,0,0];i[x.id]=f.held&&x.seed!==void 0?x.seed:[y[0]+v[0],y[1]+v[1],y[2]+v[2]],r[x.id]=M}};return o.forEach((f,M)=>{f.held&&f.centre!==void 0&&_(f,M,f.centre)}),o.forEach((f,M)=>{if(f.held)return;const y=ut(`accrete:${f.key}`);let l;if(d.length===0)l=[0,0,0];else{let x=d[d.length-1],v=-1;for(const S of d){const q=tn(f.plugins,S.particle.plugins,u);q>=v&&(x=S,v=q)}const m=g+Ue*f.radius+h,w=Math.max(.5,f.radius*.5),A=st(y);let $=[A[0]*m,A[1]*m,A[2]*m],p=null;for(let S=0;S<Pe&&p===null;S++){const q=st(y),C=[x.centre[0]-$[0],x.centre[1]-$[1],x.centre[2]-$[2]],O=Math.max(1e-9,Math.hypot(C[0],C[1],C[2])),z=[q[0]*(1-at)+C[0]/O*at,q[1]*(1-at)+C[1]/O*at,q[2]*(1-at)+C[2]/O*at],k=[$[0]+z[0]*w,$[1]+z[1]*w,$[2]+z[2]*w],I=c.touching(k,f.radius);if(I.length===0){if(Math.hypot(k[0],k[1],k[2])>m*2){const T=st(y);$=[T[0]*m,T[1]*m,T[2]*m]}else $=k;continue}let N=I[0],E=-1;for(const T of I){const L=tn(f.plugins,T.particle.plugins,u);L>E&&(N=T,E=L)}if(y()<Math.max(je,E)&&(p=en(N,$,f.radius,y),c.touching(p,f.radius-1e-6).some(T=>T!==N&&_n(p,f.radius,T))&&(p=null)),p===null){const T=en(N,$,f.radius,y),L=[T[0]-N.centre[0],T[1]-N.centre[1],T[2]-N.centre[2]],R=Math.max(1e-9,Math.hypot(L[0],L[1],L[2]));$=[T[0]+L[0]/R*w,T[1]+L[1]/R*w,T[2]+L[2]/R*w]}}l=p??Xe(x,f.radius,c,y)}_(f,M,l),M%8===0&&e(M/Math.max(1,o.length))}),e(1),{positions:i,arrival:r}}function _n(t,n,e){return Math.hypot(t[0]-e.centre[0],t[1]-e.centre[1],t[2]-e.centre[2])<n+e.particle.radius+ht*.5}function Xe(t,n,e,i){for(let o=0;o<8;o++)for(let a=0;a<24;a++){const u=st(i),h=n+t.particle.radius+ht+o*n,c=[t.centre[0]+u[0]*h,t.centre[1]+u[1]*h,t.centre[2]+u[2]*h];if(!e.touching(c,n).some(d=>_n(c,n,d)))return c}const r=st(i),s=n+t.particle.radius+ht+8*n;return[t.centre[0]+r[0]*s,t.centre[1]+r[1]*s,t.centre[2]+r[2]*s]}function Ve(t){const n=new Map;for(const e of t)for(const i of e.parents)n.set(i,(n.get(i)??0)+1),n.set(e.id,(n.get(e.id)??0)+1);return t.map(e=>e.metric??n.get(e.id)??1)}function Qe(t,n=3,e=new Map,i=rn,r=new Set){const s=[];for(const x of t)for(const v of x.parents)s.push({source:v,target:x.id});const o=Ve(t),a=Math.max(...o,1),u=o.map(x=>U*(.5+x/a*1.2)),h=new Map(t.map((x,v)=>[x.id,u[v]??U])),c=t.map(x=>{const v=e.get(x.id);return v===void 0?{id:x.id}:r.has(x.id)?{id:x.id,x:v[0],y:v[1],z:v[2],fx:v[0],fy:v[1],fz:v[2]}:{id:x.id,x:v[0],y:v[1],z:v[2]}}),d=x=>r.has(x.id)&&x.fx!==void 0;let g=c,_=s;if(r.size>0){const x=new Set(c.filter(w=>!d(w)).map(w=>w.id));_=s.filter(w=>x.has(w.source)||x.has(w.target));const v=new Set(x);for(const w of _)v.add(w.source),v.add(w.target);g=c.filter(w=>v.has(w.id));const m=new Set(g.map(w=>w.id));_=_.filter(w=>m.has(w.source)&&m.has(w.target))}const f=rt().strength(i.charge?x=>r.has(x.id)?0:-6*((h.get(x.id)??U)/U)**2:x=>r.has(x.id)?0:-6);i.reach!==void 0&&f.distanceMax(i.reach);const M=it(g,n).force("link",ft(_).id(x=>x.id).distance(i.link?x=>(h.get(x.source.id)??U)+(h.get(x.target.id)??U)+1.4:2.2)).force("charge",f).stop();if(r.size===0&&M.force("center",n===2?nt(0,0):nt(0,0,0)),i.collide&&M.force("collide",et().radius(x=>(h.get(x.id)??U)*1.2)),i.gravity){const x=v=>((h.get(v.id)??U)/U)**2*.08;M.force("gx",Tt(0).strength(x)).force("gy",Ot(0).strength(x)),n===3&&M.force("gz",Ct(0).strength(x))}const y=g.length===0?0:e.size>0?90:150;let l=0;return{total:y,moving:g.length,step:x=>{for(let v=0;v<x&&l<y;v++,l++)M.tick()},place:()=>t.map((x,v)=>{const m=c[v];return{id:x.id,position:[m?.x??0,m?.y??0,m?.z??0],radius:u[v]??U}})}}function Ze(t,n=3,e=new Map,i=rn,r=new Set){const s=Qe(t,n,e,i,r);return s.step(s.total),s.place()}function Je(t){const n=new Map(t.map(f=>[f.id,f])),e=new Map,i=(f,M)=>{const y=e.get(f.id);if(y!==void 0)return y;if(M.has(f.id)||f.parentIds.length===0)return e.set(f.id,0),0;M.add(f.id);let l=0;for(const x of f.parentIds){const v=n.get(x);v&&(l=Math.max(l,i(v,M)+1))}return e.set(f.id,l),l};for(const f of t)i(f,new Set);const r=new Map,s=[],o=(f,M)=>f.id.localeCompare(M.id,void 0,{numeric:!0});for(const f of t){const M=f.parentIds.find(l=>n.has(l));if(M===void 0){s.push(f);continue}const y=r.get(M)??[];y.push(f),r.set(M,y)}s.sort(o);for(const f of r.values())f.sort(o);const a=new Map;let u=0;const h=new Set,c=f=>{h.add(f.id);const M=(r.get(f.id)??[]).filter(v=>!h.has(v.id));if(M.length===0){const v=u++;return a.set(f.id,v),[v,v]}let y=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(const v of M){const[m,w]=c(v);y=Math.min(y,m),l=Math.max(l,w)}const x=(y+l)/2;return a.set(f.id,x),[y,l]};for(const f of s)c(f);for(const f of t)a.has(f.id)||c(f);const d=Math.max(...Array.from(e.values()),0)+1,g=Math.max(u-1,0);return{placements:t.map(f=>({id:f.id,x:a.get(f.id)??0,tier:e.get(f.id)??0})),width:g,tierCount:d}}const ti=2.6,ni=2;function ei(t){const n=t.map(s=>s.metric??0),e=Math.max(...n,0),i=Je(t),r=new Map(i.placements.map(s=>[s.id,s]));return t.map(s=>{const o=r.get(s.id),a=((o?.x??0)-i.width/2)*ni,u=((i.tierCount-1)/2-(o?.tier??0))*ti,h=s.metric??0,c=e>0?.55+h/e*1:1,d=[a,u,0];return{id:s.id,position:d,radius:U*c}})}function vt(t){const n={id:t.id,parents:t.parents,radius:t.radius,group:t.group};return t.seed!==void 0&&(n.seed=t.seed),t.frozen!==void 0&&(n.frozen=t.frozen),n}function xn(t){const n=t.attrs?.metric;return typeof n=="number"?n:void 0}function yn(t){const n={};for(const e of t)n[e.id]=e.position;return n}const ii={id:"galaxy",label:"GALAXY",needs:[],run:(t,n)=>({positions:dn(t.nodes.map(vt),t.physics,n)})},ri={id:"spokes",label:"SPOKES",needs:[],run:(t,n)=>({positions:Ft(t.nodes.map(vt),t.physics,n,"spokes")})},si={id:"clumps",label:"CLUMPS",needs:[],run:(t,n)=>({positions:Ft(t.nodes.map(vt),t.physics,n,"clumps")})},oi={id:"ranked",label:"RANKED",needs:[],run:(t,n)=>{const e=t.nodes.map(r=>{const s={id:r.id,parentIds:r.parents},o=xn(r);return o!==void 0&&(s.metric=o),s}),i=yn(ei(e));return n(1),{positions:i}}},ai={id:"molecule",label:"MOLECULE",needs:[],run:(t,n)=>{const e=t.nodes.map(o=>{const a={id:o.id,parents:o.parents},u=xn(o);return u!==void 0&&(a.metric=u),a}),i=new Map,r=new Set;for(const o of t.nodes)o.seed!==void 0&&i.set(o.id,o.seed),o.frozen===!0&&r.add(o.id);const s=yn(Ze(e,3,i,t.physics,r));return n(1),{positions:s}}},fi={id:"constellations",label:"CONSTELLATIONS",needs:["plugin"],run:(t,n)=>({positions:Ge(t.nodes,t.physics,n)})},ci={id:"hubs",label:"HUBS",needs:[],run:(t,n)=>({positions:dn(t.nodes.map(vt),t.physics,n)})},ui={id:"accretion",label:"ACCRETION",needs:["plugin"],run:(t,n)=>He(t.nodes,t.physics,n)},hi=[ii,ri,si,fi,ci,ui,oi,ai];function li(t){return hi.find(n=>n.id===t)}self.onmessage=t=>{const{generation:n,nodes:e,physics:i,arrangement:r}=t.data;let s=-1;const o=h=>{const c=Math.floor(h*100);c!==s&&(s=c,self.postMessage({generation:n,type:"progress",fraction:h}))},a=li(r);if(a===void 0){self.postMessage({generation:n,type:"failed",reason:`no layout engine named ${r}`});return}const{positions:u}=a.run({nodes:e,physics:i},o);self.postMessage({generation:n,type:"done",positions:u})};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-
|
|
2
|
-
import{_ as h,b as u,I as c}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-C9XrSjdk.js","./_commonjsHelpers-CE1G-McA.js","./index-DfT-vEKx.js","./index-CVUcpNtC.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as h,b as u,I as c}from"./index-DfT-vEKx.js";const d={gray:"gray",hot:"hot",jet:"jet",cool:"cool"},m={wl:"contrast",pan:"pan",length:"measurement",angle:"angle"};class _{name="niivue";host;path;nv=null;module=null;layout="mpr";tool="wl";colormap="gray";slice=0;slices=0;refused=0;disposed=!1;constructor(s,t){this.host=s,this.path=t}async open(s){const t=document.createElement("canvas");t.className="image-canvas",s.appendChild(t),this.host.readout_set("LOADING"),this.host.progress_set({label:"READING VOLUME",done:0,total:0});const e=performance.now();if(this.module=await h(()=>import("./index-C9XrSjdk.js"),__vite__mapDeps([0,1,2,3]),import.meta.url),this.disposed)return;const i=new this.module.Niivue({isResizeCanvas:!0,logLevel:"error",dragAndDropEnabled:!1,crosshairWidth:.4,crosshairWidthUnit:"percent"});i.onLocationChange=o=>{const r=o,l=r.vox?.[2];l!==void 0&&(this.slice=l+1),this.host.readout_set(`${this.slices>0?`SLICE ${this.slice} OF ${this.slices} · `:""}${r.string??""}`)},await i.attachToCanvas(t);const n=this.path.split("/").pop()??"volume.nii.gz";try{await i.loadVolumes([{url:u(this.host.source.url_of(this.path),location.href),name:n}])}catch(o){this.refused=1,this.host.progress_set(null),this.host.readout_set("REFUSED 1 OF 1"),this.host.note(`image: ${this.path}: ${o instanceof Error?o.message:String(o)}`);return}if(this.host.progress_set(null),this.disposed)return;this.nv=i;const a=i.volumes[0]?.dims;this.slices=a?.[3]??0,i.setSliceType(i.sliceTypeMultiplanar),this.layout="mpr",this.host.readout_set(`${this.slices} SLICES`),this.host.note(`image: ${n} drawn in ${Math.round(performance.now()-e)} ms`),this.host.regard(this.path)}async layout_set(s){return s==="slab"||this.nv===null?!1:(this.nv.setSliceType(s==="single"?this.nv.sliceTypeAxial:s==="mpr"?this.nv.sliceTypeMultiplanar:this.nv.sliceTypeRender),this.layout=s,this.host.readout_set(`${this.slices} SLICES`),!0)}slice_set(s){if(this.nv===null||this.slices===0)return!1;const t=Math.max(1,Math.min(s,this.slices)),e=this.slice>0?this.slice:Math.ceil(this.slices/2);return this.nv.moveCrosshairInVox(0,0,t-e),this.slice=t,!0}wl_set(s,t){const e=this.nv?.volumes[0];return this.nv===null||e===void 0?!1:(e.cal_min=s,e.cal_max=t,this.nv.updateGLVolume(),!0)}colormap_set(s){const t=this.nv?.volumes[0];return this.nv===null||t?.id===void 0?!1:(this.colormap=s,this.nv.setColormap(t.id,d[s]),!0)}toolsOffered_get(){return c}ghost_set(s){return!1}tool_set(s){const t=m[s];return this.nv===null||t===void 0?!1:(this.nv.setDragMode(t),this.tool=s,!0)}annotations_export(){return Promise.resolve(null)}annotations_import(){return Promise.resolve(0)}async slices_fill(){return this.nv!==null}state_get(){return{engine:"niivue",layout:this.layout,slice:this.slice,slices:this.slices,tool:this.tool,primaryTool:this.tool,refused:this.refused,annotations:0,filled:this.nv!==null,colormap:this.colormap}}dispose(){this.disposed=!0,this.nv=null}}export{_ as NiivueEngine};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as v,as as _e,R as ft,K as Ge,L as Le,W as ke,N as We,k as de,E as X,t as vt,i as Me,x as ce,F as ht,Z as St,h as dt,D as Tt,al as wt,c as yt,at as Ct,d as Ve,au as xt,y as ue,ak as le,av as ze,j as pe}from"./cornerstoneEngine-
|
|
1
|
+
import{m as v,as as _e,R as ft,K as Ge,L as Le,W as ke,N as We,k as de,E as X,t as vt,i as Me,x as ce,F as ht,Z as St,h as dt,D as Tt,al as wt,c as yt,at as Ct,d as Ve,au as xt,y as ue,ak as le,av as ze,j as pe}from"./cornerstoneEngine-CAd9z_EH.js";import{ae as Ne,am as De,an as re,K as B,k as Z,al as $,D as se,U as $e,X as Be,B as Q,J as Et,E as Rt,ak as _t,$ as He,a2 as Mt,Z as Vt,b as Dt,_ as Ke,ao as Bt,ap as be,aq as mt,ar as Te,as as Ot,z as Ut,at as Ft,au as Pt,av as ae,ad as Gt,R as Lt,aw as Y,ah as kt,ai as Wt,C as zt,P as Nt,I as $t,a as Ht}from"./Texture-CFUfIEub.js";import"./index-DfT-vEKx.js";import"./_commonjsHelpers-CE1G-McA.js";function Kt(t){return t}function ye(t){if(t===null||t==="null")return null;if(t==="true")return!0;if(t==="false")return!1;if(!(t===void 0||t==="undefined"))return t[0]==="["&&t[t.length-1]==="]"?t.substring(1,t.length-1).split(",").map(e=>ye(e.trim())):t===""||Number.isNaN(Number(t))?t:Number(t)}function bt(t=!0,e=window.location.search){const r={},s=t?ye:Kt;return new URLSearchParams(e).forEach((n,a)=>{a&&(r[a]=n?s(n):!0)}),r}var It={toNativeType:ye,extractURLParameters:bt},jt={IS_START:0,IS_NONE:0,IS_ROTATE:1,IS_PAN:2,IS_SPIN:3,IS_DOLLY:4,IS_CAMERA_POSE:11,IS_WINDOW_LEVEL:1024,IS_SLICE:1025},Ce={States:jt},{vtkErrorMacro:Qt,VOID:Yt}=v;function Xt(t,e,r,s){return t.getRenderWindow().getViews()[0].worldToDisplay(e,r,s,t)}function Zt(t,e,r,s){return t.getRenderWindow().getViews()[0].displayToWorld(e,r,s,t)}var Jt={computeWorldToDisplay:Xt,computeDisplayToWorld:Zt};function qt(t,e){e.classHierarchy.push("vtkInteractorObserver");const r={...t};function s(){for(;e.subscribedEvents.length;)e.subscribedEvents.pop().unsubscribe()}function n(){Ne.handledEvents.forEach(a=>{t[`handle${a}`]&&e.subscribedEvents.push(e._interactor[`on${a}`](o=>e.processEvents?t[`handle${a}`](o):Yt,e.priority))})}t.setInteractor=a=>{a!==e._interactor&&(s(),e._interactor=a,a&&e.enabled&&n(),t.modified())},t.setEnabled=a=>{a!==e.enabled&&(s(),a&&(e._interactor?n():Qt(`
|
|
2
2
|
The interactor must be set before subscribing to events
|
|
3
3
|
`)),e.enabled=a,t.modified())},t.computeDisplayToWorld=(a,o,i,u)=>a?e._interactor.getView().displayToWorld(o,i,u,a):null,t.computeWorldToDisplay=(a,o,i,u)=>a?e._interactor.getView().worldToDisplay(o,i,u,a):null,t.setPriority=a=>{r.setPriority(a)&&e._interactor&&(s(),n())}}var At={enabled:!0,priority:0,processEvents:!0,subscribedEvents:[]};function Ie(t,e,r={}){Object.assign(e,At,r),v.obj(t,e),v.event(t,e,"InteractionEvent"),v.event(t,e,"StartInteractionEvent"),v.event(t,e,"EndInteractionEvent"),v.get(t,e,["_interactor","enabled"]),v.setGet(t,e,["priority","processEvents"]),v.moveToProtected(t,e,["interactor"]),qt(t,e)}var en=v.newInstance(Ie,"vtkInteractorObserver"),tn={newInstance:en,extend:Ie,...Jt},{States:N}=Ce,ge={Rotate:N.IS_ROTATE,Pan:N.IS_PAN,Spin:N.IS_SPIN,Dolly:N.IS_DOLLY,CameraPose:N.IS_CAMERA_POSE,WindowLevel:N.IS_WINDOW_LEVEL,Slice:N.IS_SLICE};function nn(t,e){e.classHierarchy.push("vtkInteractorStyle"),Object.keys(ge).forEach(r=>{v.event(t,e,`Start${r}Event`),t[`start${r}`]=()=>{e.state===N.IS_NONE&&(e.state=ge[r],e._interactor.requestAnimation(t),t.invokeStartInteractionEvent({type:"StartInteractionEvent"}),t[`invokeStart${r}Event`]({type:`Start${r}Event`}))},v.event(t,e,`End${r}Event`),t[`end${r}`]=()=>{e.state===ge[r]&&(e.state=N.IS_NONE,e._interactor.cancelAnimation(t),t.invokeEndInteractionEvent({type:"EndInteractionEvent"}),t[`invokeEnd${r}Event`]({type:`End${r}Event`}),e._interactor.render())}}),e.getRenderer=r=>e.focusedRenderer||r.pokedRenderer,t.handleKeyPress=r=>{const s=e._interactor;let n=null;switch(r.key){case"r":case"R":e.getRenderer(r).resetCamera(),s.render();break;case"w":case"W":n=e.getRenderer(r).getActors(),n.forEach(a=>{const o=a.getProperty();o.setRepresentationToWireframe&&o.setRepresentationToWireframe()}),s.render();break;case"s":case"S":n=e.getRenderer(r).getActors(),n.forEach(a=>{const o=a.getProperty();o.setRepresentationToSurface&&o.setRepresentationToSurface()}),s.render();break;case"v":case"V":n=e.getRenderer(r).getActors(),n.forEach(a=>{const o=a.getProperty();o.setRepresentationToPoints&&o.setRepresentationToPoints()}),s.render();break}}}var rn={state:N.IS_NONE,handleObservers:1,autoAdjustCameraClippingRange:1};function je(t,e,r={}){Object.assign(e,rn,r),tn.extend(t,e,r),v.setGet(t,e,["focusedRenderer"]),nn(t,e)}var an=v.newInstance(je,"vtkInteractorStyle"),xe={newInstance:an,extend:je,...Ce},{States:W}=Ce;function sn(t,e){e.classHierarchy.push("vtkInteractorStyleTrackballCamera"),t.handleMouseMove=r=>{const s=r.position,n=e.getRenderer(r);switch(e.state){case W.IS_ROTATE:t.handleMouseRotate(n,s),t.invokeInteractionEvent({type:"InteractionEvent"});break;case W.IS_PAN:t.handleMousePan(n,s),t.invokeInteractionEvent({type:"InteractionEvent"});break;case W.IS_DOLLY:e.wheelDolly||(t.handleMouseDolly(n,s),t.invokeInteractionEvent({type:"InteractionEvent"}));break;case W.IS_SPIN:t.handleMouseSpin(n,s),t.invokeInteractionEvent({type:"InteractionEvent"});break}e.previousPosition=s},t.handleButton3D=r=>{if(r&&r.pressed&&r.device===De.RightController&&(r.input===re.Trigger||r.input===re.TrackPad)){t.startCameraPose();return}r&&!r.pressed&&r.device===De.RightController&&(r.input===re.Trigger||r.input===re.TrackPad)&&e.state===W.IS_CAMERA_POSE&&t.endCameraPose()},t.handleMove3D=r=>{e.state===W.IS_CAMERA_POSE&&t.updateCameraPose(r)},t.updateCameraPose=r=>{const s=e.getRenderer(r).getActiveCamera(),n=s.getPhysicalTranslation(),a=.5*.05*s.getPhysicalScale(),o=s.physicalOrientationToWorldDirection([r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w]);s.setPhysicalTranslation(n[0]+o[0]*a,n[1]+o[1]*a,n[2]+o[2]*a)},t.handleLeftButtonPress=r=>{e.previousPosition=r.position,r.shiftKey?r.controlKey||r.altKey?t.startDolly():t.startPan():r.controlKey||r.altKey?t.startSpin():t.startRotate()},t.handleLeftButtonRelease=()=>{switch(e.state){case W.IS_DOLLY:t.endDolly();break;case W.IS_PAN:t.endPan();break;case W.IS_SPIN:t.endSpin();break;case W.IS_ROTATE:t.endRotate();break}},t.handleStartMouseWheel=()=>{e.wheelDolly=!0,t.startDolly()},t.handleEndMouseWheel=()=>{t.endDolly(),e.wheelDolly=!1},t.handleStartPinch=r=>{e.previousScale=r.scale,t.startDolly()},t.handleEndPinch=()=>{t.endDolly()},t.handleStartRotate=r=>{e.previousRotation=r.rotation,t.startRotate()},t.handleEndRotate=()=>{t.endRotate()},t.handleStartPan=r=>{e.previousTranslation=r.translation,t.startPan()},t.handleEndPan=()=>{t.endPan()},t.handlePinch=r=>{t.dollyByFactor(e.getRenderer(r),r.scale/e.previousScale),e.previousScale=r.scale},t.handlePan=r=>{const s=e.getRenderer(r).getActiveCamera();let n=s.getFocalPoint();n=t.computeWorldToDisplay(e.getRenderer(r),n[0],n[1],n[2]);const a=n[2],o=r.translation,i=e.previousTranslation,u=t.computeDisplayToWorld(e.getRenderer(r),n[0]+o[0]-i[0],n[1]+o[1]-i[1],a),p=t.computeDisplayToWorld(e.getRenderer(r),n[0],n[1],a),c=[];c[0]=p[0]-u[0],c[1]=p[1]-u[1],c[2]=p[2]-u[2],n=s.getFocalPoint();const l=s.getPosition();s.setFocalPoint(c[0]+n[0],c[1]+n[1],c[2]+n[2]),s.setPosition(c[0]+l[0],c[1]+l[1],c[2]+l[2]),e._interactor.getLightFollowCamera()&&e.getRenderer(r).updateLightsGeometryToFollowCamera(),s.orthogonalizeViewUp(),e.previousTranslation=r.translation},t.handleRotate=r=>{const s=e.getRenderer(r).getActiveCamera();s.roll(r.rotation-e.previousRotation),s.orthogonalizeViewUp(),e.previousRotation=r.rotation},t.handleMouseRotate=(r,s)=>{if(!e.previousPosition)return;const n=e._interactor,a=s.x-e.previousPosition.x,o=s.y-e.previousPosition.y,i=n.getView().getViewportSize(r);let u=-.1,p=-.1;i[0]&&i[1]&&(u=-20/i[1],p=-20/i[0]);const c=a*p*e.motionFactor,l=o*u*e.motionFactor,g=r.getActiveCamera();!Number.isNaN(c)&&!Number.isNaN(l)&&(g.azimuth(c),g.elevation(l),g.orthogonalizeViewUp()),e.autoAdjustCameraClippingRange&&r.resetCameraClippingRange(),n.getLightFollowCamera()&&r.updateLightsGeometryToFollowCamera()},t.handleMouseSpin=(r,s)=>{if(!e.previousPosition)return;const n=e._interactor,a=r.getActiveCamera(),o=n.getView().getViewportCenter(r),i=_e(Math.atan2(e.previousPosition.y-o[1],e.previousPosition.x-o[0])),u=_e(Math.atan2(s.y-o[1],s.x-o[0]))-i;Number.isNaN(u)||(a.roll(u),a.orthogonalizeViewUp())},t.handleMousePan=(r,s)=>{if(!e.previousPosition)return;const n=r.getActiveCamera();let a=n.getFocalPoint();a=t.computeWorldToDisplay(r,a[0],a[1],a[2]);const o=a[2],i=t.computeDisplayToWorld(r,s.x,s.y,o),u=t.computeDisplayToWorld(r,e.previousPosition.x,e.previousPosition.y,o),p=[];p[0]=u[0]-i[0],p[1]=u[1]-i[1],p[2]=u[2]-i[2],a=n.getFocalPoint();const c=n.getPosition();n.setFocalPoint(p[0]+a[0],p[1]+a[1],p[2]+a[2]),n.setPosition(p[0]+c[0],p[1]+c[1],p[2]+c[2]),e._interactor.getLightFollowCamera()&&r.updateLightsGeometryToFollowCamera()},t.handleMouseDolly=(r,s)=>{if(!e.previousPosition)return;const n=s.y-e.previousPosition.y,a=e._interactor.getView().getViewportCenter(r),o=e.motionFactor*n/a[1];t.dollyByFactor(r,1.1**o)},t.handleMouseWheel=r=>{const s=1-r.spinY/e.zoomFactor;t.dollyByFactor(e.getRenderer(r),s)},t.dollyByFactor=(r,s)=>{if(Number.isNaN(s))return;const n=r.getActiveCamera();n.getParallelProjection()?n.setParallelScale(n.getParallelScale()/s):(n.dolly(s),e.autoAdjustCameraClippingRange&&r.resetCameraClippingRange()),e._interactor.getLightFollowCamera()&&r.updateLightsGeometryToFollowCamera()}}var on={motionFactor:10,zoomFactor:10,wheelDolly:!1};function Qe(t,e,r={}){Object.assign(e,on,r),xe.extend(t,e,r),v.setGet(t,e,["motionFactor","zoomFactor"]),sn(t,e)}var cn=v.newInstance(Qe,"vtkInteractorStyleTrackballCamera"),un={newInstance:cn,extend:Qe},{vtkErrorMacro:ln}=ft,fe=["setBindGroup","setIndexBuffer","setVertexBuffer","draw","drawIndexed"];function pn(t,e){e.classHierarchy.push("vtkWebGPURenderEncoder"),t.begin=r=>{e.drawCallbacks=[],e.handle=r.beginRenderPass(e.description),e.label&&e.handle.pushDebugGroup(e.label)},t.end=()=>{for(let r=0;r<e.drawCallbacks.length;r++){const s=e.drawCallbacks[r],n=s.pipeline;t.setPipeline(n);for(let a=0;a<s.callbacks.length;a++)s.callbacks[a](t)}e.label&&e.handle.popDebugGroup(),e.handle.end(),e.boundPipeline=null},t.setPipeline=r=>{if(e.boundPipeline===r)return;e.handle.setPipeline(r.getHandle());const s=r.getPipelineDescription(),n=s.fragment?.targets;if(e.colorTextureViews.length!==n.length)console.log(`mismatched attachment counts on pipeline ${n.length} while encoder has ${e.colorTextureViews.length}`),console.trace();else for(let a=0;a<e.colorTextureViews.length;a++){const o=e.colorTextureViews[a].getTexture()?.getFormat();o&&o!==n[a].format&&(console.log(`mismatched attachments for attachment ${a} on pipeline ${n[a].format} while encoder has ${o}`),console.trace())}if(!!e.depthTextureView!="depthStencil"in s)console.log("mismatched depth attachments"),console.trace();else if(e.depthTextureView){const a=e.depthTextureView.getTexture()?.getFormat();a&&a!==s.depthStencil.format&&(console.log(`mismatched depth attachments on pipeline ${s.depthStencil.format} while encoder has ${a}`),console.trace())}e.boundPipeline=r},t.replaceShaderCode=r=>{e.replaceShaderCodeFunction(r)},t.setColorTextureView=(r,s)=>{e.colorTextureViews[r]!==s&&(e.colorTextureViews[r]=s)},t.activateBindGroup=r=>{const s=e.boundPipeline.getDevice(),n=e.boundPipeline.getBindGroupLayoutIndex(r.getLabel());if(n<0){ln(`vtkWebGPURenderEncoder: could not find bind group layout ${r.getLabel()}`);return}e.handle.setBindGroup(n,r.getBindGroup(s));const a=s.getBindGroupLayoutDescription(r.getBindGroupLayout(s)),o=s.getBindGroupLayoutDescription(e.boundPipeline.getBindGroupLayout(n));a!==o&&(console.log(`renderEncoder ${e.pipelineHash} mismatched bind group layouts bind group has
|
|
4
4
|
${a}
|
package/dist/index.html
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
href="https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap"
|
|
13
13
|
rel="stylesheet"
|
|
14
14
|
/>
|
|
15
|
-
<script type="module" crossorigin src="./assets/index-
|
|
16
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
15
|
+
<script type="module" crossorigin src="./assets/index-DfT-vEKx.js"></script>
|
|
16
|
+
<link rel="stylesheet" crossorigin href="./assets/index-CVUcpNtC.css">
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
|
19
19
|
<!-- ARGUS's own four sounds, synthesised rather than borrowed
|
|
@@ -308,9 +308,11 @@
|
|
|
308
308
|
<button class="strategy-pill universe-view" title="every feed its own molecule, or the shapes folded to one molecule each">FEEDS</button>
|
|
309
309
|
<button class="strategy-pill universe-scale" title="what sizes a sphere: its jobs (log scale) or nothing, every sphere alike">JOBS</button>
|
|
310
310
|
<button class="strategy-pill universe-density" title="a stage as one sphere with its count (SHAPE), or every job as its own point (CENSUS)">SHAPE</button>
|
|
311
|
-
<button class="strategy-pill universe-arrangement" title="the space's own emergent shape (GALAXY), each feed a spoke from its shape's hub (SPOKES),
|
|
311
|
+
<button class="strategy-pill universe-arrangement" title="the space's own emergent shape (GALAXY), each feed a spoke from its shape's hub (SPOKES), packed round it (CLUMPS), pulled to the plugin stars it ran (CONSTELLATIONS), hung from what it began from (DATA), or grown in the order it was made, kin sticking to kin (ACCRETION)">GALAXY</button>
|
|
312
312
|
<button class="strategy-pill universe-draw" title="every sphere a point of light (STARS), or lit and solid (SPHERES); a feed you enter is always solid">STARS</button>
|
|
313
|
+
<button class="strategy-pill universe-captions" title="the hubs' words over the picture — what each is and how many feeds it holds (universe captions on|off)">CAPTIONS ON</button>
|
|
313
314
|
<button class="strategy-pill universe-gravity" title="mass-weighted centring: what gathers the clusters (a knob for play; universe physics … by word)">GRAVITY ON</button>
|
|
315
|
+
<button class="strategy-pill universe-replay rail-off" title="the space's history, feed by feed in the order they were made (universe replay [speed]|pause|stop|at <date>; Esc stops)">REPLAY</button>
|
|
314
316
|
<button class="strategy-pill universe-refresh" title="ask the session for the space again">REFRESH</button>
|
|
315
317
|
<button class="strategy-pill universe-open" title="this feed in a RUNS pane of its own">OPEN FEED</button>
|
|
316
318
|
<button class="strategy-pill universe-back" title="climb out to the whole space (Esc)">BACK</button>
|
|
@@ -555,6 +557,7 @@
|
|
|
555
557
|
<!-- A volume layout pulls every slice; over the guard
|
|
556
558
|
it waits here (series-loads-by-consent). -->
|
|
557
559
|
<button class="strategy-pill image-load" hidden title="fetch every slice for the waiting layout">LOAD</button>
|
|
560
|
+
<button class="strategy-pill image-retry" hidden title="ask again for the slices the network dropped">RETRY</button>
|
|
558
561
|
<button class="strategy-pill image-save" title="save the measurements as a DICOM SR under ~/annotations">SAVE</button>
|
|
559
562
|
<button class="strategy-pill image-tags" title="the slice's tags, in a pane that follows this one">TAGS</button>
|
|
560
563
|
<!-- What a clinical viewer writes in the corners: who
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fnndsc/argus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "ARGUS: the LCARS web surface for mise — a browser console over a calypso session",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@cornerstonejs/metadata": "^5.8.2",
|
|
21
21
|
"@cornerstonejs/tools": "^5.8.2",
|
|
22
22
|
"@cornerstonejs/utils": "^5.8.2",
|
|
23
|
-
"@fnndsc/menu": "^0.
|
|
23
|
+
"@fnndsc/menu": "^0.12.0",
|
|
24
24
|
"@kitware/vtk.js": "^36.4.1",
|
|
25
25
|
"@niivue/niivue": "^0.69.0",
|
|
26
26
|
"@types/three": "^0.185.4",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"three": "^0.185.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
+
"@fnndsc/orrery": "0.1.0",
|
|
35
36
|
"@types/jest": "^30.0.0",
|
|
36
37
|
"jest": "^30.2.0",
|
|
37
38
|
"jest-environment-jsdom": "^30.2.0",
|