@ohif/ui-next 3.14.0-beta.78 → 3.14.0-beta.79

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.
@@ -6,7 +6,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
6
6
  `);var OK=e=>{var t,r,n,a,i,o,s,l,d,u,c,h,p,m;let{invert:f,toast:g,unstyled:y,interacting:v,setHeights:b,visibleToasts:x,heights:w,index:C,toasts:k,expanded:M,removeToast:S,defaultRichColors:I,closeButton:T,style:_,cancelButtonStyle:P,actionButtonStyle:E,className:D="",descriptionClassName:A="",duration:O,position:N,gap:R,loadingIcon:L,expandByDefault:j,classNames:V,icons:F,closeButtonAriaLabel:B="Close toast",pauseWhenPageIsHidden:W}=e,[U,z]=tC.useState(null),[H,G]=tC.useState(null),[q,$]=tC.useState(!1),[K,Y]=tC.useState(!1),[X,Z]=tC.useState(!1),[J,Q]=tC.useState(!1),[ee,et]=tC.useState(!1),[er,en]=tC.useState(0),[ea,ei]=tC.useState(0),eo=tC.useRef(g.duration||O||4e3),es=tC.useRef(null),el=tC.useRef(null),ed=0===C,eu=C+1<=x,ec=g.type,eh=!1!==g.dismissible,ep=g.className||"",em=g.descriptionClassName||"",ef=tC.useMemo(()=>w.findIndex(e=>e.toastId===g.id)||0,[w,g.id]),eg=tC.useMemo(()=>{var e;return null!=(e=g.closeButton)?e:T},[g.closeButton,T]),ey=tC.useMemo(()=>g.duration||O||4e3,[g.duration,O]),ev=tC.useRef(0),eb=tC.useRef(0),ex=tC.useRef(0),ew=tC.useRef(null),[eC,ek]=N.split("-"),eM=tC.useMemo(()=>w.reduce((e,t,r)=>r>=ef?e:e+t.height,0),[w,ef]),eS=(()=>{let[e,t]=tC.useState(document.hidden);return tC.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",e),()=>window.removeEventListener("visibilitychange",e)},[]),e})(),eI=g.invert||f,eT="loading"===ec;eb.current=tC.useMemo(()=>ef*R+eM,[ef,eM]),tC.useEffect(()=>{eo.current=ey},[ey]),tC.useEffect(()=>{$(!0)},[]),tC.useEffect(()=>{let e=el.current;if(e){let t=e.getBoundingClientRect().height;return ei(t),b(e=>[{toastId:g.id,height:t,position:g.position},...e]),()=>b(e=>e.filter(e=>e.toastId!==g.id))}},[b,g.id]),tC.useLayoutEffect(()=>{if(!q)return;let e=el.current,t=e.style.height;e.style.height="auto";let r=e.getBoundingClientRect().height;e.style.height=t,ei(r),b(e=>e.find(e=>e.toastId===g.id)?e.map(e=>e.toastId===g.id?{...e,height:r}:e):[{toastId:g.id,height:r,position:g.position},...e])},[q,g.title,g.description,b,g.id]);let e_=tC.useCallback(()=>{Y(!0),en(eb.current),b(e=>e.filter(e=>e.toastId!==g.id)),setTimeout(()=>{S(g)},200)},[g,S,b,eb]);return tC.useEffect(()=>{let e;if((!g.promise||"loading"!==ec)&&g.duration!==1/0&&"loading"!==g.type)return M||v||W&&eS?(()=>{if(ex.current<ev.current){let e=new Date().getTime()-ev.current;eo.current=eo.current-e}ex.current=new Date().getTime()})():eo.current!==1/0&&(ev.current=new Date().getTime(),e=setTimeout(()=>{var e;null==(e=g.onAutoClose)||e.call(g,g),e_()},eo.current)),()=>clearTimeout(e)},[M,v,g,ec,W,eS,e_]),tC.useEffect(()=>{g.delete&&e_()},[e_,g.delete]),tC.createElement("li",{tabIndex:0,ref:el,className:O$(D,ep,null==V?void 0:V.toast,null==(t=null==g?void 0:g.classNames)?void 0:t.toast,null==V?void 0:V.default,null==V?void 0:V[ec],null==(r=null==g?void 0:g.classNames)?void 0:r[ec]),"data-sonner-toast":"","data-rich-colors":null!=(n=g.richColors)?n:I,"data-styled":!(g.jsx||g.unstyled||y),"data-mounted":q,"data-promise":!!g.promise,"data-swiped":ee,"data-removed":K,"data-visible":eu,"data-y-position":eC,"data-x-position":ek,"data-index":C,"data-front":ed,"data-swiping":X,"data-dismissible":eh,"data-type":ec,"data-invert":eI,"data-swipe-out":J,"data-swipe-direction":H,"data-expanded":!!(M||j&&q),style:{"--index":C,"--toasts-before":C,"--z-index":k.length-C,"--offset":`${K?er:eb.current}px`,"--initial-height":j?"auto":`${ea}px`,..._,...g.style},onDragEnd:()=>{Z(!1),z(null),ew.current=null},onPointerDown:e=>{eT||!eh||(es.current=new Date,en(eb.current),e.target.setPointerCapture(e.pointerId),"BUTTON"!==e.target.tagName&&(Z(!0),ew.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e,t,r,n;if(J||!eh)return;ew.current=null;let a=Number((null==(e=el.current)?void 0:e.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),i=Number((null==(t=el.current)?void 0:t.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),o=new Date().getTime()-(null==(r=es.current)?void 0:r.getTime()),s="x"===U?a:i,l=Math.abs(s)/o;if(Math.abs(s)>=20||l>.11){en(eb.current),null==(n=g.onDismiss)||n.call(g,g),G("x"===U?a>0?"right":"left":i>0?"down":"up"),e_(),Q(!0),et(!1);return}Z(!1),z(null)},onPointerMove:t=>{var r,n,a,i;if(!ew.current||!eh||(null==(r=window.getSelection())?void 0:r.toString().length)>0)return;let o=t.clientY-ew.current.y,s=t.clientX-ew.current.x,l=null!=(n=e.swipeDirections)?n:function(e){let[t,r]=e.split("-"),n=[];return t&&n.push(t),r&&n.push(r),n}(N);!U&&(Math.abs(s)>1||Math.abs(o)>1)&&z(Math.abs(s)>Math.abs(o)?"x":"y");let d={x:0,y:0};"y"===U?(l.includes("top")||l.includes("bottom"))&&(l.includes("top")&&o<0||l.includes("bottom")&&o>0)&&(d.y=o):"x"===U&&(l.includes("left")||l.includes("right"))&&(l.includes("left")&&s<0||l.includes("right")&&s>0)&&(d.x=s),(Math.abs(d.x)>0||Math.abs(d.y)>0)&&et(!0),null==(a=el.current)||a.style.setProperty("--swipe-amount-x",`${d.x}px`),null==(i=el.current)||i.style.setProperty("--swipe-amount-y",`${d.y}px`)}},eg&&!g.jsx?tC.createElement("button",{"aria-label":B,"data-disabled":eT,"data-close-button":!0,onClick:eT||!eh?()=>{}:()=>{var e;e_(),null==(e=g.onDismiss)||e.call(g,g)},className:O$(null==V?void 0:V.closeButton,null==(a=null==g?void 0:g.classNames)?void 0:a.closeButton)},null!=(i=null==F?void 0:F.close)?i:OW):null,g.jsx||(0,tC.isValidElement)(g.title)?g.jsx?g.jsx:"function"==typeof g.title?g.title():g.title:tC.createElement(tC.Fragment,null,ec||g.icon||g.promise?tC.createElement("div",{"data-icon":"",className:O$(null==V?void 0:V.icon,null==(o=null==g?void 0:g.classNames)?void 0:o.icon)},g.promise||"loading"===g.type&&!g.icon?g.icon||(null!=F&&F.loading?tC.createElement("div",{className:O$(null==V?void 0:V.loader,null==(h=null==g?void 0:g.classNames)?void 0:h.loader,"sonner-loader"),"data-visible":"loading"===ec},F.loading):L?tC.createElement("div",{className:O$(null==V?void 0:V.loader,null==(p=null==g?void 0:g.classNames)?void 0:p.loader,"sonner-loader"),"data-visible":"loading"===ec},L):tC.createElement(OL,{className:O$(null==V?void 0:V.loader,null==(m=null==g?void 0:g.classNames)?void 0:m.loader),visible:"loading"===ec})):null,"loading"!==g.type?g.icon||(null==F?void 0:F[ec])||(e=>{switch(e){case"success":return Oj;case"info":return OF;case"warning":return OV;case"error":return OB;default:return null}})(ec):null):null,tC.createElement("div",{"data-content":"",className:O$(null==V?void 0:V.content,null==(s=null==g?void 0:g.classNames)?void 0:s.content)},tC.createElement("div",{"data-title":"",className:O$(null==V?void 0:V.title,null==(l=null==g?void 0:g.classNames)?void 0:l.title)},"function"==typeof g.title?g.title():g.title),g.description?tC.createElement("div",{"data-description":"",className:O$(A,em,null==V?void 0:V.description,null==(d=null==g?void 0:g.classNames)?void 0:d.description)},"function"==typeof g.description?g.description():g.description):null),(0,tC.isValidElement)(g.cancel)?g.cancel:g.cancel&&Oq(g.cancel)?tC.createElement("button",{"data-button":!0,"data-cancel":!0,style:g.cancelButtonStyle||P,onClick:e=>{var t,r;Oq(g.cancel)&&eh&&(null==(r=(t=g.cancel).onClick)||r.call(t,e),e_())},className:O$(null==V?void 0:V.cancelButton,null==(u=null==g?void 0:g.classNames)?void 0:u.cancelButton)},g.cancel.label):null,(0,tC.isValidElement)(g.action)?g.action:g.action&&Oq(g.action)?tC.createElement("button",{"data-button":!0,"data-action":!0,style:g.actionButtonStyle||E,onClick:e=>{var t,r;Oq(g.action)&&(null==(r=(t=g.action).onClick)||r.call(t,e),e.defaultPrevented||e_())},className:O$(null==V?void 0:V.actionButton,null==(c=null==g?void 0:g.classNames)?void 0:c.actionButton)},g.action.label):null))};function OY(){if("u"<typeof window||"u"<typeof document)return"ltr";let e=document.documentElement.getAttribute("dir");return"auto"!==e&&e?e:window.getComputedStyle(document.documentElement).direction}var OX=(0,tC.forwardRef)(function(e,t){let{invert:r,position:n="bottom-right",hotkey:a=["altKey","KeyT"],expand:i,closeButton:o,className:s,offset:l,mobileOffset:d,theme:u="light",richColors:c,duration:h,style:p,visibleToasts:m=3,toastOptions:f,dir:g=OY(),gap:y=14,loadingIcon:v,icons:b,containerAriaLabel:x="Notifications",pauseWhenPageIsHidden:w}=e,[C,k]=tC.useState([]),M=tC.useMemo(()=>Array.from(new Set([n].concat(C.filter(e=>e.position).map(e=>e.position)))),[C,n]),[S,I]=tC.useState([]),[T,_]=tC.useState(!1),[P,E]=tC.useState(!1),[D,A]=tC.useState("system"!==u?u:"u">typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),O=tC.useRef(null),N=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),R=tC.useRef(null),L=tC.useRef(!1),j=tC.useCallback(e=>{k(t=>{var r;return null!=(r=t.find(t=>t.id===e.id))&&r.delete||Oz.dismiss(e.id),t.filter(({id:t})=>t!==e.id)})},[]);return tC.useEffect(()=>Oz.subscribe(e=>{e.dismiss?k(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t)):setTimeout(()=>{tJ.flushSync(()=>{k(t=>{let r=t.findIndex(t=>t.id===e.id);return -1!==r?[...t.slice(0,r),{...t[r],...e},...t.slice(r+1)]:[e,...t]})})})}),[]),tC.useEffect(()=>{if("system"!==u)return void A(u);if("system"===u&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?A("dark"):A("light")),"u"<typeof window)return;let e=window.matchMedia("(prefers-color-scheme: dark)");try{e.addEventListener("change",({matches:e})=>{A(e?"dark":"light")})}catch(t){e.addListener(({matches:e})=>{try{A(e?"dark":"light")}catch(e){console.error(e)}})}},[u]),tC.useEffect(()=>{C.length<=1&&_(!1)},[C]),tC.useEffect(()=>{let e=e=>{var t,r;a.every(t=>e[t]||e.code===t)&&(_(!0),null==(t=O.current)||t.focus()),"Escape"===e.code&&(document.activeElement===O.current||null!=(r=O.current)&&r.contains(document.activeElement))&&_(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a]),tC.useEffect(()=>{if(O.current)return()=>{R.current&&(R.current.focus({preventScroll:!0}),R.current=null,L.current=!1)}},[O.current]),tC.createElement("section",{ref:t,"aria-label":`${x} ${N}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},M.map((t,n)=>{var a;let u,[x,k]=t.split("-");return C.length?tC.createElement("ol",{key:t,dir:"auto"===g?OY():g,tabIndex:-1,ref:O,className:s,"data-sonner-toaster":!0,"data-theme":D,"data-y-position":x,"data-lifted":T&&C.length>1&&!i,"data-x-position":k,style:{"--front-toast-height":`${(null==(a=S[0])?void 0:a.height)||0}px`,"--width":"356px","--gap":`${y}px`,...p,...(u={},[l,d].forEach((e,t)=>{let r=1===t,n=r?"--mobile-offset":"--offset",a=r?"16px":"32px";function i(e){["top","right","bottom","left"].forEach(t=>{u[`${n}-${t}`]="number"==typeof e?`${e}px`:e})}"number"==typeof e||"string"==typeof e?i(e):"object"==typeof e?["top","right","bottom","left"].forEach(t=>{void 0===e[t]?u[`${n}-${t}`]=a:u[`${n}-${t}`]="number"==typeof e[t]?`${e[t]}px`:e[t]}):i(a)}),u)},onBlur:e=>{L.current&&!e.currentTarget.contains(e.relatedTarget)&&(L.current=!1,R.current&&(R.current.focus({preventScroll:!0}),R.current=null))},onFocus:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||L.current||(L.current=!0,R.current=e.relatedTarget)},onMouseEnter:()=>_(!0),onMouseMove:()=>_(!0),onMouseLeave:()=>{P||_(!1)},onDragEnd:()=>_(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||E(!0)},onPointerUp:()=>E(!1)},C.filter(e=>!e.position&&0===n||e.position===t).map((n,a)=>{var s,l;return tC.createElement(OK,{key:n.id,icons:b,index:a,toast:n,defaultRichColors:c,duration:null!=(s=null==f?void 0:f.duration)?s:h,className:null==f?void 0:f.className,descriptionClassName:null==f?void 0:f.descriptionClassName,invert:r,visibleToasts:m,closeButton:null!=(l=null==f?void 0:f.closeButton)?l:o,interacting:P,position:t,style:null==f?void 0:f.style,unstyled:null==f?void 0:f.unstyled,classNames:null==f?void 0:f.classNames,cancelButtonStyle:null==f?void 0:f.cancelButtonStyle,actionButtonStyle:null==f?void 0:f.actionButtonStyle,removeToast:j,toasts:C.filter(e=>e.position==n.position),heights:S.filter(e=>e.position==n.position),setHeights:I,expandByDefault:i,gap:y,loadingIcon:v,expanded:T,pauseWhenPageIsHidden:w,swipeDirections:e.swipeDirections})})):null}))});let OZ=e=>{let t,r,n,a,i,o=(0,tw.c)(7);return o[0]!==e?({...t}=e,o[0]=e,o[1]=t):t=o[1],o[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,tT.jsx)(um.LoadingSpinner,{className:"text-highlight"}),n={warning:(0,tT.jsx)(um.StatusWarning,{}),info:(0,tT.jsx)(um.Info,{className:"text-secondary-foreground"}),success:(0,tT.jsx)(um.StatusSuccess,{}),error:(0,tT.jsx)(um.StatusError,{className:"text-destructive"})},o[2]=r,o[3]=n):(r=o[2],n=o[3]),o[4]===Symbol.for("react.memo_cache_sentinel")?(a={style:{width:"430px",right:"8px"}},o[4]=a):a=o[4],o[5]!==t?(i=(0,tT.jsx)(OX,{className:"toaster group",loadingIcon:r,icons:n,theme:"dark",richColors:"true",toastOptions:a,...t}),o[5]=t,o[6]=i):i=o[6],i},OJ=e=>{let t,r,n,a,i=(0,tw.c)(8),{date:o,description:s}=e;return i[0]===Symbol.for("react.memo_cache_sentinel")?(t={textAlign:"left"},i[0]=t):t=i[0],i[1]!==o?(r=(0,tT.jsx)("div",{className:"text-foreground text-sm",children:o}),i[1]=o,i[2]=r):r=i[2],i[3]!==s?(n=(0,tT.jsx)("div",{className:"text-muted-foreground pb-1 text-sm",children:s}),i[3]=s,i[4]=n):n=i[4],i[5]!==r||i[6]!==n?(a=(0,tT.jsxs)("div",{className:"mx-2 my-0",style:t,children:[r,n]}),i[5]=r,i[6]=n,i[7]=a):a=i[7],a};function OQ(e,t){return(OQ=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var O0={error:null},O1=function(e){function t(){for(var t,r=arguments.length,n=Array(r),a=0;a<r;a++)n[a]=arguments[a];return(t=e.call.apply(e,[this].concat(n))||this).state=O0,t.resetErrorBoundary=function(){for(var e,r=arguments.length,n=Array(r),a=0;a<r;a++)n[a]=arguments[a];null==t.props.onReset||(e=t.props).onReset.apply(e,n),t.reset()},t}t.prototype=Object.create(e.prototype),t.prototype.constructor=t,OQ(t,e),t.getDerivedStateFromError=function(e){return{error:e}};var r=t.prototype;return r.reset=function(){this.setState(O0)},r.componentDidCatch=function(e,t){var r,n;null==(r=(n=this.props).onError)||r.call(n,e,t)},r.componentDidUpdate=function(e,t){var r,n,a,i,o=this.state.error,s=this.props.resetKeys;null!==o&&null!==t.error&&(void 0===(r=e.resetKeys)&&(r=[]),void 0===(n=s)&&(n=[]),r.length!==n.length||r.some(function(e,t){return!Object.is(e,n[t])}))&&(null==(a=(i=this.props).onResetKeysChange)||a.call(i,e.resetKeys,s),this.reset())},r.render=function(){var e=this.state.error,t=this.props,r=t.fallbackRender,n=t.FallbackComponent,a=t.fallback;if(null!==e){var i={error:e,resetErrorBoundary:this.resetErrorBoundary};if(tC.isValidElement(a))return a;if("function"==typeof r)return r(i);if(n)return tC.createElement(n,i);else throw Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},t}(tC.Component);let O2=(0,tC.createContext)(null),O5=()=>(0,tC.useContext)(O2),O3={title:"",message:"",duration:5e3,position:"bottom-right",type:"info",visible:!0},O4=e=>{let t,r,n,a,i,o,s,l,d,u,c,h,p=(0,tw.c)(22),{children:m,service:f,deduplicationInterval:g}=e,y=void 0===g?1e4:g;p[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],p[0]=t):t=p[0];let[v,b]=(0,tC.useState)(t);p[1]===Symbol.for("react.memo_cache_sentinel")?(r={},p[1]=r):r=p[1];let x=(0,tC.useRef)(r);p[2]!==f?(n=f?.getCustomComponent(),p[2]=f,p[3]=n):n=p[3];let w=n;p[4]!==y?(a=e=>{let t={...O3,...e},{title:r,message:n,duration:a,position:i,type:o,promise:s,allowDuplicates:l,deduplicationInterval:d,action:u}=t,c=d||y;if(s)return OG.promise(s,{loading:r||"Loading...",success:e=>({title:r||"Success",description:"function"==typeof n?n(e):n}),error:e=>({title:r||"Error",description:"function"==typeof n?n(e):n})});let h="function"==typeof n?"function":n,p=`${r}_${h}_${o}`;if(!(void 0!==l&&l)&&"error"===o){let e=Date.now(),t=x.current[p];if(t){let n=e-t.timestamp;if(n<c)return console.debug(`Prevented duplicate notification: "${r}" (${n}ms < ${c}ms)`),t.id;console.debug(`Showing notification again after interval: "${r}" (${n}ms >= ${c}ms)`),OG.dismiss(t.id)}}let m={duration:a,position:i,description:n,id:e.id};u&&u.label&&"function"==typeof u.onClick&&(m.action={label:u.label,onClick:u.onClick});let f=OG[o](r,m);if("error"===o){let e=Date.now();x.current[p]={timestamp:e,id:f},console.debug(`Stored notification in cache: "${r}" (id: ${f}, timestamp: ${e})`)}return b(e=>[...e,{...t,id:f}]),f},p[4]=y,p[5]=a):a=p[5];let C=a;p[6]===Symbol.for("react.memo_cache_sentinel")?(i=e=>{for(let[t,r]of(b(t=>[...t.filter(t=>t.id!==e)]),OG.dismiss(e),Object.entries(x.current)))if(r.id===e){delete x.current[t];break}},p[6]=i):i=p[6];let k=i;p[7]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{b([]),OG.dismiss(),x.current={}},p[7]=o):o=p[7];let M=o;p[8]!==f||p[9]!==C?(s=()=>{f&&f.setServiceImplementation({hide:k,show:C})},l=[f,k,C],p[8]=f,p[9]=C,p[10]=s,p[11]=l):(s=p[10],l=p[11]),(0,tC.useEffect)(s,l),p[12]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{let e={...x.current},t=Date.now();return Object.entries(e).reduce((e,r)=>{let[n,a]=r,i=t-a.timestamp;return e[n]={...a,date:new Date(a.timestamp).toISOString(),timeSinceMs:i,timeSinceStr:`${Math.floor(i/1e3)}s ago`},e},{})},p[12]=d):d=p[12];let S=d;return p[13]!==C?(u={show:C,hide:k,hideAll:M,getNotificationCache:S},p[13]=C,p[14]=u):u=p[14],p[15]!==w||p[16]!==v?(c=w?(0,tT.jsx)(w,{options:v}):(0,tT.jsx)(OZ,{position:"bottom-right"}),p[15]=w,p[16]=v,p[17]=c):c=p[17],p[18]!==m||p[19]!==u||p[20]!==c?(h=(0,tT.jsxs)(O2.Provider,{value:u,children:[c,m]}),p[18]=m,p[19]=u,p[20]=c,p[21]=h):h=p[21],h};var O8=d(2816),O6=d.n(O8);let O9={COMMANDS:"commandsModule",CUSTOMIZATION:"customizationModule",STATE_SYNC:"stateSyncModule",DATA_SOURCE:"dataSourcesModule",PANEL:"panelModule",SOP_CLASS_HANDLER:"sopClassHandlerModule",TOOLBAR:"toolbarModule",VIEWPORT:"viewportModule",CONTEXT:"contextModule",LAYOUT_TEMPLATE:"layoutTemplateModule",HANGING_PROTOCOL:"hangingProtocolModule",UTILITY:"utilityModule"},O7={error:console.error,warn:console.warn,info:console.log,trace:console.trace,debug:console.debug,time:e=>{O7.timingKeys[e]=!0,console.time(e)},timeEnd:e=>{O7.timingKeys[e]&&(O7.timingKeys[e]=!1,console.timeEnd(e))},timingKeys:{scriptToView:!0}},Ne=()=>{let e=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()},Nt=function(e,t,r){var n;let a=function(){var a=this,i=arguments,o=r&&!n;clearTimeout(n),n=setTimeout(function(){n=null,r||e.apply(a,i)},t),o&&e.apply(a,i)};return a.clearDebounceTimeout=()=>{clearTimeout(n),n=null},a},Nr={subscribe:Nn,_broadcastEvent:No,_unsubscribe:Na,_isValidEvent:Ni};function Nn(e,t){if(this._isValidEvent(e)){let r=Ne(),n={id:r,callback:t};return Array.isArray(this.listeners[e])?this.listeners[e].push(n):this.listeners[e]=[n],{unsubscribe:()=>this._unsubscribe(e,r)}}throw Error(`Event ${e} not supported.`)}function Na(e,t){if(!this.listeners[e])return;let r=this.listeners[e];Array.isArray(r)?this.listeners[e]=r.filter(({id:e,callback:r})=>(r?.clearDebounceTimeout?.(),e!==t)):this.listeners[e]=void 0}function Ni(e){return Object.values(this.EVENTS).includes(e)}function No(e,t){let r=Object.keys(this.listeners).length>0,n=Array.isArray(this.listeners[e]),a=new CustomEvent(e,{detail:t});document.body.dispatchEvent(a),r&&n&&this.listeners[e].forEach(e=>{e.callback(t)})}class Ns{constructor(e){this.EVENTS=void 0,this.subscribe=void 0,this._broadcastEvent=void 0,this._unsubscribe=void 0,this._isValidEvent=void 0,this.listeners=void 0,this.unsubscriptions=void 0,this.EVENTS=e,this.subscribe=Nn,this._broadcastEvent=No,this._unsubscribe=Na,this._isValidEvent=Ni,this.listeners={},this.unsubscriptions=[]}subscribeDebounced(e,t,r=300,n=!1){if(this._isValidEvent(e)){let a=Nt(t,r,n);return this.subscribe(e,a)}throw Error(`Event ${e} not supported.`)}reset(){this.unsubscriptions.forEach(e=>e()),this.unsubscriptions=[],Object.keys(this.listeners).forEach(e=>this.listeners[e].forEach(({callback:e})=>{e?.clearDebounceTimeout?.()})),this.listeners={}}createConsumableEvent(e){return{...e,isConsumed:!1,consume:function(){this.isConsumed=!0}}}}var Nl=d(2111),Nd=d.n(Nl);let Nu=function(e){let t=[],r=new Map;return{SeriesInstanceUID:e,instances:t,addInstance:function(e){this.addInstances([e])},addInstances:function(e){for(let n=0,a=e.length;n<a;n++){let a=e[n];r.has(a.SOPInstanceUID)||(r.set(a.SOPInstanceUID,a),t.push(a))}},getInstance:function(e){return r.get(e)}}},Nc=function(e){return{StudyInstanceUID:e,StudyDescription:"",ModalitiesInStudy:[],isLoaded:!1,series:[],addInstanceToSeries:function(e){this.addInstancesToSeries([e])},addInstancesToSeries:function(e){let{SeriesInstanceUID:t}=e[0];this.StudyDescription||(this.StudyDescription=e[0].StudyDescription);let r=this.series.find(e=>e.SeriesInstanceUID===t);r||(r=Nu(t),this.series.push(r)),r.addInstances(e)},setSeriesMetadata:function(e,t){let r=this.series.find(t=>t.SeriesInstanceUID===e);if(r)r=Object.assign(r,t);else{let r=Nu(e);this.series.push(Object.assign(r,t))}}}},Nh=["ImagePositionPatient","ImageOrientationPatient","PixelSpacing"],Np=Symbol("isMetadataProxy"),Nm=function(e){if(!e||e[Np])return e;for(let t of Nh)t in e||Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:()=>e._parentInstance?.[t]??e._parentInstance?._shared?.[t],set:r=>{Object.defineProperty(e,t,{writable:!0,enumerable:!0,value:r})}});return Object.defineProperty(e,Np,{value:!0}),e},Nf={STUDY_ADDED:"event::dicomMetadataStore:studyAdded",INSTANCES_ADDED:"event::dicomMetadataStore:instancesAdded",SERIES_ADDED:"event::dicomMetadataStore:seriesAdded",SERIES_UPDATED:"event::dicomMetadataStore:seriesUpdated"},Ng=[];function Ny(e){return Ng.find(t=>t.StudyInstanceUID===e)}function Nv(e,t){if(!e)return Ng.map(e=>e.series).flat().find(e=>e.SeriesInstanceUID===t);let r=Ny(e);if(r)return r.series.find(e=>e.SeriesInstanceUID===t)}function Nb(e,t,r){let n=Nv(e,t);if(n)return n.getInstance(r)}let Nx=Object.assign({},{EVENTS:Nf,listeners:{},addInstance(e){let t,r,{StudyInstanceUID:n,NumberOfFrames:a}=r=void 0===(t=e instanceof ArrayBuffer?Nd().data.DicomMessage.readFile(e).dict:e).SeriesInstanceUID?Nd().data.DicomMetaDictionary.naturalizeDataset(t):t,i=Ng.find(e=>e.StudyInstanceUID===n);i||(Ng.push(Nc(n)),i=Ng[Ng.length-1]),r=a>1?Nm(r):r,i.addInstanceToSeries(r)},addInstances(e,t=!1){let{StudyInstanceUID:r,SeriesInstanceUID:n,NumberOfFrames:a}=e[0];a>1&&(e=e.map(e=>Nm(e)));let i=Ng.find(e=>e.StudyInstanceUID===r);i||(Ng.push(Nc(r)),i=Ng[Ng.length-1]),i.addInstancesToSeries(e),this._broadcastEvent(Nf.INSTANCES_ADDED,{StudyInstanceUID:r,SeriesInstanceUID:n,madeInClient:t})},updateSeriesMetadata(e){let{StudyInstanceUID:t,SeriesInstanceUID:r}=e;if(!Nv(t,r))return;let n=Ny(t);n&&n.setSeriesMetadata(r,e)},addSeriesMetadata(e,t=!1){if(!e||!e.length||!e[0])return;let{StudyInstanceUID:r}=e[0],n=Ny(r);n||((n=Nc(r)).StudyDescription=e[0].StudyDescription,e.forEach(e=>{-1===n.ModalitiesInStudy.indexOf(e.Modality)&&n.ModalitiesInStudy.push(e.Modality)}),n.NumberOfStudyRelatedSeries=e.length,Ng.push(n)),e.forEach(e=>{let{SeriesInstanceUID:t}=e;n.setSeriesMetadata(t,e)}),this._broadcastEvent(Nf.SERIES_ADDED,{StudyInstanceUID:r,seriesSummaryMetadata:e,madeInClient:t})},addStudy(e){let{StudyInstanceUID:t}=e;if(!Ng.find(e=>e.StudyInstanceUID===t)){let r=Nc(t);r.PatientID=e.PatientID,r.PatientName=e.PatientName,r.StudyDate=e.StudyDate,r.ModalitiesInStudy=e.ModalitiesInStudy,r.StudyDescription=e.StudyDescription,r.AccessionNumber=e.AccessionNumber,r.NumInstances=e.NumInstances,Ng.push(r)}},getStudyInstanceUIDs:function(){return Ng.map(e=>e.StudyInstanceUID)},getStudy:Ny,getSeries:Nv,getInstance:Nb,getInstanceByImageId:function(e){let t=r?.get("frameModule",e);if(t){let{studyInstanceUID:e,seriesInstanceUID:r,sopInstanceUID:n}=t;return Nb(e,r,n)}for(let t of(console.warn("No metadata result found for",e,"looking through instances"),Ng))for(let r of t.series)for(let t of r.instances)if(t.imageId===e)return t},updateMetadataForSeries:function(e,t,r){let n=Ny(e);if(!n)return;let{instances:a}=n.series.find(e=>e.SeriesInstanceUID===t);a.forEach(e=>{Object.keys(r).forEach(t=>{"object"==typeof r[t]?e[t]={...e[t],...r[t]}:e[t]=r[t]})}),this._broadcastEvent(Nf.SERIES_UPDATED,{SeriesInstanceUID:t,StudyInstanceUID:e,madeInClient:!0})},setMetaDataProvider:function(e){r=e}},Nr),Nw=["uid","color","data","getReport","displayText","SOPInstanceUID","FrameOfReferenceUID","referenceStudyUID","referenceSeriesUID","frameNumber","displaySetInstanceUID","label","isLocked","isVisible","description","type","unit","points","source","toolName","metadata","area","mean","stdDev","perimeter","length","shortestDiameter","longestDiameter","cachedStats","isSelected","textBox","referencedImageId","isDirty"],NC={MEASUREMENT_UPDATED:"event::measurement_updated",INTERNAL_MEASUREMENT_UPDATED:"event:internal_measurement_updated",MEASUREMENT_ADDED:"event::measurement_added",RAW_MEASUREMENT_ADDED:"event::raw_measurement_added",MEASUREMENT_REMOVED:"event::measurement_removed",MEASUREMENTS_CLEARED:"event::measurements_cleared",JUMP_TO_MEASUREMENT:"event:jump_to_measurement"},Nk={ANGLE:"value_type::polyline",POLYLINE:"value_type::polyline",POINT:"value_type::point",BIDIRECTIONAL:"value_type::shortAxisLongAxis",ELLIPSE:"value_type::ellipse",RECTANGLE:"value_type::rectangle",MULTIPOINT:"value_type::multipoint",CIRCLE:"value_type::circle",ROI_THRESHOLD:"value_type::roiThreshold",ROI_THRESHOLD_MANUAL:"value_type::roiThresholdManual"};var NM=((eIH=NM||{}).HandlesUpdated="HandlesUpdated",eIH.LabelChange="LabelChange",eIH);let NS=new Set;class NI extends Ns{constructor(){super(NC),this.VALUE_TYPES=Nk,this.measurements=new Map,this.isMeasurementDeletedIndividually=void 0,this.sources={},this.mappings={},this._arrayOfObjects=e=>Object.entries(e).map(e=>({[e[0]]:e[1]})),this.setIsMeasurementDeletedIndividually=e=>{this.isMeasurementDeletedIndividually=e},this.getIsMeasurementDeletedIndividually=()=>this.isMeasurementDeletedIndividually}addMeasurementSchemaKeys(e){Array.isArray(e)||(e=[e]),Nw.push(...e)}addValueType(e){if(!Nk[e]){if(!e||"object"!=typeof e)return void console.warn(`MeasurementService: addValueType: invalid valueType: ${e}`);Object.keys(e).forEach(t=>{Nk[t]||(Nk[t]=e[t])})}}getMeasurements(e){let t=[...this.measurements.values()];return e?t.filter(t=>e.call(this,t)):t}getMeasurement(e){return this.measurements.get(e)}setMeasurementSelected(e,t){let r=this.getMeasurement(e);r&&(r.isSelected=t,this._broadcastEvent(this.EVENTS.MEASUREMENT_UPDATED,{source:r.source,measurement:r,notYetUpdatedAtSource:!1}))}createSource(e,t){if(!e)throw Error("Source name not provided.");if(!t)throw Error("Source version not provided.");let r=Object.keys(this.sources);for(let n=0;n<r.length;n++){let a=this.sources[r[n]];if(a.name===e&&a.version===t)return a}let n=Ne(),a={uid:n,name:e,version:t};return a.annotationToMeasurement=(e,t,r=!1)=>this.annotationToMeasurement(a,e,t,r),a.remove=(e,t)=>this.remove(e,a,t),a.getAnnotation=(e,t)=>this.getAnnotation(a,e,t),O7.info(`New '${e}@${t}' source added.`),this.sources[n]=a,a}getSource(e,t){let{sources:r}=this;return r[this._getSourceUID(e,t)]}getSourceMappings(e,t){let{mappings:r}=this;return r[this._getSourceUID(e,t)]}addMapping(e,t,r,n,a){if(!this._isValidSource(e))throw Error("Invalid source.");if(!r)throw Error("Matching criteria not provided.");if(!t)throw Error("annotationType not provided.");if(!n)throw Error("Mapping function to source schema not provided.");if(!a)throw Error("Measurement mapping function not provided.");let i={matchingCriteria:r,annotationType:t,toAnnotationSchema:n,toMeasurementSchema:a};Array.isArray(this.mappings[e.uid])?this.mappings[e.uid].push(i):this.mappings[e.uid]=[i]}getAnnotation(e,t,r){if(!this._isValidSource(e))return void O7.warn("Invalid source. Exiting early.");if(!t)return void O7.warn("No source annotationType provided. Exiting early.");let n=this.getMeasurement(r),a=this._getMappingByMeasurementSource(n,t);if(a)return a.toAnnotationSchema(n,t);let i=this._getMatchingMapping(e,t,n);if(i){O7.info("Matching mapping found:",i);let{toAnnotationSchema:e,annotationType:t}=i;return e(n,t)}}update(e,t,r=!1){if(!this.measurements.has(e))return;let n={...t,modifiedTimestamp:Math.floor(Date.now()/1e3)};return O7.info("Updating internal measurement representation...",n),this.measurements.set(e,n),this._broadcastEvent(this.EVENTS.MEASUREMENT_UPDATED,{source:t.source,measurement:n,notYetUpdatedAtSource:r}),n.uid}addRawMeasurement(e,t,r,n,a={}){if(!this._isValidSource(e))return void O7.warn("Invalid source. Exiting early.");let i=this._getSourceToString(e);if(!t)return void O7.warn("No source annotationType provided. Exiting early.");if(!this._sourceHasMappings(e))return void O7.warn(`No measurement mappings found for '${i}' source. Exiting early.`);let o={};try{if(!(o=n(r)))return;o.source=e}catch(e){O7.warn(`Failed to map '${i}' measurement for annotationType ${t}:`,e);return}if(!this._isValidMeasurement(o))return void O7.warn(`Attempting to add or update a invalid measurement provided by '${i}'. Exiting early.`);let s=r.uid||Ne(),{annotation:{predecessorImageId:l,data:d}}=r,u={finding:d.finding,predecessorImageId:l,findingSites:d.findingSites,site:d.findingSites?.[0],...o,modifiedTimestamp:Math.floor(Date.now()/1e3),uid:s};return this.measurements.get(s)?(this.measurements.set(s,u),this._broadcastEvent(this.EVENTS.MEASUREMENT_UPDATED,{source:e,measurement:u})):(O7.info("Measurement added",u),this.measurements.set(s,u),this._broadcastEvent(this.EVENTS.RAW_MEASUREMENT_ADDED,{source:e,measurement:u,data:r,dataSource:a})),u.uid}annotationToMeasurement(e,t,r,n=!1){if(!this._isValidSource(e))throw Error("Invalid source.");if(!t)throw Error("No source annotationType provided.");let a=this._getSourceToString(e);if(!this._sourceHasMappings(e))throw Error(`No measurement mappings found for '${a}' source. Exiting early.`);let i={};try{let n=this.mappings[e.uid].find(e=>e.annotationType===t);if(!n){NS.has(e.uid)||(console.log("No source mapping",e.uid,t,e),NS.add(e.uid)),this.addUnmappedMeasurement(r,e);return}let{toMeasurementSchema:a}=n;if(!(i=a(r)))return;i.source=e}catch(n){throw this.addUnmappedMeasurement(r,e),console.log("Failed to map",n),Error(`Failed to map '${a}' measurement for annotationType ${t}: ${n.message}`)}if(!this._isValidMeasurement(i))throw Error(`Attempting to add or update a invalid measurement provided by '${a}'. Exiting early.`);let o=r.uid;o||(o=Ne(),O7.info(`Annotation does not have UID, Generating UID for the created Measurement: ${o}`));let s=this.measurements.get(o),l={...s,...i,modifiedTimestamp:Math.floor(Date.now()/1e3),uid:o};return l.isDirty=r.changeType===NM.HandlesUpdated||r.changeType===NM.LabelChange||s?.isDirty,s?(this.measurements.set(o,l),n?this._broadcastEvent(this.EVENTS.MEASUREMENT_UPDATED,{source:e,measurement:l,notYetUpdatedAtSource:!1}):(O7.info("Measurement added.",l),this._broadcastEvent(this.EVENTS.MEASUREMENT_ADDED,{source:e,measurement:l}))):(O7.info("Measurement started.",l),this.measurements.set(o,l)),l.uid}findAttributeRecursively(e,t){if(e&&"object"==typeof e){if(e[t])return e[t];for(let r in e)if(e.hasOwnProperty(r)){let n=this.findAttributeRecursively(e[r],t);if(n)return n}}}addUnmappedMeasurement(e,t){if(e.annotation?.invalidated===!0)return void console.log("Measurement is invalidated, skipping...",e);if(e.annotation?.isPreview===!0)return void console.log("Measurement is preview, skipping...",e);let r=this.findAttributeRecursively(e,"metadata"),n=this.findAttributeRecursively(e,"label"),a=this.findAttributeRecursively(e,"referencedImageId"),i=this.findAttributeRecursively(e,"displaySetInstanceUID"),o={...e,isUnmapped:!0,statusTooltip:"This measurement is not compatible with this application",source:{name:t.name,version:t.version,uid:t.uid}};if(r&&(o.metadata=r),n&&(o.label=n),a){o.referencedImageId=a;let e=Nx.getInstanceByImageId(a);e?(o.referenceStudyUID=e.StudyInstanceUID,o.referenceSeriesUID=e.SeriesInstanceUID):console.warn("Didn't find instance for",a)}i&&(o.displaySetInstanceUID=i),this.measurements.set(e.uid,o)}remove(e){let t=this.measurements.get(e);if(!e||!t)return void console.debug("No uid provided, or unable to find measurement by uid.");let r=t.source;this.measurements.delete(e),this.isMeasurementDeletedIndividually=!0,this._broadcastEvent(this.EVENTS.MEASUREMENT_REMOVED,{source:r,measurement:e})}removeMany(e){let t=[];for(let r of e){let e=this.measurements.get(r);if(!r||!e){console.debug("No uid provided, or unable to find measurement by uid.");continue}this.measurements.delete(r),t.push(e)}t.length&&this._broadcastEvent(this.EVENTS.MEASUREMENTS_CLEARED,{measurements:t})}clearMeasurements(e,t){let r=this.getMeasurements(e),n=[...r];r.forEach(e=>this.measurements.delete(e.uid)),this._broadcastEvent(this.EVENTS.MEASUREMENTS_CLEARED,{measurements:n,...t})}onModeExit(){this.clearMeasurements()}jumpToMeasurement(e,t){let r=this.measurements.get(t);r?this._broadcastEvent(NC.JUMP_TO_MEASUREMENT,{viewportId:e,measurement:r}):O7.warn("No measurement uid, or unable to find by uid.")}_getSourceUID(e,t){let{sources:r}=this;return Object.keys(r).find(n=>{let a=r[n];return a.name===e&&a.version===t})}_getMappingByMeasurementSource(e,t){if(this._isValidSource(e.source))return this.mappings[e.source.uid].find(e=>e.annotationType===t)}_getMatchingMapping(e,t,r){return this.mappings[e.uid].filter(e=>e.annotationType===t).find(({matchingCriteria:e})=>r.points&&r.points.length===e.points)}_getSourceToString(e){return`${e.name}@${e.version}`}_isValidSource(e){return e&&this.sources[e.uid]}_sourceHasMappings(e){return Array.isArray(this.mappings[e.uid])&&this.mappings[e.uid].length}_isValidMeasurement(e){return Object.keys(e).every(e=>!!Nw.includes(e)||(O7.warn(`Invalid measurement key: ${e}`),!1))}toggleLockMeasurement(e){let t=this.measurements.get(e);t?(t.isLocked=!t.isLocked,this._broadcastEvent(this.EVENTS.MEASUREMENT_UPDATED,{source:t.source,measurement:t,notYetUpdatedAtSource:!0})):console.debug(`No measurement found for uid: ${e}`)}toggleVisibilityMeasurement(e,t){let r=this.measurements.get(e);r?(r.isVisible!==t||void 0===t)&&(r.isVisible=void 0!==t?t:!r.isVisible,this._broadcastEvent(this.EVENTS.MEASUREMENT_UPDATED,{source:r.source,measurement:r,notYetUpdatedAtSource:!0})):console.debug(`No measurement found for uid: ${e}`)}toggleVisibilityMeasurementMany(e,t){return e.forEach(e=>this.toggleVisibilityMeasurement(e,t))}updateColorMeasurement(e,t){let r=this.measurements.get(e);r?(r.color=t,this._broadcastEvent(this.EVENTS.MEASUREMENT_UPDATED,{source:r.source,measurement:r,notYetUpdatedAtSource:!0})):console.debug(`No measurement found for uid: ${e}`)}}NI.REGISTRATION={name:"measurementService",altName:"MeasurementService",create:e=>new NI},NI.EVENTS=NC,NI.VALUE_TYPES=Nk;let NT="uiDialogService",N_={_show:e=>(console.warn("show() NOT IMPLEMENTED"),""),_hide:e=>console.warn("hide() NOT IMPLEMENTED"),_hideAll:()=>console.warn("hideAll() NOT IMPLEMENTED"),_isEmpty:()=>(console.warn("isEmpty() NOT IMPLEMENTED"),!0),_updatePosition:(e,t)=>console.warn("updatePosition() NOT IMPLEMENTED"),_customComponent:null};class NP{constructor(){this.name=NT}show(e){return N_._show(e)}hide(e){return N_._hide(e)}hideAll(){return N_._hideAll()}isEmpty(){return N_._isEmpty()}updatePosition(e,t){return N_._updatePosition(e,t)}getCustomComponent(){return N_._customComponent}setServiceImplementation({show:e,hide:t,hideAll:r,isEmpty:n,updatePosition:a,customComponent:i}){e&&(N_._show=e),t&&(N_._hide=t),r&&(N_._hideAll=r),n&&(N_._isEmpty=n),a&&(N_._updatePosition=a),i&&(N_._customComponent=i)}}NP.REGISTRATION={name:NT,altName:"UIDialogService",create:()=>new NP};let NE="uiModalService",ND={_hide:()=>console.warn("hide() NOT IMPLEMENTED"),_show:()=>console.warn("show() NOT IMPLEMENTED"),_customComponent:null};class NA{constructor(){this.name=NE}show({content:e=null,contentProps:t=null,title:r=null,className:n=null,shouldCloseOnEsc:a=!0,shouldCloseOnOverlayClick:i=!0,containerClassName:o=null}){return ND._show({content:e,contentProps:t,shouldCloseOnEsc:a,title:r,className:n,shouldCloseOnOverlayClick:i,containerClassName:o})}hide(){return ND._hide()}getCustomComponent(){return ND._customComponent}setServiceImplementation({hide:e,show:t,customComponent:r}){e&&(ND._hide=e),t&&(ND._show=t),r&&(ND._customComponent=r)}}NA.REGISTRATION={name:NE,altName:"UIModalService",create:()=>new NA};let NO={_hide:()=>console.debug("hide() NOT IMPLEMENTED"),_show:e=>(console.debug("show() NOT IMPLEMENTED"),null),_customComponent:null};class NN{getCustomComponent(){return NO._customComponent}setServiceImplementation({hide:e,show:t,customComponent:r}){e&&(NO._hide=e),t&&(NO._show=t),r&&(NO._customComponent=r)}hide(e){return NO._hide(e)}show({title:e,message:t,duration:r=2e3,position:n="bottom-right",type:a="info",autoClose:i=!0,promise:o,promiseMessages:s,id:l,allowDuplicates:d=!1,deduplicationInterval:u=3e4,action:c}){if(o&&s){let t=NO._show({title:e,message:s.loading||"Loading...",type:"loading",autoClose:!1,position:n,id:l?`${l}-loading`:void 0,allowDuplicates:d,deduplicationInterval:u});return o.then(a=>{let o="function"==typeof s.success?s.success(a):s.success||"Success";NO._show({title:e,message:o,type:"success",duration:r,position:n,autoClose:i,id:l?`${l}-success`:void 0,allowDuplicates:d,deduplicationInterval:u,action:c}),this.hide(t)},a=>{let o="function"==typeof s.error?s.error(a):s.error||"Error";NO._show({title:e,message:o,type:"error",duration:r,position:n,autoClose:i,id:l?`${l}-error`:void 0,allowDuplicates:d,deduplicationInterval:u,action:c}),this.hide(t)}),t}return NO._show({title:e,message:t,duration:r,position:n,type:a,autoClose:i,id:l,allowDuplicates:d,deduplicationInterval:u,action:c})}}NN.REGISTRATION={name:"uiNotificationService",altName:"UINotificationService",create:()=>new NN};class NR extends Ns{constructor(){super(NR.EVENTS),this.serviceImplementation={_hide:()=>console.warn("hide() NOT IMPLEMENTED"),_show:()=>console.warn("show() NOT IMPLEMENTED")},this.serviceImplementation={...this.serviceImplementation}}show({viewportId:e,id:t,type:r,message:n,actions:a,onSubmit:i,onOutsideClick:o,onKeyPress:s}){return this.serviceImplementation._show({viewportId:e,id:t,type:r,message:n,actions:a,onSubmit:i,onOutsideClick:o,onKeyPress:s})}hide(){return this.serviceImplementation._hide()}setServiceImplementation({hide:e,show:t}){e&&(this.serviceImplementation._hide=e),t&&(this.serviceImplementation._show=t)}}NR.EVENTS={},NR.REGISTRATION={name:"uiViewportDialogService",altName:"UIViewportDialogService",create:({configuration:e={}})=>new NR};let NL={DISPLAY_SETS_ADDED:"event::displaySetService:displaySetsAdded",DISPLAY_SETS_CHANGED:"event::displaySetService:displaySetsChanged",DISPLAY_SETS_REMOVED:"event::displaySetService:displaySetsRemoved",DISPLAY_SET_SERIES_METADATA_INVALIDATED:"event::displaySetService:displaySetSeriesMetadataInvalidated"},Nj=new Map,NV=(e,t)=>{let r=new Set;return t.forEach(e=>{let t=e.instances;t?t.forEach(e=>r.add(e.SOPInstanceUID)):console.warn("No instances in",e)}),e.filter(e=>!r.has(e.SOPInstanceUID))};class NF extends Ns{constructor(){super(NL),this.activeDisplaySets=[],this.unsupportedSOPClassHandler=void 0,this.extensionManager=void 0,this.activeDisplaySetsMap=new Map,this.activeDisplaySetsChanged=!1,this.getDisplaySetsForSeries=e=>[...Nj.values()].filter(t=>t.SeriesInstanceUID===e),this.getDisplaySetsForReferences=e=>{let t=new Map;for(let r of Array.isArray(e)?e:[e]){let{SeriesInstanceUID:e,ReferencedInstanceSequence:n}=r;t.has(e)||t.set(e,new Set);let a=t.get(e);for(let e of n)a.add(e.ReferencedSOPInstanceUID)}return[...Nj.values()].filter(e=>{let r=t.get(e.SeriesInstanceUID);if(r&&e.instances)return e.instances.some(e=>r.has(e.SOPInstanceUID))})},this.getDisplaySetByUID=e=>{if("string"!=typeof e)throw Error(`getDisplaySetByUID: displaySetInstanceUid must be a string, you passed ${e}`);return Nj.get(e)},this.makeDisplaySets=(e,{batch:t=!1,madeInClient:r=!1,settings:n={}}={})=>{if(!e||!e.length)throw Error("No instances were provided.");if(t&&!e[0].length)throw Error("Batch displaySet creation does not contain array of array of instances.");let a=[];if(t)for(let t=0;t<e.length;t++){let r=e[t],i=this.makeDisplaySetForInstances(r,n);a.push(...i)}else{let t=this.makeDisplaySetForInstances(e,n);a.push(...t)}let i={};if(r&&(i.madeInClient=!0),this.activeDisplaySetsChanged&&(this.activeDisplaySetsChanged=!1,this._broadcastEvent(NL.DISPLAY_SETS_CHANGED,this.activeDisplaySets)),a?.length)return this._broadcastEvent(NL.DISPLAY_SETS_ADDED,{displaySetsAdded:a,options:i}),a},this.unsupportedSOPClassHandler="@ohif/extension-default.sopClassHandlerModule.not-supported-display-sets-handler"}init(e,t){this.extensionManager=e,this.SOPClassHandlerIds=t,this.activeDisplaySets=[],this.activeDisplaySetsMap.clear()}_addDisplaySetsToCache(e){e.forEach(e=>{Nj.set(e.displaySetInstanceUID,e)})}_addActiveDisplaySets(e){let{activeDisplaySets:t,activeDisplaySetsMap:r}=this;e.forEach(e=>{r.has(e.displaySetInstanceUID)||(this.activeDisplaySetsChanged=!0,t.push(e),r.set(e.displaySetInstanceUID,e))})}setUnsuportedSOPClassHandler(e){this.unsupportedSOPClassHandler=e}addDisplaySets(...e){return this._addDisplaySetsToCache(e),this._addActiveDisplaySets(e),this.activeDisplaySetsChanged=!1,this._broadcastEvent(NL.DISPLAY_SETS_ADDED,{displaySetsAdded:e,options:{madeInClient:e[0].madeInClient}}),e}getDisplaySetCache(){return Nj}getMostRecentDisplaySet(){return this.activeDisplaySets[this.activeDisplaySets.length-1]}getActiveDisplaySets(){return this.activeDisplaySets}getDisplaySetForSOPInstanceUID(e,t,r){return(t?this.getDisplaySetsForSeries(t):[...this.getDisplaySetCache().values()]).find(t=>t.instances?.some(t=>t.SOPInstanceUID===e))}setDisplaySetMetadataInvalidated(e,t=!0){this.getDisplaySetByUID(e)&&this._broadcastEvent(NL.DISPLAY_SET_SERIES_METADATA_INVALIDATED,{displaySetInstanceUID:e,invalidateData:t})}deleteDisplaySet(e){if(!e)return;let{activeDisplaySets:t,activeDisplaySetsMap:r}=this,n=t.findIndex(t=>t.displaySetInstanceUID===e);Nj.delete(e),t.splice(n,1),r.delete(e),this._broadcastEvent(NL.DISPLAY_SETS_CHANGED,this.activeDisplaySets),this._broadcastEvent(NL.DISPLAY_SETS_REMOVED,{displaySetInstanceUIDs:[e]})}onModeExit(){this.getDisplaySetCache().clear(),this.activeDisplaySets.length=0,this.activeDisplaySetsMap.clear()}makeDisplaySetForInstances(e,t){let r=e.reduce((e,t)=>(t.SOPClassUID in e||(e[t.SOPClassUID]=[]),e[t.SOPClassUID].push(t),e),{}),n=Object.keys(r),a=[];return n.forEach(e=>{let n=this._makeDisplaySetForInstances(r[e],t);a=[...a,...n]}),a}_makeDisplaySetForInstances(e,t){let r=[...e],n=r[0],a=this.getDisplaySetsForSeries(n.SeriesInstanceUID)||[],i=this.SOPClassHandlerIds,o=[];for(let e=0;e<i.length&&r.length;e++){let s=i[e],l=this.extensionManager.getModuleEntry(s);if(l.sopClassUids.includes(n.SOPClassUID)){let e=a.filter(e=>e.SOPClassHandlerId===s);if(e.length){for(let t of(r=NV(r,e),e)){let e=t.addInstances?.(r,this);if(e&&(this.activeDisplaySetsChanged=!0,r=NV(r,[e]),this._addActiveDisplaySets([e]),this.setDisplaySetMetadataInvalidated(e.displaySetInstanceUID)),!r.length)return o}if(!r.length)return this._addActiveDisplaySets(e),o}if(!(e=l.getDisplaySetsFromSeries(r))||!e.length)continue;e.forEach(e=>{Object.keys(t).forEach(r=>{e[r]=t[r]})}),this._addDisplaySetsToCache(e),this._addActiveDisplaySets(e),r=NV(r,e),o.push(...e)}}if(0===o.length){let e=this.extensionManager.getModuleEntry(this.unsupportedSOPClassHandler).getDisplaySetsFromSeries(r);e?.length&&(e.forEach(e=>{Object.keys(t).forEach(r=>{e[r]=t[r]})}),this._addDisplaySetsToCache(e),this._addActiveDisplaySets(e),o.push(...e))}return o}getDisplaySetsBy(e){let t=[];if("function"!=typeof e)throw Error(`The comparator ${e} was not a function`);return this.getActiveDisplaySets().forEach(r=>{e(r)&&t.push(r)}),t}sortDisplaySets(e,t="ascending",r=!1){this.activeDisplaySets.sort(e),"descending"===t&&this.activeDisplaySets.reverse(),r||this._broadcastEvent(NL.DISPLAY_SETS_CHANGED,this.activeDisplaySets)}}NF.REGISTRATION={altName:"DisplaySetService",name:"displaySetService",create:({configuration:e={}})=>new NF};let NB={TOOL_BAR_MODIFIED:"event::toolBarService:toolBarModified",TOOL_BAR_STATE_MODIFIED:"event::toolBarService:toolBarStateModified"},NW={primary:"primary",secondary:"secondary",viewportActionMenu:{topLeft:"viewportActionMenu.topLeft",topRight:"viewportActionMenu.topRight",bottomLeft:"viewportActionMenu.bottomLeft",bottomRight:"viewportActionMenu.bottomRight",topMiddle:"viewportActionMenu.topMiddle",bottomMiddle:"viewportActionMenu.bottomMiddle",leftMiddle:"viewportActionMenu.leftMiddle",rightMiddle:"viewportActionMenu.rightMiddle"},labelMapSegmentationToolbox:"labelMapSegmentationToolbox",contourSegmentationToolbox:"contourSegmentationToolbox",labelMapSegmentationUtilities:"labelMapSegmentationUtilities",contourSegmentationUtilities:"contourSegmentationUtilities",dynamicToolbox:"dynamic-toolbox",roiThresholdToolbox:"ROIThresholdToolbox"},NU=((eIG={})[eIG.TopLeft=0]="TopLeft",eIG[eIG.TopMiddle=1]="TopMiddle",eIG[eIG.TopRight=2]="TopRight",eIG[eIG.LeftMiddle=3]="LeftMiddle",eIG[eIG.RightMiddle=4]="RightMiddle",eIG[eIG.BottomLeft=5]="BottomLeft",eIG[eIG.BottomMiddle=6]="BottomMiddle",eIG[eIG.BottomRight=7]="BottomRight",eIG);class Nz extends Ns{get sections(){return NW}static createButton(e){let{id:t,icon:r,label:n,commands:a,tooltip:i,evaluate:o,listeners:s}=e;return{id:t,icon:r,label:n,commands:a,tooltip:i||n,evaluate:o,listeners:s}}constructor(e,t,r){super(NB),this.state={buttons:{},buttonSections:{}},this._commandsManager=void 0,this._extensionManager=void 0,this._servicesManager=void 0,this._evaluateFunction={},this._serviceSubscriptions=[],this.handleEvaluateNested=e=>{let{buttonSection:t}=e;if(!t)return;let r=this.getButtonSection(t);r?.length&&r.forEach(e=>{this.handleEvaluate(e.componentProps)})},this.handleEvaluate=e=>{let{evaluate:t,options:r}=e;if("string"==typeof r){let t=this._getButtonUITypes();e.options=t[r]?.defaultComponent}if("function"!=typeof t){if(Array.isArray(t)){let r=t.map(e=>{let t="object"==typeof e,r=t?e.name:e,n=this._evaluateFunction[r];if(!n)throw Error(`Evaluate function not found for name: ${r}, you can register an evaluate function with the getToolbarModule in your extensions`);return t?t=>n({...t,...e}):n}),n=e.evaluate;e.evaluate=e=>{let t=r.map(t=>t(e)).filter(Boolean),n=t?.some(e=>e.disabled),a=t.reduce((e,t)=>({...e,...t}),{});return n&&(a.disabled=!0),a},e.evaluateProps=n;return}if("string"==typeof t){let r=this._evaluateFunction[t];if(r){e.evaluate=r;return}throw Error(`Evaluate function not found for name: ${t}, you can register an evaluate function with the getToolbarModule in your extensions`)}if("object"==typeof t){let{name:r,...n}=t,a=this._evaluateFunction[r];if(a){let t=e.evaluate;e.evaluate=e=>a({...e,...n}),e.evaluateProps=t;return}throw Error(`Evaluate function not found for name: ${r}, you can register an evaluate function with the getToolbarModule in your extensions`)}}},this._commandsManager=e,this._extensionManager=t,this._servicesManager=r}reset(){this.state={buttons:{},buttonSections:{}},this.unsubscriptions=[]}onModeEnter(){this.reset()}registerEvaluateFunction(e,t){this._evaluateFunction[e]=t}registerEventForToolbarUpdate(e,t){let{viewportGridService:r}=this._servicesManager.services,n=()=>{let e=r.getActiveViewportId();this.refreshToolbarState({viewportId:e})};t.map(t=>e.subscribe?e.subscribe(t,n):e.addEventListener?e.addEventListener(t,n):void 0).forEach(e=>this._serviceSubscriptions.push(e))}removeButton(e){this.state.buttons[e]&&delete this.state.buttons[e],Object.keys(this.state.buttonSections).forEach(t=>{this.state.buttonSections[t]=this.state.buttonSections[t].filter(t=>t!==e)}),this._broadcastEvent(this.EVENTS.TOOL_BAR_MODIFIED,{...this.state})}register(e,t=!1){e.forEach(e=>{(t||!this.state.buttons[e.id])&&(e.props||(e.props={}),!0===e.props.buttonSection&&(e.props.buttonSection=e.id),this.state.buttons[e.id]=e)}),this._broadcastEvent(this.EVENTS.TOOL_BAR_MODIFIED,{...this.state})}recordInteraction(e,t){"string"==typeof e&&(e=this.getButtonProps(e));let r=e.itemId??e.id;e.itemId=r;let n=Array.isArray(e.commands)?e.commands:[e.commands];if(n=n.filter(Boolean),!n?.length)return void this.refreshToolbarState({...t?.refreshProps,itemId:r,interaction:e});let a={...t,...e};(n=(n=n.map(e=>"function"==typeof e?()=>{e({...a,commandsManager:this._commandsManager,servicesManager:this._servicesManager})}:e)).filter(Boolean)).length&&(this._commandsManager.run(n,a),this.refreshToolbarState({...t?.refreshProps,itemId:r,interaction:e}))}refreshToolbarState(e){let t=this.state.buttons,r={...t},n=new Map,a=(e,t,r)=>{if(n.has(e.id)){let{disabled:r,disabledText:a,className:i,isActive:o}=n.get(e.id);return{...t,disabled:r,disabledText:a,className:i,isActive:o}}{let a=t.evaluateProps,i="function"==typeof t.evaluate?t.evaluate({...r,button:e}):void 0,o=a?.hideWhenDisabled||t.hideWhenDisabled,s=i?.visible===void 0?!(o&&i?.disabled):i?.visible,l={...t,...i,disabled:i?.disabled||!1,visible:s,className:i?.className||t?.className||"",isActive:i?.isActive};return n.set(e.id,l),l}},i=new Set;return Object.values(t).forEach(n=>{if(!i.has(n.id))if(n.props?.buttonSection){let o=n.props,{evaluate:s}=o,l="function"==typeof s?s({...e,button:n}):void 0;o={...o,disabled:l?.disabled??o.disabled,disabledText:l?.disabledText??o.disabledText};let d=this.state.buttonSections[o.buttonSection];if(!d)return;d.forEach(n=>{let o=t[n];if(!o||i.has(n))return;let s=a(o,o.props,e);r[n]={...o,props:s},i.add(n)})}else{this.handleEvaluate(n.props);let t=n.props,o=a(n,t,e);r[n.id]={...n,props:o},i.add(n.id)}}),this.setButtons(r),this.state}setButtons(e){this.state.buttons=e,this._broadcastEvent(this.EVENTS.TOOL_BAR_MODIFIED,{buttons:this.state.buttons,buttonSections:this.state.buttonSections})}getButton(e){return this.state.buttons[e]}addButtons(e,t=!1){console.warn("ToolbarService.addButtons() is deprecated. Use ToolbarService.register() instead."),this.register(e,t)}getButtons(){return this.state.buttons}getButtonProps(e){if(this.state.buttons[e])return this.state.buttons[e].props}_getButtonUITypes(){let e=this._extensionManager.modules.toolbarModule;return Array.isArray(e)?e.reduce((e,t)=>(t.module.forEach(t=>{e[t.name]=t}),e),{}):{}}updateSection(e,t){this.state.buttonSections[e]?this.state.buttonSections[e].push(...t.filter(t=>!this.state.buttonSections[e].find(e=>e===t))):this.state.buttonSections[e]=t,this._broadcastEvent(this.EVENTS.TOOL_BAR_MODIFIED,{...this.state})}createButtonSection(e,t){console.warn("ToolbarService.createButtonSection() is deprecated. Use ToolbarService.updateSection() instead."),this.updateSection(e,t)}getButtonSection(e,t){let r=this.state.buttonSections[e];return r?.map(e=>{let r=this.state.buttons[e];return this._mapButtonToDisplay(r,t)})||[]}getButtonPropsInButtonSection(e){let t=this.state.buttonSections[e];return t?.map(e=>this.getButtonProps(e))||[]}getToolNameForButton(e){let{props:t}=e,r=t?.commands||e.commands,n=(Array.isArray(r)?r:[r])[0];return n?.commandOptions?n.commandOptions.toolName??t?.id??e.id:t?.id??e.id}_mapButtonToDisplay(e,t){if(!e)return;let{id:r,uiType:n}=e,{buttonSection:a}=e.props,i=this._getButtonUITypes()[n];if(e.component||(e.component=i.defaultComponent),!i&&!e.component)return void console.warn(`Neither button type nor a component found for button: ${r}`);a?this.handleEvaluateNested(e.props):this.handleEvaluate(e.props);let{id:o,props:s}=e,l=(e,t)=>{let r=Array.isArray(e)?e:[e],n=this.getButtonProps(t);return r.map(e=>"function"==typeof e.optionComponent?e:{...e,onChange:t=>{e.value=t;let r=Array.isArray(e.commands)?e.commands:[e.commands];if(n&&n.options){let r=n.options.findIndex(t=>t.id===e.id);-1!==r&&(n.options[r].value=t)}r.forEach(r=>{let a={...e,value:t,options:n.options,servicesManager:this._servicesManager,commandsManager:this._commandsManager};this._commandsManager.run(r,a)}),this._broadcastEvent(NB.TOOL_BAR_STATE_MODIFIED,{buttons:this.state.buttons,buttonSections:this.state.buttonSections})}})};if(s?.items?.length){let{items:e=[]}=s;e.forEach(e=>{e.options&&(e.options=l(e.options,e.id))})}else s.options?.length?s.options=l(s.options,o):s.optionComponent&&(s.optionComponent=options.optionComponent);return{id:r,Component:e.component,componentProps:Object.assign({id:r},e.props,t)}}getButtonComponentForUIType(e){return e?this._getButtonUITypes()[e]?.defaultComponent??null:null}clearButtonSection(e){this.state.buttonSections[e]=[],this._broadcastEvent(this.EVENTS.TOOL_BAR_MODIFIED,{...this.state})}isInAnySection(e){return!!e&&Object.values(this.state.buttonSections).some(t=>Array.isArray(t)&&t.includes(e))}getAlignAndSide(e){switch(Number(e)){case NU.TopLeft:return{align:"start",side:"bottom"};case NU.TopMiddle:return{align:"center",side:"bottom"};case NU.TopRight:return{align:"end",side:"bottom"};case NU.LeftMiddle:return{align:"start",side:"right"};case NU.RightMiddle:return{align:"end",side:"left"};case NU.BottomLeft:return{align:"start",side:"top"};case NU.BottomMiddle:return{align:"center",side:"top"};case NU.BottomRight:return{align:"end",side:"top"};default:return{align:"start",side:"bottom"}}}getOptionById(e,t){return e.props.options?.find(e=>e.id===t)}}Nz.REGISTRATION={name:"toolbarService",altName:"ToolBarService",create:({commandsManager:e,extensionManager:t,servicesManager:r})=>new Nz(e,t,r)},Nz.TOOLBAR_SECTIONS=NW;class NH extends Ns{constructor({servicesManager:e}){super(NH.EVENTS),this.serviceImplementation={},this.servicesManager=void 0,this.presentationIdProviders=void 0,this.servicesManager=e,this.serviceImplementation={},this.presentationIdProviders=new Map}addPresentationIdProvider(e,t){this.presentationIdProviders.set(e,t)}getPresentationIdProvider(e){return this.presentationIdProviders.get(e)}getPresentationId(e,t){let r=this.getState(),n=r.viewports.get(t);return this._getPresentationId(e,{viewport:n,viewports:r.viewports})}_getPresentationId(e,{viewport:t,viewports:r}){let n=[...r.values()].some(e=>e.displaySetInstanceUIDs?.toString()===t.displaySetInstanceUIDs?.toString()&&e.viewportId===t.viewportId),a=this.presentationIdProviders.get(e);return a?a(e,{viewport:t,viewports:r,isUpdatingSameViewport:n,servicesManager:this.servicesManager}):null}getPresentationIds({viewport:e,viewports:t}){return Array.from(this.presentationIdProviders.keys()).reduce((r,n)=>{let a=this._getPresentationId(n,{viewport:e,viewports:t});return null!==a&&(r[n]=a),r},{})}setServiceImplementation({getState:e,setActiveViewportId:t,setDisplaySetsForViewports:r,setLayout:n,reset:a,onModeExit:i,set:o,getNumViewportPanes:s,setViewportIsReady:l,getViewportState:d}){d&&(this.serviceImplementation._getViewportState=d),e&&(this.serviceImplementation._getState=e),t&&(this.serviceImplementation._setActiveViewport=t),r&&(this.serviceImplementation._setDisplaySetsForViewports=r),n&&(this.serviceImplementation._setLayout=n),a&&(this.serviceImplementation._reset=a),i&&(this.serviceImplementation._onModeExit=i),o&&(this.serviceImplementation._set=o),s&&(this.serviceImplementation._getNumViewportPanes=s),l&&(this.serviceImplementation._setViewportIsReady=l)}publishViewportsReady(){this._broadcastEvent(this.EVENTS.VIEWPORTS_READY,{})}publishViewportOnDropHandled(e){this._broadcastEvent(this.EVENTS.VIEWPORT_ONDROP_HANDLED,{eventData:e})}setActiveViewportId(e){e!==this.getActiveViewportId()&&(this.serviceImplementation._setActiveViewport(e),setTimeout(()=>{this._broadcastEvent(this.EVENTS.ACTIVE_VIEWPORT_ID_CHANGED,{viewportId:e})},0))}getState(){return this.serviceImplementation._getState()}getViewportState(e){return this.serviceImplementation._getViewportState(e)}setViewportIsReady(e,t){this.serviceImplementation._setViewportIsReady(e,t)}getActiveViewportId(){return this.getState().activeViewportId}setViewportGridSizeChanged(){let e=this.getState();this._broadcastEvent(this.EVENTS.GRID_SIZE_CHANGED,{state:e})}setDisplaySetsForViewport(e){this.setDisplaySetsForViewports([e])}async setDisplaySetsForViewports(e){await this.serviceImplementation._setDisplaySetsForViewports(e);let t=this.getState(),r=[],n=[];for(let a of e){let e=t.viewports.get(a.viewportId);e?(r.push(e),0===(e.displaySetInstanceUIDs||[]).length&&n.push(a.viewportId)):n.push(a.viewportId)}setTimeout(()=>{this._broadcastEvent(NH.EVENTS.GRID_STATE_CHANGED,{state:t,viewports:r,removedViewportIds:n})})}getDisplaySetsUIDsForViewport(e){let t=this.getState().viewports.get(e);return t?.displaySetInstanceUIDs}async setLayout({numCols:e,numRows:t,layoutOptions:r,layoutType:n="grid",activeViewportId:a,findOrCreateViewport:i,isHangingProtocolLayout:o=!1}){let s=new Set(this.getState().viewports.keys());await this.serviceImplementation._setLayout({numCols:e,numRows:t,layoutOptions:r,layoutType:n,activeViewportId:a,findOrCreateViewport:i,isHangingProtocolLayout:o}),setTimeout(()=>{let r=this.getState(),n=new Set(r.viewports.keys()),a=[...s].filter(e=>!n.has(e));this._broadcastEvent(this.EVENTS.LAYOUT_CHANGED,{numCols:e,numRows:t}),this._broadcastEvent(this.EVENTS.GRID_STATE_CHANGED,{state:r,removedViewportIds:a})},0)}reset(){this.serviceImplementation._reset()}onModeExit(){this.serviceImplementation._onModeExit()}set(e){let t=new Set(this.getState().viewports.keys());this.serviceImplementation._set(e);let r=this.getState(),n=new Set(r.viewports.keys()),a=[...t].filter(e=>!n.has(e));setTimeout(()=>{this._broadcastEvent(this.EVENTS.GRID_STATE_CHANGED,{state:r,removedViewportIds:a})},0)}getNumViewportPanes(){return this.serviceImplementation._getNumViewportPanes()}getLayoutOptionsFromState(e){return Array.from(e.viewports.entries()).map(([e,t])=>({x:t.x,y:t.y,width:t.width,height:t.height}))}}NH.EVENTS={ACTIVE_VIEWPORT_ID_CHANGED:"event::activeviewportidchanged",LAYOUT_CHANGED:"event::layoutChanged",GRID_STATE_CHANGED:"event::gridStateChanged",GRID_SIZE_CHANGED:"event::gridSizeChanged",VIEWPORTS_READY:"event::viewportsReady",VIEWPORT_ONDROP_HANDLED:"event::viewportOnDropHandled"},NH.REGISTRATION={name:"viewportGridService",altName:"ViewportGridService",create:({configuration:e={},servicesManager:t})=>new NH({servicesManager:t})};class NG extends Ns{constructor(){super(NG.EVENTS),this.serviceImplementation={},this.startedClips=new Map,this.closedViewports=new Set,this.serviceImplementation={}}getState(){return this.serviceImplementation._getState()}setCine({id:e,frameRate:t,isPlaying:r}){return this.serviceImplementation._setCine({id:e,frameRate:t,isPlaying:r})}setIsCineEnabled(e){this.serviceImplementation._setIsCineEnabled(e),e&&this.closedViewports.forEach(e=>{this.clearViewportCineClosed(e)}),queueMicrotask(()=>{this._broadcastEvent(this.EVENTS.CINE_STATE_CHANGED,{isCineEnabled:e})})}playClip(e,t){let r=this.serviceImplementation._playClip(e,t);return this.startedClips.set(e,t),this._broadcastEvent(this.EVENTS.CINE_STATE_CHANGED,{isPlaying:!0}),r}stopClip(e,t){let r=this.serviceImplementation._stopClip(e,t);return this._broadcastEvent(this.EVENTS.CINE_STATE_CHANGED,{isPlaying:!1}),r}onModeExit(){this.setIsCineEnabled(!1),this.startedClips.forEach((e,t)=>{this.stopClip(t,e)})}getSyncedViewports(e){return this.serviceImplementation._getSyncedViewports(e)}setViewportCineClosed(e){this.closedViewports.add(e)}isViewportCineClosed(e){return this.closedViewports.size>0}clearViewportCineClosed(e){this.closedViewports.delete(e)}setServiceImplementation({getState:e,setCine:t,setIsCineEnabled:r,playClip:n,stopClip:a,getSyncedViewports:i}){i&&(this.serviceImplementation._getSyncedViewports=i),e&&(this.serviceImplementation._getState=e),t&&(this.serviceImplementation._setCine=t),r&&(this.serviceImplementation._setIsCineEnabled=r),n&&(this.serviceImplementation._playClip=n),a&&(this.serviceImplementation._stopClip=a)}}NG.EVENTS={CINE_STATE_CHANGED:"event::cineStateChanged"},NG.REGISTRATION={name:"cineService",altName:"CineService",create:({configuration:e={}})=>new NG};var Nq=d(3359),N$=d.n(Nq);function NK(){var e=[].slice.call(arguments),t=e.length;return function(r,n){var a,i,o,s,l,d,u;for(u=0;u<t&&(d=0,a=r[s="string"==typeof(o=e[u])?o:o.name],i=n[s],void 0!==o.primer&&(a=o.primer(a),i=o.primer(i)),l=o.reverse?-1:1,a<i&&(d=-1*l),a>i&&(d=+l),0===d);u++);return d}}var NY=d(6834),NX=d.n(NY);function NZ(e){return Array.isArray(e)?e:[e]}function NJ(e){return Array.isArray(e)?e[0]:e}function NQ(e){return"string"==typeof e||"number"==typeof e||e instanceof String||e instanceof Number}function N0(e){return"object"==typeof e&&null!==e&&(Symbol.iterator in e||"number"==typeof e.length)}function N1(e,t){if(!NQ(e)||""===String(e).trim())return t;let r=Number(e);return Number.isFinite(r)?r:t}function N2(e,t){return N1(NJ(e),t)}function N5(e,t,r){return Math.abs(e-t)<=r}function N3(e){return"number"==typeof e}function N4(e){return e&&"object"==typeof e&&"length"in e&&"number"==typeof e.length&&e.length>0&&"number"==typeof e[0]}function N8(e,t,r=1e-5){return typeof e==typeof t&&null!==e&&null!==t&&(N3(e)&&N3(t)?N5(e,t,r):!!(N4(e)&&N4(t))&&function(e,t,r=1e-5){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!N5(e[n],t[n],r))return!1;return!0}(e,t,r))}let N6=e=>"number"==typeof e?-e:e?.map?e.map(N6):!e,N9=e=>"number"==typeof e?Math.abs(e):e?.map?e.map(N9):e,N7=(e,t,r)=>N8(N9(e),N9(t),r),Re=Rm("cs3d"),Rt=Re.getLogger("metadata"),Rr=Re.getLogger("core"),Rn=Re.getLogger("tools"),Ra=Re.getLogger("adapters"),Ri=Re.getLogger("dicomImageLoader"),Ro=Re.getLogger("niftiVolumeLoader"),Rs=Re.getLogger("polymorphicSegmentation"),Rl=Re.getLogger("labelmapInterpolation"),Rd=Re.getLogger("ai"),Ru=Re.getLogger("examples"),Rc=Re.getLogger("worker"),Rh=Nl.log.getLogger("consistency.dicom"),Rp=Nl.log.getLogger("consistency.image");function Rm(e){let t=Nl.log.getLogger(e);return t.getLogger=(...t)=>Rm(`${e}.${t.join(".")}`),t}function Rf(...e){return Rm(e.join("."))}let Rg=new Set(["equals","doesNotEqual","includes","doesNotInclude","containsI","contains","containsAll","doesNotContain","doesNotContainI","startsWith","endsWith","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","range","notNull"]);NX().validators.equals=function(e,t,r){let n=Rx(t);if(!RI(e,n))return`${r} must equal ${Rw(n)}`},NX().validators.doesNotEqual=function(e,t,r){let n=Rx(t);if(RI(e,n))return`${r} must not equal ${Rw(n)}`},NX().validators.includes=function(e,t,r){let n=Rx(t);if(!RS(e,n).length)return`${r} must include one of ${Rw(n)}`},NX().validators.doesNotInclude=function(e,t,r){let n=RS(e,Rx(t));if(n.length>0)return`${r} must not include ${Rw(n)}`},NX().validators.containsI=function(e,t,r){if(!RC(e,t,!0,(e,t)=>e.includes(t)))return`${r} must contain any case of one of ${Rw(Rx(t))}`},NX().validators.contains=function(e,t,r){if(!RC(e,t,!1,(e,t)=>e.includes(t)))return`${r} must contain one of ${Rw(Rx(t))}`},NX().validators.containsAll=function(e,t,r){let n=Rx(t);if(!Array.isArray(e)||!Array.isArray(n))return`${r} must be an array and test value must be an array.`;let a=n.filter(t=>!e.includes(t));if(a.length>0)return`${r} must contain all of: ${n.join(", ")}. Missing: ${a.join(", ")}`},NX().validators.doesNotContain=function(e,t,r){if(RC(e,t,!1,(e,t)=>e.includes(t)))return`${r} must not contain ${Rw(Rx(t))}`},NX().validators.doesNotContainI=function(e,t,r){if(RC(e,t,!0,(e,t)=>e.includes(t)))return`${r} must not contain any case of ${Rw(Rx(t))}`},NX().validators.startsWith=function(e,t,r){if(!RC(e,t,!1,(e,t)=>e.startsWith(t)))return`${r} must start with one of ${Rw(Rx(t))}`},NX().validators.endsWith=function(e,t,r){if(!RC(e,t,!1,(e,t)=>e.endsWith(t)))return`${r} must end with one of ${Rw(Rx(t))}`};let Ry=(e,t)=>function(r,n,a){let i=Rk(Array.isArray(r)?r[0]:r);if(void 0===i)return`${a} must be a number, but was ${Rw(r)}`;let o=Rx(n);if(Array.isArray(o)&&o.length>1)return a+" must be an array of length 1";let s=Rk(Array.isArray(o)?o[0]:o);return void 0===s?`${a} has a test value that is not a number: ${Rw(o)}`:e(i,s)?void 0:`${a} must be ${t} ${s}, but was ${i}`};NX().validators.greaterThan=Ry((e,t)=>e>t,"greater than"),NX().validators.greaterThanOrEqual=Ry((e,t)=>e>=t,"greater than or equal to"),NX().validators.lessThan=Ry((e,t)=>e<t,"less than"),NX().validators.lessThanOrEqual=Ry((e,t)=>e<=t,"less than or equal to"),NX().validators.range=function(e,t,r){let n=Rx(t),a=Array.isArray(n)?n.map(Rk):[];if(2!==a.length||a.includes(void 0))return`${r} must be an array of two numbers`;let i=Math.min(a[0],a[1]),o=Math.max(a[0],a[1]),s=Rk(Array.isArray(e)?e[0]:e);if(void 0===s||s<i||s>o)return`${r} with value ${Rw(e)} must be between ${i} and ${o}`};let Rv=e=>null==e||""===e||Array.isArray(e)&&e.every(Rv);NX().validators.notNull=(e,t)=>{let r=Rv(e);return!1===Rx(t)?r?void 0:"Value is not null":r?"Value is null":void 0};let Rb=e=>null!==e&&"object"==typeof e&&!Array.isArray(e)&&"value"in e?e.value:e,Rx=e=>Array.isArray(e)?e.map(Rb):Rb(e),Rw=e=>"number"==typeof e?String(e):JSON.stringify(e)??String(e),RC=(e,t,r,n)=>{let a=e=>r?e.toLowerCase():e,i=NZ(e).filter(e=>!Rv(e)).map(e=>a(String(e))),o=NZ(Rx(t)).filter(e=>null!=e).map(String).map(a);return i.some(e=>o.some(t=>n(e,t)))},Rk=e=>{if("string"==typeof e&&""===e.trim())return;let t="number"==typeof e||"string"==typeof e?Number(e):NaN;return Number.isFinite(t)?t:void 0},RM=(e,t)=>{if(e===t)return!0;if("boolean"==typeof e||"boolean"==typeof t){let[r,n]="boolean"==typeof e?[e,t]:[t,e];return n===String(r)}if("number"!=typeof e&&"number"!=typeof t)return!1;let r=Rk(e);return void 0!==r&&r===Rk(t)},RS=(e,t)=>{let r=NZ(e);return NZ(t).filter(e=>r.some(t=>RM(t,e)))},RI=(e,t)=>{let r=NZ(e),n=NZ(t);return r.length===n.length&&n.every((e,t)=>RM(e,r[t]))},RT=NX(),R_=e=>0===e||!1===e||""===e?{value:e}:e;class RP{constructor(e,t){this.protocols=e,this.customAttributeRetrievalCallbacks=t,this.matchedProtocols=new Map,this.matchedProtocolScores={},this.study=void 0}run({studies:e,displaySets:t,activeStudy:r}){return this.studies=e,this.study=r||e[0],this.displaySets=t,this.getBestProtocolMatch()}getBestProtocolMatch(){this.updateProtocolMatches();let e=this._getHighestScoringProtocol();return console.log("ProtocolEngine::getBestProtocolMatch bestMatch",e),e}updateProtocolMatches(){console.log("ProtocolEngine::updateProtocolMatches"),this._clearMatchedProtocols(),this.findMatchByStudy(this.study,{studies:this.studies,displaySets:this.displaySets}).forEach(e=>{let t=e.protocol;t&&(this.matchedProtocols.has(t.id)||(console.log("ProtocolEngine::updateProtocolMatches inserting protocol match",e),this.matchedProtocols.set(t.id,t),this.matchedProtocolScores[t.id]=e.score))})}findMatch(e,t,r){return((e,t=[],r,n)=>{let a={format:"grouped"},i={passed:[],failed:[]},o={},s=!1,l=0,d=n?.studies?.[1],u=n?.studies?.[0],c=e.instances?.[0],h={prior:d,current:u,instance:c,...n,options:n,metadataInstance:e};return t.forEach(t=>{let d,{attribute:u,from:p="metadataInstance"}=t;r.hasOwnProperty(u)?o[u]=r[u].callback.call(t,e,n):o[u]=h[p]?.[u]??c?.[u];let m=((e,t,r,n)=>{if("object"!=typeof t||null===t)return t;let a={};return Object.entries(t).forEach(([e,t])=>{if(t&&"object"==typeof t&&"attribute"in t){let i=t.attribute,o=t.from??"metadataInstance";if(r.hasOwnProperty(i)){let t=r[i].callback.call(null,n[o],n.options);a[e]={value:t}}else a[e]={value:n[o]?.[i]??n.metadataInstance?.[i]}}else a[e]=Rg.has(e)?R_(t):t},{}),a})(0,t.constraint,r,h),f={[u]:o[u]};try{d=RT(f,{[u]:m},[a])}catch(e){d=["Something went wrong during validation.",e]}d?(t.required&&(s=!0),i.failed.push({rule:t,errorMessages:d})):(l+=parseInt(t.weight||1,10),i.passed.push({rule:t}))}),s&&(l=0),{score:l,details:i,requiredFailed:s}})(e,t,this.customAttributeRetrievalCallbacks,r)}findMatchByStudy(e,t){let r=[];if(this.protocols.forEach(n=>{let a=n.protocolMatchingRules.slice();if(!a||!a.length)return void console.warn("ProtocolEngine::findMatchByStudy no matching rules - specify protocolMatchingRules for",n.id);let i=this.findMatch(e,a,t).score;i>0&&r.push({score:i,protocol:n})}),!r.length){let e=this.protocols.find(e=>"default"===e.id)??this.protocols[0];return console.log("No protocol matches, defaulting to",e),[{score:0,protocol:e}]}return r.sort((e,t)=>t.score-e.score),console.log("ProtocolEngine::findMatchByStudy matched",r),r}_clearMatchedProtocols(){this.matchedProtocols.clear(),this.matchedProtocolScores={}}_largestKeyByValue(e){return Object.keys(e).reduce((t,r)=>e[t]>e[r]?t:r)}_getHighestScoringProtocol(){if(!Object.keys(this.matchedProtocolScores).length)return;let e=this._largestKeyByValue(this.matchedProtocolScores);return this.matchedProtocols.get(e)}}function RE(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}function RD(e,t){if("string"!=typeof e)throw TypeError("Expected `string` parameter to be of type `string`");if("string"!=typeof t&&!(t instanceof RegExp))throw TypeError("Expected `separator` to be of type `string` or `RegExp`");if(""===e||"string"==typeof t&&""===t)return[];if("string"==typeof t){let r=e.indexOf(t);return -1===r?[]:[e.slice(0,r),e.slice(r+t.length)]}let r=t.flags.replace("g",""),n=new RegExp(t.source,r).exec(e);return n?[e.slice(0,n.index),e.slice(n.index+n[0].length)]:[]}function RA(e,t){return void 0===e||t.skipNull&&null===e||t.skipEmptyString&&""===e}function RO(e){if("string"!=typeof e||1!==e.length)throw TypeError("arrayFormatSeparator must be a single character");if(""===e.trim())throw TypeError("arrayFormatSeparator must not be whitespace, since parse() ignores leading and trailing whitespace in the query");if(/\p{Surrogate}/v.test(e))throw TypeError("arrayFormatSeparator must not be a lone surrogate, since it cannot be percent-encoded")}function RN(e,t){let r=typeof e;if("function"===r||"symbol"===r||"object"===r&&null!==e)throw TypeError(`Unsupported value type: ${r}. Supported types are string, number, bigint, boolean, null, and undefined. Use the \`replacer\` option to transform other types.`);if(t.encode)try{return t.strict?encodeURIComponent(e).replaceAll(/[!'\(\)*]/gv,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`):encodeURIComponent(e)}catch{return RN(String(e).replaceAll(/\p{Surrogate}/gv,"�"),t)}return e}function RR(e,t){let r=RN(e,t),n=String(e),{arrayFormatSeparator:a}=t;if(!t.encode||!n.includes(a))return r;let i=encodeURIComponent(a),o=i===a?`%${a.codePointAt(0).toString(16).toUpperCase().padStart(2,"0")}`:i;return n.split(a).map(e=>RN(e,t)).join(o)}let RL=/%/gv,Rj=/%[\da-f]{2}/ivy;function RV(e,t){Rj.lastIndex=t;let r=Rj.exec(e);return null===r?-1:Number.parseInt(r[0].slice(1),16)}function RF(e){try{return decodeURIComponent(e)}catch{}RL.lastIndex=0;let t="",r=0,n=RL.exec(e);for(;null!==n;){t+=e.slice(r,n.index);let[a,i]=function(e,t){let r=RV(e,t);if(-1===r)return["%",t+1];let n=r<128?1:r<194?0:r<224?2:r<240?3:4*(r<=244);if(0===n)return["�",t+3];if(1===n)return[String.fromCodePoint(r),t+3];let a=r&127>>n,i=1;for(;i<n;){let n=RV(e,t+3*i);if(!(1===i?function(e,t){if(t<128||t>191)return!1;switch(e){case 224:return t>=160;case 237:return t<=159;case 240:return t>=144;case 244:return t<=143;default:return!0}}(r,n):n>=128&&n<=191))return["�",t+3*i];a=a<<6|63&n,i++}return[String.fromCodePoint(a),t+3*n]}(e,n.index);t+=a,RL.lastIndex=r=i,n=RL.exec(e)}return t+e.slice(r)}function RB(e,t){return t.decode?RF(e):e}function RW(e){return RF(e.replaceAll("+"," "))}function RU(e){let t={};for(let[r,n]of Object.entries(e??{}))void 0!==n&&(t[r]=n);return t}function Rz(e){let t=e.indexOf("#");return -1!==t&&(e=e.slice(0,t)),e}function RH(e){let t="",r=e.indexOf("#");return -1!==r&&(t=e.slice(r)),t}function RG(e){let t=e.indexOf("?");return -1===t?e:e.slice(0,t)}function Rq(e,t,r){return"string"===r&&"string"==typeof e?e:"function"==typeof r&&"string"==typeof e?r(e):"boolean"===r&&null===e||("boolean"===r&&null!==e&&("true"===e.toLowerCase()||"false"===e.toLowerCase())?"true"===e.toLowerCase():"boolean"===r&&null!==e&&("1"===e.toLowerCase()||"0"===e.toLowerCase())?"1"===e.toLowerCase():("string[]"===r||"number[]"===r)&&"none"!==t.arrayFormat&&("string"==typeof e||null===e)?[Rq(e,t,r.slice(0,-2))]:"number"!==r||"string"!=typeof e||""===e.trim()||Number.isNaN(Number(e))?["boolean","number","string[]","number[]"].includes(r)?e:null!==e&&t.parseBooleans&&("true"===e.toLowerCase()||"false"===e.toLowerCase())?"true"===e.toLowerCase():"string"==typeof e&&t.parseNumbers&&""!==e.trim()&&!Number.isNaN(Number(e))?Number(e):e:Number(e))}function R$(e){let t=(e=Rz(e)).indexOf("?");return -1===t?"":e.slice(t+1)}function RK(e,t){RO((t={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,...RU(t),types:{__proto__:null,...t?.types}}).arrayFormatSeparator);let r=function(e){switch(e.arrayFormat){case"index":{let e=new Map;return(t,r,n)=>{let a=/\[(?<index>\d*)\]$/v.exec(t);if(t=t.replace(/\[(?<index>\d*)\]$/v,""),!a&&void 0===n[t]){n[t]=r;return}void 0===n[t]?n[t]={}:("object"!=typeof n[t]||null===n[t])&&(n[t]={"":n[t]},e.set(t,1));let i=a?.groups?.index||(e.get(t)??0);n[t][i]=r,e.set(t,Math.max(e.get(t)??0,Number(i)+1))}}case"bracket":case"colon-list-separator":{let t="bracket"===e.arrayFormat?/\[\]$/v:/:list$/v;return(e,r,n)=>{let a=t.test(e);if(void 0===n[e=e.replace(t,"")]){n[e]=a?[r]:r;return}if(!Array.isArray(n[e])){n[e]=[n[e],r];return}n[e].push(r)}}case"comma":case"separator":return(t,r,n)=>{let a="string"==typeof r&&r.includes(e.arrayFormatSeparator)?r.split(e.arrayFormatSeparator).map(t=>RB(t,e)):null===r?r:RB(r,e);if(void 0===n[t]){n[t]=a;return}for(let e of(Array.isArray(n[t])||(n[t]=[n[t]]),Array.isArray(a)?a:[a]))n[t].push(e)};case"bracket-separator":return(t,r,n)=>{let a,i=/\[\]$/v.test(t);if(t=t.replace(/\[\]$/v,""),a=i?null===r?[]:r.split(e.arrayFormatSeparator).map(t=>RB(t,e)):[null===r?r:RB(r,e)],void 0===n[t]){n[t]=i?a:a[0];return}for(let e of(Array.isArray(n[t])||(n[t]=[n[t]]),a))n[t].push(e)};default:return(e,t,r)=>{if(void 0===r[e]){r[e]=t;return}Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]}}}(t),n=Object.create(null);if("string"!=typeof e||!(e=e.trim().replace(/^[#&?]/v,""))||/^&+$/v.test(e))return n;let a=0,i=e.indexOf("&");-1===i&&(i=e.length);for(let o=i;o<=e.length;o++){if(o<e.length&&"&"!==e[o])continue;if(o===a){a=o+1;continue}let i=e.slice(a,o),s=t.decode?i.replaceAll("+"," "):i,[l,d]=RD(s,"=");void 0===l&&(l=s),d=void 0===d?null:["comma","separator","bracket-separator"].includes(t.arrayFormat)?d:RB(d,t),r(RB(l,t),d,n),a=o+1}for(let[e,r]of Object.entries(n))if("object"!=typeof r||null===r||Array.isArray(r)||(r=function(e){return Object.keys(e).toSorted().toSorted((e,t)=>Number(e)-Number(t)).map(t=>e[t])}(r),n[e]=r),Array.isArray(r)&&"string"!==t.types[e]){let n=t.types[e],a="string"==typeof n?n.replace("[]",""):n;for(let[e,n]of r.entries())r[e]=Rq(n,t,a)}else Array.isArray(r)&&"string"===t.types[e]?n[e]=r.join(t.arrayFormatSeparator):n[e]=Rq(r,t,t.types[e]);return!1===t.sort?n:Object.keys(n).toSorted("function"==typeof t.sort?t.sort:void 0).reduce((e,t)=>(e[t]=n[t],e),Object.create(null))}function RY(e,t){if(!e)return"";RO((t={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...RU(t)}).arrayFormatSeparator);let r=function(e){let{arrayFormat:t}=e;if(["comma","separator","bracket-separator"].includes(t)){let r="bracket-separator"===t?"[]=":"=";return t=>(n,a)=>{if(RA(a,e))return n;let i=RR(null===a?"":a,e);return 0===n.length?n.push([RN(t,e),r,i].join("")):n.push(i),n}}let r=function(e){switch(e){case"index":return e=>`[${e}]`;case"bracket":return()=>"[]";case"colon-list-separator":return()=>":list";default:return()=>""}}(t);return t=>(n,a)=>{if(RA(a,e))return n;let i=RN(t,e)+r(n.length);return null===a?n.push(i):n.push([i,"=",RN(a,e)].join("")),n}}(t),n={};for(let[t,r]of Object.entries(e))n[t]=r;let a=Object.keys(n);return!1!==t.sort&&a.sort("function"==typeof t.sort?t.sort:void 0),a.map(e=>{let a=n[e];if(t.replacer&&(a=t.replacer(e,a)),RA(a,t))return"";if(null===a)return RN(e,t);if(Array.isArray(a)){let n=a;t.replacer&&(n=a.map((r,n)=>t.replacer(`${e}[${n}]`,r)).filter(e=>void 0!==e));let i=n.reduce(r(e),[]);if(0===i.length)return"bracket-separator"===t.arrayFormat?RN(e,t)+"[]":"";let o=["comma","separator","bracket-separator"].includes(t.arrayFormat)?t.arrayFormatSeparator:"&";return i.join(o)}let i="comma"===t.arrayFormat||"separator"===t.arrayFormat?RR(a,t):RN(a,t);return RN(e,t)+"="+i}).filter(e=>e.length>0).join("&")}function RX(e,t){t={decode:!0,...RU(t)};let[r,n]=RD(e=e.trim(),"#");return void 0===r&&(r=e),{url:RG(r),query:RK(R$(e),t),...t.parseFragmentIdentifier&&n&&{fragmentIdentifier:RB(n,t)}}}function RZ(e,t){t={encode:!0,strict:!0,...RU(t)};let r=e.url.trim(),n=RG(Rz(r)),a=RK(R$(r),{sort:!1,...t,decode:t.encode,parseNumbers:!1,parseBooleans:!1,types:void 0}),i=Object.fromEntries(Object.entries(e.query??{}));if(!t.encode){let e=new Map;for(let[t,r]of Object.entries(i)){let n=RW(t);e.has(n)||e.set(n,{key:t,value:r})}a=Object.fromEntries(Object.entries(a).map(([t,r])=>{let n=e.get(RW(t));return n?[n.key,n.value]:[t,r]}))}let o=RY({...a,...i},t);o&&=`?${o}`;let s=RH(r);if("string"==typeof e.fragmentIdentifier&&(s=""===e.fragmentIdentifier?"":`#${e.fragmentIdentifier}`,t.encode)){let e=new URL("https://query-string.invalid");e.hash=s.replaceAll(/[\t\n\r%]/gv,e=>`%${e.codePointAt(0).toString(16).toUpperCase().padStart(2,"0")}`),s=e.hash}return`${n}${o}${s}`}function RJ(e,t,r){if(Array.isArray(t)){let n=new Set(t);return RJ(e,e=>n.has(e),r)}let n=void 0===(r=RU(r)).encode||!!r.encode,{url:a,query:i}=RX(e,{...r,decode:n,parseNumbers:!1,parseBooleans:!1,types:void 0}),o=RK(R$(e),{...r,decode:n});return RZ({url:a+RH(e),query:function(e,t){let r={};if(Array.isArray(t)||"[object Set]"===Object.prototype.toString.call(t))for(let n of t){let t=Object.getOwnPropertyDescriptor(e,n);t?.enumerable&&Object.defineProperty(r,n,t)}else for(let n of Reflect.ownKeys(e)){let a=Object.getOwnPropertyDescriptor(e,n);if(!a?.enumerable)continue;let i=e[n];t(n,i,e)&&Object.defineProperty(r,n,a)}return r}(i,e=>t(e,o[e]))},r)}function RQ(e,t,r){if(Array.isArray(t)){let n=new Set(t);return RJ(e,e=>!n.has(e),r)}return RJ(e,(e,r)=>!t(e,r),r)}var R0=d(8681),R1=d.n(R0);!function(e,t={timeout:100}){var r=[],n=null,a=[],i=!1,o=null,s=e.prototype.handleKey;function l(e,t,r){if(!this.recording)return void s.apply(this,arguments);if("keydown"==r.type){1===e.length&&i&&u();for(let e=0;e<t.length;++e)d(t[e]);d(e)}else"keyup"==r.type&&a.length>0&&u()}function d(e){for(let t=0;t<a.length;++t)if(a[t]===e)return;a.push(e),1===e.length&&(i=!0)}function u(){r.push(a),a=[],i=!1,clearTimeout(o),o=setTimeout(c,t.timeout)}function c(){if(n){var e=r;for(let t=0;t<e.length;++t)e[t].sort(function(e,t){return e.length>1&&1===t.length?-1:1===e.length&&t.length>1||e>t?1:-1}),e[t]=e[t].join("+");n(r)}r=[],n=null,a=[]}e.prototype.record=function(e){var t=this;t.recording=!0,n=function(){t.recording=!1,e.apply(t,arguments)}},e.prototype.stopRecord=function(){this.recording=!1},e.prototype.startRecording=function(){this.recording=!0},e.prototype.handleKey=function(){l.apply(this,arguments)},e.init()}(R1()),eI$=(eIq=R1()).prototype.stopCallback,eIq.prototype.stopCallback=function(e,t,r){return!!this.paused||eI$.call(this,e,t,r)},eIq.prototype.pause=function(){this.paused=!0},eIq.prototype.unpause=function(){this.paused=!1},eIq.init(),T=(eIK=R1()).prototype.stopCallback,eIK.prototype.stopCallback=function(e,t,r,n){return!!("function"==typeof t?.closest&&t.closest('[role="dialog"], .ohif-text-select'))||T.call(this,e,t,r,n)};let R2=R1();Symbol("Type"),Symbol("Task"),Symbol("List");let R5=Object.freeze(["SEG","KO","PR","SR","RTSTRUCT","RTDOSE","RTPLAN","RTRECORD","REG"]);function R3(e){return R5.includes(e)}let R4={ComputedRadiographyImageStorage:"1.2.840.10008.5.1.4.1.1.1",DigitalXRayImageStorageForPresentation:"1.2.840.10008.5.1.4.1.1.1.1",DigitalXRayImageStorageForProcessing:"1.2.840.10008.5.1.4.1.1.1.1.1",DigitalMammographyXRayImageStorageForPresentation:"1.2.840.10008.5.1.4.1.1.1.2",DigitalMammographyXRayImageStorageForProcessing:"1.2.840.10008.5.1.4.1.1.1.2.1",DigitalIntraOralXRayImageStorageForPresentation:"1.2.840.10008.5.1.4.1.1.1.3",DigitalIntraOralXRayImageStorageForProcessing:"1.2.840.10008.5.1.4.1.1.1.3.1",CTImageStorage:"1.2.840.10008.5.1.4.1.1.2",EnhancedCTImageStorage:"1.2.840.10008.5.1.4.1.1.2.1",LegacyConvertedEnhancedCTImageStorage:"1.2.840.10008.5.1.4.1.1.2.2",UltrasoundMultiframeImageStorage:"1.2.840.10008.5.1.4.1.1.3.1",MRImageStorage:"1.2.840.10008.5.1.4.1.1.4",EnhancedMRImageStorage:"1.2.840.10008.5.1.4.1.1.4.1",MRSpectroscopyStorage:"1.2.840.10008.5.1.4.1.1.4.2",EnhancedMRColorImageStorage:"1.2.840.10008.5.1.4.1.1.4.3",LegacyConvertedEnhancedMRImageStorage:"1.2.840.10008.5.1.4.1.1.4.4",UltrasoundImageStorage:"1.2.840.10008.5.1.4.1.1.6.1",EnhancedUSVolumeStorage:"1.2.840.10008.5.1.4.1.1.6.2",SecondaryCaptureImageStorage:"1.2.840.10008.5.1.4.1.1.7",MultiframeSingleBitSecondaryCaptureImageStorage:"1.2.840.10008.5.1.4.1.1.7.1",MultiframeGrayscaleByteSecondaryCaptureImageStorage:"1.2.840.10008.5.1.4.1.1.7.2",MultiframeGrayscaleWordSecondaryCaptureImageStorage:"1.2.840.10008.5.1.4.1.1.7.3",MultiframeTrueColorSecondaryCaptureImageStorage:"1.2.840.10008.5.1.4.1.1.7.4",Sop12LeadECGWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.1.1",GeneralECGWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.1.2",AmbulatoryECGWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.1.3",HemodynamicWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.2.1",CardiacElectrophysiologyWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.3.1",BasicVoiceAudioWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.4.1",GeneralAudioWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.4.2",ArterialPulseWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.5.1",RespiratoryWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.6.1",GrayscaleSoftcopyPresentationStateStorage:"1.2.840.10008.5.1.4.1.1.11.1",ColorSoftcopyPresentationStateStorage:"1.2.840.10008.5.1.4.1.1.11.2",PseudoColorSoftcopyPresentationStateStorage:"1.2.840.10008.5.1.4.1.1.11.3",BlendingSoftcopyPresentationStateStorage:"1.2.840.10008.5.1.4.1.1.11.4",XAXRFGrayscaleSoftcopyPresentationStateStorage:"1.2.840.10008.5.1.4.1.1.11.5",XRayAngiographicImageStorage:"1.2.840.10008.5.1.4.1.1.12.1",EnhancedXAImageStorage:"1.2.840.10008.5.1.4.1.1.12.1.1",XRayRadiofluoroscopicImageStorage:"1.2.840.10008.5.1.4.1.1.12.2",EnhancedXRFImageStorage:"1.2.840.10008.5.1.4.1.1.12.2.1",XRay3DAngiographicImageStorage:"1.2.840.10008.5.1.4.1.1.13.1.1",XRay3DCraniofacialImageStorage:"1.2.840.10008.5.1.4.1.1.13.1.2",BreastTomosynthesisImageStorage:"1.2.840.10008.5.1.4.1.1.13.1.3",BreastProjectionXRayImageStorageForPresentation:"1.2.840.10008.5.1.4.1.1.13.1.4",BreastProjectionXRayImageStorageForProcessing:"1.2.840.10008.5.1.4.1.1.13.1.5",IntravascularOpticalCoherenceTomographyImageStorageForPresentation:"1.2.840.10008.5.1.4.1.1.14.1",IntravascularOpticalCoherenceTomographyImageStorageForProcessing:"1.2.840.10008.5.1.4.1.1.14.2",NuclearMedicineImageStorage:"1.2.840.10008.5.1.4.1.1.20",RawDataStorage:"1.2.840.10008.5.1.4.1.1.66",SpatialRegistrationStorage:"1.2.840.10008.5.1.4.1.1.66.1",SpatialFiducialsStorage:"1.2.840.10008.5.1.4.1.1.66.2",DeformableSpatialRegistrationStorage:"1.2.840.10008.5.1.4.1.1.66.3",SegmentationStorage:"1.2.840.10008.5.1.4.1.1.66.4",LabelmapSegmentationStorage:"1.2.840.10008.5.1.4.1.1.66.7",SurfaceSegmentationStorage:"1.2.840.10008.5.1.4.1.1.66.5",RealWorldValueMappingStorage:"1.2.840.10008.5.1.4.1.1.67",SurfaceScanMeshStorage:"1.2.840.10008.5.1.4.1.1.68.1",SurfaceScanPointCloudStorage:"1.2.840.10008.5.1.4.1.1.68.2",VLEndoscopicImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.1",VideoEndoscopicImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.1.1",VLMicroscopicImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.2",VideoMicroscopicImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.2.1",VLSlideCoordinatesMicroscopicImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.3",VLPhotographicImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.4",VideoPhotographicImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.4.1",OphthalmicPhotography8BitImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.5.1",OphthalmicPhotography16BitImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.5.2",StereometricRelationshipStorage:"1.2.840.10008.5.1.4.1.1.77.1.5.3",OphthalmicTomographyImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.5.4",VLWholeSlideMicroscopyImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.6",LensometryMeasurementsStorage:"1.2.840.10008.5.1.4.1.1.78.1",AutorefractionMeasurementsStorage:"1.2.840.10008.5.1.4.1.1.78.2",KeratometryMeasurementsStorage:"1.2.840.10008.5.1.4.1.1.78.3",SubjectiveRefractionMeasurementsStorage:"1.2.840.10008.5.1.4.1.1.78.4",VisualAcuityMeasurementsStorage:"1.2.840.10008.5.1.4.1.1.78.5",SpectaclePrescriptionReportStorage:"1.2.840.10008.5.1.4.1.1.78.6",OphthalmicAxialMeasurementsStorage:"1.2.840.10008.5.1.4.1.1.78.7",IntraocularLensCalculationsStorage:"1.2.840.10008.5.1.4.1.1.78.8",MacularGridThicknessandVolumeReport:"1.2.840.10008.5.1.4.1.1.79.1",OphthalmicVisualFieldStaticPerimetryMeasurementsStorage:"1.2.840.10008.5.1.4.1.1.80.1",OphthalmicThicknessMapStorage:"1.2.840.10008.5.1.4.1.1.81.1",CornealTopographyMapStorage:"1.2.840.10008.5.1.4.1.1.82.1",BasicTextSR:"1.2.840.10008.5.1.4.1.1.88.11",EnhancedSR:"1.2.840.10008.5.1.4.1.1.88.22",ComprehensiveSR:"1.2.840.10008.5.1.4.1.1.88.33",Comprehensive3DSR:"1.2.840.10008.5.1.4.1.1.88.34",ProcedureLog:"1.2.840.10008.5.1.4.1.1.88.40",MammographyCADSR:"1.2.840.10008.5.1.4.1.1.88.50",KeyObjectSelection:"1.2.840.10008.5.1.4.1.1.88.59",ChestCADSR:"1.2.840.10008.5.1.4.1.1.88.65",XRayRadiationDoseSR:"1.2.840.10008.5.1.4.1.1.88.67",RadiopharmaceuticalRadiationDoseSR:"1.2.840.10008.5.1.4.1.1.88.68",ColonCADSR:"1.2.840.10008.5.1.4.1.1.88.69",ImplantationPlanSRDocumentStorage:"1.2.840.10008.5.1.4.1.1.88.70",EncapsulatedPDFStorage:"1.2.840.10008.5.1.4.1.1.104.1",EncapsulatedCDAStorage:"1.2.840.10008.5.1.4.1.1.104.2",PositronEmissionTomographyImageStorage:"1.2.840.10008.5.1.4.1.1.128",EnhancedPETImageStorage:"1.2.840.10008.5.1.4.1.1.130",LegacyConvertedEnhancedPETImageStorage:"1.2.840.10008.5.1.4.1.1.128.1",BasicStructuredDisplayStorage:"1.2.840.10008.5.1.4.1.1.131",RTImageStorage:"1.2.840.10008.5.1.4.1.1.481.1",RTDoseStorage:"1.2.840.10008.5.1.4.1.1.481.2",RTStructureSetStorage:"1.2.840.10008.5.1.4.1.1.481.3",RTBeamsTreatmentRecordStorage:"1.2.840.10008.5.1.4.1.1.481.4",RTPlanStorage:"1.2.840.10008.5.1.4.1.1.481.5",RTBrachyTreatmentRecordStorage:"1.2.840.10008.5.1.4.1.1.481.6",RTTreatmentSummaryRecordStorage:"1.2.840.10008.5.1.4.1.1.481.7",RTIonPlanStorage:"1.2.840.10008.5.1.4.1.1.481.8",RTIonBeamsTreatmentRecordStorage:"1.2.840.10008.5.1.4.1.1.481.9",RTBeamsDeliveryInstructionStorage:"1.2.840.10008.5.1.4.34.7",GenericImplantTemplateStorage:"1.2.840.10008.5.1.4.43.1",ImplantAssemblyTemplateStorage:"1.2.840.10008.5.1.4.44.1",ImplantTemplateGroupStorage:"1.2.840.10008.5.1.4.45.1"},R8=[R4.ComputedRadiographyImageStorage,R4.DigitalXRayImageStorageForPresentation,R4.DigitalXRayImageStorageForProcessing,R4.DigitalMammographyXRayImageStorageForPresentation,R4.DigitalMammographyXRayImageStorageForProcessing,R4.DigitalIntraOralXRayImageStorageForPresentation,R4.DigitalIntraOralXRayImageStorageForProcessing,R4.CTImageStorage,R4.EnhancedCTImageStorage,R4.LegacyConvertedEnhancedCTImageStorage,R4.UltrasoundMultiframeImageStorage,R4.EnhancedUSVolumeStorage,R4.MRImageStorage,R4.EnhancedMRImageStorage,R4.EnhancedMRColorImageStorage,R4.LegacyConvertedEnhancedMRImageStorage,R4.UltrasoundImageStorage,R4.SecondaryCaptureImageStorage,R4.MultiframeSingleBitSecondaryCaptureImageStorage,R4.MultiframeGrayscaleByteSecondaryCaptureImageStorage,R4.MultiframeGrayscaleWordSecondaryCaptureImageStorage,R4.MultiframeTrueColorSecondaryCaptureImageStorage,R4.XRayAngiographicImageStorage,R4.EnhancedXAImageStorage,R4.XRayRadiofluoroscopicImageStorage,R4.EnhancedXRFImageStorage,R4.XRay3DAngiographicImageStorage,R4.XRay3DCraniofacialImageStorage,R4.BreastTomosynthesisImageStorage,R4.BreastProjectionXRayImageStorageForPresentation,R4.BreastProjectionXRayImageStorageForProcessing,R4.IntravascularOpticalCoherenceTomographyImageStorageForPresentation,R4.IntravascularOpticalCoherenceTomographyImageStorageForProcessing,R4.NuclearMedicineImageStorage,R4.VLEndoscopicImageStorage,R4.VideoEndoscopicImageStorage,R4.VLMicroscopicImageStorage,R4.VideoMicroscopicImageStorage,R4.VLSlideCoordinatesMicroscopicImageStorage,R4.VLPhotographicImageStorage,R4.VideoPhotographicImageStorage,R4.OphthalmicPhotography8BitImageStorage,R4.OphthalmicPhotography16BitImageStorage,R4.OphthalmicTomographyImageStorage,R4.VLWholeSlideMicroscopyImageStorage,R4.PositronEmissionTomographyImageStorage,R4.EnhancedPETImageStorage,R4.LegacyConvertedEnhancedPETImageStorage,R4.RTImageStorage];function R6(e){return Array.isArray(e)?[...e].map(e=>void 0!==e?Number(e):e):void 0!==e?Number(e):e}var R9=d(7155);function R7(e){let t=e.indexOf(":");return e.substring(t+1)}function Le(e){return(/^(http|https|dicomfile):\/\//.test(e)?e:R7(e)).split("&frame=")[0].split("?frame=")[0]}let Lt=[["InstanceCreationDate","InstanceCreationTime"],["ContentDate","ContentTime"],["AcquisitionDate","AcquisitionTime"],["StructureSetDate","StructureSetTime"],["PresentationCreationDate","PresentationCreationTime"],["SeriesDate","SeriesTime"]],Lr=["AcquisitionDateTime"];function Ln(e){let t=/^([+-])(\d{2})(\d{2})$/.exec(`${e??""}`.trim());if(!t)return;let[,r,n,a]=t;return("-"===r?-1:1)*(60*Number(n)+Number(a))}let La=/^(\d{8})(\d{0,6})(\.\d{1,6})?([+-]\d{4})?$/,Li=e=>`${e}`.padStart(2,"0"),Lo=(e,t)=>{let r=e[t]??e[`${t.charAt(0).toLowerCase()}${t.slice(1)}`];return Array.isArray(r)?r[0]:r},Ls=e=>{let t=`${e??""}`.replace(/[^0-9]/g,"");return t.length<8?"":t.slice(0,8)},Ll=e=>{let[t="",r=""]=`${e??""}`.split("."),n=t.replace(/[^0-9]/g,"").slice(0,6);if(!n)return"";let a=r.replace(/[^0-9]/g,"").slice(0,6);return`${n.padEnd(6,"0")}.${a.padEnd(6,"0")}`};function Ld(e){let t=Array.isArray(e)?e:[e],r="",n="",a="",i="",o=(e,t)=>{let o=Ls(e);if(!o||o<a)return;o>a&&(a=o,r=`${e}`,i="",n="");let s=Ll(t);s>i&&(i=s,n=`${t}`)};for(let e of t)if(e){for(let[t,r]of Lt)o(Lo(e,t),Lo(e,r));for(let t of Lr){let r=function(e){let t=La.exec(`${e??""}`.trim());if(!t)return;let[,r,n="",a="",i=""]=t,o=Ln(i);if(void 0===o)return{SeriesDate:r,SeriesTime:`${n}${a}`};let s=Number(n.slice(0,2)||0),l=Number(n.slice(2,4)||0),d=new Date(0);d.setUTCFullYear(Number(r.slice(0,4)),Number(r.slice(4,6))-1,Number(r.slice(6,8))),d.setUTCHours(s,l-o,0,0);let u=d,[c,h,p,m,f]=[u.getFullYear(),u.getMonth()+1,u.getDate(),u.getHours(),u.getMinutes()];return{SeriesDate:`${c}${Li(h)}${Li(p)}`,SeriesTime:`${Li(m)}${Li(f)}${n.slice(4,6)}${a}`}}(Lo(e,t));r&&o(r.SeriesDate,r.SeriesTime)}}return{SeriesDate:r,SeriesTime:n}}function Lu(e,t){let r=Ls(e);return r?`${r} ${Ll(t)}`:""}function Lc(e){let{SeriesDate:t,SeriesTime:r}=Ld(e);return Lu(t,r)}let Lh=(e,t)=>e==t?0:!e&&t?-1:!t&&e?1:e<t?-1:1,Lp=new Map,Lm=(e,t)=>{let{compareSameSeries:r="default"}=e,{compareSameSeries:n="default"}=t,a=Lp.get(r),i=Lp.get(n);if(a&&i){let r=a===i?a.compare(e,t):Lh(a.priority,i.priority);if(r)return r}return Lb(e.instance,t.instance)},Lf=(e,t)=>Lh(e.SeriesInstanceUID,t.SeriesInstanceUID)||Lm(e,t),Lg=e=>Lu(e.seriesDate??e.SeriesDate,e.seriesTime??e.SeriesTime),Ly=(e,t)=>Lh(Lg(e),Lg(t))||Lf(e,t);function Lv(e,t){let r=R3(e.Modality??e.modality),n=R3(t.Modality??t.modality);return r?n?Ly(t,e):1:n?-1:Lh(e.SeriesNumber??e.seriesNumber,t.SeriesNumber??t.seriesNumber)||Ly(e,t)}let Lb=(e,t)=>{if(!e||!t)return e||t?e?1:-1:0;let r=parseInt(e.InstanceNumber)||0,n=parseInt(t.InstanceNumber)||0;return r!==n?r-n:e.SOPInstanceUID===t.SOPInstanceUID?Lh(e.frameNumber,t.frameNumber):Lh(Lc(e),Lc(t))||Lh(e.SOPInstanceUID,t.SOPInstanceUID)},Lx={RTSTRUCT:["StructureSetDate","StructureSetTime"],PR:["PresentationCreationDate","PresentationCreationTime"]},Lw=e=>{if(!e)return null;for(let t=0;t<e.length;t++)if(-1!==e[t].indexOf(",")){let r=e[t].split(/,/);e.splice(t,1,...r)}return e},LC=(e,t=new URLSearchParams(window.location.search))=>{let r=[...t.keys()].find(t=>t.toLowerCase()===e);if(r)return Lw(t.getAll(r))},Lk=(0,tC.createContext)(null),{Provider:LM}=Lk;function LS(e){if(e)return t=>e.includes(t.referenceSeriesUID)}function LI(e){return t=>t.referenceStudyUID==e}function LT(e){return e?.referencedImageId}function L_(e){return t=>t.metadata?.toolName===e}function LP(e){return!0}function LE(e){return!1}function LD(...e){return function(t){for(let r of e)if(!r||("string"==typeof r&&(r=this[r]),"function"==typeof r&&r.call(this,t)))return!0;return!1}}let{POINT:LA}=NI.VALUE_TYPES;function LO(e){return e.type===LA&&e.referencedImageId}function LN(e,t){return r=>!e(r)&&t(r)}let LR=e=>"string"==typeof e||e instanceof String;function LL(...e){let t=e.filter(e=>!!e);if(t.length)return 1===t.length&&"function"==typeof t[0]?t[0]:function(e){for(let r of t)if(LR(r)){if(!this[r](e))return!1}else if(!r.call(this,e))return!1;return!0}}let Lj=e=>{let t=new URLSearchParams(window.location.search),r=LC("initialseriesinstanceuid",t),n=LC("initialsopinstanceuid",t);if(!r&&!n)return!1;let a=r?.some(t=>e.SeriesInstanceUID===t),i=n?.some(t=>e.instances?.some(e=>t===e.SOPInstanceUID));return a||i};function LV(e){let t=e?.[0];if(!t)return;let r=LC("initialsopinstanceuid");if(!r)return;let n=t.instances.findIndex(e=>r.includes(e.SOPInstanceUID));return -1===n?void 0:{index:n}}let LF=(e,t)=>{let r=t?.displaySets?.filter(e=>e.numImageFrames>0)?.length;return console.log("number of display sets with images",r),r},LB=(e,t)=>t?.displaySets?.map(e=>e.SeriesDescription),LW={toolGroupId:"default",viewportType:"stack"};class LU extends Ns{constructor(e,t){super(LU.EVENTS),this.studies=void 0,this.protocols=void 0,this.activeProtocolIds=void 0,this.protocol=void 0,this._originalProtocol=void 0,this.stageIndex=0,this._commandsManager=void 0,this._servicesManager=void 0,this.protocolEngine=void 0,this.customViewportSettings=[],this.displaySets=[],this.activeStudy=void 0,this.debugLogging=void 0,this.customAttributeRetrievalCallbacks={NumberOfStudyRelatedSeries:{name:"The number of series in the study",callback:e=>e.NumberOfStudyRelatedSeries??e.series?.length},NumberOfSeriesRelatedInstances:{name:"The number of instances in the display set",callback:e=>e.numImageFrames},ModalitiesInStudy:{name:"Gets the array of the modalities for the series",callback:e=>{if(e.ModalitiesInStudy?.length>0)return e.ModalitiesInStudy;if(Array.isArray(e.series)){var t,r;return t=e.series,r="Modality",t.reduce((e,t)=>{let n=t[r];return!n&&t.instances&&t.instances[0]&&(n=t.instances[0][r]),n&&-1===e.indexOf(n)&&e.push(n),e},[])}return[]}},isReconstructable:{name:"Checks if the display set is reconstructable",callback:e=>e.isReconstructable??!1},isDisplaySetFromUrl:{name:"Checks if the display set is as specified in the URL",callback:Lj},sopInstanceLocation:{name:"Gets the position of the specified sop instance",callback:LV},seriesDescriptions:{name:"seriesDescriptions",description:"List of Series Descriptions",callback:LB},numberOfDisplaySetsWithImages:{name:"numberOfDisplaySetsWithImages",description:"Number of displays sets with images",callback:LF}},this.listeners={},this.registeredImageLoadStrategies={},this.activeImageLoadStrategyName=null,this.customImageLoadPerformed=!1,this.displaySetMatchDetails=new Map,this.viewportMatchDetails=new Map,this._commandsManager=e,this._servicesManager=t,this.protocols=new Map,this.protocolEngine=void 0,this.protocol=void 0,this.stageIndex=void 0,this.studies=[]}destroy(){this.reset(),this.protocols=new Map}reset(){this.studies=[],this.viewportMatchDetails=new Map,this.displaySetMatchDetails=new Map,this.protocol=void 0,this.stageIndex=void 0,this.protocolEngine=void 0}onModeEnter(){this.reset()}getActiveProtocol(){return{protocol:this.protocol,_originalProtocol:this._originalProtocol,stage:this.protocol?.stages?.[this.stageIndex],stageIndex:this.stageIndex,activeStudy:this.activeStudy,viewportMatchDetails:this.viewportMatchDetails,displaySetMatchDetails:this.displaySetMatchDetails,activeImageLoadStrategyName:this.activeImageLoadStrategyName}}getState(){if(this.protocol)return{protocolId:this.protocol.id,stageIndex:this.stageIndex,stageId:this.protocol.stages[this.stageIndex].id,activeStudyUID:this.activeStudy?.StudyInstanceUID}}filterSeriesRequiredForRun(e,t){Array.isArray(e)&&(e=e[0]);let r=this.getProtocolById(e)?.hpInitiationCriteria?.minSeriesLoaded||t.length;return{requiredSeries:t.slice(0,r),remaining:t.slice(r)}}getDefaultProtocol(){return this.getProtocolById("default")}getMatchDetails(){return{viewportMatchDetails:this.viewportMatchDetails,displaySetMatchDetails:this.displaySetMatchDetails}}getProtocols(){let e=[];for(let t of this.activeProtocolIds||this.protocols.keys()){let r=this.getProtocolById(t);r&&e.push(r)}return e}getProtocolById(e,t=!0){if(!e)return;if(e===this.protocol?.id)return this.protocol;let r=this.protocols.get(e);if(!r&&t){let t=e.toLowerCase();for(let[e]of this.protocols)if(e.toLowerCase()===t){r=this.getProtocolById(e);break}}if(!r)throw Error(`No protocol ${e} found`);if(!(r instanceof Function))return this._validateProtocol(r);try{let{protocol:e}=this._getProtocolFromGenerator(r);return e}catch(t){console.warn(`Error while executing protocol generator for protocol ${e}: ${t}`)}}addProtocol(e,t){this.protocols.has(e)&&console.warn(`A protocol with id ${e} already exists. It will be overwritten.`),t instanceof Function||(t=this._validateProtocol(t)),this.protocols.set(e,t)}addActiveProtocolId(e){e&&(this.activeProtocolIds||(this.activeProtocolIds=[]),this.activeProtocolIds.push(e))}setActiveProtocolIds(e){if(!e||!e.length){this.activeProtocolIds=null,console.log("No active protocols, setting all to active");return}"string"==typeof e?this.setActiveProtocolIds([e]):this.activeProtocolIds=[...e]}setActiveStudyUID(e){if(e&&e!==this.activeStudy?.StudyInstanceUID)return this.activeStudy=this.studies.find(t=>t.StudyInstanceUID===e),this.activeStudy}hasStudyUID(e){return this.studies.some(t=>t.StudyInstanceUID===e)}addStudy(e){this.hasStudyUID(e.StudyInstanceUID)||this.studies.push(e)}run({studies:e,displaySets:t,activeStudy:r},n,a={}){if(this.studies=[...e||this.studies],this.displaySets=t,this.setActiveStudyUID(r?.StudyInstanceUID||(r||this.studies[0])?.StudyInstanceUID),this.protocolEngine=new RP(this.getProtocols(),this.customAttributeRetrievalCallbacks),this.protocol=null,n&&"string"==typeof n){let e=this.getProtocolById(n);this._setProtocol(e,a)}else{let e=this.protocolEngine.run({studies:this.studies,activeStudy:r,displaySets:t});this._setProtocol(e)}this.protocol?.callbacks?.onProtocolEnter&&this._commandsManager.run(this.protocol?.callbacks?.onProtocolEnter)}hasCustomImageLoadStrategy(){return null!==this.activeImageLoadStrategyName&&this.registeredImageLoadStrategies[this.activeImageLoadStrategyName]instanceof Function}getCustomImageLoadPerformed(){return this.customImageLoadPerformed}getShouldPerformCustomImageLoad(){return this.hasCustomImageLoadStrategy()&&!this.getCustomImageLoadPerformed()}registerImageLoadStrategy(e,t){t instanceof Function&&e&&(this.registeredImageLoadStrategies[e]=t)}addCustomAttribute(e,t,r,n={}){this.customAttributeRetrievalCallbacks[e]={...n,id:e,name:t,callback:r}}runImageLoadStrategy(e){let t=(0,this.registeredImageLoadStrategies[this.activeImageLoadStrategyName])({data:e,displaySetsMatchDetails:this.displaySetMatchDetails,viewportMatchDetails:this.viewportMatchDetails});return t?(this.customImageLoadPerformed=!0,this._broadcastEvent(this.EVENTS.CUSTOM_IMAGE_LOAD_PERFORMED,t),!0):(console.warn("Not able to load data with custom strategy"),!1)}_validateProtocol(e){e.name=e.name??e.id;let{stages:t}=e;if(!t)return void console.warn("Protocol has not stages:",e.id,e);for(let t of Object.keys(e.displaySetSelectors)){let r=e.displaySetSelectors[t];r.id=t;let{seriesMatchingRules:n}=r;if(!n)return void console.warn("Selector has no series matching rules",e.id,t)}return t.forEach(t=>{if(t.viewports)t.viewports=t.viewports.map((r,n)=>{let a=t.defaultViewport||e.defaultViewport||{},i=r.viewportOptions?.viewportId;return{...r,viewportOptions:{...a.viewportOptions,...r.viewportOptions,viewportId:i||(0===n?"default":RE())},displaySets:r.displaySets||[]}}),t.viewports.forEach(e=>{e.displaySets.forEach(e=>{e.options=e.options||{}})});else{t.name=t.name||t.id,t.viewports=[];let{rows:r,columns:n}=t.viewportStructure.properties;for(let a=0;a<r*n;a++){let r=t.defaultViewport||e.defaultViewport||{};t.viewports.push({viewportOptions:{...r.viewportOptions,viewportId:0===a?"default":RE()},displaySets:[]})}}}),e}_getProtocolFromGenerator(e){let{protocol:t}=e({servicesManager:this._servicesManager,commandsManager:this._commandsManager});return{protocol:this._validateProtocol(t)}}getViewportsRequireUpdate(e,t,r=!0){let n,a=[{viewportId:e,displaySetInstanceUIDs:[t]}];if(!r)return a;let{displaySetService:i}=this._servicesManager.services,o=i.getDisplaySetByUID(t);if(o?.unsupported)throw Error("Unsupported displaySet");if(o?.isOverlayDisplaySet)return a;let s=this.protocol,l=s.stages[this.stageIndex].viewports;if(!l)return a;let d=l.find(t=>t.viewportOptions.viewportId===e);if(!d)return a;if(d.displaySets.length>1)throw Error("Cannot update viewport with multiple displaySets yet");if(0===d.displaySets.length||d.viewportOptions.allowUnmatchedView)return a;let{id:u,matchedDisplaySetsIndex:c=0}=d.displaySets[0],h=s.displaySetSelectors[u];if(!h||h.allowUnmatchedView||(this._validateViewportSpecificMatch({displaySetInstanceUIDs:[t],viewportOptions:{},displaySetOptions:[]},d,s.displaySetSelectors),!this.displaySetMatchDetails.get(u)))return a;let p=this._originalProtocol;p instanceof Function||(n=p.stages[this.stageIndex]);let m=[];return l.forEach((e,r)=>{if(e.displaySets.some(e=>e.id===u&&(e.matchedDisplaySetsIndex||0)===c)){if(n){let a=n.viewports[r],i=a.viewportOptions,o=a.displaySets;e.viewportOptions=this.getComputedOptions(i,[t]),e.displaySets=this.getComputedOptions(o,[t])}let a=[],i=[];this._updateDisplaySetInstanceUIDs(e,u,t,this.displaySetMatchDetails,a,i),m.push({viewportId:e.viewportOptions.viewportId,displaySetInstanceUIDs:a,viewportOptions:e.viewportOptions,displaySetOptions:i})}}),m}runMatchingRules(e,t,r){return this.protocolEngine.findMatch(e,t,r)}_updateDisplaySetInstanceUIDs(e,t,r,n,a,i){e.displaySets.forEach(e=>{let{id:o}=e,s=n.get(o),{displaySetInstanceUID:l}=s,d=e.id===t?r:l;s.displaySetInstanceUID=d,a.push(d),i.push(e)})}getComputedOptions(e,t){if(Array.isArray(e))return e.map(e=>this.getComputedOptions(e,t));if(null===e||"object"!=typeof e)return e;if(e.custom){let r=this.displaySets.filter(e=>t.includes(e.displaySetInstanceUID)),n=e.custom;if(!(n in this.customAttributeRetrievalCallbacks))throw Error(`Custom key "${n}" not found in customAttributeRetrievalCallbacks.`);let a=this.customAttributeRetrievalCallbacks[n].callback.call(e,r);return void 0===a&&(a=e.defaultValue),this.getComputedOptions(a,t)}let r={};for(let n in e)void 0!==e[n]&&(r[n]=this.getComputedOptions(e[n],t));return r}setProtocol(e,t={},r=null){let n=this.protocols.get(e);if(!n)return void console.warn(`ProtocolEngine::setProtocol - Protocol with id ${e} not found - you should register it first via addProtocol`);try{let e=this._validateProtocol(n);t&&this._validateOptions(t),this._setProtocol(e,t)}catch(e){throw console.log(e),r&&r(e),Error(e)}this._commandsManager.run(this.protocol?.callbacks?.onProtocolEnter)}matchActivation(e,t={},r){let{displaySetSelectors:n}=this.protocol,{displaySetSelectorsMatched:a=[]}=t;for(let e of a){let t=n[e];if(!t)return console.warn("No display set selector for",e),!1;let{bestMatch:r}=this._matchImages(t);if(!r)return!1}return e>=(t.minViewportsMatched??r)}_updateStageStatus(e=null){let t=this.protocol.stages;for(let r=0;r<t.length;r++){let n=t[r],{matchedViewports:a}=this._matchAllViewports(n,e,new Map),i=n.stageActivation||{};this.matchActivation(a,i.passive,0)?this.matchActivation(a,i.enabled,1)?n.status="enabled":n.status="passive":n.status="disabled"}this._broadcastEvent(this.EVENTS.STAGE_ACTIVATION,{protocol:this.protocol,stages:this.protocol.stages})}_findStageIndex(e=null){let t,r=e?.stageId,n=this.protocol.stages;if(r){for(let e=0;e<n.length;e++){let t=n[e];if(t.id===r&&"disabled"!==t.status)return e}return}let a=e?.stageIndex;if(void 0!==a)return n[a]?.status!=="disabled"?a:void 0;for(let e=0;e<n.length;e++){if("enabled"===n[e].status)return e;void 0===t&&"disabled"!==n[e].status&&(t=e)}return t}_setProtocol(e,t=null){let r=this.getActiveProtocol();try{if(!this.protocol||this.protocol.id!==e.id){this.stageIndex=t?.stageIndex||0,this.customImageLoadPerformed=!1,this._originalProtocol=this._copyProtocol(e),this.protocol?.callbacks?.onProtocolExit&&this._commandsManager.run(this.protocol.callbacks.onProtocolExit),this.protocol=e;let{imageLoadStrategy:r}=e;r?this.registeredImageLoadStrategies[r]instanceof Function&&(this.activeImageLoadStrategyName=r):this.activeImageLoadStrategyName=null,this._updateStageStatus(t)}let r=this._findStageIndex(t);if(void 0===r)throw Error(`Can't find applicable stage ${e.id} ${t?.stageIndex}`);this.stageIndex=r,this.protocol?.callbacks?.onStageChange&&this._commandsManager.run(this.protocol.callbacks.onStageChange),this._updateViewports(t)}catch(e){throw console.log(e),Object.assign(this,r),Error(e)}t?.restoreProtocol!==!0?this._broadcastEvent(LU.EVENTS.PROTOCOL_CHANGED,{viewportMatchDetails:this.viewportMatchDetails,displaySetMatchDetails:this.displaySetMatchDetails,protocol:this.protocol,stageIdx:this.stageIndex,stage:this.protocol.stages[this.stageIndex],activeStudyUID:this.activeStudy?.StudyInstanceUID}):this._broadcastEvent(LU.EVENTS.PROTOCOL_RESTORED,{protocol:this.protocol,stageIdx:this.stageIndex,stage:this.protocol.stages[this.stageIndex],activeStudyUID:this.activeStudy?.StudyInstanceUID})}getStageIndex(e,t){let r=this.getProtocolById(e),{stageId:n,stageIndex:a}=t;return void 0!==n?r.stages.findIndex(e=>e.id===n):void 0!==a?a:0}_getNumProtocolStages(){if(this.protocol&&this.protocol.stages&&this.protocol.stages.length)return this.protocol.stages.length}_getCurrentStageModel(){return this.protocol.stages[this.stageIndex]}getMissingViewport(e,t,r){this.protocol.id!==e&&(console.warn("setting protocol"),this.protocol=this.getProtocolById(e),this.stageIndex=0);let n=this.protocol,a=(n.stages[t]??n.stages[this.stageIndex]).defaultViewport||n.defaultViewport;if(!a)return;let i={...a};return this._matchViewport(i,r)}getDisplaySetSortFunction(){return(e,t)=>{let r=this._getSeriesSortInfoForDisplaySetSort(e),n=this._getSeriesSortInfoForDisplaySetSort(t);return NK(this._getSeriesFieldForDisplaySetSort())(r,n)}}_updateViewports(e=null){if(!this._getNumProtocolStages())throw Error("No protocol or stages found");this.viewportMatchDetails=new Map,this.displaySetMatchDetails=new Map;let t=this._getCurrentStageModel();if(!t||!t.viewportStructure||!t.viewports||!t.viewports.length)return void console.log("Stage cannot be applied",t);let{layoutType:r}=t.viewportStructure,n=t.viewportStructure.properties;if(!n)return void console.log("No viewportStructure.properties in",t);let{columns:a,rows:i,layoutOptions:o=[]}=n;this.protocol?.callbacks?.onViewportDataInitialized&&this._commandsManager.runCommand("attachProtocolViewportDataListener",{protocol:this.protocol,stageIndex:this.stageIndex}),this._broadcastEvent(this.EVENTS.NEW_LAYOUT,{layoutType:r,numRows:i,numCols:a,layoutOptions:o}),this._matchAllViewports(this.protocol.stages[this.stageIndex],e)}_matchAllViewports(e,t,r=this.viewportMatchDetails,n=this.displaySetMatchDetails){this.activeStudy||=this.studies[0];let a=0;return e.viewports.forEach(e=>{let i=e.viewportOptions.viewportId,o=this._matchViewport(e,t,r,n);o&&(o.displaySetsInfo?.length&&o.displaySetsInfo[0].displaySetInstanceUID?a++:(console.log("Adding an empty set of display sets for mapping purposes"),o.displaySetsInfo=e.displaySets.map(e=>({displaySetOptions:e}))),r.set(i,o))}),{matchedViewports:a,viewportMatchDetails:r,displaySetMatchDetails:n}}findDeduplicatedMatchDetails(e,t,r={}){if(!e)return;if(0===t)return e;let{matchingScores:n=[]}=e;if(-1===t){let{inDisplay:t}=r;if(!t)return e;for(let r=0;r<e.matchingScores.length;r++)if(-1===t.indexOf(e.matchingScores[r].displaySetInstanceUID))return e.matchingScores[r].matchingScore>0?{matchingScores:n,...e.matchingScores[r]}:null;return}let a=n[t];return a?{...a,matchingScores:n}:void 0}validateDisplaySetSelectMatch(e,t,r){if(e.displaySetInstanceUID!==r){if(!e.matchingScores)throw Error("No matchingScores found in "+e);for(let t of e.matchingScores)if(t.displaySetInstanceUID===r)return;throw Error(`Reused viewport details ${t} with ds ${r} not valid`)}}_matchViewport(e,t,r=this.viewportMatchDetails,n=this.displaySetMatchDetails){let a=t?.displaySetSelectorMap||{},{displaySetSelectors:i={}}=this.protocol;for(let t of e.displaySets){let{id:e}=t,r=i[e];if(!r){console.warn("No display set selector for",e);continue}let{bestMatch:a,matchingScores:o}=this._matchImages(r);n.set(e,a),a&&(a.matchingScores=o)}let{viewportOptions:o=LW}=e,s=[],{StudyInstanceUID:l}=this.activeStudy;return e.displaySets.forEach(e=>{let{id:r,matchedDisplaySetsIndex:n=0}=e,i=r&&a[`${l}:${r}:${n||0}`],o=this.displaySetMatchDetails.get(r),d=this.findDeduplicatedMatchDetails(o,n,t);if(i)return void i.forEach(t=>{s.push({displaySetInstanceUID:t,displaySetOptions:e})});if(d){let{displaySetInstanceUID:t}=d;s.push({displaySetInstanceUID:t,displaySetOptions:e})}else console.warn(`
7
7
  The hanging protocol viewport is requesting to display ${r} displaySet that is not
8
8
  matched based on the provided criteria (e.g. matching rules).
9
- `)}),{viewportOptions:o,displaySetsInfo:s}}_validateViewportSpecificMatch(e,t,r){let{displaySetService:n}=this._servicesManager.services,a=t.displaySets,i=e.displaySetInstanceUIDs.length;if(a.length>0&&i!==a.length)throw Error(`The number of displaySets to set ${i} does not match the number of displaySets in the protocol ${a} - not currently implemented`);e.displaySetInstanceUIDs.forEach(e=>{let a=n.getDisplaySetByUID(e),{displaySets:i}=t;for(let e of i){let t=r[e.id];t&&this._validateRequiredSelectors(t,a)}})}areRequiredSelectorsValid(e,t){let r=!0;for(let n of e)try{this._validateRequiredSelectors(n,t)}catch(e){r=!1;break}return r}_validateRequiredSelectors(e,t){let{seriesMatchingRules:r}=e,n=r.filter(e=>e.required);if(n.length){let e=this.protocolEngine.findMatch(t,n);if(!e||0===e.score)throw Error(`The displaySetInstanceUID ${t.displaySetInstanceUID} does not satisfy the required seriesMatching criteria for the protocol`)}}_validateOptions(e){let{displaySetService:t}=this._servicesManager.services,{displaySetSelectorMap:r}=e;r&&Object.entries(r).forEach(([e,r])=>{r.forEach(e=>{if(!t.getDisplaySetByUID(e))throw Error(`The displaySetInstanceUID ${e} is not found in the displaySetService`)})})}_matchImages(e){let{id:t,studyMatchingRules:r=[],seriesMatchingRules:n}=e,a=[],i=0;console.log("ProtocolEngine::matchImages",r,n);let o=-1===this.protocol.numberOfPriorsReferenced;this.studies.forEach((e,t)=>{if(o&&this.activeStudy!==e)return;let s=this.displaySets.filter(t=>t.StudyInstanceUID===e.StudyInstanceUID&&!t?.unsupported),l=this.protocolEngine.findMatch(e,r,{studies:this.studies,displaySets:s,allDisplaySets:this.displaySets,displaySetMatchDetails:this.displaySetMatchDetails,studyInstanceUIDsIndex:t});!0!==l.requiredFailed&&(this.debug("study",e.StudyInstanceUID,"display sets #",s.length),s.forEach(t=>{let{StudyInstanceUID:r,SeriesInstanceUID:o,displaySetInstanceUID:d}=t,u=this.protocolEngine.findMatch(t,n,{studies:this.studies,instance:t.images?.[0],displaySetMatchDetails:this.displaySetMatchDetails,displaySets:s});if(!0===u.requiredFailed)return void this.debug("Display set required failed",t,n);this.debug("Found displaySet for rules",t),i=Math.max(u.score,i);let c={passed:[],failed:[]};c.passed=c.passed.concat(u.details.passed),c.passed=c.passed.concat(l.details.passed),c.failed=c.failed.concat(u.details.failed),c.failed=c.failed.concat(l.details.failed);let h=u.score+l.score,p={StudyInstanceUID:r,SeriesInstanceUID:o,displaySetInstanceUID:d,matchingScore:h,matchDetails:c,sortingInfo:{score:h,study:e.StudyInstanceUID,...this._getSeriesSortInfoForDisplaySetSort(t)}};this.debug("Adding display set",t,p),a.push(p)}))}),0===a.length&&console.log("No match found",t);let s=NK({name:"score",reverse:!0},{name:"study",reverse:!0},this._getSeriesFieldForDisplaySetSort());a.sort((e,t)=>s(e.sortingInfo,t.sortingInfo));let l=a[0];return console.log("ProtocolEngine::matchImages bestMatch",l,a),{bestMatch:l,matchingScores:a}}_getSeriesSortInfoForDisplaySetSort(e){return{[this._getSeriesFieldForDisplaySetSort().name]:null!=e.SeriesNumber?parseInt(e.SeriesNumber):parseInt(e.seriesNumber)}}_getSeriesFieldForDisplaySetSort(){return{name:"series"}}_isNextStageAvailable(){let e=this._getNumProtocolStages();return this.stageIndex+1<e}_isPreviousStageAvailable(){return this.stageIndex-1>=0}_setCurrentProtocolStage(e,t){let r;for(r=this.stageIndex+e;r>=0&&r<this.protocol.stages.length&&"disabled"===this.protocol.stages[r].status;r+=e);return!(r<0)&&!(r>=this.protocol.stages.length)&&(this.stageIndex=r,this.debug(`ProtocolEngine::setCurrentProtocolStage stage = ${this.stageIndex}`),this._updateViewports(t),this._broadcastEvent(this.EVENTS.PROTOCOL_CHANGED,{viewportMatchDetails:this.viewportMatchDetails,displaySetMatchDetails:this.displaySetMatchDetails,protocol:this.protocol,stageIdx:this.stageIndex,stage:this.protocol.stages[this.stageIndex]}),!0)}debug(...e){this.debugLogging&&console.log(...e)}_copyProtocol(e){return N$()(e)}}LU.EVENTS={PROTOCOL_CHANGED:"event::hanging_protocol_changed",PROTOCOL_RESTORED:"event::hanging_protocol_restore",NEW_LAYOUT:"event::hanging_protocol_new_layout",STAGE_ACTIVATION:"event::hanging_protocol_stage_activation",CUSTOM_IMAGE_LOAD_PERFORMED:"event::hanging_protocol_custom_image_load_performed"},LU.REGISTRATION={name:"hangingProtocolService",altName:"HangingProtocolService",create:({configuration:e={},commandsManager:t,servicesManager:r})=>new LU(t,r)};class Lz extends Ns{constructor(){super(Lz.EVENTS),this.serviceImplementation={_getState:()=>console.warn("getState() NOT IMPLEMENTED"),_setUser:()=>console.warn("_setUser() NOT IMPLEMENTED"),_getUser:()=>console.warn("_getUser() NOT IMPLEMENTED"),_getAuthorizationHeader:()=>{},_handleUnauthenticated:()=>console.warn("_handleUnauthenticated() NOT IMPLEMENTED"),_reset:()=>console.warn("reset() NOT IMPLEMENTED"),_set:()=>console.warn("set() NOT IMPLEMENTED")},this.serviceImplementation={...this.serviceImplementation}}getState(){return this.serviceImplementation._getState()}setUser(e){return this.serviceImplementation._setUser(e)}getUser(){return this.serviceImplementation._getUser()}getAuthorizationHeader(){return this.serviceImplementation._getAuthorizationHeader()}handleUnauthenticated(){return this.serviceImplementation._handleUnauthenticated()}reset(){return this.serviceImplementation._reset()}set(e){return this.serviceImplementation._set(e)}setServiceImplementation({getState:e,setUser:t,getUser:r,getAuthorizationHeader:n,handleUnauthenticated:a,reset:i,set:o}){e&&(this.serviceImplementation._getState=e),t&&(this.serviceImplementation._setUser=t),r&&(this.serviceImplementation._getUser=r),n&&(this.serviceImplementation._getAuthorizationHeader=n),a&&(this.serviceImplementation._handleUnauthenticated=a),i&&(this.serviceImplementation._reset=i),o&&(this.serviceImplementation._set=o)}}Lz.EVENTS={},Lz.REGISTRATION={name:"userAuthenticationService",altName:"UserAuthenticationService",create:({configuration:e={}})=>new Lz};var LH=d(1752),LG=d.n(LH),Lq=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,L$=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,LK=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,LY=e=>"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||"$"===e||"_"===e||L$.test(e)),LX=e=>"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||"$"===e||"_"===e||"‌"===e||"‍"===e||LK.test(e)),LZ=e=>"string"==typeof e&&/[0-9]/.test(e),LJ=e=>"string"==typeof e&&/[0-9A-Fa-f]/.test(e);function LQ(){if(n[o])return String.fromCodePoint(n.codePointAt(o))}function L0(){let e=LQ();return"\n"===e?(s++,l=0):e?l+=e.length:l++,e&&(o+=e.length),e}let L1={default(){let e;switch(v){case" ":case"\v":case"\f":case" ":case" ":case"\uFEFF":case"\n":case"\r":case"\u2028":case"\u2029":L0();return;case"/":L0(),m="comment";return;case void 0:return L0(),L2("eof")}return"string"==typeof(e=v)&&Lq.test(e)?void L0():L1[a]()},comment(){switch(v){case"*":L0(),m="multiLineComment";return;case"/":L0(),m="singleLineComment";return}throw L9(L0())},multiLineComment(){switch(v){case"*":L0(),m="multiLineCommentAsterisk";return;case void 0:throw L9(L0())}L0()},multiLineCommentAsterisk(){switch(v){case"*":L0();return;case"/":L0(),m="default";return;case void 0:throw L9(L0())}L0(),m="multiLineComment"},singleLineComment(){switch(v){case"\n":case"\r":case"\u2028":case"\u2029":L0(),m="default";return;case void 0:return L0(),L2("eof")}L0()},value(){switch(v){case"{":case"[":return L2("punctuator",L0());case"n":return L0(),L5("ull"),L2("null",null);case"t":return L0(),L5("rue"),L2("boolean",!0);case"f":return L0(),L5("alse"),L2("boolean",!1);case"-":case"+":"-"===L0()&&(y=-1),m="sign";return;case".":f=L0(),m="decimalPointLeading";return;case"0":f=L0(),m="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":f=L0(),m="decimalInteger";return;case"I":return L0(),L5("nfinity"),L2("numeric",1/0);case"N":return L0(),L5("aN"),L2("numeric",NaN);case'"':case"'":g='"'===L0(),f="",m="string";return}throw L9(L0())},identifierNameStartEscape(){if("u"!==v)throw L9(L0());L0();let e=L3();switch(e){case"$":case"_":break;default:if(!LY(e))throw je()}f+=e,m="identifierName"},identifierName(){switch(v){case"$":case"_":case"‌":case"‍":f+=L0();return;case"\\":L0(),m="identifierNameEscape";return}if(LX(v)){f+=L0();return}return L2("identifier",f)},identifierNameEscape(){if("u"!==v)throw L9(L0());L0();let e=L3();switch(e){case"$":case"_":case"‌":case"‍":break;default:if(!LX(e))throw je()}f+=e,m="identifierName"},sign(){switch(v){case".":f=L0(),m="decimalPointLeading";return;case"0":f=L0(),m="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":f=L0(),m="decimalInteger";return;case"I":return L0(),L5("nfinity"),L2("numeric",1/0*y);case"N":return L0(),L5("aN"),L2("numeric",NaN)}throw L9(L0())},zero(){switch(v){case".":f+=L0(),m="decimalPoint";return;case"e":case"E":f+=L0(),m="decimalExponent";return;case"x":case"X":f+=L0(),m="hexadecimal";return}return L2("numeric",0*y)},decimalInteger(){switch(v){case".":f+=L0(),m="decimalPoint";return;case"e":case"E":f+=L0(),m="decimalExponent";return}if(LZ(v)){f+=L0();return}return L2("numeric",y*Number(f))},decimalPointLeading(){if(LZ(v)){f+=L0(),m="decimalFraction";return}throw L9(L0())},decimalPoint(){switch(v){case"e":case"E":f+=L0(),m="decimalExponent";return}if(LZ(v)){f+=L0(),m="decimalFraction";return}return L2("numeric",y*Number(f))},decimalFraction(){switch(v){case"e":case"E":f+=L0(),m="decimalExponent";return}if(LZ(v)){f+=L0();return}return L2("numeric",y*Number(f))},decimalExponent(){switch(v){case"+":case"-":f+=L0(),m="decimalExponentSign";return}if(LZ(v)){f+=L0(),m="decimalExponentInteger";return}throw L9(L0())},decimalExponentSign(){if(LZ(v)){f+=L0(),m="decimalExponentInteger";return}throw L9(L0())},decimalExponentInteger(){if(LZ(v)){f+=L0();return}return L2("numeric",y*Number(f))},hexadecimal(){if(LJ(v)){f+=L0(),m="hexadecimalInteger";return}throw L9(L0())},hexadecimalInteger(){if(LJ(v)){f+=L0();return}return L2("numeric",y*Number(f))},string(){switch(v){case"\\":L0(),f+=function(){switch(LQ()){case"b":return L0(),"\b";case"f":return L0(),"\f";case"n":return L0(),"\n";case"r":return L0(),"\r";case"t":return L0()," ";case"v":return L0(),"\v";case"0":if(L0(),LZ(LQ()))throw L9(L0());return"\0";case"x":return L0(),function(){let e="",t=LQ();if(!LJ(t)||(e+=L0(),!LJ(t=LQ())))throw L9(L0());return String.fromCodePoint(parseInt(e+=L0(),16))}();case"u":return L0(),L3();case"\n":case"\u2028":case"\u2029":return L0(),"";case"\r":return L0(),"\n"===LQ()&&L0(),"";case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case void 0:throw L9(L0())}return L0()}();return;case'"':if(g)return L0(),L2("string",f);f+=L0();return;case"'":if(!g)return L0(),L2("string",f);f+=L0();return;case"\n":case"\r":case void 0:throw L9(L0());case"\u2028":case"\u2029":var e;e=v,console.warn(`JSON5: '${jt(e)}' in strings is not valid ECMAScript; consider escaping`)}f+=L0()},start(){switch(v){case"{":case"[":return L2("punctuator",L0())}m="value"},beforePropertyName(){switch(v){case"$":case"_":f=L0(),m="identifierName";return;case"\\":L0(),m="identifierNameStartEscape";return;case"}":return L2("punctuator",L0());case'"':case"'":g='"'===L0(),m="string";return}if(LY(v)){f+=L0(),m="identifierName";return}throw L9(L0())},afterPropertyName(){if(":"===v)return L2("punctuator",L0());throw L9(L0())},beforePropertyValue(){m="value"},afterPropertyValue(){switch(v){case",":case"}":return L2("punctuator",L0())}throw L9(L0())},beforeArrayValue(){if("]"===v)return L2("punctuator",L0());m="value"},afterArrayValue(){switch(v){case",":case"]":return L2("punctuator",L0())}throw L9(L0())},end(){throw L9(L0())}};function L2(e,t){return{type:e,value:t,line:s,column:l}}function L5(e){for(let t of e){if(LQ()!==t)throw L9(L0());L0()}}function L3(){let e="",t=4;for(;t-- >0;){if(!LJ(LQ()))throw L9(L0());e+=L0()}return String.fromCodePoint(parseInt(e,16))}let L4={start(){if("eof"===c.type)throw L7();L8()},beforePropertyName(){switch(c.type){case"identifier":case"string":h=c.value,a="afterPropertyName";return;case"punctuator":L6();return;case"eof":throw L7()}},afterPropertyName(){if("eof"===c.type)throw L7();a="beforePropertyValue"},beforePropertyValue(){if("eof"===c.type)throw L7();L8()},beforeArrayValue(){if("eof"===c.type)throw L7();"punctuator"===c.type&&"]"===c.value?L6():L8()},afterPropertyValue(){if("eof"===c.type)throw L7();switch(c.value){case",":a="beforePropertyName";return;case"}":L6()}},afterArrayValue(){if("eof"===c.type)throw L7();switch(c.value){case",":a="beforeArrayValue";return;case"]":L6()}},end(){}};function L8(){let e;switch(c.type){case"punctuator":switch(c.value){case"{":e={};break;case"[":e=[]}break;case"null":case"boolean":case"numeric":case"string":e=c.value}if(void 0===p)p=e;else{let t=i[i.length-1];Array.isArray(t)?t.push(e):Object.defineProperty(t,h,{value:e,writable:!0,enumerable:!0,configurable:!0})}if(null!==e&&"object"==typeof e)i.push(e),a=Array.isArray(e)?"beforeArrayValue":"beforePropertyName";else{let e=i[i.length-1];a=null==e?"end":Array.isArray(e)?"afterArrayValue":"afterPropertyValue"}}function L6(){i.pop();let e=i[i.length-1];a=null==e?"end":Array.isArray(e)?"afterArrayValue":"afterPropertyValue"}function L9(e){return void 0===e?jr(`JSON5: invalid end of input at ${s}:${l}`):jr(`JSON5: invalid character '${jt(e)}' at ${s}:${l}`)}function L7(){return jr(`JSON5: invalid end of input at ${s}:${l}`)}function je(){return l-=5,jr(`JSON5: invalid identifier character at ${s}:${l}`)}function jt(e){let t={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(t[e])return t[e];if(e<" "){let t=e.charCodeAt(0).toString(16);return"\\x"+("00"+t).substring(t.length)}return e}function jr(e){let t=SyntaxError(e);return t.lineNumber=s,t.columnNumber=l,t}let jn=function(e,t){n=String(e),a="start",i=[],o=0,s=1,l=0,c=void 0,h=void 0,p=void 0;do c=function(){for(m="default",f="",g=!1,y=1;;){v=LQ();let e=L1[m]();if(e)return e}}(),L4[a]();while("eof"!==c.type)return"function"==typeof t?function e(t,r,n){let a=t[r];if(null!=a&&"object"==typeof a)if(Array.isArray(a))for(let t=0;t<a.length;t++){let r=String(t),i=e(a,r,n);void 0===i?delete a[r]:Object.defineProperty(a,r,{value:i,writable:!0,enumerable:!0,configurable:!0})}else for(let t in a){let r=e(a,t,n);void 0===r?delete a[t]:Object.defineProperty(a,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}return n.call(t,r,a)}({"":p},"",t):p},ja="default",ji={prefixes:{}};function jo(e){if(!e||"object"!=typeof e)return null;let t=js(e.bootstrap),r=js(e.global),n=e.mode&&"object"==typeof e.mode&&!Array.isArray(e.mode),a="string"==typeof e.requires||Array.isArray(e.requires)&&e.requires.length>0;return t||r||n||a?{...t?{bootstrap:e.bootstrap}:{},...r?{global:e.global}:{},...n?{mode:e.mode}:{},...a?{requires:e.requires}:{}}:null}function js(e){return Array.isArray(e)?e.length>0:!!e&&"object"==typeof e}let jl=/^([a-z][a-z0-9+.-]*:|\/\/)/i;function jd(e,t="customization"){let r=[];for(let n of Array.from(new Set(e.keys())))if(n.toLowerCase()===t.toLowerCase()){for(let t of e.getAll(n))if(t)for(let e of t.split(",")){let t=e.trim();t&&r.push(t)}}return r}function ju(e,t){let r={valid:[],rejected:[]},n=t.prefixes||{};for(let t of e){let e=function(e){let t=e;for(let e=0;e<5;e++){let e;if(!t.includes("%"))return t;try{e=decodeURIComponent(t)}catch{break}if(e===t)break;t=e}return null}(t);if(null===e){r.rejected.push({raw:t,reason:"contains malformed or unsupported percent-encoding"});continue}if(e.includes("..")){r.rejected.push({raw:t,reason:'contains ".." traversal segment'});continue}if(jl.test(e)){r.rejected.push({raw:t,reason:"full URLs are not permitted"});continue}let a=function(e){if(!e)return null;if(!e.startsWith("/"))return{prefix:ja,name:e};let t=e.slice(1),r=t.indexOf("/");if(r<=0)return null;let n=t.slice(0,r),a=t.slice(r+1);return n&&a?{prefix:`/${n}/`,name:a}:null}(e.trim());if(!a){r.rejected.push({raw:t,reason:"could not be split into a prefix and name"});continue}let{prefix:i,name:o}=a;if(!Object.prototype.hasOwnProperty.call(n,i)){r.rejected.push({raw:t,reason:`unknown prefix "${i}"`});continue}if(!o.trim()||o.split("/").some(e=>!e||"."===e||".."===e||e.includes(".."))){r.rejected.push({raw:t,reason:"invalid or unsafe customization name"});continue}r.valid.push({raw:t,normalized:i===ja?`/${ja}/${o}`:`${i}${o}`,prefix:i,name:o})}return r}let jc=/^([a-z][a-z0-9+.-]*:|\/\/)/i,jh="https://ohif.invalid";function jp(e,t,r){let n,a;try{n=new URL(e,jh),a=new URL(t,jh)}catch{throw Error(`Customization URL could not be parsed for "${r.raw}"`)}let i=a.pathname.endsWith("/")?a.pathname:`${a.pathname}/`;if(!(n.origin===a.origin&&n.pathname.startsWith(i)))throw Error(`Customization "${r.raw}" escapes its configured prefix directory`)}let jm={MODE_CUSTOMIZATION_MODIFIED:"event::CustomizationService:modeModified",GLOBAL_CUSTOMIZATION_MODIFIED:"event::CustomizationService:globalModified",DEFAULT_CUSTOMIZATION_MODIFIED:"event::CustomizationService:defaultModified"},jf=((eIY={}).Global="global",eIY.Mode="mode",eIY.Default="default",eIY);class jg extends Ns{constructor({configuration:e,commandsManager:t}){super(jm),this.Scope=jf,this.commandsManager=void 0,this.extensionManager=void 0,this.globalCustomizations=new Map,this.modeCustomizations=new Map,this.defaultCustomizations=new Map,this.transformedCustomizations=new Map,this.configuration=void 0,this._urlCustomizationLoaded=new Map,this._urlCustomizationPending=new Map,this._resolvedUrlModules=[],this._customizationConfig=null,this._currentModeIds=[],this._extensionCustomizationModuleApplied=new Set,this.configuration=e,this.commandsManager=t}init(e){this.extensionManager=e,this.modeCustomizations.clear(),this.extensionManager.getRegisteredExtensionIds().forEach(e=>{let t=`${e}.customizationModule.default`;if(!this._extensionCustomizationModuleApplied.has(t)){let e=this._findExtensionValue(t);if(e){let{value:r}=e;this._addReference(r,jf.Default),this._extensionCustomizationModuleApplied.add(t)}}let r=`${e}.customizationModule.global`;if(!this._extensionCustomizationModuleApplied.has(r)){let e=this._findExtensionValue(r);if(e){let{value:t}=e;this._addReference(t,jf.Global),this._extensionCustomizationModuleApplied.add(r)}}});let t=this._getCustomizationConfig();void 0===t.legacyReferences||this.configuration?._hasBeenAdded||(this.addReferences(t.legacyReferences),Object.defineProperty(this.configuration,"_hasBeenAdded",{value:!0,writable:!1})),this._broadcastEvent(this.EVENTS.MODE_CUSTOMIZATION_MODIFIED,{buttons:this.modeCustomizations,button:void 0})}_getCustomizationConfig(){return this._customizationConfig||(this._customizationConfig=function(e){if(!e)return{};if(Array.isArray(e))return{legacyReferences:e};if("object"==typeof e){if(jy.some(t=>t in e)){let t={};for(let r of jy)r in e&&(t[r]=e[r]);return{phased:t}}return{legacyReferences:e}}return{}}(this.configuration)),this._customizationConfig}async applyWindowUrlCustomizations(e){"u">typeof window&&await this.applyCustomizationUrlSearchParams(new URLSearchParams(window.location.search),e)}async applyCustomizationUrlSearchParams(e,t){let r=jd(e);r.length&&await this.requires(r,t)}requires(e,t){return this.loadCustomizationModules(e,t).then(e=>(this._applyLoadedUrlCustomizationModules(e),e))}loadCustomizationModules(e,t){let r,n=t?.policy??((r=this?.extensionManager?.appConfig?.customizationUrlPrefixes)&&"object"==typeof r?{prefixes:r}:ji),a=(Array.isArray(e)?e:[e]).map(e=>String(e).trim()).filter(Boolean);if(!a.length)return Promise.resolve([]);let{valid:i,rejected:o}=ju(a,n),s=t?.logger||console;if(o.length){let e=o.map(e=>`"${e.raw}" (${e.reason})`).join("; ");return Promise.reject(Error(`[customizationUrl] refusing to load customization(s): ${e}. Allowed prefixes are configured in appConfig.customizationUrlPrefixes.`))}if(!i.length)return Promise.resolve([]);let l=t?.importFn??this._urlDefaultImport.bind(this),d=new Set,u=[];return i.reduce((e,t)=>e.then(()=>this._urlCustomizationLoadOne(t,n,l,s,d,u)),Promise.resolve()).then(()=>(this._resolvedUrlModules.push(...u),u))}async loadAndApplyBootstrapCustomizations(e,t){this.extensionManager=e;let r=this._getCustomizationConfig(),n=[],a=r.phased?.requires;"string"==typeof a&&a?n.push(a):Array.isArray(a)&&n.push(...a.filter(e=>"string"==typeof e&&e)),"u">typeof window&&n.push(...jd(new URLSearchParams(window.location.search))),n.length&&await this.loadCustomizationModules(n,t),this.applyBootstrapCustomizations()}applyBootstrapCustomizations(){this._applyPhase("bootstrap")}applyGlobalCustomizations(){this._applyPhase("global")}applyModeCustomizations(e){let t=(Array.isArray(e)?e:[e]).filter(Boolean);this._currentModeIds=t;let r=this._collectPhaseBlocks("mode");for(let e of r){let t=e.mode?.["*"];t&&this.setCustomizations(t,jf.Mode)}for(let e of r)for(let r of t){let t=e.mode?.[r];t&&this.setCustomizations(t,jf.Mode)}}onModeEnter(){this.clearTransformedCustomizations(),this.init(this.extensionManager)}onModeExit(){this.clearTransformedCustomizations()}getCustomization(e){let t=this.transformedCustomizations.get(e);if(t)return t;let r=this.globalCustomizations.get(e)??this.modeCustomizations.get(e)??this.defaultCustomizations.get(e),n=this._resolveReferences(this.transform(r),new Set([e]));return void 0!==n&&this.transformedCustomizations.set(e,n),n}_resolveReferences(e,t){if(!e||"object"!=typeof e||e.$$typeof)return e;if("string"==typeof e.$reference)return this._resolveReferenceName(e.$reference,t);if(Array.isArray(e)){let r=!1,n=[];for(let a of e)if(a&&"object"==typeof a&&!a.$$typeof&&"string"==typeof a.$reference){r=!0;let e=this._resolveReferenceName(a.$reference,t);Array.isArray(e)?n.push(...e):void 0!==e&&n.push(e)}else{let e=this._resolveReferences(a,t);r||=e!==a,n.push(e)}return r?n:e}if(!function(e){if(null===e||"object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(e))return e;let r=!1,n={};for(let[a,i]of Object.entries(e)){let e=this._resolveReferences(i,t);r||=e!==i,n[a]=e}return r?n:e}_resolveReferenceName(e,t){if(t.has(e))return void console.warn(`CustomizationService: $reference cycle detected at "${e}"`);let r=this.globalCustomizations.get(e)??this.modeCustomizations.get(e)??this.defaultCustomizations.get(e);if(void 0===r)return void console.warn(`CustomizationService: no customization registered for $reference "${e}"`);let n=new Set(t).add(e);return this._resolveReferences(this.transform(r),n)}getValue(e,t){let r=this.getCustomization(e);return void 0===r?t:r}setCustomizations(e,t=jf.Mode){Array.isArray(e)?e.forEach(e=>{this._addReference(e,t)}):Object.entries(e).forEach(([e,r])=>{this._setCustomization(e,r,t)})}setCustomization(e,t,r=jf.Mode){console.warn("setCustomization is deprecated. Please use setCustomizations with an object instead."),this._setCustomization(e,t,r)}getCustomizations(e){return e===jf.Global?this.globalCustomizations:e===jf.Mode?this.modeCustomizations:this.defaultCustomizations}hasCustomization(e){return this.globalCustomizations.has(e)||this.modeCustomizations.has(e)}transform(e){if(!e)return e;let{inheritsFrom:t}=e;if(!t)return e;let r=this.getCustomization(t),n=r?Object.assign({},r,e):e;return n.$transform?.(this)||n}registerCustomUpdateCommand(e,t){e.startsWith("$")||(e="$"+e),(0,LH.extend)(e,t)}_addReference(e,t=jf.Global){e&&("string"==typeof e&&(e=this._findExtensionValue(e).value),Object.entries(e).forEach(([e,r])=>{this[t===jf.Global&&"setGlobalCustomization"||t===jf.Default&&"setDefaultCustomization"||"setModeCustomization"](e,r)}))}addReferences(e,t=jf.Global){e&&(Array.isArray(e)?e.forEach(e=>{this._addReference(e,t)}):this._addReference(e,t))}clearTransformedCustomizations(){for(let e of(super.reset(),Array.from(this.modeCustomizations.keys())))this.transformedCustomizations.delete(e);this.modeCustomizations.clear()}async _urlDefaultImport(e){if("function"!=typeof fetch)throw Error(`No fetch implementation available to load customization ${e}`);let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch customization ${e}: ${t.status} ${t.statusText}`);return jn(await t.text())}_normalizeImportedCustomizationModule(e){return e&&"object"==typeof e&&"customizations"in e?e:e&&"object"==typeof e.default?e.default:e}_collectUrlDependencyRefs(e){let t=new Set,r=jo(e);if(!r||"object"!=typeof r)return Array.from(t);let n=r.requires;if("string"==typeof n&&n)t.add(n);else if(Array.isArray(n))for(let e of n)"string"==typeof e&&e&&t.add(e);return Array.from(t)}_urlDependencyToRequest(e,t){let r=ju([e],t);return r.valid.length?r.valid[0]:null}_urlCustomizationLoadOne(e,t,r,n,a,i){let o=e.normalized;if(this._urlCustomizationLoaded.has(o))return Promise.resolve(this._urlCustomizationLoaded.get(o)||null);if(this._urlCustomizationPending.has(o))return this._urlCustomizationPending.get(o);a.add(o);let s=this._urlCustomizationLoadOneBody(e,t,r,n,a,i);return this._urlCustomizationPending.set(o,s),s.then(()=>this._urlCustomizationPending.delete(o),()=>this._urlCustomizationPending.delete(o)),s}_urlCustomizationLoadOneBody(e,t,r,n,a,i){let o,s=e.normalized,l=Symbol("importFailed");try{o=function(e,t){let r=(t.prefixes||{})[e.prefix];if(!r)throw Error(`Unknown customization prefix: ${e.prefix}`);if(e.name.includes(".."))throw Error(`Customization name contains traversal: ${e.name}`);let n=e.name.endsWith(".jsonc")?e.name:`${e.name}.jsonc`,a=r.endsWith("/")?r:`${r}/`,i=`${a}${n}`;if(jc.test(r))return jp(i,a,e),i;let o="u">typeof window&&window.location?.origin?window.location.origin:"",s="u"<typeof window?"/":window.PUBLIC_URL||"/",l=s?.startsWith("/")?s:`/${s||""}`,d=e=>e.startsWith("./")?e.slice(2):e.startsWith("/")?e.slice(1):e,u=d(i),c=d(a),h=l.endsWith("/")?l:`${l}/`,p=`${h}${u}`,m=`${h}${c}`,f=o?`${o}${p}`:p;return jp(f,o?`${o}${m}`:m,e),f}(e,t)}catch(r){let t=`[customizationUrl] failed to resolve "${e.raw}": ${r.message}`;return n.warn(t),Promise.resolve(null)}return r(o).catch(t=>(n.warn(`[customizationUrl] failed to import customization "${e.raw}" (${o})`,t),l)).then(d=>{if(d===l)return null;let u=this._normalizeImportedCustomizationModule(d);if(!u||"object"!=typeof u){let t=`[customizationUrl] missing customization module "${e.raw}" (${o}): module is not an object`;return n.warn(t),null}if(!jo(u)){let t=`[customizationUrl] missing customization module "${e.raw}" (${o}): no customizations payload`;return n.warn(t),null}let c=this._collectUrlDependencyRefs(u),h=Promise.resolve();for(let e of c)h=h.then(()=>{let o=this._urlDependencyToRequest(e,t);if(!(!o||a.has(o.normalized)))return this._urlCustomizationLoadOne(o,t,r,n,a,i)});return h.then(()=>{let t={request:e,module:u,url:o};return this._urlCustomizationLoaded.set(s,t),i.push(t),t})})}_applyLoadedUrlCustomizationModules(e){if(e?.length)for(let t of e){let e=jo(t.module);e?.global&&this.setCustomizations(e.global,jf.Global)}}_collectPhaseBlocks(e){let t=[],r=this._getCustomizationConfig().phased;for(let n of(r&&void 0!==r[e]&&t.push(r),this._resolvedUrlModules)){let r=jo(n.module);r&&void 0!==r[e]&&t.push(r)}return t}_applyPhase(e){for(let t of this._collectPhaseBlocks(e)){let r=t[e];r&&this.setCustomizations(r,jf.Global)}}_setCustomization(e,t,r=jf.Mode){switch(r){case jf.Global:this.setGlobalCustomization(e,t);break;case jf.Mode:this.setModeCustomization(e,t);break;case jf.Default:this.setDefaultCustomization(e,t);break;default:throw Error(`Invalid customization scope: ${r}`)}}setModeCustomization(e,t){let r=this.defaultCustomizations.get(e),n=this.modeCustomizations.get(e),a=this.globalCustomizations.get(e),i=n||this._cloneIfNeeded(a)||r,o=this._update(i,t);this.modeCustomizations.set(e,o),this.transformedCustomizations.clear(),this._broadcastEvent(this.EVENTS.MODE_CUSTOMIZATION_MODIFIED,{buttons:this.modeCustomizations,button:this.modeCustomizations.get(e)})}setGlobalCustomization(e,t){let r=this.defaultCustomizations.get(e),n=this.globalCustomizations.get(e),a=this._cloneIfNeeded(n)||r;this.globalCustomizations.set(e,this._update(a,t)),this.transformedCustomizations.clear(),this._broadcastEvent(this.EVENTS.GLOBAL_CUSTOMIZATION_MODIFIED,{buttons:this.globalCustomizations,button:this.globalCustomizations.get(e)})}setDefaultCustomization(e,t){this.transformedCustomizations.clear();let r=this.defaultCustomizations.get(e);this.defaultCustomizations.set(e,this._update(r,t)),this._broadcastEvent(this.EVENTS.DEFAULT_CUSTOMIZATION_MODIFIED,{buttons:this.defaultCustomizations,button:this.defaultCustomizations.get(e)})}_findExtensionValue(e){return this.extensionManager.getModuleEntry(e)}_update(e,t){return(e||(e=void 0),!function e(t){if(Array.isArray(t)){for(let r of t)if(e(r))return!0}else if(t&&"object"==typeof t){if(t.$$typeof)return!1;for(let r of Object.keys(t))if(r.startsWith("$")&&"$transform"!==r&&"$reference"!==r||e(t[r]))return!0}return!1}(t))?t:LG()(e,t)}_cloneIfNeeded(e){return e&&"object"==typeof e?Array.isArray(e)?[...e]:{...e}:e}}jg.EVENTS=jm,jg.REGISTRATION={name:"customizationService",create:({configuration:e,commandsManager:t})=>new jg({configuration:e,commandsManager:t})},(0,LH.extend)("$filter",(e,t)=>(function e(t,r){if(Array.isArray(t))return"function"==typeof r?t.filter(r):"string"==typeof r?t.filter(e=>e.id!==r):"object"==typeof r&&r.match&&r.$merge?t.map(t=>e(t,r)).map(e=>{var t;return(t=r.match,e&&"object"==typeof e&&Object.entries(t).every(([t,r])=>e[t]===r))?{...e,...r.$merge}:e}):"object"==typeof r&&r.id&&r.$merge?t.map(t=>e(t,r)).map(e=>e.id===r.id?{...e,...r.$merge}:e):t.map(t=>e(t,r));if(t&&"object"==typeof t){let n={...t};for(let[t,a]of Object.entries(n))n[t]=e(a,r);return n}return t})(t,e));let jy=["requires","bootstrap","global","mode"],jv={PANELS_CHANGED:"event::panelService:panelsChanged",ACTIVATE_PANEL:"event::panelService:activatePanel"},jb=((eIX={}).Left="left",eIX.Right="right",eIX.Bottom="bottom",eIX);class jx extends Ns{constructor(e){super(jv),this._extensionManager=void 0,this._panelsGroups=new Map,this._extensionManager=e}get PanelPosition(){return jb}_getPanelComponent(e){let t=this._extensionManager.getModuleEntry(e);if(!t){let t=this._getSimilarPanels(e);if(t.length>0){let r=`Did you mean: ${t.join(", ")}?`;throw Error(`${e} is not a valid entry for an extension module. ${r} Please check your configuration or make sure the extension is registered.`)}throw Error(`${e} is not a valid entry for an extension module, please check your configuration or make sure the extension is registered.`)}if(!t?.component)throw Error(`No component found from extension ${e}. Check the reference string to the extension in your Mode configuration`);let r=t.component;return{entry:t,content:r}}_getSimilarPanels(e,t=.8){return Object.keys(this._extensionManager.modulesMap).filter(e=>e.includes("panelModule")).filter(r=>this._calculateSimilarity(e,r)>=t)}_calculateSimilarity(e,t){let r=new Set(e.toLowerCase().split("")),n=new Set(t.toLowerCase().split("")),a=new Set([...r].filter(e=>n.has(e))),i=new Set([...r,...n]);return a.size/i.size}getPanelData(e){let t,r;if(Array.isArray(e)){let n=e.map(e=>this._getPanelComponent(e));r=n[0].entry,t=e=>(0,tT.jsx)(tT.Fragment,{children:n.map(({content:t},r)=>(0,tT.jsx)(t,{...e},r))})}else({content:t,entry:r}=this._getPanelComponent(e));return{id:r.id,iconName:r.iconName,iconLabel:r.iconLabel,label:r.label,name:r.name,content:t}}addPanel(e,t,r){let n=this._panelsGroups.get(e);n||(n=[],this._panelsGroups.set(e,n));let a=this.getPanelData(t);n.push(a),this._broadcastEvent(jv.PANELS_CHANGED,{position:e,options:r})}addPanels(e,t,r){if(!Array.isArray(t))throw Error('Invalid "panelsIds" array');t.forEach(t=>this.addPanel(e,t,r))}setPanels(e,t){this.reset(),Object.keys(e).forEach(r=>{this.addPanels(r,e[r],t)})}getPanels(e){return[...this._panelsGroups.get(e)??[]]}reset(){let e=Array.from(this._panelsGroups.keys());this._panelsGroups.clear(),e.forEach(e=>this._broadcastEvent(jv.PANELS_CHANGED,{position:e}))}onModeExit(){this.reset()}activatePanel(e,t=!1){this._broadcastEvent(jv.ACTIVATE_PANEL,{panelId:e,forceActive:t})}addActivatePanelTriggers(e,t,r=!1){return t.map(t=>t.sourceEvents.map(n=>t.sourcePubSubService.subscribe(n,()=>this.activatePanel(e,r)))).flat()}}jx.REGISTRATION={name:"panelService",create:({extensionManager:e})=>new jx(e)};let jw={ACTIVE_STEP_CHANGED:"event::workflowStepsService:activateStepChanged",STEPS_CHANGED:"event::workflowStepsService:stepsChanged"};class jC extends Ns{constructor(e,t,r){super(jw),this._extensionManager=void 0,this._servicesManager=void 0,this._commandsManager=void 0,this._workflowSteps=void 0,this._activeWorkflowStep=void 0,this._workflowSteps=[],this._activeWorkflowStep=null,this._extensionManager=e,this._commandsManager=t,this._servicesManager=r}get workflowSteps(){return[...this._workflowSteps]}get activeWorkflowStep(){return this._activeWorkflowStep}addWorkflowSteps(e){let t=!1;e.forEach(e=>{if(this._workflowSteps.some(t=>t.id===e.id))throw Error(`Duplicated workflow step id (${e.id})`);this._workflowSteps.push(e),t=!0}),t&&this._broadcastEvent(jw.STEPS_CHANGED,{})}_updateToolBar(e){let{toolbarService:t}=this._servicesManager.services,{toolbarButtons:r}=e;(Array.isArray(r)?r:[r]).forEach(({buttonSection:e,buttons:r})=>{t.clearButtonSection(e),t.updateSection(e,r)})}_updatePanels(e){let{panelService:t}=this._servicesManager.services,r=e?.layout?.panels;r&&t.setPanels(r,e?.layout?.options)}_updateHangingProtocol(e){let{hangingProtocol:t}=e;t&&this._commandsManager.runCommand("setHangingProtocol",{protocolId:t.protocolId,stageId:t.stageId,stageIndex:t.stageIndex})}_invokeCallbacks(e){if(!e)return;let t=this._commandsManager;Array.isArray(e)||(e=[e]),e.forEach(e=>{let r=e;if(e?.commandName){let{commandName:n,options:a}=e;r=()=>t.runCommand(n,a)}r()})}setActiveWorkflowStep(e){let t=this._activeWorkflowStep;if(e===t?.id)return;let r=this._workflowSteps.find(t=>t.id===e);if(!r)throw Error(`Invalid workflowStepId (${e})`);this._activeWorkflowStep&&this._invokeCallbacks(t.onExit),this._invokeCallbacks(r.onEnter),this._activeWorkflowStep=r,this._updateToolBar(r),this._updatePanels(r),this._updateHangingProtocol(r),this._broadcastEvent(jw.ACTIVE_STEP_CHANGED,{activeWorkflowStep:r})}reset(){this._activeWorkflowStep=null,this._workflowSteps=[]}onModeEnter(){this.reset()}}jC.REGISTRATION={name:"workflowStepsService",create:({extensionManager:e,commandsManager:t,servicesManager:r})=>new jC(e,t,r)};var jk=((eIZ=jk||{}).Interaction="interaction",eIZ.Thumbnail="thumbnail",eIZ.Prefetch="prefetch",eIZ.Compute="compute",eIZ);let jM={SERVICE_STARTED:"event::studyPrefetcherService:started",SERVICE_STOPPED:"event::studyPrefetcherService:stopped",DISPLAYSET_LOAD_PROGRESS:"event::studyPrefetcherService:displaySetLoadProgress",DISPLAYSET_LOAD_COMPLETE:"event::studyPrefetcherService:displaySetLoadComplete"};var jS=((eIJ=jS||{}).closest="closest",eIJ.downward="downward",eIJ.upward="upward",eIJ);class jI extends Ns{constructor({servicesManager:e,extensionManager:t,configuration:r}){super(jM),this._extensionManager=void 0,this._servicesManager=void 0,this._subscriptions=void 0,this._activeDisplaySetsInstanceUIDs=[],this._pendingRequests=[],this._inflightRequests=new Map,this._isRunning=!1,this._displaySetLoadingStates=new Map,this._imageIdsToDisplaySetsMap=new Map,this.config={enabled:!1,displaySetsCount:1,maxNumPrefetchRequests:10,order:jS.downward},this.requestType=jk.Prefetch,this.cache=void 0,this.imageLoadPoolManager=void 0,this.imageLoader=void 0,this.imageLoadEventsManager=void 0,this._servicesManager=e,this._extensionManager=t,this._subscriptions=[],Object.assign(this.config,r)}onModeEnter(){this._addEventListeners()}onModeExit(){this._removeEventListeners(),this._stopPrefetching()}_addImageLoadingEventsListeners(){let e=e=>{this._inflightRequests.get(e)||this._sendNextRequests()},t=t=>{let{image:r}=t.detail,{imageId:n}=r;this._moveImageIdToLoadedSet(n),e(n)},r=t=>{let{imageId:r}=t.detail;this._moveImageIdToFailedSet(r),e(r)};return this.imageLoadEventsManager.addEventListeners(t,r)}_addServicesListeners(){let{displaySetService:e,viewportGridService:t}=this._servicesManager.services;return[e.subscribe(e.EVENTS.DISPLAY_SETS_CHANGED,()=>this._syncWithActiveViewport({forceRestart:!0})),t.subscribe(NH.EVENTS.ACTIVE_VIEWPORT_ID_CHANGED,({viewportId:e})=>this._syncWithActiveViewport({activeViewportId:e})),t.subscribe(NH.EVENTS.LAYOUT_CHANGED,()=>this._syncWithActiveViewport()),t.subscribe(NH.EVENTS.GRID_STATE_CHANGED,()=>this._syncWithActiveViewport()),t.subscribe(NH.EVENTS.VIEWPORTS_READY,()=>{this._syncWithActiveViewport(),this._startPrefetching()})]}_addEventListeners(){let e=this._addImageLoadingEventsListeners(),t=this._addServicesListeners();this._subscriptions.push(...e),this._subscriptions.push(...t)}_removeEventListeners(){this._subscriptions.forEach(e=>e.unsubscribe()),this._subscriptions=[]}_syncWithActiveViewport({activeViewportId:e,forceRestart:t}={}){let{viewportGridService:r}=this._servicesManager.services,n=r.getState(),{viewports:a}=n;if(!(e=e??n.activeViewportId))return;let i=a.get(e);if(!i)return;let o=this._setActiveDisplaySetsUIDs(i.displaySetInstanceUIDs);(t||o)&&this._restartPrefetching()}_setActiveDisplaySetsUIDs(e){return!(e.length===this._activeDisplaySetsInstanceUIDs.length&&e.every(e=>this._activeDisplaySetsInstanceUIDs.includes(e)))&&(this._activeDisplaySetsInstanceUIDs=[...e],this._restartPrefetching(),!0)}_areActiveDisplaySetsLoaded(){let{_activeDisplaySetsInstanceUIDs:e}=this;return e.length&&e.every(e=>this._displaySetLoadingStates.get(e).loadingProgress>=1)}_getClosestDisplaySets(e,t){let r=[],n=t-1,a=t+1;for(;n>=0||a<e.length;)n>=0&&(r.push(e[n]),n--),a<e.length&&(r.push(e[a]),a++);return r}_getDownwardDisplaySets(e,t){let r=[];for(let n=t+1;n<e.length;n++)r.push(e[n]);return r}_getUpwardDisplaySets(e,t){let r=[];for(let n=t-1;n>=0&&n!==t;n--)r.push(e[n]);return r}_getSortedDisplaySetsToPrefetch(e){if(!this._activeDisplaySetsInstanceUIDs?.length)return[];let{displaySetsCount:t}=this.config,r=this._activeDisplaySetsInstanceUIDs,[n]=r,a=e.findIndex(e=>e.displaySetInstanceUID===n),i={[jS.closest]:this._getClosestDisplaySets,[jS.downward]:this._getDownwardDisplaySets,[jS.upward]:this._getUpwardDisplaySets},{order:o}=this.config,s=i[o];if(!s)throw Error(`Invalid order (${o})`);let l=new Set(r);return s.call(this,e,a).filter(e=>!l.has(e.displaySetInstanceUID)).slice(0,t)}_getDisplaySets(){let{displaySetService:e}=this._servicesManager.services,t=[...e.getActiveDisplaySets()],r=this._getSortedDisplaySetsToPrefetch(t);return{displaySets:t,displaySetsToPrefetch:r}}_updateImageIdsDisplaySetMap(e,t){for(let r of t){let t=this._imageIdsToDisplaySetsMap.get(r);t||(t=new Set,this._imageIdsToDisplaySetsMap.set(r,t)),t.add(e)}}_getImageIdsForDisplaySet(e){return this._extensionManager.getActiveDataSource()[0].getImageIdsForDisplaySet(e)}_updateDisplaySetLoadingProgress(e){let{numInstances:t,loadedImageIds:r,failedImageIds:n}=e;e.loadingProgress=(r.size+n.size)/t}_addDisplaySetLoadingState(e){let{displaySetInstanceUID:t}=e,r=this._getImageIdsForDisplaySet(e),n=this._displaySetLoadingStates.get(t);if(n)return;let a=new Set(r),i=new Set;for(let e of r)this.cache.isImageCached(e)?i.add(e):a.add(e);n={displaySetInstanceUID:t,numInstances:r.length,pendingImageIds:a,loadedImageIds:i,failedImageIds:new Set,loadingProgress:0},this._updateDisplaySetLoadingProgress(n),this._displaySetLoadingStates.set(t,n),this._updateImageIdsDisplaySetMap(t,r),i.size&&this._triggerDisplaySetEvents(t)}_loadDisplaySets(){let{displaySets:e,displaySetsToPrefetch:t}=this._getDisplaySets();e.forEach(e=>this._addDisplaySetLoadingState(e)),t.forEach(e=>this._enqueueDisplaySetImagesRequests(e))}_moveImageIdToLoadedSet(e){let t=this._imageIdsToDisplaySetsMap.get(e);if(t){for(let r of Array.from(t.values())){let t=this._displaySetLoadingStates.get(r),{pendingImageIds:n,loadedImageIds:a}=t;n.delete(e),a.add(e),this._updateDisplaySetLoadingProgress(t),this._triggerDisplaySetEvents(r)}return!0}}_moveImageIdToFailedSet(e){let t=this._imageIdsToDisplaySetsMap.get(e);if(t){for(let r of Array.from(t.values())){let t=this._displaySetLoadingStates.get(r),{pendingImageIds:n,failedImageIds:a}=t;n.delete(e),a.add(e),this._updateDisplaySetLoadingProgress(t),this._triggerDisplaySetEvents(r)}return!0}}_triggerDisplaySetEvents(e){let{loadingProgress:t,numInstances:r}=this._displaySetLoadingStates.get(e);this._broadcastEvent(this.EVENTS.DISPLAYSET_LOAD_PROGRESS,{displaySetInstanceUID:e,numInstances:r,loadingProgress:t}),t>=1&&this._broadcastEvent(this.EVENTS.DISPLAYSET_LOAD_COMPLETE,{displaySetInstanceUID:e})}_onImagePrefetchSuccess(e){if(e.aborted)return;let{imageId:t}=e;this._inflightRequests.delete(t),this._moveImageIdToLoadedSet(t),this._sendNextRequests()}_onImagePrefetchFailed(e,t){if(e.aborted)return;console.warn(`An error ocurred when trying to load "${e.imageId}"`,t);let{imageId:r}=e;this._inflightRequests.delete(r),this._moveImageIdToFailedSet(r),this._sendNextRequests()}async _sendNextRequests(){if(!this._isRunning||!this._areActiveDisplaySetsLoaded())return;let{_pendingRequests:e,_inflightRequests:t}=this,{maxNumPrefetchRequests:r}=this.config;if(!e.length||t.size>=r)return;let n=Math.min(e.length,r-t.size);this._pendingRequests.splice(0,n).forEach(e=>{let{imageId:r}=e,n={priority:-5,requestType:this.requestType,additionalDetails:{imageId:r},preScale:{enabled:!0}};this.imageLoadPoolManager.addRequest(async()=>this.imageLoader.loadAndCacheImage(r,n).then(t=>this._onImagePrefetchSuccess(e),t=>this._onImagePrefetchFailed(e,t)),this.requestType,{imageId:r}),t.set(r,e)})}_enqueueDisplaySetImagesRequests(e){let{displaySetInstanceUID:t}=e;this._getImageIdsForDisplaySet(e).forEach(e=>{this.cache.isImageCached(e)?this._moveImageIdToLoadedSet(e):this._pendingRequests.push({displaySetInstanceUID:t,imageId:e,aborted:!1})})}_startPrefetching(){if(!this._isRunning){if(!this.config.enabled)return void console.log("StudyPrefetcher is not enabled");this._isRunning=!0,this._loadDisplaySets(),this._sendNextRequests(),this._broadcastEvent(this.EVENTS.SERVICE_STARTED,{})}}_stopPrefetching(){this._isRunning&&(this._isRunning=!1,this._inflightRequests.forEach(e=>e.aborted=!0),this._pendingRequests=[],this._displaySetLoadingStates.clear(),this._imageIdsToDisplaySetsMap.clear(),this._inflightRequests.clear(),this.imageLoadPoolManager.clearRequestStack(this.requestType),this._broadcastEvent(this.EVENTS.SERVICE_STOPPED,{}))}_restartPrefetching(){this._isRunning&&(this._stopPrefetching(),this._startPrefetching())}}jI.REGISTRATION={name:"studyPrefetcherService",altName:"StudyPrefetcherService",create:({configuration:e,servicesManager:t,extensionManager:r})=>new jI({servicesManager:t,extensionManager:r,configuration:e})};class jT{constructor(e,t){this.numberOfScreens=void 0,this.windowsConfig=void 0,this.screenConfig=void 0,this.launchWindows=[],this.basePath=void 0,this.screenNumber=void 0,this.isMultimonitor=void 0,this.setLaunchWindows=e=>{this.launchWindows=e,window.multimonitor.launchWindows=e};const r=new URLSearchParams(window.location.search),n=r.get("screenNumber"),a=r.get("multimonitor"),i={params:r,screenNumber:n,multimonitor:a};this.screenNumber=n?Number(n):-1,this.commandsManager=t;const o=window;for(const r of(o.multimonitor||={setLaunchWindows:this.setLaunchWindows,launchWindows:this.launchWindows,commandsManager:t},o.multimonitor.commandsManager=t,this.launchWindows=window.multimonitor?.launchWindows||this.launchWindows,-1!==this.screenNumber&&(this.launchWindows[this.screenNumber]=window),o.commandsManager=(...t)=>e.commandsManager,Array.isArray(e)?e:[])){if(r.test(i)){if(this.isMultimonitor=!0,this.numberOfScreens=r.screens.length,this.windowsConfig=r,-1===this.screenNumber||null===this.screenNumber)this.screenConfig=jT.SOURCE_SCREEN;else{if(this.screenConfig=r.screens[this.screenNumber],!this.screenConfig)throw Error(`Screen ${n} not configured in ${this.windowsConfig}`);window.name=this.screenConfig.id}return}this.numberOfScreens=1,this.isMultimonitor=!1}}async run(e=1,t,r){let n=(this.screenNumber+(e??1))%this.numberOfScreens,a=await this.getWindow(n);a?a.multimonitor?.commandsManager?a.multimonitor.commandsManager.runAsync(t,r):console.warn("Didn't find a commands manager to run in the other window",a):console.warn("No multimonitor found for screen",n,t)}async launchWindow(e,t=1,r=""){let n=(this.screenNumber+t)%this.numberOfScreens;return this.getWindow(n,e?`StudyInstanceUIDs=${e}${r}`:"")}async getWindow(e,t){return e===this.screenNumber?window:this.launchWindows[e]&&!this.launchWindows[e].closed?this.launchWindows[e]:await this.createWindow(e,t)}async createWindow(e,t){if(e===this.screenNumber)return window;let r=this.windowsConfig.screens[e],n=await window.getScreenDetails?.(),{width:a=1024,height:i=1024,availLeft:o=0,availTop:s=0}=r.screen>=0&&n.screens[r.screen]||n.currentScreen||window.screen||{},l=this.windowsConfig.screens[e],{width:d=1,height:u=1,top:c=0,left:h=0}=l.location||{},p=Math.round(o+h*a),m=Math.round(s+c*i),f=Math.round(a*d),g=Math.round(i*u),y=`${this.basePath}&screenNumber=${e}`,v=t?`${y}#${t}`:y,b=l.id,x=l.options||"",w=`screenX=${p},screenY=${m},width=${f},height=${g},${x}`,C=window.open("",b,w);return(C?.location.href.startsWith(y)||(C=window.open(v,b,w)),C)?(await new Promise(e=>{"complete"===C.document.readyState?e():C.addEventListener("load",()=>e())}),this.launchWindows[e]=C,C):void console.warn("Unable to launch window",v,"called",b,"at",w)}launchAll(){for(let e=0;e<this.numberOfScreens;e++)this.createWindow(e)}setBasePath(){let e=new URL(window.location.href);e.searchParams.delete("screenNumber"),e.searchParams.delete("protocolId"),e.searchParams.delete("launchAll"),e.searchParams.set("multimonitor",e.searchParams.get("multimonitor")||"split"),e.hash="",this.basePath=e.toString()}onModeEnter(){this.setBasePath(),(this.isMultimonitor&&-1===this.screenNumber||-1!==window.location.href.toLowerCase().indexOf("launchall"))&&this.launchAll()}}jT.SOURCE_SCREEN={id:"source",launch:"source",screen:null,location:{screen:null,width:1,height:1,left:0,top:0}},jT.REGISTRATION={name:"multiMonitorService",create:({configuration:e,commandsManager:t})=>new jT(e,t)};class j_ extends Ns{constructor({commandsManager:e,servicesManager:t,serviceProvidersManager:r,hotkeysManager:n,appConfig:a={}}){super(j_.EVENTS),this._commandsManager=void 0,this._servicesManager=void 0,this._hotkeysManager=void 0,this._serviceProvidersManager=void 0,this.modulesMap=void 0,this.modules=void 0,this.registeredExtensionIds=void 0,this.moduleTypeNames=void 0,this._appConfig=void 0,this._extensionLifeCycleHooks=void 0,this.dataSourceMap=void 0,this.dataSourceDefs=void 0,this._activeDataSourceName=void 0,this.registerExtensions=async(e,t=[])=>{for(let r=0;r<e.length;r++){let n=e[r],a=Array.isArray(n);try{if(a){let e=n[0],r=n[1];await this.registerExtension(e,r,t)}else await this.registerExtension(n,{},t)}catch(e){console.error(e)}}},this.registerExtension=async(e,t={},r=[])=>{if(!e)throw Error("Attempting to register a null/undefined extension.");let n=e.id;if(!n)throw O7.warn(e),Error("Extension ID not set");this.registeredExtensionIds.includes(n)?O7.warn(`Extension ID ${n} has already been registered. Exiting before duplicating modules.`):(e.preRegistration&&await e.preRegistration({servicesManager:this._servicesManager,serviceProvidersManager:this._serviceProvidersManager,commandsManager:this._commandsManager,hotkeysManager:this._hotkeysManager,extensionManager:this,appConfig:this._appConfig,configuration:t}),e.onModeEnter&&(this._extensionLifeCycleHooks.onModeEnter[n]=e.onModeEnter),e.onModeExit&&(this._extensionLifeCycleHooks.onModeExit[n]=e.onModeExit),this.moduleTypeNames.forEach(a=>{let i=this._getExtensionModule(a,e,n,t);if(i){switch(a){case O9.COMMANDS:this._initCommandsModule(i);break;case O9.DATA_SOURCE:this._initDataSourcesModule(i,n,r);break;case O9.HANGING_PROTOCOL:this._initHangingProtocolsModule(i,n);break;case O9.PANEL:this._initPanelModule(i,n);break;case O9.TOOLBAR:this._initToolbarModule(i,n);break;case O9.VIEWPORT:case O9.SOP_CLASS_HANDLER:case O9.CONTEXT:case O9.LAYOUT_TEMPLATE:case O9.CUSTOMIZATION:case O9.STATE_SYNC:case O9.UTILITY:this.processExtensionModule(i,n,a);break;default:throw Error(`Module type invalid: ${a}`)}this.modules[a].push({extensionId:n,module:i})}}),this.registeredExtensionIds.push(n))},this.getModuleEntry=e=>this.modulesMap[e],this.getModulesByType=e=>this.modules[e],this.getDataSources=e=>(e||(e=this._activeDataSourceName),this.dataSourceMap[e]),this.getDataSourceInstance=e=>this.dataSourceMap[e][0],this.getActiveDataSource=()=>this.dataSourceMap[this._activeDataSourceName],this.getActiveDataSourceOrNull=()=>this.dataSourceMap[this._activeDataSourceName]?.[0]??null,this.getDataSourceDefinition=e=>(void 0===e&&(e=this._activeDataSourceName),this.dataSourceDefs[e]),this.getActiveDataSourceDefinition=()=>this.getDataSourceDefinition(this._activeDataSourceName),this.getDataSourcesForUI=()=>{if(this._appConfig?.allowMultiSelectExport===!1)return[];let e=Object.keys(this.dataSourceMap).filter(e=>{let t=this.dataSourceDefs[e]?.configuration,r=this.dataSourceDefs[e].sourceName!==this._activeDataSourceName;return(t?.supportsStow??t?.wadoRoot)&&r});return[this._activeDataSourceName,...e].map(e=>({value:e,label:e,placeHolder:e}))},this._getExtensionModule=(e,t,r,n)=>{var a;let i="get"+((a=e).charAt(0).toUpperCase()+a.substring(1));if(t[i])try{let e=t[i]({appConfig:this._appConfig,commandsManager:this._commandsManager,servicesManager:this._servicesManager,hotkeysManager:this._hotkeysManager,extensionManager:this,configuration:n});return e||O7.warn(`Null or undefined returned when registering the ${i} module for the ${r} extension`),e}catch(e){throw console.error(e),Error(`Exception thrown while trying to call ${i} for the ${r} extension`)}},this._initHangingProtocolsModule=(e,t)=>{let{hangingProtocolService:r}=this._servicesManager.services;e.forEach(({name:e,protocol:t})=>{t&&r.addProtocol(e,t)})},this._initPanelModule=(e,t)=>{this.processExtensionModule(e,t,O9.PANEL)},this._initToolbarModule=(e,t)=>{let{toolbarService:r}=this._servicesManager.services;e.forEach(e=>{e.evaluate&&r.registerEvaluateFunction(e.name,e.evaluate)})},this._initCommandsModule=e=>{let{definitions:t,defaultContext:r}=e;t&&0!==Object.keys(t).length?(r=r||"VIEWER",this._commandsManager.getContext(r)||this._commandsManager.createContext(r),Object.keys(t).forEach(e=>{let n=t[e];"function"==typeof n&&(n={commandFn:n}),n.context&&!this._commandsManager.getContext(n.context)&&this._commandsManager.createContext(n.context),this._commandsManager.registerCommand(n.context||r,e,n)})):O7.warn("Commands Module contains no command definitions")},this.modules={},this.registeredExtensionIds=[],this.moduleTypeNames=Object.values(O9),this._commandsManager=e,this._servicesManager=t,this._serviceProvidersManager=r,this._hotkeysManager=n,this._appConfig=a,this.modulesMap={},this.moduleTypeNames.forEach(e=>{this.modules[e]=[]}),this._extensionLifeCycleHooks={onModeEnter:{},onModeExit:{}},this.dataSourceMap={},this.dataSourceDefs={},this.defaultDataSourceName=a.defaultDataSourceName,this._activeDataSourceName=a.defaultDataSourceName,this.peerImport=a.peerImport}setActiveDataSource(e){this._activeDataSourceName!==e&&(this._activeDataSourceName=e,this._broadcastEvent(j_.EVENTS.ACTIVE_DATA_SOURCE_CHANGED,this.dataSourceDefs[this._activeDataSourceName]))}getRegisteredExtensionIds(){return[...this.registeredExtensionIds]}getUniqueServicesList(e){return Array.from(new Set(Object.values(e.services)))}onModeEnter(){let{registeredExtensionIds:e,_servicesManager:t,_commandsManager:r,_hotkeysManager:n,_extensionLifeCycleHooks:a}=this;for(let e of this.getUniqueServicesList(t))e?.onModeEnter?.();e.forEach(e=>{let i=a.onModeEnter[e];"function"==typeof i&&i({servicesManager:t,commandsManager:r,hotkeysManager:n,extensionManager:this})})}onModeExit(){let{registeredExtensionIds:e,_servicesManager:t,_commandsManager:r,_extensionLifeCycleHooks:n}=this,a=this.getUniqueServicesList(t);for(let i of(e.forEach(e=>{let a=n.onModeExit[e];"function"==typeof a&&a({servicesManager:t,commandsManager:r})}),a))try{i?.onModeExit?.()}catch(e){console.warn("onModeExit caught",e)}}processExtensionModule(e,t,r){e.forEach(e=>{if(!e.name)throw Error(`Extension ID ${t} module ${r} element has no name`);let n=`${t}.${r}.${e.name}`;e.id=n,this.modulesMap[n]=e})}addDataSource(e,t={activate:!1}){let r=this.getDataSources(e.sourceName);!r?.[0]&&(this._createDataSourceInstance(e),t.activate&&this.setActiveDataSource(e.sourceName))}updateDataSourceConfiguration(e,t){let r=this.getDataSources(e);if(!r?.[0])return;let n=this.dataSourceDefs[e];n.configuration=t,this._createDataSourceInstance(n),this._activeDataSourceName===e&&this._broadcastEvent(j_.EVENTS.ACTIVE_DATA_SOURCE_CHANGED,n)}_createDataSourceInstance(e){let t=this.getModuleEntry(e.namespace);if(!t)return;this.dataSourceDefs[e.sourceName]=e;let r=t.createDataSource(e.configuration,this._servicesManager,this);this.dataSourceMap[e.sourceName]=[r]}_initDataSourcesModule(e,t,r=[]){e.forEach(e=>{this.modulesMap[`${t}.${O9.DATA_SOURCE}.${e.name}`]=e}),e.forEach(e=>{let n=`${t}.${O9.DATA_SOURCE}.${e.name}`;r.forEach(e=>{e.namespace===n&&this.addDataSource(e)})})}registerCommandsModule(e,t="VIEWER"){this._initCommandsModule({...e,defaultContext:e.defaultContext||t})}get appConfig(){return this._appConfig}get activeDataSourceName(){return this._activeDataSourceName}}j_.EVENTS={ACTIVE_DATA_SOURCE_CHANGED:"event::activedatasourcechanged"},j_.MODULE_TYPES=O9;var jP=d(2203),jE=d.n(jP);let jD=[{commandName:"setToolActive",commandOptions:{toolName:"Zoom"},label:"Zoom",keys:["z"],isEditable:!0},{commandName:"scaleUpViewport",label:"Zoom In",keys:["+"],isEditable:!0},{commandName:"scaleDownViewport",label:"Zoom Out",keys:["-"],isEditable:!0},{commandName:"fitViewportToWindow",label:"Zoom to Fit",keys:["="],isEditable:!0},{commandName:"rotateViewportCW",label:"Rotate Right",keys:["r"],isEditable:!0},{commandName:"rotateViewportCCW",label:"Rotate Left",keys:["l"],isEditable:!0},{commandName:"flipViewportHorizontal",label:"Flip Horizontally",keys:["h"],isEditable:!0},{commandName:"flipViewportVertical",label:"Flip Vertically",keys:["v"],isEditable:!0},{commandName:"toggleCine",label:"Cine",keys:["c"]},{commandName:"invertViewport",label:"Invert",keys:["i"],isEditable:!0},{commandName:"incrementActiveViewport",label:"Next Image Viewport",keys:["right"],isEditable:!0},{commandName:"decrementActiveViewport",label:"Previous Image Viewport",keys:["left"],isEditable:!0},{commandName:"updateViewportDisplaySet",commandOptions:{direction:-1},label:"Previous Series",keys:["pageup"],isEditable:!0},{commandName:"updateViewportDisplaySet",commandOptions:{direction:1},label:"Next Series",keys:["pagedown"],isEditable:!0},{commandName:"nextStage",context:"DEFAULT",label:"Next Stage",keys:["."],isEditable:!0},{commandName:"previousStage",context:"DEFAULT",label:"Previous Stage",keys:[","],isEditable:!0},{commandName:"nextImage",label:"Next Image",keys:["down"],isEditable:!0},{commandName:"previousImage",label:"Previous Image",keys:["up"],isEditable:!0},{commandName:"firstImage",label:"First Image",keys:["home"],isEditable:!0},{commandName:"lastImage",label:"Last Image",keys:["end"],isEditable:!0},{commandName:"resetViewport",label:"Reset",keys:["space"],isEditable:!0},{commandName:"cancelActiveOperation",label:"Cancel",keys:["esc"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-soft-tissue",presetIndex:0},label:"W/L Preset 1",keys:["1"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-lung",presetIndex:1},label:"W/L Preset 2",keys:["2"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-liver",presetIndex:2},label:"W/L Preset 3",keys:["3"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-bone",presetIndex:3},label:"W/L Preset 4",keys:["4"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-brain",presetIndex:4},label:"W/L Preset 5",keys:["5"]},{commandName:"deleteActiveAnnotation",label:"Delete Annotation",keys:["backspace"]},{commandName:"acceptPreview",label:"Accept Preview",keys:["enter"]},{commandName:"undo",label:"Undo",keys:["ctrl+z"],isEditable:!0},{commandName:"redo",label:"Redo",keys:["ctrl+y"],isEditable:!0},{commandName:"interpolateScrollForMarkerLabelmap",label:"Interpolate Scroll",keys:["n"],isEditable:!0},{commandName:"increaseBrushSize",label:"Increase Brush Size",keys:["]"],isEditable:!0},{commandName:"decreaseBrushSize",label:"Decrease Brush Size",keys:["["],isEditable:!0},{commandName:"setToolActive",commandOptions:{toolName:"CircularEraser"},label:"Eraser",keys:["e"],isEditable:!0},{commandName:"setToolActive",commandOptions:{toolName:"CircularBrush"},label:"Brush",keys:["b"],isEditable:!0},{commandName:"addNewSegment",label:"Add New Segment",keys:["a"],isEditable:!0}],jA=function({generateHash:e}){try{let t=localStorage.getItem("hotkey-definitions"),r=localStorage.getItem("hotkeys-migrated");if(!t||"true"===r)return;let n=JSON.parse(t);if(!Array.isArray(n)||0===n.length)return;let a=jD||[],i=JSON.parse(localStorage.getItem("user-preferred-keys")||"{}");n.forEach(t=>{if(!t.commandName||!t.keys)return;let r=a.find(e=>{let r=e.commandName===t.commandName,n=t.commandOptions||{},a=e.commandOptions||{},i=JSON.stringify(n)===JSON.stringify(a);return r&&i});r&&JSON.stringify(r.keys)===JSON.stringify(t.keys)||(i[e({commandName:t.commandName,commandOptions:t.commandOptions||{}})]=t.keys,console.debug(`HotkeysManager: Migrated custom hotkey for ${t.commandName}`))}),localStorage.setItem("user-preferred-keys",JSON.stringify(i)),localStorage.setItem("hotkeys-migrated","true"),localStorage.removeItem("hotkey-definitions"),console.debug("HotkeysManager: Successfully migrated hotkey definitions to new format")}catch(e){console.error("HotkeysManager: Error migrating hotkey definitions",e),localStorage.setItem("hotkeys-migrated","false")}};class jO{constructor(e,t){this._servicesManager=void 0,this._commandsManager=void 0,this.isEnabled=!0,this.hotkeyDefinitions={},this.hotkeyDefaults=[],this.EVENTS=void 0,this.listeners={},this.subscribe=void 0,this._broadcastEvent=void 0,this._unsubscribe=void 0,this._isValidEvent=void 0,this._servicesManager=t,this._commandsManager=e,this.EVENTS=jO.EVENTS,this.subscribe=Nr.subscribe.bind(this),this._broadcastEvent=Nr._broadcastEvent.bind(this),this._unsubscribe=Nr._unsubscribe.bind(this),this._isValidEvent=Nr._isValidEvent.bind(this),jA({generateHash:this.generateHash})}record(e){return R2.record(e)}cancel(){R2.stopRecord(),R2.unpause()}disable(){this.isEnabled=!1,R2.pause()}enable(){this.isEnabled=!0,R2.unpause()}restoreDefaultBindings(){this.setHotkeys(this.hotkeyDefaults)}destroy(){this.hotkeyDefaults=[],this.hotkeyDefinitions={},R2.reset()}setHotkeys(e=[]){try{this.getValidDefinitions(e).forEach(e=>this.registerHotkeys(e))}catch(t){let{uiNotificationService:e}=this._servicesManager.services;e.show({title:"Hotkeys Manager",message:"Error while setting hotkeys",type:"error"})}}generateHash(e){return jE()({commandName:e.commandName,commandOptions:e.commandOptions||{}})}setDefaultHotKeys(e=[]){let t=this.getValidDefinitions(e);this.hotkeyDefaults=t;let r=JSON.parse(localStorage.getItem("user-preferred-keys")||"{}"),n=t.map(e=>{let t=this.generateHash(e);return r[t]?{...e,keys:r[t]}:e});this.setHotkeys(n)}getValidDefinitions(e){let t=Array.isArray(e)?[...e]:this._parseToArrayLike(e);return t.forEach(e=>{void 0===e.isEditable&&(e.isEditable=!0)}),t}getValidHotkeyDefinitions(e){let t=this.getValidDefinitions(e),r={};return t.forEach(e=>{let{commandName:t,commandOptions:n}=e;r[jE()({commandName:t,commandOptions:n})]=e}),r}_parseToArrayLike(e={}){return Object.entries({...e}).map(e=>this._parseToHotKeyObj(e[0],e[1]))}_parseToHotKeyObj(e,t){return{commandName:e,...t}}registerHotkeys({commandName:e,commandOptions:t={},context:r,keys:n,label:a,isEditable:i}){if(!e)throw Error(`No command was defined for hotkey "${n}"`);let o=this.generateHash({commandName:e,commandOptions:t}),s=this.hotkeyDefinitions[o];if(s&&s.keys===n)return void console.debug("HotkeysManager: Identical hotkey registration skipped.");let l=JSON.parse(localStorage.getItem("user-preferred-keys")||"{}");s&&(l[o]=n,localStorage.setItem("user-preferred-keys",JSON.stringify(l)),this._unbindHotkeys(e,s.keys)),this.hotkeyDefinitions[o]={commandName:e,commandOptions:t,keys:n,label:a,isEditable:i},this._bindHotkeys(e,t,r,n)}_bindHotkeys(e,t={},r,n){if(""===n||void 0===n)return;let a=n instanceof Array?n.join("+"):n;R2.bind(a,n=>{n.preventDefault(),n.stopPropagation(),this._commandsManager.runCommand(e,{evt:n,...t},r),this._broadcastEvent(jO.EVENTS.HOTKEY_PRESSED,{commandName:e,commandOptions:t,keys:a,context:r,evt:n})})}_unbindHotkeys(e,t){if(""!==t&&void 0!==t){if(t instanceof Array){let r=t.join("+");this._unbindHotkeys(e,r);return}R2.unbind(t)}}}jO.EVENTS={HOTKEY_PRESSED:"event::hotkeysManager:hotkeyPressed"};var jN=d(313),jR=d.n(jN);(eIQ=eTE||(eTE={})).ERROR_EVENT="CORNERSTONE_ERROR",eIQ.CACHE_SIZE_EXCEEDED="CACHE_SIZE_EXCEEDED",eIQ.IMAGE_LOAD_ERROR="IMAGE_LOAD_ERROR",eIQ.CAMERA_MODIFIED="CORNERSTONE_CAMERA_MODIFIED",eIQ.CAMERA_RESET="CORNERSTONE_CAMERA_RESET",eIQ.VOI_MODIFIED="CORNERSTONE_VOI_MODIFIED",eIQ.PRESET_MODIFIED="CORNERSTONE_VIEWPORT_RENDERING_PRESET_MODIFIED",eIQ.DISPLAY_AREA_MODIFIED="CORNERSTONE_DISPLAY_AREA_MODIFIED",eIQ.ELEMENT_DISABLED="CORNERSTONE_ELEMENT_DISABLED",eIQ.ELEMENT_ENABLED="CORNERSTONE_ELEMENT_ENABLED",eIQ.IMAGE_RENDERED="CORNERSTONE_IMAGE_RENDERED",eIQ.VIEWPORT_FIDELITY_CHANGED="CORNERSTONE_VIEWPORT_FIDELITY_CHANGED",eIQ.IMAGE_VOLUME_MODIFIED="CORNERSTONE_IMAGE_VOLUME_MODIFIED",eIQ.IMAGE_VOLUME_LOADING_COMPLETED="CORNERSTONE_IMAGE_VOLUME_LOADING_COMPLETED",eIQ.IMAGE_VOLUME_LOADING_CANCELLED="CORNERSTONE_IMAGE_VOLUME_LOADING_CANCELLED",eIQ.IMAGE_LOADED="CORNERSTONE_IMAGE_LOADED",eIQ.IMAGE_RETRIEVAL_STAGE="CORNERSTONE_IMAGE_RETRIEVAL_STAGE",eIQ.IMAGE_LOAD_FAILED="CORNERSTONE_IMAGE_LOAD_FAILED",eIQ.VOLUME_VIEWPORT_NEW_VOLUME="CORNERSTONE_VOLUME_VIEWPORT_NEW_VOLUME",eIQ.VOLUME_LOADED="CORNERSTONE_VOLUME_LOADED",eIQ.VOLUME_LOADED_FAILED="CORNERSTONE_VOLUME_LOADED_FAILED",eIQ.IMAGE_CACHE_IMAGE_ADDED="CORNERSTONE_IMAGE_CACHE_IMAGE_ADDED",eIQ.IMAGE_CACHE_IMAGE_REMOVED="CORNERSTONE_IMAGE_CACHE_IMAGE_REMOVED",eIQ.VOLUME_CACHE_VOLUME_ADDED="CORNERSTONE_VOLUME_CACHE_VOLUME_ADDED",eIQ.VOLUME_CACHE_VOLUME_REMOVED="CORNERSTONE_VOLUME_CACHE_VOLUME_REMOVED",eIQ.VOLUME_TEXTURE_LIMITS_CHANGED="CORNERSTONE_VOLUME_TEXTURE_LIMITS_CHANGED",eIQ.STACK_NEW_IMAGE="CORNERSTONE_STACK_NEW_IMAGE",eIQ.VOLUME_NEW_IMAGE="CORNERSTONE_VOLUME_NEW_IMAGE",eIQ.PRE_STACK_NEW_IMAGE="CORNERSTONE_PRE_STACK_NEW_IMAGE",eIQ.IMAGE_SPACING_CALIBRATED="CORNERSTONE_IMAGE_SPACING_CALIBRATED",eIQ.VIEWPORT_NEW_IMAGE_SET="CORNERSTONE_VIEWPORT_NEW_IMAGE_SET",eIQ.STACK_VIEWPORT_SCROLL="CORNERSTONE_STACK_VIEWPORT_SCROLL",eIQ.STACK_SCROLL_OUT_OF_BOUNDS="STACK_SCROLL_OUT_OF_BOUNDS",eIQ.GEOMETRY_CACHE_GEOMETRY_ADDED="CORNERSTONE_GEOMETRY_CACHE_GEOMETRY_ADDED",eIQ.GEOMETRY_CACHE_GEOMETRY_REMOVED="CORNERSTONE_GEOMETRY_CACHE_GEOMETRY_REMOVED",eIQ.VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS="VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS",eIQ.VOLUME_VIEWPORT_SCROLL="VOLUME_VIEWPORT_SCROLL",eIQ.CLIPPING_PLANES_UPDATED="CORNERSTONE_CLIPPING_PLANES_UPDATED",eIQ.WEB_WORKER_PROGRESS="CORNERSTONE_WEB_WORKER_PROGRESS",eIQ.COLORMAP_MODIFIED="CORNERSTONE_COLORMAP_MODIFIED",eIQ.DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED="DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED",eIQ.DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED="DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED",eIQ.DYNAMIC_VOLUME_DIMENSION_GROUP_LOADED="DYNAMIC_VOLUME_DIMENSION_GROUP_LOADED",eIQ.DYNAMIC_VOLUME_TIME_POINT_LOADED="DYNAMIC_VOLUME_TIME_POINT_LOADED",eIQ.GEOMETRY_LOADED="GEOMETRY_LOADED",eIQ.GEOMETRY_LOAD_PROGRESS="GEOMETRY_LOAD_PROGRESS",eIQ.GEOMETRY_LOADED_FAILED="GEOMETRY_LOADED_FAILED",eIQ.ACTORS_CHANGED="CORNERSTONE_ACTORS_CHANGED",eIQ.RENDER_BACKEND_CHANGED="CORNERSTONE_RENDER_BACKEND_CHANGED",eIQ.WEBGL_CONTEXT_LOST="CORNERSTONE_WEBGL_CONTEXT_LOST",eIQ.WEBGL_CONTEXT_RESTORED="CORNERSTONE_WEBGL_CONTEXT_RESTORED",eIQ.RENDER_PATH_ERROR="CORNERSTONE_RENDER_PATH_ERROR",eIQ.RENDERING_PIPELINE_CHANGED="CORNERSTONE_RENDERING_PIPELINE_CHANGED";let jL=eTE;(eI0=eTD||(eTD={})).Interaction="interaction",eI0.Thumbnail="thumbnail",eI0.Prefetch="prefetch",eI0.Compute="compute";let jj=eTD;(eI1=eTA||(eTA={})).STACK="stack",eI1.ORTHOGRAPHIC="orthographic",eI1.PERSPECTIVE="perspective",eI1.VOLUME_3D="volume3d",eI1.VOLUME_3D_NEXT="volume3dNext",eI1.PLANAR_NEXT="planarNext",eI1.VIDEO="video",eI1.VIDEO_NEXT="videoNext",eI1.WHOLE_SLIDE="wholeSlide",eI1.WHOLE_SLIDE_NEXT="wholeSlideNext",eI1.ECG="ecg",eI1.ECG_NEXT="ecgNext";let jV=eTA,jF={STACK:jV.STACK,ORTHOGRAPHIC:jV.ORTHOGRAPHIC,PERSPECTIVE:jV.PERSPECTIVE,VOLUME_3D:jV.VOLUME_3D,VOLUME_3D_NEXT:jV.VOLUME_3D_NEXT,PLANAR_NEXT:jV.PLANAR_NEXT,VIDEO:jV.VIDEO,VIDEO_NEXT:jV.VIDEO_NEXT,WHOLE_SLIDE:jV.WHOLE_SLIDE,WHOLE_SLIDE_NEXT:jV.WHOLE_SLIDE_NEXT,ECG:jV.ECG,ECG_NEXT:jV.ECG_NEXT};(eI2=eTO||(eTO={}))[eI2.NEAREST=0]="NEAREST",eI2[eI2.LINEAR=1]="LINEAR",eI2[eI2.FAST_LINEAR=2]="FAST_LINEAR";let jB=eTO;var jW={COMPOSITE_BLEND:0,MAXIMUM_INTENSITY_BLEND:1,MINIMUM_INTENSITY_BLEND:2,AVERAGE_INTENSITY_BLEND:3,ADDITIVE_INTENSITY_BLEND:4,RADON_TRANSFORM_BLEND:5,LABELMAP_EDGE_PROJECTION_BLEND:6},jU={BlendMode:jW};let{BlendMode:jz}=jU;(eI5=eTN||(eTN={}))[eI5.COMPOSITE=jz.COMPOSITE_BLEND]="COMPOSITE",eI5[eI5.MAXIMUM_INTENSITY_BLEND=jz.MAXIMUM_INTENSITY_BLEND]="MAXIMUM_INTENSITY_BLEND",eI5[eI5.MINIMUM_INTENSITY_BLEND=jz.MINIMUM_INTENSITY_BLEND]="MINIMUM_INTENSITY_BLEND",eI5[eI5.AVERAGE_INTENSITY_BLEND=jz.AVERAGE_INTENSITY_BLEND]="AVERAGE_INTENSITY_BLEND",eI5[eI5.LABELMAP_EDGE_PROJECTION_BLEND=jz.LABELMAP_EDGE_PROJECTION_BLEND]="LABELMAP_EDGE_PROJECTION_BLEND";let jH=eTN;(eI3=eTR||(eTR={})).AXIAL="axial",eI3.CORONAL="coronal",eI3.SAGITTAL="sagittal",eI3.ACQUISITION="acquisition",eI3.AXIAL_REFORMAT="axial_reformat",eI3.CORONAL_REFORMAT="coronal_reformat",eI3.SAGITTAL_REFORMAT="sagittal_reformat",eI3.REFORMAT="reformat";let jG=eTR;(eI4=eTL||(eTL={})).CONTOUR="CONTOUR",eI4.SURFACE="SURFACE",eI4.MESH="MESH";let jq=eTL;(eI8=eTj||(eTj={})).CLOSED_PLANAR="CLOSED_PLANAR",eI8.OPEN_PLANAR="OPEN_PLANAR",(eI6=eTV||(eTV={})).PLY="PLY",eI6.STL="STL",eI6.OBJ="OBJ",eI6.VTP="VTP";let j$=eTV;(eI9=eTF||(eTF={})).LINEAR="LINEAR",eI9.SAMPLED_SIGMOID="SIGMOID",eI9.LINEAR_EXACT="LINEAR_EXACT";let jK=eTF;(eI7=eTB||(eTB={})).SUM="SUM",eI7.AVERAGE="AVERAGE",eI7.SUBTRACT="SUBTRACT";class jY{constructor(e){this.fullDate=e}getTimeInSec(){let e=this.fullDate.substring(0,10),t=this.fullDate.substring(11,28),r=parseInt(e.substring(0,4),10),n=e.length>=7?parseInt(e.substring(5,7),10):void 0,a=e.length>=10?parseInt(e.substring(8,10),10):void 0;if(isNaN(r)||void 0!==n&&isNaN(n)||void 0!==a&&isNaN(a)||r>3e3||n&&(n<1||n>12)||a&&(a<1||a>31))throw Error(`invalid date '${e}'`);let i=new Date(`${e}T00:00:00.000000Z`),o=parseInt(t.substring(0,2),10),s=t.length>=5?parseInt(t.substring(3,5),10):void 0,l=t.length>=8?parseInt(t.substring(6,8),10):void 0,d=t.substring(9,15),u=d?parseInt(d,10)*Math.pow(10,-d.length):void 0;if(isNaN(o)||void 0!==s&&isNaN(s)||void 0!==l&&isNaN(l)||void 0!==u&&isNaN(u)||o<0||o>23||s&&(s<0||s>59)||l&&(l<0||l>59)||u&&(u<0||u>999999))throw Error(`invalid time '${t}'`);let c=i.getTime()/1e3;return c+=3600*o,void 0!==s&&(c+=60*s),void 0!==l&&(c+=l),void 0!==u&&(c+=u),c}getTimeInMicroSec(){return 1e6*this.getTimeInSec()}}function jX(e,t){let r=`${t.hours||"00"}`.padStart(2,"0"),n=`${t.minutes||"00"}`.padStart(2,"0"),a=`${t.seconds||"00"}`.padStart(2,"0"),i=`${e.month}`.padStart(2,"0"),o=`${e.day}`.padStart(2,"0"),s=`${t.fractionalSeconds||"000000"}`.padEnd(6,"0"),l=`${e.year}-${i}-${o}`,d=`T${r}:${n}:${a}.${s}Z`;return new jY(`${l}${d}`)}function jZ(e){if(null==e||8!==e.length||"string"!=typeof e)throw Error(`invalid DA '${e}'`);let t=parseInt(e.substring(0,4),10),r=parseInt(e.substring(4,6),10),n=parseInt(e.substring(6,8),10);if(!0!=(!isNaN(t)&&r>0&&r<=12&&n>0&&n<=function(e,t){switch(e){case 2:return t%4==0&&t%100||t%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(r,t)))throw Error(`invalid DA '${e}'`);return{year:t,month:r,day:n}}function jJ(e){if(null==e||e.length<2||"string"!=typeof e)throw Error(`invalid TM '${e}'`);let t=parseInt(e.substring(0,2),10),r=e.length>=4?parseInt(e.substring(2,4),10):void 0,n=e.length>=6?parseInt(e.substring(4,6),10):void 0,a=e.length>=8?e.substring(7,13):void 0,i=a?parseInt(a,10)*Math.pow(10,6-a.length):void 0;if(isNaN(t)||void 0!==r&&isNaN(r)||void 0!==n&&isNaN(n)||void 0!==i&&isNaN(i)||t<0||t>23||r&&(r<0||r>59)||n&&(n<0||n>59)||i&&(i<0||i>999999))throw Error(`invalid TM '${e}'`);return{hours:t,minutes:r,seconds:n,fractionalSeconds:i}}function jQ(e){if(null==e)throw Error("dateTimeToFullDateInterface : dateTime not defined.");return jX(jZ(e.substring(0,8)),jJ(e.substring(8)))}function j0(e){let t,r,{CorrectedImage:n,Units:a,PhilipsPETPrivateGroup:i,PatientWeight:o,PatientSex:s,PatientSize:l}=e[0];if(!n.includes("ATTN")||!n.includes("DECY"))throw Error(`CorrectedImage must contain "ATTN" and "DECY": ${n}`);if(!e.every(t=>{let r;return t.Units===a&&((r=t.CorrectedImage)===n||Array.isArray(r)&&Array.isArray(n)&&r.length===n.length&&r.every((e,t)=>e===n[t]))&&t.PatientWeight===o&&t.PatientSex===s&&t.PatientSize===l&&t.RadionuclideHalfLife===e[0].RadionuclideHalfLife&&t.RadionuclideTotalDose===e[0].RadionuclideTotalDose&&t.DecayCorrection===e[0].DecayCorrection&&t.SeriesDate===e[0].SeriesDate&&t.SeriesTime===e[0].SeriesTime}))throw Error("The set of instances does not appear to come from one Series. Every instance must have identical values for series-level metadata properties");if(null==o)throw Error("PatientWeight value is missing. It is not possible to calculate the SUV factors");let d=Array(e.length);d=function(e){let{RadionuclideTotalDose:t,RadionuclideHalfLife:r,RadiopharmaceuticalStartDateTime:n,RadiopharmaceuticalStartTime:a,SeriesDate:i}=e[0];if(null==t)throw Error("calculateDecayCorrection : RadionuclideTotalDose value not found.");if(null==r)throw Error("calculateDecayCorrection : RadionuclideHalfLife value not found.");let o=function(e){let{SeriesDate:t,SeriesTime:r,GEPrivatePostInjectionDateTime:n}=e[0],a=Array(e.length),i=jX(jZ(t),jJ(r)),o=new jY("3000-01-01T00:00:00.000000Z"),s=o.getTimeInSec();if(e.forEach(e=>{let{AcquisitionDate:t,AcquisitionTime:r}=e,n=jX(jZ(t),jJ(r));o=o.getTimeInSec()>=s||n.getTimeInSec()<o.getTimeInSec()?n:o}),o.getTimeInSec()>=s)throw Error("Earliest acquisition time or date could not be parsed.");return i.getTimeInSec()<=o.getTimeInSec()?a.fill(i):n?a.fill(jQ(n)):a.fill(o)}(e),s=function(e){let t,{RadiopharmaceuticalStartDateTime:r,RadiopharmaceuticalStartTime:n,SeriesDate:a}=e;if(r)return jQ(r);if(n&&a)return t=jJ(n),jX(jZ(a),t);throw Error(`Invalid input: ${e}`)}({RadiopharmaceuticalStartDateTime:n,RadiopharmaceuticalStartTime:a,SeriesDate:i});return e.map((e,n)=>{let a=o[n].getTimeInSec()-s.getTimeInSec();if(a<0)throw Error("Decay time cannot be less than zero");return 1/(t*Math.pow(2,-a/r))})}(e);let u=Array(e.length),c=1e3*o;if("BQML"===a)u=d.map(function(e){return e*c});else if("CNTS"===a){let t=e.every(e=>{var t,r,n;return e.PhilipsPETPrivateGroup&&(null==(t=e.PhilipsPETPrivateGroup)?void 0:t.SUVScaleFactor)!==null&&(null==(r=e.PhilipsPETPrivateGroup)?void 0:r.SUVScaleFactor)!==void 0&&(null==(n=e.PhilipsPETPrivateGroup)?void 0:n.SUVScaleFactor)!==0}),r=e.every(e=>{var t,r,n;return e.PhilipsPETPrivateGroup&&!(null!=(t=e.PhilipsPETPrivateGroup)&&t.SUVScaleFactor)&&(null==(r=e.PhilipsPETPrivateGroup)?void 0:r.ActivityConcentrationScaleFactor)!==void 0&&(null==(n=e.PhilipsPETPrivateGroup)?void 0:n.ActivityConcentrationScaleFactor)!==0});if(t)u=e.map(e=>e.PhilipsPETPrivateGroup.SUVScaleFactor);else if(r)u=e.map((e,t)=>e.PhilipsPETPrivateGroup.ActivityConcentrationScaleFactor*d[t]*c);else throw Error(`Units are in CNTS, but PhilipsPETPrivateGroup has invalid values: ${JSON.stringify(i)}`)}else if("GML"===a)u.fill(1);else throw Error(`Units has an invalid value: ${a}`);return null==l?console.warn("PatientSize value is missing. It is not possible to calculate the SUV bsa factors"):t=function(e){let{PatientWeight:t,PatientSize:r}=e;return Math.pow(t,.425)*Math.pow(100*r,.725)*71.84}({PatientWeight:o,PatientSize:l}),null==l?console.warn("PatientSize value is missing. It is not possible to calculate the SUV lbm factors"):null==s?console.warn("PatientSex value is missing. It is not possible to calculate the SUV lbm factors"):r=function(e){let t,{PatientSex:r,PatientWeight:n,PatientSize:a}=e,i=n*n/(a*a*1e4);if("F"===r)t=1.07*n-148*i;else if("M"===r)t=1.1*n-120*i;else throw Error(`PatientSex is an invalid value: ${r}`);return 1e3*t}({PatientWeight:o,PatientSex:s,PatientSize:l}),u.map(function(e,n){let a={suvbw:e};return t&&(a.suvbsa=d[n]*t),r&&(a.suvlbm=d[n]*r),a})}(eTe=eTW||(eTW={})).NOT_APPLICABLE="",eTe.ERMF="ERMF",eTe.USER="User",eTe.PROJECTION="Proj",eTe.REGION="Region",eTe.ERROR="Error",eTe.UNCALIBRATED="Uncalibrated",eTe.CALIBRATED="Calibrated",eTe.UNKNOWN="Unknown";let j1=eTW;(eTt=eTU||(eTU={})).CALIBRATION="calibrationModule",eTt.CINE="cineModule",eTt.FRAME_OF_REFERENCE="frameOfReferenceModule",eTt.GENERAL_IMAGE="generalImageModule",eTt.GENERAL_SERIES="generalSeriesModule",eTt.GENERAL_STUDY="generalStudyModule",eTt.IMAGE_PIXEL="imagePixelModule",eTt.IMAGE_PLANE="imagePlaneModule",eTt.IMAGE_URL="imageUrlModule",eTt.MODALITY_LUT="modalityLutModule",eTt.MULTIFRAME="multiframeModule",eTt.NM_MULTIFRAME_GEOMETRY="nmMultiframeGeometryModule",eTt.OVERLAY_PLANE="overlayPlaneModule",eTt.PATIENT="patientModule",eTt.PATIENT_DEMOGRAPHIC="patientDemographicModule",eTt.PATIENT_STUDY="patientStudyModule",eTt.PET_IMAGE="petImageModule",eTt.PET_ISOTOPE="petIsotopeModule",eTt.PET_SERIES="petSeriesModule",eTt.SCALING="scalingModule",eTt.SOP_COMMON="sopCommonModule",eTt.ULTRASOUND_ENHANCED_REGION="ultrasoundEnhancedRegionModule",eTt.ECG="ecgModule",eTt.VOI_LUT="voiLutModule",eTt.TRANSFER_SYNTAX="transferSyntax",eTt.PLANE_ORIENTATION="PlaneOrientation",eTt.PLANE_POSITION="PlanePosition",eTt.PIXEL_MEASURES="PixelMeasures",eTt.XRAY_GEOMETRY="XrayGeometry",eTt.FRAME_PIXEL_DATA="FramePixelData",eTt.FRAME_MODULE="frameModule",eTt.URI_MODULE="uriModule",eTt.WADO_WEB_CLIENT="wadoWebClient",eTt.INSTANCE="instance",eTt.IMAGE_SOP_INSTANCE_REFERENCE="ImageSopInstanceReference",eTt.REFERENCED_SERIES_REFERENCE="ReferencedSeriesReference",eTt.PREDECESSOR_SEQUENCE="PredecessorSequence",eTt.STUDY_DATA="StudyData",eTt.SERIES_DATA="SeriesData",eTt.IMAGE_DATA="ImageData",eTt.RTSS_INSTANCE_DATA="RtssInstanceData",eTt.NEW_INSTANCE_DATA="NewInstanceData",eTt.RTSS_CONTOUR="metaRTSSContour",eTt.SEG_BIT="metaSegBitmap",eTt.SR_ANNOTATION="metaSrAnnotation",eTt.COMPRESSED_FRAME_DATA="compressedFrameData",eTt.BASE_IMAGE_ID="baseImageId",eTt.FRAME_IMAGE_IDS="frameImageIds",eTt.NATURALIZED="naturalized",eTt.DISPLAY_SET="displaySetModule";let j2=eTU,j5={IMPLICIT_VR_LITTLE_ENDIAN:Nl.constants.IMPLICIT_LITTLE_ENDIAN,EXPLICIT_VR_LITTLE_ENDIAN:Nl.constants.EXPLICIT_LITTLE_ENDIAN,DEFLATED_EXPLICIT_VR_LITTLE_ENDIAN:Nl.constants.DEFLATED_EXPLICIT_LITTLE_ENDIAN,EXPLICIT_VR_BIG_ENDIAN:Nl.constants.EXPLICIT_BIG_ENDIAN,RLE_LOSSLESS:"1.2.840.10008.1.2.5",MPEG2_MAIN_PROFILE_MAIN_LEVEL:"1.2.840.10008.1.2.4.100",MPEG2_MAIN_PROFILE_MAIN_LEVEL_FRAGMENTABLE:"1.2.840.10008.1.2.4.100.1",MPEG2_MAIN_PROFILE_HIGH_LEVEL:"1.2.840.10008.1.2.4.101",MPEG2_MAIN_PROFILE_HIGH_LEVEL_FRAGMENTABLE:"1.2.840.10008.1.2.4.101.1",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1:"1.2.840.10008.1.2.4.102",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE:"1.2.840.10008.1.2.4.102.1",MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1:"1.2.840.10008.1.2.4.103",MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE:"1.2.840.10008.1.2.4.103.1",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO:"1.2.840.10008.1.2.4.104",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO_FRAGMENTABLE:"1.2.840.10008.1.2.4.104.1",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO:"1.2.840.10008.1.2.4.105",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO_FRAGMENTABLE:"1.2.840.10008.1.2.4.105.1",MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2:"1.2.840.10008.1.2.4.106",MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2_FRAGMENTABLE:"1.2.840.10008.1.2.4.106.1",HEVC_H265_MAIN_PROFILE_LEVEL_5_1:"1.2.840.10008.1.2.4.107",HEVC_H265_MAIN_10_PROFILE_LEVEL_5_1:"1.2.840.10008.1.2.4.108"},j3=Rt.getLogger("metaData"),j4=[],j8=new Map,j6=new Map;function j9(e,t=0){let r;if(!j4.some(t=>t.provider===e)){for(r=0;r<j4.length&&!(j4[r].priority<=t);r++);j4.splice(r,0,{priority:t,provider:e})}}function j7(e,t,r){let n=j6.get(e);if(n)return n(t,null,r)}function Ve(e){for(let t=0;t<j4.length;t++)if(j4[t].provider===e){j4.splice(t,1);break}}function Vt(){for(;j4.length>0;)j4.pop();j8.clear(),j6.clear()}function Vr(e,t,r){if(void 0!==t)for(let n=0;n<j4.length;n++){let a=j4[n].provider(e,t,r);if(void 0!==a)return a}}function Vn(e,t,r){return Vr(e,t,r)}let Va=(e,t)=>{var r;for(let n of[e,(r=e,`${r}Add`)]){let e=j8.get(n);if(e)for(let r of e)r?.clearQuery?.(t)}},Vi=e=>{var t;for(let r of Array.from(new Set([e,(t=e,`${t}Add`)]))){let e=j8.get(r);if(e)for(let t of e)t?.clear?.()}},Vo=(e,...t)=>1===t.length?Vr(e,t[0]):t.map(t=>t&&Vr(e,t)).find(e=>void 0!==e);function Vs(e,t,r=Vr){let n={};for(let a of t)try{let t=r(a,e);if(t){let e={};for(let r in t)r in t&&(e[Vl(r)]=t[r]);Object.assign(n,e)}}catch(e){j3.error(`Error retrieving ${a} data:`,e)}return n}let Vl=e=>e.startsWith("sop")?`SOP${e.substring(3)}`:e.startsWith("voi")?`VOI${e.substring(3)}`:(e.endsWith("Id")&&(e=`${e.substring(0,e.length-2)}ID`),e.charAt(0).toUpperCase()+e.slice(1)),Vd=e=>e.startsWith("SOP")?`sop${e.substring(3)}`:e.startsWith("VOI")?`voi${e.substring(3)}`:(e.endsWith("ID")&&!e.endsWith("UID")&&(e=`${e.substring(0,e.length-2)}Id`),e.charAt(0).toLowerCase()+e.slice(1)),Vu=new Set([j5.MPEG2_MAIN_PROFILE_MAIN_LEVEL,j5.MPEG2_MAIN_PROFILE_MAIN_LEVEL_FRAGMENTABLE,j5.MPEG2_MAIN_PROFILE_HIGH_LEVEL,j5.MPEG2_MAIN_PROFILE_HIGH_LEVEL_FRAGMENTABLE,j5.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1,j5.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE,j5.MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1,j5.MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE,j5.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO,j5.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO_FRAGMENTABLE,j5.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO,j5.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO_FRAGMENTABLE,j5.MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2,j5.MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2_FRAGMENTABLE,j5.HEVC_H265_MAIN_PROFILE_LEVEL_5_1,j5.HEVC_H265_MAIN_10_PROFILE_LEVEL_5_1]);function Vc(e){return!!e&&(Array.isArray(e)?e:[e]).find(e=>Vu.has(e))}let Vh=/^[a-zA-Z]+:/;function Vp(e){if(!e)return"";let t=e.match(Vh);if(!t)return e;let r=e.substring(t[0].length);return Vh.test(r)?r:e}let Vm=Rt.getLogger("utilities.getPixelSpacingInformation"),Vf=new Set(["1.2.840.10008.5.1.4.1.1.1","1.2.840.10008.5.1.4.1.1.1.1","1.2.840.10008.5.1.4.1.1.1.1.1","1.2.840.10008.5.1.4.1.1.1.2","1.2.840.10008.5.1.4.1.1.1.2.1","1.2.840.10008.5.1.4.1.1.1.3","1.2.840.10008.5.1.4.1.1.1.3.1","1.2.840.10008.5.1.4.1.1.12.1","1.2.840.10008.5.1.4.1.1.12.1.1","1.2.840.10008.5.1.4.1.1.12.2","1.2.840.10008.5.1.4.1.1.12.2.1","1.2.840.10008.5.1.4.1.1.12.3"]);function Vg(e){let{PixelSpacing:t,ImagerPixelSpacing:r,EstimatedRadiographicMagnificationFactor:n,DistanceSourceToDetector:a,DistanceSourceToEntrance:i,DistanceSourceToPatient:o=i}=e;return n>1?n:o<a?a/o:r?.[0]>t?.[0]||void 0}function Vy(e){let{PixelSpacing:t,ImagerPixelSpacing:r,PixelSpacingCalibrationType:n}=e;if(t&&"GEOMETRY"===n)return N8(t,r)&&Vm.warn("Calibration type is geometry, but pixel spacing and imager pixel spacing identical",t,r),{PixelSpacing:t,type:j1.ERMF,isProjection:!0};if(t&&"FIDUCIAL"===n)return{PixelSpacing:t,type:j1.CALIBRATED,isProjection:!0};if(r){let n=Vg(e);return n>1?{PixelSpacing:r.map(e=>e/n),type:j1.ERMF,isProjection:!0}:!0===n?{PixelSpacing:t,type:j1.ERMF,isProjection:!0}:(n&&Vm.error("Illegal ERMF value:",n),{PixelSpacing:t||r,type:j1.PROJECTION,isProjection:!0})}return{PixelSpacing:t,type:j1.UNKNOWN,isProjection:!0}}function Vv(e){let{PixelSpacing:t,SOPClassUID:r}=e;return Vf.has(r)?Vy(e):{PixelSpacing:t,type:j1.NOT_APPLICABLE,isProjection:!1}}let Vb=new Map,Vx={add:(e,t)=>{let r=Vp(e);Vb.set(r,t),Va(j2.IMAGE_PLANE,e)},get:(e,t)=>{if("calibratedPixelSpacing"===e){let e=Vp(t);return Vb.get(e)}},clear:()=>{Vb.clear()}},Vw=Rt.getLogger("utilities.splitImageIdsBy4DTags");function VC(e,t){let r=/\/frames\/\d+/,n=/([?&])frame=\d+/;if(r.test(e))return e.replace(r,`/frames/${t}`);if(n.test(e))return e.replace(n,(e,r)=>`${r}frame=${t}`);let a=e.includes("?")?"&":"?";return`${e}${a}frame=${t}`}function Vk(e){if(!e||0===e.length)return null;let t=e[0],r=Vo("instance",t);if(!r)return null;let n=r.NumberOfFrames;if(!n||n<=1)return null;let a=r.TimeSlotVector;if(!a||!Array.isArray(a))return null;let i=r.SliceVector,o=r.NumberOfSlices;if(a.length!==n)return Vw.warn("TimeSlotVector length does not match NumberOfFrames:",a.length,"vs",n),null;if(i){if(!Array.isArray(i))return Vw.warn("SliceVector exists but is not an array. Expected length:",n),null;if(i.length!==n||i.some(e=>void 0===e))return Vw.warn("SliceVector exists but has invalid length or undefined entries. Expected length:",n,"Actual length:",i.length),null}let s=new Map;for(let e=0;e<n;e++){let t=a[e],r=i?.[e]??e;s.has(t)||s.set(t,[]),s.get(t).push({frameIndex:e,sliceIndex:r})}let l=Array.from(s.keys()).sort((e,t)=>e-t).map(e=>{let r=s.get(e);return r.sort((e,t)=>e.sliceIndex-t.sliceIndex),r.map(e=>VC(t,e.frameIndex+1))}),d=o||l[0]?.length;return l.every(e=>e.length===d)||Vw.warn("Multiframe 4D split resulted in uneven time slot groups. Expected",d,"slices per time slot."),{imageIdGroups:l,splittingTag:"TimeSlotVector"}}function VM(e,t){let r=Vo(t,e);try{return parseFloat(r)}catch{return}}function VS(e,t){var r;return NQ(r=VM(e,t))||!N0(r)?N1(r,void 0):Array.from(r,e=>N1(e,void 0))}function VI(e){let t=Vo("20011003",e);try{let{InlineBinary:e}=t;if(e){let t=atob(e),r=new ArrayBuffer(t.length),n=new DataView(r);for(let e=0;e<t.length;e++)n.setUint8(e,t.charCodeAt(e));return new Float32Array(r)[0]}return parseFloat(t)}catch{return}}function VT(e){let t=Vo("0019100c",e)||Vo("0019100C",e);try{let{InlineBinary:e}=t;return e&&(t=atob(e)),parseFloat(t)}catch{return}}function V_(e){let t=Vo("00431039",e);try{let{InlineBinary:e}=t;return e&&(t=atob(e).split("//")),parseFloat(t[0])%1e5}catch{return}}function VP(e){let t=Vo("petImageModule",e);return t?t.frameReferenceTime:0}let VE=function(e){let t=Vk(e);if(t)return t;let r=function(e){let t;if(!e||0===e.length||void 0===VS(e[0],"CardiacNumberOfImages"))return null;let r=new Map;for(let t of e){let e=Vo("StackID",t),n=VS(t,"InStackPositionNumber"),a=VS(t,"TriggerTime");if(void 0===e||void 0===n||void 0===a)return null;let i=String(e);r.has(i)||r.set(i,new Map);let o=r.get(i);o.has(n)||o.set(n,[]),o.get(n).push({imageId:t,triggerTime:a})}let n=Array.from(r.keys()).sort((e,t)=>Number(e)-Number(t));if(0===n.length)return null;let a=[];for(let e of n){let n=r.get(e),i=Array.from(n.keys()).sort((e,t)=>e-t);for(let e of i){let r=n.get(e);if(r.sort((e,t)=>e.triggerTime-t.triggerTime),void 0===t)t=r.length;else if(r.length!==t)return null}a.push({stackId:e,positions:i,framesByPosition:n})}if(!t)return null;let i=[];for(let e=0;e<t;e++){let t=[];for(let r of a)for(let n of r.positions){let a=r.framesByPosition.get(n);t.push(a[e].imageId)}i.push(t)}return{imageIdGroups:i,splittingTag:"CardiacTriggerTime"}}(e);if(r)return r;let n=function(e){let t,r=e.map(e=>{let{imagePositionPatient:t}=Vo("imagePlaneModule",e)||{};return{imageId:e,imagePositionPatient:t}});if(!r.every(e=>e.imagePositionPatient))return null;let n=(t="imagePositionPatient",r.reduce((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e),{})),a=Object.keys(n),i=n[a[0]].length;return 1!==i&&a.every(e=>n[e].length===i)?n:null}(e);if(!n)return{imageIdGroups:[e],splittingTag:null};let a=["TemporalPositionIdentifier","DiffusionBValue","TriggerTime","EchoTime","EchoNumber","PhilipsPrivateBValue","SiemensPrivateBValue","GEPrivateBValue","PetFrameReferenceTime"],i=[e=>VM(e,a[0]),e=>VM(e,a[1]),e=>VM(e,a[2]),e=>VM(e,a[3]),e=>VM(e,a[4]),VI,VT,V_,VP];for(let e=0;e<i.length;e++){let t=function(e,t){let r={},n=[],a=Object.keys(e);for(let i=0;i<a.length;i++){let o=new Set,s=e[a[i]];for(let e=0;e<s.length;e++){let n=t(s[e].imageId)||0;if(r[n]=r[n]||[],r[n].push({imageId:s[e].imageId}),o.add(n),o.size-1<e)return}if(0==i)n=Array.from(o);else if(!function(e,t){if(e.length!=t.size)return!1;for(let r=0;r<e.length;r++)if(!t.has(e[r]))return!1;return!0}(n,o))return}return r}(n,i[e]);if(t)return{imageIdGroups:Object.keys(t).map(Number.parseFloat).sort((e,t)=>e-t).map(e=>t[e].map(e=>e.imageId)),splittingTag:a[e]}}return{imageIdGroups:[e],splittingTag:null}},VD=[[j2.TRANSFER_SYNTAX,["TransferSyntaxUID","AvailableTransferSyntaxUID"]],[j2.CINE,["FrameTime","RecommendedDisplayFrameRate"]],[j2.PET_ISOTOPE,[["RadiopharmaceuticalInfo","00540016"]]],["RadiopharmaceuticalInfo",["RadiopharmaceuticalStartTime","RadiopharmaceuticalStopTime","RadionuclideTotalDose","RadionuclideHalfLife"]],[j2.PET_IMAGE,["FrameReferenceTime","ActualFrameDuration"]],[j2.PET_SERIES,["CorrectedImage","Units","DecayCorrection"]],[j2.PATIENT,["PatientID","PatientName","PatientBirthDate","PatientBirthTime"]],[j2.PATIENT_STUDY,["PatientAge","PatientSize","PatientSex","PatientWeight"]],[j2.GENERAL_STUDY,["StudyInstanceUID","StudyDescription","StudyDate","StudyTime","AccessionNumber"]],[j2.GENERAL_SERIES,["StudyInstanceUID","SeriesInstanceUID","Modality","SeriesDescription","SeriesNumber","SeriesDate","SeriesTime","AcquisitionDate","AcquisitionTime"]],["clinicalTrialModule",["ClinicalTrialSponsorName","ClinicalTrialSiteID","ClinicalTrialSiteName","ClinicalTrialSubjectID"]],[j2.SOP_COMMON,["SOPInstanceUID","SOPClassUID"]],[j2.ECG,["StudyInstanceUID","SeriesInstanceUID","SeriesDescription","SeriesNumber","SeriesDate","SeriesTime","Modality","SOPInstanceUID","SOPClassUID","WaveformAnnotationSequence"]],[j2.GENERAL_IMAGE,["SOPInstanceUID","SOPClassUID","InstanceNumber","InstanceCreationDate","InstanceCreationTime","ContentTime","LossyImageCompression","LossyImageCompressionRatio","LossyImageCompressionMethod","FrameOfReferenceUID","NumberOfFrames","PixelSpacing"]],[j2.IMAGE_PLANE,["ImagerPixelSpacing","ImageOrientationPatient","ImagePositionPatient","SpacingBetweenSlices","SliceThickness","SliceLocation"]],[j2.IMAGE_PIXEL,["SamplesPerPixel","PhotometricInterpretation","PlanarConfiguration","Rows","Columns","BitsAllocated","BitsStored","HighBit","PixelRepresentation",["SmallestPixelValue","00280106"],["LargestPixelValue","00280107"],"PixelPaddingValue","PixelPaddingRangeLimit","RedPaletteColorLookupTableDescriptor","GreenPaletteColorLookupTableDescriptor","BluePaletteColorLookupTableDescriptor","AlphaPaletteColorLookupTableDescriptor","RedPaletteColorLookupTableData","GreenPaletteColorLookupTableData","BluePaletteColorLookupTableData","AlphaPaletteColorLookupTableData","PaletteColorLookupTableUID","DistanceSourceToDetector","DistanceSourceToPatient","EstimatedRadiographicMagnificationFactor","DistanceSourceToEntrance","PixelSpacingCalibrationType","PixelSpacingCalibrationDescription","SequenceOfUltrasoundRegions"]],[j2.VOI_LUT,["WindowCenter","WindowWidth","VOILUTFunction","WindowCenterWidthExplanation"]],[j2.MODALITY_LUT,["RescaleIntercept","RescaleSlope","RescaleType"]],[j2.ULTRASOUND_ENHANCED_REGION,["SequenceOfUltrasoundRegions"]],["usRegionChild",["PhysicalDeltaX","PhysicalDeltaY","PhysicalUnitsXDirection","PhysicalUnitsYDirection","RegionLocationMinY0","RegionLocationMaxY1","RegionLocationMinX0","RegionLocationMaxX1","ReferencePixelX0","ReferencePixelY0",["ReferencePhysicalPixelValueY","0018602A"],["ReferencePhysicalPixelValueX","00186028"],"RegionSpatialFormat","RegionDataType","RegionFlags","TransducerFrequency"]],[null,["ReferencedImageSequence","ReferencedSOPClassUID","ReferencedSOPInstanceUID","ReferencedFrameNumber","SharedFunctionalGroupsSequence","PerFrameFunctionalGroupsSequence","PlanePositionSequence","AnatomicRegionSequence","PlaneOrientationSequence","PixelMeasuresSequence","PixelValueTransformationSequence","ParametricMapFrameTypeSequence","RealWorldValueMappingSequence"]]],VA=Rt.getLogger("utilities.Tags"),VO=Nl.data.DicomMetaDictionary.dictionary,VN=Nl.data.DicomMetaDictionary.nameMap,VR=new Map,VL=new Map;function Vj(e){let t=Object.prototype.hasOwnProperty.call(VN,e)?VN[e]:void 0;if(t?.tag)return t.tag.substring(1,5)+t.tag.substring(6,10)}let VV={},VF=new Map;for(let[e,t]of VD)for(let r of t){let t="string"==typeof r?r:r[0],n="string"==typeof r?void 0:r[1],a=VF.get(t);a||(a={hex:n??Vj(t),groups:[]},VF.set(t,a)),null!==e&&a.groups.push(e)}for(let[e,{hex:t,groups:r}]of VF){if(!t){VA.warn(`Tags: keyword "${e}" not found in dcmjs nameMap`);continue}!function(e,t){if(e&&t.name&&e!==t.name)throw Error(`Tag name provided and value don't match: ${e} !== ${t.name}`);t.name||=e,t.lowerName||=Vd(e),VV[e]=t;let{tag:r}=t;t.primaryGroup||=t.groups?.[0];let{groups:n}=t;if(VL.set(e,t),r&&(t.xTag=`x${r.toLowerCase()}`,t.tag=r.toUpperCase(),VL.set(t.xTag,t),VL.set(t.tag,t),!t.vr)){let e=VO[t.tag];e&&(t.vr=e.vr,t.vm=function(e){if(null==e)return null;if("number"==typeof e)return e;let t=parseInt(e,10);return String(t)===e?t:0}(e.vm))}if(n?.length)for(let r of n){let n=VR.get(r);if(!n){n=[t],VR.set(r,n);return}let a=n.findIndex(t=>t.name===e);-1===a?n.push(t):n[a]=t}}(e,function(e,...t){return{tag:e,groups:t,xTag:null,primaryGroup:null,name:null,lowerName:null,vr:null,vm:null}}(t,...r))}let{DicomMetadataListener:VB}=Nl.utilities,{pp:VW,tZ:VU,gE:Vz,Um:VH,uu:VG,UA:Vq,LL:V$,_E:VK,sM:VY,Qe:VX,xC:VZ,RZ:VJ,UX:VQ,HL:V0,U5:V1,Rm:V2}=V,{bM:V5}=V,V3=j2.FRAME_IMAGE_IDS,V4=j2.BASE_IMAGE_ID;Rt.getLogger("utilities.metadataProvider.cacheData");class V8{static setCacheDataInternal(e,t,r){let n=this.mapCacheData.get(e);n||(n=new Map,this.mapCacheData.set(e,n)),n.set(t,r),this.clearRelatedDerivedCache(e,t)}static clearRelatedDerivedCache(e,t){let r=this.secondaryTypesByBaseType.get(e);if(r?.size)for(let e of Vr(V3,t)??new Set([t]))for(let t of r){let r=this.mapCacheData.get(t);r?.delete(e)}}static registerSecondaryTypes(e,t){if(t)for(let r of Array.isArray(t)?t:[t]){let t=this.secondaryTypesByBaseType.get(r);t||(t=new Set,this.secondaryTypesByBaseType.set(r,t)),t.add(e)}}static getCacheData(e,t){return this.mapCacheData.get(e)?.get(t)}static hasCacheData(e,t){return this.mapCacheData.get(e)?.has(t)===!0}static clearCacheData(){this.mapCacheData.clear(),this.secondaryTypesByBaseType.clear(),Vi(V3),Vi(V4)}static clearTypedCacheData(e,t){let r=this.secondaryTypesByBaseType.get(e),n=this.mapCacheData.get(e);if(t){if(n?.delete(t),r?.size)for(let e of r)this.mapCacheData.get(e)?.delete(t);(e===j2.NATURALIZED||r?.size)&&(Va(V3,t),Va(V4,t));return}if(n?.clear(),r?.size)for(let e of r)this.mapCacheData.get(e)?.clear();(e===j2.NATURALIZED||r?.size)&&(Vi(V3),Vi(V4))}static fromAsyncLookup(e,t,r,n){if(n?.noCache!==!0&&n?.reCache!==!0){let r=this.getCacheData(e,t);if(void 0!==r)return r}let a=r();if(void 0!==a)return a instanceof Promise?a.then(r=>(void 0===r||n?.noCache||this.setCacheDataInternal(e,t,r),r)):(n?.noCache||this.setCacheDataInternal(e,t,a),a)}createTypeCacheProvider(e){var t;return t=e,(e,r,n,a)=>V8.fromAsyncLookup(t,r,()=>e(r,n,a),a)}clearCacheData(){V8.clearCacheData()}clearTypedCacheData(e,t){V8.clearTypedCacheData(e,t)}getCacheData(e,t){return V8.getCacheData(e,t)}hasCacheData(e,t){return V8.hasCacheData(e,t)}fromAsyncLookup(e,t,r,n){return V8.fromAsyncLookup(e,t,r,n)}}function V6(e){return(t,r,n,a)=>(n||=j7(e,r,a?.[e]),t(r,n,a))}V8.mapCacheData=new Map,V8.secondaryTypesByBaseType=new Map,new class e extends V8{static setCacheData(e,t,r){this.setCacheDataInternal(e,t,r)}setCacheData(t,r,n){e.setCacheData(t,r,n)}},V6(j2.INSTANCE),V6(j2.NATURALIZED);let{AsyncDicomReader:V9}=Nl.async;VH.getLogger("tagModules");let V7=/(\/frames\/|[&?]frameNumber=|[&?]frame=)([^/&?]*)(.*)/i;function Fe(e){let t=e.match(V7);if(!t)return;let r=e.substring(0,t.index),n=t[2];return{baseImageId:r,frameNumber:parseFloat(n),framesString:n,remaining:t[3]}}Rt.getLogger("utilities.metadataProvider.ecgFromInstance");let Ft=.001,Fr=65536,Fn=Object.freeze({params:Object.freeze(["instance","context"]),implicitScope:"instance"});function Fa(e,t){return null!=e&&("object"==typeof e||"function"==typeof e)&&Object.prototype.hasOwnProperty.call(e,t)}function Fi(e,t){return Fa(e,t)?e[t]:void 0}function Fo(e){return"__proto__"===e}function Fs(e){if("function"==typeof e)return"<function>";try{return JSON.stringify(e)??String(e)}catch{return String(e)}}class Fl extends Error{constructor(e,t,r){super(r),this.definition=e,this.path=t,this.name="RuleCompileError"}}function Fd(e,t,...r){let n=e.path?`${e.path}: `:"",a=r.length?`: ${Fs(r[0])}`:"";throw new Fl(e.definition,e.path,`Invalid ${e.definition}: ${n}${t}${a}`)}function Fu(e,t){let r=e.toLowerCase();for(let n of t)if(n&&n!==e&&n.toLowerCase()===r)return`; did you mean '${n}'?`;return""}function Fc(e,t,r){let n="number"==typeof t?`${e.path}[${t}]`:e.path?`${e.path}.${t}`:t;return{...e,path:n,extraKeys:void 0,expression:r?.expression??e.expression,call:r?.call??e.call}}let Fh=new Set(["string","number","boolean","true","scalar","literal","priority","expression"]),Fp={string:["a string",e=>"string"==typeof e],expression:["an expression string",e=>"string"==typeof e],number:["a finite number",e=>"number"==typeof e&&Number.isFinite(e)],boolean:["a boolean",e=>"boolean"==typeof e],true:["true",e=>!0===e],scalar:["a string, a finite number or a boolean",e=>"string"==typeof e||"boolean"==typeof e||"number"==typeof e&&Number.isFinite(e)],literal:["any value",()=>!0],priority:["a finite number, or null",e=>null===e||"number"==typeof e&&Number.isFinite(e)]};function Fm(e,t,r,n="value"){let[a,i]=Fp[e.kind];i(t)||Fd(r,`expected ${a}`,t),e.oneOf&&!e.oneOf.includes(t)&&Fd(r,`unknown ${n} ${Fs(t)}; allowed: ${e.oneOf.join(", ")}`)}function Ff(e,t,r){return Fd(r,`unrecognized ${e.name}; expected ${function(e,t){let r=t?.expression,n=[];for(let t of("expression"===e.string?n.push(r?`an expression string called with (${r.params.join(", ")})`:"an expression string"):"attribute"===e.string&&n.push("a name (a DICOM keyword or a context name)"),Object.values(e.forms)))n.push(function(e,t){let r=[],n=[];for(let[t,a]of Object.entries(e.keys)){if("operator"===a.role){n.push(t);continue}if("*"===t){r.push("<any key>");continue}r.push(a.optional||"modifier"===a.role?`${t}?`:t)}n.length&&r.splice(1,0,`<one of ${n.join(" | ")}>`);let a=`{ ${r.join(", ")} }`,i=e.expression??("expression"in e.keys?t:void 0);return i?`${a} called with (${i.params.join(", ")})`:a}(t,r));return(e.function&&n.push(t?.call?`a function ${t.call}`:"a function"),1===n.length)?n[0]:`${n.slice(0,-1).join(", ")}, or ${n[n.length-1]}`}(e,r)}`,t)}function Fg(e,t,r){let[n,a]=function(e,t,r){if(t&&"object"==typeof t&&!Array.isArray(t)){let r;for(let n of Object.entries(e.forms)){let{selectBy:e}=n[1];if(void 0===e)r??=n;else if(Object.prototype.hasOwnProperty.call(t,e))return n}if(r)return r}return Ff(e,t,r)}(e,t,r);return!function(e,t,r,n="key"){let a={...e.keys,...r.extraKeys},i=a["*"];for(let e of Object.keys(t))Object.prototype.hasOwnProperty.call(a,e)||i||Fd(r,`unknown ${n} '${e}'${Fu(e,Object.keys(a))}; allowed: ${Object.keys(a).join(", ")}`);let o=[],s=!1;for(let[e,i]of Object.entries(a)){var l;if("*"!==e){if("operator"===i.role&&(s=!0),!(Object.prototype.hasOwnProperty.call(t,e)&&void 0!==t[e])){i.optional||i.role||Fd(r,`missing ${n} '${e}'`,t);continue}if("operator"===i.role&&o.push(e),l=i.kind,Fh.has(l)){let n=Fc(r,e,i);if(i.list){let r=t[e];Array.isArray(r)||Fd(n,"expected an array",r),r.forEach((t,r)=>Fm(i,t,Fc(n,r),e))}else Fm(i,t[e],n,e)}}}if(s){let n=Object.entries(a).filter(([,e])=>"operator"===e.role).map(([e])=>e),i=e.selectBy?`${e.selectBy} ${Fs(t[e.selectBy])}`:"this form";o.length||Fd(r,`no operator for ${i}; expected exactly one of: ${n.join(", ")}`,t),o.length>1&&Fd(r,`more than one operator for ${i} (${o.join(", ")}); expected exactly one of: ${n.join(", ")}`,t)}for(let[e,n]of Object.entries(a))"modifier"===n.role&&void 0!==t[e]&&n.with&&!n.with.some(e=>o.includes(e))&&Fd(r,`'${e}' applies only with ${n.with.join(", ")}`,t)}(a,t,r,e.keyNoun),[n,a]}let Fy={name:"test",function:!0,keyNoun:"operator",forms:{operator:{keys:Object.fromEntries(Object.freeze(["equals","doesNotEqual","notNull","includes","doesNotInclude","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","range","contains","containsI","doesNotContain","doesNotContainI","containsAll","startsWith","endsWith"]).map(e=>[e,{kind:"literal",role:"operator"}])),description:"One operator and its operand."}}},Fv={name:"condition",function:!0,forms:{map:{keys:{"*":{kind:"matchTest"}},description:"A map of name to test. Every entry must hold. `{}` is true."}}},Fb={name:"value",string:"attribute",function:!0,forms:{template:{selectBy:"template",keys:{template:{kind:"string"}},description:"A string with `{name}` placeholders."},expression:{selectBy:"expression",keys:{expression:{kind:"expression"}},description:"An expression; the result is the value, not coerced."}}},Fx={condition:Fv,matchTest:Fy,value:Fb};function Fw(e,t){throw Error(`Invalid split rule set entry "${e}": ${t}`)}let FC=["===","!==","==","!=","<=",">=","&&","||","<",">","+","-","*","/","%","!","(",")","[","]",",",".","?",":"],Fk=e=>/[A-Za-z_$]/.test(e),FM=e=>/[A-Za-z0-9_$]/.test(e),FS=e=>e>="0"&&e<="9";class FI extends Error{constructor(e,t){super(`${e} in expression: ${t}`),this.name="ExpressionSyntaxError"}}function FT(e,t){let r=e[t];return{ch:({n:"\n",t:" ",r:"\r","\\":"\\","'":"'",'"':'"',"`":"`",$:"$"})[r]??r,next:t+1}}let F_=new Set(["__proto__","prototype","constructor"]),FP=Symbol("defined"),FE=new Map([["true",!0],["false",!1],["null",null],["undefined",void 0],["defined",FP]]),FD={"||":1,"&&":2,"==":3,"!=":3,"===":3,"!==":3,"<":4,"<=":4,">":4,">=":4,in:4,"+":5,"-":5,"*":6,"/":6,"%":6},FA=new Set(["min","max","sum","count"]),FO=new Set(["series","displaySet","displaySets"]);class FN{constructor(e,t){this.position=0,this.expression=t,this.tokens=function(e,t=e){let r=[],n=0;t:for(;n<e.length;){let a=e[n];if(/\s/.test(a)){n++;continue}if(FS(a)||"."===a&&FS(e[n+1])){let a=n;for(;a<e.length&&/[0-9.]/.test(e[a]);)a++;if("e"===e[a]||"E"===e[a]){let t=a+1;if(("+"===e[t]||"-"===e[t])&&t++,FS(e[t])){for(t++;t<e.length&&FS(e[t]);)t++;a=t}}let i=e.slice(n,a),o=Number(i);if(Number.isNaN(o))throw new FI(`Invalid number '${i}'`,t);r.push({kind:"number",value:o}),n=a;continue}if("'"===a||'"'===a){let i="",o=n+1;for(;o<e.length&&e[o]!==a;)if("\\"===e[o]){let{ch:t,next:r}=FT(e,o+1);i+=t,o=r}else i+=e[o],o++;if(o>=e.length)throw new FI("Unterminated string literal",t);r.push({kind:"string",value:i}),n=o+1;continue}if("`"===a){let{parts:a,next:i}=function(e,t,r){let n=[],a="",i=t;for(;i<e.length;){let t=e[i];if("`"===t)return a&&n.push({kind:"text",text:a}),{parts:n,next:i+1};if("\\"===t){let{ch:t,next:r}=FT(e,i+1);a+=t,i=r;continue}if("$"===t&&"{"===e[i+1]){a&&(n.push({kind:"text",text:a}),a="");let t=1,o=i+2,s="";for(;o<e.length&&t>0;){let r=e[o];if("{"===r)t++;else if("}"===r){if(0==--t)break}else if("'"===r||'"'===r)for(s+=r,o++;o<e.length&&e[o]!==r;)"\\"===e[o]&&(s+=e[o],o++),s+=e[o],o++;s+=e[o],o++}if(0!==t)throw new FI("Unterminated template interpolation",r);n.push({kind:"expr",source:s}),i=o+1;continue}a+=t,i++}throw new FI("Unterminated template literal",r)}(e,n+1,t);r.push({kind:"template",parts:a}),n=i;continue}if(Fk(a)){let t=n+1;for(;t<e.length&&FM(e[t]);)t++;r.push({kind:"ident",name:e.slice(n,t)}),n=t;continue}for(let t of FC)if(e.startsWith(t,n)){r.push({kind:"punct",value:t}),n+=t.length;continue t}throw new FI(`Unexpected character '${a}'`,t)}return r.push({kind:"end"}),r}(e,t)}peek(){return this.tokens[this.position]}next(){return this.tokens[this.position++]}isPunct(e){let t=this.peek();return"punct"===t.kind&&t.value===e}isIdent(e){let t=this.peek();return"ident"===t.kind&&t.name===e}expectPunct(e){if(!this.isPunct(e))throw new FI(`Expected '${e}'`,this.expression);this.next()}fail(e){throw new FI(e,this.expression)}parse(){let e=this.parseConditional();return"end"!==this.peek().kind&&this.fail("Unexpected trailing input"),e}parseSubExpression(){return this.parseConditional()}parseConditional(){let e=this.parseBinary(0);if(!this.isPunct("?"))return e;this.next();let t=this.parseConditional();return this.expectPunct(":"),{type:"conditional",test:e,consequent:t,alternate:this.parseConditional()}}parseBinary(e){let t=this.parseUnary();for(;;){let r,n=this.peek();if("punct"===n.kind&&FD[n.value]?r=n.value:"ident"===n.kind&&"in"===n.name&&(r="in"),!r)return t;let a=FD[r];if(a<=e)return t;this.next();let i=this.parseBinary(a);t="&&"===r||"||"===r?{type:"logical",operator:r,left:t,right:i}:{type:"binary",operator:r,left:t,right:i}}}parseUnary(){let e=this.peek();return"punct"===e.kind&&("!"===e.value||"-"===e.value||"+"===e.value)?(this.next(),{type:"unary",operator:e.value,argument:this.parseUnary()}):this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;){if(this.isPunct(".")){this.next();let t=this.next();"ident"!==t.kind&&this.fail("Expected a property name after '.'"),F_.has(t.name)&&this.fail(`Access to '${t.name}' is not allowed`),e={type:"member",object:e,property:t.name};continue}if(this.isPunct("[")){this.next();let t=this.parseSubExpression();this.expectPunct("]"),e={type:"index",object:e,index:t};continue}if(this.isPunct("(")){let t=function(e){if("member"===e.type&&FA.has(e.property)&&"member"===e.object.type&&"instances"===e.object.property&&"identifier"===e.object.object.type&&FO.has(e.object.object.name))return e.object.object.name}(e);"identifier"===e.type||t||this.fail("Only whitelisted helper functions may be called");let r="identifier"===e.type?e.name:e.property;this.next();let n=[];if(!this.isPunct(")"))for(;;){if(n.push(this.parseSubExpression()),this.isPunct(",")){this.next();continue}break}this.expectPunct(")"),e=t?{type:"call",callee:r,args:n,receiver:t}:{type:"call",callee:r,args:n};continue}return e}}parsePrimary(){let e=this.next();if("number"===e.kind||"string"===e.kind)return{type:"literal",value:e.value};if("template"===e.kind)return{type:"template",parts:e.parts.map(e=>"text"===e.kind?e:{kind:"expr",node:FR(e.source,this.expression)})};if("ident"===e.kind)return FE.has(e.name)?{type:"literal",value:FE.get(e.name)}:("in"===e.name&&this.fail("Unexpected 'in'"),F_.has(e.name)&&this.fail(`Access to '${e.name}' is not allowed`),{type:"identifier",name:e.name});if("punct"===e.kind){if("("===e.value){let e=this.parseSubExpression();return this.expectPunct(")"),e}if("["===e.value){let e=[];if(!this.isPunct("]"))for(;;){if(e.push(this.parseSubExpression()),this.isPunct(",")){this.next();continue}break}return this.expectPunct("]"),{type:"array",elements:e}}}this.fail("Unexpected token")}}function FR(e,t=e){return new FN(e,t).parse()}function FL(e){return void 0===e}function Fj(e){return null===e||""===e||Array.isArray(e)&&e.every(e=>FV(e))}function FV(e){return FL(e)||Fj(e)}function FF(e,t){if(FV(e)||FV(t))return FW(e)===FW(t);let r=Array.isArray(e),n=Array.isArray(t);return r&&n?e.length===t.length&&e.every((e,r)=>FB(e,t[r])):r?1===e.length&&FB(e[0],t):n?1===t.length&&FB(e,t[0]):FB(e,t)}function FB(e,t){if(FV(e)||FV(t))return FW(e)===FW(t);if(e===t)return!0;if("object"==typeof e||"object"==typeof t)return!1;if("number"==typeof e||"number"==typeof t){let r=N2(e),n=N2(t);if(void 0!==r&&void 0!==n)return r===n}return String(e)===String(t)}function FW(e){return FL(e)?"absent":null===e?"null":""===e?"text":Fj(e)?"array":void 0}function FU(e){return(t,r)=>{let n=N2(t),a=N2(r);return void 0!==n&&void 0!==a&&e(n,a)}}function Fz(e){return!FV(e)&&!!e}let FH=e=>"string"==typeof e||"boolean"==typeof e||"number"==typeof e&&Number.isFinite(e),FG=e=>"number"==typeof e&&Number.isFinite(e),Fq=e=>FH(e)||Array.isArray(e)&&e.length>0&&e.every(FH),F$=e=>"string"==typeof e||Array.isArray(e)&&e.length>0&&e.every(e=>"string"==typeof e),FK=e=>FV(e)?[]:NZ(e).filter(e=>!FV(e));function FY(e){return null===e?e=>FV(e):t=>FF(t,e)}let FX=new WeakMap;function FZ(e){if(!Array.isArray(e)||e.length<9)return null;let t=FX.get(e);return void 0===t&&(t=e.every(e=>"string"==typeof e&&e)?new Set(e):null,FX.set(e,t)),t}function FJ(e,t){let r=FZ(t),n=r?t:FK(t);return e.some(e=>r&&("string"==typeof e||"boolean"==typeof e)?r.has(String(e)):n.some(t=>FF(e,t)))}function FQ(e){let t=[...NZ(e)];return FZ(t),e=>FJ(FK(e),t)}function F0(e,t){return r=>{let n=((e,t=!1)=>NZ(e).map(e=>t?String(e).toLowerCase():String(e)))(r,e);return r=>((e,t=!1)=>FK(e).map(e=>t?String(e).toLowerCase():String(e)))(r,e).some(e=>n.some(r=>t(e,r)))}}let F1=e=>t=>{let r=e(t);return(e,t,n)=>!r(e,t,n)};function F2(e){let t=FU(e);return e=>r=>t(r,e)}let F5=F0(!1,(e,t)=>e.includes(t)),F3=F0(!0,(e,t)=>e.includes(t)),F4=F0(!1,(e,t)=>e.startsWith(t)),F8=F0(!1,(e,t)=>e.endsWith(t)),F6=Object.freeze({includes:(e,t)=>FJ(FK(t),e),contains:(e,t)=>F5(t)(e),startsWith:(e,t)=>F4(t)(e),endsWith:(e,t)=>F8(t)(e)}),F9=Object.freeze({equals:{operand:"a scalar, a non-empty array of scalars, or null",accepts:e=>null===e||Fq(e),compile:FY},doesNotEqual:{operand:"a scalar, a non-empty array of scalars, or null",accepts:e=>null===e||Fq(e),compile:F1(FY)},notNull:{operand:"a boolean",accepts:e=>"boolean"==typeof e,compile:e=>e?e=>!FV(e):e=>FV(e)},includes:{operand:"a scalar, or a non-empty array of scalars",accepts:Fq,compile:FQ},doesNotInclude:{operand:"a scalar, or a non-empty array of scalars",accepts:Fq,compile:F1(FQ)},greaterThan:{operand:"a finite number",accepts:FG,compile:F2((e,t)=>e>t)},greaterThanOrEqual:{operand:"a finite number",accepts:FG,compile:F2((e,t)=>e>=t)},lessThan:{operand:"a finite number",accepts:FG,compile:F2((e,t)=>e<t)},lessThanOrEqual:{operand:"a finite number",accepts:FG,compile:F2((e,t)=>e<=t)},range:{operand:"an array of two finite numbers",accepts:e=>Array.isArray(e)&&2===e.length&&e.every(FG),compile:e=>{let[t,r]=e,n=Math.min(t,r),a=Math.max(t,r);return e=>{let t=N2(e);return void 0!==t&&t>=n&&t<=a}}},contains:{operand:"a string, or a non-empty array of strings",accepts:F$,compile:F5},containsI:{operand:"a string, or a non-empty array of strings",accepts:F$,compile:F3},doesNotContain:{operand:"a string, or a non-empty array of strings",accepts:F$,compile:F1(F5)},doesNotContainI:{operand:"a string, or a non-empty array of strings",accepts:F$,compile:F1(F3)},containsAll:{operand:"a scalar, or a non-empty array of scalars",accepts:Fq,compile:e=>{let t=NZ(e);return e=>{let r=FK(e);return r.length>0&&t.every(e=>r.some(t=>FF(t,e)))}}},startsWith:{operand:"a string, or a non-empty array of strings",accepts:F$,compile:F4},endsWith:{operand:"a string, or a non-empty array of strings",accepts:F$,compile:F8}});function F7(e,t){if("function"==typeof e)return e;if(null===e)return FY(e);if(FH(e))return FQ(e);if(Array.isArray(e))return e.length&&e.every(FH)?FQ(e):Fd(t,"an array test must hold one or more scalars",e);if(!e||"object"!=typeof e)return Fd(t,"expected a scalar, an array of scalars, null, an object with one operator, or a function",e);Fg(Fy,e,t);let[r,n]=Object.entries(e)[0],a=F9[r];return a.accepts(n)?a.compile(n):Fd(t,`the operand of ${r} must be ${a.operand}`,e)}function Be(e,t){if(null!=e&&("string"==typeof t||"number"==typeof t)&&!("string"==typeof t&&F_.has(t)))return e[t]}function Bt(e){return t=>{let r=N2(t);if(void 0===r)return;let n=e(r);return Number.isFinite(n)?n:void 0}}function Br(e){return e.map(e=>N2(e)).filter(e=>void 0!==e)}let Bn={includes:F6.includes,contains:F6.contains,startsWith:F6.startsWith,endsWith:F6.endsWith,lower:e=>FV(e)?void 0:String(NJ(e)).toLowerCase(),abs:Bt(Math.abs),min:(...e)=>{let t=Br(e);return t.length?Math.min(...t):void 0},max:(...e)=>{let t=Br(e);return t.length?Math.max(...t):void 0},round:Bt(Math.round),floor:Bt(Math.floor),ceil:Bt(Math.ceil),Number:e=>N2(e),String:e=>FV(e)?"":String(e)},Ba=new Set(["min","max","sum","count"]);function Bi(e){return void 0!==e.receiver}function Bo(e,t={}){let r=[],n=(e,a)=>{switch(e.type){case"literal":return;case"identifier":r.push({name:e.name,inAggregate:a});return;case"member":if("identifier"===e.object.type)return void r.push({name:e.object.name,field:e.property,inAggregate:a});n(e.object,a);return;case"index":"identifier"===e.object.type?r.push({name:e.object.name,indexed:!0,inAggregate:a}):n(e.object,a),n(e.index,a);return;case"call":{let r=a||!!t.aggregates&&Bi(e);e.args.forEach(e=>n(e,r));return}case"unary":n(e.argument,a);return;case"binary":case"logical":n(e.left,a),n(e.right,a);return;case"conditional":n(e.test,a),n(e.consequent,a),n(e.alternate,a);return;case"array":e.elements.forEach(e=>n(e,a));return;case"template":e.parts.forEach(e=>{"expr"===e.kind&&n(e.node,a)});return}};return n(e,!1),r}let Bs={"<":FU((e,t)=>e<t),"<=":FU((e,t)=>e<=t),">":FU((e,t)=>e>t),">=":FU((e,t)=>e>=t)};function Bl(e){return(t,r)=>{let n=N2(t),a=N2(r);if(void 0===n||void 0===a)return;let i=e(n,a);return Number.isFinite(i)?i:void 0}}function Bd(e){return"template"===e.type||"literal"===e.type&&"string"==typeof e.value&&void 0===N2(e.value)}let Bu={"+":function(e,t){let r=NJ(e);if("string"==typeof r)return r+(FV(t)?"":String(NJ(t)));if(FV(e)||FV(t))return;let n=N2(e),a=N2(t);if(void 0===n||void 0===a)throw TypeError(`'+' adds numbers when the left side is not text, and ${JSON.stringify(void 0===n?e:t)} is not a number; put the text first, or use a template`);let i=n+a;return Number.isFinite(i)?i:void 0},"-":Bl((e,t)=>e-t),"*":Bl((e,t)=>e*t),"/":Bl((e,t)=>e/t),"%":Bl((e,t)=>e%t)};function Bc(e){if("literal"===e.type){if(e.value===FP)return e=>!FV(e);if(FL(e.value))return FL;if(Fj(e.value))return FV}}let Bh="safe function definition",Bp=(e,t,r)=>void 0===r?t=>Fi(t,e):t=>Fi(Fi(t,e),r),Bm={condition:(e,t)=>Bv(e,t),matchTest:(e,t)=>F7(e,t),value:(e,t)=>(function(e,t){if("function"==typeof e)return e;if("string"==typeof e)return Bg(e,t);if(!e||"object"!=typeof e||Array.isArray(e))return Ff(Fb,e,t);let[r]=Fg(Fb,e,t);if("template"===r)return function(e,t=Bf()){let r=Bb(e,t).map(e=>"literal"in e?()=>e.literal:Bg(e.name,t,e.field));return(e,t)=>r.map(r=>{let n=r(e,t);return FV(n)?"":String(n)}).join("")}(e.template,Fc(t,"template"));let n=By(e.expression,Fc(t,"expression"));return(e,t)=>n(e,t)})(e,t)};function Bf(e={},t=Fx,r=Bm){return{path:e.path??"",definition:e.definition??Bh,schema:t,compilers:r,readName:e.readName??Bp,expression:e.expression??Fn,call:e.call}}function Bg(e,t,r){return(t.readName??Bp)(e,t,r)}function By(e,t,r=t.expression??Fn){try{return function(e,t={}){let r=t.params??["instance","context"],{implicitScope:n=!0,receivers:a,unavailableReceivers:i}=t;for(let[t,n]of Object.entries(a??{}))if(!r.includes(n))throw new FI(`the list '${n}' of the receiver '${t}' is not one of the parameters (${r.join(", ")})`,e);let o=-1;if(!0===n)o=0;else if("string"==typeof n&&-1===(o=r.indexOf(n)))throw new FI(`implicitScope '${n}' is not one of the parameters (${r.join(", ")})`,e);let s={expression:e,receivers:a,unavailable:i},l=FR(e);-1===o&&function(e,t,r){let n=new Set(t);for(let a of Bo(e,{aggregates:!!r.receivers}))if(!a.inAggregate&&!n.has(a.name))throw new FI(`'${a.name}' is not a parameter, and this expression has no implicit scope; it can read only (${t.join(", ")})`,r.expression)}(l,r,s);let d=function e(t,r){let{expression:n}=r;switch(t.type){case"literal":{let{value:e}=t;if(e===FP)throw new FI("'defined' is a literal for '== defined' and '!= defined' only",n);return()=>e}case"identifier":{let{name:e}=t;return t=>(function(e,t){if(Object.prototype.hasOwnProperty.call(t.params,e))return t.params[e];for(let r=t.implicit.length-1;r>=0;r--){let n=t.implicit[r];if(null!=n&&"object"==typeof n&&e in n)return Be(n,e)}})(e,t)}case"member":{let n=e(t.object,r),{property:a}=t;return e=>Be(n(e),a)}case"index":{let n=e(t.object,r),a=e(t.index,r);return e=>Be(n(e),a(e))}case"array":{let n=t.elements.map(t=>e(t,r));if(t.elements.every(e=>"literal"===e.type)){let e=t.elements.map(e=>e.value);return()=>e}return e=>n.map(t=>t(e))}case"template":{let n=t.parts.map(t=>"text"===t.kind?()=>t.text:e(t.node,r));return e=>n.map(t=>{let r=t(e);return FV(r)?"":String(r)}).join("")}case"unary":{let n=e(t.argument,r);switch(t.operator){case"!":return e=>!Fz(n(e));case"-":{let e=Bt(e=>-e);return t=>e(n(t))}case"+":return e=>N2(n(e))}break}case"logical":{let n=e(t.left,r),a=e(t.right,r);return"&&"===t.operator?e=>Fz(n(e))&&Fz(a(e)):e=>Fz(n(e))||Fz(a(e))}case"binary":{if("=="===t.operator||"!="===t.operator)return function(t,r){let n="!="===t.operator;for(let e of[t.left,t.right])if("array"===e.type&&!e.elements.length)throw new FI(`'${t.operator} []' accepts no value; give one or more values, or use '${t.operator} null' to test for no value`,r.expression);for(let[e,n]of[[t.left,t.right],[t.right,t.left]])if("array"===e.type&&e.elements.length>1){let a="identifier"===n.type?n.name:"X";throw new FI(`'${t.operator}' with an array of ${e.elements.length} values compares the whole value; to test that a value is one of a list, use ${"!="===t.operator?`!(${a} in [...])`:`${a} in [...]`} or includes(...), e.g. Modality in ['MR', 'CT']`,r.expression)}let a=Bc(t.right),i=Bc(t.left);if(a||i){let o=a??i,s=e(a?t.left:t.right,r);return n?e=>!o(s(e)):e=>o(s(e))}let o=e(t.left,r),s=e(t.right,r);return n?e=>!FF(o(e),s(e)):e=>FF(o(e),s(e))}(t,r);if("==="===t.operator||"!=="===t.operator)throw new FI(`'${t.operator}' is not allowed; use '${"==="===t.operator?"==":"!="}', the one equality of the rule language`,n);if(Bu[t.operator]&&"+"!==t.operator){let e=[t.left,t.right].find(Bd);if(e)throw new FI(`'${t.operator}' works on numbers only, and ${"template"===e.type?"a template literal":`'${String(e.value)}'`} is not a number`,n)}let a=e(t.left,r),i=e(t.right,r),o=Bs[t.operator];if(o)return e=>o(a(e),i(e));let s=Bu[t.operator];if(s)return e=>s(a(e),i(e));if("in"===t.operator)return e=>F6.includes(i(e),a(e));throw new FI(`Unknown operator '${t.operator}'`,n)}case"conditional":{let n=e(t.test,r),a=e(t.consequent,r),i=e(t.alternate,r);return e=>Fz(n(e))?a(e):i(e)}case"call":{let{callee:a}=t;if(Bi(t)){let{receiver:i}=t;if(!Object.prototype.hasOwnProperty.call(r.receivers??{},i))throw new FI(r.unavailable?.[i]??`${i}.instances.${a}() is not available here`,n);if(r.inAggregate)throw new FI(`${i}.instances.${a}() is not allowed inside the argument of another aggregate; put the inner aggregate in its own context entry, and read that name`,n);let o=t.args.length;if("count"===a?o>1:1!==o)throw new FI(`${i}.instances.${a}() takes ${"count"===a?"zero or one argument":"one argument"}`,n);return function(t,r){let{callee:n}=t,a=r.receivers[t.receiver],i=t.args[0]?e(t.args[0],{...r,inAggregate:!0}):void 0;return e=>{let t=e.params[a],r=Array.isArray(t)?t:[];if(!i)return r.length;let o=r.map(t=>{e.implicit.push(t);try{return i(e)}finally{e.implicit.pop()}});if("count"===n)return o.filter(e=>!FV(e)&&!1!==e).length;let s=Br(o);return"sum"===n?s.reduce((e,t)=>e+t,0):s.length?"min"===n?Math.min(...s):Math.max(...s):void 0}}(t,r)}if(void 0===t.receiver&&Ba.has(t.callee)&&("min"!==t.callee&&"max"!==t.callee||1===t.args.length)){let e=Object.keys(r.receivers??{}).map(e=>`${e}.instances.${a}(...)`);throw new FI(e.length?`${a}(...) needs a receiver; use ${e.join(" or ")}`:`${a}(...) is not available here: this place has no list of instances`,n)}let i=Object.prototype.hasOwnProperty.call(Bn,a)?Bn[a]:void 0;if(!i)throw new FI(`'${a}' is not a whitelisted helper function`,n);let o=t.args.map(t=>e(t,r));return e=>i(...o.map(t=>t(e)))}}throw new FI("Unsupported expression node",n)}(l,s),u=!1,c=(...t)=>{let n=Object.create(null);r.forEach((e,r)=>{n[e]=t[r]});let a={params:n,implicit:-1===o?[]:[t[o]]};try{return d(a)}catch(t){if(t instanceof Fl)throw t;u||(u=!0,console.warn(`Safe function expression failed at runtime: ${e}`,t));return}};return c.expressionSource=e,c}(e,{params:r.params,implicitScope:r.implicitScope,receivers:r.receivers,unavailableReceivers:r.unavailableReceivers})}catch(e){return Fd(t,e.message)}}function Bv(e,t){if("function"==typeof e)return e;if(!e||"object"!=typeof e||Array.isArray(e))return Ff(Fv,e,t);let r=Object.entries(e).map(([r,n])=>{let a=Fc(t,r);return Fo(r)&&Fd(a,`the name "${r}" is not allowed`,e),{read:Bg(r,a),test:F7(n,a)}});return(e,t)=>r.every(({read:r,test:n})=>n(r(e,t),e,t))}function Bb(e,t={path:"",definition:Bh}){"string"!=typeof e&&Fd(t,"template must be a string",e);let r=[],n="";for(let a=0;a<e.length;a++){let i=e[a];if("\\"===i&&("{"===e[a+1]||"}"===e[a+1])){n+=e[a+1],a++;continue}if("{"!==i){n+=i;continue}let o=e.indexOf("}",a+1);-1===o&&Fd(t,'template has an unclosed "{"',e);let s=e.slice(a+1,o).trim();s||Fd(t,'template has an empty "{}" placeholder',e);let[l,d,...u]=s.split(".");(!l||""===d||u.length)&&Fd(t,`template placeholder "{${s}}" must be a name, or a name and one field`,e),n&&(r.push({literal:n}),n=""),r.push(void 0===d?{name:l}:{name:l,field:d}),a=o}return n&&r.push({literal:n}),r}function Bx(e){let t=e.SOPInstanceUID??e.imageId;return void 0===t?void 0:String(t)}function Bw(e,t){let r=Bx(e)??"",n=Bx(t)??"";return r<n?-1:+(r>n)}function BC(e,t,r){var n=Fi(e,t);if(NQ(n)||!N0(n))return;let a=Array.from(n,e=>N1(e));return a.length===r&&a.every(e=>void 0!==e)?a:void 0}let Bk=(e,t)=>Math.round(e/t)*t;function BM(e,t,r=!1){let n=0,a=e.length;for(;n<a;){let i=n+a>>1;e[i]<t||r&&e[i]===t?n=i+1:a=i}return n}function BS(e,t){let r=null==t?"":String(t).replace(/:/g,"").trim(),n=null==e?"":String(e).replace(/-/g,"").trim(),a=/^(\d{2})(\d{2})?(\d{2})?(\.\d+)?/.exec(r);if(!a)return;let[,i,o="0",s="0",l=""]=a,d=3600*Number(i)+60*Number(o)+Number(s)+Number(`0${l}`),u=/^(\d{4})(\d{2})(\d{2})$/.exec(n);if(!u)return d;let[,c,h,p]=u;return Date.UTC(Number(c),Number(h)-1,Number(p))/1e3+d}let BI=Object.freeze({planeGeometry:Object.freeze({compute:(e,{args:t})=>{let r=N2(Fi(t,"tolerance"))??.1,n={regularCount:0,irregularCount:0,positions:0,complete:!1,duplicates:!1,distance:{},index:{}},a=[];for(let t of[...e].sort(Bw)){let e=Bx(t),r=BC(t,"ImagePositionPatient",3),i=BC(t,"ImageOrientationPatient",6);if(void 0===e||!r||!i){n.irregularCount++;continue}a.push({key:e,position:r,orientation:i,orientationKey:i.map(e=>Bk(e,.001).toFixed(3)).join()})}let i=new Map;for(let{orientationKey:e}of a)i.set(e,(i.get(e)??0)+1);let[o]=[...i.entries()].sort(([e,t],[r,n])=>n-t||(e<r?-1:+(e>r)));if(!o)return n;let s=a.filter(e=>e.orientationKey===o[0]);n.irregularCount+=a.length-s.length;let[l,d,u,c,h,p]=s[0].orientation,m=R9.vec3.cross(R9.vec3.create(),R9.vec3.fromValues(l,d,u),R9.vec3.fromValues(c,h,p));R9.vec3.normalize(m,m),n.normal=Array.from(m);let f=s.map(e=>({...e,d:R9.vec3.dot(m,e.position)})),g=[];for(let e of f.map(e=>e.d).sort((e,t)=>e-t))(!g.length||e-g[g.length-1]>=.01)&&g.push(Bk(e,.001));let y=new Map;for(let e=1;e<g.length;e++){let t=Bk(g[e]-g[e-1],.01);y.set(t,(y.get(t)??0)+1)}let[v]=[...y.entries()].sort(([e,t],[r,n])=>n-t||e-r),b=v?.[0];if(!b)return n.irregularCount+=s.length,n;n.spacing=b;let x=(e,t)=>{let n=(t-e)/b;return Math.abs(n-Math.round(n))>r},w=function(e,t,r,n){let a,i=e.length,o=(e,t,r,a)=>{let i=0;for(let o=t;o<r;o++)i+=+!n(e,a[o]);return i};if(r>=.5)return e[0];if(r+1e-6>=.5)a=t=>o(e[t],0,i,e);else{let n=r=>{let n=(r-e[0])/t;return n-Math.floor(n)},i=e.map(e=>[n(e),e]).sort(([e],[t])=>e-t),s=[],l=[];for(let e of[-1,0,1])for(let[t,r]of i)s.push(t+e),l.push(r);a=t=>{let a=e[t],i=n(a),d=BM(s,i-r-1e-6),u=BM(s,i+r+1e-6,!0),c=BM(s,i-r+1e-6),h=BM(s,i+r-1e-6,!0);return c>=h?o(a,d,u,l):h-c+o(a,d,c,l)+o(a,h,u,l)}}let s=e[0],l=-1;for(let t=0;t<i;t++){let r=a(t);r>l&&(l=r,s=e[t])}return s}(g,b,r,x),C=f.filter(({d:e})=>!x(w,e));n.irregularCount+=f.length-C.length,n.regularCount=C.length;let k=C.reduce((e,t)=>t.d<e.d?t:e);n.origin=[...k.position];let M=new Map;for(let{key:e,d:t}of f)n.distance[e]=t-k.d;for(let{key:e,d:t}of C){let r=Math.round((t-k.d)/b);n.index[e]=r,M.set(r,(M.get(r)??0)+1)}return n.positions=M.size,n.complete=Math.max(...M.keys())===M.size-1,n.duplicates=[...M.values()].some(e=>e>1),n},fields:Object.freeze({normal:"series",origin:"series",spacing:"series",regularCount:"series",irregularCount:"series",positions:"series",complete:"series",duplicates:"series",distance:"instance",index:"instance"})}),timeClusters:Object.freeze({compute:(e,{args:t})=>{let r,n,a=N2(Fi(t,"maxGap"))??30,i={time:{},start:{},clusters:0,untimedCount:0},o=[];for(let t of e){let e=Bx(t),r=function(e){let t=Fi(e,"AcquisitionDateTime");if(null!=t&&String(t).length>8){let e=String(t);return BS(e.slice(0,8),e.slice(8))}for(let[t,r]of[["AcquisitionDate","AcquisitionTime"],["ContentDate","ContentTime"]]){let n=BS(Fi(e,t),Fi(e,r));if(void 0!==n)return n}}(t);if(void 0===e||void 0===r){i.untimedCount++;continue}o.push({key:e,seconds:r}),i.time[e]=r}for(let{key:e,seconds:t}of(o.sort((e,t)=>e.seconds-t.seconds||(e.key<t.key?-1:+(e.key>t.key))),o))(void 0===n||t-n>a)&&(r=t,i.clusters++),i.start[e]=r,n=t;return i.first=o[0]?.seconds,i},fields:Object.freeze({time:"instance",start:"instance",first:"series",clusters:"series",untimedCount:"series"})}),revisionChains:Object.freeze({compute:e=>{let t=e.map(Bx),r=new Map;t.forEach((e,t)=>void 0!==e&&r.set(e,t));let n=e.map((t,n)=>(function(e){let t=[],r=e=>null==e?[]:NZ(e);for(let n of r(Fi(e,"PredecessorDocumentsSequence")))for(let e of r(Fi(n,"ReferencedSeriesSequence")))for(let n of r(Fi(e,"ReferencedSOPSequence"))){let e=Fi(n,"ReferencedSOPInstanceUID");"string"==typeof e&&e&&t.push(e)}return t})(t).map(e=>r.get(e)).filter(r=>void 0!==r&&r!==n&&e[r].SeriesInstanceUID===t.SeriesInstanceUID)),a=new Set(n.flat()),i=e.map(()=>void 0);e.forEach((e,t)=>{if(a.has(t))return;let r=[t];for(;r.length;){let e=r.pop();void 0===i[e]&&(i[e]=t,r.push(...n[e]))}});let o={active:{}};return t.forEach((e,r)=>{let n=t[i[r]??r];void 0!==e&&void 0!==n&&(o.active[e]=n)}),o},fields:Object.freeze({active:"instance"})})}),BT=[...Vu],B_=Object.freeze(["splitNumber","sopClassUids"]),BP=function e(t){if(t&&"object"==typeof t&&!Object.isFrozen(t))for(let r of(Object.freeze(t),Object.values(t)))e(r);return t}({rule:{name:"rule",keyNoun:"field",forms:{rule:{keys:{id:{kind:"string",optional:!0,description:"The rule id. Optional: the key of the rule in the rule set is the id. When present it must equal that key."},groupId:{kind:"string",optional:!0,description:"The group of rules this rule belongs to, for a reader that must recognize display sets from several related rules (for example every mammography rule). Defaults to the rule id."},priority:{kind:"priority",description:"Evaluation order: ascending, first match wins. null excludes the rule."},description:{kind:"string",optional:!0,description:"Human-readable explanation. Not compiled."},viewportTypes:{kind:"string",list:!0,optional:!0,description:"Viewport types for the host. CS3D copies them to the display set unchanged, and does not read them."},handler:{kind:"string",optional:!0,description:"The generic handler name of the display sets, e.g. segmentation. Any string; the host decides what an unknown name does."},context:{kind:"contextEntry",record:!0,optional:!0,description:"Context entries for this rule only. An entry replaces the global entry of the same name, also inside the global entries that the rule reads, or defines a new name."},matches:{kind:"condition",optional:!0,function:!0,call:"(instance, context) => boolean",description:"Which instances this rule claims: a map of name to test, and every entry must hold. Omit for a catch-all rule."},groupBy:{kind:"name",list:!0,optional:!0,call:"(instance, context) => value",description:"Names (or functions) whose values must all be equal for two instances to form one group. Defaults to SeriesInstanceUID."},sortBy:{kind:"sortKey",list:!0,optional:!0,call:"(a, b, context) => number",description:'The order of the instances in a display set: names in ascending order, named sort functions, or functions. A result of 0 or NaN is "no opinion": the next entry decides.'},attributes:{kind:"attributeValue",record:!0,optional:!0,function:!0,call:"(attributes, options) => Record<string, unknown>",description:"Attributes of the produced display sets, keyed by attribute name."}}}}},contextEntry:{name:"context entry",string:"expression",function:!0,forms:{declaration:{selectBy:"attribute",keys:{attribute:{kind:"string"},vr:{kind:"string",optional:!0},vm:{kind:"string",optional:!0}},description:"Reads one attribute of the instance that the DICOM dictionary does not hold: a private tag as 8-digit hex, a vendor attribute, or a synthetic attribute such as imageId. vr and vm are recorded only."},template:{selectBy:"template",keys:{template:{kind:"string"}},description:"Text: each {name} gives the value of a name or a path."},group:{selectBy:"function",keys:{function:{kind:"literal",description:"The name of a series function (planeGeometry, timeClusters, or one of options.seriesFunctions), or in code a function."},args:{kind:"literal",optional:!0,description:"The arguments of the series function. Each value is a fixed value, or an expression with one value for the series."}},description:"One call of a series function over the series. A rule reads a result field by path, e.g. timeClusters.start. In sortBy and attributes, displaySet.<name> runs it over the display set."}}},condition:Fv,matchTest:Fy,name:{name:"name",string:"attribute",function:!0,forms:{}},sortKey:{name:"sort entry",string:"attribute",function:!0,forms:{sortFunction:{selectBy:"sortFunction",keys:{sortFunction:{kind:"string",description:"The name of a sort function in options.sortFunctions."}},description:"A named sort function, called (a, b, context) => number."}}},attributeValue:{...Fb,name:"attribute value",forms:{template:Fb.forms.template,expression:{...Fb.forms.expression,description:"An expression over the display set: displaySet.instances.max(x) (and min, sum, count) runs over its instances, series.instances.max(x) over the series, and a DICOM keyword reads its first instance."}}}}),BE=Rt.getLogger("displayset","displaySetContext"),BD="displaySetContext",BA={timeClustersMaxGap:30,timeClusters:{function:"timeClusters",args:{maxGap:"timeClustersMaxGap"}},longTimeClusters:{function:"timeClusters",args:{maxGap:60}},sweepCount:"timeClusters.clusters",sweepStart:"timeClusters.start",acquisitionSeconds:"timeClusters.time",sweepOffset:"round(sweepStart - timeClusters.first)",planeGeometryTolerance:.1,planeGeometry:{function:"planeGeometry",args:{tolerance:"planeGeometryTolerance"}},sliceSpacing:"planeGeometry.spacing",sliceIndex:"planeGeometry.index",sliceDistance:"planeGeometry.distance",revisionChains:{function:"revisionChains"},revisionChainUid:"revisionChains.active",isActiveRevision:"SOPInstanceUID == revisionChainUid",seriesInstanceCount:"series.instances.count()",isMultiFrame:"NumberOfFrames > 1",imageId:{attribute:"imageId"},imageSopClassUids:["1.2.840.10008.5.1.4.1.1.1","1.2.840.10008.5.1.4.1.1.1.1","1.2.840.10008.5.1.4.1.1.1.1.1","1.2.840.10008.5.1.4.1.1.1.2","1.2.840.10008.5.1.4.1.1.1.2.1","1.2.840.10008.5.1.4.1.1.1.3","1.2.840.10008.5.1.4.1.1.1.3.1","1.2.840.10008.5.1.4.1.1.2","1.2.840.10008.5.1.4.1.1.2.1","1.2.840.10008.5.1.4.1.1.2.2","1.2.840.10008.5.1.4.1.1.3.1","1.2.840.10008.5.1.4.1.1.4","1.2.840.10008.5.1.4.1.1.4.1","1.2.840.10008.5.1.4.1.1.4.3","1.2.840.10008.5.1.4.1.1.4.4","1.2.840.10008.5.1.4.1.1.6.1","1.2.840.10008.5.1.4.1.1.6.2","1.2.840.10008.5.1.4.1.1.7","1.2.840.10008.5.1.4.1.1.7.1","1.2.840.10008.5.1.4.1.1.7.2","1.2.840.10008.5.1.4.1.1.7.3","1.2.840.10008.5.1.4.1.1.7.4","1.2.840.10008.5.1.4.1.1.12.1","1.2.840.10008.5.1.4.1.1.12.1.1","1.2.840.10008.5.1.4.1.1.12.2","1.2.840.10008.5.1.4.1.1.12.2.1","1.2.840.10008.5.1.4.1.1.13.1.1","1.2.840.10008.5.1.4.1.1.13.1.2","1.2.840.10008.5.1.4.1.1.13.1.3","1.2.840.10008.5.1.4.1.1.13.1.4","1.2.840.10008.5.1.4.1.1.13.1.5","1.2.840.10008.5.1.4.1.1.14.1","1.2.840.10008.5.1.4.1.1.14.2","1.2.840.10008.5.1.4.1.1.20","1.2.840.10008.5.1.4.1.1.77.1.1","1.2.840.10008.5.1.4.1.1.77.1.1.1","1.2.840.10008.5.1.4.1.1.77.1.2","1.2.840.10008.5.1.4.1.1.77.1.2.1","1.2.840.10008.5.1.4.1.1.77.1.3","1.2.840.10008.5.1.4.1.1.77.1.4","1.2.840.10008.5.1.4.1.1.77.1.4.1","1.2.840.10008.5.1.4.1.1.77.1.5.1","1.2.840.10008.5.1.4.1.1.77.1.5.2","1.2.840.10008.5.1.4.1.1.77.1.5.4","1.2.840.10008.5.1.4.1.1.77.1.6","1.2.840.10008.5.1.4.1.1.82.1","1.2.840.10008.5.1.4.1.1.128","1.2.840.10008.5.1.4.1.1.128.1","1.2.840.10008.5.1.4.1.1.130","1.2.840.10008.5.1.4.1.1.481.1","1.2.840.10008.5.1.4.1.1.481.2"],videoSopClassUids:["1.2.840.10008.5.1.4.1.1.77.1.1.1","1.2.840.10008.5.1.4.1.1.77.1.2.1","1.2.840.10008.5.1.4.1.1.77.1.4.1"],videoTransferSyntaxUids:BT,longVideoSopClassUids:["1.2.840.10008.5.1.4.1.1.7","1.2.840.10008.5.1.4.1.1.7.4"],longVideoMinFrames:90,ecgSopClassUids:["1.2.840.10008.5.1.4.1.1.9.1.1","1.2.840.10008.5.1.4.1.1.9.1.2","1.2.840.10008.5.1.4.1.1.9.1.3","1.2.840.10008.5.1.4.1.1.9.2.1","1.2.840.10008.5.1.4.1.1.9.3.1"],wholeSlideSopClassUids:["1.2.840.10008.5.1.4.1.1.77.1.6"],segmentationSopClassUids:["1.2.840.10008.5.1.4.1.1.66.4","1.2.840.10008.5.1.4.1.1.66.7"],rtStructureSetSopClassUids:["1.2.840.10008.5.1.4.1.1.481.3"],parametricMapSopClassUids:["1.2.840.10008.5.1.4.1.1.30"],structuredReportSopClassUids:["1.2.840.10008.5.1.4.1.1.88.11","1.2.840.10008.5.1.4.1.1.88.22","1.2.840.10008.5.1.4.1.1.88.33","1.2.840.10008.5.1.4.1.1.88.34","1.2.840.10008.5.1.4.1.1.88.67"],encapsulatedDocumentSopClassUids:["1.2.840.10008.5.1.4.1.1.104.1"],bulkAnnotationSopClassUids:["1.2.840.10008.5.1.4.1.1.91.1"],chartSopClassUids:[],isImage:"SOPClassUID in imageSopClassUids",transferSyntaxKnown:"AvailableTransferSyntaxUID != null || TransferSyntaxUID != null",isVideo:"SOPClassUID in videoSopClassUids || AvailableTransferSyntaxUID in videoTransferSyntaxUids || TransferSyntaxUID in videoTransferSyntaxUids || (!transferSyntaxKnown && SOPClassUID in longVideoSopClassUids && NumberOfFrames >= longVideoMinFrames)",isEcg:"SOPClassUID in ecgSopClassUids",isWsi:"SOPClassUID in wholeSlideSopClassUids || Modality == 'SM'",isSegmentation:"SOPClassUID in segmentationSopClassUids",isRtStructureSet:"SOPClassUID in rtStructureSetSopClassUids",isParametricMap:"SOPClassUID in parametricMapSopClassUids",isStructuredReport:"SOPClassUID in structuredReportSopClassUids",isEncapsulatedDocument:"SOPClassUID in encapsulatedDocumentSopClassUids",isBulkAnnotation:"SOPClassUID in bulkAnnotationSopClassUids",isChart:"SOPClassUID in chartSopClassUids"},BO=/^[a-z][A-Za-z0-9_]*$/,BN=new Set(["true","false","null","undefined","defined"]),BR=/^[0-9A-Fa-f]{8}$/;function BL(e){return void 0!==Vj(e)}let Bj="displaySets aggregates are not available yet; see https://github.com/cornerstonejs/cornerstone3D/issues/3000",BV=Object.freeze({params:Object.freeze(["#values","#instances"]),implicitScope:"#values",receivers:Object.freeze({series:"#instances"}),unavailableReceivers:Object.freeze({displaySet:'displaySet.instances aggregates are available only in the { "expression" } form of attributes',displaySets:Bj})}),BF=Object.freeze({params:Object.freeze(["#values","#instances","#displaySetInstances"]),implicitScope:"#values",receivers:Object.freeze({series:"#instances",displaySet:"#displaySetInstances"}),unavailableReceivers:Object.freeze({displaySets:Bj})}),BB=new Set(["series","displaySet","displaySets"]),BW=new Set(["sortBy","attributes"]),BU="the 'displaySet.' prefix is valid only in sortBy and attributes",Bz=0,BH=new WeakMap;function BG(e,t=!0){return null===e||"boolean"==typeof e||"number"==typeof e&&Number.isFinite(e)||t&&Array.isArray(e)}function Bq(e){return Array.isArray(e)?[...e]:e}class B${constructor(e,t=e,r){this.instances=e,this.seriesInstances=t,this.split=r,this.runtimes=new WeakMap}runtime(e){let t=this.runtimes.get(e);return t||(t=new BK(this.instances,this.seriesInstances,this.split?.runtime(e)),this.runtimes.set(e,t)),t}}class BK{constructor(e,t=e,r){this.instances=e,this.seriesInstances=t,this.split=r,this.seriesValues=new Map,this.instanceValues=new Map,this.views=new Map,this.envs=new Map,this.instanceEnvs=new Map,this.inProgress=[]}get seriesRuntime(){return this.split??this}value(e,t){if("series"===e.scope)return this.split&&!e.perDisplaySet?this.split.value(e,void 0):(this.seriesValues.has(e.key)||this.seriesValues.set(e.key,this.compute(e,void 0)),this.seriesValues.get(e.key));if(!t)return;let r=this.instanceValues.get(t);return r||(r=new Map,this.instanceValues.set(t,r)),r.has(e.key)||r.set(e.key,this.compute(e,t)),r.get(e.key)}compute(e,t){let r=this.inProgress.findIndex(r=>r.bound===e&&r.instance===t);if(-1!==r){let t=[...this.inProgress.slice(r).map(e=>e.bound),e];throw new Fl("display set rules",e.name,`Invalid display set rules: the context entries form a loop: ${t.map(({name:e,ruleId:t})=>void 0===t?e:`${e} (rule '${t}')`).join(" -> ")}`)}this.inProgress.push({bound:e,instance:t});try{return e.compute(this,t)}finally{this.inProgress.pop()}}groupView(e,t){let r=this.value(e,t),n=e.group?.fields;if(!t||!n||!r||"object"!=typeof r)return r;let a=this.views.get(t);if(a||(a=new Map,this.views.set(t,a)),!a.has(e.key)){let i=Bx(t),o=Object.create(null);for(let[e,t]of Object.entries(n)){let n=Fi(r,e);o[e]="instance"===t?void 0===i?void 0:Fi(n,i):n}a.set(e.key,o)}return a.get(e.key)}read(e,t,r,n){if(t)switch(t.kind){case"keyword":return r?Fi(r,e):void 0;case"attribute":return Fi(n,e);case"entry":return t.bound.group?this.groupView(t.bound,r):this.value(t.bound,r);case"series":return this.seriesRuntime.read(e,t.inner,r,n);case"displaySet":{let e=Object.create(null);return t.fields.forEach((t,a)=>{e[a]=this.read(a,t,r,n)}),e}}}env(e,t,r,n=!1){let a=!r&&!n,i=a?this.envs.get(e.key):void 0,o=i?.get(t);if(o)return o;let s=new Proxy(Object.create(null),{has:()=>!0,get:(n,a)=>{if("string"!=typeof a)return;let i=e.deps.get(a)??e.layer?.dynamicDependency(a,e.definition);return this.read(a,i,t,r)}});return a&&(i||(i=new Map,this.envs.set(e.key,i)),i.set(t,s)),s}envsOf(e,t=this.seriesInstances,r){if(r||t!==this.seriesInstances)return t.map(t=>this.env(e,t,r));if(this.split&&!e.perDisplaySet)return this.split.envsOf(e,this.split.seriesInstances);let n=this.instanceEnvs.get(e.key);return n||(n=t.map(t=>this.env(e,t)),this.instanceEnvs.set(e.key,n)),n}}class BY{constructor(e,t,r){this.program=e,this.ruleId=t,this.local=r,this.memo=new Map,this.dynamic=new Map}resolve(e,t){return t&&void 0!==t.ruleId&&t.name===e?this.program.global.get(e):this.local.get(e)??this.program.global.get(e)}dynamicDependency(e,t){let r=this.dynamic.get(t);if(r||(r=new Map,this.dynamic.set(t,r)),!r.has(e)){let n;if(this.program.isDenied(e))BE.warn(`a code entry of the context read '${e}', which is on the deny list of the host; the read gives undefined`);else if(BL(e))n={kind:"keyword"};else{let r=this.resolve(e,t);r?n={kind:"entry",bound:this.program.bind(r,this,[])}:B_.includes(e)&&(n={kind:"attribute"})}r.set(e,n)}return r.get(e)}}class BX{constructor(e,t){for(const r of(this.global=new Map,this.bounds=new Map,this.fallbackLogged=!1,this.seriesHook=({instances:e,series:t})=>Fa(t,BD)?{}:{[BD]:new B$(e)},this.seriesFunctions=t.seriesFunctions,this.denied=new Set(t.deniedNames??[]),this.deniedTags=new Set([...this.denied].map(Vj).filter(Boolean)),this.parseLayer(e,t.site,void 0)))this.global.set(r.name,r);for(const e of(this.empty=new BY(this,void 0,new Map),this.global.values()))this.bind(e,this.empty,[])}isDenied(e){return this.denied.has(e)}parseExpression(e,t,r){let n=function(e,t,r=BV){let n=By(e,t,r),a=FR(e);return{evaluate:n,reads:Bo(a,{aggregates:!0}),single:"identifier"===a.type?a.name:void 0,ast:a}}(e,t,r);if(this.denied.size){var a;let e,r;for(let i of(a=n.ast,e=[],(r=t=>{switch(t.type){case"member":e.push(t.property),r(t.object);return;case"index":"literal"!==t.index.type?e.push(void 0):"string"==typeof t.index.value&&e.push(t.index.value),r(t.object),r(t.index);return;case"call":t.args.forEach(r);return;case"unary":r(t.argument);return;case"binary":case"logical":r(t.left),r(t.right);return;case"conditional":r(t.test),r(t.consequent),r(t.alternate);return;case"array":t.elements.forEach(r);return;case"template":t.parts.forEach(e=>"expr"===e.kind&&r(e.node));return}})(a),e))void 0===i&&Fd(t,"a computed field name is not allowed when the host has a deny list; use a literal index, e.g. ViewCodeSequence[0].CodeValue"),this.denied.has(i)&&Fd(t,`the name '${i}' is on the deny list of the host, so no rule can read it`)}return n}runtimeFrom(e,t){let r=Fi(e,"displaySet");if(r instanceof B$)return r.runtime(this);let n=Fi(Fi(e,"series"),BD);return n instanceof B$?n.runtime(this):(this.fallbackLogged||(this.fallbackLogged=!0,BE.debug("a split rule hook was called with no split context; its context values cover only the instances of the call")),new B$(t?NZ(t):[]).runtime(this))}instanceValue(e,t){let r=this.global.get(e);if(!r)throw Error(`the metadata context has no entry '${e}'`);let n=this.bind(r,this.empty,[]);if("instance"!==n.scope)throw Error(`the context entry '${e}' has the series scope, so one instance cannot give its value`);return new B$([t]).runtime(this).read(e,{kind:"entry",bound:n},t)}layer(e,t,r){if(void 0===t)return this.empty;let n=new Map;for(let a of this.parseLayer(t,r,e))n.set(a.name,a),BE.debug(this.global.has(a.name)?`rule '${e}': the context entry '${a.name}' replaces the global entry for this rule`:`rule '${e}': the context entry '${a.name}' defines a new name for this rule`);let a=new BY(this,e,n);for(let e of n.values())this.bind(e,a,[]);return a}readerAt(e,t,r,n={}){let a=n.place??"",{field:i}=n,o=t,s="displaySet"===t||t.startsWith("displaySet.");if(s){BW.has(a)||Fd(r,BU);let e=t.split(".").slice(1);void 0!==i&&e.push(i),(!e.length||e.length>2||e.some(e=>!e))&&Fd(r,`'${t}' must be displaySet.<name> or displaySet.<name>.<field>, e.g. displaySet.sliceSpacing`),[o,i]=e}let l=this.dependencyOf({name:o,field:i,inAggregate:!1},void 0,e,[],r,a);return!s&&BW.has(a)&&(l={kind:"series",inner:l}),(e,t,r)=>{let n=e.read(o,l,t,r);return void 0===i?n:Fi(n,i)}}attributeExpression(e,t,r){let{evaluate:n,reads:a}=this.parseExpression(t,r,BF),i=new Map,o=new Map;for(let t of a){if("displaySet"===t.name){void 0===t.field&&Fd(r,"'displaySet' needs a name, e.g. displaySet.sliceSpacing"),o.set(t.field,this.dependencyOf({name:t.field,inAggregate:t.inAggregate},void 0,e,[],r,"attributes"));continue}let n=this.dependencyOf(t,void 0,e,[],r,"attributes");i.set(t.name,{kind:"series",inner:n})}o.size&&i.set("displaySet",{kind:"displaySet",fields:o});let s=o.size>0||[...i.values()].some(e=>"series"===e.kind&&"attribute"===e.inner.kind),l={key:`#attribute:${r.path}`,deps:i,perDisplaySet:s};return(e,t,r)=>n(e.env(l,t[0],r),s?e.envsOf(l,e.seriesInstances,r):e.envsOf(l),e.envsOf(l,t,r))}bind(e,t,r){let n=t.memo.get(e);if(n)return n;let a=r.indexOf(e);if(-1!==a){let t=[...r.slice(a),e].map(({name:e})=>e).join(" -> ");return Fd(e.site,`the context entries form a loop: ${t}`)}r.push(e);try{let n=new Map,a=new Set;void 0!==e.ruleId&&a.add(e.name),"code"===e.kind&&t.local.forEach((e,t)=>a.add(t));let i="declaration"===e.kind||"code"===e.kind?"instance":"series";for(let o of e.reads){let s=this.dependencyOf(o,e,t,r,e.site,"context");n.set(o.name,s),"entry"===s.kind&&s.bound.closure.forEach(e=>a.add(e)),!o.inAggregate&&BZ(o,s)&&(i="instance")}if("group"===e.kind){for(let t of e.args){let r=t.reads.find(e=>!e.inAggregate&&BZ(e,n.get(e.name)));r&&Fd(Fc(Fc(e.site,"args"),t.name),`the argument must have one value for the series, but '${r.name}' has one value for each instance`)}i="series"}let o=[...a].sort(),s=void 0===e.ruleId?"":"@",l=o.length?`${s}${e.name}{${o.map(e=>`${e}=${t.local.get(e)?.identity}`).join(",")}}`:`${s}${e.name}`,d=this.bounds.get(l);return d||(d=this.createBound(e,t,l,i,n,a),this.bounds.set(l,d)),t.memo.set(e,d),d}finally{r.pop()}}dependencyOf(e,t,r,n,a,i){let{name:o,field:s}=e;if(this.denied.has(o))return Fd(a,`the name '${o}' is on the deny list of the host, so no rule can read it`);if("displaySet"===o)return Fd(a,BU);if(BL(o))return void 0!==s?Fd(a,`'${o}' is a DICOM keyword and has no field '${s}'; read an item of a sequence with an index, e.g. ${o}[0].${s}`):{kind:"keyword"};let l=r.resolve(o,t);if(!l)return B_.includes(o)?"attributes"===i?{kind:"attribute"}:Fd(a,`'${o}' is a value of the display set, and only attributes can read it`):t&&void 0!==t.ruleId&&t.name===o?Fd(a,`the rule entry '${o}' reads its own name, but the global context has no entry '${o}'`):Fd(a,function(e,t,r){let n,a=Fu(e,[function(e){if(!b)for(let e of(b=new Map,Object.keys(VN)))b.set(e.toLowerCase(),e);return b.get(e.toLowerCase())}(e),...r]);if(a)return`unknown name '${e}'${a}`;n=BR.test(e)?`a hex tag needs a declaration in the context, e.g. "myValue": { "attribute": "${e}" }`:BN.has(e)?`'${e}' is a literal; write X == ${e} in a context entry`:/^[a-z]/.test(e)?"no context entry has this name":`it is not a keyword of the DICOM dictionary; a private, vendor or synthetic attribute needs a declaration, e.g. "myValue": { "attribute": "${e}" }`;let i="attributes"===t?`; fixed text is { "template": ${JSON.stringify(e)} }`:"";return`unknown name '${e}': ${n}${i}`}(o,i,[...r.local.keys(),...this.global.keys(),...B_]));let d=this.bind(l,r,n);if(e.indexed&&d.group)return Fd(a,`read a field of the group '${o}' by path, e.g. ${o}.${Object.keys(d.group.fields??{})[0]??"field"}`);if(void 0!==s){if(!d.group)return Fd(a,`'${o}' is not a group, so '${o}.${s}' reads nothing`);let{fields:e}=d.group;if(e&&!Fa(e,s))return Fd(a,`the group '${o}' has no field '${s}'${Fu(s,Object.keys(e))}; fields: ${Object.keys(e).join(", ")}`)}return{kind:"entry",bound:d}}createBound(e,t,r,n,a,i){let o={key:r,name:e.name,scope:n,deps:a,closure:i,ruleId:e.ruleId,perDisplaySet:"code"===e.kind||"group"===e.kind||[...a.values()].some(e=>"entry"===e.kind&&e.bound.perDisplaySet),compute:()=>void 0};switch(e.kind){case"fixed":{let{value:t}=e;o.compute=()=>t;break}case"declaration":{let{attribute:t}=e;o.compute=(e,r)=>Fi(r,t);break}case"code":{let{fn:r}=e;o.layer=t,o.definition=e,o.compute=(e,t)=>t?r(t,e.env(o,t,void 0,!0)):void 0;break}case"expression":{let t=void 0!==e.aliasOf?a.get(e.aliasOf):void 0;if(t?.kind==="entry"&&t.bound.group){let e=t.bound;o.group=e.group,o.scope="series",o.compute=t=>t.value(e,void 0);break}let{evaluate:r}=e;o.compute=(e,t)=>r(e.env(o,t),e.envsOf(o));break}case"template":{let t=e.segments.map(e=>"literal"in e?()=>e.literal:(t,r)=>{let n=t.read(e.name,a.get(e.name),r);return void 0===e.field?n:Fi(n,e.field)});o.compute=(e,r)=>t.map(t=>{let n=t(e,r);return FV(n)?"":String(n)}).join("");break}case"group":{let{compute:t,args:r}=e;o.group={fields:e.fields},o.compute=e=>{let n={};for(let t of r)n[t.name]=t.evaluate?t.evaluate(e.env(o,void 0),e.envsOf(o)):t.fixed;return t(e.instances,{args:Object.freeze(n)})}}}return o}parseLayer(e,t,r){return!e||"object"!=typeof e||Array.isArray(e)?Fd(t,"expected an object of context entries, keyed by context name",e):Object.entries(e).map(([e,n])=>{let a=Fc(t,e);return(Fo(e)||F_.has(e))&&Fd(a,`the context name "${e}" is not allowed`),(BN.has(e)||BB.has(e))&&Fd(a,`'${e}' is reserved by the expression language, and cannot be a context name`),BL(e)&&Fd(a,`the context name '${e}' is a DICOM keyword; a context cannot hide a value of the instance`),BO.test(e)||Fd(a,`the context name '${e}' must start with a lowercase letter, and hold only letters, digits and _`),B_.includes(e)&&Fd(a,`'${e}' is a value of the display set, and cannot be a context name`),this.denied.has(e)&&Fd(a,`the context name '${e}' is on the deny list of the host`),this.parseEntry(e,n,a,r)})}parseEntry(e,t,r,n){let a={name:e,ruleId:n,site:r,identity:JSON.stringify(t,(e,t)=>{if("function"!=typeof t)return t;let r=BH.get(t);return r||(r=`#function${++Bz}`,BH.set(t,r)),r})};if("function"==typeof t)return{...a,kind:"code",reads:[],fn:t};if(BG(t))return{...a,kind:"fixed",reads:[],value:Bq(t)};if("string"==typeof t){let{evaluate:e,reads:n,single:i}=this.parseExpression(t,r);return{...a,kind:"expression",reads:n,evaluate:e,aliasOf:i}}if(!t||"object"!=typeof t)return Fd(r,"expected a fixed value (a number, a boolean, null or an array), an expression string, { attribute }, { template }, { function, args? }, or a function",t);let[i]=Fg(BP.contextEntry,t,r);if("declaration"===i){if(!t.attribute)return Fd(Fc(r,"attribute"),"expected a non-empty string");let e=String(t.attribute);return this.denied.has(e)||this.deniedTags.has(e.replace(/^x/i,"").toUpperCase())?Fd(Fc(r,"attribute"),`the attribute '${e}' is on the deny list of the host, so no rule can read it`):{...a,kind:"declaration",reads:[],attribute:t.attribute,vr:t.vr,vm:t.vm}}if("template"===i){let e=Bb(t.template,Fc(r,"template")),n=e.flatMap(e=>"literal"in e?[]:[{name:e.name,field:e.field,inAggregate:!1}]);return{...a,kind:"template",reads:n,segments:e}}let o=this.seriesFunctionOf(t.function,Fc(r,"function")),s=this.parseArguments(t.args,Fc(r,"args"));return{...a,kind:"group",reads:s.flatMap(e=>e.reads),compute:o.compute,fields:o.fields,args:s}}seriesFunctionOf(e,t){if("function"==typeof e)return{compute:e};if(e&&"object"==typeof e&&"function"==typeof e.compute)return e;if("string"==typeof e){let t=Fi(this.seriesFunctions,e);if("function"==typeof t)return{compute:t};if(t&&"object"==typeof t)return t}return Fd(t,`unknown series function ${JSON.stringify(e)}; known: ${Object.keys(this.seriesFunctions).join(", ")||"(none)"}`)}parseArguments(e,t){return void 0===e?[]:!e||"object"!=typeof e||Array.isArray(e)?Fd(t,"expected an object of arguments",e):Object.entries(e).map(([e,r])=>{let n=Fc(t,e);if(Fo(e)&&Fd(n,`the argument name "${e}" is not allowed`),BG(r))return{name:e,fixed:Bq(r),reads:[]};if("string"==typeof r){let{evaluate:t,reads:a}=this.parseExpression(r,n);return{name:e,evaluate:t,reads:a}}return Fd(n,"an argument is a fixed value (a number, a boolean, null or an array) or an expression string",r)})}}function BZ(e,t){if(!t)return!1;switch(t.kind){case"keyword":return!0;case"attribute":case"displaySet":return!1;case"series":return BZ(e,t.inner);case"entry":{let{bound:r}=t;if(void 0!==e.field)return r.group?.fields?.[e.field]==="instance";return"instance"===r.scope}}}let BJ=new WeakMap,BQ="display set rules";function B0(e,t,r,n,a){let i=e.program.readerAt(e.layer,t,r,{field:a,place:n}),{program:o}=e;return(e,t)=>i(o.runtimeFrom(t,e),e)}function B1(e,t,r){return Array.isArray(e)?e.map((e,n)=>r(e,Fc(t,n))):Fd(t,"expected an array",e)}let B2=e=>`[${e.map(e=>`'${e}'`).join(", ")}]`,B5={isImage:!0,Rows:{notNull:!0}},B3={groupBy:["SeriesInstanceUID","revisionChainUid"],sortBy:["isActiveRevision","InstanceNumber"],attributes:{activeSopInstanceUid:"revisionChainUid"}},B4=(e,t,r,n)=>({priority:e,description:n,handler:r,matches:{[t]:!0},groupBy:["SeriesInstanceUID"]}),B8={video:{priority:1,description:"A video-only SOP class, or a video transfer syntax, or (with no known transfer syntax) a long multi-frame secondary capture. One display set per instance, shown on a video viewport.",handler:"video",matches:{isVideo:!0},groupBy:["SOPInstanceUID"]},ecg:{priority:2,description:"ECG / waveform SOP classes. One display set per instance, shown on a waveform viewport rather than an image viewport.",handler:"ecg",matches:{isEcg:!0},groupBy:["SOPInstanceUID"]},wholeslide:{priority:3,description:"VL Whole Slide Microscopy (or modality SM). All pyramid levels of the series form a single whole-slide display set.",handler:"wholeSlide",matches:{isWsi:!0},groupBy:["SeriesInstanceUID"]},singleImageModality:{priority:4,description:"CR / DX / MG, which acquire one image per instance. One display set per instance, so each view of a mammography series is its own display set.",matches:{Modality:["CR","DX","MG"],isImage:!0},groupBy:["SOPInstanceUID"]},multiFrame:{priority:5,description:"Multi-frame image instances, one display set per instance. A cine clip (a slice location, or a US, XA, RF, ES or XC multi-frame that is not a volume) is flagged isClip. Another multi-frame instance, such as an enhanced CT, is not a clip.",context:{isCineClip:`SliceLocation != null || (Modality in ${B2(["US","XA","RF","ES","XC"])} && !(SOPClassUID in ${B2(["1.2.840.10008.5.1.4.1.1.6.2","1.2.840.10008.5.1.4.1.1.13.1.1","1.2.840.10008.5.1.4.1.1.13.1.2"])}))`},matches:{isImage:!0,isMultiFrame:!0},groupBy:["SOPInstanceUID"],attributes:{isClip:"isCineClip",numImageFrames:{expression:"Number(NumberOfFrames)"}}},mixedDimensionalityBValue:{priority:6,description:"Diffusion MR that mixes 4D b-value frames with trailing frames that have none. The undefined-b-value frames are not part of the 4D set, so they split off - otherwise 4D rendering is applied to the 3D portion.",context:{isMixedBValue:"series.instances.count(DiffusionBValue) > 0 && series.instances.count(DiffusionBValue) < series.instances.count()",hasNoBValue:"DiffusionBValue == null"},matches:{Modality:"MR",isMixedBValue:!0,...B5},groupBy:["SeriesInstanceUID","hasNoBValue"]},volume3d:{priority:7,description:"Multi-slice CT / MR / PT / NM, which reconstruct into a volume.",matches:{Modality:["CT","MR","PT","NM"],seriesInstanceCount:{greaterThan:1},...B5},groupBy:["SeriesInstanceUID"]},defaultImageRule:{priority:8,description:"Fallback for any remaining image SOP class, also with no Rows in the metadata. Grouped one display set per series.",matches:{isImage:!0}},segmentation:B4(9,"isSegmentation","segmentation","Segmentations (segmentationSopClassUids). One display set per series."),rtStructureSet:B4(10,"isRtStructureSet","rtStructureSet","RT structure sets (rtStructureSetSopClassUids). One display set per series."),parametricMap:B4(11,"isParametricMap","parametricMap","Parametric maps (parametricMapSopClassUids). One display set per series."),structuredReport:{...B4(12,"isStructuredReport","structuredReport","Structured reports (structuredReportSopClassUids), also Comprehensive 3D SR. One display set per series. Manufacturer and ManufacturerModelName name the writer of the SR."),attributes:{Manufacturer:"Manufacturer",ManufacturerModelName:"ManufacturerModelName"}},encapsulatedDocument:{...B4(13,"isEncapsulatedDocument","encapsulatedDocument","Encapsulated documents (encapsulatedDocumentSopClassUids). One display set per revision chain (PredecessorDocumentsSequence) of the series; activeSopInstanceUid names the current revision."),...B3},bulkAnnotation:B4(14,"isBulkAnnotation","bulkAnnotation","Microscopy bulk annotations (bulkAnnotationSopClassUids). One display set per series."),chart:{...B4(15,"isChart","chart","Charts (chartSopClassUids, empty by default: a host adds its chart SOP class). One display set per revision chain of the series; activeSopInstanceUid names the current revision."),...B3},unsupported:{priority:Number.MAX_SAFE_INTEGER,description:"Catch-all for objects that no other rule claims (presentation states, other non-image objects). Produces one display set for each series, marked isDisplayable: false, so the objects are surfaced rather than silently dropped. Runs last.",handler:"unsupported",groupBy:["SeriesInstanceUID"]}};!function(e=B8,t={}){!function(e,t={}){if(!e||"object"!=typeof e||Array.isArray(e))throw Error(`Invalid ${BQ}: the rules must be an object keyed by rule id: ${JSON.stringify(e)}`);let r=function(e,t={}){return(t.seriesFunctions||t.deniedNames?void 0:BJ.get(e??BA))??function(e,t={}){let r=new BX({...BA,...e},{seriesFunctions:{...BI,...t.seriesFunctions},deniedNames:t.deniedNames,site:Bf({definition:t.definition??"metadata context",path:"context"},BP,Bm)});return t.seriesFunctions||t.deniedNames||BJ.set(e??BA,r),r}(e,t)}(t.context,{seriesFunctions:t.seriesFunctions,deniedNames:t.deniedNames,definition:BQ}),n=t.sortFunctions??{},a={};for(let[t,i]of Object.entries(e)){!function(e,t){Fo(e)&&Fw(e,"the id is not allowed; give the rule another id"),t&&"object"==typeof t||Fw(e,"the entry must be an object"),void 0!==t.id&&t.id!==e&&Fw(e,`the entry states id "${t.id}", but its key is the id. Remove the id, or make it equal to the key.`);let{priority:r}=t;null!==r&&("number"==typeof r&&Number.isFinite(r)||Fw(e,`priority must be a finite number, or null to exclude the rule; got ${JSON.stringify(r)}`))}(t,i);let e=Bf({definition:BQ,path:`rule '${t}'`},BP,Bm),{id:o,...s}=function(e,t,r,n,a){Fg(BP.rule,t,r);let i=n.layer(e,t.context,Fc(r,"context")),o={site:r,program:n,layer:i,sortFunctions:a},s={id:e,series:n.seriesHook};if(void 0!==t.groupId&&(s.groupId=t.groupId),void 0!==t.viewportTypes&&(s.viewportTypes=t.viewportTypes),void 0!==t.handler&&(s.handler=t.handler),void 0!==t.matches){let e={...Fc(r,"matches"),readName:(e,t,r)=>B0(o,e,t,"matches",r)};s.matches=Bv(t.matches,e)}if(void 0!==t.groupBy){let e=B1(t.groupBy,Fc(r,"groupBy"),(e,t)=>"function"==typeof e?e:"string"!=typeof e?Ff(BP.name,e,t):B0(o,e,t,"groupBy"));e.length&&(s.groupBy=e)}if(void 0!==t.sortBy){let e=B1(t.sortBy,Fc(r,"sortBy"),(e,t)=>(function(e,t,r){if("function"==typeof e)return e;if("string"==typeof e){let n=r.program.readerAt(r.layer,e,t,{place:"sortBy"}),{program:a}=r;return(e,t,r)=>{let i=a.runtimeFrom(r,[e,t]);return function(e,t){let r=N2(e),n=N2(t);if(void 0!==r&&void 0!==n)return r-n;if(FV(e)||FV(t))return Number(FV(e))-Number(FV(t));let a=String(NJ(e)),i=String(NJ(t));return a<i?-1:+(a>i)}(n(i,e),n(i,t))}}if(!e||"object"!=typeof e||Array.isArray(e))return Ff(BP.sortKey,e,t);Fg(BP.sortKey,e,t);let n=e.sortFunction,a=Fi(r.sortFunctions,n);return"function"!=typeof a?Fd(Fc(t,"sortFunction"),`unknown sort function "${n}"; known: ${Object.keys(r.sortFunctions).join(", ")||"(none)"}`):a})(e,t,o));e.length&&(s.compareInstances=1===e.length?e[0]:(t,r,n)=>{for(let a of e){let e=a(t,r,n);if(Number.isFinite(e)&&0!==e)return e}return 0})}return void 0!==t.attributes&&(s.customAttributes=function(e,t,r){if("function"==typeof e)return e;if(!e||"object"!=typeof e||Array.isArray(e))return Fd(t,"expected an object of attribute values, keyed by attribute name, or a function (attributes, options) => Record<string, unknown>",e);let n=Object.entries(e).map(([e,n])=>{let a=Fc(t,e);return Fo(e)&&Fd(a,`the key "${e}" is not allowed`),[e,function(e,t,r){let{program:n,layer:a}=r;if("function"==typeof e){let r={key:`#attribute:${t.path}`,deps:new Map,layer:a};return(t,n,a)=>e(n,t.env(r,n[0],a))}if(BG(e,!1))return()=>e;if("string"==typeof e){let r=n.readerAt(a,e,t,{place:"attributes"});return(e,t,n)=>r(e,t[0],n)}if(!e||"object"!=typeof e||Array.isArray(e))return Ff(BP.attributeValue,e,t);let[i]=Fg(BP.attributeValue,e,t);if("expression"===i)return n.attributeExpression(a,e.expression,Fc(t,"expression"));let o=Fc(t,"template"),s=Bb(e.template,o).map(e=>"literal"in e?()=>e.literal:n.readerAt(a,e.name,o,{field:e.field,place:"attributes"}));return(e,t,r)=>s.map(n=>{let a=n(e,t[0],r);return FV(a)?"":String(a)}).join("")}(n,a,r)]}),{program:a}=r;return(e,t)=>{var r;let i,o=t.instances??[],s=a.runtimeFrom({series:t.series,displaySet:(r=t.series,(i=Fi(r,BD))instanceof B$?new B$(o,i.seriesInstances,i):new B$(o))},o),l={splitNumber:t.splitNumber,sopClassUids:e?.sopClassUids},d={};for(let[e,t]of n)d[e]=o.length?t(s,o,l):void 0;return d}}(t.attributes,Fc(r,"attributes"),o)),s}(t,i,e,r,n);a[t]={...s,priority:i.priority}}}(e,t)}(B8),Rt.getLogger("utilities.metadataProvider.compressedFrameData"),j2.COMPRESSED_FRAME_DATA;let{C:B6}=W;(eTr=eTz||(eTz={})).NO_DATA="noData",eTr.LOADING="loading",eTr.PRE_RENDER="preRender",eTr.NEEDS_RENDER="needsRender",eTr.RESIZE="resize",eTr.RENDERED="rendered";let B9=eTz;(eTn=eTH||(eTH={}))[eTn.FAR_REPLICATE=1]="FAR_REPLICATE",eTn[eTn.ADJACENT_REPLICATE=3]="ADJACENT_REPLICATE",eTn[eTn.SUBRESOLUTION=6]="SUBRESOLUTION",eTn[eTn.LOSSY=7]="LOSSY",eTn[eTn.FULL_RESOLUTION=8]="FULL_RESOLUTION";let B7=eTH;(eTa=eTG||(eTG={})).FRAME="f",eTa.SECOND="s";let We=j2;(eTi=eTq||(eTq={})).SUM="SUM",eTi.SUBTRACT="SUBTRACT",eTi.AVERAGE="AVERAGE",(eTo=eT$||(eT$={})).RLE="RLE",eTo.Volume="Volume";let Wt=eT$,Wr={Average:"average",ForegroundMajority:"foregroundMajority"},Wn={None:"none",BoxAverage:"boxAverage",BoxForegroundMajority:"boxForegroundMajority",Decimation:"decimation"},Wa="directLoad";(eTs=eTK||(eTK={})).Tiled="tiled",eTs.ContextPool="contextPool";let Wi=eTK,Wo={Auto:"auto",GPU:"gpu",CPU:"cpu"},Ws=Wo,Wl={hotIron:{name:"Hot Iron",numOfColors:256,colors:[[0,0,0,255],[2,0,0,255],[4,0,0,255],[6,0,0,255],[8,0,0,255],[10,0,0,255],[12,0,0,255],[14,0,0,255],[16,0,0,255],[18,0,0,255],[20,0,0,255],[22,0,0,255],[24,0,0,255],[26,0,0,255],[28,0,0,255],[30,0,0,255],[32,0,0,255],[34,0,0,255],[36,0,0,255],[38,0,0,255],[40,0,0,255],[42,0,0,255],[44,0,0,255],[46,0,0,255],[48,0,0,255],[50,0,0,255],[52,0,0,255],[54,0,0,255],[56,0,0,255],[58,0,0,255],[60,0,0,255],[62,0,0,255],[64,0,0,255],[66,0,0,255],[68,0,0,255],[70,0,0,255],[72,0,0,255],[74,0,0,255],[76,0,0,255],[78,0,0,255],[80,0,0,255],[82,0,0,255],[84,0,0,255],[86,0,0,255],[88,0,0,255],[90,0,0,255],[92,0,0,255],[94,0,0,255],[96,0,0,255],[98,0,0,255],[100,0,0,255],[102,0,0,255],[104,0,0,255],[106,0,0,255],[108,0,0,255],[110,0,0,255],[112,0,0,255],[114,0,0,255],[116,0,0,255],[118,0,0,255],[120,0,0,255],[122,0,0,255],[124,0,0,255],[126,0,0,255],[128,0,0,255],[130,0,0,255],[132,0,0,255],[134,0,0,255],[136,0,0,255],[138,0,0,255],[140,0,0,255],[142,0,0,255],[144,0,0,255],[146,0,0,255],[148,0,0,255],[150,0,0,255],[152,0,0,255],[154,0,0,255],[156,0,0,255],[158,0,0,255],[160,0,0,255],[162,0,0,255],[164,0,0,255],[166,0,0,255],[168,0,0,255],[170,0,0,255],[172,0,0,255],[174,0,0,255],[176,0,0,255],[178,0,0,255],[180,0,0,255],[182,0,0,255],[184,0,0,255],[186,0,0,255],[188,0,0,255],[190,0,0,255],[192,0,0,255],[194,0,0,255],[196,0,0,255],[198,0,0,255],[200,0,0,255],[202,0,0,255],[204,0,0,255],[206,0,0,255],[208,0,0,255],[210,0,0,255],[212,0,0,255],[214,0,0,255],[216,0,0,255],[218,0,0,255],[220,0,0,255],[222,0,0,255],[224,0,0,255],[226,0,0,255],[228,0,0,255],[230,0,0,255],[232,0,0,255],[234,0,0,255],[236,0,0,255],[238,0,0,255],[240,0,0,255],[242,0,0,255],[244,0,0,255],[246,0,0,255],[248,0,0,255],[250,0,0,255],[252,0,0,255],[254,0,0,255],[255,0,0,255],[255,2,0,255],[255,4,0,255],[255,6,0,255],[255,8,0,255],[255,10,0,255],[255,12,0,255],[255,14,0,255],[255,16,0,255],[255,18,0,255],[255,20,0,255],[255,22,0,255],[255,24,0,255],[255,26,0,255],[255,28,0,255],[255,30,0,255],[255,32,0,255],[255,34,0,255],[255,36,0,255],[255,38,0,255],[255,40,0,255],[255,42,0,255],[255,44,0,255],[255,46,0,255],[255,48,0,255],[255,50,0,255],[255,52,0,255],[255,54,0,255],[255,56,0,255],[255,58,0,255],[255,60,0,255],[255,62,0,255],[255,64,0,255],[255,66,0,255],[255,68,0,255],[255,70,0,255],[255,72,0,255],[255,74,0,255],[255,76,0,255],[255,78,0,255],[255,80,0,255],[255,82,0,255],[255,84,0,255],[255,86,0,255],[255,88,0,255],[255,90,0,255],[255,92,0,255],[255,94,0,255],[255,96,0,255],[255,98,0,255],[255,100,0,255],[255,102,0,255],[255,104,0,255],[255,106,0,255],[255,108,0,255],[255,110,0,255],[255,112,0,255],[255,114,0,255],[255,116,0,255],[255,118,0,255],[255,120,0,255],[255,122,0,255],[255,124,0,255],[255,126,0,255],[255,128,4,255],[255,130,8,255],[255,132,12,255],[255,134,16,255],[255,136,20,255],[255,138,24,255],[255,140,28,255],[255,142,32,255],[255,144,36,255],[255,146,40,255],[255,148,44,255],[255,150,48,255],[255,152,52,255],[255,154,56,255],[255,156,60,255],[255,158,64,255],[255,160,68,255],[255,162,72,255],[255,164,76,255],[255,166,80,255],[255,168,84,255],[255,170,88,255],[255,172,92,255],[255,174,96,255],[255,176,100,255],[255,178,104,255],[255,180,108,255],[255,182,112,255],[255,184,116,255],[255,186,120,255],[255,188,124,255],[255,190,128,255],[255,192,132,255],[255,194,136,255],[255,196,140,255],[255,198,144,255],[255,200,148,255],[255,202,152,255],[255,204,156,255],[255,206,160,255],[255,208,164,255],[255,210,168,255],[255,212,172,255],[255,214,176,255],[255,216,180,255],[255,218,184,255],[255,220,188,255],[255,222,192,255],[255,224,196,255],[255,226,200,255],[255,228,204,255],[255,230,208,255],[255,232,212,255],[255,234,216,255],[255,236,220,255],[255,238,224,255],[255,240,228,255],[255,242,232,255],[255,244,236,255],[255,246,240,255],[255,248,244,255],[255,250,248,255],[255,252,252,255],[255,255,255,255]]},pet:{name:"PET",numColors:256,colors:[[0,0,0,255],[0,2,1,255],[0,4,3,255],[0,6,5,255],[0,8,7,255],[0,10,9,255],[0,12,11,255],[0,14,13,255],[0,16,15,255],[0,18,17,255],[0,20,19,255],[0,22,21,255],[0,24,23,255],[0,26,25,255],[0,28,27,255],[0,30,29,255],[0,32,31,255],[0,34,33,255],[0,36,35,255],[0,38,37,255],[0,40,39,255],[0,42,41,255],[0,44,43,255],[0,46,45,255],[0,48,47,255],[0,50,49,255],[0,52,51,255],[0,54,53,255],[0,56,55,255],[0,58,57,255],[0,60,59,255],[0,62,61,255],[0,65,63,255],[0,67,65,255],[0,69,67,255],[0,71,69,255],[0,73,71,255],[0,75,73,255],[0,77,75,255],[0,79,77,255],[0,81,79,255],[0,83,81,255],[0,85,83,255],[0,87,85,255],[0,89,87,255],[0,91,89,255],[0,93,91,255],[0,95,93,255],[0,97,95,255],[0,99,97,255],[0,101,99,255],[0,103,101,255],[0,105,103,255],[0,107,105,255],[0,109,107,255],[0,111,109,255],[0,113,111,255],[0,115,113,255],[0,117,115,255],[0,119,117,255],[0,121,119,255],[0,123,121,255],[0,125,123,255],[0,128,125,255],[1,126,127,255],[3,124,129,255],[5,122,131,255],[7,120,133,255],[9,118,135,255],[11,116,137,255],[13,114,139,255],[15,112,141,255],[17,110,143,255],[19,108,145,255],[21,106,147,255],[23,104,149,255],[25,102,151,255],[27,100,153,255],[29,98,155,255],[31,96,157,255],[33,94,159,255],[35,92,161,255],[37,90,163,255],[39,88,165,255],[41,86,167,255],[43,84,169,255],[45,82,171,255],[47,80,173,255],[49,78,175,255],[51,76,177,255],[53,74,179,255],[55,72,181,255],[57,70,183,255],[59,68,185,255],[61,66,187,255],[63,64,189,255],[65,63,191,255],[67,61,193,255],[69,59,195,255],[71,57,197,255],[73,55,199,255],[75,53,201,255],[77,51,203,255],[79,49,205,255],[81,47,207,255],[83,45,209,255],[85,43,211,255],[86,41,213,255],[88,39,215,255],[90,37,217,255],[92,35,219,255],[94,33,221,255],[96,31,223,255],[98,29,225,255],[100,27,227,255],[102,25,229,255],[104,23,231,255],[106,21,233,255],[108,19,235,255],[110,17,237,255],[112,15,239,255],[114,13,241,255],[116,11,243,255],[118,9,245,255],[120,7,247,255],[122,5,249,255],[124,3,251,255],[126,1,253,255],[128,0,255,255],[130,2,252,255],[132,4,248,255],[134,6,244,255],[136,8,240,255],[138,10,236,255],[140,12,232,255],[142,14,228,255],[144,16,224,255],[146,18,220,255],[148,20,216,255],[150,22,212,255],[152,24,208,255],[154,26,204,255],[156,28,200,255],[158,30,196,255],[160,32,192,255],[162,34,188,255],[164,36,184,255],[166,38,180,255],[168,40,176,255],[170,42,172,255],[171,44,168,255],[173,46,164,255],[175,48,160,255],[177,50,156,255],[179,52,152,255],[181,54,148,255],[183,56,144,255],[185,58,140,255],[187,60,136,255],[189,62,132,255],[191,64,128,255],[193,66,124,255],[195,68,120,255],[197,70,116,255],[199,72,112,255],[201,74,108,255],[203,76,104,255],[205,78,100,255],[207,80,96,255],[209,82,92,255],[211,84,88,255],[213,86,84,255],[215,88,80,255],[217,90,76,255],[219,92,72,255],[221,94,68,255],[223,96,64,255],[225,98,60,255],[227,100,56,255],[229,102,52,255],[231,104,48,255],[233,106,44,255],[235,108,40,255],[237,110,36,255],[239,112,32,255],[241,114,28,255],[243,116,24,255],[245,118,20,255],[247,120,16,255],[249,122,12,255],[251,124,8,255],[253,126,4,255],[255,128,0,255],[255,130,4,255],[255,132,8,255],[255,134,12,255],[255,136,16,255],[255,138,20,255],[255,140,24,255],[255,142,28,255],[255,144,32,255],[255,146,36,255],[255,148,40,255],[255,150,44,255],[255,152,48,255],[255,154,52,255],[255,156,56,255],[255,158,60,255],[255,160,64,255],[255,162,68,255],[255,164,72,255],[255,166,76,255],[255,168,80,255],[255,170,85,255],[255,172,89,255],[255,174,93,255],[255,176,97,255],[255,178,101,255],[255,180,105,255],[255,182,109,255],[255,184,113,255],[255,186,117,255],[255,188,121,255],[255,190,125,255],[255,192,129,255],[255,194,133,255],[255,196,137,255],[255,198,141,255],[255,200,145,255],[255,202,149,255],[255,204,153,255],[255,206,157,255],[255,208,161,255],[255,210,165,255],[255,212,170,255],[255,214,174,255],[255,216,178,255],[255,218,182,255],[255,220,186,255],[255,222,190,255],[255,224,194,255],[255,226,198,255],[255,228,202,255],[255,230,206,255],[255,232,210,255],[255,234,214,255],[255,236,218,255],[255,238,222,255],[255,240,226,255],[255,242,230,255],[255,244,234,255],[255,246,238,255],[255,248,242,255],[255,250,246,255],[255,252,250,255],[255,255,255,255]]},hotMetalBlue:{name:"Hot Metal Blue",numColors:256,colors:[[0,0,0,255],[0,0,2,255],[0,0,4,255],[0,0,6,255],[0,0,8,255],[0,0,10,255],[0,0,12,255],[0,0,14,255],[0,0,16,255],[0,0,17,255],[0,0,19,255],[0,0,21,255],[0,0,23,255],[0,0,25,255],[0,0,27,255],[0,0,29,255],[0,0,31,255],[0,0,33,255],[0,0,35,255],[0,0,37,255],[0,0,39,255],[0,0,41,255],[0,0,43,255],[0,0,45,255],[0,0,47,255],[0,0,49,255],[0,0,51,255],[0,0,53,255],[0,0,55,255],[0,0,57,255],[0,0,59,255],[0,0,61,255],[0,0,63,255],[0,0,65,255],[0,0,67,255],[0,0,69,255],[0,0,71,255],[0,0,73,255],[0,0,75,255],[0,0,77,255],[0,0,79,255],[0,0,81,255],[0,0,83,255],[0,0,84,255],[0,0,86,255],[0,0,88,255],[0,0,90,255],[0,0,92,255],[0,0,94,255],[0,0,96,255],[0,0,98,255],[0,0,100,255],[0,0,102,255],[0,0,104,255],[0,0,106,255],[0,0,108,255],[0,0,110,255],[0,0,112,255],[0,0,114,255],[0,0,116,255],[0,0,117,255],[0,0,119,255],[0,0,121,255],[0,0,123,255],[0,0,125,255],[0,0,127,255],[0,0,129,255],[0,0,131,255],[0,0,133,255],[0,0,135,255],[0,0,137,255],[0,0,139,255],[0,0,141,255],[0,0,143,255],[0,0,145,255],[0,0,147,255],[0,0,149,255],[0,0,151,255],[0,0,153,255],[0,0,155,255],[0,0,157,255],[0,0,159,255],[0,0,161,255],[0,0,163,255],[0,0,165,255],[0,0,167,255],[3,0,169,255],[6,0,171,255],[9,0,173,255],[12,0,175,255],[15,0,177,255],[18,0,179,255],[21,0,181,255],[24,0,183,255],[26,0,184,255],[29,0,186,255],[32,0,188,255],[35,0,190,255],[38,0,192,255],[41,0,194,255],[44,0,196,255],[47,0,198,255],[50,0,200,255],[52,0,197,255],[55,0,194,255],[57,0,191,255],[59,0,188,255],[62,0,185,255],[64,0,182,255],[66,0,179,255],[69,0,176,255],[71,0,174,255],[74,0,171,255],[76,0,168,255],[78,0,165,255],[81,0,162,255],[83,0,159,255],[85,0,156,255],[88,0,153,255],[90,0,150,255],[93,2,144,255],[96,4,138,255],[99,6,132,255],[102,8,126,255],[105,9,121,255],[108,11,115,255],[111,13,109,255],[114,15,103,255],[116,17,97,255],[119,19,91,255],[122,21,85,255],[125,23,79,255],[128,24,74,255],[131,26,68,255],[134,28,62,255],[137,30,56,255],[140,32,50,255],[143,34,47,255],[146,36,44,255],[149,38,41,255],[152,40,38,255],[155,41,35,255],[158,43,32,255],[161,45,29,255],[164,47,26,255],[166,49,24,255],[169,51,21,255],[172,53,18,255],[175,55,15,255],[178,56,12,255],[181,58,9,255],[184,60,6,255],[187,62,3,255],[190,64,0,255],[194,66,0,255],[198,68,0,255],[201,70,0,255],[205,72,0,255],[209,73,0,255],[213,75,0,255],[217,77,0,255],[221,79,0,255],[224,81,0,255],[228,83,0,255],[232,85,0,255],[236,87,0,255],[240,88,0,255],[244,90,0,255],[247,92,0,255],[251,94,0,255],[255,96,0,255],[255,98,3,255],[255,100,6,255],[255,102,9,255],[255,104,12,255],[255,105,15,255],[255,107,18,255],[255,109,21,255],[255,111,24,255],[255,113,26,255],[255,115,29,255],[255,117,32,255],[255,119,35,255],[255,120,38,255],[255,122,41,255],[255,124,44,255],[255,126,47,255],[255,128,50,255],[255,130,53,255],[255,132,56,255],[255,134,59,255],[255,136,62,255],[255,137,65,255],[255,139,68,255],[255,141,71,255],[255,143,74,255],[255,145,76,255],[255,147,79,255],[255,149,82,255],[255,151,85,255],[255,152,88,255],[255,154,91,255],[255,156,94,255],[255,158,97,255],[255,160,100,255],[255,162,103,255],[255,164,106,255],[255,166,109,255],[255,168,112,255],[255,169,115,255],[255,171,118,255],[255,173,121,255],[255,175,124,255],[255,177,126,255],[255,179,129,255],[255,181,132,255],[255,183,135,255],[255,184,138,255],[255,186,141,255],[255,188,144,255],[255,190,147,255],[255,192,150,255],[255,194,153,255],[255,196,156,255],[255,198,159,255],[255,200,162,255],[255,201,165,255],[255,203,168,255],[255,205,171,255],[255,207,174,255],[255,209,176,255],[255,211,179,255],[255,213,182,255],[255,215,185,255],[255,216,188,255],[255,218,191,255],[255,220,194,255],[255,222,197,255],[255,224,200,255],[255,226,203,255],[255,228,206,255],[255,229,210,255],[255,231,213,255],[255,233,216,255],[255,235,219,255],[255,237,223,255],[255,239,226,255],[255,240,229,255],[255,242,232,255],[255,244,236,255],[255,246,239,255],[255,248,242,255],[255,250,245,255],[255,251,249,255],[255,253,252,255],[255,255,255,255]]},pet20Step:{name:"PET 20 Step",numColors:256,colors:[[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255]]},gray:{name:"Gray",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,1,1]],green:[[0,0,0],[1,1,1]],blue:[[0,0,0],[1,1,1]]}},jet:{name:"Jet",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.35,0,0],[.66,1,1],[.89,1,1],[1,.5,.5]],green:[[0,0,0],[.125,0,0],[.375,1,1],[.64,1,1],[.91,0,0],[1,0,0]],blue:[[0,.5,.5],[.11,1,1],[.34,1,1],[.65,0,0],[1,0,0]]}},hsv:{name:"HSV",numColors:256,gamma:1,segmentedData:{red:[[0,1,1],[.15873,1,1],[.174603,.96875,.96875],[.333333,.03125,.03125],[.349206,0,0],[.666667,0,0],[.68254,.03125,.03125],[.84127,.96875,.96875],[.857143,1,1],[1,1,1]],green:[[0,0,0],[.15873,.9375,.9375],[.174603,1,1],[.507937,1,1],[.666667,.0625,.0625],[.68254,0,0],[1,0,0]],blue:[[0,0,0],[.333333,0,0],[.349206,.0625,.0625],[.507937,1,1],[.84127,1,1],[.857143,.9375,.9375],[1,.09375,.09375]]}},hot:{name:"Hot",numColors:256,gamma:1,segmentedData:{red:[[0,.0416,.0416],[.365079,1,1],[1,1,1]],green:[[0,0,0],[.365079,0,0],[.746032,1,1],[1,1,1]],blue:[[0,0,0],[.746032,0,0],[1,1,1]]}},cool:{name:"Cool",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,1,1]],green:[[0,1,1],[1,0,0]],blue:[[0,1,1],[1,1,1]]}},spring:{name:"Spring",numColors:256,gamma:1,segmentedData:{red:[[0,1,1],[1,1,1]],green:[[0,0,0],[1,1,1]],blue:[[0,1,1],[1,0,0]]}},summer:{name:"Summer",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,1,1]],green:[[0,.5,.5],[1,1,1]],blue:[[0,.4,.4],[1,.4,.4]]}},autumn:{name:"Autumn",numColors:256,gamma:1,segmentedData:{red:[[0,1,1],[1,1,1]],green:[[0,0,0],[1,1,1]],blue:[[0,0,0],[1,0,0]]}},winter:{name:"Winter",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,0,0]],green:[[0,0,0],[1,1,1]],blue:[[0,1,1],[1,.5,.5]]}},bone:{name:"Bone",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.746032,.652778,.652778],[1,1,1]],green:[[0,0,0],[.365079,.319444,.319444],[.746032,.777778,.777778],[1,1,1]],blue:[[0,0,0],[.365079,.444444,.444444],[1,1,1]]}},copper:{name:"Copper",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.809524,1,1],[1,1,1]],green:[[0,0,0],[1,.7812,.7812]],blue:[[0,0,0],[1,.4975,.4975]]}},spectral:{name:"Spectral",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.05,.4667,.4667],[.1,.5333,.5333],[.15,0,0],[.2,0,0],[.25,0,0],[.3,0,0],[.35,0,0],[.4,0,0],[.45,0,0],[.5,0,0],[.55,0,0],[.6,0,0],[.65,.7333,.7333],[.7,.9333,.9333],[.75,1,1],[.8,1,1],[.85,1,1],[.9,.8667,.8667],[.95,.8,.8],[1,.8,.8]],green:[[0,0,0],[.05,0,0],[.1,0,0],[.15,0,0],[.2,0,0],[.25,.4667,.4667],[.3,.6,.6],[.35,.6667,.6667],[.4,.6667,.6667],[.45,.6,.6],[.5,.7333,.7333],[.55,.8667,.8667],[.6,1,1],[.65,1,1],[.7,.9333,.9333],[.75,.8,.8],[.8,.6,.6],[.85,0,0],[.9,0,0],[.95,0,0],[1,.8,.8]],blue:[[0,0,0],[.05,.5333,.5333],[.1,.6,.6],[.15,.6667,.6667],[.2,.8667,.8667],[.25,.8667,.8667],[.3,.8667,.8667],[.35,.6667,.6667],[.4,.5333,.5333],[.45,0,0],[.5,0,0],[.55,0,0],[.6,0,0],[.65,0,0],[.7,0,0],[.75,0,0],[.8,0,0],[.85,0,0],[.9,0,0],[.95,0,0],[1,.8,.8]]}},coolwarm:{name:"CoolWarm",numColors:256,gamma:1,segmentedData:{red:[[0,.2298057,.2298057],[.03125,.26623388,.26623388],[.0625,.30386891,.30386891],[.09375,.342804478,.342804478],[.125,.38301334,.38301334],[.15625,.424369608,.424369608],[.1875,.46666708,.46666708],[.21875,.509635204,.509635204],[.25,.552953156,.552953156],[.28125,.596262162,.596262162],[.3125,.639176211,.639176211],[.34375,.681291281,.681291281],[.375,.722193294,.722193294],[.40625,.761464949,.761464949],[.4375,.798691636,.798691636],[.46875,.833466556,.833466556],[.5,.865395197,.865395197],[.53125,.897787179,.897787179],[.5625,.924127593,.924127593],[.59375,.944468518,.944468518],[.625,.958852946,.958852946],[.65625,.96732803,.96732803],[.6875,.969954137,.969954137],[.71875,.966811177,.966811177],[.75,.958003065,.958003065],[.78125,.943660866,.943660866],[.8125,.923944917,.923944917],[.84375,.89904617,.89904617],[.875,.869186849,.869186849],[.90625,.834620542,.834620542],[.9375,.795631745,.795631745],[.96875,.752534934,.752534934],[1,.705673158,.705673158]],green:[[0,.298717966,.298717966],[.03125,.353094838,.353094838],[.0625,.406535296,.406535296],[.09375,.458757618,.458757618],[.125,.50941904,.50941904],[.15625,.558148092,.558148092],[.1875,.604562568,.604562568],[.21875,.648280772,.648280772],[.25,.688929332,.688929332],[.28125,.726149107,.726149107],[.3125,.759599947,.759599947],[.34375,.788964712,.788964712],[.375,.813952739,.813952739],[.40625,.834302879,.834302879],[.4375,.849786142,.849786142],[.46875,.860207984,.860207984],[.5,.86541021,.86541021],[.53125,.848937047,.848937047],[.5625,.827384882,.827384882],[.59375,.800927443,.800927443],[.625,.769767752,.769767752],[.65625,.734132809,.734132809],[.6875,.694266682,.694266682],[.71875,.650421156,.650421156],[.75,.602842431,.602842431],[.78125,.551750968,.551750968],[.8125,.49730856,.49730856],[.84375,.439559467,.439559467],[.875,.378313092,.378313092],[.90625,.312874446,.312874446],[.9375,.24128379,.24128379],[.96875,.157246067,.157246067],[1,.01555616,.01555616]],blue:[[0,.753683153,.753683153],[.03125,.801466763,.801466763],[.0625,.84495867,.84495867],[.09375,.883725899,.883725899],[.125,.917387822,.917387822],[.15625,.945619588,.945619588],[.1875,.968154911,.968154911],[.21875,.98478814,.98478814],[.25,.995375608,.995375608],[.28125,.999836203,.999836203],[.3125,.998151185,.998151185],[.34375,.990363227,.990363227],[.375,.976574709,.976574709],[.40625,.956945269,.956945269],[.4375,.931688648,.931688648],[.46875,.901068838,.901068838],[.5,.865395561,.865395561],[.53125,.820880546,.820880546],[.5625,.774508472,.774508472],[.59375,.726736146,.726736146],[.625,.678007945,.678007945],[.65625,.628751763,.628751763],[.6875,.579375448,.579375448],[.71875,.530263762,.530263762],[.75,.481775914,.481775914],[.78125,.434243684,.434243684],[.8125,.387970225,.387970225],[.84375,.343229596,.343229596],[.875,.300267182,.300267182],[.90625,.259301199,.259301199],[.9375,.220525627,.220525627],[.96875,.184115123,.184115123],[1,.150232812,.150232812]]}},blues:{name:"Blues",numColors:256,gamma:1,segmentedData:{red:[[0,.9686274528503418,.9686274528503418],[.125,.8705882430076599,.8705882430076599],[.25,.7764706015586853,.7764706015586853],[.375,.6196078658103943,.6196078658103943],[.5,.41960784792900085,.41960784792900085],[.625,.25882354378700256,.25882354378700256],[.75,.12941177189350128,.12941177189350128],[.875,.0313725508749485,.0313725508749485],[1,.0313725508749485,.0313725508749485]],green:[[0,.9843137264251709,.9843137264251709],[.125,.9215686321258545,.9215686321258545],[.25,.8588235378265381,.8588235378265381],[.375,.7921568751335144,.7921568751335144],[.5,.6823529601097107,.6823529601097107],[.625,.572549045085907,.572549045085907],[.75,.4431372582912445,.4431372582912445],[.875,.3176470696926117,.3176470696926117],[1,.1882352977991104,.1882352977991104]],blue:[[0,1,1],[.125,.9686274528503418,.9686274528503418],[.25,.9372549057006836,.9372549057006836],[.375,.8823529481887817,.8823529481887817],[.5,.8392156958580017,.8392156958580017],[.625,.7764706015586853,.7764706015586853],[.75,.7098039388656616,.7098039388656616],[.875,.6117647290229797,.6117647290229797],[1,.41960784792900085,.41960784792900085]]}}},Wd={MINIMUM_SLAB_THICKNESS:.05,MAXIMUM_RAY_DISTANCE:1e6};Object.freeze(Wd);let Wu=Wd,Wc=.001,Wh=function e(t){for(let r of Object.getOwnPropertyNames(t)){let n=t[r];n&&"object"==typeof n&&e(n)}return Object.freeze(t)}({axial:{viewPlaneNormal:[0,0,-1],viewUp:[0,-1,0],viewRight:[1,0,0]},sagittal:{viewPlaneNormal:[1,0,0],viewUp:[0,0,1],viewRight:[0,1,0]},coronal:{viewPlaneNormal:[0,-1,0],viewUp:[0,0,1],viewRight:[1,0,0]}}),Wp=[{name:"CT-AAA",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"12 -3024 0 143.556 0 166.222 0.686275 214.389 0.696078 419.736 0.833333 3071 0.803922",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"24 -3024 0 0 0 143.556 0.615686 0.356863 0.184314 166.222 0.882353 0.603922 0.290196 214.389 1 1 1 419.736 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-AAA2",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"16 -3024 0 129.542 0 145.244 0.166667 157.02 0.5 169.918 0.627451 395.575 0.8125 1578.73 0.8125 3071 0.8125",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"32 -3024 0 0 0 129.542 0.54902 0.25098 0.14902 145.244 0.6 0.627451 0.843137 157.02 0.890196 0.47451 0.6 169.918 0.992157 0.870588 0.392157 395.575 1 0.886275 0.658824 1578.73 1 0.829256 0.957922 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Bone",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"8 -3024 0 -16.4458 0 641.385 0.715686 3071 0.705882",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"16 -3024 0 0 0 -16.4458 0.729412 0.254902 0.301961 641.385 0.905882 0.815686 0.552941 3071 1 1 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Bones",gradientOpacity:"4 0 1 985.12 1",specularPower:"1",scalarOpacity:"8 -1000 0 152.19 0 278.93 0.190476 952 0.2",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"20 -1000 0.3 0.3 1 -488 0.3 1 0.3 463.28 1 0 0 659.15 1 0.912535 0.0374849 953 1 0.3 0.3",diffuse:"1",interpolation:"1"},{name:"CT-Cardiac",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"12 -3024 0 -77.6875 0 94.9518 0.285714 179.052 0.553571 260.439 0.848214 3071 0.875",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"24 -3024 0 0 0 -77.6875 0.54902 0.25098 0.14902 94.9518 0.882353 0.603922 0.290196 179.052 1 0.937033 0.954531 260.439 0.615686 0 0 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Cardiac2",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"12 -3024 0 42.8964 0 163.488 0.428571 277.642 0.776786 1587 0.754902 3071 0.754902",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"24 -3024 0 0 0 42.8964 0.54902 0.25098 0.14902 163.488 0.917647 0.639216 0.0588235 277.642 1 0.878431 0.623529 1587 1 1 1 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Cardiac3",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"14 -3024 0 -86.9767 0 45.3791 0.169643 139.919 0.589286 347.907 0.607143 1224.16 0.607143 3071 0.616071",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"28 -3024 0 0 0 -86.9767 0 0.25098 1 45.3791 1 0 0 139.919 1 0.894893 0.894893 347.907 1 1 0.25098 1224.16 1 1 1 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Chest-Contrast-Enhanced",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"10 -3024 0 67.0106 0 251.105 0.446429 439.291 0.625 3071 0.616071",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"20 -3024 0 0 0 67.0106 0.54902 0.25098 0.14902 251.105 0.882353 0.603922 0.290196 439.291 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Chest-Vessels",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"10 -3024 0 -1278.35 0 22.8277 0.428571 439.291 0.625 3071 0.616071",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"20 -3024 0 0 0 -1278.35 0.54902 0.25098 0.14902 22.8277 0.882353 0.603922 0.290196 439.291 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"1",interpolation:"1"},{name:"CT-Coronary-Arteries",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"12 -2048 0 136.47 0 159.215 0.258929 318.43 0.571429 478.693 0.776786 3661 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"24 -2048 0 0 0 136.47 0 0 0 159.215 0.159804 0.159804 0.159804 318.43 0.764706 0.764706 0.764706 478.693 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Coronary-Arteries-2",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"14 -2048 0 142.677 0 145.016 0.116071 192.174 0.5625 217.24 0.776786 384.347 0.830357 3661 0.830357",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"28 -2048 0 0 0 142.677 0 0 0 145.016 0.615686 0 0.0156863 192.174 0.909804 0.454902 0 217.24 0.972549 0.807843 0.611765 384.347 0.909804 0.909804 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Coronary-Arteries-3",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"14 -2048 0 128.643 0 129.982 0.0982143 173.636 0.669643 255.884 0.857143 584.878 0.866071 3661 1",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"28 -2048 0 0 0 128.643 0 0 0 129.982 0.615686 0 0.0156863 173.636 0.909804 0.454902 0 255.884 0.886275 0.886275 0.886275 584.878 0.968627 0.968627 0.968627 3661 1 1 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Cropped-Volume-Bone",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"10 -2048 0 -451 0 -450 1 1050 1 3661 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"20 -2048 0 0 0 -451 0 0 0 -450 0.0556356 0.0556356 0.0556356 1050 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Fat",gradientOpacity:"6 0 1 985.12 1 988 1",specularPower:"1",scalarOpacity:"14 -1000 0 -100 0 -99 0.15 -60 0.15 -59 0 101.2 0 952 0",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"36 -1000 0.3 0.3 1 -497.5 0.3 1 0.3 -99 0 0 1 -76.946 0 1 0 -65.481 0.835431 0.888889 0.0165387 83.89 1 0 0 463.28 1 0 0 659.15 1 0.912535 0.0374849 2952 1 0.300267 0.299886",diffuse:"1",interpolation:"1"},{name:"CT-Liver-Vasculature",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"14 -2048 0 149.113 0 157.884 0.482143 339.96 0.660714 388.526 0.830357 1197.95 0.839286 3661 0.848214",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"28 -2048 0 0 0 149.113 0 0 0 157.884 0.501961 0.25098 0 339.96 0.695386 0.59603 0.36886 388.526 0.854902 0.85098 0.827451 1197.95 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Lung",gradientOpacity:"6 0 1 985.12 1 988 1",specularPower:"1",scalarOpacity:"12 -1000 0 -600 0 -599 0.15 -400 0.15 -399 0 2952 0",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"24 -1000 0.3 0.3 1 -600 0 0 1 -530 0.134704 0.781726 0.0724558 -460 0.929244 1 0.109473 -400 0.888889 0.254949 0.0240258 2952 1 0.3 0.3",diffuse:"1",interpolation:"1"},{name:"CT-MIP",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"8 -3024 0 -637.62 0 700 1 3071 1",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"16 -3024 0 0 0 -637.62 1 1 1 700 1 1 1 3071 1 1 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Muscle",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"10 -3024 0 -155.407 0 217.641 0.676471 419.736 0.833333 3071 0.803922",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"20 -3024 0 0 0 -155.407 0.54902 0.25098 0.14902 217.641 0.882353 0.603922 0.290196 419.736 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Pulmonary-Arteries",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"14 -2048 0 -568.625 0 -364.081 0.0714286 -244.813 0.401786 18.2775 0.607143 447.798 0.830357 3592.73 0.839286",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"28 -2048 0 0 0 -568.625 0 0 0 -364.081 0.396078 0.301961 0.180392 -244.813 0.611765 0.352941 0.0705882 18.2775 0.843137 0.0156863 0.156863 447.798 0.752941 0.752941 0.752941 3592.73 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Soft-Tissue",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"10 -2048 0 -167.01 0 -160 1 240 1 3661 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"20 -2048 0 0 0 -167.01 0 0 0 -160 0.0556356 0.0556356 0.0556356 240 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Air",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"8 -3024 0.705882 -900.0 0.715686 -500.0 0 3071 0",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"16 -3024 1 1 1 -900.0 0.2 1.0 1.0 -500.0 0.3 0.3 1.0 3071 0 0 0 ",diffuse:"0.9",interpolation:"1"},{name:"MR-Angio",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"12 -2048 0 151.354 0 158.279 0.4375 190.112 0.580357 200.873 0.732143 3661 0.741071",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"24 -2048 0 0 0 151.354 0 0 0 158.279 0.74902 0.376471 0 190.112 1 0.866667 0.733333 200.873 0.937255 0.937255 0.937255 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"MR-Default",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"12 0 0 20 0 40 0.15 120 0.3 220 0.375 1024 0.5",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"24 0 0 0 0 20 0.168627 0 0 40 0.403922 0.145098 0.0784314 120 0.780392 0.607843 0.380392 220 0.847059 0.835294 0.788235 1024 1 1 1",diffuse:"1",interpolation:"1"},{name:"MR-MIP",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"8 0 0 98.3725 0 416.637 1 2800 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"16 0 1 1 1 98.3725 1 1 1 416.637 1 1 1 2800 1 1 1",diffuse:"1",interpolation:"1"},{name:"MR-T2-Brain",gradientOpacity:"4 0 1 160.25 1",specularPower:"40",scalarOpacity:"10 0 0 36.05 0 218.302 0.171429 412.406 1 641 1",specular:"0.5",shade:"1",ambient:"0.3",colorTransfer:"16 0 0 0 0 98.7223 0.956863 0.839216 0.192157 412.406 0 0.592157 0.807843 641 1 1 1",diffuse:"0.6",interpolation:"1"},{name:"DTI-FA-Brain",gradientOpacity:"4 0 1 0.9950 1",specularPower:"40",scalarOpacity:"16 0 0 0 0 0.3501 0.0158 0.49379 0.7619 0.6419 1 0.9920 1 0.9950 0 0.9950 0",specular:"0.5",shade:"1",ambient:"0.3",colorTransfer:"28 0 1 0 0 0 1 0 0 0.24974 0.4941 1 0 0.49949 0 0.9882 1 0.7492 0.51764 0 1 0.9950 1 0 0 0.9950 1 0 0",diffuse:"0.9",interpolation:"1"}],Wm={},Wf=e=>Wm[e],Wg=()=>{let e=Object.keys(Wm).map(e=>Wm[e]);return e.sort((e,t)=>"_"===e.id[0]&&"_"!==t.id[0]?1:"_"!==e.id[0]&&"_"===t.id[0]?-1:0),e},Wy=e=>e&&"object"==typeof e&&"[object RegExp]"!==Object.prototype.toString.call(e)&&"[object Date]"!==Object.prototype.toString.call(e),Wv=(e,t)=>t&&!0===t.clone&&Wy(e)?Wx(Array.isArray(e)?[]:{},e,t):e,Wb=(e,t,r)=>{let n=e.slice();return t.forEach(function(t,a){void 0===n[a]?n[a]=Wv(t,r):Wy(t)?n[a]=Wx(e[a],t,r):-1===e.indexOf(t)&&(n[a]=Wv(t,r))}),n},Wx=(e={},t={},r)=>{let n,a=Array.isArray(t),i=(r||{arrayMerge:Wb}).arrayMerge||Wb;return a?Array.isArray(e)?i(e,t,r):Wv(t,r):(n={},Wy(e)&&Object.keys(e).forEach(function(t){n[t]=Wv(e[t],r)}),Object.keys(t).forEach(function(a){Wy(t[a])&&e[a]?n[a]=Wx(e[a],t[a],r):n[a]=Wv(t[a],r)}),n)},Ww=Symbol("Comlink.proxy"),WC=Symbol("Comlink.endpoint"),Wk=Symbol("Comlink.releaseProxy"),WM=Symbol("Comlink.finalizer"),WS=Symbol("Comlink.thrown"),WI=e=>"object"==typeof e&&null!==e||"function"==typeof e,WT=new Map([["proxy",{canHandle:e=>WI(e)&&e[Ww],serialize(e){let{port1:t,port2:r}=new MessageChannel;return function e(t,r=globalThis,n=["*"]){r.addEventListener("message",function a(i){let o;if(!i||!i.data)return;if(!function(e,t){for(let r of e)if(t===r||"*"===r||r instanceof RegExp&&r.test(t))return!0;return!1}(n,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);let{id:s,type:l,path:d}=Object.assign({path:[]},i.data),u=(i.data.argumentList||[]).map(WL);try{var c,h,p;let r=d.slice(0,-1).reduce((e,t)=>e[t],t),n=d.reduce((e,t)=>e[t],t);switch(l){case"GET":o=n;break;case"SET":r[d.slice(-1)[0]]=WL(i.data.value),o=!0;break;case"APPLY":o=n.apply(r,u);break;case"CONSTRUCT":c=new n(...u),o=Object.assign(c,{[Ww]:!0});break;case"ENDPOINT":{let{port1:r,port2:n}=new MessageChannel;e(t,n),h=r,p=[r],WN.set(h,p),o=h}break;case"RELEASE":o=void 0;break;default:return}}catch(e){o={value:e,[WS]:0}}Promise.resolve(o).catch(e=>({value:e,[WS]:0})).then(e=>{let[n,i]=WR(e);r.postMessage(Object.assign(Object.assign({},n),{id:s}),i),"RELEASE"===l&&(r.removeEventListener("message",a),W_(r),WM in t&&"function"==typeof t[WM]&&t[WM]())}).catch(e=>{let[t,n]=WR({value:TypeError("Unserializable return value"),[WS]:0});r.postMessage(Object.assign(Object.assign({},t),{id:s}),n)})}),r.start&&r.start()}(e,t),[r,[r]]},deserialize:e=>{var t;let r;return e.start(),t=e,r=new Map,t.addEventListener("message",function(e){let{data:t}=e;if(!t||!t.id)return;let n=r.get(t.id);if(n)try{n(t)}finally{r.delete(t.id)}}),function e(t,r,n=[],a=function(){}){let i,o=!1,s=new Proxy(a,{get(a,i){if(WP(o),i===Wk)return()=>{WA&&WA.unregister(s),WE(t),r.clear(),o=!0};if("then"===i){if(0===n.length)return{then:()=>s};let e=Wj(t,r,{type:"GET",path:n.map(e=>e.toString())}).then(WL);return e.then.bind(e)}return e(t,r,[...n,i])},set(e,a,i){WP(o);let[s,l]=WR(i);return Wj(t,r,{type:"SET",path:[...n,a].map(e=>e.toString()),value:s},l).then(WL)},apply(a,i,s){WP(o);let l=n[n.length-1];if(l===WC)return Wj(t,r,{type:"ENDPOINT"}).then(WL);if("bind"===l)return e(t,r,n.slice(0,-1));let[d,u]=WO(s);return Wj(t,r,{type:"APPLY",path:n.map(e=>e.toString()),argumentList:d},u).then(WL)},construct(e,a){WP(o);let[i,s]=WO(a);return Wj(t,r,{type:"CONSTRUCT",path:n.map(e=>e.toString()),argumentList:i},s).then(WL)}});return i=(WD.get(t)||0)+1,WD.set(t,i),WA&&WA.register(s,t,s),s}(t,r,[],void 0)}}],["throw",{canHandle:e=>WI(e)&&WS in e,serialize:({value:e})=>[e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[]],deserialize(e){if(e.isError)throw Object.assign(Error(e.value.message),e.value);throw e.value}}]]);function W_(e){"MessagePort"===e.constructor.name&&e.close()}function WP(e){if(e)throw Error("Proxy has been released and is not useable")}function WE(e){return Wj(e,new Map,{type:"RELEASE"}).then(()=>{W_(e)})}let WD=new WeakMap,WA="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{let t=(WD.get(e)||0)-1;WD.set(e,t),0===t&&WE(e)});function WO(e){var t;let r=e.map(WR);return[r.map(e=>e[0]),(t=r.map(e=>e[1]),Array.prototype.concat.apply([],t))]}let WN=new WeakMap;function WR(e){for(let[t,r]of WT)if(r.canHandle(e)){let[n,a]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},a]}return[{type:"RAW",value:e},WN.get(e)||[]]}function WL(e){switch(e.type){case"HANDLER":return WT.get(e.name).deserialize(e.value);case"RAW":return e.value}}function Wj(e,t,r,n){return new Promise(a=>{let i=[,,,,].fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");t.set(i,a),e.start&&e.start(),e.postMessage(Object.assign({id:i},r),n)})}function WV(){return"function"==typeof crypto.randomUUID?crypto.randomUUID():"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}let{pp:WF,tZ:WB,gE:WW,uu:WU,UA:Wz,LL:WH,_E:WG,sM:Wq,Qe:W$,xC:WK,RZ:WY,UX:WX,HL:WZ,U5:WJ,Rm:WQ}=V,{bM:W0}=V;Wz.getLogger("growCut");let W1=WU.getLogger("requestPool","requestPoolManager");class W2{constructor(e){this.numRequests={[jj.Interaction]:0,[jj.Thumbnail]:0,[jj.Prefetch]:0,[jj.Compute]:0},this.id=e||WV(),this.requestPool={[jj.Interaction]:{0:[]},[jj.Thumbnail]:{0:[]},[jj.Prefetch]:{0:[]},[jj.Compute]:{0:[]}},this.grabDelay=5,this.awake=!1,this.numRequests={[jj.Interaction]:0,[jj.Thumbnail]:0,[jj.Prefetch]:0,[jj.Compute]:0},this.maxNumRequests={[jj.Interaction]:6,[jj.Thumbnail]:6,[jj.Prefetch]:5,[jj.Compute]:1e3}}setMaxSimultaneousRequests(e,t){this.maxNumRequests[e]=t}getMaxSimultaneousRequests(e){return this.maxNumRequests[e]}destroy(){this.timeoutHandle&&window.clearTimeout(this.timeoutHandle)}addRequest(e,t,r,n=0){void 0===this.requestPool[t][n]&&(this.requestPool[t][n]=[]),this.requestPool[t][n].push({requestFn:e,type:t,additionalDetails:r}),this.startGrabbing()}filterRequests(e){Object.keys(this.requestPool).forEach(t=>{let r=this.requestPool[t];Object.keys(r).forEach(t=>{r[t]=r[t].filter(t=>e(t))})})}clearRequestStack(e){if(!this.requestPool[e])throw Error(`No category for the type ${e} found`);this.requestPool[e]={0:[]}}sendRequests(e){let t=this.maxNumRequests[e]-this.numRequests[e],r=0;for(let n=0;n<t;n++){let t=this.getNextRequest(e);if(null===t)return!1;if(t){let n;this.numRequests[e]++,this.awake=!0;try{n=t.requestFn()}catch(e){W1.warn("sendRequest failed",e)}n?.finally?n.finally(()=>{this.numRequests[e]--,this.startAgain()}):(this.numRequests[e]--,r++)}}return r&&this.startAgain(),!0}getNextRequest(e){for(let t of this.getSortedPriorityGroups(e))if(this.requestPool[e][t].length)return this.requestPool[e][t].shift();return null}startGrabbing(){let e=this.sendRequests(jj.Interaction),t=this.sendRequests(jj.Thumbnail),r=this.sendRequests(jj.Prefetch),n=this.sendRequests(jj.Compute);e||t||r||n||(this.awake=!1)}startAgain(){this.awake&&(void 0!==this.grabDelay?this.timeoutHandle||(this.timeoutHandle=window.setTimeout(()=>{this.timeoutHandle=null,this.startGrabbing()},this.grabDelay)):this.startGrabbing())}getSortedPriorityGroups(e){return Object.keys(this.requestPool[e]).map(Number).filter(t=>this.requestPool[e][t].length).sort((e,t)=>e-t)}getRequestPool(){return this.requestPool}}WU.getLogger("webWorkerManager","webWorkerManager");function W5(e,{ext:t,filterType:r,texData:n,internalFormat:a,glDataType:i}){try{let o;if(t&&!(o=e.getExtension(t)))return!1;let s=e.createTexture();e.bindTexture(e.TEXTURE_2D,s),e.texImage2D(e.TEXTURE_2D,0,a(e,o),5,1,0,e.RED,i(e,o),n);let l="LINEAR"===r?e.LINEAR:e.NEAREST;e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,l),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,l),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.POINTS,0,1);let d=new Uint8Array(4);e.readPixels(1,1,1,1,e.RGBA,e.UNSIGNED_BYTE,d);let[u,c,h]=d;return e.deleteTexture(s),u===c&&c===h&&0!==u}catch(e){return!1}}let W3="cornerstone3D.renderingCapabilities",W4=/swiftshader|llvmpipe|softpipe|software|microsoft basic render/i,W8={norm16:!1,norm16Linear:!1,float:!1,floatLinear:!1,halfFloat:!1,halfFloatLinear:!1},W6=null;function W9(){return W6||(W6=function({useCache:e=!0}={}){let t=function(){let e={webgl:!1,maxTextureSize:0,renderer:""};if("u"<typeof document)return e;try{let t=document.createElement("canvas").getContext("webgl2");if(!t)return e;e.webgl=!0,e.maxTextureSize=Number(t.getParameter(t.MAX_TEXTURE_SIZE))||0;let r=t.getExtension("WEBGL_debug_renderer_info"),n=r?t.getParameter(r.UNMASKED_RENDERER_WEBGL):t.getParameter(t.RENDERER);e.renderer="string"==typeof n?n:"";let a=t.getExtension("WEBGL_lose_context");a&&a.loseContext()}catch{}return e}();if(!t.webgl)return{...t,...W8,softwareRasterizer:!1};let r=e?function(e){try{let t=window.localStorage?.getItem(W3);if(!t)return null;let r=JSON.parse(t);if(r?.probeVersion!==1||r?.renderer!==e||"object"!=typeof r?.formats||r?.formats===null)return null;return{...W8,...r.formats}}catch{return null}}(t.renderer):null;if(!r){let e=function(){let e=function(){try{let e=document.createElement("canvas");e.width=4,e.height=4;let t=e.getContext("webgl2");if(!t)return null;let r=`#version 300 es
9
+ `)}),{viewportOptions:o,displaySetsInfo:s}}_validateViewportSpecificMatch(e,t,r){let{displaySetService:n}=this._servicesManager.services,a=t.displaySets,i=e.displaySetInstanceUIDs.length;if(a.length>0&&i!==a.length)throw Error(`The number of displaySets to set ${i} does not match the number of displaySets in the protocol ${a} - not currently implemented`);e.displaySetInstanceUIDs.forEach(e=>{let a=n.getDisplaySetByUID(e),{displaySets:i}=t;for(let e of i){let t=r[e.id];t&&this._validateRequiredSelectors(t,a)}})}areRequiredSelectorsValid(e,t){let r=!0;for(let n of e)try{this._validateRequiredSelectors(n,t)}catch(e){r=!1;break}return r}_validateRequiredSelectors(e,t){let{seriesMatchingRules:r}=e,n=r.filter(e=>e.required);if(n.length){let e=this.protocolEngine.findMatch(t,n,this._getSeriesMatchOptions(t));if(!e||0===e.score)throw Error(`The displaySetInstanceUID ${t.displaySetInstanceUID} does not satisfy the required seriesMatching criteria for the protocol`)}}_getStudyDisplaySets(e){return this.displaySets.filter(t=>t.StudyInstanceUID===e&&!t?.unsupported)}_getSeriesMatchOptions(e,t=this._getStudyDisplaySets(e.StudyInstanceUID)){return{studies:this.studies,instance:e.images?.[0],displaySetMatchDetails:this.displaySetMatchDetails,displaySets:t}}_validateOptions(e){let{displaySetService:t}=this._servicesManager.services,{displaySetSelectorMap:r}=e;r&&Object.entries(r).forEach(([e,r])=>{r.forEach(e=>{if(!t.getDisplaySetByUID(e))throw Error(`The displaySetInstanceUID ${e} is not found in the displaySetService`)})})}_matchImages(e){let{id:t,studyMatchingRules:r=[],seriesMatchingRules:n}=e,a=[],i=0;console.log("ProtocolEngine::matchImages",r,n);let o=-1===this.protocol.numberOfPriorsReferenced;this.studies.forEach((e,t)=>{if(o&&this.activeStudy!==e)return;let s=this._getStudyDisplaySets(e.StudyInstanceUID),l=this.protocolEngine.findMatch(e,r,{studies:this.studies,displaySets:s,allDisplaySets:this.displaySets,displaySetMatchDetails:this.displaySetMatchDetails,studyInstanceUIDsIndex:t});!0!==l.requiredFailed&&(this.debug("study",e.StudyInstanceUID,"display sets #",s.length),s.forEach(t=>{let{StudyInstanceUID:r,SeriesInstanceUID:o,displaySetInstanceUID:d}=t,u=this.protocolEngine.findMatch(t,n,this._getSeriesMatchOptions(t,s));if(!0===u.requiredFailed)return void this.debug("Display set required failed",t,n);this.debug("Found displaySet for rules",t),i=Math.max(u.score,i);let c={passed:[],failed:[]};c.passed=c.passed.concat(u.details.passed),c.passed=c.passed.concat(l.details.passed),c.failed=c.failed.concat(u.details.failed),c.failed=c.failed.concat(l.details.failed);let h=u.score+l.score,p={StudyInstanceUID:r,SeriesInstanceUID:o,displaySetInstanceUID:d,matchingScore:h,matchDetails:c,sortingInfo:{score:h,study:e.StudyInstanceUID,...this._getSeriesSortInfoForDisplaySetSort(t)}};this.debug("Adding display set",t,p),a.push(p)}))}),0===a.length&&console.log("No match found",t);let s=NK({name:"score",reverse:!0},{name:"study",reverse:!0},this._getSeriesFieldForDisplaySetSort());a.sort((e,t)=>s(e.sortingInfo,t.sortingInfo));let l=a[0];return console.log("ProtocolEngine::matchImages bestMatch",l,a),{bestMatch:l,matchingScores:a}}_getSeriesSortInfoForDisplaySetSort(e){return{[this._getSeriesFieldForDisplaySetSort().name]:null!=e.SeriesNumber?parseInt(e.SeriesNumber):parseInt(e.seriesNumber)}}_getSeriesFieldForDisplaySetSort(){return{name:"series"}}_isNextStageAvailable(){let e=this._getNumProtocolStages();return this.stageIndex+1<e}_isPreviousStageAvailable(){return this.stageIndex-1>=0}_setCurrentProtocolStage(e,t){let r;for(r=this.stageIndex+e;r>=0&&r<this.protocol.stages.length&&"disabled"===this.protocol.stages[r].status;r+=e);return!(r<0)&&!(r>=this.protocol.stages.length)&&(this.stageIndex=r,this.debug(`ProtocolEngine::setCurrentProtocolStage stage = ${this.stageIndex}`),this._updateViewports(t),this._broadcastEvent(this.EVENTS.PROTOCOL_CHANGED,{viewportMatchDetails:this.viewportMatchDetails,displaySetMatchDetails:this.displaySetMatchDetails,protocol:this.protocol,stageIdx:this.stageIndex,stage:this.protocol.stages[this.stageIndex]}),!0)}debug(...e){this.debugLogging&&console.log(...e)}_copyProtocol(e){return N$()(e)}}LU.EVENTS={PROTOCOL_CHANGED:"event::hanging_protocol_changed",PROTOCOL_RESTORED:"event::hanging_protocol_restore",NEW_LAYOUT:"event::hanging_protocol_new_layout",STAGE_ACTIVATION:"event::hanging_protocol_stage_activation",CUSTOM_IMAGE_LOAD_PERFORMED:"event::hanging_protocol_custom_image_load_performed"},LU.REGISTRATION={name:"hangingProtocolService",altName:"HangingProtocolService",create:({configuration:e={},commandsManager:t,servicesManager:r})=>new LU(t,r)};class Lz extends Ns{constructor(){super(Lz.EVENTS),this.serviceImplementation={_getState:()=>console.warn("getState() NOT IMPLEMENTED"),_setUser:()=>console.warn("_setUser() NOT IMPLEMENTED"),_getUser:()=>console.warn("_getUser() NOT IMPLEMENTED"),_getAuthorizationHeader:()=>{},_handleUnauthenticated:()=>console.warn("_handleUnauthenticated() NOT IMPLEMENTED"),_reset:()=>console.warn("reset() NOT IMPLEMENTED"),_set:()=>console.warn("set() NOT IMPLEMENTED")},this.serviceImplementation={...this.serviceImplementation}}getState(){return this.serviceImplementation._getState()}setUser(e){return this.serviceImplementation._setUser(e)}getUser(){return this.serviceImplementation._getUser()}getAuthorizationHeader(){return this.serviceImplementation._getAuthorizationHeader()}handleUnauthenticated(){return this.serviceImplementation._handleUnauthenticated()}reset(){return this.serviceImplementation._reset()}set(e){return this.serviceImplementation._set(e)}setServiceImplementation({getState:e,setUser:t,getUser:r,getAuthorizationHeader:n,handleUnauthenticated:a,reset:i,set:o}){e&&(this.serviceImplementation._getState=e),t&&(this.serviceImplementation._setUser=t),r&&(this.serviceImplementation._getUser=r),n&&(this.serviceImplementation._getAuthorizationHeader=n),a&&(this.serviceImplementation._handleUnauthenticated=a),i&&(this.serviceImplementation._reset=i),o&&(this.serviceImplementation._set=o)}}Lz.EVENTS={},Lz.REGISTRATION={name:"userAuthenticationService",altName:"UserAuthenticationService",create:({configuration:e={}})=>new Lz};var LH=d(1752),LG=d.n(LH),Lq=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,L$=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,LK=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,LY=e=>"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||"$"===e||"_"===e||L$.test(e)),LX=e=>"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||"$"===e||"_"===e||"‌"===e||"‍"===e||LK.test(e)),LZ=e=>"string"==typeof e&&/[0-9]/.test(e),LJ=e=>"string"==typeof e&&/[0-9A-Fa-f]/.test(e);function LQ(){if(n[o])return String.fromCodePoint(n.codePointAt(o))}function L0(){let e=LQ();return"\n"===e?(s++,l=0):e?l+=e.length:l++,e&&(o+=e.length),e}let L1={default(){let e;switch(v){case" ":case"\v":case"\f":case" ":case" ":case"\uFEFF":case"\n":case"\r":case"\u2028":case"\u2029":L0();return;case"/":L0(),m="comment";return;case void 0:return L0(),L2("eof")}return"string"==typeof(e=v)&&Lq.test(e)?void L0():L1[a]()},comment(){switch(v){case"*":L0(),m="multiLineComment";return;case"/":L0(),m="singleLineComment";return}throw L9(L0())},multiLineComment(){switch(v){case"*":L0(),m="multiLineCommentAsterisk";return;case void 0:throw L9(L0())}L0()},multiLineCommentAsterisk(){switch(v){case"*":L0();return;case"/":L0(),m="default";return;case void 0:throw L9(L0())}L0(),m="multiLineComment"},singleLineComment(){switch(v){case"\n":case"\r":case"\u2028":case"\u2029":L0(),m="default";return;case void 0:return L0(),L2("eof")}L0()},value(){switch(v){case"{":case"[":return L2("punctuator",L0());case"n":return L0(),L5("ull"),L2("null",null);case"t":return L0(),L5("rue"),L2("boolean",!0);case"f":return L0(),L5("alse"),L2("boolean",!1);case"-":case"+":"-"===L0()&&(y=-1),m="sign";return;case".":f=L0(),m="decimalPointLeading";return;case"0":f=L0(),m="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":f=L0(),m="decimalInteger";return;case"I":return L0(),L5("nfinity"),L2("numeric",1/0);case"N":return L0(),L5("aN"),L2("numeric",NaN);case'"':case"'":g='"'===L0(),f="",m="string";return}throw L9(L0())},identifierNameStartEscape(){if("u"!==v)throw L9(L0());L0();let e=L3();switch(e){case"$":case"_":break;default:if(!LY(e))throw je()}f+=e,m="identifierName"},identifierName(){switch(v){case"$":case"_":case"‌":case"‍":f+=L0();return;case"\\":L0(),m="identifierNameEscape";return}if(LX(v)){f+=L0();return}return L2("identifier",f)},identifierNameEscape(){if("u"!==v)throw L9(L0());L0();let e=L3();switch(e){case"$":case"_":case"‌":case"‍":break;default:if(!LX(e))throw je()}f+=e,m="identifierName"},sign(){switch(v){case".":f=L0(),m="decimalPointLeading";return;case"0":f=L0(),m="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":f=L0(),m="decimalInteger";return;case"I":return L0(),L5("nfinity"),L2("numeric",1/0*y);case"N":return L0(),L5("aN"),L2("numeric",NaN)}throw L9(L0())},zero(){switch(v){case".":f+=L0(),m="decimalPoint";return;case"e":case"E":f+=L0(),m="decimalExponent";return;case"x":case"X":f+=L0(),m="hexadecimal";return}return L2("numeric",0*y)},decimalInteger(){switch(v){case".":f+=L0(),m="decimalPoint";return;case"e":case"E":f+=L0(),m="decimalExponent";return}if(LZ(v)){f+=L0();return}return L2("numeric",y*Number(f))},decimalPointLeading(){if(LZ(v)){f+=L0(),m="decimalFraction";return}throw L9(L0())},decimalPoint(){switch(v){case"e":case"E":f+=L0(),m="decimalExponent";return}if(LZ(v)){f+=L0(),m="decimalFraction";return}return L2("numeric",y*Number(f))},decimalFraction(){switch(v){case"e":case"E":f+=L0(),m="decimalExponent";return}if(LZ(v)){f+=L0();return}return L2("numeric",y*Number(f))},decimalExponent(){switch(v){case"+":case"-":f+=L0(),m="decimalExponentSign";return}if(LZ(v)){f+=L0(),m="decimalExponentInteger";return}throw L9(L0())},decimalExponentSign(){if(LZ(v)){f+=L0(),m="decimalExponentInteger";return}throw L9(L0())},decimalExponentInteger(){if(LZ(v)){f+=L0();return}return L2("numeric",y*Number(f))},hexadecimal(){if(LJ(v)){f+=L0(),m="hexadecimalInteger";return}throw L9(L0())},hexadecimalInteger(){if(LJ(v)){f+=L0();return}return L2("numeric",y*Number(f))},string(){switch(v){case"\\":L0(),f+=function(){switch(LQ()){case"b":return L0(),"\b";case"f":return L0(),"\f";case"n":return L0(),"\n";case"r":return L0(),"\r";case"t":return L0()," ";case"v":return L0(),"\v";case"0":if(L0(),LZ(LQ()))throw L9(L0());return"\0";case"x":return L0(),function(){let e="",t=LQ();if(!LJ(t)||(e+=L0(),!LJ(t=LQ())))throw L9(L0());return String.fromCodePoint(parseInt(e+=L0(),16))}();case"u":return L0(),L3();case"\n":case"\u2028":case"\u2029":return L0(),"";case"\r":return L0(),"\n"===LQ()&&L0(),"";case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case void 0:throw L9(L0())}return L0()}();return;case'"':if(g)return L0(),L2("string",f);f+=L0();return;case"'":if(!g)return L0(),L2("string",f);f+=L0();return;case"\n":case"\r":case void 0:throw L9(L0());case"\u2028":case"\u2029":var e;e=v,console.warn(`JSON5: '${jt(e)}' in strings is not valid ECMAScript; consider escaping`)}f+=L0()},start(){switch(v){case"{":case"[":return L2("punctuator",L0())}m="value"},beforePropertyName(){switch(v){case"$":case"_":f=L0(),m="identifierName";return;case"\\":L0(),m="identifierNameStartEscape";return;case"}":return L2("punctuator",L0());case'"':case"'":g='"'===L0(),m="string";return}if(LY(v)){f+=L0(),m="identifierName";return}throw L9(L0())},afterPropertyName(){if(":"===v)return L2("punctuator",L0());throw L9(L0())},beforePropertyValue(){m="value"},afterPropertyValue(){switch(v){case",":case"}":return L2("punctuator",L0())}throw L9(L0())},beforeArrayValue(){if("]"===v)return L2("punctuator",L0());m="value"},afterArrayValue(){switch(v){case",":case"]":return L2("punctuator",L0())}throw L9(L0())},end(){throw L9(L0())}};function L2(e,t){return{type:e,value:t,line:s,column:l}}function L5(e){for(let t of e){if(LQ()!==t)throw L9(L0());L0()}}function L3(){let e="",t=4;for(;t-- >0;){if(!LJ(LQ()))throw L9(L0());e+=L0()}return String.fromCodePoint(parseInt(e,16))}let L4={start(){if("eof"===c.type)throw L7();L8()},beforePropertyName(){switch(c.type){case"identifier":case"string":h=c.value,a="afterPropertyName";return;case"punctuator":L6();return;case"eof":throw L7()}},afterPropertyName(){if("eof"===c.type)throw L7();a="beforePropertyValue"},beforePropertyValue(){if("eof"===c.type)throw L7();L8()},beforeArrayValue(){if("eof"===c.type)throw L7();"punctuator"===c.type&&"]"===c.value?L6():L8()},afterPropertyValue(){if("eof"===c.type)throw L7();switch(c.value){case",":a="beforePropertyName";return;case"}":L6()}},afterArrayValue(){if("eof"===c.type)throw L7();switch(c.value){case",":a="beforeArrayValue";return;case"]":L6()}},end(){}};function L8(){let e;switch(c.type){case"punctuator":switch(c.value){case"{":e={};break;case"[":e=[]}break;case"null":case"boolean":case"numeric":case"string":e=c.value}if(void 0===p)p=e;else{let t=i[i.length-1];Array.isArray(t)?t.push(e):Object.defineProperty(t,h,{value:e,writable:!0,enumerable:!0,configurable:!0})}if(null!==e&&"object"==typeof e)i.push(e),a=Array.isArray(e)?"beforeArrayValue":"beforePropertyName";else{let e=i[i.length-1];a=null==e?"end":Array.isArray(e)?"afterArrayValue":"afterPropertyValue"}}function L6(){i.pop();let e=i[i.length-1];a=null==e?"end":Array.isArray(e)?"afterArrayValue":"afterPropertyValue"}function L9(e){return void 0===e?jr(`JSON5: invalid end of input at ${s}:${l}`):jr(`JSON5: invalid character '${jt(e)}' at ${s}:${l}`)}function L7(){return jr(`JSON5: invalid end of input at ${s}:${l}`)}function je(){return l-=5,jr(`JSON5: invalid identifier character at ${s}:${l}`)}function jt(e){let t={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(t[e])return t[e];if(e<" "){let t=e.charCodeAt(0).toString(16);return"\\x"+("00"+t).substring(t.length)}return e}function jr(e){let t=SyntaxError(e);return t.lineNumber=s,t.columnNumber=l,t}let jn=function(e,t){n=String(e),a="start",i=[],o=0,s=1,l=0,c=void 0,h=void 0,p=void 0;do c=function(){for(m="default",f="",g=!1,y=1;;){v=LQ();let e=L1[m]();if(e)return e}}(),L4[a]();while("eof"!==c.type)return"function"==typeof t?function e(t,r,n){let a=t[r];if(null!=a&&"object"==typeof a)if(Array.isArray(a))for(let t=0;t<a.length;t++){let r=String(t),i=e(a,r,n);void 0===i?delete a[r]:Object.defineProperty(a,r,{value:i,writable:!0,enumerable:!0,configurable:!0})}else for(let t in a){let r=e(a,t,n);void 0===r?delete a[t]:Object.defineProperty(a,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}return n.call(t,r,a)}({"":p},"",t):p},ja="default",ji={prefixes:{}};function jo(e){if(!e||"object"!=typeof e)return null;let t=js(e.bootstrap),r=js(e.global),n=e.mode&&"object"==typeof e.mode&&!Array.isArray(e.mode),a="string"==typeof e.requires||Array.isArray(e.requires)&&e.requires.length>0;return t||r||n||a?{...t?{bootstrap:e.bootstrap}:{},...r?{global:e.global}:{},...n?{mode:e.mode}:{},...a?{requires:e.requires}:{}}:null}function js(e){return Array.isArray(e)?e.length>0:!!e&&"object"==typeof e}let jl=/^([a-z][a-z0-9+.-]*:|\/\/)/i;function jd(e,t="customization"){let r=[];for(let n of Array.from(new Set(e.keys())))if(n.toLowerCase()===t.toLowerCase()){for(let t of e.getAll(n))if(t)for(let e of t.split(",")){let t=e.trim();t&&r.push(t)}}return r}function ju(e,t){let r={valid:[],rejected:[]},n=t.prefixes||{};for(let t of e){let e=function(e){let t=e;for(let e=0;e<5;e++){let e;if(!t.includes("%"))return t;try{e=decodeURIComponent(t)}catch{break}if(e===t)break;t=e}return null}(t);if(null===e){r.rejected.push({raw:t,reason:"contains malformed or unsupported percent-encoding"});continue}if(e.includes("..")){r.rejected.push({raw:t,reason:'contains ".." traversal segment'});continue}if(jl.test(e)){r.rejected.push({raw:t,reason:"full URLs are not permitted"});continue}let a=function(e){if(!e)return null;if(!e.startsWith("/"))return{prefix:ja,name:e};let t=e.slice(1),r=t.indexOf("/");if(r<=0)return null;let n=t.slice(0,r),a=t.slice(r+1);return n&&a?{prefix:`/${n}/`,name:a}:null}(e.trim());if(!a){r.rejected.push({raw:t,reason:"could not be split into a prefix and name"});continue}let{prefix:i,name:o}=a;if(!Object.prototype.hasOwnProperty.call(n,i)){r.rejected.push({raw:t,reason:`unknown prefix "${i}"`});continue}if(!o.trim()||o.split("/").some(e=>!e||"."===e||".."===e||e.includes(".."))){r.rejected.push({raw:t,reason:"invalid or unsafe customization name"});continue}r.valid.push({raw:t,normalized:i===ja?`/${ja}/${o}`:`${i}${o}`,prefix:i,name:o})}return r}let jc=/^([a-z][a-z0-9+.-]*:|\/\/)/i,jh="https://ohif.invalid";function jp(e,t,r){let n,a;try{n=new URL(e,jh),a=new URL(t,jh)}catch{throw Error(`Customization URL could not be parsed for "${r.raw}"`)}let i=a.pathname.endsWith("/")?a.pathname:`${a.pathname}/`;if(!(n.origin===a.origin&&n.pathname.startsWith(i)))throw Error(`Customization "${r.raw}" escapes its configured prefix directory`)}let jm={MODE_CUSTOMIZATION_MODIFIED:"event::CustomizationService:modeModified",GLOBAL_CUSTOMIZATION_MODIFIED:"event::CustomizationService:globalModified",DEFAULT_CUSTOMIZATION_MODIFIED:"event::CustomizationService:defaultModified"},jf=((eIY={}).Global="global",eIY.Mode="mode",eIY.Default="default",eIY);class jg extends Ns{constructor({configuration:e,commandsManager:t}){super(jm),this.Scope=jf,this.commandsManager=void 0,this.extensionManager=void 0,this.globalCustomizations=new Map,this.modeCustomizations=new Map,this.defaultCustomizations=new Map,this.transformedCustomizations=new Map,this.configuration=void 0,this._urlCustomizationLoaded=new Map,this._urlCustomizationPending=new Map,this._resolvedUrlModules=[],this._customizationConfig=null,this._currentModeIds=[],this._extensionCustomizationModuleApplied=new Set,this.configuration=e,this.commandsManager=t}init(e){this.extensionManager=e,this.modeCustomizations.clear(),this.extensionManager.getRegisteredExtensionIds().forEach(e=>{let t=`${e}.customizationModule.default`;if(!this._extensionCustomizationModuleApplied.has(t)){let e=this._findExtensionValue(t);if(e){let{value:r}=e;this._addReference(r,jf.Default),this._extensionCustomizationModuleApplied.add(t)}}let r=`${e}.customizationModule.global`;if(!this._extensionCustomizationModuleApplied.has(r)){let e=this._findExtensionValue(r);if(e){let{value:t}=e;this._addReference(t,jf.Global),this._extensionCustomizationModuleApplied.add(r)}}});let t=this._getCustomizationConfig();void 0===t.legacyReferences||this.configuration?._hasBeenAdded||(this.addReferences(t.legacyReferences),Object.defineProperty(this.configuration,"_hasBeenAdded",{value:!0,writable:!1})),this._broadcastEvent(this.EVENTS.MODE_CUSTOMIZATION_MODIFIED,{buttons:this.modeCustomizations,button:void 0})}_getCustomizationConfig(){return this._customizationConfig||(this._customizationConfig=function(e){if(!e)return{};if(Array.isArray(e))return{legacyReferences:e};if("object"==typeof e){if(jy.some(t=>t in e)){let t={};for(let r of jy)r in e&&(t[r]=e[r]);return{phased:t}}return{legacyReferences:e}}return{}}(this.configuration)),this._customizationConfig}async applyWindowUrlCustomizations(e){"u">typeof window&&await this.applyCustomizationUrlSearchParams(new URLSearchParams(window.location.search),e)}async applyCustomizationUrlSearchParams(e,t){let r=jd(e);r.length&&await this.requires(r,t)}requires(e,t){return this.loadCustomizationModules(e,t).then(e=>(this._applyLoadedUrlCustomizationModules(e),e))}loadCustomizationModules(e,t){let r,n=t?.policy??((r=this?.extensionManager?.appConfig?.customizationUrlPrefixes)&&"object"==typeof r?{prefixes:r}:ji),a=(Array.isArray(e)?e:[e]).map(e=>String(e).trim()).filter(Boolean);if(!a.length)return Promise.resolve([]);let{valid:i,rejected:o}=ju(a,n),s=t?.logger||console;if(o.length){let e=o.map(e=>`"${e.raw}" (${e.reason})`).join("; ");return Promise.reject(Error(`[customizationUrl] refusing to load customization(s): ${e}. Allowed prefixes are configured in appConfig.customizationUrlPrefixes.`))}if(!i.length)return Promise.resolve([]);let l=t?.importFn??this._urlDefaultImport.bind(this),d=new Set,u=[];return i.reduce((e,t)=>e.then(()=>this._urlCustomizationLoadOne(t,n,l,s,d,u)),Promise.resolve()).then(()=>(this._resolvedUrlModules.push(...u),u))}async loadAndApplyBootstrapCustomizations(e,t){this.extensionManager=e;let r=this._getCustomizationConfig(),n=[],a=r.phased?.requires;"string"==typeof a&&a?n.push(a):Array.isArray(a)&&n.push(...a.filter(e=>"string"==typeof e&&e)),"u">typeof window&&n.push(...jd(new URLSearchParams(window.location.search))),n.length&&await this.loadCustomizationModules(n,t),this.applyBootstrapCustomizations()}applyBootstrapCustomizations(){this._applyPhase("bootstrap")}applyGlobalCustomizations(){this._applyPhase("global")}applyModeCustomizations(e){let t=(Array.isArray(e)?e:[e]).filter(Boolean);this._currentModeIds=t;let r=this._collectPhaseBlocks("mode");for(let e of r){let t=e.mode?.["*"];t&&this.setCustomizations(t,jf.Mode)}for(let e of r)for(let r of t){let t=e.mode?.[r];t&&this.setCustomizations(t,jf.Mode)}}onModeEnter(){this.clearTransformedCustomizations(),this.init(this.extensionManager)}onModeExit(){this.clearTransformedCustomizations()}getCustomization(e){let t=this.transformedCustomizations.get(e);if(t)return t;let r=this.globalCustomizations.get(e)??this.modeCustomizations.get(e)??this.defaultCustomizations.get(e),n=this._resolveReferences(this.transform(r),new Set([e]));return void 0!==n&&this.transformedCustomizations.set(e,n),n}_resolveReferences(e,t){if(!e||"object"!=typeof e||e.$$typeof)return e;if("string"==typeof e.$reference)return this._resolveReferenceName(e.$reference,t);if(Array.isArray(e)){let r=!1,n=[];for(let a of e)if(a&&"object"==typeof a&&!a.$$typeof&&"string"==typeof a.$reference){r=!0;let e=this._resolveReferenceName(a.$reference,t);Array.isArray(e)?n.push(...e):void 0!==e&&n.push(e)}else{let e=this._resolveReferences(a,t);r||=e!==a,n.push(e)}return r?n:e}if(!function(e){if(null===e||"object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(e))return e;let r=!1,n={};for(let[a,i]of Object.entries(e)){let e=this._resolveReferences(i,t);r||=e!==i,n[a]=e}return r?n:e}_resolveReferenceName(e,t){if(t.has(e))return void console.warn(`CustomizationService: $reference cycle detected at "${e}"`);let r=this.globalCustomizations.get(e)??this.modeCustomizations.get(e)??this.defaultCustomizations.get(e);if(void 0===r)return void console.warn(`CustomizationService: no customization registered for $reference "${e}"`);let n=new Set(t).add(e);return this._resolveReferences(this.transform(r),n)}getValue(e,t){let r=this.getCustomization(e);return void 0===r?t:r}setCustomizations(e,t=jf.Mode){Array.isArray(e)?e.forEach(e=>{this._addReference(e,t)}):Object.entries(e).forEach(([e,r])=>{this._setCustomization(e,r,t)})}setCustomization(e,t,r=jf.Mode){console.warn("setCustomization is deprecated. Please use setCustomizations with an object instead."),this._setCustomization(e,t,r)}getCustomizations(e){return e===jf.Global?this.globalCustomizations:e===jf.Mode?this.modeCustomizations:this.defaultCustomizations}hasCustomization(e){return this.globalCustomizations.has(e)||this.modeCustomizations.has(e)}transform(e){if(!e)return e;let{inheritsFrom:t}=e;if(!t)return e;let r=this.getCustomization(t),n=r?Object.assign({},r,e):e;return n.$transform?.(this)||n}registerCustomUpdateCommand(e,t){e.startsWith("$")||(e="$"+e),(0,LH.extend)(e,t)}_addReference(e,t=jf.Global){e&&("string"==typeof e&&(e=this._findExtensionValue(e).value),Object.entries(e).forEach(([e,r])=>{this[t===jf.Global&&"setGlobalCustomization"||t===jf.Default&&"setDefaultCustomization"||"setModeCustomization"](e,r)}))}addReferences(e,t=jf.Global){e&&(Array.isArray(e)?e.forEach(e=>{this._addReference(e,t)}):this._addReference(e,t))}clearTransformedCustomizations(){for(let e of(super.reset(),Array.from(this.modeCustomizations.keys())))this.transformedCustomizations.delete(e);this.modeCustomizations.clear()}async _urlDefaultImport(e){if("function"!=typeof fetch)throw Error(`No fetch implementation available to load customization ${e}`);let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch customization ${e}: ${t.status} ${t.statusText}`);return jn(await t.text())}_normalizeImportedCustomizationModule(e){return e&&"object"==typeof e&&"customizations"in e?e:e&&"object"==typeof e.default?e.default:e}_collectUrlDependencyRefs(e){let t=new Set,r=jo(e);if(!r||"object"!=typeof r)return Array.from(t);let n=r.requires;if("string"==typeof n&&n)t.add(n);else if(Array.isArray(n))for(let e of n)"string"==typeof e&&e&&t.add(e);return Array.from(t)}_urlDependencyToRequest(e,t){let r=ju([e],t);return r.valid.length?r.valid[0]:null}_urlCustomizationLoadOne(e,t,r,n,a,i){let o=e.normalized;if(this._urlCustomizationLoaded.has(o))return Promise.resolve(this._urlCustomizationLoaded.get(o)||null);if(this._urlCustomizationPending.has(o))return this._urlCustomizationPending.get(o);a.add(o);let s=this._urlCustomizationLoadOneBody(e,t,r,n,a,i);return this._urlCustomizationPending.set(o,s),s.then(()=>this._urlCustomizationPending.delete(o),()=>this._urlCustomizationPending.delete(o)),s}_urlCustomizationLoadOneBody(e,t,r,n,a,i){let o,s=e.normalized,l=Symbol("importFailed");try{o=function(e,t){let r=(t.prefixes||{})[e.prefix];if(!r)throw Error(`Unknown customization prefix: ${e.prefix}`);if(e.name.includes(".."))throw Error(`Customization name contains traversal: ${e.name}`);let n=e.name.endsWith(".jsonc")?e.name:`${e.name}.jsonc`,a=r.endsWith("/")?r:`${r}/`,i=`${a}${n}`;if(jc.test(r))return jp(i,a,e),i;let o="u">typeof window&&window.location?.origin?window.location.origin:"",s="u"<typeof window?"/":window.PUBLIC_URL||"/",l=s?.startsWith("/")?s:`/${s||""}`,d=e=>e.startsWith("./")?e.slice(2):e.startsWith("/")?e.slice(1):e,u=d(i),c=d(a),h=l.endsWith("/")?l:`${l}/`,p=`${h}${u}`,m=`${h}${c}`,f=o?`${o}${p}`:p;return jp(f,o?`${o}${m}`:m,e),f}(e,t)}catch(r){let t=`[customizationUrl] failed to resolve "${e.raw}": ${r.message}`;return n.warn(t),Promise.resolve(null)}return r(o).catch(t=>(n.warn(`[customizationUrl] failed to import customization "${e.raw}" (${o})`,t),l)).then(d=>{if(d===l)return null;let u=this._normalizeImportedCustomizationModule(d);if(!u||"object"!=typeof u){let t=`[customizationUrl] missing customization module "${e.raw}" (${o}): module is not an object`;return n.warn(t),null}if(!jo(u)){let t=`[customizationUrl] missing customization module "${e.raw}" (${o}): no customizations payload`;return n.warn(t),null}let c=this._collectUrlDependencyRefs(u),h=Promise.resolve();for(let e of c)h=h.then(()=>{let o=this._urlDependencyToRequest(e,t);if(!(!o||a.has(o.normalized)))return this._urlCustomizationLoadOne(o,t,r,n,a,i)});return h.then(()=>{let t={request:e,module:u,url:o};return this._urlCustomizationLoaded.set(s,t),i.push(t),t})})}_applyLoadedUrlCustomizationModules(e){if(e?.length)for(let t of e){let e=jo(t.module);e?.global&&this.setCustomizations(e.global,jf.Global)}}_collectPhaseBlocks(e){let t=[],r=this._getCustomizationConfig().phased;for(let n of(r&&void 0!==r[e]&&t.push(r),this._resolvedUrlModules)){let r=jo(n.module);r&&void 0!==r[e]&&t.push(r)}return t}_applyPhase(e){for(let t of this._collectPhaseBlocks(e)){let r=t[e];r&&this.setCustomizations(r,jf.Global)}}_setCustomization(e,t,r=jf.Mode){switch(r){case jf.Global:this.setGlobalCustomization(e,t);break;case jf.Mode:this.setModeCustomization(e,t);break;case jf.Default:this.setDefaultCustomization(e,t);break;default:throw Error(`Invalid customization scope: ${r}`)}}setModeCustomization(e,t){let r=this.defaultCustomizations.get(e),n=this.modeCustomizations.get(e),a=this.globalCustomizations.get(e),i=n||this._cloneIfNeeded(a)||r,o=this._update(i,t);this.modeCustomizations.set(e,o),this.transformedCustomizations.clear(),this._broadcastEvent(this.EVENTS.MODE_CUSTOMIZATION_MODIFIED,{buttons:this.modeCustomizations,button:this.modeCustomizations.get(e)})}setGlobalCustomization(e,t){let r=this.defaultCustomizations.get(e),n=this.globalCustomizations.get(e),a=this._cloneIfNeeded(n)||r;this.globalCustomizations.set(e,this._update(a,t)),this.transformedCustomizations.clear(),this._broadcastEvent(this.EVENTS.GLOBAL_CUSTOMIZATION_MODIFIED,{buttons:this.globalCustomizations,button:this.globalCustomizations.get(e)})}setDefaultCustomization(e,t){this.transformedCustomizations.clear();let r=this.defaultCustomizations.get(e);this.defaultCustomizations.set(e,this._update(r,t)),this._broadcastEvent(this.EVENTS.DEFAULT_CUSTOMIZATION_MODIFIED,{buttons:this.defaultCustomizations,button:this.defaultCustomizations.get(e)})}_findExtensionValue(e){return this.extensionManager.getModuleEntry(e)}_update(e,t){return(e||(e=void 0),!function e(t){if(Array.isArray(t)){for(let r of t)if(e(r))return!0}else if(t&&"object"==typeof t){if(t.$$typeof)return!1;for(let r of Object.keys(t))if(r.startsWith("$")&&"$transform"!==r&&"$reference"!==r||e(t[r]))return!0}return!1}(t))?t:LG()(e,t)}_cloneIfNeeded(e){return e&&"object"==typeof e?Array.isArray(e)?[...e]:{...e}:e}}jg.EVENTS=jm,jg.REGISTRATION={name:"customizationService",create:({configuration:e,commandsManager:t})=>new jg({configuration:e,commandsManager:t})},(0,LH.extend)("$filter",(e,t)=>(function e(t,r){if(Array.isArray(t))return"function"==typeof r?t.filter(r):"string"==typeof r?t.filter(e=>e.id!==r):"object"==typeof r&&r.match&&r.$merge?t.map(t=>e(t,r)).map(e=>{var t;return(t=r.match,e&&"object"==typeof e&&Object.entries(t).every(([t,r])=>e[t]===r))?{...e,...r.$merge}:e}):"object"==typeof r&&r.id&&r.$merge?t.map(t=>e(t,r)).map(e=>e.id===r.id?{...e,...r.$merge}:e):t.map(t=>e(t,r));if(t&&"object"==typeof t){let n={...t};for(let[t,a]of Object.entries(n))n[t]=e(a,r);return n}return t})(t,e));let jy=["requires","bootstrap","global","mode"],jv={PANELS_CHANGED:"event::panelService:panelsChanged",ACTIVATE_PANEL:"event::panelService:activatePanel"},jb=((eIX={}).Left="left",eIX.Right="right",eIX.Bottom="bottom",eIX);class jx extends Ns{constructor(e){super(jv),this._extensionManager=void 0,this._panelsGroups=new Map,this._extensionManager=e}get PanelPosition(){return jb}_getPanelComponent(e){let t=this._extensionManager.getModuleEntry(e);if(!t){let t=this._getSimilarPanels(e);if(t.length>0){let r=`Did you mean: ${t.join(", ")}?`;throw Error(`${e} is not a valid entry for an extension module. ${r} Please check your configuration or make sure the extension is registered.`)}throw Error(`${e} is not a valid entry for an extension module, please check your configuration or make sure the extension is registered.`)}if(!t?.component)throw Error(`No component found from extension ${e}. Check the reference string to the extension in your Mode configuration`);let r=t.component;return{entry:t,content:r}}_getSimilarPanels(e,t=.8){return Object.keys(this._extensionManager.modulesMap).filter(e=>e.includes("panelModule")).filter(r=>this._calculateSimilarity(e,r)>=t)}_calculateSimilarity(e,t){let r=new Set(e.toLowerCase().split("")),n=new Set(t.toLowerCase().split("")),a=new Set([...r].filter(e=>n.has(e))),i=new Set([...r,...n]);return a.size/i.size}getPanelData(e){let t,r;if(Array.isArray(e)){let n=e.map(e=>this._getPanelComponent(e));r=n[0].entry,t=e=>(0,tT.jsx)(tT.Fragment,{children:n.map(({content:t},r)=>(0,tT.jsx)(t,{...e},r))})}else({content:t,entry:r}=this._getPanelComponent(e));return{id:r.id,iconName:r.iconName,iconLabel:r.iconLabel,label:r.label,name:r.name,content:t}}addPanel(e,t,r){let n=this._panelsGroups.get(e);n||(n=[],this._panelsGroups.set(e,n));let a=this.getPanelData(t);n.push(a),this._broadcastEvent(jv.PANELS_CHANGED,{position:e,options:r})}addPanels(e,t,r){if(!Array.isArray(t))throw Error('Invalid "panelsIds" array');t.forEach(t=>this.addPanel(e,t,r))}setPanels(e,t){this.reset(),Object.keys(e).forEach(r=>{this.addPanels(r,e[r],t)})}getPanels(e){return[...this._panelsGroups.get(e)??[]]}reset(){let e=Array.from(this._panelsGroups.keys());this._panelsGroups.clear(),e.forEach(e=>this._broadcastEvent(jv.PANELS_CHANGED,{position:e}))}onModeExit(){this.reset()}activatePanel(e,t=!1){this._broadcastEvent(jv.ACTIVATE_PANEL,{panelId:e,forceActive:t})}addActivatePanelTriggers(e,t,r=!1){return t.map(t=>t.sourceEvents.map(n=>t.sourcePubSubService.subscribe(n,()=>this.activatePanel(e,r)))).flat()}}jx.REGISTRATION={name:"panelService",create:({extensionManager:e})=>new jx(e)};let jw={ACTIVE_STEP_CHANGED:"event::workflowStepsService:activateStepChanged",STEPS_CHANGED:"event::workflowStepsService:stepsChanged"};class jC extends Ns{constructor(e,t,r){super(jw),this._extensionManager=void 0,this._servicesManager=void 0,this._commandsManager=void 0,this._workflowSteps=void 0,this._activeWorkflowStep=void 0,this._workflowSteps=[],this._activeWorkflowStep=null,this._extensionManager=e,this._commandsManager=t,this._servicesManager=r}get workflowSteps(){return[...this._workflowSteps]}get activeWorkflowStep(){return this._activeWorkflowStep}addWorkflowSteps(e){let t=!1;e.forEach(e=>{if(this._workflowSteps.some(t=>t.id===e.id))throw Error(`Duplicated workflow step id (${e.id})`);this._workflowSteps.push(e),t=!0}),t&&this._broadcastEvent(jw.STEPS_CHANGED,{})}_updateToolBar(e){let{toolbarService:t}=this._servicesManager.services,{toolbarButtons:r}=e;(Array.isArray(r)?r:[r]).forEach(({buttonSection:e,buttons:r})=>{t.clearButtonSection(e),t.updateSection(e,r)})}_updatePanels(e){let{panelService:t}=this._servicesManager.services,r=e?.layout?.panels;r&&t.setPanels(r,e?.layout?.options)}_updateHangingProtocol(e){let{hangingProtocol:t}=e;t&&this._commandsManager.runCommand("setHangingProtocol",{protocolId:t.protocolId,stageId:t.stageId,stageIndex:t.stageIndex})}_invokeCallbacks(e){if(!e)return;let t=this._commandsManager;Array.isArray(e)||(e=[e]),e.forEach(e=>{let r=e;if(e?.commandName){let{commandName:n,options:a}=e;r=()=>t.runCommand(n,a)}r()})}setActiveWorkflowStep(e){let t=this._activeWorkflowStep;if(e===t?.id)return;let r=this._workflowSteps.find(t=>t.id===e);if(!r)throw Error(`Invalid workflowStepId (${e})`);this._activeWorkflowStep&&this._invokeCallbacks(t.onExit),this._invokeCallbacks(r.onEnter),this._activeWorkflowStep=r,this._updateToolBar(r),this._updatePanels(r),this._updateHangingProtocol(r),this._broadcastEvent(jw.ACTIVE_STEP_CHANGED,{activeWorkflowStep:r})}reset(){this._activeWorkflowStep=null,this._workflowSteps=[]}onModeEnter(){this.reset()}}jC.REGISTRATION={name:"workflowStepsService",create:({extensionManager:e,commandsManager:t,servicesManager:r})=>new jC(e,t,r)};var jk=((eIZ=jk||{}).Interaction="interaction",eIZ.Thumbnail="thumbnail",eIZ.Prefetch="prefetch",eIZ.Compute="compute",eIZ);let jM={SERVICE_STARTED:"event::studyPrefetcherService:started",SERVICE_STOPPED:"event::studyPrefetcherService:stopped",DISPLAYSET_LOAD_PROGRESS:"event::studyPrefetcherService:displaySetLoadProgress",DISPLAYSET_LOAD_COMPLETE:"event::studyPrefetcherService:displaySetLoadComplete"};var jS=((eIJ=jS||{}).closest="closest",eIJ.downward="downward",eIJ.upward="upward",eIJ);class jI extends Ns{constructor({servicesManager:e,extensionManager:t,configuration:r}){super(jM),this._extensionManager=void 0,this._servicesManager=void 0,this._subscriptions=void 0,this._activeDisplaySetsInstanceUIDs=[],this._pendingRequests=[],this._inflightRequests=new Map,this._isRunning=!1,this._displaySetLoadingStates=new Map,this._imageIdsToDisplaySetsMap=new Map,this.config={enabled:!1,displaySetsCount:1,maxNumPrefetchRequests:10,order:jS.downward},this.requestType=jk.Prefetch,this.cache=void 0,this.imageLoadPoolManager=void 0,this.imageLoader=void 0,this.imageLoadEventsManager=void 0,this._servicesManager=e,this._extensionManager=t,this._subscriptions=[],Object.assign(this.config,r)}onModeEnter(){this._addEventListeners()}onModeExit(){this._removeEventListeners(),this._stopPrefetching()}_addImageLoadingEventsListeners(){let e=e=>{this._inflightRequests.get(e)||this._sendNextRequests()},t=t=>{let{image:r}=t.detail,{imageId:n}=r;this._moveImageIdToLoadedSet(n),e(n)},r=t=>{let{imageId:r}=t.detail;this._moveImageIdToFailedSet(r),e(r)};return this.imageLoadEventsManager.addEventListeners(t,r)}_addServicesListeners(){let{displaySetService:e,viewportGridService:t}=this._servicesManager.services;return[e.subscribe(e.EVENTS.DISPLAY_SETS_CHANGED,()=>this._syncWithActiveViewport({forceRestart:!0})),t.subscribe(NH.EVENTS.ACTIVE_VIEWPORT_ID_CHANGED,({viewportId:e})=>this._syncWithActiveViewport({activeViewportId:e})),t.subscribe(NH.EVENTS.LAYOUT_CHANGED,()=>this._syncWithActiveViewport()),t.subscribe(NH.EVENTS.GRID_STATE_CHANGED,()=>this._syncWithActiveViewport()),t.subscribe(NH.EVENTS.VIEWPORTS_READY,()=>{this._syncWithActiveViewport(),this._startPrefetching()})]}_addEventListeners(){let e=this._addImageLoadingEventsListeners(),t=this._addServicesListeners();this._subscriptions.push(...e),this._subscriptions.push(...t)}_removeEventListeners(){this._subscriptions.forEach(e=>e.unsubscribe()),this._subscriptions=[]}_syncWithActiveViewport({activeViewportId:e,forceRestart:t}={}){let{viewportGridService:r}=this._servicesManager.services,n=r.getState(),{viewports:a}=n;if(!(e=e??n.activeViewportId))return;let i=a.get(e);if(!i)return;let o=this._setActiveDisplaySetsUIDs(i.displaySetInstanceUIDs);(t||o)&&this._restartPrefetching()}_setActiveDisplaySetsUIDs(e){return!(e.length===this._activeDisplaySetsInstanceUIDs.length&&e.every(e=>this._activeDisplaySetsInstanceUIDs.includes(e)))&&(this._activeDisplaySetsInstanceUIDs=[...e],this._restartPrefetching(),!0)}_areActiveDisplaySetsLoaded(){let{_activeDisplaySetsInstanceUIDs:e}=this;return e.length&&e.every(e=>this._displaySetLoadingStates.get(e).loadingProgress>=1)}_getClosestDisplaySets(e,t){let r=[],n=t-1,a=t+1;for(;n>=0||a<e.length;)n>=0&&(r.push(e[n]),n--),a<e.length&&(r.push(e[a]),a++);return r}_getDownwardDisplaySets(e,t){let r=[];for(let n=t+1;n<e.length;n++)r.push(e[n]);return r}_getUpwardDisplaySets(e,t){let r=[];for(let n=t-1;n>=0&&n!==t;n--)r.push(e[n]);return r}_getSortedDisplaySetsToPrefetch(e){if(!this._activeDisplaySetsInstanceUIDs?.length)return[];let{displaySetsCount:t}=this.config,r=this._activeDisplaySetsInstanceUIDs,[n]=r,a=e.findIndex(e=>e.displaySetInstanceUID===n),i={[jS.closest]:this._getClosestDisplaySets,[jS.downward]:this._getDownwardDisplaySets,[jS.upward]:this._getUpwardDisplaySets},{order:o}=this.config,s=i[o];if(!s)throw Error(`Invalid order (${o})`);let l=new Set(r);return s.call(this,e,a).filter(e=>!l.has(e.displaySetInstanceUID)).slice(0,t)}_getDisplaySets(){let{displaySetService:e}=this._servicesManager.services,t=[...e.getActiveDisplaySets()],r=this._getSortedDisplaySetsToPrefetch(t);return{displaySets:t,displaySetsToPrefetch:r}}_updateImageIdsDisplaySetMap(e,t){for(let r of t){let t=this._imageIdsToDisplaySetsMap.get(r);t||(t=new Set,this._imageIdsToDisplaySetsMap.set(r,t)),t.add(e)}}_getImageIdsForDisplaySet(e){return this._extensionManager.getActiveDataSource()[0].getImageIdsForDisplaySet(e)}_updateDisplaySetLoadingProgress(e){let{numInstances:t,loadedImageIds:r,failedImageIds:n}=e;e.loadingProgress=(r.size+n.size)/t}_addDisplaySetLoadingState(e){let{displaySetInstanceUID:t}=e,r=this._getImageIdsForDisplaySet(e),n=this._displaySetLoadingStates.get(t);if(n)return;let a=new Set(r),i=new Set;for(let e of r)this.cache.isImageCached(e)?i.add(e):a.add(e);n={displaySetInstanceUID:t,numInstances:r.length,pendingImageIds:a,loadedImageIds:i,failedImageIds:new Set,loadingProgress:0},this._updateDisplaySetLoadingProgress(n),this._displaySetLoadingStates.set(t,n),this._updateImageIdsDisplaySetMap(t,r),i.size&&this._triggerDisplaySetEvents(t)}_loadDisplaySets(){let{displaySets:e,displaySetsToPrefetch:t}=this._getDisplaySets();e.forEach(e=>this._addDisplaySetLoadingState(e)),t.forEach(e=>this._enqueueDisplaySetImagesRequests(e))}_moveImageIdToLoadedSet(e){let t=this._imageIdsToDisplaySetsMap.get(e);if(t){for(let r of Array.from(t.values())){let t=this._displaySetLoadingStates.get(r),{pendingImageIds:n,loadedImageIds:a}=t;n.delete(e),a.add(e),this._updateDisplaySetLoadingProgress(t),this._triggerDisplaySetEvents(r)}return!0}}_moveImageIdToFailedSet(e){let t=this._imageIdsToDisplaySetsMap.get(e);if(t){for(let r of Array.from(t.values())){let t=this._displaySetLoadingStates.get(r),{pendingImageIds:n,failedImageIds:a}=t;n.delete(e),a.add(e),this._updateDisplaySetLoadingProgress(t),this._triggerDisplaySetEvents(r)}return!0}}_triggerDisplaySetEvents(e){let{loadingProgress:t,numInstances:r}=this._displaySetLoadingStates.get(e);this._broadcastEvent(this.EVENTS.DISPLAYSET_LOAD_PROGRESS,{displaySetInstanceUID:e,numInstances:r,loadingProgress:t}),t>=1&&this._broadcastEvent(this.EVENTS.DISPLAYSET_LOAD_COMPLETE,{displaySetInstanceUID:e})}_onImagePrefetchSuccess(e){if(e.aborted)return;let{imageId:t}=e;this._inflightRequests.delete(t),this._moveImageIdToLoadedSet(t),this._sendNextRequests()}_onImagePrefetchFailed(e,t){if(e.aborted)return;console.warn(`An error ocurred when trying to load "${e.imageId}"`,t);let{imageId:r}=e;this._inflightRequests.delete(r),this._moveImageIdToFailedSet(r),this._sendNextRequests()}async _sendNextRequests(){if(!this._isRunning||!this._areActiveDisplaySetsLoaded())return;let{_pendingRequests:e,_inflightRequests:t}=this,{maxNumPrefetchRequests:r}=this.config;if(!e.length||t.size>=r)return;let n=Math.min(e.length,r-t.size);this._pendingRequests.splice(0,n).forEach(e=>{let{imageId:r}=e,n={priority:-5,requestType:this.requestType,additionalDetails:{imageId:r},preScale:{enabled:!0}};this.imageLoadPoolManager.addRequest(async()=>this.imageLoader.loadAndCacheImage(r,n).then(t=>this._onImagePrefetchSuccess(e),t=>this._onImagePrefetchFailed(e,t)),this.requestType,{imageId:r}),t.set(r,e)})}_enqueueDisplaySetImagesRequests(e){let{displaySetInstanceUID:t}=e;this._getImageIdsForDisplaySet(e).forEach(e=>{this.cache.isImageCached(e)?this._moveImageIdToLoadedSet(e):this._pendingRequests.push({displaySetInstanceUID:t,imageId:e,aborted:!1})})}_startPrefetching(){if(!this._isRunning){if(!this.config.enabled)return void console.log("StudyPrefetcher is not enabled");this._isRunning=!0,this._loadDisplaySets(),this._sendNextRequests(),this._broadcastEvent(this.EVENTS.SERVICE_STARTED,{})}}_stopPrefetching(){this._isRunning&&(this._isRunning=!1,this._inflightRequests.forEach(e=>e.aborted=!0),this._pendingRequests=[],this._displaySetLoadingStates.clear(),this._imageIdsToDisplaySetsMap.clear(),this._inflightRequests.clear(),this.imageLoadPoolManager.clearRequestStack(this.requestType),this._broadcastEvent(this.EVENTS.SERVICE_STOPPED,{}))}_restartPrefetching(){this._isRunning&&(this._stopPrefetching(),this._startPrefetching())}}jI.REGISTRATION={name:"studyPrefetcherService",altName:"StudyPrefetcherService",create:({configuration:e,servicesManager:t,extensionManager:r})=>new jI({servicesManager:t,extensionManager:r,configuration:e})};class jT{constructor(e,t){this.numberOfScreens=void 0,this.windowsConfig=void 0,this.screenConfig=void 0,this.launchWindows=[],this.basePath=void 0,this.screenNumber=void 0,this.isMultimonitor=void 0,this.setLaunchWindows=e=>{this.launchWindows=e,window.multimonitor.launchWindows=e};const r=new URLSearchParams(window.location.search),n=r.get("screenNumber"),a=r.get("multimonitor"),i={params:r,screenNumber:n,multimonitor:a};this.screenNumber=n?Number(n):-1,this.commandsManager=t;const o=window;for(const r of(o.multimonitor||={setLaunchWindows:this.setLaunchWindows,launchWindows:this.launchWindows,commandsManager:t},o.multimonitor.commandsManager=t,this.launchWindows=window.multimonitor?.launchWindows||this.launchWindows,-1!==this.screenNumber&&(this.launchWindows[this.screenNumber]=window),o.commandsManager=(...t)=>e.commandsManager,Array.isArray(e)?e:[])){if(r.test(i)){if(this.isMultimonitor=!0,this.numberOfScreens=r.screens.length,this.windowsConfig=r,-1===this.screenNumber||null===this.screenNumber)this.screenConfig=jT.SOURCE_SCREEN;else{if(this.screenConfig=r.screens[this.screenNumber],!this.screenConfig)throw Error(`Screen ${n} not configured in ${this.windowsConfig}`);window.name=this.screenConfig.id}return}this.numberOfScreens=1,this.isMultimonitor=!1}}async run(e=1,t,r){let n=(this.screenNumber+(e??1))%this.numberOfScreens,a=await this.getWindow(n);a?a.multimonitor?.commandsManager?a.multimonitor.commandsManager.runAsync(t,r):console.warn("Didn't find a commands manager to run in the other window",a):console.warn("No multimonitor found for screen",n,t)}async launchWindow(e,t=1,r=""){let n=(this.screenNumber+t)%this.numberOfScreens;return this.getWindow(n,e?`StudyInstanceUIDs=${e}${r}`:"")}async getWindow(e,t){return e===this.screenNumber?window:this.launchWindows[e]&&!this.launchWindows[e].closed?this.launchWindows[e]:await this.createWindow(e,t)}async createWindow(e,t){if(e===this.screenNumber)return window;let r=this.windowsConfig.screens[e],n=await window.getScreenDetails?.(),{width:a=1024,height:i=1024,availLeft:o=0,availTop:s=0}=r.screen>=0&&n.screens[r.screen]||n.currentScreen||window.screen||{},l=this.windowsConfig.screens[e],{width:d=1,height:u=1,top:c=0,left:h=0}=l.location||{},p=Math.round(o+h*a),m=Math.round(s+c*i),f=Math.round(a*d),g=Math.round(i*u),y=`${this.basePath}&screenNumber=${e}`,v=t?`${y}#${t}`:y,b=l.id,x=l.options||"",w=`screenX=${p},screenY=${m},width=${f},height=${g},${x}`,C=window.open("",b,w);return(C?.location.href.startsWith(y)||(C=window.open(v,b,w)),C)?(await new Promise(e=>{"complete"===C.document.readyState?e():C.addEventListener("load",()=>e())}),this.launchWindows[e]=C,C):void console.warn("Unable to launch window",v,"called",b,"at",w)}launchAll(){for(let e=0;e<this.numberOfScreens;e++)this.createWindow(e)}setBasePath(){let e=new URL(window.location.href);e.searchParams.delete("screenNumber"),e.searchParams.delete("protocolId"),e.searchParams.delete("launchAll"),e.searchParams.set("multimonitor",e.searchParams.get("multimonitor")||"split"),e.hash="",this.basePath=e.toString()}onModeEnter(){this.setBasePath(),(this.isMultimonitor&&-1===this.screenNumber||-1!==window.location.href.toLowerCase().indexOf("launchall"))&&this.launchAll()}}jT.SOURCE_SCREEN={id:"source",launch:"source",screen:null,location:{screen:null,width:1,height:1,left:0,top:0}},jT.REGISTRATION={name:"multiMonitorService",create:({configuration:e,commandsManager:t})=>new jT(e,t)};class j_ extends Ns{constructor({commandsManager:e,servicesManager:t,serviceProvidersManager:r,hotkeysManager:n,appConfig:a={}}){super(j_.EVENTS),this._commandsManager=void 0,this._servicesManager=void 0,this._hotkeysManager=void 0,this._serviceProvidersManager=void 0,this.modulesMap=void 0,this.modules=void 0,this.registeredExtensionIds=void 0,this.moduleTypeNames=void 0,this._appConfig=void 0,this._extensionLifeCycleHooks=void 0,this.dataSourceMap=void 0,this.dataSourceDefs=void 0,this._activeDataSourceName=void 0,this.registerExtensions=async(e,t=[])=>{for(let r=0;r<e.length;r++){let n=e[r],a=Array.isArray(n);try{if(a){let e=n[0],r=n[1];await this.registerExtension(e,r,t)}else await this.registerExtension(n,{},t)}catch(e){console.error(e)}}},this.registerExtension=async(e,t={},r=[])=>{if(!e)throw Error("Attempting to register a null/undefined extension.");let n=e.id;if(!n)throw O7.warn(e),Error("Extension ID not set");this.registeredExtensionIds.includes(n)?O7.warn(`Extension ID ${n} has already been registered. Exiting before duplicating modules.`):(e.preRegistration&&await e.preRegistration({servicesManager:this._servicesManager,serviceProvidersManager:this._serviceProvidersManager,commandsManager:this._commandsManager,hotkeysManager:this._hotkeysManager,extensionManager:this,appConfig:this._appConfig,configuration:t}),e.onModeEnter&&(this._extensionLifeCycleHooks.onModeEnter[n]=e.onModeEnter),e.onModeExit&&(this._extensionLifeCycleHooks.onModeExit[n]=e.onModeExit),this.moduleTypeNames.forEach(a=>{let i=this._getExtensionModule(a,e,n,t);if(i){switch(a){case O9.COMMANDS:this._initCommandsModule(i);break;case O9.DATA_SOURCE:this._initDataSourcesModule(i,n,r);break;case O9.HANGING_PROTOCOL:this._initHangingProtocolsModule(i,n);break;case O9.PANEL:this._initPanelModule(i,n);break;case O9.TOOLBAR:this._initToolbarModule(i,n);break;case O9.VIEWPORT:case O9.SOP_CLASS_HANDLER:case O9.CONTEXT:case O9.LAYOUT_TEMPLATE:case O9.CUSTOMIZATION:case O9.STATE_SYNC:case O9.UTILITY:this.processExtensionModule(i,n,a);break;default:throw Error(`Module type invalid: ${a}`)}this.modules[a].push({extensionId:n,module:i})}}),this.registeredExtensionIds.push(n))},this.getModuleEntry=e=>this.modulesMap[e],this.getModulesByType=e=>this.modules[e],this.getDataSources=e=>(e||(e=this._activeDataSourceName),this.dataSourceMap[e]),this.getDataSourceInstance=e=>this.dataSourceMap[e][0],this.getActiveDataSource=()=>this.dataSourceMap[this._activeDataSourceName],this.getActiveDataSourceOrNull=()=>this.dataSourceMap[this._activeDataSourceName]?.[0]??null,this.getDataSourceDefinition=e=>(void 0===e&&(e=this._activeDataSourceName),this.dataSourceDefs[e]),this.getActiveDataSourceDefinition=()=>this.getDataSourceDefinition(this._activeDataSourceName),this.getDataSourcesForUI=()=>{if(this._appConfig?.allowMultiSelectExport===!1)return[];let e=Object.keys(this.dataSourceMap).filter(e=>{let t=this.dataSourceDefs[e]?.configuration,r=this.dataSourceDefs[e].sourceName!==this._activeDataSourceName;return(t?.supportsStow??t?.wadoRoot)&&r});return[this._activeDataSourceName,...e].map(e=>({value:e,label:e,placeHolder:e}))},this._getExtensionModule=(e,t,r,n)=>{var a;let i="get"+((a=e).charAt(0).toUpperCase()+a.substring(1));if(t[i])try{let e=t[i]({appConfig:this._appConfig,commandsManager:this._commandsManager,servicesManager:this._servicesManager,hotkeysManager:this._hotkeysManager,extensionManager:this,configuration:n});return e||O7.warn(`Null or undefined returned when registering the ${i} module for the ${r} extension`),e}catch(e){throw console.error(e),Error(`Exception thrown while trying to call ${i} for the ${r} extension`)}},this._initHangingProtocolsModule=(e,t)=>{let{hangingProtocolService:r}=this._servicesManager.services;e.forEach(({name:e,protocol:t})=>{t&&r.addProtocol(e,t)})},this._initPanelModule=(e,t)=>{this.processExtensionModule(e,t,O9.PANEL)},this._initToolbarModule=(e,t)=>{let{toolbarService:r}=this._servicesManager.services;e.forEach(e=>{e.evaluate&&r.registerEvaluateFunction(e.name,e.evaluate)})},this._initCommandsModule=e=>{let{definitions:t,defaultContext:r}=e;t&&0!==Object.keys(t).length?(r=r||"VIEWER",this._commandsManager.getContext(r)||this._commandsManager.createContext(r),Object.keys(t).forEach(e=>{let n=t[e];"function"==typeof n&&(n={commandFn:n}),n.context&&!this._commandsManager.getContext(n.context)&&this._commandsManager.createContext(n.context),this._commandsManager.registerCommand(n.context||r,e,n)})):O7.warn("Commands Module contains no command definitions")},this.modules={},this.registeredExtensionIds=[],this.moduleTypeNames=Object.values(O9),this._commandsManager=e,this._servicesManager=t,this._serviceProvidersManager=r,this._hotkeysManager=n,this._appConfig=a,this.modulesMap={},this.moduleTypeNames.forEach(e=>{this.modules[e]=[]}),this._extensionLifeCycleHooks={onModeEnter:{},onModeExit:{}},this.dataSourceMap={},this.dataSourceDefs={},this.defaultDataSourceName=a.defaultDataSourceName,this._activeDataSourceName=a.defaultDataSourceName,this.peerImport=a.peerImport}setActiveDataSource(e){this._activeDataSourceName!==e&&(this._activeDataSourceName=e,this._broadcastEvent(j_.EVENTS.ACTIVE_DATA_SOURCE_CHANGED,this.dataSourceDefs[this._activeDataSourceName]))}getRegisteredExtensionIds(){return[...this.registeredExtensionIds]}getUniqueServicesList(e){return Array.from(new Set(Object.values(e.services)))}onModeEnter(){let{registeredExtensionIds:e,_servicesManager:t,_commandsManager:r,_hotkeysManager:n,_extensionLifeCycleHooks:a}=this;for(let e of this.getUniqueServicesList(t))e?.onModeEnter?.();e.forEach(e=>{let i=a.onModeEnter[e];"function"==typeof i&&i({servicesManager:t,commandsManager:r,hotkeysManager:n,extensionManager:this})})}onModeExit(){let{registeredExtensionIds:e,_servicesManager:t,_commandsManager:r,_extensionLifeCycleHooks:n}=this,a=this.getUniqueServicesList(t);for(let i of(e.forEach(e=>{let a=n.onModeExit[e];"function"==typeof a&&a({servicesManager:t,commandsManager:r})}),a))try{i?.onModeExit?.()}catch(e){console.warn("onModeExit caught",e)}}processExtensionModule(e,t,r){e.forEach(e=>{if(!e.name)throw Error(`Extension ID ${t} module ${r} element has no name`);let n=`${t}.${r}.${e.name}`;e.id=n,this.modulesMap[n]=e})}addDataSource(e,t={activate:!1}){let r=this.getDataSources(e.sourceName);!r?.[0]&&(this._createDataSourceInstance(e),t.activate&&this.setActiveDataSource(e.sourceName))}updateDataSourceConfiguration(e,t){let r=this.getDataSources(e);if(!r?.[0])return;let n=this.dataSourceDefs[e];n.configuration=t,this._createDataSourceInstance(n),this._activeDataSourceName===e&&this._broadcastEvent(j_.EVENTS.ACTIVE_DATA_SOURCE_CHANGED,n)}_createDataSourceInstance(e){let t=this.getModuleEntry(e.namespace);if(!t)return;this.dataSourceDefs[e.sourceName]=e;let r=t.createDataSource(e.configuration,this._servicesManager,this);this.dataSourceMap[e.sourceName]=[r]}_initDataSourcesModule(e,t,r=[]){e.forEach(e=>{this.modulesMap[`${t}.${O9.DATA_SOURCE}.${e.name}`]=e}),e.forEach(e=>{let n=`${t}.${O9.DATA_SOURCE}.${e.name}`;r.forEach(e=>{e.namespace===n&&this.addDataSource(e)})})}registerCommandsModule(e,t="VIEWER"){this._initCommandsModule({...e,defaultContext:e.defaultContext||t})}get appConfig(){return this._appConfig}get activeDataSourceName(){return this._activeDataSourceName}}j_.EVENTS={ACTIVE_DATA_SOURCE_CHANGED:"event::activedatasourcechanged"},j_.MODULE_TYPES=O9;var jP=d(2203),jE=d.n(jP);let jD=[{commandName:"setToolActive",commandOptions:{toolName:"Zoom"},label:"Zoom",keys:["z"],isEditable:!0},{commandName:"scaleUpViewport",label:"Zoom In",keys:["+"],isEditable:!0},{commandName:"scaleDownViewport",label:"Zoom Out",keys:["-"],isEditable:!0},{commandName:"fitViewportToWindow",label:"Zoom to Fit",keys:["="],isEditable:!0},{commandName:"rotateViewportCW",label:"Rotate Right",keys:["r"],isEditable:!0},{commandName:"rotateViewportCCW",label:"Rotate Left",keys:["l"],isEditable:!0},{commandName:"flipViewportHorizontal",label:"Flip Horizontally",keys:["h"],isEditable:!0},{commandName:"flipViewportVertical",label:"Flip Vertically",keys:["v"],isEditable:!0},{commandName:"toggleCine",label:"Cine",keys:["c"]},{commandName:"invertViewport",label:"Invert",keys:["i"],isEditable:!0},{commandName:"incrementActiveViewport",label:"Next Image Viewport",keys:["right"],isEditable:!0},{commandName:"decrementActiveViewport",label:"Previous Image Viewport",keys:["left"],isEditable:!0},{commandName:"updateViewportDisplaySet",commandOptions:{direction:-1},label:"Previous Series",keys:["pageup"],isEditable:!0},{commandName:"updateViewportDisplaySet",commandOptions:{direction:1},label:"Next Series",keys:["pagedown"],isEditable:!0},{commandName:"nextStage",context:"DEFAULT",label:"Next Stage",keys:["."],isEditable:!0},{commandName:"previousStage",context:"DEFAULT",label:"Previous Stage",keys:[","],isEditable:!0},{commandName:"nextImage",label:"Next Image",keys:["down"],isEditable:!0},{commandName:"previousImage",label:"Previous Image",keys:["up"],isEditable:!0},{commandName:"firstImage",label:"First Image",keys:["home"],isEditable:!0},{commandName:"lastImage",label:"Last Image",keys:["end"],isEditable:!0},{commandName:"resetViewport",label:"Reset",keys:["space"],isEditable:!0},{commandName:"cancelActiveOperation",label:"Cancel",keys:["esc"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-soft-tissue",presetIndex:0},label:"W/L Preset 1",keys:["1"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-lung",presetIndex:1},label:"W/L Preset 2",keys:["2"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-liver",presetIndex:2},label:"W/L Preset 3",keys:["3"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-bone",presetIndex:3},label:"W/L Preset 4",keys:["4"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-brain",presetIndex:4},label:"W/L Preset 5",keys:["5"]},{commandName:"deleteActiveAnnotation",label:"Delete Annotation",keys:["backspace"]},{commandName:"acceptPreview",label:"Accept Preview",keys:["enter"]},{commandName:"undo",label:"Undo",keys:["ctrl+z"],isEditable:!0},{commandName:"redo",label:"Redo",keys:["ctrl+y"],isEditable:!0},{commandName:"interpolateScrollForMarkerLabelmap",label:"Interpolate Scroll",keys:["n"],isEditable:!0},{commandName:"increaseBrushSize",label:"Increase Brush Size",keys:["]"],isEditable:!0},{commandName:"decreaseBrushSize",label:"Decrease Brush Size",keys:["["],isEditable:!0},{commandName:"setToolActive",commandOptions:{toolName:"CircularEraser"},label:"Eraser",keys:["e"],isEditable:!0},{commandName:"setToolActive",commandOptions:{toolName:"CircularBrush"},label:"Brush",keys:["b"],isEditable:!0},{commandName:"addNewSegment",label:"Add New Segment",keys:["a"],isEditable:!0}],jA=function({generateHash:e}){try{let t=localStorage.getItem("hotkey-definitions"),r=localStorage.getItem("hotkeys-migrated");if(!t||"true"===r)return;let n=JSON.parse(t);if(!Array.isArray(n)||0===n.length)return;let a=jD||[],i=JSON.parse(localStorage.getItem("user-preferred-keys")||"{}");n.forEach(t=>{if(!t.commandName||!t.keys)return;let r=a.find(e=>{let r=e.commandName===t.commandName,n=t.commandOptions||{},a=e.commandOptions||{},i=JSON.stringify(n)===JSON.stringify(a);return r&&i});r&&JSON.stringify(r.keys)===JSON.stringify(t.keys)||(i[e({commandName:t.commandName,commandOptions:t.commandOptions||{}})]=t.keys,console.debug(`HotkeysManager: Migrated custom hotkey for ${t.commandName}`))}),localStorage.setItem("user-preferred-keys",JSON.stringify(i)),localStorage.setItem("hotkeys-migrated","true"),localStorage.removeItem("hotkey-definitions"),console.debug("HotkeysManager: Successfully migrated hotkey definitions to new format")}catch(e){console.error("HotkeysManager: Error migrating hotkey definitions",e),localStorage.setItem("hotkeys-migrated","false")}};class jO{constructor(e,t){this._servicesManager=void 0,this._commandsManager=void 0,this.isEnabled=!0,this.hotkeyDefinitions={},this.hotkeyDefaults=[],this.EVENTS=void 0,this.listeners={},this.subscribe=void 0,this._broadcastEvent=void 0,this._unsubscribe=void 0,this._isValidEvent=void 0,this._servicesManager=t,this._commandsManager=e,this.EVENTS=jO.EVENTS,this.subscribe=Nr.subscribe.bind(this),this._broadcastEvent=Nr._broadcastEvent.bind(this),this._unsubscribe=Nr._unsubscribe.bind(this),this._isValidEvent=Nr._isValidEvent.bind(this),jA({generateHash:this.generateHash})}record(e){return R2.record(e)}cancel(){R2.stopRecord(),R2.unpause()}disable(){this.isEnabled=!1,R2.pause()}enable(){this.isEnabled=!0,R2.unpause()}restoreDefaultBindings(){this.setHotkeys(this.hotkeyDefaults)}destroy(){this.hotkeyDefaults=[],this.hotkeyDefinitions={},R2.reset()}setHotkeys(e=[]){try{this.getValidDefinitions(e).forEach(e=>this.registerHotkeys(e))}catch(t){let{uiNotificationService:e}=this._servicesManager.services;e.show({title:"Hotkeys Manager",message:"Error while setting hotkeys",type:"error"})}}generateHash(e){return jE()({commandName:e.commandName,commandOptions:e.commandOptions||{}})}setDefaultHotKeys(e=[]){let t=this.getValidDefinitions(e);this.hotkeyDefaults=t;let r=JSON.parse(localStorage.getItem("user-preferred-keys")||"{}"),n=t.map(e=>{let t=this.generateHash(e);return r[t]?{...e,keys:r[t]}:e});this.setHotkeys(n)}getValidDefinitions(e){let t=Array.isArray(e)?[...e]:this._parseToArrayLike(e);return t.forEach(e=>{void 0===e.isEditable&&(e.isEditable=!0)}),t}getValidHotkeyDefinitions(e){let t=this.getValidDefinitions(e),r={};return t.forEach(e=>{let{commandName:t,commandOptions:n}=e;r[jE()({commandName:t,commandOptions:n})]=e}),r}_parseToArrayLike(e={}){return Object.entries({...e}).map(e=>this._parseToHotKeyObj(e[0],e[1]))}_parseToHotKeyObj(e,t){return{commandName:e,...t}}registerHotkeys({commandName:e,commandOptions:t={},context:r,keys:n,label:a,isEditable:i}){if(!e)throw Error(`No command was defined for hotkey "${n}"`);let o=this.generateHash({commandName:e,commandOptions:t}),s=this.hotkeyDefinitions[o];if(s&&s.keys===n)return void console.debug("HotkeysManager: Identical hotkey registration skipped.");let l=JSON.parse(localStorage.getItem("user-preferred-keys")||"{}");s&&(l[o]=n,localStorage.setItem("user-preferred-keys",JSON.stringify(l)),this._unbindHotkeys(e,s.keys)),this.hotkeyDefinitions[o]={commandName:e,commandOptions:t,keys:n,label:a,isEditable:i},this._bindHotkeys(e,t,r,n)}_bindHotkeys(e,t={},r,n){if(""===n||void 0===n)return;let a=n instanceof Array?n.join("+"):n;R2.bind(a,n=>{n.preventDefault(),n.stopPropagation(),this._commandsManager.runCommand(e,{evt:n,...t},r),this._broadcastEvent(jO.EVENTS.HOTKEY_PRESSED,{commandName:e,commandOptions:t,keys:a,context:r,evt:n})})}_unbindHotkeys(e,t){if(""!==t&&void 0!==t){if(t instanceof Array){let r=t.join("+");this._unbindHotkeys(e,r);return}R2.unbind(t)}}}jO.EVENTS={HOTKEY_PRESSED:"event::hotkeysManager:hotkeyPressed"};var jN=d(313),jR=d.n(jN);(eIQ=eTE||(eTE={})).ERROR_EVENT="CORNERSTONE_ERROR",eIQ.CACHE_SIZE_EXCEEDED="CACHE_SIZE_EXCEEDED",eIQ.IMAGE_LOAD_ERROR="IMAGE_LOAD_ERROR",eIQ.CAMERA_MODIFIED="CORNERSTONE_CAMERA_MODIFIED",eIQ.CAMERA_RESET="CORNERSTONE_CAMERA_RESET",eIQ.VOI_MODIFIED="CORNERSTONE_VOI_MODIFIED",eIQ.PRESET_MODIFIED="CORNERSTONE_VIEWPORT_RENDERING_PRESET_MODIFIED",eIQ.DISPLAY_AREA_MODIFIED="CORNERSTONE_DISPLAY_AREA_MODIFIED",eIQ.ELEMENT_DISABLED="CORNERSTONE_ELEMENT_DISABLED",eIQ.ELEMENT_ENABLED="CORNERSTONE_ELEMENT_ENABLED",eIQ.IMAGE_RENDERED="CORNERSTONE_IMAGE_RENDERED",eIQ.VIEWPORT_FIDELITY_CHANGED="CORNERSTONE_VIEWPORT_FIDELITY_CHANGED",eIQ.IMAGE_VOLUME_MODIFIED="CORNERSTONE_IMAGE_VOLUME_MODIFIED",eIQ.IMAGE_VOLUME_LOADING_COMPLETED="CORNERSTONE_IMAGE_VOLUME_LOADING_COMPLETED",eIQ.IMAGE_VOLUME_LOADING_CANCELLED="CORNERSTONE_IMAGE_VOLUME_LOADING_CANCELLED",eIQ.IMAGE_LOADED="CORNERSTONE_IMAGE_LOADED",eIQ.IMAGE_RETRIEVAL_STAGE="CORNERSTONE_IMAGE_RETRIEVAL_STAGE",eIQ.IMAGE_LOAD_FAILED="CORNERSTONE_IMAGE_LOAD_FAILED",eIQ.VOLUME_VIEWPORT_NEW_VOLUME="CORNERSTONE_VOLUME_VIEWPORT_NEW_VOLUME",eIQ.VOLUME_LOADED="CORNERSTONE_VOLUME_LOADED",eIQ.VOLUME_LOADED_FAILED="CORNERSTONE_VOLUME_LOADED_FAILED",eIQ.IMAGE_CACHE_IMAGE_ADDED="CORNERSTONE_IMAGE_CACHE_IMAGE_ADDED",eIQ.IMAGE_CACHE_IMAGE_REMOVED="CORNERSTONE_IMAGE_CACHE_IMAGE_REMOVED",eIQ.VOLUME_CACHE_VOLUME_ADDED="CORNERSTONE_VOLUME_CACHE_VOLUME_ADDED",eIQ.VOLUME_CACHE_VOLUME_REMOVED="CORNERSTONE_VOLUME_CACHE_VOLUME_REMOVED",eIQ.VOLUME_TEXTURE_LIMITS_CHANGED="CORNERSTONE_VOLUME_TEXTURE_LIMITS_CHANGED",eIQ.STACK_NEW_IMAGE="CORNERSTONE_STACK_NEW_IMAGE",eIQ.VOLUME_NEW_IMAGE="CORNERSTONE_VOLUME_NEW_IMAGE",eIQ.PRE_STACK_NEW_IMAGE="CORNERSTONE_PRE_STACK_NEW_IMAGE",eIQ.IMAGE_SPACING_CALIBRATED="CORNERSTONE_IMAGE_SPACING_CALIBRATED",eIQ.VIEWPORT_NEW_IMAGE_SET="CORNERSTONE_VIEWPORT_NEW_IMAGE_SET",eIQ.STACK_VIEWPORT_SCROLL="CORNERSTONE_STACK_VIEWPORT_SCROLL",eIQ.STACK_SCROLL_OUT_OF_BOUNDS="STACK_SCROLL_OUT_OF_BOUNDS",eIQ.GEOMETRY_CACHE_GEOMETRY_ADDED="CORNERSTONE_GEOMETRY_CACHE_GEOMETRY_ADDED",eIQ.GEOMETRY_CACHE_GEOMETRY_REMOVED="CORNERSTONE_GEOMETRY_CACHE_GEOMETRY_REMOVED",eIQ.VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS="VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS",eIQ.VOLUME_VIEWPORT_SCROLL="VOLUME_VIEWPORT_SCROLL",eIQ.CLIPPING_PLANES_UPDATED="CORNERSTONE_CLIPPING_PLANES_UPDATED",eIQ.WEB_WORKER_PROGRESS="CORNERSTONE_WEB_WORKER_PROGRESS",eIQ.COLORMAP_MODIFIED="CORNERSTONE_COLORMAP_MODIFIED",eIQ.DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED="DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED",eIQ.DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED="DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED",eIQ.DYNAMIC_VOLUME_DIMENSION_GROUP_LOADED="DYNAMIC_VOLUME_DIMENSION_GROUP_LOADED",eIQ.DYNAMIC_VOLUME_TIME_POINT_LOADED="DYNAMIC_VOLUME_TIME_POINT_LOADED",eIQ.GEOMETRY_LOADED="GEOMETRY_LOADED",eIQ.GEOMETRY_LOAD_PROGRESS="GEOMETRY_LOAD_PROGRESS",eIQ.GEOMETRY_LOADED_FAILED="GEOMETRY_LOADED_FAILED",eIQ.ACTORS_CHANGED="CORNERSTONE_ACTORS_CHANGED",eIQ.RENDER_BACKEND_CHANGED="CORNERSTONE_RENDER_BACKEND_CHANGED",eIQ.WEBGL_CONTEXT_LOST="CORNERSTONE_WEBGL_CONTEXT_LOST",eIQ.WEBGL_CONTEXT_RESTORED="CORNERSTONE_WEBGL_CONTEXT_RESTORED",eIQ.RENDER_PATH_ERROR="CORNERSTONE_RENDER_PATH_ERROR",eIQ.RENDERING_PIPELINE_CHANGED="CORNERSTONE_RENDERING_PIPELINE_CHANGED";let jL=eTE;(eI0=eTD||(eTD={})).Interaction="interaction",eI0.Thumbnail="thumbnail",eI0.Prefetch="prefetch",eI0.Compute="compute";let jj=eTD;(eI1=eTA||(eTA={})).STACK="stack",eI1.ORTHOGRAPHIC="orthographic",eI1.PERSPECTIVE="perspective",eI1.VOLUME_3D="volume3d",eI1.VOLUME_3D_NEXT="volume3dNext",eI1.PLANAR_NEXT="planarNext",eI1.VIDEO="video",eI1.VIDEO_NEXT="videoNext",eI1.WHOLE_SLIDE="wholeSlide",eI1.WHOLE_SLIDE_NEXT="wholeSlideNext",eI1.ECG="ecg",eI1.ECG_NEXT="ecgNext";let jV=eTA,jF={STACK:jV.STACK,ORTHOGRAPHIC:jV.ORTHOGRAPHIC,PERSPECTIVE:jV.PERSPECTIVE,VOLUME_3D:jV.VOLUME_3D,VOLUME_3D_NEXT:jV.VOLUME_3D_NEXT,PLANAR_NEXT:jV.PLANAR_NEXT,VIDEO:jV.VIDEO,VIDEO_NEXT:jV.VIDEO_NEXT,WHOLE_SLIDE:jV.WHOLE_SLIDE,WHOLE_SLIDE_NEXT:jV.WHOLE_SLIDE_NEXT,ECG:jV.ECG,ECG_NEXT:jV.ECG_NEXT};(eI2=eTO||(eTO={}))[eI2.NEAREST=0]="NEAREST",eI2[eI2.LINEAR=1]="LINEAR",eI2[eI2.FAST_LINEAR=2]="FAST_LINEAR";let jB=eTO;var jW={COMPOSITE_BLEND:0,MAXIMUM_INTENSITY_BLEND:1,MINIMUM_INTENSITY_BLEND:2,AVERAGE_INTENSITY_BLEND:3,ADDITIVE_INTENSITY_BLEND:4,RADON_TRANSFORM_BLEND:5,LABELMAP_EDGE_PROJECTION_BLEND:6},jU={BlendMode:jW};let{BlendMode:jz}=jU;(eI5=eTN||(eTN={}))[eI5.COMPOSITE=jz.COMPOSITE_BLEND]="COMPOSITE",eI5[eI5.MAXIMUM_INTENSITY_BLEND=jz.MAXIMUM_INTENSITY_BLEND]="MAXIMUM_INTENSITY_BLEND",eI5[eI5.MINIMUM_INTENSITY_BLEND=jz.MINIMUM_INTENSITY_BLEND]="MINIMUM_INTENSITY_BLEND",eI5[eI5.AVERAGE_INTENSITY_BLEND=jz.AVERAGE_INTENSITY_BLEND]="AVERAGE_INTENSITY_BLEND",eI5[eI5.LABELMAP_EDGE_PROJECTION_BLEND=jz.LABELMAP_EDGE_PROJECTION_BLEND]="LABELMAP_EDGE_PROJECTION_BLEND";let jH=eTN;(eI3=eTR||(eTR={})).AXIAL="axial",eI3.CORONAL="coronal",eI3.SAGITTAL="sagittal",eI3.ACQUISITION="acquisition",eI3.AXIAL_REFORMAT="axial_reformat",eI3.CORONAL_REFORMAT="coronal_reformat",eI3.SAGITTAL_REFORMAT="sagittal_reformat",eI3.REFORMAT="reformat";let jG=eTR;(eI4=eTL||(eTL={})).CONTOUR="CONTOUR",eI4.SURFACE="SURFACE",eI4.MESH="MESH";let jq=eTL;(eI8=eTj||(eTj={})).CLOSED_PLANAR="CLOSED_PLANAR",eI8.OPEN_PLANAR="OPEN_PLANAR",(eI6=eTV||(eTV={})).PLY="PLY",eI6.STL="STL",eI6.OBJ="OBJ",eI6.VTP="VTP";let j$=eTV;(eI9=eTF||(eTF={})).LINEAR="LINEAR",eI9.SAMPLED_SIGMOID="SIGMOID",eI9.LINEAR_EXACT="LINEAR_EXACT";let jK=eTF;(eI7=eTB||(eTB={})).SUM="SUM",eI7.AVERAGE="AVERAGE",eI7.SUBTRACT="SUBTRACT";class jY{constructor(e){this.fullDate=e}getTimeInSec(){let e=this.fullDate.substring(0,10),t=this.fullDate.substring(11,28),r=parseInt(e.substring(0,4),10),n=e.length>=7?parseInt(e.substring(5,7),10):void 0,a=e.length>=10?parseInt(e.substring(8,10),10):void 0;if(isNaN(r)||void 0!==n&&isNaN(n)||void 0!==a&&isNaN(a)||r>3e3||n&&(n<1||n>12)||a&&(a<1||a>31))throw Error(`invalid date '${e}'`);let i=new Date(`${e}T00:00:00.000000Z`),o=parseInt(t.substring(0,2),10),s=t.length>=5?parseInt(t.substring(3,5),10):void 0,l=t.length>=8?parseInt(t.substring(6,8),10):void 0,d=t.substring(9,15),u=d?parseInt(d,10)*Math.pow(10,-d.length):void 0;if(isNaN(o)||void 0!==s&&isNaN(s)||void 0!==l&&isNaN(l)||void 0!==u&&isNaN(u)||o<0||o>23||s&&(s<0||s>59)||l&&(l<0||l>59)||u&&(u<0||u>999999))throw Error(`invalid time '${t}'`);let c=i.getTime()/1e3;return c+=3600*o,void 0!==s&&(c+=60*s),void 0!==l&&(c+=l),void 0!==u&&(c+=u),c}getTimeInMicroSec(){return 1e6*this.getTimeInSec()}}function jX(e,t){let r=`${t.hours||"00"}`.padStart(2,"0"),n=`${t.minutes||"00"}`.padStart(2,"0"),a=`${t.seconds||"00"}`.padStart(2,"0"),i=`${e.month}`.padStart(2,"0"),o=`${e.day}`.padStart(2,"0"),s=`${t.fractionalSeconds||"000000"}`.padEnd(6,"0"),l=`${e.year}-${i}-${o}`,d=`T${r}:${n}:${a}.${s}Z`;return new jY(`${l}${d}`)}function jZ(e){if(null==e||8!==e.length||"string"!=typeof e)throw Error(`invalid DA '${e}'`);let t=parseInt(e.substring(0,4),10),r=parseInt(e.substring(4,6),10),n=parseInt(e.substring(6,8),10);if(!0!=(!isNaN(t)&&r>0&&r<=12&&n>0&&n<=function(e,t){switch(e){case 2:return t%4==0&&t%100||t%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(r,t)))throw Error(`invalid DA '${e}'`);return{year:t,month:r,day:n}}function jJ(e){if(null==e||e.length<2||"string"!=typeof e)throw Error(`invalid TM '${e}'`);let t=parseInt(e.substring(0,2),10),r=e.length>=4?parseInt(e.substring(2,4),10):void 0,n=e.length>=6?parseInt(e.substring(4,6),10):void 0,a=e.length>=8?e.substring(7,13):void 0,i=a?parseInt(a,10)*Math.pow(10,6-a.length):void 0;if(isNaN(t)||void 0!==r&&isNaN(r)||void 0!==n&&isNaN(n)||void 0!==i&&isNaN(i)||t<0||t>23||r&&(r<0||r>59)||n&&(n<0||n>59)||i&&(i<0||i>999999))throw Error(`invalid TM '${e}'`);return{hours:t,minutes:r,seconds:n,fractionalSeconds:i}}function jQ(e){if(null==e)throw Error("dateTimeToFullDateInterface : dateTime not defined.");return jX(jZ(e.substring(0,8)),jJ(e.substring(8)))}function j0(e){let t,r,{CorrectedImage:n,Units:a,PhilipsPETPrivateGroup:i,PatientWeight:o,PatientSex:s,PatientSize:l}=e[0];if(!n.includes("ATTN")||!n.includes("DECY"))throw Error(`CorrectedImage must contain "ATTN" and "DECY": ${n}`);if(!e.every(t=>{let r;return t.Units===a&&((r=t.CorrectedImage)===n||Array.isArray(r)&&Array.isArray(n)&&r.length===n.length&&r.every((e,t)=>e===n[t]))&&t.PatientWeight===o&&t.PatientSex===s&&t.PatientSize===l&&t.RadionuclideHalfLife===e[0].RadionuclideHalfLife&&t.RadionuclideTotalDose===e[0].RadionuclideTotalDose&&t.DecayCorrection===e[0].DecayCorrection&&t.SeriesDate===e[0].SeriesDate&&t.SeriesTime===e[0].SeriesTime}))throw Error("The set of instances does not appear to come from one Series. Every instance must have identical values for series-level metadata properties");if(null==o)throw Error("PatientWeight value is missing. It is not possible to calculate the SUV factors");let d=Array(e.length);d=function(e){let{RadionuclideTotalDose:t,RadionuclideHalfLife:r,RadiopharmaceuticalStartDateTime:n,RadiopharmaceuticalStartTime:a,SeriesDate:i}=e[0];if(null==t)throw Error("calculateDecayCorrection : RadionuclideTotalDose value not found.");if(null==r)throw Error("calculateDecayCorrection : RadionuclideHalfLife value not found.");let o=function(e){let{SeriesDate:t,SeriesTime:r,GEPrivatePostInjectionDateTime:n}=e[0],a=Array(e.length),i=jX(jZ(t),jJ(r)),o=new jY("3000-01-01T00:00:00.000000Z"),s=o.getTimeInSec();if(e.forEach(e=>{let{AcquisitionDate:t,AcquisitionTime:r}=e,n=jX(jZ(t),jJ(r));o=o.getTimeInSec()>=s||n.getTimeInSec()<o.getTimeInSec()?n:o}),o.getTimeInSec()>=s)throw Error("Earliest acquisition time or date could not be parsed.");return i.getTimeInSec()<=o.getTimeInSec()?a.fill(i):n?a.fill(jQ(n)):a.fill(o)}(e),s=function(e){let t,{RadiopharmaceuticalStartDateTime:r,RadiopharmaceuticalStartTime:n,SeriesDate:a}=e;if(r)return jQ(r);if(n&&a)return t=jJ(n),jX(jZ(a),t);throw Error(`Invalid input: ${e}`)}({RadiopharmaceuticalStartDateTime:n,RadiopharmaceuticalStartTime:a,SeriesDate:i});return e.map((e,n)=>{let a=o[n].getTimeInSec()-s.getTimeInSec();if(a<0)throw Error("Decay time cannot be less than zero");return 1/(t*Math.pow(2,-a/r))})}(e);let u=Array(e.length),c=1e3*o;if("BQML"===a)u=d.map(function(e){return e*c});else if("CNTS"===a){let t=e.every(e=>{var t,r,n;return e.PhilipsPETPrivateGroup&&(null==(t=e.PhilipsPETPrivateGroup)?void 0:t.SUVScaleFactor)!==null&&(null==(r=e.PhilipsPETPrivateGroup)?void 0:r.SUVScaleFactor)!==void 0&&(null==(n=e.PhilipsPETPrivateGroup)?void 0:n.SUVScaleFactor)!==0}),r=e.every(e=>{var t,r,n;return e.PhilipsPETPrivateGroup&&!(null!=(t=e.PhilipsPETPrivateGroup)&&t.SUVScaleFactor)&&(null==(r=e.PhilipsPETPrivateGroup)?void 0:r.ActivityConcentrationScaleFactor)!==void 0&&(null==(n=e.PhilipsPETPrivateGroup)?void 0:n.ActivityConcentrationScaleFactor)!==0});if(t)u=e.map(e=>e.PhilipsPETPrivateGroup.SUVScaleFactor);else if(r)u=e.map((e,t)=>e.PhilipsPETPrivateGroup.ActivityConcentrationScaleFactor*d[t]*c);else throw Error(`Units are in CNTS, but PhilipsPETPrivateGroup has invalid values: ${JSON.stringify(i)}`)}else if("GML"===a)u.fill(1);else throw Error(`Units has an invalid value: ${a}`);return null==l?console.warn("PatientSize value is missing. It is not possible to calculate the SUV bsa factors"):t=function(e){let{PatientWeight:t,PatientSize:r}=e;return Math.pow(t,.425)*Math.pow(100*r,.725)*71.84}({PatientWeight:o,PatientSize:l}),null==l?console.warn("PatientSize value is missing. It is not possible to calculate the SUV lbm factors"):null==s?console.warn("PatientSex value is missing. It is not possible to calculate the SUV lbm factors"):r=function(e){let t,{PatientSex:r,PatientWeight:n,PatientSize:a}=e,i=n*n/(a*a*1e4);if("F"===r)t=1.07*n-148*i;else if("M"===r)t=1.1*n-120*i;else throw Error(`PatientSex is an invalid value: ${r}`);return 1e3*t}({PatientWeight:o,PatientSex:s,PatientSize:l}),u.map(function(e,n){let a={suvbw:e};return t&&(a.suvbsa=d[n]*t),r&&(a.suvlbm=d[n]*r),a})}(eTe=eTW||(eTW={})).NOT_APPLICABLE="",eTe.ERMF="ERMF",eTe.USER="User",eTe.PROJECTION="Proj",eTe.REGION="Region",eTe.ERROR="Error",eTe.UNCALIBRATED="Uncalibrated",eTe.CALIBRATED="Calibrated",eTe.UNKNOWN="Unknown";let j1=eTW;(eTt=eTU||(eTU={})).CALIBRATION="calibrationModule",eTt.CINE="cineModule",eTt.FRAME_OF_REFERENCE="frameOfReferenceModule",eTt.GENERAL_IMAGE="generalImageModule",eTt.GENERAL_SERIES="generalSeriesModule",eTt.GENERAL_STUDY="generalStudyModule",eTt.IMAGE_PIXEL="imagePixelModule",eTt.IMAGE_PLANE="imagePlaneModule",eTt.IMAGE_URL="imageUrlModule",eTt.MODALITY_LUT="modalityLutModule",eTt.MULTIFRAME="multiframeModule",eTt.NM_MULTIFRAME_GEOMETRY="nmMultiframeGeometryModule",eTt.OVERLAY_PLANE="overlayPlaneModule",eTt.PATIENT="patientModule",eTt.PATIENT_DEMOGRAPHIC="patientDemographicModule",eTt.PATIENT_STUDY="patientStudyModule",eTt.PET_IMAGE="petImageModule",eTt.PET_ISOTOPE="petIsotopeModule",eTt.PET_SERIES="petSeriesModule",eTt.SCALING="scalingModule",eTt.SOP_COMMON="sopCommonModule",eTt.ULTRASOUND_ENHANCED_REGION="ultrasoundEnhancedRegionModule",eTt.ECG="ecgModule",eTt.VOI_LUT="voiLutModule",eTt.TRANSFER_SYNTAX="transferSyntax",eTt.PLANE_ORIENTATION="PlaneOrientation",eTt.PLANE_POSITION="PlanePosition",eTt.PIXEL_MEASURES="PixelMeasures",eTt.XRAY_GEOMETRY="XrayGeometry",eTt.FRAME_PIXEL_DATA="FramePixelData",eTt.FRAME_MODULE="frameModule",eTt.URI_MODULE="uriModule",eTt.WADO_WEB_CLIENT="wadoWebClient",eTt.INSTANCE="instance",eTt.IMAGE_SOP_INSTANCE_REFERENCE="ImageSopInstanceReference",eTt.REFERENCED_SERIES_REFERENCE="ReferencedSeriesReference",eTt.PREDECESSOR_SEQUENCE="PredecessorSequence",eTt.STUDY_DATA="StudyData",eTt.SERIES_DATA="SeriesData",eTt.IMAGE_DATA="ImageData",eTt.RTSS_INSTANCE_DATA="RtssInstanceData",eTt.NEW_INSTANCE_DATA="NewInstanceData",eTt.RTSS_CONTOUR="metaRTSSContour",eTt.SEG_BIT="metaSegBitmap",eTt.SR_ANNOTATION="metaSrAnnotation",eTt.COMPRESSED_FRAME_DATA="compressedFrameData",eTt.BASE_IMAGE_ID="baseImageId",eTt.FRAME_IMAGE_IDS="frameImageIds",eTt.NATURALIZED="naturalized",eTt.DISPLAY_SET="displaySetModule";let j2=eTU,j5={IMPLICIT_VR_LITTLE_ENDIAN:Nl.constants.IMPLICIT_LITTLE_ENDIAN,EXPLICIT_VR_LITTLE_ENDIAN:Nl.constants.EXPLICIT_LITTLE_ENDIAN,DEFLATED_EXPLICIT_VR_LITTLE_ENDIAN:Nl.constants.DEFLATED_EXPLICIT_LITTLE_ENDIAN,EXPLICIT_VR_BIG_ENDIAN:Nl.constants.EXPLICIT_BIG_ENDIAN,RLE_LOSSLESS:"1.2.840.10008.1.2.5",MPEG2_MAIN_PROFILE_MAIN_LEVEL:"1.2.840.10008.1.2.4.100",MPEG2_MAIN_PROFILE_MAIN_LEVEL_FRAGMENTABLE:"1.2.840.10008.1.2.4.100.1",MPEG2_MAIN_PROFILE_HIGH_LEVEL:"1.2.840.10008.1.2.4.101",MPEG2_MAIN_PROFILE_HIGH_LEVEL_FRAGMENTABLE:"1.2.840.10008.1.2.4.101.1",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1:"1.2.840.10008.1.2.4.102",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE:"1.2.840.10008.1.2.4.102.1",MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1:"1.2.840.10008.1.2.4.103",MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE:"1.2.840.10008.1.2.4.103.1",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO:"1.2.840.10008.1.2.4.104",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO_FRAGMENTABLE:"1.2.840.10008.1.2.4.104.1",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO:"1.2.840.10008.1.2.4.105",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO_FRAGMENTABLE:"1.2.840.10008.1.2.4.105.1",MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2:"1.2.840.10008.1.2.4.106",MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2_FRAGMENTABLE:"1.2.840.10008.1.2.4.106.1",HEVC_H265_MAIN_PROFILE_LEVEL_5_1:"1.2.840.10008.1.2.4.107",HEVC_H265_MAIN_10_PROFILE_LEVEL_5_1:"1.2.840.10008.1.2.4.108"},j3=Rt.getLogger("metaData"),j4=[],j8=new Map,j6=new Map;function j9(e,t=0){let r;if(!j4.some(t=>t.provider===e)){for(r=0;r<j4.length&&!(j4[r].priority<=t);r++);j4.splice(r,0,{priority:t,provider:e})}}function j7(e,t,r){let n=j6.get(e);if(n)return n(t,null,r)}function Ve(e){for(let t=0;t<j4.length;t++)if(j4[t].provider===e){j4.splice(t,1);break}}function Vt(){for(;j4.length>0;)j4.pop();j8.clear(),j6.clear()}function Vr(e,t,r){if(void 0!==t)for(let n=0;n<j4.length;n++){let a=j4[n].provider(e,t,r);if(void 0!==a)return a}}function Vn(e,t,r){return Vr(e,t,r)}let Va=(e,t)=>{var r;for(let n of[e,(r=e,`${r}Add`)]){let e=j8.get(n);if(e)for(let r of e)r?.clearQuery?.(t)}},Vi=e=>{var t;for(let r of Array.from(new Set([e,(t=e,`${t}Add`)]))){let e=j8.get(r);if(e)for(let t of e)t?.clear?.()}},Vo=(e,...t)=>1===t.length?Vr(e,t[0]):t.map(t=>t&&Vr(e,t)).find(e=>void 0!==e);function Vs(e,t,r=Vr){let n={};for(let a of t)try{let t=r(a,e);if(t){let e={};for(let r in t)r in t&&(e[Vl(r)]=t[r]);Object.assign(n,e)}}catch(e){j3.error(`Error retrieving ${a} data:`,e)}return n}let Vl=e=>e.startsWith("sop")?`SOP${e.substring(3)}`:e.startsWith("voi")?`VOI${e.substring(3)}`:(e.endsWith("Id")&&(e=`${e.substring(0,e.length-2)}ID`),e.charAt(0).toUpperCase()+e.slice(1)),Vd=e=>e.startsWith("SOP")?`sop${e.substring(3)}`:e.startsWith("VOI")?`voi${e.substring(3)}`:(e.endsWith("ID")&&!e.endsWith("UID")&&(e=`${e.substring(0,e.length-2)}Id`),e.charAt(0).toLowerCase()+e.slice(1)),Vu=new Set([j5.MPEG2_MAIN_PROFILE_MAIN_LEVEL,j5.MPEG2_MAIN_PROFILE_MAIN_LEVEL_FRAGMENTABLE,j5.MPEG2_MAIN_PROFILE_HIGH_LEVEL,j5.MPEG2_MAIN_PROFILE_HIGH_LEVEL_FRAGMENTABLE,j5.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1,j5.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE,j5.MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1,j5.MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE,j5.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO,j5.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO_FRAGMENTABLE,j5.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO,j5.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO_FRAGMENTABLE,j5.MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2,j5.MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2_FRAGMENTABLE,j5.HEVC_H265_MAIN_PROFILE_LEVEL_5_1,j5.HEVC_H265_MAIN_10_PROFILE_LEVEL_5_1]);function Vc(e){return!!e&&(Array.isArray(e)?e:[e]).find(e=>Vu.has(e))}let Vh=/^[a-zA-Z]+:/;function Vp(e){if(!e)return"";let t=e.match(Vh);if(!t)return e;let r=e.substring(t[0].length);return Vh.test(r)?r:e}let Vm=Rt.getLogger("utilities.getPixelSpacingInformation"),Vf=new Set(["1.2.840.10008.5.1.4.1.1.1","1.2.840.10008.5.1.4.1.1.1.1","1.2.840.10008.5.1.4.1.1.1.1.1","1.2.840.10008.5.1.4.1.1.1.2","1.2.840.10008.5.1.4.1.1.1.2.1","1.2.840.10008.5.1.4.1.1.1.3","1.2.840.10008.5.1.4.1.1.1.3.1","1.2.840.10008.5.1.4.1.1.12.1","1.2.840.10008.5.1.4.1.1.12.1.1","1.2.840.10008.5.1.4.1.1.12.2","1.2.840.10008.5.1.4.1.1.12.2.1","1.2.840.10008.5.1.4.1.1.12.3"]);function Vg(e){let{PixelSpacing:t,ImagerPixelSpacing:r,EstimatedRadiographicMagnificationFactor:n,DistanceSourceToDetector:a,DistanceSourceToEntrance:i,DistanceSourceToPatient:o=i}=e;return n>1?n:o<a?a/o:r?.[0]>t?.[0]||void 0}function Vy(e){let{PixelSpacing:t,ImagerPixelSpacing:r,PixelSpacingCalibrationType:n}=e;if(t&&"GEOMETRY"===n)return N8(t,r)&&Vm.warn("Calibration type is geometry, but pixel spacing and imager pixel spacing identical",t,r),{PixelSpacing:t,type:j1.ERMF,isProjection:!0};if(t&&"FIDUCIAL"===n)return{PixelSpacing:t,type:j1.CALIBRATED,isProjection:!0};if(r){let n=Vg(e);return n>1?{PixelSpacing:r.map(e=>e/n),type:j1.ERMF,isProjection:!0}:!0===n?{PixelSpacing:t,type:j1.ERMF,isProjection:!0}:(n&&Vm.error("Illegal ERMF value:",n),{PixelSpacing:t||r,type:j1.PROJECTION,isProjection:!0})}return{PixelSpacing:t,type:j1.UNKNOWN,isProjection:!0}}function Vv(e){let{PixelSpacing:t,SOPClassUID:r}=e;return Vf.has(r)?Vy(e):{PixelSpacing:t,type:j1.NOT_APPLICABLE,isProjection:!1}}let Vb=new Map,Vx={add:(e,t)=>{let r=Vp(e);Vb.set(r,t),Va(j2.IMAGE_PLANE,e)},get:(e,t)=>{if("calibratedPixelSpacing"===e){let e=Vp(t);return Vb.get(e)}},clear:()=>{Vb.clear()}},Vw=Rt.getLogger("utilities.splitImageIdsBy4DTags");function VC(e,t){let r=/\/frames\/\d+/,n=/([?&])frame=\d+/;if(r.test(e))return e.replace(r,`/frames/${t}`);if(n.test(e))return e.replace(n,(e,r)=>`${r}frame=${t}`);let a=e.includes("?")?"&":"?";return`${e}${a}frame=${t}`}function Vk(e){if(!e||0===e.length)return null;let t=e[0],r=Vo("instance",t);if(!r)return null;let n=r.NumberOfFrames;if(!n||n<=1)return null;let a=r.TimeSlotVector;if(!a||!Array.isArray(a))return null;let i=r.SliceVector,o=r.NumberOfSlices;if(a.length!==n)return Vw.warn("TimeSlotVector length does not match NumberOfFrames:",a.length,"vs",n),null;if(i){if(!Array.isArray(i))return Vw.warn("SliceVector exists but is not an array. Expected length:",n),null;if(i.length!==n||i.some(e=>void 0===e))return Vw.warn("SliceVector exists but has invalid length or undefined entries. Expected length:",n,"Actual length:",i.length),null}let s=new Map;for(let e=0;e<n;e++){let t=a[e],r=i?.[e]??e;s.has(t)||s.set(t,[]),s.get(t).push({frameIndex:e,sliceIndex:r})}let l=Array.from(s.keys()).sort((e,t)=>e-t).map(e=>{let r=s.get(e);return r.sort((e,t)=>e.sliceIndex-t.sliceIndex),r.map(e=>VC(t,e.frameIndex+1))}),d=o||l[0]?.length;return l.every(e=>e.length===d)||Vw.warn("Multiframe 4D split resulted in uneven time slot groups. Expected",d,"slices per time slot."),{imageIdGroups:l,splittingTag:"TimeSlotVector"}}function VM(e,t){let r=Vo(t,e);try{return parseFloat(r)}catch{return}}function VS(e,t){var r;return NQ(r=VM(e,t))||!N0(r)?N1(r,void 0):Array.from(r,e=>N1(e,void 0))}function VI(e){let t=Vo("20011003",e);try{let{InlineBinary:e}=t;if(e){let t=atob(e),r=new ArrayBuffer(t.length),n=new DataView(r);for(let e=0;e<t.length;e++)n.setUint8(e,t.charCodeAt(e));return new Float32Array(r)[0]}return parseFloat(t)}catch{return}}function VT(e){let t=Vo("0019100c",e)||Vo("0019100C",e);try{let{InlineBinary:e}=t;return e&&(t=atob(e)),parseFloat(t)}catch{return}}function V_(e){let t=Vo("00431039",e);try{let{InlineBinary:e}=t;return e&&(t=atob(e).split("//")),parseFloat(t[0])%1e5}catch{return}}function VP(e){let t=Vo("petImageModule",e);return t?t.frameReferenceTime:0}let VE=function(e){let t=Vk(e);if(t)return t;let r=function(e){let t;if(!e||0===e.length||void 0===VS(e[0],"CardiacNumberOfImages"))return null;let r=new Map;for(let t of e){let e=Vo("StackID",t),n=VS(t,"InStackPositionNumber"),a=VS(t,"TriggerTime");if(void 0===e||void 0===n||void 0===a)return null;let i=String(e);r.has(i)||r.set(i,new Map);let o=r.get(i);o.has(n)||o.set(n,[]),o.get(n).push({imageId:t,triggerTime:a})}let n=Array.from(r.keys()).sort((e,t)=>Number(e)-Number(t));if(0===n.length)return null;let a=[];for(let e of n){let n=r.get(e),i=Array.from(n.keys()).sort((e,t)=>e-t);for(let e of i){let r=n.get(e);if(r.sort((e,t)=>e.triggerTime-t.triggerTime),void 0===t)t=r.length;else if(r.length!==t)return null}a.push({stackId:e,positions:i,framesByPosition:n})}if(!t)return null;let i=[];for(let e=0;e<t;e++){let t=[];for(let r of a)for(let n of r.positions){let a=r.framesByPosition.get(n);t.push(a[e].imageId)}i.push(t)}return{imageIdGroups:i,splittingTag:"CardiacTriggerTime"}}(e);if(r)return r;let n=function(e){let t,r=e.map(e=>{let{imagePositionPatient:t}=Vo("imagePlaneModule",e)||{};return{imageId:e,imagePositionPatient:t}});if(!r.every(e=>e.imagePositionPatient))return null;let n=(t="imagePositionPatient",r.reduce((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e),{})),a=Object.keys(n),i=n[a[0]].length;return 1!==i&&a.every(e=>n[e].length===i)?n:null}(e);if(!n)return{imageIdGroups:[e],splittingTag:null};let a=["TemporalPositionIdentifier","DiffusionBValue","TriggerTime","EchoTime","EchoNumber","PhilipsPrivateBValue","SiemensPrivateBValue","GEPrivateBValue","PetFrameReferenceTime"],i=[e=>VM(e,a[0]),e=>VM(e,a[1]),e=>VM(e,a[2]),e=>VM(e,a[3]),e=>VM(e,a[4]),VI,VT,V_,VP];for(let e=0;e<i.length;e++){let t=function(e,t){let r={},n=[],a=Object.keys(e);for(let i=0;i<a.length;i++){let o=new Set,s=e[a[i]];for(let e=0;e<s.length;e++){let n=t(s[e].imageId)||0;if(r[n]=r[n]||[],r[n].push({imageId:s[e].imageId}),o.add(n),o.size-1<e)return}if(0==i)n=Array.from(o);else if(!function(e,t){if(e.length!=t.size)return!1;for(let r=0;r<e.length;r++)if(!t.has(e[r]))return!1;return!0}(n,o))return}return r}(n,i[e]);if(t)return{imageIdGroups:Object.keys(t).map(Number.parseFloat).sort((e,t)=>e-t).map(e=>t[e].map(e=>e.imageId)),splittingTag:a[e]}}return{imageIdGroups:[e],splittingTag:null}},VD=[[j2.TRANSFER_SYNTAX,["TransferSyntaxUID","AvailableTransferSyntaxUID"]],[j2.CINE,["FrameTime","RecommendedDisplayFrameRate"]],[j2.PET_ISOTOPE,[["RadiopharmaceuticalInfo","00540016"]]],["RadiopharmaceuticalInfo",["RadiopharmaceuticalStartTime","RadiopharmaceuticalStopTime","RadionuclideTotalDose","RadionuclideHalfLife"]],[j2.PET_IMAGE,["FrameReferenceTime","ActualFrameDuration"]],[j2.PET_SERIES,["CorrectedImage","Units","DecayCorrection"]],[j2.PATIENT,["PatientID","PatientName","PatientBirthDate","PatientBirthTime"]],[j2.PATIENT_STUDY,["PatientAge","PatientSize","PatientSex","PatientWeight"]],[j2.GENERAL_STUDY,["StudyInstanceUID","StudyDescription","StudyDate","StudyTime","AccessionNumber"]],[j2.GENERAL_SERIES,["StudyInstanceUID","SeriesInstanceUID","Modality","SeriesDescription","SeriesNumber","SeriesDate","SeriesTime","AcquisitionDate","AcquisitionTime"]],["clinicalTrialModule",["ClinicalTrialSponsorName","ClinicalTrialSiteID","ClinicalTrialSiteName","ClinicalTrialSubjectID"]],[j2.SOP_COMMON,["SOPInstanceUID","SOPClassUID"]],[j2.ECG,["StudyInstanceUID","SeriesInstanceUID","SeriesDescription","SeriesNumber","SeriesDate","SeriesTime","Modality","SOPInstanceUID","SOPClassUID","WaveformAnnotationSequence"]],[j2.GENERAL_IMAGE,["SOPInstanceUID","SOPClassUID","InstanceNumber","InstanceCreationDate","InstanceCreationTime","ContentTime","LossyImageCompression","LossyImageCompressionRatio","LossyImageCompressionMethod","FrameOfReferenceUID","NumberOfFrames","PixelSpacing"]],[j2.IMAGE_PLANE,["ImagerPixelSpacing","ImageOrientationPatient","ImagePositionPatient","SpacingBetweenSlices","SliceThickness","SliceLocation"]],[j2.IMAGE_PIXEL,["SamplesPerPixel","PhotometricInterpretation","PlanarConfiguration","Rows","Columns","BitsAllocated","BitsStored","HighBit","PixelRepresentation",["SmallestPixelValue","00280106"],["LargestPixelValue","00280107"],"PixelPaddingValue","PixelPaddingRangeLimit","RedPaletteColorLookupTableDescriptor","GreenPaletteColorLookupTableDescriptor","BluePaletteColorLookupTableDescriptor","AlphaPaletteColorLookupTableDescriptor","RedPaletteColorLookupTableData","GreenPaletteColorLookupTableData","BluePaletteColorLookupTableData","AlphaPaletteColorLookupTableData","PaletteColorLookupTableUID","DistanceSourceToDetector","DistanceSourceToPatient","EstimatedRadiographicMagnificationFactor","DistanceSourceToEntrance","PixelSpacingCalibrationType","PixelSpacingCalibrationDescription","SequenceOfUltrasoundRegions"]],[j2.VOI_LUT,["WindowCenter","WindowWidth","VOILUTFunction","WindowCenterWidthExplanation"]],[j2.MODALITY_LUT,["RescaleIntercept","RescaleSlope","RescaleType"]],[j2.ULTRASOUND_ENHANCED_REGION,["SequenceOfUltrasoundRegions"]],["usRegionChild",["PhysicalDeltaX","PhysicalDeltaY","PhysicalUnitsXDirection","PhysicalUnitsYDirection","RegionLocationMinY0","RegionLocationMaxY1","RegionLocationMinX0","RegionLocationMaxX1","ReferencePixelX0","ReferencePixelY0",["ReferencePhysicalPixelValueY","0018602A"],["ReferencePhysicalPixelValueX","00186028"],"RegionSpatialFormat","RegionDataType","RegionFlags","TransducerFrequency"]],[null,["ReferencedImageSequence","ReferencedSOPClassUID","ReferencedSOPInstanceUID","ReferencedFrameNumber","SharedFunctionalGroupsSequence","PerFrameFunctionalGroupsSequence","PlanePositionSequence","AnatomicRegionSequence","PlaneOrientationSequence","PixelMeasuresSequence","PixelValueTransformationSequence","ParametricMapFrameTypeSequence","RealWorldValueMappingSequence"]]],VA=Rt.getLogger("utilities.Tags"),VO=Nl.data.DicomMetaDictionary.dictionary,VN=Nl.data.DicomMetaDictionary.nameMap,VR=new Map,VL=new Map;function Vj(e){let t=Object.prototype.hasOwnProperty.call(VN,e)?VN[e]:void 0;if(t?.tag)return t.tag.substring(1,5)+t.tag.substring(6,10)}let VV={},VF=new Map;for(let[e,t]of VD)for(let r of t){let t="string"==typeof r?r:r[0],n="string"==typeof r?void 0:r[1],a=VF.get(t);a||(a={hex:n??Vj(t),groups:[]},VF.set(t,a)),null!==e&&a.groups.push(e)}for(let[e,{hex:t,groups:r}]of VF){if(!t){VA.warn(`Tags: keyword "${e}" not found in dcmjs nameMap`);continue}!function(e,t){if(e&&t.name&&e!==t.name)throw Error(`Tag name provided and value don't match: ${e} !== ${t.name}`);t.name||=e,t.lowerName||=Vd(e),VV[e]=t;let{tag:r}=t;t.primaryGroup||=t.groups?.[0];let{groups:n}=t;if(VL.set(e,t),r&&(t.xTag=`x${r.toLowerCase()}`,t.tag=r.toUpperCase(),VL.set(t.xTag,t),VL.set(t.tag,t),!t.vr)){let e=VO[t.tag];e&&(t.vr=e.vr,t.vm=function(e){if(null==e)return null;if("number"==typeof e)return e;let t=parseInt(e,10);return String(t)===e?t:0}(e.vm))}if(n?.length)for(let r of n){let n=VR.get(r);if(!n){n=[t],VR.set(r,n);return}let a=n.findIndex(t=>t.name===e);-1===a?n.push(t):n[a]=t}}(e,function(e,...t){return{tag:e,groups:t,xTag:null,primaryGroup:null,name:null,lowerName:null,vr:null,vm:null}}(t,...r))}let{DicomMetadataListener:VB}=Nl.utilities,{pp:VW,tZ:VU,gE:Vz,Um:VH,uu:VG,UA:Vq,LL:V$,_E:VK,sM:VY,Qe:VX,xC:VZ,RZ:VJ,UX:VQ,HL:V0,U5:V1,Rm:V2}=V,{bM:V5}=V,V3=j2.FRAME_IMAGE_IDS,V4=j2.BASE_IMAGE_ID;Rt.getLogger("utilities.metadataProvider.cacheData");class V8{static setCacheDataInternal(e,t,r){let n=this.mapCacheData.get(e);n||(n=new Map,this.mapCacheData.set(e,n)),n.set(t,r),this.clearRelatedDerivedCache(e,t)}static clearRelatedDerivedCache(e,t){let r=this.secondaryTypesByBaseType.get(e);if(r?.size)for(let e of Vr(V3,t)??new Set([t]))for(let t of r){let r=this.mapCacheData.get(t);r?.delete(e)}}static registerSecondaryTypes(e,t){if(t)for(let r of Array.isArray(t)?t:[t]){let t=this.secondaryTypesByBaseType.get(r);t||(t=new Set,this.secondaryTypesByBaseType.set(r,t)),t.add(e)}}static getCacheData(e,t){return this.mapCacheData.get(e)?.get(t)}static hasCacheData(e,t){return this.mapCacheData.get(e)?.has(t)===!0}static clearCacheData(){this.mapCacheData.clear(),this.secondaryTypesByBaseType.clear(),Vi(V3),Vi(V4)}static clearTypedCacheData(e,t){let r=this.secondaryTypesByBaseType.get(e),n=this.mapCacheData.get(e);if(t){if(n?.delete(t),r?.size)for(let e of r)this.mapCacheData.get(e)?.delete(t);(e===j2.NATURALIZED||r?.size)&&(Va(V3,t),Va(V4,t));return}if(n?.clear(),r?.size)for(let e of r)this.mapCacheData.get(e)?.clear();(e===j2.NATURALIZED||r?.size)&&(Vi(V3),Vi(V4))}static fromAsyncLookup(e,t,r,n){if(n?.noCache!==!0&&n?.reCache!==!0){let r=this.getCacheData(e,t);if(void 0!==r)return r}let a=r();if(void 0!==a)return a instanceof Promise?a.then(r=>(void 0===r||n?.noCache||this.setCacheDataInternal(e,t,r),r)):(n?.noCache||this.setCacheDataInternal(e,t,a),a)}createTypeCacheProvider(e){var t;return t=e,(e,r,n,a)=>V8.fromAsyncLookup(t,r,()=>e(r,n,a),a)}clearCacheData(){V8.clearCacheData()}clearTypedCacheData(e,t){V8.clearTypedCacheData(e,t)}getCacheData(e,t){return V8.getCacheData(e,t)}hasCacheData(e,t){return V8.hasCacheData(e,t)}fromAsyncLookup(e,t,r,n){return V8.fromAsyncLookup(e,t,r,n)}}function V6(e){return(t,r,n,a)=>(n||=j7(e,r,a?.[e]),t(r,n,a))}V8.mapCacheData=new Map,V8.secondaryTypesByBaseType=new Map,new class e extends V8{static setCacheData(e,t,r){this.setCacheDataInternal(e,t,r)}setCacheData(t,r,n){e.setCacheData(t,r,n)}},V6(j2.INSTANCE),V6(j2.NATURALIZED);let{AsyncDicomReader:V9}=Nl.async;VH.getLogger("tagModules");let V7=/(\/frames\/|[&?]frameNumber=|[&?]frame=)([^/&?]*)(.*)/i;function Fe(e){let t=e.match(V7);if(!t)return;let r=e.substring(0,t.index),n=t[2];return{baseImageId:r,frameNumber:parseFloat(n),framesString:n,remaining:t[3]}}Rt.getLogger("utilities.metadataProvider.ecgFromInstance");let Ft=.001,Fr=65536,Fn=Object.freeze({params:Object.freeze(["instance","context"]),implicitScope:"instance"});function Fa(e,t){return null!=e&&("object"==typeof e||"function"==typeof e)&&Object.prototype.hasOwnProperty.call(e,t)}function Fi(e,t){return Fa(e,t)?e[t]:void 0}function Fo(e){return"__proto__"===e}function Fs(e){if("function"==typeof e)return"<function>";try{return JSON.stringify(e)??String(e)}catch{return String(e)}}class Fl extends Error{constructor(e,t,r){super(r),this.definition=e,this.path=t,this.name="RuleCompileError"}}function Fd(e,t,...r){let n=e.path?`${e.path}: `:"",a=r.length?`: ${Fs(r[0])}`:"";throw new Fl(e.definition,e.path,`Invalid ${e.definition}: ${n}${t}${a}`)}function Fu(e,t){let r=e.toLowerCase();for(let n of t)if(n&&n!==e&&n.toLowerCase()===r)return`; did you mean '${n}'?`;return""}function Fc(e,t,r){let n="number"==typeof t?`${e.path}[${t}]`:e.path?`${e.path}.${t}`:t;return{...e,path:n,extraKeys:void 0,expression:r?.expression??e.expression,call:r?.call??e.call}}let Fh=new Set(["string","number","boolean","true","scalar","literal","priority","expression"]),Fp={string:["a string",e=>"string"==typeof e],expression:["an expression string",e=>"string"==typeof e],number:["a finite number",e=>"number"==typeof e&&Number.isFinite(e)],boolean:["a boolean",e=>"boolean"==typeof e],true:["true",e=>!0===e],scalar:["a string, a finite number or a boolean",e=>"string"==typeof e||"boolean"==typeof e||"number"==typeof e&&Number.isFinite(e)],literal:["any value",()=>!0],priority:["a finite number, or null",e=>null===e||"number"==typeof e&&Number.isFinite(e)]};function Fm(e,t,r,n="value"){let[a,i]=Fp[e.kind];i(t)||Fd(r,`expected ${a}`,t),e.oneOf&&!e.oneOf.includes(t)&&Fd(r,`unknown ${n} ${Fs(t)}; allowed: ${e.oneOf.join(", ")}`)}function Ff(e,t,r){return Fd(r,`unrecognized ${e.name}; expected ${function(e,t){let r=t?.expression,n=[];for(let t of("expression"===e.string?n.push(r?`an expression string called with (${r.params.join(", ")})`:"an expression string"):"attribute"===e.string&&n.push("a name (a DICOM keyword or a context name)"),Object.values(e.forms)))n.push(function(e,t){let r=[],n=[];for(let[t,a]of Object.entries(e.keys)){if("operator"===a.role){n.push(t);continue}if("*"===t){r.push("<any key>");continue}r.push(a.optional||"modifier"===a.role?`${t}?`:t)}n.length&&r.splice(1,0,`<one of ${n.join(" | ")}>`);let a=`{ ${r.join(", ")} }`,i=e.expression??("expression"in e.keys?t:void 0);return i?`${a} called with (${i.params.join(", ")})`:a}(t,r));return(e.function&&n.push(t?.call?`a function ${t.call}`:"a function"),1===n.length)?n[0]:`${n.slice(0,-1).join(", ")}, or ${n[n.length-1]}`}(e,r)}`,t)}function Fg(e,t,r){let[n,a]=function(e,t,r){if(t&&"object"==typeof t&&!Array.isArray(t)){let r;for(let n of Object.entries(e.forms)){let{selectBy:e}=n[1];if(void 0===e)r??=n;else if(Object.prototype.hasOwnProperty.call(t,e))return n}if(r)return r}return Ff(e,t,r)}(e,t,r);return!function(e,t,r,n="key"){let a={...e.keys,...r.extraKeys},i=a["*"];for(let e of Object.keys(t))Object.prototype.hasOwnProperty.call(a,e)||i||Fd(r,`unknown ${n} '${e}'${Fu(e,Object.keys(a))}; allowed: ${Object.keys(a).join(", ")}`);let o=[],s=!1;for(let[e,i]of Object.entries(a)){var l;if("*"!==e){if("operator"===i.role&&(s=!0),!(Object.prototype.hasOwnProperty.call(t,e)&&void 0!==t[e])){i.optional||i.role||Fd(r,`missing ${n} '${e}'`,t);continue}if("operator"===i.role&&o.push(e),l=i.kind,Fh.has(l)){let n=Fc(r,e,i);if(i.list){let r=t[e];Array.isArray(r)||Fd(n,"expected an array",r),r.forEach((t,r)=>Fm(i,t,Fc(n,r),e))}else Fm(i,t[e],n,e)}}}if(s){let n=Object.entries(a).filter(([,e])=>"operator"===e.role).map(([e])=>e),i=e.selectBy?`${e.selectBy} ${Fs(t[e.selectBy])}`:"this form";o.length||Fd(r,`no operator for ${i}; expected exactly one of: ${n.join(", ")}`,t),o.length>1&&Fd(r,`more than one operator for ${i} (${o.join(", ")}); expected exactly one of: ${n.join(", ")}`,t)}for(let[e,n]of Object.entries(a))"modifier"===n.role&&void 0!==t[e]&&n.with&&!n.with.some(e=>o.includes(e))&&Fd(r,`'${e}' applies only with ${n.with.join(", ")}`,t)}(a,t,r,e.keyNoun),[n,a]}let Fy={name:"test",function:!0,keyNoun:"operator",forms:{operator:{keys:Object.fromEntries(Object.freeze(["equals","doesNotEqual","notNull","includes","doesNotInclude","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","range","contains","containsI","doesNotContain","doesNotContainI","containsAll","startsWith","endsWith"]).map(e=>[e,{kind:"literal",role:"operator"}])),description:"One operator and its operand."}}},Fv={name:"condition",function:!0,forms:{map:{keys:{"*":{kind:"matchTest"}},description:"A map of name to test. Every entry must hold. `{}` is true."}}},Fb={name:"value",string:"attribute",function:!0,forms:{template:{selectBy:"template",keys:{template:{kind:"string"}},description:"A string with `{name}` placeholders."},expression:{selectBy:"expression",keys:{expression:{kind:"expression"}},description:"An expression; the result is the value, not coerced."}}},Fx={condition:Fv,matchTest:Fy,value:Fb};function Fw(e,t){throw Error(`Invalid split rule set entry "${e}": ${t}`)}let FC=["===","!==","==","!=","<=",">=","&&","||","<",">","+","-","*","/","%","!","(",")","[","]",",",".","?",":"],Fk=e=>/[A-Za-z_$]/.test(e),FM=e=>/[A-Za-z0-9_$]/.test(e),FS=e=>e>="0"&&e<="9";class FI extends Error{constructor(e,t){super(`${e} in expression: ${t}`),this.name="ExpressionSyntaxError"}}function FT(e,t){let r=e[t];return{ch:({n:"\n",t:" ",r:"\r","\\":"\\","'":"'",'"':'"',"`":"`",$:"$"})[r]??r,next:t+1}}let F_=new Set(["__proto__","prototype","constructor"]),FP=Symbol("defined"),FE=new Map([["true",!0],["false",!1],["null",null],["undefined",void 0],["defined",FP]]),FD={"||":1,"&&":2,"==":3,"!=":3,"===":3,"!==":3,"<":4,"<=":4,">":4,">=":4,in:4,"+":5,"-":5,"*":6,"/":6,"%":6},FA=new Set(["min","max","sum","count"]),FO=new Set(["series","displaySet","displaySets"]);class FN{constructor(e,t){this.position=0,this.expression=t,this.tokens=function(e,t=e){let r=[],n=0;t:for(;n<e.length;){let a=e[n];if(/\s/.test(a)){n++;continue}if(FS(a)||"."===a&&FS(e[n+1])){let a=n;for(;a<e.length&&/[0-9.]/.test(e[a]);)a++;if("e"===e[a]||"E"===e[a]){let t=a+1;if(("+"===e[t]||"-"===e[t])&&t++,FS(e[t])){for(t++;t<e.length&&FS(e[t]);)t++;a=t}}let i=e.slice(n,a),o=Number(i);if(Number.isNaN(o))throw new FI(`Invalid number '${i}'`,t);r.push({kind:"number",value:o}),n=a;continue}if("'"===a||'"'===a){let i="",o=n+1;for(;o<e.length&&e[o]!==a;)if("\\"===e[o]){let{ch:t,next:r}=FT(e,o+1);i+=t,o=r}else i+=e[o],o++;if(o>=e.length)throw new FI("Unterminated string literal",t);r.push({kind:"string",value:i}),n=o+1;continue}if("`"===a){let{parts:a,next:i}=function(e,t,r){let n=[],a="",i=t;for(;i<e.length;){let t=e[i];if("`"===t)return a&&n.push({kind:"text",text:a}),{parts:n,next:i+1};if("\\"===t){let{ch:t,next:r}=FT(e,i+1);a+=t,i=r;continue}if("$"===t&&"{"===e[i+1]){a&&(n.push({kind:"text",text:a}),a="");let t=1,o=i+2,s="";for(;o<e.length&&t>0;){let r=e[o];if("{"===r)t++;else if("}"===r){if(0==--t)break}else if("'"===r||'"'===r)for(s+=r,o++;o<e.length&&e[o]!==r;)"\\"===e[o]&&(s+=e[o],o++),s+=e[o],o++;s+=e[o],o++}if(0!==t)throw new FI("Unterminated template interpolation",r);n.push({kind:"expr",source:s}),i=o+1;continue}a+=t,i++}throw new FI("Unterminated template literal",r)}(e,n+1,t);r.push({kind:"template",parts:a}),n=i;continue}if(Fk(a)){let t=n+1;for(;t<e.length&&FM(e[t]);)t++;r.push({kind:"ident",name:e.slice(n,t)}),n=t;continue}for(let t of FC)if(e.startsWith(t,n)){r.push({kind:"punct",value:t}),n+=t.length;continue t}throw new FI(`Unexpected character '${a}'`,t)}return r.push({kind:"end"}),r}(e,t)}peek(){return this.tokens[this.position]}next(){return this.tokens[this.position++]}isPunct(e){let t=this.peek();return"punct"===t.kind&&t.value===e}isIdent(e){let t=this.peek();return"ident"===t.kind&&t.name===e}expectPunct(e){if(!this.isPunct(e))throw new FI(`Expected '${e}'`,this.expression);this.next()}fail(e){throw new FI(e,this.expression)}parse(){let e=this.parseConditional();return"end"!==this.peek().kind&&this.fail("Unexpected trailing input"),e}parseSubExpression(){return this.parseConditional()}parseConditional(){let e=this.parseBinary(0);if(!this.isPunct("?"))return e;this.next();let t=this.parseConditional();return this.expectPunct(":"),{type:"conditional",test:e,consequent:t,alternate:this.parseConditional()}}parseBinary(e){let t=this.parseUnary();for(;;){let r,n=this.peek();if("punct"===n.kind&&FD[n.value]?r=n.value:"ident"===n.kind&&"in"===n.name&&(r="in"),!r)return t;let a=FD[r];if(a<=e)return t;this.next();let i=this.parseBinary(a);t="&&"===r||"||"===r?{type:"logical",operator:r,left:t,right:i}:{type:"binary",operator:r,left:t,right:i}}}parseUnary(){let e=this.peek();return"punct"===e.kind&&("!"===e.value||"-"===e.value||"+"===e.value)?(this.next(),{type:"unary",operator:e.value,argument:this.parseUnary()}):this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;){if(this.isPunct(".")){this.next();let t=this.next();"ident"!==t.kind&&this.fail("Expected a property name after '.'"),F_.has(t.name)&&this.fail(`Access to '${t.name}' is not allowed`),e={type:"member",object:e,property:t.name};continue}if(this.isPunct("[")){this.next();let t=this.parseSubExpression();this.expectPunct("]"),e={type:"index",object:e,index:t};continue}if(this.isPunct("(")){let t=function(e){if("member"===e.type&&FA.has(e.property)&&"member"===e.object.type&&"instances"===e.object.property&&"identifier"===e.object.object.type&&FO.has(e.object.object.name))return e.object.object.name}(e);"identifier"===e.type||t||this.fail("Only whitelisted helper functions may be called");let r="identifier"===e.type?e.name:e.property;this.next();let n=[];if(!this.isPunct(")"))for(;;){if(n.push(this.parseSubExpression()),this.isPunct(",")){this.next();continue}break}this.expectPunct(")"),e=t?{type:"call",callee:r,args:n,receiver:t}:{type:"call",callee:r,args:n};continue}return e}}parsePrimary(){let e=this.next();if("number"===e.kind||"string"===e.kind)return{type:"literal",value:e.value};if("template"===e.kind)return{type:"template",parts:e.parts.map(e=>"text"===e.kind?e:{kind:"expr",node:FR(e.source,this.expression)})};if("ident"===e.kind)return FE.has(e.name)?{type:"literal",value:FE.get(e.name)}:("in"===e.name&&this.fail("Unexpected 'in'"),F_.has(e.name)&&this.fail(`Access to '${e.name}' is not allowed`),{type:"identifier",name:e.name});if("punct"===e.kind){if("("===e.value){let e=this.parseSubExpression();return this.expectPunct(")"),e}if("["===e.value){let e=[];if(!this.isPunct("]"))for(;;){if(e.push(this.parseSubExpression()),this.isPunct(",")){this.next();continue}break}return this.expectPunct("]"),{type:"array",elements:e}}}this.fail("Unexpected token")}}function FR(e,t=e){return new FN(e,t).parse()}function FL(e){return void 0===e}function Fj(e){return null===e||""===e||Array.isArray(e)&&e.every(e=>FV(e))}function FV(e){return FL(e)||Fj(e)}function FF(e,t){if(FV(e)||FV(t))return FW(e)===FW(t);let r=Array.isArray(e),n=Array.isArray(t);return r&&n?e.length===t.length&&e.every((e,r)=>FB(e,t[r])):r?1===e.length&&FB(e[0],t):n?1===t.length&&FB(e,t[0]):FB(e,t)}function FB(e,t){if(FV(e)||FV(t))return FW(e)===FW(t);if(e===t)return!0;if("object"==typeof e||"object"==typeof t)return!1;if("number"==typeof e||"number"==typeof t){let r=N2(e),n=N2(t);if(void 0!==r&&void 0!==n)return r===n}return String(e)===String(t)}function FW(e){return FL(e)?"absent":null===e?"null":""===e?"text":Fj(e)?"array":void 0}function FU(e){return(t,r)=>{let n=N2(t),a=N2(r);return void 0!==n&&void 0!==a&&e(n,a)}}function Fz(e){return!FV(e)&&!!e}let FH=e=>"string"==typeof e||"boolean"==typeof e||"number"==typeof e&&Number.isFinite(e),FG=e=>"number"==typeof e&&Number.isFinite(e),Fq=e=>FH(e)||Array.isArray(e)&&e.length>0&&e.every(FH),F$=e=>"string"==typeof e||Array.isArray(e)&&e.length>0&&e.every(e=>"string"==typeof e),FK=e=>FV(e)?[]:NZ(e).filter(e=>!FV(e));function FY(e){return null===e?e=>FV(e):t=>FF(t,e)}let FX=new WeakMap;function FZ(e){if(!Array.isArray(e)||e.length<9)return null;let t=FX.get(e);return void 0===t&&(t=e.every(e=>"string"==typeof e&&e)?new Set(e):null,FX.set(e,t)),t}function FJ(e,t){let r=FZ(t),n=r?t:FK(t);return e.some(e=>r&&("string"==typeof e||"boolean"==typeof e)?r.has(String(e)):n.some(t=>FF(e,t)))}function FQ(e){let t=[...NZ(e)];return FZ(t),e=>FJ(FK(e),t)}function F0(e,t){return r=>{let n=((e,t=!1)=>NZ(e).map(e=>t?String(e).toLowerCase():String(e)))(r,e);return r=>((e,t=!1)=>FK(e).map(e=>t?String(e).toLowerCase():String(e)))(r,e).some(e=>n.some(r=>t(e,r)))}}let F1=e=>t=>{let r=e(t);return(e,t,n)=>!r(e,t,n)};function F2(e){let t=FU(e);return e=>r=>t(r,e)}let F5=F0(!1,(e,t)=>e.includes(t)),F3=F0(!0,(e,t)=>e.includes(t)),F4=F0(!1,(e,t)=>e.startsWith(t)),F8=F0(!1,(e,t)=>e.endsWith(t)),F6=Object.freeze({includes:(e,t)=>FJ(FK(t),e),contains:(e,t)=>F5(t)(e),startsWith:(e,t)=>F4(t)(e),endsWith:(e,t)=>F8(t)(e)}),F9=Object.freeze({equals:{operand:"a scalar, a non-empty array of scalars, or null",accepts:e=>null===e||Fq(e),compile:FY},doesNotEqual:{operand:"a scalar, a non-empty array of scalars, or null",accepts:e=>null===e||Fq(e),compile:F1(FY)},notNull:{operand:"a boolean",accepts:e=>"boolean"==typeof e,compile:e=>e?e=>!FV(e):e=>FV(e)},includes:{operand:"a scalar, or a non-empty array of scalars",accepts:Fq,compile:FQ},doesNotInclude:{operand:"a scalar, or a non-empty array of scalars",accepts:Fq,compile:F1(FQ)},greaterThan:{operand:"a finite number",accepts:FG,compile:F2((e,t)=>e>t)},greaterThanOrEqual:{operand:"a finite number",accepts:FG,compile:F2((e,t)=>e>=t)},lessThan:{operand:"a finite number",accepts:FG,compile:F2((e,t)=>e<t)},lessThanOrEqual:{operand:"a finite number",accepts:FG,compile:F2((e,t)=>e<=t)},range:{operand:"an array of two finite numbers",accepts:e=>Array.isArray(e)&&2===e.length&&e.every(FG),compile:e=>{let[t,r]=e,n=Math.min(t,r),a=Math.max(t,r);return e=>{let t=N2(e);return void 0!==t&&t>=n&&t<=a}}},contains:{operand:"a string, or a non-empty array of strings",accepts:F$,compile:F5},containsI:{operand:"a string, or a non-empty array of strings",accepts:F$,compile:F3},doesNotContain:{operand:"a string, or a non-empty array of strings",accepts:F$,compile:F1(F5)},doesNotContainI:{operand:"a string, or a non-empty array of strings",accepts:F$,compile:F1(F3)},containsAll:{operand:"a scalar, or a non-empty array of scalars",accepts:Fq,compile:e=>{let t=NZ(e);return e=>{let r=FK(e);return r.length>0&&t.every(e=>r.some(t=>FF(t,e)))}}},startsWith:{operand:"a string, or a non-empty array of strings",accepts:F$,compile:F4},endsWith:{operand:"a string, or a non-empty array of strings",accepts:F$,compile:F8}});function F7(e,t){if("function"==typeof e)return e;if(null===e)return FY(e);if(FH(e))return FQ(e);if(Array.isArray(e))return e.length&&e.every(FH)?FQ(e):Fd(t,"an array test must hold one or more scalars",e);if(!e||"object"!=typeof e)return Fd(t,"expected a scalar, an array of scalars, null, an object with one operator, or a function",e);Fg(Fy,e,t);let[r,n]=Object.entries(e)[0],a=F9[r];return a.accepts(n)?a.compile(n):Fd(t,`the operand of ${r} must be ${a.operand}`,e)}function Be(e,t){if(null!=e&&("string"==typeof t||"number"==typeof t)&&!("string"==typeof t&&F_.has(t)))return e[t]}function Bt(e){return t=>{let r=N2(t);if(void 0===r)return;let n=e(r);return Number.isFinite(n)?n:void 0}}function Br(e){return e.map(e=>N2(e)).filter(e=>void 0!==e)}let Bn={includes:F6.includes,contains:F6.contains,startsWith:F6.startsWith,endsWith:F6.endsWith,lower:e=>FV(e)?void 0:String(NJ(e)).toLowerCase(),abs:Bt(Math.abs),min:(...e)=>{let t=Br(e);return t.length?Math.min(...t):void 0},max:(...e)=>{let t=Br(e);return t.length?Math.max(...t):void 0},round:Bt(Math.round),floor:Bt(Math.floor),ceil:Bt(Math.ceil),Number:e=>N2(e),String:e=>FV(e)?"":String(e)},Ba=new Set(["min","max","sum","count"]);function Bi(e){return void 0!==e.receiver}function Bo(e,t={}){let r=[],n=(e,a)=>{switch(e.type){case"literal":return;case"identifier":r.push({name:e.name,inAggregate:a});return;case"member":if("identifier"===e.object.type)return void r.push({name:e.object.name,field:e.property,inAggregate:a});n(e.object,a);return;case"index":"identifier"===e.object.type?r.push({name:e.object.name,indexed:!0,inAggregate:a}):n(e.object,a),n(e.index,a);return;case"call":{let r=a||!!t.aggregates&&Bi(e);e.args.forEach(e=>n(e,r));return}case"unary":n(e.argument,a);return;case"binary":case"logical":n(e.left,a),n(e.right,a);return;case"conditional":n(e.test,a),n(e.consequent,a),n(e.alternate,a);return;case"array":e.elements.forEach(e=>n(e,a));return;case"template":e.parts.forEach(e=>{"expr"===e.kind&&n(e.node,a)});return}};return n(e,!1),r}let Bs={"<":FU((e,t)=>e<t),"<=":FU((e,t)=>e<=t),">":FU((e,t)=>e>t),">=":FU((e,t)=>e>=t)};function Bl(e){return(t,r)=>{let n=N2(t),a=N2(r);if(void 0===n||void 0===a)return;let i=e(n,a);return Number.isFinite(i)?i:void 0}}function Bd(e){return"template"===e.type||"literal"===e.type&&"string"==typeof e.value&&void 0===N2(e.value)}let Bu={"+":function(e,t){let r=NJ(e);if("string"==typeof r)return r+(FV(t)?"":String(NJ(t)));if(FV(e)||FV(t))return;let n=N2(e),a=N2(t);if(void 0===n||void 0===a)throw TypeError(`'+' adds numbers when the left side is not text, and ${JSON.stringify(void 0===n?e:t)} is not a number; put the text first, or use a template`);let i=n+a;return Number.isFinite(i)?i:void 0},"-":Bl((e,t)=>e-t),"*":Bl((e,t)=>e*t),"/":Bl((e,t)=>e/t),"%":Bl((e,t)=>e%t)};function Bc(e){if("literal"===e.type){if(e.value===FP)return e=>!FV(e);if(FL(e.value))return FL;if(Fj(e.value))return FV}}let Bh="safe function definition",Bp=(e,t,r)=>void 0===r?t=>Fi(t,e):t=>Fi(Fi(t,e),r),Bm={condition:(e,t)=>Bv(e,t),matchTest:(e,t)=>F7(e,t),value:(e,t)=>(function(e,t){if("function"==typeof e)return e;if("string"==typeof e)return Bg(e,t);if(!e||"object"!=typeof e||Array.isArray(e))return Ff(Fb,e,t);let[r]=Fg(Fb,e,t);if("template"===r)return function(e,t=Bf()){let r=Bb(e,t).map(e=>"literal"in e?()=>e.literal:Bg(e.name,t,e.field));return(e,t)=>r.map(r=>{let n=r(e,t);return FV(n)?"":String(n)}).join("")}(e.template,Fc(t,"template"));let n=By(e.expression,Fc(t,"expression"));return(e,t)=>n(e,t)})(e,t)};function Bf(e={},t=Fx,r=Bm){return{path:e.path??"",definition:e.definition??Bh,schema:t,compilers:r,readName:e.readName??Bp,expression:e.expression??Fn,call:e.call}}function Bg(e,t,r){return(t.readName??Bp)(e,t,r)}function By(e,t,r=t.expression??Fn){try{return function(e,t={}){let r=t.params??["instance","context"],{implicitScope:n=!0,receivers:a,unavailableReceivers:i}=t;for(let[t,n]of Object.entries(a??{}))if(!r.includes(n))throw new FI(`the list '${n}' of the receiver '${t}' is not one of the parameters (${r.join(", ")})`,e);let o=-1;if(!0===n)o=0;else if("string"==typeof n&&-1===(o=r.indexOf(n)))throw new FI(`implicitScope '${n}' is not one of the parameters (${r.join(", ")})`,e);let s={expression:e,receivers:a,unavailable:i},l=FR(e);-1===o&&function(e,t,r){let n=new Set(t);for(let a of Bo(e,{aggregates:!!r.receivers}))if(!a.inAggregate&&!n.has(a.name))throw new FI(`'${a.name}' is not a parameter, and this expression has no implicit scope; it can read only (${t.join(", ")})`,r.expression)}(l,r,s);let d=function e(t,r){let{expression:n}=r;switch(t.type){case"literal":{let{value:e}=t;if(e===FP)throw new FI("'defined' is a literal for '== defined' and '!= defined' only",n);return()=>e}case"identifier":{let{name:e}=t;return t=>(function(e,t){if(Object.prototype.hasOwnProperty.call(t.params,e))return t.params[e];for(let r=t.implicit.length-1;r>=0;r--){let n=t.implicit[r];if(null!=n&&"object"==typeof n&&e in n)return Be(n,e)}})(e,t)}case"member":{let n=e(t.object,r),{property:a}=t;return e=>Be(n(e),a)}case"index":{let n=e(t.object,r),a=e(t.index,r);return e=>Be(n(e),a(e))}case"array":{let n=t.elements.map(t=>e(t,r));if(t.elements.every(e=>"literal"===e.type)){let e=t.elements.map(e=>e.value);return()=>e}return e=>n.map(t=>t(e))}case"template":{let n=t.parts.map(t=>"text"===t.kind?()=>t.text:e(t.node,r));return e=>n.map(t=>{let r=t(e);return FV(r)?"":String(r)}).join("")}case"unary":{let n=e(t.argument,r);switch(t.operator){case"!":return e=>!Fz(n(e));case"-":{let e=Bt(e=>-e);return t=>e(n(t))}case"+":return e=>N2(n(e))}break}case"logical":{let n=e(t.left,r),a=e(t.right,r);return"&&"===t.operator?e=>Fz(n(e))&&Fz(a(e)):e=>Fz(n(e))||Fz(a(e))}case"binary":{if("=="===t.operator||"!="===t.operator)return function(t,r){let n="!="===t.operator;for(let e of[t.left,t.right])if("array"===e.type&&!e.elements.length)throw new FI(`'${t.operator} []' accepts no value; give one or more values, or use '${t.operator} null' to test for no value`,r.expression);for(let[e,n]of[[t.left,t.right],[t.right,t.left]])if("array"===e.type&&e.elements.length>1){let a="identifier"===n.type?n.name:"X";throw new FI(`'${t.operator}' with an array of ${e.elements.length} values compares the whole value; to test that a value is one of a list, use ${"!="===t.operator?`!(${a} in [...])`:`${a} in [...]`} or includes(...), e.g. Modality in ['MR', 'CT']`,r.expression)}let a=Bc(t.right),i=Bc(t.left);if(a||i){let o=a??i,s=e(a?t.left:t.right,r);return n?e=>!o(s(e)):e=>o(s(e))}let o=e(t.left,r),s=e(t.right,r);return n?e=>!FF(o(e),s(e)):e=>FF(o(e),s(e))}(t,r);if("==="===t.operator||"!=="===t.operator)throw new FI(`'${t.operator}' is not allowed; use '${"==="===t.operator?"==":"!="}', the one equality of the rule language`,n);if(Bu[t.operator]&&"+"!==t.operator){let e=[t.left,t.right].find(Bd);if(e)throw new FI(`'${t.operator}' works on numbers only, and ${"template"===e.type?"a template literal":`'${String(e.value)}'`} is not a number`,n)}let a=e(t.left,r),i=e(t.right,r),o=Bs[t.operator];if(o)return e=>o(a(e),i(e));let s=Bu[t.operator];if(s)return e=>s(a(e),i(e));if("in"===t.operator)return e=>F6.includes(i(e),a(e));throw new FI(`Unknown operator '${t.operator}'`,n)}case"conditional":{let n=e(t.test,r),a=e(t.consequent,r),i=e(t.alternate,r);return e=>Fz(n(e))?a(e):i(e)}case"call":{let{callee:a}=t;if(Bi(t)){let{receiver:i}=t;if(!Object.prototype.hasOwnProperty.call(r.receivers??{},i))throw new FI(r.unavailable?.[i]??`${i}.instances.${a}() is not available here`,n);if(r.inAggregate)throw new FI(`${i}.instances.${a}() is not allowed inside the argument of another aggregate; put the inner aggregate in its own context entry, and read that name`,n);let o=t.args.length;if("count"===a?o>1:1!==o)throw new FI(`${i}.instances.${a}() takes ${"count"===a?"zero or one argument":"one argument"}`,n);return function(t,r){let{callee:n}=t,a=r.receivers[t.receiver],i=t.args[0]?e(t.args[0],{...r,inAggregate:!0}):void 0;return e=>{let t=e.params[a],r=Array.isArray(t)?t:[];if(!i)return r.length;let o=r.map(t=>{e.implicit.push(t);try{return i(e)}finally{e.implicit.pop()}});if("count"===n)return o.filter(e=>!FV(e)&&!1!==e).length;let s=Br(o);return"sum"===n?s.reduce((e,t)=>e+t,0):s.length?"min"===n?Math.min(...s):Math.max(...s):void 0}}(t,r)}if(void 0===t.receiver&&Ba.has(t.callee)&&("min"!==t.callee&&"max"!==t.callee||1===t.args.length)){let e=Object.keys(r.receivers??{}).map(e=>`${e}.instances.${a}(...)`);throw new FI(e.length?`${a}(...) needs a receiver; use ${e.join(" or ")}`:`${a}(...) is not available here: this place has no list of instances`,n)}let i=Object.prototype.hasOwnProperty.call(Bn,a)?Bn[a]:void 0;if(!i)throw new FI(`'${a}' is not a whitelisted helper function`,n);let o=t.args.map(t=>e(t,r));return e=>i(...o.map(t=>t(e)))}}throw new FI("Unsupported expression node",n)}(l,s),u=!1,c=(...t)=>{let n=Object.create(null);r.forEach((e,r)=>{n[e]=t[r]});let a={params:n,implicit:-1===o?[]:[t[o]]};try{return d(a)}catch(t){if(t instanceof Fl)throw t;u||(u=!0,console.warn(`Safe function expression failed at runtime: ${e}`,t));return}};return c.expressionSource=e,c}(e,{params:r.params,implicitScope:r.implicitScope,receivers:r.receivers,unavailableReceivers:r.unavailableReceivers})}catch(e){return Fd(t,e.message)}}function Bv(e,t){if("function"==typeof e)return e;if(!e||"object"!=typeof e||Array.isArray(e))return Ff(Fv,e,t);let r=Object.entries(e).map(([r,n])=>{let a=Fc(t,r);return Fo(r)&&Fd(a,`the name "${r}" is not allowed`,e),{read:Bg(r,a),test:F7(n,a)}});return(e,t)=>r.every(({read:r,test:n})=>n(r(e,t),e,t))}function Bb(e,t={path:"",definition:Bh}){"string"!=typeof e&&Fd(t,"template must be a string",e);let r=[],n="";for(let a=0;a<e.length;a++){let i=e[a];if("\\"===i&&("{"===e[a+1]||"}"===e[a+1])){n+=e[a+1],a++;continue}if("{"!==i){n+=i;continue}let o=e.indexOf("}",a+1);-1===o&&Fd(t,'template has an unclosed "{"',e);let s=e.slice(a+1,o).trim();s||Fd(t,'template has an empty "{}" placeholder',e);let[l,d,...u]=s.split(".");(!l||""===d||u.length)&&Fd(t,`template placeholder "{${s}}" must be a name, or a name and one field`,e),n&&(r.push({literal:n}),n=""),r.push(void 0===d?{name:l}:{name:l,field:d}),a=o}return n&&r.push({literal:n}),r}function Bx(e){let t=e.SOPInstanceUID??e.imageId;return void 0===t?void 0:String(t)}function Bw(e,t){let r=Bx(e)??"",n=Bx(t)??"";return r<n?-1:+(r>n)}function BC(e,t,r){var n=Fi(e,t);if(NQ(n)||!N0(n))return;let a=Array.from(n,e=>N1(e));return a.length===r&&a.every(e=>void 0!==e)?a:void 0}let Bk=(e,t)=>Math.round(e/t)*t;function BM(e,t,r=!1){let n=0,a=e.length;for(;n<a;){let i=n+a>>1;e[i]<t||r&&e[i]===t?n=i+1:a=i}return n}function BS(e,t){let r=null==t?"":String(t).replace(/:/g,"").trim(),n=null==e?"":String(e).replace(/-/g,"").trim(),a=/^(\d{2})(\d{2})?(\d{2})?(\.\d+)?/.exec(r);if(!a)return;let[,i,o="0",s="0",l=""]=a,d=3600*Number(i)+60*Number(o)+Number(s)+Number(`0${l}`),u=/^(\d{4})(\d{2})(\d{2})$/.exec(n);if(!u)return d;let[,c,h,p]=u;return Date.UTC(Number(c),Number(h)-1,Number(p))/1e3+d}let BI=Object.freeze({planeGeometry:Object.freeze({compute:(e,{args:t})=>{let r=N2(Fi(t,"tolerance"))??.1,n={regularCount:0,irregularCount:0,positions:0,complete:!1,duplicates:!1,distance:{},index:{}},a=[];for(let t of[...e].sort(Bw)){let e=Bx(t),r=BC(t,"ImagePositionPatient",3),i=BC(t,"ImageOrientationPatient",6);if(void 0===e||!r||!i){n.irregularCount++;continue}a.push({key:e,position:r,orientation:i,orientationKey:i.map(e=>Bk(e,.001).toFixed(3)).join()})}let i=new Map;for(let{orientationKey:e}of a)i.set(e,(i.get(e)??0)+1);let[o]=[...i.entries()].sort(([e,t],[r,n])=>n-t||(e<r?-1:+(e>r)));if(!o)return n;let s=a.filter(e=>e.orientationKey===o[0]);n.irregularCount+=a.length-s.length;let[l,d,u,c,h,p]=s[0].orientation,m=R9.vec3.cross(R9.vec3.create(),R9.vec3.fromValues(l,d,u),R9.vec3.fromValues(c,h,p));R9.vec3.normalize(m,m),n.normal=Array.from(m);let f=s.map(e=>({...e,d:R9.vec3.dot(m,e.position)})),g=[];for(let e of f.map(e=>e.d).sort((e,t)=>e-t))(!g.length||e-g[g.length-1]>=.01)&&g.push(Bk(e,.001));let y=new Map;for(let e=1;e<g.length;e++){let t=Bk(g[e]-g[e-1],.01);y.set(t,(y.get(t)??0)+1)}let[v]=[...y.entries()].sort(([e,t],[r,n])=>n-t||e-r),b=v?.[0];if(!b)return n.irregularCount+=s.length,n;n.spacing=b;let x=(e,t)=>{let n=(t-e)/b;return Math.abs(n-Math.round(n))>r},w=function(e,t,r,n){let a,i=e.length,o=(e,t,r,a)=>{let i=0;for(let o=t;o<r;o++)i+=+!n(e,a[o]);return i};if(r>=.5)return e[0];if(r+1e-6>=.5)a=t=>o(e[t],0,i,e);else{let n=r=>{let n=(r-e[0])/t;return n-Math.floor(n)},i=e.map(e=>[n(e),e]).sort(([e],[t])=>e-t),s=[],l=[];for(let e of[-1,0,1])for(let[t,r]of i)s.push(t+e),l.push(r);a=t=>{let a=e[t],i=n(a),d=BM(s,i-r-1e-6),u=BM(s,i+r+1e-6,!0),c=BM(s,i-r+1e-6),h=BM(s,i+r-1e-6,!0);return c>=h?o(a,d,u,l):h-c+o(a,d,c,l)+o(a,h,u,l)}}let s=e[0],l=-1;for(let t=0;t<i;t++){let r=a(t);r>l&&(l=r,s=e[t])}return s}(g,b,r,x),C=f.filter(({d:e})=>!x(w,e));n.irregularCount+=f.length-C.length,n.regularCount=C.length;let k=C.reduce((e,t)=>t.d<e.d?t:e);n.origin=[...k.position];let M=new Map;for(let{key:e,d:t}of f)n.distance[e]=t-k.d;for(let{key:e,d:t}of C){let r=Math.round((t-k.d)/b);n.index[e]=r,M.set(r,(M.get(r)??0)+1)}return n.positions=M.size,n.complete=Math.max(...M.keys())===M.size-1,n.duplicates=[...M.values()].some(e=>e>1),n},fields:Object.freeze({normal:"series",origin:"series",spacing:"series",regularCount:"series",irregularCount:"series",positions:"series",complete:"series",duplicates:"series",distance:"instance",index:"instance"})}),timeClusters:Object.freeze({compute:(e,{args:t})=>{let r,n,a=N2(Fi(t,"maxGap"))??30,i={time:{},start:{},clusters:0,untimedCount:0},o=[];for(let t of e){let e=Bx(t),r=function(e){let t=Fi(e,"AcquisitionDateTime");if(null!=t&&String(t).length>8){let e=String(t);return BS(e.slice(0,8),e.slice(8))}for(let[t,r]of[["AcquisitionDate","AcquisitionTime"],["ContentDate","ContentTime"]]){let n=BS(Fi(e,t),Fi(e,r));if(void 0!==n)return n}}(t);if(void 0===e||void 0===r){i.untimedCount++;continue}o.push({key:e,seconds:r}),i.time[e]=r}for(let{key:e,seconds:t}of(o.sort((e,t)=>e.seconds-t.seconds||(e.key<t.key?-1:+(e.key>t.key))),o))(void 0===n||t-n>a)&&(r=t,i.clusters++),i.start[e]=r,n=t;return i.first=o[0]?.seconds,i},fields:Object.freeze({time:"instance",start:"instance",first:"series",clusters:"series",untimedCount:"series"})}),revisionChains:Object.freeze({compute:e=>{let t=e.map(Bx),r=new Map;t.forEach((e,t)=>void 0!==e&&r.set(e,t));let n=e.map((t,n)=>(function(e){let t=[],r=e=>null==e?[]:NZ(e);for(let n of r(Fi(e,"PredecessorDocumentsSequence")))for(let e of r(Fi(n,"ReferencedSeriesSequence")))for(let n of r(Fi(e,"ReferencedSOPSequence"))){let e=Fi(n,"ReferencedSOPInstanceUID");"string"==typeof e&&e&&t.push(e)}return t})(t).map(e=>r.get(e)).filter(r=>void 0!==r&&r!==n&&e[r].SeriesInstanceUID===t.SeriesInstanceUID)),a=new Set(n.flat()),i=e.map(()=>void 0);e.forEach((e,t)=>{if(a.has(t))return;let r=[t];for(;r.length;){let e=r.pop();void 0===i[e]&&(i[e]=t,r.push(...n[e]))}});let o={active:{}};return t.forEach((e,r)=>{let n=t[i[r]??r];void 0!==e&&void 0!==n&&(o.active[e]=n)}),o},fields:Object.freeze({active:"instance"})})}),BT=[...Vu],B_=Object.freeze(["splitNumber","sopClassUids"]),BP=function e(t){if(t&&"object"==typeof t&&!Object.isFrozen(t))for(let r of(Object.freeze(t),Object.values(t)))e(r);return t}({rule:{name:"rule",keyNoun:"field",forms:{rule:{keys:{id:{kind:"string",optional:!0,description:"The rule id. Optional: the key of the rule in the rule set is the id. When present it must equal that key."},groupId:{kind:"string",optional:!0,description:"The group of rules this rule belongs to, for a reader that must recognize display sets from several related rules (for example every mammography rule). Defaults to the rule id."},priority:{kind:"priority",description:"Evaluation order: ascending, first match wins. null excludes the rule."},description:{kind:"string",optional:!0,description:"Human-readable explanation. Not compiled."},viewportTypes:{kind:"string",list:!0,optional:!0,description:"Viewport types for the host. CS3D copies them to the display set unchanged, and does not read them."},handler:{kind:"string",optional:!0,description:"The generic handler name of the display sets, e.g. segmentation. Any string; the host decides what an unknown name does."},context:{kind:"contextEntry",record:!0,optional:!0,description:"Context entries for this rule only. An entry replaces the global entry of the same name, also inside the global entries that the rule reads, or defines a new name."},matches:{kind:"condition",optional:!0,function:!0,call:"(instance, context) => boolean",description:"Which instances this rule claims: a map of name to test, and every entry must hold. Omit for a catch-all rule."},groupBy:{kind:"name",list:!0,optional:!0,call:"(instance, context) => value",description:"Names (or functions) whose values must all be equal for two instances to form one group. Defaults to SeriesInstanceUID."},sortBy:{kind:"sortKey",list:!0,optional:!0,call:"(a, b, context) => number",description:'The order of the instances in a display set: names in ascending order, named sort functions, or functions. A result of 0 or NaN is "no opinion": the next entry decides.'},attributes:{kind:"attributeValue",record:!0,optional:!0,function:!0,call:"(attributes, options) => Record<string, unknown>",description:"Attributes of the produced display sets, keyed by attribute name."}}}}},contextEntry:{name:"context entry",string:"expression",function:!0,forms:{declaration:{selectBy:"attribute",keys:{attribute:{kind:"string"},vr:{kind:"string",optional:!0},vm:{kind:"string",optional:!0}},description:"Reads one attribute of the instance that the DICOM dictionary does not hold: a private tag as 8-digit hex, a vendor attribute, or a synthetic attribute such as imageId. vr and vm are recorded only."},template:{selectBy:"template",keys:{template:{kind:"string"}},description:"Text: each {name} gives the value of a name or a path."},group:{selectBy:"function",keys:{function:{kind:"literal",description:"The name of a series function (planeGeometry, timeClusters, or one of options.seriesFunctions), or in code a function."},args:{kind:"literal",optional:!0,description:"The arguments of the series function. Each value is a fixed value, or an expression with one value for the series."}},description:"One call of a series function over the series. A rule reads a result field by path, e.g. timeClusters.start. In sortBy and attributes, displaySet.<name> runs it over the display set."}}},condition:Fv,matchTest:Fy,name:{name:"name",string:"attribute",function:!0,forms:{}},sortKey:{name:"sort entry",string:"attribute",function:!0,forms:{sortFunction:{selectBy:"sortFunction",keys:{sortFunction:{kind:"string",description:"The name of a sort function in options.sortFunctions."}},description:"A named sort function, called (a, b, context) => number."}}},attributeValue:{...Fb,name:"attribute value",forms:{template:Fb.forms.template,expression:{...Fb.forms.expression,description:"An expression over the display set: displaySet.instances.max(x) (and min, sum, count) runs over its instances, series.instances.max(x) over the series, and a DICOM keyword reads its first instance."}}}}),BE=Rt.getLogger("displayset","displaySetContext"),BD="displaySetContext",BA={timeClustersMaxGap:30,timeClusters:{function:"timeClusters",args:{maxGap:"timeClustersMaxGap"}},longTimeClusters:{function:"timeClusters",args:{maxGap:60}},sweepCount:"timeClusters.clusters",sweepStart:"timeClusters.start",acquisitionSeconds:"timeClusters.time",sweepOffset:"round(sweepStart - timeClusters.first)",planeGeometryTolerance:.1,planeGeometry:{function:"planeGeometry",args:{tolerance:"planeGeometryTolerance"}},sliceSpacing:"planeGeometry.spacing",sliceIndex:"planeGeometry.index",sliceDistance:"planeGeometry.distance",revisionChains:{function:"revisionChains"},revisionChainUid:"revisionChains.active",isActiveRevision:"SOPInstanceUID == revisionChainUid",seriesInstanceCount:"series.instances.count()",isMultiFrame:"NumberOfFrames > 1",imageId:{attribute:"imageId"},imageSopClassUids:["1.2.840.10008.5.1.4.1.1.1","1.2.840.10008.5.1.4.1.1.1.1","1.2.840.10008.5.1.4.1.1.1.1.1","1.2.840.10008.5.1.4.1.1.1.2","1.2.840.10008.5.1.4.1.1.1.2.1","1.2.840.10008.5.1.4.1.1.1.3","1.2.840.10008.5.1.4.1.1.1.3.1","1.2.840.10008.5.1.4.1.1.2","1.2.840.10008.5.1.4.1.1.2.1","1.2.840.10008.5.1.4.1.1.2.2","1.2.840.10008.5.1.4.1.1.3.1","1.2.840.10008.5.1.4.1.1.4","1.2.840.10008.5.1.4.1.1.4.1","1.2.840.10008.5.1.4.1.1.4.3","1.2.840.10008.5.1.4.1.1.4.4","1.2.840.10008.5.1.4.1.1.6.1","1.2.840.10008.5.1.4.1.1.6.2","1.2.840.10008.5.1.4.1.1.7","1.2.840.10008.5.1.4.1.1.7.1","1.2.840.10008.5.1.4.1.1.7.2","1.2.840.10008.5.1.4.1.1.7.3","1.2.840.10008.5.1.4.1.1.7.4","1.2.840.10008.5.1.4.1.1.12.1","1.2.840.10008.5.1.4.1.1.12.1.1","1.2.840.10008.5.1.4.1.1.12.2","1.2.840.10008.5.1.4.1.1.12.2.1","1.2.840.10008.5.1.4.1.1.13.1.1","1.2.840.10008.5.1.4.1.1.13.1.2","1.2.840.10008.5.1.4.1.1.13.1.3","1.2.840.10008.5.1.4.1.1.13.1.4","1.2.840.10008.5.1.4.1.1.13.1.5","1.2.840.10008.5.1.4.1.1.14.1","1.2.840.10008.5.1.4.1.1.14.2","1.2.840.10008.5.1.4.1.1.20","1.2.840.10008.5.1.4.1.1.77.1.1","1.2.840.10008.5.1.4.1.1.77.1.1.1","1.2.840.10008.5.1.4.1.1.77.1.2","1.2.840.10008.5.1.4.1.1.77.1.2.1","1.2.840.10008.5.1.4.1.1.77.1.3","1.2.840.10008.5.1.4.1.1.77.1.4","1.2.840.10008.5.1.4.1.1.77.1.4.1","1.2.840.10008.5.1.4.1.1.77.1.5.1","1.2.840.10008.5.1.4.1.1.77.1.5.2","1.2.840.10008.5.1.4.1.1.77.1.5.4","1.2.840.10008.5.1.4.1.1.77.1.6","1.2.840.10008.5.1.4.1.1.82.1","1.2.840.10008.5.1.4.1.1.128","1.2.840.10008.5.1.4.1.1.128.1","1.2.840.10008.5.1.4.1.1.130","1.2.840.10008.5.1.4.1.1.481.1","1.2.840.10008.5.1.4.1.1.481.2"],videoSopClassUids:["1.2.840.10008.5.1.4.1.1.77.1.1.1","1.2.840.10008.5.1.4.1.1.77.1.2.1","1.2.840.10008.5.1.4.1.1.77.1.4.1"],videoTransferSyntaxUids:BT,longVideoSopClassUids:["1.2.840.10008.5.1.4.1.1.7","1.2.840.10008.5.1.4.1.1.7.4"],longVideoMinFrames:90,ecgSopClassUids:["1.2.840.10008.5.1.4.1.1.9.1.1","1.2.840.10008.5.1.4.1.1.9.1.2","1.2.840.10008.5.1.4.1.1.9.1.3","1.2.840.10008.5.1.4.1.1.9.2.1","1.2.840.10008.5.1.4.1.1.9.3.1"],wholeSlideSopClassUids:["1.2.840.10008.5.1.4.1.1.77.1.6"],segmentationSopClassUids:["1.2.840.10008.5.1.4.1.1.66.4","1.2.840.10008.5.1.4.1.1.66.7"],rtStructureSetSopClassUids:["1.2.840.10008.5.1.4.1.1.481.3"],parametricMapSopClassUids:["1.2.840.10008.5.1.4.1.1.30"],structuredReportSopClassUids:["1.2.840.10008.5.1.4.1.1.88.11","1.2.840.10008.5.1.4.1.1.88.22","1.2.840.10008.5.1.4.1.1.88.33","1.2.840.10008.5.1.4.1.1.88.34","1.2.840.10008.5.1.4.1.1.88.67"],encapsulatedDocumentSopClassUids:["1.2.840.10008.5.1.4.1.1.104.1"],bulkAnnotationSopClassUids:["1.2.840.10008.5.1.4.1.1.91.1"],chartSopClassUids:[],isImage:"SOPClassUID in imageSopClassUids",transferSyntaxKnown:"AvailableTransferSyntaxUID != null || TransferSyntaxUID != null",isVideo:"SOPClassUID in videoSopClassUids || AvailableTransferSyntaxUID in videoTransferSyntaxUids || TransferSyntaxUID in videoTransferSyntaxUids || (!transferSyntaxKnown && SOPClassUID in longVideoSopClassUids && NumberOfFrames >= longVideoMinFrames)",isEcg:"SOPClassUID in ecgSopClassUids",isWsi:"SOPClassUID in wholeSlideSopClassUids || Modality == 'SM'",isSegmentation:"SOPClassUID in segmentationSopClassUids",isRtStructureSet:"SOPClassUID in rtStructureSetSopClassUids",isParametricMap:"SOPClassUID in parametricMapSopClassUids",isStructuredReport:"SOPClassUID in structuredReportSopClassUids",isEncapsulatedDocument:"SOPClassUID in encapsulatedDocumentSopClassUids",isBulkAnnotation:"SOPClassUID in bulkAnnotationSopClassUids",isChart:"SOPClassUID in chartSopClassUids"},BO=/^[a-z][A-Za-z0-9_]*$/,BN=new Set(["true","false","null","undefined","defined"]),BR=/^[0-9A-Fa-f]{8}$/;function BL(e){return void 0!==Vj(e)}let Bj="displaySets aggregates are not available yet; see https://github.com/cornerstonejs/cornerstone3D/issues/3000",BV=Object.freeze({params:Object.freeze(["#values","#instances"]),implicitScope:"#values",receivers:Object.freeze({series:"#instances"}),unavailableReceivers:Object.freeze({displaySet:'displaySet.instances aggregates are available only in the { "expression" } form of attributes',displaySets:Bj})}),BF=Object.freeze({params:Object.freeze(["#values","#instances","#displaySetInstances"]),implicitScope:"#values",receivers:Object.freeze({series:"#instances",displaySet:"#displaySetInstances"}),unavailableReceivers:Object.freeze({displaySets:Bj})}),BB=new Set(["series","displaySet","displaySets"]),BW=new Set(["sortBy","attributes"]),BU="the 'displaySet.' prefix is valid only in sortBy and attributes",Bz=0,BH=new WeakMap;function BG(e,t=!0){return null===e||"boolean"==typeof e||"number"==typeof e&&Number.isFinite(e)||t&&Array.isArray(e)}function Bq(e){return Array.isArray(e)?[...e]:e}class B${constructor(e,t=e,r){this.instances=e,this.seriesInstances=t,this.split=r,this.runtimes=new WeakMap}runtime(e){let t=this.runtimes.get(e);return t||(t=new BK(this.instances,this.seriesInstances,this.split?.runtime(e)),this.runtimes.set(e,t)),t}}class BK{constructor(e,t=e,r){this.instances=e,this.seriesInstances=t,this.split=r,this.seriesValues=new Map,this.instanceValues=new Map,this.views=new Map,this.envs=new Map,this.instanceEnvs=new Map,this.inProgress=[]}get seriesRuntime(){return this.split??this}value(e,t){if("series"===e.scope)return this.split&&!e.perDisplaySet?this.split.value(e,void 0):(this.seriesValues.has(e.key)||this.seriesValues.set(e.key,this.compute(e,void 0)),this.seriesValues.get(e.key));if(!t)return;let r=this.instanceValues.get(t);return r||(r=new Map,this.instanceValues.set(t,r)),r.has(e.key)||r.set(e.key,this.compute(e,t)),r.get(e.key)}compute(e,t){let r=this.inProgress.findIndex(r=>r.bound===e&&r.instance===t);if(-1!==r){let t=[...this.inProgress.slice(r).map(e=>e.bound),e];throw new Fl("display set rules",e.name,`Invalid display set rules: the context entries form a loop: ${t.map(({name:e,ruleId:t})=>void 0===t?e:`${e} (rule '${t}')`).join(" -> ")}`)}this.inProgress.push({bound:e,instance:t});try{return e.compute(this,t)}finally{this.inProgress.pop()}}groupView(e,t){let r=this.value(e,t),n=e.group?.fields;if(!t||!n||!r||"object"!=typeof r)return r;let a=this.views.get(t);if(a||(a=new Map,this.views.set(t,a)),!a.has(e.key)){let i=Bx(t),o=Object.create(null);for(let[e,t]of Object.entries(n)){let n=Fi(r,e);o[e]="instance"===t?void 0===i?void 0:Fi(n,i):n}a.set(e.key,o)}return a.get(e.key)}read(e,t,r,n){if(t)switch(t.kind){case"keyword":return r?Fi(r,e):void 0;case"attribute":return Fi(n,e);case"entry":return t.bound.group?this.groupView(t.bound,r):this.value(t.bound,r);case"series":return this.seriesRuntime.read(e,t.inner,r,n);case"displaySet":{let e=Object.create(null);return t.fields.forEach((t,a)=>{e[a]=this.read(a,t,r,n)}),e}}}env(e,t,r,n=!1){let a=!r&&!n,i=a?this.envs.get(e.key):void 0,o=i?.get(t);if(o)return o;let s=new Proxy(Object.create(null),{has:()=>!0,get:(n,a)=>{if("string"!=typeof a)return;let i=e.deps.get(a)??e.layer?.dynamicDependency(a,e.definition);return this.read(a,i,t,r)}});return a&&(i||(i=new Map,this.envs.set(e.key,i)),i.set(t,s)),s}envsOf(e,t=this.seriesInstances,r){if(r||t!==this.seriesInstances)return t.map(t=>this.env(e,t,r));if(this.split&&!e.perDisplaySet)return this.split.envsOf(e,this.split.seriesInstances);let n=this.instanceEnvs.get(e.key);return n||(n=t.map(t=>this.env(e,t)),this.instanceEnvs.set(e.key,n)),n}}class BY{constructor(e,t,r){this.program=e,this.ruleId=t,this.local=r,this.memo=new Map,this.dynamic=new Map}resolve(e,t){return t&&void 0!==t.ruleId&&t.name===e?this.program.global.get(e):this.local.get(e)??this.program.global.get(e)}dynamicDependency(e,t){let r=this.dynamic.get(t);if(r||(r=new Map,this.dynamic.set(t,r)),!r.has(e)){let n;if(this.program.isDenied(e))BE.warn(`a code entry of the context read '${e}', which is on the deny list of the host; the read gives undefined`);else if(BL(e))n={kind:"keyword"};else{let r=this.resolve(e,t);r?n={kind:"entry",bound:this.program.bind(r,this,[])}:B_.includes(e)&&(n={kind:"attribute"})}r.set(e,n)}return r.get(e)}}class BX{constructor(e,t){for(const r of(this.global=new Map,this.bounds=new Map,this.fallbackLogged=!1,this.seriesHook=({instances:e,series:t})=>Fa(t,BD)?{}:{[BD]:new B$(e)},this.seriesFunctions=t.seriesFunctions,this.denied=new Set(t.deniedNames??[]),this.deniedTags=new Set([...this.denied].map(Vj).filter(Boolean)),this.parseLayer(e,t.site,void 0)))this.global.set(r.name,r);for(const e of(this.empty=new BY(this,void 0,new Map),this.global.values()))this.bind(e,this.empty,[])}isDenied(e){return this.denied.has(e)}parseExpression(e,t,r){let n=function(e,t,r=BV){let n=By(e,t,r),a=FR(e);return{evaluate:n,reads:Bo(a,{aggregates:!0}),single:"identifier"===a.type?a.name:void 0,ast:a}}(e,t,r);if(this.denied.size){var a;let e,r;for(let i of(a=n.ast,e=[],(r=t=>{switch(t.type){case"member":e.push(t.property),r(t.object);return;case"index":"literal"!==t.index.type?e.push(void 0):"string"==typeof t.index.value&&e.push(t.index.value),r(t.object),r(t.index);return;case"call":t.args.forEach(r);return;case"unary":r(t.argument);return;case"binary":case"logical":r(t.left),r(t.right);return;case"conditional":r(t.test),r(t.consequent),r(t.alternate);return;case"array":t.elements.forEach(r);return;case"template":t.parts.forEach(e=>"expr"===e.kind&&r(e.node));return}})(a),e))void 0===i&&Fd(t,"a computed field name is not allowed when the host has a deny list; use a literal index, e.g. ViewCodeSequence[0].CodeValue"),this.denied.has(i)&&Fd(t,`the name '${i}' is on the deny list of the host, so no rule can read it`)}return n}runtimeFrom(e,t){let r=Fi(e,"displaySet");if(r instanceof B$)return r.runtime(this);let n=Fi(Fi(e,"series"),BD);return n instanceof B$?n.runtime(this):(this.fallbackLogged||(this.fallbackLogged=!0,BE.debug("a split rule hook was called with no split context; its context values cover only the instances of the call")),new B$(t?NZ(t):[]).runtime(this))}instanceValue(e,t){let r=this.global.get(e);if(!r)throw Error(`the metadata context has no entry '${e}'`);let n=this.bind(r,this.empty,[]);if("instance"!==n.scope)throw Error(`the context entry '${e}' has the series scope, so one instance cannot give its value`);return new B$([t]).runtime(this).read(e,{kind:"entry",bound:n},t)}layer(e,t,r){if(void 0===t)return this.empty;let n=new Map;for(let a of this.parseLayer(t,r,e))n.set(a.name,a),BE.debug(this.global.has(a.name)?`rule '${e}': the context entry '${a.name}' replaces the global entry for this rule`:`rule '${e}': the context entry '${a.name}' defines a new name for this rule`);let a=new BY(this,e,n);for(let e of n.values())this.bind(e,a,[]);return a}readerAt(e,t,r,n={}){let a=n.place??"",{field:i}=n,o=t,s="displaySet"===t||t.startsWith("displaySet.");if(s){BW.has(a)||Fd(r,BU);let e=t.split(".").slice(1);void 0!==i&&e.push(i),(!e.length||e.length>2||e.some(e=>!e))&&Fd(r,`'${t}' must be displaySet.<name> or displaySet.<name>.<field>, e.g. displaySet.sliceSpacing`),[o,i]=e}let l=this.dependencyOf({name:o,field:i,inAggregate:!1},void 0,e,[],r,a);return!s&&BW.has(a)&&(l={kind:"series",inner:l}),(e,t,r)=>{let n=e.read(o,l,t,r);return void 0===i?n:Fi(n,i)}}attributeExpression(e,t,r){let{evaluate:n,reads:a}=this.parseExpression(t,r,BF),i=new Map,o=new Map;for(let t of a){if("displaySet"===t.name){void 0===t.field&&Fd(r,"'displaySet' needs a name, e.g. displaySet.sliceSpacing"),o.set(t.field,this.dependencyOf({name:t.field,inAggregate:t.inAggregate},void 0,e,[],r,"attributes"));continue}let n=this.dependencyOf(t,void 0,e,[],r,"attributes");i.set(t.name,{kind:"series",inner:n})}o.size&&i.set("displaySet",{kind:"displaySet",fields:o});let s=o.size>0||[...i.values()].some(e=>"series"===e.kind&&"attribute"===e.inner.kind),l={key:`#attribute:${r.path}`,deps:i,perDisplaySet:s};return(e,t,r)=>n(e.env(l,t[0],r),s?e.envsOf(l,e.seriesInstances,r):e.envsOf(l),e.envsOf(l,t,r))}bind(e,t,r){let n=t.memo.get(e);if(n)return n;let a=r.indexOf(e);if(-1!==a){let t=[...r.slice(a),e].map(({name:e})=>e).join(" -> ");return Fd(e.site,`the context entries form a loop: ${t}`)}r.push(e);try{let n=new Map,a=new Set;void 0!==e.ruleId&&a.add(e.name),"code"===e.kind&&t.local.forEach((e,t)=>a.add(t));let i="declaration"===e.kind||"code"===e.kind?"instance":"series";for(let o of e.reads){let s=this.dependencyOf(o,e,t,r,e.site,"context");n.set(o.name,s),"entry"===s.kind&&s.bound.closure.forEach(e=>a.add(e)),!o.inAggregate&&BZ(o,s)&&(i="instance")}if("group"===e.kind){for(let t of e.args){let r=t.reads.find(e=>!e.inAggregate&&BZ(e,n.get(e.name)));r&&Fd(Fc(Fc(e.site,"args"),t.name),`the argument must have one value for the series, but '${r.name}' has one value for each instance`)}i="series"}let o=[...a].sort(),s=void 0===e.ruleId?"":"@",l=o.length?`${s}${e.name}{${o.map(e=>`${e}=${t.local.get(e)?.identity}`).join(",")}}`:`${s}${e.name}`,d=this.bounds.get(l);return d||(d=this.createBound(e,t,l,i,n,a),this.bounds.set(l,d)),t.memo.set(e,d),d}finally{r.pop()}}dependencyOf(e,t,r,n,a,i){let{name:o,field:s}=e;if(this.denied.has(o))return Fd(a,`the name '${o}' is on the deny list of the host, so no rule can read it`);if("displaySet"===o)return Fd(a,BU);if(BL(o))return void 0!==s?Fd(a,`'${o}' is a DICOM keyword and has no field '${s}'; read an item of a sequence with an index, e.g. ${o}[0].${s}`):{kind:"keyword"};let l=r.resolve(o,t);if(!l)return B_.includes(o)?"attributes"===i?{kind:"attribute"}:Fd(a,`'${o}' is a value of the display set, and only attributes can read it`):t&&void 0!==t.ruleId&&t.name===o?Fd(a,`the rule entry '${o}' reads its own name, but the global context has no entry '${o}'`):Fd(a,function(e,t,r){let n,a=Fu(e,[function(e){if(!b)for(let e of(b=new Map,Object.keys(VN)))b.set(e.toLowerCase(),e);return b.get(e.toLowerCase())}(e),...r]);if(a)return`unknown name '${e}'${a}`;n=BR.test(e)?`a hex tag needs a declaration in the context, e.g. "myValue": { "attribute": "${e}" }`:BN.has(e)?`'${e}' is a literal; write X == ${e} in a context entry`:/^[a-z]/.test(e)?"no context entry has this name":`it is not a keyword of the DICOM dictionary; a private, vendor or synthetic attribute needs a declaration, e.g. "myValue": { "attribute": "${e}" }`;let i="attributes"===t?`; fixed text is { "template": ${JSON.stringify(e)} }`:"";return`unknown name '${e}': ${n}${i}`}(o,i,[...r.local.keys(),...this.global.keys(),...B_]));let d=this.bind(l,r,n);if(e.indexed&&d.group)return Fd(a,`read a field of the group '${o}' by path, e.g. ${o}.${Object.keys(d.group.fields??{})[0]??"field"}`);if(void 0!==s){if(!d.group)return Fd(a,`'${o}' is not a group, so '${o}.${s}' reads nothing`);let{fields:e}=d.group;if(e&&!Fa(e,s))return Fd(a,`the group '${o}' has no field '${s}'${Fu(s,Object.keys(e))}; fields: ${Object.keys(e).join(", ")}`)}return{kind:"entry",bound:d}}createBound(e,t,r,n,a,i){let o={key:r,name:e.name,scope:n,deps:a,closure:i,ruleId:e.ruleId,perDisplaySet:"code"===e.kind||"group"===e.kind||[...a.values()].some(e=>"entry"===e.kind&&e.bound.perDisplaySet),compute:()=>void 0};switch(e.kind){case"fixed":{let{value:t}=e;o.compute=()=>t;break}case"declaration":{let{attribute:t}=e;o.compute=(e,r)=>Fi(r,t);break}case"code":{let{fn:r}=e;o.layer=t,o.definition=e,o.compute=(e,t)=>t?r(t,e.env(o,t,void 0,!0)):void 0;break}case"expression":{let t=void 0!==e.aliasOf?a.get(e.aliasOf):void 0;if(t?.kind==="entry"&&t.bound.group){let e=t.bound;o.group=e.group,o.scope="series",o.compute=t=>t.value(e,void 0);break}let{evaluate:r}=e;o.compute=(e,t)=>r(e.env(o,t),e.envsOf(o));break}case"template":{let t=e.segments.map(e=>"literal"in e?()=>e.literal:(t,r)=>{let n=t.read(e.name,a.get(e.name),r);return void 0===e.field?n:Fi(n,e.field)});o.compute=(e,r)=>t.map(t=>{let n=t(e,r);return FV(n)?"":String(n)}).join("");break}case"group":{let{compute:t,args:r}=e;o.group={fields:e.fields},o.compute=e=>{let n={};for(let t of r)n[t.name]=t.evaluate?t.evaluate(e.env(o,void 0),e.envsOf(o)):t.fixed;return t(e.instances,{args:Object.freeze(n)})}}}return o}parseLayer(e,t,r){return!e||"object"!=typeof e||Array.isArray(e)?Fd(t,"expected an object of context entries, keyed by context name",e):Object.entries(e).map(([e,n])=>{let a=Fc(t,e);return(Fo(e)||F_.has(e))&&Fd(a,`the context name "${e}" is not allowed`),(BN.has(e)||BB.has(e))&&Fd(a,`'${e}' is reserved by the expression language, and cannot be a context name`),BL(e)&&Fd(a,`the context name '${e}' is a DICOM keyword; a context cannot hide a value of the instance`),BO.test(e)||Fd(a,`the context name '${e}' must start with a lowercase letter, and hold only letters, digits and _`),B_.includes(e)&&Fd(a,`'${e}' is a value of the display set, and cannot be a context name`),this.denied.has(e)&&Fd(a,`the context name '${e}' is on the deny list of the host`),this.parseEntry(e,n,a,r)})}parseEntry(e,t,r,n){let a={name:e,ruleId:n,site:r,identity:JSON.stringify(t,(e,t)=>{if("function"!=typeof t)return t;let r=BH.get(t);return r||(r=`#function${++Bz}`,BH.set(t,r)),r})};if("function"==typeof t)return{...a,kind:"code",reads:[],fn:t};if(BG(t))return{...a,kind:"fixed",reads:[],value:Bq(t)};if("string"==typeof t){let{evaluate:e,reads:n,single:i}=this.parseExpression(t,r);return{...a,kind:"expression",reads:n,evaluate:e,aliasOf:i}}if(!t||"object"!=typeof t)return Fd(r,"expected a fixed value (a number, a boolean, null or an array), an expression string, { attribute }, { template }, { function, args? }, or a function",t);let[i]=Fg(BP.contextEntry,t,r);if("declaration"===i){if(!t.attribute)return Fd(Fc(r,"attribute"),"expected a non-empty string");let e=String(t.attribute);return this.denied.has(e)||this.deniedTags.has(e.replace(/^x/i,"").toUpperCase())?Fd(Fc(r,"attribute"),`the attribute '${e}' is on the deny list of the host, so no rule can read it`):{...a,kind:"declaration",reads:[],attribute:t.attribute,vr:t.vr,vm:t.vm}}if("template"===i){let e=Bb(t.template,Fc(r,"template")),n=e.flatMap(e=>"literal"in e?[]:[{name:e.name,field:e.field,inAggregate:!1}]);return{...a,kind:"template",reads:n,segments:e}}let o=this.seriesFunctionOf(t.function,Fc(r,"function")),s=this.parseArguments(t.args,Fc(r,"args"));return{...a,kind:"group",reads:s.flatMap(e=>e.reads),compute:o.compute,fields:o.fields,args:s}}seriesFunctionOf(e,t){if("function"==typeof e)return{compute:e};if(e&&"object"==typeof e&&"function"==typeof e.compute)return e;if("string"==typeof e){let t=Fi(this.seriesFunctions,e);if("function"==typeof t)return{compute:t};if(t&&"object"==typeof t)return t}return Fd(t,`unknown series function ${JSON.stringify(e)}; known: ${Object.keys(this.seriesFunctions).join(", ")||"(none)"}`)}parseArguments(e,t){return void 0===e?[]:!e||"object"!=typeof e||Array.isArray(e)?Fd(t,"expected an object of arguments",e):Object.entries(e).map(([e,r])=>{let n=Fc(t,e);if(Fo(e)&&Fd(n,`the argument name "${e}" is not allowed`),BG(r))return{name:e,fixed:Bq(r),reads:[]};if("string"==typeof r){let{evaluate:t,reads:a}=this.parseExpression(r,n);return{name:e,evaluate:t,reads:a}}return Fd(n,"an argument is a fixed value (a number, a boolean, null or an array) or an expression string",r)})}}function BZ(e,t){if(!t)return!1;switch(t.kind){case"keyword":return!0;case"attribute":case"displaySet":return!1;case"series":return BZ(e,t.inner);case"entry":{let{bound:r}=t;if(void 0!==e.field)return r.group?.fields?.[e.field]==="instance";return"instance"===r.scope}}}let BJ=new WeakMap,BQ="display set rules";function B0(e,t,r,n,a){let i=e.program.readerAt(e.layer,t,r,{field:a,place:n}),{program:o}=e;return(e,t)=>i(o.runtimeFrom(t,e),e)}function B1(e,t,r){return Array.isArray(e)?e.map((e,n)=>r(e,Fc(t,n))):Fd(t,"expected an array",e)}let B2=e=>`[${e.map(e=>`'${e}'`).join(", ")}]`,B5={isImage:!0,Rows:{notNull:!0}},B3={groupBy:["SeriesInstanceUID","revisionChainUid"],sortBy:["isActiveRevision","InstanceNumber"],attributes:{activeSopInstanceUid:"revisionChainUid"}},B4=(e,t,r,n)=>({priority:e,description:n,handler:r,matches:{[t]:!0},groupBy:["SeriesInstanceUID"]}),B8={video:{priority:1,description:"A video-only SOP class, or a video transfer syntax, or (with no known transfer syntax) a long multi-frame secondary capture. One display set per instance, shown on a video viewport.",handler:"video",matches:{isVideo:!0},groupBy:["SOPInstanceUID"]},ecg:{priority:2,description:"ECG / waveform SOP classes. One display set per instance, shown on a waveform viewport rather than an image viewport.",handler:"ecg",matches:{isEcg:!0},groupBy:["SOPInstanceUID"]},wholeslide:{priority:3,description:"VL Whole Slide Microscopy (or modality SM). All pyramid levels of the series form a single whole-slide display set.",handler:"wholeSlide",matches:{isWsi:!0},groupBy:["SeriesInstanceUID"]},singleImageModality:{priority:4,description:"CR / DX / MG, which acquire one image per instance. One display set per instance, so each view of a mammography series is its own display set.",matches:{Modality:["CR","DX","MG"],isImage:!0},groupBy:["SOPInstanceUID"]},multiFrame:{priority:5,description:"Multi-frame image instances, one display set per instance. A cine clip (a slice location, or a US, XA, RF, ES or XC multi-frame that is not a volume) is flagged isClip. Another multi-frame instance, such as an enhanced CT, is not a clip.",context:{isCineClip:`SliceLocation != null || (Modality in ${B2(["US","XA","RF","ES","XC"])} && !(SOPClassUID in ${B2(["1.2.840.10008.5.1.4.1.1.6.2","1.2.840.10008.5.1.4.1.1.13.1.1","1.2.840.10008.5.1.4.1.1.13.1.2"])}))`},matches:{isImage:!0,isMultiFrame:!0},groupBy:["SOPInstanceUID"],attributes:{isClip:"isCineClip",numImageFrames:{expression:"Number(NumberOfFrames)"}}},mixedDimensionalityBValue:{priority:6,description:"Diffusion MR that mixes 4D b-value frames with trailing frames that have none. The undefined-b-value frames are not part of the 4D set, so they split off - otherwise 4D rendering is applied to the 3D portion.",context:{isMixedBValue:"series.instances.count(DiffusionBValue) > 0 && series.instances.count(DiffusionBValue) < series.instances.count()",hasNoBValue:"DiffusionBValue == null"},matches:{Modality:"MR",isMixedBValue:!0,...B5},groupBy:["SeriesInstanceUID","hasNoBValue"]},volume3d:{priority:7,description:"Multi-slice CT / MR / PT / NM, which reconstruct into a volume.",matches:{Modality:["CT","MR","PT","NM"],seriesInstanceCount:{greaterThan:1},...B5},groupBy:["SeriesInstanceUID"]},defaultImageRule:{priority:8,description:"Fallback for any remaining image SOP class, also with no Rows in the metadata. Grouped one display set per series.",matches:{isImage:!0}},segmentation:B4(9,"isSegmentation","segmentation","Segmentations (segmentationSopClassUids). One display set per series."),rtStructureSet:B4(10,"isRtStructureSet","rtStructureSet","RT structure sets (rtStructureSetSopClassUids). One display set per series."),parametricMap:B4(11,"isParametricMap","parametricMap","Parametric maps (parametricMapSopClassUids). One display set per series."),structuredReport:{...B4(12,"isStructuredReport","structuredReport","Structured reports (structuredReportSopClassUids), also Comprehensive 3D SR. One display set per series. Manufacturer and ManufacturerModelName name the writer of the SR."),attributes:{Manufacturer:"Manufacturer",ManufacturerModelName:"ManufacturerModelName"}},encapsulatedDocument:{...B4(13,"isEncapsulatedDocument","encapsulatedDocument","Encapsulated documents (encapsulatedDocumentSopClassUids). One display set per revision chain (PredecessorDocumentsSequence) of the series; activeSopInstanceUid names the current revision."),...B3},bulkAnnotation:B4(14,"isBulkAnnotation","bulkAnnotation","Microscopy bulk annotations (bulkAnnotationSopClassUids). One display set per series."),chart:{...B4(15,"isChart","chart","Charts (chartSopClassUids, empty by default: a host adds its chart SOP class). One display set per revision chain of the series; activeSopInstanceUid names the current revision."),...B3},unsupported:{priority:Number.MAX_SAFE_INTEGER,description:"Catch-all for objects that no other rule claims (presentation states, other non-image objects). Produces one display set for each series, marked isDisplayable: false, so the objects are surfaced rather than silently dropped. Runs last.",handler:"unsupported",groupBy:["SeriesInstanceUID"]}};!function(e=B8,t={}){!function(e,t={}){if(!e||"object"!=typeof e||Array.isArray(e))throw Error(`Invalid ${BQ}: the rules must be an object keyed by rule id: ${JSON.stringify(e)}`);let r=function(e,t={}){return(t.seriesFunctions||t.deniedNames?void 0:BJ.get(e??BA))??function(e,t={}){let r=new BX({...BA,...e},{seriesFunctions:{...BI,...t.seriesFunctions},deniedNames:t.deniedNames,site:Bf({definition:t.definition??"metadata context",path:"context"},BP,Bm)});return t.seriesFunctions||t.deniedNames||BJ.set(e??BA,r),r}(e,t)}(t.context,{seriesFunctions:t.seriesFunctions,deniedNames:t.deniedNames,definition:BQ}),n=t.sortFunctions??{},a={};for(let[t,i]of Object.entries(e)){!function(e,t){Fo(e)&&Fw(e,"the id is not allowed; give the rule another id"),t&&"object"==typeof t||Fw(e,"the entry must be an object"),void 0!==t.id&&t.id!==e&&Fw(e,`the entry states id "${t.id}", but its key is the id. Remove the id, or make it equal to the key.`);let{priority:r}=t;null!==r&&("number"==typeof r&&Number.isFinite(r)||Fw(e,`priority must be a finite number, or null to exclude the rule; got ${JSON.stringify(r)}`))}(t,i);let e=Bf({definition:BQ,path:`rule '${t}'`},BP,Bm),{id:o,...s}=function(e,t,r,n,a){Fg(BP.rule,t,r);let i=n.layer(e,t.context,Fc(r,"context")),o={site:r,program:n,layer:i,sortFunctions:a},s={id:e,series:n.seriesHook};if(void 0!==t.groupId&&(s.groupId=t.groupId),void 0!==t.viewportTypes&&(s.viewportTypes=t.viewportTypes),void 0!==t.handler&&(s.handler=t.handler),void 0!==t.matches){let e={...Fc(r,"matches"),readName:(e,t,r)=>B0(o,e,t,"matches",r)};s.matches=Bv(t.matches,e)}if(void 0!==t.groupBy){let e=B1(t.groupBy,Fc(r,"groupBy"),(e,t)=>"function"==typeof e?e:"string"!=typeof e?Ff(BP.name,e,t):B0(o,e,t,"groupBy"));e.length&&(s.groupBy=e)}if(void 0!==t.sortBy){let e=B1(t.sortBy,Fc(r,"sortBy"),(e,t)=>(function(e,t,r){if("function"==typeof e)return e;if("string"==typeof e){let n=r.program.readerAt(r.layer,e,t,{place:"sortBy"}),{program:a}=r;return(e,t,r)=>{let i=a.runtimeFrom(r,[e,t]);return function(e,t){let r=N2(e),n=N2(t);if(void 0!==r&&void 0!==n)return r-n;if(FV(e)||FV(t))return Number(FV(e))-Number(FV(t));let a=String(NJ(e)),i=String(NJ(t));return a<i?-1:+(a>i)}(n(i,e),n(i,t))}}if(!e||"object"!=typeof e||Array.isArray(e))return Ff(BP.sortKey,e,t);Fg(BP.sortKey,e,t);let n=e.sortFunction,a=Fi(r.sortFunctions,n);return"function"!=typeof a?Fd(Fc(t,"sortFunction"),`unknown sort function "${n}"; known: ${Object.keys(r.sortFunctions).join(", ")||"(none)"}`):a})(e,t,o));e.length&&(s.compareInstances=1===e.length?e[0]:(t,r,n)=>{for(let a of e){let e=a(t,r,n);if(Number.isFinite(e)&&0!==e)return e}return 0})}return void 0!==t.attributes&&(s.customAttributes=function(e,t,r){if("function"==typeof e)return e;if(!e||"object"!=typeof e||Array.isArray(e))return Fd(t,"expected an object of attribute values, keyed by attribute name, or a function (attributes, options) => Record<string, unknown>",e);let n=Object.entries(e).map(([e,n])=>{let a=Fc(t,e);return Fo(e)&&Fd(a,`the key "${e}" is not allowed`),[e,function(e,t,r){let{program:n,layer:a}=r;if("function"==typeof e){let r={key:`#attribute:${t.path}`,deps:new Map,layer:a};return(t,n,a)=>e(n,t.env(r,n[0],a))}if(BG(e,!1))return()=>e;if("string"==typeof e){let r=n.readerAt(a,e,t,{place:"attributes"});return(e,t,n)=>r(e,t[0],n)}if(!e||"object"!=typeof e||Array.isArray(e))return Ff(BP.attributeValue,e,t);let[i]=Fg(BP.attributeValue,e,t);if("expression"===i)return n.attributeExpression(a,e.expression,Fc(t,"expression"));let o=Fc(t,"template"),s=Bb(e.template,o).map(e=>"literal"in e?()=>e.literal:n.readerAt(a,e.name,o,{field:e.field,place:"attributes"}));return(e,t,r)=>s.map(n=>{let a=n(e,t[0],r);return FV(a)?"":String(a)}).join("")}(n,a,r)]}),{program:a}=r;return(e,t)=>{var r;let i,o=t.instances??[],s=a.runtimeFrom({series:t.series,displaySet:(r=t.series,(i=Fi(r,BD))instanceof B$?new B$(o,i.seriesInstances,i):new B$(o))},o),l={splitNumber:t.splitNumber,sopClassUids:e?.sopClassUids},d={};for(let[e,t]of n)d[e]=o.length?t(s,o,l):void 0;return d}}(t.attributes,Fc(r,"attributes"),o)),s}(t,i,e,r,n);a[t]={...s,priority:i.priority}}}(e,t)}(B8),Rt.getLogger("utilities.metadataProvider.compressedFrameData"),j2.COMPRESSED_FRAME_DATA;let{C:B6}=W;(eTr=eTz||(eTz={})).NO_DATA="noData",eTr.LOADING="loading",eTr.PRE_RENDER="preRender",eTr.NEEDS_RENDER="needsRender",eTr.RESIZE="resize",eTr.RENDERED="rendered";let B9=eTz;(eTn=eTH||(eTH={}))[eTn.FAR_REPLICATE=1]="FAR_REPLICATE",eTn[eTn.ADJACENT_REPLICATE=3]="ADJACENT_REPLICATE",eTn[eTn.SUBRESOLUTION=6]="SUBRESOLUTION",eTn[eTn.LOSSY=7]="LOSSY",eTn[eTn.FULL_RESOLUTION=8]="FULL_RESOLUTION";let B7=eTH;(eTa=eTG||(eTG={})).FRAME="f",eTa.SECOND="s";let We=j2;(eTi=eTq||(eTq={})).SUM="SUM",eTi.SUBTRACT="SUBTRACT",eTi.AVERAGE="AVERAGE",(eTo=eT$||(eT$={})).RLE="RLE",eTo.Volume="Volume";let Wt=eT$,Wr={Average:"average",ForegroundMajority:"foregroundMajority"},Wn={None:"none",BoxAverage:"boxAverage",BoxForegroundMajority:"boxForegroundMajority",Decimation:"decimation"},Wa="directLoad";(eTs=eTK||(eTK={})).Tiled="tiled",eTs.ContextPool="contextPool";let Wi=eTK,Wo={Auto:"auto",GPU:"gpu",CPU:"cpu"},Ws=Wo,Wl={hotIron:{name:"Hot Iron",numOfColors:256,colors:[[0,0,0,255],[2,0,0,255],[4,0,0,255],[6,0,0,255],[8,0,0,255],[10,0,0,255],[12,0,0,255],[14,0,0,255],[16,0,0,255],[18,0,0,255],[20,0,0,255],[22,0,0,255],[24,0,0,255],[26,0,0,255],[28,0,0,255],[30,0,0,255],[32,0,0,255],[34,0,0,255],[36,0,0,255],[38,0,0,255],[40,0,0,255],[42,0,0,255],[44,0,0,255],[46,0,0,255],[48,0,0,255],[50,0,0,255],[52,0,0,255],[54,0,0,255],[56,0,0,255],[58,0,0,255],[60,0,0,255],[62,0,0,255],[64,0,0,255],[66,0,0,255],[68,0,0,255],[70,0,0,255],[72,0,0,255],[74,0,0,255],[76,0,0,255],[78,0,0,255],[80,0,0,255],[82,0,0,255],[84,0,0,255],[86,0,0,255],[88,0,0,255],[90,0,0,255],[92,0,0,255],[94,0,0,255],[96,0,0,255],[98,0,0,255],[100,0,0,255],[102,0,0,255],[104,0,0,255],[106,0,0,255],[108,0,0,255],[110,0,0,255],[112,0,0,255],[114,0,0,255],[116,0,0,255],[118,0,0,255],[120,0,0,255],[122,0,0,255],[124,0,0,255],[126,0,0,255],[128,0,0,255],[130,0,0,255],[132,0,0,255],[134,0,0,255],[136,0,0,255],[138,0,0,255],[140,0,0,255],[142,0,0,255],[144,0,0,255],[146,0,0,255],[148,0,0,255],[150,0,0,255],[152,0,0,255],[154,0,0,255],[156,0,0,255],[158,0,0,255],[160,0,0,255],[162,0,0,255],[164,0,0,255],[166,0,0,255],[168,0,0,255],[170,0,0,255],[172,0,0,255],[174,0,0,255],[176,0,0,255],[178,0,0,255],[180,0,0,255],[182,0,0,255],[184,0,0,255],[186,0,0,255],[188,0,0,255],[190,0,0,255],[192,0,0,255],[194,0,0,255],[196,0,0,255],[198,0,0,255],[200,0,0,255],[202,0,0,255],[204,0,0,255],[206,0,0,255],[208,0,0,255],[210,0,0,255],[212,0,0,255],[214,0,0,255],[216,0,0,255],[218,0,0,255],[220,0,0,255],[222,0,0,255],[224,0,0,255],[226,0,0,255],[228,0,0,255],[230,0,0,255],[232,0,0,255],[234,0,0,255],[236,0,0,255],[238,0,0,255],[240,0,0,255],[242,0,0,255],[244,0,0,255],[246,0,0,255],[248,0,0,255],[250,0,0,255],[252,0,0,255],[254,0,0,255],[255,0,0,255],[255,2,0,255],[255,4,0,255],[255,6,0,255],[255,8,0,255],[255,10,0,255],[255,12,0,255],[255,14,0,255],[255,16,0,255],[255,18,0,255],[255,20,0,255],[255,22,0,255],[255,24,0,255],[255,26,0,255],[255,28,0,255],[255,30,0,255],[255,32,0,255],[255,34,0,255],[255,36,0,255],[255,38,0,255],[255,40,0,255],[255,42,0,255],[255,44,0,255],[255,46,0,255],[255,48,0,255],[255,50,0,255],[255,52,0,255],[255,54,0,255],[255,56,0,255],[255,58,0,255],[255,60,0,255],[255,62,0,255],[255,64,0,255],[255,66,0,255],[255,68,0,255],[255,70,0,255],[255,72,0,255],[255,74,0,255],[255,76,0,255],[255,78,0,255],[255,80,0,255],[255,82,0,255],[255,84,0,255],[255,86,0,255],[255,88,0,255],[255,90,0,255],[255,92,0,255],[255,94,0,255],[255,96,0,255],[255,98,0,255],[255,100,0,255],[255,102,0,255],[255,104,0,255],[255,106,0,255],[255,108,0,255],[255,110,0,255],[255,112,0,255],[255,114,0,255],[255,116,0,255],[255,118,0,255],[255,120,0,255],[255,122,0,255],[255,124,0,255],[255,126,0,255],[255,128,4,255],[255,130,8,255],[255,132,12,255],[255,134,16,255],[255,136,20,255],[255,138,24,255],[255,140,28,255],[255,142,32,255],[255,144,36,255],[255,146,40,255],[255,148,44,255],[255,150,48,255],[255,152,52,255],[255,154,56,255],[255,156,60,255],[255,158,64,255],[255,160,68,255],[255,162,72,255],[255,164,76,255],[255,166,80,255],[255,168,84,255],[255,170,88,255],[255,172,92,255],[255,174,96,255],[255,176,100,255],[255,178,104,255],[255,180,108,255],[255,182,112,255],[255,184,116,255],[255,186,120,255],[255,188,124,255],[255,190,128,255],[255,192,132,255],[255,194,136,255],[255,196,140,255],[255,198,144,255],[255,200,148,255],[255,202,152,255],[255,204,156,255],[255,206,160,255],[255,208,164,255],[255,210,168,255],[255,212,172,255],[255,214,176,255],[255,216,180,255],[255,218,184,255],[255,220,188,255],[255,222,192,255],[255,224,196,255],[255,226,200,255],[255,228,204,255],[255,230,208,255],[255,232,212,255],[255,234,216,255],[255,236,220,255],[255,238,224,255],[255,240,228,255],[255,242,232,255],[255,244,236,255],[255,246,240,255],[255,248,244,255],[255,250,248,255],[255,252,252,255],[255,255,255,255]]},pet:{name:"PET",numColors:256,colors:[[0,0,0,255],[0,2,1,255],[0,4,3,255],[0,6,5,255],[0,8,7,255],[0,10,9,255],[0,12,11,255],[0,14,13,255],[0,16,15,255],[0,18,17,255],[0,20,19,255],[0,22,21,255],[0,24,23,255],[0,26,25,255],[0,28,27,255],[0,30,29,255],[0,32,31,255],[0,34,33,255],[0,36,35,255],[0,38,37,255],[0,40,39,255],[0,42,41,255],[0,44,43,255],[0,46,45,255],[0,48,47,255],[0,50,49,255],[0,52,51,255],[0,54,53,255],[0,56,55,255],[0,58,57,255],[0,60,59,255],[0,62,61,255],[0,65,63,255],[0,67,65,255],[0,69,67,255],[0,71,69,255],[0,73,71,255],[0,75,73,255],[0,77,75,255],[0,79,77,255],[0,81,79,255],[0,83,81,255],[0,85,83,255],[0,87,85,255],[0,89,87,255],[0,91,89,255],[0,93,91,255],[0,95,93,255],[0,97,95,255],[0,99,97,255],[0,101,99,255],[0,103,101,255],[0,105,103,255],[0,107,105,255],[0,109,107,255],[0,111,109,255],[0,113,111,255],[0,115,113,255],[0,117,115,255],[0,119,117,255],[0,121,119,255],[0,123,121,255],[0,125,123,255],[0,128,125,255],[1,126,127,255],[3,124,129,255],[5,122,131,255],[7,120,133,255],[9,118,135,255],[11,116,137,255],[13,114,139,255],[15,112,141,255],[17,110,143,255],[19,108,145,255],[21,106,147,255],[23,104,149,255],[25,102,151,255],[27,100,153,255],[29,98,155,255],[31,96,157,255],[33,94,159,255],[35,92,161,255],[37,90,163,255],[39,88,165,255],[41,86,167,255],[43,84,169,255],[45,82,171,255],[47,80,173,255],[49,78,175,255],[51,76,177,255],[53,74,179,255],[55,72,181,255],[57,70,183,255],[59,68,185,255],[61,66,187,255],[63,64,189,255],[65,63,191,255],[67,61,193,255],[69,59,195,255],[71,57,197,255],[73,55,199,255],[75,53,201,255],[77,51,203,255],[79,49,205,255],[81,47,207,255],[83,45,209,255],[85,43,211,255],[86,41,213,255],[88,39,215,255],[90,37,217,255],[92,35,219,255],[94,33,221,255],[96,31,223,255],[98,29,225,255],[100,27,227,255],[102,25,229,255],[104,23,231,255],[106,21,233,255],[108,19,235,255],[110,17,237,255],[112,15,239,255],[114,13,241,255],[116,11,243,255],[118,9,245,255],[120,7,247,255],[122,5,249,255],[124,3,251,255],[126,1,253,255],[128,0,255,255],[130,2,252,255],[132,4,248,255],[134,6,244,255],[136,8,240,255],[138,10,236,255],[140,12,232,255],[142,14,228,255],[144,16,224,255],[146,18,220,255],[148,20,216,255],[150,22,212,255],[152,24,208,255],[154,26,204,255],[156,28,200,255],[158,30,196,255],[160,32,192,255],[162,34,188,255],[164,36,184,255],[166,38,180,255],[168,40,176,255],[170,42,172,255],[171,44,168,255],[173,46,164,255],[175,48,160,255],[177,50,156,255],[179,52,152,255],[181,54,148,255],[183,56,144,255],[185,58,140,255],[187,60,136,255],[189,62,132,255],[191,64,128,255],[193,66,124,255],[195,68,120,255],[197,70,116,255],[199,72,112,255],[201,74,108,255],[203,76,104,255],[205,78,100,255],[207,80,96,255],[209,82,92,255],[211,84,88,255],[213,86,84,255],[215,88,80,255],[217,90,76,255],[219,92,72,255],[221,94,68,255],[223,96,64,255],[225,98,60,255],[227,100,56,255],[229,102,52,255],[231,104,48,255],[233,106,44,255],[235,108,40,255],[237,110,36,255],[239,112,32,255],[241,114,28,255],[243,116,24,255],[245,118,20,255],[247,120,16,255],[249,122,12,255],[251,124,8,255],[253,126,4,255],[255,128,0,255],[255,130,4,255],[255,132,8,255],[255,134,12,255],[255,136,16,255],[255,138,20,255],[255,140,24,255],[255,142,28,255],[255,144,32,255],[255,146,36,255],[255,148,40,255],[255,150,44,255],[255,152,48,255],[255,154,52,255],[255,156,56,255],[255,158,60,255],[255,160,64,255],[255,162,68,255],[255,164,72,255],[255,166,76,255],[255,168,80,255],[255,170,85,255],[255,172,89,255],[255,174,93,255],[255,176,97,255],[255,178,101,255],[255,180,105,255],[255,182,109,255],[255,184,113,255],[255,186,117,255],[255,188,121,255],[255,190,125,255],[255,192,129,255],[255,194,133,255],[255,196,137,255],[255,198,141,255],[255,200,145,255],[255,202,149,255],[255,204,153,255],[255,206,157,255],[255,208,161,255],[255,210,165,255],[255,212,170,255],[255,214,174,255],[255,216,178,255],[255,218,182,255],[255,220,186,255],[255,222,190,255],[255,224,194,255],[255,226,198,255],[255,228,202,255],[255,230,206,255],[255,232,210,255],[255,234,214,255],[255,236,218,255],[255,238,222,255],[255,240,226,255],[255,242,230,255],[255,244,234,255],[255,246,238,255],[255,248,242,255],[255,250,246,255],[255,252,250,255],[255,255,255,255]]},hotMetalBlue:{name:"Hot Metal Blue",numColors:256,colors:[[0,0,0,255],[0,0,2,255],[0,0,4,255],[0,0,6,255],[0,0,8,255],[0,0,10,255],[0,0,12,255],[0,0,14,255],[0,0,16,255],[0,0,17,255],[0,0,19,255],[0,0,21,255],[0,0,23,255],[0,0,25,255],[0,0,27,255],[0,0,29,255],[0,0,31,255],[0,0,33,255],[0,0,35,255],[0,0,37,255],[0,0,39,255],[0,0,41,255],[0,0,43,255],[0,0,45,255],[0,0,47,255],[0,0,49,255],[0,0,51,255],[0,0,53,255],[0,0,55,255],[0,0,57,255],[0,0,59,255],[0,0,61,255],[0,0,63,255],[0,0,65,255],[0,0,67,255],[0,0,69,255],[0,0,71,255],[0,0,73,255],[0,0,75,255],[0,0,77,255],[0,0,79,255],[0,0,81,255],[0,0,83,255],[0,0,84,255],[0,0,86,255],[0,0,88,255],[0,0,90,255],[0,0,92,255],[0,0,94,255],[0,0,96,255],[0,0,98,255],[0,0,100,255],[0,0,102,255],[0,0,104,255],[0,0,106,255],[0,0,108,255],[0,0,110,255],[0,0,112,255],[0,0,114,255],[0,0,116,255],[0,0,117,255],[0,0,119,255],[0,0,121,255],[0,0,123,255],[0,0,125,255],[0,0,127,255],[0,0,129,255],[0,0,131,255],[0,0,133,255],[0,0,135,255],[0,0,137,255],[0,0,139,255],[0,0,141,255],[0,0,143,255],[0,0,145,255],[0,0,147,255],[0,0,149,255],[0,0,151,255],[0,0,153,255],[0,0,155,255],[0,0,157,255],[0,0,159,255],[0,0,161,255],[0,0,163,255],[0,0,165,255],[0,0,167,255],[3,0,169,255],[6,0,171,255],[9,0,173,255],[12,0,175,255],[15,0,177,255],[18,0,179,255],[21,0,181,255],[24,0,183,255],[26,0,184,255],[29,0,186,255],[32,0,188,255],[35,0,190,255],[38,0,192,255],[41,0,194,255],[44,0,196,255],[47,0,198,255],[50,0,200,255],[52,0,197,255],[55,0,194,255],[57,0,191,255],[59,0,188,255],[62,0,185,255],[64,0,182,255],[66,0,179,255],[69,0,176,255],[71,0,174,255],[74,0,171,255],[76,0,168,255],[78,0,165,255],[81,0,162,255],[83,0,159,255],[85,0,156,255],[88,0,153,255],[90,0,150,255],[93,2,144,255],[96,4,138,255],[99,6,132,255],[102,8,126,255],[105,9,121,255],[108,11,115,255],[111,13,109,255],[114,15,103,255],[116,17,97,255],[119,19,91,255],[122,21,85,255],[125,23,79,255],[128,24,74,255],[131,26,68,255],[134,28,62,255],[137,30,56,255],[140,32,50,255],[143,34,47,255],[146,36,44,255],[149,38,41,255],[152,40,38,255],[155,41,35,255],[158,43,32,255],[161,45,29,255],[164,47,26,255],[166,49,24,255],[169,51,21,255],[172,53,18,255],[175,55,15,255],[178,56,12,255],[181,58,9,255],[184,60,6,255],[187,62,3,255],[190,64,0,255],[194,66,0,255],[198,68,0,255],[201,70,0,255],[205,72,0,255],[209,73,0,255],[213,75,0,255],[217,77,0,255],[221,79,0,255],[224,81,0,255],[228,83,0,255],[232,85,0,255],[236,87,0,255],[240,88,0,255],[244,90,0,255],[247,92,0,255],[251,94,0,255],[255,96,0,255],[255,98,3,255],[255,100,6,255],[255,102,9,255],[255,104,12,255],[255,105,15,255],[255,107,18,255],[255,109,21,255],[255,111,24,255],[255,113,26,255],[255,115,29,255],[255,117,32,255],[255,119,35,255],[255,120,38,255],[255,122,41,255],[255,124,44,255],[255,126,47,255],[255,128,50,255],[255,130,53,255],[255,132,56,255],[255,134,59,255],[255,136,62,255],[255,137,65,255],[255,139,68,255],[255,141,71,255],[255,143,74,255],[255,145,76,255],[255,147,79,255],[255,149,82,255],[255,151,85,255],[255,152,88,255],[255,154,91,255],[255,156,94,255],[255,158,97,255],[255,160,100,255],[255,162,103,255],[255,164,106,255],[255,166,109,255],[255,168,112,255],[255,169,115,255],[255,171,118,255],[255,173,121,255],[255,175,124,255],[255,177,126,255],[255,179,129,255],[255,181,132,255],[255,183,135,255],[255,184,138,255],[255,186,141,255],[255,188,144,255],[255,190,147,255],[255,192,150,255],[255,194,153,255],[255,196,156,255],[255,198,159,255],[255,200,162,255],[255,201,165,255],[255,203,168,255],[255,205,171,255],[255,207,174,255],[255,209,176,255],[255,211,179,255],[255,213,182,255],[255,215,185,255],[255,216,188,255],[255,218,191,255],[255,220,194,255],[255,222,197,255],[255,224,200,255],[255,226,203,255],[255,228,206,255],[255,229,210,255],[255,231,213,255],[255,233,216,255],[255,235,219,255],[255,237,223,255],[255,239,226,255],[255,240,229,255],[255,242,232,255],[255,244,236,255],[255,246,239,255],[255,248,242,255],[255,250,245,255],[255,251,249,255],[255,253,252,255],[255,255,255,255]]},pet20Step:{name:"PET 20 Step",numColors:256,colors:[[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255]]},gray:{name:"Gray",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,1,1]],green:[[0,0,0],[1,1,1]],blue:[[0,0,0],[1,1,1]]}},jet:{name:"Jet",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.35,0,0],[.66,1,1],[.89,1,1],[1,.5,.5]],green:[[0,0,0],[.125,0,0],[.375,1,1],[.64,1,1],[.91,0,0],[1,0,0]],blue:[[0,.5,.5],[.11,1,1],[.34,1,1],[.65,0,0],[1,0,0]]}},hsv:{name:"HSV",numColors:256,gamma:1,segmentedData:{red:[[0,1,1],[.15873,1,1],[.174603,.96875,.96875],[.333333,.03125,.03125],[.349206,0,0],[.666667,0,0],[.68254,.03125,.03125],[.84127,.96875,.96875],[.857143,1,1],[1,1,1]],green:[[0,0,0],[.15873,.9375,.9375],[.174603,1,1],[.507937,1,1],[.666667,.0625,.0625],[.68254,0,0],[1,0,0]],blue:[[0,0,0],[.333333,0,0],[.349206,.0625,.0625],[.507937,1,1],[.84127,1,1],[.857143,.9375,.9375],[1,.09375,.09375]]}},hot:{name:"Hot",numColors:256,gamma:1,segmentedData:{red:[[0,.0416,.0416],[.365079,1,1],[1,1,1]],green:[[0,0,0],[.365079,0,0],[.746032,1,1],[1,1,1]],blue:[[0,0,0],[.746032,0,0],[1,1,1]]}},cool:{name:"Cool",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,1,1]],green:[[0,1,1],[1,0,0]],blue:[[0,1,1],[1,1,1]]}},spring:{name:"Spring",numColors:256,gamma:1,segmentedData:{red:[[0,1,1],[1,1,1]],green:[[0,0,0],[1,1,1]],blue:[[0,1,1],[1,0,0]]}},summer:{name:"Summer",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,1,1]],green:[[0,.5,.5],[1,1,1]],blue:[[0,.4,.4],[1,.4,.4]]}},autumn:{name:"Autumn",numColors:256,gamma:1,segmentedData:{red:[[0,1,1],[1,1,1]],green:[[0,0,0],[1,1,1]],blue:[[0,0,0],[1,0,0]]}},winter:{name:"Winter",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,0,0]],green:[[0,0,0],[1,1,1]],blue:[[0,1,1],[1,.5,.5]]}},bone:{name:"Bone",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.746032,.652778,.652778],[1,1,1]],green:[[0,0,0],[.365079,.319444,.319444],[.746032,.777778,.777778],[1,1,1]],blue:[[0,0,0],[.365079,.444444,.444444],[1,1,1]]}},copper:{name:"Copper",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.809524,1,1],[1,1,1]],green:[[0,0,0],[1,.7812,.7812]],blue:[[0,0,0],[1,.4975,.4975]]}},spectral:{name:"Spectral",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.05,.4667,.4667],[.1,.5333,.5333],[.15,0,0],[.2,0,0],[.25,0,0],[.3,0,0],[.35,0,0],[.4,0,0],[.45,0,0],[.5,0,0],[.55,0,0],[.6,0,0],[.65,.7333,.7333],[.7,.9333,.9333],[.75,1,1],[.8,1,1],[.85,1,1],[.9,.8667,.8667],[.95,.8,.8],[1,.8,.8]],green:[[0,0,0],[.05,0,0],[.1,0,0],[.15,0,0],[.2,0,0],[.25,.4667,.4667],[.3,.6,.6],[.35,.6667,.6667],[.4,.6667,.6667],[.45,.6,.6],[.5,.7333,.7333],[.55,.8667,.8667],[.6,1,1],[.65,1,1],[.7,.9333,.9333],[.75,.8,.8],[.8,.6,.6],[.85,0,0],[.9,0,0],[.95,0,0],[1,.8,.8]],blue:[[0,0,0],[.05,.5333,.5333],[.1,.6,.6],[.15,.6667,.6667],[.2,.8667,.8667],[.25,.8667,.8667],[.3,.8667,.8667],[.35,.6667,.6667],[.4,.5333,.5333],[.45,0,0],[.5,0,0],[.55,0,0],[.6,0,0],[.65,0,0],[.7,0,0],[.75,0,0],[.8,0,0],[.85,0,0],[.9,0,0],[.95,0,0],[1,.8,.8]]}},coolwarm:{name:"CoolWarm",numColors:256,gamma:1,segmentedData:{red:[[0,.2298057,.2298057],[.03125,.26623388,.26623388],[.0625,.30386891,.30386891],[.09375,.342804478,.342804478],[.125,.38301334,.38301334],[.15625,.424369608,.424369608],[.1875,.46666708,.46666708],[.21875,.509635204,.509635204],[.25,.552953156,.552953156],[.28125,.596262162,.596262162],[.3125,.639176211,.639176211],[.34375,.681291281,.681291281],[.375,.722193294,.722193294],[.40625,.761464949,.761464949],[.4375,.798691636,.798691636],[.46875,.833466556,.833466556],[.5,.865395197,.865395197],[.53125,.897787179,.897787179],[.5625,.924127593,.924127593],[.59375,.944468518,.944468518],[.625,.958852946,.958852946],[.65625,.96732803,.96732803],[.6875,.969954137,.969954137],[.71875,.966811177,.966811177],[.75,.958003065,.958003065],[.78125,.943660866,.943660866],[.8125,.923944917,.923944917],[.84375,.89904617,.89904617],[.875,.869186849,.869186849],[.90625,.834620542,.834620542],[.9375,.795631745,.795631745],[.96875,.752534934,.752534934],[1,.705673158,.705673158]],green:[[0,.298717966,.298717966],[.03125,.353094838,.353094838],[.0625,.406535296,.406535296],[.09375,.458757618,.458757618],[.125,.50941904,.50941904],[.15625,.558148092,.558148092],[.1875,.604562568,.604562568],[.21875,.648280772,.648280772],[.25,.688929332,.688929332],[.28125,.726149107,.726149107],[.3125,.759599947,.759599947],[.34375,.788964712,.788964712],[.375,.813952739,.813952739],[.40625,.834302879,.834302879],[.4375,.849786142,.849786142],[.46875,.860207984,.860207984],[.5,.86541021,.86541021],[.53125,.848937047,.848937047],[.5625,.827384882,.827384882],[.59375,.800927443,.800927443],[.625,.769767752,.769767752],[.65625,.734132809,.734132809],[.6875,.694266682,.694266682],[.71875,.650421156,.650421156],[.75,.602842431,.602842431],[.78125,.551750968,.551750968],[.8125,.49730856,.49730856],[.84375,.439559467,.439559467],[.875,.378313092,.378313092],[.90625,.312874446,.312874446],[.9375,.24128379,.24128379],[.96875,.157246067,.157246067],[1,.01555616,.01555616]],blue:[[0,.753683153,.753683153],[.03125,.801466763,.801466763],[.0625,.84495867,.84495867],[.09375,.883725899,.883725899],[.125,.917387822,.917387822],[.15625,.945619588,.945619588],[.1875,.968154911,.968154911],[.21875,.98478814,.98478814],[.25,.995375608,.995375608],[.28125,.999836203,.999836203],[.3125,.998151185,.998151185],[.34375,.990363227,.990363227],[.375,.976574709,.976574709],[.40625,.956945269,.956945269],[.4375,.931688648,.931688648],[.46875,.901068838,.901068838],[.5,.865395561,.865395561],[.53125,.820880546,.820880546],[.5625,.774508472,.774508472],[.59375,.726736146,.726736146],[.625,.678007945,.678007945],[.65625,.628751763,.628751763],[.6875,.579375448,.579375448],[.71875,.530263762,.530263762],[.75,.481775914,.481775914],[.78125,.434243684,.434243684],[.8125,.387970225,.387970225],[.84375,.343229596,.343229596],[.875,.300267182,.300267182],[.90625,.259301199,.259301199],[.9375,.220525627,.220525627],[.96875,.184115123,.184115123],[1,.150232812,.150232812]]}},blues:{name:"Blues",numColors:256,gamma:1,segmentedData:{red:[[0,.9686274528503418,.9686274528503418],[.125,.8705882430076599,.8705882430076599],[.25,.7764706015586853,.7764706015586853],[.375,.6196078658103943,.6196078658103943],[.5,.41960784792900085,.41960784792900085],[.625,.25882354378700256,.25882354378700256],[.75,.12941177189350128,.12941177189350128],[.875,.0313725508749485,.0313725508749485],[1,.0313725508749485,.0313725508749485]],green:[[0,.9843137264251709,.9843137264251709],[.125,.9215686321258545,.9215686321258545],[.25,.8588235378265381,.8588235378265381],[.375,.7921568751335144,.7921568751335144],[.5,.6823529601097107,.6823529601097107],[.625,.572549045085907,.572549045085907],[.75,.4431372582912445,.4431372582912445],[.875,.3176470696926117,.3176470696926117],[1,.1882352977991104,.1882352977991104]],blue:[[0,1,1],[.125,.9686274528503418,.9686274528503418],[.25,.9372549057006836,.9372549057006836],[.375,.8823529481887817,.8823529481887817],[.5,.8392156958580017,.8392156958580017],[.625,.7764706015586853,.7764706015586853],[.75,.7098039388656616,.7098039388656616],[.875,.6117647290229797,.6117647290229797],[1,.41960784792900085,.41960784792900085]]}}},Wd={MINIMUM_SLAB_THICKNESS:.05,MAXIMUM_RAY_DISTANCE:1e6};Object.freeze(Wd);let Wu=Wd,Wc=.001,Wh=function e(t){for(let r of Object.getOwnPropertyNames(t)){let n=t[r];n&&"object"==typeof n&&e(n)}return Object.freeze(t)}({axial:{viewPlaneNormal:[0,0,-1],viewUp:[0,-1,0],viewRight:[1,0,0]},sagittal:{viewPlaneNormal:[1,0,0],viewUp:[0,0,1],viewRight:[0,1,0]},coronal:{viewPlaneNormal:[0,-1,0],viewUp:[0,0,1],viewRight:[1,0,0]}}),Wp=[{name:"CT-AAA",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"12 -3024 0 143.556 0 166.222 0.686275 214.389 0.696078 419.736 0.833333 3071 0.803922",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"24 -3024 0 0 0 143.556 0.615686 0.356863 0.184314 166.222 0.882353 0.603922 0.290196 214.389 1 1 1 419.736 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-AAA2",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"16 -3024 0 129.542 0 145.244 0.166667 157.02 0.5 169.918 0.627451 395.575 0.8125 1578.73 0.8125 3071 0.8125",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"32 -3024 0 0 0 129.542 0.54902 0.25098 0.14902 145.244 0.6 0.627451 0.843137 157.02 0.890196 0.47451 0.6 169.918 0.992157 0.870588 0.392157 395.575 1 0.886275 0.658824 1578.73 1 0.829256 0.957922 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Bone",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"8 -3024 0 -16.4458 0 641.385 0.715686 3071 0.705882",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"16 -3024 0 0 0 -16.4458 0.729412 0.254902 0.301961 641.385 0.905882 0.815686 0.552941 3071 1 1 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Bones",gradientOpacity:"4 0 1 985.12 1",specularPower:"1",scalarOpacity:"8 -1000 0 152.19 0 278.93 0.190476 952 0.2",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"20 -1000 0.3 0.3 1 -488 0.3 1 0.3 463.28 1 0 0 659.15 1 0.912535 0.0374849 953 1 0.3 0.3",diffuse:"1",interpolation:"1"},{name:"CT-Cardiac",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"12 -3024 0 -77.6875 0 94.9518 0.285714 179.052 0.553571 260.439 0.848214 3071 0.875",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"24 -3024 0 0 0 -77.6875 0.54902 0.25098 0.14902 94.9518 0.882353 0.603922 0.290196 179.052 1 0.937033 0.954531 260.439 0.615686 0 0 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Cardiac2",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"12 -3024 0 42.8964 0 163.488 0.428571 277.642 0.776786 1587 0.754902 3071 0.754902",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"24 -3024 0 0 0 42.8964 0.54902 0.25098 0.14902 163.488 0.917647 0.639216 0.0588235 277.642 1 0.878431 0.623529 1587 1 1 1 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Cardiac3",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"14 -3024 0 -86.9767 0 45.3791 0.169643 139.919 0.589286 347.907 0.607143 1224.16 0.607143 3071 0.616071",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"28 -3024 0 0 0 -86.9767 0 0.25098 1 45.3791 1 0 0 139.919 1 0.894893 0.894893 347.907 1 1 0.25098 1224.16 1 1 1 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Chest-Contrast-Enhanced",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"10 -3024 0 67.0106 0 251.105 0.446429 439.291 0.625 3071 0.616071",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"20 -3024 0 0 0 67.0106 0.54902 0.25098 0.14902 251.105 0.882353 0.603922 0.290196 439.291 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Chest-Vessels",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"10 -3024 0 -1278.35 0 22.8277 0.428571 439.291 0.625 3071 0.616071",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"20 -3024 0 0 0 -1278.35 0.54902 0.25098 0.14902 22.8277 0.882353 0.603922 0.290196 439.291 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"1",interpolation:"1"},{name:"CT-Coronary-Arteries",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"12 -2048 0 136.47 0 159.215 0.258929 318.43 0.571429 478.693 0.776786 3661 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"24 -2048 0 0 0 136.47 0 0 0 159.215 0.159804 0.159804 0.159804 318.43 0.764706 0.764706 0.764706 478.693 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Coronary-Arteries-2",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"14 -2048 0 142.677 0 145.016 0.116071 192.174 0.5625 217.24 0.776786 384.347 0.830357 3661 0.830357",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"28 -2048 0 0 0 142.677 0 0 0 145.016 0.615686 0 0.0156863 192.174 0.909804 0.454902 0 217.24 0.972549 0.807843 0.611765 384.347 0.909804 0.909804 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Coronary-Arteries-3",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"14 -2048 0 128.643 0 129.982 0.0982143 173.636 0.669643 255.884 0.857143 584.878 0.866071 3661 1",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"28 -2048 0 0 0 128.643 0 0 0 129.982 0.615686 0 0.0156863 173.636 0.909804 0.454902 0 255.884 0.886275 0.886275 0.886275 584.878 0.968627 0.968627 0.968627 3661 1 1 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Cropped-Volume-Bone",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"10 -2048 0 -451 0 -450 1 1050 1 3661 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"20 -2048 0 0 0 -451 0 0 0 -450 0.0556356 0.0556356 0.0556356 1050 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Fat",gradientOpacity:"6 0 1 985.12 1 988 1",specularPower:"1",scalarOpacity:"14 -1000 0 -100 0 -99 0.15 -60 0.15 -59 0 101.2 0 952 0",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"36 -1000 0.3 0.3 1 -497.5 0.3 1 0.3 -99 0 0 1 -76.946 0 1 0 -65.481 0.835431 0.888889 0.0165387 83.89 1 0 0 463.28 1 0 0 659.15 1 0.912535 0.0374849 2952 1 0.300267 0.299886",diffuse:"1",interpolation:"1"},{name:"CT-Liver-Vasculature",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"14 -2048 0 149.113 0 157.884 0.482143 339.96 0.660714 388.526 0.830357 1197.95 0.839286 3661 0.848214",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"28 -2048 0 0 0 149.113 0 0 0 157.884 0.501961 0.25098 0 339.96 0.695386 0.59603 0.36886 388.526 0.854902 0.85098 0.827451 1197.95 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Lung",gradientOpacity:"6 0 1 985.12 1 988 1",specularPower:"1",scalarOpacity:"12 -1000 0 -600 0 -599 0.15 -400 0.15 -399 0 2952 0",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"24 -1000 0.3 0.3 1 -600 0 0 1 -530 0.134704 0.781726 0.0724558 -460 0.929244 1 0.109473 -400 0.888889 0.254949 0.0240258 2952 1 0.3 0.3",diffuse:"1",interpolation:"1"},{name:"CT-MIP",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"8 -3024 0 -637.62 0 700 1 3071 1",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"16 -3024 0 0 0 -637.62 1 1 1 700 1 1 1 3071 1 1 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Muscle",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"10 -3024 0 -155.407 0 217.641 0.676471 419.736 0.833333 3071 0.803922",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"20 -3024 0 0 0 -155.407 0.54902 0.25098 0.14902 217.641 0.882353 0.603922 0.290196 419.736 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Pulmonary-Arteries",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"14 -2048 0 -568.625 0 -364.081 0.0714286 -244.813 0.401786 18.2775 0.607143 447.798 0.830357 3592.73 0.839286",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"28 -2048 0 0 0 -568.625 0 0 0 -364.081 0.396078 0.301961 0.180392 -244.813 0.611765 0.352941 0.0705882 18.2775 0.843137 0.0156863 0.156863 447.798 0.752941 0.752941 0.752941 3592.73 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Soft-Tissue",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"10 -2048 0 -167.01 0 -160 1 240 1 3661 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"20 -2048 0 0 0 -167.01 0 0 0 -160 0.0556356 0.0556356 0.0556356 240 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Air",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"8 -3024 0.705882 -900.0 0.715686 -500.0 0 3071 0",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"16 -3024 1 1 1 -900.0 0.2 1.0 1.0 -500.0 0.3 0.3 1.0 3071 0 0 0 ",diffuse:"0.9",interpolation:"1"},{name:"MR-Angio",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"12 -2048 0 151.354 0 158.279 0.4375 190.112 0.580357 200.873 0.732143 3661 0.741071",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"24 -2048 0 0 0 151.354 0 0 0 158.279 0.74902 0.376471 0 190.112 1 0.866667 0.733333 200.873 0.937255 0.937255 0.937255 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"MR-Default",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"12 0 0 20 0 40 0.15 120 0.3 220 0.375 1024 0.5",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"24 0 0 0 0 20 0.168627 0 0 40 0.403922 0.145098 0.0784314 120 0.780392 0.607843 0.380392 220 0.847059 0.835294 0.788235 1024 1 1 1",diffuse:"1",interpolation:"1"},{name:"MR-MIP",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"8 0 0 98.3725 0 416.637 1 2800 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"16 0 1 1 1 98.3725 1 1 1 416.637 1 1 1 2800 1 1 1",diffuse:"1",interpolation:"1"},{name:"MR-T2-Brain",gradientOpacity:"4 0 1 160.25 1",specularPower:"40",scalarOpacity:"10 0 0 36.05 0 218.302 0.171429 412.406 1 641 1",specular:"0.5",shade:"1",ambient:"0.3",colorTransfer:"16 0 0 0 0 98.7223 0.956863 0.839216 0.192157 412.406 0 0.592157 0.807843 641 1 1 1",diffuse:"0.6",interpolation:"1"},{name:"DTI-FA-Brain",gradientOpacity:"4 0 1 0.9950 1",specularPower:"40",scalarOpacity:"16 0 0 0 0 0.3501 0.0158 0.49379 0.7619 0.6419 1 0.9920 1 0.9950 0 0.9950 0",specular:"0.5",shade:"1",ambient:"0.3",colorTransfer:"28 0 1 0 0 0 1 0 0 0.24974 0.4941 1 0 0.49949 0 0.9882 1 0.7492 0.51764 0 1 0.9950 1 0 0 0.9950 1 0 0",diffuse:"0.9",interpolation:"1"}],Wm={},Wf=e=>Wm[e],Wg=()=>{let e=Object.keys(Wm).map(e=>Wm[e]);return e.sort((e,t)=>"_"===e.id[0]&&"_"!==t.id[0]?1:"_"!==e.id[0]&&"_"===t.id[0]?-1:0),e},Wy=e=>e&&"object"==typeof e&&"[object RegExp]"!==Object.prototype.toString.call(e)&&"[object Date]"!==Object.prototype.toString.call(e),Wv=(e,t)=>t&&!0===t.clone&&Wy(e)?Wx(Array.isArray(e)?[]:{},e,t):e,Wb=(e,t,r)=>{let n=e.slice();return t.forEach(function(t,a){void 0===n[a]?n[a]=Wv(t,r):Wy(t)?n[a]=Wx(e[a],t,r):-1===e.indexOf(t)&&(n[a]=Wv(t,r))}),n},Wx=(e={},t={},r)=>{let n,a=Array.isArray(t),i=(r||{arrayMerge:Wb}).arrayMerge||Wb;return a?Array.isArray(e)?i(e,t,r):Wv(t,r):(n={},Wy(e)&&Object.keys(e).forEach(function(t){n[t]=Wv(e[t],r)}),Object.keys(t).forEach(function(a){Wy(t[a])&&e[a]?n[a]=Wx(e[a],t[a],r):n[a]=Wv(t[a],r)}),n)},Ww=Symbol("Comlink.proxy"),WC=Symbol("Comlink.endpoint"),Wk=Symbol("Comlink.releaseProxy"),WM=Symbol("Comlink.finalizer"),WS=Symbol("Comlink.thrown"),WI=e=>"object"==typeof e&&null!==e||"function"==typeof e,WT=new Map([["proxy",{canHandle:e=>WI(e)&&e[Ww],serialize(e){let{port1:t,port2:r}=new MessageChannel;return function e(t,r=globalThis,n=["*"]){r.addEventListener("message",function a(i){let o;if(!i||!i.data)return;if(!function(e,t){for(let r of e)if(t===r||"*"===r||r instanceof RegExp&&r.test(t))return!0;return!1}(n,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);let{id:s,type:l,path:d}=Object.assign({path:[]},i.data),u=(i.data.argumentList||[]).map(WL);try{var c,h,p;let r=d.slice(0,-1).reduce((e,t)=>e[t],t),n=d.reduce((e,t)=>e[t],t);switch(l){case"GET":o=n;break;case"SET":r[d.slice(-1)[0]]=WL(i.data.value),o=!0;break;case"APPLY":o=n.apply(r,u);break;case"CONSTRUCT":c=new n(...u),o=Object.assign(c,{[Ww]:!0});break;case"ENDPOINT":{let{port1:r,port2:n}=new MessageChannel;e(t,n),h=r,p=[r],WN.set(h,p),o=h}break;case"RELEASE":o=void 0;break;default:return}}catch(e){o={value:e,[WS]:0}}Promise.resolve(o).catch(e=>({value:e,[WS]:0})).then(e=>{let[n,i]=WR(e);r.postMessage(Object.assign(Object.assign({},n),{id:s}),i),"RELEASE"===l&&(r.removeEventListener("message",a),W_(r),WM in t&&"function"==typeof t[WM]&&t[WM]())}).catch(e=>{let[t,n]=WR({value:TypeError("Unserializable return value"),[WS]:0});r.postMessage(Object.assign(Object.assign({},t),{id:s}),n)})}),r.start&&r.start()}(e,t),[r,[r]]},deserialize:e=>{var t;let r;return e.start(),t=e,r=new Map,t.addEventListener("message",function(e){let{data:t}=e;if(!t||!t.id)return;let n=r.get(t.id);if(n)try{n(t)}finally{r.delete(t.id)}}),function e(t,r,n=[],a=function(){}){let i,o=!1,s=new Proxy(a,{get(a,i){if(WP(o),i===Wk)return()=>{WA&&WA.unregister(s),WE(t),r.clear(),o=!0};if("then"===i){if(0===n.length)return{then:()=>s};let e=Wj(t,r,{type:"GET",path:n.map(e=>e.toString())}).then(WL);return e.then.bind(e)}return e(t,r,[...n,i])},set(e,a,i){WP(o);let[s,l]=WR(i);return Wj(t,r,{type:"SET",path:[...n,a].map(e=>e.toString()),value:s},l).then(WL)},apply(a,i,s){WP(o);let l=n[n.length-1];if(l===WC)return Wj(t,r,{type:"ENDPOINT"}).then(WL);if("bind"===l)return e(t,r,n.slice(0,-1));let[d,u]=WO(s);return Wj(t,r,{type:"APPLY",path:n.map(e=>e.toString()),argumentList:d},u).then(WL)},construct(e,a){WP(o);let[i,s]=WO(a);return Wj(t,r,{type:"CONSTRUCT",path:n.map(e=>e.toString()),argumentList:i},s).then(WL)}});return i=(WD.get(t)||0)+1,WD.set(t,i),WA&&WA.register(s,t,s),s}(t,r,[],void 0)}}],["throw",{canHandle:e=>WI(e)&&WS in e,serialize:({value:e})=>[e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[]],deserialize(e){if(e.isError)throw Object.assign(Error(e.value.message),e.value);throw e.value}}]]);function W_(e){"MessagePort"===e.constructor.name&&e.close()}function WP(e){if(e)throw Error("Proxy has been released and is not useable")}function WE(e){return Wj(e,new Map,{type:"RELEASE"}).then(()=>{W_(e)})}let WD=new WeakMap,WA="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{let t=(WD.get(e)||0)-1;WD.set(e,t),0===t&&WE(e)});function WO(e){var t;let r=e.map(WR);return[r.map(e=>e[0]),(t=r.map(e=>e[1]),Array.prototype.concat.apply([],t))]}let WN=new WeakMap;function WR(e){for(let[t,r]of WT)if(r.canHandle(e)){let[n,a]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},a]}return[{type:"RAW",value:e},WN.get(e)||[]]}function WL(e){switch(e.type){case"HANDLER":return WT.get(e.name).deserialize(e.value);case"RAW":return e.value}}function Wj(e,t,r,n){return new Promise(a=>{let i=[,,,,].fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");t.set(i,a),e.start&&e.start(),e.postMessage(Object.assign({id:i},r),n)})}function WV(){return"function"==typeof crypto.randomUUID?crypto.randomUUID():"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}let{pp:WF,tZ:WB,gE:WW,uu:WU,UA:Wz,LL:WH,_E:WG,sM:Wq,Qe:W$,xC:WK,RZ:WY,UX:WX,HL:WZ,U5:WJ,Rm:WQ}=V,{bM:W0}=V;Wz.getLogger("growCut");let W1=WU.getLogger("requestPool","requestPoolManager");class W2{constructor(e){this.numRequests={[jj.Interaction]:0,[jj.Thumbnail]:0,[jj.Prefetch]:0,[jj.Compute]:0},this.id=e||WV(),this.requestPool={[jj.Interaction]:{0:[]},[jj.Thumbnail]:{0:[]},[jj.Prefetch]:{0:[]},[jj.Compute]:{0:[]}},this.grabDelay=5,this.awake=!1,this.numRequests={[jj.Interaction]:0,[jj.Thumbnail]:0,[jj.Prefetch]:0,[jj.Compute]:0},this.maxNumRequests={[jj.Interaction]:6,[jj.Thumbnail]:6,[jj.Prefetch]:5,[jj.Compute]:1e3}}setMaxSimultaneousRequests(e,t){this.maxNumRequests[e]=t}getMaxSimultaneousRequests(e){return this.maxNumRequests[e]}destroy(){this.timeoutHandle&&window.clearTimeout(this.timeoutHandle)}addRequest(e,t,r,n=0){void 0===this.requestPool[t][n]&&(this.requestPool[t][n]=[]),this.requestPool[t][n].push({requestFn:e,type:t,additionalDetails:r}),this.startGrabbing()}filterRequests(e){Object.keys(this.requestPool).forEach(t=>{let r=this.requestPool[t];Object.keys(r).forEach(t=>{r[t]=r[t].filter(t=>e(t))})})}clearRequestStack(e){if(!this.requestPool[e])throw Error(`No category for the type ${e} found`);this.requestPool[e]={0:[]}}sendRequests(e){let t=this.maxNumRequests[e]-this.numRequests[e],r=0;for(let n=0;n<t;n++){let t=this.getNextRequest(e);if(null===t)return!1;if(t){let n;this.numRequests[e]++,this.awake=!0;try{n=t.requestFn()}catch(e){W1.warn("sendRequest failed",e)}n?.finally?n.finally(()=>{this.numRequests[e]--,this.startAgain()}):(this.numRequests[e]--,r++)}}return r&&this.startAgain(),!0}getNextRequest(e){for(let t of this.getSortedPriorityGroups(e))if(this.requestPool[e][t].length)return this.requestPool[e][t].shift();return null}startGrabbing(){let e=this.sendRequests(jj.Interaction),t=this.sendRequests(jj.Thumbnail),r=this.sendRequests(jj.Prefetch),n=this.sendRequests(jj.Compute);e||t||r||n||(this.awake=!1)}startAgain(){this.awake&&(void 0!==this.grabDelay?this.timeoutHandle||(this.timeoutHandle=window.setTimeout(()=>{this.timeoutHandle=null,this.startGrabbing()},this.grabDelay)):this.startGrabbing())}getSortedPriorityGroups(e){return Object.keys(this.requestPool[e]).map(Number).filter(t=>this.requestPool[e][t].length).sort((e,t)=>e-t)}getRequestPool(){return this.requestPool}}WU.getLogger("webWorkerManager","webWorkerManager");function W5(e,{ext:t,filterType:r,texData:n,internalFormat:a,glDataType:i}){try{let o;if(t&&!(o=e.getExtension(t)))return!1;let s=e.createTexture();e.bindTexture(e.TEXTURE_2D,s),e.texImage2D(e.TEXTURE_2D,0,a(e,o),5,1,0,e.RED,i(e,o),n);let l="LINEAR"===r?e.LINEAR:e.NEAREST;e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,l),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,l),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.POINTS,0,1);let d=new Uint8Array(4);e.readPixels(1,1,1,1,e.RGBA,e.UNSIGNED_BYTE,d);let[u,c,h]=d;return e.deleteTexture(s),u===c&&c===h&&0!==u}catch(e){return!1}}let W3="cornerstone3D.renderingCapabilities",W4=/swiftshader|llvmpipe|softpipe|software|microsoft basic render/i,W8={norm16:!1,norm16Linear:!1,float:!1,floatLinear:!1,halfFloat:!1,halfFloatLinear:!1},W6=null;function W9(){return W6||(W6=function({useCache:e=!0}={}){let t=function(){let e={webgl:!1,maxTextureSize:0,renderer:""};if("u"<typeof document)return e;try{let t=document.createElement("canvas").getContext("webgl2");if(!t)return e;e.webgl=!0,e.maxTextureSize=Number(t.getParameter(t.MAX_TEXTURE_SIZE))||0;let r=t.getExtension("WEBGL_debug_renderer_info"),n=r?t.getParameter(r.UNMASKED_RENDERER_WEBGL):t.getParameter(t.RENDERER);e.renderer="string"==typeof n?n:"";let a=t.getExtension("WEBGL_lose_context");a&&a.loseContext()}catch{}return e}();if(!t.webgl)return{...t,...W8,softwareRasterizer:!1};let r=e?function(e){try{let t=window.localStorage?.getItem(W3);if(!t)return null;let r=JSON.parse(t);if(r?.probeVersion!==1||r?.renderer!==e||"object"!=typeof r?.formats||r?.formats===null)return null;return{...W8,...r.formats}}catch{return null}}(t.renderer):null;if(!r){let e=function(){let e=function(){try{let e=document.createElement("canvas");e.width=4,e.height=4;let t=e.getContext("webgl2");if(!t)return null;let r=`#version 300 es
10
10
  void main() {
11
11
  gl_PointSize = 4.0;
12
12
  gl_Position = vec4(0, 0, 0, 1);