/*! For license information please see 957.bundle.dd46b7a4ddd3e6a28a17.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([[957],{14957:(e,t,n)=>{"use strict";n.r(t),n.d(t,{AngleTool:()=>Su,AnnotationDisplayTool:()=>co,AnnotationTool:()=>ho,ArrowAnnotateTool:()=>xu,BaseTool:()=>xi,BidirectionalTool:()=>rl,BrushTool:()=>Oa,CONSTANTS:()=>H,CircleROITool:()=>Ll,CircleScissorsTool:()=>qu,CobbAngleTool:()=>Ou,CrosshairsTool:()=>Fs,DragProbeTool:()=>gl,EllipticalROITool:()=>Il,Enums:()=>r,LengthTool:()=>sl,MIPJumpToClickTool:()=>ls,MagnifyTool:()=>js,OrientationMarkerTool:()=>vp,OverlayGridTool:()=>qs,PaintFillTool:()=>ad,PanTool:()=>Ua,PlanarFreehandROITool:()=>_u,PlanarRotateTool:()=>Xa,ProbeTool:()=>pl,RectangleROIStartEndThresholdTool:()=>Qu,RectangleROIThresholdTool:()=>Ju,RectangleROITool:()=>xl,RectangleScissorsTool:()=>Gu,ReferenceCursors:()=>ku,ReferenceLines:()=>zs,ReferenceLinesTool:()=>zs,ScaleOverlayTool:()=>Ru,SegmentationDisplayTool:()=>fo,SphereScissorsTool:()=>Xu,StackScrollMouseWheelTool:()=>Ja,StackScrollTool:()=>Ha,Synchronizer:()=>km,SynchronizerManager:()=>W,ToolGroupManager:()=>z,TrackballRotateTool:()=>Va,Types:()=>K,VolumeRotateMouseWheelTool:()=>ts,WindowLevelTool:()=>za,ZoomTool:()=>Za,addTool:()=>Ke,annotation:()=>x,cancelActiveManipulations:()=>Nm,cursors:()=>E,destroy:()=>dg,drawing:()=>v,init:()=>ug,removeTool:()=>Xe,segmentation:()=>g,state:()=>He,synchronizers:()=>q,utilities:()=>V});var r={};n.r(r),n.d(r,{AnnotationStyleStates:()=>ee,Events:()=>ne,KeyboardBindings:()=>$,MouseBindings:()=>X,SegmentationRepresentations:()=>ie,Swipe:()=>oe,ToolModes:()=>Z});var i={};n.r(i),n.d(i,{checkAndDefineIsLockedProperty:()=>fe,getAnnotationsLocked:()=>de,getAnnotationsLockedCount:()=>pe,isAnnotationLocked:()=>he,setAnnotationLocked:()=>ce,unlockAllAnnotations:()=>ue});var o={};n.r(o),n.d(o,{deselectAnnotation:()=>we,getAnnotationsSelected:()=>xe,getAnnotationsSelectedByToolName:()=>Ce,getAnnotationsSelectedCount:()=>Se,isAnnotationSelected:()=>De,setAnnotationSelected:()=>Ee});var a={};n.r(a),n.d(a,{checkAndDefineIsVisibleProperty:()=>Me,isAnnotationVisible:()=>ke,setAnnotationVisibility:()=>Oe,showAllAnnotations:()=>Pe});var s={};n.r(s),n.d(s,{copyPoints:()=>Wt,copyPointsList:()=>Vt,getDeltaDistance:()=>Ut,getDeltaDistanceBetweenIPoints:()=>jt,getDeltaPoints:()=>Ft,getDeltaRotation:()=>Bt,getMeanPoints:()=>zt,getMeanTouchPoints:()=>Gt});var l={};n.r(l),n.d(l,{triggerSegmentationDataModified:()=>Kn,triggerSegmentationModified:()=>qn,triggerSegmentationRemoved:()=>zn,triggerSegmentationRepresentationModified:()=>Hn,triggerSegmentationRepresentationRemoved:()=>Gn});var c={};n.r(c),n.d(c,{addColorLUT:()=>gr,addSegmentation:()=>Zn,addSegmentationRepresentation:()=>lr,getAllSegmentationRepresentations:()=>er,getColorLUT:()=>mr,getDefaultSegmentationStateManager:()=>$n,getGlobalConfig:()=>cr,getSegmentSpecificRepresentationConfig:()=>ar,getSegmentation:()=>Jn,getSegmentationRepresentationByUID:()=>dr,getSegmentationRepresentationSpecificConfig:()=>or,getSegmentationRepresentations:()=>Qn,getSegmentations:()=>Yn,getToolGroupIdsWithSegmentation:()=>tr,getToolGroupSpecificConfig:()=>nr,removeColorLUT:()=>fr,removeSegmentation:()=>hr,removeSegmentationRepresentation:()=>pr,setGlobalConfig:()=>ur,setSegmentSpecificRepresentationConfig:()=>sr,setSegmentationRepresentationSpecificConfig:()=>ir,setToolGroupSpecificConfig:()=>rr});var u={};n.r(u),n.d(u,{getActiveSegmentationRepresentation:()=>si,setActiveSegmentationRepresentation:()=>li});var d={};n.r(d),n.d(d,{getLockedSegments:()=>di,isSegmentIndexLocked:()=>ci,setSegmentIndexLocked:()=>ui});var h={};n.r(h),n.d(h,{addColorLUT:()=>hi,getColorForSegmentIndex:()=>fi,setColorForSegmentIndex:()=>mi,setColorLUT:()=>pi});var p={};n.r(p),n.d(p,{getSegmentationVisibility:()=>vi,setSegmentVisibility:()=>_i,setSegmentationVisibility:()=>gi,setSegmentsVisibility:()=>yi});var f={};n.r(f),n.d(f,{color:()=>h,getGlobalConfig:()=>vr,getGlobalRepresentationConfig:()=>_r,getSegmentSpecificConfig:()=>Dr,getSegmentationRepresentationSpecificConfig:()=>xr,getToolGroupSpecificConfig:()=>Er,setGlobalConfig:()=>yr,setGlobalRepresentationConfig:()=>br,setSegmentSpecificConfig:()=>Sr,setSegmentationRepresentationSpecificConfig:()=>Cr,setToolGroupSpecificConfig:()=>wr,visibility:()=>p});var m={};n.r(m),n.d(m,{getActiveSegmentIndex:()=>Ei,setActiveSegmentIndex:()=>bi});var g={};n.r(g),n.d(g,{activeSegmentation:()=>u,addSegmentationRepresentations:()=>ai,addSegmentations:()=>oi,config:()=>f,removeSegmentationsFromToolGroup:()=>ni,segmentIndex:()=>m,segmentLocking:()=>d,state:()=>c,triggerSegmentationEvents:()=>l});var v={};n.r(v),n.d(v,{draw:()=>Oi,drawArrow:()=>Ki,drawCircle:()=>Li,drawEllipse:()=>Ri,drawHandles:()=>Fi,drawLine:()=>Ui,drawLinkedTextBox:()=>Hi,drawPolyline:()=>Bi,drawRect:()=>qi,drawTextBox:()=>Wi,setAttributesIfNecessary:()=>ki,setNewAttributesIfValid:()=>Mi});var y={};n.r(y),n.d(y,{getFont:()=>so,getState:()=>ao,style:()=>io});var _={};n.r(_),n.d(_,{extend2DBoundingBoxInViewAxis:()=>Ro,getBoundingBoxAroundShape:()=>Fo});var b={};n.r(b),n.d(b,{getCanvasEllipseCorners:()=>Ko,pointInEllipse:()=>qo});var E={};n.r(E),n.d(E,{CursorNames:()=>xa,CursorSVG:()=>ha,ImageMouseCursor:()=>ia,MouseCursor:()=>ta,SVGMouseCursor:()=>ya,elementCursor:()=>w,registerCursor:()=>fa,setCursorForElement:()=>wa});var w={};n.r(w),n.d(w,{hideElementCursor:()=>Ia,initElementCursor:()=>Da,resetElementCursor:()=>Ta,setElementCursor:()=>Sa});var x={};n.r(x),n.d(x,{FrameOfReferenceSpecificAnnotationManager:()=>We,config:()=>y,locking:()=>i,selection:()=>o,state:()=>G,visibility:()=>a});var C={};n.r(C),n.d(C,{default:()=>os,filterAnnotationsForDisplay:()=>ro,filterAnnotationsWithinSlice:()=>no,getPointInLineOfSightWithCriteria:()=>rs,getWorldWidthAndHeightFromCorners:()=>ns});var D={};n.r(D),n.d(D,{filterViewportsWithFrameOfReferenceUID:()=>us,filterViewportsWithParallelNormals:()=>gs,filterViewportsWithToolEnabled:()=>fs,getViewportIdsWithToolToRender:()=>vs});var S={};n.r(S),n.d(S,{distanceToPoint:()=>Ds,distanceToPointSquared:()=>Cs,intersectLine:()=>Ts});var T={};n.r(T),n.d(T,{getTextBoxCoordsCanvas:()=>Qs});var I={};n.r(I),n.d(I,{distanceToPoint:()=>vl});var A={};n.r(A),n.d(A,{BasicStatsCalculator:()=>_l,Calculator:()=>yl});var N={};n.r(N),n.d(N,{distanceToPoint:()=>Al});var O={};n.r(O),n.d(O,{findClosestPoint:()=>zi,liangBarksyClip:()=>ws});var P={};n.r(P),n.d(P,{addCanvasPointsToArray:()=>ql,calculateAreaOfPoints:()=>Xl,getClosestIntersectionWithPolyline:()=>Ul,getFirstIntersectionWithPolyline:()=>Fl,getSubPixelSpacingAndXYDirections:()=>Gl,pointCanProjectOnLine:()=>Kl,pointsAreWithinCloseContourProximity:()=>Hl});var k={};n.r(k),n.d(k,{BasicStatsCalculator:()=>A,ellipse:()=>b,lineSegment:()=>S,point:()=>N,polyline:()=>P,rectangle:()=>I,vec2:()=>O});var M={};n.r(M),n.d(M,{createLabelmapVolumeForViewport:()=>xp,createMergedLabelmapForIndex:()=>bp,floodFill:()=>nd,getBrushSizeForToolGroup:()=>Dp,getBrushThresholdForToolGroup:()=>Tp,getDefaultRepresentationConfig:()=>wp,isValidRepresentationConfig:()=>Ep,rectangleROIThresholdVolumeByRange:()=>_p,setBrushSizeForToolGroup:()=>Cp,setBrushThresholdForToolGroup:()=>Sp,thresholdSegmentationByRange:()=>Ip,thresholdVolumeByRange:()=>Ra,triggerSegmentationRender:()=>go});var L={};n.r(L),n.d(L,{getOrientationStringLPS:()=>Ap,invertOrientationStringLPS:()=>Np});var R={};n.r(R),n.d(R,{Events:()=>Pp,addToolState:()=>Mp,getToolState:()=>Lp,playClip:()=>Vp,stopClip:()=>Wp});var F={};n.r(F),n.d(F,{default:()=>Kp,interpolateAnnotation:()=>qp});var U={};n.r(U),n.d(U,{getBoundsIJKFromRectangleAnnotations:()=>yp});var B={};n.r(B),n.d(B,{isViewportPreScaled:()=>cl,jumpToSlice:()=>Mo,jumpToWorld:()=>as});var j={};n.r(j),n.d(j,{generateImageFromTimeData:()=>yf,getDataInTime:()=>vf});var V={};n.r(V),n.d(V,{boundingBox:()=>_,calibrateImageSpacing:()=>Oo,cine:()=>R,clip:()=>Ao,debounce:()=>So,drawing:()=>T,dynamicVolume:()=>j,getAnnotationNearPoint:()=>wo,getAnnotationNearPointOnEnabledElement:()=>xo,isObject:()=>Do,jumpToSlice:()=>Mo,math:()=>k,orientation:()=>L,planar:()=>C,planarFreehandROITool:()=>F,pointInShapeCallback:()=>Lo,pointInSurroundingSphereCallback:()=>Bo,rectangleROITool:()=>U,roundNumber:()=>jo,scroll:()=>ko,segmentation:()=>M,stackContextPrefetch:()=>gf,stackPrefetch:()=>cf,throttle:()=>To,touch:()=>s,triggerAnnotationRender:()=>Qi,triggerAnnotationRenderForViewportIds:()=>Po,triggerEvent:()=>Y.triggerEvent,viewport:()=>B,viewportFilters:()=>D});var W={};n.r(W),n.d(W,{createSynchronizer:()=>Mm,destroy:()=>Lm,destroySynchronizer:()=>Um,getAllSynchronizers:()=>Fm,getSynchronizer:()=>Rm,getSynchronizersForViewport:()=>xm});var z={};n.r(z),n.d(z,{createToolGroup:()=>qm,destroy:()=>Xm,destroyToolGroup:()=>Km,getAllToolGroups:()=>Jm,getToolGroup:()=>$m,getToolGroupForViewport:()=>Cm,getToolGroupsWithToolName:()=>Zm});var G={};n.r(G),n.d(G,{addAnnotation:()=>ig,getAnnotation:()=>sg,getAnnotationManager:()=>eg,getAnnotations:()=>rg,getNumberOfAnnotations:()=>og,removeAllAnnotations:()=>lg,removeAnnotation:()=>ag,resetAnnotationManager:()=>ng,setAnnotationManager:()=>tg});var H={};n.r(H),n.d(H,{COLOR_LUT:()=>Mn});var q={};n.r(q),n.d(q,{createCameraPositionSynchronizer:()=>gg,createStackImageSynchronizer:()=>Dg,createVOISynchronizer:()=>yg,createZoomPanSynchronizer:()=>Eg});var K={};n.r(K);var X,$,J,Y=n(3743);!function(e){e[e.Primary=1]="Primary",e[e.Secondary=2]="Secondary",e[e.Primary_And_Secondary=3]="Primary_And_Secondary",e[e.Auxiliary=4]="Auxiliary",e[e.Primary_And_Auxiliary=5]="Primary_And_Auxiliary",e[e.Secondary_And_Auxiliary=6]="Secondary_And_Auxiliary",e[e.Primary_And_Secondary_And_Auxiliary=7]="Primary_And_Secondary_And_Auxiliary",e[e.Fourth_Button=8]="Fourth_Button",e[e.Fifth_Button=16]="Fifth_Button"}(X||(X={})),function(e){e[e.Shift=16]="Shift",e[e.Ctrl=17]="Ctrl",e[e.Alt=18]="Alt",e[e.Meta=91]="Meta",e[e.ShiftCtrl=1617]="ShiftCtrl",e[e.ShiftAlt=1618]="ShiftAlt",e[e.ShiftMeta=1691]="ShiftMeta",e[e.CtrlAlt=1718]="CtrlAlt",e[e.CtrlMeta=1791]="CtrlMeta",e[e.AltMeta=1891]="AltMeta"}($||($={})),function(e){e.Active="Active",e.Passive="Passive",e.Enabled="Enabled",e.Disabled="Disabled"}(J||(J={}));const Z=J;var Q;!function(e){e.Default="",e.Highlighted="Highlighted",e.Selected="Selected",e.Locked="Locked"}(Q||(Q={}));const ee=Q;var te;!function(e){e.TOOL_ACTIVATED="CORNERSTONE_TOOLS_TOOL_ACTIVATED",e.ANNOTATION_ADDED="CORNERSTONE_TOOLS_ANNOTATION_ADDED",e.ANNOTATION_COMPLETED="CORNERSTONE_TOOLS_ANNOTATION_COMPLETED",e.ANNOTATION_MODIFIED="CORNERSTONE_TOOLS_ANNOTATION_MODIFIED",e.ANNOTATION_REMOVED="CORNERSTONE_TOOLS_ANNOTATION_REMOVED",e.ANNOTATION_SELECTION_CHANGE="CORNERSTONE_TOOLS_ANNOTATION_SELECTION_CHANGE",e.ANNOTATION_LOCK_CHANGE="CORNERSTONE_TOOLS_ANNOTATION_LOCK_CHANGE",e.ANNOTATION_VISIBILITY_CHANGE="CORNERSTONE_TOOLS_ANNOTATION_VISIBILITY_CHANGE",e.ANNOTATION_RENDERED="CORNERSTONE_TOOLS_ANNOTATION_RENDERED",e.SEGMENTATION_MODIFIED="CORNERSTONE_TOOLS_SEGMENTATION_MODIFIED",e.SEGMENTATION_RENDERED="CORNERSTONE_TOOLS_SEGMENTATION_RENDERED",e.SEGMENTATION_REPRESENTATION_MODIFIED="CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_MODIFIED",e.SEGMENTATION_REMOVED="CORNERSTONE_TOOLS_SEGMENTATION_REMOVED",e.SEGMENTATION_REPRESENTATION_REMOVED="CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_REMOVED",e.SEGMENTATION_DATA_MODIFIED="CORNERSTONE_TOOLS_SEGMENTATION_DATA_MODIFIED",e.KEY_DOWN="CORNERSTONE_TOOLS_KEY_DOWN",e.KEY_UP="CORNERSTONE_TOOLS_KEY_UP",e.MOUSE_DOWN="CORNERSTONE_TOOLS_MOUSE_DOWN",e.MOUSE_UP="CORNERSTONE_TOOLS_MOUSE_UP",e.MOUSE_DOWN_ACTIVATE="CORNERSTONE_TOOLS_MOUSE_DOWN_ACTIVATE",e.MOUSE_DRAG="CORNERSTONE_TOOLS_MOUSE_DRAG",e.MOUSE_MOVE="CORNERSTONE_TOOLS_MOUSE_MOVE",e.MOUSE_CLICK="CORNERSTONE_TOOLS_MOUSE_CLICK",e.MOUSE_DOUBLE_CLICK="CORNERSTONE_TOOLS_MOUSE_DOUBLE_CLICK",e.MOUSE_WHEEL="CORNERSTONE_TOOLS_MOUSE_WHEEL",e.TOUCH_START="CORNERSTONE_TOOLS_TOUCH_START",e.TOUCH_START_ACTIVATE="CORNERSTONE_TOOLS_TOUCH_START_ACTIVATE",e.TOUCH_PRESS="CORNERSTONE_TOOLS_TOUCH_PRESS",e.TOUCH_DRAG="CORNERSTONE_TOOLS_TOUCH_DRAG",e.TOUCH_END="CORNERSTONE_TOOLS_TOUCH_END",e.TOUCH_TAP="CORNERSTONE_TOOLS_TAP",e.TOUCH_SWIPE="CORNERSTONE_TOOLS_SWIPE"}(te||(te={}));const ne=te;var re;!function(e){e.Labelmap="LABELMAP",e.Contour="CONTOUR"}(re||(re={}));const ie=re;var oe;!function(e){e.UP="UP",e.DOWN="DOWN",e.LEFT="LEFT",e.RIGHT="RIGHT"}(oe||(oe={}));var ae=n(11677),se=n.n(ae);const le=new Set;function ce(e,t=!0){const n=me();e&&(t?function(e,t,n){t.has(e)||(t.add(e),n.added.push(e))}(e,le,n):ge(e,le,n)),ve(n,le)}function ue(){const e=me();!function(e,t){e.forEach((n=>{ge(n,e,t)}))}(le,e),ve(e,le)}function de(){return Array.from(le)}function he(e){return le.has(e)}function pe(){return le.size}function fe(e){if(e){const t=!!e.isLocked;(function(e){const t=Object.getOwnPropertyDescriptor(e,"isLocked");if(t)return t.configurable&&(t.set!==ye||t.get!==_e);return Object.isExtensible(e)})(e)&&Object.defineProperty(e,"isLocked",{configurable:!1,enumerable:!0,set:ye,get:_e}),ce(e,t)}}function me(){return Object.freeze({added:[],removed:[],locked:[]})}function ge(e,t,n){t.delete(e)&&n.removed.push(e)}function ve(e,t){(e.added.length>0||e.removed.length>0)&&(t.forEach((t=>{e.locked.push(t)})),(0,Y.triggerEvent)(Y.eventTarget,ne.ANNOTATION_LOCK_CHANGE,e))}function ye(e){ce(this,e)}function _e(){return he(this)}const be=new Set;function Ee(e,t=!0,n=!1){t?function(e,t=!1){const n=Te();t||Ie(be,n);e&&!be.has(e)&&(be.add(e),n.added.push(e));Ae(n,be)}(e,n):we(e)}function we(e){const t=Te();e?be.delete(e)&&t.removed.push(e):Ie(be,t),Ae(t,be)}function xe(){return Array.from(be)}function Ce(e){return xe().filter((t=>sg(t).metadata.toolName===e))}function De(e){return be.has(e)}function Se(){return be.size}function Te(){return Object.freeze({added:[],removed:[],selection:[]})}function Ie(e,t){e.forEach((n=>{e.delete(n)&&t.removed.push(n)}))}function Ae(e,t){(e.added.length>0||e.removed.length>0)&&(t.forEach((t=>{e.selection.push(t)})),(0,Y.triggerEvent)(Y.eventTarget,ne.ANNOTATION_SELECTION_CHANGE,e))}const Ne=new Set;function Oe(e,t=!0){const n=Le();e&&(t?Re(e,Ne,n):function(e,t,n){t.has(e)||(t.add(e),De(e)&&we(e),n.lastHidden.push(e))}(e,Ne,n)),Fe(n)}function Pe(){const e=Le();Ne.forEach((t=>{Re(t,Ne,e)})),Fe(e)}function ke(e){if(sg(e))return!Ne.has(e)}function Me(e){if(e){const t=e.isVisible??!0;(function(e){const t=Object.getOwnPropertyDescriptor(e,"isVisible");if(t)return t.configurable&&(t.set!==Ue||t.get!==Be);return Object.isExtensible(e)})(e)&&Object.defineProperty(e,"isVisible",{configurable:!1,enumerable:!0,set:Ue,get:Be}),Oe(e.annotationUID,t)}}function Le(){return Object.freeze({lastVisible:[],lastHidden:[],hidden:[]})}function Re(e,t,n){t.delete(e)&&n.lastVisible.push(e)}function Fe(e){(e.lastHidden.length>0||e.lastVisible.length>0)&&(Ne.forEach((t=>{e.hidden.push(t)})),(0,Y.triggerEvent)(Y.eventTarget,ne.ANNOTATION_VISIBILITY_CHANGE,e))}function Ue(e){Oe(this.annotationUID,e)}function Be(){return ke(this.annotationUID)}class je{constructor(e){this.getGroupKey=e=>{if("string"==typeof e)return e;const t=e,n=(0,Y.getEnabledElement)(t);if(!n)throw new Error("Element not enabled, you must have an enabled element if you are not providing a FrameOfReferenceUID");return n.FrameOfReferenceUID},this._imageVolumeModifiedHandler=e=>{const t=e.detail,{FrameOfReferenceUID:n}=t,r=this.annotations[n];r&&Object.keys(r).forEach((e=>{r[e].forEach((e=>{void 0!==e.invalidated&&(e.invalidated=!0)}))}))},this.getFramesOfReference=()=>Object.keys(this.annotations),this.getAnnotations=(e,t)=>{const n=this.annotations;return n[e]?t?n[e][t]:n[e]:[]},this.getAnnotation=e=>{const t=this.annotations;for(const n in t){const r=t[n];for(const t in r){const n=r[t];for(const t of n)if(e===t.annotationUID)return t}}},this.getNumberOfAnnotations=(e,t)=>{const n=this.getAnnotations(e,t);if(!n.length)return 0;if(t)return n.length;let r=0;for(const e in n)r+=n[e].length;return r},this.addAnnotation=(e,t)=>{const{metadata:n}=e,{FrameOfReferenceUID:r,toolName:i}=n;t=t||r;const o=this.annotations;let a=o[t];a||(o[t]={},a=o[t]);let s=a[i];s||(a[i]=[],s=a[i]),s.push(e),fe(e),Me(e)},this.removeAnnotation=e=>{const{annotations:t}=this;for(const n in t){const r=t[n];for(const t in r){const n=r[t],i=n.findIndex((t=>t.annotationUID===e));-1!==i&&(n.splice(i,1),0===n.length&&delete r[t])}0===Object.keys(r).length&&delete t[n]}},this.removeAnnotations=(e,t)=>{const n=this.annotations;n[e]&&(t?delete n[e][t]:delete n[e])},this.saveAnnotations=(e,t)=>{const n=this.annotations;if(e&&t){const r=n[e];if(!r)return;const i=r[t];return se()(i)}if(e){const t=n[e];return se()(t)}return se()(n)},this.restoreAnnotations=(e,t,n)=>{const r=this.annotations;if(t&&n){let i=r[t];i||(r[t]={},i=r[t]),i[n]=e}else t?r[t]=e:this.annotations=se()(e)},this.getNumberOfAllAnnotations=()=>{let e=0;const t=this.annotations;for(const n in t){const r=t[n];for(const t in r){e+=r[t].length}}return e},this.removeAllAnnotations=()=>{this.annotations={}},e||(e=Y.utilities.uuidv4()),this.annotations={},this.uid=e,Y.eventTarget.addEventListener(Y.Enums.Events.IMAGE_VOLUME_MODIFIED,this._imageVolumeModifiedHandler)}}const Ve=new je("DEFAULT"),We=je;let ze={};const Ge={isInteractingWithTool:!1,isMultiPartToolActive:!1,tools:{},toolGroups:[],synchronizers:[],svgNodeCache:ze,enabledElements:[],handleRadius:6};let He={isInteractingWithTool:!1,isMultiPartToolActive:!1,tools:{},toolGroups:[],synchronizers:[],svgNodeCache:ze,enabledElements:[],handleRadius:6};function qe(){ze={},He=se()(Ge)}function Ke(e){const t=e.toolName,n=void 0!==He.tools[t];if(!t)throw new Error(`No Tool Found for the ToolClass ${e.name}`);if(n)throw new Error(`${t} has already been added globally`);He.tools[t]={toolClass:e}}function Xe(e){const t=e.toolName;if(!t)throw new Error(`No tool found for: ${e.name}`);if(void 0===!He.tools[t])throw new Error(`${t} cannot be removed because it has not been added`);delete He.tools[t]}function $e(e,t){const n=t||e.currentTarget,{viewport:r}=(0,Y.getEnabledElement)(n),i=function(e){return[e.clientX,e.clientY]}(e),o=function(e){return[e.pageX,e.pageY]}(e),a=function(e,t){const n=e.getBoundingClientRect();return[t[0]-n.left-window.pageXOffset,t[1]-n.top-window.pageYOffset]}(n,o);return{page:o,client:i,canvas:a,world:r.canvasToWorld(a)}}const Je=function(e){const t=e.currentTarget,{viewportId:n,renderingEngineId:r}=(0,Y.getEnabledElement)(t),i=$e(e,t),o={event:e,eventName:ne.MOUSE_DOUBLE_CLICK,viewportId:n,renderingEngineId:r,camera:{},element:t,startPoints:i,lastPoints:i,currentPoints:i,deltaPoints:{page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0]}};!(0,Y.triggerEvent)(t,ne.MOUSE_DOUBLE_CLICK,o)&&(e.stopImmediatePropagation(),e.preventDefault())},Ye=ne.MOUSE_MOVE;const Ze=function(e){const t=e.currentTarget,n=(0,Y.getEnabledElement)(t),{renderingEngineId:r,viewportId:i}=n,o={renderingEngineId:r,viewportId:i,camera:{},element:t,currentPoints:$e(e),eventName:Ye,event:e};(0,Y.triggerEvent)(t,Ye,o)},{MOUSE_DOWN:Qe,MOUSE_DOWN_ACTIVATE:et,MOUSE_CLICK:tt,MOUSE_UP:nt,MOUSE_DRAG:rt}=ne,it=3,ot={mouseButton:void 0,element:null,renderingEngineId:void 0,viewportId:void 0,isClickEvent:!0,clickDelay:200,preventClickTimeout:null,startPoints:{page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0]},lastPoints:{page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0]}};let at={mouseButton:void 0,renderingEngineId:void 0,viewportId:void 0,isClickEvent:!0,clickDelay:200,element:null,preventClickTimeout:null,startPoints:{page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0]},lastPoints:{page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0]}};const st={doubleClickTimeout:null,mouseDownEvent:null,mouseUpEvent:null,ignoreDoubleClick:!1};function lt(e){const t=$e(e,at.element),n=vt(at.element,at.lastPoints),r=yt(t,n);if(st.doubleClickTimeout){if(!dt(r.canvas))return;pt()}const i={event:e,eventName:rt,mouseButton:at.mouseButton,renderingEngineId:at.renderingEngineId,viewportId:at.viewportId,camera:{},element:at.element,startPoints:gt(at.startPoints),lastPoints:gt(n),currentPoints:t,deltaPoints:r};(0,Y.triggerEvent)(at.element,rt,i),at.lastPoints=gt(t)}function ct(e){if(clearTimeout(at.preventClickTimeout),st.doubleClickTimeout)st.mouseUpEvent?mt():(st.mouseUpEvent=e,at.element.addEventListener("mousemove",ut));else{const t=at.isClickEvent?tt:nt,n=$e(e,at.element),r=yt(n,at.lastPoints),i={event:e,eventName:t,mouseButton:at.mouseButton,element:at.element,renderingEngineId:at.renderingEngineId,viewportId:at.viewportId,camera:{},startPoints:gt(at.startPoints),lastPoints:gt(at.lastPoints),currentPoints:n,deltaPoints:r};(0,Y.triggerEvent)(i.element,t,i),mt()}document.removeEventListener("mousemove",lt)}function ut(e){dt(yt($e(e,at.element),vt(at.element,at.lastPoints)).canvas)&&(pt(),Ze(e))}function dt(e){return Math.abs(e[0])+Math.abs(e[1])>it}function ht(){at.isClickEvent=!1}function pt(){st.ignoreDoubleClick=!0;const e=st.mouseDownEvent,t=st.mouseUpEvent;ft(),function(e){const t=yt(at.startPoints,at.startPoints),n={event:e,eventName:Qe,element:at.element,mouseButton:at.mouseButton,renderingEngineId:at.renderingEngineId,viewportId:at.viewportId,camera:{},startPoints:at.startPoints,lastPoints:at.startPoints,currentPoints:at.startPoints,deltaPoints:t};at.lastPoints=gt(n.lastPoints),(0,Y.triggerEvent)(n.element,Qe,n)&&(0,Y.triggerEvent)(n.element,et,n)}(e),t&&ct(t)}function ft(){st.doubleClickTimeout&&(clearTimeout(st.doubleClickTimeout),st.doubleClickTimeout=null),st.mouseDownEvent=null,st.mouseUpEvent=null}function mt(){document.removeEventListener("mouseup",ct),at.element?.removeEventListener("mousemove",ut),at.element?.addEventListener("mousemove",Ze),ft(),at=JSON.parse(JSON.stringify(ot))}function gt(e){return JSON.parse(JSON.stringify(e))}function vt(e,t){const{viewport:n}=(0,Y.getEnabledElement)(e),r=n.canvasToWorld(t.canvas);return{page:t.page,client:t.client,canvas:t.canvas,world:r}}function yt(e,t){return{page:_t(e.page,t.page),client:_t(e.client,t.client),canvas:_t(e.canvas,t.canvas),world:(n=e.world,r=t.world,[n[0]-r[0],n[1]-r[1],n[2]-r[2]])};var n,r}function _t(e,t){return[e[0]-t[0],e[1]-t[1]]}function bt(e){st.ignoreDoubleClick?(st.ignoreDoubleClick=!1,e.stopImmediatePropagation(),e.preventDefault()):mt()}const Et=function(e){if(st.doubleClickTimeout){if(e.buttons===st.mouseDownEvent.buttons)return;return st.mouseDownEvent=e,void pt()}st.doubleClickTimeout=setTimeout(pt,1===e.buttons?400:150),st.mouseDownEvent=e,st.ignoreDoubleClick=!1,at.element=e.currentTarget,at.mouseButton=e.buttons;const t=(0,Y.getEnabledElement)(at.element),{renderingEngineId:n,viewportId:r}=t;at.renderingEngineId=n,at.viewportId=r,at.preventClickTimeout=setTimeout(ht,at.clickDelay),at.element.removeEventListener("mousemove",Ze);const i=$e(e,at.element);at.startPoints=gt(i),at.lastPoints=gt(i),document.addEventListener("mouseup",ct),document.addEventListener("mousemove",lt)};function wt(e){e.removeEventListener("dblclick",Je),e.removeEventListener("mousedown",Et),e.removeEventListener("mousemove",Ze),e.removeEventListener("dblclick",bt,{capture:!0})}const xt={enable:function(e){wt(e),e.addEventListener("dblclick",Je),e.addEventListener("mousedown",Et),e.addEventListener("mousemove",Ze),e.addEventListener("dblclick",bt,{capture:!0})},disable:wt},Ct={mouse:0,touch:1};let Dt,St;function Tt(e,t){const n=Date.now();if(e!==Dt){if(n-St<=2e3)return t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),!1;Dt=e}St=n}const It=Tt.bind(null,Ct.mouse),At=Tt.bind(null,Ct.touch);function Nt(e,t,n){const r=n?It:At;t.forEach((function(t){e.addEventListener(t,r,{passive:!1})}))}function Ot(e,t,n){const r=n?It:At;t.forEach((function(t){e.removeEventListener(t,r)}))}const Pt=["mousedown","mouseup","mousemove"],kt=["touchstart","touchend"];function Mt(e){Ot(e,Pt,Ct.mouse),Ot(e,kt,Ct.touch)}const Lt={enable:function(e){Mt(e),Nt(e,Pt,Ct.mouse),Nt(e,kt,Ct.touch)},disable:Mt};function Rt(e,t){const n=t||e.currentTarget,r="touchend"===e.type?e.changedTouches:e.touches;return Object.keys(r).map((e=>{const t=function(e){return[e.clientX,e.clientY]}(r[e]),i=function(e){return[e.pageX,e.pageY]}(r[e]),o=function(e,t){const n=e.getBoundingClientRect();return[t[0]-n.left-window.pageXOffset,t[1]-n.top-window.pageYOffset]}(n,i),{viewport:a}=(0,Y.getEnabledElement)(n);return{page:i,client:t,canvas:o,world:a.canvasToWorld(o),touch:{identifier:e,radiusX:r[e].radiusX,radiusY:r[e].radiusY,force:r[e].force,rotationAngle:r[e].rotationAngle}}}))}function Ft(e,t){const n=zt(e),r=zt(t);return{page:Ht(n.page,r.page),client:Ht(n.client,r.client),canvas:Ht(n.canvas,r.canvas),world:(i=n.world,o=r.world,[i[0]-o[0],i[1]-o[1],i[2]-o[2]])};var i,o}function Ut(e,t){const n=zt(e),r=zt(t);return{page:Kt(n.page,r.page),client:Kt(n.client,r.client),canvas:Kt(n.canvas,r.canvas),world:Xt(n.world,r.world)}}function Bt(e,t){}function jt(e,t){const n=qt(e),r=qt(t);return{page:n.page-r.page,client:n.client-r.client,canvas:n.canvas-r.canvas,world:n.world-r.world}}function Vt(e){return JSON.parse(JSON.stringify(e))}function Wt(e){return JSON.parse(JSON.stringify(e))}function zt(e){return e.reduce(((t,n)=>({page:[t.page[0]+n.page[0]/e.length,t.page[1]+n.page[1]/e.length],client:[t.client[0]+n.client[0]/e.length,t.client[1]+n.client[1]/e.length],canvas:[t.canvas[0]+n.canvas[0]/e.length,t.canvas[1]+n.canvas[1]/e.length],world:[t.world[0]+n.world[0]/e.length,t.world[1]+n.world[1]/e.length,t.world[2]+n.world[2]/e.length]})),{page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0]})}function Gt(e){return e.reduce(((t,n)=>({page:[t.page[0]+n.page[0]/e.length,t.page[1]+n.page[1]/e.length],client:[t.client[0]+n.client[0]/e.length,t.client[1]+n.client[1]/e.length],canvas:[t.canvas[0]+n.canvas[0]/e.length,t.canvas[1]+n.canvas[1]/e.length],world:[t.world[0]+n.world[0]/e.length,t.world[1]+n.world[1]/e.length,t.world[2]+n.world[2]/e.length],touch:{identifier:null,radiusX:t.touch.radiusX+n.touch.radiusX/e.length,radiusY:t.touch.radiusY+n.touch.radiusY/e.length,force:t.touch.force+n.touch.force/e.length,rotationAngle:t.touch.rotationAngle+n.touch.rotationAngle/e.length}})),{page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0],touch:{identifier:null,radiusX:0,radiusY:0,force:0,rotationAngle:0}})}function Ht(e,t){return[e[0]-t[0],e[1]-t[1]]}function qt(e){const t=[];for(let n=0;n({page:e.page+n.page/t.length,client:e.client+n.client/t.length,canvas:e.canvas+n.canvas/t.length,world:e.world+n.world/t.length})),{page:0,client:0,canvas:0,world:0})}function Kt(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2))}function Xt(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2))}const $t=Y.Settings.getRuntimeSettings(),{TOUCH_START:Jt,TOUCH_START_ACTIVATE:Yt,TOUCH_PRESS:Zt,TOUCH_DRAG:Qt,TOUCH_END:en,TOUCH_TAP:tn,TOUCH_SWIPE:nn}=ne,rn={page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0]},on={page:0,client:0,canvas:0,world:0},an={renderingEngineId:void 0,viewportId:void 0,element:null,startPointsList:[{...rn,touch:null}],lastPointsList:[{...rn,touch:null}],isTouchStart:!1,startTime:null,pressTimeout:null,pressDelay:700,pressMaxDistance:5,accumulatedDistance:on,swipeDistanceThreshold:48,swiped:!1,swipeToleranceMs:300},sn={renderingEngineId:void 0,viewportId:void 0,element:null,startPointsList:[{...rn,touch:null}],taps:0,tapTimeout:null,tapMaxDistance:24,tapToleranceMs:300};let ln=JSON.parse(JSON.stringify(an)),cn=JSON.parse(JSON.stringify(sn));function un(e,t,n){return $t.get("debug")&&("CORNERSTONE_TOOLS_TOUCH_DRAG"===t?console.debug(t):console.debug(t,n)),(0,Y.triggerEvent)(e,t,n)}function dn(e){const t=Rt(e,ln.element),n=pn(ln.element,ln.lastPointsList),r=t.length===n.length?Ft(t,n):rn,i=t.length===n.length?jt(t,n):on,o=t.length===n.length?Ut(t,ln.lastPointsList):on;ln.accumulatedDistance={page:ln.accumulatedDistance.page+o.page,client:ln.accumulatedDistance.client+o.client,canvas:ln.accumulatedDistance.canvas+o.canvas,world:ln.accumulatedDistance.world+o.world};const a={event:e,eventName:Qt,renderingEngineId:ln.renderingEngineId,viewportId:ln.viewportId,camera:{},element:ln.element,startPoints:Gt(ln.startPointsList),lastPoints:Gt(n),currentPoints:Gt(t),startPointsList:Vt(ln.startPointsList),lastPointsList:Vt(n),currentPointsList:t,deltaPoints:r,deltaDistance:i};un(ln.element,Qt,a),function(e,t){const n=(new Date).getTime(),r=ln.startTime.getTime();if(ln.swiped||n-r>ln.swipeToleranceMs)return;const[i,o]=t.canvas,a={event:e,eventName:nn,renderingEngineId:ln.renderingEngineId,viewportId:ln.viewportId,camera:{},element:ln.element,swipe:null};Math.abs(i)>ln.swipeDistanceThreshold&&(a.swipe=i>0?oe.RIGHT:oe.LEFT,un(a.element,nn,a),ln.swiped=!0);Math.abs(o)>ln.swipeDistanceThreshold&&(a.swipe=o>0?oe.DOWN:oe.UP,un(a.element,nn,a),ln.swiped=!0)}(e,r),ln.lastPointsList=Vt(t)}function hn(e){clearTimeout(ln.pressTimeout);const t=Rt(e,ln.element),n=pn(ln.element,ln.lastPointsList),r=t.length===n.length?Ft(t,n):Ft(t,t),i=t.length===n.length?jt(t,n):jt(t,t),o={event:e,eventName:en,element:ln.element,renderingEngineId:ln.renderingEngineId,viewportId:ln.viewportId,camera:{},startPointsList:Vt(ln.startPointsList),lastPointsList:Vt(n),currentPointsList:t,startPoints:Gt(ln.startPointsList),lastPoints:Gt(n),currentPoints:Gt(t),deltaPoints:r,deltaDistance:i};un(o.element,en,o),function(e){const t=(new Date).getTime(),n=ln.startTime.getTime();if(t-n>cn.tapToleranceMs)return;0===cn.taps&&(cn.element=ln.element,cn.renderingEngineId=ln.renderingEngineId,cn.viewportId=ln.viewportId,cn.startPointsList=ln.startPointsList);if(cn.taps>0&&(cn.element!=ln.element||cn.renderingEngineId!=ln.renderingEngineId||cn.viewportId!=ln.viewportId))return;const r=Rt(e,cn.element),i=Ut(r,cn.startPointsList).canvas;if(i>cn.tapMaxDistance)return;clearTimeout(cn.tapTimeout),cn.taps+=1,cn.tapTimeout=setTimeout((()=>{const t={event:e,eventName:tn,element:cn.element,renderingEngineId:cn.renderingEngineId,viewportId:cn.viewportId,camera:{},currentPointsList:r,currentPoints:Gt(r),taps:cn.taps};un(t.element,tn,t),cn=JSON.parse(JSON.stringify(sn))}),cn.tapToleranceMs)}(e),ln=JSON.parse(JSON.stringify(an)),document.removeEventListener("touchmove",dn),document.removeEventListener("touchend",hn)}function pn(e,t){const{viewport:n}=(0,Y.getEnabledElement)(e);return t.map((e=>{const t=n.canvasToWorld(e.canvas);return{page:e.page,client:e.client,canvas:e.canvas,world:t,touch:e.touch}}))}const fn=function(e){ln.element=e.currentTarget;const t=(0,Y.getEnabledElement)(ln.element),{renderingEngineId:n,viewportId:r}=t;ln.renderingEngineId=n,ln.viewportId=r,ln.isTouchStart||(clearTimeout(ln.pressTimeout),ln.pressTimeout=setTimeout((()=>function(e){if(ln.accumulatedDistance.canvas>ln.pressMaxDistance)return;const t={event:e,eventName:Zt,renderingEngineId:ln.renderingEngineId,viewportId:ln.viewportId,camera:{},element:ln.element,startPointsList:Vt(ln.startPointsList),lastPointsList:Vt(ln.lastPointsList),startPoints:Wt(Gt(ln.startPointsList)),lastPoints:Wt(Gt(ln.lastPointsList))};un(t.element,Zt,t)}(e)),ln.pressDelay),function(e){ln.isTouchStart=!0,ln.startTime=new Date;const t=Rt(e,ln.element),n=Gt(t),r=rn,i=on,o={event:e,eventName:Jt,element:ln.element,renderingEngineId:ln.renderingEngineId,viewportId:ln.viewportId,camera:{},startPointsList:t,lastPointsList:t,currentPointsList:t,startPoints:n,lastPoints:n,currentPoints:n,deltaPoints:r,deltaDistance:i};ln.startPointsList=Vt(o.startPointsList),ln.lastPointsList=Vt(o.lastPointsList);un(o.element,Jt,o)&&un(o.element,Yt,o)}(e),document.addEventListener("touchmove",dn),document.addEventListener("touchend",hn))};function mn(e){Lt.disable(e),e.removeEventListener("touchstart",fn)}const gn={enable:function(e){mn(e),Lt.enable(e),e.addEventListener("touchstart",fn,{passive:!1})},disable:mn},vn=10,yn=40,_n=800;const bn=function(e){const t=e.currentTarget,n=(0,Y.getEnabledElement)(t),{renderingEngineId:r,viewportId:i}=n;if(e.deltaY>-1&&e.deltaY<1)return;e.preventDefault();const{spinX:o,spinY:a,pixelX:s,pixelY:l}=function(e){let t=0,n=0,r=0,i=0;return"detail"in e&&(n=e.detail),"wheelDelta"in e&&(n=-e.wheelDelta/120),"wheelDeltaY"in e&&(n=-e.wheelDeltaY/120),"wheelDeltaX"in e&&(t=-e.wheelDeltaX/120),r=t*vn,i=n*vn,"deltaY"in e&&(i=e.deltaY),"deltaX"in e&&(r=e.deltaX),(r||i)&&e.deltaMode&&(1===e.deltaMode?(r*=yn,i*=yn):(r*=_n,i*=_n)),r&&!t&&(t=r<1?-1:1),i&&!n&&(n=i<1?-1:1),{spinX:t,spinY:n,pixelX:r,pixelY:i}}(e),c=a<0?-1:1,u={event:e,eventName:ne.MOUSE_WHEEL,renderingEngineId:r,viewportId:i,element:t,camera:{},detail:e,wheel:{spinX:o,spinY:a,pixelX:s,pixelY:l,direction:c},points:$e(e)};(0,Y.triggerEvent)(t,ne.MOUSE_WHEEL,u)};function En(e){e.removeEventListener("wheel",bn)}const wn={enable:function(e){En(e),e.addEventListener("wheel",bn,{passive:!1})},disable:En},xn={renderingEngineId:void 0,viewportId:void 0,key:void 0,keyCode:void 0,element:null};let Cn={renderingEngineId:void 0,viewportId:void 0,key:void 0,keyCode:void 0,element:null};function Dn(e){Cn.element=e.currentTarget;const t=(0,Y.getEnabledElement)(Cn.element),{renderingEngineId:n,viewportId:r}=t;Cn.renderingEngineId=n,Cn.viewportId=r,Cn.key=e.key,Cn.keyCode=e.keyCode,e.preventDefault();const i={renderingEngineId:Cn.renderingEngineId,viewportId:Cn.viewportId,element:Cn.element,key:Cn.key,keyCode:Cn.keyCode};(0,Y.triggerEvent)(i.element,ne.KEY_DOWN,i),document.addEventListener("keyup",Tn),document.addEventListener("visibilitychange",Sn),Cn.element.removeEventListener("keydown",Dn)}function Sn(){document.removeEventListener("visibilitychange",Sn),"hidden"===document.visibilityState&&In()}function Tn(e){const t={renderingEngineId:Cn.renderingEngineId,viewportId:Cn.viewportId,element:Cn.element,key:Cn.key,keyCode:Cn.keyCode};document.removeEventListener("keyup",Tn),document.removeEventListener("visibilitychange",Sn),Cn.element.addEventListener("keydown",Dn),Cn=se()(xn),(0,Y.triggerEvent)(t.element,ne.KEY_UP,t)}function In(){Cn.keyCode=void 0}const An=Dn;function Nn(e){e.removeEventListener("keydown",An)}const On={enable:function(e){Nn(e),e.addEventListener("keydown",An)},disable:Nn,getModifierKey:function(){return Cn.keyCode}};var Pn=n(44031),kn=n(95548);const Mn=[[0,0,0,0],[221,84,84,255],[77,228,121,255],[166,70,235,255],[189,180,116,255],[109,182,196,255],[204,101,157,255],[123,211,94,255],[93,87,218,255],[225,128,80,255],[73,232,172,255],[181,119,186,255],[176,193,112,255],[105,153,200,255],[208,97,120,255],[90,215,101,255],[135,83,222,255],[229,178,76,255],[122,183,181,255],[190,115,171,255],[149,197,108,255],[100,118,205,255],[212,108,93,255],[86,219,141,255],[183,79,226,255],[233,233,72,255],[118,167,187,255],[194,111,146,255],[116,201,104,255],[115,96,209,255],[216,147,89,255],[82,223,188,255],[230,75,224,255],[163,184,121,255],[114,143,191,255],[198,107,114,255],[99,206,122,255],[153,92,213,255],[220,192,85,255],[78,215,227,255],[234,71,173,255],[141,188,117,255],[110,113,195,255],[202,128,103,255],[95,210,157,255],[195,88,217,255],[206,224,81,255],[74,166,231,255],[185,120,139,255],[113,192,113,255],[133,106,199,255],[207,162,98,255],[91,214,198,255],[221,84,198,255],[159,228,77,255],[70,111,235,255],[189,119,116,255],[109,196,138,255],[165,101,204,255],[211,201,94,255],[87,191,218,255],[225,80,153,255],[106,232,73,255],[124,119,186,255],[193,142,112,255],[105,200,168,255],[203,97,208,255],[184,215,90,255],[83,147,222,255],[229,76,101,255],[122,183,130,255],[146,115,190,255],[197,171,108,255],[100,205,205,255],[212,93,177,255],[141,219,86,255],[79,97,226,255],[233,99,72,255],[118,187,150,255],[173,111,194,255],[197,201,104,255],[96,171,209,255],[216,89,137,255],[94,223,82,255],[107,75,230,255],[184,153,121,255],[114,191,175,255],[198,107,191,255],[166,206,99,255],[92,132,213,255],[220,85,91,255],[78,227,115,255],[159,71,234,255],[188,176,117,255],[110,185,195,255],[202,103,161,255],[129,210,95,255],[88,88,217,255],[224,123,81,255],[74,231,166,255],[177,120,185,255],[179,192,113,255],[106,156,199,255],[207,98,125,255],[91,214,96,255],[130,84,221,255],[228,171,77,255],[70,235,221,255],[189,116,174,255],[153,196,109,255],[101,123,204,255],[211,104,94,255],[87,218,136,255],[177,80,225,255],[232,225,73,255],[119,169,186,255],[193,112,149,255],[121,200,105,255],[111,97,208,255],[215,142,90,255],[83,222,181,255],[229,76,229,255],[165,183,122,255],[115,146,190,255],[197,108,119,255],[100,205,118,255],[148,93,212,255],[219,186,86,255],[79,220,226,255],[233,72,179,255],[144,187,118,255],[111,118,194,255],[201,124,104,255],[96,209,153,255],[189,89,216,255],[211,223,82,255],[75,172,230,255],[184,121,142,255],[117,191,114,255],[130,107,198,255],[206,157,99,255],[92,213,193,255],[220,85,203,255],[165,227,78,255],[71,118,234,255],[188,117,117,255],[110,195,135,255],[161,103,202,255],[210,195,95,255],[88,195,217,255],[224,81,158,255],[113,231,74,255],[123,120,185,255],[192,139,113,255],[106,199,164,255],[198,98,207,255],[188,214,91,255],[84,153,221,255],[228,77,108,255],[70,235,84,255],[143,116,189,255],[196,167,109,255],[101,204,199,255],[211,94,182,255],[147,218,87,255],[80,104,225,255],[232,93,73,255],[119,186,147,255],[170,112,193,255],[200,200,105,255],[97,175,208,255],[215,90,142,255],[100,222,83,255],[101,76,229,255],[183,150,122,255],[115,190,171,255],[197,108,194,255],[170,205,100,255],[93,138,212,255],[219,86,97,255],[79,226,110,255],[153,72,233,255],[187,173,118,255],[111,187,194,255],[201,104,165,255],[134,209,96,255],[89,95,216,255],[223,117,82,255],[75,230,159,255],[174,121,184,255],[182,191,114,255],[107,160,198,255],[206,99,130,255],[92,213,92,255],[124,85,220,255],[227,165,78,255],[71,234,214,255],[188,117,176,255],[156,195,110,255],[103,128,202,255],[210,100,95,255],[88,217,131,255],[170,81,224,255],[231,218,74,255],[120,172,185,255],[192,113,153,255],[125,199,106,255],[107,98,207,255],[214,137,91,255],[84,221,175,255],[222,77,228,255],[194,235,70,255],[116,149,189,255],[196,109,123,255],[101,204,114,255],[143,94,211,255],[218,180,87,255],[80,225,225,255],[232,73,186,255],[147,186,119,255],[112,122,193,255],[200,121,105,255],[97,208,148,255],[184,90,215,255],[216,222,83,255],[76,178,229,255],[183,122,145,255],[121,190,115,255],[126,108,197,255],[205,153,100,255],[93,212,187,255],[219,86,208,255],[171,226,79,255],[72,126,233,255],[187,118,121,255],[111,194,132,255],[157,104,201,255],[209,190,96,255],[89,200,216,255],[223,82,164,255],[120,230,75,255],[121,121,184,255],[191,136,114,255],[107,198,160,255],[192,99,206,255],[193,213,92,255],[85,158,220,255],[227,78,115,255],[71,234,78,255],[141,117,188,255],[195,163,110,255],[103,202,194,255],[210,95,186,255],[153,217,88,255],[81,111,224,255]],Ln={renderOutline:!0,outlineWidthActive:2,outlineWidthInactive:2,outlineOpacity:1,outlineOpacityInactive:.85,renderFill:!0,fillAlpha:1,fillAlphaInactive:0};const Rn=function(){return Ln},Fn={renderOutline:!0,outlineWidthActive:3,outlineWidthInactive:2,renderFill:!0,renderFillInactive:!0,fillAlpha:.7,fillAlphaInactive:.65,outlineOpacity:1,outlineOpacityInactive:.85};const Un=function(){return Fn},Bn=Un(),jn=Rn(),Vn={colorLUT:[],segmentations:[],globalConfig:{renderInactiveSegmentations:!0,representations:{[ie.Labelmap]:Bn,[ie.Contour]:jn}},toolGroups:{}};const Wn=new class{constructor(e){e||(e=Y.utilities.uuidv4()),this.state=se()(Vn),this.uid=e}getState(){return this.state}getToolGroups(){return Object.keys(this.state.toolGroups)}getColorLUT(e){return this.state.colorLUT[e]}resetState(){this.state=se()(Vn)}getSegmentation(e){return this.state.segmentations.find((t=>t.segmentationId===e))}addSegmentation(e){if(this._initDefaultColorLUTIfNecessary(),this.getSegmentation(e.segmentationId))throw new Error(`Segmentation with id ${e.segmentationId} already exists`);this.state.segmentations.push(e)}getSegmentationRepresentations(e){const t=this.state.toolGroups[e];if(t)return t.segmentationRepresentations}getAllSegmentationRepresentations(){const e={};return Object.entries(this.state.toolGroups).forEach((([t,n])=>{e[t]=n.segmentationRepresentations})),e}addSegmentationRepresentation(e,t){this.state.toolGroups[e]||(this.state.toolGroups[e]={segmentationRepresentations:[],config:{}}),this.state.toolGroups[e].segmentationRepresentations.push(t),this._handleActiveSegmentation(e,t)}getGlobalConfig(){return this.state.globalConfig}setGlobalConfig(e){this.state.globalConfig=e}getSegmentationRepresentationByUID(e,t){return this.getSegmentationRepresentations(e).find((e=>e.segmentationRepresentationUID===t))}removeSegmentation(e){this.state.segmentations=this.state.segmentations.filter((t=>t.segmentationId!==e))}removeSegmentationRepresentation(e,t){const n=this.getSegmentationRepresentations(e);if(!n||!n.length)throw new Error(`No viewport specific segmentation state found for viewport ${e}`);const r=n.findIndex((e=>e.segmentationRepresentationUID===t));-1===r&&console.warn(`No viewport specific segmentation state data found for viewport ${e} and segmentation data UID ${t}`);const i=n[r];n.splice(r,1),this._handleActiveSegmentation(e,i)}setActiveSegmentationRepresentation(e,t){const n=this.getSegmentationRepresentations(e);if(!n||!n.length)throw new Error(`No segmentation data found for toolGroupId: ${e}`);const r=n.find((e=>e.segmentationRepresentationUID===t));if(!r)throw new Error(`No segmentation data found for segmentation data UID ${t}`);r.active=!0,this._handleActiveSegmentation(e,r)}getToolGroupSpecificConfig(e){const t=this.state.toolGroups[e];if(t)return t.config}getSegmentationRepresentationSpecificConfig(e,t){const n=this.getSegmentationRepresentationByUID(e,t);if(n)return n.segmentationRepresentationSpecificConfig}setSegmentationRepresentationSpecificConfig(e,t,n){const r=this.getSegmentationRepresentationByUID(e,t);r&&(r.segmentationRepresentationSpecificConfig=n)}getSegmentSpecificConfig(e,t,n){const r=this.getSegmentationRepresentationByUID(e,t);if(r)return r.segmentSpecificConfig[n]}setSegmentSpecificConfig(e,t,n){const r=this.getSegmentationRepresentationByUID(e,t);r&&(r.segmentSpecificConfig=n)}setSegmentationRepresentationConfig(e,t){let n=this.state.toolGroups[e];n||(this.state.toolGroups[e]={segmentationRepresentations:[],config:{renderInactiveSegmentations:!0,representations:{}}},n=this.state.toolGroups[e]),n.config={...n.config,...t}}addColorLUT(e,t){this.state.colorLUT[t]&&console.log("Color LUT table already exists, overwriting"),this.state.colorLUT[t]=e}removeColorLUT(e){delete this.state.colorLUT[e]}_handleActiveSegmentation(e,t){const n=this.getSegmentationRepresentations(e);if(0===n.length)return;if(1===n.length)return void(n[0].active=!0);0!==n.filter((e=>e.active)).length?t.active&&n.forEach((e=>{e.segmentationRepresentationUID!==t.segmentationRepresentationUID&&(e.active=!1)})):n[0].active=!0}_initDefaultColorLUTIfNecessary(){0!==this.state.colorLUT.length&&this.state.colorLUT[0]||this.addColorLUT(Mn,0)}}("DEFAULT");function zn(e){const t={segmentationId:e};(0,Y.triggerEvent)(Y.eventTarget,ne.SEGMENTATION_REMOVED,t)}function Gn(e,t){const n={toolGroupId:e,segmentationRepresentationUID:t};(0,Y.triggerEvent)(Y.eventTarget,ne.SEGMENTATION_REPRESENTATION_REMOVED,n)}function Hn(e,t){const n={toolGroupId:e,segmentationRepresentationUID:t};if(t)return void(0,Y.triggerEvent)(Y.eventTarget,ne.SEGMENTATION_REPRESENTATION_MODIFIED,n);(Qn(e)||[]).forEach((t=>{const{segmentationRepresentationUID:n}=t,r={toolGroupId:e,segmentationRepresentationUID:n};(0,Y.triggerEvent)(Y.eventTarget,ne.SEGMENTATION_REPRESENTATION_MODIFIED,r)}))}function qn(e){let t;t=e?[e]:Yn().map((({segmentationId:e})=>e)),t.forEach((e=>{const t={segmentationId:e};(0,Y.triggerEvent)(Y.eventTarget,ne.SEGMENTATION_MODIFIED,t)}))}function Kn(e,t){const n={segmentationId:e,modifiedSlicesToUse:t};(0,Y.triggerEvent)(Y.eventTarget,ne.SEGMENTATION_DATA_MODIFIED,n)}const Xn=function(e){const{segmentationId:t,representation:n}=e;return{segmentationId:t,cachedStats:{},segmentLabels:{},label:null,segmentsLocked:new Set,type:n.type,activeSegmentIndex:1,representationData:{[n.type]:{...n.data}}}};function $n(){return Wn}function Jn(e){return $n().getSegmentation(e)}function Yn(){return $n().getState().segmentations}function Zn(e,t){const n=$n(),r=Xn(e);n.addSegmentation(r),t||qn(r.segmentationId)}function Qn(e){return $n().getSegmentationRepresentations(e)}function er(){return $n().getAllSegmentationRepresentations()}function tr(e){if(!e)throw new Error("getToolGroupIdsWithSegmentation: segmentationId is empty");const t=$n(),n=t.getState(),r=Object.keys(n.toolGroups),i=[];return r.forEach((n=>{t.getSegmentationRepresentations(n).forEach((t=>{t.segmentationId===e&&i.push(n)}))})),i}function nr(e){return $n().getToolGroupSpecificConfig(e)}function rr(e,t,n){$n().setSegmentationRepresentationConfig(e,t),n||Hn(e)}function ir(e,t,n,r=!1){$n().setSegmentationRepresentationSpecificConfig(e,t,n),r||Hn(e,t)}function or(e,t){return $n().getSegmentationRepresentationSpecificConfig(e,t)}function ar(e,t,n){return $n().getSegmentSpecificConfig(e,t,n)}function sr(e,t,n,r=!1){$n().setSegmentSpecificConfig(e,t,n),r||Hn(e,t)}function lr(e,t,n){$n().addSegmentationRepresentation(e,t),n||Hn(e,t.segmentationRepresentationUID)}function cr(){return $n().getGlobalConfig()}function ur(e,t){$n().setGlobalConfig(e),t||qn()}function dr(e,t){return $n().getSegmentationRepresentationByUID(e,t)}function hr(e){$n().removeSegmentation(e),zn(e)}function pr(e,t){$n().removeSegmentationRepresentation(e,t),Gn(e,t)}function fr(e){$n().removeColorLUT(e)}function mr(e){return $n().getColorLUT(e)}function gr(e,t){$n().addColorLUT(e,t)}function vr(){return cr()}function yr(e){ur(e)}function _r(e){return vr().representations[e]}function br(e,t){const n=vr();yr({...n,representations:{...n.representations,[e]:{...n.representations[e],...t}}})}function Er(e){return nr(e)}function wr(e,t){rr(e,t)}function xr(e,t){return or(e,t)}function Cr(e,t,n){ir(e,t,n)}function Dr(e,t,n){return ar(e,t,n)}function Sr(e,t,n){sr(e,t,n)}const Tr=async function(e,t,n){const r=(0,Y.getEnabledElement)(e),{renderingEngine:i,viewport:o}=r,{id:a}=o,s=[{volumeId:t,actorUID:n,visibility:!0,blendMode:Y.Enums.BlendModes.MAXIMUM_INTENSITY_BLEND}];await(0,Y.addVolumesToViewports)(i,s,[a],!1,!0)};const Ir=function(e,t,n=!1){const r=(0,Y.getEnabledElement)(e),{viewport:i}=r;i instanceof Y.StackViewport||i.removeVolumeActors([t])},Ar=255,Nr=new Map;function Or(e,t,n,r){const i={...e,...t,...r||{}};return{fillAlpha:n?i.fillAlpha:i.fillAlphaInactive,outlineWidth:n?i.outlineWidthActive:i.outlineWidthInactive,renderFill:n?i.renderFill:i.renderFillInactive,renderOutline:i.renderOutline,outlineOpacity:n?i.outlineOpacity:i.outlineOpacityInactive}}function Pr(e,t,n,{fillAlpha:r,renderFill:i,renderOutline:o,segmentColor:a,outlineWidth:s,segmentsHidden:l}){const c=`${e}-${t}-${n}`,u=Nr.get(c);if(!u)return Nr.set(c,{fillAlpha:r,renderFill:i,renderOutline:o,outlineWidth:s,segmentColor:a.slice(),segmentsHidden:new Set(l)}),{forceOpacityUpdate:!0,forceColorUpdate:!0};const{fillAlpha:d,renderFill:h,renderOutline:p,outlineWidth:f,segmentColor:m,segmentsHidden:g}=u,v=m[0]!==a[0]||m[1]!==a[1]||m[2]!==a[2],y=m[3]!==a[3]||d!==r||h!==i||p!==o||f!==s||g.has(n)!==l.has(n);return Nr.set(c,{fillAlpha:r,renderFill:i,renderOutline:o,outlineWidth:s,segmentColor:a.slice(),segmentsHidden:new Set(l)}),{forceOpacityUpdate:y,forceColorUpdate:v}}const kr={render:async function(e,t,n){const{colorLUTIndex:r,active:i,segmentationId:o,segmentationRepresentationUID:a,segmentsHidden:s,config:l}=t,c=Jn(o).representationData[ie.Labelmap],{volumeId:u}=c;if(!Y.cache.getVolume(u))throw new Error(`No Labelmap found for volumeId: ${u}`);if(!function(e,t){if(!t)return!0;const n=e.getDefaultActor();if(!n)return!1;const{uid:r}=n,i=Y.cache.getVolume(r);if(i){const e=Y.cache.getVolume(t);if(e&&i.metadata.FrameOfReferenceUID===e.metadata.FrameOfReferenceUID)return!0}return!1}(e,c?.referencedVolumeId))return;let d=e.getActor(a);if(!d){const t=Jn(o),{volumeId:n}=t.representationData[ie.Labelmap];await async function(e,t,n){await Tr(e.element,t,n)}(e,n,a),d=e.getActor(a)}if(!d)return;const{cfun:h,ofun:p}=l,f=n.renderInactiveSegmentations;!function(e,t,n,r,i,o,a,s,l,c){const{segmentSpecificConfig:u,segmentationRepresentationSpecificConfig:d}=a,h=d[ie.Labelmap],p=mr(i),f=Math.min(256,p.length),m=t.actor,{uid:g}=t,{outlineWidth:v,renderOutline:y,outlineOpacity:_}=Or(o,h,s);for(let t=0;t{(0,Y.getEnabledElementByIds)(e,t).viewport.render()}))}}};var Mr=n(54131),Lr=n(41168),Rr=n(23834),Fr=n(1299),Ur=n(21477),Br=n(89262),jr=Lr.default.vtkErrorMacro;function Vr(e,t,n,r){var i,o;e.set((i=n,o=0,t.map((function(e,t){return t===o?(o+=e+1,e):e+i}))),r)}var Wr={outputPointsPrecision:Ur.XJ.DEFAULT};function zr(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Object.assign(t,Wr,n),Lr.default.setGet(e,t,["outputPointsPrecision"]),Lr.default.obj(e,t),Lr.default.algo(e,t,1,1),function(e,t){t.classHierarchy.push("vtkAppendPolyData"),e.requestData=function(n,r){var i=e.getNumberOfInputPorts();if(i)if(1!==i){for(var o=Fr.ZP.newInstance(),a=0,s=0,l=1,c=1,u=0,d=0,h=0,p=0,f=!0,m=!0,g=!0,v=0;v(l=y.getPoints().getDataType())?s:l);var b=y.getPointData();b?(f=f&&null!==b.getNormals(),m=m&&null!==b.getTCoords(),g=g&&null!==b.getScalars()):(f=!1,m=!1,g=!1)}}t.outputPointsPrecision===Ur.XJ.SINGLE?s=Br.Tu.FLOAT:t.outputPointsPrecision===Ur.XJ.DOUBLE&&(s=Br.Tu.DOUBLE);var E=Rr.ZP.newInstance({dataType:s});E.setNumberOfPoints(a);var w=E.getData(),x=new Uint32Array(u),C=new Uint32Array(d),D=new Uint32Array(h),S=new Uint32Array(p),T=null,I=null,A=null,N=n[i-1];if(f){var O=N.getPointData().getNormals();T=Mr.ZP.newInstance({numberOfComponents:3,numberOfTuples:a,size:3*a,dataType:O.getDataType(),name:O.getName()})}if(m){var P=N.getPointData().getTCoords();I=Mr.ZP.newInstance({numberOfComponents:2,numberOfTuples:a,size:2*a,dataType:P.getDataType(),name:P.getName()})}if(g){var k=N.getPointData().getScalars();A=Mr.ZP.newInstance({numberOfComponents:k.getNumberOfComponents(),numberOfTuples:a,size:a*k.getNumberOfComponents(),dataType:k.getDataType(),name:k.getName()})}a=0,u=0,d=0,h=0,p=0;for(var M=0;M{const t=Y.cache.getGeometry(e);if(!t)return void console.warn(`No geometry found for geometryId ${e}. Skipping render.`);const r=t.data.getSegmentIndex();!function(e){if(!e)throw new Error(`No contours found for geometryId ${e.id}`);const t=e.id;if(e.type!==Y.Enums.GeometryType.CONTOUR)throw new Error(`Geometry type ${e.type} not supported for rendering.`);e.data||console.warn(`No contours found for geometryId ${t}. Skipping render.`)}(t);const i=Xr(n,e,r),o=t.data,u=function(e){const t=[],n=Rr.ZP.newInstance(),r=Kr.ZP.newInstance();let i=0;e.getContours().forEach((e=>{const n=e.getPoints(),o=e.getFlatPointsArray(),a=e.getType(),s=n.map(((e,t)=>t+i));a===Y.Enums.ContourType.CLOSED_PLANAR&&s.push(s[0]);const l=Float32Array.from(o);t.push(...l),r.insertNextCell([...s]),i+=n.length})),n.setData(t,3);const o=Fr.ZP.newInstance();return o.setPoints(n),o.setLines(r),o}(o),d=o.getColor(),h=u.getPoints().getNumberOfPoints(),p=Mr.ZP.newInstance({size:4*h,numberOfComponents:4,dataType:"Uint8Array"});for(let e=0;e!m.includes(e))).concat(f),{contourSets:v,segmentSpecificConfigs:y}=t.reduce(((e,t)=>{const r=Y.cache.getGeometry(t),{data:i}=r,o=i.getSegmentIndex(),a=Xr(n,t,o);return e.contourSets.push(i),e.segmentSpecificConfigs[o]=a??{},e}),{contourSets:[],segmentSpecificConfigs:{}}),_=[...g,...m],b=Object.values(y).some((e=>Object.keys(e).length>0));let E=!1;if(_.length||b){const e=h.getInputData(),t=e.getPointData().getScalars().getData();let n=0;v.forEach((e=>{const r=e.getSegmentIndex(),i=e.getTotalNumberOfPoints();if(_.includes(r)||y[r]?.fillAlpha){const o=e.getColor();let a=g.includes(r)?0:255;const s=y[r];void 0!==s.fillAlpha&&(a=255*s.fillAlpha);for(let e=0;ee.includes(t)?e:void 0)).filter(Boolean);i.removeActors(o)};const ti={render:async function(e,t,n){const{segmentationId:r}=t,i=Jn(r).representationData[ie.Contour],{geometryIds:o}=i;e instanceof Y.StackViewport||(o?.length||console.warn(`No contours found for segmentationId ${r}. Skipping render.`),function(e,t,n,r){const{segmentationRepresentationUID:i}=n,o=`CONTOUR_${i}`;(e.getActor(o)?Qr:Zr)(e,t,n,r,o)}(e,o,t,n))},addSegmentationRepresentation:async function(e,t,n){const{segmentationId:r}=t,i=Y.utilities.uuidv4(),o=new Set,a={segmentationId:r,segmentationRepresentationUID:i,type:ie.Contour,segmentsHidden:o,colorLUTIndex:0,active:!0,segmentationRepresentationSpecificConfig:{},segmentSpecificConfig:{},config:{}};if(n){const t=Er(e),r=Y.utilities.deepMerge(t,n);wr(e,{renderInactiveSegmentations:r.renderInactiveSegmentations||!0,representations:{...r.representations}})}return lr(e,a),i},removeSegmentationRepresentation:function(e,t,n=!1){if(function(e,t){const n=$m(e);if(void 0===n)throw new Error(`ToolGroup with ToolGroupId ${e} does not exist`);const{viewportsInfo:r}=n;for(const e of r){const{viewportId:n,renderingEngineId:r}=e,i=(0,Y.getEnabledElementByIds)(n,r);ei(i.viewport.element,t)}}(e,t),pr(e,t),function(e){$r.delete(e)}(t),n){$m(e).getViewportsInfo().forEach((({viewportId:e,renderingEngineId:t})=>{(0,Y.getEnabledElementByIds)(e,t).viewport.render()}))}}};const ni=function(e,t,n){const r=Qn(e);if(!r||0===r.length)return;const i=r.map((e=>e.segmentationRepresentationUID));let o=t;if(o){const e=t.filter((e=>!i.includes(e)));if(e.length>0)throw new Error(`The following segmentationRepresentationUIDs are not part of the toolGroup: ${JSON.stringify(e)}`)}else o=i;o.forEach((t=>{!function(e,t,n){const r=dr(e,t),{type:i}=r;if(i===ie.Labelmap)kr.removeSegmentationRepresentation(e,t,n);else{if(i!==ie.Contour)throw new Error(`The representation ${i} is not supported yet`);ti.removeSegmentationRepresentation(e,t,n)}}(e,t,n)}))};const ri=function(e){if(!e.representation.data)throw new Error("The segmentationInput.representationData.data is undefined, please provide a valid representationData.data");const t=e.representation.data;if(!t.volumeId)throw new Error("The segmentationInput.representationData.volumeId is undefined, please provide a valid representationData.volumeId");if(!Y.cache.getVolume(t.volumeId))throw new Error(`volumeId of ${t.volumeId} not found in cache, you should load and cache volume before adding segmentation`)};const ii=function(e){if(!e||!e.length)throw new Error("The segmentationInputArray is undefined or empty array");e.forEach((e=>{if(void 0===e.segmentationId)throw new Error("The segmentationInput.segmentationId is undefined, please provide a valid segmentationId");if(void 0===e.representation)throw new Error("The segmentationInput.representation is undefined, please provide a valid representation");e.representation.type===ie.Labelmap&&ri(e)}))};const oi=function(e){ii(e),e.map((e=>{Zn(se()(e))}))};const ai=async function(e,t,n){if(!$m(e))throw new Error(`No tool group found for toolGroupId: ${e}`);const r=t.map((t=>async function(e,t,n){let r;if(t.type===ie.Labelmap)r=await kr.addSegmentationRepresentation(e,t,n);else{if(t.type!==ie.Contour)throw new Error(`The representation type ${t.type} is not supported`);r=await ti.addSegmentationRepresentation(e,t,n)}return r}(e,t,n)));return await Promise.all(r)};function si(e){const t=$n().getSegmentationRepresentations(e);if(!t)return;return t.find((e=>e.active))}function li(e,t){$n().setActiveSegmentationRepresentation(e,t),Hn(e,t)}function ci(e,t){const n=Jn(e);if(!n)throw new Error(`No segmentation state found for ${e}`);const{segmentsLocked:r}=n;return r.has(t)}function ui(e,t,n=!0){const r=Jn(e);if(!r)throw new Error(`No segmentation state found for ${e}`);const{segmentsLocked:i}=r;n?i.add(t):i.delete(t),qn(e)}function di(e){const t=Jn(e);if(!t)throw new Error(`No segmentation state found for ${e}`);const{segmentsLocked:n}=t;return Array.from(n)}function hi(e,t){if(!e)throw new Error("addColorLUT: colorLUT is required");Y.utilities.isEqual(e[0],[0,0,0,0])||(console.warn("addColorLUT: [0, 0, 0, 0] color is not provided for the background color (segmentIndex =0), automatically adding it"),e.unshift([0,0,0,0])),gr(e,t)}function pi(e,t,n){const r=dr(e,t);if(!r)throw new Error(`setColorLUT: could not find segmentation representation with UID ${t}`);if(!mr(n))throw new Error(`setColorLUT: could not find colorLUT with index ${n}`);r.colorLUTIndex=n,Hn(e,t)}function fi(e,t,n){const r=dr(e,t);if(!r)throw new Error(`segmentation representation with UID ${t} does not exist for tool group ${e}`);const{colorLUTIndex:i}=r;return mr(i)[n]}function mi(e,t,n,r){const i=fi(e,t,n);for(let e=0;ee.segmentationRepresentationUID===t));if(!i)return;const{segmentsHidden:o,segmentationId:a}=i,s=function(e){const t=Jn(e);if(t.type===ie.Labelmap){const t=Y.cache.getVolume(e).getScalarData(),n={};for(let e=0;eparseInt(e,10)))}if(t.type===ie.Contour){const n=t.representationData.CONTOUR?.geometryIds;if(!n)throw new Error(`No geometryIds found for segmentationId ${e}`);return n.map((e=>Y.cache.getGeometry(e).data.getSegmentIndex()))}}(a);n?o.clear():s.forEach((e=>{o.add(e)})),Hn(e,i.segmentationRepresentationUID)}function vi(e,t){const n=Qn(e).find((e=>e.segmentationRepresentationUID===t));if(!n)return;const{segmentsHidden:r}=n;return 0===r.size}function yi(e,t,n,r){const i=dr(e,t);i&&(n.forEach((e=>{r?i.segmentsHidden.delete(e):i.segmentsHidden.add(e)})),Hn(e,t))}function _i(e,t,n,r){const i=dr(e,t);i&&(r?i.segmentsHidden.delete(n):i.segmentsHidden.add(n),Hn(e,t))}function bi(e,t){const n=Jn(e);n?.activeSegmentIndex!==t&&(n.activeSegmentIndex=t,qn(e))}function Ei(e){const t=Jn(e);if(t)return t.activeSegmentIndex}class wi{constructor(e,t){const n=Y.utilities.deepMerge(t,e),{configuration:r={},supportedInteractionTypes:i,toolGroupId:o}=n;r.strategies||(r.strategies={},r.defaultStrategy=void 0,r.activeStrategy=void 0,r.strategyOptions={}),this.toolGroupId=o,this.supportedInteractionTypes=i||[],this.configuration=Object.assign({},r),this.mode=Z.Disabled}getToolName(){return this.constructor.toolName}applyActiveStrategy(e,t){const{strategies:n,activeStrategy:r}=this.configuration;return n[r].call(this,e,t)}setConfiguration(e){this.configuration=Y.utilities.deepMerge(this.configuration,e)}setActiveStrategy(e){this.setConfiguration({activeStrategy:e})}getTargetVolumeId(e){if(this.configuration.volumeId)return this.configuration.volumeId;const t=e.getActors();return t?t.find((e=>"vtkVolume"===e.actor.getClassName()))?.uid:void 0}getTargetIdImage(e,t){if(e.startsWith("imageId:")){const n=e.split("imageId:")[1],r=Y.utilities.imageIdToURI(n);let i=Y.utilities.getViewportsWithImageURI(r,t.id);if(!i||!i.length)return;if(i=i.filter((e=>e.getCurrentImageId()===n)),!i||!i.length)return;return i[0].getImageData()}if(e.startsWith("volumeId:")){const n=e.split("volumeId:")[1],r=Y.utilities.getViewportsWithVolumeId(n,t.id);if(!r||!r.length)return;return r[0].getImageData()}throw new Error('getTargetIdImage: targetId must start with "imageId:" or "volumeId:"')}getTargetId(e){if(e instanceof Y.StackViewport)return`imageId:${e.getCurrentImageId()}`;if(e instanceof Y.BaseVolumeViewport)return`volumeId:${this.getTargetVolumeId(e)}`;throw new Error("getTargetId: viewport must be a StackViewport or VolumeViewport")}}wi.toolName="BaseTool";const xi=wi;var Ci=n(45451);const Di="viewport-element";function Si(e,t){if(He.svgNodeCache[e])return He.svgNodeCache[e][t]?He.svgNodeCache[e][t].domRef:void 0}function Ti(e,t,n,r){if(!He.svgNodeCache[t])return null;He.svgNodeCache[t][r]={touched:!0,domRef:n},e.appendChild(n)}function Ii(e,t){He.svgNodeCache[e]&&He.svgNodeCache[e][t]&&(He.svgNodeCache[e][t].touched=!0)}function Ai(e,t){He.svgNodeCache[t]&&Object.keys(He.svgNodeCache[t]).forEach((n=>{const r=He.svgNodeCache[t][n];!r.touched&&r.domRef&&(e.removeChild(r.domRef),delete He.svgNodeCache[t][n])}))}const Ni=function(e){const t=(0,Y.getEnabledElement)(e),{viewportId:n,renderingEngineId:r}=t,i=`${n}:${r}`,o=function(e){const t=`.${Di}`,n=e.querySelector(t);return n.querySelector(".svg-layer")}(e);return Object.keys(He.svgNodeCache[i]).forEach((e=>{He.svgNodeCache[i][e].touched=!1})),{svgLayerElement:o,svgNodeCacheForCanvas:He.svgNodeCache,getSvgNode:Si.bind(this,i),appendNode:Ti.bind(this,o,i),setNodeTouched:Ii.bind(this,i),clearUntouched:Ai.bind(this,o,i)}};const Oi=function(e,t){const n=Ni(e);t(n),n.clearUntouched()};const Pi=function(e,t,n){return`${e}::${t}::${n}`};const ki=function(e,t){Object.keys(e).forEach((n=>{const r=t.getAttribute(n),i=e[n];void 0===i||""===i?t.removeAttribute(n):r!==i&&t.setAttribute(n,i)}))};const Mi=function(e,t){Object.keys(e).forEach((n=>{const r=e[n];void 0!==r&&""!==r&&t.setAttribute(n,r)}))};const Li=function(e,t,n,r,i,o={},a=""){const{color:s,fill:l,width:c,lineWidth:u,lineDash:d,fillOpacity:h,strokeOpacity:p}=Object.assign({color:"dodgerblue",fill:"transparent",width:"2",lineDash:void 0,lineWidth:void 0,strokeOpacity:1,fillOpacity:1},o),f=u||c,m=Pi(t,"circle",n),g=e.getSvgNode(m),v={cx:`${r[0]}`,cy:`${r[1]}`,r:`${i}`,stroke:s,fill:l,"stroke-width":f,"stroke-dasharray":d,"fill-opacity":h,"stroke-opacity":p};if(g)ki(v,g),e.setNodeTouched(m);else{const t=document.createElementNS("http://www.w3.org/2000/svg","circle");""!==a&&t.setAttribute("data-id",a),Mi(v,t),e.appendNode(t,m)}};const Ri=function(e,t,n,r,i,o={},a=""){const{color:s,width:l,lineWidth:c,lineDash:u}=Object.assign({color:"dodgerblue",width:"2",lineWidth:void 0,lineDash:void 0},o),d=c||l,h=Pi(t,"ellipse",n),p=e.getSvgNode(h),f=Math.abs(r[0]-i[0]),m=Math.abs(r[1]-i[1]),g=[Math.min(r[0],i[0])+f/2,Math.min(r[1],i[1])+m/2],v={cx:`${g[0]}`,cy:`${g[1]}`,rx:`${f/2}`,ry:`${m/2}`,stroke:s,fill:"transparent","stroke-width":d,"stroke-dasharray":u};if(p)ki(v,p),e.setNodeTouched(h);else{const t=document.createElementNS("http://www.w3.org/2000/svg","ellipse");""!==a&&t.setAttribute("data-id",a),Mi(v,t),e.appendNode(t,h)}};const Fi=function(e,t,n,r,i={}){const{color:o,handleRadius:a,width:s,lineWidth:l,fill:c,type:u,opacity:d}=Object.assign({color:"dodgerblue",handleRadius:"6",width:"2",lineWidth:void 0,fill:"transparent",type:"circle",opacity:1},i),h=l||s;for(let i=0;in.length){for(let e=0;e0?zi(r,i):i,l=function(e){const{x:t,y:n,height:r,width:i}=e,o=i/2,a=r/2;return[[t+o,n],[t,n+a],[t+o,n+r],[t+i,n+a]]}(o);Ui(e,t,`link-${n}`,s,zi(l,s),Object.assign({color:"rgb(255, 255, 0)",lineWidth:"1",lineDash:"2,3"},a))};const Hi=function(e,t,n,r,i,o,a,s={}){const l=Object.assign({handleRadius:"6",centering:{x:!1,y:!0}},s),c=Wi(e,t,n,r,i,l);return Gi(e,t,n,o,i,c,l),c};function qi(e,t,n,r,i,o={},a=""){const{color:s,width:l,lineWidth:c,lineDash:u}=Object.assign({color:"dodgerblue",width:"2",lineWidth:void 0,lineDash:void 0},o),d=c||l,h=Pi(t,"rect",n),p=e.getSvgNode(h),f=[Math.min(r[0],i[0]),Math.min(r[1],i[1])],m=Math.abs(r[0]-i[0]),g=Math.abs(r[1]-i[1]),v={x:`${f[0]}`,y:`${f[1]}`,width:`${m}`,height:`${g}`,stroke:s,fill:"transparent","stroke-width":d,"stroke-dasharray":u};if(p)ki(v,p),e.setNodeTouched(h);else{const t=document.createElementNS("http://www.w3.org/2000/svg","rect");""!==a&&t.setAttribute("data-id",a),Mi(v,t),e.appendNode(t,h)}}function Ki(e,t,n,r,i,o={}){if(isNaN(r[0])||isNaN(r[1])||isNaN(i[0])||isNaN(i[1]))return;const{color:a,width:s,lineWidth:l,lineDash:c}=Object.assign({color:"dodgerblue",width:"2",lineWidth:void 0,lineDash:void 0},o);Ui(e,t,n,r,i,{color:a,width:s,lineWidth:l,lineDash:c});const u=Math.atan2(i[1]-r[1],i[0]-r[0]),d={start:[i[0]-10*Math.cos(u-Math.PI/7),i[1]-10*Math.sin(u-Math.PI/7)],end:i},h={start:[i[0]-10*Math.cos(u+Math.PI/7),i[1]-10*Math.sin(u+Math.PI/7)],end:i};Ui(e,t,"2",d.start,d.end,{color:a,width:s,lineWidth:l}),Ui(e,t,"3",h.start,h.end,{color:a,width:s,lineWidth:l})}function Xi(e,t){const n=(0,Y.getEnabledElement)(e),{renderingEngineId:r,viewportId:i}=n,o=Cm(i,r);if(!o)return[];const a=[],s=Object.keys(o.toolOptions);for(let e=0;e{this._throwIfDestroyed();const e=Array.from(this._viewportElements.values());for(let t=0;t{this._needsRender.add(e)})),this._renderFlaggedViewports()}_setViewportsToBeRenderedNextFrame(e){const t=[...this._viewportElements.values()];e.forEach((e=>{-1!==t.indexOf(e)&&this._needsRender.add(e)})),this._render()}_render(){this._needsRender.size>0&&!1===this._animationFrameSet&&(this._animationFrameHandle=window.requestAnimationFrame(this._renderFlaggedViewports),this._animationFrameSet=!0)}_triggerRender(e){const t=(0,Y.getEnabledElement)(e);if(!t)return void console.warn("Element has been disabled");if(!(0,Y.getRenderingEngine)(t.renderingEngineId))return void console.warn("rendering Engine has been destroyed");const n=Xi(e,[$i,Ji,Yi]),{renderingEngineId:r,viewportId:i}=t,o={element:e,renderingEngineId:r,viewportId:i};Oi(e,(r=>{let i=!1;n.forEach((e=>{if(e.renderAnnotation){const n=e.renderAnnotation(t,r);i=i||n}})),i&&(0,Y.triggerEvent)(e,ne.ANNOTATION_RENDERED,{...o})}))}_reset(){window.cancelAnimationFrame(this._animationFrameHandle),this._needsRender.clear(),this._animationFrameSet=!1,this._animationFrameHandle=null,this._setAllViewportsToBeRenderedNextFrame()}};const Qi=function(e){Zi.renderViewport(e)},{EPSILON:eo}=Y.CONSTANTS,to=1-eo;function no(e,t,n){const{viewPlaneNormal:r}=t,i=e.filter((e=>{let t=e.metadata.viewPlaneNormal;if(!t){const{referencedImageId:n}=e.metadata,{imageOrientationPatient:r}=Y.metaData.get("imagePlaneModule",n),i=Ci.R3.fromValues(r[0],r[1],r[2]),o=Ci.R3.fromValues(r[3],r[4],r[5]);t=Ci.R3.create(),Ci.R3.cross(t,i,o),e.metadata.viewPlaneNormal=t}const n=Math.abs(Ci.R3.dot(r,t))>to;return t&&n}));if(!i.length)return[];const o=n/2,{focalPoint:a}=t,s=[];for(const e of i){const t=e.data.handles.points[0];if(!e.isVisible)continue;const n=Ci.R3.create();Ci.R3.sub(n,a,t);const i=Ci.R3.dot(n,r);Math.abs(i){if(!e.isVisible)return!1;const t=e.metadata.referencedImageId;if(void 0===t)return!1;const n=t.indexOf(":");return t.substring(n+1)===i}))}if(e instanceof Y.VolumeViewport){const n=e.getCamera(),{spacingInNormalDirection:r}=Y.utilities.getTargetVolumeAndSpacingInNormalDir(e,n);return no(t,n,r)}throw new Error(`Viewport Type ${e.type} not supported`)}const io=new class{constructor(){this._initializeConfig({color:"rgb(255, 255, 0)",colorHighlighted:"rgb(0, 255, 0)",colorSelected:"rgb(0, 220, 0)",colorLocked:"rgb(255, 255, 0)",lineWidth:"1",lineDash:"",shadow:!0,textBoxVisibility:!0,textBoxFontFamily:"Helvetica Neue, Helvetica, Arial, sans-serif",textBoxFontSize:"14px",textBoxColor:"rgb(255, 255, 0)",textBoxColorHighlighted:"rgb(0, 255, 0)",textBoxColorSelected:"rgb(0, 255, 0)",textBoxColorLocked:"rgb(255, 255, 0)",textBoxBackground:"",textBoxLinkLineWidth:"1",textBoxLinkLineDash:"2,3",textBoxShadow:!0})}getAnnotationToolStyles(e){return this.config.annotations&&this.config.annotations[e]}getViewportToolStyles(e){return this.config.viewports&&this.config.viewports[e]}getToolGroupToolStyles(e){return this.config.toolGroups&&this.config.toolGroups[e]}getDefaultToolStyles(){return this.config.default}setAnnotationStyles(e,t){let n=this.config.annotations;n||(this.config={...this.config,annotations:{}},n=this.config.annotations),n[e]=t}setViewportToolStyles(e,t){let n=this.config.viewports;n||(this.config={...this.config,viewports:{}},n=this.config.viewports),n[e]=t}setToolGroupToolStyles(e,t){let n=this.config.toolGroups;n||(this.config={...this.config,toolGroups:{}},n=this.config.toolGroups),n[e]=t}setDefaultToolStyles(e){this.config.default=e}getStyleProperty(e,t){const{annotationUID:n,viewportId:r,toolGroupId:i,toolName:o}=t;return this._getToolStyle(e,n,r,i,o)}_getToolStyle(e,t,n,r,i){if(t){const n=this.getAnnotationToolStyles(t);if(n&&n[e])return n[e]}if(n){const t=this.getViewportToolStyles(n);if(t){if(t[i]&&t[i][e])return t[i][e];if(t.global&&t.global[e])return t.global[e]}}if(r){const t=this.getToolGroupToolStyles(r);if(t){if(t[i]&&t[i][e])return t[i][e];if(t.global&&t.global[e])return t.global[e]}}const o=this.getDefaultToolStyles();return o[i]&&o[i][e]?o[i][e]:o.global&&o.global[e]?o.global[e]:void 0}_initializeConfig(e){const t={};for(const n in e)t[n]=e[n];this.config={default:{global:t}}}};function oo(e,t,n,r){const i=function(e,t,n){const r=[`${e}`];return t&&r.push(`${r[0]}${t}`),n&&r.push(`${r[r.length-1]}${n}`),r}(e,n,r);for(let e=i.length-1;e>=0;--e){const n=io.getStyleProperty(i[e],t);if(void 0!==n)return n}}const ao=function(e){if(e){if(e.data&&e.highlighted)return ee.Highlighted;if(De(e.annotationUID))return ee.Selected;if(he(e))return ee.Locked}return ee.Default};const so=function(e,t,n){return`${oo("textBoxFontSize",e,t,n)}px ${oo("textBoxFontFamily",e,t,n)}`};class lo extends xi{constructor(){super(...arguments),this.onImageSpacingCalibrated=e=>{const{element:t,imageId:n}=e.detail,r=Y.utilities.imageIdToURI(n),i=eg();i.getFramesOfReference().forEach((e=>{const n=i.getAnnotations(e)[this.getToolName()];n&&n.length&&(n.forEach((e=>{if(!e.metadata?.referencedImageId)return;Y.utilities.imageIdToURI(e.metadata.referencedImageId)===r&&(e.invalidated=!0,e.data.cachedStats={})})),Qi(t))}))}}filterInteractableAnnotationsForElement(e,t){if(!t||!t.length)return;const n=(0,Y.getEnabledElement)(e),{viewport:r}=n;return ro(r,t)}getReferencedImageId(e,t,n,r){const i=this.getTargetId(e);let o;if(e instanceof Y.StackViewport)o=i.split("imageId:")[1];else{const e=i.split("volumeId:")[1],r=Y.cache.getVolume(e);o=Y.utilities.getClosestImageId(r,t,n)}return o}getStyle(e,t,n){return oo(e,t,ao(n),this.mode)}}lo.toolName="AnnotationDisplayTool";const co=lo;class uo extends co{constructor(e,t){super(e,t),this.mouseMoveCallback=(e,t)=>{if(!t)return!1;const{element:n,currentPoints:r}=e.detail,i=r.canvas;let o=!1;for(const e of t){if(he(e)||!ke(e.annotationUID))continue;const{data:t}=e,r=t.handles?t.handles.activeHandleIndex:void 0,a=this._imagePointNearToolOrHandle(n,e,i,6),s=a&&!e.highlighted,l=!a&&e.highlighted;s||l?(e.highlighted=!e.highlighted,o=!0):t.handles&&t.handles.activeHandleIndex!==r&&(o=!0)}return o},e.configuration?.getTextLines&&(this.configuration.getTextLines=e.configuration.getTextLines),e.configuration?.statsCalculator&&(this.configuration.statsCalculator=e.configuration.statsCalculator)}getHandleNearImagePoint(e,t,n,r){const i=(0,Y.getEnabledElement)(e),{viewport:o}=i,{data:a}=t,{points:s,textBox:l}=a.handles;if(l){const{worldBoundingBox:e}=l;if(e){const t={topLeft:o.worldToCanvas(e.topLeft),topRight:o.worldToCanvas(e.topRight),bottomLeft:o.worldToCanvas(e.bottomLeft),bottomRight:o.worldToCanvas(e.bottomRight)};if(n[0]>=t.topLeft[0]&&n[0]<=t.bottomRight[0]&&n[1]>=t.topLeft[1]&&n[1]<=t.bottomRight[1])return a.handles.activeHandleIndex=null,l}}for(let e=0;e{const t=$m(e);if(!t)return;const n=Qn(e);if(!n||0===n.length)return;const r=t.viewportsInfo.map((({renderingEngineId:e,viewportId:t})=>{const n=(0,Y.getEnabledElementByIds)(t,e);if(n)return n.viewport})),i=n.map((t=>{const n=this._getMergedRepresentationsConfig(e),i=[],o=t.type===ie.Labelmap?kr:ti;for(const e of r){const r=o.render(e,t,n);i.push(r)}return i}));Promise.allSettled(i).then((()=>{r.forEach((e=>{e.render()}))}))}}onSetToolEnabled(){const e=this.toolGroupId,t=Qn(e);t&&0!==t.length&&t.forEach((t=>{gi(e,t.segmentationRepresentationUID,!0)}))}onSetToolDisabled(){const e=this.toolGroupId,t=Qn(e);t&&0!==t.length&&t.forEach((t=>{gi(e,t.segmentationRepresentationUID,!1)}))}_getMergedRepresentationsConfig(e){const t=Er(e),n=vr();return Y.utilities.deepMerge(n,t)}}po.toolName="SegmentationDisplay";const fo=po;const mo=new class{constructor(){this._needsRender=new Set,this._animationFrameSet=!1,this._animationFrameHandle=null,this._renderFlaggedToolGroups=()=>{this._throwIfDestroyed();const e=Array.from(this._needsRender.values());for(const t of e)if(this._triggerRender(t),this._needsRender.delete(t),0===this._needsRender.size)return this._animationFrameSet=!1,void(this._animationFrameHandle=null)}}removeToolGroup(e){this._needsRender.delete(e),0===this._needsRender.size&&this._reset()}renderToolGroupSegmentations(e){this._setToolGroupSegmentationToBeRenderedNextFrame([e])}_throwIfDestroyed(){if(this.hasBeenDestroyed)throw new Error("this.destroy() has been manually called to free up memory, can not longer use this instance. Instead make a new one.")}_setToolGroupSegmentationToBeRenderedNextFrame(e){e.forEach((e=>{this._needsRender.add(e)})),this._render()}_render(){this._needsRender.size>0&&!1===this._animationFrameSet&&(this._animationFrameHandle=window.requestAnimationFrame(this._renderFlaggedToolGroups),this._animationFrameSet=!0)}_triggerRender(e){const t=$m(e);if(!t)return void console.warn(`No tool group found with toolGroupId: ${e}`);const{viewportsInfo:n}=t,r=[];n.forEach((({viewportId:e,renderingEngineId:t})=>{const n=(0,Y.getRenderingEngine)(t);n?r.push(n.getViewport(e)):console.warn("rendering Engine has been destroyed")}));const i=t.getToolInstance(fo.toolName);function o(e){const{element:t,viewportId:n,renderingEngineId:r}=e.detail;t.removeEventListener(Y.Enums.Events.IMAGE_RENDERED,o);const i=Cm(n,r);if(!i)return void console.warn("toolGroup has been destroyed");const a={toolGroupId:i.id,viewportId:n};(0,Y.triggerEvent)(Y.eventTarget,ne.SEGMENTATION_RENDERED,{...a})}i?(r.forEach((({element:e})=>{e.addEventListener(Y.Enums.Events.IMAGE_RENDERED,o)})),i.renderSegmentation(e)):console.warn("No segmentation tool found inside",e)}_reset(){window.cancelAnimationFrame(this._animationFrameHandle),this._needsRender.clear(),this._animationFrameSet=!1,this._animationFrameHandle=null}};function go(e){mo.renderToolGroupSegmentations(e)}const vo=go,yo=function(e){const{toolGroupId:t}=e.detail;vo(t)},_o=function(e){const{segmentationId:t,modifiedSlicesToUse:n}=e.detail,{representationData:r,type:i}=Jn(t);let o;if(i!==ie.Labelmap)throw new Error(`onSegmentationDataModified: representationType ${i} not supported yet`);{const e=Y.cache.getVolume(r[i].volumeId);if(!e)return void console.warn("segmentation not found in cache");const{imageData:a,vtkOpenGLTexture:s}=e;let l;if(n&&Array.isArray(n))l=n;else{const e=a.getDimensions()[2];l=[...Array(e).keys()]}l.forEach((e=>{s.setUpdatedFrame(e)})),a.modified(),o=tr(t)}o.forEach((e=>{vo(e)}))},bo=function(e){const{toolGroupId:t,segmentationRepresentationUID:n}=e.detail;vo(t)},Eo=function(e){const{segmentationId:t}=e.detail;tr(t).forEach((e=>{Qn(e).forEach((n=>{n.segmentationId===t&&Hn(e,n.segmentationRepresentationUID)}))}))};function wo(e,t,n=5){const r=(0,Y.getEnabledElement)(e);if(!r)throw new Error("getAnnotationNearPoint: enabledElement not found");return xo(r,t,n)}function xo(e,t,n){const{renderingEngineId:r,viewportId:i}=e,o=Cm(i,r);if(!o)return null;const{_toolInstances:a}=o;for(const r in a){const i=Co(a[r],e,t,n);if(i)return i}return null}function Co(e,t,n,r){const{viewport:i}=t,o=rg(e.constructor.toolName,i?.element),a=i?.getCurrentImageId?.();if(o?.length){const{element:i}=t.viewport;for(const t of o){const o=t.metadata?.referencedImageId;if(!(a&&o&&a!==o||!e.isPointNearTool)&&(e.isPointNearTool(i,t,n,r,"")||e.getHandleNearImagePoint(i,t,n,r)))return t}}return null}const Do=function(e){const t=typeof e;return null!==e&&("object"===t||"function"===t)};const So=function(e,t,n){let r,i,o,a,s,l,c=0,u=!1,d=!1,h=!0;const p=!t&&0!==t&&"function"==typeof window.requestAnimationFrame;if("function"!=typeof e)throw new TypeError("Expected a function");function f(t){const n=r,o=i;return r=i=void 0,c=t,a=e.apply(o,n),a}function m(e,t){return p?window.requestAnimationFrame(e):setTimeout(e,t)}function g(e){const n=e-l;return void 0===l||n>=t||n<0||d&&e-c>=o}function v(){const e=Date.now();if(g(e))return y(e);s=m(v,function(e){const n=e-c,r=t-(e-l);return d?Math.min(r,o-n):r}(e))}function y(e){return s=void 0,h&&r?f(e):(r=i=void 0,a)}function _(...e){const n=Date.now(),o=g(n);if(r=e,i=this,l=n,o){if(void 0===s)return function(e){return c=e,s=m(v,t),u?f(e):a}(l);if(d)return s=m(v,t),f(l)}return void 0===s&&(s=m(v,t)),a}return t=Number(t)||0,Do(n)&&(u=Boolean(n.leading),d="maxWait"in n,o=d?Math.max(Number(n.maxWait)||0,t):o,h="trailing"in n?Boolean(n.trailing):h),_.cancel=function(){void 0!==s&&function(e){if(p)return window.cancelAnimationFrame(e);clearTimeout(e)}(s),c=0,r=l=i=s=void 0},_.flush=function(){return void 0===s?a:y(Date.now())},_.pending=function(){return void 0!==s},_};const To=function(e,t,n){let r=!0,i=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return Do(n)&&(r="leading"in n?Boolean(n.leading):r,i="trailing"in n?Boolean(n.trailing):i),So(e,t,{leading:r,trailing:i,maxWait:t})};function Io(e,t,n){return Math.min(Math.max(t,e),n)}const Ao=Io,{calibratedPixelSpacingMetadataProvider:No}=Y.utilities;function Oo(e,t,n){"number"==typeof n&&(n={type:Y.Enums.CalibrationTypes.USER,scale:n}),No.add(e,n);t.getStackViewports().forEach((t=>{t.getImageIds().includes(e)&&t.calibrateSpacing(e)}))}const Po=function(e,t){t.length&&t.forEach((t=>{const{element:n}=e.getViewport(t);Qi(n)}))};function ko(e,t){if(!(0,Y.getEnabledElement)(e.element))throw new Error("Scroll::Viewport is not enabled (it might be disabled)");if(e instanceof Y.StackViewport&&0===e.getImageIds().length)throw new Error("Scroll::Stack Viewport has no images");const{type:n}=e,{volumeId:r,delta:i}=t;if(e instanceof Y.StackViewport)e.scroll(i,t.debounceLoading,t.loop);else{if(!(e instanceof Y.VolumeViewport))throw new Error(`Not implemented for Viewport Type: ${n}`);!function(e,t,n){const{numScrollSteps:r,currentStepIndex:i,sliceRangeInfo:o}=Y.utilities.getVolumeViewportScrollInfo(e,t);if(!o)return;const{sliceRange:a,spacingInNormalDirection:s,camera:l}=o,{focalPoint:c,viewPlaneNormal:u,position:d}=l,{newFocalPoint:h,newPosition:p}=Y.utilities.snapFocalPointToSlice(c,d,a,u,s,n);e.setCamera({focalPoint:h,position:p}),e.render();const f=i+n;if((f>r||f<0)&&e.getCurrentImageId()){const o={volumeId:t,viewport:e,delta:n,desiredStepIndex:f,currentStepIndex:i,numScrollSteps:r,currentImageId:e.getCurrentImageId()};Y.utilities.triggerEvent(Y.eventTarget,Y.EVENTS.VOLUME_SCROLL_OUT_OF_BOUNDS,o)}}(e,r,i)}}const Mo=async function(e,t={}){const{imageIndex:n,debounceLoading:r,volumeId:i}=t,o=(0,Y.getEnabledElement)(e);if(!o)throw new Error("Element has been disabled");const{viewport:a}=o,{imageIndex:s,numberOfSlices:l}=function(e,t){if(e instanceof Y.StackViewport)return{numberOfSlices:e.getImageIds().length,imageIndex:t?e.getTargetImageIdIndex():e.getCurrentImageIdIndex()};if(e instanceof Y.VolumeViewport)return Y.utilities.getImageSliceDataForVolumeViewport(e);throw new Error("Unsupported viewport type")}(a,r),c=function(e,t){const n=e-1;return Ao(t,0,n)}(l,n);ko(a,{delta:c-s,debounceLoading:r,volumeId:i})};function Lo(e,t,n,r){let i,o,a,s,l,c,u;u=e.getScalarData?e.getScalarData():e.getPointData().getScalars().getData();const d=e.getDimensions();r?[[i,o],[a,s],[l,c]]=r:(i=0,o=d[0],a=0,s=d[1],l=0,c=d[2]);const h=Ci.R3.fromValues(i,a,l),p=e.getDirection(),f=p.slice(0,3),m=p.slice(3,6),g=p.slice(6,9),v=e.getSpacing(),[y,_,b]=v,E=e.indexToWorld(h),w=Ci.R3.fromValues(f[0]*y,f[1]*y,f[2]*y),x=Ci.R3.fromValues(m[0]*_,m[1]*_,m[2]*_),C=Ci.R3.fromValues(g[0]*b,g[1]*b,g[2]*b),D=d[0],S=d[0]*d[1],T=[];for(let e=l;e<=c;e++)for(let r=a;r<=s;r++)for(let s=i;s<=o;s++){const o=[s,r,e],c=s-i,d=r-a,h=e-l,p=E,f=[p[0]+c*w[0]+d*x[0]+h*C[0],p[1]+c*w[1]+d*x[1]+h*C[1],p[2]+c*w[2]+d*x[2]+h*C[2]];if(t(f,o)){const t=e*S+r*D+s,i=u[t];T.push({value:i,index:t,pointIJK:o,pointLPS:f}),null!==n&&n({value:i,index:t,pointIJK:o,pointLPS:f})}}return T}const Ro=function(e,t){const n=e.findIndex((([e,t])=>e===t));if(-1===n)throw new Error("3D bounding boxes not supported in an oblique plane");return e[n][0]-=t,e[n][1]+=t,e};const Fo=function(e,t){let n=1/0,r=0,i=1/0,o=0,a=1/0,s=0;if(e.forEach((e=>{n=Math.min(e[0],n),r=Math.max(e[0],r),i=Math.min(e[1],i),o=Math.max(e[1],o),a=Math.min(e[2],a),s=Math.max(e[2],s)})),n=Math.floor(n),r=Math.floor(r),i=Math.floor(i),o=Math.floor(o),a=Math.floor(a),s=Math.floor(s),t){const[e,l,c]=t;n=Math.max(0,n),r=Math.min(e-1,r),i=Math.max(0,i),o=Math.min(l-1,o),a=Math.max(0,a),s=Math.min(c-1,s)}return[[n,r],[i,o],[a,s]]},{transformWorldToIndex:Uo}=Y.utilities;function Bo(e,t,n,r){const{boundsIJK:i,centerWorld:o,radiusWorld:a}=function(e,t,n){const[r,i]=e,o=Ci.R3.fromValues((r[0]+i[0])/2,(r[1]+i[1])/2,(r[2]+i[2])/2),a=Ci.R3.distance(r,i)/2;let s;if(!n){const e=Uo(t,o),n=t.getSpacing(),r=Math.min(...n),i=Math.ceil(a/r);return s=[[e[0]-i,e[0]+i],[e[1]-i,e[1]+i],[e[2]-i,e[2]+i]],{boundsIJK:s,centerWorld:o,radiusWorld:a}}return s=function(e,t,n,r,i){const[o,a]=n,s=e.getDimensions(),l=t.getCamera(),c=Ci.R3.fromValues(l.viewUp[0],l.viewUp[1],l.viewUp[2]),u=Ci.R3.fromValues(l.viewPlaneNormal[0],l.viewPlaneNormal[1],l.viewPlaneNormal[2]),d=Ci.R3.create();Ci.R3.cross(d,c,u);const h=Ci.R3.create(),p=Ci.R3.create();Ci.R3.scaleAndAdd(h,a,u,i),Ci.R3.scaleAndAdd(p,o,u,-i),Ci.R3.scaleAndAdd(h,h,d,-i),Ci.R3.scaleAndAdd(p,p,d,i);const f=[Uo(e,h),Uo(e,p)],m=Fo(f,s);return m}(t,n,e,0,a),{boundsIJK:s,centerWorld:o,radiusWorld:a}}(t,e,r),s={center:o,radius:a};Lo(e,(e=>function(e,t){const{center:n,radius:r}=e;return(t[0]-n[0])**2+(t[1]-n[1])**2+(t[2]-n[2])**2<=r**2}(s,e)),n,i)}const jo=function(e,t=2){if(null==e||""===e)return"NaN";if((e=Number(e))<1e-4)return`${e}`;const n=e>=100?t-2:e>=10?t-1:e>=1?t:e>=.1?t+1:e>=.01?t+2:e>=.001?t+3:t+4;return e.toFixed(n)};const Vo=function(e,t,n){const{THRESHOLD_INSIDE_CIRCLE:r}=n,i=t.getScalarData()[e],{threshold:o}=r;return o[0]<=i&&i<=o[1]};function Wo(e,t,n=!0,r=!1){const{viewport:i}=e,{volume:o,segmentsLocked:a,segmentIndex:s,imageVolume:l,strategySpecificConfiguration:c,segmentationId:u,points:d}=t,{imageData:h,dimensions:p}=o,f=o.getScalarData(),m=[];let g;g=r?({value:e,index:t,pointIJK:n})=>{a.includes(e)||Vo(t,l,c)&&(f[t]=s,m.push(t))}:({index:e,value:t})=>{a.includes(t)||(f[e]=s,m.push(e))},Bo(h,[d[0],d[1]],g,i);const v=p[0]*p[1],y=Math.floor(m[0]/v),_=Math.floor(m[m.length-1]/v);Kn(u,Array.from({length:_-y+1},((e,t)=>t+y)))}function zo(e,t){Wo(e,t,!0)}function Go(e,t){const{volume:n,imageVolume:r}=t;if(!Y.utilities.isEqual(n.dimensions,r.dimensions)||!Y.utilities.isEqual(n.direction,r.direction))throw new Error("Only source data the same dimensions/size/orientation as the segmentation currently supported.");Wo(e,t,!0,!0)}function Ho(e,t){zo(e,Object.assign({},t,{segmentIndex:0}))}function qo(e,t){const{center:n,xRadius:r,yRadius:i,zRadius:o}=e,[a,s,l]=t,[c,u,d]=n;let h=0;return 0!==r&&(h+=(a-c)*(a-c)/(r*r)),0!==i&&(h+=(s-u)*(s-u)/(i*i)),0!==o&&(h+=(l-d)*(l-d)/(o*o)),h<=1}function Ko(e){const[t,n,r,i]=e;return[[r[0],n[1]],[i[0],t[1]]]}const{transformWorldToIndex:Xo}=Y.utilities;function $o(e,t,n=!1){const{volume:r,imageVolume:i,points:o,segmentsLocked:a,segmentIndex:s,segmentationId:l,strategySpecificConfiguration:c}=t,{imageData:u,dimensions:d}=r,h=r.getScalarData(),{viewport:p}=e,f=Ci.R3.fromValues(0,0,0);o.forEach((e=>{Ci.R3.add(f,f,e)})),Ci.R3.scale(f,f,1/o.length);const m=o.map((e=>p.worldToCanvas(e))),[g,v]=Ko(m),y=p.canvasToWorld(g),_=p.canvasToWorld(v),b=[Xo(u,y),Xo(u,_)],E=Fo(b,d),w={center:f,xRadius:Math.abs(y[0]-_[0])/2,yRadius:Math.abs(y[1]-_[1])/2,zRadius:Math.abs(y[2]-_[2])/2},x=new Set;let C;C=n?({value:e,index:t,pointIJK:n})=>{a.includes(e)||Vo(t,i,c)&&(h[t]=s,x.add(n[2]))}:({value:e,index:t,pointIJK:n})=>{a.includes(e)||(h[t]=s,x.add(n[2]))},Lo(u,((e,t)=>qo(w,e)),C,E);Kn(l,Array.from(x))}function Jo(e,t){$o(e,t,!1)}function Yo(e,t){const{volume:n,imageVolume:r}=t;if(!Y.utilities.isEqual(n.dimensions,r.dimensions)||!Y.utilities.isEqual(n.direction,r.direction))throw new Error("Only source data the same dimensions/size/orientation as the segmentation currently supported.");$o(e,t,!0)}function Zo(e,t){Jo(e,{...t,segmentIndex:0})}const Qo=Symbol("DefinedCursors"),ea=new Set(["alias","all-scroll","auto","cell","col-resize","context-menu","copy","crosshair","default","e-resize","ew-resize","grab","grabbing","help","move","ne-resize","nesw-resize","no-drop","none","not-allowed","n-resize","ns-resize","nw-resize","nwse-resize","pointer","progress","row-resize","se-resize","s-resize","sw-resize","text","vertical-text","wait","w-resize","zoom-in","zoom-out"]);class ta{constructor(e,t){this.name=e+"",this.fallback=t}getName(){return this.name+""}addFallbackStyleProperty(e){const{fallback:t}=this;return t instanceof ta?`${e}, ${t.getStyleProperty()}`:e+""}getStyleProperty(){return this.addFallbackStyleProperty(this.name)+""}static getDefinedCursor(e){const t=na(ta,Qo);let n=t.get(e);return n instanceof ta?n:ea.has(e)?(n=new ta(e),t.set(e,n),n):void 0}static setDefinedCursor(e,t){if(t instanceof ta){return na(ta,Qo).set(e,t),!0}return!1}}function na(e,t){let n=e[t];return n instanceof Map||(n=new Map,Object.defineProperty(e,t,{value:n})),n}const ra=ea.values();class ia extends ta{constructor(e,t,n,r,i){super(r||ia.getUniqueInstanceName("image-cursor"),i),this.url=e,this.x=Number(t)||0,this.y=Number(n)||0}getStyleProperty(){const{url:e,x:t,y:n}=this;let r=`url('${e}')`;return t>=0&&n>=0&&(t>0||n>0)&&(r+=` ${t} ${n}`),this.addFallbackStyleProperty(r)}static getUniqueInstanceName(e){return`${e}-${Y.utilities.getRuntimeId(ia)}`}}const oa={iconContent:"",iconSize:16,viewBox:{x:16,y:16},mousePoint:{x:8,y:8},mousePointerGroupString:'\n \n \n '},aa={x:127,y:60},sa='\n\n',la='\n\n\n',ca='',ua='',da='',ha={Angle:pa(oa,{iconContent:'',viewBox:{x:1792,y:1792}}),ArrowAnnotate:pa(oa,{iconContent:'\n \n ',viewBox:{x:24,y:24}}),Bidirectional:pa(oa,{iconContent:'\n \n \n \n \n \n \n ',viewBox:{x:48,y:48}}),CobbAngle:pa(oa,{iconContent:'\n \n \n \n \n ',viewBox:{x:32,y:32}}),CircleROI:pa(oa,{iconContent:'',viewBox:{x:32,y:32}}),EllipticalROI:pa(oa,{iconContent:'',viewBox:{x:32,y:32}}),FreehandROI:pa(oa,{iconContent:'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ',viewBox:{x:18,y:18}}),FreehandROISculptor:pa(oa,{iconContent:'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ',viewBox:{x:18,y:18}}),Length:pa(oa,{iconContent:'\n \n ',viewBox:{x:24,y:24}}),Probe:pa(oa,{iconContent:'',viewBox:{x:1792,y:1792}}),RectangleROI:pa(oa,{iconContent:'',viewBox:{x:1792,y:1792}}),TextMarker:pa(oa,{iconContent:'',viewBox:{x:1792,y:1792}}),Crosshairs:pa(oa,{iconContent:'',viewBox:{x:1792,y:1792}}),Eraser:pa(oa,{iconContent:'',viewBox:{x:2048,y:1792}}),Magnify:pa(oa,{iconContent:'',viewBox:{x:512,y:512}}),Pan:pa(oa,{iconContent:'',viewBox:{x:1792,y:1792}}),Rotate:pa(oa,{iconContent:'',viewBox:{x:1792,y:1792}}),StackScroll:pa(oa,{iconContent:'',viewBox:{x:24,y:28}}),WindowLevelRegion:pa(oa,{iconContent:'',viewBox:{x:1792,y:1792}}),WindowLevel:pa(oa,{iconContent:'\n \n ',viewBox:{x:18,y:18}}),Zoom:pa(oa,{iconContent:'\n \n ',viewBox:{x:640,y:512}}),SegmentationFreeHandEraseInside:pa(oa,{iconContent:`${ca} ${sa}`,viewBox:aa}),SegmentationFreeHandFillInside:pa(oa,{iconContent:`${ca} ${la}`,viewBox:aa}),SegmentationFreeHandEraseOutside:pa(oa,{iconContent:`${ca} ${sa}`,viewBox:aa}),SegmentationFreeHandFillOutside:pa(oa,{iconContent:`${ca} ${la}`,viewBox:aa}),SegmentationRectangleEraseInside:pa(oa,{iconContent:`${ua} ${sa}`,viewBox:aa}),RectangleScissor:pa(oa,{iconContent:`${ua} ${la}`,viewBox:aa}),"RectangleScissor.FILL_INSIDE":pa(oa,{iconContent:`${ua} ${la}`,viewBox:aa}),"RectangleScissor.FILL_OUTSIDE":pa(oa,{iconContent:`${ua} ${la}`,viewBox:aa}),"RectangleScissor.ERASE_OUTSIDE":pa(oa,{iconContent:`${ua} ${sa}`,viewBox:aa}),"RectangleScissor.ERASE_INSIDE":pa(oa,{iconContent:`${ua} ${sa}`,viewBox:aa}),CircleScissor:pa(oa,{iconContent:`${da} ${la}`,viewBox:aa}),"CircleScissor.FILL_INSIDE":pa(oa,{iconContent:`${da} ${la}`,viewBox:aa}),"CircleScissor.ERASE_OUTSIDE":pa(oa,{iconContent:`${da} ${sa}`,viewBox:aa}),"CircleScissor.FILL_OUTSIDE":pa(oa,{iconContent:`${da} ${la}`,viewBox:aa})};function pa(e,t){return Object.assign(Object.create(e),t)}function fa(e,t,n){ha[e]=pa(oa,{iconContent:t,viewBox:n})}const ma=Object.keys(ha),ga=ee.Highlighted,va=Z.Active;class ya extends ia{constructor(e,t,n,r,i){super(e,t,n,r,i)}static getDefinedCursor(e,t=!1,n){n||(n=oo("color",{},ga,va));const r=function(e,t,n){const r=t?"pointer":"cursor";return`${r}:${e}/${n}`}(e,t,n);let i=super.getDefinedCursor(r);if(!i){const o=function(e){return ha[e]}(e);o&&(i=function(e,t,n,r,i){const{x:o,y:a}=e.mousePoint;return new ya(function(e,t,n){return URL.createObjectURL(function(e,t,n){const r=(t?Ea:ba)(e,n);return new Blob([r],{type:"image/svg+xml"})}(e,t,n))}(e,n,{color:r}),o,a,t,i)}(o,r,t,n,super.getDefinedCursor("default")),super.setDefinedCursor(r,i))}return i}}function _a(e,t){const n=Object(t),r=Object.prototype.hasOwnProperty.bind(n);return(e+"").replace(/\{\{(\w+)\}\}/g,((e,t)=>r(t)?n[t]+"":""))}function ba(e,t){const{iconContent:n,iconSize:r,viewBox:i}=e;return _a(`\n \n ${n}\n `,t)}function Ea(e,t){const{iconContent:n,iconSize:r,viewBox:i,mousePointerGroupString:o}=e,a=16+r;return _a(`\n \n ${o}\n ${n}\n `,t)}const wa=function(e,t){let n=ya.getDefinedCursor(t,!0);n||(n=ta.getDefinedCursor(t)),n||(console.log(`Cursor ${t} is not defined either as SVG or as a standard cursor.`),n=ta.getDefinedCursor(t)),Sa(e,n)},xa=[...ma,...ra],Ca=Symbol("ElementCursorsMap");function Da(e,t){Aa(e)[0]=t,Sa(e,t)}function Sa(e,t){const n=Aa(e);n[1]=n[0],n[0]=t,e.style.cursor=(t instanceof ta?t:ta.getDefinedCursor("auto")).getStyleProperty()}function Ta(e){Sa(e,Aa(e)[1])}function Ia(e){Sa(e,ta.getDefinedCursor("none"))}function Aa(e){let t=Aa[Ca];t instanceof WeakMap||(t=new WeakMap,Object.defineProperty(Aa,Ca,{value:t}));let n=t.get(e);return n||(n=[null,null],t.set(e,n)),n}class Na extends xi{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{strategies:{FILL_INSIDE_CIRCLE:Jo,ERASE_INSIDE_CIRCLE:Zo,FILL_INSIDE_SPHERE:zo,ERASE_INSIDE_SPHERE:Ho,THRESHOLD_INSIDE_CIRCLE:Yo,THRESHOLD_INSIDE_SPHERE:Go},strategySpecificConfiguration:{THRESHOLD_INSIDE_CIRCLE:{threshold:[-150,-70]}},defaultStrategy:"FILL_INSIDE_CIRCLE",activeStrategy:"FILL_INSIDE_CIRCLE",brushSize:25}}){super(e,t),this.onSetToolPassive=()=>{this.disableCursor()},this.onSetToolEnabled=()=>{this.disableCursor()},this.onSetToolDisabled=()=>{this.disableCursor()},this.preMouseDownCallback=e=>{const t=e.detail,{element:n}=t,r=(0,Y.getEnabledElement)(n),{viewport:i,renderingEngine:o}=r;if(i instanceof Y.StackViewport)throw new Error("Not implemented yet");const a=si(this.toolGroupId);if(!a)throw new Error("No active segmentation detected, create one before using the brush tool");const{segmentationId:s,type:l}=a,c=di(s),{representationData:u}=Jn(s),{volumeId:d}=u[l],h=Y.cache.getVolume(d),p=i.getActors()[0].uid,f=Y.cache.getVolume(p),m=[i.id];return this._editData={segmentation:h,imageVolume:f,segmentsLocked:c},this._activateDraw(n),Ia(n),e.preventDefault(),Po(o,m),!0},this.mouseMoveCallback=e=>{this.mode===Z.Active&&this.updateCursor(e)},this._dragCallback=e=>{const t=e.detail,{element:n}=t,r=(0,Y.getEnabledElement)(n),{renderingEngine:i}=r,{imageVolume:o,segmentation:a,segmentsLocked:s}=this._editData;this.updateCursor(e);const{segmentIndex:l,segmentationId:c,segmentationRepresentationUID:u,brushCursor:d,viewportIdsToRender:h}=this._hoverData,{data:p}=d,{viewPlaneNormal:f,viewUp:m}=d.metadata;Po(i,h);const g={points:p.handles.points,volume:a,imageVolume:o,segmentIndex:l,segmentsLocked:s,viewPlaneNormal:f,toolGroupId:this.toolGroupId,segmentationId:c,segmentationRepresentationUID:u,viewUp:m,strategySpecificConfiguration:this.configuration.strategySpecificConfiguration};this.applyActiveStrategy(r,g)},this._endCallback=e=>{const t=e.detail,{element:n}=t,{imageVolume:r,segmentation:i,segmentsLocked:o}=this._editData,{segmentIndex:a,segmentationId:s,segmentationRepresentationUID:l,brushCursor:c}=this._hoverData,{data:u}=c,{viewPlaneNormal:d,viewUp:h}=c.metadata;this._deactivateDraw(n),Ta(n);const p=(0,Y.getEnabledElement)(n),{viewport:f}=p;if(this._editData=null,this.updateCursor(e),f instanceof Y.StackViewport)throw new Error("Not implemented yet");const m={points:u.handles.points,volume:i,imageVolume:r,segmentIndex:a,segmentsLocked:o,viewPlaneNormal:d,toolGroupId:this.toolGroupId,segmentationId:s,segmentationRepresentationUID:l,viewUp:h,strategySpecificConfiguration:this.configuration.strategySpecificConfiguration};this.applyActiveStrategy(p,m)},this._activateDraw=e=>{e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback)},this._deactivateDraw=e=>{e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback)}}disableCursor(){this._hoverData=void 0}updateCursor(e){const t=e.detail,{element:n}=t,{currentPoints:r}=t,i=r.canvas,o=(0,Y.getEnabledElement)(n),{renderingEngine:a,viewport:s}=o,l=s.getCamera(),{viewPlaneNormal:c,viewUp:u}=l,d=this.toolGroupId,h=si(d);if(!h)return void console.warn("No active segmentation detected, create one before using the brush tool");const{segmentationRepresentationUID:p,segmentationId:f}=h,m=Ei(f),g=fi(d,p,m),v=[s.id],y={metadata:{viewPlaneNormal:[...c],viewUp:[...u],FrameOfReferenceUID:s.getFrameOfReferenceUID(),referencedImageId:"",toolName:this.getToolName(),segmentColor:g},data:{}};this._hoverData={brushCursor:y,centerCanvas:i,segmentIndex:m,segmentationId:f,segmentationRepresentationUID:p,segmentColor:g,viewportIdsToRender:v},this._calculateCursor(n,i),Po(a,v)}_calculateCursor(e,t){const n=(0,Y.getEnabledElement)(e),{viewport:r}=n,{canvasToWorld:i}=r,o=r.getCamera(),{brushSize:a}=this.configuration,s=Ci.R3.fromValues(o.viewUp[0],o.viewUp[1],o.viewUp[2]),l=Ci.R3.fromValues(o.viewPlaneNormal[0],o.viewPlaneNormal[1],o.viewPlaneNormal[2]),c=Ci.R3.create();Ci.R3.cross(c,s,l);const u=i([t[0],t[1]]),d=Ci.R3.create(),h=Ci.R3.create(),p=Ci.R3.create(),f=Ci.R3.create();for(let e=0;e<=2;e++)d[e]=u[e]-s[e]*a,h[e]=u[e]+s[e]*a,p[e]=u[e]-c[e]*a,f[e]=u[e]+c[e]*a;const{brushCursor:m}=this._hoverData,{data:g}=m;void 0===g.handles&&(g.handles={}),g.handles.points=[d,h,p,f],g.invalidated=!1}invalidateBrushCursor(){if(void 0!==this._hoverData){const{data:e}=this._hoverData.brushCursor;e.invalidated=!0}}renderAnnotation(e,t){if(!this._hoverData)return;const{viewport:n}=e;if(!this._hoverData.viewportIdsToRender.includes(n.id))return;const r=this._hoverData.brushCursor;if(!0===r.data.invalidated){const{centerCanvas:e}=this._hoverData,{element:t}=n;this._calculateCursor(t,e)}const i=r.metadata,o=i.brushCursorUID,a=r.data,{points:s}=a.handles,l=s.map((e=>n.worldToCanvas(e))),c=l[0],u=l[1],d=[Math.floor((c[0]+u[0])/2),Math.floor((c[1]+u[1])/2)],h=Math.abs(c[1]-Math.floor((c[1]+u[1])/2)),p=`rgb(${i.segmentColor.slice(0,3)})`;if(!n.getRenderingEngine())return void console.warn("Rendering Engine has been destroyed");Li(t,o,"0",d,h,{color:p})}}Na.toolName="Brush";const Oa=Na;function Pa(e,t){const n=$m(e);if(void 0===n)return;const r=n._toolInstances;if(!Object.keys(r).length)return;if(t&&r[t])return[r[t]];return Object.values(r).filter((e=>e instanceof Oa))}const ka=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function Ma(e,t,n,r){const i=[];for(let e=0;e<2;e++)for(let t=0;t<2;t++)for(let o=0;o<2;o++){const a=r;a[0]=a[0]+(2*e-1)*n[0]/2,a[1]=a[1]+(2*t-1)*n[1]/2,a[2]=a[2]+(2*o-1)*n[2]/2,i.push(a)}const o=i.map((t=>Y.utilities.transformWorldToIndex(e,t)));return Fo(o,t)}function La(e,t){const{spacing:n,imageData:r}=e,i=e.getScalarData(),o=[];let a=0;for(let e=0;e{const{imageData:r,dimensions:i,lower:o,upper:a}=e,l=Ma(r,i,t,n);d=0,u=0,h={lower:o,upper:a};let c=!1;return Lo(r,(()=>!0),(({value:e})=>{d+=1,e>=h.lower&&e<=h.upper&&(u+=1)}),l),0===s?c=u>0:1==s&&(c=u===d),c},f=(e,t)=>{const{imageData:n,referenceValues:r,lower:i,upper:o}=e,a=r[n.computeOffsetIndex(t)];return!(a<=i||a>=o)};return Lo(r,(()=>!0),(({index:e,pointIJK:t,pointLPS:n})=>{let r=c.length>0;for(let e=0;e{const i=e.getVtkActiveCamera(),o=i.getViewUp(),a=i.getFocalPoint(),s=i.getPosition(),l=[0,0,0],c=[0,0,0],u=[0,0,0],d=Ci._E.identity(new Float32Array(16));Ci._E.translate(d,d,t),Ci._E.rotate(d,d,r,n),Ci._E.translate(d,d,[-t[0],-t[1],-t[2]]),Ci.R3.transformMat4(l,s,d),Ci.R3.transformMat4(c,a,d),Ci._E.identity(d),Ci._E.rotate(d,d,r,n),Ci.R3.transformMat4(u,o,d),e.setCamera({position:l,viewUp:u,focalPoint:c})},this.touchDragCallback=this._dragCallback.bind(this),this.mouseDragCallback=this._dragCallback.bind(this)}_dragCallback(e){const{element:t,currentPoints:n,lastPoints:r}=e.detail,i=n.canvas,o=r.canvas,{rotateIncrementDegrees:a}=this.configuration,s=(0,Y.getEnabledElement)(t),{viewport:l}=s,c=l.getCamera(),u=t.clientWidth,d=t.clientHeight,h=[i[0]/u,i[1]/d],p=[o[0]/u,o[1]/d],f=[.5*u,.5*d],m=l.canvasToWorld(f),g=(1+Math.abs(.5))**2,v=[p[0],0,0],y=[h[0],0,0],_=v[0]**2,b=y[0]**2,E=_>g?0:Math.sqrt(g-_),w=b>g?0:Math.sqrt(g-b),x=[v[0],0,E];Ba.ZP.normalize(x);const C=[y[0],0,w];Ba.ZP.normalize(C);const D=Ba.ZP.dot(x,C);if(Math.abs(D)>1e-4){const e=-2*Math.acos(Ba.ZP.clampValue(D,-1,1))*Math.sign(h[0]-p[0])*a,t=c.viewUp,n=c.viewPlaneNormal,r=[0,0,0],i=[0,0,0];Ba.ZP.cross(t,n,r),Ba.ZP.normalize(r),Ba.ZP.cross(n,r,i),Ba.ZP.normalize(i),Ba.ZP.normalize(t),this.rotateCamera(l,m,i,e);const o=(p[1]-h[1])*a;this.rotateCamera(l,m,r,o),l.render()}}}ja.toolName="TrackballRotate";const Va=ja;class Wa extends xi{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"]}){super(e,t),this._getImageDynamicRangeFromMiddleSlice=(e,t)=>{const n=Math.floor(t[2]/2),r=t[0]*t[1];let i,o;e instanceof Float32Array?(i=4,o=Float32Array):e instanceof Uint8Array?(i=1,o=Uint8Array):e instanceof Uint16Array?(i=2,o=Uint16Array):e instanceof Int16Array&&(i=2,o=Int16Array);const a=new o(e.buffer,n*r*i,r),{max:s,min:l}=this._getMinMax(a,r);return s-l}}touchDragCallback(e){this.mouseDragCallback(e)}mouseDragCallback(e){const{element:t,deltaPoints:n}=e.detail,r=(0,Y.getEnabledElement)(t),{renderingEngine:i,viewport:o}=r;let a,s,l,c,u,d,h=!1;if(o instanceof Y.VolumeViewport){a=this.getTargetId(o).split("volumeId:")[1],d=Y.utilities.getViewportsWithVolumeId(a,i.id);const e=o.getProperties();({lower:s,upper:l}=e.voiRange);const t=Y.cache.getVolume(a);c=t.metadata.Modality,h=t.scaling&&Object.keys(t.scaling).length>0}else{if(!(o instanceof Y.StackViewport))throw new Error("Viewport is not a valid type");{const e=o.getProperties();c=o.modality,({lower:s,upper:l}=e.voiRange);const{preScale:t}=o.getImageData();h=t.scaled&&void 0!==t.scalingParameters?.suvbw}}return u="PT"===c?this.getPTScaledNewRange({deltaPointsCanvas:n.canvas,lower:s,upper:l,clientHeight:t.clientHeight,isPreScaled:h,viewport:o,volumeId:a}):this.getNewRange({viewport:o,deltaPointsCanvas:n.canvas,volumeId:a,lower:s,upper:l}),o instanceof Y.StackViewport?(o.setProperties({voiRange:u}),void o.render()):o instanceof Y.VolumeViewport?(o.setProperties({voiRange:u}),void d.forEach((e=>{e.render()}))):void 0}getPTScaledNewRange({deltaPointsCanvas:e,lower:t,upper:n,clientHeight:r,viewport:i,volumeId:o,isPreScaled:a}){let s=4;s=a?5/r:this._getMultiplierFromDynamicRange(i,o)||4;return n-=e[1]*s,{lower:t,upper:n=a?Math.max(n,.1):n}}getNewRange({viewport:e,deltaPointsCanvas:t,volumeId:n,lower:r,upper:i}){const o=this._getMultiplierFromDynamicRange(e,n)||4,a=t[0]*o,s=t[1]*o;let{windowWidth:l,windowCenter:c}=Y.utilities.windowLevel.toWindowLevel(r,i);return l+=a,c+=s,l=Math.max(l,1),Y.utilities.windowLevel.toLowHighRange(l,c)}_getMultiplierFromDynamicRange(e,t){let n;if(t){const e=Y.cache.getVolume(t),{dimensions:r}=e,i=e.getScalarData(),o=this._getImageDynamicRangeFromMiddleSlice(i,r),a=e?.metadata?.BitsStored,s=a?2**a:1/0;n=Math.min(o,s)}else n=this._getImageDynamicRangeFromViewport(e);const r=n/1024;let i=4;return r>1&&(i=Math.round(r)),i}_getImageDynamicRangeFromViewport(e){const{imageData:t}=e.getImageData(),n=t.getDimensions();let r,i;if(r=t.getScalarData?t.getScalarData():t.getPointData().getScalars(),1!==n[2])return this._getImageDynamicRangeFromMiddleSlice(r,n);if(r.getRange)i=r.getRange();else{const{min:e,max:t}=this._getMinMax(r,r.length);i=[e,t]}return i[1]-i[0]}_getMinMax(e,t){let n=1/0,r=-1/0;for(let i=0;ir&&(r=t)}return{max:r,min:n}}}Wa.toolName="WindowLevel";const za=Wa;class Ga extends xi{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{invert:!1,debounceIfNotLoaded:!0,loop:!1}}){super(e,t),this.deltaY=1}mouseDragCallback(e){this._dragCallback(e)}touchDragCallback(e){this._dragCallback(e)}_dragCallback(e){const{deltaPoints:t,viewportId:n,renderingEngineId:r}=e.detail,{viewport:i}=(0,Y.getEnabledElementByIds)(n,r),o=this.getTargetId(i),{debounceIfNotLoaded:a,invert:s,loop:l}=this.configuration,c=t.canvas[1];let u;i instanceof Y.VolumeViewport&&(u=o.split("volumeId:")[1]);const d=this._getPixelPerImage(i),h=c+this.deltaY;if(d)if(Math.abs(h)>=d){const e=Math.round(h/d);ko(i,{delta:s?-e:e,volumeId:u,debounceLoading:a,loop:l}),this.deltaY=h%d}else this.deltaY=h}_getPixelPerImage(e){const{element:t}=e,n=this._getNumberOfSlices(e);return Math.max(2,t.offsetHeight/Math.max(n,8))}_getNumberOfSlices(e){if(e instanceof Y.VolumeViewport){const{numberOfSlices:t}=Y.utilities.getImageSliceDataForVolumeViewport(e);return t}if(e instanceof Y.StackViewport)return e.getImageIds().length}}Ga.toolName="StackScroll";const Ha=Ga;function qa(e,t){const[n,r]=e,[i,o]=t,a=Ci.R3.sub(Ci.R3.create(),r,n),s=Ci.R3.sub(Ci.R3.create(),i,o),l=Ci.R3.dot(a,s)/(Ci.R3.length(a)*Ci.R3.length(s));return 180*Math.acos(l)/Math.PI}class Ka extends xi{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"]}){super(e,t),this.touchDragCallback=this._dragCallback.bind(this),this.mouseDragCallback=this._dragCallback.bind(this)}_dragCallback(e){const{element:t,currentPoints:n,startPoints:r}=e.detail,i=n.world,o=r.world,a=(0,Y.getEnabledElement)(t),{viewport:s}=a,l=s.getCamera(),c=[.5*t.clientWidth,.5*t.clientHeight],u=s.canvasToWorld(c);let d=qa([o,u],[u,i]);const{viewPlaneNormal:h,viewUp:p}=l,f=Ci.R3.sub(Ci.R3.create(),u,o),m=Ci.R3.sub(Ci.R3.create(),u,i),g=Ci.R3.cross(Ci.R3.create(),f,m);if(Ci.R3.dot(h,g)>0&&(d=-d),!Number.isNaN(d)){if(s instanceof Y.BaseVolumeViewport){const e=d*Math.PI/180,t=Ci._E.identity(new Float32Array(16));Ci._E.rotate(t,t,e,h);const n=Ci.R3.transformMat4(Ci.R3.create(),p,t);s.setCamera({viewUp:n})}else{const{rotation:e}=s.getProperties();s.setProperties({rotation:e+d})}s.render()}}}Ka.toolName="PlanarRotate";const Xa=Ka;class $a extends xi{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{invert:!1,debounceIfNotLoaded:!0,loop:!1}}){super(e,t)}mouseWheelCallback(e){const{wheel:t,element:n}=e.detail,{direction:r}=t,{invert:i}=this.configuration,{viewport:o}=(0,Y.getEnabledElement)(n),a=r*(i?-1:1),s=this.getTargetId(o).split("volumeId:")[1];ko(o,{delta:a,debounceLoading:this.configuration.debounceIfNotLoaded,loop:this.configuration.loop,volumeId:s})}}$a.toolName="StackScrollMouseWheel";const Ja=$a;class Ya extends xi{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{zoomToCenter:!1,minZoomScale:.1,maxZoomScale:30,pinchToZoom:!0,pan:!0,invert:!1}}){super(e,t),this.preMouseDownCallback=e=>{const t=e.detail,{element:n,currentPoints:r}=t,i=r.world,o=(0,Y.getEnabledElement)(n).viewport.getCamera(),{focalPoint:a}=o;this.initialMousePosWorld=i;let s=Ci.R3.fromValues(a[0]-i[0],a[1]-i[1],a[2]-i[2]);return s=Ci.R3.normalize(Ci.R3.create(),s),this.dirVec=s,!1},this.preTouchStartCallback=e=>{if(!this.configuration.pinchToZoom)return this.preMouseDownCallback(e)},this._dragParallelProjection=(e,t,n,r=!1)=>{const{element:i,deltaPoints:o}=e.detail,a=r?e.detail.deltaDistance.canvas:o.canvas[1],s=[i.clientWidth,i.clientHeight],{parallelScale:l,focalPoint:c,position:u}=n;let d=(1-a*(1.5/s[1])*(this.configuration.invert?-1:1))*l,h=c,p=u;if(!this.configuration.zoomToCenter){const e=Ci.R3.distance(c,this.initialMousePosWorld),t=a*(5/s[1])*(this.configuration.invert?-1:1);d=(1-t)*l,p=Ci.R3.scaleAndAdd(Ci.R3.create(),u,this.dirVec,-e*t),h=Ci.R3.scaleAndAdd(Ci.R3.create(),c,this.dirVec,-e*t)}const f=t.getImageData();let m=[1,1,1];f&&(m=f.spacing);const{minZoomScale:g,maxZoomScale:v}=this.configuration,y=i.clientHeight*m[1]*.5,_=y/d;let b=d,E=!1;f&&(_=v&&(b=y/v,E=!0)),t.setCamera({parallelScale:b,focalPoint:E?c:h,position:E?u:p})},this._dragPerspectiveProjection=(e,t,n,r=!1)=>{const{element:i,deltaPoints:o}=e.detail,a=r?e.detail.deltaDistance.canvas:o.canvas[1],s=[i.clientWidth,i.clientHeight],{position:l,focalPoint:c,viewPlaneNormal:u}=n,d=Ba.ZP.distance2BetweenPoints(l,c),h=Math.sqrt(d)/s[1],p=[-u[0],-u[1],-u[2]],f=this.configuration.invert?a/h:a*h;let m=f*p[0];l[0]+=m,c[0]+=m,m=f*p[1],l[1]+=m,c[1]+=m,m=f*p[2],l[2]+=m,c[2]+=m,t.setCamera({position:l,focalPoint:c})},this.initialMousePosWorld=[0,0,0],this.dirVec=[0,0,0],this.configuration.pinchToZoom?this.touchDragCallback=this._pinchCallback.bind(this):this.touchDragCallback=this._dragCallback.bind(this),this.mouseDragCallback=this._dragCallback.bind(this)}_pinchCallback(e){if(e.detail.currentPointsList.length>1){const{element:t,currentPoints:n}=e.detail,r=(0,Y.getEnabledElement)(t),{viewport:i}=r,o=i.getCamera(),a=n.world,{focalPoint:s}=o;this.initialMousePosWorld=a;let l=Ci.R3.fromValues(s[0]-a[0],s[1]-a[1],s[2]-a[2]);l=Ci.R3.normalize(Ci.R3.create(),l),this.dirVec=l,o.parallelProjection?this._dragParallelProjection(e,i,o,!0):this._dragPerspectiveProjection(e,i,o,!0),i.render()}this.configuration.pan&&this._panCallback(e)}_dragCallback(e){const{element:t}=e.detail,n=(0,Y.getEnabledElement)(t),{viewport:r}=n,i=r.getCamera();i.parallelProjection?this._dragParallelProjection(e,r,i):this._dragPerspectiveProjection(e,r,i),r.render()}_panCallback(e){const{element:t,deltaPoints:n}=e.detail,r=(0,Y.getEnabledElement)(t),i=n.world,o=r.viewport.getCamera(),{focalPoint:a,position:s}=o,l=[s[0]-i[0],s[1]-i[1],s[2]-i[2]],c=[a[0]-i[0],a[1]-i[1],a[2]-i[2]];r.viewport.setCamera({focalPoint:c,position:l}),r.viewport.render()}}Ya.toolName="Zoom";const Za=Ya,Qa=[0,0,1];class es extends xi{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{direction:Qa,rotateIncrementDegrees:.5}}){super(e,t)}mouseWheelCallback(e){const{element:t,wheel:n}=e.detail,r=(0,Y.getEnabledElement)(t),{viewport:i}=r,{direction:o,rotateIncrementDegrees:a}=this.configuration,s=i.getCamera(),{viewUp:l,position:c,focalPoint:u}=s,{direction:d}=n,[h,p,f]=u,[m,g,v]=o,y=d*a,_=[0,0,0],b=[0,0,0],E=[0,0,0],w=Ci._E.identity(new Float32Array(16));Ci._E.translate(w,w,[h,p,f]),Ci._E.rotate(w,w,y,[m,g,v]),Ci._E.translate(w,w,[-h,-p,-f]),Ci.R3.transformMat4(_,c,w),Ci.R3.transformMat4(b,u,w),Ci._E.identity(w),Ci._E.rotate(w,w,y,[m,g,v]),Ci.R3.transformMat4(E,l,w),i.setCamera({position:_,viewUp:E,focalPoint:b}),i.render()}}es.toolName="VolumeRotateMouseWheel";const ts=es;function ns(e,t,n,r){const i=Ci.R3.create();Ci.R3.cross(i,t,e);const o=Ci.R3.fromValues(...n),a=Ci.R3.fromValues(...r),s=Ci.R3.create();Ci.R3.subtract(s,o,a);const l=Ci.R3.length(s);if(l<1e-4)return{worldWidth:0,worldHeight:0};const c=Ci.R3.dot(s,i)/(l*Ci.R3.length(i));return{worldWidth:Math.sqrt(1-c*c)*l,worldHeight:c*l}}function rs(e,t,n,r,i=.25){const o=e.getCamera(),{position:a}=o,{spacingInNormalDirection:s}=Y.utilities.getTargetVolumeAndSpacingInNormalDir(e,o,n),l=s*i,c=e.getBounds(),u=c[0],d=c[1],h=[0,0,0];let p,f=[0,0,0];Ba.ZP.subtract(t,a,h);for(let t=u;t<=d;t+=l){f=[t,0,0];const n=(t-a[0])/h[0];if(f[1]=n*h[1]+a[1],f[2]=n*h[2]+a[2],is(f,c)){const t=r(e.getIntensityFromWorld(f),f);t&&(p=t)}}return p}const is=function(e,t){const[n,r,i,o,a,s]=t;return e[0]>n&&e[0]i&&e[1]a&&e[2].001||Math.abs(o[1])>.001||Math.abs(o[2])>.001){const t=[0,0,0],r=[0,0,0];Ci.R3.add(t,n.focalPoint,o),Ci.R3.add(r,n.position,o),e.setCamera({focalPoint:t,position:r}),e.render()}}(e,r),!0}class ss extends xi{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{targetViewportIds:[]}}){super(e,t)}mouseClickCallback(e){const{element:t,currentPoints:n}=e.detail,r=(0,Y.getEnabledElement)(t),{viewport:i,renderingEngine:o}=r,a=this.getTargetId(i);if(!a.startsWith("volumeId"))throw new Error("MIPJumpToClickTool: targetId is not a volumeId, you should only use MIPJumpToClickTool with a volumeId as the targetId");const s=a.split("volumeId:")[1];let l=-1/0;const c=rs(i,n.world,s,((e,t)=>{if(e>l)return l=e,t}));if(!c||!c.length)return;const{targetViewportIds:u,toolGroupId:d}=this.configuration;o.getViewports().filter((e=>{if(u?.indexOf(e.id)>=0)return!0;const t=Cm(e.id,o.id);return!(!d||d!==t?.id)})).forEach((e=>{e instanceof Y.VolumeViewport?as(e,c):console.warn("Cannot jump to specified world coordinates for a viewport that is not a VolumeViewport")}))}}ss.toolName="MIPJumpToClickTool";const ls=ss;var cs=n(45802);function us(e,t){const n=e.length,r=[];for(let i=0;i{const r=e.getCamera();return Math.abs(Ci.R3.dot(r.viewPlaneNormal,t.viewPlaneNormal))>n}))};function vs(e,t,n=!0){const r=(0,Y.getEnabledElement)(e),{renderingEngine:i,FrameOfReferenceUID:o}=r;let a=i.getViewports();a=us(a,o),a=fs(a,t);const s=i.getViewport(r.viewportId);n&&(a=gs(a,s.getCamera()));return a.map((e=>e.id))}const ys=1e-6,_s=1,bs=0;function Es(e,t,n){const[r,i]=n;if(Math.abs(t)0){if(o>i)return 0;o>r&&(n[0]=o)}else{if(o=n[0]&&o<=n[2]&&a>=n[1]&&a<=n[3])return _s;const d=[0,1];if(Es(n[0]-o,c,d)&&Es(o-n[2],-c,d)&&Es(n[1]-a,u,d)&&Es(a-n[3],-u,d)){const[e,t]=d;return t<1&&(i[0]=o+t*c,i[1]=a+t*u),e>0&&(r[0]+=e*c,r[1]+=e*u),_s}return bs}function xs(e,t){return(e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])}function Cs(e,t,n){const r=xs(e,t);if(0===r)return xs(n,e);const i=((n[0]-e[0])*(t[0]-e[0])+(n[1]-e[1])*(t[1]-e[1]))/r;if(i<0)return xs(n,e);if(i>1)return xs(n,t);return xs(n,[e[0]+i*(t[0]-e[0]),e[1]+i*(t[1]-e[1])])}function Ds(e,t,n){if(2!==e.length||2!==t.length||2!==n.length)throw Error("lineStart, lineEnd, and point should have 2 elements of [x, y]");return Math.sqrt(Cs(e,t,n))}function Ss(e){return"number"==typeof e?e?e<0?-1:1:e==e?0:NaN:NaN}function Ts(e,t,n,r){const[i,o]=e,[a,s]=t,[l,c]=n,[u,d]=r,h=s-o,p=i-a,f=a*o-i*s,m=h*l+p*c+f,g=h*u+p*d+f;if(0!==m&&0!==g&&Ss(m)===Ss(g))return;const v=d-c,y=l-u,_=u*c-l*d,b=v*i+y*o+_,E=v*a+y*s+_;if(0!==b&&0!==E&&Ss(b)===Ss(E))return;const w=h*y-v*p;let x;x=p*_-y*f;const C=x/w;x=v*f-h*_;return[C,x/w]}const{RENDERING_DEFAULTS:Is}=Y.CONSTANTS;function As(){return"rgb(0, 200, 0)"}function Ns(){return!0}function Os(){return!0}function Ps(){return!0}const ks=1,Ms=2,Ls=3;class Rs extends ho{constructor(e={},t={supportedInteractionTypes:["Mouse"],configuration:{shadow:!0,viewportIndicators:!0,autoPan:{enabled:!1,panSize:10},referenceLinesCenterGapRadius:20,filterActorUIDsToSetSlabThickness:[],slabThicknessBlendMode:Y.Enums.BlendModes.MAXIMUM_INTENSITY_BLEND,mobile:{enabled:!1,opacity:.8,handleRadius:9}}}){super(e,t),this.toolCenter=[0,0,0],this.initializeViewport=({renderingEngineId:e,viewportId:t})=>{const n=(0,Y.getEnabledElementByIds)(t,e),{FrameOfReferenceUID:r,viewport:i}=n,{element:o}=i,{position:a,focalPoint:s,viewPlaneNormal:l}=i.getCamera();let c=this._getAnnotations(n);c=this.filterInteractableAnnotationsForElement(o,c),c.length&&ag(c[0].annotationUID);return ig({highlighted:!1,metadata:{cameraPosition:[...a],cameraFocalPoint:[...s],FrameOfReferenceUID:r,toolName:this.getToolName()},data:{handles:{rotationPoints:[],slabThicknessPoints:[],toolCenter:this.toolCenter},activeOperation:null,activeViewportIds:[],viewportId:t}},o),{normal:l,point:i.canvasToWorld([i.canvas.clientWidth/2,i.canvas.clientHeight/2])}},this._getViewportsInfo=()=>$m(this.toolGroupId).viewportsInfo,this.computeToolCenter=e=>{if(!e.length||1===e.length)throw new Error("For crosshairs to operate, at least two viewports must be given.");const[t,n,r]=e,{normal:i,point:o}=this.initializeViewport(t),{normal:a,point:s}=this.initializeViewport(n);let l=[0,0,0],c=Ci.R3.create();r?({normal:l,point:c}=this.initializeViewport(r)):(Ci.R3.add(c,o,s),Ci.R3.scale(c,c,.5),Ci.R3.cross(l,i,a));const u=Y.utilities.planar.planeEquation(i,o),d=Y.utilities.planar.planeEquation(a,s),h=Y.utilities.planar.planeEquation(l,c);this.toolCenter=Y.utilities.planar.threePlaneIntersection(u,d,h);const{renderingEngine:p}=(0,Y.getEnabledElementByIds)(e[0].viewportId,e[0].renderingEngineId);Po(p,e.map((({viewportId:e})=>e)))},this.addNewAnnotation=e=>{const t=e.detail,{element:n}=t,{currentPoints:r}=t,i=r.world,o=(0,Y.getEnabledElement)(n),{viewport:a}=o;this._jump(o,i);const s=this._getAnnotations(o),l=this.filterInteractableAnnotationsForElement(a.element,s),{data:c}=l[0],{rotationPoints:u}=c.handles,d=[];for(let e=0;e{console.log("Not implemented yet")},this.handleSelectedCallback=(e,t)=>{const n=e.detail,{element:r}=n;t.highlighted=!0,this._activateModify(r),Ia(r),e.preventDefault()},this.isPointNearTool=(e,t,n,r)=>!!this._pointNearTool(e,t,n,6),this.toolSelectedCallback=(e,t,n)=>{const r=e.detail,{element:i}=r;t.highlighted=!0,this._activateModify(i),Ia(i),e.preventDefault()},this.onCameraModified=e=>{const t=e.detail,{element:n}=t,r=(0,Y.getEnabledElement)(n),{renderingEngine:i}=r,o=r.viewport,a=this._getAnnotations(r),s=this.filterInteractableAnnotationsForElement(n,a)[0];if(!s)return;const l=o.getCamera(),c=s.metadata.cameraPosition,u=[0,0,0];Ba.ZP.subtract(l.position,c,u);const d=s.metadata.cameraFocalPoint,h=[0,0,0];Ba.ZP.subtract(l.focalPoint,d,h),s.metadata.cameraPosition=[...l.position],s.metadata.cameraFocalPoint=[...l.focalPoint];const p=this._getReferenceLineControllable(o.id),f=this._getReferenceLineDraggableRotatable(o.id);if(!Y.utilities.isEqual(l.position,c,.001)&&p&&f){let e=!1;Y.utilities.isEqual(u,h,.001)||(e=!0);const t=Math.abs(Ba.ZP.dot(u,l.viewPlaneNormal))<.01;e||t||(this.toolCenter[0]+=u[0],this.toolCenter[1]+=u[1],this.toolCenter[2]+=u[2])}if(this.configuration.autoPan?.enabled){Cm(o.id,i.id).getViewportIds().filter((e=>e!==o.id)).forEach((e=>{this._autoPanViewportIfNecessary(e,i)}))}const m=vs(n,this.getToolName(),!1);Po(i,m)},this.mouseMoveCallback=(e,t)=>{const{element:n,currentPoints:r}=e.detail,i=r.canvas;let o=!1;for(let e=0;e0?[...a.activeViewportIds]:[];a.activeViewportIds=[],a.handles.activeOperation=null;let u=!1;u=!!this.getHandleNearImagePoint(n,r,i,6)||this._pointNearTool(n,r,i,6);u&&!s||!u&&s?(r.highlighted=!s,o=!0):a.handles.activeOperation===l&&this._areViewportIdArraysEqual(a.activeViewportIds,c)||(o=!0)}return o},this.filterInteractableAnnotationsForElement=(e,t)=>{if(!t||!t.length)return[];const n=(0,Y.getEnabledElement)(e),{viewportId:r}=n;return t.filter((e=>e.data.viewportId===r))},this.renderAnnotation=(e,t)=>{let n=!1;const{viewport:r,renderingEngine:i}=e,{element:o}=r,a=this._getAnnotations(e),s=r.getCamera(),l=this.filterInteractableAnnotationsForElement(o,a)[0];if(!a?.length||!l?.data)return n;const c=l.annotationUID,{clientWidth:u,clientHeight:d}=r.canvas,h=Math.sqrt(u*u+d*d),p=Math.min(u,d),f=l.data,m=r.worldToCanvas(this.toolCenter),g=this._filterAnnotationsByUniqueViewportOrientations(e,a),v=[],y=[0,0,u,d];g.forEach((e=>{const{data:t}=e;t.handles.toolCenter=this.toolCenter;const n=i.getViewport(t.viewportId),o=n.getCamera(),a=this._getReferenceLineControllable(n.id),l=this._getReferenceLineDraggableRotatable(n.id),c=this._getReferenceLineSlabThicknessControlsOn(n.id),{clientWidth:u,clientHeight:d}=n.canvas,f=Math.sqrt(u*u+d*d),_=[.5*u,.5*d],b=n.canvasToWorld(_),E=[0,0,0];Ba.ZP.cross(s.viewPlaneNormal,o.viewPlaneNormal,E),Ba.ZP.normalize(E),Ba.ZP.multiplyScalar(E,f);const w=[0,0,0];Ba.ZP.add(b,E,w);const x=[0,0,0];Ba.ZP.subtract(b,E,x);const C=r.worldToCanvas(w),D=r.worldToCanvas(b),S=Ci.K4.create();Ci.K4.subtract(S,C,D),Ci.K4.normalize(S,S);const T=Ci.K4.create();Ci.K4.scale(T,S,100*h);const I=Ci.K4.create();Ci.K4.scale(I,S,.4*p);const A=Ci.K4.create();Ci.K4.scale(A,S,.2*p);const N=Ci.K4.create(),O=this.configuration.referenceLinesCenterGapRadius;Ci.K4.scale(N,S,2===g.length?O:0);const P=Ci.K4.create(),k=Ci.K4.create(),M=Ci.K4.create(),L=Ci.K4.create();let R=Ci.K4.clone(m);l&&a||(R=Ci.K4.clone(D)),Ci.K4.add(P,R,N),Ci.K4.add(k,R,T),Ci.K4.subtract(M,R,N),Ci.K4.subtract(L,R,T),ws(P,k,y),ws(M,L,y);const F=Ci.K4.create();Ci.K4.subtract(F,m,I);const U=Ci.K4.create();Ci.K4.add(U,m,I);let B=Ci.K4.clone(m);!l&&c&&(B=Ci.K4.clone(D));let j=[...this.toolCenter];!l&&c&&(j=[...b]);const V=[0,0,0];Ba.ZP.subtract(w,x,V),Ba.ZP.normalize(V);const{viewPlaneNormal:W}=s,{matrix:z}=cs.Z.buildFromDegree().rotate(90,W),G=[0,0,0];Ci.R3.transformMat4(G,V,z);const H=n.getSlabThickness(),q=[...G];Ba.ZP.multiplyScalar(q,H);const K=[0,0,0];Ba.ZP.add(j,q,K);const X=r.worldToCanvas(K),$=Ci.K4.create();Ci.K4.subtract($,B,X);const J=Ci.K4.create();Ci.K4.subtract(J,B,T),Ci.K4.add(J,J,$);const Y=Ci.K4.create();Ci.K4.add(Y,B,T),Ci.K4.add(Y,Y,$),ws(J,Y,y);const Z=Ci.K4.create();Ci.K4.add(Z,B,T),Ci.K4.subtract(Z,Z,$);const Q=Ci.K4.create();Ci.K4.subtract(Q,B,T),Ci.K4.subtract(Q,Q,$),ws(Z,Q,y);const ee=Ci.K4.create(),te=Ci.K4.create(),ne=Ci.K4.create(),re=Ci.K4.create();Ci.K4.subtract(ee,B,A),Ci.K4.add(ee,ee,$),Ci.K4.add(te,B,A),Ci.K4.add(te,te,$),Ci.K4.subtract(ne,B,A),Ci.K4.subtract(ne,ne,$),Ci.K4.add(re,B,A),Ci.K4.subtract(re,re,$),v.push([n,P,k,M,L,J,Y,Z,Q,F,U,ee,te,ne,re])}));const _=[],b=[],E=this._getReferenceLineColor(r.id),w=void 0!==E?E:"rgb(200, 200, 200)";if(v.forEach(((e,n)=>{const i=e[0],o=this._getReferenceLineColor(i.id),a=this._getReferenceLineControllable(i.id),s=this._getReferenceLineDraggableRotatable(i.id)||this.configuration.mobile?.enabled,l=this._getReferenceLineSlabThicknessControlsOn(i.id)||this.configuration.mobile?.enabled,u=f.activeViewportIds.find((e=>e===i.id));let d=void 0!==o?o:"rgb(200, 200, 200)",h=1;const p=null!==f.handles.activeOperation&&f.handles.activeOperation===ks&&u;p&&(h=2.5);let m=`${n}`;if(a&&s?(m=`${n}One`,Ui(t,c,m,e[1],e[2],{color:d,lineWidth:h}),m=`${n}Two`,Ui(t,c,m,e[3],e[4],{color:d,lineWidth:h})):Ui(t,c,m,e[2],e[4],{color:d,lineWidth:h}),a){d=void 0!==o?o:"rgb(200, 200, 200)";const a=f.handles.activeOperation===Ms,h=[e[9],e[10]],g=[r.canvasToWorld(e[9]),i,e[1],e[2]],v=[r.canvasToWorld(e[10]),i,e[3],e[4]];_.push(g,v);const y=f.handles.activeOperation===Ls,E=[e[11],e[12],e[13],e[14]],w=[r.canvasToWorld(e[11]),i,e[5],e[6]],x=[r.canvasToWorld(e[12]),i,e[5],e[6]],C=[r.canvasToWorld(e[13]),i,e[7],e[8]],D=[r.canvasToWorld(e[14]),i,e[7],e[8]];if(b.push(w,x,C,D),(p||this.configuration.mobile?.enabled)&&!a&&!y&&s&&l){let e=`${n}One`;Fi(t,c,e,h,{color:d,handleRadius:this.configuration.mobile?.enabled?this.configuration.mobile?.handleRadius:3,opacity:this.configuration.mobile?.enabled?this.configuration.mobile?.opacity:1,type:"circle"}),e=`${n}Two`,Fi(t,c,e,E,{color:d,handleRadius:this.configuration.mobile?.enabled?this.configuration.mobile?.handleRadius:3,opacity:this.configuration.mobile?.enabled?this.configuration.mobile?.opacity:1,type:"rect"})}else if(p&&!a&&!y&&s){Fi(t,c,`${n}`,h,{color:d,handleRadius:this.configuration.mobile?.enabled?this.configuration.mobile?.handleRadius:3,opacity:this.configuration.mobile?.enabled?this.configuration.mobile?.opacity:1,type:"circle"})}else if(u&&!a&&!y&&l){Fi(t,c,`${n}`,E,{color:d,handleRadius:this.configuration.mobile?.enabled?this.configuration.mobile?.handleRadius:3,opacity:this.configuration.mobile?.enabled?this.configuration.mobile?.opacity:1,type:"rect"})}else if(a&&s){Fi(t,c,`${n}`,h,{color:d,handleRadius:2,fill:d,type:"circle"})}else y&&u&&l&&Fi(t,c,m,E,{color:d,handleRadius:2,fill:d,type:"rect"});i.getSlabThickness()>.5&&l&&(m=`${n}STOne`,Ui(t,c,m,e[5],e[6],{color:d,width:1,lineDash:[2,3]}),m=`${n}STTwo`,Ui(t,c,m,e[7],e[8],{color:d,width:e,lineDash:[2,3]}))}})),n=!0,f.handles.rotationPoints=_,f.handles.slabThicknessPoints=b,this.configuration.viewportIndicators){Li(t,c,"0",[.95*u,.05*d],.01*h,{color:w,fill:w})}return n},this._getAnnotations=e=>{const{viewport:t}=e;return rg(this.getToolName(),t.element)},this._onNewVolume=e=>{const t=this._getViewportsInfo();this.computeToolCenter(t)},this._areViewportIdArraysEqual=(e,t)=>e.length===t.length&&(e.forEach((e=>{let n=!1;for(let r=0;r{const{viewportId:n,renderingEngine:r,viewport:i}=e,o=t.filter((e=>e.data.viewportId!==n));if(!o||!o.length)return[];const a=i.getCamera(),{viewPlaneNormal:s,position:l}=a,c=o.filter((e=>{const{viewportId:t}=e.data,n=r.getViewport(t).getCamera();return!(Y.utilities.isEqual(n.viewPlaneNormal,s,.01)&&Y.utilities.isEqual(n.position,l,1))}));return c},this._filterViewportWithSameOrientation=(e,t,n)=>{const{renderingEngine:r}=e,{data:i}=t,o=r.getViewport(i.viewportId),a=n.filter((e=>{const{data:t}=e,n=r.getViewport(t.viewportId);return!0===this._getReferenceLineControllable(n.id)}));if(!a||!a.length)return[];const s=o.getCamera(),l=s.viewPlaneNormal;Ba.ZP.normalize(l);return a.filter((e=>{const{viewportId:t}=e.data,n=r.getViewport(t).getCamera(),i=n.viewPlaneNormal;return Ba.ZP.normalize(i),Y.utilities.isEqual(l,i,.01)&&Y.utilities.isEqual(s.viewUp,n.viewUp,.01)}))},this._filterAnnotationsByUniqueViewportOrientations=(e,t)=>{const{renderingEngine:n,viewport:r}=e,i=r.getCamera().viewPlaneNormal;Ba.ZP.normalize(i);const o=t.filter((e=>{const{data:t}=e,i=n.getViewport(t.viewportId),o=this._getReferenceLineControllable(i.id);return r!==i&&!0===o})),a=[];for(let e=0;e{const{data:t}=e,i=n.getViewport(t.viewportId),o=this._getReferenceLineControllable(i.id);return r!==i&&!0!==o}));for(let e=0;ee===t)))continue;const{viewportId:r}=t.data,o=n.getViewport(r).getCamera(),s=o.viewPlaneNormal;if(Ba.ZP.normalize(s),Y.utilities.isEqual(i,s,.01)||Y.utilities.isOpposite(i,s,.01))continue;let c=!1;for(let e=0;e{const n=e.getActors(),r=t.getActors();let i=!0;return n.forEach((e=>{n.length===r.length&&void 0!==r.find((({uid:t})=>t===e.uid))||(i=!1)})),i},this._jump=(e,t)=>{He.isInteractingWithTool=!0;const{viewport:n,renderingEngine:r}=e,i=this._getAnnotations(e),o=[0,0,0];Ba.ZP.subtract(t,this.toolCenter,o);const a=this._getAnnotationsForViewportsWithDifferentCameras(e,i).filter((e=>{const{data:t}=e,i=r.getViewport(t.viewportId),o=this._checkIfViewportsRenderingSameScene(n,i);return this._getReferenceLineControllable(i.id)&&this._getReferenceLineDraggableRotatable(i.id)&&o}));return 0===a.length?(He.isInteractingWithTool=!1,!1):(this._applyDeltaShiftToSelectedViewportCameras(r,a,o),He.isInteractingWithTool=!1,!0)},this._activateModify=e=>{He.isInteractingWithTool=!this.configuration.mobile?.enabled,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback)},this._deactivateModify=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback)},this._endCallback=e=>{const t=e.detail,{element:n}=t;this.editData.annotation.data.handles.activeOperation=null,this.editData.annotation.data.activeViewportIds=[],this._deactivateModify(n),Ta(n),this.editData=null;const r=(0,Y.getEnabledElement)(n),{renderingEngine:i}=r,o=vs(n,this.getToolName(),!1);Po(i,o)},this._dragCallback=e=>{const t=e.detail,n=t.deltaPoints.world;if(Math.abs(n[0])<.001&&Math.abs(n[1])<.001&&Math.abs(n[2])<.001)return;const{element:r}=t,i=(0,Y.getEnabledElement)(r),{renderingEngine:o,viewport:a}=i,s=this._getAnnotations(i),l=this.filterInteractableAnnotationsForElement(r,s)[0];if(!l)return;const{handles:c}=l.data,{currentPoints:u}=e.detail,d=u.canvas;if(c.activeOperation===ks){const e=this._getAnnotationsForViewportsWithDifferentCameras(i,s).filter((e=>{const{data:t}=e,n=o.getViewport(t.viewportId),r=this._getReferenceLineControllable(n.id),i=this._getReferenceLineDraggableRotatable(n.id);return!0===r&&!0===i&&l.data.activeViewportIds.find((e=>e===n.id))}));this._applyDeltaShiftToSelectedViewportCameras(o,e,n)}else if(c.activeOperation===Ms){const e=this._getAnnotationsForViewportsWithDifferentCameras(i,s).filter((e=>{const{data:t}=e,n=o.getViewport(t.viewportId),r=this._getReferenceLineControllable(n.id),i=this._getReferenceLineDraggableRotatable(n.id);return!0===r&&!0===i})),n=Ci.K4.create(),r=Ci.K4.create(),l=[this.toolCenter[0],this.toolCenter[1],this.toolCenter[2]],c=a.worldToCanvas(l),u=t.currentPoints.canvas,d=Ci.K4.create();Ci.K4.sub(d,u,t.deltaPoints.canvas),Ci.K4.sub(n,d,c),Ci.K4.sub(r,u,c);let h=Ci.K4.angle(n,r);this._isClockWise(c,d,u)&&(h*=-1),h=Math.round(100*h)/100;const p=a.getCamera().viewPlaneNormal,{matrix:f}=cs.Z.buildFromRadian().translate(l[0],l[1],l[2]).rotate(h,p).translate(-l[0],-l[1],-l[2]),m=[];e.forEach((e=>{const{data:t}=e;t.handles.toolCenter=l;const n=o.getViewport(t.viewportId),r=n.getCamera(),{viewUp:i,position:a,focalPoint:s}=r;i[0]+=a[0],i[1]+=a[1],i[2]+=a[2],Ci.R3.transformMat4(s,s,f),Ci.R3.transformMat4(a,a,f),Ci.R3.transformMat4(i,i,f),i[0]-=a[0],i[1]-=a[1],i[2]-=a[2],n.setCamera({position:a,viewUp:i,focalPoint:s}),m.push(n.id)})),o.renderViewports(m)}else if(c.activeOperation===Ls){const e=this._getAnnotationsForViewportsWithDifferentCameras(i,s).filter((e=>{const{data:t}=e,n=o.getViewport(t.viewportId),r=this._getReferenceLineControllable(n.id),i=this._getReferenceLineSlabThicknessControlsOn(n.id);return!0===r&&!0===i&&l.data.activeViewportIds.find((e=>e===n.id))}));if(0===e.length)return;const r=this._filterViewportWithSameOrientation(i,e[0],s),c=[];c.push(a.id),r.forEach((e=>{const{data:r}=e,i=o.getViewport(r.viewportId),s=i.getCamera().viewPlaneNormal,u=Ba.ZP.dot(n,s),h=[...s];if(Ba.ZP.multiplyScalar(h,u),Math.abs(h[0])>.001||Math.abs(h[1])>.001||Math.abs(h[2])>.001){const e=Math.sqrt(h[0]*h[0]+h[1]*h[1]+h[2]*h[2]),n=t.lastPoints.world,r=[0,0,0],u=[this.toolCenter[0],this.toolCenter[1],this.toolCenter[2]];if(!this._getReferenceLineDraggableRotatable(i.id)){const{rotationPoints:e}=this.editData.annotation.data.handles,t=e.filter((e=>e[1].uid===i.id));if(2===t.length){const e=a.canvasToWorld(t[0][3]),n=a.canvasToWorld(t[1][3]);Ba.ZP.add(e,n,u),Ba.ZP.multiplyScalar(u,.5)}}Ba.ZP.subtract(n,u,r);const p=Ba.ZP.dot(r,s),f=[...s];Ba.ZP.multiplyScalar(f,p);const m=[f[0],f[1],f[2]];Ci.R3.normalize(m,m);const g=[h[0],h[1],h[2]];Ci.R3.normalize(g,g);let v=i.getSlabThickness();Y.utilities.isOpposite(m,g,.001)?v-=e:v+=e,v=Math.abs(v),v=Math.max(Is.MINIMUM_SLAB_THICKNESS,v);this._pointNearReferenceLine(l,d,6,i)&&(v=Is.MINIMUM_SLAB_THICKNESS);Cm(i.id,o.id).getToolInstance(this.getToolName()).setSlabThickness(i,v),c.push(i.id)}})),o.renderViewports(c)}},this._pointNearReferenceLine=(e,t,n,r)=>{const{data:i}=e,{rotationPoints:o}=i.handles;for(let e=0;e{const n=(0,Y.getEnabledElementByIds)(t,e);if(!n)return;const r=this._getAnnotations(n);r?.length&&r.forEach((e=>{ag(e.annotationUID)}))}))}getHandleNearImagePoint(e,t,n,r){const i=(0,Y.getEnabledElement)(e),{viewport:o}=i;let a=this._getRotationHandleNearImagePoint(o,t,n,r);return null!==a?a:(a=this._getSlabThicknessHandleNearImagePoint(o,t,n,r),null!==a?a:void 0)}_unsubscribeToViewportNewVolumeSet(e){e.forEach((({viewportId:e,renderingEngineId:t})=>{const{viewport:n}=(0,Y.getEnabledElementByIds)(e,t),{element:r}=n;r.removeEventListener(Y.Enums.Events.VOLUME_VIEWPORT_NEW_VOLUME,this._onNewVolume)}))}_subscribeToViewportNewVolumeSet(e){e.forEach((({viewportId:e,renderingEngineId:t})=>{const{viewport:n}=(0,Y.getEnabledElementByIds)(e,t),{element:r}=n;r.addEventListener(Y.Enums.Events.VOLUME_VIEWPORT_NEW_VOLUME,this._onNewVolume)}))}_autoPanViewportIfNecessary(e,t){const n=t.getViewport(e),{clientWidth:r,clientHeight:i}=n.canvas,o=n.worldToCanvas(this.toolCenter),a=this.configuration.autoPan.panSize,s=[o[0],o[1]];if(o[0]<0?s[0]=a:o[0]>r&&(s[0]=r-a),o[1]<0?s[1]=a:o[1]>i&&(s[1]=i-a),s[0]===o[0]&&s[1]===o[1])return;const l=n.canvasToWorld(s),c=[l[0]-this.toolCenter[0],l[1]-this.toolCenter[1],l[2]-this.toolCenter[2]],u=n.getCamera(),{focalPoint:d,position:h}=u,p=[h[0]-c[0],h[1]-c[1],h[2]-c[2]],f=[d[0]-c[0],d[1]-c[1],d[2]-c[2]];n.setCamera({focalPoint:f,position:p}),n.render()}setSlabThickness(e,t){let n;const{filterActorUIDsToSetSlabThickness:r}=this.configuration;r&&r.length>0&&(n=r);let i=this.configuration.slabThicknessBlendMode;t===Is.MINIMUM_SLAB_THICKNESS&&(i=Y.Enums.BlendModes.COMPOSITE);e.setBlendMode(i,n,!1),e.setSlabThickness(t,n)}_isClockWise(e,t,n){return(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0])>0}_applyDeltaShiftToSelectedViewportCameras(e,t,n){t.forEach((t=>{this._applyDeltaShiftToViewportCamera(e,t,n)}))}_applyDeltaShiftToViewportCamera(e,t,n){const{data:r}=t,i=e.getViewport(r.viewportId),o=i.getCamera(),a=o.viewPlaneNormal,s=Ba.ZP.dot(n,a),l=[...a];if(Ba.ZP.multiplyScalar(l,s),Math.abs(l[0])>.001||Math.abs(l[1])>.001||Math.abs(l[2])>.001){const e=[0,0,0],t=[0,0,0];Ba.ZP.add(o.focalPoint,l,e),Ba.ZP.add(o.position,l,t),i.setCamera({focalPoint:e,position:t}),i.render()}}_getRotationHandleNearImagePoint(e,t,n,r){const{data:i}=t,{rotationPoints:o}=i.handles;for(let a=0;ae===t.id)))continue;const i=this._getReferenceLineControllable(t.id),o=this._getReferenceLineSlabThicknessControlsOn(t.id);if(!i||!o)continue;const a=d[e][2],s=d[e][3],u=Ci.K4.create();Ci.K4.add(u,a,s),Ci.K4.scale(u,u,.5);const p=Ci.K4.create();Ci.K4.subtract(p,a,u),Ci.K4.normalize(p,p);const f=Ci.K4.create();Ci.K4.scale(f,p,.05*l);const m=Ci.K4.create(),g=Ci.K4.create();Ci.K4.add(m,u,f),Ci.K4.subtract(g,u,f);const v={start:{x:m[0],y:m[1]},end:{x:a[0],y:a[1]}},y=Ds([v.start.x,v.start.y],[v.end.x,v.end.y],[n[0],n[1]]),_={start:{x:g[0],y:g[1]},end:{x:s[0],y:s[1]}},b=Ds([_.start.x,_.start.y],[_.end.x,_.end.y],[n[0],n[1]]);(y<=r||b<=r)&&(h.push(t.id),c.handles.activeOperation=null),e++}return c.activeViewportIds=[...h],this.editData={annotation:t},c.handles.activeOperation===ks}}Rs.toolName="Crosshairs";const Fs=Rs,Us="magnify-viewport";class Bs extends xi{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{magnifySize:10,magnifyWidth:250,magnifyHeight:250}}){super(e,t),this.preMouseDownCallback=e=>{const t=e.detail,{element:n,currentPoints:r}=t,i=(0,Y.getEnabledElement)(n),{viewport:o,renderingEngine:a}=i;if(!(o instanceof Y.StackViewport))throw new Error("MagnifyTool only works on StackViewports");const s=this._getReferencedImageId(o);if(!s)throw new Error("MagnifyTool: No referenced image id found, reconstructed planes not supported yet");const l=vs(n,this.getToolName());return this.editData={referencedImageId:s,viewportIdsToRender:l,enabledElement:i,renderingEngine:a,currentPoints:r},this._createMagnificationViewport(),this._activateDraw(n),Ia(n),e.preventDefault(),Po(a,l),!0},this.preTouchStartCallback=e=>{this.preMouseDownCallback(e)},this._createMagnificationViewport=()=>{const{enabledElement:e,referencedImageId:t,viewportIdsToRender:n,renderingEngine:r,currentPoints:i}=this.editData,{viewport:o}=e,{element:a}=o,{voiRange:s}=o.getProperties(),{canvas:l,world:c}=i;let u;if(u=a.querySelector(".magnifyTool"),null===u){const e=document.createElement("div");e.classList.add("magnifyTool"),e.style.display="block",e.style.width=`${this.configuration.magnifyWidth}px`,e.style.height=`${this.configuration.magnifyHeight}px`,e.style.position="absolute",u=e;a.querySelector(".viewport-element").appendChild(e);const t={viewportId:Us,type:Y.Enums.ViewportType.STACK,element:u};r.enableElement(t)}u.style.top=l[1]-this.configuration.magnifyHeight/2+"px",u.style.left=l[0]-this.configuration.magnifyWidth/2+"px";const d=r.getViewport(Us);d.setStack([t]).then((()=>{d.setProperties({voiRange:s});const{parallelScale:e}=o.getCamera(),{focalPoint:t,position:n,viewPlaneNormal:r}=d.getCamera(),i=Math.sqrt(Math.pow(t[0]-n[0],2)+Math.pow(t[1]-n[1],2)+Math.pow(t[2]-n[2],2)),a=[c[0],c[1],c[2]],l=[a[0]+i*r[0],a[1]+i*r[1],a[2]+i*r[2]];d.setCamera({parallelScale:e*(1/this.configuration.magnifySize),focalPoint:a,position:l}),d.render()})),u.style.display="block",Po(r,n)},this._dragCallback=e=>{const t=e.detail,{deltaPoints:n,element:r,currentPoints:i}=t,o=n.world,a=i.canvas,s=(0,Y.getEnabledElement)(r),{renderingEngine:l}=s,c=l.getViewport(Us),u=r.querySelector(".magnifyTool");if(!u)return;u.style.top=a[1]-this.configuration.magnifyHeight/2+"px",u.style.left=a[0]-this.configuration.magnifyWidth/2+"px";const{focalPoint:d,position:h}=c.getCamera(),p=[h[0]+o[0],h[1]+o[1],h[2]+o[2]],f=[d[0]+o[0],d[1]+o[1],d[2]+o[2]];c.setCamera({focalPoint:f,position:p}),c.render()},this._dragEndCallback=e=>{const{element:t}=e.detail,n=(0,Y.getEnabledElement)(t),{renderingEngine:r}=n;r.disableElement(Us);const i=t.querySelector(".viewport-element"),o=i.querySelector(".magnifyTool");i.removeChild(o),this._deactivateDraw(t),Ta(t)},this._activateDraw=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._dragEndCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragCallback),e.addEventListener(ne.MOUSE_CLICK,this._dragEndCallback),e.addEventListener(ne.TOUCH_END,this._dragEndCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragCallback)},this._deactivateDraw=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._dragEndCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._dragEndCallback),e.removeEventListener(ne.TOUCH_END,this._dragEndCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragCallback)}}_getReferencedImageId(e){const t=this.getTargetId(e);let n;return e instanceof Y.StackViewport&&(n=t.split("imageId:")[1]),n}}Bs.toolName="Magnify";const js=Bs,{EPSILON:Vs}=Y.CONSTANTS;class Ws extends co{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{sourceViewportId:"",showFullDimension:!1}}){super(e,t),this.editData={},this._init=()=>{const e=(0,Y.getRenderingEngines)()[0];if(!e)return;let t=e.getViewports();t=fs(t,this.getToolName());const n=e.getViewport(this.configuration.sourceViewportId);if(!n||!n.getImageData())return;const{element:r}=n,{viewUp:i,viewPlaneNormal:o}=n.getCamera(),a=Y.utilities.getViewportImageCornersInWorld(n);let s=this.editData.annotation;const l=n.getFrameOfReferenceUID();if(s)this.editData.annotation.data.handles.points=a;else{const e={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...o],viewUp:[...i],FrameOfReferenceUID:l,referencedImageId:null},data:{handles:{points:a}}};ig(e,r),s=e}this.editData={sourceViewport:n,renderingEngine:e,annotation:s},Po(e,t.filter((e=>e.id!==n.id)).map((e=>e.id)))},this.onSetToolEnabled=()=>{this._init()},this.onCameraModified=e=>{this._init()},this.renderAnnotation=(e,t)=>{const{viewport:n}=e,{annotation:r,sourceViewport:i}=this.editData;let o=!1;if(!i)return o;if(i.id===n.id)return o;if(!r||!r?.data?.handles?.points)return o;const a={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id},s=r.data.handles.points[0],l=r.data.handles.points[1],c=r.data.handles.points[2],u=r.data.handles.points[3],{focalPoint:d,viewPlaneNormal:h,viewUp:p}=n.getCamera(),{viewPlaneNormal:f}=i.getCamera();if(this.isParallel(h,f))return o;const m=Y.utilities.planar.planeEquation(h,d),g=[s,c,l,u],v=[s,l,c,u];let y=g,_=Ci.R3.subtract(Ci.R3.create(),g[0],g[1]);_=Ci.R3.normalize(Ci.R3.create(),_);let b=Ci.R3.subtract(Ci.R3.create(),g[2],g[0]);b=Ci.R3.normalize(Ci.R3.create(),b);const E=Ci.R3.cross(Ci.R3.create(),_,b);if(this.isParallel(E,h))return o;this.isPerpendicular(_,h)&&(y=v);const w=Y.utilities.planar.linePlaneIntersection(y[0],y[1],m),x=Y.utilities.planar.linePlaneIntersection(y[2],y[3],m),{annotationUID:C}=r;a.annotationUID=C;const D=this.getStyle("lineWidth",a,r),S=this.getStyle("lineDash",a,r),T=this.getStyle("color",a,r),I=this.getStyle("shadow",a,r);let A=[w,x].map((e=>n.worldToCanvas(e)));this.configuration.showFullDimension&&(A=this.handleFullDimension(n,w,h,p,x,A));const N=`${C}-line`;return Ui(t,C,"1",A[0],A[1],{color:T,width:D,lineDash:S,shadow:I},N),o=!0,o},this.isPerpendicular=(e,t)=>{const n=Ci.R3.dot(e,t);return Math.abs(n)Y.utilities.worldToImageCoords(c,e))),[h,p]=[t,i].map((e=>Y.utilities.worldToImageCoords(c,e)));o=[[a,s],[s,u],[d,u],[a,d]].map((([e,t])=>this.intersectInfiniteLines(e,t,h,p))).filter((e=>e&&this.isInBound(e,r))).map((t=>{const n=Y.utilities.imageToWorldCoords(c,t);return e.worldToCanvas(n)}))}catch(e){console.log(e)}return o}intersectInfiniteLines(e,t,n,r){const[i,o]=e,[a,s]=t,[l,c]=n,[u,d]=r,h=s-o,p=i-a,f=a*o-i*s,m=d-c,g=l-u,v=u*c-l*d;if(Math.abs(h*g-m*p)1-Vs}isInBound(e,t){return e[0]>=0&&e[0]<=t[0]&&e[1]>=0&&e[1]<=t[1]}}Ws.toolName="ReferenceLines";const zs=Ws,{EPSILON:Gs}=Y.CONSTANTS;class Hs extends co{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{sourceImageIds:[]}}){super(e,t),this.onSetToolEnabled=()=>{this._init()},this.onSetToolActive=()=>{this._init()},this._init=()=>{const e=this.configuration.sourceImageIds;if(!e?.length)return void console.warn("OverlayGridTool: No sourceImageIds provided in configuration");const t=Y.metaData.get("imagePlaneModule",e[0]);if(!t)return void console.warn("OverlayGridTool: No imagePlaneModule found for sourceImageIds");const{frameOfReferenceUID:n}=t,r=$m(this.toolGroupId).viewportsInfo;if(!r?.length)return void console.warn("OverlayGridTool: No viewports found");const i=rg(this.getToolName(),n);if(!i?.length){const t=e.map((e=>this.calculateImageIdPointSets(e)));ig({highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),FrameOfReferenceUID:n,referencedImageId:null},data:{viewportData:new Map,pointSets:t}},n)}Po((0,Y.getRenderingEngine)(r[0].renderingEngineId),r.map((({viewportId:e})=>e)))},this.calculateImageIdPointSets=e=>{const{imagePositionPatient:t,rows:n,columns:r,rowCosines:i,columnCosines:o,rowPixelSpacing:a,columnPixelSpacing:s}=Y.metaData.get("imagePlaneModule",e),l=[...t],c=[...t],u=[...t],d=[...t];Ci.R3.scaleAndAdd(c,t,o,r*s),Ci.R3.scaleAndAdd(u,t,i,n*a),Ci.R3.scaleAndAdd(d,u,o,r*s);return{pointSet1:[l,u,c,d],pointSet2:[l,c,u,d]}},this.renderAnnotation=(e,t)=>{const n=this.configuration.sourceImageIds;let r=!1;if(!n?.length)return r;const{viewport:i,FrameOfReferenceUID:o}=e;if(i.getImageIds().length<2)return r;const a=rg(this.getToolName(),o);if(!a?.length)return r;const s=a[0],{annotationUID:l}=s,{focalPoint:c,viewPlaneNormal:u}=i.getCamera(),d={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id},h=this.getImageIdNormal(n[0]);if(this.isParallel(u,h))return r;const p=Y.utilities.planar.planeEquation(u,c),f=s.data.pointSets,m=s.data.viewportData;for(let e=0;ei.worldToCanvas(e))),b=`${l}-line`;Ui(t,l,`${e}`,_[0],_[1],{color:v,width:h,lineDash:g,shadow:y},b)}return r=!0,r},this.initializeViewportData=(e,t)=>(e.set(t,{pointSetsToUse:[],lineStartsWorld:[],lineEndsWorld:[]}),e.get(t)),this.isPerpendicular=(e,t)=>{const n=Ci.R3.dot(e,t);return Math.abs(n)1-Gs}getImageIdNormal(e){const{imageOrientationPatient:t}=Y.metaData.get("imagePlaneModule",e),n=Ci.R3.fromValues(t[0],t[1],t[2]),r=Ci.R3.fromValues(t[3],t[4],t[5]);return Ci.R3.cross(Ci.R3.create(),n,r)}}Hs.toolName="OverlayGrid";const qs=Hs,{CalibrationTypes:Ks}=Y.Enums,Xs="px",$s=(e,t)=>{const{calibration:n,hasPixelSpacing:r}=t,i=r?"mm":Xs;return n&&n.type?n.type===Ks.UNCALIBRATED?Xs:n.SequenceOfUltrasoundRegions?"US Region":`${i} ${n.type}`:i},Js=(e,t)=>{const{calibration:n,hasPixelSpacing:r}=t,i=(r?"mm":Xs)+"²";return n&&n.type?n.SequenceOfUltrasoundRegions?"US Region":`${i} ${n.type}`:i},Ys=e=>e.calibration?.scale||1,Zs=e=>e.calibration?.aspect||1;function Qs(e){const t=function(e){const t=[e[0],e[1]].sort(a),n=[e[0],e[1]].sort(s),r=t[t.length-1],i=n[0],o=n[n.length-1];return{top:i,bottom:o,right:r};function a(e,t){return e[0]{const i=(0,Y.getEnabledElement)(e),{viewport:o}=i,{data:a}=t,{points:s}=a.handles;let l=o.worldToCanvas(s[0]),c=o.worldToCanvas(s[1]),u={start:{x:l[0],y:l[1]},end:{x:c[0],y:c[1]}},d=Ds([u.start.x,u.start.y],[u.end.x,u.end.y],[n[0],n[1]]);return d<=r||(l=o.worldToCanvas(s[2]),c=o.worldToCanvas(s[3]),u={start:{x:l[0],y:l[1]},end:{x:c[0],y:c[1]}},d=Ds([u.start.x,u.start.y],[u.end.x,u.end.y],[n[0],n[1]]),d<=r)},this.toolSelectedCallback=(e,t)=>{const n=e.detail,{element:r}=n;t.highlighted=!0;const i=vs(r,this.getToolName());this.editData={annotation:t,viewportIdsToRender:i,movingTextBox:!1},this._activateModify(r);const o=(0,Y.getEnabledElement)(r),{renderingEngine:a}=o;Po(a,i),Ia(r),e.preventDefault()},this.handleSelectedCallback=(e,t,n)=>{const r=e.detail,{element:i}=r,o=t.data;t.highlighted=!0;let a,s=!1;n.worldPosition?s=!0:a=o.handles.points.findIndex((e=>e===n));const l=vs(i,this.getToolName());Ia(i),this.editData={annotation:t,viewportIdsToRender:l,handleIndex:a,movingTextBox:s},this._activateModify(i);const c=(0,Y.getEnabledElement)(i),{renderingEngine:u}=c;Po(u,l),e.preventDefault()},this._endCallback=e=>{const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,newAnnotation:o,hasMoved:a}=this.editData,{data:s}=r;if(o&&!a)return;s.handles.activeHandleIndex=null,this._deactivateModify(n),this._deactivateDraw(n),Ta(n);const l=(0,Y.getEnabledElement)(n),{renderingEngine:c}=l;if(void 0!==this.editData.handleIndex){const{points:e}=s.handles,t=Ci.R3.distance(e[0],e[1]);if(Ci.R3.distance(e[2],e[3])>t){const t=[[...e[2]],[...e[3]]],n=[...e[0]],r=[...e[1]],i=Ci.K4.create();Ci.K4.set(i,t[1][0]-t[0][0],t[1][1]-t[1][0]);const o=Ci.K4.create();Ci.K4.set(o,-i[1],i[0]);const a=Ci.K4.create();let l;Ci.K4.set(a,r[0]-n[0],r[1]-n[0]),l=Ci.K4.dot(a,o)>0?[n,r]:[r,n],s.handles.points=[t[0],t[1],l[0],l[1]]}}if(this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&ag(r.annotationUID),Po(c,i),o){const e=ne.ANNOTATION_COMPLETED,t={annotation:r};(0,Y.triggerEvent)(Y.eventTarget,e,t)}this.editData=null,this.isDrawing=!1},this._dragDrawCallback=e=>{this.isDrawing=!0;const t=e.detail,{currentPoints:n,element:r}=t,i=(0,Y.getEnabledElement)(r),{renderingEngine:o,viewport:a}=i,{worldToCanvas:s}=a,{annotation:l,viewportIdsToRender:c,handleIndex:u}=this.editData,{data:d}=l,h=n.world;d.handles.points[u]=[...h];const p=d.handles.points.map(s),f={start:{x:p[0][0],y:p[0][1]},end:{x:p[1][0],y:p[1][1]}},m=(p[2][0],p[2][1],p[3][0],p[3][1],Ci.K4.distance(p[0],p[1])/3),g=f.start.x-f.end.x,v=f.start.y-f.end.y,y=Math.sqrt(g*g+v*v),_=g/y,b=v/y,E=(f.start.x+f.end.x)/2,w=(f.start.y+f.end.y)/2,x=E+m*b,C=w-m*_,D=E-m*b,S=w+m*_;d.handles.points[2]=a.canvasToWorld([x,C]),d.handles.points[3]=a.canvasToWorld([D,S]),l.invalidated=!0,Po(o,c),this.editData.hasMoved=!0},this._dragModifyCallback=e=>{this.isDrawing=!0;const t=e.detail,{element:n}=t,r=(0,Y.getEnabledElement)(n),{renderingEngine:i}=r,{annotation:o,viewportIdsToRender:a,handleIndex:s,movingTextBox:l}=this.editData,{data:c}=o;if(l){const{deltaPoints:e}=t,n=e.world,{textBox:r}=c.handles,{worldPosition:i}=r;i[0]+=n[0],i[1]+=n[1],i[2]+=n[2],r.hasMoved=!0}else if(void 0===s){const{deltaPoints:e}=t,n=e.world;c.handles.points.forEach((e=>{e[0]+=n[0],e[1]+=n[1],e[2]+=n[2]})),o.invalidated=!0}else this._dragModifyHandle(e),o.invalidated=!0;Po(i,a)},this._dragModifyHandle=e=>{const t=e.detail,{currentPoints:n,element:r}=t,i=(0,Y.getEnabledElement)(r),{viewport:o}=i,{annotation:a,handleIndex:s}=this.editData,{data:l}=a,c=n.world,u=[o.worldToCanvas(l.handles.points[0]),o.worldToCanvas(l.handles.points[1]),o.worldToCanvas(l.handles.points[2]),o.worldToCanvas(l.handles.points[3])],d={start:{x:u[0][0],y:u[0][1]},end:{x:u[1][0],y:u[1][1]}},h={start:{x:u[2][0],y:u[2][1]},end:{x:u[3][0],y:u[3][1]}},p=[...c],f=o.worldToCanvas(p);if(0===s||1===s){const e=u[0===s?1:0],t=Ci.K4.set(Ci.K4.create(),f[0]-e[0],f[1]-e[1]),n=Ci.K4.set(Ci.K4.create(),u[s][0]-e[0],u[s][1]-e[1]);Ci.K4.normalize(t,t),Ci.K4.normalize(n,n);const r={start:{x:e[0],y:e[1]},end:{x:f[0],y:f[1]}};if(this._movingLongAxisWouldPutItThroughShortAxis(r,h))return;const i=e,a=this._getSignedAngle(n,t);let c=u[2][0],d=u[2][1],m=u[3][0],g=u[3][1];c-=i[0],d-=i[1],m-=i[0],g-=i[1];const v=c*Math.cos(a)-d*Math.sin(a),y=c*Math.sin(a)+d*Math.cos(a),_=m*Math.cos(a)-g*Math.sin(a),b=m*Math.sin(a)+g*Math.cos(a);c=v+i[0],d=y+i[1],m=_+i[0],g=b+i[1];const E=o.canvasToWorld([c,d]),w=o.canvasToWorld([m,g]);l.handles.points[s]=p,l.handles.points[2]=E,l.handles.points[3]=w}else{const e=2===s?3:2,t={longLineSegment:{start:d.start,end:d.end},shortLineSegment:{start:h.start,end:h.end}},n=Ci.K4.subtract(Ci.K4.create(),[t.longLineSegment.end.x,t.longLineSegment.end.y],[t.longLineSegment.start.x,t.longLineSegment.start.y]),r=Ci.K4.normalize(Ci.K4.create(),n),i=Ci.K4.subtract(Ci.K4.create(),[f[0],f[1]],[u[s][0],u[s][1]]),a=Ci.K4.length(i),c=this._getSignedAngle(r,i),m=Math.cos(c)*a,g=Ci.K4.scaleAndAdd(Ci.K4.create(),[u[e][0],u[e][1]],r,m);if(this._movingLongAxisWouldPutItThroughShortAxis({start:{x:f[0],y:f[1]},end:{x:g[0],y:g[1]}},{start:{x:t.longLineSegment.start.x,y:t.longLineSegment.start.y},end:{x:t.longLineSegment.end.x,y:t.longLineSegment.end.y}}))return;if(!Ts([f[0],f[1]],[g[0],g[1]],[d.start.x,d.start.y],[d.end.x,d.end.y]))return;l.handles.points[e]=o.canvasToWorld(g),l.handles.points[s]=p}},this.cancel=e=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(e),this._deactivateModify(e),Ta(e);const{annotation:t,viewportIdsToRender:n,newAnnotation:r}=this.editData,{data:i}=t;t.highlighted=!1,i.handles.activeHandleIndex=null;const o=(0,Y.getEnabledElement)(e),{renderingEngine:a}=o;if(Po(a,n),r){const e=ne.ANNOTATION_COMPLETED,n={annotation:t};(0,Y.triggerEvent)(Y.eventTarget,e,n)}return this.editData=null,t.annotationUID}},this._activateDraw=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragDrawCallback),e.addEventListener(ne.MOUSE_MOVE,this._dragDrawCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragDrawCallback)},this._deactivateDraw=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragDrawCallback),e.removeEventListener(ne.MOUSE_MOVE,this._dragDrawCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragDrawCallback)},this._activateModify=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragModifyCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragModifyCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback)},this._deactivateModify=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragModifyCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragModifyCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(e,t)=>{let n=!0;const{viewport:r}=e,{element:i}=r;let o=rg(this.getToolName(),i);if(!o?.length)return n;if(o=this.filterInteractableAnnotationsForElement(i,o),!o?.length)return n;const a=this.getTargetId(r),s=r.getRenderingEngine(),l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id};for(let i=0;ir.worldToCanvas(e)));l.annotationUID=u;const m=this.getStyle("lineWidth",l,c),g=this.getStyle("lineDash",l,c),v=this.getStyle("color",l,c),y=this.getStyle("shadow",l,c);if(d.cachedStats[a]&&null!=d.cachedStats[a].unit?c.invalidated&&this._throttledCalculateCachedStats(c,s,e):(d.cachedStats[a]={length:null,width:null,unit:null},this._calculateCachedStats(c,s,e)),!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;let _;if(!ke(u))continue;if(he(c)||this.editData||null===p||(_=[f[p]]),_){Fi(t,u,"0",_,{color:v})}const b=`${u}-line-1`,E=`${u}-line-2`;Ui(t,u,"0",f[0],f[1],{color:v,lineDash:g,lineWidth:m,shadow:y},b);Ui(t,u,"1",f[2],f[3],{color:v,lineDash:g,lineWidth:m,shadow:y},E),n=!0;const w=this.getLinkedTextBoxStyle(l,c);if(!w.visibility){d.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const x=this.configuration.getTextLines(d,a);if(!x||0===x.length)continue;let C;d.handles.textBox.hasMoved||(C=Qs(f),d.handles.textBox.worldPosition=r.canvasToWorld(C));const D=r.worldToCanvas(d.handles.textBox.worldPosition),S=Hi(t,u,"1",x,D,f,{},w),{x:T,y:I,width:A,height:N}=S;d.handles.textBox.worldBoundingBox={topLeft:r.canvasToWorld([T,I]),topRight:r.canvasToWorld([T+A,I]),bottomLeft:r.canvasToWorld([T,I+N]),bottomRight:r.canvasToWorld([T+A,I+N])}}return n},this._movingLongAxisWouldPutItThroughShortAxis=(e,t)=>{const n=Ci.K4.create();Ci.K4.set(n,t.end.x-t.start.x,t.end.y-t.start.y),Ci.K4.normalize(n,n);const r={start:{x:t.start.x-10*n[0],y:t.start.y-10*n[1]},end:{x:t.end.x+10*n[0],y:t.end.y+10*n[1]}};return!Ts([r.start.x,r.start.y],[r.end.x,r.end.y],[e.start.x,e.start.y],[e.end.x,e.end.y])},this._calculateCachedStats=(e,t,n)=>{const{data:r}=e,{viewportId:i,renderingEngineId:o}=n,a=r.handles.points[0],s=r.handles.points[1],l=r.handles.points[2],c=r.handles.points[3],{cachedStats:u}=r,d=Object.keys(u);for(let e=0;ef?p:f,g=p>f?f:p,v=el(i,a),y=el(i,s),_=el(i,l),b=el(i,c);this._isInsideVolume(v,y,_,b,o)?this.isHandleOutsideImage=!1:this.isHandleOutsideImage=!0,u[n]={length:m,width:g,unit:$s(0,r)}}e.invalidated=!1;const h=ne.ANNOTATION_MODIFIED,p={annotation:e,viewportId:i,renderingEngineId:o};return(0,Y.triggerEvent)(Y.eventTarget,h,p),u},this._isInsideVolume=(e,t,n,r,i)=>Y.utilities.indexWithinDimensions(e,i)&&Y.utilities.indexWithinDimensions(t,i)&&Y.utilities.indexWithinDimensions(n,i)&&Y.utilities.indexWithinDimensions(r,i),this._getSignedAngle=(e,t)=>Math.atan2(e[0]*t[1]-e[1]*t[0],e[0]*t[0]+e[1]*t[1]),this._throttledCalculateCachedStats=To(this._calculateCachedStats,100,{trailing:!0})}addNewAnnotation(e){const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=(0,Y.getEnabledElement)(r),{viewport:a,renderingEngine:s}=o;this.isDrawing=!0;const l=a.getCamera(),{viewPlaneNormal:c,viewUp:u}=l,d=this.getReferencedImageId(a,i,c,u),h=a.getFrameOfReferenceUID(),p={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...c],viewUp:[...u],FrameOfReferenceUID:h,referencedImageId:d},data:{handles:{points:[[...i],[...i],[...i],[...i]],textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}},activeHandleIndex:null},label:"",cachedStats:{}}};ig(p,r);const f=vs(r,this.getToolName());return this.editData={annotation:p,viewportIdsToRender:f,handleIndex:1,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(r),Ia(r),e.preventDefault(),Po(s,f),p}_calculateLength(e,t){const n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(n*n+r*r+i*i)}}function nl(e,t){const{cachedStats:n}=e,{length:r,width:i,unit:o}=n[t];if(void 0===r)return;return[`L: ${jo(r)} ${o}`,`W: ${jo(i)} ${o}`]}tl.toolName="Bidirectional";const rl=tl,{transformWorldToIndex:il}=Y.utilities;class ol extends ho{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{preventHandleOutsideImage:!1,getTextLines:al}}){super(e,t),this.addNewAnnotation=e=>{const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=(0,Y.getEnabledElement)(r),{viewport:a,renderingEngine:s}=o;Ia(r),this.isDrawing=!0;const l=a.getCamera(),{viewPlaneNormal:c,viewUp:u}=l,d=this.getReferencedImageId(a,i,c,u),h=a.getFrameOfReferenceUID(),p={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...c],viewUp:[...u],FrameOfReferenceUID:h,referencedImageId:d},data:{handles:{points:[[...i],[...i]],activeHandleIndex:null,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},label:"",cachedStats:{}}};ig(p,r);const f=vs(r,this.getToolName());return this.editData={annotation:p,viewportIdsToRender:f,handleIndex:1,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(r),e.preventDefault(),Po(s,f),p},this.isPointNearTool=(e,t,n,r)=>{const i=(0,Y.getEnabledElement)(e),{viewport:o}=i,{data:a}=t,[s,l]=a.handles.points,c=o.worldToCanvas(s),u=o.worldToCanvas(l),d={start:{x:c[0],y:c[1]},end:{x:u[0],y:u[1]}};return Ds([d.start.x,d.start.y],[d.end.x,d.end.y],[n[0],n[1]])<=r},this.toolSelectedCallback=(e,t)=>{const n=e.detail,{element:r}=n;t.highlighted=!0;const i=vs(r,this.getToolName());this.editData={annotation:t,viewportIdsToRender:i,movingTextBox:!1},this._activateModify(r),Ia(r);const o=(0,Y.getEnabledElement)(r),{renderingEngine:a}=o;Po(a,i),e.preventDefault()},this._endCallback=e=>{const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,newAnnotation:o,hasMoved:a}=this.editData,{data:s}=r;if(o&&!a)return;s.handles.activeHandleIndex=null,this._deactivateModify(n),this._deactivateDraw(n),Ta(n);const l=(0,Y.getEnabledElement)(n),{renderingEngine:c}=l;if(this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&ag(r.annotationUID),Po(c,i),o){const e=ne.ANNOTATION_COMPLETED,t={annotation:r};(0,Y.triggerEvent)(Y.eventTarget,e,t)}this.editData=null,this.isDrawing=!1},this._dragCallback=e=>{this.isDrawing=!0;const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,handleIndex:o,movingTextBox:a}=this.editData,{data:s}=r;if(a){const{deltaPoints:e}=t,n=e.world,{textBox:r}=s.handles,{worldPosition:i}=r;i[0]+=n[0],i[1]+=n[1],i[2]+=n[2],r.hasMoved=!0}else if(void 0===o){const{deltaPoints:e}=t,n=e.world;s.handles.points.forEach((e=>{e[0]+=n[0],e[1]+=n[1],e[2]+=n[2]})),r.invalidated=!0}else{const{currentPoints:e}=t,n=e.world;s.handles.points[o]=[...n],r.invalidated=!0}this.editData.hasMoved=!0;const l=(0,Y.getEnabledElement)(n),{renderingEngine:c}=l;Po(c,i)},this.cancel=e=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(e),this._deactivateModify(e),Ta(e);const{annotation:t,viewportIdsToRender:n,newAnnotation:r}=this.editData,{data:i}=t;t.highlighted=!1,i.handles.activeHandleIndex=null;const o=(0,Y.getEnabledElement)(e),{renderingEngine:a}=o;if(Po(a,n),r){const e=ne.ANNOTATION_COMPLETED,n={annotation:t};(0,Y.triggerEvent)(Y.eventTarget,e,n)}return this.editData=null,t.annotationUID}},this._activateModify=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback)},this._deactivateModify=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback)},this._activateDraw=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragCallback),e.addEventListener(ne.MOUSE_MOVE,this._dragCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback)},this._deactivateDraw=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragCallback),e.removeEventListener(ne.MOUSE_MOVE,this._dragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(e,t)=>{let n=!1;const{viewport:r}=e,{element:i}=r;let o=rg(this.getToolName(),i);if(!o?.length)return n;if(o=this.filterInteractableAnnotationsForElement(i,o),!o?.length)return n;const a=this.getTargetId(r),s=r.getRenderingEngine(),l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id};for(let i=0;ir.worldToCanvas(e)));let _;if(d.cachedStats[a]&&null!=d.cachedStats[a].unit?c.invalidated&&this._throttledCalculateCachedStats(c,s,e):(d.cachedStats[a]={length:null,unit:null},this._calculateCachedStats(c,s,e)),!ke(u))continue;if(he(c)||this.editData||null===p||(_=[y[p]]),_){Fi(t,u,"0",y,{color:g,lineDash:m,lineWidth:f})}const b=`${u}-line`;if(Ui(t,u,"1",y[0],y[1],{color:g,width:f,lineDash:m,shadow:v},b),n=!0,!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;const E=this.getLinkedTextBoxStyle(l,c);if(!E.visibility){d.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const w=this.configuration.getTextLines(d,a);if(!d.handles.textBox.hasMoved){const e=Qs(y);d.handles.textBox.worldPosition=r.canvasToWorld(e)}const x=r.worldToCanvas(d.handles.textBox.worldPosition),C=Hi(t,u,"1",w,x,y,{},E),{x:D,y:S,width:T,height:I}=C;d.handles.textBox.worldBoundingBox={topLeft:r.canvasToWorld([D,S]),topRight:r.canvasToWorld([D+T,S]),bottomLeft:r.canvasToWorld([D,S+I]),bottomRight:r.canvasToWorld([D+T,S+I])}}return n},this._throttledCalculateCachedStats=To(this._calculateCachedStats,100,{trailing:!0})}handleSelectedCallback(e,t,n){const r=e.detail,{element:i}=r,{data:o}=t;t.highlighted=!0;let a,s=!1;n.worldPosition?s=!0:a=o.handles.points.findIndex((e=>e===n));const l=vs(i,this.getToolName());this.editData={annotation:t,viewportIdsToRender:l,handleIndex:a,movingTextBox:s},this._activateModify(i),Ia(i);const c=(0,Y.getEnabledElement)(i),{renderingEngine:u}=c;Po(u,l),e.preventDefault()}_calculateLength(e,t){const n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(n*n+r*r+i*i)}_calculateCachedStats(e,t,n){const r=e.data,{viewportId:i,renderingEngineId:o}=n,a=r.handles.points[0],s=r.handles.points[1],{cachedStats:l}=r,c=Object.keys(l);for(let e=0;e0}if(e instanceof Y.StackViewport){const{preScale:t}=e.getImageData()||{};return!!t?.scaled}throw new Error("Viewport is not a valid type")}const{transformWorldToIndex:ul}=Y.utilities;class dl extends ho{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1,getTextLines:hl}}){super(e,t),this.addNewAnnotation=e=>{const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=(0,Y.getEnabledElement)(r),{viewport:a,renderingEngine:s}=o;this.isDrawing=!0;const l=a.getCamera(),{viewPlaneNormal:c,viewUp:u}=l,d=this.getReferencedImageId(a,i,c,u),h=a.getFrameOfReferenceUID(),p={invalidated:!0,highlighted:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...c],viewUp:[...u],FrameOfReferenceUID:h,referencedImageId:d},data:{label:"",handles:{points:[[...i]]},cachedStats:{}}};ig(p,r);const f=vs(r,this.getToolName());return this.editData={annotation:p,newAnnotation:!0,viewportIdsToRender:f},this._activateModify(r),Ia(r),e.preventDefault(),Po(s,f),p},this._endCallback=e=>{const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,newAnnotation:o}=this.editData,a=(0,Y.getEnabledElement)(n),{renderingEngine:s}=a,{viewportId:l}=a;if(this.eventDispatchDetail={viewportId:l,renderingEngineId:s.id},this._deactivateModify(n),Ta(n),this.editData=null,this.isDrawing=!1,this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&ag(r.annotationUID),Po(s,i),o){const e=ne.ANNOTATION_COMPLETED,t={annotation:r};(0,Y.triggerEvent)(Y.eventTarget,e,t)}},this._dragCallback=e=>{this.isDrawing=!0;const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,{annotation:o,viewportIdsToRender:a}=this.editData,{data:s}=o;s.handles.points[0]=[...i],o.invalidated=!0;const l=(0,Y.getEnabledElement)(r),{renderingEngine:c}=l;Po(c,a)},this.cancel=e=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateModify(e),Ta(e);const{annotation:t,viewportIdsToRender:n,newAnnotation:r}=this.editData,{data:i}=t;t.highlighted=!1,i.handles.activeHandleIndex=null;const o=(0,Y.getEnabledElement)(e),{renderingEngine:a}=o;if(Po(a,n),r){const e=ne.ANNOTATION_COMPLETED,n={annotation:t};(0,Y.triggerEvent)(Y.eventTarget,e,n)}return this.editData=null,t.annotationUID}},this._activateModify=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback)},this._deactivateModify=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(e,t)=>{let n=!1;const{viewport:r}=e,{element:i}=r;let o=rg(this.getToolName(),i);if(!o?.length)return n;if(o=this.filterInteractableAnnotationsForElement(i,o),!o?.length)return n;const a=this.getTargetId(r),s=r.getRenderingEngine(),l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id};for(let i=0;i{const n=Y.utilities.imageIdToURI(e),r=t.hasImageURI(n),i=Y.utilities.imageIdToURI(t.getCurrentImageId());return r&&i!==n}))&&delete d.cachedStats[t]}}}else d.cachedStats[a]={Modality:null,index:null,value:null},this._calculateCachedStats(c,s,e);if(!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;Fi(t,u,"0",[p],{color:f}),n=!0;const m=this.getLinkedTextBoxStyle(l,c);if(!m.visibility)continue;const g=this.configuration.getTextLines(d,a);if(g){const e=[p[0]+6,p[1]-6];Wi(t,u,"0",g,[e[0],e[1]],m)}}return n}}isPointNearTool(){return!1}toolSelectedCallback(){}getHandleNearImagePoint(e,t,n,r){const i=(0,Y.getEnabledElement)(e),{viewport:o}=i,{data:a}=t,s=a.handles.points[0],l=o.worldToCanvas(s);if(!0===Ci.K4.distance(n,l){const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=(0,Y.getEnabledElement)(r),{viewport:a,renderingEngine:s}=o;this.isDrawing=!0;const l=a.getCamera(),{viewPlaneNormal:c,viewUp:u}=l,d=this.getReferencedImageId(a,i,c,u),h={invalidated:!0,highlighted:!0,isVisible:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...c],viewUp:[...u],FrameOfReferenceUID:a.getFrameOfReferenceUID(),referencedImageId:d},data:{label:"",handles:{points:[[...i]]},cachedStats:{}}},p=vs(r,this.getToolName());return this.editData={annotation:h,newAnnotation:!0,viewportIdsToRender:p},this._activateModify(r),Ia(r),e.preventDefault(),Po(s,p),h},this.postTouchStartCallback=e=>this.postMouseDownCallback(e),this.renderAnnotation=(e,t)=>{let n=!1;const{viewport:r}=e;if(!this.editData)return n;const i=this.filterInteractableAnnotationsForElement(r.element,[this.editData.annotation]);if(!i?.length)return n;const o=this.getTargetId(r),a=r.getRenderingEngine(),s={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id},l=this.editData.annotation,c=l.annotationUID,u=l.data,d=u.handles.points[0],h=r.worldToCanvas(d);s.annotationUID=c;const p=this.getStyle("color",s,l);cl(r,o),this.isSuvScaled(r,o,l.metadata.referencedImageId);if(u.cachedStats[o]&&null!=u.cachedStats[o].value?l.invalidated&&this._calculateCachedStats(l,a,e):(u.cachedStats[o]={Modality:null,index:null,value:null},this._calculateCachedStats(l,a,e)),!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;Fi(t,c,"0",[h],{color:p}),n=!0;const f=this.configuration.getTextLines(u,o);if(f){const e=[h[0]+6,h[1]-6];Wi(t,c,"0",f,[e[0],e[1]],this.getLinkedTextBoxStyle(s,l))}return n}}}function ml(e,t){const n=e.cachedStats[t],{index:r,value:i,modalityUnit:o}=n;if(void 0===i)return;const a=[];return a.push(`(${r[0]}, ${r[1]}, ${r[2]})`),a.push(`${i.toFixed(2)} ${o}`),a}fl.toolName="DragProbe";const gl=fl;function vl(e,t){if(4!==e.length||2!==t.length)throw Error("rectangle:[left, top, width, height] or point: [x,y] not defined correctly");const[n,r,i,o]=e;let a=655535;const s=function(e,t,n,r){return{top:[[e,t],[e+n,t]],right:[[e+n,t],[e+n,t+r]],bottom:[[e+n,t+r],[e,t+r]],left:[[e,t+r],[e,t]]}}(n,r,i,o);return Object.keys(s).forEach((e=>{const[n,r]=s[e],i=Ds(n,r,t);i{e>this.max&&(this.max=e,this.currentMax=e),this.count+=1,this.sum+=e,this.sumSquares+=e**2,this.squaredDiffSum+=Math.pow(e-this.sum/this.count,2)}}static{this.getStatistics=()=>{const e=this.sum/this.count,t=Math.sqrt(this.squaredDiffSum/this.count),n=Math.sqrt(this.sumSquares/this.count-e**2);return this.max=-1/0,this.sum=0,this.sumSquares=0,this.squaredDiffSum=0,this.count=0,[{name:"max",value:this.currentMax,unit:null},{name:"mean",value:e,unit:null},{name:"stdDev",value:t,unit:null},{name:"stdDevWithSumSquare",value:n,unit:null}]}}}const{transformWorldToIndex:bl}=Y.utilities;class El extends ho{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1,getTextLines:wl,statsCalculator:_l}}){super(e,t),this.addNewAnnotation=e=>{const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=(0,Y.getEnabledElement)(r),{viewport:a,renderingEngine:s}=o;this.isDrawing=!0;const l=a.getCamera(),{viewPlaneNormal:c,viewUp:u}=l,d=this.getReferencedImageId(a,i,c,u),h=a.getFrameOfReferenceUID(),p={invalidated:!0,highlighted:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...c],viewUp:[...u],FrameOfReferenceUID:h,referencedImageId:d},data:{label:"",handles:{points:[[...i],[...i],[...i],[...i]],textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}},activeHandleIndex:null},cachedStats:{}}};ig(p,r);const f=vs(r,this.getToolName());return this.editData={annotation:p,viewportIdsToRender:f,handleIndex:3,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(r),Ia(r),e.preventDefault(),Po(s,f),p},this.isPointNearTool=(e,t,n,r)=>{const i=(0,Y.getEnabledElement)(e),{viewport:o}=i,{data:a}=t,{points:s}=a.handles,l=o.worldToCanvas(s[0]),c=o.worldToCanvas(s[3]),u=this._getRectangleImageCoordinates([l,c]),d=[n[0],n[1]],{left:h,top:p,width:f,height:m}=u;return vl([h,p,f,m],d)<=r},this.toolSelectedCallback=(e,t)=>{const n=e.detail,{element:r}=n;t.highlighted=!0;const i=vs(r,this.getToolName());this.editData={annotation:t,viewportIdsToRender:i,movingTextBox:!1},this._activateModify(r),Ia(r);const o=(0,Y.getEnabledElement)(r),{renderingEngine:a}=o;Po(a,i),e.preventDefault()},this.handleSelectedCallback=(e,t,n)=>{const r=e.detail,{element:i}=r,{data:o}=t;t.highlighted=!0;let a,s=!1;n.worldPosition?s=!0:a=o.handles.points.findIndex((e=>e===n));const l=vs(i,this.getToolName());this.editData={annotation:t,viewportIdsToRender:l,handleIndex:a,movingTextBox:s},this._activateModify(i),Ia(i);const c=(0,Y.getEnabledElement)(i),{renderingEngine:u}=c;Po(u,l),e.preventDefault()},this._endCallback=e=>{const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,newAnnotation:o,hasMoved:a}=this.editData,{data:s}=r;if(o&&!a)return;s.handles.activeHandleIndex=null,this._deactivateModify(n),this._deactivateDraw(n),Ta(n);const l=(0,Y.getEnabledElement)(n),{renderingEngine:c}=l;if(this.editData=null,this.isDrawing=!1,this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&ag(r.annotationUID),Po(c,i),o){const e=ne.ANNOTATION_COMPLETED,t={annotation:r};(0,Y.triggerEvent)(Y.eventTarget,e,t)}},this._dragCallback=e=>{this.isDrawing=!0;const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,handleIndex:o,movingTextBox:a}=this.editData,{data:s}=r;if(a){const{deltaPoints:e}=t,n=e.world,{textBox:r}=s.handles,{worldPosition:i}=r;i[0]+=n[0],i[1]+=n[1],i[2]+=n[2],r.hasMoved=!0}else if(void 0===o){const{deltaPoints:e}=t,n=e.world,{points:i}=s.handles;i.forEach((e=>{e[0]+=n[0],e[1]+=n[1],e[2]+=n[2]})),r.invalidated=!0}else{const{currentPoints:e}=t,i=(0,Y.getEnabledElement)(n),{worldToCanvas:a,canvasToWorld:l}=i.viewport,c=e.world,{points:u}=s.handles;let d,h,p,f,m,g,v,y;switch(u[o]=[...c],o){case 0:case 3:d=a(u[0]),f=a(u[3]),h=[f[0],d[1]],p=[d[0],f[1]],g=l(h),v=l(p),u[1]=g,u[2]=v;break;case 1:case 2:h=a(u[1]),p=a(u[2]),d=[p[0],h[1]],f=[h[0],p[1]],m=l(d),y=l(f),u[0]=m,u[3]=y}r.invalidated=!0}this.editData.hasMoved=!0;const l=(0,Y.getEnabledElement)(n),{renderingEngine:c}=l;Po(c,i)},this.cancel=e=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(e),this._deactivateModify(e),Ta(e);const{annotation:t,viewportIdsToRender:n,newAnnotation:r}=this.editData,{data:i}=t;t.highlighted=!1,i.handles.activeHandleIndex=null;const o=(0,Y.getEnabledElement)(e),{renderingEngine:a}=o;if(Po(a,n),r){const e=ne.ANNOTATION_COMPLETED,n={annotation:t};(0,Y.triggerEvent)(Y.eventTarget,e,n)}return this.editData=null,t.annotationUID}},this._activateDraw=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragCallback),e.addEventListener(ne.MOUSE_MOVE,this._dragCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback)},this._deactivateDraw=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragCallback),e.removeEventListener(ne.MOUSE_MOVE,this._dragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback)},this._activateModify=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback)},this._deactivateModify=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(e,t)=>{let n=!1;const{viewport:r}=e,{element:i}=r;let o=rg(this.getToolName(),i);if(!o?.length)return n;if(o=this.filterInteractableAnnotationsForElement(i,o),!o?.length)return n;const a=this.getTargetId(r),s=r.getRenderingEngine(),l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id};for(let i=0;ir.worldToCanvas(e)));l.annotationUID=u;const m=this.getStyle("lineWidth",l,c),g=this.getStyle("lineDash",l,c),v=this.getStyle("color",l,c),{viewPlaneNormal:y,viewUp:_}=r.getCamera();if(d.cachedStats[a]&&null!=d.cachedStats[a].areaUnit){if(c.invalidated&&(this._throttledCalculateCachedStats(c,y,_,s,e),r instanceof Y.VolumeViewport)){const{referencedImageId:e}=c.metadata;for(const t in d.cachedStats)if(t.startsWith("imageId")){s.getStackViewports().find((t=>{const n=Y.utilities.imageIdToURI(e),r=t.hasImageURI(n),i=Y.utilities.imageIdToURI(t.getCurrentImageId());return r&&i!==n}))&&delete d.cachedStats[t]}}}else d.cachedStats[a]={Modality:null,area:null,max:null,mean:null,stdDev:null,areaUnit:null},this._calculateCachedStats(c,y,_,s,e);if(!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;let b;if(!ke(u))continue;if(he(c)||this.editData||null===p||(b=[f[p]]),b){Fi(t,u,"0",b,{color:v})}const E=`${u}-rect`;qi(t,u,"0",f[0],f[3],{color:v,lineDash:g,lineWidth:m},E),n=!0;const w=this.getLinkedTextBoxStyle(l,c);if(!w.visibility){d.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const x=this.configuration.getTextLines(d,a);if(!x||0===x.length)continue;if(!d.handles.textBox.hasMoved){const e=Qs(f);d.handles.textBox.worldPosition=r.canvasToWorld(e)}const C=r.worldToCanvas(d.handles.textBox.worldPosition),D=Hi(t,u,"1",x,C,f,{},w),{x:S,y:T,width:I,height:A}=D;d.handles.textBox.worldBoundingBox={topLeft:r.canvasToWorld([S,T]),topRight:r.canvasToWorld([S+I,T]),bottomLeft:r.canvasToWorld([S,T+A]),bottomRight:r.canvasToWorld([S+I,T+A])}}return n},this._getRectangleImageCoordinates=e=>{const[t,n]=e;return{left:Math.min(t[0],n[0]),top:Math.min(t[1],n[1]),width:Math.abs(t[0]-n[0]),height:Math.abs(t[1]-n[1])}},this._calculateCachedStats=(e,t,n,r,i)=>{const{data:o}=e,{viewportId:a,renderingEngineId:s,viewport:l}=i,c=o.handles.points[0],u=o.handles.points[3],{cachedStats:d}=o,h=Object.keys(d);for(let i=0;i!0),this.configuration.statsCalculator.statsCallback,r),E=this.configuration.statsCalculator.getStatistics();d[o]={Modality:f.Modality,area:v,mean:E[1]?.value,stdDev:E[2]?.value,max:E[0]?.value,statsArray:E,pointsInShape:b,areaUnit:Js(0,a),modalityUnit:_}}else this.isHandleOutsideImage=!0,d[o]={Modality:f.Modality}}e.invalidated=!1;const p=ne.ANNOTATION_MODIFIED,f={annotation:e,viewportId:a,renderingEngineId:s};return(0,Y.triggerEvent)(Y.eventTarget,p,f),d},this._isInsideVolume=(e,t,n)=>Y.utilities.indexWithinDimensions(e,n)&&Y.utilities.indexWithinDimensions(t,n),this._throttledCalculateCachedStats=To(this._calculateCachedStats,100,{trailing:!0})}}function wl(e,t){const n=e.cachedStats[t],{area:r,mean:i,max:o,stdDev:a,areaUnit:s,modalityUnit:l}=n;if(void 0===i)return;const c=[];return c.push(`Area: ${jo(r)} ${s}`),c.push(`Mean: ${jo(i)} ${l}`),c.push(`Max: ${jo(o)} ${l}`),c.push(`Std Dev: ${jo(a)} ${l}`),c}El.toolName="RectangleROI";const xl=El;function Cl(e,t,n,r){const i=Ci.R3.create();Ci.R3.cross(i,t,e);const o=Ci.R3.fromValues(...n),a=Ci.R3.fromValues(...r),s=Ci.R3.create();Ci.R3.subtract(s,o,a);const l=Ci.R3.length(s);if(l<1e-4)return{worldWidth:0,worldHeight:0};const c=Ci.R3.dot(s,i)/(l*Ci.R3.length(i));return{worldWidth:Math.sqrt(1-c*c)*l,worldHeight:c*l}}const{transformWorldToIndex:Dl}=Y.utilities;class Sl extends ho{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1,centerPointRadius:0,getTextLines:Tl,statsCalculator:_l}}){super(e,t),this.isHandleOutsideImage=!1,this.addNewAnnotation=e=>{const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=n.canvas,a=(0,Y.getEnabledElement)(r),{viewport:s,renderingEngine:l}=a;this.isDrawing=!0;const c=s.getCamera(),{viewPlaneNormal:u,viewUp:d}=c,h=this.getReferencedImageId(s,i,u,d),p=s.getFrameOfReferenceUID(),f={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...u],viewUp:[...d],FrameOfReferenceUID:p,referencedImageId:h},data:{label:"",handles:{textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}},points:[[...i],[...i],[...i],[...i]],activeHandleIndex:null},cachedStats:{},initialRotation:s.getRotation()}};ig(f,r);const m=vs(r,this.getToolName());return this.editData={annotation:f,viewportIdsToRender:m,centerCanvas:o,newAnnotation:!0,hasMoved:!1},this._activateDraw(r),Ia(r),e.preventDefault(),Po(l,m),f},this.isPointNearTool=(e,t,n,r)=>{const i=(0,Y.getEnabledElement)(e),{viewport:o}=i,{data:a}=t,{points:s}=a.handles,l=Ko(s.map((e=>o.worldToCanvas(e)))),[c,u]=l,d={left:Math.min(c[0],u[0])+r/2,top:Math.min(c[1],u[1])+r/2,width:Math.abs(c[0]-u[0])-r,height:Math.abs(c[1]-u[1])-r},h={left:Math.min(c[0],u[0])-r/2,top:Math.min(c[1],u[1])-r/2,width:Math.abs(c[0]-u[0])+r,height:Math.abs(c[1]-u[1])+r},p=this._pointInEllipseCanvas(d,n);return!(!this._pointInEllipseCanvas(h,n)||p)},this.toolSelectedCallback=(e,t)=>{const n=e.detail,{element:r}=n;t.highlighted=!0;const i=vs(r,this.getToolName());this.editData={annotation:t,viewportIdsToRender:i,movingTextBox:!1},Ia(r),this._activateModify(r);const o=(0,Y.getEnabledElement)(r),{renderingEngine:a}=o;Po(a,i),e.preventDefault()},this.handleSelectedCallback=(e,t,n)=>{const r=e.detail,{element:i}=r,{data:o}=t;t.highlighted=!0;let a,s,l,c,u,d=!1;if(n.worldPosition)d=!0;else{const{points:e}=o.handles,t=(0,Y.getEnabledElement)(i),{worldToCanvas:r}=t.viewport;a=e.findIndex((e=>e===n));const d=e.map(r);u=d[a],l=Math.abs(d[2][0]-d[3][0]),c=Math.abs(d[0][1]-d[1][1]),s=[(d[2][0]+d[3][0])/2,(d[0][1]+d[1][1])/2]}const h=vs(i,this.getToolName());this.editData={annotation:t,viewportIdsToRender:h,handleIndex:a,canvasWidth:l,canvasHeight:c,centerCanvas:s,originalHandleCanvas:u,movingTextBox:d},this._activateModify(i),Ia(i);const p=(0,Y.getEnabledElement)(i),{renderingEngine:f}=p;Po(f,h),e.preventDefault()},this._endCallback=e=>{const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,newAnnotation:o,hasMoved:a}=this.editData,{data:s}=r;if(o&&!a)return;r.highlighted=!1,s.handles.activeHandleIndex=null,this._deactivateModify(n),this._deactivateDraw(n),Ta(n);const l=(0,Y.getEnabledElement)(n),{renderingEngine:c}=l;if(this.editData=null,this.isDrawing=!1,this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&ag(r.annotationUID),Po(c,i),o){const e=ne.ANNOTATION_COMPLETED,t={annotation:r};(0,Y.triggerEvent)(Y.eventTarget,e,t)}},this._dragDrawCallback=e=>{this.isDrawing=!0;const t=e.detail,{element:n}=t,{currentPoints:r}=t,i=r.canvas,o=(0,Y.getEnabledElement)(n),{renderingEngine:a,viewport:s}=o,{canvasToWorld:l}=s,{annotation:c,viewportIdsToRender:u,centerCanvas:d}=this.editData,{data:h}=c,p=Math.abs(i[0]-d[0]),f=Math.abs(i[1]-d[1]),m=[d[0],d[1]-f],g=[d[0],d[1]+f],v=[d[0]-p,d[1]],y=[d[0]+p,d[1]];h.handles.points=[l(m),l(g),l(v),l(y)],c.invalidated=!0,this.editData.hasMoved=!0,Po(a,u)},this._dragModifyCallback=e=>{this.isDrawing=!0;const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,handleIndex:o,movingTextBox:a}=this.editData,{data:s}=r;if(a){const{deltaPoints:e}=t,n=e.world,{textBox:r}=s.handles,{worldPosition:i}=r;i[0]+=n[0],i[1]+=n[1],i[2]+=n[2],r.hasMoved=!0}else if(void 0===o){const{deltaPoints:e}=t,n=e.world;s.handles.points.forEach((e=>{e[0]+=n[0],e[1]+=n[1],e[2]+=n[2]})),r.invalidated=!0}else this._dragHandle(e),r.invalidated=!0;const l=(0,Y.getEnabledElement)(n),{renderingEngine:c}=l;Po(c,i)},this._dragHandle=e=>{const t=e.detail,{element:n}=t,r=(0,Y.getEnabledElement)(n),{canvasToWorld:i}=r.viewport,{annotation:o,canvasWidth:a,canvasHeight:s,handleIndex:l,centerCanvas:c,originalHandleCanvas:u}=this.editData,{data:d}=o,{points:h}=d.handles,{currentPoints:p}=t,f=p.canvas;if(0===l||1===l){const e=Math.abs(f[1]-c[1]),t=[c[0],c[1]-e],n=[c[0],c[1]+e];h[0]=i(t),h[1]=i(n);const r=a/2+(f[0]-u[0]),o=[c[0]-r,c[1]],s=[c[0]+r,c[1]];h[2]=i(o),h[3]=i(s)}else{const e=Math.abs(f[0]-c[0]),t=[c[0]-e,c[1]],n=[c[0]+e,c[1]];h[2]=i(t),h[3]=i(n);const r=s/2+(f[1]-u[1]),o=[c[0],c[1]-r],a=[c[0],c[1]+r];h[0]=i(o),h[1]=i(a)}},this.cancel=e=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(e),this._deactivateModify(e),Ta(e);const{annotation:t,viewportIdsToRender:n,newAnnotation:r}=this.editData,{data:i}=t;t.highlighted=!1,i.handles.activeHandleIndex=null;const o=(0,Y.getEnabledElement)(e),{renderingEngine:a}=o;if(Po(a,n),r){const e=ne.ANNOTATION_COMPLETED,n={annotation:t};(0,Y.triggerEvent)(Y.eventTarget,e,n)}return this.editData=null,t.annotationUID}},this._activateModify=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragModifyCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragModifyCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback)},this._deactivateModify=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragModifyCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragModifyCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback)},this._activateDraw=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragDrawCallback),e.addEventListener(ne.MOUSE_MOVE,this._dragDrawCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragDrawCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback)},this._deactivateDraw=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragDrawCallback),e.removeEventListener(ne.MOUSE_MOVE,this._dragDrawCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragDrawCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(e,t)=>{let n=!1;const{viewport:r}=e,{element:i}=r;let o=rg(this.getToolName(),i);if(!o?.length)return n;if(o=this.filterInteractableAnnotationsForElement(i,o),!o?.length)return n;const a=this.getTargetId(r),s=r.getRenderingEngine(),l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id};for(let i=0;ir.worldToCanvas(e))),_=Math.abs(r.getRotation()-(d.initialRotation||0));let b;b=Ko(90==_||270==_?[y[2],y[3],y[0],y[1]]:y);const{centerPointRadius:E}=this.configuration;if(d.cachedStats[a]&&null!=d.cachedStats[a].areaUnit){if(c.invalidated&&(this._throttledCalculateCachedStats(c,r,s,e),r instanceof Y.VolumeViewport)){const{referencedImageId:e}=c.metadata;for(const t in d.cachedStats)if(t.startsWith("imageId")){s.getStackViewports().find((t=>{const n=Y.utilities.imageIdToURI(e),r=t.hasImageURI(n),i=Y.utilities.imageIdToURI(t.getCurrentImageId());return r&&i!==n}))&&delete d.cachedStats[t]}}}else d.cachedStats[a]={Modality:null,area:null,max:null,mean:null,stdDev:null,areaUnit:null},this._calculateCachedStats(c,r,s,e);if(!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;let w;if(!ke(u))continue;if(he(c)||this.editData||null===f||(w=[y[f]]),w){Fi(t,u,"0",w,{color:v})}const x=`${u}-ellipse`,C="0";if(Ri(t,u,C,b[0],b[1],{color:v,lineDash:g,lineWidth:m},x),E>0){if(Math.min(Math.abs(b[0][0]-b[1][0])/2,Math.abs(b[0][1]-b[1][1])/2)>3*E){const e=this._getCanvasEllipseCenter(y);Li(t,u,`${C}-center`,e,E,{color:v,lineDash:g,lineWidth:m})}}n=!0;const D=this.getLinkedTextBoxStyle(l,c);if(!D.visibility){d.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const S=this.configuration.getTextLines(d,a);if(!S||0===S.length)continue;let T;d.handles.textBox.hasMoved||(T=Qs(b),d.handles.textBox.worldPosition=r.canvasToWorld(T));const I=r.worldToCanvas(d.handles.textBox.worldPosition),A=Hi(t,u,"1",S,I,y,{},D),{x:N,y:O,width:P,height:k}=A;d.handles.textBox.worldBoundingBox={topLeft:r.canvasToWorld([N,O]),topRight:r.canvasToWorld([N+P,O]),bottomLeft:r.canvasToWorld([N,O+k]),bottomRight:r.canvasToWorld([N+P,O+k])}}return n},this._calculateCachedStats=(e,t,n,r)=>{const i=e.data,{viewportId:o,renderingEngineId:a}=r,{points:s}=i.handles,l=s.map((e=>t.worldToCanvas(e))),{viewPlaneNormal:c,viewUp:u}=t.getCamera(),[d,h]=Ko(l),p=t.canvasToWorld(d),f=t.canvasToWorld(h),{cachedStats:m}=i,g=Object.keys(m),v=p,y=f;for(let r=0;rqo(r,e)),this.configuration.statsCalculator.statsCallback,n),D=this.configuration.statsCalculator.getStatistics();m[i]={Modality:l.Modality,area:E,mean:D[1]?.value,max:D[0]?.value,stdDev:D[2]?.value,statsArray:D,pointsInShape:C,isEmptyArea:g,areaUnit:Js(0,o),modalityUnit:x}}else this.isHandleOutsideImage=!0,m[i]={Modality:l.Modality}}e.invalidated=!1;const _=ne.ANNOTATION_MODIFIED,b={annotation:e,viewportId:o,renderingEngineId:a};return(0,Y.triggerEvent)(Y.eventTarget,_,b),m},this._isInsideVolume=(e,t,n)=>Y.utilities.indexWithinDimensions(e,n)&&Y.utilities.indexWithinDimensions(t,n),this._throttledCalculateCachedStats=To(this._calculateCachedStats,100,{trailing:!0})}_pointInEllipseCanvas(e,t){const n=e.width/2,r=e.height/2;if(n<=0||r<=0)return!1;const i=[e.left+n,e.top+r],o=[t[0]-i[0],t[1]-i[1]];return o[0]*o[0]/(n*n)+o[1]*o[1]/(r*r)<=1}_getCanvasEllipseCenter(e){const[t,n,r,i]=e,o=[r[0],n[1]],a=[i[0],t[1]];return[(o[0]+a[0])/2,(o[1]+a[1])/2]}}function Tl(e,t){const n=e.cachedStats[t],{area:r,mean:i,stdDev:o,max:a,isEmptyArea:s,areaUnit:l,modalityUnit:c}=n,u=[];if(r){const e=s?"Area: Oblique not supported":`Area: ${jo(r)} ${l}`;u.push(e)}return i&&u.push(`Mean: ${jo(i)} ${c}`),a&&u.push(`Max: ${jo(a)} ${c}`),o&&u.push(`Std Dev: ${jo(o)} ${c}`),u}Sl.toolName="EllipticalROI";const Il=Sl;function Al(e,t){if(2!==e?.length||2!==t?.length)throw Error("points should have 2 elements of [x, y]");const[n,r]=e,[i,o]=t;return Math.sqrt(Math.pow(n-i,2)+Math.pow(r-o,2))}function Nl(e){const[t,n]=e;return Al(t,n)}function Ol(e){const[t,n]=e,r=Al(t,n);return[[t[0]-r,t[1]-r],[t[0]+r,t[1]+r]]}const{transformWorldToIndex:Pl}=Y.utilities;class kl extends ho{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1,centerPointRadius:0,getTextLines:Ml,statsCalculator:_l}}){super(e,t),this.isHandleOutsideImage=!1,this.addNewAnnotation=e=>{const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=(n.canvas,(0,Y.getEnabledElement)(r)),{viewport:a,renderingEngine:s}=o;this.isDrawing=!0;const l=a.getCamera(),{viewPlaneNormal:c,viewUp:u}=l,d=this.getReferencedImageId(a,i,c,u),h=a.getFrameOfReferenceUID(),p={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...c],viewUp:[...u],FrameOfReferenceUID:h,referencedImageId:d},data:{label:"",handles:{textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}},points:[[...i],[...i]],activeHandleIndex:null},cachedStats:{}}};ig(p,r);const f=vs(r,this.getToolName());return this.editData={annotation:p,viewportIdsToRender:f,newAnnotation:!0,hasMoved:!1},this._activateDraw(r),Ia(r),e.preventDefault(),Po(s,f),p},this.isPointNearTool=(e,t,n,r)=>{const i=(0,Y.getEnabledElement)(e),{viewport:o}=i,{data:a}=t,{points:s}=a.handles,l=s.map((e=>o.worldToCanvas(e))),c=Nl(l),u=Nl([l[0],n]);return Math.abs(u-c){const n=e.detail,{element:r}=n;t.highlighted=!0;const i=vs(r,this.getToolName());this.editData={annotation:t,viewportIdsToRender:i,movingTextBox:!1},Ia(r),this._activateModify(r);const o=(0,Y.getEnabledElement)(r),{renderingEngine:a}=o;Po(a,i),e.preventDefault()},this.handleSelectedCallback=(e,t,n)=>{const r=e.detail,{element:i}=r,{data:o}=t;t.highlighted=!0;let a,s=!1;if(n.worldPosition)s=!0;else{const{points:e}=o.handles;a=e.findIndex((e=>e===n))}const l=vs(i,this.getToolName());this.editData={annotation:t,viewportIdsToRender:l,handleIndex:a,movingTextBox:s},this._activateModify(i),Ia(i);const c=(0,Y.getEnabledElement)(i),{renderingEngine:u}=c;Po(u,l),e.preventDefault()},this._endCallback=e=>{const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,newAnnotation:o,hasMoved:a}=this.editData,{data:s}=r;if(o&&!a)return;r.highlighted=!1,s.handles.activeHandleIndex=null,this._deactivateModify(n),this._deactivateDraw(n),Ta(n);const l=(0,Y.getEnabledElement)(n),{renderingEngine:c}=l;if(this.editData=null,this.isDrawing=!1,this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&ag(r.annotationUID),Po(c,i),o){const e=ne.ANNOTATION_COMPLETED,t={annotation:r};(0,Y.triggerEvent)(Y.eventTarget,e,t)}},this._dragDrawCallback=e=>{this.isDrawing=!0;const t=e.detail,{element:n}=t,{currentPoints:r}=t,i=r.canvas,o=(0,Y.getEnabledElement)(n),{renderingEngine:a,viewport:s}=o,{canvasToWorld:l}=s,{annotation:c,viewportIdsToRender:u}=this.editData,{data:d}=c;d.handles.points=[d.handles.points[0],l(i)],c.invalidated=!0,this.editData.hasMoved=!0,Po(a,u)},this._dragModifyCallback=e=>{this.isDrawing=!0;const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,handleIndex:o,movingTextBox:a}=this.editData,{data:s}=r;if(a){const{deltaPoints:e}=t,n=e.world,{textBox:r}=s.handles,{worldPosition:i}=r;i[0]+=n[0],i[1]+=n[1],i[2]+=n[2],r.hasMoved=!0}else if(void 0===o){const{deltaPoints:e}=t,n=e.world;s.handles.points.forEach((e=>{e[0]+=n[0],e[1]+=n[1],e[2]+=n[2]})),r.invalidated=!0}else this._dragHandle(e),r.invalidated=!0;const l=(0,Y.getEnabledElement)(n),{renderingEngine:c}=l;Po(c,i)},this._dragHandle=e=>{const t=e.detail,{element:n}=t,r=(0,Y.getEnabledElement)(n),{canvasToWorld:i,worldToCanvas:o}=r.viewport,{annotation:a,handleIndex:s}=this.editData,{data:l}=a,{points:c}=l.handles,u=c.map((e=>o(e))),{currentPoints:d}=t,h=d.canvas;if(0===s){const e=h[0]-u[0][0],t=h[1]-u[0][1],n=h,r=[u[1][0]+e,u[1][1]+t];c[0]=i(n),c[1]=i(r)}else c[1]=i(h)},this.cancel=e=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(e),this._deactivateModify(e),Ta(e);const{annotation:t,viewportIdsToRender:n,newAnnotation:r}=this.editData,{data:i}=t;t.highlighted=!1,i.handles.activeHandleIndex=null;const o=(0,Y.getEnabledElement)(e),{renderingEngine:a}=o;if(Po(a,n),r){const e=ne.ANNOTATION_COMPLETED,n={annotation:t};(0,Y.triggerEvent)(Y.eventTarget,e,n)}return this.editData=null,t.annotationUID}},this._activateModify=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragModifyCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragModifyCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback)},this._deactivateModify=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragModifyCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragModifyCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback)},this._activateDraw=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragDrawCallback),e.addEventListener(ne.MOUSE_MOVE,this._dragDrawCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragDrawCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback)},this._deactivateDraw=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragDrawCallback),e.removeEventListener(ne.MOUSE_MOVE,this._dragDrawCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragDrawCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(e,t)=>{let n=!1;const{viewport:r}=e,{element:i}=r;let o=rg(this.getToolName(),i);if(!o?.length)return n;if(o=this.filterInteractableAnnotationsForElement(i,o),!o?.length)return n;const a=this.getTargetId(r),s=r.getRenderingEngine(),l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id};for(let i=0;ir.worldToCanvas(e))),_=y[0],b=Nl(y),E=Ol(y),{centerPointRadius:w}=this.configuration;if(d.cachedStats[a]&&null!=d.cachedStats[a].areaUnit){if(c.invalidated&&(this._throttledCalculateCachedStats(c,r,s,e),r instanceof Y.VolumeViewport)){const{referencedImageId:e}=c.metadata;for(const t in d.cachedStats)if(t.startsWith("imageId")){s.getStackViewports().find((t=>{const n=Y.utilities.imageIdToURI(e),r=t.hasImageURI(n),i=Y.utilities.imageIdToURI(t.getCurrentImageId());return r&&i!==n}))&&delete d.cachedStats[t]}}}else d.cachedStats[a]={Modality:null,area:null,max:null,mean:null,stdDev:null,areaUnit:null,radius:null,radiusUnit:null,perimeter:null},this._calculateCachedStats(c,r,s,e);if(!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;let x;if(!ke(u))continue;if(he(c)||this.editData||null===f||(x=[y[f]]),x){Fi(t,u,"0",x,{color:v})}const C="0";Li(t,u,C,_,b,{color:v,lineDash:g,lineWidth:m},`${u}-circle`),w>0&&b>3*w&&Li(t,u,`${C}-center`,_,w,{color:v,lineDash:g,lineWidth:m}),n=!0;const D=this.getLinkedTextBoxStyle(l,c);if(!D.visibility){d.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const S=this.configuration.getTextLines(d,a);if(!S||0===S.length)continue;let T;d.handles.textBox.hasMoved||(T=Qs(E),d.handles.textBox.worldPosition=r.canvasToWorld(T));const I=r.worldToCanvas(d.handles.textBox.worldPosition),A=Hi(t,u,"1",S,I,y,{},D),{x:N,y:O,width:P,height:k}=A;d.handles.textBox.worldBoundingBox={topLeft:r.canvasToWorld([N,O]),topRight:r.canvasToWorld([N+P,O]),bottomLeft:r.canvasToWorld([N,O+k]),bottomRight:r.canvasToWorld([N+P,O+k])}}return n},this._calculateCachedStats=(e,t,n,r)=>{const i=e.data,{viewportId:o,renderingEngineId:a}=r,{points:s}=i.handles,l=s.map((e=>t.worldToCanvas(e))),{viewPlaneNormal:c,viewUp:u}=t.getCamera(),[d,h]=Ol(l),p=t.canvasToWorld(d),f=t.canvasToWorld(h),{cachedStats:m}=i,g=Object.keys(m),v=p,y=f;for(let r=0;rqo(r,e)),this.configuration.statsCalculator.statsCallback,n),S=this.configuration.statsCalculator.getStatistics();m[i]={Modality:l.Modality,area:w,mean:S[1]?.value,max:S[0]?.value,stdDev:S[2]?.value,statsArray:S,pointsInShape:D,isEmptyArea:g,areaUnit:Js(0,o),radius:a/2/b,radiusUnit:$s(0,o),perimeter:2*Math.PI*(a/2)/b,modalityUnit:C}}else this.isHandleOutsideImage=!0,m[i]={Modality:l.Modality}}e.invalidated=!1;const _=ne.ANNOTATION_MODIFIED,b={annotation:e,viewportId:o,renderingEngineId:a};return(0,Y.triggerEvent)(Y.eventTarget,_,b),m},this._isInsideVolume=(e,t,n)=>Y.utilities.indexWithinDimensions(e,n)&&Y.utilities.indexWithinDimensions(t,n),this._throttledCalculateCachedStats=To(this._calculateCachedStats,100,{trailing:!0})}}function Ml(e,t){const n=e.cachedStats[t],{radius:r,radiusUnit:i,area:o,mean:a,stdDev:s,max:l,isEmptyArea:c,Modality:u,areaUnit:d,modalityUnit:h}=n,p=[];if(r){const e=c?"Radius: Oblique not supported":`Radius: ${jo(r)} ${i}`;p.push(e)}if(o){const e=c?"Area: Oblique not supported":`Area: ${jo(o)} ${d}`;p.push(e)}return a&&p.push(`Mean: ${jo(a)} ${h}`),l&&p.push(`Max: ${jo(l)} ${h}`),s&&p.push(`Std Dev: ${jo(s)} ${h}`),p}kl.toolName="CircleROI";const Ll=kl;function Rl(e,t,n,r=!0){const i=[],o=function(e,t,n,r=!0){let i,o;const a=[];r?(o=e.length-1,i=0):(o=0,i=1);for(let r=i;r{const r=[e[n[0]],e[n[1]]],i=[(r[0][0]+r[1][0])/2,(r[0][1]+r[1][1])/2];s.push(Ci.K4.distance(i,t))}));const l=Math.min(...s);return{segment:a[s.indexOf(l)],distance:l}}function Bl(e,t,n,r){let i=!1;const o=[jl(e,t,n),jl(e,t,r),jl(n,r,e),jl(n,r,t)];return o[0]!==o[1]&&o[2]!==o[3]||((0===o[0]&&Vl(e,n,t)||0===o[1]&&Vl(e,r,t)||0===o[2]&&Vl(n,e,r)||0===o[3]&&Vl(n,t,r))&&(i=!0),i)}function jl(e,t,n){const r=(t[1]-e[1])*(n[0]-t[0])-(t[0]-e[0])*(n[1]-t[1]);return 0===r?0:r>0?1:2}function Vl(e,t,n){return t[0]<=Math.max(e[0],n[0])&&t[0]>=Math.min(e[0],n[0])&&t[1]<=Math.max(e[1],n[1])&&t[1]>=Math.min(e[1],n[1])}function Wl(e,t,n,r){const i=(r[1]-n[1])*(t[0]-e[0])-(r[0]-n[0])*(t[1]-e[1]);if(0==i)return;let o=e[1]-n[1],a=e[0]-n[0];const s=(r[0]-n[0])*o-(r[1]-n[1])*a,l=(t[0]-e[0])*o-(t[1]-e[1])*a;o=s/i,a=l/i;return[e[0]+o*(t[0]-e[0]),e[1]+o*(t[1]-e[1])]}const zl=.001,Gl=(e,t)=>{let n,r,i;if(e instanceof Y.StackViewport){const t=e.getImageData();r=t.direction.slice(0,3),i=t.direction.slice(3,6),n=t.spacing}else{const t=e.getImageData(),{direction:o,spacing:a}=t,{viewPlaneNormal:s,viewUp:l}=e.getCamera(),c=o.slice(0,3),u=o.slice(3,6),d=o.slice(6,9),h=Ci.R3.create();Ci.R3.cross(h,l,s);const p=Math.abs(Ci.R3.dot(h,c)),f=Math.abs(Ci.R3.dot(h,u)),m=Math.abs(Ci.R3.dot(h,d));let g;if(Math.abs(1-p)Ci.K4.dist(e,t){const{xDir:i,yDir:o,spacing:a}=r,s=(0,Y.getEnabledElement)(e),{viewport:l}=s,c=l.canvasToWorld(t[t.length-1]),u=l.canvasToWorld(n),d=Ci.R3.create();Ci.R3.subtract(d,u,c);const h=Math.abs(Ci.R3.dot(d,i)),p=Math.abs(Ci.R3.dot(d,o)),f=Math.max(Math.floor(h/a[0]),Math.floor(p/a[0]));if(f>1){const e=t[t.length-1],r=Ci.K4.dist(e,n),i=Ci.K4.create();Ci.K4.subtract(i,n,e),Ci.K4.set(i,i[0]/r,i[1]/r);const o=r/f;for(let n=1;n<=f;n++)t.push([e[0]+o*i[0]*n,e[1]+o*i[1]*n])}else t.push(n);return f},Kl=(e,t,n,r)=>{const i=[e[0]-t[0],e[1]-t[1]],o=[n[0]-t[0],n[1]-t[1]],a=i[0]*o[0]+i[1]*o[1];if(a<0)return!1;const s=Math.sqrt(o[0]*o[0]+o[1]*o[1]);if(0===s)return!1;const l=a/s,c=[o[0]/s,o[1]/s],u=[c[0]*l,c[1]*l],d=[t[0]+u[0],t[1]+u[1]];return!(Ci.K4.distance(e,d)>r)&&!(Ci.K4.distance(t,d)>Ci.K4.distance(t,n))};function Xl(e){const t=e.length;let n=0,r=t-1;for(let i=0;ie[t][0]))),i=(0,$l.nH)(t.map((t=>e[t][1])));if(o=e,3===o[0]?.length){const o=(0,$l.nH)(t.map((t=>e[t][2])));return(0,Jl.$R)((0,$l.q$)(r,n),(0,$l.q$)(i,n),(0,$l.q$)(o,n))}return(0,Jl.$R)((0,$l.q$)(r,n),(0,$l.q$)(i,n));var o}(e,d);return[...c,...h,...u]}function Zl(e){return!0===e?.interpolation?.interpolateOnAdd||!0===e?.interpolation?.interpolateOnEdit}function Ql(e,t,n){return(e+t+n)%t}function ec(e,t,n,r){const[,i,o]=e,[,a,s]=t,l=o.length,c=s.length;let u=e[0],d=t[0];if(!(o[u]&&s[d]&&o[i]&&s[a]))return[void 0,void 0];for(;u!==i&&d!==a;){if(n(s[d],o[u]))return[u,d];u=Ql(u,l,r),d=Ql(d,c,r)}return[void 0,void 0]}function tc(e,t){const[n,r]=function(e,t){for(let i=0;i!1===function(e,t){return Al(e,t)<.001}(e,t),[o,a]=ec([Ql(n,e.length,1),n,e],[Ql(r,t.length,1),r,t],i,1),[s]=ec([Ql(o,e.length,-1),o,e],[Ql(a,t.length,-1),a,t],i,-1);return[o,s]}function nc(e,t,n){const{interpolation:r}=e,i=t;if(r){const{knotsRatioPercentageOnAdd:e,knotsRatioPercentageOnEdit:i,interpolateOnAdd:o=!1,interpolateOnEdit:a=!1}=r,s=n?i:e;if(n?a:o){const[e,r]=n?tc(t,n):[0,t.length-1];return t[e]&&t[r]?Yl(t,e,r,s):t}}return i}function rc(e,t){const n=e[0],r=e[e.length-1],i=Ci.K4.create();Ci.K4.set(i,r[0]-n[0],r[1]-n[1]),Ci.K4.normalize(i,i);const o=Ci.K4.create(),a=Ci.K4.create();Ci.K4.set(o,-i[1],i[0]),Ci.K4.set(a,i[1],-i[0]);const s=[(n[0]+r[0])/2,(n[1]+r[1])/2],l={dist:0,index:null};for(let t=0;tl.dist&&(l.dist=r,l.index=t)}return[e[l.index],s].map(t.canvasToWorld)}const{addCanvasPointsToArray:ic,pointsAreWithinCloseContourProximity:oc,getFirstIntersectionWithPolyline:ac,getSubPixelSpacingAndXYDirections:sc}=P;function lc(e,t,n){this.isDrawing=!0;const r=e.detail,{currentPoints:i,element:o}=r,a=i.canvas,s=(0,Y.getEnabledElement)(o),{viewport:l}=s,{spacing:c,xDir:u,yDir:d}=sc(l,this.configuration.subPixelResolution);this.drawData={canvasPoints:[a],polylineIndex:0},this.commonData={annotation:t,viewportIdsToRender:n,spacing:c,xDir:u,yDir:d,movingTextBox:!1},He.isInteractingWithTool=!0,o.addEventListener(ne.MOUSE_UP,this.mouseUpDrawCallback),o.addEventListener(ne.MOUSE_DRAG,this.mouseDragDrawCallback),o.addEventListener(ne.MOUSE_CLICK,this.mouseUpDrawCallback),o.addEventListener(ne.TOUCH_END,this.mouseUpDrawCallback),o.addEventListener(ne.TOUCH_DRAG,this.mouseDragDrawCallback),o.addEventListener(ne.TOUCH_TAP,this.mouseUpDrawCallback),Ia(o)}function cc(e){He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this.mouseUpDrawCallback),e.removeEventListener(ne.MOUSE_DRAG,this.mouseDragDrawCallback),e.removeEventListener(ne.MOUSE_CLICK,this.mouseUpDrawCallback),e.removeEventListener(ne.TOUCH_END,this.mouseUpDrawCallback),e.removeEventListener(ne.TOUCH_DRAG,this.mouseDragDrawCallback),e.removeEventListener(ne.TOUCH_TAP,this.mouseUpDrawCallback),Ta(e)}function uc(e){const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=n.canvas,a=(0,Y.getEnabledElement)(r),{renderingEngine:s,viewport:l}=a,{annotation:c,viewportIdsToRender:u,xDir:d,yDir:h,spacing:p,movingTextBox:f}=this.commonData,{polylineIndex:m,canvasPoints:g}=this.drawData,v=g[g.length-1],y=l.canvasToWorld(v),_=Ci.R3.create();Ci.R3.subtract(_,i,y);const b=Math.abs(Ci.R3.dot(_,d)),E=Math.abs(Ci.R3.dot(_,h));if(!(b<=p[0]&&E<=p[1])){if(f){this.isDrawing=!1;const{deltaPoints:e}=t,n=e.world,{textBox:r}=c.data.handles,{worldPosition:i}=r;i[0]+=n[0],i[1]+=n[1],i[2]+=n[2],r.hasMoved=!0}else{const t=this.findCrossingIndexDuringCreate(e);if(void 0!==t)this.applyCreateOnCross(e,t);else{const e=ic(r,g,o,this.commonData);this.drawData.polylineIndex=m+e}}Po(s,u)}}function dc(e){const{allowOpenContours:t}=this.configuration,{canvasPoints:n}=this.drawData,r=n[0],i=n[n.length-1],o=e.detail,{element:a}=o;t&&!oc(r,i,this.configuration.closeContourProximity)?this.completeDrawOpenContour(a):this.completeDrawClosedContour(a)}function hc(e){this.removeCrossedLinesOnCompleteDraw();const{canvasPoints:t}=this.drawData;if(this.haltDrawing(e,t))return!1;const{annotation:n,viewportIdsToRender:r}=this.commonData,i=(0,Y.getEnabledElement)(e),{viewport:o,renderingEngine:a}=i;ic(e,t,t[0],this.commonData),t.pop();const s=(Zl(this.configuration)?nc(this.configuration,t):t).map((e=>o.canvasToWorld(e)));n.data.polyline=s,n.data.isOpenContour=!1;const{textBox:l}=n.data.handles;return l.hasMoved||this.triggerAnnotationCompleted(n),this.isDrawing=!1,this.drawData=void 0,this.commonData=void 0,Po(a,r),this.deactivateDraw(e),!0}function pc(){const{canvasPoints:e}=this.drawData,t=e.length,n=[e[0],e[t-1]],r=e.slice(0,-1).slice(1),i=ac(r,n[0],n[1],!1);if(i){const t=i[1];this.drawData.canvasPoints=e.splice(0,t)}}function fc(e){const{canvasPoints:t}=this.drawData;if(this.haltDrawing(e,t))return!1;const{annotation:n,viewportIdsToRender:r}=this.commonData,i=(0,Y.getEnabledElement)(e),{viewport:o,renderingEngine:a}=i,s=(Zl(this.configuration)?nc(this.configuration,t):t).map((e=>o.canvasToWorld(e)));n.data.polyline=s,n.data.isOpenContour=!0;const{textBox:l}=n.data.handles;return n.data.handles.points=[s[0],s[s.length-1]],n.data.isOpenUShapeContour&&(n.data.openUShapeContourVectorToPeak=rc(t,o)),l.hasMoved||this.triggerAnnotationCompleted(n),this.isDrawing=!1,this.drawData=void 0,this.commonData=void 0,Po(a,r),this.deactivateDraw(e),!0}function mc(e){const t=e.detail,{currentPoints:n,lastPoints:r}=t,i=n.canvas,o=r.canvas,{canvasPoints:a}=this.drawData,s=a.slice(0,-1),l=ac(s,i,o,!1);if(void 0===l)return;return l[0]}function gc(e,t){const n=e.detail,{element:r}=n,{canvasPoints:i}=this.drawData,{annotation:o,viewportIdsToRender:a}=this.commonData;ic(r,i,i[t],this.commonData),i.pop();for(let e=0;e=2)if(l.length>this.configuration.checkCanvasEditFallbackProximity){const e=l[0],t=[];for(let n=0;ne.distance-t.distance));const n=[t[0],t[1]],r=Math.min(n[0].index,n[1].index);this.editData.startCrossingIndex=r}else{const e=Ci.K4.create();Ci.K4.subtract(e,l[1],l[0]),Ci.K4.normalize(e,e);const n=6,i=[l[0][0]-e[0]*n,l[0][1]-e[1]*n],o=Ec(c,i,l[0],t);if(o){const e=[i];bc(r,e,l[0],this.commonData),l.unshift(...e),this.removePointsUpUntilFirstCrossing(t),this.editData.editIndex=l.length-1,this.editData.startCrossingIndex=o[0]}}}function xc(e){const{editCanvasPoints:t,prevCanvasPoints:n}=this.editData;let r=0;for(let i=0;i0;r--){const i=[n[r],n[r-1]],o=!!Ec(t,i[0],i[1],e);if(n.pop(),o)break}}function Sc(){const{editCanvasPoints:e,prevCanvasPoints:t,startCrossingIndex:n}=this.editData;if(void 0===n)return;const r=e[e.length-1],i=[];for(let e=0;ee.distance-t.distance));const o=e.slice(0,-1);for(let n=0;n1&&this.checkForFirstCrossing(e,!0),this.editData.snapIndex=this.findSnapIndex(),-1!==this.editData.snapIndex?(this.editData.fusedCanvasPoints=this.fuseEditPointsWithClosedContour(e),void 0!==m&&this.checkForSecondCrossing(e,!0)&&(this.removePointsAfterSecondCrossing(!0),this.finishEditAndStartNewEdit(e)),Po(s,c)):this.finishEditAndStartNewEdit(e)}function Lc(e){const t=e.detail,{element:n}=t,r=(0,Y.getEnabledElement)(n),{viewport:i,renderingEngine:o}=r,{annotation:a,viewportIdsToRender:s}=this.commonData,{fusedCanvasPoints:l,editCanvasPoints:c}=this.editData,u=l.map((e=>i.canvasToWorld(e)));a.data.polyline=u,a.data.isOpenContour=!1,this.triggerAnnotationModified(a,r);const d=c.pop();this.editData={prevCanvasPoints:l,editCanvasPoints:[d],startCrossingIndex:void 0,editIndex:0,snapIndex:void 0},Po(o,s)}function Rc(e){const{prevCanvasPoints:t,editCanvasPoints:n,startCrossingIndex:r,snapIndex:i}=this.editData;if(void 0===r||void 0===i)return;const o=e.detail,{element:a}=o,s=[...n];let l,c;Nc(a,s,t[i],this.commonData),s.length>n.length&&s.pop(),r>i?(l=i,c=r):(l=r,c=i);const u=Ci.K4.distance(t[l],s[0]),d=Ci.K4.distance(t[l],s[s.length-1]),h=Ci.K4.distance(t[c],s[0]),p=Ci.K4.distance(t[c],s[s.length-1]),f=[];for(let e=0;e=0;e--){const t=s[e];f.push([t[0],t[1]])}for(let e=c;e=0;e--){const t=s[e];v.push([t[0],t[1]])}return Oc(f)>Oc(v)?f:v}function Fc(e){const t=e.detail,{element:n}=t;this.completeClosedContourEdit(n)}function Uc(e){const t=(0,Y.getEnabledElement)(e),{viewport:n,renderingEngine:r}=t,{annotation:i,viewportIdsToRender:o}=this.commonData,{fusedCanvasPoints:a,prevCanvasPoints:s}=this.editData;if(a){const e=(Zl(this.configuration)?nc(this.configuration,a,s):a).map((e=>n.canvasToWorld(e)));i.data.polyline=e,i.data.isOpenContour=!1,i.invalidated=!0,this.triggerAnnotationModified(i,t)}this.isEditingClosed=!1,this.editData=void 0,this.commonData=void 0,Po(r,o),this.deactivateClosedContourEdit(e)}function Bc(e){this.completeClosedContourEdit(e)}const jc=function(e){e.activateClosedContourEdit=Pc.bind(e),e.deactivateClosedContourEdit=kc.bind(e),e.mouseDragClosedContourEditCallback=Mc.bind(e),e.mouseUpClosedContourEditCallback=Fc.bind(e),e.finishEditAndStartNewEdit=Lc.bind(e),e.fuseEditPointsWithClosedContour=Rc.bind(e),e.cancelClosedContourEdit=Bc.bind(e),e.completeClosedContourEdit=Uc.bind(e)},{addCanvasPointsToArray:Vc,getSubPixelSpacingAndXYDirections:Wc}=P;function zc(e,t,n){this.isEditingOpen=!0;const r=e.detail,{currentPoints:i,element:o}=r,a=i.canvas,s=(0,Y.getEnabledElement)(o),{viewport:l}=s,c=t.data.polyline.map(l.worldToCanvas),{spacing:u,xDir:d,yDir:h}=Wc(l,this.configuration.subPixelResolution);this.editData={prevCanvasPoints:c,editCanvasPoints:[a],startCrossingIndex:void 0,editIndex:0},this.commonData={annotation:t,viewportIdsToRender:n,spacing:u,xDir:d,yDir:h,movingTextBox:!1},He.isInteractingWithTool=!0,o.addEventListener(ne.MOUSE_UP,this.mouseUpOpenContourEditCallback),o.addEventListener(ne.MOUSE_DRAG,this.mouseDragOpenContourEditCallback),o.addEventListener(ne.MOUSE_CLICK,this.mouseUpOpenContourEditCallback),o.addEventListener(ne.TOUCH_END,this.mouseUpOpenContourEditCallback),o.addEventListener(ne.TOUCH_DRAG,this.mouseDragOpenContourEditCallback),o.addEventListener(ne.TOUCH_TAP,this.mouseUpOpenContourEditCallback),Ia(o)}function Gc(e){He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this.mouseUpOpenContourEditCallback),e.removeEventListener(ne.MOUSE_DRAG,this.mouseDragOpenContourEditCallback),e.removeEventListener(ne.MOUSE_CLICK,this.mouseUpOpenContourEditCallback),e.removeEventListener(ne.TOUCH_END,this.mouseUpOpenContourEditCallback),e.removeEventListener(ne.TOUCH_DRAG,this.mouseDragOpenContourEditCallback),e.removeEventListener(ne.TOUCH_TAP,this.mouseUpOpenContourEditCallback),Ta(e)}function Hc(e){const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=n.canvas,a=(0,Y.getEnabledElement)(r),{renderingEngine:s,viewport:l}=a,{viewportIdsToRender:c,xDir:u,yDir:d,spacing:h}=this.commonData,{editIndex:p,editCanvasPoints:f,startCrossingIndex:m}=this.editData,g=f[f.length-1],v=l.canvasToWorld(g),y=Ci.R3.create();Ci.R3.subtract(y,i,v);const _=Math.abs(Ci.R3.dot(y,u)),b=Math.abs(Ci.R3.dot(y,d));if(_<=h[0]&&b<=h[1])return;void 0!==m&&this.checkAndRemoveCrossesOnEditLine(e);const E=p+Vc(r,f,o,this.commonData);this.editData.editIndex=E,void 0===m&&f.length>1&&this.checkForFirstCrossing(e,!1),this.editData.snapIndex=this.findSnapIndex(),this.editData.fusedCanvasPoints=this.fuseEditPointsWithOpenContour(e),void 0!==m&&this.checkForSecondCrossing(e,!1)?(this.removePointsAfterSecondCrossing(!1),this.finishEditOpenOnSecondCrossing(e)):this.checkIfShouldOverwriteAnEnd(e)&&this.openContourEditOverwriteEnd(e),Po(s,c)}function qc(e){const t=e.detail,{element:n}=t,r=(0,Y.getEnabledElement)(n),{viewport:i}=r,{annotation:o,viewportIdsToRender:a}=this.commonData,s=this.fuseEditPointsForOpenContourEndEdit().map((e=>i.canvasToWorld(e)));o.data.polyline=s,o.data.isOpenContour=!0,o.data.handles.points=[s[0],s[s.length-1]],o.data.handles.activeHandleIndex=1,this.triggerAnnotationModified(o,r),this.isEditingOpen=!1,this.editData=void 0,this.commonData=void 0,this.deactivateOpenContourEdit(n),this.activateOpenContourEndEdit(e,o,a,null)}function Kc(e){const t=e.detail,{currentPoints:n,lastPoints:r}=t,i=n.canvas,o=r.canvas,{snapIndex:a,prevCanvasPoints:s,startCrossingIndex:l}=this.editData;if(void 0===l||void 0===a)return!1;if(-1===a)return!0;if(0!==a&&a!==s.length-1)return!1;const c=i,u=o,d=s[a],h=Ci.K4.create(),p=Ci.K4.create();Ci.K4.set(h,c[0]-u[0],c[1]-u[1]),Ci.K4.set(p,c[0]-d[0],c[1]-d[1]);const f=Ci.K4.dot(h,p),m=Math.sqrt(h[0]*h[0]+h[1]*h[1]),g=Math.sqrt(p[0]*p[0]+p[1]*p[1]);return Math.acos(f/(m*g))=r;e--){const n=t[e];i.push([n[0],n[1]])}else for(let e=0;e=0;e--){const t=n[e];i.push([t[0],t[1]])}return i}function $c(e){const{prevCanvasPoints:t,editCanvasPoints:n,startCrossingIndex:r,snapIndex:i}=this.editData;if(void 0===r||void 0===i)return;const o=e.detail,{element:a}=o,s=[...n];let l,c;Vc(a,s,t[i],this.commonData),s.length>n.length&&s.pop(),r>i?(l=i,c=r):(l=r,c=i);const u=Ci.K4.distance(t[l],s[0]),d=Ci.K4.distance(t[l],s[s.length-1]),h=Ci.K4.distance(t[c],s[0]),p=Ci.K4.distance(t[c],s[s.length-1]),f=[];for(let e=0;e=0;e--){const t=s[e];f.push([t[0],t[1]])}for(let e=c;ei.canvasToWorld(e)));a.data.polyline=u,a.data.isOpenContour=!0,a.data.handles.points=[u[0],u[u.length-1]],this.triggerAnnotationModified(a,r);const d=c.pop();this.editData={prevCanvasPoints:l,editCanvasPoints:[d],startCrossingIndex:void 0,editIndex:0},Po(o,s)}function Yc(e){const t=e.detail,{element:n}=t;this.completeOpenContourEdit(n)}function Zc(e){const t=(0,Y.getEnabledElement)(e),{viewport:n,renderingEngine:r}=t,{annotation:i,viewportIdsToRender:o}=this.commonData,{fusedCanvasPoints:a,prevCanvasPoints:s}=this.editData;if(a){const e=(Zl(this.configuration)?nc(this.configuration,a,s):a).map((e=>n.canvasToWorld(e)));i.data.polyline=e,i.data.isOpenContour=!0,i.data.handles.points=[e[0],e[e.length-1]],i.data.isOpenUShapeContour&&(i.data.openUShapeContourVectorToPeak=rc(a,n)),i.invalidated=!0,this.triggerAnnotationModified(i,t)}this.isEditingOpen=!1,this.editData=void 0,this.commonData=void 0,Po(r,o),this.deactivateOpenContourEdit(e)}function Qc(e){this.completeOpenContourEdit(e)}const eu=function(e){e.activateOpenContourEdit=zc.bind(e),e.deactivateOpenContourEdit=Gc.bind(e),e.mouseDragOpenContourEditCallback=Hc.bind(e),e.mouseUpOpenContourEditCallback=Yc.bind(e),e.fuseEditPointsWithOpenContour=$c.bind(e),e.finishEditOpenOnSecondCrossing=Jc.bind(e),e.checkIfShouldOverwriteAnEnd=Kc.bind(e),e.fuseEditPointsForOpenContourEndEdit=Xc.bind(e),e.openContourEditOverwriteEnd=qc.bind(e),e.cancelOpenContourEdit=Qc.bind(e),e.completeOpenContourEdit=Zc.bind(e)},{getSubPixelSpacingAndXYDirections:tu}=P;function nu(e,t,n,r){this.isDrawing=!0;const i=e.detail,{element:o}=i,a=(0,Y.getEnabledElement)(o),{viewport:s}=a,{spacing:l,xDir:c,yDir:u}=tu(s,this.configuration.subPixelResolution),d=t.data.polyline.map(s.worldToCanvas);0===t.data.handles.activeHandleIndex&&d.reverse();let h=!1;r.worldPosition&&(h=!0),this.drawData={canvasPoints:d,polylineIndex:d.length-1},this.commonData={annotation:t,viewportIdsToRender:n,spacing:l,xDir:c,yDir:u,movingTextBox:h},He.isInteractingWithTool=!0,o.addEventListener(ne.MOUSE_UP,this.mouseUpDrawCallback),o.addEventListener(ne.MOUSE_DRAG,this.mouseDragDrawCallback),o.addEventListener(ne.MOUSE_CLICK,this.mouseUpDrawCallback),o.addEventListener(ne.TOUCH_END,this.mouseUpDrawCallback),o.addEventListener(ne.TOUCH_DRAG,this.mouseDragDrawCallback),o.addEventListener(ne.TOUCH_TAP,this.mouseUpDrawCallback),Ia(o)}const ru=function(e){e.activateOpenContourEndEdit=nu.bind(e)},{pointsAreWithinCloseContourProximity:iu}=P;function ou(e,t){const n={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id,annotationUID:t.annotationUID},r=this.getStyle("lineWidth",n,t),i=this.getStyle("lineDash",n,t),o=this.getStyle("color",n,t);return{color:void 0===o?void 0:o,width:void 0===r?void 0:r,lineDash:void 0===i?void 0:i,connectLastToFirst:!t.data.isOpenContour}}function au(e,t,n){e?.viewport?.getImageData()&&(n.data.isOpenContour?n.data.isOpenUShapeContour?(!function(e,t){t.data.openUShapeContourVectorToPeak||(t.data.openUShapeContourVectorToPeak=function(e,t){const{viewport:n}=e;return rc(t.data.polyline.map(n.worldToCanvas),n)}(e,t))}(e,n),this.renderOpenUShapedContour(e,t,n)):this.renderOpenContour(e,t,n):this.renderClosedContour(e,t,n))}function su(e,t,n){const{viewport:r}=e,i=this._getRenderingOptions(e,n),o=n.data.polyline.map((e=>r.worldToCanvas(e)));Bi(t,n.annotationUID,"1",o,i)}function lu(e,t,n){const{viewport:r}=e,i=this._getRenderingOptions(e,n),o=n.data.polyline.map((e=>r.worldToCanvas(e)));Bi(t,n.annotationUID,"1",o,i);const a=n.data.handles.activeHandleIndex;if(!0===this.configuration.alwaysRenderOpenContourHandles?.enabled){const e=this.configuration.alwaysRenderOpenContourHandles.radius,r="0",s=[o[0],o[o.length-1]];0===a?s.shift():1===a&&s.pop(),Fi(t,n.annotationUID,r,s,{color:i.color,handleRadius:e})}if(null!==a){const e="1",r=o[0===a?0:o.length-1];Fi(t,n.annotationUID,e,[r],{color:i.color})}}function cu(e,t,n){const{viewport:r}=e,{polyline:i,openUShapeContourVectorToPeak:o}=n.data;if(this.renderOpenContour(e,t,n),!o)return;const a=r.worldToCanvas(i[0]),s=r.worldToCanvas(i[i.length-1]),l=[r.worldToCanvas(o[0]),r.worldToCanvas(o[1])],c=this._getRenderingOptions(e,n);Bi(t,n.annotationUID,"first-to-last",[a,s],{color:c.color,width:c.width,connectLastToFirst:!1,lineDash:"2,2"}),Bi(t,n.annotationUID,"midpoint-to-open-contour",[l[0],l[1]],{color:c.color,width:c.width,connectLastToFirst:!1,lineDash:"2,2"})}function uu(e,t,n){const r=this._getRenderingOptions(e,n),{allowOpenContours:i}=this.configuration,{canvasPoints:o}=this.drawData;if(r.connectLastToFirst=!1,Bi(t,n.annotationUID,"1",o,r),i){const e=o[0],i=o[o.length-1];if(iu(e,i,this.configuration.closeContourProximity))Bi(t,n.annotationUID,"2",[i,e],r);else{const i="0";Fi(t,n.annotationUID,i,[e],{color:r.color,handleRadius:2})}}}function du(e,t,n){const{fusedCanvasPoints:r}=this.editData;if(void 0===r)return void this.renderClosedContour(e,t,n);const i=this._getRenderingOptions(e,n);Bi(t,n.annotationUID,"preview-1",r,i)}function hu(e,t,n){const{fusedCanvasPoints:r}=this.editData;if(void 0===r)return void this.renderOpenContour(e,t,n);const i=this._getRenderingOptions(e,n);Bi(t,n.annotationUID,"preview-1",r,i)}const pu=function(e){e.renderContour=au.bind(e),e.renderClosedContour=su.bind(e),e.renderOpenContour=lu.bind(e),e.renderOpenUShapedContour=cu.bind(e),e.renderContourBeingDrawn=uu.bind(e),e.renderClosedContourBeingEdited=du.bind(e),e.renderOpenContourBeingEdited=hu.bind(e),e._getRenderingOptions=ou.bind(e)},{pointCanProjectOnLine:fu}=P,{EPSILON:mu}=Y.CONSTANTS,gu=1-mu;class vu extends ho{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1,alwaysRenderOpenContourHandles:{enabled:!1,radius:2},allowOpenContours:!0,closeContourProximity:10,checkCanvasEditFallbackProximity:6,subPixelResolution:4,interpolation:{interpolateOnAdd:!1,interpolateOnEdit:!1,knotsRatioPercentageOnAdd:40,knotsRatioPercentageOnEdit:40},calculateStats:!1,getTextLines:yu,statsCalculator:_l}}){super(e,t),this.isDrawing=!1,this.isEditingClosed=!1,this.isEditingOpen=!1,this.addNewAnnotation=e=>{const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=(0,Y.getEnabledElement)(r),{viewport:a,renderingEngine:s}=o,l=a.getCamera(),{viewPlaneNormal:c,viewUp:u}=l,d=this.getReferencedImageId(a,i,c,u),h=vs(r,this.getToolName()),p=a.getFrameOfReferenceUID(),f={highlighted:!0,invalidated:!0,metadata:{viewPlaneNormal:[...c],viewUp:[...u],FrameOfReferenceUID:p,referencedImageId:d,toolName:this.getToolName()},data:{handles:{points:[],activeHandleIndex:null,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},polyline:[[...i]],label:"",cachedStats:{}}};return ig(f,r),this.activateDraw(e,f,h),e.preventDefault(),Po(s,h),f},this.handleSelectedCallback=(e,t,n)=>{const r=e.detail,{element:i}=r,o=vs(i,this.getToolName());this.activateOpenContourEndEdit(e,t,o,n)},this.toolSelectedCallback=(e,t)=>{const n=e.detail,{element:r}=n,i=vs(r,this.getToolName());t.data.isOpenContour?this.activateOpenContourEdit(e,t,i):this.activateClosedContourEdit(e,t,i)},this.isPointNearTool=(e,t,n,r)=>{const i=(0,Y.getEnabledElement)(e),{viewport:o}=i,a=t.data.polyline;let s=o.worldToCanvas(a[0]);for(let e=1;e{const t=this.isDrawing,n=this.isEditingOpen,r=this.isEditingClosed;t?this.cancelDrawing(e):n?this.cancelOpenContourEdit(e):r&&this.cancelClosedContourEdit(e)},this.triggerAnnotationModified=(e,t)=>{const{viewportId:n,renderingEngineId:r}=t,i=ne.ANNOTATION_MODIFIED,o={annotation:e,viewportId:n,renderingEngineId:r};(0,Y.triggerEvent)(Y.eventTarget,i,o)},this.triggerAnnotationCompleted=e=>{const t=ne.ANNOTATION_COMPLETED,n={annotation:e};(0,Y.triggerEvent)(Y.eventTarget,t,n)},this.renderAnnotation=(e,t)=>{let n=!1;const{viewport:r,renderingEngine:i}=e,{element:o}=r,a=this.getTargetId(r);let s=rg(this.getToolName(),o);if(!s?.length)return n;if(s=this.filterInteractableAnnotationsForElement(o,s),!s?.length)return n;const l=this.isDrawing,c=this.isEditingOpen,u=this.isEditingClosed;if(l||c||u){const r=this.commonData.annotation.annotationUID;s.forEach((n=>{if(n.annotationUID===r)if(l)this.renderContourBeingDrawn(e,t,n);else if(u)this.renderClosedContourBeingEdited(e,t,n);else{if(!c)throw new Error(`Unknown ${this.getToolName()} annotation rendering state`);this.renderOpenContourBeingEdited(e,t,n)}else this.renderContour(e,t,n)})),n=!0}else s.forEach((n=>{this.renderContour(e,t,n)}));return this.configuration.calculateStats?(s.forEach((n=>{const o=this.commonData?.annotation.annotationUID;if(n.annotationUID!==o||this.commonData?.movingTextBox){if(!this.commonData?.movingTextBox){const{data:t}=n;t.cachedStats[a]&&null!=t.cachedStats[a].areaUnit?n.invalidated&&this._throttledCalculateCachedStats(n,r,i,e):(t.cachedStats[a]={Modality:null,area:null,max:null,mean:null,stdDev:null,areaUnit:null},this._calculateCachedStats(n,r,i,e))}this._renderStats(n,r,e,t)}})),n):void 0},this._calculateCachedStats=(e,t,n,r)=>{const i=e.data,{cachedStats:o,polyline:a}=i,s=Object.keys(o);for(let r=0;rt.worldToCanvas(e))),h=d[0],p=t.canvasToWorld(h),f=t.canvasToWorld([h[0]+1,h[1]]),m=t.canvasToWorld([h[0],h[1]+1]),g=Ci.R3.distance(p,f),v=Ci.R3.distance(p,m),y=Ys(l);let _=Xl(d)/y/y;_*=g*v;const b=Y.utilities.transformWorldToIndex(c,a[0]);b[0]=Math.floor(b[0]),b[1]=Math.floor(b[1]),b[2]=Math.floor(b[2]);let E=b[0],w=b[0],x=b[1],C=b[1],D=b[2],S=b[2];for(let e=1;e{let r=!0;const i=t.worldToCanvas(e);return i[1]!=k&&(L=0,k=i[1],M=Rl(d,i,[P[0],i[1]]),M.sort((function(e,t){return e[0]===t[0]?0:e[0]M[0][0]&&(M.shift(),L++),L%2==0&&(r=!1),r}),this.configuration.statsCalculator.statsCallback,N),F={isPreScaled:cl(t,i),isSuvScaled:this.isSuvScaled(t,i,e.metadata.referencedImageId)},U=ll(u.Modality,e.metadata.referencedImageId,F),B=this.configuration.statsCalculator.getStatistics();o[i]={Modality:u.Modality,area:_,mean:B[1]?.value,max:B[0]?.value,stdDev:B[3]?.value,statsArray:B,pointsInShape:R,areaUnit:Js(0,l),modalityUnit:U}}return this.triggerAnnotationModified(e,r),e.invalidated=!1,o},this._renderStats=(e,t,n,r)=>{const i=e.data,o=this.getTargetId(t),a={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id},s=this.getLinkedTextBoxStyle(a,e);if(!s.visibility)return;const l=this.configuration.getTextLines(i,o);if(!l||0===l.length)return;const c=i.polyline.map((e=>t.worldToCanvas(e)));if(!i.handles.textBox.hasMoved){const e=Qs(c);i.handles.textBox.worldPosition=t.canvasToWorld(e)}const u=t.worldToCanvas(i.handles.textBox.worldPosition),d=Hi(r,e.annotationUID??"","1",l,u,c,{},s),{x:h,y:p,width:f,height:m}=d;i.handles.textBox.worldBoundingBox={topLeft:t.canvasToWorld([h,p]),topRight:t.canvasToWorld([h+f,p]),bottomLeft:t.canvasToWorld([h,p+m]),bottomRight:t.canvasToWorld([h+f,p+m])}},_c(this),Ic(this),jc(this),eu(this),ru(this),pu(this),this._throttledCalculateCachedStats=To(this._calculateCachedStats,100,{trailing:!0})}filterInteractableAnnotationsForElement(e,t){if(!t||!t.length)return;const n=(0,Y.getEnabledElement)(e),{viewport:r}=n;let i;if(r instanceof Y.StackViewport)i=ro(r,t);else{if(!(r instanceof Y.VolumeViewport))throw new Error(`Viewport Type ${r.type} not supported`);{const e=r.getCamera(),{spacingInNormalDirection:n}=Y.utilities.getTargetVolumeAndSpacingInNormalDir(r,e);i=this.filterAnnotationsWithinSlice(t,e,n)}}return i}filterAnnotationsWithinSlice(e,t,n){const{viewPlaneNormal:r}=t,i=e.filter((e=>{const t=e.metadata.viewPlaneNormal,n=Math.abs(Ci.R3.dot(r,t))>gu;return t&&n}));if(!i.length)return[];const o=n/2,{focalPoint:a}=t,s=[];for(const e of i){const t=e.data.polyline[0];if(!e.isVisible)continue;const n=Ci.R3.create();Ci.R3.sub(n,a,t);const i=Ci.R3.dot(n,r);Math.abs(i){const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=(0,Y.getEnabledElement)(r),{viewport:a,renderingEngine:s}=o;Ia(r),this.isDrawing=!0;const l=a.getCamera(),{viewPlaneNormal:c,viewUp:u}=l,d=this.getReferencedImageId(a,i,c,u),{arrowFirst:h}=this.configuration,p=a.getFrameOfReferenceUID(),f={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...c],viewUp:[...u],FrameOfReferenceUID:p,referencedImageId:d},data:{text:"",handles:{points:[[...i],[...i]],activeHandleIndex:null,arrowFirst:h,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},label:""}};ig(f,r);const m=vs(r,this.getToolName());return this.editData={annotation:f,viewportIdsToRender:m,handleIndex:1,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(r),e.preventDefault(),Po(s,m),f},this.isPointNearTool=(e,t,n,r)=>{const i=(0,Y.getEnabledElement)(e),{viewport:o}=i,{data:a}=t,[s,l]=a.handles.points,c=o.worldToCanvas(s),u=o.worldToCanvas(l),d={start:{x:c[0],y:c[1]},end:{x:u[0],y:u[1]}};return Ds([d.start.x,d.start.y],[d.end.x,d.end.y],[n[0],n[1]])<=r},this.toolSelectedCallback=(e,t)=>{const n=e.detail,{element:r}=n;t.highlighted=!0;const i=vs(r,this.getToolName());this.editData={annotation:t,viewportIdsToRender:i,movingTextBox:!1},this._activateModify(r),Ia(r);const o=(0,Y.getEnabledElement)(r),{renderingEngine:a}=o;Po(a,i),e.preventDefault()},this._endCallback=e=>{const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,newAnnotation:o,hasMoved:a}=this.editData,{data:s}=r;if(o&&!a)return;s.handles.activeHandleIndex=null,this._deactivateModify(n),this._deactivateDraw(n),Ta(n);const l=(0,Y.getEnabledElement)(n),{viewportId:c,renderingEngineId:u,renderingEngine:d}=l;if(this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&ag(r.annotationUID),o)this.configuration.getTextCallback((e=>{if(!e)return ag(r.annotationUID),Po(d,i),this.editData=null,void(this.isDrawing=!1);r.data.text=e;const t=ne.ANNOTATION_COMPLETED,n={annotation:r};(0,Y.triggerEvent)(Y.eventTarget,t,n),Po(d,i)}));else{const e=ne.ANNOTATION_MODIFIED,t={annotation:r,viewportId:c,renderingEngineId:u};(0,Y.triggerEvent)(Y.eventTarget,e,t)}this.editData=null,this.isDrawing=!1},this._dragCallback=e=>{this.isDrawing=!0;const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,handleIndex:o,movingTextBox:a}=this.editData,{data:s}=r;if(a){const{deltaPoints:e}=t,n=e.world,{textBox:r}=s.handles,{worldPosition:i}=r;i[0]+=n[0],i[1]+=n[1],i[2]+=n[2],r.hasMoved=!0}else if(void 0===o){const{deltaPoints:e}=t,n=e.world;s.handles.points.forEach((e=>{e[0]+=n[0],e[1]+=n[1],e[2]+=n[2]})),r.invalidated=!0}else{const{currentPoints:e}=t,n=e.world;s.handles.points[o]=[...n],r.invalidated=!0}this.editData.hasMoved=!0;const l=(0,Y.getEnabledElement)(n),{renderingEngine:c}=l;Po(c,i)},this.touchTapCallback=e=>{2==e.detail.taps&&this.doubleClickCallback(e)},this.doubleClickCallback=e=>{const t=e.detail,{element:n}=t;let r=rg(this.getToolName(),n);if(r=this.filterInteractableAnnotationsForElement(n,r),!r?.length)return;const i=r.find((e=>this.isPointNearTool(n,e,t.currentPoints.canvas,6)));if(!i)return;const o=i;this.configuration.changeTextCallback(i,e.detail,this._doneChangingTextCallback.bind(this,n,o)),this.editData=null,this.isDrawing=!1,e.stopImmediatePropagation(),e.preventDefault()},this.cancel=e=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(e),this._deactivateModify(e),Ta(e);const{annotation:t,viewportIdsToRender:n,newAnnotation:r}=this.editData,{data:i}=t;t.highlighted=!1,i.handles.activeHandleIndex=null;const o=(0,Y.getEnabledElement)(e),{renderingEngine:a}=o;if(Po(a,n),r){const e=ne.ANNOTATION_COMPLETED,n={annotation:t};(0,Y.triggerEvent)(Y.eventTarget,e,n)}return this.editData=null,t.annotationUID}},this._activateModify=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragCallback)},this._deactivateModify=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback)},this._activateDraw=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragCallback),e.addEventListener(ne.MOUSE_MOVE,this._dragCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragCallback)},this._deactivateDraw=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragCallback),e.removeEventListener(ne.MOUSE_MOVE,this._dragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragCallback)},this.renderAnnotation=(e,t)=>{let n=!1;const{viewport:r}=e,{element:i}=r;let o=rg(this.getToolName(),i);if(!o?.length)return n;if(o=this.filterInteractableAnnotationsForElement(i,o),!o?.length)return n;const a={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id};for(let e=0;er.worldToCanvas(e)));let v;if(he(i)||this.editData||null===h||(v=[g[h]]),v){Fi(t,s,"0",g,{color:m,lineWidth:p})}const y="1";if(this.configuration.arrowFirst?Ki(t,s,y,g[1],g[0],{color:m,width:p,lineDash:f}):Ki(t,s,y,g[0],g[1],{color:m,width:p,lineDash:f}),n=!0,!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;if(!u)continue;const _=this.getLinkedTextBoxStyle(a,i);if(!_.visibility){l.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}if(!l.handles.textBox.hasMoved){const e=g[1];l.handles.textBox.worldPosition=r.canvasToWorld(e)}const b=r.worldToCanvas(l.handles.textBox.worldPosition),E=Hi(t,s,"1",[u],b,g,{},_),{x:w,y:x,width:C,height:D}=E;l.handles.textBox.worldBoundingBox={topLeft:r.canvasToWorld([w,x]),topRight:r.canvasToWorld([w+C,x]),bottomLeft:r.canvasToWorld([w,x+D]),bottomRight:r.canvasToWorld([w+C,x+D])}}return n}}handleSelectedCallback(e,t,n){const r=e.detail,{element:i}=r,{data:o}=t;t.highlighted=!0;let a,s=!1;n.worldPosition?s=!0:a=o.handles.points.findIndex((e=>e===n));const l=vs(i,this.getToolName());this.editData={annotation:t,viewportIdsToRender:l,handleIndex:a,movingTextBox:s},this._activateModify(i),Ia(i);const c=(0,Y.getEnabledElement)(i),{renderingEngine:u}=c;Po(u,l),e.preventDefault()}_doneChangingTextCallback(e,t,n){t.data.text=n;const{renderingEngine:r,viewportId:i,renderingEngineId:o}=(0,Y.getEnabledElement)(e),a=vs(e,this.getToolName());Po(r,a);const s=ne.ANNOTATION_MODIFIED;(0,Y.triggerEvent)(Y.eventTarget,s,{annotation:t,viewportId:i,renderingEngineId:o})}_isInsideVolume(e,t,n){return Y.utilities.indexWithinDimensions(e,n)&&Y.utilities.indexWithinDimensions(t,n)}}function Eu(e){return e(prompt("Enter your annotation:"))}function wu(e,t,n){return n(prompt("Enter your annotation:"))}bu.toolName="ArrowAnnotate";const xu=bu;class Cu extends ho{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1,getTextLines:Du}}){super(e,t),this.addNewAnnotation=e=>{if(this.angleStartedNotYetCompleted)return;this.angleStartedNotYetCompleted=!0;const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=(0,Y.getEnabledElement)(r),{viewport:a,renderingEngine:s}=o;Ia(r),this.isDrawing=!0;const l=a.getCamera(),{viewPlaneNormal:c,viewUp:u}=l,d=this.getReferencedImageId(a,i,c,u),h=a.getFrameOfReferenceUID(),p={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...c],viewUp:[...u],FrameOfReferenceUID:h,referencedImageId:d},data:{handles:{points:[[...i],[...i]],activeHandleIndex:null,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},label:"",cachedStats:{}}};ig(p,r);const f=vs(r,this.getToolName());return this.editData={annotation:p,viewportIdsToRender:f,handleIndex:1,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(r),e.preventDefault(),Po(s,f),p},this.isPointNearTool=(e,t,n,r)=>{const i=(0,Y.getEnabledElement)(e),{viewport:o}=i,{data:a}=t,[s,l,c]=a.handles.points,u=o.worldToCanvas(s),d=o.worldToCanvas(l),h={start:{x:u[0],y:u[1]},end:{x:d[0],y:d[1]}};if(Ds([h.start.x,h.start.y],[h.end.x,h.end.y],[n[0],n[1]])<=r)return!0;if(!c)return!1;const p=o.worldToCanvas(c),f={start:{x:d[0],y:d[1]},end:{x:p[0],y:p[1]}};return Ds([f.start.x,f.start.y],[f.end.x,f.end.y],[n[0],n[1]])<=r},this.toolSelectedCallback=(e,t)=>{const n=e.detail,{element:r}=n;t.highlighted=!0;const i=vs(r,this.getToolName());this.editData={annotation:t,viewportIdsToRender:i,movingTextBox:!1},this._activateModify(r),Ia(r);const o=(0,Y.getEnabledElement)(r),{renderingEngine:a}=o;Po(a,i),e.preventDefault()},this._endCallback=e=>{const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,newAnnotation:o,hasMoved:a}=this.editData,{data:s}=r;if(o&&!a)return;if(this.angleStartedNotYetCompleted&&2===s.handles.points.length)return void(this.editData.handleIndex=2);this.angleStartedNotYetCompleted=!1,s.handles.activeHandleIndex=null,this._deactivateModify(n),this._deactivateDraw(n),Ta(n);const l=(0,Y.getEnabledElement)(n),{renderingEngine:c}=l;if(this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&ag(r.annotationUID),Po(c,i),o){const e=ne.ANNOTATION_COMPLETED,t={annotation:r};(0,Y.triggerEvent)(Y.eventTarget,e,t)}this.editData=null,this.isDrawing=!1},this._dragCallback=e=>{this.isDrawing=!0;const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,handleIndex:o,movingTextBox:a}=this.editData,{data:s}=r;if(a){const{deltaPoints:e}=t,n=e.world,{textBox:r}=s.handles,{worldPosition:i}=r;i[0]+=n[0],i[1]+=n[1],i[2]+=n[2],r.hasMoved=!0}else if(void 0===o){const{deltaPoints:e}=t,n=e.world;s.handles.points.forEach((e=>{e[0]+=n[0],e[1]+=n[1],e[2]+=n[2]})),r.invalidated=!0}else{const{currentPoints:e}=t,n=e.world;s.handles.points[o]=[...n],r.invalidated=!0}this.editData.hasMoved=!0;const l=(0,Y.getEnabledElement)(n),{renderingEngine:c}=l;Po(c,i)},this.cancel=e=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(e),this._deactivateModify(e),Ta(e);const{annotation:t,viewportIdsToRender:n,newAnnotation:r}=this.editData,{data:i}=t;t.highlighted=!1,i.handles.activeHandleIndex=null;const o=(0,Y.getEnabledElement)(e),{renderingEngine:a}=o;if(Po(a,n),r){const e=ne.ANNOTATION_COMPLETED,n={annotation:t};(0,Y.triggerEvent)(Y.eventTarget,e,n)}return this.editData=null,this.angleStartedNotYetCompleted=!1,t.annotationUID}},this._activateModify=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragCallback)},this._deactivateModify=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragCallback)},this._activateDraw=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragCallback),e.addEventListener(ne.MOUSE_MOVE,this._dragCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragCallback)},this._deactivateDraw=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragCallback),e.removeEventListener(ne.MOUSE_MOVE,this._dragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragCallback)},this.renderAnnotation=(e,t)=>{let n=!1;const{viewport:r}=e,{element:i}=r;let o=rg(this.getToolName(),i);if(!o?.length)return n;if(o=this.filterInteractableAnnotationsForElement(i,o),!o?.length)return n;const a=this.getTargetId(r),s=r.getRenderingEngine(),l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id};for(let i=0;ir.worldToCanvas(e)));let y;if(d.cachedStats[a]&&null!=d.cachedStats[a].angle?c.invalidated&&this._throttledCalculateCachedStats(c,s,e):(d.cachedStats[a]={angle:null},this._calculateCachedStats(c,s,e)),he(c)||this.editData||null===p||(y=[v[p]]),!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;if(y){Fi(t,u,"0",v,{color:g,lineDash:m,lineWidth:f})}let _="1";if(Ui(t,u,_,v[0],v[1],{color:g,width:f,lineDash:m}),n=!0,3!==v.length)return n;if(_="2",Ui(t,u,_,v[1],v[2],{color:g,width:f,lineDash:m}),!d.cachedStats[a]?.angle)continue;const b=this.getLinkedTextBoxStyle(l,c);if(!b.visibility){d.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const E=this.configuration.getTextLines(d,a);if(!d.handles.textBox.hasMoved){const e=v[1];d.handles.textBox.worldPosition=r.canvasToWorld(e)}const w=r.worldToCanvas(d.handles.textBox.worldPosition),x=Hi(t,u,"1",E,w,v,{},b),{x:C,y:D,width:S,height:T}=x;d.handles.textBox.worldBoundingBox={topLeft:r.canvasToWorld([C,D]),topRight:r.canvasToWorld([C+S,D]),bottomLeft:r.canvasToWorld([C,D+T]),bottomRight:r.canvasToWorld([C+S,D+T])}}return n},this._throttledCalculateCachedStats=To(this._calculateCachedStats,100,{trailing:!0})}handleSelectedCallback(e,t,n){const r=e.detail,{element:i}=r,{data:o}=t;t.highlighted=!0;let a,s=!1;n.worldPosition?s=!0:a=o.handles.points.findIndex((e=>e===n));const l=vs(i,this.getToolName());this.editData={annotation:t,viewportIdsToRender:l,handleIndex:a,movingTextBox:s},this._activateModify(i),Ia(i);const c=(0,Y.getEnabledElement)(i),{renderingEngine:u}=c;Po(u,l),e.preventDefault()}_calculateCachedStats(e,t,n){const r=e.data,{viewportId:i,renderingEngineId:o}=n;if(3!==r.handles.points.length)return;const a=r.handles.points[0],s=r.handles.points[1],l=r.handles.points[2],{cachedStats:c}=r,u=Object.keys(c);for(let e=0;e{const t=2===e[0].length?[0,0]:[0,0,0],n=e.length;for(const r of e)t[0]+=r[0]/n,t[1]+=r[1]/n,3===t.length&&(t[2]+=r[2]/n);return t},Iu=Tu;class Au extends ho{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1,getTextLines:Nu}}){super(e,t),this.addNewAnnotation=e=>{if(this.angleStartedNotYetCompleted)return;this.angleStartedNotYetCompleted=!0;const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=(0,Y.getEnabledElement)(r),{viewport:a,renderingEngine:s}=o;Ia(r),this.isDrawing=!0;const l=a.getCamera(),{viewPlaneNormal:c,viewUp:u}=l,d=this.getReferencedImageId(a,i,c,u),h=a.getFrameOfReferenceUID(),p={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...c],viewUp:[...u],FrameOfReferenceUID:h,referencedImageId:d},data:{handles:{points:[[...i],[...i]],activeHandleIndex:null,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},label:"",cachedStats:{}}};ig(p,r);const f=vs(r,this.getToolName());return this.editData={annotation:p,viewportIdsToRender:f,handleIndex:1,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(r),e.preventDefault(),Po(s,f),p},this.isPointNearTool=(e,t,n,r)=>{const i=(0,Y.getEnabledElement)(e),{viewport:o}=i,{data:a}=t,[s,l,c,u]=a.handles.points,d=o.worldToCanvas(s),h=o.worldToCanvas(l),p=o.worldToCanvas(c),f=o.worldToCanvas(u),m={start:{x:d[0],y:d[1]},end:{x:h[0],y:h[1]}},g={start:{x:p[0],y:p[1]},end:{x:f[0],y:f[1]}},v=Ds([m.start.x,m.start.y],[m.end.x,m.end.y],[n[0],n[1]]),y=Ds([g.start.x,g.start.y],[g.end.x,g.end.y],[n[0],n[1]]);return v<=r||y<=r},this.toolSelectedCallback=(e,t,n)=>{const r=e.detail,{element:i}=r;t.highlighted=!0;const o=vs(i,this.getToolName());this.editData={annotation:t,viewportIdsToRender:o,movingTextBox:!1},this._activateModify(i),Ia(i);const a=(0,Y.getEnabledElement)(i),{renderingEngine:s}=a;Po(s,o),e.preventDefault()},this._mouseUpCallback=e=>{const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,newAnnotation:o,hasMoved:a}=this.editData,{data:s}=r;if(o&&!a)return;if(this.angleStartedNotYetCompleted&&s.handles.points.length<4)return Ta(n),void(this.editData.handleIndex=s.handles.points.length);this.angleStartedNotYetCompleted=!1,s.handles.activeHandleIndex=null,this._deactivateModify(n),this._deactivateDraw(n),Ta(n);const l=(0,Y.getEnabledElement)(n),{renderingEngine:c}=l;if(this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&ag(r.annotationUID),Po(c,i),o){const e=ne.ANNOTATION_COMPLETED,t={annotation:r};(0,Y.triggerEvent)(Y.eventTarget,e,t)}this.editData=null,this.isDrawing=!1},this._mouseDownCallback=e=>{const{annotation:t,handleIndex:n}=this.editData,r=e.detail,{element:i,currentPoints:o}=r,a=o.world,{data:s}=t;return 1===n?(s.handles.points[1]=a,void(this.editData.hasMoved=s.handles.points[1][0]!==s.handles.points[0][0]||s.handles.points[1][1]!==s.handles.points[0][0])):3===n?(s.handles.points[3]=a,this.editData.hasMoved=s.handles.points[3][0]!==s.handles.points[2][0]||s.handles.points[3][1]!==s.handles.points[2][0],void(this.angleStartedNotYetCompleted=!1)):(this.editData.hasMoved=!1,Ia(i),s.handles.points[2]=s.handles.points[3]=a,void(this.editData.handleIndex=s.handles.points.length-1))},this._mouseDragCallback=e=>{this.isDrawing=!0;const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,handleIndex:o,movingTextBox:a}=this.editData,{data:s}=r;if(a){const{deltaPoints:e}=t,n=e.world,{textBox:r}=s.handles,{worldPosition:i}=r;i[0]+=n[0],i[1]+=n[1],i[2]+=n[2],r.hasMoved=!0}else if(void 0===o){const{deltaPoints:e}=t,n=e.world;s.handles.points.forEach((e=>{e[0]+=n[0],e[1]+=n[1],e[2]+=n[2]})),r.invalidated=!0}else{const{currentPoints:e}=t,n=e.world;s.handles.points[o]=[...n],r.invalidated=!0}this.editData.hasMoved=!0;const l=(0,Y.getEnabledElement)(n),{renderingEngine:c}=l;Po(c,i)},this.cancel=e=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(e),this._deactivateModify(e),Ta(e);const{annotation:t,viewportIdsToRender:n,newAnnotation:r}=this.editData,{data:i}=t;t.highlighted=!1,i.handles.activeHandleIndex=null;const o=(0,Y.getEnabledElement)(e),{renderingEngine:a}=o;if(Po(a,n),r){const e=ne.ANNOTATION_COMPLETED,n={annotation:t};(0,Y.triggerEvent)(Y.eventTarget,e,n)}return this.editData=null,this.angleStartedNotYetCompleted=!1,t.annotationUID}},this._activateModify=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._mouseUpCallback),e.addEventListener(ne.MOUSE_DRAG,this._mouseDragCallback),e.addEventListener(ne.MOUSE_CLICK,this._mouseUpCallback)},this._deactivateModify=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._mouseUpCallback),e.removeEventListener(ne.MOUSE_DRAG,this._mouseDragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._mouseUpCallback)},this._activateDraw=e=>{He.isInteractingWithTool=!0,e.addEventListener(ne.MOUSE_UP,this._mouseUpCallback),e.addEventListener(ne.MOUSE_DRAG,this._mouseDragCallback),e.addEventListener(ne.MOUSE_MOVE,this._mouseDragCallback),e.addEventListener(ne.MOUSE_CLICK,this._mouseUpCallback),e.addEventListener(ne.MOUSE_DOWN,this._mouseDownCallback)},this._deactivateDraw=e=>{He.isInteractingWithTool=!1,e.removeEventListener(ne.MOUSE_UP,this._mouseUpCallback),e.removeEventListener(ne.MOUSE_DRAG,this._mouseDragCallback),e.removeEventListener(ne.MOUSE_MOVE,this._mouseDragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._mouseUpCallback),e.removeEventListener(ne.MOUSE_DOWN,this._mouseDownCallback)},this.renderAnnotation=(e,t)=>{let n=!1;const{viewport:r}=e,{element:i}=r;let o=rg(this.getToolName(),i);if(!o?.length)return n;if(o=this.filterInteractableAnnotationsForElement(i,o),!o?.length)return n;const a=this.getTargetId(r),s=r.getRenderingEngine(),l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id};for(let i=0;ir.worldToCanvas(e)));let y;if(d.cachedStats[a]&&null!=d.cachedStats[a].angle?c.invalidated&&this._throttledCalculateCachedStats(c,s,e):(d.cachedStats[a]={angle:null},this._calculateCachedStats(c,s,e)),he(c)||this.editData||null===p||(y=[v[p]]),!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;if(y){Fi(t,u,"0",v,{color:g,lineDash:m,lineWidth:f})}let _="1";if(Ui(t,u,_,v[0],v[1],{color:g,width:f,lineDash:m}),n=!0,v.length<4)return n;_="2",Ui(t,u,_,v[2],v[3],{color:g,width:f,lineDash:m}),_="3";if(Ui(t,u,_,Iu(v[0],v[1]),Iu(v[2],v[3]),{color:g,lineWidth:"1",lineDash:"1,4"}),!d.cachedStats[a]?.angle)continue;const b=this.getLinkedTextBoxStyle(l,c);if(!b.visibility){d.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const E=this.configuration.getTextLines(d,a);if(!d.handles.textBox.hasMoved){const e=Qs(v);d.handles.textBox.worldPosition=r.canvasToWorld(e)}const w=r.worldToCanvas(d.handles.textBox.worldPosition),x=Hi(t,u,"1",E,w,v,{},b),{x:C,y:D,width:S,height:T}=x;d.handles.textBox.worldBoundingBox={topLeft:r.canvasToWorld([C,D]),topRight:r.canvasToWorld([C+S,D]),bottomLeft:r.canvasToWorld([C,D+T]),bottomRight:r.canvasToWorld([C+S,D+T])}}return n},this._throttledCalculateCachedStats=To(this._calculateCachedStats,100,{trailing:!0})}handleSelectedCallback(e,t,n,r="mouse"){const i=e.detail,{element:o}=i,{data:a}=t;t.highlighted=!0;let s,l=!1;n.worldPosition?l=!0:s=a.handles.points.findIndex((e=>e===n));const c=vs(o,this.getToolName());this.editData={annotation:t,viewportIdsToRender:c,handleIndex:s,movingTextBox:l},this._activateModify(o),Ia(o);const u=(0,Y.getEnabledElement)(o),{renderingEngine:d}=u;Po(d,c),e.preventDefault()}_calculateCachedStats(e,t,n){const r=e.data,{viewportId:i,renderingEngineId:o}=n;if(4!==r.handles.points.length)return;const a=[null,null],s=[null,null];let l=Number.MAX_VALUE;for(let e=0;e<2;e+=1)for(let t=2;t<4;t+=1){const n=Ci.R3.distance(r.handles.points[e],r.handles.points[t]);n{const{detail:t}=e,{element:n,currentPoints:r}=t;this._currentCursorWorldPosition=r.world,this._currentCanvasPosition=r.canvas,this._elementWithCursor=n;const i=this.getActiveAnnotation(n);return null===i?(this.createInitialAnnotation(r.world,n),!1):(this.updateAnnotationPosition(n,i),!1)},this.createInitialAnnotation=(e,t)=>{const n=(0,Y.getEnabledElement)(t);if(!n)throw new Error("No enabled element found");const{viewport:r,renderingEngine:i}=n;this.isDrawing=!0;const o=r.getCamera(),{viewPlaneNormal:a,viewUp:s}=o;if(!a||!s)throw new Error("Camera not found");const l=this.getReferencedImageId(r,e,a,s),c=r.getFrameOfReferenceUID(),u={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...a],viewUp:[...s],FrameOfReferenceUID:c,referencedImageId:l},data:{label:"",handles:{points:[[...e]],activeHandleIndex:null,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}}}};if(rg(this.getToolName(),t).length>0)return null;if(null===ig(u,t))return;const d=vs(t,this.getToolName(),!1);Po(i,d)},this.onCameraModified=e=>{const t=e.detail,{element:n,previousCamera:r,camera:i}=t,o=(0,Y.getEnabledElement)(n).viewport;if(n!==this._elementWithCursor)return;const a=r.focalPoint,s=i.viewPlaneNormal,l=i.focalPoint,c=[0,0,0];if(Ba.ZP.subtract(l,a,c),0===c.reduce(((e,t)=>e+t),0))return;const u=Ba.ZP.dot(c,s);if(Math.abs(u)<.01)return;if(!this._currentCanvasPosition)return;const d=o.canvasToWorld(this._currentCanvasPosition);this._currentCursorWorldPosition=d,this.updateAnnotationPosition(n,this.getActiveAnnotation(n))},this.renderAnnotation=(e,t)=>{let n=!1;const{viewport:r,FrameOfReferenceUID:i}=e,o=this._elementWithCursor===r.element;this.configuration.positionSync&&!o&&this.updateViewportImage(r);const{element:a}=r;let s=rg(this.getToolName(),a);if(!s?.length)return n;if(s=this.filterInteractableAnnotationsForElement(a,s),!s?.length)return n;const l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id};for(let e=0;eisNaN(e))))return n;const g=d.map((e=>r.worldToCanvas(e)));if(!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;if(!ke(a))continue;const v={upper:"upper",right:"right",lower:"lower",left:"left"},[y,_]=g[0],b=o?20:7,E=o?5:7;Ui(t,a,v.upper,[y,_-(b/2+E)],[y,_-b/2],{color:m,lineDash:f,lineWidth:p}),Ui(t,a,v.lower,[y,_+(b/2+E)],[y,_+b/2],{color:m,lineDash:f,lineWidth:p}),Ui(t,a,v.right,[y+(b/2+E),_],[y+b/2,_],{color:m,lineDash:f,lineWidth:p}),Ui(t,a,v.left,[y-(b/2+E),_],[y-b/2,_],{color:m,lineDash:f,lineWidth:p}),n=!0}return n},this._disableCursorEnabled=this.configuration.disableCursor}onSetToolActive(){if(this._disableCursorEnabled=this.configuration.disableCursor,!this._disableCursorEnabled)return;const e=$m(this.toolGroupId).viewportsInfo;if(!e)return;e.map((e=>(0,Y.getEnabledElementByIds)(e.viewportId,e.renderingEngineId))).forEach((e=>{e&&Ia(e.viewport.element)}))}onSetToolDisabled(){if(!this._disableCursorEnabled)return;const e=$m(this.toolGroupId).viewportsInfo;if(!e)return;e.map((e=>(0,Y.getEnabledElementByIds)(e.viewportId,e.renderingEngineId))).forEach((e=>{e&&Ta(e.viewport.element)}))}getActiveAnnotation(e){const t=rg(this.getToolName(),e);if(!t.length)return null;return t[0]}updateAnnotationPosition(e,t){const n=this._currentCursorWorldPosition;if(!n)return;if(!t.data?.handles?.points)return;t.data.handles.points=[[...n]],t.invalidated=!0;const r=vs(e,this.getToolName(),!1),i=(0,Y.getEnabledElement)(e);if(!i)return;const{renderingEngine:o}=i;Po(o,r)}filterInteractableAnnotationsForElement(e,t){if(!(t instanceof Array)||0===t.length)return[];const n=t[0],r=(0,Y.getEnabledElement)(e)?.viewport;if(!r)return[];const i=r.getCamera(),{viewPlaneNormal:o,focalPoint:a}=i;if(!o||!a)return[];const s=n.data?.handles?.points;if(!(s instanceof Array)||1!==s.length)return[];const l=s[0],c=Y.utilities.planar.planeEquation(o,a);return Y.utilities.planar.planeDistanceToPoint(c,l)isNaN(e))))if(e instanceof Y.StackViewport){const n=Y.utilities.getClosestStackImageIndexForPoint(t,e);if(null===n)return;n!==e.getCurrentImageIdIndex()&&e.setImageIdIndex(n)}else if(e instanceof Y.VolumeViewport){const{focalPoint:n,viewPlaneNormal:r}=e.getCamera();if(!n||!r)return;const i=Y.utilities.planar.planeEquation(r,n),o=Y.utilities.planar.planeDistanceToPoint(i,t,!0);if(Math.abs(o)<.5)return;const a=Ci.R3.normalize(Ci.R3.create(),Ci.R3.fromValues(...r)),s=Ci.R3.scale(Ci.R3.create(),a,o),l=Ci.R3.add(Ci.R3.create(),Ci.R3.fromValues(...n),s);if(!0){e.setCamera({focalPoint:l});const t=e.getRenderingEngine();t&&t.renderViewport(e.id)}}}}Pu.toolName="ReferenceCursors";const ku=Pu,Mu=[];class Lu extends co{constructor(e={},t={configuration:{viewportId:"",scaleLocation:"bottom"}}){super(e,t),this.editData={},this._init=()=>{const e=(0,Y.getRenderingEngines)()[0];if(!e)return;const t=$m(this.toolGroupId).viewportsInfo;if(!t)return;const n=t.map((e=>(0,Y.getEnabledElementByIds)(e.viewportId,e.renderingEngineId)));let{viewport:r}=n[0];const{FrameOfReferenceUID:i}=n[0];if(this.configuration.viewportId&&n.forEach((e=>{e.viewport.id==this.configuration.viewportId&&(r=e.viewport)})),!r)return;const{viewUp:o,viewPlaneNormal:a}=r.getCamera(),s=Y.utilities.getViewportImageCornersInWorld(r);let l=this.editData.annotation;const c=rg(this.getToolName(),r.element);if(c.length&&(l=c.filter((e=>e.data.viewportId==r.id))[0]),Mu.includes(r.id))this.editData.annotation.data.viewportId==r.id&&(this.editData.annotation.data.handles.points=s,this.editData.annotation.data.viewportId=r.id);else{const e={metadata:{toolName:this.getToolName(),viewPlaneNormal:[...a],viewUp:[...o],FrameOfReferenceUID:i,referencedImageId:null},data:{handles:{points:s},viewportId:r.id}};Mu.push(r.id),ig(e,r.element),l=e}this.editData={viewport:r,renderingEngine:e,annotation:l}},this.onSetToolEnabled=()=>{this._init()},this.onCameraModified=e=>{this.configuration.viewportId=e.detail.viewportId,this._init()},this.computeScaleSize=(e,t,n)=>{const r=[16e3,8e3,4e3,2e3,1e3,500,250,100,50,25,10,5,2];let i;return i="top"==n||"bottom"==n?r.filter((t=>t<.6*e&&t>.2*e)):r.filter((e=>e<.6*t&&e>.2*t)),i[0]},this.computeEndScaleTicks=(e,t)=>{const n={bottom:[[0,-10],[0,-10]],top:[[0,10],[0,10]],left:[[0,0],[10,0]],right:[[0,0],[-10,0]]};return{endTick1:[[e[1][0]+n[t][0][0],e[1][1]+n[t][0][0]],[e[1][0]+n[t][1][0],e[1][1]+n[t][1][1]]],endTick2:[[e[0][0]+n[t][0][0],e[0][1]+n[t][0][0]],[e[0][0]+n[t][1][0],e[0][1]+n[t][1][1]]]}},this.computeInnerScaleTicks=(e,t,n,r,i)=>{let o;"bottom"==t||"top"==t?o=i[0][0]-r[0][0]:"left"!=t&&"right"!=t||(o=i[0][1]-r[0][1]);const a=[],s=[],l=[];let c=e;e>=50&&(c=e/10);const u=o/c;for(let e=0;e{let r,i=Ci.R3.subtract(Ci.R3.create(),n[0],n[1]);i=Ci.R3.normalize(Ci.R3.create(),i);let o=Ci.R3.subtract(Ci.R3.create(),n[2],n[0]);o=Ci.R3.normalize(Ci.R3.create(),o);const a={bottom:[n[1],n[2]],top:[n[0],n[3]],right:[n[2],n[3]],left:[n[0],n[1]]},s=Ci.R3.add(Ci.R3.create(),a[t][0],a[t][0]).map((e=>e/2)),l=e/2/Math.sqrt(Math.pow(i[0],2)+Math.pow(i[1],2)+Math.pow(i[2],2));return"top"==t||"bottom"==t?r=[Ci.R3.subtract(Ci.R3.create(),s,o.map((e=>e*l))),Ci.R3.add(Ci.R3.create(),s,o.map((e=>e*l)))]:"left"!=t&&"right"!=t||(r=[Ci.R3.add(Ci.R3.create(),s,i.map((e=>e*l))),Ci.R3.subtract(Ci.R3.create(),s,i.map((e=>e*l)))]),r},this.computeCanvasScaleCoordinates=(e,t,n,r,i)=>{let o;if("top"==i||"bottom"==i){const r=t[0][0]-t[1][0];o=[[e.width/2-r/2,n.height],[e.width/2+r/2,n.height]]}else if("left"==i||"right"==i){const n=t[0][1]-t[1][1];o=[[r.width,e.height/2-n/2],[r.width,e.height/2+n/2]]}return o},this.computeScaleBounds=(e,t,n,r)=>{const i=t*Math.min(1e3,e.width),o=n*Math.min(1e3,e.height),a={bottom:[-o,-i],top:[o,i],left:[o,i],right:[-o,-i]},s={bottom:[e.height,e.width],top:[0,e.width],left:[e.height,0],right:[e.height,e.width]};return{height:s[r][0]+a[r][0],width:s[r][1]+a[r][1]}}}renderAnnotation(e,t){if(!this.editData.viewport)return;const n=this.configuration.scaleLocation,{viewport:r}=e,i=rg(this.getToolName(),r.element).filter((e=>e.data.viewportId==r.id))[0],o=e.viewport.canvas;if(!r)return false;const a={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id},s={width:o.width,height:o.height},l=i.data.handles.points[0],c=i.data.handles.points[1],u=i.data.handles.points[2],d=i.data.handles.points[3],h=[l,u,c,d],p=Ci.R3.distance(u,d),f=Ci.R3.distance(l,u),m=this.computeScaleBounds(s,.05,.05,n),g=this.computeScaleBounds(s,.05,.05,n),v=this.computeScaleSize(p,f,n),y=this.computeWorldScaleCoordinates(v,n,h).map((e=>r.worldToCanvas(e))),_=this.computeCanvasScaleCoordinates(s,y,g,m,n),b=this.computeEndScaleTicks(_,n),{annotationUID:E}=i;a.annotationUID=E;const w=this.getStyle("lineWidth",a,i),x=this.getStyle("lineDash",a,i),C=this.getStyle("color",a,i),D=this.getStyle("shadow",a,i),S=`${E}-scaleline`;Ui(t,E,"1",_[0],_[1],{color:C,width:w,lineDash:x,shadow:D},S);const T=`${E}-left`;Ui(t,E,"2",b.endTick1[0],b.endTick1[1],{color:C,width:w,lineDash:x,shadow:D},T);const I=`${E}-right`;Ui(t,E,"3",b.endTick2[0],b.endTick2[1],{color:C,width:w,lineDash:x,shadow:D},I);const A={bottom:[-10,-42],top:[-12,-35],left:[-40,-20],right:[-50,-20]},N=[_[0][0]+A[n][0],_[0][1]+A[n][1]],O=this._getTextLines(v),{tickIds:P,tickUIDs:k,tickCoordinates:M}=this.computeInnerScaleTicks(v,n,E,b.endTick1,b.endTick2);for(let e=0;e=50?(t=e/10,n=" cm"):(t=e,n=" mm");return[t.toString().concat(n)]}}Lu.toolName="ScaleOverlay";const Ru=Lu,{transformWorldToIndex:Fu}=Y.utilities;function Uu(e,t,n=!0){const{volume:r,points:i,segmentsLocked:o,segmentIndex:a,segmentationId:s,constraintFn:l}=t,{imageData:c,dimensions:u}=r,d=r.getScalarData();let h=i.map((e=>Fu(c,e)));h=h.map((e=>e.map((e=>Math.round(e)))));const p=Fo(h,u);Lo(c,(()=>!0),(({value:e,index:t,pointIJK:n})=>{o.includes(e)||(l?l(n)&&(d[t]=a):d[t]=a)}),p),Kn(s)}function Bu(e,t){Uu(0,t,!0)}const{transformWorldToIndex:ju}=Y.utilities;function Vu(e,t,n=!0){const{volume:r,points:i,segmentsLocked:o,segmentationId:a}=t,{imageData:s,dimensions:l}=r,c=r.getScalarData(),u=i.map((e=>ju(s,e))),d=Fo(u,l);Lo(s,(()=>!0),(({value:e,index:t})=>{o.includes(e)||(c[t]=0)}),d),Kn(a)}function Wu(e,t){Vu(0,t,!0)}class zu extends xi{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{strategies:{FILL_INSIDE:Bu,ERASE_INSIDE:Wu},defaultStrategy:"FILL_INSIDE",activeStrategy:"FILL_INSIDE"}}){super(e,t),this.preMouseDownCallback=e=>{const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=(0,Y.getEnabledElement)(r),{viewport:a,renderingEngine:s}=o;this.isDrawing=!0;const l=a.getCamera(),{viewPlaneNormal:c,viewUp:u}=l,d=this.toolGroupId,h=si(d);if(!h)throw new Error("No active segmentation detected, create one before using scissors tool");const{segmentationRepresentationUID:p,segmentationId:f,type:m}=h,g=Ei(f),v=di(f),y=fi(d,p,g),{representationData:_}=Jn(f),{volumeId:b}=_[m],E=Y.cache.getVolume(b),w={highlighted:!0,invalidated:!0,metadata:{viewPlaneNormal:[...c],viewUp:[...u],FrameOfReferenceUID:a.getFrameOfReferenceUID(),referencedImageId:"",toolName:this.getToolName(),segmentColor:y},data:{handles:{points:[[...i],[...i],[...i],[...i]],activeHandleIndex:null}}},x=vs(r,this.getToolName());return this.editData={annotation:w,segmentation:E,segmentIndex:g,segmentsLocked:v,segmentColor:y,segmentationId:f,viewportIdsToRender:x,handleIndex:3,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(r),Ia(r),e.preventDefault(),Po(s,x),!0},this._dragCallback=e=>{this.isDrawing=!0;const t=e.detail,{element:n}=t,{annotation:r,viewportIdsToRender:i,handleIndex:o}=this.editData,{data:a}=r,{currentPoints:s}=t,l=(0,Y.getEnabledElement)(n),{worldToCanvas:c,canvasToWorld:u}=l.viewport,d=s.world,{points:h}=a.handles;let p,f,m,g,v,y,_,b;switch(h[o]=[...d],o){case 0:case 3:p=c(h[0]),g=c(h[3]),f=[g[0],p[1]],m=[p[0],g[1]],y=u(f),_=u(m),h[1]=y,h[2]=_;break;case 1:case 2:f=c(h[1]),m=c(h[2]),p=[m[0],f[1]],g=[f[0],m[1]],v=u(p),b=u(g),h[0]=v,h[3]=b}r.invalidated=!0,this.editData.hasMoved=!0;const{renderingEngine:E}=l;Po(E,i)},this._endCallback=e=>{const t=e.detail,{element:n}=t,{annotation:r,newAnnotation:i,hasMoved:o,segmentation:a,segmentationId:s,segmentIndex:l,segmentsLocked:c}=this.editData,{data:u}=r;if(i&&!o)return;u.handles.activeHandleIndex=null,this._deactivateDraw(n),Ta(n);const d=(0,Y.getEnabledElement)(n),{viewport:h}=d;if(this.editData=null,this.isDrawing=!1,h instanceof Y.StackViewport)throw new Error("Not implemented yet");const p={points:u.handles.points,volume:a,segmentationId:s,segmentIndex:l,segmentsLocked:c};this.applyActiveStrategy(d,p)},this._activateDraw=e=>{e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback)},this._deactivateDraw=e=>{e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragCallback)},this.renderAnnotation=(e,t)=>{let n=!1;if(!this.editData)return n;const{viewport:r}=e,{annotation:i}=this.editData,o=i.metadata,a=i.annotationUID,s=i.data,{points:l}=s.handles,c=l.map((e=>r.worldToCanvas(e))),u=`rgb(${o.segmentColor.slice(0,3)})`;if(!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;return qi(t,a,"0",c[0],c[3],{color:u}),n=!0,n}}}zu.toolName="RectangleScissor";const Gu=zu;class Hu extends xi{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{strategies:{FILL_INSIDE:Jo},defaultStrategy:"FILL_INSIDE",activeStrategy:"FILL_INSIDE"}}){super(e,t),this.preMouseDownCallback=e=>{const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=n.canvas,a=(0,Y.getEnabledElement)(r),{viewport:s,renderingEngine:l}=a;this.isDrawing=!0;const c=s.getCamera(),{viewPlaneNormal:u,viewUp:d}=c,h=this.toolGroupId,p=si(h);if(!p)throw new Error("No active segmentation detected, create one before using scissors tool");const{segmentationRepresentationUID:f,segmentationId:m,type:g}=p,v=Ei(m),y=di(m),_=fi(h,f,v),{representationData:b}=Jn(m),{volumeId:E}=b[g],w=Y.cache.getVolume(E),x={invalidated:!0,highlighted:!0,metadata:{viewPlaneNormal:[...u],viewUp:[...d],FrameOfReferenceUID:s.getFrameOfReferenceUID(),referencedImageId:"",toolName:this.getToolName(),segmentColor:_},data:{handles:{points:[[...i],[...i],[...i],[...i]],activeHandleIndex:null},isDrawing:!0,cachedStats:{}}},C=[s.id];return this.editData={annotation:x,segmentation:w,centerCanvas:o,segmentIndex:v,segmentationId:m,segmentsLocked:y,segmentColor:_,viewportIdsToRender:C,handleIndex:3,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(r),Ia(r),e.preventDefault(),Po(l,C),!0},this._dragCallback=e=>{this.isDrawing=!0;const t=e.detail,{element:n}=t,{currentPoints:r}=t,i=r.canvas,o=(0,Y.getEnabledElement)(n),{renderingEngine:a,viewport:s}=o,{canvasToWorld:l}=s,{annotation:c,viewportIdsToRender:u,centerCanvas:d}=this.editData,{data:h}=c,p=Math.abs(i[0]-d[0]),f=Math.abs(i[1]-d[1]),m=Math.sqrt(p*p+f*f),g=[d[0],d[1]+m],v=[d[0],d[1]-m],y=[d[0]-m,d[1]],_=[d[0]+m,d[1]];h.handles.points=[l(g),l(v),l(y),l(_)],c.invalidated=!0,this.editData.hasMoved=!0,Po(a,u)},this._endCallback=e=>{const t=e.detail,{element:n}=t,{annotation:r,newAnnotation:i,hasMoved:o,segmentation:a,segmentIndex:s,segmentsLocked:l,segmentationId:c}=this.editData,{data:u}=r,{viewPlaneNormal:d,viewUp:h}=r.metadata;if(i&&!o)return;u.handles.activeHandleIndex=null,this._deactivateDraw(n),Ta(n);const p=(0,Y.getEnabledElement)(n),{viewport:f}=p;if(this.editData=null,this.isDrawing=!1,f instanceof Y.StackViewport)throw new Error("Not implemented yet");const m={points:u.handles.points,volume:a,segmentIndex:s,segmentsLocked:l,viewPlaneNormal:d,segmentationId:c,viewUp:h};this.applyActiveStrategy(p,m)},this._activateDraw=e=>{e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragCallback),e.addEventListener(ne.TOUCH_END,this._endCallback)},this._deactivateDraw=e=>{e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(e,t)=>{let n=!1;if(!this.editData)return n;const{viewport:r}=e,{viewportIdsToRender:i}=this.editData;if(!i.includes(r.id))return n;const{annotation:o}=this.editData,a=o.metadata,s=o.annotationUID,l=o.data,{points:c}=l.handles,u=c.map((e=>r.worldToCanvas(e))),d=u[0],h=u[1],p=[Math.floor((d[0]+h[0])/2),Math.floor((d[1]+h[1])/2)],f=Math.abs(d[1]-Math.floor((d[1]+h[1])/2)),m=`rgb(${a.segmentColor.slice(0,3)})`;if(!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;return Li(t,s,"0",p,f,{color:m}),n=!0,n}}}Hu.toolName="CircleScissor";const qu=Hu;class Ku extends xi{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{strategies:{FILL_INSIDE:zo},defaultStrategy:"FILL_INSIDE",activeStrategy:"FILL_INSIDE"}}){super(e,t),this.preMouseDownCallback=e=>{const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=n.canvas,a=(0,Y.getEnabledElement)(r),{viewport:s,renderingEngine:l}=a;this.isDrawing=!0;const c=s.getCamera(),{viewPlaneNormal:u,viewUp:d}=c,h=this.toolGroupId,p=si(h);if(!p)throw new Error("No active segmentation detected, create one before using scissors tool");const{segmentationRepresentationUID:f,segmentationId:m,type:g}=p,v=Ei(m),y=di(m),_=fi(h,f,v),{representationData:b}=Jn(m),{volumeId:E}=b[g],w=Y.cache.getVolume(E);this.isDrawing=!0;const x={metadata:{viewPlaneNormal:[...u],viewUp:[...d],FrameOfReferenceUID:s.getFrameOfReferenceUID(),referencedImageId:"",toolName:this.getToolName(),segmentColor:_},data:{invalidated:!0,handles:{points:[[...i],[...i],[...i],[...i]],activeHandleIndex:null},cachedStats:{},highlighted:!0}},C=[s.id];return this.editData={annotation:x,segmentation:w,centerCanvas:o,segmentIndex:v,segmentsLocked:y,segmentColor:_,segmentationId:m,toolGroupId:h,viewportIdsToRender:C,handleIndex:3,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(r),Ia(r),e.preventDefault(),Po(l,C),!0},this._dragCallback=e=>{this.isDrawing=!0;const t=e.detail,{element:n}=t,{currentPoints:r}=t,i=r.canvas,o=(0,Y.getEnabledElement)(n),{renderingEngine:a,viewport:s}=o,{canvasToWorld:l}=s,{annotation:c,viewportIdsToRender:u,centerCanvas:d}=this.editData,{data:h}=c,p=Math.abs(i[0]-d[0]),f=Math.abs(i[1]-d[1]),m=Math.sqrt(p*p+f*f),g=[d[0],d[1]+m],v=[d[0],d[1]-m],y=[d[0]-m,d[1]],_=[d[0]+m,d[1]];h.handles.points=[l(g),l(v),l(y),l(_)],c.invalidated=!0,this.editData.hasMoved=!0,Po(a,u)},this._endCallback=e=>{const t=e.detail,{element:n}=t,{annotation:r,newAnnotation:i,hasMoved:o,segmentation:a,segmentIndex:s,segmentsLocked:l,segmentationId:c}=this.editData,{data:u}=r,{viewPlaneNormal:d,viewUp:h}=r.metadata;if(i&&!o)return;r.highlighted=!1,u.handles.activeHandleIndex=null,this._deactivateDraw(n),Ta(n);const p=(0,Y.getEnabledElement)(n),{viewport:f}=p;if(this.editData=null,this.isDrawing=!1,f instanceof Y.StackViewport)throw new Error("Not implemented yet");const m={points:u.handles.points,volume:a,segmentIndex:s,segmentsLocked:l,segmentationId:c,viewPlaneNormal:d,viewUp:h};this.applyActiveStrategy(p,m)},this._activateDraw=e=>{e.addEventListener(ne.MOUSE_UP,this._endCallback),e.addEventListener(ne.MOUSE_DRAG,this._dragCallback),e.addEventListener(ne.MOUSE_CLICK,this._endCallback),e.addEventListener(ne.TOUCH_END,this._endCallback),e.addEventListener(ne.TOUCH_TAP,this._endCallback),e.addEventListener(ne.TOUCH_DRAG,this._dragCallback)},this._deactivateDraw=e=>{e.removeEventListener(ne.MOUSE_UP,this._endCallback),e.removeEventListener(ne.MOUSE_DRAG,this._dragCallback),e.removeEventListener(ne.MOUSE_CLICK,this._endCallback),e.removeEventListener(ne.TOUCH_END,this._endCallback),e.removeEventListener(ne.TOUCH_DRAG,this._dragCallback),e.removeEventListener(ne.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(e,t)=>{let n=!1;if(!this.editData)return n;const{viewport:r}=e,{viewportIdsToRender:i}=this.editData;if(!i.includes(r.id))return n;const{annotation:o}=this.editData,a=o.metadata,s=o.annotationUID,l=o.data,{points:c}=l.handles,u=c.map((e=>r.worldToCanvas(e))),d=u[0],h=u[1],p=[Math.floor((d[0]+h[0])/2),Math.floor((d[1]+h[1])/2)],f=Math.abs(d[1]-Math.floor((d[1]+h[1])/2)),m=`rgb(${a.segmentColor.slice(0,3)})`;if(!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;return Li(t,s,"0",p,f,{color:m}),n=!0,n}}}Ku.toolName="SphereScissor";const Xu=Ku;class $u extends xl{constructor(e={},t={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1}}){super(e,t),this.addNewAnnotation=e=>{const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=(0,Y.getEnabledElement)(r),{viewport:a,renderingEngine:s}=o;this.isDrawing=!0;const l=a.getCamera(),{viewPlaneNormal:c,viewUp:u}=l,d=this.getTargetId(a);let h,p;if(a instanceof Y.StackViewport)h=d.split("imageId:")[1];else{p=d.split("volumeId:")[1];const e=Y.cache.getVolume(p);h=Y.utilities.getClosestImageId(e,i,c)}const f=a.getFrameOfReferenceUID(),m={highlighted:!0,invalidated:!0,metadata:{viewPlaneNormal:[...c],enabledElement:o,viewUp:[...u],FrameOfReferenceUID:f,referencedImageId:h,toolName:this.getToolName(),volumeId:p},data:{label:"",handles:{textBox:{hasMoved:!1,worldPosition:null,worldBoundingBox:null},points:[[...i],[...i],[...i],[...i]],activeHandleIndex:null},segmentationId:null}};ig(m,r);const g=vs(r,this.getToolName());return this.editData={annotation:m,viewportIdsToRender:g,handleIndex:3,newAnnotation:!0,hasMoved:!1},this._activateDraw(r),Ia(r),e.preventDefault(),Po(s,g),m},this.renderAnnotation=(e,t)=>{let n=!1;const{viewport:r,renderingEngineId:i}=e,{element:o}=r;let a=rg(this.getToolName(),o);if(!a?.length)return n;if(a=this.filterInteractableAnnotationsForElement(o,a),!a?.length)return n;const s={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id};for(let e=0;er.worldToCanvas(e)));s.annotationUID=l;const p=this.getStyle("lineWidth",s,o),f=this.getStyle("lineDash",s,o),m=this.getStyle("color",s,o);if(!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;const g=ne.ANNOTATION_MODIFIED,v={annotation:o,viewportId:r.id,renderingEngineId:i};let y;if((0,Y.triggerEvent)(Y.eventTarget,g,v),!ke(l))continue;if(he(o)||this.editData||null===d||(y=[h[d]]),y){Fi(t,l,"0",y,{color:m})}qi(t,l,"0",h[0],h[3],{color:m,lineDash:f,lineWidth:p}),n=!0}return n}}}$u.toolName="RectangleROIThreshold";const Ju=$u,{transformWorldToIndex:Yu}=Y.utilities;class Zu extends xl{constructor(e={},t={configuration:{numSlicesToPropagate:10}}){super(e,t),this.addNewAnnotation=e=>{const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=(0,Y.getEnabledElement)(r),{viewport:a,renderingEngine:s}=o;this.isDrawing=!0;const l=a.getCamera(),{viewPlaneNormal:c,viewUp:u}=l;let d,h,p;if(a instanceof Y.StackViewport)throw new Error("Stack Viewport Not implemented");p=this.getTargetId(a).split("volumeId:")[1],h=Y.cache.getVolume(p),d=Y.utilities.getClosestImageId(h,i,c);if(!d)throw new Error("This tool does not work on non-acquisition planes");const f=a.getCurrentImageIdIndex(),m=Y.utilities.getSpacingInNormalDirection(h,c),g=this._getEndSliceIndex(h,i,m,c),v=a.getFrameOfReferenceUID(),y={highlighted:!0,invalidated:!0,metadata:{viewPlaneNormal:[...c],enabledElement:o,viewUp:[...u],FrameOfReferenceUID:v,referencedImageId:d,toolName:this.getToolName(),volumeId:p,spacingInNormal:m},data:{label:"",startSlice:f,endSlice:g,cachedStats:{projectionPoints:[],projectionPointsImageIds:[d]},handles:{textBox:{hasMoved:!1,worldPosition:null,worldBoundingBox:null},points:[[...i],[...i],[...i],[...i]],activeHandleIndex:null},labelmapUID:null}};this._computeProjectionPoints(y,h),ig(y,r);const _=vs(r,this.getToolName());return this.editData={annotation:y,viewportIdsToRender:_,handleIndex:3,newAnnotation:!0,hasMoved:!1},this._activateDraw(r),Ia(r),e.preventDefault(),Po(s,_),y},this.renderAnnotation=(e,t)=>{let n=!1;const{viewport:r}=e,i=rg(this.getToolName(),r.element);if(!i?.length)return n;const o=r.getCurrentImageIdIndex(),a={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id};for(let s=0;sr.worldToCanvas(e)));a.annotationUID=c;const g=this.getStyle("lineWidth",a,l),v=this.getStyle("lineDash",a,l),y=this.getStyle("color",a,l);if(oMath.max(d,h))continue;l.invalidated&&this._throttledCalculateCachedStats(l,e);let _,b=!1;if(o!==d&&o!==h||(b=!0),!r.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;if(!ke(c))continue;if(he(l)||this.editData||null===f||!b||(_=[m[f]]),_){Fi(t,c,"0",_,{color:y})}let E=v;b||(E=2);qi(t,c,"0",m[0],m[3],{color:y,lineDash:E,lineWidth:g}),n=!0}return n},this._throttledCalculateCachedStats=To(this._calculateCachedStatsTool,100,{trailing:!0})}_computeProjectionPoints(e,t){const{data:n,metadata:r}=e,{viewPlaneNormal:i,spacingInNormal:o}=r,{imageData:a}=t,{startSlice:s,endSlice:l}=n,{points:c}=n.handles,u=Yu(a,c[0]);if(u[2]!==s)throw new Error("Start slice does not match");const d=Ci.R3.fromValues(u[0],u[1],l),h=Ci.R3.create();a.indexToWorldVec3(u,h);const p=Ci.R3.create();a.indexToWorldVec3(d,p);const f=Ci.R3.distance(h,p),m=[];for(let e=0;e{const n=Ci.R3.create();return Ci.R3.scaleAndAdd(n,t,i,e),Array.from(n)})));n.cachedStats.projectionPoints=m;const g=[];for(const e of m){const n=Y.utilities.getClosestImageId(t,e[0],i);g.push(n)}n.cachedStats.projectionPointsImageIds=g}_calculateCachedStatsTool(e,t){const n=e.data,{viewportId:r,renderingEngineId:i,viewport:o}=t,{cachedStats:a}=n,s=this.getTargetId(o),l=Y.cache.getVolume(s.split("volumeId:")[1]);this._computeProjectionPoints(e,l),e.invalidated=!1;const c=ne.ANNOTATION_MODIFIED,u={annotation:e,viewportId:r,renderingEngineId:i};return(0,Y.triggerEvent)(Y.eventTarget,c,u),a}_getEndSliceIndex(e,t,n,r){const i=this.configuration.numSlicesToPropagate,o=Ci.R3.create();Ci.R3.scaleAndAdd(o,t,r,i*n);const a=n/2,{imageIds:s}=e;let l;for(let e=0;e0;)p(c.pop());return{flooded:u,boundaries:function(){const e=[];for(const t in h)void 0!==h[t]&&e.unshift(h[t]);return e}()};function p(e){const t=e.currentArgs,n=e.previousArgs;!0!==d[t]&&(!function(e){d[e]=!0}(t),function(e){const t=m(f,[e]);return m(o,[t,s])}(t)?(function(e){u.push(e),r&&r(...e)}(t),function(e){for(let t=0;t{const t=e.detail,{currentPoints:n,element:r}=t,i=n.world,o=(0,Y.getEnabledElement)(r),{viewport:a}=o,s=a.getCamera(),{viewPlaneNormal:l}=s,c=si(this.toolGroupId);if(!c)throw new Error("No active segmentation detected, create one before using scissors tool");const{segmentationId:u,type:d}=c,h=Ei(u),p=di(u),{representationData:f}=Jn(u),{volumeId:m}=f[d],g=Y.cache.getVolume(m),{dimensions:v,direction:y}=g,_=g.getScalarData(),b=rd(g.imageData,i),E=this.getFixedDimension(l,y);if(void 0===E)return void console.warn("Oblique paint fill not yet supported");const{floodFillGetter:w,getLabelValue:x,getScalarDataPositionFromPlane:C,inPlaneSeedPoint:D,fixedDimensionValue:S}=this.generateHelpers(_,v,b,E);if(b[0]<0||b[0]>=v[0]||b[1]<0||b[1]>=v[1]||b[2]<0||b[2]>=v[2])return;const T=x(b[0],b[1],b[2]);if(p.includes(T))return;const I=nd(w,D),{flooded:A}=I;A.forEach((e=>{const t=C(e[0],e[1]);_[t]=h}));return Kn(u,this.getFramesModified(E,S,I)),!0},this.getFramesModified=(e,t,n)=>{const{boundaries:r}=n;if(2===e)return[t];let i=1/0,o=-1/0;for(let e=0;eo&&(o=t)}const a=[];for(let e=i;e<=o;e++)a.push(e);return a},this.generateHelpers=(e,t,n,r=2)=>{let i,o;switch(r){case 0:i=n[0],o=[n[1],n[2]];break;case 1:i=n[1],o=[n[0],n[2]];break;case 2:i=n[2],o=[n[0],n[1]];break;default:throw new Error(`Invalid fixedDimension: ${r}`)}const a=(e,n,r)=>r*t[1]*t[0]+n*t[0]+e,s=(t,n,r)=>e[a(t,n,r)],l=this.generateFloodFillGetter(t,r,i,s);return{getScalarDataPositionFromPlane:this.generateGetScalarDataPositionFromPlane(a,r,i),getLabelValue:s,floodFillGetter:l,inPlaneSeedPoint:o,fixedDimensionValue:i}},this.generateFloodFillGetter=(e,t,n,r)=>{let i;switch(t){case 0:i=(t,i)=>{if(!(t>=e[1]||t<0||i>=e[2]||i<0))return r(n,t,i)};break;case 1:i=(t,i)=>{if(!(t>=e[0]||t<0||i>=e[2]||i<0))return r(t,n,i)};break;case 2:i=(t,i)=>{if(!(t>=e[0]||t<0||i>=e[1]||i<0))return r(t,i,n)};break;default:throw new Error(`Invalid fixedDimension: ${t}`)}return i},this.generateGetScalarDataPositionFromPlane=(e,t,n)=>{let r;switch(t){case 0:r=(t,r)=>e(n,t,r);break;case 1:r=(t,r)=>e(t,n,r);break;case 2:r=(t,r)=>e(t,r,n);break;default:throw new Error(`Invalid fixedDimension: ${t}`)}return r}}getFixedDimension(e,t){const n=t.slice(0,3),r=t.slice(3,6),i=t.slice(6,9),o=[Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2])],a=[Math.abs(n[0]),Math.abs(n[1]),Math.abs(n[2])];if(id(o,a))return 0;const s=[Math.abs(r[0]),Math.abs(r[1]),Math.abs(r[2])];if(id(o,s))return 1;const l=[Math.abs(i[0]),Math.abs(i[1]),Math.abs(i[2])];return id(o,l)?2:void 0}}od.toolName="PaintFill";const ad=od;var sd=n(78826),ld=n(16976),cd=n(87765),ud=n(32198),dd={Corners:{TOP_LEFT:"TOP_LEFT",TOP_RIGHT:"TOP_RIGHT",BOTTOM_LEFT:"BOTTOM_LEFT",BOTTOM_RIGHT:"BOTTOM_RIGHT"}};function hd(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 pd(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:{};Object.assign(t,gd,n),Lr.default.obj(e,t),Lr.default.get(e,t,["enabled","viewportCorner","viewportSize"]),Lr.default.setGet(e,t,["_interactor","minPixelSize","maxPixelSize","parentRenderer"]),Lr.default.get(e,t,["actor"]),Lr.default.moveToProtected(e,t,["interactor"]),function(e,t){t.classHierarchy.push("vtkOrientationMarkerWidget");var n=pd({},e),r=[],i=ud.ZP.newInstance(),o=new ResizeObserver((function(t){e.updateViewport()})),a=null,s=null,l=null,c=null,u=null;function d(){t._interactor.isAnimating()||e.updateMarkerOrientation()}t._onParentRendererChanged=function(){return e.updateViewport()},e.computeViewport=function(){var e=t.parentRenderer||t._interactor.getCurrentRenderer(),n=e.getViewport(),r=(0,ld.Z)(n,4),i=r[0],o=r[1],a=r[2],s=r[3],l=t._interactor.getView(),c=l.getSize(),u=l.getViewportSize(e),d=(0,ld.Z)(u,2),h=d[0],p=d[1],f=Math.min(h,p),m=t.viewportSize*f,g=(m=Math.max(Math.min(t.minPixelSize,f),Math.min(t.maxPixelSize,m)))/c[0],v=m/c[1];switch(t.viewportCorner){case md.TOP_LEFT:return[i,s-v,i+g,s];case md.TOP_RIGHT:return[a-g,s-v,a,s];case md.BOTTOM_LEFT:return[i,o,i+g,o+v];case md.BOTTOM_RIGHT:return[a-g,o,a,o+v];default:return fd("Invalid widget corner"),null}},e.updateViewport=function(){t.enabled&&(i.setViewport.apply(i,(0,sd.Z)(e.computeViewport())),t._interactor.render())},e.updateMarkerOrientation=function(){var e=(t.parentRenderer||t._interactor.getCurrentRenderer()).getActiveCamera();if(e){var n=e.getReferenceByName("position"),o=e.getReferenceByName("focalPoint"),a=e.getReferenceByName("viewUp");if(r[0]!==n[0]||r[1]!==n[1]||r[2]!==n[2]||r[3]!==o[0]||r[4]!==o[1]||r[5]!==o[2]||r[6]!==a[0]||r[7]!==a[1]||r[8]!==a[2]){r[0]=n[0],r[1]=n[1],r[2]=n[2],r[3]=o[0],r[4]=o[1],r[5]=o[2],r[6]=a[0],r[7]=a[1],r[8]=a[2];var s=i.getActiveCamera();s.setPosition(n[0],n[1],n[2]),s.setFocalPoint(o[0],o[1],o[2]),s.setViewUp(a[0],a[1],a[2]),i.resetCamera()}}},e.setEnabled=function(n){if(n){if(t.enabled)return;if(!t.actor)return void fd("Must set actor before enabling orientation marker.");if(!t._interactor)return void fd("Must set interactor before enabling orientation marker.");var r=t.parentRenderer||t._interactor.getCurrentRenderer(),u=r.getRenderWindow();u.addRenderer(i),u.getNumberOfLayers()<2&&u.setNumberOfLayers(2),i.setLayer(u.getNumberOfLayers()-1),i.setInteractive(!1),i.addViewProp(t.actor),t.actor.setVisibility(!0),a=r.onEvent((function(e){"ActiveCameraEvent"===e.type&&(s&&s.unsubscribe(),s=e.camera.onModified(d))})),s=r.getActiveCamera().onModified(d),l=t._interactor.onAnimation(e.updateMarkerOrientation),c=t._interactor.onEndAnimation(e.updateMarkerOrientation),o.observe(t._interactor.getView().getCanvas()),e.updateViewport(),e.updateMarkerOrientation(),t.enabled=!0}else{var h,p;if(!t.enabled)return;t.enabled=!1,o.disconnect(),a.unsubscribe(),a=null,s.unsubscribe(),s=null,l.unsubscribe(),l=null,c.unsubscribe(),c=null,t.actor.setVisibility(!1),i.removeViewProp(t.actor);var f=null===(h=t._interactor)||void 0===h||null===(p=h.findPokedRenderer())||void 0===p?void 0:p.getRenderWindow();f&&f.removeRenderer(i)}e.modified()},e.setViewportCorner=function(n){n!==t.viewportCorner&&(t.viewportCorner=n,e.updateViewport())},e.setViewportSize=function(n){var r=Math.min(1,Math.max(0,n));r!==t.viewportSize&&(t.viewportSize=r,e.updateViewport())},e.setActor=function(n){var r=t.enabled;e.setEnabled(!1),t.actor=n,e.setEnabled(r)},e.getRenderer=function(){return i},e.delete=function(){n.delete(),u&&(u.unsubscribe(),u=null),a&&(a.unsubscribe(),a=null),s&&(s.unsubscribe(),s=null),l&&(l.unsubscribe(),l=null),c&&(c.unsubscribe(),c=null),o.disconnect()},u=e.onModified(e.updateViewport)}(e,t)}var yd=pd({newInstance:Lr.default.newInstance(vd,"vtkOrientationMarkerWidget"),extend:vd},dd),_d=n(64725),bd=n(97442),Ed=n(96372);function wd(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0,0],n=(0,ld.Z)(t,4),r=n[0],i=n[1],o=n[2],a=n[3],s=e.getContext("2d").getImageData(r,i,o||e.width,a||e.height),l=Ed.ZP.newInstance({type:"vtkImageData"});l.setOrigin(0,0,0),l.setSpacing(1,1,1),l.setExtent(0,(o||e.width)-1,0,(a||e.height)-1,0,0);var c=Mr.ZP.newInstance({numberOfComponents:4,values:new Uint8Array(s.data.buffer)});return c.setName("scalars"),l.getPointData().setScalars(c),l}var xd={canvasToImageData:wd,imageToImageData:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{flipX:!1,flipY:!1,rotate:0},n=document.createElement("canvas");n.width=e.width,n.height=e.height;var r=n.getContext("2d"),i=t.flipX,o=t.flipY,a=t.rotate;return r.translate(n.width/2,n.height/2),r.scale(i?-1:1,o?-1:1),r.rotate(a*Math.PI/180),r.drawImage(e,-e.width/2,-e.height/2),wd(n)}},Cd={default:{defaultStyle:{fontStyle:"bold",fontFamily:"Arial",fontColor:"black",fontSizeScale:function(e){return e/2},faceColor:"white",edgeThickness:.1,edgeColor:"black",resolution:400},xMinusFaceProperty:{text:"X-",faceColor:"yellow"},xPlusFaceProperty:{text:"X+",faceColor:"yellow"},yMinusFaceProperty:{text:"Y-",faceColor:"red"},yPlusFaceProperty:{text:"Y+",faceColor:"red"},zMinusFaceProperty:{text:"Z-",faceColor:"#008000"},zPlusFaceProperty:{text:"Z+",faceColor:"#008000"}},lps:{xMinusFaceProperty:{text:"R",faceRotation:-90},xPlusFaceProperty:{text:"L",faceRotation:90},yMinusFaceProperty:{text:"A",faceRotation:0},yPlusFaceProperty:{text:"P",faceRotation:180},zMinusFaceProperty:{text:"I",faceRotation:180},zPlusFaceProperty:{text:"S",faceRotation:0}}};function Dd(e,t){t.set(e)}var Sd={applyDefinitions:Dd,applyPreset:function(e,t){return Dd(Cd[e],t)},registerStylePreset:function(e,t){Cd[e]=t}};function Td(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 Id(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:{};Object.assign(t,Nd,n),Hr.ZP.extend(e,t,n),Lr.default.get(e,t,["defaultStyle","xPlusFaceProperty","xMinusFaceProperty","yPlusFaceProperty","yMinusFaceProperty","zPlusFaceProperty","zMinusFaceProperty"]),function(e,t){t.classHierarchy.push("vtkAnnotatedCubeActor"),t.xPlusFaceProperty=Id({},t.xPlusFaceProperty),t.xMinusFaceProperty=Id({},t.xMinusFaceProperty),t.yPlusFaceProperty=Id({},t.yPlusFaceProperty),t.yMinusFaceProperty=Id({},t.yMinusFaceProperty),t.zPlusFaceProperty=Id({},t.zPlusFaceProperty),t.zMinusFaceProperty=Id({},t.zMinusFaceProperty);var n=null,r=document.createElement("canvas"),i=qr.ZP.newInstance(),o=_d.ZP.newInstance();function a(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;i&&Object.assign(t["".concat(n,"FaceProperty")],i);var a=Id(Id({},t.defaultStyle),t["".concat(n,"FaceProperty")]);r.width=a.resolution,r.height=a.resolution;var s=r.getContext("2d");s.fillStyle=a.faceColor,s.fillRect(0,0,r.width,r.height),a.edgeThickness>0&&(s.strokeStyle=a.edgeColor,s.lineWidth=a.edgeThickness*r.width,s.strokeRect(0,0,r.width,r.height)),s.save(),s.translate(0,r.height),s.scale(1,-1),s.translate(r.width/2,r.height/2),s.rotate(-Math.PI*(a.faceRotation/180));var l=a.fontSizeScale(a.resolution);s.fillStyle=a.fontColor,s.textAlign="center",s.textBaseline="middle",s.font="".concat(a.fontStyle," ").concat(l,'px "').concat(a.fontFamily,'"'),s.fillText(a.text,0,0),s.restore();var c=xd.canvasToImageData(r);o.setInputData(c,Ad[n]),e.modified()}function s(){n=bd.ZP.newInstance({generate3DTextureCoordinates:!0}),i.setInputConnection(n.getOutputPort()),a("xPlus"),a("xMinus"),a("yPlus"),a("yMinus"),a("zPlus"),a("zMinus")}o.setInterpolate(!0),e.setDefaultStyle=function(e){t.defaultStyle=Id(Id({},t.defaultStyle),e),s()},e.setXPlusFaceProperty=function(e){return a("xPlus",e)},e.setXMinusFaceProperty=function(e){return a("xMinus",e)},e.setYPlusFaceProperty=function(e){return a("yPlus",e)},e.setYMinusFaceProperty=function(e){return a("yMinus",e)},e.setZPlusFaceProperty=function(e){return a("zPlus",e)},e.setZMinusFaceProperty=function(e){return a("zMinus",e)},s(),i.setInputConnection(n.getOutputPort()),e.setMapper(i),e.addTexture(o)}(e,t)}var Pd={newInstance:Lr.default.newInstance(Od,"vtkAnnotatedCubeActor"),extend:Od,Presets:Sd};var kd={height:1,radius:.5,resolution:6,center:[0,0,0],direction:[1,0,0],capping:!0,pointType:"Float64Array"};function Md(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Object.assign(t,kd,n),Lr.default.obj(e,t),Lr.default.setGet(e,t,["height","radius","resolution","capping"]),Lr.default.setGetArray(e,t,["center","direction"],3),Lr.default.algo(e,t,0,1),function(e,t){t.classHierarchy.push("vtkConeSource"),e.requestData=function(e,n){var r;if(!t.deleted){var i=n[0],o=2*Math.PI/t.resolution,a=-t.height/2,s=t.resolution+1,l=4*t.resolution+1+t.resolution,c=0,u=Lr.default.newTypedArray(t.pointType,3*s),d=0,h=new Uint32Array(l);u[0]=t.height/2,u[1]=0,u[2]=0,t.capping&&(h[d++]=t.resolution);for(var p=0;pt.resolution?1:f+2;(r=cs.Z.buildFromRadian()).translate.apply(r,(0,sd.Z)(t.center)).rotateFromDirections([1,0,0],t.direction).apply(u),(i=Fr.ZP.newInstance()).getPoints().setData(u,3),i.getPolys().setData(h,1),n[0]=i}}}(e,t)}var Ld={newInstance:Lr.default.newInstance(Md,"vtkConeSource"),extend:Md};var Rd={height:1,initAngle:0,radius:1,resolution:6,center:[0,0,0],direction:[0,1,0],capping:!0,pointType:"Float64Array"};function Fd(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Object.assign(t,Rd,n),Lr.default.obj(e,t),Lr.default.setGet(e,t,["height","initAngle","otherRadius","radius","resolution","capping"]),Lr.default.setGetArray(e,t,["center","direction"],3),Lr.default.algo(e,t,0,1),function(e,t){t.classHierarchy.push("vtkCylinderSource"),e.requestData=function(e,n){var r,i;if(!t.deleted){var o=n[0],a=2*Math.PI/t.resolution,s=2*t.resolution,l=5*t.resolution;t.capping&&(s=4*t.resolution,l=7*t.resolution+2);for(var c=Lr.default.newTypedArray(t.pointType,3*s),u=0,d=new Uint32Array(l),h=new Float32Array(3*s),p=Mr.ZP.newInstance({numberOfComponents:3,values:h,name:"Normals"}),f=new Float32Array(2*s),m=Mr.ZP.newInstance({numberOfComponents:2,values:f,name:"TCoords"}),g=[0,0,0],v=[0,0,0],y=[0,0,0],_=[0,0,0],b=[0,0],E=[0,0],w=null==t.otherRadius?t.radius:t.otherRadius,x=0;x2&&void 0!==arguments[2]?arguments[2]:{};Object.assign(t,Bd,n),Lr.default.obj(e,t),Lr.default.setGet(e,t,["tipResolution","tipRadius","tipLength","shaftResolution","shaftRadius","invert"]),Lr.default.setGetArray(e,t,["direction"],3),Lr.default.algo(e,t,0,1),function(e,t){t.classHierarchy.push("vtkArrowSource"),e.requestData=function(e,n){if(!t.deleted){var r=Ud.newInstance({capping:!0});r.setResolution(t.shaftResolution),r.setRadius(t.shaftRadius),r.setHeight(1-t.tipLength),r.setCenter(0,.5*(1-t.tipLength),0);var i=r.getOutputData(),o=i.getPoints().getData(),a=i.getPointData().getNormals().getData();cs.Z.buildFromDegree().rotateZ(-90).apply(o).apply(a);var s=Ld.newInstance();s.setResolution(t.tipResolution),s.setHeight(t.tipLength),s.setRadius(t.tipRadius);var l=s.getOutputData(),c=l.getPoints().getData();cs.Z.buildFromRadian().translate(1-.5*t.tipLength,0,0).apply(c);var u=Gr.newInstance();u.setInputData(i),u.addInputData(l);var d=u.getOutputData(),h=d.getPoints().getData();cs.Z.buildFromRadian().translate(.5*t.tipLength-.5,0,0).apply(h),t.invert?(cs.Z.buildFromRadian().rotateFromDirections([1,0,0],t.direction).scale(-1,-1,-1).apply(h),n[0]=d):(cs.Z.buildFromRadian().rotateFromDirections([1,0,0],t.direction).scale(1,1,1).apply(h),n[0]=u.getOutputData())}}}(e,t)}var Vd={newInstance:Lr.default.newInstance(jd,"vtkArrowSource"),extend:jd};function Wd(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 zd(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:{};Object.assign(t,Kd,n),Hr.ZP.extend(e,t,n),Lr.default.setGet(e,t,["config"]),Lr.default.setGetArray(e,t,["xAxisColor","yAxisColor","zAxisColor"],3,255),function(e,t){t.classHierarchy.push("vtkAxesActor");var n=qr.ZP.newInstance();e.setMapper(n),e.update=function(){var e=Vd.newInstance(zd({direction:[1,0,0]},t.config)).getOutputData();t.config.recenter?Gd(e):Hd(e,0),qd.apply(void 0,[e].concat((0,sd.Z)(t.xAxisColor)));var r=Vd.newInstance(zd({direction:[0,1,0]},t.config)).getOutputData();t.config.recenter?Gd(r):Hd(r,1),qd.apply(void 0,[r].concat((0,sd.Z)(t.yAxisColor)));var i=Vd.newInstance(zd({direction:[0,0,1]},t.config)).getOutputData();t.config.recenter?Gd(i):Hd(i,2),qd.apply(void 0,[i].concat((0,sd.Z)(t.zAxisColor)));var o=Gr.newInstance();o.setInputData(e),o.addInputData(r),o.addInputData(i),n.setInputConnection(o.getOutputPort())},e.update();var r=Lr.default.debounce(e.update,0),i=e.setConfig,o=e.setXAxisColor,a=e.setYAxisColor,s=e.setZAxisColor;e.setConfig=function(e){return!!i(e)&&(r(),!0)},e.setXAxisColor=function(e){return!!o(e)&&(r(),!0)},e.setYAxisColor=function(e){return!!a(e)&&(r(),!0)},e.setZAxisColor=function(e){return!!s(e)&&(r(),!0)}}(e,t)}var $d={newInstance:Lr.default.newInstance(Xd,"vtkAxesActor"),extend:Xd},Jd=n(39053),Yd=Uint8Array,Zd=Uint16Array,Qd=Uint32Array,eh=new Yd([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),th=new Yd([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),nh=new Yd([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),rh=function(e,t){for(var n=new Zd(31),r=0;r<31;++r)n[r]=t+=1<>>1|(21845&uh)<<1;dh=(61680&(dh=(52428&dh)>>>2|(13107&dh)<<2))>>>4|(3855&dh)<<4,ch[uh]=((65280&dh)>>>8|(255&dh)<<8)>>>1}var hh=function(e,t,n){for(var r=e.length,i=0,o=new Zd(t);i>>l]=c}else for(a=new Zd(r),i=0;i>>15-e[i]);return a},ph=new Yd(288);for(uh=0;uh<144;++uh)ph[uh]=8;for(uh=144;uh<256;++uh)ph[uh]=9;for(uh=256;uh<280;++uh)ph[uh]=7;for(uh=280;uh<288;++uh)ph[uh]=8;var fh=new Yd(32);for(uh=0;uh<32;++uh)fh[uh]=5;var mh=hh(ph,9,1),gh=hh(fh,5,1),vh=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},yh=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},_h=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},bh=function(e){return(e+7)/8|0},Eh=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(2==e.BYTES_PER_ELEMENT?Zd:4==e.BYTES_PER_ELEMENT?Qd:Yd)(n-t);return r.set(e.subarray(t,n)),r},wh=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],xh=function(e,t,n){var r=new Error(t||wh[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,xh),!n)throw r;return r},Ch=function(e,t,n){var r=e.length;if(!r||n&&n.f&&!n.l)return t||new Yd(0);var i=!t||n,o=!n||n.i;n||(n={}),t||(t=new Yd(3*r));var a=function(e){var n=t.length;if(e>n){var r=new Yd(Math.max(2*n,e));r.set(t),t=r}},s=n.f||0,l=n.p||0,c=n.b||0,u=n.l,d=n.d,h=n.m,p=n.n,f=8*r;do{if(!u){s=yh(e,l,1);var m=yh(e,l+1,3);if(l+=3,!m){var g=e[(T=bh(l)+4)-4]|e[T-3]<<8,v=T+g;if(v>r){o&&xh(0);break}i&&a(c+g),t.set(e.subarray(T,v),c),n.b=c+=g,n.p=l=8*v,n.f=s;continue}if(1==m)u=mh,d=gh,h=9,p=5;else if(2==m){var y=yh(e,l,31)+257,_=yh(e,l+10,15)+4,b=y+yh(e,l+5,31)+1;l+=14;for(var E=new Yd(b),w=new Yd(19),x=0;x<_;++x)w[nh[x]]=yh(e,l+3*x,7);l+=3*_;var C=vh(w),D=(1<>>4)<16)E[x++]=T;else{var A=0,N=0;for(16==T?(N=3+yh(e,l,3),l+=2,A=E[x-1]):17==T?(N=3+yh(e,l,7),l+=3):18==T&&(N=11+yh(e,l,127),l+=7);N--;)E[x++]=A}}var O=E.subarray(0,y),P=E.subarray(y);h=vh(O),p=vh(P),u=hh(O,h,1),d=hh(P,p,1)}else xh(1);if(l>f){o&&xh(0);break}}i&&a(c+131072);for(var k=(1<>>4;if((l+=15&A)>f){o&&xh(0);break}if(A||xh(2),R<256)t[c++]=R;else{if(256==R){L=l,u=null;break}var F=R-254;if(R>264){var U=eh[x=R-257];F=yh(e,l,(1<>>4;B||xh(3),l+=15&B;P=lh[j];if(j>3){U=th[j];P+=_h(e,l)&(1<f){o&&xh(0);break}i&&a(c+131072);for(var V=c+F;c>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(2&t)},Th=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},Ih=function(e){(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)&&xh(6,"invalid zlib data"),32&e[1]&&xh(6,"invalid zlib data: preset dictionaries not supported")};function Ah(e,t){return Ch(e,t)}function Nh(e,t){return Ch(e.subarray(Sh(e),-8),t||new Yd(Th(e)))}function Oh(e,t){return Ch((Ih(e),e.subarray(2,-4)),t)}var Ph="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ph.decode(Dh,{stream:!0}),1}catch(e){}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;var kh={};function Mh(e){return!!kh[e]}function Lh(e,t){kh[e]=t}var Rh={get:function(){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return kh[arguments.length>0&&void 0!==arguments[0]?arguments[0]:"http"](e)},has:Mh,registerType:Lh},Fh=[];Fh["-".charCodeAt(0)]=62,Fh["_".charCodeAt(0)]=63;for(var Uh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Bh=0;Bh>16&255,r[u++]=c>>8&255,r[u++]=255&c}switch(a){case 3:for(;!jh(e[l]);)l++;for(c=Fh[e.charCodeAt(l++)]<<10;!jh(e[l]);)l++;for(c|=Fh[e.charCodeAt(l++)]<<4;!jh(e[l]);)l++;c|=Fh[e.charCodeAt(l++)]>>2,r[u++]=c>>8&255,r[u++]=255&c;break;case 2:for(;!jh(e[l]);)l++;for(c=Fh[e.charCodeAt(l++)]<<2;!jh(e[l]);)l++;c|=Fh[e.charCodeAt(l++)]>>4,r[u++]=255&c;break;case 1:throw new Error("BASE64: remain 1 should not happen")}return u}function Wh(e,t,n){var r=(e<<16)+(t<<8)+n;return Uh[r>>18]+Uh[r>>12&63]+Uh[r>>6&63]+Uh[63&r]}var zh={toArrayBuffer:function(e){for(var t=function(e){for(var t=e.length,n=[],r=null,i=0;i0){var s=Wh(t[r],t[r+1]||0,t[r+2]||0);1===n?i.push("".concat(s.substr(0,2),"==")):2===n&&i.push("".concat(s.substr(0,3),"="))}return i.join("")}};function Gh(e){return new TextDecoder("latin1").decode(e)}var Hh={arrayBufferToString:Gh,extractBinary:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=Gh(e),i=t.exec(r);if(!i)return{text:r};var o=i.index+i[0].length,a=r.substring(0,o),s=n?n.exec(r):null;return s?{text:a+r.substr(s.index),binaryBuffer:e.slice(o,s.index)}:{text:a,binaryBuffer:e.slice(o)}}};function qh(){var e=new ArrayBuffer(4),t=new Uint8Array(e),n=new Uint32Array(e);return t[0]=161,t[1]=178,t[2]=195,t[3]=212,3569595041===n[0]?"LittleEndian":2712847316===n[0]?"BigEndian":null}var Kh={ENDIANNESS:qh(),getEndianness:qh,swapBytes:function(e,t){if(!(t<2))for(var n=new Int8Array(e),r=n.length,i=[],o=0;o2&&void 0!==arguments[2]?arguments[2]:{},r=new XMLHttpRequest;return r.open(e,t,!0),n.headers&&Object.entries(n.headers).forEach((function(e){var t=(0,ld.Z)(e,2),n=t[0],i=t[1];return r.setRequestHeader(n,i)})),n.progressCallback&&r.addEventListener("progress",n.progressCallback),r}var Qh={fetchArray:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return r&&r.compression?Jh():n.ref&&!n.ref.pending?new Promise((function(i,o){var a=Zh("GET",[t,n.ref.basepath,n.ref.id].join("/"),r);a.onreadystatechange=function(t){1===a.readyState&&(n.ref.pending=!0,1==++Yh&&null!=e&&e.invokeBusy&&e.invokeBusy(!0)),4===a.readyState&&(n.ref.pending=!1,200===a.status||0===a.status?(n.buffer=a.response,"JSON"===n.ref.encode?n.values=JSON.parse(n.buffer):(Kh.ENDIANNESS!==n.ref.encode&&Kh.ENDIANNESS&&($h("Swap bytes of ".concat(n.name)),Kh.swapBytes(n.buffer,Br.Xe[n.dataType])),n.values=Lr.default.newTypedArray(n.dataType,n.buffer)),n.values.length!==n.size&&Xh("Error in FetchArray: ".concat(n.name,", does not have the proper array size. Got ").concat(n.values.length,", instead of ").concat(n.size)),delete n.ref,0==--Yh&&null!=e&&e.invokeBusy&&e.invokeBusy(!1),null!=e&&e.modified&&e.modified(),i(n)):o({xhr:a,e:t}))},a.responseType="string"!==n.dataType?"arraybuffer":"text",a.send()})):Promise.resolve(n)},fetchJSON:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return n&&n.compression?Jh():new Promise((function(r,i){var o=Zh("GET",t,n);o.onreadystatechange=function(t){1===o.readyState&&1==++Yh&&null!=e&&e.invokeBusy&&e.invokeBusy(!0),4===o.readyState&&(0==--Yh&&null!=e&&e.invokeBusy&&e.invokeBusy(!1),200===o.status||0===o.status?r(JSON.parse(o.responseText)):i({xhr:o,e:t}))},o.responseType="text",o.send()}))},fetchText:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return n&&n.compression?Jh():new Promise((function(r,i){var o=Zh("GET",t,n);o.onreadystatechange=function(t){1===o.readyState&&1==++Yh&&null!=e&&e.invokeBusy&&e.invokeBusy(!0),4===o.readyState&&(0==--Yh&&null!=e&&e.invokeBusy&&e.invokeBusy(!1),200===o.status||0===o.status?r(o.responseText):i({xhr:o,e:t}))},o.responseType="text",o.send()}))},fetchBinary:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(n,r){var i=Zh("GET",e,t);i.onreadystatechange=function(e){4===i.readyState&&(200===i.status||0===i.status?n(i.response):r({xhr:i,e}))},i.responseType="arraybuffer",i.send()}))},fetchImage:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise((function(e,r){var i=new Image;n.crossOrigin&&(i.crossOrigin=n.crossOrigin),i.onload=function(){return e(i)},i.onerror=r,i.src=t}))}};function ep(e,t){return(0,sd.Z)(e.getElementsByTagName(t))}function tp(e,t){return ep(e,t)[0]}Mh("http")||Lh("http",(function(e){return Qh}));var np={Int8:Int8Array,UInt8:Uint8Array,Int16:Int16Array,UInt16:Uint16Array,Int32:Int32Array,UInt32:Uint32Array,Int64:Int32Array,UInt64:Uint32Array,Float32:Float32Array,Float64:Float64Array},rp={Int8:1,UInt8:1,Int16:2,UInt16:2,Int32:4,UInt32:4,Int64:8,UInt64:8,Float32:4,Float64:8};function ip(e){var t=e.length-1;return e.filter((function(e,n){return n>4>7||(n[0]<<8|n[1])%31?Ah(n,r):Oh(n,r);t.uint8.set(i,t.offset),t.offset+=i.length}function sp(e,t,n,r,i,o){var a=t.getAttribute("type"),s=t.getAttribute("Name"),l=t.getAttribute("format"),c=Number(t.getAttribute("NumberOfComponents")||"1"),u=null;if("ascii"===l){u=new np[a](e*c);var d=0;t.firstChild.nodeValue.split(/[\\t \\n]+/).forEach((function(e){e.trim().length&&(u[d++]=Number(e))}))}else if("binary"===l){var h=new Uint8Array(zh.toArrayBuffer(t.firstChild.nodeValue.trim()));if("vtkZLibDataCompressor"===n){var p=new ArrayBuffer(rp[a]*e*c);u=new np[a](p);for(var f={offset:0,uint8:new Uint8Array(p)},m=op(h,i),g=m[1],v=h.length-(m.reduce((function(e,t){return e+t}),0)-(m[0]+m[1]+m[2]+m[3])),y=0;y1&&void 0!==arguments[1]?arguments[1]:{};t.url=n;var i=n.split("/");return i.pop(),t.baseURL=i.join("/"),e.loadData(r)},e.loadData=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.dataAccessHelper.fetchBinary(e,n)}(t.url,n).then(e.parseAsArrayBuffer)},e.parseAsArrayBuffer=function(n){if(!n)return!1;if(n===t.rawDataBuffer)return!0;e.modified();var r=function(e){return Hh.extractBinary(e,/^\s*\s*_/m,/\n\s*<\/AppendedData>/m)}(n),i=r.text,o=r.binaryBuffer;t.rawDataBuffer=n,t.binaryBuffer=o;var a,s=(a=i,(0,Jd.create)(a)).root().node,l=s.getAttribute("type"),c=s.getAttribute("compressor"),u=s.getAttribute("byte_order"),d=s.getAttribute("header_type")||"UInt32";if(c&&"vtkZLibDataCompressor"!==c)return console.error("Invalid compressor",c),!1;if(u&&"LittleEndian"!==u)return console.error("Only LittleEndian encoding is supported"),!1;if(l!==t.dataType)return console.error("Invalid data type",l,"expecting",t.dataType),!1;if(tp(s,"AppendedData")){var h=tp(s,"AppendedData"),p=h.getAttribute("encoding"),f=ep(s,"DataArray"),m=t.binaryBuffer;"base64"===p&&(m=h.textContent.trim().substr(1));for(var g=[],v=0;v0?0===w[3]?new ArrayBuffer(w[2]*x):new ArrayBuffer(w[2]*(x-1)+w[3]):new ArrayBuffer(0);for(var S=new Uint8Array(D),T={offset:0,uint8:S},I=0;I2&&void 0!==arguments[2]?arguments[2]:{};Object.assign(t,cp,n),Lr.default.obj(e,t),Lr.default.get(e,t,["url","baseURL"]),Lr.default.setGet(e,t,["dataAccessHelper"]),Lr.default.algo(e,t,0,1),lp(e,t)},processDataArray:sp,processFieldData:function(e,t,n,r,i,o,a){if(t){var s={};["Scalars","Vectors","Normals","Tensors","TCoords"].forEach((function(e){var r=t.getAttribute(e);r&&(s[r]=n["set".concat(e)])}));for(var l=t.getElementsByTagName("DataArray"),c=l.length,u=0;u0){var l=n.getElementsByTagName(t)[0].getElementsByTagName("DataArray")[0],c=up.processDataArray(s,l,r,i,o,a),u=c.values,d=c.numberOfComponents;e["get".concat(t)]().setData(u,d)}return s}(n,"Points",s,r,i,o,t.binaryBuffer),c=0;["Verts","Lines","Strips","Polys"].forEach((function(e){c+=function(e,t,n,r,i,o,a){var s=Number(n.getAttribute("NumberOf".concat(t)));if(s>0){var l=up.processCells(s,n.getElementsByTagName(t)[0],r,i,o,a);e["get".concat(t)]().setData(l)}return s}(n,e,s,r,i,o,t.binaryBuffer)})),up.processFieldData(l,s.getElementsByTagName("PointData")[0],n.getPointData(),r,i,o,t.binaryBuffer),up.processFieldData(c,s.getElementsByTagName("CellData")[0],n.getCellData(),r,i,o,t.binaryBuffer),t.output[e]=n},c=0;c2&&void 0!==arguments[2]?arguments[2]:{};Object.assign(t,hp,n),up.extend(e,t,n),dp(e,t)}var fp={newInstance:Lr.default.newInstance(pp,"vtkXMLPolyDataReader"),extend:pp};const mp={ANNOTATED_CUBE:1,AXES:2,CUSTOM:3};class gp extends xi{constructor(e={},t={configuration:{orientationWidget:{enabled:!0,viewportCorner:yd.Corners.BOTTOM_RIGHT,viewportSize:.15,minPixelSize:100,maxPixelSize:300},overlayMarkerType:gp.OVERLAY_MARKER_TYPES.ANNOTATED_CUBE,overlayConfiguration:{[gp.OVERLAY_MARKER_TYPES.ANNOTATED_CUBE]:{faceProperties:{xPlus:{text:"R",faceColor:"#ffff00",faceRotation:90},xMinus:{text:"L",faceColor:"#ffff00",faceRotation:270},yPlus:{text:"P",faceColor:"#00ffff",fontColor:"white",faceRotation:180},yMinus:{text:"A",faceColor:"#00ffff",fontColor:"white"},zPlus:{text:"S"},zMinus:{text:"I"}},defaultStyle:{fontStyle:"bold",fontFamily:"Arial",fontColor:"black",fontSizeScale:e=>e/2,faceColor:"#0000ff",edgeThickness:.1,edgeColor:"black",resolution:400}},[gp.OVERLAY_MARKER_TYPES.AXES]:{},[gp.OVERLAY_MARKER_TYPES.CUSTOM]:{polyDataURL:"https://raw.githubusercontent.com/Slicer/Slicer/80ad0a04dacf134754459557bf2638c63f3d1d1b/Base/Logic/Resources/OrientationMarkers/Human.vtp"}}}}){super(e,t),this.configuration_invalidated=!0,this.onSetToolEnabled=()=>{this.initViewports(),this.configuration_invalidated=!0},this.onSetToolActive=()=>{this.initViewports()},this.orientationMarkers={},this.configuration_invalidated=!0}static{this.CUBE=1}static{this.AXIS=2}static{this.VTPFILE=3}static{this.OVERLAY_MARKER_TYPES=mp}initViewports(){const e=(0,Y.getRenderingEngines)()[0];if(!e)return;let t=e.getViewports();t=fs(t,this.getToolName()),t.forEach((e=>this.addAxisActorInViewport(e)))}async addAxisActorInViewport(e){const t=e.id,n=this.configuration.overlayMarkerType,r=this.configuration.overlayConfiguration[n];if(this.orientationMarkers[t]){const{actor:n,orientationWidget:r}=this.orientationMarkers[t];e.getRenderer().removeActor(n),r.setEnabled(!1)}let i;1===n?i=this.createAnnotationCube(r):2===n?i=$d.newInstance():3===n&&(i=await this.createCustomActor());const o=e.getRenderer(),a=e.getRenderingEngine().offscreenMultiRenderWindow.getRenderWindow(),{enabled:s,viewportCorner:l,viewportSize:c,minPixelSize:u,maxPixelSize:d}=this.configuration.orientationWidget,h=yd.newInstance({actor:i,interactor:a.getInteractor(),parentRenderer:o});h.setEnabled(s),h.setViewportCorner(l),h.setViewportSize(c),h.setMinPixelSize(u),h.setMaxPixelSize(d),h.updateMarkerOrientation(),this.orientationMarkers[t]={orientationWidget:h,actor:i},o.resetCamera(),a.render(),e.getRenderingEngine().render(),this.configuration_invalidated=!1}async createCustomActor(){const e=this.configuration.overlayConfiguration[mp.CUSTOM].polyDataURL,t=await fetch(e),n=await t.arrayBuffer(),r=fp.newInstance();r.parseAsArrayBuffer(n),r.update();const i=Fr.ZP.newInstance();i.shallowCopy(r.getOutputData()),i.getPointData().setActiveScalars("Color");const o=qr.ZP.newInstance();o.setInputData(i),o.setColorModeToDirectScalars();const a=Hr.ZP.newInstance();return a.setMapper(o),a.rotateZ(180),a}createAnnotationCube(e){const t=Pd.newInstance();return t.setDefaultStyle({...e.defaultStyle}),t.setXPlusFaceProperty({...e.faceProperties.xPlus}),t.setXMinusFaceProperty({...e.faceProperties.xMinus}),t.setYPlusFaceProperty({...e.faceProperties.yPlus}),t.setYMinusFaceProperty({...e.faceProperties.yMinus}),t.setZPlusFaceProperty({...e.faceProperties.zPlus}),t.setZMinusFaceProperty({...e.faceProperties.zMinus}),t}async createAnnotatedCubeActor(){const e=Pd.newInstance(),{faceProperties:t,defaultStyle:n}=this.configuration.annotatedCube;return e.setDefaultStyle(n),Object.keys(t).forEach((n=>{const r=`set${n.charAt(0).toUpperCase()+n.slice(1)}FaceProperty`;e[r](t[n])})),e}}gp.toolName="OrientationMarker";const vp=gp;const yp=function(e,t,n={}){const r=[];return e.forEach((e=>{const{data:i}=e,{points:o}=i.handles,{imageData:a,dimensions:s}=t;let l=o;if(i.cachedStats?.projectionPoints){const{projectionPoints:e}=i.cachedStats;l=[].concat(...e)}const c=l.map((e=>Y.utilities.transformWorldToIndex(a,e)));let u=Fo(c,s);n.numSlicesToProject&&!i.cachedStats?.projectionPoints&&(u=Ro(u,n.numSlicesToProject)),r.push(u)})),1===r.length?r[0]:r.reduce(((e,t)=>({iMin:Math.min(e.iMin,t.iMin),jMin:Math.min(e.jMin,t.jMin),kMin:Math.min(e.kMin,t.kMin),iMax:Math.max(e.iMax,t.iMax),jMax:Math.max(e.jMax,t.jMax),kMax:Math.max(e.kMax,t.kMax)})),{iMin:1/0,jMin:1/0,kMin:1/0,iMax:-1/0,jMax:-1/0,kMax:-1/0})};const _p=function(e,t,n,r){const i=e.map((e=>sg(e)));let o;!function(e){const t=[Ju.toolName,Qu.toolName];for(const n of e){const e=n.metadata.toolName;if(!t.includes(e))throw new Error("rectangleROIThresholdVolumeByRange only supports RectangleROIThreshold and RectangleROIStartEndThreshold annotations")}}(i);for(let e=0;e{if(!(Y.utilities.isEqual(n,e[0].dimensions)&&Y.utilities.isEqual(t,e[0].direction)&&Y.utilities.isEqual(i,e[0].spacing)&&Y.utilities.isEqual(r,e[0].origin)))throw new Error("labelmaps must have the same size and shape")}));const r=e[0],i=new(0,r.getScalarData().constructor)(r.getScalarData().length);e.forEach((e=>{const n=e.getScalarData();for(let e=0;e{e.configuration.brushSize=t,e.invalidateBrushCursor()}));const i=r.getViewportsInfo(),o=Object.keys(i).map((e=>i[e]));if(!o.length)return;const{renderingEngineId:a}=o[0],s=r.getViewportIds(),l=(0,Y.getRenderingEngine)(a);Po(l,s)}function Dp(e,t){const n=$m(e);if(void 0===n)return;const r=n._toolInstances;if(!Object.keys(r).length)return;const i=Pa(e,t)[0];return i?i.configuration.brushSize:void 0}function Sp(e,t){const n=$m(e);if(void 0===n)return;Pa(e).forEach((e=>{e.configuration.strategySpecificConfiguration.THRESHOLD_INSIDE_CIRCLE.threshold=t}));const r=n.getViewportsInfo();if(!r.length)return;const{renderingEngineId:i}=r[0],o=n.getViewportIds(),a=(0,Y.getRenderingEngine)(i);Po(a,o)}function Tp(e){const t=$m(e);if(void 0===t)return;const n=t._toolInstances;if(!Object.keys(n).length)return;const r=Pa(e)[0];return r?r.configuration.strategySpecificConfiguration.THRESHOLD_INSIDE_CIRCLE.threshold:void 0}const Ip=function(e,t,n,r){const i=e.getScalarData(),{baseVolumeIdx:o,volumeInfoList:a}=La(e,n);return a.forEach((e=>{const{volumeSize:n}=e;n===i.length?function(e,t,n){const{referenceValues:r,lower:i,upper:o}=n;for(let n=0;n=i&&a<=o?t:0}}(i,t,e):function(e,t,n,r,i,o){const{imageData:a,lower:s,upper:l,dimensions:c}=n;let u,d,h;for(let n=0;n{u+=1,e>=h.lower&&e<=h.upper&&(d+=1)};u=0,d=0,h={lower:s,upper:l};let m=!1;Lo(a,(()=>!0),f,p),m=0===o?d>0:d===u,e[n]=m?t:0}}(i,t,e,a,o,r)})),Kn(e.volumeId),e};function Ap(e){let t="";const n=e[0]<0?"R":"L",r=e[1]<0?"A":"P",i=e[2]<0?"F":"H",o=[Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2])],a=1e-4;for(let e=0;e<3;e++)if(o[0]>a&&o[0]>o[1]&&o[0]>o[2])t+=n,o[0]=0;else if(o[1]>a&&o[1]>o[0]&&o[1]>o[2])t+=r,o[1]=0;else if(o[2]>a&&o[2]>o[0]&&o[2]>o[1])t+=i,o[2]=0;else if(o[0]>a&&o[1]>a&&o[0]===o[1])t+=n+r,o[0]=0,o[1]=0;else if(o[0]>a&&o[2]>a&&o[0]===o[2])t+=n+i,o[0]=0,o[2]=0;else{if(!(o[1]>a&&o[2]>a&&o[1]===o[2]))break;t+=r+i,o[1]=0,o[2]=0}return t}function Np(e){let t=e.replace("H","f");return t=t.replace("F","h"),t=t.replace("R","l"),t=t.replace("L","r"),t=t.replace("A","p"),t=t.replace("P","a"),t=t.toUpperCase(),t}var Op;!function(e){e.CLIP_STOPPED="CORNERSTONE_CINE_TOOL_STOPPED",e.CLIP_STARTED="CORNERSTONE_CINE_TOOL_STARTED"}(Op||(Op={}));const Pp=Op,kp={};function Mp(e,t){const n=(0,Y.getEnabledElement)(e),{viewportId:r}=n;kp[r]=t}function Lp(e){const t=(0,Y.getEnabledElement)(e),{viewportId:n}=t;return kp[n]}const{ViewportStatus:Rp}=Y.Enums,{triggerEvent:Fp}=Y.utilities,Up=!0,Bp=!0,jp=new Map;function Vp(e,t){let n,r;if(void 0===e)throw new Error("playClip: element must not be undefined");const i=(0,Y.getEnabledElement)(e);if(!i)throw new Error("playClip: element must be a valid Cornerstone enabled element");t.dynamicCineEnabled=t.dynamicCineEnabled??!0;const{viewport:o}=i,a=Hp(o),s=function(e,t){if(e instanceof Y.StackViewport)return function(e,t){const n=e.getImageIds();return{get numScrollSteps(){return n.length},get currentStepIndex(){return e.getTargetImageIdIndex()},get frameTimeVectorEnabled(){return!0},waitForRenderedCount:0,scroll(n){this.waitForRenderedCount<=t&&e.viewportStatus!==Rp.RENDERED?this.waitForRenderedCount++:(this.waitForRenderedCount=0,ko(e,{delta:n,debounceLoading:Up}))}}}(e,t.waitForRendered??30);if(e instanceof Y.VolumeViewport){const n=Hp(e);return t.dynamicCineEnabled&&n?.isDynamicVolume()?function(e){return{get numScrollSteps(){return e.numTimePoints},get currentStepIndex(){return e.timePointIndex},get frameTimeVectorEnabled(){return!1},scroll(t){e.timePointIndex+=t}}}(n):function(e,t){const{volumeId:n}=t,r={viewPlaneNormal:Ci.R3.create(),scrollInfo:null},i=()=>{const t=e.getCamera();if(!r.scrollInfo||!Ci.R3.equals(t.viewPlaneNormal,r.viewPlaneNormal)){const i=Y.utilities.getVolumeViewportScrollInfo(e,n);r.viewPlaneNormal=t.viewPlaneNormal,r.scrollInfo=i}return r.scrollInfo};return{get numScrollSteps(){return i().numScrollSteps},get currentStepIndex(){return i().currentStepIndex},get frameTimeVectorEnabled(){const n=e.getCamera(),r=t.direction.slice(6,9).map((e=>-e)),i=Ci.R3.dot(r,n.viewPlaneNormal);return Ci.DV.equals(i,1)},scroll(t){i().currentStepIndex+=t,ko(e,{delta:t})}}}(e,n)}throw new Error("Unknown viewport type")}(o,t);let l=Lp(e);const c=t.dynamicCineEnabled&&a?.isDynamicVolume();if(c&&Gp(e),l?zp(e,c):(l={intervalId:void 0,framesPerSecond:30,lastFrameTimeStamp:void 0,ignoreFrameTimeVector:!1,usingFrameTimeVector:!1,frameTimeVector:t.frameTimeVector??void 0,speed:t.frameTimeVectorSpeedMultiplier??1,reverse:t.reverse??!1,loop:t.loop??!0},Mp(e,l)),l.dynamicCineEnabled=t.dynamicCineEnabled,(t.framesPerSecond<0||t.framesPerSecond>0)&&(l.framesPerSecond=Number(t.framesPerSecond),l.reverse=l.framesPerSecond<0,l.ignoreFrameTimeVector=!0),!0!==l.ignoreFrameTimeVector&&l.frameTimeVector&&l.frameTimeVector.length===s.numScrollSteps&&s.frameTimeVectorEnabled){const{timeouts:e,isTimeVarying:t}=function(e,t){let n,r,i,o=0;const a=e.length,s=[];let l=!1;("number"!=typeof t||t<=0)&&(t=1);for(n=1;n0&&(i=l?o/s.length|0:s[0],s.push(i));return{timeouts:s,isTimeVarying:l}}(l.frameTimeVector,l.speed);n=e,r=t}const u=()=>{const{numScrollSteps:t,currentStepIndex:n}=s;let r=n+(l.reverse?-1:1);if(!Bp&&(r<0||r>=t)){zp(e,c);const t={element:e};return void Fp(e,Pp.CLIP_STOPPED,t)}r>=t?r=0:r<0&&(r=t-1);const i=r-n;i&&s.scroll(i)};c&&jp.set(a.volumeId,e),n&&n.length>0&&r?(l.usingFrameTimeVector=!0,l.intervalId=window.setTimeout((function e(){l.intervalId=window.setTimeout(e,n[s.currentStepIndex]),u()}),0)):(l.usingFrameTimeVector=!1,l.intervalId=window.setInterval(u,1e3/Math.abs(l.framesPerSecond)));const d={element:e};Fp(e,Pp.CLIP_STARTED,d)}function Wp(e){zp(e,!0)}function zp(e,t){const n=(0,Y.getEnabledElement)(e);if(!n)return;const{viewport:r}=n,i=Lp(r.element);i&&function(e){const t=e.intervalId;void 0!==t&&(e.intervalId=void 0,e.usingFrameTimeVector?clearTimeout(t):clearInterval(t))}(i),t&&r instanceof Y.BaseVolumeViewport&&Gp(e)}function Gp(e){const{viewport:t}=(0,Y.getEnabledElement)(e),n=Hp(t);if(n?.isDynamicVolume()){const t=jp.get(n.volumeId);jp.delete(n.volumeId),t&&t!==e&&Wp(t)}}function Hp(e){const t=function(e){return e.getActors().map((e=>Y.cache.getVolume(e.uid))).filter((e=>!!e))}(e);return t.find((e=>e.isDynamicVolume()))??t[0]}function qp(e,t,n){if(function(e,t,n){if(!t?.data?.polyline||n<=0)return!0;if(!e.viewport)return!0;const{renderingEngineId:r,viewportId:i,FrameOfReferenceUID:o}=e,a=Cm(i,r);if(t.metadata.FrameOfReferenceUID!==o)return!0;if(!a)return!0;const s=a.getToolInstance(t.metadata.toolName);return!(s instanceof _u)||s.isDrawing||s.isEditingOpen||s.isEditingClosed}(e,t,n))return!1;const{viewport:r}=e,i=t.data.polyline.map(r.worldToCanvas),o=Yl(i,0,i.length,n);return o!==i&&(t.data.polyline=o.map(r.canvasToWorld),!0)}const Kp={interpolateAnnotation:qp},Xp={};function $p(e,t){const n=(0,Y.getEnabledElement)(e),{viewportId:r}=n;Xp[r]=t}function Jp(e){const t=(0,Y.getEnabledElement)(e),{viewportId:n}=t;return Xp[n]}const Yp=Y.Enums.RequestType.Prefetch,Zp=0;function Qp(e,t){e=Math.round(e)||0;const n=[];let r=(t=Math.round(t)||0)-e+1;if(r<=0)return n;for(;r--;)n[r]=t--;return n}function ef(e){const t=(0,Y.getEnabledElement)(e);if(!t)return null;const{viewport:n}=t;if(!(n instanceof Y.StackViewport))throw new Error("stackPrefetch: element must be a StackViewport, VolumeViewport stackPrefetch not yet implemented");return{currentImageIdIndex:n.getCurrentImageIdIndex(),imageIds:n.getImageIds()}}function tf(e){return function(t){const n=t.detail;let r;try{r=ef(e)}catch(e){return}if(!r||!r.imageIds||0===r.imageIds.length)return;const i=r.imageIds.indexOf(n.imageId);if(i<0)return;const o=Jp(e);o&&o.data&&o.data.length&&o.indicesToRequest.push(i)}}const nf=e=>{const t=new Set(e.imageIds);return e=>e.type!==Yp||!t.has(e.additionalDetails.imageId)};let rf,of={maxImagesToPrefetch:1/0,preserveExistingPool:!0};const af=10;function sf(e){const t=Jp(e);if(!t)return;const n=t||{},r=ef(e);if(!r?.imageIds?.length)return void console.warn("CornerstoneTools.stackPrefetch: No images in stack.");const{currentImageIdIndex:i}=r;if(n.enabled&&=n.indicesToRequest?.length,!1===n.enabled)return;function o(e){const t=n.indicesToRequest.indexOf(e);t>-1&&n.indicesToRequest.splice(t,1)}t.indicesToRequest.sort(((e,t)=>e-t));if(n.indicesToRequest.slice().forEach((function(e){const t=r.imageIds[e];if(!t)return;(Math.abs(i-e)<6?Y.cache.getImageLoadObject(t):Y.cache.isLoaded(t))&&o(e)})),!n.indicesToRequest.length)return;of.preserveExistingPool||Y.imageLoadPoolManager.clearRequestStack(Yp);const a=function(e,t){let n=0,r=e.length-1;return e.forEach(((e,i)=>{et&&(r=Math.min(i,r))})),{low:n,high:r}}(n.indicesToRequest,r.currentImageIdIndex);let s,l;let c=a.low,u=a.high;const d=[];for(;c>=0||uof.maxImagesToPrefetch)&&c>=0,i=!(n.indicesToRequest[u]-e>of.maxImagesToPrefetch)&&uY.imageLoader.loadAndCacheImage(e,t),{useNorm16Texture:p}=(0,Y.getConfiguration)().rendering;d.forEach((e=>{const t={targetBuffer:{type:p?void 0:"Float32Array"},preScale:{enabled:!0},requestType:Yp};Y.imageLoadPoolManager.addRequest(h.bind(null,e,t),Yp,{imageId:e},Zp)}))}function lf(e){clearTimeout(rf),rf=setTimeout((function(){const t=e.target;try{sf(t)}catch(e){return}}),af)}const cf={enable:function(e){const t=ef(e);if(!t||!t.imageIds||0===t.imageIds.length)return void console.warn("CornerstoneTools.stackPrefetch: No images in stack.");const n={indicesToRequest:Qp(0,t.imageIds.length-1),enabled:!0,direction:1},r=n.indicesToRequest.indexOf(t.currentImageIdIndex);n.indicesToRequest.splice(r,1),$p(e,n),sf(e),e.removeEventListener(Y.Enums.Events.STACK_NEW_IMAGE,lf),e.addEventListener(Y.Enums.Events.STACK_NEW_IMAGE,lf);const i=tf(e);Y.eventTarget.removeEventListener(Y.Enums.Events.IMAGE_CACHE_IMAGE_REMOVED,i),Y.eventTarget.addEventListener(Y.Enums.Events.IMAGE_CACHE_IMAGE_REMOVED,i)},disable:function(e){clearTimeout(rf),e.removeEventListener(Y.Enums.Events.STACK_NEW_IMAGE,lf);const t=tf(e);Y.eventTarget.removeEventListener(Y.Enums.Events.IMAGE_CACHE_IMAGE_REMOVED,t);const n=Jp(e);n&&n.indicesToRequest.length&&(n.enabled=!1,Y.imageLoadPoolManager.clearRequestStack(Yp))},getConfiguration:function(){return of},setConfiguration:function(e){of=e}};let uf,df={maxImagesToPrefetch:1/0,minBefore:2,maxAfter:2,directionExtraImages:10,preserveExistingPool:!1};const hf=5;function pf(e){const t=ef(e);if(!t?.imageIds?.length)return void console.warn("CornerstoneTools.stackPrefetch: No images in stack.");const n=Jp(e);if(!n)return;const r=n||{};if(r.enabled&&=r.indicesToRequest?.length,!1===r.enabled)return;function i(e){const t=r.indicesToRequest.indexOf(e);t>-1&&r.indicesToRequest.splice(t,1)}const o=r.indicesToRequest.slice(),{currentImageIdIndex:a}=t;if(o.forEach((e=>{const n=t.imageIds[e];if(!n)return;(Math.abs(a-e)<6?Y.cache.getImageLoadObject(n):Y.cache.isLoaded(n))&&i(e)})),!r.indicesToRequest.length)return;df.preserveExistingPool||Y.imageLoadPoolManager.filterRequests(nf(t));const s=(n,o)=>Y.imageLoader.loadAndCacheImage(n,o).then((()=>function(n){i(t.imageIds.indexOf(n));const o=Y.cache.getCachedImageBasedOnImageURI(n),{stats:a}=r,s=o?.image?.decodeTimeInMS||0;if(s){a.imageIds.set(n,s),a.decodeTimeInMS+=s;const e=o?.image?.loadTimeInMS||0;a.loadTimeInMS+=e}if(!r.indicesToRequest.length&&o?.sizeInBytes){const{sizeInBytes:t}=o,n=Y.cache.getMaxCacheSize()/4/t;if(r.cacheFill){if(a.imageIds.size){a.fillTime=Date.now()-a.start;const{size:e}=a.imageIds;a.fillSize=e,console.log("Done cache fill",a.fillTime,"ms",e,"items","average total time",jo(a.fillTime/e),"ms","average load",jo(a.loadTimeInMS/e),"ms","average decode",jo(a.decodeTimeInMS/e),"ms")}}else a.initialTime=Date.now()-a.start,a.initialSize=a.imageIds.size,mf(e,n),pf(e)}}(n))),{useNorm16Texture:l}=(0,Y.getConfiguration)().rendering;o.forEach((e=>{const n=t.imageIds[e],r={targetBuffer:{type:l?void 0:"Float32Array"},preScale:{enabled:!0},requestType:Yp};Y.imageLoadPoolManager.addRequest(s.bind(null,n,r),Yp,{imageId:n},Zp)}))}function ff(e){clearTimeout(uf),uf=setTimeout((function(){const t=e.target;try{mf(t),pf(t)}catch(e){return}}),hf)}const mf=(e,t)=>{const n=ef(e);if(!n||!n.imageIds||0===n.imageIds.length)return void console.warn("CornerstoneTools.stackPrefetch: No images in stack.");const{currentImageIdIndex:r}=n;let{maxAfter:i=2,minBefore:o=2}=df;const{directionExtraImages:a=10}=df,s=Jp(e)||{indicesToRequest:[],currentImageIdIndex:r,stackCount:0,enabled:!0,direction:1,stats:{start:Date.now(),imageIds:new Map,decodeTimeInMS:0,loadTimeInMS:0,totalBytes:0}},l=r-s.currentImageIdIndex;if(s.direction=(e=>e<0?-1:1)(l),s.currentImageIdIndex=r,s.enabled=!0,s.stackCount<100&&(s.stackCount+=a),Math.abs(l)>i||!l)if(s.stackCount=0,t){const e=r/n.imageIds.length;o=Math.ceil(t*e),i=Math.ceil(t*(1-e)),s.cacheFill=!0}else s.cacheFill=!1;else l<0?(o+=s.stackCount,i=0):(i+=s.stackCount,o=0);const c=Math.max(0,r-o),u=Math.min(n.imageIds.length-1,r+i),d=[];for(let e=r+1;e<=u;e++)d.push(e);for(let e=r-1;e>=c;e--)d.push(e);s.indicesToRequest=d,$p(e,s)};const gf={enable:e=>{const t=ef(e);if(!t||!t.imageIds||0===t.imageIds.length)return void console.warn("CornerstoneTools.stackPrefetch: No images in stack.");mf(e),pf(e),e.removeEventListener(Y.Enums.Events.STACK_NEW_IMAGE,ff),e.addEventListener(Y.Enums.Events.STACK_NEW_IMAGE,ff);const n=tf(e);Y.eventTarget.removeEventListener(Y.Enums.Events.IMAGE_CACHE_IMAGE_REMOVED,n),Y.eventTarget.addEventListener(Y.Enums.Events.IMAGE_CACHE_IMAGE_REMOVED,n)},disable:function(e){clearTimeout(uf),e.removeEventListener(Y.Enums.Events.STACK_NEW_IMAGE,ff);const t=tf(e);Y.eventTarget.removeEventListener(Y.Enums.Events.IMAGE_CACHE_IMAGE_REMOVED,t);const n=Jp(e);n&&n.data.length&&(n.enabled=!1)},getConfiguration:function(){return df},setConfiguration:function(e){df=e}};const vf=function(e,t){const n=t.frameNumbers||[...Array(e.numTimePoints).keys()];if(!t.maskVolumeId&&!t.imageCoordinate)throw new Error("No ROI provided");if(t.maskVolumeId&&t.imageCoordinate)throw new Error("Please provide only one ROI");if(t.maskVolumeId){const r=Y.cache.getVolume(t.maskVolumeId).getScalarData(),i=[];for(let e=0,t=r.length;e{const i=r[e];o.push(i[t[n]])})),i.push(o)}return i}(n,i,e);return o}if(t.imageCoordinate){const r=function(e,t,n){const{dimensions:r,imageData:i}=n,o=i.worldToIndex(t);if(o[0]=Math.floor(o[0]),o[1]=Math.floor(o[1]),o[2]=Math.floor(o[2]),!Y.utilities.indexWithinDimensions(o,r))throw new Error("outside bounds");const a=r[0],s=r[0]*r[1],l=n.getScalarDataArrays(),c=[];return e.forEach((e=>{const t=l[e],n=o[2]*s+o[1]*a+o[0];c.push(t[n])})),c}(n,t.imageCoordinate,e);return r}};const yf=function(e,t,n){const r=n||[...Array(e.numTimePoints).keys()],i=r.length;if(r.length<=1)throw new Error("Please provide two or more time points");const o=e.getScalarDataArrays(),a=o[0].length,s=new Float32Array(a);if(t===Y.Enums.DynamicOperatorType.SUM){for(let e=0;e2)throw new Error("Please provide only 2 time points for subtraction.");for(let e=0;e{const t=e.getViewports().map((e=>e.id));Po(e,t)}))};const bf=function(e){const{viewportId:t,renderingEngineId:n}=e.detail,r=(0,Y.getRenderingEngine)(n);Po(r,[t])},Ef=function(e){Qi(e.detail.element)},wf={enable:function(e){e.addEventListener(Y.Enums.Events.IMAGE_RENDERED,Ef)},disable:function(e){e.removeEventListener(Y.Enums.Events.IMAGE_RENDERED,Ef)}},{Active:xf}=Z;function Cf(e,t,n){if(He.isInteractingWithTool)return!1;const{renderingEngineId:r,viewportId:i}=n.detail,o=Cm(i,r);if(!o)return!1;let a;const s=Object.keys(o.toolOptions);for(let e=0;e{for(const a of r){if(a.isLocked||!a.isVisible)continue;const r=t.getHandleNearImagePoint(e,a,n,i);if(r){o.push({tool:t,annotation:a,handle:r});break}}})),o}function If(e,t){const n=[];for(let r=0;r0&&n.push({tool:i,annotations:o}))}return n}function Af(e,t,n,r="mouse"){const i="touch"===r?36:6,o=[];return t.forEach((({tool:t,annotations:a})=>{for(const s of a){if(s.isLocked||!s.isVisible)continue;if(t.isPointNearTool(e,s,n,i,r)){o.push({tool:t,annotation:s});break}}})),o}const Nf=e=>e.shiftKey?e.ctrlKey?$.ShiftCtrl:e.altKey?$.ShiftAlt:e.metaKey?$.ShiftMeta:$.Shift:e.ctrlKey?e.altKey?$.CtrlAlt:e.metaKey?$.CtrlMeta:$.Ctrl:e.altKey?e.metaKey&&$.AltMeta||$.Alt:e.metaKey?$.Meta:void 0,{Active:Of}=Z;function Pf(e){const{renderingEngineId:t,viewportId:n}=e.detail,r=e.detail.event,i=Nf(r)||On.getModifierKey(),o=Cm(n,t);if(!o)return null;const a=Object.keys(o.toolOptions),s=o.getDefaultMousePrimary();for(let e=0;ee.mouseButton===(r?r.buttons:s)&&e.modifierKey===i));if(n.mode===Of&&l)return o.getToolInstance(t)}}function kf(e,t,n){const{renderingEngineId:r,viewportId:i}=e.detail,o=Cm(i,r);if(!o)return[];const a=[],s=Object.keys(o.toolOptions);for(let e=0;ee.mouseButton===n));if(t.includes(i.mode)&&(!n||l)){const e=o.getToolInstance(r);a.push(e)}}return a}const{Active:Mf,Passive:Lf}=Z;function Rf(e){if(He.isInteractingWithTool)return;const t=Pf(e);if(t&&"function"==typeof t.preMouseDownCallback){if(t.preMouseDownCallback(e))return}const n=1===e.detail.event.buttons,r=[...kf(e,[Mf],e.detail.event.buttons)||[],...(n?kf(e,[Lf]):void 0)||[]],i=e.detail,{element:o}=i,a=If(o,r),s=i.currentPoints.canvas,l=Tf(o,a,s,"mouse"),c=!!e.detail.event.shiftKey;if(l.length>0){const{tool:t,annotation:n,handle:r}=Ff(l);return Uf(n.annotationUID,c),void t.handleSelectedCallback(e,n,r,"Mouse")}const u=Af(o,a,s,"mouse");if(u.length>0){const{tool:t,annotation:n}=Ff(u);return Uf(n.annotationUID,c),void t.toolSelectedCallback(e,n,"Mouse")}if(t&&"function"==typeof t.postMouseDownCallback){if(t.postMouseDownCallback(e))return}}function Ff(e){return e.length>1&&e.find((e=>!he(e.annotation)&&ke(e.annotation.annotationUID)))||e[0]}function Uf(e,t=!1){if(t)if(De(e))Ee(e,!1);else{Ee(e,!0,!0)}else{Ee(e,!0,!1)}}function Bf(e){if(He.isInteractingWithTool)return;const t=Pf(e);if(t&&!He.isMultiPartToolActive&&t.addNewAnnotation){Ee(t.addNewAnnotation(e,"mouse").annotationUID)}}function jf(e){if(He.isInteractingWithTool)return;const t=Pf(e);!t||"function"!=typeof t.mouseDragCallback||t.mouseDragCallback(e)}const{Active:Vf,Passive:Wf}=Z;function zf(e){if(He.isInteractingWithTool||He.isMultiPartToolActive)return;const t=kf(e,[Vf,Wf]),n=e.detail,{element:r}=n,i=If(r,t),o=t.filter((e=>!i.some((t=>t.tool.getToolName()===e.getToolName()))));let a=!1;for(const{tool:t,annotations:n}of i)"function"==typeof t.mouseMoveCallback&&(a=t.mouseMoveCallback(e,n)||a);o.forEach((t=>{"function"==typeof t.mouseMoveCallback&&t.mouseMoveCallback(e)})),!0===a&&Qi(r)}const Gf=Cf.bind(null,"Mouse","mouseUpCallback"),Hf=Cf.bind(null,"MouseWheel","mouseWheelCallback"),qf={enable:function(e){e.addEventListener(ne.MOUSE_CLICK,Df),e.addEventListener(ne.MOUSE_DOWN,Rf),e.addEventListener(ne.MOUSE_DOWN_ACTIVATE,Bf),e.addEventListener(ne.MOUSE_DOUBLE_CLICK,Sf),e.addEventListener(ne.MOUSE_DRAG,jf),e.addEventListener(ne.MOUSE_MOVE,zf),e.addEventListener(ne.MOUSE_UP,Gf),e.addEventListener(ne.MOUSE_WHEEL,Hf)},disable:function(e){e.removeEventListener(ne.MOUSE_CLICK,Df),e.removeEventListener(ne.MOUSE_DOWN,Rf),e.removeEventListener(ne.MOUSE_DOWN_ACTIVATE,Bf),e.removeEventListener(ne.MOUSE_DOUBLE_CLICK,Sf),e.removeEventListener(ne.MOUSE_DRAG,jf),e.removeEventListener(ne.MOUSE_MOVE,zf),e.removeEventListener(ne.MOUSE_UP,Gf),e.removeEventListener(ne.MOUSE_WHEEL,Hf)}},{Active:Kf}=Z;function Xf(e){const{renderingEngineId:t,viewportId:n}=e.detail,r=at.mouseButton,i=On.getModifierKey(),o=Cm(n,t);if(!o)return null;const a=Object.keys(o.toolOptions),s=o.getDefaultMousePrimary();for(let e=0;ee.mouseButton===(r??s)&&e.modifierKey===i));if(n.mode===Kf&&l)return o.getToolInstance(t)}}function $f(e){const t=Xf(e);if(!t)return;const{renderingEngineId:n,viewportId:r}=e.detail,i=Cm(r,n),o=t.getToolName();Object.keys(i.toolOptions).includes(o)&&i.setViewportsCursorByToolName(o)}function Jf(e){const t=Xf(e);if(!t)return;const{renderingEngineId:n,viewportId:r}=e.detail,i=Cm(r,n);In();const o=t.getToolName();Object.keys(i.toolOptions).includes(o)&&i.setViewportsCursorByToolName(o)}const Yf={enable:function(e){e.addEventListener(ne.KEY_DOWN,$f),e.addEventListener(ne.KEY_UP,Jf)},disable:function(e){e.removeEventListener(ne.KEY_DOWN,$f),e.removeEventListener(ne.KEY_UP,Jf)}},{Active:Zf,Passive:Qf,Enabled:em}=Z,tm=function(e){kf(e,[Zf,Qf,em]).forEach((t=>{t.onCameraModified&&t.onCameraModified(e)}))},nm={enable:function(e){e.addEventListener(Y.Enums.Events.CAMERA_MODIFIED,tm)},disable:function(e){e.removeEventListener(Y.Enums.Events.CAMERA_MODIFIED,tm)}},{Active:rm,Passive:im,Enabled:om}=Z,am=function(e){kf(e,[rm,im,om]).forEach((t=>{t.onImageSpacingCalibrated&&t.onImageSpacingCalibrated(e)}))},sm={enable:function(e){e.addEventListener(Y.Enums.Events.IMAGE_SPACING_CALIBRATED,am)},disable:function(e){e.removeEventListener(Y.Enums.Events.IMAGE_SPACING_CALIBRATED,am)}},{Active:lm}=Z;function cm(e){const{renderingEngineId:t,viewportId:n}=e.detail,r=e.detail.event,i=Cm(n,t);if(!i)return null;const o=Object.keys(i.toolOptions),a=Object.keys(r.touches).length,s=Nf(r)||On.getModifierKey(),l=i.getDefaultMousePrimary();for(let e=0;e(e.numTouchPoints===a||1===a&&e.mouseButton===l)&&e.modifierKey===s));if(n.mode===lm&&r)return i.getToolInstance(t)}}function um(e,t,n){const{renderingEngineId:r,viewportId:i}=e.detail,o=Cm(i,r);if(!o)return[];const a=[],s=Object.keys(o.toolOptions);for(let e=0;ee.numTouchPoints===n));if(t.includes(i.mode)&&(!n||l)){const e=o.getToolInstance(r);a.push(e)}}return a}const{Active:dm,Passive:hm}=Z;function pm(e){if(He.isInteractingWithTool)return;const t=cm(e);if(t&&"function"==typeof t.preTouchStartCallback){if(t.preTouchStartCallback(e))return}const n=1===Object.keys(e.detail.event.touches).length,r=[...um(e,[dm],Object.keys(e.detail.event.touches).length)||[],...(n?um(e,[hm]):void 0)||[],t],i=e.detail,{element:o}=i,a=If(o,r),s=i.currentPoints.canvas,l=Tf(o,a,s,"touch");if(l.length>0){const{tool:t,annotation:n,handle:r}=fm(l);return mm(n.annotationUID,false),void t.handleSelectedCallback(e,n,r,"Touch")}const c=Af(o,a,s,"touch");if(c.length>0){const{tool:t,annotation:n}=fm(c);return mm(n.annotationUID,false),void t.toolSelectedCallback(e,n,"Touch")}if(t&&"function"==typeof t.postTouchStartCallback){if(t.postTouchStartCallback(e))return}}function fm(e){return e.length>1&&e.find((e=>!he(e.annotation)&&ke(e.annotation.annotationUID)))||e[0]}function mm(e,t=!1){if(t)if(De(e))Ee(e,!1);else{Ee(e,!0,!0)}else{Ee(e,!0,!1)}}function gm(e){if(He.isInteractingWithTool)return;const t=cm(e);if(t&&!He.isMultiPartToolActive&&t.addNewAnnotation){Ee(t.addNewAnnotation(e,"touch").annotationUID)}}function vm(e){if(He.isInteractingWithTool)return;const t=cm(e);!t||"function"!=typeof t.touchDragCallback||t.touchDragCallback(e)}const ym=Cf.bind(null,"Touch","touchEndCallback"),_m=Cf.bind(null,"Touch","touchTapCallback"),bm=Cf.bind(null,"Touch","touchPressCallback"),Em={enable:function(e){e.addEventListener(ne.TOUCH_START,pm),e.addEventListener(ne.TOUCH_START_ACTIVATE,gm),e.addEventListener(ne.TOUCH_DRAG,vm),e.addEventListener(ne.TOUCH_END,ym),e.addEventListener(ne.TOUCH_TAP,_m),e.addEventListener(ne.TOUCH_PRESS,bm)},disable:function(e){e.removeEventListener(ne.TOUCH_START,pm),e.removeEventListener(ne.TOUCH_START_ACTIVATE,gm),e.removeEventListener(ne.TOUCH_DRAG,vm),e.removeEventListener(ne.TOUCH_END,ym),e.removeEventListener(ne.TOUCH_PRESS,bm)}};function wm(e){const{element:t,viewportId:n}=e.detail,r=function(e){const t="http://www.w3.org/2000/svg",n=document.createElementNS(t,"svg"),r=`svg-layer-${e}`;n.classList.add("svg-layer"),n.setAttribute("id",r),n.setAttribute("xmlns","http://www.w3.org/2000/svg"),n.style.width="100%",n.style.height="100%",n.style.pointerEvents="none",n.style.position="absolute";const i=document.createElementNS(t,"defs"),o=document.createElementNS(t,"filter"),a=document.createElementNS(t,"feOffset"),s=document.createElementNS(t,"feColorMatrix"),l=document.createElementNS(t,"feBlend");return o.setAttribute("id",`shadow-${r}`),o.setAttribute("filterUnits","userSpaceOnUse"),a.setAttribute("result","offOut"),a.setAttribute("in","SourceGraphic"),a.setAttribute("dx","0.5"),a.setAttribute("dy","0.5"),s.setAttribute("result","matrixOut"),s.setAttribute("in","offOut"),s.setAttribute("in2","matrix"),s.setAttribute("values","0.2 0 0 0 0 0 0.2 0 0 0 0 0 0.2 0 0 0 0 0 1 0"),l.setAttribute("in","SourceGraphic"),l.setAttribute("in2","matrixOut"),l.setAttribute("mode","normal"),o.appendChild(a),o.appendChild(s),o.appendChild(l),i.appendChild(o),n.appendChild(i),n}(n);var i;!function(e){const{viewportUid:t,renderingEngineUid:n}=e.dataset,r=`${t}:${n}`;He.svgNodeCache[r]={}}(t),i=r,t.querySelector("div.viewport-element").appendChild(i),Zi.addViewportElement(n,t),xt.enable(t),wn.enable(t),gn.enable(t),On.enable(t),wf.enable(t),nm.enable(t),sm.enable(t),qf.enable(t),Yf.enable(t),Em.enable(t),He.enabledElements.push(t)}const xm=function(e,t){const n=[];if(!t&&!e)throw new Error("At least one of renderingEngineId or viewportId should be given");for(let r=0;rn.viewportsInfo.some((n=>n.renderingEngineId===t&&(!n.viewportId||n.viewportId===e)))));if(n.length){if(n.length>1)throw new Error(`Multiple tool groups found for renderingEngineId: ${t} and viewportId: ${e}. You should only\n have one tool group per viewport in a renderingEngine.`);return n[0]}},Dm="viewport-element";const Sm=e=>{const t=(0,Y.getEnabledElement)(e);xm(t.viewportId,t.renderingEngineId).forEach((e=>{e.remove(t)}))},Tm=e=>{const{renderingEngineId:t,viewportId:n}=(0,Y.getEnabledElement)(e),r=Cm(n,t);r&&r.removeViewports(t,n)};const Im=function(e){const t=He.enabledElements.findIndex((t=>t===e));t>-1&&He.enabledElements.splice(t,1)},Am=function(e){const{element:t,viewportId:n}=e.detail;!function(e){const{viewportUid:t,renderingEngineUid:n}=e.dataset,r=`${t}:${n}`;delete He.svgNodeCache[r]}(t),function(e){const t=e.querySelector(`div.${Dm}`),n=t.querySelector("svg");n&&t.removeChild(n)}(t),Zi.removeViewportElement(n,t),xt.disable(t),wn.disable(t),gn.disable(t),On.disable(t),wf.disable(t),nm.disable(t),sm.disable(t),qf.disable(t),Yf.disable(t),Em.disable(t),Sm(t),Tm(t),Im(t)};function Nm(e){const t=If(e,Xi(e,[Z.Active,Z.Passive]));for(const{tool:n}of t){const t=n.cancel(e);if(t)return t}}function Om(e,t){return e.findIndex((e=>t.renderingEngineId===e.renderingEngineId&&t.viewportId===e.viewportId))}function Pm(e,t){return e.some((e=>e.renderingEngineId===t.renderingEngineId&&e.viewportId===t.viewportId))}const km=class{constructor(e,t,n,r){this._viewportOptions={},this._onEvent=e=>{if(!0===this._ignoreFiredEvents)return;if(!this._targetViewports.length)return;const t=(0,Y.getEnabledElement)(e.currentTarget);if(!t)return;const{renderingEngineId:n,viewportId:r}=t;this._sourceViewports.find((e=>e.viewportId===r))&&this.fireEvent({renderingEngineId:n,viewportId:r},e)},this._enabled=!0,this._eventName=t,this._eventHandler=n,this._ignoreFiredEvents=!1,this._sourceViewports=[],this._targetViewports=[],this._options=r||{},this.id=e}isDisabled(){return!this._enabled||!this._hasSourceElements()}setOptions(e,t={}){this._viewportOptions[e]=t}getOptions(e){return this._viewportOptions[e]}add(e){this.addTarget(e),this.addSource(e)}addSource(e){if(Pm(this._sourceViewports,e))return;const{renderingEngineId:t,viewportId:n}=e,{element:r}=(0,Y.getRenderingEngine)(t).getViewport(n);r.addEventListener(this._eventName,this._onEvent.bind(this)),this._updateDisableHandlers(),this._sourceViewports.push(e)}addTarget(e){Pm(this._targetViewports,e)||(this._targetViewports.push(e),this._updateDisableHandlers())}getSourceViewports(){return this._sourceViewports}getTargetViewports(){return this._targetViewports}destroy(){this._sourceViewports.forEach((e=>this.removeSource(e))),this._targetViewports.forEach((e=>this.removeTarget(e)))}remove(e){this.removeTarget(e),this.removeSource(e)}removeSource(e){const t=Om(this._sourceViewports,e);if(-1===t)return;const n=function(e){const t=(0,Y.getRenderingEngine)(e.renderingEngineId);if(!t)throw new Error(`No RenderingEngine for Id: ${e.renderingEngineId}`);return t.getViewport(e.viewportId).element}(e);this._sourceViewports.splice(t,1),n.removeEventListener(this._eventName,this._eventHandler),this._updateDisableHandlers()}removeTarget(e){const t=Om(this._targetViewports,e);-1!==t&&(this._targetViewports.splice(t,1),this._updateDisableHandlers())}hasSourceViewport(e,t){return Pm(this._sourceViewports,{renderingEngineId:e,viewportId:t})}hasTargetViewport(e,t){return Pm(this._targetViewports,{renderingEngineId:e,viewportId:t})}fireEvent(e,t){if(this.isDisabled()||this._ignoreFiredEvents)return;this._ignoreFiredEvents=!0;const n=[];try{for(let r=0;r{this._ignoreFiredEvents=!1})):this._ignoreFiredEvents=!1}}_hasSourceElements(){return 0!==this._sourceViewports.length}_updateDisableHandlers(){const e=function(e,t){const n=[],r=e.concat(t);for(let e=0;et.renderingEngineId===e.renderingEngineId&&t.viewportId===e.viewportId))||n.push(t)}return n}(this._sourceViewports,this._targetViewports),t=this.remove,n=e=>{t(e.detail.element)};e.forEach((function(e){const t=(0,Y.getRenderingEngine)(e.renderingEngineId).getViewport(e.viewportId);if(!t)return;const{element:r}=t;r.removeEventListener(Y.Enums.Events.ELEMENT_DISABLED,n),r.addEventListener(Y.Enums.Events.ELEMENT_DISABLED,n)}))}};const Mm=function(e,t,n,r){if(He.synchronizers.some((t=>t.id===e)))throw new Error(`Synchronizer with id '${e}' already exists.`);const i=new km(e,t,n,r);return He.synchronizers.push(i),i};const Lm=function(){for(;He.synchronizers.length>0;){He.synchronizers.pop().destroy()}};const Rm=function(e){return He.synchronizers.find((t=>t.id===e))};const Fm=function(){return He.synchronizers};const Um=function(e){const t=He.synchronizers.findIndex((t=>t.id===e));if(t>-1){He.synchronizers[t].destroy(),He.synchronizers.splice(t,1)}};var Bm=n(20346),jm=n.n(Bm);const{Active:Vm,Passive:Wm,Enabled:zm,Disabled:Gm}=Z;class Hm{constructor(e){this.viewportsInfo=[],this.toolOptions={},this._toolInstances={},this.id=e}getViewportIds(){return this.viewportsInfo.map((({viewportId:e})=>e))}getViewportsInfo(){return this.viewportsInfo.slice()}getToolInstance(e){const t=this._toolInstances[e];if(t)return t;console.warn(`'${e}' is not registered with this toolGroup (${this.id}).`)}addTool(e,t={}){const n=He.tools[e],r=void 0!==e&&""!==e,i=this.toolOptions[e];if(!r)return void console.warn("Tool with configuration did not produce a toolName: ",t);if(!n)return void console.warn(`'${e}' is not registered with the library. You need to use cornerstoneTools.addTool to register it.`);if(i)return void console.warn(`'${e}' is already registered for ToolGroup ${this.id}.`);const{toolClass:o}=n,a=new o({name:e,toolGroupId:this.id,configuration:t});this._toolInstances[e]=a}addToolInstance(e,t,n={}){let r=He.tools[e]?.toolClass;if(!r){const n=He.tools[t].toolClass;class i extends n{}i.toolName=e,r=i,He.tools[e]={toolClass:i}}this.addTool(r.toolName,n)}addViewport(e,t){const n=(0,Y.getRenderingEngines)();if(!t&&n.length>1)throw new Error("You must specify a renderingEngineId when there are multiple rendering engines.");const r=t||n[0].id;this.viewportsInfo.some((({viewportId:t})=>t===e))||this.viewportsInfo.push({viewportId:e,renderingEngineId:r});const i=this.getActivePrimaryMouseButtonTool();Y.Settings.getRuntimeSettings().get("useCursors")&&this.setViewportsCursorByToolName(i)}removeViewports(e,t){const n=[];if(this.viewportsInfo.forEach(((r,i)=>{let o=!1;r.renderingEngineId===e&&(o=!0,t&&r.viewportId!==t&&(o=!1)),o&&n.push(i)})),n.length)for(let e=n.length-1;e>=0;e--)this.viewportsInfo.splice(n[e],1)}setActiveStrategy(e,t){const n=this._toolInstances[e];void 0!==n?n.setActiveStrategy(t):console.warn(`Tool ${e} not added to toolGroup, can't set tool configuration.`)}setToolMode(e,t,n={}){e?t!==Z.Active?t!==Z.Passive?t!==Z.Enabled?t!==Z.Disabled?console.warn("setToolMode: mode must be defined"):this.setToolDisabled(e):this.setToolEnabled(e):this.setToolPassive(e):this.setToolActive(e,n):console.warn("setToolMode: toolName must be defined")}setToolActive(e,t={}){const n=this._toolInstances[e];if(void 0===n)return void console.warn(`Tool ${e} not added to toolGroup, can't set tool mode.`);if(!n)return void console.warn(`'${e}' instance ${n} is not registered with this toolGroup, can't set tool mode.`);const r={bindings:[...this.toolOptions[e]?this.toolOptions[e].bindings:[],...t.bindings?t.bindings:[]].reduce(((e,t)=>{const n=void 0!==t.numTouchPoints,r=void 0!==t.mouseButton;return e.some((e=>function(e,t){if(e.mouseButton!==t.mouseButton)return!1;return e.modifierKey===t.modifierKey}(e,t)))||!n&&!r||e.push(t),e}),[]),mode:Vm};this.toolOptions[e]=r,this._toolInstances[e].mode=Vm;const i=Y.Settings.getRuntimeSettings().get("useCursors");if(this._hasMousePrimaryButtonBinding(t)&&i)this.setViewportsCursorByToolName(e);else{if(!this.getActivePrimaryMouseButtonTool()&&i){const e=ta.getDefinedCursor("default");this._setCursorForViewports(e)}}"function"==typeof n.onSetToolActive&&n.onSetToolActive(),this._renderViewports();const o={toolGroupId:this.id,toolName:e,toolBindingsOptions:t};(0,Y.triggerEvent)(Y.eventTarget,ne.TOOL_ACTIVATED,o)}setToolPassive(e){const t=this._toolInstances[e];if(void 0===t)return void console.warn(`Tool ${e} not added to toolGroup, can't set tool mode.`);const n=this.getToolOptions(e),r=Object.assign({bindings:n?n.bindings:[]},n,{mode:Wm}),i=this.getDefaultMousePrimary();r.bindings=r.bindings.filter((e=>e.mouseButton!==i||e.modifierKey));let o=Wm;0!==r.bindings.length&&(o=Vm,r.mode=o),this.toolOptions[e]=r,t.mode=o,"function"==typeof t.onSetToolPassive&&t.onSetToolPassive(),this._renderViewports()}setToolEnabled(e){const t=this._toolInstances[e];if(void 0===t)return void console.warn(`Tool ${e} not added to toolGroup, can't set tool mode.`);const n={bindings:[],mode:zm};this.toolOptions[e]=n,t.mode=zm,"function"==typeof t.onSetToolEnabled&&t.onSetToolEnabled(),this._renderViewports()}setToolDisabled(e){const t=this._toolInstances[e];if(void 0===t)return void console.warn(`Tool ${e} not added to toolGroup, can't set tool mode.`);const n={bindings:[],mode:Gm};this.toolOptions[e]=n,t.mode=Gm,"function"==typeof t.onSetToolDisabled&&t.onSetToolDisabled(),this._renderViewports()}getToolOptions(e){const t=this.toolOptions[e];if(void 0!==t)return t}getActivePrimaryMouseButtonTool(){return Object.keys(this.toolOptions).find((e=>{const t=this.toolOptions[e];return t.mode===Vm&&this._hasMousePrimaryButtonBinding(t)}))}setViewportsCursorByToolName(e,t){const n=this._getCursor(e,t);this._setCursorForViewports(n)}_getCursor(e,t){let n,r;return t&&(n=`${e}.${t}`,r=ya.getDefinedCursor(n,!0),r)?r:(n=`${e}`,r=ya.getDefinedCursor(n,!0),r||(n=e,r=ya.getDefinedCursor(n,!0),r||ta.getDefinedCursor("default")))}_setCursorForViewports(e){this.viewportsInfo.forEach((({renderingEngineId:t,viewportId:n})=>{const r=(0,Y.getEnabledElementByIds)(n,t);if(!r)return;const{viewport:i}=r;Da(i.element,e)}))}setToolConfiguration(e,t,n){if(void 0===this._toolInstances[e])return console.warn(`Tool ${e} not present, can't set tool configuration.`),!1;let r;return r=n?t:Object.assign(this._toolInstances[e].configuration,t),this._toolInstances[e].configuration=r,this._renderViewports(),!0}getDefaultMousePrimary(){return X.Primary}getToolConfiguration(e,t){if(void 0===this._toolInstances[e])return void console.warn(`Tool ${e} not present, can't set tool configuration.`);const n=jm()(this._toolInstances[e].configuration,t);return se()(n)}_hasMousePrimaryButtonBinding(e){const t=this.getDefaultMousePrimary();return e?.bindings?.some((e=>e.mouseButton===t&&void 0===e.modifierKey))}_renderViewports(){this.viewportsInfo.forEach((({renderingEngineId:e,viewportId:t})=>{(0,Y.getRenderingEngine)(e).renderViewport(t)}))}}const qm=function(e){if(He.toolGroups.some((t=>t.id===e)))return void console.warn(`'${e}' already exists.`);const t=new Hm(e);return He.toolGroups.push(t),t};const Km=function(e){const t=He.toolGroups.findIndex((t=>t.id===e));t>-1&&(mo.removeToolGroup(e),ni(e),He.toolGroups.splice(t,1))};const Xm=function(){const e=[...He.toolGroups];for(const t of e)Km(t.id);He.toolGroups=[]};const $m=function(e){return He.toolGroups.find((t=>t.id===e))};const Jm=function(){return He.toolGroups},Ym=[Z.Active,Z.Passive,Z.Enabled];const Zm=function(e){return He.toolGroups.filter((({toolOptions:t})=>{const n=Object.keys(t);for(let r=0;r{t.viewportsInfo.forEach((t=>{const{renderingEngineId:n,viewportId:i}=t,{FrameOfReferenceUID:o}=(0,Y.getEnabledElementByIds)(i,n);e.metadata.FrameOfReferenceUID===o&&r.push(t)}))})),!r.length)return;const i=ne.ANNOTATION_ADDED;r.forEach((({renderingEngineId:t,viewportId:n})=>{const r={annotation:e,viewportId:n,renderingEngineId:t};(0,Y.triggerEvent)(Y.eventTarget,i,r)}))}(e),e.annotationUID}function og(e,t){const n=eg(),r=n.getGroupKey(t);return n.getNumberOfAnnotations(r,e)}function ag(e){const t=eg(),n=t.getAnnotation(e);if(!n)return;t.removeAnnotation(e);const r=ne.ANNOTATION_REMOVED,i={annotation:n,annotationManagerUID:t.uid};(0,Y.triggerEvent)(Y.eventTarget,r,i)}function sg(e){return eg().getAnnotation(e)}function lg(){eg().removeAllAnnotations()}let cg=!1;function ug(e={}){cg||(!function(){hg();const e=Y.Enums.Events.ELEMENT_ENABLED,t=Y.Enums.Events.ELEMENT_DISABLED;Y.eventTarget.addEventListener(e,wm),Y.eventTarget.addEventListener(t,Am)}(),pg(),Y.eventTarget.addEventListener(ne.ANNOTATION_MODIFIED,bf),Y.eventTarget.addEventListener(ne.ANNOTATION_SELECTION_CHANGE,_f),Y.eventTarget.addEventListener(ne.ANNOTATION_SELECTION_CHANGE,_f),Y.eventTarget.addEventListener(ne.SEGMENTATION_MODIFIED,Eo),Y.eventTarget.addEventListener(ne.SEGMENTATION_DATA_MODIFIED,_o),Y.eventTarget.addEventListener(ne.SEGMENTATION_REPRESENTATION_MODIFIED,yo),Y.eventTarget.addEventListener(ne.SEGMENTATION_REPRESENTATION_REMOVED,bo),cg=!0)}function dg(){hg(),pg(),Xm(),qe();const e=eg(),t=$n();e.restoreAnnotations({}),t.resetState(),cg=!1}function hg(){const e=Y.Enums.Events.ELEMENT_ENABLED,t=Y.Enums.Events.ELEMENT_DISABLED;Y.eventTarget.removeEventListener(e,wm),Y.eventTarget.removeEventListener(t,Am)}function pg(){Y.eventTarget.removeEventListener(ne.ANNOTATION_MODIFIED,bf),Y.eventTarget.removeEventListener(ne.ANNOTATION_SELECTION_CHANGE,_f),Y.eventTarget.removeEventListener(ne.ANNOTATION_SELECTION_CHANGE,_f),Y.eventTarget.removeEventListener(ne.SEGMENTATION_MODIFIED,Eo),Y.eventTarget.removeEventListener(ne.SEGMENTATION_DATA_MODIFIED,_o),Y.eventTarget.removeEventListener(ne.SEGMENTATION_REPRESENTATION_MODIFIED,yo),Y.eventTarget.removeEventListener(ne.SEGMENTATION_REPRESENTATION_REMOVED,bo)}function fg(e,t,n,r){const{camera:i}=r.detail,o=(0,Y.getRenderingEngine)(n.renderingEngineId);if(!o)throw new Error(`No RenderingEngine for Id: ${n.renderingEngineId}`);const a=o.getViewport(n.viewportId);a.setCamera(i),a.render()}const{CAMERA_MODIFIED:mg}=Y.Enums.Events;function gg(e){return Mm(e,mg,fg)}function vg(e,t,n,r,i){const o=r.detail,{volumeId:a,range:s,invertStateChanged:l,invert:c}=o,u=(0,Y.getRenderingEngine)(n.renderingEngineId);if(!u)throw new Error(`Rendering Engine does not exist: ${n.renderingEngineId}`);const d=u.getViewport(n.viewportId),h={voiRange:s};if(i?.syncInvertState&&l&&(h.invert=c),d instanceof Y.BaseVolumeViewport)d.setProperties(h,a);else{if(!(d instanceof Y.StackViewport))throw new Error("Viewport type not supported.");d.setProperties(h)}d.render()}function yg(e,t={syncInvertState:!0}){return Mm(e,Y.Enums.Events.VOI_MODIFIED,vg,t)}function _g(e,t,n){const r=(0,Y.getRenderingEngine)(n.renderingEngineId);if(!r)throw new Error(`No RenderingEngine for Id: ${n.renderingEngineId}`);const i=e.getOptions(n.viewportId),o=r.getViewport(n.viewportId),a=r.getViewport(t.viewportId);if(!1!==i?.syncZoom){const e=a.getZoom();o.setZoom(e)}if(!1!==i?.syncPan){const e=a.getPan();o.setPan(e)}o.render()}const{CAMERA_MODIFIED:bg}=Y.Enums.Events;function Eg(e){return Mm(e,bg,_g)}const wg=(e,t)=>Y.utilities.spatialRegistrationMetadataProvider.get("spatialRegistrationModule",[e,t]);async function xg(e,t,n){const r=(0,Y.getRenderingEngine)(n.renderingEngineId);if(!r)throw new Error(`No RenderingEngine for Id: ${n.renderingEngineId}`);const i=r.getViewport(t.viewportId),o=e.getOptions(n.viewportId);if(o?.disabled)return;const a=r.getViewport(n.viewportId),s=i.getCurrentImageId(),l=Y.metaData.get("imagePlaneModule",s).imagePositionPatient,c=a.getImageIds();if(!function(e,t){const{viewPlaneNormal:n}=e.getCamera(),{viewPlaneNormal:r}=t.getCamera(),i=Ci.R3.dot(n,r);return Math.abs(i)>.9}(i,a))return;let u=wg(n.viewportId,t.viewportId);if(!u){if(i.getFrameOfReferenceUID()===a.getFrameOfReferenceUID()&&!1!==o?.useInitialPosition?u=Ci._E.identity(Ci._E.create()):(Y.utilities.calculateViewportsSpatialRegistration(i,a),u=wg(n.viewportId,t.viewportId)),!u)return}const d=Ci.R3.transformMat4(Ci.R3.create(),l,u),h=(p=d,c.reduce(((e,t,n)=>{const{imagePositionPatient:r}=Y.metaData.get("imagePlaneModule",t),i=Ci.R3.distance(r,p);return i{var r="__lodash_hash_undefined__",i=1/0,o="[object Function]",a="[object GeneratorFunction]",s="[object Symbol]",l=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,c=/^\w*$/,u=/^\./,d=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,h=/\\(\\)?/g,p=/^\[object .+?Constructor\]$/,f="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,m="object"==typeof self&&self&&self.Object===Object&&self,g=f||m||Function("return this")();var v,y=Array.prototype,_=Function.prototype,b=Object.prototype,E=g["__core-js_shared__"],w=(v=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||""))?"Symbol(src)_1."+v:"",x=_.toString,C=b.hasOwnProperty,D=b.toString,S=RegExp("^"+x.call(C).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=g.Symbol,I=y.splice,A=j(g,"Map"),N=j(Object,"create"),O=T?T.prototype:void 0,P=O?O.toString:void 0;function k(e){var t=-1,n=e?e.length:0;for(this.clear();++t-1},M.prototype.set=function(e,t){var n=this.__data__,r=R(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},L.prototype.clear=function(){this.__data__={hash:new k,map:new(A||M),string:new k}},L.prototype.delete=function(e){return B(this,e).delete(e)},L.prototype.get=function(e){return B(this,e).get(e)},L.prototype.has=function(e){return B(this,e).has(e)},L.prototype.set=function(e,t){return B(this,e).set(e,t),this};var V=z((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(q(e))return P?P.call(e):"";var t=e+"";return"0"==t&&1/e==-i?"-0":t}(t);var n=[];return u.test(e)&&n.push(""),e.replace(d,(function(e,t,r,i){n.push(r?i.replace(h,"$1"):t||e)})),n}));function W(e){if("string"==typeof e||q(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}function z(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a),a};return n.cache=new(z.Cache||L),n}z.Cache=L;var G=Array.isArray;function H(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function q(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&D.call(e)==s}e.exports=function(e,t,n){var r=null==e?void 0:F(e,t);return void 0===r?n:r}},39053:function(e){e.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=184)}([function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),r(n(240)),r(n(251)),r(n(175)),r(n(107)),r(n(29)),r(n(73)),r(n(106)),r(n(30)),r(n(252)),r(n(52)),r(n(97)),r(n(253)),r(n(37)),r(n(51)),r(n(173)),r(n(176)),r(n(172)),r(n(108)),r(n(254)),r(n(255)),r(n(256)),r(n(72)),r(n(177)),r(n(105)),r(n(17)),r(n(257)),r(n(12)),r(n(174))},function(e,t,n){"use strict";var r=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(212);t.FixedSizeSet=i.FixedSizeSet;var o=n(213);t.ObjectCache=o.ObjectCache;var a=n(214);t.CompareCache=a.CompareCache;var s=n(215);t.Lazy=s.Lazy;var l=n(216);function c(e,t,n){if(m(e))e.forEach((function(e,r){return t.call(n,r,e)}));else for(var r in e)e.hasOwnProperty(r)&&t.call(n,r,e[r])}function u(e){var t,n;if(d(e))return e;if(p(e)){var i=[];try{for(var o=r(e),a=o.next();!a.done;a=o.next()){var s=a.value;i.push(u(s))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return i}if(h(e)){for(var l in i={},e)if(e.hasOwnProperty(l)){var c=e[l];i[l]=u(c)}return i}return e}function d(e){return!!e&&"[object Function]"===Object.prototype.toString.call(e)}function h(e){var t=typeof e;return!!e&&("function"===t||"object"===t)}function p(e){return Array.isArray(e)}function f(e){return e instanceof Set}function m(e){return e instanceof Map}function g(e){if(h(e)){var t=Object.getPrototypeOf(e),n=t.constructor;return t&&n&&"function"==typeof n&&n instanceof n&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object)}return!1}t.StringWalker=l.StringWalker,t.applyMixin=function(e,t){for(var n=[],r=2;r>6|192;else{if(i>55295&&i<56320){if(++r>=e.length)throw new Error("Incomplete surrogate pair.");var o=e.charCodeAt(r);if(o<56320||o>57343)throw new Error("Invalid surrogate character.");i=65536+((1023&i)<<10)+(1023&o),t[n++]=i>>18|240,t[n++]=i>>12&63|128}else t[n++]=i>>12|224;t[n++]=i>>6&63|128}t[n++]=63&i|128}}return t.subarray(0,n)},t.utf8Decode=function(e){for(var t="",n=0;n127)if(r>191&&r<224){if(n>=e.length)throw new Error("Incomplete 2-byte sequence.");r=(31&r)<<6|63&e[n++]}else if(r>223&&r<240){if(n+1>=e.length)throw new Error("Incomplete 3-byte sequence.");r=(15&r)<<12|(63&e[n++])<<6|63&e[n++]}else{if(!(r>239&&r<248))throw new Error("Unknown multi-byte start.");if(n+2>=e.length)throw new Error("Incomplete 4-byte sequence.");r=(7&r)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++]}if(r<=65535)t+=String.fromCharCode(r);else{if(!(r<=1114111))throw new Error("Code point exceeds UTF-16 limit.");r-=65536,t+=String.fromCharCode(r>>10|55296),t+=String.fromCharCode(1023&r|56320)}}return t}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.Before=0]="Before",e[e.Equal=1]="Equal",e[e.After=2]="After"}(t.BoundaryPosition||(t.BoundaryPosition={})),function(e){e[e.None=0]="None",e[e.Capturing=1]="Capturing",e[e.AtTarget=2]="AtTarget",e[e.Bubbling=3]="Bubbling"}(t.EventPhase||(t.EventPhase={})),function(e){e[e.Element=1]="Element",e[e.Attribute=2]="Attribute",e[e.Text=3]="Text",e[e.CData=4]="CData",e[e.EntityReference=5]="EntityReference",e[e.Entity=6]="Entity",e[e.ProcessingInstruction=7]="ProcessingInstruction",e[e.Comment=8]="Comment",e[e.Document=9]="Document",e[e.DocumentType=10]="DocumentType",e[e.DocumentFragment=11]="DocumentFragment",e[e.Notation=12]="Notation"}(t.NodeType||(t.NodeType={})),function(e){e[e.Disconnected=1]="Disconnected",e[e.Preceding=2]="Preceding",e[e.Following=4]="Following",e[e.Contains=8]="Contains",e[e.ContainedBy=16]="ContainedBy",e[e.ImplementationSpecific=32]="ImplementationSpecific"}(t.Position||(t.Position={})),function(e){e[e.Accept=1]="Accept",e[e.Reject=2]="Reject",e[e.Skip=3]="Skip"}(t.FilterResult||(t.FilterResult={})),function(e){e[e.All=4294967295]="All",e[e.Element=1]="Element",e[e.Attribute=2]="Attribute",e[e.Text=4]="Text",e[e.CDataSection=8]="CDataSection",e[e.EntityReference=16]="EntityReference",e[e.Entity=32]="Entity",e[e.ProcessingInstruction=64]="ProcessingInstruction",e[e.Comment=128]="Comment",e[e.Document=256]="Document",e[e.DocumentType=512]="DocumentType",e[e.DocumentFragment=1024]="DocumentFragment",e[e.Notation=2048]="Notation"}(t.WhatToShow||(t.WhatToShow={})),function(e){e[e.StartToStart=0]="StartToStart",e[e.StartToEnd=1]="StartToEnd",e[e.EndToEnd=2]="EndToEnd",e[e.EndToStart=3]="EndToStart"}(t.HowToCompare||(t.HowToCompare={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(241);t.Cast=r.Cast;var i=n(150);t.Guard=i.Guard;var o=n(242);t.EmptySet=o.EmptySet},function(e,t,n){var r=n(11),i=n(55).f,o=n(21),a=n(25),s=n(80),l=n(119),c=n(123);e.exports=function(e,t){var n,u,d,h,p,f=e.target,m=e.global,g=e.stat;if(n=m?r:g?r[f]||s(f,{}):(r[f]||{}).prototype)for(u in t){if(h=t[u],d=e.noTargetGet?(p=i(n,u))&&p.value:n[u],!c(m?u:f+(g?".":"#")+u,e.forced)&&void 0!==d){if(typeof h==typeof d)continue;l(h,d)}(e.sham||d&&d.sham)&&o(h,"sham",!0),a(n,u,h,e)}}},function(e,t,n){var r=n(11),i=n(81),o=n(14),a=n(58),s=n(86),l=n(124),c=i("wks"),u=r.Symbol,d=l?u:u&&u.withoutSetter||a;e.exports=function(e){return o(c,e)||(s&&o(u,e)?c[e]=u[e]:c[e]=d("Symbol."+e)),c[e]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),i=n(29),o=function(){function e(){this._features={mutationObservers:!0,customElements:!0,slots:!0,steps:!0},this._window=null,this._compareCache=new r.CompareCache,this._rangeList=new r.FixedSizeSet}return e.prototype.setFeatures=function(e){if(void 0===e&&(e=!0),r.isObject(e))for(var t in e)this._features[t]=e[t]||!1;else for(var t in this._features)this._features[t]=e},Object.defineProperty(e.prototype,"features",{get:function(){return this._features},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"window",{get:function(){return null===this._window&&(this._window=i.create_window()),this._window},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"compareCache",{get:function(){return this._compareCache},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rangeList",{get:function(){return this._rangeList},enumerable:!0,configurable:!0}),Object.defineProperty(e,"instance",{get:function(){return e._instance||(e._instance=new e),e._instance},enumerable:!0,configurable:!0}),e}();t.dom=o.instance},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(228));t.base64=i;var o=r(n(146));t.byte=o;var a=r(n(147));t.byteSequence=a;var s=r(n(96));t.codePoint=s;var l=r(n(232));t.json=l;var c=r(n(233));t.list=c;var u=r(n(234));t.map=u;var d=r(n(235));t.namespace=d;var h=r(n(236));t.queue=h;var p=r(n(237));t.set=p;var f=r(n(238));t.stack=f;var m=r(n(239));t.string=m},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t,n){void 0===n&&(n="");var r=e.call(this,n)||this;return r.name=t,r}return i(t,e),t}(Error);t.DOMException=o;var a=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"DOMStringSizeError",t)||this}return i(t,e),t}(o);t.DOMStringSizeError=a;var s=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"WrongDocumentError","The object is in the wrong document. "+t)||this}return i(t,e),t}(o);t.WrongDocumentError=s;var l=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"NoDataAllowedError",t)||this}return i(t,e),t}(o);t.NoDataAllowedError=l;var c=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"NoModificationAllowedError","The object can not be modified. "+t)||this}return i(t,e),t}(o);t.NoModificationAllowedError=c;var u=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"NotSupportedError","The operation is not supported. "+t)||this}return i(t,e),t}(o);t.NotSupportedError=u;var d=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"InUseAttributeError",t)||this}return i(t,e),t}(o);t.InUseAttributeError=d;var h=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"InvalidStateError","The object is in an invalid state. "+t)||this}return i(t,e),t}(o);t.InvalidStateError=h;var p=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"InvalidModificationError","The object can not be modified in this way. "+t)||this}return i(t,e),t}(o);t.InvalidModificationError=p;var f=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"NamespaceError","The operation is not allowed by Namespaces in XML. [XMLNS] "+t)||this}return i(t,e),t}(o);t.NamespaceError=f;var m=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"InvalidAccessError","The object does not support the operation or argument. "+t)||this}return i(t,e),t}(o);t.InvalidAccessError=m;var g=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"ValidationError",t)||this}return i(t,e),t}(o);t.ValidationError=g;var v=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"TypeMismatchError",t)||this}return i(t,e),t}(o);t.TypeMismatchError=v;var y=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"SecurityError","The operation is insecure. "+t)||this}return i(t,e),t}(o);t.SecurityError=y;var _=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"NetworkError","A network error occurred. "+t)||this}return i(t,e),t}(o);t.NetworkError=_;var b=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"AbortError","The operation was aborted. "+t)||this}return i(t,e),t}(o);t.AbortError=b;var E=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"URLMismatchError","The given URL does not match another URL. "+t)||this}return i(t,e),t}(o);t.URLMismatchError=E;var w=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"QuotaExceededError","The quota has been exceeded. "+t)||this}return i(t,e),t}(o);t.QuotaExceededError=w;var x=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"TimeoutError","The operation timed out. "+t)||this}return i(t,e),t}(o);t.TimeoutError=x;var C=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"InvalidNodeTypeError","The supplied node is incorrect or has an incorrect ancestor for this operation. "+t)||this}return i(t,e),t}(o);t.InvalidNodeTypeError=C;var D=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"DataCloneError","The object can not be cloned. "+t)||this}return i(t,e),t}(o);t.DataCloneError=D;var S=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"NotImplementedError","The DOM method is not implemented by this module. "+t)||this}return i(t,e),t}(o);t.NotImplementedError=S;var T=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"HierarchyRequestError","The operation would yield an incorrect node tree. "+t)||this}return i(t,e),t}(o);t.HierarchyRequestError=T;var I=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"NotFoundError","The object can not be found here. "+t)||this}return i(t,e),t}(o);t.NotFoundError=I;var A=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"IndexSizeError","The index is not in the allowed range. "+t)||this}return i(t,e),t}(o);t.IndexSizeError=A;var N=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"SyntaxError","The string did not match the expected pattern. "+t)||this}return i(t,e),t}(o);t.SyntaxError=N;var O=function(e){function t(t){return void 0===t&&(t=""),e.call(this,"InvalidCharacterError","The string contains invalid characters. "+t)||this}return i(t,e),t}(o);t.InvalidCharacterError=O},function(e,t,n){"use strict";var r=n(53),i=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],o=["scalar","sequence","mapping"];e.exports=function(e,t){var n,a;if(t=t||{},Object.keys(t).forEach((function(t){if(-1===i.indexOf(t))throw new r('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')})),this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.defaultStyle=t.defaultStyle||null,this.styleAliases=(n=t.styleAliases||null,a={},null!==n&&Object.keys(n).forEach((function(e){n[e].forEach((function(t){a[String(t)]=e}))})),a),-1===o.indexOf(this.kind))throw new r('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}},function(e,t,n){(function(t){var n=function(e){return e&&e.Math==Math&&e};e.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof t&&t)||Function("return this")()}).call(this,n(78))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.idl_defineConst=function(e,t,n){Object.defineProperty(e,t,{writable:!1,enumerable:!0,configurable:!1,value:n})}},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t,n){var r=n(16),i=n(115),o=n(18),a=n(56),s=Object.defineProperty;t.f=r?s:function(e,t,n){if(o(e),t=a(t,!0),o(n),i)try{return s(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},function(e,t,n){var r=n(8);e.exports=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},function(e,t,n){"use strict";var r=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(3),o=n(2);function a(e,t,n){if(void 0===n&&(n=!1),n&&i.Guard.isElementNode(t)&&i.Guard.isShadowRoot(t.shadowRoot)&&t.shadowRoot._firstChild)return t.shadowRoot._firstChild;if(t._firstChild)return t._firstChild;if(t===e)return null;if(t._nextSibling)return t._nextSibling;for(var r=t._parent;r&&r!==e;){if(r._nextSibling)return r._nextSibling;r=r._parent}return null}function s(){var e;return(e={})[Symbol.iterator]=function(){return{next:function(){return{done:!0,value:null}}}},e}function l(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);for(var i=t?e:a(e,e,n);i&&r&&!r(i);)i=a(e,i,n);return i}function c(e,t,n,r,i){void 0===n&&(n=!1),void 0===r&&(r=!1);for(var o=a(e,t,r);o&&i&&!i(o);)o=a(e,o,r);return o}function u(e,t,n,r){var i;return void 0===t&&(t=!1),void 0===n&&(n=!1),t||0!==e._children.size?((i={})[Symbol.iterator]=function(){var i=t?e:a(e,e,n);return{next:function(){for(;i&&r&&!r(i);)i=a(e,i,n);if(null===i)return{done:!0,value:null};var t={done:!1,value:i};return i=a(e,i,n),t}}},i):s()}function d(e,t,n){void 0===t&&(t=!1);for(var r=t?e:e._parent;r&&n&&!n(r);)r=r._parent;return r}function h(e,t,n,r){void 0===n&&(n=!1);for(var i=t._parent;i&&r&&!r(i);)i=i._parent;return i}function p(e){return i.Guard.isDocumentTypeNode(e)?0:i.Guard.isCharacterDataNode(e)?e._data.length:e._children.size}function f(e,t){if(void 0===t&&(t=!1),t){var n=f(e,!1);return i.Guard.isShadowRoot(n)?f(n._host,!0):n}return e._parent?f(e._parent):e}function m(e,t,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1);for(var o=n?e:r&&i.Guard.isShadowRoot(e)?e._host:e._parent;null!==o;){if(o===t)return!0;o=r&&i.Guard.isShadowRoot(o)?o._host:o._parent}return!1}function g(e){for(var t=f(e),n=0,r=l(t);null!==r;){if(n++,r===e)return n;r=c(t,r)}return-1}t.tree_getFirstDescendantNode=l,t.tree_getNextDescendantNode=c,t.tree_getDescendantNodes=u,t.tree_getDescendantElements=function(e,t,n,r){var o;return void 0===t&&(t=!1),void 0===n&&(n=!1),t||0!==e._children.size?((o={})[Symbol.iterator]=function(){var o=u(e,t,n,(function(e){return i.Guard.isElementNode(e)}))[Symbol.iterator](),a=o.next().value;return{next:function(){for(;a&&r&&!r(a);)a=o.next().value;if(null===a)return{done:!0,value:null};var e={done:!1,value:a};return a=o.next().value,e}}},o):s()},t.tree_getSiblingNodes=function(e,t,n){var r;return void 0===t&&(t=!1),e._parent&&0!==e._parent._children.size?((r={})[Symbol.iterator]=function(){var r=e._parent?e._parent._firstChild:null;return{next:function(){for(;r&&(n&&!n(r)||!t&&r===e);)r=r._nextSibling;if(null===r)return{done:!0,value:null};var i={done:!1,value:r};return r=r._nextSibling,i}}},r):s()},t.tree_getFirstAncestorNode=d,t.tree_getNextAncestorNode=h,t.tree_getAncestorNodes=function(e,t,n){var r;return void 0===t&&(t=!1),t||e._parent?((r={})[Symbol.iterator]=function(){var r=d(e,t,n);return{next:function(){if(null===r)return{done:!0,value:null};var e={done:!1,value:r};return r=h(0,r,t,n),e}}},r):s()},t.tree_getCommonAncestor=function(e,t){if(e===t)return e._parent;for(var n=[],r=[],i=d(e,!0);null!==i;)n.push(i),i=h(0,i,!0);for(var o=d(t,!0);null!==o;)r.push(o),o=h(0,o,!0);for(var a=n.length,s=r.length,l=null,c=Math.min(a,s);c>0;c--){var u=n[--a];if(u!==r[--s])break;l=u}return l},t.tree_getFollowingNode=function(e,t){if(t._firstChild)return t._firstChild;if(t._nextSibling)return t._nextSibling;for(;;){var n=t._parent;if(null===n||n===e)return null;if(n._nextSibling)return n._nextSibling;t=n}},t.tree_getPrecedingNode=function(e,t){return t===e?null:t._previousSibling?(t=t._previousSibling)._lastChild?t._lastChild:t:t._parent},t.tree_isConstrained=function e(t){var n,i,a,s,l,c;switch(t._nodeType){case o.NodeType.Document:var u=!1,d=!1;try{for(var h=r(t._children),p=h.next();!p.done;p=h.next())switch(p.value._nodeType){case o.NodeType.ProcessingInstruction:case o.NodeType.Comment:break;case o.NodeType.DocumentType:if(u||d)return!1;u=!0;break;case o.NodeType.Element:if(d)return!1;d=!0;break;default:return!1}}catch(e){n={error:e}}finally{try{p&&!p.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}break;case o.NodeType.DocumentFragment:case o.NodeType.Element:try{for(var f=r(t._children),m=f.next();!m.done;m=f.next())switch(m.value._nodeType){case o.NodeType.Element:case o.NodeType.Text:case o.NodeType.ProcessingInstruction:case o.NodeType.CData:case o.NodeType.Comment:break;default:return!1}}catch(e){a={error:e}}finally{try{m&&!m.done&&(s=f.return)&&s.call(f)}finally{if(a)throw a.error}}break;case o.NodeType.DocumentType:case o.NodeType.Text:case o.NodeType.ProcessingInstruction:case o.NodeType.CData:case o.NodeType.Comment:return!t.hasChildNodes()}try{for(var g=r(t._children),v=g.next();!v.done;v=g.next())if(!e(v.value))return!1}catch(e){l={error:e}}finally{try{v&&!v.done&&(c=g.return)&&c.call(g)}finally{if(l)throw l.error}}return!0},t.tree_nodeLength=p,t.tree_isEmpty=function(e){return 0===p(e)},t.tree_rootNode=f,t.tree_isDescendantOf=function(e,t,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1);for(var i=l(e,n,r);null!==i;){if(i===t)return!0;i=c(e,i,n,r)}return!1},t.tree_isAncestorOf=m,t.tree_isHostIncludingAncestorOf=function e(t,n,r){if(void 0===r&&(r=!1),m(t,n,r))return!0;var o=f(t);return!(!i.Guard.isDocumentFragmentNode(o)||null===o._host||!e(o._host,n,r))},t.tree_isSiblingOf=function(e,t,n){return void 0===n&&(n=!1),e!==t?null!==e._parent&&e._parent===t._parent:!!n},t.tree_isPreceding=function(e,t){var n=g(e),r=g(t);return-1!==n&&-1!==r&&f(e)===f(t)&&rn},t.tree_isParentOf=function(e,t){return e._parent===t},t.tree_isChildOf=function(e,t){return t._parent===e},t.tree_previousSibling=function(e){return e._previousSibling},t.tree_nextSibling=function(e){return e._nextSibling},t.tree_firstChild=function(e){return e._firstChild},t.tree_lastChild=function(e){return e._lastChild},t.tree_treePosition=g,t.tree_index=function(e){for(var t=0;null!==e._previousSibling;)t++,e=e._previousSibling;return t},t.tree_retarget=function(e,t){for(;;){if(!e||!i.Guard.isNode(e))return e;var n=f(e);if(!i.Guard.isShadowRoot(n))return e;if(t&&i.Guard.isNode(t)&&m(n,t,!0,!0))return e;e=n.host}}},function(e,t,n){var r=n(13);e.exports=function(e){if(!r(e))throw TypeError(String(e)+" is not an object");return e}},function(e,t,n){"use strict";var r=n(24),i=n(130),o=n(49),a=n(43),s=n(88),l=a.set,c=a.getterFor("Array Iterator");e.exports=s(Array,"Array",(function(e,t){l(this,{type:"Array Iterator",target:r(e),index:0,kind:t})}),(function(){var e=c(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:t[r],done:!1}:{value:[r,t[r]],done:!1}}),"values"),o.Arguments=o.Array,i("keys"),i("values"),i("entries")},function(e,t,n){var r=n(90),i=n(25),o=n(202);r||i(Object.prototype,"toString",o,{unsafe:!0})},function(e,t,n){var r=n(16),i=n(15),o=n(40);e.exports=r?function(e,t,n){return i.f(e,t,o(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t,n){"use strict";var r=n(137).charAt,i=n(43),o=n(88),a=i.set,s=i.getterFor("String Iterator");o(String,"String",(function(e){a(this,{type:"String Iterator",string:String(e),index:0})}),(function(){var e,t=s(this),n=t.string,i=t.index;return i>=n.length?{value:void 0,done:!0}:(e=r(n,i),t.index+=e.length,{value:e,done:!1})}))},function(e,t,n){var r=n(11),i=n(203),o=n(19),a=n(21),s=n(5),l=s("iterator"),c=s("toStringTag"),u=o.values;for(var d in i){var h=r[d],p=h&&h.prototype;if(p){if(p[l]!==u)try{a(p,l,u)}catch(e){p[l]=u}if(p[c]||a(p,c,d),i[d])for(var f in o)if(p[f]!==o[f])try{a(p,f,o[f])}catch(e){p[f]=o[f]}}}},function(e,t,n){var r=n(41),i=n(35);e.exports=function(e){return r(i(e))}},function(e,t,n){var r=n(11),i=n(21),o=n(14),a=n(80),s=n(117),l=n(43),c=l.get,u=l.enforce,d=String(String).split("String");(e.exports=function(e,t,n,s){var l=!!s&&!!s.unsafe,c=!!s&&!!s.enumerable,h=!!s&&!!s.noTargetGet;"function"==typeof n&&("string"!=typeof t||o(n,"name")||i(n,"name",t),u(n).source=d.join("string"==typeof t?t:"")),e!==r?(l?!h&&e[t]&&(c=!0):delete e[t],c?e[t]=n:i(e,t,n)):c?e[t]=n:a(t,n)})(Function.prototype,"toString",(function(){return"function"==typeof this&&c(this).source||s(this)}))},function(e,t,n){var r=n(47),i=Math.min;e.exports=function(e){return e>0?i(r(e),9007199254740991):0}},function(e,t,n){var r=n(35);e.exports=function(e){return Object(r(e))}},function(e,t,n){var r=n(16),i=n(8),o=n(14),a=Object.defineProperty,s={},l=function(e){throw e};e.exports=function(e,t){if(o(s,e))return s[e];t||(t={});var n=[][e],c=!!o(t,"ACCESSORS")&&t.ACCESSORS,u=o(t,0)?t[0]:l,d=o(t,1)?t[1]:void 0;return s[e]=!!n&&!i((function(){if(c&&!r)return!0;var e={length:-1};c?a(e,1,{enumerable:!0,get:l}):e[1]=1,n.call(e,u,d)}))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(148),i=n(149),o=n(151),a=n(98),s=n(153),l=n(154),c=n(155),u=n(99),d=n(100),h=n(156),p=n(157),f=n(101),m=n(158),g=n(159),v=n(160),y=n(161),_=n(162),b=n(163),E=n(164),w=n(165),x=n(166),C=n(167),D=n(168),S=n(169),T=n(170);t.create_domImplementation=function(e){return r.DOMImplementationImpl._create(e)},t.create_window=function(){return i.WindowImpl._create()},t.create_xmlDocument=function(){return new o.XMLDocumentImpl},t.create_document=function(){return new a.DocumentImpl},t.create_abortController=function(){return new s.AbortControllerImpl},t.create_abortSignal=function(){return l.AbortSignalImpl._create()},t.create_documentType=function(e,t,n,r){return c.DocumentTypeImpl._create(e,t,n,r)},t.create_element=function(e,t,n,r){return u.ElementImpl._create(e,t,n,r)},t.create_htmlElement=function(e,t,n,r){return u.ElementImpl._create(e,t,n,r)},t.create_htmlUnknownElement=function(e,t,n,r){return u.ElementImpl._create(e,t,n,r)},t.create_documentFragment=function(e){return d.DocumentFragmentImpl._create(e)},t.create_shadowRoot=function(e,t){return h.ShadowRootImpl._create(e,t)},t.create_attr=function(e,t){return p.AttrImpl._create(e,t)},t.create_text=function(e,t){return f.TextImpl._create(e,t)},t.create_cdataSection=function(e,t){return m.CDATASectionImpl._create(e,t)},t.create_comment=function(e,t){return g.CommentImpl._create(e,t)},t.create_processingInstruction=function(e,t,n){return v.ProcessingInstructionImpl._create(e,t,n)},t.create_htmlCollection=function(e,t){return void 0===t&&(t=function(){return!0}),y.HTMLCollectionImpl._create(e,t)},t.create_nodeList=function(e){return _.NodeListImpl._create(e)},t.create_nodeListStatic=function(e,t){return b.NodeListStaticImpl._create(e,t)},t.create_namedNodeMap=function(e){return E.NamedNodeMapImpl._create(e)},t.create_range=function(e,t){return w.RangeImpl._create(e,t)},t.create_nodeIterator=function(e,t,n){return x.NodeIteratorImpl._create(e,t,n)},t.create_treeWalker=function(e,t){return C.TreeWalkerImpl._create(e,t)},t.create_nodeFilter=function(){return D.NodeFilterImpl._create()},t.create_mutationRecord=function(e,t,n,r,i,o,a,s,l){return S.MutationRecordImpl._create(e,t,n,r,i,o,a,s,l)},t.create_domTokenList=function(e,t){return T.DOMTokenListImpl._create(e,t)}},function(e,t,n){"use strict";var r=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(6),o=n(17),a=n(3),s=n(72),l=new Map;function c(e,t){if(t!==e._root&&o.tree_isAncestorOf(e._reference,t,!0)){if(e._pointerBeforeReference)for(;;){var n=o.tree_getFollowingNode(e._root,t);if(null!==n&&o.tree_isDescendantOf(e._root,n,!0)&&!o.tree_isDescendantOf(t,n,!0))return void(e._reference=n);if(null===n)return void(e._pointerBeforeReference=!1)}if(null===t._previousSibling)null!==t._parent&&(e._reference=t._parent);else{for(var r=t._previousSibling,i=o.tree_getFirstDescendantNode(t._previousSibling,!0,!1);null!==i;)null!==i&&(r=i),i=o.tree_getNextDescendantNode(t._previousSibling,i,!0,!1);e._reference=r}}}function u(e,t,n,r,i){if(a.Guard.isSlot(e)&&"name"===t&&null===i){if(r===n)return;if(null===r&&""===n)return;if(""===r&&null===n)return;e._name=null===r||""===r?"":r,s.shadowTree_assignSlotablesForATree(o.tree_rootNode(e))}}function d(e,t,n,r,i){if(a.Guard.isSlotable(e)&&"slot"===t&&null===i){if(r===n)return;if(null===r&&""===n)return;if(""===r&&null===n)return;e._name=null===r||""===r?"":r,s.shadowTree_isAssigned(e)&&s.shadowTree_assignSlotables(e._assignedSlot),s.shadowTree_assignASlot(e)}}function h(e,t,n,r){"id"===t&&null===r&&(e._uniqueIdentifier=n||void 0)}t.dom_runRemovingSteps=function(e,t){},t.dom_runCloningSteps=function(e,t,n,r){},t.dom_runAdoptingSteps=function(e,t){},t.dom_runAttributeChangeSteps=function(e,t,n,o,a){var s,l;i.dom.features.slots&&(d.call(e,e,t,n,o,a),u.call(e,e,t,n,o,a)),h.call(e,e,t,o,a);try{for(var c=r(e._attributeChangeSteps),p=c.next();!p.done;p=c.next())p.value.call(e,e,t,n,o,a)}catch(e){s={error:e}}finally{try{p&&!p.done&&(l=c.return)&&l.call(c)}finally{if(s)throw s.error}}},t.dom_runInsertionSteps=function(e){},t.dom_runNodeIteratorPreRemovingSteps=function(e,t){c.call(e,e,t)},t.dom_hasSupportedTokens=function(e){return l.has(e)},t.dom_getSupportedTokens=function(e){return l.get(e)||new Set},t.dom_runEventConstructingSteps=function(e){},t.dom_runChildTextContentChangeSteps=function(e){}},function(e,t,n){"use strict";var r=n(4),i=n(11),o=n(46),a=n(44),s=n(16),l=n(86),c=n(124),u=n(8),d=n(14),h=n(59),p=n(13),f=n(18),m=n(27),g=n(24),v=n(56),y=n(40),_=n(60),b=n(61),E=n(82),w=n(190),x=n(85),C=n(55),D=n(15),S=n(79),T=n(21),I=n(25),A=n(81),N=n(57),O=n(45),P=n(58),k=n(5),M=n(125),L=n(126),R=n(62),F=n(43),U=n(36).forEach,B=N("hidden"),j=k("toPrimitive"),V=F.set,W=F.getterFor("Symbol"),z=Object.prototype,G=i.Symbol,H=o("JSON","stringify"),q=C.f,K=D.f,X=w.f,$=S.f,J=A("symbols"),Y=A("op-symbols"),Z=A("string-to-symbol-registry"),Q=A("symbol-to-string-registry"),ee=A("wks"),te=i.QObject,ne=!te||!te.prototype||!te.prototype.findChild,re=s&&u((function(){return 7!=_(K({},"a",{get:function(){return K(this,"a",{value:7}).a}})).a}))?function(e,t,n){var r=q(z,t);r&&delete z[t],K(e,t,n),r&&e!==z&&K(z,t,r)}:K,ie=function(e,t){var n=J[e]=_(G.prototype);return V(n,{type:"Symbol",tag:e,description:t}),s||(n.description=t),n},oe=c?function(e){return"symbol"==typeof e}:function(e){return Object(e)instanceof G},ae=function(e,t,n){e===z&&ae(Y,t,n),f(e);var r=v(t,!0);return f(n),d(J,r)?(n.enumerable?(d(e,B)&&e[B][r]&&(e[B][r]=!1),n=_(n,{enumerable:y(0,!1)})):(d(e,B)||K(e,B,y(1,{})),e[B][r]=!0),re(e,r,n)):K(e,r,n)},se=function(e,t){f(e);var n=g(t),r=b(n).concat(de(n));return U(r,(function(t){s&&!le.call(n,t)||ae(e,t,n[t])})),e},le=function(e){var t=v(e,!0),n=$.call(this,t);return!(this===z&&d(J,t)&&!d(Y,t))&&(!(n||!d(this,t)||!d(J,t)||d(this,B)&&this[B][t])||n)},ce=function(e,t){var n=g(e),r=v(t,!0);if(n!==z||!d(J,r)||d(Y,r)){var i=q(n,r);return!i||!d(J,r)||d(n,B)&&n[B][r]||(i.enumerable=!0),i}},ue=function(e){var t=X(g(e)),n=[];return U(t,(function(e){d(J,e)||d(O,e)||n.push(e)})),n},de=function(e){var t=e===z,n=X(t?Y:g(e)),r=[];return U(n,(function(e){!d(J,e)||t&&!d(z,e)||r.push(J[e])})),r};l||(I((G=function(){if(this instanceof G)throw TypeError("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?String(arguments[0]):void 0,t=P(e),n=function(e){this===z&&n.call(Y,e),d(this,B)&&d(this[B],t)&&(this[B][t]=!1),re(this,t,y(1,e))};return s&&ne&&re(z,t,{configurable:!0,set:n}),ie(t,e)}).prototype,"toString",(function(){return W(this).tag})),I(G,"withoutSetter",(function(e){return ie(P(e),e)})),S.f=le,D.f=ae,C.f=ce,E.f=w.f=ue,x.f=de,M.f=function(e){return ie(k(e),e)},s&&(K(G.prototype,"description",{configurable:!0,get:function(){return W(this).description}}),a||I(z,"propertyIsEnumerable",le,{unsafe:!0}))),r({global:!0,wrap:!0,forced:!l,sham:!l},{Symbol:G}),U(b(ee),(function(e){L(e)})),r({target:"Symbol",stat:!0,forced:!l},{for:function(e){var t=String(e);if(d(Z,t))return Z[t];var n=G(t);return Z[t]=n,Q[n]=t,n},keyFor:function(e){if(!oe(e))throw TypeError(e+" is not a symbol");if(d(Q,e))return Q[e]},useSetter:function(){ne=!0},useSimple:function(){ne=!1}}),r({target:"Object",stat:!0,forced:!l,sham:!s},{create:function(e,t){return void 0===t?_(e):se(_(e),t)},defineProperty:ae,defineProperties:se,getOwnPropertyDescriptor:ce}),r({target:"Object",stat:!0,forced:!l},{getOwnPropertyNames:ue,getOwnPropertySymbols:de}),r({target:"Object",stat:!0,forced:u((function(){x.f(1)}))},{getOwnPropertySymbols:function(e){return x.f(m(e))}}),H&&r({target:"JSON",stat:!0,forced:!l||u((function(){var e=G();return"[null]"!=H([e])||"{}"!=H({a:e})||"{}"!=H(Object(e))}))},{stringify:function(e,t,n){for(var r,i=[e],o=1;arguments.length>o;)i.push(arguments[o++]);if(r=t,(p(t)||void 0!==e)&&!oe(e))return h(t)||(t=function(e,t){if("function"==typeof r&&(t=r.call(this,e,t)),!oe(t))return t}),i[1]=t,H.apply(null,i)}}),G.prototype[j]||T(G.prototype,j,G.prototype.valueOf),R(G,"Symbol"),O[B]=!0},function(e,t,n){"use strict";var r=n(4),i=n(16),o=n(11),a=n(14),s=n(13),l=n(15).f,c=n(119),u=o.Symbol;if(i&&"function"==typeof u&&(!("description"in u.prototype)||void 0!==u().description)){var d={},h=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:String(arguments[0]),t=this instanceof h?new u(e):void 0===e?u():u(e);return""===e&&(d[t]=!0),t};c(h,u);var p=h.prototype=u.prototype;p.constructor=h;var f=p.toString,m="Symbol(test)"==String(u("test")),g=/^Symbol\((.*)\)[^)]+$/;l(p,"description",{configurable:!0,get:function(){var e=s(this)?this.valueOf():this,t=f.call(e);if(a(d,e))return"";var n=m?t.slice(7,-1):t.replace(g,"$1");return""===n?void 0:n}}),r({global:!0,forced:!0},{Symbol:h})}},function(e,t,n){n(126)("iterator")},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var a=n(6),s=n(2),l=n(70),c=n(3),u=n(9),d=n(0),h=n(152),p=n(12),f=function(e){function t(){var t=e.call(this)||this;return t._parent=null,t._firstChild=null,t._lastChild=null,t._previousSibling=null,t._nextSibling=null,t}return i(t,e),Object.defineProperty(t.prototype,"_childNodes",{get:function(){return this.__childNodes||(this.__childNodes=d.create_nodeList(this))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_nodeDocument",{get:function(){return this._nodeDocumentOverride||a.dom.window._associatedDocument},set:function(e){this._nodeDocumentOverride=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_registeredObserverList",{get:function(){return this.__registeredObserverList||(this.__registeredObserverList=[])},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nodeType",{get:function(){return this._nodeType},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nodeName",{get:function(){return c.Guard.isElementNode(this)?this._htmlUppercasedQualifiedName:c.Guard.isAttrNode(this)?this._qualifiedName:c.Guard.isExclusiveTextNode(this)?"#text":c.Guard.isCDATASectionNode(this)?"#cdata-section":c.Guard.isProcessingInstructionNode(this)?this._target:c.Guard.isCommentNode(this)?"#comment":c.Guard.isDocumentNode(this)?"#document":c.Guard.isDocumentTypeNode(this)?this._name:c.Guard.isDocumentFragmentNode(this)?"#document-fragment":""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"baseURI",{get:function(){return h.urlSerializer(this._nodeDocument._URL)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isConnected",{get:function(){return c.Guard.isElementNode(this)&&d.shadowTree_isConnected(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ownerDocument",{get:function(){return this._nodeType===s.NodeType.Document?null:this._nodeDocument},enumerable:!0,configurable:!0}),t.prototype.getRootNode=function(e){return d.tree_rootNode(this,!!e&&e.composed)},Object.defineProperty(t.prototype,"parentNode",{get:function(){return this._nodeType===s.NodeType.Attribute?null:this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parentElement",{get:function(){return this._parent&&c.Guard.isElementNode(this._parent)?this._parent:null},enumerable:!0,configurable:!0}),t.prototype.hasChildNodes=function(){return null!==this._firstChild},Object.defineProperty(t.prototype,"childNodes",{get:function(){return this._childNodes},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"firstChild",{get:function(){return this._firstChild},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lastChild",{get:function(){return this._lastChild},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"previousSibling",{get:function(){return this._previousSibling},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nextSibling",{get:function(){return this._nextSibling},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nodeValue",{get:function(){return c.Guard.isAttrNode(this)?this._value:c.Guard.isCharacterDataNode(this)?this._data:null},set:function(e){null===e&&(e=""),c.Guard.isAttrNode(this)?d.attr_setAnExistingAttributeValue(this,e):c.Guard.isCharacterDataNode(this)&&d.characterData_replaceData(this,0,this._data.length,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textContent",{get:function(){return c.Guard.isDocumentFragmentNode(this)||c.Guard.isElementNode(this)?d.text_descendantTextContent(this):c.Guard.isAttrNode(this)?this._value:c.Guard.isCharacterDataNode(this)?this._data:null},set:function(e){null===e&&(e=""),c.Guard.isDocumentFragmentNode(this)||c.Guard.isElementNode(this)?d.node_stringReplaceAll(e,this):c.Guard.isAttrNode(this)?d.attr_setAnExistingAttributeValue(this,e):c.Guard.isCharacterDataNode(this)&&d.characterData_replaceData(this,0,d.tree_nodeLength(this),e)},enumerable:!0,configurable:!0}),t.prototype.normalize=function(){for(var e,t,n,r,i=[],s=d.tree_getFirstDescendantNode(this,!1,!1,(function(e){return c.Guard.isExclusiveTextNode(e)}));null!==s;)i.push(s),s=d.tree_getNextDescendantNode(this,s,!1,!1,(function(e){return c.Guard.isExclusiveTextNode(e)}));for(var l=0;lx;x++)if((h||x in b)&&(y=E(v=b[x],x,_),e))if(t)D[x]=y;else if(y)switch(e){case 3:return!0;case 5:return v;case 6:return x;case 2:l.call(D,v)}else if(u)return!1;return d?-1:c||u?u:D}};e.exports={forEach:c(0),map:c(1),filter:c(2),some:c(3),every:c(4),find:c(5),findIndex:c(6)}},function(e,t,n){"use strict";var r=this&&this.__values||function(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.")},i=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},o=this&&this.__spread||function(){for(var e=[],t=0;t1)throw new s.HierarchyRequestError("A document node can only have one document element node. Document fragment to be inserted has "+y+" element nodes.");if(1===y){try{for(var w=r(t._children),x=w.next();!x.done;x=w.next())if(x.value._nodeType===l.NodeType.Element)throw new s.HierarchyRequestError("The document node already has a document element node.")}catch(e){a={error:e}}finally{try{x&&!x.done&&(c=w.return)&&c.call(w)}finally{if(a)throw a.error}}if(n){if(v===l.NodeType.DocumentType)throw new s.HierarchyRequestError("Cannot insert an element node before a document type node.");for(var C=n._nextSibling;C;){if(C._nodeType===l.NodeType.DocumentType)throw new s.HierarchyRequestError("Cannot insert an element node before a document type node.");C=C._nextSibling}}}}else if(g===l.NodeType.Element){try{for(var D=r(t._children),S=D.next();!S.done;S=D.next())if(S.value._nodeType===l.NodeType.Element)throw new s.HierarchyRequestError("Document already has a document element node. Node is "+e.nodeName+".")}catch(e){u={error:e}}finally{try{S&&!S.done&&(d=D.return)&&d.call(D)}finally{if(u)throw u.error}}if(n){if(v===l.NodeType.DocumentType)throw new s.HierarchyRequestError("Cannot insert an element node before a document type node. Node is "+e.nodeName+".");for(C=n._nextSibling;C;){if(C._nodeType===l.NodeType.DocumentType)throw new s.HierarchyRequestError("Cannot insert an element node before a document type node. Node is "+e.nodeName+".");C=C._nextSibling}}}else if(g===l.NodeType.DocumentType){try{for(var T=r(t._children),I=T.next();!I.done;I=T.next())if(I.value._nodeType===l.NodeType.DocumentType)throw new s.HierarchyRequestError("Document already has a document type node. Node is "+e.nodeName+".")}catch(e){h={error:e}}finally{try{I&&!I.done&&(f=T.return)&&f.call(T)}finally{if(h)throw h.error}}if(n)for(var A=n._previousSibling;A;){if(A._nodeType===l.NodeType.Element)throw new s.HierarchyRequestError("Cannot insert a document type node before an element node. Node is "+e.nodeName+".");A=A._previousSibling}else for(A=t._firstChild;A;){if(A._nodeType===l.NodeType.Element)throw new s.HierarchyRequestError("Cannot insert a document type node before an element node. Node is "+e.nodeName+".");A=A._nextSibling}}}function b(e,t,n){_(e,t,n);var r=n;return r===e&&(r=e._nextSibling),y.document_adopt(e,t._nodeDocument),E(e,t,r),e}function E(e,t,n,i){var s,f;if(null!==n||e._nodeType===l.NodeType.DocumentFragment){var y=e._nodeType===l.NodeType.DocumentFragment?e._children.size:1;if(null!==n&&0!==a.dom.rangeList.size){var _=p.tree_index(n);try{for(var b=r(a.dom.rangeList),E=b.next();!E.done;E=b.next()){var x=E.value;x._start[0]===t&&x._start[1]>_&&(x._start[1]+=y),x._end[0]===t&&x._end[1]>_&&(x._end[1]+=y)}}catch(e){s={error:e}}finally{try{E&&!E.done&&(f=b.return)&&f.call(b)}finally{if(s)throw s.error}}}var C=e._nodeType===l.NodeType.DocumentFragment?new(Array.bind.apply(Array,o([void 0],e._children))):[e];if(e._nodeType===l.NodeType.DocumentFragment)for(;e._firstChild;)w(e._firstChild,e,!0);a.dom.features.mutationObservers&&e._nodeType===l.NodeType.DocumentFragment&&g.observer_queueTreeMutationRecord(e,[],C,null,null);for(var D=n?n._previousSibling:t._lastChild,S=null===n?-1:p.tree_index(n),T=0;TE&&C._start[1]--,C._end[0]===t&&C._end[1]>E&&C._end[1]--}}catch(e){i={error:e}}finally{try{x&&!x.done&&(o=w.return)&&o.call(w)}finally{if(i)throw i.error}}try{for(var D=r(a.dom.rangeList),S=D.next();!S.done;S=D.next())(C=S.value)._start[0]===t&&C._start[1]>E&&(C._start[1]-=1),C._end[0]===t&&C._end[1]>E&&(C._end[1]-=1)}catch(e){s={error:e}}finally{try{S&&!S.done&&(l=D.return)&&l.call(D)}finally{if(s)throw s.error}}}if(a.dom.features.steps)try{for(var T=r(f.nodeIterator_iteratorList()),I=T.next();!I.done;I=T.next()){var A=I.value;A._root._nodeDocument===e._nodeDocument&&v.dom_runNodeIteratorPreRemovingSteps(A,e)}}catch(e){d={error:e}}finally{try{I&&!I.done&&(y=T.return)&&y.call(T)}finally{if(d)throw d.error}}var N=e._previousSibling,O=e._nextSibling;c.Guard.isDocumentNode(t)&&c.Guard.isElementNode(e)&&(t._documentElement=null),e._parent=null,t._children.delete(e);var P=e._previousSibling,k=e._nextSibling;e._previousSibling=null,e._nextSibling=null,P&&(P._nextSibling=k),k&&(k._previousSibling=P),P||(t._firstChild=k),k||(t._lastChild=P),a.dom.features.slots&&c.Guard.isSlotable(e)&&null!==e._assignedSlot&&m.shadowTree_isAssigned(e)&&m.shadowTree_assignSlotables(e._assignedSlot),a.dom.features.slots&&c.Guard.isShadowRoot(p.tree_rootNode(t))&&c.Guard.isSlot(t)&&u.isEmpty(t._assignedNodes)&&m.shadowTree_signalASlotChange(t),a.dom.features.slots&&null!==p.tree_getFirstDescendantNode(e,!0,!1,(function(e){return c.Guard.isSlot(e)}))&&(m.shadowTree_assignSlotablesForATree(p.tree_rootNode(t)),m.shadowTree_assignSlotablesForATree(e)),a.dom.features.steps&&v.dom_runRemovingSteps(e,t),a.dom.features.customElements&&c.Guard.isCustomElementNode(e)&&h.customElement_enqueueACustomElementCallbackReaction(e,"disconnectedCallback",[]);for(var M=p.tree_getFirstDescendantNode(e,!1,!0);null!==M;)a.dom.features.steps&&v.dom_runRemovingSteps(M,e),a.dom.features.customElements&&c.Guard.isCustomElementNode(M)&&h.customElement_enqueueACustomElementCallbackReaction(M,"disconnectedCallback",[]),M=p.tree_getNextDescendantNode(e,M,!1,!0);if(a.dom.features.mutationObservers)for(var L=p.tree_getFirstAncestorNode(t,!0);null!==L;){try{for(var R=(_=void 0,r(L._registeredObserverList)),F=R.next();!F.done;F=R.next()){var U=F.value;U.options.subtree&&e._registeredObserverList.push({observer:U.observer,options:U.options,source:U})}}catch(e){_={error:e}}finally{try{F&&!F.done&&(b=R.return)&&b.call(R)}finally{if(_)throw _.error}}L=p.tree_getNextAncestorNode(t,L,!0)}a.dom.features.mutationObservers&&(n||g.observer_queueTreeMutationRecord(t,[],[e],N,O)),a.dom.features.steps&&c.Guard.isTextNode(e)&&v.dom_runChildTextContentChangeSteps(t)}t.mutation_ensurePreInsertionValidity=_,t.mutation_preInsert=b,t.mutation_insert=E,t.mutation_append=function(e,t){return b(e,t,null)},t.mutation_replace=function(e,t,n){var i,o,c,u,d,h,f,m;if(n._nodeType!==l.NodeType.Document&&n._nodeType!==l.NodeType.DocumentFragment&&n._nodeType!==l.NodeType.Element)throw new s.HierarchyRequestError("Only document, document fragment and element nodes can contain child nodes. Parent node is "+n.nodeName+".");if(p.tree_isHostIncludingAncestorOf(n,t,!0))throw new s.HierarchyRequestError("The node to be inserted cannot be an ancestor of parent node. Node is "+t.nodeName+", parent node is "+n.nodeName+".");if(e._parent!==n)throw new s.NotFoundError("The reference child node cannot be found under parent node. Child node is "+e.nodeName+", parent node is "+n.nodeName+".");if(t._nodeType!==l.NodeType.DocumentFragment&&t._nodeType!==l.NodeType.DocumentType&&t._nodeType!==l.NodeType.Element&&t._nodeType!==l.NodeType.Text&&t._nodeType!==l.NodeType.ProcessingInstruction&&t._nodeType!==l.NodeType.CData&&t._nodeType!==l.NodeType.Comment)throw new s.HierarchyRequestError("Only document fragment, document type, element, text, processing instruction, cdata section or comment nodes can be inserted. Node is "+t.nodeName+".");if(t._nodeType===l.NodeType.Text&&n._nodeType===l.NodeType.Document)throw new s.HierarchyRequestError("Cannot insert a text node as a child of a document node. Node is "+t.nodeName+".");if(t._nodeType===l.NodeType.DocumentType&&n._nodeType!==l.NodeType.Document)throw new s.HierarchyRequestError("A document type node can only be inserted under a document node. Parent node is "+n.nodeName+".");if(n._nodeType===l.NodeType.Document)if(t._nodeType===l.NodeType.DocumentFragment){var v=0;try{for(var _=r(t._children),b=_.next();!b.done;b=_.next()){var x=b.value;if(x._nodeType===l.NodeType.Element)v++;else if(x._nodeType===l.NodeType.Text)throw new s.HierarchyRequestError("Cannot insert text a node as a child of a document node. Node is "+x.nodeName+".")}}catch(e){i={error:e}}finally{try{b&&!b.done&&(o=_.return)&&o.call(_)}finally{if(i)throw i.error}}if(v>1)throw new s.HierarchyRequestError("A document node can only have one document element node. Document fragment to be inserted has "+v+" element nodes.");if(1===v){try{for(var C=r(n._children),D=C.next();!D.done;D=C.next())if((O=D.value)._nodeType===l.NodeType.Element&&O!==e)throw new s.HierarchyRequestError("The document node already has a document element node.")}catch(e){c={error:e}}finally{try{D&&!D.done&&(u=C.return)&&u.call(C)}finally{if(c)throw c.error}}for(var S=e._nextSibling;S;){if(S._nodeType===l.NodeType.DocumentType)throw new s.HierarchyRequestError("Cannot insert an element node before a document type node.");S=S._nextSibling}}}else if(t._nodeType===l.NodeType.Element){try{for(var T=r(n._children),I=T.next();!I.done;I=T.next())if((O=I.value)._nodeType===l.NodeType.Element&&O!==e)throw new s.HierarchyRequestError("Document already has a document element node. Node is "+t.nodeName+".")}catch(e){d={error:e}}finally{try{I&&!I.done&&(h=T.return)&&h.call(T)}finally{if(d)throw d.error}}for(S=e._nextSibling;S;){if(S._nodeType===l.NodeType.DocumentType)throw new s.HierarchyRequestError("Cannot insert an element node before a document type node. Node is "+t.nodeName+".");S=S._nextSibling}}else if(t._nodeType===l.NodeType.DocumentType){try{for(var A=r(n._children),N=A.next();!N.done;N=A.next()){var O;if((O=N.value)._nodeType===l.NodeType.DocumentType&&O!==e)throw new s.HierarchyRequestError("Document already has a document type node. Node is "+t.nodeName+".")}}catch(e){f={error:e}}finally{try{N&&!N.done&&(m=A.return)&&m.call(A)}finally{if(f)throw f.error}}for(var P=e._previousSibling;P;){if(P._nodeType===l.NodeType.Element)throw new s.HierarchyRequestError("Cannot insert a document type node before an element node. Node is "+t.nodeName+".");P=P._previousSibling}}var k=e._nextSibling;k===t&&(k=t._nextSibling);var M=e._previousSibling;y.document_adopt(t,n._nodeDocument);var L=[];null!==e._parent&&(L.push(e),w(e,e._parent,!0));var R=[];return t._nodeType===l.NodeType.DocumentFragment?R=Array.from(t._children):R.push(t),E(t,n,k,!0),a.dom.features.mutationObservers&&g.observer_queueTreeMutationRecord(n,R,L,M,k),e},t.mutation_replaceAll=function(e,t){var n,i;null!==e&&y.document_adopt(e,t._nodeDocument);var o=Array.from(t._children),s=[];e&&e._nodeType===l.NodeType.DocumentFragment?s=Array.from(e._children):null!==e&&s.push(e);try{for(var c=r(o),u=c.next();!u.done;u=c.next())w(u.value,t,!0)}catch(e){n={error:e}}finally{try{u&&!u.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}null!==e&&E(e,t,null,!0),a.dom.features.mutationObservers&&g.observer_queueTreeMutationRecord(t,s,o,null,null)},t.mutation_preRemove=function(e,t){if(e._parent!==t)throw new s.NotFoundError("The child node cannot be found under parent node. Child node is "+e.nodeName+", parent node is "+t.nodeName+".");return w(e,t),e},t.mutation_remove=w},function(e,t,n){"use strict";function r(e){return null==e}e.exports.isNothing=r,e.exports.isObject=function(e){return"object"==typeof e&&null!==e},e.exports.toArray=function(e){return Array.isArray(e)?e:r(e)?[]:[e]},e.exports.repeat=function(e,t){var n,r="";for(n=0;n0?r:n)(e)}},function(e,t,n){"use strict";var r=n(8);e.exports=function(e,t){var n=[][e];return!!n&&r((function(){n.call(null,t||function(){throw 1},1)}))}},function(e,t){e.exports={}},function(e,t,n){"use strict";n(31),n(32),n(33),n(220),n(64),n(19),n(65),n(20),n(68),n(66),n(92),n(144),n(22),n(94),n(23);var r=this&&this.__values||function(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.")},i=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},o=this&&this.__spread||function(){for(var e=[],t=0;t/g,">");this.text(n)},e.prototype._serializeDocumentFragmentNS=function(e,t,n,i,o){var a,s;try{for(var l=r(e.childNodes),c=l.next();!c.done;c=l.next()){var u=c.value;this._serializeNodeNS(u,t,n,i,o)}}catch(e){a={error:e}}finally{try{c&&!c.done&&(s=l.return)&&s.call(l)}finally{if(a)throw a.error}}},e.prototype._serializeDocumentFragment=function(e,t){var n,i;try{for(var o=r(e._children),a=o.next();!a.done;a=o.next()){var s=a.value;this._serializeNode(s,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},e.prototype._serializeDocumentType=function(e,t){if(t&&!u.xml_isPubidChar(e.publicId))throw new Error("DocType public identifier does not match PubidChar construct (well-formed required).");if(t&&(!u.xml_isLegalChar(e.systemId)||-1!==e.systemId.indexOf('"')&&-1!==e.systemId.indexOf("'")))throw new Error("DocType system identifier contains invalid characters (well-formed required).");this.docType(e.name,e.publicId,e.systemId)},e.prototype._serializeProcessingInstruction=function(e,t){if(t&&(-1!==e.target.indexOf(":")||/^xml$/i.test(e.target)))throw new Error("Processing instruction target contains invalid characters (well-formed required).");if(t&&(!u.xml_isLegalChar(e.data)||-1!==e.data.indexOf("?>")))throw new Error("Processing instruction data contains invalid characters (well-formed required).");this.instruction(e.target,e.data)},e.prototype._serializeCData=function(e,t){if(t&&-1!==e.data.indexOf("]]>"))throw new Error("CDATA contains invalid characters (well-formed required).");this.cdata(e.data)},e.prototype._serializeAttributesNS=function(e,t,n,i,o,a){var l,d,h=[],p=a?new s.LocalNameSet:void 0;try{for(var f=r(e.attributes),m=f.next();!m.done;m=f.next()){var g=m.value;if(a||o||null!==g.namespaceURI){if(a&&p&&p.has(g.namespaceURI,g.localName))throw new Error("Element contains duplicate attributes (well-formed required).");a&&p&&p.set(g.namespaceURI,g.localName);var v=g.namespaceURI,y=null;if(null!==v)if(y=t.get(g.prefix,v),v===c.namespace.XMLNS){if(g.value===c.namespace.XML||null===g.prefix&&o||null!==g.prefix&&(!(g.localName in i)||i[g.localName]!==g.value)&&t.has(g.localName,g.value))continue;if(a&&g.value===c.namespace.XMLNS)throw new Error("XMLNS namespace is reserved (well-formed required).");if(a&&""===g.value)throw new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required).");"xmlns"===g.prefix&&(y="xmlns")}else null===y&&(y=null===g.prefix||t.hasPrefix(g.prefix)&&!t.has(g.prefix,v)?this._generatePrefix(v,t,n):g.prefix,h.push([null,"xmlns",y,this._serializeAttributeValue(v,a)]));if(a&&(-1!==g.localName.indexOf(":")||!u.xml_isName(g.localName)||"xmlns"===g.localName&&null===v))throw new Error("Attribute local name contains invalid characters (well-formed required).");h.push([v,y,g.localName,this._serializeAttributeValue(g.value,a)])}else h.push([null,null,g.localName,this._serializeAttributeValue(g.value,a)])}}catch(e){l={error:e}}finally{try{m&&!m.done&&(d=f.return)&&d.call(f)}finally{if(l)throw l.error}}return h},e.prototype._serializeAttributes=function(e,t){var n,i,o=[],a=t?{}:void 0;try{for(var s=r(e.attributes),l=s.next();!l.done;l=s.next()){var c=l.value;if(t){if(t&&a&&c.localName in a)throw new Error("Element contains duplicate attributes (well-formed required).");if(t&&a&&(a[c.localName]=!0),t&&(-1!==c.localName.indexOf(":")||!u.xml_isName(c.localName)))throw new Error("Attribute local name contains invalid characters (well-formed required).");o.push([null,null,c.localName,this._serializeAttributeValue(c.value,t)])}else o.push([null,null,c.localName,this._serializeAttributeValue(c.value,t)])}}catch(e){n={error:e}}finally{try{l&&!l.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}return o},e.prototype._recordNamespaceInformation=function(e,t,n){var i,o,a=null;try{for(var s=r(e.attributes),l=s.next();!l.done;l=s.next()){var u=l.value,d=u.namespaceURI,h=u.prefix;if(d===c.namespace.XMLNS){if(null===h){a=u.value;continue}var p=u.localName,f=u.value;if(f===c.namespace.XML)continue;if(""===f&&(f=null),t.has(p,f))continue;t.set(p,f),n[p]=f||""}}}catch(e){i={error:e}}finally{try{l&&!l.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}return a},e.prototype._generatePrefix=function(e,t,n){var r="ns"+n.value.toString();return n.value++,t.set(r,e),r},e.prototype._serializeAttributeValue=function(e,t){if(t&&null!==e&&!u.xml_isLegalChar(e))throw new Error("Invalid characters in attribute value.");return null===e?"":e.replace(/(?!&([^&;]*);)&/g,"&").replace(//g,">").replace(/"/g,""")},e._VoidElementNames=new Set(["area","base","basefont","bgsound","br","col","embed","frame","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),e}();t.BaseWriter=d},function(e,t,n){"use strict";var r=this&&this.__values||function(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.")},i=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 o=n(6),a=n(3),s=n(7),l=n(29),c=n(17),u=n(97);function d(){var e=o.dom.window;e._mutationObserverMicrotaskQueued||(e._mutationObserverMicrotaskQueued=!0,Promise.resolve().then((function(){h()})))}function h(){var e,t,n,i,l=o.dom.window;l._mutationObserverMicrotaskQueued=!1;var c=s.set.clone(l._mutationObservers),d=s.set.clone(l._signalSlots);s.set.empty(l._signalSlots);var h=function(e){var t=s.list.clone(e._recordQueue);s.list.empty(e._recordQueue);for(var n=0;n"+e+"<\/script>"},p=function(){try{r=document.domain&&new ActiveXObject("htmlfile")}catch(e){}var e,t;p=r?function(e){e.write(h("")),e.close();var t=e.parentWindow.Object;return e=null,t}(r):((t=c("iframe")).style.display="none",l.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(h("document.F=Object")),e.close(),e.F);for(var n=a.length;n--;)delete p.prototype[a[n]];return p()};s[u]=!0,e.exports=Object.create||function(e,t){var n;return null!==e?(d.prototype=i(e),n=new d,d.prototype=null,n[u]=e):n=p(),void 0===t?n:o(n,t)}},function(e,t,n){var r=n(121),i=n(84);e.exports=Object.keys||function(e){return r(e,i)}},function(e,t,n){var r=n(15).f,i=n(14),o=n(5)("toStringTag");e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,o)&&r(e,o,{configurable:!0,value:t})}},function(e,t,n){var r=n(8),i=n(5),o=n(129),a=i("species");e.exports=function(e){return o>=51||!r((function(){var t=[];return(t.constructor={})[a]=function(){return{foo:1}},1!==t[e](Boolean).foo}))}},function(e,t,n){"use strict";var r=n(4),i=n(122).indexOf,o=n(48),a=n(28),s=[].indexOf,l=!!s&&1/[1].indexOf(1,-0)<0,c=o("indexOf"),u=a("indexOf",{ACCESSORS:!0,1:0});r({target:"Array",proto:!0,forced:l||!c||!u},{indexOf:function(e){return l?s.apply(this,arguments)||0:i(this,e,arguments.length>1?arguments[1]:void 0)}})},function(e,t,n){var r=n(16),i=n(15).f,o=Function.prototype,a=o.toString,s=/^\s*function ([^ (]*)/;r&&!("name"in o)&&i(o,"name",{configurable:!0,get:function(){try{return a.call(this).match(s)[1]}catch(e){return""}}})},function(e,t,n){"use strict";var r=n(25),i=n(18),o=n(8),a=n(136),s=RegExp.prototype,l=s.toString,c=o((function(){return"/a/b"!=l.call({source:"a",flags:"b"})})),u="toString"!=l.name;(c||u)&&r(RegExp.prototype,"toString",(function(){var e=i(this),t=String(e.source),n=e.flags;return"/"+t+"/"+String(void 0===n&&e instanceof RegExp&&!("flags"in s)?a.call(e):n)}),{unsafe:!0})},function(e,t,n){"use strict";n(31),n(32),n(33),n(19),n(138),n(20),n(66),n(22),n(23);var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var a=n(1),s=n(2),l=function(e){function t(t,n){var r=e.call(this,t)||this;return r._writerOptions=a.applyDefaults(n,{format:"object",wellFormed:!1,group:!1,verbose:!1}),r}return i(t,e),t.prototype.serialize=function(e){return this._currentList=[],this._currentIndex=0,this._listRegister=[this._currentList],this.serializeNode(e,this._writerOptions.wellFormed),this._process(this._currentList,this._writerOptions)},t.prototype._process=function(e,t){var n,r,i,o,l,c,u;if(0===e.length)return{};for(var d={},h=!1,p=0,f=0,m=0,g=0,v=0;v2)try{for(var u=o(e),d=u.next();!d.done;d=u.next()){var h=d.value;t[r+(s++).toString()]=h}}catch(e){l={error:e}}finally{try{d&&!d.done&&(c=u.return)&&c.call(u)}finally{if(l)throw l.error}}else t[i>1?r+(s++).toString():r]=e;return s},t.prototype.beginElement=function(e){var t,n,r=[];if(0===this._currentList.length)this._currentList.push(((t={})[e]=r,t));else{var i=this._currentList[this._currentList.length-1];this._isElementNode(i,e)?0!==i[e].length&&a.isArray(i[e][0])?i[e].push(r):i[e]=[i[e],r]:this._currentList.push(((n={})[e]=r,n))}this._currentIndex++,this._listRegister.length>this._currentIndex?this._listRegister[this._currentIndex]=r:this._listRegister.push(r),this._currentList=r},t.prototype.endElement=function(){this._currentList=this._listRegister[--this._currentIndex]},t.prototype.attribute=function(e,t){var n,r;if(0===this._currentList.length)this._currentList.push({"@":(n={},n[e]=t,n)});else{var i=this._currentList[this._currentList.length-1];this._isAttrNode(i)?i["@"][e]=t:this._currentList.push({"@":(r={},r[e]=t,r)})}},t.prototype.comment=function(e){if(0===this._currentList.length)this._currentList.push({"!":e});else{var t=this._currentList[this._currentList.length-1];this._isCommentNode(t)?a.isArray(t["!"])?t["!"].push(e):t["!"]=[t["!"],e]:this._currentList.push({"!":e})}},t.prototype.text=function(e){if(0===this._currentList.length)this._currentList.push({"#":e});else{var t=this._currentList[this._currentList.length-1];this._isTextNode(t)?a.isArray(t["#"])?t["#"].push(e):t["#"]=[t["#"],e]:this._currentList.push({"#":e})}},t.prototype.instruction=function(e,t){var n=""===t?e:e+" "+t;if(0===this._currentList.length)this._currentList.push({"?":n});else{var r=this._currentList[this._currentList.length-1];this._isInstructionNode(r)?a.isArray(r["?"])?r["?"].push(n):r["?"]=[r["?"],n]:this._currentList.push({"?":n})}},t.prototype.cdata=function(e){if(0===this._currentList.length)this._currentList.push({$:e});else{var t=this._currentList[this._currentList.length-1];this._isCDATANode(t)?a.isArray(t.$)?t.$.push(e):t.$=[t.$,e]:this._currentList.push({$:e})}},t.prototype._isAttrNode=function(e){return"@"in e},t.prototype._isTextNode=function(e){return"#"in e},t.prototype._isCommentNode=function(e){return"!"in e},t.prototype._isInstructionNode=function(e){return"?"in e},t.prototype._isCDATANode=function(e){return"$"in e},t.prototype._isElementNode=function(e,t){return t in e},t.prototype._getAttrKey=function(){return this._builderOptions.convert.att},t.prototype._getNodeKey=function(e){switch(e){case s.NodeType.Comment:return this._builderOptions.convert.comment;case s.NodeType.Text:return this._builderOptions.convert.text;case s.NodeType.ProcessingInstruction:return this._builderOptions.convert.ins;case s.NodeType.CData:return this._builderOptions.convert.cdata;default:throw new Error("Invalid node type.")}},t}(n(50).BaseWriter);t.ObjectWriter=l},function(e,t,n){"use strict";var r=n(4),i=n(93);r({target:"RegExp",proto:!0,forced:/./.exec!==i},{exec:i})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){this._items={},this._nullItems={}}return e.prototype.set=function(e,t){null===e?this._nullItems[t]=!0:(this._items[e]||(this._items[e]={}),this._items[e][t]=!0)},e.prototype.has=function(e,t){return null===e?!0===this._nullItems[t]:!!this._items[e]&&!0===this._items[e][t]},e}();t.LocalNameSet=r},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(9),o=n(3),a=n(0),s=function(){function e(){}return Object.defineProperty(e.prototype,"_eventListenerList",{get:function(){return this.__eventListenerList||(this.__eventListenerList=[])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_eventHandlerMap",{get:function(){return this.__eventHandlerMap||(this.__eventHandlerMap={})},enumerable:!0,configurable:!0}),e.prototype.addEventListener=function(e,t,n){void 0===n&&(n={passive:!1,once:!1,capture:!1});var i,s=r(a.eventTarget_flattenMore(n),3),l=s[0],c=s[1],u=s[2];t&&(i=o.Guard.isEventListener(t)?t:{handleEvent:t},a.eventTarget_addEventListener(this,{type:e,callback:i,capture:l,passive:c,once:u,removed:!1}))},e.prototype.removeEventListener=function(e,t,n){void 0===n&&(n={capture:!1});var r=a.eventTarget_flatten(n);if(t)for(var i=0;i=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},i=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},o=this&&this.__spread||function(){for(var e=[],t=0;t",amp:"&",quot:'"',apos:"'"},e}();t.BaseReader=i},function(e,t,n){"use strict";var r=n(39);e.exports=r.DEFAULT=new r({include:[n(54)],explicit:[n(299),n(300),n(301)]})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(185);t.XMLBuilderImpl=r.XMLBuilderImpl;var i=n(304);t.XMLBuilderCBImpl=i.XMLBuilderCBImpl;var o=n(183);t.builder=o.builder,t.create=o.create,t.fragment=o.fragment,t.convert=o.convert;var a=n(309);t.createCB=a.createCB,t.fragmentCB=a.fragmentCB},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";var r={}.propertyIsEnumerable,i=Object.getOwnPropertyDescriptor,o=i&&!r.call({1:2},1);t.f=o?function(e){var t=i(this,e);return!!t&&t.enumerable}:r},function(e,t,n){var r=n(11),i=n(21);e.exports=function(e,t){try{i(r,e,t)}catch(n){r[e]=t}return t}},function(e,t,n){var r=n(44),i=n(118);(e.exports=function(e,t){return i[e]||(i[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.6.5",mode:r?"pure":"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})},function(e,t,n){var r=n(121),i=n(84).concat("length","prototype");t.f=Object.getOwnPropertyNames||function(e){return r(e,i)}},function(e,t,n){var r=n(47),i=Math.max,o=Math.min;e.exports=function(e,t){var n=r(e);return n<0?i(n+t,0):o(n,t)}},function(e,t){e.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},function(e,t){t.f=Object.getOwnPropertySymbols},function(e,t,n){var r=n(8);e.exports=!!Object.getOwnPropertySymbols&&!r((function(){return!String(Symbol())}))},function(e,t,n){var r=n(127);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 0:return function(){return e.call(t)};case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t,n){"use strict";var r=n(4),i=n(195),o=n(132),a=n(133),s=n(62),l=n(21),c=n(25),u=n(5),d=n(44),h=n(49),p=n(131),f=p.IteratorPrototype,m=p.BUGGY_SAFARI_ITERATORS,g=u("iterator"),v=function(){return this};e.exports=function(e,t,n,u,p,y,_){i(n,t,u);var b,E,w,x=function(e){if(e===p&&I)return I;if(!m&&e in S)return S[e];switch(e){case"keys":case"values":case"entries":return function(){return new n(this,e)}}return function(){return new n(this)}},C=t+" Iterator",D=!1,S=e.prototype,T=S[g]||S["@@iterator"]||p&&S[p],I=!m&&T||x(p),A="Array"==t&&S.entries||T;if(A&&(b=o(A.call(new e)),f!==Object.prototype&&b.next&&(d||o(b)===f||(a?a(b,f):"function"!=typeof b[g]&&l(b,g,v)),s(b,C,!0,!0),d&&(h[C]=v))),"values"==p&&T&&"values"!==T.name&&(D=!0,I=function(){return T.call(this)}),d&&!_||S[g]===I||l(S,g,I),h[t]=I,p)if(E={values:x("values"),keys:y?I:x("keys"),entries:x("entries")},_)for(w in E)(m||D||!(w in S))&&c(S,w,E[w]);else r({target:t,proto:!0,forced:m||D},E);return E}},function(e,t,n){"use strict";var r=n(4),i=n(13),o=n(59),a=n(83),s=n(26),l=n(24),c=n(134),u=n(5),d=n(63),h=n(28),p=d("slice"),f=h("slice",{ACCESSORS:!0,0:0,1:2}),m=u("species"),g=[].slice,v=Math.max;r({target:"Array",proto:!0,forced:!p||!f},{slice:function(e,t){var n,r,u,d=l(this),h=s(d.length),p=a(e,h),f=a(void 0===t?h:t,h);if(o(d)&&("function"!=typeof(n=d.constructor)||n!==Array&&!o(n.prototype)?i(n)&&null===(n=n[m])&&(n=void 0):n=void 0,n===Array||void 0===n))return g.call(d,p,f);for(r=new(void 0===n?Array:n)(v(f-p,0)),u=0;p0&&(!a.multiline||a.multiline&&"\n"!==e[a.lastIndex-1])&&(f="(?: "+f+")",g=" "+g,m++),n=new RegExp("^(?:"+f+")",p)),h&&(n=new RegExp("^"+f+"$(?!\\s)",p)),u&&(t=a.lastIndex),r=s.call(c?n:a,g),c?r?(r.input=r.input.slice(m),r[0]=r[0].slice(m),r.index=a.lastIndex,a.lastIndex+=r[0].length):a.lastIndex=0:u&&r&&(a.lastIndex=a.global?r.index+r[0].length:t),h&&r&&r.length>1&&l.call(r[0],n,(function(){for(i=1;i]*>)/g,m=/\$([$&'`]|\d\d?)/g;r("replace",2,(function(e,t,n,r){var g=r.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE,v=r.REPLACE_KEEPS_$0,y=g?"$":"$0";return[function(n,r){var i=l(this),o=null==n?void 0:n[e];return void 0!==o?o.call(n,i,r):t.call(String(i),n,r)},function(e,r){if(!g&&v||"string"==typeof r&&-1===r.indexOf(y)){var o=n(t,e,this,r);if(o.done)return o.value}var l=i(e),p=String(this),f="function"==typeof r;f||(r=String(r));var m=l.global;if(m){var b=l.unicode;l.lastIndex=0}for(var E=[];;){var w=u(l,p);if(null===w)break;if(E.push(w),!m)break;""===String(w[0])&&(l.lastIndex=c(p,a(l.lastIndex),b))}for(var x,C="",D=0,S=0;S=D&&(C+=p.slice(D,I)+k,D=I+T.length)}return C+p.slice(D)}];function _(e,n,r,i,a,s){var l=r+e.length,c=i.length,u=m;return void 0!==a&&(a=o(a),u=f),t.call(s,u,(function(t,o){var s;switch(o.charAt(0)){case"$":return"$";case"&":return e;case"`":return n.slice(0,r);case"'":return n.slice(l);case"<":s=a[o.slice(1,-1)];break;default:var u=+o;if(0===u)return t;if(u>c){var d=p(u/10);return 0===d?t:d<=c?void 0===i[d-1]?o.charAt(1):i[d-1]+o.charAt(1):t}s=i[u-1]}return void 0===s?"":s}))}}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){this._items={},this._nullItems=[]}return e.prototype.copy=function(){var t=new e;for(var n in this._items)t._items[n]=this._items[n].slice(0);return t._nullItems=this._nullItems.slice(0),t},e.prototype.get=function(e,t){var n=null===t?this._nullItems:this._items[t]||null;if(null===n)return null;for(var r=null,i=0;i=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},i=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},o=this&&this.__spread||function(){for(var e=[],t=0;t=0;k--)if(null!==(L=P[k]).shadowAdjustedTarget){O=L;break}if(null!==O)if(l.Guard.isNode(O.shadowAdjustedTarget)&&l.Guard.isShadowRoot(h.tree_rootNode(O.shadowAdjustedTarget,!0)))d=!0;else if(l.Guard.isNode(O.relatedTarget)&&l.Guard.isShadowRoot(h.tree_rootNode(O.relatedTarget,!0)))d=!0;else for(var M=0;M=0;k--)null!==(L=P[k]).shadowAdjustedTarget?e._eventPhase=s.EventPhase.AtTarget:e._eventPhase=s.EventPhase.Capturing,_(L,e,"capturing",i);for(k=0;k0&&null!==(l=i[a-1]).shadowAdjustedTarget)&&(t._target=l.shadowAdjustedTarget)}if(t._relatedTarget=e.relatedTarget,t._touchTargetList=e.touchTargetList,!t._stopPropagationFlag){t._currentTarget=e.invocationTarget;var c=t._currentTarget._eventListenerList,u=new(Array.bind.apply(Array,o([void 0],c)));if(!b(t,u,n,e,r)&&t._isTrusted){var d=t._type;"animationend"===d?t._type="webkitAnimationEnd":"animationiteration"===d?t._type="webkitAnimationIteration":"animationstart"===d?t._type="webkitAnimationStart":"transitionend"===d&&(t._type="webkitTransitionEnd"),b(t,u,n,e,r),t._type=d}}}function b(e,t,n,r,i){void 0===i&&(i={value:!1});for(var o=!1,a=0;a=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},a=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 s=n(6),l=n(2),c=n(9),u=n(34),d=n(3),h=n(1),p=n(7),f=n(152),m=n(0),g=n(12),v=function(e){function t(){var t=e.call(this)||this;return t._children=new Set,t._encoding={name:"UTF-8",labels:["unicode-1-1-utf-8","utf-8","utf8"]},t._contentType="application/xml",t._URL={scheme:"about",username:"",password:"",host:null,port:null,path:["blank"],query:null,fragment:null,_cannotBeABaseURLFlag:!0,_blobURLEntry:null},t._origin=null,t._type="xml",t._mode="no-quirks",t._documentElement=null,t._hasNamespaces=!1,t._nodeDocumentOverwrite=null,t}return i(t,e),Object.defineProperty(t.prototype,"_nodeDocument",{get:function(){return this._nodeDocumentOverwrite||this},set:function(e){this._nodeDocumentOverwrite=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"implementation",{get:function(){return this._implementation||(this._implementation=m.create_domImplementation(this))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"URL",{get:function(){return f.urlSerializer(this._URL)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"documentURI",{get:function(){return this.URL},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"origin",{get:function(){return"null"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"compatMode",{get:function(){return"quirks"===this._mode?"BackCompat":"CSS1Compat"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"characterSet",{get:function(){return this._encoding.name},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"charset",{get:function(){return this._encoding.name},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"inputEncoding",{get:function(){return this._encoding.name},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contentType",{get:function(){return this._contentType},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"doctype",{get:function(){var e,t;try{for(var n=o(this._children),r=n.next();!r.done;r=n.next()){var i=r.value;if(d.Guard.isDocumentTypeNode(i))return i}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"documentElement",{get:function(){return this._documentElement},enumerable:!0,configurable:!0}),t.prototype.getElementsByTagName=function(e){return m.node_listOfElementsWithQualifiedName(e,this)},t.prototype.getElementsByTagNameNS=function(e,t){return m.node_listOfElementsWithNamespace(e,t,this)},t.prototype.getElementsByClassName=function(e){return m.node_listOfElementsWithClassNames(e,this)},t.prototype.createElement=function(e,t){if(!m.xml_isName(e))throw new c.InvalidCharacterError;"html"===this._type&&(e=e.toLowerCase());var n=null;void 0!==t&&(n=h.isString(t)?t:t.is);var r="html"===this._type||"application/xhtml+xml"===this._contentType?p.namespace.HTML:null;return m.element_createAnElement(this,e,r,null,n,!0)},t.prototype.createElementNS=function(e,t,n){return m.document_internalCreateElementNS(this,e,t,n)},t.prototype.createDocumentFragment=function(){return m.create_documentFragment(this)},t.prototype.createTextNode=function(e){return m.create_text(this,e)},t.prototype.createCDATASection=function(e){if("html"===this._type)throw new c.NotSupportedError;if(-1!==e.indexOf("]]>"))throw new c.InvalidCharacterError;return m.create_cdataSection(this,e)},t.prototype.createComment=function(e){return m.create_comment(this,e)},t.prototype.createProcessingInstruction=function(e,t){if(!m.xml_isName(e))throw new c.InvalidCharacterError;if(-1!==t.indexOf("?>"))throw new c.InvalidCharacterError;return m.create_processingInstruction(this,e,t)},t.prototype.importNode=function(e,t){if(void 0===t&&(t=!1),d.Guard.isDocumentNode(e)||d.Guard.isShadowRoot(e))throw new c.NotSupportedError;return m.node_clone(e,this,t)},t.prototype.adoptNode=function(e){if(d.Guard.isDocumentNode(e))throw new c.NotSupportedError;if(d.Guard.isShadowRoot(e))throw new c.HierarchyRequestError;return m.document_adopt(e,this),e},t.prototype.createAttribute=function(e){if(!m.xml_isName(e))throw new c.InvalidCharacterError;return"html"===this._type&&(e=e.toLowerCase()),m.create_attr(this,e)},t.prototype.createAttributeNS=function(e,t){var n=a(m.namespace_validateAndExtract(e,t),3),r=n[0],i=n[1],o=n[2],s=m.create_attr(this,o);return s._namespace=r,s._namespacePrefix=i,s},t.prototype.createEvent=function(e){return m.event_createLegacyEvent(e)},t.prototype.createRange=function(){var e=m.create_range();return e._start=[this,0],e._end=[this,0],e},t.prototype.createNodeIterator=function(e,t,n){void 0===t&&(t=l.WhatToShow.All),void 0===n&&(n=null);var r=m.create_nodeIterator(e,e,!0);return r._whatToShow=t,r._iteratorCollection=m.create_nodeList(e),h.isFunction(n)?(r._filter=m.create_nodeFilter(),r._filter.acceptNode=n):r._filter=n,r},t.prototype.createTreeWalker=function(e,t,n){void 0===t&&(t=l.WhatToShow.All),void 0===n&&(n=null);var r=m.create_treeWalker(e,e);return r._whatToShow=t,h.isFunction(n)?(r._filter=m.create_nodeFilter(),r._filter.acceptNode=n):r._filter=n,r},t.prototype._getTheParent=function(e){return"load"===e._type?null:s.dom.window},t.prototype.getElementById=function(e){throw new Error("Mixin: NonElementParentNode not implemented.")},Object.defineProperty(t.prototype,"children",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"firstElementChild",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lastElementChild",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"childElementCount",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),t.prototype.prepend=function(){for(var e=[],t=0;t=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},a=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 s=n(2),l=n(34),c=n(9),u=n(7),d=n(0),h=n(12),p=function(e){function t(){var t=e.call(this)||this;return t._children=new Set,t._namespace=null,t._namespacePrefix=null,t._localName="",t._customElementState="undefined",t._customElementDefinition=null,t._is=null,t._shadowRoot=null,t._attributeList=d.create_namedNodeMap(t),t._attributeChangeSteps=[],t._name="",t._assignedSlot=null,t}return i(t,e),Object.defineProperty(t.prototype,"namespaceURI",{get:function(){return this._namespace},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"prefix",{get:function(){return this._namespacePrefix},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"localName",{get:function(){return this._localName},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"tagName",{get:function(){return this._htmlUppercasedQualifiedName},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"id",{get:function(){return d.element_getAnAttributeValue(this,"id")},set:function(e){d.element_setAnAttributeValue(this,"id",e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"className",{get:function(){return d.element_getAnAttributeValue(this,"class")},set:function(e){d.element_setAnAttributeValue(this,"class",e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"classList",{get:function(){var e=d.element_getAnAttributeByName("class",this);return null===e&&(e=d.create_attr(this._nodeDocument,"class")),d.create_domTokenList(this,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"slot",{get:function(){return d.element_getAnAttributeValue(this,"slot")},set:function(e){d.element_setAnAttributeValue(this,"slot",e)},enumerable:!0,configurable:!0}),t.prototype.hasAttributes=function(){return 0!==this._attributeList.length},Object.defineProperty(t.prototype,"attributes",{get:function(){return this._attributeList},enumerable:!0,configurable:!0}),t.prototype.getAttributeNames=function(){var e,t,n=[];try{for(var r=o(this._attributeList),i=r.next();!i.done;i=r.next()){var a=i.value;n.push(a._qualifiedName)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},t.prototype.getAttribute=function(e){var t=d.element_getAnAttributeByName(e,this);return t?t._value:null},t.prototype.getAttributeNS=function(e,t){var n=d.element_getAnAttributeByNamespaceAndLocalName(e,t,this);return n?n._value:null},t.prototype.setAttribute=function(e,t){if(!d.xml_isName(e))throw new c.InvalidCharacterError;this._namespace===u.namespace.HTML&&"html"===this._nodeDocument._type&&(e=e.toLowerCase());for(var n=null,r=0;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.")};Object.defineProperty(t,"__esModule",{value:!0});var a=n(2),s=n(71),l=n(0),c=n(12),u=function(e){function t(t){void 0===t&&(t="");var n=e.call(this,t)||this;return n._name="",n._assignedSlot=null,n}return i(t,e),Object.defineProperty(t.prototype,"wholeText",{get:function(){var e,t,n="";try{for(var r=o(l.text_contiguousTextNodes(this,!0)),i=r.next();!i.done;i=r.next())n+=i.value._data}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!0,configurable:!0}),t.prototype.splitText=function(e){return l.text_split(this,e)},Object.defineProperty(t.prototype,"assignedSlot",{get:function(){throw new Error("Mixin: Slotable not implemented.")},enumerable:!0,configurable:!0}),t._create=function(e,n){void 0===n&&(n="");var r=new t(n);return r._nodeDocument=e,r},t}(s.CharacterDataImpl);t.TextImpl=u,c.idl_defineConst(u.prototype,"_nodeType",a.NodeType.Text)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){}return Object.defineProperty(e.prototype,"_startNode",{get:function(){return this._start[0]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_startOffset",{get:function(){return this._start[1]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_endNode",{get:function(){return this._end[0]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_endOffset",{get:function(){return this._end[1]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_collapsed",{get:function(){return this._start[0]===this._end[0]&&this._start[1]===this._end[1]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"startContainer",{get:function(){return this._startNode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"startOffset",{get:function(){return this._startOffset},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"endContainer",{get:function(){return this._endNode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"endOffset",{get:function(){return this._endOffset},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"collapsed",{get:function(){return this._collapsed},enumerable:!0,configurable:!0}),e}();t.AbstractRangeImpl=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),i=function(){function e(e){this._activeFlag=!1,this._root=e,this._whatToShow=r.WhatToShow.All,this._filter=null}return Object.defineProperty(e.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"whatToShow",{get:function(){return this._whatToShow},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),e}();t.TraverserImpl=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),i=n(0),o=n(12),a=function(){function e(e,t){this._target=null,this._relatedTarget=null,this._touchTargetList=[],this._path=[],this._currentTarget=null,this._eventPhase=r.EventPhase.None,this._stopPropagationFlag=!1,this._stopImmediatePropagationFlag=!1,this._canceledFlag=!1,this._inPassiveListenerFlag=!1,this._composedFlag=!1,this._initializedFlag=!1,this._dispatchFlag=!1,this._isTrusted=!1,this._bubbles=!1,this._cancelable=!1,this._type=e,t&&(this._bubbles=t.bubbles||!1,this._cancelable=t.cancelable||!1,this._composedFlag=t.composed||!1),this._initializedFlag=!0,this._timeStamp=(new Date).getTime()}return Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"srcElement",{get:function(){return this._target},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentTarget",{get:function(){return this._currentTarget},enumerable:!0,configurable:!0}),e.prototype.composedPath=function(){var e=[],t=this._path;if(0===t.length)return e;var n=this._currentTarget;if(null===n)throw new Error("Event currentTarget is null.");e.push(n);for(var r=0,i=0,o=t.length-1;o>=0;){if(t[o].rootOfClosedTree&&i++,t[o].invocationTarget===n){r=o;break}t[o].slotInClosedTree&&i--,o--}var a=i,s=i;for(o=r-1;o>=0;)t[o].rootOfClosedTree&&a++,a<=s&&e.unshift(t[o].invocationTarget),t[o].slotInClosedTree&&--a0)&&!(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},i=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var o=n(6),a=n(3),s=n(1),l=n(99),c=n(73),u=n(17),d=n(173),h=n(30),p=n(52),f=n(37);t.document_elementInterface=function(e,t){return l.ElementImpl},t.document_internalCreateElementNS=function(e,t,n,i){var o=r(d.namespace_validateAndExtract(t,n),3),a=o[0],l=o[1],c=o[2],u=null;return void 0!==i&&(u=s.isString(i)?i:i.is),p.element_createAnElement(e,c,a,l,u,!0)},t.document_adopt=function(e,t){var n,r;if(e._nodeDocument!==t||null!==e._parent){var s=e._nodeDocument;if(e._parent&&f.mutation_remove(e,e._parent),t!==s)for(var l=u.tree_getFirstDescendantNode(e,!0,!0);null!==l;){if(l._nodeDocument=t,a.Guard.isElementNode(l))try{for(var d=(n=void 0,i(l._attributeList._asArray())),p=d.next();!p.done;p=d.next())p.value._nodeDocument=t}catch(e){n={error:e}}finally{try{p&&!p.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}o.dom.features.customElements&&a.Guard.isElementNode(l)&&"custom"===l._customElementState&&c.customElement_enqueueACustomElementCallbackReaction(l,"adoptedCallback",[s,t]),o.dom.features.steps&&h.dom_runAdoptingSteps(l,s),l=u.tree_getNextDescendantNode(e,l,!0,!0)}}}},function(e,t,n){"use strict";var r=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(6),o=n(3),a=n(9),s=n(17),l=n(51),c=n(30);t.characterData_replaceData=function(e,t,n,u){var d,h,p=s.tree_nodeLength(e);if(t>p)throw new a.IndexSizeError("Offset exceeds character data length. Offset: "+t+", Length: "+p+", Node is "+e.nodeName+".");t+n>p&&(n=p-t),i.dom.features.mutationObservers&&l.observer_queueMutationRecord("characterData",e,null,null,e._data,[],[],null,null);var f=e._data.substring(0,t)+u+e._data.substring(t+n);e._data=f;try{for(var m=r(i.dom.rangeList),g=m.next();!g.done;g=m.next()){var v=g.value;v._start[0]===e&&v._start[1]>t&&v._start[1]<=t+n&&(v._start[1]=t),v._end[0]===e&&v._end[1]>t&&v._end[1]<=t+n&&(v._end[1]=t),v._start[0]===e&&v._start[1]>t+n&&(v._start[1]+=u.length-n),v._end[0]===e&&v._end[1]>t+n&&(v._end[1]+=u.length-n)}}catch(e){d={error:e}}finally{try{g&&!g.done&&(h=m.return)&&h.call(m)}finally{if(d)throw d.error}}i.dom.features.steps&&o.Guard.isTextNode(e)&&null!==e._parent&&c.dom_runChildTextContentChangeSteps(e._parent)},t.characterData_substringData=function(e,t,n){var r=s.tree_nodeLength(e);if(t>r)throw new a.IndexSizeError("Offset exceeds character data length. Offset: "+t+", Length: "+r+", Node is "+e.nodeName+".");return t+n>r?e._data.substr(t):e._data.substr(t,n)}},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},i=this&&this.__spread||function(){for(var e=[],t=0;t=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0});var a=n(7);function s(e){var t=a.string.splitAStringOnASCIIWhitespace(e);return new Set(t)}function l(e){return i(e).join(" ")}t.orderedSet_parse=s,t.orderedSet_serialize=l,t.orderedSet_sanitize=function(e){return l(s(e))},t.orderedSet_contains=function(e,t,n){var r,i,a,s;try{for(var l=o(t),c=l.next();!c.done;c=l.next()){var u=c.value,d=!1;try{for(var h=(a=void 0,o(e)),p=h.next();!p.done;p=h.next()){var f=p.value;if(n){if(f===u){d=!0;break}}else if(f.toUpperCase()===u.toUpperCase()){d=!0;break}}}catch(e){a={error:e}}finally{try{p&&!p.done&&(s=h.return)&&s.call(h)}finally{if(a)throw a.error}}if(!d)return!1}}catch(e){r={error:e}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}return!0}},function(e,t,n){"use strict";n(179),Object.defineProperty(t,"__esModule",{value:!0});var r=n(262),i=n(110),o=n(1);i.dom.setFeatures(!1),t.createDocument=function(){var e=(new r.DOMImplementation).createDocument(null,"root",null);return e.documentElement&&e.removeChild(e.documentElement),e},t.sanitizeInput=function(e,t){if(null==e)return e;if(void 0===t)return e+"";var n="";e+="";for(var r=0;r=32&&i<=55295||i>=57344&&i<=65533)n+=e.charAt(r);else if(i>=55296&&i<=56319&&r=56320&&a<=57343?(i=1024*(i-55296)+a-56320+65536,n+=String.fromCodePoint(i),r++):n+=o.isString(t)?t:t(e.charAt(r),r,e)}else n+=o.isString(t)?t:t(e.charAt(r),r,e)}return n}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),i=n(153);t.AbortController=i.AbortControllerImpl;var o=n(154);t.AbortSignal=o.AbortSignalImpl;var a=n(102);t.AbstractRange=a.AbstractRangeImpl;var s=n(157);t.Attr=s.AttrImpl;var l=n(158);t.CDATASection=l.CDATASectionImpl;var c=n(71);t.CharacterData=c.CharacterDataImpl;var u=n(263),d=n(159);t.Comment=d.CommentImpl;var h=n(171);t.CustomEvent=h.CustomEventImpl;var p=n(100);t.DocumentFragment=p.DocumentFragmentImpl;var f=n(98);t.Document=f.DocumentImpl;var m=n(264),g=n(155);t.DocumentType=g.DocumentTypeImpl;var v=n(6);t.dom=v.dom;var y=n(148);t.DOMImplementation=y.DOMImplementationImpl;var _=n(170);t.DOMTokenList=_.DOMTokenListImpl;var b=n(99);t.Element=b.ElementImpl;var E=n(104);t.Event=E.EventImpl;var w=n(70);t.EventTarget=w.EventTargetImpl;var x=n(161);t.HTMLCollection=x.HTMLCollectionImpl;var C=n(265);t.MutationObserver=C.MutationObserverImpl;var D=n(169);t.MutationRecord=D.MutationRecordImpl;var S=n(164);t.NamedNodeMap=S.NamedNodeMapImpl;var T=n(168);t.NodeFilter=T.NodeFilterImpl;var I=n(34);t.Node=I.NodeImpl;var A=n(166);t.NodeIterator=A.NodeIteratorImpl;var N=n(162);t.NodeList=N.NodeListImpl;var O=n(163);t.NodeListStatic=O.NodeListStaticImpl;var P=n(266),k=n(267),M=n(268),L=n(160);t.ProcessingInstruction=L.ProcessingInstructionImpl;var R=n(165);t.Range=R.RangeImpl;var F=n(156);t.ShadowRoot=F.ShadowRootImpl;var U=n(269),B=n(270);t.StaticRange=B.StaticRangeImpl;var j=n(101);t.Text=j.TextImpl;var V=n(103);t.Traverser=V.TraverserImpl;var W=n(167);t.TreeWalker=W.TreeWalkerImpl;var z=n(149);t.Window=z.WindowImpl;var G=n(151);t.XMLDocument=G.XMLDocumentImpl,r.applyMixin(b.ElementImpl,u.ChildNodeImpl),r.applyMixin(c.CharacterDataImpl,u.ChildNodeImpl),r.applyMixin(g.DocumentTypeImpl,u.ChildNodeImpl),r.applyMixin(f.DocumentImpl,m.DocumentOrShadowRootImpl),r.applyMixin(F.ShadowRootImpl,m.DocumentOrShadowRootImpl),r.applyMixin(b.ElementImpl,P.NonDocumentTypeChildNodeImpl),r.applyMixin(c.CharacterDataImpl,P.NonDocumentTypeChildNodeImpl),r.applyMixin(f.DocumentImpl,k.NonElementParentNodeImpl),r.applyMixin(p.DocumentFragmentImpl,k.NonElementParentNodeImpl),r.applyMixin(f.DocumentImpl,M.ParentNodeImpl),r.applyMixin(p.DocumentFragmentImpl,M.ParentNodeImpl),r.applyMixin(b.ElementImpl,M.ParentNodeImpl),r.applyMixin(j.TextImpl,U.SlotableImpl),r.applyMixin(b.ElementImpl,U.SlotableImpl)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.EOF=0]="EOF",e[e.Declaration=1]="Declaration",e[e.DocType=2]="DocType",e[e.Element=3]="Element",e[e.Text=4]="Text",e[e.CDATA=5]="CDATA",e[e.PI=6]="PI",e[e.Comment=7]="Comment",e[e.ClosingTag=8]="ClosingTag"}(t.TokenType||(t.TokenType={}))},function(e,t,n){"use strict";n(64),n(20),n(66);var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype._parse=function(e,t){var n=this,r=this._builderOptions,i=null;return o.isFunction(t)?i=this.parse(e,t.apply(this)):o.isArray(t)||o.isSet(t)?o.forEachArray(t,(function(t){return i=n.parse(e,t)}),this):o.isMap(t)||o.isObject(t)?o.forEachObject(t,(function(t,a){if(o.isFunction(a)&&(a=a.apply(n)),r.ignoreConverters||0!==t.indexOf(r.convert.att))if(r.ignoreConverters||0!==t.indexOf(r.convert.text))if(r.ignoreConverters||0!==t.indexOf(r.convert.cdata))if(r.ignoreConverters||0!==t.indexOf(r.convert.comment))if(r.ignoreConverters||0!==t.indexOf(r.convert.ins)){if((o.isArray(a)||o.isSet(a))&&o.isEmpty(a));else if((o.isMap(a)||o.isObject(a))&&o.isEmpty(a))i=n.element(e,void 0,n.sanitize(t))||i;else if(r.keepNullNodes||null!=a)if(o.isArray(a)||o.isSet(a))o.forEachArray(a,(function(r){var o={};o[t]=r,i=n.parse(e,o)}),n);else if(o.isMap(a)||o.isObject(a))(s=n.element(e,void 0,n.sanitize(t)))&&(i=s,n.parse(s,a));else if(null!=a&&""!==a){var s;(s=n.element(e,void 0,n.sanitize(t)))&&(i=s,n.text(s,n._decodeText(n.sanitize(a))))}else i=n.element(e,void 0,n.sanitize(t))||i}else if(o.isString(a)){var l=a.indexOf(" "),c=-1===l?a:a.substr(0,l),u=-1===l?"":a.substr(l+1);i=n.instruction(e,n.sanitize(c),n.sanitize(u))||i}else o.isArray(a)||o.isSet(a)?o.forEachArray(a,(function(t){var r=t.indexOf(" "),o=-1===r?t:t.substr(0,r),a=-1===r?"":t.substr(r+1);i=n.instruction(e,n.sanitize(o),n.sanitize(a))||i}),n):o.forEachObject(a,(function(t,r){return i=n.instruction(e,n.sanitize(t),n.sanitize(r))||i}),n);else o.isArray(a)||o.isSet(a)?o.forEachArray(a,(function(t){return i=n.comment(e,n.sanitize(t))||i}),n):i=n.comment(e,n.sanitize(a))||i;else o.isArray(a)||o.isSet(a)?o.forEachArray(a,(function(t){return i=n.cdata(e,n.sanitize(t))||i}),n):i=n.cdata(e,n.sanitize(a))||i;else i=o.isMap(a)||o.isObject(a)?n.parse(e,a):n.text(e,n._decodeText(n.sanitize(a)))||i;else if(t===r.convert.att){if(o.isArray(a)||o.isSet(a))throw new Error("Invalid attribute: "+a.toString()+". "+e._debugInfo());o.forEachObject(a,(function(t,r){i=n.attribute(e,void 0,n.sanitize(t),n._decodeAttributeValue(n.sanitize(r)))||i}))}else i=n.attribute(e,void 0,n.sanitize(t.substr(r.convert.att.length)),n._decodeAttributeValue(n.sanitize(a)))||i}),this):(r.keepNullNodes||null!=t)&&(i=this.text(e,this._decodeText(this.sanitize(t)))||i),i||e},t}(n(75).BaseReader);t.ObjectReader=a},function(e,t,n){"use strict";var r=n(39);e.exports=new r({explicit:[n(286),n(287),n(288)]})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(e){this.level=0,this._builderOptions=e,this._writerOptions=e};t.BaseCBWriter=r},function(e,t,n){var r=n(16),i=n(8),o=n(116);e.exports=!r&&!i((function(){return 7!=Object.defineProperty(o("div"),"a",{get:function(){return 7}}).a}))},function(e,t,n){var r=n(11),i=n(13),o=r.document,a=i(o)&&i(o.createElement);e.exports=function(e){return a?o.createElement(e):{}}},function(e,t,n){var r=n(118),i=Function.toString;"function"!=typeof r.inspectSource&&(r.inspectSource=function(e){return i.call(e)}),e.exports=r.inspectSource},function(e,t,n){var r=n(11),i=n(80),o=r["__core-js_shared__"]||i("__core-js_shared__",{});e.exports=o},function(e,t,n){var r=n(14),i=n(187),o=n(55),a=n(15);e.exports=function(e,t){for(var n=i(t),s=a.f,l=o.f,c=0;cl;)r(s,n=t[l++])&&(~o(c,n)||c.push(n));return c}},function(e,t,n){var r=n(24),i=n(26),o=n(83),a=function(e){return function(t,n,a){var s,l=r(t),c=i(l.length),u=o(a,c);if(e&&n!=n){for(;c>u;)if((s=l[u++])!=s)return!0}else for(;c>u;u++)if((e||u in l)&&l[u]===n)return e||u||0;return!e&&-1}};e.exports={includes:a(!0),indexOf:a(!1)}},function(e,t,n){var r=n(8),i=/#|\.prototype\./,o=function(e,t){var n=s[a(e)];return n==c||n!=l&&("function"==typeof t?r(t):!!t)},a=o.normalize=function(e){return String(e).replace(i,".").toLowerCase()},s=o.data={},l=o.NATIVE="N",c=o.POLYFILL="P";e.exports=o},function(e,t,n){var r=n(86);e.exports=r&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},function(e,t,n){var r=n(5);t.f=r},function(e,t,n){var r=n(120),i=n(14),o=n(125),a=n(15).f;e.exports=function(e){var t=r.Symbol||(r.Symbol={});i(t,e)||a(t,e,{value:o.f(e)})}},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e}},function(e,t,n){var r=n(13),i=n(59),o=n(5)("species");e.exports=function(e,t){var n;return i(e)&&("function"!=typeof(n=e.constructor)||n!==Array&&!i(n.prototype)?r(n)&&null===(n=n[o])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===t?0:t)}},function(e,t,n){var r,i,o=n(11),a=n(193),s=o.process,l=s&&s.versions,c=l&&l.v8;c?i=(r=c.split("."))[0]+r[1]:a&&(!(r=a.match(/Edge\/(\d+)/))||r[1]>=74)&&(r=a.match(/Chrome\/(\d+)/))&&(i=r[1]),e.exports=i&&+i},function(e,t,n){var r=n(5),i=n(60),o=n(15),a=r("unscopables"),s=Array.prototype;null==s[a]&&o.f(s,a,{configurable:!0,value:i(null)}),e.exports=function(e){s[a][e]=!0}},function(e,t,n){"use strict";var r,i,o,a=n(132),s=n(21),l=n(14),c=n(5),u=n(44),d=c("iterator"),h=!1;[].keys&&("next"in(o=[].keys())?(i=a(a(o)))!==Object.prototype&&(r=i):h=!0),null==r&&(r={}),u||l(r,d)||s(r,d,(function(){return this})),e.exports={IteratorPrototype:r,BUGGY_SAFARI_ITERATORS:h}},function(e,t,n){var r=n(14),i=n(27),o=n(57),a=n(196),s=o("IE_PROTO"),l=Object.prototype;e.exports=a?Object.getPrototypeOf:function(e){return e=i(e),r(e,s)?e[s]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?l:null}},function(e,t,n){var r=n(18),i=n(197);e.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(n,[]),t=n instanceof Array}catch(e){}return function(n,o){return r(n),i(o),t?e.call(n,o):n.__proto__=o,n}}():void 0)},function(e,t,n){"use strict";var r=n(56),i=n(15),o=n(40);e.exports=function(e,t,n){var a=r(t);a in e?i.f(e,a,o(0,n)):e[a]=n}},function(e,t,n){var r=n(90),i=n(42),o=n(5)("toStringTag"),a="Arguments"==i(function(){return arguments}());e.exports=r?i:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),o))?n:a?i(t):"Object"==(r=i(t))&&"function"==typeof t.callee?"Arguments":r}},function(e,t,n){"use strict";var r=n(18);e.exports=function(){var e=r(this),t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t}},function(e,t,n){var r=n(47),i=n(35),o=function(e){return function(t,n){var o,a,s=String(i(t)),l=r(n),c=s.length;return l<0||l>=c?e?"":void 0:(o=s.charCodeAt(l))<55296||o>56319||l+1===c||(a=s.charCodeAt(l+1))<56320||a>57343?e?s.charAt(l):o:e?s.slice(l,l+2):a-56320+(o-55296<<10)+65536}};e.exports={codeAt:o(!1),charAt:o(!0)}},function(e,t,n){var r=n(4),i=n(27),o=n(61);r({target:"Object",stat:!0,forced:n(8)((function(){o(1)}))},{keys:function(e){return o(i(e))}})},function(e,t,n){"use strict";var r=n(4),i=n(11),o=n(123),a=n(25),s=n(140),l=n(141),c=n(142),u=n(13),d=n(8),h=n(208),p=n(62),f=n(209);e.exports=function(e,t,n){var m=-1!==e.indexOf("Map"),g=-1!==e.indexOf("Weak"),v=m?"set":"add",y=i[e],_=y&&y.prototype,b=y,E={},w=function(e){var t=_[e];a(_,e,"add"==e?function(e){return t.call(this,0===e?0:e),this}:"delete"==e?function(e){return!(g&&!u(e))&&t.call(this,0===e?0:e)}:"get"==e?function(e){return g&&!u(e)?void 0:t.call(this,0===e?0:e)}:"has"==e?function(e){return!(g&&!u(e))&&t.call(this,0===e?0:e)}:function(e,n){return t.call(this,0===e?0:e,n),this})};if(o(e,"function"!=typeof y||!(g||_.forEach&&!d((function(){(new y).entries().next()})))))b=n.getConstructor(t,e,m,v),s.REQUIRED=!0;else if(o(e,!0)){var x=new b,C=x[v](g?{}:-0,1)!=x,D=d((function(){x.has(1)})),S=h((function(e){new y(e)})),T=!g&&d((function(){for(var e=new y,t=5;t--;)e[v](t,t);return!e.has(-0)}));S||((b=t((function(t,n){c(t,b,e);var r=f(new y,t,b);return null!=n&&l(n,r[v],r,m),r}))).prototype=_,_.constructor=b),(D||T)&&(w("delete"),w("has"),m&&w("get")),(T||C)&&w(v),g&&_.clear&&delete _.clear}return E[e]=b,r({global:!0,forced:b!=y},E),p(b,e),g||n.setStrong(b,e,m),b}},function(e,t,n){var r=n(45),i=n(13),o=n(14),a=n(15).f,s=n(58),l=n(204),c=s("meta"),u=0,d=Object.isExtensible||function(){return!0},h=function(e){a(e,c,{value:{objectID:"O"+ ++u,weakData:{}}})},p=e.exports={REQUIRED:!1,fastKey:function(e,t){if(!i(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!o(e,c)){if(!d(e))return"F";if(!t)return"E";h(e)}return e[c].objectID},getWeakData:function(e,t){if(!o(e,c)){if(!d(e))return!0;if(!t)return!1;h(e)}return e[c].weakData},onFreeze:function(e){return l&&p.REQUIRED&&d(e)&&!o(e,c)&&h(e),e}};r[c]=!0},function(e,t,n){var r=n(18),i=n(205),o=n(26),a=n(87),s=n(206),l=n(207),c=function(e,t){this.stopped=e,this.result=t};(e.exports=function(e,t,n,u,d){var h,p,f,m,g,v,y,_=a(t,n,u?2:1);if(d)h=e;else{if("function"!=typeof(p=s(e)))throw TypeError("Target is not iterable");if(i(p)){for(f=0,m=o(e.length);m>f;f++)if((g=u?_(r(y=e[f])[0],y[1]):_(e[f]))&&g instanceof c)return g;return new c(!1)}h=p.call(e)}for(v=h.next;!(y=v.call(h)).done;)if("object"==typeof(g=l(h,_,y.value,u))&&g&&g instanceof c)return g;return new c(!1)}).stop=function(e){return new c(!0,e)}},function(e,t){e.exports=function(e,t,n){if(!(e instanceof t))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return e}},function(e,t,n){"use strict";var r=n(15).f,i=n(60),o=n(210),a=n(87),s=n(142),l=n(141),c=n(88),u=n(211),d=n(16),h=n(140).fastKey,p=n(43),f=p.set,m=p.getterFor;e.exports={getConstructor:function(e,t,n,c){var u=e((function(e,r){s(e,u,t),f(e,{type:t,index:i(null),first:void 0,last:void 0,size:0}),d||(e.size=0),null!=r&&l(r,e[c],e,n)})),p=m(t),g=function(e,t,n){var r,i,o=p(e),a=v(e,t);return a?a.value=n:(o.last=a={index:i=h(t,!0),key:t,value:n,previous:r=o.last,next:void 0,removed:!1},o.first||(o.first=a),r&&(r.next=a),d?o.size++:e.size++,"F"!==i&&(o.index[i]=a)),e},v=function(e,t){var n,r=p(e),i=h(t);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key==t)return n};return o(u.prototype,{clear:function(){for(var e=p(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete t[n.index],n=n.next;e.first=e.last=void 0,d?e.size=0:this.size=0},delete:function(e){var t=p(this),n=v(this,e);if(n){var r=n.next,i=n.previous;delete t.index[n.index],n.removed=!0,i&&(i.next=r),r&&(r.previous=i),t.first==n&&(t.first=r),t.last==n&&(t.last=i),d?t.size--:this.size--}return!!n},forEach:function(e){for(var t,n=p(this),r=a(e,arguments.length>1?arguments[1]:void 0,3);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!v(this,e)}}),o(u.prototype,n?{get:function(e){var t=v(this,e);return t&&t.value},set:function(e,t){return g(this,0===e?0:e,t)}}:{add:function(e){return g(this,e=0===e?0:e,e)}}),d&&r(u.prototype,"size",{get:function(){return p(this).size}}),u},setStrong:function(e,t,n){var r=t+" Iterator",i=m(t),o=m(r);c(e,t,(function(e,t){f(this,{type:r,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=o(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?"keys"==t?{value:n.key,done:!1}:"values"==t?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(e.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),u(t)}}},function(e,t,n){"use strict";var r,i=n(4),o=n(55).f,a=n(26),s=n(222),l=n(35),c=n(224),u=n(44),d="".endsWith,h=Math.min,p=c("endsWith");i({target:"String",proto:!0,forced:!(!u&&!p&&(r=o(String.prototype,"endsWith"),r&&!r.writable)||p)},{endsWith:function(e){var t=String(l(this));s(e);var n=arguments.length>1?arguments[1]:void 0,r=a(t.length),i=void 0===n?r:h(a(n),r),o=String(e);return d?d.call(t,o,i):t.slice(i-o.length,i)===o}})},function(e,t,n){"use strict";(function(e){var r=n(229),i=n(230),o=n(231);function a(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(e,t){if(a()=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|e}function f(e,t){if(l.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return V(e).length;default:if(r)return j(e).length;t=(""+t).toLowerCase(),r=!0}}function m(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return A(this,t,n);case"utf8":case"utf-8":return S(this,t,n);case"ascii":return T(this,t,n);case"latin1":case"binary":return I(this,t,n);case"base64":return D(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function g(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function v(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=l.from(t,r)),l.isBuffer(t))return 0===t.length?-1:y(e,t,n,r,i);if("number"==typeof t)return t&=255,l.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,r,i){var o,a=1,s=e.length,l=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,s/=2,l/=2,n/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var u=-1;for(o=n;os&&(n=s-l),o=n;o>=0;o--){for(var d=!0,h=0;hi&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;a>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function D(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function S(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+d<=n)switch(d){case 1:c<128&&(u=c);break;case 2:128==(192&(o=e[i+1]))&&(l=(31&c)<<6|63&o)>127&&(u=l);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(l=(15&c)<<12|(63&o)<<6|63&a)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(l=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&l<1114112&&(u=l)}null===u?(u=65533,d=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),i+=d}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);for(var n="",r=0;rr)&&(n=r);for(var i="",o=t;on)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,n,r,i,o){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function k(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i>>8*(r?i:1-i)}function M(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i>>8*(r?i:3-i)&255}function L(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function R(e,t,n,r,o){return o||L(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function F(e,t,n,r,o){return o||L(e,0,n,8),i.write(e,t,n,r,52,8),n+8}t.Buffer=l,t.SlowBuffer=function(e){return+e!=e&&(e=0),l.alloc(+e)},t.INSPECT_MAX_BYTES=50,l.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=a(),l.poolSize=8192,l._augment=function(e){return e.__proto__=l.prototype,e},l.from=function(e,t,n){return c(null,e,t,n)},l.TYPED_ARRAY_SUPPORT&&(l.prototype.__proto__=Uint8Array.prototype,l.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&l[Symbol.species]===l&&Object.defineProperty(l,Symbol.species,{value:null,configurable:!0})),l.alloc=function(e,t,n){return function(e,t,n,r){return u(t),t<=0?s(e,t):void 0!==n?"string"==typeof r?s(e,t).fill(n,r):s(e,t).fill(n):s(e,t)}(null,e,t,n)},l.allocUnsafe=function(e){return d(null,e)},l.allocUnsafeSlow=function(e){return d(null,e)},l.isBuffer=function(e){return!(null==e||!e._isBuffer)},l.compare=function(e,t){if(!l.isBuffer(e)||!l.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},l.prototype.compare=function(e,t,n,r,i){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0),s=Math.min(o,a),c=this.slice(r,i),u=e.slice(t,n),d=0;di)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return _(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return E(this,e,t,n);case"latin1":case"binary":return w(this,e,t,n);case"base64":return x(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},l.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t0&&(i*=256);)r+=this[e+--t]*i;return r},l.prototype.readUInt8=function(e,t){return t||O(e,1,this.length),this[e]},l.prototype.readUInt16LE=function(e,t){return t||O(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUInt16BE=function(e,t){return t||O(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUInt32LE=function(e,t){return t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},l.prototype.readUInt32BE=function(e,t){return t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},l.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||O(e,t,this.length);for(var r=this[e],i=1,o=0;++o=(i*=128)&&(r-=Math.pow(2,8*t)),r},l.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||O(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},l.prototype.readInt8=function(e,t){return t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.prototype.readInt16LE=function(e,t){t||O(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt16BE=function(e,t){t||O(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt32LE=function(e,t){return t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},l.prototype.readInt32BE=function(e,t){return t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},l.prototype.readFloatLE=function(e,t){return t||O(e,4,this.length),i.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return t||O(e,4,this.length),i.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return t||O(e,8,this.length),i.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return t||O(e,8,this.length),i.read(this,e,!1,52,8)},l.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||P(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+n},l.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,1,255,0),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},l.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):k(this,e,t,!0),t+2},l.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):k(this,e,t,!1),t+2},l.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):M(this,e,t,!0),t+4},l.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},l.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);P(this,e,t,n,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+n},l.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);P(this,e,t,n,i-1,-i)}var o=n-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+n},l.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,1,127,-128),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},l.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):k(this,e,t,!0),t+2},l.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):k(this,e,t,!1),t+2},l.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):M(this,e,t,!0),t+4},l.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},l.prototype.writeFloatLE=function(e,t,n){return R(this,e,t,!0,n)},l.prototype.writeFloatBE=function(e,t,n){return R(this,e,t,!1,n)},l.prototype.writeDoubleLE=function(e,t,n){return F(this,e,t,!0,n)},l.prototype.writeDoubleBE=function(e,t,n){return F(this,e,t,!1,n)},l.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--i)e[i+t]=this[i+n];else if(o<1e3||!l.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function V(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(U,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function W(e,t,n,r){for(var i=0;i=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(this,n(78))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isASCIIByte=function(e){return e>=0&&e<=127}},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},i=this&&this.__spread||function(){for(var e=[],t=0;t=65&&n<=90&&(e[t]=n+32)}},t.byteUppercase=function(e){for(var t=0;t=97&&n<=122&&(e[t]=n-32)}},t.byteCaseInsensitiveMatch=function(e,t){if(e.length!==t.length)return!1;for(var n=0;n=65&&r<=90&&(r+=32),i>=65&&i<=90&&(i+=32),r!==i)return!1}return!0},t.startsWith=function(e,t){for(var n=0;;){if(n>=e.length)return!1;if(n>=t.length)return!0;if(e[n]!==t[n])return!1;n++}},t.byteLessThan=function(e,t){for(var n=0;;){if(n>=e.length)return!1;if(n>=t.length)return!0;var r=e[n],i=t[n];if(ri)return!1;n++}},t.isomorphicDecode=function(e){return String.fromCodePoint.apply(String,i(e))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6),i=n(7),o=n(0),a=n(12),s=function(){function e(e){this._associatedDocument=e||r.dom.window.document}return e.prototype.createDocumentType=function(e,t,n){return o.namespace_validate(e),o.create_documentType(this._associatedDocument,e,t,n)},e.prototype.createDocument=function(e,t,n){void 0===n&&(n=null);var r=o.create_xmlDocument(),a=null;return t&&(a=o.document_internalCreateElementNS(r,e,t)),n&&r.appendChild(n),a&&r.appendChild(a),r._origin=this._associatedDocument._origin,e===i.namespace.HTML?r._contentType="application/xhtml+xml":e===i.namespace.SVG?r._contentType="image/svg+xml":r._contentType="application/xml",r},e.prototype.createHTMLDocument=function(e){var t=o.create_document();t._type="html",t._contentType="text/html",t.appendChild(o.create_documentType(t,"html","",""));var n=o.element_createAnElement(t,"html",i.namespace.HTML);t.appendChild(n);var r=o.element_createAnElement(t,"head",i.namespace.HTML);if(n.appendChild(r),void 0!==e){var a=o.element_createAnElement(t,"title",i.namespace.HTML);r.appendChild(a);var s=o.create_text(t,e);a.appendChild(s)}var l=o.element_createAnElement(t,"body",i.namespace.HTML);return n.appendChild(l),t._origin=this._associatedDocument._origin,t},e.prototype.hasFeature=function(){return!0},e._create=function(t){return new e(t)},e}();t.DOMImplementationImpl=s,a.idl_defineConst(s.prototype,"_ID","@oozcitak/dom")},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=n(70),a=n(1),s=n(0),l=function(e){function t(){var t=e.call(this)||this;return t._signalSlots=new Set,t._mutationObserverMicrotaskQueued=!1,t._mutationObservers=new Set,t._iteratorList=new a.FixedSizeSet,t._associatedDocument=s.create_document(),t}return i(t,e),Object.defineProperty(t.prototype,"document",{get:function(){return this._associatedDocument},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"event",{get:function(){return this._currentEvent},enumerable:!0,configurable:!0}),t._create=function(){return new t},t}(o.EventTargetImpl);t.WindowImpl=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),i=function(){function e(){}return e.isNode=function(e){return!!e&&void 0!==e._nodeType},e.isDocumentNode=function(t){return e.isNode(t)&&t._nodeType===r.NodeType.Document},e.isDocumentTypeNode=function(t){return e.isNode(t)&&t._nodeType===r.NodeType.DocumentType},e.isDocumentFragmentNode=function(t){return e.isNode(t)&&t._nodeType===r.NodeType.DocumentFragment},e.isAttrNode=function(t){return e.isNode(t)&&t._nodeType===r.NodeType.Attribute},e.isCharacterDataNode=function(t){if(!e.isNode(t))return!1;var n=t._nodeType;return n===r.NodeType.Text||n===r.NodeType.ProcessingInstruction||n===r.NodeType.Comment||n===r.NodeType.CData},e.isTextNode=function(t){return e.isNode(t)&&(t._nodeType===r.NodeType.Text||t._nodeType===r.NodeType.CData)},e.isExclusiveTextNode=function(t){return e.isNode(t)&&t._nodeType===r.NodeType.Text},e.isCDATASectionNode=function(t){return e.isNode(t)&&t._nodeType===r.NodeType.CData},e.isCommentNode=function(t){return e.isNode(t)&&t._nodeType===r.NodeType.Comment},e.isProcessingInstructionNode=function(t){return e.isNode(t)&&t._nodeType===r.NodeType.ProcessingInstruction},e.isElementNode=function(t){return e.isNode(t)&&t._nodeType===r.NodeType.Element},e.isCustomElementNode=function(t){return e.isElementNode(t)&&"custom"===t._customElementState},e.isShadowRoot=function(e){return!!e&&void 0!==e.host},e.isMouseEvent=function(e){return!!e&&void 0!==e.screenX&&null!=e.screenY},e.isSlotable=function(t){return!!t&&void 0!==t._name&&void 0!==t._assignedSlot&&(e.isTextNode(t)||e.isElementNode(t))},e.isSlot=function(t){return!!t&&void 0!==t._name&&void 0!==t._assignedNodes&&e.isElementNode(t)},e.isWindow=function(e){return!!e&&void 0!==e.navigator},e.isEventListener=function(e){return!!e&&void 0!==e.handleEvent},e.isRegisteredObserver=function(e){return!!e&&void 0!==e.observer&&void 0!==e.options},e.isTransientRegisteredObserver=function(t){return!!t&&void 0!==t.source&&e.isRegisteredObserver(t)},e}();t.Guard=i},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return e.call(this)||this}return i(t,e),t}(n(98).DocumentImpl);t.XMLDocumentImpl=o},function(e,t,n){"use strict";var r=this&&this.__values||function(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.")},i=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 o,a=n(1),s=n(243),l=n(7),c=n(244),u={ftp:21,file:null,http:80,https:443,ws:80,wss:443},d=/[\0-\x1F\x7F-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,h=/[ "<>`]|[\0-\x1F\x7F-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,p=/[ "<>`#?{}]|[\0-\x1F\x7F-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,f=/[ "<>`#?{}/:;=@\[\]\\\^\|]|[\0-\x1F\x7F-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,m=/[0-9A-Za-z!\$&-\/:;=\?@_~\xA0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uD83E\uD840-\uD87E\uD880-\uD8BE\uD8C0-\uD8FE\uD900-\uD93E\uD940-\uD97E\uD980-\uD9BE\uD9C0-\uD9FE\uDA00-\uDA3E\uDA40-\uDA7E\uDA80-\uDABE\uDAC0-\uDAFE\uDB00-\uDB3E\uDB40-\uDB7E\uDB80-\uDBBE\uDBC0-\uDBFE][\uDC00-\uDFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDC00-\uDFFD]/,g=/[\0\t\f\r #%/:?@\[\\\]]/;function v(e){void 0!==o&&o.call(null,"Validation Error: "+e)}function y(){return{scheme:"",username:"",password:"",host:null,port:null,path:[],query:null,fragment:null,_cannotBeABaseURLFlag:!1,_blobURLEntry:null}}function _(e){return e in u}function b(e){return _(e.scheme)}function E(e){return u[e]||null}function w(e){return""!==e.username||""!==e.password}function x(e,t){var n,i;void 0===t&&(t=!1);var o=e.scheme+":";if(null!==e.host?(o+="//",w(e)&&(o+=e.username,""!==e.password&&(o+=":"+e.password),o+="@"),o+=C(e.host),null!==e.port&&(o+=":"+e.port)):null===e.host&&"file"===e.scheme&&(o+="//"),e._cannotBeABaseURLFlag)o+=e.path[0];else try{for(var a=r(e.path),s=a.next();!s.done;s=a.next())o+="/"+s.value}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return null!==e.query&&(o+="?"+e.query),t||null===e.fragment||(o+="#"+e.fragment),o}function C(e){return a.isNumber(e)?D(e):a.isArray(e)?"["+S(e)+"]":e}function D(e){for(var t="",n=e,r=1;r<=4;r++)t=(n%256).toString()+t,4!==r&&(t="."+t),n=Math.floor(n/256);return t}function S(e){for(var t="",n=null,r=-1,i=0,o=0,a=0;a<8;a++)if(0===e[a]){i=1;for(var s=a+1;s<8&&0===e[s];s++)i++;i>o&&(o=i,r=a)}o>1&&(n=r);for(var l=!1,c=0;c<8;c++)l&&0===e[c]||(l&&(l=!1),n!==c?(t+=e[c].toString(16),7!==c&&(t+=":")):(t+=0===c?"::":":",l=!0));return t}function T(e,t,n,i,o){var c,u,g,y;if(void 0===i){i={scheme:"",username:"",password:"",host:null,port:null,path:[],query:null,fragment:null,_cannotBeABaseURLFlag:!1,_blobURLEntry:null};var x=/^[\u0000-\u001F\u0020]+/,C=/[\u0000-\u001F\u0020]+$/;(x.test(e)||C.test(e))&&v("Input string contains leading or trailing control characters or space."),e=(e=e.replace(x,"")).replace(C,"")}var D=/[\u0009\u000A\u000D]/g;D.test(e)&&v("Input string contains tab or newline characters."),e=e.replace(D,"");var S=void 0===o?s.ParserState.SchemeStart:o;void 0===t&&(t=null);for(var T=void 0===n||"replacement"===n||"UTF-16BE"===n||"UTF-16LE"===n?"UTF-8":n,L="",R=!1,F=!1,U=!1,B=new a.StringWalker(e);;){switch(S){case s.ParserState.SchemeStart:if(l.codePoint.ASCIIAlpha.test(B.c()))L+=B.c().toLowerCase(),S=s.ParserState.Scheme;else{if(void 0!==o)return v("Invalid scheme start character."),null;S=s.ParserState.NoScheme,B.pointer--}break;case s.ParserState.Scheme:if(l.codePoint.ASCIIAlphanumeric.test(B.c())||"+"===B.c()||"-"===B.c()||"."===B.c())L+=B.c().toLowerCase();else{if(":"!==B.c()){if(void 0===o){L="",S=s.ParserState.NoScheme,B.pointer=0;continue}return v("Invalid input string."),null}if(void 0!==o){if(_(i.scheme)&&!_(L))return i;if(!_(i.scheme)&&_(L))return i;if((w(i)||null!==i.port)&&"file"===L)return i;if("file"===i.scheme&&(""===i.host||null===i.host))return i}if(i.scheme=L,void 0!==o)return i.port===E(i.scheme)&&(i.port=null),i;L="","file"===i.scheme?(B.remaining().startsWith("//")||v("Invalid file URL scheme, '//' expected."),S=s.ParserState.File):b(i)&&null!==t&&t.scheme===i.scheme?S=s.ParserState.SpecialRelativeOrAuthority:b(i)?S=s.ParserState.SpecialAuthoritySlashes:B.remaining().startsWith("/")?(S=s.ParserState.PathOrAuthority,B.pointer++):(i._cannotBeABaseURLFlag=!0,i.path.push(""),S=s.ParserState.CannotBeABaseURLPath)}break;case s.ParserState.NoScheme:if(null===t||t._cannotBeABaseURLFlag&&"#"!==B.c())return v("Invalid input string."),null;t._cannotBeABaseURLFlag&&"#"===B.c()?(i.scheme=t.scheme,i.path=l.list.clone(t.path),i.query=t.query,i.fragment="",i._cannotBeABaseURLFlag=!0,S=s.ParserState.Fragment):"file"!==t.scheme?(S=s.ParserState.Relative,B.pointer--):(S=s.ParserState.File,B.pointer--);break;case s.ParserState.SpecialRelativeOrAuthority:"/"===B.c()&&B.remaining().startsWith("/")?(S=s.ParserState.SpecialAuthorityIgnoreSlashes,B.pointer++):(v("Invalid input string."),S=s.ParserState.Relative,B.pointer--);break;case s.ParserState.PathOrAuthority:"/"===B.c()?S=s.ParserState.Authority:(S=s.ParserState.Path,B.pointer--);break;case s.ParserState.Relative:if(null===t)throw new Error("Invalid parser state. Base URL is null.");switch(i.scheme=t.scheme,B.c()){case"":i.username=t.username,i.password=t.password,i.host=t.host,i.port=t.port,i.path=l.list.clone(t.path),i.query=t.query;break;case"/":S=s.ParserState.RelativeSlash;break;case"?":i.username=t.username,i.password=t.password,i.host=t.host,i.port=t.port,i.path=l.list.clone(t.path),i.query="",S=s.ParserState.Query;break;case"#":i.username=t.username,i.password=t.password,i.host=t.host,i.port=t.port,i.path=l.list.clone(t.path),i.query=t.query,i.fragment="",S=s.ParserState.Fragment;break;default:b(i)&&"\\"===B.c()?(v("Invalid input string."),S=s.ParserState.RelativeSlash):(i.username=t.username,i.password=t.password,i.host=t.host,i.port=t.port,i.path=l.list.clone(t.path),0!==i.path.length&&i.path.splice(i.path.length-1,1),S=s.ParserState.Path,B.pointer--)}break;case s.ParserState.RelativeSlash:if(!b(i)||"/"!==B.c()&&"\\"!==B.c())if("/"===B.c())S=s.ParserState.Authority;else{if(null===t)throw new Error("Invalid parser state. Base URL is null.");i.username=t.username,i.password=t.password,i.host=t.host,i.port=t.port,S=s.ParserState.Path,B.pointer--}else"\\"===B.c()&&v("Invalid input string."),S=s.ParserState.SpecialAuthorityIgnoreSlashes;break;case s.ParserState.SpecialAuthoritySlashes:"/"===B.c()&&B.remaining().startsWith("/")?(S=s.ParserState.SpecialAuthorityIgnoreSlashes,B.pointer++):(v("Expected '//'."),S=s.ParserState.SpecialAuthorityIgnoreSlashes,B.pointer--);break;case s.ParserState.SpecialAuthorityIgnoreSlashes:"/"!==B.c()&&"\\"!==B.c()?(S=s.ParserState.Authority,B.pointer--):v("Unexpected '/' or '\\'.");break;case s.ParserState.Authority:if("@"===B.c()){v("Unexpected '@'."),R&&(L="%40"+L),R=!0;try{for(var V=(c=void 0,r(L)),W=V.next();!W.done;W=V.next()){var G=W.value;if(":"!==G||U){var H=z(G,f);U?i.password+=H:i.username+=H}else U=!0}}catch(e){c={error:e}}finally{try{W&&!W.done&&(u=V.return)&&u.call(V)}finally{if(c)throw c.error}}L=""}else if(""===B.c()||"/"===B.c()||"?"===B.c()||"#"===B.c()||b(i)&&"\\"===B.c()){if(R&&""===L)return v("Invalid input string."),null;B.pointer-=L.length+1,L="",S=s.ParserState.Host}else L+=B.c();break;case s.ParserState.Host:case s.ParserState.Hostname:if(void 0!==o&&"file"===i.scheme)B.pointer--,S=s.ParserState.FileHost;else if(":"!==B.c()||F)if(""===B.c()||"/"===B.c()||"?"===B.c()||"#"===B.c()||b(i)&&"\\"===B.c()){if(B.pointer--,b(i)&&""===L)return v("Invalid input string."),null;if(void 0!==o&&""===L&&(w(i)||null!==i.port))return v("Invalid input string."),i;if(null===(K=M(L,!b(i))))return null;if(i.host=K,L="",S=s.ParserState.PathStart,void 0!==o)return i}else"["===B.c()&&(F=!0),"]"===B.c()&&(F=!1),L+=B.c();else{if(""===L)return v("Invalid input string."),null;if(null===(K=M(L,!b(i))))return null;if(i.host=K,L="",S=s.ParserState.Port,o===s.ParserState.Hostname)return i}break;case s.ParserState.Port:if(l.codePoint.ASCIIDigit.test(B.c()))L+=B.c();else{if(!(""===B.c()||"/"===B.c()||"?"===B.c()||"#"===B.c()||b(i)&&"\\"===B.c()||o))return v("Invalid input string."),null;if(""!==L&&""!==L){var q=parseInt(L,10);if(q>Math.pow(2,16)-1)return v("Invalid port number."),null;i.port=q===E(i.scheme)?null:q,L=""}if(void 0!==o)return i;S=s.ParserState.PathStart,B.pointer--}break;case s.ParserState.File:if(i.scheme="file","/"===B.c()||"\\"===B.c())"\\"===B.c()&&v("Invalid input string."),S=s.ParserState.FileSlash;else if(null!==t&&"file"===t.scheme)switch(B.c()){case"":i.host=t.host,i.path=l.list.clone(t.path),i.query=t.query;break;case"?":i.host=t.host,i.path=l.list.clone(t.path),i.query="",S=s.ParserState.Query;break;case"#":i.host=t.host,i.path=l.list.clone(t.path),i.query=t.query,i.fragment="",S=s.ParserState.Fragment;break;default:k(B.substring())?v("Unexpected windows drive letter in input string."):(i.host=t.host,i.path=l.list.clone(t.path),N(i)),S=s.ParserState.Path,B.pointer--}else S=s.ParserState.Path,B.pointer--;break;case s.ParserState.FileSlash:"/"===B.c()||"\\"===B.c()?("\\"===B.c()&&v("Invalid input string."),S=s.ParserState.FileHost):(null===t||"file"!==t.scheme||k(B.substring())||(O(t.path[0])?i.path.push(t.path[0]):i.host=t.host),S=s.ParserState.Path,B.pointer--);break;case s.ParserState.FileHost:if(""===B.c()||"/"===B.c()||"\\"===B.c()||"?"===B.c()||"#"===B.c())if(B.pointer--,void 0===o&&P(L))v("Unexpected windows drive letter in input string."),S=s.ParserState.Path;else if(""===L){if(i.host="",void 0!==o)return i;S=s.ParserState.PathStart}else{var K;if(null===(K=M(L,!b(i))))return null;if("localhost"===K&&(K=""),i.host=K,void 0!==o)return i;L="",S=s.ParserState.PathStart}else L+=B.c();break;case s.ParserState.PathStart:b(i)?("\\"===B.c()&&v("Invalid input string."),S=s.ParserState.Path,"/"!==B.c()&&"\\"!==B.c()&&B.pointer--):void 0===o&&"?"===B.c()?(i.query="",S=s.ParserState.Query):void 0===o&&"#"===B.c()?(i.fragment="",S=s.ParserState.Fragment):""!==B.c()&&(S=s.ParserState.Path,"/"!==B.c()&&B.pointer--);break;case s.ParserState.Path:if(""===B.c()||"/"===B.c()||b(i)&&"\\"===B.c()||void 0===o&&("?"===B.c()||"#"===B.c())){if(b(i)&&"\\"===B.c()&&v("Invalid input string."),A(L))N(i),"/"===B.c()||b(i)&&"\\"===B.c()||i.path.push("");else if(!I(L)||"/"===B.c()||b(i)&&"\\"===B.c()){if(!I(L)){if("file"===i.scheme&&0===i.path.length&&P(L)){null!==i.host&&""!==i.host&&(v("Invalid input string."),i.host="");var X=Array.from(L);L=X.slice(0,1)+":"+X.slice(2)}i.path.push(L)}}else i.path.push("");if(L="","file"===i.scheme&&(""===B.c()||"?"===B.c()||"#"===B.c()))for(;i.path.length>1&&""===i.path[0];)v("Invalid input string."),i.path.splice(0,1);"?"===B.c()&&(i.query="",S=s.ParserState.Query),"#"===B.c()&&(i.fragment="",S=s.ParserState.Fragment)}else m.test(B.c())||"%"===B.c()||v("Character is not a URL code point or a percent encoded character."),"%"!==B.c()||/^[0-9a-fA-F][0-9a-fA-F]/.test(B.remaining())||v("Percent encoded character must be followed by two hex digits."),L+=z(B.c(),p);break;case s.ParserState.CannotBeABaseURLPath:"?"===B.c()?(i.query="",S=s.ParserState.Query):"#"===B.c()?(i.fragment="",S=s.ParserState.Fragment):(""===B.c()||m.test(B.c())||"%"===B.c()||v("Character is not a URL code point or a percent encoded character."),"%"!==B.c()||/^[0-9a-fA-F][0-9a-fA-F]/.test(B.remaining())||v("Percent encoded character must be followed by two hex digits."),""!==B.c()&&(i.path[0]+=z(B.c(),d)));break;case s.ParserState.Query:if("UTF-8"===T||b(i)&&"ws"!==i.scheme&&"wss"!==i.scheme||(T="UTF-8"),void 0===o&&"#"===B.c())i.fragment="",S=s.ParserState.Fragment;else if(""!==B.c()){if(m.test(B.c())||"%"===B.c()||v("Character is not a URL code point or a percent encoded character."),"%"!==B.c()||/^[0-9a-fA-F][0-9a-fA-F]/.test(B.remaining())||v("Percent encoded character must be followed by two hex digits."),"UTF-8"!==T.toUpperCase())throw new Error("Only UTF-8 encoding is supported.");var $=a.utf8Encode(B.c());if($.length>=3&&38===$[0]&&35===$[1]&&59===$[$.length-1])$=$.subarray(2,$.length-1),i.query+="%26%23"+l.byteSequence.isomorphicDecode($)+"%3B";else try{for(var J=(g=void 0,r($)),Y=J.next();!Y.done;Y=J.next()){var Z=Y.value;Z<33||Z>126||34===Z||35===Z||60===Z||62===Z||39===Z&&b(i)?i.query+=j(Z):i.query+=String.fromCharCode(Z)}}catch(e){g={error:e}}finally{try{Y&&!Y.done&&(y=J.return)&&y.call(J)}finally{if(g)throw g.error}}}break;case s.ParserState.Fragment:""===B.c()||("\0"===B.c()?v("NULL character in input string."):(m.test(B.c())||"%"===B.c()||v("Unexpected character in fragment string."),"%"!==B.c()||/^[A-Za-z0-9][A-Za-z0-9]/.test(B.remaining())||v("Unexpected character in fragment string."),i.fragment+=z(B.c(),h)))}if(B.eof)break;B.pointer++}return i}function I(e){return"."===e||"%2e"===e.toLowerCase()}function A(e){var t=e.toLowerCase();return".."===t||".%2e"===t||"%2e."===t||"%2e%2e"===t}function N(e){var t=e.path;0!==t.length&&("file"===e.scheme&&1===t.length&&O(t[0])||e.path.splice(e.path.length-1,1))}function O(e){return e.length>=2&&l.codePoint.ASCIIAlpha.test(e[0])&&":"===e[1]}function P(e){return e.length>=2&&l.codePoint.ASCIIAlpha.test(e[0])&&(":"===e[1]||"|"===e[1])}function k(e){return e.length>=2&&P(e)&&(2===e.length||"/"===e[2]||"\\"===e[2]||"?"===e[2]||"#"===e[2])}function M(e,t){if(void 0===t&&(t=!1),e.startsWith("["))return e.endsWith("]")?F(e.substring(1,e.length-1)):(v("Expected ']' after '['."),null);if(t)return U(e);var n=q(a.utf8Decode(W(e)));if(null===n)return v("Invalid domain."),null;if(g.test(n))return v("Invalid domain."),null;var r=R(n);return null===r||a.isNumber(r)?r:n}function L(e,t){void 0===t&&(t={value:!1});var n=10;return e.startsWith("0x")||e.startsWith("0X")?(t.value=!0,e=e.substr(2),n=16):e.length>=2&&"0"===e[0]&&(t.value=!0,e=e.substr(1),n=8),""===e?0:(10===n?/^[0-9]+$/:16===n?/^[0-9A-Fa-f]+$/:/^[0-7]+$/).test(e)?parseInt(e,n):null}function R(e){var t,n,i,o,a={value:!1},s=e.split(".");if(""===s[s.length-1]&&(a.value=!0,s.length>1&&s.pop()),s.length>4)return e;var l=[];try{for(var c=r(s),u=c.next();!u.done;u=c.next()){var d=u.value;if(""===d)return e;if(null===(y=L(d,a)))return e;l.push(y)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}a.value&&v("Invalid IP v4 address.");for(var h=0;h255&&(v("Invalid IP v4 address."),h=Math.pow(256,5-l.length))return v("Invalid IP v4 address."),null;var p=l[l.length-1];l.pop();var f=0;try{for(var m=r(l),g=m.next();!g.done;g=m.next()){var y;p+=(y=g.value)*Math.pow(256,3-f),f++}}catch(e){i={error:e}}finally{try{g&&!g.done&&(o=m.return)&&o.call(m)}finally{if(i)throw i.error}}return p}function F(e){var t,n=[0,0,0,0,0,0,0,0],r=0,o=null,s=new a.StringWalker(e);if(":"===s.c()){if(!s.remaining().startsWith(":"))return v("Invalid IP v6 address."),null;s.pointer+=2,o=r+=1}for(;""!==s.c();){if(8===r)return v("Invalid IP v6 address."),null;if(":"!==s.c()){for(var c=0,u=0;u<4&&l.codePoint.ASCIIHexDigit.test(s.c());)c=16*c+parseInt(s.c(),16),s.pointer++,u++;if("."===s.c()){if(0===u)return v("Invalid IP v6 address."),null;if(s.pointer-=u,r>6)return v("Invalid IP v6 address."),null;for(var d=0;""!==s.c();){var h=null;if(d>0){if(!("."===s.c()&&d<4))return v("Invalid IP v6 address."),null;s.pointer++}if(!l.codePoint.ASCIIDigit.test(s.c()))return v("Invalid IP v6 address."),null;for(;l.codePoint.ASCIIDigit.test(s.c());){var p=parseInt(s.c(),10);if(null===h)h=p;else{if(0===h)return v("Invalid IP v6 address."),null;h=10*h+p}if(h>255)return v("Invalid IP v6 address."),null;s.pointer++}if(null===h)return v("Invalid IP v6 address."),null;n[r]=256*n[r]+h,2!=++d&&4!==d||r++}if(4!==d)return v("Invalid IP v6 address."),null;break}if(":"===s.c()){if(s.pointer++,""===s.c())return v("Invalid IP v6 address."),null}else if(""!==s.c())return v("Invalid IP v6 address."),null;n[r]=c,r++}else{if(null!==o)return v("Invalid IP v6 address."),null;s.pointer++,o=++r}}if(null!==o){var f=r-o;for(r=7;0!==r&&f>0;)t=i([n[o+f-1],n[r]],2),n[r]=t[0],n[o+f-1]=t[1],r--,f--}else if(null===o&&8!==r)return v("Invalid IP v6 address."),null;return n}function U(e){var t,n;if(/[\x00\t\f\r #/:?@\[\\\]]/.test(e))return v("Invalid host string."),null;var i="";try{for(var o=r(e),a=o.next();!a.done;a=o.next())i+=z(a.value,d)}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return i}function B(e){return null}function j(e){return"%"+("00"+e.toString(16).toUpperCase()).slice(-2)}function V(e){for(var t=function(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102},n=new Uint8Array(e.length),r=0,i=0;i=e.length-2)n[r]=o,r++;else if(37!==o||t(e[i+1])&&t(e[i+2])){var s=parseInt(a.utf8Decode(Uint8Array.of(e[i+1],e[i+2])),16);n[r]=s,r++,i+=2}else n[r]=o,r++}return n.subarray(0,r)}function W(e){return V(a.utf8Encode(e))}function z(e,t){var n,i;if(!t.test(e))return e;var o=a.utf8Encode(e),s="";try{for(var l=r(o),c=l.next();!c.done;c=l.next())s+=j(c.value)}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}return s}function G(e){var t,n,i,o,s=[],l=[];try{for(var c=r(e),u=c.next();!u.done;u=c.next()){var d=u.value;38===d?(s.push(Uint8Array.from(l)),l=[]):l.push(d)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}0!==l.length&&s.push(Uint8Array.from(l));var h=[];try{for(var p=r(s),f=p.next();!f.done;f=p.next()){var m=f.value;if(0!==m.length){for(var g=m.indexOf(61),v=-1!==g?m.slice(0,g):m,y=-1!==g?m.slice(g+1):new Uint8Array,_=0;_=48&&s<=57||s>=65&&s<=90||95===s||s>=97&&s<=122?String.fromCodePoint(s):j(s)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return i}function q(e,t){void 0===t&&(t=!1);var n=c.domainToASCII(e);return""===n?(v("Invalid domain name."),null):n}t.setValidationErrorCallback=function(e){o=e},t.newURL=y,t.isSpecialScheme=_,t.isSpecial=b,t.defaultPort=E,t.includesCredentials=w,t.cannotHaveAUsernamePasswordPort=function(e){return null===e.host||""===e.host||e._cannotBeABaseURLFlag||"file"===e.scheme},t.urlSerializer=x,t.hostSerializer=C,t.iPv4Serializer=D,t.iPv6Serializer=S,t.urlParser=function(e,t,n){var r=T(e,t,n);return null===r?null:("blob"!==r.scheme||(r._blobURLEntry=null),r)},t.basicURLParser=T,t.setTheUsername=function(e,t){var n,i,o="";try{for(var a=r(t),s=a.next();!s.done;s=a.next())o+=z(s.value,f)}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}e.username=o},t.setThePassword=function(e,t){var n,i,o="";try{for(var a=r(t),s=a.next();!s.done;s=a.next())o+=z(s.value,f)}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}e.password=o},t.isSingleDotPathSegment=I,t.isDoubleDotPathSegment=A,t.shorten=N,t.isNormalizedWindowsDriveLetter=O,t.isWindowsDriveLetter=P,t.startsWithAWindowsDriveLetter=k,t.hostParser=M,t.iPv4NumberParser=L,t.iPv4Parser=R,t.iPv6Parser=F,t.opaqueHostParser=U,t.resolveABlobURL=B,t.percentEncode=j,t.percentDecode=V,t.stringPercentDecode=W,t.utf8PercentEncode=z,t.hostEquals=function(e,t){return e===t},t.urlEquals=function(e,t,n){return void 0===n&&(n=!1),x(e,n)===x(t,n)},t.urlEncodedStringParser=function(e){return G(a.utf8Encode(e))},t.urlEncodedParser=G,t.urlEncodedByteSerializer=H,t.urlEncodedSerializer=function(e,t){var n,i;if("UTF-8"!==(void 0===t||"replacement"===t||"UTF-16BE"===t||"UTF-16LE"===t?"UTF-8":t).toUpperCase())throw new Error("Only UTF-8 encoding is supported.");var o="";try{for(var s=r(e),l=s.next();!l.done;l=s.next()){var c=l.value,u=H(a.utf8Encode(c[0])),d=c[1];d=H(a.utf8Encode(d)),""!==o&&(o+="&"),o+=u+"="+d}}catch(e){n={error:e}}finally{try{l&&!l.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}return o},t.origin=function e(t){switch(t.scheme){case"blob":t._blobURLEntry;var n=T(t.path[0]);return null===n?s.OpaqueOrigin:e(n);case"ftp":case"http":case"https":case"ws":case"wss":return[t.scheme,null===t.host?"":t.host,t.port,null];default:return s.OpaqueOrigin}},t.domainToASCII=q,t.domainToUnicode=function(e,t){void 0===t&&(t=!1);var n=c.domainToUnicode(e);return""===n&&v("Invalid domain name."),n},t.asciiSerializationOfAnOrigin=function(e){if(""===e[0]&&""===e[1]&&null===e[2]&&null===e[3])return"null";var t=e[0]+"://"+C(e[1]);return null!==e[2]&&(t+=":"+e[2].toString()),t}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=function(){function e(){this._signal=r.create_abortSignal()}return Object.defineProperty(e.prototype,"signal",{get:function(){return this._signal},enumerable:!0,configurable:!0}),e.prototype.abort=function(){r.abort_signalAbort(this._signal)},e}();t.AbortControllerImpl=i},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=n(70),a=n(0),s=function(e){function t(){var t=e.call(this)||this;return t._abortedFlag=!1,t._abortAlgorithms=new Set,t}return i(t,e),Object.defineProperty(t.prototype,"aborted",{get:function(){return this._abortedFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onabort",{get:function(){return a.event_getterEventHandlerIDLAttribute(this,"onabort")},set:function(e){a.event_setterEventHandlerIDLAttribute(this,"onabort",e)},enumerable:!0,configurable:!0}),t._create=function(){return new t},t}(o.EventTargetImpl);t.AbortSignalImpl=s},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),a=n(34),s=n(12),l=function(e){function t(t,n,r){var i=e.call(this)||this;return i._name="",i._publicId="",i._systemId="",i._name=t,i._publicId=n,i._systemId=r,i}return i(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"publicId",{get:function(){return this._publicId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"systemId",{get:function(){return this._systemId},enumerable:!0,configurable:!0}),t.prototype.before=function(){for(var e=[],t=0;t=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(6),o=n(1),a=n(0),s=function(){function e(e){return this._live=!0,this._filter=null,this._length=0,this._root=e,new Proxy(this,this)}return Object.defineProperty(e.prototype,"length",{get:function(){return this._root._children.size},enumerable:!0,configurable:!0}),e.prototype.item=function(e){if(e<0||e>this.length-1)return null;if(e=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(6),o=n(1),a=function(){function e(e){return this._live=!1,this._items=[],this._length=0,this._root=e,this._items=[],this._filter=function(e){return!0},new Proxy(this,this)}return Object.defineProperty(e.prototype,"length",{get:function(){return this._items.length},enumerable:!0,configurable:!0}),e.prototype.item=function(e){return e<0||e>this.length-1?null:this._items[e]},e.prototype.keys=function(){var e;return(e={})[Symbol.iterator]=function(){var e=0;return{next:function(){return e===this.length?{done:!0,value:null}:{done:!1,value:e++}}.bind(this)}}.bind(this),e},e.prototype.values=function(){var e;return(e={})[Symbol.iterator]=function(){var e=this[Symbol.iterator]();return{next:function(){return e.next()}}}.bind(this),e},e.prototype.entries=function(){var e;return(e={})[Symbol.iterator]=function(){var e=this[Symbol.iterator](),t=0;return{next:function(){var n=e.next();return n.done?{done:!0,value:null}:{done:!1,value:[t++,n.value]}}}}.bind(this),e},e.prototype[Symbol.iterator]=function(){var e=this._items[Symbol.iterator]();return{next:function(){return e.next()}}},e.prototype.forEach=function(e,t){var n,o;void 0===t&&(t=i.dom.window);var a=0;try{for(var s=r(this._items),l=s.next();!l.done;l=s.next()){var c=l.value;e.call(t,c,a++,this)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}},e.prototype.get=function(e,t,n){if(!o.isString(t))return Reflect.get(e,t,n);var r=Number(t);return isNaN(r)?Reflect.get(e,t,n):e._items[r]||void 0},e.prototype.set=function(e,t,n,r){if(!o.isString(t))return Reflect.set(e,t,n,r);var i=Number(t);return isNaN(i)?Reflect.set(e,t,n,r):i>=0&&i=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0});var a=n(6),s=n(2),l=n(102),c=n(9),u=n(0),d=n(12),h=n(3),p=function(e){function t(){var t=e.call(this)||this,n=a.dom.window._associatedDocument;return t._start=[n,0],t._end=[n,0],a.dom.rangeList.add(t),t}return i(t,e),Object.defineProperty(t.prototype,"commonAncestorContainer",{get:function(){for(var e=this._start[0];!u.tree_isAncestorOf(this._end[0],e,!0);){if(null===e._parent)throw new Error("Parent node is null.");e=e._parent}return e},enumerable:!0,configurable:!0}),t.prototype.setStart=function(e,t){u.range_setTheStart(this,e,t)},t.prototype.setEnd=function(e,t){u.range_setTheEnd(this,e,t)},t.prototype.setStartBefore=function(e){var t=e._parent;if(null===t)throw new c.InvalidNodeTypeError;u.range_setTheStart(this,t,u.tree_index(e))},t.prototype.setStartAfter=function(e){var t=e._parent;if(null===t)throw new c.InvalidNodeTypeError;u.range_setTheStart(this,t,u.tree_index(e)+1)},t.prototype.setEndBefore=function(e){var t=e._parent;if(null===t)throw new c.InvalidNodeTypeError;u.range_setTheEnd(this,t,u.tree_index(e))},t.prototype.setEndAfter=function(e){var t=e._parent;if(null===t)throw new c.InvalidNodeTypeError;u.range_setTheEnd(this,t,u.tree_index(e)+1)},t.prototype.collapse=function(e){e?this._end=this._start:this._start=this._end},t.prototype.selectNode=function(e){u.range_select(e,this)},t.prototype.selectNodeContents=function(e){if(h.Guard.isDocumentTypeNode(e))throw new c.InvalidNodeTypeError;var t=u.tree_nodeLength(e);this._start=[e,0],this._end=[e,t]},t.prototype.compareBoundaryPoints=function(e,t){if(e!==s.HowToCompare.StartToStart&&e!==s.HowToCompare.StartToEnd&&e!==s.HowToCompare.EndToEnd&&e!==s.HowToCompare.EndToStart)throw new c.NotSupportedError;if(u.range_root(this)!==u.range_root(t))throw new c.WrongDocumentError;var n,r;switch(e){case s.HowToCompare.StartToStart:n=this._start,r=t._start;break;case s.HowToCompare.StartToEnd:n=this._end,r=t._start;break;case s.HowToCompare.EndToEnd:n=this._end,r=t._end;break;case s.HowToCompare.EndToStart:n=this._start,r=t._end;break;default:throw new c.NotSupportedError}var i=u.boundaryPoint_position(n,r);return i===s.BoundaryPosition.Before?-1:i===s.BoundaryPosition.After?1:0},t.prototype.deleteContents=function(){var e,t,n,r;if(!u.range_collapsed(this)){var i=this._startNode,a=this._startOffset,s=this._endNode,l=this._endOffset;if(i===s&&h.Guard.isCharacterDataNode(i))u.characterData_replaceData(i,a,l-a,"");else{var c,d,p=[];try{for(var f=o(u.range_getContainedNodes(this)),m=f.next();!m.done;m=f.next()){var g=(b=m.value)._parent;null!==g&&u.range_isContained(g,this)||p.push(b)}}catch(t){e={error:t}}finally{try{m&&!m.done&&(t=f.return)&&t.call(f)}finally{if(e)throw e.error}}if(u.tree_isAncestorOf(s,i,!0))c=i,d=a;else{for(var v=i;null!==v._parent&&!u.tree_isAncestorOf(s,v._parent,!0);)v=v._parent;if(null===v._parent)throw new Error("Parent node is null.");c=v._parent,d=u.tree_index(v)+1}h.Guard.isCharacterDataNode(i)&&u.characterData_replaceData(i,a,u.tree_nodeLength(i)-a,"");try{for(var y=o(p),_=y.next();!_.done;_=y.next()){var b;(b=_.value)._parent&&u.mutation_remove(b,b._parent)}}catch(e){n={error:e}}finally{try{_&&!_.done&&(r=y.return)&&r.call(y)}finally{if(n)throw n.error}}h.Guard.isCharacterDataNode(s)&&u.characterData_replaceData(s,0,l,""),this._start=[c,d],this._end=[c,d]}}},t.prototype.extractContents=function(){return u.range_extract(this)},t.prototype.cloneContents=function(){return u.range_cloneTheContents(this)},t.prototype.insertNode=function(e){return u.range_insert(e,this)},t.prototype.surroundContents=function(e){var t,n;try{for(var r=o(u.range_getPartiallyContainedNodes(this)),i=r.next();!i.done;i=r.next()){var a=i.value;if(!h.Guard.isTextNode(a))throw new c.InvalidStateError}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}if(h.Guard.isDocumentNode(e)||h.Guard.isDocumentTypeNode(e)||h.Guard.isDocumentFragmentNode(e))throw new c.InvalidNodeTypeError;var s=u.range_extract(this);0!==e._children.size&&u.mutation_replaceAll(null,e),u.range_insert(e,this),u.mutation_append(s,e),u.range_select(e,this)},t.prototype.cloneRange=function(){return u.create_range(this._start,this._end)},t.prototype.detach=function(){a.dom.rangeList.delete(this)},t.prototype.isPointInRange=function(e,t){if(u.tree_rootNode(e)!==u.range_root(this))return!1;if(h.Guard.isDocumentTypeNode(e))throw new c.InvalidNodeTypeError;if(t>u.tree_nodeLength(e))throw new c.IndexSizeError;var n=[e,t];return u.boundaryPoint_position(n,this._start)!==s.BoundaryPosition.Before&&u.boundaryPoint_position(n,this._end)!==s.BoundaryPosition.After},t.prototype.comparePoint=function(e,t){if(u.tree_rootNode(e)!==u.range_root(this))throw new c.WrongDocumentError;if(h.Guard.isDocumentTypeNode(e))throw new c.InvalidNodeTypeError;if(t>u.tree_nodeLength(e))throw new c.IndexSizeError;var n=[e,t];return u.boundaryPoint_position(n,this._start)===s.BoundaryPosition.Before?-1:u.boundaryPoint_position(n,this._end)===s.BoundaryPosition.After?1:0},t.prototype.intersectsNode=function(e){if(u.tree_rootNode(e)!==u.range_root(this))return!1;var t=e._parent;if(null===t)return!0;var n=u.tree_index(e);return u.boundaryPoint_position([t,n],this._end)===s.BoundaryPosition.Before&&u.boundaryPoint_position([t,n+1],this._start)===s.BoundaryPosition.After},t.prototype.toString=function(){var e,t,n="";if(this._startNode===this._endNode&&h.Guard.isTextNode(this._startNode))return this._startNode._data.substring(this._startOffset,this._endOffset);h.Guard.isTextNode(this._startNode)&&(n+=this._startNode._data.substring(this._startOffset));try{for(var r=o(u.range_getContainedNodes(this)),i=r.next();!i.done;i=r.next()){var a=i.value;h.Guard.isTextNode(a)&&(n+=a._data)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return h.Guard.isTextNode(this._endNode)&&(n+=this._endNode._data.substring(0,this._endOffset)),n},t._create=function(e,n){var r=new t;return e&&(r._start=e),n&&(r._end=n),r},t.START_TO_START=0,t.START_TO_END=1,t.END_TO_END=2,t.END_TO_START=3,t}(l.AbstractRangeImpl);t.RangeImpl=p,d.idl_defineConst(p.prototype,"START_TO_START",0),d.idl_defineConst(p.prototype,"START_TO_END",1),d.idl_defineConst(p.prototype,"END_TO_END",2),d.idl_defineConst(p.prototype,"END_TO_START",3)},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=n(103),a=n(0),s=function(e){function t(t,n,r){var i=e.call(this,t)||this;return i._iteratorCollection=void 0,i._reference=n,i._pointerBeforeReference=r,a.nodeIterator_iteratorList().add(i),i}return i(t,e),Object.defineProperty(t.prototype,"referenceNode",{get:function(){return this._reference},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointerBeforeReferenceNode",{get:function(){return this._pointerBeforeReference},enumerable:!0,configurable:!0}),t.prototype.nextNode=function(){return a.nodeIterator_traverse(this,!0)},t.prototype.previousNode=function(){return a.nodeIterator_traverse(this,!1)},t.prototype.detach=function(){a.nodeIterator_iteratorList().delete(this)},t._create=function(e,n,r){return new t(e,n,r)},t}(o.TraverserImpl);t.NodeIteratorImpl=s},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),a=n(103),s=n(0),l=function(e){function t(t,n){var r=e.call(this,t)||this;return r._current=n,r}return i(t,e),Object.defineProperty(t.prototype,"currentNode",{get:function(){return this._current},set:function(e){this._current=e},enumerable:!0,configurable:!0}),t.prototype.parentNode=function(){for(var e=this._current;null!==e&&e!==this._root;)if(null!==(e=e._parent)&&s.traversal_filter(this,e)===o.FilterResult.Accept)return this._current=e,e;return null},t.prototype.firstChild=function(){return s.treeWalker_traverseChildren(this,!0)},t.prototype.lastChild=function(){return s.treeWalker_traverseChildren(this,!1)},t.prototype.nextSibling=function(){return s.treeWalker_traverseSiblings(this,!0)},t.prototype.previousNode=function(){for(var e=this._current;e!==this._root;){for(var t=e._previousSibling;t;){e=t;for(var n=s.traversal_filter(this,e);n!==o.FilterResult.Reject&&e._lastChild;)e=e._lastChild,n=s.traversal_filter(this,e);if(n===o.FilterResult.Accept)return this._current=e,e;t=e._previousSibling}if(e===this._root||null===e._parent)return null;if(e=e._parent,s.traversal_filter(this,e)===o.FilterResult.Accept)return this._current=e,e}return null},t.prototype.previousSibling=function(){return s.treeWalker_traverseSiblings(this,!1)},t.prototype.nextNode=function(){for(var e=this._current,t=o.FilterResult.Accept;;){for(;t!==o.FilterResult.Reject&&e._firstChild;)if(e=e._firstChild,(t=s.traversal_filter(this,e))===o.FilterResult.Accept)return this._current=e,e;for(var n=null,r=e;null!==r;){if(r===this._root)return null;if(null!==(n=r._nextSibling)){e=n;break}r=r._parent}if((t=s.traversal_filter(this,e))===o.FilterResult.Accept)return this._current=e,e}},t._create=function(e,n){return new t(e,n)},t}(a.TraverserImpl);t.TreeWalkerImpl=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),i=n(12),o=function(){function e(){}return e.prototype.acceptNode=function(e){return r.FilterResult.Accept},e._create=function(){return new e},e.FILTER_ACCEPT=1,e.FILTER_REJECT=2,e.FILTER_SKIP=3,e.SHOW_ALL=4294967295,e.SHOW_ELEMENT=1,e.SHOW_ATTRIBUTE=2,e.SHOW_TEXT=4,e.SHOW_CDATA_SECTION=8,e.SHOW_ENTITY_REFERENCE=16,e.SHOW_ENTITY=32,e.SHOW_PROCESSING_INSTRUCTION=64,e.SHOW_COMMENT=128,e.SHOW_DOCUMENT=256,e.SHOW_DOCUMENT_TYPE=512,e.SHOW_DOCUMENT_FRAGMENT=1024,e.SHOW_NOTATION=2048,e}();t.NodeFilterImpl=o,i.idl_defineConst(o.prototype,"FILTER_ACCEPT",1),i.idl_defineConst(o.prototype,"FILTER_REJECT",2),i.idl_defineConst(o.prototype,"FILTER_SKIP",3),i.idl_defineConst(o.prototype,"SHOW_ALL",4294967295),i.idl_defineConst(o.prototype,"SHOW_ELEMENT",1),i.idl_defineConst(o.prototype,"SHOW_ATTRIBUTE",2),i.idl_defineConst(o.prototype,"SHOW_TEXT",4),i.idl_defineConst(o.prototype,"SHOW_CDATA_SECTION",8),i.idl_defineConst(o.prototype,"SHOW_ENTITY_REFERENCE",16),i.idl_defineConst(o.prototype,"SHOW_ENTITY",32),i.idl_defineConst(o.prototype,"SHOW_PROCESSING_INSTRUCTION",64),i.idl_defineConst(o.prototype,"SHOW_COMMENT",128),i.idl_defineConst(o.prototype,"SHOW_DOCUMENT",256),i.idl_defineConst(o.prototype,"SHOW_DOCUMENT_TYPE",512),i.idl_defineConst(o.prototype,"SHOW_DOCUMENT_FRAGMENT",1024),i.idl_defineConst(o.prototype,"SHOW_NOTATION",2048)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t,n,r,i,o,a,s,l){this._type=e,this._target=t,this._addedNodes=n,this._removedNodes=r,this._previousSibling=i,this._nextSibling=o,this._attributeName=a,this._attributeNamespace=s,this._oldValue=l}return Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"addedNodes",{get:function(){return this._addedNodes},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"removedNodes",{get:function(){return this._removedNodes},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){return this._previousSibling},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){return this._nextSibling},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"attributeName",{get:function(){return this._attributeName},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"attributeNamespace",{get:function(){return this._attributeNamespace},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"oldValue",{get:function(){return this._oldValue},enumerable:!0,configurable:!0}),e._create=function(t,n,r,i,o,a,s,l,c){return new e(t,n,r,i,o,a,s,l,c)},e}();t.MutationRecordImpl=r},function(e,t,n){"use strict";var r=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(6),o=n(9),a=n(7),s=n(0),l=function(){function e(e,t){this._element=e,this._attribute=t,this._tokenSet=new Set;var n=t._localName,r=s.element_getAnAttributeValue(e,n),o=this;this._element._attributeChangeSteps.push((function(e,t,n,r,i){t===o._attribute._localName&&null===i&&(r?o._tokenSet=s.orderedSet_parse(r):o._tokenSet.clear())})),i.dom.features.steps&&s.dom_runAttributeChangeSteps(e,n,r,r,null)}return Object.defineProperty(e.prototype,"length",{get:function(){return this._tokenSet.size},enumerable:!0,configurable:!0}),e.prototype.item=function(e){var t,n,i=0;try{for(var o=r(this._tokenSet),a=o.next();!a.done;a=o.next()){var s=a.value;if(i===e)return s;i++}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return null},e.prototype.contains=function(e){return this._tokenSet.has(e)},e.prototype.add=function(){for(var e,t,n=[],i=0;i=97&&n<=122||n>=65&&n<=90||58===n||95===n||n>=192&&n<=214||n>=216&&n<=246||n>=248&&n<=767||n>=880&&n<=893||n>=895&&n<=8191||n>=8204&&n<=8205||n>=8304&&n<=8591||n>=11264&&n<=12271||n>=12289&&n<=55295||n>=63744&&n<=64975||n>=65008&&n<=65533||0!==t&&(45===n||46===n||n>=48&&n<=57||183===n||n>=768&&n<=879||n>=8255&&n<=8256))){if(n>=55296&&n<=56319&&t=56320&&r<=57343&&(t++,(n=1024*(n-55296)+r-56320+65536)>=65536&&n<=983039))continue}return!1}}return!0},t.xml_isQName=function(e){for(var t=!1,n=0;n=97&&r<=122||r>=65&&r<=90||95===r||r>=192&&r<=214||r>=216&&r<=246||r>=248&&r<=767||r>=880&&r<=893||r>=895&&r<=8191||r>=8204&&r<=8205||r>=8304&&r<=8591||r>=11264&&r<=12271||r>=12289&&r<=55295||r>=63744&&r<=64975||r>=65008&&r<=65533||0!==n&&(45===r||46===r||r>=48&&r<=57||183===r||r>=768&&r<=879||r>=8255&&r<=8256))){if(0===n||58!==r){if(r>=55296&&r<=56319&&n=56320&&i<=57343&&(n++,(r=1024*(r-55296)+i-56320+65536)>=65536&&r<=983039))continue}return!1}if(t)return!1;if(n===e.length-1)return!1;t=!0}}return!0},t.xml_isLegalChar=function(e){for(var t=0;t=32&&n<=55295||n>=57344&&n<=65533)){if(n>=55296&&n<=56319&&t=56320&&r<=57343&&(t++,(n=1024*(n-55296)+r-56320+65536)>=65536&&n<=1114111))continue}return!1}}return!0},t.xml_isPubidChar=function(e){for(var t=0;t=97&&n<=122||n>=65&&n<=90||n>=39&&n<=59||32===n||13===n||10===n||n>=35&&n<=37||33===n||61===n||63===n||64===n||95===n))return!1}return!0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),i=n(17);t.boundaryPoint_position=function e(t,n){var o=t[0],a=t[1],s=n[0],l=n[1];if(console.assert(i.tree_rootNode(o)===i.tree_rootNode(s),"Boundary points must share the same root node."),o===s)return a===l?r.BoundaryPosition.Equal:a=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(6),o=n(3),a=n(7),s=n(29),l=n(108),c=n(30),u=n(37),d=n(52);t.node_stringReplaceAll=function(e,t){var n=null;""!==e&&(n=s.create_text(t._nodeDocument,e)),u.mutation_replaceAll(n,t)},t.node_clone=function e(t,n,a){var l,h,p,f,m;if(void 0===n&&(n=null),void 0===a&&(a=!1),null===n&&(n=t._nodeDocument),o.Guard.isElementNode(t)){m=d.element_createAnElement(n,t._localName,t._namespace,t._namespacePrefix,t._is,!1);try{for(var g=r(t._attributeList),v=g.next();!v.done;v=g.next()){var y=e(v.value,n);d.element_append(y,m)}}catch(e){l={error:e}}finally{try{v&&!v.done&&(h=g.return)&&h.call(g)}finally{if(l)throw l.error}}}else if(o.Guard.isDocumentNode(t)){var _=s.create_document();_._encoding=t._encoding,_._contentType=t._contentType,_._URL=t._URL,_._origin=t._origin,_._type=t._type,_._mode=t._mode,m=_}else if(o.Guard.isDocumentTypeNode(t))m=s.create_documentType(n,t._name,t._publicId,t._systemId);else if(o.Guard.isAttrNode(t)){var b=s.create_attr(n,t.localName);b._namespace=t._namespace,b._namespacePrefix=t._namespacePrefix,b._value=t._value,m=b}else m=o.Guard.isExclusiveTextNode(t)?s.create_text(n,t._data):o.Guard.isCDATASectionNode(t)?s.create_cdataSection(n,t._data):o.Guard.isCommentNode(t)?s.create_comment(n,t._data):o.Guard.isProcessingInstructionNode(t)?s.create_processingInstruction(n,t._target,t._data):o.Guard.isDocumentFragmentNode(t)?s.create_documentFragment(n):Object.create(t);if(o.Guard.isDocumentNode(m)?(m._nodeDocument=m,n=m):m._nodeDocument=n,i.dom.features.steps&&c.dom_runCloningSteps(m,t,n,a),a)try{for(var E=r(t._children),w=E.next();!w.done;w=E.next()){var x=e(w.value,n,!0);u.mutation_append(x,m)}}catch(e){p={error:e}}finally{try{w&&!w.done&&(f=E.return)&&f.call(E)}finally{if(p)throw p.error}}return m},t.node_equals=function e(t,n){var i,a,s,l;if(t._nodeType!==n._nodeType)return!1;if(o.Guard.isDocumentTypeNode(t)&&o.Guard.isDocumentTypeNode(n)){if(t._name!==n._name||t._publicId!==n._publicId||t._systemId!==n._systemId)return!1}else if(o.Guard.isElementNode(t)&&o.Guard.isElementNode(n)){if(t._namespace!==n._namespace||t._namespacePrefix!==n._namespacePrefix||t._localName!==n._localName||t._attributeList.length!==n._attributeList.length)return!1}else if(o.Guard.isAttrNode(t)&&o.Guard.isAttrNode(n)){if(t._namespace!==n._namespace||t._localName!==n._localName||t._value!==n._value)return!1}else if(o.Guard.isProcessingInstructionNode(t)&&o.Guard.isProcessingInstructionNode(n)){if(t._target!==n._target||t._data!==n._data)return!1}else if(o.Guard.isCharacterDataNode(t)&&o.Guard.isCharacterDataNode(n)&&t._data!==n._data)return!1;if(o.Guard.isElementNode(t)&&o.Guard.isElementNode(n)){var c={};try{for(var u=r(t._attributeList),d=u.next();!d.done;d=u.next())c[(f=d.value)._localName]=f}catch(e){i={error:e}}finally{try{d&&!d.done&&(a=u.return)&&a.call(u)}finally{if(i)throw i.error}}try{for(var h=r(n._attributeList),p=h.next();!p.done;p=h.next()){var f,m=p.value;if(!(f=c[m._localName]))return!1;if(!e(f,m))return!1}}catch(e){s={error:e}}finally{try{p&&!p.done&&(l=h.return)&&l.call(h)}finally{if(s)throw s.error}}}if(t._children.size!==n._children.size)return!1;for(var g=t._children[Symbol.iterator](),v=n._children[Symbol.iterator](),y=g.next(),_=v.next();!y.done&&!_.done;){if(!e(y.value,_.value))return!1;y=g.next(),_=v.next()}return!0},t.node_listOfElementsWithQualifiedName=function(e,t){return"*"===e?s.create_htmlCollection(t):"html"===t._nodeDocument._type?s.create_htmlCollection(t,(function(t){return t._namespace===a.namespace.HTML&&t._qualifiedName===e.toLowerCase()||t._namespace!==a.namespace.HTML&&t._qualifiedName===e})):s.create_htmlCollection(t,(function(t){return t._qualifiedName===e}))},t.node_listOfElementsWithNamespace=function(e,t,n){return""===e&&(e=null),"*"===e&&"*"===t?s.create_htmlCollection(n):"*"===e?s.create_htmlCollection(n,(function(e){return e._localName===t})):"*"===t?s.create_htmlCollection(n,(function(t){return t._namespace===e})):s.create_htmlCollection(n,(function(n){return n._localName===t&&n._namespace===e}))},t.node_listOfElementsWithClassNames=function(e,t){var n=l.orderedSet_parse(e);if(0===n.size)return s.create_htmlCollection(t,(function(){return!1}));var r="quirks"!==t._nodeDocument._mode;return s.create_htmlCollection(t,(function(e){var t=e.classList;return l.orderedSet_contains(t._tokenSet,n,r)}))},t.node_locateANamespacePrefix=function e(t,n){if(t._namespace===n&&null!==t._namespacePrefix)return t._namespacePrefix;for(var r=0;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.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(6),o=n(3),a=n(9),s=n(29),l=n(17),c=n(107),u=n(37);t.text_contiguousTextNodes=function(e,t){var n;return void 0===t&&(t=!1),(n={})[Symbol.iterator]=function(){for(var n=e;n&&o.Guard.isTextNode(n._previousSibling);)n=n._previousSibling;return{next:function(){if(n&&!t&&n===e&&(n=o.Guard.isTextNode(n._nextSibling)?n._nextSibling:null),null===n)return{done:!0,value:null};var r={done:!1,value:n};return n=o.Guard.isTextNode(n._nextSibling)?n._nextSibling:null,r}}},n},t.text_contiguousExclusiveTextNodes=function(e,t){var n;return void 0===t&&(t=!1),(n={})[Symbol.iterator]=function(){for(var n=e;n&&o.Guard.isExclusiveTextNode(n._previousSibling);)n=n._previousSibling;return{next:function(){if(n&&!t&&n===e&&(n=o.Guard.isExclusiveTextNode(n._nextSibling)?n._nextSibling:null),null===n)return{done:!0,value:null};var r={done:!1,value:n};return n=o.Guard.isExclusiveTextNode(n._nextSibling)?n._nextSibling:null,r}}},n},t.text_descendantTextContent=function(e){for(var t="",n=l.tree_getFirstDescendantNode(e,!1,!1,(function(e){return o.Guard.isTextNode(e)}));null!==n;)t+=n._data,n=l.tree_getNextDescendantNode(e,n,!1,!1,(function(e){return o.Guard.isTextNode(e)}));return t},t.text_split=function(e,t){var n,o,d=e._data.length;if(t>d)throw new a.IndexSizeError;var h=d-t,p=c.characterData_substringData(e,t,h),f=s.create_text(e._nodeDocument,p),m=e._parent;if(null!==m){u.mutation_insert(f,m,e._nextSibling);try{for(var g=r(i.dom.rangeList),v=g.next();!v.done;v=g.next()){var y=v.value;y._start[0]===e&&y._start[1]>t&&(y._start[0]=f,y._start[1]-=t),y._end[0]===e&&y._end[1]>t&&(y._end[0]=f,y._end[1]-=t);var _=l.tree_index(e);y._start[0]===m&&y._start[1]===_+1&&y._start[1]++,y._end[0]===m&&y._end[1]===_+1&&y._end[1]++}}catch(e){n={error:e}}finally{try{v&&!v.done&&(o=g.return)&&o.call(g)}finally{if(n)throw n.error}}}return c.characterData_replaceData(e,t,h,""),f}},function(e,t,n){"use strict";var r=n(4),i=n(41),o=n(24),a=n(48),s=[].join,l=i!=Object,c=a("join",",");r({target:"Array",proto:!0,forced:l||!c},{join:function(e){return s.call(o(this),void 0===e?",":e)}})},function(e,t,n){var r=n(4),i=n(83),o=String.fromCharCode,a=String.fromCodePoint;r({target:"String",stat:!0,forced:!!a&&1!=a.length},{fromCodePoint:function(e){for(var t,n=[],r=arguments.length,a=0;r>a;){if(t=+arguments[a++],i(t,1114111)!==t)throw RangeError(t+" is not a valid code point");n.push(t<65536?o(t):o(55296+((t-=65536)>>10),t%1024+56320))}return n.join("")}})},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(111),o=function(){function e(e,t){this._options={skipWhitespaceOnlyText:!1},this.err={line:-1,col:-1,index:-1,str:""},this._str=e,this._index=0,this._length=e.length,t&&(this._options.skipWhitespaceOnlyText=t.skipWhitespaceOnlyText||!1)}return e.prototype.nextToken=function(){if(this.eof())return{type:i.TokenType.EOF};var t=this.skipIfStartsWith("<")?this.openBracket():this.text();return this._options.skipWhitespaceOnlyText&&t.type===i.TokenType.Text&&e.isWhiteSpaceToken(t)&&(t=this.nextToken()),t},e.prototype.openBracket=function(){return this.skipIfStartsWith("?")?this.skipIfStartsWith("xml")?e.isSpace(this._str[this._index])?this.declaration():(this.seek(-3),this.pi()):this.pi():this.skipIfStartsWith("!")?this.skipIfStartsWith("--")?this.comment():this.skipIfStartsWith("[CDATA[")?this.cdata():this.skipIfStartsWith("DOCTYPE")?this.doctype():void this.throwError("Invalid '!' in opening tag."):this.skipIfStartsWith("/")?this.closeTag():this.openTag()},e.prototype.declaration=function(){for(var e="",t="",n="";!this.eof();){if(this.skipSpace(),this.skipIfStartsWith("?>"))return{type:i.TokenType.Declaration,version:e,encoding:t,standalone:n};var o=r(this.attribute(),2),a=o[0],s=o[1];"version"===a?e=s:"encoding"===a?t=s:"standalone"===a?n=s:this.throwError("Invalid attribute name: "+a)}this.throwError("Missing declaration end symbol `?>`")},e.prototype.doctype=function(){var e="",t="";this.skipSpace();var n=this.takeUntil2("[",">",!0);return this.skipSpace(),this.skipIfStartsWith("PUBLIC")?(e=this.quotedString(),t=this.quotedString()):this.skipIfStartsWith("SYSTEM")&&(t=this.quotedString()),this.skipSpace(),this.skipIfStartsWith("[")&&(this.skipUntil("]"),this.skipIfStartsWith("]")||this.throwError("Missing end bracket of DTD internal subset")),this.skipSpace(),this.skipIfStartsWith(">")||this.throwError("Missing doctype end symbol `>`"),{type:i.TokenType.DocType,name:n,pubId:e,sysId:t}},e.prototype.pi=function(){var e=this.takeUntilStartsWith("?>",!0);if(this.eof()&&this.throwError("Missing processing instruction end symbol `?>`"),this.skipSpace(),this.skipIfStartsWith("?>"))return{type:i.TokenType.PI,target:e,data:""};var t=this.takeUntilStartsWith("?>");return this.eof()&&this.throwError("Missing processing instruction end symbol `?>`"),this.seek(2),{type:i.TokenType.PI,target:e,data:t}},e.prototype.text=function(){var e=this.takeUntil("<");return{type:i.TokenType.Text,data:e}},e.prototype.comment=function(){var e=this.takeUntilStartsWith("--\x3e");return this.eof()&&this.throwError("Missing comment end symbol `--\x3e`"),this.seek(3),{type:i.TokenType.Comment,data:e}},e.prototype.cdata=function(){var e=this.takeUntilStartsWith("]]>");return this.eof()&&this.throwError("Missing CDATA end symbol `]>`"),this.seek(3),{type:i.TokenType.CDATA,data:e}},e.prototype.openTag=function(){this.skipSpace();var e=this.takeUntil2(">","/",!0);if(this.skipSpace(),this.skipIfStartsWith(">"))return{type:i.TokenType.Element,name:e,attributes:[],selfClosing:!1};if(this.skipIfStartsWith("/>"))return{type:i.TokenType.Element,name:e,attributes:[],selfClosing:!0};for(var t=[];!this.eof();){if(this.skipSpace(),this.skipIfStartsWith(">"))return{type:i.TokenType.Element,name:e,attributes:t,selfClosing:!1};if(this.skipIfStartsWith("/>"))return{type:i.TokenType.Element,name:e,attributes:t,selfClosing:!0};var n=this.attribute();t.push(n)}this.throwError("Missing opening element tag end symbol `>`")},e.prototype.closeTag=function(){this.skipSpace();var e=this.takeUntil(">",!0);return this.skipSpace(),this.skipIfStartsWith(">")||this.throwError("Missing closing element tag end symbol `>`"),{type:i.TokenType.ClosingTag,name:e}},e.prototype.attribute=function(){this.skipSpace();var e=this.takeUntil("=",!0);return this.skipSpace(),this.skipIfStartsWith("=")||this.throwError("Missing equals sign before attribute value"),[e,this.quotedString()]},e.prototype.quotedString=function(){this.skipSpace();var t=this.take(1);e.isQuote(t)||this.throwError("Missing start quote character before quoted value");var n=this.takeUntil(t);return this.skipIfStartsWith(t)||this.throwError("Missing end quote character after quoted value"),n},e.prototype.eof=function(){return this._index>=this._length},e.prototype.skipIfStartsWith=function(e){var t=e.length;if(1===t)return this._str[this._index]===e&&(this._index++,!0);for(var n=0;nthis._length&&(this._index=this._length)},e.prototype.skipSpace=function(){for(;!this.eof()&&e.isSpace(this._str[this._index]);)this._index++},e.prototype.take=function(e){if(1===e)return this._str[this._index++];var t=this._index;return this.seek(e),this._str.slice(t,this._index)},e.prototype.takeUntil=function(t,n){void 0===n&&(n=!1);for(var r=this._index;this._indexthis._index){o=n.index;break}throw this.err={line:r,col:this._index-i,index:this._index,str:this._str.substring(i,o)},new Error(e+"\nIndex: "+this.err.index+"\nLn: "+this.err.line+", Col: "+this.err.col+"\nInput: "+this.err.str)},e.prototype[Symbol.iterator]=function(){return this._index=0,{next:function(){var e=this.nextToken();return e.type===i.TokenType.EOF?{done:!0,value:null}:{done:!1,value:e}}.bind(this)}},e}();t.XMLStringLexer=o},function(e,t,n){"use strict";var r=n(39);e.exports=new r({include:[n(182)]})},function(e,t,n){"use strict";var r=n(39);e.exports=new r({include:[n(113)],implicit:[n(289),n(290),n(291),n(292)]})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(91),i=n(1),o=n(3),a=n(77),s=n(109);function l(e,t){var n=u(void 0===e||c(e)?e:r.DefaultBuilderOptions),i=c(e)?t:e,o=s.createDocument();d(o,n);var l=new a.XMLBuilderImpl(o);return void 0!==i&&l.ele(i),l}function c(e){if(!i.isPlainObject(e))return!1;for(var t in e)if(e.hasOwnProperty(t)&&!r.XMLBuilderOptionKeys.has(t))return!1;return!0}function u(e){void 0===e&&(e={});var t=i.applyDefaults(e,r.DefaultBuilderOptions);if(0===t.convert.att.length||0===t.convert.ins.length||0===t.convert.text.length||0===t.convert.cdata.length||0===t.convert.comment.length)throw new Error("JS object converter strings cannot be zero length.");return t}function d(e,t,n){var r=e;r._xmlBuilderOptions=t,r._isFragment=n}t.builder=function(e,t){var n=u(c(e)?e:r.DefaultBuilderOptions),s=o.Guard.isNode(e)||i.isArray(e)?e:t;if(void 0===s)throw new Error("Invalid arguments.");if(i.isArray(s)){for(var l=[],d=0;d0)&&!(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},i=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var o=n(91),a=n(1),s=n(217),l=n(2),c=n(3),u=n(0),d=n(109),h=n(7),p=n(276),f=function(){function e(e){this._domNode=e}return Object.defineProperty(e.prototype,"node",{get:function(){return this._domNode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this._options},enumerable:!0,configurable:!0}),e.prototype.set=function(e){return this._options=a.applyDefaults(a.applyDefaults(this._options,e,!0),o.DefaultBuilderOptions),this},e.prototype.ele=function(t,n,i){var o,s,l,c,h,f;if(a.isObject(t))return new p.ObjectReader(this._options).parse(this,t);if(null!==t&&/^\s*0&&(void 0===e&&(e=t.slice(r+1)),t=t.slice(0,r)),void 0===e)e=n?this._options.defaultNamespace.ele:this._options.defaultNamespace.att;else if(null!==e&&"@"===e[0]){var i=e.slice(1);if(void 0===(e=this._options.namespaceAlias[i]))throw new Error("Namespace alias `"+i+"` is not defined. "+this._debugInfo())}return[e,t]},e.prototype._updateNamespace=function(t){var n,o,a,s,l=this._domNode;if(c.Guard.isElementNode(l)&&null!==t&&l.namespaceURI!==t){var d=r(u.namespace_extractQName(l.prefix?l.prefix+":"+l.localName:l.localName),2),h=d[0],p=d[1],f=u.create_element(this._doc,p,t,h);try{for(var m=i(l.attributes),g=m.next();!g.done;g=m.next()){var v=g.value,y=v.prefix?v.prefix+":"+v.localName:v.localName,_=r(u.namespace_extractQName(y),1)[0],b=v.namespaceURI;null===b&&null!==_&&(b=l.lookupNamespaceURI(_)),null===b?f.setAttribute(y,v.value):f.setAttributeNS(b,y,v.value)}}catch(e){n={error:e}}finally{try{g&&!g.done&&(o=m.return)&&o.call(m)}finally{if(n)throw n.error}}var E=l.parentNode;if(null===E)throw new Error("Parent node is null."+this._debugInfo());E.replaceChild(f,l),this._domNode=f;try{for(var w=i(l.childNodes),x=w.next();!x.done;x=w.next()){var C=x.value.cloneNode(!0);if(f.appendChild(C),c.Guard.isElementNode(C)){var D=r(u.namespace_extractQName(C.prefix?C.prefix+":"+C.localName:C.localName),1)[0],S=f.lookupNamespaceURI(D);new e(C)._updateNamespace(S)}}}catch(e){a={error:e}}finally{try{x&&!x.done&&(s=w.return)&&s.call(w)}finally{if(a)throw a.error}}}},Object.defineProperty(e.prototype,"_doc",{get:function(){var e=this.node;if(c.Guard.isDocumentNode(e))return e;var t=e.ownerDocument;if(!t)throw new Error("Owner document is null. "+this._debugInfo());return t},enumerable:!0,configurable:!0}),e.prototype._debugInfo=function(e){var t=this.node,n=t.parentNode;e=e||t.nodeName;var r=n?n.nodeName:"";return r?"node: <"+e+">, parent: <"+r+">":"node: <"+e+">"},Object.defineProperty(e.prototype,"_options",{get:function(){var e=this._doc;if(void 0===e._xmlBuilderOptions)throw new Error("Builder options is not set.");return e._xmlBuilderOptions},set:function(e){this._doc._xmlBuilderOptions=e},enumerable:!0,configurable:!0}),e}();t.XMLBuilderImpl=f},function(e,t,n){var r=n(11),i=n(117),o=r.WeakMap;e.exports="function"==typeof o&&/native code/.test(i(o))},function(e,t,n){var r=n(46),i=n(82),o=n(85),a=n(18);e.exports=r("Reflect","ownKeys")||function(e){var t=i.f(a(e)),n=o.f;return n?t.concat(n(e)):t}},function(e,t,n){var r=n(16),i=n(15),o=n(18),a=n(61);e.exports=r?Object.defineProperties:function(e,t){o(e);for(var n,r=a(t),s=r.length,l=0;s>l;)i.f(e,n=r[l++],t[n]);return e}},function(e,t,n){var r=n(46);e.exports=r("document","documentElement")},function(e,t,n){var r=n(24),i=n(82).f,o={}.toString,a="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];e.exports.f=function(e){return a&&"[object Window]"==o.call(e)?function(e){try{return i(e)}catch(e){return a.slice()}}(e):i(r(e))}},function(e,t,n){"use strict";var r=n(4),i=n(36).every,o=n(48),a=n(28),s=o("every"),l=a("every");r({target:"Array",proto:!0,forced:!s||!l},{every:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0)}})},function(e,t,n){"use strict";var r=n(4),i=n(36).filter,o=n(63),a=n(28),s=o("filter"),l=a("filter");r({target:"Array",proto:!0,forced:!s||!l},{filter:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0)}})},function(e,t,n){var r=n(46);e.exports=r("navigator","userAgent")||""},function(e,t,n){"use strict";var r=n(4),i=n(36).find,o=n(130),a=n(28),s=!0,l=a("find");"find"in[]&&Array(1).find((function(){s=!1})),r({target:"Array",proto:!0,forced:s||!l},{find:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0)}}),o("find")},function(e,t,n){"use strict";var r=n(131).IteratorPrototype,i=n(60),o=n(40),a=n(62),s=n(49),l=function(){return this};e.exports=function(e,t,n){var c=t+" Iterator";return e.prototype=i(r,{next:o(1,n)}),a(e,c,!1,!0),s[c]=l,e}},function(e,t,n){var r=n(8);e.exports=!r((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}))},function(e,t,n){var r=n(13);e.exports=function(e){if(!r(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype");return e}},function(e,t,n){"use strict";var r=n(4),i=n(36).map,o=n(63),a=n(28),s=o("map"),l=a("map");r({target:"Array",proto:!0,forced:!s||!l},{map:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0)}})},function(e,t,n){"use strict";var r=n(4),i=n(200).left,o=n(48),a=n(28),s=o("reduce"),l=a("reduce",{1:0});r({target:"Array",proto:!0,forced:!s||!l},{reduce:function(e){return i(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}})},function(e,t,n){var r=n(127),i=n(27),o=n(41),a=n(26),s=function(e){return function(t,n,s,l){r(n);var c=i(t),u=o(c),d=a(c.length),h=e?d-1:0,p=e?-1:1;if(s<2)for(;;){if(h in u){l=u[h],h+=p;break}if(h+=p,e?h<0:d<=h)throw TypeError("Reduce of empty array with no initial value")}for(;e?h>=0:d>h;h+=p)h in u&&(l=n(l,u[h],h,c));return l}};e.exports={left:s(!1),right:s(!0)}},function(e,t,n){"use strict";var r=n(4),i=n(36).some,o=n(48),a=n(28),s=o("some"),l=a("some");r({target:"Array",proto:!0,forced:!s||!l},{some:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0)}})},function(e,t,n){"use strict";var r=n(90),i=n(135);e.exports=r?{}.toString:function(){return"[object "+i(this)+"]"}},function(e,t){e.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},function(e,t,n){var r=n(8);e.exports=!r((function(){return Object.isExtensible(Object.preventExtensions({}))}))},function(e,t,n){var r=n(5),i=n(49),o=r("iterator"),a=Array.prototype;e.exports=function(e){return void 0!==e&&(i.Array===e||a[o]===e)}},function(e,t,n){var r=n(135),i=n(49),o=n(5)("iterator");e.exports=function(e){if(null!=e)return e[o]||e["@@iterator"]||i[r(e)]}},function(e,t,n){var r=n(18);e.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var o=e.return;throw void 0!==o&&r(o.call(e)),t}}},function(e,t,n){var r=n(5)("iterator"),i=!1;try{var o=0,a={next:function(){return{done:!!o++}},return:function(){i=!0}};a[r]=function(){return this},Array.from(a,(function(){throw 2}))}catch(e){}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var o={};o[r]=function(){return{next:function(){return{done:n=!0}}}},e(o)}catch(e){}return n}},function(e,t,n){var r=n(13),i=n(133);e.exports=function(e,t,n){var o,a;return i&&"function"==typeof(o=t.constructor)&&o!==n&&r(a=o.prototype)&&a!==n.prototype&&i(e,a),e}},function(e,t,n){var r=n(25);e.exports=function(e,t,n){for(var i in t)r(e,i,t[i],n);return e}},function(e,t,n){"use strict";var r=n(46),i=n(15),o=n(5),a=n(16),s=o("species");e.exports=function(e){var t=r(e),n=i.f;a&&t&&!t[s]&&n(t,s,{configurable:!0,get:function(){return this}})}},function(e,t,n){"use strict";var r=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e){void 0===e&&(e=1e3),this._items=new Set,this._limit=e}return e.prototype.add=function(e){if(this._items.add(e),this._items.size>this._limit){var t=this._items.values().next();t.done||this._items.delete(t.value)}return this},e.prototype.delete=function(e){return this._items.delete(e)},e.prototype.has=function(e){return this._items.has(e)},e.prototype.clear=function(){this._items.clear()},Object.defineProperty(e.prototype,"size",{get:function(){return this._items.size},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e,t){var n=this;this._items.forEach((function(r){return e.call(t,r,r,n)}))},e.prototype.keys=function(){return r(this,(function(e){switch(e.label){case 0:return[5,i(this._items.keys())];case 1:return e.sent(),[2]}}))},e.prototype.values=function(){return r(this,(function(e){switch(e.label){case 0:return[5,i(this._items.values())];case 1:return e.sent(),[2]}}))},e.prototype.entries=function(){return r(this,(function(e){switch(e.label){case 0:return[5,i(this._items.entries())];case 1:return e.sent(),[2]}}))},e.prototype[Symbol.iterator]=function(){return r(this,(function(e){switch(e.label){case 0:return[5,i(this._items)];case 1:return e.sent(),[2]}}))},Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"FixedSizeSet"},enumerable:!0,configurable:!0}),e}();t.FixedSizeSet=o},function(e,t,n){"use strict";var r=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e){void 0===e&&(e=1e3),this._items=new Map,this._limit=e}return e.prototype.get=function(e){return this._items.get(e)},e.prototype.set=function(e,t){if(this._items.set(e,t),this._items.size>this._limit){var n=this._items.keys().next();n.done||this._items.delete(n.value)}},e.prototype.delete=function(e){return this._items.delete(e)},e.prototype.has=function(e){return this._items.has(e)},e.prototype.clear=function(){this._items.clear()},Object.defineProperty(e.prototype,"size",{get:function(){return this._items.size},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e,t){this._items.forEach((function(n,r){return e.call(t,r,n)}))},e.prototype.keys=function(){return r(this,(function(e){switch(e.label){case 0:return[5,i(this._items.keys())];case 1:return e.sent(),[2]}}))},e.prototype.values=function(){return r(this,(function(e){switch(e.label){case 0:return[5,i(this._items.values())];case 1:return e.sent(),[2]}}))},e.prototype.entries=function(){return r(this,(function(e){switch(e.label){case 0:return[5,i(this._items.entries())];case 1:return e.sent(),[2]}}))},e.prototype[Symbol.iterator]=function(){return r(this,(function(e){switch(e.label){case 0:return[5,i(this._items)];case 1:return e.sent(),[2]}}))},Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"ObjectCache"},enumerable:!0,configurable:!0}),e}();t.ObjectCache=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){void 0===e&&(e=1e3),this._items=new Map,this._limit=e}return e.prototype.check=function(e,t){if(this._items.get(e)===t)return!0;if(this._items.get(t)===e)return!1;var n=Math.random()<.5;if(n?this._items.set(e,t):this._items.set(t,e),this._items.size>this._limit){var r=this._items.keys().next();r.done||this._items.delete(r.value)}return n},e}();t.CompareCache=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){this._initialized=!1,this._value=void 0,this._initFunc=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._initialized||(this._value=this._initFunc(),this._initialized=!0),this._value},enumerable:!0,configurable:!0}),e}();t.Lazy=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){this._pointer=0,this._chars=Array.from(e),this._length=this._chars.length}return Object.defineProperty(e.prototype,"eof",{get:function(){return this._pointer>=this._length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._length},enumerable:!0,configurable:!0}),e.prototype.codePoint=function(){if(void 0===this._codePoint)if(this.eof)this._codePoint=-1;else{var e=this._chars[this._pointer].codePointAt(0);this._codePoint=void 0!==e?e:-1}return this._codePoint},e.prototype.c=function(){return void 0===this._c&&(this._c=this.eof?"":this._chars[this._pointer]),this._c},e.prototype.remaining=function(){return void 0===this._remaining&&(this._remaining=this.eof?"":this._chars.slice(this._pointer+1).join("")),this._remaining},e.prototype.substring=function(){return void 0===this._substring&&(this._substring=this.eof?"":this._chars.slice(this._pointer).join("")),this._substring},Object.defineProperty(e.prototype,"pointer",{get:function(){return this._pointer},set:function(e){e!==this._pointer&&(this._pointer=e,this._codePoint=void 0,this._c=void 0,this._remaining=void 0,this._substring=void 0)},enumerable:!0,configurable:!0}),e}();t.StringWalker=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(218);t.MapWriter=r.MapWriter;var i=n(258);t.XMLWriter=i.XMLWriter;var o=n(67);t.ObjectWriter=o.ObjectWriter;var a=n(260);t.JSONWriter=a.JSONWriter;var s=n(261);t.YAMLWriter=s.YAMLWriter},function(e,t,n){"use strict";n(19),n(219),n(20),n(22),n(23);var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),a=n(67),s=function(e){function t(t,n){var r=e.call(this,t)||this;return r._writerOptions=o.applyDefaults(n,{format:"map",wellFormed:!1,group:!1,verbose:!1}),r}return i(t,e),t.prototype.serialize=function(e){var t=o.applyDefaults(this._writerOptions,{format:"object",wellFormed:!1,verbose:!1}),n=new a.ObjectWriter(this._builderOptions,t).serialize(e);return this._convertObject(n)},t.prototype._convertObject=function(e){if(o.isArray(e)){for(var t=0;t=51||!i((function(){var e=[];return e[f]=!1,e.concat()[0]!==e})),g=d("concat"),v=function(e){if(!a(e))return!1;var t=e[f];return void 0!==t?!!t:o(e)};r({target:"Array",proto:!0,forced:!m||!g},{concat:function(e){var t,n,r,i,o,a=s(this),d=u(a,0),h=0;for(t=-1,r=arguments.length;t9007199254740991)throw TypeError("Maximum allowed index exceeded");for(n=0;n=9007199254740991)throw TypeError("Maximum allowed index exceeded");c(d,h++,o)}return d.length=h,d}})},function(e,t,n){"use strict";var r=n(8);function i(e,t){return RegExp(e,t)}t.UNSUPPORTED_Y=r((function(){var e=i("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),t.BROKEN_CARET=r((function(){var e=i("^r","gy");return e.lastIndex=2,null!=e.exec("str")}))},function(e,t,n){var r=n(223);e.exports=function(e){if(r(e))throw TypeError("The method doesn't accept regular expressions");return e}},function(e,t,n){var r=n(13),i=n(42),o=n(5)("match");e.exports=function(e){var t;return r(e)&&(void 0!==(t=e[o])?!!t:"RegExp"==i(e))}},function(e,t,n){var r=n(5)("match");e.exports=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[r]=!1,"/./"[e](t)}catch(e){}}return!1}},function(e,t,n){"use strict";n(68);var r=n(25),i=n(8),o=n(5),a=n(93),s=n(21),l=o("species"),c=!i((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$")})),u="$0"==="a".replace(/./,"$0"),d=o("replace"),h=!!/./[d]&&""===/./[d]("a","$0"),p=!i((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return 2!==n.length||"a"!==n[0]||"b"!==n[1]}));e.exports=function(e,t,n,d){var f=o(e),m=!i((function(){var t={};return t[f]=function(){return 7},7!=""[e](t)})),g=m&&!i((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[l]=function(){return n},n.flags="",n[f]=/./[f]),n.exec=function(){return t=!0,null},n[f](""),!t}));if(!m||!g||"replace"===e&&(!c||!u||h)||"split"===e&&!p){var v=/./[f],y=n(f,""[e],(function(e,t,n,r,i){return t.exec===a?m&&!i?{done:!0,value:v.call(t,n,r)}:{done:!0,value:e.call(n,t,r)}:{done:!1}}),{REPLACE_KEEPS_$0:u,REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE:h}),_=y[0],b=y[1];r(String.prototype,e,_),r(RegExp.prototype,f,2==t?function(e,t){return b.call(e,this,t)}:function(e){return b.call(e,this)})}d&&s(RegExp.prototype[f],"sham",!0)}},function(e,t,n){"use strict";var r=n(137).charAt;e.exports=function(e,t,n){return t+(n?r(e,t).length:1)}},function(e,t,n){var r=n(42),i=n(93);e.exports=function(e,t){var n=e.exec;if("function"==typeof n){var o=n.call(e,t);if("object"!=typeof o)throw TypeError("RegExp exec method returned something other than an Object or null");return o}if("RegExp"!==r(e))throw TypeError("RegExp#exec called on incompatible receiver");return i.call(e,t)}},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});var r=n(96);t.forgivingBase64Encode=function(t){return e.from(t).toString("base64")},t.forgivingBase64Decode=function(t){return""===t?"":((t=t.replace(r.ASCIIWhiteSpace,"")).length%4==0&&(t.endsWith("==")?t=t.substr(0,t.length-2):t.endsWith("=")&&(t=t.substr(0,t.length-1))),t.length%4==1?null:/[0-9A-Za-z+/]/.test(t)?e.from(t,"base64").toString("utf8"):null)}}).call(this,n(145).Buffer)},function(e,t,n){"use strict";t.byteLength=function(e){var t=c(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=c(e),a=r[0],s=r[1],l=new o(function(e,t,n){return 3*(t+n)/4-n}(0,a,s)),u=0,d=s>0?a-4:a;for(n=0;n>16&255,l[u++]=t>>8&255,l[u++]=255&t;return 2===s&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,l[u++]=255&t),1===s&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t),l},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],a=0,s=n-i;as?s:a+16383));return 1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e,t,n){for(var i,o,a=[],s=t;s>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,n,r,i){var o,a,s=8*i-r-1,l=(1<>1,u=-7,d=n?i-1:0,h=n?-1:1,p=e[t+d];for(d+=h,o=p&(1<<-u)-1,p>>=-u,u+=s;u>0;o=256*o+e[t+d],d+=h,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=r;u>0;a=256*a+e[t+d],d+=h,u-=8);if(0===o)o=1-c;else{if(o===l)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,r),o-=c}return(p?-1:1)*a*Math.pow(2,o-r)},t.write=function(e,t,n,r,i,o){var a,s,l,c=8*o-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+d>=1?h/l:h*Math.pow(2,1-d))*l>=2&&(a++,l/=2),a+d>=u?(s=0,a=u):a+d>=1?(s=(t*l-1)*Math.pow(2,i),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),a=0));i>=8;e[n+p]=255&s,p+=f,s/=256,i-=8);for(a=a<0;e[n+p]=255&a,p+=f,a/=256,c-=8);e[n+p-f]|=128*m}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){"use strict";var r=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(1);function o(e){var t,n;if(null===e||i.isString(e)||i.isNumber(e))return e;if(i.isArray(e)){var a=new Array;try{for(var s=r(e),l=s.next();!l.done;l=s.next()){var c=l.value;a.push(o(c))}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return a}if(i.isObject(e)){for(var u in a=new Map,e)if(e.hasOwnProperty(u)){var d=e[u];a.set(u,o(d))}return a}return e}t.parseJSONFromBytes=function(e){var t=i.utf8Decode(e);return JSON.parse.call(void 0,t)},t.serializeJSONToBytes=function(e){var t=JSON.stringify.call(void 0,e);return i.utf8Encode(t)},t.parseJSONIntoInfraValues=function(e){return o(JSON.parse.call(void 0,e))},t.convertAJSONDerivedJavaScriptValueToAnInfraValue=o},function(e,t,n){"use strict";var r=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]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},o=this&&this.__spread||function(){for(var e=[],t=0;t=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0});var s=n(1);t.append=function(e,t){e.push(t)},t.extend=function(e,t){e.push.apply(e,o(t))},t.prepend=function(e,t){e.unshift(t)},t.replace=function(e,t,n){var r,i,o=0;try{for(var l=a(e),c=l.next();!c.done;c=l.next()){var u=c.value;if(s.isFunction(t))t.call(null,u)&&(e[o]=n);else if(u===t)return void(e[o]=n);o++}}catch(e){r={error:e}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}},t.insert=function(e,t,n){e.splice(n,0,t)},t.remove=function(e,t){for(var n=e.length;n--;){var r=e[n];if(s.isFunction(t))t.call(null,r)&&e.splice(n,1);else if(r===t)return void e.splice(n,1)}},t.empty=function(e){e.length=0},t.contains=function(e,t){var n,r;try{for(var i=a(e),o=i.next();!o.done;o=i.next()){var l=o.value;if(s.isFunction(t)){if(t.call(null,l))return!0}else if(l===t)return!0}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return!1},t.size=function(e,t){var n,r;if(void 0===t)return e.length;var i=0;try{for(var o=a(e),s=o.next();!s.done;s=o.next()){var l=s.value;t.call(null,l)&&i++}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},t.isEmpty=function(e){return 0===e.length},t.forEach=function(e,t){var n,i,o,s,l,c;return r(this,(function(r){switch(r.label){case 0:return void 0!==t?[3,2]:[5,a(e)];case 1:return r.sent(),[3,9];case 2:r.trys.push([2,7,8,9]),n=a(e),i=n.next(),r.label=3;case 3:return i.done?[3,6]:(o=i.value,t.call(null,o)?[4,o]:[3,5]);case 4:r.sent(),r.label=5;case 5:return i=n.next(),[3,3];case 6:return[3,9];case 7:return s=r.sent(),l={error:s},[3,9];case 8:try{i&&!i.done&&(c=n.return)&&c.call(n)}finally{if(l)throw l.error}return[7];case 9:return[2]}}))},t.clone=function(e){return new(Array.bind.apply(Array,o([void 0],e)))},t.sortInAscendingOrder=function(e,t){return e.sort((function(e,n){return t.call(null,e,n)?-1:1}))},t.sortInDescendingOrder=function(e,t){return e.sort((function(e,n){return t.call(null,e,n)?1:-1}))}},function(e,t,n){"use strict";var r=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},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},a=this&&this.__spread||function(){for(var e=[],t=0;t0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},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},a=this&&this.__spread||function(){for(var e=[],t=0;t=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(96),o=n(147),a=n(146),s=n(1);function l(e,t){for(var n=0;;){var r=n=65&&l<=90?String.fromCodePoint(l+32):s}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return i}function h(e){return e.replace(/^[\t\n\f\r ]+/,"").replace(/[\t\n\f\r ]+$/,"")}function p(e,t,n){if(!s.isArray(t))return p(e,Array.from(t),n);for(var r="";n.position=97&&l<=122?String.fromCodePoint(l-32):s}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return i},t.asciiCaseInsensitiveMatch=function(e,t){return d(e)===d(t)},t.asciiEncode=function(e){return console.assert(u(e),"asciiEncode requires an ASCII string."),c(e)},t.asciiDecode=function(e){var t,n;try{for(var i=r(e),s=i.next();!s.done;s=i.next()){var l=s.value;console.assert(a.isASCIIByte(l),"asciiDecode requires an ASCII byte sequence.")}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return o.isomorphicDecode(e)},t.stripNewlines=function(e){return e.replace(/[\n\r]/g,"")},t.normalizeNewlines=function(e){return e.replace(/\r\n/g,"\n").replace(/\r/g,"\n")},t.stripLeadingAndTrailingASCIIWhitespace=h,t.stripAndCollapseASCIIWhitespace=function(e){return h(e.replace(/[\t\n\f\r ]{2,}/g," "))},t.collectASequenceOfCodePoints=p,t.skipASCIIWhitespace=f,t.strictlySplit=function e(t,n){if(!s.isArray(t))return e(Array.from(t),n);var r={position:0},i=[],o=p((function(e){return n!==e}),t,r);for(i.push(o);r.position=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(97);t.abort_add=function(e,t){t._abortedFlag||t._abortAlgorithms.add(e)},t.abort_remove=function(e,t){t._abortAlgorithms.delete(e)},t.abort_signalAbort=function(e){var t,n;if(!e._abortedFlag){e._abortedFlag=!0;try{for(var o=r(e._abortAlgorithms),a=o.next();!a.done;a=o.next())a.value.call(e)}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}e._abortAlgorithms.clear(),i.event_fireAnEvent("abort",e)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(150),i=function(){function e(){}return e.asNode=function(e){if(r.Guard.isNode(e))return e;throw new Error("Invalid object. Node expected.")},e}();t.Cast=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){}return Object.defineProperty(e.prototype,"size",{get:function(){return 0},enumerable:!0,configurable:!0}),e.prototype.add=function(e){throw new Error("Cannot add to an empty set.")},e.prototype.clear=function(){},e.prototype.delete=function(e){return!1},e.prototype.forEach=function(e,t){},e.prototype.has=function(e){return!1},e.prototype[Symbol.iterator]=function(){return new i},e.prototype.entries=function(){return new i},e.prototype.keys=function(){return new i},e.prototype.values=function(){return new i},Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"EmptySet"},enumerable:!0,configurable:!0}),e}();t.EmptySet=r;var i=function(){function e(){}return e.prototype[Symbol.iterator]=function(){return this},e.prototype.next=function(){return{done:!0,value:null}},e}()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.SchemeStart=0]="SchemeStart",e[e.Scheme=1]="Scheme",e[e.NoScheme=2]="NoScheme",e[e.SpecialRelativeOrAuthority=3]="SpecialRelativeOrAuthority",e[e.PathOrAuthority=4]="PathOrAuthority",e[e.Relative=5]="Relative",e[e.RelativeSlash=6]="RelativeSlash",e[e.SpecialAuthoritySlashes=7]="SpecialAuthoritySlashes",e[e.SpecialAuthorityIgnoreSlashes=8]="SpecialAuthorityIgnoreSlashes",e[e.Authority=9]="Authority",e[e.Host=10]="Host",e[e.Hostname=11]="Hostname",e[e.Port=12]="Port",e[e.File=13]="File",e[e.FileSlash=14]="FileSlash",e[e.FileHost=15]="FileHost",e[e.PathStart=16]="PathStart",e[e.Path=17]="Path",e[e.CannotBeABaseURLPath=18]="CannotBeABaseURLPath",e[e.Query=19]="Query",e[e.Fragment=20]="Fragment"}(t.ParserState||(t.ParserState={})),t.OpaqueOrigin=["","",null,null]},function(e,t,n){"use strict";var r=n(245),i=n(247);function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}t.parse=_,t.resolve=function(e,t){return _(e,!1,!0).resolve(t)},t.resolveObject=function(e,t){return e?_(e,!1,!0).resolveObject(t):t},t.format=function(e){return i.isString(e)&&(e=_(e)),e instanceof o?e.format():o.prototype.format.call(e)},t.Url=o;var a=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,l=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(c),d=["%","/","?",";","#"].concat(u),h=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,f=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=n(248);function _(e,t,n){if(e&&i.isObject(e)&&e instanceof o)return e;var r=new o;return r.parse(e,t,n),r}o.prototype.parse=function(e,t,n){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o127?k+="x":k+=P[M];if(!k.match(p)){var R=N.slice(0,T),F=N.slice(T+1),U=P.match(f);U&&(R.push(U[1]),F.unshift(U[2])),F.length&&(_="/"+F.join(".")+_),this.hostname=R.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),A||(this.hostname=r.toASCII(this.hostname));var B=this.port?":"+this.port:"",j=this.hostname||"";this.host=j+B,this.href+=this.host,A&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!m[w])for(T=0,O=u.length;T0)&&n.host.split("@"))&&(n.auth=A.shift(),n.host=n.hostname=A.shift())),n.search=e.search,n.query=e.query,i.isNull(n.pathname)&&i.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!x.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var D=x.slice(-1)[0],S=(n.host||e.host||x.length>1)&&("."===D||".."===D)||""===D,T=0,I=x.length;I>=0;I--)"."===(D=x[I])?x.splice(I,1):".."===D?(x.splice(I,1),T++):T&&(x.splice(I,1),T--);if(!E&&!w)for(;T--;T)x.unshift("..");!E||""===x[0]||x[0]&&"/"===x[0].charAt(0)||x.unshift(""),S&&"/"!==x.join("/").substr(-1)&&x.push("");var A,N=""===x[0]||x[0]&&"/"===x[0].charAt(0);return C&&(n.hostname=n.host=N?"":x.length?x.shift():"",(A=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=A.shift(),n.host=n.hostname=A.shift())),(E=E||n.host&&x.length)&&!N&&x.unshift(""),x.length?n.pathname=x.join("/"):(n.pathname=null,n.path=null),i.isNull(n.pathname)&&i.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t,n){(function(e,r){var i;!function(o){t&&t.nodeType,e&&e.nodeType;var a="object"==typeof r&&r;a.global!==a&&a.window!==a&&a.self;var s,l=2147483647,c=/^xn--/,u=/[^\x20-\x7E]/,d=/[\x2E\u3002\uFF0E\uFF61]/g,h={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},p=Math.floor,f=String.fromCharCode;function m(e){throw new RangeError(h[e])}function g(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function v(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+g((e=e.replace(d,".")).split("."),t).join(".")}function y(e){for(var t,n,r=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=f((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+f(e)})).join("")}function b(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function E(e,t,n){var r=0;for(e=n?p(e/700):e>>1,e+=p(e/t);e>455;r+=36)e=p(e/35);return p(r+36*e/(e+38))}function w(e){var t,n,r,i,o,a,s,c,u,d,h,f=[],g=e.length,v=0,y=128,b=72;for((n=e.lastIndexOf("-"))<0&&(n=0),r=0;r=128&&m("not-basic"),f.push(e.charCodeAt(r));for(i=n>0?n+1:0;i=g&&m("invalid-input"),((c=(h=e.charCodeAt(i++))-48<10?h-22:h-65<26?h-65:h-97<26?h-97:36)>=36||c>p((l-v)/a))&&m("overflow"),v+=c*a,!(c<(u=s<=b?1:s>=b+26?26:s-b));s+=36)a>p(l/(d=36-u))&&m("overflow"),a*=d;b=E(v-o,t=f.length+1,0==o),p(v/t)>l-y&&m("overflow"),y+=p(v/t),v%=t,f.splice(v++,0,y)}return _(f)}function x(e){var t,n,r,i,o,a,s,c,u,d,h,g,v,_,w,x=[];for(g=(e=y(e)).length,t=128,n=0,o=72,a=0;a=t&&hp((l-n)/(v=r+1))&&m("overflow"),n+=(s-t)*v,t=s,a=0;al&&m("overflow"),h==t){for(c=n,u=36;!(c<(d=u<=o?1:u>=o+26?26:u-o));u+=36)w=c-d,_=36-d,x.push(f(b(d+w%_,0))),c=p(w/_);x.push(f(b(c,0))),o=E(n,v,r==i),n=0,++r}++n,++t}return x.join("")}s={version:"1.4.1",ucs2:{decode:y,encode:_},decode:w,encode:x,toASCII:function(e){return v(e,(function(e){return u.test(e)?"xn--"+x(e):e}))},toUnicode:function(e){return v(e,(function(e){return c.test(e)?w(e.slice(4).toLowerCase()):e}))}},void 0===(i=function(){return s}.call(t,n,t,e))||(e.exports=i)}()}).call(this,n(246)(e),n(78))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";e.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},function(e,t,n){"use strict";t.decode=t.parse=n(249),t.encode=t.stringify=n(250)},function(e,t,n){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,n,o){t=t||"&",n=n||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var l=1e3;o&&"number"==typeof o.maxKeys&&(l=o.maxKeys);var c=e.length;l>0&&c>l&&(c=l);for(var u=0;u=0?(d=m.substr(0,g),h=m.substr(g+1)):(d=m,h=""),p=decodeURIComponent(d),f=decodeURIComponent(h),r(a,p)?i(a[p])?a[p].push(f):a[p]=[a[p],f]:a[p]=f}return a};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,n,s){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),(function(a){var s=encodeURIComponent(r(a))+n;return i(e[a])?o(e[a],(function(e){return s+encodeURIComponent(r(e))})).join(t):s+encodeURIComponent(r(e[a]))})).join(t):s?encodeURIComponent(r(s))+n+encodeURIComponent(r(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var n=[],r=0;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.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(1);function o(e){return i.isBoolean(e)?e:e.capture||!1}t.eventTarget_flatten=o,t.eventTarget_flattenMore=function(e){var t=o(e),n=!1,r=!1;return i.isBoolean(e)||(n=e.once||!1,r=e.passive||!1),[t,r,n]},t.eventTarget_addEventListener=function(e,t){if(null!==t.callback){for(var n=0;n=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(1),o=n(29);t.parentNode_convertNodesIntoANode=function(e,t){for(var n,a,s=null,l=0;l=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},i=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},o=this&&this.__spread||function(){for(var e=[],t=0;t0;O--){var P;if(_(P=N[O],e)){A=P;break}}var k,M,L=[];try{for(var R=r(D._children),F=R.next();!F.done;F=R.next())if(y(z=F.value,e)){if(l.Guard.isDocumentTypeNode(z))throw new s.HierarchyRequestError;L.push(z)}}catch(e){i={error:e}}finally{try{F&&!F.done&&(a=R.return)&&a.call(R)}finally{if(i)throw i.error}}if(u.tree_isAncestorOf(x,E,!0))k=E,M=w;else{for(var U=E;null!==U._parent&&!u.tree_isAncestorOf(x,U._parent);)U=U._parent;if(null===U._parent)throw new Error("Parent node is null.");k=U._parent,M=1+u.tree_index(U)}if(l.Guard.isCharacterDataNode(S))(B=p.node_clone(E))._data=h.characterData_substringData(E,w,u.tree_nodeLength(E)-w),f.mutation_append(B,v),h.characterData_replaceData(E,w,u.tree_nodeLength(E)-w,"");else if(null!==S){var B=p.node_clone(S);f.mutation_append(B,v);var j=b(c.create_range([E,w],[S,u.tree_nodeLength(S)]));f.mutation_append(j,B)}try{for(var V=r(L),W=V.next();!W.done;W=V.next()){var z=W.value;f.mutation_append(z,v)}}catch(e){d={error:e}}finally{try{W&&!W.done&&(m=V.return)&&m.call(V)}finally{if(d)throw d.error}}return l.Guard.isCharacterDataNode(A)?((B=p.node_clone(x))._data=h.characterData_substringData(x,0,C),f.mutation_append(B,v),h.characterData_replaceData(x,0,C,"")):null!==A&&(B=p.node_clone(A),f.mutation_append(B,v),j=b(c.create_range([A,0],[x,C])),f.mutation_append(j,B)),e._start=[k,M],e._end=[k,M],v}t.range_collapsed=g,t.range_root=v,t.range_isContained=y,t.range_isPartiallyContained=_,t.range_setTheStart=function(e,t,n){if(l.Guard.isDocumentTypeNode(t))throw new s.InvalidNodeTypeError;if(n>u.tree_nodeLength(t))throw new s.IndexSizeError;var r=[t,n];v(e)===u.tree_rootNode(t)&&d.boundaryPoint_position(r,e._end)!==a.BoundaryPosition.After||(e._end=r),e._start=r},t.range_setTheEnd=function(e,t,n){if(l.Guard.isDocumentTypeNode(t))throw new s.InvalidNodeTypeError;if(n>u.tree_nodeLength(t))throw new s.IndexSizeError;var r=[t,n];v(e)===u.tree_rootNode(t)&&d.boundaryPoint_position(r,e._start)!==a.BoundaryPosition.Before||(e._start=r),e._end=r},t.range_select=function(e,t){var n=e._parent;if(null===n)throw new s.InvalidNodeTypeError;var r=u.tree_index(e);t._start=[n,r],t._end=[n,r+1]},t.range_extract=b,t.range_cloneTheContents=function e(t){var n,i,a,d,m,v,E=c.create_documentFragment(t._startNode._nodeDocument);if(g(t))return E;var w=t._startNode,x=t._startOffset,C=t._endNode,D=t._endOffset;w===C&&l.Guard.isCharacterDataNode(w)&&((F=p.node_clone(w))._data=h.characterData_substringData(w,x,D-x),f.mutation_append(F,E));for(var S=w;!u.tree_isAncestorOf(C,S,!0);){if(null===S._parent)throw new Error("Parent node is null.");S=S._parent}var T=null;if(!u.tree_isAncestorOf(C,w,!0))try{for(var I=r(S._children),A=I.next();!A.done;A=I.next())if(_(k=A.value,t)){T=k;break}}catch(e){n={error:e}}finally{try{A&&!A.done&&(i=I.return)&&i.call(I)}finally{if(n)throw n.error}}var N=null;if(!u.tree_isAncestorOf(w,C,!0))for(var O=o(S._children),P=O.length-1;P>0;P--){var k;if(_(k=O[P],t)){N=k;break}}var M=[];try{for(var L=r(S._children),R=L.next();!R.done;R=L.next())if(y(V=R.value,t)){if(l.Guard.isDocumentTypeNode(V))throw new s.HierarchyRequestError;M.push(V)}}catch(e){a={error:e}}finally{try{R&&!R.done&&(d=L.return)&&d.call(L)}finally{if(a)throw a.error}}if(l.Guard.isCharacterDataNode(T))(F=p.node_clone(w))._data=h.characterData_substringData(w,x,u.tree_nodeLength(w)-x),f.mutation_append(F,E);else if(null!==T){var F=p.node_clone(T);f.mutation_append(F,E);var U=e(c.create_range([w,x],[T,u.tree_nodeLength(T)]));f.mutation_append(U,F)}try{for(var B=r(M),j=B.next();!j.done;j=B.next()){var V=j.value;F=p.node_clone(V),f.mutation_append(F,E)}}catch(e){m={error:e}}finally{try{j&&!j.done&&(v=B.return)&&v.call(B)}finally{if(m)throw m.error}}return l.Guard.isCharacterDataNode(N)?((F=p.node_clone(C))._data=h.characterData_substringData(C,0,D),f.mutation_append(F,E)):null!==N&&(F=p.node_clone(N),E.append(F),U=b(c.create_range([N,0],[C,D])),f.mutation_append(U,F)),E},t.range_insert=function(e,t){var n,i;if(l.Guard.isProcessingInstructionNode(t._startNode)||l.Guard.isCommentNode(t._startNode)||l.Guard.isTextNode(t._startNode)&&null===t._startNode._parent||t._startNode===e)throw new s.HierarchyRequestError;var o,a=null;if(l.Guard.isTextNode(t._startNode))a=t._startNode;else{var c=0;try{for(var d=r(t._startNode._children),h=d.next();!h.done;h=d.next()){var p=h.value;if(c===t._startOffset){a=p;break}c++}}catch(e){n={error:e}}finally{try{h&&!h.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}}if(null===a)o=t._startNode;else{if(null===a._parent)throw new Error("Parent node is null.");o=a._parent}f.mutation_ensurePreInsertionValidity(e,o,a),l.Guard.isTextNode(t._startNode)&&(a=m.text_split(t._startNode,t._startOffset)),e===a&&(a=e._nextSibling),null!==e._parent&&f.mutation_remove(e,e._parent);var v=null===a?u.tree_nodeLength(o):u.tree_index(a);l.Guard.isDocumentFragmentNode(e)?v+=u.tree_nodeLength(e):v++,f.mutation_preInsert(e,o,a),g(t)&&(t._end=[o,v])},t.range_getContainedNodes=function(e){var t;return(t={})[Symbol.iterator]=function(){var t=e.commonAncestorContainer,n=u.tree_getFirstDescendantNode(t);return{next:function(){for(;n&&!y(n,e);)n=u.tree_getNextDescendantNode(t,n);if(null===n)return{done:!0,value:null};var r={done:!1,value:n};return n=u.tree_getNextDescendantNode(t,n),r}}},t},t.range_getPartiallyContainedNodes=function(e){var t;return(t={})[Symbol.iterator]=function(){var t=e.commonAncestorContainer,n=u.tree_getFirstDescendantNode(t);return{next:function(){for(;n&&!_(n,e);)n=u.tree_getNextDescendantNode(t,n);if(null===n)return{done:!0,value:null};var r={done:!1,value:n};return n=u.tree_getNextDescendantNode(t,n),r}}},t}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9);t.selectors_scopeMatchASelectorsString=function(e,t){throw new r.NotSupportedError}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),i=n(105);t.treeWalker_traverseChildren=function(e,t){for(var n=t?e._current._firstChild:e._current._lastChild;null!==n;){var o=i.traversal_filter(e,n);if(o===r.FilterResult.Accept)return e._current=n,n;if(o===r.FilterResult.Skip){var a=t?n._firstChild:n._lastChild;if(null!==a){n=a;continue}}for(;null!==n;){var s=t?n._nextSibling:n._previousSibling;if(null!==s){n=s;break}var l=n._parent;if(null===l||l===e._root||l===e._current)return null;n=l}}return null},t.treeWalker_traverseSiblings=function(e,t){var n=e._current;if(n===e._root)return null;for(;;){for(var o=t?n._nextSibling:n._previousSibling;null!==o;){n=o;var a=i.traversal_filter(e,n);if(a===r.FilterResult.Accept)return e._current=n,n;o=t?n._firstChild:n._lastChild,a!==r.FilterResult.Reject&&null!==o||(o=t?n._nextSibling:n._previousSibling)}if(null===(n=n._parent)||n===e._root)return null;if(i.traversal_filter(e,n)===r.FilterResult.Accept)return null}}},function(e,t,n){"use strict";n(89),n(74);var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),a=n(2),s=n(50),l=n(3),c=function(e){function t(t,n){var r=e.call(this,t)||this;return r._indentation={},r._lengthToLastNewline=0,r._writerOptions=o.applyDefaults(n,{wellFormed:!1,headless:!1,prettyPrint:!1,indent:" ",newline:"\n",offset:0,width:0,allowEmptyTags:!1,indentTextOnlyNodes:!1,spaceBeforeSlash:!1}),r}return i(t,e),t.prototype.serialize=function(e){return this._refs={suppressPretty:!1,emptyNode:!1,markup:""},e.nodeType!==a.NodeType.Document||this._writerOptions.headless||this.declaration(this._builderOptions.version,this._builderOptions.encoding,this._builderOptions.standalone),this.serializeNode(e,this._writerOptions.wellFormed),this._writerOptions.prettyPrint&&this._refs.markup.slice(-this._writerOptions.newline.length)===this._writerOptions.newline&&(this._refs.markup=this._refs.markup.slice(0,-this._writerOptions.newline.length)),this._refs.markup},t.prototype.declaration=function(e,t,n){this._beginLine(),this._refs.markup+='",this._endLine()},t.prototype.docType=function(e,t,n){this._beginLine(),this._refs.markup+=t&&n?"':t?"':n?"':"",this._endLine()},t.prototype.openTagBegin=function(e){this._beginLine(),this._refs.markup+="<"+e},t.prototype.openTagEnd=function(e,t,n){if(this._refs.suppressPretty=!1,this._refs.emptyNode=!1,this._writerOptions.prettyPrint&&!t&&!n){for(var r=!0,i=!0,o=this.currentNode.firstChild,a=0,s=0;o;){if(l.Guard.isExclusiveTextNode(o))s++;else{if(!l.Guard.isCDATASectionNode(o)){r=!1,i=!1;break}a++}""!==o.data&&(i=!1),o=o.nextSibling}this._refs.suppressPretty=!this._writerOptions.indentTextOnlyNodes&&r&&(a<=1&&0===s||0===a),this._refs.emptyNode=i}(n||t||this._refs.emptyNode)&&this._writerOptions.allowEmptyTags?this._refs.markup+=">":this._refs.markup+=n?" />":t||this._refs.emptyNode?this._writerOptions.spaceBeforeSlash?" />":"/>":">",this._endLine()},t.prototype.closeTag=function(e){this._refs.emptyNode||(this._beginLine(),this._refs.markup+=""),this._refs.suppressPretty=!1,this._refs.emptyNode=!1,this._endLine()},t.prototype.attribute=function(e,t){var n=e+'="'+t+'"';this._writerOptions.prettyPrint&&this._writerOptions.width>0&&this._refs.markup.length-this._lengthToLastNewline+1+n.length>this._writerOptions.width?(this._endLine(),this._beginLine(),this._refs.markup+=this._indent(1)+n):this._refs.markup+=" "+n},t.prototype.text=function(e){""!==e&&(this._beginLine(),this._refs.markup+=e,this._endLine())},t.prototype.cdata=function(e){""!==e&&(this._beginLine(),this._refs.markup+="",this._endLine())},t.prototype.comment=function(e){this._beginLine(),this._refs.markup+="\x3c!--"+e+"--\x3e",this._endLine()},t.prototype.instruction=function(e,t){this._beginLine(),this._refs.markup+="",this._endLine()},t.prototype._beginLine=function(){this._writerOptions.prettyPrint&&!this._refs.suppressPretty&&(this._refs.markup+=this._indent(this._writerOptions.offset+this.level))},t.prototype._endLine=function(){this._writerOptions.prettyPrint&&!this._refs.suppressPretty&&(this._refs.markup+=this._writerOptions.newline,this._lengthToLastNewline=this._refs.markup.length)},t.prototype._indent=function(e){if(e<=0)return"";if(void 0!==this._indentation[e])return this._indentation[e];var t=this._writerOptions.indent.repeat(e);return this._indentation[e]=t,t},t}(s.BaseWriter);t.XMLWriter=c},function(e,t,n){"use strict";var r=n(47),i=n(35);e.exports="".repeat||function(e){var t=String(i(this)),n="",o=r(e);if(o<0||o==1/0)throw RangeError("Wrong number of repetitions");for(;o>0;(o>>>=1)&&(t+=t))1&o&&(n+=t);return n}},function(e,t,n){"use strict";n(31),n(32),n(33),n(19),n(178),n(20),n(22),n(23);var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var a=n(67),s=n(1),l=function(e){function t(t,n){var r=e.call(this,t)||this;return r._writerOptions=s.applyDefaults(n,{wellFormed:!1,prettyPrint:!1,indent:" ",newline:"\n",offset:0,group:!1,verbose:!1}),r}return i(t,e),t.prototype.serialize=function(e){var t=s.applyDefaults(this._writerOptions,{format:"object",wellFormed:!1}),n=new a.ObjectWriter(this._builderOptions,t).serialize(e);return this._beginLine(this._writerOptions,0)+this._convertObject(n,this._writerOptions)},t.prototype._convertObject=function(e,t,n){var r,i,a=this;void 0===n&&(n=0);var l="",c=this._isLeafNode(e);if(s.isArray(e)){l+="[";var u=e.length,d=0;try{for(var h=o(e),p=h.next();!p.done;p=h.next()){var f=p.value;l+=this._endLine(t,n+1)+this._beginLine(t,n+1)+this._convertObject(f,t,n+1),d0?new Array(n).join(e.indent):""},t.prototype._endLine=function(e,t){return e.prettyPrint?e.newline:""},t.prototype._key=function(e){return'"'+e+'":'},t.prototype._val=function(e){return JSON.stringify(e)},t.prototype._isLeafNode=function(e){return this._descendantCount(e)<=1},t.prototype._descendantCount=function(e,t){var n=this;return void 0===t&&(t=0),s.isArray(e)?s.forEachArray(e,(function(e){return t+=n._descendantCount(e,t)}),this):s.isObject(e)?s.forEachObject(e,(function(e,r){return t+=n._descendantCount(r,t)}),this):t++,t},t}(n(50).BaseWriter);t.JSONWriter=l},function(e,t,n){"use strict";n(31),n(32),n(33),n(19),n(178),n(89),n(20),n(22),n(23);var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var a=n(67),s=n(1),l=function(e){function t(t,n){var r=e.call(this,t)||this;if(r._writerOptions=s.applyDefaults(n,{wellFormed:!1,indent:" ",newline:"\n",offset:0,group:!1,verbose:!1}),r._writerOptions.indent.length<2)throw new Error("YAML indententation string must be at least two characters long.");if(r._writerOptions.offset<0)throw new Error("YAML offset should be zero or a positive number.");return r}return i(t,e),t.prototype.serialize=function(e){var t=s.applyDefaults(this._writerOptions,{format:"object",wellFormed:!1}),n=new a.ObjectWriter(this._builderOptions,t).serialize(e),r=this._beginLine(this._writerOptions,0)+"---"+this._endLine(this._writerOptions)+this._convertObject(n,this._writerOptions,0);return r.slice(-this._writerOptions.newline.length)===this._writerOptions.newline&&(r=r.slice(0,-this._writerOptions.newline.length)),r},t.prototype._convertObject=function(e,t,n,r){var i,a,l=this;void 0===r&&(r=!1);var c="";if(s.isArray(e))try{for(var u=o(e),d=u.next();!d.done;d=u.next()){var h=d.value;c+=this._beginLine(t,n,!0),s.isObject(h)?s.isEmpty(h)?c+='""'+this._endLine(t):c+=this._convertObject(h,t,n,!0):c+=this._val(h)+this._endLine(t)}}catch(e){i={error:e}}finally{try{d&&!d.done&&(a=u.return)&&a.call(u)}finally{if(i)throw i.error}}else s.forEachObject(e,(function(e,i){r?(c+=l._key(e),r=!1):c+=l._beginLine(t,n)+l._key(e),s.isObject(i)?s.isEmpty(i)?c+=' ""'+l._endLine(t):c+=l._endLine(t)+l._convertObject(i,t,n+1):c+=" "+l._val(i)+l._endLine(t)}),this);return c},t.prototype._beginLine=function(e,t,n){void 0===n&&(n=!1);var r=e.offset+t+1,i=new Array(r).join(e.indent);return n?i.substr(0,i.length-2)+"-"+i.substr(-1,1):i},t.prototype._endLine=function(e){return e.newline},t.prototype._key=function(e){return'"'+e+'":'},t.prototype._val=function(e){return JSON.stringify(e)},t}(n(50).BaseWriter);t.YAMLWriter=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),n(110).dom.setFeatures(!0);var r=n(110);t.DOMImplementation=r.DOMImplementation;var i=n(271);t.DOMParser=i.DOMParser;var o=n(274);t.XMLSerializer=o.XMLSerializer},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3),i=n(0),o=function(){function e(){}return e.prototype.before=function(){for(var e=[],t=0;t=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(6),o=n(3),a=n(7),s=function(){function e(e){this._nodeList=[],this._recordQueue=[],this._callback=e;var t=i.dom.window;a.set.append(t._mutationObservers,this)}return e.prototype.observe=function(e,t){var n,i;if(void 0===(t=t||{childList:!1,subtree:!1}).attributeOldValue&&void 0===t.attributeFilter||void 0!==t.attributes||(t.attributes=!0),void 0!==t.characterDataOldValue&&void 0===t.characterData&&(t.characterData=!0),!t.childList&&!t.attributes&&!t.characterData)throw new TypeError;if(t.attributeOldValue&&!t.attributes)throw new TypeError;if(void 0!==t.attributeFilter&&!t.attributes)throw new TypeError;if(t.characterDataOldValue&&!t.characterData)throw new TypeError;var s=!1,l=t,c=function(e){var t,n;if(e.observer===u){s=!0;try{for(var i=(t=void 0,r(u._nodeList)),c=i.next();!c.done;c=i.next()){var d=c.value;a.list.remove(d._registeredObserverList,(function(t){return o.Guard.isTransientRegisteredObserver(t)&&t.source===e}))}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}e.options=l}},u=this;try{for(var d=r(e._registeredObserverList),h=d.next();!h.done;h=d.next())c(h.value)}catch(e){n={error:e}}finally{try{h&&!h.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}s||(e._registeredObserverList.push({observer:this,options:t}),this._nodeList.push(e))},e.prototype.disconnect=function(){var e,t,n=this;try{for(var i=r(this._nodeList),o=i.next();!o.done;o=i.next()){var s=o.value;a.list.remove(s._registeredObserverList,(function(e){return e.observer===n}))}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}this._recordQueue=[]},e.prototype.takeRecords=function(){var e=this._recordQueue;return this._recordQueue=[],e},e}();t.MutationObserverImpl=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3),i=function(){function e(){}return Object.defineProperty(e.prototype,"previousElementSibling",{get:function(){for(var e=r.Cast.asNode(this)._previousSibling;e;){if(r.Guard.isElementNode(e))return e;e=e._previousSibling}return null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nextElementSibling",{get:function(){for(var e=r.Cast.asNode(this)._nextSibling;e;){if(r.Guard.isElementNode(e))return e;e=e._nextSibling}return null},enumerable:!0,configurable:!0}),e}();t.NonDocumentTypeChildNodeImpl=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3),i=n(0),o=function(){function e(){}return e.prototype.getElementById=function(e){for(var t=i.tree_getFirstDescendantNode(r.Cast.asNode(this),!1,!1,(function(e){return r.Guard.isElementNode(e)}));null!==t;){if(t._uniqueIdentifier===e)return t;t=i.tree_getNextDescendantNode(r.Cast.asNode(this),t,!1,!1,(function(e){return r.Guard.isElementNode(e)}))}return null},e}();t.NonElementParentNodeImpl=o},function(e,t,n){"use strict";var r=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(3),o=n(0),a=function(){function e(){}return Object.defineProperty(e.prototype,"children",{get:function(){return o.create_htmlCollection(i.Cast.asNode(this))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"firstElementChild",{get:function(){for(var e=i.Cast.asNode(this)._firstChild;e;){if(i.Guard.isElementNode(e))return e;e=e._nextSibling}return null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lastElementChild",{get:function(){for(var e=i.Cast.asNode(this)._lastChild;e;){if(i.Guard.isElementNode(e))return e;e=e._previousSibling}return null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"childElementCount",{get:function(){var e,t,n=0;try{for(var o=r(i.Cast.asNode(this)._children),a=o.next();!a.done;a=o.next()){var s=a.value;i.Guard.isElementNode(s)&&n++}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return n},enumerable:!0,configurable:!0}),e.prototype.prepend=function(){for(var e=[],t=0;t0)&&!(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},i=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var o=n(180),a=n(111),s=n(7),l=n(0),c=n(69),u=function(){function e(){}return e.prototype.parse=function(e){for(var t,n,u,d,h=new o.XMLStringLexer(e,{skipWhitespaceOnlyText:!0}),p=l.create_document(),f=p,m=h.nextToken();m.type!==a.TokenType.EOF;){switch(m.type){case a.TokenType.Declaration:var g=m;if("1.0"!==g.version)throw new Error("Invalid xml version: "+g.version);break;case a.TokenType.DocType:var v=m;if(!l.xml_isPubidChar(v.pubId))throw new Error("DocType public identifier does not match PubidChar construct.");if(!l.xml_isLegalChar(v.sysId)||-1!==v.sysId.indexOf('"')&&-1!==v.sysId.indexOf("'"))throw new Error("DocType system identifier contains invalid characters.");f.appendChild(p.implementation.createDocumentType(v.name,v.pubId,v.sysId));break;case a.TokenType.CDATA:var y=m;if(!l.xml_isLegalChar(y.data)||-1!==y.data.indexOf("]]>"))throw new Error("CDATA contains invalid characters.");f.appendChild(p.createCDATASection(y.data));break;case a.TokenType.Comment:var _=m;if(!l.xml_isLegalChar(_.data)||-1!==_.data.indexOf("--")||_.data.endsWith("-"))throw new Error("Comment data contains invalid characters.");f.appendChild(p.createComment(_.data));break;case a.TokenType.PI:var b=m;if(-1!==b.target.indexOf(":")||/^xml$/i.test(b.target))throw new Error("Processing instruction target contains invalid characters.");if(!l.xml_isLegalChar(b.data)||-1!==b.data.indexOf("?>"))throw new Error("Processing instruction data contains invalid characters.");f.appendChild(p.createProcessingInstruction(b.target,b.data));break;case a.TokenType.Text:var E=m;if(!l.xml_isLegalChar(E.data))throw new Error("Text data contains invalid characters.");f.appendChild(p.createTextNode(this._decodeText(E.data)));break;case a.TokenType.Element:var w=m,x=r(l.namespace_extractQName(w.name),2),C=x[0],D=x[1];if(-1!==D.indexOf(":")||!l.xml_isName(D))throw new Error("Node local name contains invalid characters.");if("xmlns"===C)throw new Error("An element cannot have the 'xmlns' prefix.");var S=f.lookupNamespaceURI(C),T={};try{for(var I=(t=void 0,i(w.attributes)),A=I.next();!A.done;A=I.next()){var N=r(A.value,2),O=N[0],P=N[1];if("xmlns"===O)S=P;else{var k=r(l.namespace_extractQName(O),2),M=k[0],L=k[1];"xmlns"===M&&(L===C&&(S=P),T[L]=P)}}}catch(e){t={error:e}}finally{try{A&&!A.done&&(n=I.return)&&n.call(I)}finally{if(t)throw t.error}}var R=null!==S?p.createElementNS(S,w.name):p.createElement(w.name);f.appendChild(R);var F=new c.LocalNameSet;try{for(var U=(u=void 0,i(w.attributes)),B=U.next();!B.done;B=U.next()){var j=r(B.value,2),V=(O=j[0],P=j[1],r(l.namespace_extractQName(O),2)),W=(M=V[0],L=V[1],null);if("xmlns"===M||null===M&&"xmlns"===L?W=s.namespace.XMLNS:null!==(W=R.lookupNamespaceURI(M))&&R.isDefaultNamespace(W)?W=null:null===W&&null!==M&&(W=T[M]||null),F.has(W,L))throw new Error("Element contains duplicate attributes.");if(F.set(W,L),W===s.namespace.XMLNS&&P===s.namespace.XMLNS)throw new Error("XMLNS namespace is reserved.");if(-1!==L.indexOf(":")||!l.xml_isName(L))throw new Error("Attribute local name contains invalid characters.");if("xmlns"===M&&""===P)throw new Error("Empty XML namespace is not allowed.");null!==W?R.setAttributeNS(W,O,this._decodeAttributeValue(P)):R.setAttribute(O,this._decodeAttributeValue(P))}}catch(e){u={error:e}}finally{try{B&&!B.done&&(d=U.return)&&d.call(U)}finally{if(u)throw u.error}}w.selfClosing||(f=R);break;case a.TokenType.ClosingTag:if(m.name!==f.nodeName)throw new Error("Closing tag name does not match opening tag name.");f._parent&&(f=f._parent)}m=h.nextToken()}return p},e.prototype._decodeText=function(e){return null==e?e:e.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")},e.prototype._decodeAttributeValue=function(e){return null==e?e:e.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")},e}();t.XMLParserImpl=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(275);t.XMLSerializer=r.XMLSerializerImpl},function(e,t,n){"use strict";var r=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),o=n(69),a=n(95),s=n(9),l=n(7),c=n(0),u=function(){function e(){}return e.prototype.serializeToString=function(e){return this._xmlSerialization(e,!1)},e.prototype._xmlSerialization=function(e,t){if(void 0===e._nodeDocument||e._nodeDocument._hasNamespaces){var n=new a.NamespacePrefixMap;n.set("xml",l.namespace.XML);try{return this._serializeNodeNS(e,null,n,{value:1},t)}catch(e){throw new s.InvalidStateError}}else try{return this._serializeNode(e,t)}catch(e){throw new s.InvalidStateError}},e.prototype._serializeNodeNS=function(e,t,n,r,o){switch(e.nodeType){case i.NodeType.Element:return this._serializeElementNS(e,t,n,r,o);case i.NodeType.Document:return this._serializeDocumentNS(e,t,n,r,o);case i.NodeType.Comment:return this._serializeComment(e,o);case i.NodeType.Text:return this._serializeText(e,o);case i.NodeType.DocumentFragment:return this._serializeDocumentFragmentNS(e,t,n,r,o);case i.NodeType.DocumentType:return this._serializeDocumentType(e,o);case i.NodeType.ProcessingInstruction:return this._serializeProcessingInstruction(e,o);case i.NodeType.CData:return this._serializeCData(e,o);default:throw new Error("Unknown node type: "+e.nodeType)}},e.prototype._serializeNode=function(e,t){switch(e.nodeType){case i.NodeType.Element:return this._serializeElement(e,t);case i.NodeType.Document:return this._serializeDocument(e,t);case i.NodeType.Comment:return this._serializeComment(e,t);case i.NodeType.Text:return this._serializeText(e,t);case i.NodeType.DocumentFragment:return this._serializeDocumentFragment(e,t);case i.NodeType.DocumentType:return this._serializeDocumentType(e,t);case i.NodeType.ProcessingInstruction:return this._serializeProcessingInstruction(e,t);case i.NodeType.CData:return this._serializeCData(e,t);default:throw new Error("Unknown node type: "+e.nodeType)}},e.prototype._serializeElementNS=function(t,n,i,o,a){var s,u;if(a&&(-1!==t.localName.indexOf(":")||!c.xml_isName(t.localName)))throw new Error("Node local name contains invalid characters (well-formed required).");var d="<",h="",p=!1,f=!1,m=i.copy(),g={},v=this._recordNamespaceInformation(t,m,g),y=n,_=t.namespaceURI;if(y===_)null!==v&&(f=!0),d+=h=_===l.namespace.XML?"xml:"+t.localName:t.localName;else{var b=t.prefix,E=null;if(null===b&&_===v||(E=m.get(b,_)),"xmlns"===b){if(a)throw new Error("An element cannot have the 'xmlns' prefix (well-formed required).");E=b}null!==E?(h=E+":"+t.localName,null!==v&&v!==l.namespace.XML&&(y=v||null),d+=h):null!==b?(b in g&&(b=this._generatePrefix(_,m,o)),m.set(b,_),d+=h+=b+":"+t.localName,d+=" xmlns:"+b+'="'+this._serializeAttributeValue(_,a)+'"',null!==v&&(y=v||null)):null===v||null!==v&&v!==_?(f=!0,y=_,d+=h+=t.localName,d+=' xmlns="'+this._serializeAttributeValue(_,a)+'"'):(y=_,d+=h+=t.localName)}d+=this._serializeAttributesNS(t,m,o,g,f,a);var w=_===l.namespace.HTML;if(w&&0===t.childNodes.length&&e._VoidElementNames.has(t.localName)?(d+=" /",p=!0):w||0!==t.childNodes.length||(d+="/",p=!0),d+=">",p)return d;if(w&&"template"===t.localName);else try{for(var x=r(t._children||t.childNodes),C=x.next();!C.done;C=x.next()){var D=C.value;d+=this._serializeNodeNS(D,y,m,o,a)}}catch(e){s={error:e}}finally{try{C&&!C.done&&(u=x.return)&&u.call(x)}finally{if(s)throw s.error}}return d+""},e.prototype._serializeDocumentNS=function(e,t,n,i,o){var a,s;if(o&&null===e.documentElement)throw new Error("Missing document element (well-formed required).");var l="";try{for(var c=r(e._children||e.childNodes),u=c.next();!u.done;u=c.next()){var d=u.value;l+=this._serializeNodeNS(d,t,n,i,o)}}catch(e){a={error:e}}finally{try{u&&!u.done&&(s=c.return)&&s.call(c)}finally{if(a)throw a.error}}return l},e.prototype._serializeComment=function(e,t){if(t&&(!c.xml_isLegalChar(e.data)||-1!==e.data.indexOf("--")||e.data.endsWith("-")))throw new Error("Comment data contains invalid characters (well-formed required).");return"\x3c!--"+e.data+"--\x3e"},e.prototype._serializeText=function(e,t){if(t&&!c.xml_isLegalChar(e.data))throw new Error("Text data contains invalid characters (well-formed required).");for(var n="",r=0;r"===i?">":i}return n},e.prototype._serializeDocumentFragmentNS=function(e,t,n,i,o){var a,s,l="";try{for(var c=r(e._children||e.childNodes),u=c.next();!u.done;u=c.next()){var d=u.value;l+=this._serializeNodeNS(d,t,n,i,o)}}catch(e){a={error:e}}finally{try{u&&!u.done&&(s=c.return)&&s.call(c)}finally{if(a)throw a.error}}return l},e.prototype._serializeDocumentType=function(e,t){if(t&&!c.xml_isPubidChar(e.publicId))throw new Error("DocType public identifier does not match PubidChar construct (well-formed required).");if(t&&(!c.xml_isLegalChar(e.systemId)||-1!==e.systemId.indexOf('"')&&-1!==e.systemId.indexOf("'")))throw new Error("DocType system identifier contains invalid characters (well-formed required).");return e.publicId&&e.systemId?"':e.publicId?"':e.systemId?"':""},e.prototype._serializeProcessingInstruction=function(e,t){if(t&&(-1!==e.target.indexOf(":")||/^xml$/i.test(e.target)))throw new Error("Processing instruction target contains invalid characters (well-formed required).");if(t&&(!c.xml_isLegalChar(e.data)||-1!==e.data.indexOf("?>")))throw new Error("Processing instruction data contains invalid characters (well-formed required).");return""},e.prototype._serializeCData=function(e,t){if(t&&-1!==e.data.indexOf("]]>"))throw new Error("CDATA contains invalid characters (well-formed required).");return""},e.prototype._serializeAttributesNS=function(e,t,n,i,a,s){var u,d,h="",p=s?new o.LocalNameSet:void 0;try{for(var f=r(e.attributes),m=f.next();!m.done;m=f.next()){var g=m.value;if(a||s||null!==g.namespaceURI){if(s&&p&&p.has(g.namespaceURI,g.localName))throw new Error("Element contains duplicate attributes (well-formed required).");s&&p&&p.set(g.namespaceURI,g.localName);var v=g.namespaceURI,y=null;if(null!==v)if(y=t.get(g.prefix,v),v===l.namespace.XMLNS){if(g.value===l.namespace.XML||null===g.prefix&&a||null!==g.prefix&&(!(g.localName in i)||i[g.localName]!==g.value)&&t.has(g.localName,g.value))continue;if(s&&g.value===l.namespace.XMLNS)throw new Error("XMLNS namespace is reserved (well-formed required).");if(s&&""===g.value)throw new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required).");"xmlns"===g.prefix&&(y="xmlns")}else null===y&&(h+=" xmlns:"+(y=null===g.prefix||t.hasPrefix(g.prefix)&&!t.has(g.prefix,v)?this._generatePrefix(v,t,n):g.prefix)+'="'+this._serializeAttributeValue(v,s)+'"');if(h+=" ",null!==y&&(h+=y+":"),s&&(-1!==g.localName.indexOf(":")||!c.xml_isName(g.localName)||"xmlns"===g.localName&&null===v))throw new Error("Attribute local name contains invalid characters (well-formed required).");h+=g.localName+'="'+this._serializeAttributeValue(g.value,s)+'"'}else h+=" "+g.localName+'="'+this._serializeAttributeValue(g.value,s)+'"'}}catch(e){u={error:e}}finally{try{m&&!m.done&&(d=f.return)&&d.call(f)}finally{if(u)throw u.error}}return h},e.prototype._recordNamespaceInformation=function(e,t,n){var i,o,a=null;try{for(var s=r(e.attributes),c=s.next();!c.done;c=s.next()){var u=c.value,d=u.namespaceURI,h=u.prefix;if(d===l.namespace.XMLNS){if(null===h){a=u.value;continue}var p=u.localName,f=u.value;if(f===l.namespace.XML)continue;if(""===f&&(f=null),t.has(p,f))continue;t.set(p,f),n[p]=f||""}}}catch(e){i={error:e}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}return a},e.prototype._generatePrefix=function(e,t,n){var r="ns"+n.value;return n.value++,t.set(r,e),r},e.prototype._serializeAttributeValue=function(e,t){if(t&&null!==e&&!c.xml_isLegalChar(e))throw new Error("Invalid characters in attribute value.");if(null===e)return"";for(var n="",r=0;r"===i?">":i}return n},e.prototype._serializeElement=function(e,t){var n,i;if(t&&(-1!==e.localName.indexOf(":")||!c.xml_isName(e.localName)))throw new Error("Node local name contains invalid characters (well-formed required).");var o=!1,a=e.localName,s="<"+a;if(s+=this._serializeAttributes(e,t),0===e._children.size&&(s+="/",o=!0),s+=">",o)return s;try{for(var l=r(e._children),u=l.next();!u.done;u=l.next()){var d=u.value;s+=this._serializeNode(d,t)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}return s+""},e.prototype._serializeDocument=function(e,t){var n,i;if(t&&null===e.documentElement)throw new Error("Missing document element (well-formed required).");var o="";try{for(var a=r(e._children),s=a.next();!s.done;s=a.next()){var l=s.value;o+=this._serializeNode(l,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return o},e.prototype._serializeDocumentFragment=function(e,t){var n,i,o="";try{for(var a=r(e._children),s=a.next();!s.done;s=a.next()){var l=s.value;o+=this._serializeNode(l,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return o},e.prototype._serializeAttributes=function(e,t){var n,i,o="",a=t?{}:void 0;try{for(var s=r(e.attributes),l=s.next();!l.done;l=s.next()){var u=l.value;if(t&&a&&u.localName in a)throw new Error("Element contains duplicate attributes (well-formed required).");if(t&&a&&(a[u.localName]=!0),t&&(-1!==u.localName.indexOf(":")||!c.xml_isName(u.localName)))throw new Error("Attribute local name contains invalid characters (well-formed required).");o+=" "+u.localName+'="'+this._serializeAttributeValue(u.value,t)+'"'}}catch(e){n={error:e}}finally{try{l&&!l.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}return o},e._VoidElementNames=new Set(["area","base","basefont","bgsound","br","col","embed","frame","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),e}();t.XMLSerializerImpl=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(277);t.XMLReader=r.XMLReader;var i=n(112);t.ObjectReader=i.ObjectReader;var o=n(280);t.JSONReader=o.JSONReader;var a=n(281);t.YAMLReader=a.YAMLReader},function(e,t,n){"use strict";n(31),n(32),n(33),n(19),n(65),n(20),n(22),n(23);var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new 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},a=this&&this.__values||function(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.")};Object.defineProperty(t,"__esModule",{value:!0});var s=n(180),l=n(111),c=n(7),u=n(0),d=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype._parse=function(e,t){for(var n,r,i,d,h=new s.XMLStringLexer(t,{skipWhitespaceOnlyText:!0}),p=e,f=e,m=h.nextToken();m.type!==l.TokenType.EOF;){switch(m.type){case l.TokenType.Declaration:var g=m,v=this.sanitize(g.version);if("1.0"!==v)throw new Error("Invalid xml version: "+v);var y={version:v};g.encoding&&(y.encoding=this.sanitize(g.encoding)),g.standalone&&(y.standalone="yes"===this.sanitize(g.standalone)),f.set(y);break;case l.TokenType.DocType:var _=m;f=this.docType(f,this.sanitize(_.name),this.sanitize(_.pubId),this.sanitize(_.sysId))||f;break;case l.TokenType.CDATA:var b=m;f=this.cdata(f,this.sanitize(b.data))||f;break;case l.TokenType.Comment:var E=m;f=this.comment(f,this.sanitize(E.data))||f;break;case l.TokenType.PI:var w=m;f=this.instruction(f,this.sanitize(w.target),this.sanitize(w.data))||f;break;case l.TokenType.Text:var x=m;f=this.text(f,this._decodeText(this.sanitize(x.data)))||f;break;case l.TokenType.Element:var C=m,D=this.sanitize(C.name),S=o(u.namespace_extractQName(D),1)[0],T=f.node.lookupNamespaceURI(S),I={};try{for(var A=(n=void 0,a(C.attributes)),N=A.next();!N.done;N=A.next()){var O=o(N.value,2),P=O[0],k=O[1];if(P=this.sanitize(P),k=this.sanitize(k),"xmlns"===P)T=k;else{var M=o(u.namespace_extractQName(P),2),L=M[0],R=M[1];"xmlns"===L&&(R===S&&(T=k),I[R]=k)}}}catch(e){n={error:e}}finally{try{N&&!N.done&&(r=A.return)&&r.call(A)}finally{if(n)throw n.error}}var F=null!==T?this.element(f,T,D):this.element(f,void 0,D);if(void 0===F)break;f.node===e.node&&(p=F);try{for(var U=(i=void 0,a(C.attributes)),B=U.next();!B.done;B=U.next()){var j=o(B.value,2);P=j[0],k=j[1],P=this.sanitize(P),k=this.sanitize(k);var V=o(u.namespace_extractQName(P),2),W=(L=V[0],R=V[1],null);"xmlns"===L||null===L&&"xmlns"===R?W=c.namespace.XMLNS:null!==(W=F.node.lookupNamespaceURI(L))&&F.node.isDefaultNamespace(W)?W=null:null===W&&null!==L&&(W=I[L]||null),null!==W?this.attribute(F,W,P,this._decodeAttributeValue(k)):this.attribute(F,void 0,P,this._decodeAttributeValue(k))}}catch(e){i={error:e}}finally{try{B&&!B.done&&(d=U.return)&&d.call(U)}finally{if(i)throw i.error}}C.selfClosing||(f=F);break;case l.TokenType.ClosingTag:f.node.parentNode&&(f=f.up())}m=h.nextToken()}return p},t}(n(75).BaseReader);t.XMLReader=d},function(e,t,n){var r=n(4),i=n(279);r({target:"Object",stat:!0,forced:Object.assign!==i},{assign:i})},function(e,t,n){"use strict";var r=n(16),i=n(8),o=n(61),a=n(85),s=n(79),l=n(27),c=n(41),u=Object.assign,d=Object.defineProperty;e.exports=!u||i((function(){if(r&&1!==u({b:1},u(d({},"a",{enumerable:!0,get:function(){d(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol();return e[n]=7,"abcdefghijklmnopqrst".split("").forEach((function(e){t[e]=e})),7!=u({},e)[n]||"abcdefghijklmnopqrst"!=o(u({},t)).join("")}))?function(e,t){for(var n=l(e),i=arguments.length,u=1,d=a.f,h=s.f;i>u;)for(var p,f=c(arguments[u++]),m=d?o(f).concat(d(f)):o(f),g=m.length,v=0;g>v;)p=m[v++],r&&!h.call(f,p)||(n[p]=f[p]);return n}:u},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=n(112),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype._parse=function(e,t){return new o.ObjectReader(this._builderOptions).parse(e,JSON.parse(t))},t}(n(75).BaseReader);t.JSONReader=a},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=n(112),a=n(75),s=n(282),l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype._parse=function(e,t){var n=s.safeLoad(t);if(void 0===n)throw new Error("Unable to parse YAML document.");return new o.ObjectReader(this._builderOptions).parse(e,n)},t}(a.BaseReader);t.YAMLReader=l},function(e,t,n){"use strict";var r=n(283);e.exports=r},function(e,t,n){"use strict";var r=n(284),i=n(303);function o(e){return function(){throw new Error("Function "+e+" is deprecated and cannot be used.")}}e.exports.Type=n(10),e.exports.Schema=n(39),e.exports.FAILSAFE_SCHEMA=n(113),e.exports.JSON_SCHEMA=n(182),e.exports.CORE_SCHEMA=n(181),e.exports.DEFAULT_SAFE_SCHEMA=n(54),e.exports.DEFAULT_FULL_SCHEMA=n(76),e.exports.load=r.load,e.exports.loadAll=r.loadAll,e.exports.safeLoad=r.safeLoad,e.exports.safeLoadAll=r.safeLoadAll,e.exports.dump=i.dump,e.exports.safeDump=i.safeDump,e.exports.YAMLException=n(53),e.exports.MINIMAL_SCHEMA=n(113),e.exports.SAFE_SCHEMA=n(54),e.exports.DEFAULT_SCHEMA=n(76),e.exports.scan=o("scan"),e.exports.parse=o("parse"),e.exports.compose=o("compose"),e.exports.addConstructor=o("addConstructor")},function(e,t,n){"use strict";var r=n(38),i=n(53),o=n(285),a=n(54),s=n(76),l=Object.prototype.hasOwnProperty,c=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,u=/[\x85\u2028\u2029]/,d=/[,\[\]\{\}]/,h=/^(?:!|!!|![a-z\-]+!)$/i,p=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function f(e){return Object.prototype.toString.call(e)}function m(e){return 10===e||13===e}function g(e){return 9===e||32===e}function v(e){return 9===e||32===e||10===e||13===e}function y(e){return 44===e||91===e||93===e||123===e||125===e}function _(e){var t;return 48<=e&&e<=57?e-48:97<=(t=32|e)&&t<=102?t-97+10:-1}function b(e){return 48===e?"\0":97===e?"":98===e?"\b":116===e||9===e?"\t":110===e?"\n":118===e?"\v":102===e?"\f":114===e?"\r":101===e?"":32===e?" ":34===e?'"':47===e?"/":92===e?"\\":78===e?"…":95===e?" ":76===e?"\u2028":80===e?"\u2029":""}function E(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}for(var w=new Array(256),x=new Array(256),C=0;C<256;C++)w[C]=b(C)?1:0,x[C]=b(C);function D(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||s,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.documents=[]}function S(e,t){return new i(t,new o(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function T(e,t){throw S(e,t)}function I(e,t){e.onWarning&&e.onWarning.call(null,S(e,t))}var A={YAML:function(e,t,n){var r,i,o;null!==e.version&&T(e,"duplication of %YAML directive"),1!==n.length&&T(e,"YAML directive accepts exactly one argument"),null===(r=/^([0-9]+)\.([0-9]+)$/.exec(n[0]))&&T(e,"ill-formed argument of the YAML directive"),i=parseInt(r[1],10),o=parseInt(r[2],10),1!==i&&T(e,"unacceptable YAML version of the document"),e.version=n[0],e.checkLineBreaks=o<2,1!==o&&2!==o&&I(e,"unsupported YAML version of the document")},TAG:function(e,t,n){var r,i;2!==n.length&&T(e,"TAG directive accepts exactly two arguments"),r=n[0],i=n[1],h.test(r)||T(e,"ill-formed tag handle (first argument) of the TAG directive"),l.call(e.tagMap,r)&&T(e,'there is a previously declared suffix for "'+r+'" tag handle'),p.test(i)||T(e,"ill-formed tag prefix (second argument) of the TAG directive"),e.tagMap[r]=i}};function N(e,t,n,r){var i,o,a,s;if(t1&&(e.result+=r.repeat("\n",t-1))}function F(e,t){var n,r,i=e.tag,o=e.anchor,a=[],s=!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=a),r=e.input.charCodeAt(e.position);0!==r&&45===r&&v(e.input.charCodeAt(e.position+1));)if(s=!0,e.position++,M(e,!0,-1)&&e.lineIndent<=t)a.push(null),r=e.input.charCodeAt(e.position);else if(n=e.line,j(e,t,3,!1,!0),a.push(e.result),M(e,!0,-1),r=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&0!==r)T(e,"bad indentation of a sequence entry");else if(e.lineIndentt?b=1:e.lineIndent===t?b=0:e.lineIndentt?b=1:e.lineIndent===t?b=0:e.lineIndentt)&&(j(e,t,4,!0,i)&&(m?p=e.result:f=e.result),m||(P(e,u,d,h,p,f,o,a),h=p=f=null),M(e,!0,-1),s=e.input.charCodeAt(e.position)),e.lineIndent>t&&0!==s)T(e,"bad indentation of a mapping entry");else if(e.lineIndent=0))break;0===o?T(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):u?T(e,"repeat of an indentation width identifier"):(d=t+o-1,u=!0)}if(g(a)){do{a=e.input.charCodeAt(++e.position)}while(g(a));if(35===a)do{a=e.input.charCodeAt(++e.position)}while(!m(a)&&0!==a)}for(;0!==a;){for(k(e),e.lineIndent=0,a=e.input.charCodeAt(e.position);(!u||e.lineIndentd&&(d=e.lineIndent),m(a))h++;else{if(e.lineIndent0){for(i=a,o=0;i>0;i--)(a=_(s=e.input.charCodeAt(++e.position)))>=0?o=(o<<4)+a:T(e,"expected hexadecimal character");e.result+=E(o),e.position++}else T(e,"unknown escape sequence");n=r=e.position}else m(s)?(N(e,n,r,!0),R(e,M(e,!1,t)),n=r=e.position):e.position===e.lineStart&&L(e)?T(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}T(e,"unexpected end of the stream within a double quoted scalar")}(e,p)?D=!0:function(e){var t,n,r;if(42!==(r=e.input.charCodeAt(e.position)))return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!v(r)&&!y(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&T(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),e.anchorMap.hasOwnProperty(n)||T(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],M(e,!0,-1),!0}(e)?(D=!0,null===e.tag&&null===e.anchor||T(e,"alias node should not have any properties")):function(e,t,n){var r,i,o,a,s,l,c,u,d=e.kind,h=e.result;if(v(u=e.input.charCodeAt(e.position))||y(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(v(r=e.input.charCodeAt(e.position+1))||n&&y(r)))return!1;for(e.kind="scalar",e.result="",i=o=e.position,a=!1;0!==u;){if(58===u){if(v(r=e.input.charCodeAt(e.position+1))||n&&y(r))break}else if(35===u){if(v(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&L(e)||n&&y(u))break;if(m(u)){if(s=e.line,l=e.lineStart,c=e.lineIndent,M(e,!1,-1),e.lineIndent>=t){a=!0,u=e.input.charCodeAt(e.position);continue}e.position=o,e.line=s,e.lineStart=l,e.lineIndent=c;break}}a&&(N(e,i,o,!1),R(e,e.line-s),i=o=e.position,a=!1),g(u)||(o=e.position+1),u=e.input.charCodeAt(++e.position)}return N(e,i,o,!1),!!e.result||(e.kind=d,e.result=h,!1)}(e,p,1===n)&&(D=!0,null===e.tag&&(e.tag="?")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===b&&(D=c&&F(e,f))),null!==e.tag&&"!"!==e.tag)if("?"===e.tag){for(null!==e.result&&"scalar"!==e.kind&&T(e,'unacceptable node kind for ! tag; it should be "scalar", not "'+e.kind+'"'),u=0,d=e.implicitTypes.length;u tag; it should be "'+h.kind+'", not "'+e.kind+'"'),h.resolve(e.result)?(e.result=h.construct(e.result),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):T(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")):T(e,"unknown tag !<"+e.tag+">");return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||D}function V(e){var t,n,r,i,o=e.position,a=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};0!==(i=e.input.charCodeAt(e.position))&&(M(e,!0,-1),i=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==i));){for(a=!0,i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!v(i);)i=e.input.charCodeAt(++e.position);for(r=[],(n=e.input.slice(t,e.position)).length<1&&T(e,"directive name must not be less than one character in length");0!==i;){for(;g(i);)i=e.input.charCodeAt(++e.position);if(35===i){do{i=e.input.charCodeAt(++e.position)}while(0!==i&&!m(i));break}if(m(i))break;for(t=e.position;0!==i&&!v(i);)i=e.input.charCodeAt(++e.position);r.push(e.input.slice(t,e.position))}0!==i&&k(e),l.call(A,n)?A[n](e,n,r):I(e,'unknown document directive "'+n+'"')}M(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,M(e,!0,-1)):a&&T(e,"directives end mark is expected"),j(e,e.lineIndent-1,4,!1,!0),M(e,!0,-1),e.checkLineBreaks&&u.test(e.input.slice(o,e.position))&&I(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&L(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,M(e,!0,-1)):e.position0&&-1==="\0\r\n…\u2028\u2029".indexOf(this.buffer.charAt(i-1));)if(i-=1,this.position-i>t/2-1){n=" ... ",i+=5;break}for(o="",a=this.position;at/2-1){o=" ... ",a-=5;break}return s=this.buffer.slice(i,a),r.repeat(" ",e)+n+s+o+"\n"+r.repeat(" ",e+this.position-i+n.length)+"^"},i.prototype.toString=function(e){var t,n="";return this.name&&(n+='in "'+this.name+'" '),n+="at line "+(this.line+1)+", column "+(this.column+1),e||(t=this.getSnippet())&&(n+=":\n"+t),n},e.exports=i},function(e,t,n){"use strict";var r=n(10);e.exports=new r("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return null!==e?e:""}})},function(e,t,n){"use strict";var r=n(10);e.exports=new r("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return null!==e?e:[]}})},function(e,t,n){"use strict";var r=n(10);e.exports=new r("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return null!==e?e:{}}})},function(e,t,n){"use strict";var r=n(10);e.exports=new r("tag:yaml.org,2002:null",{kind:"scalar",resolve:function(e){if(null===e)return!0;var t=e.length;return 1===t&&"~"===e||4===t&&("null"===e||"Null"===e||"NULL"===e)},construct:function(){return null},predicate:function(e){return null===e},represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})},function(e,t,n){"use strict";var r=n(10);e.exports=new r("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return"true"===e||"True"===e||"TRUE"===e},predicate:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})},function(e,t,n){"use strict";var r=n(38),i=n(10);function o(e){return 48<=e&&e<=55}function a(e){return 48<=e&&e<=57}e.exports=new i("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,r=e.length,i=0,s=!1;if(!r)return!1;if("-"!==(t=e[i])&&"+"!==t||(t=e[++i]),"0"===t){if(i+1===r)return!0;if("b"===(t=e[++i])){for(i++;i=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0"+e.toString(8):"-0"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})},function(e,t,n){"use strict";var r=n(38),i=n(10),o=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),a=/^[-+]?[0-9]+e/;e.exports=new i("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!o.test(e)||"_"===e[e.length-1])},construct:function(e){var t,n,r,i;return n="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,i=[],"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:t.indexOf(":")>=0?(t.split(":").forEach((function(e){i.unshift(parseFloat(e,10))})),t=0,r=1,i.forEach((function(e){t+=e*r,r*=60})),n*t):n*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||r.isNegativeZero(e))},represent:function(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(r.isNegativeZero(e))return"-0.0";return n=e.toString(10),a.test(n)?n.replace("e",".e"):n},defaultStyle:"lowercase"})},function(e,t,n){"use strict";var r=n(10),i=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),o=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");e.exports=new r("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==i.exec(e)||null!==o.exec(e))},construct:function(e){var t,n,r,a,s,l,c,u,d=0,h=null;if(null===(t=i.exec(e))&&(t=o.exec(e)),null===t)throw new Error("Date resolve error");if(n=+t[1],r=+t[2]-1,a=+t[3],!t[4])return new Date(Date.UTC(n,r,a));if(s=+t[4],l=+t[5],c=+t[6],t[7]){for(d=t[7].slice(0,3);d.length<3;)d+="0";d=+d}return t[9]&&(h=6e4*(60*+t[10]+ +(t[11]||0)),"-"===t[9]&&(h=-h)),u=new Date(Date.UTC(n,r,a,s,l,c,d)),h&&u.setTime(u.getTime()-h),u},instanceOf:Date,represent:function(e){return e.toISOString()}})},function(e,t,n){"use strict";var r=n(10);e.exports=new r("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}})},function(e,t,n){"use strict";var r;try{r=n(145).Buffer}catch(e){}var i=n(10),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";e.exports=new i("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,r=0,i=e.length,a=o;for(n=0;n64)){if(t<0)return!1;r+=6}return r%8==0},construct:function(e){var t,n,i=e.replace(/[\r\n=]/g,""),a=i.length,s=o,l=0,c=[];for(t=0;t>16&255),c.push(l>>8&255),c.push(255&l)),l=l<<6|s.indexOf(i.charAt(t));return 0==(n=a%4*6)?(c.push(l>>16&255),c.push(l>>8&255),c.push(255&l)):18===n?(c.push(l>>10&255),c.push(l>>2&255)):12===n&&c.push(l>>4&255),r?r.from?r.from(c):new r(c):c},predicate:function(e){return r&&r.isBuffer(e)},represent:function(e){var t,n,r="",i=0,a=e.length,s=o;for(t=0;t>18&63],r+=s[i>>12&63],r+=s[i>>6&63],r+=s[63&i]),i=(i<<8)+e[t];return 0==(n=a%3)?(r+=s[i>>18&63],r+=s[i>>12&63],r+=s[i>>6&63],r+=s[63&i]):2===n?(r+=s[i>>10&63],r+=s[i>>4&63],r+=s[i<<2&63],r+=s[64]):1===n&&(r+=s[i>>2&63],r+=s[i<<4&63],r+=s[64],r+=s[64]),r}})},function(e,t,n){"use strict";var r=n(10),i=Object.prototype.hasOwnProperty,o=Object.prototype.toString;e.exports=new r("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,n,r,a,s,l=[],c=e;for(t=0,n=c.length;t3)return!1;if("/"!==t[t.length-r.length-1])return!1}return!0},construct:function(e){var t=e,n=/\/([gim]*)$/.exec(e),r="";return"/"===t[0]&&(n&&(r=n[1]),t=t.slice(1,t.length-r.length-1)),new RegExp(t,r)},predicate:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},represent:function(e){var t="/"+e.source+"/";return e.global&&(t+="g"),e.multiline&&(t+="m"),e.ignoreCase&&(t+="i"),t}})},function(e,t,n){"use strict";var r;try{r=n(302)}catch(e){"undefined"!=typeof window&&(r=window.esprima)}var i=n(10);e.exports=new i("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:function(e){if(null===e)return!1;try{var t="("+e+")",n=r.parse(t,{range:!0});return"Program"===n.type&&1===n.body.length&&"ExpressionStatement"===n.body[0].type&&("ArrowFunctionExpression"===n.body[0].expression.type||"FunctionExpression"===n.body[0].expression.type)}catch(e){return!1}},construct:function(e){var t,n="("+e+")",i=r.parse(n,{range:!0}),o=[];if("Program"!==i.type||1!==i.body.length||"ExpressionStatement"!==i.body[0].type||"ArrowFunctionExpression"!==i.body[0].expression.type&&"FunctionExpression"!==i.body[0].expression.type)throw new Error("Failed to resolve function");return i.body[0].expression.params.forEach((function(e){o.push(e.name)})),t=i.body[0].expression.body.range,"BlockStatement"===i.body[0].expression.body.type?new Function(o,n.slice(t[0]+1,t[1]-1)):new Function(o,"return "+n.slice(t[0],t[1]))},predicate:function(e){return"[object Function]"===Object.prototype.toString.call(e)},represent:function(e){return e.toString()}})},function(e,t,n){var r;r=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}return n.m=e,n.c=t,n.p="",n(0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),i=n(3),o=n(8),a=n(15);function s(e,t,n){var a=null,s=function(e,t){n&&n(e,t),a&&a.visit(e,t)},l="function"==typeof n?s:null,c=!1;if(t){c="boolean"==typeof t.comment&&t.comment;var u="boolean"==typeof t.attachComment&&t.attachComment;(c||u)&&((a=new r.CommentHandler).attach=u,t.comment=!0,l=s)}var d,h=!1;t&&"string"==typeof t.sourceType&&(h="module"===t.sourceType),d=t&&"boolean"==typeof t.jsx&&t.jsx?new i.JSXParser(e,t,l):new o.Parser(e,t,l);var p=h?d.parseModule():d.parseScript();return c&&a&&(p.comments=a.comments),d.config.tokens&&(p.tokens=d.tokens),d.config.tolerant&&(p.errors=d.errorHandler.errors),p}t.parse=s,t.parseModule=function(e,t,n){var r=t||{};return r.sourceType="module",s(e,r,n)},t.parseScript=function(e,t,n){var r=t||{};return r.sourceType="script",s(e,r,n)},t.tokenize=function(e,t,n){var r,i=new a.Tokenizer(e,t);r=[];try{for(;;){var o=i.getNextToken();if(!o)break;n&&(o=n(o)),r.push(o)}}catch(e){i.errorHandler.tolerate(e)}return i.errorHandler.tolerant&&(r.errors=i.errors()),r};var l=n(2);t.Syntax=l.Syntax,t.version="4.0.1"},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),i=function(){function e(){this.attach=!1,this.comments=[],this.stack=[],this.leading=[],this.trailing=[]}return e.prototype.insertInnerComments=function(e,t){if(e.type===r.Syntax.BlockStatement&&0===e.body.length){for(var n=[],i=this.leading.length-1;i>=0;--i){var o=this.leading[i];t.end.offset>=o.start&&(n.unshift(o.comment),this.leading.splice(i,1),this.trailing.splice(i,1))}n.length&&(e.innerComments=n)}},e.prototype.findTrailingComments=function(e){var t=[];if(this.trailing.length>0){for(var n=this.trailing.length-1;n>=0;--n){var r=this.trailing[n];r.start>=e.end.offset&&t.unshift(r.comment)}return this.trailing.length=0,t}var i=this.stack[this.stack.length-1];if(i&&i.node.trailingComments){var o=i.node.trailingComments[0];o&&o.range[0]>=e.end.offset&&(t=i.node.trailingComments,delete i.node.trailingComments)}return t},e.prototype.findLeadingComments=function(e){for(var t,n=[];this.stack.length>0&&(o=this.stack[this.stack.length-1])&&o.start>=e.start.offset;)t=o.node,this.stack.pop();if(t){for(var r=(t.leadingComments?t.leadingComments.length:0)-1;r>=0;--r){var i=t.leadingComments[r];i.range[1]<=e.start.offset&&(n.unshift(i),t.leadingComments.splice(r,1))}return t.leadingComments&&0===t.leadingComments.length&&delete t.leadingComments,n}for(r=this.leading.length-1;r>=0;--r){var o;(o=this.leading[r]).start<=e.start.offset&&(n.unshift(o.comment),this.leading.splice(r,1))}return n},e.prototype.visitNode=function(e,t){if(!(e.type===r.Syntax.Program&&e.body.length>0)){this.insertInnerComments(e,t);var n=this.findTrailingComments(t),i=this.findLeadingComments(t);i.length>0&&(e.leadingComments=i),n.length>0&&(e.trailingComments=n),this.stack.push({node:e,start:t.start.offset})}},e.prototype.visitComment=function(e,t){var n="L"===e.type[0]?"Line":"Block",r={type:n,value:e.value};if(e.range&&(r.range=e.range),e.loc&&(r.loc=e.loc),this.comments.push(r),this.attach){var i={comment:{type:n,value:e.value,range:[t.start.offset,t.end.offset]},start:t.start.offset};e.loc&&(i.comment.loc=e.loc),e.type=n,this.leading.push(i),this.trailing.push(i)}},e.prototype.visit=function(e,t){"LineComment"===e.type||"BlockComment"===e.type?this.visitComment(e,t):this.attach&&this.visitNode(e,t)},e}();t.CommentHandler=i},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Syntax={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForOfStatement:"ForOfStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchCase:"SwitchCase",SwitchStatement:"SwitchStatement",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"}},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=n(4),a=n(5),s=n(6),l=n(7),c=n(8),u=n(13),d=n(14);function h(e){var t;switch(e.type){case s.JSXSyntax.JSXIdentifier:t=e.name;break;case s.JSXSyntax.JSXNamespacedName:var n=e;t=h(n.namespace)+":"+h(n.name);break;case s.JSXSyntax.JSXMemberExpression:var r=e;t=h(r.object)+"."+h(r.property)}return t}u.TokenName[100]="JSXIdentifier",u.TokenName[101]="JSXText";var p=function(e){function t(t,n,r){return e.call(this,t,n,r)||this}return i(t,e),t.prototype.parsePrimaryExpression=function(){return this.match("<")?this.parseJSXRoot():e.prototype.parsePrimaryExpression.call(this)},t.prototype.startJSX=function(){this.scanner.index=this.startMarker.index,this.scanner.lineNumber=this.startMarker.line,this.scanner.lineStart=this.startMarker.index-this.startMarker.column},t.prototype.finishJSX=function(){this.nextToken()},t.prototype.reenterJSX=function(){this.startJSX(),this.expectJSX("}"),this.config.tokens&&this.tokens.pop()},t.prototype.createJSXNode=function(){return this.collectComments(),{index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}},t.prototype.createJSXChildNode=function(){return{index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}},t.prototype.scanXHTMLEntity=function(e){for(var t="&",n=!0,r=!1,i=!1,a=!1;!this.scanner.eof()&&n&&!r;){var s=this.scanner.source[this.scanner.index];if(s===e)break;if(r=";"===s,t+=s,++this.scanner.index,!r)switch(t.length){case 2:i="#"===s;break;case 3:i&&(n=(a="x"===s)||o.Character.isDecimalDigit(s.charCodeAt(0)),i=i&&!a);break;default:n=(n=n&&!(i&&!o.Character.isDecimalDigit(s.charCodeAt(0))))&&!(a&&!o.Character.isHexDigit(s.charCodeAt(0)))}}if(n&&r&&t.length>2){var l=t.substr(1,t.length-2);i&&l.length>1?t=String.fromCharCode(parseInt(l.substr(1),10)):a&&l.length>2?t=String.fromCharCode(parseInt("0"+l.substr(1),16)):i||a||!d.XHTMLEntities[l]||(t=d.XHTMLEntities[l])}return t},t.prototype.lexJSX=function(){var e=this.scanner.source.charCodeAt(this.scanner.index);if(60===e||62===e||47===e||58===e||61===e||123===e||125===e)return{type:7,value:s=this.scanner.source[this.scanner.index++],lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:this.scanner.index-1,end:this.scanner.index};if(34===e||39===e){for(var t=this.scanner.index,n=this.scanner.source[this.scanner.index++],r="";!this.scanner.eof()&&(l=this.scanner.source[this.scanner.index++])!==n;)r+="&"===l?this.scanXHTMLEntity(n):l;return{type:8,value:r,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:t,end:this.scanner.index}}if(46===e){var i=this.scanner.source.charCodeAt(this.scanner.index+1),a=this.scanner.source.charCodeAt(this.scanner.index+2),s=46===i&&46===a?"...":".";return t=this.scanner.index,this.scanner.index+=s.length,{type:7,value:s,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:t,end:this.scanner.index}}if(96===e)return{type:10,value:"",lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:this.scanner.index,end:this.scanner.index};if(o.Character.isIdentifierStart(e)&&92!==e){for(t=this.scanner.index,++this.scanner.index;!this.scanner.eof();){var l=this.scanner.source.charCodeAt(this.scanner.index);if(o.Character.isIdentifierPart(l)&&92!==l)++this.scanner.index;else{if(45!==l)break;++this.scanner.index}}return{type:100,value:this.scanner.source.slice(t,this.scanner.index),lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:t,end:this.scanner.index}}return this.scanner.lex()},t.prototype.nextJSXToken=function(){this.collectComments(),this.startMarker.index=this.scanner.index,this.startMarker.line=this.scanner.lineNumber,this.startMarker.column=this.scanner.index-this.scanner.lineStart;var e=this.lexJSX();return this.lastMarker.index=this.scanner.index,this.lastMarker.line=this.scanner.lineNumber,this.lastMarker.column=this.scanner.index-this.scanner.lineStart,this.config.tokens&&this.tokens.push(this.convertToken(e)),e},t.prototype.nextJSXText=function(){this.startMarker.index=this.scanner.index,this.startMarker.line=this.scanner.lineNumber,this.startMarker.column=this.scanner.index-this.scanner.lineStart;for(var e=this.scanner.index,t="";!this.scanner.eof();){var n=this.scanner.source[this.scanner.index];if("{"===n||"<"===n)break;++this.scanner.index,t+=n,o.Character.isLineTerminator(n.charCodeAt(0))&&(++this.scanner.lineNumber,"\r"===n&&"\n"===this.scanner.source[this.scanner.index]&&++this.scanner.index,this.scanner.lineStart=this.scanner.index)}this.lastMarker.index=this.scanner.index,this.lastMarker.line=this.scanner.lineNumber,this.lastMarker.column=this.scanner.index-this.scanner.lineStart;var r={type:101,value:t,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:e,end:this.scanner.index};return t.length>0&&this.config.tokens&&this.tokens.push(this.convertToken(r)),r},t.prototype.peekJSXToken=function(){var e=this.scanner.saveState();this.scanner.scanComments();var t=this.lexJSX();return this.scanner.restoreState(e),t},t.prototype.expectJSX=function(e){var t=this.nextJSXToken();7===t.type&&t.value===e||this.throwUnexpectedToken(t)},t.prototype.matchJSX=function(e){var t=this.peekJSXToken();return 7===t.type&&t.value===e},t.prototype.parseJSXIdentifier=function(){var e=this.createJSXNode(),t=this.nextJSXToken();return 100!==t.type&&this.throwUnexpectedToken(t),this.finalize(e,new a.JSXIdentifier(t.value))},t.prototype.parseJSXElementName=function(){var e=this.createJSXNode(),t=this.parseJSXIdentifier();if(this.matchJSX(":")){var n=t;this.expectJSX(":");var r=this.parseJSXIdentifier();t=this.finalize(e,new a.JSXNamespacedName(n,r))}else if(this.matchJSX("."))for(;this.matchJSX(".");){var i=t;this.expectJSX(".");var o=this.parseJSXIdentifier();t=this.finalize(e,new a.JSXMemberExpression(i,o))}return t},t.prototype.parseJSXAttributeName=function(){var e,t=this.createJSXNode(),n=this.parseJSXIdentifier();if(this.matchJSX(":")){var r=n;this.expectJSX(":");var i=this.parseJSXIdentifier();e=this.finalize(t,new a.JSXNamespacedName(r,i))}else e=n;return e},t.prototype.parseJSXStringLiteralAttribute=function(){var e=this.createJSXNode(),t=this.nextJSXToken();8!==t.type&&this.throwUnexpectedToken(t);var n=this.getTokenRaw(t);return this.finalize(e,new l.Literal(t.value,n))},t.prototype.parseJSXExpressionAttribute=function(){var e=this.createJSXNode();this.expectJSX("{"),this.finishJSX(),this.match("}")&&this.tolerateError("JSX attributes must only be assigned a non-empty expression");var t=this.parseAssignmentExpression();return this.reenterJSX(),this.finalize(e,new a.JSXExpressionContainer(t))},t.prototype.parseJSXAttributeValue=function(){return this.matchJSX("{")?this.parseJSXExpressionAttribute():this.matchJSX("<")?this.parseJSXElement():this.parseJSXStringLiteralAttribute()},t.prototype.parseJSXNameValueAttribute=function(){var e=this.createJSXNode(),t=this.parseJSXAttributeName(),n=null;return this.matchJSX("=")&&(this.expectJSX("="),n=this.parseJSXAttributeValue()),this.finalize(e,new a.JSXAttribute(t,n))},t.prototype.parseJSXSpreadAttribute=function(){var e=this.createJSXNode();this.expectJSX("{"),this.expectJSX("..."),this.finishJSX();var t=this.parseAssignmentExpression();return this.reenterJSX(),this.finalize(e,new a.JSXSpreadAttribute(t))},t.prototype.parseJSXAttributes=function(){for(var e=[];!this.matchJSX("/")&&!this.matchJSX(">");){var t=this.matchJSX("{")?this.parseJSXSpreadAttribute():this.parseJSXNameValueAttribute();e.push(t)}return e},t.prototype.parseJSXOpeningElement=function(){var e=this.createJSXNode();this.expectJSX("<");var t=this.parseJSXElementName(),n=this.parseJSXAttributes(),r=this.matchJSX("/");return r&&this.expectJSX("/"),this.expectJSX(">"),this.finalize(e,new a.JSXOpeningElement(t,r,n))},t.prototype.parseJSXBoundaryElement=function(){var e=this.createJSXNode();if(this.expectJSX("<"),this.matchJSX("/")){this.expectJSX("/");var t=this.parseJSXElementName();return this.expectJSX(">"),this.finalize(e,new a.JSXClosingElement(t))}var n=this.parseJSXElementName(),r=this.parseJSXAttributes(),i=this.matchJSX("/");return i&&this.expectJSX("/"),this.expectJSX(">"),this.finalize(e,new a.JSXOpeningElement(n,i,r))},t.prototype.parseJSXEmptyExpression=function(){var e=this.createJSXChildNode();return this.collectComments(),this.lastMarker.index=this.scanner.index,this.lastMarker.line=this.scanner.lineNumber,this.lastMarker.column=this.scanner.index-this.scanner.lineStart,this.finalize(e,new a.JSXEmptyExpression)},t.prototype.parseJSXExpressionContainer=function(){var e,t=this.createJSXNode();return this.expectJSX("{"),this.matchJSX("}")?(e=this.parseJSXEmptyExpression(),this.expectJSX("}")):(this.finishJSX(),e=this.parseAssignmentExpression(),this.reenterJSX()),this.finalize(t,new a.JSXExpressionContainer(e))},t.prototype.parseJSXChildren=function(){for(var e=[];!this.scanner.eof();){var t=this.createJSXChildNode(),n=this.nextJSXText();if(n.start0))break;o=this.finalize(e.node,new a.JSXElement(e.opening,e.children,e.closing)),(e=t[t.length-1]).children.push(o),t.pop()}}return e},t.prototype.parseJSXElement=function(){var e=this.createJSXNode(),t=this.parseJSXOpeningElement(),n=[],r=null;if(!t.selfClosing){var i=this.parseComplexJSXElement({node:e,opening:t,closing:r,children:n});n=i.children,r=i.closing}return this.finalize(e,new a.JSXElement(t,n,r))},t.prototype.parseJSXRoot=function(){this.config.tokens&&this.tokens.pop(),this.startJSX();var e=this.parseJSXElement();return this.finishJSX(),e},t.prototype.isStartOfExpression=function(){return e.prototype.isStartOfExpression.call(this)||this.match("<")},t}(c.Parser);t.JSXParser=p},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={NonAsciiIdentifierStart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,NonAsciiIdentifierPart:/[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/};t.Character={fromCodePoint:function(e){return e<65536?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10))+String.fromCharCode(56320+(e-65536&1023))},isWhiteSpace:function(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0},isLineTerminator:function(e){return 10===e||13===e||8232===e||8233===e},isIdentifierStart:function(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||92===e||e>=128&&n.NonAsciiIdentifierStart.test(t.Character.fromCodePoint(e))},isIdentifierPart:function(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||92===e||e>=128&&n.NonAsciiIdentifierPart.test(t.Character.fromCodePoint(e))},isDecimalDigit:function(e){return e>=48&&e<=57},isHexDigit:function(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102},isOctalDigit:function(e){return e>=48&&e<=55}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6),i=function(e){this.type=r.JSXSyntax.JSXClosingElement,this.name=e};t.JSXClosingElement=i;var o=function(e,t,n){this.type=r.JSXSyntax.JSXElement,this.openingElement=e,this.children=t,this.closingElement=n};t.JSXElement=o;var a=function(){this.type=r.JSXSyntax.JSXEmptyExpression};t.JSXEmptyExpression=a;var s=function(e){this.type=r.JSXSyntax.JSXExpressionContainer,this.expression=e};t.JSXExpressionContainer=s;var l=function(e){this.type=r.JSXSyntax.JSXIdentifier,this.name=e};t.JSXIdentifier=l;var c=function(e,t){this.type=r.JSXSyntax.JSXMemberExpression,this.object=e,this.property=t};t.JSXMemberExpression=c;var u=function(e,t){this.type=r.JSXSyntax.JSXAttribute,this.name=e,this.value=t};t.JSXAttribute=u;var d=function(e,t){this.type=r.JSXSyntax.JSXNamespacedName,this.namespace=e,this.name=t};t.JSXNamespacedName=d;var h=function(e,t,n){this.type=r.JSXSyntax.JSXOpeningElement,this.name=e,this.selfClosing=t,this.attributes=n};t.JSXOpeningElement=h;var p=function(e){this.type=r.JSXSyntax.JSXSpreadAttribute,this.argument=e};t.JSXSpreadAttribute=p;var f=function(e,t){this.type=r.JSXSyntax.JSXText,this.value=e,this.raw=t};t.JSXText=f},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JSXSyntax={JSXAttribute:"JSXAttribute",JSXClosingElement:"JSXClosingElement",JSXElement:"JSXElement",JSXEmptyExpression:"JSXEmptyExpression",JSXExpressionContainer:"JSXExpressionContainer",JSXIdentifier:"JSXIdentifier",JSXMemberExpression:"JSXMemberExpression",JSXNamespacedName:"JSXNamespacedName",JSXOpeningElement:"JSXOpeningElement",JSXSpreadAttribute:"JSXSpreadAttribute",JSXText:"JSXText"}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),i=function(e){this.type=r.Syntax.ArrayExpression,this.elements=e};t.ArrayExpression=i;var o=function(e){this.type=r.Syntax.ArrayPattern,this.elements=e};t.ArrayPattern=o;var a=function(e,t,n){this.type=r.Syntax.ArrowFunctionExpression,this.id=null,this.params=e,this.body=t,this.generator=!1,this.expression=n,this.async=!1};t.ArrowFunctionExpression=a;var s=function(e,t,n){this.type=r.Syntax.AssignmentExpression,this.operator=e,this.left=t,this.right=n};t.AssignmentExpression=s;var l=function(e,t){this.type=r.Syntax.AssignmentPattern,this.left=e,this.right=t};t.AssignmentPattern=l;var c=function(e,t,n){this.type=r.Syntax.ArrowFunctionExpression,this.id=null,this.params=e,this.body=t,this.generator=!1,this.expression=n,this.async=!0};t.AsyncArrowFunctionExpression=c;var u=function(e,t,n){this.type=r.Syntax.FunctionDeclaration,this.id=e,this.params=t,this.body=n,this.generator=!1,this.expression=!1,this.async=!0};t.AsyncFunctionDeclaration=u;var d=function(e,t,n){this.type=r.Syntax.FunctionExpression,this.id=e,this.params=t,this.body=n,this.generator=!1,this.expression=!1,this.async=!0};t.AsyncFunctionExpression=d;var h=function(e){this.type=r.Syntax.AwaitExpression,this.argument=e};t.AwaitExpression=h;var p=function(e,t,n){var i="||"===e||"&&"===e;this.type=i?r.Syntax.LogicalExpression:r.Syntax.BinaryExpression,this.operator=e,this.left=t,this.right=n};t.BinaryExpression=p;var f=function(e){this.type=r.Syntax.BlockStatement,this.body=e};t.BlockStatement=f;var m=function(e){this.type=r.Syntax.BreakStatement,this.label=e};t.BreakStatement=m;var g=function(e,t){this.type=r.Syntax.CallExpression,this.callee=e,this.arguments=t};t.CallExpression=g;var v=function(e,t){this.type=r.Syntax.CatchClause,this.param=e,this.body=t};t.CatchClause=v;var y=function(e){this.type=r.Syntax.ClassBody,this.body=e};t.ClassBody=y;var _=function(e,t,n){this.type=r.Syntax.ClassDeclaration,this.id=e,this.superClass=t,this.body=n};t.ClassDeclaration=_;var b=function(e,t,n){this.type=r.Syntax.ClassExpression,this.id=e,this.superClass=t,this.body=n};t.ClassExpression=b;var E=function(e,t){this.type=r.Syntax.MemberExpression,this.computed=!0,this.object=e,this.property=t};t.ComputedMemberExpression=E;var w=function(e,t,n){this.type=r.Syntax.ConditionalExpression,this.test=e,this.consequent=t,this.alternate=n};t.ConditionalExpression=w;var x=function(e){this.type=r.Syntax.ContinueStatement,this.label=e};t.ContinueStatement=x;var C=function(){this.type=r.Syntax.DebuggerStatement};t.DebuggerStatement=C;var D=function(e,t){this.type=r.Syntax.ExpressionStatement,this.expression=e,this.directive=t};t.Directive=D;var S=function(e,t){this.type=r.Syntax.DoWhileStatement,this.body=e,this.test=t};t.DoWhileStatement=S;var T=function(){this.type=r.Syntax.EmptyStatement};t.EmptyStatement=T;var I=function(e){this.type=r.Syntax.ExportAllDeclaration,this.source=e};t.ExportAllDeclaration=I;var A=function(e){this.type=r.Syntax.ExportDefaultDeclaration,this.declaration=e};t.ExportDefaultDeclaration=A;var N=function(e,t,n){this.type=r.Syntax.ExportNamedDeclaration,this.declaration=e,this.specifiers=t,this.source=n};t.ExportNamedDeclaration=N;var O=function(e,t){this.type=r.Syntax.ExportSpecifier,this.exported=t,this.local=e};t.ExportSpecifier=O;var P=function(e){this.type=r.Syntax.ExpressionStatement,this.expression=e};t.ExpressionStatement=P;var k=function(e,t,n){this.type=r.Syntax.ForInStatement,this.left=e,this.right=t,this.body=n,this.each=!1};t.ForInStatement=k;var M=function(e,t,n){this.type=r.Syntax.ForOfStatement,this.left=e,this.right=t,this.body=n};t.ForOfStatement=M;var L=function(e,t,n,i){this.type=r.Syntax.ForStatement,this.init=e,this.test=t,this.update=n,this.body=i};t.ForStatement=L;var R=function(e,t,n,i){this.type=r.Syntax.FunctionDeclaration,this.id=e,this.params=t,this.body=n,this.generator=i,this.expression=!1,this.async=!1};t.FunctionDeclaration=R;var F=function(e,t,n,i){this.type=r.Syntax.FunctionExpression,this.id=e,this.params=t,this.body=n,this.generator=i,this.expression=!1,this.async=!1};t.FunctionExpression=F;var U=function(e){this.type=r.Syntax.Identifier,this.name=e};t.Identifier=U;var B=function(e,t,n){this.type=r.Syntax.IfStatement,this.test=e,this.consequent=t,this.alternate=n};t.IfStatement=B;var j=function(e,t){this.type=r.Syntax.ImportDeclaration,this.specifiers=e,this.source=t};t.ImportDeclaration=j;var V=function(e){this.type=r.Syntax.ImportDefaultSpecifier,this.local=e};t.ImportDefaultSpecifier=V;var W=function(e){this.type=r.Syntax.ImportNamespaceSpecifier,this.local=e};t.ImportNamespaceSpecifier=W;var z=function(e,t){this.type=r.Syntax.ImportSpecifier,this.local=e,this.imported=t};t.ImportSpecifier=z;var G=function(e,t){this.type=r.Syntax.LabeledStatement,this.label=e,this.body=t};t.LabeledStatement=G;var H=function(e,t){this.type=r.Syntax.Literal,this.value=e,this.raw=t};t.Literal=H;var q=function(e,t){this.type=r.Syntax.MetaProperty,this.meta=e,this.property=t};t.MetaProperty=q;var K=function(e,t,n,i,o){this.type=r.Syntax.MethodDefinition,this.key=e,this.computed=t,this.value=n,this.kind=i,this.static=o};t.MethodDefinition=K;var X=function(e){this.type=r.Syntax.Program,this.body=e,this.sourceType="module"};t.Module=X;var $=function(e,t){this.type=r.Syntax.NewExpression,this.callee=e,this.arguments=t};t.NewExpression=$;var J=function(e){this.type=r.Syntax.ObjectExpression,this.properties=e};t.ObjectExpression=J;var Y=function(e){this.type=r.Syntax.ObjectPattern,this.properties=e};t.ObjectPattern=Y;var Z=function(e,t,n,i,o,a){this.type=r.Syntax.Property,this.key=t,this.computed=n,this.value=i,this.kind=e,this.method=o,this.shorthand=a};t.Property=Z;var Q=function(e,t,n,i){this.type=r.Syntax.Literal,this.value=e,this.raw=t,this.regex={pattern:n,flags:i}};t.RegexLiteral=Q;var ee=function(e){this.type=r.Syntax.RestElement,this.argument=e};t.RestElement=ee;var te=function(e){this.type=r.Syntax.ReturnStatement,this.argument=e};t.ReturnStatement=te;var ne=function(e){this.type=r.Syntax.Program,this.body=e,this.sourceType="script"};t.Script=ne;var re=function(e){this.type=r.Syntax.SequenceExpression,this.expressions=e};t.SequenceExpression=re;var ie=function(e){this.type=r.Syntax.SpreadElement,this.argument=e};t.SpreadElement=ie;var oe=function(e,t){this.type=r.Syntax.MemberExpression,this.computed=!1,this.object=e,this.property=t};t.StaticMemberExpression=oe;var ae=function(){this.type=r.Syntax.Super};t.Super=ae;var se=function(e,t){this.type=r.Syntax.SwitchCase,this.test=e,this.consequent=t};t.SwitchCase=se;var le=function(e,t){this.type=r.Syntax.SwitchStatement,this.discriminant=e,this.cases=t};t.SwitchStatement=le;var ce=function(e,t){this.type=r.Syntax.TaggedTemplateExpression,this.tag=e,this.quasi=t};t.TaggedTemplateExpression=ce;var ue=function(e,t){this.type=r.Syntax.TemplateElement,this.value=e,this.tail=t};t.TemplateElement=ue;var de=function(e,t){this.type=r.Syntax.TemplateLiteral,this.quasis=e,this.expressions=t};t.TemplateLiteral=de;var he=function(){this.type=r.Syntax.ThisExpression};t.ThisExpression=he;var pe=function(e){this.type=r.Syntax.ThrowStatement,this.argument=e};t.ThrowStatement=pe;var fe=function(e,t,n){this.type=r.Syntax.TryStatement,this.block=e,this.handler=t,this.finalizer=n};t.TryStatement=fe;var me=function(e,t){this.type=r.Syntax.UnaryExpression,this.operator=e,this.argument=t,this.prefix=!0};t.UnaryExpression=me;var ge=function(e,t,n){this.type=r.Syntax.UpdateExpression,this.operator=e,this.argument=t,this.prefix=n};t.UpdateExpression=ge;var ve=function(e,t){this.type=r.Syntax.VariableDeclaration,this.declarations=e,this.kind=t};t.VariableDeclaration=ve;var ye=function(e,t){this.type=r.Syntax.VariableDeclarator,this.id=e,this.init=t};t.VariableDeclarator=ye;var _e=function(e,t){this.type=r.Syntax.WhileStatement,this.test=e,this.body=t};t.WhileStatement=_e;var be=function(e,t){this.type=r.Syntax.WithStatement,this.object=e,this.body=t};t.WithStatement=be;var Ee=function(e,t){this.type=r.Syntax.YieldExpression,this.argument=e,this.delegate=t};t.YieldExpression=Ee},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9),i=n(10),o=n(11),a=n(7),s=n(12),l=n(2),c=n(13),u=function(){function e(e,t,n){void 0===t&&(t={}),this.config={range:"boolean"==typeof t.range&&t.range,loc:"boolean"==typeof t.loc&&t.loc,source:null,tokens:"boolean"==typeof t.tokens&&t.tokens,comment:"boolean"==typeof t.comment&&t.comment,tolerant:"boolean"==typeof t.tolerant&&t.tolerant},this.config.loc&&t.source&&null!==t.source&&(this.config.source=String(t.source)),this.delegate=n,this.errorHandler=new i.ErrorHandler,this.errorHandler.tolerant=this.config.tolerant,this.scanner=new s.Scanner(e,this.errorHandler),this.scanner.trackComment=this.config.comment,this.operatorPrecedence={")":0,";":0,",":0,"=":0,"]":0,"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":11,"/":11,"%":11},this.lookahead={type:2,value:"",lineNumber:this.scanner.lineNumber,lineStart:0,start:0,end:0},this.hasLineTerminator=!1,this.context={isModule:!1,await:!1,allowIn:!0,allowStrictDirective:!0,allowYield:!0,firstCoverInitializedNameError:null,isAssignmentTarget:!1,isBindingElement:!1,inFunctionBody:!1,inIteration:!1,inSwitch:!1,labelSet:{},strict:!1},this.tokens=[],this.startMarker={index:0,line:this.scanner.lineNumber,column:0},this.lastMarker={index:0,line:this.scanner.lineNumber,column:0},this.nextToken(),this.lastMarker={index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}}return e.prototype.throwError=function(e){for(var t=[],n=1;n0&&this.delegate)for(var t=0;t>="===e||">>>="===e||"&="===e||"^="===e||"|="===e},e.prototype.isolateCoverGrammar=function(e){var t=this.context.isBindingElement,n=this.context.isAssignmentTarget,r=this.context.firstCoverInitializedNameError;this.context.isBindingElement=!0,this.context.isAssignmentTarget=!0,this.context.firstCoverInitializedNameError=null;var i=e.call(this);return null!==this.context.firstCoverInitializedNameError&&this.throwUnexpectedToken(this.context.firstCoverInitializedNameError),this.context.isBindingElement=t,this.context.isAssignmentTarget=n,this.context.firstCoverInitializedNameError=r,i},e.prototype.inheritCoverGrammar=function(e){var t=this.context.isBindingElement,n=this.context.isAssignmentTarget,r=this.context.firstCoverInitializedNameError;this.context.isBindingElement=!0,this.context.isAssignmentTarget=!0,this.context.firstCoverInitializedNameError=null;var i=e.call(this);return this.context.isBindingElement=this.context.isBindingElement&&t,this.context.isAssignmentTarget=this.context.isAssignmentTarget&&n,this.context.firstCoverInitializedNameError=r||this.context.firstCoverInitializedNameError,i},e.prototype.consumeSemicolon=function(){this.match(";")?this.nextToken():this.hasLineTerminator||(2===this.lookahead.type||this.match("}")||this.throwUnexpectedToken(this.lookahead),this.lastMarker.index=this.startMarker.index,this.lastMarker.line=this.startMarker.line,this.lastMarker.column=this.startMarker.column)},e.prototype.parsePrimaryExpression=function(){var e,t,n,r=this.createNode();switch(this.lookahead.type){case 3:(this.context.isModule||this.context.await)&&"await"===this.lookahead.value&&this.tolerateUnexpectedToken(this.lookahead),e=this.matchAsyncFunction()?this.parseFunctionExpression():this.finalize(r,new a.Identifier(this.nextToken().value));break;case 6:case 8:this.context.strict&&this.lookahead.octal&&this.tolerateUnexpectedToken(this.lookahead,o.Messages.StrictOctalLiteral),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,t=this.nextToken(),n=this.getTokenRaw(t),e=this.finalize(r,new a.Literal(t.value,n));break;case 1:this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,t=this.nextToken(),n=this.getTokenRaw(t),e=this.finalize(r,new a.Literal("true"===t.value,n));break;case 5:this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,t=this.nextToken(),n=this.getTokenRaw(t),e=this.finalize(r,new a.Literal(null,n));break;case 10:e=this.parseTemplateLiteral();break;case 7:switch(this.lookahead.value){case"(":this.context.isBindingElement=!1,e=this.inheritCoverGrammar(this.parseGroupExpression);break;case"[":e=this.inheritCoverGrammar(this.parseArrayInitializer);break;case"{":e=this.inheritCoverGrammar(this.parseObjectInitializer);break;case"/":case"/=":this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,this.scanner.index=this.startMarker.index,t=this.nextRegexToken(),n=this.getTokenRaw(t),e=this.finalize(r,new a.RegexLiteral(t.regex,n,t.pattern,t.flags));break;default:e=this.throwUnexpectedToken(this.nextToken())}break;case 4:!this.context.strict&&this.context.allowYield&&this.matchKeyword("yield")?e=this.parseIdentifierName():!this.context.strict&&this.matchKeyword("let")?e=this.finalize(r,new a.Identifier(this.nextToken().value)):(this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,this.matchKeyword("function")?e=this.parseFunctionExpression():this.matchKeyword("this")?(this.nextToken(),e=this.finalize(r,new a.ThisExpression)):e=this.matchKeyword("class")?this.parseClassExpression():this.throwUnexpectedToken(this.nextToken()));break;default:e=this.throwUnexpectedToken(this.nextToken())}return e},e.prototype.parseSpreadElement=function(){var e=this.createNode();this.expect("...");var t=this.inheritCoverGrammar(this.parseAssignmentExpression);return this.finalize(e,new a.SpreadElement(t))},e.prototype.parseArrayInitializer=function(){var e=this.createNode(),t=[];for(this.expect("[");!this.match("]");)if(this.match(","))this.nextToken(),t.push(null);else if(this.match("...")){var n=this.parseSpreadElement();this.match("]")||(this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,this.expect(",")),t.push(n)}else t.push(this.inheritCoverGrammar(this.parseAssignmentExpression)),this.match("]")||this.expect(",");return this.expect("]"),this.finalize(e,new a.ArrayExpression(t))},e.prototype.parsePropertyMethod=function(e){this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1;var t=this.context.strict,n=this.context.allowStrictDirective;this.context.allowStrictDirective=e.simple;var r=this.isolateCoverGrammar(this.parseFunctionSourceElements);return this.context.strict&&e.firstRestricted&&this.tolerateUnexpectedToken(e.firstRestricted,e.message),this.context.strict&&e.stricted&&this.tolerateUnexpectedToken(e.stricted,e.message),this.context.strict=t,this.context.allowStrictDirective=n,r},e.prototype.parsePropertyMethodFunction=function(){var e=this.createNode(),t=this.context.allowYield;this.context.allowYield=!0;var n=this.parseFormalParameters(),r=this.parsePropertyMethod(n);return this.context.allowYield=t,this.finalize(e,new a.FunctionExpression(null,n.params,r,!1))},e.prototype.parsePropertyMethodAsyncFunction=function(){var e=this.createNode(),t=this.context.allowYield,n=this.context.await;this.context.allowYield=!1,this.context.await=!0;var r=this.parseFormalParameters(),i=this.parsePropertyMethod(r);return this.context.allowYield=t,this.context.await=n,this.finalize(e,new a.AsyncFunctionExpression(null,r.params,i))},e.prototype.parseObjectPropertyKey=function(){var e,t=this.createNode(),n=this.nextToken();switch(n.type){case 8:case 6:this.context.strict&&n.octal&&this.tolerateUnexpectedToken(n,o.Messages.StrictOctalLiteral);var r=this.getTokenRaw(n);e=this.finalize(t,new a.Literal(n.value,r));break;case 3:case 1:case 5:case 4:e=this.finalize(t,new a.Identifier(n.value));break;case 7:"["===n.value?(e=this.isolateCoverGrammar(this.parseAssignmentExpression),this.expect("]")):e=this.throwUnexpectedToken(n);break;default:e=this.throwUnexpectedToken(n)}return e},e.prototype.isPropertyKey=function(e,t){return e.type===l.Syntax.Identifier&&e.name===t||e.type===l.Syntax.Literal&&e.value===t},e.prototype.parseObjectProperty=function(e){var t,n=this.createNode(),r=this.lookahead,i=null,s=null,l=!1,c=!1,u=!1,d=!1;if(3===r.type){var h=r.value;this.nextToken(),l=this.match("["),i=(d=!(this.hasLineTerminator||"async"!==h||this.match(":")||this.match("(")||this.match("*")||this.match(",")))?this.parseObjectPropertyKey():this.finalize(n,new a.Identifier(h))}else this.match("*")?this.nextToken():(l=this.match("["),i=this.parseObjectPropertyKey());var p=this.qualifiedPropertyName(this.lookahead);if(3===r.type&&!d&&"get"===r.value&&p)t="get",l=this.match("["),i=this.parseObjectPropertyKey(),this.context.allowYield=!1,s=this.parseGetterMethod();else if(3===r.type&&!d&&"set"===r.value&&p)t="set",l=this.match("["),i=this.parseObjectPropertyKey(),s=this.parseSetterMethod();else if(7===r.type&&"*"===r.value&&p)t="init",l=this.match("["),i=this.parseObjectPropertyKey(),s=this.parseGeneratorMethod(),c=!0;else if(i||this.throwUnexpectedToken(this.lookahead),t="init",this.match(":")&&!d)!l&&this.isPropertyKey(i,"__proto__")&&(e.value&&this.tolerateError(o.Messages.DuplicateProtoProperty),e.value=!0),this.nextToken(),s=this.inheritCoverGrammar(this.parseAssignmentExpression);else if(this.match("("))s=d?this.parsePropertyMethodAsyncFunction():this.parsePropertyMethodFunction(),c=!0;else if(3===r.type)if(h=this.finalize(n,new a.Identifier(r.value)),this.match("=")){this.context.firstCoverInitializedNameError=this.lookahead,this.nextToken(),u=!0;var f=this.isolateCoverGrammar(this.parseAssignmentExpression);s=this.finalize(n,new a.AssignmentPattern(h,f))}else u=!0,s=h;else this.throwUnexpectedToken(this.nextToken());return this.finalize(n,new a.Property(t,i,l,s,c,u))},e.prototype.parseObjectInitializer=function(){var e=this.createNode();this.expect("{");for(var t=[],n={value:!1};!this.match("}");)t.push(this.parseObjectProperty(n)),this.match("}")||this.expectCommaSeparator();return this.expect("}"),this.finalize(e,new a.ObjectExpression(t))},e.prototype.parseTemplateHead=function(){r.assert(this.lookahead.head,"Template literal must start with a template head");var e=this.createNode(),t=this.nextToken(),n=t.value,i=t.cooked;return this.finalize(e,new a.TemplateElement({raw:n,cooked:i},t.tail))},e.prototype.parseTemplateElement=function(){10!==this.lookahead.type&&this.throwUnexpectedToken();var e=this.createNode(),t=this.nextToken(),n=t.value,r=t.cooked;return this.finalize(e,new a.TemplateElement({raw:n,cooked:r},t.tail))},e.prototype.parseTemplateLiteral=function(){var e=this.createNode(),t=[],n=[],r=this.parseTemplateHead();for(n.push(r);!r.tail;)t.push(this.parseExpression()),r=this.parseTemplateElement(),n.push(r);return this.finalize(e,new a.TemplateLiteral(n,t))},e.prototype.reinterpretExpressionAsPattern=function(e){switch(e.type){case l.Syntax.Identifier:case l.Syntax.MemberExpression:case l.Syntax.RestElement:case l.Syntax.AssignmentPattern:break;case l.Syntax.SpreadElement:e.type=l.Syntax.RestElement,this.reinterpretExpressionAsPattern(e.argument);break;case l.Syntax.ArrayExpression:e.type=l.Syntax.ArrayPattern;for(var t=0;t")||this.expect("=>"),e={type:"ArrowParameterPlaceHolder",params:[],async:!1};else{var t=this.lookahead,n=[];if(this.match("..."))e=this.parseRestElement(n),this.expect(")"),this.match("=>")||this.expect("=>"),e={type:"ArrowParameterPlaceHolder",params:[e],async:!1};else{var r=!1;if(this.context.isBindingElement=!0,e=this.inheritCoverGrammar(this.parseAssignmentExpression),this.match(",")){var i=[];for(this.context.isAssignmentTarget=!1,i.push(e);2!==this.lookahead.type&&this.match(",");){if(this.nextToken(),this.match(")")){this.nextToken();for(var o=0;o")||this.expect("=>"),this.context.isBindingElement=!1,o=0;o")&&(e.type===l.Syntax.Identifier&&"yield"===e.name&&(r=!0,e={type:"ArrowParameterPlaceHolder",params:[e],async:!1}),!r)){if(this.context.isBindingElement||this.throwUnexpectedToken(this.lookahead),e.type===l.Syntax.SequenceExpression)for(o=0;o")){for(var l=0;l0){this.nextToken(),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1;for(var i=[e,this.lookahead],o=t,s=this.isolateCoverGrammar(this.parseExponentiationExpression),l=[o,n.value,s],c=[r];!((r=this.binaryPrecedence(this.lookahead))<=0);){for(;l.length>2&&r<=c[c.length-1];){s=l.pop();var u=l.pop();c.pop(),o=l.pop(),i.pop();var d=this.startNode(i[i.length-1]);l.push(this.finalize(d,new a.BinaryExpression(u,o,s)))}l.push(this.nextToken().value),c.push(r),i.push(this.lookahead),l.push(this.isolateCoverGrammar(this.parseExponentiationExpression))}var h=l.length-1;t=l[h];for(var p=i.pop();h>1;){var f=i.pop(),m=p&&p.lineStart;d=this.startNode(f,m),u=l[h-1],t=this.finalize(d,new a.BinaryExpression(u,l[h-2],t)),h-=2,p=f}}return t},e.prototype.parseConditionalExpression=function(){var e=this.lookahead,t=this.inheritCoverGrammar(this.parseBinaryExpression);if(this.match("?")){this.nextToken();var n=this.context.allowIn;this.context.allowIn=!0;var r=this.isolateCoverGrammar(this.parseAssignmentExpression);this.context.allowIn=n,this.expect(":");var i=this.isolateCoverGrammar(this.parseAssignmentExpression);t=this.finalize(this.startNode(e),new a.ConditionalExpression(t,r,i)),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1}return t},e.prototype.checkPatternParam=function(e,t){switch(t.type){case l.Syntax.Identifier:this.validateParam(e,t,t.name);break;case l.Syntax.RestElement:this.checkPatternParam(e,t.argument);break;case l.Syntax.AssignmentPattern:this.checkPatternParam(e,t.left);break;case l.Syntax.ArrayPattern:for(var n=0;n")){this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1;var i=e.async,s=this.reinterpretAsCoverFormalsList(e);if(s){this.hasLineTerminator&&this.tolerateUnexpectedToken(this.lookahead),this.context.firstCoverInitializedNameError=null;var c=this.context.strict,u=this.context.allowStrictDirective;this.context.allowStrictDirective=s.simple;var d=this.context.allowYield,h=this.context.await;this.context.allowYield=!0,this.context.await=i;var p=this.startNode(t);this.expect("=>");var f=void 0;if(this.match("{")){var m=this.context.allowIn;this.context.allowIn=!0,f=this.parseFunctionSourceElements(),this.context.allowIn=m}else f=this.isolateCoverGrammar(this.parseAssignmentExpression);var g=f.type!==l.Syntax.BlockStatement;this.context.strict&&s.firstRestricted&&this.throwUnexpectedToken(s.firstRestricted,s.message),this.context.strict&&s.stricted&&this.tolerateUnexpectedToken(s.stricted,s.message),e=i?this.finalize(p,new a.AsyncArrowFunctionExpression(s.params,f,g)):this.finalize(p,new a.ArrowFunctionExpression(s.params,f,g)),this.context.strict=c,this.context.allowStrictDirective=u,this.context.allowYield=d,this.context.await=h}}else if(this.matchAssign()){if(this.context.isAssignmentTarget||this.tolerateError(o.Messages.InvalidLHSInAssignment),this.context.strict&&e.type===l.Syntax.Identifier){var v=e;this.scanner.isRestrictedWord(v.name)&&this.tolerateUnexpectedToken(n,o.Messages.StrictLHSAssignment),this.scanner.isStrictModeReservedWord(v.name)&&this.tolerateUnexpectedToken(n,o.Messages.StrictReservedWord)}this.match("=")?this.reinterpretExpressionAsPattern(e):(this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1);var y=(n=this.nextToken()).value,_=this.isolateCoverGrammar(this.parseAssignmentExpression);e=this.finalize(this.startNode(t),new a.AssignmentExpression(y,e,_)),this.context.firstCoverInitializedNameError=null}}return e},e.prototype.parseExpression=function(){var e=this.lookahead,t=this.isolateCoverGrammar(this.parseAssignmentExpression);if(this.match(",")){var n=[];for(n.push(t);2!==this.lookahead.type&&this.match(",");)this.nextToken(),n.push(this.isolateCoverGrammar(this.parseAssignmentExpression));t=this.finalize(this.startNode(e),new a.SequenceExpression(n))}return t},e.prototype.parseStatementListItem=function(){var e;if(this.context.isAssignmentTarget=!0,this.context.isBindingElement=!0,4===this.lookahead.type)switch(this.lookahead.value){case"export":this.context.isModule||this.tolerateUnexpectedToken(this.lookahead,o.Messages.IllegalExportDeclaration),e=this.parseExportDeclaration();break;case"import":this.context.isModule||this.tolerateUnexpectedToken(this.lookahead,o.Messages.IllegalImportDeclaration),e=this.parseImportDeclaration();break;case"const":e=this.parseLexicalDeclaration({inFor:!1});break;case"function":e=this.parseFunctionDeclaration();break;case"class":e=this.parseClassDeclaration();break;case"let":e=this.isLexicalDeclaration()?this.parseLexicalDeclaration({inFor:!1}):this.parseStatement();break;default:e=this.parseStatement()}else e=this.parseStatement();return e},e.prototype.parseBlock=function(){var e=this.createNode();this.expect("{");for(var t=[];!this.match("}");)t.push(this.parseStatementListItem());return this.expect("}"),this.finalize(e,new a.BlockStatement(t))},e.prototype.parseLexicalBinding=function(e,t){var n=this.createNode(),r=this.parsePattern([],e);this.context.strict&&r.type===l.Syntax.Identifier&&this.scanner.isRestrictedWord(r.name)&&this.tolerateError(o.Messages.StrictVarName);var i=null;return"const"===e?this.matchKeyword("in")||this.matchContextualKeyword("of")||(this.match("=")?(this.nextToken(),i=this.isolateCoverGrammar(this.parseAssignmentExpression)):this.throwError(o.Messages.DeclarationMissingInitializer,"const")):(!t.inFor&&r.type!==l.Syntax.Identifier||this.match("="))&&(this.expect("="),i=this.isolateCoverGrammar(this.parseAssignmentExpression)),this.finalize(n,new a.VariableDeclarator(r,i))},e.prototype.parseBindingList=function(e,t){for(var n=[this.parseLexicalBinding(e,t)];this.match(",");)this.nextToken(),n.push(this.parseLexicalBinding(e,t));return n},e.prototype.isLexicalDeclaration=function(){var e=this.scanner.saveState();this.scanner.scanComments();var t=this.scanner.lex();return this.scanner.restoreState(e),3===t.type||7===t.type&&"["===t.value||7===t.type&&"{"===t.value||4===t.type&&"let"===t.value||4===t.type&&"yield"===t.value},e.prototype.parseLexicalDeclaration=function(e){var t=this.createNode(),n=this.nextToken().value;r.assert("let"===n||"const"===n,"Lexical declaration must be either let or const");var i=this.parseBindingList(n,e);return this.consumeSemicolon(),this.finalize(t,new a.VariableDeclaration(i,n))},e.prototype.parseBindingRestElement=function(e,t){var n=this.createNode();this.expect("...");var r=this.parsePattern(e,t);return this.finalize(n,new a.RestElement(r))},e.prototype.parseArrayPattern=function(e,t){var n=this.createNode();this.expect("[");for(var r=[];!this.match("]");)if(this.match(","))this.nextToken(),r.push(null);else{if(this.match("...")){r.push(this.parseBindingRestElement(e,t));break}r.push(this.parsePatternWithDefault(e,t)),this.match("]")||this.expect(",")}return this.expect("]"),this.finalize(n,new a.ArrayPattern(r))},e.prototype.parsePropertyPattern=function(e,t){var n,r,i=this.createNode(),o=!1,s=!1;if(3===this.lookahead.type){var l=this.lookahead;n=this.parseVariableIdentifier();var c=this.finalize(i,new a.Identifier(l.value));if(this.match("=")){e.push(l),s=!0,this.nextToken();var u=this.parseAssignmentExpression();r=this.finalize(this.startNode(l),new a.AssignmentPattern(c,u))}else this.match(":")?(this.expect(":"),r=this.parsePatternWithDefault(e,t)):(e.push(l),s=!0,r=c)}else o=this.match("["),n=this.parseObjectPropertyKey(),this.expect(":"),r=this.parsePatternWithDefault(e,t);return this.finalize(i,new a.Property("init",n,o,r,!1,s))},e.prototype.parseObjectPattern=function(e,t){var n=this.createNode(),r=[];for(this.expect("{");!this.match("}");)r.push(this.parsePropertyPattern(e,t)),this.match("}")||this.expect(",");return this.expect("}"),this.finalize(n,new a.ObjectPattern(r))},e.prototype.parsePattern=function(e,t){var n;return this.match("[")?n=this.parseArrayPattern(e,t):this.match("{")?n=this.parseObjectPattern(e,t):(!this.matchKeyword("let")||"const"!==t&&"let"!==t||this.tolerateUnexpectedToken(this.lookahead,o.Messages.LetInLexicalBinding),e.push(this.lookahead),n=this.parseVariableIdentifier(t)),n},e.prototype.parsePatternWithDefault=function(e,t){var n=this.lookahead,r=this.parsePattern(e,t);if(this.match("=")){this.nextToken();var i=this.context.allowYield;this.context.allowYield=!0;var o=this.isolateCoverGrammar(this.parseAssignmentExpression);this.context.allowYield=i,r=this.finalize(this.startNode(n),new a.AssignmentPattern(r,o))}return r},e.prototype.parseVariableIdentifier=function(e){var t=this.createNode(),n=this.nextToken();return 4===n.type&&"yield"===n.value?this.context.strict?this.tolerateUnexpectedToken(n,o.Messages.StrictReservedWord):this.context.allowYield||this.throwUnexpectedToken(n):3!==n.type?this.context.strict&&4===n.type&&this.scanner.isStrictModeReservedWord(n.value)?this.tolerateUnexpectedToken(n,o.Messages.StrictReservedWord):(this.context.strict||"let"!==n.value||"var"!==e)&&this.throwUnexpectedToken(n):(this.context.isModule||this.context.await)&&3===n.type&&"await"===n.value&&this.tolerateUnexpectedToken(n),this.finalize(t,new a.Identifier(n.value))},e.prototype.parseVariableDeclaration=function(e){var t=this.createNode(),n=this.parsePattern([],"var");this.context.strict&&n.type===l.Syntax.Identifier&&this.scanner.isRestrictedWord(n.name)&&this.tolerateError(o.Messages.StrictVarName);var r=null;return this.match("=")?(this.nextToken(),r=this.isolateCoverGrammar(this.parseAssignmentExpression)):n.type===l.Syntax.Identifier||e.inFor||this.expect("="),this.finalize(t,new a.VariableDeclarator(n,r))},e.prototype.parseVariableDeclarationList=function(e){var t={inFor:e.inFor},n=[];for(n.push(this.parseVariableDeclaration(t));this.match(",");)this.nextToken(),n.push(this.parseVariableDeclaration(t));return n},e.prototype.parseVariableStatement=function(){var e=this.createNode();this.expectKeyword("var");var t=this.parseVariableDeclarationList({inFor:!1});return this.consumeSemicolon(),this.finalize(e,new a.VariableDeclaration(t,"var"))},e.prototype.parseEmptyStatement=function(){var e=this.createNode();return this.expect(";"),this.finalize(e,new a.EmptyStatement)},e.prototype.parseExpressionStatement=function(){var e=this.createNode(),t=this.parseExpression();return this.consumeSemicolon(),this.finalize(e,new a.ExpressionStatement(t))},e.prototype.parseIfClause=function(){return this.context.strict&&this.matchKeyword("function")&&this.tolerateError(o.Messages.StrictFunction),this.parseStatement()},e.prototype.parseIfStatement=function(){var e,t=this.createNode(),n=null;this.expectKeyword("if"),this.expect("(");var r=this.parseExpression();return!this.match(")")&&this.config.tolerant?(this.tolerateUnexpectedToken(this.nextToken()),e=this.finalize(this.createNode(),new a.EmptyStatement)):(this.expect(")"),e=this.parseIfClause(),this.matchKeyword("else")&&(this.nextToken(),n=this.parseIfClause())),this.finalize(t,new a.IfStatement(r,e,n))},e.prototype.parseDoWhileStatement=function(){var e=this.createNode();this.expectKeyword("do");var t=this.context.inIteration;this.context.inIteration=!0;var n=this.parseStatement();this.context.inIteration=t,this.expectKeyword("while"),this.expect("(");var r=this.parseExpression();return!this.match(")")&&this.config.tolerant?this.tolerateUnexpectedToken(this.nextToken()):(this.expect(")"),this.match(";")&&this.nextToken()),this.finalize(e,new a.DoWhileStatement(n,r))},e.prototype.parseWhileStatement=function(){var e,t=this.createNode();this.expectKeyword("while"),this.expect("(");var n=this.parseExpression();if(!this.match(")")&&this.config.tolerant)this.tolerateUnexpectedToken(this.nextToken()),e=this.finalize(this.createNode(),new a.EmptyStatement);else{this.expect(")");var r=this.context.inIteration;this.context.inIteration=!0,e=this.parseStatement(),this.context.inIteration=r}return this.finalize(t,new a.WhileStatement(n,e))},e.prototype.parseForStatement=function(){var e,t,n,r=null,i=null,s=null,c=!0,u=this.createNode();if(this.expectKeyword("for"),this.expect("("),this.match(";"))this.nextToken();else if(this.matchKeyword("var")){r=this.createNode(),this.nextToken();var d=this.context.allowIn;this.context.allowIn=!1;var h=this.parseVariableDeclarationList({inFor:!0});if(this.context.allowIn=d,1===h.length&&this.matchKeyword("in")){var p=h[0];p.init&&(p.id.type===l.Syntax.ArrayPattern||p.id.type===l.Syntax.ObjectPattern||this.context.strict)&&this.tolerateError(o.Messages.ForInOfLoopInitializer,"for-in"),r=this.finalize(r,new a.VariableDeclaration(h,"var")),this.nextToken(),e=r,t=this.parseExpression(),r=null}else 1===h.length&&null===h[0].init&&this.matchContextualKeyword("of")?(r=this.finalize(r,new a.VariableDeclaration(h,"var")),this.nextToken(),e=r,t=this.parseAssignmentExpression(),r=null,c=!1):(r=this.finalize(r,new a.VariableDeclaration(h,"var")),this.expect(";"))}else if(this.matchKeyword("const")||this.matchKeyword("let")){r=this.createNode();var f=this.nextToken().value;this.context.strict||"in"!==this.lookahead.value?(d=this.context.allowIn,this.context.allowIn=!1,h=this.parseBindingList(f,{inFor:!0}),this.context.allowIn=d,1===h.length&&null===h[0].init&&this.matchKeyword("in")?(r=this.finalize(r,new a.VariableDeclaration(h,f)),this.nextToken(),e=r,t=this.parseExpression(),r=null):1===h.length&&null===h[0].init&&this.matchContextualKeyword("of")?(r=this.finalize(r,new a.VariableDeclaration(h,f)),this.nextToken(),e=r,t=this.parseAssignmentExpression(),r=null,c=!1):(this.consumeSemicolon(),r=this.finalize(r,new a.VariableDeclaration(h,f)))):(r=this.finalize(r,new a.Identifier(f)),this.nextToken(),e=r,t=this.parseExpression(),r=null)}else{var m=this.lookahead;if(d=this.context.allowIn,this.context.allowIn=!1,r=this.inheritCoverGrammar(this.parseAssignmentExpression),this.context.allowIn=d,this.matchKeyword("in"))this.context.isAssignmentTarget&&r.type!==l.Syntax.AssignmentExpression||this.tolerateError(o.Messages.InvalidLHSInForIn),this.nextToken(),this.reinterpretExpressionAsPattern(r),e=r,t=this.parseExpression(),r=null;else if(this.matchContextualKeyword("of"))this.context.isAssignmentTarget&&r.type!==l.Syntax.AssignmentExpression||this.tolerateError(o.Messages.InvalidLHSInForLoop),this.nextToken(),this.reinterpretExpressionAsPattern(r),e=r,t=this.parseAssignmentExpression(),r=null,c=!1;else{if(this.match(",")){for(var g=[r];this.match(",");)this.nextToken(),g.push(this.isolateCoverGrammar(this.parseAssignmentExpression));r=this.finalize(this.startNode(m),new a.SequenceExpression(g))}this.expect(";")}}if(void 0===e&&(this.match(";")||(i=this.parseExpression()),this.expect(";"),this.match(")")||(s=this.parseExpression())),!this.match(")")&&this.config.tolerant)this.tolerateUnexpectedToken(this.nextToken()),n=this.finalize(this.createNode(),new a.EmptyStatement);else{this.expect(")");var v=this.context.inIteration;this.context.inIteration=!0,n=this.isolateCoverGrammar(this.parseStatement),this.context.inIteration=v}return void 0===e?this.finalize(u,new a.ForStatement(r,i,s,n)):c?this.finalize(u,new a.ForInStatement(e,t,n)):this.finalize(u,new a.ForOfStatement(e,t,n))},e.prototype.parseContinueStatement=function(){var e=this.createNode();this.expectKeyword("continue");var t=null;if(3===this.lookahead.type&&!this.hasLineTerminator){var n=this.parseVariableIdentifier();t=n;var r="$"+n.name;Object.prototype.hasOwnProperty.call(this.context.labelSet,r)||this.throwError(o.Messages.UnknownLabel,n.name)}return this.consumeSemicolon(),null!==t||this.context.inIteration||this.throwError(o.Messages.IllegalContinue),this.finalize(e,new a.ContinueStatement(t))},e.prototype.parseBreakStatement=function(){var e=this.createNode();this.expectKeyword("break");var t=null;if(3===this.lookahead.type&&!this.hasLineTerminator){var n=this.parseVariableIdentifier(),r="$"+n.name;Object.prototype.hasOwnProperty.call(this.context.labelSet,r)||this.throwError(o.Messages.UnknownLabel,n.name),t=n}return this.consumeSemicolon(),null!==t||this.context.inIteration||this.context.inSwitch||this.throwError(o.Messages.IllegalBreak),this.finalize(e,new a.BreakStatement(t))},e.prototype.parseReturnStatement=function(){this.context.inFunctionBody||this.tolerateError(o.Messages.IllegalReturn);var e=this.createNode();this.expectKeyword("return");var t=(this.match(";")||this.match("}")||this.hasLineTerminator||2===this.lookahead.type)&&8!==this.lookahead.type&&10!==this.lookahead.type?null:this.parseExpression();return this.consumeSemicolon(),this.finalize(e,new a.ReturnStatement(t))},e.prototype.parseWithStatement=function(){this.context.strict&&this.tolerateError(o.Messages.StrictModeWith);var e,t=this.createNode();this.expectKeyword("with"),this.expect("(");var n=this.parseExpression();return!this.match(")")&&this.config.tolerant?(this.tolerateUnexpectedToken(this.nextToken()),e=this.finalize(this.createNode(),new a.EmptyStatement)):(this.expect(")"),e=this.parseStatement()),this.finalize(t,new a.WithStatement(n,e))},e.prototype.parseSwitchCase=function(){var e,t=this.createNode();this.matchKeyword("default")?(this.nextToken(),e=null):(this.expectKeyword("case"),e=this.parseExpression()),this.expect(":");for(var n=[];!(this.match("}")||this.matchKeyword("default")||this.matchKeyword("case"));)n.push(this.parseStatementListItem());return this.finalize(t,new a.SwitchCase(e,n))},e.prototype.parseSwitchStatement=function(){var e=this.createNode();this.expectKeyword("switch"),this.expect("(");var t=this.parseExpression();this.expect(")");var n=this.context.inSwitch;this.context.inSwitch=!0;var r=[],i=!1;for(this.expect("{");!this.match("}");){var s=this.parseSwitchCase();null===s.test&&(i&&this.throwError(o.Messages.MultipleDefaultsInSwitch),i=!0),r.push(s)}return this.expect("}"),this.context.inSwitch=n,this.finalize(e,new a.SwitchStatement(t,r))},e.prototype.parseLabelledStatement=function(){var e,t=this.createNode(),n=this.parseExpression();if(n.type===l.Syntax.Identifier&&this.match(":")){this.nextToken();var r=n,i="$"+r.name;Object.prototype.hasOwnProperty.call(this.context.labelSet,i)&&this.throwError(o.Messages.Redeclaration,"Label",r.name),this.context.labelSet[i]=!0;var s=void 0;if(this.matchKeyword("class"))this.tolerateUnexpectedToken(this.lookahead),s=this.parseClassDeclaration();else if(this.matchKeyword("function")){var c=this.lookahead,u=this.parseFunctionDeclaration();this.context.strict?this.tolerateUnexpectedToken(c,o.Messages.StrictFunction):u.generator&&this.tolerateUnexpectedToken(c,o.Messages.GeneratorInLegacyContext),s=u}else s=this.parseStatement();delete this.context.labelSet[i],e=new a.LabeledStatement(r,s)}else this.consumeSemicolon(),e=new a.ExpressionStatement(n);return this.finalize(t,e)},e.prototype.parseThrowStatement=function(){var e=this.createNode();this.expectKeyword("throw"),this.hasLineTerminator&&this.throwError(o.Messages.NewlineAfterThrow);var t=this.parseExpression();return this.consumeSemicolon(),this.finalize(e,new a.ThrowStatement(t))},e.prototype.parseCatchClause=function(){var e=this.createNode();this.expectKeyword("catch"),this.expect("("),this.match(")")&&this.throwUnexpectedToken(this.lookahead);for(var t=[],n=this.parsePattern(t),r={},i=0;i0&&this.tolerateError(o.Messages.BadGetterArity);var r=this.parsePropertyMethod(n);return this.context.allowYield=t,this.finalize(e,new a.FunctionExpression(null,n.params,r,!1))},e.prototype.parseSetterMethod=function(){var e=this.createNode(),t=this.context.allowYield;this.context.allowYield=!0;var n=this.parseFormalParameters();1!==n.params.length?this.tolerateError(o.Messages.BadSetterArity):n.params[0]instanceof a.RestElement&&this.tolerateError(o.Messages.BadSetterRestParameter);var r=this.parsePropertyMethod(n);return this.context.allowYield=t,this.finalize(e,new a.FunctionExpression(null,n.params,r,!1))},e.prototype.parseGeneratorMethod=function(){var e=this.createNode(),t=this.context.allowYield;this.context.allowYield=!0;var n=this.parseFormalParameters();this.context.allowYield=!1;var r=this.parsePropertyMethod(n);return this.context.allowYield=t,this.finalize(e,new a.FunctionExpression(null,n.params,r,!0))},e.prototype.isStartOfExpression=function(){var e=!0,t=this.lookahead.value;switch(this.lookahead.type){case 7:e="["===t||"("===t||"{"===t||"+"===t||"-"===t||"!"===t||"~"===t||"++"===t||"--"===t||"/"===t||"/="===t;break;case 4:e="class"===t||"delete"===t||"function"===t||"let"===t||"new"===t||"super"===t||"this"===t||"typeof"===t||"void"===t||"yield"===t}return e},e.prototype.parseYieldExpression=function(){var e=this.createNode();this.expectKeyword("yield");var t=null,n=!1;if(!this.hasLineTerminator){var r=this.context.allowYield;this.context.allowYield=!1,(n=this.match("*"))?(this.nextToken(),t=this.parseAssignmentExpression()):this.isStartOfExpression()&&(t=this.parseAssignmentExpression()),this.context.allowYield=r}return this.finalize(e,new a.YieldExpression(t,n))},e.prototype.parseClassElement=function(e){var t=this.lookahead,n=this.createNode(),r="",i=null,s=null,l=!1,c=!1,u=!1,d=!1;if(this.match("*"))this.nextToken();else if(l=this.match("["),"static"===(i=this.parseObjectPropertyKey()).name&&(this.qualifiedPropertyName(this.lookahead)||this.match("*"))&&(t=this.lookahead,u=!0,l=this.match("["),this.match("*")?this.nextToken():i=this.parseObjectPropertyKey()),3===t.type&&!this.hasLineTerminator&&"async"===t.value){var h=this.lookahead.value;":"!==h&&"("!==h&&"*"!==h&&(d=!0,t=this.lookahead,i=this.parseObjectPropertyKey(),3===t.type&&"constructor"===t.value&&this.tolerateUnexpectedToken(t,o.Messages.ConstructorIsAsync))}var p=this.qualifiedPropertyName(this.lookahead);return 3===t.type?"get"===t.value&&p?(r="get",l=this.match("["),i=this.parseObjectPropertyKey(),this.context.allowYield=!1,s=this.parseGetterMethod()):"set"===t.value&&p&&(r="set",l=this.match("["),i=this.parseObjectPropertyKey(),s=this.parseSetterMethod()):7===t.type&&"*"===t.value&&p&&(r="init",l=this.match("["),i=this.parseObjectPropertyKey(),s=this.parseGeneratorMethod(),c=!0),!r&&i&&this.match("(")&&(r="init",s=d?this.parsePropertyMethodAsyncFunction():this.parsePropertyMethodFunction(),c=!0),r||this.throwUnexpectedToken(this.lookahead),"init"===r&&(r="method"),l||(u&&this.isPropertyKey(i,"prototype")&&this.throwUnexpectedToken(t,o.Messages.StaticPrototype),!u&&this.isPropertyKey(i,"constructor")&&(("method"!==r||!c||s&&s.generator)&&this.throwUnexpectedToken(t,o.Messages.ConstructorSpecialMethod),e.value?this.throwUnexpectedToken(t,o.Messages.DuplicateConstructor):e.value=!0,r="constructor")),this.finalize(n,new a.MethodDefinition(i,l,s,r,u))},e.prototype.parseClassElementList=function(){var e=[],t={value:!1};for(this.expect("{");!this.match("}");)this.match(";")?this.nextToken():e.push(this.parseClassElement(t));return this.expect("}"),e},e.prototype.parseClassBody=function(){var e=this.createNode(),t=this.parseClassElementList();return this.finalize(e,new a.ClassBody(t))},e.prototype.parseClassDeclaration=function(e){var t=this.createNode(),n=this.context.strict;this.context.strict=!0,this.expectKeyword("class");var r=e&&3!==this.lookahead.type?null:this.parseVariableIdentifier(),i=null;this.matchKeyword("extends")&&(this.nextToken(),i=this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall));var o=this.parseClassBody();return this.context.strict=n,this.finalize(t,new a.ClassDeclaration(r,i,o))},e.prototype.parseClassExpression=function(){var e=this.createNode(),t=this.context.strict;this.context.strict=!0,this.expectKeyword("class");var n=3===this.lookahead.type?this.parseVariableIdentifier():null,r=null;this.matchKeyword("extends")&&(this.nextToken(),r=this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall));var i=this.parseClassBody();return this.context.strict=t,this.finalize(e,new a.ClassExpression(n,r,i))},e.prototype.parseModule=function(){this.context.strict=!0,this.context.isModule=!0,this.scanner.isModule=!0;for(var e=this.createNode(),t=this.parseDirectivePrologues();2!==this.lookahead.type;)t.push(this.parseStatementListItem());return this.finalize(e,new a.Module(t))},e.prototype.parseScript=function(){for(var e=this.createNode(),t=this.parseDirectivePrologues();2!==this.lookahead.type;)t.push(this.parseStatementListItem());return this.finalize(e,new a.Script(t))},e.prototype.parseModuleSpecifier=function(){var e=this.createNode();8!==this.lookahead.type&&this.throwError(o.Messages.InvalidModuleSpecifier);var t=this.nextToken(),n=this.getTokenRaw(t);return this.finalize(e,new a.Literal(t.value,n))},e.prototype.parseImportSpecifier=function(){var e,t,n=this.createNode();return 3===this.lookahead.type?(t=e=this.parseVariableIdentifier(),this.matchContextualKeyword("as")&&(this.nextToken(),t=this.parseVariableIdentifier())):(t=e=this.parseIdentifierName(),this.matchContextualKeyword("as")?(this.nextToken(),t=this.parseVariableIdentifier()):this.throwUnexpectedToken(this.nextToken())),this.finalize(n,new a.ImportSpecifier(t,e))},e.prototype.parseNamedImports=function(){this.expect("{");for(var e=[];!this.match("}");)e.push(this.parseImportSpecifier()),this.match("}")||this.expect(",");return this.expect("}"),e},e.prototype.parseImportDefaultSpecifier=function(){var e=this.createNode(),t=this.parseIdentifierName();return this.finalize(e,new a.ImportDefaultSpecifier(t))},e.prototype.parseImportNamespaceSpecifier=function(){var e=this.createNode();this.expect("*"),this.matchContextualKeyword("as")||this.throwError(o.Messages.NoAsAfterImportNamespace),this.nextToken();var t=this.parseIdentifierName();return this.finalize(e,new a.ImportNamespaceSpecifier(t))},e.prototype.parseImportDeclaration=function(){this.context.inFunctionBody&&this.throwError(o.Messages.IllegalImportDeclaration);var e,t=this.createNode();this.expectKeyword("import");var n=[];if(8===this.lookahead.type)e=this.parseModuleSpecifier();else{if(this.match("{")?n=n.concat(this.parseNamedImports()):this.match("*")?n.push(this.parseImportNamespaceSpecifier()):this.isIdentifierName(this.lookahead)&&!this.matchKeyword("default")?(n.push(this.parseImportDefaultSpecifier()),this.match(",")&&(this.nextToken(),this.match("*")?n.push(this.parseImportNamespaceSpecifier()):this.match("{")?n=n.concat(this.parseNamedImports()):this.throwUnexpectedToken(this.lookahead))):this.throwUnexpectedToken(this.nextToken()),!this.matchContextualKeyword("from")){var r=this.lookahead.value?o.Messages.UnexpectedToken:o.Messages.MissingFromClause;this.throwError(r,this.lookahead.value)}this.nextToken(),e=this.parseModuleSpecifier()}return this.consumeSemicolon(),this.finalize(t,new a.ImportDeclaration(n,e))},e.prototype.parseExportSpecifier=function(){var e=this.createNode(),t=this.parseIdentifierName(),n=t;return this.matchContextualKeyword("as")&&(this.nextToken(),n=this.parseIdentifierName()),this.finalize(e,new a.ExportSpecifier(t,n))},e.prototype.parseExportDeclaration=function(){this.context.inFunctionBody&&this.throwError(o.Messages.IllegalExportDeclaration);var e,t=this.createNode();if(this.expectKeyword("export"),this.matchKeyword("default"))if(this.nextToken(),this.matchKeyword("function")){var n=this.parseFunctionDeclaration(!0);e=this.finalize(t,new a.ExportDefaultDeclaration(n))}else this.matchKeyword("class")?(n=this.parseClassDeclaration(!0),e=this.finalize(t,new a.ExportDefaultDeclaration(n))):this.matchContextualKeyword("async")?(n=this.matchAsyncFunction()?this.parseFunctionDeclaration(!0):this.parseAssignmentExpression(),e=this.finalize(t,new a.ExportDefaultDeclaration(n))):(this.matchContextualKeyword("from")&&this.throwError(o.Messages.UnexpectedToken,this.lookahead.value),n=this.match("{")?this.parseObjectInitializer():this.match("[")?this.parseArrayInitializer():this.parseAssignmentExpression(),this.consumeSemicolon(),e=this.finalize(t,new a.ExportDefaultDeclaration(n)));else if(this.match("*")){if(this.nextToken(),!this.matchContextualKeyword("from")){var r=this.lookahead.value?o.Messages.UnexpectedToken:o.Messages.MissingFromClause;this.throwError(r,this.lookahead.value)}this.nextToken();var i=this.parseModuleSpecifier();this.consumeSemicolon(),e=this.finalize(t,new a.ExportAllDeclaration(i))}else if(4===this.lookahead.type){switch(n=void 0,this.lookahead.value){case"let":case"const":n=this.parseLexicalDeclaration({inFor:!1});break;case"var":case"class":case"function":n=this.parseStatementListItem();break;default:this.throwUnexpectedToken(this.lookahead)}e=this.finalize(t,new a.ExportNamedDeclaration(n,[],null))}else if(this.matchAsyncFunction())n=this.parseFunctionDeclaration(),e=this.finalize(t,new a.ExportNamedDeclaration(n,[],null));else{var s=[],l=null,c=!1;for(this.expect("{");!this.match("}");)c=c||this.matchKeyword("default"),s.push(this.parseExportSpecifier()),this.match("}")||this.expect(",");this.expect("}"),this.matchContextualKeyword("from")?(this.nextToken(),l=this.parseModuleSpecifier(),this.consumeSemicolon()):c?(r=this.lookahead.value?o.Messages.UnexpectedToken:o.Messages.MissingFromClause,this.throwError(r,this.lookahead.value)):this.consumeSemicolon(),e=this.finalize(t,new a.ExportNamedDeclaration(null,s,l))}return e},e}();t.Parser=u},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assert=function(e,t){if(!e)throw new Error("ASSERT: "+t)}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){this.errors=[],this.tolerant=!1}return e.prototype.recordError=function(e){this.errors.push(e)},e.prototype.tolerate=function(e){if(!this.tolerant)throw e;this.recordError(e)},e.prototype.constructError=function(e,t){var n=new Error(e);try{throw n}catch(e){Object.create&&Object.defineProperty&&(n=Object.create(e),Object.defineProperty(n,"column",{value:t}))}return n},e.prototype.createError=function(e,t,n,r){var i="Line "+t+": "+r,o=this.constructError(i,n);return o.index=e,o.lineNumber=t,o.description=r,o},e.prototype.throwError=function(e,t,n,r){throw this.createError(e,t,n,r)},e.prototype.tolerateError=function(e,t,n,r){var i=this.createError(e,t,n,r);if(!this.tolerant)throw i;this.recordError(i)},e}();t.ErrorHandler=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Messages={BadGetterArity:"Getter must not have any formal parameters",BadSetterArity:"Setter must have exactly one formal parameter",BadSetterRestParameter:"Setter function argument must not be a rest parameter",ConstructorIsAsync:"Class constructor may not be an async method",ConstructorSpecialMethod:"Class constructor may not be an accessor",DeclarationMissingInitializer:"Missing initializer in %0 declaration",DefaultRestParameter:"Unexpected token =",DuplicateBinding:"Duplicate binding %0",DuplicateConstructor:"A class may only have one constructor",DuplicateProtoProperty:"Duplicate __proto__ fields are not allowed in object literals",ForInOfLoopInitializer:"%0 loop variable declaration may not have an initializer",GeneratorInLegacyContext:"Generator declarations are not allowed in legacy contexts",IllegalBreak:"Illegal break statement",IllegalContinue:"Illegal continue statement",IllegalExportDeclaration:"Unexpected token",IllegalImportDeclaration:"Unexpected token",IllegalLanguageModeDirective:"Illegal 'use strict' directive in function with non-simple parameter list",IllegalReturn:"Illegal return statement",InvalidEscapedReservedWord:"Keyword must not contain escaped characters",InvalidHexEscapeSequence:"Invalid hexadecimal escape sequence",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",InvalidLHSInForLoop:"Invalid left-hand side in for-loop",InvalidModuleSpecifier:"Unexpected token",InvalidRegExp:"Invalid regular expression",LetInLexicalBinding:"let is disallowed as a lexically bound name",MissingFromClause:"Unexpected token",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NewlineAfterThrow:"Illegal newline after throw",NoAsAfterImportNamespace:"Unexpected token",NoCatchOrFinally:"Missing catch or finally after try",ParameterAfterRestParameter:"Rest parameter must be last formal parameter",Redeclaration:"%0 '%1' has already been declared",StaticPrototype:"Classes may not have static property named prototype",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictFunction:"In strict mode code, functions can only be declared at top level or inside a block",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictModeWith:"Strict mode code may not include a with statement",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictReservedWord:"Use of future reserved word in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",TemplateOctalLiteral:"Octal literals are not allowed in template strings.",UnexpectedEOS:"Unexpected end of input",UnexpectedIdentifier:"Unexpected identifier",UnexpectedNumber:"Unexpected number",UnexpectedReserved:"Unexpected reserved word",UnexpectedString:"Unexpected string",UnexpectedTemplate:"Unexpected quasi %0",UnexpectedToken:"Unexpected token %0",UnexpectedTokenIllegal:"Unexpected token ILLEGAL",UnknownLabel:"Undefined label '%0'",UnterminatedRegExp:"Invalid regular expression: missing /"}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9),i=n(4),o=n(11);function a(e){return"0123456789abcdef".indexOf(e.toLowerCase())}function s(e){return"01234567".indexOf(e)}var l=function(){function e(e,t){this.source=e,this.errorHandler=t,this.trackComment=!1,this.isModule=!1,this.length=e.length,this.index=0,this.lineNumber=e.length>0?1:0,this.lineStart=0,this.curlyStack=[]}return e.prototype.saveState=function(){return{index:this.index,lineNumber:this.lineNumber,lineStart:this.lineStart}},e.prototype.restoreState=function(e){this.index=e.index,this.lineNumber=e.lineNumber,this.lineStart=e.lineStart},e.prototype.eof=function(){return this.index>=this.length},e.prototype.throwUnexpectedToken=function(e){return void 0===e&&(e=o.Messages.UnexpectedTokenIllegal),this.errorHandler.throwError(this.index,this.lineNumber,this.index-this.lineStart+1,e)},e.prototype.tolerateUnexpectedToken=function(e){void 0===e&&(e=o.Messages.UnexpectedTokenIllegal),this.errorHandler.tolerateError(this.index,this.lineNumber,this.index-this.lineStart+1,e)},e.prototype.skipSingleLineComment=function(e){var t,n,r=[];for(this.trackComment&&(r=[],t=this.index-e,n={start:{line:this.lineNumber,column:this.index-this.lineStart-e},end:{}});!this.eof();){var o=this.source.charCodeAt(this.index);if(++this.index,i.Character.isLineTerminator(o)){if(this.trackComment){n.end={line:this.lineNumber,column:this.index-this.lineStart-1};var a={multiLine:!1,slice:[t+e,this.index-1],range:[t,this.index-1],loc:n};r.push(a)}return 13===o&&10===this.source.charCodeAt(this.index)&&++this.index,++this.lineNumber,this.lineStart=this.index,r}}return this.trackComment&&(n.end={line:this.lineNumber,column:this.index-this.lineStart},a={multiLine:!1,slice:[t+e,this.index],range:[t,this.index],loc:n},r.push(a)),r},e.prototype.skipMultiLineComment=function(){var e,t,n=[];for(this.trackComment&&(n=[],e=this.index-2,t={start:{line:this.lineNumber,column:this.index-this.lineStart-2},end:{}});!this.eof();){var r=this.source.charCodeAt(this.index);if(i.Character.isLineTerminator(r))13===r&&10===this.source.charCodeAt(this.index+1)&&++this.index,++this.lineNumber,++this.index,this.lineStart=this.index;else if(42===r){if(47===this.source.charCodeAt(this.index+1)){if(this.index+=2,this.trackComment){t.end={line:this.lineNumber,column:this.index-this.lineStart};var o={multiLine:!0,slice:[e+2,this.index-2],range:[e,this.index],loc:t};n.push(o)}return n}++this.index}else++this.index}return this.trackComment&&(t.end={line:this.lineNumber,column:this.index-this.lineStart},o={multiLine:!0,slice:[e+2,this.index],range:[e,this.index],loc:t},n.push(o)),this.tolerateUnexpectedToken(),n},e.prototype.scanComments=function(){var e;this.trackComment&&(e=[]);for(var t=0===this.index;!this.eof();){var n=this.source.charCodeAt(this.index);if(i.Character.isWhiteSpace(n))++this.index;else if(i.Character.isLineTerminator(n))++this.index,13===n&&10===this.source.charCodeAt(this.index)&&++this.index,++this.lineNumber,this.lineStart=this.index,t=!0;else if(47===n)if(47===(n=this.source.charCodeAt(this.index+1))){this.index+=2;var r=this.skipSingleLineComment(2);this.trackComment&&(e=e.concat(r)),t=!0}else{if(42!==n)break;this.index+=2,r=this.skipMultiLineComment(),this.trackComment&&(e=e.concat(r))}else if(t&&45===n){if(45!==this.source.charCodeAt(this.index+1)||62!==this.source.charCodeAt(this.index+2))break;this.index+=3,r=this.skipSingleLineComment(3),this.trackComment&&(e=e.concat(r))}else{if(60!==n||this.isModule)break;if("!--"!==this.source.slice(this.index+1,this.index+4))break;this.index+=4,r=this.skipSingleLineComment(4),this.trackComment&&(e=e.concat(r))}}return e},e.prototype.isFutureReservedWord=function(e){switch(e){case"enum":case"export":case"import":case"super":return!0;default:return!1}},e.prototype.isStrictModeReservedWord=function(e){switch(e){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return!0;default:return!1}},e.prototype.isRestrictedWord=function(e){return"eval"===e||"arguments"===e},e.prototype.isKeyword=function(e){switch(e.length){case 2:return"if"===e||"in"===e||"do"===e;case 3:return"var"===e||"for"===e||"new"===e||"try"===e||"let"===e;case 4:return"this"===e||"else"===e||"case"===e||"void"===e||"with"===e||"enum"===e;case 5:return"while"===e||"break"===e||"catch"===e||"throw"===e||"const"===e||"yield"===e||"class"===e||"super"===e;case 6:return"return"===e||"typeof"===e||"delete"===e||"switch"===e||"export"===e||"import"===e;case 7:return"default"===e||"finally"===e||"extends"===e;case 8:return"function"===e||"continue"===e||"debugger"===e;case 10:return"instanceof"===e;default:return!1}},e.prototype.codePointAt=function(e){var t=this.source.charCodeAt(e);if(t>=55296&&t<=56319){var n=this.source.charCodeAt(e+1);n>=56320&&n<=57343&&(t=1024*(t-55296)+n-56320+65536)}return t},e.prototype.scanHexEscape=function(e){for(var t="u"===e?4:2,n=0,r=0;r1114111||"}"!==e)&&this.throwUnexpectedToken(),i.Character.fromCodePoint(t)},e.prototype.getIdentifier=function(){for(var e=this.index++;!this.eof();){var t=this.source.charCodeAt(this.index);if(92===t)return this.index=e,this.getComplexIdentifier();if(t>=55296&&t<57343)return this.index=e,this.getComplexIdentifier();if(!i.Character.isIdentifierPart(t))break;++this.index}return this.source.slice(e,this.index)},e.prototype.getComplexIdentifier=function(){var e,t=this.codePointAt(this.index),n=i.Character.fromCodePoint(t);for(this.index+=n.length,92===t&&(117!==this.source.charCodeAt(this.index)&&this.throwUnexpectedToken(),++this.index,"{"===this.source[this.index]?(++this.index,e=this.scanUnicodeCodePointEscape()):null!==(e=this.scanHexEscape("u"))&&"\\"!==e&&i.Character.isIdentifierStart(e.charCodeAt(0))||this.throwUnexpectedToken(),n=e);!this.eof()&&(t=this.codePointAt(this.index),i.Character.isIdentifierPart(t));)n+=e=i.Character.fromCodePoint(t),this.index+=e.length,92===t&&(n=n.substr(0,n.length-1),117!==this.source.charCodeAt(this.index)&&this.throwUnexpectedToken(),++this.index,"{"===this.source[this.index]?(++this.index,e=this.scanUnicodeCodePointEscape()):null!==(e=this.scanHexEscape("u"))&&"\\"!==e&&i.Character.isIdentifierPart(e.charCodeAt(0))||this.throwUnexpectedToken(),n+=e);return n},e.prototype.octalToDecimal=function(e){var t="0"!==e,n=s(e);return!this.eof()&&i.Character.isOctalDigit(this.source.charCodeAt(this.index))&&(t=!0,n=8*n+s(this.source[this.index++]),"0123".indexOf(e)>=0&&!this.eof()&&i.Character.isOctalDigit(this.source.charCodeAt(this.index))&&(n=8*n+s(this.source[this.index++]))),{code:n,octal:t}},e.prototype.scanIdentifier=function(){var e,t=this.index,n=92===this.source.charCodeAt(t)?this.getComplexIdentifier():this.getIdentifier();if(3!=(e=1===n.length?3:this.isKeyword(n)?4:"null"===n?5:"true"===n||"false"===n?1:3)&&t+n.length!==this.index){var r=this.index;this.index=t,this.tolerateUnexpectedToken(o.Messages.InvalidEscapedReservedWord),this.index=r}return{type:e,value:n,lineNumber:this.lineNumber,lineStart:this.lineStart,start:t,end:this.index}},e.prototype.scanPunctuator=function(){var e=this.index,t=this.source[this.index];switch(t){case"(":case"{":"{"===t&&this.curlyStack.push("{"),++this.index;break;case".":++this.index,"."===this.source[this.index]&&"."===this.source[this.index+1]&&(this.index+=2,t="...");break;case"}":++this.index,this.curlyStack.pop();break;case")":case";":case",":case"[":case"]":case":":case"?":case"~":++this.index;break;default:">>>="===(t=this.source.substr(this.index,4))?this.index+=4:"==="===(t=t.substr(0,3))||"!=="===t||">>>"===t||"<<="===t||">>="===t||"**="===t?this.index+=3:"&&"===(t=t.substr(0,2))||"||"===t||"=="===t||"!="===t||"+="===t||"-="===t||"*="===t||"/="===t||"++"===t||"--"===t||"<<"===t||">>"===t||"&="===t||"|="===t||"^="===t||"%="===t||"<="===t||">="===t||"=>"===t||"**"===t?this.index+=2:(t=this.source[this.index],"<>=!+-*%&|^/".indexOf(t)>=0&&++this.index)}return this.index===e&&this.throwUnexpectedToken(),{type:7,value:t,lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}},e.prototype.scanHexLiteral=function(e){for(var t="";!this.eof()&&i.Character.isHexDigit(this.source.charCodeAt(this.index));)t+=this.source[this.index++];return 0===t.length&&this.throwUnexpectedToken(),i.Character.isIdentifierStart(this.source.charCodeAt(this.index))&&this.throwUnexpectedToken(),{type:6,value:parseInt("0x"+t,16),lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}},e.prototype.scanBinaryLiteral=function(e){for(var t,n="";!this.eof()&&("0"===(t=this.source[this.index])||"1"===t);)n+=this.source[this.index++];return 0===n.length&&this.throwUnexpectedToken(),this.eof()||(t=this.source.charCodeAt(this.index),(i.Character.isIdentifierStart(t)||i.Character.isDecimalDigit(t))&&this.throwUnexpectedToken()),{type:6,value:parseInt(n,2),lineNumber:this.lineNumber,lineStart:this.lineStart,start:e,end:this.index}},e.prototype.scanOctalLiteral=function(e,t){var n="",r=!1;for(i.Character.isOctalDigit(e.charCodeAt(0))?(r=!0,n="0"+this.source[this.index++]):++this.index;!this.eof()&&i.Character.isOctalDigit(this.source.charCodeAt(this.index));)n+=this.source[this.index++];return r||0!==n.length||this.throwUnexpectedToken(),(i.Character.isIdentifierStart(this.source.charCodeAt(this.index))||i.Character.isDecimalDigit(this.source.charCodeAt(this.index)))&&this.throwUnexpectedToken(),{type:6,value:parseInt(n,8),octal:r,lineNumber:this.lineNumber,lineStart:this.lineStart,start:t,end:this.index}},e.prototype.isImplicitOctalLiteral=function(){for(var e=this.index+1;e=0&&(n=n.replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g,(function(e,t,n){var i=parseInt(t||n,16);return i>1114111&&r.throwUnexpectedToken(o.Messages.InvalidRegExp),i<=65535?String.fromCharCode(i):"￿"})).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"￿"));try{RegExp(n)}catch(e){this.throwUnexpectedToken(o.Messages.InvalidRegExp)}try{return new RegExp(e,t)}catch(e){return null}},e.prototype.scanRegExpBody=function(){var e=this.source[this.index];r.assert("/"===e,"Regular expression literal must start with a slash");for(var t=this.source[this.index++],n=!1,a=!1;!this.eof();)if(t+=e=this.source[this.index++],"\\"===e)e=this.source[this.index++],i.Character.isLineTerminator(e.charCodeAt(0))&&this.throwUnexpectedToken(o.Messages.UnterminatedRegExp),t+=e;else if(i.Character.isLineTerminator(e.charCodeAt(0)))this.throwUnexpectedToken(o.Messages.UnterminatedRegExp);else if(n)"]"===e&&(n=!1);else{if("/"===e){a=!0;break}"["===e&&(n=!0)}return a||this.throwUnexpectedToken(o.Messages.UnterminatedRegExp),t.substr(1,t.length-2)},e.prototype.scanRegExpFlags=function(){for(var e="";!this.eof();){var t=this.source[this.index];if(!i.Character.isIdentifierPart(t.charCodeAt(0)))break;if(++this.index,"\\"!==t||this.eof())e+=t;else if("u"===(t=this.source[this.index])){++this.index;var n=this.index,r=this.scanHexEscape("u");if(null!==r)for(e+=r;n=55296&&e<57343&&i.Character.isIdentifierStart(this.codePointAt(this.index))?this.scanIdentifier():this.scanPunctuator()},e}();t.Scanner=l},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TokenName={},t.TokenName[1]="Boolean",t.TokenName[2]="",t.TokenName[3]="Identifier",t.TokenName[4]="Keyword",t.TokenName[5]="Null",t.TokenName[6]="Numeric",t.TokenName[7]="Punctuator",t.TokenName[8]="String",t.TokenName[9]="RegularExpression",t.TokenName[10]="Template"},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.XHTMLEntities={quot:'"',amp:"&",apos:"'",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",lang:"⟨",rang:"⟩"}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(10),i=n(12),o=n(13),a=function(){function e(){this.values=[],this.curly=this.paren=-1}return e.prototype.beforeFunctionExpression=function(e){return["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","**=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","**","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="].indexOf(e)>=0},e.prototype.isRegexStart=function(){var e=this.values[this.values.length-1],t=null!==e;switch(e){case"this":case"]":t=!1;break;case")":var n=this.values[this.paren-1];t="if"===n||"while"===n||"for"===n||"with"===n;break;case"}":if(t=!1,"function"===this.values[this.curly-3])t=!!(r=this.values[this.curly-4])&&!this.beforeFunctionExpression(r);else if("function"===this.values[this.curly-4]){var r;t=!(r=this.values[this.curly-5])||!this.beforeFunctionExpression(r)}}return t},e.prototype.push=function(e){7===e.type||4===e.type?("{"===e.value?this.curly=this.values.length:"("===e.value&&(this.paren=this.values.length),this.values.push(e.value)):this.values.push(null)},e}(),s=function(){function e(e,t){this.errorHandler=new r.ErrorHandler,this.errorHandler.tolerant=!!t&&"boolean"==typeof t.tolerant&&t.tolerant,this.scanner=new i.Scanner(e,this.errorHandler),this.scanner.trackComment=!!t&&"boolean"==typeof t.comment&&t.comment,this.trackRange=!!t&&"boolean"==typeof t.range&&t.range,this.trackLoc=!!t&&"boolean"==typeof t.loc&&t.loc,this.buffer=[],this.reader=new a}return e.prototype.errors=function(){return this.errorHandler.errors},e.prototype.getNextToken=function(){if(0===this.buffer.length){var e=this.scanner.scanComments();if(this.scanner.trackComment)for(var t=0;t0?e.charCodeAt(o-1):null,p=p&&v(a,s)}else{for(o=0;or&&" "!==e[h+1],h=o);else if(!g(a))return 5;s=o>0?e.charCodeAt(o-1):null,p=p&&v(a,s)}u=u||d&&o-h-1>r&&" "!==e[h+1]}return c||u?n>9&&y(e)?5:u?4:3:p&&!i(e)?1:2}function b(e,t,n,r){e.dump=function(){if(0===t.length)return"''";if(!e.noCompatMode&&-1!==u.indexOf(t))return"'"+t+"'";var o=e.indent*Math.max(1,n),a=-1===e.lineWidth?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-o),s=r||e.flowLevel>-1&&n>=e.flowLevel;switch(_(t,s,e.indent,a,(function(t){return function(e,t){var n,r;for(n=0,r=e.implicitTypes.length;n"+E(t,e.indent)+w(p(function(e,t){for(var n,r,i,o=/(\n+)([^\n]*)/g,a=(i=-1!==(i=e.indexOf("\n"))?i:e.length,o.lastIndex=i,x(e.slice(0,i),t)),s="\n"===e[0]||" "===e[0];r=o.exec(e);){var l=r[1],c=r[2];n=" "===c[0],a+=l+(s||n||""===c?"":"\n")+x(c,t),s=n}return a}(t,a),o));case 5:return'"'+function(e){for(var t,n,r,i="",o=0;o=55296&&t<=56319&&(n=e.charCodeAt(o+1))>=56320&&n<=57343?(i+=d(1024*(t-55296)+n-56320+65536),o++):i+=!(r=c[t])&&g(t)?e[o]:r||d(t);return i}(t)+'"';default:throw new i("impossible error: invalid scalar style")}}()}function E(e,t){var n=y(e)?String(t):"",r="\n"===e[e.length-1];return n+(!r||"\n"!==e[e.length-2]&&"\n"!==e?r?"":"-":"+")+"\n"}function w(e){return"\n"===e[e.length-1]?e.slice(0,-1):e}function x(e,t){if(""===e||" "===e[0])return e;for(var n,r,i=/ [^ ]/g,o=0,a=0,s=0,l="";n=i.exec(e);)(s=n.index)-o>t&&(r=a>o?a:s,l+="\n"+e.slice(o,r),o=r+1),a=s;return l+="\n",e.length-o>t&&a>o?l+=e.slice(o,a)+"\n"+e.slice(a+1):l+=e.slice(o),l.slice(1)}function C(e,t,n){var r,o,a,c,u,d;for(a=0,c=(o=n?e.explicitTypes:e.implicitTypes).length;a tag resolver accepts not "'+d+'" style');r=u.represent[d](t,d)}e.dump=r}return!0}return!1}function D(e,t,n,r,o,a){e.tag=null,e.dump=n,C(e,n,!1)||C(e,n,!0);var l=s.call(e.dump);r&&(r=e.flowLevel<0||e.flowLevel>t);var c,u,d="[object Object]"===l||"[object Array]"===l;if(d&&(u=-1!==(c=e.duplicates.indexOf(n))),(null!==e.tag&&"?"!==e.tag||u||2!==e.indent&&t>0)&&(o=!1),u&&e.usedDuplicates[c])e.dump="*ref_"+c;else{if(d&&u&&!e.usedDuplicates[c]&&(e.usedDuplicates[c]=!0),"[object Object]"===l)r&&0!==Object.keys(e.dump).length?(function(e,t,n,r){var o,a,s,l,c,u,d="",h=e.tag,p=Object.keys(n);if(!0===e.sortKeys)p.sort();else if("function"==typeof e.sortKeys)p.sort(e.sortKeys);else if(e.sortKeys)throw new i("sortKeys must be a boolean or a function");for(o=0,a=p.length;o1024)&&(e.dump&&10===e.dump.charCodeAt(0)?u+="?":u+="? "),u+=e.dump,c&&(u+=f(e,t)),D(e,t+1,l,!0,c)&&(e.dump&&10===e.dump.charCodeAt(0)?u+=":":u+=": ",d+=u+=e.dump));e.tag=h,e.dump=d||"{}"}(e,t,e.dump,o),u&&(e.dump="&ref_"+c+e.dump)):(function(e,t,n){var r,i,o,a,s,l="",c=e.tag,u=Object.keys(n);for(r=0,i=u.length;r1024&&(s+="? "),s+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),D(e,t,a,!1,!1)&&(l+=s+=e.dump));e.tag=c,e.dump="{"+l+"}"}(e,t,e.dump),u&&(e.dump="&ref_"+c+" "+e.dump));else if("[object Array]"===l){var h=e.noArrayIndent&&t>0?t-1:t;r&&0!==e.dump.length?(function(e,t,n,r){var i,o,a="",s=e.tag;for(i=0,o=n.length;i "+e.dump)}return!0}function S(e,t){var n,r,i=[],o=[];for(function e(t,n,r){var i,o,a;if(null!==t&&"object"==typeof t)if(-1!==(o=n.indexOf(t)))-1===r.indexOf(o)&&r.push(o);else if(n.push(t),Array.isArray(t))for(o=0,a=t.length;o=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},a=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 s=n(91),l=n(1),c=n(183),u=n(0),d=n(7),h=n(95),p=n(69),f=n(3),m=n(305),g=n(306),v=n(307),y=function(e){function t(t,n){void 0===n&&(n=!1);var r=e.call(this)||this;return r._hasDeclaration=!1,r._docTypeName="",r._hasDocumentElement=!1,r._currentElementSerialized=!1,r._openTags=[],r._ended=!1,r._fragment=n,r._options=l.applyDefaults(t||{},s.DefaultXMLBuilderCBOptions),r._builderOptions={defaultNamespace:r._options.defaultNamespace,namespaceAlias:r._options.namespaceAlias},"json"===r._options.format?r._writer=new g.JSONCBWriter(r._options):"yaml"===r._options.format?r._writer=new v.YAMLCBWriter(r._options):r._writer=new m.XMLCBWriter(r._options),void 0!==r._options.data&&r.on("data",r._options.data),void 0!==r._options.end&&r.on("end",r._options.end),void 0!==r._options.error&&r.on("error",r._options.error),r._prefixMap=new h.NamespacePrefixMap,r._prefixMap.set("xml",d.namespace.XML),r._prefixIndex={value:1},r._push(r._writer.frontMatter()),r}return i(t,e),t.prototype.ele=function(e,t,n){var r,i;if(l.isObject(e)||l.isString(e)&&(/^\s*/g,">");return this._push(this._writer.text(n)),this},t.prototype.ins=function(e,t){var n;void 0===t&&(t=""),this._serializeOpenTag(!0);try{n=c.fragment(this._builderOptions).ins(e,t).first().node}catch(e){return this.emit("error",e),this}return this._options.wellFormed&&(-1!==n.target.indexOf(":")||/^xml$/i.test(n.target))?(this.emit("error",new Error("Processing instruction target contains invalid characters (well-formed required).")),this):this._options.wellFormed&&!u.xml_isLegalChar(n.data)?(this.emit("error",Error("Processing instruction data contains invalid characters (well-formed required).")),this):(this._push(this._writer.instruction(n.target,n.data)),this)},t.prototype.dat=function(e){var t;this._serializeOpenTag(!0);try{t=c.fragment(this._builderOptions).dat(e).first().node}catch(e){return this.emit("error",e),this}return this._push(this._writer.cdata(t.data)),this},t.prototype.dec=function(e){return void 0===e&&(e={version:"1.0"}),this._fragment?(this.emit("error",Error("Cannot insert an XML declaration into a document fragment.")),this):this._hasDeclaration?(this.emit("error",Error("XML declaration is already inserted.")),this):(this._push(this._writer.declaration(e.version||"1.0",e.encoding,e.standalone)),this._hasDeclaration=!0,this)},t.prototype.dtd=function(e){if(this._fragment)return this.emit("error",Error("Cannot insert a DocType declaration into a document fragment.")),this;if(""!==this._docTypeName)return this.emit("error",new Error("DocType declaration is already inserted.")),this;if(this._hasDocumentElement)return this.emit("error",new Error("Cannot insert DocType declaration after document element.")),this;var t;try{t=c.create().dtd(e).first().node}catch(e){return this.emit("error",e),this}return this._options.wellFormed&&!u.xml_isPubidChar(t.publicId)?(this.emit("error",new Error("DocType public identifier does not match PubidChar construct (well-formed required).")),this):this._options.wellFormed&&(!u.xml_isLegalChar(t.systemId)||-1!==t.systemId.indexOf('"')&&-1!==t.systemId.indexOf("'"))?(this.emit("error",new Error("DocType system identifier contains invalid characters (well-formed required).")),this):(this._docTypeName=e.name,this._push(this._writer.docType(e.name,t.publicId,t.systemId)),this)},t.prototype.import=function(e){var t,n,r=c.fragment().set(this._options);try{r.import(e)}catch(e){return this.emit("error",e),this}try{for(var i=o(r.node.childNodes),a=i.next();!a.done;a=i.next()){var s=a.value;this._fromNode(s)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return this},t.prototype.up=function(){return this._serializeOpenTag(!1),this._serializeCloseTag(),this},t.prototype.end=function(){for(this._serializeOpenTag(!1);this._openTags.length>0;)this._serializeCloseTag();return this._push(null),this},t.prototype._serializeOpenTag=function(e){if(!this._currentElementSerialized&&void 0!==this._currentElement){var n=this._currentElement.node;if(!this._options.wellFormed||-1===n.localName.indexOf(":")&&u.xml_isName(n.localName)){var r="",i=!1,o=this._prefixMap.copy(),a={},s=this._recordNamespaceInformation(n,o,a),l=0===this._openTags.length?null:this._openTags[this._openTags.length-1][1],c=n.namespaceURI;if(null===c&&(c=l),l===c)null!==s&&(i=!0),r=c===d.namespace.XML?"xml:"+n.localName:n.localName,this._writer.beginElement(r),this._push(this._writer.openTagBegin(r));else{var h=n.prefix,p=null;if(null===h&&c===s||(p=o.get(h,c)),"xmlns"===h){if(this._options.wellFormed)return void this.emit("error",new Error("An element cannot have the 'xmlns' prefix (well-formed required)."));p=h}null!==p?(r=p+":"+n.localName,null!==s&&s!==d.namespace.XML&&(l=s||null),this._writer.beginElement(r),this._push(this._writer.openTagBegin(r))):null!==h?(h in a&&(h=this._generatePrefix(c,o,this._prefixIndex)),o.set(h,c),r+=h+":"+n.localName,this._writer.beginElement(r),this._push(this._writer.openTagBegin(r)),this._push(this._writer.attribute("xmlns:"+h,this._serializeAttributeValue(c,this._options.wellFormed))),null!==s&&(l=s||null)):null===s||null!==s&&s!==c?(i=!0,r+=n.localName,l=c,this._writer.beginElement(r),this._push(this._writer.openTagBegin(r)),this._push(this._writer.attribute("xmlns",this._serializeAttributeValue(c,this._options.wellFormed)))):(r+=n.localName,l=c,this._writer.beginElement(r),this._push(this._writer.openTagBegin(r)))}this._serializeAttributes(n,o,this._prefixIndex,a,i,this._options.wellFormed);var f=c===d.namespace.HTML;f&&!e&&t._VoidElementNames.has(n.localName)?(this._push(this._writer.openTagEnd(r,!0,!0)),this._writer.endElement(r)):f||e?this._push(this._writer.openTagEnd(r,!1,!1)):(this._push(this._writer.openTagEnd(r,!0,!1)),this._writer.endElement(r)),this._currentElementSerialized=!0,this._openTags.push([r,l,this._prefixMap,e]),this._isPrefixMapModified(this._prefixMap,o)&&(this._prefixMap=o),this._writer.level++}else this.emit("error",new Error("Node local name contains invalid characters (well-formed required)."))}},t.prototype._serializeCloseTag=function(){this._writer.level--;var e=this._openTags.pop();if(void 0!==e){var t=a(e,4),n=t[0],r=(t[1],t[2]),i=t[3];this._prefixMap=r,i&&(this._push(this._writer.closeTag(n)),this._writer.endElement(n))}else this.emit("error",new Error("Last element is undefined."))},t.prototype._push=function(e){null===e?(this._ended=!0,this.emit("end")):this._ended?this.emit("error",new Error("Cannot push to ended stream.")):0!==e.length&&(this._writer.hasData=!0,this.emit("data",e,this._writer.level))},t.prototype._fromNode=function(e){var t,n,r,i;if(f.Guard.isElementNode(e)){var a=e.prefix?e.prefix+":"+e.localName:e.localName;null!==e.namespaceURI?this.ele(e.namespaceURI,a):this.ele(a);try{for(var s=o(e.attributes),l=s.next();!l.done;l=s.next()){var c=l.value,u=c.prefix?c.prefix+":"+c.localName:c.localName;null!==c.namespaceURI?this.att(c.namespaceURI,u,c.value):this.att(u,c.value)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}try{for(var d=o(e.childNodes),h=d.next();!h.done;h=d.next()){var p=h.value;this._fromNode(p)}}catch(e){r={error:e}}finally{try{h&&!h.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}this.up()}else f.Guard.isExclusiveTextNode(e)&&e.data?this.txt(e.data):f.Guard.isCommentNode(e)?this.com(e.data):f.Guard.isCDATASectionNode(e)?this.dat(e.data):f.Guard.isProcessingInstructionNode(e)&&this.ins(e.target,e.data)},t.prototype._serializeAttributes=function(e,t,n,r,i,a){var s,l,c=a?new p.LocalNameSet:void 0;try{for(var h=o(e.attributes),f=h.next();!f.done;f=h.next()){var m=f.value;if(a||i||null!==m.namespaceURI){if(a&&c&&c.has(m.namespaceURI,m.localName))return void this.emit("error",new Error("Element contains duplicate attributes (well-formed required)."));a&&c&&c.set(m.namespaceURI,m.localName);var g=m.namespaceURI,v=null;if(null!==g)if(v=t.get(m.prefix,g),g===d.namespace.XMLNS){if(m.value===d.namespace.XML||null===m.prefix&&i||null!==m.prefix&&(!(m.localName in r)||r[m.localName]!==m.value)&&t.has(m.localName,m.value))continue;if(a&&m.value===d.namespace.XMLNS)return void this.emit("error",new Error("XMLNS namespace is reserved (well-formed required)."));if(a&&""===m.value)return void this.emit("error",new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required)."));"xmlns"===m.prefix&&(v="xmlns")}else null===v&&(v=null===m.prefix||t.hasPrefix(m.prefix)&&!t.has(m.prefix,g)?this._generatePrefix(g,t,n):m.prefix,this._push(this._writer.attribute("xmlns:"+v,this._serializeAttributeValue(g,this._options.wellFormed))));if(a&&(-1!==m.localName.indexOf(":")||!u.xml_isName(m.localName)||"xmlns"===m.localName&&null===g))return void this.emit("error",new Error("Attribute local name contains invalid characters (well-formed required)."));this._push(this._writer.attribute((null!==v?v+":":"")+m.localName,this._serializeAttributeValue(m.value,this._options.wellFormed)))}else this._push(this._writer.attribute(m.localName,this._serializeAttributeValue(m.value,this._options.wellFormed)))}}catch(e){s={error:e}}finally{try{f&&!f.done&&(l=h.return)&&l.call(h)}finally{if(s)throw s.error}}},t.prototype._serializeAttributeValue=function(e,t){return t&&null!==e&&!u.xml_isLegalChar(e)?(this.emit("error",new Error("Invalid characters in attribute value.")),""):null===e?"":e.replace(/(?!&(lt|gt|amp|apos|quot);)&/g,"&").replace(//g,">").replace(/"/g,""")},t.prototype._recordNamespaceInformation=function(e,t,n){var r,i,a=null;try{for(var s=o(e.attributes),l=s.next();!l.done;l=s.next()){var c=l.value,u=c.namespaceURI,h=c.prefix;if(u===d.namespace.XMLNS){if(null===h){a=c.value;continue}var p=c.localName,f=c.value;if(f===d.namespace.XML)continue;if(""===f&&(f=null),t.has(p,f))continue;t.set(p,f),n[p]=f||""}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return a},t.prototype._generatePrefix=function(e,t,n){var r="ns"+n.value;return n.value++,t.set(r,e),r},t.prototype._isPrefixMapModified=function(e,t){var n=e._items,r=t._items,i=e._nullItems,o=t._nullItems;for(var a in r){var s=n[a];if(void 0===s)return!0;var l=r[a];if(s.length!==l.length)return!0;for(var c=0;c"},t.prototype.docType=function(e,t,n){return this._beginLine()+(t&&n?"':t?"':n?"':"")},t.prototype.comment=function(e){return this._beginLine()+"\x3c!--"+e+"--\x3e"},t.prototype.text=function(e){return this._beginLine()+e},t.prototype.instruction=function(e,t){return t?this._beginLine()+"":this._beginLine()+""},t.prototype.cdata=function(e){return this._beginLine()+""},t.prototype.openTagBegin=function(e){return this._lineLength+=1+e.length,this._beginLine()+"<"+e},t.prototype.openTagEnd=function(e,t,n){return n?" />":t?this._writerOptions.allowEmptyTags?">":this._writerOptions.spaceBeforeSlash?" />":"/>":">"},t.prototype.closeTag=function(e){return this._beginLine()+""},t.prototype.attribute=function(e,t){var n=e+'="'+t+'"';return this._writerOptions.prettyPrint&&this._writerOptions.width>0&&this._lineLength+1+n.length>this._writerOptions.width?(n=this._beginLine()+this._indent(1)+n,this._lineLength=n.length,n):(this._lineLength+=1+n.length," "+n)},t.prototype.beginElement=function(e){},t.prototype.endElement=function(e){},t.prototype._beginLine=function(){if(this._writerOptions.prettyPrint){var e=(this.hasData?this._writerOptions.newline:"")+this._indent(this._writerOptions.offset+this.level);return this._lineLength=e.length,e}return""},t.prototype._indent=function(e){return e<=0?"":this._writerOptions.indent.repeat(e)},t}(n(114).BaseCBWriter);t.XMLCBWriter=o},function(e,t,n){"use strict";n(74);var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){var n=e.call(this,t)||this;return n._hasChildren=[],n._additionalLevel=0,n}return i(t,e),t.prototype.frontMatter=function(){return""},t.prototype.declaration=function(e,t,n){return""},t.prototype.docType=function(e,t,n){return""},t.prototype.comment=function(e){return this._comma()+this._beginLine()+"{"+this._sep()+this._key(this._builderOptions.convert.comment)+this._sep()+this._val(e)+this._sep()+"}"},t.prototype.text=function(e){return this._comma()+this._beginLine()+"{"+this._sep()+this._key(this._builderOptions.convert.text)+this._sep()+this._val(e)+this._sep()+"}"},t.prototype.instruction=function(e,t){return this._comma()+this._beginLine()+"{"+this._sep()+this._key(this._builderOptions.convert.ins)+this._sep()+this._val(t?e+" "+t:e)+this._sep()+"}"},t.prototype.cdata=function(e){return this._comma()+this._beginLine()+"{"+this._sep()+this._key(this._builderOptions.convert.cdata)+this._sep()+this._val(e)+this._sep()+"}"},t.prototype.attribute=function(e,t){return this._comma()+this._beginLine(1)+"{"+this._sep()+this._key(this._builderOptions.convert.att+e)+this._sep()+this._val(t)+this._sep()+"}"},t.prototype.openTagBegin=function(e){var t=this._comma()+this._beginLine()+"{"+this._sep()+this._key(e)+this._sep()+"{";return this._additionalLevel++,this.hasData=!0,t+=this._beginLine()+this._key(this._builderOptions.convert.text)+this._sep()+"[",this._hasChildren.push(!1),t},t.prototype.openTagEnd=function(e,t,n){if(t){var r=this._sep()+"]";return this._additionalLevel--,r+(this._beginLine()+"}")+this._sep()+"}"}return""},t.prototype.closeTag=function(e){var t=this._beginLine()+"]";return this._additionalLevel--,t+(this._beginLine()+"}")+this._sep()+"}"},t.prototype.beginElement=function(e){},t.prototype.endElement=function(e){this._hasChildren.pop()},t.prototype._beginLine=function(e){return void 0===e&&(e=0),this._writerOptions.prettyPrint?(this.hasData?this._writerOptions.newline:"")+this._indent(this._writerOptions.offset+this.level+e):""},t.prototype._indent=function(e){return e+this._additionalLevel<=0?"":this._writerOptions.indent.repeat(e+this._additionalLevel)},t.prototype._comma=function(){var e=this._hasChildren[this._hasChildren.length-1]?",":"";return this._hasChildren.length>0&&(this._hasChildren[this._hasChildren.length-1]=!0),e},t.prototype._sep=function(){return this._writerOptions.prettyPrint?" ":""},t.prototype._key=function(e){return'"'+e+'":'},t.prototype._val=function(e){return JSON.stringify(e)},t}(n(114).BaseCBWriter);t.JSONCBWriter=o},function(e,t,n){"use strict";n(74);var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){var n=e.call(this,t)||this;if(n._rootWritten=!1,n._additionalLevel=0,t.indent.length<2)throw new Error("YAML indententation string must be at least two characters long.");if(t.offset<0)throw new Error("YAML offset should be zero or a positive number.");return n}return i(t,e),t.prototype.frontMatter=function(){return this._beginLine()+"---"},t.prototype.declaration=function(e,t,n){return""},t.prototype.docType=function(e,t,n){return""},t.prototype.comment=function(e){return this._beginLine()+this._key(this._builderOptions.convert.comment)+" "+this._val(e)},t.prototype.text=function(e){return this._beginLine()+this._key(this._builderOptions.convert.text)+" "+this._val(e)},t.prototype.instruction=function(e,t){return this._beginLine()+this._key(this._builderOptions.convert.ins)+" "+this._val(t?e+" "+t:e)},t.prototype.cdata=function(e){return this._beginLine()+this._key(this._builderOptions.convert.cdata)+" "+this._val(e)},t.prototype.attribute=function(e,t){this._additionalLevel++;var n=this._beginLine()+this._key(this._builderOptions.convert.att+e)+" "+this._val(t);return this._additionalLevel--,n},t.prototype.openTagBegin=function(e){var t=this._beginLine()+this._key(e);return this._rootWritten||(this._rootWritten=!0),this.hasData=!0,this._additionalLevel++,t+(this._beginLine(!0)+this._key(this._builderOptions.convert.text))},t.prototype.openTagEnd=function(e,t,n){return t?" "+this._val(""):""},t.prototype.closeTag=function(e){return this._additionalLevel--,""},t.prototype.beginElement=function(e){},t.prototype.endElement=function(e){},t.prototype._beginLine=function(e){return void 0===e&&(e=!1),(this.hasData?this._writerOptions.newline:"")+this._indent(this._writerOptions.offset+this.level,e)},t.prototype._indent=function(e,t){if(e+this._additionalLevel<=0)return"";var n=this._writerOptions.indent.repeat(e+this._additionalLevel);return!t&&this._rootWritten?n.substr(0,n.length-2)+"-"+n.substr(-1,1):n},t.prototype._key=function(e){return'"'+e+'":'},t.prototype._val=function(e){return JSON.stringify(e)},t}(n(114).BaseCBWriter);t.YAMLCBWriter=o},function(e,t,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var a=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var l=10;function c(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function d(e,t,n,r){var i,o,a,s;if(c(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]),void 0===a)a=o[t]=n,++e._eventsCount;else if("function"==typeof a?a=o[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(i=u(e))>0&&a.length>i&&!a.warned){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=a.length,s=l,console&&console.warn&&console.warn(s)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=h.bind(r);return i.listener=n,r.wrapFn=i,i}function f(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var l=i[e];if(void 0===l)return!1;if("function"==typeof l)o(l,this,t);else{var c=l.length,u=g(l,c);for(n=0;n=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1=0;r--)this.removeListener(e,t[r]);return this},s.prototype.listeners=function(e){return f(this,e,!0)},s.prototype.rawListeners=function(e){return f(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},s.prototype.listenerCount=m,s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(77);t.createCB=function(e){return new r.XMLBuilderCBImpl(e)},t.fragmentCB=function(e){return new r.XMLBuilderCBImpl(e,!0)}}])}}]); //# sourceMappingURL=957.bundle.dd46b7a4ddd3e6a28a17.js.map