@signalk/freeboard-sk 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/{chunk-4WQJ5OCH.js → chunk-D7ZEGEOC.js} +4 -4
- package/public/{chunk-R2B7EL5S.js → chunk-DNH7JESK.js} +1 -1
- package/public/{chunk-2BZ663DE.js → chunk-EM5FQG4A.js} +1 -1
- package/public/{chunk-KOKEUVWV.js → chunk-H7UNBNCX.js} +1 -1
- package/public/{chunk-JWF7HEH3.js → chunk-O6UXXKK5.js} +1 -1
- package/public/{chunk-5FQJDXLT.js → chunk-SWYHX6EA.js} +1 -1
- package/public/{chunk-DXGM3UI4.js → chunk-VAP4SPL7.js} +1 -1
- package/public/{chunk-DN47TOA6.js → chunk-VXGBILC6.js} +1 -1
- package/public/index.html +1 -1
- package/public/{main-L4CGDOIX.js → main-QZHUBX6D.js} +5 -5
|
@@ -747,11 +747,11 @@ To display the radar overlay WebGL support is required.`)}init(e){return J(this,
|
|
|
747
747
|
.cdk-drag-preview * {
|
|
748
748
|
pointer-events: none !important;
|
|
749
749
|
}
|
|
750
|
-
`],encapsulation:2,changeDetection:0})}return n})(),M2=(()=>{class n{_ngZone=M(Gi);_document=M(Go);_styleLoader=M(Dr);_renderer=M(FC).createRenderer(null,null);_cleanupDocumentTouchmove;_scroll=new ze;_dropInstances=new Set;_dragInstances=new Set;_activeDragInstances=X([]);_globalListeners;_draggingPredicate=t=>t.isDragging();_domNodesToDirectives=null;pointerMove=new ze;pointerUp=new ze;constructor(){}registerDropContainer(t){this._dropInstances.has(t)||this._dropInstances.add(t)}registerDragItem(t){this._dragInstances.add(t),this._dragInstances.size===1&&this._ngZone.runOutsideAngular(()=>{this._cleanupDocumentTouchmove?.(),this._cleanupDocumentTouchmove=this._renderer.listen(this._document,"touchmove",this._persistentTouchmoveListener,aE)})}removeDropContainer(t){this._dropInstances.delete(t)}removeDragItem(t){this._dragInstances.delete(t),this.stopDragging(t),this._dragInstances.size===0&&this._cleanupDocumentTouchmove?.()}startDragging(t,i){if(!(this._activeDragInstances().indexOf(t)>-1)&&(this._styleLoader.load(nre),this._activeDragInstances.update(r=>[...r,t]),this._activeDragInstances().length===1)){let r=i.type.startsWith("touch"),o=s=>this.pointerUp.next(s),a=[["scroll",s=>this._scroll.next(s),C_],["selectstart",this._preventDefaultWhileDragging,aE]];r?a.push(["touchend",o,C_],["touchcancel",o,C_]):a.push(["mouseup",o,C_]),r||a.push(["mousemove",s=>this.pointerMove.next(s),aE]),this._ngZone.runOutsideAngular(()=>{this._globalListeners=a.map(([s,l,c])=>this._renderer.listen(this._document,s,l,c))})}}stopDragging(t){this._activeDragInstances.update(i=>{let r=i.indexOf(t);return r>-1?(i.splice(r,1),[...i]):i}),this._activeDragInstances().length===0&&this._clearGlobalListeners()}isDragging(t){return this._activeDragInstances().indexOf(t)>-1}scrolled(t){let i=[this._scroll];return t&&t!==this._document&&i.push(new Ru(r=>this._ngZone.runOutsideAngular(()=>{let o=this._renderer.listen(t,"scroll",a=>{this._activeDragInstances().length&&r.next(a)},C_);return()=>{o()}}))),Ir(...i)}registerDirectiveNode(t,i){this._domNodesToDirectives??=new WeakMap,this._domNodesToDirectives.set(t,i)}removeDirectiveNode(t){this._domNodesToDirectives?.delete(t)}getDragDirectiveForNode(t){return this._domNodesToDirectives?.get(t)||null}ngOnDestroy(){this._dragInstances.forEach(t=>this.removeDragItem(t)),this._dropInstances.forEach(t=>this.removeDropContainer(t)),this._domNodesToDirectives=null,this._clearGlobalListeners(),this.pointerMove.complete(),this.pointerUp.complete()}_preventDefaultWhileDragging=t=>{this._activeDragInstances().length>0&&t.preventDefault()};_persistentTouchmoveListener=t=>{this._activeDragInstances().length>0&&(this._activeDragInstances().some(this._draggingPredicate)&&t.preventDefault(),this.pointerMove.next(t))};_clearGlobalListeners(){this._globalListeners?.forEach(t=>t()),this._globalListeners=void 0}static \u0275fac=function(i){return new(i||n)};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();function GF(n){let e=n.toLowerCase().indexOf("ms")>-1?1:1e3;return parseFloat(n)*e}function rre(n){let e=getComputedStyle(n),t=sE(e,"transition-property"),i=t.find(s=>s==="transform"||s==="all");if(!i)return 0;let r=t.indexOf(i),o=sE(e,"transition-duration"),a=sE(e,"transition-delay");return GF(o[r])+GF(a[r])}function sE(n,e){return n.getPropertyValue(e).split(",").map(i=>i.trim())}var ore=new Set(["position"]),dE=class{_document;_rootElement;_direction;_initialDomRect;_previewTemplate;_previewClass;_pickupPositionOnPage;_initialTransform;_zIndex;_renderer;_previewEmbeddedView=null;_preview;get element(){return this._preview}constructor(e,t,i,r,o,a,s,l,c,d){this._document=e,this._rootElement=t,this._direction=i,this._initialDomRect=r,this._previewTemplate=o,this._previewClass=a,this._pickupPositionOnPage=s,this._initialTransform=l,this._zIndex=c,this._renderer=d}attach(e){this._preview=this._createPreview(),e.appendChild(this._preview),zF(this._preview)&&this._preview.showPopover()}destroy(){this._preview.remove(),this._previewEmbeddedView?.destroy(),this._preview=this._previewEmbeddedView=null}setTransform(e){this._preview.style.transform=e}getBoundingClientRect(){return this._preview.getBoundingClientRect()}addClass(e){this._preview.classList.add(e)}getTransitionDuration(){return rre(this._preview)}addEventListener(e,t){return this._renderer.listen(this._preview,e,t)}_createPreview(){let e=this._previewTemplate,t=this._previewClass,i=e?e.template:null,r;if(i&&e){let o=e.matchSize?this._initialDomRect:null,a=e.viewContainer.createEmbeddedView(i,e.context);a.detectChanges(),r=qF(a,this._document),this._previewEmbeddedView=a,e.matchSize?VF(r,o):r.style.transform=S_(this._pickupPositionOnPage.x,this._pickupPositionOnPage.y)}else r=lE(this._rootElement),VF(r,this._initialDomRect),this._initialTransform&&(r.style.transform=this._initialTransform);return gE(r.style,{"pointer-events":"none",margin:zF(r)?"0 auto 0 0":"0",position:"fixed",top:"0",left:"0","z-index":this._zIndex+""},ore),Tf(r,!1),r.classList.add("cdk-drag-preview"),r.setAttribute("popover","manual"),r.setAttribute("dir",this._direction),t&&(Array.isArray(t)?t.forEach(o=>r.classList.add(o)):r.classList.add(t)),r}};function zF(n){return"showPopover"in n}var are={passive:!0},jF={passive:!1},sre={passive:!1,capture:!0},lre=800,WF="cdk-drag-placeholder",UF=new Set(["position"]);function ZF(n,e,t={dragStartThreshold:5,pointerDirectionChangeThreshold:5}){let i=n.get(Rn,null,{optional:!0})||n.get(FC).createRenderer(null,null);return new uE(e,t,n.get(Go),n.get(Gi),n.get(jp),n.get(M2),i)}var uE=class{_config;_document;_ngZone;_viewportRuler;_dragDropRegistry;_renderer;_rootElementCleanups;_cleanupShadowRootSelectStart;_preview=null;_previewContainer;_placeholderRef=null;_placeholder;_pickupPositionInElement;_pickupPositionOnPage;_marker;_anchor=null;_passiveTransform={x:0,y:0};_activeTransform={x:0,y:0};_initialTransform;_hasStartedDragging=X(!1);_hasMoved=!1;_initialContainer;_initialIndex;_parentPositions;_moveEvents=new ze;_pointerDirectionDelta;_pointerPositionAtLastDirectionChange;_lastKnownPointerPosition;_rootElement;_ownerSVGElement=null;_rootElementTapHighlight;_pointerMoveSubscription=rr.EMPTY;_pointerUpSubscription=rr.EMPTY;_scrollSubscription=rr.EMPTY;_resizeSubscription=rr.EMPTY;_lastTouchEventTime;_dragStartTime;_boundaryElement=null;_nativeInteractionsEnabled=!0;_initialDomRect;_previewRect;_boundaryRect;_previewTemplate;_placeholderTemplate;_handles=[];_disabledHandles=new Set;_dropContainer;_direction="ltr";_parentDragRef=null;_cachedShadowRoot;lockAxis=null;dragStartDelay=0;previewClass;scale=1;get disabled(){return this._disabled||!!(this._dropContainer&&this._dropContainer.disabled)}set disabled(e){e!==this._disabled&&(this._disabled=e,this._toggleNativeDragInteractions(),this._handles.forEach(t=>Tf(t,e)))}_disabled=!1;beforeStarted=new ze;started=new ze;released=new ze;ended=new ze;entered=new ze;exited=new ze;dropped=new ze;moved=this._moveEvents;data;constrainPosition;constructor(e,t,i,r,o,a,s){this._config=t,this._document=i,this._ngZone=r,this._viewportRuler=o,this._dragDropRegistry=a,this._renderer=s,this.withRootElement(e).withParent(t.parentDragRef||null),this._parentPositions=new b2(i),a.registerDragItem(this)}getPlaceholderElement(){return this._placeholder}getRootElement(){return this._rootElement}getVisibleElement(){return this.isDragging()?this.getPlaceholderElement():this.getRootElement()}withHandles(e){this._handles=e.map(i=>Ec(i)),this._handles.forEach(i=>Tf(i,this.disabled)),this._toggleNativeDragInteractions();let t=new Set;return this._disabledHandles.forEach(i=>{this._handles.indexOf(i)>-1&&t.add(i)}),this._disabledHandles=t,this}withPreviewTemplate(e){return this._previewTemplate=e,this}withPlaceholderTemplate(e){return this._placeholderTemplate=e,this}withRootElement(e){let t=Ec(e);if(t!==this._rootElement){this._removeRootElementListeners();let i=this._renderer;this._rootElementCleanups=this._ngZone.runOutsideAngular(()=>[i.listen(t,"mousedown",this._pointerDown,jF),i.listen(t,"touchstart",this._pointerDown,are),i.listen(t,"dragstart",this._nativeDragStart,jF)]),this._initialTransform=void 0,this._rootElement=t}return typeof SVGElement<"u"&&this._rootElement instanceof SVGElement&&(this._ownerSVGElement=this._rootElement.ownerSVGElement),this}withBoundaryElement(e){return this._boundaryElement=e?Ec(e):null,this._resizeSubscription.unsubscribe(),e&&(this._resizeSubscription=this._viewportRuler.change(10).subscribe(()=>this._containInsideBoundaryOnResize())),this}withParent(e){return this._parentDragRef=e,this}dispose(){this._removeRootElementListeners(),this.isDragging()&&this._rootElement?.remove(),this._marker?.remove(),this._destroyPreview(),this._destroyPlaceholder(),this._dragDropRegistry.removeDragItem(this),this._removeListeners(),this.beforeStarted.complete(),this.started.complete(),this.released.complete(),this.ended.complete(),this.entered.complete(),this.exited.complete(),this.dropped.complete(),this._moveEvents.complete(),this._handles=[],this._disabledHandles.clear(),this._dropContainer=void 0,this._resizeSubscription.unsubscribe(),this._parentPositions.clear(),this._boundaryElement=this._rootElement=this._ownerSVGElement=this._placeholderTemplate=this._previewTemplate=this._marker=this._parentDragRef=null}isDragging(){return this._hasStartedDragging()&&this._dragDropRegistry.isDragging(this)}reset(){this._rootElement.style.transform=this._initialTransform||"",this._activeTransform={x:0,y:0},this._passiveTransform={x:0,y:0}}resetToBoundary(){if(this._boundaryElement&&this._rootElement&&ire(this._boundaryElement.getBoundingClientRect(),this._rootElement.getBoundingClientRect())){let e=this._boundaryElement.getBoundingClientRect(),t=this._rootElement.getBoundingClientRect(),i=0,r=0;t.left<e.left?i=e.left-t.left:t.right>e.right&&(i=e.right-t.right),t.top<e.top?r=e.top-t.top:t.bottom>e.bottom&&(r=e.bottom-t.bottom);let o=this._activeTransform.x,a=this._activeTransform.y,s=o+i,l=a+r;this._rootElement.style.transform=S_(s,l),this._activeTransform={x:s,y:l},this._passiveTransform={x:s,y:l}}}disableHandle(e){!this._disabledHandles.has(e)&&this._handles.indexOf(e)>-1&&(this._disabledHandles.add(e),Tf(e,!0))}enableHandle(e){this._disabledHandles.has(e)&&(this._disabledHandles.delete(e),Tf(e,this.disabled))}withDirection(e){return this._direction=e,this}_withDropContainer(e){this._dropContainer=e}getFreeDragPosition(){let e=this.isDragging()?this._activeTransform:this._passiveTransform;return{x:e.x,y:e.y}}setFreeDragPosition(e){return this._activeTransform={x:0,y:0},this._passiveTransform.x=e.x,this._passiveTransform.y=e.y,this._dropContainer||this._applyRootElementTransform(e.x,e.y),this}withPreviewContainer(e){return this._previewContainer=e,this}_sortFromLastPointerPosition(){let e=this._lastKnownPointerPosition;e&&this._dropContainer&&this._updateActiveDropContainer(this._getConstrainedPointerPosition(e),e)}_removeListeners(){this._pointerMoveSubscription.unsubscribe(),this._pointerUpSubscription.unsubscribe(),this._scrollSubscription.unsubscribe(),this._cleanupShadowRootSelectStart?.(),this._cleanupShadowRootSelectStart=void 0}_destroyPreview(){this._preview?.destroy(),this._preview=null}_destroyPlaceholder(){this._anchor?.remove(),this._placeholder?.remove(),this._placeholderRef?.destroy(),this._placeholder=this._anchor=this._placeholderRef=null}_pointerDown=e=>{if(this.beforeStarted.next(),this._handles.length){let t=this._getTargetHandle(e);t&&!this._disabledHandles.has(t)&&!this.disabled&&this._initializeDragSequence(t,e)}else this.disabled||this._initializeDragSequence(this._rootElement,e)};_pointerMove=e=>{let t=this._getPointerPositionOnPage(e);if(!this._hasStartedDragging()){let r=Math.abs(t.x-this._pickupPositionOnPage.x),o=Math.abs(t.y-this._pickupPositionOnPage.y);if(r+o>=this._config.dragStartThreshold){let s=Date.now()>=this._dragStartTime+this._getDragStartDelay(e),l=this._dropContainer;if(!s){this._endDragSequence(e);return}(!l||!l.isDragging()&&!l.isReceiving())&&(e.cancelable&&e.preventDefault(),this._hasStartedDragging.set(!0),this._ngZone.run(()=>this._startDragSequence(e)))}return}e.cancelable&&e.preventDefault();let i=this._getConstrainedPointerPosition(t);if(this._hasMoved=!0,this._lastKnownPointerPosition=t,this._updatePointerDirectionDelta(i),this._dropContainer)this._updateActiveDropContainer(i,t);else{let r=this.constrainPosition?this._initialDomRect:this._pickupPositionOnPage,o=this._activeTransform;o.x=i.x-r.x+this._passiveTransform.x,o.y=i.y-r.y+this._passiveTransform.y,this._applyRootElementTransform(o.x,o.y)}this._moveEvents.observers.length&&this._ngZone.run(()=>{this._moveEvents.next({source:this,pointerPosition:i,event:e,distance:this._getDragDistance(i),delta:this._pointerDirectionDelta})})};_pointerUp=e=>{this._endDragSequence(e)};_endDragSequence(e){if(this._dragDropRegistry.isDragging(this)&&(this._removeListeners(),this._dragDropRegistry.stopDragging(this),this._toggleNativeDragInteractions(),this._handles&&(this._rootElement.style.webkitTapHighlightColor=this._rootElementTapHighlight),!!this._hasStartedDragging()))if(this.released.next({source:this,event:e}),this._dropContainer)this._dropContainer._stopScrolling(),this._animatePreviewToPlaceholder().then(()=>{this._cleanupDragArtifacts(e),this._cleanupCachedDimensions(),this._dragDropRegistry.stopDragging(this)});else{this._passiveTransform.x=this._activeTransform.x;let t=this._getPointerPositionOnPage(e);this._passiveTransform.y=this._activeTransform.y,this._ngZone.run(()=>{this.ended.next({source:this,distance:this._getDragDistance(t),dropPoint:t,event:e})}),this._cleanupCachedDimensions(),this._dragDropRegistry.stopDragging(this)}}_startDragSequence(e){w_(e)&&(this._lastTouchEventTime=Date.now()),this._toggleNativeDragInteractions();let t=this._getShadowRoot(),i=this._dropContainer;if(t&&this._ngZone.runOutsideAngular(()=>{this._cleanupShadowRootSelectStart=this._renderer.listen(t,"selectstart",cre,sre)}),i){let r=this._rootElement,o=r.parentNode,a=this._placeholder=this._createPlaceholderElement(),s=this._marker=this._marker||this._document.createComment("");o.insertBefore(s,r),this._initialTransform=r.style.transform||"",this._preview=new dE(this._document,this._rootElement,this._direction,this._initialDomRect,this._previewTemplate||null,this.previewClass||null,this._pickupPositionOnPage,this._initialTransform,this._config.zIndex||1e3,this._renderer),this._preview.attach(this._getPreviewInsertionPoint(o,t)),BF(r,!1,UF),this._document.body.appendChild(o.replaceChild(a,r)),this.started.next({source:this,event:e}),i.start(),this._initialContainer=i,this._initialIndex=i.getItemIndex(this)}else this.started.next({source:this,event:e}),this._initialContainer=this._initialIndex=void 0;this._parentPositions.cache(i?i.getScrollableParents():[])}_initializeDragSequence(e,t){this._parentDragRef&&t.stopPropagation();let i=this.isDragging(),r=w_(t),o=!r&&t.button!==0,a=this._rootElement,s=e0(t),l=!r&&this._lastTouchEventTime&&this._lastTouchEventTime+lre>Date.now(),c=r?e1(t):J_(t);if(s&&s.draggable&&t.type==="mousedown"&&t.preventDefault(),i||o||l||c)return;if(this._handles.length){let m=a.style;this._rootElementTapHighlight=m.webkitTapHighlightColor||"",m.webkitTapHighlightColor="transparent"}this._hasMoved=!1,this._hasStartedDragging.set(this._hasMoved),this._removeListeners(),this._initialDomRect=this._rootElement.getBoundingClientRect(),this._pointerMoveSubscription=this._dragDropRegistry.pointerMove.subscribe(this._pointerMove),this._pointerUpSubscription=this._dragDropRegistry.pointerUp.subscribe(this._pointerUp),this._scrollSubscription=this._dragDropRegistry.scrolled(this._getShadowRoot()).subscribe(m=>this._updateOnScroll(m)),this._boundaryElement&&(this._boundaryRect=fE(this._boundaryElement));let d=this._previewTemplate;this._pickupPositionInElement=d&&d.template&&!d.matchSize?{x:0,y:0}:this._getPointerPositionInElement(this._initialDomRect,e,t);let h=this._pickupPositionOnPage=this._lastKnownPointerPosition=this._getPointerPositionOnPage(t);this._pointerDirectionDelta={x:0,y:0},this._pointerPositionAtLastDirectionChange={x:h.x,y:h.y},this._dragStartTime=Date.now(),this._dragDropRegistry.startDragging(this,t)}_cleanupDragArtifacts(e){BF(this._rootElement,!0,UF),this._marker.parentNode.replaceChild(this._rootElement,this._marker),this._destroyPreview(),this._destroyPlaceholder(),this._initialDomRect=this._boundaryRect=this._previewRect=this._initialTransform=void 0,this._ngZone.run(()=>{let t=this._dropContainer,i=t.getItemIndex(this),r=this._getPointerPositionOnPage(e),o=this._getDragDistance(r),a=t._isOverContainer(r.x,r.y);this.ended.next({source:this,distance:o,dropPoint:r,event:e}),this.dropped.next({item:this,currentIndex:i,previousIndex:this._initialIndex,container:t,previousContainer:this._initialContainer,isPointerOverContainer:a,distance:o,dropPoint:r,event:e}),t.drop(this,i,this._initialIndex,this._initialContainer,a,o,r,e),this._dropContainer=this._initialContainer})}_updateActiveDropContainer({x:e,y:t},{x:i,y:r}){let o=this._initialContainer._getSiblingContainerFromPosition(this,e,t);!o&&this._dropContainer!==this._initialContainer&&this._initialContainer._isOverContainer(e,t)&&(o=this._initialContainer),o&&o!==this._dropContainer&&this._ngZone.run(()=>{let a=this._dropContainer.getItemIndex(this),s=this._dropContainer.getItemAtIndex(a+1)?.getVisibleElement()||null;this.exited.next({item:this,container:this._dropContainer}),this._dropContainer.exit(this),this._conditionallyInsertAnchor(o,this._dropContainer,s),this._dropContainer=o,this._dropContainer.enter(this,e,t,o===this._initialContainer&&o.sortingDisabled?this._initialIndex:void 0),this.entered.next({item:this,container:o,currentIndex:o.getItemIndex(this)})}),this.isDragging()&&(this._dropContainer._startScrollingIfNecessary(i,r),this._dropContainer._sortItem(this,e,t,this._pointerDirectionDelta),this.constrainPosition?this._applyPreviewTransform(e,t):this._applyPreviewTransform(e-this._pickupPositionInElement.x,t-this._pickupPositionInElement.y))}_animatePreviewToPlaceholder(){if(!this._hasMoved)return Promise.resolve();let e=this._placeholder.getBoundingClientRect();this._preview.addClass("cdk-drag-animating"),this._applyPreviewTransform(e.left,e.top);let t=this._preview.getTransitionDuration();return t===0?Promise.resolve():this._ngZone.runOutsideAngular(()=>new Promise(i=>{let r=s=>{(!s||this._preview&&e0(s)===this._preview.element&&s.propertyName==="transform")&&(a(),i(),clearTimeout(o))},o=setTimeout(r,t*1.5),a=this._preview.addEventListener("transitionend",r)}))}_createPlaceholderElement(){let e=this._placeholderTemplate,t=e?e.template:null,i;return t?(this._placeholderRef=e.viewContainer.createEmbeddedView(t,e.context),this._placeholderRef.detectChanges(),i=qF(this._placeholderRef,this._document)):i=lE(this._rootElement),i.style.pointerEvents="none",i.classList.add(WF),i}_getPointerPositionInElement(e,t,i){let r=t===this._rootElement?null:t,o=r?r.getBoundingClientRect():e,a=w_(i)?i.targetTouches[0]:i,s=this._getViewportScrollPosition(),l=a.pageX-o.left-s.left,c=a.pageY-o.top-s.top;return{x:o.left-e.left+l,y:o.top-e.top+c}}_getPointerPositionOnPage(e){let t=this._getViewportScrollPosition(),i=w_(e)?e.touches[0]||e.changedTouches[0]||{pageX:0,pageY:0}:e,r=i.pageX-t.left,o=i.pageY-t.top;if(this._ownerSVGElement){let a=this._ownerSVGElement.getScreenCTM();if(a){let s=this._ownerSVGElement.createSVGPoint();return s.x=r,s.y=o,s.matrixTransform(a.inverse())}}return{x:r,y:o}}_getConstrainedPointerPosition(e){let t=this._dropContainer?this._dropContainer.lockAxis:null,{x:i,y:r}=this.constrainPosition?this.constrainPosition(e,this,this._initialDomRect,this._pickupPositionInElement):e;if(this.lockAxis==="x"||t==="x"?r=this._pickupPositionOnPage.y-(this.constrainPosition?this._pickupPositionInElement.y:0):(this.lockAxis==="y"||t==="y")&&(i=this._pickupPositionOnPage.x-(this.constrainPosition?this._pickupPositionInElement.x:0)),this._boundaryRect){let{x:o,y:a}=this.constrainPosition?{x:0,y:0}:this._pickupPositionInElement,s=this._boundaryRect,{width:l,height:c}=this._getPreviewRect(),d=s.top+a,h=s.bottom-(c-a),m=s.left+o,f=s.right-(l-o);i=HF(i,m,f),r=HF(r,d,h)}return{x:i,y:r}}_updatePointerDirectionDelta(e){let{x:t,y:i}=e,r=this._pointerDirectionDelta,o=this._pointerPositionAtLastDirectionChange,a=Math.abs(t-o.x),s=Math.abs(i-o.y);return a>this._config.pointerDirectionChangeThreshold&&(r.x=t>o.x?1:-1,o.x=t),s>this._config.pointerDirectionChangeThreshold&&(r.y=i>o.y?1:-1,o.y=i),r}_toggleNativeDragInteractions(){if(!this._rootElement||!this._handles)return;let e=this._handles.length>0||!this.isDragging();e!==this._nativeInteractionsEnabled&&(this._nativeInteractionsEnabled=e,Tf(this._rootElement,e))}_removeRootElementListeners(){this._rootElementCleanups?.forEach(e=>e()),this._rootElementCleanups=void 0}_applyRootElementTransform(e,t){let i=1/this.scale,r=S_(e*i,t*i),o=this._rootElement.style;this._initialTransform==null&&(this._initialTransform=o.transform&&o.transform!="none"?o.transform:""),o.transform=x2(r,this._initialTransform)}_applyPreviewTransform(e,t){let i=this._previewTemplate?.template?void 0:this._initialTransform,r=S_(e,t);this._preview.setTransform(x2(r,i))}_getDragDistance(e){let t=this._pickupPositionOnPage;return t?{x:e.x-t.x,y:e.y-t.y}:{x:0,y:0}}_cleanupCachedDimensions(){this._boundaryRect=this._previewRect=void 0,this._parentPositions.clear()}_containInsideBoundaryOnResize(){let{x:e,y:t}=this._passiveTransform;if(e===0&&t===0||this.isDragging()||!this._boundaryElement)return;let i=this._rootElement.getBoundingClientRect(),r=this._boundaryElement.getBoundingClientRect();if(r.width===0&&r.height===0||i.width===0&&i.height===0)return;let o=r.left-i.left,a=i.right-r.right,s=r.top-i.top,l=i.bottom-r.bottom;r.width>i.width?(o>0&&(e+=o),a>0&&(e-=a)):e=0,r.height>i.height?(s>0&&(t+=s),l>0&&(t-=l)):t=0,(e!==this._passiveTransform.x||t!==this._passiveTransform.y)&&this.setFreeDragPosition({y:t,x:e})}_getDragStartDelay(e){let t=this.dragStartDelay;return typeof t=="number"?t:w_(e)?t.touch:t?t.mouse:0}_updateOnScroll(e){let t=this._parentPositions.handleScroll(e);if(t){let i=e0(e);this._boundaryRect&&i!==this._boundaryElement&&i.contains(this._boundaryElement)&&M_(this._boundaryRect,t.top,t.left),this._pickupPositionOnPage.x+=t.left,this._pickupPositionOnPage.y+=t.top,this._dropContainer||(this._activeTransform.x-=t.left,this._activeTransform.y-=t.top,this._applyRootElementTransform(this._activeTransform.x,this._activeTransform.y))}}_getViewportScrollPosition(){return this._parentPositions.positions.get(this._document)?.scrollPosition||this._parentPositions.getViewportScrollPosition()}_getShadowRoot(){return this._cachedShadowRoot===void 0&&(this._cachedShadowRoot=Y_(this._rootElement)),this._cachedShadowRoot}_getPreviewInsertionPoint(e,t){let i=this._previewContainer||"global";if(i==="parent")return e;if(i==="global"){let r=this._document;return t||r.fullscreenElement||r.webkitFullscreenElement||r.mozFullScreenElement||r.msFullscreenElement||r.body}return Ec(i)}_getPreviewRect(){return(!this._previewRect||!this._previewRect.width&&!this._previewRect.height)&&(this._previewRect=this._preview?this._preview.getBoundingClientRect():this._initialDomRect),this._previewRect}_nativeDragStart=e=>{if(this._handles.length){let t=this._getTargetHandle(e);t&&!this._disabledHandles.has(t)&&!this.disabled&&e.preventDefault()}else this.disabled||e.preventDefault()};_getTargetHandle(e){return this._handles.find(t=>e.target&&(e.target===t||t.contains(e.target)))}_conditionallyInsertAnchor(e,t,i){if(e===this._initialContainer)this._anchor?.remove(),this._anchor=null;else if(t===this._initialContainer&&t.hasAnchor){let r=this._anchor??=lE(this._placeholder);r.classList.remove(WF),r.classList.add("cdk-drag-anchor"),r.style.transform="",i?i.before(r):Ec(t.element).appendChild(r)}}};function HF(n,e,t){return Math.max(e,Math.min(t,n))}function w_(n){return n.type[0]==="t"}function cre(n){n.preventDefault()}function il(n,e,t){let i=pE(e,n.length-1),r=pE(t,n.length-1);if(i===r)return;let o=n[i],a=r<i?-1:1;for(let s=i;s!==r;s+=a)n[s]=n[s+a];n[r]=o}function XF(n,e,t,i){let r=pE(i,e.length);n.length&&e.splice(r,0,n[t])}function pE(n,e){return Math.max(0,Math.min(e,n))}var C2=class{_dragDropRegistry;_element;_sortPredicate;_itemPositions=[];_activeDraggables;orientation="vertical";direction="ltr";constructor(e){this._dragDropRegistry=e}_previousSwap={drag:null,delta:0,overlaps:!1};start(e){this.withItems(e)}sort(e,t,i,r){let o=this._itemPositions,a=this._getItemIndexFromPointerPosition(e,t,i,r);if(a===-1&&o.length>0)return null;let s=this.orientation==="horizontal",l=o.findIndex(S=>S.drag===e),c=o[a],d=o[l].clientRect,h=c.clientRect,m=l>a?1:-1,f=this._getItemOffsetPx(d,h,m),y=this._getSiblingOffsetPx(l,o,m),b=o.slice();return il(o,l,a),o.forEach((S,I)=>{if(b[I]===S)return;let D=S.drag===e,E=D?f:y,C=D?e.getPlaceholderElement():S.drag.getRootElement();S.offset+=E;let x=Math.round(S.offset*(1/S.drag.scale));s?(C.style.transform=x2(`translate3d(${x}px, 0, 0)`,S.initialTransform),M_(S.clientRect,0,E)):(C.style.transform=x2(`translate3d(0, ${x}px, 0)`,S.initialTransform),M_(S.clientRect,E,0))}),this._previousSwap.overlaps=cE(h,t,i),this._previousSwap.drag=c.drag,this._previousSwap.delta=s?r.x:r.y,{previousIndex:l,currentIndex:a}}enter(e,t,i,r){let o=this._activeDraggables,a=o.indexOf(e),s=e.getPlaceholderElement();a>-1&&o.splice(a,1);let l=r==null||r<0?this._getItemIndexFromPointerPosition(e,t,i):r,c=o[l];if(c===e&&(c=o[l+1]),!c&&(l==null||l===-1||l<o.length-1)&&this._shouldEnterAsFirstChild(t,i)&&(c=o[0]),c&&!this._dragDropRegistry.isDragging(c)){let d=c.getRootElement();d.parentElement.insertBefore(s,d),o.splice(l,0,e)}else this._element.appendChild(s),o.push(e);s.style.transform="",this._cacheItemPositions()}withItems(e){this._activeDraggables=e.slice(),this._cacheItemPositions()}withSortPredicate(e){this._sortPredicate=e}reset(){this._activeDraggables?.forEach(e=>{let t=e.getRootElement();if(t){let i=this._itemPositions.find(r=>r.drag===e)?.initialTransform;t.style.transform=i||""}}),this._itemPositions=[],this._activeDraggables=[],this._previousSwap.drag=null,this._previousSwap.delta=0,this._previousSwap.overlaps=!1}getActiveItemsSnapshot(){return this._activeDraggables}getItemIndex(e){return this._getVisualItemPositions().findIndex(t=>t.drag===e)}getItemAtIndex(e){return this._getVisualItemPositions()[e]?.drag||null}updateOnScroll(e,t){this._itemPositions.forEach(({clientRect:i})=>{M_(i,e,t)}),this._itemPositions.forEach(({drag:i})=>{this._dragDropRegistry.isDragging(i)&&i._sortFromLastPointerPosition()})}withElementContainer(e){this._element=e}_cacheItemPositions(){let e=this.orientation==="horizontal";this._itemPositions=this._activeDraggables.map(t=>{let i=t.getVisibleElement();return{drag:t,offset:0,initialTransform:i.style.transform||"",clientRect:fE(i)}}).sort((t,i)=>e?t.clientRect.left-i.clientRect.left:t.clientRect.top-i.clientRect.top)}_getVisualItemPositions(){return this.orientation==="horizontal"&&this.direction==="rtl"?this._itemPositions.slice().reverse():this._itemPositions}_getItemOffsetPx(e,t,i){let r=this.orientation==="horizontal",o=r?t.left-e.left:t.top-e.top;return i===-1&&(o+=r?t.width-e.width:t.height-e.height),o}_getSiblingOffsetPx(e,t,i){let r=this.orientation==="horizontal",o=t[e].clientRect,a=t[e+i*-1],s=o[r?"width":"height"]*i;if(a){let l=r?"left":"top",c=r?"right":"bottom";i===-1?s-=a.clientRect[l]-o[c]:s+=o[l]-a.clientRect[c]}return s}_shouldEnterAsFirstChild(e,t){if(!this._activeDraggables.length)return!1;let i=this._itemPositions,r=this.orientation==="horizontal";if(i[0].drag!==this._activeDraggables[0]){let a=i[i.length-1].clientRect;return r?e>=a.right:t>=a.bottom}else{let a=i[0].clientRect;return r?e<=a.left:t<=a.top}}_getItemIndexFromPointerPosition(e,t,i,r){let o=this.orientation==="horizontal",a=this._itemPositions.findIndex(({drag:s,clientRect:l})=>{if(s===e)return!1;if(r){let c=o?r.x:r.y;if(s===this._previousSwap.drag&&this._previousSwap.overlaps&&c===this._previousSwap.delta)return!1}return o?t>=Math.floor(l.left)&&t<Math.floor(l.right):i>=Math.floor(l.top)&&i<Math.floor(l.bottom)});return a===-1||!this._sortPredicate(a,e)?-1:a}},hE=class{_document;_dragDropRegistry;_element;_sortPredicate;_rootNode;_activeItems;_previousSwap={drag:null,deltaX:0,deltaY:0,overlaps:!1};_relatedNodes=[];constructor(e,t){this._document=e,this._dragDropRegistry=t}start(e){let t=this._element.childNodes;this._relatedNodes=[];for(let i=0;i<t.length;i++){let r=t[i];this._relatedNodes.push([r,r.nextSibling])}this.withItems(e)}sort(e,t,i,r){let o=this._getItemIndexFromPointerPosition(e,t,i),a=this._previousSwap;if(o===-1||this._activeItems[o]===e)return null;let s=this._activeItems[o];if(a.drag===s&&a.overlaps&&a.deltaX===r.x&&a.deltaY===r.y)return null;let l=this.getItemIndex(e),c=e.getPlaceholderElement(),d=s.getRootElement();o>l?d.after(c):d.before(c),il(this._activeItems,l,o);let h=this._getRootNode().elementFromPoint(t,i);return a.deltaX=r.x,a.deltaY=r.y,a.drag=s,a.overlaps=d===h||d.contains(h),{previousIndex:l,currentIndex:o}}enter(e,t,i,r){let o=this._activeItems.indexOf(e);o>-1&&this._activeItems.splice(o,1);let a=r==null||r<0?this._getItemIndexFromPointerPosition(e,t,i):r;a===-1&&(a=this._getClosestItemIndexToPointer(e,t,i));let s=this._activeItems[a];s&&!this._dragDropRegistry.isDragging(s)?(this._activeItems.splice(a,0,e),s.getRootElement().before(e.getPlaceholderElement())):(this._activeItems.push(e),this._element.appendChild(e.getPlaceholderElement()))}withItems(e){this._activeItems=e.slice()}withSortPredicate(e){this._sortPredicate=e}reset(){let e=this._element,t=this._previousSwap;for(let i=this._relatedNodes.length-1;i>-1;i--){let[r,o]=this._relatedNodes[i];r.parentNode===e&&r.nextSibling!==o&&(o===null?e.appendChild(r):o.parentNode===e&&e.insertBefore(r,o))}this._relatedNodes=[],this._activeItems=[],t.drag=null,t.deltaX=t.deltaY=0,t.overlaps=!1}getActiveItemsSnapshot(){return this._activeItems}getItemIndex(e){return this._activeItems.indexOf(e)}getItemAtIndex(e){return this._activeItems[e]||null}updateOnScroll(){this._activeItems.forEach(e=>{this._dragDropRegistry.isDragging(e)&&e._sortFromLastPointerPosition()})}withElementContainer(e){e!==this._element&&(this._element=e,this._rootNode=void 0)}_getItemIndexFromPointerPosition(e,t,i){let r=this._getRootNode().elementFromPoint(Math.floor(t),Math.floor(i)),o=r?this._activeItems.findIndex(a=>{let s=a.getRootElement();return r===s||s.contains(r)}):-1;return o===-1||!this._sortPredicate(o,e)?-1:o}_getRootNode(){return this._rootNode||(this._rootNode=Y_(this._element)||this._document),this._rootNode}_getClosestItemIndexToPointer(e,t,i){if(this._activeItems.length===0)return-1;if(this._activeItems.length===1)return 0;let r=1/0,o=-1;for(let a=0;a<this._activeItems.length;a++){let s=this._activeItems[a];if(s!==e){let{x:l,y:c}=s.getRootElement().getBoundingClientRect(),d=Math.hypot(t-l,i-c);d<r&&(r=d,o=a)}}return o}},KF=.05,YF=.05,tl=(function(n){return n[n.NONE=0]="NONE",n[n.UP=1]="UP",n[n.DOWN=2]="DOWN",n})(tl||{}),xa=(function(n){return n[n.NONE=0]="NONE",n[n.LEFT=1]="LEFT",n[n.RIGHT=2]="RIGHT",n})(xa||{});function QF(n,e){return new mE(e,n.get(M2),n.get(Go),n.get(Gi),n.get(jp))}var mE=class{_dragDropRegistry;_ngZone;_viewportRuler;element;disabled=!1;sortingDisabled=!1;lockAxis=null;autoScrollDisabled=!1;autoScrollStep=2;hasAnchor=!1;enterPredicate=()=>!0;sortPredicate=()=>!0;beforeStarted=new ze;entered=new ze;exited=new ze;dropped=new ze;sorted=new ze;receivingStarted=new ze;receivingStopped=new ze;data;_container;_isDragging=!1;_parentPositions;_sortStrategy;_domRect;_draggables=[];_siblings=[];_activeSiblings=new Set;_viewportScrollSubscription=rr.EMPTY;_verticalScrollDirection=tl.NONE;_horizontalScrollDirection=xa.NONE;_scrollNode;_stopScrollTimers=new ze;_cachedShadowRoot=null;_document;_scrollableElements=[];_initialScrollSnap;_direction="ltr";constructor(e,t,i,r,o){this._dragDropRegistry=t,this._ngZone=r,this._viewportRuler=o;let a=this.element=Ec(e);this._document=i,this.withOrientation("vertical").withElementContainer(a),t.registerDropContainer(this),this._parentPositions=new b2(i)}dispose(){this._stopScrolling(),this._stopScrollTimers.complete(),this._viewportScrollSubscription.unsubscribe(),this.beforeStarted.complete(),this.entered.complete(),this.exited.complete(),this.dropped.complete(),this.sorted.complete(),this.receivingStarted.complete(),this.receivingStopped.complete(),this._activeSiblings.clear(),this._scrollNode=null,this._parentPositions.clear(),this._dragDropRegistry.removeDropContainer(this)}isDragging(){return this._isDragging}start(){this._draggingStarted(),this._notifyReceivingSiblings()}enter(e,t,i,r){this._draggingStarted(),r==null&&this.sortingDisabled&&(r=this._draggables.indexOf(e)),this._sortStrategy.enter(e,t,i,r),this._cacheParentPositions(),this._notifyReceivingSiblings(),this.entered.next({item:e,container:this,currentIndex:this.getItemIndex(e)})}exit(e){this._reset(),this.exited.next({item:e,container:this})}drop(e,t,i,r,o,a,s,l={}){this._reset(),this.dropped.next({item:e,currentIndex:t,previousIndex:i,container:this,previousContainer:r,isPointerOverContainer:o,distance:a,dropPoint:s,event:l})}withItems(e){let t=this._draggables;return this._draggables=e,e.forEach(i=>i._withDropContainer(this)),this.isDragging()&&(t.filter(r=>r.isDragging()).every(r=>e.indexOf(r)===-1)?this._reset():this._sortStrategy.withItems(this._draggables)),this}withDirection(e){return this._direction=e,this._sortStrategy instanceof C2&&(this._sortStrategy.direction=e),this}connectedTo(e){return this._siblings=e.slice(),this}withOrientation(e){if(e==="mixed")this._sortStrategy=new hE(this._document,this._dragDropRegistry);else{let t=new C2(this._dragDropRegistry);t.direction=this._direction,t.orientation=e,this._sortStrategy=t}return this._sortStrategy.withElementContainer(this._container),this._sortStrategy.withSortPredicate((t,i)=>this.sortPredicate(t,i,this)),this}withScrollableParents(e){let t=this._container;return this._scrollableElements=e.indexOf(t)===-1?[t,...e]:e.slice(),this}withElementContainer(e){if(e===this._container)return this;let t=Ec(this.element),i=this._scrollableElements.indexOf(this._container),r=this._scrollableElements.indexOf(e);return i>-1&&this._scrollableElements.splice(i,1),r>-1&&this._scrollableElements.splice(r,1),this._sortStrategy&&this._sortStrategy.withElementContainer(e),this._cachedShadowRoot=null,this._scrollableElements.unshift(e),this._container=e,this}getScrollableParents(){return this._scrollableElements}getItemIndex(e){return this._isDragging?this._sortStrategy.getItemIndex(e):this._draggables.indexOf(e)}getItemAtIndex(e){return this._isDragging?this._sortStrategy.getItemAtIndex(e):this._draggables[e]||null}isReceiving(){return this._activeSiblings.size>0}_sortItem(e,t,i,r){if(this.sortingDisabled||!this._domRect||!NF(this._domRect,KF,t,i))return;let o=this._sortStrategy.sort(e,t,i,r);o&&this.sorted.next({previousIndex:o.previousIndex,currentIndex:o.currentIndex,container:this,item:e})}_startScrollingIfNecessary(e,t){if(this.autoScrollDisabled)return;let i,r=tl.NONE,o=xa.NONE;if(this._parentPositions.positions.forEach((a,s)=>{s===this._document||!a.clientRect||i||NF(a.clientRect,KF,e,t)&&([r,o]=dre(s,a.clientRect,this._direction,e,t),(r||o)&&(i=s))}),!r&&!o){let{width:a,height:s}=this._viewportRuler.getViewportSize(),l={width:a,height:s,top:0,right:a,bottom:s,left:0};r=JF(l,t),o=eN(l,e),i=window}i&&(r!==this._verticalScrollDirection||o!==this._horizontalScrollDirection||i!==this._scrollNode)&&(this._verticalScrollDirection=r,this._horizontalScrollDirection=o,this._scrollNode=i,(r||o)&&i?this._ngZone.runOutsideAngular(this._startScrollInterval):this._stopScrolling())}_stopScrolling(){this._stopScrollTimers.next()}_draggingStarted(){let e=this._container.style;this.beforeStarted.next(),this._isDragging=!0,this._initialScrollSnap=e.msScrollSnapType||e.scrollSnapType||"",e.scrollSnapType=e.msScrollSnapType="none",this._sortStrategy.start(this._draggables),this._cacheParentPositions(),this._viewportScrollSubscription.unsubscribe(),this._listenToScrollEvents()}_cacheParentPositions(){this._parentPositions.cache(this._scrollableElements),this._domRect=this._parentPositions.positions.get(this._container).clientRect}_reset(){this._isDragging=!1;let e=this._container.style;e.scrollSnapType=e.msScrollSnapType=this._initialScrollSnap,this._siblings.forEach(t=>t._stopReceiving(this)),this._sortStrategy.reset(),this._stopScrolling(),this._viewportScrollSubscription.unsubscribe(),this._parentPositions.clear()}_startScrollInterval=()=>{this._stopScrolling(),hI(0,dI).pipe(xi(this._stopScrollTimers)).subscribe(()=>{let e=this._scrollNode,t=this.autoScrollStep;this._verticalScrollDirection===tl.UP?e.scrollBy(0,-t):this._verticalScrollDirection===tl.DOWN&&e.scrollBy(0,t),this._horizontalScrollDirection===xa.LEFT?e.scrollBy(-t,0):this._horizontalScrollDirection===xa.RIGHT&&e.scrollBy(t,0)})};_isOverContainer(e,t){return this._domRect!=null&&cE(this._domRect,e,t)}_getSiblingContainerFromPosition(e,t,i){return this._siblings.find(r=>r._canReceive(e,t,i))}_canReceive(e,t,i){if(!this._domRect||!cE(this._domRect,t,i)||!this.enterPredicate(e,this))return!1;let r=this._getShadowRoot().elementFromPoint(t,i);return r?r===this._container||this._container.contains(r):!1}_startReceiving(e,t){let i=this._activeSiblings;!i.has(e)&&t.every(r=>this.enterPredicate(r,this)||this._draggables.indexOf(r)>-1)&&(i.add(e),this._cacheParentPositions(),this._listenToScrollEvents(),this.receivingStarted.next({initiator:e,receiver:this,items:t}))}_stopReceiving(e){this._activeSiblings.delete(e),this._viewportScrollSubscription.unsubscribe(),this.receivingStopped.next({initiator:e,receiver:this})}_listenToScrollEvents(){this._viewportScrollSubscription=this._dragDropRegistry.scrolled(this._getShadowRoot()).subscribe(e=>{if(this.isDragging()){let t=this._parentPositions.handleScroll(e);t&&this._sortStrategy.updateOnScroll(t.top,t.left)}else this.isReceiving()&&this._cacheParentPositions()})}_getShadowRoot(){if(!this._cachedShadowRoot){let e=Y_(this._container);this._cachedShadowRoot=e||this._document}return this._cachedShadowRoot}_notifyReceivingSiblings(){let e=this._sortStrategy.getActiveItemsSnapshot().filter(t=>t.isDragging());this._siblings.forEach(t=>t._startReceiving(this,e))}};function JF(n,e){let{top:t,bottom:i,height:r}=n,o=r*YF;return e>=t-o&&e<=t+o?tl.UP:e>=i-o&&e<=i+o?tl.DOWN:tl.NONE}function eN(n,e){let{left:t,right:i,width:r}=n,o=r*YF;return e>=t-o&&e<=t+o?xa.LEFT:e>=i-o&&e<=i+o?xa.RIGHT:xa.NONE}function dre(n,e,t,i,r){let o=JF(e,r),a=eN(e,i),s=tl.NONE,l=xa.NONE;if(o){let c=n.scrollTop;o===tl.UP?c>0&&(s=tl.UP):n.scrollHeight-c>n.clientHeight&&(s=tl.DOWN)}if(a){let c=n.scrollLeft;t==="rtl"?a===xa.RIGHT?c<0&&(l=xa.RIGHT):n.scrollWidth+c>n.clientWidth&&(l=xa.LEFT):a===xa.LEFT?c>0&&(l=xa.LEFT):n.scrollWidth-c>n.clientWidth&&(l=xa.RIGHT)}return[s,l]}var ure=(()=>{class n{_injector=M(Kr);constructor(){}createDrag(t,i){return ZF(this._injector,t,i)}createDropList(t){return QF(this._injector,t)}static \u0275fac=function(i){return new(i||n)};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),w2=new xt("CDK_DRAG_PARENT");var tN=new xt("CdkDragHandle"),Cu=(()=>{class n{element=M(Ct);_parentDrag=M(w2,{optional:!0,skipSelf:!0});_dragDropRegistry=M(M2);_stateChanges=new ze;get disabled(){return this._disabled}set disabled(t){this._disabled=t,this._stateChanges.next(this)}_disabled=!1;constructor(){this._parentDrag?._addHandle(this)}ngAfterViewInit(){if(!this._parentDrag){let t=this.element.nativeElement.parentElement;for(;t;){let i=this._dragDropRegistry.getDragDirectiveForNode(t);if(i){this._parentDrag=i,i._addHandle(this);break}t=t.parentElement}}}ngOnDestroy(){this._parentDrag?._removeHandle(this),this._stateChanges.complete()}static \u0275fac=function(i){return new(i||n)};static \u0275dir=lt({type:n,selectors:[["","cdkDragHandle",""]],hostAttrs:[1,"cdk-drag-handle"],inputs:{disabled:[2,"cdkDragHandleDisabled","disabled",Ue]},features:[Lt([{provide:tN,useExisting:n}])]})}return n})(),iN=new xt("CDK_DRAG_CONFIG"),nN=new xt("CdkDropList"),Qa=(()=>{class n{element=M(Ct);dropContainer=M(nN,{optional:!0,skipSelf:!0});_ngZone=M(Gi);_viewContainerRef=M(pa);_dir=M(co,{optional:!0});_changeDetectorRef=M(re);_selfHandle=M(tN,{optional:!0,self:!0});_parentDrag=M(w2,{optional:!0,skipSelf:!0});_dragDropRegistry=M(M2);_destroyed=new ze;_handles=new al([]);_previewTemplate=null;_placeholderTemplate=null;_dragRef;data;lockAxis=null;rootElementSelector;boundaryElement;dragStartDelay;freeDragPosition;get disabled(){return this._disabled||!!(this.dropContainer&&this.dropContainer.disabled)}set disabled(t){this._disabled=t,this._dragRef.disabled=this._disabled}_disabled=!1;constrainPosition;previewClass;previewContainer;scale=1;started=new he;released=new he;ended=new he;entered=new he;exited=new he;dropped=new he;moved=new Ru(t=>{let i=this._dragRef.moved.pipe(Fr(r=>({source:this,pointerPosition:r.pointerPosition,event:r.event,delta:r.delta,distance:r.distance}))).subscribe(t);return()=>{i.unsubscribe()}});_injector=M(Kr);constructor(){let t=this.dropContainer,i=M(iN,{optional:!0});this._dragRef=ZF(this._injector,this.element,{dragStartThreshold:i&&i.dragStartThreshold!=null?i.dragStartThreshold:5,pointerDirectionChangeThreshold:i&&i.pointerDirectionChangeThreshold!=null?i.pointerDirectionChangeThreshold:5,zIndex:i?.zIndex}),this._dragRef.data=this,this._dragDropRegistry.registerDirectiveNode(this.element.nativeElement,this),i&&this._assignDefaults(i),t&&(t.addItem(this),t._dropListRef.beforeStarted.pipe(xi(this._destroyed)).subscribe(()=>{this._dragRef.scale=this.scale})),this._syncInputs(this._dragRef),this._handleEvents(this._dragRef)}getPlaceholderElement(){return this._dragRef.getPlaceholderElement()}getRootElement(){return this._dragRef.getRootElement()}reset(){this._dragRef.reset()}resetToBoundary(){this._dragRef.resetToBoundary()}getFreeDragPosition(){return this._dragRef.getFreeDragPosition()}setFreeDragPosition(t){this._dragRef.setFreeDragPosition(t)}ngAfterViewInit(){ll(()=>{this._updateRootElement(),this._setupHandlesListener(),this._dragRef.scale=this.scale,this.freeDragPosition&&this._dragRef.setFreeDragPosition(this.freeDragPosition)},{injector:this._injector})}ngOnChanges(t){let i=t.rootElementSelector,r=t.freeDragPosition;i&&!i.firstChange&&this._updateRootElement(),this._dragRef.scale=this.scale,r&&!r.firstChange&&this.freeDragPosition&&this._dragRef.setFreeDragPosition(this.freeDragPosition)}ngOnDestroy(){this.dropContainer&&this.dropContainer.removeItem(this),this._dragDropRegistry.removeDirectiveNode(this.element.nativeElement),this._ngZone.runOutsideAngular(()=>{this._handles.complete(),this._destroyed.next(),this._destroyed.complete(),this._dragRef.dispose()})}_addHandle(t){let i=this._handles.getValue();i.push(t),this._handles.next(i)}_removeHandle(t){let i=this._handles.getValue(),r=i.indexOf(t);r>-1&&(i.splice(r,1),this._handles.next(i))}_setPreviewTemplate(t){this._previewTemplate=t}_resetPreviewTemplate(t){t===this._previewTemplate&&(this._previewTemplate=null)}_setPlaceholderTemplate(t){this._placeholderTemplate=t}_resetPlaceholderTemplate(t){t===this._placeholderTemplate&&(this._placeholderTemplate=null)}_updateRootElement(){let t=this.element.nativeElement,i=t;this.rootElementSelector&&(i=t.closest!==void 0?t.closest(this.rootElementSelector):t.parentElement?.closest(this.rootElementSelector)),this._dragRef.withRootElement(i||t)}_getBoundaryElement(){let t=this.boundaryElement;return t?typeof t=="string"?this.element.nativeElement.closest(t):Ec(t):null}_syncInputs(t){t.beforeStarted.subscribe(()=>{if(!t.isDragging()){let i=this._dir,r=this.dragStartDelay,o=this._placeholderTemplate?{template:this._placeholderTemplate.templateRef,context:this._placeholderTemplate.data,viewContainer:this._viewContainerRef}:null,a=this._previewTemplate?{template:this._previewTemplate.templateRef,context:this._previewTemplate.data,matchSize:this._previewTemplate.matchSize,viewContainer:this._viewContainerRef}:null;t.disabled=this.disabled,t.lockAxis=this.lockAxis,t.scale=this.scale,t.dragStartDelay=typeof r=="object"&&r?r:zC(r),t.constrainPosition=this.constrainPosition,t.previewClass=this.previewClass,t.withBoundaryElement(this._getBoundaryElement()).withPlaceholderTemplate(o).withPreviewTemplate(a).withPreviewContainer(this.previewContainer||"global"),i&&t.withDirection(i.value)}}),t.beforeStarted.pipe(Vo(1)).subscribe(()=>{if(this._parentDrag){t.withParent(this._parentDrag._dragRef);return}let i=this.element.nativeElement.parentElement;for(;i;){let r=this._dragDropRegistry.getDragDirectiveForNode(i);if(r){t.withParent(r._dragRef);break}i=i.parentElement}})}_handleEvents(t){t.started.subscribe(i=>{this.started.emit({source:this,event:i.event}),this._changeDetectorRef.markForCheck()}),t.released.subscribe(i=>{this.released.emit({source:this,event:i.event})}),t.ended.subscribe(i=>{this.ended.emit({source:this,distance:i.distance,dropPoint:i.dropPoint,event:i.event}),this._changeDetectorRef.markForCheck()}),t.entered.subscribe(i=>{this.entered.emit({container:i.container.data,item:this,currentIndex:i.currentIndex})}),t.exited.subscribe(i=>{this.exited.emit({container:i.container.data,item:this})}),t.dropped.subscribe(i=>{this.dropped.emit({previousIndex:i.previousIndex,currentIndex:i.currentIndex,previousContainer:i.previousContainer.data,container:i.container.data,isPointerOverContainer:i.isPointerOverContainer,item:this,distance:i.distance,dropPoint:i.dropPoint,event:i.event})})}_assignDefaults(t){let{lockAxis:i,dragStartDelay:r,constrainPosition:o,previewClass:a,boundaryElement:s,draggingDisabled:l,rootElementSelector:c,previewContainer:d}=t;this.disabled=l??!1,this.dragStartDelay=r||0,this.lockAxis=i||null,o&&(this.constrainPosition=o),a&&(this.previewClass=a),s&&(this.boundaryElement=s),c&&(this.rootElementSelector=c),d&&(this.previewContainer=d)}_setupHandlesListener(){this._handles.pipe(ua(t=>{let i=t.map(r=>r.element);this._selfHandle&&this.rootElementSelector&&i.push(this.element),this._dragRef.withHandles(i)}),mr(t=>Ir(...t.map(i=>i._stateChanges.pipe(un(i))))),xi(this._destroyed)).subscribe(t=>{let i=this._dragRef,r=t.element.nativeElement;t.disabled?i.disableHandle(r):i.enableHandle(r)})}static \u0275fac=function(i){return new(i||n)};static \u0275dir=lt({type:n,selectors:[["","cdkDrag",""]],hostAttrs:[1,"cdk-drag"],hostVars:4,hostBindings:function(i,r){i&2&&_t("cdk-drag-disabled",r.disabled)("cdk-drag-dragging",r._dragRef.isDragging())},inputs:{data:[0,"cdkDragData","data"],lockAxis:[0,"cdkDragLockAxis","lockAxis"],rootElementSelector:[0,"cdkDragRootElement","rootElementSelector"],boundaryElement:[0,"cdkDragBoundary","boundaryElement"],dragStartDelay:[0,"cdkDragStartDelay","dragStartDelay"],freeDragPosition:[0,"cdkDragFreeDragPosition","freeDragPosition"],disabled:[2,"cdkDragDisabled","disabled",Ue],constrainPosition:[0,"cdkDragConstrainPosition","constrainPosition"],previewClass:[0,"cdkDragPreviewClass","previewClass"],previewContainer:[0,"cdkDragPreviewContainer","previewContainer"],scale:[2,"cdkDragScale","scale",zi]},outputs:{started:"cdkDragStarted",released:"cdkDragReleased",ended:"cdkDragEnded",entered:"cdkDragEntered",exited:"cdkDragExited",dropped:"cdkDragDropped",moved:"cdkDragMoved"},exportAs:["cdkDrag"],features:[Lt([{provide:w2,useExisting:n}]),Se]})}return n})(),$F=new xt("CdkDropListGroup");var Ef=(()=>{class n{element=M(Ct);_changeDetectorRef=M(re);_scrollDispatcher=M(jC);_dir=M(co,{optional:!0});_group=M($F,{optional:!0,skipSelf:!0});_latestSortedRefs;_destroyed=new ze;_scrollableParentsResolved=!1;static _dropLists=[];_dropListRef;connectedTo=[];data;orientation="vertical";id=M(or).getId("cdk-drop-list-");lockAxis=null;get disabled(){return this._disabled||!!this._group&&this._group.disabled}set disabled(t){this._dropListRef.disabled=this._disabled=t}_disabled=!1;sortingDisabled=!1;enterPredicate=()=>!0;sortPredicate=()=>!0;autoScrollDisabled=!1;autoScrollStep;elementContainerSelector=null;hasAnchor=!1;dropped=new he;entered=new he;exited=new he;sorted=new he;_unsortedItems=new Set;constructor(){let t=M(iN,{optional:!0}),i=M(Kr);this._dropListRef=QF(i,this.element),this._dropListRef.data=this,t&&this._assignDefaults(t),this._dropListRef.enterPredicate=(r,o)=>this.enterPredicate(r.data,o.data),this._dropListRef.sortPredicate=(r,o,a)=>this.sortPredicate(r,o.data,a.data),this._setupInputSyncSubscription(this._dropListRef),this._handleEvents(this._dropListRef),n._dropLists.push(this),this._group&&this._group._items.add(this)}addItem(t){this._unsortedItems.add(t),t._dragRef._withDropContainer(this._dropListRef),this._dropListRef.isDragging()&&this._syncItemsWithRef(this.getSortedItems().map(i=>i._dragRef))}removeItem(t){if(this._unsortedItems.delete(t),this._latestSortedRefs){let i=this._latestSortedRefs.indexOf(t._dragRef);i>-1&&(this._latestSortedRefs.splice(i,1),this._syncItemsWithRef(this._latestSortedRefs))}}getSortedItems(){return Array.from(this._unsortedItems).sort((t,i)=>t._dragRef.getVisibleElement().compareDocumentPosition(i._dragRef.getVisibleElement())&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)}ngOnDestroy(){let t=n._dropLists.indexOf(this);t>-1&&n._dropLists.splice(t,1),this._group&&this._group._items.delete(this),this._latestSortedRefs=void 0,this._unsortedItems.clear(),this._dropListRef.dispose(),this._destroyed.next(),this._destroyed.complete()}_setupInputSyncSubscription(t){this._dir&&this._dir.change.pipe(un(this._dir.value),xi(this._destroyed)).subscribe(i=>t.withDirection(i)),t.beforeStarted.subscribe(()=>{let i=PI(this.connectedTo).map(r=>{if(typeof r=="string"){let o=n._dropLists.find(a=>a.id===r);return o}return r});if(this._group&&this._group._items.forEach(r=>{i.indexOf(r)===-1&&i.push(r)}),!this._scrollableParentsResolved){let r=this._scrollDispatcher.getAncestorScrollContainers(this.element).map(o=>o.getElementRef().nativeElement);this._dropListRef.withScrollableParents(r),this._scrollableParentsResolved=!0}if(this.elementContainerSelector){let r=this.element.nativeElement.querySelector(this.elementContainerSelector);t.withElementContainer(r)}t.disabled=this.disabled,t.lockAxis=this.lockAxis,t.sortingDisabled=this.sortingDisabled,t.autoScrollDisabled=this.autoScrollDisabled,t.autoScrollStep=zC(this.autoScrollStep,2),t.hasAnchor=this.hasAnchor,t.connectedTo(i.filter(r=>r&&r!==this).map(r=>r._dropListRef)).withOrientation(this.orientation)})}_handleEvents(t){t.beforeStarted.subscribe(()=>{this._syncItemsWithRef(this.getSortedItems().map(i=>i._dragRef)),this._changeDetectorRef.markForCheck()}),t.entered.subscribe(i=>{this.entered.emit({container:this,item:i.item.data,currentIndex:i.currentIndex})}),t.exited.subscribe(i=>{this.exited.emit({container:this,item:i.item.data}),this._changeDetectorRef.markForCheck()}),t.sorted.subscribe(i=>{this.sorted.emit({previousIndex:i.previousIndex,currentIndex:i.currentIndex,container:this,item:i.item.data})}),t.dropped.subscribe(i=>{this.dropped.emit({previousIndex:i.previousIndex,currentIndex:i.currentIndex,previousContainer:i.previousContainer.data,container:i.container.data,item:i.item.data,isPointerOverContainer:i.isPointerOverContainer,distance:i.distance,dropPoint:i.dropPoint,event:i.event}),this._changeDetectorRef.markForCheck()}),Ir(t.receivingStarted,t.receivingStopped).subscribe(()=>this._changeDetectorRef.markForCheck())}_assignDefaults(t){let{lockAxis:i,draggingDisabled:r,sortingDisabled:o,listAutoScrollDisabled:a,listOrientation:s}=t;this.disabled=r??!1,this.sortingDisabled=o??!1,this.autoScrollDisabled=a??!1,this.orientation=s||"vertical",this.lockAxis=i||null}_syncItemsWithRef(t){this._latestSortedRefs=t,this._dropListRef.withItems(t)}static \u0275fac=function(i){return new(i||n)};static \u0275dir=lt({type:n,selectors:[["","cdkDropList",""],["cdk-drop-list"]],hostAttrs:[1,"cdk-drop-list"],hostVars:7,hostBindings:function(i,r){i&2&&(st("id",r.id),_t("cdk-drop-list-disabled",r.disabled)("cdk-drop-list-dragging",r._dropListRef.isDragging())("cdk-drop-list-receiving",r._dropListRef.isReceiving()))},inputs:{connectedTo:[0,"cdkDropListConnectedTo","connectedTo"],data:[0,"cdkDropListData","data"],orientation:[0,"cdkDropListOrientation","orientation"],id:"id",lockAxis:[0,"cdkDropListLockAxis","lockAxis"],disabled:[2,"cdkDropListDisabled","disabled",Ue],sortingDisabled:[2,"cdkDropListSortingDisabled","sortingDisabled",Ue],enterPredicate:[0,"cdkDropListEnterPredicate","enterPredicate"],sortPredicate:[0,"cdkDropListSortPredicate","sortPredicate"],autoScrollDisabled:[2,"cdkDropListAutoScrollDisabled","autoScrollDisabled",Ue],autoScrollStep:[0,"cdkDropListAutoScrollStep","autoScrollStep"],elementContainerSelector:[0,"cdkDropListElementContainer","elementContainerSelector"],hasAnchor:[2,"cdkDropListHasAnchor","hasAnchor",Ue]},outputs:{dropped:"cdkDropListDropped",entered:"cdkDropListEntered",exited:"cdkDropListExited",sorted:"cdkDropListSorted"},exportAs:["cdkDropList"],features:[Lt([{provide:$F,useValue:void 0},{provide:nN,useExisting:n}])]})}return n})();var pre=new xt("CdkDragPlaceholder"),rN=(()=>{class n{templateRef=M(qr);_drag=M(w2,{optional:!0});data;constructor(){this._drag?._setPlaceholderTemplate(this)}ngOnDestroy(){this._drag?._resetPlaceholderTemplate(this)}static \u0275fac=function(i){return new(i||n)};static \u0275dir=lt({type:n,selectors:[["ng-template","cdkDragPlaceholder",""]],inputs:{data:"data"},features:[Lt([{provide:pre,useExisting:n}])]})}return n})();var S2=(()=>{class n{static \u0275fac=function(i){return new(i||n)};static \u0275mod=Di({type:n});static \u0275inj=Ii({providers:[ure],imports:[Q_]})}return n})();var T_=100,hre=200,aN=n=>Number.isFinite(n)?Math.min(hre,Math.max(0,Math.round(n*100))):T_,sN=n=>n/100,T2=class n{brightness=X(T_);contrast=X(T_);dialogRef=M(di);data=M(ui);initialPosition=this.data.position??{x:0,y:0};ngOnInit(){this.brightness.set(aN(this.data.value?.brightness??1)),this.contrast.set(aN(this.data.value?.contrast??1))}onBrightnessChange(e){this.brightness.set(Number(e.target.value)),this.emitChange()}onContrastChange(e){this.contrast.set(Number(e.target.value)),this.emitChange()}reset(){this.brightness.set(T_),this.contrast.set(T_),this.emitChange()}onDragEnded(e){typeof this.data?.onMoved=="function"&&this.data.onMoved(e.source.getFreeDragPosition())}currentValue(){return{brightness:sN(this.brightness()),contrast:sN(this.contrast())}}emitChange(){typeof this.data?.onChange=="function"&&this.data.onChange(this.currentValue())}handleClose(e){this.dialogRef.close({apply:e,value:this.currentValue()})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-image-adjustment-dialog"]],decls:30,vars:13,consts:[["cdkDrag","","cdkDragRootElement",".cdk-overlay-pane",1,"_ap-image-adjustment",2,"overflow","hidden","color","var(--mat-app-text-color)",3,"cdkDragEnded","cdkDragFreeDragPosition"],["cdkDragHandle","",2,"display","flex","align-items","center","cursor","move","padding","4px 4px 0 12px"],[2,"opacity","0.6"],[2,"flex","1 1 auto","min-width","0","padding-left","8px","font-weight","500","overflow","hidden","text-overflow","ellipsis","white-space","nowrap",3,"title"],["mat-icon-button","","aria-label","Close",3,"click"],[2,"padding","0 24px","overflow","hidden","margin-top","-4px"],[2,"display","flex","align-items","center","margin","-11px 0"],[2,"width","72px","font-size","13px"],[2,"flex","1 1 auto","min-width","0",3,"min","max","step"],["matSliderThumb","","aria-label","Brightness",3,"input","value"],[2,"min-width","44px","text-align","right","font-size","13px"],["matSliderThumb","","aria-label","Contrast",3,"input","value"],[2,"min-height","38px","padding","0 8px 2px"],["mat-button","",3,"click"],[2,"flex","1 1 auto"]],template:function(t,i){t&1&&(u(0,"div",0),T("cdkDragEnded",function(o){return i.onDragEnded(o)}),u(1,"div",1)(2,"mat-icon",2),_(3,"tune"),p(),u(4,"div",3),_(5),p(),u(6,"button",4),T("click",function(){return i.handleClose(!1)}),u(7,"mat-icon"),_(8,"close"),p()()(),u(9,"mat-dialog-content",5)(10,"div",6)(11,"div",7),_(12,"Brightness"),p(),u(13,"mat-slider",8)(14,"input",9),T("input",function(o){return i.onBrightnessChange(o)}),p()(),u(15,"div",10),_(16),p()(),u(17,"div",6)(18,"div",7),_(19,"Contrast"),p(),u(20,"mat-slider",8)(21,"input",11),T("input",function(o){return i.onContrastChange(o)}),p()(),u(22,"div",10),_(23),p()()(),u(24,"mat-dialog-actions",12)(25,"button",13),T("click",function(){return i.reset()}),_(26,"RESET"),p(),z(27,"span",14),u(28,"button",13),T("click",function(){return i.handleClose(!0)}),_(29,"SAVE"),p()()()),t&2&&(w("cdkDragFreeDragPosition",i.initialPosition),g(4),w("title",i.data.text),g(),$(" ",i.data.text," "),g(8),w("min",0)("max",200)("step",1),g(),w("value",i.brightness()),g(2),$(" ",i.brightness(),"% "),g(4),w("min",0)("max",200)("step",1),g(),w("value",i.contrast()),g(2),$(" ",i.contrast(),"% "))},dependencies:[Bs,Ns,ss,le,ce,ue,Xe,Fe,pi,Si,_i,be,Qa,Cu],encapsulation:2})};function _E(n){let e=n*10,t=e+Number.EPSILON*Math.max(1,Math.abs(e));return Math.floor(t)/10}function lN(n){return _E(n).toFixed(1)}function mre(n,e){if(n&1&&(u(0,"div",11),_(1),p()),n&2){let t=v();g(),$(" ",t.error()," ")}}function fre(n,e){if(n&1&&(u(0,"div",12),_(1),p()),n&2){let t=v();g(),$(" ",t.summary()," ")}}var yE=1,vE=28;function cN(n){if(n==null||String(n).trim()==="")return{invalid:!1};let e=Number(n);return!Number.isFinite(e)||e<yE||e>vE?{invalid:!0}:{value:e,invalid:!1}}function gre(n){return n.invalid?`Enter a zoom level between ${yE} and ${vE}`:null}function uN(n){return typeof n=="number"?`from z${n}`:""}function dN(n){return Number.isFinite(n)?String(_E(n)):""}var E2=class n{ZOOM_ENTRY_MIN=yE;ZOOM_ENTRY_MAX=vE;text=X("");dialogRef=M(di);data=M(ui);error=qt(()=>gre(cN(this.text())));summary=qt(()=>{let e=this.currentValue();return typeof e=="number"?`Hidden below z${e}`:"Shown at every zoom level"});ngOnInit(){this.text.set(typeof this.data.value=="number"?String(this.data.value):"")}declaredText(){let{declaredMin:e,declaredMax:t}=this.data;return typeof e=="number"&&typeof t=="number"?`data z${e}\u2013z${t}`:"data zoom range unknown"}currentZoomText(){return dN(this.data.currentZoom())}onTextChange(e){this.setText(e.target.value)}useCurrentZoom(){this.setText(dN(this.data.currentZoom()))}clear(){this.setText("")}setText(e){this.text.set(e),!this.error()&&typeof this.data?.onChange=="function"&&this.data.onChange(this.currentValue())}currentValue(){return cN(this.text()).value}handleClose(e){this.dialogRef.close({apply:e,value:this.currentValue()})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-chart-min-zoom-dialog"]],decls:27,vars:10,consts:[["cdkDrag","","cdkDragRootElement",".cdk-overlay-pane",1,"_ap-chart-min-zoom",2,"overflow","hidden","color","var(--mat-app-text-color)"],["cdkDragHandle","",2,"display","flex","align-items","center","cursor","move","padding","4px 4px 0 12px"],[2,"opacity","0.6"],[2,"flex","1 1 auto","min-width","0","padding-left","8px","font-weight","500","overflow","hidden","text-overflow","ellipsis","white-space","nowrap",3,"title"],["mat-icon-button","","aria-label","Close",3,"click"],[2,"padding","0 16px","font-size","12px","opacity","0.7","margin-top","-4px"],[2,"display","flex","align-items","center","gap","4px","padding","10px 8px 0 16px"],[2,"font-size","13px"],["type","number","inputmode","decimal","step","any","aria-label","Lowest zoom level to show this chart at",2,"width","70px","height","34px","box-sizing","border-box","padding","0 0 0 8px","font","inherit","font-size","14px","color","inherit","background","transparent","border","1px solid rgba(128, 128, 128, 0.5)","border-radius","4px",3,"change","min","max","value"],["mat-icon-button","","aria-label","Use the current map zoom","matTooltip","Use current map zoom",3,"click"],["mat-icon-button","","aria-label","Clear","matTooltip","Clear",3,"click","disabled"],["role","alert",1,"mat-mdc-form-field-error",2,"padding","4px 16px 0","font-size","12px"],[2,"padding","4px 16px 0","font-size","12px","opacity","0.7"],[2,"min-height","38px","padding","0 8px 2px"],[2,"flex","1 1 auto"],["mat-button","",3,"click","disabled"]],template:function(t,i){t&1&&(u(0,"div",0)(1,"div",1)(2,"mat-icon",2),_(3,"vertical_align_bottom"),p(),u(4,"div",3),_(5),p(),u(6,"button",4),T("click",function(){return i.handleClose(!1)}),u(7,"mat-icon"),_(8,"close"),p()()(),u(9,"div",5),_(10),p(),u(11,"div",6)(12,"div",7),_(13,"Show from"),p(),u(14,"input",8),T("change",function(o){return i.onTextChange(o)}),p(),u(15,"button",9),T("click",function(){return i.useCurrentZoom()}),u(16,"mat-icon"),_(17,"my_location"),p()(),u(18,"button",10),T("click",function(){return i.clear()}),u(19,"mat-icon"),_(20,"close"),p()()(),R(21,mre,2,1,"div",11)(22,fre,2,1,"div",12),u(23,"mat-dialog-actions",13),z(24,"span",14),u(25,"button",15),T("click",function(){return i.handleClose(!0)}),_(26," APPLY "),p()()()),t&2&&(g(4),w("title",i.data.text),g(),$(" ",i.data.text," "),g(5),lo(" ",i.declaredText()," \xB7 map at z",i.currentZoomText()," "),g(4),w("min",i.ZOOM_ENTRY_MIN)("max",i.ZOOM_ENTRY_MAX)("value",i.text()),g(4),w("disabled",i.text()===""),g(3),A(i.error()?21:22),g(4),w("disabled",!!i.error()))},dependencies:[le,ce,ue,Xe,Fe,pi,Si,be,Pe,Qa,Cu],encapsulation:2})};var pN="3.1.0";var hN=500,If=1.5,yre=1,vre=2147483647;function mN(n){return typeof n!="number"||!Number.isFinite(n)?If*1e3:Math.min(Math.max(n,yre)*1e3,vre)}var I2=class{constructor(e=()=>{}){this.onExpire=e}onExpire;_marker=X(null);timer;seq=0;get marker(){return this._marker.asReadonly()}get active(){return this._marker()!==null}pin(e,t,i){this.stopTimer(),this._marker.set({id:++this.seq,position:e,worldOffset:t,fadeMs:i}),this.timer=setTimeout(()=>{this.timer=void 0,this._marker.set(null),this.onExpire()},i)}release(){this.stopTimer(),this._marker.set(null)}stopTimer(){clearTimeout(this.timer),this.timer=void 0}};function fN(n){let e=!0,t=Object.keys(n);return Object.keys(xE()).forEach(i=>{t.includes(i)||(e=!1)}),e}function bE(n,e){if(typeof n.ui>"u"?n.ui={mapNorthUp:!0,mapMove:!1,mapConstrainZoom:!1,invertColor:!1,toolbarButtons:!0,showCourseData:!0,showAisTargets:!0,showNotes:!0,autoNightMode:!1}:(typeof n.ui.showCourseData>"u"&&(n.ui.showCourseData=!0),typeof n.ui.showAisTargets>"u"&&(n.ui.showAisTargets=!0),typeof n.ui.showNotes>"u"&&(n.ui.showNotes=!0)),typeof n.imageAdjustPalettePos>"u"&&(n.imageAdjustPalettePos=null),typeof n.display>"u"?n.display={fab:"wpt",disableWakelock:!1,darkMode:{enabled:!1,source:0},nightMode:!1,muteSound:!1,depthAlarm:{enabled:!1,smoothing:1e4},plugins:{instruments:"/@signalk/instrumentpanel",startOnOpen:!0,parameters:null,favourites:[]},preferInfoPanel:!0,singleClickNoteDetails:!1,windIndicator:"barb",statusBar:{liveEta:!1,referenceSpeed:6,tapFadeSpeed:If}}:(typeof n.display.preferInfoPanel>"u"&&(n.display.preferInfoPanel=!0),typeof n.display.singleClickNoteDetails>"u"&&(n.display.singleClickNoteDetails=!1),typeof n.display.windIndicator>"u"&&(n.display.windIndicator="barb"),typeof n.display.statusBar>"u"?n.display.statusBar={liveEta:!1,referenceSpeed:6,tapFadeSpeed:If}:typeof n.display.statusBar.tapFadeSpeed>"u"&&(n.display.statusBar.tapFadeSpeed=If)),typeof n.units.temperature>"u"&&(n.units.temperature="C"),n.units.temperature=n.units.temperature.toUpperCase(),n.units.depth=n.units.depth==="ft"?"foot":n.units.depth,typeof n.units.length>"u"&&(n.units.length=n.units.depth??"m"),n.units.speed=n.units.speed==="msec"?"m/s":n.units.speed==="kmh"?"km/h":n.units.speed,n.units.distance=n.units.distance==="m"?"kilometer":n.units.distance==="ft"?"naut-mile":n.units.distance,typeof n.map.s57Options>"u"?n.map.s57Options={graphicsStyle:"Paper",boundaries:"Plain",colors:4,shallowDepth:2,safetyDepth:3,deepDepth:6,colorTable:0,otherLayers:vf.otherLayers,depthUnit:n.units.depth??"m"}:(typeof n.map.s57Options.otherLayers>"u"&&(n.map.s57Options.otherLayers=vf.otherLayers),typeof n.map.s57Options.depthUnit>"u"&&(n.map.s57Options.depthUnit=n.units.depth??"m")),typeof n.map.labelsMinZoom>"u"&&(n.map.labelsMinZoom=8),typeof n.map.panBehavior>"u"){let i=n.map;n.map.panBehavior=S6(i.lockMoveMap),delete i.lockMoveMap}typeof n.map.popoverMulti>"u"&&(n.map.popoverMulti=!1);let t=n.map.centerOffsetAbeam;if(n.map.centerOffset=T6(n.map.centerOffset,t),delete n.map.centerOffsetAbeam,typeof n.map.doubleClickZoom>"u"&&(n.map.doubleClickZoom=!1),typeof n.map.overZoomTiles>"u"&&(n.map.overZoomTiles=!0),n.units.positionFormat||(n.units.positionFormat="XY"),typeof n.units.headingAttribute>"u"&&(n.units.headingAttribute="navigation.headingTrue"),typeof n.units.preferredPaths>"u"&&(n.units.preferredPaths={tws:"environment.wind.speedTrue",twd:"environment.wind.directionTrue",heading:"navigation.courseOverGroundTrue",course:"navigation.courseGreatCircle"}),typeof n.units.useServerPrefs>"u"&&(n.units.useServerPrefs=!1),typeof n.course>"u"?n.course={autoNextPointOnArrival:!1,autoNextPointDelay:5e3,autoNextPointTrigger:"perpendicularPassed",arrivalCircle:100}:typeof n.course.arrivalCircle>"u"&&(n.course.arrivalCircle=100),typeof n.vessels>"u"?n.vessels={fixedLocationMode:!1,fixedPosition:[0,0],trail:!0,windVectors:!0,laylines:!1,selfLines:{cog:{length:10,color:"rgba(204, 12, 225, 0.7)",weight:1,dash:"none"},heading:{length:-1,color:"rgba(221, 99, 0, 0.5)",weight:4,dash:"none"}},aisCogLine:10,iconScale:.9,rangeCircles:!1,rangeCirclesFixed:!1,rangeCirclesDistance:1e3,rangeCircleCount:4,rangeCircleMinZoom:8,aisStaleAge:36e4,aisMaxAge:54e4,aisWindApparent:!1,aisWindMinZoom:15,aisShowTrack:!1,trailFromServer:!1,trailDuration:24,trailResolution:{lastHour:"5s",next23:"1m",beyond24:"5m"}}:(typeof n.vessels.rangeCircleCount>"u"&&(n.vessels.rangeCircleCount=4),typeof n.vessels.rangeCircleMinZoom>"u"&&(n.vessels.rangeCircleMinZoom=8),typeof n.vessels.rangeCirclesFixed>"u"&&(n.vessels.rangeCirclesFixed=!1),typeof n.vessels.rangeCirclesDistance>"u"&&(n.vessels.rangeCirclesDistance=1e3),typeof n.vessels.selfLines>"u"&&(n.vessels.selfLines={cog:{length:n.vessels.cogLine??10,color:"rgba(204, 12, 225, 0.7)",weight:1,dash:"none"},heading:{length:n.vessels.headingLineSize??-1,color:"rgba(221, 99, 0, 0.5)",weight:4,dash:"none"}},delete n.vessels.cogLine,delete n.vessels.headingLineSize)),typeof n.resources>"u"?n.resources={fetchFilter:"?position=[%map:longitude%,%map:latitude%]&distance=%fetch:radius%",fetchRadius:0,notes:{rootFilter:"?position=[%map:longitude%,%map:latitude%]&distance=%note:radius%",getRadius:20,groupNameEdit:!1,groupRequiresPosition:!1,minZoom:10},video:{enable:!1,url:""},paths:[]}:(typeof n.resources.notes.minZoom>"u"&&(n.resources.notes.minZoom=10),typeof n.resources.video>"u"&&(n.resources.video={enable:!1,url:""}),typeof n.resources.paths>"u"&&(n.resources.paths=[]),typeof n.resources.fetchFilter>"u"&&(n.resources.fetchFilter="?position=[%map:longitude%,%map:latitude%]&distance=%fetch:radius%"),typeof n.resources.fetchRadius>"u"&&(n.resources.fetchRadius=0)),typeof n.signalk>"u"?n.signalk={vessels:!0,atons:!0,aircraft:!1,sar:!1,meteo:!0,maxRadius:0,proxied:!0}:n.signalk.proxied=!0,typeof n.anchor>"u"&&(n.anchor={radius:40,setRadius:!1,manualSet:!1,rodeLength:50}),(!n.plotterExtensions||typeof n.plotterExtensions!="object"||Array.isArray(n.plotterExtensions))&&(n.plotterExtensions={widgets:[]}),delete n.plotterExtensions.enabled,Array.isArray(n.plotterExtensions.widgets)||(n.plotterExtensions.widgets=[]),n.plotterExtensions.widgets=n.plotterExtensions.widgets.map(i=>(i.corner&&!i.anchor&&(i.anchor=i.corner==="tl"?"tr":i.corner,delete i.corner),i)).filter(i=>["tr","ct","cb","bl","br"].includes(i.anchor)),typeof n.radars>"u"?n.radars={deviceId:"",opacity:1}:typeof n.radars.opacity>"u"&&(n.radars.opacity=1),typeof n.selections>"u"&&(n.selections={routes:[],waypoints:[],regions:[],tracks:null,charts:["openstreetmap","openseamap"],chartOrder:["openstreetmap","openseamap"],chartOpacity:{},chartImageAdjustment:{},chartDisplayMinZoom:{},aisTargets:null,aisTargetTypes:[],aisFilterByShipType:!1,aisState:[],resourceSets:{},infolayers:null,weatherWindEnabled:!1,oceanCurrentsEnabled:!1,tidalCurrentsEnabled:!1}),typeof n.selections.aisTargetTypes>"u"&&(n.selections.aisTargetTypes=[]),typeof n.selections.aisFilterByShipType>"u"&&(n.selections.aisFilterByShipType=!1),typeof n.selections.aisState>"u"&&(n.selections.aisState=[]),typeof n.selections.chartOrder>"u"&&(n.selections.chartOrder=[]),typeof n.selections.chartOpacity>"u"&&(n.selections.chartOpacity={}),typeof n.selections.chartImageAdjustment>"u"&&(n.selections.chartImageAdjustment={}),typeof n.selections.chartDisplayMinZoom>"u"&&(n.selections.chartDisplayMinZoom={}),typeof n.selections.tracks>"u"&&(n.selections.tracks=[]),typeof n.selections.resourceSets>"u"&&(n.selections.resourceSets={}),typeof n.selections.infolayers>"u"&&(n.selections.infolayers=[]),typeof n.selections.regions>"u"&&(n.selections.regions=[]),typeof n.selections.weatherWindEnabled>"u"&&(n.selections.weatherWindEnabled=!1),typeof n.selections.oceanCurrentsEnabled>"u"&&(n.selections.oceanCurrentsEnabled=!1),typeof n.selections.tidalCurrentsEnabled>"u"&&(n.selections.tidalCurrentsEnabled=!1),n.selections.notes,delete n.selections.notes,typeof e.northup<"u"&&(n.ui.mapNorthUp=e.northup!=="0"),typeof e.movemap<"u"&&(n.ui.mapMove=e.movemap!=="0"),e.zoom)try{let i=parseInt(e.zoom);isNaN(i)||(n.map.zoomLevel=i>28?28:i<1?1:i)}catch(i){console.warn(`Invalid zoom level parameter (${e.zoom} supplied!`)}}function xE(){return{ui:{mapNorthUp:!0,mapMove:!1,mapConstrainZoom:!1,toolbarButtons:!0,invertColor:!1,showCourseData:!0,showAisTargets:!0,showNotes:!0,autoNightMode:!1},imageAdjustPalettePos:null,display:{fab:"wpt",disableWakelock:!1,darkMode:{enabled:!1,source:0},nightMode:!1,muteSound:!1,depthAlarm:{enabled:!1,smoothing:1e4},plugins:{instruments:"/@signalk/instrumentpanel",startOnOpen:!0,parameters:null,favourites:[]},preferInfoPanel:!0,singleClickNoteDetails:!1,windIndicator:"barb",statusBar:{liveEta:!1,referenceSpeed:6,tapFadeSpeed:If}},units:{distance:"kilometer",depth:"m",length:"m",speed:"kn",temperature:"C",positionFormat:"XY",headingAttribute:"navigation.headingTrue",preferredPaths:{tws:"environment.wind.speedTrue",twd:"environment.wind.directionTrue",heading:"navigation.courseOverGroundTrue",course:"navigation.courseGreatCircle"},useServerPrefs:!1},map:{zoomLevel:2,center:[0,0],rotation:0,panBehavior:"offset",animate:!1,labelsMinZoom:8,doubleClickZoom:!1,overZoomTiles:!0,centerOffset:{x:0,y:0},s57Options:{graphicsStyle:"Paper",boundaries:"Plain",colors:4,shallowDepth:2,safetyDepth:3,deepDepth:6,colorTable:0,otherLayers:vf.otherLayers,depthUnit:"m"},popoverMulti:!1},course:{autoNextPointOnArrival:!1,autoNextPointDelay:5e3,autoNextPointTrigger:"perpendicularPassed",arrivalCircle:100},vessels:{fixedLocationMode:!1,fixedPosition:[0,0],trail:!1,windVectors:!0,laylines:!1,selfLines:{cog:{length:10,color:"rgba(204, 12, 225, 0.7)",weight:1,dash:"none"},heading:{length:-1,color:"rgba(221, 99, 0, 0.5)",weight:4,dash:"none"}},aisCogLine:10,iconScale:.9,rangeCircles:!1,rangeCirclesFixed:!1,rangeCirclesDistance:1e3,rangeCircleCount:4,rangeCircleMinZoom:8,aisStaleAge:36e4,aisMaxAge:54e4,aisWindApparent:!1,aisWindMinZoom:15,aisShowTrack:!1,trailFromServer:!1,trailDuration:24,trailResolution:{lastHour:"5s",next23:"1m",beyond24:"5m"}},resources:{fetchFilter:"?position=[%map:longitude%,%map:latitude%]&distance=%fetch:radius%",fetchRadius:0,notes:{rootFilter:"?position=[%map:longitude%,%map:latitude%]&distance=%note:radius%",getRadius:20,groupNameEdit:!1,groupRequiresPosition:!0,minZoom:10},video:{enable:!1,url:null},paths:[]},signalk:{vessels:!0,atons:!0,aircraft:!1,sar:!1,meteo:!0,maxRadius:0,proxied:!0},anchor:{radius:40,setRadius:!1,manualSet:!1,rodeLength:50},radars:{deviceId:void 0,opacity:1},experiments:!1,plotterExtensions:{widgets:[]},selections:{routes:[],waypoints:[],regions:[],tracks:null,charts:["openstreetmap","openseamap"],chartOrder:["openstreetmap","openseamap"],chartOpacity:{},chartImageAdjustment:{},chartDisplayMinZoom:{},aisTargets:null,aisTargetTypes:[],aisFilterByShipType:!1,aisState:[],resourceSets:{},infolayers:null,weatherWindEnabled:!1,oceanCurrentsEnabled:!1,tidalCurrentsEnabled:!1}}}function gN(){return{loginRequired:!1,chartBounds:{show:!1,charts:[]},selfId:null,activeRoute:null,activeRouteReversed:!1,activeRouteCircular:!1,activeRouteIsEditing:!1,editingId:null,activeWaypoint:null,serverTrail:!1,server:null,lastGet:null,map:{atClick:{features:[],lonlat:[0,0]}},vessels:{showSelf:!1,self:new Md,aisTargets:new Map,aisTracks:new Map,activeId:null,active:null,closest:[],prefAvailablePaths:{},flagged:[],showTrack:[]},aircraft:new Map,atons:new Map,sar:new Map,meteo:new Map,racing:{startLine:[]}}}var D2=(n,e)=>{if(!n)return n;let t=n.split("%");return t.length>1&&(n=t.map(r=>r==="map:latitude"?e.map.center[1]:r==="map:longitude"?e.map.center[0]:r==="map:zoom"?Math.floor(e.map.zoomLevel):r==="note:radius"?(e.units.distance==="kilometer"?e.resources.notes.getRadius:Math.floor(Ge.nauticalMilesToKm(e.resources.notes.getRadius)))*1e3:r==="fetch:radius"?(e.units.distance==="kilometer"?e.resources.notes.getRadius:Math.floor(Ge.nauticalMilesToKm(e.resources.fetchRadius)))*1e3:r).join("")),n};var _N="symbols";var yN={id:"freeboard",name:"Freeboard-SK",description:"Signal K Chart Plotter.",version:pN,url:"https://github.com/signalk/freeboard-sk",logo:"./assets/img/app_logo.png"},bre="1.0.0",E_={host:"localhost",port:3e3,ssl:!1},ae=class n extends v1{skApiVersion=2;hostDef={name:void 0,port:void 0,ssl:!1,url:void 0,params:{}};STANDARD_RESOURCES=["routes","waypoints","regions","notes","charts"];CUSTOM_RESOURCES=[{name:"tracks",description:"Freeboard GPX track imports.",featureKey:"resourceTracks"},{name:"infolayers",description:"Freeboard map overlays.",featureKey:"infoLayers"},{name:"groups",description:"Freeboard resource groups.",featureKey:"resourceGroups"}];get IGNORE_RESOURCES(){return this.STANDARD_RESOURCES.concat(this.CUSTOM_RESOURCES.map(e=>e.name),["buddies",fD,_N])}serverConfig={unitPreferences:X(void 0),pathDisplayUnits:X({})};MAP_ZOOM_EXTENT={min:2,max:28};AudioContext=window.AudioContext||window.webkitAudioContext;audio={context:new AudioContext};db;watchingSKLogin;kioskMode=X(!1);hasAuthToken=X(!1);isLoggedIn=X(!1);instrumentPanelAvailable=X(!0);skAuthChange=X(void 0);sIsFetching=X(!1);sTrueMagChoice=X("");instrumentPanel=X({open:!1,activate:!1});uiCtrl=X({alertList:!1,autopilotConsole:!1,radarLayer:!1,routeBuilder:!1,suppressContextMenu:!1,forceNightMode:!1});uiConfig=X({mapNorthUp:!0,mapMove:!1,mapConstrainZoom:!1,toolbarButtons:!1,invertColor:!1,showCourseData:!0,showAisTargets:!0,showNotes:!0,autoNightMode:!1});featureFlags=X({anchorApi:!0,autopilotApi:!1,weatherApi:!1,radarApi:!1,notificationApi:!1,resourceGroups:!1,resourceTracks:!1,infoLayers:!1,buddyList:!1,tidalApi:!1});selfLines=X({cog:{fill:{color:"rgba(204, 12, 225, 0.7)"},stroke:{color:"rgba(204, 12, 225, 0.7)",width:1,lineDash:null}},heading:{fill:{color:"rgba(221, 99, 0, 0.5)"},stroke:{color:"rgba(221, 99, 0, 0.5)",width:4,lineDash:null}}});selfTrail=X([]);selfTrailFromServer=X([]);mapExtent=X([]);mapViewTopCenter=X([0,0]);mapViewRightCenter=X([0,0]);mapViewRotation=X(0);mapZoom=X(0);mapMoveRequest=X(null);signalk=M(Ot);worker=M(Wn);dialog=M(xn);snackbar=M(lD);iconReg=M(n1);dom=M(Rd);s57=M(Dp);constructor(){super(yN),this.config=xE(),this.data=gN(),this.suppressPersist=!0,this.db=new CE,this.db.dbUpdate$.subscribe(e=>{if(e.action)switch(e.action){case"db_init":e.value&&this.config.vessels.trail&&this.db.getTrail().then(t=>{this.selfTrail.update(()=>t&&t.value?t.value:[])});break;case"trail_save":e.value||this.debug("app.trail.save.error","warn");break}}),this.signalk.setAppId(yN.id),this.signalk.setAppVersion(bre),this.initAppIcons(),this.parseLaunchUrl(),this.instrumentPanelAvailable.update(()=>this.isTopWindow()),this.isTopWindow()||window.addEventListener("message",e=>{this.parseMessageFromParent(e)}),this.testForInternet(),this.loadConfig(),this.parseLocalConfig(),Me(()=>{this.uiConfig(),this.debug("AppFacade.effect().uiConfig",this.uiConfig()),this.config.ui=this.uiConfig(),this.saveConfigDebounced()}),Me(()=>{this.alignUnitPrefs(this.serverConfig.unitPreferences())})}useInfoPanel(){return!window.matchMedia("(max-width: 760px)").matches&&!this.instrumentPanel().open&&this.config.display.preferInfoPanel}fetchUnitPrefsFromSKServer(){this.signalk.get("/signalk/v1/unitpreferences/active").subscribe({next:e=>{this.serverConfig.unitPreferences.set(e),this.refreshPathDisplayUnits()},error:()=>{this.debug("No server unit preferences...using fallback!")}})}twsDisplayUnitPath(){return this.config.units.preferredPaths.tws??"environment.wind.speedTrue"}displayUnitPaths(){return[this.twsDisplayUnitPath(),"environment.wind.speedApparent"]}refreshPathDisplayUnits(){if(!this.config.units.useServerPrefs){this.serverConfig.pathDisplayUnits.set({});return}this.displayUnitPaths().forEach(e=>this.fetchPathDisplayUnits(e))}fetchPathDisplayUnits(e){let t=e.split(".").join("/");this.signalk.get(`/signalk/v1/api/vessels/self/${t}/meta`).subscribe({next:i=>{this.config.units.useServerPrefs&&i?.displayUnits?.targetUnit?this.setPathDisplayUnits(e,i.displayUnits):this.clearPathDisplayUnits(e)},error:()=>{this.debug(`No display units for path: ${e}`),this.clearPathDisplayUnits(e)}})}parseMessageFromParent(e){if(os()||e.origin===this.hostDef.url){this.debug("parseMessageFromParent()",e.origin,e.data);let{settings:t,commands:i}=e.data;if(!t&&!i){this.debug("parseMessageFromParent() - invalid data!");return}typeof t?.autoNightMode=="boolean"&&(this.config.display.nightMode=t.autoNightMode,this.uiConfig.update(r=>Object.assign({},r,{autoNightMode:this.config.display.nightMode}))),typeof i?.nightModeEnable=="boolean"&&this.uiCtrl.update(r=>Object.assign({},r,{forceNightMode:i.nightModeEnable}))}else{this.debug("parseMessageFromParent() - untrusted origin!",e.origin);return}}parseLocalConfig(){bE(this.config,this.hostDef.params),this.s57.init(this.config.map.s57Options),this.doPostConfigLoad()}get lineDashMap(){return new Map([["none","none"],["short","2 2"],["medium","4 4"],["long","8 4"],["alt","8 4 2 4"]])}formatLineDashArray(e){return e==="none"?null:Array.from(this.lineDashMap.get(e)).filter(t=>t!==" ").map(t=>Number(t))}doPostConfigLoad(){this.uiConfig.update(()=>this.config.ui),this.config.vessels.fixedLocationMode&&(this.data.vessels.self.position=[...this.config.vessels.fixedPosition],this.data.vessels.showSelf=!0,this.config.map.center=[...this.config.vessels.fixedPosition]),this.selfLines.update(e=>({cog:{fill:{color:this.config.vessels.selfLines.cog.color},stroke:{color:this.config.vessels.selfLines.cog.color,width:this.config.vessels.selfLines.cog.weight,lineDash:this.formatLineDashArray(this.config.vessels.selfLines.cog.dash)}},heading:{fill:{color:this.config.vessels.selfLines.heading.color},stroke:{color:this.config.vessels.selfLines.heading.color,width:this.config.vessels.selfLines.heading.weight,lineDash:this.formatLineDashArray(this.config.vessels.selfLines.heading.dash)}}})),this.sTrueMagChoice.set(this.config.units.headingAttribute),this.s57.setOptions(this.config.map.s57Options),this.mapZoom.set(this.config.map.zoomLevel),this.debug("doPostConfigLoad(): emit config$.ready"),this.emitConfigEvent("ready"),this.suppressPersist=!1}loadUserConfigfromServer(){return J(this,null,function*(){return new Promise(e=>{this.signalk.isLoggedIn().subscribe({next:t=>{if(this.isLoggedIn.set(t),t)this.debug("loadUserConfigfromServer(): Is authenticated. Fetching config from SK Server..."),this.signalk.appDataGet("/").subscribe({next:i=>{Object.keys(i).length===0&&e(!1),bE(i,this.hostDef.params),fN(i)&&(this.config=i,this.doPostConfigLoad(),this.alignCustomResourcesPaths(),this.alignUnitPrefs(this.serverConfig.unitPreferences()),this.saveConfig()),e(!0)},error:()=>{console.info("applicationData: Unable to retrieve settings from server!"),e(!1)}});else return this.debug("loadUserConfigfromServer(): Not authenticated to SK Server!"),e(!1)},error:()=>{this.isLoggedIn.set(!1),this.debug("loadUserConfigfromServer(): Error fetching loginStatus!"),e(!1)}})})})}getPathDisplayUnits(e){return this.serverConfig.pathDisplayUnits()[e]}setPathDisplayUnits(e,t){this.serverConfig.pathDisplayUnits.update(i=>ri(se({},i),{[e]:t}))}clearPathDisplayUnits(e){this.serverConfig.pathDisplayUnits.update(t=>{if(!(e in t))return t;let i=se({},t);return delete i[e],i})}alignUnitPrefs(e){if(this.config.units.useServerPrefs){if(this.debug("Aligning Unit preferences from server:",e),!e?.categories){this.debug("No Unit preferences available!");return}e.categories.speed&&(this.config.units.speed=["kn","m/s","km/h","mph"].includes(e.categories.speed.targetUnit)?e.categories.speed.targetUnit:this.config.units.speed,Ge.setSymbol(e.categories.speed.targetUnit,e.categories.speed.symbol)),e.categories.temperature&&(this.config.units.temperature=["C","F"].includes(e.categories.temperature.targetUnit)?e.categories.temperature.targetUnit:this.config.units.temperature,Ge.setSymbol(e.categories.temperature.targetUnit,e.categories.temperature.symbol)),e.categories.distance&&(this.config.units.distance=["kilometer","naut-mile"].includes(e.categories.distance.targetUnit)?e.categories.distance.targetUnit:this.config.units.distance,Ge.setSymbol(e.categories.distance.targetUnit,e.categories.distance.symbol)),e.categories.depth&&(this.config.units.depth=["m","foot"].includes(e.categories.depth.targetUnit)?e.categories.depth.targetUnit:this.config.units.depth,Ge.setSymbol(e.categories.depth.targetUnit,e.categories.depth.symbol)),e.categories.length&&(this.config.units.length=["m","foot"].includes(e.categories.length.targetUnit)?e.categories.length.targetUnit:this.config.units.length,Ge.setSymbol(e.categories.length.targetUnit,e.categories.length.symbol))}}initAppIcons(){c5().forEach(e=>{this.iconReg.addSvgIcon(e.id,this.dom.bypassSecurityTrustResourceUrl(e.path))})}parseLaunchUrl(){window.location.search&&window.location.search.slice(1).split("&").forEach(t=>{let i=t.split("=");this.hostDef.params[i[0]]=i.length>1?i[1]:null}),this.hostDef.name=typeof this.hostDef.params?.host<"u"?this.hostDef.params.host:this.devMode&&E_.host?E_.host:window.location.hostname,this.hostDef.ssl=!!(window.location.protocol==="https:"||this.devMode&&E_.ssl),this.hostDef.port=typeof this.hostDef.params.port<"u"?parseInt(this.hostDef.params.port):this.devMode&&E_.port?E_.port:parseInt(window.location.port),this.hostDef.port=isNaN(this.hostDef.port)?this.hostDef.ssl?443:80:this.hostDef.port,this.hostDef.url=`${this.hostDef.ssl?"https:":"http:"}//${this.hostDef.name}:${this.hostDef.port}`,this.kioskMode.update(()=>typeof this.hostDef.params.kiosk<"u"),typeof this.hostDef.params.token<"u"&&this.persistToken(this.hostDef.params.token),this.debug("host:",this.hostDef)}testForInternet(){window.fetch("https://tile.openstreetmap.org").then(()=>{console.info("Internet connection detected.")}).catch(()=>{console.warn("No Internet connection detected!");let e=this.config.selections.charts;(e.includes("openstreetmap")||e.includes("openseamap"))&&(this.kioskMode()||this.showAlert("Internet Map Service Unavailable: ",`Unable to display Open Street / Sea Maps!
|
|
750
|
+
`],encapsulation:2,changeDetection:0})}return n})(),M2=(()=>{class n{_ngZone=M(Gi);_document=M(Go);_styleLoader=M(Dr);_renderer=M(FC).createRenderer(null,null);_cleanupDocumentTouchmove;_scroll=new ze;_dropInstances=new Set;_dragInstances=new Set;_activeDragInstances=X([]);_globalListeners;_draggingPredicate=t=>t.isDragging();_domNodesToDirectives=null;pointerMove=new ze;pointerUp=new ze;constructor(){}registerDropContainer(t){this._dropInstances.has(t)||this._dropInstances.add(t)}registerDragItem(t){this._dragInstances.add(t),this._dragInstances.size===1&&this._ngZone.runOutsideAngular(()=>{this._cleanupDocumentTouchmove?.(),this._cleanupDocumentTouchmove=this._renderer.listen(this._document,"touchmove",this._persistentTouchmoveListener,aE)})}removeDropContainer(t){this._dropInstances.delete(t)}removeDragItem(t){this._dragInstances.delete(t),this.stopDragging(t),this._dragInstances.size===0&&this._cleanupDocumentTouchmove?.()}startDragging(t,i){if(!(this._activeDragInstances().indexOf(t)>-1)&&(this._styleLoader.load(nre),this._activeDragInstances.update(r=>[...r,t]),this._activeDragInstances().length===1)){let r=i.type.startsWith("touch"),o=s=>this.pointerUp.next(s),a=[["scroll",s=>this._scroll.next(s),C_],["selectstart",this._preventDefaultWhileDragging,aE]];r?a.push(["touchend",o,C_],["touchcancel",o,C_]):a.push(["mouseup",o,C_]),r||a.push(["mousemove",s=>this.pointerMove.next(s),aE]),this._ngZone.runOutsideAngular(()=>{this._globalListeners=a.map(([s,l,c])=>this._renderer.listen(this._document,s,l,c))})}}stopDragging(t){this._activeDragInstances.update(i=>{let r=i.indexOf(t);return r>-1?(i.splice(r,1),[...i]):i}),this._activeDragInstances().length===0&&this._clearGlobalListeners()}isDragging(t){return this._activeDragInstances().indexOf(t)>-1}scrolled(t){let i=[this._scroll];return t&&t!==this._document&&i.push(new Ru(r=>this._ngZone.runOutsideAngular(()=>{let o=this._renderer.listen(t,"scroll",a=>{this._activeDragInstances().length&&r.next(a)},C_);return()=>{o()}}))),Ir(...i)}registerDirectiveNode(t,i){this._domNodesToDirectives??=new WeakMap,this._domNodesToDirectives.set(t,i)}removeDirectiveNode(t){this._domNodesToDirectives?.delete(t)}getDragDirectiveForNode(t){return this._domNodesToDirectives?.get(t)||null}ngOnDestroy(){this._dragInstances.forEach(t=>this.removeDragItem(t)),this._dropInstances.forEach(t=>this.removeDropContainer(t)),this._domNodesToDirectives=null,this._clearGlobalListeners(),this.pointerMove.complete(),this.pointerUp.complete()}_preventDefaultWhileDragging=t=>{this._activeDragInstances().length>0&&t.preventDefault()};_persistentTouchmoveListener=t=>{this._activeDragInstances().length>0&&(this._activeDragInstances().some(this._draggingPredicate)&&t.preventDefault(),this.pointerMove.next(t))};_clearGlobalListeners(){this._globalListeners?.forEach(t=>t()),this._globalListeners=void 0}static \u0275fac=function(i){return new(i||n)};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();function GF(n){let e=n.toLowerCase().indexOf("ms")>-1?1:1e3;return parseFloat(n)*e}function rre(n){let e=getComputedStyle(n),t=sE(e,"transition-property"),i=t.find(s=>s==="transform"||s==="all");if(!i)return 0;let r=t.indexOf(i),o=sE(e,"transition-duration"),a=sE(e,"transition-delay");return GF(o[r])+GF(a[r])}function sE(n,e){return n.getPropertyValue(e).split(",").map(i=>i.trim())}var ore=new Set(["position"]),dE=class{_document;_rootElement;_direction;_initialDomRect;_previewTemplate;_previewClass;_pickupPositionOnPage;_initialTransform;_zIndex;_renderer;_previewEmbeddedView=null;_preview;get element(){return this._preview}constructor(e,t,i,r,o,a,s,l,c,d){this._document=e,this._rootElement=t,this._direction=i,this._initialDomRect=r,this._previewTemplate=o,this._previewClass=a,this._pickupPositionOnPage=s,this._initialTransform=l,this._zIndex=c,this._renderer=d}attach(e){this._preview=this._createPreview(),e.appendChild(this._preview),zF(this._preview)&&this._preview.showPopover()}destroy(){this._preview.remove(),this._previewEmbeddedView?.destroy(),this._preview=this._previewEmbeddedView=null}setTransform(e){this._preview.style.transform=e}getBoundingClientRect(){return this._preview.getBoundingClientRect()}addClass(e){this._preview.classList.add(e)}getTransitionDuration(){return rre(this._preview)}addEventListener(e,t){return this._renderer.listen(this._preview,e,t)}_createPreview(){let e=this._previewTemplate,t=this._previewClass,i=e?e.template:null,r;if(i&&e){let o=e.matchSize?this._initialDomRect:null,a=e.viewContainer.createEmbeddedView(i,e.context);a.detectChanges(),r=qF(a,this._document),this._previewEmbeddedView=a,e.matchSize?VF(r,o):r.style.transform=S_(this._pickupPositionOnPage.x,this._pickupPositionOnPage.y)}else r=lE(this._rootElement),VF(r,this._initialDomRect),this._initialTransform&&(r.style.transform=this._initialTransform);return gE(r.style,{"pointer-events":"none",margin:zF(r)?"0 auto 0 0":"0",position:"fixed",top:"0",left:"0","z-index":this._zIndex+""},ore),Tf(r,!1),r.classList.add("cdk-drag-preview"),r.setAttribute("popover","manual"),r.setAttribute("dir",this._direction),t&&(Array.isArray(t)?t.forEach(o=>r.classList.add(o)):r.classList.add(t)),r}};function zF(n){return"showPopover"in n}var are={passive:!0},jF={passive:!1},sre={passive:!1,capture:!0},lre=800,WF="cdk-drag-placeholder",UF=new Set(["position"]);function ZF(n,e,t={dragStartThreshold:5,pointerDirectionChangeThreshold:5}){let i=n.get(Rn,null,{optional:!0})||n.get(FC).createRenderer(null,null);return new uE(e,t,n.get(Go),n.get(Gi),n.get(jp),n.get(M2),i)}var uE=class{_config;_document;_ngZone;_viewportRuler;_dragDropRegistry;_renderer;_rootElementCleanups;_cleanupShadowRootSelectStart;_preview=null;_previewContainer;_placeholderRef=null;_placeholder;_pickupPositionInElement;_pickupPositionOnPage;_marker;_anchor=null;_passiveTransform={x:0,y:0};_activeTransform={x:0,y:0};_initialTransform;_hasStartedDragging=X(!1);_hasMoved=!1;_initialContainer;_initialIndex;_parentPositions;_moveEvents=new ze;_pointerDirectionDelta;_pointerPositionAtLastDirectionChange;_lastKnownPointerPosition;_rootElement;_ownerSVGElement=null;_rootElementTapHighlight;_pointerMoveSubscription=rr.EMPTY;_pointerUpSubscription=rr.EMPTY;_scrollSubscription=rr.EMPTY;_resizeSubscription=rr.EMPTY;_lastTouchEventTime;_dragStartTime;_boundaryElement=null;_nativeInteractionsEnabled=!0;_initialDomRect;_previewRect;_boundaryRect;_previewTemplate;_placeholderTemplate;_handles=[];_disabledHandles=new Set;_dropContainer;_direction="ltr";_parentDragRef=null;_cachedShadowRoot;lockAxis=null;dragStartDelay=0;previewClass;scale=1;get disabled(){return this._disabled||!!(this._dropContainer&&this._dropContainer.disabled)}set disabled(e){e!==this._disabled&&(this._disabled=e,this._toggleNativeDragInteractions(),this._handles.forEach(t=>Tf(t,e)))}_disabled=!1;beforeStarted=new ze;started=new ze;released=new ze;ended=new ze;entered=new ze;exited=new ze;dropped=new ze;moved=this._moveEvents;data;constrainPosition;constructor(e,t,i,r,o,a,s){this._config=t,this._document=i,this._ngZone=r,this._viewportRuler=o,this._dragDropRegistry=a,this._renderer=s,this.withRootElement(e).withParent(t.parentDragRef||null),this._parentPositions=new b2(i),a.registerDragItem(this)}getPlaceholderElement(){return this._placeholder}getRootElement(){return this._rootElement}getVisibleElement(){return this.isDragging()?this.getPlaceholderElement():this.getRootElement()}withHandles(e){this._handles=e.map(i=>Ec(i)),this._handles.forEach(i=>Tf(i,this.disabled)),this._toggleNativeDragInteractions();let t=new Set;return this._disabledHandles.forEach(i=>{this._handles.indexOf(i)>-1&&t.add(i)}),this._disabledHandles=t,this}withPreviewTemplate(e){return this._previewTemplate=e,this}withPlaceholderTemplate(e){return this._placeholderTemplate=e,this}withRootElement(e){let t=Ec(e);if(t!==this._rootElement){this._removeRootElementListeners();let i=this._renderer;this._rootElementCleanups=this._ngZone.runOutsideAngular(()=>[i.listen(t,"mousedown",this._pointerDown,jF),i.listen(t,"touchstart",this._pointerDown,are),i.listen(t,"dragstart",this._nativeDragStart,jF)]),this._initialTransform=void 0,this._rootElement=t}return typeof SVGElement<"u"&&this._rootElement instanceof SVGElement&&(this._ownerSVGElement=this._rootElement.ownerSVGElement),this}withBoundaryElement(e){return this._boundaryElement=e?Ec(e):null,this._resizeSubscription.unsubscribe(),e&&(this._resizeSubscription=this._viewportRuler.change(10).subscribe(()=>this._containInsideBoundaryOnResize())),this}withParent(e){return this._parentDragRef=e,this}dispose(){this._removeRootElementListeners(),this.isDragging()&&this._rootElement?.remove(),this._marker?.remove(),this._destroyPreview(),this._destroyPlaceholder(),this._dragDropRegistry.removeDragItem(this),this._removeListeners(),this.beforeStarted.complete(),this.started.complete(),this.released.complete(),this.ended.complete(),this.entered.complete(),this.exited.complete(),this.dropped.complete(),this._moveEvents.complete(),this._handles=[],this._disabledHandles.clear(),this._dropContainer=void 0,this._resizeSubscription.unsubscribe(),this._parentPositions.clear(),this._boundaryElement=this._rootElement=this._ownerSVGElement=this._placeholderTemplate=this._previewTemplate=this._marker=this._parentDragRef=null}isDragging(){return this._hasStartedDragging()&&this._dragDropRegistry.isDragging(this)}reset(){this._rootElement.style.transform=this._initialTransform||"",this._activeTransform={x:0,y:0},this._passiveTransform={x:0,y:0}}resetToBoundary(){if(this._boundaryElement&&this._rootElement&&ire(this._boundaryElement.getBoundingClientRect(),this._rootElement.getBoundingClientRect())){let e=this._boundaryElement.getBoundingClientRect(),t=this._rootElement.getBoundingClientRect(),i=0,r=0;t.left<e.left?i=e.left-t.left:t.right>e.right&&(i=e.right-t.right),t.top<e.top?r=e.top-t.top:t.bottom>e.bottom&&(r=e.bottom-t.bottom);let o=this._activeTransform.x,a=this._activeTransform.y,s=o+i,l=a+r;this._rootElement.style.transform=S_(s,l),this._activeTransform={x:s,y:l},this._passiveTransform={x:s,y:l}}}disableHandle(e){!this._disabledHandles.has(e)&&this._handles.indexOf(e)>-1&&(this._disabledHandles.add(e),Tf(e,!0))}enableHandle(e){this._disabledHandles.has(e)&&(this._disabledHandles.delete(e),Tf(e,this.disabled))}withDirection(e){return this._direction=e,this}_withDropContainer(e){this._dropContainer=e}getFreeDragPosition(){let e=this.isDragging()?this._activeTransform:this._passiveTransform;return{x:e.x,y:e.y}}setFreeDragPosition(e){return this._activeTransform={x:0,y:0},this._passiveTransform.x=e.x,this._passiveTransform.y=e.y,this._dropContainer||this._applyRootElementTransform(e.x,e.y),this}withPreviewContainer(e){return this._previewContainer=e,this}_sortFromLastPointerPosition(){let e=this._lastKnownPointerPosition;e&&this._dropContainer&&this._updateActiveDropContainer(this._getConstrainedPointerPosition(e),e)}_removeListeners(){this._pointerMoveSubscription.unsubscribe(),this._pointerUpSubscription.unsubscribe(),this._scrollSubscription.unsubscribe(),this._cleanupShadowRootSelectStart?.(),this._cleanupShadowRootSelectStart=void 0}_destroyPreview(){this._preview?.destroy(),this._preview=null}_destroyPlaceholder(){this._anchor?.remove(),this._placeholder?.remove(),this._placeholderRef?.destroy(),this._placeholder=this._anchor=this._placeholderRef=null}_pointerDown=e=>{if(this.beforeStarted.next(),this._handles.length){let t=this._getTargetHandle(e);t&&!this._disabledHandles.has(t)&&!this.disabled&&this._initializeDragSequence(t,e)}else this.disabled||this._initializeDragSequence(this._rootElement,e)};_pointerMove=e=>{let t=this._getPointerPositionOnPage(e);if(!this._hasStartedDragging()){let r=Math.abs(t.x-this._pickupPositionOnPage.x),o=Math.abs(t.y-this._pickupPositionOnPage.y);if(r+o>=this._config.dragStartThreshold){let s=Date.now()>=this._dragStartTime+this._getDragStartDelay(e),l=this._dropContainer;if(!s){this._endDragSequence(e);return}(!l||!l.isDragging()&&!l.isReceiving())&&(e.cancelable&&e.preventDefault(),this._hasStartedDragging.set(!0),this._ngZone.run(()=>this._startDragSequence(e)))}return}e.cancelable&&e.preventDefault();let i=this._getConstrainedPointerPosition(t);if(this._hasMoved=!0,this._lastKnownPointerPosition=t,this._updatePointerDirectionDelta(i),this._dropContainer)this._updateActiveDropContainer(i,t);else{let r=this.constrainPosition?this._initialDomRect:this._pickupPositionOnPage,o=this._activeTransform;o.x=i.x-r.x+this._passiveTransform.x,o.y=i.y-r.y+this._passiveTransform.y,this._applyRootElementTransform(o.x,o.y)}this._moveEvents.observers.length&&this._ngZone.run(()=>{this._moveEvents.next({source:this,pointerPosition:i,event:e,distance:this._getDragDistance(i),delta:this._pointerDirectionDelta})})};_pointerUp=e=>{this._endDragSequence(e)};_endDragSequence(e){if(this._dragDropRegistry.isDragging(this)&&(this._removeListeners(),this._dragDropRegistry.stopDragging(this),this._toggleNativeDragInteractions(),this._handles&&(this._rootElement.style.webkitTapHighlightColor=this._rootElementTapHighlight),!!this._hasStartedDragging()))if(this.released.next({source:this,event:e}),this._dropContainer)this._dropContainer._stopScrolling(),this._animatePreviewToPlaceholder().then(()=>{this._cleanupDragArtifacts(e),this._cleanupCachedDimensions(),this._dragDropRegistry.stopDragging(this)});else{this._passiveTransform.x=this._activeTransform.x;let t=this._getPointerPositionOnPage(e);this._passiveTransform.y=this._activeTransform.y,this._ngZone.run(()=>{this.ended.next({source:this,distance:this._getDragDistance(t),dropPoint:t,event:e})}),this._cleanupCachedDimensions(),this._dragDropRegistry.stopDragging(this)}}_startDragSequence(e){w_(e)&&(this._lastTouchEventTime=Date.now()),this._toggleNativeDragInteractions();let t=this._getShadowRoot(),i=this._dropContainer;if(t&&this._ngZone.runOutsideAngular(()=>{this._cleanupShadowRootSelectStart=this._renderer.listen(t,"selectstart",cre,sre)}),i){let r=this._rootElement,o=r.parentNode,a=this._placeholder=this._createPlaceholderElement(),s=this._marker=this._marker||this._document.createComment("");o.insertBefore(s,r),this._initialTransform=r.style.transform||"",this._preview=new dE(this._document,this._rootElement,this._direction,this._initialDomRect,this._previewTemplate||null,this.previewClass||null,this._pickupPositionOnPage,this._initialTransform,this._config.zIndex||1e3,this._renderer),this._preview.attach(this._getPreviewInsertionPoint(o,t)),BF(r,!1,UF),this._document.body.appendChild(o.replaceChild(a,r)),this.started.next({source:this,event:e}),i.start(),this._initialContainer=i,this._initialIndex=i.getItemIndex(this)}else this.started.next({source:this,event:e}),this._initialContainer=this._initialIndex=void 0;this._parentPositions.cache(i?i.getScrollableParents():[])}_initializeDragSequence(e,t){this._parentDragRef&&t.stopPropagation();let i=this.isDragging(),r=w_(t),o=!r&&t.button!==0,a=this._rootElement,s=e0(t),l=!r&&this._lastTouchEventTime&&this._lastTouchEventTime+lre>Date.now(),c=r?e1(t):J_(t);if(s&&s.draggable&&t.type==="mousedown"&&t.preventDefault(),i||o||l||c)return;if(this._handles.length){let m=a.style;this._rootElementTapHighlight=m.webkitTapHighlightColor||"",m.webkitTapHighlightColor="transparent"}this._hasMoved=!1,this._hasStartedDragging.set(this._hasMoved),this._removeListeners(),this._initialDomRect=this._rootElement.getBoundingClientRect(),this._pointerMoveSubscription=this._dragDropRegistry.pointerMove.subscribe(this._pointerMove),this._pointerUpSubscription=this._dragDropRegistry.pointerUp.subscribe(this._pointerUp),this._scrollSubscription=this._dragDropRegistry.scrolled(this._getShadowRoot()).subscribe(m=>this._updateOnScroll(m)),this._boundaryElement&&(this._boundaryRect=fE(this._boundaryElement));let d=this._previewTemplate;this._pickupPositionInElement=d&&d.template&&!d.matchSize?{x:0,y:0}:this._getPointerPositionInElement(this._initialDomRect,e,t);let h=this._pickupPositionOnPage=this._lastKnownPointerPosition=this._getPointerPositionOnPage(t);this._pointerDirectionDelta={x:0,y:0},this._pointerPositionAtLastDirectionChange={x:h.x,y:h.y},this._dragStartTime=Date.now(),this._dragDropRegistry.startDragging(this,t)}_cleanupDragArtifacts(e){BF(this._rootElement,!0,UF),this._marker.parentNode.replaceChild(this._rootElement,this._marker),this._destroyPreview(),this._destroyPlaceholder(),this._initialDomRect=this._boundaryRect=this._previewRect=this._initialTransform=void 0,this._ngZone.run(()=>{let t=this._dropContainer,i=t.getItemIndex(this),r=this._getPointerPositionOnPage(e),o=this._getDragDistance(r),a=t._isOverContainer(r.x,r.y);this.ended.next({source:this,distance:o,dropPoint:r,event:e}),this.dropped.next({item:this,currentIndex:i,previousIndex:this._initialIndex,container:t,previousContainer:this._initialContainer,isPointerOverContainer:a,distance:o,dropPoint:r,event:e}),t.drop(this,i,this._initialIndex,this._initialContainer,a,o,r,e),this._dropContainer=this._initialContainer})}_updateActiveDropContainer({x:e,y:t},{x:i,y:r}){let o=this._initialContainer._getSiblingContainerFromPosition(this,e,t);!o&&this._dropContainer!==this._initialContainer&&this._initialContainer._isOverContainer(e,t)&&(o=this._initialContainer),o&&o!==this._dropContainer&&this._ngZone.run(()=>{let a=this._dropContainer.getItemIndex(this),s=this._dropContainer.getItemAtIndex(a+1)?.getVisibleElement()||null;this.exited.next({item:this,container:this._dropContainer}),this._dropContainer.exit(this),this._conditionallyInsertAnchor(o,this._dropContainer,s),this._dropContainer=o,this._dropContainer.enter(this,e,t,o===this._initialContainer&&o.sortingDisabled?this._initialIndex:void 0),this.entered.next({item:this,container:o,currentIndex:o.getItemIndex(this)})}),this.isDragging()&&(this._dropContainer._startScrollingIfNecessary(i,r),this._dropContainer._sortItem(this,e,t,this._pointerDirectionDelta),this.constrainPosition?this._applyPreviewTransform(e,t):this._applyPreviewTransform(e-this._pickupPositionInElement.x,t-this._pickupPositionInElement.y))}_animatePreviewToPlaceholder(){if(!this._hasMoved)return Promise.resolve();let e=this._placeholder.getBoundingClientRect();this._preview.addClass("cdk-drag-animating"),this._applyPreviewTransform(e.left,e.top);let t=this._preview.getTransitionDuration();return t===0?Promise.resolve():this._ngZone.runOutsideAngular(()=>new Promise(i=>{let r=s=>{(!s||this._preview&&e0(s)===this._preview.element&&s.propertyName==="transform")&&(a(),i(),clearTimeout(o))},o=setTimeout(r,t*1.5),a=this._preview.addEventListener("transitionend",r)}))}_createPlaceholderElement(){let e=this._placeholderTemplate,t=e?e.template:null,i;return t?(this._placeholderRef=e.viewContainer.createEmbeddedView(t,e.context),this._placeholderRef.detectChanges(),i=qF(this._placeholderRef,this._document)):i=lE(this._rootElement),i.style.pointerEvents="none",i.classList.add(WF),i}_getPointerPositionInElement(e,t,i){let r=t===this._rootElement?null:t,o=r?r.getBoundingClientRect():e,a=w_(i)?i.targetTouches[0]:i,s=this._getViewportScrollPosition(),l=a.pageX-o.left-s.left,c=a.pageY-o.top-s.top;return{x:o.left-e.left+l,y:o.top-e.top+c}}_getPointerPositionOnPage(e){let t=this._getViewportScrollPosition(),i=w_(e)?e.touches[0]||e.changedTouches[0]||{pageX:0,pageY:0}:e,r=i.pageX-t.left,o=i.pageY-t.top;if(this._ownerSVGElement){let a=this._ownerSVGElement.getScreenCTM();if(a){let s=this._ownerSVGElement.createSVGPoint();return s.x=r,s.y=o,s.matrixTransform(a.inverse())}}return{x:r,y:o}}_getConstrainedPointerPosition(e){let t=this._dropContainer?this._dropContainer.lockAxis:null,{x:i,y:r}=this.constrainPosition?this.constrainPosition(e,this,this._initialDomRect,this._pickupPositionInElement):e;if(this.lockAxis==="x"||t==="x"?r=this._pickupPositionOnPage.y-(this.constrainPosition?this._pickupPositionInElement.y:0):(this.lockAxis==="y"||t==="y")&&(i=this._pickupPositionOnPage.x-(this.constrainPosition?this._pickupPositionInElement.x:0)),this._boundaryRect){let{x:o,y:a}=this.constrainPosition?{x:0,y:0}:this._pickupPositionInElement,s=this._boundaryRect,{width:l,height:c}=this._getPreviewRect(),d=s.top+a,h=s.bottom-(c-a),m=s.left+o,f=s.right-(l-o);i=HF(i,m,f),r=HF(r,d,h)}return{x:i,y:r}}_updatePointerDirectionDelta(e){let{x:t,y:i}=e,r=this._pointerDirectionDelta,o=this._pointerPositionAtLastDirectionChange,a=Math.abs(t-o.x),s=Math.abs(i-o.y);return a>this._config.pointerDirectionChangeThreshold&&(r.x=t>o.x?1:-1,o.x=t),s>this._config.pointerDirectionChangeThreshold&&(r.y=i>o.y?1:-1,o.y=i),r}_toggleNativeDragInteractions(){if(!this._rootElement||!this._handles)return;let e=this._handles.length>0||!this.isDragging();e!==this._nativeInteractionsEnabled&&(this._nativeInteractionsEnabled=e,Tf(this._rootElement,e))}_removeRootElementListeners(){this._rootElementCleanups?.forEach(e=>e()),this._rootElementCleanups=void 0}_applyRootElementTransform(e,t){let i=1/this.scale,r=S_(e*i,t*i),o=this._rootElement.style;this._initialTransform==null&&(this._initialTransform=o.transform&&o.transform!="none"?o.transform:""),o.transform=x2(r,this._initialTransform)}_applyPreviewTransform(e,t){let i=this._previewTemplate?.template?void 0:this._initialTransform,r=S_(e,t);this._preview.setTransform(x2(r,i))}_getDragDistance(e){let t=this._pickupPositionOnPage;return t?{x:e.x-t.x,y:e.y-t.y}:{x:0,y:0}}_cleanupCachedDimensions(){this._boundaryRect=this._previewRect=void 0,this._parentPositions.clear()}_containInsideBoundaryOnResize(){let{x:e,y:t}=this._passiveTransform;if(e===0&&t===0||this.isDragging()||!this._boundaryElement)return;let i=this._rootElement.getBoundingClientRect(),r=this._boundaryElement.getBoundingClientRect();if(r.width===0&&r.height===0||i.width===0&&i.height===0)return;let o=r.left-i.left,a=i.right-r.right,s=r.top-i.top,l=i.bottom-r.bottom;r.width>i.width?(o>0&&(e+=o),a>0&&(e-=a)):e=0,r.height>i.height?(s>0&&(t+=s),l>0&&(t-=l)):t=0,(e!==this._passiveTransform.x||t!==this._passiveTransform.y)&&this.setFreeDragPosition({y:t,x:e})}_getDragStartDelay(e){let t=this.dragStartDelay;return typeof t=="number"?t:w_(e)?t.touch:t?t.mouse:0}_updateOnScroll(e){let t=this._parentPositions.handleScroll(e);if(t){let i=e0(e);this._boundaryRect&&i!==this._boundaryElement&&i.contains(this._boundaryElement)&&M_(this._boundaryRect,t.top,t.left),this._pickupPositionOnPage.x+=t.left,this._pickupPositionOnPage.y+=t.top,this._dropContainer||(this._activeTransform.x-=t.left,this._activeTransform.y-=t.top,this._applyRootElementTransform(this._activeTransform.x,this._activeTransform.y))}}_getViewportScrollPosition(){return this._parentPositions.positions.get(this._document)?.scrollPosition||this._parentPositions.getViewportScrollPosition()}_getShadowRoot(){return this._cachedShadowRoot===void 0&&(this._cachedShadowRoot=Y_(this._rootElement)),this._cachedShadowRoot}_getPreviewInsertionPoint(e,t){let i=this._previewContainer||"global";if(i==="parent")return e;if(i==="global"){let r=this._document;return t||r.fullscreenElement||r.webkitFullscreenElement||r.mozFullScreenElement||r.msFullscreenElement||r.body}return Ec(i)}_getPreviewRect(){return(!this._previewRect||!this._previewRect.width&&!this._previewRect.height)&&(this._previewRect=this._preview?this._preview.getBoundingClientRect():this._initialDomRect),this._previewRect}_nativeDragStart=e=>{if(this._handles.length){let t=this._getTargetHandle(e);t&&!this._disabledHandles.has(t)&&!this.disabled&&e.preventDefault()}else this.disabled||e.preventDefault()};_getTargetHandle(e){return this._handles.find(t=>e.target&&(e.target===t||t.contains(e.target)))}_conditionallyInsertAnchor(e,t,i){if(e===this._initialContainer)this._anchor?.remove(),this._anchor=null;else if(t===this._initialContainer&&t.hasAnchor){let r=this._anchor??=lE(this._placeholder);r.classList.remove(WF),r.classList.add("cdk-drag-anchor"),r.style.transform="",i?i.before(r):Ec(t.element).appendChild(r)}}};function HF(n,e,t){return Math.max(e,Math.min(t,n))}function w_(n){return n.type[0]==="t"}function cre(n){n.preventDefault()}function il(n,e,t){let i=pE(e,n.length-1),r=pE(t,n.length-1);if(i===r)return;let o=n[i],a=r<i?-1:1;for(let s=i;s!==r;s+=a)n[s]=n[s+a];n[r]=o}function XF(n,e,t,i){let r=pE(i,e.length);n.length&&e.splice(r,0,n[t])}function pE(n,e){return Math.max(0,Math.min(e,n))}var C2=class{_dragDropRegistry;_element;_sortPredicate;_itemPositions=[];_activeDraggables;orientation="vertical";direction="ltr";constructor(e){this._dragDropRegistry=e}_previousSwap={drag:null,delta:0,overlaps:!1};start(e){this.withItems(e)}sort(e,t,i,r){let o=this._itemPositions,a=this._getItemIndexFromPointerPosition(e,t,i,r);if(a===-1&&o.length>0)return null;let s=this.orientation==="horizontal",l=o.findIndex(S=>S.drag===e),c=o[a],d=o[l].clientRect,h=c.clientRect,m=l>a?1:-1,f=this._getItemOffsetPx(d,h,m),y=this._getSiblingOffsetPx(l,o,m),b=o.slice();return il(o,l,a),o.forEach((S,I)=>{if(b[I]===S)return;let D=S.drag===e,E=D?f:y,C=D?e.getPlaceholderElement():S.drag.getRootElement();S.offset+=E;let x=Math.round(S.offset*(1/S.drag.scale));s?(C.style.transform=x2(`translate3d(${x}px, 0, 0)`,S.initialTransform),M_(S.clientRect,0,E)):(C.style.transform=x2(`translate3d(0, ${x}px, 0)`,S.initialTransform),M_(S.clientRect,E,0))}),this._previousSwap.overlaps=cE(h,t,i),this._previousSwap.drag=c.drag,this._previousSwap.delta=s?r.x:r.y,{previousIndex:l,currentIndex:a}}enter(e,t,i,r){let o=this._activeDraggables,a=o.indexOf(e),s=e.getPlaceholderElement();a>-1&&o.splice(a,1);let l=r==null||r<0?this._getItemIndexFromPointerPosition(e,t,i):r,c=o[l];if(c===e&&(c=o[l+1]),!c&&(l==null||l===-1||l<o.length-1)&&this._shouldEnterAsFirstChild(t,i)&&(c=o[0]),c&&!this._dragDropRegistry.isDragging(c)){let d=c.getRootElement();d.parentElement.insertBefore(s,d),o.splice(l,0,e)}else this._element.appendChild(s),o.push(e);s.style.transform="",this._cacheItemPositions()}withItems(e){this._activeDraggables=e.slice(),this._cacheItemPositions()}withSortPredicate(e){this._sortPredicate=e}reset(){this._activeDraggables?.forEach(e=>{let t=e.getRootElement();if(t){let i=this._itemPositions.find(r=>r.drag===e)?.initialTransform;t.style.transform=i||""}}),this._itemPositions=[],this._activeDraggables=[],this._previousSwap.drag=null,this._previousSwap.delta=0,this._previousSwap.overlaps=!1}getActiveItemsSnapshot(){return this._activeDraggables}getItemIndex(e){return this._getVisualItemPositions().findIndex(t=>t.drag===e)}getItemAtIndex(e){return this._getVisualItemPositions()[e]?.drag||null}updateOnScroll(e,t){this._itemPositions.forEach(({clientRect:i})=>{M_(i,e,t)}),this._itemPositions.forEach(({drag:i})=>{this._dragDropRegistry.isDragging(i)&&i._sortFromLastPointerPosition()})}withElementContainer(e){this._element=e}_cacheItemPositions(){let e=this.orientation==="horizontal";this._itemPositions=this._activeDraggables.map(t=>{let i=t.getVisibleElement();return{drag:t,offset:0,initialTransform:i.style.transform||"",clientRect:fE(i)}}).sort((t,i)=>e?t.clientRect.left-i.clientRect.left:t.clientRect.top-i.clientRect.top)}_getVisualItemPositions(){return this.orientation==="horizontal"&&this.direction==="rtl"?this._itemPositions.slice().reverse():this._itemPositions}_getItemOffsetPx(e,t,i){let r=this.orientation==="horizontal",o=r?t.left-e.left:t.top-e.top;return i===-1&&(o+=r?t.width-e.width:t.height-e.height),o}_getSiblingOffsetPx(e,t,i){let r=this.orientation==="horizontal",o=t[e].clientRect,a=t[e+i*-1],s=o[r?"width":"height"]*i;if(a){let l=r?"left":"top",c=r?"right":"bottom";i===-1?s-=a.clientRect[l]-o[c]:s+=o[l]-a.clientRect[c]}return s}_shouldEnterAsFirstChild(e,t){if(!this._activeDraggables.length)return!1;let i=this._itemPositions,r=this.orientation==="horizontal";if(i[0].drag!==this._activeDraggables[0]){let a=i[i.length-1].clientRect;return r?e>=a.right:t>=a.bottom}else{let a=i[0].clientRect;return r?e<=a.left:t<=a.top}}_getItemIndexFromPointerPosition(e,t,i,r){let o=this.orientation==="horizontal",a=this._itemPositions.findIndex(({drag:s,clientRect:l})=>{if(s===e)return!1;if(r){let c=o?r.x:r.y;if(s===this._previousSwap.drag&&this._previousSwap.overlaps&&c===this._previousSwap.delta)return!1}return o?t>=Math.floor(l.left)&&t<Math.floor(l.right):i>=Math.floor(l.top)&&i<Math.floor(l.bottom)});return a===-1||!this._sortPredicate(a,e)?-1:a}},hE=class{_document;_dragDropRegistry;_element;_sortPredicate;_rootNode;_activeItems;_previousSwap={drag:null,deltaX:0,deltaY:0,overlaps:!1};_relatedNodes=[];constructor(e,t){this._document=e,this._dragDropRegistry=t}start(e){let t=this._element.childNodes;this._relatedNodes=[];for(let i=0;i<t.length;i++){let r=t[i];this._relatedNodes.push([r,r.nextSibling])}this.withItems(e)}sort(e,t,i,r){let o=this._getItemIndexFromPointerPosition(e,t,i),a=this._previousSwap;if(o===-1||this._activeItems[o]===e)return null;let s=this._activeItems[o];if(a.drag===s&&a.overlaps&&a.deltaX===r.x&&a.deltaY===r.y)return null;let l=this.getItemIndex(e),c=e.getPlaceholderElement(),d=s.getRootElement();o>l?d.after(c):d.before(c),il(this._activeItems,l,o);let h=this._getRootNode().elementFromPoint(t,i);return a.deltaX=r.x,a.deltaY=r.y,a.drag=s,a.overlaps=d===h||d.contains(h),{previousIndex:l,currentIndex:o}}enter(e,t,i,r){let o=this._activeItems.indexOf(e);o>-1&&this._activeItems.splice(o,1);let a=r==null||r<0?this._getItemIndexFromPointerPosition(e,t,i):r;a===-1&&(a=this._getClosestItemIndexToPointer(e,t,i));let s=this._activeItems[a];s&&!this._dragDropRegistry.isDragging(s)?(this._activeItems.splice(a,0,e),s.getRootElement().before(e.getPlaceholderElement())):(this._activeItems.push(e),this._element.appendChild(e.getPlaceholderElement()))}withItems(e){this._activeItems=e.slice()}withSortPredicate(e){this._sortPredicate=e}reset(){let e=this._element,t=this._previousSwap;for(let i=this._relatedNodes.length-1;i>-1;i--){let[r,o]=this._relatedNodes[i];r.parentNode===e&&r.nextSibling!==o&&(o===null?e.appendChild(r):o.parentNode===e&&e.insertBefore(r,o))}this._relatedNodes=[],this._activeItems=[],t.drag=null,t.deltaX=t.deltaY=0,t.overlaps=!1}getActiveItemsSnapshot(){return this._activeItems}getItemIndex(e){return this._activeItems.indexOf(e)}getItemAtIndex(e){return this._activeItems[e]||null}updateOnScroll(){this._activeItems.forEach(e=>{this._dragDropRegistry.isDragging(e)&&e._sortFromLastPointerPosition()})}withElementContainer(e){e!==this._element&&(this._element=e,this._rootNode=void 0)}_getItemIndexFromPointerPosition(e,t,i){let r=this._getRootNode().elementFromPoint(Math.floor(t),Math.floor(i)),o=r?this._activeItems.findIndex(a=>{let s=a.getRootElement();return r===s||s.contains(r)}):-1;return o===-1||!this._sortPredicate(o,e)?-1:o}_getRootNode(){return this._rootNode||(this._rootNode=Y_(this._element)||this._document),this._rootNode}_getClosestItemIndexToPointer(e,t,i){if(this._activeItems.length===0)return-1;if(this._activeItems.length===1)return 0;let r=1/0,o=-1;for(let a=0;a<this._activeItems.length;a++){let s=this._activeItems[a];if(s!==e){let{x:l,y:c}=s.getRootElement().getBoundingClientRect(),d=Math.hypot(t-l,i-c);d<r&&(r=d,o=a)}}return o}},KF=.05,YF=.05,tl=(function(n){return n[n.NONE=0]="NONE",n[n.UP=1]="UP",n[n.DOWN=2]="DOWN",n})(tl||{}),xa=(function(n){return n[n.NONE=0]="NONE",n[n.LEFT=1]="LEFT",n[n.RIGHT=2]="RIGHT",n})(xa||{});function QF(n,e){return new mE(e,n.get(M2),n.get(Go),n.get(Gi),n.get(jp))}var mE=class{_dragDropRegistry;_ngZone;_viewportRuler;element;disabled=!1;sortingDisabled=!1;lockAxis=null;autoScrollDisabled=!1;autoScrollStep=2;hasAnchor=!1;enterPredicate=()=>!0;sortPredicate=()=>!0;beforeStarted=new ze;entered=new ze;exited=new ze;dropped=new ze;sorted=new ze;receivingStarted=new ze;receivingStopped=new ze;data;_container;_isDragging=!1;_parentPositions;_sortStrategy;_domRect;_draggables=[];_siblings=[];_activeSiblings=new Set;_viewportScrollSubscription=rr.EMPTY;_verticalScrollDirection=tl.NONE;_horizontalScrollDirection=xa.NONE;_scrollNode;_stopScrollTimers=new ze;_cachedShadowRoot=null;_document;_scrollableElements=[];_initialScrollSnap;_direction="ltr";constructor(e,t,i,r,o){this._dragDropRegistry=t,this._ngZone=r,this._viewportRuler=o;let a=this.element=Ec(e);this._document=i,this.withOrientation("vertical").withElementContainer(a),t.registerDropContainer(this),this._parentPositions=new b2(i)}dispose(){this._stopScrolling(),this._stopScrollTimers.complete(),this._viewportScrollSubscription.unsubscribe(),this.beforeStarted.complete(),this.entered.complete(),this.exited.complete(),this.dropped.complete(),this.sorted.complete(),this.receivingStarted.complete(),this.receivingStopped.complete(),this._activeSiblings.clear(),this._scrollNode=null,this._parentPositions.clear(),this._dragDropRegistry.removeDropContainer(this)}isDragging(){return this._isDragging}start(){this._draggingStarted(),this._notifyReceivingSiblings()}enter(e,t,i,r){this._draggingStarted(),r==null&&this.sortingDisabled&&(r=this._draggables.indexOf(e)),this._sortStrategy.enter(e,t,i,r),this._cacheParentPositions(),this._notifyReceivingSiblings(),this.entered.next({item:e,container:this,currentIndex:this.getItemIndex(e)})}exit(e){this._reset(),this.exited.next({item:e,container:this})}drop(e,t,i,r,o,a,s,l={}){this._reset(),this.dropped.next({item:e,currentIndex:t,previousIndex:i,container:this,previousContainer:r,isPointerOverContainer:o,distance:a,dropPoint:s,event:l})}withItems(e){let t=this._draggables;return this._draggables=e,e.forEach(i=>i._withDropContainer(this)),this.isDragging()&&(t.filter(r=>r.isDragging()).every(r=>e.indexOf(r)===-1)?this._reset():this._sortStrategy.withItems(this._draggables)),this}withDirection(e){return this._direction=e,this._sortStrategy instanceof C2&&(this._sortStrategy.direction=e),this}connectedTo(e){return this._siblings=e.slice(),this}withOrientation(e){if(e==="mixed")this._sortStrategy=new hE(this._document,this._dragDropRegistry);else{let t=new C2(this._dragDropRegistry);t.direction=this._direction,t.orientation=e,this._sortStrategy=t}return this._sortStrategy.withElementContainer(this._container),this._sortStrategy.withSortPredicate((t,i)=>this.sortPredicate(t,i,this)),this}withScrollableParents(e){let t=this._container;return this._scrollableElements=e.indexOf(t)===-1?[t,...e]:e.slice(),this}withElementContainer(e){if(e===this._container)return this;let t=Ec(this.element),i=this._scrollableElements.indexOf(this._container),r=this._scrollableElements.indexOf(e);return i>-1&&this._scrollableElements.splice(i,1),r>-1&&this._scrollableElements.splice(r,1),this._sortStrategy&&this._sortStrategy.withElementContainer(e),this._cachedShadowRoot=null,this._scrollableElements.unshift(e),this._container=e,this}getScrollableParents(){return this._scrollableElements}getItemIndex(e){return this._isDragging?this._sortStrategy.getItemIndex(e):this._draggables.indexOf(e)}getItemAtIndex(e){return this._isDragging?this._sortStrategy.getItemAtIndex(e):this._draggables[e]||null}isReceiving(){return this._activeSiblings.size>0}_sortItem(e,t,i,r){if(this.sortingDisabled||!this._domRect||!NF(this._domRect,KF,t,i))return;let o=this._sortStrategy.sort(e,t,i,r);o&&this.sorted.next({previousIndex:o.previousIndex,currentIndex:o.currentIndex,container:this,item:e})}_startScrollingIfNecessary(e,t){if(this.autoScrollDisabled)return;let i,r=tl.NONE,o=xa.NONE;if(this._parentPositions.positions.forEach((a,s)=>{s===this._document||!a.clientRect||i||NF(a.clientRect,KF,e,t)&&([r,o]=dre(s,a.clientRect,this._direction,e,t),(r||o)&&(i=s))}),!r&&!o){let{width:a,height:s}=this._viewportRuler.getViewportSize(),l={width:a,height:s,top:0,right:a,bottom:s,left:0};r=JF(l,t),o=eN(l,e),i=window}i&&(r!==this._verticalScrollDirection||o!==this._horizontalScrollDirection||i!==this._scrollNode)&&(this._verticalScrollDirection=r,this._horizontalScrollDirection=o,this._scrollNode=i,(r||o)&&i?this._ngZone.runOutsideAngular(this._startScrollInterval):this._stopScrolling())}_stopScrolling(){this._stopScrollTimers.next()}_draggingStarted(){let e=this._container.style;this.beforeStarted.next(),this._isDragging=!0,this._initialScrollSnap=e.msScrollSnapType||e.scrollSnapType||"",e.scrollSnapType=e.msScrollSnapType="none",this._sortStrategy.start(this._draggables),this._cacheParentPositions(),this._viewportScrollSubscription.unsubscribe(),this._listenToScrollEvents()}_cacheParentPositions(){this._parentPositions.cache(this._scrollableElements),this._domRect=this._parentPositions.positions.get(this._container).clientRect}_reset(){this._isDragging=!1;let e=this._container.style;e.scrollSnapType=e.msScrollSnapType=this._initialScrollSnap,this._siblings.forEach(t=>t._stopReceiving(this)),this._sortStrategy.reset(),this._stopScrolling(),this._viewportScrollSubscription.unsubscribe(),this._parentPositions.clear()}_startScrollInterval=()=>{this._stopScrolling(),hI(0,dI).pipe(xi(this._stopScrollTimers)).subscribe(()=>{let e=this._scrollNode,t=this.autoScrollStep;this._verticalScrollDirection===tl.UP?e.scrollBy(0,-t):this._verticalScrollDirection===tl.DOWN&&e.scrollBy(0,t),this._horizontalScrollDirection===xa.LEFT?e.scrollBy(-t,0):this._horizontalScrollDirection===xa.RIGHT&&e.scrollBy(t,0)})};_isOverContainer(e,t){return this._domRect!=null&&cE(this._domRect,e,t)}_getSiblingContainerFromPosition(e,t,i){return this._siblings.find(r=>r._canReceive(e,t,i))}_canReceive(e,t,i){if(!this._domRect||!cE(this._domRect,t,i)||!this.enterPredicate(e,this))return!1;let r=this._getShadowRoot().elementFromPoint(t,i);return r?r===this._container||this._container.contains(r):!1}_startReceiving(e,t){let i=this._activeSiblings;!i.has(e)&&t.every(r=>this.enterPredicate(r,this)||this._draggables.indexOf(r)>-1)&&(i.add(e),this._cacheParentPositions(),this._listenToScrollEvents(),this.receivingStarted.next({initiator:e,receiver:this,items:t}))}_stopReceiving(e){this._activeSiblings.delete(e),this._viewportScrollSubscription.unsubscribe(),this.receivingStopped.next({initiator:e,receiver:this})}_listenToScrollEvents(){this._viewportScrollSubscription=this._dragDropRegistry.scrolled(this._getShadowRoot()).subscribe(e=>{if(this.isDragging()){let t=this._parentPositions.handleScroll(e);t&&this._sortStrategy.updateOnScroll(t.top,t.left)}else this.isReceiving()&&this._cacheParentPositions()})}_getShadowRoot(){if(!this._cachedShadowRoot){let e=Y_(this._container);this._cachedShadowRoot=e||this._document}return this._cachedShadowRoot}_notifyReceivingSiblings(){let e=this._sortStrategy.getActiveItemsSnapshot().filter(t=>t.isDragging());this._siblings.forEach(t=>t._startReceiving(this,e))}};function JF(n,e){let{top:t,bottom:i,height:r}=n,o=r*YF;return e>=t-o&&e<=t+o?tl.UP:e>=i-o&&e<=i+o?tl.DOWN:tl.NONE}function eN(n,e){let{left:t,right:i,width:r}=n,o=r*YF;return e>=t-o&&e<=t+o?xa.LEFT:e>=i-o&&e<=i+o?xa.RIGHT:xa.NONE}function dre(n,e,t,i,r){let o=JF(e,r),a=eN(e,i),s=tl.NONE,l=xa.NONE;if(o){let c=n.scrollTop;o===tl.UP?c>0&&(s=tl.UP):n.scrollHeight-c>n.clientHeight&&(s=tl.DOWN)}if(a){let c=n.scrollLeft;t==="rtl"?a===xa.RIGHT?c<0&&(l=xa.RIGHT):n.scrollWidth+c>n.clientWidth&&(l=xa.LEFT):a===xa.LEFT?c>0&&(l=xa.LEFT):n.scrollWidth-c>n.clientWidth&&(l=xa.RIGHT)}return[s,l]}var ure=(()=>{class n{_injector=M(Kr);constructor(){}createDrag(t,i){return ZF(this._injector,t,i)}createDropList(t){return QF(this._injector,t)}static \u0275fac=function(i){return new(i||n)};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),w2=new xt("CDK_DRAG_PARENT");var tN=new xt("CdkDragHandle"),Cu=(()=>{class n{element=M(Ct);_parentDrag=M(w2,{optional:!0,skipSelf:!0});_dragDropRegistry=M(M2);_stateChanges=new ze;get disabled(){return this._disabled}set disabled(t){this._disabled=t,this._stateChanges.next(this)}_disabled=!1;constructor(){this._parentDrag?._addHandle(this)}ngAfterViewInit(){if(!this._parentDrag){let t=this.element.nativeElement.parentElement;for(;t;){let i=this._dragDropRegistry.getDragDirectiveForNode(t);if(i){this._parentDrag=i,i._addHandle(this);break}t=t.parentElement}}}ngOnDestroy(){this._parentDrag?._removeHandle(this),this._stateChanges.complete()}static \u0275fac=function(i){return new(i||n)};static \u0275dir=lt({type:n,selectors:[["","cdkDragHandle",""]],hostAttrs:[1,"cdk-drag-handle"],inputs:{disabled:[2,"cdkDragHandleDisabled","disabled",Ue]},features:[Lt([{provide:tN,useExisting:n}])]})}return n})(),iN=new xt("CDK_DRAG_CONFIG"),nN=new xt("CdkDropList"),Qa=(()=>{class n{element=M(Ct);dropContainer=M(nN,{optional:!0,skipSelf:!0});_ngZone=M(Gi);_viewContainerRef=M(pa);_dir=M(co,{optional:!0});_changeDetectorRef=M(re);_selfHandle=M(tN,{optional:!0,self:!0});_parentDrag=M(w2,{optional:!0,skipSelf:!0});_dragDropRegistry=M(M2);_destroyed=new ze;_handles=new al([]);_previewTemplate=null;_placeholderTemplate=null;_dragRef;data;lockAxis=null;rootElementSelector;boundaryElement;dragStartDelay;freeDragPosition;get disabled(){return this._disabled||!!(this.dropContainer&&this.dropContainer.disabled)}set disabled(t){this._disabled=t,this._dragRef.disabled=this._disabled}_disabled=!1;constrainPosition;previewClass;previewContainer;scale=1;started=new he;released=new he;ended=new he;entered=new he;exited=new he;dropped=new he;moved=new Ru(t=>{let i=this._dragRef.moved.pipe(Fr(r=>({source:this,pointerPosition:r.pointerPosition,event:r.event,delta:r.delta,distance:r.distance}))).subscribe(t);return()=>{i.unsubscribe()}});_injector=M(Kr);constructor(){let t=this.dropContainer,i=M(iN,{optional:!0});this._dragRef=ZF(this._injector,this.element,{dragStartThreshold:i&&i.dragStartThreshold!=null?i.dragStartThreshold:5,pointerDirectionChangeThreshold:i&&i.pointerDirectionChangeThreshold!=null?i.pointerDirectionChangeThreshold:5,zIndex:i?.zIndex}),this._dragRef.data=this,this._dragDropRegistry.registerDirectiveNode(this.element.nativeElement,this),i&&this._assignDefaults(i),t&&(t.addItem(this),t._dropListRef.beforeStarted.pipe(xi(this._destroyed)).subscribe(()=>{this._dragRef.scale=this.scale})),this._syncInputs(this._dragRef),this._handleEvents(this._dragRef)}getPlaceholderElement(){return this._dragRef.getPlaceholderElement()}getRootElement(){return this._dragRef.getRootElement()}reset(){this._dragRef.reset()}resetToBoundary(){this._dragRef.resetToBoundary()}getFreeDragPosition(){return this._dragRef.getFreeDragPosition()}setFreeDragPosition(t){this._dragRef.setFreeDragPosition(t)}ngAfterViewInit(){ll(()=>{this._updateRootElement(),this._setupHandlesListener(),this._dragRef.scale=this.scale,this.freeDragPosition&&this._dragRef.setFreeDragPosition(this.freeDragPosition)},{injector:this._injector})}ngOnChanges(t){let i=t.rootElementSelector,r=t.freeDragPosition;i&&!i.firstChange&&this._updateRootElement(),this._dragRef.scale=this.scale,r&&!r.firstChange&&this.freeDragPosition&&this._dragRef.setFreeDragPosition(this.freeDragPosition)}ngOnDestroy(){this.dropContainer&&this.dropContainer.removeItem(this),this._dragDropRegistry.removeDirectiveNode(this.element.nativeElement),this._ngZone.runOutsideAngular(()=>{this._handles.complete(),this._destroyed.next(),this._destroyed.complete(),this._dragRef.dispose()})}_addHandle(t){let i=this._handles.getValue();i.push(t),this._handles.next(i)}_removeHandle(t){let i=this._handles.getValue(),r=i.indexOf(t);r>-1&&(i.splice(r,1),this._handles.next(i))}_setPreviewTemplate(t){this._previewTemplate=t}_resetPreviewTemplate(t){t===this._previewTemplate&&(this._previewTemplate=null)}_setPlaceholderTemplate(t){this._placeholderTemplate=t}_resetPlaceholderTemplate(t){t===this._placeholderTemplate&&(this._placeholderTemplate=null)}_updateRootElement(){let t=this.element.nativeElement,i=t;this.rootElementSelector&&(i=t.closest!==void 0?t.closest(this.rootElementSelector):t.parentElement?.closest(this.rootElementSelector)),this._dragRef.withRootElement(i||t)}_getBoundaryElement(){let t=this.boundaryElement;return t?typeof t=="string"?this.element.nativeElement.closest(t):Ec(t):null}_syncInputs(t){t.beforeStarted.subscribe(()=>{if(!t.isDragging()){let i=this._dir,r=this.dragStartDelay,o=this._placeholderTemplate?{template:this._placeholderTemplate.templateRef,context:this._placeholderTemplate.data,viewContainer:this._viewContainerRef}:null,a=this._previewTemplate?{template:this._previewTemplate.templateRef,context:this._previewTemplate.data,matchSize:this._previewTemplate.matchSize,viewContainer:this._viewContainerRef}:null;t.disabled=this.disabled,t.lockAxis=this.lockAxis,t.scale=this.scale,t.dragStartDelay=typeof r=="object"&&r?r:zC(r),t.constrainPosition=this.constrainPosition,t.previewClass=this.previewClass,t.withBoundaryElement(this._getBoundaryElement()).withPlaceholderTemplate(o).withPreviewTemplate(a).withPreviewContainer(this.previewContainer||"global"),i&&t.withDirection(i.value)}}),t.beforeStarted.pipe(Vo(1)).subscribe(()=>{if(this._parentDrag){t.withParent(this._parentDrag._dragRef);return}let i=this.element.nativeElement.parentElement;for(;i;){let r=this._dragDropRegistry.getDragDirectiveForNode(i);if(r){t.withParent(r._dragRef);break}i=i.parentElement}})}_handleEvents(t){t.started.subscribe(i=>{this.started.emit({source:this,event:i.event}),this._changeDetectorRef.markForCheck()}),t.released.subscribe(i=>{this.released.emit({source:this,event:i.event})}),t.ended.subscribe(i=>{this.ended.emit({source:this,distance:i.distance,dropPoint:i.dropPoint,event:i.event}),this._changeDetectorRef.markForCheck()}),t.entered.subscribe(i=>{this.entered.emit({container:i.container.data,item:this,currentIndex:i.currentIndex})}),t.exited.subscribe(i=>{this.exited.emit({container:i.container.data,item:this})}),t.dropped.subscribe(i=>{this.dropped.emit({previousIndex:i.previousIndex,currentIndex:i.currentIndex,previousContainer:i.previousContainer.data,container:i.container.data,isPointerOverContainer:i.isPointerOverContainer,item:this,distance:i.distance,dropPoint:i.dropPoint,event:i.event})})}_assignDefaults(t){let{lockAxis:i,dragStartDelay:r,constrainPosition:o,previewClass:a,boundaryElement:s,draggingDisabled:l,rootElementSelector:c,previewContainer:d}=t;this.disabled=l??!1,this.dragStartDelay=r||0,this.lockAxis=i||null,o&&(this.constrainPosition=o),a&&(this.previewClass=a),s&&(this.boundaryElement=s),c&&(this.rootElementSelector=c),d&&(this.previewContainer=d)}_setupHandlesListener(){this._handles.pipe(ua(t=>{let i=t.map(r=>r.element);this._selfHandle&&this.rootElementSelector&&i.push(this.element),this._dragRef.withHandles(i)}),mr(t=>Ir(...t.map(i=>i._stateChanges.pipe(un(i))))),xi(this._destroyed)).subscribe(t=>{let i=this._dragRef,r=t.element.nativeElement;t.disabled?i.disableHandle(r):i.enableHandle(r)})}static \u0275fac=function(i){return new(i||n)};static \u0275dir=lt({type:n,selectors:[["","cdkDrag",""]],hostAttrs:[1,"cdk-drag"],hostVars:4,hostBindings:function(i,r){i&2&&_t("cdk-drag-disabled",r.disabled)("cdk-drag-dragging",r._dragRef.isDragging())},inputs:{data:[0,"cdkDragData","data"],lockAxis:[0,"cdkDragLockAxis","lockAxis"],rootElementSelector:[0,"cdkDragRootElement","rootElementSelector"],boundaryElement:[0,"cdkDragBoundary","boundaryElement"],dragStartDelay:[0,"cdkDragStartDelay","dragStartDelay"],freeDragPosition:[0,"cdkDragFreeDragPosition","freeDragPosition"],disabled:[2,"cdkDragDisabled","disabled",Ue],constrainPosition:[0,"cdkDragConstrainPosition","constrainPosition"],previewClass:[0,"cdkDragPreviewClass","previewClass"],previewContainer:[0,"cdkDragPreviewContainer","previewContainer"],scale:[2,"cdkDragScale","scale",zi]},outputs:{started:"cdkDragStarted",released:"cdkDragReleased",ended:"cdkDragEnded",entered:"cdkDragEntered",exited:"cdkDragExited",dropped:"cdkDragDropped",moved:"cdkDragMoved"},exportAs:["cdkDrag"],features:[Lt([{provide:w2,useExisting:n}]),Se]})}return n})(),$F=new xt("CdkDropListGroup");var Ef=(()=>{class n{element=M(Ct);_changeDetectorRef=M(re);_scrollDispatcher=M(jC);_dir=M(co,{optional:!0});_group=M($F,{optional:!0,skipSelf:!0});_latestSortedRefs;_destroyed=new ze;_scrollableParentsResolved=!1;static _dropLists=[];_dropListRef;connectedTo=[];data;orientation="vertical";id=M(or).getId("cdk-drop-list-");lockAxis=null;get disabled(){return this._disabled||!!this._group&&this._group.disabled}set disabled(t){this._dropListRef.disabled=this._disabled=t}_disabled=!1;sortingDisabled=!1;enterPredicate=()=>!0;sortPredicate=()=>!0;autoScrollDisabled=!1;autoScrollStep;elementContainerSelector=null;hasAnchor=!1;dropped=new he;entered=new he;exited=new he;sorted=new he;_unsortedItems=new Set;constructor(){let t=M(iN,{optional:!0}),i=M(Kr);this._dropListRef=QF(i,this.element),this._dropListRef.data=this,t&&this._assignDefaults(t),this._dropListRef.enterPredicate=(r,o)=>this.enterPredicate(r.data,o.data),this._dropListRef.sortPredicate=(r,o,a)=>this.sortPredicate(r,o.data,a.data),this._setupInputSyncSubscription(this._dropListRef),this._handleEvents(this._dropListRef),n._dropLists.push(this),this._group&&this._group._items.add(this)}addItem(t){this._unsortedItems.add(t),t._dragRef._withDropContainer(this._dropListRef),this._dropListRef.isDragging()&&this._syncItemsWithRef(this.getSortedItems().map(i=>i._dragRef))}removeItem(t){if(this._unsortedItems.delete(t),this._latestSortedRefs){let i=this._latestSortedRefs.indexOf(t._dragRef);i>-1&&(this._latestSortedRefs.splice(i,1),this._syncItemsWithRef(this._latestSortedRefs))}}getSortedItems(){return Array.from(this._unsortedItems).sort((t,i)=>t._dragRef.getVisibleElement().compareDocumentPosition(i._dragRef.getVisibleElement())&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)}ngOnDestroy(){let t=n._dropLists.indexOf(this);t>-1&&n._dropLists.splice(t,1),this._group&&this._group._items.delete(this),this._latestSortedRefs=void 0,this._unsortedItems.clear(),this._dropListRef.dispose(),this._destroyed.next(),this._destroyed.complete()}_setupInputSyncSubscription(t){this._dir&&this._dir.change.pipe(un(this._dir.value),xi(this._destroyed)).subscribe(i=>t.withDirection(i)),t.beforeStarted.subscribe(()=>{let i=PI(this.connectedTo).map(r=>{if(typeof r=="string"){let o=n._dropLists.find(a=>a.id===r);return o}return r});if(this._group&&this._group._items.forEach(r=>{i.indexOf(r)===-1&&i.push(r)}),!this._scrollableParentsResolved){let r=this._scrollDispatcher.getAncestorScrollContainers(this.element).map(o=>o.getElementRef().nativeElement);this._dropListRef.withScrollableParents(r),this._scrollableParentsResolved=!0}if(this.elementContainerSelector){let r=this.element.nativeElement.querySelector(this.elementContainerSelector);t.withElementContainer(r)}t.disabled=this.disabled,t.lockAxis=this.lockAxis,t.sortingDisabled=this.sortingDisabled,t.autoScrollDisabled=this.autoScrollDisabled,t.autoScrollStep=zC(this.autoScrollStep,2),t.hasAnchor=this.hasAnchor,t.connectedTo(i.filter(r=>r&&r!==this).map(r=>r._dropListRef)).withOrientation(this.orientation)})}_handleEvents(t){t.beforeStarted.subscribe(()=>{this._syncItemsWithRef(this.getSortedItems().map(i=>i._dragRef)),this._changeDetectorRef.markForCheck()}),t.entered.subscribe(i=>{this.entered.emit({container:this,item:i.item.data,currentIndex:i.currentIndex})}),t.exited.subscribe(i=>{this.exited.emit({container:this,item:i.item.data}),this._changeDetectorRef.markForCheck()}),t.sorted.subscribe(i=>{this.sorted.emit({previousIndex:i.previousIndex,currentIndex:i.currentIndex,container:this,item:i.item.data})}),t.dropped.subscribe(i=>{this.dropped.emit({previousIndex:i.previousIndex,currentIndex:i.currentIndex,previousContainer:i.previousContainer.data,container:i.container.data,item:i.item.data,isPointerOverContainer:i.isPointerOverContainer,distance:i.distance,dropPoint:i.dropPoint,event:i.event}),this._changeDetectorRef.markForCheck()}),Ir(t.receivingStarted,t.receivingStopped).subscribe(()=>this._changeDetectorRef.markForCheck())}_assignDefaults(t){let{lockAxis:i,draggingDisabled:r,sortingDisabled:o,listAutoScrollDisabled:a,listOrientation:s}=t;this.disabled=r??!1,this.sortingDisabled=o??!1,this.autoScrollDisabled=a??!1,this.orientation=s||"vertical",this.lockAxis=i||null}_syncItemsWithRef(t){this._latestSortedRefs=t,this._dropListRef.withItems(t)}static \u0275fac=function(i){return new(i||n)};static \u0275dir=lt({type:n,selectors:[["","cdkDropList",""],["cdk-drop-list"]],hostAttrs:[1,"cdk-drop-list"],hostVars:7,hostBindings:function(i,r){i&2&&(st("id",r.id),_t("cdk-drop-list-disabled",r.disabled)("cdk-drop-list-dragging",r._dropListRef.isDragging())("cdk-drop-list-receiving",r._dropListRef.isReceiving()))},inputs:{connectedTo:[0,"cdkDropListConnectedTo","connectedTo"],data:[0,"cdkDropListData","data"],orientation:[0,"cdkDropListOrientation","orientation"],id:"id",lockAxis:[0,"cdkDropListLockAxis","lockAxis"],disabled:[2,"cdkDropListDisabled","disabled",Ue],sortingDisabled:[2,"cdkDropListSortingDisabled","sortingDisabled",Ue],enterPredicate:[0,"cdkDropListEnterPredicate","enterPredicate"],sortPredicate:[0,"cdkDropListSortPredicate","sortPredicate"],autoScrollDisabled:[2,"cdkDropListAutoScrollDisabled","autoScrollDisabled",Ue],autoScrollStep:[0,"cdkDropListAutoScrollStep","autoScrollStep"],elementContainerSelector:[0,"cdkDropListElementContainer","elementContainerSelector"],hasAnchor:[2,"cdkDropListHasAnchor","hasAnchor",Ue]},outputs:{dropped:"cdkDropListDropped",entered:"cdkDropListEntered",exited:"cdkDropListExited",sorted:"cdkDropListSorted"},exportAs:["cdkDropList"],features:[Lt([{provide:$F,useValue:void 0},{provide:nN,useExisting:n}])]})}return n})();var pre=new xt("CdkDragPlaceholder"),rN=(()=>{class n{templateRef=M(qr);_drag=M(w2,{optional:!0});data;constructor(){this._drag?._setPlaceholderTemplate(this)}ngOnDestroy(){this._drag?._resetPlaceholderTemplate(this)}static \u0275fac=function(i){return new(i||n)};static \u0275dir=lt({type:n,selectors:[["ng-template","cdkDragPlaceholder",""]],inputs:{data:"data"},features:[Lt([{provide:pre,useExisting:n}])]})}return n})();var S2=(()=>{class n{static \u0275fac=function(i){return new(i||n)};static \u0275mod=Di({type:n});static \u0275inj=Ii({providers:[ure],imports:[Q_]})}return n})();var T_=100,hre=200,aN=n=>Number.isFinite(n)?Math.min(hre,Math.max(0,Math.round(n*100))):T_,sN=n=>n/100,T2=class n{brightness=X(T_);contrast=X(T_);dialogRef=M(di);data=M(ui);initialPosition=this.data.position??{x:0,y:0};ngOnInit(){this.brightness.set(aN(this.data.value?.brightness??1)),this.contrast.set(aN(this.data.value?.contrast??1))}onBrightnessChange(e){this.brightness.set(Number(e.target.value)),this.emitChange()}onContrastChange(e){this.contrast.set(Number(e.target.value)),this.emitChange()}reset(){this.brightness.set(T_),this.contrast.set(T_),this.emitChange()}onDragEnded(e){typeof this.data?.onMoved=="function"&&this.data.onMoved(e.source.getFreeDragPosition())}currentValue(){return{brightness:sN(this.brightness()),contrast:sN(this.contrast())}}emitChange(){typeof this.data?.onChange=="function"&&this.data.onChange(this.currentValue())}handleClose(e){this.dialogRef.close({apply:e,value:this.currentValue()})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-image-adjustment-dialog"]],decls:30,vars:13,consts:[["cdkDrag","","cdkDragRootElement",".cdk-overlay-pane",1,"_ap-image-adjustment",2,"overflow","hidden","color","var(--mat-app-text-color)",3,"cdkDragEnded","cdkDragFreeDragPosition"],["cdkDragHandle","",2,"display","flex","align-items","center","cursor","move","padding","4px 4px 0 12px"],[2,"opacity","0.6"],[2,"flex","1 1 auto","min-width","0","padding-left","8px","font-weight","500","overflow","hidden","text-overflow","ellipsis","white-space","nowrap",3,"title"],["mat-icon-button","","aria-label","Close",3,"click"],[2,"padding","0 24px","overflow","hidden","margin-top","-4px"],[2,"display","flex","align-items","center","margin","-11px 0"],[2,"width","72px","font-size","13px"],[2,"flex","1 1 auto","min-width","0",3,"min","max","step"],["matSliderThumb","","aria-label","Brightness",3,"input","value"],[2,"min-width","44px","text-align","right","font-size","13px"],["matSliderThumb","","aria-label","Contrast",3,"input","value"],[2,"min-height","38px","padding","0 8px 2px"],["mat-button","",3,"click"],[2,"flex","1 1 auto"]],template:function(t,i){t&1&&(u(0,"div",0),T("cdkDragEnded",function(o){return i.onDragEnded(o)}),u(1,"div",1)(2,"mat-icon",2),_(3,"tune"),p(),u(4,"div",3),_(5),p(),u(6,"button",4),T("click",function(){return i.handleClose(!1)}),u(7,"mat-icon"),_(8,"close"),p()()(),u(9,"mat-dialog-content",5)(10,"div",6)(11,"div",7),_(12,"Brightness"),p(),u(13,"mat-slider",8)(14,"input",9),T("input",function(o){return i.onBrightnessChange(o)}),p()(),u(15,"div",10),_(16),p()(),u(17,"div",6)(18,"div",7),_(19,"Contrast"),p(),u(20,"mat-slider",8)(21,"input",11),T("input",function(o){return i.onContrastChange(o)}),p()(),u(22,"div",10),_(23),p()()(),u(24,"mat-dialog-actions",12)(25,"button",13),T("click",function(){return i.reset()}),_(26,"RESET"),p(),z(27,"span",14),u(28,"button",13),T("click",function(){return i.handleClose(!0)}),_(29,"SAVE"),p()()()),t&2&&(w("cdkDragFreeDragPosition",i.initialPosition),g(4),w("title",i.data.text),g(),$(" ",i.data.text," "),g(8),w("min",0)("max",200)("step",1),g(),w("value",i.brightness()),g(2),$(" ",i.brightness(),"% "),g(4),w("min",0)("max",200)("step",1),g(),w("value",i.contrast()),g(2),$(" ",i.contrast(),"% "))},dependencies:[Bs,Ns,ss,le,ce,ue,Xe,Fe,pi,Si,_i,be,Qa,Cu],encapsulation:2})};function _E(n){let e=n*10,t=e+Number.EPSILON*Math.max(1,Math.abs(e));return Math.floor(t)/10}function lN(n){return _E(n).toFixed(1)}function mre(n,e){if(n&1&&(u(0,"div",11),_(1),p()),n&2){let t=v();g(),$(" ",t.error()," ")}}function fre(n,e){if(n&1&&(u(0,"div",12),_(1),p()),n&2){let t=v();g(),$(" ",t.summary()," ")}}var yE=1,vE=28;function cN(n){if(n==null||String(n).trim()==="")return{invalid:!1};let e=Number(n);return!Number.isFinite(e)||e<yE||e>vE?{invalid:!0}:{value:e,invalid:!1}}function gre(n){return n.invalid?`Enter a zoom level between ${yE} and ${vE}`:null}function uN(n){return typeof n=="number"?`from z${n}`:""}function dN(n){return Number.isFinite(n)?String(_E(n)):""}var E2=class n{ZOOM_ENTRY_MIN=yE;ZOOM_ENTRY_MAX=vE;text=X("");dialogRef=M(di);data=M(ui);error=qt(()=>gre(cN(this.text())));summary=qt(()=>{let e=this.currentValue();return typeof e=="number"?`Hidden below z${e}`:"Shown at every zoom level"});ngOnInit(){this.text.set(typeof this.data.value=="number"?String(this.data.value):"")}declaredText(){let{declaredMin:e,declaredMax:t}=this.data;return typeof e=="number"&&typeof t=="number"?`data z${e}\u2013z${t}`:"data zoom range unknown"}currentZoomText(){return dN(this.data.currentZoom())}onTextChange(e){this.setText(e.target.value)}useCurrentZoom(){this.setText(dN(this.data.currentZoom()))}clear(){this.setText("")}setText(e){this.text.set(e),!this.error()&&typeof this.data?.onChange=="function"&&this.data.onChange(this.currentValue())}currentValue(){return cN(this.text()).value}handleClose(e){this.dialogRef.close({apply:e,value:this.currentValue()})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-chart-min-zoom-dialog"]],decls:27,vars:10,consts:[["cdkDrag","","cdkDragRootElement",".cdk-overlay-pane",1,"_ap-chart-min-zoom",2,"overflow","hidden","color","var(--mat-app-text-color)"],["cdkDragHandle","",2,"display","flex","align-items","center","cursor","move","padding","4px 4px 0 12px"],[2,"opacity","0.6"],[2,"flex","1 1 auto","min-width","0","padding-left","8px","font-weight","500","overflow","hidden","text-overflow","ellipsis","white-space","nowrap",3,"title"],["mat-icon-button","","aria-label","Close",3,"click"],[2,"padding","0 16px","font-size","12px","opacity","0.7","margin-top","-4px"],[2,"display","flex","align-items","center","gap","4px","padding","10px 8px 0 16px"],[2,"font-size","13px"],["type","number","inputmode","decimal","step","any","aria-label","Lowest zoom level to show this chart at",2,"width","70px","height","34px","box-sizing","border-box","padding","0 0 0 8px","font","inherit","font-size","14px","color","inherit","background","transparent","border","1px solid rgba(128, 128, 128, 0.5)","border-radius","4px",3,"change","min","max","value"],["mat-icon-button","","aria-label","Use the current map zoom","matTooltip","Use current map zoom",3,"click"],["mat-icon-button","","aria-label","Clear","matTooltip","Clear",3,"click","disabled"],["role","alert",1,"mat-mdc-form-field-error",2,"padding","4px 16px 0","font-size","12px"],[2,"padding","4px 16px 0","font-size","12px","opacity","0.7"],[2,"min-height","38px","padding","0 8px 2px"],[2,"flex","1 1 auto"],["mat-button","",3,"click","disabled"]],template:function(t,i){t&1&&(u(0,"div",0)(1,"div",1)(2,"mat-icon",2),_(3,"vertical_align_bottom"),p(),u(4,"div",3),_(5),p(),u(6,"button",4),T("click",function(){return i.handleClose(!1)}),u(7,"mat-icon"),_(8,"close"),p()()(),u(9,"div",5),_(10),p(),u(11,"div",6)(12,"div",7),_(13,"Show from"),p(),u(14,"input",8),T("change",function(o){return i.onTextChange(o)}),p(),u(15,"button",9),T("click",function(){return i.useCurrentZoom()}),u(16,"mat-icon"),_(17,"my_location"),p()(),u(18,"button",10),T("click",function(){return i.clear()}),u(19,"mat-icon"),_(20,"close"),p()()(),R(21,mre,2,1,"div",11)(22,fre,2,1,"div",12),u(23,"mat-dialog-actions",13),z(24,"span",14),u(25,"button",15),T("click",function(){return i.handleClose(!0)}),_(26," APPLY "),p()()()),t&2&&(g(4),w("title",i.data.text),g(),$(" ",i.data.text," "),g(5),lo(" ",i.declaredText()," \xB7 map at z",i.currentZoomText()," "),g(4),w("min",i.ZOOM_ENTRY_MIN)("max",i.ZOOM_ENTRY_MAX)("value",i.text()),g(4),w("disabled",i.text()===""),g(3),A(i.error()?21:22),g(4),w("disabled",!!i.error()))},dependencies:[le,ce,ue,Xe,Fe,pi,Si,be,Pe,Qa,Cu],encapsulation:2})};var pN="3.1.1";var hN=500,If=1.5,yre=1,vre=2147483647;function mN(n){return typeof n!="number"||!Number.isFinite(n)?If*1e3:Math.min(Math.max(n,yre)*1e3,vre)}var I2=class{constructor(e=()=>{}){this.onExpire=e}onExpire;_marker=X(null);timer;seq=0;get marker(){return this._marker.asReadonly()}get active(){return this._marker()!==null}pin(e,t,i){this.stopTimer(),this._marker.set({id:++this.seq,position:e,worldOffset:t,fadeMs:i}),this.timer=setTimeout(()=>{this.timer=void 0,this._marker.set(null),this.onExpire()},i)}release(){this.stopTimer(),this._marker.set(null)}stopTimer(){clearTimeout(this.timer),this.timer=void 0}};function fN(n){let e=!0,t=Object.keys(n);return Object.keys(xE()).forEach(i=>{t.includes(i)||(e=!1)}),e}function bE(n,e){if(typeof n.ui>"u"?n.ui={mapNorthUp:!0,mapMove:!1,mapConstrainZoom:!1,invertColor:!1,toolbarButtons:!0,showCourseData:!0,showAisTargets:!0,showNotes:!0,autoNightMode:!1}:(typeof n.ui.showCourseData>"u"&&(n.ui.showCourseData=!0),typeof n.ui.showAisTargets>"u"&&(n.ui.showAisTargets=!0),typeof n.ui.showNotes>"u"&&(n.ui.showNotes=!0)),typeof n.imageAdjustPalettePos>"u"&&(n.imageAdjustPalettePos=null),typeof n.display>"u"?n.display={fab:"wpt",disableWakelock:!1,darkMode:{enabled:!1,source:0},nightMode:!1,muteSound:!1,depthAlarm:{enabled:!1,smoothing:1e4},plugins:{instruments:"/@signalk/instrumentpanel",startOnOpen:!0,parameters:null,favourites:[]},preferInfoPanel:!0,singleClickNoteDetails:!1,windIndicator:"barb",statusBar:{liveEta:!1,referenceSpeed:6,tapFadeSpeed:If}}:(typeof n.display.preferInfoPanel>"u"&&(n.display.preferInfoPanel=!0),typeof n.display.singleClickNoteDetails>"u"&&(n.display.singleClickNoteDetails=!1),typeof n.display.windIndicator>"u"&&(n.display.windIndicator="barb"),typeof n.display.statusBar>"u"?n.display.statusBar={liveEta:!1,referenceSpeed:6,tapFadeSpeed:If}:typeof n.display.statusBar.tapFadeSpeed>"u"&&(n.display.statusBar.tapFadeSpeed=If)),typeof n.units.temperature>"u"&&(n.units.temperature="C"),n.units.temperature=n.units.temperature.toUpperCase(),n.units.depth=n.units.depth==="ft"?"foot":n.units.depth,typeof n.units.length>"u"&&(n.units.length=n.units.depth??"m"),n.units.speed=n.units.speed==="msec"?"m/s":n.units.speed==="kmh"?"km/h":n.units.speed,n.units.distance=n.units.distance==="m"?"kilometer":n.units.distance==="ft"?"naut-mile":n.units.distance,typeof n.map.s57Options>"u"?n.map.s57Options={graphicsStyle:"Paper",boundaries:"Plain",colors:4,shallowDepth:2,safetyDepth:3,deepDepth:6,colorTable:0,otherLayers:vf.otherLayers,depthUnit:n.units.depth??"m"}:(typeof n.map.s57Options.otherLayers>"u"&&(n.map.s57Options.otherLayers=vf.otherLayers),typeof n.map.s57Options.depthUnit>"u"&&(n.map.s57Options.depthUnit=n.units.depth??"m")),typeof n.map.labelsMinZoom>"u"&&(n.map.labelsMinZoom=8),typeof n.map.panBehavior>"u"){let i=n.map;n.map.panBehavior=S6(i.lockMoveMap),delete i.lockMoveMap}typeof n.map.popoverMulti>"u"&&(n.map.popoverMulti=!1);let t=n.map.centerOffsetAbeam;if(n.map.centerOffset=T6(n.map.centerOffset,t),delete n.map.centerOffsetAbeam,typeof n.map.doubleClickZoom>"u"&&(n.map.doubleClickZoom=!1),typeof n.map.overZoomTiles>"u"&&(n.map.overZoomTiles=!0),n.units.positionFormat||(n.units.positionFormat="XY"),typeof n.units.headingAttribute>"u"&&(n.units.headingAttribute="navigation.headingTrue"),typeof n.units.preferredPaths>"u"&&(n.units.preferredPaths={tws:"environment.wind.speedTrue",twd:"environment.wind.directionTrue",heading:"navigation.courseOverGroundTrue",course:"navigation.courseGreatCircle"}),typeof n.units.useServerPrefs>"u"&&(n.units.useServerPrefs=!1),typeof n.course>"u"?n.course={autoNextPointOnArrival:!1,autoNextPointDelay:5e3,autoNextPointTrigger:"perpendicularPassed",arrivalCircle:100}:typeof n.course.arrivalCircle>"u"&&(n.course.arrivalCircle=100),typeof n.vessels>"u"?n.vessels={fixedLocationMode:!1,fixedPosition:[0,0],trail:!0,windVectors:!0,laylines:!1,selfLines:{cog:{length:10,color:"rgba(204, 12, 225, 0.7)",weight:1,dash:"none"},heading:{length:-1,color:"rgba(221, 99, 0, 0.5)",weight:4,dash:"none"}},aisCogLine:10,iconScale:.9,rangeCircles:!1,rangeCirclesFixed:!1,rangeCirclesDistance:1e3,rangeCircleCount:4,rangeCircleMinZoom:8,aisStaleAge:36e4,aisMaxAge:54e4,aisWindApparent:!1,aisWindMinZoom:15,aisShowTrack:!1,trailFromServer:!1,trailDuration:24,trailResolution:{lastHour:"5s",next23:"1m",beyond24:"5m"}}:(typeof n.vessels.rangeCircleCount>"u"&&(n.vessels.rangeCircleCount=4),typeof n.vessels.rangeCircleMinZoom>"u"&&(n.vessels.rangeCircleMinZoom=8),typeof n.vessels.rangeCirclesFixed>"u"&&(n.vessels.rangeCirclesFixed=!1),typeof n.vessels.rangeCirclesDistance>"u"&&(n.vessels.rangeCirclesDistance=1e3),typeof n.vessels.selfLines>"u"&&(n.vessels.selfLines={cog:{length:n.vessels.cogLine??10,color:"rgba(204, 12, 225, 0.7)",weight:1,dash:"none"},heading:{length:n.vessels.headingLineSize??-1,color:"rgba(221, 99, 0, 0.5)",weight:4,dash:"none"}},delete n.vessels.cogLine,delete n.vessels.headingLineSize)),typeof n.resources>"u"?n.resources={fetchFilter:"?position=[%map:longitude%,%map:latitude%]&distance=%fetch:radius%",fetchRadius:0,notes:{rootFilter:"?position=[%map:longitude%,%map:latitude%]&distance=%note:radius%",getRadius:20,groupNameEdit:!1,groupRequiresPosition:!1,minZoom:10},video:{enable:!1,url:""},paths:[]}:(typeof n.resources.notes.minZoom>"u"&&(n.resources.notes.minZoom=10),typeof n.resources.video>"u"&&(n.resources.video={enable:!1,url:""}),typeof n.resources.paths>"u"&&(n.resources.paths=[]),typeof n.resources.fetchFilter>"u"&&(n.resources.fetchFilter="?position=[%map:longitude%,%map:latitude%]&distance=%fetch:radius%"),typeof n.resources.fetchRadius>"u"&&(n.resources.fetchRadius=0)),typeof n.signalk>"u"?n.signalk={vessels:!0,atons:!0,aircraft:!1,sar:!1,meteo:!0,maxRadius:0,proxied:!0}:n.signalk.proxied=!0,typeof n.anchor>"u"&&(n.anchor={radius:40,setRadius:!1,manualSet:!1,rodeLength:50}),(!n.plotterExtensions||typeof n.plotterExtensions!="object"||Array.isArray(n.plotterExtensions))&&(n.plotterExtensions={widgets:[]}),delete n.plotterExtensions.enabled,Array.isArray(n.plotterExtensions.widgets)||(n.plotterExtensions.widgets=[]),n.plotterExtensions.widgets=n.plotterExtensions.widgets.map(i=>(i.corner&&!i.anchor&&(i.anchor=i.corner==="tl"?"tr":i.corner,delete i.corner),i)).filter(i=>["tr","ct","cb","bl","br"].includes(i.anchor)),typeof n.radars>"u"?n.radars={deviceId:"",opacity:1}:typeof n.radars.opacity>"u"&&(n.radars.opacity=1),typeof n.selections>"u"&&(n.selections={routes:[],waypoints:[],regions:[],tracks:null,charts:["openstreetmap","openseamap"],chartOrder:["openstreetmap","openseamap"],chartOpacity:{},chartImageAdjustment:{},chartDisplayMinZoom:{},aisTargets:null,aisTargetTypes:[],aisFilterByShipType:!1,aisState:[],resourceSets:{},infolayers:null,weatherWindEnabled:!1,oceanCurrentsEnabled:!1,tidalCurrentsEnabled:!1}),typeof n.selections.aisTargetTypes>"u"&&(n.selections.aisTargetTypes=[]),typeof n.selections.aisFilterByShipType>"u"&&(n.selections.aisFilterByShipType=!1),typeof n.selections.aisState>"u"&&(n.selections.aisState=[]),typeof n.selections.chartOrder>"u"&&(n.selections.chartOrder=[]),typeof n.selections.chartOpacity>"u"&&(n.selections.chartOpacity={}),typeof n.selections.chartImageAdjustment>"u"&&(n.selections.chartImageAdjustment={}),typeof n.selections.chartDisplayMinZoom>"u"&&(n.selections.chartDisplayMinZoom={}),typeof n.selections.tracks>"u"&&(n.selections.tracks=[]),typeof n.selections.resourceSets>"u"&&(n.selections.resourceSets={}),typeof n.selections.infolayers>"u"&&(n.selections.infolayers=[]),typeof n.selections.regions>"u"&&(n.selections.regions=[]),typeof n.selections.weatherWindEnabled>"u"&&(n.selections.weatherWindEnabled=!1),typeof n.selections.oceanCurrentsEnabled>"u"&&(n.selections.oceanCurrentsEnabled=!1),typeof n.selections.tidalCurrentsEnabled>"u"&&(n.selections.tidalCurrentsEnabled=!1),n.selections.notes,delete n.selections.notes,typeof e.northup<"u"&&(n.ui.mapNorthUp=e.northup!=="0"),typeof e.movemap<"u"&&(n.ui.mapMove=e.movemap!=="0"),e.zoom)try{let i=parseInt(e.zoom);isNaN(i)||(n.map.zoomLevel=i>28?28:i<1?1:i)}catch(i){console.warn(`Invalid zoom level parameter (${e.zoom} supplied!`)}}function xE(){return{ui:{mapNorthUp:!0,mapMove:!1,mapConstrainZoom:!1,toolbarButtons:!0,invertColor:!1,showCourseData:!0,showAisTargets:!0,showNotes:!0,autoNightMode:!1},imageAdjustPalettePos:null,display:{fab:"wpt",disableWakelock:!1,darkMode:{enabled:!1,source:0},nightMode:!1,muteSound:!1,depthAlarm:{enabled:!1,smoothing:1e4},plugins:{instruments:"/@signalk/instrumentpanel",startOnOpen:!0,parameters:null,favourites:[]},preferInfoPanel:!0,singleClickNoteDetails:!1,windIndicator:"barb",statusBar:{liveEta:!1,referenceSpeed:6,tapFadeSpeed:If}},units:{distance:"kilometer",depth:"m",length:"m",speed:"kn",temperature:"C",positionFormat:"XY",headingAttribute:"navigation.headingTrue",preferredPaths:{tws:"environment.wind.speedTrue",twd:"environment.wind.directionTrue",heading:"navigation.courseOverGroundTrue",course:"navigation.courseGreatCircle"},useServerPrefs:!1},map:{zoomLevel:2,center:[0,0],rotation:0,panBehavior:"offset",animate:!1,labelsMinZoom:8,doubleClickZoom:!1,overZoomTiles:!0,centerOffset:{x:0,y:0},s57Options:{graphicsStyle:"Paper",boundaries:"Plain",colors:4,shallowDepth:2,safetyDepth:3,deepDepth:6,colorTable:0,otherLayers:vf.otherLayers,depthUnit:"m"},popoverMulti:!1},course:{autoNextPointOnArrival:!1,autoNextPointDelay:5e3,autoNextPointTrigger:"perpendicularPassed",arrivalCircle:100},vessels:{fixedLocationMode:!1,fixedPosition:[0,0],trail:!1,windVectors:!0,laylines:!1,selfLines:{cog:{length:10,color:"rgba(204, 12, 225, 0.7)",weight:1,dash:"none"},heading:{length:-1,color:"rgba(221, 99, 0, 0.5)",weight:4,dash:"none"}},aisCogLine:10,iconScale:.9,rangeCircles:!1,rangeCirclesFixed:!1,rangeCirclesDistance:1e3,rangeCircleCount:4,rangeCircleMinZoom:8,aisStaleAge:36e4,aisMaxAge:54e4,aisWindApparent:!1,aisWindMinZoom:15,aisShowTrack:!1,trailFromServer:!1,trailDuration:24,trailResolution:{lastHour:"5s",next23:"1m",beyond24:"5m"}},resources:{fetchFilter:"?position=[%map:longitude%,%map:latitude%]&distance=%fetch:radius%",fetchRadius:0,notes:{rootFilter:"?position=[%map:longitude%,%map:latitude%]&distance=%note:radius%",getRadius:20,groupNameEdit:!1,groupRequiresPosition:!0,minZoom:10},video:{enable:!1,url:null},paths:[]},signalk:{vessels:!0,atons:!0,aircraft:!1,sar:!1,meteo:!0,maxRadius:0,proxied:!0},anchor:{radius:40,setRadius:!1,manualSet:!1,rodeLength:50},radars:{deviceId:void 0,opacity:1},experiments:!1,plotterExtensions:{widgets:[]},selections:{routes:[],waypoints:[],regions:[],tracks:null,charts:["openstreetmap","openseamap"],chartOrder:["openstreetmap","openseamap"],chartOpacity:{},chartImageAdjustment:{},chartDisplayMinZoom:{},aisTargets:null,aisTargetTypes:[],aisFilterByShipType:!1,aisState:[],resourceSets:{},infolayers:null,weatherWindEnabled:!1,oceanCurrentsEnabled:!1,tidalCurrentsEnabled:!1}}}function gN(){return{loginRequired:!1,chartBounds:{show:!1,charts:[]},selfId:null,activeRoute:null,activeRouteReversed:!1,activeRouteCircular:!1,activeRouteIsEditing:!1,editingId:null,activeWaypoint:null,serverTrail:!1,server:null,lastGet:null,map:{atClick:{features:[],lonlat:[0,0]}},vessels:{showSelf:!1,self:new Md,aisTargets:new Map,aisTracks:new Map,activeId:null,active:null,closest:[],prefAvailablePaths:{},flagged:[],showTrack:[]},aircraft:new Map,atons:new Map,sar:new Map,meteo:new Map,racing:{startLine:[]}}}var D2=(n,e)=>{if(!n)return n;let t=n.split("%");return t.length>1&&(n=t.map(r=>r==="map:latitude"?e.map.center[1]:r==="map:longitude"?e.map.center[0]:r==="map:zoom"?Math.floor(e.map.zoomLevel):r==="note:radius"?(e.units.distance==="kilometer"?e.resources.notes.getRadius:Math.floor(Ge.nauticalMilesToKm(e.resources.notes.getRadius)))*1e3:r==="fetch:radius"?(e.units.distance==="kilometer"?e.resources.notes.getRadius:Math.floor(Ge.nauticalMilesToKm(e.resources.fetchRadius)))*1e3:r).join("")),n};var _N="symbols";var yN={id:"freeboard",name:"Freeboard-SK",description:"Signal K Chart Plotter.",version:pN,url:"https://github.com/signalk/freeboard-sk",logo:"./assets/img/app_logo.png"},bre="1.0.0",E_={host:"localhost",port:3e3,ssl:!1},ae=class n extends v1{skApiVersion=2;hostDef={name:void 0,port:void 0,ssl:!1,url:void 0,params:{}};sessionToken;STANDARD_RESOURCES=["routes","waypoints","regions","notes","charts"];CUSTOM_RESOURCES=[{name:"tracks",description:"Freeboard GPX track imports.",featureKey:"resourceTracks"},{name:"infolayers",description:"Freeboard map overlays.",featureKey:"infoLayers"},{name:"groups",description:"Freeboard resource groups.",featureKey:"resourceGroups"}];get IGNORE_RESOURCES(){return this.STANDARD_RESOURCES.concat(this.CUSTOM_RESOURCES.map(e=>e.name),["buddies",fD,_N])}serverConfig={unitPreferences:X(void 0),pathDisplayUnits:X({})};MAP_ZOOM_EXTENT={min:2,max:28};AudioContext=window.AudioContext||window.webkitAudioContext;audio={context:new AudioContext};db;watchingSKLogin;kioskMode=X(!1);hasAuthToken=X(!1);isLoggedIn=X(!1);instrumentPanelAvailable=X(!0);skAuthChange=X(void 0);sIsFetching=X(!1);sTrueMagChoice=X("");instrumentPanel=X({open:!1,activate:!1});uiCtrl=X({alertList:!1,autopilotConsole:!1,radarLayer:!1,routeBuilder:!1,suppressContextMenu:!1,forceNightMode:!1});uiConfig=X({mapNorthUp:!0,mapMove:!1,mapConstrainZoom:!1,toolbarButtons:!1,invertColor:!1,showCourseData:!0,showAisTargets:!0,showNotes:!0,autoNightMode:!1});featureFlags=X({anchorApi:!0,autopilotApi:!1,weatherApi:!1,radarApi:!1,notificationApi:!1,resourceGroups:!1,resourceTracks:!1,infoLayers:!1,buddyList:!1,tidalApi:!1});selfLines=X({cog:{fill:{color:"rgba(204, 12, 225, 0.7)"},stroke:{color:"rgba(204, 12, 225, 0.7)",width:1,lineDash:null}},heading:{fill:{color:"rgba(221, 99, 0, 0.5)"},stroke:{color:"rgba(221, 99, 0, 0.5)",width:4,lineDash:null}}});selfTrail=X([]);selfTrailFromServer=X([]);mapExtent=X([]);mapViewTopCenter=X([0,0]);mapViewRightCenter=X([0,0]);mapViewRotation=X(0);mapZoom=X(0);mapMoveRequest=X(null);signalk=M(Ot);worker=M(Wn);dialog=M(xn);snackbar=M(lD);iconReg=M(n1);dom=M(Rd);s57=M(Dp);constructor(){super(yN),this.config=xE(),this.data=gN(),this.suppressPersist=!0,this.db=new CE,this.db.dbUpdate$.subscribe(e=>{if(e.action)switch(e.action){case"db_init":e.value&&this.config.vessels.trail&&this.db.getTrail().then(t=>{this.selfTrail.update(()=>t&&t.value?t.value:[])});break;case"trail_save":e.value||this.debug("app.trail.save.error","warn");break}}),this.signalk.setAppId(yN.id),this.signalk.setAppVersion(bre),this.initAppIcons(),this.parseLaunchUrl(),this.instrumentPanelAvailable.update(()=>this.isTopWindow()),this.isTopWindow()||window.addEventListener("message",e=>{this.parseMessageFromParent(e)}),this.testForInternet(),this.loadConfig(),this.parseLocalConfig(),Me(()=>{this.uiConfig(),this.debug("AppFacade.effect().uiConfig",this.uiConfig()),this.config.ui=this.uiConfig(),this.saveConfigDebounced()}),Me(()=>{this.alignUnitPrefs(this.serverConfig.unitPreferences())})}useInfoPanel(){return!window.matchMedia("(max-width: 760px)").matches&&!this.instrumentPanel().open&&this.config.display.preferInfoPanel}fetchUnitPrefsFromSKServer(){this.signalk.get("/signalk/v1/unitpreferences/active").subscribe({next:e=>{this.serverConfig.unitPreferences.set(e),this.refreshPathDisplayUnits()},error:()=>{this.debug("No server unit preferences...using fallback!")}})}twsDisplayUnitPath(){return this.config.units.preferredPaths.tws??"environment.wind.speedTrue"}displayUnitPaths(){return[this.twsDisplayUnitPath(),"environment.wind.speedApparent"]}refreshPathDisplayUnits(){if(!this.config.units.useServerPrefs){this.serverConfig.pathDisplayUnits.set({});return}this.displayUnitPaths().forEach(e=>this.fetchPathDisplayUnits(e))}fetchPathDisplayUnits(e){let t=e.split(".").join("/");this.signalk.get(`/signalk/v1/api/vessels/self/${t}/meta`).subscribe({next:i=>{this.config.units.useServerPrefs&&i?.displayUnits?.targetUnit?this.setPathDisplayUnits(e,i.displayUnits):this.clearPathDisplayUnits(e)},error:()=>{this.debug(`No display units for path: ${e}`),this.clearPathDisplayUnits(e)}})}parseMessageFromParent(e){if(os()||e.origin===window.location.origin){this.debug("parseMessageFromParent()",e.origin,e.data);let{settings:t,commands:i}=e.data;if(!t&&!i){this.debug("parseMessageFromParent() - invalid data!");return}typeof t?.autoNightMode=="boolean"&&(this.config.display.nightMode=t.autoNightMode,this.uiConfig.update(r=>Object.assign({},r,{autoNightMode:this.config.display.nightMode}))),typeof i?.nightModeEnable=="boolean"&&this.uiCtrl.update(r=>Object.assign({},r,{forceNightMode:i.nightModeEnable}))}else{this.debug("parseMessageFromParent() - untrusted origin!",e.origin);return}}parseLocalConfig(){bE(this.config,this.hostDef.params),this.s57.init(this.config.map.s57Options),this.doPostConfigLoad()}get lineDashMap(){return new Map([["none","none"],["short","2 2"],["medium","4 4"],["long","8 4"],["alt","8 4 2 4"]])}formatLineDashArray(e){return e==="none"?null:Array.from(this.lineDashMap.get(e)).filter(t=>t!==" ").map(t=>Number(t))}doPostConfigLoad(){this.uiConfig.update(()=>this.config.ui),this.config.vessels.fixedLocationMode&&(this.data.vessels.self.position=[...this.config.vessels.fixedPosition],this.data.vessels.showSelf=!0,this.config.map.center=[...this.config.vessels.fixedPosition]),this.selfLines.update(e=>({cog:{fill:{color:this.config.vessels.selfLines.cog.color},stroke:{color:this.config.vessels.selfLines.cog.color,width:this.config.vessels.selfLines.cog.weight,lineDash:this.formatLineDashArray(this.config.vessels.selfLines.cog.dash)}},heading:{fill:{color:this.config.vessels.selfLines.heading.color},stroke:{color:this.config.vessels.selfLines.heading.color,width:this.config.vessels.selfLines.heading.weight,lineDash:this.formatLineDashArray(this.config.vessels.selfLines.heading.dash)}}})),this.sTrueMagChoice.set(this.config.units.headingAttribute),this.s57.setOptions(this.config.map.s57Options),this.mapZoom.set(this.config.map.zoomLevel),this.debug("doPostConfigLoad(): emit config$.ready"),this.emitConfigEvent("ready"),this.suppressPersist=!1}loadUserConfigfromServer(){return J(this,null,function*(){return new Promise(e=>{this.signalk.isLoggedIn().subscribe({next:t=>{if(this.isLoggedIn.set(t),t)this.debug("loadUserConfigfromServer(): Is authenticated. Fetching config from SK Server..."),this.signalk.appDataGet("/").subscribe({next:i=>{Object.keys(i).length===0&&e(!1),bE(i,this.hostDef.params),fN(i)&&(this.config=i,this.doPostConfigLoad(),this.alignCustomResourcesPaths(),this.alignUnitPrefs(this.serverConfig.unitPreferences()),this.saveConfig()),e(!0)},error:()=>{console.info("applicationData: Unable to retrieve settings from server!"),e(!1)}});else return this.debug("loadUserConfigfromServer(): Not authenticated to SK Server!"),e(!1)},error:()=>{this.isLoggedIn.set(!1),this.debug("loadUserConfigfromServer(): Error fetching loginStatus!"),e(!1)}})})})}getPathDisplayUnits(e){return this.serverConfig.pathDisplayUnits()[e]}setPathDisplayUnits(e,t){this.serverConfig.pathDisplayUnits.update(i=>ri(se({},i),{[e]:t}))}clearPathDisplayUnits(e){this.serverConfig.pathDisplayUnits.update(t=>{if(!(e in t))return t;let i=se({},t);return delete i[e],i})}alignUnitPrefs(e){if(this.config.units.useServerPrefs){if(this.debug("Aligning Unit preferences from server:",e),!e?.categories){this.debug("No Unit preferences available!");return}e.categories.speed&&(this.config.units.speed=["kn","m/s","km/h","mph"].includes(e.categories.speed.targetUnit)?e.categories.speed.targetUnit:this.config.units.speed,Ge.setSymbol(e.categories.speed.targetUnit,e.categories.speed.symbol)),e.categories.temperature&&(this.config.units.temperature=["C","F"].includes(e.categories.temperature.targetUnit)?e.categories.temperature.targetUnit:this.config.units.temperature,Ge.setSymbol(e.categories.temperature.targetUnit,e.categories.temperature.symbol)),e.categories.distance&&(this.config.units.distance=["kilometer","naut-mile"].includes(e.categories.distance.targetUnit)?e.categories.distance.targetUnit:this.config.units.distance,Ge.setSymbol(e.categories.distance.targetUnit,e.categories.distance.symbol)),e.categories.depth&&(this.config.units.depth=["m","foot"].includes(e.categories.depth.targetUnit)?e.categories.depth.targetUnit:this.config.units.depth,Ge.setSymbol(e.categories.depth.targetUnit,e.categories.depth.symbol)),e.categories.length&&(this.config.units.length=["m","foot"].includes(e.categories.length.targetUnit)?e.categories.length.targetUnit:this.config.units.length,Ge.setSymbol(e.categories.length.targetUnit,e.categories.length.symbol))}}initAppIcons(){c5().forEach(e=>{this.iconReg.addSvgIcon(e.id,this.dom.bypassSecurityTrustResourceUrl(e.path))})}parseLaunchUrl(e=window.location){e.search&&e.search.slice(1).split("&").forEach(i=>{let r=i.split("=");this.hostDef.params[r[0]]=r.length>1?r[1]:null}),this.hostDef.name=typeof this.hostDef.params?.host<"u"?this.hostDef.params.host:this.devMode&&E_.host?E_.host:e.hostname,this.hostDef.ssl=!!(e.protocol==="https:"||this.devMode&&E_.ssl),this.hostDef.port=typeof this.hostDef.params.port<"u"?parseInt(this.hostDef.params.port):this.devMode&&E_.port?E_.port:parseInt(e.port),this.hostDef.port=isNaN(this.hostDef.port)?this.hostDef.ssl?443:80:this.hostDef.port,this.hostDef.url=`${this.hostDef.ssl?"https:":"http:"}//${this.hostDef.name}:${this.hostDef.port}`,this.kioskMode.update(()=>typeof this.hostDef.params.kiosk<"u"),typeof this.hostDef.params.token<"u"&&this.setAuthToken(this.hostDef.params.token,!1),this.debug("host:",this.hostDef)}testForInternet(){window.fetch("https://tile.openstreetmap.org").then(()=>{console.info("Internet connection detected.")}).catch(()=>{console.warn("No Internet connection detected!");let e=this.config.selections.charts;(e.includes("openstreetmap")||e.includes("openseamap"))&&(this.kioskMode()||this.showAlert("Internet Map Service Unavailable: ",`Unable to display Open Street / Sea Maps!
|
|
751
751
|
|
|
752
752
|
Please check your Internet connection or select maps from the local network.
|
|
753
753
|
|
|
754
|
-
`))})}isTopWindow(){try{return window.self===window.top}catch(e){return!1}}
|
|
754
|
+
`))})}isTopWindow(){try{return window.self===window.top}catch(e){return!1}}setAuthToken(e,t=!0){e?(this.signalk.authToken=e,this.worker.postMessage({cmd:"auth",options:{token:e}}),t?(this.sessionToken=void 0,document.cookie=`sktoken=${e}; SameSite=Strict`,document.cookie=`sktokenhost=${this.hostDef.url}; SameSite=Strict`):this.sessionToken=e,this.hasAuthToken.set(!0)):(this.hasAuthToken.set(!1),this.sessionToken=void 0,this.signalk.authToken=null,this.isLoggedIn.set(!1),document.cookie="sktoken=null; SameSite=Strict; max-age=0;",document.cookie="sktokenhost=null; SameSite=Strict; max-age=0;",this.worker.postMessage({cmd:"auth",options:{token:null}}))}watchSKLogin(){this.watchingSKLogin||(this.watchingSKLogin=window.setInterval((()=>{let e=this.getCookie(document.cookie,"skLoginInfo");return()=>{let t=this.getCookie(document.cookie,"skLoginInfo");this.skAuthChange.set(t)}})(),2e3))}getFBToken(){if(this.sessionToken)return this.sessionToken;let e=this.getCookie(document.cookie,"sktoken");return e&&(this.getCookie(document.cookie,"sktokenhost")??this.servingOrigin())===this.hostDef.url?e:void 0}servingOrigin(){let e=window.location,t=e.protocol==="https:",i=e.port?parseInt(e.port):t?443:80;return`${t?"https:":"http:"}//${e.hostname}:${i}`}getCookie(e,t){if(!e)return;let i=new Map;if(e.split(";").forEach(r=>{let o=r.trim().split("=");i.set(o[0],o[1])}),i.has(t))return i.get(t)}get useMagnetic(){return this.config.units.headingAttribute==="navigation.headingMagnetic"}addToSelfTrail(e){this.selfTrail.update(t=>{if(t.length===0)return t;let i=t.slice(-1)[0];if(e[0]===i[0]&&e[1]===i[1])return t;let r=[].concat(t);return r.push(e),r})}isVesselTrackShown(e){return ow(this.data.vessels.showTrack,e)}toggleVesselTrack(e){this.data.vessels.showTrack=SD(this.data.vessels.showTrack,e)}mapViewport(){return this.mapExtent().length?{halfWidth:oi.distanceTo(this.config.map.center,this.mapViewRightCenter()),halfHeight:oi.distanceTo(this.config.map.center,this.mapViewTopCenter()),rotation:this.mapViewRotation()}:null}calcMapCenter(e=!0,t=0){let i=this.data.vessels.active.position,r=this.config.map.centerOffset,o=e&&(r.x||r.y)?this.mapViewport():null;return o?t?E6(i,o,r,t):Pw(i,o,r):i}applyPanGesture(e){let t=this.mapViewport();if(!t)return"unchanged";let i=I6(this.data.vessels.active.position,e,t);if(i.action==="release")return"release";if(i.action==="ignore")return"unchanged";let r=this.config.map.centerOffset;return i.offset.x===r.x&&i.offset.y===r.y?"unchanged":(this.config.map.centerOffset=i.offset,"adopted")}alignCustomResourcesPaths(){this.signalk.api.get(this.skApiVersion,"/resources").subscribe(e=>{let t=Object.keys(e).filter(i=>!this.IGNORE_RESOURCES.includes(i));this.config.resources.paths=this.config.resources.paths.filter(i=>t.includes(i))})}saveConfig(){super.saveConfig(),this.isLoggedIn()&&this.signalk.appDataSet("/",this.config).subscribe({next:()=>this.debug("saveConfig: config saved to server."),error:()=>this.debug("saveConfig: Cannot save config to server!")})}saveCfgTimer;saveConfigDebounced(e=1e3){clearTimeout(this.saveCfgTimer),this.saveCfgTimer=setTimeout(()=>this.saveConfig(),e)}showHelp(e){let t=`./assets/help/index.html${e?"#"+e:""}`;window.open(t,"help")}showMsgBox(e,t,i){return this.dialog.open(UC,{disableClose:!1,data:{message:t,title:e,buttonText:i}}).afterClosed()}showAlert(e,t,i){return this.dialog.open(HC,{disableClose:!1,data:{message:t,title:e,buttonText:i}}).afterClosed()}showErrorList(e,t){return this.dialog.open(vy,{disableClose:!1,data:{errorList:e,buttonText:t}}).afterClosed()}showMessage(e,t=!1,i=5e3){this.snackbar.openFromComponent($C,{duration:i,data:{message:e,sound:t}})}showConfirm(e,t,i,r,o){return this.dialog.open(KC,{disableClose:!0,data:{message:e,title:t,button1Text:i,button2Text:r,checkText:o}}).afterClosed()}parseHttpErrorResponse(e){let t="";e.status&&[401,403].includes(e.status)?t=`Signal K server requires authentication to update resources.
|
|
755
755
|
Please login and try again.
|
|
756
756
|
`:t=`Operation could not be completed!
|
|
757
757
|
`,this.showAlert(`${e.status??"Error"}`,t+`${e.error?.message??""}`)}formatValueForDisplay(e,t,i){if(typeof e=="number"){let r=i?.precision??1,o="",a,s=i?.path?this.getPathDisplayUnits(i.path):void 0;if(s)try{return a=t==="ratio"?this.formatNumericDisplay(Math.abs(e)<=1?e*100:e,Math.abs(e)<=1?r:4):this.formatNumericDisplay(Ge.transform(e,t,s.targetUnit),r),o=s.symbol??Ge.getSymbol(s.targetUnit),`${a}${i?.noSymbol?"":o}`}catch(l){console.warn(`formatValueForDisplay: invalid displayUnits for path "${i.path}" \u2014 falling back to category preset.`)}if(t==="K")o=Ge.getSymbol(this.config.units.temperature),a=this.formatNumericDisplay(Ge.transform(e,t,this.config.units.temperature),r);else if(t==="rad")o=Ge.getSymbol("degree"),a=this.formatNumericDisplay(Ge.transform(e,t,"degree"),r);else if(t==="m/s")o=Ge.getSymbol(this.config.units.speed),a=this.formatNumericDisplay(Ge.transform(e,t,this.config.units.speed),r);else if(t==="ratio")o=Ge.getSymbol("percent"),a=Math.abs(e)<=1?this.formatNumericDisplay(e*100,r):this.formatNumericDisplay(e,4);else if(t==="deg")o=Ge.getSymbol("degree"),a=this.formatNumericDisplay(e,r);else if(t==="m")if(i?.category==="depth")o=Ge.getSymbol(this.config.units.depth),a=this.formatNumericDisplay(Ge.transform(e,t,this.config.units.depth),r);else if(i?.category==="length")({nv:a,symbol:o}=this.formatAsLengthUnit(e,t,r));else if(this.config.units.distance==="kilometer"&&e<1e3)o=Ge.getSymbol("m"),a=this.formatNumericDisplay(e,0);else if(this.config.units.distance==="naut-mile"){let l=Ge.transform(e,t,this.config.units.distance);l<.5?{nv:a,symbol:o}=this.formatAsLengthUnit(e,t,0):(o=Ge.getSymbol(this.config.units.distance),a=this.formatNumericDisplay(l,r))}else o=Ge.getSymbol(this.config.units.distance),a=this.formatNumericDisplay(Ge.transform(e,t,this.config.units.distance),r);else if(t==="s"){let l=Math.floor(e/60),c=l/60;if(c>=24){let d=Math.floor(c%24),h=d!==0?`${d}`.slice(-2)+"h":"";return`${Math.floor(c/24)}d ${h}`}if(l>=60){let d=Math.floor(c%1*60),h=d!==0?`00${d}`.slice(-2)+"m":"";return`${Math.floor(c)}h ${h}`}return`${l} min`}else a=this.formatNumericDisplay(Ge.transform(e,t,t),r);return`${a}${i?.noSymbol?"":o}`}else return typeof e=="string"&&e[String(e).length-1]==="Z"&&e[10]==="T"?new Date(e).toLocaleString():`${e}${t}`}formatNumericDisplay(e,t){return t=Number.isFinite(t)?t:1,Number.isFinite(e)?Number.isFinite(t)?e.toFixed(t):`${e}`:"---".slice(0-t)}formatAsLengthUnit(e,t,i){return{nv:this.formatNumericDisplay(Ge.transform(e,t,this.config.units.length),i),symbol:Ge.getSymbol(this.config.units.length)}}formatSpeed(e,t=!1){this.formattedSpeedUnits=Ge.getSymbol(this.config.units.speed);try{e=Ge.transform(e,"m/s",this.config.units.speed)}catch(i){e=null}finally{return t?this.formatNumericDisplay(e):e}}formattedSpeedUnits=Ge.getSymbol("kn");static \u0275fac=function(t){return new(t||n)};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})},CE=class{db;dbUpdateSource;dbUpdate$;constructor(){this.dbUpdateSource=new ze,this.dbUpdate$=this.dbUpdateSource.asObservable(),this.db=new b1("freeboard",1),this.db.openDatabase(1,e=>{e.currentTarget.result.createObjectStore("trail",{keyPath:"uuid"}).createIndex("uuid_idx","uuid",{unique:!0})}).then(()=>{this.emitDbUpdate({action:"db_init",value:!0})},()=>{this.emitDbUpdate({action:"db_init",value:!1})})}emitDbUpdate(e=null){this.dbUpdateSource.next(e)}getTrail(e="self"){return this.db.getByIndex("trail","uuid_idx",e)}saveTrail(e="self",t){this.db.update("trail",{uuid:e,value:t}).then(()=>{this.emitDbUpdate({action:"trail_save",value:!0})},()=>{this.db.add("trail",{uuid:e,value:t}).then(()=>{this.emitDbUpdate({action:"trail_save",value:!0})},()=>{this.emitDbUpdate({action:"trail_save",value:!1})})})}};var xre=["*"];function Cre(n,e){n&1&&de(0)}var wE=(()=>{class n{_elementRef=M(Ct);constructor(){}focus(){this._elementRef.nativeElement.focus()}static \u0275fac=function(i){return new(i||n)};static \u0275dir=lt({type:n,selectors:[["","cdkStepHeader",""]],hostAttrs:["role","tab"]})}return n})(),ME=(()=>{class n{template=M(qr);constructor(){}static \u0275fac=function(i){return new(i||n)};static \u0275dir=lt({type:n,selectors:[["","cdkStepLabel",""]]})}return n})();var kp={NUMBER:"number",EDIT:"edit",DONE:"done",ERROR:"error"},wre=new xt("STEPPER_GLOBAL_OPTIONS"),k2=(()=>{class n{_stepperOptions;_stepper=M(I_);_displayDefaultIndicatorType;stepLabel;_childForms;content;stepControl;get interacted(){return this._interacted()}set interacted(t){this._interacted.set(t)}_interacted=X(!1);interactedStream=new he;label;errorMessage;ariaLabel;ariaLabelledby;get state(){return this._state()}set state(t){this._state.set(t)}_state=X(void 0);get editable(){return this._editable()}set editable(t){this._editable.set(t)}_editable=X(!0);optional=!1;get completed(){let t=this._completedOverride(),i=this._interacted();return t??(i&&(!this.stepControl||this.stepControl.valid))}set completed(t){this._completedOverride.set(t)}_completedOverride=X(null);index=X(-1);isSelected=qt(()=>this._stepper.selectedIndex===this.index());indicatorType=qt(()=>{let t=this.isSelected(),i=this.completed,r=this._state()??kp.NUMBER,o=this._editable();return this._showError()&&this.hasError&&!t?kp.ERROR:this._displayDefaultIndicatorType?!i||t?kp.NUMBER:o?kp.EDIT:kp.DONE:i&&!t?kp.DONE:i&&t?r:o&&t?kp.EDIT:r});isNavigable=qt(()=>{let t=this.isSelected();return this.completed||t||!this._stepper.linear});get hasError(){let t=this._customError();return t??this._getDefaultError()}set hasError(t){this._customError.set(t)}_customError=X(null);_getDefaultError(){return this.interacted&&!!this.stepControl?.invalid}constructor(){let t=M(wre,{optional:!0});this._stepperOptions=t||{},this._displayDefaultIndicatorType=this._stepperOptions.displayDefaultIndicatorType!==!1}select(){this._stepper.selected=this}reset(){this._interacted.set(!1),this._completedOverride()!=null&&this._completedOverride.set(!1),this._customError()!=null&&this._customError.set(!1),this.stepControl&&(this._childForms?.forEach(t=>t.resetForm?.()),this.stepControl.reset())}ngOnChanges(){this._stepper._stateChanged()}_markAsInteracted(){this._interacted()||(this._interacted.set(!0),this.interactedStream.emit(this))}_showError(){return this._stepperOptions.showError??this._customError()!=null}static \u0275fac=function(i){return new(i||n)};static \u0275cmp=W({type:n,selectors:[["cdk-step"]],contentQueries:function(i,r,o){if(i&1&&on(o,ME,5)(o,JI,5),i&2){let a;De(a=ke())&&(r.stepLabel=a.first),De(a=ke())&&(r._childForms=a)}},viewQuery:function(i,r){if(i&1&&$t(qr,7),i&2){let o;De(o=ke())&&(r.content=o.first)}},inputs:{stepControl:"stepControl",label:"label",errorMessage:"errorMessage",ariaLabel:[0,"aria-label","ariaLabel"],ariaLabelledby:[0,"aria-labelledby","ariaLabelledby"],state:"state",editable:[2,"editable","editable",Ue],optional:[2,"optional","optional",Ue],completed:[2,"completed","completed",Ue],hasError:[2,"hasError","hasError",Ue]},outputs:{interactedStream:"interacted"},exportAs:["cdkStep"],features:[Se],ngContentSelectors:xre,decls:1,vars:0,template:function(i,r){i&1&&(fe(),Pd(0,Cre,1,0,"ng-template"))},encapsulation:2,changeDetection:0})}return n})(),I_=(()=>{class n{_dir=M(co,{optional:!0});_changeDetectorRef=M(re);_elementRef=M(Ct);_destroyed=new ze;_keyManager;_steps;steps=new rs;_stepHeader;_sortedHeaders=new rs;get linear(){return this._linear()}set linear(t){this._linear.set(t)}_linear=X(!1);get selectedIndex(){return this._selectedIndex()}set selectedIndex(t){this._steps?(this._isValidIndex(t),this.selectedIndex!==t&&(this.selected?._markAsInteracted(),!this._anyControlsInvalidOrPending(t)&&(t>=this.selectedIndex||this.steps.toArray()[t].editable)&&this._updateSelectedItemIndex(t))):this._selectedIndex.set(t)}_selectedIndex=X(0);get selected(){return this.steps?this.steps.toArray()[this.selectedIndex]:void 0}set selected(t){this.selectedIndex=t&&this.steps?this.steps.toArray().indexOf(t):-1}selectionChange=new he;selectedIndexChange=new he;_groupId=M(or).getId("cdk-stepper-");get orientation(){return this._orientation}set orientation(t){this._orientation=t,this._keyManager&&this._keyManager.withVerticalOrientation(t==="vertical")}_orientation="horizontal";constructor(){}ngAfterContentInit(){this._steps.changes.pipe(un(this._steps),xi(this._destroyed)).subscribe(t=>{this.steps.reset(t.filter(i=>i._stepper===this)),this.steps.forEach((i,r)=>i.index.set(r)),this.steps.notifyOnChanges()})}ngAfterViewInit(){if(this._stepHeader.changes.pipe(un(this._stepHeader),xi(this._destroyed)).subscribe(t=>{this._sortedHeaders.reset(t.toArray().sort((i,r)=>i._elementRef.nativeElement.compareDocumentPosition(r._elementRef.nativeElement)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),this._sortedHeaders.notifyOnChanges()}),this._keyManager=new Bl(this._sortedHeaders).withWrap().withHomeAndEnd().withVerticalOrientation(this._orientation==="vertical"),this._keyManager.updateActiveItem(this.selectedIndex),(this._dir?this._dir.change:Jt()).pipe(un(this._layoutDirection()),xi(this._destroyed)).subscribe(t=>this._keyManager?.withHorizontalOrientation(t)),this._keyManager.updateActiveItem(this.selectedIndex),this.steps.changes.subscribe(()=>{this.selected||this._selectedIndex.set(Math.max(this.selectedIndex-1,0))}),this._isValidIndex(this.selectedIndex)||this._selectedIndex.set(0),this.linear&&this.selectedIndex>0){let t=this.steps.toArray().slice(0,this._selectedIndex());for(let i of t)i._markAsInteracted()}}ngOnDestroy(){this._keyManager?.destroy(),this.steps.destroy(),this._sortedHeaders.destroy(),this._destroyed.next(),this._destroyed.complete()}next(){this.selectedIndex=Math.min(this._selectedIndex()+1,this.steps.length-1)}previous(){this.selectedIndex=Math.max(this._selectedIndex()-1,0)}reset(){this._updateSelectedItemIndex(0),this.steps.forEach(t=>t.reset()),this._stateChanged()}_getStepLabelId(t){return`${this._groupId}-label-${t}`}_getStepContentId(t){return`${this._groupId}-content-${t}`}_stateChanged(){this._changeDetectorRef.markForCheck()}_getAnimationDirection(t){let i=t-this._selectedIndex();return i<0?this._layoutDirection()==="rtl"?"next":"previous":i>0?this._layoutDirection()==="rtl"?"previous":"next":"current"}_getFocusIndex(){return this._keyManager?this._keyManager.activeItemIndex:this._selectedIndex()}_updateSelectedItemIndex(t){let i=this.steps.toArray(),r=this._selectedIndex();this.selectionChange.emit({selectedIndex:t,previouslySelectedIndex:r,selectedStep:i[t],previouslySelectedStep:i[r]}),this._keyManager&&(this._containsFocus()?this._keyManager.setActiveItem(t):this._keyManager.updateActiveItem(t)),this._selectedIndex.set(t),this.selectedIndexChange.emit(t),this._stateChanged()}_onKeydown(t){let i=Ss(t),r=t.keyCode,o=this._keyManager;o?.activeItemIndex!=null&&!i&&(r===32||r===13)?(this.selectedIndex=o.activeItemIndex,t.preventDefault()):o?.setFocusOrigin("keyboard").onKeydown(t)}_anyControlsInvalidOrPending(t){return this.linear&&t>=0?this.steps.toArray().slice(0,t).some(i=>{let r=i.stepControl;return(r?r.invalid||r.pending||!i.interacted:!i.completed)&&!i.optional&&!i._completedOverride()}):!1}_layoutDirection(){return this._dir&&this._dir.value==="rtl"?"rtl":"ltr"}_containsFocus(){let t=this._elementRef.nativeElement,i=kI();return t===i||t.contains(i)}_isValidIndex(t){return t>-1&&(!this.steps||t<this.steps.length)}static \u0275fac=function(i){return new(i||n)};static \u0275dir=lt({type:n,selectors:[["","cdkStepper",""]],contentQueries:function(i,r,o){if(i&1&&on(o,k2,5)(o,wE,5),i&2){let a;De(a=ke())&&(r._steps=a),De(a=ke())&&(r._stepHeader=a)}},inputs:{linear:[2,"linear","linear",Ue],selectedIndex:[2,"selectedIndex","selectedIndex",zi],selected:"selected",orientation:"orientation"},outputs:{selectionChange:"selectionChange",selectedIndexChange:"selectedIndexChange"},exportAs:["cdkStepper"]})}return n})(),vN=(()=>{class n{_stepper=M(I_);type="submit";constructor(){}static \u0275fac=function(i){return new(i||n)};static \u0275dir=lt({type:n,selectors:[["button","cdkStepperNext",""]],hostVars:1,hostBindings:function(i,r){i&1&&T("click",function(){return r._stepper.next()}),i&2&&Mo("type",r.type)},inputs:{type:"type"}})}return n})();var bN=(()=>{class n{static \u0275fac=function(i){return new(i||n)};static \u0275mod=Di({type:n});static \u0275inj=Ii({imports:[An]})}return n})();var Mre=(n,e,t)=>({index:n,active:e,optional:t});function Sre(n,e){if(n&1&&so(0,2),n&2){let t=v();w("ngTemplateOutlet",t.iconOverrides[t.state])("ngTemplateOutletContext",zp(2,Mre,t.index,t.active,t.optional))}}function Tre(n,e){if(n&1&&(u(0,"span",7),_(1),p()),n&2){let t=v(2);g(),q(t._getDefaultTextForState(t.state))}}function Ere(n,e){if(n&1&&(u(0,"span",8),_(1),p()),n&2){let t=v(3);g(),q(t._intl.completedLabel)}}function Ire(n,e){if(n&1&&(u(0,"span",8),_(1),p()),n&2){let t=v(3);g(),q(t._intl.editableLabel)}}function Dre(n,e){if(n&1&&(R(0,Ere,2,1,"span",8)(1,Ire,2,1,"span",8),u(2,"mat-icon",7),_(3),p()),n&2){let t=v(2);A(t.state==="done"?0:t.state==="edit"?1:-1),g(3),q(t._getDefaultTextForState(t.state))}}function kre(n,e){if(n&1&&R(0,Tre,2,1,"span",7)(1,Dre,4,2),n&2){let t,i=v();A((t=i.state)==="number"?0:1)}}function Pre(n,e){n&1&&(u(0,"div",4),so(1,9),p()),n&2&&(g(),w("ngTemplateOutlet",e.template))}function Rre(n,e){if(n&1&&(u(0,"div",4),_(1),p()),n&2){let t=v();g(),q(t.label)}}function Lre(n,e){if(n&1&&(u(0,"div",5),_(1),p()),n&2){let t=v();g(),q(t._intl.optionalLabel)}}function Are(n,e){if(n&1&&(u(0,"div",6),_(1),p()),n&2){let t=v();g(),q(t.errorMessage)}}var xN=["*"];function Ore(n,e){}function Fre(n,e){if(n&1&&(de(0),Mt(1,Ore,0,0,"ng-template",0)),n&2){let t=v();g(),w("cdkPortalOutlet",t._portal)}}var Nre=["animatedContainer"],CN=n=>({steps:n}),wN=n=>({step:n});function Bre(n,e){n&1&&de(0)}function Vre(n,e){if(n&1&&(u(0,"div",5),so(1,9)(2,6),p()),n&2){let t=v(2),i=Oe(6);g(),w("ngTemplateOutlet",t.headerPrefix()),g(),w("ngTemplateOutlet",i)("ngTemplateOutletContext",an(3,CN,t.steps))}}function Gre(n,e){if(n&1&&so(0,6),n&2){let t=v(2),i=Oe(6);w("ngTemplateOutlet",i)("ngTemplateOutletContext",an(2,CN,t.steps))}}function zre(n,e){if(n&1&&(u(0,"div",10,2),so(2,9),p()),n&2){let t=e.$implicit,i=e.$index,r=v(2);Rt("mat-horizontal-stepper-content-"+r._getAnimationDirection(i)),w("id",r._getStepContentId(i)),st("aria-labelledby",r._getStepLabelId(i))("inert",r.selectedIndex===i?null:""),g(2),w("ngTemplateOutlet",t.content)}}function jre(n,e){if(n&1&&(u(0,"div",3),R(1,Vre,3,5,"div",5)(2,Gre,1,4,"ng-container",6),u(3,"div",7),Le(4,zre,3,6,"div",8,gt),p()()),n&2){let t=v();g(),A(t.headerPrefix()?1:2),g(3),Ae(t.steps)}}function Wre(n,e){if(n&1&&so(0,9),n&2){let t=v(2);w("ngTemplateOutlet",t.headerPrefix())}}function Ure(n,e){if(n&1&&(u(0,"div",11),so(1,6),u(2,"div",12,2)(4,"div",13)(5,"div",14),so(6,9),p()()()()),n&2){let t=e.$implicit,i=e.$index,r=e.$index,o=e.$count,a=v(2),s=Oe(4);g(),w("ngTemplateOutlet",s)("ngTemplateOutletContext",an(11,wN,t)),g(),_t("mat-stepper-vertical-line",r!==o-1)("mat-vertical-content-container-active",a.selectedIndex===i),st("inert",a.selectedIndex===i?null:"")("aria-label",a.ariaLabel),g(2),w("id",a._getStepContentId(i)),st("aria-labelledby",a._getStepLabelId(i)),g(2),w("ngTemplateOutlet",t.content)}}function Hre(n,e){if(n&1&&(u(0,"div",4),R(1,Wre,1,1,"ng-container",9),Le(2,Ure,7,13,"div",11,gt),p()),n&2){let t=v();g(),A(t.headerPrefix()?1:-1),g(),Ae(t.steps)}}function Kre(n,e){if(n&1){let t=H();u(0,"mat-step-header",15),T("click",function(){let r=O(t).step;return F(r.select())})("keydown",function(r){O(t);let o=v();return F(o._onKeydown(r))}),p()}if(n&2){let t=e.step,i=v();_t("mat-horizontal-stepper-header",i.orientation==="horizontal")("mat-vertical-stepper-header",i.orientation==="vertical"),w("tabIndex",i._getFocusIndex()===t.index()?0:-1)("id",i._getStepLabelId(t.index()))("index",t.index())("state",t.indicatorType())("label",t.stepLabel||t.label)("selected",t.isSelected())("active",t.isNavigable())("optional",t.optional)("errorMessage",t.errorMessage)("iconOverrides",i._iconOverrides)("disableRipple",i.disableRipple||!t.isNavigable())("color",t.color||i.color),st("role",i.orientation==="horizontal"?"tab":"button")("aria-posinset",i.orientation==="horizontal"?t.index()+1:null)("aria-setsize",i.orientation==="horizontal"?i.steps.length:null)("aria-selected",i.orientation==="horizontal"?t.isSelected():null)("aria-current",i.orientation==="vertical"&&t.isSelected()?"step":null)("aria-disabled",i.orientation==="vertical"&&t.isSelected()?"true":null)("aria-expanded",i.orientation==="vertical"?t.isSelected():null)("aria-controls",i._getStepContentId(t.index()))("aria-label",t.ariaLabel||null)("aria-labelledby",!t.ariaLabel&&t.ariaLabelledby?t.ariaLabelledby:null)("aria-disabled",t.isNavigable()?null:!0)}}function $re(n,e){n&1&&z(0,"div",17)}function qre(n,e){if(n&1&&(so(0,6),R(1,$re,1,0,"div",17)),n&2){let t=e.$implicit,i=e.$index,r=e.$count;v(2);let o=Oe(4);w("ngTemplateOutlet",o)("ngTemplateOutletContext",an(3,wN,t)),g(),A(i!==r-1?1:-1)}}function Zre(n,e){if(n&1&&(u(0,"div",16),Le(1,qre,2,5,null,null,gt),p()),n&2){let t=e.steps,i=v();st("aria-label",i.ariaLabel),g(),Ae(t)}}var D_=(()=>{class n extends ME{static \u0275fac=(()=>{let t;return function(r){return(t||(t=$r(n)))(r||n)}})();static \u0275dir=lt({type:n,selectors:[["","matStepLabel",""]],features:[Qe]})}return n})(),Xre=(()=>{class n{changes=new ze;optionalLabel="Optional";completedLabel="Completed";editableLabel="Editable";static \u0275fac=function(i){return new(i||n)};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})(),SE=(()=>{class n extends wE{_intl=M(Xre);_focusMonitor=M(Ho);_intlSubscription;state;label;errorMessage;iconOverrides;index;selected=!1;active=!1;optional=!1;disableRipple=!1;color;constructor(){super();let t=M(Dr);t.load(Zr),t.load(t1);let i=M(re);this._intlSubscription=this._intl.changes.subscribe(()=>i.markForCheck())}ngAfterViewInit(){this._focusMonitor.monitor(this._elementRef,!0)}ngOnDestroy(){this._intlSubscription.unsubscribe(),this._focusMonitor.stopMonitoring(this._elementRef)}focus(t,i){t?this._focusMonitor.focusVia(this._elementRef,t,i):this._elementRef.nativeElement.focus(i)}_stringLabel(){return this.label instanceof D_?null:this.label}_templateLabel(){return this.label instanceof D_?this.label:null}_getHostElement(){return this._elementRef.nativeElement}_getDefaultTextForState(t){return t=="number"?`${this.index+1}`:t=="edit"?"create":t=="error"?"warning":t}_hasEmptyLabel(){return!this._stringLabel()&&!this._templateLabel()&&!this._hasOptionalLabel()&&!this._hasErrorLabel()}_hasOptionalLabel(){return this.optional&&this.state!=="error"}_hasErrorLabel(){return this.state==="error"}static \u0275fac=function(i){return new(i||n)};static \u0275cmp=W({type:n,selectors:[["mat-step-header"]],hostAttrs:["role","",1,"mat-step-header"],hostVars:4,hostBindings:function(i,r){i&2&&(Rt("mat-"+(r.color||"primary")),_t("mat-step-header-empty-label",r._hasEmptyLabel()))},inputs:{state:"state",label:"label",errorMessage:"errorMessage",iconOverrides:"iconOverrides",index:"index",selected:"selected",active:"active",optional:"optional",disableRipple:"disableRipple",color:"color"},features:[Qe],decls:10,vars:17,consts:[["matRipple","",1,"mat-step-header-ripple","mat-focus-indicator",3,"matRippleTrigger","matRippleDisabled"],[1,"mat-step-icon-content"],[3,"ngTemplateOutlet","ngTemplateOutletContext"],[1,"mat-step-label"],[1,"mat-step-text-label"],[1,"mat-step-optional"],[1,"mat-step-sub-label-error"],["aria-hidden","true"],[1,"cdk-visually-hidden"],[3,"ngTemplateOutlet"]],template:function(i,r){if(i&1&&(z(0,"div",0),u(1,"div")(2,"div",1),R(3,Sre,1,6,"ng-container",2)(4,kre,2,1),p()(),u(5,"div",3),R(6,Pre,2,1,"div",4)(7,Rre,2,1,"div",4),R(8,Lre,2,1,"div",5),R(9,Are,2,1,"div",6),p()),i&2){let o;w("matRippleTrigger",r._getHostElement())("matRippleDisabled",r.disableRipple),g(),Rt(SI("mat-step-icon-state-",r.state," mat-step-icon")),_t("mat-step-icon-selected",r.selected),g(2),A(r.iconOverrides&&r.iconOverrides[r.state]?3:4),g(2),_t("mat-step-label-active",r.active)("mat-step-label-selected",r.selected)("mat-step-label-error",r.state=="error"),g(),A((o=r._templateLabel())?6:r._stringLabel()?7:-1,o),g(2),A(r._hasOptionalLabel()?8:-1),g(),A(r._hasErrorLabel()?9:-1)}},dependencies:[Ko,Jf,ce],styles:[`.mat-step-header {
|
|
@@ -1120,7 +1120,7 @@ Please login and try again.
|
|
|
1120
1120
|
.mat-vertical-content {
|
|
1121
1121
|
padding: 0 24px 24px 24px;
|
|
1122
1122
|
}
|
|
1123
|
-
`],encapsulation:2,changeDetection:0})}return n})(),MN=(()=>{class n extends vN{static \u0275fac=(()=>{let t;return function(r){return(t||(t=$r(n)))(r||n)}})();static \u0275dir=lt({type:n,selectors:[["button","matStepperNext",""]],hostAttrs:[1,"mat-stepper-next"],hostVars:1,hostBindings:function(i,r){i&2&&Mo("type",r.type)},features:[Qe]})}return n})();var Df=(()=>{class n{static \u0275fac=function(i){return new(i||n)};static \u0275mod=Di({type:n});static \u0275inj=Ii({providers:[$p],imports:[Wp,bN,le,Ts,P_,SE,An]})}return n})();var EE=Ma(Os());var dn=class n{symDegree="\xBA";transform(e,t,i){let r=i?e<0?"S":"N":e<0?"W":"E";switch(t){case"SHDd":return this.toHDdSigned(e,r);case"DMdH":return this.toDMdH(e,r);case"HDd":return this.toHDd(e,r);case"HDMS":return this.toHDMS(e,r);case"DHMS":return this.toDHMS(e,r);default:return this.toXY(e)}}toXY(e,t=5){return e.toFixed(t)}toHDdSigned(e,t,i=5){let r=["S","W"].includes(t)?`${t} -`:`${t} +`,o=e.toFixed(i);return o=o.substring(o.indexOf(".")),`${r}${Math.floor(Math.abs(e))}${o}${this.symDegree}`}toDMdH(e,t,i=5){let r=Math.floor(Math.abs(e))??0,a=(Math.abs(r===0?e:e%r)*60).toFixed(i),s=["N","S"].includes(t)?"00":"000";return`${(s+r.toString()).slice(0-s.length)}${this.symDegree} ${a}' ${t}`}toHDd(e,t,i=5){let r=e.toFixed(i);return r=r.substring(r.indexOf(".")),`${t} ${Math.floor(Math.abs(e))}${r}${this.symDegree}`}toHDMS(e,t){return`${t} ${(0,EE.decimalToSexagesimal)(e)}`}toDHMS(e,t){let i=(0,EE.decimalToSexagesimal)(e);return i=i.slice(0,i.indexOf(" ")-1)+t+i.slice(i.indexOf(" ")+1),i}static \u0275fac=function(t){return new(t||n)};static \u0275pipe=Bp({name:"coords",type:n,pure:!0})};function Qre(n,e){if(n&1&&(u(0,"span",4),_(1),p()),n&2){let t=v().$implicit;g(),q(t[1])}}function Jre(n,e){if(n&1&&(u(0,"div",7),_(1),wt(2,"coords"),p()),n&2){let t=v(2).$implicit,i=v();w("matTooltip",t[2]),g(),$(" ",Oi(2,2,t[2],i.app.config.units.positionFormat,!0)," ")}}function eoe(n,e){if(n&1&&(u(0,"div",7),_(1),wt(2,"coords"),p()),n&2){let t=v(2).$implicit,i=v();w("matTooltip",t[2]),g(),$(" ",Oi(2,2,t[2],i.app.config.units.positionFormat,!1)," ")}}function toe(n,e){if(n&1&&(u(0,"div",7),_(1),p()),n&2){let t=v(2).$implicit;w("matTooltip",t[2]),g(),q(t[2])}}function ioe(n,e){if(n&1&&(u(0,"div",5)(1,"div",6),_(2),p(),R(3,Jre,3,6,"div",7)(4,eoe,3,6,"div",7)(5,toe,2,2,"div",7),p()),n&2){let t=v().$implicit;g(),w("matTooltip",t[1]),g(),q(t[1]),g(),A(t[1]==="latitude"?3:t[1]==="longitude"?4:5)}}function noe(n,e){if(n&1&&(u(0,"div",3),R(1,Qre,2,1,"span",4),R(2,ioe,6,3,"div",5),p()),n&2){let t=e.$implicit;g(),A(t[0]===0&&t[2]===null?1:-1),g(),A(t[2]!==null?2:-1)}}var Sd=class n{title=Z("");details=Z();items;app=M(ae);constructor(){}ngOnChanges(){this.details()?this.parseEntries():this.items=[]}parseEntries(){let e=Object.entries(this.details());e.sort((t,i)=>t[0]<i[0]?-1:1),this.items=this.section(this.flatten(e))}section(e){let t=[];e.forEach(o=>{let a=o[0].split(".");if(a.length===1)t.push([0,"",a[0],typeof o[1]!="object"?o[1]:null]);else{let s=a.slice(0,a.length-1).join(".");t.push([a.length-1,s,a[a.length-1],o[1]])}}),t.sort((o,a)=>o[1]<a[1]?-1:1);let i=null,r=[];return e=[],t.forEach(o=>{o[1]!==i&&(i=o[1],r.indexOf(o[1])===-1&&(r.push(o[1]),e.push([0,o[1],null]))),e.push([o[0],o[2],o[3]])}),e}flatten(e){let t=[];return e.forEach(i=>{typeof i[1]=="object"&&i[1]!==null?t=t.concat(this.processObject(i[0],i[1])):t.push([i[0],i[1]])}),t}processObject(e,t){let i=[],r=Object.entries(t);return r.sort((o,a)=>o[0]<a[0]?-1:1),r.forEach(o=>{typeof o[1]=="object"&&o[1]!==null?i=i.concat(this.processObject(e+"."+o[0],o[1])):i.push([e+"."+o[0],o[1]])}),i}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["signalk-details-list"]],inputs:{title:[1,"title"],details:[1,"details"]},features:[Se],decls:7,vars:1,consts:[[1,"sk-details"],[1,"title"],[1,"content"],[1,"item"],[1,"sectionname"],[1,"pathvalue"],[1,"path",3,"matTooltip"],[1,"value",3,"matTooltip"]],template:function(t,i){t&1&&(u(0,"div",0)(1,"div",1)(2,"div"),_(3),p()(),u(4,"div",2),Le(5,noe,3,2,"div",3,gt),p()()),t&2&&(g(3),q(i.title()),g(2),Ae(i.items))},dependencies:[be,Pe,dn],styles:[".sk-details[_ngcontent-%COMP%]{position:relative;display:flex;flex-direction:column;font-family:Roboto,Arial,Helvetica,sans-serif;font-size:10pt;max-height:100%}.sk-details[_ngcontent-%COMP%] .title[_ngcontent-%COMP%]{background:left 1px -webkit-gradient(linear,left top,left bottom,from(rgba(0,0,0,.18)),color-stop(.65,transparent)) #b2bbc2e3;padding:3px 5px 0;font-weight:500;line-height:23px}.sk-details[_ngcontent-%COMP%] .content[_ngcontent-%COMP%]{padding:0;line-height:23px;margin:0;flex:1 1 auto;overflow:auto}.sk-details[_ngcontent-%COMP%] .item[_ngcontent-%COMP%]{display:flex;flex-direction:row;line-height:26px;border-width:0 0 0 0;border-style:solid;border-color:gray;padding-left:5px}.sk-details[_ngcontent-%COMP%] .content[_ngcontent-%COMP%] .item[_ngcontent-%COMP%]{border-width:0 0 1px 0}.sk-details[_ngcontent-%COMP%] .sectionname[_ngcontent-%COMP%]{text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%;font-weight:500}.sk-details[_ngcontent-%COMP%] .pathvalue[_ngcontent-%COMP%]{display:flex;flex-wrap:nowrap;width:100%}.sk-details[_ngcontent-%COMP%] .pathvalue[_ngcontent-%COMP%] .path[_ngcontent-%COMP%]{text-align:left;width:60%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-style:italic}.sk-details[_ngcontent-%COMP%] .pathvalue[_ngcontent-%COMP%] .value[_ngcontent-%COMP%]{text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}"],changeDetection:0})};var NE=Ma(RN());var _c=class n{isMeasuring=X(!1);isDrawing=X(!1);isModifying=X(!1);isBoxSelecting=X(!1);measurement=X({coords:[],index:-1,center:null,radius:0});selection=X({mode:null});selectionResult;measureGeometryType="LineString";draw={resourceType:null,featureType:"Point",coordinates:null,features:null,forSave:null,properties:{}};modifyUndoStack=[];undoDepth=X(0);canUndo=qt(()=>this.isDrawing()?this.measurement().coords.length>=1:this.isModifying()?this.undoDepth()>0:!1);app=M(ae);constructor(){}pushModifyUndo(e){this.modifyUndoStack.push(e),this.undoDepth.set(this.modifyUndoStack.length)}popModifyUndo(){let e=this.modifyUndoStack.pop();return this.undoDepth.set(this.modifyUndoStack.length),e}clearUndo(){this.modifyUndoStack=[],this.undoDepth.set(0)}initBoxCoord(e){this.selectionResult||(this.selectionResult={mode:null}),this.selectionResult.bbox=[e]}set measurementCoords(e){this.measurement.update(t=>Object.assign({},t,{coords:e}))}set measurementIndex(e){this.measurement.update(t=>Object.assign({},t,{index:e}))}set measurementCenter(e){this.measurement.update(t=>Object.assign({},t,{center:e}))}set measurementRadius(e){this.measurement.update(t=>Object.assign({},t,{radius:e}))}addMeasurementCoord(e){let t=oi.distanceTo(this.measurement().coords[this.measurement().coords.length-1],e);return this.measurement.update(i=>{let r=[].concat(i.coords);return r.push(e),Object.assign({},i,{coords:r})}),t}distanceFromLastPoint(e){return e&&this.measurement().coords.length>0?oi.distanceTo(this.measurement().coords[this.measurement().coords.length-1],e):0}distanceFromCenter(e){return!e||!this.measurement().center?0:oi.distanceTo(this.measurement().center,e)}startMeasuring(e,t){this.measureGeometryType=e??"LineString",this.app.debug("startMeasuring()..."),this.isMeasuring.set(!0),this.interactionStarted()}stopMeasuring(){this.app.debug("stopMeasuring()..."),this.isMeasuring.set(!1),this.interactionEnded()}startDrawing(e){this.app.debug("startDrawing()..."),this.isDrawing.set(!0),this.draw.name=void 0,this.draw.resourceType=e,this.draw.featureType=e==="route"?"LineString":e==="region"?"Polygon":"Point",this.interactionStarted()}stopDrawing(e){if(this.app.debug("stopDrawing()..."),this.isDrawing.set(!1),e)switch(this.draw.featureType){case"Point":this.draw.coordinates=ln(e.getGeometry().getCoordinates());break;case"LineString":let t=e.getGeometry().getCoordinates();this.draw.coordinates=t.map(r=>ln(r));break;case"Polygon":let i=e.getGeometry().getCoordinates();i.length===0&&(this.draw.coordinates=[]),this.draw.coordinates=i[0].map(r=>ln(r));break}this.interactionEnded()}startModifying(e){this.app.debug("startModifying()..."),this.draw.features.getLength()!==0&&(this.isModifying.set(!0),this.draw.name=void 0,this.draw.resourceType=e.type,this.draw.featureType=null,this.draw.forSave={id:null,coords:null},this.draw.coordinates=null,this.draw.properties={},this.interactionStarted())}stopModifying(){this.app.debug("stopModifying()..."),this.isModifying.set(!1),this.draw.features=null,this.interactionEnded()}startBoxSelection(e,t){this.app.debug("startBoxSelection()..."),this.selectionResult={mode:e,data:t,bbox:[]},this.isBoxSelecting.set(!0),this.interactionStarted()}stopBoxSelection(e){this.app.debug("stopBoxSelection()..."),e&&(this.selectionResult.bbox.push(e),this.formatBbox(),this.selection.update(()=>this.selectionResult)),this.isBoxSelecting.set(!1),this.interactionEnded()}formatBbox(){if(this.selectionResult.bbox.length!==2)return;let e=[].concat(this.selectionResult.bbox);this.selectionResult.bbox=[[e[0][0]<e[1][0]?e[0][0]:e[1][0],e[0][1]<e[1][1]?e[0][1]:e[1][1]],[e[0][0]>e[1][0]?e[0][0]:e[1][0],e[0][1]>e[1][1]?e[0][1]:e[1][1]]]}interactionStarted(){this.app.debug("interactionStarted()..."),this.clearUndo(),this.measurement.set({coords:[],index:-1,center:null,radius:0}),this.app.uiCtrl.update(e=>Object.assign({},e,{suppressContextMenu:!0}))}interactionEnded(){this.app.debug("interactionEnded()..."),this.clearUndo(),this.app.uiCtrl.update(e=>Object.assign({},e,{suppressContextMenu:!1})),this.measurement.set({coords:[],index:-1,center:null,radius:0})}static \u0275fac=function(t){return new(t||n)};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})};var vs=class{name;description;distance=0;feature;constructor(e){this.name=e?.name?e.name:"",this.description=e?.description?e.description:"",this.distance=e?.distance?e.distance:0,this.feature=e?.feature??{type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:{},id:""}}},Td=class{name;description;feature;type;constructor(e){this.name=e?.name?e.name:"",this.description=e?.description?e.description:"",this.type=e?.type?e.type:"",this.feature=e?.feature??{type:"Feature",geometry:{type:"Point",coordinates:[0,0]},properties:{},id:""}}},Ed=class{name;description;position;href;mimeType;url;group;authors;properties;constructor(e){this.name=e?.name??"",this.description=e?.description??"",this.position=e?.position,this.href=e?.href,this.mimeType=e?.mimeType??"",this.url=e?.url??"",this.group=e?.group,this.authors=e?.authors&&Array.isArray(e?.authors)?e.authors:[],this.properties=e?.properties&&typeof e?.properties=="object"?e.properties:{}}},Id=class{name;description;feature;constructor(e){this.name=e?.name?e.name:"",this.description=e?.description?e.description:"",this.feature=e?.feature??{type:"Feature",geometry:{type:"Polygon",coordinates:[]},properties:{},id:""}}},bs=class{identifier;name;description;region;scale=25e4;layers;bounds;format;minZoom=0;maxZoom=24;tileSize=256;type;url;source;style;defaultOpacity;imageAdjustment;displayMinZoom;proxy;constructor(e){let t=e;this.identifier=e?.identifier?e.identifier:void 0,this.name=e?.name?e.name:void 0,this.description=e?.description?e.description:void 0,this.layers=e?.layers?e.layers:[],this.bounds=e?.bounds?e.bounds:void 0,this.format=e?.format?e.format:void 0,this.minZoom=t?.minzoom??t?.minZoom??this.minZoom,this.maxZoom=t?.maxzoom??t?.maxZoom??this.maxZoom,this.tileSize=typeof e?.tileSize<"u"?e.tileSize:this.tileSize,this.type=e?.type?e.type:void 0,this.url=e?.url?e.url:void 0,this.scale=typeof e?.scale<"u"&&!isNaN(e?.scale)?e.scale:this.scale,this.style=e?.style??void 0,this.source=t?.$source??t?.source??void 0,this.defaultOpacity=e?.defaultOpacity??1,this.imageAdjustment=e?.imageAdjustment,this.displayMinZoom=e?.displayMinZoom,this.proxy=e?.proxy??!1}},Af=class{name;description;feature;constructor(e){this.feature=e?.feature??{type:"Feature",geometry:{type:"MultiLineString",coordinates:[]},properties:{},id:""},this.name=this.feature.properties?.name??"",this.description=this.feature.properties?.description??""}},DE=class{id;name;mmsi;position=[0,0];positionReceived=!1;positionTimestamp="";positionUpdatedAt=0;state;type={id:-1,name:""};properties={};lastUpdated=new Date;callsignVhf;callsignHf;orientation=0;virtual},Md=class extends DE{anchor={maxRadius:null,radius:null,position:null};autopilot={state:null,mode:null,target:null,enabled:!1,default:null,availableActions:[]};buddy=!1;closestApproach={distance:null,timeTo:null};cog;cogTrue=null;cogMagnetic=null;courseApi={arrivalCircle:0,activeRoute:{},nextPoint:{},previousPoint:{}};courseCalcs={};distanceToSelf;environment={mode:null,sun:null};heading;headingTrue=null;headingMagnetic=null;performance={beatAngle:null,gybeAngle:null};racing;radars={};registrations={};resourceUpdates=[];sog;track=[];vectors={cog:[]};wind={direction:null,mwd:null,twd:null,tws:null,speedTrue:null,sog:null,awa:null,aws:null};design={airHeight:null,beam:null,draft:{current:null,maximum:null},length:null};destination={name:null,eta:null};flag;port};function doe(n,e){if(n&1&&(u(0,"div",7)(1,"div",4),z(2,"span",13),wt(3,"coords"),z(4,"br")(5,"span",13),wt(6,"coords"),p(),u(7,"div"),z(8,"span",13),wt(9,"coords"),z(10,"br")(11,"span",13),wt(12,"coords"),p()()),n&2){let t=v();g(2),w("innerText",Oi(3,4,t.data.bbox[1][1],"HDd",!0)),g(3),w("innerText",Xn(6,8,t.data.bbox[1][0],"HDd")),g(3),w("innerText",Oi(9,11,t.data.bbox[0][1],"HDd",!0)),g(3),w("innerText",Xn(12,15,t.data.bbox[0][0],"HDd"))}}function uoe(n,e){if(n&1&&(u(0,"mat-option",10),_(1),p()),n&2){let t=e.$implicit;w("value",t),g(),q(t)}}var O2=class n{icon;zoomRange=[];selZoom;app=M(ae);dialogRef=M(di);data=M(ui);constructor(){}ngOnInit(){let e=this.data.chart[1].minZoom??1,t=this.data.chart[1].maxZoom??15;this.selZoom=t;for(let i=e;i<=t;i++)this.zoomRange.push(i)}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-chartproperties"]],decls:26,vars:3,consts:[[1,"_ap-chartjob"],[2,"background-color","transparent"],[1,"dialog-icon"],[2,"flex","1 1 auto","text-align","center"],[2,"text-align","right"],["mat-icon-button","",3,"click"],[2,"flex","1 1 auto"],[2,"flex","1 1 auto","border","gray 1px solid","font-size","10pt"],[2,"width","100%"],[3,"ngModelChange","ngModel"],[3,"value"],["align","right"],["mat-flat-button","",3,"click"],[2,"flex","1 1 auto",3,"innerText"]],template:function(t,i){t&1&&(u(0,"div",0)(1,"mat-toolbar",1)(2,"span",2)(3,"mat-icon"),_(4,"download"),p()(),u(5,"span",3),_(6,"Chart Seed job"),p(),u(7,"span",4)(8,"button",5),T("click",function(){return i.dialogRef.close(-1)}),u(9,"mat-icon"),_(10,"close"),p()()()(),u(11,"mat-dialog-content")(12,"div")(13,"div",6),_(14),p(),R(15,doe,13,18,"div",7),u(16,"div",6)(17,"mat-form-field",8)(18,"mat-label"),_(19,"Max. Zoom Level"),p(),u(20,"mat-select",9),bt("ngModelChange",function(o){return vt(i.selZoom,o)||(i.selZoom=o),o}),Le(21,uoe,2,2,"mat-option",10,gt),p()()()()(),u(23,"mat-dialog-actions",11)(24,"button",12),T("click",function(){return i.dialogRef.close(i.selZoom)}),_(25," Submit "),p()()()),t&2&&(g(14),q(i.data.chart[1].name),g(),A(i.data.bbox?15:-1),g(5),yt("ngModel",i.selZoom),g(),Ae(i.zoomRange))},dependencies:[be,le,ce,Ze,ue,Xe,Fe,Et,kt,pi,Si,_i,Ps,Ut,Wt,zl,Gl,St,Yi,Qi,dn],styles:["._ap-chartjob[_ngcontent-%COMP%]{font-family:arial;min-width:300px}.ap-confirm-icon[_ngcontent-%COMP%]{min-width:35px;max-width:35px;color:#ff8c00;text-align:left}._ap-chartjob[_ngcontent-%COMP%] .key-label[_ngcontent-%COMP%]{width:150px;font-weight:500}@media only screen and (min-device-width:768px)and (max-device-width:1024px),only screen and (min-width:800px){.ap-confirm-icon[_ngcontent-%COMP%]{min-width:25%;max-width:25%}}"]})};function poe(n,e){if(n&1&&(pn(0,"span",2),_(1),En()),n&2){let t=v();g(),$("(",t.subTitle(),")")}}function hoe(n,e){if(n&1&&(pn(0,"span",2),_(1),En()),n&2){let t=v();g(),$(" (",t.subTitle(),") ")}}var kE=".dial-text[_ngcontent-%COMP%]{padding:0 10px;height:96px;font-family:roboto;border:transparent 1px solid}.dial-text-title[_ngcontent-%COMP%]{font-size:12pt;font-weight:500}.dial-text-subtitle[_ngcontent-%COMP%]{font-size:8pt;font-weight:500}.dial-text-value[_ngcontent-%COMP%]{font-size:22pt;font-weight:500}.dial-text-units[_ngcontent-%COMP%]{font-size:10pt}";function moe(n,e){if(n&1&&(pn(0,"span",2),_(1),En()),n&2){let t=v();g(),$(" (",t.subTitle(),") ")}}var LN=class n{title=Z();subTitle=Z();value=Z();units=Z();static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-dial-text"]],inputs:{title:[1,"title"],subTitle:[1,"subTitle"],value:[1,"value"],units:[1,"units"]},decls:8,vars:4,consts:[[1,"dial-text","mat-app-background"],[1,"dial-text-title"],[1,"dial-text-subtitle"],[1,"dial-text-value"],[1,"dial-text-units"]],template:function(t,i){t&1&&(pn(0,"div",0)(1,"div",1),_(2),R(3,poe,2,1,"span",2),En(),pn(4,"div",3),_(5),En(),pn(6,"div",4),_(7),En()()),t&2&&(g(2),$(" ",i.title(),"\xA0 "),g(),A(i.subTitle()?3:-1),g(2),q(i.value()),g(2),q(i.units()))},styles:[kE],changeDetection:0})},AN=class n{value=Z();subTitle=Z();ttg="--";units="min";constructor(){Me(()=>{let e=this.value();if(typeof e!="number")this.ttg="--",this.units="min";else if(e<60)this.ttg=Math.floor(e).toString(),this.units="min";else if(e<1440)this.ttg=`${Math.floor(e/60)}:${("00"+(e%60).toFixed(0)).slice(-2)}`,this.units="hr:min";else{let i=Math.floor(e/1440),r=i*1440,o=e-r,a=Math.floor(o/60),s=`00${Math.floor(o-a*60)}`.slice(-2);this.ttg=`${i}:${("00"+a).slice(-2)}:${s}`,this.units="day:hr:min"}})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-dial-ttg"]],inputs:{value:[1,"value"],subTitle:[1,"subTitle"]},decls:8,vars:3,consts:[[1,"dial-text","mat-app-background"],[1,"dial-text-title"],[1,"dial-text-subtitle"],[1,"dial-text-value"],[1,"dial-text-units"]],template:function(t,i){t&1&&(pn(0,"div",0)(1,"div",1),_(2," TTG\xA0 "),R(3,hoe,2,1,"span",2),En(),pn(4,"div",3),_(5),En(),pn(6,"div",4),_(7),En()()),t&2&&(g(3),A(i.subTitle()?3:-1),g(2),q(i.ttg),g(2),q(i.units))},styles:[kE],changeDetection:0})},ON=class n{value=Z();subTitle=Z();etaTime="--";etaDate="--";constructor(){Me(()=>{this.value()&&(this.etaTime=this.value().toLocaleTimeString().split(":").slice(0,2).join(":"),this.etaDate=this.value().toLocaleDateString())})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-dial-eta"]],inputs:{value:[1,"value"],subTitle:[1,"subTitle"]},decls:8,vars:3,consts:[[1,"dial-text","mat-app-background"],[1,"dial-text-title"],[1,"dial-text-subtitle"],[1,"dial-text-value"],[1,"dial-text-units"]],template:function(t,i){t&1&&(pn(0,"div",0)(1,"div",1),_(2," ETA\xA0 "),R(3,moe,2,1,"span",2),En(),pn(4,"div",3),_(5),En(),pn(6,"div",4),_(7),En()()),t&2&&(g(3),A(i.subTitle()?3:-1),g(2),q(i.etaTime),g(2),q(i.etaDate))},styles:[kE],changeDetection:0})};var foe=["*"],goe=n=>({disabled:n});function _oe(n,e){if(n&1&&(u(0,"span")(1,"i",6),_(2,"upload"),p(),_(3," \xA0"),u(4,"span",7),_(5),p()()),n&2){let t=v();g(5),q(t.label())}}function yoe(n,e){if(n&1){let t=H();u(0,"button",9),T("click",function(){O(t);let r=v(2);return F(r.clear())}),_(1,"Clear"),p()}}function voe(n,e){if(n&1&&(u(0,"div",5),z(1,"img",8),R(2,yoe,2,0,"button"),p()),n&2){let t=v();g(),st("src",t.avatar,Mc),g(),A(t.avatar?2:-1)}}var FN=class n{disabled=Z(!1);multiple=Z(!1);maxfilesize=Z(void 0);accept=Z("");astext=Z(!1);preview=Z(!1);icon=Z(!1);label=Z("Upload File");chosen=we();invalid=we();cleared=we();avatar=null;changeDetectorRef=M(re);constructor(){}fileChange(e){this.readFiles(e.files)}dragOver(e){e.preventDefault()}drop(e){e.preventDefault(),e.dataTransfer.files&&e.dataTransfer.files.length>0&&this.readFiles(e.dataTransfer.files)}clear(){this.avatar=null,this.cleared.emit()}readFiles(e,t=0){let i=new FileReader,r={type:"",value:"",message:""};if(t in e){if(this.maxfilesize()&&e[t].size>this.maxfilesize()){r.type="SIZE",r.value=e[t].size,r.message=`File size exceeds the accepted maximum size of ${this.maxfilesize()}`,this.invalid.emit(r);return}if(this.accept().indexOf("/*")!==-1){let o=e[t].type.substring(0,e[t].type.indexOf("/"));if(this.accept().indexOf(o)<0){r.type="TYPE",r.value=e[t].type,r.message=`File type does not match the accepted type (${this.accept()}) specified.`,this.invalid.emit(r);return}}this.readFile(e[t],i,o=>{t===0&&this.preview()&&(this.avatar=o),this.chosen.emit({name:e[t].name,data:o}),this.readFiles(e,t+1)})}else this.changeDetectorRef.detectChanges()}readFile(e,t,i){t.onload=()=>{i(t.result)},e.type.indexOf("text")!==-1||this.astext()?t.readAsText(e):t.readAsDataURL(e)}resize(e,t,i,r){return e.onload=()=>{let o=e.width,a=e.height;o>a?o>t&&(a*=t/o,o=t):a>i&&(o*=i/a,a=i);let s=document.createElement("canvas");s.width=o,s.height=a,s.getContext("2d").drawImage(e,0,0,o,a);let c=s.toDataURL("image/jpeg");r(c,e.src.length,c.length)}}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-file-input"]],inputs:{disabled:[1,"disabled"],multiple:[1,"multiple"],maxfilesize:[1,"maxfilesize"],accept:[1,"accept"],astext:[1,"astext"],preview:[1,"preview"],icon:[1,"icon"],label:[1,"label"]},outputs:{chosen:"chosen",invalid:"invalid",cleared:"cleared"},ngContentSelectors:foe,decls:8,vars:8,consts:[["input",""],[1,"ap-file-input",3,"dragover","drop"],["id","ctrl",3,"ngClass"],["mat-menu-item",""],["type","file",2,"display","none",3,"change","click","multiple","disabled","accept"],["id","avatar",2,"display","inline-flex"],[1,"material-icons"],[2,"font-size","10pt"],["alt",""],[3,"click"]],template:function(t,i){if(t&1){let r=H();fe(),u(0,"div",1),T("dragover",function(a){return i.dragOver(a)})("drop",function(a){return i.drop(a)}),u(1,"div",2)(2,"label",3),de(3),R(4,_oe,6,1,"span"),u(5,"input",4,0),T("change",function(){O(r);let a=Oe(6);return F(i.fileChange(a))})("click",function(){O(r);let a=Oe(6);return F(a.value=null)}),p()()(),R(7,voe,3,2,"div",5),p()}t&2&&(g(),w("ngClass",an(6,goe,i.disabled())),g(3),A(i.icon()?4:-1),g(),w("multiple",i.multiple())("disabled",i.disabled())("accept",i.accept()),g(2),A(i.preview()&&i.avatar?7:-1))},dependencies:[hn,Ln],styles:[".ap-file-input[_ngcontent-%COMP%]{display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:inline-flex;-moz-flex-direction:row;-ms-flex-direction:row;-webkit-flex-direction:row;flex-direction:row;flex-wrap:nowrap;justify-content:flex-start;align-content:stretch;width:100%}#ctrl[_ngcontent-%COMP%], #ctrl[_ngcontent-%COMP%] label[_ngcontent-%COMP%]{cursor:pointer}#apfileinput[_ngcontent-%COMP%]{position:absolute;top:0;left:-9000px;width:.1px;height:.1px;opacity:0;overflow:hidden;z-index:-1}.disabled[_ngcontent-%COMP%]{color:#21212180!important;border-color:#21212180!important;cursor:none!important}#avatar[_ngcontent-%COMP%]{background-color:inherit;border-radius:5px;height:42px}#avatar[_ngcontent-%COMP%] > img[_ngcontent-%COMP%]{width:42px;height:42px}#avatar[_ngcontent-%COMP%] > button[_ngcontent-%COMP%]{background-color:inherit;border:0;color:red}"]})};var boe=["vid"],NN=class n{pipVideo;pipWindow;pipMode=!1;vidUrl;src=Z();muted=Z(!0);_muted=Ta(()=>this.muted());resize=we();change=we();click=we();vid;constructor(){Me(()=>{this.src()&&(this.vidUrl=this.src())})}ngOnInit(){"pictureInPictureEnabled"in document||(this.pipMode=!0),this.pipVideo=this.vid.nativeElement,this.pipVideo.addEventListener("enterpictureinpicture",e=>{this.pipMode=!0,this.pipWindow=e.pictureInPictureWindow,this.pipWindow.addEventListener("resize",this.onPipWindowResize.bind(this)),this.change.emit(this.pipMode)}),this.pipVideo.addEventListener("leavepictureinpicture",()=>{this.pipMode=!1,this.pipVideo.pause(),this.pipWindow.removeEventListener("resize",this.onPipWindowResize),this.change.emit(this.pipMode)})}onPipWindowResize(e){this.resize.emit([e.srcElement.width,e.srcElement.height])}toggleMute(){this._muted.update(e=>!e)}initPiP(){return J(this,null,function*(){try{yield this.pipVideo.requestPictureInPicture(),this.pipMode=!0,this.vid.nativeElement.play(),this.click.emit(!0)}catch(e){this.pipMode=!1}})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["pip-video"]],viewQuery:function(t,i){if(t&1&&$t(boe,7),t&2){let r;De(r=ke())&&(i.vid=r.first)}},inputs:{src:[1,"src"],muted:[1,"muted"]},outputs:{resize:"resize",change:"change",click:"click"},decls:7,vars:5,consts:[["vid",""],[2,"border","gray 1px solid","border-radius","5px","display","none"],["autoplay","",3,"src","muted"],[2,"padding-left","5px"],["mat-mini-fab","","matTooltip","Show Video","matTooltipPosition","left",1,"button-toolbar",3,"click","disabled"]],template:function(t,i){t&1&&(u(0,"div",1),z(1,"video",2,0),p(),u(3,"div",3)(4,"button",4),T("click",function(){return i.initPiP()}),u(5,"mat-icon"),_(6,"videocam"),p()()()),t&2&&(g(),w("src",i.vidUrl,Mc)("muted",i._muted()),g(3),Nt("display",i.src()?"block":"none"),w("disabled",i.pipMode))},dependencies:[ue,Es,be,Pe,le,ce],encapsulation:2})};var BN=Ma(Os());function xoe(n,e){if(n&1&&_(0),n&2){let t=v(3);$(" \xB7 ",t.legBearing," ")}}function Coe(n,e){if(n&1&&(u(0,"div",2)(1,"div",3),_(2,"Leg:"),p(),u(3,"div",4),_(4),R(5,xoe,1,1),p()()),n&2){let t=v(2);g(4),$(" ",t.coords().length<2?"--":t.legDistance," "),g(),A(t.coords().length>=2&&t.legBearing!=="--"?5:-1)}}function woe(n,e){if(n&1&&(u(0,"div",0)(1,"div",2)(2,"div",3),_(3,"Distance:"),p(),u(4,"div",4),_(5),p()(),R(6,Coe,6,2,"div",2),p()),n&2){let t=v();g(5),q(t.totalDistance),g(),A(t.totalOnly()?-1:6)}}function Moe(n,e){if(n&1&&(u(0,"div",5)(1,"div",5)(2,"div",9)(3,"mat-icon"),_(4,"square_foot"),p(),z(5,"br"),_(6),p(),u(7,"div",7),_(8),z(9,"br"),_(10),p()()()),n&2){let t=v(2);g(6),$(" ",t.coords().length<2?"-":t._index()===-1?t.coords().length-1:t._index()+1," "),g(2),$(" ",t.legDistance),g(2),$(" ",t.legBearing," ")}}function Soe(n,e){if(n&1){let t=H();u(0,"div",1)(1,"mat-toolbar")(2,"div",5)(3,"div",5)(4,"div",6)(5,"mat-icon"),_(6,"straighten"),p()(),u(7,"div",7),_(8),z(9,"br"),p()(),R(10,Moe,11,3,"div",5),u(11,"div")(12,"button",8),T("click",function(){O(t);let r=v();return F(r.close())}),u(13,"mat-icon"),_(14,"close"),p()()()()()()}if(n&2){let t=v();g(8),q(t.totalDistance),g(2),A(t.totalOnly()?-1:10)}}var N2=class n{coords=Z([]);index=Z(-1);_index=Ta(()=>this.index());totalOnly=Z(!1);card=Z(!1);cancel=we();totalDistance;legDistance;legBearing;btnDisable={prev:!1,next:!1};app=M(ae);constructor(){Me(()=>{if(!this.coords()||!Array.isArray(this.coords())||this.coords().length===0){this.init();return}if(this._index())if(Number.isFinite(this._index())){if(this._index()<-1&&this._index()>=this.coords().length)return}else return;this.calc(),this.setButtonState()}),this.init()}init(e){e||(this.totalDistance="--"),this.legDistance="--",this.legBearing="--",this.btnDisable={prev:!0,next:!0}}close(){this.cancel.emit()}calc(){let e=oi.routeLength(this.coords());this.totalDistance=this.app.formatValueForDisplay(e,"m");let t;if(this._index()===-1)t=this.coords().slice(-2);else{let i=this._index()===this.coords().length-2?void 0:this._index()+2;t=this.coords().slice(this._index(),i)}if(t.length<2)this.init(!0);else{let i=oi.distanceTo(t[0],t[1]),r=(0,BN.getGreatCircleBearing)(t[0],t[1]);this.legDistance=this.app.formatValueForDisplay(i,"m"),this.legBearing=this.app.formatValueForDisplay(r,"deg")}}select(e){e?this._index()===-1?this.coords().length>2&&this._index.set(this.coords().length-3):this._index()>0&&this._index.update(t=>--t):(this._index()!==-1||this._index()<this.coords().length-2)&&this._index.update(t=>++t),this.setButtonState(),this.calc()}setButtonState(){this._index()>0||this._index()===-1&&this.coords().length>2?this.btnDisable.prev=!1:this.btnDisable.prev=!0,this._index()!==-1&&this._index()<this.coords().length-2?this.btnDisable.next=!1:this.btnDisable.next=!0}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["fb-measurements"]],inputs:{coords:[1,"coords"],index:[1,"index"],totalOnly:[1,"totalOnly"],card:[1,"card"]},outputs:{cancel:"cancel"},decls:2,vars:1,consts:[[1,"_ap_measurements_card"],[1,"_ap_measurements"],[1,"_ap_prop"],[1,"_ap_prop_key"],[1,"_ap_prop_val"],[1,"_ap_row"],[1,"icon-label"],[1,"value"],["matTooltip","Cancel","matTooltipPosition","below","mat-icon-button","",3,"click"],[2,"font-size","12pt"]],template:function(t,i){t&1&&R(0,woe,7,2,"div",0)(1,Soe,15,2,"div",1),t&2&&A(i.card()?0:1)},dependencies:[le,ce,ue,Fe,Pe,Et,kt],styles:["._ap_measurements[_ngcontent-%COMP%]{position:relative;top:0;min-width:200px}._ap_prop[_ngcontent-%COMP%]{display:flex;margin:2px 0}._ap_prop_key[_ngcontent-%COMP%]{font-weight:700}._ap_prop_val[_ngcontent-%COMP%]{flex:1 1 auto;text-align:right;white-space:nowrap}._ap_row[_ngcontent-%COMP%]{display:flex;flex-wrap:no-wrap;flex:2}._ap_row[_ngcontent-%COMP%] .icon-label[_ngcontent-%COMP%]{width:30px}._ap_row[_ngcontent-%COMP%] .row-label[_ngcontent-%COMP%]{font-weight:500;min-width:60px}._ap_measurements[_ngcontent-%COMP%] .value[_ngcontent-%COMP%]{padding-right:10px}@media only screen and (max-width:500px){._ap_measurements[_ngcontent-%COMP%]{left:0;width:100%}}"],changeDetection:0})};function Toe(n,e){if(n&1){let t=H();pn(0,"img",1),Z_("error",function(){O(t);let r=v();return F(r.imgError())}),En()}if(n&2){let t=v();Mo("src",t.flagIcon,Mc)}}var B2=class n{flagIcon;showFlag=X(!0);mmsi=Z();host=Z("");constructor(){Me(()=>{this.flagIcon=`${this.host()}/signalk/v2/api/resources/flags/mmsi/${this.mmsi()}`})}imgError(){this.showFlag.set(!1)}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["country-flag"]],inputs:{mmsi:[1,"mmsi"],host:[1,"host"]},decls:1,vars:1,consts:[[3,"src"],[3,"error","src"]],template:function(t,i){t&1&&R(0,Toe,1,1,"img",0),t&2&&A(i.showFlag()?0:-1)},encapsulation:2})};var V2=class n{notiMgr=M(nl);constructor(){}raiseAlarm(){this.notiMgr.raiseServerAlarm("mob","Person Overboard!")}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["pob-button"]],decls:2,vars:0,consts:[["mat-fab","","matTooltip","Raise POB Alarm","matTooltipPosition","above",1,"button-warn",3,"click"],["svgIcon","alarm-mob",1,"ob"]],template:function(t,i){t&1&&(u(0,"button",0),T("click",function(){return i.raiseAlarm()}),z(1,"mat-icon",1),p())},dependencies:[le,ce,ue,Ad,be,Pe],encapsulation:2})};var G2=class n{position=Z([0,0]);active=Z(!1);skres=M(Pt);constructor(){}dropWaypoint(){this.skres.newWaypointAt(this.position())}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["wpt-button"]],inputs:{position:[1,"position"],active:[1,"active"]},decls:3,vars:1,consts:[["mat-fab","","matTooltip","Mark Vessel Position","matTooltipPosition","above",1,"button-toolbar",3,"click","disabled"]],template:function(t,i){t&1&&(u(0,"button",0),T("click",function(){return i.dropWaypoint()}),u(1,"mat-icon"),_(2,"add_location"),p()()),t&2&&w("disabled",!i.active())},dependencies:[le,ce,ue,Ad,be,Pe],encapsulation:2})};var Eoe=(n,e)=>({"button-primary":n,"button-toolbar":e}),z2=class n{active=Z(!1);app=M(ae);constructor(){}handleClick(){this.app.uiCtrl.update(e=>{let t=!e.autopilotConsole;return Object.assign({},e,{autopilotConsole:t})})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["autopilot-button"]],inputs:{active:[1,"active"]},decls:2,vars:5,consts:[["mat-fab","","matTooltip","Autopilot Console","matTooltipPosition","above",3,"click","ngClass","disabled"],["svgIcon","command-autopilot",1,"ob"]],template:function(t,i){t&1&&(u(0,"button",0),T("click",function(){return i.handleClick()}),z(1,"mat-icon",1),p()),t&2&&w("ngClass",cl(2,Eoe,i.app.data.vessels.self.autopilot.enabled,!i.app.data.vessels.self.autopilot.enabled||!i.app.featureFlags().autopilotApi||!i.app.data.vessels.self.autopilot.default))("disabled",!i.active())},dependencies:[hn,Ln,le,ce,ue,Ad,be,Pe],encapsulation:2})};var Ioe=(n,e)=>({"button-primary":n,"button-toolbar":e}),j2=class n{active=Z(!1);app=M(ae);radarApi=M(gc);constructor(){}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["radar-button"]],inputs:{active:[1,"active"]},decls:2,vars:5,consts:[["mat-fab","","matTooltip","Radar Overlay","matTooltipPosition","above",3,"ngClass","disabled"],["svgIcon","radar-iec",1,"ob"]],template:function(t,i){t&1&&(u(0,"button",0),z(1,"mat-icon",1),p()),t&2&&w("ngClass",cl(2,Ioe,i.radarApi.radarId()&&i.app.uiCtrl().radarLayer,!i.app.featureFlags().radarApi||!i.app.uiCtrl().radarLayer))("disabled",!i.active()||!i.app.data.vessels.showSelf||i.app.instrumentPanel().open)},dependencies:[hn,Ln,le,ce,ue,Ad,be,Pe],encapsulation:2})};var Fo=[];for(let n=0;n<256;++n)Fo.push((n+256).toString(16).slice(1));function VN(n,e=0){return(Fo[n[e+0]]+Fo[n[e+1]]+Fo[n[e+2]]+Fo[n[e+3]]+"-"+Fo[n[e+4]]+Fo[n[e+5]]+"-"+Fo[n[e+6]]+Fo[n[e+7]]+"-"+Fo[n[e+8]]+Fo[n[e+9]]+"-"+Fo[n[e+10]]+Fo[n[e+11]]+Fo[n[e+12]]+Fo[n[e+13]]+Fo[n[e+14]]+Fo[n[e+15]]).toLowerCase()}var Doe=new Uint8Array(16);function PE(){return crypto.getRandomValues(Doe)}function koe(n,e,t){return!e&&!n&&crypto.randomUUID?crypto.randomUUID():Poe(n,e,t)}function Poe(n,e,t){n=n||{};let i=n.random??n.rng?.()??PE();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){if(t=t||0,t<0||t+16>e.length)throw new RangeError(`UUID byte range ${t}:${t+15} is out of buffer bounds`);for(let r=0;r<16;++r)e[t+r]=i[r];return e}return VN(i)}var RE=koe;var LE="plotterExt/1",Ki={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,HOST_ERROR:-32e3,TIMEOUT:-32001,CONNECTION_CLOSED:-32002},si=class F_ extends Error{code;data;constructor(e,t={}){super(e),this.name="RpcError",this.code=t.code??Ki.HOST_ERROR;let i=se({},t.data??{});t.reason!==void 0&&(i.reason=t.reason),this.data=Object.keys(i).length>0?i:void 0}get reason(){return typeof this.data?.reason=="string"?this.data.reason:void 0}toErrorObject(){return se({code:this.code,message:this.message},this.data?{data:this.data}:{})}static fromErrorObject(e){return new F_(e.message,{code:e.code,data:e.data})}static from(e){return e instanceof F_?e:e instanceof Error?new F_(e.message,{code:Ki.INTERNAL_ERROR}):new F_(String(e),{code:Ki.INTERNAL_ERROR})}},AE="bus.ready",OE="bus.handshake";function GN(n,e){return n===e?!0:zN(n.split("."),0,e.split("."),0)}function zN(n,e,t,i){for(;e<n.length;){let r=n[e];if(r==="**"){if(e===n.length-1)return!0;for(let o=i;o<=t.length;o++)if(zN(n,e+1,t,o))return!0;return!1}if(i>=t.length||r!=="*"&&r!==t[i])return!1;e++,i++}return i===t.length}function W2(n,e){for(let t of n)if(GN(t,e))return!0;return!1}function Loe(n){return{bus:LE,msg:n}}function Aoe(n){if(typeof n!="object"||n===null)return null;let e=n;return e.bus!==LE?null:Ooe(e.msg)?e.msg:null}function Ooe(n){if(typeof n!="object"||n===null)return!1;let e=n;if(e.jsonrpc!=="2.0")return!1;if(typeof e.method=="string")return e.id===void 0||typeof e.id=="string"||typeof e.id=="number";if(!(typeof e.id=="string"||typeof e.id=="number"||e.id===null))return!1;let i="result"in e,r=e.error,o=typeof r=="object"&&r!==null&&typeof r.code=="number"&&typeof r.message=="string";return i?!("error"in e):o}function Foe(n){return"method"in n&&"id"in n&&n.id!==void 0}function Noe(n){return"method"in n&&(!("id"in n)||n.id===void 0)}function Boe(n){return!("method"in n)}function Of(n,e={}){let t=e.listenWindow??globalThis,i=e.origin??t.location?.origin??"*";return{post(r){n.postMessage(r,i)},listen(r){let o=a=>{a.source===n&&(i!=="*"&&a.origin!==i||r(a.data))};return t.addEventListener("message",o),()=>t.removeEventListener("message",o)}}}var Voe=1e4,FE=class{callTimeoutMs;port;unlisten;onError;pending=new Map;methods=new Map;eventHandlers=new Set;idPrefix=Math.random().toString(36).slice(2,8);seq=0;closed=!1;constructor(n){this.port=n.port,this.callTimeoutMs=n.callTimeoutMs??Voe,this.onError=n.onError??(e=>console.warn("[plotterext-bus]",e)),this.unlisten=this.port.listen(e=>this.onData(e))}registerMethod(n,e){this.methods.set(n,e)}unregisterMethod(n){this.methods.delete(n)}onEvent(n,e){let t={patterns:n,fn:e};return this.eventHandlers.add(t),()=>this.eventHandlers.delete(t)}notify(n,e){this.send(se({jsonrpc:"2.0",method:n},e!==void 0?{params:e}:{}))}call(n,e,t={}){if(this.closed)return Promise.reject(new si("Bus endpoint is closed",{code:Ki.CONNECTION_CLOSED,reason:"CLOSED"}));let i=`${this.idPrefix}-${++this.seq}`,r=t.timeoutMs??this.callTimeoutMs;return new Promise((o,a)=>{let s=r>0?setTimeout(()=>{this.pending.delete(i),a(new si(`Call timed out after ${r}ms: ${n}`,{code:Ki.TIMEOUT,reason:"TIMEOUT"}))},r):null;this.pending.set(i,{resolve:o,reject:a,timer:s}),this.send(se({jsonrpc:"2.0",id:i,method:n},e!==void 0?{params:e}:{}))})}close(){if(!this.closed){this.closed=!0,this.unlisten();for(let[,n]of this.pending)n.timer&&clearTimeout(n.timer),n.reject(new si("Bus endpoint closed",{code:Ki.CONNECTION_CLOSED,reason:"CLOSED"}));this.pending.clear(),this.eventHandlers.clear()}}send(n){this.closed||this.port.post(Loe(n))}onData(n){let e=Aoe(n);e&&(Boe(e)?this.onResponse(e):Foe(e)?this.onRequest(e):Noe(e)&&this.onNotification(e.method,e.params))}onResponse(n){if(n.id===null)return;let e=this.pending.get(n.id);e&&(this.pending.delete(n.id),e.timer&&clearTimeout(e.timer),"error"in n?e.reject(si.fromErrorObject(n.error)):e.resolve(n.result))}onRequest(n){return J(this,null,function*(){let e=this.methods.get(n.method);if(!e){this.send({jsonrpc:"2.0",id:n.id,error:{code:Ki.METHOD_NOT_FOUND,message:`Method not found: ${n.method}`}});return}try{let t=yield e(n.params,{endpoint:this});this.send({jsonrpc:"2.0",id:n.id,result:t===void 0?null:t})}catch(t){this.send({jsonrpc:"2.0",id:n.id,error:si.from(t).toErrorObject()})}})}onNotification(n,e){for(let t of[...this.eventHandlers])if(W2(t.patterns,n))try{t.fn(n,e)}catch(i){this.onError(i)}}};var Ff=class{endpoint;context;hostInfo;subs=new Map;onSubscriptionsChanged;adoptCallerId;subSeq=0;constructor(n){this.hostInfo=n.hostInfo,this.context=n.context,this.onSubscriptionsChanged=n.onSubscriptionsChanged,this.adoptCallerId=n.adoptCallerId??!1,this.endpoint=new FE({port:n.port,callTimeoutMs:n.callTimeoutMs,onError:n.onError});for(let[e,t]of Object.entries(n.methods??{}))this.endpoint.registerMethod(e,t);this.endpoint.registerMethod("events.subscribe",e=>this.handleSubscribe(e)),this.endpoint.registerMethod("events.unsubscribe",e=>this.handleUnsubscribe(e)),this.endpoint.onEvent([AE],(e,t)=>this.sendHandshake(t))}registerMethod(n,e){this.endpoint.registerMethod(n,e)}publish(n,e){return this.hasSubscriber(n)?(this.endpoint.notify(n,e),!0):!1}hasSubscriber(n){for(let[,e]of this.subs)if(W2(e,n))return!0;return!1}subscribedPatterns(){let n=new Set;for(let[,e]of this.subs)for(let t of e)n.add(t);return[...n]}close(){this.endpoint.close(),this.subs.clear()}sendHandshake(n){let e=this.adoptCallerId&&n?.id?ri(se({},this.context),{id:n.id}):this.context;this.endpoint.notify(OE,ri(se({},this.hostInfo),{context:e}))}handleSubscribe(n){let e=n?.patterns;if(!Array.isArray(e)||e.length===0||!e.every(i=>typeof i=="string"&&i.length>0))throw new si("events.subscribe requires a non-empty patterns array",{code:Ki.INVALID_PARAMS,reason:"INVALID_PATTERNS"});let t=`sub-${++this.subSeq}`;return this.subs.set(t,e),this.onSubscriptionsChanged?.(this.subscribedPatterns()),{subscriptionId:t}}handleUnsubscribe(n){let e=n?.subscriptionId;if(typeof e!="string"||!this.subs.has(e))throw new si("Unknown subscriptionId",{code:Ki.INVALID_PARAMS,reason:"UNKNOWN_SUBSCRIPTION"});return this.subs.delete(e),this.onSubscriptionsChanged?.(this.subscribedPatterns()),{}}};function jN(n,e={}){let t=s=>{let l=s?.routeId;if(typeof l!="string"||l.length===0)throw new si("route method requires a routeId",{code:Ki.INVALID_PARAMS,reason:"routes.badRequest"});return l},i=()=>new si("Unknown route buffer",{reason:"routes.unknownId"}),r=s=>new si(s,{code:Ki.INVALID_PARAMS,reason:"routes.badRequest"}),o=(s,l)=>{if(s!==void 0&&typeof s!="string")throw r(`${l} must be a string`)},a=s=>{if(!Array.isArray(s)||s.length<2)throw r("a route needs at least two points");for(let l of s){let c=l?.position;if(!Array.isArray(c)||c.length<2||!Number.isFinite(c[0])||!Number.isFinite(c[1]))throw r("each route point needs a numeric [lon, lat] position");o(l.name,"point name"),o(l.description,"point description")}return s};return{"route.list":()=>({routes:n.list()}),"route.create":s=>{let{name:l,description:c,points:d}=s??{};o(l,"name"),o(c,"description");let h=a(d),m=n.create({name:l,description:c,points:h});return{routeId:m.routeId,rev:m.rev}},"route.replace":s=>{let l=t(s),{points:c}=s??{},d=a(c),h=n.replace(l,d);if(!h)throw i();return{rev:h.rev}},"route.save":s=>J(null,null,function*(){let l=t(s);if(!n.has(l))throw i();if(!e.onSave)throw new si("This host cannot persist routes",{reason:"routes.notSupported"});let{name:c,description:d,dialog:h}=s??{};if(o(c,"name"),o(d,"description"),h!==void 0&&typeof h!="boolean")throw r("dialog must be a boolean");let m=yield e.onSave(l,{name:c,description:d,dialog:h});if(!m)throw new si("Route save was cancelled",{reason:"routes.saveCancelled"});return m}),"route.get":s=>{let l=n.get(t(s));if(!l)throw i();return l},"route.hide":s=>J(null,null,function*(){let l=t(s);if(!n.has(l))throw i();return e.onHide?yield e.onHide(l):n.delete(l),{}}),"route.delete":s=>J(null,null,function*(){let l=t(s);if(!n.has(l))throw i();return e.onDelete?yield e.onDelete(l):n.delete(l,!1),{}}),"route.show":s=>{let l=s?.ref;if(typeof l!="string"||l.length===0)throw new si("route.show requires a ref",{code:Ki.INVALID_PARAMS,reason:"routes.badRef"});if(!e.onShow)throw new si("route.show is not supported by this host",{reason:"routes.notSupported"});return e.onShow(l)}}}function Goe(n){let[e,t,i]=n,r={id:e,name:t?.name??e,visible:!!i,opacity:typeof t?.defaultOpacity=="number"?t.defaultOpacity:1};return t?.type&&(r.type=t.type),Array.isArray(t?.bounds)&&t.bounds.length===4&&(r.bounds=[t.bounds[0],t.bounds[1],t.bounds[2],t.bounds[3]]),typeof t?.minZoom=="number"&&(r.minZoom=t.minZoom),typeof t?.maxZoom=="number"&&(r.maxZoom=t.maxZoom),r}function WN(n){let e=r=>new si(r,{code:Ki.INVALID_PARAMS,reason:"charts.badRequest"}),t=(r,o)=>{if(!Array.isArray(r)||r.some(a=>typeof a!="string"||a.length===0))throw e(`${o} must be an array of chart ids`);return r},i=(r,o)=>{let a=new Set(o.map(l=>l[0])),s=r.find(l=>!a.has(l));if(s!==void 0)throw new si(`Unknown chart id: ${s}`,{reason:"charts.unknownId"})};return{"chart.list":()=>J(null,null,function*(){return{charts:(yield n.listAvailableOrdered()).map(Goe)}}),"chart.setVisibility":r=>J(null,null,function*(){let o=t(r?.ids,"ids"),a=r?.visible;if(typeof a!="boolean")throw e("visible must be a boolean");return o.length>0&&(i(o,yield n.listAvailableOrdered()),yield n.setVisibility(o,a)),{}}),"chart.setOpacity":r=>J(null,null,function*(){let o=t(r?.ids,"ids"),a=r?.opacity;if(typeof a!="number"||!Number.isFinite(a))throw e("opacity must be a finite number");if(a<0||a>1)throw e("opacity must be between 0 and 1");return o.length>0&&(i(o,yield n.listAvailableOrdered()),yield n.setOpacity(o,a)),{}}),"chart.setOrder":r=>J(null,null,function*(){let o=t(r?.order,"order");return o.length>0&&(i(o,yield n.listAvailableOrdered()),yield n.setOrder(o)),{}})}}function UN(n){let e=t=>new si(t,{code:Ki.INVALID_PARAMS,reason:"nightMode.badRequest"});return{"nightMode.get":()=>J(null,null,function*(){return n.getState()}),"nightMode.set":t=>J(null,null,function*(){let i=t??{},r=i.enabled!==void 0,o=i.auto!==void 0;if(!r&&!o)throw e("nightMode.set requires enabled and/or auto");if(r&&typeof i.enabled!="boolean")throw e("enabled must be a boolean");if(o&&typeof i.auto!="boolean")throw e("auto must be a boolean");let a={};return o&&(a.auto=i.auto),r&&(a.enabled=i.enabled),yield n.setState(a),{}})}}var yc=class n{buffers=new Map;events=new ze;events$=this.events.asObservable();liveSignal=X([]);live=this.liveSignal.asReadonly();create(e={}){let t=this.newRouteId(),i={routeId:t,name:e.name??null,description:e.description??null,rev:1,saved:!1,dirty:!0,points:(e.points??[]).map(r=>this.clonePoint(r))};return this.buffers.set(t,i),this.refreshLive(),this.events.next({type:"visible",routeId:t,rev:i.rev,name:i.name,pointCount:i.points.length,saved:i.saved,dirty:i.dirty}),this.snapshot(i)}show(e){let t=this.buffers.get(e.routeId),i={routeId:e.routeId,name:e.name??t?.name??null,description:e.description??t?.description??null,rev:t?t.rev+1:1,saved:!0,dirty:!1,href:e.href,points:(e.points??t?.points??[]).map(r=>this.clonePoint(r))};return this.buffers.set(e.routeId,i),this.refreshLive(),this.events.next({type:"visible",routeId:i.routeId,rev:i.rev,name:i.name,pointCount:i.points.length,saved:!0,dirty:!1}),this.snapshot(i)}get(e){let t=this.buffers.get(e);return t?this.snapshot(t):void 0}has(e){return this.buffers.has(e)}hasHref(e){return this.getByHref(e)!==void 0}getByHref(e){for(let t of this.buffers.values())if(t.href===e)return this.snapshot(t)}all(){return[...this.buffers.values()].map(e=>this.snapshot(e))}list(){return[...this.buffers.values()].map(e=>({routeId:e.routeId,name:e.name,rev:e.rev,pointCount:e.points.length,saved:e.saved,dirty:e.dirty}))}delete(e,t){let i=this.buffers.get(e);if(!i)return!1;i.rev+=1;let r=t??i.saved;return this.buffers.delete(e),this.refreshLive(),this.events.next({type:"hidden",routeId:e,rev:i.rev,saved:r}),!0}markSaved(e,t,i,r){let o=this.buffers.get(e);if(o){if(!o.saved&&t===void 0)throw new Error("markSaved requires an href when saving a draft route");return o.rev+=1,o.saved=!0,o.dirty=!1,t!==void 0&&(o.href=t),i!==void 0&&(o.name=i),r!==void 0&&(o.description=r),this.refreshLive(),o.rev}}replace(e,t){let i=this.buffers.get(e);if(i)return i.points=(t??[]).map(r=>this.clonePoint(r)),i.rev+=1,i.dirty=!0,this.refreshLive(),this.events.next({type:"dirty",routeId:e,rev:i.rev,reason:"replaced"}),this.snapshot(i)}refreshLive(){this.liveSignal.set([...this.buffers.values()].map(e=>this.snapshot(e)))}refresh(){this.refreshLive()}newRouteId(){let e=globalThis.crypto;return e?.randomUUID?e.randomUUID():"rb-"+Date.now().toString(36)+"-"+Math.random().toString(36).slice(2,10)}clonePoint(e){return se(se({position:[...e.position]},e.name!==void 0?{name:e.name}:{}),e.description!==void 0?{description:e.description}:{})}snapshot(e){return ri(se({routeId:e.routeId,name:e.name,description:e.description,rev:e.rev,saved:e.saved,dirty:e.dirty},e.href!==void 0?{href:e.href}:{}),{points:e.points.map(t=>this.clonePoint(t))})}static \u0275fac=function(t){return new(t||n)};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})};var HN="fb-plotterext-state",joe="embedding-host",Woe=1e3,Uoe=new Set(["eq","ne","lt","lte","gt","gte","in","contains","regex","exists"]),Hoe=n=>!!n&&typeof n=="object"&&typeof n.path=="string"&&n.path.length>0&&Uoe.has(n.op),Nf=class n{constructor(e,t,i,r,o,a,s){this.app=e;this.signalk=t;this.dialog=i;this.skres=r;this.mapService=o;this.routeRegistry=a;this.stream=s;os()&&(window.fbPlotterExt=this),window.addEventListener("resize",()=>this.viewportTick.update(l=>l+1)),this.bridgeRouteEvents(),Me(()=>this.syncVisibleFromSelections()),Me(()=>this.emitChartChanges(this.skres.charts())),Me(()=>this.emitNightModeChange(this.readNightMode())),Me(()=>this.emitMapViewChange(this.mapView()))}app;signalk;dialog;skres;mapService;routeRegistry;stream;manifests=X({});activeWidgets=X([]);initialized=X(!1);viewportTick=X(0);actionButtonLift=qt(()=>{this.viewportTick();let e=this.activeWidgets().filter(i=>i.anchor==="br");if(!e.length)return 0;let t=e.some(i=>i.row===0)?2:1;return t*f1()+(t-1)*m1+6});statusBarLift=qt(()=>{this.viewportTick();let e=this.activeWidgets().filter(i=>i.anchor==="cb");if(!e.length)return 0;let t=e.some(i=>i.row===0)?2:1;return t*f1()+(t-1)*m1+4});toolbarTopOffset=qt(()=>{this.viewportTick();let e=this.activeWidgets().filter(i=>i.anchor==="tr");if(!e.length)return 0;let t=e.some(i=>i.row===1)?2:1;return t*f1()+(t-1)*m1+4});toolbarButtons=qt(()=>{let e=[];for(let[t,i]of Object.entries(this.manifests()))if(this.isCompatible(i))for(let r of i.buttons??[])r.apiVersion!==void 0&&r.apiVersion!=="1"||e.push({extension:t,extensionName:i.name,button:r});return e});backgroundRuntimes=qt(()=>{let e=[];for(let[t,i]of Object.entries(this.manifests()))if(this.isCompatible(i))for(let r of i.background??[])r.apiVersion!==void 0&&r.apiVersion!=="1"||r.type!=="iframe"||!r.url||e.push({key:`${t}/${r.id}`,extension:t,extensionName:i.name,runtime:r});return e});openPanels=X([]);visiblePanel=qt(()=>this.openPanels().find(e=>e.visible)??null);openPanel(e,t){let r=this.manifests()[e]?.panels?.find(a=>a.id===t);if(!r||r.type!=="iframe"||!r.url||r.apiVersion!==void 0&&r.apiVersion!=="1")return!1;let o=`${e}/${t}`;return this.openPanels.update(a=>{let s=a.filter(l=>l.key===o||l.panel.lifecycle==="keepAlive").map(l=>ri(se({},l),{visible:l.key===o}));return s.some(l=>l.key===o)?s:[...s,{key:o,extension:e,panel:r,visible:!0}]}),!0}closeVisiblePanel(){let e=this.openPanels().find(t=>t.visible);e&&this.closePanel(e.key)}closePanel(e){this.openPanels.update(t=>{let i=t.find(r=>r.key===e);return i?i.panel.lifecycle==="keepAlive"?t.map(r=>r.key===e?ri(se({},r),{visible:!1}):r):t.filter(r=>r.key!==e):t})}togglePanel(e,t){let i=`${e}/${t}`;return this.visiblePanel()?.key===i?(this.closeVisiblePanel(),!0):this.openPanel(e,t)}uiPanelMethods(e){let t=i=>{let r=i?.panel;if(!r)throw new si("panel is required",{code:Ki.INVALID_PARAMS,reason:"UNKNOWN_PANEL"});return r};return{"ui.openPanel":i=>J(this,null,function*(){let r=t(i);if(!this.openPanel(e,r))throw new si(`No such panel: ${r}`,{code:Ki.INVALID_PARAMS,reason:"UNKNOWN_PANEL"});return{}}),"ui.togglePanel":i=>J(this,null,function*(){let r=t(i);if(!this.togglePanel(e,r))throw new si(`No such panel: ${r}`,{code:Ki.INVALID_PARAMS,reason:"UNKNOWN_PANEL"});return{}})}}handleButtonAction(e,t){let i=t.action;if(!i)return;if(i.type==="sendMessage"){i.topic&&this.broadcastMessage(i.topic,i.params);return}let r=i.panel;r&&(i.type==="togglePanel"?this.togglePanel(e,r):i.type==="openPanel"&&this.openPanel(e,r))}resourceFilters=X({});visibleNotes=qt(()=>{let e=this.skres.notes(),t=this.resourceFilters().notes;if(!t||!Object.keys(t).length)return e;let i=Object.values(t);return e.filter(([r,o])=>i.every(a=>this.passesFilter(a,r,o)))});filterChips=qt(()=>{let e=[];for(let[t,i]of Object.entries(this.resourceFilters()))for(let[r,o]of Object.entries(i))e.push({type:t,extension:r,label:o.label??`${this.manifests()[r]?.name??r} filter`});return e});setResourceFilter(e,t,i){this.resourceFilters.update(r=>ri(se({},r),{[t]:ri(se({},r[t]??{}),{[e]:i})})),this.publishToExtension(e,"filters.changed",{type:t,active:!0})}clearResourceFilter(e,t){this.resourceFilters.update(i=>{let r=se({},i[t]??{});delete r[e];let o=se({},i);return Object.keys(r).length?o[t]=r:delete o[t],o}),this.publishToExtension(e,"filters.changed",{type:t,active:!1})}passesFilter(e,t,i){let r=!0;return e.ids&&(r=e.ids.includes(t)),r&&e.match&&(r=e.match.every(o=>this.evalCondition(o,i))),e.mode==="exclude"?!r:r}evalCondition(e,t){let i=t;for(let r of e.path.split(".")){if(i===null||typeof i!="object"){i=void 0;break}i=i[r]}switch(e.op){case"exists":return i!==void 0;case"eq":return this.refEquals(i,e.value,e.exact);case"ne":return!this.refEquals(i,e.value,e.exact);case"lt":return typeof i=="number"&&i<e.value;case"lte":return typeof i=="number"&&i<=e.value;case"gt":return typeof i=="number"&&i>e.value;case"gte":return typeof i=="number"&&i>=e.value;case"in":return Array.isArray(e.value)&&e.value.some(r=>this.refEquals(i,r,e.exact));case"contains":return typeof i=="string"?i.toLowerCase().includes(String(e.value).toLowerCase()):Array.isArray(i)&&i.includes(e.value);case"regex":{if(typeof i!="string"||typeof e.value!="string"||i.length>2e3)return!1;let r=this.compileRegex(e.value);return r?r.test(i):!1}default:return!1}}symbolLocalId(e){if(typeof e!="string")return null;let t=/^[A-Za-z0-9_-]+:([^:]+)$/.exec(e);return t?t[1]:null}refEquals(e,t,i){return e===t?!0:i?!1:typeof t=="string"&&!t.includes(":")&&this.symbolLocalId(e)===t||typeof e=="string"&&!e.includes(":")&&this.symbolLocalId(t)===e}compileRegex(e){if(e.length>200)return null;try{return new RegExp(e)}catch(t){return null}}contexts=new Set;embeddingHostDetach=null;ws=null;wsReady=!1;pathRefs=new Map;reconnectTimer=null;pointsFromRoute(e,t){return e.map((i,r)=>se(se({position:i},t?.[r]?.name?{name:t[r].name}:{}),t?.[r]?.description?{description:t[r].description}:{}))}pointsEqual(e,t){return e.length!==t.length?!1:e.every((i,r)=>{let o=t[r];return i.position[0]===o.position[0]&&i.position[1]===o.position[1]&&(i.position[2]??null)===(o.position[2]??null)&&(i.name??null)===(o.name??null)&&(i.description??null)===(o.description??null)})}syncVisibleFromSelections(){let e=this.skres.routes(),t=new Set(e.map(i=>i[0]));for(let[i,r]of e){let o=r.feature?.geometry?.coordinates??[],a=r.feature?.properties?.coordinatesMeta,s=this.pointsFromRoute(o,a),l=this.routeRegistry.getByHref(i);if(l){l.saved&&!l.dirty&&((l.name??null)!==(r.name??null)||(l.description??null)!==(r.description??null)||!this.pointsEqual(l.points,s))&&this.routeRegistry.show({routeId:l.routeId,name:r.name??null,description:r.description??null,points:s,href:i});continue}this.routeRegistry.show({routeId:i,name:r.name??null,description:r.description??null,points:s,href:i})}for(let i of this.routeRegistry.all())i.saved&&!i.dirty&&i.href&&!t.has(i.href)&&this.routeRegistry.delete(i.routeId,!0)}bridgeRouteEvents(){this.routeRegistry.events$.subscribe(e=>{switch(e.type){case"visible":this.broadcastMessage("route.visible",{routeId:e.routeId,rev:e.rev,name:e.name,pointCount:e.pointCount,saved:e.saved,dirty:e.dirty});break;case"hidden":this.broadcastMessage("route.hidden",{routeId:e.routeId,rev:e.rev,saved:e.saved});break;case"dirty":this.broadcastMessage("route.dirty",se({routeId:e.routeId,rev:e.rev},e.reason!==void 0?{reason:e.reason}:{}));break}})}routeMethods(){return jN(this.routeRegistry,{onSave:(e,t)=>this.saveBuffer(e,t),onShow:e=>this.showRoute(e),onHide:e=>this.hideRoute(e),onDelete:e=>this.deleteRoute(e)})}chartMethods(){return WN({listAvailableOrdered:()=>this.skres.chartsForHostApi(),setVisibility:(e,t)=>this.skres.setChartsVisibility(e,t),setOpacity:(e,t)=>this.skres.setChartsOpacity(e,t),setOrder:e=>this.skres.setChartsOrder(e)})}nightModeMethods(){return UN({getState:()=>this.readNightMode(),setState:e=>this.applyNightMode(e)})}readNightMode(){return{enabled:this.stream.selfNightMode()||this.app.uiCtrl().forceNightMode,auto:this.app.config.display.nightMode??!1}}applyNightMode(e){let t=e.auto;if(typeof t=="boolean"){if(t)this.app.uiCtrl.update(r=>ri(se({},r),{forceNightMode:!1}));else if(typeof e.enabled!="boolean"){let r=this.readNightMode().enabled;this.app.uiCtrl.update(o=>ri(se({},o),{forceNightMode:r}))}this.app.config.display.nightMode=t,this.app.uiConfig.update(r=>ri(se({},r),{autoNightMode:t}))}let i=e.enabled;typeof i=="boolean"&&(this.app.config.display.nightMode=!1,this.app.uiConfig.update(r=>ri(se({},r),{autoNightMode:!1})),this.app.uiCtrl.update(r=>ri(se({},r),{forceNightMode:i}))),this.stream.refreshSelfNightMode(),this.emitNightModeChange(this.readNightMode())}prevNightMode=null;emitNightModeChange(e){let t=this.prevNightMode;this.prevNightMode=e,t!==null&&(t.enabled===e.enabled&&t.auto===e.auto||this.broadcastMessage("nightMode.changed",e))}prevChartSnapshot=null;emitChartChanges(e){let t=e.map(c=>c[0]).reverse(),i=new Map(e.map(c=>[c[0],typeof c[1]?.defaultOpacity=="number"?c[1].defaultOpacity:1])),r=this.prevChartSnapshot;if(this.prevChartSnapshot={order:t,opacity:i},!r)return;let o=new Set(r.order),a=new Set(t);for(let c of t)o.has(c)||this.broadcastMessage("chart.visibility",{id:c,visible:!0});for(let c of r.order)a.has(c)||this.broadcastMessage("chart.visibility",{id:c,visible:!1});for(let[c,d]of i){let h=r.opacity.get(c);h!==void 0&&h!==d&&this.broadcastMessage("chart.opacity",{id:c,opacity:d})}let s=r.order.filter(c=>a.has(c)),l=t.filter(c=>o.has(c));s.length===l.length&&s.some((c,d)=>c!==l[d])&&this.broadcastMessage("chart.order",{order:t})}hideRoute(e){let t=this.routeRegistry.get(e);t&&(t.saved&&t.href?(this.skres.routeHide(t.href),this.routeRegistry.delete(e,!0)):this.routeRegistry.delete(e,!1))}deleteRoute(e){return J(this,null,function*(){let t=this.routeRegistry.get(e);if(t){if(t.saved&&t.href)try{yield this.skres.deleteFromServer("routes",t.href)}catch(i){throw this.app.parseHttpErrorResponse(i),new si("Failed to delete route",{reason:"routes.deleteFailed"})}this.routeRegistry.delete(e,!1)}})}showRoute(e){return J(this,null,function*(){let t=this.routeRegistry.getByHref(e);if(t)return{routeId:t.routeId,rev:t.rev};this.skres.selectionAdd("routes",e),yield this.skres.refreshRoutes();let i=this.skres.fromCache("routes",e);if(!i)throw this.skres.selectionRemove("routes",e),new si("No such route",{reason:"routes.badRef"});let r=i[1],o=r.feature?.geometry?.coordinates??[],a=r.feature?.properties?.coordinatesMeta,s=this.pointsFromRoute(o,a),l=this.routeRegistry.show({routeId:e,name:r.name??null,description:r.description??null,points:s,href:e});return{routeId:l.routeId,rev:l.rev}})}saveNativeRouteEdit(e,t,i){return J(this,null,function*(){let r=this.pointsFromRoute(t,i),o=this.routeRegistry.get(e);if(!o){let c=this.skres.fromCache("routes",e),d=c?c[1].name??null:null,h=c?c[1].description??null:null;this.routeRegistry.show({routeId:e,name:d,description:h,points:r,href:e})}this.routeRegistry.replace(e,r),o=this.routeRegistry.get(e);let a=o?.href??e;if(!(yield this.skres.updateRouteCoords(a,t,i)))return;let l=this.routeRegistry.markSaved(e,a)??0;this.broadcastMessage("route.saved",{routeId:e,rev:l,href:a,name:o?.name??null,saved:!0,dirty:!1})})}saveBuffer(i){return J(this,arguments,function*(e,t={}){let r=this.routeRegistry.get(e);if(!r)return null;let[,o]=this.skres.buildRoute(r.points.map(d=>d.position)),a=r.points.map(d=>se(se({},d.name?{name:d.name}:{}),d.description?{description:d.description}:{}));a.some(d=>Object.keys(d).length>0)&&(o.feature.properties.coordinatesMeta=a),o.name=t.name??r.name??"",o.description=t.description??r.description??"";let s;if(r.href)try{yield this.skres.putToServer("routes",r.href,o),s=r.href}catch(d){throw this.app.parseHttpErrorResponse(d),new si("Failed to save route",{reason:"routes.saveFailed"})}else if(t.dialog)try{s=yield this.skres.saveNewRoute(o)}catch(d){throw new si("Failed to save route",{reason:"routes.saveFailed"})}else try{s=(yield this.skres.postToServer("routes",o)).id,this.skres.selectionAdd("routes",s)}catch(d){throw this.app.parseHttpErrorResponse(d),new si("Failed to save route",{reason:"routes.saveFailed"})}if(!s)return null;let l=o.name||null,c=this.routeRegistry.markSaved(e,s,l,o.description||null)??r.rev+1;return this.broadcastMessage("route.saved",{routeId:e,rev:c,href:s,name:l,saved:!0,dirty:!1}),this.app.data.editingId="",{href:s,rev:c}})}init(){return J(this,null,function*(){try{let e=yield Fp(this.signalk.api.get(this.app.skApiVersion,"/resources/plotterExtensions")),t={};if(e&&typeof e=="object")for(let[i,r]of Object.entries(e))this.isManifest(r)&&(t[i]=r);this.manifests.set(t)}catch(e){this.manifests.set({})}this.refreshActiveWidgets(),this.initialized.set(!0),this.attachEmbeddingHostOnce()})}isCompatible(e){return e.apiVersion!=="1"?!1:(e.requires??[]).every(t=>qC.includes(t))}isManifest(e){return typeof e=="object"&&e!==null&&typeof e.name=="string"&&typeof e.apiVersion=="string"}widgetDef(e,t){return this.manifests()[e]?.widgets?.find(r=>r.id===t)??null}placements(){return this.app.config.plotterExtensions.widgets}occupancy(e){let{cols:t,rows:i}=h1[e],r=Array.from({length:i},()=>Array.from({length:t},()=>!1));for(let o of this.activeWidgets()){if(o.anchor!==e)continue;let a=this.widgetDef(o.extension,o.widget),s=XC(a?.size??"1x1");for(let l=o.row;l<o.row+s.rows&&l<i;l++)for(let c=o.col;c<o.col+s.cols&&c<t;c++)r[l][c]=!0}return r}cellOccupied(e,t){return this.occupancy(e)[t.row]?.[t.col]??!0}isValidOrigin(e,t,i,r){let{cols:o,rows:a}=h1[e];if(i.col+t.cols>o||i.row+t.rows>a)return!1;for(let s=i.row;s<i.row+t.rows;s++)for(let l=i.col;l<i.col+t.cols;l++)if(r[s][l])return!1;if(t.rows===1){let s=ZC[e]==="bottom"?a-1:0;if(i.row!==s){for(let l=i.col;l<i.col+t.cols;l++)if(!r[s][l])return!1}}return!0}originOrder(e){let t=h1[e].rows,i=Array.from({length:t},(s,l)=>l),r=ZC[e]==="bottom"?[...i].reverse():i,o=gD[e],a=[];for(let s of r)for(let l of o)a.push({col:l,row:s});return a}findOrigin(e,t,i){let r=XC(t.size),o=this.occupancy(e);for(let a of this.originOrder(e))if(this.isValidOrigin(e,r,a,o)&&!(i&&!(i.col>=a.col&&i.col<a.col+r.cols&&i.row>=a.row&&i.row<a.row+r.rows)))return a;return null}addableWidgets(e,t){let i=[];for(let[r,o]of Object.entries(this.manifests()))if(this.isCompatible(o))for(let a of o.widgets??[]){if(a.type!=="iframe"||a.apiVersion!==void 0&&a.apiVersion!=="1")continue;let s=this.findOrigin(e,a,t);s&&i.push({extension:r,extensionName:o.name,widget:a,origin:s})}return i}hitTester=null;registerHitTester(e){return this.hitTester=e,()=>{this.hitTester===e&&(this.hitTester=null)}}addableCellAt(e,t){let i=this.hitTester?.(e,t);return!i||this.cellOccupied(i.anchor,i.cell)||!this.addableWidgets(i.anchor,i.cell).length?null:i}openAddWidgetPicker(e,t){return J(this,null,function*(){let i=this.addableWidgets(e,t);if(!i.length)return;let{PlotterAddWidgetDialog:r}=yield import("./chunk-RU2QXGZX.js");this.dialog.open(r,{data:{anchor:e,candidates:i},width:"340px"}).afterClosed().subscribe(o=>{if(!o)return;let a=this.placeWidget(o.extension,o.widget,e,o.origin);this.widgetHasConfigPanel(a)&&this.openConfigPanel(a)})})}placeWidget(e,t,i,r){let o={instanceId:RE(),extension:e,widget:t.id,anchor:i,col:r.col,row:r.row};return this.app.config.plotterExtensions.widgets.push(o),this.app.saveConfig(),this.refreshActiveWidgets(),o}removeWidget(e){let t=this.app.config.plotterExtensions.widgets,i=t.findIndex(r=>r.instanceId===e);if(i!==-1){let[r]=t.splice(i,1);this.clearInstanceState(r.extension,e),this.app.saveConfig(),this.refreshActiveWidgets()}}refreshActiveWidgets(){let e=this.manifests();this.activeWidgets.set(this.placements().filter(t=>{let i=e[t.extension];return i&&this.isCompatible(i)&&i.widgets?.some(r=>r.id===t.widget&&(r.apiVersion===void 0||r.apiVersion==="1"))}))}resolveAssetUrl(e){let t=this.app.hostDef?.url||window.location.origin;try{let i=new URL(t),r=new URL(e,t);return r.protocol!=="http:"&&r.protocol!=="https:"||r.origin!==i.origin?"about:blank":r.toString()}catch(i){return"about:blank"}}assetOrigin(e){try{return new URL(this.resolveAssetUrl(e)).origin}catch(t){return"*"}}attachWidget(e,t){let i={extension:t.extension,conn:null,skSubs:new Map,skSubSeq:0},r=this.widgetDef(t.extension,t.widget)?.url??"";return i.conn=new Ff({port:Of(e.contentWindow,{origin:this.assetOrigin(r)}),hostInfo:this.hostInfo(),context:{kind:"widget",id:t.widget,instanceId:t.instanceId,targetInstance:null},methods:ri(se(se(se(se(se(se(se(se(se({},this.stateMethods(t.extension,t.instanceId)),this.signalkMethods(i)),this.unitsMethods()),this.resourcesMethods(t.extension)),this.mapMethods()),this.routeMethods()),this.chartMethods()),this.nightModeMethods()),this.uiPanelMethods(t.extension)),{"ui.openConfigPanel":()=>J(this,null,function*(){return this.openConfigPanel(t),{}}),"ui.toggleConfigPanel":()=>J(this,null,function*(){return this.toggleConfigPanel(t),{}})}),onError:o=>console.warn("plotterext widget error",o)}),this.contexts.add(i),()=>this.detach(i)}attachPanel(e,t){let i={extension:t.extension,conn:null,skSubs:new Map,skSubSeq:0};return i.conn=new Ff({port:Of(e.contentWindow,{origin:this.assetOrigin(t.panel.url??"")}),hostInfo:this.hostInfo(),context:{kind:"panel",id:t.panel.id,instanceId:null,targetInstance:t.targetInstance??null,targetWidget:t.targetWidget??null},methods:ri(se(se(se(se(se(se(se(se(se({},this.stateMethods(t.extension,t.targetInstance??null)),this.signalkMethods(i)),this.unitsMethods()),this.resourcesMethods(t.extension)),this.mapMethods()),this.routeMethods()),this.chartMethods()),this.nightModeMethods()),this.uiPanelMethods(t.extension)),{"ui.closePanel":()=>J(this,null,function*(){return t.close(),{}})}),onError:r=>console.warn("plotterext panel error",r)}),this.contexts.add(i),()=>this.detach(i)}attachBackground(e,t){let i={extension:t.extension,conn:null,skSubs:new Map,skSubSeq:0};return i.conn=new Ff({port:Of(e.contentWindow,{origin:this.assetOrigin(t.runtime.url)}),hostInfo:this.hostInfo(),context:{kind:"background",id:t.runtime.id,instanceId:null},methods:se(se(se(se(se(se(se(se(se({},this.stateMethods(t.extension,null)),this.signalkMethods(i)),this.unitsMethods()),this.resourcesMethods(t.extension)),this.mapMethods()),this.routeMethods()),this.chartMethods()),this.nightModeMethods()),this.uiPanelMethods(t.extension)),onError:r=>console.warn("plotterext background error",r)}),this.contexts.add(i),()=>this.detach(i)}attachEmbeddingHost(e=Of(window.parent,{origin:window.location.origin})){let t=joe,i={extension:t,conn:null,skSubs:new Map,skSubSeq:0};return i.conn=new Ff({port:e,hostInfo:this.hostInfo(),adoptCallerId:!0,context:{kind:"embedding-host",id:t,instanceId:null},methods:se(se(se(se(se(se(se(se(se({},this.stateMethods(t,null)),this.signalkMethods(i)),this.unitsMethods()),this.resourcesMethods(t)),this.mapMethods()),this.routeMethods()),this.chartMethods()),this.nightModeMethods()),this.uiPanelMethods(t)),onError:r=>console.warn("plotterext embedding-host error",r)}),this.contexts.add(i),()=>this.detach(i)}attachEmbeddingHostOnce(){this.embeddingHostDetach||this.app.isTopWindow()||(this.embeddingHostDetach=this.attachEmbeddingHost())}detach(e){if(this.contexts.has(e)){this.contexts.delete(e);for(let[,t]of e.skSubs)this.releasePaths(t);e.skSubs.clear(),e.conn.close()}}hostInfo(){return{host:"freeboard-sk",hostVersion:this.app.data?.server?.version??"dev",apiVersion:"1",capabilities:qC}}configDialogRef=null;configDialogInstance=null;widgetHasConfigPanel(e){let t=this.manifests()[e.extension],i=this.widgetDef(e.extension,e.widget),r=t?.panels?.find(o=>o.id===i?.configPanel);return!!(r&&r.type==="iframe"&&r.url)}openConfigPanel(e){let t=this.manifests()[e.extension],i=this.widgetDef(e.extension,e.widget),r=t?.panels?.find(a=>a.id===i?.configPanel),o=r&&r.type==="iframe"&&r.url&&(r.apiVersion===void 0||r.apiVersion==="1")?r:null;import("./chunk-KOKEUVWV.js").then(({PlotterPanelDialog:a})=>{let s=this.dialog.open(a,{data:{extension:e.extension,panel:o,title:i?.title??e.widget,targetInstance:e.instanceId,targetWidget:e.widget},width:"440px",maxHeight:"85vh"});this.configDialogRef=s,this.configDialogInstance=e.instanceId,s.afterClosed().subscribe(()=>{this.configDialogRef===s&&(this.configDialogRef=null,this.configDialogInstance=null)})})}toggleConfigPanel(e){if(this.configDialogRef&&this.configDialogInstance===e.instanceId){this.configDialogRef.close();return}this.openConfigPanel(e)}loadStore(){try{return JSON.parse(localStorage.getItem(HN)??"{}")}catch(e){return{}}}saveStore(e){localStorage.setItem(HN,JSON.stringify(e))}clearInstanceState(e,t){let i=this.loadStore();i[e]?.instances?.[t]&&(delete i[e].instances[t],this.saveStore(i))}stateMethods(e,t){let i=(r,o)=>{let a=r[e]=r[e]??{};if((o??(t?"instance":"extension"))==="instance"){if(!t)throw new si("No widget instance in scope",{code:Ki.INVALID_PARAMS,reason:"NO_INSTANCE"});return a.instances=a.instances??{},a.instances[t]=a.instances[t]??{}}return a.extension=a.extension??{}};return{"state.get":r=>J(this,null,function*(){let{scope:o,keys:a}=r??{},s=i(this.loadStore(),o);if(!a)return{values:s};let l={};for(let c of a)c in s&&(l[c]=s[c]);return{values:l}}),"state.set":r=>J(this,null,function*(){let{scope:o,values:a}=r??{};if(!a||typeof a!="object")throw new si("state.set requires a values object",{code:Ki.INVALID_PARAMS,reason:"INVALID_VALUES"});let s=this.loadStore(),l=i(s,o);Object.assign(l,a),this.saveStore(s);let c=(o??(t?"instance":"extension"))==="instance";return this.publishToExtension(e,"state.changed",{scope:c?"instance":"extension",instanceId:c?t:null,keys:Object.keys(a)}),{}})}}publishToExtension(e,t,i){for(let r of this.contexts)r.extension===e&&r.conn.publish(t,i)}broadcastMessage(e,t){for(let i of this.contexts)i.conn.publish(e,t)}resourcesMethods(e){return{"resources.list":t=>J(this,null,function*(){let{type:i,query:r}=t??{};if(typeof i!="string"||!/^[A-Za-z][A-Za-z0-9_-]*$/.test(i))throw new si("resources.list requires a resource type",{code:Ki.INVALID_PARAMS,reason:"INVALID_TYPE"});let o=this.serializeQuery(r);try{return(yield Fp(this.signalk.api.get(this.app.skApiVersion,`/resources/${i}${o}`)))??{}}catch(a){throw new si(`resources.list ${i} failed`,{reason:"LIST_FAILED",data:{message:a?.message}})}}),"resources.setFilter":t=>J(this,null,function*(){let{type:i,filter:r}=t??{};if(typeof i!="string"||!r||r.mode!=="include"&&r.mode!=="exclude"||r.ids===void 0&&r.match===void 0||r.ids!==void 0&&(!Array.isArray(r.ids)||!r.ids.every(o=>typeof o=="string"))||r.match!==void 0&&(!Array.isArray(r.match)||!r.match.every(Hoe)))throw new si("resources.setFilter requires a type and a filter with mode plus ids and/or match",{code:Ki.INVALID_PARAMS,reason:"INVALID_FILTER"});return this.setResourceFilter(e,i,r),{}}),"resources.clearFilter":t=>J(this,null,function*(){let{type:i}=t??{};if(typeof i!="string")throw new si("resources.clearFilter requires a type",{code:Ki.INVALID_PARAMS,reason:"INVALID_TYPE"});return this.clearResourceFilter(e,i),{}})}}serializeQuery(e){if(!e||typeof e!="object")return"";let t=[];for(let[i,r]of Object.entries(e)){if(r==null)continue;let o=Array.isArray(r)?JSON.stringify(r):String(r);t.push(`${encodeURIComponent(i)}=${encodeURIComponent(o)}`)}return t.length?`?${t.join("&")}`:""}mapView(){return{center:this.app.config.map.center,zoom:this.app.config.map.zoomLevel,bounds:this.app.mapExtent()}}prevMapView=null;emitMapViewChange(e){let t=this.prevMapView;this.prevMapView=e,!(t===null||t.zoom===e.zoom&&t.center[0]===e.center[0]&&t.center[1]===e.center[1]&&t.bounds.length===e.bounds.length&&t.bounds.every((r,o)=>r===e.bounds[o]))&&this.broadcastMessage("map.view",e)}mapMethods(){return{"map.getView":()=>J(this,null,function*(){return this.mapView()}),"map.center":e=>J(this,null,function*(){let{position:t,zoom:i}=e??{};if(!Array.isArray(t)||t.length!==2||!t.every(r=>typeof r=="number"))throw new si("map.center requires position [lon, lat]",{code:Ki.INVALID_PARAMS,reason:"INVALID_POSITION"});return this.app.mapMoveRequest.set(se({center:t},typeof i=="number"?{zoom:i}:{})),{}}),"map.fitBounds":e=>J(this,null,function*(){let{bounds:t}=e??{};if(!Array.isArray(t)||t.length!==4||!t.every(l=>typeof l=="number"))throw new si("map.fitBounds requires bounds [minLon, minLat, maxLon, maxLat]",{code:Ki.INVALID_PARAMS,reason:"INVALID_BOUNDS"});let[i,r,o,a]=t,s=[(i+o)/2,(r+a)/2];return this.app.mapMoveRequest.set({center:s,zoom:this.zoomForBounds(t)}),{}})}}zoomForBounds(e){let t=this.mapService.getMaps()[0],i=t?.getSize();if(!t||!i)return 12;let r=t.getView(),o=Gn(e,"EPSG:4326","EPSG:3857"),a=[i[0]*.85,i[1]*.85],s=r.getResolutionForExtent(o,a),l=r.getZoomForResolution(s)??12,c=this.app.MAP_ZOOM_EXTENT?.max??18;return Math.min(l,c)}pulseMapResize(e=320){let t=0,i=()=>{this.mapService.updateSize(),t+=16,t<e&&requestAnimationFrame(i)};requestAnimationFrame(i)}unitsMethods(){return{"units.get":()=>J(this,null,function*(){let e=this.app.config.units;return{units:{speed:e.speed,distance:e.distance,depth:e.depth,length:e.length,temperature:e.temperature}}})}}signalkMethods(e){return{"signalk.subscribe":t=>J(this,null,function*(){let{paths:i}=t??{};if(!Array.isArray(i)||i.length===0||!i.every(o=>typeof o=="string"&&o.length>0&&!o.includes("*")))throw new si("signalk.subscribe requires an array of literal Signal K paths",{code:Ki.INVALID_PARAMS,reason:"INVALID_PATHS"});let r=`sk-${++e.skSubSeq}`;return e.skSubs.set(r,i),this.acquirePaths(i),{subscriptionId:r}}),"signalk.unsubscribe":t=>J(this,null,function*(){let{subscriptionId:i}=t??{},r=i?e.skSubs.get(i):null;if(!r)throw new si("Unknown subscriptionId",{code:Ki.INVALID_PARAMS,reason:"UNKNOWN_SUBSCRIPTION"});return e.skSubs.delete(i),this.releasePaths(r),{}}),"signalk.put":t=>J(this,null,function*(){let{path:i,value:r}=t??{};if(typeof i!="string"||!i.length)throw new si("signalk.put requires a path",{code:Ki.INVALID_PARAMS,reason:"INVALID_PATH"});try{return(yield Fp(this.signalk.api.put(1,`vessels/self/${i.split(".").join("/")}`,r)))??{}}catch(o){throw new si(`PUT ${i} failed`,{reason:"PUT_FAILED",data:{message:o?.message}})}})}}acquirePaths(e){let t=[];for(let i of e){let r=this.pathRefs.get(i)??0;this.pathRefs.set(i,r+1),r===0&&t.push(i)}t.length&&(this.ensureSocket(),this.sendSubscribe(t))}releasePaths(e){let t=[];for(let i of e){let r=this.pathRefs.get(i)??0;r<=1?(this.pathRefs.delete(i),t.push(i)):this.pathRefs.set(i,r-1)}t.length&&this.wsReady&&this.wsSend({context:"vessels.self",unsubscribe:t.map(i=>({path:i}))}),this.pathRefs.size===0&&this.closeSocket()}ensureSocket(){if(this.ws)return;let e=this.app.data?.server?this.signalk.server?.endpoints?.v1?.["signalk-ws"]:null;if(!e){console.warn("plotterext: no signalk-ws endpoint available");return}let t=`${e}?subscribe=none`,i=this.app.getFBToken();i&&(t+=`&token=${i}`);let r=new WebSocket(t);this.ws=r,r.onopen=()=>{this.wsReady=!0;let o=[...this.pathRefs.keys()];o.length&&this.sendSubscribe(o)},r.onmessage=o=>this.handleDelta(o.data),r.onclose=()=>{this.ws===r&&(this.ws=null,this.wsReady=!1,this.pathRefs.size&&!this.reconnectTimer&&(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.ensureSocket()},3e3)))},r.onerror=()=>{}}closeSocket(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);let e=this.ws;this.ws=null,this.wsReady=!1,e?.close()}sendSubscribe(e){this.wsReady&&this.wsSend({context:"vessels.self",subscribe:e.map(t=>({path:t,period:Woe,policy:"instant",minPeriod:200}))})}wsSend(e){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify(e))}handleDelta(e){let t;try{t=JSON.parse(e)}catch(i){return}if(Array.isArray(t.updates)){for(let i of t.updates)if(Array.isArray(i.values))for(let r of i.values){if(!r?.path||!this.pathRefs.has(r.path))continue;let o={path:r.path,value:r.value,timestamp:i.timestamp,$source:i.$source??i.source?.label};for(let a of this.contexts)a.conn.publish(`sk.${r.path}`,o)}}}static \u0275fac=function(t){return new(t||n)(ct(ae),ct(Ot),ct(xn),ct(Pt),ct(Sl),ct(yc),ct(Xa))};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})};function Koe(n,e){if(n&1&&z(0,"wpt-button",1),n&2){let t=v();w("position",t.app.data.vessels.self.position)("active",t.app.data.vessels.showSelf)}}function $oe(n,e){n&1&&z(0,"pob-button")}function qoe(n,e){if(n&1&&z(0,"autopilot-button",2),n&2){let t=v();w("active",t.app.featureFlags().autopilotApi&&t.app.data.vessels.self.autopilot.default)}}function Zoe(n,e){if(n&1){let t=H();u(0,"radar-button",3),T("click",function(){O(t);let r=v();return F(r.radarClick.emit())}),p()}if(n&2){let t=v();w("active",t.app.featureFlags().radarApi&&t.radarApi.radarId().length!==0)}}var KN=class n{action=Z();radarClick=we();app=M(ae);radarApi=M(gc);plotterExt=M(Nf);bottomOffset=qt(()=>{let e=this.plotterExt.actionButtonLift();return e>0?e:23});constructor(){}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["mfb-container"]],inputs:{action:[1,"action"]},outputs:{radarClick:"radarClick"},decls:5,vars:6,consts:[[1,"mfb-container"],[3,"position","active"],[3,"active"],[3,"click","active"]],template:function(t,i){t&1&&(u(0,"div",0),R(1,Koe,1,2,"wpt-button",1),R(2,$oe,1,0,"pob-button"),R(3,qoe,1,1,"autopilot-button",2),R(4,Zoe,1,1,"radar-button",2),p()),t&2&&(Nt("bottom",i.bottomOffset(),"px"),g(),A(i.action()==="wpt"?1:-1),g(),A(i.action()==="pob"?2:-1),g(),A(i.action()==="autopilot"?3:-1),g(),A(i.action()==="radar"?4:-1))},dependencies:[V2,G2,z2,j2],styles:[".mfb-container[_ngcontent-%COMP%]{position:absolute;bottom:23px;right:5px;z-index:5000}"]})};var Xoe=["*"],Yoe=(n,e,t)=>({measure:n,compact:e,docked:t}),Qoe=n=>({measure:n});function Joe(n,e){if(n&1&&(u(0,"mat-icon"),z(1,"country-flag",7),p()),n&2){let t=v(2);g(),w("mmsi",t.mmsi)("host",t.app.hostDef.url)}}function eae(n,e){if(n&1&&z(0,"mat-icon",8),n&2){let t=v(2);Rt(t.icon==null?null:t.icon.class),w("svgIcon",t.icon.svgIcon)}}function tae(n,e){if(n&1&&(u(0,"mat-icon"),_(1),p()),n&2){let t=v(2);Rt(t.icon==null?null:t.icon.class),g(),q(t.icon==null?null:t.icon.name)}}function iae(n,e){if(n&1&&_(0),n&2){let t=v(2);$(" \xA0",t.title," ")}}function nae(n,e){if(n&1){let t=H();u(0,"div")(1,"button",9),T("click",function(){O(t);let r=v(2);return F(r.handleClose())}),u(2,"mat-icon"),_(3,"close"),p()()()}}function rae(n,e){if(n&1){let t=H();u(0,"div")(1,"button",10),T("click",function(){O(t);let r=v(2);return F(r.handleNavTo())}),u(2,"mat-icon"),_(3,"near_me"),p()()()}}function oae(n,e){if(n&1&&(u(0,"div",1)(1,"div",4),R(2,Joe,2,2,"mat-icon"),R(3,eae,1,3,"mat-icon",5)(4,tae,2,3,"mat-icon",6),R(5,iae,1,1),p(),R(6,nae,4,0,"div"),R(7,rae,4,0,"div"),p()),n&2){let t=v();g(),w("ngClass",an(6,Qoe,t.measure)),g(),A(t.mmsi?2:-1),g(),A(t.icon!=null&&t.icon.svgIcon?3:t.icon!=null&&t.icon.name?4:-1),g(2),A(t.title?5:-1),g(),A(t.canClose?6:-1),g(),A(!t.canClose&&t.navTo?7:-1)}}var pr=class n{title;mmsi;icon;canClose=!0;measure=!1;compact=!1;docked=!1;navTo=!1;closed=new he;navigateTo=new he;app=M(ae);constructor(){}handleClose(){this.closed.emit()}handleNavTo(){this.navigateTo.emit()}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-popover"]],inputs:{title:"title",mmsi:"mmsi",icon:"icon",canClose:"canClose",measure:"measure",compact:"compact",docked:"docked",navTo:"navTo"},outputs:{closed:"closed",navigateTo:"navigateTo"},ngContentSelectors:Xoe,decls:5,vars:6,consts:[[1,"popover","top","in","mat-app-background",3,"ngClass"],[1,"popover-title"],[1,"popover-content"],[1,"arrow",2,"left","50%"],[2,"flex","1 1 auto","overflow","hidden","display","-webkit-box","-webkit-box-orient","vertical","-webkit-line-clamp","1","line-clamp","1","text-overflow","ellipsis",3,"ngClass"],[3,"class","svgIcon"],[3,"class"],[3,"mmsi","host"],[3,"svgIcon"],["mat-icon-button","",3,"click"],["mat-icon-button","","matTooltip","Navigate to here",3,"click"]],template:function(t,i){t&1&&(fe(),u(0,"div",0),R(1,oae,8,8,"div",1),u(2,"div",2),de(3),p(),z(4,"div",3),p()),t&2&&(w("ngClass",zp(2,Yoe,i.measure,i.compact,i.docked)),g(),A(i.title||i.icon||i.mmsi||i.canClose||i.navTo?1:-1))},dependencies:[hn,Ln,ue,Fe,be,Pe,le,ce,B2],styles:['.popover[_ngcontent-%COMP%]{position:absolute;top:0;left:0;transform:translate(-50%,-100%);z-index:3990;display:block;max-width:276px;min-width:270px;padding:1px;font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;line-height:1.42857143;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;letter-spacing:normal;word-break:normal;word-spacing:normal;word-wrap:normal;white-space:normal;-webkit-background-clip:padding-box;background-clip:padding-box;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px #0003;line-break:auto}.popover.top[_ngcontent-%COMP%]{margin-top:-10px;margin-left:10px}.popover-title[_ngcontent-%COMP%]{padding:2px 0 2px 5px;margin:0;display:flex;line-height:2.5em;font-size:12pt;background-color:#fafafa82;border-radius:5px 5px 0 0;min-width:110px}.popover-content[_ngcontent-%COMP%]{padding:9px 14px;max-height:330px;overflow:auto}.popover[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%], .popover[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]:after{position:absolute;display:block;width:0;height:0;border-style:solid}.popover[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]{border-width:11px}.popover[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]:after{content:"";border-width:10px}.popover.top[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]{bottom:-11px;left:50%;margin-left:-11px;border-bottom-width:0;border-right-width:0;border-left-width:0}.popover.top[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]:after{bottom:1px;margin-left:-10px;content:" ";border-bottom-width:0}.popover.measure[_ngcontent-%COMP%]{min-width:100px;background-color:#39c}.popover.measure[_ngcontent-%COMP%] > .popover-content[_ngcontent-%COMP%]{display:none}.popover.measure[_ngcontent-%COMP%] > .popover-title[_ngcontent-%COMP%]{color:#fff;font-weight:700;border-bottom:none;background-color:inherit;text-align:left;width:max-content}.popover.top.measure[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]{bottom:-11px;left:50%;margin-left:-11px;border-bottom-width:0;border-right-width:0;border-left-width:0}.popover.top.measure[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]:after{bottom:1px;margin-left:-10px;content:" ";border-bottom-width:0;border-top-color:#39c}.popover-action-button[_ngcontent-%COMP%]{flex:1 1 45%}.popover.docked[_ngcontent-%COMP%]{position:static;transform:none;margin:0}.popover.docked[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]{display:none}.popover.compact[_ngcontent-%COMP%]{min-width:0;max-width:170px;width:fit-content}.popover.compact[_ngcontent-%COMP%] > .popover-title[_ngcontent-%COMP%]{padding:0;line-height:0;min-height:0;min-width:unset}.popover.compact[_ngcontent-%COMP%] > .popover-content[_ngcontent-%COMP%]{padding:6px 10px}'],changeDetection:0})};var aae=n=>({class:"",name:n});function sae(n,e){if(n&1&&(u(0,"li"),_(1),p()),n&2){let t=e.$implicit;g(),q(t)}}function lae(n,e){if(n&1&&(u(0,"ol",4),Le(1,sae,2,1,"li",null,gt),p()),n&2){let t=v(2);g(),Ae(t.mode.steps)}}function cae(n,e){if(n&1){let t=H();u(0,"div",0)(1,"ap-popover",2),T("closed",function(){O(t);let r=v();return F(r.close())}),z(2,"fb-measurements",3),R(3,lae,3,0,"ol",4),u(4,"div",5)(5,"div",6)(6,"button",7),T("click",function(){O(t);let r=v();return F(r.undoLast())}),u(7,"mat-icon"),_(8,"undo"),p(),_(9," UNDO "),p()(),u(10,"div",6)(11,"button",8),T("click",function(){O(t);let r=v();return F(r.finishEditing())}),u(12,"mat-icon"),_(13,"check"),p(),_(14),p()(),u(15,"div",6)(16,"button",9),T("click",function(){O(t);let r=v();return F(r.close())}),u(17,"mat-icon",10),_(18,"close"),p(),_(19," CANCEL "),p()()()()()}if(n&2){let t=v();g(),w("docked",!0)("canClose",!0)("title",t.mode.iconText)("icon",an(13,aae,t.mode.iconName)),g(),w("coords",t.mapInteract.measurement().coords)("index",t.mapInteract.measurement().index)("totalOnly",t.mapInteract.isDrawing())("card",!0),g(),A(t.mode.steps.length!==0?3:-1),g(3),w("disabled",!t.mapInteract.canUndo()),g(5),w("disabled",!t.canFinish())("matTooltip",t.mapInteract.isModifying()?"Save changes":"Finish \u2014 keep changes"),g(3),$(" ",t.mapInteract.isModifying()?"SAVE":"FINISH"," ")}}function dae(n,e){if(n&1&&(u(0,"div",14),_(1),p()),n&2){let t=v(3);g(),$(" ",t.mode.description," ")}}function uae(n,e){if(n&1&&(u(0,"li"),_(1),p()),n&2){let t=e.$implicit;g(),q(t)}}function pae(n,e){if(n&1&&(u(0,"div",14)(1,"ol",17),Le(2,uae,2,1,"li",null,gt),p()()),n&2){let t=v(3);g(2),Ae(t.mode.steps)}}function hae(n,e){if(n&1){let t=H();u(0,"div",11)(1,"div")(2,"span",13)(3,"mat-icon"),_(4),p(),_(5),p(),R(6,dae,2,1,"div",14),R(7,pae,4,0,"div",14),p(),u(8,"div",15)(9,"a",16),T("click",function(){O(t);let r=v(2);return F(r.close())}),u(10,"mat-icon",10),_(11,"close"),p(),_(12),p()()()}if(n&2){let t=v(2);g(4),q(t.mode.iconName),g(),$(" ",t.mode.iconText," "),g(),A(t.mode.description.length!==0?6:-1),g(),A(t.mode.steps.length!==0?7:-1),g(2),w("matTooltip",t.mapInteract.isModifying()?"Finish Editing":"Cancel Operation"),g(3),$(" ",t.mapInteract.isModifying()?"FINISH":"CANCEL"," ")}}function mae(n,e){if(n&1){let t=H();u(0,"fb-measurements",18),T("cancel",function(){O(t);let r=v(2);return F(r.close())}),p()}if(n&2){let t=v(2);w("coords",t.mapInteract.measurement().coords)("index",t.mapInteract.measurement().index)}}function fae(n,e){if(n&1&&(u(0,"div",1),R(1,hae,13,6,"div",11),R(2,mae,1,2,"fb-measurements",12),p()),n&2){let t=v();g(),A(t.showHelpPanel()?1:-1),g(),A(t.showMeasurePanel()?2:-1)}}var $N=class n{finish=we();cancel=we();undo=we();showHelpPanel;showMeasurePanel;isRouteEditing;canFinish;mode={iconName:"",iconText:"",description:"",steps:[]};app=M(ae);mapInteract=M(_c);constructor(){this.showHelpPanel=qt(()=>this.mapInteract.isDrawing()&&this.mapInteract.draw.resourceType!=="route"||this.mapInteract.isModifying()||this.mapInteract.isBoxSelecting()||this.mapInteract.isMeasuring()&&this.mapInteract.measureGeometryType==="Circle"),this.showMeasurePanel=qt(()=>this.mapInteract.isMeasuring()&&this.mapInteract.measureGeometryType==="LineString"),this.isRouteEditing=qt(()=>this.mapInteract.draw.resourceType==="route"&&(this.mapInteract.isDrawing()||this.mapInteract.isModifying())),this.canFinish=qt(()=>this.mapInteract.isModifying()||this.mapInteract.measurement().coords.length>=2),this.isRouteEditing()?this.mode=this.mapInteract.isDrawing()?{iconName:"edit",iconText:"Draw New Route",description:"",steps:["Click / tap the map to add each point.","Double-click, or press Finish, to end."]}:{iconName:"edit",iconText:this.mapInteract.draw.name?`Modify ${this.mapInteract.draw.name}`:"Modify Route",description:"",steps:["Click and drag to move a point.","Ctrl-Click or press-and-hold to remove a point."]}:this.showHelpPanel()&&(this.mapInteract.isDrawing()?this.mode={iconName:"edit",iconText:"Drawing Help",description:this.mapInteract.draw.resourceType==="region"?"":"Click on the Map where to drop the feature.",steps:this.mapInteract.draw.resourceType==="region"?["Click on the Map to place a vertex of the Region.","Click on the last point to end drawing."]:[]}:this.mapInteract.isModifying()?this.mode={iconName:"edit",iconText:"Modify",description:this.mapInteract.draw.forSave.id==="anchor"?"Click and drag to move anchor.":"",steps:this.mapInteract.draw.forSave.id!=="anchor"?["Click and drag to move point.","Ctrl-Click or press-and-hold to remove point from a line."]:[]}:this.mapInteract.isBoxSelecting()?this.mode={iconName:"highlight_alt",iconText:"Select",description:"",steps:["Click and drag to select area.","On touch devices, press and hold then drag."]}:this.mapInteract.isMeasuring()&&this.mapInteract.measureGeometryType==="Circle"&&(this.mode={iconName:"straighten",iconText:"Measure",description:"",steps:["Click on the Map to start.","On touch devices, press and hold then move."]}))}close(){this.cancel.emit()}finishEditing(){this.finish.emit()}undoLast(){this.undo.emit()}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["fb-interact-help"]],outputs:{finish:"finish",cancel:"cancel",undo:"undo"},decls:2,vars:1,consts:[[1,"_ap_interact_dock"],[1,"mat-app-background","_ap_interact_help"],[3,"closed","docked","canClose","title","icon"],[3,"coords","index","totalOnly","card"],[1,"_ap_steps"],[1,"_ap_action_row"],[1,"_ap_action_button"],["mat-button","","matTooltip","Undo last change (Ctrl/Cmd-Z)","matTooltipPosition","after",3,"click","disabled"],["mat-button","","color","primary","matTooltipPosition","after",3,"click","disabled","matTooltip"],["mat-button","","matTooltip","Cancel \u2014 discard changes","matTooltipPosition","after",1,"icon-warn",3,"click"],[1,"icon-warn"],[1,"mat-app-background","measurePanel"],["matTooltip","Click on the Map to start. Click cancel or the last point to end.",3,"coords","index"],[2,"font-weight","bold","padding","5px"],[2,"padding","5px"],[2,"text-align","center","padding","6px 0 8px"],["mat-raised-button","","matTooltipPosition","left",1,"icon-warn",3,"click","matTooltip"],[2,"margin-block-start","0.2em","margin-block-end","0.2em","padding-inline-start","15px"],["matTooltip","Click on the Map to start. Click cancel or the last point to end.",3,"cancel","coords","index"]],template:function(t,i){t&1&&R(0,cae,20,15,"div",0)(1,fae,3,2,"div",1),t&2&&A(i.isRouteEditing()?0:1)},dependencies:[le,ce,ue,Xe,Pe,Et,N2,pr],styles:["._ap_interact_help[_ngcontent-%COMP%]{position:fixed;min-width:200px;top:60px;left:50px;border:black 1px solid;font-family:roboto;font-size:10pt}._ap_interact_dock[_ngcontent-%COMP%]{position:fixed;top:60px;left:50px;font-family:roboto;font-size:10pt}._ap_steps[_ngcontent-%COMP%]{margin-block-start:.2em;margin-block-end:.4em;padding-inline-start:18px}._ap_action_row[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap}._ap_action_button[_ngcontent-%COMP%]{flex:1 1 45%}._ap_row[_ngcontent-%COMP%]{display:flex;flex-wrap:no-wrap;flex:2}._ap_row[_ngcontent-%COMP%] .icon-label[_ngcontent-%COMP%]{width:30px}._ap_row[_ngcontent-%COMP%] .row-label[_ngcontent-%COMP%]{font-weight:500;min-width:60px}._ap_measurements[_ngcontent-%COMP%] .value[_ngcontent-%COMP%]{padding-right:10px}@media only screen and (max-width:500px){._ap_measurements[_ngcontent-%COMP%]{left:0;width:100%}}"],changeDetection:0})};var qN=70,gae=40,Pt=class n{reOpen;app=M(ae);dialog=M(xn);chartPaletteRef;chartPaletteEdit;signalk=M(Ot);worker=M(Wn);mapInteract=M(_c);constructor(){this.worker.resource$().subscribe(e=>this.processResourceMessage(e))}selectionIsFiltered(e){return Array.isArray(this.app.config.selections[e])}selectionHas(e,t){return!this.app.config.selections[e]||!this.selectionIsFiltered(e)?!1:this.app.config.selections[e].includes(t)}selectionAdd(e,t){if(!(typeof this.app.config.selections[e]>"u")&&this.selectionIsFiltered(e)){let i=typeof t=="string"?[t]:t;i=i.filter(r=>!this.app.config.selections[e].includes(r)),this.app.config.selections[e]=this.app.config.selections[e].concat(i),this.app.saveConfig()}}selectionRemove(e,t){if(!(typeof this.app.config.selections[e]>"u")&&this.selectionIsFiltered(e)){let i=typeof t=="string"?[t]:t;this.app.config.selections[e]=this.app.config.selections[e].filter(r=>!i.includes(r)),this.app.saveConfig()}}selectionUnfilter(e){this.app.config.selections[e]=null,this.app.saveConfig()}selectionClear(e){this.app.config.selections[e]=[],this.app.saveConfig()}selectionClean(e,t){Array.isArray(this.app.config.selections[e])&&(this.app.config.selections[e]=this.app.config.selections[e].filter(i=>t.includes(i)),this.app.saveConfig())}fetchRelatedNotes(e,t){return J(this,null,function*(){try{return yield this.listFromServer("notes",`href=/resources/${e}/${t}`)}catch(i){return[]}})}getCacheRef(e){switch(e){case"routes":return this.routeCacheSignal;case"waypoints":return this.waypointCacheSignal;case"notes":return this.noteCacheSignal;case"regions":return this.regionCacheSignal;case"charts":return this.chartCacheSignal;case"tracks":return this.trackCacheSignal}}fromCache(e,t){if(["routes","waypoints","notes","regions","charts","tracks"].includes(e)){let i=this.getCacheRef(e);if(!i){this.app.showAlert("Error","Collection not found!");return}return i().find(r=>r[0]===t)}else return!this.app.data[e]||!Array.isArray(this.app.data[e])?void 0:this.app.data[e].find(r=>r[0]===t)??void 0}listFromServer(e,t){return t?t=t.startsWith("?")?t:`?${t}`:t="",new Promise((i,r)=>{this.signalk.api.get(this.app.skApiVersion,`/resources/${e}${t}`)?.subscribe(a=>{let s=[];Object.keys(a).forEach(l=>{s.push([l,this.transform(e,a[l],l),this.selectionIsFiltered(e)?this.selectionHas(e,l):!0])}),i(s)},a=>r(a))})}fromServer(e,t){return new Promise((i,r)=>{this.signalk.api.get(this.app.skApiVersion,`/resources/${e}/${t}`).subscribe(o=>i(this.transform(e,o,t)),o=>r(o))})}transform(e,t,i){switch(e){case"regions":return this.transformRegion(t,i);case"routes":return this.transformRoute(t,i);case"waypoints":return this.transformWaypoint(t,i);case"notes":return this.transformNote(t,i);case"charts":return this.transformChart(t,i);case"tracks":return this.transformTrack(t)}}deleteFromServer(e,t,i){let r=i?`?provider=${i}`:"";return new Promise((o,a)=>{this.signalk.api.delete(this.app.skApiVersion,`/resources/${e}/${t}${r}`).subscribe(()=>o(),s=>a(s))})}putToServer(e,t,i,r){let o=r?`?provider=${r}`:"";return new Promise((a,s)=>{this.signalk.api.put(this.app.skApiVersion,`/resources/${e}/${t}${r?o:""}`,i).subscribe(l=>a(l),l=>s(l))})}postToServer(e,t){return new Promise((i,r)=>{this.signalk.api.post(this.app.skApiVersion,`/resources/${e}`,t).subscribe(o=>i(o),o=>r(o))})}processResourceMessage(e){if(!Array.isArray(e))return;let t={routes:!1,waypoints:!1,notes:!1,regions:!1,charts:!1};e.forEach(i=>{let r=i.path.split(".");if(r.length===3){let o=r[1],a=r[2];o in t&&(t[o]=!0),this.selectionIsFiltered(o)&&!i.value&&this.app.config.selections[o].includes(a)&&(this.app.config.selections[o].splice(this.app.config.selections[o].indexOf(a),1),this.app.saveConfig())}}),t.routes&&this.refreshRoutes(),t.waypoints&&this.refreshWaypoints(),t.regions&&this.refreshRegions(),t.notes&&this.refreshNotes(),t.charts&&this.refreshCharts()}resourceProperties(e){switch(e.type){case"waypoint":this.editWaypointInfo(e.id);break;case"route":this.editRouteInfo(e.id);break;case"note":this.showNoteDetails(e.id);break;case"region":this.editRegionInfo(e.id);break;case"chart":this.editChartInfo(e.id);break;case"track":this.editTrackInfo(e.id);break}}chartCacheSignal=X([]);charts=this.chartCacheSignal.asReadonly();appendOSM(e){let t=[["openstreetmap",new bs({name:"World Map",description:"Open Street Map"}),this.app&&this.selectionIsFiltered("charts")?this.app.config.selections.charts.includes("openstreetmap"):!0],["openseamap",new bs({name:"Sea Map",description:"Open Sea Map",url:"https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png",minzoom:1,maxzoom:24,bounds:[-180,-90,180,90],type:"tilelayer"}),this.app&&this.selectionIsFiltered("charts")?this.app.config.selections.charts.includes("openseamap"):!0]];return this.app&&t.forEach(i=>{let r=this.app.config.selections.chartOpacity[i[0]];typeof r<"u"&&(i[1].defaultOpacity=r);let o=this.app.config.selections.chartImageAdjustment?.[i[0]];typeof o<"u"&&(i[1].imageAdjustment=o);let a=this.app.config.selections.chartDisplayMinZoom?.[i[0]];typeof a<"u"&&(i[1].displayMinZoom=a)}),e.push(t[1]),e.unshift(t[0]),e}refreshCharts(e){return J(this,null,function*(){e&&e[0]!=="?"&&(e="?"+e),this.app.debug(`** refreshCharts(): ${e}`);try{let t=yield this.listFromServer("charts",e);this.appendOSM(t);let i=t.filter(r=>r[2]);i=this.sortByScaleDesc(i),i=this.arrangeChartLayers(i),this.chartCacheSignal.set(i),this.setMapZoomRange()}catch(t){this.app.debug("** refreshCharts:",t);let i=this.appendOSM([]);this.chartCacheSignal.set(i),this.setMapZoomRange()}})}transformChart(e,t){e.tilemapUrl&&(e.url=e.tilemapUrl),e.chartLayers&&(e.layers=e.chartLayers),e.serverType&&!e.type&&(e.type=e.serverType),e.type&&(e.url.startsWith("/")||!e.url.startsWith("http"))&&(e.url=this.app.hostDef.url+e.url),typeof this.app.config.selections.chartOpacity[t]<"u"&&(e.defaultOpacity=this.app.config.selections.chartOpacity[t]);let i=this.app.config.selections.chartImageAdjustment?.[t];typeof i<"u"&&(e.imageAdjustment=i);let r=this.app.config.selections.chartDisplayMinZoom?.[t];return typeof r<"u"&&(e.displayMinZoom=r),new bs(e)}setMapZoomRange(e){let t={min:2,max:28};if(e||!this.app.uiConfig().mapConstrainZoom)this.app.MAP_ZOOM_EXTENT=t;else{let i={min:1e3,max:-1};this.chartCacheSignal().forEach(r=>{r[2]&&(r[1].minZoom<i.min&&(i.min=r[1].minZoom),r[1].maxZoom>i.max&&(i.max=r[1].maxZoom))}),this.app.MAP_ZOOM_EXTENT={min:i.min===1e3?t.min:i.min,max:i.max===-1?t.max:i.max},this.app.debug("*** MAP_ZOOM_EXTENT",this.app.MAP_ZOOM_EXTENT)}}deleteChart(e){e&&this.app.showConfirm(`Do you want to delete this Chart source?
|
|
1123
|
+
`],encapsulation:2,changeDetection:0})}return n})(),MN=(()=>{class n extends vN{static \u0275fac=(()=>{let t;return function(r){return(t||(t=$r(n)))(r||n)}})();static \u0275dir=lt({type:n,selectors:[["button","matStepperNext",""]],hostAttrs:[1,"mat-stepper-next"],hostVars:1,hostBindings:function(i,r){i&2&&Mo("type",r.type)},features:[Qe]})}return n})();var Df=(()=>{class n{static \u0275fac=function(i){return new(i||n)};static \u0275mod=Di({type:n});static \u0275inj=Ii({providers:[$p],imports:[Wp,bN,le,Ts,P_,SE,An]})}return n})();var EE=Ma(Os());var dn=class n{symDegree="\xBA";transform(e,t,i){let r=i?e<0?"S":"N":e<0?"W":"E";switch(t){case"SHDd":return this.toHDdSigned(e,r);case"DMdH":return this.toDMdH(e,r);case"HDd":return this.toHDd(e,r);case"HDMS":return this.toHDMS(e,r);case"DHMS":return this.toDHMS(e,r);default:return this.toXY(e)}}toXY(e,t=5){return e.toFixed(t)}toHDdSigned(e,t,i=5){let r=["S","W"].includes(t)?`${t} -`:`${t} +`,o=e.toFixed(i);return o=o.substring(o.indexOf(".")),`${r}${Math.floor(Math.abs(e))}${o}${this.symDegree}`}toDMdH(e,t,i=5){let r=Math.floor(Math.abs(e))??0,a=(Math.abs(r===0?e:e%r)*60).toFixed(i),s=["N","S"].includes(t)?"00":"000";return`${(s+r.toString()).slice(0-s.length)}${this.symDegree} ${a}' ${t}`}toHDd(e,t,i=5){let r=e.toFixed(i);return r=r.substring(r.indexOf(".")),`${t} ${Math.floor(Math.abs(e))}${r}${this.symDegree}`}toHDMS(e,t){return`${t} ${(0,EE.decimalToSexagesimal)(e)}`}toDHMS(e,t){let i=(0,EE.decimalToSexagesimal)(e);return i=i.slice(0,i.indexOf(" ")-1)+t+i.slice(i.indexOf(" ")+1),i}static \u0275fac=function(t){return new(t||n)};static \u0275pipe=Bp({name:"coords",type:n,pure:!0})};function Qre(n,e){if(n&1&&(u(0,"span",4),_(1),p()),n&2){let t=v().$implicit;g(),q(t[1])}}function Jre(n,e){if(n&1&&(u(0,"div",7),_(1),wt(2,"coords"),p()),n&2){let t=v(2).$implicit,i=v();w("matTooltip",t[2]),g(),$(" ",Oi(2,2,t[2],i.app.config.units.positionFormat,!0)," ")}}function eoe(n,e){if(n&1&&(u(0,"div",7),_(1),wt(2,"coords"),p()),n&2){let t=v(2).$implicit,i=v();w("matTooltip",t[2]),g(),$(" ",Oi(2,2,t[2],i.app.config.units.positionFormat,!1)," ")}}function toe(n,e){if(n&1&&(u(0,"div",7),_(1),p()),n&2){let t=v(2).$implicit;w("matTooltip",t[2]),g(),q(t[2])}}function ioe(n,e){if(n&1&&(u(0,"div",5)(1,"div",6),_(2),p(),R(3,Jre,3,6,"div",7)(4,eoe,3,6,"div",7)(5,toe,2,2,"div",7),p()),n&2){let t=v().$implicit;g(),w("matTooltip",t[1]),g(),q(t[1]),g(),A(t[1]==="latitude"?3:t[1]==="longitude"?4:5)}}function noe(n,e){if(n&1&&(u(0,"div",3),R(1,Qre,2,1,"span",4),R(2,ioe,6,3,"div",5),p()),n&2){let t=e.$implicit;g(),A(t[0]===0&&t[2]===null?1:-1),g(),A(t[2]!==null?2:-1)}}var Sd=class n{title=Z("");details=Z();items;app=M(ae);constructor(){}ngOnChanges(){this.details()?this.parseEntries():this.items=[]}parseEntries(){let e=Object.entries(this.details());e.sort((t,i)=>t[0]<i[0]?-1:1),this.items=this.section(this.flatten(e))}section(e){let t=[];e.forEach(o=>{let a=o[0].split(".");if(a.length===1)t.push([0,"",a[0],typeof o[1]!="object"?o[1]:null]);else{let s=a.slice(0,a.length-1).join(".");t.push([a.length-1,s,a[a.length-1],o[1]])}}),t.sort((o,a)=>o[1]<a[1]?-1:1);let i=null,r=[];return e=[],t.forEach(o=>{o[1]!==i&&(i=o[1],r.indexOf(o[1])===-1&&(r.push(o[1]),e.push([0,o[1],null]))),e.push([o[0],o[2],o[3]])}),e}flatten(e){let t=[];return e.forEach(i=>{typeof i[1]=="object"&&i[1]!==null?t=t.concat(this.processObject(i[0],i[1])):t.push([i[0],i[1]])}),t}processObject(e,t){let i=[],r=Object.entries(t);return r.sort((o,a)=>o[0]<a[0]?-1:1),r.forEach(o=>{typeof o[1]=="object"&&o[1]!==null?i=i.concat(this.processObject(e+"."+o[0],o[1])):i.push([e+"."+o[0],o[1]])}),i}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["signalk-details-list"]],inputs:{title:[1,"title"],details:[1,"details"]},features:[Se],decls:7,vars:1,consts:[[1,"sk-details"],[1,"title"],[1,"content"],[1,"item"],[1,"sectionname"],[1,"pathvalue"],[1,"path",3,"matTooltip"],[1,"value",3,"matTooltip"]],template:function(t,i){t&1&&(u(0,"div",0)(1,"div",1)(2,"div"),_(3),p()(),u(4,"div",2),Le(5,noe,3,2,"div",3,gt),p()()),t&2&&(g(3),q(i.title()),g(2),Ae(i.items))},dependencies:[be,Pe,dn],styles:[".sk-details[_ngcontent-%COMP%]{position:relative;display:flex;flex-direction:column;font-family:Roboto,Arial,Helvetica,sans-serif;font-size:10pt;max-height:100%}.sk-details[_ngcontent-%COMP%] .title[_ngcontent-%COMP%]{background:left 1px -webkit-gradient(linear,left top,left bottom,from(rgba(0,0,0,.18)),color-stop(.65,transparent)) #b2bbc2e3;padding:3px 5px 0;font-weight:500;line-height:23px}.sk-details[_ngcontent-%COMP%] .content[_ngcontent-%COMP%]{padding:0;line-height:23px;margin:0;flex:1 1 auto;overflow:auto}.sk-details[_ngcontent-%COMP%] .item[_ngcontent-%COMP%]{display:flex;flex-direction:row;line-height:26px;border-width:0 0 0 0;border-style:solid;border-color:gray;padding-left:5px}.sk-details[_ngcontent-%COMP%] .content[_ngcontent-%COMP%] .item[_ngcontent-%COMP%]{border-width:0 0 1px 0}.sk-details[_ngcontent-%COMP%] .sectionname[_ngcontent-%COMP%]{text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%;font-weight:500}.sk-details[_ngcontent-%COMP%] .pathvalue[_ngcontent-%COMP%]{display:flex;flex-wrap:nowrap;width:100%}.sk-details[_ngcontent-%COMP%] .pathvalue[_ngcontent-%COMP%] .path[_ngcontent-%COMP%]{text-align:left;width:60%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-style:italic}.sk-details[_ngcontent-%COMP%] .pathvalue[_ngcontent-%COMP%] .value[_ngcontent-%COMP%]{text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}"],changeDetection:0})};var NE=Ma(RN());var _c=class n{isMeasuring=X(!1);isDrawing=X(!1);isModifying=X(!1);isBoxSelecting=X(!1);measurement=X({coords:[],index:-1,center:null,radius:0});selection=X({mode:null});selectionResult;measureGeometryType="LineString";draw={resourceType:null,featureType:"Point",coordinates:null,features:null,forSave:null,properties:{}};modifyUndoStack=[];undoDepth=X(0);canUndo=qt(()=>this.isDrawing()?this.measurement().coords.length>=1:this.isModifying()?this.undoDepth()>0:!1);app=M(ae);constructor(){}pushModifyUndo(e){this.modifyUndoStack.push(e),this.undoDepth.set(this.modifyUndoStack.length)}popModifyUndo(){let e=this.modifyUndoStack.pop();return this.undoDepth.set(this.modifyUndoStack.length),e}clearUndo(){this.modifyUndoStack=[],this.undoDepth.set(0)}initBoxCoord(e){this.selectionResult||(this.selectionResult={mode:null}),this.selectionResult.bbox=[e]}set measurementCoords(e){this.measurement.update(t=>Object.assign({},t,{coords:e}))}set measurementIndex(e){this.measurement.update(t=>Object.assign({},t,{index:e}))}set measurementCenter(e){this.measurement.update(t=>Object.assign({},t,{center:e}))}set measurementRadius(e){this.measurement.update(t=>Object.assign({},t,{radius:e}))}addMeasurementCoord(e){let t=oi.distanceTo(this.measurement().coords[this.measurement().coords.length-1],e);return this.measurement.update(i=>{let r=[].concat(i.coords);return r.push(e),Object.assign({},i,{coords:r})}),t}distanceFromLastPoint(e){return e&&this.measurement().coords.length>0?oi.distanceTo(this.measurement().coords[this.measurement().coords.length-1],e):0}distanceFromCenter(e){return!e||!this.measurement().center?0:oi.distanceTo(this.measurement().center,e)}startMeasuring(e,t){this.measureGeometryType=e??"LineString",this.app.debug("startMeasuring()..."),this.isMeasuring.set(!0),this.interactionStarted()}stopMeasuring(){this.app.debug("stopMeasuring()..."),this.isMeasuring.set(!1),this.interactionEnded()}startDrawing(e){this.app.debug("startDrawing()..."),this.isDrawing.set(!0),this.draw.name=void 0,this.draw.resourceType=e,this.draw.featureType=e==="route"?"LineString":e==="region"?"Polygon":"Point",this.interactionStarted()}stopDrawing(e){if(this.app.debug("stopDrawing()..."),this.isDrawing.set(!1),e)switch(this.draw.featureType){case"Point":this.draw.coordinates=ln(e.getGeometry().getCoordinates());break;case"LineString":let t=e.getGeometry().getCoordinates();this.draw.coordinates=t.map(r=>ln(r));break;case"Polygon":let i=e.getGeometry().getCoordinates();i.length===0&&(this.draw.coordinates=[]),this.draw.coordinates=i[0].map(r=>ln(r));break}this.interactionEnded()}startModifying(e){this.app.debug("startModifying()..."),this.draw.features.getLength()!==0&&(this.isModifying.set(!0),this.draw.name=void 0,this.draw.resourceType=e.type,this.draw.featureType=null,this.draw.forSave={id:null,coords:null},this.draw.coordinates=null,this.draw.properties={},this.interactionStarted())}stopModifying(){this.app.debug("stopModifying()..."),this.isModifying.set(!1),this.draw.features=null,this.interactionEnded()}startBoxSelection(e,t){this.app.debug("startBoxSelection()..."),this.selectionResult={mode:e,data:t,bbox:[]},this.isBoxSelecting.set(!0),this.interactionStarted()}stopBoxSelection(e){this.app.debug("stopBoxSelection()..."),e&&(this.selectionResult.bbox.push(e),this.formatBbox(),this.selection.update(()=>this.selectionResult)),this.isBoxSelecting.set(!1),this.interactionEnded()}formatBbox(){if(this.selectionResult.bbox.length!==2)return;let e=[].concat(this.selectionResult.bbox);this.selectionResult.bbox=[[e[0][0]<e[1][0]?e[0][0]:e[1][0],e[0][1]<e[1][1]?e[0][1]:e[1][1]],[e[0][0]>e[1][0]?e[0][0]:e[1][0],e[0][1]>e[1][1]?e[0][1]:e[1][1]]]}interactionStarted(){this.app.debug("interactionStarted()..."),this.clearUndo(),this.measurement.set({coords:[],index:-1,center:null,radius:0}),this.app.uiCtrl.update(e=>Object.assign({},e,{suppressContextMenu:!0}))}interactionEnded(){this.app.debug("interactionEnded()..."),this.clearUndo(),this.app.uiCtrl.update(e=>Object.assign({},e,{suppressContextMenu:!1})),this.measurement.set({coords:[],index:-1,center:null,radius:0})}static \u0275fac=function(t){return new(t||n)};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})};var vs=class{name;description;distance=0;feature;constructor(e){this.name=e?.name?e.name:"",this.description=e?.description?e.description:"",this.distance=e?.distance?e.distance:0,this.feature=e?.feature??{type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:{},id:""}}},Td=class{name;description;feature;type;constructor(e){this.name=e?.name?e.name:"",this.description=e?.description?e.description:"",this.type=e?.type?e.type:"",this.feature=e?.feature??{type:"Feature",geometry:{type:"Point",coordinates:[0,0]},properties:{},id:""}}},Ed=class{name;description;position;href;mimeType;url;group;authors;properties;constructor(e){this.name=e?.name??"",this.description=e?.description??"",this.position=e?.position,this.href=e?.href,this.mimeType=e?.mimeType??"",this.url=e?.url??"",this.group=e?.group,this.authors=e?.authors&&Array.isArray(e?.authors)?e.authors:[],this.properties=e?.properties&&typeof e?.properties=="object"?e.properties:{}}},Id=class{name;description;feature;constructor(e){this.name=e?.name?e.name:"",this.description=e?.description?e.description:"",this.feature=e?.feature??{type:"Feature",geometry:{type:"Polygon",coordinates:[]},properties:{},id:""}}},bs=class{identifier;name;description;region;scale=25e4;layers;bounds;format;minZoom=0;maxZoom=24;tileSize=256;type;url;source;style;defaultOpacity;imageAdjustment;displayMinZoom;proxy;constructor(e){let t=e;this.identifier=e?.identifier?e.identifier:void 0,this.name=e?.name?e.name:void 0,this.description=e?.description?e.description:void 0,this.layers=e?.layers?e.layers:[],this.bounds=e?.bounds?e.bounds:void 0,this.format=e?.format?e.format:void 0,this.minZoom=t?.minzoom??t?.minZoom??this.minZoom,this.maxZoom=t?.maxzoom??t?.maxZoom??this.maxZoom,this.tileSize=typeof e?.tileSize<"u"?e.tileSize:this.tileSize,this.type=e?.type?e.type:void 0,this.url=e?.url?e.url:void 0,this.scale=typeof e?.scale<"u"&&!isNaN(e?.scale)?e.scale:this.scale,this.style=e?.style??void 0,this.source=t?.$source??t?.source??void 0,this.defaultOpacity=e?.defaultOpacity??1,this.imageAdjustment=e?.imageAdjustment,this.displayMinZoom=e?.displayMinZoom,this.proxy=e?.proxy??!1}},Af=class{name;description;feature;constructor(e){this.feature=e?.feature??{type:"Feature",geometry:{type:"MultiLineString",coordinates:[]},properties:{},id:""},this.name=this.feature.properties?.name??"",this.description=this.feature.properties?.description??""}},DE=class{id;name;mmsi;position=[0,0];positionReceived=!1;positionTimestamp="";positionUpdatedAt=0;state;type={id:-1,name:""};properties={};lastUpdated=new Date;callsignVhf;callsignHf;orientation=0;virtual},Md=class extends DE{anchor={maxRadius:null,radius:null,position:null};autopilot={state:null,mode:null,target:null,enabled:!1,default:null,availableActions:[]};buddy=!1;closestApproach={distance:null,timeTo:null};cog;cogTrue=null;cogMagnetic=null;courseApi={arrivalCircle:0,activeRoute:{},nextPoint:{},previousPoint:{}};courseCalcs={};distanceToSelf;environment={mode:null,sun:null};heading;headingTrue=null;headingMagnetic=null;performance={beatAngle:null,gybeAngle:null};racing;radars={};registrations={};resourceUpdates=[];sog;track=[];vectors={cog:[]};wind={direction:null,mwd:null,twd:null,tws:null,speedTrue:null,sog:null,awa:null,aws:null};design={airHeight:null,beam:null,draft:{current:null,maximum:null},length:null};destination={name:null,eta:null};flag;port};function doe(n,e){if(n&1&&(u(0,"div",7)(1,"div",4),z(2,"span",13),wt(3,"coords"),z(4,"br")(5,"span",13),wt(6,"coords"),p(),u(7,"div"),z(8,"span",13),wt(9,"coords"),z(10,"br")(11,"span",13),wt(12,"coords"),p()()),n&2){let t=v();g(2),w("innerText",Oi(3,4,t.data.bbox[1][1],"HDd",!0)),g(3),w("innerText",Xn(6,8,t.data.bbox[1][0],"HDd")),g(3),w("innerText",Oi(9,11,t.data.bbox[0][1],"HDd",!0)),g(3),w("innerText",Xn(12,15,t.data.bbox[0][0],"HDd"))}}function uoe(n,e){if(n&1&&(u(0,"mat-option",10),_(1),p()),n&2){let t=e.$implicit;w("value",t),g(),q(t)}}var O2=class n{icon;zoomRange=[];selZoom;app=M(ae);dialogRef=M(di);data=M(ui);constructor(){}ngOnInit(){let e=this.data.chart[1].minZoom??1,t=this.data.chart[1].maxZoom??15;this.selZoom=t;for(let i=e;i<=t;i++)this.zoomRange.push(i)}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-chartproperties"]],decls:26,vars:3,consts:[[1,"_ap-chartjob"],[2,"background-color","transparent"],[1,"dialog-icon"],[2,"flex","1 1 auto","text-align","center"],[2,"text-align","right"],["mat-icon-button","",3,"click"],[2,"flex","1 1 auto"],[2,"flex","1 1 auto","border","gray 1px solid","font-size","10pt"],[2,"width","100%"],[3,"ngModelChange","ngModel"],[3,"value"],["align","right"],["mat-flat-button","",3,"click"],[2,"flex","1 1 auto",3,"innerText"]],template:function(t,i){t&1&&(u(0,"div",0)(1,"mat-toolbar",1)(2,"span",2)(3,"mat-icon"),_(4,"download"),p()(),u(5,"span",3),_(6,"Chart Seed job"),p(),u(7,"span",4)(8,"button",5),T("click",function(){return i.dialogRef.close(-1)}),u(9,"mat-icon"),_(10,"close"),p()()()(),u(11,"mat-dialog-content")(12,"div")(13,"div",6),_(14),p(),R(15,doe,13,18,"div",7),u(16,"div",6)(17,"mat-form-field",8)(18,"mat-label"),_(19,"Max. Zoom Level"),p(),u(20,"mat-select",9),bt("ngModelChange",function(o){return vt(i.selZoom,o)||(i.selZoom=o),o}),Le(21,uoe,2,2,"mat-option",10,gt),p()()()()(),u(23,"mat-dialog-actions",11)(24,"button",12),T("click",function(){return i.dialogRef.close(i.selZoom)}),_(25," Submit "),p()()()),t&2&&(g(14),q(i.data.chart[1].name),g(),A(i.data.bbox?15:-1),g(5),yt("ngModel",i.selZoom),g(),Ae(i.zoomRange))},dependencies:[be,le,ce,Ze,ue,Xe,Fe,Et,kt,pi,Si,_i,Ps,Ut,Wt,zl,Gl,St,Yi,Qi,dn],styles:["._ap-chartjob[_ngcontent-%COMP%]{font-family:arial;min-width:300px}.ap-confirm-icon[_ngcontent-%COMP%]{min-width:35px;max-width:35px;color:#ff8c00;text-align:left}._ap-chartjob[_ngcontent-%COMP%] .key-label[_ngcontent-%COMP%]{width:150px;font-weight:500}@media only screen and (min-device-width:768px)and (max-device-width:1024px),only screen and (min-width:800px){.ap-confirm-icon[_ngcontent-%COMP%]{min-width:25%;max-width:25%}}"]})};function poe(n,e){if(n&1&&(pn(0,"span",2),_(1),En()),n&2){let t=v();g(),$("(",t.subTitle(),")")}}function hoe(n,e){if(n&1&&(pn(0,"span",2),_(1),En()),n&2){let t=v();g(),$(" (",t.subTitle(),") ")}}var kE=".dial-text[_ngcontent-%COMP%]{padding:0 10px;height:96px;font-family:roboto;border:transparent 1px solid}.dial-text-title[_ngcontent-%COMP%]{font-size:12pt;font-weight:500}.dial-text-subtitle[_ngcontent-%COMP%]{font-size:8pt;font-weight:500}.dial-text-value[_ngcontent-%COMP%]{font-size:22pt;font-weight:500}.dial-text-units[_ngcontent-%COMP%]{font-size:10pt}";function moe(n,e){if(n&1&&(pn(0,"span",2),_(1),En()),n&2){let t=v();g(),$(" (",t.subTitle(),") ")}}var LN=class n{title=Z();subTitle=Z();value=Z();units=Z();static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-dial-text"]],inputs:{title:[1,"title"],subTitle:[1,"subTitle"],value:[1,"value"],units:[1,"units"]},decls:8,vars:4,consts:[[1,"dial-text","mat-app-background"],[1,"dial-text-title"],[1,"dial-text-subtitle"],[1,"dial-text-value"],[1,"dial-text-units"]],template:function(t,i){t&1&&(pn(0,"div",0)(1,"div",1),_(2),R(3,poe,2,1,"span",2),En(),pn(4,"div",3),_(5),En(),pn(6,"div",4),_(7),En()()),t&2&&(g(2),$(" ",i.title(),"\xA0 "),g(),A(i.subTitle()?3:-1),g(2),q(i.value()),g(2),q(i.units()))},styles:[kE],changeDetection:0})},AN=class n{value=Z();subTitle=Z();ttg="--";units="min";constructor(){Me(()=>{let e=this.value();if(typeof e!="number")this.ttg="--",this.units="min";else if(e<60)this.ttg=Math.floor(e).toString(),this.units="min";else if(e<1440)this.ttg=`${Math.floor(e/60)}:${("00"+(e%60).toFixed(0)).slice(-2)}`,this.units="hr:min";else{let i=Math.floor(e/1440),r=i*1440,o=e-r,a=Math.floor(o/60),s=`00${Math.floor(o-a*60)}`.slice(-2);this.ttg=`${i}:${("00"+a).slice(-2)}:${s}`,this.units="day:hr:min"}})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-dial-ttg"]],inputs:{value:[1,"value"],subTitle:[1,"subTitle"]},decls:8,vars:3,consts:[[1,"dial-text","mat-app-background"],[1,"dial-text-title"],[1,"dial-text-subtitle"],[1,"dial-text-value"],[1,"dial-text-units"]],template:function(t,i){t&1&&(pn(0,"div",0)(1,"div",1),_(2," TTG\xA0 "),R(3,hoe,2,1,"span",2),En(),pn(4,"div",3),_(5),En(),pn(6,"div",4),_(7),En()()),t&2&&(g(3),A(i.subTitle()?3:-1),g(2),q(i.ttg),g(2),q(i.units))},styles:[kE],changeDetection:0})},ON=class n{value=Z();subTitle=Z();etaTime="--";etaDate="--";constructor(){Me(()=>{this.value()&&(this.etaTime=this.value().toLocaleTimeString().split(":").slice(0,2).join(":"),this.etaDate=this.value().toLocaleDateString())})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-dial-eta"]],inputs:{value:[1,"value"],subTitle:[1,"subTitle"]},decls:8,vars:3,consts:[[1,"dial-text","mat-app-background"],[1,"dial-text-title"],[1,"dial-text-subtitle"],[1,"dial-text-value"],[1,"dial-text-units"]],template:function(t,i){t&1&&(pn(0,"div",0)(1,"div",1),_(2," ETA\xA0 "),R(3,moe,2,1,"span",2),En(),pn(4,"div",3),_(5),En(),pn(6,"div",4),_(7),En()()),t&2&&(g(3),A(i.subTitle()?3:-1),g(2),q(i.etaTime),g(2),q(i.etaDate))},styles:[kE],changeDetection:0})};var foe=["*"],goe=n=>({disabled:n});function _oe(n,e){if(n&1&&(u(0,"span")(1,"i",6),_(2,"upload"),p(),_(3," \xA0"),u(4,"span",7),_(5),p()()),n&2){let t=v();g(5),q(t.label())}}function yoe(n,e){if(n&1){let t=H();u(0,"button",9),T("click",function(){O(t);let r=v(2);return F(r.clear())}),_(1,"Clear"),p()}}function voe(n,e){if(n&1&&(u(0,"div",5),z(1,"img",8),R(2,yoe,2,0,"button"),p()),n&2){let t=v();g(),st("src",t.avatar,Mc),g(),A(t.avatar?2:-1)}}var FN=class n{disabled=Z(!1);multiple=Z(!1);maxfilesize=Z(void 0);accept=Z("");astext=Z(!1);preview=Z(!1);icon=Z(!1);label=Z("Upload File");chosen=we();invalid=we();cleared=we();avatar=null;changeDetectorRef=M(re);constructor(){}fileChange(e){this.readFiles(e.files)}dragOver(e){e.preventDefault()}drop(e){e.preventDefault(),e.dataTransfer.files&&e.dataTransfer.files.length>0&&this.readFiles(e.dataTransfer.files)}clear(){this.avatar=null,this.cleared.emit()}readFiles(e,t=0){let i=new FileReader,r={type:"",value:"",message:""};if(t in e){if(this.maxfilesize()&&e[t].size>this.maxfilesize()){r.type="SIZE",r.value=e[t].size,r.message=`File size exceeds the accepted maximum size of ${this.maxfilesize()}`,this.invalid.emit(r);return}if(this.accept().indexOf("/*")!==-1){let o=e[t].type.substring(0,e[t].type.indexOf("/"));if(this.accept().indexOf(o)<0){r.type="TYPE",r.value=e[t].type,r.message=`File type does not match the accepted type (${this.accept()}) specified.`,this.invalid.emit(r);return}}this.readFile(e[t],i,o=>{t===0&&this.preview()&&(this.avatar=o),this.chosen.emit({name:e[t].name,data:o}),this.readFiles(e,t+1)})}else this.changeDetectorRef.detectChanges()}readFile(e,t,i){t.onload=()=>{i(t.result)},e.type.indexOf("text")!==-1||this.astext()?t.readAsText(e):t.readAsDataURL(e)}resize(e,t,i,r){return e.onload=()=>{let o=e.width,a=e.height;o>a?o>t&&(a*=t/o,o=t):a>i&&(o*=i/a,a=i);let s=document.createElement("canvas");s.width=o,s.height=a,s.getContext("2d").drawImage(e,0,0,o,a);let c=s.toDataURL("image/jpeg");r(c,e.src.length,c.length)}}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-file-input"]],inputs:{disabled:[1,"disabled"],multiple:[1,"multiple"],maxfilesize:[1,"maxfilesize"],accept:[1,"accept"],astext:[1,"astext"],preview:[1,"preview"],icon:[1,"icon"],label:[1,"label"]},outputs:{chosen:"chosen",invalid:"invalid",cleared:"cleared"},ngContentSelectors:foe,decls:8,vars:8,consts:[["input",""],[1,"ap-file-input",3,"dragover","drop"],["id","ctrl",3,"ngClass"],["mat-menu-item",""],["type","file",2,"display","none",3,"change","click","multiple","disabled","accept"],["id","avatar",2,"display","inline-flex"],[1,"material-icons"],[2,"font-size","10pt"],["alt",""],[3,"click"]],template:function(t,i){if(t&1){let r=H();fe(),u(0,"div",1),T("dragover",function(a){return i.dragOver(a)})("drop",function(a){return i.drop(a)}),u(1,"div",2)(2,"label",3),de(3),R(4,_oe,6,1,"span"),u(5,"input",4,0),T("change",function(){O(r);let a=Oe(6);return F(i.fileChange(a))})("click",function(){O(r);let a=Oe(6);return F(a.value=null)}),p()()(),R(7,voe,3,2,"div",5),p()}t&2&&(g(),w("ngClass",an(6,goe,i.disabled())),g(3),A(i.icon()?4:-1),g(),w("multiple",i.multiple())("disabled",i.disabled())("accept",i.accept()),g(2),A(i.preview()&&i.avatar?7:-1))},dependencies:[hn,Ln],styles:[".ap-file-input[_ngcontent-%COMP%]{display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:inline-flex;-moz-flex-direction:row;-ms-flex-direction:row;-webkit-flex-direction:row;flex-direction:row;flex-wrap:nowrap;justify-content:flex-start;align-content:stretch;width:100%}#ctrl[_ngcontent-%COMP%], #ctrl[_ngcontent-%COMP%] label[_ngcontent-%COMP%]{cursor:pointer}#apfileinput[_ngcontent-%COMP%]{position:absolute;top:0;left:-9000px;width:.1px;height:.1px;opacity:0;overflow:hidden;z-index:-1}.disabled[_ngcontent-%COMP%]{color:#21212180!important;border-color:#21212180!important;cursor:none!important}#avatar[_ngcontent-%COMP%]{background-color:inherit;border-radius:5px;height:42px}#avatar[_ngcontent-%COMP%] > img[_ngcontent-%COMP%]{width:42px;height:42px}#avatar[_ngcontent-%COMP%] > button[_ngcontent-%COMP%]{background-color:inherit;border:0;color:red}"]})};var boe=["vid"],NN=class n{pipVideo;pipWindow;pipMode=!1;vidUrl;src=Z();muted=Z(!0);_muted=Ta(()=>this.muted());resize=we();change=we();click=we();vid;constructor(){Me(()=>{this.src()&&(this.vidUrl=this.src())})}ngOnInit(){"pictureInPictureEnabled"in document||(this.pipMode=!0),this.pipVideo=this.vid.nativeElement,this.pipVideo.addEventListener("enterpictureinpicture",e=>{this.pipMode=!0,this.pipWindow=e.pictureInPictureWindow,this.pipWindow.addEventListener("resize",this.onPipWindowResize.bind(this)),this.change.emit(this.pipMode)}),this.pipVideo.addEventListener("leavepictureinpicture",()=>{this.pipMode=!1,this.pipVideo.pause(),this.pipWindow.removeEventListener("resize",this.onPipWindowResize),this.change.emit(this.pipMode)})}onPipWindowResize(e){this.resize.emit([e.srcElement.width,e.srcElement.height])}toggleMute(){this._muted.update(e=>!e)}initPiP(){return J(this,null,function*(){try{yield this.pipVideo.requestPictureInPicture(),this.pipMode=!0,this.vid.nativeElement.play(),this.click.emit(!0)}catch(e){this.pipMode=!1}})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["pip-video"]],viewQuery:function(t,i){if(t&1&&$t(boe,7),t&2){let r;De(r=ke())&&(i.vid=r.first)}},inputs:{src:[1,"src"],muted:[1,"muted"]},outputs:{resize:"resize",change:"change",click:"click"},decls:7,vars:5,consts:[["vid",""],[2,"border","gray 1px solid","border-radius","5px","display","none"],["autoplay","",3,"src","muted"],[2,"padding-left","5px"],["mat-mini-fab","","matTooltip","Show Video","matTooltipPosition","left",1,"button-toolbar",3,"click","disabled"]],template:function(t,i){t&1&&(u(0,"div",1),z(1,"video",2,0),p(),u(3,"div",3)(4,"button",4),T("click",function(){return i.initPiP()}),u(5,"mat-icon"),_(6,"videocam"),p()()()),t&2&&(g(),w("src",i.vidUrl,Mc)("muted",i._muted()),g(3),Nt("display",i.src()?"block":"none"),w("disabled",i.pipMode))},dependencies:[ue,Es,be,Pe,le,ce],encapsulation:2})};var BN=Ma(Os());function xoe(n,e){if(n&1&&_(0),n&2){let t=v(3);$(" \xB7 ",t.legBearing," ")}}function Coe(n,e){if(n&1&&(u(0,"div",2)(1,"div",3),_(2,"Leg:"),p(),u(3,"div",4),_(4),R(5,xoe,1,1),p()()),n&2){let t=v(2);g(4),$(" ",t.coords().length<2?"--":t.legDistance," "),g(),A(t.coords().length>=2&&t.legBearing!=="--"?5:-1)}}function woe(n,e){if(n&1&&(u(0,"div",0)(1,"div",2)(2,"div",3),_(3,"Distance:"),p(),u(4,"div",4),_(5),p()(),R(6,Coe,6,2,"div",2),p()),n&2){let t=v();g(5),q(t.totalDistance),g(),A(t.totalOnly()?-1:6)}}function Moe(n,e){if(n&1&&(u(0,"div",5)(1,"div",5)(2,"div",9)(3,"mat-icon"),_(4,"square_foot"),p(),z(5,"br"),_(6),p(),u(7,"div",7),_(8),z(9,"br"),_(10),p()()()),n&2){let t=v(2);g(6),$(" ",t.coords().length<2?"-":t._index()===-1?t.coords().length-1:t._index()+1," "),g(2),$(" ",t.legDistance),g(2),$(" ",t.legBearing," ")}}function Soe(n,e){if(n&1){let t=H();u(0,"div",1)(1,"mat-toolbar")(2,"div",5)(3,"div",5)(4,"div",6)(5,"mat-icon"),_(6,"straighten"),p()(),u(7,"div",7),_(8),z(9,"br"),p()(),R(10,Moe,11,3,"div",5),u(11,"div")(12,"button",8),T("click",function(){O(t);let r=v();return F(r.close())}),u(13,"mat-icon"),_(14,"close"),p()()()()()()}if(n&2){let t=v();g(8),q(t.totalDistance),g(2),A(t.totalOnly()?-1:10)}}var N2=class n{coords=Z([]);index=Z(-1);_index=Ta(()=>this.index());totalOnly=Z(!1);card=Z(!1);cancel=we();totalDistance;legDistance;legBearing;btnDisable={prev:!1,next:!1};app=M(ae);constructor(){Me(()=>{if(!this.coords()||!Array.isArray(this.coords())||this.coords().length===0){this.init();return}if(this._index())if(Number.isFinite(this._index())){if(this._index()<-1&&this._index()>=this.coords().length)return}else return;this.calc(),this.setButtonState()}),this.init()}init(e){e||(this.totalDistance="--"),this.legDistance="--",this.legBearing="--",this.btnDisable={prev:!0,next:!0}}close(){this.cancel.emit()}calc(){let e=oi.routeLength(this.coords());this.totalDistance=this.app.formatValueForDisplay(e,"m");let t;if(this._index()===-1)t=this.coords().slice(-2);else{let i=this._index()===this.coords().length-2?void 0:this._index()+2;t=this.coords().slice(this._index(),i)}if(t.length<2)this.init(!0);else{let i=oi.distanceTo(t[0],t[1]),r=(0,BN.getGreatCircleBearing)(t[0],t[1]);this.legDistance=this.app.formatValueForDisplay(i,"m"),this.legBearing=this.app.formatValueForDisplay(r,"deg")}}select(e){e?this._index()===-1?this.coords().length>2&&this._index.set(this.coords().length-3):this._index()>0&&this._index.update(t=>--t):(this._index()!==-1||this._index()<this.coords().length-2)&&this._index.update(t=>++t),this.setButtonState(),this.calc()}setButtonState(){this._index()>0||this._index()===-1&&this.coords().length>2?this.btnDisable.prev=!1:this.btnDisable.prev=!0,this._index()!==-1&&this._index()<this.coords().length-2?this.btnDisable.next=!1:this.btnDisable.next=!0}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["fb-measurements"]],inputs:{coords:[1,"coords"],index:[1,"index"],totalOnly:[1,"totalOnly"],card:[1,"card"]},outputs:{cancel:"cancel"},decls:2,vars:1,consts:[[1,"_ap_measurements_card"],[1,"_ap_measurements"],[1,"_ap_prop"],[1,"_ap_prop_key"],[1,"_ap_prop_val"],[1,"_ap_row"],[1,"icon-label"],[1,"value"],["matTooltip","Cancel","matTooltipPosition","below","mat-icon-button","",3,"click"],[2,"font-size","12pt"]],template:function(t,i){t&1&&R(0,woe,7,2,"div",0)(1,Soe,15,2,"div",1),t&2&&A(i.card()?0:1)},dependencies:[le,ce,ue,Fe,Pe,Et,kt],styles:["._ap_measurements[_ngcontent-%COMP%]{position:relative;top:0;min-width:200px}._ap_prop[_ngcontent-%COMP%]{display:flex;margin:2px 0}._ap_prop_key[_ngcontent-%COMP%]{font-weight:700}._ap_prop_val[_ngcontent-%COMP%]{flex:1 1 auto;text-align:right;white-space:nowrap}._ap_row[_ngcontent-%COMP%]{display:flex;flex-wrap:no-wrap;flex:2}._ap_row[_ngcontent-%COMP%] .icon-label[_ngcontent-%COMP%]{width:30px}._ap_row[_ngcontent-%COMP%] .row-label[_ngcontent-%COMP%]{font-weight:500;min-width:60px}._ap_measurements[_ngcontent-%COMP%] .value[_ngcontent-%COMP%]{padding-right:10px}@media only screen and (max-width:500px){._ap_measurements[_ngcontent-%COMP%]{left:0;width:100%}}"],changeDetection:0})};function Toe(n,e){if(n&1){let t=H();pn(0,"img",1),Z_("error",function(){O(t);let r=v();return F(r.imgError())}),En()}if(n&2){let t=v();Mo("src",t.flagIcon,Mc)}}var B2=class n{flagIcon;showFlag=X(!0);mmsi=Z();host=Z("");constructor(){Me(()=>{this.flagIcon=`${this.host()}/signalk/v2/api/resources/flags/mmsi/${this.mmsi()}`})}imgError(){this.showFlag.set(!1)}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["country-flag"]],inputs:{mmsi:[1,"mmsi"],host:[1,"host"]},decls:1,vars:1,consts:[[3,"src"],[3,"error","src"]],template:function(t,i){t&1&&R(0,Toe,1,1,"img",0),t&2&&A(i.showFlag()?0:-1)},encapsulation:2})};var V2=class n{notiMgr=M(nl);constructor(){}raiseAlarm(){this.notiMgr.raiseServerAlarm("mob","Person Overboard!")}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["pob-button"]],decls:2,vars:0,consts:[["mat-fab","","matTooltip","Raise POB Alarm","matTooltipPosition","above",1,"button-warn",3,"click"],["svgIcon","alarm-mob",1,"ob"]],template:function(t,i){t&1&&(u(0,"button",0),T("click",function(){return i.raiseAlarm()}),z(1,"mat-icon",1),p())},dependencies:[le,ce,ue,Ad,be,Pe],encapsulation:2})};var G2=class n{position=Z([0,0]);active=Z(!1);skres=M(Pt);constructor(){}dropWaypoint(){this.skres.newWaypointAt(this.position())}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["wpt-button"]],inputs:{position:[1,"position"],active:[1,"active"]},decls:3,vars:1,consts:[["mat-fab","","matTooltip","Mark Vessel Position","matTooltipPosition","above",1,"button-toolbar",3,"click","disabled"]],template:function(t,i){t&1&&(u(0,"button",0),T("click",function(){return i.dropWaypoint()}),u(1,"mat-icon"),_(2,"add_location"),p()()),t&2&&w("disabled",!i.active())},dependencies:[le,ce,ue,Ad,be,Pe],encapsulation:2})};var Eoe=(n,e)=>({"button-primary":n,"button-toolbar":e}),z2=class n{active=Z(!1);app=M(ae);constructor(){}handleClick(){this.app.uiCtrl.update(e=>{let t=!e.autopilotConsole;return Object.assign({},e,{autopilotConsole:t})})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["autopilot-button"]],inputs:{active:[1,"active"]},decls:2,vars:5,consts:[["mat-fab","","matTooltip","Autopilot Console","matTooltipPosition","above",3,"click","ngClass","disabled"],["svgIcon","command-autopilot",1,"ob"]],template:function(t,i){t&1&&(u(0,"button",0),T("click",function(){return i.handleClick()}),z(1,"mat-icon",1),p()),t&2&&w("ngClass",cl(2,Eoe,i.app.data.vessels.self.autopilot.enabled,!i.app.data.vessels.self.autopilot.enabled||!i.app.featureFlags().autopilotApi||!i.app.data.vessels.self.autopilot.default))("disabled",!i.active())},dependencies:[hn,Ln,le,ce,ue,Ad,be,Pe],encapsulation:2})};var Ioe=(n,e)=>({"button-primary":n,"button-toolbar":e}),j2=class n{active=Z(!1);app=M(ae);radarApi=M(gc);constructor(){}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["radar-button"]],inputs:{active:[1,"active"]},decls:2,vars:5,consts:[["mat-fab","","matTooltip","Radar Overlay","matTooltipPosition","above",3,"ngClass","disabled"],["svgIcon","radar-iec",1,"ob"]],template:function(t,i){t&1&&(u(0,"button",0),z(1,"mat-icon",1),p()),t&2&&w("ngClass",cl(2,Ioe,i.radarApi.radarId()&&i.app.uiCtrl().radarLayer,!i.app.featureFlags().radarApi||!i.app.uiCtrl().radarLayer))("disabled",!i.active()||!i.app.data.vessels.showSelf||i.app.instrumentPanel().open)},dependencies:[hn,Ln,le,ce,ue,Ad,be,Pe],encapsulation:2})};var Fo=[];for(let n=0;n<256;++n)Fo.push((n+256).toString(16).slice(1));function VN(n,e=0){return(Fo[n[e+0]]+Fo[n[e+1]]+Fo[n[e+2]]+Fo[n[e+3]]+"-"+Fo[n[e+4]]+Fo[n[e+5]]+"-"+Fo[n[e+6]]+Fo[n[e+7]]+"-"+Fo[n[e+8]]+Fo[n[e+9]]+"-"+Fo[n[e+10]]+Fo[n[e+11]]+Fo[n[e+12]]+Fo[n[e+13]]+Fo[n[e+14]]+Fo[n[e+15]]).toLowerCase()}var Doe=new Uint8Array(16);function PE(){return crypto.getRandomValues(Doe)}function koe(n,e,t){return!e&&!n&&crypto.randomUUID?crypto.randomUUID():Poe(n,e,t)}function Poe(n,e,t){n=n||{};let i=n.random??n.rng?.()??PE();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){if(t=t||0,t<0||t+16>e.length)throw new RangeError(`UUID byte range ${t}:${t+15} is out of buffer bounds`);for(let r=0;r<16;++r)e[t+r]=i[r];return e}return VN(i)}var RE=koe;var LE="plotterExt/1",Ki={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,HOST_ERROR:-32e3,TIMEOUT:-32001,CONNECTION_CLOSED:-32002},si=class F_ extends Error{code;data;constructor(e,t={}){super(e),this.name="RpcError",this.code=t.code??Ki.HOST_ERROR;let i=se({},t.data??{});t.reason!==void 0&&(i.reason=t.reason),this.data=Object.keys(i).length>0?i:void 0}get reason(){return typeof this.data?.reason=="string"?this.data.reason:void 0}toErrorObject(){return se({code:this.code,message:this.message},this.data?{data:this.data}:{})}static fromErrorObject(e){return new F_(e.message,{code:e.code,data:e.data})}static from(e){return e instanceof F_?e:e instanceof Error?new F_(e.message,{code:Ki.INTERNAL_ERROR}):new F_(String(e),{code:Ki.INTERNAL_ERROR})}},AE="bus.ready",OE="bus.handshake";function GN(n,e){return n===e?!0:zN(n.split("."),0,e.split("."),0)}function zN(n,e,t,i){for(;e<n.length;){let r=n[e];if(r==="**"){if(e===n.length-1)return!0;for(let o=i;o<=t.length;o++)if(zN(n,e+1,t,o))return!0;return!1}if(i>=t.length||r!=="*"&&r!==t[i])return!1;e++,i++}return i===t.length}function W2(n,e){for(let t of n)if(GN(t,e))return!0;return!1}function Loe(n){return{bus:LE,msg:n}}function Aoe(n){if(typeof n!="object"||n===null)return null;let e=n;return e.bus!==LE?null:Ooe(e.msg)?e.msg:null}function Ooe(n){if(typeof n!="object"||n===null)return!1;let e=n;if(e.jsonrpc!=="2.0")return!1;if(typeof e.method=="string")return e.id===void 0||typeof e.id=="string"||typeof e.id=="number";if(!(typeof e.id=="string"||typeof e.id=="number"||e.id===null))return!1;let i="result"in e,r=e.error,o=typeof r=="object"&&r!==null&&typeof r.code=="number"&&typeof r.message=="string";return i?!("error"in e):o}function Foe(n){return"method"in n&&"id"in n&&n.id!==void 0}function Noe(n){return"method"in n&&(!("id"in n)||n.id===void 0)}function Boe(n){return!("method"in n)}function Of(n,e={}){let t=e.listenWindow??globalThis,i=e.origin??t.location?.origin??"*";return{post(r){n.postMessage(r,i)},listen(r){let o=a=>{a.source===n&&(i!=="*"&&a.origin!==i||r(a.data))};return t.addEventListener("message",o),()=>t.removeEventListener("message",o)}}}var Voe=1e4,FE=class{callTimeoutMs;port;unlisten;onError;pending=new Map;methods=new Map;eventHandlers=new Set;idPrefix=Math.random().toString(36).slice(2,8);seq=0;closed=!1;constructor(n){this.port=n.port,this.callTimeoutMs=n.callTimeoutMs??Voe,this.onError=n.onError??(e=>console.warn("[plotterext-bus]",e)),this.unlisten=this.port.listen(e=>this.onData(e))}registerMethod(n,e){this.methods.set(n,e)}unregisterMethod(n){this.methods.delete(n)}onEvent(n,e){let t={patterns:n,fn:e};return this.eventHandlers.add(t),()=>this.eventHandlers.delete(t)}notify(n,e){this.send(se({jsonrpc:"2.0",method:n},e!==void 0?{params:e}:{}))}call(n,e,t={}){if(this.closed)return Promise.reject(new si("Bus endpoint is closed",{code:Ki.CONNECTION_CLOSED,reason:"CLOSED"}));let i=`${this.idPrefix}-${++this.seq}`,r=t.timeoutMs??this.callTimeoutMs;return new Promise((o,a)=>{let s=r>0?setTimeout(()=>{this.pending.delete(i),a(new si(`Call timed out after ${r}ms: ${n}`,{code:Ki.TIMEOUT,reason:"TIMEOUT"}))},r):null;this.pending.set(i,{resolve:o,reject:a,timer:s}),this.send(se({jsonrpc:"2.0",id:i,method:n},e!==void 0?{params:e}:{}))})}close(){if(!this.closed){this.closed=!0,this.unlisten();for(let[,n]of this.pending)n.timer&&clearTimeout(n.timer),n.reject(new si("Bus endpoint closed",{code:Ki.CONNECTION_CLOSED,reason:"CLOSED"}));this.pending.clear(),this.eventHandlers.clear()}}send(n){this.closed||this.port.post(Loe(n))}onData(n){let e=Aoe(n);e&&(Boe(e)?this.onResponse(e):Foe(e)?this.onRequest(e):Noe(e)&&this.onNotification(e.method,e.params))}onResponse(n){if(n.id===null)return;let e=this.pending.get(n.id);e&&(this.pending.delete(n.id),e.timer&&clearTimeout(e.timer),"error"in n?e.reject(si.fromErrorObject(n.error)):e.resolve(n.result))}onRequest(n){return J(this,null,function*(){let e=this.methods.get(n.method);if(!e){this.send({jsonrpc:"2.0",id:n.id,error:{code:Ki.METHOD_NOT_FOUND,message:`Method not found: ${n.method}`}});return}try{let t=yield e(n.params,{endpoint:this});this.send({jsonrpc:"2.0",id:n.id,result:t===void 0?null:t})}catch(t){this.send({jsonrpc:"2.0",id:n.id,error:si.from(t).toErrorObject()})}})}onNotification(n,e){for(let t of[...this.eventHandlers])if(W2(t.patterns,n))try{t.fn(n,e)}catch(i){this.onError(i)}}};var Ff=class{endpoint;context;hostInfo;subs=new Map;onSubscriptionsChanged;adoptCallerId;subSeq=0;constructor(n){this.hostInfo=n.hostInfo,this.context=n.context,this.onSubscriptionsChanged=n.onSubscriptionsChanged,this.adoptCallerId=n.adoptCallerId??!1,this.endpoint=new FE({port:n.port,callTimeoutMs:n.callTimeoutMs,onError:n.onError});for(let[e,t]of Object.entries(n.methods??{}))this.endpoint.registerMethod(e,t);this.endpoint.registerMethod("events.subscribe",e=>this.handleSubscribe(e)),this.endpoint.registerMethod("events.unsubscribe",e=>this.handleUnsubscribe(e)),this.endpoint.onEvent([AE],(e,t)=>this.sendHandshake(t))}registerMethod(n,e){this.endpoint.registerMethod(n,e)}publish(n,e){return this.hasSubscriber(n)?(this.endpoint.notify(n,e),!0):!1}hasSubscriber(n){for(let[,e]of this.subs)if(W2(e,n))return!0;return!1}subscribedPatterns(){let n=new Set;for(let[,e]of this.subs)for(let t of e)n.add(t);return[...n]}close(){this.endpoint.close(),this.subs.clear()}sendHandshake(n){let e=this.adoptCallerId&&n?.id?ri(se({},this.context),{id:n.id}):this.context;this.endpoint.notify(OE,ri(se({},this.hostInfo),{context:e}))}handleSubscribe(n){let e=n?.patterns;if(!Array.isArray(e)||e.length===0||!e.every(i=>typeof i=="string"&&i.length>0))throw new si("events.subscribe requires a non-empty patterns array",{code:Ki.INVALID_PARAMS,reason:"INVALID_PATTERNS"});let t=`sub-${++this.subSeq}`;return this.subs.set(t,e),this.onSubscriptionsChanged?.(this.subscribedPatterns()),{subscriptionId:t}}handleUnsubscribe(n){let e=n?.subscriptionId;if(typeof e!="string"||!this.subs.has(e))throw new si("Unknown subscriptionId",{code:Ki.INVALID_PARAMS,reason:"UNKNOWN_SUBSCRIPTION"});return this.subs.delete(e),this.onSubscriptionsChanged?.(this.subscribedPatterns()),{}}};function jN(n,e={}){let t=s=>{let l=s?.routeId;if(typeof l!="string"||l.length===0)throw new si("route method requires a routeId",{code:Ki.INVALID_PARAMS,reason:"routes.badRequest"});return l},i=()=>new si("Unknown route buffer",{reason:"routes.unknownId"}),r=s=>new si(s,{code:Ki.INVALID_PARAMS,reason:"routes.badRequest"}),o=(s,l)=>{if(s!==void 0&&typeof s!="string")throw r(`${l} must be a string`)},a=s=>{if(!Array.isArray(s)||s.length<2)throw r("a route needs at least two points");for(let l of s){let c=l?.position;if(!Array.isArray(c)||c.length<2||!Number.isFinite(c[0])||!Number.isFinite(c[1]))throw r("each route point needs a numeric [lon, lat] position");o(l.name,"point name"),o(l.description,"point description")}return s};return{"route.list":()=>({routes:n.list()}),"route.create":s=>{let{name:l,description:c,points:d}=s??{};o(l,"name"),o(c,"description");let h=a(d),m=n.create({name:l,description:c,points:h});return{routeId:m.routeId,rev:m.rev}},"route.replace":s=>{let l=t(s),{points:c}=s??{},d=a(c),h=n.replace(l,d);if(!h)throw i();return{rev:h.rev}},"route.save":s=>J(null,null,function*(){let l=t(s);if(!n.has(l))throw i();if(!e.onSave)throw new si("This host cannot persist routes",{reason:"routes.notSupported"});let{name:c,description:d,dialog:h}=s??{};if(o(c,"name"),o(d,"description"),h!==void 0&&typeof h!="boolean")throw r("dialog must be a boolean");let m=yield e.onSave(l,{name:c,description:d,dialog:h});if(!m)throw new si("Route save was cancelled",{reason:"routes.saveCancelled"});return m}),"route.get":s=>{let l=n.get(t(s));if(!l)throw i();return l},"route.hide":s=>J(null,null,function*(){let l=t(s);if(!n.has(l))throw i();return e.onHide?yield e.onHide(l):n.delete(l),{}}),"route.delete":s=>J(null,null,function*(){let l=t(s);if(!n.has(l))throw i();return e.onDelete?yield e.onDelete(l):n.delete(l,!1),{}}),"route.show":s=>{let l=s?.ref;if(typeof l!="string"||l.length===0)throw new si("route.show requires a ref",{code:Ki.INVALID_PARAMS,reason:"routes.badRef"});if(!e.onShow)throw new si("route.show is not supported by this host",{reason:"routes.notSupported"});return e.onShow(l)}}}function Goe(n){let[e,t,i]=n,r={id:e,name:t?.name??e,visible:!!i,opacity:typeof t?.defaultOpacity=="number"?t.defaultOpacity:1};return t?.type&&(r.type=t.type),Array.isArray(t?.bounds)&&t.bounds.length===4&&(r.bounds=[t.bounds[0],t.bounds[1],t.bounds[2],t.bounds[3]]),typeof t?.minZoom=="number"&&(r.minZoom=t.minZoom),typeof t?.maxZoom=="number"&&(r.maxZoom=t.maxZoom),r}function WN(n){let e=r=>new si(r,{code:Ki.INVALID_PARAMS,reason:"charts.badRequest"}),t=(r,o)=>{if(!Array.isArray(r)||r.some(a=>typeof a!="string"||a.length===0))throw e(`${o} must be an array of chart ids`);return r},i=(r,o)=>{let a=new Set(o.map(l=>l[0])),s=r.find(l=>!a.has(l));if(s!==void 0)throw new si(`Unknown chart id: ${s}`,{reason:"charts.unknownId"})};return{"chart.list":()=>J(null,null,function*(){return{charts:(yield n.listAvailableOrdered()).map(Goe)}}),"chart.setVisibility":r=>J(null,null,function*(){let o=t(r?.ids,"ids"),a=r?.visible;if(typeof a!="boolean")throw e("visible must be a boolean");return o.length>0&&(i(o,yield n.listAvailableOrdered()),yield n.setVisibility(o,a)),{}}),"chart.setOpacity":r=>J(null,null,function*(){let o=t(r?.ids,"ids"),a=r?.opacity;if(typeof a!="number"||!Number.isFinite(a))throw e("opacity must be a finite number");if(a<0||a>1)throw e("opacity must be between 0 and 1");return o.length>0&&(i(o,yield n.listAvailableOrdered()),yield n.setOpacity(o,a)),{}}),"chart.setOrder":r=>J(null,null,function*(){let o=t(r?.order,"order");return o.length>0&&(i(o,yield n.listAvailableOrdered()),yield n.setOrder(o)),{}})}}function UN(n){let e=t=>new si(t,{code:Ki.INVALID_PARAMS,reason:"nightMode.badRequest"});return{"nightMode.get":()=>J(null,null,function*(){return n.getState()}),"nightMode.set":t=>J(null,null,function*(){let i=t??{},r=i.enabled!==void 0,o=i.auto!==void 0;if(!r&&!o)throw e("nightMode.set requires enabled and/or auto");if(r&&typeof i.enabled!="boolean")throw e("enabled must be a boolean");if(o&&typeof i.auto!="boolean")throw e("auto must be a boolean");let a={};return o&&(a.auto=i.auto),r&&(a.enabled=i.enabled),yield n.setState(a),{}})}}var yc=class n{buffers=new Map;events=new ze;events$=this.events.asObservable();liveSignal=X([]);live=this.liveSignal.asReadonly();create(e={}){let t=this.newRouteId(),i={routeId:t,name:e.name??null,description:e.description??null,rev:1,saved:!1,dirty:!0,points:(e.points??[]).map(r=>this.clonePoint(r))};return this.buffers.set(t,i),this.refreshLive(),this.events.next({type:"visible",routeId:t,rev:i.rev,name:i.name,pointCount:i.points.length,saved:i.saved,dirty:i.dirty}),this.snapshot(i)}show(e){let t=this.buffers.get(e.routeId),i={routeId:e.routeId,name:e.name??t?.name??null,description:e.description??t?.description??null,rev:t?t.rev+1:1,saved:!0,dirty:!1,href:e.href,points:(e.points??t?.points??[]).map(r=>this.clonePoint(r))};return this.buffers.set(e.routeId,i),this.refreshLive(),this.events.next({type:"visible",routeId:i.routeId,rev:i.rev,name:i.name,pointCount:i.points.length,saved:!0,dirty:!1}),this.snapshot(i)}get(e){let t=this.buffers.get(e);return t?this.snapshot(t):void 0}has(e){return this.buffers.has(e)}hasHref(e){return this.getByHref(e)!==void 0}getByHref(e){for(let t of this.buffers.values())if(t.href===e)return this.snapshot(t)}all(){return[...this.buffers.values()].map(e=>this.snapshot(e))}list(){return[...this.buffers.values()].map(e=>({routeId:e.routeId,name:e.name,rev:e.rev,pointCount:e.points.length,saved:e.saved,dirty:e.dirty}))}delete(e,t){let i=this.buffers.get(e);if(!i)return!1;i.rev+=1;let r=t??i.saved;return this.buffers.delete(e),this.refreshLive(),this.events.next({type:"hidden",routeId:e,rev:i.rev,saved:r}),!0}markSaved(e,t,i,r){let o=this.buffers.get(e);if(o){if(!o.saved&&t===void 0)throw new Error("markSaved requires an href when saving a draft route");return o.rev+=1,o.saved=!0,o.dirty=!1,t!==void 0&&(o.href=t),i!==void 0&&(o.name=i),r!==void 0&&(o.description=r),this.refreshLive(),o.rev}}replace(e,t){let i=this.buffers.get(e);if(i)return i.points=(t??[]).map(r=>this.clonePoint(r)),i.rev+=1,i.dirty=!0,this.refreshLive(),this.events.next({type:"dirty",routeId:e,rev:i.rev,reason:"replaced"}),this.snapshot(i)}refreshLive(){this.liveSignal.set([...this.buffers.values()].map(e=>this.snapshot(e)))}refresh(){this.refreshLive()}newRouteId(){let e=globalThis.crypto;return e?.randomUUID?e.randomUUID():"rb-"+Date.now().toString(36)+"-"+Math.random().toString(36).slice(2,10)}clonePoint(e){return se(se({position:[...e.position]},e.name!==void 0?{name:e.name}:{}),e.description!==void 0?{description:e.description}:{})}snapshot(e){return ri(se({routeId:e.routeId,name:e.name,description:e.description,rev:e.rev,saved:e.saved,dirty:e.dirty},e.href!==void 0?{href:e.href}:{}),{points:e.points.map(t=>this.clonePoint(t))})}static \u0275fac=function(t){return new(t||n)};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})};var HN="fb-plotterext-state",joe="embedding-host",Woe=1e3,Uoe=new Set(["eq","ne","lt","lte","gt","gte","in","contains","regex","exists"]),Hoe=n=>!!n&&typeof n=="object"&&typeof n.path=="string"&&n.path.length>0&&Uoe.has(n.op),Nf=class n{constructor(e,t,i,r,o,a,s){this.app=e;this.signalk=t;this.dialog=i;this.skres=r;this.mapService=o;this.routeRegistry=a;this.stream=s;os()&&(window.fbPlotterExt=this),window.addEventListener("resize",()=>this.viewportTick.update(l=>l+1)),this.bridgeRouteEvents(),Me(()=>this.syncVisibleFromSelections()),Me(()=>this.emitChartChanges(this.skres.charts())),Me(()=>this.emitNightModeChange(this.readNightMode())),Me(()=>this.emitMapViewChange(this.mapView()))}app;signalk;dialog;skres;mapService;routeRegistry;stream;manifests=X({});activeWidgets=X([]);initialized=X(!1);viewportTick=X(0);actionButtonLift=qt(()=>{this.viewportTick();let e=this.activeWidgets().filter(i=>i.anchor==="br");if(!e.length)return 0;let t=e.some(i=>i.row===0)?2:1;return t*f1()+(t-1)*m1+6});statusBarLift=qt(()=>{this.viewportTick();let e=this.activeWidgets().filter(i=>i.anchor==="cb");if(!e.length)return 0;let t=e.some(i=>i.row===0)?2:1;return t*f1()+(t-1)*m1+4});toolbarTopOffset=qt(()=>{this.viewportTick();let e=this.activeWidgets().filter(i=>i.anchor==="tr");if(!e.length)return 0;let t=e.some(i=>i.row===1)?2:1;return t*f1()+(t-1)*m1+4});toolbarButtons=qt(()=>{let e=[];for(let[t,i]of Object.entries(this.manifests()))if(this.isCompatible(i))for(let r of i.buttons??[])r.apiVersion!==void 0&&r.apiVersion!=="1"||e.push({extension:t,extensionName:i.name,button:r});return e});backgroundRuntimes=qt(()=>{let e=[];for(let[t,i]of Object.entries(this.manifests()))if(this.isCompatible(i))for(let r of i.background??[])r.apiVersion!==void 0&&r.apiVersion!=="1"||r.type!=="iframe"||!r.url||e.push({key:`${t}/${r.id}`,extension:t,extensionName:i.name,runtime:r});return e});openPanels=X([]);visiblePanel=qt(()=>this.openPanels().find(e=>e.visible)??null);openPanel(e,t){let r=this.manifests()[e]?.panels?.find(a=>a.id===t);if(!r||r.type!=="iframe"||!r.url||r.apiVersion!==void 0&&r.apiVersion!=="1")return!1;let o=`${e}/${t}`;return this.openPanels.update(a=>{let s=a.filter(l=>l.key===o||l.panel.lifecycle==="keepAlive").map(l=>ri(se({},l),{visible:l.key===o}));return s.some(l=>l.key===o)?s:[...s,{key:o,extension:e,panel:r,visible:!0}]}),!0}closeVisiblePanel(){let e=this.openPanels().find(t=>t.visible);e&&this.closePanel(e.key)}closePanel(e){this.openPanels.update(t=>{let i=t.find(r=>r.key===e);return i?i.panel.lifecycle==="keepAlive"?t.map(r=>r.key===e?ri(se({},r),{visible:!1}):r):t.filter(r=>r.key!==e):t})}togglePanel(e,t){let i=`${e}/${t}`;return this.visiblePanel()?.key===i?(this.closeVisiblePanel(),!0):this.openPanel(e,t)}uiPanelMethods(e){let t=i=>{let r=i?.panel;if(!r)throw new si("panel is required",{code:Ki.INVALID_PARAMS,reason:"UNKNOWN_PANEL"});return r};return{"ui.openPanel":i=>J(this,null,function*(){let r=t(i);if(!this.openPanel(e,r))throw new si(`No such panel: ${r}`,{code:Ki.INVALID_PARAMS,reason:"UNKNOWN_PANEL"});return{}}),"ui.togglePanel":i=>J(this,null,function*(){let r=t(i);if(!this.togglePanel(e,r))throw new si(`No such panel: ${r}`,{code:Ki.INVALID_PARAMS,reason:"UNKNOWN_PANEL"});return{}})}}handleButtonAction(e,t){let i=t.action;if(!i)return;if(i.type==="sendMessage"){i.topic&&this.broadcastMessage(i.topic,i.params);return}let r=i.panel;r&&(i.type==="togglePanel"?this.togglePanel(e,r):i.type==="openPanel"&&this.openPanel(e,r))}resourceFilters=X({});visibleNotes=qt(()=>{let e=this.skres.notes(),t=this.resourceFilters().notes;if(!t||!Object.keys(t).length)return e;let i=Object.values(t);return e.filter(([r,o])=>i.every(a=>this.passesFilter(a,r,o)))});filterChips=qt(()=>{let e=[];for(let[t,i]of Object.entries(this.resourceFilters()))for(let[r,o]of Object.entries(i))e.push({type:t,extension:r,label:o.label??`${this.manifests()[r]?.name??r} filter`});return e});setResourceFilter(e,t,i){this.resourceFilters.update(r=>ri(se({},r),{[t]:ri(se({},r[t]??{}),{[e]:i})})),this.publishToExtension(e,"filters.changed",{type:t,active:!0})}clearResourceFilter(e,t){this.resourceFilters.update(i=>{let r=se({},i[t]??{});delete r[e];let o=se({},i);return Object.keys(r).length?o[t]=r:delete o[t],o}),this.publishToExtension(e,"filters.changed",{type:t,active:!1})}passesFilter(e,t,i){let r=!0;return e.ids&&(r=e.ids.includes(t)),r&&e.match&&(r=e.match.every(o=>this.evalCondition(o,i))),e.mode==="exclude"?!r:r}evalCondition(e,t){let i=t;for(let r of e.path.split(".")){if(i===null||typeof i!="object"){i=void 0;break}i=i[r]}switch(e.op){case"exists":return i!==void 0;case"eq":return this.refEquals(i,e.value,e.exact);case"ne":return!this.refEquals(i,e.value,e.exact);case"lt":return typeof i=="number"&&i<e.value;case"lte":return typeof i=="number"&&i<=e.value;case"gt":return typeof i=="number"&&i>e.value;case"gte":return typeof i=="number"&&i>=e.value;case"in":return Array.isArray(e.value)&&e.value.some(r=>this.refEquals(i,r,e.exact));case"contains":return typeof i=="string"?i.toLowerCase().includes(String(e.value).toLowerCase()):Array.isArray(i)&&i.includes(e.value);case"regex":{if(typeof i!="string"||typeof e.value!="string"||i.length>2e3)return!1;let r=this.compileRegex(e.value);return r?r.test(i):!1}default:return!1}}symbolLocalId(e){if(typeof e!="string")return null;let t=/^[A-Za-z0-9_-]+:([^:]+)$/.exec(e);return t?t[1]:null}refEquals(e,t,i){return e===t?!0:i?!1:typeof t=="string"&&!t.includes(":")&&this.symbolLocalId(e)===t||typeof e=="string"&&!e.includes(":")&&this.symbolLocalId(t)===e}compileRegex(e){if(e.length>200)return null;try{return new RegExp(e)}catch(t){return null}}contexts=new Set;embeddingHostDetach=null;ws=null;wsReady=!1;pathRefs=new Map;reconnectTimer=null;pointsFromRoute(e,t){return e.map((i,r)=>se(se({position:i},t?.[r]?.name?{name:t[r].name}:{}),t?.[r]?.description?{description:t[r].description}:{}))}pointsEqual(e,t){return e.length!==t.length?!1:e.every((i,r)=>{let o=t[r];return i.position[0]===o.position[0]&&i.position[1]===o.position[1]&&(i.position[2]??null)===(o.position[2]??null)&&(i.name??null)===(o.name??null)&&(i.description??null)===(o.description??null)})}syncVisibleFromSelections(){let e=this.skres.routes(),t=new Set(e.map(i=>i[0]));for(let[i,r]of e){let o=r.feature?.geometry?.coordinates??[],a=r.feature?.properties?.coordinatesMeta,s=this.pointsFromRoute(o,a),l=this.routeRegistry.getByHref(i);if(l){l.saved&&!l.dirty&&((l.name??null)!==(r.name??null)||(l.description??null)!==(r.description??null)||!this.pointsEqual(l.points,s))&&this.routeRegistry.show({routeId:l.routeId,name:r.name??null,description:r.description??null,points:s,href:i});continue}this.routeRegistry.show({routeId:i,name:r.name??null,description:r.description??null,points:s,href:i})}for(let i of this.routeRegistry.all())i.saved&&!i.dirty&&i.href&&!t.has(i.href)&&this.routeRegistry.delete(i.routeId,!0)}bridgeRouteEvents(){this.routeRegistry.events$.subscribe(e=>{switch(e.type){case"visible":this.broadcastMessage("route.visible",{routeId:e.routeId,rev:e.rev,name:e.name,pointCount:e.pointCount,saved:e.saved,dirty:e.dirty});break;case"hidden":this.broadcastMessage("route.hidden",{routeId:e.routeId,rev:e.rev,saved:e.saved});break;case"dirty":this.broadcastMessage("route.dirty",se({routeId:e.routeId,rev:e.rev},e.reason!==void 0?{reason:e.reason}:{}));break}})}routeMethods(){return jN(this.routeRegistry,{onSave:(e,t)=>this.saveBuffer(e,t),onShow:e=>this.showRoute(e),onHide:e=>this.hideRoute(e),onDelete:e=>this.deleteRoute(e)})}chartMethods(){return WN({listAvailableOrdered:()=>this.skres.chartsForHostApi(),setVisibility:(e,t)=>this.skres.setChartsVisibility(e,t),setOpacity:(e,t)=>this.skres.setChartsOpacity(e,t),setOrder:e=>this.skres.setChartsOrder(e)})}nightModeMethods(){return UN({getState:()=>this.readNightMode(),setState:e=>this.applyNightMode(e)})}readNightMode(){return{enabled:this.stream.selfNightMode()||this.app.uiCtrl().forceNightMode,auto:this.app.config.display.nightMode??!1}}applyNightMode(e){let t=e.auto;if(typeof t=="boolean"){if(t)this.app.uiCtrl.update(r=>ri(se({},r),{forceNightMode:!1}));else if(typeof e.enabled!="boolean"){let r=this.readNightMode().enabled;this.app.uiCtrl.update(o=>ri(se({},o),{forceNightMode:r}))}this.app.config.display.nightMode=t,this.app.uiConfig.update(r=>ri(se({},r),{autoNightMode:t}))}let i=e.enabled;typeof i=="boolean"&&(this.app.config.display.nightMode=!1,this.app.uiConfig.update(r=>ri(se({},r),{autoNightMode:!1})),this.app.uiCtrl.update(r=>ri(se({},r),{forceNightMode:i}))),this.stream.refreshSelfNightMode(),this.emitNightModeChange(this.readNightMode())}prevNightMode=null;emitNightModeChange(e){let t=this.prevNightMode;this.prevNightMode=e,t!==null&&(t.enabled===e.enabled&&t.auto===e.auto||this.broadcastMessage("nightMode.changed",e))}prevChartSnapshot=null;emitChartChanges(e){let t=e.map(c=>c[0]).reverse(),i=new Map(e.map(c=>[c[0],typeof c[1]?.defaultOpacity=="number"?c[1].defaultOpacity:1])),r=this.prevChartSnapshot;if(this.prevChartSnapshot={order:t,opacity:i},!r)return;let o=new Set(r.order),a=new Set(t);for(let c of t)o.has(c)||this.broadcastMessage("chart.visibility",{id:c,visible:!0});for(let c of r.order)a.has(c)||this.broadcastMessage("chart.visibility",{id:c,visible:!1});for(let[c,d]of i){let h=r.opacity.get(c);h!==void 0&&h!==d&&this.broadcastMessage("chart.opacity",{id:c,opacity:d})}let s=r.order.filter(c=>a.has(c)),l=t.filter(c=>o.has(c));s.length===l.length&&s.some((c,d)=>c!==l[d])&&this.broadcastMessage("chart.order",{order:t})}hideRoute(e){let t=this.routeRegistry.get(e);t&&(t.saved&&t.href?(this.skres.routeHide(t.href),this.routeRegistry.delete(e,!0)):this.routeRegistry.delete(e,!1))}deleteRoute(e){return J(this,null,function*(){let t=this.routeRegistry.get(e);if(t){if(t.saved&&t.href)try{yield this.skres.deleteFromServer("routes",t.href)}catch(i){throw this.app.parseHttpErrorResponse(i),new si("Failed to delete route",{reason:"routes.deleteFailed"})}this.routeRegistry.delete(e,!1)}})}showRoute(e){return J(this,null,function*(){let t=this.routeRegistry.getByHref(e);if(t)return{routeId:t.routeId,rev:t.rev};this.skres.selectionAdd("routes",e),yield this.skres.refreshRoutes();let i=this.skres.fromCache("routes",e);if(!i)throw this.skres.selectionRemove("routes",e),new si("No such route",{reason:"routes.badRef"});let r=i[1],o=r.feature?.geometry?.coordinates??[],a=r.feature?.properties?.coordinatesMeta,s=this.pointsFromRoute(o,a),l=this.routeRegistry.show({routeId:e,name:r.name??null,description:r.description??null,points:s,href:e});return{routeId:l.routeId,rev:l.rev}})}saveNativeRouteEdit(e,t,i){return J(this,null,function*(){let r=this.pointsFromRoute(t,i),o=this.routeRegistry.get(e);if(!o){let c=this.skres.fromCache("routes",e),d=c?c[1].name??null:null,h=c?c[1].description??null:null;this.routeRegistry.show({routeId:e,name:d,description:h,points:r,href:e})}this.routeRegistry.replace(e,r),o=this.routeRegistry.get(e);let a=o?.href??e;if(!(yield this.skres.updateRouteCoords(a,t,i)))return;let l=this.routeRegistry.markSaved(e,a)??0;this.broadcastMessage("route.saved",{routeId:e,rev:l,href:a,name:o?.name??null,saved:!0,dirty:!1})})}saveBuffer(i){return J(this,arguments,function*(e,t={}){let r=this.routeRegistry.get(e);if(!r)return null;let[,o]=this.skres.buildRoute(r.points.map(d=>d.position)),a=r.points.map(d=>se(se({},d.name?{name:d.name}:{}),d.description?{description:d.description}:{}));a.some(d=>Object.keys(d).length>0)&&(o.feature.properties.coordinatesMeta=a),o.name=t.name??r.name??"",o.description=t.description??r.description??"";let s;if(r.href)try{yield this.skres.putToServer("routes",r.href,o),s=r.href}catch(d){throw this.app.parseHttpErrorResponse(d),new si("Failed to save route",{reason:"routes.saveFailed"})}else if(t.dialog)try{s=yield this.skres.saveNewRoute(o)}catch(d){throw new si("Failed to save route",{reason:"routes.saveFailed"})}else try{s=(yield this.skres.postToServer("routes",o)).id,this.skres.selectionAdd("routes",s)}catch(d){throw this.app.parseHttpErrorResponse(d),new si("Failed to save route",{reason:"routes.saveFailed"})}if(!s)return null;let l=o.name||null,c=this.routeRegistry.markSaved(e,s,l,o.description||null)??r.rev+1;return this.broadcastMessage("route.saved",{routeId:e,rev:c,href:s,name:l,saved:!0,dirty:!1}),this.app.data.editingId="",{href:s,rev:c}})}init(){return J(this,null,function*(){try{let e=yield Fp(this.signalk.api.get(this.app.skApiVersion,"/resources/plotterExtensions")),t={};if(e&&typeof e=="object")for(let[i,r]of Object.entries(e))this.isManifest(r)&&(t[i]=r);this.manifests.set(t)}catch(e){this.manifests.set({})}this.refreshActiveWidgets(),this.initialized.set(!0),this.attachEmbeddingHostOnce()})}isCompatible(e){return e.apiVersion!=="1"?!1:(e.requires??[]).every(t=>qC.includes(t))}isManifest(e){return typeof e=="object"&&e!==null&&typeof e.name=="string"&&typeof e.apiVersion=="string"}widgetDef(e,t){return this.manifests()[e]?.widgets?.find(r=>r.id===t)??null}placements(){return this.app.config.plotterExtensions.widgets}occupancy(e){let{cols:t,rows:i}=h1[e],r=Array.from({length:i},()=>Array.from({length:t},()=>!1));for(let o of this.activeWidgets()){if(o.anchor!==e)continue;let a=this.widgetDef(o.extension,o.widget),s=XC(a?.size??"1x1");for(let l=o.row;l<o.row+s.rows&&l<i;l++)for(let c=o.col;c<o.col+s.cols&&c<t;c++)r[l][c]=!0}return r}cellOccupied(e,t){return this.occupancy(e)[t.row]?.[t.col]??!0}isValidOrigin(e,t,i,r){let{cols:o,rows:a}=h1[e];if(i.col+t.cols>o||i.row+t.rows>a)return!1;for(let s=i.row;s<i.row+t.rows;s++)for(let l=i.col;l<i.col+t.cols;l++)if(r[s][l])return!1;if(t.rows===1){let s=ZC[e]==="bottom"?a-1:0;if(i.row!==s){for(let l=i.col;l<i.col+t.cols;l++)if(!r[s][l])return!1}}return!0}originOrder(e){let t=h1[e].rows,i=Array.from({length:t},(s,l)=>l),r=ZC[e]==="bottom"?[...i].reverse():i,o=gD[e],a=[];for(let s of r)for(let l of o)a.push({col:l,row:s});return a}findOrigin(e,t,i){let r=XC(t.size),o=this.occupancy(e);for(let a of this.originOrder(e))if(this.isValidOrigin(e,r,a,o)&&!(i&&!(i.col>=a.col&&i.col<a.col+r.cols&&i.row>=a.row&&i.row<a.row+r.rows)))return a;return null}addableWidgets(e,t){let i=[];for(let[r,o]of Object.entries(this.manifests()))if(this.isCompatible(o))for(let a of o.widgets??[]){if(a.type!=="iframe"||a.apiVersion!==void 0&&a.apiVersion!=="1")continue;let s=this.findOrigin(e,a,t);s&&i.push({extension:r,extensionName:o.name,widget:a,origin:s})}return i}hitTester=null;registerHitTester(e){return this.hitTester=e,()=>{this.hitTester===e&&(this.hitTester=null)}}addableCellAt(e,t){let i=this.hitTester?.(e,t);return!i||this.cellOccupied(i.anchor,i.cell)||!this.addableWidgets(i.anchor,i.cell).length?null:i}openAddWidgetPicker(e,t){return J(this,null,function*(){let i=this.addableWidgets(e,t);if(!i.length)return;let{PlotterAddWidgetDialog:r}=yield import("./chunk-RU2QXGZX.js");this.dialog.open(r,{data:{anchor:e,candidates:i},width:"340px"}).afterClosed().subscribe(o=>{if(!o)return;let a=this.placeWidget(o.extension,o.widget,e,o.origin);this.widgetHasConfigPanel(a)&&this.openConfigPanel(a)})})}placeWidget(e,t,i,r){let o={instanceId:RE(),extension:e,widget:t.id,anchor:i,col:r.col,row:r.row};return this.app.config.plotterExtensions.widgets.push(o),this.app.saveConfig(),this.refreshActiveWidgets(),o}removeWidget(e){let t=this.app.config.plotterExtensions.widgets,i=t.findIndex(r=>r.instanceId===e);if(i!==-1){let[r]=t.splice(i,1);this.clearInstanceState(r.extension,e),this.app.saveConfig(),this.refreshActiveWidgets()}}refreshActiveWidgets(){let e=this.manifests();this.activeWidgets.set(this.placements().filter(t=>{let i=e[t.extension];return i&&this.isCompatible(i)&&i.widgets?.some(r=>r.id===t.widget&&(r.apiVersion===void 0||r.apiVersion==="1"))}))}resolveAssetUrl(e){let t=this.app.hostDef?.url||window.location.origin;try{let i=new URL(t),r=new URL(e,t);return r.protocol!=="http:"&&r.protocol!=="https:"||r.origin!==i.origin?"about:blank":r.toString()}catch(i){return"about:blank"}}assetOrigin(e){try{return new URL(this.resolveAssetUrl(e)).origin}catch(t){return"*"}}attachWidget(e,t){let i={extension:t.extension,conn:null,skSubs:new Map,skSubSeq:0},r=this.widgetDef(t.extension,t.widget)?.url??"";return i.conn=new Ff({port:Of(e.contentWindow,{origin:this.assetOrigin(r)}),hostInfo:this.hostInfo(),context:{kind:"widget",id:t.widget,instanceId:t.instanceId,targetInstance:null},methods:ri(se(se(se(se(se(se(se(se(se({},this.stateMethods(t.extension,t.instanceId)),this.signalkMethods(i)),this.unitsMethods()),this.resourcesMethods(t.extension)),this.mapMethods()),this.routeMethods()),this.chartMethods()),this.nightModeMethods()),this.uiPanelMethods(t.extension)),{"ui.openConfigPanel":()=>J(this,null,function*(){return this.openConfigPanel(t),{}}),"ui.toggleConfigPanel":()=>J(this,null,function*(){return this.toggleConfigPanel(t),{}})}),onError:o=>console.warn("plotterext widget error",o)}),this.contexts.add(i),()=>this.detach(i)}attachPanel(e,t){let i={extension:t.extension,conn:null,skSubs:new Map,skSubSeq:0};return i.conn=new Ff({port:Of(e.contentWindow,{origin:this.assetOrigin(t.panel.url??"")}),hostInfo:this.hostInfo(),context:{kind:"panel",id:t.panel.id,instanceId:null,targetInstance:t.targetInstance??null,targetWidget:t.targetWidget??null},methods:ri(se(se(se(se(se(se(se(se(se({},this.stateMethods(t.extension,t.targetInstance??null)),this.signalkMethods(i)),this.unitsMethods()),this.resourcesMethods(t.extension)),this.mapMethods()),this.routeMethods()),this.chartMethods()),this.nightModeMethods()),this.uiPanelMethods(t.extension)),{"ui.closePanel":()=>J(this,null,function*(){return t.close(),{}})}),onError:r=>console.warn("plotterext panel error",r)}),this.contexts.add(i),()=>this.detach(i)}attachBackground(e,t){let i={extension:t.extension,conn:null,skSubs:new Map,skSubSeq:0};return i.conn=new Ff({port:Of(e.contentWindow,{origin:this.assetOrigin(t.runtime.url)}),hostInfo:this.hostInfo(),context:{kind:"background",id:t.runtime.id,instanceId:null},methods:se(se(se(se(se(se(se(se(se({},this.stateMethods(t.extension,null)),this.signalkMethods(i)),this.unitsMethods()),this.resourcesMethods(t.extension)),this.mapMethods()),this.routeMethods()),this.chartMethods()),this.nightModeMethods()),this.uiPanelMethods(t.extension)),onError:r=>console.warn("plotterext background error",r)}),this.contexts.add(i),()=>this.detach(i)}attachEmbeddingHost(e=Of(window.parent,{origin:window.location.origin})){let t=joe,i={extension:t,conn:null,skSubs:new Map,skSubSeq:0};return i.conn=new Ff({port:e,hostInfo:this.hostInfo(),adoptCallerId:!0,context:{kind:"embedding-host",id:t,instanceId:null},methods:se(se(se(se(se(se(se(se(se({},this.stateMethods(t,null)),this.signalkMethods(i)),this.unitsMethods()),this.resourcesMethods(t)),this.mapMethods()),this.routeMethods()),this.chartMethods()),this.nightModeMethods()),this.uiPanelMethods(t)),onError:r=>console.warn("plotterext embedding-host error",r)}),this.contexts.add(i),()=>this.detach(i)}attachEmbeddingHostOnce(){this.embeddingHostDetach||this.app.isTopWindow()||(this.embeddingHostDetach=this.attachEmbeddingHost())}detach(e){if(this.contexts.has(e)){this.contexts.delete(e);for(let[,t]of e.skSubs)this.releasePaths(t);e.skSubs.clear(),e.conn.close()}}hostInfo(){return{host:"freeboard-sk",hostVersion:this.app.data?.server?.version??"dev",apiVersion:"1",capabilities:qC}}configDialogRef=null;configDialogInstance=null;widgetHasConfigPanel(e){let t=this.manifests()[e.extension],i=this.widgetDef(e.extension,e.widget),r=t?.panels?.find(o=>o.id===i?.configPanel);return!!(r&&r.type==="iframe"&&r.url)}openConfigPanel(e){let t=this.manifests()[e.extension],i=this.widgetDef(e.extension,e.widget),r=t?.panels?.find(a=>a.id===i?.configPanel),o=r&&r.type==="iframe"&&r.url&&(r.apiVersion===void 0||r.apiVersion==="1")?r:null;import("./chunk-H7UNBNCX.js").then(({PlotterPanelDialog:a})=>{let s=this.dialog.open(a,{data:{extension:e.extension,panel:o,title:i?.title??e.widget,targetInstance:e.instanceId,targetWidget:e.widget},width:"440px",maxHeight:"85vh"});this.configDialogRef=s,this.configDialogInstance=e.instanceId,s.afterClosed().subscribe(()=>{this.configDialogRef===s&&(this.configDialogRef=null,this.configDialogInstance=null)})})}toggleConfigPanel(e){if(this.configDialogRef&&this.configDialogInstance===e.instanceId){this.configDialogRef.close();return}this.openConfigPanel(e)}loadStore(){try{return JSON.parse(localStorage.getItem(HN)??"{}")}catch(e){return{}}}saveStore(e){localStorage.setItem(HN,JSON.stringify(e))}clearInstanceState(e,t){let i=this.loadStore();i[e]?.instances?.[t]&&(delete i[e].instances[t],this.saveStore(i))}stateMethods(e,t){let i=(r,o)=>{let a=r[e]=r[e]??{};if((o??(t?"instance":"extension"))==="instance"){if(!t)throw new si("No widget instance in scope",{code:Ki.INVALID_PARAMS,reason:"NO_INSTANCE"});return a.instances=a.instances??{},a.instances[t]=a.instances[t]??{}}return a.extension=a.extension??{}};return{"state.get":r=>J(this,null,function*(){let{scope:o,keys:a}=r??{},s=i(this.loadStore(),o);if(!a)return{values:s};let l={};for(let c of a)c in s&&(l[c]=s[c]);return{values:l}}),"state.set":r=>J(this,null,function*(){let{scope:o,values:a}=r??{};if(!a||typeof a!="object")throw new si("state.set requires a values object",{code:Ki.INVALID_PARAMS,reason:"INVALID_VALUES"});let s=this.loadStore(),l=i(s,o);Object.assign(l,a),this.saveStore(s);let c=(o??(t?"instance":"extension"))==="instance";return this.publishToExtension(e,"state.changed",{scope:c?"instance":"extension",instanceId:c?t:null,keys:Object.keys(a)}),{}})}}publishToExtension(e,t,i){for(let r of this.contexts)r.extension===e&&r.conn.publish(t,i)}broadcastMessage(e,t){for(let i of this.contexts)i.conn.publish(e,t)}resourcesMethods(e){return{"resources.list":t=>J(this,null,function*(){let{type:i,query:r}=t??{};if(typeof i!="string"||!/^[A-Za-z][A-Za-z0-9_-]*$/.test(i))throw new si("resources.list requires a resource type",{code:Ki.INVALID_PARAMS,reason:"INVALID_TYPE"});let o=this.serializeQuery(r);try{return(yield Fp(this.signalk.api.get(this.app.skApiVersion,`/resources/${i}${o}`)))??{}}catch(a){throw new si(`resources.list ${i} failed`,{reason:"LIST_FAILED",data:{message:a?.message}})}}),"resources.setFilter":t=>J(this,null,function*(){let{type:i,filter:r}=t??{};if(typeof i!="string"||!r||r.mode!=="include"&&r.mode!=="exclude"||r.ids===void 0&&r.match===void 0||r.ids!==void 0&&(!Array.isArray(r.ids)||!r.ids.every(o=>typeof o=="string"))||r.match!==void 0&&(!Array.isArray(r.match)||!r.match.every(Hoe)))throw new si("resources.setFilter requires a type and a filter with mode plus ids and/or match",{code:Ki.INVALID_PARAMS,reason:"INVALID_FILTER"});return this.setResourceFilter(e,i,r),{}}),"resources.clearFilter":t=>J(this,null,function*(){let{type:i}=t??{};if(typeof i!="string")throw new si("resources.clearFilter requires a type",{code:Ki.INVALID_PARAMS,reason:"INVALID_TYPE"});return this.clearResourceFilter(e,i),{}})}}serializeQuery(e){if(!e||typeof e!="object")return"";let t=[];for(let[i,r]of Object.entries(e)){if(r==null)continue;let o=Array.isArray(r)?JSON.stringify(r):String(r);t.push(`${encodeURIComponent(i)}=${encodeURIComponent(o)}`)}return t.length?`?${t.join("&")}`:""}mapView(){return{center:this.app.config.map.center,zoom:this.app.config.map.zoomLevel,bounds:this.app.mapExtent()}}prevMapView=null;emitMapViewChange(e){let t=this.prevMapView;this.prevMapView=e,!(t===null||t.zoom===e.zoom&&t.center[0]===e.center[0]&&t.center[1]===e.center[1]&&t.bounds.length===e.bounds.length&&t.bounds.every((r,o)=>r===e.bounds[o]))&&this.broadcastMessage("map.view",e)}mapMethods(){return{"map.getView":()=>J(this,null,function*(){return this.mapView()}),"map.center":e=>J(this,null,function*(){let{position:t,zoom:i}=e??{};if(!Array.isArray(t)||t.length!==2||!t.every(r=>typeof r=="number"))throw new si("map.center requires position [lon, lat]",{code:Ki.INVALID_PARAMS,reason:"INVALID_POSITION"});return this.app.mapMoveRequest.set(se({center:t},typeof i=="number"?{zoom:i}:{})),{}}),"map.fitBounds":e=>J(this,null,function*(){let{bounds:t}=e??{};if(!Array.isArray(t)||t.length!==4||!t.every(l=>typeof l=="number"))throw new si("map.fitBounds requires bounds [minLon, minLat, maxLon, maxLat]",{code:Ki.INVALID_PARAMS,reason:"INVALID_BOUNDS"});let[i,r,o,a]=t,s=[(i+o)/2,(r+a)/2];return this.app.mapMoveRequest.set({center:s,zoom:this.zoomForBounds(t)}),{}})}}zoomForBounds(e){let t=this.mapService.getMaps()[0],i=t?.getSize();if(!t||!i)return 12;let r=t.getView(),o=Gn(e,"EPSG:4326","EPSG:3857"),a=[i[0]*.85,i[1]*.85],s=r.getResolutionForExtent(o,a),l=r.getZoomForResolution(s)??12,c=this.app.MAP_ZOOM_EXTENT?.max??18;return Math.min(l,c)}pulseMapResize(e=320){let t=0,i=()=>{this.mapService.updateSize(),t+=16,t<e&&requestAnimationFrame(i)};requestAnimationFrame(i)}unitsMethods(){return{"units.get":()=>J(this,null,function*(){let e=this.app.config.units;return{units:{speed:e.speed,distance:e.distance,depth:e.depth,length:e.length,temperature:e.temperature}}})}}signalkMethods(e){return{"signalk.subscribe":t=>J(this,null,function*(){let{paths:i}=t??{};if(!Array.isArray(i)||i.length===0||!i.every(o=>typeof o=="string"&&o.length>0&&!o.includes("*")))throw new si("signalk.subscribe requires an array of literal Signal K paths",{code:Ki.INVALID_PARAMS,reason:"INVALID_PATHS"});let r=`sk-${++e.skSubSeq}`;return e.skSubs.set(r,i),this.acquirePaths(i),{subscriptionId:r}}),"signalk.unsubscribe":t=>J(this,null,function*(){let{subscriptionId:i}=t??{},r=i?e.skSubs.get(i):null;if(!r)throw new si("Unknown subscriptionId",{code:Ki.INVALID_PARAMS,reason:"UNKNOWN_SUBSCRIPTION"});return e.skSubs.delete(i),this.releasePaths(r),{}}),"signalk.put":t=>J(this,null,function*(){let{path:i,value:r}=t??{};if(typeof i!="string"||!i.length)throw new si("signalk.put requires a path",{code:Ki.INVALID_PARAMS,reason:"INVALID_PATH"});try{return(yield Fp(this.signalk.api.put(1,`vessels/self/${i.split(".").join("/")}`,r)))??{}}catch(o){throw new si(`PUT ${i} failed`,{reason:"PUT_FAILED",data:{message:o?.message}})}})}}acquirePaths(e){let t=[];for(let i of e){let r=this.pathRefs.get(i)??0;this.pathRefs.set(i,r+1),r===0&&t.push(i)}t.length&&(this.ensureSocket(),this.sendSubscribe(t))}releasePaths(e){let t=[];for(let i of e){let r=this.pathRefs.get(i)??0;r<=1?(this.pathRefs.delete(i),t.push(i)):this.pathRefs.set(i,r-1)}t.length&&this.wsReady&&this.wsSend({context:"vessels.self",unsubscribe:t.map(i=>({path:i}))}),this.pathRefs.size===0&&this.closeSocket()}ensureSocket(){if(this.ws)return;let e=this.app.data?.server?this.signalk.server?.endpoints?.v1?.["signalk-ws"]:null;if(!e){console.warn("plotterext: no signalk-ws endpoint available");return}let t=`${e}?subscribe=none`,i=this.app.getFBToken();i&&(t+=`&token=${i}`);let r=new WebSocket(t);this.ws=r,r.onopen=()=>{this.wsReady=!0;let o=[...this.pathRefs.keys()];o.length&&this.sendSubscribe(o)},r.onmessage=o=>this.handleDelta(o.data),r.onclose=()=>{this.ws===r&&(this.ws=null,this.wsReady=!1,this.pathRefs.size&&!this.reconnectTimer&&(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.ensureSocket()},3e3)))},r.onerror=()=>{}}closeSocket(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);let e=this.ws;this.ws=null,this.wsReady=!1,e?.close()}sendSubscribe(e){this.wsReady&&this.wsSend({context:"vessels.self",subscribe:e.map(t=>({path:t,period:Woe,policy:"instant",minPeriod:200}))})}wsSend(e){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify(e))}handleDelta(e){let t;try{t=JSON.parse(e)}catch(i){return}if(Array.isArray(t.updates)){for(let i of t.updates)if(Array.isArray(i.values))for(let r of i.values){if(!r?.path||!this.pathRefs.has(r.path))continue;let o={path:r.path,value:r.value,timestamp:i.timestamp,$source:i.$source??i.source?.label};for(let a of this.contexts)a.conn.publish(`sk.${r.path}`,o)}}}static \u0275fac=function(t){return new(t||n)(ct(ae),ct(Ot),ct(xn),ct(Pt),ct(Sl),ct(yc),ct(Xa))};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})};function Koe(n,e){if(n&1&&z(0,"wpt-button",1),n&2){let t=v();w("position",t.app.data.vessels.self.position)("active",t.app.data.vessels.showSelf)}}function $oe(n,e){n&1&&z(0,"pob-button")}function qoe(n,e){if(n&1&&z(0,"autopilot-button",2),n&2){let t=v();w("active",t.app.featureFlags().autopilotApi&&t.app.data.vessels.self.autopilot.default)}}function Zoe(n,e){if(n&1){let t=H();u(0,"radar-button",3),T("click",function(){O(t);let r=v();return F(r.radarClick.emit())}),p()}if(n&2){let t=v();w("active",t.app.featureFlags().radarApi&&t.radarApi.radarId().length!==0)}}var KN=class n{action=Z();radarClick=we();app=M(ae);radarApi=M(gc);plotterExt=M(Nf);bottomOffset=qt(()=>{let e=this.plotterExt.actionButtonLift();return e>0?e:23});constructor(){}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["mfb-container"]],inputs:{action:[1,"action"]},outputs:{radarClick:"radarClick"},decls:5,vars:6,consts:[[1,"mfb-container"],[3,"position","active"],[3,"active"],[3,"click","active"]],template:function(t,i){t&1&&(u(0,"div",0),R(1,Koe,1,2,"wpt-button",1),R(2,$oe,1,0,"pob-button"),R(3,qoe,1,1,"autopilot-button",2),R(4,Zoe,1,1,"radar-button",2),p()),t&2&&(Nt("bottom",i.bottomOffset(),"px"),g(),A(i.action()==="wpt"?1:-1),g(),A(i.action()==="pob"?2:-1),g(),A(i.action()==="autopilot"?3:-1),g(),A(i.action()==="radar"?4:-1))},dependencies:[V2,G2,z2,j2],styles:[".mfb-container[_ngcontent-%COMP%]{position:absolute;bottom:23px;right:5px;z-index:5000}"]})};var Xoe=["*"],Yoe=(n,e,t)=>({measure:n,compact:e,docked:t}),Qoe=n=>({measure:n});function Joe(n,e){if(n&1&&(u(0,"mat-icon"),z(1,"country-flag",7),p()),n&2){let t=v(2);g(),w("mmsi",t.mmsi)("host",t.app.hostDef.url)}}function eae(n,e){if(n&1&&z(0,"mat-icon",8),n&2){let t=v(2);Rt(t.icon==null?null:t.icon.class),w("svgIcon",t.icon.svgIcon)}}function tae(n,e){if(n&1&&(u(0,"mat-icon"),_(1),p()),n&2){let t=v(2);Rt(t.icon==null?null:t.icon.class),g(),q(t.icon==null?null:t.icon.name)}}function iae(n,e){if(n&1&&_(0),n&2){let t=v(2);$(" \xA0",t.title," ")}}function nae(n,e){if(n&1){let t=H();u(0,"div")(1,"button",9),T("click",function(){O(t);let r=v(2);return F(r.handleClose())}),u(2,"mat-icon"),_(3,"close"),p()()()}}function rae(n,e){if(n&1){let t=H();u(0,"div")(1,"button",10),T("click",function(){O(t);let r=v(2);return F(r.handleNavTo())}),u(2,"mat-icon"),_(3,"near_me"),p()()()}}function oae(n,e){if(n&1&&(u(0,"div",1)(1,"div",4),R(2,Joe,2,2,"mat-icon"),R(3,eae,1,3,"mat-icon",5)(4,tae,2,3,"mat-icon",6),R(5,iae,1,1),p(),R(6,nae,4,0,"div"),R(7,rae,4,0,"div"),p()),n&2){let t=v();g(),w("ngClass",an(6,Qoe,t.measure)),g(),A(t.mmsi?2:-1),g(),A(t.icon!=null&&t.icon.svgIcon?3:t.icon!=null&&t.icon.name?4:-1),g(2),A(t.title?5:-1),g(),A(t.canClose?6:-1),g(),A(!t.canClose&&t.navTo?7:-1)}}var pr=class n{title;mmsi;icon;canClose=!0;measure=!1;compact=!1;docked=!1;navTo=!1;closed=new he;navigateTo=new he;app=M(ae);constructor(){}handleClose(){this.closed.emit()}handleNavTo(){this.navigateTo.emit()}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["ap-popover"]],inputs:{title:"title",mmsi:"mmsi",icon:"icon",canClose:"canClose",measure:"measure",compact:"compact",docked:"docked",navTo:"navTo"},outputs:{closed:"closed",navigateTo:"navigateTo"},ngContentSelectors:Xoe,decls:5,vars:6,consts:[[1,"popover","top","in","mat-app-background",3,"ngClass"],[1,"popover-title"],[1,"popover-content"],[1,"arrow",2,"left","50%"],[2,"flex","1 1 auto","overflow","hidden","display","-webkit-box","-webkit-box-orient","vertical","-webkit-line-clamp","1","line-clamp","1","text-overflow","ellipsis",3,"ngClass"],[3,"class","svgIcon"],[3,"class"],[3,"mmsi","host"],[3,"svgIcon"],["mat-icon-button","",3,"click"],["mat-icon-button","","matTooltip","Navigate to here",3,"click"]],template:function(t,i){t&1&&(fe(),u(0,"div",0),R(1,oae,8,8,"div",1),u(2,"div",2),de(3),p(),z(4,"div",3),p()),t&2&&(w("ngClass",zp(2,Yoe,i.measure,i.compact,i.docked)),g(),A(i.title||i.icon||i.mmsi||i.canClose||i.navTo?1:-1))},dependencies:[hn,Ln,ue,Fe,be,Pe,le,ce,B2],styles:['.popover[_ngcontent-%COMP%]{position:absolute;top:0;left:0;transform:translate(-50%,-100%);z-index:3990;display:block;max-width:276px;min-width:270px;padding:1px;font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;line-height:1.42857143;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;letter-spacing:normal;word-break:normal;word-spacing:normal;word-wrap:normal;white-space:normal;-webkit-background-clip:padding-box;background-clip:padding-box;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px #0003;line-break:auto}.popover.top[_ngcontent-%COMP%]{margin-top:-10px;margin-left:10px}.popover-title[_ngcontent-%COMP%]{padding:2px 0 2px 5px;margin:0;display:flex;line-height:2.5em;font-size:12pt;background-color:#fafafa82;border-radius:5px 5px 0 0;min-width:110px}.popover-content[_ngcontent-%COMP%]{padding:9px 14px;max-height:330px;overflow:auto}.popover[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%], .popover[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]:after{position:absolute;display:block;width:0;height:0;border-style:solid}.popover[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]{border-width:11px}.popover[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]:after{content:"";border-width:10px}.popover.top[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]{bottom:-11px;left:50%;margin-left:-11px;border-bottom-width:0;border-right-width:0;border-left-width:0}.popover.top[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]:after{bottom:1px;margin-left:-10px;content:" ";border-bottom-width:0}.popover.measure[_ngcontent-%COMP%]{min-width:100px;background-color:#39c}.popover.measure[_ngcontent-%COMP%] > .popover-content[_ngcontent-%COMP%]{display:none}.popover.measure[_ngcontent-%COMP%] > .popover-title[_ngcontent-%COMP%]{color:#fff;font-weight:700;border-bottom:none;background-color:inherit;text-align:left;width:max-content}.popover.top.measure[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]{bottom:-11px;left:50%;margin-left:-11px;border-bottom-width:0;border-right-width:0;border-left-width:0}.popover.top.measure[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]:after{bottom:1px;margin-left:-10px;content:" ";border-bottom-width:0;border-top-color:#39c}.popover-action-button[_ngcontent-%COMP%]{flex:1 1 45%}.popover.docked[_ngcontent-%COMP%]{position:static;transform:none;margin:0}.popover.docked[_ngcontent-%COMP%] > .arrow[_ngcontent-%COMP%]{display:none}.popover.compact[_ngcontent-%COMP%]{min-width:0;max-width:170px;width:fit-content}.popover.compact[_ngcontent-%COMP%] > .popover-title[_ngcontent-%COMP%]{padding:0;line-height:0;min-height:0;min-width:unset}.popover.compact[_ngcontent-%COMP%] > .popover-content[_ngcontent-%COMP%]{padding:6px 10px}'],changeDetection:0})};var aae=n=>({class:"",name:n});function sae(n,e){if(n&1&&(u(0,"li"),_(1),p()),n&2){let t=e.$implicit;g(),q(t)}}function lae(n,e){if(n&1&&(u(0,"ol",4),Le(1,sae,2,1,"li",null,gt),p()),n&2){let t=v(2);g(),Ae(t.mode.steps)}}function cae(n,e){if(n&1){let t=H();u(0,"div",0)(1,"ap-popover",2),T("closed",function(){O(t);let r=v();return F(r.close())}),z(2,"fb-measurements",3),R(3,lae,3,0,"ol",4),u(4,"div",5)(5,"div",6)(6,"button",7),T("click",function(){O(t);let r=v();return F(r.undoLast())}),u(7,"mat-icon"),_(8,"undo"),p(),_(9," UNDO "),p()(),u(10,"div",6)(11,"button",8),T("click",function(){O(t);let r=v();return F(r.finishEditing())}),u(12,"mat-icon"),_(13,"check"),p(),_(14),p()(),u(15,"div",6)(16,"button",9),T("click",function(){O(t);let r=v();return F(r.close())}),u(17,"mat-icon",10),_(18,"close"),p(),_(19," CANCEL "),p()()()()()}if(n&2){let t=v();g(),w("docked",!0)("canClose",!0)("title",t.mode.iconText)("icon",an(13,aae,t.mode.iconName)),g(),w("coords",t.mapInteract.measurement().coords)("index",t.mapInteract.measurement().index)("totalOnly",t.mapInteract.isDrawing())("card",!0),g(),A(t.mode.steps.length!==0?3:-1),g(3),w("disabled",!t.mapInteract.canUndo()),g(5),w("disabled",!t.canFinish())("matTooltip",t.mapInteract.isModifying()?"Save changes":"Finish \u2014 keep changes"),g(3),$(" ",t.mapInteract.isModifying()?"SAVE":"FINISH"," ")}}function dae(n,e){if(n&1&&(u(0,"div",14),_(1),p()),n&2){let t=v(3);g(),$(" ",t.mode.description," ")}}function uae(n,e){if(n&1&&(u(0,"li"),_(1),p()),n&2){let t=e.$implicit;g(),q(t)}}function pae(n,e){if(n&1&&(u(0,"div",14)(1,"ol",17),Le(2,uae,2,1,"li",null,gt),p()()),n&2){let t=v(3);g(2),Ae(t.mode.steps)}}function hae(n,e){if(n&1){let t=H();u(0,"div",11)(1,"div")(2,"span",13)(3,"mat-icon"),_(4),p(),_(5),p(),R(6,dae,2,1,"div",14),R(7,pae,4,0,"div",14),p(),u(8,"div",15)(9,"a",16),T("click",function(){O(t);let r=v(2);return F(r.close())}),u(10,"mat-icon",10),_(11,"close"),p(),_(12),p()()()}if(n&2){let t=v(2);g(4),q(t.mode.iconName),g(),$(" ",t.mode.iconText," "),g(),A(t.mode.description.length!==0?6:-1),g(),A(t.mode.steps.length!==0?7:-1),g(2),w("matTooltip",t.mapInteract.isModifying()?"Finish Editing":"Cancel Operation"),g(3),$(" ",t.mapInteract.isModifying()?"FINISH":"CANCEL"," ")}}function mae(n,e){if(n&1){let t=H();u(0,"fb-measurements",18),T("cancel",function(){O(t);let r=v(2);return F(r.close())}),p()}if(n&2){let t=v(2);w("coords",t.mapInteract.measurement().coords)("index",t.mapInteract.measurement().index)}}function fae(n,e){if(n&1&&(u(0,"div",1),R(1,hae,13,6,"div",11),R(2,mae,1,2,"fb-measurements",12),p()),n&2){let t=v();g(),A(t.showHelpPanel()?1:-1),g(),A(t.showMeasurePanel()?2:-1)}}var $N=class n{finish=we();cancel=we();undo=we();showHelpPanel;showMeasurePanel;isRouteEditing;canFinish;mode={iconName:"",iconText:"",description:"",steps:[]};app=M(ae);mapInteract=M(_c);constructor(){this.showHelpPanel=qt(()=>this.mapInteract.isDrawing()&&this.mapInteract.draw.resourceType!=="route"||this.mapInteract.isModifying()||this.mapInteract.isBoxSelecting()||this.mapInteract.isMeasuring()&&this.mapInteract.measureGeometryType==="Circle"),this.showMeasurePanel=qt(()=>this.mapInteract.isMeasuring()&&this.mapInteract.measureGeometryType==="LineString"),this.isRouteEditing=qt(()=>this.mapInteract.draw.resourceType==="route"&&(this.mapInteract.isDrawing()||this.mapInteract.isModifying())),this.canFinish=qt(()=>this.mapInteract.isModifying()||this.mapInteract.measurement().coords.length>=2),this.isRouteEditing()?this.mode=this.mapInteract.isDrawing()?{iconName:"edit",iconText:"Draw New Route",description:"",steps:["Click / tap the map to add each point.","Double-click, or press Finish, to end."]}:{iconName:"edit",iconText:this.mapInteract.draw.name?`Modify ${this.mapInteract.draw.name}`:"Modify Route",description:"",steps:["Click and drag to move a point.","Ctrl-Click or press-and-hold to remove a point."]}:this.showHelpPanel()&&(this.mapInteract.isDrawing()?this.mode={iconName:"edit",iconText:"Drawing Help",description:this.mapInteract.draw.resourceType==="region"?"":"Click on the Map where to drop the feature.",steps:this.mapInteract.draw.resourceType==="region"?["Click on the Map to place a vertex of the Region.","Click on the last point to end drawing."]:[]}:this.mapInteract.isModifying()?this.mode={iconName:"edit",iconText:"Modify",description:this.mapInteract.draw.forSave.id==="anchor"?"Click and drag to move anchor.":"",steps:this.mapInteract.draw.forSave.id!=="anchor"?["Click and drag to move point.","Ctrl-Click or press-and-hold to remove point from a line."]:[]}:this.mapInteract.isBoxSelecting()?this.mode={iconName:"highlight_alt",iconText:"Select",description:"",steps:["Click and drag to select area.","On touch devices, press and hold then drag."]}:this.mapInteract.isMeasuring()&&this.mapInteract.measureGeometryType==="Circle"&&(this.mode={iconName:"straighten",iconText:"Measure",description:"",steps:["Click on the Map to start.","On touch devices, press and hold then move."]}))}close(){this.cancel.emit()}finishEditing(){this.finish.emit()}undoLast(){this.undo.emit()}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["fb-interact-help"]],outputs:{finish:"finish",cancel:"cancel",undo:"undo"},decls:2,vars:1,consts:[[1,"_ap_interact_dock"],[1,"mat-app-background","_ap_interact_help"],[3,"closed","docked","canClose","title","icon"],[3,"coords","index","totalOnly","card"],[1,"_ap_steps"],[1,"_ap_action_row"],[1,"_ap_action_button"],["mat-button","","matTooltip","Undo last change (Ctrl/Cmd-Z)","matTooltipPosition","after",3,"click","disabled"],["mat-button","","color","primary","matTooltipPosition","after",3,"click","disabled","matTooltip"],["mat-button","","matTooltip","Cancel \u2014 discard changes","matTooltipPosition","after",1,"icon-warn",3,"click"],[1,"icon-warn"],[1,"mat-app-background","measurePanel"],["matTooltip","Click on the Map to start. Click cancel or the last point to end.",3,"coords","index"],[2,"font-weight","bold","padding","5px"],[2,"padding","5px"],[2,"text-align","center","padding","6px 0 8px"],["mat-raised-button","","matTooltipPosition","left",1,"icon-warn",3,"click","matTooltip"],[2,"margin-block-start","0.2em","margin-block-end","0.2em","padding-inline-start","15px"],["matTooltip","Click on the Map to start. Click cancel or the last point to end.",3,"cancel","coords","index"]],template:function(t,i){t&1&&R(0,cae,20,15,"div",0)(1,fae,3,2,"div",1),t&2&&A(i.isRouteEditing()?0:1)},dependencies:[le,ce,ue,Xe,Pe,Et,N2,pr],styles:["._ap_interact_help[_ngcontent-%COMP%]{position:fixed;min-width:200px;top:60px;left:50px;border:black 1px solid;font-family:roboto;font-size:10pt}._ap_interact_dock[_ngcontent-%COMP%]{position:fixed;top:60px;left:50px;font-family:roboto;font-size:10pt}._ap_steps[_ngcontent-%COMP%]{margin-block-start:.2em;margin-block-end:.4em;padding-inline-start:18px}._ap_action_row[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap}._ap_action_button[_ngcontent-%COMP%]{flex:1 1 45%}._ap_row[_ngcontent-%COMP%]{display:flex;flex-wrap:no-wrap;flex:2}._ap_row[_ngcontent-%COMP%] .icon-label[_ngcontent-%COMP%]{width:30px}._ap_row[_ngcontent-%COMP%] .row-label[_ngcontent-%COMP%]{font-weight:500;min-width:60px}._ap_measurements[_ngcontent-%COMP%] .value[_ngcontent-%COMP%]{padding-right:10px}@media only screen and (max-width:500px){._ap_measurements[_ngcontent-%COMP%]{left:0;width:100%}}"],changeDetection:0})};var qN=70,gae=40,Pt=class n{reOpen;app=M(ae);dialog=M(xn);chartPaletteRef;chartPaletteEdit;signalk=M(Ot);worker=M(Wn);mapInteract=M(_c);constructor(){this.worker.resource$().subscribe(e=>this.processResourceMessage(e))}selectionIsFiltered(e){return Array.isArray(this.app.config.selections[e])}selectionHas(e,t){return!this.app.config.selections[e]||!this.selectionIsFiltered(e)?!1:this.app.config.selections[e].includes(t)}selectionAdd(e,t){if(!(typeof this.app.config.selections[e]>"u")&&this.selectionIsFiltered(e)){let i=typeof t=="string"?[t]:t;i=i.filter(r=>!this.app.config.selections[e].includes(r)),this.app.config.selections[e]=this.app.config.selections[e].concat(i),this.app.saveConfig()}}selectionRemove(e,t){if(!(typeof this.app.config.selections[e]>"u")&&this.selectionIsFiltered(e)){let i=typeof t=="string"?[t]:t;this.app.config.selections[e]=this.app.config.selections[e].filter(r=>!i.includes(r)),this.app.saveConfig()}}selectionUnfilter(e){this.app.config.selections[e]=null,this.app.saveConfig()}selectionClear(e){this.app.config.selections[e]=[],this.app.saveConfig()}selectionClean(e,t){Array.isArray(this.app.config.selections[e])&&(this.app.config.selections[e]=this.app.config.selections[e].filter(i=>t.includes(i)),this.app.saveConfig())}fetchRelatedNotes(e,t){return J(this,null,function*(){try{return yield this.listFromServer("notes",`href=/resources/${e}/${t}`)}catch(i){return[]}})}getCacheRef(e){switch(e){case"routes":return this.routeCacheSignal;case"waypoints":return this.waypointCacheSignal;case"notes":return this.noteCacheSignal;case"regions":return this.regionCacheSignal;case"charts":return this.chartCacheSignal;case"tracks":return this.trackCacheSignal}}fromCache(e,t){if(["routes","waypoints","notes","regions","charts","tracks"].includes(e)){let i=this.getCacheRef(e);if(!i){this.app.showAlert("Error","Collection not found!");return}return i().find(r=>r[0]===t)}else return!this.app.data[e]||!Array.isArray(this.app.data[e])?void 0:this.app.data[e].find(r=>r[0]===t)??void 0}listFromServer(e,t){return t?t=t.startsWith("?")?t:`?${t}`:t="",new Promise((i,r)=>{this.signalk.api.get(this.app.skApiVersion,`/resources/${e}${t}`)?.subscribe(a=>{let s=[];Object.keys(a).forEach(l=>{s.push([l,this.transform(e,a[l],l),this.selectionIsFiltered(e)?this.selectionHas(e,l):!0])}),i(s)},a=>r(a))})}fromServer(e,t){return new Promise((i,r)=>{this.signalk.api.get(this.app.skApiVersion,`/resources/${e}/${t}`).subscribe(o=>i(this.transform(e,o,t)),o=>r(o))})}transform(e,t,i){switch(e){case"regions":return this.transformRegion(t,i);case"routes":return this.transformRoute(t,i);case"waypoints":return this.transformWaypoint(t,i);case"notes":return this.transformNote(t,i);case"charts":return this.transformChart(t,i);case"tracks":return this.transformTrack(t)}}deleteFromServer(e,t,i){let r=i?`?provider=${i}`:"";return new Promise((o,a)=>{this.signalk.api.delete(this.app.skApiVersion,`/resources/${e}/${t}${r}`).subscribe(()=>o(),s=>a(s))})}putToServer(e,t,i,r){let o=r?`?provider=${r}`:"";return new Promise((a,s)=>{this.signalk.api.put(this.app.skApiVersion,`/resources/${e}/${t}${r?o:""}`,i).subscribe(l=>a(l),l=>s(l))})}postToServer(e,t){return new Promise((i,r)=>{this.signalk.api.post(this.app.skApiVersion,`/resources/${e}`,t).subscribe(o=>i(o),o=>r(o))})}processResourceMessage(e){if(!Array.isArray(e))return;let t={routes:!1,waypoints:!1,notes:!1,regions:!1,charts:!1};e.forEach(i=>{let r=i.path.split(".");if(r.length===3){let o=r[1],a=r[2];o in t&&(t[o]=!0),this.selectionIsFiltered(o)&&!i.value&&this.app.config.selections[o].includes(a)&&(this.app.config.selections[o].splice(this.app.config.selections[o].indexOf(a),1),this.app.saveConfig())}}),t.routes&&this.refreshRoutes(),t.waypoints&&this.refreshWaypoints(),t.regions&&this.refreshRegions(),t.notes&&this.refreshNotes(),t.charts&&this.refreshCharts()}resourceProperties(e){switch(e.type){case"waypoint":this.editWaypointInfo(e.id);break;case"route":this.editRouteInfo(e.id);break;case"note":this.showNoteDetails(e.id);break;case"region":this.editRegionInfo(e.id);break;case"chart":this.editChartInfo(e.id);break;case"track":this.editTrackInfo(e.id);break}}chartCacheSignal=X([]);charts=this.chartCacheSignal.asReadonly();appendOSM(e){let t=[["openstreetmap",new bs({name:"World Map",description:"Open Street Map"}),this.app&&this.selectionIsFiltered("charts")?this.app.config.selections.charts.includes("openstreetmap"):!0],["openseamap",new bs({name:"Sea Map",description:"Open Sea Map",url:"https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png",minzoom:1,maxzoom:24,bounds:[-180,-90,180,90],type:"tilelayer"}),this.app&&this.selectionIsFiltered("charts")?this.app.config.selections.charts.includes("openseamap"):!0]];return this.app&&t.forEach(i=>{let r=this.app.config.selections.chartOpacity[i[0]];typeof r<"u"&&(i[1].defaultOpacity=r);let o=this.app.config.selections.chartImageAdjustment?.[i[0]];typeof o<"u"&&(i[1].imageAdjustment=o);let a=this.app.config.selections.chartDisplayMinZoom?.[i[0]];typeof a<"u"&&(i[1].displayMinZoom=a)}),e.push(t[1]),e.unshift(t[0]),e}refreshCharts(e){return J(this,null,function*(){e&&e[0]!=="?"&&(e="?"+e),this.app.debug(`** refreshCharts(): ${e}`);try{let t=yield this.listFromServer("charts",e);this.appendOSM(t);let i=t.filter(r=>r[2]);i=this.sortByScaleDesc(i),i=this.arrangeChartLayers(i),this.chartCacheSignal.set(i),this.setMapZoomRange()}catch(t){this.app.debug("** refreshCharts:",t);let i=this.appendOSM([]);this.chartCacheSignal.set(i),this.setMapZoomRange()}})}transformChart(e,t){e.tilemapUrl&&(e.url=e.tilemapUrl),e.chartLayers&&(e.layers=e.chartLayers),e.serverType&&!e.type&&(e.type=e.serverType),e.type&&(e.url.startsWith("/")||!e.url.startsWith("http"))&&(e.url=this.app.hostDef.url+e.url),typeof this.app.config.selections.chartOpacity[t]<"u"&&(e.defaultOpacity=this.app.config.selections.chartOpacity[t]);let i=this.app.config.selections.chartImageAdjustment?.[t];typeof i<"u"&&(e.imageAdjustment=i);let r=this.app.config.selections.chartDisplayMinZoom?.[t];return typeof r<"u"&&(e.displayMinZoom=r),new bs(e)}setMapZoomRange(e){let t={min:2,max:28};if(e||!this.app.uiConfig().mapConstrainZoom)this.app.MAP_ZOOM_EXTENT=t;else{let i={min:1e3,max:-1};this.chartCacheSignal().forEach(r=>{r[2]&&(r[1].minZoom<i.min&&(i.min=r[1].minZoom),r[1].maxZoom>i.max&&(i.max=r[1].maxZoom))}),this.app.MAP_ZOOM_EXTENT={min:i.min===1e3?t.min:i.min,max:i.max===-1?t.max:i.max},this.app.debug("*** MAP_ZOOM_EXTENT",this.app.MAP_ZOOM_EXTENT)}}deleteChart(e){e&&this.app.showConfirm(`Do you want to delete this Chart source?
|
|
1124
1124
|
`,"Delete Chart:","YES","NO").subscribe(t=>{t&&t.ok&&this.deleteFromServer("charts",e,"resources-provider").then(()=>this.forgetChartSettings(e)).catch(i=>this.app.parseHttpErrorResponse(i))})}forgetChartSettings(e){let t=this.app.config.selections,i=[t.chartOpacity,t.chartImageAdjustment,t.chartDisplayMinZoom].filter(r=>e in r);i.length!==0&&(i.forEach(r=>delete r[e]),this.app.saveConfig())}sortByScaleDesc(e){return e.sort((t,i)=>i[1].scale-t[1].scale)}arrangeChartLayers(e){Array.isArray(this.app.config.selections.chartOrder)||(this.app.config.selections.chartOrder=[]);let t=this.app.config.selections.chartOrder;e.forEach(o=>{t.includes(o[0])||t.push(o[0])});let i=e.map(o=>o[0]),r=t.filter(o=>i.includes(o));for(let o=0;o<r.length;o++){let a=e.findIndex(s=>s[0]===r[o]);a!==-1&&il(e,a,o+1)}return e.slice()}chartReorder(){this.chartCacheSignal.update(e=>this.arrangeChartLayers(e))}chartAddFromServer(e){e?this.selectionIsFiltered("charts")&&this.selectionAdd("charts",e):this.selectionUnfilter("charts"),this.refreshCharts()}chartAdd(e){this.chartCacheSignal.update(t=>(this.selectionIsFiltered("charts")&&this.selectionAdd("charts",e.map(i=>i[0])),this.arrangeChartLayers(t.concat(e))))}chartRemove(e){this.chartCacheSignal.update(t=>e?(this.selectionRemove("charts",e),t.filter(i=>!e.includes(i[0]))):(this.selectionClear("charts"),this.app.saveConfig(),[]))}chartSetOpacity(e,t){if(!e||!Number.isFinite(t))return;this.chartCacheSignal().findIndex(r=>r[0]===e)!==-1&&this.chartCacheSignal.update(r=>r.map(o=>{if(o[0]!==e)return o;let a=new bs(o[1]);return a.defaultOpacity=t,[o[0],a,o[2]]}))}chartSetImageAdjustment(e,t){if(!e||!t)return;this.chartCacheSignal().findIndex(r=>r[0]===e)!==-1&&this.chartCacheSignal.update(r=>r.map(o=>{if(o[0]!==e)return o;let a=new bs(o[1]);return a.imageAdjustment=t,[o[0],a,o[2]]}))}chartSetDisplayMinZoom(e,t){if(!e)return;this.chartCacheSignal().findIndex(r=>r[0]===e)!==-1&&this.chartCacheSignal.update(r=>r.map(o=>{if(o[0]!==e)return o;let a=new bs(o[1]);return a.displayMinZoom=t,[o[0],a,o[2]]}))}openImageAdjustment(e){let t=e[0],i=se({brightness:1,contrast:1},this.app.config.selections.chartImageAdjustment[t]??e[1]?.imageAdjustment),r=this.openChartPalette(T2,{width:"290px",data:{text:e[1]?.name??"",value:se({},i),position:this.onScreenPalettePosition(this.app.config.imageAdjustPalettePos,290),onChange:o=>{this.chartSetImageAdjustment(t,o)},onMoved:o=>{this.app.config.imageAdjustPalettePos=o,this.app.saveConfig()}}},`imageAdjustment:${t}`);r.afterClosed().subscribe(o=>{let a=this.paletteHandedOver(`imageAdjustment:${t}`,r);this.releaseChartPalette(r),o?.apply?(this.app.config.selections.chartImageAdjustment[t]=o.value,this.chartSetImageAdjustment(t,o.value),this.app.saveConfig()):a||this.chartSetImageAdjustment(t,i)})}openDisplayMinZoom(e,t){let i=e[0],r=this.app.config.selections.chartDisplayMinZoom[i]??e[1]?.displayMinZoom,o=this.openChartPalette(E2,{width:"300px",data:{text:e[1]?.name??"",value:r,declaredMin:e[1]?.minZoom,declaredMax:e[1]?.maxZoom,currentZoom:()=>this.app.mapZoom(),onChange:a=>{this.chartSetDisplayMinZoom(i,a)}}},`displayMinZoom:${i}`);o.afterClosed().subscribe(a=>{let s=this.paletteHandedOver(`displayMinZoom:${i}`,o);this.releaseChartPalette(o),a?.apply?(typeof a.value=="number"?this.app.config.selections.chartDisplayMinZoom[i]=a.value:delete this.app.config.selections.chartDisplayMinZoom[i],this.chartSetDisplayMinZoom(i,a.value),this.app.saveConfig(),t?.(a.value)):s||this.chartSetDisplayMinZoom(i,r)})}openChartPalette(e,t,i){this.chartPaletteRef?.close();let r=this.dialog.open(e,se({hasBackdrop:!1,disableClose:!0,autoFocus:!1,restoreFocus:!1,position:{top:`${qN}px`,left:`${this.chartDialogLeft()}px`}},t));return this.chartPaletteRef=r,this.chartPaletteEdit=i,r}releaseChartPalette(e){this.chartPaletteRef===e&&(this.chartPaletteRef=void 0,this.chartPaletteEdit=void 0)}paletteHandedOver(e,t){return this.chartPaletteRef!==t&&this.chartPaletteEdit===e}onScreenPalettePosition(e,t){if(!e)return e;let i=this.chartDialogLeft(),r=window.innerWidth-i-t-8,o=-(i-8),a=Math.max(0,window.innerHeight-qN-gae);return{x:Math.max(o,Math.min(e.x,r)),y:Math.max(0,Math.min(e.y,a))}}chartDialogLeft(){return Math.max(8,Math.min(323,window.innerWidth-300-16))}chartSelected(e){e=Array.isArray(e)?e:[e],e.forEach(t=>{this.selectionHas("charts",t)?this.selectionRemove("charts",t):this.selectionAdd("charts",t)}),this.refreshCharts()}chartsForHostApi(){return J(this,null,function*(){let e;try{e=this.appendOSM(yield this.listFromServer("charts"))}catch(a){this.app.debug("** chartsForHostApi:",a),e=this.appendOSM([])}let t=new Set(e.map(a=>a[0])),i=this.chartCacheSignal().slice().reverse().filter(a=>t.has(a[0])),r=new Set(i.map(a=>a[0])),o=e.filter(a=>!r.has(a[0]));return i.concat(o)})}setChartsVisibility(e,t){return J(this,null,function*(){if(!Array.isArray(e)||e.length===0)return;let i;try{i=this.appendOSM(yield this.listFromServer("charts"))}catch(a){this.app.debug("** setChartsVisibility:",a);return}let r=new Set(i.filter(a=>a[2]).map(a=>a[0])),o=!1;e.forEach(a=>{r.has(a)!==t&&(o=!0,t?r.add(a):r.delete(a))}),o&&(r.size>=i.length?this.selectionUnfilter("charts"):(this.selectionClear("charts"),this.selectionAdd("charts",[...r])),yield this.refreshCharts())})}setChartsOpacity(e,t){!Array.isArray(e)||!Number.isFinite(t)||t<0||t>1||(e.forEach(i=>{this.app.config.selections.chartOpacity[i]=t,this.chartSetOpacity(i,t)}),this.app.saveConfig())}setChartsOrder(e){if(!Array.isArray(e))return;let t=Array.isArray(this.app.config.selections.chartOrder)?this.app.config.selections.chartOrder.slice():[],i=e.slice().reverse(),r=new Set(i),o=t.filter(a=>!r.has(a));this.app.config.selections.chartOrder=o.concat(i),this.app.saveConfig(),this.chartReorder()}newChart(e){e&&this.dialog.open(V_,{disableClose:!0,data:e}).afterClosed().subscribe(t=>J(this,null,function*(){if(t.save)try{let i=yield this.postToServer("charts",t.chart);this.selectionAdd("charts",i.id)}catch(i){this.app.parseHttpErrorResponse(i)}}))}editChartInfo(e){return J(this,null,function*(){if(!e)return;let t;if(["openseamap","openstreetmap"].includes(e))t=new bs({name:e==="openseamap"?"Sea Map":"World Map",description:e==="openseamap"?"Open Sea Map":"Open Street Map",url:`https://${e==="openseamap"?"tiles.openseamap.org/seamark":"tile.openstreetmap.org}/{z}/{x}/{y}.png"}`,minzoom:1,maxzoom:24,bounds:[-180,-90,180,90],type:"tilelayer"});else try{this.app.sIsFetching.set(!0),t=yield this.fromServer("charts",e),this.app.sIsFetching.set(!1)}catch(i){this.app.sIsFetching.set(!1),this.app.parseHttpErrorResponse(i);return}this.dialog.open(V_,{disableClose:!0,data:t}).afterClosed().subscribe(i=>{i.save&&this.putToServer("charts",e,this.withoutDisplayMinZoom(i.chart)).catch(r=>this.app.parseHttpErrorResponse(r))})})}withoutDisplayMinZoom(e){let t=se({},e);return delete t.displayMinZoom,t}seedChartCache(e,t){return J(this,null,function*(){if(!e||!Array.isArray(t)){this.app.showAlert("Selection Error","Invalid selection data!");return}let i=r=>({minLon:r[0][0],minLat:r[0][1],maxLon:r[1][0],maxLat:r[1][1]});if(t.length!==2){this.app.showAlert("Selection Error","Invalid selection!");return}this.dialog.open(O2,{data:{chart:e,bbox:t}}).afterClosed().subscribe(r=>{if(r>0){let o={bbox:i(t),maxZoom:r};this.app.debug(`Submit chart seed job ${JSON.stringify(o)} for chart ${e[0]}`),this.signalk.post(`/signalk/chart-tiles/cache/${e[0]}`,o).subscribe({next:a=>{this.app.showAlert("Chart Cache","Tile cache seed job created successfully.")},error:a=>{this.app.parseHttpErrorResponse(a)}})}})})}routeCacheSignal=X([]);routes=this.routeCacheSignal.asReadonly();refreshRoutes(e){return J(this,null,function*(){e&&e[0]!=="?"&&(e="?"+e),this.app.debug(`** refreshRoutes(): ${e}`);try{this.app.data.activeRoute&&this.selectionAdd("routes",this.app.data.activeRoute);let i=(yield this.listFromServer("routes",e)).filter(r=>r[2]);this.routeCacheSignal.set(i)}catch(t){this.app.debug("** refreshRoutes:",t),this.routeCacheSignal.set([])}})}transformRoute(e,t){if(typeof e.start<"u"&&delete e.start,typeof e.end<"u"&&delete e.end,typeof e.name>"u"&&(e.name="Rte-"+t.slice(-6)),e.feature&&!e.feature.properties&&(e.feature.properties={}),typeof e.feature?.properties?.points<"u"&&!Array.isArray(e.feature.properties.points)&&e.feature.properties.points.names&&Array.isArray(e.feature.properties.points.names)){let i=[];e.feature.properties.points.names.forEach(r=>{r?i.push({name:r}):i.push({name:""})}),e.feature.properties.coordinatesMeta=i,delete e.feature.properties.points}return e.feature?.properties?.coordinatesMeta&&e.feature.properties.coordinatesMeta.length!==e.feature.geometry.coordinates.length&&delete e.feature.properties.coordinatesMeta,new vs(e)}routeAddFromServer(e){e?this.selectionIsFiltered("routes")&&this.selectionAdd("routes",e):this.selectionUnfilter("routes"),this.refreshRoutes()}routeAdd(e){this.routeCacheSignal.update(t=>(this.selectionIsFiltered("routes")&&this.selectionAdd("routes",e.map(i=>i[0])),t.concat(e)))}routeRemove(e){this.routeCacheSignal.update(t=>e?(this.selectionRemove("routes",e),t.filter(i=>!e.includes(i[0]))):(this.selectionClear("routes"),[]))}routeHide(e){if(!this.selectionIsFiltered("routes")){let t=this.routeCacheSignal().map(i=>i[0]);this.selectionClear("routes"),this.selectionAdd("routes",t)}this.routeRemove([e])}buildRoute(e){let t=new vs,i=this.signalk.uuid;return t.feature.geometry.coordinates=oi.normaliseCoords(e),t.distance=oi.routeLength(t.feature.geometry.coordinates),[i,t,!0]}newRouteAt(e,t){if(!e)return;let i=this.buildRoute(e);t&&Array.isArray(t)&&(i[1].feature.properties.coordinatesMeta=t),this.newRoute(i[1])}newRoute(e){e&&this.dialog.open(Vf,{disableClose:!0,data:{title:"New Route",route:e}}).afterClosed().subscribe(t=>J(this,null,function*(){if(t.save)try{let i=yield this.postToServer("routes",t.route);this.selectionAdd("routes",i.id)}catch(i){this.app.parseHttpErrorResponse(i)}}))}saveNewRoute(e){return new Promise((t,i)=>{this.dialog.open(Vf,{disableClose:!0,data:{title:"Route Details",route:e}}).afterClosed().subscribe(r=>J(this,null,function*(){if(r?.save)try{let o=yield this.postToServer("routes",r.route);this.selectionAdd("routes",o.id),t(o.id)}catch(o){this.app.parseHttpErrorResponse(o),i(o)}else t(null)}))})}editRouteInfo(e){return J(this,null,function*(){if(!e)return;let t;try{this.app.sIsFetching.set(!0),t=yield this.fromServer("routes",e),this.app.sIsFetching.set(!1)}catch(i){this.app.sIsFetching.set(!1),this.app.parseHttpErrorResponse(i);return}this.dialog.open(Vf,{disableClose:!0,data:{title:"Route Details",addMode:!1,route:t}}).afterClosed().subscribe(i=>{i.save&&this.putToServer("routes",e,i.route).catch(r=>this.app.parseHttpErrorResponse(r))})})}deleteRoute(e){return J(this,null,function*(){if(!e)return!1;let t=yield this.fetchRelatedNotes("routes",e),i=t?.length!==0?"Delete attached Notes.":"";return new Promise(r=>{this.app.showConfirm(`Do you want to delete this Route from the server?
|
|
1125
1125
|
`,"Delete Route:","YES","NO",i).subscribe(o=>J(this,null,function*(){if(o&&o.ok)try{if(yield this.deleteFromServer("routes",e),o.checked){let a=yield Promise.allSettled(t.map(s=>this.deleteFromServer("notes",s[0])));for(let s of a)s.status==="rejected"&&this.app.parseHttpErrorResponse(s.reason)}r(!0)}catch(a){this.app.parseHttpErrorResponse(a),r(!1)}else r(!1)}))})})}updateRouteCoords(e,t,i){let r=this.fromCache("routes",e);if(!r)return Promise.resolve(!1);let o=r[1];return o.feature.geometry.coordinates=oi.normaliseCoords(t),o.distance=oi.routeLength(o.feature.geometry.coordinates),i&&(o.feature.properties.coordinatesMeta=i),this.putToServer("routes",e,o).then(()=>!0).catch(a=>(this.app.parseHttpErrorResponse(a),!1))}waypointCacheSignal=X([]);waypoints=this.waypointCacheSignal.asReadonly();refreshWaypoints(e){return J(this,null,function*(){e&&e[0]!=="?"&&(e="?"+e),this.app.debug(`** refreshWaypoints(): ${e}`);try{this.app.data.activeWaypoint&&this.selectionAdd("waypoints",this.app.data.activeWaypoint);let i=(yield this.listFromServer("waypoints",e)).filter(r=>r[2]);this.waypointCacheSignal.set(i)}catch(t){this.app.debug("** refreshWaypoints:",t),this.waypointCacheSignal.set([])}})}transformWaypoint(e,t){if(typeof e.position<"u"&&delete e.position,e.feature&&!e.feature.properties&&(e.feature.properties={}),!e.name)if(e.feature.properties.name)e.name=e.feature.properties.name,delete e.feature.properties.name;else{let i="Wpt-"+t.slice(-6);e.name=i}return e.description||(e.feature.properties.description?(e.description=e.feature.properties.description,delete e.feature.properties.description):e.feature.properties.cmt&&(e.description=e.feature.properties.cmt)),e.feature.properties.skType&&(e.type=e.feature.properties.skType,delete e.feature.properties.skType),e.type&&(e.type=e.type.toLowerCase()),new Td(e)}waypointAddFromServer(e){e?this.selectionIsFiltered&&this.selectionAdd("waypoints",e):this.selectionUnfilter("waypoints"),this.refreshWaypoints()}waypointAdd(e){this.waypointCacheSignal.update(t=>(this.selectionIsFiltered("waypoints")&&this.selectionAdd("waypoints",e.map(i=>i[0])),t.concat(e)))}waypointRemove(e){this.waypointCacheSignal.update(t=>e?(this.selectionRemove("waypoints",e),t.filter(i=>!e.includes(i[0]))):(this.selectionClear("waypoints"),[]))}buildWaypoint(e){let t=new Td,i=this.signalk.uuid;return t.feature.geometry.coordinates=oi.normaliseCoords(e),[i,t,!0]}newWaypointAt(e,t){if(!e)return;let i=this.buildWaypoint(e);i[1].name=t??`Wpt-${Date.now().toString().slice(-5)}`,this.newWaypoint(i[1])}newWaypoint(e){e&&this.dialog.open(G_,{disableClose:!0,data:{title:"New Waypoint",waypoint:e}}).afterClosed().subscribe(t=>J(this,null,function*(){if(t.save)try{let i=yield this.postToServer("waypoints",t.waypoint);this.selectionAdd("waypoints",i.id)}catch(i){this.app.parseHttpErrorResponse(i)}}))}editWaypointInfo(e){return J(this,null,function*(){if(!e)return;let t;try{this.app.sIsFetching.set(!0),t=yield this.fromServer("waypoints",e),this.app.sIsFetching.set(!1)}catch(i){this.app.sIsFetching.set(!1),this.app.parseHttpErrorResponse(i);return}this.dialog.open(G_,{disableClose:!0,data:{title:"Waypoint Details",addMode:!1,waypoint:t}}).afterClosed().subscribe(i=>{i.save&&this.putToServer("waypoints",e,i.waypoint).catch(r=>this.app.parseHttpErrorResponse(r))})})}deleteWaypoint(e){return J(this,null,function*(){if(!e)return;let t=yield this.fetchRelatedNotes("waypoints",e),i=t?.length!==0?"Delete attached Notes.":"";this.app.showConfirm(`Do you want to delete this Waypoint from the server?
|
|
1126
1126
|
`,"Delete Waypoint:","YES","NO",i).subscribe(r=>J(this,null,function*(){if(r&&r.ok)try{yield this.deleteFromServer("waypoints",e),r.checked&&t.forEach(o=>{this.deleteFromServer("notes",o[0])})}catch(o){this.app.parseHttpErrorResponse(o)}}))})}updateWaypointPosition(e,t){if(!e||!t)return;let i=this.fromCache("waypoints",e);if(!i)return;let r=i[1];r.feature.geometry.coordinates=oi.normaliseCoords(t),r.position={latitude:r.feature.geometry.coordinates[1],longitude:r.feature.geometry.coordinates[0]},this.putToServer("waypoints",e,r).catch(o=>{this.app.parseHttpErrorResponse(o)})}regionCacheSignal=X([]);regions=this.regionCacheSignal.asReadonly();refreshRegions(e){return J(this,null,function*(){e&&e[0]!=="?"&&(e="?"+e),this.app.debug(`** refreshRegions->query: ${e}`);try{let i=(yield this.listFromServer("regions",e)).filter(r=>r[2]);this.regionCacheSignal.set(i)}catch(t){this.app.debug("** refreshRegions:",t)}})}transformRegion(e,t){if(typeof e.geohash<"u"&&typeof e.geohash=="string"){let i=NE.default.decode_bbox(e.geohash),r=new Id;return r.name="Region-"+t.slice(-6),r.feature.geometry.coordinates=[[[i[1],i[0]],[i[3],i[0]],[i[3],i[2]],[i[1],i[2]],[i[1],i[0]]]],r}else return new Id(e)}newRegion(e){e&&this.dialog.open(B_,{disableClose:!0,data:{region:e}}).afterClosed().subscribe(t=>J(this,null,function*(){if(t.save)try{let i=yield this.postToServer("regions",t.region);this.selectionAdd("regions",i.id)}catch(i){this.app.parseHttpErrorResponse(i)}}))}editRegionInfo(e){return J(this,null,function*(){if(!e)return;let t;try{this.app.sIsFetching.set(!0),t=yield this.fromServer("regions",e),this.app.sIsFetching.set(!1)}catch(i){this.app.sIsFetching.set(!1),this.app.parseHttpErrorResponse(i);return}this.dialog.open(B_,{disableClose:!0,data:{region:t}}).afterClosed().subscribe(i=>{i.save&&this.putToServer("regions",e,i.region).catch(r=>this.app.parseHttpErrorResponse(r))})})}deleteRegion(e){return J(this,null,function*(){if(!e)return;let t=yield this.fetchRelatedNotes("regions",e),i=t?.length!==0?"Delete attached Notes.":"";this.app.showConfirm(`Do you want to delete this Region from the server?
|
|
@@ -4194,4 +4194,4 @@ Do you want to create a new group?`,"Group").pipe(Gt(this.destroyRef)).subscribe
|
|
|
4194
4194
|
border-top-right-radius: var(--mat-button-toggle-shape, var(--mat-sys-corner-extra-large));
|
|
4195
4195
|
border-top-left-radius: var(--mat-button-toggle-shape, var(--mat-sys-corner-extra-large));
|
|
4196
4196
|
}
|
|
4197
|
-
`],encapsulation:2,changeDetection:0})}return n})(),HV=(()=>{class n{static \u0275fac=function(i){return new(i||n)};static \u0275mod=Di({type:n});static \u0275inj=Ii({imports:[Ts,kC,An]})}return n})();var H0e=(n,e)=>e[0];function K0e(n,e){if(n&1&&(u(0,"mat-option",3),_(1),p()),n&2){let t=e.$implicit;v(2);let i=Sc(0);w("value",t),g(),$(" ",i.descriptions?i.descriptions[t]:t," ")}}function $0e(n,e){if(n&1){let t=H();u(0,"mat-select",17),T("selectionChange",function(r){O(t);let o=v().$implicit,a=v();return F(a.handleControl(o[0],r.value))}),Le(1,K0e,2,2,"mat-option",3,gt),p()}if(n&2){let t=v().$implicit,i=Sc(0),r=v();w("disabled",i.isReadOnly||!r.app.uiCtrl().radarLayer||r.forceReadOnly)("value",t[1].value),g(),Ae(i.validValues)}}function q0e(n,e){if(n&1&&z(0,"input",16),n&2){let t=v().$implicit,i=Sc(0),r=v();w("disabled",i.isReadOnly||!r.app.uiCtrl().radarLayer||r.forceReadOnly)("min",i.minValue??0)("max",i.maxValue??void 0)("value",t[1].value)}}function Z0e(n,e){if(n&1&&(Vp(0),u(1,"div",11)(2,"div",12)(3,"mat-form-field",13)(4,"mat-label"),_(5),p(),u(6,"mat-hint",14),_(7),p(),R(8,$0e,3,2,"mat-select",15)(9,q0e,1,4,"input",16),p()()()),n&2){let t=e.$implicit,i=Gp(v().radar().capabilities.controls[t[0]]);g(3),w("matTooltip",i.description),g(2),$(" ",i.name," "),g(2),$(" ",i.description," "),g(),A(i.dataType==="enum"||i.dataType==="number"&&i.validValues?8:i.dataType==="number"?9:-1)}}var KV=class n{radar=Z();id=Z(void 0);connect=we();disconnect=we();icon;app=M(ae);radarApi=M(gc);forceReadOnly=!1;constructor(){Me(()=>{this.radar()})}ngOnDestroy(){this.app.saveConfig()}handleConnect(e){e?this.connect.emit():this.disconnect.emit()}handleOpacity(e){this.app.config.radars.opacity=Number(e.target.value)}handleControl(e,t){console.log(e,t),this.radarApi.setControl(void 0,e,t).catch(i=>this.app.parseHttpErrorResponse(i))}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["radar-panel"]],inputs:{radar:[1,"radar"],id:[1,"id"]},outputs:{connect:"connect",disconnect:"disconnect"},decls:23,vars:10,consts:[[2,"display","flex","flex-direction","column","position","relative","width","stretch","height","100%"],[2,"display","flex"],["name","connection",3,"change","value","hideSingleSelectionIndicator"],[3,"value"],["svgIcon","radar-iec",1,"ob"],[2,"flex","1","font-size","10pt","padding","0 0 0 10px","text-align","right"],[2,"flex","1","padding-top","1em"],[2,"flex","1 1 auto"],["showTickMarks","","discrete","",2,"width","stretch",3,"min","max","step"],["matSliderThumb","",3,"input","value"],[2,"flex","2 1 auto","overflow-y","auto","padding-left","5px","padding-top","10px"],[1,"kvRow"],[2,"flex","2","text-align","right"],[2,"width","stretch",3,"matTooltip"],[2,"overflow","hidden","display","-webkit-box","-webkit-box-orient","vertical","-webkit-line-clamp","1","line-clamp","1","text-overflow","ellipsis"],[3,"disabled","value"],["matInput","","type","number",3,"disabled","min","max","value"],[3,"selectionChange","disabled","value"]],template:function(t,i){if(t&1&&(u(0,"div",0)(1,"div")(2,"div",1)(3,"div")(4,"mat-button-toggle-group",2),T("change",function(o){return i.handleConnect(o.value)}),u(5,"mat-button-toggle",3),_(6,"Off"),p(),u(7,"mat-button-toggle",3),_(8," On "),z(9,"mat-icon",4),p()()(),u(10,"div",5),_(11),z(12,"br"),_(13),p()(),u(14,"div",1)(15,"div",6),_(16,"Opacity"),p(),u(17,"div",7)(18,"mat-slider",8)(19,"input",9),T("input",function(o){return i.handleOpacity(o)}),p()()()()(),u(20,"div",10),Le(21,Z0e,10,5,"div",11,H0e),p()()),t&2){let r;g(4),w("value",i.app.uiCtrl().radarLayer)("hideSingleSelectionIndicator",!0),g(),w("value",!1),g(2),w("value",!0),g(4),$(" ",i.radar().device.name??i.radar().device.id??""," "),g(2),$(" ",(r=i.radar())==null||r.device==null?null:r.device.brand," "),g(5),w("min",0)("max",1)("step",.1),g(),w("value",i.app.config.radars.opacity),g(2),Ae(i.radar().controls)}},dependencies:[Ze,ue,le,ce,be,Pe,Vl,Ut,Wt,ks,Tt,ei,Ps,zl,Gl,HV,cI,kC,Bs,Ns,ss],styles:[".kvRow[_ngcontent-%COMP%]{display:flex;flex-direction:row;padding-left:5px;padding-top:15px}"]})};var $V=class{symDegree="\xBA";availableUnits={distance:new Map([["kilometer","Kilometres"],["naut-mile","Nautical Miles"]]),depth:new Map([["m","metres"],["foot","feet"],["fathom","fathom"]]),length:new Map([["m","metres"],["foot","feet"]]),speed:new Map([["kn","knots"],["m/s","m/sec"],["km/h","km/h"],["mph","mph"]]),temperature:new Map([["C","Celsius"],["F","Fahrenheit"]])};preferredValues={heading:[["navigation.headingTrue","True"],["navigation.headingMagnetic","Magnetic"]],wind:new Map([[!1,"Wind True"],[!0,"Wind Apparent"]]),coords:[["XY","-128.12345"],["SHDd",`W-128.12345${this.symDegree}`],["DMdH",`128${this.symDegree} 15.34567' W`],["HDd",`W 128.12345${this.symDegree}`],["HDMS",`W 128${this.symDegree}15'46"123`],["DHMS",`128W15'46"123`]]};buttons={fab:new Map([["wpt","Waypoint at vessel"],["pob","Person Overboard"],["autopilot","Autopilot Console"],["radar","Radar Overlay"]])};map={panBehavior:new Map([["offset","Set Follow Offset"],["exit","Exit Follow Mode"],["none","Do nothing"]]),s57:{graphicsStyle:new Map([["Simplified","Simplified"],["Paper","Paper chart"]]),boundaries:new Map([["Symbolized","Symbolized"],["Plain","Plain"]]),colors:[2,4],shallowDepth:2,safetyDepth:3,deepDepth:6,colorTables:new Map([[0,"Day Bright"],[1,"Day Black Background"],[2,"Day White Background"]]),otherLayers:new Map([["SOUNDG","Depth Soundings"],["DEPCNT","Depth Contours"],["OBSTRN","Obstructions"],["UWTROC","Underwater Rocks"],["WRECKS","Wrecks"],["CBLSUB","Submarine Cable"],["PIPSOL","Submarine Pipelines"],["BERTHS","Berths"],["MORFAC","Mooring Facilities"],["LNDMRK","Landmarks"],["DISMAR","Distance Marks"],["CURENT","Currents"],["MAGVAR","Magnetic Variation"],["RIVERS","Rivers"],["LAKARE","Lakes"]])}};trailIntervals={highResolution:new Map([["1s","1 sec"],["5s","5 secs"],["10s","10 secs"],["30s","30 secs"],["1m","1 min"]]),mediumResolution:new Map([["10s","10 secs"],["30s","30 secs"],["1m","1 min"],["2m","2 mins"],["5m","5 mins"],["10m","10 mins"],["15m","15 mins"],["30m","30 mins"]])};alarm={smoothing:new Map([[5e3,"5 secs"],[1e4,"10 secs"],[2e4,"20 secs"],[3e4,"30 secs"]])};darkMode=new Map([[0,"Use OS setting"],[1,"Use Signal K Mode"],[-1,"On"]]);windIndicator=new Map([["barb","Wind barb"],["arrow","Arrow"]]);vessel={selfIconScale:new Map([[.75,"S"],[.9,"M"],[1.15,"L"],[1.4,"XL"]]),headingLine:new Map([[-1,"Default"],[1,"1 nmi (2km)"],[2,"2 nmi (4km)"],[5,"5 nmi (10km)"],[10,"10 nmi (20km)"],[15,"15 nmi (30km)"],[20,"20 nmi (40km)"],[50,"50 nmi (90km)"],[100,"100 nmi (180km)"]]),cogLine:new Map([[0,"None"],[5,"5 min"],[10,"10 min"],[30,"30 min"],[60,"60 min"],[120,"2 hrs"],[1440,"24 hrs"]]),aisTimeouts:new Map([[6e4,"1 min"],[12e4,"2 min"],[18e4,"3 min"],[36e4,"6 min"],[54e4,"9 min"],[15*6e4,"15 min"],[30*6e4,"30 min"],[60*6e4,"1 hr"],[1440*6e4,"24 hrs"]]),aisMaxRadius:new Map([[0,"None"],[1e4,"5 nmi (10km)"],[2e4,"10 nmi (20km)"],[3e4,"15 nmi (30km)"],[4e4,"20 nmi (40km)"],[5e4,"25 nmi (50km)"],[75e3,"40 nmi (75km)"],[1e5,"55 nmi (100km)"]]),aisCogLine:new Map([[0,"Off"],[10,"10 min"],[30,"30 min"],[60,"60 min"]])};course={nextPointTrigger:["perpendicularPassed","arrivalCircleEntered"],nextPointDelay:this.alarm.smoothing};resources={noteRadius:[5,10,20,50,100,150,200,500],resSetRadius:[0,5,10,20,50,100,150,200,500]};zoomLevels=[8,9,10,11,12,13,14,15,16,17];rangeCircles={count:[4,5,6,7,8,9,10,15,20],zoomLevels:[2,3,4,5,6,7].concat(this.zoomLevels)}},wf=class n{constructor(e,t){this.app=e;this.signalk=t;this.changeEvent=new ze,this.change$=this.changeEvent.asObservable(),this.data=this.app.data,this.settings=this.app.config,this.fixedPosition=this.settings.vessels.fixedPosition.slice()}app;signalk;applicationList=[];favouritesList=[];resourcePathList=[];fixedPosition=[0,0];settings;data;changeEvent;change$;emitChangeEvent(e){let t=e?[e]:[];this.changeEvent.next(t)}clearToken(){this.app.persistToken(null)}refresh(){this.settings=this.app.config,this.fixedPosition=this.settings.vessels.fixedPosition.slice(),this.getApps(),this.getResourcePaths(),this.app.fetchUnitPrefsFromSKServer()}getResourcePaths(){this.signalk.api.get(this.app.skApiVersion,"resources").subscribe(e=>{this.resourcePathList=Object.keys(e).filter(t=>!this.app.IGNORE_RESOURCES.includes(t)).sort()},()=>this.resourcePathList=[])}getApps(){this.app.config.display.plugins.instruments&&this.applicationList.push(this.app.config.display.plugins.instruments),this.signalk.apps.list().subscribe(e=>{this.applicationList=e.map(t=>{if(t.name==="@signalk/freeboard-sk")return null;if(!t._location&&!t.location)return{name:t.name,description:t.description,url:`/${t.name}`};if(typeof t._location<"u"){let i=t._location.indexOf("/signalk-server/");return{name:t.name,description:t.description,url:i===-1?t._location:t._location.slice(15)}}else if(typeof t.location<"u")return{name:t.name,description:t.description,url:t.location}}).filter(t=>t),this.applicationList.unshift({name:"None",description:"",url:null}),this.buildFavouritesList()},()=>{this.app.debug("ERROR retrieving AppList!")})}buildFavouritesList(){this.favouritesList=this.applicationList.slice(1);let e=this.app.config.display.plugins.favourites.indexOf(this.app.config.display.plugins.instruments)}applySettings(){this.app.debug("Saving Settings.."),this.app.config.vessels.trail||(this.app.config.vessels.trailFromServer=!1),typeof this.fixedPosition[0]=="number"&&typeof this.fixedPosition[1]=="number"&&(this.settings.vessels.fixedPosition=this.fixedPosition.slice(),this.settings.vessels.fixedLocationMode&&(this.app.data.vessels.self.position=this.fixedPosition.slice())),this.app.saveConfig()}static \u0275fac=function(t){return new(t||n)(ct(ae),ct(Ot))};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})};function X0e(n,e){n&1&&z(0,"mat-progress-bar",4)}function Y0e(n,e){if(n&1&&(u(0,"div",5),_(1),p()),n&2){let t=v(2);g(),q(t.errorText)}}function Q0e(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.time)}}function J0e(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.temperature)}}function ege(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.dewPoint)}}function tge(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.wind==null?null:t.wind.speed)}}function ige(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.wind==null?null:t.wind.direction)}}function nge(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.wind==null?null:t.wind.gust)}}function rge(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.humidity)}}function oge(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.pressure)}}function age(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.rain)}}function sge(n,e){if(n&1&&(u(0,"div",6),z(1,"div",7),u(2,"div",8)(3,"span",9),_(4),p(),u(5,"div",10)(6,"div",7)(7,"span",11),_(8,"Lat:"),p(),_(9,"\xA0 "),z(10,"span",12),wt(11,"coords"),_(12," \xA0 "),p(),u(13,"div",7)(14,"span",11),_(15,"Lon:"),p(),_(16,"\xA0 "),z(17,"span",12),wt(18,"coords"),p()()(),z(19,"div",7),p(),u(20,"div",13)(21,"div",14)(22,"div",15)(23,"mat-icon"),_(24,"schedule"),p(),_(25,"Time "),p(),u(26,"div",16),_(27,"\xA0"),p(),Le(28,Q0e,2,1,"div",17,gt),p(),u(30,"div",14)(31,"div",15)(32,"mat-icon"),_(33,"device_thermostat"),p(),_(34,"Temp "),p(),u(35,"div",16),_(36),p(),Le(37,J0e,2,1,"div",17,gt),p(),u(39,"div",14)(40,"div",15)(41,"mat-icon"),_(42,"eco"),p(),_(43,"DewP"),p(),u(44,"div",16),_(45),p(),Le(46,ege,2,1,"div",17,gt),p(),u(48,"div",14)(49,"div",15)(50,"mat-icon"),_(51,"air"),p(),_(52,"Speed"),p(),u(53,"div",16),_(54),p(),Le(55,tge,2,1,"div",17,gt),p(),u(57,"div",14)(58,"div",15)(59,"mat-icon"),_(60,"explore"),p(),_(61,"Dir"),p(),u(62,"div",16),_(63,"\xA0"),p(),Le(64,ige,2,1,"div",17,gt),p(),u(66,"div",14)(67,"div",15)(68,"mat-icon"),_(69,"air"),p(),_(70,"Gust"),p(),u(71,"div",16),_(72),p(),Le(73,nge,2,1,"div",17,gt),p(),u(75,"div",14)(76,"div",15)(77,"mat-icon"),_(78,"opacity"),p(),_(79,"Hum. "),p(),u(80,"div",16),_(81),p(),Le(82,rge,2,1,"div",17,gt),p(),u(84,"div",14)(85,"div",15)(86,"mat-icon"),_(87,"compress"),p(),_(88,"Bar. "),p(),u(89,"div",16),_(90),p(),Le(91,oge,2,1,"div",17,gt),p(),u(93,"div",14)(94,"div",15)(95,"mat-icon"),_(96,"water_drop"),p(),_(97,"Rain "),p(),u(98,"div",16),_(99),p(),Le(100,age,2,1,"div",17,gt),p()()),n&2){let t=v(2);g(4),q(t.data.subTitle),g(6),w("innerText",Oi(11,10,t.data.position[1],t.app.config.units.positionFormat,!0)),g(7),w("innerText",Oi(18,14,t.data.position[0],t.app.config.units.positionFormat,!1)),g(11),Ae(t.forecasts),g(8),q(t.units.temp),g(),Ae(t.forecasts),g(8),q(t.units.temp),g(),Ae(t.forecasts),g(8),q(t.units.speed),g(),Ae(t.forecasts),g(9),Ae(t.forecasts),g(8),q(t.units.speed),g(),Ae(t.forecasts),g(8),q(t.units.humidity),g(),Ae(t.forecasts),g(8),q(t.units.pressure),g(),Ae(t.forecasts),g(8),q(t.units.precipitation),g(),Ae(t.forecasts)}}function lge(n,e){if(n&1&&R(0,Y0e,2,1,"div",5)(1,sge,102,18),n&2){let t=v();A(!t.forecasts||t.forecasts.length===0?0:1)}}var IC=class n{forecasts=[];isFetching=!1;errorText="No weather data found!";units;maxForecasts=12;app=M(ae);sk=M(Ot);modalRef=M(gr);data=M(Xr);destroyRef=M(Ai);constructor(){}ngOnInit(){this.getForecast(this.data.position),this.units={temp:Ge.getSymbol(this.app.config.units?.temperature.toUpperCase()),speed:this.app.formattedSpeedUnits,humidity:"%",pressure:"Pa",precipitation:"mm"}}getForecast(e){if(!this.app.featureFlags().weatherApi){this.errorText="Cannot retrieve forecasts as Weather API is not available!";return}if(!this.data.position){this.errorText="Cannot retrieve forecasts as location has not been supplied!";return}let t=`/weather/forecasts/point?lat=${e[1]}&lon=${e[0]}`;this.isFetching=!0,this.sk.api.get(2,t).pipe(Gt(this.destroyRef)).subscribe(i=>{this.isFetching=!1,i=i.slice(0,this.maxForecasts),Object.values(i).forEach(r=>{let o={wind:{}};o.description=r.description??"";let a=new Date(r.date);o.time=a?`${a.getHours()}:${("00"+a.getMinutes()).slice(-2)}`:"",typeof r.outside?.temperature<"u"?o.temperature=this.app.formatValueForDisplay(r.outside.temperature,"K",{noSymbol:!0}):o.temperature="--",typeof r.outside?.dewPointTemperature<"u"?o.dewPoint=this.app.formatValueForDisplay(r.outside?.dewPointTemperature,"K",{noSymbol:!0}):o.dewPoint="--",o.humidity=typeof r.outside?.absoluteHumidity<"u"?`${(r.outside?.absoluteHumidity*100).toFixed(0)}`:"--",o.pressure=typeof r.outside?.pressure<"u"?`${Math.round(r.outside?.pressure)}`:"--",o.rain=typeof r.outside?.precipitationVolume<"u"?`${(r.outside?.precipitationVolume*1e3).toFixed(2)}`:"--",typeof r.wind<"u"&&(o.wind.speed=typeof r.wind.speedTrue<"u"?`${this.app.formatSpeed(r.wind.speedTrue,!0)}`:"--",o.wind.gust=typeof r.wind.gust<"u"?`${this.app.formatSpeed(r.wind.gust,!0)}`:"--",o.wind.direction=typeof r.wind.directionTrue<"u"?`${this.toCardinal(Ge.radiansToDegrees(r.wind.directionTrue))}`:"--"),this.forecasts.push(o)})},()=>{this.isFetching=!1,this.errorText="Error retrieving weather data!"})}toCardinal(e){return e>348.75&&e<=11.25?"N":e>11.25&&e<=22.5?"NNE":e>22.5&&e<=67.5?"NE":e>67.5&&e<=78.75?"ENE":e>78.75&&e<=101.25?"E":e>101.25&&e<=112.5?"ESE":e>112.5&&e<=157.5?"SE":e>157.5&&e<=168.75?"SSE":e>168.75&&e<=191.25?"S":e>191.25&&e<=202.5?"SSW":e>202.5&&e<=245.5?"SW":e>245.5&&e<=258.75?"WSW":e>258.75&&e<=281.25?"W":e>281.25&&e<=292.5?"WNW":e>292.5&&e<=337.5?"NW":e>337.5&&e<=348.75?"NNW":"N"}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["weather-forecast-modal"]],decls:13,vars:2,consts:[[1,"_weather-forecast"],[2,"background-color","transparent"],[2,"flex","1 1 auto","padding-left","20px","text-align","center"],["mat-icon-button","","matTooltip","Close","matTooltipPosition","below",3,"click"],["mode","query"],[2,"text-align","center"],[2,"display","flex","flex-wrap","nowrap"],[2,"flex","1"],[2,"width","350px","text-align","center"],[2,"font-size","small"],[2,"font-size","small","text-align","left","display","flex","flex-wrap","wrap"],[2,"font-weight","bold"],[3,"innerText"],[1,"meteo"],[1,"meteo-row"],[1,"meteo-row-label"],[1,"meteo-row-units"],[1,"meteo-row-value"]],template:function(t,i){t&1&&(u(0,"div",0)(1,"mat-toolbar",1)(2,"span")(3,"mat-icon"),_(4,"air"),p()(),u(5,"span",2),_(6),p(),u(7,"span")(8,"button",3),T("click",function(){return i.modalRef.dismiss()}),u(9,"mat-icon"),_(10,"keyboard_arrow_down"),p()()()(),R(11,X0e,1,0,"mat-progress-bar",4)(12,lge,2,1),p()),t&2&&(g(6),$(" ",i.data.title," "),g(5),A(i.isFetching?11:12))},dependencies:[Ze,Cn,ue,Fe,le,ce,be,Pe,g1,Vl,Tt,Et,kt,Df,Tn,dn],styles:["._weather-forecast[_ngcontent-%COMP%]{font-family:arial}._weather-forecast[_ngcontent-%COMP%] .key-label[_ngcontent-%COMP%]{width:150px;font-weight:700}.meteo[_ngcontent-%COMP%]{overflow:auto;font-size:small}.meteo-row[_ngcontent-%COMP%]{display:flex;text-wrap-mode:nowrap;border-color:gray;border-style:solid;border-width:0;font-weight:700}.meteo-row-label[_ngcontent-%COMP%], .meteo-row-units[_ngcontent-%COMP%]{min-width:65px;border-color:inherit;border-style:inherit;border-width:0 0 1px 1px}.meteo-row-units[_ngcontent-%COMP%]{min-width:45px;max-width:45px;text-align:center}.meteo-row-value[_ngcontent-%COMP%]{border-width:0 1px 1px;border-color:inherit;border-style:inherit;min-width:50px;max-width:50px;text-align:center}.meteo-row[_ngcontent-%COMP%]:first-child div[_ngcontent-%COMP%]{border-top:gray 1px solid}.meteo-row[_ngcontent-%COMP%]:nth-child(odd) div[_ngcontent-%COMP%]{background-color:#d1f3d199;color:#000}"]})};var qV=class n{selected=new he;handleSelect(e,t){this.selected.emit({choice:e,value:t})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["fb-experiments"]],outputs:{selected:"selected"},decls:11,vars:1,consts:[["experimentsmenu","matMenu"],["mat-menu-item","",3,"click"],["mat-mini-fab","","matTooltip","Experiments","matTooltipPosition","left",1,"button-toolbar",3,"matMenuTriggerFor"]],template:function(t,i){if(t&1&&(u(0,"mat-menu",null,0)(2,"a",1),T("click",function(){return i.handleSelect("debugCapture")}),u(3,"mat-icon"),_(4,"adb"),p(),u(5,"span"),_(6,"Capture Debug Info"),p()()(),u(7,"div")(8,"button",2)(9,"mat-icon"),_(10,"science"),p()()()),t&2){let r=Oe(1);g(8),w("matMenuTriggerFor",r)}},dependencies:[rl,la,Ca,es,le,ce,ue,Es,be,Pe],encapsulation:2})};var PC=class n{constructor(e,t,i){this.app=e;this.skres=t;this.signalk=i;this.uploadSource=new ze,this.uploaded$=this.uploadSource.asObservable()}app;skres;signalk;errorCount=0;subCount=0;uploadSource;uploaded$;validate(e){try{let t=JSON.parse(e);return typeof t.type>"u"||t.type!=="FeatureCollection"||typeof t.features>"u"||!Array.isArray(t.features)?null:(t.features.forEach(i=>{i.type&&i.type==="Feature"&&i.geometry&&i.geometry.type&&(i.properties||(i.properties={}))}),t)}catch(t){return null}}uploadToServer(e){this.errorCount=0,this.subCount=0,e.features.forEach(t=>{if(t.type&&t.type==="Feature"&&t.geometry&&t.geometry.type)switch(t.geometry.type){case"LineString":this.transformRoute(t);break;case"Point":this.transformWaypoint(t);break;case"MultiLineString":this.transformTrack(t);break;case"Polygon":case"MultiPolygon":this.transformRegion(t);break}else console.warn("Parse GeoJSON: invalid feature data!")})}checkComplete(){this.subCount===0&&(this.uploadSource.next(this.errorCount),this.app.debug(`GeoJSONLoad: complete: ${this.errorCount}`))}transformRoute(e){let t=new vs;e.properties||(e.properties={}),typeof e.properties.name<"u"?(t.name=e.properties.name??"",delete e.properties.name):t.name=`rte-${new Date().getTime()}`,typeof e.properties.description<"u"?(t.description=e.properties.description??"",delete e.properties.description):t.description="GeoJSON import",t.feature=e,this.subCount++,this.signalk.api.post(this.app.skApiVersion,"/resources/routes",t).subscribe(i=>{this.subCount--,i.state==="COMPLETED"?this.app.debug("SUCCESS: GeoJSON Route added."):this.errorCount++,this.checkComplete()},()=>{this.errorCount++,this.subCount--,this.checkComplete()})}transformWaypoint(e){let t=new Td;e.properties||(e.properties={}),typeof e.properties.name<"u"?(t.name=e.properties.name??"",delete e.properties.name):t.name=`wpt-${new Date().getTime()}`,typeof e.properties.description<"u"?(t.description=e.properties.description??"",delete e.properties.description):t.description="GeoJSON import",t.feature=e,this.subCount++,this.signalk.api.post(this.app.skApiVersion,"/resources/waypoints",t).subscribe(i=>{this.subCount--,i.state==="COMPLETED"?this.app.debug("SUCCESS: GeoJSON Waypoint added."):this.errorCount++,this.checkComplete()},()=>{this.errorCount++,this.subCount--,this.checkComplete()})}transformTrack(e){e.properties||(e.properties={}),e.properties.name=typeof e.properties.name<"u"?e.properties.name??"":`trk-${new Date().getTime()}`,e.properties.description=typeof e.properties.description<"u"?e.properties.description??"":"GeoJSON import";let t=new Af({feature:e});this.subCount++,this.signalk.api.post(this.app.skApiVersion,"/resources/tracks",t).subscribe(i=>{this.subCount--,i.state==="COMPLETED"?this.app.debug("SUCCESS: GeoJSON Track added."):this.errorCount++,this.checkComplete()},()=>{this.errorCount++,this.subCount--,this.checkComplete()})}transformRegion(e){let t=new Id;e.properties||(e.properties={}),typeof e.properties.name<"u"?(t.name=e.properties.name??"",delete e.properties.name):t.name=`reg-${new Date().getTime()}`,typeof e.properties.description<"u"?(t.description=e.properties.description??"",delete e.properties.description):t.description="GeoJSON import",t.feature=e,this.subCount++,this.signalk.api.post(this.app.skApiVersion,"/resources/regions",t).subscribe(i=>{this.subCount--,i.state==="COMPLETED"?this.app.debug("SUCCESS: GeoJSON Region added."):this.errorCount++,this.checkComplete()},()=>{this.errorCount++,this.subCount--,this.checkComplete()})}static \u0275fac=function(t){return new(t||n)(ct(ae),ct(Pt),ct(Ot))};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})};function cge(n,e){if(n&1){let t=H();u(0,"div")(1,"div",6)(2,"b"),_(3,"Invalid GeoJSON Data:"),p(),z(4,"br")(5,"br"),u(6,"i"),_(7,"Selected file does not contain valid GeoJSON data or"),z(8,"br"),_(9," does not define a valid FeatureCollection. "),p(),z(10,"br"),p(),u(11,"div",7)(12,"button",8),T("click",function(){O(t);let r=v();return F(r.app.showHelp("geojson"))}),u(13,"mat-icon"),_(14,"help"),p(),_(15," Help "),p()()()}}function dge(n,e){if(n&1&&(u(0,"div",9)(1,"mat-card")(2,"mat-card-content")(3,"div",14)(4,"div",15)(5,"b"),_(6,"Point:"),p(),_(7," \xA0 "),p(),u(8,"div",16)(9,"mat-icon"),_(10,"arrow_forward"),p()(),u(11,"div",17)(12,"mat-icon",18),_(13,"place"),p(),u(14,"b"),_(15,"Waypoints:"),p(),_(16),p()()()()()),n&2){let t=v(2);g(16),$(" \xA0(",t.geoData==null?null:t.geoData.waypoints.length,") ")}}function uge(n,e){if(n&1&&(u(0,"div",9)(1,"mat-card")(2,"mat-card-content")(3,"div",14)(4,"div",15)(5,"b"),_(6,"LineString:"),p(),_(7," \xA0 "),p(),u(8,"div",16)(9,"mat-icon"),_(10,"arrow_forward"),p()(),u(11,"div",17)(12,"mat-icon",19),_(13,"directions"),p(),u(14,"b"),_(15,"Routes:"),p(),_(16),p()()()()()),n&2){let t=v(2);g(16),$(" \xA0(",t.geoData==null?null:t.geoData.routes.length,") ")}}function pge(n,e){if(n&1&&(u(0,"div",9)(1,"mat-card")(2,"mat-card-content")(3,"div",14)(4,"div",15)(5,"b"),_(6,"MultiLineString:"),p(),_(7," \xA0 "),p(),u(8,"div",16)(9,"mat-icon"),_(10,"arrow_forward"),p()(),u(11,"div",17)(12,"mat-icon",20),_(13,"show_chart"),p(),u(14,"b"),_(15,"Tracks:"),p(),_(16),p()()()()()),n&2){let t=v(2);g(16),$(" \xA0(",t.geoData==null?null:t.geoData.tracks.length,") ")}}function hge(n,e){if(n&1&&(u(0,"div",9)(1,"mat-card")(2,"mat-card-content")(3,"div",14)(4,"div",15)(5,"b"),_(6,"Polygon:"),p(),_(7," \xA0 "),p(),u(8,"div",16)(9,"mat-icon"),_(10,"arrow_forward"),p()(),u(11,"div",17)(12,"mat-icon"),_(13,"tab_unselected"),p(),u(14,"b"),_(15,"Regions:"),p(),_(16),p()()()()()),n&2){let t=v(2);g(16),$(" \xA0(",t.geoData==null?null:t.geoData.regions.length,") ")}}function mge(n,e){if(n&1){let t=H();u(0,"div",6)(1,"div",9)(2,"div",10)(3,"div",11)(4,"div",12),_(5),p()()()(),R(6,dge,17,1,"div",9),R(7,uge,17,1,"div",9),R(8,pge,17,1,"div",9),R(9,hge,17,1,"div",9),u(10,"div",7)(11,"button",13),T("click",function(){O(t);let r=v();return F(r.load())}),u(12,"mat-icon"),_(13,"file_upload"),p(),_(14," \xA0Load "),p()()()}if(n&2){let t=v();g(5),q(t.data.fileName),g(),A(t.geoData.waypoints.length!==0?6:-1),g(),A(t.geoData.routes.length!==0?7:-1),g(),A(t.geoData.tracks.length!=0&&t.app.featureFlags().resourceTracks?8:-1),g(),A(t.geoData.regions.length!==0?9:-1)}}var ZV=class n{geoData={name:"",routes:[],waypoints:[],tracks:[],regions:[],value:null};display={notValid:!1};unsubscribe=[];dialogRef=M(di);data=M(ui);app=M(ae);facade=M(PC);constructor(){}ngOnInit(){this.data.fileData=this.data.fileData||null,this.parseFileData(this.data.fileData),this.unsubscribe.push(this.facade.uploaded$.subscribe(e=>{this.dialogRef.close(e)}))}ngOnDestroy(){this.unsubscribe.forEach(e=>e.unsubscribe())}load(){this.facade.uploadToServer(this.geoData.value)}parseFileData(e){if(this.geoData.value=this.facade.validate(e),!this.geoData.value){console.warn("Error:","Invalid GeoJSON file!"),this.display.notValid=!0;return}this.geoData.value.features.forEach(t=>{if(t.type&&t.type==="Feature"&&t.geometry&&t.geometry.type)switch(t.geometry.type){case"LineString":this.geoData.routes.push(t);break;case"Point":this.geoData.waypoints.push(t);break;case"MultiLineString":this.geoData.tracks.push(t);break;case"Polygon":case"MultiPolygon":this.geoData.regions.push(t);break}})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["geojson-dialog"]],decls:13,vars:1,consts:[[1,"geojsonload-dialog"],[2,"background-color","transparent"],[1,"dialog-icon"],[2,"flex","1 1 auto","text-align","center"],[2,"text-align","right"],["mat-icon-button","",3,"click"],["mat-dialog-content",""],["mat-dialog-actions","","align","center"],["mat-raised-button","",3,"click"],[1,"card-group"],[1,"card-group-title"],[2,"display","flex","flex-wrap","wrap"],[2,"flex","1 1 auto"],["mat-raised-button","","matTooltip","Load features","matTooltipPosition","below",3,"click"],[1,"pnlRow"],[1,"pnlGeoType"],[1,"pnlArrow"],[1,"pnlSKType"],[1,"icon-waypoint"],[1,"icon-route"],[1,"icon-track"]],template:function(t,i){t&1&&(u(0,"div",0)(1,"mat-toolbar",1)(2,"span",2)(3,"mat-icon"),_(4,"public"),p()(),u(5,"span",3),_(6,"Load GeoJSON"),p(),u(7,"span",4)(8,"button",5),T("click",function(){return i.dialogRef.close(-1)}),u(9,"mat-icon"),_(10,"close"),p()()()(),R(11,cge,16,0,"div")(12,mge,15,5,"div",6),p()),t&2&&(g(11),A(i.display.notValid?11:12))},dependencies:[St,pi,Si,_i,le,ce,ue,Xe,Fe,Ze,Dt,jt,Od,Ti,be,Pe,Et,kt,Vl,Tt],styles:[".geojsonload-dialog[_ngcontent-%COMP%]{font-family:roboto;position:relative;width:100%}.dialog-icon[_ngcontent-%COMP%]{display:none}.card-group-title[_ngcontent-%COMP%]{font-weight:700;font-size:10pt;font-family:Arial,Helvetica,sans-serif;padding:10px 0}.card-group-row[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap}.card-group-row-item[_ngcontent-%COMP%]{padding-right:15px;max-width:60%}.pnlRow[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;width:100%}.pnlGeoType[_ngcontent-%COMP%]{flex:unset}.pnlArrow[_ngcontent-%COMP%]{width:30px;text-align:center}.pnlSKType[_ngcontent-%COMP%]{width:unset;padding-left:3px;padding-right:0;flex:1 1 auto}@media only screen and (min-width:475px){.dialog-content[_ngcontent-%COMP%]{min-width:400px}.dialog-icon[_ngcontent-%COMP%]{display:inline}}"]})};export{Bu as a,Ca as b,la as c,es as d,rl as e,Tn as f,Sr as g,Fu as h,Nu as i,qp as j,Zp as k,Od as l,MD as m,Ge as n,oi as o,w6 as p,Gu as q,Ot as r,Dp as s,xE as t,sGe as u,lGe as v,x9 as w,Xa as x,gc as y,ae as z,_c as A,Id as B,Af as C,Pt as D,Tu as E,aa as F,ZN as G,Co as H,yc as I,q2 as J,JN as K,rB as L,KE as M,uB as N,pB as O,hB as P,mB as Q,_B as R,yB as S,vB as T,bB as U,RB as V,AB as W,OB as X,Iu as Y,FB as Z,BB as _,eI as $,VB as aa,XB as ba,kpe as ca,JB as da,eV as ea,tV as fa,iV as ga,nV as ha,Ns as ia,ss as ja,Bs as ka,oV as la,sV as ma,nl as na,lV as oa,dV as pa,$f as qa,uV as ra,cC as sa,hV as ta,mV as ua,Nf as va,lI as wa,KV as xa,$V as ya,wf as za,IC as Aa,qV as Ba,ZV as Ca,RF as Da,LN as Ea,AN as Fa,ON as Ga,FN as Ha,NN as Ia,KN as Ja,$N as Ka};
|
|
4197
|
+
`],encapsulation:2,changeDetection:0})}return n})(),HV=(()=>{class n{static \u0275fac=function(i){return new(i||n)};static \u0275mod=Di({type:n});static \u0275inj=Ii({imports:[Ts,kC,An]})}return n})();var H0e=(n,e)=>e[0];function K0e(n,e){if(n&1&&(u(0,"mat-option",3),_(1),p()),n&2){let t=e.$implicit;v(2);let i=Sc(0);w("value",t),g(),$(" ",i.descriptions?i.descriptions[t]:t," ")}}function $0e(n,e){if(n&1){let t=H();u(0,"mat-select",17),T("selectionChange",function(r){O(t);let o=v().$implicit,a=v();return F(a.handleControl(o[0],r.value))}),Le(1,K0e,2,2,"mat-option",3,gt),p()}if(n&2){let t=v().$implicit,i=Sc(0),r=v();w("disabled",i.isReadOnly||!r.app.uiCtrl().radarLayer||r.forceReadOnly)("value",t[1].value),g(),Ae(i.validValues)}}function q0e(n,e){if(n&1&&z(0,"input",16),n&2){let t=v().$implicit,i=Sc(0),r=v();w("disabled",i.isReadOnly||!r.app.uiCtrl().radarLayer||r.forceReadOnly)("min",i.minValue??0)("max",i.maxValue??void 0)("value",t[1].value)}}function Z0e(n,e){if(n&1&&(Vp(0),u(1,"div",11)(2,"div",12)(3,"mat-form-field",13)(4,"mat-label"),_(5),p(),u(6,"mat-hint",14),_(7),p(),R(8,$0e,3,2,"mat-select",15)(9,q0e,1,4,"input",16),p()()()),n&2){let t=e.$implicit,i=Gp(v().radar().capabilities.controls[t[0]]);g(3),w("matTooltip",i.description),g(2),$(" ",i.name," "),g(2),$(" ",i.description," "),g(),A(i.dataType==="enum"||i.dataType==="number"&&i.validValues?8:i.dataType==="number"?9:-1)}}var KV=class n{radar=Z();id=Z(void 0);connect=we();disconnect=we();icon;app=M(ae);radarApi=M(gc);forceReadOnly=!1;constructor(){Me(()=>{this.radar()})}ngOnDestroy(){this.app.saveConfig()}handleConnect(e){e?this.connect.emit():this.disconnect.emit()}handleOpacity(e){this.app.config.radars.opacity=Number(e.target.value)}handleControl(e,t){console.log(e,t),this.radarApi.setControl(void 0,e,t).catch(i=>this.app.parseHttpErrorResponse(i))}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["radar-panel"]],inputs:{radar:[1,"radar"],id:[1,"id"]},outputs:{connect:"connect",disconnect:"disconnect"},decls:23,vars:10,consts:[[2,"display","flex","flex-direction","column","position","relative","width","stretch","height","100%"],[2,"display","flex"],["name","connection",3,"change","value","hideSingleSelectionIndicator"],[3,"value"],["svgIcon","radar-iec",1,"ob"],[2,"flex","1","font-size","10pt","padding","0 0 0 10px","text-align","right"],[2,"flex","1","padding-top","1em"],[2,"flex","1 1 auto"],["showTickMarks","","discrete","",2,"width","stretch",3,"min","max","step"],["matSliderThumb","",3,"input","value"],[2,"flex","2 1 auto","overflow-y","auto","padding-left","5px","padding-top","10px"],[1,"kvRow"],[2,"flex","2","text-align","right"],[2,"width","stretch",3,"matTooltip"],[2,"overflow","hidden","display","-webkit-box","-webkit-box-orient","vertical","-webkit-line-clamp","1","line-clamp","1","text-overflow","ellipsis"],[3,"disabled","value"],["matInput","","type","number",3,"disabled","min","max","value"],[3,"selectionChange","disabled","value"]],template:function(t,i){if(t&1&&(u(0,"div",0)(1,"div")(2,"div",1)(3,"div")(4,"mat-button-toggle-group",2),T("change",function(o){return i.handleConnect(o.value)}),u(5,"mat-button-toggle",3),_(6,"Off"),p(),u(7,"mat-button-toggle",3),_(8," On "),z(9,"mat-icon",4),p()()(),u(10,"div",5),_(11),z(12,"br"),_(13),p()(),u(14,"div",1)(15,"div",6),_(16,"Opacity"),p(),u(17,"div",7)(18,"mat-slider",8)(19,"input",9),T("input",function(o){return i.handleOpacity(o)}),p()()()()(),u(20,"div",10),Le(21,Z0e,10,5,"div",11,H0e),p()()),t&2){let r;g(4),w("value",i.app.uiCtrl().radarLayer)("hideSingleSelectionIndicator",!0),g(),w("value",!1),g(2),w("value",!0),g(4),$(" ",i.radar().device.name??i.radar().device.id??""," "),g(2),$(" ",(r=i.radar())==null||r.device==null?null:r.device.brand," "),g(5),w("min",0)("max",1)("step",.1),g(),w("value",i.app.config.radars.opacity),g(2),Ae(i.radar().controls)}},dependencies:[Ze,ue,le,ce,be,Pe,Vl,Ut,Wt,ks,Tt,ei,Ps,zl,Gl,HV,cI,kC,Bs,Ns,ss],styles:[".kvRow[_ngcontent-%COMP%]{display:flex;flex-direction:row;padding-left:5px;padding-top:15px}"]})};var $V=class{symDegree="\xBA";availableUnits={distance:new Map([["kilometer","Kilometres"],["naut-mile","Nautical Miles"]]),depth:new Map([["m","metres"],["foot","feet"],["fathom","fathom"]]),length:new Map([["m","metres"],["foot","feet"]]),speed:new Map([["kn","knots"],["m/s","m/sec"],["km/h","km/h"],["mph","mph"]]),temperature:new Map([["C","Celsius"],["F","Fahrenheit"]])};preferredValues={heading:[["navigation.headingTrue","True"],["navigation.headingMagnetic","Magnetic"]],wind:new Map([[!1,"Wind True"],[!0,"Wind Apparent"]]),coords:[["XY","-128.12345"],["SHDd",`W-128.12345${this.symDegree}`],["DMdH",`128${this.symDegree} 15.34567' W`],["HDd",`W 128.12345${this.symDegree}`],["HDMS",`W 128${this.symDegree}15'46"123`],["DHMS",`128W15'46"123`]]};buttons={fab:new Map([["wpt","Waypoint at vessel"],["pob","Person Overboard"],["autopilot","Autopilot Console"],["radar","Radar Overlay"]])};map={panBehavior:new Map([["offset","Set Follow Offset"],["exit","Exit Follow Mode"],["none","Do nothing"]]),s57:{graphicsStyle:new Map([["Simplified","Simplified"],["Paper","Paper chart"]]),boundaries:new Map([["Symbolized","Symbolized"],["Plain","Plain"]]),colors:[2,4],shallowDepth:2,safetyDepth:3,deepDepth:6,colorTables:new Map([[0,"Day Bright"],[1,"Day Black Background"],[2,"Day White Background"]]),otherLayers:new Map([["SOUNDG","Depth Soundings"],["DEPCNT","Depth Contours"],["OBSTRN","Obstructions"],["UWTROC","Underwater Rocks"],["WRECKS","Wrecks"],["CBLSUB","Submarine Cable"],["PIPSOL","Submarine Pipelines"],["BERTHS","Berths"],["MORFAC","Mooring Facilities"],["LNDMRK","Landmarks"],["DISMAR","Distance Marks"],["CURENT","Currents"],["MAGVAR","Magnetic Variation"],["RIVERS","Rivers"],["LAKARE","Lakes"]])}};trailIntervals={highResolution:new Map([["1s","1 sec"],["5s","5 secs"],["10s","10 secs"],["30s","30 secs"],["1m","1 min"]]),mediumResolution:new Map([["10s","10 secs"],["30s","30 secs"],["1m","1 min"],["2m","2 mins"],["5m","5 mins"],["10m","10 mins"],["15m","15 mins"],["30m","30 mins"]])};alarm={smoothing:new Map([[5e3,"5 secs"],[1e4,"10 secs"],[2e4,"20 secs"],[3e4,"30 secs"]])};darkMode=new Map([[0,"Use OS setting"],[1,"Use Signal K Mode"],[-1,"On"]]);windIndicator=new Map([["barb","Wind barb"],["arrow","Arrow"]]);vessel={selfIconScale:new Map([[.75,"S"],[.9,"M"],[1.15,"L"],[1.4,"XL"]]),headingLine:new Map([[-1,"Default"],[1,"1 nmi (2km)"],[2,"2 nmi (4km)"],[5,"5 nmi (10km)"],[10,"10 nmi (20km)"],[15,"15 nmi (30km)"],[20,"20 nmi (40km)"],[50,"50 nmi (90km)"],[100,"100 nmi (180km)"]]),cogLine:new Map([[0,"None"],[5,"5 min"],[10,"10 min"],[30,"30 min"],[60,"60 min"],[120,"2 hrs"],[1440,"24 hrs"]]),aisTimeouts:new Map([[6e4,"1 min"],[12e4,"2 min"],[18e4,"3 min"],[36e4,"6 min"],[54e4,"9 min"],[15*6e4,"15 min"],[30*6e4,"30 min"],[60*6e4,"1 hr"],[1440*6e4,"24 hrs"]]),aisMaxRadius:new Map([[0,"None"],[1e4,"5 nmi (10km)"],[2e4,"10 nmi (20km)"],[3e4,"15 nmi (30km)"],[4e4,"20 nmi (40km)"],[5e4,"25 nmi (50km)"],[75e3,"40 nmi (75km)"],[1e5,"55 nmi (100km)"]]),aisCogLine:new Map([[0,"Off"],[10,"10 min"],[30,"30 min"],[60,"60 min"]])};course={nextPointTrigger:["perpendicularPassed","arrivalCircleEntered"],nextPointDelay:this.alarm.smoothing};resources={noteRadius:[5,10,20,50,100,150,200,500],resSetRadius:[0,5,10,20,50,100,150,200,500]};zoomLevels=[8,9,10,11,12,13,14,15,16,17];rangeCircles={count:[4,5,6,7,8,9,10,15,20],zoomLevels:[2,3,4,5,6,7].concat(this.zoomLevels)}},wf=class n{constructor(e,t){this.app=e;this.signalk=t;this.changeEvent=new ze,this.change$=this.changeEvent.asObservable(),this.data=this.app.data,this.settings=this.app.config,this.fixedPosition=this.settings.vessels.fixedPosition.slice()}app;signalk;applicationList=[];favouritesList=[];resourcePathList=[];fixedPosition=[0,0];settings;data;changeEvent;change$;emitChangeEvent(e){let t=e?[e]:[];this.changeEvent.next(t)}clearToken(){this.app.setAuthToken(null)}refresh(){this.settings=this.app.config,this.fixedPosition=this.settings.vessels.fixedPosition.slice(),this.getApps(),this.getResourcePaths(),this.app.fetchUnitPrefsFromSKServer()}getResourcePaths(){this.signalk.api.get(this.app.skApiVersion,"resources").subscribe(e=>{this.resourcePathList=Object.keys(e).filter(t=>!this.app.IGNORE_RESOURCES.includes(t)).sort()},()=>this.resourcePathList=[])}getApps(){this.app.config.display.plugins.instruments&&this.applicationList.push(this.app.config.display.plugins.instruments),this.signalk.apps.list().subscribe(e=>{this.applicationList=e.map(t=>{if(t.name==="@signalk/freeboard-sk")return null;if(!t._location&&!t.location)return{name:t.name,description:t.description,url:`/${t.name}`};if(typeof t._location<"u"){let i=t._location.indexOf("/signalk-server/");return{name:t.name,description:t.description,url:i===-1?t._location:t._location.slice(15)}}else if(typeof t.location<"u")return{name:t.name,description:t.description,url:t.location}}).filter(t=>t),this.applicationList.unshift({name:"None",description:"",url:null}),this.buildFavouritesList()},()=>{this.app.debug("ERROR retrieving AppList!")})}buildFavouritesList(){this.favouritesList=this.applicationList.slice(1);let e=this.app.config.display.plugins.favourites.indexOf(this.app.config.display.plugins.instruments)}applySettings(){this.app.debug("Saving Settings.."),this.app.config.vessels.trail||(this.app.config.vessels.trailFromServer=!1),typeof this.fixedPosition[0]=="number"&&typeof this.fixedPosition[1]=="number"&&(this.settings.vessels.fixedPosition=this.fixedPosition.slice(),this.settings.vessels.fixedLocationMode&&(this.app.data.vessels.self.position=this.fixedPosition.slice())),this.app.saveConfig()}static \u0275fac=function(t){return new(t||n)(ct(ae),ct(Ot))};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})};function X0e(n,e){n&1&&z(0,"mat-progress-bar",4)}function Y0e(n,e){if(n&1&&(u(0,"div",5),_(1),p()),n&2){let t=v(2);g(),q(t.errorText)}}function Q0e(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.time)}}function J0e(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.temperature)}}function ege(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.dewPoint)}}function tge(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.wind==null?null:t.wind.speed)}}function ige(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.wind==null?null:t.wind.direction)}}function nge(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.wind==null?null:t.wind.gust)}}function rge(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.humidity)}}function oge(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.pressure)}}function age(n,e){if(n&1&&(u(0,"div",17),_(1),p()),n&2){let t=e.$implicit;g(),q(t.rain)}}function sge(n,e){if(n&1&&(u(0,"div",6),z(1,"div",7),u(2,"div",8)(3,"span",9),_(4),p(),u(5,"div",10)(6,"div",7)(7,"span",11),_(8,"Lat:"),p(),_(9,"\xA0 "),z(10,"span",12),wt(11,"coords"),_(12," \xA0 "),p(),u(13,"div",7)(14,"span",11),_(15,"Lon:"),p(),_(16,"\xA0 "),z(17,"span",12),wt(18,"coords"),p()()(),z(19,"div",7),p(),u(20,"div",13)(21,"div",14)(22,"div",15)(23,"mat-icon"),_(24,"schedule"),p(),_(25,"Time "),p(),u(26,"div",16),_(27,"\xA0"),p(),Le(28,Q0e,2,1,"div",17,gt),p(),u(30,"div",14)(31,"div",15)(32,"mat-icon"),_(33,"device_thermostat"),p(),_(34,"Temp "),p(),u(35,"div",16),_(36),p(),Le(37,J0e,2,1,"div",17,gt),p(),u(39,"div",14)(40,"div",15)(41,"mat-icon"),_(42,"eco"),p(),_(43,"DewP"),p(),u(44,"div",16),_(45),p(),Le(46,ege,2,1,"div",17,gt),p(),u(48,"div",14)(49,"div",15)(50,"mat-icon"),_(51,"air"),p(),_(52,"Speed"),p(),u(53,"div",16),_(54),p(),Le(55,tge,2,1,"div",17,gt),p(),u(57,"div",14)(58,"div",15)(59,"mat-icon"),_(60,"explore"),p(),_(61,"Dir"),p(),u(62,"div",16),_(63,"\xA0"),p(),Le(64,ige,2,1,"div",17,gt),p(),u(66,"div",14)(67,"div",15)(68,"mat-icon"),_(69,"air"),p(),_(70,"Gust"),p(),u(71,"div",16),_(72),p(),Le(73,nge,2,1,"div",17,gt),p(),u(75,"div",14)(76,"div",15)(77,"mat-icon"),_(78,"opacity"),p(),_(79,"Hum. "),p(),u(80,"div",16),_(81),p(),Le(82,rge,2,1,"div",17,gt),p(),u(84,"div",14)(85,"div",15)(86,"mat-icon"),_(87,"compress"),p(),_(88,"Bar. "),p(),u(89,"div",16),_(90),p(),Le(91,oge,2,1,"div",17,gt),p(),u(93,"div",14)(94,"div",15)(95,"mat-icon"),_(96,"water_drop"),p(),_(97,"Rain "),p(),u(98,"div",16),_(99),p(),Le(100,age,2,1,"div",17,gt),p()()),n&2){let t=v(2);g(4),q(t.data.subTitle),g(6),w("innerText",Oi(11,10,t.data.position[1],t.app.config.units.positionFormat,!0)),g(7),w("innerText",Oi(18,14,t.data.position[0],t.app.config.units.positionFormat,!1)),g(11),Ae(t.forecasts),g(8),q(t.units.temp),g(),Ae(t.forecasts),g(8),q(t.units.temp),g(),Ae(t.forecasts),g(8),q(t.units.speed),g(),Ae(t.forecasts),g(9),Ae(t.forecasts),g(8),q(t.units.speed),g(),Ae(t.forecasts),g(8),q(t.units.humidity),g(),Ae(t.forecasts),g(8),q(t.units.pressure),g(),Ae(t.forecasts),g(8),q(t.units.precipitation),g(),Ae(t.forecasts)}}function lge(n,e){if(n&1&&R(0,Y0e,2,1,"div",5)(1,sge,102,18),n&2){let t=v();A(!t.forecasts||t.forecasts.length===0?0:1)}}var IC=class n{forecasts=[];isFetching=!1;errorText="No weather data found!";units;maxForecasts=12;app=M(ae);sk=M(Ot);modalRef=M(gr);data=M(Xr);destroyRef=M(Ai);constructor(){}ngOnInit(){this.getForecast(this.data.position),this.units={temp:Ge.getSymbol(this.app.config.units?.temperature.toUpperCase()),speed:this.app.formattedSpeedUnits,humidity:"%",pressure:"Pa",precipitation:"mm"}}getForecast(e){if(!this.app.featureFlags().weatherApi){this.errorText="Cannot retrieve forecasts as Weather API is not available!";return}if(!this.data.position){this.errorText="Cannot retrieve forecasts as location has not been supplied!";return}let t=`/weather/forecasts/point?lat=${e[1]}&lon=${e[0]}`;this.isFetching=!0,this.sk.api.get(2,t).pipe(Gt(this.destroyRef)).subscribe(i=>{this.isFetching=!1,i=i.slice(0,this.maxForecasts),Object.values(i).forEach(r=>{let o={wind:{}};o.description=r.description??"";let a=new Date(r.date);o.time=a?`${a.getHours()}:${("00"+a.getMinutes()).slice(-2)}`:"",typeof r.outside?.temperature<"u"?o.temperature=this.app.formatValueForDisplay(r.outside.temperature,"K",{noSymbol:!0}):o.temperature="--",typeof r.outside?.dewPointTemperature<"u"?o.dewPoint=this.app.formatValueForDisplay(r.outside?.dewPointTemperature,"K",{noSymbol:!0}):o.dewPoint="--",o.humidity=typeof r.outside?.absoluteHumidity<"u"?`${(r.outside?.absoluteHumidity*100).toFixed(0)}`:"--",o.pressure=typeof r.outside?.pressure<"u"?`${Math.round(r.outside?.pressure)}`:"--",o.rain=typeof r.outside?.precipitationVolume<"u"?`${(r.outside?.precipitationVolume*1e3).toFixed(2)}`:"--",typeof r.wind<"u"&&(o.wind.speed=typeof r.wind.speedTrue<"u"?`${this.app.formatSpeed(r.wind.speedTrue,!0)}`:"--",o.wind.gust=typeof r.wind.gust<"u"?`${this.app.formatSpeed(r.wind.gust,!0)}`:"--",o.wind.direction=typeof r.wind.directionTrue<"u"?`${this.toCardinal(Ge.radiansToDegrees(r.wind.directionTrue))}`:"--"),this.forecasts.push(o)})},()=>{this.isFetching=!1,this.errorText="Error retrieving weather data!"})}toCardinal(e){return e>348.75&&e<=11.25?"N":e>11.25&&e<=22.5?"NNE":e>22.5&&e<=67.5?"NE":e>67.5&&e<=78.75?"ENE":e>78.75&&e<=101.25?"E":e>101.25&&e<=112.5?"ESE":e>112.5&&e<=157.5?"SE":e>157.5&&e<=168.75?"SSE":e>168.75&&e<=191.25?"S":e>191.25&&e<=202.5?"SSW":e>202.5&&e<=245.5?"SW":e>245.5&&e<=258.75?"WSW":e>258.75&&e<=281.25?"W":e>281.25&&e<=292.5?"WNW":e>292.5&&e<=337.5?"NW":e>337.5&&e<=348.75?"NNW":"N"}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["weather-forecast-modal"]],decls:13,vars:2,consts:[[1,"_weather-forecast"],[2,"background-color","transparent"],[2,"flex","1 1 auto","padding-left","20px","text-align","center"],["mat-icon-button","","matTooltip","Close","matTooltipPosition","below",3,"click"],["mode","query"],[2,"text-align","center"],[2,"display","flex","flex-wrap","nowrap"],[2,"flex","1"],[2,"width","350px","text-align","center"],[2,"font-size","small"],[2,"font-size","small","text-align","left","display","flex","flex-wrap","wrap"],[2,"font-weight","bold"],[3,"innerText"],[1,"meteo"],[1,"meteo-row"],[1,"meteo-row-label"],[1,"meteo-row-units"],[1,"meteo-row-value"]],template:function(t,i){t&1&&(u(0,"div",0)(1,"mat-toolbar",1)(2,"span")(3,"mat-icon"),_(4,"air"),p()(),u(5,"span",2),_(6),p(),u(7,"span")(8,"button",3),T("click",function(){return i.modalRef.dismiss()}),u(9,"mat-icon"),_(10,"keyboard_arrow_down"),p()()()(),R(11,X0e,1,0,"mat-progress-bar",4)(12,lge,2,1),p()),t&2&&(g(6),$(" ",i.data.title," "),g(5),A(i.isFetching?11:12))},dependencies:[Ze,Cn,ue,Fe,le,ce,be,Pe,g1,Vl,Tt,Et,kt,Df,Tn,dn],styles:["._weather-forecast[_ngcontent-%COMP%]{font-family:arial}._weather-forecast[_ngcontent-%COMP%] .key-label[_ngcontent-%COMP%]{width:150px;font-weight:700}.meteo[_ngcontent-%COMP%]{overflow:auto;font-size:small}.meteo-row[_ngcontent-%COMP%]{display:flex;text-wrap-mode:nowrap;border-color:gray;border-style:solid;border-width:0;font-weight:700}.meteo-row-label[_ngcontent-%COMP%], .meteo-row-units[_ngcontent-%COMP%]{min-width:65px;border-color:inherit;border-style:inherit;border-width:0 0 1px 1px}.meteo-row-units[_ngcontent-%COMP%]{min-width:45px;max-width:45px;text-align:center}.meteo-row-value[_ngcontent-%COMP%]{border-width:0 1px 1px;border-color:inherit;border-style:inherit;min-width:50px;max-width:50px;text-align:center}.meteo-row[_ngcontent-%COMP%]:first-child div[_ngcontent-%COMP%]{border-top:gray 1px solid}.meteo-row[_ngcontent-%COMP%]:nth-child(odd) div[_ngcontent-%COMP%]{background-color:#d1f3d199;color:#000}"]})};var qV=class n{selected=new he;handleSelect(e,t){this.selected.emit({choice:e,value:t})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["fb-experiments"]],outputs:{selected:"selected"},decls:11,vars:1,consts:[["experimentsmenu","matMenu"],["mat-menu-item","",3,"click"],["mat-mini-fab","","matTooltip","Experiments","matTooltipPosition","left",1,"button-toolbar",3,"matMenuTriggerFor"]],template:function(t,i){if(t&1&&(u(0,"mat-menu",null,0)(2,"a",1),T("click",function(){return i.handleSelect("debugCapture")}),u(3,"mat-icon"),_(4,"adb"),p(),u(5,"span"),_(6,"Capture Debug Info"),p()()(),u(7,"div")(8,"button",2)(9,"mat-icon"),_(10,"science"),p()()()),t&2){let r=Oe(1);g(8),w("matMenuTriggerFor",r)}},dependencies:[rl,la,Ca,es,le,ce,ue,Es,be,Pe],encapsulation:2})};var PC=class n{constructor(e,t,i){this.app=e;this.skres=t;this.signalk=i;this.uploadSource=new ze,this.uploaded$=this.uploadSource.asObservable()}app;skres;signalk;errorCount=0;subCount=0;uploadSource;uploaded$;validate(e){try{let t=JSON.parse(e);return typeof t.type>"u"||t.type!=="FeatureCollection"||typeof t.features>"u"||!Array.isArray(t.features)?null:(t.features.forEach(i=>{i.type&&i.type==="Feature"&&i.geometry&&i.geometry.type&&(i.properties||(i.properties={}))}),t)}catch(t){return null}}uploadToServer(e){this.errorCount=0,this.subCount=0,e.features.forEach(t=>{if(t.type&&t.type==="Feature"&&t.geometry&&t.geometry.type)switch(t.geometry.type){case"LineString":this.transformRoute(t);break;case"Point":this.transformWaypoint(t);break;case"MultiLineString":this.transformTrack(t);break;case"Polygon":case"MultiPolygon":this.transformRegion(t);break}else console.warn("Parse GeoJSON: invalid feature data!")})}checkComplete(){this.subCount===0&&(this.uploadSource.next(this.errorCount),this.app.debug(`GeoJSONLoad: complete: ${this.errorCount}`))}transformRoute(e){let t=new vs;e.properties||(e.properties={}),typeof e.properties.name<"u"?(t.name=e.properties.name??"",delete e.properties.name):t.name=`rte-${new Date().getTime()}`,typeof e.properties.description<"u"?(t.description=e.properties.description??"",delete e.properties.description):t.description="GeoJSON import",t.feature=e,this.subCount++,this.signalk.api.post(this.app.skApiVersion,"/resources/routes",t).subscribe(i=>{this.subCount--,i.state==="COMPLETED"?this.app.debug("SUCCESS: GeoJSON Route added."):this.errorCount++,this.checkComplete()},()=>{this.errorCount++,this.subCount--,this.checkComplete()})}transformWaypoint(e){let t=new Td;e.properties||(e.properties={}),typeof e.properties.name<"u"?(t.name=e.properties.name??"",delete e.properties.name):t.name=`wpt-${new Date().getTime()}`,typeof e.properties.description<"u"?(t.description=e.properties.description??"",delete e.properties.description):t.description="GeoJSON import",t.feature=e,this.subCount++,this.signalk.api.post(this.app.skApiVersion,"/resources/waypoints",t).subscribe(i=>{this.subCount--,i.state==="COMPLETED"?this.app.debug("SUCCESS: GeoJSON Waypoint added."):this.errorCount++,this.checkComplete()},()=>{this.errorCount++,this.subCount--,this.checkComplete()})}transformTrack(e){e.properties||(e.properties={}),e.properties.name=typeof e.properties.name<"u"?e.properties.name??"":`trk-${new Date().getTime()}`,e.properties.description=typeof e.properties.description<"u"?e.properties.description??"":"GeoJSON import";let t=new Af({feature:e});this.subCount++,this.signalk.api.post(this.app.skApiVersion,"/resources/tracks",t).subscribe(i=>{this.subCount--,i.state==="COMPLETED"?this.app.debug("SUCCESS: GeoJSON Track added."):this.errorCount++,this.checkComplete()},()=>{this.errorCount++,this.subCount--,this.checkComplete()})}transformRegion(e){let t=new Id;e.properties||(e.properties={}),typeof e.properties.name<"u"?(t.name=e.properties.name??"",delete e.properties.name):t.name=`reg-${new Date().getTime()}`,typeof e.properties.description<"u"?(t.description=e.properties.description??"",delete e.properties.description):t.description="GeoJSON import",t.feature=e,this.subCount++,this.signalk.api.post(this.app.skApiVersion,"/resources/regions",t).subscribe(i=>{this.subCount--,i.state==="COMPLETED"?this.app.debug("SUCCESS: GeoJSON Region added."):this.errorCount++,this.checkComplete()},()=>{this.errorCount++,this.subCount--,this.checkComplete()})}static \u0275fac=function(t){return new(t||n)(ct(ae),ct(Pt),ct(Ot))};static \u0275prov=et({token:n,factory:n.\u0275fac,providedIn:"root"})};function cge(n,e){if(n&1){let t=H();u(0,"div")(1,"div",6)(2,"b"),_(3,"Invalid GeoJSON Data:"),p(),z(4,"br")(5,"br"),u(6,"i"),_(7,"Selected file does not contain valid GeoJSON data or"),z(8,"br"),_(9," does not define a valid FeatureCollection. "),p(),z(10,"br"),p(),u(11,"div",7)(12,"button",8),T("click",function(){O(t);let r=v();return F(r.app.showHelp("geojson"))}),u(13,"mat-icon"),_(14,"help"),p(),_(15," Help "),p()()()}}function dge(n,e){if(n&1&&(u(0,"div",9)(1,"mat-card")(2,"mat-card-content")(3,"div",14)(4,"div",15)(5,"b"),_(6,"Point:"),p(),_(7," \xA0 "),p(),u(8,"div",16)(9,"mat-icon"),_(10,"arrow_forward"),p()(),u(11,"div",17)(12,"mat-icon",18),_(13,"place"),p(),u(14,"b"),_(15,"Waypoints:"),p(),_(16),p()()()()()),n&2){let t=v(2);g(16),$(" \xA0(",t.geoData==null?null:t.geoData.waypoints.length,") ")}}function uge(n,e){if(n&1&&(u(0,"div",9)(1,"mat-card")(2,"mat-card-content")(3,"div",14)(4,"div",15)(5,"b"),_(6,"LineString:"),p(),_(7," \xA0 "),p(),u(8,"div",16)(9,"mat-icon"),_(10,"arrow_forward"),p()(),u(11,"div",17)(12,"mat-icon",19),_(13,"directions"),p(),u(14,"b"),_(15,"Routes:"),p(),_(16),p()()()()()),n&2){let t=v(2);g(16),$(" \xA0(",t.geoData==null?null:t.geoData.routes.length,") ")}}function pge(n,e){if(n&1&&(u(0,"div",9)(1,"mat-card")(2,"mat-card-content")(3,"div",14)(4,"div",15)(5,"b"),_(6,"MultiLineString:"),p(),_(7," \xA0 "),p(),u(8,"div",16)(9,"mat-icon"),_(10,"arrow_forward"),p()(),u(11,"div",17)(12,"mat-icon",20),_(13,"show_chart"),p(),u(14,"b"),_(15,"Tracks:"),p(),_(16),p()()()()()),n&2){let t=v(2);g(16),$(" \xA0(",t.geoData==null?null:t.geoData.tracks.length,") ")}}function hge(n,e){if(n&1&&(u(0,"div",9)(1,"mat-card")(2,"mat-card-content")(3,"div",14)(4,"div",15)(5,"b"),_(6,"Polygon:"),p(),_(7," \xA0 "),p(),u(8,"div",16)(9,"mat-icon"),_(10,"arrow_forward"),p()(),u(11,"div",17)(12,"mat-icon"),_(13,"tab_unselected"),p(),u(14,"b"),_(15,"Regions:"),p(),_(16),p()()()()()),n&2){let t=v(2);g(16),$(" \xA0(",t.geoData==null?null:t.geoData.regions.length,") ")}}function mge(n,e){if(n&1){let t=H();u(0,"div",6)(1,"div",9)(2,"div",10)(3,"div",11)(4,"div",12),_(5),p()()()(),R(6,dge,17,1,"div",9),R(7,uge,17,1,"div",9),R(8,pge,17,1,"div",9),R(9,hge,17,1,"div",9),u(10,"div",7)(11,"button",13),T("click",function(){O(t);let r=v();return F(r.load())}),u(12,"mat-icon"),_(13,"file_upload"),p(),_(14," \xA0Load "),p()()()}if(n&2){let t=v();g(5),q(t.data.fileName),g(),A(t.geoData.waypoints.length!==0?6:-1),g(),A(t.geoData.routes.length!==0?7:-1),g(),A(t.geoData.tracks.length!=0&&t.app.featureFlags().resourceTracks?8:-1),g(),A(t.geoData.regions.length!==0?9:-1)}}var ZV=class n{geoData={name:"",routes:[],waypoints:[],tracks:[],regions:[],value:null};display={notValid:!1};unsubscribe=[];dialogRef=M(di);data=M(ui);app=M(ae);facade=M(PC);constructor(){}ngOnInit(){this.data.fileData=this.data.fileData||null,this.parseFileData(this.data.fileData),this.unsubscribe.push(this.facade.uploaded$.subscribe(e=>{this.dialogRef.close(e)}))}ngOnDestroy(){this.unsubscribe.forEach(e=>e.unsubscribe())}load(){this.facade.uploadToServer(this.geoData.value)}parseFileData(e){if(this.geoData.value=this.facade.validate(e),!this.geoData.value){console.warn("Error:","Invalid GeoJSON file!"),this.display.notValid=!0;return}this.geoData.value.features.forEach(t=>{if(t.type&&t.type==="Feature"&&t.geometry&&t.geometry.type)switch(t.geometry.type){case"LineString":this.geoData.routes.push(t);break;case"Point":this.geoData.waypoints.push(t);break;case"MultiLineString":this.geoData.tracks.push(t);break;case"Polygon":case"MultiPolygon":this.geoData.regions.push(t);break}})}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=W({type:n,selectors:[["geojson-dialog"]],decls:13,vars:1,consts:[[1,"geojsonload-dialog"],[2,"background-color","transparent"],[1,"dialog-icon"],[2,"flex","1 1 auto","text-align","center"],[2,"text-align","right"],["mat-icon-button","",3,"click"],["mat-dialog-content",""],["mat-dialog-actions","","align","center"],["mat-raised-button","",3,"click"],[1,"card-group"],[1,"card-group-title"],[2,"display","flex","flex-wrap","wrap"],[2,"flex","1 1 auto"],["mat-raised-button","","matTooltip","Load features","matTooltipPosition","below",3,"click"],[1,"pnlRow"],[1,"pnlGeoType"],[1,"pnlArrow"],[1,"pnlSKType"],[1,"icon-waypoint"],[1,"icon-route"],[1,"icon-track"]],template:function(t,i){t&1&&(u(0,"div",0)(1,"mat-toolbar",1)(2,"span",2)(3,"mat-icon"),_(4,"public"),p()(),u(5,"span",3),_(6,"Load GeoJSON"),p(),u(7,"span",4)(8,"button",5),T("click",function(){return i.dialogRef.close(-1)}),u(9,"mat-icon"),_(10,"close"),p()()()(),R(11,cge,16,0,"div")(12,mge,15,5,"div",6),p()),t&2&&(g(11),A(i.display.notValid?11:12))},dependencies:[St,pi,Si,_i,le,ce,ue,Xe,Fe,Ze,Dt,jt,Od,Ti,be,Pe,Et,kt,Vl,Tt],styles:[".geojsonload-dialog[_ngcontent-%COMP%]{font-family:roboto;position:relative;width:100%}.dialog-icon[_ngcontent-%COMP%]{display:none}.card-group-title[_ngcontent-%COMP%]{font-weight:700;font-size:10pt;font-family:Arial,Helvetica,sans-serif;padding:10px 0}.card-group-row[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap}.card-group-row-item[_ngcontent-%COMP%]{padding-right:15px;max-width:60%}.pnlRow[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;width:100%}.pnlGeoType[_ngcontent-%COMP%]{flex:unset}.pnlArrow[_ngcontent-%COMP%]{width:30px;text-align:center}.pnlSKType[_ngcontent-%COMP%]{width:unset;padding-left:3px;padding-right:0;flex:1 1 auto}@media only screen and (min-width:475px){.dialog-content[_ngcontent-%COMP%]{min-width:400px}.dialog-icon[_ngcontent-%COMP%]{display:inline}}"]})};export{Bu as a,Ca as b,la as c,es as d,rl as e,Tn as f,Sr as g,Fu as h,Nu as i,qp as j,Zp as k,Od as l,MD as m,Ge as n,oi as o,w6 as p,Gu as q,Ot as r,Dp as s,xE as t,sGe as u,lGe as v,x9 as w,Xa as x,gc as y,ae as z,_c as A,Id as B,Af as C,Pt as D,Tu as E,aa as F,ZN as G,Co as H,yc as I,q2 as J,JN as K,rB as L,KE as M,uB as N,pB as O,hB as P,mB as Q,_B as R,yB as S,vB as T,bB as U,RB as V,AB as W,OB as X,Iu as Y,FB as Z,BB as _,eI as $,VB as aa,XB as ba,kpe as ca,JB as da,eV as ea,tV as fa,iV as ga,nV as ha,Ns as ia,ss as ja,Bs as ka,oV as la,sV as ma,nl as na,lV as oa,dV as pa,$f as qa,uV as ra,cC as sa,hV as ta,mV as ua,Nf as va,lI as wa,KV as xa,$V as ya,wf as za,IC as Aa,qV as Ba,ZV as Ca,RF as Da,LN as Ea,AN as Fa,ON as Ga,FN as Ha,NN as Ia,KN as Ja,$N as Ka};
|