@ohif/extension-measurement-tracking 0.0.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! For license information please see ohif-extension-measurement-tracking.umd.js.LICENSE.txt */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@ohif/ui"),require("@ohif/core"),require("@ohif/extension-cornerstone-dicom-sr"),require("@cornerstonejs/tools"),require("@cornerstonejs/core")):"function"==typeof define&&define.amd?define(["@ohif/ui","@ohif/core","@ohif/extension-cornerstone-dicom-sr","@cornerstonejs/tools","@cornerstonejs/core"],t):"object"==typeof exports?exports["ohif-extension-measurement-tracking"]=t(require("@ohif/ui"),require("@ohif/core"),require("@ohif/extension-cornerstone-dicom-sr"),require("@cornerstonejs/tools"),require("@cornerstonejs/core")):e["ohif-extension-measurement-tracking"]=t(e["@ohif/ui"],e["@ohif/core"],e["@ohif/extension-cornerstone-dicom-sr"],e["@cornerstonejs/tools"],e["@cornerstonejs/core"])}(globalThis,((e,t,n,r,i)=>(()=>{var o,a,s,c,u={531:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)},i=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n},o=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a};Object.defineProperty(t,"__esModule",{value:!0});var a=n(735),s=n(519),c={immediate:!1};t.useMachine=function(e,t){void 0===t&&(t=c);var n=t.context,u=t.guards,l=t.actions,d=t.activities,f=t.services,p=t.delays,h=t.immediate,v=t.state,y=i(t,["context","guards","actions","activities","services","delays","immediate","state"]),m={context:n,guards:u,actions:l,activities:d,services:f,delays:p},g=a.useRef(null);null===g.current&&(g.current=e.withConfig(m,r(r({},e.context),n)));var S=a.useRef(null);null===S.current&&(S.current=s.interpret(g.current,y).onTransition((function(e){e.changed&&x(e)})));var b=S.current;a.useEffect((function(){Object.assign(b.machine.options.actions,l)}),[l]),a.useEffect((function(){Object.assign(b.machine.options.services,f)}),[f]);var E=v?s.State.create(v):b.initialState,w=o(a.useState((function(){return E})),2),I=w[0],x=w[1];return h&&b.start(),a.useEffect((function(){return b.start(v?E:void 0),function(){b.stop()}}),[]),[I,b.send,b]},t.useService=function(e){var t=o(a.useState(e.state),2),n=t[0],r=t[1];return a.useEffect((function(){r(e.state);var t=e.subscribe((function(e){e.changed&&r(e)}));return function(){t.unsubscribe()}}),[e]),[n,e.send,e]};var u=n(283);t.useActor=u.useActor},283:function(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a};Object.defineProperty(t,"__esModule",{value:!0});var i=n(735);t.useActor=function(e){var t=r(i.useState(void 0),2),n=t[0],o=t[1],a=i.useRef(e);return i.useEffect((function(){if(e){a.current=e;var t=e.subscribe(o);return function(){t.unsubscribe()}}}),[e]),[n,a.current?a.current.send:function(){}]}},18:(e,t,n)=>{"use strict";n.d(t,{Z:()=>V,I:()=>P});var r=n(735),i=n(216),o=n.n(i),a=n(519),s=n(531),c=n(369);const u=-1,l=0,d=1,f=2,p=3,h=4,v=5,y={id:"measurementTracking",initial:"idle",context:{trackedStudy:"",trackedSeries:[],ignoredSeries:[],prevTrackedStudy:"",prevTrackedSeries:[],prevIgnoredSeries:[],ignoredSRSeriesForHydration:[],isDirty:!1},states:{off:{type:"final"},idle:{entry:"clearContext",on:{TRACK_SERIES:"promptBeginTracking",SET_TRACKED_SERIES:[{target:"tracking",actions:["setTrackedStudyAndMultipleSeries","setIsDirtyToClean"]}],PROMPT_HYDRATE_SR:{target:"promptHydrateStructuredReport",cond:"hasNotIgnoredSRSeriesForHydration"},RESTORE_PROMPT_HYDRATE_SR:"promptHydrateStructuredReport",HYDRATE_SR:"hydrateStructuredReport"}},promptBeginTracking:{invoke:{src:"promptBeginTracking",onDone:[{target:"tracking",actions:["setTrackedStudyAndSeries","setIsDirty"],cond:"shouldSetStudyAndSeries"},{target:"off",cond:"shouldKillMachine"},{target:"idle"}],onError:{target:"idle"}}},tracking:{on:{TRACK_SERIES:[{target:"promptTrackNewStudy",cond:"isNewStudy"},{target:"promptTrackNewSeries",cond:"isNewSeries"}],UNTRACK_SERIES:[{target:"tracking",actions:["removeTrackedSeries","setIsDirty"],cond:"hasRemainingTrackedSeries"},{target:"idle"}],SET_TRACKED_SERIES:[{target:"tracking",actions:["setTrackedStudyAndMultipleSeries"]}],SAVE_REPORT:"promptSaveReport",SET_DIRTY:[{target:"tracking",actions:["setIsDirty"],cond:"shouldSetDirty"},{target:"tracking"}]}},promptTrackNewSeries:{invoke:{src:"promptTrackNewSeries",onDone:[{target:"tracking",actions:["addTrackedSeries","setIsDirty"],cond:"shouldAddSeries"},{target:"tracking",actions:["discardPreviouslyTrackedMeasurements","setTrackedStudyAndSeries","setIsDirty"],cond:"shouldSetStudyAndSeries"},{target:"promptSaveReport",cond:"shouldPromptSaveReport"},{target:"tracking"}],onError:{target:"idle"}}},promptTrackNewStudy:{invoke:{src:"promptTrackNewStudy",onDone:[{target:"tracking",actions:["discardPreviouslyTrackedMeasurements","setTrackedStudyAndSeries","setIsDirty"],cond:"shouldSetStudyAndSeries"},{target:"tracking",actions:["ignoreSeries"],cond:"shouldAddIgnoredSeries"},{target:"promptSaveReport",cond:"shouldPromptSaveReport"},{target:"tracking"}],onError:{target:"idle"}}},promptSaveReport:{invoke:{src:"promptSaveReport",onDone:[{target:"idle",actions:["clearAllMeasurements","showStructuredReportDisplaySetInActiveViewport"],cond:"shouldSaveAndContinueWithSameReport"},{target:"tracking",actions:["discardPreviouslyTrackedMeasurements","setTrackedStudyAndSeries"],cond:"shouldSaveAndStartNewReport"},{target:"tracking"}],onError:{target:"idle"}}},promptHydrateStructuredReport:{invoke:{src:"promptHydrateStructuredReport",onDone:[{target:"tracking",actions:["setTrackedStudyAndMultipleSeries","jumpToFirstMeasurementInActiveViewport","setIsDirtyToClean"],cond:"shouldHydrateStructuredReport"},{target:"idle",actions:["ignoreHydrationForSRSeries"],cond:"shouldIgnoreHydrationForSR"}],onError:{target:"idle"}}},hydrateStructuredReport:{invoke:{src:"hydrateStructuredReport",onDone:[{target:"tracking",actions:["setTrackedStudyAndMultipleSeries","jumpToFirstMeasurementInActiveViewport","setIsDirtyToClean"]}],onError:{target:"idle"}}}},strict:!0},m={services:{promptBeginTracking:(e,t)=>{},promptTrackNewStudy:(e,t)=>{},promptTrackNewSeries:(e,t)=>{}},actions:{discardPreviouslyTrackedMeasurements:(e,t)=>{console.log("discardPreviouslyTrackedMeasurements: not implemented")},clearAllMeasurements:(e,t)=>{console.log("clearAllMeasurements: not implemented")},jumpToFirstMeasurementInActiveViewport:(e,t)=>{console.warn("jumpToFirstMeasurementInActiveViewport: not implemented")},showStructuredReportDisplaySetInActiveViewport:(e,t)=>{console.warn("showStructuredReportDisplaySetInActiveViewport: not implemented")},clearContext:(0,a.assign)({trackedStudy:"",trackedSeries:[],ignoredSeries:[],prevTrackedStudy:"",prevTrackedSeries:[],prevIgnoredSeries:[]}),setTrackedStudyAndSeries:(0,a.assign)(((e,t)=>({prevTrackedStudy:e.trackedStudy,prevTrackedSeries:e.trackedSeries.slice(),prevIgnoredSeries:e.ignoredSeries.slice(),trackedStudy:t.data.StudyInstanceUID,trackedSeries:[t.data.SeriesInstanceUID],ignoredSeries:[]}))),setTrackedStudyAndMultipleSeries:(0,a.assign)(((e,t)=>{const n=t.StudyInstanceUID||t.data.StudyInstanceUID,r=t.SeriesInstanceUIDs||t.data.SeriesInstanceUIDs;return{prevTrackedStudy:e.trackedStudy,prevTrackedSeries:e.trackedSeries.slice(),prevIgnoredSeries:e.ignoredSeries.slice(),trackedStudy:n,trackedSeries:[...e.trackedSeries,...r],ignoredSeries:[]}})),setIsDirtyToClean:(0,a.assign)(((e,t)=>({isDirty:!1}))),setIsDirty:(0,a.assign)(((e,t)=>({isDirty:!0}))),ignoreSeries:(0,a.assign)(((e,t)=>({prevIgnoredSeries:[...e.ignoredSeries],ignoredSeries:[...e.ignoredSeries,t.data.SeriesInstanceUID]}))),ignoreHydrationForSRSeries:(0,a.assign)(((e,t)=>({ignoredSRSeriesForHydration:[...e.ignoredSRSeriesForHydration,t.data.srSeriesInstanceUID]}))),addTrackedSeries:(0,a.assign)(((e,t)=>({prevTrackedSeries:[...e.trackedSeries],trackedSeries:[...e.trackedSeries,t.data.SeriesInstanceUID]}))),removeTrackedSeries:(0,a.assign)(((e,t)=>({prevTrackedSeries:e.trackedSeries.slice().filter((e=>e!==t.SeriesInstanceUID)),trackedSeries:e.trackedSeries.slice().filter((e=>e!==t.SeriesInstanceUID))})))},guards:{shouldSetDirty:(e,t)=>void 0===t.SeriesInstanceUID||e.trackedSeries.includes(t.SeriesInstanceUID),shouldKillMachine:(e,t)=>t.data&&t.data.userResponse===u,shouldAddSeries:(e,t)=>t.data&&t.data.userResponse===f,shouldSetStudyAndSeries:(e,t)=>t.data&&t.data.userResponse===p,shouldAddIgnoredSeries:(e,t)=>t.data&&t.data.userResponse===h,shouldPromptSaveReport:(e,t)=>t.data&&t.data.userResponse===d,shouldIgnoreHydrationForSR:(e,t)=>t.data&&t.data.userResponse===l,shouldSaveAndContinueWithSameReport:(e,t)=>t.data&&t.data.userResponse===d&&!0===t.data.isBackupSave,shouldSaveAndStartNewReport:(e,t)=>t.data&&t.data.userResponse===d&&!1===t.data.isBackupSave,shouldHydrateStructuredReport:(e,t)=>t.data&&t.data.userResponse===v,hasRemainingTrackedSeries:(e,t)=>e.trackedSeries.length>1||!e.trackedSeries.includes(t.SeriesInstanceUID),hasNotIgnoredSRSeriesForHydration:(e,t)=>!e.ignoredSRSeriesForHydration.includes(t.SeriesInstanceUID),isNewStudy:(e,t)=>!e.ignoredSeries.includes(t.SeriesInstanceUID)&&e.trackedStudy!==t.StudyInstanceUID,isNewSeries:(e,t)=>!e.ignoredSeries.includes(t.SeriesInstanceUID)&&!e.trackedSeries.includes(t.SeriesInstanceUID)}},g={NO_NEVER:-1,CANCEL:0,CREATE_REPORT:1,ADD_SERIES:2,SET_STUDY_AND_SERIES:3};const S=function(e,t,n){let{servicesManager:r,extensionManager:i}=e;const{uiViewportDialogService:o}=r.services,{viewportIndex:a,StudyInstanceUID:s,SeriesInstanceUID:c}=n;return new Promise((async function(e,t){let n=await function(e,t){return new Promise((function(n,r){const i="Track measurements for this series?",o=[{id:"prompt-begin-tracking-cancel",type:"cancel",text:"No",value:g.CANCEL},{id:"prompt-begin-tracking-no-do-not-ask-again",type:"secondary",text:"No, do not ask again",value:g.NO_NEVER},{id:"prompt-begin-tracking-yes",type:"primary",text:"Yes",value:g.SET_STUDY_AND_SERIES}],a=t=>{e.hide(),n(t)};e.show({viewportIndex:t,id:"measurement-tracking-prompt-begin-tracking",type:"info",message:i,actions:o,onSubmit:a,onOutsideClick:()=>{e.hide(),n(g.CANCEL)}})}))}(o,a);e({userResponse:n,StudyInstanceUID:s,SeriesInstanceUID:c,viewportIndex:a})}))},b={NO_NEVER:-1,CANCEL:0,CREATE_REPORT:1,ADD_SERIES:2,SET_STUDY_AND_SERIES:3,NO_NOT_FOR_SERIES:4};const E=function(e,t,n){let{servicesManager:r,extensionManager:i}=e;const{UIViewportDialogService:o}=r.services,{viewportIndex:a,StudyInstanceUID:s,SeriesInstanceUID:c}=n;return new Promise((async function(e,n){let r=await function(e,t){return new Promise((function(n,r){const i="Do you want to add this measurement to the existing report?",o=[{type:"cancel",text:"Cancel",value:b.CANCEL},{type:"secondary",text:"Create new report",value:b.CREATE_REPORT},{type:"primary",text:"Add to existing report",value:b.ADD_SERIES}],a=t=>{e.hide(),n(t)};e.show({viewportIndex:t,type:"info",message:i,actions:o,onSubmit:a,onOutsideClick:()=>{e.hide(),n(b.CANCEL)}})}))}(o,a);r===b.CREATE_REPORT&&(r=t.isDirty?await function(e,t){return new Promise((function(n,r){const i="You have existing tracked measurements. What would you like to do with your existing tracked measurements?",o=[{type:"cancel",text:"Cancel",value:b.CANCEL},{type:"secondary",text:"Save",value:b.CREATE_REPORT},{type:"primary",text:"Discard",value:b.SET_STUDY_AND_SERIES}],a=t=>{e.hide(),n(t)};e.show({viewportIndex:t,type:"warning",message:i,actions:o,onSubmit:a,onOutsideClick:()=>{e.hide(),n(b.CANCEL)}})}))}(o,a):b.SET_STUDY_AND_SERIES),e({userResponse:r,StudyInstanceUID:s,SeriesInstanceUID:c,viewportIndex:a,isBackupSave:!1})}))},w={NO_NEVER:-1,CANCEL:0,CREATE_REPORT:1,ADD_SERIES:2,SET_STUDY_AND_SERIES:3,NO_NOT_FOR_SERIES:4};const I=function(e,t,n){let{servicesManager:r,extensionManager:i}=e;const{UIViewportDialogService:o}=r.services,{viewportIndex:a,StudyInstanceUID:s,SeriesInstanceUID:c}=n;return new Promise((async function(e,n){let r=await function(e,t){return new Promise((function(n,r){const i="Track measurements for this series?",o=[{type:"cancel",text:"No",value:w.CANCEL},{type:"secondary",text:"No, do not ask again for this series",value:w.NO_NOT_FOR_SERIES},{type:"primary",text:"Yes",value:w.SET_STUDY_AND_SERIES}],a=t=>{e.hide(),n(t)};e.show({viewportIndex:t,type:"info",message:i,actions:o,onSubmit:a,onOutsideClick:()=>{e.hide(),n(w.CANCEL)}})}))}(o,a);r===w.SET_STUDY_AND_SERIES&&(r=t.isDirty?await function(e,t){return new Promise((function(n,r){const i="Measurements cannot span across multiple studies. Do you want to save your tracked measurements?",o=[{type:"cancel",text:"Cancel",value:w.CANCEL},{type:"secondary",text:"No, discard previously tracked series & measurements",value:w.SET_STUDY_AND_SERIES},{type:"primary",text:"Yes",value:w.CREATE_REPORT}],a=t=>{e.hide(),n(t)};e.show({viewportIndex:t,type:"warning",message:i,actions:o,onSubmit:a,onOutsideClick:()=>{e.hide(),n(w.CANCEL)}})}))}(o,a):w.SET_STUDY_AND_SERIES),e({userResponse:r,StudyInstanceUID:s,SeriesInstanceUID:c,viewportIndex:a,isBackupSave:!1})}))};var x=n(762);function D(){return r.createElement("div",{className:"text-primary-active"},"Loading...")}const _=async function(e,t,n,r,i){const{displaySetService:o,uiNotificationService:a,uiDialogService:s}=e.services,c=s.create({showOverlay:!0,isDraggable:!1,centralize:!0,content:D});try{const e=await t.runCommand("storeMeasurements",{measurementData:r,dataSource:n,additionalFindingTypes:["ArrowAnnotate"],options:i},"CORNERSTONE_STRUCTURED_REPORT");x.DicomMetadataStore.addInstances([e],!0);const s=o.getMostRecentDisplaySet();return a.show({title:"Create Report",message:"Measurements saved successfully",type:"success"}),[s]}catch(e){a.show({title:"Create Report",message:e.message||"Failed to store measurements",type:"error"})}finally{s.dismiss({id:c})}},k={NO_NEVER:-1,CANCEL:0,CREATE_REPORT:1,ADD_SERIES:2,SET_STUDY_AND_SERIES:3,NO_NOT_FOR_SERIES:4};const T=4700;const R=function(e,t,n){let{servicesManager:i,commandsManager:o,extensionManager:a}=e;const{uiDialogService:s,measurementService:u,displaySetService:l}=i.services,d=void 0===n.viewportIndex?n.data.viewportIndex:n.viewportIndex,f=void 0===n.isBackupSave?n.data.isBackupSave:n.isBackupSave,p=n?.data?.StudyInstanceUID,h=n?.data?.SeriesInstanceUID,{trackedStudy:v,trackedSeries:y}=t;let m;return new Promise((async function(e,t){const n=await function(e){return new Promise((function(t,n){let i;i=e.create({centralize:!0,isDraggable:!1,content:c.Dialog,useLastPosition:!1,showOverlay:!0,contentProps:{title:"Provide a name for your report",value:{label:""},noCloseButton:!0,onClose:()=>{e.dismiss({id:i}),t({action:k.CANCEL,value:void 0})},actions:[{id:"cancel",text:"Cancel",type:"primary"},{id:"save",text:"Save",type:"secondary"}],onSubmit:n=>{let{action:r,value:o}=n;switch(e.dismiss({id:i}),r.id){case"save":t({action:k.CREATE_REPORT,value:o.label});break;case"cancel":t({action:k.CANCEL,value:void 0})}},body:n=>{let{value:o,setValue:a}=n;return r.createElement("div",{className:"p-4 bg-primary-dark"},r.createElement(c.Input,{autoFocus:!0,className:"mt-2 bg-black border-primary-main",type:"text",containerClassName:"mr-2",value:o.label,onChange:e=>{e.persist(),a((t=>({...t,label:e.target.value})))},onKeyPress:n=>{"Enter"===n.key&&(e.dismiss({id:i}),t({action:k.CREATE_REPORT,value:o.label}))}}))}}})}))}(s);if(n.action===k.CREATE_REPORT){const e=a.getDataSources()[0],t=u.getMeasurements().filter((e=>v===e.referenceStudyUID&&y.includes(e.referenceSeriesUID))),r=void 0===n.value||""===n.value?"Research Derived Series":n.value,s=function(e){const t=e.getActiveDisplaySets().filter((e=>"SR"===e.Modality)).map((e=>e.SeriesNumber));return Math.max(...t,T)+1}(l);m=await _(i,o,e,t,{SeriesDescription:r,SeriesNumber:s})}else n.action,k.CANCEL;e({userResponse:n.action,createdDisplaySetInstanceUIDs:m,StudyInstanceUID:p,SeriesInstanceUID:h,viewportIndex:d,isBackupSave:f})}))};var O=n(148);const N={NO_NEVER:-1,CANCEL:0,CREATE_REPORT:1,ADD_SERIES:2,SET_STUDY_AND_SERIES:3,NO_NOT_FOR_SERIES:4,HYDRATE_REPORT:5};const A=function(e,t,n){let{servicesManager:r,extensionManager:i}=e;const{uiViewportDialogService:o,displaySetService:a}=r.services,{viewportIndex:s,displaySetInstanceUID:c}=n,u=a.getDisplaySetByUID(c);return new Promise((async function(e,t){const a=await function(e,t){return new Promise((function(n,r){const i="Do you want to continue tracking measurements for this study?",o=[{type:"secondary",text:"No",value:N.CANCEL},{type:"primary",text:"Yes",value:N.HYDRATE_REPORT}],a=t=>{e.hide(),n(t)};e.show({viewportIndex:t,type:"info",message:i,actions:o,onSubmit:a,onOutsideClick:()=>{e.hide(),n(N.CANCEL)}})}))}(o,s);let l,d;if(a===N.HYDRATE_REPORT){console.warn("!! HYDRATING STRUCTURED REPORT");const e=(0,O.hydrateStructuredReport)({servicesManager:r,extensionManager:i},c);l=e.StudyInstanceUID,d=e.SeriesInstanceUIDs}e({userResponse:a,displaySetInstanceUID:n.displaySetInstanceUID,srSeriesInstanceUID:u.SeriesInstanceUID,viewportIndex:s,StudyInstanceUID:l,SeriesInstanceUIDs:d})}))};const C=function(e,t,n){let{servicesManager:r,extensionManager:i}=e;const{displaySetService:o}=r.services,{viewportIndex:a,displaySetInstanceUID:s}=n,c=o.getDisplaySetByUID(s);return new Promise(((e,t)=>{const o=(0,O.hydrateStructuredReport)({servicesManager:r,extensionManager:i},s),u=o.StudyInstanceUID,l=o.SeriesInstanceUIDs;e({displaySetInstanceUID:n.displaySetInstanceUID,srSeriesInstanceUID:c.SeriesInstanceUID,viewportIndex:a,StudyInstanceUID:u,SeriesInstanceUIDs:l})}))},j=r.createContext();j.displayName="TrackedMeasurementsContext";const P=()=>(0,r.useContext)(j),M="@ohif/extension-cornerstone-dicom-sr.sopClassHandlerModule.dicom-sr";function U(e,t){let{servicesManager:n,commandsManager:i,extensionManager:o}=e,{children:u}=t;const[l,d]=(0,c.useViewportGrid)(),{activeViewportIndex:f,viewports:p}=l,{measurementService:h,displaySetService:v}=n.services,g=Object.assign({},m);g.actions=Object.assign({},g.actions,{jumpToFirstMeasurementInActiveViewport:(e,t)=>{const{trackedStudy:n,trackedSeries:r}=e,i=h.getMeasurements().filter((e=>n===e.referenceStudyUID&&r.includes(e.referenceSeriesUID)));console.log("jumping to measurement reset viewport",l.activeViewportIndex,i[0]);const o=i[0].displaySetInstanceUID,a=v.getDisplaySetByUID(o).images,s=a[0].imageId.startsWith("volumeId"),c=i[0].data;let u=0;!s&&c&&(u=a.findIndex((e=>{const t=Object.keys(c)[0].substring(8);return e.imageId===t})),-1===u&&(console.warn("Could not find image index for tracked measurement, using 0"),u=0)),d.setDisplaySetsForViewport({viewportIndex:l.activeViewportIndex,displaySetInstanceUIDs:[o],viewportOptions:{initialImageOptions:{index:u}}})},showStructuredReportDisplaySetInActiveViewport:(e,t)=>{if(t.data.createdDisplaySetInstanceUIDs.length>0){const e=t.data.createdDisplaySetInstanceUIDs[0].displaySetInstanceUID;d.setDisplaySetsForViewport({viewportIndex:t.data.viewportIndex,displaySetInstanceUIDs:[e]})}},discardPreviouslyTrackedMeasurements:(e,t)=>{const n=h.getMeasurements().filter((t=>e.prevTrackedSeries.includes(t.referenceSeriesUID))).map((e=>e.id));for(let e=0;e<n.length;e++)h.remove(n[e])},clearAllMeasurements:(e,t)=>{const n=h.getMeasurements().map((e=>e.uid));for(let e=0;e<n.length;e++)h.remove(n[e])}}),g.services=Object.assign({},g.services,{promptBeginTracking:S.bind(null,{servicesManager:n,extensionManager:o}),promptTrackNewSeries:E.bind(null,{servicesManager:n,extensionManager:o}),promptTrackNewStudy:I.bind(null,{servicesManager:n,extensionManager:o}),promptSaveReport:R.bind(null,{servicesManager:n,commandsManager:i,extensionManager:o}),promptHydrateStructuredReport:A.bind(null,{servicesManager:n,extensionManager:o}),hydrateStructuredReport:C.bind(null,{servicesManager:n,extensionManager:o})});const b=(0,a.Machine)(y,g),[w,x,D]=(0,s.useMachine)(b);return(0,r.useEffect)((()=>{if(p.length>0){const e=p[f];if(!e||!e?.displaySetInstanceUIDs?.length)return;const{displaySetService:t}=n.services,r=t.getDisplaySetByUID(e.displaySetInstanceUIDs[0]);if(!r)return;r.SOPClassHandlerId===M&&!r.isLoaded&&r.load&&r.load(),r.SOPClassHandlerId===M&&!0===r.isRehydratable&&(console.log("sending event...",w),x("PROMPT_HYDRATE_SR",{displaySetInstanceUID:r.displaySetInstanceUID,SeriesInstanceUID:r.SeriesInstanceUID,viewportIndex:f}))}}),[f,x,n.services,p]),r.createElement(j.Provider,{value:[w,x]},u)}U.propTypes={children:o().oneOf([o().func,o().node]),servicesManager:o().object.isRequired,commandsManager:o().object.isRequired,extensionManager:o().object.isRequired};const V=function(e){let{servicesManager:t,extensionManager:n,commandsManager:r}=e;const i=U.bind(null,{servicesManager:t,extensionManager:n,commandsManager:r});return[{name:"TrackedMeasurementsContext",context:j,provider:i}]}},736:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>y});var r=n(735),i=n(216),o=n.n(i),a=n(762),s=n.n(a),c=n(369),u=n(9),l=n(867),d=n(18),f=n(464);function p(){return p=Object.assign?Object.assign.bind():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},p.apply(this,arguments)}const{formatDate:h}=a.utils;function v(e){const{displaySets:t,viewportIndex:n,viewportLabel:i,servicesManager:o,extensionManager:a,viewportOptions:v}=e,{t:y}=(0,u.$G)("TrackedViewport"),{measurementService:m,cornerstoneViewportService:g}=o.services,S=t[0],[b]=(0,d.I)(),[E,w]=(0,r.useState)(!1),[I,x]=(0,r.useState)(null),[D,_]=(0,r.useState)(null),{trackedSeries:k}=b.context,T=v.viewportId,{SeriesDate:R,SeriesDescription:O,SeriesInstanceUID:N,SeriesNumber:A}=S,{PatientID:C,PatientName:j,PatientSex:P,PatientAge:M,SliceThickness:U,SpacingBetweenSlices:V,ManufacturerModelName:L}=S.images[0],F=(0,r.useCallback)((()=>{const e=g.getCornerstoneViewportByIndex(n);if(e instanceof f.BaseVolumeViewport){const t=e?.getCurrentImageId();if(!t)return void(E&&w(!1))}k.includes(N)!==E&&w(!E)}),[E,b,n,N]),B=(0,r.useCallback)((e=>{e.detail.element!==D&&(e.detail.element?.addEventListener(f.Enums.Events.VOLUME_VIEWPORT_NEW_VOLUME,F),_(e.detail.element))}),[F,D]),q=(0,r.useCallback)((()=>{D?.removeEventListener(f.Enums.Events.VOLUME_VIEWPORT_NEW_VOLUME,F)}),[F,D]);(0,r.useEffect)(F,[F]),(0,r.useEffect)((()=>{const{unsubscribe:e}=g.subscribe(g.EVENTS.VIEWPORT_DATA_CHANGED,(e=>{e.viewportIndex===n&&F()}));return()=>{e()}}),[F,n]),(0,r.useEffect)((()=>E?(l.annotation.config.style.setViewportToolStyles(T,{global:{lineDash:""}}),void g.getRenderingEngine().renderViewport(T)):(l.annotation.config.style.setViewportToolStyles(T,{global:{lineDash:"4,4"}}),g.getRenderingEngine().renderViewport(T),()=>{l.annotation.config.style.setViewportToolStyles(T,{})})),[E]);return r.createElement(r.Fragment,null,r.createElement(c.ViewportActionBar,{onDoubleClick:e=>{e.stopPropagation(),e.preventDefault()},useAltStyling:E,onArrowsClick:e=>function(e){const t=function(e,t,n,r){const{measurementService:i,viewportGridService:o}=t.services,a=i.getMeasurements(),{activeViewportIndex:s,viewports:c}=o.getState(),{displaySetInstanceUIDs:u}=c[s],{trackedSeries:l}=r.context,d=a.filter((e=>l.includes(e.referenceSeriesUID)&&u.includes(e.displaySetInstanceUID)));if(!d.length)return;const f=d.length,p=d.map((e=>e.uid));let h=p.findIndex((e=>e===n));return-1===h?h=0:"left"===e?(h--,h<0&&(h=f-1)):"right"===e&&(h++,h===f&&(h=0)),p[h]}(e,o,I,b);t&&(x(t),m.jumpToMeasurement(n,t))}(e),getStatusComponent:()=>function(e){const t=e?"status-tracked":"status-untracked";return r.createElement("div",{className:"relative"},r.createElement(c.Tooltip,{position:"bottom-left",content:r.createElement("div",{className:"flex py-2"},r.createElement("div",{className:"flex pt-1"},r.createElement(c.Icon,{name:"info-link",className:"w-4 text-primary-main"})),r.createElement("div",{className:"flex ml-4"},r.createElement("span",{className:"text-base text-common-light"},e?r.createElement(r.Fragment,null,"Series is",r.createElement("span",{className:"font-bold text-white"}," tracked")," and can be viewed ",r.createElement("br",null)," in the measurement panel"):r.createElement(r.Fragment,null,"Measurements for",r.createElement("span",{className:"font-bold text-white"}," untracked "),"series ",r.createElement("br",null)," will not be shown in the ",r.createElement("br",null)," measurements panel"))))},r.createElement(c.Icon,{name:t,className:"text-primary-light"})))}(E),studyData:{label:i,studyDate:h(R),currentSeries:A,seriesDescription:O,patientInformation:{patientName:j?s().utils.formatPN(j):"",patientSex:P||"",patientAge:M||"",MRN:C||"",thickness:U?`${parseFloat(U).toFixed(2)}mm`:"",spacing:void 0!==V?`${parseFloat(V).toFixed(2)}mm`:"",scanner:L||""}}}),r.createElement("div",{className:"relative flex flex-row w-full h-full overflow-hidden"},(()=>{const{component:t}=a.getModuleEntry("@ohif/extension-cornerstone.viewportModule.cornerstone");return r.createElement(t,p({},e,{onElementEnabled:B,onElementDisabled:q}))})()))}v.propTypes={displaySets:o().arrayOf(o().object.isRequired).isRequired,viewportIndex:o().number.isRequired,dataSource:o().object,children:o().node,customProps:o().object},v.defaultProps={customProps:{}};const y=v},1:(e,t,n)=>{var r=NaN,i="[object Symbol]",o=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt,l="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,d="object"==typeof self&&self&&self.Object===Object&&self,f=l||d||Function("return this")(),p=Object.prototype.toString,h=Math.max,v=Math.min,y=function(){return f.Date.now()};function m(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function g(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&p.call(e)==i}(e))return r;if(m(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=m(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var n=s.test(e);return n||c.test(e)?u(e.slice(2),n?2:8):a.test(e)?r:+e}e.exports=function(e,t,n){var r,i,o,a,s,c,u=0,l=!1,d=!1,f=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function p(t){var n=r,o=i;return r=i=void 0,u=t,a=e.apply(o,n)}function S(e){var n=e-c;return void 0===c||n>=t||n<0||d&&e-u>=o}function b(){var e=y();if(S(e))return E(e);s=setTimeout(b,function(e){var n=t-(e-c);return d?v(n,o-(e-u)):n}(e))}function E(e){return s=void 0,f&&r?p(e):(r=i=void 0,a)}function w(){var e=y(),n=S(e);if(r=arguments,i=this,c=e,n){if(void 0===s)return function(e){return u=e,s=setTimeout(b,t),l?p(e):a}(c);if(d)return s=setTimeout(b,t),p(c)}return void 0===s&&(s=setTimeout(b,t)),a}return t=g(t)||0,m(n)&&(l=!!n.leading,o=(d="maxWait"in n)?h(g(n.maxWait)||0,t):o,f="trailing"in n?!!n.trailing:f),w.cancel=function(){void 0!==s&&clearTimeout(s),u=0,r=c=i=s=void 0},w.flush=function(){return void 0===s?a:E(y())},w}},516:e=>{"use strict";var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,i){for(var o,a,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),c=1;c<arguments.length;c++){for(var u in o=Object(arguments[c]))n.call(o,u)&&(s[u]=o[u]);if(t){a=t(o);for(var l=0;l<a.length;l++)r.call(o,a[l])&&(s[a[l]]=o[a[l]])}}return s}},459:(e,t,n)=>{"use strict";var r=n(704);function i(){}function o(){}o.resetWarningCache=i,e.exports=function(){function e(e,t,n,i,o,a){if(a!==r){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:i};return n.PropTypes=n,n}},216:(e,t,n)=>{e.exports=n(459)()},704:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},447:(e,t,n)=>{"use strict";var r=n(516),i=60103,o=60106;t.Fragment=60107,t.StrictMode=60108,t.Profiler=60114;var a=60109,s=60110,c=60112;t.Suspense=60113;var u=60115,l=60116;if("function"==typeof Symbol&&Symbol.for){var d=Symbol.for;i=d("react.element"),o=d("react.portal"),t.Fragment=d("react.fragment"),t.StrictMode=d("react.strict_mode"),t.Profiler=d("react.profiler"),a=d("react.provider"),s=d("react.context"),c=d("react.forward_ref"),t.Suspense=d("react.suspense"),u=d("react.memo"),l=d("react.lazy")}var f="function"==typeof Symbol&&Symbol.iterator;function p(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||h}function m(){}function g(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||h}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error(p(85));this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},m.prototype=y.prototype;var S=g.prototype=new m;S.constructor=g,r(S,y.prototype),S.isPureReactComponent=!0;var b={current:null},E=Object.prototype.hasOwnProperty,w={key:!0,ref:!0,__self:!0,__source:!0};function I(e,t,n){var r,o={},a=null,s=null;if(null!=t)for(r in void 0!==t.ref&&(s=t.ref),void 0!==t.key&&(a=""+t.key),t)E.call(t,r)&&!w.hasOwnProperty(r)&&(o[r]=t[r]);var c=arguments.length-2;if(1===c)o.children=n;else if(1<c){for(var u=Array(c),l=0;l<c;l++)u[l]=arguments[l+2];o.children=u}if(e&&e.defaultProps)for(r in c=e.defaultProps)void 0===o[r]&&(o[r]=c[r]);return{$$typeof:i,type:e,key:a,ref:s,props:o,_owner:b.current}}function x(e){return"object"==typeof e&&null!==e&&e.$$typeof===i}var D=/\/+/g;function _(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function k(e,t,n,r,a){var s=typeof e;"undefined"!==s&&"boolean"!==s||(e=null);var c=!1;if(null===e)c=!0;else switch(s){case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case i:case o:c=!0}}if(c)return a=a(c=e),e=""===r?"."+_(c,0):r,Array.isArray(a)?(n="",null!=e&&(n=e.replace(D,"$&/")+"/"),k(a,t,n,"",(function(e){return e}))):null!=a&&(x(a)&&(a=function(e,t){return{$$typeof:i,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(a,n+(!a.key||c&&c.key===a.key?"":(""+a.key).replace(D,"$&/")+"/")+e)),t.push(a)),1;if(c=0,r=""===r?".":r+":",Array.isArray(e))for(var u=0;u<e.length;u++){var l=r+_(s=e[u],u);c+=k(s,t,n,l,a)}else if(l=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=f&&e[f]||e["@@iterator"])?e:null}(e),"function"==typeof l)for(e=l.call(e),u=0;!(s=e.next()).done;)c+=k(s=s.value,t,n,l=r+_(s,u++),a);else if("object"===s)throw t=""+e,Error(p(31,"[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t));return c}function T(e,t,n){if(null==e)return e;var r=[],i=0;return k(e,r,"","",(function(e){return t.call(n,e,i++)})),r}function R(e){if(-1===e._status){var t=e._result;t=t(),e._status=0,e._result=t,t.then((function(t){0===e._status&&(t=t.default,e._status=1,e._result=t)}),(function(t){0===e._status&&(e._status=2,e._result=t)}))}if(1===e._status)return e._result;throw e._result}var O={current:null};function N(){var e=O.current;if(null===e)throw Error(p(321));return e}var A={ReactCurrentDispatcher:O,ReactCurrentBatchConfig:{transition:0},ReactCurrentOwner:b,IsSomeRendererActing:{current:!1},assign:r};t.Children={map:T,forEach:function(e,t,n){T(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return T(e,(function(){t++})),t},toArray:function(e){return T(e,(function(e){return e}))||[]},only:function(e){if(!x(e))throw Error(p(143));return e}},t.Component=y,t.PureComponent=g,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=A,t.cloneElement=function(e,t,n){if(null==e)throw Error(p(267,e));var o=r({},e.props),a=e.key,s=e.ref,c=e._owner;if(null!=t){if(void 0!==t.ref&&(s=t.ref,c=b.current),void 0!==t.key&&(a=""+t.key),e.type&&e.type.defaultProps)var u=e.type.defaultProps;for(l in t)E.call(t,l)&&!w.hasOwnProperty(l)&&(o[l]=void 0===t[l]&&void 0!==u?u[l]:t[l])}var l=arguments.length-2;if(1===l)o.children=n;else if(1<l){u=Array(l);for(var d=0;d<l;d++)u[d]=arguments[d+2];o.children=u}return{$$typeof:i,type:e.type,key:a,ref:s,props:o,_owner:c}},t.createContext=function(e,t){return void 0===t&&(t=null),(e={$$typeof:s,_calculateChangedBits:t,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},t.createElement=I,t.createFactory=function(e){var t=I.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:c,render:e}},t.isValidElement=x,t.lazy=function(e){return{$$typeof:l,_payload:{_status:-1,_result:e},_init:R}},t.memo=function(e,t){return{$$typeof:u,type:e,compare:void 0===t?null:t}},t.useCallback=function(e,t){return N().useCallback(e,t)},t.useContext=function(e,t){return N().useContext(e,t)},t.useDebugValue=function(){},t.useEffect=function(e,t){return N().useEffect(e,t)},t.useImperativeHandle=function(e,t,n){return N().useImperativeHandle(e,t,n)},t.useLayoutEffect=function(e,t){return N().useLayoutEffect(e,t)},t.useMemo=function(e,t){return N().useMemo(e,t)},t.useReducer=function(e,t,n){return N().useReducer(e,t,n)},t.useRef=function(e){return N().useRef(e)},t.useState=function(e){return N().useState(e)},t.version="17.0.2"},735:(e,t,n)=>{"use strict";e.exports=n(447)},432:e=>{e.exports={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}},519:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ActionTypes:()=>o,Interpreter:()=>xt,InterpreterStatus:()=>wt,Machine:()=>Mt,SpecialTargets:()=>a,State:()=>lt,StateNode:()=>jt,actions:()=>i,assign:()=>qt,createMachine:()=>Ut,createSchema:()=>Ft,doneInvoke:()=>Jt,forwardTo:()=>Wt,interpret:()=>kt,mapState:()=>Vt,matchState:()=>Lt,matchesState:()=>P,raise:()=>Gt,send:()=>Ht,sendParent:()=>Yt,sendTo:()=>$t,sendUpdate:()=>zt,spawn:()=>_t,spawnBehavior:()=>Et,t:()=>Bt,toActorRef:()=>Ke,toEventObject:()=>oe,toObserver:()=>le,toSCXMLEvent:()=>ae});var r={};n.r(r),n.d(r,{after:()=>b,assign:()=>S,cancel:()=>m,choose:()=>R,doneState:()=>E,error:()=>k,errorExecution:()=>D,errorPlatform:()=>_,init:()=>I,invoke:()=>x,log:()=>w,nullEvent:()=>g,pure:()=>O,raise:()=>v,send:()=>y,start:()=>p,stop:()=>h,update:()=>T});var i={};n.r(i),n.d(i,{actionTypes:()=>r,after:()=>Pe,assign:()=>Ce,cancel:()=>Re,choose:()=>qe,done:()=>Me,doneInvoke:()=>Ue,error:()=>Ve,escalate:()=>Be,forwardTo:()=>Fe,getActionFunction:()=>he,initEvent:()=>pe,isActionObject:()=>je,log:()=>ke,pure:()=>Le,raise:()=>ge,resolveActions:()=>$e,resolveLog:()=>Te,resolveRaise:()=>Se,resolveSend:()=>Ee,resolveStop:()=>Ae,respond:()=>De,send:()=>be,sendParent:()=>we,sendTo:()=>Ie,sendUpdate:()=>xe,start:()=>Oe,stop:()=>Ne,toActionObject:()=>ve,toActionObjects:()=>ye,toActivityDefinition:()=>me});var o,a,s=function(){return s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},s.apply(this,arguments)};function c(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function d(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}!function(e){e.Start="xstate.start",e.Stop="xstate.stop",e.Raise="xstate.raise",e.Send="xstate.send",e.Cancel="xstate.cancel",e.NullEvent="",e.Assign="xstate.assign",e.After="xstate.after",e.DoneState="done.state",e.DoneInvoke="done.invoke",e.Log="xstate.log",e.Init="xstate.init",e.Invoke="xstate.invoke",e.ErrorExecution="error.execution",e.ErrorCommunication="error.communication",e.ErrorPlatform="error.platform",e.ErrorCustom="xstate.error",e.Update="xstate.update",e.Pure="xstate.pure",e.Choose="xstate.choose"}(o||(o={})),function(e){e.Parent="#_parent",e.Internal="#_internal"}(a||(a={}));var f,p=o.Start,h=o.Stop,v=o.Raise,y=o.Send,m=o.Cancel,g=o.NullEvent,S=o.Assign,b=o.After,E=o.DoneState,w=o.Log,I=o.Init,x=o.Invoke,D=o.ErrorExecution,_=o.ErrorPlatform,k=o.ErrorCustom,T=o.Update,R=o.Choose,O=o.Pure,N=".",A={},C="xstate.guard",j=!0;function P(e,t,n){void 0===n&&(n=N);var r=V(e,n),i=V(t,n);return ee(i)?!!ee(r)&&i===r:ee(r)?r in i:Object.keys(r).every((function(e){return e in i&&P(r[e],i[e])}))}function M(e){try{return ee(e)||"number"==typeof e?"".concat(e):e.type}catch(e){throw new Error("Events must be strings or objects with a string event.type property.")}}function U(e,t){try{return Q(e)?e:e.toString().split(t)}catch(t){throw new Error("'".concat(e,"' is not a valid state path."))}}function V(e,t){return"object"==typeof(n=e)&&"value"in n&&"context"in n&&"event"in n&&"_event"in n?e.value:Q(e)?L(e):"string"!=typeof e?e:L(U(e,t));var n}function L(e){if(1===e.length)return e[0];for(var t={},n=t,r=0;r<e.length-1;r++)r===e.length-2?n[e[r]]=e[r+1]:(n[e[r]]={},n=n[e[r]]);return t}function F(e,t){for(var n={},r=Object.keys(e),i=0;i<r.length;i++){var o=r[i];n[o]=t(e[o],o,e,i)}return n}function B(e,t,n){var r,i,o={};try{for(var a=u(Object.keys(e)),s=a.next();!s.done;s=a.next()){var c=s.value,l=e[c];n(l)&&(o[c]=t(l,c,e))}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return o}var q=function(e){return function(t){var n,r,i=t;try{for(var o=u(e),a=o.next();!a.done;a=o.next()){i=i[a.value]}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}};function H(e){return e?ee(e)?[[e]]:$(Object.keys(e).map((function(t){var n=e[t];return"string"==typeof n||n&&Object.keys(n).length?H(e[t]).map((function(e){return[t].concat(e)})):[[t]]}))):[[]]}function $(e){var t;return(t=[]).concat.apply(t,d([],l(e),!1))}function Y(e){return Q(e)?e:[e]}function z(e){return void 0===e?[]:Y(e)}function W(e,t,n){var r,i;if(Z(e))return e(t,n.data);var o={};try{for(var a=u(Object.keys(e)),s=a.next();!s.done;s=a.next()){var c=s.value,l=e[c];Z(l)?o[c]=l(t,n.data):o[c]=l}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return o}function J(e){return e instanceof Promise||!(null===e||!Z(e)&&"object"!=typeof e||!Z(e.then))}function G(e,t){return F(e.states,(function(e,n){if(e){var r=(ee(t)?void 0:t[n])||(e?e.current:void 0);if(r)return{current:r,states:G(e,r)}}}))}function K(e,t,n,r){j||X(!!e,"Attempting to update undefined context");var i=e?n.reduce((function(e,n){var i,o,a=n.assignment,s={state:r,action:n,_event:t},c={};if(Z(a))c=a(e,t.data,s);else try{for(var l=u(Object.keys(a)),d=l.next();!d.done;d=l.next()){var f=d.value,p=a[f];c[f]=Z(p)?p(e,t.data,s):p}}catch(e){i={error:e}}finally{try{d&&!d.done&&(o=l.return)&&o.call(l)}finally{if(i)throw i.error}}return Object.assign({},e,c)}),e):e;return i}var X=function(){};function Q(e){return Array.isArray(e)}function Z(e){return"function"==typeof e}function ee(e){return"string"==typeof e}function te(e,t){if(e)return ee(e)?{type:C,name:e,predicate:t?t[e]:void 0}:Z(e)?{type:C,name:e.name,predicate:e}:e}j||(X=function(e,t){var n=e instanceof Error?e:void 0;if((n||!e)&&void 0!==console){var r=["Warning: ".concat(t)];n&&r.push(n),console.warn.apply(console,r)}});var ne=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();(f={})[ne]=function(){return this},f[Symbol.observable]=function(){return this};function re(e){return!!e&&"__xstatenode"in e}var ie=function(){var e=0;return function(){return(++e).toString(16)}}();function oe(e,t){return ee(e)||"number"==typeof e?s({type:e},t):e}function ae(e,t){if(!ee(e)&&"$$type"in e&&"scxml"===e.$$type)return e;var n=oe(e);return s({name:n.type,data:n,$$type:"scxml",type:"external"},t)}function se(e,t){return Y(t).map((function(t){return void 0===t||"string"==typeof t||re(t)?{target:t,event:e}:s(s({},t),{event:e})}))}function ce(e,t,n,r,i){var o=e.options.guards,a={state:i,cond:t,_event:r};if(t.type===C)return((null==o?void 0:o[t.name])||t.predicate)(n,r.data,a);var s=null==o?void 0:o[t.type];if(!s)throw new Error("Guard '".concat(t.type,"' is not implemented on machine '").concat(e.id,"'."));return s(n,r.data,a)}function ue(e){return"string"==typeof e?{type:e}:e}function le(e,t,n){var r=function(){},i="object"==typeof e,o=i?e:null;return{next:((i?e.next:e)||r).bind(o),error:((i?e.error:t)||r).bind(o),complete:((i?e.complete:n)||r).bind(o)}}function de(e,t){return"".concat(e,":invocation[").concat(t,"]")}function fe(e){return(e.type===v||e.type===y&&e.to===a.Internal)&&"number"!=typeof e.delay}var pe=ae({type:I});function he(e,t){return t&&t[e]||void 0}function ve(e,t){var n;if(ee(e)||"number"==typeof e)n=Z(r=he(e,t))?{type:e,exec:r}:r||{type:e,exec:void 0};else if(Z(e))n={type:e.name||e.toString(),exec:e};else{var r;if(Z(r=he(e.type,t)))n=s(s({},e),{exec:r});else if(r){var i=r.type||e.type;n=s(s(s({},r),e),{type:i})}else n=e}return n}var ye=function(e,t){return e?(Q(e)?e:[e]).map((function(e){return ve(e,t)})):[]};function me(e){var t=ve(e);return s(s({id:ee(e)?e:t.id},t),{type:t.type})}function ge(e,t){return{type:v,event:"function"==typeof e?e:oe(e),delay:t?t.delay:void 0,id:null==t?void 0:t.id}}function Se(e,t,n,r){var i,o={_event:n},a=ae(Z(e.event)?e.event(t,n.data,o):e.event);if(ee(e.delay)){var c=r&&r[e.delay];i=Z(c)?c(t,n.data,o):c}else i=Z(e.delay)?e.delay(t,n.data,o):e.delay;return s(s({},e),{type:v,_event:a,delay:i})}function be(e,t){return{to:t?t.to:void 0,type:y,event:Z(e)?e:oe(e),delay:t?t.delay:void 0,id:t&&void 0!==t.id?t.id:Z(e)?e.name:M(e)}}function Ee(e,t,n,r){var i,o={_event:n},a=ae(Z(e.event)?e.event(t,n.data,o):e.event);if(ee(e.delay)){var c=r&&r[e.delay];i=Z(c)?c(t,n.data,o):c}else i=Z(e.delay)?e.delay(t,n.data,o):e.delay;var u=Z(e.to)?e.to(t,n.data,o):e.to;return s(s({},e),{to:u,_event:a,event:a.data,delay:i})}function we(e,t){return be(e,s(s({},t),{to:a.Parent}))}function Ie(e,t,n){return be(t,s(s({},n),{to:e}))}function xe(){return we(T)}function De(e,t){return be(e,s(s({},t),{to:function(e,t,n){return n._event.origin}}))}var _e=function(e,t){return{context:e,event:t}};function ke(e,t){return void 0===e&&(e=_e),{type:w,label:t,expr:e}}var Te=function(e,t,n){return s(s({},e),{value:ee(e.expr)?e.expr:e.expr(t,n.data,{_event:n})})},Re=function(e){return{type:m,sendId:e}};function Oe(e){var t=me(e);return{type:o.Start,activity:t,exec:void 0}}function Ne(e){var t=Z(e)?e:me(e);return{type:o.Stop,activity:t,exec:void 0}}function Ae(e,t,n){var r=Z(e.activity)?e.activity(t,n.data):e.activity,i="string"==typeof r?{id:r}:r;return{type:o.Stop,activity:i}}var Ce=function(e){return{type:S,assignment:e}};function je(e){return"object"==typeof e&&"type"in e}function Pe(e,t){var n=t?"#".concat(t):"";return"".concat(o.After,"(").concat(e,")").concat(n)}function Me(e,t){var n="".concat(o.DoneState,".").concat(e),r={type:n,data:t,toString:function(){return n}};return r}function Ue(e,t){var n="".concat(o.DoneInvoke,".").concat(e),r={type:n,data:t,toString:function(){return n}};return r}function Ve(e,t){var n="".concat(o.ErrorPlatform,".").concat(e),r={type:n,data:t,toString:function(){return n}};return r}function Le(e){return{type:o.Pure,get:e}}function Fe(e,t){if(!(j||e&&"function"!=typeof e)){var n=e;e=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="function"==typeof n?n.apply(void 0,d([],l(e),!1)):n;if(!r)throw new Error("Attempted to forward event to undefined actor. This risks an infinite loop in the sender.");return r}}return be((function(e,t){return t}),s(s({},t),{to:e}))}function Be(e,t){return we((function(t,n,r){return{type:k,data:Z(e)?e(t,n,r):e}}),s(s({},t),{to:a.Parent}))}function qe(e){return{type:o.Choose,conds:e}}var He=function(e){var t,n,r=[];try{for(var i=u(e),o=i.next();!o.done;o=i.next())for(var a=o.value,s=0;s<a.actions.length;)a.actions[s].type!==S?s++:(r.push(a.actions[s]),a.actions.splice(s,1))}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r};function $e(e,t,n,r,i,o,c){void 0===c&&(c=!1);var f=c?[]:He(i),p=f.length?K(n,r,f,t):n,m=c?[n]:void 0,g=[];function b(i,u){var f;switch(u.type){case v:var b=Se(u,p,r,e.options.delays);return o&&"number"==typeof b.delay&&o(b,p,r),b;case y:var E=Ee(u,p,r,e.options.delays);if(!j){var I=u.delay;X(!ee(I)||"number"==typeof E.delay,"No delay reference for delay expression '".concat(I,"' was found on machine '").concat(e.id,"'"))}return o&&E.to!==a.Internal&&("entry"===i?g.push(E):o(E,p,r)),E;case w:var x=Te(u,p,r);return null==o||o(x,p,r),x;case R:if(!(T=null===(f=u.conds.find((function(n){var i=te(n.cond,e.options.guards);return!i||ce(e,i,p,r,o?void 0:t)})))||void 0===f?void 0:f.actions))return[];var D=l($e(e,t,p,r,[{type:i,actions:ye(z(T),e.options.actions)}],o,c),2),_=D[0],k=D[1];return p=k,null==m||m.push(p),_;case O:var T;if(!(T=u.get(p,r.data)))return[];var N=l($e(e,t,p,r,[{type:i,actions:ye(z(T),e.options.actions)}],o,c),2),A=N[0],C=N[1];return p=C,null==m||m.push(p),A;case h:x=Ae(u,p,r);return null==o||o(x,n,r),x;case S:p=K(p,r,[u],o?void 0:t),null==m||m.push(p);break;default:var P=ve(u,e.options.actions),M=P.exec;if(o)o(P,p,r);else if(M&&m){var U=m.length-1,V=s(s({},P),{exec:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];M.apply(void 0,d([m[U]],l(t),!1))}});P=V}return P}}var E=$(i.map((function(e){var t,n,i=[];try{for(var a=u(e.actions),s=a.next();!s.done;s=a.next()){var c=s.value,l=b(e.type,c);l&&(i=i.concat(l))}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return g.forEach((function(e){o(e,p,r)})),g.length=0,i})));return[E,p]}var Ye=[],ze=function(e,t){Ye.push(e);var n=t(e);return Ye.pop(),n},We=function(e){return e(Ye[Ye.length-1])};function Je(e){var t;return(t={id:e,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},getSnapshot:function(){},toJSON:function(){return{id:e}}})[ne]=function(){return this},t}function Ge(e,t,n){var r=Je(t);if(r.deferred=!0,re(e)){var i=r.state=ze(void 0,(function(){return(n?e.withContext(n):e).initialState}));r.getSnapshot=function(){return i}}return r}function Ke(e){var t;return s(((t={subscribe:function(){return{unsubscribe:function(){}}},id:"anonymous",getSnapshot:function(){}})[ne]=function(){return this},t),e)}var Xe=function(e){return"atomic"===e.type||"final"===e.type};function Qe(e){return Object.keys(e.states).map((function(t){return e.states[t]}))}function Ze(e){return Qe(e).filter((function(e){return"history"!==e.type}))}function et(e){var t=[e];return Xe(e)?t:t.concat($(Ze(e).map(et)))}function tt(e,t){var n,r,i,o,a,s,c,l,d=rt(new Set(e)),f=new Set(t);try{for(var p=u(f),h=p.next();!h.done;h=p.next())for(var v=(x=h.value).parent;v&&!f.has(v);)f.add(v),v=v.parent}catch(e){n={error:e}}finally{try{h&&!h.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}var y=rt(f);try{for(var m=u(f),g=m.next();!g.done;g=m.next()){if("compound"!==(x=g.value).type||y.get(x)&&y.get(x).length){if("parallel"===x.type)try{for(var S=(a=void 0,u(Ze(x))),b=S.next();!b.done;b=S.next()){var E=b.value;f.has(E)||(f.add(E),d.get(E)?d.get(E).forEach((function(e){return f.add(e)})):E.initialStateNodes.forEach((function(e){return f.add(e)})))}}catch(e){a={error:e}}finally{try{b&&!b.done&&(s=S.return)&&s.call(S)}finally{if(a)throw a.error}}}else d.get(x)?d.get(x).forEach((function(e){return f.add(e)})):x.initialStateNodes.forEach((function(e){return f.add(e)}))}}catch(e){i={error:e}}finally{try{g&&!g.done&&(o=m.return)&&o.call(m)}finally{if(i)throw i.error}}try{for(var w=u(f),I=w.next();!I.done;I=w.next()){var x;for(v=(x=I.value).parent;v&&!f.has(v);)f.add(v),v=v.parent}}catch(e){c={error:e}}finally{try{I&&!I.done&&(l=w.return)&&l.call(w)}finally{if(c)throw c.error}}return f}function nt(e,t){var n=t.get(e);if(!n)return{};if("compound"===e.type){var r=n[0];if(!r)return{};if(Xe(r))return r.key}var i={};return n.forEach((function(e){i[e.key]=nt(e,t)})),i}function rt(e){var t,n,r=new Map;try{for(var i=u(e),o=i.next();!o.done;o=i.next()){var a=o.value;r.has(a)||r.set(a,[]),a.parent&&(r.has(a.parent)||r.set(a.parent,[]),r.get(a.parent).push(a))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r}function it(e,t){return nt(e,rt(tt([e],t)))}function ot(e,t){return Array.isArray(e)?e.some((function(e){return e===t})):e instanceof Set&&e.has(t)}function at(e,t){return"compound"===t.type?Ze(t).some((function(t){return"final"===t.type&&ot(e,t)})):"parallel"===t.type&&Ze(t).every((function(t){return at(e,t)}))}function st(e){return new Set($(e.map((function(e){return e.tags}))))}function ct(e,t){if(e===t)return!0;if(void 0===e||void 0===t)return!1;if(ee(e)||ee(t))return e===t;var n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every((function(n){return ct(e[n],t[n])}))}function ut(e){return"object"==typeof e&&null!==e&&("value"in e&&"_event"in e)}var lt=function(){function e(e){var t,n,r=this;this.actions=[],this.activities=A,this.meta={},this.events=[],this.value=e.value,this.context=e.context,this._event=e._event,this._sessionid=e._sessionid,this.event=this._event.data,this.historyValue=e.historyValue,this.history=e.history,this.actions=e.actions||[],this.activities=e.activities||A,this.meta=(void 0===(n=e.configuration)&&(n=[]),n.reduce((function(e,t){return void 0!==t.meta&&(e[t.id]=t.meta),e}),{})),this.events=e.events||[],this.matches=this.matches.bind(this),this.toStrings=this.toStrings.bind(this),this.configuration=e.configuration,this.transitions=e.transitions,this.children=e.children,this.done=!!e.done,this.tags=null!==(t=Array.isArray(e.tags)?new Set(e.tags):e.tags)&&void 0!==t?t:new Set,this.machine=e.machine,Object.defineProperty(this,"nextEvents",{get:function(){return function(e){return d([],l(new Set($(d([],l(e.map((function(e){return e.ownEvents}))),!1)))),!1)}(r.configuration)}})}return e.from=function(t,n){return t instanceof e?t.context!==n?new e({value:t.value,context:n,_event:t._event,_sessionid:null,historyValue:t.historyValue,history:t.history,actions:[],activities:t.activities,meta:{},events:[],configuration:[],transitions:[],children:{}}):t:new e({value:t,context:n,_event:pe,_sessionid:null,historyValue:void 0,history:void 0,actions:[],activities:void 0,meta:void 0,events:[],configuration:[],transitions:[],children:{}})},e.create=function(t){return new e(t)},e.inert=function(t,n){if(t instanceof e){if(!t.actions.length)return t;var r=pe;return new e({value:t.value,context:n,_event:r,_sessionid:null,historyValue:t.historyValue,history:t.history,activities:t.activities,configuration:t.configuration,transitions:[],children:{}})}return e.from(t,n)},e.prototype.toStrings=function(e,t){var n=this;if(void 0===e&&(e=this.value),void 0===t&&(t="."),ee(e))return[e];var r=Object.keys(e);return r.concat.apply(r,d([],l(r.map((function(r){return n.toStrings(e[r],t).map((function(e){return r+t+e}))}))),!1))},e.prototype.toJSON=function(){var e=this;e.configuration,e.transitions;var t=e.tags;e.machine;var n=c(e,["configuration","transitions","tags","machine"]);return s(s({},n),{tags:Array.from(t)})},e.prototype.matches=function(e){return P(e,this.value)},e.prototype.hasTag=function(e){return this.tags.has(e)},e.prototype.can=function(e){var t;j&&X(!!this.machine,"state.can(...) used outside of a machine-created State object; this will always return false.");var n=null===(t=this.machine)||void 0===t?void 0:t.getTransitionData(this,e);return!!(null==n?void 0:n.transitions.length)&&n.transitions.some((function(e){return void 0!==e.target||e.actions.length}))},e}(),dt={deferEvents:!1},ft=function(){function e(e){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=s(s({},dt),e)}return e.prototype.initialize=function(e){if(this.initialized=!0,e){if(!this.options.deferEvents)return void this.schedule(e);this.process(e)}this.flushEvents()},e.prototype.schedule=function(e){if(this.initialized&&!this.processingEvent){if(0!==this.queue.length)throw new Error("Event queue should be empty when it is not processing events");this.process(e),this.flushEvents()}else this.queue.push(e)},e.prototype.clear=function(){this.queue=[]},e.prototype.flushEvents=function(){for(var e=this.queue.shift();e;)this.process(e),e=this.queue.shift()},e.prototype.process=function(e){this.processingEvent=!0;try{e()}catch(e){throw this.clear(),e}finally{this.processingEvent=!1}},e}(),pt=new Map,ht=0,vt=function(){return"x:".concat(ht++)},yt=function(e,t){return pt.set(e,t),e},mt=function(e){return pt.get(e)},gt=function(e){pt.delete(e)};function St(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==n.g?n.g:void(j||console.warn("XState could not find a global object in this environment. Please let the maintainers know and raise an issue here: https://github.com/statelyai/xstate/issues"))}function bt(e){if(St()){var t=function(){var e=St();if(e&&"__xstate__"in e)return e.__xstate__}();t&&t.register(e)}}function Et(e,t){void 0===t&&(t={});var n=e.initialState,r=new Set,i=[],o=!1,a=Ke({id:t.id,send:function(t){i.push(t),function(){if(!o){for(o=!0;i.length>0;){var t=i.shift();n=e.transition(n,t,s),r.forEach((function(e){return e.next(n)}))}o=!1}}()},getSnapshot:function(){return n},subscribe:function(e,t,i){var o=le(e,t,i);return r.add(o),o.next(n),{unsubscribe:function(){r.delete(o)}}}}),s={parent:t.parent,self:a,id:t.id||"anonymous",observers:r};return n=e.start?e.start(s):n,a}var wt,It={sync:!1,autoForward:!1};!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(wt||(wt={}));var xt=function(){function e(t,n){void 0===n&&(n=e.defaultOptions);var r=this;this.machine=t,this.delayedEventsMap={},this.listeners=new Set,this.contextListeners=new Set,this.stopListeners=new Set,this.doneListeners=new Set,this.eventListeners=new Set,this.sendListeners=new Set,this.initialized=!1,this.status=wt.NotStarted,this.children=new Map,this.forwardTo=new Set,this._outgoingQueue=[],this.init=this.start,this.send=function(e,t){if(Q(e))return r.batch(e),r.state;var n=ae(oe(e,t));if(r.status===wt.Stopped)return j||X(!1,'Event "'.concat(n.name,'" was sent to stopped service "').concat(r.machine.id,'". This service has already reached its final state, and will not transition.\nEvent: ').concat(JSON.stringify(n.data))),r.state;if(r.status!==wt.Running&&!r.options.deferEvents)throw new Error('Event "'.concat(n.name,'" was sent to uninitialized service "').concat(r.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.\nEvent: ').concat(JSON.stringify(n.data)));return r.scheduler.schedule((function(){r.forward(n);var e=r._nextState(n);r.update(e,n)})),r._state},this.sendTo=function(e,t,n){var i,o=r.parent&&(t===a.Parent||r.parent.id===t),c=o?r.parent:ee(t)?t===a.Internal?r:r.children.get(t)||mt(t):(i=t)&&"function"==typeof i.send?t:void 0;if(c)if("machine"in c){if(r.status!==wt.Stopped||r.parent!==c||r.state.done){var u=s(s({},e),{name:e.name===k?"".concat(Ve(r.id)):e.name,origin:r.sessionId});!n&&r.machine.config.predictableActionArguments?r._outgoingQueue.push([c,u]):c.send(u)}}else!n&&r.machine.config.predictableActionArguments?r._outgoingQueue.push([c,e.data]):c.send(e.data);else{if(!o)throw new Error("Unable to send event to child '".concat(t,"' from service '").concat(r.id,"'."));j||X(!1,"Service '".concat(r.id,"' has no parent: unable to send event ").concat(e.type))}},this._exec=function(e,t,n,i){void 0===i&&(i=r.machine.options.actions);var a=e.exec||he(e.type,i),s=Z(a)?a:a?a.exec:e.exec;if(s)try{return s(t,n.data,r.machine.config.predictableActionArguments?{action:e,_event:n}:{action:e,state:r.state,_event:n})}catch(e){throw r.parent&&r.parent.send({type:"xstate.error",data:e}),e}switch(e.type){case v:var c=e;r.defer(c);break;case y:var u=e;if("number"==typeof u.delay)return void r.defer(u);u.to?r.sendTo(u._event,u.to,n===pe):r.send(u._event);break;case m:r.cancel(e.sendId);break;case p:if(r.status!==wt.Running)return;var l=e.activity;if(!r.machine.config.predictableActionArguments&&!r.state.activities[l.id||l.type])break;if(l.type===o.Invoke){var d=ue(l.src),f=r.machine.options.services?r.machine.options.services[d.type]:void 0,g=l.id,S=l.data;j||X(!("forward"in l),"`forward` property is deprecated (found in invocation of '".concat(l.src,"' in in machine '").concat(r.machine.id,"'). ")+"Please use `autoForward` instead.");var b="autoForward"in l?l.autoForward:!!l.forward;if(!f)return void(j||X(!1,"No service found for invocation '".concat(l.src,"' in machine '").concat(r.machine.id,"'.")));var E=S?W(S,t,n):void 0;if("string"==typeof f)return;var I=Z(f)?f(t,n.data,{data:E,src:d,meta:l.meta}):f;if(!I)return;var x=void 0;re(I)&&(I=E?I.withContext(E):I,x={autoForward:b}),r.spawn(I,g,x)}else r.spawnActivity(l);break;case h:r.stopChild(e.activity.id);break;case w:var D=e,_=D.label,k=D.value;_?r.logger(_,k):r.logger(k);break;default:j||X(!1,"No implementation found for action type '".concat(e.type,"'"))}};var i=s(s({},e.defaultOptions),n),c=i.clock,u=i.logger,l=i.parent,d=i.id,f=void 0!==d?d:t.id;this.id=f,this.logger=u,this.clock=c,this.parent=l,this.options=i,this.scheduler=new ft({deferEvents:this.options.deferEvents}),this.sessionId=vt()}return Object.defineProperty(e.prototype,"initialState",{get:function(){var e=this;return this._initialState?this._initialState:ze(this,(function(){return e._initialState=e.machine.initialState,e._initialState}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return j||X(this.status!==wt.NotStarted,"Attempted to read state from uninitialized service '".concat(this.id,"'. Make sure the service is started first.")),this._state},enumerable:!1,configurable:!0}),e.prototype.execute=function(e,t){var n,r;try{for(var i=u(e.actions),o=i.next();!o.done;o=i.next()){var a=o.value;this.exec(a,e,t)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype.update=function(e,t){var n,r,i,o,a,s,c,l,d=this;if(e._sessionid=this.sessionId,this._state=e,this.machine.config.predictableActionArguments&&t!==pe||!this.options.execute)for(var f=void 0;f=this._outgoingQueue.shift();)f[0].send(f[1]);else this.execute(this.state);if(this.children.forEach((function(e){d.state.children[e.id]=e})),this.devTools&&this.devTools.send(t.data,e),e.event)try{for(var p=u(this.eventListeners),h=p.next();!h.done;h=p.next()){(0,h.value)(e.event)}}catch(e){n={error:e}}finally{try{h&&!h.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}try{for(var v=u(this.listeners),y=v.next();!y.done;y=v.next()){(0,y.value)(e,e.event)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(o=v.return)&&o.call(v)}finally{if(i)throw i.error}}try{for(var m=u(this.contextListeners),g=m.next();!g.done;g=m.next()){(0,g.value)(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(e){a={error:e}}finally{try{g&&!g.done&&(s=m.return)&&s.call(m)}finally{if(a)throw a.error}}if(this.state.done){var S=e.configuration.find((function(e){return"final"===e.type&&e.parent===d.machine})),b=S&&S.doneData?W(S.doneData,e.context,t):void 0;this._doneEvent=Ue(this.id,b);try{for(var E=u(this.doneListeners),w=E.next();!w.done;w=E.next()){(0,w.value)(this._doneEvent)}}catch(e){c={error:e}}finally{try{w&&!w.done&&(l=E.return)&&l.call(E)}finally{if(c)throw c.error}}this._stop(),this._stopChildren(),gt(this.sessionId)}},e.prototype.onTransition=function(e){return this.listeners.add(e),this.status===wt.Running&&e(this.state,this.state.event),this},e.prototype.subscribe=function(e,t,n){var r=this,i=le(e,t,n);this.listeners.add(i.next),this.status!==wt.NotStarted&&i.next(this.state);var o=function(){r.doneListeners.delete(o),r.stopListeners.delete(o),i.complete()};return this.status===wt.Stopped?i.complete():(this.onDone(o),this.onStop(o)),{unsubscribe:function(){r.listeners.delete(i.next),r.doneListeners.delete(o),r.stopListeners.delete(o)}}},e.prototype.onEvent=function(e){return this.eventListeners.add(e),this},e.prototype.onSend=function(e){return this.sendListeners.add(e),this},e.prototype.onChange=function(e){return this.contextListeners.add(e),this},e.prototype.onStop=function(e){return this.stopListeners.add(e),this},e.prototype.onDone=function(e){return this.status===wt.Stopped&&this._doneEvent?e(this._doneEvent):this.doneListeners.add(e),this},e.prototype.off=function(e){return this.listeners.delete(e),this.eventListeners.delete(e),this.sendListeners.delete(e),this.stopListeners.delete(e),this.doneListeners.delete(e),this.contextListeners.delete(e),this},e.prototype.start=function(e){var t=this;if(this.status===wt.Running)return this;this.machine._init(),yt(this.sessionId,this),this.initialized=!0,this.status=wt.Running;var n=void 0===e?this.initialState:ze(this,(function(){return ut(e)?t.machine.resolveState(e):t.machine.resolveState(lt.from(e,t.machine.context))}));return this.options.devTools&&this.attachDev(),this.scheduler.initialize((function(){t.update(n,pe)})),this},e.prototype._stopChildren=function(){this.children.forEach((function(e){Z(e.stop)&&e.stop()})),this.children.clear()},e.prototype._stop=function(){var e,t,n,r,i,o,a,s,c,l;try{for(var d=u(this.listeners),f=d.next();!f.done;f=d.next()){var p=f.value;this.listeners.delete(p)}}catch(t){e={error:t}}finally{try{f&&!f.done&&(t=d.return)&&t.call(d)}finally{if(e)throw e.error}}try{for(var h=u(this.stopListeners),v=h.next();!v.done;v=h.next()){(p=v.value)(),this.stopListeners.delete(p)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}try{for(var y=u(this.contextListeners),m=y.next();!m.done;m=y.next()){p=m.value;this.contextListeners.delete(p)}}catch(e){i={error:e}}finally{try{m&&!m.done&&(o=y.return)&&o.call(y)}finally{if(i)throw i.error}}try{for(var g=u(this.doneListeners),S=g.next();!S.done;S=g.next()){p=S.value;this.doneListeners.delete(p)}}catch(e){a={error:e}}finally{try{S&&!S.done&&(s=g.return)&&s.call(g)}finally{if(a)throw a.error}}if(!this.initialized)return this;this.initialized=!1,this.status=wt.Stopped,this._initialState=void 0;try{for(var b=u(Object.keys(this.delayedEventsMap)),E=b.next();!E.done;E=b.next()){var w=E.value;this.clock.clearTimeout(this.delayedEventsMap[w])}}catch(e){c={error:e}}finally{try{E&&!E.done&&(l=b.return)&&l.call(b)}finally{if(c)throw c.error}}this.scheduler.clear(),this.scheduler=new ft({deferEvents:this.options.deferEvents})},e.prototype.stop=function(){var e=this,t=this.scheduler;return this._stop(),t.schedule((function(){var t=ae({type:"xstate.stop"}),n=ze(e,(function(){var n=$(d([],l(e.state.configuration),!1).sort((function(e,t){return t.order-e.order})).map((function(t){return ye(t.onExit,e.machine.options.actions)}))),r=l($e(e.machine,e.state,e.state.context,t,[{type:"exit",actions:n}],e.machine.config.predictableActionArguments?e._exec:void 0,e.machine.config.predictableActionArguments||e.machine.config.preserveActionOrder),2),i=r[0],o=r[1],a=new lt({value:e.state.value,context:o,_event:t,_sessionid:e.sessionId,historyValue:void 0,history:e.state,actions:i.filter((function(e){return!fe(e)})),activities:{},events:[],configuration:[],transitions:[],children:{},done:e.state.done,tags:e.state.tags,machine:e.machine});return a.changed=!0,a}));e.update(n,t),e._stopChildren(),gt(e.sessionId)})),this},e.prototype.batch=function(e){var t=this;if(this.status===wt.NotStarted&&this.options.deferEvents)j||X(!1,"".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,'" and are deferred. Make sure .start() is called for this service.\nEvent: ').concat(JSON.stringify(event)));else if(this.status!==wt.Running)throw new Error("".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.'));if(e.length){var n=!!this.machine.config.predictableActionArguments&&this._exec;this.scheduler.schedule((function(){var r,i,o=t.state,a=!1,c=[],f=function(e){var r=ae(e);t.forward(r),o=ze(t,(function(){return t.machine.transition(o,r,void 0,n||void 0)})),c.push.apply(c,d([],l(t.machine.config.predictableActionArguments?o.actions:o.actions.map((function(e){return function(e,t){var n=e.exec;return s(s({},e),{exec:void 0!==n?function(){return n(t.context,t.event,{action:e,state:t,_event:t._event})}:void 0})}(e,o)}))),!1)),a=a||!!o.changed};try{for(var p=u(e),h=p.next();!h.done;h=p.next()){f(h.value)}}catch(e){r={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}o.changed=a,o.actions=c,t.update(o,ae(e[e.length-1]))}))}},e.prototype.sender=function(e){return this.send.bind(this,e)},e.prototype._nextState=function(e,t){var n=this;void 0===t&&(t=!!this.machine.config.predictableActionArguments&&this._exec);var r=ae(e);if(0===r.name.indexOf(_)&&!this.state.nextEvents.some((function(e){return 0===e.indexOf(_)})))throw r.data.data;return ze(this,(function(){return n.machine.transition(n.state,r,void 0,t||void 0)}))},e.prototype.nextState=function(e){return this._nextState(e,!1)},e.prototype.forward=function(e){var t,n;try{for(var r=u(this.forwardTo),i=r.next();!i.done;i=r.next()){var o=i.value,a=this.children.get(o);if(!a)throw new Error("Unable to forward event '".concat(e,"' from interpreter '").concat(this.id,"' to nonexistant child '").concat(o,"'."));a.send(e)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},e.prototype.defer=function(e){var t=this,n=this.clock.setTimeout((function(){"to"in e&&e.to?t.sendTo(e._event,e.to,!0):t.send(e._event)}),e.delay);e.id&&(this.delayedEventsMap[e.id]=n)},e.prototype.cancel=function(e){this.clock.clearTimeout(this.delayedEventsMap[e]),delete this.delayedEventsMap[e]},e.prototype.exec=function(e,t,n){void 0===n&&(n=this.machine.options.actions),this._exec(e,t.context,t._event,n)},e.prototype.removeChild=function(e){var t;this.children.delete(e),this.forwardTo.delete(e),null===(t=this.state)||void 0===t||delete t.children[e]},e.prototype.stopChild=function(e){var t=this.children.get(e);t&&(this.removeChild(e),Z(t.stop)&&t.stop())},e.prototype.spawn=function(e,t,n){if(this.status!==wt.Running)return Ge(e,t);if(J(e))return this.spawnPromise(Promise.resolve(e),t);if(Z(e))return this.spawnCallback(e,t);if(function(e){try{return"function"==typeof e.send}catch(e){return!1}}(i=e)&&"id"in i)return this.spawnActor(e,t);if(function(e){try{return"subscribe"in e&&Z(e.subscribe)}catch(e){return!1}}(e))return this.spawnObservable(e,t);if(re(e))return this.spawnMachine(e,s(s({},n),{id:t}));if(null!==(r=e)&&"object"==typeof r&&"transition"in r&&"function"==typeof r.transition)return this.spawnBehavior(e,t);throw new Error('Unable to spawn entity "'.concat(t,'" of type "').concat(typeof e,'".'));var r,i},e.prototype.spawnMachine=function(t,n){var r=this;void 0===n&&(n={});var i=new e(t,s(s({},this.options),{parent:this,id:n.id||t.id})),o=s(s({},It),n);o.sync&&i.onTransition((function(e){r.send(T,{state:e,id:i.id})}));var a=i;return this.children.set(i.id,a),o.autoForward&&this.forwardTo.add(i.id),i.onDone((function(e){r.removeChild(i.id),r.send(ae(e,{origin:i.id}))})).start(),a},e.prototype.spawnBehavior=function(e,t){var n=Et(e,{id:t,parent:this});return this.children.set(t,n),n},e.prototype.spawnPromise=function(e,t){var n,r,i=this,o=!1;e.then((function(e){o||(r=e,i.removeChild(t),i.send(ae(Ue(t,e),{origin:t})))}),(function(e){if(!o){i.removeChild(t);var n=Ve(t,e);try{i.send(ae(n,{origin:t}))}catch(r){!function(e,t,n){if(!j){var r=e.stack?" Stacktrace was '".concat(e.stack,"'"):"";if(e===t)console.error("Missing onError handler for invocation '".concat(n,"', error was '").concat(e,"'.").concat(r));else{var i=t.stack?" Stacktrace was '".concat(t.stack,"'"):"";console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '".concat(n,"'. ")+"Original error: '".concat(e,"'. ").concat(r," Current error is '").concat(t,"'.").concat(i))}}}(e,r,t),i.devTools&&i.devTools.send(n,i.state),i.machine.strict&&i.stop()}}}));var a=((n={id:t,send:function(){},subscribe:function(t,n,r){var i=le(t,n,r),o=!1;return e.then((function(e){o||(i.next(e),o||i.complete())}),(function(e){o||i.error(e)})),{unsubscribe:function(){return o=!0}}},stop:function(){o=!0},toJSON:function(){return{id:t}},getSnapshot:function(){return r}})[ne]=function(){return this},n);return this.children.set(t,a),a},e.prototype.spawnCallback=function(e,t){var n,r,i,o=this,a=!1,s=new Set,c=new Set;try{i=e((function(e){r=e,c.forEach((function(t){return t(e)})),a||o.send(ae(e,{origin:t}))}),(function(e){s.add(e)}))}catch(e){this.send(Ve(t,e))}if(J(i))return this.spawnPromise(i,t);var u=((n={id:t,send:function(e){return s.forEach((function(t){return t(e)}))},subscribe:function(e){var t=le(e);return c.add(t.next),{unsubscribe:function(){c.delete(t.next)}}},stop:function(){a=!0,Z(i)&&i()},toJSON:function(){return{id:t}},getSnapshot:function(){return r}})[ne]=function(){return this},n);return this.children.set(t,u),u},e.prototype.spawnObservable=function(e,t){var n,r,i=this,o=e.subscribe((function(e){r=e,i.send(ae(e,{origin:t}))}),(function(e){i.removeChild(t),i.send(ae(Ve(t,e),{origin:t}))}),(function(){i.removeChild(t),i.send(ae(Ue(t),{origin:t}))})),a=((n={id:t,send:function(){},subscribe:function(t,n,r){return e.subscribe(t,n,r)},stop:function(){return o.unsubscribe()},getSnapshot:function(){return r},toJSON:function(){return{id:t}}})[ne]=function(){return this},n);return this.children.set(t,a),a},e.prototype.spawnActor=function(e,t){return this.children.set(t,e),e},e.prototype.spawnActivity=function(e){var t=this.machine.options&&this.machine.options.activities?this.machine.options.activities[e.type]:void 0;if(t){var n=t(this.state.context,e);this.spawnEffect(e.id,n)}else j||X(!1,"No implementation found for activity '".concat(e.type,"'"))},e.prototype.spawnEffect=function(e,t){var n;this.children.set(e,((n={id:e,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},stop:t||void 0,getSnapshot:function(){},toJSON:function(){return{id:e}}})[ne]=function(){return this},n))},e.prototype.attachDev=function(){var e=St();if(this.options.devTools&&e){if(e.__REDUX_DEVTOOLS_EXTENSION__){var t="object"==typeof this.options.devTools?this.options.devTools:void 0;this.devTools=e.__REDUX_DEVTOOLS_EXTENSION__.connect(s(s({name:this.id,autoPause:!0,stateSanitizer:function(e){return{value:e.value,context:e.context,actions:e.actions}}},t),{features:s({jump:!1,skip:!1},t?t.features:void 0)}),this.machine),this.devTools.init(this.state)}bt(this)}},e.prototype.toJSON=function(){return{id:this.id}},e.prototype[ne]=function(){return this},e.prototype.getSnapshot=function(){return this.status===wt.NotStarted?this.initialState:this._state},e.defaultOptions={execute:!0,deferEvents:!0,clock:{setTimeout:function(e,t){return setTimeout(e,t)},clearTimeout:function(e){return clearTimeout(e)}},logger:console.log.bind(console),devTools:!1},e.interpret=kt,e}(),Dt=function(e){return ee(e)?s(s({},It),{name:e}):s(s(s({},It),{name:ie()}),e)};function _t(e,t){var n=Dt(t);return We((function(t){if(!j){var r=re(e)||Z(e);X(!!t||r,'Attempted to spawn an Actor (ID: "'.concat(re(e)?e.id:"undefined",'") outside of a service. This will have no effect.'))}return t?t.spawn(e,n.name,n):Ge(e,n.name)}))}function kt(e,t){return new xt(e,t)}function Tt(e){if("string"==typeof e){var t={type:e,toString:function(){return e}};return t}return e}function Rt(e){return s(s({type:x},e),{toJSON:function(){e.onDone,e.onError;var t=c(e,["onDone","onError"]);return s(s({},t),{type:x,src:Tt(e.src)})}})}var Ot="",Nt="*",At={},Ct=function(e){return"#"===e[0]},jt=function(){function e(t,n,r,i){void 0===r&&(r="context"in t?t.context:void 0);var o,a=this;this.config=t,this._context=r,this.order=-1,this.__xstatenode=!0,this.__cache={events:void 0,relativeValue:new Map,initialStateValue:void 0,initialState:void 0,on:void 0,transitions:void 0,candidates:{},delayedTransitions:void 0},this.idMap={},this.tags=[],this.options=Object.assign({actions:{},guards:{},services:{},activities:{},delays:{}},n),this.parent=null==i?void 0:i.parent,this.key=this.config.key||(null==i?void 0:i.key)||this.config.id||"(machine)",this.machine=this.parent?this.parent.machine:this,this.path=this.parent?this.parent.path.concat(this.key):[],this.delimiter=this.config.delimiter||(this.parent?this.parent.delimiter:N),this.id=this.config.id||d([this.machine.key],l(this.path),!1).join(this.delimiter),this.version=this.parent?this.parent.version:this.config.version,this.type=this.config.type||(this.config.parallel?"parallel":this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.schema=this.parent?this.machine.schema:null!==(o=this.config.schema)&&void 0!==o?o:{},this.description=this.config.description,j||X(!("parallel"in this.config),'The "parallel" property is deprecated and will be removed in version 4.1. '.concat(this.config.parallel?"Replace with `type: 'parallel'`":"Use `type: '".concat(this.type,"'`")," in the config for state node '").concat(this.id,"' instead.")),this.initial=this.config.initial,this.states=this.config.states?F(this.config.states,(function(t,n){var r,i=new e(t,{},void 0,{parent:a,key:n});return Object.assign(a.idMap,s(((r={})[i.id]=i,r),i.idMap)),i})):At;var c=0;!function e(t){var n,r;t.order=c++;try{for(var i=u(Qe(t)),o=i.next();!o.done;o=i.next()){e(o.value)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}(this),this.history=!0===this.config.history?"shallow":this.config.history||!1,this._transient=!!this.config.always||!!this.config.on&&(Array.isArray(this.config.on)?this.config.on.some((function(e){return e.event===Ot})):Ot in this.config.on),this.strict=!!this.config.strict,this.onEntry=z(this.config.entry||this.config.onEntry).map((function(e){return ve(e)})),this.onExit=z(this.config.exit||this.config.onExit).map((function(e){return ve(e)})),this.meta=this.config.meta,this.doneData="final"===this.type?this.config.data:void 0,this.invoke=z(this.config.invoke).map((function(e,t){var n,r;if(re(e)){var i=de(a.id,t);return a.machine.options.services=s(((n={})[i]=e,n),a.machine.options.services),Rt({src:i,id:i})}if(ee(e.src)){i=e.id||de(a.id,t);return Rt(s(s({},e),{id:i,src:e.src}))}if(re(e.src)||Z(e.src)){i=e.id||de(a.id,t);return a.machine.options.services=s(((r={})[i]=e.src,r),a.machine.options.services),Rt(s(s({id:i},e),{src:i}))}var o=e.src;return Rt(s(s({id:de(a.id,t)},e),{src:o}))})),this.activities=z(this.config.activities).concat(this.invoke).map((function(e){return me(e)})),this.transition=this.transition.bind(this),this.tags=z(this.config.tags)}return e.prototype._init=function(){this.__cache.transitions||et(this).forEach((function(e){return e.on}))},e.prototype.withConfig=function(t,n){var r=this.options,i=r.actions,o=r.activities,a=r.guards,c=r.services,u=r.delays;return new e(this.config,{actions:s(s({},i),t.actions),activities:s(s({},o),t.activities),guards:s(s({},a),t.guards),services:s(s({},c),t.services),delays:s(s({},u),t.delays)},null!=n?n:this.context)},e.prototype.withContext=function(t){return new e(this.config,this.options,t)},Object.defineProperty(e.prototype,"context",{get:function(){return Z(this._context)?this._context():this._context},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"definition",{get:function(){return{id:this.id,key:this.key,version:this.version,context:this.context,type:this.type,initial:this.initial,history:this.history,states:F(this.states,(function(e){return e.definition})),on:this.on,transitions:this.transitions,entry:this.onEntry,exit:this.onExit,activities:this.activities||[],meta:this.meta,order:this.order||-1,data:this.doneData,invoke:this.invoke,description:this.description,tags:this.tags}},enumerable:!1,configurable:!0}),e.prototype.toJSON=function(){return this.definition},Object.defineProperty(e.prototype,"on",{get:function(){if(this.__cache.on)return this.__cache.on;var e=this.transitions;return this.__cache.on=e.reduce((function(e,t){return e[t.eventType]=e[t.eventType]||[],e[t.eventType].push(t),e}),{})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"after",{get:function(){return this.__cache.delayedTransitions||(this.__cache.delayedTransitions=this.getDelayedTransitions(),this.__cache.delayedTransitions)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transitions",{get:function(){return this.__cache.transitions||(this.__cache.transitions=this.formatTransitions(),this.__cache.transitions)},enumerable:!1,configurable:!0}),e.prototype.getCandidates=function(e){if(this.__cache.candidates[e])return this.__cache.candidates[e];var t=e===Ot,n=this.transitions.filter((function(n){var r=n.eventType===e;return t?r:r||n.eventType===Nt}));return this.__cache.candidates[e]=n,n},e.prototype.getDelayedTransitions=function(){var e=this,t=this.config.after;if(!t)return[];var n=function(t,n){var r=Pe(Z(t)?"".concat(e.id,":delay[").concat(n,"]"):t,e.id);return e.onEntry.push(be(r,{delay:t})),e.onExit.push(Re(r)),r};return(Q(t)?t.map((function(e,t){var r=n(e.delay,t);return s(s({},e),{event:r})})):$(Object.keys(t).map((function(e,r){var i=t[e],o=ee(i)?{target:i}:i,a=isNaN(+e)?e:+e,c=n(a,r);return z(o).map((function(e){return s(s({},e),{event:c,delay:a})}))})))).map((function(t){var n=t.delay;return s(s({},e.formatTransition(t)),{delay:n})}))},e.prototype.getStateNodes=function(e){var t,n=this;if(!e)return[];var r=e instanceof lt?e.value:V(e,this.delimiter);if(ee(r)){var i=this.getStateNode(r).initial;return void 0!==i?this.getStateNodes(((t={})[r]=i,t)):[this,this.states[r]]}var o=Object.keys(r),a=[this];return a.push.apply(a,d([],l($(o.map((function(e){return n.getStateNode(e).getStateNodes(r[e])})))),!1)),a},e.prototype.handles=function(e){var t=M(e);return this.events.includes(t)},e.prototype.resolveState=function(e){var t=e instanceof lt?e:lt.create(e),n=Array.from(tt([],this.getStateNodes(t.value)));return new lt(s(s({},t),{value:this.resolve(t.value),configuration:n,done:at(n,this),tags:st(n),machine:this.machine}))},e.prototype.transitionLeafNode=function(e,t,n){var r=this.getStateNode(e).next(t,n);return r&&r.transitions.length?r:this.next(t,n)},e.prototype.transitionCompoundNode=function(e,t,n){var r=Object.keys(e),i=this.getStateNode(r[0])._transition(e[r[0]],t,n);return i&&i.transitions.length?i:this.next(t,n)},e.prototype.transitionParallelNode=function(e,t,n){var r,i,o={};try{for(var a=u(Object.keys(e)),s=a.next();!s.done;s=a.next()){var c=s.value,l=e[c];if(l){var d=this.getStateNode(c)._transition(l,t,n);d&&(o[c]=d)}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}var f=Object.keys(o).map((function(e){return o[e]})),p=$(f.map((function(e){return e.transitions})));if(!f.some((function(e){return e.transitions.length>0})))return this.next(t,n);var h=$(Object.keys(o).map((function(e){return o[e].configuration})));return{transitions:p,exitSet:$(f.map((function(e){return e.exitSet}))),configuration:h,source:t,actions:$(Object.keys(o).map((function(e){return o[e].actions})))}},e.prototype._transition=function(e,t,n){return ee(e)?this.transitionLeafNode(e,t,n):1===Object.keys(e).length?this.transitionCompoundNode(e,t,n):this.transitionParallelNode(e,t,n)},e.prototype.getTransitionData=function(e,t){return this._transition(e.value,e,ae(t))},e.prototype.next=function(e,t){var n,r,i,o=this,a=t.name,s=[],c=[];try{for(var f=u(this.getCandidates(a)),p=f.next();!p.done;p=f.next()){var h=p.value,v=h.cond,y=h.in,m=e.context,g=!y||(ee(y)&&Ct(y)?e.matches(V(this.getStateNodeById(y).path,this.delimiter)):P(V(y,this.delimiter),q(this.path.slice(0,-2))(e.value))),S=!1;try{S=!v||ce(this.machine,v,m,t,e)}catch(e){throw new Error("Unable to evaluate guard '".concat(v.name||v.type,"' in transition for event '").concat(a,"' in state node '").concat(this.id,"':\n").concat(e.message))}if(S&&g){void 0!==h.target&&(c=h.target),s.push.apply(s,d([],l(h.actions),!1)),i=h;break}}}catch(e){n={error:e}}finally{try{p&&!p.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}if(i){if(!c.length)return{transitions:[i],exitSet:[],configuration:e.value?[this]:[],source:e,actions:s};var b=$(c.map((function(t){return o.getRelativeStateNodes(t,e.historyValue)})));return{transitions:[i],exitSet:!!i.internal?[]:$(c.map((function(e){return o.getPotentiallyReenteringNodes(e)}))),configuration:b,source:e,actions:s}}},e.prototype.getPotentiallyReenteringNodes=function(e){if(this.order<e.order)return[this];for(var t=[],n=this,r=e;n&&n!==r;)t.push(n),n=n.parent;return n!==r?[]:(t.push(r),t)},e.prototype.getActions=function(e,t,n,r,i,o,a){var s,c,f,p,h=this,v=o?tt([],this.getStateNodes(o.value)):[],y=new Set;try{for(var m=u(Array.from(e).sort((function(e,t){return e.order-t.order}))),g=m.next();!g.done;g=m.next()){(!ot(v,E=g.value)||ot(n.exitSet,E)||E.parent&&y.has(E.parent))&&y.add(E)}}catch(e){s={error:e}}finally{try{g&&!g.done&&(c=m.return)&&c.call(m)}finally{if(s)throw s.error}}try{for(var S=u(v),b=S.next();!b.done;b=S.next()){var E;ot(e,E=b.value)&&!ot(n.exitSet,E.parent)||n.exitSet.push(E)}}catch(e){f={error:e}}finally{try{b&&!b.done&&(p=S.return)&&p.call(S)}finally{if(f)throw f.error}}n.exitSet.sort((function(e,t){return t.order-e.order}));var w=Array.from(y).sort((function(e,t){return e.order-t.order})),I=new Set(n.exitSet),x=$(w.map((function(e){var t=[];if("final"!==e.type)return t;var o=e.parent;if(!o.parent)return t;t.push(Me(e.id,e.doneData),Me(o.id,e.doneData?W(e.doneData,r,i):void 0));var a=o.parent;return"parallel"===a.type&&Ze(a).every((function(e){return at(n.configuration,e)}))&&t.push(Me(a.id)),t}))),D=w.map((function(e){var t=e.onEntry,n=e.activities.map((function(e){return Oe(e)}));return{type:"entry",actions:ye(a?d(d([],l(t),!1),l(n),!1):d(d([],l(n),!1),l(t),!1),h.machine.options.actions)}})).concat({type:"state_done",actions:x.map((function(e){return ge(e)}))}),_=Array.from(I).map((function(e){return{type:"exit",actions:ye(d(d([],l(e.onExit),!1),l(e.activities.map((function(e){return Ne(e)}))),!1),h.machine.options.actions)}})).concat({type:"transition",actions:ye(n.actions,this.machine.options.actions)}).concat(D);if(t){var k=ye($(d([],l(e),!1).sort((function(e,t){return t.order-e.order})).map((function(e){return e.onExit}))),this.machine.options.actions).filter((function(e){return!fe(e)}));return _.concat({type:"stop",actions:k})}return _},e.prototype.transition=function(e,t,n,r){void 0===e&&(e=this.initialState);var i,o,a=ae(t);if(e instanceof lt)i=void 0===n?e:this.resolveState(lt.from(e,n));else{var s=ee(e)?this.resolve(L(this.getResolvedPath(e))):this.resolve(e),c=null!=n?n:this.machine.context;i=this.resolveState(lt.from(s,c))}if(!j&&a.name===Nt)throw new Error("An event cannot have the wildcard type ('".concat(Nt,"')"));if(this.strict&&!this.events.includes(a.name)&&(o=a.name,!/^(done|error)\./.test(o)))throw new Error("Machine '".concat(this.id,"' does not accept event '").concat(a.name,"'"));var u=this._transition(i.value,i,a)||{transitions:[],configuration:[],exitSet:[],source:i,actions:[]},f=tt([],this.getStateNodes(i.value)),p=u.configuration.length?tt(f,u.configuration):f;return u.configuration=d([],l(p),!1),this.resolveTransition(u,i,i.context,r,a)},e.prototype.resolveRaisedTransition=function(e,t,n,r){var i,o=e.actions;return(e=this.transition(e,t,void 0,r))._event=n,e.event=n.data,(i=e.actions).unshift.apply(i,d([],l(o),!1)),e},e.prototype.resolveTransition=function(e,t,n,r,i){var o,a,c,d,f=this;void 0===i&&(i=pe);var v=e.configuration,y=!t||e.transitions.length>0,m=y?e.configuration:t?t.configuration:[],S=at(m,this),b=y?it(this.machine,v):void 0,E=t?t.historyValue?t.historyValue:e.source?this.machine.historyValue(t.value):void 0:void 0,w=this.getActions(new Set(m),S,e,n,i,t,r),I=t?s({},t.activities):{};try{for(var D=u(w),_=D.next();!_.done;_=D.next()){var k=_.value;try{for(var R=(c=void 0,u(k.actions)),O=R.next();!O.done;O=R.next()){var N=O.value;N.type===p?I[N.activity.id||N.activity.type]=N:N.type===h&&(I[N.activity.id||N.activity.type]=!1)}}catch(e){c={error:e}}finally{try{O&&!O.done&&(d=R.return)&&d.call(R)}finally{if(c)throw c.error}}}}catch(e){o={error:e}}finally{try{_&&!_.done&&(a=D.return)&&a.call(D)}finally{if(o)throw o.error}}var A,C,j=l($e(this,t,n,i,w,r,this.machine.config.predictableActionArguments||this.machine.config.preserveActionOrder),2),P=j[0],M=j[1],U=l(function(e,t){var n,r,i=l([[],[]],2),o=i[0],a=i[1];try{for(var s=u(e),c=s.next();!c.done;c=s.next()){var d=c.value;t(d)?o.push(d):a.push(d)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return[o,a]}(P,fe),2),V=U[0],L=U[1],F=P.filter((function(e){var t;return e.type===p&&(null===(t=e.activity)||void 0===t?void 0:t.type)===x})),B=F.reduce((function(e,t){return e[t.activity.id]=function(e,t,n,r){var i,o=ue(e.src),a=null===(i=null==t?void 0:t.options.services)||void 0===i?void 0:i[o.type],s=e.data?W(e.data,n,r):void 0,c=a?Ge(a,e.id,s):Je(e.id);return c.meta=e,c}(t.activity,f.machine,M,i),e}),t?s({},t.children):{}),q=new lt({value:b||t.value,context:M,_event:i,_sessionid:t?t._sessionid:null,historyValue:b?E?(A=E,C=b,{current:C,states:G(A,C)}):void 0:t?t.historyValue:void 0,history:!b||e.source?t:void 0,actions:b?L:[],activities:b?I:t?t.activities:{},events:[],configuration:m,transitions:e.transitions,children:B,done:S,tags:st(m),machine:this}),H=n!==M;q.changed=i.name===T||H;var $=q.history;$&&delete $.history;var Y=!S&&(this._transient||v.some((function(e){return e._transient})));if(!(y||Y&&i.name!==Ot))return q;var z=q;if(!S)for(Y&&(z=this.resolveRaisedTransition(z,{type:g},i,r));V.length;){var J=V.shift();z=this.resolveRaisedTransition(z,J._event,i,r)}var K=z.changed||($?!!z.actions.length||H||typeof $.value!=typeof z.value||!ct(z.value,$.value):void 0);return z.changed=K,z.history=$,z},e.prototype.getStateNode=function(e){if(Ct(e))return this.machine.getStateNodeById(e);if(!this.states)throw new Error("Unable to retrieve child state '".concat(e,"' from '").concat(this.id,"'; no child states exist."));var t=this.states[e];if(!t)throw new Error("Child state '".concat(e,"' does not exist on '").concat(this.id,"'"));return t},e.prototype.getStateNodeById=function(e){var t=Ct(e)?e.slice(1):e;if(t===this.id)return this;var n=this.machine.idMap[t];if(!n)throw new Error("Child state node '#".concat(t,"' does not exist on machine '").concat(this.id,"'"));return n},e.prototype.getStateNodeByPath=function(e){if("string"==typeof e&&Ct(e))try{return this.getStateNodeById(e.slice(1))}catch(e){}for(var t=U(e,this.delimiter).slice(),n=this;t.length;){var r=t.shift();if(!r.length)break;n=n.getStateNode(r)}return n},e.prototype.resolve=function(e){var t,n=this;if(!e)return this.initialStateValue||At;switch(this.type){case"parallel":return F(this.initialStateValue,(function(t,r){return t?n.getStateNode(r).resolve(e[r]||t):At}));case"compound":if(ee(e)){var r=this.getStateNode(e);return"parallel"===r.type||"compound"===r.type?((t={})[e]=r.initialStateValue,t):e}return Object.keys(e).length?F(e,(function(e,t){return e?n.getStateNode(t).resolve(e):At})):this.initialStateValue||{};default:return e||At}},e.prototype.getResolvedPath=function(e){if(Ct(e)){var t=this.machine.idMap[e.slice(1)];if(!t)throw new Error("Unable to find state node '".concat(e,"'"));return t.path}return U(e,this.delimiter)},Object.defineProperty(e.prototype,"initialStateValue",{get:function(){var e,t;if(this.__cache.initialStateValue)return this.__cache.initialStateValue;if("parallel"===this.type)t=B(this.states,(function(e){return e.initialStateValue||At}),(function(e){return!("history"===e.type)}));else if(void 0!==this.initial){if(!this.states[this.initial])throw new Error("Initial state '".concat(this.initial,"' not found on '").concat(this.key,"'"));t=Xe(this.states[this.initial])?this.initial:((e={})[this.initial]=this.states[this.initial].initialStateValue,e)}else t={};return this.__cache.initialStateValue=t,this.__cache.initialStateValue},enumerable:!1,configurable:!0}),e.prototype.getInitialState=function(e,t){this._init();var n=this.getStateNodes(e);return this.resolveTransition({configuration:n,exitSet:[],transitions:[],source:void 0,actions:[]},void 0,null!=t?t:this.machine.context,void 0)},Object.defineProperty(e.prototype,"initialState",{get:function(){var e=this.initialStateValue;if(!e)throw new Error("Cannot retrieve initial state from simple state '".concat(this.id,"'."));return this.getInitialState(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){var e;if("history"===this.type){var t=this.config;e=ee(t.target)&&Ct(t.target)?L(this.machine.getStateNodeById(t.target).path.slice(this.path.length-1)):t.target}return e},enumerable:!1,configurable:!0}),e.prototype.getRelativeStateNodes=function(e,t,n){return void 0===n&&(n=!0),n?"history"===e.type?e.resolveHistory(t):e.initialStateNodes:[e]},Object.defineProperty(e.prototype,"initialStateNodes",{get:function(){var e=this;return Xe(this)?[this]:"compound"!==this.type||this.initial?$(H(this.initialStateValue).map((function(t){return e.getFromRelativePath(t)}))):(j||X(!1,"Compound state node '".concat(this.id,"' has no initial state.")),[this])},enumerable:!1,configurable:!0}),e.prototype.getFromRelativePath=function(e){if(!e.length)return[this];var t=l(e),n=t[0],r=t.slice(1);if(!this.states)throw new Error("Cannot retrieve subPath '".concat(n,"' from node with no states"));var i=this.getStateNode(n);if("history"===i.type)return i.resolveHistory();if(!this.states[n])throw new Error("Child state '".concat(n,"' does not exist on '").concat(this.id,"'"));return this.states[n].getFromRelativePath(r)},e.prototype.historyValue=function(e){if(Object.keys(this.states).length)return{current:e||this.initialStateValue,states:B(this.states,(function(t,n){if(!e)return t.historyValue();var r=ee(e)?void 0:e[n];return t.historyValue(r||t.initialStateValue)}),(function(e){return!e.history}))}},e.prototype.resolveHistory=function(e){var t=this;if("history"!==this.type)return[this];var n=this.parent;if(!e){var r=this.target;return r?$(H(r).map((function(e){return n.getFromRelativePath(e)}))):n.initialStateNodes}var i,o,a=(i=n.path,o="states",function(e){var t,n,r=e;try{for(var a=u(i),s=a.next();!s.done;s=a.next()){var c=s.value;r=r[o][c]}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return r})(e).current;return ee(a)?[n.getStateNode(a)]:$(H(a).map((function(e){return"deep"===t.history?n.getFromRelativePath(e):[n.states[e[0]]]})))},Object.defineProperty(e.prototype,"stateIds",{get:function(){var e=this,t=$(Object.keys(this.states).map((function(t){return e.states[t].stateIds})));return[this.id].concat(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"events",{get:function(){var e,t,n,r;if(this.__cache.events)return this.__cache.events;var i=this.states,o=new Set(this.ownEvents);if(i)try{for(var a=u(Object.keys(i)),s=a.next();!s.done;s=a.next()){var c=i[s.value];if(c.states)try{for(var l=(n=void 0,u(c.events)),d=l.next();!d.done;d=l.next()){var f=d.value;o.add("".concat(f))}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}return this.__cache.events=Array.from(o)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ownEvents",{get:function(){var e=new Set(this.transitions.filter((function(e){return!(!e.target&&!e.actions.length&&e.internal)})).map((function(e){return e.eventType})));return Array.from(e)},enumerable:!1,configurable:!0}),e.prototype.resolveTarget=function(e){var t=this;if(void 0!==e)return e.map((function(e){if(!ee(e))return e;var n=e[0]===t.delimiter;if(n&&!t.parent)return t.getStateNodeByPath(e.slice(1));var r=n?t.key+e:e;if(!t.parent)return t.getStateNodeByPath(r);try{return t.parent.getStateNodeByPath(r)}catch(e){throw new Error("Invalid transition definition for state node '".concat(t.id,"':\n").concat(e.message))}}))},e.prototype.formatTransition=function(e){var t=this,n=function(e){if(void 0!==e&&""!==e)return z(e)}(e.target),r="internal"in e?e.internal:!n||n.some((function(e){return ee(e)&&e[0]===t.delimiter})),i=this.machine.options.guards,o=this.resolveTarget(n),a=s(s({},e),{actions:ye(z(e.actions)),cond:te(e.cond,i),target:o,source:this,internal:r,eventType:e.event,toJSON:function(){return s(s({},a),{target:a.target?a.target.map((function(e){return"#".concat(e.id)})):void 0,source:"#".concat(t.id)})}});return a},e.prototype.formatTransitions=function(){var e,t,n,r=this;if(this.config.on)if(Array.isArray(this.config.on))n=this.config.on;else{var i=this.config.on,o=Nt,a=i[o],s=void 0===a?[]:a,f=c(i,["*"]);n=$(Object.keys(f).map((function(e){j||e!==Ot||X(!1,"Empty string transition configs (e.g., `{ on: { '': ... }}`) for transient transitions are deprecated. Specify the transition in the `{ always: ... }` property instead. "+'Please check the `on` configuration for "#'.concat(r.id,'".'));var t=se(e,f[e]);return j||function(e,t,n){var r=n.slice(0,-1).some((function(e){return!("cond"in e)&&!("in"in e)&&(ee(e.target)||re(e.target))})),i=t===Ot?"the transient event":"event '".concat(t,"'");X(!r,"One or more transitions for ".concat(i," on state '").concat(e.id,"' are unreachable. ")+"Make sure that the default transition is the last one defined.")}(r,e,t),t})).concat(se(Nt,s)))}else n=[];var p=this.config.always?se("",this.config.always):[],h=this.config.onDone?se(String(Me(this.id)),this.config.onDone):[];j||X(!(this.config.onDone&&!this.parent),'Root nodes cannot have an ".onDone" transition. Please check the config of "'.concat(this.id,'".'));var v=$(this.invoke.map((function(e){var t=[];return e.onDone&&t.push.apply(t,d([],l(se(String(Ue(e.id)),e.onDone)),!1)),e.onError&&t.push.apply(t,d([],l(se(String(Ve(e.id)),e.onError)),!1)),t}))),y=this.after,m=$(d(d(d(d([],l(h),!1),l(v),!1),l(n),!1),l(p),!1).map((function(e){return z(e).map((function(e){return r.formatTransition(e)}))})));try{for(var g=u(y),S=g.next();!S.done;S=g.next()){var b=S.value;m.push(b)}}catch(t){e={error:t}}finally{try{S&&!S.done&&(t=g.return)&&t.call(g)}finally{if(e)throw e.error}}return m},e}(),Pt=!1;function Mt(e,t,n){return void 0===n&&(n=e.context),new jt(e,t,n)}function Ut(e,t){return j||"predictableActionArguments"in e||Pt||(Pt=!0,console.warn("It is highly recommended to set `predictableActionArguments` to `true` when using `createMachine`. https://xstate.js.org/docs/guides/actions.html")),new jt(e,t)}function Vt(e,t){var n,r,i;try{for(var o=u(Object.keys(e)),a=o.next();!a.done;a=o.next()){var s=a.value;P(s,t)&&(!i||t.length>i.length)&&(i=s)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return e[i]}function Lt(e,t,n){var r,i,o=lt.from(e,e instanceof lt?e.context:void 0);try{for(var a=u(t),s=a.next();!s.done;s=a.next()){var c=l(s.value,2),d=c[0],f=c[1];if(o.matches(d))return f(o)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return n(o)}function Ft(e){return e}var Bt=Ft,qt=Ce,Ht=be,$t=Ie,Yt=we,zt=xe,Wt=Fe,Jt=Ue,Gt=ge},464:e=>{"use strict";e.exports=i},867:e=>{"use strict";e.exports=r},762:e=>{"use strict";e.exports=t},148:e=>{"use strict";e.exports=n},369:t=>{"use strict";t.exports=e},9:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(e){var t=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===r(t)?t:String(t)}function o(e,t,n){return(t=i(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{$G:()=>x});var a=n(735);n(432);Object.create(null);function s(){if(console&&console.warn){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];"string"==typeof n[0]&&(n[0]="react-i18next:: ".concat(n[0])),(e=console).warn.apply(e,n)}}var c={};function u(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&c[t[0]]||("string"==typeof t[0]&&(c[t[0]]=new Date),s.apply(void 0,t))}function l(e,t,n){e.loadNamespaces(t,(function(){if(e.isInitialized)n();else{e.on("initialized",(function t(){setTimeout((function(){e.off("initialized",t)}),0),n()}))}}))}var d=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,f={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},p=function(e){return f[e]};var h,v={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:function(e){return e.replace(d,p)}};function y(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,i(r.key),r)}}var m=(0,a.createContext)(),g=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.usedNamespaces={}}var t,n,r;return t=e,(n=[{key:"addUsedNamespaces",value:function(e){var t=this;e.forEach((function(e){t.usedNamespaces[e]||(t.usedNamespaces[e]=!0)}))}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}])&&y(t.prototype,n),r&&y(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function b(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return S(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?S(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?E(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var I=function(e,t){var n=(0,a.useRef)();return(0,a.useEffect)((function(){n.current=t?n.current:e}),[e,t]),n.current};function x(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.i18n,i=(0,a.useContext)(m)||{},o=i.i18n,s=i.defaultNS,c=n||o||h;if(c&&!c.reportNamespaces&&(c.reportNamespaces=new g),!c){u("You will need to pass in an i18next instance by using initReactI18next");var d=function(e,t){return"string"==typeof t?t:t&&"object"===r(t)&&"string"==typeof t.defaultValue?t.defaultValue:Array.isArray(e)?e[e.length-1]:e},f=[d,{},!1];return f.t=d,f.i18n={},f.ready=!1,f}c.options.react&&void 0!==c.options.react.wait&&u("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var p=w(w(w({},v),c.options.react),t),y=p.useSuspense,S=p.keyPrefix,E=e||s||c.options&&c.options.defaultNS;E="string"==typeof E?[E]:E||["translation"],c.reportNamespaces.addUsedNamespaces&&c.reportNamespaces.addUsedNamespaces(E);var x=(c.isInitialized||c.initializedStoreOnce)&&E.every((function(e){return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.languages&&t.languages.length?void 0!==t.options.ignoreJSONStructure?t.hasLoadedNamespace(e,{precheck:function(t,r){if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}):function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=t.languages[0],i=!!t.options&&t.options.fallbackLng,o=t.languages[t.languages.length-1];if("cimode"===r.toLowerCase())return!0;var a=function(e,n){var r=t.services.backendConnector.state["".concat(e,"|").concat(n)];return-1===r||2===r};return!(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!a(t.isLanguageChangingTo,e)||!t.hasResourceBundle(r,e)&&t.services.backendConnector.backend&&(!t.options.resources||t.options.partialBundledLanguages)&&(!a(r,e)||i&&!a(o,e)))}(e,t,n):(u("i18n.languages were undefined or empty",t.languages),!0)}(e,c,p)}));function D(){return c.getFixedT(null,"fallback"===p.nsMode?E:E[0],S)}var _=b((0,a.useState)(D),2),k=_[0],T=_[1],R=E.join(),O=I(R),N=(0,a.useRef)(!0);(0,a.useEffect)((function(){var e=p.bindI18n,t=p.bindI18nStore;function n(){N.current&&T(D)}return N.current=!0,x||y||l(c,E,(function(){N.current&&T(D)})),x&&O&&O!==R&&N.current&&T(D),e&&c&&c.on(e,n),t&&c&&c.store.on(t,n),function(){N.current=!1,e&&c&&e.split(" ").forEach((function(e){return c.off(e,n)})),t&&c&&t.split(" ").forEach((function(e){return c.store.off(e,n)}))}}),[c,R]);var A=(0,a.useRef)(!0);(0,a.useEffect)((function(){N.current&&!A.current&&T(D),A.current=!1}),[c,S]);var C=[k,c,x];if(C.t=k,C.i18n=c,C.ready=x,x)return C;if(!x&&!y)return C;throw new Promise((function(e){l(c,E,(function(){e()}))}))}}},l={};function d(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return u[e].call(n.exports,n,n.exports,d),n.exports}d.m=u,o=[],d.O=(e,t,n,r)=>{if(!t){var i=1/0;for(u=0;u<o.length;u++){for(var[t,n,r]=o[u],a=!0,s=0;s<t.length;s++)(!1&r||i>=r)&&Object.keys(d.O).every((e=>d.O[e](t[s])))?t.splice(s--,1):(a=!1,r<i&&(i=r));if(a){o.splice(u--,1);var c=n();void 0!==c&&(e=c)}}return e}r=r||0;for(var u=o.length;u>0&&o[u-1][2]>r;u--)o[u]=o[u-1];o[u]=[t,n,r]},d.F={},d.E=e=>{Object.keys(d.F).map((t=>{d.F[t](e)}))},d.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return d.d(t,{a:t}),t},s=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,d.t=function(e,t){if(1&t&&(e=this(e)),8&t)return e;if("object"==typeof e&&e){if(4&t&&e.__esModule)return e;if(16&t&&"function"==typeof e.then)return e}var n=Object.create(null);d.r(n);var r={};a=a||[null,s({}),s([]),s(s)];for(var i=2&t&&e;"object"==typeof i&&!~a.indexOf(i);i=s(i))Object.getOwnPropertyNames(i).forEach((t=>r[t]=()=>e[t]));return r.default=()=>e,d.d(n,r),n},d.d=(e,t)=>{for(var n in t)d.o(t,n)&&!d.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),d.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c={143:0},d.F.j=e=>{if(!d.o(c,e)||void 0===c[e]){c[e]=null;var t=document.createElement("link");d.nc&&t.setAttribute("nonce",d.nc),t.rel="prefetch",t.as="script",t.href=d.p+d.u(e),document.head.appendChild(t)}},d.O.j=e=>0===c[e],d.O(0,[143],(()=>{d.E(143)}),5);var f={};return(()=>{"use strict";d.r(f),d.d(f,{default:()=>X});var e=d(18),t=d(735),n=d.t(t,2),r=d(216),i=d.n(r),o=d(762),a=d(369);const{formatDate:s}=o.utils;function c(n){let{servicesManager:r,getImageSrc:i,getStudiesForPatientByMRN:o,requestDisplaySetCreationForStudy:c,dataSource:u}=n;const{measurementService:d,displaySetService:f,uiDialogService:p,hangingProtocolService:h,uiNotificationService:v}=r.services,{StudyInstanceUIDs:y}=(0,a.useImageViewer)(),[{activeViewportIndex:m,viewports:g,numCols:S,numRows:b},E]=(0,a.useViewportGrid)(),[w,I]=(0,e.I)(),[x,D]=(0,t.useState)("primary"),[_,k]=(0,t.useState)([...y]),[T,R]=(0,t.useState)([]),[O,N]=(0,t.useState)([]),[A,C]=(0,t.useState)({}),[j,P]=(0,t.useState)(null),M=g[m]?.displaySetInstanceUIDs;(0,t.useEffect)((()=>{const e=d.EVENTS.MEASUREMENT_ADDED,t=d.EVENTS.RAW_MEASUREMENT_ADDED,n=[];return[e,t].forEach((e=>{n.push(d.subscribe(e,(e=>{let{source:t,measurement:n}=e;const{referenceSeriesUID:r,referenceStudyUID:i}=n;I("SET_DIRTY",{SeriesInstanceUID:r}),I("TRACK_SERIES",{viewportIndex:m,StudyInstanceUID:i,SeriesInstanceUID:r})})).unsubscribe)})),()=>{n.forEach((e=>{e()}))}}),[d,m,I]);const{trackedSeries:U}=w.context;(0,t.useEffect)((()=>{y.forEach((e=>async function(e){const t=await u.query.studies.search({studyInstanceUid:e});let n=t;try{n=await o(t)}catch(e){console.warn(e)}const r=n.map((e=>({AccessionNumber:e.accession,StudyDate:e.date,StudyDescription:e.description,NumInstances:e.instances,ModalitiesInStudy:e.modalities,PatientID:e.mrn,PatientName:e.patientName,StudyInstanceUID:e.studyInstanceUid,StudyTime:e.time}))).map((e=>({studyInstanceUid:e.StudyInstanceUID,date:s(e.StudyDate),description:e.StudyDescription,modalities:e.ModalitiesInStudy,numInstances:e.NumInstances})));R((e=>{const t=[...e];for(const n of r)e.find((e=>e.studyInstanceUid===n.studyInstanceUid))||t.push(n);return t}))}(e)))}),[y,o]),(0,t.useEffect)((()=>{const e=f.activeDisplaySets;e.length&&e.forEach((async e=>{const t={},n=f.getDisplaySetByUID(e.displaySetInstanceUID),r=u.getImageIdsForDisplaySet(n),o=r[Math.floor(r.length/2)];o&&(t[e.displaySetInstanceUID]=await i(o),C((e=>({...e,...t}))))}))}),[f,u,i]),(0,t.useEffect)((()=>{const e=f.activeDisplaySets;if(!e.length)return;const t=l(e,A,U,g,E,u,f,p,v);N(t)}),[f.activeDisplaySets,U,g,u,A]),(0,t.useEffect)((()=>{const e=f.subscribe(f.EVENTS.DISPLAY_SETS_ADDED,(e=>{const{displaySetsAdded:t,options:n}=e;t.forEach((async e=>{const t=e.displaySetInstanceUID,r={},o=f.getDisplaySetByUID(t);n.madeInClient&&P(t);const a=u.getImageIdsForDisplaySet(o),s=a[Math.floor(a.length/2)];s&&(r[t]=await i(s),C((e=>({...e,...r}))))}))})),t=f.subscribe(f.EVENTS.DISPLAY_SETS_CHANGED,(e=>{const t=l(e,A,U,g,E,u,f,p,v);N(t)}));return()=>{e.unsubscribe(),t.unsubscribe()}}),[f,u,i,A,U,g]);const V=function(e,t,n,r){const i=[],o=[],a=[];t.forEach((t=>{const s=n.filter((e=>e.StudyInstanceUID===t.studyInstanceUid)),c=r.getDisplaySetSortFunction();s.sort(c);const u=Object.assign({},t,{displaySets:s});e.includes(t.studyInstanceUid)?(i.push(u),a.push(u)):(o.push(u),a.push(u))}));const s=(e,t)=>{const n=Date.parse(e);return Date.parse(t)-n},c=[{name:"primary",label:"Primary",studies:i.sort(((e,t)=>s(e.date,t.date)))},{name:"recent",label:"Recent",studies:o.sort(((e,t)=>s(e.date,t.date)))},{name:"all",label:"All",studies:a.sort(((e,t)=>s(e.date,t.date)))}];return c}(y,T,O,h);return(0,t.useEffect)((()=>{if(j){const e=j,t=document.getElementById(`thumbnail-${e}`);t&&"function"==typeof t.scrollIntoView&&(t.scrollIntoView({behavior:"smooth"}),P(null))}}),[j,_,x]),(0,t.useEffect)((()=>{if(!j)return;const e=function(e,t){for(let n=0;n<t.length;n++){const{studies:r}=t[n];for(let i=0;i<r.length;i++){const{displaySets:o}=r[i];for(let a=0;a<o.length;a++){if(o[a].displaySetInstanceUID===e)return{tabName:t[n].name,StudyInstanceUID:r[i].studyInstanceUid}}}}}(j,V);if(!e)return void console.warn("jumpToThumbnail: displaySet thumbnail not found.");const{tabName:t,StudyInstanceUID:n}=e;D(t);if(!_.includes(n)){const e=[..._,n];k(e)}}),[_,j,V]),t.createElement(a.StudyBrowser,{tabs:V,servicesManager:r,activeTabName:x,expandedStudyInstanceUIDs:_,onClickStudy:function(e){const t=_.includes(e),n=t?[..._.filter((t=>t!==e))]:[..._,e];if(k(n),!t){c(f,e,!0)}},onClickTab:e=>{D(e)},onClickUntrack:e=>{const t=f.getDisplaySetByUID(e);I("UNTRACK_SERIES",{SeriesInstanceUID:t.SeriesInstanceUID})},onClickThumbnail:()=>{},onDoubleClickThumbnail:e=>{let t=[];const n=m;try{t=h.getViewportsRequireUpdate(n,e)}catch(e){console.warn(e),v.show({title:"Thumbnail Double Click",message:"The selected display sets could not be added to the viewport due to a mismatch in the Hanging Protocol rules.",type:"info",duration:3e3})}E.setDisplaySetsForViewports(t)},activeDisplaySetInstanceUIDs:M})}c.propTypes={servicesManager:i().object.isRequired,dataSource:i().shape({getImageIdsForDisplaySet:i().func.isRequired}).isRequired,getImageSrc:i().func.isRequired,getStudiesForPatientByMRN:i().func.isRequired,requestDisplaySetCreationForStudy:i().func.isRequired};const u=c;function l(e,n,r,i,o,c,u,l,d){const f=[],h=[];return e.filter((e=>!e.excludeFromThumbnailBrowser)).forEach((e=>{const v=n[e.displaySetInstanceUID],y=function(e){if(p.includes(e))return"thumbnailNoImage";return"thumbnailTracked"}(e.Modality),m=o.getNumViewportPanes(),g=1===m?[]:i.reduce(((t,n,r)=>(r<m&&n?.displaySetInstanceUIDs?.includes(e.displaySetInstanceUID)&&t.push(n.viewportLabel),t)),[]),S="thumbnailTracked"===y?f:h,{displaySetInstanceUID:b}=e,E={displaySetInstanceUID:b,description:e.SeriesDescription,seriesNumber:e.SeriesNumber,modality:e.Modality,seriesDate:s(e.SeriesDate),numInstances:e.numImageFrames,countIcon:e.countIcon,StudyInstanceUID:e.StudyInstanceUID,componentType:y,imageSrc:v,dragData:{type:"displayset",displaySetInstanceUID:b},isTracked:r.includes(e.SeriesInstanceUID),viewportIdentificator:g};"thumbnailNoImage"===y&&(c.reject&&c.reject.series?(E.canReject=!0,E.onReject=()=>{l.create({id:"ds-reject-sr",centralize:!0,isDraggable:!1,showOverlay:!0,content:a.Dialog,contentProps:{title:"Delete Report",body:()=>t.createElement("div",{className:"p-4 text-white bg-primary-dark"},t.createElement("p",null,"Are you sure you want to delete this report?"),t.createElement("p",null,"This action cannot be undone.")),actions:[{id:"cancel",text:"Cancel",type:"secondary"},{id:"yes",text:"Yes",type:"primary",classes:["reject-yes-button"]}],onClose:()=>l.dismiss({id:"ds-reject-sr"}),onShow:()=>{document.querySelector(".reject-yes-button").focus()},onSubmit:async t=>{let{action:n}=t;switch(n.id){case"yes":try{await c.reject.series(e.StudyInstanceUID,e.SeriesInstanceUID),u.deleteDisplaySet(b),l.dismiss({id:"ds-reject-sr"}),d.show({title:"Delete Report",message:"Report deleted successfully",type:"success"})}catch(e){l.dismiss({id:"ds-reject-sr"}),d.show({title:"Delete Report",message:"Failed to delete report",type:"error"})}break;case"cancel":l.dismiss({id:"ds-reject-sr"})}}}})}):E.canReject=!1),S.push(E)})),[...f,...h]}const p=["SR","SEG","SM","RTSTRUCT","RTPLAN","RTDOSE","DOC","OT"];const h=function(e,t){return new Promise(((n,r)=>{const i=document.createElement("canvas");e.utilities.loadImageToCanvas({canvas:i,imageId:t}).then((e=>{n(i.toDataURL())})).catch(r)}))};const v=function(e,t,n,r){t.activeDisplaySets.some((e=>e.StudyInstanceUID===n))||e.retrieve.series.metadata({StudyInstanceUID:n,madeInClient:r})};function y(e){let{commandsManager:n,extensionManager:r,servicesManager:i}=e;const o=r.getActiveDataSource()[0],a=function(e){const t=e.getModuleEntry("@ohif/extension-default.utilityModule.common"),{getStudiesForPatientByMRN:n}=t.exports;return n}(r),s=a.bind(null,o),c=function(e){const t=e.getModuleEntry("@ohif/extension-cornerstone.utilityModule.common");try{const{cornerstone:e}=t.exports.getCornerstoneLibraries();return h.bind(null,e)}catch(e){throw new Error("Required command not found")}}(r),l=v.bind(null,o);return t.createElement(u,{servicesManager:i,dataSource:o,getImageSrc:c,getStudiesForPatientByMRN:s,requestDisplaySetCreationForStudy:l})}y.propTypes={commandsManager:i().object.isRequired,extensionManager:i().object.isRequired,servicesManager:i().object.isRequired};const m=y;var g;!function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"}(g||(g={}));var S;!function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"}(S||(S={}));new Set(["lazy","caseSensitive","path","id","index","children"]);class b extends Error{}const E=["post","put","patch","delete"],w=(new Set(E),["get",...E]);new Set(w),new Set([301,302,303,307,308]),new Set([307,308]),"undefined"!=typeof window&&void 0!==window.document&&window.document.createElement;Symbol("deferred");const I="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},{useState:x,useEffect:D,useLayoutEffect:_,useDebugValue:k}=n;function T(e){const t=e.getSnapshot,n=e.value;try{const e=t();return!I(n,e)}catch(e){return!0}}"undefined"==typeof window||void 0===window.document||window.document.createElement;class R extends t.Component{constructor(e){super(e),this.state={location:e.location,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location?{error:e.error,location:e.location}:{error:e.error||t.error,location:t.location}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return this.state.error?React.createElement(RouteContext.Provider,{value:this.props.routeContext},React.createElement(RouteErrorContext.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}var O,N;!function(e){e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator"}(O||(O={})),function(e){e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator"}(N||(N={}));var A;!function(e){e[e.pending=0]="pending",e[e.success=1]="success",e[e.error=2]="error"}(A||(A={}));new Promise((()=>{}));class C extends t.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error("<Await> caught the following error during render",e,t)}render(){let{children:e,errorElement:t,resolve:n}=this.props,r=null,i=A.pending;if(n instanceof Promise)if(this.state.error){A.error;let e=this.state.error;Promise.reject().catch((()=>{})),Object.defineProperty(r,"_tracked",{get:()=>!0}),Object.defineProperty(r,"_error",{get:()=>e})}else n._tracked?(n,void 0!==r._error?A.error:void 0!==r._data?A.success:A.pending):(A.pending,Object.defineProperty(n,"_tracked",{get:()=>!0}),n.then((e=>Object.defineProperty(n,"_data",{get:()=>e})),(e=>Object.defineProperty(n,"_error",{get:()=>e}))));else A.success,Promise.resolve(),Object.defineProperty(r,"_tracked",{get:()=>!0}),Object.defineProperty(r,"_data",{get:()=>n});if(i===A.error&&r._error instanceof AbortedDeferredError)throw neverSettledPromise;if(i===A.error&&!t)throw r._error;if(i===A.error)return React.createElement(AwaitContext.Provider,{value:r,children:t});if(i===A.success)return React.createElement(AwaitContext.Provider,{value:r,children:e});throw r}}"undefined"!=typeof window&&void 0!==window.document&&window.document.createElement;var j,P;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmitImpl="useSubmitImpl",e.UseFetcher="useFetcher"})(j||(j={})),function(e){e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(P||(P={}));var M=d(9);function U(e){let{onExportClick:n,onCreateReportClick:r,disabled:i}=e;const{t:o}=(0,M.$G)("MeasurementTable");return t.createElement(t.Fragment,null,t.createElement(a.Button,{className:"text-base px-2 py-2",size:"initial",variant:i?"disabled":"outlined",color:"black",border:"primaryActive",onClick:n,disabled:i},o("Export")),t.createElement(a.Button,{className:"ml-2 px-2 text-base",variant:i?"disabled":"outlined",size:"initial",color:"black",border:"primaryActive",onClick:r,disabled:i},o("Create Report")))}U.propTypes={onExportClick:i().func,onCreateReportClick:i().func,disabled:i().bool},U.defaultProps={onExportClick:()=>alert("Export"),onCreateReportClick:()=>alert("Create Report"),disabled:!1};const V=U;var L=d(1),F=d.n(L);const{downloadCSVReport:B}=o.utils,{formatDate:q}=o.utils,H={key:void 0,date:"",modality:"",description:""};function $(n){let{servicesManager:r,extensionManager:i}=n;const[s,c]=(0,a.useViewportGrid)(),[u,l]=(0,t.useState)(Date.now().toString()),d=function(e,n){const[r,i]=(0,t.useState)(e);return(0,t.useEffect)((()=>{const t=setTimeout((()=>{i(e)}),n);return()=>{clearTimeout(t)}}),[e,n]),r}(u,200),{measurementService:f,uiDialogService:p,displaySetService:h}=r.services,[v,y]=(0,e.I)(),{trackedStudy:m,trackedSeries:g}=v.context,[S,b]=(0,t.useState)(H),[E,w]=(0,t.useState)([]),I=(0,t.useRef)(null);(0,t.useEffect)((()=>{const e=f.getMeasurements().filter((e=>m===e.referenceStudyUID&&g.includes(e.referenceSeriesUID))).map((e=>function(e,t,n){const{referenceStudyUID:r,referenceSeriesUID:i,SOPInstanceUID:a}=e,s=(o.DicomMetadataStore.getInstance(r,i,a),n.getDisplaySetsForSeries(i));if(!s[0]||!s[0].images)throw new Error('The tracked measurements panel should only be tracking "stack" displaySets.');const{displayText:c,uid:u,label:l,type:d,selected:f,findingSites:p,finding:h}=e,v=p?.[0],y=l||h?.text||v?.text||"(empty)";let m=c||[];if(p){const e=[];p.forEach((t=>{t?.text!==y&&e.push(t.text)})),m=[...e,...m]}h&&h?.text!==y&&(m=[h.text,...m]);return{uid:u,label:y,baseLabel:l,measurementType:d,displayText:m,baseDisplayText:c,isActive:f,finding:h,findingSites:p}}(e,f.VALUE_TYPES,h)));w(e)}),[f,m,g,d]);const x=async()=>{if(v.matches("tracking")){const e=m,t=o.DicomMetadataStore.getStudy(e),n=t.series[0].instances[0],{StudyDate:r,StudyDescription:i}=n,a=new Set;t.series.forEach((e=>{g.includes(e.SeriesInstanceUID)&&a.add(e.instances[0].Modality)}));const s=Array.from(a).join("/");S.key!==e&&b({key:e,date:r,modality:s,description:i})}else""!==m&&void 0!==m||b(H)};(0,t.useEffect)((()=>{x()}),[S.key,v,m,x]),(0,t.useEffect)((()=>{const e=f.EVENTS.MEASUREMENT_ADDED,t=f.EVENTS.RAW_MEASUREMENT_ADDED,n=f.EVENTS.MEASUREMENT_UPDATED,r=f.EVENTS.MEASUREMENT_REMOVED,i=f.EVENTS.MEASUREMENTS_CLEARED,o=[];return[e,t,n,r,i].forEach((t=>{o.push(f.subscribe(t,(()=>{l(Date.now().toString()),t===e&&F()((()=>{I.current.scrollTop=I.current.scrollHeight}),300)()})).unsubscribe)})),()=>{o.forEach((e=>{e()}))}}),[f,y]);const D=e=>{let{uid:t,isActive:n}=e;f.jumpToMeasurement(s.activeViewportIndex,t),k({uid:t,isActive:n})},_=e=>{let{uid:n,isActive:r}=e;const i=f.getMeasurement(n);D({uid:n,isActive:r});const o=e=>{let{action:t,value:r}=e;if("save"===t.id)f.update(n,{...i,...r},!0);p.dismiss({id:"enter-annotation"})};p.create({id:"enter-annotation",centralize:!0,isDraggable:!1,showOverlay:!0,content:a.Dialog,contentProps:{title:"Enter your annotation",noCloseButton:!0,value:{label:i.label||""},body:e=>{let{value:n,setValue:r}=e;return t.createElement("div",{className:"p-4 bg-primary-dark"},t.createElement(a.Input,{autoFocus:!0,id:"annotation",className:"mt-2 bg-black border-primary-main",type:"text",containerClassName:"mr-2",value:n.label,onChange:e=>{e.persist(),r((t=>({...t,label:e.target.value})))},onKeyPress:e=>{"Enter"===e.key&&o({value:n,action:{id:"save"}})}}))},actions:[{id:"cancel",text:"Cancel",type:"primary"},{id:"save",text:"Save",type:"secondary"}],onSubmit:o}})},k=e=>{let{uid:t,isActive:n}=e;if(!n){const e=[...E],n=e.find((e=>e.uid===t));e.forEach((e=>e.isActive=e.uid===t)),n.isActive=!0,w(e)}},T=E.filter((e=>e.measurementType!==f.VALUE_TYPES.POINT)),R=E.filter((e=>e.measurementType===f.VALUE_TYPES.POINT));return t.createElement(t.Fragment,null,t.createElement("div",{className:"overflow-x-hidden overflow-y-auto invisible-scrollbar",ref:I,"data-cy":"trackedMeasurements-panel"},S.key&&t.createElement(a.StudySummary,{date:q(S.date),modality:S.modality,description:S.description}),t.createElement(a.MeasurementTable,{title:"Measurements",data:T,servicesManager:r,onClick:D,onEdit:_}),0!==R.length&&t.createElement(a.MeasurementTable,{title:"Additional Findings",data:R,servicesManager:r,onClick:D,onEdit:_})),t.createElement("div",{className:"flex justify-center p-4"},t.createElement(V,{onExportClick:async function(){const e=f.getMeasurements().filter((e=>m===e.referenceStudyUID&&g.includes(e.referenceSeriesUID)));B(e,f)},onCreateReportClick:()=>{y("SAVE_REPORT",{viewportIndex:s.activeViewportIndex,isBackupSave:!0})},disabled:0===R.length&&0===T.length})))}$.propTypes={servicesManager:i().shape({services:i().shape({measurementService:i().shape({getMeasurements:i().func.isRequired,VALUE_TYPES:i().object.isRequired}).isRequired}).isRequired}).isRequired};const Y=$;const z=function(e){let{commandsManager:t,extensionManager:n,servicesManager:r}=e;return[{name:"seriesList",iconName:"group-layers",iconLabel:"Studies",label:"Studies",component:m.bind(null,{commandsManager:t,extensionManager:n,servicesManager:r})},{name:"trackedMeasurements",iconName:"tab-linear",iconLabel:"Measure",label:"Measurements",component:Y.bind(null,{commandsManager:t,extensionManager:n,servicesManager:r})}]};function W(){return W=Object.assign?Object.assign.bind():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},W.apply(this,arguments)}const J=t.lazy((()=>Promise.resolve().then(d.bind(d,736)))),G=e=>t.createElement(t.Suspense,{fallback:t.createElement("div",null,"Loading...")},t.createElement(J,e));const K=function(e){let{servicesManager:n,commandsManager:r,extensionManager:i}=e;return[{name:"cornerstone-tracked",component:e=>t.createElement(G,W({servicesManager:n,commandsManager:r,extensionManager:i},e))}]},X={id:JSON.parse('{"u2":"@ohif/extension-measurement-tracking"}').u2,getContextModule:e.Z,getPanelModule:z,getViewportModule:K}})(),f=d.O(f)})()));
|
|
3
|
+
//# sourceMappingURL=ohif-extension-measurement-tracking.umd.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
object-assign
|
|
3
|
+
(c) Sindre Sorhus
|
|
4
|
+
@license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*! *****************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* React Router v6.10.0
|
|
24
|
+
*
|
|
25
|
+
* Copyright (c) Remix Software Inc.
|
|
26
|
+
*
|
|
27
|
+
* This source code is licensed under the MIT license found in the
|
|
28
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
29
|
+
*
|
|
30
|
+
* @license MIT
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/** @license React v17.0.2
|
|
34
|
+
* react.production.min.js
|
|
35
|
+
*
|
|
36
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
37
|
+
*
|
|
38
|
+
* This source code is licensed under the MIT license found in the
|
|
39
|
+
* LICENSE file in the root directory of this source tree.
|
|
40
|
+
*/
|