Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lunit/insight-viewer

Package Overview
Dependencies
Maintainers
8
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lunit/insight-viewer - npm Package Compare versions

Comparing version 5.1.0-alpha.6 to 5.1.0-alpha.7

contour.ts

2

dist/index.esm.js

@@ -1,2 +0,2 @@

import e,{useState as r,useEffect as n,useCallback as t,forwardRef as i,useRef as o,useReducer as a}from"react";import{Subject as u,merge as c,fromEvent as l,from as s}from"rxjs";import{useResizeDetector as d}from"react-resize-detector";import f from"cornerstone-core";import{tap as v,filter as m,switchMap as p,map as g,takeUntil as w,concatMap as h,catchError as y}from"rxjs/operators";import b from"consola";import x from"ky";function C(){return C=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},C.apply(this,arguments)}function I(e,r){if(null==e)return{};var n,t,i={},o=Object.keys(e);for(t=0;t<o.length;t++)r.indexOf(n=o[t])>=0||(i[n]=e[n]);return i}var P,E=new u,S=new u,V=new u,q=function(e){return V.next({loaded:e.loaded,total:e.total})};function j(e){var r=e.loadedCount,n=e.totalCount,t=e.progress;return r===n?100:Math.floor((100*r+(null!=t?t:0))*(1/n))}var k={position:"absolute",top:"50%",width:"100%",transform:"translateY(-50%)",textAlign:"center"};function W(t){var i=t.Progress,o=r({progress:void 0,hidden:!0}),a=o[0],u=a.progress,l=a.hidden,s=o[1];return n(function(){var e=!1,r=E.asObservable(),n=V.asObservable(),t=0,i=1,o=0;return P=c(r,n).subscribe(function(r){"number"==typeof r?o=r:(t=r.loaded,i=r.total),e||s(function(e){return C({},e,{progress:j({loadedCount:t,totalCount:i,progress:o})})})}),function(){e=!0,P.unsubscribe()}},[]),n(function(){100===u&&s(function(e){return C({},e,{hidden:!0})}),0===u&&s(function(e){return C({},e,{hidden:!1})})},[u]),e.createElement("div",{style:k,"data-cy-loading":l?"":"loading"},!l&&e.createElement(i,{progress:null!=u?u:0}))}var D={scale:0,invert:!1,hflip:!1,vflip:!1,x:0,y:0,windowWidth:0,windowCenter:0};function A(e){if(!e)return D;var r=e.translation,n=e.voi;return{scale:e.scale,invert:e.invert,hflip:e.hflip,vflip:e.vflip,x:r.x,y:r.y,windowWidth:n.windowWidth,windowCenter:n.windowCenter}}function O(e,r){var n,t,i,o,a,u,c,l;return void 0===r&&(r={}),C({},e,{scale:null!=(n=r.scale)?n:e.scale,invert:null!=(t=r.invert)?t:e.invert,hflip:null!=(i=r.hflip)?i:e.hflip,vflip:null!=(o=r.vflip)?o:e.vflip,translation:{x:null!=(a=r.x)?a:e.translation.x,y:null!=(u=r.y)?u:e.translation.y},voi:{windowWidth:null!=(c=r.windowWidth)?c:e.voi.windowWidth,windowCenter:null!=(l=r.windowCenter)?l:e.voi.windowCenter}})}function Y(){return f}function z(e,r){return f.loadImage(e,r)}function R(e){return f.getViewport(e)}function _(e,r){return f.setViewport(e,r)}var M={position:"relative",width:"100%",height:"100%",backgroundColor:"#000",userSelect:"none"},X=i(function(r,n){var i=r.Progress,o=r.children,a=function(e){var r=e,n=null==r?void 0:r.current,i=t(function(){if(n)return function(e){f.resize(e)}(n)},[n]);return{resizeRef:d({targetRef:r,onResize:i,skipOnMount:!1}).ref}}(n);return e.createElement("div",{ref:a.resizeRef,style:M,className:"cornerstone-canvas-wrapper","data-cy":"cornerstone-canvas-wrapper"},i&&e.createElement(W,{Progress:i}),e.createElement("canvas",{className:"cornerstone-canvas"}),o)}),B=e.memo(X);function T(e){e.preventDefault()}X.displayName="Forwarded",B.displayName="ViewerWrapper";var F,L,N,G,H={pan:function(e,r){return{x:e.translation.x+r.x/e.scale,y:e.translation.y+r.y/e.scale}},adjust:function(e,r){return{windowWidth:e.voi.windowWidth+r.x/e.scale,windowCenter:e.voi.windowCenter+r.y/e.scale}}};function J(r){var t,i=r.image,a=r.Progress,u=r.viewport,c=r.interaction,s=r.onViewportChange,d=r.children,h=o(null),y=o(u),b=function(){var e=o();return n(function(){return G=S.asObservable().subscribe(function(r){e.current=r}),function(){G.unsubscribe()}},[]),e}();return n(function(){if(t)return function(e){f.enable(e)}(t),function(){!function(e){f.disable(e)}(t)}},[t=h.current]),function(e){var r=e.element,t=e.image,i=e.viewportRef,a=e.onViewportChange,u=o(0);n(function(){var e;if(t&&r){u.current+=1;var n=function(e,r,n){var t=f.getDefaultViewportForImage(e,r),i=n?O(t,n):t;return f.displayImage(e,r,i),{viewport:i,defaultViewport:t,image:r}}(r,t,1===u.current?null==i||null==(e=i.current)?void 0:e._default:null==i?void 0:i.current),o=n.viewport;S.next(n.defaultViewport),a&&a(A(o))}},[r,t,i,a])}({element:h.current,image:i,viewportRef:y,onViewportChange:s}),function(e){var r=e.element,t=e.viewport,i=e.initialViewport,o=e.onViewportChange;n(function(){if(r&&t){var e,n=(null==t?void 0:t._reset)&&i,a=n?i:R(r);a&&(_(r,O(a,t)),n&&o&&o(C({},A(i),null!=(e=null==t?void 0:t._reset)?e:{})))}},[r,t,i,o])}({element:h.current,viewport:u,initialViewport:null==b?void 0:b.current,onViewportChange:s}),function(e){var r=e.element,t=e.interaction,i=e.viewport,o=e.onViewportChange;!function(e){var r=e.element,t=e.interaction;n(function(){if(r){var e=l(r,"wheel");return N=e.pipe(m(function(e){return 0!==e.deltaY}),v(function(e){e.preventDefault()})).subscribe(function(e){null!=t&&t.mouseWheel&&(null==t||t.mouseWheel(e.deltaX,e.deltaY))}),function(){N.unsubscribe()}}},[t,r,e.onViewportChange])}({element:r,interaction:t,onViewportChange:o}),function(e){var r=e.element,t=e.interaction,i=e.onViewportChange;n(function(){if(t&&r&&(null==r||r.removeEventListener("contextmenu",T),t.primaryDrag||t.secondaryDrag)){var e,n=l(r,"mousedown"),o=l(document,"mousemove"),a=l(document,"mouseup");return F=n.pipe(v(function(r){var n=r.button;0===n&&(e="primaryDrag"),2===n&&(e="secondaryDrag")}),m(function(){return void 0!==e}),v(function(e){2===e.button&&(null==r||r.addEventListener("contextmenu",T))}),p(function(e){var r=e.pageX,n=e.pageY;return o.pipe(g(function(e){e.preventDefault();var t=e.pageX-r,i=e.pageY-n;return r=e.pageX,n=e.pageY,{x:t,y:i}}),w(a))})).subscribe(function(n){var o=R(r);o&&e&&function(e){var r,n,t=e.element,i=e.dragged,o=e.viewport,a=e.onViewportChange,u=e.interaction[e.dragType];switch(typeof u){case"string":(r=u)&&(a?a(function(e){var n;return C({},e,null==(n=H[r])?void 0:n.call(H,o,i))}):_(t,O(o,null==(n=H[r])?void 0:n.call(H,o,i))));break;case"function":u({viewport:o,delta:i})}}({interaction:t,dragType:e,element:r,viewport:o,dragged:n,onViewportChange:i})}),function(){F.unsubscribe()}}},[r,t,i])}({element:r,interaction:t,onViewportChange:o}),function(e){var r=e.element,t=e.interaction,i=e.viewport;n(function(){if(t&&r&&(null==r||r.removeEventListener("contextmenu",T),t.primaryClick||t.secondaryClick)){var e,n=l(r,"mousedown");if(t)return L=n.pipe(v(function(r){var n=r.button;0===n&&(e="primaryClick"),2===n&&(e="secondaryClick")}),m(function(){return void 0!==e}),v(function(e){2===e.button&&(null==r||r.addEventListener("contextmenu",T))}),g(function(e){return{clientX:e.clientX,clientY:e.clientY,currentTarget:e.currentTarget}})).subscribe(function(n){var o,a=n.clientX,u=n.clientY,c=n.currentTarget.getBoundingClientRect(),l=function(e,r){var n;if(r)return{x:r.x,y:r.y};var t=(null!=(n=R(e))?n:{}).translation,i=(t=void 0===t?{}:t).x,o=t.y;return{x:void 0===i?0:i,y:void 0===o?0:o}}(r,i);e&&(null==(o=t[e])||o.call(t,-l.x+a-c.left,-l.y+u-c.top))}),function(){L.unsubscribe()}}},[r,t,i])}({element:r,interaction:t,viewport:i})}({element:h.current,interaction:c,viewport:u,onViewportChange:s}),n(function(){y.current=u},[u]),e.createElement(B,{ref:h,Progress:a},d)}var K={onError:function(e){b.error(e)},Progress:void 0,requestInterceptor:function(e){}},Q={scale:0,invert:!1,hflip:!1,vflip:!1,x:0,y:0,windowWidth:0,windowCenter:0};function U(e){if(function(e){return e instanceof Error}(e))return e;if(function(e){var r;return void 0!==(null==e?void 0:e.error)&&void 0!==(null==e||null==(r=e.error)?void 0:r.message)}(e)){var r,n,t=new Error(e.error.message);return t.status=null==e||null==(r=e.error)||null==(n=r.response)?void 0:n.status,t}return new Error("error unknown")}var Z=function(e){try{var r,n,t;return Promise.resolve(function(e,i){try{var o=Promise.resolve(Promise.all([import("cornerstone-wado-image-loader"),import("dicom-parser")])).then(function(e){return t=(r=e)[1],(n=r[0]).external.cornerstone=Y(),n.external.dicomParser=t,n})}catch(e){return i(e)}return o&&o.then?o.then(void 0,i):o}(0,function(r){e(U(r))}))}catch(e){return Promise.reject(e)}},$=function(e){try{var r;return Promise.resolve(function(e,n){try{var t=Promise.resolve(import("cornerstone-web-image-loader")).then(function(e){return(r=e).external.cornerstone=Y(),r})}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(0,function(r){e(U(r))}))}catch(e){return Promise.reject(e)}};function ee(e,n){var t=r(!1),i=t[0],o=t[1],a="dicom"==(e.web?"web":"dicom")?Z:$;return function(){try{var e=function(){if(!i)return Promise.resolve(a(n)).then(function(e){o(!!e)})}();e&&e.then&&e.then(function(){})}catch(e){Promise.reject(e)}}(),i}var re=function(e){return function(r){try{var n=x.create({hooks:{beforeRequest:[function(r){e(r)}]},onDownloadProgress:function(e){try{return r=0===e.percent&&0===e.totalBytes&&e.transferredBytes>0?100:Math.round(100*e.percent),E.next(r),Promise.resolve()}catch(e){return Promise.reject(e)}var r}});return Promise.resolve(n.get(r)).then(function(e){return e.arrayBuffer()})}catch(e){return Promise.reject(e)}}};function ne(e){var r=e.stateMap,n=e.value;return n===e.size?r.set(n-1,"success"):r.set(n-1,"success").set(n,"loading")}function te(e){return void 0===e?[]:Array.isArray(e)?e:[e]}var ie=["onError","requestInterceptor"],oe=["requestInterceptor","onError"],ae=function(e){var t=e.requestInterceptor,i=void 0===t?K.requestInterceptor:t,o=e.onError,a=void 0===o?K.onError:o,u=function(e){var t,i,o,a=e.onError,u=e.requestInterceptor,c=I(e,ie),l=(t=c).wadouri?{ids:te(t.wadouri),scheme:"wadouri"}:t.dicomfile?{ids:te(t.dicomfile),scheme:"dicomfile"}:t.web?{ids:te(t.web),scheme:"web"}:{ids:[],scheme:void 0},d=l.ids,f=l.scheme,v=r({images:[],loadingStates:(i=Array.isArray(d)?d.length:0,o=Array(i).fill("initial"),new Map(o.map(function(e,r){return[r,e]}))),_currentIndex:-1}),m=v[0],p=m.images,w=m.loadingStates,b=v[1],x=ee(c,a);return n(function(){d&&0!==d.length&&f&&x&&(b(function(e){return C({},e,{loadingStates:e.loadingStates.set(0,"loading")})}),function(e){var r=e.images,n=e.imageScheme,t=e.requestInterceptor,i=0;return q({loaded:i,total:r.length}),s(r).pipe(h(function(e){return function(e,r,n){return z(e,{loader:"dicomfile"===r?void 0:re(n)})}(e,n,t)}),g(function(e){return q({loaded:i+=1,total:r.length}),{image:e,loaded:i}}),y(function(e){throw U(e)}))}({images:d,imageScheme:f,requestInterceptor:u}).subscribe({next:function(e){var r=e.image,n=e.loaded;b(function(e){return{images:[].concat(e.images,[r]),loadingStates:ne({size:d.length,stateMap:e.loadingStates,value:n}),_currentIndex:n-1}})},error:function(e){a(e),b(function(e){return C({},e,{loadingStates:e.loadingStates.set(e._currentIndex+1,"fail")})})}}))},[d,f,a,u,x]),{images:p,loadingStates:Array.from(w.values())}}(C({},I(e,oe),{onError:a,requestInterceptor:i})),c=u.images;return{loadingStates:u.loadingStates,images:void 0===c?[]:c}};function ue(e){var n=r(C({},e?C({},Q,{_default:e}):Q)),t=n[0],i=n[1];return{viewport:t,setViewport:i,resetViewport:function(){i(C({},t,{_reset:e}))},initialized:t.scale!==Q.scale}}function ce(){var e,n=r(((e={}).primaryDrag=void 0,e.secondaryDrag=void 0,e.primaryClick=void 0,e.secondaryClick=void 0,e.mouseWheel=void 0,e));return{interaction:n[0],setInteraction:n[1]}}function le(e,r){var n=r.payload;switch(r.type){case"loading":return C({},e,{loadingState:"loading"});case"success":return{loadingState:"success",image:n};case"fail":return C({},e,{loadingState:"fail"});default:return e}}var se={loadingState:"initial",image:void 0};function de(e){if(void 0!==e)return Array.isArray(e)?e[0]:e}var fe=["requestInterceptor","onError"],ve=function(e){var r=e.requestInterceptor,t=void 0===r?K.requestInterceptor:r,i=e.onError,o=void 0===i?K.onError:i,u=I(e,fe),c=function(e){return e.wadouri?{id:de(e.wadouri),scheme:"wadouri"}:e.dicomfile?{id:de(e.dicomfile),scheme:"dicomfile"}:e.web?{id:de(e.web),scheme:"web"}:{id:void 0,scheme:void 0}}(u),l=c.id,s=c.scheme,d=a(le,se),f=d[0],v=f.loadingState,m=f.image,p=d[1],g=ee(u,o);return n(function(){g&&l&&s&&(p({type:"loading"}),function(e){var r=e.imageId,n=e.imageScheme,t=e.requestInterceptor,i=e.onError;try{return Promise.resolve(function(e,i){try{var o=Promise.resolve(function(e){var r=e.imageId,n=e.imageScheme,t=e.requestInterceptor;try{return Promise.resolve(function(e,i){try{var o=Promise.resolve(z(r,{loader:"dicomfile"===n?void 0:re(t)}))}catch(e){return i(e)}return o&&o.then?o.then(void 0,i):o}(0,function(e){throw U(e)}))}catch(e){return Promise.reject(e)}}({imageId:r,imageScheme:n,requestInterceptor:t}))}catch(e){return i(e)}return o&&o.then?o.then(void 0,i):o}(0,function(e){throw i(U(e)),e}))}catch(e){return Promise.reject(e)}}({imageId:l,imageScheme:s,requestInterceptor:t,onError:o}).then(function(e){p({type:"success",payload:e})}).catch(function(){return p({type:"fail"})}))},[g,l,s,t,o]),{image:m,loadingState:v}},me=function(e){var n=e.initial,t=e.max,i=r(void 0===n?0:n),o=i[0],a=i[1];return{frame:o,setFrame:function(e){var r;(r="number"==typeof e?e:e(o))<0||r>t||a(e)}}};function pe(){var e=r({imageId:"",file:void 0}),n=e[0],t=e[1];return{imageId:n.imageId,setImageIdByFile:function(e){var r;(r=e,function(){try{return Promise.resolve(Z(K.onError)).then(function(e){var n;return null!=(n=null==e?void 0:e.wadouri.fileManager.add(r))?n:""})}catch(e){return Promise.reject(e)}}()).then(function(r){t({imageId:r,file:e})})},file:n.file}}export{J as default,pe as useDicomFile,me as useFrame,ve as useImage,ce as useInteraction,ae as useMultipleImages,ue as useViewport};
import e,{useState as n,useEffect as t,useCallback as r,forwardRef as o,useRef as i,createContext as a,useContext as u,useReducer as l}from"react";import c from"cornerstone-core";import{Subject as s,merge as d,fromEvent as f,from as v}from"rxjs";import{useResizeDetector as m}from"react-resize-detector";import{tap as p,filter as g,switchMap as h,map as w,takeUntil as y,concatMap as b,catchError as E}from"rxjs/operators";import x from"consola";import C from"point-in-polygon";import{uid as P}from"uid";import I from"ky";function S(){return(S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function V(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n.indexOf(t=i[r])>=0||(o[t]=e[t]);return o}var k={scale:0,invert:!1,hflip:!1,vflip:!1,x:0,y:0,windowWidth:0,windowCenter:0};function L(e){if(!e)return k;var n=e.translation,t=e.voi;return{scale:e.scale,invert:e.invert,hflip:e.hflip,vflip:e.vflip,x:n.x,y:n.y,windowWidth:t.windowWidth,windowCenter:t.windowCenter}}function T(e,n){var t,r,o,i,a,u,l,c;return void 0===n&&(n={}),S({},e,{scale:null!=(t=n.scale)?t:e.scale,invert:null!=(r=n.invert)?r:e.invert,hflip:null!=(o=n.hflip)?o:e.hflip,vflip:null!=(i=n.vflip)?i:e.vflip,translation:{x:null!=(a=n.x)?a:e.translation.x,y:null!=(u=n.y)?u:e.translation.y},voi:{windowWidth:null!=(l=n.windowWidth)?l:e.voi.windowWidth,windowCenter:null!=(c=n.windowCenter)?c:e.voi.windowCenter}})}function _(){return c}function q(e,n){return c.loadImage(e,n)}function j(e){return c.getViewport(e)}function W(e,n){return c.setViewport(e,n)}function A(e,n){return c.getDefaultViewportForImage(e,n)}var D,R=new s,Y=new s,O=function(e){return Y.next({loaded:e.loaded,total:e.total})};function F(e){var n=e.loadedCount,t=e.totalCount,r=e.progress;return n===t?100:Math.floor((100*n+(null!=r?r:0))*(1/t))}var X={position:"absolute",top:"50%",width:"100%",transform:"translateY(-50%)",textAlign:"center"};function z(r){var o=r.Progress,i=n({progress:void 0,hidden:!0}),a=i[0],u=a.progress,l=a.hidden,c=i[1];return t(function(){var e=!1,n=R.asObservable(),t=Y.asObservable(),r=0,o=1,i=0;return D=d(n,t).subscribe(function(n){"number"==typeof n?i=n:(r=n.loaded,o=n.total),e||c(function(e){return S({},e,{progress:F({loadedCount:r,totalCount:o,progress:i})})})}),function(){e=!0,D.unsubscribe()}},[]),t(function(){100===u&&c(function(e){return S({},e,{hidden:!0})}),0===u&&c(function(e){return S({},e,{hidden:!1})})},[u]),e.createElement("div",{style:X,"data-cy-loading":l?"":"loading"},!l&&e.createElement(o,{progress:null!=u?u:0}))}var M,N={position:"relative",width:"100%",height:"100%",backgroundColor:"#000",userSelect:"none"},B=o(function(n,o){var i=n.Progress,a=n.onViewportChange,u=n.imageEnabled,l=n.children,s=function(e){var n=e,t=null==n?void 0:n.current,o=r(function(){t&&function(e){c.resize(e)}(t)},[t]),i=m({targetRef:n,onResize:o,refreshMode:"debounce",refreshRate:10,skipOnMount:!0});return{resizeRef:i.ref,width:i.width,height:i.height}}(o),d=s.resizeRef,f=s.width,v=s.height;return t(function(){if(void 0!==f&&void 0!==v&&d.current&&u&&a){var e=j(d.current);a(L(e))}},[f,v,d,u,a]),e.createElement("div",{ref:d,style:N,className:"cornerstone-canvas-wrapper","data-cy":"cornerstone-canvas-wrapper"},i&&e.createElement(z,{Progress:i}),e.createElement("canvas",{className:"cornerstone-canvas"}),l)}),K=e.memo(B);function G(e){e.preventDefault()}B.displayName="Forwarded",K.displayName="ViewerWrapper";var H,J,Q,U={pan:function(e,n){return{x:e.translation.x+n.x/e.scale,y:e.translation.y+n.y/e.scale}},adjust:function(e,n){return{windowWidth:e.voi.windowWidth+n.x/e.scale,windowCenter:e.voi.windowCenter+n.y/e.scale}}},Z={onError:function(e){x.error(e)},Progress:void 0,requestInterceptor:function(e){}},$={scale:0,invert:!1,hflip:!1,vflip:!1,x:0,y:0,windowWidth:0,windowCenter:0},ee=a({enabledElement:null,setToPixelCoordinateSystem:function(){},pixelToCanvas:function(){return{}},pageToPixel:function(){return{}},viewport:$});function ne(r){var o=r.element,i=r.imageEnabled,a=r.viewport,u=void 0===a?$:a,l=r.children,s=n(null),d=s[0],f=s[1],v=e.useState(0)[1];return t(function(){d&&v(function(e){return e+1})},[u,d]),t(function(){if(i&&o){var e=function(e){return c.getEnabledElement(e)}(o);e&&f(e)}},[o,i]),e.createElement(ee.Provider,{value:{setToPixelCoordinateSystem:function(e){if(null==d||!d.element)throw new Error("enabledElement value is null, Please check the enabledElement value.");e.setTransform(1,0,0,1,0,0),function(e,n){c.setToPixelCoordinateSystem(e,n)}(d,e)},pixelToCanvas:function(e){var n=e[0],t=e[1];if(null==d||!d.element)throw new Error("enabledElement value is null, Please check the enabledElement value.");var r=function(e,n){return c.pixelToCanvas(e,n)}(d.element,{x:n,y:t,_pixelCoordinateBrand:"pixel"});return[r.x,r.y]},pageToPixel:function(e){var n=e[0],t=e[1];if(null==d||!d.element)throw new Error("enabledElement value is null, Please check the enabledElement value.");var r=function(e,n,t){return c.pageToPixel(e,n,t)}(d.element,n,t);return[r.x,r.y]},enabledElement:d,viewport:u}},l)}function te(){return u(ee)}function re(n){var r,o=n.image,a=n.Progress,u=n.viewport,l=n.interaction,s=n.onViewportChange,d=n.children,v=i(null),m=i(null!=u?u:{});return t(function(){if(r)return function(e){c.enable(e)}(r),function(){!function(e){c.disable(e)}(r)}},[r=v.current]),function(e){var n=e.element,r=e.image,o=e.viewportRef,a=e.onViewportChange,u=i();t(function(){if(r&&n){var e=void 0===r._imageSeriesKey||M!==(null==r?void 0:r._imageSeriesKey)?null==u?void 0:u.current:S({},T(A(n,r)),o.current),t=function(e,n,t){var r=c.getDefaultViewportForImage(e,n),o=t?T(r,t):r;return c.displayImage(e,n,o),{viewport:o,defaultViewport:r,image:n}}(n,r,o.current._initialViewport?o.current._initialViewport:e).viewport;void 0!==r._imageSeriesKey&&M!==r._imageSeriesKey&&(M=r._imageSeriesKey),o.current._initialViewport&&(u.current=o.current._initialViewport),a&&a(L(t))}},[r,n,o,a])}({element:v.current,image:o,viewportRef:m,onViewportChange:s}),function(e){var n=e.element,r=e.image,o=e.viewport,i=e.onViewportChange;t(function(){if(n&&r&&o){var e,t=A(n,r),a=(null==o?void 0:o._resetViewport)&&t,u=a?t:j(n);u&&(W(n,T(u,o)),a&&i&&i(S({},L(t),null!=(e=null==o?void 0:o._resetViewport)?e:{})))}},[n,r,o,i])}({element:v.current,image:o,viewport:u,onViewportChange:s}),function(e){var n=e.element,r=e.interaction,o=e.viewport,i=e.onViewportChange;!function(e){var n=e.element,r=e.interaction;t(function(){if(n){var e=f(n,"wheel");return Q=e.pipe(g(function(e){return 0!==e.deltaY}),p(function(e){e.preventDefault()})).subscribe(function(e){null!=r&&r.mouseWheel&&(null==r||r.mouseWheel(e.deltaX,e.deltaY))}),function(){Q.unsubscribe()}}},[r,n,e.onViewportChange])}({element:n,interaction:r,onViewportChange:i}),function(e){var n=e.element,r=e.interaction,o=e.onViewportChange;t(function(){if(r&&n&&(null==n||n.removeEventListener("contextmenu",G),r.primaryDrag||r.secondaryDrag)){var e,t=f(n,"mousedown"),i=f(document,"mousemove"),a=f(document,"mouseup");return H=t.pipe(p(function(n){var t=n.button;0===t&&(e="primaryDrag"),2===t&&(e="secondaryDrag")}),g(function(){return void 0!==e}),p(function(e){2===e.button&&(null==n||n.addEventListener("contextmenu",G))}),h(function(e){var n=e.pageX,t=e.pageY;return i.pipe(w(function(e){e.preventDefault();var r=e.pageX-n,o=e.pageY-t;return n=e.pageX,t=e.pageY,{x:r,y:o}}),y(a))})).subscribe(function(t){var i=j(n);i&&e&&function(e){var n,t,r=e.element,o=e.dragged,i=e.viewport,a=e.onViewportChange,u=e.interaction[e.dragType];switch(typeof u){case"string":(n=u)&&(a?a(function(e){var t;return S({},e,null==(t=U[n])?void 0:t.call(U,i,o))}):W(r,T(i,null==(t=U[n])?void 0:t.call(U,i,o))));break;case"function":u({viewport:i,delta:o})}}({interaction:r,dragType:e,element:n,viewport:i,dragged:t,onViewportChange:o})}),function(){H.unsubscribe()}}},[n,r,o])}({element:n,interaction:r,onViewportChange:i}),function(e){var n=e.element,r=e.interaction,o=e.viewport;t(function(){if(r&&n&&(null==n||n.removeEventListener("contextmenu",G),r.primaryClick||r.secondaryClick)){var e,t=f(n,"mousedown");if(r)return J=t.pipe(p(function(n){var t=n.button;0===t&&(e="primaryClick"),2===t&&(e="secondaryClick")}),g(function(){return void 0!==e}),p(function(e){2===e.button&&(null==n||n.addEventListener("contextmenu",G))}),w(function(e){return{clientX:e.clientX,clientY:e.clientY,currentTarget:e.currentTarget}})).subscribe(function(t){var i,a=t.clientX,u=t.clientY,l=t.currentTarget.getBoundingClientRect(),c=function(e,n){var t;if(n)return{x:n.x,y:n.y};var r=(null!=(t=j(e))?t:{}).translation,o=(r=void 0===r?{}:r).x,i=r.y;return{x:void 0===o?0:o,y:void 0===i?0:i}}(n,o);e&&(null==(i=r[e])||i.call(r,-c.x+a-l.left,-c.y+u-l.top))}),function(){J.unsubscribe()}}},[n,r,o])}({element:n,interaction:r,viewport:o})}({element:v.current,interaction:l,viewport:u,onViewportChange:s}),t(function(){u&&(m.current=u)},[u]),e.createElement(K,{ref:v,Progress:a,onViewportChange:s,imageEnabled:!!o},e.createElement(ne,{element:v.current,imageEnabled:!!o,viewport:u},d))}var oe={position:"absolute",top:0,left:0,width:"100%",height:"100%"},ie={fill:"transparent",strokeWidth:"1.5px",stroke:"#000000"};function ae(n){var t=n.style,r=n.width,o=n.height,a=n.contours,u=n.className,l=n.focusedContour,c=n.showOutline,s=void 0!==c&&c,d=n.showPolygonLabel,f=void 0!==d&&d,v=n.polygonAttrs,m=i(null),p=te(),g=p.pixelToCanvas,h=p.enabledElement;return e.createElement("svg",{ref:m,width:r,height:o,style:S({},oe,t),className:u},0!==a.length&&h?function(n){var t=n.showOutline,r=n.showPolygonLabel,o=n.focusedContour,i=n.polygonAttrs,a=n.pixelToCanvas;return n.contours.map(function(n){var u=n.polygon,l=n.label,c=n.id,s=n.labelPosition,d=u===(null==o?void 0:o.polygon),f=u.map(a),v="function"==typeof i?i(n,t):void 0,m=s?a(s):void 0,p=f.map(function(e){return e[0]+","+e[1]}).join(" ");return e.createElement(e.Fragment,{key:c},t&&e.createElement("polygon",{style:S({},ie,null==v?void 0:v.style),"data-border":"border","data-focus":d||void 0,points:p}),e.createElement("polygon",{style:S({},ie,null==v?void 0:v.style),"data-focus":d||void 0,points:p}),r&&m&&e.createElement("text",{x:m[0],y:m[1]},null!=l?l:c))})}({showOutline:s,showPolygonLabel:f,contours:a,focusedContour:l,pixelToCanvas:g,polygonAttrs:v}):null)}var ue={position:"absolute",top:0,left:0,width:"100%",height:"100%"},le={default:{fill:"rgba(255, 244, 0, 0.2)",strokeWidth:"5px",stroke:"rgb(255, 224, 0)"},highlight:{stroke:"#ffffff",strokeWidth:"5px",strokeDasharray:"10, 10",strokeDashoffset:"1000",fill:"transparent"}},ce=function(e){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()};function se(r){var o=r.style,a=r.width,u=r.height,l=r.device,c=r.contours,s=r.className,d=r.onAdd,f=r.onFocus,v=r.onRemove,m=i(null),p=function(e){var r=e.svgElement,o=e.contours,i=e.onAdd,a=e.onFocus,u=e.onRemove,l=n([]),c=l[0],s=l[1],d=n(null),f=d[0],v=d[1],m=n(!1),p=m[0],g=m[1],h=te(),w=h.pageToPixel,y=h.enabledElement;return t(function(){if(r&&y){var e=function(e){if(ce(e),c.length>0&&p){var n=w([e.pageX,e.pageY]);s(function(e){return[].concat(e,[n])})}},n=function(e){ce(e),P(),b(),i(c),s([]),g(!1)},t=function(e){ce(e),P(),b(),s([]),g(!1)},l=function(e){"Escape"===e.code&&(ce(e),P(),b(),s([]),g(!1))},d=function(e){ce(e),E(),x();var n=w([e.pageX,e.pageY]);s([n]),g(!0)},m=function(e){if(e.stopPropagation(),0!==o.length){var n=w([e.pageX,e.pageY]),t=function(e,n){return e.find(function(e){return C(n,e.polygon)})||null}(o,n);v(t),a(t)}},h=function(e){e.stopPropagation(),f&&!p&&u(f)},b=function(){y&&y.element&&(y.element.addEventListener("mousemove",m),y.element.addEventListener("mousedown",d),y.element.addEventListener("click",h))},E=function(){y&&y.element&&(y.element.removeEventListener("mousemove",m),y.element.removeEventListener("mousedown",d),y.element.removeEventListener("click",h))},x=function(){y&&y.element&&(y.element.addEventListener("mousemove",e),y.element.addEventListener("mouseup",n),y.element.addEventListener("mouseleave",t),window.addEventListener("keydown",l))},P=function(){y&&y.element&&(y.element.removeEventListener("mousemove",e),y.element.removeEventListener("mouseup",n),y.element.removeEventListener("mouseleave",t),window.removeEventListener("keydown",l))};return c.length>0?x():b(),function(){E(),P()}}},[o,r,c,p,f,y,i,a,u,w]),[c]}({svgElement:m,device:l,contours:c,onAdd:d,onFocus:f,onRemove:v})[0],g=te(),h=p.map(g.pixelToCanvas).map(function(e){return e[0]+","+e[1]}).join(" ");return e.createElement("svg",{ref:m,width:a,height:u,style:S({},ue,o),className:s},p&&p.length>0&&e.createElement(e.Fragment,null,e.createElement("polyline",{style:le.default,points:h}),e.createElement("polyline",{style:le.highlight,points:h})))}function de(e){if(function(e){return e instanceof Error}(e))return e;if(function(e){var n;return void 0!==(null==e?void 0:e.error)&&void 0!==(null==e||null==(n=e.error)?void 0:n.message)}(e)){var n,t,r=new Error(e.error.message);return r.status=null==e||null==(n=e.error)||null==(t=n.response)?void 0:t.status,r}return new Error("error unknown")}var fe=function(){},ve=function(e){try{var n,t,r;return Promise.resolve(function(e,o){try{var i=Promise.resolve(Promise.all([import("cornerstone-wado-image-loader"),import("dicom-parser")])).then(function(e){return r=(n=e)[1],(t=n[0]).external.cornerstone=_(),t.external.dicomParser=r,t})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(n){e(de(n))}))}catch(e){return Promise.reject(e)}},me=function(e){try{var n;return Promise.resolve(function(e,t){try{var r=Promise.resolve(import("cornerstone-web-image-loader")).then(function(e){return(n=e).external.cornerstone=_(),n})}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(0,function(n){e(de(n))}))}catch(e){return Promise.reject(e)}};function pe(e,t){var r=n(!1),o=r[0],i=r[1],a="dicom"==(e.web?"web":"dicom")?ve:me;return function(){try{var e=function(){if(!o)return Promise.resolve(a(t)).then(function(e){i(!!e)})}();e&&e.then&&e.then(function(){})}catch(e){Promise.reject(e)}}(),o}var ge=function(e){return function(n){try{var t=I.create({hooks:{beforeRequest:[function(n){e(n)}]},onDownloadProgress:function(e){try{return n=0===e.percent&&0===e.totalBytes&&e.transferredBytes>0?100:Math.round(100*e.percent),R.next(n),Promise.resolve()}catch(e){return Promise.reject(e)}var n}});return Promise.resolve(t.get(n)).then(function(e){return e.arrayBuffer()})}catch(e){return Promise.reject(e)}}};function he(e){var n=e.stateMap,t=e.value;return t===e.size?n.set(t-1,"success"):n.set(t-1,"success").set(t,"loading")}function we(e){return void 0===e?[]:Array.isArray(e)?e:[e]}var ye,be,Ee=["onError","requestInterceptor","onImagesLoaded"],xe=["requestInterceptor","onError","onImagesLoaded"],Ce=function(e){var r=e.requestInterceptor,o=void 0===r?Z.requestInterceptor:r,a=e.onError,u=void 0===a?Z.onError:a,l=e.onImagesLoaded,c=void 0===l?fe:l,s=V(e,xe),d=i(),f=function(e){var r,o,a,u=e.onError,l=e.requestInterceptor,c=e.onImagesLoaded,s=void 0===c?fe:c,d=V(e,Ee),f=(r=d).wadouri?{ids:we(r.wadouri),scheme:"wadouri"}:r.dicomfile?{ids:we(r.dicomfile),scheme:"dicomfile"}:r.web?{ids:we(r.web),scheme:"web"}:{ids:[],scheme:void 0},m=f.ids,p=f.scheme,g=n({loadingStates:(o=Array.isArray(m)?m.length:0,a=Array(o).fill("initial"),new Map(a.map(function(e,n){return[n,e]}))),_currentIndex:-1}),h=g[0].loadingStates,y=g[1],x=i([]),C=pe(d,u);return t(function(){m&&0!==m.length&&p&&C&&(x.current=[],y(function(e){return S({},e,{loadingStates:e.loadingStates.set(0,"loading")})}),ye=P(),function(e){var n=e.images,t=e.imageScheme,r=e.requestInterceptor,o=0;return O({loaded:o,total:n.length}),v(n).pipe(b(function(e){return function(e,n,t){return q(e,{loader:"dicomfile"===n?void 0:ge(t)})}(e,t,r)}),w(function(e){return O({loaded:o+=1,total:n.length}),{image:e,loaded:o}}),E(function(e){throw de(e)}))}({images:m,imageScheme:p,requestInterceptor:l}).subscribe({next:function(e){var n=e.loaded;x.current=[].concat(x.current,[S({},e.image,{_imageSeriesKey:ye})]),y(function(e){return{loadingStates:he({size:m.length,stateMap:e.loadingStates,value:n}),_currentIndex:n-1}})},error:function(e){u(e),y(function(e){return S({},e,{loadingStates:e.loadingStates.set(e._currentIndex+1,"fail")})})},complete:function(){s()}}))},[m,p,u,s,l,C]),{images:x.current,loadingStates:Array.from(h.values())}}(S({},s,{onError:u,requestInterceptor:o,onImagesLoaded:d.current})),m=f.loadingStates,p=f.images,g=void 0===p?[]:p;return t(function(){null!=d&&d.current||(d.current=c)},[c]),{loadingStates:m,images:g}};function Pe(e){var t=n(S({},e?S({},$,{_initialViewport:e}):$)),r=t[0],o=t[1];return{viewport:r,setViewport:o,resetViewport:function(){o(S({},r,{_resetViewport:e}))},initialized:r.scale!==$.scale}}var Ie=((be={}).primaryDrag=void 0,be.secondaryDrag=void 0,be.primaryClick=void 0,be.secondaryClick=void 0,be.mouseWheel=void 0,be);function Se(e){void 0===e&&(e={});var t=n(S({},Ie,e));return{interaction:t[0],setInteraction:t[1]}}function Ve(e,n){var t=n.payload;switch(n.type){case"loading":return S({},e,{loadingState:"loading"});case"success":return{loadingState:"success",image:t};case"fail":return S({},e,{loadingState:"fail"});default:return e}}var ke={loadingState:"initial",image:void 0};function Le(e){if(void 0!==e)return Array.isArray(e)?e[0]:e}var Te=["requestInterceptor","onError","onImageLoaded"],_e=function(e){var n=e.requestInterceptor,r=void 0===n?Z.requestInterceptor:n,o=e.onError,a=void 0===o?Z.onError:o,u=e.onImageLoaded,c=void 0===u?fe:u,s=V(e,Te),d=function(e){return e.wadouri?{id:Le(e.wadouri),scheme:"wadouri"}:e.dicomfile?{id:Le(e.dicomfile),scheme:"dicomfile"}:e.web?{id:Le(e.web),scheme:"web"}:{id:void 0,scheme:void 0}}(s),f=d.id,v=d.scheme,m=i(),p=l(Ve,ke),g=p[0],h=g.loadingState,w=g.image,y=p[1],b=pe(s,a);return t(function(){null!=m&&m.current||(m.current=c)},[c]),t(function(){b&&f&&v&&(y({type:"loading"}),function(e){var n=e.imageId,t=e.imageScheme,r=e.requestInterceptor,o=e.onError;try{return Promise.resolve(function(e,o){try{var i=Promise.resolve(function(e){var n=e.imageId,t=e.imageScheme,r=e.requestInterceptor;try{return Promise.resolve(function(e,o){try{var i=Promise.resolve(q(n,{loader:"dicomfile"===t?void 0:ge(r)}))}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw de(e)}))}catch(e){return Promise.reject(e)}}({imageId:n,imageScheme:t,requestInterceptor:r}))}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw o(de(e)),e}))}catch(e){return Promise.reject(e)}}({imageId:f,imageScheme:v,requestInterceptor:r,onError:a}).then(function(e){y({type:"success",payload:e}),setTimeout(function(){null==m.current||m.current()},0)}).catch(function(){return y({type:"fail"})}))},[b,f,v,r,a]),{image:w,loadingState:h}},qe=function(e){var t=e.initial,r=e.max,o=n(void 0===t?0:t),i=o[0],a=o[1];return{frame:i,setFrame:function(e){var n;(n="number"==typeof e?e:e(i))<0||n>r||a(e)}}};function je(){var e=n({imageId:"",file:void 0}),t=e[0],r=e[1];return{imageId:t.imageId,setImageIdByFile:function(e){var n;(n=e,function(){try{return Promise.resolve(ve(Z.onError)).then(function(e){var t;return null!=(t=null==e?void 0:e.wadouri.fileManager.add(n))?t:""})}catch(e){return Promise.reject(e)}}()).then(function(n){r({imageId:n,file:e})})},file:t.file}}export{se as SvgContourDrawer,ae as SvgContourViewer,re as default,je as useDicomFile,qe as useFrame,_e as useImage,Se as useInteraction,Ce as useMultipleImages,te as useOverlayContext,Pe as useViewport};
//# sourceMappingURL=index.esm.js.map

@@ -1,2 +0,2 @@

var e=require("react"),r=require("rxjs"),t=require("react-resize-detector"),n=require("cornerstone-core"),i=require("rxjs/operators"),o=require("consola"),a=require("ky");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function c(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,r}var l=u(e),s=u(n),f=u(o),d=u(a);function v(){return v=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},v.apply(this,arguments)}function m(e,r){if(null==e)return{};var t,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r.indexOf(t=o[n])>=0||(i[t]=e[t]);return i}var p,g=new r.Subject,w=new r.Subject,h=new r.Subject,y=function(e){return h.next({loaded:e.loaded,total:e.total})};function b(e){var r=e.loadedCount,t=e.totalCount,n=e.progress;return r===t?100:Math.floor((100*r+(null!=n?n:0))*(1/t))}var E={position:"absolute",top:"50%",width:"100%",transform:"translateY(-50%)",textAlign:"center"};function x(t){var n=t.Progress,i=e.useState({progress:void 0,hidden:!0}),o=i[0],a=o.progress,u=o.hidden,c=i[1];return e.useEffect(function(){var e=!1,t=g.asObservable(),n=h.asObservable(),i=0,o=1,a=0;return p=r.merge(t,n).subscribe(function(r){"number"==typeof r?a=r:(i=r.loaded,o=r.total),e||c(function(e){return v({},e,{progress:b({loadedCount:i,totalCount:o,progress:a})})})}),function(){e=!0,p.unsubscribe()}},[]),e.useEffect(function(){100===a&&c(function(e){return v({},e,{hidden:!0})}),0===a&&c(function(e){return v({},e,{hidden:!1})})},[a]),l.default.createElement("div",{style:E,"data-cy-loading":u?"":"loading"},!u&&l.default.createElement(n,{progress:null!=a?a:0}))}var I={scale:0,invert:!1,hflip:!1,vflip:!1,x:0,y:0,windowWidth:0,windowCenter:0};function C(e){if(!e)return I;var r=e.translation,t=e.voi;return{scale:e.scale,invert:e.invert,hflip:e.hflip,vflip:e.vflip,x:r.x,y:r.y,windowWidth:t.windowWidth,windowCenter:t.windowCenter}}function P(e,r){var t,n,i,o,a,u,c,l;return void 0===r&&(r={}),v({},e,{scale:null!=(t=r.scale)?t:e.scale,invert:null!=(n=r.invert)?n:e.invert,hflip:null!=(i=r.hflip)?i:e.hflip,vflip:null!=(o=r.vflip)?o:e.vflip,translation:{x:null!=(a=r.x)?a:e.translation.x,y:null!=(u=r.y)?u:e.translation.y},voi:{windowWidth:null!=(c=r.windowWidth)?c:e.voi.windowWidth,windowCenter:null!=(l=r.windowCenter)?l:e.voi.windowCenter}})}function S(){return s.default}function q(e,r){return s.default.loadImage(e,r)}function V(e){return s.default.getViewport(e)}function j(e,r){return s.default.setViewport(e,r)}var k={position:"relative",width:"100%",height:"100%",backgroundColor:"#000",userSelect:"none"},R=e.forwardRef(function(r,n){var i=r.Progress,o=r.children,a=function(r){var n=r,i=null==n?void 0:n.current,o=e.useCallback(function(){if(i)return function(e){s.default.resize(e)}(i)},[i]);return{resizeRef:t.useResizeDetector({targetRef:n,onResize:o,skipOnMount:!1}).ref}}(n);return l.default.createElement("div",{ref:a.resizeRef,style:k,className:"cornerstone-canvas-wrapper","data-cy":"cornerstone-canvas-wrapper"},i&&l.default.createElement(x,{Progress:i}),l.default.createElement("canvas",{className:"cornerstone-canvas"}),o)}),D=l.default.memo(R);function O(e){e.preventDefault()}R.displayName="Forwarded",D.displayName="ViewerWrapper";var W,M,_,z,A={pan:function(e,r){return{x:e.translation.x+r.x/e.scale,y:e.translation.y+r.y/e.scale}},adjust:function(e,r){return{windowWidth:e.voi.windowWidth+r.x/e.scale,windowCenter:e.voi.windowCenter+r.y/e.scale}}},Y={onError:function(e){f.default.error(e)},Progress:void 0,requestInterceptor:function(e){}},X={scale:0,invert:!1,hflip:!1,vflip:!1,x:0,y:0,windowWidth:0,windowCenter:0};function F(e){if(function(e){return e instanceof Error}(e))return e;if(function(e){var r;return void 0!==(null==e?void 0:e.error)&&void 0!==(null==e||null==(r=e.error)?void 0:r.message)}(e)){var r,t,n=new Error(e.error.message);return n.status=null==e||null==(r=e.error)||null==(t=r.response)?void 0:t.status,n}return new Error("error unknown")}var B=function(e){try{var r,t,n;return Promise.resolve(function(e,i){try{var o=Promise.resolve(Promise.all([Promise.resolve().then(function(){return c(require("cornerstone-wado-image-loader"))}),Promise.resolve().then(function(){return c(require("dicom-parser"))})])).then(function(e){return n=(r=e)[1],(t=r[0]).external.cornerstone=S(),t.external.dicomParser=n,t})}catch(e){return i(e)}return o&&o.then?o.then(void 0,i):o}(0,function(r){e(F(r))}))}catch(e){return Promise.reject(e)}},T=function(e){try{var r;return Promise.resolve(function(e,t){try{var n=Promise.resolve(Promise.resolve().then(function(){return c(require("cornerstone-web-image-loader"))})).then(function(e){return(r=e).external.cornerstone=S(),r})}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}(0,function(r){e(F(r))}))}catch(e){return Promise.reject(e)}};function L(r,t){var n=e.useState(!1),i=n[0],o=n[1],a="dicom"==(r.web?"web":"dicom")?B:T;return function(){try{var e=function(){if(!i)return Promise.resolve(a(t)).then(function(e){o(!!e)})}();e&&e.then&&e.then(function(){})}catch(e){Promise.reject(e)}}(),i}var N=function(e){return function(r){try{var t=d.default.create({hooks:{beforeRequest:[function(r){e(r)}]},onDownloadProgress:function(e){try{return r=0===e.percent&&0===e.totalBytes&&e.transferredBytes>0?100:Math.round(100*e.percent),g.next(r),Promise.resolve()}catch(e){return Promise.reject(e)}var r}});return Promise.resolve(t.get(r)).then(function(e){return e.arrayBuffer()})}catch(e){return Promise.reject(e)}}};function U(e){var r=e.stateMap,t=e.value;return t===e.size?r.set(t-1,"success"):r.set(t-1,"success").set(t,"loading")}function G(e){return void 0===e?[]:Array.isArray(e)?e:[e]}var H=["onError","requestInterceptor"],J=["requestInterceptor","onError"];function K(e,r){var t=r.payload;switch(r.type){case"loading":return v({},e,{loadingState:"loading"});case"success":return{loadingState:"success",image:t};case"fail":return v({},e,{loadingState:"fail"});default:return e}}var Q={loadingState:"initial",image:void 0};function Z(e){if(void 0!==e)return Array.isArray(e)?e[0]:e}var $=["requestInterceptor","onError"];exports.default=function(t){var n,o=t.image,a=t.Progress,u=t.viewport,c=t.interaction,f=t.onViewportChange,d=t.children,m=e.useRef(null),p=e.useRef(u),g=function(){var r=e.useRef();return e.useEffect(function(){return z=w.asObservable().subscribe(function(e){r.current=e}),function(){z.unsubscribe()}},[]),r}();return e.useEffect(function(){if(n)return function(e){s.default.enable(e)}(n),function(){!function(e){s.default.disable(e)}(n)}},[n=m.current]),function(r){var t=r.element,n=r.image,i=r.viewportRef,o=r.onViewportChange,a=e.useRef(0);e.useEffect(function(){var e;if(n&&t){a.current+=1;var r=function(e,r,t){var n=s.default.getDefaultViewportForImage(e,r),i=t?P(n,t):n;return s.default.displayImage(e,r,i),{viewport:i,defaultViewport:n,image:r}}(t,n,1===a.current?null==i||null==(e=i.current)?void 0:e._default:null==i?void 0:i.current),u=r.viewport;w.next(r.defaultViewport),o&&o(C(u))}},[t,n,i,o])}({element:m.current,image:o,viewportRef:p,onViewportChange:f}),function(r){var t=r.element,n=r.viewport,i=r.initialViewport,o=r.onViewportChange;e.useEffect(function(){if(t&&n){var e,r=(null==n?void 0:n._reset)&&i,a=r?i:V(t);a&&(j(t,P(a,n)),r&&o&&o(v({},C(i),null!=(e=null==n?void 0:n._reset)?e:{})))}},[t,n,i,o])}({element:m.current,viewport:u,initialViewport:null==g?void 0:g.current,onViewportChange:f}),function(t){var n=t.element,o=t.interaction,a=t.viewport,u=t.onViewportChange;!function(t){var n=t.element,o=t.interaction;e.useEffect(function(){if(n){var e=r.fromEvent(n,"wheel");return _=e.pipe(i.filter(function(e){return 0!==e.deltaY}),i.tap(function(e){e.preventDefault()})).subscribe(function(e){null!=o&&o.mouseWheel&&(null==o||o.mouseWheel(e.deltaX,e.deltaY))}),function(){_.unsubscribe()}}},[o,n,t.onViewportChange])}({element:n,interaction:o,onViewportChange:u}),function(t){var n=t.element,o=t.interaction,a=t.onViewportChange;e.useEffect(function(){if(o&&n&&(null==n||n.removeEventListener("contextmenu",O),o.primaryDrag||o.secondaryDrag)){var e,t=r.fromEvent(n,"mousedown"),u=r.fromEvent(document,"mousemove"),c=r.fromEvent(document,"mouseup");return W=t.pipe(i.tap(function(r){var t=r.button;0===t&&(e="primaryDrag"),2===t&&(e="secondaryDrag")}),i.filter(function(){return void 0!==e}),i.tap(function(e){2===e.button&&(null==n||n.addEventListener("contextmenu",O))}),i.switchMap(function(e){var r=e.pageX,t=e.pageY;return u.pipe(i.map(function(e){e.preventDefault();var n=e.pageX-r,i=e.pageY-t;return r=e.pageX,t=e.pageY,{x:n,y:i}}),i.takeUntil(c))})).subscribe(function(r){var t=V(n);t&&e&&function(e){var r,t,n=e.element,i=e.dragged,o=e.viewport,a=e.onViewportChange,u=e.interaction[e.dragType];switch(typeof u){case"string":(r=u)&&(a?a(function(e){var t;return v({},e,null==(t=A[r])?void 0:t.call(A,o,i))}):j(n,P(o,null==(t=A[r])?void 0:t.call(A,o,i))));break;case"function":u({viewport:o,delta:i})}}({interaction:o,dragType:e,element:n,viewport:t,dragged:r,onViewportChange:a})}),function(){W.unsubscribe()}}},[n,o,a])}({element:n,interaction:o,onViewportChange:u}),function(t){var n=t.element,o=t.interaction,a=t.viewport;e.useEffect(function(){if(o&&n&&(null==n||n.removeEventListener("contextmenu",O),o.primaryClick||o.secondaryClick)){var e,t=r.fromEvent(n,"mousedown");if(o)return M=t.pipe(i.tap(function(r){var t=r.button;0===t&&(e="primaryClick"),2===t&&(e="secondaryClick")}),i.filter(function(){return void 0!==e}),i.tap(function(e){2===e.button&&(null==n||n.addEventListener("contextmenu",O))}),i.map(function(e){return{clientX:e.clientX,clientY:e.clientY,currentTarget:e.currentTarget}})).subscribe(function(r){var t,i=r.clientX,u=r.clientY,c=r.currentTarget.getBoundingClientRect(),l=function(e,r){var t;if(r)return{x:r.x,y:r.y};var n=(null!=(t=V(e))?t:{}).translation,i=(n=void 0===n?{}:n).x,o=n.y;return{x:void 0===i?0:i,y:void 0===o?0:o}}(n,a);e&&(null==(t=o[e])||t.call(o,-l.x+i-c.left,-l.y+u-c.top))}),function(){M.unsubscribe()}}},[n,o,a])}({element:n,interaction:o,viewport:a})}({element:m.current,interaction:c,viewport:u,onViewportChange:f}),e.useEffect(function(){p.current=u},[u]),l.default.createElement(D,{ref:m,Progress:a},d)},exports.useDicomFile=function(){var r=e.useState({imageId:"",file:void 0}),t=r[0],n=r[1];return{imageId:t.imageId,setImageIdByFile:function(e){var r;(r=e,function(){try{return Promise.resolve(B(Y.onError)).then(function(e){var t;return null!=(t=null==e?void 0:e.wadouri.fileManager.add(r))?t:""})}catch(e){return Promise.reject(e)}}()).then(function(r){n({imageId:r,file:e})})},file:t.file}},exports.useFrame=function(r){var t=r.initial,n=r.max,i=e.useState(void 0===t?0:t),o=i[0],a=i[1];return{frame:o,setFrame:function(e){var r;(r="number"==typeof e?e:e(o))<0||r>n||a(e)}}},exports.useImage=function(r){var t=r.requestInterceptor,n=void 0===t?Y.requestInterceptor:t,i=r.onError,o=void 0===i?Y.onError:i,a=m(r,$),u=function(e){return e.wadouri?{id:Z(e.wadouri),scheme:"wadouri"}:e.dicomfile?{id:Z(e.dicomfile),scheme:"dicomfile"}:e.web?{id:Z(e.web),scheme:"web"}:{id:void 0,scheme:void 0}}(a),c=u.id,l=u.scheme,s=e.useReducer(K,Q),f=s[0],d=f.loadingState,v=f.image,p=s[1],g=L(a,o);return e.useEffect(function(){g&&c&&l&&(p({type:"loading"}),function(e){var r=e.imageId,t=e.imageScheme,n=e.requestInterceptor,i=e.onError;try{return Promise.resolve(function(e,i){try{var o=Promise.resolve(function(e){var r=e.imageId,t=e.imageScheme,n=e.requestInterceptor;try{return Promise.resolve(function(e,i){try{var o=Promise.resolve(q(r,{loader:"dicomfile"===t?void 0:N(n)}))}catch(e){return i(e)}return o&&o.then?o.then(void 0,i):o}(0,function(e){throw F(e)}))}catch(e){return Promise.reject(e)}}({imageId:r,imageScheme:t,requestInterceptor:n}))}catch(e){return i(e)}return o&&o.then?o.then(void 0,i):o}(0,function(e){throw i(F(e)),e}))}catch(e){return Promise.reject(e)}}({imageId:c,imageScheme:l,requestInterceptor:n,onError:o}).then(function(e){p({type:"success",payload:e})}).catch(function(){return p({type:"fail"})}))},[g,c,l,n,o]),{image:v,loadingState:d}},exports.useInteraction=function(){var r,t=e.useState(((r={}).primaryDrag=void 0,r.secondaryDrag=void 0,r.primaryClick=void 0,r.secondaryClick=void 0,r.mouseWheel=void 0,r));return{interaction:t[0],setInteraction:t[1]}},exports.useMultipleImages=function(t){var n=t.requestInterceptor,o=void 0===n?Y.requestInterceptor:n,a=t.onError,u=void 0===a?Y.onError:a,c=function(t){var n,o,a,u=t.onError,c=t.requestInterceptor,l=m(t,H),s=(n=l).wadouri?{ids:G(n.wadouri),scheme:"wadouri"}:n.dicomfile?{ids:G(n.dicomfile),scheme:"dicomfile"}:n.web?{ids:G(n.web),scheme:"web"}:{ids:[],scheme:void 0},f=s.ids,d=s.scheme,p=e.useState({images:[],loadingStates:(o=Array.isArray(f)?f.length:0,a=Array(o).fill("initial"),new Map(a.map(function(e,r){return[r,e]}))),_currentIndex:-1}),g=p[0],w=g.images,h=g.loadingStates,b=p[1],E=L(l,u);return e.useEffect(function(){f&&0!==f.length&&d&&E&&(b(function(e){return v({},e,{loadingStates:e.loadingStates.set(0,"loading")})}),function(e){var t=e.images,n=e.imageScheme,o=e.requestInterceptor,a=0;return y({loaded:a,total:t.length}),r.from(t).pipe(i.concatMap(function(e){return function(e,r,t){return q(e,{loader:"dicomfile"===r?void 0:N(t)})}(e,n,o)}),i.map(function(e){return y({loaded:a+=1,total:t.length}),{image:e,loaded:a}}),i.catchError(function(e){throw F(e)}))}({images:f,imageScheme:d,requestInterceptor:c}).subscribe({next:function(e){var r=e.image,t=e.loaded;b(function(e){return{images:[].concat(e.images,[r]),loadingStates:U({size:f.length,stateMap:e.loadingStates,value:t}),_currentIndex:t-1}})},error:function(e){u(e),b(function(e){return v({},e,{loadingStates:e.loadingStates.set(e._currentIndex+1,"fail")})})}}))},[f,d,u,c,E]),{images:w,loadingStates:Array.from(h.values())}}(v({},m(t,J),{onError:u,requestInterceptor:o})),l=c.images;return{loadingStates:c.loadingStates,images:void 0===l?[]:l}},exports.useViewport=function(r){var t=e.useState(v({},r?v({},X,{_default:r}):X)),n=t[0],i=t[1];return{viewport:n,setViewport:i,resetViewport:function(){i(v({},n,{_reset:r}))},initialized:n.scale!==X.scale}};
var e=require("react"),t=require("cornerstone-core"),n=require("rxjs"),r=require("react-resize-detector"),o=require("rxjs/operators"),i=require("consola"),a=require("point-in-polygon"),u=require("uid"),l=require("ky");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,t}var f=c(e),d=c(t),v=c(i),m=c(a),p=c(l);function g(){return(g=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function h(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t.indexOf(n=i[r])>=0||(o[n]=e[n]);return o}var w={scale:0,invert:!1,hflip:!1,vflip:!1,x:0,y:0,windowWidth:0,windowCenter:0};function y(e){if(!e)return w;var t=e.translation,n=e.voi;return{scale:e.scale,invert:e.invert,hflip:e.hflip,vflip:e.vflip,x:t.x,y:t.y,windowWidth:n.windowWidth,windowCenter:n.windowCenter}}function E(e,t){var n,r,o,i,a,u,l,c;return void 0===t&&(t={}),g({},e,{scale:null!=(n=t.scale)?n:e.scale,invert:null!=(r=t.invert)?r:e.invert,hflip:null!=(o=t.hflip)?o:e.hflip,vflip:null!=(i=t.vflip)?i:e.vflip,translation:{x:null!=(a=t.x)?a:e.translation.x,y:null!=(u=t.y)?u:e.translation.y},voi:{windowWidth:null!=(l=t.windowWidth)?l:e.voi.windowWidth,windowCenter:null!=(c=t.windowCenter)?c:e.voi.windowCenter}})}function b(){return d.default}function x(e,t){return d.default.loadImage(e,t)}function C(e){return d.default.getViewport(e)}function P(e,t){return d.default.setViewport(e,t)}function S(e,t){return d.default.getDefaultViewportForImage(e,t)}var I,V=new n.Subject,k=new n.Subject,q=function(e){return k.next({loaded:e.loaded,total:e.total})};function L(e){var t=e.loadedCount,n=e.totalCount,r=e.progress;return t===n?100:Math.floor((100*t+(null!=r?r:0))*(1/n))}var j={position:"absolute",top:"50%",width:"100%",transform:"translateY(-50%)",textAlign:"center"};function R(t){var r=t.Progress,o=e.useState({progress:void 0,hidden:!0}),i=o[0],a=i.progress,u=i.hidden,l=o[1];return e.useEffect(function(){var e=!1,t=V.asObservable(),r=k.asObservable(),o=0,i=1,a=0;return I=n.merge(t,r).subscribe(function(t){"number"==typeof t?a=t:(o=t.loaded,i=t.total),e||l(function(e){return g({},e,{progress:L({loadedCount:o,totalCount:i,progress:a})})})}),function(){e=!0,I.unsubscribe()}},[]),e.useEffect(function(){100===a&&l(function(e){return g({},e,{hidden:!0})}),0===a&&l(function(e){return g({},e,{hidden:!1})})},[a]),f.default.createElement("div",{style:j,"data-cy-loading":u?"":"loading"},!u&&f.default.createElement(r,{progress:null!=a?a:0}))}var T,_={position:"relative",width:"100%",height:"100%",backgroundColor:"#000",userSelect:"none"},D=e.forwardRef(function(t,n){var o=t.Progress,i=t.onViewportChange,a=t.imageEnabled,u=t.children,l=function(t){var n=t,o=null==n?void 0:n.current,i=e.useCallback(function(){o&&function(e){d.default.resize(e)}(o)},[o]),a=r.useResizeDetector({targetRef:n,onResize:i,refreshMode:"debounce",refreshRate:10,skipOnMount:!0});return{resizeRef:a.ref,width:a.width,height:a.height}}(n),c=l.resizeRef,s=l.width,v=l.height;return e.useEffect(function(){if(void 0!==s&&void 0!==v&&c.current&&a&&i){var e=C(c.current);i(y(e))}},[s,v,c,a,i]),f.default.createElement("div",{ref:c,style:_,className:"cornerstone-canvas-wrapper","data-cy":"cornerstone-canvas-wrapper"},o&&f.default.createElement(R,{Progress:o}),f.default.createElement("canvas",{className:"cornerstone-canvas"}),u)}),O=f.default.memo(D);function W(e){e.preventDefault()}D.displayName="Forwarded",O.displayName="ViewerWrapper";var A,F,M,Y={pan:function(e,t){return{x:e.translation.x+t.x/e.scale,y:e.translation.y+t.y/e.scale}},adjust:function(e,t){return{windowWidth:e.voi.windowWidth+t.x/e.scale,windowCenter:e.voi.windowCenter+t.y/e.scale}}},X={onError:function(e){v.default.error(e)},Progress:void 0,requestInterceptor:function(e){}},z={scale:0,invert:!1,hflip:!1,vflip:!1,x:0,y:0,windowWidth:0,windowCenter:0},N=e.createContext({enabledElement:null,setToPixelCoordinateSystem:function(){},pixelToCanvas:function(){return{}},pageToPixel:function(){return{}},viewport:z});function B(t){var n=t.element,r=t.imageEnabled,o=t.viewport,i=void 0===o?z:o,a=t.children,u=e.useState(null),l=u[0],c=u[1],s=f.default.useState(0)[1];return e.useEffect(function(){l&&s(function(e){return e+1})},[i,l]),e.useEffect(function(){if(r&&n){var e=function(e){return d.default.getEnabledElement(e)}(n);e&&c(e)}},[n,r]),f.default.createElement(N.Provider,{value:{setToPixelCoordinateSystem:function(e){if(null==l||!l.element)throw new Error("enabledElement value is null, Please check the enabledElement value.");e.setTransform(1,0,0,1,0,0),function(e,t){d.default.setToPixelCoordinateSystem(e,t)}(l,e)},pixelToCanvas:function(e){var t=e[0],n=e[1];if(null==l||!l.element)throw new Error("enabledElement value is null, Please check the enabledElement value.");var r=function(e,t){return d.default.pixelToCanvas(e,t)}(l.element,{x:t,y:n,_pixelCoordinateBrand:"pixel"});return[r.x,r.y]},pageToPixel:function(e){var t=e[0],n=e[1];if(null==l||!l.element)throw new Error("enabledElement value is null, Please check the enabledElement value.");var r=function(e,t,n){return d.default.pageToPixel(e,t,n)}(l.element,t,n);return[r.x,r.y]},enabledElement:l,viewport:i}},a)}function K(){return e.useContext(N)}var U={position:"absolute",top:0,left:0,width:"100%",height:"100%"},G={fill:"transparent",strokeWidth:"1.5px",stroke:"#000000"},H={position:"absolute",top:0,left:0,width:"100%",height:"100%"},J={default:{fill:"rgba(255, 244, 0, 0.2)",strokeWidth:"5px",stroke:"rgb(255, 224, 0)"},highlight:{stroke:"#ffffff",strokeWidth:"5px",strokeDasharray:"10, 10",strokeDashoffset:"1000",fill:"transparent"}},Q=function(e){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()};function Z(e){if(function(e){return e instanceof Error}(e))return e;if(function(e){var t;return void 0!==(null==e?void 0:e.error)&&void 0!==(null==e||null==(t=e.error)?void 0:t.message)}(e)){var t,n,r=new Error(e.error.message);return r.status=null==e||null==(t=e.error)||null==(n=t.response)?void 0:n.status,r}return new Error("error unknown")}var $=function(){},ee=function(e){try{var t,n,r;return Promise.resolve(function(e,o){try{var i=Promise.resolve(Promise.all([Promise.resolve().then(function(){return s(require("cornerstone-wado-image-loader"))}),Promise.resolve().then(function(){return s(require("dicom-parser"))})])).then(function(e){return r=(t=e)[1],(n=t[0]).external.cornerstone=b(),n.external.dicomParser=r,n})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(t){e(Z(t))}))}catch(e){return Promise.reject(e)}},te=function(e){try{var t;return Promise.resolve(function(e,n){try{var r=Promise.resolve(Promise.resolve().then(function(){return s(require("cornerstone-web-image-loader"))})).then(function(e){return(t=e).external.cornerstone=b(),t})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(t){e(Z(t))}))}catch(e){return Promise.reject(e)}};function ne(t,n){var r=e.useState(!1),o=r[0],i=r[1],a="dicom"==(t.web?"web":"dicom")?ee:te;return function(){try{var e=function(){if(!o)return Promise.resolve(a(n)).then(function(e){i(!!e)})}();e&&e.then&&e.then(function(){})}catch(e){Promise.reject(e)}}(),o}var re=function(e){return function(t){try{var n=p.default.create({hooks:{beforeRequest:[function(t){e(t)}]},onDownloadProgress:function(e){try{return t=0===e.percent&&0===e.totalBytes&&e.transferredBytes>0?100:Math.round(100*e.percent),V.next(t),Promise.resolve()}catch(e){return Promise.reject(e)}var t}});return Promise.resolve(n.get(t)).then(function(e){return e.arrayBuffer()})}catch(e){return Promise.reject(e)}}};function oe(e){var t=e.stateMap,n=e.value;return n===e.size?t.set(n-1,"success"):t.set(n-1,"success").set(n,"loading")}function ie(e){return void 0===e?[]:Array.isArray(e)?e:[e]}var ae,ue,le=["onError","requestInterceptor","onImagesLoaded"],ce=["requestInterceptor","onError","onImagesLoaded"],se=((ue={}).primaryDrag=void 0,ue.secondaryDrag=void 0,ue.primaryClick=void 0,ue.secondaryClick=void 0,ue.mouseWheel=void 0,ue);function fe(e,t){var n=t.payload;switch(t.type){case"loading":return g({},e,{loadingState:"loading"});case"success":return{loadingState:"success",image:n};case"fail":return g({},e,{loadingState:"fail"});default:return e}}var de={loadingState:"initial",image:void 0};function ve(e){if(void 0!==e)return Array.isArray(e)?e[0]:e}var me=["requestInterceptor","onError","onImageLoaded"];exports.SvgContourDrawer=function(t){var n=t.style,r=t.width,o=t.height,i=t.device,a=t.contours,u=t.className,l=t.onAdd,c=t.onFocus,s=t.onRemove,d=e.useRef(null),v=function(t){var n=t.svgElement,r=t.contours,o=t.onAdd,i=t.onFocus,a=t.onRemove,u=e.useState([]),l=u[0],c=u[1],s=e.useState(null),f=s[0],d=s[1],v=e.useState(!1),p=v[0],g=v[1],h=K(),w=h.pageToPixel,y=h.enabledElement;return e.useEffect(function(){if(n&&y){var e=function(e){if(Q(e),l.length>0&&p){var t=w([e.pageX,e.pageY]);c(function(e){return[].concat(e,[t])})}},t=function(e){Q(e),P(),b(),o(l),c([]),g(!1)},u=function(e){Q(e),P(),b(),c([]),g(!1)},s=function(e){"Escape"===e.code&&(Q(e),P(),b(),c([]),g(!1))},v=function(e){Q(e),x(),C();var t=w([e.pageX,e.pageY]);c([t]),g(!0)},h=function(e){if(e.stopPropagation(),0!==r.length){var t=w([e.pageX,e.pageY]),n=function(e,t){return e.find(function(e){return m.default(t,e.polygon)})||null}(r,t);d(n),i(n)}},E=function(e){e.stopPropagation(),f&&!p&&a(f)},b=function(){y&&y.element&&(y.element.addEventListener("mousemove",h),y.element.addEventListener("mousedown",v),y.element.addEventListener("click",E))},x=function(){y&&y.element&&(y.element.removeEventListener("mousemove",h),y.element.removeEventListener("mousedown",v),y.element.removeEventListener("click",E))},C=function(){y&&y.element&&(y.element.addEventListener("mousemove",e),y.element.addEventListener("mouseup",t),y.element.addEventListener("mouseleave",u),window.addEventListener("keydown",s))},P=function(){y&&y.element&&(y.element.removeEventListener("mousemove",e),y.element.removeEventListener("mouseup",t),y.element.removeEventListener("mouseleave",u),window.removeEventListener("keydown",s))};return l.length>0?C():b(),function(){x(),P()}}},[r,n,l,p,f,y,o,i,a,w]),[l]}({svgElement:d,device:i,contours:a,onAdd:l,onFocus:c,onRemove:s})[0],p=K(),h=v.map(p.pixelToCanvas).map(function(e){return e[0]+","+e[1]}).join(" ");return f.default.createElement("svg",{ref:d,width:r,height:o,style:g({},H,n),className:u},v&&v.length>0&&f.default.createElement(f.default.Fragment,null,f.default.createElement("polyline",{style:J.default,points:h}),f.default.createElement("polyline",{style:J.highlight,points:h})))},exports.SvgContourViewer=function(t){var n=t.style,r=t.width,o=t.height,i=t.contours,a=t.className,u=t.focusedContour,l=t.showOutline,c=void 0!==l&&l,s=t.showPolygonLabel,d=void 0!==s&&s,v=t.polygonAttrs,m=e.useRef(null),p=K(),h=p.pixelToCanvas,w=p.enabledElement;return f.default.createElement("svg",{ref:m,width:r,height:o,style:g({},U,n),className:a},0!==i.length&&w?function(e){var t=e.showOutline,n=e.showPolygonLabel,r=e.focusedContour,o=e.polygonAttrs,i=e.pixelToCanvas;return e.contours.map(function(e){var a=e.polygon,u=e.label,l=e.id,c=e.labelPosition,s=a===(null==r?void 0:r.polygon),d=a.map(i),v="function"==typeof o?o(e,t):void 0,m=c?i(c):void 0,p=d.map(function(e){return e[0]+","+e[1]}).join(" ");return f.default.createElement(f.default.Fragment,{key:l},t&&f.default.createElement("polygon",{style:g({},G,null==v?void 0:v.style),"data-border":"border","data-focus":s||void 0,points:p}),f.default.createElement("polygon",{style:g({},G,null==v?void 0:v.style),"data-focus":s||void 0,points:p}),n&&m&&f.default.createElement("text",{x:m[0],y:m[1]},null!=u?u:l))})}({showOutline:c,showPolygonLabel:d,contours:i,focusedContour:u,pixelToCanvas:h,polygonAttrs:v}):null)},exports.default=function(t){var r,i=t.image,a=t.Progress,u=t.viewport,l=t.interaction,c=t.onViewportChange,s=t.children,v=e.useRef(null),m=e.useRef(null!=u?u:{});return e.useEffect(function(){if(r)return function(e){d.default.enable(e)}(r),function(){!function(e){d.default.disable(e)}(r)}},[r=v.current]),function(t){var n=t.element,r=t.image,o=t.viewportRef,i=t.onViewportChange,a=e.useRef();e.useEffect(function(){if(r&&n){var e=void 0===r._imageSeriesKey||T!==(null==r?void 0:r._imageSeriesKey)?null==a?void 0:a.current:g({},E(S(n,r)),o.current),t=function(e,t,n){var r=d.default.getDefaultViewportForImage(e,t),o=n?E(r,n):r;return d.default.displayImage(e,t,o),{viewport:o,defaultViewport:r,image:t}}(n,r,o.current._initialViewport?o.current._initialViewport:e).viewport;void 0!==r._imageSeriesKey&&T!==r._imageSeriesKey&&(T=r._imageSeriesKey),o.current._initialViewport&&(a.current=o.current._initialViewport),i&&i(y(t))}},[r,n,o,i])}({element:v.current,image:i,viewportRef:m,onViewportChange:c}),function(t){var n=t.element,r=t.image,o=t.viewport,i=t.onViewportChange;e.useEffect(function(){if(n&&r&&o){var e,t=S(n,r),a=(null==o?void 0:o._resetViewport)&&t,u=a?t:C(n);u&&(P(n,E(u,o)),a&&i&&i(g({},y(t),null!=(e=null==o?void 0:o._resetViewport)?e:{})))}},[n,r,o,i])}({element:v.current,image:i,viewport:u,onViewportChange:c}),function(t){var r=t.element,i=t.interaction,a=t.viewport,u=t.onViewportChange;!function(t){var r=t.element,i=t.interaction;e.useEffect(function(){if(r){var e=n.fromEvent(r,"wheel");return M=e.pipe(o.filter(function(e){return 0!==e.deltaY}),o.tap(function(e){e.preventDefault()})).subscribe(function(e){null!=i&&i.mouseWheel&&(null==i||i.mouseWheel(e.deltaX,e.deltaY))}),function(){M.unsubscribe()}}},[i,r,t.onViewportChange])}({element:r,interaction:i,onViewportChange:u}),function(t){var r=t.element,i=t.interaction,a=t.onViewportChange;e.useEffect(function(){if(i&&r&&(null==r||r.removeEventListener("contextmenu",W),i.primaryDrag||i.secondaryDrag)){var e,t=n.fromEvent(r,"mousedown"),u=n.fromEvent(document,"mousemove"),l=n.fromEvent(document,"mouseup");return A=t.pipe(o.tap(function(t){var n=t.button;0===n&&(e="primaryDrag"),2===n&&(e="secondaryDrag")}),o.filter(function(){return void 0!==e}),o.tap(function(e){2===e.button&&(null==r||r.addEventListener("contextmenu",W))}),o.switchMap(function(e){var t=e.pageX,n=e.pageY;return u.pipe(o.map(function(e){e.preventDefault();var r=e.pageX-t,o=e.pageY-n;return t=e.pageX,n=e.pageY,{x:r,y:o}}),o.takeUntil(l))})).subscribe(function(t){var n=C(r);n&&e&&function(e){var t,n,r=e.element,o=e.dragged,i=e.viewport,a=e.onViewportChange,u=e.interaction[e.dragType];switch(typeof u){case"string":(t=u)&&(a?a(function(e){var n;return g({},e,null==(n=Y[t])?void 0:n.call(Y,i,o))}):P(r,E(i,null==(n=Y[t])?void 0:n.call(Y,i,o))));break;case"function":u({viewport:i,delta:o})}}({interaction:i,dragType:e,element:r,viewport:n,dragged:t,onViewportChange:a})}),function(){A.unsubscribe()}}},[r,i,a])}({element:r,interaction:i,onViewportChange:u}),function(t){var r=t.element,i=t.interaction,a=t.viewport;e.useEffect(function(){if(i&&r&&(null==r||r.removeEventListener("contextmenu",W),i.primaryClick||i.secondaryClick)){var e,t=n.fromEvent(r,"mousedown");if(i)return F=t.pipe(o.tap(function(t){var n=t.button;0===n&&(e="primaryClick"),2===n&&(e="secondaryClick")}),o.filter(function(){return void 0!==e}),o.tap(function(e){2===e.button&&(null==r||r.addEventListener("contextmenu",W))}),o.map(function(e){return{clientX:e.clientX,clientY:e.clientY,currentTarget:e.currentTarget}})).subscribe(function(t){var n,o=t.clientX,u=t.clientY,l=t.currentTarget.getBoundingClientRect(),c=function(e,t){var n;if(t)return{x:t.x,y:t.y};var r=(null!=(n=C(e))?n:{}).translation,o=(r=void 0===r?{}:r).x,i=r.y;return{x:void 0===o?0:o,y:void 0===i?0:i}}(r,a);e&&(null==(n=i[e])||n.call(i,-c.x+o-l.left,-c.y+u-l.top))}),function(){F.unsubscribe()}}},[r,i,a])}({element:r,interaction:i,viewport:a})}({element:v.current,interaction:l,viewport:u,onViewportChange:c}),e.useEffect(function(){u&&(m.current=u)},[u]),f.default.createElement(O,{ref:v,Progress:a,onViewportChange:c,imageEnabled:!!i},f.default.createElement(B,{element:v.current,imageEnabled:!!i,viewport:u},s))},exports.useDicomFile=function(){var t=e.useState({imageId:"",file:void 0}),n=t[0],r=t[1];return{imageId:n.imageId,setImageIdByFile:function(e){var t;(t=e,function(){try{return Promise.resolve(ee(X.onError)).then(function(e){var n;return null!=(n=null==e?void 0:e.wadouri.fileManager.add(t))?n:""})}catch(e){return Promise.reject(e)}}()).then(function(t){r({imageId:t,file:e})})},file:n.file}},exports.useFrame=function(t){var n=t.initial,r=t.max,o=e.useState(void 0===n?0:n),i=o[0],a=o[1];return{frame:i,setFrame:function(e){var t;(t="number"==typeof e?e:e(i))<0||t>r||a(e)}}},exports.useImage=function(t){var n=t.requestInterceptor,r=void 0===n?X.requestInterceptor:n,o=t.onError,i=void 0===o?X.onError:o,a=t.onImageLoaded,u=void 0===a?$:a,l=h(t,me),c=function(e){return e.wadouri?{id:ve(e.wadouri),scheme:"wadouri"}:e.dicomfile?{id:ve(e.dicomfile),scheme:"dicomfile"}:e.web?{id:ve(e.web),scheme:"web"}:{id:void 0,scheme:void 0}}(l),s=c.id,f=c.scheme,d=e.useRef(),v=e.useReducer(fe,de),m=v[0],p=m.loadingState,g=m.image,w=v[1],y=ne(l,i);return e.useEffect(function(){null!=d&&d.current||(d.current=u)},[u]),e.useEffect(function(){y&&s&&f&&(w({type:"loading"}),function(e){var t=e.imageId,n=e.imageScheme,r=e.requestInterceptor,o=e.onError;try{return Promise.resolve(function(e,o){try{var i=Promise.resolve(function(e){var t=e.imageId,n=e.imageScheme,r=e.requestInterceptor;try{return Promise.resolve(function(e,o){try{var i=Promise.resolve(x(t,{loader:"dicomfile"===n?void 0:re(r)}))}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw Z(e)}))}catch(e){return Promise.reject(e)}}({imageId:t,imageScheme:n,requestInterceptor:r}))}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw o(Z(e)),e}))}catch(e){return Promise.reject(e)}}({imageId:s,imageScheme:f,requestInterceptor:r,onError:i}).then(function(e){w({type:"success",payload:e}),setTimeout(function(){null==d.current||d.current()},0)}).catch(function(){return w({type:"fail"})}))},[y,s,f,r,i]),{image:g,loadingState:p}},exports.useInteraction=function(t){void 0===t&&(t={});var n=e.useState(g({},se,t));return{interaction:n[0],setInteraction:n[1]}},exports.useMultipleImages=function(t){var r=t.requestInterceptor,i=void 0===r?X.requestInterceptor:r,a=t.onError,l=void 0===a?X.onError:a,c=t.onImagesLoaded,s=void 0===c?$:c,f=h(t,ce),d=e.useRef(),v=function(t){var r,i,a,l=t.onError,c=t.requestInterceptor,s=t.onImagesLoaded,f=void 0===s?$:s,d=h(t,le),v=(r=d).wadouri?{ids:ie(r.wadouri),scheme:"wadouri"}:r.dicomfile?{ids:ie(r.dicomfile),scheme:"dicomfile"}:r.web?{ids:ie(r.web),scheme:"web"}:{ids:[],scheme:void 0},m=v.ids,p=v.scheme,w=e.useState({loadingStates:(i=Array.isArray(m)?m.length:0,a=Array(i).fill("initial"),new Map(a.map(function(e,t){return[t,e]}))),_currentIndex:-1}),y=w[0].loadingStates,E=w[1],b=e.useRef([]),C=ne(d,l);return e.useEffect(function(){m&&0!==m.length&&p&&C&&(b.current=[],E(function(e){return g({},e,{loadingStates:e.loadingStates.set(0,"loading")})}),ae=u.uid(),function(e){var t=e.images,r=e.imageScheme,i=e.requestInterceptor,a=0;return q({loaded:a,total:t.length}),n.from(t).pipe(o.concatMap(function(e){return function(e,t,n){return x(e,{loader:"dicomfile"===t?void 0:re(n)})}(e,r,i)}),o.map(function(e){return q({loaded:a+=1,total:t.length}),{image:e,loaded:a}}),o.catchError(function(e){throw Z(e)}))}({images:m,imageScheme:p,requestInterceptor:c}).subscribe({next:function(e){var t=e.loaded;b.current=[].concat(b.current,[g({},e.image,{_imageSeriesKey:ae})]),E(function(e){return{loadingStates:oe({size:m.length,stateMap:e.loadingStates,value:t}),_currentIndex:t-1}})},error:function(e){l(e),E(function(e){return g({},e,{loadingStates:e.loadingStates.set(e._currentIndex+1,"fail")})})},complete:function(){f()}}))},[m,p,l,f,c,C]),{images:b.current,loadingStates:Array.from(y.values())}}(g({},f,{onError:l,requestInterceptor:i,onImagesLoaded:d.current})),m=v.loadingStates,p=v.images,w=void 0===p?[]:p;return e.useEffect(function(){null!=d&&d.current||(d.current=s)},[s]),{loadingStates:m,images:w}},exports.useOverlayContext=K,exports.useViewport=function(t){var n=e.useState(g({},t?g({},z,{_initialViewport:t}):z)),r=n[0],o=n[1];return{viewport:r,setViewport:o,resetViewport:function(){o(g({},r,{_resetViewport:t}))},initialized:r.scale!==z.scale}};
//# sourceMappingURL=index.js.map
import React from 'react';
import { ProgressComponent } from '../../types';
import { ProgressComponent, OnViewportChange } from '../../types';
declare const ViewerWrapper: React.MemoExoticComponent<React.ForwardRefExoticComponent<{
Progress?: ProgressComponent | undefined;
onViewportChange: OnViewportChange | undefined;
imageEnabled: boolean;
} & {

@@ -6,0 +8,0 @@ children?: React.ReactNode;

import React from 'react';
export default function useResize(ref: React.ForwardedRef<HTMLDivElement>): {
resizeRef: React.RefObject<HTMLDivElement>;
width: number | undefined;
height: number | undefined;
};
//# sourceMappingURL=useResize.d.ts.map
import { LoadingState, ImageId, HTTP } from '../../types';
import { CornerstoneImage } from '../../utils/cornerstoneHelper';
interface OnImageLoaded {
(): void;
}
interface UseImage {
(props: Partial<HTTP> & ImageId): {
(props: Partial<HTTP> & ImageId & {
onImageLoaded?: OnImageLoaded;
}): {
loadingState: LoadingState;

@@ -6,0 +11,0 @@ image: CornerstoneImage | undefined;

import { Interaction } from './types';
export declare function useInteraction(): {
export declare function useInteraction(initialInteraction?: Partial<Interaction>): {
interaction: Interaction;

@@ -4,0 +4,0 @@ setInteraction: React.Dispatch<React.SetStateAction<Interaction>>;

import { HTTP, ImageId } from '../../types';
import { ImagesLoadState } from './types';
import { ImagesLoadState, OnImagesLoaded } from './types';
interface UseMultiframeImages {
(props: Partial<HTTP> & ImageId): ImagesLoadState;
(props: Partial<HTTP> & ImageId & {
onImagesLoaded?: OnImagesLoaded;
}): ImagesLoadState;
}

@@ -6,0 +8,0 @@ /**

import { CornerstoneImage } from '../../utils/cornerstoneHelper';
import { Image } from '../../Viewer/types';
import { HTTP, LoaderType, LoadingState } from '../../types';

@@ -9,3 +10,3 @@ export interface Loaded {

loadingStates: LoadingState[];
images: CornerstoneImage[];
images: Image[];
}

@@ -16,2 +17,5 @@ export declare type Props = {

} & Partial<HTTP>;
export interface OnImagesLoaded {
(): void;
}
//# sourceMappingURL=types.d.ts.map
import { HTTP, ImageId } from '../../types';
import { ImagesLoadState } from './types';
import { ImagesLoadState, OnImagesLoaded } from './types';
interface UseLoadImages {
({ onError, requestInterceptor, ...rest }: HTTP & ImageId): ImagesLoadState;
({ onError, requestInterceptor, ...rest }: HTTP & ImageId & {
onImagesLoaded?: OnImagesLoaded;
}): ImagesLoadState;
}

@@ -6,0 +8,0 @@ /**

import { Viewport, BasicViewport } from '../types';
/**
* @param defaultViewport The user-defined default viewport.
* @param initialViewport The user-defined initial viewport.
* @returns {viewport} The viewport which is used as a Viewer's viewport prop.

@@ -9,3 +9,3 @@ * @returns {setViewport} The viewport setter which is used as a Viewer's onViewportChange prop.

*/
export declare function useViewport(defaultViewport?: Partial<BasicViewport>): {
export declare function useViewport(initialViewport?: Partial<BasicViewport>): {
viewport: Viewport;

@@ -12,0 +12,0 @@ setViewport: React.Dispatch<React.SetStateAction<Viewport>>;

@@ -1,7 +0,7 @@

import { CornerstoneViewport } from '../utils/cornerstoneHelper';
import { CornerstoneImage } from '../utils/cornerstoneHelper';
import { Element, Viewport, OnViewportChange } from '../types';
interface Prop {
element: Element;
image: CornerstoneImage | undefined;
viewport?: Viewport;
initialViewport: CornerstoneViewport | undefined;
onViewportChange?: OnViewportChange;

@@ -15,4 +15,4 @@ }

*/
export default function useViewportUpdate({ element, viewport: newViewport, initialViewport, onViewportChange, }: Prop): void;
export default function useViewportUpdate({ element, image, viewport: newViewportProp, onViewportChange, }: Prop): void;
export {};
//# sourceMappingURL=useViewportUpdate.d.ts.map
export { InsightViewer as default } from './Viewer';
export { SvgContourViewer } from './Viewer/SvgContourViewer';
export { SvgContourDrawer } from './Viewer/SvgContourDrawer';
export { useMultipleImages } from './hooks/useMultipleImages';

@@ -8,5 +10,7 @@ export { useViewport } from './hooks/useViewport';

export type { Interaction, SetInteraction } from './hooks/useInteraction/types';
export type { Viewport, ViewerError } from './types';
export type { Viewport, ViewerError, Contours, Contour, Point } from './types';
export type { DragEvent, Click, Drag, Wheel, } from './hooks/useInteraction/types';
export { useDicomFile } from './hooks/useDicomFile';
export { useOverlayContext } from './contexts';
export type { OverlayContext } from './contexts';
//# sourceMappingURL=index.d.ts.map

@@ -26,5 +26,7 @@ import { Dispatch, SetStateAction } from 'react';

export declare type Viewport = BasicViewport & {
_default?: Partial<BasicViewport>;
_reset?: Partial<BasicViewport>;
_initialViewport?: Partial<BasicViewport>;
_resetViewport?: Partial<BasicViewport>;
};
export declare type Point = [number, number];
export declare type Contours = Point[][];
export interface HTTP {

@@ -51,2 +53,25 @@ onError: OnError;

};
export interface Contour {
/** Serves as id by contour */
id: number;
/**
* The method used is different depending on the mode
* - (mode: contour) = [[x, y], [x, y], [x, y]...]
* - (mode: circle) = [[centerX, centerY][radius, ]]
* - (mode: point) = [[x, y]]
*/
polygon: Point[];
/** If label is present, it will output instead of id */
label?: string;
/** polygon pabel position = [x, y] */
labelPosition?: Point;
/**
* The data-attribute is added to the svg element
* You can implement functions such as css styling based on the attributes
*/
dataAttrs?: {
[attr: string]: string;
};
lineWidth: number;
}
//# sourceMappingURL=index.d.ts.map
import { CornerstoneViewport } from '../cornerstoneHelper/types';
import { Viewport } from '../../types';
export declare function formatViewport(cornerstoneViewport: CornerstoneViewport | undefined): Viewport;
export declare function formatViewerViewport(cornerstoneViewport: CornerstoneViewport | undefined): Viewport;
export declare function formatCornerstoneViewport(cornerstoneViewport: CornerstoneViewport, viewport?: Partial<Viewport>): CornerstoneViewport;
//# sourceMappingURL=formatViewport.d.ts.map

@@ -16,3 +16,4 @@ import { ViewerError } from '../../types';

export declare function normalizeError(e: Error | HTTPError | unknown): ViewerError;
export declare const noop: () => void;
export {};
//# sourceMappingURL=index.d.ts.map
import cornerstone from 'cornerstone-core';
export type { EnabledElement, PixelCoordinate } from 'cornerstone-core';
export declare type CornerstoneImage = cornerstone.Image;
export declare type CornerstoneViewport = Required<Pick<cornerstone.Viewport, 'scale' | 'translation' | 'voi' | 'invert' | 'pixelReplication' | 'hflip' | 'vflip' | 'rotation' | 'labelmap'>> & Pick<cornerstone.Viewport, 'colormap' | 'modalityLUT' | 'voiLUT'>;
export declare type CornerstoneViewportParam = cornerstone.Viewport;
//# sourceMappingURL=types.d.ts.map

@@ -1,3 +0,3 @@

import cornerstone from 'cornerstone-core';
import { CornerstoneImage, CornerstoneViewport, CornerstoneViewportParam } from './types';
import cornerstone, { CanvasCoordinate, EnabledElement, PixelCoordinate } from 'cornerstone-core';
import { CornerstoneImage, CornerstoneViewport } from './types';
export declare function enable(element: HTMLDivElement): void;

@@ -7,3 +7,3 @@ export declare function disable(element: HTMLDivElement): void;

export declare function getCornerstone(): typeof cornerstone;
export declare function displayImage(element: HTMLDivElement, image: CornerstoneImage, viewportOption?: CornerstoneViewportParam): {
export declare function displayImage(element: HTMLDivElement, image: CornerstoneImage, viewportOption?: cornerstone.Viewport): {
viewport: CornerstoneViewport;

@@ -15,3 +15,8 @@ defaultViewport: CornerstoneViewport;

export declare function getViewport(element: HTMLDivElement): ReturnType<typeof cornerstone.getViewport>;
export declare function setViewport(element: HTMLDivElement, viewport: CornerstoneViewportParam): ReturnType<typeof cornerstone.setViewport>;
export declare function setViewport(element: HTMLDivElement, viewport: cornerstone.Viewport): ReturnType<typeof cornerstone.setViewport>;
export declare function getEnabledElement(element: HTMLElement): ReturnType<typeof cornerstone.getEnabledElement>;
export declare function setToPixelCoordinateSystem(element: EnabledElement, context: CanvasRenderingContext2D): ReturnType<typeof cornerstone.setToPixelCoordinateSystem>;
export declare function pixelToCanvas(element: HTMLElement, points: PixelCoordinate): CanvasCoordinate;
export declare function getDefaultViewportForImage(element: HTMLDivElement, image: CornerstoneImage): ReturnType<typeof cornerstone.getDefaultViewportForImage>;
export declare function pageToPixel(element: HTMLElement, pageX: number, pageY: number): PixelCoordinate;
//# sourceMappingURL=utils.d.ts.map
export { loadingProgressMessage } from './loadingProgress';
export { initialViewportMessage } from './initialViewport';
export { loadedCountMessageMessage } from './loadedCountMessage';
//# sourceMappingURL=index.d.ts.map

@@ -5,4 +5,7 @@ import { CornerstoneImage } from '../utils/cornerstoneHelper';

import { Interaction } from '../hooks/useInteraction/types';
export declare type Image = (CornerstoneImage & {
_imageSeriesKey?: string;
}) | undefined;
export declare type ViewerProp = {
image: CornerstoneImage | undefined;
image: Image;
} & {

@@ -9,0 +12,0 @@ Progress?: ProgressComponent;

{
"name": "@lunit/insight-viewer",
"version": "5.1.0-alpha.6",
"version": "5.1.0-alpha.7",
"description": "cornerstone 라이브러리를 기반으로 Dicom Image를 다루기 위한 여러 Component들을 제공한다.",
"source": "src/index.ts",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"exports": {
".": "./dist/index.esm.js",
"./contour": "./dist/contour.esm.js"
},
"types": "dist/types/index.d.ts",
"files": [
"dist"
],
"repository": {

@@ -29,7 +29,9 @@ "type": "git",

"scripts": {
"build": "yarn run clean & yarn run compile",
"dev": "microbundle watch -f esm --jsx React.createElement --tsconfig tsconfig.json",
"compile": "microbundle --jsx React.createElement --tsconfig tsconfig.build.json -f modern,esm,cjs",
"clean": "rimraf dist *.tsbuildinfo",
"test": "yarn jest"
"build": "scripty",
"dev": "scripty",
"compile": "scripty",
"clean": "scripty",
"test": "scripty",
"prepublish": "scripty",
"publish": "scripty"
},

@@ -46,4 +48,6 @@ "publishConfig": {

"ky": "^0.27.0",
"point-in-polygon": "^1.1.0",
"react-resize-detector": "^6.7.0",
"rxjs": "^7.0.0"
"rxjs": "^7.0.0",
"uid": "^2.0.0"
},

@@ -54,2 +58,4 @@ "devDependencies": {

"@types/jest": "^26.0.24",
"@types/node": "^17.0.7",
"@types/point-in-polygon": "^1.1.1",
"@types/react": "^17.0.3",

@@ -60,2 +66,3 @@ "eslint-import-resolver-node": "^0.3.4",

"react-is": "^17.0.2",
"scripty": "^2.0.0",
"ts-jest": "^26.5.4"

@@ -62,0 +69,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc