@qaecy/cue-ui 0.0.38 → 0.0.40
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/112.js +1 -1
- package/137.js +1 -0
- package/153.js +1 -0
- package/222.js +1 -0
- package/311.js +1 -1
- package/329.js +1 -0
- package/336.js +1 -1
- package/347.js +1 -0
- package/36.js +1 -1
- package/376.js +1 -1
- package/382.js +1 -1
- package/41.js +1 -0
- package/419.js +1 -1
- package/423.js +1 -0
- package/493.js +1 -1
- package/586.js +1 -0
- package/613.js +1 -0
- package/614.js +1 -0
- package/628.js +1 -0
- package/629.js +1 -1
- package/673.js +1 -0
- package/675.js +1 -1
- package/695.js +1 -0
- package/7.js +1 -0
- package/836.js +1 -0
- package/872.js +1 -1
- package/879.js +1 -0
- package/911.js +1 -0
- package/981.js +1 -0
- package/README.md +205 -11
- package/common.js +1 -1
- package/index.js +1 -1
- package/main.js +1 -1
- package/package.json +1 -1
- package/170.js +0 -1
- package/5.js +0 -1
- package/571.js +0 -1
- package/611.js +0 -1
- package/627.js +0 -1
- package/722.js +0 -1
- package/773.js +0 -1
- package/828.js +0 -1
- package/834.js +0 -1
- package/953.js +0 -1
- package/995.js +0 -1
package/872.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[170,872],{503(se,Q,u){var S=u(6119);function O(F){var l=0;if(F&&F.length>0){l+=Math.abs(z(F[0]));for(var R=1;R<F.length;R++)l-=Math.abs(z(F[R]))}return l}function z(F){var l,R,p,a,g,M,D=0,k=F.length;if(k>2){for(M=0;M<k;M++)M===k-2?(p=k-2,a=k-1,g=0):M===k-1?(p=k-1,a=0,g=1):(p=M,a=M+1,g=M+2),l=F[p],R=F[a],D+=(s(F[g][0])-s(l[0]))*Math.sin(s(R[1]));D=D*S.RADIUS*S.RADIUS/2}return D}function s(F){return F*Math.PI/180}se.exports.geometry=function m(F){var R,l=0;switch(F.type){case"Polygon":return O(F.coordinates);case"MultiPolygon":for(R=0;R<F.coordinates.length;R++)l+=O(F.coordinates[R]);return l;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(R=0;R<F.geometries.length;R++)l+=m(F.geometries[R]);return l}},se.exports.ring=z},5341(se){se.exports=function u(S){if(!S||!S.type)return null;var m=Q[S.type];return m?"geometry"===m?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:S}]}:"feature"===m?{type:"FeatureCollection",features:[S]}:"featurecollection"===m?S:void 0:null};var Q={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"}},6756(se,Q,u){"use strict";u.d(Q,{BK:()=>S,In:()=>P,Kz:()=>p,Mc:()=>g,U6:()=>O,g0:()=>M,g8:()=>z,r:()=>m,u9:()=>F});const S=["#2B5DE6","#1A2B50","#C5E045","#6FA8FF","#00C2E0","#5847EB","#008585","#4ADE80","#0F4C81","#8B5CF6","#FACC15","#FB923C","#F43F5E","#E879F9","#D97706","#334155","#64748B","#94A3B8","#C7D2FE","#F8FAFC"];function m(b){switch(b){case"primary":default:return"#2859e1";case"accent":return"#e2f552";case"tertiary":return"#ffffff"}}function O(b){switch(b){case"primary":default:return"#1744c2";case"accent":return"#b8cc3f";case"tertiary":return"#eeeeee"}}function z(b){const[A,U,B]=function s(b,A){if(void 0===b)return[];const B=window.getComputedStyle(b.nativeElement);return A.map(X=>B.getPropertyValue(X).trim()||"")}(b,["--cue-chart-text-color","--cue-chart-border-background-color","--chart-graph-edge-color"]);return{text:A,borderBackground:U,edgeColor:B}}const F={fontFamily:"Poppins, sans-serif",fontWeight:"normal",color:"#333"};function P(b){return b>=1e6?`${(b/1e6).toFixed(1)}m`:b>=1e3?`${(b/1e3).toFixed(0)}k`:b.toString()}function p(b,A,U,B){if(1===B)return b;const X=D(b),h=D(A),C=U/(B-1);return`rgb(${Math.round(X.r+(h.r-X.r)*C)}, ${Math.round(X.g+(h.g-X.g)*C)}, ${Math.round(X.b+(h.b-X.b)*C)})`}const g=(b,A)=>void 0===A?b:A.children??[];function M(b,A,U=.05,B="Other"){const X=b.reduce((x,L)=>x+k(L),0),h=[],C=[];if(b.forEach(x=>{let L,w;L=void 0===x.value&&Array.isArray(x.children)&&x.children.length>0?x.children.reduce((Z,J)=>Z+k(J),0):void 0!==x.value?x.value:0,Array.isArray(x.children)&&x.children.length>0&&(w=M(x.children,A,U,B));const W={...x,value:L,children:w};A&&X>0&&L/X<U?C.push(W):h.push(W)}),A&&C.length>0){const x=C.reduce((L,w)=>L+w.value,0);h.push({id:"__grouped_small__",name:B,value:x,children:C,isGroup:!0})}return h}function D(b){const A=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(b);return A?{r:parseInt(A[1],16),g:parseInt(A[2],16),b:parseInt(A[3],16)}:{r:0,g:0,b:0}}function k(b){return"number"==typeof b.value?b.value:Array.isArray(b.children)&&b.children.length>0?b.children.reduce((A,U)=>A+k(U),0):0}},4853(se,Q,u){"use strict";u.d(Q,{H:()=>b});var S=u(7705),m=u(5802),O=u(7089),z=u(7023),s=u(5381),F=u(5971),l=u(3319),R=u(356),P=u(6279),p=u(5547);const a=()=>({position:"bottomleft"}),g=(A,U)=>U.label||A;function M(A,U){if(1&A){const B=p.RV6();p.j41(0,"cue-menu-item",4),p.bIt("click",function(){const h=m.eBV(B).$implicit;return m.Njj(h.action())}),p.EFF(1),p.k0s()}if(2&A){const B=U.$implicit;p.Y8G("selected",B.selected),p.R7$(),p.JRh(B.label)}}function D(A,U){if(1&A&&(p.j41(0,"cue-menu-wrap"),p.Z7z(1,M,2,2,"cue-menu-item",3,g),p.k0s()),2&A){const B=p.XpG();p.R7$(),p.Dyx(B.contextMenuItems())}}function k(A,U){if(1&A){const B=p.RV6();p.j41(0,"cue-button",5),p.bIt("click",function(h){const C=m.eBV(B).$implicit,x=p.XpG();return m.Njj(x.handleClick(h,C))}),p.nrm(1,"cue-button-icon",6),p.k0s()}if(2&A){const B=U.$implicit,X=p.XpG(),h=p.sdS(1);p.Y8G("cueTooltip",B.label)("variant",B.variant?B.variant:X.variant())("size",X.size())("cueContextMenu",h)("contextMenuData",p.lJ4(7,a))("cueContextEnabled",void 0!==B.contextMenuItems&&B.contextMenuItems.length>0),p.R7$(),p.Y8G("icon",B.icon)}}let b=(()=>{class A{items=S.hFB.required();noGap=(0,S.hFB)(!0);direction=(0,S.hFB)("row");size=(0,S.hFB)("xs");variant=(0,S.hFB)("tertiary");mouseEnter=(0,S.CGW)();mouseLeave=(0,S.CGW)();contextMenuItems=(0,m.vPA)([]);handleClick(B,X){B.stopPropagation(),X.contextMenuItems&&X.contextMenuItems.length>0?this.contextMenuItems.set(X.contextMenuItems):X.action&&(this.contextMenuItems.set([]),X.action())}static \u0275fac=function(X){return new(X||A)};static \u0275cmp=p.VBU({type:A,selectors:[["cue-entity-menu"]],inputs:{items:[1,"items"],noGap:[1,"noGap"],direction:[1,"direction"],size:[1,"size"],variant:[1,"variant"]},outputs:{mouseEnter:"mouseEnter",mouseLeave:"mouseLeave"},decls:5,vars:2,consts:[["contextMenu",""],["gap","s","justify","end",2,"width","100%",3,"mouseenter","mouseleave","direction","noGap"],["trigger","leftclick",3,"cueTooltip","variant","size","cueContextMenu","contextMenuData","cueContextEnabled"],[3,"selected"],[3,"click","selected"],["trigger","leftclick",3,"click","cueTooltip","variant","size","cueContextMenu","contextMenuData","cueContextEnabled"],[3,"icon"]],template:function(X,h){1&X&&(p.DNE(0,D,3,0,"ng-template",null,0,p.C5r),p.j41(2,"cue-flexcontainer",1),p.bIt("mouseenter",function(){return h.mouseEnter.emit()})("mouseleave",function(){return h.mouseLeave.emit()}),p.Z7z(3,k,2,8,"cue-button",2,g),p.k0s()),2&X&&(p.R7$(2),p.Y8G("direction",h.direction())("noGap",h.noGap()),p.R7$(),p.Dyx(h.items()))},dependencies:[s.n,F.$,O.d,l.a,z.Q,R.M,P.D],encapsulation:2,changeDetection:0})}return A})()},1024(se,Q,u){"use strict";u.d(Q,{p:()=>O});var S=u(5547);const m=["*"];let O=(()=>{class z{static \u0275fac=function(l){return new(l||z)};static \u0275cmp=S.VBU({type:z,selectors:[["cue-key-val-list"]],ngContentSelectors:m,decls:2,vars:0,consts:[[1,"key-val-list"]],template:function(l,R){1&l&&(S.NAR(),S.rj2(0,"div",0),S.SdG(1),S.eux())},styles:[".key-val-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:var(--cue-grid-gap-s)}"]})}return z})()},9421(se,Q,u){"use strict";u.d(Q,{F:()=>l});var S=u(7705),m=u(5802),O=u(2271),z=u(7335),s=u(2245),F=u(5547);let l=(()=>{class R{entityMenuDirective;size=(0,S.hFB)("m");key=S.hFB.required();val=S.geq.required();options=(0,S.hFB)([]);suffix=(0,S.hFB)("");valueChange=(0,S.CGW)();editModeEnabled=(0,m.vPA)(!1);valueChanged=(0,O.EW)(()=>this.val()!==this.newValue());newValue=(0,O.uu)(()=>this.val());labelSize=(0,O.EW)(()=>{switch(this.size()){case"s":return"xs";case"m":return"s";case"l":return"m";case"xl":return"l"}});onKeyPress(p){this.editModeEnabled()&&("Escape"===p.key?(this._reset(),p.stopPropagation()):"Enter"===p.key&&this._emitChange())}saveCancelMenu=(0,O.EW)(()=>{const p=[{icon:"close",label:"Cancel",action:()=>this._reset()}];return this.valueChanged()&&p.push({icon:"save",label:"Save",action:()=>this._emitChange()}),p});selectionChange(p){this.newValue.set(p?.toString()??"")}inputChange(p){this.newValue.set(p)}_emitChange(){this.valueChange.emit(this.newValue()),this.val.set(this.newValue()),this.editModeEnabled.set(!1)}_reset(){this.newValue.set(this.val()),this.editModeEnabled.set(!1)}static \u0275fac=function(a){return new(a||R)};static \u0275cmp=F.VBU({type:R,selectors:[["cue-key-val"]],viewQuery:function(a,g){if(1&a&&F.GBs(z.e,5),2&a){let M;F.mGM(M=F.lsd())&&(g.entityMenuDirective=M.first)}},hostBindings:function(a,g){1&a&&F.bIt("keydown",function(D){return g.onKeyPress(D)},F.EBC)},inputs:{size:[1,"size"],key:[1,"key"],val:[1,"val"],options:[1,"options"],suffix:[1,"suffix"]},outputs:{val:"valChange",valueChange:"valueChange"},decls:8,vars:5,consts:[[1,"key-val-container"],[3,"size"],[1,"value-content"]],template:function(a,g){1&a&&(F.j41(0,"dl",0)(1,"dt")(2,"cue-typography",1),F.EFF(3),F.k0s()(),F.j41(4,"dd")(5,"cue-typography",1)(6,"span",2),F.EFF(7),F.k0s()()()()),2&a&&(F.R7$(2),F.Y8G("size",g.labelSize()),F.R7$(),F.JRh(g.key()),F.R7$(2),F.Y8G("size",g.size()),F.R7$(2),F.Lme("",g.val()," ",g.suffix()))},dependencies:[s.Typography],styles:[".key-val-container[_ngcontent-%COMP%]{margin:0;display:flex;flex-direction:column;gap:var(--cue-grid-gap-s, 8px)}dt[_ngcontent-%COMP%], dd[_ngcontent-%COMP%]{margin:0}.read-mode-container[_ngcontent-%COMP%]{display:inline-flex;align-items:center;width:100%;position:relative}.read-mode-container.interactive[_ngcontent-%COMP%]:hover{cursor:pointer}.value-content[_ngcontent-%COMP%]{flex:1}[_nghost-%COMP%]{color:var(--cue-typography-text-color, inherit)}dt[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%], dd[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%], .value-content[_ngcontent-%COMP%]{color:var(--cue-typography-text-color, inherit)!important}dt[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%] div[_ngcontent-%COMP%], dd[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%] div[_ngcontent-%COMP%]{color:var(--cue-typography-text-color, inherit)!important}[_ngcontent-%COMP%]:deep(cue-svg-icon), [_ngcontent-%COMP%]:deep(cue-entity-menu cue-svg-icon){color:var(--cue-icon-color, inherit)!important}.dirty-indicator[_ngcontent-%COMP%]{opacity:.8;margin-left:4px;color:var(--cue-typography-text-color, inherit)!important;font-weight:700;font-size:.4em;transform:translateY(-1em)}"]})}return R})()},7517(se,Q,u){"use strict";u.d(Q,{P:()=>M});var S=u(7705),m=u(2271),O=u(2245),z=u(1359),s=u(5381),F=u(5802),l=u(5547);const R=(D,k)=>k.category;function P(D,k){if(1&D){const b=l.RV6();l.j41(0,"cue-flexcontainer",1)(1,"cue-checkbox",2),l.bIt("checkedChange",function(){F.eBV(b);const U=l.XpG();return F.Njj(U.toggleAll())}),l.k0s()()}if(2&D){const b=l.XpG();l.R7$(),l.Y8G("checked",b.allVisible())}}function p(D,k){if(1&D&&(l.j41(0,"cue-typography",3),l.EFF(1),l.k0s()),2&D){const b=l.XpG().$implicit;l.R7$(),l.JRh(b.category)}}function a(D,k){if(1&D){const b=l.RV6();l.j41(0,"cue-flexcontainer",1)(1,"cue-checkbox",4),l.bIt("checkedChange",function(){const U=F.eBV(b).$implicit,B=l.XpG(2);return F.Njj(B.toggleSingle(U))}),l.k0s(),l.j41(2,"cue-typography",5),l.bIt("click",function(){const U=F.eBV(b).$implicit,B=l.XpG(2);return F.Njj(B.toggleSingle(U))}),l.EFF(3),l.k0s()()}if(2&D){const b=k.$implicit;l.R7$(),l.Y8G("checked",b.visible)("color",b.color),l.R7$(2),l.JRh(b.label)}}function g(D,k){if(1&D&&(l.nVh(0,p,2,1,"cue-typography",3),l.Z7z(1,a,4,3,"cue-flexcontainer",1,l.Vm6)),2&D){const b=k.$implicit;l.vxM(b.category?0:-1),l.R7$(),l.Dyx(b.items)}}let M=(()=>{class D{layers=(0,S.geq)([]);visibilityChange=(0,S.CGW)();layerChange=(0,S.CGW)();visibilityAll=(0,S.CGW)();showCheckAll=(0,m.EW)(()=>this.layers().length>1);allVisible=(0,m.EW)(()=>this.layers().every(b=>b.visible));groupedLayers=(0,m.EW)(()=>{const b=[];for(const A of this.layers()){const U=A.category,B=b.find(X=>X.category===U);B?B.items.push(A):b.push({category:U,items:[A]})}return b});toggleAll(){const b=this.allVisible(),A=this.layers().map(U=>(U.visible=!b,U));this.layers.update(()=>[...A]),this.visibilityAll.emit(b),this.emitChange()}toggleSingle(b){b.visible=!b.visible,this.layerChange.emit(b),this.layers.update(()=>[...this.layers()]),this.emitChange()}emitChange(){this.visibilityChange.emit(this.layers())}static \u0275fac=function(A){return new(A||D)};static \u0275cmp=l.VBU({type:D,selectors:[["cue-layer-legend"]],inputs:{layers:[1,"layers"]},outputs:{layers:"layersChange",visibilityChange:"visibilityChange",layerChange:"layerChange",visibilityAll:"visibilityAll"},decls:4,vars:1,consts:[["direction","column"],["align","center","justify","start",2,"width","100%"],["size","s",3,"checkedChange","checked"],["variant","label",2,"margin-top","4px","opacity","0.6"],["size","s",3,"checkedChange","checked","color"],[2,"cursor","pointer",3,"click"]],template:function(A,U){1&A&&(l.j41(0,"cue-flexcontainer",0),l.nVh(1,P,2,1,"cue-flexcontainer",1),l.Z7z(2,g,3,1,null,null,R),l.k0s()),2&A&&(l.R7$(),l.vxM(U.showCheckAll()?1:-1),l.R7$(),l.Dyx(U.groupedLayers()))},dependencies:[s.n,O.Typography,z.S],encapsulation:2,changeDetection:0})}return D})()},2843(se,Q,u){"use strict";u.d(Q,{M:()=>Wn});var S={};u.r(S),u.d(S,{LAT_MAX:()=>U,LAT_MIN:()=>b,LAT_RENDERED_MAX:()=>B,LAT_RENDERED_MIN:()=>A,LNG_MAX:()=>h,LNG_MIN:()=>X,activeStates:()=>D,classes:()=>s,cursors:()=>l,events:()=>a,geojsonTypes:()=>P,interactions:()=>k,meta:()=>M,modes:()=>p,sources:()=>F,types:()=>R,updateActions:()=>g});var m={};u.r(m),u.d(m,{isActiveFeature:()=>L,isBackspaceKey:()=>he,isDeleteKey:()=>me,isDigit1Key:()=>ne,isDigit2Key:()=>ze,isDigit3Key:()=>xe,isDigitKey:()=>ve,isEnterKey:()=>fe,isEscapeKey:()=>ye,isFeature:()=>Z,isInactiveFeature:()=>w,isOfMetaType:()=>C,isShiftDown:()=>oe,isShiftMousedown:()=>x,isTrue:()=>ct,isVertex:()=>J,noTarget:()=>W});var O={};u.r(O),u.d(O,{CommonSelectors:()=>m,ModeHandler:()=>nt,StringSet:()=>we,constrainFeatureMovement:()=>wt,createMidPoint:()=>nn,createSupplementaryPoints:()=>At,createVertex:()=>Ze,doubleClickZoom:()=>Ie,euclideanDistance:()=>qe,featuresAt:()=>ke,getFeatureAtAndSetCursors:()=>Xe,isClick:()=>et,isEventAtCoordinates:()=>mt,isTap:()=>tt,mapEventToBoundingBox:()=>He,moveFeatures:()=>Nt,sortFeatures:()=>dt,stringSetsAreEqual:()=>pn,theme:()=>Gt,toDenseArray:()=>pe});var z=u(5802);const s={CANVAS:"mapboxgl-canvas",CONTROL_BASE:"mapboxgl-ctrl",CONTROL_PREFIX:"mapboxgl-ctrl-",CONTROL_BUTTON:"mapbox-gl-draw_ctrl-draw-btn",CONTROL_BUTTON_LINE:"mapbox-gl-draw_line",CONTROL_BUTTON_POLYGON:"mapbox-gl-draw_polygon",CONTROL_BUTTON_POINT:"mapbox-gl-draw_point",CONTROL_BUTTON_TRASH:"mapbox-gl-draw_trash",CONTROL_BUTTON_COMBINE_FEATURES:"mapbox-gl-draw_combine",CONTROL_BUTTON_UNCOMBINE_FEATURES:"mapbox-gl-draw_uncombine",CONTROL_GROUP:"mapboxgl-ctrl-group",ATTRIBUTION:"mapboxgl-ctrl-attrib",ACTIVE_BUTTON:"active",BOX_SELECT:"mapbox-gl-draw_boxselect"},F={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},l={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},R={POLYGON:"polygon",LINE:"line_string",POINT:"point"},P={FEATURE:"Feature",POLYGON:"Polygon",LINE_STRING:"LineString",POINT:"Point",FEATURE_COLLECTION:"FeatureCollection",MULTI_PREFIX:"Multi",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon"},p={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select"},a={CREATE:"draw.create",DELETE:"draw.delete",UPDATE:"draw.update",SELECTION_CHANGE:"draw.selectionchange",MODE_CHANGE:"draw.modechange",ACTIONABLE:"draw.actionable",RENDER:"draw.render",COMBINE_FEATURES:"draw.combine",UNCOMBINE_FEATURES:"draw.uncombine"},g={MOVE:"move",CHANGE_PROPERTIES:"change_properties",CHANGE_COORDINATES:"change_coordinates"},M={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},D={ACTIVE:"true",INACTIVE:"false"},k=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],b=-90,A=-85,U=90,B=85,X=-270,h=270;function C(e){return function(t){const n=t.featureTarget;return!(!n||!n.properties)&&n.properties.meta===e}}function x(e){return!(!e.originalEvent||!e.originalEvent.shiftKey)&&0===e.originalEvent.button}function L(e){return!(!e.featureTarget||!e.featureTarget.properties)&&e.featureTarget.properties.active===D.ACTIVE&&e.featureTarget.properties.meta===M.FEATURE}function w(e){return!(!e.featureTarget||!e.featureTarget.properties)&&e.featureTarget.properties.active===D.INACTIVE&&e.featureTarget.properties.meta===M.FEATURE}function W(e){return void 0===e.featureTarget}function Z(e){return!(!e.featureTarget||!e.featureTarget.properties)&&e.featureTarget.properties.meta===M.FEATURE}function J(e){const t=e.featureTarget;return!(!t||!t.properties)&&t.properties.meta===M.VERTEX}function oe(e){return!!e.originalEvent&&!0===e.originalEvent.shiftKey}function ye(e){return"Escape"===e.key||27===e.keyCode}function fe(e){return"Enter"===e.key||13===e.keyCode}function he(e){return"Backspace"===e.key||8===e.keyCode}function me(e){return"Delete"===e.key||46===e.keyCode}function ne(e){return"1"===e.key||49===e.keyCode}function ze(e){return"2"===e.key||50===e.keyCode}function xe(e){return"3"===e.key||51===e.keyCode}function ve(e){const t=e.key||String.fromCharCode(e.keyCode);return t>="0"&&t<="9"}function ct(){return!0}var Ke=u(503);const Ae={Point:0,LineString:1,MultiLineString:1,Polygon:2};function ut(e,t){const n=Ae[e.geometry.type]-Ae[t.geometry.type];return 0===n&&e.geometry.type===P.POLYGON?e.area-t.area:n}const dt=function _t(e){return e.map(t=>(t.geometry.type===P.POLYGON&&(t.area=Ke.geometry({type:P.FEATURE,property:{},geometry:t.geometry})),t)).sort(ut).map(t=>(delete t.area,t))},He=function je(e,t=0){return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]};function Re(e){if(this._items={},this._nums={},this._length=e?e.length:0,e)for(let t=0,n=e.length;t<n;t++)this.add(e[t]),void 0!==e[t]&&("string"==typeof e[t]?this._items[e[t]]=t:this._nums[e[t]]=t)}Re.prototype.add=function(e){return this.has(e)||(this._length++,"string"==typeof e?this._items[e]=this._length:this._nums[e]=this._length),this},Re.prototype.delete=function(e){return!1===this.has(e)||(this._length--,delete this._items[e],delete this._nums[e]),this},Re.prototype.has=function(e){return!("string"!=typeof e&&"number"!=typeof e||void 0===this._items[e]&&void 0===this._nums[e])},Re.prototype.values=function(){const e=[];return Object.keys(this._items).forEach(t=>{e.push({k:t,v:this._items[t]})}),Object.keys(this._nums).forEach(t=>{e.push({k:JSON.parse(t),v:this._nums[t]})}),e.sort((t,n)=>t.v-n.v).map(t=>t.k)},Re.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const we=Re,Qe=[M.FEATURE,M.MIDPOINT,M.VERTEX],ke={click:function vt(e,t,n){return ft(e,t,n,n.options.clickBuffer)},touch:function bt(e,t,n){return ft(e,t,n,n.options.touchBuffer)}};function ft(e,t,n,o){if(null===n.map)return[];const r=e?He(e,o):t,i={};n.options.styles&&(i.layers=n.options.styles.map(N=>N.id).filter(N=>null!=n.map.getLayer(N)));const f=n.map.queryRenderedFeatures(r,i).filter(N=>-1!==Qe.indexOf(N.properties.meta)),E=new we,y=[];return f.forEach(N=>{const K=N.properties.id;E.has(K)||(E.add(K),y.push(N))}),dt(y)}function Xe(e,t){const n=ke.click(e,null,t),o={mouse:l.NONE};return n[0]&&(o.mouse=n[0].properties.active===D.ACTIVE?l.MOVE:l.POINTER,o.feature=n[0].properties.meta),-1!==t.events.currentModeName().indexOf("draw")&&(o.mouse=l.ADD),t.ui.queueMapClasses(o),t.ui.updateMapClasses(),n[0]}function qe(e,t){const n=e.x-t.x,o=e.y-t.y;return Math.sqrt(n*n+o*o)}function et(e,t,n={}){const o=null!=n.fineTolerance?n.fineTolerance:4,r=null!=n.grossTolerance?n.grossTolerance:12,i=null!=n.interval?n.interval:500;e.point=e.point||t.point,e.time=e.time||t.time;const f=qe(e.point,t.point);return f<o||f<r&&t.time-e.time<i}function tt(e,t,n={}){const o=null!=n.tolerance?n.tolerance:25,r=null!=n.interval?n.interval:250;return e.point=e.point||t.point,e.time=e.time||t.time,qe(e.point,t.point)<o&&t.time-e.time<r}const nt=function(e,t){const n={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},o={on(i,f,E){if(void 0===n[i])throw new Error(`Invalid event type: ${i}`);n[i].push({selector:f,fn:E})},render(i){t.store.featureChanged(i)}},r=function(i,f){const E=n[i];let y=E.length;for(;y--;){const N=E[y];if(N.selector(f)){N.fn.call(o,f)||t.store.render(),t.ui.updateMapClasses();break}}};return e.start.call(o),{render:e.render,stop(){e.stop&&e.stop()},trash(){e.trash&&(e.trash(),t.store.render())},combineFeatures(){e.combineFeatures&&e.combineFeatures()},uncombineFeatures(){e.uncombineFeatures&&e.uncombineFeatures()},drag(i){r("drag",i)},click(i){r("click",i)},mousemove(i){r("mousemove",i)},mousedown(i){r("mousedown",i)},mouseup(i){r("mouseup",i)},mouseout(i){r("mouseout",i)},keydown(i){r("keydown",i)},keyup(i){r("keyup",i)},touchstart(i){r("touchstart",i)},touchmove(i){r("touchmove",i)},touchend(i){r("touchend",i)},tap(i){r("tap",i)}}},I=((e,t=21)=>(n=t)=>{let o="",r=0|n;for(;r--;)o+=e[Math.random()*e.length|0];return o})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",32);function c(){return I()}const d=function(e,t){this.ctx=e,this.properties=t.properties||{},this.coordinates=t.geometry.coordinates,this.id=t.id||c(),this.type=t.geometry.type};d.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},d.prototype.incomingCoords=function(e){this.setCoordinates(e)},d.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},d.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},d.prototype.setProperty=function(e,t){this.properties[e]=t},d.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:P.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},d.prototype.internal=function(e){const t={id:this.id,meta:M.FEATURE,"meta:type":this.type,active:D.INACTIVE,mode:e};if(this.ctx.options.userProperties)for(const n in this.properties)t[`user_${n}`]=this.properties[n];return{type:P.FEATURE,properties:t,geometry:{coordinates:this.getCoordinates(),type:this.type}}};const v=d,V=function(e,t){v.call(this,e,t)};(V.prototype=Object.create(v.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},V.prototype.updateCoordinate=function(e,t,n){this.coordinates=3===arguments.length?[t,n]:[e,t],this.changed()},V.prototype.getCoordinate=function(){return this.getCoordinates()};const Y=V,q=function(e,t){v.call(this,e,t)};(q.prototype=Object.create(v.prototype)).isValid=function(){return this.coordinates.length>1},q.prototype.addCoordinate=function(e,t,n){this.changed();const o=parseInt(e,10);this.coordinates.splice(o,0,[t,n])},q.prototype.getCoordinate=function(e){const t=parseInt(e,10);return JSON.parse(JSON.stringify(this.coordinates[t]))},q.prototype.removeCoordinate=function(e){this.changed(),this.coordinates.splice(parseInt(e,10),1)},q.prototype.updateCoordinate=function(e,t,n){const o=parseInt(e,10);this.coordinates[o]=[t,n],this.changed()};const le=q,ge=function(e,t){v.call(this,e,t),this.coordinates=this.coordinates.map(n=>n.slice(0,-1))};(ge.prototype=Object.create(v.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every(e=>e.length>2)},ge.prototype.incomingCoords=function(e){this.coordinates=e.map(t=>t.slice(0,-1)),this.changed()},ge.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},ge.prototype.addCoordinate=function(e,t,n){this.changed();const o=e.split(".").map(i=>parseInt(i,10));this.coordinates[o[0]].splice(o[1],0,[t,n])},ge.prototype.removeCoordinate=function(e){this.changed();const t=e.split(".").map(o=>parseInt(o,10)),n=this.coordinates[t[0]];n&&(n.splice(t[1],1),n.length<3&&this.coordinates.splice(t[0],1))},ge.prototype.getCoordinate=function(e){const t=e.split(".").map(o=>parseInt(o,10));return JSON.parse(JSON.stringify(this.coordinates[t[0]][t[1]]))},ge.prototype.getCoordinates=function(){return this.coordinates.map(e=>e.concat([e[0]]))},ge.prototype.updateCoordinate=function(e,t,n){this.changed();const o=e.split("."),r=parseInt(o[0],10),i=parseInt(o[1],10);void 0===this.coordinates[r]&&(this.coordinates[r]=[]),this.coordinates[r][i]=[t,n]};const ae=ge,de={MultiPoint:Y,MultiLineString:le,MultiPolygon:ae},_e=(e,t,n,o,r)=>{const i=n.split("."),f=parseInt(i[0],10),E=i[1]?i.slice(1).join("."):null;return e[f][t](E,o,r)},Ee=function(e,t){if(v.call(this,e,t),delete this.coordinates,this.model=de[t.geometry.type],void 0===this.model)throw new TypeError(`${t.geometry.type} is not a valid type`);this.features=this._coordinatesToFeatures(t.geometry.coordinates)};(Ee.prototype=Object.create(v.prototype))._coordinatesToFeatures=function(e){const t=this.model.bind(this);return e.map(n=>new t(this.ctx,{id:c(),type:P.FEATURE,properties:{},geometry:{coordinates:n,type:this.type.replace("Multi","")}}))},Ee.prototype.isValid=function(){return this.features.every(e=>e.isValid())},Ee.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()},Ee.prototype.getCoordinate=function(e){return _e(this.features,"getCoordinate",e)},Ee.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(e=>e.type===P.POLYGON?e.getCoordinates():e.coordinates)))},Ee.prototype.updateCoordinate=function(e,t,n){_e(this.features,"updateCoordinate",e,t,n),this.changed()},Ee.prototype.addCoordinate=function(e,t,n){_e(this.features,"addCoordinate",e,t,n),this.changed()},Ee.prototype.removeCoordinate=function(e){_e(this.features,"removeCoordinate",e),this.changed()},Ee.prototype.getFeatures=function(){return this.features};const Ne=Ee;function H(e){this.map=e.map,this.drawConfig=JSON.parse(JSON.stringify(e.options||{})),this._ctx=e}H.prototype.setSelected=function(e){return this._ctx.store.setSelected(e)},H.prototype.setSelectedCoordinates=function(e){this._ctx.store.setSelectedCoordinates(e),e.reduce((t,n)=>(void 0===t[n.feature_id]&&(t[n.feature_id]=!0,this._ctx.store.get(n.feature_id).changed()),t),{})},H.prototype.getSelected=function(){return this._ctx.store.getSelected()},H.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},H.prototype.isSelected=function(e){return this._ctx.store.isSelected(e)},H.prototype.getFeature=function(e){return this._ctx.store.get(e)},H.prototype.select=function(e){return this._ctx.store.select(e)},H.prototype.deselect=function(e){return this._ctx.store.deselect(e)},H.prototype.deleteFeature=function(e,t={}){return this._ctx.store.delete(e,t)},H.prototype.addFeature=function(e,t={}){return this._ctx.store.add(e,t)},H.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},H.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},H.prototype.setActionableState=function(e={}){return this._ctx.events.actionable({trash:e.trash||!1,combineFeatures:e.combineFeatures||!1,uncombineFeatures:e.uncombineFeatures||!1})},H.prototype.changeMode=function(e,t={},n={}){return this._ctx.events.changeMode(e,t,n)},H.prototype.fire=function(e,t){return this._ctx.events.fire(e,t)},H.prototype.updateUIClasses=function(e){return this._ctx.ui.queueMapClasses(e)},H.prototype.activateUIButton=function(e){return this._ctx.ui.setActiveButton(e)},H.prototype.featuresAt=function(e,t,n="click"){if("click"!==n&&"touch"!==n)throw new Error("invalid buffer type");return ke[n](e,t,this._ctx)},H.prototype.newFeature=function(e){const t=e.geometry.type;return t===P.POINT?new Y(this._ctx,e):t===P.LINE_STRING?new le(this._ctx,e):t===P.POLYGON?new ae(this._ctx,e):new Ne(this._ctx,e)},H.prototype.isInstanceOf=function(e,t){if(e===P.POINT)return t instanceof Y;if(e===P.LINE_STRING)return t instanceof le;if(e===P.POLYGON)return t instanceof ae;if("MultiFeature"===e)return t instanceof Ne;throw new Error(`Unknown feature class: ${e}`)},H.prototype.doRender=function(e){return this._ctx.store.featureChanged(e)};const ee=H;H.prototype.onSetup=function(){},H.prototype.onDrag=function(){},H.prototype.onClick=function(){},H.prototype.onMouseMove=function(){},H.prototype.onMouseDown=function(){},H.prototype.onMouseUp=function(){},H.prototype.onMouseOut=function(){},H.prototype.onKeyUp=function(){},H.prototype.onKeyDown=function(){},H.prototype.onTouchStart=function(){},H.prototype.onTouchMove=function(){},H.prototype.onTouchEnd=function(){},H.prototype.onTap=function(){},H.prototype.onStop=function(){},H.prototype.onTrash=function(){},H.prototype.onCombineFeature=function(){},H.prototype.onUncombineFeature=function(){},H.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};const re={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},be=Object.keys(re);const pe=function Me(e){return[].concat(e).filter(t=>void 0!==t)};function ot(){const e=this;if(!e.ctx.map||void 0===e.ctx.map.getSource(F.HOT))return y();const n=e.ctx.events.currentModeName();e.ctx.ui.queueMapClasses({mode:n});let o=[],r=[];e.isDirty?r=e.getAllIds():(o=e.getChangedIds().filter(N=>void 0!==e.get(N)),r=e.sources.hot.filter(N=>N.properties.id&&-1===o.indexOf(N.properties.id)&&void 0!==e.get(N.properties.id)).map(N=>N.properties.id)),e.sources.hot=[];const i=e.sources.cold.length;e.sources.cold=e.isDirty?[]:e.sources.cold.filter(N=>-1===o.indexOf(N.properties.id||N.properties.parent));const f=i!==e.sources.cold.length||r.length>0;function E(N,K){const T=e.get(N).internal(n);e.ctx.events.currentModeRender(T,G=>{G.properties.mode=n,e.sources[K].push(G)})}function y(){e.isDirty=!1,e.clearChangedIds()}o.forEach(N=>E(N,"hot")),r.forEach(N=>E(N,"cold")),f&&e.ctx.map.getSource(F.COLD).setData({type:P.FEATURE_COLLECTION,features:e.sources.cold}),e.ctx.map.getSource(F.HOT).setData({type:P.FEATURE_COLLECTION,features:e.sources.hot}),y()}function ie(e){let t;this._features={},this._featureIds=new we,this._selectedFeatureIds=new we,this._selectedCoordinates=[],this._changedFeatureIds=new we,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]},this.render=()=>{t||(t=requestAnimationFrame(()=>{t=null,ot.call(this),this._emitSelectionChange&&(this.ctx.events.fire(a.SELECTION_CHANGE,{features:this.getSelected().map(n=>n.toGeoJSON()),points:this.getSelectedCoordinates().map(n=>({type:P.FEATURE,properties:{},geometry:{type:P.POINT,coordinates:n.coordinates}}))}),this._emitSelectionChange=!1),this.ctx.events.fire(a.RENDER,{})}))},this.isDirty=!1}function rt(e,t={}){const n=e._selectedCoordinates.filter(o=>e._selectedFeatureIds.has(o.feature_id));e._selectedCoordinates.length!==n.length&&!t.silent&&(e._emitSelectionChange=!0),e._selectedCoordinates=n}ie.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}},ie.prototype.setDirty=function(){return this.isDirty=!0,this},ie.prototype.featureCreated=function(e,t={}){if(this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)){const o=this.get(e);this.ctx.events.fire(a.CREATE,{features:[o.toGeoJSON()]})}return this},ie.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)&&this.ctx.events.fire(a.UPDATE,{action:t.action?t.action:g.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this},ie.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},ie.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},ie.prototype.getAllIds=function(){return this._featureIds.values()},ie.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this},ie.prototype.delete=function(e,t={}){const n=[];return pe(e).forEach(o=>{this._featureIds.has(o)&&(this._featureIds.delete(o),this._selectedFeatureIds.delete(o),t.silent||-1===n.indexOf(this._features[o])&&n.push(this._features[o].toGeoJSON()),delete this._features[o],this.isDirty=!0)}),n.length&&this.ctx.events.fire(a.DELETE,{features:n}),rt(this,t),this},ie.prototype.get=function(e){return this._features[e]},ie.prototype.getAll=function(){return Object.keys(this._features).map(e=>this._features[e])},ie.prototype.select=function(e,t={}){return pe(e).forEach(n=>{this._selectedFeatureIds.has(n)||(this._selectedFeatureIds.add(n),this._changedFeatureIds.add(n),t.silent||(this._emitSelectionChange=!0))}),this},ie.prototype.deselect=function(e,t={}){return pe(e).forEach(n=>{this._selectedFeatureIds.has(n)&&(this._selectedFeatureIds.delete(n),this._changedFeatureIds.add(n),t.silent||(this._emitSelectionChange=!0))}),rt(this,t),this},ie.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this},ie.prototype.setSelected=function(e,t={}){return e=pe(e),this.deselect(this._selectedFeatureIds.values().filter(n=>-1===e.indexOf(n)),{silent:t.silent}),this.select(e.filter(n=>!this._selectedFeatureIds.has(n)),{silent:t.silent}),this},ie.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this},ie.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},ie.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},ie.prototype.getSelected=function(){return this.getSelectedIds().map(e=>this.get(e))},ie.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map(t=>({coordinates:this.get(t.feature_id).getCoordinate(t.coord_path)}))},ie.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)},ie.prototype.setFeatureProperty=function(e,t,n,o={}){this.get(e).setProperty(t,n),this.featureChanged(e,{silent:o.silent,action:g.CHANGE_PROPERTIES})},ie.prototype.storeMapConfig=function(){k.forEach(e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())})},ie.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach(e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()})},ie.prototype.getInitialConfigValue=function(e){return void 0===this._mapInitialConfig[e]||this._mapInitialConfig[e]};const it=["mode","feature","mouse"];function kt(e){let t=null,n=null;const o={onRemove(){return e.map.off("load",o.connect),clearInterval(n),o.removeLayers(),e.store.restoreMapConfig(),e.ui.removeButtons(),e.events.removeEventListeners(),e.ui.clearMapClasses(),e.boxZoomInitial&&e.map.boxZoom.enable(),e.map=null,e.container=null,e.store=null,t&&t.parentNode&&t.parentNode.removeChild(t),t=null,this},connect(){e.map.off("load",o.connect),clearInterval(n),o.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners()},onAdd(r){if(e.map=r,e.events=function Be(e){const t=Object.keys(e.options.modes).reduce((T,G)=>(T[G]=function Se(e){const t=Object.keys(e);return function(n,o={}){let r={};const i=t.reduce((E,y)=>(E[y]=e[y],E),new ee(n));return{start(){r=i.onSetup(o),be.forEach(E=>{const y=re[E];let N=()=>!1;e[y]&&(N=()=>!0),this.on(E,N,function f(E){return y=>i[E](r,y)}(y))})},stop(){i.onStop(r)},trash(){i.onTrash(r)},combineFeatures(){i.onCombineFeatures(r)},uncombineFeatures(){i.onUncombineFeatures(r)},render(E,y){i.toDisplayFeatures(r,E,y)}}}}(e.options.modes[G]),T),{});let n={},o={};const r={};let i=null,f=null;r.drag=function(T,G){G({point:T.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:l.DRAG}),f.drag(T)):T.originalEvent.stopPropagation()},r.mousedrag=function(T){r.drag(T,G=>!et(n,G))},r.touchdrag=function(T){r.drag(T,G=>!tt(o,G))},r.mousemove=function(T){if(1===(void 0!==T.originalEvent.buttons?T.originalEvent.buttons:T.originalEvent.which))return r.mousedrag(T);const $=Xe(T,e);T.featureTarget=$,f.mousemove(T)},r.mousedown=function(T){n={time:(new Date).getTime(),point:T.point};const G=Xe(T,e);T.featureTarget=G,f.mousedown(T)},r.mouseup=function(T){const G=Xe(T,e);T.featureTarget=G,et(n,{point:T.point,time:(new Date).getTime()})?f.click(T):f.mouseup(T)},r.mouseout=function(T){f.mouseout(T)},r.touchstart=function(T){if(!e.options.touchEnabled)return;o={time:(new Date).getTime(),point:T.point};const G=ke.touch(T,null,e)[0];T.featureTarget=G,f.touchstart(T)},r.touchmove=function(T){if(e.options.touchEnabled)return f.touchmove(T),r.touchdrag(T)},r.touchend=function(T){if(T.originalEvent.preventDefault(),!e.options.touchEnabled)return;const G=ke.touch(T,null,e)[0];T.featureTarget=G,tt(o,{time:(new Date).getTime(),point:T.point})?f.tap(T):f.touchend(T)};const E=T=>{const G=he(T),$=me(T),te=ve(T);return!(G||$||te)};function y(T,G,$={}){f.stop();const te=t[T];if(void 0===te)throw new Error(`${T} is not valid`);i=T;const Ce=te(e,G);f=nt(Ce,e),$.silent||e.map.fire(a.MODE_CHANGE,{mode:T}),e.store.setDirty(),e.store.render()}r.keydown=function(T){(T.srcElement||T.target).classList.contains(s.CANVAS)&&((he(T)||me(T))&&e.options.controls.trash?(T.preventDefault(),f.trash()):E(T)?f.keydown(T):ne(T)&&e.options.controls.point?y(p.DRAW_POINT):ze(T)&&e.options.controls.line_string?y(p.DRAW_LINE_STRING):xe(T)&&e.options.controls.polygon&&y(p.DRAW_POLYGON))},r.keyup=function(T){E(T)&&f.keyup(T)},r.zoomend=function(){e.store.changeZoom()},r.data=function(T){if("style"===T.dataType){const{setup:G,map:$,options:te,store:Ce}=e;te.styles.some(Ve=>$.getLayer(Ve.id))||(G.addLayers(),Ce.setDirty(),Ce.render())}};const N={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start(){i=e.options.defaultMode,f=nt(t[i](e),e)},changeMode:y,actionable:function K(T){let G=!1;Object.keys(T).forEach($=>{if(void 0===N[$])throw new Error("Invalid action type");N[$]!==T[$]&&(G=!0),N[$]=T[$]}),G&&e.map.fire(a.ACTIONABLE,{actions:N})},currentModeName:()=>i,currentModeRender:(T,G)=>f.render(T,G),fire(T,G){e.map&&e.map.fire(T,G)},addEventListeners(){e.map.on("mousemove",r.mousemove),e.map.on("mousedown",r.mousedown),e.map.on("mouseup",r.mouseup),e.map.on("data",r.data),e.map.on("touchmove",r.touchmove),e.map.on("touchstart",r.touchstart),e.map.on("touchend",r.touchend),e.container.addEventListener("mouseout",r.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",r.keydown),e.container.addEventListener("keyup",r.keyup))},removeEventListeners(){e.map.off("mousemove",r.mousemove),e.map.off("mousedown",r.mousedown),e.map.off("mouseup",r.mouseup),e.map.off("data",r.data),e.map.off("touchmove",r.touchmove),e.map.off("touchstart",r.touchstart),e.map.off("touchend",r.touchend),e.container.removeEventListener("mouseout",r.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",r.keydown),e.container.removeEventListener("keyup",r.keyup))},trash(T){f.trash(T)},combineFeatures(){f.combineFeatures()},uncombineFeatures(){f.uncombineFeatures()},getMode:()=>i}}(e),e.ui=function It(e){const t={};let n=null,o={mode:null,feature:null,mouse:null},r={mode:null,feature:null,mouse:null};function f(G){r=Object.assign(r,G)}function E(){if(!e.container)return;const G=[],$=[];it.forEach(te=>{r[te]!==o[te]&&(G.push(`${te}-${o[te]}`),null!==r[te]&&$.push(`${te}-${r[te]}`))}),G.length>0&&e.container.classList.remove(...G),$.length>0&&e.container.classList.add(...$),o=Object.assign(o,r)}function y(G,$={}){const te=document.createElement("button");return te.className=`${s.CONTROL_BUTTON} ${$.className}`,te.setAttribute("title",$.title),$.container.appendChild(te),te.addEventListener("click",Ce=>{if(Ce.preventDefault(),Ce.stopPropagation(),Ce.target===n)return N(),void $.onDeactivate();K(G),$.onActivate()},!0),te}function N(){n&&(n.classList.remove(s.ACTIVE_BUTTON),n=null)}function K(G){N();const $=t[G];$&&$&&"trash"!==G&&($.classList.add(s.ACTIVE_BUTTON),n=$)}return{setActiveButton:K,queueMapClasses:f,updateMapClasses:E,clearMapClasses:function i(){f({mode:null,feature:null,mouse:null}),E()},addButtons:function j(){const G=e.options.controls,$=document.createElement("div");return $.className=`${s.CONTROL_GROUP} ${s.CONTROL_BASE}`,G&&(G[R.POINT]&&(t[R.POINT]=y(R.POINT,{container:$,className:s.CONTROL_BUTTON_POINT,title:"Marker tool "+(e.options.keybindings?"(1)":""),onActivate:()=>e.events.changeMode(p.DRAW_POINT),onDeactivate:()=>e.events.trash()})),G[R.LINE]&&(t[R.LINE]=y(R.LINE,{container:$,className:s.CONTROL_BUTTON_LINE,title:"LineString tool "+(e.options.keybindings?"(2)":""),onActivate:()=>e.events.changeMode(p.DRAW_LINE_STRING),onDeactivate:()=>e.events.trash()})),G[R.POLYGON]&&(t[R.POLYGON]=y(R.POLYGON,{container:$,className:s.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(e.options.keybindings?"(3)":""),onActivate:()=>e.events.changeMode(p.DRAW_POLYGON),onDeactivate:()=>e.events.trash()})),G.trash&&(t.trash=y("trash",{container:$,className:s.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:()=>{e.events.trash()}})),G.combine_features&&(t.combine_features=y("combineFeatures",{container:$,className:s.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:()=>{e.events.combineFeatures()}})),G.uncombine_features&&(t.uncombine_features=y("uncombineFeatures",{container:$,className:s.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:()=>{e.events.uncombineFeatures()}}))),$},removeButtons:function T(){Object.keys(t).forEach(G=>{const $=t[G];$.parentNode&&$.parentNode.removeChild($),delete t[G]})}}}(e),e.container=r.getContainer(),e.store=new ie(e),t=e.ui.addButtons(),e.options.boxSelect){e.boxZoomInitial=r.boxZoom.isEnabled(),r.boxZoom.disable();const i=r.dragPan.isEnabled();r.dragPan.disable(),r.dragPan.enable(),i||r.dragPan.disable()}return r.loaded()?o.connect():(r.on("load",o.connect),n=setInterval(()=>{r.loaded()&&o.connect()},16)),e.events.start(),t},addLayers(){e.map.addSource(F.COLD,{data:{type:P.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(F.HOT,{data:{type:P.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.options.styles.forEach(r=>{e.map.addLayer(r)}),e.store.setDirty(!0),e.store.render()},removeLayers(){e.options.styles.forEach(r=>{e.map.getLayer(r.id)&&e.map.removeLayer(r.id)}),e.map.getSource(F.COLD)&&e.map.removeSource(F.COLD),e.map.getSource(F.HOT)&&e.map.removeSource(F.HOT)}};return e.setup=o,o}const st="#3bb2d0",at="#fbb03b",Gt=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],at,st],"fill-opacity":.1}},{id:"gl-draw-lines",type:"line",filter:["any",["==","$type","LineString"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["==",["get","active"],"true"],at,st],"line-dasharray":["case",["==",["get","active"],"true"],[.2,2],[2,0]],"line-width":2}},{id:"gl-draw-point-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":"#fff"}},{id:"gl-draw-point-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":["case",["==",["get","active"],"true"],at,st]}},{id:"gl-draw-vertex-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":"#fff"}},{id:"gl-draw-vertex-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":at}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":at}}];function Ge(e,t){this.x=e,this.y=t}Ge.prototype={clone(){return new Ge(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const n=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=n,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),n=Math.sin(e),r=n*this.x+t*this.y;return this.x=t*this.x-n*this.y,this.y=r,this},_rotateAround(e,t){const n=Math.cos(e),o=Math.sin(e),i=t.y+o*(this.x-t.x)+n*(this.y-t.y);return this.x=t.x+n*(this.x-t.x)-o*(this.y-t.y),this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Ge},Ge.convert=function(e){if(e instanceof Ge)return e;if(Array.isArray(e))return new Ge(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new Ge(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};const Ot=function mn(e,t){const n=t.getBoundingClientRect();return new Ge(e.clientX-n.left-(t.clientLeft||0),e.clientY-n.top-(t.clientTop||0))};function Ze(e,t,n,o){return{type:P.FEATURE,properties:{meta:M.VERTEX,parent:e,coord_path:n,active:o?D.ACTIVE:D.INACTIVE},geometry:{type:P.POINT,coordinates:t}}}function lt(e,t,n){if(null!==e)for(var o,r,i,f,E,y,N,T,K=0,j=0,G=e.type,$="FeatureCollection"===G,te="Feature"===G,Ce=$?e.features.length:1,Te=0;Te<Ce;Te++){E=(T=!!(N=$?e.features[Te].geometry:te?e.geometry:e)&&"GeometryCollection"===N.type)?N.geometries.length:1;for(var Ve=0;Ve<E;Ve++){var Pe=0,We=0;if(null!==(f=T?N.geometries[Ve]:N)){y=f.coordinates;var Ue=f.type;switch(K=!n||"Polygon"!==Ue&&"MultiPolygon"!==Ue?0:1,Ue){case null:break;case"Point":if(!1===t(y,j,Te,Pe,We))return!1;j++,Pe++;break;case"LineString":case"MultiPoint":for(o=0;o<y.length;o++){if(!1===t(y[o],j,Te,Pe,We))return!1;j++,"MultiPoint"===Ue&&Pe++}"LineString"===Ue&&Pe++;break;case"Polygon":case"MultiLineString":for(o=0;o<y.length;o++){for(r=0;r<y[o].length-K;r++){if(!1===t(y[o][r],j,Te,Pe,We))return!1;j++}"MultiLineString"===Ue&&Pe++,"Polygon"===Ue&&We++}"Polygon"===Ue&&Pe++;break;case"MultiPolygon":for(o=0;o<y.length;o++){for(We=0,r=0;r<y[o].length;r++){for(i=0;i<y[o][r].length-K;i++){if(!1===t(y[o][r][i],j,Te,Pe,We))return!1;j++}We++}Pe++}break;case"GeometryCollection":for(o=0;o<f.geometries.length;o++)if(!1===lt(f.geometries[o],t,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Jt(e){const t={type:"Feature"};return Object.keys(e).forEach(n=>{switch(n){case"type":case"properties":case"geometry":return;default:t[n]=e[n]}}),t.properties=Yt(e.properties),t.geometry=null==e.geometry?null:xt(e.geometry),t}function Yt(e){const t={};return e&&Object.keys(e).forEach(n=>{const o=e[n];t[n]="object"==typeof o?null===o?null:Array.isArray(o)?o.map(r=>r):Yt(o):o}),t}function xt(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(n=>xt(n)),t):(t.coordinates=jt(e.coordinates),t)}function jt(e){const t=e;return"object"!=typeof t[0]?t.slice():t.map(n=>jt(n))}function Qt(e,t={}){return qt(e,"mercator",t)}function qt(e,t,n={}){var o=(n=n||{}).mutate;if(!e)throw new Error("geojson is required");return Array.isArray(e)&&function ht(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}(e[0])?e="mercator"===t?en(e):tn(e):(!0!==o&&(e=function Pn(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return Jt(e);case"FeatureCollection":return function Sn(e){const t={type:"FeatureCollection"};return Object.keys(e).forEach(n=>{switch(n){case"type":case"features":return;default:t[n]=e[n]}}),t.features=e.features.map(n=>Jt(n)),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return xt(e);default:throw new Error("unknown GeoJSON type")}}(e)),lt(e,function(r){var i="mercator"===t?en(r):tn(r);r[0]=i[0],r[1]=i[1]})),e}function en(e){var t=Math.PI/180,n=6378137,o=20037508.342789244,r=Math.abs(e[0])<=180?e[0]:e[0]-360*function On(e){return e<0?-1:e>0?1:0}(e[0]),i=[n*r*t,n*Math.log(Math.tan(.25*Math.PI+.5*e[1]*t))];return i[0]>o&&(i[0]=o),i[0]<-o&&(i[0]=-o),i[1]>o&&(i[1]=o),i[1]<-o&&(i[1]=-o),i}function tn(e){var t=180/Math.PI,n=6378137;return[e[0]*t/n,(.5*Math.PI-2*Math.atan(Math.exp(-e[1]/n)))*t]}function nn(e,t,n){const o=t.geometry.coordinates,r=n.geometry.coordinates;if(o[1]>B||o[1]<A||r[1]>B||r[1]<A)return null;const i=Qt(o),f=Qt(r),E=j=>Number(j.toFixed(8)),y=(j,T)=>(j+T)/2,N=function In(e,t={}){return qt(e,"wgs84",t)}([y(i[0],f[0]),y(i[1],f[1])]),K=[E(N[0]),E(N[1])];return{type:P.FEATURE,properties:{meta:M.MIDPOINT,parent:e,lng:K[0],lat:K[1],coord_path:n.properties.coord_path},geometry:{type:P.POINT,coordinates:K}}}Math;const At=function on(e,t={},n=null){const{type:o,coordinates:r}=e.geometry,i=e.properties&&e.properties.id;let f=[];function E(K,j){let T="",G=null;K.forEach(($,te)=>{const Ce=null!=j?`${j}.${te}`:String(te),Te=Ze(i,$,Ce,y(Ce));if(t.midpoints&&G){const Pe=nn(i,G,Te);Pe&&f.push(Pe)}G=Te;const Ve=JSON.stringify($);T!==Ve&&f.push(Te),0===te&&(T=Ve)})}function y(K){return!!t.selectedPaths&&-1!==t.selectedPaths.indexOf(K)}return o===P.POINT?f.push(Ze(i,r,n,y(n))):o===P.POLYGON?r.forEach((K,j)=>{E(K,null!==n?`${n}.${j}`:String(j))}):o===P.LINE_STRING?E(r,n):0===o.indexOf(P.MULTI_PREFIX)&&function N(){const K=o.replace(P.MULTI_PREFIX,"");r.forEach((j,T)=>{f=f.concat(on({type:P.FEATURE,properties:e.properties,geometry:{type:K,coordinates:j}},t,T))})}(),f},Ie={enable(e){setTimeout(()=>{!e.map||!e.map.doubleClickZoom||!e._ctx||!e._ctx.store||!e._ctx.store.getInitialConfigValue||e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable()},0)},disable(e){setTimeout(()=>{!e.map||!e.map.doubleClickZoom||e.map.doubleClickZoom.disable()},0)}},{LAT_MIN:pt,LAT_MAX:gt,LAT_RENDERED_MIN:rn,LAT_RENDERED_MAX:sn,LNG_MIN:an,LNG_MAX:ln}=S;function wt(e,t){let n=pt,o=gt,r=pt,i=gt,f=ln,E=an;e.forEach(N=>{const K=function Dn(e){const n=[e.geometry.coordinates].flat({Point:0,LineString:1,Polygon:2,MultiPoint:1,MultiLineString:2,MultiPolygon:3}[e.geometry.type]),o=n.map(E=>E[0]),r=n.map(E=>E[1]),i=E=>Math.min.apply(null,E),f=E=>Math.max.apply(null,E);return[i(o),i(r),f(o),f(r)]}(N),j=K[1],T=K[3],G=K[0],$=K[2];j>n&&(n=j),T<o&&(o=T),T>r&&(r=T),j<i&&(i=j),G<f&&(f=G),$>E&&(E=$)});const y=t;return n+y.lat>sn&&(y.lat=sn-n),r+y.lat>gt&&(y.lat=gt-r),o+y.lat<rn&&(y.lat=rn-o),i+y.lat<pt&&(y.lat=pt-i),f+y.lng<=an&&(y.lng+=360*Math.ceil(Math.abs(y.lng)/360)),E+y.lng>=ln&&(y.lng-=360*Math.ceil(Math.abs(y.lng)/360)),y}function Nt(e,t){const n=wt(e.map(o=>o.toGeoJSON()),t);e.forEach(o=>{const r=o.getCoordinates(),i=N=>{const K={lng:N[0]+n.lng,lat:N[1]+n.lat};return[K.lng,K.lat]},f=N=>N.map(K=>i(K));let y;o.type===P.POINT?y=i(r):o.type===P.LINE_STRING||o.type===P.MULTI_POINT?y=r.map(i):o.type===P.POLYGON||o.type===P.MULTI_LINE_STRING?y=r.map(f):o.type===P.MULTI_POLYGON&&(y=r.map(N=>N.map(K=>f(K)))),o.incomingCoords(y)})}const ce={onSetup:function(e){const t={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initialDragPanState:this.map.dragPan.isEnabled(),initiallySelectedFeatureIds:e.featureIds||[]};return this.setSelected(t.initiallySelectedFeatureIds.filter(n=>void 0!==this.getFeature(n))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),t},fireUpdate:function(){this.fire(a.UPDATE,{action:g.MOVE,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(){const e=this.getSelected(),t=e.filter(i=>this.isInstanceOf("MultiFeature",i));let n=!1;if(e.length>1){n=!0;const i=e[0].type.replace("Multi","");e.forEach(f=>{f.type.replace("Multi","")!==i&&(n=!1)})}this.setActionableState({combineFeatures:n,uncombineFeatures:t.length>0,trash:e.length>0})},getUniqueIds:function(e){return e.length?e.map(n=>n.properties.id).filter(n=>void 0!==n).reduce((n,o)=>(n.add(o),n),new we).values():[]},stopExtendedInteractions:function(e){e.boxSelectElement&&(e.boxSelectElement.parentNode&&e.boxSelectElement.parentNode.removeChild(e.boxSelectElement),e.boxSelectElement=null),(e.canDragMove||e.canBoxSelect)&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.boxSelecting=!1,e.canBoxSelect=!1,e.dragMoving=!1,e.canDragMove=!1},onStop:function(){Ie.enable(this)},onMouseMove:function(e,t){return Z(t)&&e.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(e),!0},onMouseOut:function(e){return!e.dragMoving||this.fireUpdate()}};ce.onTap=ce.onClick=function(e,t){return W(t)?this.clickAnywhere(e,t):C(M.VERTEX)(t)?this.clickOnVertex(e,t):Z(t)?this.clickOnFeature(e,t):void 0},ce.clickAnywhere=function(e){const t=this.getSelectedIds();t.length&&(this.clearSelectedFeatures(),t.forEach(n=>this.doRender(n))),Ie.enable(this),this.stopExtendedInteractions(e)},ce.clickOnVertex=function(e,t){this.changeMode(p.DIRECT_SELECT,{featureId:t.featureTarget.properties.parent,coordPath:t.featureTarget.properties.coord_path,startPos:t.lngLat}),this.updateUIClasses({mouse:l.MOVE})},ce.startOnActiveFeature=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),this.doRender(t.featureTarget.properties.id),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},ce.clickOnFeature=function(e,t){Ie.disable(this),this.stopExtendedInteractions(e);const n=oe(t),o=this.getSelectedIds(),r=t.featureTarget.properties.id,i=this.isSelected(r);if(!n&&i&&this.getFeature(r).type!==P.POINT)return this.changeMode(p.DIRECT_SELECT,{featureId:r});i&&n?(this.deselect(r),this.updateUIClasses({mouse:l.POINTER}),1===o.length&&Ie.enable(this)):!i&&n?(this.select(r),this.updateUIClasses({mouse:l.MOVE})):!i&&!n&&(o.forEach(f=>this.doRender(f)),this.setSelected(r),this.updateUIClasses({mouse:l.MOVE})),this.doRender(r)},ce.onMouseDown=function(e,t){return e.initialDragPanState=this.map.dragPan.isEnabled(),L(t)?this.startOnActiveFeature(e,t):this.drawConfig.boxSelect&&x(t)?this.startBoxSelect(e,t):void 0},ce.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=Ot(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0},ce.onTouchStart=function(e,t){if(L(t))return this.startOnActiveFeature(e,t)},ce.onDrag=function(e,t){return e.canDragMove?this.dragMove(e,t):this.drawConfig.boxSelect&&e.canBoxSelect?this.whileBoxSelect(e,t):void 0},ce.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:l.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(s.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));const n=Ot(t.originalEvent,this.map.getContainer()),o=Math.min(e.boxSelectStartLocation.x,n.x),r=Math.max(e.boxSelectStartLocation.x,n.x),i=Math.min(e.boxSelectStartLocation.y,n.y),f=Math.max(e.boxSelectStartLocation.y,n.y),E=`translate(${o}px, ${i}px)`;e.boxSelectElement.style.transform=E,e.boxSelectElement.style.WebkitTransform=E,e.boxSelectElement.style.width=r-o+"px",e.boxSelectElement.style.height=f-i+"px"},ce.dragMove=function(e,t){e.dragMoving=!0,t.originalEvent.stopPropagation();const n={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};Nt(this.getSelected(),n),e.dragMoveLocation=t.lngLat},ce.onTouchEnd=ce.onMouseUp=function(e,t){if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){const n=[e.boxSelectStartLocation,Ot(t.originalEvent,this.map.getContainer())],o=this.featuresAt(null,n,"click"),r=this.getUniqueIds(o).filter(i=>!this.isSelected(i));r.length&&(this.select(r),r.forEach(i=>this.doRender(i)),this.updateUIClasses({mouse:l.MOVE}))}this.stopExtendedInteractions(e)},ce.toDisplayFeatures=function(e,t,n){t.properties.active=this.isSelected(t.properties.id)?D.ACTIVE:D.INACTIVE,n(t),this.fireActionable(),t.properties.active===D.ACTIVE&&t.geometry.type!==P.POINT&&At(t).forEach(n)},ce.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},ce.onCombineFeatures=function(){const e=this.getSelected();if(0===e.length||e.length<2)return;const t=[],n=[],o=e[0].type.replace("Multi","");for(let r=0;r<e.length;r++){const i=e[r];if(i.type.replace("Multi","")!==o)return;i.type.includes("Multi")?i.getCoordinates().forEach(f=>{t.push(f)}):t.push(i.getCoordinates()),n.push(i.toGeoJSON())}if(n.length>1){const r=this.newFeature({type:P.FEATURE,properties:n[0].properties,geometry:{type:`Multi${o}`,coordinates:t}});this.addFeature(r),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([r.id]),this.fire(a.COMBINE_FEATURES,{createdFeatures:[r.toGeoJSON()],deletedFeatures:n})}this.fireActionable()},ce.onUncombineFeatures=function(){const e=this.getSelected();if(0===e.length)return;const t=[],n=[];for(let o=0;o<e.length;o++){const r=e[o];this.isInstanceOf("MultiFeature",r)&&(r.getFeatures().forEach(i=>{this.addFeature(i),i.properties=r.properties,t.push(i.toGeoJSON()),this.select([i.id])}),this.deleteFeature(r.id,{silent:!0}),n.push(r.toGeoJSON()))}t.length>1&&this.fire(a.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:n}),this.fireActionable()};const Fn=ce,cn=C(M.VERTEX),un=C(M.MIDPOINT),ue={fireUpdate:function(){this.fire(a.UPDATE,{action:g.CHANGE_COORDINATES,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(e){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:e.selectedCoordPaths.length>0})},startDragging:function(e,t){null==e.initialDragPanState&&(e.initialDragPanState=this.map.dragPan.isEnabled()),this.map.dragPan.disable(),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},stopDragging:function(e){e.canDragMove&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.initialDragPanState=null,e.dragMoving=!1,e.canDragMove=!1,e.dragMoveLocation=null},onVertex:function(e,t){this.startDragging(e,t);const n=t.featureTarget.properties,o=e.selectedCoordPaths.indexOf(n.coord_path);oe(t)||-1!==o?oe(t)&&-1===o&&e.selectedCoordPaths.push(n.coord_path):e.selectedCoordPaths=[n.coord_path];const r=this.pathsToCoordinates(e.featureId,e.selectedCoordPaths);this.setSelectedCoordinates(r)},onMidpoint:function(e,t){this.startDragging(e,t);const n=t.featureTarget.properties;e.feature.addCoordinate(n.coord_path,n.lng,n.lat),this.fireUpdate(),e.selectedCoordPaths=[n.coord_path]},pathsToCoordinates:function(e,t){return t.map(n=>({feature_id:e,coord_path:n}))},onFeature:function(e,t){0===e.selectedCoordPaths.length?this.startDragging(e,t):this.stopDragging(e)},dragFeature:function(e,t,n){Nt(this.getSelected(),n),e.dragMoveLocation=t.lngLat},dragVertex:function(e,t,n){const o=e.selectedCoordPaths.map(f=>e.feature.getCoordinate(f)),i=wt(o.map(f=>({type:P.FEATURE,properties:{},geometry:{type:P.POINT,coordinates:f}})),n);for(let f=0;f<o.length;f++){const E=o[f];e.feature.updateCoordinate(e.selectedCoordPaths[f],E[0]+i.lng,E[1]+i.lat)}},clickNoTarget:function(){this.changeMode(p.SIMPLE_SELECT)},clickInactive:function(){this.changeMode(p.SIMPLE_SELECT)},clickActiveFeature:function(e){e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed()},onSetup:function(e){const t=e.featureId,n=this.getFeature(t);if(!n)throw new Error("You must provide a featureId to enter direct_select mode");if(n.type===P.POINT)throw new TypeError("direct_select mode doesn't handle point features");const o={featureId:t,feature:n,dragMoveLocation:e.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:e.coordPath?[e.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(t,o.selectedCoordPaths)),this.setSelected(t),Ie.disable(this),this.setActionableState({trash:!0}),o},onStop:function(){Ie.enable(this),this.clearSelectedCoordinates()},toDisplayFeatures:function(e,t,n){e.featureId===t.properties.id?(t.properties.active=D.ACTIVE,n(t),At(t,{map:this.map,midpoints:!0,selectedPaths:e.selectedCoordPaths}).forEach(n)):(t.properties.active=D.INACTIVE,n(t)),this.fireActionable(e)},onTrash:function(e){e.selectedCoordPaths.sort((t,n)=>n.localeCompare(t,"en",{numeric:!0})).forEach(t=>e.feature.removeCoordinate(t)),this.fireUpdate(),e.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(e),!1===e.feature.isValid()&&(this.deleteFeature([e.featureId]),this.changeMode(p.SIMPLE_SELECT,{}))},onMouseMove:function(e,t){const n=L(t),o=cn(t),r=un(t),i=0===e.selectedCoordPaths.length;return this.updateUIClasses(n&&i||o&&!i?{mouse:l.MOVE}:{mouse:l.NONE}),(o||n||r)&&e.dragMoving&&this.fireUpdate(),this.stopDragging(e),!0},onMouseOut:function(e){return e.dragMoving&&this.fireUpdate(),!0}};ue.onTouchStart=ue.onMouseDown=function(e,t){return cn(t)?this.onVertex(e,t):L(t)?this.onFeature(e,t):un(t)?this.onMidpoint(e,t):void 0},ue.onDrag=function(e,t){if(!0!==e.canDragMove)return;e.dragMoving=!0,t.originalEvent.stopPropagation();const n={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};e.selectedCoordPaths.length>0?this.dragVertex(e,t,n):this.dragFeature(e,t,n),e.dragMoveLocation=t.lngLat},ue.onClick=function(e,t){return W(t)?this.clickNoTarget(e,t):L(t)?this.clickActiveFeature(e,t):w(t)?this.clickInactive(e,t):void this.stopDragging(e)},ue.onTap=function(e,t){return W(t)?this.clickNoTarget(e,t):L(t)?this.clickActiveFeature(e,t):w(t)?this.clickInactive(e,t):void 0},ue.onTouchEnd=ue.onMouseUp=function(e){e.dragMoving&&this.fireUpdate(),this.stopDragging(e)};const xn=ue,Fe={onSetup:function(){const e=this.newFeature({type:P.FEATURE,properties:{},geometry:{type:P.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:l.ADD}),this.activateUIButton(R.POINT),this.setActionableState({trash:!0}),{point:e}},stopDrawingAndRemove:function(e){this.deleteFeature([e.point.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT)}};Fe.onTap=Fe.onClick=function(e,t){this.updateUIClasses({mouse:l.MOVE}),e.point.updateCoordinate("",t.lngLat.lng,t.lngLat.lat),this.fire(a.CREATE,{features:[e.point.toGeoJSON()]}),this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.point.id]})},Fe.onStop=function(e){this.activateUIButton(),e.point.getCoordinate().length||this.deleteFeature([e.point.id],{silent:!0})},Fe.toDisplayFeatures=function(e,t,n){const o=t.properties.id===e.point.id;if(t.properties.active=o?D.ACTIVE:D.INACTIVE,!o)return n(t)},Fe.onTrash=Fe.stopDrawingAndRemove,Fe.onKeyUp=function(e,t){if(ye(t)||fe(t))return this.stopDrawingAndRemove(e,t)};const An=Fe,mt=function wn(e,t){return!!e.lngLat&&e.lngLat.lng===t[0]&&e.lngLat.lat===t[1]},Oe={onSetup:function(){const e=this.newFeature({type:P.FEATURE,properties:{},geometry:{type:P.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),Ie.disable(this),this.updateUIClasses({mouse:l.ADD}),this.activateUIButton(R.POLYGON),this.setActionableState({trash:!0}),{polygon:e,currentVertexPosition:0}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&mt(t,e.polygon.coordinates[0][e.currentVertexPosition-1]))return this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.polygon.id]});this.updateUIClasses({mouse:l.ADD}),e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},onMouseMove:function(e,t){e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),J(t)&&this.updateUIClasses({mouse:l.POINTER})}};Oe.onTap=Oe.onClick=function(e,t){return J(t)?this.clickOnVertex(e,t):this.clickAnywhere(e,t)},Oe.onKeyUp=function(e,t){ye(t)?(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT)):fe(t)&&this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},Oe.onStop=function(e){this.updateUIClasses({mouse:l.NONE}),Ie.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.polygon.id)&&(e.polygon.removeCoordinate(`0.${e.currentVertexPosition}`),e.polygon.isValid()?this.fire(a.CREATE,{features:[e.polygon.toGeoJSON()]}):(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT,{},{silent:!0})))},Oe.toDisplayFeatures=function(e,t,n){const o=t.properties.id===e.polygon.id;if(t.properties.active=o?D.ACTIVE:D.INACTIVE,!o)return n(t);if(0===t.geometry.coordinates.length)return;const r=t.geometry.coordinates[0].length;if(!(r<3)){if(t.properties.meta=M.FEATURE,n(Ze(e.polygon.id,t.geometry.coordinates[0][0],"0.0",!1)),r>3){const i=t.geometry.coordinates[0].length-3;n(Ze(e.polygon.id,t.geometry.coordinates[0][i],`0.${i}`,!1))}if(r<=4&&(n({type:P.FEATURE,properties:t.properties,geometry:{coordinates:[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]],type:P.LINE_STRING}}),3===r))return;return n(t)}},Oe.onTrash=function(e){this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT)};const Nn=Oe,De={onSetup:function(e){const t=(e=e||{}).featureId;let n,o,r="forward";if(t){if(n=this.getFeature(t),!n)throw new Error("Could not find a feature with the provided featureId");let i=e.from;if(i&&"Feature"===i.type&&i.geometry&&"Point"===i.geometry.type&&(i=i.geometry),i&&"Point"===i.type&&i.coordinates&&2===i.coordinates.length&&(i=i.coordinates),!i||!Array.isArray(i))throw new Error("Please use the `from` property to indicate which point to continue the line from");const f=n.coordinates.length-1;if(n.coordinates[f][0]===i[0]&&n.coordinates[f][1]===i[1])o=f+1,n.addCoordinate(o,...n.coordinates[f]);else{if(n.coordinates[0][0]!==i[0]||n.coordinates[0][1]!==i[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");r="backwards",o=0,n.addCoordinate(o,...n.coordinates[0])}}else n=this.newFeature({type:P.FEATURE,properties:{},geometry:{type:P.LINE_STRING,coordinates:[]}}),o=0,this.addFeature(n);return this.clearSelectedFeatures(),Ie.disable(this),this.updateUIClasses({mouse:l.ADD}),this.activateUIButton(R.LINE),this.setActionableState({trash:!0}),{line:n,currentVertexPosition:o,direction:r}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&mt(t,e.line.coordinates[e.currentVertexPosition-1])||"backwards"===e.direction&&mt(t,e.line.coordinates[e.currentVertexPosition+1]))return this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.line.id]});this.updateUIClasses({mouse:l.ADD}),e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),"forward"===e.direction?(e.currentVertexPosition++,e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat)):e.line.addCoordinate(0,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.line.id]})},onMouseMove:function(e,t){e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),J(t)&&this.updateUIClasses({mouse:l.POINTER})}};De.onTap=De.onClick=function(e,t){if(J(t))return this.clickOnVertex(e,t);this.clickAnywhere(e,t)},De.onKeyUp=function(e,t){fe(t)?this.changeMode(p.SIMPLE_SELECT,{featureIds:[e.line.id]}):ye(t)&&(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT))},De.onStop=function(e){Ie.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.line.id)&&(e.line.removeCoordinate(`${e.currentVertexPosition}`),e.line.isValid()?this.fire(a.CREATE,{features:[e.line.toGeoJSON()]}):(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT,{},{silent:!0})))},De.onTrash=function(e){this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(p.SIMPLE_SELECT)},De.toDisplayFeatures=function(e,t,n){const o=t.properties.id===e.line.id;if(t.properties.active=o?D.ACTIVE:D.INACTIVE,!o)return n(t);t.geometry.coordinates.length<2||(t.properties.meta=M.FEATURE,n(Ze(e.line.id,t.geometry.coordinates["forward"===e.direction?t.geometry.coordinates.length-2:1],""+("forward"===e.direction?t.geometry.coordinates.length-2:1),!1)),n(t))};const dn={simple_select:Fn,direct_select:xn,draw_point:An,draw_polygon:Nn,draw_line_string:De},Rn={defaultMode:p.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:Gt,modes:dn,controls:{},userProperties:!1,suppressAPIEvents:!0},kn={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},Bn={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function fn(e,t){return e.map(n=>n.source?n:Object.assign({},n,{id:`${n.id}.${t}`,source:"hot"===t?F.HOT:F.COLD}))}var hn=u(362),Vn=u(5341);function pn(e,t){return e.length===t.length&&JSON.stringify(e.map(n=>n).sort())===JSON.stringify(t.map(n=>n).sort())}const Un={Polygon:ae,LineString:le,Point:Y,MultiPolygon:Ne,MultiLineString:Ne,MultiPoint:Ne};function yt(e){!function(e,t){e=function Gn(e={}){let t=Object.assign({},e);return e.controls||(t.controls={}),t.controls=Object.assign({},!1===e.displayControlsDefault?Bn:kn,e.controls),t=Object.assign({},Rn,t),t.styles=fn(t.styles,"cold").concat(fn(t.styles,"hot")),t}(e);const n={options:e};t=function zn(e,t){t.modes=p;const n=void 0===e.options.suppressAPIEvents||!!e.options.suppressAPIEvents;return t.getFeatureIdsAt=function(o){return ke.click({point:o},null,e).map(i=>i.properties.id)},t.getSelectedIds=function(){return e.store.getSelectedIds()},t.getSelected=function(){return{type:P.FEATURE_COLLECTION,features:e.store.getSelectedIds().map(o=>e.store.get(o)).map(o=>o.toGeoJSON())}},t.getSelectedPoints=function(){return{type:P.FEATURE_COLLECTION,features:e.store.getSelectedCoordinates().map(o=>({type:P.FEATURE,properties:{},geometry:{type:P.POINT,coordinates:o.coordinates}}))}},t.set=function(o){if(void 0===o.type||o.type!==P.FEATURE_COLLECTION||!Array.isArray(o.features))throw new Error("Invalid FeatureCollection");const r=e.store.createRenderBatch();let i=e.store.getAllIds().slice();const f=t.add(o),E=new we(f);return i=i.filter(y=>!E.has(y)),i.length&&t.delete(i),r(),f},t.add=function(o){const i=JSON.parse(JSON.stringify(Vn(o))).features.map(f=>{if(f.id=f.id||c(),null===f.geometry)throw new Error("Invalid geometry: null");if(void 0===e.store.get(f.id)||e.store.get(f.id).type!==f.geometry.type){const E=Un[f.geometry.type];if(void 0===E)throw new Error(`Invalid geometry type: ${f.geometry.type}.`);const y=new E(e,f);e.store.add(y,{silent:n})}else{const E=e.store.get(f.id),y=E.properties;E.properties=f.properties,hn(y,f.properties)||e.store.featureChanged(E.id,{silent:n}),hn(E.getCoordinates(),f.geometry.coordinates)||E.incomingCoords(f.geometry.coordinates)}return f.id});return e.store.render(),i},t.get=function(o){const r=e.store.get(o);if(r)return r.toGeoJSON()},t.getAll=function(){return{type:P.FEATURE_COLLECTION,features:e.store.getAll().map(o=>o.toGeoJSON())}},t.delete=function(o){return e.store.delete(o,{silent:n}),t.getMode()!==p.DIRECT_SELECT||e.store.getSelectedIds().length?e.store.render():e.events.changeMode(p.SIMPLE_SELECT,void 0,{silent:n}),t},t.deleteAll=function(){return e.store.delete(e.store.getAllIds(),{silent:n}),t.getMode()===p.DIRECT_SELECT?e.events.changeMode(p.SIMPLE_SELECT,void 0,{silent:n}):e.store.render(),t},t.changeMode=function(o,r={}){return o===p.SIMPLE_SELECT&&t.getMode()===p.SIMPLE_SELECT?(pn(r.featureIds||[],e.store.getSelectedIds())||(e.store.setSelected(r.featureIds,{silent:n}),e.store.render()),t):(o===p.DIRECT_SELECT&&t.getMode()===p.DIRECT_SELECT&&r.featureId===e.store.getSelectedIds()[0]||e.events.changeMode(o,r,{silent:n}),t)},t.getMode=function(){return e.events.getMode()},t.trash=function(){return e.events.trash({silent:n}),t},t.combineFeatures=function(){return e.events.combineFeatures({silent:n}),t},t.uncombineFeatures=function(){return e.events.uncombineFeatures({silent:n}),t},t.setFeatureProperty=function(o,r,i){return e.store.setFeatureProperty(o,r,i,{silent:n}),t},t}(n,t),n.api=t;const o=kt(n);t.onAdd=o.onAdd,t.onRemove=o.onRemove,t.types=R,t.options=e}(e,this)}yt.modes=dn,yt.constants=S,yt.lib=O;const gn=yt;let Wn=(()=>{class e{_draw;_map;_drawMode=(0,z.vPA)(!1);_settingDrawMode=!1;_eventListeners=[];_clearAfterFinish=!0;drawEvent=(0,z.vPA)(void 0);destroy(){this._cleanup()}initializeWithMap(n){this._map=n,this._initDrawControl(n)}setDrawMode(n,o){if(this._draw&&this._map&&!this._settingDrawMode){if(this._clearAfterFinish=o,this._settingDrawMode=!0,this._drawMode.set(n),n){this._draw.deleteAll(),this._draw.changeMode("draw_polygon");const r={type:"polygon",status:"started",coordinates:[],bbox:{minLng:0,minLat:0,maxLng:0,maxLat:0}};this.drawEvent.update(()=>r)}else this._draw.changeMode("simple_select"),this._draw.deleteAll();this._settingDrawMode=!1}}setClearAfterFinish(n){this._clearAfterFinish=n}getClearAfterFinish(){return this._clearAfterFinish}getDrawMode(){return this._drawMode()}clearDrawings(){this._draw&&this._draw.deleteAll()}getDrawInstance(){return this._draw}_initDrawControl(n){this._draw=new gn({displayControlsDefault:!1,modes:{...gn.modes}}),n.addControl(this._draw,"top-left");const o=document.querySelector(".mapbox-gl-draw_ctrl-draw-btn")?.parentElement;o&&(o.style.display="none");const r=E=>{const y=E.features[0];if("Polygon"===y.geometry.type){const N=y.geometry.coordinates[0],j={type:"polygon",status:"ended",coordinates:N,bbox:this._calculateBBox(N)};this.drawEvent.update(()=>j),this._drawMode.set(!1),this._clearAfterFinish&&this._draw?.deleteAll()}},i=E=>{const y=E.features[0];if("Polygon"===y.geometry.type){const N=y.geometry.coordinates[0],j={type:"polygon",status:"in-progress",coordinates:N,bbox:this._calculateBBox(N)};this.drawEvent.update(()=>j)}},f=()=>{if(this._drawMode()){const E=this._draw?.getAll();if(E?.features?.length){const y=E.features[0];if("Polygon"===y.geometry.type){const N=y.geometry.coordinates[0];if(N.length>2){const j={type:"polygon",status:"in-progress",coordinates:N,bbox:this._calculateBBox(N)};this.drawEvent.update(()=>j)}}}}};n.on("draw.create",r),n.on("draw.update",i),n.on("mousemove",f),this._eventListeners.push({event:"draw.create",handler:r}),this._eventListeners.push({event:"draw.update",handler:i}),this._eventListeners.push({event:"mousemove",handler:f})}_cleanup(){this._map&&(this._eventListeners.forEach(({event:n,handler:o})=>{this._map?.off(n,o)}),this._eventListeners=[],this._draw&&this._map._controls?.includes(this._draw)&&this._map.removeControl(this._draw)),this._draw=void 0,this._map=void 0,this.drawEvent.set(void 0)}_calculateBBox(n){return n.reduce((o,r)=>({minLng:Math.min(o.minLng,r[0]),minLat:Math.min(o.minLat,r[1]),maxLng:Math.max(o.maxLng,r[0]),maxLat:Math.max(o.maxLat,r[1])}),{minLng:1/0,minLat:1/0,maxLng:-1/0,maxLat:-1/0})}static \u0275fac=function(o){return new(o||e)};static \u0275prov=z.jDH({token:e,factory:e.\u0275fac})}return e})()},6986(se,Q,u){"use strict";u.d(Q,{A4:()=>S,Jc:()=>l,Ln:()=>O,dx:()=>s,g8:()=>m,j5:()=>z,n7:()=>F});const S=12;function m(p,a,g){return{id:p,source:a,type:"circle",maxzoom:S,filter:["==",["get","_isCentroid"],!0],paint:{"circle-radius":6,"circle-color":["coalesce",["get","_color"],g],"circle-stroke-width":2,"circle-stroke-color":"white","circle-opacity":.8}}}function O(p,a,g,M){return function P(p,a,g,M,D){const k={id:p,source:M},b=D||g;switch(a){case"Point":case"MultiPoint":return[{...k,id:`${p}-clusters`,type:"circle",filter:["has","point_count"],paint:{"circle-color":b,"circle-radius":["step",["get","point_count"],15,100,20,750,25],"circle-stroke-width":2,"circle-stroke-color":"white","circle-opacity":.8}},{...k,id:`${p}-cluster-count`,type:"symbol",filter:["has","point_count"],layout:{"text-field":"{point_count_abbreviated}","text-font":["Poppins Medium","Arial Unicode MS Bold"],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#ffffff","text-halo-color":"rgba(0, 0, 0, 0.3)","text-halo-width":1}},{...k,id:`${p}-unclustered`,type:"circle",filter:["!",["has","point_count"]],paint:{"circle-radius":6,"circle-color":["coalesce",["get","_color"],g],"circle-stroke-width":2,"circle-stroke-color":"white","circle-opacity":.8}}];case"LineString":case"MultiLineString":return{...k,type:"line",paint:{"line-color":["coalesce",["get","_color"],g],"line-width":3,"line-opacity":.8},layout:{"line-join":"round","line-cap":"round"}};case"Polygon":case"MultiPolygon":return[{id:`${p}-fill`,source:M,type:"fill",paint:{"fill-color":["coalesce",["get","_color"],g],"fill-opacity":.3}},{id:`${p}-stroke`,source:M,type:"line",paint:{"line-color":["coalesce",["get","_color"],g],"line-width":2,"line-opacity":.8},layout:{"line-join":"round","line-cap":"round"}},{id:`${p}-labels`,source:M,type:"symbol",layout:{"text-field":["coalesce",["get","label"],""],"text-font":["Poppins Medium","Arial Unicode MS Bold"],"text-size":13,"text-anchor":"center","text-allow-overlap":!1},paint:{"text-color":"#333333","text-halo-color":"rgba(255, 255, 255, 0.9)","text-halo-width":2}}];default:return console.warn(`Unsupported geometry type: ${a}`),null}}(p,a,g,M,g)}function z(p){return"Polygon"===p||"MultiPolygon"===p}function s(p){return"LineString"===p||"MultiLineString"===p}function F(p,a){return a&&("Point"===p||"MultiPoint"===p)}function l(p,a){return F(p,a)?{cluster:!0,clusterMaxZoom:14,clusterRadius:50,clusterMinPoints:2}:{cluster:!1}}},3646(se,Q,u){"use strict";u.d(Q,{B:()=>U});var S=u(467),m=u(5802),O=u(2271),z=u(4412),s=u(1413),F=u(2306),l=u(140);function b(B){let X=1/0,h=1/0,C=-1/0,x=-1/0;const L=B.features,w=Z=>{Z.length>=2&&(X=Math.min(X,Z[0]),h=Math.min(h,Z[1]),C=Math.max(C,Z[0]),x=Math.max(x,Z[1]))},W=(Z,J)=>{if(0===J)w(Z);else if(Array.isArray(Z))for(const oe of Z)W(oe,J-1)};for(const Z of L){const J=Z.geometry;switch(J.type){case"Point":W(J.coordinates,0);break;case"LineString":case"MultiPoint":W(J.coordinates,1);break;case"Polygon":case"MultiLineString":W(J.coordinates,2);break;case"MultiPolygon":W(J.coordinates,3);break;case"GeometryCollection":for(const oe of J.geometries){const he=b(new l.o([{type:"Feature",geometry:oe,properties:null}]));he&&(w([he[0],he[1]]),w([he[2],he[3]]))}}}return X===1/0?null:[X,h,C,x]}var A=u(6986);let U=(()=>{class B{_layers$=new z.t([]);_map;_sources={};_sourceLayers={};_sourceIds=[];_attachedListeners=[];_hoveredFeature=(0,m.vPA)(void 0);_layerGroups={};_layerClickable={};_pointLayerIds=new Set;_lineLayerIds=new Set;_processedClickEvents=new WeakSet;_clearHoverTimeout;_hoverSequence=0;layers=this._layers$.asObservable();layersSignal=(0,O.EW)(()=>this._layers$.getValue());clickedFeature=new s.B;hoveredFeature=new s.B;initializeWithMap(h){this._map=h,h.on("mousemove",C=>{const x=h.getCanvas();if(!x)return;const L=Object.keys(this._layerClickable).filter(W=>this._layerClickable[W]&&h.getLayer(W)),w=h.queryRenderedFeatures(C.point,{layers:L});x.style.cursor=w.length>0?"pointer":""})}getLayers(){return this._layers$.getValue()}setLayers(h){this._layers$.next([...h])}addLayer(h){const C=this._layers$.getValue(),x=C.findIndex(L=>L.id===h.id);x>=0?C[x]={...h}:C.push({...h}),this._layers$.next([...C])}removeLayer(h){const x=this._layers$.getValue().filter(L=>L.id!==h);this._layers$.next(x),this._deleteSourceIfExists(h.toString()),delete this._sources[h.toString()],delete this._sourceLayers[h.toString()],delete this._layerClickable[h.toString()],this._pointLayerIds.delete(h.toString()),this._lineLayerIds.delete(h.toString()),this._sourceIds=this._sourceIds.filter(L=>L!==h.toString())}toggleVisibility(h){const C=h.toString();if(this._layerGroups[C])return void this.toggleLayerGroupVisibility(C);const L=this._layers$.getValue().map(w=>{if(w.id===h){const W={...w,visible:!w.visible};return this._updateLayerVisibility(h.toString(),W.visible),W}return w});this._layers$.next(L)}setLayerVisibility(h,C){const x=h.toString();if(this._layerGroups[x]){if(this._map){const Z=C?"visible":"none";this._layerGroups[x].forEach(J=>{this._map.setLayoutProperty(J,"visibility",Z)})}}else this._updateLayerVisibility(x,C);const w=this._layers$.getValue().map(W=>W.id===h?{...W,visible:C}:W);this._layers$.next(w)}loadGeoJSONLayerGroup(h,C,x){var L=this;return(0,S.A)(function*(w,W,Z,J={}){const{cluster:oe=!1,zoomToFit:ye=!0,visible:fe=!0,label:he=w,color:me=L._extractColorFromLayer(Z[0])}=J;if(!L._map)return void console.warn("Map not initialized in LayerService");const ne=w;yield L._addSource(w,{type:"geojson",data:W,...(0,A.Jc)("Point",oe)});const ze=[];for(const ve of Z){ze.push(ve.id),L._layerClickable[ve.id]=!0,L._sourceLayers[ne]||(L._sourceLayers[ne]={layer:ve,clickable:!0});const Ke=ve.type;if("circle"===Ke||"symbol"===Ke)L._pointLayerIds.add(ve.id),L._map.addLayer(ve);else if("line"===Ke){L._lineLayerIds.add(ve.id);const Ae=L._getBeforePointLayerId();L._map.addLayer(ve,Ae)}else{const Ae=L._getBeforeLineLayerId()??L._getBeforePointLayerId();L._map.addLayer(ve,Ae)}L._map&&L._map.setLayoutProperty(ve.id,"visibility",fe?"visible":"none")}for(const ve of Z)L._setLayerEvents(ne,ve);L._layerGroups[w]=ze;const xe=new F.ux(he,w);xe.collection=W,xe.color=me,xe.visible=fe,L.addLayer(xe),ye&&L.fitLayerBounds(w)}).apply(this,arguments)}toggleLayerGroupVisibility(h){const C=this._layerGroups[h];if(!C)return;const x=this.getLayer(h);if(!x)return;const L=!x.visible;if(this._map){const w=L?"visible":"none";C.forEach(W=>{this._map.setLayoutProperty(W,"visibility",w)})}this.updateLayer(h,{visible:L})}removeLayerGroup(h){const C=this._layerGroups[h];C&&(this._map&&(C.forEach(x=>{this._map.removeLayer(x),this._attachedListeners=this._attachedListeners.filter(L=>L!==h),delete this._layerClickable[x],this._pointLayerIds.delete(x),this._lineLayerIds.delete(x)}),this._deleteSourceIfExists(h)),delete this._sources[h],delete this._sourceLayers[h],this._sourceIds=this._sourceIds.filter(x=>x!==h),delete this._layerGroups[h],this.removeLayer(h))}loadGeoJSONLayer(h,C,x){var L=this;return(0,S.A)(function*(w,W,Z,J={}){const{cluster:oe=!0,zoomToFit:ye=!0,visible:fe=!0,label:he=w,color:me=L._extractColorFromLayer(Z)}=J;if(!L._map)return void console.warn("Map not initialized in LayerService");yield L._addSource(w,{type:"geojson",data:W,...(0,A.Jc)("Point",oe)},Z);const ne=new F.ux(he,w);ne.collection=W,ne.color=me,ne.visible=fe,L.addLayer(ne),L._updateLayerVisibility(w,fe),ye&&L.fitLayerBounds(w)}).apply(this,arguments)}_addSource(h,C,x){var L=this;return(0,S.A)(function*(w,W,Z,J=!0){L._map&&(L._sources[w]=W,L._deleteSourceIfExists(w),L._sourceIds.push(w),L._map.getSource(w)&&L._map.removeSource(w),L._map.addSource(w,W),Z&&L._addSourceLayer(w,Z,J))}).apply(this,arguments)}_getBeforePointLayerId(){if(!this._map||0===this._pointLayerIds.size)return;const h=this._map.getStyle()?.layers??[];for(const C of h)if(this._pointLayerIds.has(C.id))return C.id}_getBeforeLineLayerId(){if(!this._map||0===this._lineLayerIds.size)return;const h=this._map.getStyle()?.layers??[];for(const C of h)if(this._lineLayerIds.has(C.id))return C.id}_addSourceLayer(h,C,x=!0){if(!this._map)return;this._layerClickable[C.id]=x,this._sourceLayers[h]||(this._sourceLayers[h]={layer:C,clickable:x});const L=C.type;if("circle"===L||"symbol"===L)this._pointLayerIds.add(C.id),this._map.addLayer(C);else if("line"===L){this._lineLayerIds.add(C.id);const w=this._getBeforePointLayerId();this._map.addLayer(C,w)}else{const w=this._getBeforeLineLayerId()??this._getBeforePointLayerId();this._map.addLayer(C,w)}x&&this._setLayerEvents(h,C)}_updateLayerVisibility(h,C){if(!this._map)return;const x=this._sourceLayers[h];x&&this._map.setLayoutProperty(x.layer.id,"visibility",C?"visible":"none")}getLayer(h){return this._layers$.getValue().find(C=>C.id===h)}updateLayer(h,C){const L=this._layers$.getValue().map(w=>{if(w.id===h){const W={...w,...C};return void 0!==C.visible&&this._updateLayerVisibility(h.toString(),C.visible),W}return w});this._layers$.next(L)}toggleAllLayers(){const h=this._layers$.getValue(),x=!h.some(w=>w.visible),L=h.map(w=>(this._updateLayerVisibility(w.id.toString(),x),{...w,visible:x}));this._layers$.next(L)}getVisibleLayersCount(){return this._layers$.getValue().filter(h=>h.visible).length}getTotalLayersCount(){return this._layers$.getValue().length}hasLayer(h){return this._layers$.getValue().some(C=>C.id===h)}fitGeoJSONBounds(h,C=50,x=!0,L=19){this._fitGeoJSONBounds(h,C,x,L)}fitLayerBounds(h,C=50){const x=this._layers$.getValue().find(L=>L.id===h);!x||!x.collection||!this._map||("features"in x.collection?this._fitGeoJSONBounds(x.collection,C):console.warn("Layer collection is not a FeatureCollection, cannot fit bounds."))}fitAllVisibleLayers(h=50){const C=this._layers$.getValue().filter(W=>W.visible&&W.collection);if(0===C.length||!this._map)return;const x=C.flatMap(W=>{const Z=W.collection;return Z&&"features"in Z&&Array.isArray(Z.features)?Z.features:[]}),L=new l.o(x),w=b(L);w&&(L.bbox=w),this._fitGeoJSONBounds(L,h)}clearAllLayers(){if(this._map){for(const[h,C]of Object.entries(this._layerGroups))C.forEach(x=>{this._map.getLayer(x)&&this._map.removeLayer(x)}),this._map.getSource(h)&&this._map.removeSource(h);for(const h of this._sourceIds)this._layerGroups[h]||this._deleteSourceIfExists(h)}this._sourceIds=[],this._sourceLayers={},this._sources={},this._attachedListeners=[],this._layerGroups={},this._layerClickable={},this._layers$.next([])}reapplyLayers(){this._map&&(Object.keys(this._sources).forEach(h=>{this._deleteSourceIfExists(h),this._map.addSource(h,this._sources[h]);const C=this._sourceLayers[h];if(C){this._map.addLayer(C.layer);const x=this._layers$.getValue().find(L=>L.id===h);x&&this._updateLayerVisibility(h,x.visible)}}),this._reattachAllLayerEvents())}_extractColorFromLayer(h){if("paint"in h&&"object"==typeof h.paint){const C=h.paint;return C["circle-color"]||C["fill-color"]||C["line-color"]||""}return""}_fitGeoJSONBounds(h,C=50,x=!0,L=19){if(!this._map)return void console.warn("Map not initialized when trying to fit bounds");if(!h.features||0===h.features.length)return void console.warn("No features to fit bounds to");let w=h.bbox;if(!w){const W=b(h);if(!W)return void console.warn("Failed to calculate bbox for GeoJSON");h.bbox=W,w=W}if(w&&4===w.length)try{this._map.fitBounds([[w[0],w[1]],[w[2],w[3]]],{padding:C,maxZoom:L,animate:x})}catch(W){console.error("Error fitting bounds:",W)}}_deleteSourceIfExists(h){if(!this._map||!this._map.getSource(h))return;const x=this._layerGroups[h];if(x)x.forEach(L=>{this._map.getLayer(L)&&this._map.removeLayer(L)});else{const L=Object.values(this._sourceLayers).find(w=>"source"in w.layer&&w.layer.source===h);L&&this._map.getLayer(L.layer.id)&&(this._map.removeLayer(L.layer.id),this._attachedListeners=this._attachedListeners.filter(w=>w!==L.layer.id))}this._map.removeSource(h)}_setLayerEvents(h,C){if(!this._map)return;const x=C.id.endsWith("-fill"),L=C.id.endsWith("-stroke"),w=x?C.id.replace("-fill",""):L?C.id.replace("-stroke",""):C.id;if(x||L){const J=`${w}-stroke`;this._layerClickable[`${w}-fill`]=!0,this._layerClickable[J]=!0}if(!this._layerClickable[C.id])return;const W=[];if(x||L){const Z=`${w}-fill`,J=`${w}-stroke`;this._map.getLayer(Z)&&W.push(Z),this._map.getLayer(J)&&W.push(J)}else W.push(C.id);W.forEach(Z=>{this._attachedListeners.includes(Z)||(this._map.on("click",Z,J=>{if(!J.features||this._processedClickEvents.has(J.originalEvent))return;const oe=J.features[0],ye=oe.properties;if(ye&&!ye.cluster){const fe=this.getLayer(h)||this.getLayer(w)||this.getLayer(Z);if(fe){const he={...oe,geometry:oe.geometry};if(fe.collection&&"features"in fe.collection){const me=fe.collection.features.find(ne=>ne.geometry.type===oe.geometry?.type&&JSON.stringify(ne.properties)===JSON.stringify(oe.properties));me&&me.id&&(he.id=me.id)}this._processedClickEvents.add(J.originalEvent),this.clickedFeature.next({feature:he,event:J.originalEvent,layer:fe,lngLat:J.lngLat})}}}),this._map.on("mouseenter",Z,J=>{if(this._hoverSequence++,this._clearHoverTimeout&&(clearTimeout(this._clearHoverTimeout),this._clearHoverTimeout=void 0),!J.features)return;const oe=J.features[0],ye=oe.properties,fe={...oe,geometry:oe.geometry};if(ye&&!ye.cluster){const he=this.getLayer(h)||this.getLayer(w)||this.getLayer(Z);if(he){if(he.collection&&"features"in he.collection){const me=he.collection.features.find(ne=>ne.geometry.type===oe.geometry?.type&&JSON.stringify(ne.properties)===JSON.stringify(oe.properties));me&&me.id&&(fe.id=me.id)}this.hoveredFeature.next({feature:fe,event:J.originalEvent,layer:he,lngLat:J.lngLat})}this._hoveredFeature.set(fe)}}),this._map.on("mouseleave",Z,()=>{const J=this._hoverSequence;this._clearHoverTimeout=window.setTimeout(()=>{this._hoverSequence===J&&(this._hoveredFeature.set(void 0),this.hoveredFeature.next(void 0)),this._clearHoverTimeout=void 0},50)}),this._map.on("click",Z,J=>{if(!J.features)return;const oe=J.features[0].properties;if(oe&&oe.cluster){const ye=this._map?.getZoom();ye&&this._map?.flyTo({center:J.lngLat,zoom:ye+1})}}),this._attachedListeners.push(Z))})}_reattachAllLayerEvents(){this._attachedListeners=[],Object.keys(this._sourceLayers).forEach(h=>{const C=this._sourceLayers[h];C&&this._setLayerEvents(h,C.layer)})}static \u0275fac=function(C){return new(C||B)};static \u0275prov=m.jDH({token:B,factory:B.\u0275fac})}return B})()},8017(se,Q,u){"use strict";u.d(Q,{T:()=>St});var S=u(467),m=u(5802),O=u(7705),z=u(2271),s=u(5547),F=u(9769),l=u(5970),R=u(6170),P=u(5949),p=u(2843),a=u(3646),g=u(9079),M=u(1413),D=u(2306),k=u(7089),b=u(9352),A=u(5381),U=u(5187),B=u(5971),X=u(3319);function h(_,I){if(1&_){const c=s.RV6();s.j41(0,"cue-button",5),s.nI1(1,"transloco"),s.bIt("click",function(){m.eBV(c);const v=s.XpG(2);return m.Njj(v.handleZoomFit())}),s.nrm(2,"cue-button-icon",9),s.k0s()}2&_&&s.Y8G("cueTooltip",s.bMT(1,1,"components.map.tooltipZoomFit"))}function C(_,I){if(1&_){const c=s.RV6();s.j41(0,"cue-flexcontainer",3)(1,"cue-button",5),s.nI1(2,"transloco"),s.bIt("click",function(){m.eBV(c);const v=s.XpG();return m.Njj(v.handleZoomOut())}),s.nrm(3,"cue-button-icon",6),s.k0s(),s.j41(4,"cue-button",5),s.nI1(5,"transloco"),s.bIt("click",function(){m.eBV(c);const v=s.XpG();return m.Njj(v.handleZoomIn())}),s.nrm(6,"cue-button-icon",7),s.k0s(),s.nVh(7,h,3,3,"cue-button",8),s.k0s()}if(2&_){const c=s.XpG();s.R7$(),s.Y8G("cueTooltip",s.bMT(2,3,"components.map.tooltipZoomOut")),s.R7$(3),s.Y8G("cueTooltip",s.bMT(5,5,"components.map.tooltipZoomIn")),s.R7$(3),s.vxM(c.displayZoomFit()?7:-1)}}function x(_,I){if(1&_){const c=s.RV6();s.j41(0,"cue-button",10),s.nI1(1,"transloco"),s.nI1(2,"transloco"),s.mxI("selectedChange",function(v){m.eBV(c);const V=s.XpG();return s.DH7(V.layersVisible,v)||(V.layersVisible=v),m.Njj(v)}),s.nrm(3,"cue-button-icon",11),s.k0s()}if(2&_){const c=s.XpG();s.AVh("border-left",c.options().displayZoom&&c.displayLayerToggle()),s.Y8G("cueTooltip",c.layersVisible()?s.bMT(1,6,"components.map.tooltipHideLayers"):s.bMT(2,8,"components.map.tooltipShowLayers"))("toggleButton",!0),s.R50("selected",c.layersVisible),s.R7$(3),s.Y8G("icon",c.layersVisible()?"layers-clear":"layers")}}function L(_,I){if(1&_){const c=s.RV6();s.j41(0,"cue-button",10),s.nI1(1,"transloco"),s.nI1(2,"transloco"),s.mxI("selectedChange",function(v){m.eBV(c);const V=s.XpG();return s.DH7(V.geoFenceDrawEnabled,v)||(V.geoFenceDrawEnabled=v),m.Njj(v)}),s.nrm(3,"cue-button-icon",12),s.k0s()}if(2&_){const c=s.XpG();s.AVh("border-left",c.options().displayGeofenceDraw),s.Y8G("cueTooltip",c.geoFenceDrawEnabled()?s.bMT(1,5,"components.map.tooltipEndDrawGeofence"):s.bMT(2,7,"components.map.tooltipDrawGeofence"))("toggleButton",!0),s.R50("selected",c.geoFenceDrawEnabled)}}let w=(()=>{class _{_service=(0,m.WQX)(P.u);layerService=(0,m.WQX)(a.B);mapLayers=(0,g.ot)(this.layerService.layers);options=(0,O.hFB)(new D.AA);zoom=(0,O.geq)(1);rotate=(0,O.CGW)();geoFenceDrawEnabled=(0,O.geq)(!1);layersVisible=(0,O.geq)(!1);hasLayers=(0,z.EW)(()=>void 0!==this.mapLayers()&&this.mapLayers().length>0);displayLayerToggle=(0,z.EW)(()=>this.options().displayLayerToggle&&this.hasLayers());displayZoomFit=(0,z.EW)(()=>this.options().displayZoom&&this.hasLayers());selectMenuPositions=(0,z.EW)(()=>"top"===this.options().position?"bottomleft":"topleft");handleZoomIn(){this._service.zoomIn()}handleZoomOut(){this._service.zoomOut()}handleZoomFit(){this._service.fitGeoJSONBBOX(void 0,.01)}static \u0275fac=function(d){return new(d||_)};static \u0275cmp=s.VBU({type:_,selectors:[["cue-map-toolbar"]],inputs:{options:[1,"options"],zoom:[1,"zoom"],geoFenceDrawEnabled:[1,"geoFenceDrawEnabled"],layersVisible:[1,"layersVisible"]},outputs:{zoom:"zoomChange",rotate:"rotate",geoFenceDrawEnabled:"geoFenceDrawEnabledChange",layersVisible:"layersVisibleChange"},decls:6,vars:4,consts:[["justify","center",1,"container"],[1,"toolbar",3,"padded"],["align","center"],["align","center","gap","s"],["size","xs","variant","ghost",3,"border-left","cueTooltip","toggleButton","selected"],["size","xs","variant","tertiary",3,"click","cueTooltip"],["icon","zoom-out"],["icon","zoom-in"],["size","xs","variant","tertiary",3,"cueTooltip"],["icon","zoom-fit"],["size","xs","variant","ghost",3,"selectedChange","cueTooltip","toggleButton","selected"],[3,"icon"],["icon","polygon"]],template:function(d,v){1&d&&(s.j41(0,"cue-flexcontainer",0)(1,"cue-card",1)(2,"cue-flexcontainer",2),s.nVh(3,C,8,7,"cue-flexcontainer",3),s.nVh(4,x,4,10,"cue-button",4),s.nVh(5,L,4,9,"cue-button",4),s.k0s()()()),2&d&&(s.R7$(),s.Y8G("padded",!1),s.R7$(2),s.vxM(v.options().displayZoom?3:-1),s.R7$(),s.vxM(v.displayLayerToggle()?4:-1),s.R7$(),s.vxM(v.options().displayGeofenceDraw?5:-1))},dependencies:[A.n,U.Z,B.$,X.a,k.d,b.Kj],styles:[".container[_ngcontent-%COMP%]{width:100%;pointer-events:none}.toolbar[_ngcontent-%COMP%]{pointer-events:all;padding:5px 10px}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return _})();var W=u(7023),Z=u(1024),J=u(9421);function oe(_,I){if(1&_&&s.nrm(0,"cue-key-val",1),2&_){const c=I.$implicit;s.Y8G("key",c.key)("val",c.val)}}let ye=(()=>{class _{props=(0,O.hFB)(null);keyVals=(0,z.EW)(()=>{const c=this.props();return c?Object.entries(c).map(([d,v])=>({key:d,val:String(v)})):[]});static \u0275fac=function(d){return new(d||_)};static \u0275cmp=s.VBU({type:_,selectors:[["cue-props-panel"]],inputs:{props:[1,"props"]},decls:4,vars:0,consts:[[2,"height","100%","overflow-y","auto"],[3,"key","val"]],template:function(d,v){1&d&&(s.j41(0,"cue-flexcontainer",0)(1,"cue-key-val-list"),s.Z7z(2,oe,1,2,"cue-key-val",1,s.Vm6),s.k0s()()),2&d&&(s.R7$(2),s.Dyx(v.keyVals()))},dependencies:[Z.p,J.F,A.n],encapsulation:2,changeDetection:0})}return _})();var fe=u(7517);let he=(()=>{class _{layerService=(0,m.WQX)(a.B);mapLayers=(0,g.ot)(this.layerService.layers);layerDefs=(0,z.EW)(()=>{const c=this.mapLayers();return c?c.map(d=>({label:d.label,color:d.color??"#000000",visible:d.visible,category:d.category})):[]});updateSingle(c){const d=this.mapLayers()?.find(v=>v.label===c.label);d&&this.layerService.toggleVisibility(d.id)}updateAll(c){const d=this.mapLayers();if(d)for(const v of d)v.visible===c&&this.layerService.toggleVisibility(v.id)}static \u0275fac=function(d){return new(d||_)};static \u0275cmp=s.VBU({type:_,selectors:[["cue-layer-panel"]],decls:1,vars:1,consts:[[3,"layerChange","visibilityAll","layers"]],template:function(d,v){1&d&&(s.j41(0,"cue-layer-legend",0),s.bIt("layerChange",function(Y){return v.updateSingle(Y)})("visibilityAll",function(Y){return v.updateAll(Y)}),s.k0s()),2&d&&s.Y8G("layers",v.layerDefs())},dependencies:[F.MD,fe.P],encapsulation:2})}return _})();var me=u(140),ne=u(6986);function ve(_){const I=_.flatMap(c=>{const d=function xe(_){switch(_.type){case"Point":return[_.coordinates[0],_.coordinates[1]];case"MultiPoint":{if(!_.coordinates.length)return null;const I=_.coordinates.reduce((c,d)=>[c[0]+d[0],c[1]+d[1]],[0,0]);return[I[0]/_.coordinates.length,I[1]/_.coordinates.length]}case"LineString":{if(!_.coordinates.length)return null;const I=Math.floor(_.coordinates.length/2);return[_.coordinates[I][0],_.coordinates[I][1]]}case"MultiLineString":{if(!_.coordinates.length||!_.coordinates[0].length)return null;const I=_.coordinates[0],c=Math.floor(I.length/2);return[I[c][0],I[c][1]]}case"Polygon":{if(!_.coordinates.length||!_.coordinates[0].length)return null;const I=_.coordinates[0],c=I.reduce((d,v)=>[d[0]+v[0],d[1]+v[1]],[0,0]);return[c[0]/I.length,c[1]/I.length]}case"MultiPolygon":{if(!_.coordinates.length||!_.coordinates[0]?.length||!_.coordinates[0][0]?.length)return null;const I=_.coordinates[0][0],c=I.reduce((d,v)=>[d[0]+v[0],d[1]+v[1]],[0,0]);return[c[0]/I.length,c[1]/I.length]}default:return null}}(c.geometry);return d?[{type:"Feature",id:c.id,geometry:{type:"Point",coordinates:d},properties:{...c.properties??{},_isCentroid:!0}}]:[]});return[..._,...I]}const ut=["rgba(255, 0, 0, 0.5)","rgba(0, 0, 255, 0.5)","rgba(0, 255, 0, 0.5)","rgba(255, 165, 0, 0.5)","rgba(128, 0, 128, 0.5)","rgba(255, 192, 203, 0.5)","rgba(255, 255, 0, 0.5)"];function _t(_){const I=_.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d\.]+))?\)/);if(I)return{r:parseInt(I[1]),g:parseInt(I[2]),b:parseInt(I[3]),a:I[4]?parseFloat(I[4]):1};const c=_.match(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/);if(c){const d=c[1];return{r:parseInt(3===d.length?d[0]+d[0]:d.slice(0,2),16),g:parseInt(3===d.length?d[1]+d[1]:d.slice(2,4),16),b:parseInt(3===d.length?d[2]+d[2]:d.slice(4,6),16),a:1}}return{r:0,g:0,b:0,a:1}}function je(_){if(0===_.length)return ut[0];if(1===_.length)return _[0].color;const I=_.map(ae=>({...ae,totalWeight:ae.featureCount*ae.weight})).sort((ae,de)=>de.totalWeight-ae.totalWeight),c=I.reduce((ae,de)=>ae+de.totalWeight,0),d=I[0];if(d.totalWeight/c>.6)return d.color;const v=I.slice(0,Math.min(3,I.length)),V=v.reduce((ae,de)=>ae+de.totalWeight,0);let Y=0,q=0,le=0,ge=0;for(const ae of v){const de=_t(ae.color),_e=ae.totalWeight/V;Y+=de.r*_e,q+=de.g*_e,le+=de.b*_e,ge+=de.a*_e}return function dt(_,I,c,d=1){return d<1?`rgba(${Math.round(_)}, ${Math.round(I)}, ${Math.round(c)}, ${d})`:`rgb(${Math.round(_)}, ${Math.round(I)}, ${Math.round(c)})`}(Y,q,le,ge)}function He(_,I,c,d){if(!d||"Point"!==c&&"MultiPoint"!==c)return[{color:I,weight:1,featureCount:_.length}];const v=_.length;if(v<10)return[{color:I,weight:1,featureCount:v}];let V=0,Y=0,q=0;v>=750?(V=Math.floor(.1*v),Y=Math.floor(.3*v),q=v-V-Y):v>=100?(Y=Math.floor(.4*v),q=v-Y):(q=Math.floor(.8*v),Y=v-q);const le=[];return q>0&&le.push({color:I,weight:1,featureCount:q}),Y>0&&le.push({color:"#f28cb1",weight:2,featureCount:Y}),V>0&&le.push({color:"#e2f552",weight:3,featureCount:V}),le}function Qe(_,I,c,d,v,V){const Y=Array.isArray(d)?d:[d];(0,ne.j5)(v)?_.layerService.loadGeoJSONLayerGroup(I,c,Y,{cluster:!1,zoomToFit:V.zoomToFit,visible:V.visible,label:V.label,color:V.color}):Y.length>1||("Point"===v||"MultiPoint"===v)&&Array.isArray(Y)&&Y.length>1?_.layerService.loadGeoJSONLayerGroup(I,c,Y,{cluster:(0,ne.n7)(v,V.cluster),zoomToFit:V.zoomToFit,visible:V.visible,label:V.label,color:V.color}):_.loadGeoJSON(I,c,Y[0],(0,ne.n7)(v,V.cluster),V.zoomToFit)}var vt=u(6756),bt=u(356),ft=u(6279);const Xe=["map"],qe=_=>({position:"bottomleft",hoveredFeature:_}),Et=(_,I)=>I.label;function Mt(_,I){if(1&_){const c=s.RV6();s.j41(0,"cue-menu-item",6),s.bIt("click",function(v){const V=m.eBV(c).$implicit;return m.Njj(V.action(v))}),s.EFF(1),s.k0s()}if(2&_){const c=I.$implicit;s.R7$(),s.JRh(c.label)}}function Ct(_,I){if(1&_&&(s.j41(0,"cue-menu-wrap"),s.Z7z(1,Mt,2,1,"cue-menu-item",null,Et),s.k0s()),2&_){const c=s.XpG();s.R7$(),s.Dyx(c.contextMenuItems())}}function et(_,I){if(1&_&&(s.j41(0,"span"),s.EFF(1),s.k0s()),2&_){const c=s.XpG();s.R7$(),s.JRh(c.mapService.error())}}function Lt(_,I){if(1&_){const c=s.RV6();s.j41(0,"cue-map-toolbar",8),s.mxI("zoomChange",function(v){m.eBV(c);const V=s.XpG(2);return s.DH7(V.zoom,v)||(V.zoom=v),m.Njj(v)})("layersVisibleChange",function(v){m.eBV(c);const V=s.XpG(2);return s.DH7(V.layerPanelVisible,v)||(V.layerPanelVisible=v),m.Njj(v)})("geoFenceDrawEnabledChange",function(v){m.eBV(c);const V=s.XpG(2);return s.DH7(V.geoFenceDrawEnabled,v)||(V.geoFenceDrawEnabled=v),m.Njj(v)}),s.k0s()}if(2&_){const c=s.XpG(),d=s.XpG();s.Aen(d.toolbarStyle()),s.Y8G("options",c),s.R50("zoom",d.zoom)("layersVisible",d.layerPanelVisible)("geoFenceDrawEnabled",d.geoFenceDrawEnabled)}}function Tt(_,I){1&_&&s.nVh(0,Lt,1,6,"cue-map-toolbar",7),2&_&&s.vxM(I.hidden?-1:0)}function tt(_,I){1&_&&(s.j41(0,"cue-card",4),s.nrm(1,"cue-layer-panel"),s.k0s())}function Rt(_,I){1&_&&(s.j41(0,"cue-card",5),s.nrm(1,"cue-props-panel",9),s.k0s()),2&_&&(s.R7$(),s.Y8G("props",I))}function nt(_,I){if(1&_&&(s.j41(0,"div",11),s.EFF(1),s.k0s()),2&_){const c=I,d=s.XpG();s.xc7("left",c.x,"px")("top",c.y,"px"),s.R7$(),s.SpI(" ",d," ")}}function Pt(_,I){if(1&_&&s.nVh(0,nt,2,5,"div",10),2&_){let c;const d=s.XpG();s.vxM((c=d.hoveredTooltipPosition())?0:-1,c)}}let St=(()=>{class _{mapService=(0,m.WQX)(P.u);drawService=(0,m.WQX)(p.M);settings=(0,O.hFB)(new D.yY);center=(0,O.hFB)([8.5,47.4]);layerPanelVisible=(0,O.geq)(!1);zoom=(0,O.geq)(2);instruction=(0,O.geq)("Hello");layers=(0,O.hFB)([]);zoomToFit=(0,O.hFB)(!0);zoomToFitEachLayer=(0,O.hFB)(!1);splitLayersByGeometryType=(0,O.hFB)(!0);maxClickZoom=(0,O.hFB)(1/0);borderRadius=(0,O.hFB)("0");geoFenceDrawEnabled=(0,O.geq)(!1);contextMenuItemsBefore=(0,O.hFB)([]);contextMenuItemsAfter=(0,O.hFB)([]);immidiateDrawMode=(0,O.hFB)(void 0);hoverTooltipFn=(0,O.hFB)(null);mapReady=(0,O.CGW)();clickedMap=(0,O.CGW)();pannedMap=(0,O.CGW)();panningMap=(0,O.CGW)();zoomedMap=(0,O.CGW)();clickedFeature=(0,O.CGW)();hoveredFeature=(0,O.CGW)();drawEvent=(0,O.CGW)();layersSaturated=(0,z.EW)(()=>this.layers().map((c,d)=>{const v={...c};return v.color||(v.color=vt.BK[d]),v}));toolbarOptions=(0,z.EW)(()=>this.settings().toolbar);featureBeingHovered=(0,m.vPA)(void 0);lastClickedFeatureEvent=(0,m.vPA)(void 0);lastHoveredFeatureEvent=(0,m.vPA)(void 0);shownProperties=(0,m.vPA)(null);hoveredTooltipLabel=(0,z.EW)(()=>{const c=this.hoverTooltipFn();if(!c)return null;const d=this.lastHoveredFeatureEvent();return d?c(d.feature.properties??{})??null:null});hoveredTooltipPosition=(0,z.EW)(()=>{if(!this.hoveredTooltipLabel())return null;const c=this.lastHoveredFeatureEvent();if(!c)return null;const d=this.mapService.map;if(!d)return null;const v=d.project([c.lngLat.lng,c.lngLat.lat]);return{x:v.x,y:v.y}});_featureClickedThisTick=!1;_previousLayersHash=(0,m.vPA)("");_userHasInteracted=(0,m.vPA)(!1);toolbarStyle=(0,z.EW)(()=>{const c=this.toolbarOptions();return{position:"absolute",left:c.margin,right:c.margin,["top"===c.position?"top":"bottom"]:c.margin,"z-index":"10",display:"flex","justify-content":"center"}});contextMenuEnabled=(0,z.EW)(()=>{const c=this.contextMenuItems().length>0,d=this.featureBeingHovered(),v=this.lastClickedFeatureEvent();return c&&(void 0!==d||void 0!==v)});contextMenuItems=(0,z.EW)(()=>{const c=this.lastHoveredFeatureEvent(),d=this.lastClickedFeatureEvent(),V=(c?.feature||d?.feature)?.properties||null,Y=V?Object.fromEntries(Object.entries(V).filter(([_e])=>!_e.startsWith("_"))):null,q=c?.lngLat||d?.lngLat||null,ge=[...this.contextMenuItemsBefore()||[]],ae=this.settings().contextMenu;Y&&Object.keys(Y).length>0&&ae.showProperties&&ge.push({label:"Show properties",action:()=>{this.shownProperties.update(()=>Y)}}),q&&ae.showFlyTo&&ge.push({label:"Fly to feature",action:()=>{this.mapService.flyTo([q.lng,q.lat],this.zoom())}});const de=this.contextMenuItemsAfter()||[];return[...ge,...de]});_mapContainer;_destroy$=new M.B;constructor(){this._subscribeToServiceOutputs(),this._setupEffects(),(0,s.mal)(()=>{this._destroy$.closed||this._tryInitializeMap()})}ngOnDestroy(){this._destroy$.next(),this._destroy$.complete(),this.drawService.destroy(),this.mapService.destroy()}_subscribeToServiceOutputs(){this.mapService.mapReady.pipe((0,g.pQ)()).subscribe(()=>this.mapReady.emit()),this.mapService.clickedMap.pipe((0,g.pQ)()).subscribe(c=>{this._featureClickedThisTick||(this.lastClickedFeatureEvent.update(()=>{}),this.lastHoveredFeatureEvent.update(()=>{}),this.featureBeingHovered.update(()=>{}),this.clickedMap.emit(c),this.shownProperties.update(()=>null))}),this.mapService.pannedMap.pipe((0,g.pQ)()).subscribe(c=>{this._userHasInteracted.set(!0),this.pannedMap.emit(c)}),this.mapService.panningMap.pipe((0,g.pQ)()).subscribe(c=>this.panningMap.emit(c)),this.mapService.zoomedMap.pipe((0,g.pQ)()).subscribe(c=>{this._userHasInteracted.set(!0),this.zoomedMap.emit(this.mapService.getZoom()??this.zoom())}),this.mapService.clickedFeature.pipe((0,g.pQ)()).subscribe(c=>{this._featureClickedThisTick=!0,queueMicrotask(()=>{this._featureClickedThisTick=!1}),this.lastClickedFeatureEvent.update(()=>c),this.clickedFeature.emit(c);const d=c.feature?.geometry?.type,v="Point"===d||"MultiPoint"===d,V=this.mapService.getZoom()??0,Y=this.contextMenuItems().length>0;v&&!Y&&V<this.maxClickZoom()&&this.mapService.zoomToCoordinate(c.lngLat)}),this.mapService.hoveredFeature.pipe((0,g.pQ)()).subscribe(c=>{this.featureBeingHovered.update(()=>c?.feature),this.lastHoveredFeatureEvent.update(()=>c),this.hoveredFeature.emit(c)})}_setupEffects(){var c=this;(0,m.QZP)(()=>{"polygon"===this.immidiateDrawMode()&&(this.geoFenceDrawEnabled.set(!0),setTimeout(()=>{this.drawService.setDrawMode(!0,this.settings().toolbar.clearGeofenceAfterDraw)},500))}),(0,m.QZP)(()=>this.mapService.flyTo(this.center(),this.zoom())),(0,m.QZP)(()=>{const v=this.settings()?.mapboxToken;v&&"string"==typeof v&&""!==v.trim()&&!this.mapService.isMapReady()&&this._tryInitializeMap()}),(0,m.QZP)(()=>{const d=this.geoFenceDrawEnabled();this.drawService.setDrawMode(d,this.settings().toolbar.clearGeofenceAfterDraw)}),(0,m.QZP)(()=>{const d=this.drawService.drawEvent();void 0!==d&&this.drawEvent.emit(d)}),(0,m.QZP)((0,S.A)(function*(){const d=c.layersSaturated();if(!d||0===d.length)return;const v=c._createLayersHash(d);if(v===c._previousLayersHash())return;c._previousLayersHash.set(v),yield c.mapService.waitForMapReady(),c.mapService.clearLayers();const Y=c.zoomToFitEachLayer();d.forEach((q,le)=>{!function ke(_,I,c,d,v,V,Y){const q=I.collection,le=I.color??ut[c];let ge;ge="geometries"in q?function Re(_){const I=_.geometries.map((d,v)=>({type:"Feature",geometry:d,properties:{},id:_.id?`${_.id}_${v}`:void 0})),c=new me.o(I);return c.id=_.id,c.bbox=_.bbox,c}(q):q;const ae=function we(_){const I=[];return _.forEach(c=>{c.geometry&&"GeometryCollection"===c.geometry.type?c.geometry.geometries.forEach((d,v)=>{I.push({type:"Feature",geometry:d,properties:c.properties||{},id:c.id?`${c.id}_${v}`:void 0})}):I.push(c)}),I}(ge.features),de=new me.o(ae);de.id=ge.id,de.bbox=ge.bbox;let _e=le;if(!V){const H=I.id.toString(),ee=ae[0]?.geometry?.type||"Point";_e=je(He(ae,le,ee,d));let be=Y(H,ee,_e,H),Se=de;const Be="Point"!==ee&&"MultiPoint"!==ee,Me=(0,ne.j5)(ee),pe=(0,ne.dx)(ee);if(d&&Be&&!Me&&!pe&&be){const ot=Array.isArray(be)?be:[be],ie=ve(ae);Se=new me.o(ie),Se.id=de.id,Se.bbox=de.bbox,be=[(0,ne.g8)(`${H}-centroid`,H,_e),...ot.map(it=>({...it,minzoom:ne.A4}))]}return void(be&&Qe(_,H,Se,be,ee,{cluster:d,zoomToFit:v,visible:!0,label:I.label||I.id.toString(),color:_e}))}if(V){const H=new Set(ae.map(re=>re.geometry.type)),ee=[];return H.forEach(re=>{const be=`${I.id.toString()}-${re}`,Se=ae.filter(pe=>pe.geometry.type===re),Be=He(Se,le,re,d);ee.push(...Be);let Me=Y(be,re,le,be);if(Me){let pe=new me.o(Se);pe.id=de.id,pe.bbox=de.bbox;const ot="Point"!==re&&"MultiPoint"!==re,ie=(0,ne.j5)(re),rt=(0,ne.dx)(re);if(d&&ot&&!ie&&!rt){const it=Array.isArray(Me)?Me:[Me],It=ve(Se);pe=new me.o(It),pe.id=de.id,pe.bbox=de.bbox,Me=[(0,ne.g8)(`${be}-centroid`,be,le),...it.map(st=>({...st,minzoom:ne.A4}))]}Qe(_,be,pe,Me,re,{cluster:d,zoomToFit:v,visible:!0,label:H.size>1?`${I.label||I.id} (${re})`:`${I.label||I.id}`,color:le})}}),void(ee.length>0&&(_e=je(ee),_.layerService.getLayer(I.id.toString())&&_.layerService.updateLayer(I.id.toString(),{color:_e})))}const Ee=new Map;ae.forEach(H=>{const ee=H.geometry.type;let re;re="Point"===ee||"MultiPoint"===ee?"Point":"LineString"===ee||"MultiLineString"===ee?"LineString":"Polygon"===ee||"MultiPolygon"===ee?"Polygon":ee,Ee.has(re)||Ee.set(re,[]),Ee.get(re).push(ee)});const Ne=[];Ee.forEach((H,ee)=>{const re=`${I.id.toString()}-${ee}`,be=ae.filter(Me=>{const pe=Me.geometry.type;return"Point"===ee?"Point"===pe||"MultiPoint"===pe:"LineString"===ee?"LineString"===pe||"MultiLineString"===pe:"Polygon"===ee?"Polygon"===pe||"MultiPolygon"===pe:pe===ee}),Se=He(be,le,ee,d);Ne.push(...Se);const Be=Y(re,ee,le,re);if(Be){const Me=new me.o(be);Me.id=de.id,Me.bbox=de.bbox,Qe(_,re,Me,Be,ee,{cluster:d,zoomToFit:v,visible:!0,label:Ee.size>1?`${I.label||I.id} (${ee})`:`${I.label||I.id}`,color:le})}}),Ne.length>0&&(_e=je(Ne),_.layerService.getLayer(I.id.toString())&&_.layerService.updateLayer(I.id.toString(),{color:_e}))}(c.mapService,q,le,q.cluster,Y&&q.zoomToFit,c.splitLayersByGeometryType(),ne.Ln)}),c.zoomToFit()&&!Y&&!c._userHasInteracted()&&c.mapService.fitGeoJSONBBOX()}))}_tryInitializeMap(){if(this._destroy$.closed)return;const d=this.settings()?.mapboxToken,v=d&&"string"==typeof d&&""!==d.trim(),V=this._mapContainer,Y=!this.mapService.isMapReady();v&&V&&Y&&(this._userHasInteracted.set(!1),this.mapService.init(this._mapContainer.nativeElement,d,this.center(),this.zoom(),this.borderRadius()))}_createLayersHash(c){return c.map(d=>{const v=d.collection;let V=0;return v&&"FeatureCollection"===v.type&&"features"in v&&(V=Array.isArray(v.features)?v.features.length:0),`${d.id}|${d.label}|${d.visible}|${V}`}).join("::")}static \u0275fac=function(d){return new(d||_)};static \u0275cmp=s.VBU({type:_,selectors:[["cue-map"]],viewQuery:function(d,v){if(1&d&&s.GBs(Xe,5),2&d){let V;s.mGM(V=s.lsd())&&(v._mapContainer=V.first)}},hostAttrs:["data-component","cue-map-main"],inputs:{settings:[1,"settings"],center:[1,"center"],layerPanelVisible:[1,"layerPanelVisible"],zoom:[1,"zoom"],instruction:[1,"instruction"],layers:[1,"layers"],zoomToFit:[1,"zoomToFit"],zoomToFitEachLayer:[1,"zoomToFitEachLayer"],splitLayersByGeometryType:[1,"splitLayersByGeometryType"],maxClickZoom:[1,"maxClickZoom"],borderRadius:[1,"borderRadius"],geoFenceDrawEnabled:[1,"geoFenceDrawEnabled"],contextMenuItemsBefore:[1,"contextMenuItemsBefore"],contextMenuItemsAfter:[1,"contextMenuItemsAfter"],immidiateDrawMode:[1,"immidiateDrawMode"],hoverTooltipFn:[1,"hoverTooltipFn"]},outputs:{layerPanelVisible:"layerPanelVisibleChange",zoom:"zoomChange",instruction:"instructionChange",geoFenceDrawEnabled:"geoFenceDrawEnabledChange",mapReady:"mapReady",clickedMap:"clickedMap",pannedMap:"pannedMap",panningMap:"panningMap",zoomedMap:"zoomedMap",clickedFeature:"clickedFeature",hoveredFeature:"hoveredFeature",drawEvent:"drawEvent"},features:[s.Jv_([P.u,p.M,a.B])],decls:10,vars:10,consts:[["hoveringFeature",""],["map",""],["direction","row",1,"container"],["id","map","cueResized","","cueDarkMode","","trigger","leftclick",3,"darkModeChange","resized","cueContextMenu","contextMenuData","cueContextEnabled"],[1,"layer-panel"],[1,"props-panel"],[3,"click"],[3,"options","style","zoom","layersVisible","geoFenceDrawEnabled"],[3,"zoomChange","layersVisibleChange","geoFenceDrawEnabledChange","options","zoom","layersVisible","geoFenceDrawEnabled"],[3,"props"],[1,"hover-tooltip",3,"left","top"],[1,"hover-tooltip"]],template:function(d,v){if(1&d&&(s.DNE(0,Ct,3,0,"ng-template",null,0,s.C5r),s.j41(2,"cue-flexcontainer",2)(3,"div",3,1),s.bIt("darkModeChange",function(Y){return v.mapService.setDarkMode(Y)})("resized",function(){return v.mapService.onParentResize()}),s.k0s(),s.nVh(5,et,2,1,"span"),s.nVh(6,Tt,1,1),s.nVh(7,tt,2,0,"cue-card",4),s.nVh(8,Rt,2,1,"cue-card",5),s.nVh(9,Pt,1,1),s.k0s()),2&d){let V,Y,q;const le=s.sdS(1);s.R7$(3),s.Y8G("cueContextMenu",le)("contextMenuData",s.eq3(8,qe,v.lastHoveredFeatureEvent()))("cueContextEnabled",v.contextMenuEnabled()),s.R7$(2),s.vxM(v.mapService.error()?5:-1),s.R7$(),s.vxM((V=v.toolbarOptions())?6:-1,V),s.R7$(),s.vxM(v.layerPanelVisible()?7:-1),s.R7$(),s.vxM((Y=v.shownProperties())?8:-1,Y),s.R7$(),s.vxM((q=v.hoveredTooltipLabel())?9:-1,q)}},dependencies:[F.MD,l.C,R.R,w,W.Q,bt.M,ft.D,A.n,ye,he,U.Z],styles:["#map[_ngcontent-%COMP%]{flex:1;min-height:0;border-radius:inherit;overflow:hidden}[_nghost-%COMP%]{display:flex;flex-direction:column;position:relative;width:100%;height:100%;min-height:400px;min-width:200px;flex:1 1 auto;align-self:stretch;box-sizing:border-box;overflow:hidden;border-radius:var(--cue-card-border-radius, inherit)}.mapboxgl-canvas-container[_ngcontent-%COMP%], .mapboxgl-canvas[_ngcontent-%COMP%]{border-radius:inherit!important}.mapboxgl-map[_ngcontent-%COMP%]{border-radius:inherit!important;overflow:hidden!important}.container[_ngcontent-%COMP%]{position:relative;width:100%;flex:1;min-height:0;overflow:hidden;display:flex;flex-direction:column}.props-panel[_ngcontent-%COMP%]{position:absolute;top:8px;right:8px;bottom:8px;z-index:10}.layer-panel[_ngcontent-%COMP%]{position:absolute;top:10px;left:10px;z-index:10}cue-map-toolbar[_ngcontent-%COMP%]{position:absolute;left:0;right:0;bottom:0;z-index:10;display:flex;justify-content:center}.hover-tooltip[_ngcontent-%COMP%]{position:absolute;background:var(--cue-menu-background-color);color:var(--cue-menu-foreground-color);box-shadow:var(--cue-menu-box-shadow);border:1px solid var(--cue-menu-border-color);padding:3px 8px;border-radius:4px;font-family:var(--cue-font-family);font-size:.75rem;line-height:1.4;pointer-events:none;white-space:nowrap;z-index:20;transform:translate(-50%,calc(-100% - 8px))}"]})}return _})()},5949(se,Q,u){"use strict";u.d(Q,{u:()=>R});var S=u(467),m=u(5802),O=u(2271),z=u(1413),s=u(3646),F=u(2843),l=u(9079);let R=(()=>{class P{_map;_mapContainer;_isInitializing=!1;_mapReadyPromiseResolve;_mapReady=new Promise(a=>{this._mapReadyPromiseResolve=a});_emittedReady=!1;_firstThemeReceived=!1;_hoveredFeature=(0,m.vPA)(void 0);_layerService=(0,m.WQX)(s.B);_drawService=(0,m.WQX)(F.M);mapboxToken=(0,m.vPA)("");center=(0,m.vPA)([8.5,47.4]);zoom=(0,m.vPA)(2);borderRadius=(0,m.vPA)("0");mapReady=new z.B;clickedMap=new z.B;pannedMap=new z.B;panningMap=new z.B;zoomedMap=new z.B;error=(0,m.vPA)("");get clickedFeature(){return this._layerService.clickedFeature}get hoveredFeature(){return this._layerService.hoveredFeature}get layers(){return this._layerService.layers}get layersSignal(){return this._layerService.layersSignal}get layerService(){return this._layerService}get drawService(){return this._drawService}get drawEvent(){return this._drawService.drawEvent}_darkMode=(0,m.vPA)(this._getSystemColorPreference());_styleId=(0,O.EW)(()=>this._darkMode()?"madsholten/clwjh4xeu00q601pnczm07jq6":"madsholten/clwjh6ug900q701pn6eor8p51");get map(){return this._map}constructor(){this._layerService.hoveredFeature.pipe((0,l.pQ)()).subscribe(a=>{this._hoveredFeature.set(a?.feature)}),(0,m.QZP)(()=>{this._styleId(),this._firstThemeReceived?void 0!==this._map&&this._updateStyle().catch(a=>{console.error("Failed to update map style:",a)}):this._firstThemeReceived=!0})}destroy(){if(this._layerService?.clearAllLayers(),this._drawService?.destroy(),this._map)try{this._map.remove()}catch(a){console.warn("Error removing map:",a)}this._map=void 0,this._mapContainer&&(this._mapContainer.innerHTML="",this._mapContainer=void 0),this._isInitializing=!1,this._emittedReady=!1,this._mapReady=new Promise(a=>{this._mapReadyPromiseResolve=a})}isMapReady(){return void 0!==this._map&&this._emittedReady&&!this._isInitializing}waitForMapReady(){var a=this;return(0,S.A)(function*(){return a._mapReady})()}init(a,g,M,D,k){var b=this;return(0,S.A)(function*(){if(g&&""!==g.trim())if(b._map||b._isInitializing)console.warn("MapService: Map is already initialized or currently initializing");else{b._isInitializing=!0,b.mapboxToken.set(g),b.center.set(M),b.zoom.set(D),b.borderRadius.set(k),b._mapContainer=a,b._mapContainer&&(b._mapContainer.innerHTML="");try{yield b._loadMapboxCSS();const A=yield u.e(247).then(u.t.bind(u,1247,23)),U=A.default||A;if(!U||"function"!=typeof U.Map)throw new Error("Mapbox GL JS not properly loaded");U.accessToken=b.mapboxToken(),b._map=new U.Map({container:a,style:b._getMapStyleURL(),center:b.center(),zoom:b.zoom()}),b._applyBorderRadius(a),b._initEventListeners(b._map)}catch(A){console.error("Failed to load mapbox-gl:",A),b.error.set("Failed to load map library. Please ensure mapbox-gl is installed.")}finally{b._isInitializing=!1}}else console.warn("MapService: Cannot initialize map without valid mapbox token")})()}loadGeoJSON(a,g,M){var D=this;return(0,S.A)(function*(k,b,A,U=!0,B=!0){return yield D._mapReady,D._layerService.loadGeoJSONLayer(k,b,A,{cluster:U,zoomToFit:B,visible:!0,label:k})}).apply(this,arguments)}fitGeoJSONBBOX(a){var g=this;return(0,S.A)(function*(M,D=50,k=!0,b=19){yield g._mapReady,M?g._layerService.fitGeoJSONBounds(M,D,k,b):g._layerService.fitAllVisibleLayers(D)}).apply(this,arguments)}jumpTo(a,g){this._map?.jumpTo({center:a,zoom:g??this.zoom()})}setDarkMode(a){this._darkMode.set(a)}zoomToCoordinate(a){const g=this._map?.getZoom();if(!g)return;const M=g+1;this._map?.flyTo({center:a,zoom:M})}getZoom(){return this._map?.getZoom()}flyTo(a,g,M){this._map?.flyTo({center:a,zoom:g??this.zoom(),essential:!0,padding:M})}zoomIn(){if(!this._map)return;const a=this._map.getZoom();this._map.flyTo({zoom:a+1})}zoomOut(){if(!this._map)return;const a=this._map.getZoom();this._map.flyTo({zoom:a-1})}clearLayers(){this._layerService.clearAllLayers()}getImage(){const a=this._map?.getCanvas();if(void 0!==a)return a.toDataURL("image/png")}onParentResize(){this._map?.resize()}_loadMapboxCSS(){return(0,S.A)(function*(){return new Promise((a,g)=>{if(document.querySelector('link[href*="mapbox-gl.css"]'))return void a();const M=document.createElement("link");M.rel="stylesheet",M.href="https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.css",M.onload=()=>a(),M.onerror=()=>{const D=document.createElement("link");D.rel="stylesheet",D.href="node_modules/mapbox-gl/dist/mapbox-gl.css",D.onload=()=>a(),D.onerror=()=>g(new Error("Failed to load Mapbox CSS")),document.head.appendChild(D)},document.head.appendChild(M)})})()}_applyBorderRadius(a){const g=this.borderRadius();let M=g;if("0"===g){const k=a.closest("cue-map")?.parentElement;k&&(M=getComputedStyle(k).borderRadius||"0")}"0"!==M&&(a.style.borderRadius=M,a.style.overflow="hidden",setTimeout(()=>{const D=a.querySelector(".mapboxgl-canvas"),k=a.querySelector(".mapboxgl-canvas-container"),b=a.querySelector(".mapboxgl-map");D&&(D.style.borderRadius=M),k&&(k.style.borderRadius=M),b&&(b.style.borderRadius=M)},100))}_initEventListeners(a){a.on("click",g=>{void 0===this._hoveredFeature()&&this.clickedMap.next(g)}),a.on("drag",g=>{void 0===this._hoveredFeature()&&this.panningMap.next(g)}),a.on("dragend",g=>{void 0===this._hoveredFeature()&&this.pannedMap.next(g)}),a.on("zoomend",g=>{this.zoomedMap.next(g)}),a.on("load",()=>{this._emittedReady||(this._layerService.initializeWithMap(a),this._drawService.initializeWithMap(a),this._mapReadyPromiseResolve(),this.mapReady.next(),this._emittedReady=!0)}),a.on("error",g=>{this.error.set(g.error.message)})}_getMapStyleURL(){return`mapbox://styles/${this._styleId()}`}_updateStyle(){var a=this;return(0,S.A)(function*(){if(void 0===a._map)return;const g=a._map.getZoom(),M=a._map.getCenter();void 0!==a._mapContainer&&(yield a.init(a._mapContainer,a.mapboxToken(),M,g,a.borderRadius()),setTimeout(()=>{a._layerService.reapplyLayers(),a._map?.flyTo({center:M,zoom:g})},500))})()}_getSystemColorPreference(){return typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches}static \u0275fac=function(g){return new(g||P)};static \u0275prov=m.jDH({token:P,factory:P.\u0275fac})}return P})()},2306(se,Q,u){"use strict";u.d(Q,{AA:()=>z,ux:()=>s,yY:()=>O});var S=u(140),m=u(8402);class O{mapboxToken;contextMenu={showProperties:!0,showFlyTo:!0};toolbar=new z}class z{hidden=!1;position="bottom";margin="20px";displayZoom=!0;displayGeofenceDraw=!1;displayLayerToggle=!0;clearGeofenceAfterDraw=!0}class s{label;id;collection=new S.o;color;visible=!0;cluster=!0;zoomToFit=!0;category;constructor(l,R=(0,m.A)()){this.label=l,this.id=R}}},8334(se,Q,u){"use strict";u.d(Q,{o:()=>z});var S=u(7705),m=u(5547);const O=["*"];let z=(()=>{class s{label=S.hFB.required();active=(0,S.geq)(!1);static \u0275fac=function(R){return new(R||s)};static \u0275cmp=m.VBU({type:s,selectors:[["cue-tab"]],hostVars:1,hostBindings:function(R,P){2&R&&m.Avn("hidden",!P.active())},inputs:{label:[1,"label"],active:[1,"active"]},outputs:{active:"activeChange"},ngContentSelectors:O,decls:1,vars:0,template:function(R,P){1&R&&(m.NAR(),m.SdG(0))},styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0}[hidden][_nghost-%COMP%]{display:none!important}"]})}return s})()},6455(se,Q,u){"use strict";u.d(Q,{t:()=>D});var S=u(7705),m=u(5802),O=u(2271),z=u(8334),s=u(5187),F=u(9769),l=u(5547);const R=["*"],P=(k,b)=>b.label();function p(k,b){if(1&k&&(l.j41(0,"cue-card",1),l.eu8(1,2),l.k0s()),2&k){const A=l.XpG(),U=l.sdS(3);l.Y8G("variant",A._cardVariant())("padded",!1),l.R7$(),l.Y8G("ngTemplateOutlet",U)}}function a(k,b){if(1&k&&l.eu8(0,2),2&k){l.XpG();const A=l.sdS(3);l.Y8G("ngTemplateOutlet",A)}}function g(k,b){if(1&k){const A=l.RV6();l.j41(0,"button",6),l.bIt("click",function(){const B=m.eBV(A).$index,X=l.XpG(2);return m.Njj(X.setActive(B))}),l.EFF(1),l.k0s()}if(2&k){const A=b.$implicit,U=b.$index,B=l.XpG(2);l.AVh("active",B.activeIndex()===U),l.R7$(),l.SpI(" ",A.label()," ")}}function M(k,b){if(1&k&&(l.j41(0,"div",3),l.Z7z(1,g,2,3,"button",4,P),l.k0s(),l.j41(3,"div",5),l.SdG(4),l.k0s()),2&k){const A=l.XpG();l.R7$(),l.Dyx(A.tabs())}}let D=(()=>{class k{tabs=(0,S.tEk)(z.o);activeIndex=(0,m.vPA)(0);variant=(0,S.hFB)("none");_cardVariant=(0,O.EW)(()=>"none"===this.variant()?"default":this.variant());constructor(){(0,m.QZP)(()=>{const A=this.tabs(),U=this.activeIndex();A.forEach((B,X)=>B.active.set(X===U))})}setActive(A){this.activeIndex.set(A)}static \u0275fac=function(U){return new(U||k)};static \u0275cmp=l.VBU({type:k,selectors:[["cue-tabs"]],contentQueries:function(U,B,X){1&U&&l.C6U(X,B.tabs,z.o,4),2&U&&l.NyB()},inputs:{variant:[1,"variant"]},ngContentSelectors:R,decls:4,vars:1,consts:[["inner",""],[2,"height","100%","width","100%","display","flex","flex-direction","column","overflow","hidden",3,"variant","padded"],[3,"ngTemplateOutlet"],[1,"tabs-header"],[1,"tab-button",3,"active"],[1,"tabs-content"],[1,"tab-button",3,"click"]],template:function(U,B){1&U&&(l.NAR(),l.nVh(0,p,2,3,"cue-card",1)(1,a,1,1,"ng-container",2),l.DNE(2,M,5,0,"ng-template",null,0,l.C5r)),2&U&&l.vxM("none"!==B.variant()?0:1)},dependencies:[s.Z,F.T3],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;box-sizing:border-box;border-radius:var(--cue-card-border-radius);border:1px solid var(--cue-card-border-color);background-color:var(--cue-default);color:var(--cue-defaultContrast);overflow:hidden}.tabs-header[_ngcontent-%COMP%]{display:flex;border-bottom:1px solid var(--cue-card-border-color);background-color:var(--background-color, var(--cue-default))}.tab-button[_ngcontent-%COMP%]{padding:10px 16px;background:none;border:none;border-bottom:2px solid transparent;cursor:pointer;color:inherit;font-family:var(--cue-font-family);font-size:var(--cue-font-s-size);line-height:var(--cue-font-s-line-height);opacity:.6;transition:opacity .15s,border-bottom-color .15s}.tab-button[_ngcontent-%COMP%]:hover{opacity:.9}.tab-button.active[_ngcontent-%COMP%]{border-bottom-color:currentColor;opacity:1;font-weight:500}.tabs-content[_ngcontent-%COMP%]{padding:var(--cue-card-padding-y) var(--cue-card-padding-x);flex:1;min-height:0;box-sizing:border-box;display:flex;flex-direction:column}"]})}return k})()},6170(se,Q,u){"use strict";u.d(Q,{R:()=>s});var S=u(7705),m=u(5802),O=u(2271),z=u(5547);let s=(()=>{class F{destroyRef=(0,m.WQX)(m.abz);_isDarkMode=(0,m.vPA)(this.hasDarkClass());isDarkMode=(0,O.EW)(()=>this._isDarkMode());darkModeChange=(0,S.CGW)();constructor(){const R=new MutationObserver(P=>{P.forEach(p=>{if("attributes"===p.type&&"class"===p.attributeName){const a=this.hasDarkClass();a!==this._isDarkMode()&&this._isDarkMode.set(a)}})});R.observe(document.body,{attributes:!0,attributeFilter:["class"]}),this.destroyRef.onDestroy(()=>R.disconnect()),(0,m.QZP)(()=>{this.darkModeChange.emit(this._isDarkMode()),document.documentElement.style.colorScheme=this._isDarkMode()?"dark":"light"})}hasDarkClass(){return document.body.classList.contains("dark")}toggleDarkMode(){document.body.classList.toggle("dark")}static \u0275fac=function(P){return new(P||F)};static \u0275dir=z.FsC({type:F,selectors:[["","cueDarkMode",""]],outputs:{darkModeChange:"darkModeChange"},exportAs:["darkModeDetector"]})}return F})()},7335(se,Q,u){"use strict";u.d(Q,{e:()=>R});var S=u(7705),m=u(5802),O=u(5547),z=u(8359),s=u(6939),F=u(63),l=u(4853);let R=(()=>{class P{_targetEl=(0,m.WQX)(O.aKT);_overlay=(0,m.WQX)(F.hJ);_overlayRef;_isOverlayHovered=!1;_subscriptions;display=(0,S.hFB)("on-hover");menuItems=S.hFB.required();menuEnabled=(0,S.hFB)(!0);onMouseEnter(){if("on-hover"===this.display()){if(!this.menuItems().length)return void this.removeOverlayMenu();this.appendOverlayMenu()}}onMouseLeave(){this._checkShouldRemoveOverlay()}appendOverlayMenu(){if(!this.menuItems().length||this._overlayRef)return;const a=this._overlay.create({positionStrategy:this._overlay.position().flexibleConnectedTo(this._targetEl).withPositions([{originX:"end",originY:"center",overlayX:"start",overlayY:"center",offsetX:2,offsetY:0}])});this._overlayRef=a;const g=window.getComputedStyle(this._targetEl.nativeElement).color;a.overlayElement.style.color=g;const M=new s.A8(l.H),D=a.attach(M);D.instance.items=this.menuItems,this._subscriptions&&this._subscriptions.unsubscribe(),this._subscriptions=new z.yU,this._subscriptions.add(D.instance.mouseEnter.subscribe(()=>{this._isOverlayHovered=!0})),this._subscriptions.add(D.instance.mouseLeave.subscribe(()=>{this._isOverlayHovered=!1,this._checkShouldRemoveOverlay()}))}removeOverlayMenu(){this._overlayRef&&(this._subscriptions&&(this._subscriptions.unsubscribe(),this._subscriptions=void 0),this._overlayRef.detach(),this._overlayRef.dispose(),this._overlayRef=void 0)}_checkShouldRemoveOverlay(){setTimeout(()=>{this._isOverlayHovered||this.removeOverlayMenu()},300)}static \u0275fac=function(g){return new(g||P)};static \u0275dir=O.FsC({type:P,selectors:[["","cueEntityMenu",""]],hostBindings:function(g,M){1&g&&O.bIt("mouseenter",function(){return M.onMouseEnter()})("mouseleave",function(){return M.onMouseLeave()})},inputs:{display:[1,"display"],menuItems:[1,"menuItems"],menuEnabled:[1,"menuEnabled"]}})}return P})()},140(se,Q,u){"use strict";u.d(Q,{o:()=>S});class S{type="FeatureCollection";features=[];bbox;id;constructor(O=[]){this.features=O}addFeature(O){this.features.push(O)}removeFeature(O){return this.features.splice(O,1)[0]}getFeatureCount(){return this.features.length}clear(){this.features=[]}}},58(se,Q,u){"use strict";function S(a){let g=0,M=-1,D=-1;for(let k=0;k<a.length;k++)if("("===a[k])g++,1===g&&(M=k+1);else if(")"===a[k]&&(g--,0===g)){D=k;break}return-1!==M&&-1!==D?a.substring(M,D):null}u.d(Q,{S:()=>P,n:()=>p});class m{x;y;z;constructor(g,M,D){this.x=g,this.y=M,this.z=D}}class O{points;constructor(g){this.points=g}}class z{lines;constructor(g){this.lines=g}}function P(a){if(a){if((a=a.trim().toUpperCase()).startsWith("POINT"))return function F(a){a=a.trim().toUpperCase();const M=S(a)?.split(" ")??[];return a.includes("POINT Z")?new m(parseFloat(M[0]),parseFloat(M[1]),parseFloat(M[2])):new m(parseFloat(M[0]),parseFloat(M[1]))}(a);if(a.startsWith("LINESTRING"))return function s(a){const g=S(a=a.trim().toUpperCase()),M=[];return g?.split(",").map(D=>D.trim().split(" ").map(k=>parseFloat(k))).map(D=>{M.push(new m(D[0],D[1],D[2]))}),new O(M)}(a);if(a.startsWith("POLYGON"))return function l(a){const g=S(a=a.trim().toUpperCase());if(!g)return new z([]);const M=g.match(/\(([^)]+)\)/g);if(!M)return new z([]);const D=M.map(k=>{const b=S(k);return b?b.split(",").map(A=>{const U=A.trim().split(" ");return U.length>=3?new m(parseFloat(U[0]),parseFloat(U[1]),parseFloat(U[2])):new m(parseFloat(U[0]),parseFloat(U[1]))}):[]});return new z(D)}(a)}}function p(a){if(a instanceof m)return{type:"Point",coordinates:void 0!==a.z?[a.x,a.y,a.z]:[a.x,a.y]};if(a instanceof O)return{type:"LineString",coordinates:a.points.map(g=>void 0!==g.z?[g.x,g.y,g.z]:[g.x,g.y])};if(a instanceof z)return{type:"Polygon",coordinates:a.lines.map(g=>g.map(M=>void 0!==M.z?[M.x,M.y,M.z]:[M.x,M.y]))};throw new Error("Unknown WKT type")}},362(se){"use strict";se.exports=function Q(u,S){if(u===S)return!0;if(u&&S&&"object"==typeof u&&"object"==typeof S){if(u.constructor!==S.constructor)return!1;var m,O,z;if(Array.isArray(u)){if((m=u.length)!=S.length)return!1;for(O=m;0!==O--;)if(!Q(u[O],S[O]))return!1;return!0}if(u.constructor===RegExp)return u.source===S.source&&u.flags===S.flags;if(u.valueOf!==Object.prototype.valueOf)return u.valueOf()===S.valueOf();if(u.toString!==Object.prototype.toString)return u.toString()===S.toString();if((m=(z=Object.keys(u)).length)!==Object.keys(S).length)return!1;for(O=m;0!==O--;)if(!Object.prototype.hasOwnProperty.call(S,z[O]))return!1;for(O=m;0!==O--;){var s=z[O];if(!Q(u[s],S[s]))return!1}return!0}return u!=u&&S!=S}},5332(se,Q,u){"use strict";u.d(Q,{k:()=>z});for(var m=[],O=0;O<256;++O)m.push((O+256).toString(16).slice(1));function z(l,R=0){return(m[l[R+0]]+m[l[R+1]]+m[l[R+2]]+m[l[R+3]]+"-"+m[l[R+4]]+m[l[R+5]]+"-"+m[l[R+6]]+m[l[R+7]]+"-"+m[l[R+8]]+m[l[R+9]]+"-"+m[l[R+10]]+m[l[R+11]]+m[l[R+12]]+m[l[R+13]]+m[l[R+14]]+m[l[R+15]]).toLowerCase()}},8402(se,Q,u){"use strict";u.d(Q,{A:()=>R});const m={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};var O,z=new Uint8Array(16);function s(){if(!O&&!(O=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return O(z)}var F=u(5332);const R=function l(P,p,a){if(m.randomUUID&&!p&&!P)return m.randomUUID();var g=(P=P||{}).random||(P.rng||s)();if(g[6]=15&g[6]|64,g[8]=63&g[8]|128,p){a=a||0;for(var M=0;M<16;++M)p[a+M]=g[M];return p}return(0,F.k)(g)}},6119(se){se.exports.RADIUS=6378137,se.exports.FLATTENING=1/298.257223563,se.exports.POLAR_RADIUS=6356752.3142}}]);
|
|
1
|
+
(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[872],{503(ae,Q,u){var I=u(6119);function x(D){var l=0;if(D&&D.length>0){l+=Math.abs(z(D[0]));for(var R=1;R<D.length;R++)l-=Math.abs(z(D[R]))}return l}function z(D){var l,R,g,a,p,M,O=0,B=D.length;if(B>2){for(M=0;M<B;M++)M===B-2?(g=B-2,a=B-1,p=0):M===B-1?(g=B-1,a=0,p=1):(g=M,a=M+1,p=M+2),l=D[g],R=D[a],O+=(s(D[p][0])-s(l[0]))*Math.sin(s(R[1]));O=O*I.RADIUS*I.RADIUS/2}return O}function s(D){return D*Math.PI/180}ae.exports.geometry=function y(D){var R,l=0;switch(D.type){case"Polygon":return x(D.coordinates);case"MultiPolygon":for(R=0;R<D.coordinates.length;R++)l+=x(D.coordinates[R]);return l;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(R=0;R<D.geometries.length;R++)l+=y(D.geometries[R]);return l}},ae.exports.ring=z},5341(ae){ae.exports=function u(I){if(!I||!I.type)return null;var y=Q[I.type];return y?"geometry"===y?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:I}]}:"feature"===y?{type:"FeatureCollection",features:[I]}:"featurecollection"===y?I:void 0:null};var Q={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"}},6756(ae,Q,u){"use strict";u.d(Q,{BK:()=>I,In:()=>P,Kz:()=>g,Mc:()=>p,U6:()=>x,g0:()=>M,g8:()=>z,r:()=>y,u9:()=>D});const I=["#2B5DE6","#1A2B50","#C5E045","#6FA8FF","#00C2E0","#5847EB","#008585","#4ADE80","#0F4C81","#8B5CF6","#FACC15","#FB923C","#F43F5E","#E879F9","#D97706","#334155","#64748B","#94A3B8","#C7D2FE","#F8FAFC"];function y(b){switch(b){case"primary":default:return"#2859e1";case"accent":return"#e2f552";case"tertiary":return"#ffffff"}}function x(b){switch(b){case"primary":default:return"#1744c2";case"accent":return"#b8cc3f";case"tertiary":return"#eeeeee"}}function z(b){const[w,U,k]=function s(b,w){if(void 0===b)return[];const k=window.getComputedStyle(b.nativeElement);return w.map(X=>k.getPropertyValue(X).trim()||"")}(b,["--cue-chart-text-color","--cue-chart-border-background-color","--chart-graph-edge-color"]);return{text:w,borderBackground:U,edgeColor:k}}const D={fontFamily:"Poppins, sans-serif",fontWeight:"normal",color:"#333"};function P(b){return b>=1e6?`${(b/1e6).toFixed(1)}m`:b>=1e3?`${(b/1e3).toFixed(0)}k`:b.toString()}function g(b,w,U,k){if(1===k)return b;const X=O(b),h=O(w),C=U/(k-1);return`rgb(${Math.round(X.r+(h.r-X.r)*C)}, ${Math.round(X.g+(h.g-X.g)*C)}, ${Math.round(X.b+(h.b-X.b)*C)})`}const p=(b,w)=>void 0===w?b:w.children??[];function M(b,w,U=.05,k="Other"){const X=b.reduce((F,L)=>F+B(L),0),h=[],C=[];if(b.forEach(F=>{let L,A;L=void 0===F.value&&Array.isArray(F.children)&&F.children.length>0?F.children.reduce((Z,J)=>Z+B(J),0):void 0!==F.value?F.value:0,Array.isArray(F.children)&&F.children.length>0&&(A=M(F.children,w,U,k));const W={...F,value:L,children:A};w&&X>0&&L/X<U?C.push(W):h.push(W)}),w&&C.length>0){const F=C.reduce((L,A)=>L+A.value,0);h.push({id:"__grouped_small__",name:k,value:F,children:C,isGroup:!0})}return h}function O(b){const w=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(b);return w?{r:parseInt(w[1],16),g:parseInt(w[2],16),b:parseInt(w[3],16)}:{r:0,g:0,b:0}}function B(b){return"number"==typeof b.value?b.value:Array.isArray(b.children)&&b.children.length>0?b.children.reduce((w,U)=>w+B(U),0):0}},4853(ae,Q,u){"use strict";u.d(Q,{H:()=>b});var I=u(7705),y=u(5802),x=u(7089),z=u(7023),s=u(5381),D=u(5971),l=u(3319),R=u(356),P=u(6279),g=u(5547);const a=()=>({position:"bottomleft"}),p=(w,U)=>U.label||w;function M(w,U){if(1&w){const k=g.RV6();g.j41(0,"cue-menu-item",4),g.bIt("click",function(){const h=y.eBV(k).$implicit;return y.Njj(h.action())}),g.EFF(1),g.k0s()}if(2&w){const k=U.$implicit;g.Y8G("selected",k.selected),g.R7$(),g.JRh(k.label)}}function O(w,U){if(1&w&&(g.j41(0,"cue-menu-wrap"),g.Z7z(1,M,2,2,"cue-menu-item",3,p),g.k0s()),2&w){const k=g.XpG();g.R7$(),g.Dyx(k.contextMenuItems())}}function B(w,U){if(1&w){const k=g.RV6();g.j41(0,"cue-button",5),g.bIt("click",function(h){const C=y.eBV(k).$implicit,F=g.XpG();return y.Njj(F.handleClick(h,C))}),g.nrm(1,"cue-button-icon",6),g.k0s()}if(2&w){const k=U.$implicit,X=g.XpG(),h=g.sdS(1);g.Y8G("cueTooltip",k.label)("variant",k.variant?k.variant:X.variant())("size",X.size())("cueContextMenu",h)("contextMenuData",g.lJ4(7,a))("cueContextEnabled",void 0!==k.contextMenuItems&&k.contextMenuItems.length>0),g.R7$(),g.Y8G("icon",k.icon)}}let b=(()=>{class w{items=I.hFB.required();noGap=(0,I.hFB)(!0);direction=(0,I.hFB)("row");size=(0,I.hFB)("xs");variant=(0,I.hFB)("tertiary");mouseEnter=(0,I.CGW)();mouseLeave=(0,I.CGW)();contextMenuItems=(0,y.vPA)([]);handleClick(k,X){k.stopPropagation(),X.contextMenuItems&&X.contextMenuItems.length>0?this.contextMenuItems.set(X.contextMenuItems):X.action&&(this.contextMenuItems.set([]),X.action())}static \u0275fac=function(X){return new(X||w)};static \u0275cmp=g.VBU({type:w,selectors:[["cue-entity-menu"]],inputs:{items:[1,"items"],noGap:[1,"noGap"],direction:[1,"direction"],size:[1,"size"],variant:[1,"variant"]},outputs:{mouseEnter:"mouseEnter",mouseLeave:"mouseLeave"},decls:5,vars:2,consts:[["contextMenu",""],["gap","s","justify","end",2,"width","100%",3,"mouseenter","mouseleave","direction","noGap"],["trigger","leftclick",3,"cueTooltip","variant","size","cueContextMenu","contextMenuData","cueContextEnabled"],[3,"selected"],[3,"click","selected"],["trigger","leftclick",3,"click","cueTooltip","variant","size","cueContextMenu","contextMenuData","cueContextEnabled"],[3,"icon"]],template:function(X,h){1&X&&(g.DNE(0,O,3,0,"ng-template",null,0,g.C5r),g.j41(2,"cue-flexcontainer",1),g.bIt("mouseenter",function(){return h.mouseEnter.emit()})("mouseleave",function(){return h.mouseLeave.emit()}),g.Z7z(3,B,2,8,"cue-button",2,p),g.k0s()),2&X&&(g.R7$(2),g.Y8G("direction",h.direction())("noGap",h.noGap()),g.R7$(),g.Dyx(h.items()))},dependencies:[s.n,D.$,x.d,l.a,z.Q,R.M,P.D],encapsulation:2,changeDetection:0})}return w})()},1024(ae,Q,u){"use strict";u.d(Q,{p:()=>x});var I=u(5547);const y=["*"];let x=(()=>{class z{static \u0275fac=function(l){return new(l||z)};static \u0275cmp=I.VBU({type:z,selectors:[["cue-key-val-list"]],ngContentSelectors:y,decls:2,vars:0,consts:[[1,"key-val-list"]],template:function(l,R){1&l&&(I.NAR(),I.rj2(0,"div",0),I.SdG(1),I.eux())},styles:[".key-val-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:var(--cue-grid-gap-s)}"]})}return z})()},9421(ae,Q,u){"use strict";u.d(Q,{F:()=>l});var I=u(7705),y=u(5802),x=u(2271),z=u(7335),s=u(2245),D=u(5547);let l=(()=>{class R{entityMenuDirective;size=(0,I.hFB)("m");key=I.hFB.required();val=I.geq.required();options=(0,I.hFB)([]);suffix=(0,I.hFB)("");valueChange=(0,I.CGW)();editModeEnabled=(0,y.vPA)(!1);valueChanged=(0,x.EW)(()=>this.val()!==this.newValue());newValue=(0,x.uu)(()=>this.val());labelSize=(0,x.EW)(()=>{switch(this.size()){case"s":return"xs";case"m":return"s";case"l":return"m";case"xl":return"l"}});onKeyPress(g){this.editModeEnabled()&&("Escape"===g.key?(this._reset(),g.stopPropagation()):"Enter"===g.key&&this._emitChange())}saveCancelMenu=(0,x.EW)(()=>{const g=[{icon:"close",label:"Cancel",action:()=>this._reset()}];return this.valueChanged()&&g.push({icon:"save",label:"Save",action:()=>this._emitChange()}),g});selectionChange(g){this.newValue.set(g?.toString()??"")}inputChange(g){this.newValue.set(g)}_emitChange(){this.valueChange.emit(this.newValue()),this.val.set(this.newValue()),this.editModeEnabled.set(!1)}_reset(){this.newValue.set(this.val()),this.editModeEnabled.set(!1)}static \u0275fac=function(a){return new(a||R)};static \u0275cmp=D.VBU({type:R,selectors:[["cue-key-val"]],viewQuery:function(a,p){if(1&a&&D.GBs(z.e,5),2&a){let M;D.mGM(M=D.lsd())&&(p.entityMenuDirective=M.first)}},hostBindings:function(a,p){1&a&&D.bIt("keydown",function(O){return p.onKeyPress(O)},D.EBC)},inputs:{size:[1,"size"],key:[1,"key"],val:[1,"val"],options:[1,"options"],suffix:[1,"suffix"]},outputs:{val:"valChange",valueChange:"valueChange"},decls:8,vars:5,consts:[[1,"key-val-container"],[3,"size"],[1,"value-content"]],template:function(a,p){1&a&&(D.j41(0,"dl",0)(1,"dt")(2,"cue-typography",1),D.EFF(3),D.k0s()(),D.j41(4,"dd")(5,"cue-typography",1)(6,"span",2),D.EFF(7),D.k0s()()()()),2&a&&(D.R7$(2),D.Y8G("size",p.labelSize()),D.R7$(),D.JRh(p.key()),D.R7$(2),D.Y8G("size",p.size()),D.R7$(2),D.Lme("",p.val()," ",p.suffix()))},dependencies:[s.Typography],styles:[".key-val-container[_ngcontent-%COMP%]{margin:0;display:flex;flex-direction:column;gap:var(--cue-grid-gap-s, 8px)}dt[_ngcontent-%COMP%], dd[_ngcontent-%COMP%]{margin:0}.read-mode-container[_ngcontent-%COMP%]{display:inline-flex;align-items:center;width:100%;position:relative}.read-mode-container.interactive[_ngcontent-%COMP%]:hover{cursor:pointer}.value-content[_ngcontent-%COMP%]{flex:1}[_nghost-%COMP%]{color:var(--cue-typography-text-color, inherit)}dt[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%], dd[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%], .value-content[_ngcontent-%COMP%]{color:var(--cue-typography-text-color, inherit)!important}dt[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%] div[_ngcontent-%COMP%], dd[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%] div[_ngcontent-%COMP%]{color:var(--cue-typography-text-color, inherit)!important}[_ngcontent-%COMP%]:deep(cue-svg-icon), [_ngcontent-%COMP%]:deep(cue-entity-menu cue-svg-icon){color:var(--cue-icon-color, inherit)!important}.dirty-indicator[_ngcontent-%COMP%]{opacity:.8;margin-left:4px;color:var(--cue-typography-text-color, inherit)!important;font-weight:700;font-size:.4em;transform:translateY(-1em)}"]})}return R})()},7517(ae,Q,u){"use strict";u.d(Q,{P:()=>M});var I=u(7705),y=u(2271),x=u(2245),z=u(1359),s=u(5381),D=u(5802),l=u(5547);const R=(O,B)=>B.category;function P(O,B){if(1&O){const b=l.RV6();l.j41(0,"cue-flexcontainer",1)(1,"cue-checkbox",2),l.bIt("checkedChange",function(){D.eBV(b);const U=l.XpG();return D.Njj(U.toggleAll())}),l.k0s()()}if(2&O){const b=l.XpG();l.R7$(),l.Y8G("checked",b.allVisible())}}function g(O,B){if(1&O&&(l.j41(0,"cue-typography",3),l.EFF(1),l.k0s()),2&O){const b=l.XpG().$implicit;l.R7$(),l.JRh(b.category)}}function a(O,B){if(1&O){const b=l.RV6();l.j41(0,"cue-flexcontainer",1)(1,"cue-checkbox",4),l.bIt("checkedChange",function(){const U=D.eBV(b).$implicit,k=l.XpG(2);return D.Njj(k.toggleSingle(U))}),l.k0s(),l.j41(2,"cue-typography",5),l.bIt("click",function(){const U=D.eBV(b).$implicit,k=l.XpG(2);return D.Njj(k.toggleSingle(U))}),l.EFF(3),l.k0s()()}if(2&O){const b=B.$implicit;l.R7$(),l.Y8G("checked",b.visible)("color",b.color),l.R7$(2),l.JRh(b.label)}}function p(O,B){if(1&O&&(l.nVh(0,g,2,1,"cue-typography",3),l.Z7z(1,a,4,3,"cue-flexcontainer",1,l.Vm6)),2&O){const b=B.$implicit;l.vxM(b.category?0:-1),l.R7$(),l.Dyx(b.items)}}let M=(()=>{class O{layers=(0,I.geq)([]);visibilityChange=(0,I.CGW)();layerChange=(0,I.CGW)();visibilityAll=(0,I.CGW)();showCheckAll=(0,y.EW)(()=>this.layers().length>1);allVisible=(0,y.EW)(()=>this.layers().every(b=>b.visible));groupedLayers=(0,y.EW)(()=>{const b=[];for(const w of this.layers()){const U=w.category,k=b.find(X=>X.category===U);k?k.items.push(w):b.push({category:U,items:[w]})}return b});toggleAll(){const b=this.allVisible(),w=this.layers().map(U=>(U.visible=!b,U));this.layers.update(()=>[...w]),this.visibilityAll.emit(b),this.emitChange()}toggleSingle(b){b.visible=!b.visible,this.layerChange.emit(b),this.layers.update(()=>[...this.layers()]),this.emitChange()}emitChange(){this.visibilityChange.emit(this.layers())}static \u0275fac=function(w){return new(w||O)};static \u0275cmp=l.VBU({type:O,selectors:[["cue-layer-legend"]],inputs:{layers:[1,"layers"]},outputs:{layers:"layersChange",visibilityChange:"visibilityChange",layerChange:"layerChange",visibilityAll:"visibilityAll"},decls:4,vars:1,consts:[["direction","column"],["align","center","justify","start",2,"width","100%"],["size","s",3,"checkedChange","checked"],["variant","label",2,"margin-top","4px","opacity","0.6"],["size","s",3,"checkedChange","checked","color"],[2,"cursor","pointer",3,"click"]],template:function(w,U){1&w&&(l.j41(0,"cue-flexcontainer",0),l.nVh(1,P,2,1,"cue-flexcontainer",1),l.Z7z(2,p,3,1,null,null,R),l.k0s()),2&w&&(l.R7$(),l.vxM(U.showCheckAll()?1:-1),l.R7$(),l.Dyx(U.groupedLayers()))},dependencies:[s.n,x.Typography,z.S],encapsulation:2,changeDetection:0})}return O})()},2843(ae,Q,u){"use strict";u.d(Q,{M:()=>Wn});var I={};u.r(I),u.d(I,{LAT_MAX:()=>U,LAT_MIN:()=>b,LAT_RENDERED_MAX:()=>k,LAT_RENDERED_MIN:()=>w,LNG_MAX:()=>h,LNG_MIN:()=>X,activeStates:()=>O,classes:()=>s,cursors:()=>l,events:()=>a,geojsonTypes:()=>P,interactions:()=>B,meta:()=>M,modes:()=>g,sources:()=>D,types:()=>R,updateActions:()=>p});var y={};u.r(y),u.d(y,{isActiveFeature:()=>L,isBackspaceKey:()=>he,isDeleteKey:()=>me,isDigit1Key:()=>ne,isDigit2Key:()=>ze,isDigit3Key:()=>De,isDigitKey:()=>ve,isEnterKey:()=>fe,isEscapeKey:()=>ye,isFeature:()=>Z,isInactiveFeature:()=>A,isOfMetaType:()=>C,isShiftDown:()=>oe,isShiftMousedown:()=>F,isTrue:()=>ct,isVertex:()=>J,noTarget:()=>W});var x={};u.r(x),u.d(x,{CommonSelectors:()=>y,ModeHandler:()=>nt,StringSet:()=>Ae,constrainFeatureMovement:()=>At,createMidPoint:()=>nn,createSupplementaryPoints:()=>wt,createVertex:()=>Ze,doubleClickZoom:()=>Ie,euclideanDistance:()=>qe,featuresAt:()=>Be,getFeatureAtAndSetCursors:()=>Xe,isClick:()=>et,isEventAtCoordinates:()=>mt,isTap:()=>tt,mapEventToBoundingBox:()=>He,moveFeatures:()=>Nt,sortFeatures:()=>dt,stringSetsAreEqual:()=>pn,theme:()=>Gt,toDenseArray:()=>pe});var z=u(5802);const s={CANVAS:"mapboxgl-canvas",CONTROL_BASE:"mapboxgl-ctrl",CONTROL_PREFIX:"mapboxgl-ctrl-",CONTROL_BUTTON:"mapbox-gl-draw_ctrl-draw-btn",CONTROL_BUTTON_LINE:"mapbox-gl-draw_line",CONTROL_BUTTON_POLYGON:"mapbox-gl-draw_polygon",CONTROL_BUTTON_POINT:"mapbox-gl-draw_point",CONTROL_BUTTON_TRASH:"mapbox-gl-draw_trash",CONTROL_BUTTON_COMBINE_FEATURES:"mapbox-gl-draw_combine",CONTROL_BUTTON_UNCOMBINE_FEATURES:"mapbox-gl-draw_uncombine",CONTROL_GROUP:"mapboxgl-ctrl-group",ATTRIBUTION:"mapboxgl-ctrl-attrib",ACTIVE_BUTTON:"active",BOX_SELECT:"mapbox-gl-draw_boxselect"},D={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},l={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},R={POLYGON:"polygon",LINE:"line_string",POINT:"point"},P={FEATURE:"Feature",POLYGON:"Polygon",LINE_STRING:"LineString",POINT:"Point",FEATURE_COLLECTION:"FeatureCollection",MULTI_PREFIX:"Multi",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon"},g={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select"},a={CREATE:"draw.create",DELETE:"draw.delete",UPDATE:"draw.update",SELECTION_CHANGE:"draw.selectionchange",MODE_CHANGE:"draw.modechange",ACTIONABLE:"draw.actionable",RENDER:"draw.render",COMBINE_FEATURES:"draw.combine",UNCOMBINE_FEATURES:"draw.uncombine"},p={MOVE:"move",CHANGE_PROPERTIES:"change_properties",CHANGE_COORDINATES:"change_coordinates"},M={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},O={ACTIVE:"true",INACTIVE:"false"},B=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],b=-90,w=-85,U=90,k=85,X=-270,h=270;function C(e){return function(t){const n=t.featureTarget;return!(!n||!n.properties)&&n.properties.meta===e}}function F(e){return!(!e.originalEvent||!e.originalEvent.shiftKey)&&0===e.originalEvent.button}function L(e){return!(!e.featureTarget||!e.featureTarget.properties)&&e.featureTarget.properties.active===O.ACTIVE&&e.featureTarget.properties.meta===M.FEATURE}function A(e){return!(!e.featureTarget||!e.featureTarget.properties)&&e.featureTarget.properties.active===O.INACTIVE&&e.featureTarget.properties.meta===M.FEATURE}function W(e){return void 0===e.featureTarget}function Z(e){return!(!e.featureTarget||!e.featureTarget.properties)&&e.featureTarget.properties.meta===M.FEATURE}function J(e){const t=e.featureTarget;return!(!t||!t.properties)&&t.properties.meta===M.VERTEX}function oe(e){return!!e.originalEvent&&!0===e.originalEvent.shiftKey}function ye(e){return"Escape"===e.key||27===e.keyCode}function fe(e){return"Enter"===e.key||13===e.keyCode}function he(e){return"Backspace"===e.key||8===e.keyCode}function me(e){return"Delete"===e.key||46===e.keyCode}function ne(e){return"1"===e.key||49===e.keyCode}function ze(e){return"2"===e.key||50===e.keyCode}function De(e){return"3"===e.key||51===e.keyCode}function ve(e){const t=e.key||String.fromCharCode(e.keyCode);return t>="0"&&t<="9"}function ct(){return!0}var Ke=u(503);const we={Point:0,LineString:1,MultiLineString:1,Polygon:2};function ut(e,t){const n=we[e.geometry.type]-we[t.geometry.type];return 0===n&&e.geometry.type===P.POLYGON?e.area-t.area:n}const dt=function _t(e){return e.map(t=>(t.geometry.type===P.POLYGON&&(t.area=Ke.geometry({type:P.FEATURE,property:{},geometry:t.geometry})),t)).sort(ut).map(t=>(delete t.area,t))},He=function je(e,t=0){return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]};function Re(e){if(this._items={},this._nums={},this._length=e?e.length:0,e)for(let t=0,n=e.length;t<n;t++)this.add(e[t]),void 0!==e[t]&&("string"==typeof e[t]?this._items[e[t]]=t:this._nums[e[t]]=t)}Re.prototype.add=function(e){return this.has(e)||(this._length++,"string"==typeof e?this._items[e]=this._length:this._nums[e]=this._length),this},Re.prototype.delete=function(e){return!1===this.has(e)||(this._length--,delete this._items[e],delete this._nums[e]),this},Re.prototype.has=function(e){return!("string"!=typeof e&&"number"!=typeof e||void 0===this._items[e]&&void 0===this._nums[e])},Re.prototype.values=function(){const e=[];return Object.keys(this._items).forEach(t=>{e.push({k:t,v:this._items[t]})}),Object.keys(this._nums).forEach(t=>{e.push({k:JSON.parse(t),v:this._nums[t]})}),e.sort((t,n)=>t.v-n.v).map(t=>t.k)},Re.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const Ae=Re,Qe=[M.FEATURE,M.MIDPOINT,M.VERTEX],Be={click:function vt(e,t,n){return ft(e,t,n,n.options.clickBuffer)},touch:function bt(e,t,n){return ft(e,t,n,n.options.touchBuffer)}};function ft(e,t,n,o){if(null===n.map)return[];const r=e?He(e,o):t,i={};n.options.styles&&(i.layers=n.options.styles.map(N=>N.id).filter(N=>null!=n.map.getLayer(N)));const f=n.map.queryRenderedFeatures(r,i).filter(N=>-1!==Qe.indexOf(N.properties.meta)),E=new Ae,m=[];return f.forEach(N=>{const K=N.properties.id;E.has(K)||(E.add(K),m.push(N))}),dt(m)}function Xe(e,t){const n=Be.click(e,null,t),o={mouse:l.NONE};return n[0]&&(o.mouse=n[0].properties.active===O.ACTIVE?l.MOVE:l.POINTER,o.feature=n[0].properties.meta),-1!==t.events.currentModeName().indexOf("draw")&&(o.mouse=l.ADD),t.ui.queueMapClasses(o),t.ui.updateMapClasses(),n[0]}function qe(e,t){const n=e.x-t.x,o=e.y-t.y;return Math.sqrt(n*n+o*o)}function et(e,t,n={}){const o=null!=n.fineTolerance?n.fineTolerance:4,r=null!=n.grossTolerance?n.grossTolerance:12,i=null!=n.interval?n.interval:500;e.point=e.point||t.point,e.time=e.time||t.time;const f=qe(e.point,t.point);return f<o||f<r&&t.time-e.time<i}function tt(e,t,n={}){const o=null!=n.tolerance?n.tolerance:25,r=null!=n.interval?n.interval:250;return e.point=e.point||t.point,e.time=e.time||t.time,qe(e.point,t.point)<o&&t.time-e.time<r}const nt=function(e,t){const n={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},o={on(i,f,E){if(void 0===n[i])throw new Error(`Invalid event type: ${i}`);n[i].push({selector:f,fn:E})},render(i){t.store.featureChanged(i)}},r=function(i,f){const E=n[i];let m=E.length;for(;m--;){const N=E[m];if(N.selector(f)){N.fn.call(o,f)||t.store.render(),t.ui.updateMapClasses();break}}};return e.start.call(o),{render:e.render,stop(){e.stop&&e.stop()},trash(){e.trash&&(e.trash(),t.store.render())},combineFeatures(){e.combineFeatures&&e.combineFeatures()},uncombineFeatures(){e.uncombineFeatures&&e.uncombineFeatures()},drag(i){r("drag",i)},click(i){r("click",i)},mousemove(i){r("mousemove",i)},mousedown(i){r("mousedown",i)},mouseup(i){r("mouseup",i)},mouseout(i){r("mouseout",i)},keydown(i){r("keydown",i)},keyup(i){r("keyup",i)},touchstart(i){r("touchstart",i)},touchmove(i){r("touchmove",i)},touchend(i){r("touchend",i)},tap(i){r("tap",i)}}},S=((e,t=21)=>(n=t)=>{let o="",r=0|n;for(;r--;)o+=e[Math.random()*e.length|0];return o})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",32);function c(){return S()}const d=function(e,t){this.ctx=e,this.properties=t.properties||{},this.coordinates=t.geometry.coordinates,this.id=t.id||c(),this.type=t.geometry.type};d.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},d.prototype.incomingCoords=function(e){this.setCoordinates(e)},d.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},d.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},d.prototype.setProperty=function(e,t){this.properties[e]=t},d.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:P.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},d.prototype.internal=function(e){const t={id:this.id,meta:M.FEATURE,"meta:type":this.type,active:O.INACTIVE,mode:e};if(this.ctx.options.userProperties)for(const n in this.properties)t[`user_${n}`]=this.properties[n];return{type:P.FEATURE,properties:t,geometry:{coordinates:this.getCoordinates(),type:this.type}}};const v=d,V=function(e,t){v.call(this,e,t)};(V.prototype=Object.create(v.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},V.prototype.updateCoordinate=function(e,t,n){this.coordinates=3===arguments.length?[t,n]:[e,t],this.changed()},V.prototype.getCoordinate=function(){return this.getCoordinates()};const Y=V,q=function(e,t){v.call(this,e,t)};(q.prototype=Object.create(v.prototype)).isValid=function(){return this.coordinates.length>1},q.prototype.addCoordinate=function(e,t,n){this.changed();const o=parseInt(e,10);this.coordinates.splice(o,0,[t,n])},q.prototype.getCoordinate=function(e){const t=parseInt(e,10);return JSON.parse(JSON.stringify(this.coordinates[t]))},q.prototype.removeCoordinate=function(e){this.changed(),this.coordinates.splice(parseInt(e,10),1)},q.prototype.updateCoordinate=function(e,t,n){const o=parseInt(e,10);this.coordinates[o]=[t,n],this.changed()};const le=q,ge=function(e,t){v.call(this,e,t),this.coordinates=this.coordinates.map(n=>n.slice(0,-1))};(ge.prototype=Object.create(v.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every(e=>e.length>2)},ge.prototype.incomingCoords=function(e){this.coordinates=e.map(t=>t.slice(0,-1)),this.changed()},ge.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},ge.prototype.addCoordinate=function(e,t,n){this.changed();const o=e.split(".").map(i=>parseInt(i,10));this.coordinates[o[0]].splice(o[1],0,[t,n])},ge.prototype.removeCoordinate=function(e){this.changed();const t=e.split(".").map(o=>parseInt(o,10)),n=this.coordinates[t[0]];n&&(n.splice(t[1],1),n.length<3&&this.coordinates.splice(t[0],1))},ge.prototype.getCoordinate=function(e){const t=e.split(".").map(o=>parseInt(o,10));return JSON.parse(JSON.stringify(this.coordinates[t[0]][t[1]]))},ge.prototype.getCoordinates=function(){return this.coordinates.map(e=>e.concat([e[0]]))},ge.prototype.updateCoordinate=function(e,t,n){this.changed();const o=e.split("."),r=parseInt(o[0],10),i=parseInt(o[1],10);void 0===this.coordinates[r]&&(this.coordinates[r]=[]),this.coordinates[r][i]=[t,n]};const se=ge,de={MultiPoint:Y,MultiLineString:le,MultiPolygon:se},_e=(e,t,n,o,r)=>{const i=n.split("."),f=parseInt(i[0],10),E=i[1]?i.slice(1).join("."):null;return e[f][t](E,o,r)},Ee=function(e,t){if(v.call(this,e,t),delete this.coordinates,this.model=de[t.geometry.type],void 0===this.model)throw new TypeError(`${t.geometry.type} is not a valid type`);this.features=this._coordinatesToFeatures(t.geometry.coordinates)};(Ee.prototype=Object.create(v.prototype))._coordinatesToFeatures=function(e){const t=this.model.bind(this);return e.map(n=>new t(this.ctx,{id:c(),type:P.FEATURE,properties:{},geometry:{coordinates:n,type:this.type.replace("Multi","")}}))},Ee.prototype.isValid=function(){return this.features.every(e=>e.isValid())},Ee.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()},Ee.prototype.getCoordinate=function(e){return _e(this.features,"getCoordinate",e)},Ee.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(e=>e.type===P.POLYGON?e.getCoordinates():e.coordinates)))},Ee.prototype.updateCoordinate=function(e,t,n){_e(this.features,"updateCoordinate",e,t,n),this.changed()},Ee.prototype.addCoordinate=function(e,t,n){_e(this.features,"addCoordinate",e,t,n),this.changed()},Ee.prototype.removeCoordinate=function(e){_e(this.features,"removeCoordinate",e),this.changed()},Ee.prototype.getFeatures=function(){return this.features};const Ne=Ee;function H(e){this.map=e.map,this.drawConfig=JSON.parse(JSON.stringify(e.options||{})),this._ctx=e}H.prototype.setSelected=function(e){return this._ctx.store.setSelected(e)},H.prototype.setSelectedCoordinates=function(e){this._ctx.store.setSelectedCoordinates(e),e.reduce((t,n)=>(void 0===t[n.feature_id]&&(t[n.feature_id]=!0,this._ctx.store.get(n.feature_id).changed()),t),{})},H.prototype.getSelected=function(){return this._ctx.store.getSelected()},H.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},H.prototype.isSelected=function(e){return this._ctx.store.isSelected(e)},H.prototype.getFeature=function(e){return this._ctx.store.get(e)},H.prototype.select=function(e){return this._ctx.store.select(e)},H.prototype.deselect=function(e){return this._ctx.store.deselect(e)},H.prototype.deleteFeature=function(e,t={}){return this._ctx.store.delete(e,t)},H.prototype.addFeature=function(e,t={}){return this._ctx.store.add(e,t)},H.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},H.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},H.prototype.setActionableState=function(e={}){return this._ctx.events.actionable({trash:e.trash||!1,combineFeatures:e.combineFeatures||!1,uncombineFeatures:e.uncombineFeatures||!1})},H.prototype.changeMode=function(e,t={},n={}){return this._ctx.events.changeMode(e,t,n)},H.prototype.fire=function(e,t){return this._ctx.events.fire(e,t)},H.prototype.updateUIClasses=function(e){return this._ctx.ui.queueMapClasses(e)},H.prototype.activateUIButton=function(e){return this._ctx.ui.setActiveButton(e)},H.prototype.featuresAt=function(e,t,n="click"){if("click"!==n&&"touch"!==n)throw new Error("invalid buffer type");return Be[n](e,t,this._ctx)},H.prototype.newFeature=function(e){const t=e.geometry.type;return t===P.POINT?new Y(this._ctx,e):t===P.LINE_STRING?new le(this._ctx,e):t===P.POLYGON?new se(this._ctx,e):new Ne(this._ctx,e)},H.prototype.isInstanceOf=function(e,t){if(e===P.POINT)return t instanceof Y;if(e===P.LINE_STRING)return t instanceof le;if(e===P.POLYGON)return t instanceof se;if("MultiFeature"===e)return t instanceof Ne;throw new Error(`Unknown feature class: ${e}`)},H.prototype.doRender=function(e){return this._ctx.store.featureChanged(e)};const ee=H;H.prototype.onSetup=function(){},H.prototype.onDrag=function(){},H.prototype.onClick=function(){},H.prototype.onMouseMove=function(){},H.prototype.onMouseDown=function(){},H.prototype.onMouseUp=function(){},H.prototype.onMouseOut=function(){},H.prototype.onKeyUp=function(){},H.prototype.onKeyDown=function(){},H.prototype.onTouchStart=function(){},H.prototype.onTouchMove=function(){},H.prototype.onTouchEnd=function(){},H.prototype.onTap=function(){},H.prototype.onStop=function(){},H.prototype.onTrash=function(){},H.prototype.onCombineFeature=function(){},H.prototype.onUncombineFeature=function(){},H.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};const re={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},be=Object.keys(re);const pe=function Me(e){return[].concat(e).filter(t=>void 0!==t)};function ot(){const e=this;if(!e.ctx.map||void 0===e.ctx.map.getSource(D.HOT))return m();const n=e.ctx.events.currentModeName();e.ctx.ui.queueMapClasses({mode:n});let o=[],r=[];e.isDirty?r=e.getAllIds():(o=e.getChangedIds().filter(N=>void 0!==e.get(N)),r=e.sources.hot.filter(N=>N.properties.id&&-1===o.indexOf(N.properties.id)&&void 0!==e.get(N.properties.id)).map(N=>N.properties.id)),e.sources.hot=[];const i=e.sources.cold.length;e.sources.cold=e.isDirty?[]:e.sources.cold.filter(N=>-1===o.indexOf(N.properties.id||N.properties.parent));const f=i!==e.sources.cold.length||r.length>0;function E(N,K){const T=e.get(N).internal(n);e.ctx.events.currentModeRender(T,G=>{G.properties.mode=n,e.sources[K].push(G)})}function m(){e.isDirty=!1,e.clearChangedIds()}o.forEach(N=>E(N,"hot")),r.forEach(N=>E(N,"cold")),f&&e.ctx.map.getSource(D.COLD).setData({type:P.FEATURE_COLLECTION,features:e.sources.cold}),e.ctx.map.getSource(D.HOT).setData({type:P.FEATURE_COLLECTION,features:e.sources.hot}),m()}function ie(e){let t;this._features={},this._featureIds=new Ae,this._selectedFeatureIds=new Ae,this._selectedCoordinates=[],this._changedFeatureIds=new Ae,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]},this.render=()=>{t||(t=requestAnimationFrame(()=>{t=null,ot.call(this),this._emitSelectionChange&&(this.ctx.events.fire(a.SELECTION_CHANGE,{features:this.getSelected().map(n=>n.toGeoJSON()),points:this.getSelectedCoordinates().map(n=>({type:P.FEATURE,properties:{},geometry:{type:P.POINT,coordinates:n.coordinates}}))}),this._emitSelectionChange=!1),this.ctx.events.fire(a.RENDER,{})}))},this.isDirty=!1}function rt(e,t={}){const n=e._selectedCoordinates.filter(o=>e._selectedFeatureIds.has(o.feature_id));e._selectedCoordinates.length!==n.length&&!t.silent&&(e._emitSelectionChange=!0),e._selectedCoordinates=n}ie.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}},ie.prototype.setDirty=function(){return this.isDirty=!0,this},ie.prototype.featureCreated=function(e,t={}){if(this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)){const o=this.get(e);this.ctx.events.fire(a.CREATE,{features:[o.toGeoJSON()]})}return this},ie.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)&&this.ctx.events.fire(a.UPDATE,{action:t.action?t.action:p.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this},ie.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},ie.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},ie.prototype.getAllIds=function(){return this._featureIds.values()},ie.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this},ie.prototype.delete=function(e,t={}){const n=[];return pe(e).forEach(o=>{this._featureIds.has(o)&&(this._featureIds.delete(o),this._selectedFeatureIds.delete(o),t.silent||-1===n.indexOf(this._features[o])&&n.push(this._features[o].toGeoJSON()),delete this._features[o],this.isDirty=!0)}),n.length&&this.ctx.events.fire(a.DELETE,{features:n}),rt(this,t),this},ie.prototype.get=function(e){return this._features[e]},ie.prototype.getAll=function(){return Object.keys(this._features).map(e=>this._features[e])},ie.prototype.select=function(e,t={}){return pe(e).forEach(n=>{this._selectedFeatureIds.has(n)||(this._selectedFeatureIds.add(n),this._changedFeatureIds.add(n),t.silent||(this._emitSelectionChange=!0))}),this},ie.prototype.deselect=function(e,t={}){return pe(e).forEach(n=>{this._selectedFeatureIds.has(n)&&(this._selectedFeatureIds.delete(n),this._changedFeatureIds.add(n),t.silent||(this._emitSelectionChange=!0))}),rt(this,t),this},ie.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this},ie.prototype.setSelected=function(e,t={}){return e=pe(e),this.deselect(this._selectedFeatureIds.values().filter(n=>-1===e.indexOf(n)),{silent:t.silent}),this.select(e.filter(n=>!this._selectedFeatureIds.has(n)),{silent:t.silent}),this},ie.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this},ie.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},ie.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},ie.prototype.getSelected=function(){return this.getSelectedIds().map(e=>this.get(e))},ie.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map(t=>({coordinates:this.get(t.feature_id).getCoordinate(t.coord_path)}))},ie.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)},ie.prototype.setFeatureProperty=function(e,t,n,o={}){this.get(e).setProperty(t,n),this.featureChanged(e,{silent:o.silent,action:p.CHANGE_PROPERTIES})},ie.prototype.storeMapConfig=function(){B.forEach(e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())})},ie.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach(e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()})},ie.prototype.getInitialConfigValue=function(e){return void 0===this._mapInitialConfig[e]||this._mapInitialConfig[e]};const it=["mode","feature","mouse"];function Bt(e){let t=null,n=null;const o={onRemove(){return e.map.off("load",o.connect),clearInterval(n),o.removeLayers(),e.store.restoreMapConfig(),e.ui.removeButtons(),e.events.removeEventListeners(),e.ui.clearMapClasses(),e.boxZoomInitial&&e.map.boxZoom.enable(),e.map=null,e.container=null,e.store=null,t&&t.parentNode&&t.parentNode.removeChild(t),t=null,this},connect(){e.map.off("load",o.connect),clearInterval(n),o.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners()},onAdd(r){if(e.map=r,e.events=function ke(e){const t=Object.keys(e.options.modes).reduce((T,G)=>(T[G]=function Se(e){const t=Object.keys(e);return function(n,o={}){let r={};const i=t.reduce((E,m)=>(E[m]=e[m],E),new ee(n));return{start(){r=i.onSetup(o),be.forEach(E=>{const m=re[E];let N=()=>!1;e[m]&&(N=()=>!0),this.on(E,N,function f(E){return m=>i[E](r,m)}(m))})},stop(){i.onStop(r)},trash(){i.onTrash(r)},combineFeatures(){i.onCombineFeatures(r)},uncombineFeatures(){i.onUncombineFeatures(r)},render(E,m){i.toDisplayFeatures(r,E,m)}}}}(e.options.modes[G]),T),{});let n={},o={};const r={};let i=null,f=null;r.drag=function(T,G){G({point:T.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:l.DRAG}),f.drag(T)):T.originalEvent.stopPropagation()},r.mousedrag=function(T){r.drag(T,G=>!et(n,G))},r.touchdrag=function(T){r.drag(T,G=>!tt(o,G))},r.mousemove=function(T){if(1===(void 0!==T.originalEvent.buttons?T.originalEvent.buttons:T.originalEvent.which))return r.mousedrag(T);const $=Xe(T,e);T.featureTarget=$,f.mousemove(T)},r.mousedown=function(T){n={time:(new Date).getTime(),point:T.point};const G=Xe(T,e);T.featureTarget=G,f.mousedown(T)},r.mouseup=function(T){const G=Xe(T,e);T.featureTarget=G,et(n,{point:T.point,time:(new Date).getTime()})?f.click(T):f.mouseup(T)},r.mouseout=function(T){f.mouseout(T)},r.touchstart=function(T){if(!e.options.touchEnabled)return;o={time:(new Date).getTime(),point:T.point};const G=Be.touch(T,null,e)[0];T.featureTarget=G,f.touchstart(T)},r.touchmove=function(T){if(e.options.touchEnabled)return f.touchmove(T),r.touchdrag(T)},r.touchend=function(T){if(T.originalEvent.preventDefault(),!e.options.touchEnabled)return;const G=Be.touch(T,null,e)[0];T.featureTarget=G,tt(o,{time:(new Date).getTime(),point:T.point})?f.tap(T):f.touchend(T)};const E=T=>{const G=he(T),$=me(T),te=ve(T);return!(G||$||te)};function m(T,G,$={}){f.stop();const te=t[T];if(void 0===te)throw new Error(`${T} is not valid`);i=T;const Ce=te(e,G);f=nt(Ce,e),$.silent||e.map.fire(a.MODE_CHANGE,{mode:T}),e.store.setDirty(),e.store.render()}r.keydown=function(T){(T.srcElement||T.target).classList.contains(s.CANVAS)&&((he(T)||me(T))&&e.options.controls.trash?(T.preventDefault(),f.trash()):E(T)?f.keydown(T):ne(T)&&e.options.controls.point?m(g.DRAW_POINT):ze(T)&&e.options.controls.line_string?m(g.DRAW_LINE_STRING):De(T)&&e.options.controls.polygon&&m(g.DRAW_POLYGON))},r.keyup=function(T){E(T)&&f.keyup(T)},r.zoomend=function(){e.store.changeZoom()},r.data=function(T){if("style"===T.dataType){const{setup:G,map:$,options:te,store:Ce}=e;te.styles.some(Ve=>$.getLayer(Ve.id))||(G.addLayers(),Ce.setDirty(),Ce.render())}};const N={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start(){i=e.options.defaultMode,f=nt(t[i](e),e)},changeMode:m,actionable:function K(T){let G=!1;Object.keys(T).forEach($=>{if(void 0===N[$])throw new Error("Invalid action type");N[$]!==T[$]&&(G=!0),N[$]=T[$]}),G&&e.map.fire(a.ACTIONABLE,{actions:N})},currentModeName:()=>i,currentModeRender:(T,G)=>f.render(T,G),fire(T,G){e.map&&e.map.fire(T,G)},addEventListeners(){e.map.on("mousemove",r.mousemove),e.map.on("mousedown",r.mousedown),e.map.on("mouseup",r.mouseup),e.map.on("data",r.data),e.map.on("touchmove",r.touchmove),e.map.on("touchstart",r.touchstart),e.map.on("touchend",r.touchend),e.container.addEventListener("mouseout",r.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",r.keydown),e.container.addEventListener("keyup",r.keyup))},removeEventListeners(){e.map.off("mousemove",r.mousemove),e.map.off("mousedown",r.mousedown),e.map.off("mouseup",r.mouseup),e.map.off("data",r.data),e.map.off("touchmove",r.touchmove),e.map.off("touchstart",r.touchstart),e.map.off("touchend",r.touchend),e.container.removeEventListener("mouseout",r.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",r.keydown),e.container.removeEventListener("keyup",r.keyup))},trash(T){f.trash(T)},combineFeatures(){f.combineFeatures()},uncombineFeatures(){f.uncombineFeatures()},getMode:()=>i}}(e),e.ui=function It(e){const t={};let n=null,o={mode:null,feature:null,mouse:null},r={mode:null,feature:null,mouse:null};function f(G){r=Object.assign(r,G)}function E(){if(!e.container)return;const G=[],$=[];it.forEach(te=>{r[te]!==o[te]&&(G.push(`${te}-${o[te]}`),null!==r[te]&&$.push(`${te}-${r[te]}`))}),G.length>0&&e.container.classList.remove(...G),$.length>0&&e.container.classList.add(...$),o=Object.assign(o,r)}function m(G,$={}){const te=document.createElement("button");return te.className=`${s.CONTROL_BUTTON} ${$.className}`,te.setAttribute("title",$.title),$.container.appendChild(te),te.addEventListener("click",Ce=>{if(Ce.preventDefault(),Ce.stopPropagation(),Ce.target===n)return N(),void $.onDeactivate();K(G),$.onActivate()},!0),te}function N(){n&&(n.classList.remove(s.ACTIVE_BUTTON),n=null)}function K(G){N();const $=t[G];$&&$&&"trash"!==G&&($.classList.add(s.ACTIVE_BUTTON),n=$)}return{setActiveButton:K,queueMapClasses:f,updateMapClasses:E,clearMapClasses:function i(){f({mode:null,feature:null,mouse:null}),E()},addButtons:function j(){const G=e.options.controls,$=document.createElement("div");return $.className=`${s.CONTROL_GROUP} ${s.CONTROL_BASE}`,G&&(G[R.POINT]&&(t[R.POINT]=m(R.POINT,{container:$,className:s.CONTROL_BUTTON_POINT,title:"Marker tool "+(e.options.keybindings?"(1)":""),onActivate:()=>e.events.changeMode(g.DRAW_POINT),onDeactivate:()=>e.events.trash()})),G[R.LINE]&&(t[R.LINE]=m(R.LINE,{container:$,className:s.CONTROL_BUTTON_LINE,title:"LineString tool "+(e.options.keybindings?"(2)":""),onActivate:()=>e.events.changeMode(g.DRAW_LINE_STRING),onDeactivate:()=>e.events.trash()})),G[R.POLYGON]&&(t[R.POLYGON]=m(R.POLYGON,{container:$,className:s.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(e.options.keybindings?"(3)":""),onActivate:()=>e.events.changeMode(g.DRAW_POLYGON),onDeactivate:()=>e.events.trash()})),G.trash&&(t.trash=m("trash",{container:$,className:s.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:()=>{e.events.trash()}})),G.combine_features&&(t.combine_features=m("combineFeatures",{container:$,className:s.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:()=>{e.events.combineFeatures()}})),G.uncombine_features&&(t.uncombine_features=m("uncombineFeatures",{container:$,className:s.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:()=>{e.events.uncombineFeatures()}}))),$},removeButtons:function T(){Object.keys(t).forEach(G=>{const $=t[G];$.parentNode&&$.parentNode.removeChild($),delete t[G]})}}}(e),e.container=r.getContainer(),e.store=new ie(e),t=e.ui.addButtons(),e.options.boxSelect){e.boxZoomInitial=r.boxZoom.isEnabled(),r.boxZoom.disable();const i=r.dragPan.isEnabled();r.dragPan.disable(),r.dragPan.enable(),i||r.dragPan.disable()}return r.loaded()?o.connect():(r.on("load",o.connect),n=setInterval(()=>{r.loaded()&&o.connect()},16)),e.events.start(),t},addLayers(){e.map.addSource(D.COLD,{data:{type:P.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(D.HOT,{data:{type:P.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.options.styles.forEach(r=>{e.map.addLayer(r)}),e.store.setDirty(!0),e.store.render()},removeLayers(){e.options.styles.forEach(r=>{e.map.getLayer(r.id)&&e.map.removeLayer(r.id)}),e.map.getSource(D.COLD)&&e.map.removeSource(D.COLD),e.map.getSource(D.HOT)&&e.map.removeSource(D.HOT)}};return e.setup=o,o}const st="#3bb2d0",at="#fbb03b",Gt=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],at,st],"fill-opacity":.1}},{id:"gl-draw-lines",type:"line",filter:["any",["==","$type","LineString"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["==",["get","active"],"true"],at,st],"line-dasharray":["case",["==",["get","active"],"true"],[.2,2],[2,0]],"line-width":2}},{id:"gl-draw-point-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":"#fff"}},{id:"gl-draw-point-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":["case",["==",["get","active"],"true"],at,st]}},{id:"gl-draw-vertex-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":"#fff"}},{id:"gl-draw-vertex-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":at}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":at}}];function Ge(e,t){this.x=e,this.y=t}Ge.prototype={clone(){return new Ge(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const n=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=n,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),n=Math.sin(e),r=n*this.x+t*this.y;return this.x=t*this.x-n*this.y,this.y=r,this},_rotateAround(e,t){const n=Math.cos(e),o=Math.sin(e),i=t.y+o*(this.x-t.x)+n*(this.y-t.y);return this.x=t.x+n*(this.x-t.x)-o*(this.y-t.y),this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Ge},Ge.convert=function(e){if(e instanceof Ge)return e;if(Array.isArray(e))return new Ge(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new Ge(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};const Ot=function mn(e,t){const n=t.getBoundingClientRect();return new Ge(e.clientX-n.left-(t.clientLeft||0),e.clientY-n.top-(t.clientTop||0))};function Ze(e,t,n,o){return{type:P.FEATURE,properties:{meta:M.VERTEX,parent:e,coord_path:n,active:o?O.ACTIVE:O.INACTIVE},geometry:{type:P.POINT,coordinates:t}}}function lt(e,t,n){if(null!==e)for(var o,r,i,f,E,m,N,T,K=0,j=0,G=e.type,$="FeatureCollection"===G,te="Feature"===G,Ce=$?e.features.length:1,Te=0;Te<Ce;Te++){E=(T=!!(N=$?e.features[Te].geometry:te?e.geometry:e)&&"GeometryCollection"===N.type)?N.geometries.length:1;for(var Ve=0;Ve<E;Ve++){var Pe=0,We=0;if(null!==(f=T?N.geometries[Ve]:N)){m=f.coordinates;var Ue=f.type;switch(K=!n||"Polygon"!==Ue&&"MultiPolygon"!==Ue?0:1,Ue){case null:break;case"Point":if(!1===t(m,j,Te,Pe,We))return!1;j++,Pe++;break;case"LineString":case"MultiPoint":for(o=0;o<m.length;o++){if(!1===t(m[o],j,Te,Pe,We))return!1;j++,"MultiPoint"===Ue&&Pe++}"LineString"===Ue&&Pe++;break;case"Polygon":case"MultiLineString":for(o=0;o<m.length;o++){for(r=0;r<m[o].length-K;r++){if(!1===t(m[o][r],j,Te,Pe,We))return!1;j++}"MultiLineString"===Ue&&Pe++,"Polygon"===Ue&&We++}"Polygon"===Ue&&Pe++;break;case"MultiPolygon":for(o=0;o<m.length;o++){for(We=0,r=0;r<m[o].length;r++){for(i=0;i<m[o][r].length-K;i++){if(!1===t(m[o][r][i],j,Te,Pe,We))return!1;j++}We++}Pe++}break;case"GeometryCollection":for(o=0;o<f.geometries.length;o++)if(!1===lt(f.geometries[o],t,n))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Jt(e){const t={type:"Feature"};return Object.keys(e).forEach(n=>{switch(n){case"type":case"properties":case"geometry":return;default:t[n]=e[n]}}),t.properties=Yt(e.properties),t.geometry=null==e.geometry?null:Dt(e.geometry),t}function Yt(e){const t={};return e&&Object.keys(e).forEach(n=>{const o=e[n];t[n]="object"==typeof o?null===o?null:Array.isArray(o)?o.map(r=>r):Yt(o):o}),t}function Dt(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(n=>Dt(n)),t):(t.coordinates=jt(e.coordinates),t)}function jt(e){const t=e;return"object"!=typeof t[0]?t.slice():t.map(n=>jt(n))}function Qt(e,t={}){return qt(e,"mercator",t)}function qt(e,t,n={}){var o=(n=n||{}).mutate;if(!e)throw new Error("geojson is required");return Array.isArray(e)&&function ht(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}(e[0])?e="mercator"===t?en(e):tn(e):(!0!==o&&(e=function Pn(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return Jt(e);case"FeatureCollection":return function Sn(e){const t={type:"FeatureCollection"};return Object.keys(e).forEach(n=>{switch(n){case"type":case"features":return;default:t[n]=e[n]}}),t.features=e.features.map(n=>Jt(n)),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Dt(e);default:throw new Error("unknown GeoJSON type")}}(e)),lt(e,function(r){var i="mercator"===t?en(r):tn(r);r[0]=i[0],r[1]=i[1]})),e}function en(e){var t=Math.PI/180,n=6378137,o=20037508.342789244,r=Math.abs(e[0])<=180?e[0]:e[0]-360*function On(e){return e<0?-1:e>0?1:0}(e[0]),i=[n*r*t,n*Math.log(Math.tan(.25*Math.PI+.5*e[1]*t))];return i[0]>o&&(i[0]=o),i[0]<-o&&(i[0]=-o),i[1]>o&&(i[1]=o),i[1]<-o&&(i[1]=-o),i}function tn(e){var t=180/Math.PI,n=6378137;return[e[0]*t/n,(.5*Math.PI-2*Math.atan(Math.exp(-e[1]/n)))*t]}function nn(e,t,n){const o=t.geometry.coordinates,r=n.geometry.coordinates;if(o[1]>k||o[1]<w||r[1]>k||r[1]<w)return null;const i=Qt(o),f=Qt(r),E=j=>Number(j.toFixed(8)),m=(j,T)=>(j+T)/2,N=function In(e,t={}){return qt(e,"wgs84",t)}([m(i[0],f[0]),m(i[1],f[1])]),K=[E(N[0]),E(N[1])];return{type:P.FEATURE,properties:{meta:M.MIDPOINT,parent:e,lng:K[0],lat:K[1],coord_path:n.properties.coord_path},geometry:{type:P.POINT,coordinates:K}}}Math;const wt=function on(e,t={},n=null){const{type:o,coordinates:r}=e.geometry,i=e.properties&&e.properties.id;let f=[];function E(K,j){let T="",G=null;K.forEach(($,te)=>{const Ce=null!=j?`${j}.${te}`:String(te),Te=Ze(i,$,Ce,m(Ce));if(t.midpoints&&G){const Pe=nn(i,G,Te);Pe&&f.push(Pe)}G=Te;const Ve=JSON.stringify($);T!==Ve&&f.push(Te),0===te&&(T=Ve)})}function m(K){return!!t.selectedPaths&&-1!==t.selectedPaths.indexOf(K)}return o===P.POINT?f.push(Ze(i,r,n,m(n))):o===P.POLYGON?r.forEach((K,j)=>{E(K,null!==n?`${n}.${j}`:String(j))}):o===P.LINE_STRING?E(r,n):0===o.indexOf(P.MULTI_PREFIX)&&function N(){const K=o.replace(P.MULTI_PREFIX,"");r.forEach((j,T)=>{f=f.concat(on({type:P.FEATURE,properties:e.properties,geometry:{type:K,coordinates:j}},t,T))})}(),f},Ie={enable(e){setTimeout(()=>{!e.map||!e.map.doubleClickZoom||!e._ctx||!e._ctx.store||!e._ctx.store.getInitialConfigValue||e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable()},0)},disable(e){setTimeout(()=>{!e.map||!e.map.doubleClickZoom||e.map.doubleClickZoom.disable()},0)}},{LAT_MIN:pt,LAT_MAX:gt,LAT_RENDERED_MIN:rn,LAT_RENDERED_MAX:sn,LNG_MIN:an,LNG_MAX:ln}=I;function At(e,t){let n=pt,o=gt,r=pt,i=gt,f=ln,E=an;e.forEach(N=>{const K=function Fn(e){const n=[e.geometry.coordinates].flat({Point:0,LineString:1,Polygon:2,MultiPoint:1,MultiLineString:2,MultiPolygon:3}[e.geometry.type]),o=n.map(E=>E[0]),r=n.map(E=>E[1]),i=E=>Math.min.apply(null,E),f=E=>Math.max.apply(null,E);return[i(o),i(r),f(o),f(r)]}(N),j=K[1],T=K[3],G=K[0],$=K[2];j>n&&(n=j),T<o&&(o=T),T>r&&(r=T),j<i&&(i=j),G<f&&(f=G),$>E&&(E=$)});const m=t;return n+m.lat>sn&&(m.lat=sn-n),r+m.lat>gt&&(m.lat=gt-r),o+m.lat<rn&&(m.lat=rn-o),i+m.lat<pt&&(m.lat=pt-i),f+m.lng<=an&&(m.lng+=360*Math.ceil(Math.abs(m.lng)/360)),E+m.lng>=ln&&(m.lng-=360*Math.ceil(Math.abs(m.lng)/360)),m}function Nt(e,t){const n=At(e.map(o=>o.toGeoJSON()),t);e.forEach(o=>{const r=o.getCoordinates(),i=N=>{const K={lng:N[0]+n.lng,lat:N[1]+n.lat};return[K.lng,K.lat]},f=N=>N.map(K=>i(K));let m;o.type===P.POINT?m=i(r):o.type===P.LINE_STRING||o.type===P.MULTI_POINT?m=r.map(i):o.type===P.POLYGON||o.type===P.MULTI_LINE_STRING?m=r.map(f):o.type===P.MULTI_POLYGON&&(m=r.map(N=>N.map(K=>f(K)))),o.incomingCoords(m)})}const ce={onSetup:function(e){const t={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initialDragPanState:this.map.dragPan.isEnabled(),initiallySelectedFeatureIds:e.featureIds||[]};return this.setSelected(t.initiallySelectedFeatureIds.filter(n=>void 0!==this.getFeature(n))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),t},fireUpdate:function(){this.fire(a.UPDATE,{action:p.MOVE,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(){const e=this.getSelected(),t=e.filter(i=>this.isInstanceOf("MultiFeature",i));let n=!1;if(e.length>1){n=!0;const i=e[0].type.replace("Multi","");e.forEach(f=>{f.type.replace("Multi","")!==i&&(n=!1)})}this.setActionableState({combineFeatures:n,uncombineFeatures:t.length>0,trash:e.length>0})},getUniqueIds:function(e){return e.length?e.map(n=>n.properties.id).filter(n=>void 0!==n).reduce((n,o)=>(n.add(o),n),new Ae).values():[]},stopExtendedInteractions:function(e){e.boxSelectElement&&(e.boxSelectElement.parentNode&&e.boxSelectElement.parentNode.removeChild(e.boxSelectElement),e.boxSelectElement=null),(e.canDragMove||e.canBoxSelect)&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.boxSelecting=!1,e.canBoxSelect=!1,e.dragMoving=!1,e.canDragMove=!1},onStop:function(){Ie.enable(this)},onMouseMove:function(e,t){return Z(t)&&e.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(e),!0},onMouseOut:function(e){return!e.dragMoving||this.fireUpdate()}};ce.onTap=ce.onClick=function(e,t){return W(t)?this.clickAnywhere(e,t):C(M.VERTEX)(t)?this.clickOnVertex(e,t):Z(t)?this.clickOnFeature(e,t):void 0},ce.clickAnywhere=function(e){const t=this.getSelectedIds();t.length&&(this.clearSelectedFeatures(),t.forEach(n=>this.doRender(n))),Ie.enable(this),this.stopExtendedInteractions(e)},ce.clickOnVertex=function(e,t){this.changeMode(g.DIRECT_SELECT,{featureId:t.featureTarget.properties.parent,coordPath:t.featureTarget.properties.coord_path,startPos:t.lngLat}),this.updateUIClasses({mouse:l.MOVE})},ce.startOnActiveFeature=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),this.doRender(t.featureTarget.properties.id),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},ce.clickOnFeature=function(e,t){Ie.disable(this),this.stopExtendedInteractions(e);const n=oe(t),o=this.getSelectedIds(),r=t.featureTarget.properties.id,i=this.isSelected(r);if(!n&&i&&this.getFeature(r).type!==P.POINT)return this.changeMode(g.DIRECT_SELECT,{featureId:r});i&&n?(this.deselect(r),this.updateUIClasses({mouse:l.POINTER}),1===o.length&&Ie.enable(this)):!i&&n?(this.select(r),this.updateUIClasses({mouse:l.MOVE})):!i&&!n&&(o.forEach(f=>this.doRender(f)),this.setSelected(r),this.updateUIClasses({mouse:l.MOVE})),this.doRender(r)},ce.onMouseDown=function(e,t){return e.initialDragPanState=this.map.dragPan.isEnabled(),L(t)?this.startOnActiveFeature(e,t):this.drawConfig.boxSelect&&F(t)?this.startBoxSelect(e,t):void 0},ce.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=Ot(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0},ce.onTouchStart=function(e,t){if(L(t))return this.startOnActiveFeature(e,t)},ce.onDrag=function(e,t){return e.canDragMove?this.dragMove(e,t):this.drawConfig.boxSelect&&e.canBoxSelect?this.whileBoxSelect(e,t):void 0},ce.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:l.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(s.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));const n=Ot(t.originalEvent,this.map.getContainer()),o=Math.min(e.boxSelectStartLocation.x,n.x),r=Math.max(e.boxSelectStartLocation.x,n.x),i=Math.min(e.boxSelectStartLocation.y,n.y),f=Math.max(e.boxSelectStartLocation.y,n.y),E=`translate(${o}px, ${i}px)`;e.boxSelectElement.style.transform=E,e.boxSelectElement.style.WebkitTransform=E,e.boxSelectElement.style.width=r-o+"px",e.boxSelectElement.style.height=f-i+"px"},ce.dragMove=function(e,t){e.dragMoving=!0,t.originalEvent.stopPropagation();const n={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};Nt(this.getSelected(),n),e.dragMoveLocation=t.lngLat},ce.onTouchEnd=ce.onMouseUp=function(e,t){if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){const n=[e.boxSelectStartLocation,Ot(t.originalEvent,this.map.getContainer())],o=this.featuresAt(null,n,"click"),r=this.getUniqueIds(o).filter(i=>!this.isSelected(i));r.length&&(this.select(r),r.forEach(i=>this.doRender(i)),this.updateUIClasses({mouse:l.MOVE}))}this.stopExtendedInteractions(e)},ce.toDisplayFeatures=function(e,t,n){t.properties.active=this.isSelected(t.properties.id)?O.ACTIVE:O.INACTIVE,n(t),this.fireActionable(),t.properties.active===O.ACTIVE&&t.geometry.type!==P.POINT&&wt(t).forEach(n)},ce.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},ce.onCombineFeatures=function(){const e=this.getSelected();if(0===e.length||e.length<2)return;const t=[],n=[],o=e[0].type.replace("Multi","");for(let r=0;r<e.length;r++){const i=e[r];if(i.type.replace("Multi","")!==o)return;i.type.includes("Multi")?i.getCoordinates().forEach(f=>{t.push(f)}):t.push(i.getCoordinates()),n.push(i.toGeoJSON())}if(n.length>1){const r=this.newFeature({type:P.FEATURE,properties:n[0].properties,geometry:{type:`Multi${o}`,coordinates:t}});this.addFeature(r),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([r.id]),this.fire(a.COMBINE_FEATURES,{createdFeatures:[r.toGeoJSON()],deletedFeatures:n})}this.fireActionable()},ce.onUncombineFeatures=function(){const e=this.getSelected();if(0===e.length)return;const t=[],n=[];for(let o=0;o<e.length;o++){const r=e[o];this.isInstanceOf("MultiFeature",r)&&(r.getFeatures().forEach(i=>{this.addFeature(i),i.properties=r.properties,t.push(i.toGeoJSON()),this.select([i.id])}),this.deleteFeature(r.id,{silent:!0}),n.push(r.toGeoJSON()))}t.length>1&&this.fire(a.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:n}),this.fireActionable()};const xn=ce,cn=C(M.VERTEX),un=C(M.MIDPOINT),ue={fireUpdate:function(){this.fire(a.UPDATE,{action:p.CHANGE_COORDINATES,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(e){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:e.selectedCoordPaths.length>0})},startDragging:function(e,t){null==e.initialDragPanState&&(e.initialDragPanState=this.map.dragPan.isEnabled()),this.map.dragPan.disable(),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},stopDragging:function(e){e.canDragMove&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.initialDragPanState=null,e.dragMoving=!1,e.canDragMove=!1,e.dragMoveLocation=null},onVertex:function(e,t){this.startDragging(e,t);const n=t.featureTarget.properties,o=e.selectedCoordPaths.indexOf(n.coord_path);oe(t)||-1!==o?oe(t)&&-1===o&&e.selectedCoordPaths.push(n.coord_path):e.selectedCoordPaths=[n.coord_path];const r=this.pathsToCoordinates(e.featureId,e.selectedCoordPaths);this.setSelectedCoordinates(r)},onMidpoint:function(e,t){this.startDragging(e,t);const n=t.featureTarget.properties;e.feature.addCoordinate(n.coord_path,n.lng,n.lat),this.fireUpdate(),e.selectedCoordPaths=[n.coord_path]},pathsToCoordinates:function(e,t){return t.map(n=>({feature_id:e,coord_path:n}))},onFeature:function(e,t){0===e.selectedCoordPaths.length?this.startDragging(e,t):this.stopDragging(e)},dragFeature:function(e,t,n){Nt(this.getSelected(),n),e.dragMoveLocation=t.lngLat},dragVertex:function(e,t,n){const o=e.selectedCoordPaths.map(f=>e.feature.getCoordinate(f)),i=At(o.map(f=>({type:P.FEATURE,properties:{},geometry:{type:P.POINT,coordinates:f}})),n);for(let f=0;f<o.length;f++){const E=o[f];e.feature.updateCoordinate(e.selectedCoordPaths[f],E[0]+i.lng,E[1]+i.lat)}},clickNoTarget:function(){this.changeMode(g.SIMPLE_SELECT)},clickInactive:function(){this.changeMode(g.SIMPLE_SELECT)},clickActiveFeature:function(e){e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed()},onSetup:function(e){const t=e.featureId,n=this.getFeature(t);if(!n)throw new Error("You must provide a featureId to enter direct_select mode");if(n.type===P.POINT)throw new TypeError("direct_select mode doesn't handle point features");const o={featureId:t,feature:n,dragMoveLocation:e.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:e.coordPath?[e.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(t,o.selectedCoordPaths)),this.setSelected(t),Ie.disable(this),this.setActionableState({trash:!0}),o},onStop:function(){Ie.enable(this),this.clearSelectedCoordinates()},toDisplayFeatures:function(e,t,n){e.featureId===t.properties.id?(t.properties.active=O.ACTIVE,n(t),wt(t,{map:this.map,midpoints:!0,selectedPaths:e.selectedCoordPaths}).forEach(n)):(t.properties.active=O.INACTIVE,n(t)),this.fireActionable(e)},onTrash:function(e){e.selectedCoordPaths.sort((t,n)=>n.localeCompare(t,"en",{numeric:!0})).forEach(t=>e.feature.removeCoordinate(t)),this.fireUpdate(),e.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(e),!1===e.feature.isValid()&&(this.deleteFeature([e.featureId]),this.changeMode(g.SIMPLE_SELECT,{}))},onMouseMove:function(e,t){const n=L(t),o=cn(t),r=un(t),i=0===e.selectedCoordPaths.length;return this.updateUIClasses(n&&i||o&&!i?{mouse:l.MOVE}:{mouse:l.NONE}),(o||n||r)&&e.dragMoving&&this.fireUpdate(),this.stopDragging(e),!0},onMouseOut:function(e){return e.dragMoving&&this.fireUpdate(),!0}};ue.onTouchStart=ue.onMouseDown=function(e,t){return cn(t)?this.onVertex(e,t):L(t)?this.onFeature(e,t):un(t)?this.onMidpoint(e,t):void 0},ue.onDrag=function(e,t){if(!0!==e.canDragMove)return;e.dragMoving=!0,t.originalEvent.stopPropagation();const n={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};e.selectedCoordPaths.length>0?this.dragVertex(e,t,n):this.dragFeature(e,t,n),e.dragMoveLocation=t.lngLat},ue.onClick=function(e,t){return W(t)?this.clickNoTarget(e,t):L(t)?this.clickActiveFeature(e,t):A(t)?this.clickInactive(e,t):void this.stopDragging(e)},ue.onTap=function(e,t){return W(t)?this.clickNoTarget(e,t):L(t)?this.clickActiveFeature(e,t):A(t)?this.clickInactive(e,t):void 0},ue.onTouchEnd=ue.onMouseUp=function(e){e.dragMoving&&this.fireUpdate(),this.stopDragging(e)};const Dn=ue,xe={onSetup:function(){const e=this.newFeature({type:P.FEATURE,properties:{},geometry:{type:P.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:l.ADD}),this.activateUIButton(R.POINT),this.setActionableState({trash:!0}),{point:e}},stopDrawingAndRemove:function(e){this.deleteFeature([e.point.id],{silent:!0}),this.changeMode(g.SIMPLE_SELECT)}};xe.onTap=xe.onClick=function(e,t){this.updateUIClasses({mouse:l.MOVE}),e.point.updateCoordinate("",t.lngLat.lng,t.lngLat.lat),this.fire(a.CREATE,{features:[e.point.toGeoJSON()]}),this.changeMode(g.SIMPLE_SELECT,{featureIds:[e.point.id]})},xe.onStop=function(e){this.activateUIButton(),e.point.getCoordinate().length||this.deleteFeature([e.point.id],{silent:!0})},xe.toDisplayFeatures=function(e,t,n){const o=t.properties.id===e.point.id;if(t.properties.active=o?O.ACTIVE:O.INACTIVE,!o)return n(t)},xe.onTrash=xe.stopDrawingAndRemove,xe.onKeyUp=function(e,t){if(ye(t)||fe(t))return this.stopDrawingAndRemove(e,t)};const wn=xe,mt=function An(e,t){return!!e.lngLat&&e.lngLat.lng===t[0]&&e.lngLat.lat===t[1]},Oe={onSetup:function(){const e=this.newFeature({type:P.FEATURE,properties:{},geometry:{type:P.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),Ie.disable(this),this.updateUIClasses({mouse:l.ADD}),this.activateUIButton(R.POLYGON),this.setActionableState({trash:!0}),{polygon:e,currentVertexPosition:0}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&mt(t,e.polygon.coordinates[0][e.currentVertexPosition-1]))return this.changeMode(g.SIMPLE_SELECT,{featureIds:[e.polygon.id]});this.updateUIClasses({mouse:l.ADD}),e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(g.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},onMouseMove:function(e,t){e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),J(t)&&this.updateUIClasses({mouse:l.POINTER})}};Oe.onTap=Oe.onClick=function(e,t){return J(t)?this.clickOnVertex(e,t):this.clickAnywhere(e,t)},Oe.onKeyUp=function(e,t){ye(t)?(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(g.SIMPLE_SELECT)):fe(t)&&this.changeMode(g.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},Oe.onStop=function(e){this.updateUIClasses({mouse:l.NONE}),Ie.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.polygon.id)&&(e.polygon.removeCoordinate(`0.${e.currentVertexPosition}`),e.polygon.isValid()?this.fire(a.CREATE,{features:[e.polygon.toGeoJSON()]}):(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(g.SIMPLE_SELECT,{},{silent:!0})))},Oe.toDisplayFeatures=function(e,t,n){const o=t.properties.id===e.polygon.id;if(t.properties.active=o?O.ACTIVE:O.INACTIVE,!o)return n(t);if(0===t.geometry.coordinates.length)return;const r=t.geometry.coordinates[0].length;if(!(r<3)){if(t.properties.meta=M.FEATURE,n(Ze(e.polygon.id,t.geometry.coordinates[0][0],"0.0",!1)),r>3){const i=t.geometry.coordinates[0].length-3;n(Ze(e.polygon.id,t.geometry.coordinates[0][i],`0.${i}`,!1))}if(r<=4&&(n({type:P.FEATURE,properties:t.properties,geometry:{coordinates:[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]],type:P.LINE_STRING}}),3===r))return;return n(t)}},Oe.onTrash=function(e){this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(g.SIMPLE_SELECT)};const Nn=Oe,Fe={onSetup:function(e){const t=(e=e||{}).featureId;let n,o,r="forward";if(t){if(n=this.getFeature(t),!n)throw new Error("Could not find a feature with the provided featureId");let i=e.from;if(i&&"Feature"===i.type&&i.geometry&&"Point"===i.geometry.type&&(i=i.geometry),i&&"Point"===i.type&&i.coordinates&&2===i.coordinates.length&&(i=i.coordinates),!i||!Array.isArray(i))throw new Error("Please use the `from` property to indicate which point to continue the line from");const f=n.coordinates.length-1;if(n.coordinates[f][0]===i[0]&&n.coordinates[f][1]===i[1])o=f+1,n.addCoordinate(o,...n.coordinates[f]);else{if(n.coordinates[0][0]!==i[0]||n.coordinates[0][1]!==i[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");r="backwards",o=0,n.addCoordinate(o,...n.coordinates[0])}}else n=this.newFeature({type:P.FEATURE,properties:{},geometry:{type:P.LINE_STRING,coordinates:[]}}),o=0,this.addFeature(n);return this.clearSelectedFeatures(),Ie.disable(this),this.updateUIClasses({mouse:l.ADD}),this.activateUIButton(R.LINE),this.setActionableState({trash:!0}),{line:n,currentVertexPosition:o,direction:r}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&mt(t,e.line.coordinates[e.currentVertexPosition-1])||"backwards"===e.direction&&mt(t,e.line.coordinates[e.currentVertexPosition+1]))return this.changeMode(g.SIMPLE_SELECT,{featureIds:[e.line.id]});this.updateUIClasses({mouse:l.ADD}),e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),"forward"===e.direction?(e.currentVertexPosition++,e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat)):e.line.addCoordinate(0,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(g.SIMPLE_SELECT,{featureIds:[e.line.id]})},onMouseMove:function(e,t){e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),J(t)&&this.updateUIClasses({mouse:l.POINTER})}};Fe.onTap=Fe.onClick=function(e,t){if(J(t))return this.clickOnVertex(e,t);this.clickAnywhere(e,t)},Fe.onKeyUp=function(e,t){fe(t)?this.changeMode(g.SIMPLE_SELECT,{featureIds:[e.line.id]}):ye(t)&&(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(g.SIMPLE_SELECT))},Fe.onStop=function(e){Ie.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.line.id)&&(e.line.removeCoordinate(`${e.currentVertexPosition}`),e.line.isValid()?this.fire(a.CREATE,{features:[e.line.toGeoJSON()]}):(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(g.SIMPLE_SELECT,{},{silent:!0})))},Fe.onTrash=function(e){this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(g.SIMPLE_SELECT)},Fe.toDisplayFeatures=function(e,t,n){const o=t.properties.id===e.line.id;if(t.properties.active=o?O.ACTIVE:O.INACTIVE,!o)return n(t);t.geometry.coordinates.length<2||(t.properties.meta=M.FEATURE,n(Ze(e.line.id,t.geometry.coordinates["forward"===e.direction?t.geometry.coordinates.length-2:1],""+("forward"===e.direction?t.geometry.coordinates.length-2:1),!1)),n(t))};const dn={simple_select:xn,direct_select:Dn,draw_point:wn,draw_polygon:Nn,draw_line_string:Fe},Rn={defaultMode:g.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:Gt,modes:dn,controls:{},userProperties:!1,suppressAPIEvents:!0},Bn={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},kn={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function fn(e,t){return e.map(n=>n.source?n:Object.assign({},n,{id:`${n.id}.${t}`,source:"hot"===t?D.HOT:D.COLD}))}var hn=u(362),Vn=u(5341);function pn(e,t){return e.length===t.length&&JSON.stringify(e.map(n=>n).sort())===JSON.stringify(t.map(n=>n).sort())}const Un={Polygon:se,LineString:le,Point:Y,MultiPolygon:Ne,MultiLineString:Ne,MultiPoint:Ne};function yt(e){!function(e,t){e=function Gn(e={}){let t=Object.assign({},e);return e.controls||(t.controls={}),t.controls=Object.assign({},!1===e.displayControlsDefault?kn:Bn,e.controls),t=Object.assign({},Rn,t),t.styles=fn(t.styles,"cold").concat(fn(t.styles,"hot")),t}(e);const n={options:e};t=function zn(e,t){t.modes=g;const n=void 0===e.options.suppressAPIEvents||!!e.options.suppressAPIEvents;return t.getFeatureIdsAt=function(o){return Be.click({point:o},null,e).map(i=>i.properties.id)},t.getSelectedIds=function(){return e.store.getSelectedIds()},t.getSelected=function(){return{type:P.FEATURE_COLLECTION,features:e.store.getSelectedIds().map(o=>e.store.get(o)).map(o=>o.toGeoJSON())}},t.getSelectedPoints=function(){return{type:P.FEATURE_COLLECTION,features:e.store.getSelectedCoordinates().map(o=>({type:P.FEATURE,properties:{},geometry:{type:P.POINT,coordinates:o.coordinates}}))}},t.set=function(o){if(void 0===o.type||o.type!==P.FEATURE_COLLECTION||!Array.isArray(o.features))throw new Error("Invalid FeatureCollection");const r=e.store.createRenderBatch();let i=e.store.getAllIds().slice();const f=t.add(o),E=new Ae(f);return i=i.filter(m=>!E.has(m)),i.length&&t.delete(i),r(),f},t.add=function(o){const i=JSON.parse(JSON.stringify(Vn(o))).features.map(f=>{if(f.id=f.id||c(),null===f.geometry)throw new Error("Invalid geometry: null");if(void 0===e.store.get(f.id)||e.store.get(f.id).type!==f.geometry.type){const E=Un[f.geometry.type];if(void 0===E)throw new Error(`Invalid geometry type: ${f.geometry.type}.`);const m=new E(e,f);e.store.add(m,{silent:n})}else{const E=e.store.get(f.id),m=E.properties;E.properties=f.properties,hn(m,f.properties)||e.store.featureChanged(E.id,{silent:n}),hn(E.getCoordinates(),f.geometry.coordinates)||E.incomingCoords(f.geometry.coordinates)}return f.id});return e.store.render(),i},t.get=function(o){const r=e.store.get(o);if(r)return r.toGeoJSON()},t.getAll=function(){return{type:P.FEATURE_COLLECTION,features:e.store.getAll().map(o=>o.toGeoJSON())}},t.delete=function(o){return e.store.delete(o,{silent:n}),t.getMode()!==g.DIRECT_SELECT||e.store.getSelectedIds().length?e.store.render():e.events.changeMode(g.SIMPLE_SELECT,void 0,{silent:n}),t},t.deleteAll=function(){return e.store.delete(e.store.getAllIds(),{silent:n}),t.getMode()===g.DIRECT_SELECT?e.events.changeMode(g.SIMPLE_SELECT,void 0,{silent:n}):e.store.render(),t},t.changeMode=function(o,r={}){return o===g.SIMPLE_SELECT&&t.getMode()===g.SIMPLE_SELECT?(pn(r.featureIds||[],e.store.getSelectedIds())||(e.store.setSelected(r.featureIds,{silent:n}),e.store.render()),t):(o===g.DIRECT_SELECT&&t.getMode()===g.DIRECT_SELECT&&r.featureId===e.store.getSelectedIds()[0]||e.events.changeMode(o,r,{silent:n}),t)},t.getMode=function(){return e.events.getMode()},t.trash=function(){return e.events.trash({silent:n}),t},t.combineFeatures=function(){return e.events.combineFeatures({silent:n}),t},t.uncombineFeatures=function(){return e.events.uncombineFeatures({silent:n}),t},t.setFeatureProperty=function(o,r,i){return e.store.setFeatureProperty(o,r,i,{silent:n}),t},t}(n,t),n.api=t;const o=Bt(n);t.onAdd=o.onAdd,t.onRemove=o.onRemove,t.types=R,t.options=e}(e,this)}yt.modes=dn,yt.constants=I,yt.lib=x;const gn=yt;let Wn=(()=>{class e{_draw;_map;_drawMode=(0,z.vPA)(!1);_settingDrawMode=!1;_eventListeners=[];_clearAfterFinish=!0;drawEvent=(0,z.vPA)(void 0);destroy(){this._cleanup()}initializeWithMap(n){this._map=n,this._initDrawControl(n)}setDrawMode(n,o){if(this._draw&&this._map&&!this._settingDrawMode){if(this._clearAfterFinish=o,this._settingDrawMode=!0,this._drawMode.set(n),n){this._draw.deleteAll(),this._draw.changeMode("draw_polygon");const r={type:"polygon",status:"started",coordinates:[],bbox:{minLng:0,minLat:0,maxLng:0,maxLat:0}};this.drawEvent.update(()=>r)}else this._draw.changeMode("simple_select"),this._draw.deleteAll();this._settingDrawMode=!1}}setClearAfterFinish(n){this._clearAfterFinish=n}getClearAfterFinish(){return this._clearAfterFinish}getDrawMode(){return this._drawMode()}clearDrawings(){this._draw&&this._draw.deleteAll()}getDrawInstance(){return this._draw}_initDrawControl(n){this._draw=new gn({displayControlsDefault:!1,modes:{...gn.modes}}),n.addControl(this._draw,"top-left");const o=document.querySelector(".mapbox-gl-draw_ctrl-draw-btn")?.parentElement;o&&(o.style.display="none");const r=E=>{const m=E.features[0];if("Polygon"===m.geometry.type){const N=m.geometry.coordinates[0],j={type:"polygon",status:"ended",coordinates:N,bbox:this._calculateBBox(N)};this.drawEvent.update(()=>j),this._drawMode.set(!1),this._clearAfterFinish&&this._draw?.deleteAll()}},i=E=>{const m=E.features[0];if("Polygon"===m.geometry.type){const N=m.geometry.coordinates[0],j={type:"polygon",status:"in-progress",coordinates:N,bbox:this._calculateBBox(N)};this.drawEvent.update(()=>j)}},f=()=>{if(this._drawMode()){const E=this._draw?.getAll();if(E?.features?.length){const m=E.features[0];if("Polygon"===m.geometry.type){const N=m.geometry.coordinates[0];if(N.length>2){const j={type:"polygon",status:"in-progress",coordinates:N,bbox:this._calculateBBox(N)};this.drawEvent.update(()=>j)}}}}};n.on("draw.create",r),n.on("draw.update",i),n.on("mousemove",f),this._eventListeners.push({event:"draw.create",handler:r}),this._eventListeners.push({event:"draw.update",handler:i}),this._eventListeners.push({event:"mousemove",handler:f})}_cleanup(){this._map&&(this._eventListeners.forEach(({event:n,handler:o})=>{this._map?.off(n,o)}),this._eventListeners=[],this._draw&&this._map._controls?.includes(this._draw)&&this._map.removeControl(this._draw)),this._draw=void 0,this._map=void 0,this.drawEvent.set(void 0)}_calculateBBox(n){return n.reduce((o,r)=>({minLng:Math.min(o.minLng,r[0]),minLat:Math.min(o.minLat,r[1]),maxLng:Math.max(o.maxLng,r[0]),maxLat:Math.max(o.maxLat,r[1])}),{minLng:1/0,minLat:1/0,maxLng:-1/0,maxLat:-1/0})}static \u0275fac=function(o){return new(o||e)};static \u0275prov=z.jDH({token:e,factory:e.\u0275fac})}return e})()},6986(ae,Q,u){"use strict";u.d(Q,{A4:()=>I,Jc:()=>l,Ln:()=>x,dx:()=>s,g8:()=>y,j5:()=>z,n7:()=>D});const I=12;function y(g,a,p){return{id:g,source:a,type:"circle",maxzoom:I,filter:["==",["get","_isCentroid"],!0],paint:{"circle-radius":6,"circle-color":["coalesce",["get","_color"],p],"circle-stroke-width":2,"circle-stroke-color":"white","circle-opacity":.8}}}function x(g,a,p,M){return function P(g,a,p,M,O){const B={id:g,source:M},b=O||p;switch(a){case"Point":case"MultiPoint":return[{...B,id:`${g}-clusters`,type:"circle",filter:["has","point_count"],paint:{"circle-color":b,"circle-radius":["step",["get","point_count"],15,100,20,750,25],"circle-stroke-width":2,"circle-stroke-color":"white","circle-opacity":.8}},{...B,id:`${g}-cluster-count`,type:"symbol",filter:["has","point_count"],layout:{"text-field":"{point_count_abbreviated}","text-font":["Poppins Medium","Arial Unicode MS Bold"],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#ffffff","text-halo-color":"rgba(0, 0, 0, 0.3)","text-halo-width":1}},{...B,id:`${g}-unclustered`,type:"circle",filter:["!",["has","point_count"]],paint:{"circle-radius":6,"circle-color":["coalesce",["get","_color"],p],"circle-stroke-width":2,"circle-stroke-color":"white","circle-opacity":.8}}];case"LineString":case"MultiLineString":return{...B,type:"line",paint:{"line-color":["coalesce",["get","_color"],p],"line-width":3,"line-opacity":.8},layout:{"line-join":"round","line-cap":"round"}};case"Polygon":case"MultiPolygon":return[{id:`${g}-fill`,source:M,type:"fill",paint:{"fill-color":["coalesce",["get","_color"],p],"fill-opacity":.3}},{id:`${g}-stroke`,source:M,type:"line",paint:{"line-color":["coalesce",["get","_color"],p],"line-width":2,"line-opacity":.8},layout:{"line-join":"round","line-cap":"round"}},{id:`${g}-labels`,source:M,type:"symbol",layout:{"text-field":["coalesce",["get","label"],""],"text-font":["Poppins Medium","Arial Unicode MS Bold"],"text-size":13,"text-anchor":"center","text-allow-overlap":!1},paint:{"text-color":"#333333","text-halo-color":"rgba(255, 255, 255, 0.9)","text-halo-width":2}}];default:return console.warn(`Unsupported geometry type: ${a}`),null}}(g,a,p,M,p)}function z(g){return"Polygon"===g||"MultiPolygon"===g}function s(g){return"LineString"===g||"MultiLineString"===g}function D(g,a){return a&&("Point"===g||"MultiPoint"===g)}function l(g,a){return D(g,a)?{cluster:!0,clusterMaxZoom:14,clusterRadius:50,clusterMinPoints:2}:{cluster:!1}}},3646(ae,Q,u){"use strict";u.d(Q,{B:()=>U});var I=u(467),y=u(5802),x=u(2271),z=u(4412),s=u(1413),D=u(2306),l=u(140);function b(k){let X=1/0,h=1/0,C=-1/0,F=-1/0;const L=k.features,A=Z=>{Z.length>=2&&(X=Math.min(X,Z[0]),h=Math.min(h,Z[1]),C=Math.max(C,Z[0]),F=Math.max(F,Z[1]))},W=(Z,J)=>{if(0===J)A(Z);else if(Array.isArray(Z))for(const oe of Z)W(oe,J-1)};for(const Z of L){const J=Z.geometry;switch(J.type){case"Point":W(J.coordinates,0);break;case"LineString":case"MultiPoint":W(J.coordinates,1);break;case"Polygon":case"MultiLineString":W(J.coordinates,2);break;case"MultiPolygon":W(J.coordinates,3);break;case"GeometryCollection":for(const oe of J.geometries){const he=b(new l.o([{type:"Feature",geometry:oe,properties:null}]));he&&(A([he[0],he[1]]),A([he[2],he[3]]))}}}return X===1/0?null:[X,h,C,F]}var w=u(6986);let U=(()=>{class k{_layers$=new z.t([]);_map;_sources={};_sourceLayers={};_sourceIds=[];_attachedListeners=[];_hoveredFeature=(0,y.vPA)(void 0);_layerGroups={};_layerClickable={};_pointLayerIds=new Set;_lineLayerIds=new Set;_processedClickEvents=new WeakSet;_clearHoverTimeout;_hoverSequence=0;layers=this._layers$.asObservable();layersSignal=(0,x.EW)(()=>this._layers$.getValue());clickedFeature=new s.B;hoveredFeature=new s.B;initializeWithMap(h){this._map=h,h.on("mousemove",C=>{const F=h.getCanvas();if(!F)return;const L=Object.keys(this._layerClickable).filter(W=>this._layerClickable[W]&&h.getLayer(W)),A=h.queryRenderedFeatures(C.point,{layers:L});F.style.cursor=A.length>0?"pointer":""})}getLayers(){return this._layers$.getValue()}setLayers(h){this._layers$.next([...h])}addLayer(h){const C=this._layers$.getValue(),F=C.findIndex(L=>L.id===h.id);F>=0?C[F]={...h}:C.push({...h}),this._layers$.next([...C])}removeLayer(h){const F=this._layers$.getValue().filter(L=>L.id!==h);this._layers$.next(F),this._deleteSourceIfExists(h.toString()),delete this._sources[h.toString()],delete this._sourceLayers[h.toString()],delete this._layerClickable[h.toString()],this._pointLayerIds.delete(h.toString()),this._lineLayerIds.delete(h.toString()),this._sourceIds=this._sourceIds.filter(L=>L!==h.toString())}toggleVisibility(h){const C=h.toString();if(this._layerGroups[C])return void this.toggleLayerGroupVisibility(C);const L=this._layers$.getValue().map(A=>{if(A.id===h){const W={...A,visible:!A.visible};return this._updateLayerVisibility(h.toString(),W.visible),W}return A});this._layers$.next(L)}setLayerVisibility(h,C){const F=h.toString();if(this._layerGroups[F]){if(this._map){const Z=C?"visible":"none";this._layerGroups[F].forEach(J=>{this._map.setLayoutProperty(J,"visibility",Z)})}}else this._updateLayerVisibility(F,C);const A=this._layers$.getValue().map(W=>W.id===h?{...W,visible:C}:W);this._layers$.next(A)}loadGeoJSONLayerGroup(h,C,F){var L=this;return(0,I.A)(function*(A,W,Z,J={}){const{cluster:oe=!1,zoomToFit:ye=!0,visible:fe=!0,label:he=A,color:me=L._extractColorFromLayer(Z[0])}=J;if(!L._map)return void console.warn("Map not initialized in LayerService");const ne=A;yield L._addSource(A,{type:"geojson",data:W,...(0,w.Jc)("Point",oe)});const ze=[];for(const ve of Z){ze.push(ve.id),L._layerClickable[ve.id]=!0,L._sourceLayers[ne]||(L._sourceLayers[ne]={layer:ve,clickable:!0});const Ke=ve.type;if("circle"===Ke||"symbol"===Ke)L._pointLayerIds.add(ve.id),L._map.addLayer(ve);else if("line"===Ke){L._lineLayerIds.add(ve.id);const we=L._getBeforePointLayerId();L._map.addLayer(ve,we)}else{const we=L._getBeforeLineLayerId()??L._getBeforePointLayerId();L._map.addLayer(ve,we)}L._map&&L._map.setLayoutProperty(ve.id,"visibility",fe?"visible":"none")}for(const ve of Z)L._setLayerEvents(ne,ve);L._layerGroups[A]=ze;const De=new D.ux(he,A);De.collection=W,De.color=me,De.visible=fe,L.addLayer(De),ye&&L.fitLayerBounds(A)}).apply(this,arguments)}toggleLayerGroupVisibility(h){const C=this._layerGroups[h];if(!C)return;const F=this.getLayer(h);if(!F)return;const L=!F.visible;if(this._map){const A=L?"visible":"none";C.forEach(W=>{this._map.setLayoutProperty(W,"visibility",A)})}this.updateLayer(h,{visible:L})}removeLayerGroup(h){const C=this._layerGroups[h];C&&(this._map&&(C.forEach(F=>{this._map.removeLayer(F),this._attachedListeners=this._attachedListeners.filter(L=>L!==h),delete this._layerClickable[F],this._pointLayerIds.delete(F),this._lineLayerIds.delete(F)}),this._deleteSourceIfExists(h)),delete this._sources[h],delete this._sourceLayers[h],this._sourceIds=this._sourceIds.filter(F=>F!==h),delete this._layerGroups[h],this.removeLayer(h))}loadGeoJSONLayer(h,C,F){var L=this;return(0,I.A)(function*(A,W,Z,J={}){const{cluster:oe=!0,zoomToFit:ye=!0,visible:fe=!0,label:he=A,color:me=L._extractColorFromLayer(Z)}=J;if(!L._map)return void console.warn("Map not initialized in LayerService");yield L._addSource(A,{type:"geojson",data:W,...(0,w.Jc)("Point",oe)},Z);const ne=new D.ux(he,A);ne.collection=W,ne.color=me,ne.visible=fe,L.addLayer(ne),L._updateLayerVisibility(A,fe),ye&&L.fitLayerBounds(A)}).apply(this,arguments)}_addSource(h,C,F){var L=this;return(0,I.A)(function*(A,W,Z,J=!0){L._map&&(L._sources[A]=W,L._deleteSourceIfExists(A),L._sourceIds.push(A),L._map.getSource(A)&&L._map.removeSource(A),L._map.addSource(A,W),Z&&L._addSourceLayer(A,Z,J))}).apply(this,arguments)}_getBeforePointLayerId(){if(!this._map||0===this._pointLayerIds.size)return;const h=this._map.getStyle()?.layers??[];for(const C of h)if(this._pointLayerIds.has(C.id))return C.id}_getBeforeLineLayerId(){if(!this._map||0===this._lineLayerIds.size)return;const h=this._map.getStyle()?.layers??[];for(const C of h)if(this._lineLayerIds.has(C.id))return C.id}_addSourceLayer(h,C,F=!0){if(!this._map)return;this._layerClickable[C.id]=F,this._sourceLayers[h]||(this._sourceLayers[h]={layer:C,clickable:F});const L=C.type;if("circle"===L||"symbol"===L)this._pointLayerIds.add(C.id),this._map.addLayer(C);else if("line"===L){this._lineLayerIds.add(C.id);const A=this._getBeforePointLayerId();this._map.addLayer(C,A)}else{const A=this._getBeforeLineLayerId()??this._getBeforePointLayerId();this._map.addLayer(C,A)}F&&this._setLayerEvents(h,C)}_updateLayerVisibility(h,C){if(!this._map)return;const F=this._sourceLayers[h];F&&this._map.setLayoutProperty(F.layer.id,"visibility",C?"visible":"none")}getLayer(h){return this._layers$.getValue().find(C=>C.id===h)}updateLayer(h,C){const L=this._layers$.getValue().map(A=>{if(A.id===h){const W={...A,...C};return void 0!==C.visible&&this._updateLayerVisibility(h.toString(),C.visible),W}return A});this._layers$.next(L)}toggleAllLayers(){const h=this._layers$.getValue(),F=!h.some(A=>A.visible),L=h.map(A=>(this._updateLayerVisibility(A.id.toString(),F),{...A,visible:F}));this._layers$.next(L)}getVisibleLayersCount(){return this._layers$.getValue().filter(h=>h.visible).length}getTotalLayersCount(){return this._layers$.getValue().length}hasLayer(h){return this._layers$.getValue().some(C=>C.id===h)}fitGeoJSONBounds(h,C=50,F=!0,L=19){this._fitGeoJSONBounds(h,C,F,L)}fitLayerBounds(h,C=50){const F=this._layers$.getValue().find(L=>L.id===h);!F||!F.collection||!this._map||("features"in F.collection?this._fitGeoJSONBounds(F.collection,C):console.warn("Layer collection is not a FeatureCollection, cannot fit bounds."))}fitAllVisibleLayers(h=50){const C=this._layers$.getValue().filter(W=>W.visible&&W.collection);if(0===C.length||!this._map)return;const F=C.flatMap(W=>{const Z=W.collection;return Z&&"features"in Z&&Array.isArray(Z.features)?Z.features:[]}),L=new l.o(F),A=b(L);A&&(L.bbox=A),this._fitGeoJSONBounds(L,h)}clearAllLayers(){if(this._map){for(const[h,C]of Object.entries(this._layerGroups))C.forEach(F=>{this._map.getLayer(F)&&this._map.removeLayer(F)}),this._map.getSource(h)&&this._map.removeSource(h);for(const h of this._sourceIds)this._layerGroups[h]||this._deleteSourceIfExists(h)}this._sourceIds=[],this._sourceLayers={},this._sources={},this._attachedListeners=[],this._layerGroups={},this._layerClickable={},this._layers$.next([])}reapplyLayers(){this._map&&(Object.keys(this._sources).forEach(h=>{this._deleteSourceIfExists(h),this._map.addSource(h,this._sources[h]);const C=this._sourceLayers[h];if(C){this._map.addLayer(C.layer);const F=this._layers$.getValue().find(L=>L.id===h);F&&this._updateLayerVisibility(h,F.visible)}}),this._reattachAllLayerEvents())}_extractColorFromLayer(h){if("paint"in h&&"object"==typeof h.paint){const C=h.paint;return C["circle-color"]||C["fill-color"]||C["line-color"]||""}return""}_fitGeoJSONBounds(h,C=50,F=!0,L=19){if(!this._map)return void console.warn("Map not initialized when trying to fit bounds");if(!h.features||0===h.features.length)return void console.warn("No features to fit bounds to");let A=h.bbox;if(!A){const W=b(h);if(!W)return void console.warn("Failed to calculate bbox for GeoJSON");h.bbox=W,A=W}if(A&&4===A.length)try{this._map.fitBounds([[A[0],A[1]],[A[2],A[3]]],{padding:C,maxZoom:L,animate:F})}catch(W){console.error("Error fitting bounds:",W)}}_deleteSourceIfExists(h){if(!this._map||!this._map.getSource(h))return;const F=this._layerGroups[h];if(F)F.forEach(L=>{this._map.getLayer(L)&&this._map.removeLayer(L)});else{const L=Object.values(this._sourceLayers).find(A=>"source"in A.layer&&A.layer.source===h);L&&this._map.getLayer(L.layer.id)&&(this._map.removeLayer(L.layer.id),this._attachedListeners=this._attachedListeners.filter(A=>A!==L.layer.id))}this._map.removeSource(h)}_setLayerEvents(h,C){if(!this._map)return;const F=C.id.endsWith("-fill"),L=C.id.endsWith("-stroke"),A=F?C.id.replace("-fill",""):L?C.id.replace("-stroke",""):C.id;if(F||L){const J=`${A}-stroke`;this._layerClickable[`${A}-fill`]=!0,this._layerClickable[J]=!0}if(!this._layerClickable[C.id])return;const W=[];if(F||L){const Z=`${A}-fill`,J=`${A}-stroke`;this._map.getLayer(Z)&&W.push(Z),this._map.getLayer(J)&&W.push(J)}else W.push(C.id);W.forEach(Z=>{this._attachedListeners.includes(Z)||(this._map.on("click",Z,J=>{if(!J.features||this._processedClickEvents.has(J.originalEvent))return;const oe=J.features[0],ye=oe.properties;if(ye&&!ye.cluster){const fe=this.getLayer(h)||this.getLayer(A)||this.getLayer(Z);if(fe){const he={...oe,geometry:oe.geometry};if(fe.collection&&"features"in fe.collection){const me=fe.collection.features.find(ne=>ne.geometry.type===oe.geometry?.type&&JSON.stringify(ne.properties)===JSON.stringify(oe.properties));me&&me.id&&(he.id=me.id)}this._processedClickEvents.add(J.originalEvent),this.clickedFeature.next({feature:he,event:J.originalEvent,layer:fe,lngLat:J.lngLat})}}}),this._map.on("mouseenter",Z,J=>{if(this._hoverSequence++,this._clearHoverTimeout&&(clearTimeout(this._clearHoverTimeout),this._clearHoverTimeout=void 0),!J.features)return;const oe=J.features[0],ye=oe.properties,fe={...oe,geometry:oe.geometry};if(ye&&!ye.cluster){const he=this.getLayer(h)||this.getLayer(A)||this.getLayer(Z);if(he){if(he.collection&&"features"in he.collection){const me=he.collection.features.find(ne=>ne.geometry.type===oe.geometry?.type&&JSON.stringify(ne.properties)===JSON.stringify(oe.properties));me&&me.id&&(fe.id=me.id)}this.hoveredFeature.next({feature:fe,event:J.originalEvent,layer:he,lngLat:J.lngLat})}this._hoveredFeature.set(fe)}}),this._map.on("mouseleave",Z,()=>{const J=this._hoverSequence;this._clearHoverTimeout=window.setTimeout(()=>{this._hoverSequence===J&&(this._hoveredFeature.set(void 0),this.hoveredFeature.next(void 0)),this._clearHoverTimeout=void 0},50)}),this._map.on("click",Z,J=>{if(!J.features)return;const oe=J.features[0].properties;if(oe&&oe.cluster){const ye=this._map?.getZoom();ye&&this._map?.flyTo({center:J.lngLat,zoom:ye+1})}}),this._attachedListeners.push(Z))})}_reattachAllLayerEvents(){this._attachedListeners=[],Object.keys(this._sourceLayers).forEach(h=>{const C=this._sourceLayers[h];C&&this._setLayerEvents(h,C.layer)})}static \u0275fac=function(C){return new(C||k)};static \u0275prov=y.jDH({token:k,factory:k.\u0275fac})}return k})()},8017(ae,Q,u){"use strict";u.d(Q,{T:()=>St});var I=u(467),y=u(5802),x=u(7705),z=u(2271),s=u(5547),D=u(9769),l=u(5970),R=u(6170),P=u(5949),g=u(2843),a=u(3646),p=u(9079),M=u(1413),O=u(2306),B=u(7089),b=u(9352),w=u(5381),U=u(5187),k=u(5971),X=u(3319);function h(_,S){if(1&_){const c=s.RV6();s.j41(0,"cue-button",5),s.nI1(1,"transloco"),s.bIt("click",function(){y.eBV(c);const v=s.XpG(2);return y.Njj(v.handleZoomFit())}),s.nrm(2,"cue-button-icon",9),s.k0s()}2&_&&s.Y8G("cueTooltip",s.bMT(1,1,"components.map.tooltipZoomFit"))}function C(_,S){if(1&_){const c=s.RV6();s.j41(0,"cue-flexcontainer",3)(1,"cue-button",5),s.nI1(2,"transloco"),s.bIt("click",function(){y.eBV(c);const v=s.XpG();return y.Njj(v.handleZoomOut())}),s.nrm(3,"cue-button-icon",6),s.k0s(),s.j41(4,"cue-button",5),s.nI1(5,"transloco"),s.bIt("click",function(){y.eBV(c);const v=s.XpG();return y.Njj(v.handleZoomIn())}),s.nrm(6,"cue-button-icon",7),s.k0s(),s.nVh(7,h,3,3,"cue-button",8),s.k0s()}if(2&_){const c=s.XpG();s.R7$(),s.Y8G("cueTooltip",s.bMT(2,3,"components.map.tooltipZoomOut")),s.R7$(3),s.Y8G("cueTooltip",s.bMT(5,5,"components.map.tooltipZoomIn")),s.R7$(3),s.vxM(c.displayZoomFit()?7:-1)}}function F(_,S){if(1&_){const c=s.RV6();s.j41(0,"cue-button",10),s.nI1(1,"transloco"),s.nI1(2,"transloco"),s.mxI("selectedChange",function(v){y.eBV(c);const V=s.XpG();return s.DH7(V.layersVisible,v)||(V.layersVisible=v),y.Njj(v)}),s.nrm(3,"cue-button-icon",11),s.k0s()}if(2&_){const c=s.XpG();s.AVh("border-left",c.options().displayZoom&&c.displayLayerToggle()),s.Y8G("cueTooltip",c.layersVisible()?s.bMT(1,6,"components.map.tooltipHideLayers"):s.bMT(2,8,"components.map.tooltipShowLayers"))("toggleButton",!0),s.R50("selected",c.layersVisible),s.R7$(3),s.Y8G("icon",c.layersVisible()?"layers-clear":"layers")}}function L(_,S){if(1&_){const c=s.RV6();s.j41(0,"cue-button",10),s.nI1(1,"transloco"),s.nI1(2,"transloco"),s.mxI("selectedChange",function(v){y.eBV(c);const V=s.XpG();return s.DH7(V.geoFenceDrawEnabled,v)||(V.geoFenceDrawEnabled=v),y.Njj(v)}),s.nrm(3,"cue-button-icon",12),s.k0s()}if(2&_){const c=s.XpG();s.AVh("border-left",c.options().displayGeofenceDraw),s.Y8G("cueTooltip",c.geoFenceDrawEnabled()?s.bMT(1,5,"components.map.tooltipEndDrawGeofence"):s.bMT(2,7,"components.map.tooltipDrawGeofence"))("toggleButton",!0),s.R50("selected",c.geoFenceDrawEnabled)}}let A=(()=>{class _{_service=(0,y.WQX)(P.u);layerService=(0,y.WQX)(a.B);mapLayers=(0,p.ot)(this.layerService.layers);options=(0,x.hFB)(new O.AA);zoom=(0,x.geq)(1);rotate=(0,x.CGW)();geoFenceDrawEnabled=(0,x.geq)(!1);layersVisible=(0,x.geq)(!1);hasLayers=(0,z.EW)(()=>void 0!==this.mapLayers()&&this.mapLayers().length>0);displayLayerToggle=(0,z.EW)(()=>this.options().displayLayerToggle&&this.hasLayers());displayZoomFit=(0,z.EW)(()=>this.options().displayZoom&&this.hasLayers());selectMenuPositions=(0,z.EW)(()=>"top"===this.options().position?"bottomleft":"topleft");handleZoomIn(){this._service.zoomIn()}handleZoomOut(){this._service.zoomOut()}handleZoomFit(){this._service.fitGeoJSONBBOX(void 0,.01)}static \u0275fac=function(d){return new(d||_)};static \u0275cmp=s.VBU({type:_,selectors:[["cue-map-toolbar"]],inputs:{options:[1,"options"],zoom:[1,"zoom"],geoFenceDrawEnabled:[1,"geoFenceDrawEnabled"],layersVisible:[1,"layersVisible"]},outputs:{zoom:"zoomChange",rotate:"rotate",geoFenceDrawEnabled:"geoFenceDrawEnabledChange",layersVisible:"layersVisibleChange"},decls:6,vars:4,consts:[["justify","center",1,"container"],[1,"toolbar",3,"padded"],["align","center"],["align","center","gap","s"],["size","xs","variant","ghost",3,"border-left","cueTooltip","toggleButton","selected"],["size","xs","variant","tertiary",3,"click","cueTooltip"],["icon","zoom-out"],["icon","zoom-in"],["size","xs","variant","tertiary",3,"cueTooltip"],["icon","zoom-fit"],["size","xs","variant","ghost",3,"selectedChange","cueTooltip","toggleButton","selected"],[3,"icon"],["icon","polygon"]],template:function(d,v){1&d&&(s.j41(0,"cue-flexcontainer",0)(1,"cue-card",1)(2,"cue-flexcontainer",2),s.nVh(3,C,8,7,"cue-flexcontainer",3),s.nVh(4,F,4,10,"cue-button",4),s.nVh(5,L,4,9,"cue-button",4),s.k0s()()()),2&d&&(s.R7$(),s.Y8G("padded",!1),s.R7$(2),s.vxM(v.options().displayZoom?3:-1),s.R7$(),s.vxM(v.displayLayerToggle()?4:-1),s.R7$(),s.vxM(v.options().displayGeofenceDraw?5:-1))},dependencies:[w.n,U.Z,k.$,X.a,B.d,b.Kj],styles:[".container[_ngcontent-%COMP%]{width:100%;pointer-events:none}.toolbar[_ngcontent-%COMP%]{pointer-events:all;padding:5px 10px}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return _})();var W=u(7023),Z=u(1024),J=u(9421);function oe(_,S){if(1&_&&s.nrm(0,"cue-key-val",1),2&_){const c=S.$implicit;s.Y8G("key",c.key)("val",c.val)}}let ye=(()=>{class _{props=(0,x.hFB)(null);keyVals=(0,z.EW)(()=>{const c=this.props();return c?Object.entries(c).map(([d,v])=>({key:d,val:String(v)})):[]});static \u0275fac=function(d){return new(d||_)};static \u0275cmp=s.VBU({type:_,selectors:[["cue-props-panel"]],inputs:{props:[1,"props"]},decls:4,vars:0,consts:[[2,"height","100%","overflow-y","auto"],[3,"key","val"]],template:function(d,v){1&d&&(s.j41(0,"cue-flexcontainer",0)(1,"cue-key-val-list"),s.Z7z(2,oe,1,2,"cue-key-val",1,s.Vm6),s.k0s()()),2&d&&(s.R7$(2),s.Dyx(v.keyVals()))},dependencies:[Z.p,J.F,w.n],encapsulation:2,changeDetection:0})}return _})();var fe=u(7517);let he=(()=>{class _{layerService=(0,y.WQX)(a.B);mapLayers=(0,p.ot)(this.layerService.layers);layerDefs=(0,z.EW)(()=>{const c=this.mapLayers();return c?c.map(d=>({label:d.label,color:d.color??"#000000",visible:d.visible,category:d.category})):[]});updateSingle(c){const d=this.mapLayers()?.find(v=>v.label===c.label);d&&this.layerService.toggleVisibility(d.id)}updateAll(c){const d=this.mapLayers();if(d)for(const v of d)v.visible===c&&this.layerService.toggleVisibility(v.id)}static \u0275fac=function(d){return new(d||_)};static \u0275cmp=s.VBU({type:_,selectors:[["cue-layer-panel"]],decls:1,vars:1,consts:[[3,"layerChange","visibilityAll","layers"]],template:function(d,v){1&d&&(s.j41(0,"cue-layer-legend",0),s.bIt("layerChange",function(Y){return v.updateSingle(Y)})("visibilityAll",function(Y){return v.updateAll(Y)}),s.k0s()),2&d&&s.Y8G("layers",v.layerDefs())},dependencies:[D.MD,fe.P],encapsulation:2})}return _})();var me=u(140),ne=u(6986);function ve(_){const S=_.flatMap(c=>{const d=function De(_){switch(_.type){case"Point":return[_.coordinates[0],_.coordinates[1]];case"MultiPoint":{if(!_.coordinates.length)return null;const S=_.coordinates.reduce((c,d)=>[c[0]+d[0],c[1]+d[1]],[0,0]);return[S[0]/_.coordinates.length,S[1]/_.coordinates.length]}case"LineString":{if(!_.coordinates.length)return null;const S=Math.floor(_.coordinates.length/2);return[_.coordinates[S][0],_.coordinates[S][1]]}case"MultiLineString":{if(!_.coordinates.length||!_.coordinates[0].length)return null;const S=_.coordinates[0],c=Math.floor(S.length/2);return[S[c][0],S[c][1]]}case"Polygon":{if(!_.coordinates.length||!_.coordinates[0].length)return null;const S=_.coordinates[0],c=S.reduce((d,v)=>[d[0]+v[0],d[1]+v[1]],[0,0]);return[c[0]/S.length,c[1]/S.length]}case"MultiPolygon":{if(!_.coordinates.length||!_.coordinates[0]?.length||!_.coordinates[0][0]?.length)return null;const S=_.coordinates[0][0],c=S.reduce((d,v)=>[d[0]+v[0],d[1]+v[1]],[0,0]);return[c[0]/S.length,c[1]/S.length]}default:return null}}(c.geometry);return d?[{type:"Feature",id:c.id,geometry:{type:"Point",coordinates:d},properties:{...c.properties??{},_isCentroid:!0}}]:[]});return[..._,...S]}const ut=["rgba(255, 0, 0, 0.5)","rgba(0, 0, 255, 0.5)","rgba(0, 255, 0, 0.5)","rgba(255, 165, 0, 0.5)","rgba(128, 0, 128, 0.5)","rgba(255, 192, 203, 0.5)","rgba(255, 255, 0, 0.5)"];function _t(_){const S=_.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d\.]+))?\)/);if(S)return{r:parseInt(S[1]),g:parseInt(S[2]),b:parseInt(S[3]),a:S[4]?parseFloat(S[4]):1};const c=_.match(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/);if(c){const d=c[1];return{r:parseInt(3===d.length?d[0]+d[0]:d.slice(0,2),16),g:parseInt(3===d.length?d[1]+d[1]:d.slice(2,4),16),b:parseInt(3===d.length?d[2]+d[2]:d.slice(4,6),16),a:1}}return{r:0,g:0,b:0,a:1}}function je(_){if(0===_.length)return ut[0];if(1===_.length)return _[0].color;const S=_.map(se=>({...se,totalWeight:se.featureCount*se.weight})).sort((se,de)=>de.totalWeight-se.totalWeight),c=S.reduce((se,de)=>se+de.totalWeight,0),d=S[0];if(d.totalWeight/c>.6)return d.color;const v=S.slice(0,Math.min(3,S.length)),V=v.reduce((se,de)=>se+de.totalWeight,0);let Y=0,q=0,le=0,ge=0;for(const se of v){const de=_t(se.color),_e=se.totalWeight/V;Y+=de.r*_e,q+=de.g*_e,le+=de.b*_e,ge+=de.a*_e}return function dt(_,S,c,d=1){return d<1?`rgba(${Math.round(_)}, ${Math.round(S)}, ${Math.round(c)}, ${d})`:`rgb(${Math.round(_)}, ${Math.round(S)}, ${Math.round(c)})`}(Y,q,le,ge)}function He(_,S,c,d){if(!d||"Point"!==c&&"MultiPoint"!==c)return[{color:S,weight:1,featureCount:_.length}];const v=_.length;if(v<10)return[{color:S,weight:1,featureCount:v}];let V=0,Y=0,q=0;v>=750?(V=Math.floor(.1*v),Y=Math.floor(.3*v),q=v-V-Y):v>=100?(Y=Math.floor(.4*v),q=v-Y):(q=Math.floor(.8*v),Y=v-q);const le=[];return q>0&&le.push({color:S,weight:1,featureCount:q}),Y>0&&le.push({color:"#f28cb1",weight:2,featureCount:Y}),V>0&&le.push({color:"#e2f552",weight:3,featureCount:V}),le}function Qe(_,S,c,d,v,V){const Y=Array.isArray(d)?d:[d];(0,ne.j5)(v)?_.layerService.loadGeoJSONLayerGroup(S,c,Y,{cluster:!1,zoomToFit:V.zoomToFit,visible:V.visible,label:V.label,color:V.color}):Y.length>1||("Point"===v||"MultiPoint"===v)&&Array.isArray(Y)&&Y.length>1?_.layerService.loadGeoJSONLayerGroup(S,c,Y,{cluster:(0,ne.n7)(v,V.cluster),zoomToFit:V.zoomToFit,visible:V.visible,label:V.label,color:V.color}):_.loadGeoJSON(S,c,Y[0],(0,ne.n7)(v,V.cluster),V.zoomToFit)}var vt=u(6756),bt=u(356),ft=u(6279);const Xe=["map"],qe=_=>({position:"bottomleft",hoveredFeature:_}),Et=(_,S)=>S.label;function Mt(_,S){if(1&_){const c=s.RV6();s.j41(0,"cue-menu-item",6),s.bIt("click",function(v){const V=y.eBV(c).$implicit;return y.Njj(V.action(v))}),s.EFF(1),s.k0s()}if(2&_){const c=S.$implicit;s.R7$(),s.JRh(c.label)}}function Ct(_,S){if(1&_&&(s.j41(0,"cue-menu-wrap"),s.Z7z(1,Mt,2,1,"cue-menu-item",null,Et),s.k0s()),2&_){const c=s.XpG();s.R7$(),s.Dyx(c.contextMenuItems())}}function et(_,S){if(1&_&&(s.j41(0,"span"),s.EFF(1),s.k0s()),2&_){const c=s.XpG();s.R7$(),s.JRh(c.mapService.error())}}function Lt(_,S){if(1&_){const c=s.RV6();s.j41(0,"cue-map-toolbar",8),s.mxI("zoomChange",function(v){y.eBV(c);const V=s.XpG(2);return s.DH7(V.zoom,v)||(V.zoom=v),y.Njj(v)})("layersVisibleChange",function(v){y.eBV(c);const V=s.XpG(2);return s.DH7(V.layerPanelVisible,v)||(V.layerPanelVisible=v),y.Njj(v)})("geoFenceDrawEnabledChange",function(v){y.eBV(c);const V=s.XpG(2);return s.DH7(V.geoFenceDrawEnabled,v)||(V.geoFenceDrawEnabled=v),y.Njj(v)}),s.k0s()}if(2&_){const c=s.XpG(),d=s.XpG();s.Aen(d.toolbarStyle()),s.Y8G("options",c),s.R50("zoom",d.zoom)("layersVisible",d.layerPanelVisible)("geoFenceDrawEnabled",d.geoFenceDrawEnabled)}}function Tt(_,S){1&_&&s.nVh(0,Lt,1,6,"cue-map-toolbar",7),2&_&&s.vxM(S.hidden?-1:0)}function tt(_,S){1&_&&(s.j41(0,"cue-card",4),s.nrm(1,"cue-layer-panel"),s.k0s())}function Rt(_,S){1&_&&(s.j41(0,"cue-card",5),s.nrm(1,"cue-props-panel",9),s.k0s()),2&_&&(s.R7$(),s.Y8G("props",S))}function nt(_,S){if(1&_&&(s.j41(0,"div",11),s.EFF(1),s.k0s()),2&_){const c=S,d=s.XpG();s.xc7("left",c.x,"px")("top",c.y,"px"),s.R7$(),s.SpI(" ",d," ")}}function Pt(_,S){if(1&_&&s.nVh(0,nt,2,5,"div",10),2&_){let c;const d=s.XpG();s.vxM((c=d.hoveredTooltipPosition())?0:-1,c)}}let St=(()=>{class _{mapService=(0,y.WQX)(P.u);drawService=(0,y.WQX)(g.M);settings=(0,x.hFB)(new O.yY);center=(0,x.hFB)([8.5,47.4]);layerPanelVisible=(0,x.geq)(!1);zoom=(0,x.geq)(2);instruction=(0,x.geq)("Hello");layers=(0,x.hFB)([]);zoomToFit=(0,x.hFB)(!0);zoomToFitEachLayer=(0,x.hFB)(!1);splitLayersByGeometryType=(0,x.hFB)(!0);maxClickZoom=(0,x.hFB)(1/0);borderRadius=(0,x.hFB)("0");geoFenceDrawEnabled=(0,x.geq)(!1);contextMenuItemsBefore=(0,x.hFB)([]);contextMenuItemsAfter=(0,x.hFB)([]);immidiateDrawMode=(0,x.hFB)(void 0);hoverTooltipFn=(0,x.hFB)(null);mapReady=(0,x.CGW)();clickedMap=(0,x.CGW)();pannedMap=(0,x.CGW)();panningMap=(0,x.CGW)();zoomedMap=(0,x.CGW)();clickedFeature=(0,x.CGW)();hoveredFeature=(0,x.CGW)();drawEvent=(0,x.CGW)();layersSaturated=(0,z.EW)(()=>this.layers().map((c,d)=>{const v={...c};return v.color||(v.color=vt.BK[d]),v}));toolbarOptions=(0,z.EW)(()=>this.settings().toolbar);featureBeingHovered=(0,y.vPA)(void 0);lastClickedFeatureEvent=(0,y.vPA)(void 0);lastHoveredFeatureEvent=(0,y.vPA)(void 0);shownProperties=(0,y.vPA)(null);hoveredTooltipLabel=(0,z.EW)(()=>{const c=this.hoverTooltipFn();if(!c)return null;const d=this.lastHoveredFeatureEvent();return d?c(d.feature.properties??{})??null:null});hoveredTooltipPosition=(0,z.EW)(()=>{if(!this.hoveredTooltipLabel())return null;const c=this.lastHoveredFeatureEvent();if(!c)return null;const d=this.mapService.map;if(!d)return null;const v=d.project([c.lngLat.lng,c.lngLat.lat]);return{x:v.x,y:v.y}});_featureClickedThisTick=!1;_previousLayersHash=(0,y.vPA)("");_userHasInteracted=(0,y.vPA)(!1);toolbarStyle=(0,z.EW)(()=>{const c=this.toolbarOptions();return{position:"absolute",left:c.margin,right:c.margin,["top"===c.position?"top":"bottom"]:c.margin,"z-index":"10",display:"flex","justify-content":"center"}});contextMenuEnabled=(0,z.EW)(()=>{const c=this.contextMenuItems().length>0,d=this.featureBeingHovered(),v=this.lastClickedFeatureEvent();return c&&(void 0!==d||void 0!==v)});contextMenuItems=(0,z.EW)(()=>{const c=this.lastHoveredFeatureEvent(),d=this.lastClickedFeatureEvent(),V=(c?.feature||d?.feature)?.properties||null,Y=V?Object.fromEntries(Object.entries(V).filter(([_e])=>!_e.startsWith("_"))):null,q=c?.lngLat||d?.lngLat||null,ge=[...this.contextMenuItemsBefore()||[]],se=this.settings().contextMenu;Y&&Object.keys(Y).length>0&&se.showProperties&&ge.push({label:"Show properties",action:()=>{this.shownProperties.update(()=>Y)}}),q&&se.showFlyTo&&ge.push({label:"Fly to feature",action:()=>{this.mapService.flyTo([q.lng,q.lat],this.zoom())}});const de=this.contextMenuItemsAfter()||[];return[...ge,...de]});_mapContainer;_destroy$=new M.B;constructor(){this._subscribeToServiceOutputs(),this._setupEffects(),(0,s.mal)(()=>{this._destroy$.closed||this._tryInitializeMap()})}ngOnDestroy(){this._destroy$.next(),this._destroy$.complete(),this.drawService.destroy(),this.mapService.destroy()}_subscribeToServiceOutputs(){this.mapService.mapReady.pipe((0,p.pQ)()).subscribe(()=>this.mapReady.emit()),this.mapService.clickedMap.pipe((0,p.pQ)()).subscribe(c=>{this._featureClickedThisTick||(this.lastClickedFeatureEvent.update(()=>{}),this.lastHoveredFeatureEvent.update(()=>{}),this.featureBeingHovered.update(()=>{}),this.clickedMap.emit(c),this.shownProperties.update(()=>null))}),this.mapService.pannedMap.pipe((0,p.pQ)()).subscribe(c=>{this._userHasInteracted.set(!0),this.pannedMap.emit(c)}),this.mapService.panningMap.pipe((0,p.pQ)()).subscribe(c=>this.panningMap.emit(c)),this.mapService.zoomedMap.pipe((0,p.pQ)()).subscribe(c=>{this._userHasInteracted.set(!0),this.zoomedMap.emit(this.mapService.getZoom()??this.zoom())}),this.mapService.clickedFeature.pipe((0,p.pQ)()).subscribe(c=>{this._featureClickedThisTick=!0,queueMicrotask(()=>{this._featureClickedThisTick=!1}),this.lastClickedFeatureEvent.update(()=>c),this.clickedFeature.emit(c);const d=c.feature?.geometry?.type,v="Point"===d||"MultiPoint"===d,V=this.mapService.getZoom()??0,Y=this.contextMenuItems().length>0;v&&!Y&&V<this.maxClickZoom()&&this.mapService.zoomToCoordinate(c.lngLat)}),this.mapService.hoveredFeature.pipe((0,p.pQ)()).subscribe(c=>{this.featureBeingHovered.update(()=>c?.feature),this.lastHoveredFeatureEvent.update(()=>c),this.hoveredFeature.emit(c)})}_setupEffects(){var c=this;(0,y.QZP)(()=>{"polygon"===this.immidiateDrawMode()&&(this.geoFenceDrawEnabled.set(!0),setTimeout(()=>{this.drawService.setDrawMode(!0,this.settings().toolbar.clearGeofenceAfterDraw)},500))}),(0,y.QZP)(()=>this.mapService.flyTo(this.center(),this.zoom())),(0,y.QZP)(()=>{const v=this.settings()?.mapboxToken;v&&"string"==typeof v&&""!==v.trim()&&!this.mapService.isMapReady()&&this._tryInitializeMap()}),(0,y.QZP)(()=>{const d=this.geoFenceDrawEnabled();this.drawService.setDrawMode(d,this.settings().toolbar.clearGeofenceAfterDraw)}),(0,y.QZP)(()=>{const d=this.drawService.drawEvent();void 0!==d&&this.drawEvent.emit(d)}),(0,y.QZP)((0,I.A)(function*(){const d=c.layersSaturated();if(!d||0===d.length)return;const v=c._createLayersHash(d);if(v===c._previousLayersHash())return;c._previousLayersHash.set(v),yield c.mapService.waitForMapReady(),c.mapService.clearLayers();const Y=c.zoomToFitEachLayer();d.forEach((q,le)=>{!function Be(_,S,c,d,v,V,Y){const q=S.collection,le=S.color??ut[c];let ge;ge="geometries"in q?function Re(_){const S=_.geometries.map((d,v)=>({type:"Feature",geometry:d,properties:{},id:_.id?`${_.id}_${v}`:void 0})),c=new me.o(S);return c.id=_.id,c.bbox=_.bbox,c}(q):q;const se=function Ae(_){const S=[];return _.forEach(c=>{c.geometry&&"GeometryCollection"===c.geometry.type?c.geometry.geometries.forEach((d,v)=>{S.push({type:"Feature",geometry:d,properties:c.properties||{},id:c.id?`${c.id}_${v}`:void 0})}):S.push(c)}),S}(ge.features),de=new me.o(se);de.id=ge.id,de.bbox=ge.bbox;let _e=le;if(!V){const H=S.id.toString(),ee=se[0]?.geometry?.type||"Point";_e=je(He(se,le,ee,d));let be=Y(H,ee,_e,H),Se=de;const ke="Point"!==ee&&"MultiPoint"!==ee,Me=(0,ne.j5)(ee),pe=(0,ne.dx)(ee);if(d&&ke&&!Me&&!pe&&be){const ot=Array.isArray(be)?be:[be],ie=ve(se);Se=new me.o(ie),Se.id=de.id,Se.bbox=de.bbox,be=[(0,ne.g8)(`${H}-centroid`,H,_e),...ot.map(it=>({...it,minzoom:ne.A4}))]}return void(be&&Qe(_,H,Se,be,ee,{cluster:d,zoomToFit:v,visible:!0,label:S.label||S.id.toString(),color:_e}))}if(V){const H=new Set(se.map(re=>re.geometry.type)),ee=[];return H.forEach(re=>{const be=`${S.id.toString()}-${re}`,Se=se.filter(pe=>pe.geometry.type===re),ke=He(Se,le,re,d);ee.push(...ke);let Me=Y(be,re,le,be);if(Me){let pe=new me.o(Se);pe.id=de.id,pe.bbox=de.bbox;const ot="Point"!==re&&"MultiPoint"!==re,ie=(0,ne.j5)(re),rt=(0,ne.dx)(re);if(d&&ot&&!ie&&!rt){const it=Array.isArray(Me)?Me:[Me],It=ve(Se);pe=new me.o(It),pe.id=de.id,pe.bbox=de.bbox,Me=[(0,ne.g8)(`${be}-centroid`,be,le),...it.map(st=>({...st,minzoom:ne.A4}))]}Qe(_,be,pe,Me,re,{cluster:d,zoomToFit:v,visible:!0,label:H.size>1?`${S.label||S.id} (${re})`:`${S.label||S.id}`,color:le})}}),void(ee.length>0&&(_e=je(ee),_.layerService.getLayer(S.id.toString())&&_.layerService.updateLayer(S.id.toString(),{color:_e})))}const Ee=new Map;se.forEach(H=>{const ee=H.geometry.type;let re;re="Point"===ee||"MultiPoint"===ee?"Point":"LineString"===ee||"MultiLineString"===ee?"LineString":"Polygon"===ee||"MultiPolygon"===ee?"Polygon":ee,Ee.has(re)||Ee.set(re,[]),Ee.get(re).push(ee)});const Ne=[];Ee.forEach((H,ee)=>{const re=`${S.id.toString()}-${ee}`,be=se.filter(Me=>{const pe=Me.geometry.type;return"Point"===ee?"Point"===pe||"MultiPoint"===pe:"LineString"===ee?"LineString"===pe||"MultiLineString"===pe:"Polygon"===ee?"Polygon"===pe||"MultiPolygon"===pe:pe===ee}),Se=He(be,le,ee,d);Ne.push(...Se);const ke=Y(re,ee,le,re);if(ke){const Me=new me.o(be);Me.id=de.id,Me.bbox=de.bbox,Qe(_,re,Me,ke,ee,{cluster:d,zoomToFit:v,visible:!0,label:Ee.size>1?`${S.label||S.id} (${ee})`:`${S.label||S.id}`,color:le})}}),Ne.length>0&&(_e=je(Ne),_.layerService.getLayer(S.id.toString())&&_.layerService.updateLayer(S.id.toString(),{color:_e}))}(c.mapService,q,le,q.cluster,Y&&q.zoomToFit,c.splitLayersByGeometryType(),ne.Ln)}),c.zoomToFit()&&!Y&&!c._userHasInteracted()&&c.mapService.fitGeoJSONBBOX()}))}_tryInitializeMap(){if(this._destroy$.closed)return;const d=this.settings()?.mapboxToken,v=d&&"string"==typeof d&&""!==d.trim(),V=this._mapContainer,Y=!this.mapService.isMapReady();v&&V&&Y&&(this._userHasInteracted.set(!1),this.mapService.init(this._mapContainer.nativeElement,d,this.center(),this.zoom(),this.borderRadius()))}_createLayersHash(c){return c.map(d=>{const v=d.collection;let V=0;return v&&"FeatureCollection"===v.type&&"features"in v&&(V=Array.isArray(v.features)?v.features.length:0),`${d.id}|${d.label}|${d.visible}|${V}`}).join("::")}static \u0275fac=function(d){return new(d||_)};static \u0275cmp=s.VBU({type:_,selectors:[["cue-map"]],viewQuery:function(d,v){if(1&d&&s.GBs(Xe,5),2&d){let V;s.mGM(V=s.lsd())&&(v._mapContainer=V.first)}},hostAttrs:["data-component","cue-map-main"],inputs:{settings:[1,"settings"],center:[1,"center"],layerPanelVisible:[1,"layerPanelVisible"],zoom:[1,"zoom"],instruction:[1,"instruction"],layers:[1,"layers"],zoomToFit:[1,"zoomToFit"],zoomToFitEachLayer:[1,"zoomToFitEachLayer"],splitLayersByGeometryType:[1,"splitLayersByGeometryType"],maxClickZoom:[1,"maxClickZoom"],borderRadius:[1,"borderRadius"],geoFenceDrawEnabled:[1,"geoFenceDrawEnabled"],contextMenuItemsBefore:[1,"contextMenuItemsBefore"],contextMenuItemsAfter:[1,"contextMenuItemsAfter"],immidiateDrawMode:[1,"immidiateDrawMode"],hoverTooltipFn:[1,"hoverTooltipFn"]},outputs:{layerPanelVisible:"layerPanelVisibleChange",zoom:"zoomChange",instruction:"instructionChange",geoFenceDrawEnabled:"geoFenceDrawEnabledChange",mapReady:"mapReady",clickedMap:"clickedMap",pannedMap:"pannedMap",panningMap:"panningMap",zoomedMap:"zoomedMap",clickedFeature:"clickedFeature",hoveredFeature:"hoveredFeature",drawEvent:"drawEvent"},features:[s.Jv_([P.u,g.M,a.B])],decls:10,vars:10,consts:[["hoveringFeature",""],["map",""],["direction","row",1,"container"],["id","map","cueResized","","cueDarkMode","","trigger","leftclick",3,"darkModeChange","resized","cueContextMenu","contextMenuData","cueContextEnabled"],[1,"layer-panel"],[1,"props-panel"],[3,"click"],[3,"options","style","zoom","layersVisible","geoFenceDrawEnabled"],[3,"zoomChange","layersVisibleChange","geoFenceDrawEnabledChange","options","zoom","layersVisible","geoFenceDrawEnabled"],[3,"props"],[1,"hover-tooltip",3,"left","top"],[1,"hover-tooltip"]],template:function(d,v){if(1&d&&(s.DNE(0,Ct,3,0,"ng-template",null,0,s.C5r),s.j41(2,"cue-flexcontainer",2)(3,"div",3,1),s.bIt("darkModeChange",function(Y){return v.mapService.setDarkMode(Y)})("resized",function(){return v.mapService.onParentResize()}),s.k0s(),s.nVh(5,et,2,1,"span"),s.nVh(6,Tt,1,1),s.nVh(7,tt,2,0,"cue-card",4),s.nVh(8,Rt,2,1,"cue-card",5),s.nVh(9,Pt,1,1),s.k0s()),2&d){let V,Y,q;const le=s.sdS(1);s.R7$(3),s.Y8G("cueContextMenu",le)("contextMenuData",s.eq3(8,qe,v.lastHoveredFeatureEvent()))("cueContextEnabled",v.contextMenuEnabled()),s.R7$(2),s.vxM(v.mapService.error()?5:-1),s.R7$(),s.vxM((V=v.toolbarOptions())?6:-1,V),s.R7$(),s.vxM(v.layerPanelVisible()?7:-1),s.R7$(),s.vxM((Y=v.shownProperties())?8:-1,Y),s.R7$(),s.vxM((q=v.hoveredTooltipLabel())?9:-1,q)}},dependencies:[D.MD,l.C,R.R,A,W.Q,bt.M,ft.D,w.n,ye,he,U.Z],styles:["#map[_ngcontent-%COMP%]{flex:1;min-height:0;border-radius:inherit;overflow:hidden}[_nghost-%COMP%]{display:flex;flex-direction:column;position:relative;width:100%;height:100%;min-height:400px;min-width:200px;flex:1 1 auto;align-self:stretch;box-sizing:border-box;overflow:hidden;border-radius:var(--cue-card-border-radius, inherit)}.mapboxgl-canvas-container[_ngcontent-%COMP%], .mapboxgl-canvas[_ngcontent-%COMP%]{border-radius:inherit!important}.mapboxgl-map[_ngcontent-%COMP%]{border-radius:inherit!important;overflow:hidden!important}.container[_ngcontent-%COMP%]{position:relative;width:100%;flex:1;min-height:0;overflow:hidden;display:flex;flex-direction:column}.props-panel[_ngcontent-%COMP%]{position:absolute;top:8px;right:8px;bottom:8px;z-index:10}.layer-panel[_ngcontent-%COMP%]{position:absolute;top:10px;left:10px;z-index:10}cue-map-toolbar[_ngcontent-%COMP%]{position:absolute;left:0;right:0;bottom:0;z-index:10;display:flex;justify-content:center}.hover-tooltip[_ngcontent-%COMP%]{position:absolute;background:var(--cue-menu-background-color);color:var(--cue-menu-foreground-color);box-shadow:var(--cue-menu-box-shadow);border:1px solid var(--cue-menu-border-color);padding:3px 8px;border-radius:4px;font-family:var(--cue-font-family);font-size:.75rem;line-height:1.4;pointer-events:none;white-space:nowrap;z-index:20;transform:translate(-50%,calc(-100% - 8px))}"]})}return _})()},5949(ae,Q,u){"use strict";u.d(Q,{u:()=>R});var I=u(467),y=u(5802),x=u(2271),z=u(1413),s=u(3646),D=u(2843),l=u(9079);let R=(()=>{class P{_map;_mapContainer;_isInitializing=!1;_mapReadyPromiseResolve;_mapReady=new Promise(a=>{this._mapReadyPromiseResolve=a});_emittedReady=!1;_firstThemeReceived=!1;_hoveredFeature=(0,y.vPA)(void 0);_layerService=(0,y.WQX)(s.B);_drawService=(0,y.WQX)(D.M);mapboxToken=(0,y.vPA)("");center=(0,y.vPA)([8.5,47.4]);zoom=(0,y.vPA)(2);borderRadius=(0,y.vPA)("0");mapReady=new z.B;clickedMap=new z.B;pannedMap=new z.B;panningMap=new z.B;zoomedMap=new z.B;error=(0,y.vPA)("");get clickedFeature(){return this._layerService.clickedFeature}get hoveredFeature(){return this._layerService.hoveredFeature}get layers(){return this._layerService.layers}get layersSignal(){return this._layerService.layersSignal}get layerService(){return this._layerService}get drawService(){return this._drawService}get drawEvent(){return this._drawService.drawEvent}_darkMode=(0,y.vPA)(this._getSystemColorPreference());_styleId=(0,x.EW)(()=>this._darkMode()?"madsholten/clwjh4xeu00q601pnczm07jq6":"madsholten/clwjh6ug900q701pn6eor8p51");get map(){return this._map}constructor(){this._layerService.hoveredFeature.pipe((0,l.pQ)()).subscribe(a=>{this._hoveredFeature.set(a?.feature)}),(0,y.QZP)(()=>{this._styleId(),this._firstThemeReceived?void 0!==this._map&&this._updateStyle().catch(a=>{console.error("Failed to update map style:",a)}):this._firstThemeReceived=!0})}destroy(){if(this._layerService?.clearAllLayers(),this._drawService?.destroy(),this._map)try{this._map.remove()}catch(a){console.warn("Error removing map:",a)}this._map=void 0,this._mapContainer&&(this._mapContainer.innerHTML="",this._mapContainer=void 0),this._isInitializing=!1,this._emittedReady=!1,this._mapReady=new Promise(a=>{this._mapReadyPromiseResolve=a})}isMapReady(){return void 0!==this._map&&this._emittedReady&&!this._isInitializing}waitForMapReady(){var a=this;return(0,I.A)(function*(){return a._mapReady})()}init(a,p,M,O,B){var b=this;return(0,I.A)(function*(){if(p&&""!==p.trim())if(b._map||b._isInitializing)console.warn("MapService: Map is already initialized or currently initializing");else{b._isInitializing=!0,b.mapboxToken.set(p),b.center.set(M),b.zoom.set(O),b.borderRadius.set(B),b._mapContainer=a,b._mapContainer&&(b._mapContainer.innerHTML="");try{yield b._loadMapboxCSS();const w=yield u.e(247).then(u.t.bind(u,1247,23)),U=w.default||w;if(!U||"function"!=typeof U.Map)throw new Error("Mapbox GL JS not properly loaded");U.accessToken=b.mapboxToken(),b._map=new U.Map({container:a,style:b._getMapStyleURL(),center:b.center(),zoom:b.zoom()}),b._applyBorderRadius(a),b._initEventListeners(b._map)}catch(w){console.error("Failed to load mapbox-gl:",w),b.error.set("Failed to load map library. Please ensure mapbox-gl is installed.")}finally{b._isInitializing=!1}}else console.warn("MapService: Cannot initialize map without valid mapbox token")})()}loadGeoJSON(a,p,M){var O=this;return(0,I.A)(function*(B,b,w,U=!0,k=!0){return yield O._mapReady,O._layerService.loadGeoJSONLayer(B,b,w,{cluster:U,zoomToFit:k,visible:!0,label:B})}).apply(this,arguments)}fitGeoJSONBBOX(a){var p=this;return(0,I.A)(function*(M,O=50,B=!0,b=19){yield p._mapReady,M?p._layerService.fitGeoJSONBounds(M,O,B,b):p._layerService.fitAllVisibleLayers(O)}).apply(this,arguments)}jumpTo(a,p){this._map?.jumpTo({center:a,zoom:p??this.zoom()})}setDarkMode(a){this._darkMode.set(a)}zoomToCoordinate(a){const p=this._map?.getZoom();if(!p)return;const M=p+1;this._map?.flyTo({center:a,zoom:M})}getZoom(){return this._map?.getZoom()}flyTo(a,p,M){this._map?.flyTo({center:a,zoom:p??this.zoom(),essential:!0,padding:M})}zoomIn(){if(!this._map)return;const a=this._map.getZoom();this._map.flyTo({zoom:a+1})}zoomOut(){if(!this._map)return;const a=this._map.getZoom();this._map.flyTo({zoom:a-1})}clearLayers(){this._layerService.clearAllLayers()}getImage(){const a=this._map?.getCanvas();if(void 0!==a)return a.toDataURL("image/png")}onParentResize(){this._map?.resize()}_loadMapboxCSS(){return(0,I.A)(function*(){return new Promise((a,p)=>{if(document.querySelector('link[href*="mapbox-gl.css"]'))return void a();const M=document.createElement("link");M.rel="stylesheet",M.href="https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.css",M.onload=()=>a(),M.onerror=()=>{const O=document.createElement("link");O.rel="stylesheet",O.href="node_modules/mapbox-gl/dist/mapbox-gl.css",O.onload=()=>a(),O.onerror=()=>p(new Error("Failed to load Mapbox CSS")),document.head.appendChild(O)},document.head.appendChild(M)})})()}_applyBorderRadius(a){const p=this.borderRadius();let M=p;if("0"===p){const B=a.closest("cue-map")?.parentElement;B&&(M=getComputedStyle(B).borderRadius||"0")}"0"!==M&&(a.style.borderRadius=M,a.style.overflow="hidden",setTimeout(()=>{const O=a.querySelector(".mapboxgl-canvas"),B=a.querySelector(".mapboxgl-canvas-container"),b=a.querySelector(".mapboxgl-map");O&&(O.style.borderRadius=M),B&&(B.style.borderRadius=M),b&&(b.style.borderRadius=M)},100))}_initEventListeners(a){a.on("click",p=>{void 0===this._hoveredFeature()&&this.clickedMap.next(p)}),a.on("drag",p=>{void 0===this._hoveredFeature()&&this.panningMap.next(p)}),a.on("dragend",p=>{void 0===this._hoveredFeature()&&this.pannedMap.next(p)}),a.on("zoomend",p=>{this.zoomedMap.next(p)}),a.on("load",()=>{this._emittedReady||(this._layerService.initializeWithMap(a),this._drawService.initializeWithMap(a),this._mapReadyPromiseResolve(),this.mapReady.next(),this._emittedReady=!0)}),a.on("error",p=>{this.error.set(p.error.message)})}_getMapStyleURL(){return`mapbox://styles/${this._styleId()}`}_updateStyle(){var a=this;return(0,I.A)(function*(){if(void 0===a._map)return;const p=a._map.getZoom(),M=a._map.getCenter();void 0!==a._mapContainer&&(yield a.init(a._mapContainer,a.mapboxToken(),M,p,a.borderRadius()),setTimeout(()=>{a._layerService.reapplyLayers(),a._map?.flyTo({center:M,zoom:p})},500))})()}_getSystemColorPreference(){return typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches}static \u0275fac=function(p){return new(p||P)};static \u0275prov=y.jDH({token:P,factory:P.\u0275fac})}return P})()},2306(ae,Q,u){"use strict";u.d(Q,{AA:()=>z,ux:()=>s,yY:()=>x});var I=u(140),y=u(8402);class x{mapboxToken;contextMenu={showProperties:!0,showFlyTo:!0};toolbar=new z}class z{hidden=!1;position="bottom";margin="20px";displayZoom=!0;displayGeofenceDraw=!1;displayLayerToggle=!0;clearGeofenceAfterDraw=!0}class s{label;id;collection=new I.o;color;visible=!0;cluster=!0;zoomToFit=!0;category;constructor(l,R=(0,y.A)()){this.label=l,this.id=R}}},8334(ae,Q,u){"use strict";u.d(Q,{o:()=>z});var I=u(7705),y=u(5547);const x=["*"];let z=(()=>{class s{label=I.hFB.required();active=(0,I.geq)(!1);static \u0275fac=function(R){return new(R||s)};static \u0275cmp=y.VBU({type:s,selectors:[["cue-tab"]],hostVars:1,hostBindings:function(R,P){2&R&&y.Avn("hidden",!P.active())},inputs:{label:[1,"label"],active:[1,"active"]},outputs:{active:"activeChange"},ngContentSelectors:x,decls:1,vars:0,template:function(R,P){1&R&&(y.NAR(),y.SdG(0))},styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0}[hidden][_nghost-%COMP%]{display:none!important}"]})}return s})()},6455(ae,Q,u){"use strict";u.d(Q,{t:()=>O});var I=u(7705),y=u(5802),x=u(2271),z=u(8334),s=u(5187),D=u(9769),l=u(5547);const R=["*"],P=(B,b)=>b.label();function g(B,b){if(1&B&&(l.j41(0,"cue-card",1),l.eu8(1,2),l.k0s()),2&B){const w=l.XpG(),U=l.sdS(3);l.Y8G("variant",w._cardVariant())("padded",!1),l.R7$(),l.Y8G("ngTemplateOutlet",U)}}function a(B,b){if(1&B&&l.eu8(0,2),2&B){l.XpG();const w=l.sdS(3);l.Y8G("ngTemplateOutlet",w)}}function p(B,b){if(1&B){const w=l.RV6();l.j41(0,"button",6),l.bIt("click",function(){const k=y.eBV(w).$index,X=l.XpG(2);return y.Njj(X.setActive(k))}),l.EFF(1),l.k0s()}if(2&B){const w=b.$implicit,U=b.$index,k=l.XpG(2);l.AVh("active",k.activeIndex()===U),l.R7$(),l.SpI(" ",w.label()," ")}}function M(B,b){if(1&B&&(l.j41(0,"div",3),l.Z7z(1,p,2,3,"button",4,P),l.k0s(),l.j41(3,"div",5),l.SdG(4),l.k0s()),2&B){const w=l.XpG();l.R7$(),l.Dyx(w.tabs())}}let O=(()=>{class B{tabs=(0,I.tEk)(z.o);activeIndex=(0,y.vPA)(0);variant=(0,I.hFB)("none");_cardVariant=(0,x.EW)(()=>"none"===this.variant()?"default":this.variant());constructor(){(0,y.QZP)(()=>{const w=this.tabs(),U=this.activeIndex();w.forEach((k,X)=>k.active.set(X===U))})}setActive(w){this.activeIndex.set(w)}static \u0275fac=function(U){return new(U||B)};static \u0275cmp=l.VBU({type:B,selectors:[["cue-tabs"]],contentQueries:function(U,k,X){1&U&&l.C6U(X,k.tabs,z.o,4),2&U&&l.NyB()},inputs:{variant:[1,"variant"]},ngContentSelectors:R,decls:4,vars:1,consts:[["inner",""],[2,"height","100%","width","100%","display","flex","flex-direction","column","overflow","hidden",3,"variant","padded"],[3,"ngTemplateOutlet"],[1,"tabs-header"],[1,"tab-button",3,"active"],[1,"tabs-content"],[1,"tab-button",3,"click"]],template:function(U,k){1&U&&(l.NAR(),l.nVh(0,g,2,3,"cue-card",1)(1,a,1,1,"ng-container",2),l.DNE(2,M,5,0,"ng-template",null,0,l.C5r)),2&U&&l.vxM("none"!==k.variant()?0:1)},dependencies:[s.Z,D.T3],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;box-sizing:border-box;border-radius:var(--cue-card-border-radius);border:1px solid var(--cue-card-border-color);background-color:var(--cue-default);color:var(--cue-defaultContrast);overflow:hidden}.tabs-header[_ngcontent-%COMP%]{display:flex;border-bottom:1px solid var(--cue-card-border-color);background-color:var(--background-color, var(--cue-default))}.tab-button[_ngcontent-%COMP%]{padding:10px 16px;background:none;border:none;border-bottom:2px solid transparent;cursor:pointer;color:inherit;font-family:var(--cue-font-family);font-size:var(--cue-font-s-size);line-height:var(--cue-font-s-line-height);opacity:.6;transition:opacity .15s,border-bottom-color .15s}.tab-button[_ngcontent-%COMP%]:hover{opacity:.9}.tab-button.active[_ngcontent-%COMP%]{border-bottom-color:currentColor;opacity:1;font-weight:500}.tabs-content[_ngcontent-%COMP%]{padding:var(--cue-card-padding-y) var(--cue-card-padding-x);flex:1;min-height:0;box-sizing:border-box;display:flex;flex-direction:column}"]})}return B})()},7335(ae,Q,u){"use strict";u.d(Q,{e:()=>R});var I=u(7705),y=u(5802),x=u(5547),z=u(8359),s=u(6939),D=u(63),l=u(4853);let R=(()=>{class P{_targetEl=(0,y.WQX)(x.aKT);_overlay=(0,y.WQX)(D.hJ);_overlayRef;_isOverlayHovered=!1;_subscriptions;display=(0,I.hFB)("on-hover");menuItems=I.hFB.required();menuEnabled=(0,I.hFB)(!0);onMouseEnter(){if("on-hover"===this.display()){if(!this.menuItems().length)return void this.removeOverlayMenu();this.appendOverlayMenu()}}onMouseLeave(){this._checkShouldRemoveOverlay()}appendOverlayMenu(){if(!this.menuItems().length||this._overlayRef)return;const a=this._overlay.create({positionStrategy:this._overlay.position().flexibleConnectedTo(this._targetEl).withPositions([{originX:"end",originY:"center",overlayX:"start",overlayY:"center",offsetX:2,offsetY:0}])});this._overlayRef=a;const p=window.getComputedStyle(this._targetEl.nativeElement).color;a.overlayElement.style.color=p;const M=new s.A8(l.H),O=a.attach(M);O.instance.items=this.menuItems,this._subscriptions&&this._subscriptions.unsubscribe(),this._subscriptions=new z.yU,this._subscriptions.add(O.instance.mouseEnter.subscribe(()=>{this._isOverlayHovered=!0})),this._subscriptions.add(O.instance.mouseLeave.subscribe(()=>{this._isOverlayHovered=!1,this._checkShouldRemoveOverlay()}))}removeOverlayMenu(){this._overlayRef&&(this._subscriptions&&(this._subscriptions.unsubscribe(),this._subscriptions=void 0),this._overlayRef.detach(),this._overlayRef.dispose(),this._overlayRef=void 0)}_checkShouldRemoveOverlay(){setTimeout(()=>{this._isOverlayHovered||this.removeOverlayMenu()},300)}static \u0275fac=function(p){return new(p||P)};static \u0275dir=x.FsC({type:P,selectors:[["","cueEntityMenu",""]],hostBindings:function(p,M){1&p&&x.bIt("mouseenter",function(){return M.onMouseEnter()})("mouseleave",function(){return M.onMouseLeave()})},inputs:{display:[1,"display"],menuItems:[1,"menuItems"],menuEnabled:[1,"menuEnabled"]}})}return P})()},140(ae,Q,u){"use strict";u.d(Q,{o:()=>I});class I{type="FeatureCollection";features=[];bbox;id;constructor(x=[]){this.features=x}addFeature(x){this.features.push(x)}removeFeature(x){return this.features.splice(x,1)[0]}getFeatureCount(){return this.features.length}clear(){this.features=[]}}},58(ae,Q,u){"use strict";function I(a){let p=0,M=-1,O=-1;for(let B=0;B<a.length;B++)if("("===a[B])p++,1===p&&(M=B+1);else if(")"===a[B]&&(p--,0===p)){O=B;break}return-1!==M&&-1!==O?a.substring(M,O):null}u.d(Q,{S:()=>P,n:()=>g});class y{x;y;z;constructor(p,M,O){this.x=p,this.y=M,this.z=O}}class x{points;constructor(p){this.points=p}}class z{lines;constructor(p){this.lines=p}}function P(a){if(a){if((a=a.trim().toUpperCase()).startsWith("POINT"))return function D(a){a=a.trim().toUpperCase();const M=I(a)?.split(" ")??[];return a.includes("POINT Z")?new y(parseFloat(M[0]),parseFloat(M[1]),parseFloat(M[2])):new y(parseFloat(M[0]),parseFloat(M[1]))}(a);if(a.startsWith("LINESTRING"))return function s(a){const p=I(a=a.trim().toUpperCase()),M=[];return p?.split(",").map(O=>O.trim().split(" ").map(B=>parseFloat(B))).map(O=>{M.push(new y(O[0],O[1],O[2]))}),new x(M)}(a);if(a.startsWith("POLYGON"))return function l(a){const p=I(a=a.trim().toUpperCase());if(!p)return new z([]);const M=p.match(/\(([^)]+)\)/g);if(!M)return new z([]);const O=M.map(B=>{const b=I(B);return b?b.split(",").map(w=>{const U=w.trim().split(" ");return U.length>=3?new y(parseFloat(U[0]),parseFloat(U[1]),parseFloat(U[2])):new y(parseFloat(U[0]),parseFloat(U[1]))}):[]});return new z(O)}(a)}}function g(a){if(a instanceof y)return{type:"Point",coordinates:void 0!==a.z?[a.x,a.y,a.z]:[a.x,a.y]};if(a instanceof x)return{type:"LineString",coordinates:a.points.map(p=>void 0!==p.z?[p.x,p.y,p.z]:[p.x,p.y])};if(a instanceof z)return{type:"Polygon",coordinates:a.lines.map(p=>p.map(M=>void 0!==M.z?[M.x,M.y,M.z]:[M.x,M.y]))};throw new Error("Unknown WKT type")}},362(ae){"use strict";ae.exports=function Q(u,I){if(u===I)return!0;if(u&&I&&"object"==typeof u&&"object"==typeof I){if(u.constructor!==I.constructor)return!1;var y,x,z;if(Array.isArray(u)){if((y=u.length)!=I.length)return!1;for(x=y;0!==x--;)if(!Q(u[x],I[x]))return!1;return!0}if(u.constructor===RegExp)return u.source===I.source&&u.flags===I.flags;if(u.valueOf!==Object.prototype.valueOf)return u.valueOf()===I.valueOf();if(u.toString!==Object.prototype.toString)return u.toString()===I.toString();if((y=(z=Object.keys(u)).length)!==Object.keys(I).length)return!1;for(x=y;0!==x--;)if(!Object.prototype.hasOwnProperty.call(I,z[x]))return!1;for(x=y;0!==x--;){var s=z[x];if(!Q(u[s],I[s]))return!1}return!0}return u!=u&&I!=I}},5332(ae,Q,u){"use strict";u.d(Q,{k:()=>z});for(var y=[],x=0;x<256;++x)y.push((x+256).toString(16).slice(1));function z(l,R=0){return(y[l[R+0]]+y[l[R+1]]+y[l[R+2]]+y[l[R+3]]+"-"+y[l[R+4]]+y[l[R+5]]+"-"+y[l[R+6]]+y[l[R+7]]+"-"+y[l[R+8]]+y[l[R+9]]+"-"+y[l[R+10]]+y[l[R+11]]+y[l[R+12]]+y[l[R+13]]+y[l[R+14]]+y[l[R+15]]).toLowerCase()}},8402(ae,Q,u){"use strict";u.d(Q,{A:()=>R});const y={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};var x,z=new Uint8Array(16);function s(){if(!x&&!(x=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return x(z)}var D=u(5332);const R=function l(P,g,a){if(y.randomUUID&&!g&&!P)return y.randomUUID();var p=(P=P||{}).random||(P.rng||s)();if(p[6]=15&p[6]|64,p[8]=63&p[8]|128,g){a=a||0;for(var M=0;M<16;++M)g[a+M]=p[M];return g}return(0,D.k)(p)}},6119(ae){ae.exports.RADIUS=6378137,ae.exports.FLATTENING=1/298.257223563,ae.exports.POLAR_RADIUS=6356752.3142}}]);
|