Major feature batch covering drawing-tool improvements, layer additions,
and offline-first capabilities. Largest changes in MapView.js (+1700),
main.js (+1500), public/sw.js (+367), and new modules under src/.
Drawing & editing toolkit
* Polygon Divide tool — sub-button under Split, divides a polygon into
N equal-area pieces via binary search; user picks the cutting edge
* UPN pick phase after Split and Divide — non-picked pieces have their
identifier fields cleared automatically
* Improved Merge algorithm — vertex-to-edge proximity (5 m tol.) with
hybrid lockstep extension; bold A/B labels on selected polygons
* Persistent vertex highlights — all vertices of the selected polygon
rendered as dots while edit mode is on, without subclassing ol-ext
* Toast notifications for merge/split/divide outcomes
* Shapefile import — addGeoJSONLayer now includes an image style so
Point features render (previously invisible)
Background & overlay layers
* DEAfrica Coastlines v0.4 (WMS) in Biophysical Environment
* DEAfrica Slope (SRTM 30m, style_slope) — semi-transparent background
* Contours hillshade — get_contours_hillshade.php → local SQLite cache
* OSM_roads — get_osm_roads.php → local SQLite cache, casing-stroke
style (black 3.5 px outer, #F0F1F0 1.5 px inner)
* External Source dialog — green + button in LayerSwitcher lets users
add WMS / WFS / XYZ layers at runtime
* Generic addWMSLayer / addXYZLayer with style, opacity, zIndex,
legendUrl, onlineOnly options
* TileWMS replaces ImageWMS (fixes 'Width exceeds 512' WMS errors)
* Legend panel — bottom-right, auto-shown for visible layers that
register a legendUrl
* Default base map setting in Settings, persisted in localStorage;
setBaseMap() on MapView
Offline tile cache (Phase 1 + 2)
* Service worker: per-host tile caches (osm / topo / satellite /
carto-light / carto-dark), counter-based eviction to prevent
iOS Safari memory-pressure reloads, GET_TILE_STATS /
CLEAR_TILE_CACHES message API
* pwa.js helpers: getActiveServiceWorker, onServiceWorkerControllerChange,
getTileCacheStats, clearTileCaches, getStorageEstimate
* Settings: Offline Map Tiles card with per-provider stats + clear
* Phase 2 download dialog: form to pick base map, area (current view /
district / Ghana), zoom range; live tile-count + size estimate;
progress bar with cancel; OfflineTileDownloader class with
concurrency + throttling
Local database management
* osm_roads table + saveOSMRoads / getLocalOSMRoads helpers
* CACHED_LAYER_TABLES allow-list with clearTable / clearAllCachedLayers
* Local Database Tables card: per-row Clear button (cached layers
only) + 'Refresh cached layers' header button with reload prompt
Build & infrastructure
* Shpjs lazy-loaded via dynamic import (saves ~140 kB from initial JS)
* chunkSizeWarningLimit raised to 900 kB (openlayers + sqlite3.wasm
can't be split further)
* Toast notification module (src/toast.js)
* Units module (src/units.js) for metric / imperial conversions
* PDF export module (src/pdf-export.js)
Documentation & SQL
* Topographic_Background_Layers_for_LUPMIS2.docx — research report
* OpenTopography_Workflow.svg/.png — ETL pipeline diagram
* LUPMIS2_Development_Status_Report.docx — April update section
* sql/create_landuse_parcels.sql — PostgreSQL schema for the LUSPA
land-use parcel specification (Feb 2026, revised), with PostGIS
geometry column and standard indices
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
574 lines
522 KiB
JavaScript
574 lines
522 KiB
JavaScript
const rf="modulepreload",of=function(s){return"/"+s},ph={},w0=function(e,t,n){let i=Promise.resolve();if(t&&t.length>0){let o=function(h){return Promise.all(h.map(c=>Promise.resolve(c).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");i=o(t.map(h=>{if(h=of(h),h in ph)return;ph[h]=!0;const c=h.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":rf,c||(d.as="script"),d.crossOrigin="",d.href=h,l&&d.setAttribute("nonce",l),document.head.appendChild(d),c)return new Promise((f,g)=>{d.addEventListener("load",f),d.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})},Se={ADD:"add",REMOVE:"remove"},Ni={PROPERTYCHANGE:"propertychange"},V={CHANGE:"change",ERROR:"error",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",TOUCHMOVE:"touchmove",WHEEL:"wheel"};class bs{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function af(s,e,t){let n,i;t=t||Nt;let r=0,o=s.length,a=!1;for(;r<o;)n=r+(o-r>>1),i=+t(s[n],e),i<0?r=n+1:(o=n,a=!i);return a?r:~r}function Nt(s,e){return s>e?1:s<e?-1:0}function lf(s,e){return s<e?1:s>e?-1:0}function qa(s,e,t){if(s[0]<=e)return 0;const n=s.length;if(e<=s[n-1])return n-1;if(typeof t=="function"){for(let i=1;i<n;++i){const r=s[i];if(r===e)return i;if(r<e)return t(e,s[i-1],r)>0?i-1:i}return n-1}if(t>0){for(let i=1;i<n;++i)if(s[i]<e)return i-1;return n-1}if(t<0){for(let i=1;i<n;++i)if(s[i]<=e)return i;return n-1}for(let i=1;i<n;++i){if(s[i]==e)return i;if(s[i]<e)return s[i-1]-e<e-s[i]?i-1:i}return n-1}function hf(s,e,t){for(;e<t;){const n=s[e];s[e]=s[t],s[t]=n,++e,--t}}function ne(s,e){const t=Array.isArray(e)?e:[e],n=t.length;for(let i=0;i<n;i++)s[s.length]=t[i]}function Bt(s,e){const t=s.length;if(t!==e.length)return!1;for(let n=0;n<t;n++)if(s[n]!==e[n])return!1;return!0}function cf(s,e,t){const n=e||Nt;return s.every(function(i,r){if(r===0)return!0;const o=n(s[r-1],i);return!(o>0||o===0)})}function Pn(){return!0}function Xi(){return!1}function Ts(){}function Dc(s){let e,t,n;return function(){const i=Array.prototype.slice.call(arguments);return(!t||this!==n||!Bt(i,t))&&(n=this,t=i,e=s.apply(this,arguments)),e}}function Oc(s){function e(){let t;try{t=s()}catch(n){return Promise.reject(n)}return t instanceof Promise?t:Promise.resolve(t)}return e()}function ei(s){for(const e in s)delete s[e]}function Vn(s){let e;for(e in s)return!1;return!e}class ut{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class Ds extends bs{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,t){if(!e||!t)return;const n=this.listeners_||(this.listeners_={}),i=n[e]||(n[e]=[]);i.includes(t)||i.push(t)}dispatchEvent(e){const t=typeof e=="string",n=t?e:e.type,i=this.listeners_&&this.listeners_[n];if(!i)return;const r=t?new ut(e):e;r.target||(r.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});n in o||(o[n]=0,a[n]=0),++o[n];let l;for(let h=0,c=i.length;h<c;++h)if("handleEvent"in i[h]?l=i[h].handleEvent(r):l=i[h].call(this,r),l===!1||r.propagationStopped){l=!1;break}if(--o[n]===0){let h=a[n];for(delete a[n];h--;)this.removeEventListener(n,Ts);delete o[n]}return l}disposeInternal(){this.listeners_&&ei(this.listeners_)}getListeners(e){return this.listeners_&&this.listeners_[e]||void 0}hasListener(e){return this.listeners_?e?e in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(e,t){if(!this.listeners_)return;const n=this.listeners_[e];if(!n)return;const i=n.indexOf(t);i!==-1&&(this.pendingRemovals_&&e in this.pendingRemovals_?(n[i]=Ts,++this.pendingRemovals_[e]):(n.splice(i,1),n.length===0&&delete this.listeners_[e]))}}function J(s,e,t,n,i){if(i){const o=t;t=function(a){return s.removeEventListener(e,t),o.call(n??this,a)}}else n&&n!==s&&(t=t.bind(n));const r={target:s,type:e,listener:t};return s.addEventListener(e,t),r}function wr(s,e,t,n){return J(s,e,t,n,!0)}function ue(s){s&&s.target&&(s.target.removeEventListener(s.type,s.listener),ei(s))}class Os extends Ds{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(V.CHANGE)}getRevision(){return this.revision_}onInternal(e,t){if(Array.isArray(e)){const n=e.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=J(this,e[r],t);return i}return J(this,e,t)}onceInternal(e,t){let n;if(Array.isArray(e)){const i=e.length;n=new Array(i);for(let r=0;r<i;++r)n[r]=wr(this,e[r],t)}else n=wr(this,e,t);return t.ol_key=n,n}unInternal(e,t){const n=t.ol_key;if(n)uf(n);else if(Array.isArray(e))for(let i=0,r=e.length;i<r;++i)this.removeEventListener(e[i],t);else this.removeEventListener(e,t)}}Os.prototype.on;Os.prototype.once;Os.prototype.un;function uf(s){if(Array.isArray(s))for(let e=0,t=s.length;e<t;++e)ue(s[e]);else ue(s)}function $(){throw new Error("Unimplemented abstract method.")}let df=0;function D(s){return s.ol_uid||(s.ol_uid=String(++df))}class yh extends ut{constructor(e,t,n){super(e),this.key=t,this.oldValue=n}}class Rt extends Os{constructor(e){super(),this.on,this.once,this.un,D(this),this.values_=null,e!==void 0&&this.setProperties(e)}get(e){let t;return this.values_&&this.values_.hasOwnProperty(e)&&(t=this.values_[e]),t}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(e,t){let n;n=`change:${e}`,this.hasListener(n)&&this.dispatchEvent(new yh(n,e,t)),n=Ni.PROPERTYCHANGE,this.hasListener(n)&&this.dispatchEvent(new yh(n,e,t))}addChangeListener(e,t){this.addEventListener(`change:${e}`,t)}removeChangeListener(e,t){this.removeEventListener(`change:${e}`,t)}set(e,t,n){const i=this.values_||(this.values_={});if(n)i[e]=t;else{const r=i[e];i[e]=t,r!==t&&this.notify(e,r)}}setProperties(e,t){for(const n in e)this.set(n,e[n],t)}applyProperties(e){e.values_&&Object.assign(this.values_||(this.values_={}),e.values_)}unset(e,t){if(this.values_&&e in this.values_){const n=this.values_[e];delete this.values_[e],Vn(this.values_)&&(this.values_=null),t||this.notify(e,n)}}}const xh={LENGTH:"length"};class Hs extends ut{constructor(e,t,n){super(e),this.element=t,this.index=n}}class Ze extends Rt{constructor(e,t){if(super(),this.on,this.once,this.un,t=t||{},this.unique_=!!t.unique,this.array_=e??[],this.unique_)for(let n=1,i=this.array_.length;n<i;++n)this.assertUnique_(this.array_[n],n);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(e){for(let t=0,n=e.length;t<n;++t)this.push(e[t]);return this}forEach(e){const t=this.array_;for(let n=0,i=t.length;n<i;++n)e(t[n],n,t)}getArray(){return this.array_}item(e){return this.array_[e]}getLength(){return this.get(xh.LENGTH)}insertAt(e,t){if(e<0||e>this.getLength())throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t),this.array_.splice(e,0,t),this.updateLength_(),this.dispatchEvent(new Hs(Se.ADD,t,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){const t=this.getLength();return this.insertAt(t,e),this.getLength()}remove(e){const t=this.array_;for(let n=0,i=t.length;n<i;++n)if(t[n]===e)return this.removeAt(n)}removeAt(e){if(e<0||e>=this.getLength())return;const t=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new Hs(Se.REMOVE,t,e)),t}setAt(e,t){const n=this.getLength();if(e>=n){this.insertAt(e,t);return}if(e<0)throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t,e);const i=this.array_[e];this.array_[e]=t,this.dispatchEvent(new Hs(Se.REMOVE,i,e)),this.dispatchEvent(new Hs(Se.ADD,t,e))}updateLength_(){this.set(xh.LENGTH,this.array_.length)}assertUnique_(e,t){const n=this.array_;for(let i=0,r=n.length;i<r;++i)if(n[i]===e&&i!==t)throw new Error("Duplicate item added to a unique collection")}}class Ti extends ut{constructor(e,t,n){super(e),this.map=t,this.frameState=n!==void 0?n:null}}class Zt extends Ti{constructor(e,t,n,i,r,o){super(e,t,r),this.originalEvent=n,this.pixel_=null,this.coordinate_=null,this.dragging=i!==void 0?i:!1,this.activePointers=o}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(e){this.pixel_=e}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(e){this.coordinate_=e}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}}const ee={SINGLECLICK:"singleclick",CLICK:V.CLICK,DBLCLICK:V.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"},Zn=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",ff=Zn.includes("safari")&&!Zn.includes("chrom"),gf=ff&&(Zn.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Zn)),_f=Zn.includes("webkit")&&!Zn.includes("edge"),Nc=Zn.includes("macintosh"),mf=typeof devicePixelRatio<"u"?devicePixelRatio:1,at=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Gc=typeof Image<"u"&&Image.prototype.decode,pf=typeof createImageBitmap=="function",kc=(function(){let s=!1;try{const e=Object.defineProperty({},"passive",{get:function(){s=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}return s})(),pa={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown"};class yf extends Ds{constructor(e,t){super(e),this.map_=e,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=t===void 0?1:t,this.down_=null;const n=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=n,this.pointerdownListenerKey_=J(n,pa.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=J(n,pa.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(V.TOUCHMOVE,this.boundHandleTouchMove_,kc?{passive:!1}:!1)}emulateClick_(e){let t=new Zt(ee.CLICK,this.map_,e);this.dispatchEvent(t),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,t=new Zt(ee.DBLCLICK,this.map_,e),this.dispatchEvent(t)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;const n=new Zt(ee.SINGLECLICK,this.map_,e);this.dispatchEvent(n)},250)}updateActivePointers_(e){const t=e,n=t.pointerId;if(t.type==ee.POINTERUP||t.type==ee.POINTERCANCEL){delete this.trackedTouches_[n];for(const i in this.trackedTouches_)if(this.trackedTouches_[i].target!==t.target){delete this.trackedTouches_[i];break}}else(t.type==ee.POINTERDOWN||t.type==ee.POINTERMOVE)&&(this.trackedTouches_[n]=t);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(e){this.updateActivePointers_(e);const t=new Zt(ee.POINTERUP,this.map_,e,void 0,void 0,this.activePointers_);this.dispatchEvent(t),this.emulateClicks_&&!t.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(e)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(ue),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(e){return e.button===0}handlePointerDown_(e){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(e);const t=new Zt(ee.POINTERDOWN,this.map_,e,void 0,void 0,this.activePointers_);if(this.dispatchEvent(t),this.down_=new PointerEvent(e.type,e),Object.defineProperty(this.down_,"target",{writable:!1,value:e.target}),this.dragListenerKeys_.length===0){const n=this.map_.getOwnerDocument();this.dragListenerKeys_.push(J(n,ee.POINTERMOVE,this.handlePointerMove_,this),J(n,ee.POINTERUP,this.handlePointerUp_,this),J(this.element_,ee.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==n&&this.dragListenerKeys_.push(J(this.element_.getRootNode(),ee.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(e){if(this.isMoving_(e)){this.updateActivePointers_(e),this.dragging_=!0;const t=new Zt(ee.POINTERDRAG,this.map_,e,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(t)}}relayMoveEvent_(e){this.originalPointerMoveEvent_=e;const t=!!(this.down_&&this.isMoving_(e));this.dispatchEvent(new Zt(ee.POINTERMOVE,this.map_,e,t))}handleTouchMove_(e){const t=this.originalPointerMoveEvent_;(!t||t.defaultPrevented)&&(typeof e.cancelable!="boolean"||e.cancelable===!0)&&e.preventDefault()}isMoving_(e){return this.dragging_||Math.abs(e.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(e.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(ue(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(V.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(ue(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(ue),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const Kt={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},Be={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},B={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function te(s,e){if(!s)throw new Error(e)}const Pr=1/0;class xf{constructor(e,t){this.priorityFunction_=e,this.keyFunction_=t,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,ei(this.queuedElements_)}dequeue(){const e=this.elements_,t=this.priorities_,n=e[0];e.length==1?(e.length=0,t.length=0):(e[0]=e.pop(),t[0]=t.pop(),this.siftUp_(0));const i=this.keyFunction_(n);return delete this.queuedElements_[i],n}enqueue(e){te(!(this.keyFunction_(e)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const t=this.priorityFunction_(e);return t!=Pr?(this.elements_.push(e),this.priorities_.push(t),this.queuedElements_[this.keyFunction_(e)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(e){return e*2+1}getRightChildIndex_(e){return e*2+2}getParentIndex_(e){return e-1>>1}heapify_(){let e;for(e=(this.elements_.length>>1)-1;e>=0;e--)this.siftUp_(e)}isEmpty(){return this.elements_.length===0}isKeyQueued(e){return e in this.queuedElements_}isQueued(e){return this.isKeyQueued(this.keyFunction_(e))}siftUp_(e){const t=this.elements_,n=this.priorities_,i=t.length,r=t[e],o=n[e],a=e;for(;e<i>>1;){const l=this.getLeftChildIndex_(e),h=this.getRightChildIndex_(e),c=h<i&&n[h]<n[l]?h:l;t[e]=t[c],n[e]=n[c],e=c}t[e]=r,n[e]=o,this.siftDown_(a,e)}siftDown_(e,t){const n=this.elements_,i=this.priorities_,r=n[t],o=i[t];for(;t>e;){const a=this.getParentIndex_(t);if(i[a]>o)n[t]=n[a],i[t]=i[a],t=a;else break}n[t]=r,i[t]=o}reprioritize(){const e=this.priorityFunction_,t=this.elements_,n=this.priorities_;let i=0;const r=t.length;let o,a,l;for(a=0;a<r;++a)o=t[a],l=e(o),l==Pr?delete this.queuedElements_[this.keyFunction_(o)]:(n[i]=l,t[i++]=o);t.length=i,n.length=i,this.heapify_()}}class Ef extends xf{constructor(e,t){super(n=>e.apply(null,n),n=>n[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=t,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(e){const t=super.enqueue(e);return t&&e[0].addEventListener(V.CHANGE,this.boundHandleTileChange_),t}getTilesLoading(){return this.tilesLoading_}handleTileChange(e){const t=e.target,n=t.getState();if(n===B.LOADED||n===B.ERROR||n===B.EMPTY){n!==B.ERROR&&t.removeEventListener(V.CHANGE,this.boundHandleTileChange_);const i=t.getKey();i in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[i],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(e,t){let n=0;for(;this.tilesLoading_<e&&n<t&&this.getCount()>0;){const i=this.dequeue()[0],r=i.getKey();i.getState()===B.IDLE&&!(r in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[r]=!0,++this.tilesLoading_,++n,i.load())}}}function Tf(s,e,t,n,i){if(!s||!(t in s.wantedTiles)||!s.wantedTiles[t][e.getKey()])return Pr;const r=s.viewState.center,o=n[0]-r[0],a=n[1]-r[1];return 65536*Math.log(i)+Math.sqrt(o*o+a*a)/i}const he={ANIMATING:0,INTERACTING:1},vt={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function ge(s,e,t){return Math.min(Math.max(s,e),t)}function Cf(s,e,t,n,i,r){const o=i-t,a=r-n;if(o!==0||a!==0){const l=((s-t)*o+(e-n)*a)/(o*o+a*a);l>1?(t=i,n=r):l>0&&(t+=o*l,n+=a*l)}return Qt(s,e,t,n)}function Qt(s,e,t,n){const i=t-s,r=n-e;return i*i+r*r}function Rf(s){const e=s.length;for(let n=0;n<e;n++){let i=n,r=Math.abs(s[n][n]);for(let a=n+1;a<e;a++){const l=Math.abs(s[a][n]);l>r&&(r=l,i=a)}if(r===0)return null;const o=s[i];s[i]=s[n],s[n]=o;for(let a=n+1;a<e;a++){const l=-s[a][n]/s[n][n];for(let h=n;h<e+1;h++)n==h?s[a][h]=0:s[a][h]+=l*s[n][h]}}const t=new Array(e);for(let n=e-1;n>=0;n--){t[n]=s[n][e]/s[n][n];for(let i=n-1;i>=0;i--)s[i][e]-=s[i][n]*t[n]}return t}function Ir(s){return s*180/Math.PI}function Ke(s){return s*Math.PI/180}function en(s,e){const t=s%e;return t*e<0?t+e:t}function rt(s,e,t){return s+t*(e-s)}function Yi(s,e){const t=Math.pow(10,e);return Math.round(s*t)/t}function Eh(s,e){return Math.round(Yi(s,e))}function qs(s,e){return Math.floor(Yi(s,e))}function Js(s,e){return Math.ceil(Yi(s,e))}function ya(s,e,t){if(s>=e&&s<t)return s;const n=t-e;return((s-e)%n+n)%n+e}function Th(s,e,t){return(function(n,i,r,o,a){if(!n)return;if(!i&&!e)return n;const l=e?0:r[0]*i,h=e?0:r[1]*i,c=a?a[0]:0,u=a?a[1]:0;let d=s[0]+l/2+c,f=s[2]-l/2+c,g=s[1]+h/2+u,m=s[3]-h/2+u;d>f&&(d=(f+d)/2,f=d),g>m&&(g=(m+g)/2,m=g);let _=ge(n[0],d,f),p=ge(n[1],g,m);if(o&&t&&i){const y=30*i;_+=-y*Math.log(1+Math.max(0,d-n[0])/y)+y*Math.log(1+Math.max(0,n[0]-f)/y),p+=-y*Math.log(1+Math.max(0,g-n[1])/y)+y*Math.log(1+Math.max(0,n[1]-m)/y)}return[_,p]})}function Sf(s){return s}const Fe={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function ze(s){const e=tt();for(let t=0,n=s.length;t<n;++t)gs(e,s[t]);return e}function vf(s,e,t){const n=Math.min.apply(null,s),i=Math.min.apply(null,e),r=Math.max.apply(null,s),o=Math.max.apply(null,e);return Ut(n,i,r,o,t)}function rn(s,e,t){return t?(t[0]=s[0]-e,t[1]=s[1]-e,t[2]=s[2]+e,t[3]=s[3]+e,t):[s[0]-e,s[1]-e,s[2]+e,s[3]+e]}function Uc(s,e){return e?(e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e):s.slice()}function ti(s,e,t){let n,i;return e<s[0]?n=s[0]-e:s[2]<e?n=e-s[2]:n=0,t<s[1]?i=s[1]-t:s[3]<t?i=t-s[3]:i=0,n*n+i*i}function Kn(s,e){return Ja(s,e[0],e[1])}function yn(s,e){return s[0]<=e[0]&&e[2]<=s[2]&&s[1]<=e[1]&&e[3]<=s[3]}function Ja(s,e,t){return s[0]<=e&&e<=s[2]&&s[1]<=t&&t<=s[3]}function xa(s,e){const t=s[0],n=s[1],i=s[2],r=s[3],o=e[0],a=e[1];let l=Fe.UNKNOWN;return o<t?l=l|Fe.LEFT:o>i&&(l=l|Fe.RIGHT),a<n?l=l|Fe.BELOW:a>r&&(l=l|Fe.ABOVE),l===Fe.UNKNOWN&&(l=Fe.INTERSECTING),l}function tt(){return[1/0,1/0,-1/0,-1/0]}function Ut(s,e,t,n,i){return i?(i[0]=s,i[1]=e,i[2]=t,i[3]=n,i):[s,e,t,n]}function ji(s){return Ut(1/0,1/0,-1/0,-1/0,s)}function fs(s,e){const t=s[0],n=s[1];return Ut(t,n,t,n,e)}function Qa(s,e,t,n,i){const r=ji(i);return zc(r,s,e,t,n)}function Hn(s,e){return s[0]==e[0]&&s[2]==e[2]&&s[1]==e[1]&&s[3]==e[3]}function Bc(s,e){return e[0]<s[0]&&(s[0]=e[0]),e[2]>s[2]&&(s[2]=e[2]),e[1]<s[1]&&(s[1]=e[1]),e[3]>s[3]&&(s[3]=e[3]),s}function gs(s,e){e[0]<s[0]&&(s[0]=e[0]),e[0]>s[2]&&(s[2]=e[0]),e[1]<s[1]&&(s[1]=e[1]),e[1]>s[3]&&(s[3]=e[1])}function zc(s,e,t,n,i){for(;t<n;t+=i)wf(s,e[t],e[t+1]);return s}function wf(s,e,t){s[0]=Math.min(s[0],e),s[1]=Math.min(s[1],t),s[2]=Math.max(s[2],e),s[3]=Math.max(s[3],t)}function el(s,e){let t;return t=e(Jr(s)),t||(t=e(Qr(s)),t)||(t=e(eo(s)),t)||(t=e(Fn(s)),t)?t:!1}function Ea(s){let e=0;return ni(s)||(e=ie(s)*be(s)),e}function Jr(s){return[s[0],s[1]]}function Qr(s){return[s[2],s[1]]}function In(s){return[(s[0]+s[2])/2,(s[1]+s[3])/2]}function Pf(s,e){let t;if(e==="bottom-left")t=Jr(s);else if(e==="bottom-right")t=Qr(s);else if(e==="top-left")t=Fn(s);else if(e==="top-right")t=eo(s);else throw new Error("Invalid corner");return t}function Ta(s,e,t,n,i){const[r,o,a,l,h,c,u,d]=$c(s,e,t,n);return Ut(Math.min(r,a,h,u),Math.min(o,l,c,d),Math.max(r,a,h,u),Math.max(o,l,c,d),i)}function $c(s,e,t,n){const i=e*n[0]/2,r=e*n[1]/2,o=Math.cos(t),a=Math.sin(t),l=i*o,h=i*a,c=r*o,u=r*a,d=s[0],f=s[1];return[d-l+u,f-h-c,d-l-u,f-h+c,d+l-u,f+h+c,d+l+u,f+h-c,d-l+u,f-h-c]}function be(s){return s[3]-s[1]}function tn(s,e,t){const n=t||tt();return Te(s,e)?(s[0]>e[0]?n[0]=s[0]:n[0]=e[0],s[1]>e[1]?n[1]=s[1]:n[1]=e[1],s[2]<e[2]?n[2]=s[2]:n[2]=e[2],s[3]<e[3]?n[3]=s[3]:n[3]=e[3]):ji(n),n}function Fn(s){return[s[0],s[3]]}function eo(s){return[s[2],s[3]]}function ie(s){return s[2]-s[0]}function Te(s,e){return s[0]<=e[2]&&s[2]>=e[0]&&s[1]<=e[3]&&s[3]>=e[1]}function ni(s){return s[2]<s[0]||s[3]<s[1]}function If(s,e){return e?(e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e):s}function Af(s,e){const t=(s[2]-s[0])/2*(e-1),n=(s[3]-s[1])/2*(e-1);s[0]-=t,s[2]+=t,s[1]-=n,s[3]+=n}function Lf(s,e,t){let n=!1;const i=xa(s,e),r=xa(s,t);if(i===Fe.INTERSECTING||r===Fe.INTERSECTING)n=!0;else{const o=s[0],a=s[1],l=s[2],h=s[3],c=e[0],u=e[1],d=t[0],f=t[1],g=(f-u)/(d-c);let m,_;r&Fe.ABOVE&&!(i&Fe.ABOVE)&&(m=d-(f-h)/g,n=m>=o&&m<=l),!n&&r&Fe.RIGHT&&!(i&Fe.RIGHT)&&(_=f-(d-l)*g,n=_>=a&&_<=h),!n&&r&Fe.BELOW&&!(i&Fe.BELOW)&&(m=d-(f-a)/g,n=m>=o&&m<=l),!n&&r&Fe.LEFT&&!(i&Fe.LEFT)&&(_=f-(d-o)*g,n=_>=a&&_<=h)}return n}function Ff(s,e,t,n){if(ni(s))return ji(t);let i=[];{const a=s[2]-s[0],l=s[3]-s[1];for(let h=0;h<n;++h)i.push(s[0]+a*h/n,s[1],s[2],s[1]+l*h/n,s[2]-a*h/n,s[3],s[0],s[3]-l*h/n)}e(i,i,2);const r=[],o=[];for(let a=0,l=i.length;a<l;a+=2)r.push(i[a]),o.push(i[a+1]);return vf(r,o,t)}function Xc(s,e){const t=e.getExtent(),n=In(s);if(e.canWrapX()&&(n[0]<t[0]||n[0]>=t[2])){const i=ie(t),o=Math.floor((n[0]-t[0])/i)*i;s[0]-=o,s[2]-=o}return s}function Yc(s,e,t){if(e.canWrapX()){const n=e.getExtent();if(!isFinite(s[0])||!isFinite(s[2]))return[[n[0],s[1],n[2],s[3]]];Xc(s,e);const i=ie(n);if(ie(s)>i&&!t)return[[n[0],s[1],n[2],s[3]]];if(s[0]<n[0])return[[s[0]+i,s[1],n[2],s[3]],[n[0],s[1],s[2],s[3]]];if(s[2]>n[2])return[[s[0],s[1],n[2],s[3]],[n[0],s[1],s[2]-i,s[3]]]}return[s]}function jc(s,e){const t=(""+s).split("."),n=(""+e).split(".");for(let i=0;i<Math.max(t.length,n.length);i++){const r=parseInt(t[i]||"0",10),o=parseInt(n[i]||"0",10);if(r>o)return 1;if(o>r)return-1}return 0}function Mf(s,e){return s[0]+=+e[0],s[1]+=+e[1],s}function tl(s,e){const t=s[0],n=s[1],i=e[0],r=e[1],o=i[0],a=i[1],l=r[0],h=r[1],c=l-o,u=h-a,d=c===0&&u===0?0:(c*(t-o)+u*(n-a))/(c*c+u*u||0);let f,g;return d<=0?(f=o,g=a):d>=1?(f=l,g=h):(f=o+d*c,g=a+d*u),[f,g]}function Ve(s,e){let t=!0;for(let n=s.length-1;n>=0;--n)if(s[n]!=e[n]){t=!1;break}return t}function nl(s,e){const t=Math.cos(e),n=Math.sin(e),i=s[0]*t-s[1]*n,r=s[1]*t+s[0]*n;return s[0]=i,s[1]=r,s}function bf(s,e){return s[0]*=e,s[1]*=e,s}function Gi(s,e){const t=s[0]-e[0],n=s[1]-e[1];return t*t+n*n}function vi(s,e){return Math.sqrt(Gi(s,e))}function Df(s,e){return Gi(s,tl(s,e))}function il(s,e){if(e.canWrapX()){const t=ie(e.getExtent()),n=Of(s,e,t);n&&(s[0]-=n*t)}return s}function Of(s,e,t){const n=e.getExtent();let i=0;return e.canWrapX()&&(s[0]<n[0]||s[0]>n[2])&&(t=t||ie(n),i=Math.floor((s[0]-n[0])/t)),i}function Wc(s){return Math.pow(s,3)}function Wi(s){return 1-Wc(1-s)}function Nf(s){return 3*s*s-2*s*s*s}function Gf(s){return s}const to=63710088e-1;function Ca(s,e,t){t=t||to;const n=Ke(s[1]),i=Ke(e[1]),r=(i-n)/2,o=Ke(e[0]-s[0])/2,a=Math.sin(r)*Math.sin(r)+Math.sin(o)*Math.sin(o)*Math.cos(n)*Math.cos(i);return 2*t*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function Io(s,e){let t=0;for(let n=0,i=s.length;n<i-1;++n)t+=Ca(s[n],s[n+1],e);return t}function kf(s,e){e=e||{};const t=e.radius||to,n=e.projection||"EPSG:3857",i=s.getType();i!=="GeometryCollection"&&(s=s.clone().transform(n,"EPSG:4326"));let r=0,o,a,l,h,c,u;switch(i){case"Point":case"MultiPoint":break;case"LineString":case"LinearRing":{o=s.getCoordinates(),r=Io(o,t);break}case"MultiLineString":case"Polygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)r+=Io(o[l],t);break}case"MultiPolygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],c=0,u=a.length;c<u;++c)r+=Io(a[c],t);break}case"GeometryCollection":{const d=s.getGeometries();for(l=0,h=d.length;l<h;++l)r+=kf(d[l],e);break}default:throw new Error("Unsupported geometry type: "+i)}return r}function Qs(s,e){let t=0;const n=s.length;let i=s[n-1][0],r=s[n-1][1];for(let o=0;o<n;o++){const a=s[o][0],l=s[o][1];t+=Ke(a-i)*(2+Math.sin(Ke(r))+Math.sin(Ke(l))),i=a,r=l}return t*e*e/2}function Uf(s,e){e=e||{};const t=e.radius||to,n=e.projection||"EPSG:3857",i=s.getType();i!=="GeometryCollection"&&(s=s.clone().transform(n,"EPSG:4326"));let r=0,o,a,l,h,c,u;switch(i){case"Point":case"MultiPoint":case"LineString":case"MultiLineString":case"LinearRing":break;case"Polygon":{for(o=s.getCoordinates(),r=Math.abs(Qs(o[0],t)),l=1,h=o.length;l<h;++l)r-=Math.abs(Qs(o[l],t));break}case"MultiPolygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],r+=Math.abs(Qs(a[0],t)),c=1,u=a.length;c<u;++c)r-=Math.abs(Qs(a[c],t));break}case"GeometryCollection":{const d=s.getGeometries();for(l=0,h=d.length;l<h;++l)r+=Uf(d[l],e);break}default:throw new Error("Unsupported geometry type: "+i)}return r}function Bf(s,e,t,n){n=n||to;const i=Ke(s[1]),r=Ke(s[0]),o=e/n,a=Math.asin(Math.sin(i)*Math.cos(o)+Math.cos(i)*Math.sin(o)*Math.cos(t)),l=r+Math.atan2(Math.sin(t)*Math.sin(o)*Math.cos(i),Math.cos(o)-Math.sin(i)*Math.sin(a));return[Ir(l),Ir(a)]}function Vc(...s){console.warn(...s)}const ki={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class sl{constructor(e){this.code_=e.code,this.units_=e.units,this.extent_=e.extent!==void 0?e.extent:null,this.worldExtent_=e.worldExtent!==void 0?e.worldExtent:null,this.axisOrientation_=e.axisOrientation!==void 0?e.axisOrientation:"enu",this.global_=e.global!==void 0?e.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=e.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=e.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||ki[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(e){this.global_=e,this.canWrapX_=!!(e&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(e){this.defaultTileGrid_=e}setExtent(e){this.extent_=e,this.canWrapX_=!!(this.global_&&e)}setWorldExtent(e){this.worldExtent_=e}setGetPointResolution(e){this.getPointResolutionFunc_=e}getPointResolutionFunc(){return this.getPointResolutionFunc_}}const Ns=6378137,wi=Math.PI*Ns,zf=[-wi,-wi,wi,wi],$f=[-180,-85,180,85],er=Ns*Math.log(Math.tan(Math.PI/2));class ui extends sl{constructor(e){super({code:e,units:"m",extent:zf,global:!0,worldExtent:$f,getPointResolution:function(t,n){return t/Math.cosh(n[1]/Ns)}})}}const Ch=[new ui("EPSG:3857"),new ui("EPSG:102100"),new ui("EPSG:102113"),new ui("EPSG:900913"),new ui("http://www.opengis.net/def/crs/EPSG/0/3857"),new ui("http://www.opengis.net/gml/srs/epsg.xml#3857")];function Xf(s,e,t,n){const i=s.length;t=t>1?t:2,n=n??t,e===void 0&&(t>2?e=s.slice():e=new Array(i));for(let r=0;r<i;r+=n){e[r]=wi*s[r]/180;let o=Ns*Math.log(Math.tan(Math.PI*(+s[r+1]+90)/360));o>er?o=er:o<-er&&(o=-er),e[r+1]=o}return e}function Yf(s,e,t,n){const i=s.length;t=t>1?t:2,n=n??t,e===void 0&&(t>2?e=s.slice():e=new Array(i));for(let r=0;r<i;r+=n)e[r]=180*s[r]/wi,e[r+1]=360*Math.atan(Math.exp(s[r+1]/Ns))/Math.PI-90;return e}const jf=6378137,Rh=[-180,-90,180,90],Wf=Math.PI*jf/180;class Nn extends sl{constructor(e,t){super({code:e,units:"degrees",extent:Rh,axisOrientation:t,global:!0,metersPerUnit:Wf,worldExtent:Rh})}}const Sh=[new Nn("CRS:84"),new Nn("EPSG:4326","neu"),new Nn("urn:ogc:def:crs:OGC:1.3:CRS84"),new Nn("urn:ogc:def:crs:OGC:2:84"),new Nn("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new Nn("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new Nn("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let Ra={};function Vf(s){return Ra[s]||Ra[s.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function Zf(s,e){Ra[s]=e}let Ai={};function Cs(s,e,t){const n=s.getCode(),i=e.getCode();n in Ai||(Ai[n]={}),Ai[n][i]=t}function Ao(s,e){return s in Ai&&e in Ai[s]?Ai[s][e]:null}const Ar=.9996,Et=.00669438,no=Et*Et,io=no*Et,Bn=Et/(1-Et),vh=Math.sqrt(1-Et),Ui=(1-vh)/(1+vh),Zc=Ui*Ui,rl=Zc*Ui,ol=rl*Ui,Kc=ol*Ui,Hc=1-Et/4-3*no/64-5*io/256,Kf=3*Et/8+3*no/32+45*io/1024,Hf=15*no/256+45*io/1024,qf=35*io/3072,Jf=3/2*Ui-27/32*rl+269/512*Kc,Qf=21/16*Zc-55/32*ol,eg=151/96*rl-417/128*Kc,tg=1097/512*ol,Lr=6378137;function ng(s,e,t){const n=s-5e5,o=(t.north?e:e-1e7)/Ar/(Lr*Hc),a=o+Jf*Math.sin(2*o)+Qf*Math.sin(4*o)+eg*Math.sin(6*o)+tg*Math.sin(8*o),l=Math.sin(a),h=l*l,c=Math.cos(a),u=l/c,d=u*u,f=d*d,g=1-Et*h,m=Math.sqrt(1-Et*h),_=Lr/m,p=(1-Et)/g,y=Bn*c**2,E=y*y,x=n/(_*Ar),T=x*x,R=T*x,S=R*x,v=S*x,w=v*x,I=a-u/p*(T/2-S/24*(5+3*d+10*y-4*E-9*Bn))+w/720*(61+90*d+298*y+45*f-252*Bn-3*E);let F=(x-R/6*(1+2*d+y)+v/120*(5-2*y+28*d-3*E+8*Bn+24*f))/c;return F=ya(F+Ke(qc(t.number)),-Math.PI,Math.PI),[Ir(F),Ir(I)]}const wh=-80,Ph=84,ig=-180,sg=180;function rg(s,e,t){s=ya(s,ig,sg),e<wh?e=wh:e>Ph&&(e=Ph);const n=Ke(e),i=Math.sin(n),r=Math.cos(n),o=i/r,a=o*o,l=a*a,h=Ke(s),c=qc(t.number),u=Ke(c),d=Lr/Math.sqrt(1-Et*i**2),f=Bn*r**2,g=r*ya(h-u,-Math.PI,Math.PI),m=g*g,_=m*g,p=_*g,y=p*g,E=y*g,x=Lr*(Hc*n-Kf*Math.sin(2*n)+Hf*Math.sin(4*n)-qf*Math.sin(6*n)),T=Ar*d*(g+_/6*(1-a+f)+y/120*(5-18*a+l+72*f-58*Bn))+5e5;let R=Ar*(x+d*o*(m/2+p/24*(5-a+9*f+4*f**2)+E/720*(61-58*a+l+600*f-330*Bn)));return t.north||(R+=1e7),[T,R]}function qc(s){return(s-1)*6-180+3}const og=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Jc(s){let e=0;for(const i of og){const r=s.match(i);if(r){e=parseInt(r[1]);break}}if(!e)return null;let t=0,n=!1;return e>32700&&e<32761?t=e-32700:e>32600&&e<32661&&(n=!0,t=e-32600),t?{number:t,north:n}:null}function Ih(s,e){return function(t,n,i,r){const o=t.length;i=i>1?i:2,r=r??i,n||(i>2?n=t.slice():n=new Array(o));for(let a=0;a<o;a+=r){const l=t[a],h=t[a+1],c=s(l,h,e);n[a]=c[0],n[a+1]=c[1]}return n}}function ag(s){return Jc(s)?new sl({code:s,units:"m"}):null}function lg(s){const e=Jc(s.getCode());return e?{forward:Ih(rg,e),inverse:Ih(ng,e)}:null}const hg=[lg],cg=[ag];let Sa=!0;function Qc(s){Sa=!1}function al(s,e){if(e!==void 0){for(let t=0,n=s.length;t<n;++t)e[t]=s[t];e=e}else e=s.slice();return e}function ug(s,e){if(e!==void 0&&s!==e){for(let t=0,n=s.length;t<n;++t)e[t]=s[t];s=e}return s}function va(s){Zf(s.getCode(),s),Cs(s,s,al)}function dg(s){s.forEach(va)}function de(s){if(typeof s!="string")return s;const e=Vf(s);if(e)return e;for(const t of cg){const n=t(s);if(n)return n}return null}function Fr(s,e,t,n){s=de(s);let i;const r=s.getPointResolutionFunc();if(r){if(i=r(e,t),n&&n!==s.getUnits()){const o=s.getMetersPerUnit();o&&(i=i*o/ki[n])}}else{const o=s.getUnits();if(o=="degrees"&&!n||n=="degrees")i=e;else{const a=Gs(s,de("EPSG:4326"));if(!a&&o!=="degrees")i=e*s.getMetersPerUnit();else{let h=[t[0]-e/2,t[1],t[0]+e/2,t[1],t[0],t[1]-e/2,t[0],t[1]+e/2];h=a(h,h,2);const c=Ca(h.slice(0,2),h.slice(2,4)),u=Ca(h.slice(4,6),h.slice(6,8));i=(c+u)/2}const l=n?ki[n]:s.getMetersPerUnit();l!==void 0&&(i/=l)}}return i}function Ah(s){dg(s),s.forEach(function(e){s.forEach(function(t){e!==t&&Cs(e,t,al)})})}function fg(s,e,t,n){s.forEach(function(i){e.forEach(function(r){Cs(i,r,t),Cs(r,i,n)})})}function ll(s,e){return s?typeof s=="string"?de(s):s:de(e)}function gg(s){return(function(e,t,n,i){const r=e.length;n=n!==void 0?n:2,i=i??n,t=t!==void 0?t:new Array(r);for(let o=0;o<r;o+=i){const a=s(e.slice(o,o+n)),l=a.length;for(let h=0,c=i;h<c;++h)t[o+h]=h>=l?e[o+h]:a[h]}return t})}function P0(s,e){return Qc(),ks(s,"EPSG:4326","EPSG:3857")}function I0(s,e){const t=ks(s,"EPSG:3857","EPSG:4326"),n=t[0];return(n<-180||n>180)&&(t[0]=en(n+180,360)-180),t}function Wn(s,e){if(s===e)return!0;const t=s.getUnits()===e.getUnits();return(s.getCode()===e.getCode()||Gs(s,e)===al)&&t}function Gs(s,e){const t=s.getCode(),n=e.getCode();let i=Ao(t,n);if(i)return i;let r=null,o=null;for(const l of hg)r||(r=l(s)),o||(o=l(e));if(!r&&!o)return null;const a="EPSG:4326";if(o)if(r)i=Lo(r.inverse,o.forward);else{const l=Ao(t,a);l&&(i=Lo(l,o.forward))}else{const l=Ao(a,n);l&&(i=Lo(r.inverse,l))}return i&&(va(s),va(e),Cs(s,e,i)),i}function Lo(s,e){return function(t,n,i,r){return n=s(t,n,i,r),e(n,n,i,r)}}function qn(s,e){const t=de(s),n=de(e);return Gs(t,n)}function ks(s,e,t){const n=qn(e,t);if(!n){const i=de(e).getCode(),r=de(t).getCode();throw new Error(`No transform available between ${i} and ${r}`)}return n(s,void 0,s.length)}function _g(s,e,t,n){const i=qn(e,t);return Ff(s,i,void 0,n)}let mg=null;function pg(){return mg}function Jn(s,e){return s}function pe(s,e){return Sa&&!Ve(s,[0,0])&&s[0]>=-180&&s[0]<=180&&s[1]>=-90&&s[1]<=90&&(Sa=!1,Vc("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),s}function so(s,e){return s}function wt(s,e){return s}function yg(){Ah(Ch),Ah(Sh),fg(Sh,Ch,Xf,Yf)}yg();const eu=new Array(6);function Ce(){return[1,0,0,1,0,0]}function Lh(s){return hl(s,1,0,0,1,0,0)}function ro(s,e){const t=s[0],n=s[1],i=s[2],r=s[3],o=s[4],a=s[5],l=e[0],h=e[1],c=e[2],u=e[3],d=e[4],f=e[5];return s[0]=t*l+i*h,s[1]=n*l+r*h,s[2]=t*c+i*u,s[3]=n*c+r*u,s[4]=t*d+i*f+o,s[5]=n*d+r*f+a,s}function hl(s,e,t,n,i,r,o){return s[0]=e,s[1]=t,s[2]=n,s[3]=i,s[4]=r,s[5]=o,s}function tu(s,e){return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=e[4],s[5]=e[5],s}function fe(s,e){const t=e[0],n=e[1];return e[0]=s[0]*t+s[2]*n+s[4],e[1]=s[1]*t+s[3]*n+s[5],e}function Fo(s,e,t){return ro(s,hl(eu,e,0,0,t,0,0))}function nu(s,e,t){return ro(s,hl(eu,1,0,0,1,e,t))}function ct(s,e,t,n,i,r,o,a){const l=Math.sin(r),h=Math.cos(r);return s[0]=n*h,s[1]=i*l,s[2]=-n*l,s[3]=i*h,s[4]=o*n*h-a*n*l+e,s[5]=o*i*l+a*i*h+t,s}function Rs(s,e){const t=xg(e);te(t!==0,"Transformation matrix cannot be inverted");const n=e[0],i=e[1],r=e[2],o=e[3],a=e[4],l=e[5];return s[0]=o/t,s[1]=-i/t,s[2]=-r/t,s[3]=n/t,s[4]=(r*l-o*a)/t,s[5]=-(n*l-i*a)/t,s}function xg(s){return s[0]*s[3]-s[1]*s[2]}const Eg=[1e5,1e5,1e5,1e5,2,2];function Tg(s){return"matrix("+s.join(", ")+")"}function wa(s){return s.substring(7,s.length-1).split(",").map(parseFloat)}function Cg(s,e){const t=wa(s),n=wa(e);for(let i=0;i<6;++i)if(Math.round((t[i]-n[i])*Eg[i])!==0)return!1;return!0}function Gt(s,e,t,n,i,r,o){r=r||[],o=o||2;let a=0;for(let l=e;l<t;l+=n){const h=s[l],c=s[l+1];r[a++]=i[0]*h+i[2]*c+i[4],r[a++]=i[1]*h+i[3]*c+i[5];for(let u=2;u<o;u++)r[a++]=s[l+u]}return r&&r.length!=a&&(r.length=a),r}function cl(s,e,t,n,i,r,o){o=o||[];const a=Math.cos(i),l=Math.sin(i),h=r[0],c=r[1];let u=0;for(let d=e;d<t;d+=n){const f=s[d]-h,g=s[d+1]-c;o[u++]=h+f*a-g*l,o[u++]=c+f*l+g*a;for(let m=d+2;m<d+n;++m)o[u++]=s[m]}return o&&o.length!=u&&(o.length=u),o}function Rg(s,e,t,n,i,r,o,a){a=a||[];const l=o[0],h=o[1];let c=0;for(let u=e;u<t;u+=n){const d=s[u]-l,f=s[u+1]-h;a[c++]=l+i*d,a[c++]=h+r*f;for(let g=u+2;g<u+n;++g)a[c++]=s[g]}return a&&a.length!=c&&(a.length=c),a}function Sg(s,e,t,n,i,r,o){o=o||[];let a=0;for(let l=e;l<t;l+=n){o[a++]=s[l]+i,o[a++]=s[l+1]+r;for(let h=l+2;h<l+n;++h)o[a++]=s[h]}return o&&o.length!=a&&(o.length=a),o}const Fh=Ce(),vg=[NaN,NaN];class iu extends Rt{constructor(){super(),this.extent_=tt(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=Dc((e,t,n)=>{if(!n)return this.getSimplifiedGeometry(t);const i=this.clone();return i.applyTransform(n),i.getSimplifiedGeometry(t)})}simplifyTransformed(e,t){return this.simplifyTransformedInternal(this.getRevision(),e,t)}clone(){return $()}closestPointXY(e,t,n,i){return $()}containsXY(e,t){return this.closestPointXY(e,t,vg,Number.MIN_VALUE)===0}getClosestPoint(e,t){return t=t||[NaN,NaN],this.closestPointXY(e[0],e[1],t,1/0),t}intersectsCoordinate(e){return this.containsXY(e[0],e[1])}computeExtent(e){return $()}getExtent(e){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&ji(t),this.extentRevision_=this.getRevision()}return If(this.extent_,e)}rotate(e,t){$()}scale(e,t,n){$()}simplify(e){return this.getSimplifiedGeometry(e*e)}getSimplifiedGeometry(e){return $()}getType(){return $()}applyTransform(e){$()}intersectsExtent(e){return $()}translate(e,t){$()}transform(e,t){const n=de(e),i=n.getUnits()=="tile-pixels"?function(r,o,a){const l=n.getExtent(),h=n.getWorldExtent(),c=be(h)/be(l);ct(Fh,h[0],h[3],c,-c,0,0,0);const u=Gt(r,0,r.length,a,Fh,o),d=qn(n,t);return d?d(u,u,a):u}:qn(n,t);return this.applyTransform(i),this}}class Mn extends iu{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(e){return Qa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinates(){return $()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const t=this.getSimplifiedGeometryInternal(e);return t.getFlatCoordinates().length<this.flatCoordinates.length?t:(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getSimplifiedGeometryInternal(e){return this}getStride(){return this.stride}setFlatCoordinates(e,t){this.stride=Mr(e),this.layout=e,this.flatCoordinates=t}setCoordinates(e,t){$()}setLayout(e,t,n){let i;if(e)i=Mr(e);else{for(let r=0;r<n;++r){if(t.length===0){this.layout="XY",this.stride=2;return}t=t[0]}i=t.length,e=ii(i)}this.layout=e,this.stride=i}applyTransform(e){this.flatCoordinates&&(e(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(e,t){const n=this.getFlatCoordinates();if(n){const i=this.getStride();cl(n,0,n.length,i,e,t,n),this.changed()}}scale(e,t,n){t===void 0&&(t=e),n||(n=In(this.getExtent()));const i=this.getFlatCoordinates();if(i){const r=this.getStride();Rg(i,0,i.length,r,e,t,n,i),this.changed()}}translate(e,t){const n=this.getFlatCoordinates();if(n){const i=this.getStride();Sg(n,0,n.length,i,e,t,n),this.changed()}}}function ii(s){let e;return s==2?e="XY":s==3?e="XYZ":s==4&&(e="XYZM"),e}function Mr(s){let e;return s=="XY"?e=2:s=="XYZ"||s=="XYM"?e=3:s=="XYZM"&&(e=4),e}function wg(s,e,t){const n=s.getFlatCoordinates();if(!n)return null;const i=s.getStride();return Gt(n,0,n.length,i,e,t)}function su(s,e,t,n){let i=0;const r=s[t-n],o=s[t-n+1];let a=0,l=0;for(;e<t;e+=n){const h=s[e]-r,c=s[e+1]-o;i+=l*h-a*c,a=h,l=c}return i/2}function ru(s,e,t,n){let i=0;for(let r=0,o=t.length;r<o;++r){const a=t[r];i+=su(s,e,a,n),e=a}return i}function Pg(s,e,t,n){let i=0;for(let r=0,o=t.length;r<o;++r){const a=t[r];i+=ru(s,e,a,n),e=a[a.length-1]}return i}function Mh(s,e,t,n,i,r,o){const a=s[e],l=s[e+1],h=s[t]-a,c=s[t+1]-l;let u;if(h===0&&c===0)u=e;else{const d=((i-a)*h+(r-l)*c)/(h*h+c*c);if(d>1)u=t;else if(d>0){for(let f=0;f<n;++f)o[f]=rt(s[e+f],s[t+f],d);o.length=n;return}else u=e}for(let d=0;d<n;++d)o[d]=s[u+d];o.length=n}function ul(s,e,t,n,i){let r=s[e],o=s[e+1];for(e+=n;e<t;e+=n){const a=s[e],l=s[e+1],h=Qt(r,o,a,l);h>i&&(i=h),r=a,o=l}return i}function dl(s,e,t,n,i){for(let r=0,o=t.length;r<o;++r){const a=t[r];i=ul(s,e,a,n,i),e=a}return i}function Ig(s,e,t,n,i){for(let r=0,o=t.length;r<o;++r){const a=t[r];i=dl(s,e,a,n,i),e=a[a.length-1]}return i}function fl(s,e,t,n,i,r,o,a,l,h,c){if(e==t)return h;let u,d;if(i===0){if(d=Qt(o,a,s[e],s[e+1]),d<h){for(u=0;u<n;++u)l[u]=s[e+u];return l.length=n,d}return h}c=c||[NaN,NaN];let f=e+n;for(;f<t;)if(Mh(s,f-n,f,n,o,a,c),d=Qt(o,a,c[0],c[1]),d<h){for(h=d,u=0;u<n;++u)l[u]=c[u];l.length=n,f+=n}else f+=n*Math.max((Math.sqrt(d)-Math.sqrt(h))/i|0,1);if(r&&(Mh(s,t-n,e,n,o,a,c),d=Qt(o,a,c[0],c[1]),d<h)){for(h=d,u=0;u<n;++u)l[u]=c[u];l.length=n}return h}function gl(s,e,t,n,i,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=t.length;u<d;++u){const f=t[u];h=fl(s,e,f,n,i,r,o,a,l,h,c),e=f}return h}function Ag(s,e,t,n,i,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=t.length;u<d;++u){const f=t[u];h=gl(s,e,f,n,i,r,o,a,l,h,c),e=f[f.length-1]}return h}function ou(s,e,t,n){for(let i=0,r=t.length;i<r;++i)s[e++]=t[i];return e}function oo(s,e,t,n){for(let i=0,r=t.length;i<r;++i){const o=t[i];for(let a=0;a<n;++a)s[e++]=o[a]}return e}function Us(s,e,t,n,i){i=i||[];let r=0;for(let o=0,a=t.length;o<a;++o){const l=oo(s,e,t[o],n);i[r++]=l,e=l}return i.length=r,i}function au(s,e,t,n,i){i=i||[];let r=0;for(let o=0,a=t.length;o<a;++o){const l=Us(s,e,t[o],n,i[r]);l.length===0&&(l[0]=e),i[r++]=l,e=l[l.length-1]}return i.length=r,i}function xn(s,e,t,n,i){i=i!==void 0?i:[];let r=0;for(let o=e;o<t;o+=n)i[r++]=s.slice(o,o+n);return i.length=r,i}function Ss(s,e,t,n,i){i=i!==void 0?i:[];let r=0;for(let o=0,a=t.length;o<a;++o){const l=t[o];i[r++]=xn(s,e,l,n,i[r]),e=l}return i.length=r,i}function Pa(s,e,t,n,i){i=i!==void 0?i:[];let r=0;for(let o=0,a=t.length;o<a;++o){const l=t[o];i[r++]=l.length===1&&l[0]===e?[]:Ss(s,e,l,n,i[r]),e=l[l.length-1]}return i.length=r,i}function ao(s,e,t,n,i,r,o){const a=(t-e)/n;if(a<3){for(;e<t;e+=n)r[o++]=s[e],r[o++]=s[e+1];return o}const l=new Array(a);l[0]=1,l[a-1]=1;const h=[e,t-n];let c=0;for(;h.length>0;){const u=h.pop(),d=h.pop();let f=0;const g=s[d],m=s[d+1],_=s[u],p=s[u+1];for(let y=d+n;y<u;y+=n){const E=s[y],x=s[y+1],T=Cf(E,x,g,m,_,p);T>f&&(c=y,f=T)}f>i&&(l[(c-e)/n]=1,d+n<c&&h.push(d,c),c+n<u&&h.push(c,u))}for(let u=0;u<a;++u)l[u]&&(r[o++]=s[e+u*n],r[o++]=s[e+u*n+1]);return o}function lu(s,e,t,n,i,r,o,a){for(let l=0,h=t.length;l<h;++l){const c=t[l];o=ao(s,e,c,n,i,r,o),a.push(o),e=c}return o}function kn(s,e){return e*Math.round(s/e)}function Lg(s,e,t,n,i,r,o){if(e==t)return o;let a=kn(s[e],i),l=kn(s[e+1],i);e+=n,r[o++]=a,r[o++]=l;let h,c;do if(h=kn(s[e],i),c=kn(s[e+1],i),e+=n,e==t)return r[o++]=h,r[o++]=c,o;while(h==a&&c==l);for(;e<t;){const u=kn(s[e],i),d=kn(s[e+1],i);if(e+=n,u==h&&d==c)continue;const f=h-a,g=c-l,m=u-a,_=d-l;if(f*_==g*m&&(f<0&&m<f||f==m||f>0&&m>f)&&(g<0&&_<g||g==_||g>0&&_>g)){h=u,c=d;continue}r[o++]=h,r[o++]=c,a=h,l=c,h=u,c=d}return r[o++]=h,r[o++]=c,o}function _l(s,e,t,n,i,r,o,a){for(let l=0,h=t.length;l<h;++l){const c=t[l];o=Lg(s,e,c,n,i,r,o),a.push(o),e=c}return o}function Fg(s,e,t,n,i,r,o,a){for(let l=0,h=t.length;l<h;++l){const c=t[l],u=[];o=_l(s,e,c,n,i,r,o,u),a.push(u),e=c[c.length-1]}return o}class vs extends Mn{constructor(e,t){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,t!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(t,e):this.setCoordinates(e,t)}clone(){return new vs(this.flatCoordinates.slice(),this.layout)}closestPointXY(e,t,n,i){return i<ti(this.getExtent(),e,t)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(ul(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),fl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,e,t,n,i))}getArea(){return su(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return xn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(e){const t=[];return t.length=ao(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t,0),new vs(t,"XY")}getType(){return"LinearRing"}intersectsExtent(e){return!1}setCoordinates(e,t){this.setLayout(t,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=oo(this.flatCoordinates,0,e,this.stride),this.changed()}}class lt extends Mn{constructor(e,t){super(),this.setCoordinates(e,t)}clone(){const e=new lt(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,t,n,i){const r=this.flatCoordinates,o=Qt(e,t,r[0],r[1]);if(o<i){const a=this.stride;for(let l=0;l<a;++l)n[l]=r[l];return n.length=a,o}return i}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(e){return fs(this.flatCoordinates,e)}getType(){return"Point"}intersectsExtent(e){return Ja(e,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(e,t){this.setLayout(t,e,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ou(this.flatCoordinates,0,e,this.stride),this.changed()}}function Mg(s,e,t,n,i){return!el(i,function(o){return!zn(s,e,t,n,o[0],o[1])})}function zn(s,e,t,n,i,r){let o=0,a=s[t-n],l=s[t-n+1];for(;e<t;e+=n){const h=s[e],c=s[e+1];l<=r?c>r&&(h-a)*(r-l)-(i-a)*(c-l)>0&&o++:c<=r&&(h-a)*(r-l)-(i-a)*(c-l)<0&&o--,a=h,l=c}return o!==0}function ml(s,e,t,n,i,r){if(t.length===0||!zn(s,e,t[0],n,i,r))return!1;for(let o=1,a=t.length;o<a;++o)if(zn(s,t[o-1],t[o],n,i,r))return!1;return!0}function bg(s,e,t,n,i,r){if(t.length===0)return!1;for(let o=0,a=t.length;o<a;++o){const l=t[o];if(ml(s,e,l,n,i,r))return!0;e=l[l.length-1]}return!1}function pl(s,e,t,n,i,r,o){let a,l,h,c,u,d,f;const g=i[r+1],m=[];for(let y=0,E=t.length;y<E;++y){const x=t[y];for(c=s[x-n],d=s[x-n+1],a=e;a<x;a+=n)u=s[a],f=s[a+1],(g<=d&&f<=g||d<=g&&g<=f)&&(h=(g-d)/(f-d)*(u-c)+c,m.push(h)),c=u,d=f}let _=NaN,p=-1/0;for(m.sort(Nt),c=m[0],a=1,l=m.length;a<l;++a){u=m[a];const y=Math.abs(u-c);y>p&&(h=(c+u)/2,ml(s,e,t,n,h,g)&&(_=h,p=y)),c=u}return isNaN(_)&&(_=i[r]),o?(o.push(_,g,p),o):[_,g,p]}function hu(s,e,t,n,i){let r=[];for(let o=0,a=t.length;o<a;++o){const l=t[o];r=pl(s,e,l,n,i,2*o,r),e=l[l.length-1]}return r}function cu(s,e,t,n,i){let r;for(e+=n;e<t;e+=n)if(r=i(s.slice(e-n,e),s.slice(e,e+n)),r)return r;return!1}function lo(s,e,t,n,i,r){return r=r??zc(tt(),s,e,t,n),Te(i,r)?r[0]>=i[0]&&r[2]<=i[2]||r[1]>=i[1]&&r[3]<=i[3]?!0:cu(s,e,t,n,function(o,a){return Lf(i,o,a)}):!1}function Dg(s,e,t,n,i){for(let r=0,o=t.length;r<o;++r){if(lo(s,e,t[r],n,i))return!0;e=t[r]}return!1}function uu(s,e,t,n,i){return!!(lo(s,e,t,n,i)||zn(s,e,t,n,i[0],i[1])||zn(s,e,t,n,i[0],i[3])||zn(s,e,t,n,i[2],i[1])||zn(s,e,t,n,i[2],i[3]))}function du(s,e,t,n,i){if(!uu(s,e,t[0],n,i))return!1;if(t.length===1)return!0;for(let r=1,o=t.length;r<o;++r)if(Mg(s,t[r-1],t[r],n,i)&&!lo(s,t[r-1],t[r],n,i))return!1;return!0}function Og(s,e,t,n,i){for(let r=0,o=t.length;r<o;++r){const a=t[r];if(du(s,e,a,n,i))return!0;e=a[a.length-1]}return!1}function Ng(s,e,t,n){for(;e<t-n;){for(let i=0;i<n;++i){const r=s[e+i];s[e+i]=s[t-n+i],s[t-n+i]=r}e+=n,t-=n}}function yl(s,e,t,n){let i=0,r=s[t-n],o=s[t-n+1];for(;e<t;e+=n){const a=s[e],l=s[e+1];i+=(a-r)*(l+o),r=a,o=l}return i===0?void 0:i>0}function xl(s,e,t,n,i){i=i!==void 0?i:!1;for(let r=0,o=t.length;r<o;++r){const a=t[r],l=yl(s,e,a,n);if(r===0){if(i&&l||!i&&!l)return!1}else if(i&&!l||!i&&l)return!1;e=a}return!0}function fu(s,e,t,n,i){for(let r=0,o=t.length;r<o;++r){const a=t[r];if(!xl(s,e,a,n,i))return!1;a.length&&(e=a[a.length-1])}return!0}function br(s,e,t,n,i){i=i!==void 0?i:!1;for(let r=0,o=t.length;r<o;++r){const a=t[r],l=yl(s,e,a,n);(r===0?i&&l||!i&&!l:i&&!l||!i&&l)&&Ng(s,e,a,n),e=a}return e}function Ia(s,e,t,n,i){for(let r=0,o=t.length;r<o;++r)e=br(s,e,t[r],n,i);return e}function gu(s,e){const t=[];let n=0,i=0,r;for(let o=0,a=e.length;o<a;++o){const l=e[o],h=yl(s,n,l,2);if(r===void 0&&(r=h),h===r)t.push(e.slice(i,o+1));else{if(t.length===0)continue;t[t.length-1].push(e[i])}i=o+1,n=l}return t}class qe extends Mn{constructor(e,t,n){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,t!==void 0&&n?(this.setFlatCoordinates(t,e),this.ends_=n):this.setCoordinates(e,t)}appendLinearRing(e){this.flatCoordinates?ne(this.flatCoordinates,e.getFlatCoordinates()):this.flatCoordinates=e.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const e=new qe(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,t,n,i){return i<ti(this.getExtent(),e,t)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(dl(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),gl(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,e,t,n,i))}containsXY(e,t){return ml(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,t)}getArea(){return ru(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(e){let t;return e!==void 0?(t=this.getOrientedFlatCoordinates().slice(),br(t,0,this.ends_,this.stride,e)):t=this.flatCoordinates,Ss(t,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const e=In(this.getExtent());this.flatInteriorPoint_=pl(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new lt(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(e){return e<0||this.ends_.length<=e?null:new vs(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLinearRings(){const e=this.layout,t=this.flatCoordinates,n=this.ends_,i=[];let r=0;for(let o=0,a=n.length;o<a;++o){const l=n[o],h=new vs(t.slice(r,l),e);i.push(h),r=l}return i}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const e=this.flatCoordinates;xl(e,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=br(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){const t=[],n=[];return t.length=_l(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(e),t,0,n),new qe(t,"XY",n)}getType(){return"Polygon"}intersectsExtent(e){return du(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e)}setCoordinates(e,t){this.setLayout(t,e,2),this.flatCoordinates||(this.flatCoordinates=[]);const n=Us(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=n.length===0?0:n[n.length-1],this.changed()}}function Gg(s,e,t,n){t=t||32;const i=[];for(let r=0;r<t;++r)ne(i,Bf(s,e,2*Math.PI*r/t,n));return i.push(i[0],i[1]),new qe(i,"XY",[i.length])}function bh(s){if(ni(s))throw new Error("Cannot create polygon from empty extent");const e=s[0],t=s[1],n=s[2],i=s[3],r=[e,t,e,i,n,i,n,t,e,t];return new qe(r,"XY",[r.length])}function A0(s,e,t){e=e||32;const n=s.getStride(),i=s.getLayout(),r=s.getCenter(),o=n*(e+1),a=new Array(o);for(let c=0;c<o;c+=n){a[c]=0,a[c+1]=0;for(let u=2;u<n;u++)a[c+u]=r[u]}const l=[a.length],h=new qe(a,i,l);return kg(h,r,s.getRadius(),t),h}function kg(s,e,t,n){const i=s.getFlatCoordinates(),r=s.getStride(),o=i.length/r-1,a=n||0;for(let l=0;l<=o;++l){const h=l*r,c=a+en(l,o)*2*Math.PI/o;i[h]=e[0]+t*Math.cos(c),i[h+1]=e[1]+t*Math.sin(c)}s.changed()}function El(s,e,t,n){const i=ie(e)/t[0],r=be(e)/t[1];return n?Math.min(s,Math.max(i,r)):Math.min(s,Math.min(i,r))}function Tl(s,e,t){let n=Math.min(s,e);const i=50;return n*=Math.log(1+i*Math.max(0,s/e-1))/i+1,t&&(n=Math.max(n,t),n/=Math.log(1+i*Math.max(0,t/s-1))/i+1),ge(n,t/2,e*2)}function Ug(s,e,t,n){return e=e!==void 0?e:!0,(function(i,r,o,a){if(i!==void 0){const l=s[0],h=s[s.length-1],c=t?El(l,t,o,n):l;if(a)return e?Tl(i,c,h):ge(i,h,c);const u=Math.min(c,i),d=Math.floor(qa(s,u,r));return s[d]>c&&d<s.length-1?s[d+1]:s[d]}})}function Bg(s,e,t,n,i,r){return n=n!==void 0?n:!0,t=t!==void 0?t:0,(function(o,a,l,h){if(o!==void 0){const c=i?El(e,i,l,r):e;if(h)return n?Tl(o,c,t):ge(o,t,c);const u=1e-9,d=Math.ceil(Math.log(e/c)/Math.log(s)-u),f=-a*(.5-u)+.5,g=Math.min(c,o),m=Math.floor(Math.log(e/g)/Math.log(s)+f),_=Math.max(d,m),p=e/Math.pow(s,_);return ge(p,t,c)}})}function Dh(s,e,t,n,i){return t=t!==void 0?t:!0,(function(r,o,a,l){if(r!==void 0){const h=n?El(s,n,a,i):s;return!t||!l?ge(r,e,h):Tl(r,h,e)}})}function Cl(s){if(s!==void 0)return 0}function Oh(s){if(s!==void 0)return s}function zg(s){const e=2*Math.PI/s;return(function(t,n){if(n)return t;if(t!==void 0)return t=Math.floor(t/e+.5)*e,t})}function $g(s){const e=Ke(5);return(function(t,n){return n||t===void 0?t:Math.abs(t)<=e?0:t})}const Xg=42,Rl=256,Mo=0;class Jt extends Rt{constructor(e){super(),this.on,this.once,this.un,e=Object.assign({},e),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=ll(e.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,e.projection&&Qc(),e.center&&(e.center=pe(e.center,this.projection_)),e.extent&&(e.extent=wt(e.extent,this.projection_)),this.applyOptions_(e)}applyOptions_(e){const t=Object.assign({},e);for(const a in vt)delete t[a];this.setProperties(t,!0);const n=jg(e);this.maxResolution_=n.maxResolution,this.minResolution_=n.minResolution,this.zoomFactor_=n.zoomFactor,this.resolutions_=e.resolutions,this.padding_=e.padding,this.minZoom_=n.minZoom;const i=Yg(e),r=n.constraint,o=Wg(e);this.constraints_={center:i,resolution:r,rotation:o},this.setRotation(e.rotation!==void 0?e.rotation:0),this.setCenterInternal(e.center!==void 0?e.center:null),e.resolution!==void 0?this.setResolution(e.resolution):e.zoom!==void 0&&this.setZoom(e.zoom)}get padding(){return this.padding_}set padding(e){let t=this.padding_;this.padding_=e;const n=this.getCenterInternal();if(n){const i=e||[0,0,0,0];t=t||[0,0,0,0];const r=this.getResolution(),o=r/2*(i[3]-t[3]+t[1]-i[1]),a=r/2*(i[0]-t[0]+t[2]-i[2]);this.setCenterInternal([n[0]+o,n[1]-a])}}getUpdatedOptions_(e){const t=this.getProperties();return t.resolution!==void 0?t.resolution=this.getResolution():t.zoom=this.getZoom(),t.center=this.getCenterInternal(),t.rotation=this.getRotation(),Object.assign({},t,e)}animate(e){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);const t=new Array(arguments.length);for(let n=0;n<t.length;++n){let i=arguments[n];i.center&&(i=Object.assign({},i),i.center=pe(i.center,this.getProjection())),i.anchor&&(i=Object.assign({},i),i.anchor=pe(i.anchor,this.getProjection())),t[n]=i}this.animateInternal.apply(this,t)}animateInternal(e){let t=arguments.length,n;t>1&&typeof arguments[t-1]=="function"&&(n=arguments[t-1],--t);let i=0;for(;i<t&&!this.isDef();++i){const c=arguments[i];c.center&&this.setCenterInternal(c.center),c.zoom!==void 0?this.setZoom(c.zoom):c.resolution&&this.setResolution(c.resolution),c.rotation!==void 0&&this.setRotation(c.rotation)}if(i===t){n&&tr(n,!0);return}let r=Date.now(),o=this.targetCenter_.slice(),a=this.targetResolution_,l=this.targetRotation_;const h=[];for(;i<t;++i){const c=arguments[i],u={start:r,complete:!1,anchor:c.anchor,duration:c.duration!==void 0?c.duration:1e3,easing:c.easing||Nf,callback:n};if(c.center&&(u.sourceCenter=o,u.targetCenter=c.center.slice(),o=u.targetCenter),c.zoom!==void 0?(u.sourceResolution=a,u.targetResolution=this.getResolutionForZoom(c.zoom),a=u.targetResolution):c.resolution&&(u.sourceResolution=a,u.targetResolution=c.resolution,a=u.targetResolution),c.rotation!==void 0){u.sourceRotation=l;const d=en(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;u.targetRotation=l+d,l=u.targetRotation}Vg(u)?u.complete=!0:r+=u.duration,h.push(u)}this.animations_.push(h),this.setHint(he.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[he.ANIMATING]>0}getInteracting(){return this.hints_[he.INTERACTING]>0}cancelAnimations(){this.setHint(he.ANIMATING,-this.hints_[he.ANIMATING]);let e;for(let t=0,n=this.animations_.length;t<n;++t){const i=this.animations_[t];if(i[0].callback&&tr(i[0].callback,!1),!e)for(let r=0,o=i.length;r<o;++r){const a=i[r];if(!a.complete){e=a.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=e,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;const e=Date.now();let t=!1;for(let n=this.animations_.length-1;n>=0;--n){const i=this.animations_[n];let r=!0;for(let o=0,a=i.length;o<a;++o){const l=i[o];if(l.complete)continue;const h=e-l.start;let c=l.duration>0?h/l.duration:1;c>=1?(l.complete=!0,c=1):r=!1;const u=l.easing(c);if(l.sourceCenter){const d=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],m=l.targetCenter[1];this.nextCenter_=l.targetCenter;const _=d+u*(g-d),p=f+u*(m-f);this.targetCenter_=[_,p]}if(l.sourceResolution&&l.targetResolution){const d=u===1?l.targetResolution:l.sourceResolution+u*(l.targetResolution-l.sourceResolution);if(l.anchor){const f=this.getViewportSize_(this.getRotation()),g=this.constraints_.resolution(d,0,f,!0);this.targetCenter_=this.calculateCenterZoom(g,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=d,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){const d=u===1?en(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+u*(l.targetRotation-l.sourceRotation);if(l.anchor){const f=this.constraints_.rotation(d,!0);this.targetCenter_=this.calculateCenterRotate(f,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=d}if(this.applyTargetState_(!0),t=!0,!l.complete)break}if(r){this.animations_[n]=null,this.setHint(he.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=i[0].callback;o&&tr(o,!0)}}this.animations_=this.animations_.filter(Boolean),t&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(e,t){let n;const i=this.getCenterInternal();return i!==void 0&&(n=[i[0]-t[0],i[1]-t[1]],nl(n,e-this.getRotation()),Mf(n,t)),n}calculateCenterZoom(e,t){let n;const i=this.getCenterInternal(),r=this.getResolution();if(i!==void 0&&r!==void 0){const o=t[0]-e*(t[0]-i[0])/r,a=t[1]-e*(t[1]-i[1])/r;n=[o,a]}return n}getViewportSize_(e){const t=this.viewportSize_;if(e){const n=t[0],i=t[1];return[Math.abs(n*Math.cos(e))+Math.abs(i*Math.sin(e)),Math.abs(n*Math.sin(e))+Math.abs(i*Math.cos(e))]}return t}setViewportSize(e){this.viewportSize_=Array.isArray(e)?e.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const e=this.getCenterInternal();return e&&Jn(e,this.getProjection())}getCenterInternal(){return this.get(vt.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(e){return e!==void 0?(e[0]=this.hints_[0],e[1]=this.hints_[1],e):this.hints_.slice()}calculateExtent(e){const t=this.calculateExtentInternal(e);return so(t,this.getProjection())}calculateExtentInternal(e){e=e||this.getViewportSizeMinusPadding_();const t=this.getCenterInternal();te(t,"The view center is not defined");const n=this.getResolution();te(n!==void 0,"The view resolution is not defined");const i=this.getRotation();return te(i!==void 0,"The view rotation is not defined"),Ta(t,n,i,e)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(e){this.applyOptions_(this.getUpdatedOptions_({maxZoom:e}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(e){this.applyOptions_(this.getUpdatedOptions_({minZoom:e}))}setConstrainResolution(e){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:e}))}getProjection(){return this.projection_}getResolution(){return this.get(vt.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(e,t){return this.getResolutionForExtentInternal(wt(e,this.getProjection()),t)}getResolutionForExtentInternal(e,t){t=t||this.getViewportSizeMinusPadding_();const n=ie(e)/t[0],i=be(e)/t[1];return Math.max(n,i)}getResolutionForValueFunction(e){e=e||2;const t=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,i=Math.log(t/n)/Math.log(e);return(function(r){return t/Math.pow(e,r*i)})}getRotation(){return this.get(vt.ROTATION)}getValueForResolutionFunction(e){const t=Math.log(e||2),n=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,r=Math.log(n/i)/t;return(function(o){return Math.log(n/o)/t/r})}getViewportSizeMinusPadding_(e){let t=this.getViewportSize_(e);const n=this.padding_;return n&&(t=[t[0]-n[1]-n[3],t[1]-n[0]-n[2]]),t}getState(){const e=this.getProjection(),t=this.getResolution(),n=this.getRotation();let i=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();i=bo(i,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],t,n)}return{center:i.slice(0),projection:e!==void 0?e:null,resolution:t,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:n,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let e;const t=this.getResolution();return t!==void 0&&(e=this.getZoomForResolution(t)),e}getZoomForResolution(e){let t=this.minZoom_||0,n,i;if(this.resolutions_){const r=qa(this.resolutions_,e,1);t=r,n=this.resolutions_[r],r==this.resolutions_.length-1?i=2:i=n/this.resolutions_[r+1]}else n=this.maxResolution_,i=this.zoomFactor_;return t+Math.log(n/e)/Math.log(i)}getResolutionForZoom(e){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];const t=ge(Math.floor(e),0,this.resolutions_.length-2),n=this.resolutions_[t]/this.resolutions_[t+1];return this.resolutions_[t]/Math.pow(n,ge(e-t,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,e-this.minZoom_)}fit(e,t){let n;if(te(Array.isArray(e)||typeof e.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(e)){te(!ni(e),"Cannot fit empty extent provided as `geometry`");const i=wt(e,this.getProjection());n=bh(i)}else if(e.getType()==="Circle"){const i=wt(e.getExtent(),this.getProjection());n=bh(i),n.rotate(this.getRotation(),In(i))}else n=e;this.fitInternal(n,t)}rotatedExtentForGeometry(e){const t=this.getRotation(),n=Math.cos(t),i=Math.sin(-t),r=e.getFlatCoordinates(),o=e.getStride();let a=1/0,l=1/0,h=-1/0,c=-1/0;for(let u=0,d=r.length;u<d;u+=o){const f=r[u]*n-r[u+1]*i,g=r[u]*i+r[u+1]*n;a=Math.min(a,f),l=Math.min(l,g),h=Math.max(h,f),c=Math.max(c,g)}return[a,l,h,c]}fitInternal(e,t){t=t||{};let n=t.size;n||(n=this.getViewportSizeMinusPadding_());const i=t.padding!==void 0?t.padding:[0,0,0,0],r=t.nearest!==void 0?t.nearest:!1;let o;t.minResolution!==void 0?o=t.minResolution:t.maxZoom!==void 0?o=this.getResolutionForZoom(t.maxZoom):o=0;const a=this.rotatedExtentForGeometry(e);let l=this.getResolutionForExtentInternal(a,[n[0]-i[1]-i[3],n[1]-i[0]-i[2]]);l=isNaN(l)?o:Math.max(l,o),l=this.getConstrainedResolution(l,r?0:1);const h=this.getRotation(),c=Math.sin(h),u=Math.cos(h),d=In(a);d[0]+=(i[1]-i[3])/2*l,d[1]+=(i[0]-i[2])/2*l;const f=d[0]*u-d[1]*c,g=d[1]*u+d[0]*c,m=this.getConstrainedCenter([f,g],l),_=t.callback?t.callback:Ts;t.duration!==void 0?this.animateInternal({resolution:l,center:m,duration:t.duration,easing:t.easing},_):(this.targetResolution_=l,this.targetCenter_=m,this.applyTargetState_(!1,!0),tr(_,!0))}centerOn(e,t,n){this.centerOnInternal(pe(e,this.getProjection()),t,n)}centerOnInternal(e,t,n){this.setCenterInternal(bo(e,t,n,this.getResolution(),this.getRotation()))}calculateCenterShift(e,t,n,i){let r;const o=this.padding_;if(o&&e){const a=this.getViewportSizeMinusPadding_(-n),l=bo(e,i,[a[0]/2+o[3],a[1]/2+o[0]],t,n);r=[e[0]-l[0],e[1]-l[1]]}return r}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(e){const t=Jn(this.targetCenter_,this.getProjection());this.setCenter([t[0]+e[0],t[1]+e[1]])}adjustCenterInternal(e){const t=this.targetCenter_;this.setCenterInternal([t[0]+e[0],t[1]+e[1]])}adjustResolution(e,t){t=t&&pe(t,this.getProjection()),this.adjustResolutionInternal(e,t)}adjustResolutionInternal(e,t){const n=this.getAnimating()||this.getInteracting(),i=this.getViewportSize_(this.getRotation()),r=this.constraints_.resolution(this.targetResolution_*e,0,i,n);t&&(this.targetCenter_=this.calculateCenterZoom(r,t)),this.targetResolution_*=e,this.applyTargetState_()}adjustZoom(e,t){this.adjustResolution(Math.pow(this.zoomFactor_,-e),t)}adjustRotation(e,t){t&&(t=pe(t,this.getProjection())),this.adjustRotationInternal(e,t)}adjustRotationInternal(e,t){const n=this.getAnimating()||this.getInteracting(),i=this.constraints_.rotation(this.targetRotation_+e,n);t&&(this.targetCenter_=this.calculateCenterRotate(i,t)),this.targetRotation_+=e,this.applyTargetState_()}setCenter(e){this.setCenterInternal(e&&pe(e,this.getProjection()))}setCenterInternal(e){this.targetCenter_=e,this.applyTargetState_()}setHint(e,t){return this.hints_[e]+=t,this.changed(),this.hints_[e]}setResolution(e){this.targetResolution_=e,this.applyTargetState_()}setRotation(e){this.targetRotation_=e,this.applyTargetState_()}setZoom(e){this.setResolution(this.getResolutionForZoom(e))}applyTargetState_(e,t){const n=this.getAnimating()||this.getInteracting()||t,i=this.constraints_.rotation(this.targetRotation_,n),r=this.getViewportSize_(i),o=this.constraints_.resolution(this.targetResolution_,0,r,n),a=this.constraints_.center(this.targetCenter_,o,r,n,this.calculateCenterShift(this.targetCenter_,o,i,r));this.get(vt.ROTATION)!==i&&this.set(vt.ROTATION,i),this.get(vt.RESOLUTION)!==o&&(this.set(vt.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(vt.CENTER)||!Ve(this.get(vt.CENTER),a))&&this.set(vt.CENTER,a),this.getAnimating()&&!e&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(e,t,n){e=e!==void 0?e:200;const i=t||0,r=this.constraints_.rotation(this.targetRotation_),o=this.getViewportSize_(r),a=this.constraints_.resolution(this.targetResolution_,i,o),l=this.constraints_.center(this.targetCenter_,a,o,!1,this.calculateCenterShift(this.targetCenter_,a,r,o));if(e===0&&!this.cancelAnchor_){this.targetResolution_=a,this.targetRotation_=r,this.targetCenter_=l,this.applyTargetState_();return}n=n||(e===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==a||this.getRotation()!==r||!this.getCenterInternal()||!Ve(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:l,resolution:a,duration:e,easing:Wi,anchor:n}))}beginInteraction(){this.resolveConstraints(0),this.setHint(he.INTERACTING,1)}endInteraction(e,t,n){n=n&&pe(n,this.getProjection()),this.endInteractionInternal(e,t,n)}endInteractionInternal(e,t,n){this.getInteracting()&&(this.setHint(he.INTERACTING,-1),this.resolveConstraints(e,t,n))}getConstrainedCenter(e,t){const n=this.getViewportSize_(this.getRotation());return this.constraints_.center(e,t||this.getResolution(),n)}getConstrainedZoom(e,t){const n=this.getResolutionForZoom(e);return this.getZoomForResolution(this.getConstrainedResolution(n,t))}getConstrainedResolution(e,t){t=t||0;const n=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(e,t,n)}}function tr(s,e){setTimeout(function(){s(e)},0)}function Yg(s){if(s.extent!==void 0){const t=s.smoothExtentConstraint!==void 0?s.smoothExtentConstraint:!0;return Th(s.extent,s.constrainOnlyCenter,t)}const e=ll(s.projection,"EPSG:3857");if(s.multiWorld!==!0&&e.isGlobal()){const t=e.getExtent().slice();return t[0]=-1/0,t[2]=1/0,Th(t,!1,!1)}return Sf}function jg(s){let e,t,n,o=s.minZoom!==void 0?s.minZoom:Mo,a=s.maxZoom!==void 0?s.maxZoom:28;const l=s.zoomFactor!==void 0?s.zoomFactor:2,h=s.multiWorld!==void 0?s.multiWorld:!1,c=s.smoothResolutionConstraint!==void 0?s.smoothResolutionConstraint:!0,u=s.showFullExtent!==void 0?s.showFullExtent:!1,d=ll(s.projection,"EPSG:3857"),f=d.getExtent();let g=s.constrainOnlyCenter,m=s.extent;if(!h&&!m&&d.isGlobal()&&(g=!1,m=f),s.resolutions!==void 0){const _=s.resolutions;t=_[o],n=_[a]!==void 0?_[a]:_[_.length-1],s.constrainResolution?e=Ug(_,c,!g&&m,u):e=Dh(t,n,c,!g&&m,u)}else{const p=(f?Math.max(ie(f),be(f)):360*ki.degrees/d.getMetersPerUnit())/Rl/Math.pow(2,Mo),y=p/Math.pow(2,28-Mo);t=s.maxResolution,t!==void 0?o=0:t=p/Math.pow(l,o),n=s.minResolution,n===void 0&&(s.maxZoom!==void 0?s.maxResolution!==void 0?n=t/Math.pow(l,a):n=p/Math.pow(l,a):n=y),a=o+Math.floor(Math.log(t/n)/Math.log(l)),n=t/Math.pow(l,a-o),s.constrainResolution?e=Bg(l,t,n,c,!g&&m,u):e=Dh(t,n,c,!g&&m,u)}return{constraint:e,maxResolution:t,minResolution:n,minZoom:o,zoomFactor:l}}function Wg(s){if(s.enableRotation!==void 0?s.enableRotation:!0){const t=s.constrainRotation;return t===void 0||t===!0?$g():t===!1?Oh:typeof t=="number"?zg(t):Oh}return Cl}function Vg(s){return!(s.sourceCenter&&s.targetCenter&&!Ve(s.sourceCenter,s.targetCenter)||s.sourceResolution!==s.targetResolution||s.sourceRotation!==s.targetRotation)}function bo(s,e,t,n,i){const r=Math.cos(-i);let o=Math.sin(-i),a=s[0]*r-s[1]*o,l=s[1]*r+s[0]*o;a+=(e[0]/2-t[0])*n,l+=(t[1]-e[1]/2)*n,o=-o;const h=a*r-l*o,c=l*r+a*o;return[h,c]}const nr="ol-hidden",Zg="ol-selectable",Bs="ol-unselectable",Sl="ol-control",Nh="ol-collapsed",Kg=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z0-9]+?)\\s*$`].join(""),"i"),Gh=["style","variant","weight","size","lineHeight","family"],Aa={normal:400,bold:700},La=function(s){const e=s.match(Kg);if(!e)return null;const t={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let n=0,i=Gh.length;n<i;++n){const r=e[n+1];r!==void 0&&(t[Gh[n]]=typeof r=="string"?r.trim():r)}return isNaN(Number(t.weight))&&t.weight in Aa&&(t.weight=Aa[t.weight]),t.families=t.family.split(/,\s?/).map(n=>n.trim().replace(/^['"]|['"]$/g,"")),t};function we(s,e,t,n){let i;return t&&t.length?i=t.shift():at?i=new class extends OffscreenCanvas{style={}}(s??300,e??150):i=document.createElement("canvas"),s&&(i.width=s),e&&(i.height=e),i.getContext("2d",n)}let Do;function Dr(){return Do||(Do=we(1,1)),Do}function ho(s){const e=s.canvas;e.width=1,e.height=1,s.clearRect(0,0,1,1)}function Hg(s){let e=s.offsetWidth;const t=getComputedStyle(s);return e+=parseInt(t.marginLeft,10)+parseInt(t.marginRight,10),e}function qg(s){let e=s.offsetHeight;const t=getComputedStyle(s);return e+=parseInt(t.marginTop,10)+parseInt(t.marginBottom,10),e}function kh(s,e){const t=e.parentNode;t&&t.replaceChild(s,e)}function _u(s){for(;s.lastChild;)s.lastChild.remove()}function Jg(s,e){const t=s.childNodes;for(let n=0;;++n){const i=t[n],r=e[n];if(!i&&!r)break;if(i!==r){if(!i){s.appendChild(r);continue}if(!r){s.removeChild(i),--n;continue}s.insertBefore(r,i)}}}function mu(){return new Proxy({childNodes:[],appendChild:function(e){return this.childNodes.push(e),e},remove:function(){},removeChild:function(e){const t=this.childNodes.indexOf(e);if(t===-1)throw new Error("Node to remove was not found");return this.childNodes.splice(t,1),e},insertBefore:function(e,t){const n=this.childNodes.indexOf(t);if(n===-1)throw new Error("Reference node not found");return this.childNodes.splice(n,0,e),e},style:{}},{get(e,t,n){return t==="firstElementChild"?e.childNodes.length>0?e.childNodes[0]:null:Reflect.get(e,t,n)}})}function En(s){return typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas}class co extends Rt{constructor(e){super();const t=e.element;t&&!e.target&&!t.style.pointerEvents&&(t.style.pointerEvents="auto"),this.element=t||null,this.target_=null,this.map_=null,this.listenerKeys=[],e.render&&(this.render=e.render),e.target&&this.setTarget(e.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(e){this.map_&&this.element?.remove();for(let t=0,n=this.listenerKeys.length;t<n;++t)ue(this.listenerKeys[t]);if(this.listenerKeys.length=0,this.map_=e,e){const t=this.target_??e.getOverlayContainerStopEvent();this.element&&t.appendChild(this.element),this.render!==Ts&&this.listenerKeys.push(J(e,Kt.POSTRENDER,this.render,this)),e.render()}}render(e){}setTarget(e){this.target_=typeof e=="string"?document.getElementById(e):e}}class Qg extends co{constructor(e){e=e||{},super({element:document.createElement("div"),render:e.render,target:e.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=e.collapsed!==void 0?e.collapsed:!0,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=e.collapsible!==void 0,this.collapsible_=e.collapsible!==void 0?e.collapsible:!0,this.collapsible_||(this.collapsed_=!1),this.attributions_=e.attributions;const t=e.className!==void 0?e.className:"ol-attribution",n=e.tipLabel!==void 0?e.tipLabel:"Attributions",i=e.expandClassName!==void 0?e.expandClassName:t+"-expand",r=e.collapseLabel!==void 0?e.collapseLabel:"›",o=e.collapseClassName!==void 0?e.collapseClassName:t+"-collapse";typeof r=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=r,this.collapseLabel_.className=o):this.collapseLabel_=r;const a=e.label!==void 0?e.label:"i";typeof a=="string"?(this.label_=document.createElement("span"),this.label_.textContent=a,this.label_.className=i):this.label_=a;const l=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=n,this.toggleButton_.appendChild(l),this.toggleButton_.addEventListener(V.CLICK,this.handleClick_.bind(this),!1);const h=t+" "+Bs+" "+Sl+(this.collapsed_&&this.collapsible_?" "+Nh:"")+(this.collapsible_?"":" ol-uncollapsible"),c=this.element;c.className=h,c.appendChild(this.toggleButton_),c.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(e){const t=this.getMap().getAllLayers(),n=new Set(t.flatMap(i=>i.getAttributions(e)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(i=>n.add(i)):n.add(this.attributions_)),!this.overrideCollapsible_){const i=!t.some(r=>r.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(i)}return Array.from(n)}async updateElement_(e){if(!e){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const t=await Promise.all(this.collectSourceAttributions_(e).map(i=>Oc(()=>i))),n=t.length>0;if(this.renderedVisible_!=n&&(this.element.style.display=n?"":"none",this.renderedVisible_=n),!Bt(t,this.renderedAttributions_)){_u(this.ulElement_);for(let i=0,r=t.length;i<r;++i){const o=document.createElement("li");o.innerHTML=t[i],this.ulElement_.appendChild(o)}this.renderedAttributions_=t}}handleClick_(e){e.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(Nh),this.collapsed_?kh(this.collapseLabel_,this.label_):kh(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(e){this.collapsible_!==e&&(this.collapsible_=e,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(e){this.userCollapsed_=e,!(!this.collapsible_||this.collapsed_===e)&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(e){this.updateElement_(e.frameState)}}class e_ extends co{constructor(e){e=e||{},super({element:document.createElement("div"),render:e.render,target:e.target});const t=e.className!==void 0?e.className:"ol-rotate",n=e.label!==void 0?e.label:"⇧",i=e.compassClassName!==void 0?e.compassClassName:"ol-compass";this.label_=null,typeof n=="string"?(this.label_=document.createElement("span"),this.label_.className=i,this.label_.textContent=n):(this.label_=n,this.label_.classList.add(i));const r=e.tipLabel?e.tipLabel:"Reset rotation",o=document.createElement("button");o.className=t+"-reset",o.setAttribute("type","button"),o.title=r,o.appendChild(this.label_),o.addEventListener(V.CLICK,this.handleClick_.bind(this),!1);const a=t+" "+Bs+" "+Sl,l=this.element;l.className=a,l.appendChild(o),this.callResetNorth_=e.resetNorth?e.resetNorth:void 0,this.duration_=e.duration!==void 0?e.duration:250,this.autoHide_=e.autoHide!==void 0?e.autoHide:!0,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(nr)}handleClick_(e){e.preventDefault(),this.callResetNorth_!==void 0?this.callResetNorth_():this.resetNorth_()}resetNorth_(){const t=this.getMap().getView();if(!t)return;const n=t.getRotation();n!==void 0&&(this.duration_>0&&n%(2*Math.PI)!==0?t.animate({rotation:0,duration:this.duration_,easing:Wi}):t.setRotation(0))}render(e){const t=e.frameState;if(!t)return;const n=t.viewState.rotation;if(n!=this.rotation_){const i="rotate("+n+"rad)";if(this.autoHide_){const r=this.element.classList.contains(nr);!r&&n===0?this.element.classList.add(nr):r&&n!==0&&this.element.classList.remove(nr)}this.label_.style.transform=i}this.rotation_=n}}class t_ extends co{constructor(e){e=e||{},super({element:document.createElement("div"),target:e.target});const t=e.className!==void 0?e.className:"ol-zoom",n=e.delta!==void 0?e.delta:1,i=e.zoomInClassName!==void 0?e.zoomInClassName:t+"-in",r=e.zoomOutClassName!==void 0?e.zoomOutClassName:t+"-out",o=e.zoomInLabel!==void 0?e.zoomInLabel:"+",a=e.zoomOutLabel!==void 0?e.zoomOutLabel:"–",l=e.zoomInTipLabel!==void 0?e.zoomInTipLabel:"Zoom in",h=e.zoomOutTipLabel!==void 0?e.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=i,c.setAttribute("type","button"),c.title=l,c.appendChild(typeof o=="string"?document.createTextNode(o):o),c.addEventListener(V.CLICK,this.handleClick_.bind(this,n),!1);const u=document.createElement("button");u.className=r,u.setAttribute("type","button"),u.title=h,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(V.CLICK,this.handleClick_.bind(this,-n),!1);const d=t+" "+Bs+" "+Sl,f=this.element;f.className=d,f.appendChild(c),f.appendChild(u),this.duration_=e.duration!==void 0?e.duration:250}handleClick_(e,t){t.preventDefault(),this.zoomByDelta_(e)}zoomByDelta_(e){const n=this.getMap().getView();if(!n)return;const i=n.getZoom();if(i!==void 0){const r=n.getConstrainedZoom(i+e);this.duration_>0?(n.getAnimating()&&n.cancelAnimations(),n.animate({zoom:r,duration:this.duration_,easing:Wi})):n.setZoom(r)}}}function n_(s){s=s||{};const e=new Ze;return(s.zoom!==void 0?s.zoom:!0)&&e.push(new t_(s.zoomOptions)),(s.rotate!==void 0?s.rotate:!0)&&e.push(new e_(s.rotateOptions)),(s.attribution!==void 0?s.attribution:!0)&&e.push(new Qg(s.attributionOptions)),e}class i_{constructor(e,t,n){this.decay_=e,this.minVelocity_=t,this.delay_=n,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(e,t){this.points_.push(e,t,Date.now())}end(){if(this.points_.length<6)return!1;const e=Date.now()-this.delay_,t=this.points_.length-3;if(this.points_[t+2]<e)return!1;let n=t-3;for(;n>0&&this.points_[n+2]>e;)n-=3;const i=this.points_[t+2]-this.points_[n+2];if(i<1e3/60)return!1;const r=this.points_[t]-this.points_[n],o=this.points_[t+1]-this.points_[n+1];return this.angle_=Math.atan2(o,r),this.initialVelocity_=Math.sqrt(r*r+o*o)/i,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}}const Fa={ACTIVE:"active"};class Vi extends Rt{constructor(e){super(),this.on,this.once,this.un,e&&e.handleEvent&&(this.handleEvent=e.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(Fa.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(Fa.ACTIVE,e)}setMap(e){this.map_=e}}function s_(s,e,t){const n=s.getCenterInternal();if(n){const i=[n[0]+e[0],n[1]+e[1]];s.animateInternal({duration:t!==void 0?t:250,easing:Gf,center:s.getConstrainedCenter(i)})}}function vl(s,e,t,n){const i=s.getZoom();if(i===void 0)return;const r=s.getConstrainedZoom(i+e),o=s.getResolutionForZoom(r);s.getAnimating()&&s.cancelAnimations(),s.animate({resolution:o,anchor:t,duration:n!==void 0?n:250,easing:Wi})}class r_ extends Vi{constructor(e){super(),e=e||{},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:250}handleEvent(e){let t=!1;if(e.type==ee.DBLCLICK){const n=e.originalEvent,i=e.map,r=e.coordinate,o=n.shiftKey?-this.delta_:this.delta_,a=i.getView();vl(a,o,r,this.duration_),n.preventDefault(),t=!0}return!t}}function Ma(s){const e=arguments;return function(t){let n=!0;for(let i=0,r=e.length;i<r&&(n=n&&e[i](t),!!n);++i);return n}}const o_=function(s){const e=s.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey},a_=function(s){const e=s.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},l_=function(s){const e=s.map.getTargetElement(),t=e.getRootNode(),n=s.map.getOwnerDocument().activeElement;return t instanceof ShadowRoot?t.host.contains(n):e.contains(n)},pu=function(s){const e=s.map.getTargetElement(),t=e.getRootNode();return(t instanceof ShadowRoot?t.host:e).hasAttribute("tabindex")?l_(s):!0},Li=Pn,L0=function(s){return s.type==ee.CLICK},yu=function(s){const e=s.originalEvent;return"pointerId"in e&&e.button==0&&!(_f&&Nc&&e.ctrlKey)},Or=Xi,xu=function(s){return s.type==ee.SINGLECLICK},wl=function(s){const e=s.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey},h_=function(s){const e=s.originalEvent;return Nc?e.metaKey:e.ctrlKey},Nr=function(s){const e=s.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},Eu=function(s){const e=s.originalEvent,t=e.target.tagName;return t!=="INPUT"&&t!=="SELECT"&&t!=="TEXTAREA"&&!e.target.isContentEditable},Oo=function(s){const e=s.originalEvent;return"pointerId"in e&&e.pointerType=="mouse"},Tu=function(s){const e=s.originalEvent;return"pointerId"in e&&e.isPrimary&&e.button===0};class si extends Vi{constructor(e){e=e||{},super(e),e.handleDownEvent&&(this.handleDownEvent=e.handleDownEvent),e.handleDragEvent&&(this.handleDragEvent=e.handleDragEvent),e.handleMoveEvent&&(this.handleMoveEvent=e.handleMoveEvent),e.handleUpEvent&&(this.handleUpEvent=e.handleUpEvent),e.stopDown&&(this.stopDown=e.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(e){return!1}handleDragEvent(e){}handleEvent(e){if(!e.originalEvent)return!0;let t=!1;if(this.updateTrackedPointers_(e),this.handlingDownUpSequence){if(e.type==ee.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==ee.POINTERUP){const n=this.handleUpEvent(e);this.handlingDownUpSequence=n&&this.targetPointers.length>0}}else if(e.type==ee.POINTERDOWN){const n=this.handleDownEvent(e);this.handlingDownUpSequence=n,t=this.stopDown(n)}else e.type==ee.POINTERMOVE&&this.handleMoveEvent(e);return!t}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}}function Pl(s){const e=s.length;let t=0,n=0;for(let i=0;i<e;i++)t+=s[i].clientX,n+=s[i].clientY;return{clientX:t/e,clientY:n/e}}class c_ extends si{constructor(e){super({stopDown:Xi}),e=e||{},this.kinetic_=e.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;const t=e.condition?e.condition:Ma(wl,Tu);this.condition_=e.onFocusOnly?Ma(pu,t):t,this.noKinetic_=!1}handleDragEvent(e){const t=e.map;this.panning_||(this.panning_=!0,t.getView().beginInteraction());const n=this.targetPointers,i=t.getEventPixel(Pl(n));if(n.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(i[0],i[1]),this.lastCentroid){const r=[this.lastCentroid[0]-i[0],i[1]-this.lastCentroid[1]],a=e.map.getView();bf(r,a.getResolution()),nl(r,a.getRotation()),a.adjustCenterInternal(r)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=i,this.lastPointersCount_=n.length,e.originalEvent.preventDefault()}handleUpEvent(e){const t=e.map,n=t.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){const i=this.kinetic_.getDistance(),r=this.kinetic_.getAngle(),o=n.getCenterInternal(),a=t.getPixelFromCoordinateInternal(o),l=t.getCoordinateFromPixelInternal([a[0]-i*Math.cos(r),a[1]-i*Math.sin(r)]);n.animateInternal({center:n.getConstrainedCenter(l),duration:500,easing:Wi})}return this.panning_&&(this.panning_=!1,n.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(e){if(this.targetPointers.length>0&&this.condition_(e)){const n=e.map.getView();return this.lastCentroid=null,n.getAnimating()&&n.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}}class u_ extends si{constructor(e){e=e||{},super({stopDown:Xi}),this.condition_=e.condition?e.condition:a_,this.lastAngle_=void 0,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){if(!Oo(e))return;const t=e.map,n=t.getView();if(n.getConstraints().rotation===Cl)return;const i=t.getSize(),r=e.pixel,o=Math.atan2(i[1]/2-r[1],r[0]-i[0]/2);if(this.lastAngle_!==void 0){const a=o-this.lastAngle_;n.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(e){return Oo(e)?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){return Oo(e)&&yu(e)&&this.condition_(e)?(e.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class d_ extends bs{constructor(e){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+e,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const e=this.startPixel_,t=this.endPixel_,n="px",i=this.element_.style;i.left=Math.min(e[0],t[0])+n,i.top=Math.min(e[1],t[1])+n,i.width=Math.abs(t[0]-e[0])+n,i.height=Math.abs(t[1]-e[1])+n}setMap(e){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const t=this.element_.style;t.left="inherit",t.top="inherit",t.width="inherit",t.height="inherit"}this.map_=e,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(e,t){this.startPixel_=e,this.endPixel_=t,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;const e=this.startPixel_,t=this.endPixel_,i=[e,[e[0],t[1]],t,[t[0],e[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);i[4]=i[0].slice(),this.geometry_?this.geometry_.setCoordinates([i]):this.geometry_=new qe([i])}getGeometry(){return this.geometry_}}const di={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class is extends ut{constructor(e,t,n){super(e),this.coordinate=t,this.mapBrowserEvent=n}}class f_ extends si{constructor(e){super(),this.on,this.once,this.un,e=e??{},this.box_=new d_(e.className||"ol-dragbox"),this.minArea_=e.minArea??64,e.onBoxEnd&&(this.onBoxEnd=e.onBoxEnd),this.startPixel_=null,this.condition_=e.condition??yu,this.boxEndCondition_=e.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(e,t,n){const i=n[0]-t[0],r=n[1]-t[1];return i*i+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(e){this.startPixel_&&(this.box_.setPixels(this.startPixel_,e.pixel),this.dispatchEvent(new is(di.BOXDRAG,e.coordinate,e)))}handleUpEvent(e){if(!this.startPixel_)return!1;const t=this.boxEndCondition_(e,this.startPixel_,e.pixel);return t&&this.onBoxEnd(e),this.dispatchEvent(new is(t?di.BOXEND:di.BOXCANCEL,e.coordinate,e)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(e){return this.condition_(e)?(this.startPixel_=e.pixel,this.box_.setMap(e.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new is(di.BOXSTART,e.coordinate,e)),!0):!1}onBoxEnd(e){}setActive(e){e||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new is(di.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(e)}setMap(e){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new is(di.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(e)}}class g_ extends f_{constructor(e){e=e||{};const t=e.condition?e.condition:Nr;super({condition:t,className:e.className||"ol-dragzoom",minArea:e.minArea}),this.duration_=e.duration!==void 0?e.duration:200,this.out_=e.out!==void 0?e.out:!1}onBoxEnd(e){const n=this.getMap().getView();let i=this.getGeometry();if(this.out_){const r=n.rotatedExtentForGeometry(i),o=n.getResolutionForExtentInternal(r),a=n.getResolution()/o;i=i.clone(),i.scale(a*a)}n.fitInternal(i,{duration:this.duration_,easing:Wi})}}const Gn={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class __ extends Vi{constructor(e){super(),e=e||{},this.defaultCondition_=function(t){return wl(t)&&Eu(t)},this.condition_=e.condition!==void 0?e.condition:this.defaultCondition_,this.duration_=e.duration!==void 0?e.duration:100,this.pixelDelta_=e.pixelDelta!==void 0?e.pixelDelta:128}handleEvent(e){let t=!1;if(e.type==V.KEYDOWN){const n=e.originalEvent,i=n.key;if(this.condition_(e)&&(i==Gn.DOWN||i==Gn.LEFT||i==Gn.RIGHT||i==Gn.UP)){const o=e.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,h=0;i==Gn.DOWN?h=-a:i==Gn.LEFT?l=-a:i==Gn.RIGHT?l=a:h=a;const c=[l,h];nl(c,o.getRotation()),s_(o,c,this.duration_),n.preventDefault(),t=!0}}return!t}}class m_ extends Vi{constructor(e){super(),e=e||{},this.condition_=e.condition?e.condition:function(t){return!h_(t)&&Eu(t)},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:100}handleEvent(e){let t=!1;if(e.type==V.KEYDOWN||e.type==V.KEYPRESS){const n=e.originalEvent,i=n.key;if(this.condition_(e)&&(i==="+"||i==="-")){const r=e.map,o=i==="+"?this.delta_:-this.delta_,a=r.getView();vl(a,o,void 0,this.duration_),n.preventDefault(),t=!0}}return!t}}const p_=40,y_=300;class x_ extends Vi{constructor(e){e=e||{},super(e),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=e.maxDelta!==void 0?e.maxDelta:1,this.duration_=e.duration!==void 0?e.duration:250,this.timeout_=e.timeout!==void 0?e.timeout:80,this.useAnchor_=e.useAnchor!==void 0?e.useAnchor:!0,this.constrainResolution_=e.constrainResolution!==void 0?e.constrainResolution:!1;const t=e.condition?e.condition:Li;this.condition_=e.onFocusOnly?Ma(pu,t):t,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300}endInteraction_(){this.trackpadTimeoutId_=void 0;const e=this.getMap();if(!e)return;e.getView().endInteraction(void 0,this.lastDelta_?this.lastDelta_>0?1:-1:0,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(e){if(!this.condition_(e)||e.type!==V.WHEEL)return!0;const n=e.map,i=e.originalEvent;i.preventDefault(),this.useAnchor_&&(this.lastAnchor_=e.pixel);let r=i.deltaY;switch(i.deltaMode){case WheelEvent.DOM_DELTA_LINE:r*=p_;break;case WheelEvent.DOM_DELTA_PAGE:r*=y_;break}if(r===0)return!1;this.lastDelta_=r;const o=Date.now();this.startTime_===void 0&&(this.startTime_=o),(!this.mode_||o-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(r)<4?"trackpad":"wheel");const a=n.getView();if(this.mode_==="trackpad"&&!(a.getConstrainResolution()||this.constrainResolution_))return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(a.getAnimating()&&a.cancelAnimations(),a.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),a.adjustZoom(-r/this.deltaPerZoom_,this.lastAnchor_?n.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=o,!1;this.totalDelta_+=r;const l=Math.max(this.timeout_-(o-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,n),l),!1}handleWheelZoom_(e){const t=e.getView();t.getAnimating()&&t.cancelAnimations();let n=-ge(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(t.getConstrainResolution()||this.constrainResolution_)&&(n=n?n>0?1:-1:0),vl(t,n,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(e){this.useAnchor_=e,e||(this.lastAnchor_=null)}}class E_ extends si{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=Xi),super(t),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=e.threshold!==void 0?e.threshold:.3,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){let t=0;const n=this.targetPointers[0],i=this.targetPointers[1],r=Math.atan2(i.clientY-n.clientY,i.clientX-n.clientX);if(this.lastAngle_!==void 0){const l=r-this.lastAngle_;this.rotationDelta_+=l,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),t=l}this.lastAngle_=r;const o=e.map,a=o.getView();a.getConstraints().rotation!==Cl&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(Pl(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(t,this.anchor_)))}handleUpEvent(e){return this.targetPointers.length<2?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){if(this.targetPointers.length>=2){const t=e.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}}class T_ extends si{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=Xi),super(t),this.anchor_=null,this.duration_=e.duration!==void 0?e.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(e){let t=1;const n=this.targetPointers[0],i=this.targetPointers[1],r=n.clientX-i.clientX,o=n.clientY-i.clientY,a=Math.sqrt(r*r+o*o);this.lastDistance_!==void 0&&(t=this.lastDistance_/a),this.lastDistance_=a;const l=e.map,h=l.getView();t!=1&&(this.lastScaleDelta_=t),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(Pl(this.targetPointers))),l.render(),h.adjustResolutionInternal(t,this.anchor_)}handleUpEvent(e){if(this.targetPointers.length<2){const n=e.map.getView(),i=this.lastScaleDelta_>1?1:-1;return n.endInteraction(this.duration_,i),!1}return!0}handleDownEvent(e){if(this.targetPointers.length>=2){const t=e.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}}function C_(s){s=s||{};const e=new Ze,t=new i_(-.005,.05,100);return(s.altShiftDragRotate!==void 0?s.altShiftDragRotate:!0)&&e.push(new u_),(s.doubleClickZoom!==void 0?s.doubleClickZoom:!0)&&e.push(new r_({delta:s.zoomDelta,duration:s.zoomDuration})),(s.dragPan!==void 0?s.dragPan:!0)&&e.push(new c_({onFocusOnly:s.onFocusOnly,kinetic:t})),(s.pinchRotate!==void 0?s.pinchRotate:!0)&&e.push(new E_),(s.pinchZoom!==void 0?s.pinchZoom:!0)&&e.push(new T_({duration:s.zoomDuration})),(s.keyboard!==void 0?s.keyboard:!0)&&(e.push(new __),e.push(new m_({delta:s.zoomDelta,duration:s.zoomDuration}))),(s.mouseWheelZoom!==void 0?s.mouseWheelZoom:!0)&&e.push(new x_({onFocusOnly:s.onFocusOnly,duration:s.zoomDuration})),(s.shiftDragZoom!==void 0?s.shiftDragZoom:!0)&&e.push(new g_({duration:s.zoomDuration})),e}const ae={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};class Cu extends Rt{constructor(e){super(),this.on,this.once,this.un,this.background_=e.background;const t=Object.assign({},e);typeof e.properties=="object"&&(delete t.properties,Object.assign(t,e.properties)),t[ae.OPACITY]=e.opacity!==void 0?e.opacity:1,te(typeof t[ae.OPACITY]=="number","Layer opacity must be a number"),t[ae.VISIBLE]=e.visible!==void 0?e.visible:!0,t[ae.Z_INDEX]=e.zIndex,t[ae.MAX_RESOLUTION]=e.maxResolution!==void 0?e.maxResolution:1/0,t[ae.MIN_RESOLUTION]=e.minResolution!==void 0?e.minResolution:0,t[ae.MIN_ZOOM]=e.minZoom!==void 0?e.minZoom:-1/0,t[ae.MAX_ZOOM]=e.maxZoom!==void 0?e.maxZoom:1/0,this.className_=t.className!==void 0?t.className:"ol-layer",delete t.className,this.setProperties(t),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(e){const t=this.state_||{layer:this,managed:e===void 0?!0:e},n=this.getZIndex();return t.opacity=ge(Math.round(this.getOpacity()*100)/100,0,1),t.visible=this.getVisible(),t.extent=this.getExtent(),t.zIndex=n===void 0&&!t.managed?1/0:n,t.maxResolution=this.getMaxResolution(),t.minResolution=Math.max(this.getMinResolution(),0),t.minZoom=this.getMinZoom(),t.maxZoom=this.getMaxZoom(),this.state_=t,t}getLayersArray(e){return $()}getLayerStatesArray(e){return $()}getExtent(){return this.get(ae.EXTENT)}getMaxResolution(){return this.get(ae.MAX_RESOLUTION)}getMinResolution(){return this.get(ae.MIN_RESOLUTION)}getMinZoom(){return this.get(ae.MIN_ZOOM)}getMaxZoom(){return this.get(ae.MAX_ZOOM)}getOpacity(){return this.get(ae.OPACITY)}getSourceState(){return $()}getVisible(){return this.get(ae.VISIBLE)}getZIndex(){return this.get(ae.Z_INDEX)}setBackground(e){this.background_=e,this.changed()}setExtent(e){this.set(ae.EXTENT,e)}setMaxResolution(e){this.set(ae.MAX_RESOLUTION,e)}setMinResolution(e){this.set(ae.MIN_RESOLUTION,e)}setMaxZoom(e){this.set(ae.MAX_ZOOM,e)}setMinZoom(e){this.set(ae.MIN_ZOOM,e)}setOpacity(e){te(typeof e=="number","Layer opacity must be a number"),this.set(ae.OPACITY,e)}setVisible(e){this.set(ae.VISIBLE,e)}setZIndex(e){this.set(ae.Z_INDEX,e)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}const un={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"};class mn extends ut{constructor(e,t){super(e),this.layer=t}}const No={LAYERS:"layers"};class Zi extends Cu{constructor(e){e=e||{};const t=Object.assign({},e);delete t.layers;let n=e.layers;super(t),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(No.LAYERS,this.handleLayersChanged_),n?Array.isArray(n)?n=new Ze(n.slice(),{unique:!0}):te(typeof n.getArray=="function","Expected `layers` to be an array or a `Collection`"):n=new Ze(void 0,{unique:!0}),this.setLayers(n)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(ue),this.layersListenerKeys_.length=0;const e=this.getLayers();this.layersListenerKeys_.push(J(e,Se.ADD,this.handleLayersAdd_,this),J(e,Se.REMOVE,this.handleLayersRemove_,this));for(const n in this.listenerKeys_)this.listenerKeys_[n].forEach(ue);ei(this.listenerKeys_);const t=e.getArray();for(let n=0,i=t.length;n<i;n++){const r=t[n];this.registerLayerListeners_(r),this.dispatchEvent(new mn(un.ADDLAYER,r))}this.changed()}registerLayerListeners_(e){const t=[J(e,Ni.PROPERTYCHANGE,this.handleLayerChange_,this),J(e,V.CHANGE,this.handleLayerChange_,this)];e instanceof Zi&&t.push(J(e,un.ADDLAYER,this.handleLayerGroupAdd_,this),J(e,un.REMOVELAYER,this.handleLayerGroupRemove_,this)),this.listenerKeys_[D(e)]=t}handleLayerGroupAdd_(e){this.dispatchEvent(new mn(un.ADDLAYER,e.layer))}handleLayerGroupRemove_(e){this.dispatchEvent(new mn(un.REMOVELAYER,e.layer))}handleLayersAdd_(e){const t=e.element;this.registerLayerListeners_(t),this.dispatchEvent(new mn(un.ADDLAYER,t)),this.changed()}handleLayersRemove_(e){const t=e.element,n=D(t);this.listenerKeys_[n].forEach(ue),delete this.listenerKeys_[n],this.dispatchEvent(new mn(un.REMOVELAYER,t)),this.changed()}getLayers(){return this.get(No.LAYERS)}setLayers(e){const t=this.getLayers();if(t){const n=t.getArray();for(let i=0,r=n.length;i<r;++i)this.dispatchEvent(new mn(un.REMOVELAYER,n[i]))}this.set(No.LAYERS,e)}getLayersArray(e){return e=e!==void 0?e:[],this.getLayers().forEach(function(t){t.getLayersArray(e)}),e}getLayerStatesArray(e){const t=e!==void 0?e:[],n=t.length;this.getLayers().forEach(function(o){o.getLayerStatesArray(t)});const i=this.getLayerState();let r=i.zIndex;!e&&i.zIndex===void 0&&(r=0);for(let o=n,a=t.length;o<a;o++){const l=t[o];l.opacity*=i.opacity,l.visible=l.visible&&i.visible,l.maxResolution=Math.min(l.maxResolution,i.maxResolution),l.minResolution=Math.max(l.minResolution,i.minResolution),l.minZoom=Math.max(l.minZoom,i.minZoom),l.maxZoom=Math.min(l.maxZoom,i.maxZoom),i.extent!==void 0&&(l.extent!==void 0?l.extent=tn(l.extent,i.extent):l.extent=i.extent),l.zIndex===void 0&&(l.zIndex=r)}return t}getSourceState(){return"ready"}}const Me={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};class zs extends Cu{constructor(e){const t=Object.assign({},e);delete t.source,super(t),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,e.render&&(this.render=e.render),e.map&&this.setMap(e.map),this.addChangeListener(ae.SOURCE,this.handleSourcePropertyChange_);const n=e.source?e.source:null;this.setSource(n)}getLayersArray(e){return e=e||[],e.push(this),e}getLayerStatesArray(e){return e=e||[],e.push(this.getLayerState()),e}getSource(){return this.get(ae.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){const e=this.getSource();return e?e.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(ue(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const e=this.getSource();e&&(this.sourceChangeKey_=J(e,V.CHANGE,this.handleSourceChange_,this),e.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(e){return this.renderer_?this.renderer_.getFeatures(e):Promise.resolve([])}getData(e){return!this.renderer_||!this.rendered?null:this.renderer_.getData(e)}isVisible(e){let t;const n=this.getMapInternal();!e&&n&&(e=n.getView()),e instanceof Jt?t={viewState:e.getState(),extent:e.calculateExtent()}:t=e,!t.layerStatesArray&&n&&(t.layerStatesArray=n.getLayerGroup().getLayerStatesArray());let i;if(t.layerStatesArray){if(i=t.layerStatesArray.find(o=>o.layer===this),!i)return!1}else i=this.getLayerState();const r=this.getExtent();return Il(i,t.viewState)&&(!r||Te(r,t.extent))}getAttributions(e){if(!this.isVisible(e))return[];const t=this.getSource()?.getAttributions();if(!t)return[];const n=e instanceof Jt?e.getViewStateAndExtent():e;let i=t(n);return Array.isArray(i)||(i=[i]),i}render(e,t){const n=this.getRenderer();return n.prepareFrame(e)?(this.rendered=!0,n.renderFrame(e,t)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(e,t){}renderDeferred(e){const t=this.getRenderer();t&&t.renderDeferred(e)}setMapInternal(e){e||this.unrender(),this.set(ae.MAP,e)}getMapInternal(){return this.get(ae.MAP)}setMap(e){this.mapPrecomposeKey_&&(ue(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),e||this.changed(),this.mapRenderKey_&&(ue(this.mapRenderKey_),this.mapRenderKey_=null),e&&(this.mapPrecomposeKey_=J(e,Me.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=J(this,V.CHANGE,e.render,e),this.changed())}handlePrecompose_(e){const t=e.frameState.layerStatesArray,n=this.getLayerState(!1);te(!t.some(i=>i.layer===n.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),t.push(n)}setSource(e){this.set(ae.SOURCE,e)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}}function Il(s,e){if(!s.visible)return!1;const t=e.resolution;if(t<s.minResolution||t>=s.maxResolution)return!1;const n=e.zoom;return n>s.minZoom&&n<=s.maxZoom}function Ru(s,e,t=0,n=s.length-1,i=R_){for(;n>t;){if(n-t>600){const l=n-t+1,h=e-t+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(t,Math.floor(e-h*u/l+d)),g=Math.min(n,Math.floor(e+(l-h)*u/l+d));Ru(s,e,f,g,i)}const r=s[e];let o=t,a=n;for(ss(s,t,e),i(s[n],r)>0&&ss(s,t,n);o<a;){for(ss(s,o,a),o++,a--;i(s[o],r)<0;)o++;for(;i(s[a],r)>0;)a--}i(s[t],r)===0?ss(s,t,a):(a++,ss(s,a,n)),a<=e&&(t=a+1),e<=a&&(n=a-1)}}function ss(s,e,t){const n=s[e];s[e]=s[t],s[t]=n}function R_(s,e){return s<e?-1:s>e?1:0}let Al=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const n=[];if(!sr(e,t))return n;const i=this.toBBox,r=[];for(;t;){for(let o=0;o<t.children.length;o++){const a=t.children[o],l=t.leaf?i(a):a;sr(e,l)&&(t.leaf?n.push(a):ko(e,l)?this._all(a,n):r.push(a))}t=r.pop()}return n}collides(e){let t=this.data;if(!sr(e,t))return!1;const n=[];for(;t;){for(let i=0;i<t.children.length;i++){const r=t.children[i],o=t.leaf?this.toBBox(r):r;if(sr(e,o)){if(t.leaf||ko(e,o))return!0;n.push(r)}}t=n.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let n=0;n<e.length;n++)this.insert(e[n]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const n=this.data;this.data=t,t=n}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=Ci([]),this}remove(e,t){if(!e)return this;let n=this.data;const i=this.toBBox(e),r=[],o=[];let a,l,h;for(;n||r.length;){if(n||(n=r.pop(),l=r[r.length-1],a=o.pop(),h=!0),n.leaf){const c=S_(e,n.children,t);if(c!==-1)return n.children.splice(c,1),r.push(n),this._condense(r),this}!h&&!n.leaf&&ko(n,i)?(r.push(n),o.push(a),a=0,l=n,n=n.children[0]):l?(a++,n=l.children[a],h=!1):n=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const n=[];for(;e;)e.leaf?t.push(...e.children):n.push(...e.children),e=n.pop();return t}_build(e,t,n,i){const r=n-t+1;let o=this._maxEntries,a;if(r<=o)return a=Ci(e.slice(t,n+1)),fi(a,this.toBBox),a;i||(i=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,i-1))),a=Ci([]),a.leaf=!1,a.height=i;const l=Math.ceil(r/o),h=l*Math.ceil(Math.sqrt(o));Uh(e,t,n,h,this.compareMinX);for(let c=t;c<=n;c+=h){const u=Math.min(c+h-1,n);Uh(e,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(e,d,f,i-1))}}return fi(a,this.toBBox),a}_chooseSubtree(e,t,n,i){for(;i.push(t),!(t.leaf||i.length-1===n);){let r=1/0,o=1/0,a;for(let l=0;l<t.children.length;l++){const h=t.children[l],c=Go(h),u=P_(e,h)-c;u<o?(o=u,r=c<r?c:r,a=h):u===o&&c<r&&(r=c,a=h)}t=a||t.children[0]}return t}_insert(e,t,n){const i=n?e:this.toBBox(e),r=[],o=this._chooseSubtree(i,this.data,t,r);for(o.children.push(e),cs(o,i);t>=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(i,r,t)}_split(e,t){const n=e[t],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);const o=this._chooseSplitIndex(n,r,i),a=Ci(n.children.splice(o,n.children.length-o));a.height=n.height,a.leaf=n.leaf,fi(n,this.toBBox),fi(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(n,a)}_splitRoot(e,t){this.data=Ci([e,t]),this.data.height=e.height+1,this.data.leaf=!1,fi(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let i,r=1/0,o=1/0;for(let a=t;a<=n-t;a++){const l=hs(e,0,a,this.toBBox),h=hs(e,a,n,this.toBBox),c=I_(l,h),u=Go(l)+Go(h);c<r?(r=c,i=a,o=u<o?u:o):c===r&&u<o&&(o=u,i=a)}return i||n-t}_chooseSplitAxis(e,t,n){const i=e.leaf?this.compareMinX:v_,r=e.leaf?this.compareMinY:w_,o=this._allDistMargin(e,t,n,i),a=this._allDistMargin(e,t,n,r);o<a&&e.children.sort(i)}_allDistMargin(e,t,n,i){e.children.sort(i);const r=this.toBBox,o=hs(e,0,t,r),a=hs(e,n-t,n,r);let l=ir(o)+ir(a);for(let h=t;h<n-t;h++){const c=e.children[h];cs(o,e.leaf?r(c):c),l+=ir(o)}for(let h=n-t-1;h>=t;h--){const c=e.children[h];cs(a,e.leaf?r(c):c),l+=ir(a)}return l}_adjustParentBBoxes(e,t,n){for(let i=n;i>=0;i--)cs(t[i],e)}_condense(e){for(let t=e.length-1,n;t>=0;t--)e[t].children.length===0?t>0?(n=e[t-1].children,n.splice(n.indexOf(e[t]),1)):this.clear():fi(e[t],this.toBBox)}};function S_(s,e,t){if(!t)return e.indexOf(s);for(let n=0;n<e.length;n++)if(t(s,e[n]))return n;return-1}function fi(s,e){hs(s,0,s.children.length,e,s)}function hs(s,e,t,n,i){i||(i=Ci(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let r=e;r<t;r++){const o=s.children[r];cs(i,s.leaf?n(o):o)}return i}function cs(s,e){return s.minX=Math.min(s.minX,e.minX),s.minY=Math.min(s.minY,e.minY),s.maxX=Math.max(s.maxX,e.maxX),s.maxY=Math.max(s.maxY,e.maxY),s}function v_(s,e){return s.minX-e.minX}function w_(s,e){return s.minY-e.minY}function Go(s){return(s.maxX-s.minX)*(s.maxY-s.minY)}function ir(s){return s.maxX-s.minX+(s.maxY-s.minY)}function P_(s,e){return(Math.max(e.maxX,s.maxX)-Math.min(e.minX,s.minX))*(Math.max(e.maxY,s.maxY)-Math.min(e.minY,s.minY))}function I_(s,e){const t=Math.max(s.minX,e.minX),n=Math.max(s.minY,e.minY),i=Math.min(s.maxX,e.maxX),r=Math.min(s.maxY,e.maxY);return Math.max(0,i-t)*Math.max(0,r-n)}function ko(s,e){return s.minX<=e.minX&&s.minY<=e.minY&&e.maxX<=s.maxX&&e.maxY<=s.maxY}function sr(s,e){return e.minX<=s.maxX&&e.minY<=s.maxY&&e.maxX>=s.minX&&e.maxY>=s.minY}function Ci(s){return{children:s,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Uh(s,e,t,n,i){const r=[e,t];for(;r.length;){if(t=r.pop(),e=r.pop(),t-e<=n)continue;const o=e+Math.ceil((t-e)/n/2)*n;Ru(s,o,e,t,i),r.push(e,o,o,t)}}const Ll=[NaN,NaN,NaN,0];let Uo;function A_(){return Uo||(Uo=we(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),Uo}const L_=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,F_=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,M_=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,b_=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function rr(s,e){return s.endsWith("%")?Number(s.substring(0,s.length-1))/e:Number(s)}function _s(s){throw new Error('failed to parse "'+s+'" as color')}function Su(s){if(s.toLowerCase().startsWith("rgb")){const r=s.match(F_)||s.match(L_)||s.match(M_);if(r){const o=r[4],a=100/255;return[ge(rr(r[1],a)+.5|0,0,255),ge(rr(r[2],a)+.5|0,0,255),ge(rr(r[3],a)+.5|0,0,255),o!==void 0?ge(rr(o,100),0,1):1]}_s(s)}if(s.startsWith("#")){if(b_.test(s)){const r=s.substring(1),o=r.length<=4?1:2,a=[0,0,0,255];for(let l=0,h=r.length;l<h;l+=o){let c=parseInt(r.substring(l,l+o),16);o===1&&(c+=c<<4),a[l/o]=c}return a[3]=a[3]/255,a}_s(s)}const e=A_();e.fillStyle="#abcdef";let t=e.fillStyle;e.fillStyle=s,e.fillStyle===t&&(e.fillStyle="#fedcba",t=e.fillStyle,e.fillStyle=s,e.fillStyle===t&&_s(s));const n=e.fillStyle;if(n.startsWith("#")||n.startsWith("rgba"))return Su(n);e.clearRect(0,0,1,1),e.fillRect(0,0,1,1);const i=Array.from(e.getImageData(0,0,1,1).data);return i[3]=Yi(i[3]/255,3),i}function D_(s){return typeof s=="string"?s:Ml(s)}const O_=1024,rs={};let Bo=0;function N_(s){if(s.length===4)return s;const e=s.slice();return e[3]=1,e}function zo(s){return s>.0031308?Math.pow(s,1/2.4)*269.025-14.025:s*3294.6}function $o(s){return s>.2068965?Math.pow(s,3):(s-4/29)*(108/841)}function Xo(s){return s>10.314724?Math.pow((s+14.025)/269.025,2.4):s/3294.6}function Yo(s){return s>.0088564?Math.pow(s,1/3):s/(108/841)+4/29}function Bh(s){const e=Xo(s[0]),t=Xo(s[1]),n=Xo(s[2]),i=Yo(e*.222488403+t*.716873169+n*.06060791),r=500*(Yo(e*.452247074+t*.399439023+n*.148375274)-i),o=200*(i-Yo(e*.016863605+t*.117638439+n*.865350722)),a=Math.atan2(o,r)*(180/Math.PI);return[116*i-16,Math.sqrt(r*r+o*o),a<0?a+360:a,s[3]]}function G_(s){const e=(s[0]+16)/116,t=s[1],n=s[2]*Math.PI/180,i=$o(e),r=$o(e+t/500*Math.cos(n)),o=$o(e-t/200*Math.sin(n)),a=zo(r*3.021973625-i*1.617392459-o*.404875592),l=zo(r*-.943766287+i*1.916279586+o*.027607165),h=zo(r*.069407491-i*.22898585+o*1.159737864);return[ge(a+.5|0,0,255),ge(l+.5|0,0,255),ge(h+.5|0,0,255),s[3]]}function Fl(s){if(s==="none")return Ll;if(rs.hasOwnProperty(s))return rs[s];if(Bo>=O_){let t=0;for(const n in rs)(t++&3)===0&&(delete rs[n],--Bo)}const e=Su(s);e.length!==4&&_s(s);for(const t of e)isNaN(t)&&_s(s);return rs[s]=e,++Bo,e}function Ct(s){return Array.isArray(s)?s:Fl(s)}function Ml(s){let e=s[0];e!=(e|0)&&(e=e+.5|0);let t=s[1];t!=(t|0)&&(t=t+.5|0);let n=s[2];n!=(n|0)&&(n=n+.5|0);const i=s[3]===void 0?1:Math.round(s[3]*1e3)/1e3;return"rgba("+e+","+t+","+n+","+i+")"}function zh(s){return s[0]>0&&s[1]>0}function k_(s,e,t){return t===void 0&&(t=[0,0]),t[0]=s[0]*e+.5|0,t[1]=s[1]*e+.5|0,t}function Xe(s,e){return Array.isArray(s)?s:(e===void 0?e=[s,s]:(e[0]=s,e[1]=s),e)}let ri=0;const ve=1<<ri++,N=1<<ri++,Ie=1<<ri++,_e=1<<ri++,nt=1<<ri++,yt=1<<ri++,or=Math.pow(2,ri)-1,bl={[ve]:"boolean",[N]:"number",[Ie]:"string",[_e]:"color",[nt]:"number[]",[yt]:"size"},U_=Object.keys(bl).map(Number).sort(Nt);function B_(s){return s in bl}function Pi(s){const e=[];for(const t of U_)us(s,t)&&e.push(bl[t]);return e.length===0?"untyped":e.length<3?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e[e.length-1]}function us(s,e){return(s&e)===e}function Dt(s,e){return s===e}class Pe{constructor(e,t){if(!B_(e))throw new Error(`literal expressions must have a specific type, got ${Pi(e)}`);this.type=e,this.value=t}}class vu{constructor(e,t,...n){this.type=e,this.operator=t,this.args=n}}function Dl(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mapState:!1}}function De(s,e,t){switch(typeof s){case"boolean":{if(Dt(e,Ie))return new Pe(Ie,s?"true":"false");if(!us(e,ve))throw new Error(`got a boolean, but expected ${Pi(e)}`);return new Pe(ve,s)}case"number":{if(Dt(e,yt))return new Pe(yt,Xe(s));if(Dt(e,ve))return new Pe(ve,!!s);if(Dt(e,Ie))return new Pe(Ie,s.toString());if(!us(e,N))throw new Error(`got a number, but expected ${Pi(e)}`);return new Pe(N,s)}case"string":{if(Dt(e,_e))return new Pe(_e,Fl(s));if(Dt(e,ve))return new Pe(ve,!!s);if(!us(e,Ie))throw new Error(`got a string, but expected ${Pi(e)}`);return new Pe(Ie,s)}}if(!Array.isArray(s))throw new Error("expression must be an array or a primitive value");if(s.length===0)throw new Error("empty expression");if(typeof s[0]=="string")return q_(s,e,t);for(const n of s)if(typeof n!="number")throw new Error("expected an array of numbers");if(Dt(e,yt)){if(s.length!==2)throw new Error(`expected an array of two values for a size, got ${s.length}`);return new Pe(yt,s)}if(Dt(e,_e)){if(s.length===3)return new Pe(_e,[...s,1]);if(s.length===4)return new Pe(_e,s);throw new Error(`expected an array of 3 or 4 values for a color, got ${s.length}`)}if(!us(e,nt))throw new Error(`got an array of numbers, but expected ${Pi(e)}`);return new Pe(nt,s)}const C={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},z_={[C.Get]:j(q(1,1/0),$h),[C.Var]:j(q(1,1),$_),[C.Has]:j(q(1,1/0),$h),[C.Id]:j(X_,gi),[C.Concat]:j(q(2,1/0),re(Ie)),[C.GeometryType]:j(Y_,gi),[C.LineMetric]:j(gi),[C.Resolution]:j(jo,gi),[C.Zoom]:j(jo,gi),[C.Time]:j(jo,gi),[C.Any]:j(q(2,1/0),re(ve)),[C.All]:j(q(2,1/0),re(ve)),[C.Not]:j(q(1,1),re(ve)),[C.Equal]:j(q(2,2),re(or)),[C.NotEqual]:j(q(2,2),re(or)),[C.GreaterThan]:j(q(2,2),re(N)),[C.GreaterThanOrEqualTo]:j(q(2,2),re(N)),[C.LessThan]:j(q(2,2),re(N)),[C.LessThanOrEqualTo]:j(q(2,2),re(N)),[C.Multiply]:j(q(2,1/0),Xh),[C.Coalesce]:j(q(2,1/0),Xh),[C.Divide]:j(q(2,2),re(N)),[C.Add]:j(q(2,1/0),re(N)),[C.Subtract]:j(q(2,2),re(N)),[C.Clamp]:j(q(3,3),re(N)),[C.Mod]:j(q(2,2),re(N)),[C.Pow]:j(q(2,2),re(N)),[C.Abs]:j(q(1,1),re(N)),[C.Floor]:j(q(1,1),re(N)),[C.Ceil]:j(q(1,1),re(N)),[C.Round]:j(q(1,1),re(N)),[C.Sin]:j(q(1,1),re(N)),[C.Cos]:j(q(1,1),re(N)),[C.Atan]:j(q(1,2),re(N)),[C.Sqrt]:j(q(1,1),re(N)),[C.Match]:j(q(4,1/0),Yh,W_),[C.Between]:j(q(3,3),re(N)),[C.Interpolate]:j(q(6,1/0),Yh,V_),[C.Case]:j(q(3,1/0),j_,Z_),[C.In]:j(q(2,2),K_),[C.Number]:j(q(1,1/0),re(or)),[C.String]:j(q(1,1/0),re(or)),[C.Array]:j(q(1,1/0),re(N)),[C.Color]:j(q(1,4),re(N)),[C.Band]:j(q(1,3),re(N)),[C.Palette]:j(q(2,2),H_),[C.ToString]:j(q(1,1),re(ve|N|Ie|_e))};function $h(s,e,t){const n=s.length-1,i=new Array(n);for(let r=0;r<n;++r){const o=s[r+1];switch(typeof o){case"number":{i[r]=new Pe(N,o);break}case"string":{i[r]=new Pe(Ie,o);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${o}`)}r===0&&t.properties.add(String(o))}return i}function $_(s,e,t){const n=s[1];if(typeof n!="string")throw new Error("expected a string argument for var operation");return t.variables.add(n),[new Pe(Ie,n)]}function X_(s,e,t){t.featureId=!0}function Y_(s,e,t){t.geometryType=!0}function jo(s,e,t){t.mapState=!0}function gi(s,e,t){const n=s[0];if(s.length!==1)throw new Error(`expected no arguments for ${n} operation`);return[]}function q(s,e){return function(t,n,i){const r=t[0],o=t.length-1;if(s===e){if(o!==s){const a=s===1?"":"s";throw new Error(`expected ${s} argument${a} for ${r}, got ${o}`)}}else if(o<s||o>e){const a=e===1/0?`${s} or more`:`${s} to ${e}`;throw new Error(`expected ${a} arguments for ${r}, got ${o}`)}}}function Xh(s,e,t){const n=s.length-1,i=new Array(n);for(let r=0;r<n;++r){const o=De(s[r+1],e,t);i[r]=o}return i}function re(s){return function(e,t,n){const i=e.length-1,r=new Array(i);for(let o=0;o<i;++o){const a=De(e[o+1],s,n);r[o]=a}return r}}function j_(s,e,t){const n=s[0],i=s.length-1;if(i%2===0)throw new Error(`expected an odd number of arguments for ${n}, got ${i} instead`)}function Yh(s,e,t){const n=s[0],i=s.length-1;if(i%2===1)throw new Error(`expected an even number of arguments for operation ${n}, got ${i} instead`)}function W_(s,e,t){const n=s.length-1,i=Ie|N|ve,r=De(s[1],i,t),o=De(s[s.length-1],e,t),a=new Array(n-2);for(let l=0;l<n-2;l+=2){try{const h=De(s[l+2],r.type,t);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}try{const h=De(s[l+3],o.type,t);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+2} of match expression: ${h.message}`)}}return[r,...a,o]}function V_(s,e,t){const n=s[1];let i;switch(n[0]){case"linear":i=1;break;case"exponential":const l=n[1];if(typeof l!="number"||l<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(l)} instead`);i=l;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(n)}`)}const r=new Pe(N,i);let o;try{o=De(s[2],N,t)}catch(l){throw new Error(`failed to parse argument 1 in interpolate expression: ${l.message}`)}const a=new Array(s.length-3);for(let l=0;l<a.length;l+=2){try{const h=De(s[l+3],N,t);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{const h=De(s[l+4],e,t);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+3} for interpolate expression: ${h.message}`)}}return[r,o,...a]}function Z_(s,e,t){const n=De(s[s.length-1],e,t),i=new Array(s.length-1);for(let r=0;r<i.length-1;r+=2){try{const o=De(s[r+1],ve,t);i[r]=o}catch(o){throw new Error(`failed to parse argument ${r} of case expression: ${o.message}`)}try{const o=De(s[r+2],n.type,t);i[r+1]=o}catch(o){throw new Error(`failed to parse argument ${r+1} of case expression: ${o.message}`)}}return i[i.length-1]=n,i}function K_(s,e,t){let n=s[2];if(!Array.isArray(n))throw new Error('the second argument for the "in" operator must be an array');let i;if(typeof n[0]=="string"){if(n[0]!=="literal")throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');if(!Array.isArray(n[1]))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array');n=n[1],i=Ie}else i=N;const r=new Array(n.length);for(let a=0;a<r.length;a++)try{const l=De(n[a],i,t);r[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[De(s[1],i,t),...r]}function H_(s,e,t){let n;try{n=De(s[1],N,t)}catch(o){throw new Error(`failed to parse first argument in palette expression: ${o.message}`)}const i=s[2];if(!Array.isArray(i))throw new Error("the second argument of palette must be an array");const r=new Array(i.length);for(let o=0;o<r.length;o++){let a;try{a=De(i[o],_e,t)}catch(l){throw new Error(`failed to parse color at index ${o} in palette expression: ${l.message}`)}if(!(a instanceof Pe))throw new Error(`the palette color at index ${o} must be a literal value`);r[o]=a}return[n,...r]}function j(...s){return function(e,t,n){const i=e[0];let r;for(let o=0;o<s.length;o++){const a=s[o](e,t,n);if(o==s.length-1){if(!a)throw new Error("expected last argument validator to return the parsed args");r=a}}return new vu(t,i,...r)}}function q_(s,e,t){const n=s[0],i=z_[n];if(!i)throw new Error(`unknown operator: ${n}`);return i(s,e,t)}function Ol(s){if(!s)return"";const e=s.getType();switch(e){case"Point":case"LineString":case"Polygon":return e;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return e.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return Ol(s.getGeometries()[0]);default:return""}}function wu(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function an(s,e,t){const n=De(s,e,t);return Pt(n)}function Pt(s,e){if(s instanceof Pe){if(s.type===_e&&typeof s.value=="string"){const n=Fl(s.value);return function(){return n}}return function(){return s.value}}const t=s.operator;switch(t){case C.Number:case C.String:case C.Coalesce:return J_(s);case C.Get:case C.Var:case C.Has:return Q_(s);case C.Id:return n=>n.featureId;case C.GeometryType:return n=>n.geometryType;case C.Concat:{const n=s.args.map(i=>Pt(i));return i=>"".concat(...n.map(r=>r(i).toString()))}case C.Resolution:return n=>n.resolution;case C.Any:case C.All:case C.Between:case C.In:case C.Not:return tm(s);case C.Equal:case C.NotEqual:case C.LessThan:case C.LessThanOrEqualTo:case C.GreaterThan:case C.GreaterThanOrEqualTo:return em(s);case C.Multiply:case C.Divide:case C.Add:case C.Subtract:case C.Clamp:case C.Mod:case C.Pow:case C.Abs:case C.Floor:case C.Ceil:case C.Round:case C.Sin:case C.Cos:case C.Atan:case C.Sqrt:return nm(s);case C.Case:return im(s);case C.Match:return sm(s);case C.Interpolate:return rm(s);case C.ToString:return om(s);default:throw new Error(`Unsupported operator ${t}`)}}function J_(s,e){const t=s.operator,n=s.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=Pt(s.args[r]);switch(t){case C.Coalesce:return r=>{for(let o=0;o<n;++o){const a=i[o](r);if(typeof a<"u"&&a!==null)return a}throw new Error("Expected one of the values to be non-null")};case C.Number:case C.String:return r=>{for(let o=0;o<n;++o){const a=i[o](r);if(typeof a===t)return a}throw new Error(`Expected one of the values to be a ${t}`)};default:throw new Error(`Unsupported assertion operator ${t}`)}}function Q_(s,e){const n=s.args[0].value;switch(s.operator){case C.Get:return i=>{const r=s.args;let o=i.properties[n];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;o=o[c]}return o};case C.Var:return i=>i.variables[n];case C.Has:return i=>{const r=s.args;if(!(n in i.properties))return!1;let o=i.properties[n];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;if(!o||!Object.hasOwn(o,c))return!1;o=o[c]}return!0};default:throw new Error(`Unsupported accessor operator ${s.operator}`)}}function em(s,e){const t=s.operator,n=Pt(s.args[0]),i=Pt(s.args[1]);switch(t){case C.Equal:return r=>n(r)===i(r);case C.NotEqual:return r=>n(r)!==i(r);case C.LessThan:return r=>n(r)<i(r);case C.LessThanOrEqualTo:return r=>n(r)<=i(r);case C.GreaterThan:return r=>n(r)>i(r);case C.GreaterThanOrEqualTo:return r=>n(r)>=i(r);default:throw new Error(`Unsupported comparison operator ${t}`)}}function tm(s,e){const t=s.operator,n=s.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=Pt(s.args[r]);switch(t){case C.Any:return r=>{for(let o=0;o<n;++o)if(i[o](r))return!0;return!1};case C.All:return r=>{for(let o=0;o<n;++o)if(!i[o](r))return!1;return!0};case C.Between:return r=>{const o=i[0](r),a=i[1](r),l=i[2](r);return o>=a&&o<=l};case C.In:return r=>{const o=i[0](r);for(let a=1;a<n;++a)if(o===i[a](r))return!0;return!1};case C.Not:return r=>!i[0](r);default:throw new Error(`Unsupported logical operator ${t}`)}}function nm(s,e){const t=s.operator,n=s.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=Pt(s.args[r]);switch(t){case C.Multiply:return r=>{let o=1;for(let a=0;a<n;++a)o*=i[a](r);return o};case C.Divide:return r=>i[0](r)/i[1](r);case C.Add:return r=>{let o=0;for(let a=0;a<n;++a)o+=i[a](r);return o};case C.Subtract:return r=>i[0](r)-i[1](r);case C.Clamp:return r=>{const o=i[0](r),a=i[1](r);if(o<a)return a;const l=i[2](r);return o>l?l:o};case C.Mod:return r=>i[0](r)%i[1](r);case C.Pow:return r=>Math.pow(i[0](r),i[1](r));case C.Abs:return r=>Math.abs(i[0](r));case C.Floor:return r=>Math.floor(i[0](r));case C.Ceil:return r=>Math.ceil(i[0](r));case C.Round:return r=>Math.round(i[0](r));case C.Sin:return r=>Math.sin(i[0](r));case C.Cos:return r=>Math.cos(i[0](r));case C.Atan:return n===2?r=>Math.atan2(i[0](r),i[1](r)):r=>Math.atan(i[0](r));case C.Sqrt:return r=>Math.sqrt(i[0](r));default:throw new Error(`Unsupported numeric operator ${t}`)}}function im(s,e){const t=s.args.length,n=new Array(t);for(let i=0;i<t;++i)n[i]=Pt(s.args[i]);return i=>{for(let r=0;r<t-1;r+=2)if(n[r](i))return n[r+1](i);return n[t-1](i)}}function sm(s,e){const t=s.args.length,n=new Array(t);for(let i=0;i<t;++i)n[i]=Pt(s.args[i]);return i=>{const r=n[0](i);for(let o=1;o<t-1;o+=2)if(r===n[o](i))return n[o+1](i);return n[t-1](i)}}function rm(s,e){const t=s.args.length,n=new Array(t);for(let i=0;i<t;++i)n[i]=Pt(s.args[i]);return i=>{const r=n[0](i),o=n[1](i);let a,l;for(let h=2;h<t;h+=2){const c=n[h](i);let u=n[h+1](i);const d=Array.isArray(u);if(d&&(u=N_(u)),c>=o)return h===2?u:d?am(r,o,a,l,c,u):ds(r,o,a,l,c,u);a=c,l=u}return l}}function om(s,e){const t=s.operator,n=s.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=Pt(s.args[r]);switch(t){case C.ToString:return r=>{const o=i[0](r);return s.args[0].type===_e?Ml(o):o.toString()};default:throw new Error(`Unsupported convert operator ${t}`)}}function ds(s,e,t,n,i,r){const o=i-t;if(o===0)return n;const a=e-t,l=s===1?a/o:(Math.pow(s,a)-1)/(Math.pow(s,o)-1);return n+l*(r-n)}function am(s,e,t,n,i,r){if(i-t===0)return n;const a=Bh(n),l=Bh(r);let h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);const c=[ds(s,e,t,a[0],i,l[0]),ds(s,e,t,a[1],i,l[1]),a[2]+ds(s,e,t,0,i,h),ds(s,e,t,n[3],i,r[3])];return G_(c)}const U={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};class lm extends Ds{constructor(e,t,n,i){super(),this.extent=e,this.pixelRatio_=n,this.resolution=t,this.state=typeof i=="function"?U.IDLE:i,this.image_=null,this.loader=typeof i=="function"?i:null}changed(){this.dispatchEvent(V.CHANGE)}getExtent(){return this.extent}getImage(){return this.image_}getPixelRatio(){return this.pixelRatio_}getResolution(){return this.resolution}getState(){return this.state}load(){if(this.state==U.IDLE&&this.loader){this.state=U.LOADING,this.changed();const e=this.getResolution(),t=Array.isArray(e)?e[0]:e;Oc(()=>this.loader(this.getExtent(),t,this.getPixelRatio())).then(n=>{"image"in n&&(this.image_=n.image),"extent"in n&&(this.extent=n.extent),"resolution"in n&&(this.resolution=n.resolution),"pixelRatio"in n&&(this.pixelRatio_=n.pixelRatio),(n instanceof HTMLImageElement||pf&&n instanceof ImageBitmap||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement)&&(this.image_=n),this.state=U.LOADED}).catch(n=>{this.state=U.ERROR,console.error(n)}).finally(()=>this.changed())}}setImage(e){this.image_=e}setResolution(e){this.resolution=e}}function hm(s,e,t){const n=s;let i=!0,r=!1,o=!1;const a=[wr(n,V.LOAD,function(){o=!0,r||e()})];return n.src&&Gc?(r=!0,n.decode().then(function(){i&&e()}).catch(function(l){i&&(o?e():t())})):a.push(wr(n,V.ERROR,t)),function(){i=!1,a.forEach(ue)}}function cm(s,e){return new Promise((t,n)=>{function i(){o(),t(s)}function r(){o(),n(new Error("Image load error"))}function o(){s.removeEventListener("load",i),s.removeEventListener("error",r)}s.addEventListener("load",i),s.addEventListener("error",r)})}function um(s,e){return e&&(s.src=e),s.src&&Gc?new Promise((t,n)=>s.decode().then(()=>t(s)).catch(i=>s.complete&&s.width?t(s):n(i))):cm(s)}class dm{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let e=0;for(const t in this.cache_){const n=this.cache_[t];(e++&3)===0&&!n.hasListener()&&(delete this.cache_[t],delete this.patternCache_[t],--this.cacheSize_)}}}get(e,t,n){const i=Wo(e,t,n);return i in this.cache_?this.cache_[i]:null}getPattern(e,t,n){const i=Wo(e,t,n);return i in this.patternCache_?this.patternCache_[i]:null}set(e,t,n,i,r){const o=Wo(e,t,n),a=o in this.cache_;this.cache_[o]=i,r&&(i.getImageState()===U.IDLE&&i.load(),i.getImageState()===U.LOADING?i.ready().then(()=>{this.patternCache_[o]=Dr().createPattern(i.getImage(1),"repeat")}):this.patternCache_[o]=Dr().createPattern(i.getImage(1),"repeat")),a||++this.cacheSize_}setSize(e){this.maxCacheSize_=e,this.expire()}}function Wo(s,e,t){const n=t?Ct(t):"null";return e+":"+s+":"+n}const xt=new dm;let os=null;class Pu extends Ds{constructor(e,t,n,i,r){super(),this.hitDetectionImage_=null,this.image_=e,this.crossOrigin_=n,this.canvas_={},this.color_=r,this.imageState_=i===void 0?U.IDLE:i,this.size_=e&&e.width&&e.height?[e.width,e.height]:null,this.src_=t,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===U.LOADED){os||(os=we(1,1,void 0,{willReadFrequently:!0})),os.drawImage(this.image_,0,0);try{os.getImageData(0,0,1,1),this.tainted_=!1}catch{os=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(V.CHANGE)}handleImageError_(){this.imageState_=U.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=U.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(e){return this.image_||this.initializeImage_(),this.replaceColor_(e),this.canvas_[e]?this.canvas_[e]:this.image_}getPixelRatio(e){return this.replaceColor_(e),this.canvas_[e]?e:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const e=this.size_[0],t=this.size_[1],n=we(e,t);n.fillRect(0,0,e,t),this.hitDetectionImage_=n.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===U.IDLE){this.image_||this.initializeImage_(),this.imageState_=U.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&um(this.image_,this.src_).then(e=>{this.image_=e,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(e){if(!this.color_||this.canvas_[e]||this.imageState_!==U.LOADED)return;const t=this.image_,n=we(Math.ceil(t.width*e),Math.ceil(t.height*e)),i=n.canvas;n.scale(e,e),n.drawImage(t,0,0),n.globalCompositeOperation="multiply",n.fillStyle=D_(this.color_),n.fillRect(0,0,i.width/e,i.height/e),n.globalCompositeOperation="destination-in",n.drawImage(t,0,0),this.canvas_[e]=i}ready(){return this.ready_||(this.ready_=new Promise(e=>{if(this.imageState_===U.LOADED||this.imageState_===U.ERROR)e();else{const t=()=>{(this.imageState_===U.LOADED||this.imageState_===U.ERROR)&&(this.removeEventListener(V.CHANGE,t),e())};this.addEventListener(V.CHANGE,t)}})),this.ready_}}function Gr(s,e,t,n,i,r){let o=e===void 0?void 0:xt.get(e,t,i);return o||(o=new Pu(s,s&&"src"in s?s.src||void 0:e,t,n,i),xt.set(e,t,i,o,r)),r&&o&&!xt.getPattern(e,t,i)&&xt.set(e,t,i,o,r),o}function Ot(s){return s?Array.isArray(s)?Ml(s):typeof s=="object"&&"src"in s?fm(s):s:null}function fm(s){if(!s.offset||!s.size)return xt.getPattern(s.src,"anonymous",s.color);const e=s.src+":"+s.offset,t=xt.getPattern(e,void 0,s.color);if(t)return t;const n=xt.get(s.src,"anonymous",null);if(n.getImageState()!==U.LOADED)return null;const i=we(s.size[0],s.size[1]);return i.drawImage(n.getImage(1),s.offset[0],s.offset[1],s.size[0],s.size[1],0,0,s.size[0],s.size[1]),Gr(i.canvas,e,void 0,U.LOADED,s.color,!0),xt.getPattern(e,void 0,s.color)}const Iu="10px sans-serif",Je="#000",Bi="round",nn=[],sn=0,zi="round",ws=10,Ps="#000",Is="center",kr="middle",$n=[0,0,0,0],As=1,Ri=new Rt;let as=null,jh;const ba={},gm=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function _m(s,e,t){return`${s} ${e} 16px "${t}"`}const mm=(function(){let e,t;async function n(r){await t.ready;const o=await t.load(r);if(o.length===0)return!1;const a=La(r),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{const u=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),d=Aa[c.weight]||c.weight;return u===l&&c.style===a.style&&d==h})}async function i(){await t.ready;let r=!0;const o=Ri.getProperties(),a=Object.keys(o).filter(l=>o[l]<100);for(let l=a.length-1;l>=0;--l){const h=a[l];let c=o[h];c<100&&(await n(h)?(ei(ba),Ri.set(h,100)):(c+=10,Ri.set(h,c,!0),c<100&&(r=!1)))}e=void 0,r||(e=setTimeout(i,100))}return async function(r){t||(t=at?self.fonts:document.fonts);const o=La(r);if(!o)return;const a=o.families;let l=!1;for(const h of a){if(gm.has(h))continue;const c=_m(o.style,o.weight,h);Ri.get(c)===void 0&&(Ri.set(c,0,!0),l=!0)}l&&(clearTimeout(e),e=setTimeout(i,100))}})(),pm=(function(){let s;return function(e){let t=ba[e];if(t==null){if(at){const n=La(e),i=Au(e,"Žg");t=(isNaN(Number(n.lineHeight))?1.2:Number(n.lineHeight))*(i.actualBoundingBoxAscent+i.actualBoundingBoxDescent)}else s||(s=document.createElement("div"),s.innerHTML="M",s.style.minHeight="0",s.style.maxHeight="none",s.style.height="auto",s.style.padding="0",s.style.border="none",s.style.position="absolute",s.style.display="block",s.style.left="-99999px"),s.style.font=e,document.body.appendChild(s),t=s.offsetHeight,document.body.removeChild(s);ba[e]=t}return t}})();function Au(s,e){return as||(as=we(1,1)),s!=jh&&(as.font=s,jh=as.font),as.measureText(e)}function Lu(s,e){return Au(s,e).width}function Wh(s,e,t){if(e in t)return t[e];const n=e.split(`
|
||
`).reduce((i,r)=>Math.max(i,Lu(s,r)),0);return t[e]=n,n}function ym(s,e){const t=[],n=[],i=[];let r=0,o=0,a=0,l=0;for(let h=0,c=e.length;h<=c;h+=2){const u=e[h];if(u===`
|
||
`||h===c){r=Math.max(r,o),i.push(o),o=0,a+=l,l=0;continue}const d=e[h+1]||s.font,f=Lu(d,u);t.push(f),o+=f;const g=pm(d);n.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:t,heights:n,lineWidths:i}}function xm(s,e,t,n,i,r,o,a,l,h,c){s.save(),t!==1&&(s.globalAlpha===void 0?s.globalAlpha=u=>u.globalAlpha*=t:s.globalAlpha*=t),e&&s.transform.apply(s,e),n.contextInstructions?(s.translate(l,h),s.scale(c[0],c[1]),Em(n,s)):c[0]<0||c[1]<0?(s.translate(l,h),s.scale(c[0],c[1]),s.drawImage(n,i,r,o,a,0,0,o,a)):s.drawImage(n,i,r,o,a,l,h,o*c[0],a*c[1]),s.restore()}function Em(s,e){const t=s.contextInstructions;for(let n=0,i=t.length;n<i;n+=2)Array.isArray(t[n+1])?e[t[n]].apply(e,t[n+1]):e[t[n]]=t[n+1]}class uo{constructor(e){this.opacity_=e.opacity,this.rotateWithView_=e.rotateWithView,this.rotation_=e.rotation,this.scale_=e.scale,this.scaleArray_=Xe(e.scale),this.displacement_=e.displacement,this.declutterMode_=e.declutterMode}clone(){const e=this.getScale();return new uo({opacity:this.getOpacity(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return $()}getImage(e){return $()}getHitDetectionImage(){return $()}getPixelRatio(e){return 1}getImageState(){return $()}getImageSize(){return $()}getOrigin(){return $()}getSize(){return $()}setDisplacement(e){this.displacement_=e}setOpacity(e){this.opacity_=e}setRotateWithView(e){this.rotateWithView_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=Xe(e)}listenImageChange(e){$()}load(){$()}unlistenImageChange(e){$()}ready(){return Promise.resolve()}}class fo extends uo{constructor(e){super({opacity:1,rotateWithView:e.rotateWithView!==void 0?e.rotateWithView:!1,rotation:e.rotation!==void 0?e.rotation:0,scale:e.scale!==void 0?e.scale:1,displacement:e.displacement!==void 0?e.displacement:[0,0],declutterMode:e.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=e.fill!==void 0?e.fill:null,this.origin_=[0,0],this.points_=e.points,this.radius=e.radius,this.radius2_=e.radius2,this.angle_=e.angle!==void 0?e.angle:0,this.stroke_=e.stroke!==void 0?e.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?U.LOADING:U.LOADED,this.imageState_===U.LOADING&&this.ready().then(()=>this.imageState_=U.LOADED),this.render()}clone(){const e=this.getScale(),t=new fo({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(e)?e.slice():e,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return t.setOpacity(this.getOpacity()),t}getAnchor(){const e=this.size_,t=this.getDisplacement(),n=this.getScaleArray();return[e[0]/2-t[0]/n[0],e[1]/2+t[1]/n[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(e){this.fill_=e,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(e){const t=this.fill_?.getKey(),n=`${e},${this.angle_},${this.radius},${this.radius2_},${this.points_},${t}`+Object.values(this.renderOptions_).join(",");let i=xt.get(n,null,null)?.getImage(1);if(!i){const r=this.renderOptions_,o=Math.ceil(r.size*e),a=we(o,o);this.draw_(r,a,e),i=a.canvas,xt.set(n,null,null,new Pu(i,void 0,null,U.LOADED,null))}return i}getPixelRatio(e){return e}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e,this.render()}listenImageChange(e){}load(){}unlistenImageChange(e){}calculateLineJoinSize_(e,t,n){if(t===0||this.points_===1/0||e!=="bevel"&&e!=="miter")return t;let i=this.radius,r=this.radius2_===void 0?i:this.radius2_;if(i<r){const R=i;i=r,r=R}const o=this.radius2_===void 0?this.points_:this.points_*2,a=2*Math.PI/o,l=r*Math.sin(a),h=Math.sqrt(r*r-l*l),c=i-h,u=Math.sqrt(l*l+c*c),d=u/l;if(e==="miter"&&d<=n)return d*t;const f=t/2/d,g=t/2*(c/u),_=Math.sqrt((i+f)*(i+f)+g*g)-i;if(this.radius2_===void 0||e==="bevel")return _*2;const p=i*Math.sin(a),y=Math.sqrt(i*i-p*p),E=r-y,T=Math.sqrt(p*p+E*E)/p;if(T<=n){const R=T*t/2-r-i;return 2*Math.max(_,R)}return _*2}createRenderOptions(){let e=Bi,t=zi,n=0,i=null,r=0,o,a=0;this.stroke_&&(o=Ot(this.stroke_.getColor()??Ps),a=this.stroke_.getWidth()??As,i=this.stroke_.getLineDash(),r=this.stroke_.getLineDashOffset()??0,t=this.stroke_.getLineJoin()??zi,e=this.stroke_.getLineCap()??Bi,n=this.stroke_.getMiterLimit()??ws);const l=this.calculateLineJoinSize_(t,a,n),h=Math.max(this.radius,this.radius2_||0),c=Math.ceil(2*h+l);return{strokeStyle:o,strokeWidth:a,size:c,lineCap:e,lineDash:i,lineDashOffset:r,lineJoin:t,miterLimit:n}}render(){this.renderOptions_=this.createRenderOptions();const e=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[e,e]}draw_(e,t,n){if(t.scale(n,n),t.translate(e.size/2,e.size/2),this.createPath_(t),this.fill_){let i=this.fill_.getColor();i===null&&(i=Je),t.fillStyle=Ot(i),t.fill()}e.strokeStyle&&(t.strokeStyle=e.strokeStyle,t.lineWidth=e.strokeWidth,e.lineDash&&(t.setLineDash(e.lineDash),t.lineDashOffset=e.lineDashOffset),t.lineCap=e.lineCap,t.lineJoin=e.lineJoin,t.miterLimit=e.miterLimit,t.stroke())}createHitDetectionCanvas_(e){let t;if(this.fill_){let n=this.fill_.getColor(),i=0;typeof n=="string"&&(n=Ct(n)),n===null?i=1:Array.isArray(n)&&(i=n.length===4?n[3]:1),i===0&&(t=we(e.size,e.size),this.drawHitDetectionCanvas_(e,t))}return t?t.canvas:this.getImage(1)}createPath_(e){let t=this.points_;const n=this.radius;if(t===1/0)e.arc(0,0,n,0,2*Math.PI);else{const i=this.radius2_===void 0?n:this.radius2_;this.radius2_!==void 0&&(t*=2);const r=this.angle_-Math.PI/2,o=2*Math.PI/t;for(let a=0;a<t;a++){const l=r+a*o,h=a%2===0?n:i;e.lineTo(h*Math.cos(l),h*Math.sin(l))}e.closePath()}}drawHitDetectionCanvas_(e,t){t.translate(e.size/2,e.size/2),this.createPath_(t),t.fillStyle=Je,t.fill(),e.strokeStyle&&(t.strokeStyle=e.strokeStyle,t.lineWidth=e.strokeWidth,e.lineDash&&(t.setLineDash(e.lineDash),t.lineDashOffset=e.lineDashOffset),t.lineJoin=e.lineJoin,t.miterLimit=e.miterLimit,t.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}}class $s extends fo{constructor(e){e=e||{radius:5},super({points:1/0,fill:e.fill,radius:e.radius,stroke:e.stroke,scale:e.scale!==void 0?e.scale:1,rotation:e.rotation!==void 0?e.rotation:0,rotateWithView:e.rotateWithView!==void 0?e.rotateWithView:!1,displacement:e.displacement!==void 0?e.displacement:[0,0],declutterMode:e.declutterMode})}clone(){const e=this.getScale(),t=new $s({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return t.setOpacity(this.getOpacity()),t}setRadius(e){this.radius=e,this.render()}}class It{constructor(e){e=e||{},this.patternImage_=null,this.color_=null,e.color!==void 0&&this.setColor(e.color)}clone(){const e=this.getColor();return new It({color:Array.isArray(e)?e.slice():e||void 0})}getColor(){return this.color_}setColor(e){if(e!==null&&typeof e=="object"&&"src"in e){const t=Gr(null,e.src,"anonymous",void 0,e.offset?null:e.color?e.color:null,!(e.offset&&e.size));t.ready().then(()=>{this.patternImage_=null}),t.getImageState()===U.IDLE&&t.load(),t.getImageState()===U.LOADING&&(this.patternImage_=t)}this.color_=e}getKey(){const e=this.getColor();return e?e instanceof CanvasPattern||e instanceof CanvasGradient?D(e):typeof e=="object"&&"src"in e?e.src+":"+e.offset:Ct(e).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function Vh(s,e,t,n){return t!==void 0&&n!==void 0?[t/s,n/e]:t!==void 0?t/s:n!==void 0?n/e:1}class Ki extends uo{constructor(e){e=e||{};const t=e.opacity!==void 0?e.opacity:1,n=e.rotation!==void 0?e.rotation:0,i=e.scale!==void 0?e.scale:1,r=e.rotateWithView!==void 0?e.rotateWithView:!1;super({opacity:t,rotation:n,scale:i,displacement:e.displacement!==void 0?e.displacement:[0,0],rotateWithView:r,declutterMode:e.declutterMode}),this.anchor_=e.anchor!==void 0?e.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=e.anchorOrigin!==void 0?e.anchorOrigin:"top-left",this.anchorXUnits_=e.anchorXUnits!==void 0?e.anchorXUnits:"fraction",this.anchorYUnits_=e.anchorYUnits!==void 0?e.anchorYUnits:"fraction",this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:null;const o=e.img!==void 0?e.img:null;let a=e.src;te(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||D(o)),te(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),te(!((e.width!==void 0||e.height!==void 0)&&e.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(e.src!==void 0?l=U.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?U.LOADED:U.IDLE:l=U.LOADING:l=U.LOADED),this.color_=e.color!==void 0?Ct(e.color):null,this.iconImage_=Gr(o,a,this.crossOrigin_,l,this.color_),this.offset_=e.offset!==void 0?e.offset:[0,0],this.offsetOrigin_=e.offsetOrigin!==void 0?e.offsetOrigin:"top-left",this.origin_=null,this.size_=e.size!==void 0?e.size:null,this.initialOptions_,e.width!==void 0||e.height!==void 0){let h,c;if(e.size)[h,c]=e.size;else{const u=this.getImage(1);if(u.width&&u.height)h=u.width,c=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=e;const d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(Vh(f[0],f[1],e.width,e.height))};this.listenImageChange(d);return}}h!==void 0&&this.setScale(Vh(h,c,e.width,e.height))}}clone(){let e,t,n;return this.initialOptions_?(t=this.initialOptions_.width,n=this.initialOptions_.height):(e=this.getScale(),e=Array.isArray(e)?e.slice():e),new Ki({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:e,width:t,height:n,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let e=this.normalizedAnchor_;if(!e){e=this.anchor_;const i=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!i)return null;e=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(e[0]*=i[0]),this.anchorYUnits_=="fraction"&&(e[1]*=i[1])}if(this.anchorOrigin_!="top-left"){if(!i)return null;e===this.anchor_&&(e=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(e[0]=-e[0]+i[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(e[1]=-e[1]+i[1])}this.normalizedAnchor_=e}const t=this.getDisplacement(),n=this.getScaleArray();return[e[0]-t[0]/n[0],e[1]+t[1]/n[1]]}setAnchor(e){this.anchor_=e,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(e){return this.iconImage_.getImage(e)}getPixelRatio(e){return this.iconImage_.getPixelRatio(e)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let e=this.offset_;if(this.offsetOrigin_!="top-left"){const t=this.getSize(),n=this.iconImage_.getSize();if(!t||!n)return null;e=e.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(e[0]=n[0]-t[0]-e[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(e[1]=n[1]-t[1]-e[1])}return this.origin_=e,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(e){this.iconImage_=Gr(null,e,this.crossOrigin_,U.IDLE,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const e=this.getScaleArray();if(this.size_)return this.size_[0]*e[0];if(this.iconImage_.getImageState()==U.LOADED)return this.iconImage_.getSize()[0]*e[0]}getHeight(){const e=this.getScaleArray();if(this.size_)return this.size_[1]*e[1];if(this.iconImage_.getImageState()==U.LOADED)return this.iconImage_.getSize()[1]*e[1]}setScale(e){delete this.initialOptions_,super.setScale(e)}listenImageChange(e){this.iconImage_.addEventListener(V.CHANGE,e)}load(){this.iconImage_.load()}unlistenImageChange(e){this.iconImage_.removeEventListener(V.CHANGE,e)}ready(){return this.iconImage_.ready()}}class kt{constructor(e){e=e||{},this.color_=e.color!==void 0?e.color:null,this.lineCap_=e.lineCap,this.lineDash_=e.lineDash!==void 0?e.lineDash:null,this.lineDashOffset_=e.lineDashOffset,this.lineJoin_=e.lineJoin,this.miterLimit_=e.miterLimit,this.width_=e.width}clone(){const e=this.getColor();return new kt({color:Array.isArray(e)?e.slice():e||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(e){this.color_=e}setLineCap(e){this.lineCap_=e}setLineDash(e){this.lineDash_=e}setLineDashOffset(e){this.lineDashOffset_=e}setLineJoin(e){this.lineJoin_=e}setMiterLimit(e){this.miterLimit_=e}setWidth(e){this.width_=e}}class Ne{constructor(e){e=e||{},this.geometry_=null,this.geometryFunction_=Zh,e.geometry!==void 0&&this.setGeometry(e.geometry),this.fill_=e.fill!==void 0?e.fill:null,this.image_=e.image!==void 0?e.image:null,this.renderer_=e.renderer!==void 0?e.renderer:null,this.hitDetectionRenderer_=e.hitDetectionRenderer!==void 0?e.hitDetectionRenderer:null,this.stroke_=e.stroke!==void 0?e.stroke:null,this.text_=e.text!==void 0?e.text:null,this.zIndex_=e.zIndex}clone(){let e=this.getGeometry();return e&&typeof e=="object"&&(e=e.clone()),new Ne({geometry:e??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(e){this.renderer_=e}setHitDetectionRenderer(e){this.hitDetectionRenderer_=e}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(e){this.fill_=e}getImage(){return this.image_}setImage(e){this.image_=e}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e}getText(){return this.text_}setText(e){this.text_=e}getZIndex(){return this.zIndex_}setGeometry(e){typeof e=="function"?this.geometryFunction_=e:typeof e=="string"?this.geometryFunction_=function(t){return t.get(e)}:e?e!==void 0&&(this.geometryFunction_=function(){return e}):this.geometryFunction_=Zh,this.geometry_=e}setZIndex(e){this.zIndex_=e}}function Tm(s){let e;if(typeof s=="function")e=s;else{let t;Array.isArray(s)?t=s:(te(typeof s.getZIndex=="function","Expected an `Style` or an array of `Style`"),t=[s]),e=function(){return t}}return e}let Vo=null;function Fu(s,e){if(!Vo){const t=new It({color:"rgba(255,255,255,0.4)"}),n=new kt({color:"#3399CC",width:1.25});Vo=[new Ne({image:new $s({fill:t,stroke:n,radius:5}),fill:t,stroke:n})]}return Vo}function Nl(){const s={},e=[255,255,255,1],t=[0,153,255,1],n=3;return s.Polygon=[new Ne({fill:new It({color:[255,255,255,.5]})})],s.MultiPolygon=s.Polygon,s.LineString=[new Ne({stroke:new kt({color:e,width:n+2})}),new Ne({stroke:new kt({color:t,width:n})})],s.MultiLineString=s.LineString,s.Circle=s.Polygon.concat(s.LineString),s.Point=[new Ne({image:new $s({radius:n*2,fill:new It({color:t}),stroke:new kt({color:e,width:n/2})}),zIndex:1/0})],s.MultiPoint=s.Point,s.GeometryCollection=s.Polygon.concat(s.LineString,s.Point),s}function Zh(s){return s.getGeometry()}const Cm="#333";class Xs{constructor(e){e=e||{},this.font_=e.font,this.rotation_=e.rotation,this.rotateWithView_=e.rotateWithView,this.keepUpright_=e.keepUpright,this.scale_=e.scale,this.scaleArray_=Xe(e.scale!==void 0?e.scale:1),this.text_=e.text,this.textAlign_=e.textAlign,this.justify_=e.justify,this.repeat_=e.repeat,this.textBaseline_=e.textBaseline,this.fill_=e.fill!==void 0?e.fill:new It({color:Cm}),this.maxAngle_=e.maxAngle!==void 0?e.maxAngle:Math.PI/4,this.placement_=e.placement!==void 0?e.placement:"point",this.overflow_=!!e.overflow,this.stroke_=e.stroke!==void 0?e.stroke:null,this.offsetX_=e.offsetX!==void 0?e.offsetX:0,this.offsetY_=e.offsetY!==void 0?e.offsetY:0,this.backgroundFill_=e.backgroundFill?e.backgroundFill:null,this.backgroundStroke_=e.backgroundStroke?e.backgroundStroke:null,this.padding_=e.padding===void 0?null:e.padding,this.declutterMode_=e.declutterMode}clone(){const e=this.getScale();return new Xs({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(e)?e.slice():e,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()instanceof It?this.getFill().clone():this.getFill(),stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(e){this.overflow_=e}setFont(e){this.font_=e}setMaxAngle(e){this.maxAngle_=e}setOffsetX(e){this.offsetX_=e}setOffsetY(e){this.offsetY_=e}setPlacement(e){this.placement_=e}setRepeat(e){this.repeat_=e}setRotateWithView(e){this.rotateWithView_=e}setKeepUpright(e){this.keepUpright_=e}setFill(e){this.fill_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=Xe(e!==void 0?e:1)}setStroke(e){this.stroke_=e}setText(e){this.text_=e}setTextAlign(e){this.textAlign_=e}setJustify(e){this.justify_=e}setTextBaseline(e){this.textBaseline_=e}setBackgroundFill(e){this.backgroundFill_=e}setBackgroundStroke(e){this.backgroundStroke_=e}setPadding(e){this.padding_=e}}function Rm(s){return!0}function Sm(s){const e=Dl(),t=vm(s,e),n=wu();return function(i,r){if(n.properties=i.getPropertiesInternal(),n.resolution=r,e.featureId){const o=i.getId();o!==void 0?n.featureId=o:n.featureId=null}return e.geometryType&&(n.geometryType=Ol(i.getGeometry())),t(n)}}function Kh(s){const e=Dl(),t=s.length,n=new Array(t);for(let o=0;o<t;++o)n[o]=Da(s[o],e);const i=wu(),r=new Array(t);return function(o,a){if(i.properties=o.getPropertiesInternal(),i.resolution=a,e.featureId){const h=o.getId();h!==void 0?i.featureId=h:i.featureId=null}let l=0;for(let h=0;h<t;++h){const c=n[h](i);c&&(r[l]=c,l+=1)}return r.length=l,r}}function vm(s,e){const t=s.length,n=new Array(t);for(let i=0;i<t;++i){const r=s[i],o="filter"in r?an(r.filter,ve,e):Rm;let a;if(Array.isArray(r.style)){const l=r.style.length;a=new Array(l);for(let h=0;h<l;++h)a[h]=Da(r.style[h],e)}else a=[Da(r.style,e)];n[i]={filter:o,styles:a}}return function(i){const r=[];let o=!1;for(let a=0;a<t;++a){const l=n[a].filter;if(l(i)&&!(s[a].else&&o)){o=!0;for(const h of n[a].styles){const c=h(i);c&&r.push(c)}}}return r}}function Da(s,e){const t=Ls(s,"",e),n=Fs(s,"",e),i=wm(s,e),r=Pm(s,e),o=et(s,"z-index",e);if(!t&&!n&&!i&&!r&&!Vn(s))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(s));const a=new Ne;return function(l){let h=!0;if(t){const c=t(l);c&&(h=!1),a.setFill(c)}if(n){const c=n(l);c&&(h=!1),a.setStroke(c)}if(i){const c=i(l);c&&(h=!1),a.setText(c)}if(r){const c=r(l);c&&(h=!1),a.setImage(c)}return o&&a.setZIndex(o(l)),h?null:a}}function Ls(s,e,t){let n;if(e+"fill-pattern-src"in s)n=Fm(s,e+"fill-",t);else{if(s[e+"fill-color"]==="none")return r=>null;n=Gl(s,e+"fill-color",t)}if(!n)return null;const i=new It;return function(r){const o=n(r);return o===Ll?null:(i.setColor(o),i)}}function Fs(s,e,t){const n=et(s,e+"stroke-width",t),i=Gl(s,e+"stroke-color",t);if(!n&&!i)return null;const r=Ht(s,e+"stroke-line-cap",t),o=Ht(s,e+"stroke-line-join",t),a=Mu(s,e+"stroke-line-dash",t),l=et(s,e+"stroke-line-dash-offset",t),h=et(s,e+"stroke-miter-limit",t),c=new kt;return function(u){if(i){const d=i(u);if(d===Ll)return null;c.setColor(d)}if(n&&c.setWidth(n(u)),r){const d=r(u);if(d!=="butt"&&d!=="round"&&d!=="square")throw new Error("Expected butt, round, or square line cap");c.setLineCap(d)}if(o){const d=o(u);if(d!=="bevel"&&d!=="round"&&d!=="miter")throw new Error("Expected bevel, round, or miter line join");c.setLineJoin(d)}return a&&c.setLineDash(a(u)),l&&c.setLineDashOffset(l(u)),h&&c.setMiterLimit(h(u)),c}}function wm(s,e){const t="text-",n=Ht(s,t+"value",e);if(!n)return null;const i=Ls(s,t,e),r=Ls(s,t+"background-",e),o=Fs(s,t,e),a=Fs(s,t+"background-",e),l=Ht(s,t+"font",e),h=et(s,t+"max-angle",e),c=et(s,t+"offset-x",e),u=et(s,t+"offset-y",e),d=Fi(s,t+"overflow",e),f=Ht(s,t+"placement",e),g=et(s,t+"repeat",e),m=go(s,t+"scale",e),_=Fi(s,t+"rotate-with-view",e),p=et(s,t+"rotation",e),y=Ht(s,t+"align",e),E=Ht(s,t+"justify",e),x=Ht(s,t+"baseline",e),T=Fi(s,t+"keep-upright",e),R=Mu(s,t+"padding",e),S=_o(s,t+"declutter-mode"),v=new Xs({declutterMode:S});return function(w){if(v.setText(n(w)),i&&v.setFill(i(w)),r&&v.setBackgroundFill(r(w)),o&&v.setStroke(o(w)),a&&v.setBackgroundStroke(a(w)),l&&v.setFont(l(w)),h&&v.setMaxAngle(h(w)),c&&v.setOffsetX(c(w)),u&&v.setOffsetY(u(w)),d&&v.setOverflow(d(w)),f){const I=f(w);if(I!=="point"&&I!=="line")throw new Error("Expected point or line for text-placement");v.setPlacement(I)}if(g&&v.setRepeat(g(w)),m&&v.setScale(m(w)),_&&v.setRotateWithView(_(w)),p&&v.setRotation(p(w)),y){const I=y(w);if(I!=="left"&&I!=="center"&&I!=="right"&&I!=="end"&&I!=="start")throw new Error("Expected left, right, center, start, or end for text-align");v.setTextAlign(I)}if(E){const I=E(w);if(I!=="left"&&I!=="right"&&I!=="center")throw new Error("Expected left, right, or center for text-justify");v.setJustify(I)}if(x){const I=x(w);if(I!=="bottom"&&I!=="top"&&I!=="middle"&&I!=="alphabetic"&&I!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");v.setTextBaseline(I)}return R&&v.setPadding(R(w)),T&&v.setKeepUpright(T(w)),v}}function Pm(s,e){return"icon-src"in s?Im(s,e):"shape-points"in s?Am(s,e):"circle-radius"in s?Lm(s,e):null}function Im(s,e){const t="icon-",n=t+"src",i=bu(s[n],n),r=Ur(s,t+"anchor",e),o=go(s,t+"scale",e),a=et(s,t+"opacity",e),l=Ur(s,t+"displacement",e),h=et(s,t+"rotation",e),c=Fi(s,t+"rotate-with-view",e),u=qh(s,t+"anchor-origin"),d=Jh(s,t+"anchor-x-units"),f=Jh(s,t+"anchor-y-units"),g=Om(s,t+"color"),m=bm(s,t+"cross-origin"),_=Dm(s,t+"offset"),p=qh(s,t+"offset-origin"),y=Br(s,t+"width"),E=Br(s,t+"height"),x=Mm(s,t+"size"),T=_o(s,t+"declutter-mode"),R=new Ki({src:i,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,color:g,crossOrigin:m,offset:_,offsetOrigin:p,height:E,width:y,size:x,declutterMode:T});return function(S){return a&&R.setOpacity(a(S)),l&&R.setDisplacement(l(S)),h&&R.setRotation(h(S)),c&&R.setRotateWithView(c(S)),o&&R.setScale(o(S)),r&&R.setAnchor(r(S)),R}}function Am(s,e){const t="shape-",n=t+"points",i=t+"radius",r=Oa(s[n],n),o=Oa(s[i],i),a=Ls(s,t,e),l=Fs(s,t,e),h=go(s,t+"scale",e),c=Ur(s,t+"displacement",e),u=et(s,t+"rotation",e),d=Fi(s,t+"rotate-with-view",e),f=Br(s,t+"radius2"),g=Br(s,t+"angle"),m=_o(s,t+"declutter-mode"),_=new fo({points:r,radius:o,radius2:f,angle:g,declutterMode:m});return function(p){return a&&_.setFill(a(p)),l&&_.setStroke(l(p)),c&&_.setDisplacement(c(p)),u&&_.setRotation(u(p)),d&&_.setRotateWithView(d(p)),h&&_.setScale(h(p)),_}}function Lm(s,e){const t="circle-",n=Ls(s,t,e),i=Fs(s,t,e),r=et(s,t+"radius",e),o=go(s,t+"scale",e),a=Ur(s,t+"displacement",e),l=et(s,t+"rotation",e),h=Fi(s,t+"rotate-with-view",e),c=_o(s,t+"declutter-mode"),u=new $s({radius:5,declutterMode:c});return function(d){return r&&u.setRadius(r(d)),n&&u.setFill(n(d)),i&&u.setStroke(i(d)),a&&u.setDisplacement(a(d)),l&&u.setRotation(l(d)),h&&u.setRotateWithView(h(d)),o&&u.setScale(o(d)),u}}function et(s,e,t){if(!(e in s))return;const n=an(s[e],N,t);return function(i){return Oa(n(i),e)}}function Ht(s,e,t){if(!(e in s))return null;const n=an(s[e],Ie,t);return function(i){return bu(n(i),e)}}function Fm(s,e,t){const n=Ht(s,e+"pattern-src",t),i=Hh(s,e+"pattern-offset",t),r=Hh(s,e+"pattern-size",t),o=Gl(s,e+"color",t);return function(a){return{src:n(a),offset:i&&i(a),size:r&&r(a),color:o&&o(a)}}}function Fi(s,e,t){if(!(e in s))return null;const n=an(s[e],ve,t);return function(i){const r=n(i);if(typeof r!="boolean")throw new Error(`Expected a boolean for ${e}`);return r}}function Gl(s,e,t){if(!(e in s))return null;const n=an(s[e],_e,t);return function(i){return Du(n(i),e)}}function Mu(s,e,t){if(!(e in s))return null;const n=an(s[e],nt,t);return function(i){return Ys(n(i),e)}}function Ur(s,e,t){if(!(e in s))return null;const n=an(s[e],nt,t);return function(i){const r=Ys(n(i),e);if(r.length!==2)throw new Error(`Expected two numbers for ${e}`);return r}}function Hh(s,e,t){if(!(e in s))return null;const n=an(s[e],nt,t);return function(i){return Ou(n(i),e)}}function go(s,e,t){if(!(e in s))return null;const n=an(s[e],nt|N,t);return function(i){return Nm(n(i),e)}}function Br(s,e){const t=s[e];if(t!==void 0){if(typeof t!="number")throw new Error(`Expected a number for ${e}`);return t}}function Mm(s,e){const t=s[e];if(t!==void 0){if(typeof t=="number")return Xe(t);if(!Array.isArray(t))throw new Error(`Expected a number or size array for ${e}`);if(t.length!==2||typeof t[0]!="number"||typeof t[1]!="number")throw new Error(`Expected a number or size array for ${e}`);return t}}function bm(s,e){const t=s[e];if(t!==void 0){if(typeof t!="string")throw new Error(`Expected a string for ${e}`);return t}}function qh(s,e){const t=s[e];if(t!==void 0){if(t!=="bottom-left"&&t!=="bottom-right"&&t!=="top-left"&&t!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${e}`);return t}}function Jh(s,e){const t=s[e];if(t!==void 0){if(t!=="pixels"&&t!=="fraction")throw new Error(`Expected pixels or fraction for ${e}`);return t}}function Dm(s,e){const t=s[e];if(t!==void 0)return Ys(t,e)}function _o(s,e){const t=s[e];if(t!==void 0){if(typeof t!="string")throw new Error(`Expected a string for ${e}`);if(t!=="declutter"&&t!=="obstacle"&&t!=="none")throw new Error(`Expected declutter, obstacle, or none for ${e}`);return t}}function Om(s,e){const t=s[e];if(t!==void 0)return Du(t,e)}function Ys(s,e){if(!Array.isArray(s))throw new Error(`Expected an array for ${e}`);const t=s.length;for(let n=0;n<t;++n)if(typeof s[n]!="number")throw new Error(`Expected an array of numbers for ${e}`);return s}function bu(s,e){if(typeof s!="string")throw new Error(`Expected a string for ${e}`);return s}function Oa(s,e){if(typeof s!="number")throw new Error(`Expected a number for ${e}`);return s}function Du(s,e){if(typeof s=="string")return s;const t=Ys(s,e),n=t.length;if(n<3||n>4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return t}function Ou(s,e){const t=Ys(s,e);if(t.length!==2)throw new Error(`Expected an array of two numbers for ${e}`);return t}function Nm(s,e){return typeof s=="number"?s:Ou(s,e)}const Qh={RENDER_ORDER:"renderOrder"};class Hi extends zs{constructor(e){e=e||{};const t=Object.assign({},e);delete t.style,delete t.renderBuffer,delete t.updateWhileAnimating,delete t.updateWhileInteracting,super(t),this.declutter_=e.declutter?String(e.declutter):void 0,this.renderBuffer_=e.renderBuffer!==void 0?e.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(e.style),this.updateWhileAnimating_=e.updateWhileAnimating!==void 0?e.updateWhileAnimating:!1,this.updateWhileInteracting_=e.updateWhileInteracting!==void 0?e.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(e){return super.getFeatures(e)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Qh.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(e,t){const n=this.getDeclutter();n in e.declutter||(e.declutter[n]=new Al(9)),this.getRenderer().renderDeclutter(e,t)}setRenderOrder(e){this.set(Qh.RENDER_ORDER,e)}setStyle(e){this.style_=e===void 0?Fu:e;const t=Gm(e);this.styleFunction_=e===null?void 0:Tm(t),this.changed()}setDeclutter(e){this.declutter_=e?String(e):void 0,this.changed()}}function Gm(s){if(s===void 0)return Fu;if(!s)return null;if(typeof s=="function"||s instanceof Ne)return s;if(!Array.isArray(s))return Kh([s]);if(s.length===0)return[];const e=s.length,t=s[0];if(t instanceof Ne){const i=new Array(e);for(let r=0;r<e;++r){const o=s[r];if(!(o instanceof Ne))throw new Error("Expected a list of style instances");i[r]=o}return i}if("style"in t){const i=new Array(e);for(let r=0;r<e;++r){const o=s[r];if(!("style"in o))throw new Error("Expected a list of rules with a style property");i[r]=o}return Sm(i)}return Kh(s)}class ms extends ut{constructor(e,t,n,i){super(e),this.inversePixelTransform=t,this.frameState=n,this.context=i}}class km extends bs{constructor(e){super(),this.map_=e}dispatchRenderEvent(e,t){$()}calculateMatrices2D(e){const t=e.viewState,n=e.coordinateToPixelTransform,i=e.pixelToCoordinateTransform;ct(n,e.size[0]/2,e.size[1]/2,1/t.resolution,-1/t.resolution,-t.rotation,-t.center[0],-t.center[1]),Rs(i,n)}forEachFeatureAtCoordinate(e,t,n,i,r,o,a,l){let h;const c=t.viewState;function u(x,T,R,S){return r.call(o,T,x?R:null,S)}const d=c.projection,f=il(e.slice(),d),g=[[0,0]];if(d.canWrapX()&&i){const x=d.getExtent(),T=ie(x);g.push([-T,0],[T,0])}const m=t.layerStatesArray,_=m.length,p=[],y=[];for(let x=0;x<g.length;x++)for(let T=_-1;T>=0;--T){const R=m[T],S=R.layer;if(S.hasRenderer()&&Il(R,c)&&a.call(l,S)){const v=S.getRenderer(),w=S.getSource();if(v&&w){const I=w.getWrapX()?f:e,F=u.bind(null,R.managed);y[0]=I[0]+g[x][0],y[1]=I[1]+g[x][1],h=v.forEachFeatureAtCoordinate(y,t,n,F,p)}if(h)return h}}if(p.length===0)return;const E=1/p.length;return p.forEach((x,T)=>x.distanceSq+=T*E),p.sort((x,T)=>x.distanceSq-T.distanceSq),p.some(x=>h=x.callback(x.feature,x.layer,x.geometry)),h}hasFeatureAtCoordinate(e,t,n,i,r,o){return this.forEachFeatureAtCoordinate(e,t,n,i,Pn,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(e){$()}scheduleExpireIconCache(e){xt.canExpireCache()&&e.postRenderFunctions.push(Um)}}function Um(s,e){xt.expire()}class Bm extends km{constructor(e){super(e),this.fontChangeListenerKey_=J(Ri,Ni.PROPERTYCHANGE,e.redrawText,e),this.element_=at?mu():document.createElement("div");const t=this.element_.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="0",this.element_.className=Bs+" ol-layers";const n=e.getViewport();n&&n.insertBefore(this.element_,n.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(e,t){const n=this.getMap();if(n.hasListener(e)){const i=new ms(e,void 0,t);n.dispatchEvent(i)}}disposeInternal(){ue(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(e){if(!e){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(e),this.dispatchRenderEvent(Me.PRECOMPOSE,e);const t=e.layerStatesArray.sort((h,c)=>h.zIndex-c.zIndex);t.some(h=>h.layer instanceof Hi&&h.layer.getDeclutter())&&(e.declutter={});const i=e.viewState;this.children_.length=0;const r=[];let o=null;for(let h=0,c=t.length;h<c;++h){const u=t[h];e.layerIndex=h;const d=u.layer,f=d.getSourceState();if(!Il(u,i)||f!="ready"&&f!="undefined"){d.unrender();continue}const g=d.render(e,o);g&&(g!==o&&(this.children_.push(g),o=g),r.push(u))}this.declutter(e,r),Jg(this.element_,this.children_);const l=this.getMap().getTargetElement();if(En(l)){const h=l.getContext("2d");for(const c of this.children_){const u=c.firstElementChild||c,d=c.style.backgroundColor;if(d&&(!En(u)||u.width>0)&&(h.fillStyle=d,h.fillRect(0,0,l.width,l.height)),En(u)&&u.width>0){const f=c.style.opacity||u.style.opacity;h.globalAlpha=f===""?1:Number(f);const g=u.style.transform;if(g)h.setTransform(...wa(g));else{const m=parseFloat(u.style.width)/u.width,_=parseFloat(u.style.height)/u.height;h.setTransform(m,0,0,_,0,0)}h.drawImage(u,0,0)}}h.globalAlpha=1,h.setTransform(1,0,0,1,0,0)}this.dispatchRenderEvent(Me.POSTCOMPOSE,e),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(e)}declutter(e,t){if(e.declutter){for(let n=t.length-1;n>=0;--n){const i=t[n],r=i.layer;r.getDeclutter()&&r.renderDeclutter(e,i)}t.forEach(n=>n.layer.renderDeferred(e))}}}function Nu(s){if(s instanceof zs){s.setMapInternal(null);return}s instanceof Zi&&s.getLayers().forEach(Nu)}function Gu(s,e){if(s instanceof zs){s.setMapInternal(e);return}if(s instanceof Zi){const t=s.getLayers().getArray();for(let n=0,i=t.length;n<i;++n)Gu(t[n],e)}}let M0=class extends Rt{constructor(e){super(),e=e||{},this.on,this.once,this.un;const t=zm(e);this.renderComplete_=!1,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=e.maxTilesLoading!==void 0?e.maxTilesLoading:16,this.pixelRatio_=e.pixelRatio!==void 0?e.pixelRatio:mf,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=Ce(),this.pixelToCoordinateTransform_=Ce(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,at||(this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_)),this.mapBrowserEventHandler_=null,this.moveTolerance_=e.moveTolerance,this.keyboardEventTarget_=t.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,at||(this.resizeObserver_=new ResizeObserver(()=>this.updateSize())),this.controls=t.controls||(at?new Ze:n_()),this.interactions=t.interactions||(at?new Ze:C_({onFocusOnly:!0})),this.overlays_=t.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Ef(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Be.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(Be.VIEW,this.handleViewChanged_),this.addChangeListener(Be.SIZE,this.handleSizeChanged_),this.addChangeListener(Be.TARGET,this.handleTargetChanged_),this.setProperties(t.values);const n=this;e.view&&!(e.view instanceof Jt)&&e.view.then(function(i){n.setView(new Jt(i))}),this.controls.addEventListener(Se.ADD,i=>{i.element.setMap(this)}),this.controls.addEventListener(Se.REMOVE,i=>{i.element.setMap(null)}),this.interactions.addEventListener(Se.ADD,i=>{i.element.setMap(this)}),this.interactions.addEventListener(Se.REMOVE,i=>{i.element.setMap(null)}),this.overlays_.addEventListener(Se.ADD,i=>{this.addOverlayInternal_(i.element)}),this.overlays_.addEventListener(Se.REMOVE,i=>{const r=i.element.getId();r!==void 0&&delete this.overlayIdIndex_[r.toString()],i.element.setMap(null)}),this.controls.forEach(i=>{i.setMap(this)}),this.interactions.forEach(i=>{i.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(e){this.getControls().push(e)}addInteraction(e){this.getInteractions().push(e)}addLayer(e){this.getLayerGroup().getLayers().push(e)}handleLayerAdd_(e){Gu(e.layer,this)}addOverlay(e){this.getOverlays().push(e)}addOverlayInternal_(e){const t=e.getId();t!==void 0&&(this.overlayIdIndex_[t.toString()]=e),e.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_?.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(e,t,n){if(!this.frameState_||!this.renderer_)return;const i=this.getCoordinateFromPixelInternal(e);n=n!==void 0?n:{};const r=n.hitTolerance!==void 0?n.hitTolerance:0,o=n.layerFilter!==void 0?n.layerFilter:Pn,a=n.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(i,this.frameState_,r,a,t,null,o,null)}getFeaturesAtPixel(e,t){const n=[];return this.forEachFeatureAtPixel(e,function(i){n.push(i)},t),n}getAllLayers(){const e=[];function t(n){n.forEach(function(i){i instanceof Zi?t(i.getLayers()):e.push(i)})}return t(this.getLayers()),e}hasFeatureAtPixel(e,t){if(!this.frameState_||!this.renderer_)return!1;const n=this.getCoordinateFromPixelInternal(e);t=t!==void 0?t:{};const i=t.layerFilter!==void 0?t.layerFilter:Pn,r=t.hitTolerance!==void 0?t.hitTolerance:0,o=t.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(n,this.frameState_,r,o,i,null)}getEventCoordinate(e){return this.getCoordinateFromPixel(this.getEventPixel(e))}getEventCoordinateInternal(e){return this.getCoordinateFromPixelInternal(this.getEventPixel(e))}getEventPixel(e){const n=this.viewport_.getBoundingClientRect(),i=this.getSize(),r=n.width/i[0],o=n.height/i[1],a="changedTouches"in e?e.changedTouches[0]:e;return[(a.clientX-n.left)/r,(a.clientY-n.top)/o]}getTarget(){return this.get(Be.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(e){return Jn(this.getCoordinateFromPixelInternal(e),this.getView().getProjection())}getCoordinateFromPixelInternal(e){const t=this.frameState_;return t?fe(t.pixelToCoordinateTransform,e.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(e){const t=this.overlayIdIndex_[e.toString()];return t!==void 0?t:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(Be.LAYERGROUP)}setLayers(e){const t=this.getLayerGroup();if(e instanceof Ze){t.setLayers(e);return}const n=t.getLayers();n.clear(),n.extend(e)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const e=this.getLayerGroup().getLayerStatesArray();for(let t=0,n=e.length;t<n;++t){const i=e[t];if(!i.visible)continue;const r=i.layer.getRenderer();if(r&&!r.ready)return!0;const o=i.layer.getSource();if(o&&o.loading)return!0}return!1}getPixelFromCoordinate(e){const t=pe(e,this.getView().getProjection());return this.getPixelFromCoordinateInternal(t)}getPixelFromCoordinateInternal(e){const t=this.frameState_;return t?fe(t.coordinateToPixelTransform,e.slice(0,2)):null}getRenderer(){return this.renderer_}getSize(){return this.get(Be.SIZE)}getView(){return this.get(Be.VIEW)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){const e=this.getTargetElement();return e?e.ownerDocument:document}getTilePriority(e,t,n,i){return Tf(this.frameState_,e,t,n,i)}handleBrowserEvent(e,t){t=t||e.type;const n=new Zt(t,this,e);this.handleMapBrowserEvent(n)}handleMapBrowserEvent(e){if(!this.frameState_)return;const t=e.originalEvent,n=t.type;if(n===pa.POINTERDOWN||n===V.WHEEL||n===V.KEYDOWN){const i=this.getOwnerDocument(),r=this.viewport_.getRootNode?this.viewport_.getRootNode():i,o=t.target,a=r instanceof ShadowRoot?r.host===o?r.host.ownerDocument:r:r===i?i.documentElement:r;if(this.overlayContainerStopEvent_.contains(o)||!a.contains(o))return}if(e.frameState=this.frameState_,this.dispatchEvent(e)!==!1){const i=this.getInteractions().getArray().slice();for(let r=i.length-1;r>=0;r--){const o=i[r];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(e)||e.propagationStopped)break}}}handlePostRender(){const e=this.frameState_,t=this.tileQueue_;if(!t.isEmpty()){let i=this.maxTilesLoading_,r=i;if(e){const o=e.viewHints;if(o[he.ANIMATING]||o[he.INTERACTING]){const a=Date.now()-e.time>8;i=a?0:8,r=a?0:2}}t.getTilesLoading()<i&&(t.reprioritize(),t.loadMoreTiles(i,r))}e&&this.renderer_&&!e.animate&&(this.renderComplete_?(this.hasListener(Me.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(Me.RENDERCOMPLETE,e),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new Ti(Kt.LOADEND,this,e)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new Ti(Kt.LOADSTART,this,e))));const n=this.postRenderFunctions_;if(e)for(let i=0,r=n.length;i<r;++i)n[i](this,e);n.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let n=0,i=this.targetChangeHandlerKeys_.length;n<i;++n)ue(this.targetChangeHandlerKeys_[n]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(V.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(V.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_&&!En(this.targetElement_)){this.resizeObserver_?.unobserve(this.targetElement_);const n=this.targetElement_.getRootNode();n instanceof ShadowRoot&&this.resizeObserver_.unobserve(n.host),this.setSize(void 0)}const e=this.getTarget(),t=typeof e=="string"?document.getElementById(e):e;if(this.targetElement_=t,!t)this.renderer_&&(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),this.renderer_=null),this.animationDelayKey_&&(cancelAnimationFrame(this.animationDelayKey_),this.animationDelayKey_=void 0);else{if(En(t)||t.appendChild(this.viewport_),this.renderer_||(this.renderer_=new Bm(this)),!En(t)){this.mapBrowserEventHandler_=new yf(this,this.moveTolerance_);for(const i in ee)this.mapBrowserEventHandler_.addEventListener(ee[i],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(V.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(V.WHEEL,this.boundHandleBrowserEvent_,kc?{passive:!1}:!1);let n;if(this.keyboardEventTarget_)n=this.keyboardEventTarget_;else{const i=t.getRootNode();n=i instanceof ShadowRoot?i.host:t}if(this.targetChangeHandlerKeys_=[J(n,V.KEYDOWN,this.handleBrowserEvent,this),J(n,V.KEYPRESS,this.handleBrowserEvent,this)],t instanceof HTMLElement){const i=t.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.observe(i.host),this.resizeObserver_?.observe(t)}}this.updateSize()}}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&(ue(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(ue(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);const e=this.getView();e&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=J(e,Ni.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=J(e,V.CHANGE,this.handleViewPropertyChanged_,this),e.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(ue),this.layerGroupPropertyListenerKeys_=null);const e=this.getLayerGroup();e&&(this.handleLayerAdd_(new mn("addlayer",e)),this.layerGroupPropertyListenerKeys_=[J(e,Ni.PROPERTYCHANGE,this.render,this),J(e,V.CHANGE,this.render,this),J(e,"addlayer",this.handleLayerAdd_,this),J(e,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){if(!this.frameState_)return;const e=this.frameState_.layerStatesArray;for(let t=0,n=e.length;t<n;++t){const i=e[t].layer;i.hasRenderer()&&i.getRenderer().handleFontsChanged()}}render(){this.renderer_&&this.animationDelayKey_===void 0&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}removeControl(e){return this.getControls().remove(e)}removeInteraction(e){return this.getInteractions().remove(e)}removeLayer(e){return this.getLayerGroup().getLayers().remove(e)}handleLayerRemove_(e){Nu(e.layer)}removeOverlay(e){return this.getOverlays().remove(e)}renderFrame_(e){const t=this.getSize(),n=this.getView(),i=this.frameState_;let r=null;if(t!==void 0&&zh(t)&&n&&n.isDef()){const o=n.getHints(this.frameState_?this.frameState_.viewHints:void 0),a=n.getState();if(r={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:Ta(a.center,a.resolution,a.rotation,t),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:t,tileQueue:this.tileQueue_,time:e,usedTiles:{},viewState:a,viewHints:o,wantedTiles:{},mapId:D(this),renderTargets:{}},a.nextCenter&&a.nextResolution){const l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;r.nextExtent=Ta(a.nextCenter,a.nextResolution,l,t)}}this.frameState_=r,this.renderer_.renderFrame(r),r&&(r.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,r.postRenderFunctions),i&&(!this.previousExtent_||!ni(this.previousExtent_)&&!Hn(r.extent,this.previousExtent_))&&(this.dispatchEvent(new Ti(Kt.MOVESTART,this,i)),this.previousExtent_=ji(this.previousExtent_)),this.previousExtent_&&!r.viewHints[he.ANIMATING]&&!r.viewHints[he.INTERACTING]&&!Hn(r.extent,this.previousExtent_)&&(this.dispatchEvent(new Ti(Kt.MOVEEND,this,r)),Uc(r.extent,this.previousExtent_))),this.dispatchEvent(new Ti(Kt.POSTRENDER,this,r)),this.renderComplete_=(this.hasListener(Kt.LOADSTART)||this.hasListener(Kt.LOADEND)||this.hasListener(Me.RENDERCOMPLETE))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(e){const t=this.getLayerGroup();t&&this.handleLayerRemove_(new mn("removelayer",t)),this.set(Be.LAYERGROUP,e)}setSize(e){this.set(Be.SIZE,e)}setTarget(e){this.set(Be.TARGET,e)}setView(e){if(!e||e instanceof Jt){this.set(Be.VIEW,e);return}this.set(Be.VIEW,new Jt);const t=this;e.then(function(n){t.setView(new Jt(n))})}updateSize(){const e=this.getTargetElement();let t;if(e){let i,r;if(En(e))i=e.width,r=e.height;else{const o=getComputedStyle(e);i=e.offsetWidth-parseFloat(o.borderLeftWidth)-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight)-parseFloat(o.borderRightWidth),r=e.offsetHeight-parseFloat(o.borderTopWidth)-parseFloat(o.paddingTop)-parseFloat(o.paddingBottom)-parseFloat(o.borderBottomWidth)}!isNaN(i)&&!isNaN(r)&&(t=[Math.max(0,i),Math.max(0,r)],!zh(t)&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length)&&Vc("No map visible because the map container's width or height are 0."))}const n=this.getSize();t&&(!n||!Bt(t,n))&&(this.setSize(t),this.updateViewportSize_(t))}updateViewportSize_(e){const t=this.getView();t&&t.setViewportSize(e)}};function zm(s){let e=null;s.keyboardEventTarget!==void 0&&(e=typeof s.keyboardEventTarget=="string"?document.getElementById(s.keyboardEventTarget):s.keyboardEventTarget);const t={},n=s.layers&&typeof s.layers.getLayers=="function"?s.layers:new Zi({layers:s.layers});t[Be.LAYERGROUP]=n,t[Be.TARGET]=s.target,t[Be.VIEW]=s.view instanceof Jt?s.view:new Jt;let i;s.controls!==void 0&&(Array.isArray(s.controls)?i=new Ze(s.controls.slice()):(te(typeof s.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),i=s.controls));let r;s.interactions!==void 0&&(Array.isArray(s.interactions)?r=new Ze(s.interactions.slice()):(te(typeof s.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),r=s.interactions));let o;return s.overlays!==void 0?Array.isArray(s.overlays)?o=new Ze(s.overlays.slice()):(te(typeof s.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=s.overlays):o=new Ze,{controls:i,interactions:r,keyboardEventTarget:e,overlays:o,values:t}}const Ue={ELEMENT:"element",MAP:"map",OFFSET:"offset",POSITION:"position",POSITIONING:"positioning"};class D0 extends Rt{constructor(e){super(),this.on,this.once,this.un,this.options=e,this.id=e.id,this.insertFirst=e.insertFirst!==void 0?e.insertFirst:!0,this.stopEvent=e.stopEvent!==void 0?e.stopEvent:!0,this.element=document.createElement("div"),this.element.className=e.className!==void 0?e.className:"ol-overlay-container "+Zg,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=e.autoPan===!0?{}:e.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(Ue.ELEMENT,this.handleElementChanged),this.addChangeListener(Ue.MAP,this.handleMapChanged),this.addChangeListener(Ue.OFFSET,this.handleOffsetChanged),this.addChangeListener(Ue.POSITION,this.handlePositionChanged),this.addChangeListener(Ue.POSITIONING,this.handlePositioningChanged),e.element!==void 0&&this.setElement(e.element),this.setOffset(e.offset!==void 0?e.offset:[0,0]),this.setPositioning(e.positioning||"top-left"),e.position!==void 0&&this.setPosition(e.position)}getElement(){return this.get(Ue.ELEMENT)}getId(){return this.id}getMap(){return this.get(Ue.MAP)||null}getOffset(){return this.get(Ue.OFFSET)}getPosition(){return this.get(Ue.POSITION)}getPositioning(){return this.get(Ue.POSITIONING)}handleElementChanged(){_u(this.element);const e=this.getElement();e&&this.element.appendChild(e)}handleMapChanged(){this.mapPostrenderListenerKey&&(this.element?.remove(),ue(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const e=this.getMap();if(e){this.mapPostrenderListenerKey=J(e,Kt.POSTRENDER,this.render,this),this.updatePixelPosition();const t=this.stopEvent?e.getOverlayContainerStopEvent():e.getOverlayContainer();this.insertFirst?t.insertBefore(this.element,t.childNodes[0]||null):t.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(e){this.set(Ue.ELEMENT,e)}setMap(e){this.set(Ue.MAP,e)}setOffset(e){this.set(Ue.OFFSET,e)}setPosition(e){this.set(Ue.POSITION,e)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(e){const t=this.getMap();if(!t||!t.getTargetElement()||!this.get(Ue.POSITION))return;const n=this.getRect(t.getTargetElement(),t.getSize()),i=this.getElement(),r=this.getRect(i,[Hg(i),qg(i)]);e=e||{};const o=e.margin===void 0?20:e.margin;if(!yn(n,r)){const a=r[0]-n[0],l=n[2]-r[2],h=r[1]-n[1],c=n[3]-r[3],u=[0,0];if(a<0?u[0]=a-o:l<0&&(u[0]=Math.abs(l)+o),h<0?u[1]=h-o:c<0&&(u[1]=Math.abs(c)+o),u[0]!==0||u[1]!==0){const d=t.getView().getCenterInternal(),f=t.getPixelFromCoordinateInternal(d);if(!f)return;const g=[f[0]+u[0],f[1]+u[1]],m=e.animation||{};t.getView().animateInternal({center:t.getCoordinateFromPixelInternal(g),duration:m.duration,easing:m.easing})}}}getRect(e,t){const n=e.getBoundingClientRect(),i=n.left+window.pageXOffset,r=n.top+window.pageYOffset;return[i,r,i+t[0],r+t[1]]}setPositioning(e){this.set(Ue.POSITIONING,e)}setVisible(e){this.rendered.visible!==e&&(this.element.style.display=e?"":"none",this.rendered.visible=e)}updatePixelPosition(){const e=this.getMap(),t=this.getPosition();if(!e||!e.isRendered()||!t){this.setVisible(!1);return}const n=e.getPixelFromCoordinate(t),i=e.getSize();this.updateRenderedPosition(n,i)}updateRenderedPosition(e,t){const n=this.element.style,i=this.getOffset(),r=this.getPositioning();this.setVisible(!0);const o=`${e[0]+i[0]}px`,a=`${e[1]+i[1]}px`;let l="0%",h="0%";r=="bottom-right"||r=="center-right"||r=="top-right"?l="-100%":(r=="bottom-center"||r=="center-center"||r=="top-center")&&(l="-50%"),r=="bottom-left"||r=="bottom-center"||r=="bottom-right"?h="-100%":(r=="center-left"||r=="center-center"||r=="center-right")&&(h="-50%");const c=`translate(${l}, ${h}) translate(${o}, ${a})`;this.rendered.transform_!=c&&(this.rendered.transform_=c,n.transform=c)}getOptions(){return this.options}}class kl extends Ds{constructor(e,t,n){super(),n=n||{},this.tileCoord=e,this.state=t,this.key="",this.transition_=n.transition===void 0?250:n.transition,this.transitionStarts_={},this.interpolate=!!n.interpolate}changed(){this.dispatchEvent(V.CHANGE)}release(){this.setState(B.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(e){if(this.state!==B.EMPTY){if(this.state!==B.ERROR&&this.state>e)throw new Error("Tile load sequence violation");this.state=e,this.changed()}}load(){$()}getAlpha(e,t){if(!this.transition_)return 1;let n=this.transitionStarts_[e];if(!n)n=t,this.transitionStarts_[e]=n;else if(n===-1)return 1;const i=t-n+1e3/60;return i>=this.transition_?1:Wc(i/this.transition_)}inTransition(e){return this.transition_?this.transitionStarts_[e]!==-1:!1}endTransition(e){this.transition_&&(this.transitionStarts_[e]=-1)}disposeInternal(){this.release(),super.disposeInternal()}}function Na(s){return s instanceof Image||s instanceof HTMLCanvasElement||s instanceof HTMLVideoElement||s instanceof ImageBitmap?s:null}const $m=new Error("disposed"),Xm=[256,256];class ec extends kl{constructor(e){const t=B.IDLE;super(e.tileCoord,t,{transition:e.transition,interpolate:e.interpolate}),this.loader_=e.loader,this.data_=null,this.error_=null,this.size_=e.size||null,this.controller_=e.controller||null}getSize(){if(this.size_)return this.size_;const e=Na(this.data_);return e?[e.width,e.height]:Xm}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==B.IDLE&&this.state!==B.ERROR)return;this.state=B.LOADING,this.changed();const e=this;this.loader_().then(function(t){e.data_=t,e.state=B.LOADED,e.changed()}).catch(function(t){e.error_=t,e.state=B.ERROR,e.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort($m),this.controller_=null),super.disposeInternal()}}class ku extends kl{constructor(e,t,n,i,r,o){super(e,t,o),this.crossOrigin_=i,this.src_=n,this.key=n,this.image_,at?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,i!==null&&(this.image_.crossOrigin=i)),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(e){this.image_=e,this.state=B.LOADED,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}handleImageError_(){this.state=B.ERROR,this.unlistenImage_(),this.image_=Ym(),this.changed()}handleImageLoad_(){if(at)this.state=B.LOADED;else{const e=this.image_;e.naturalWidth&&e.naturalHeight?this.state=B.LOADED:this.state=B.EMPTY}this.unlistenImage_(),this.changed()}load(){this.state==B.ERROR&&(this.state=B.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==B.IDLE&&(this.state=B.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=hm(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}}function Ym(){const s=we(1,1);return s.fillStyle="rgba(0,0,0,0)",s.fillRect(0,0,1,1),s.canvas}class Ul{constructor(e,t,n,i){this.minX=e,this.maxX=t,this.minY=n,this.maxY=i}contains(e){return this.containsXY(e[1],e[2])}containsTileRange(e){return this.minX<=e.minX&&e.maxX<=this.maxX&&this.minY<=e.minY&&e.maxY<=this.maxY}containsXY(e,t){return this.minX<=e&&e<=this.maxX&&this.minY<=t&&t<=this.maxY}equals(e){return this.minX==e.minX&&this.minY==e.minY&&this.maxX==e.maxX&&this.maxY==e.maxY}extend(e){e.minX<this.minX&&(this.minX=e.minX),e.maxX>this.maxX&&(this.maxX=e.maxX),e.minY<this.minY&&(this.minY=e.minY),e.maxY>this.maxY&&(this.maxY=e.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(e){return this.minX<=e.maxX&&this.maxX>=e.minX&&this.minY<=e.maxY&&this.maxY>=e.minY}}function _i(s,e,t,n,i){return i!==void 0?(i.minX=s,i.maxX=e,i.minY=t,i.maxY=n,i):new Ul(s,e,t,n)}let Zo;const Mi=[];function tc(s,e,t,n,i){s.beginPath(),s.moveTo(0,0),s.lineTo(e,t),s.lineTo(n,i),s.closePath(),s.save(),s.clip(),s.fillRect(0,0,Math.max(e,n)+1,Math.max(t,i)),s.restore()}function Ko(s,e){return Math.abs(s[e*4]-210)>2||Math.abs(s[e*4+3]-.75*255)>2}function jm(){if(Zo===void 0){const s=we(6,6,Mi);s.globalCompositeOperation="lighter",s.fillStyle="rgba(210, 0, 0, 0.75)",tc(s,4,5,4,0),tc(s,4,5,0,5);const e=s.getImageData(0,0,3,3).data;Zo=Ko(e,0)||Ko(e,4)||Ko(e,8),ho(s),Mi.push(s.canvas)}return Zo}function Ga(s,e,t,n){const i=ks(t,e,s);let r=Fr(e,n,t);const o=e.getMetersPerUnit();o!==void 0&&(r*=o);const a=s.getMetersPerUnit();a!==void 0&&(r/=a);const l=s.getExtent();if(!l||Kn(l,i)){const h=Fr(s,r,i)/r;isFinite(h)&&h>0&&(r/=h)}return r}function Wm(s,e,t,n){const i=In(t);let r=Ga(s,e,i,n);return(!isFinite(r)||r<=0)&&el(t,function(o){return r=Ga(s,e,o,n),isFinite(r)&&r>0}),r}function Vm(s,e,t,n,i,r,o,a,l,h,c,u,d,f){const g=we(Math.round(t*s),Math.round(t*e),Mi);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(t,t);function m(T){return Math.round(T*t)/t}g.globalCompositeOperation="lighter";const _=tt();l.forEach(function(T,R,S){Bc(_,T.extent)});let p;const y=t/n,E=(u?1:1+Math.pow(2,-24))/y;p=we(Math.round(ie(_)*y),Math.round(be(_)*y),Mi),u||(p.imageSmoothingEnabled=!1),l.forEach(function(T,R,S){if(T.image.width>0&&T.image.height>0){if(T.clipExtent){p.save();const A=(T.clipExtent[0]-_[0])*y,M=-(T.clipExtent[3]-_[3])*y,b=ie(T.clipExtent)*y,K=be(T.clipExtent)*y;p.rect(u?A:Math.round(A),u?M:Math.round(M),u?b:Math.round(A+b)-Math.round(A),u?K:Math.round(M+K)-Math.round(M)),p.clip()}const v=(T.extent[0]-_[0])*y,w=-(T.extent[3]-_[3])*y,I=ie(T.extent)*y,F=be(T.extent)*y;p.drawImage(T.image,h,h,T.image.width-2*h,T.image.height-2*h,u?v:Math.round(v),u?w:Math.round(w),u?I:Math.round(v+I)-Math.round(v),u?F:Math.round(w+F)-Math.round(w)),T.clipExtent&&p.restore()}});const x=Fn(o);return a.getTriangles().forEach(function(T,R,S){const v=T.source,w=T.target;let I=v[0][0],F=v[0][1],A=v[1][0],M=v[1][1],b=v[2][0],K=v[2][1];const L=m((w[0][0]-x[0])/r),Z=m(-(w[0][1]-x[1])/r),G=m((w[1][0]-x[0])/r),H=m(-(w[1][1]-x[1])/r),Q=m((w[2][0]-x[0])/r),le=m(-(w[2][1]-x[1])/r),P=I,Ge=F;I=0,F=0,A-=P,M-=Ge,b-=P,K-=Ge;const je=[[A,M,0,0,G-L],[b,K,0,0,Q-L],[0,0,A,M,H-Z],[0,0,b,K,le-Z]],Ee=Rf(je);if(!Ee)return;if(g.save(),g.beginPath(),jm()||!u){g.moveTo(G,H);const ke=4,Lt=L-G,St=Z-H;for(let st=0;st<ke;st++)g.lineTo(G+m((st+1)*Lt/ke),H+m(st*St/(ke-1))),st!=ke-1&&g.lineTo(G+m((st+1)*Lt/ke),H+m((st+1)*St/(ke-1)));g.lineTo(Q,le)}else g.moveTo(G,H),g.lineTo(L,Z),g.lineTo(Q,le);g.clip(),g.transform(Ee[0],Ee[2],Ee[1],Ee[3],L,Z),g.translate(_[0]-P,_[3]-Ge);let it;if(p)it=p.canvas,g.scale(E,-E);else{const ke=l[0],Lt=ke.extent;it=ke.image,g.scale(ie(Lt)/it.width,-be(Lt)/it.height)}g.drawImage(it,0,0),g.restore()}),p&&(ho(p),Mi.push(p.canvas)),c&&(g.save(),g.globalCompositeOperation="source-over",g.strokeStyle="black",g.lineWidth=1,a.getTriangles().forEach(function(T,R,S){const v=T.target,w=(v[0][0]-x[0])/r,I=-(v[0][1]-x[1])/r,F=(v[1][0]-x[0])/r,A=-(v[1][1]-x[1])/r,M=(v[2][0]-x[0])/r,b=-(v[2][1]-x[1])/r;g.beginPath(),g.moveTo(F,A),g.lineTo(w,I),g.lineTo(M,b),g.closePath(),g.stroke()}),g.restore()),g.canvas}const Zm=10,nc=.25;class Km{constructor(e,t,n,i,r,o,a){this.sourceProj_=e,this.targetProj_=t;let l={};const h=a?gg(E=>fe(a,ks(E,this.targetProj_,this.sourceProj_))):qn(this.targetProj_,this.sourceProj_);this.transformInv_=function(E){const x=E[0]+"/"+E[1];return l[x]||(l[x]=h(E)),l[x]},this.maxSourceExtent_=i,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!i&&!!this.sourceProj_.getExtent()&&ie(i)>=ie(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?ie(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?ie(this.targetProj_.getExtent()):null;const c=Fn(n),u=eo(n),d=Qr(n),f=Jr(n),g=this.transformInv_(c),m=this.transformInv_(u),_=this.transformInv_(d),p=this.transformInv_(f),y=Zm+(o?Math.max(0,Math.ceil(Math.log2(Ea(n)/(o*o*256*256)))):0);if(this.addQuad_(c,u,d,f,g,m,_,p,y),this.wrapsXInSource_){let E=1/0;this.triangles_.forEach(function(x,T,R){E=Math.min(E,x.source[0][0],x.source[1][0],x.source[2][0])}),this.triangles_.forEach(x=>{if(Math.max(x.source[0][0],x.source[1][0],x.source[2][0])-E>this.sourceWorldWidth_/2){const T=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];T[0][0]-E>this.sourceWorldWidth_/2&&(T[0][0]-=this.sourceWorldWidth_),T[1][0]-E>this.sourceWorldWidth_/2&&(T[1][0]-=this.sourceWorldWidth_),T[2][0]-E>this.sourceWorldWidth_/2&&(T[2][0]-=this.sourceWorldWidth_);const R=Math.min(T[0][0],T[1][0],T[2][0]);Math.max(T[0][0],T[1][0],T[2][0])-R<this.sourceWorldWidth_/2&&(x.source=T)}})}l={}}addTriangle_(e,t,n,i,r,o){this.triangles_.push({source:[i,r,o],target:[e,t,n]})}addQuad_(e,t,n,i,r,o,a,l,h){const c=ze([r,o,a,l]),u=this.sourceWorldWidth_?ie(c)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,f=this.sourceProj_.canWrapX()&&u>.5&&u<1;let g=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const _=ze([e,t,n,i]);g=ie(_)/this.targetWorldWidth_>nc||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>nc||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!Te(c,this.maxSourceExtent_))return;let m=0;if(!g&&(!isFinite(r[0])||!isFinite(r[1])||!isFinite(o[0])||!isFinite(o[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(l[0])||!isFinite(l[1]))){if(h>0)g=!0;else if(m=(!isFinite(r[0])||!isFinite(r[1])?8:0)+(!isFinite(o[0])||!isFinite(o[1])?4:0)+(!isFinite(a[0])||!isFinite(a[1])?2:0)+(!isFinite(l[0])||!isFinite(l[1])?1:0),m!=1&&m!=2&&m!=4&&m!=8)return}if(h>0){if(!g){const _=[(e[0]+n[0])/2,(e[1]+n[1])/2],p=this.transformInv_(_);let y;f?y=(en(r[0],d)+en(a[0],d))/2-en(p[0],d):y=(r[0]+a[0])/2-p[0];const E=(r[1]+a[1])/2-p[1];g=y*y+E*E>this.errorThresholdSquared_}if(g){if(Math.abs(e[0]-n[0])<=Math.abs(e[1]-n[1])){const _=[(t[0]+n[0])/2,(t[1]+n[1])/2],p=this.transformInv_(_),y=[(i[0]+e[0])/2,(i[1]+e[1])/2],E=this.transformInv_(y);this.addQuad_(e,t,_,y,r,o,p,E,h-1),this.addQuad_(y,_,n,i,E,p,a,l,h-1)}else{const _=[(e[0]+t[0])/2,(e[1]+t[1])/2],p=this.transformInv_(_),y=[(n[0]+i[0])/2,(n[1]+i[1])/2],E=this.transformInv_(y);this.addQuad_(e,_,y,i,r,p,E,l,h-1),this.addQuad_(_,t,n,y,p,o,a,E,h-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(m&11)==0&&this.addTriangle_(e,n,i,r,a,l),(m&14)==0&&this.addTriangle_(e,n,t,r,a,o),m&&((m&13)==0&&this.addTriangle_(t,i,e,o,l,r),(m&7)==0&&this.addTriangle_(t,i,n,o,l,a))}calculateSourceExtent(){const e=tt();return this.triangles_.forEach(function(t,n,i){const r=t.source;gs(e,r[0]),gs(e,r[1]),gs(e,r[2])}),e}getTriangles(){return this.triangles_}}const Hm=.5;class Uu extends kl{constructor(e,t,n,i,r,o,a,l,h,c,u,d){super(r,B.IDLE,d),this.renderEdges_=u!==void 0?u:!1,this.pixelRatio_=a,this.gutter_=l,this.canvas_=null,this.sourceTileGrid_=t,this.targetTileGrid_=i,this.wrappedTileCoord_=o||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=e.canWrapX()?e.getExtent():void 0;const f=i.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent();let m=this.sourceTileGrid_.getExtent();const _=g?tn(f,g):f;if(Ea(_)===0){this.state=B.EMPTY;return}const p=e.getExtent();p&&(m?m=tn(m,p):m=p);const y=i.getResolution(this.wrappedTileCoord_[0]),E=Wm(e,n,_,y);if(!isFinite(E)||E<=0){this.state=B.EMPTY;return}const x=c!==void 0?c:Hm;if(this.triangulation_=new Km(e,n,_,m,E*x,y),this.triangulation_.getTriangles().length===0){this.state=B.EMPTY;return}this.sourceZ_=t.getZForResolution(E);let T=this.triangulation_.calculateSourceExtent();if(m&&(e.canWrapX()?(T[1]=ge(T[1],m[1],m[3]),T[3]=ge(T[3],m[1],m[3])):T=tn(T,m)),!Ea(T))this.state=B.EMPTY;else{let R=0,S=0;e.canWrapX()&&(R=ie(p),S=Math.floor((T[0]-p[0])/R)),Yc(T.slice(),e,!0).forEach(w=>{const I=t.getTileRangeForExtentAndZ(w,this.sourceZ_);for(let F=I.minX;F<=I.maxX;F++)for(let A=I.minY;A<=I.maxY;A++){const M=h(this.sourceZ_,F,A,a);if(M){const b=S*R;this.sourceTiles_.push({tile:M,offset:b})}}++S}),this.sourceTiles_.length===0&&(this.state=B.EMPTY)}}getImage(){return this.canvas_}reproject_(){const e=[];if(this.sourceTiles_.forEach(t=>{const n=t.tile;if(n&&n.getState()==B.LOADED){const i=this.sourceTileGrid_.getTileCoordExtent(n.tileCoord);i[0]+=t.offset,i[2]+=t.offset;const r=this.clipExtent_?.slice();r&&(r[0]+=t.offset,r[2]+=t.offset),e.push({extent:i,clipExtent:r,image:n.getImage()})}}),this.sourceTiles_.length=0,e.length===0)this.state=B.ERROR;else{const t=this.wrappedTileCoord_[0],n=this.targetTileGrid_.getTileSize(t),i=typeof n=="number"?n:n[0],r=typeof n=="number"?n:n[1],o=this.targetTileGrid_.getResolution(t),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=Vm(i,r,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,e,this.gutter_,this.renderEdges_,this.interpolate),this.state=B.LOADED}this.changed()}load(){if(this.state==B.IDLE){this.state=B.LOADING,this.changed();let e=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:t})=>{const n=t.getState();if(n==B.IDLE||n==B.LOADING){e++;const i=J(t,V.CHANGE,r=>{const o=t.getState();(o==B.LOADED||o==B.ERROR||o==B.EMPTY)&&(ue(i),e--,e===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(i)}}),e===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:t},n,i){t.getState()==B.IDLE&&t.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(ue),this.sourcesListenerKeys_=null}release(){this.canvas_&&(ho(this.canvas_.getContext("2d")),Mi.push(this.canvas_),this.canvas_=null),super.release()}}class ic{constructor(e){this.highWaterMark=e!==void 0?e:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const e=this.pop();e instanceof bs&&e.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(e){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(e){return this.entries_.hasOwnProperty(e)}forEach(e){let t=this.oldest_;for(;t;)e(t.value_,t.key_,this),t=t.newer}get(e,t){const n=this.entries_[e];return te(n!==void 0,"Tried to get a value for a key that does not exist in the cache"),n===this.newest_||(n===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(n.newer.older=n.older,n.older.newer=n.newer),n.newer=null,n.older=this.newest_,this.newest_.newer=n,this.newest_=n),n.value_}remove(e){const t=this.entries_[e];return te(t!==void 0,"Tried to get a value for a key that does not exist in the cache"),t===this.newest_?(this.newest_=t.older,this.newest_&&(this.newest_.newer=null)):t===this.oldest_?(this.oldest_=t.newer,this.oldest_&&(this.oldest_.older=null)):(t.newer.older=t.older,t.older.newer=t.newer),delete this.entries_[e],--this.count_,t.value_}getCount(){return this.count_}getKeys(){const e=new Array(this.count_);let t=0,n;for(n=this.newest_;n;n=n.older)e[t++]=n.key_;return e}getValues(){const e=new Array(this.count_);let t=0,n;for(n=this.newest_;n;n=n.older)e[t++]=n.value_;return e}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(e){return this.entries_[e]?.value_}pop(){const e=this.oldest_;return delete this.entries_[e.key_],e.newer&&(e.newer.older=null),this.oldest_=e.newer,this.oldest_||(this.newest_=null),--this.count_,e.value_}replace(e,t){this.get(e),this.entries_[e].value_=t}set(e,t){te(!(e in this.entries_),"Tried to set a value for a key that is used already");const n={key_:e,newer:null,older:this.newest_,value_:t};this.newest_?this.newest_.newer=n:this.oldest_=n,this.newest_=n,this.entries_[e]=n,++this.count_}setSize(e){this.highWaterMark=e}}function zr(s,e,t,n){return n!==void 0?(n[0]=s,n[1]=e,n[2]=t,n):[s,e,t]}function qm(s,e,t){return s+"/"+e+"/"+t}function Cr(s,e,t,n,i){return`${D(s)},${e},${qm(t,n,i)}`}function Bu(s){return Jm(s[0],s[1],s[2])}function Jm(s,e,t){return(e<<s)+t}function Qm(s,e){const t=s[0],n=s[1],i=s[2];if(e.getMinZoom()>t||t>e.getMaxZoom())return!1;const r=e.getFullTileRange(t);return r?r.containsXY(n,i):!0}class Bl{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Dr(),{get:(e,t)=>{if(typeof Dr()[t]=="function")return this.push_(t),this.pushMethodArgs_},set:(e,t,n)=>(this.push_(t,n),!0)})}push_(...e){const t=this.instructions_,n=this.zIndex+this.offset_;t[n]||(t[n]=[]),t[n].push(...e)}pushMethodArgs_=(...e)=>(this.push_(e),this);pushFunction(e){this.push_(e)}getContext(){return this.context_}draw(e){this.instructions_.forEach(t=>{for(let n=0,i=t.length;n<i;++n){const r=t[n];if(typeof r=="function"){r(e);continue}const o=t[++n];if(typeof e[r]=="function")e[r](...o);else{if(typeof o=="function"){e[r]=o(e);continue}e[r]=o}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}}const ep=5;class zu extends Os{constructor(e){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=e,this.staleKeys_=new Array,this.maxStaleKeys=ep}getStaleKeys(){return this.staleKeys_}prependStaleKey(e){this.staleKeys_.unshift(e),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(e){return $()}getData(e){return null}prepareFrame(e){return $()}renderFrame(e,t){return $()}forEachFeatureAtCoordinate(e,t,n,i,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(e){const t=e.target;(t.getState()===U.LOADED||t.getState()===U.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let t=e.getState();return t!=U.LOADED&&t!=U.ERROR&&e.addEventListener(V.CHANGE,this.boundHandleImageChange_),t==U.IDLE&&(e.load(),t=e.getState()),t==U.LOADED}renderIfReadyAndVisible(){const e=this.getLayer();e&&e.getVisible()&&e.getSourceState()==="ready"&&e.changed()}renderDeferred(e){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const sc=[];let Si=null;function tp(){Si=we(1,1,void 0,{willReadFrequently:!0})}class zl extends zu{constructor(e){super(e),this.container=null,this.renderedResolution,this.tempTransform=Ce(),this.pixelTransform=Ce(),this.inversePixelTransform=Ce(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(e,t,n){Si||tp(),Si.clearRect(0,0,1,1);let i;try{Si.drawImage(e,t,n,1,1,0,0,1,1),i=Si.getImageData(0,0,1,1).data}catch{return Si=null,null}return i}getBackground(e){let n=this.getLayer().getBackground();return typeof n=="function"&&(n=n(e.viewState.resolution)),n||void 0}useContainer(e,t,n){const i=this.getLayer().getClassName();let r,o;if(e&&e.className===i&&(!n||e&&e.style.backgroundColor&&Bt(Ct(e.style.backgroundColor),Ct(n)))){const a=e.firstElementChild;En(a)&&(o=a.getContext("2d"))}if(o&&Cg(o.canvas.style.transform,t)?(this.container=e,this.context=o,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){r=at?mu():document.createElement("div"),r.className=i;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=we();const l=o.canvas;r.appendChild(l),a=l.style,a.position="absolute",a.left="0",a.transformOrigin="top left",this.container=r,this.context=o}!this.containerReused&&n&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=n)}clipUnrotated(e,t,n){const i=Fn(n),r=eo(n),o=Qr(n),a=Jr(n);fe(t.coordinateToPixelTransform,i),fe(t.coordinateToPixelTransform,r),fe(t.coordinateToPixelTransform,o),fe(t.coordinateToPixelTransform,a);const l=this.inversePixelTransform;fe(l,i),fe(l,r),fe(l,o),fe(l,a),e.save(),e.beginPath(),e.moveTo(Math.round(i[0]),Math.round(i[1])),e.lineTo(Math.round(r[0]),Math.round(r[1])),e.lineTo(Math.round(o[0]),Math.round(o[1])),e.lineTo(Math.round(a[0]),Math.round(a[1])),e.clip()}prepareContainer(e,t){const n=e.extent,i=e.viewState.resolution,r=e.viewState.rotation,o=e.pixelRatio,a=Math.round(ie(n)/i*o),l=Math.round(be(n)/i*o);ct(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/o,1/o,r,-a/2,-l/2),Rs(this.inversePixelTransform,this.pixelTransform);const h=Tg(this.pixelTransform);if(this.useContainer(t,h,this.getBackground(e)),!this.containerReused){const c=this.context.canvas;c.width!=a||c.height!=l?(c.width=a,c.height=l):this.context.clearRect(0,0,a,l),h!==c.style.transform&&(c.style.transform=h)}}dispatchRenderEvent_(e,t,n){const i=this.getLayer();if(i.hasListener(e)){const r=new ms(e,this.inversePixelTransform,n,t);i.dispatchEvent(r)}}preRender(e,t){this.frameState=t,!t.declutter&&this.dispatchRenderEvent_(Me.PRERENDER,e,t)}postRender(e,t){t.declutter||this.dispatchRenderEvent_(Me.POSTRENDER,e,t)}renderDeferredInternal(e){}getRenderContext(e){return e.declutter&&!this.deferredContext_&&(this.deferredContext_=new Bl),e.declutter?this.deferredContext_.getContext():this.context}renderDeferred(e){e.declutter&&(this.dispatchRenderEvent_(Me.PRERENDER,this.context,e),e.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(e),this.dispatchRenderEvent_(Me.POSTRENDER,this.context,e))}getRenderTransform(e,t,n,i,r,o,a){const l=r/2,h=o/2,c=i/t,u=-c,d=-e[0]+a,f=-e[1];return ct(this.tempTransform,l,h,c,u,-n,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}function Ho(s,e,t){if(!(t in s))return s[t]=new Set([e]),!0;const n=s[t],i=n.has(e);return i||n.add(e),!i}function np(s,e,t){const n=s[t];return n?n.delete(e):!1}function rc(s,e){const t=s.layerStatesArray[s.layerIndex];t.extent&&(e=tn(e,wt(t.extent,s.viewState.projection)));const n=t.layer.getRenderSource();if(!n.getWrapX()){const i=n.getTileGridForProjection(s.viewState.projection).getExtent();i&&(e=tn(e,i))}return e}class $u extends zl{constructor(e,t){super(e),t=t||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=tt(),this.tempTileRange_=new Ul(0,0,0,0),this.tempTileCoord_=zr(0,0,0);const n=t.cacheSize!==void 0?t.cacheSize:512;this.tileCache_=new ic(n),this.sourceTileCache_=null,this.maxStaleKeys=n*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new ic(512)),this.sourceTileCache_}getOrCreateTile(e,t,n,i){const r=this.tileCache_,a=this.getLayer().getSource(),l=Cr(a,a.getKey(),e,t,n);let h;if(r.containsKey(l))h=r.get(l);else{const c=i.viewState.projection,u=a.getProjection();if(h=a.getTile(e,t,n,i.pixelRatio,c,!u||Wn(u,c)?void 0:this.getSourceTileCache()),!h)return null;r.set(l,h)}return h}getTile(e,t,n,i){const r=this.getOrCreateTile(e,t,n,i);return r||null}getData(e){const t=this.frameState;if(!t)return null;const n=this.getLayer(),i=fe(t.pixelToCoordinateTransform,e.slice()),r=n.getExtent();if(r&&!Kn(r,i))return null;const o=t.viewState,a=n.getRenderSource(),l=a.getTileGridForProjection(o.projection),h=a.getTilePixelRatio(t.pixelRatio);for(let c=l.getZForResolution(o.resolution);c>=l.getMinZoom();--c){const u=l.getTileCoordForCoordAndZ(i,c),d=this.getTile(c,u[1],u[2],t);if(!d||d.getState()!==B.LOADED)continue;const f=l.getOrigin(c),g=Xe(l.getTileSize(c)),m=l.getResolution(c);let _;if(d instanceof ku||d instanceof Uu)_=d.getImage();else if(d instanceof ec){if(_=Na(d.getData()),!_)continue}else continue;const p=Math.floor(h*((i[0]-f[0])/m-u[1]*g[0])),y=Math.floor(h*((f[1]-i[1])/m-u[2]*g[1])),E=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(_,p+E,y+E)}return null}prepareFrame(e){this.renderedProjection?e.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=e.viewState.projection):this.renderedProjection=e.viewState.projection;const t=this.getLayer().getSource();if(!t)return!1;const n=t.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==n&&(this.renderedSourceRevision_=n,this.renderedSourceKey_===t.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=n,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(e,t,n,i,r){const o=e.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),c=D(l);c in e.wantedTiles||(e.wantedTiles[c]={});const u=e.wantedTiles[c],d=a.getMapInternal(),f=Math.max(n-r,h.getMinZoom(),h.getZForResolution(Math.min(a.getMaxResolution(),d?d.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):h.getResolution(0)),l.zDirection)),g=o.rotation,m=g?$c(o.center,o.resolution,g,e.size):void 0;for(let _=n;_>=f;--_){const p=h.getTileRangeForExtentAndZ(t,_,this.tempTileRange_),y=h.getResolution(_);for(let E=p.minX;E<=p.maxX;++E)for(let x=p.minY;x<=p.maxY;++x){if(g&&!h.tileCoordIntersectsViewport([_,E,x],m))continue;const T=this.getTile(_,E,x,e);if(!T||!Ho(i,T,_))continue;const S=T.getKey();if(u[S]=!0,T.getState()===B.IDLE&&!e.tileQueue.isKeyQueued(S)){const v=zr(_,E,x,this.tempTileCoord_);e.tileQueue.enqueue([T,c,h.getTileCoordCenter(v),y])}}}}findStaleTile_(e,t){const n=this.tileCache_,i=e[0],r=e[1],o=e[2],a=this.getStaleKeys();for(let l=0;l<a.length;++l){const h=Cr(this.getLayer().getSource(),a[l],i,r,o);if(n.containsKey(h)){const c=n.peek(h);if(c.getState()===B.LOADED)return c.endTransition(D(this)),Ho(t,c,i),!0}}return!1}findAltTiles_(e,t,n,i){const r=e.getTileRangeForTileCoordAndZ(t,n,this.tempTileRange_);if(!r)return!1;let o=!0;const a=this.tileCache_,l=this.getLayer().getRenderSource(),h=l.getKey();for(let c=r.minX;c<=r.maxX;++c)for(let u=r.minY;u<=r.maxY;++u){const d=Cr(l,h,n,c,u);let f=!1;if(a.containsKey(d)){const g=a.peek(d);g.getState()===B.LOADED&&(Ho(i,g,n),f=!0)}f||(o=!1)}return o}renderFrame(e,t){this.renderComplete=!0;const n=e.layerStatesArray[e.layerIndex],i=e.viewState,r=i.projection,o=i.resolution,a=i.center,l=e.pixelRatio,h=this.getLayer(),c=h.getSource(),u=c.getTileGridForProjection(r),d=u.getZForResolution(o,c.zDirection),f=u.getResolution(d),g=c.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==g&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=g):this.renderedSourceKey_=g;let m=e.extent;const _=c.getTilePixelRatio(l);this.prepareContainer(e,t);const p=this.context.canvas.width,y=this.context.canvas.height,E=n.extent&&wt(n.extent);E&&(m=tn(m,wt(n.extent)));const x=f*p/2/_,T=f*y/2/_,R=[a[0]-x,a[1]-T,a[0]+x,a[1]+T],S={};this.renderedTiles.length=0;const v=h.getPreload();if(e.nextExtent&&this.enqueueTilesForNextExtent()){const G=u.getZForResolution(i.nextResolution,c.zDirection),H=rc(e,e.nextExtent);this.enqueueTiles(e,H,G,S,v)}const w=rc(e,m);if(this.enqueueTiles(e,w,d,S,0),v>0&&setTimeout(()=>{this.enqueueTiles(e,w,d-1,S,v-1)},0),!(d in S))return this.container;const I=D(this),F=e.time;for(const G of S[d]){const H=G.getState();if(H===B.EMPTY)continue;const Q=G.tileCoord;if(H===B.LOADED&&G.getAlpha(I,F)===1){G.endTransition(I);continue}if(H!==B.ERROR&&(this.renderComplete=!1),this.findStaleTile_(Q,S)){np(S,G,d),e.animate=!0;continue}if(this.findAltTiles_(u,Q,d+1,S))continue;const Ge=u.getMinZoom();for(let je=d-1;je>=Ge&&!this.findAltTiles_(u,Q,je,S);--je);}const A=f/o*l/_,M=this.getRenderContext(e);ct(this.tempTransform,p/2,y/2,A,A,0,-p/2,-y/2),n.extent&&this.clipUnrotated(M,e,E),c.getInterpolate()||(M.imageSmoothingEnabled=!1),this.preRender(M,e);const b=Object.keys(S).map(Number);b.sort(Nt);let K;const L=[],Z=[];for(let G=b.length-1;G>=0;--G){const H=b[G],Q=c.getTilePixelSize(H,l,r),P=u.getResolution(H)/f,Ge=Q[0]*P*A,je=Q[1]*P*A,Ee=u.getTileCoordForCoordAndZ(Fn(R),H),it=u.getTileCoordExtent(Ee),ke=fe(this.tempTransform,[_*(it[0]-R[0])/f,_*(R[3]-it[3])/f]),Lt=_*c.getGutterForProjection(r);for(const St of S[H]){if(St.getState()!==B.LOADED)continue;const st=St.tileCoord,Vs=Ee[1]-st[1],Co=Math.round(ke[0]-(Vs-1)*Ge),Ji=Ee[2]-st[2],bn=Math.round(ke[1]-(Ji-1)*je),dt=Math.round(ke[0]-Vs*Ge),Ft=Math.round(ke[1]-Ji*je),ai=Co-dt,li=bn-Ft,Qi=b.length===1;let Dn=!1;K=[dt,Ft,dt+ai,Ft,dt+ai,Ft+li,dt,Ft+li];for(let hi=0,ci=L.length;hi<ci;++hi)if(!Qi&&H<Z[hi]){const Ae=L[hi];Te([dt,Ft,dt+ai,Ft+li],[Ae[0],Ae[3],Ae[4],Ae[7]])&&(Dn||(M.save(),Dn=!0),M.beginPath(),M.moveTo(K[0],K[1]),M.lineTo(K[2],K[3]),M.lineTo(K[4],K[5]),M.lineTo(K[6],K[7]),M.moveTo(Ae[6],Ae[7]),M.lineTo(Ae[4],Ae[5]),M.lineTo(Ae[2],Ae[3]),M.lineTo(Ae[0],Ae[1]),M.clip())}L.push(K),Z.push(H),this.drawTile(St,e,dt,Ft,ai,li,Lt,Qi),Dn&&M.restore(),this.renderedTiles.unshift(St),this.updateUsedTiles(e.usedTiles,c,St)}}if(this.renderedResolution=f,this.extentChanged=!this.renderedExtent_||!Hn(this.renderedExtent_,R),this.renderedExtent_=R,this.renderedPixelRatio=l,this.postRender(this.context,e),n.extent&&M.restore(),M.imageSmoothingEnabled=!0,this.renderComplete){const G=(H,Q)=>{const le=D(c),P=Q.wantedTiles[le],Ge=P?Object.keys(P).length:0;this.updateCacheSize(Ge),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};e.postRenderFunctions.push(G)}return this.container}updateCacheSize(e){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,e*2)}drawTile(e,t,n,i,r,o,a,l){let h;if(e instanceof ec){if(h=Na(e.getData()),!h)throw new Error("Rendering array data is not yet supported")}else h=this.getTileImage(e);if(!h)return;const c=this.getRenderContext(t),u=D(this),d=t.layerStatesArray[t.layerIndex],f=d.opacity*(l?e.getAlpha(u,t.time):1),g=f!==c.globalAlpha;g&&(c.save(),c.globalAlpha=f),c.drawImage(h,a,a,h.width-2*a,h.height-2*a,n,i,r,o),g&&c.restore(),f!==d.opacity?t.animate=!0:l&&e.endTransition(u)}getImage(){const e=this.context;return e?e.canvas:null}getTileImage(e){return e.getImage()}updateUsedTiles(e,t,n){const i=D(t);i in e||(e[i]={}),e[i][n.getKey()]=!0}}const Tn={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class ip extends zs{constructor(e){e=e||{};const t=Object.assign({},e),n=e.cacheSize;delete e.cacheSize,delete t.preload,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.cacheSize_=n,this.setPreload(e.preload!==void 0?e.preload:0),this.setUseInterimTilesOnError(e.useInterimTilesOnError!==void 0?e.useInterimTilesOnError:!0)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(Tn.PRELOAD)}setPreload(e){this.set(Tn.PRELOAD,e)}getUseInterimTilesOnError(){return this.get(Tn.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(e){this.set(Tn.USE_INTERIM_TILES_ON_ERROR,e)}getData(e){return super.getData(e)}}class O0 extends ip{constructor(e){super(e)}createRenderer(){return new $u(this,{cacheSize:this.getCacheSize()})}}class Xu extends zl{constructor(e){super(e),this.image=null}getImage(){return this.image?this.image.getImage():null}prepareFrame(e){const t=e.layerStatesArray[e.layerIndex],n=e.pixelRatio,i=e.viewState,r=i.resolution,o=this.getLayer().getSource(),a=e.viewHints;let l=e.extent;if(t.extent!==void 0&&(l=tn(l,wt(t.extent,i.projection))),!a[he.ANIMATING]&&!a[he.INTERACTING]&&!ni(l))if(o){const h=i.projection,c=o.getImage(l,r,n,h);c&&(this.loadImage(c)?this.image=c:c.getState()===U.EMPTY&&(this.image=null))}else this.image=null;return!!this.image}getData(e){const t=this.frameState;if(!t)return null;const n=this.getLayer(),i=fe(t.pixelToCoordinateTransform,e.slice()),r=n.getExtent();if(r&&!Kn(r,i))return null;const o=this.image.getExtent(),a=this.image.getImage(),l=ie(o),h=Math.floor(a.width*((i[0]-o[0])/l));if(h<0||h>=a.width)return null;const c=be(o),u=Math.floor(a.height*((o[3]-i[1])/c));return u<0||u>=a.height?null:this.getImageData(a,h,u)}renderFrame(e,t){const n=this.image,i=n.getExtent(),r=n.getResolution(),[o,a]=Array.isArray(r)?r:[r,r],l=n.getPixelRatio(),h=e.layerStatesArray[e.layerIndex],c=e.pixelRatio,u=e.viewState,d=u.center,f=u.resolution,g=c*o/(f*l),m=c*a/(f*l);this.prepareContainer(e,t);const _=this.context.canvas.width,p=this.context.canvas.height,y=this.getRenderContext(e);let E=!1,x=!0;if(h.extent){const w=wt(h.extent,u.projection);x=Te(w,e.extent),E=x&&!yn(w,e.extent),E&&this.clipUnrotated(y,e,w)}const T=n.getImage(),R=ct(this.tempTransform,_/2,p/2,g,m,0,l*(i[0]-d[0])/o,l*(d[1]-i[3])/a);this.renderedResolution=a*c/l;const S=T.width*R[0],v=T.height*R[3];if(this.getLayer().getSource().getInterpolate()||(y.imageSmoothingEnabled=!1),this.preRender(y,e),x&&S>=.5&&v>=.5){const w=R[4],I=R[5],F=h.opacity;F!==1&&(y.save(),y.globalAlpha=F),y.drawImage(T,0,0,+T.width,+T.height,w,I,S,v),F!==1&&y.restore()}return this.postRender(this.context,e),E&&y.restore(),y.imageSmoothingEnabled=!0,this.container}}class sp extends zs{constructor(e){e=e||{},super(e)}}class N0 extends sp{constructor(e){super(e)}createRenderer(){return new Xu(this)}getData(e){return super.getData(e)}}class Yu{drawCustom(e,t,n,i,r){}drawGeometry(e){}setStyle(e){}drawCircle(e,t,n){}drawFeature(e,t,n){}drawGeometryCollection(e,t,n){}drawLineString(e,t,n){}drawMultiLineString(e,t,n){}drawMultiPoint(e,t,n){}drawMultiPolygon(e,t,n){}drawPoint(e,t,n){}drawPolygon(e,t,n){}drawText(e,t,n){}setFillStrokeStyle(e,t){}setImageStyle(e,t){}setTextStyle(e,t){}}const X={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},ar=[X.FILL],Cn=[X.STROKE],Xn=[X.BEGIN_PATH],oc=[X.CLOSE_PATH];class js extends Yu{constructor(e,t,n,i){super(),this.tolerance=e,this.maxExtent=t,this.pixelRatio=i,this.maxLineWidth=0,this.resolution=n,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(e){const t=this.pixelRatio;return t==1?e:e.map(function(n){return n*t})}appendFlatPointCoordinates(e,t){const n=this.getBufferedMaxExtent(),i=this.tmpCoordinate_,r=this.coordinates;let o=r.length;for(let a=0,l=e.length;a<l;a+=t)i[0]=e[a],i[1]=e[a+1],Kn(n,i)&&(r[o++]=i[0],r[o++]=i[1]);return o}appendFlatLineCoordinates(e,t,n,i,r,o){const a=this.coordinates;let l=a.length;const h=this.getBufferedMaxExtent();o&&(t+=i);let c=e[t],u=e[t+1];const d=this.tmpCoordinate_;let f=!0,g,m,_;for(g=t+i;g<n;g+=i)d[0]=e[g],d[1]=e[g+1],_=xa(h,d),_!==m?(f&&(a[l++]=c,a[l++]=u,f=!1),a[l++]=d[0],a[l++]=d[1]):_===Fe.INTERSECTING?(a[l++]=d[0],a[l++]=d[1],f=!1):f=!0,c=d[0],u=d[1],m=_;return(r&&f||g===t+i)&&(a[l++]=c,a[l++]=u),l}drawCustomCoordinates_(e,t,n,i,r){for(let o=0,a=n.length;o<a;++o){const l=n[o],h=this.appendFlatLineCoordinates(e,t,l,i,!1,!1);r.push(h),t=l}return t}drawCustom(e,t,n,i,r){this.beginGeometry(e,t,r);const o=e.getType(),a=e.getStride(),l=this.coordinates.length;let h,c,u,d,f;switch(o){case"MultiPolygon":h=e.getOrientedFlatCoordinates(),d=[];const g=e.getEndss();f=0;for(let m=0,_=g.length;m<_;++m){const p=[];f=this.drawCustomCoordinates_(h,f,g[m],a,p),d.push(p)}this.instructions.push([X.CUSTOM,l,d,e,n,Pa,r]),this.hitDetectionInstructions.push([X.CUSTOM,l,d,e,i||n,Pa,r]);break;case"Polygon":case"MultiLineString":u=[],h=o=="Polygon"?e.getOrientedFlatCoordinates():e.getFlatCoordinates(),f=this.drawCustomCoordinates_(h,0,e.getEnds(),a,u),this.instructions.push([X.CUSTOM,l,u,e,n,Ss,r]),this.hitDetectionInstructions.push([X.CUSTOM,l,u,e,i||n,Ss,r]);break;case"LineString":case"Circle":h=e.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([X.CUSTOM,l,c,e,n,xn,r]),this.hitDetectionInstructions.push([X.CUSTOM,l,c,e,i||n,xn,r]);break;case"MultiPoint":h=e.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([X.CUSTOM,l,c,e,n,xn,r]),this.hitDetectionInstructions.push([X.CUSTOM,l,c,e,i||n,xn,r]));break;case"Point":h=e.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([X.CUSTOM,l,c,e,n,void 0,r]),this.hitDetectionInstructions.push([X.CUSTOM,l,c,e,i||n,void 0,r]);break}this.endGeometry(t)}beginGeometry(e,t,n){this.beginGeometryInstruction1_=[X.BEGIN_GEOMETRY,t,0,e,n],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[X.BEGIN_GEOMETRY,t,0,e,n],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const e=this.hitDetectionInstructions;e.reverse();let t;const n=e.length;let i,r,o=-1;for(t=0;t<n;++t)i=e[t],r=i[0],r==X.END_GEOMETRY?o=t:r==X.BEGIN_GEOMETRY&&(i[2]=t,hf(this.hitDetectionInstructions,o,t),o=-1)}fillStyleToState(e,t={}){if(e){const n=e.getColor();t.fillPatternScale=n&&typeof n=="object"&&"src"in n?this.pixelRatio:1,t.fillStyle=Ot(n||Je)}else t.fillStyle=void 0;return t}strokeStyleToState(e,t={}){if(e){const n=e.getColor();t.strokeStyle=Ot(n||Ps);const i=e.getLineCap();t.lineCap=i!==void 0?i:Bi;const r=e.getLineDash();t.lineDash=r?r.slice():nn;const o=e.getLineDashOffset();t.lineDashOffset=o||sn;const a=e.getLineJoin();t.lineJoin=a!==void 0?a:zi;const l=e.getWidth();t.lineWidth=l!==void 0?l:As;const h=e.getMiterLimit();t.miterLimit=h!==void 0?h:ws,t.lineWidth>this.maxLineWidth&&(this.maxLineWidth=t.lineWidth,this.bufferedMaxExtent_=null)}else t.strokeStyle=void 0,t.lineCap=void 0,t.lineDash=null,t.lineDashOffset=void 0,t.lineJoin=void 0,t.lineWidth=void 0,t.miterLimit=void 0;return t}setFillStrokeStyle(e,t){const n=this.state;this.fillStyleToState(e,n),this.strokeStyleToState(t,n)}createFill(e){const t=e.fillStyle,n=[X.SET_FILL_STYLE,t];return typeof t!="string"&&n.push(e.fillPatternScale),n}applyStroke(e){this.instructions.push(this.createStroke(e))}createStroke(e){return[X.SET_STROKE_STYLE,e.strokeStyle,e.lineWidth*this.pixelRatio,e.lineCap,e.lineJoin,e.miterLimit,e.lineDash?this.applyPixelRatio(e.lineDash):null,e.lineDashOffset*this.pixelRatio]}updateFillStyle(e,t){const n=e.fillStyle;(typeof n!="string"||e.currentFillStyle!=n)&&(this.instructions.push(t.call(this,e)),e.currentFillStyle=n)}updateStrokeStyle(e,t){const n=e.strokeStyle,i=e.lineCap,r=e.lineDash,o=e.lineDashOffset,a=e.lineJoin,l=e.lineWidth,h=e.miterLimit;(e.currentStrokeStyle!=n||e.currentLineCap!=i||r!=e.currentLineDash&&!Bt(e.currentLineDash,r)||e.currentLineDashOffset!=o||e.currentLineJoin!=a||e.currentLineWidth!=l||e.currentMiterLimit!=h)&&(t.call(this,e),e.currentStrokeStyle=n,e.currentLineCap=i,e.currentLineDash=r,e.currentLineDashOffset=o,e.currentLineJoin=a,e.currentLineWidth=l,e.currentMiterLimit=h)}endGeometry(e){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const t=[X.END_GEOMETRY,e];this.instructions.push(t),this.hitDetectionInstructions.push(t)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Uc(this.maxExtent),this.maxLineWidth>0)){const e=this.resolution*(this.maxLineWidth+1)/2;rn(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class rp extends js{constructor(e,t,n,i){super(e,t,n,i),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(e,t,n){if(!this.image_||this.maxExtent&&!Kn(this.maxExtent,e.getFlatCoordinates()))return;this.beginGeometry(e,t,n);const i=e.getFlatCoordinates(),r=e.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(i,r);this.instructions.push([X.DRAW_IMAGE,o,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([X.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(t)}drawMultiPoint(e,t,n){if(!this.image_)return;this.beginGeometry(e,t,n);const i=e.getFlatCoordinates(),r=[];for(let l=0,h=i.length;l<h;l+=e.getStride())(!this.maxExtent||Kn(this.maxExtent,i.slice(l,l+2)))&&r.push(i[l],i[l+1]);const o=this.coordinates.length,a=this.appendFlatPointCoordinates(r,2);this.instructions.push([X.DRAW_IMAGE,o,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([X.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(t)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(e,t){const n=e.getAnchor(),i=e.getSize(),r=e.getOrigin();this.imagePixelRatio_=e.getPixelRatio(this.pixelRatio),this.anchorX_=n[0],this.anchorY_=n[1],this.hitDetectionImage_=e.getHitDetectionImage(),this.image_=e.getImage(this.pixelRatio),this.height_=i[1],this.opacity_=e.getOpacity(),this.originX_=r[0],this.originY_=r[1],this.rotateWithView_=e.getRotateWithView(),this.rotation_=e.getRotation(),this.scale_=e.getScaleArray(),this.width_=i[0],this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}}class op extends js{constructor(e,t,n,i){super(e,t,n,i)}drawFlatCoordinates_(e,t,n,i){const r=this.coordinates.length,o=this.appendFlatLineCoordinates(e,t,n,i,!1,!1),a=[X.MOVE_TO_LINE_TO,r,o];return this.instructions.push(a),this.hitDetectionInstructions.push(a),n}drawLineString(e,t,n){const i=this.state,r=i.strokeStyle,o=i.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(e,t,n),this.hitDetectionInstructions.push([X.SET_STROKE_STYLE,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,nn,sn],Xn);const a=e.getFlatCoordinates(),l=e.getStride();this.drawFlatCoordinates_(a,0,a.length,l),this.hitDetectionInstructions.push(Cn),this.endGeometry(t)}drawMultiLineString(e,t,n){const i=this.state,r=i.strokeStyle,o=i.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(e,t,n),this.hitDetectionInstructions.push([X.SET_STROKE_STYLE,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,nn,sn],Xn);const a=e.getEnds(),l=e.getFlatCoordinates(),h=e.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinates_(l,c,a[u],h);this.hitDetectionInstructions.push(Cn),this.endGeometry(t)}finish(){const e=this.state;return e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&this.instructions.push(Cn),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(e){e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&(this.instructions.push(Cn),e.lastStroke=this.coordinates.length),e.lastStroke=0,super.applyStroke(e),this.instructions.push(Xn)}}class ac extends js{constructor(e,t,n,i){super(e,t,n,i)}drawFlatCoordinatess_(e,t,n,i){const r=this.state,o=r.fillStyle!==void 0,a=r.strokeStyle!==void 0,l=n.length;this.instructions.push(Xn),this.hitDetectionInstructions.push(Xn);for(let h=0;h<l;++h){const c=n[h],u=this.coordinates.length,d=this.appendFlatLineCoordinates(e,t,c,i,!0,!a),f=[X.MOVE_TO_LINE_TO,u,d];this.instructions.push(f),this.hitDetectionInstructions.push(f),a&&(this.instructions.push(oc),this.hitDetectionInstructions.push(oc)),t=c}return o&&(this.instructions.push(ar),this.hitDetectionInstructions.push(ar)),a&&(this.instructions.push(Cn),this.hitDetectionInstructions.push(Cn)),t}drawCircle(e,t,n){const i=this.state,r=i.fillStyle,o=i.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,n),i.fillStyle!==void 0&&this.hitDetectionInstructions.push([X.SET_FILL_STYLE,Je]),i.strokeStyle!==void 0&&this.hitDetectionInstructions.push([X.SET_STROKE_STYLE,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,nn,sn]);const a=e.getFlatCoordinates(),l=e.getStride(),h=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const c=[X.CIRCLE,h];this.instructions.push(Xn,c),this.hitDetectionInstructions.push(Xn,c),i.fillStyle!==void 0&&(this.instructions.push(ar),this.hitDetectionInstructions.push(ar)),i.strokeStyle!==void 0&&(this.instructions.push(Cn),this.hitDetectionInstructions.push(Cn)),this.endGeometry(t)}drawPolygon(e,t,n){const i=this.state,r=i.fillStyle,o=i.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,n),i.fillStyle!==void 0&&this.hitDetectionInstructions.push([X.SET_FILL_STYLE,Je]),i.strokeStyle!==void 0&&this.hitDetectionInstructions.push([X.SET_STROKE_STYLE,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,nn,sn]);const a=e.getEnds(),l=e.getOrientedFlatCoordinates(),h=e.getStride();this.drawFlatCoordinatess_(l,0,a,h),this.endGeometry(t)}drawMultiPolygon(e,t,n){const i=this.state,r=i.fillStyle,o=i.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,n),i.fillStyle!==void 0&&this.hitDetectionInstructions.push([X.SET_FILL_STYLE,Je]),i.strokeStyle!==void 0&&this.hitDetectionInstructions.push([X.SET_STROKE_STYLE,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,nn,sn]);const a=e.getEndss(),l=e.getOrientedFlatCoordinates(),h=e.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinatess_(l,c,a[u],h);this.endGeometry(t)}finish(){this.reverseHitDetectionInstructions(),this.state=null;const e=this.tolerance;if(e!==0){const t=this.coordinates;for(let n=0,i=t.length;n<i;++n)t[n]=kn(t[n],e)}return super.finish()}setFillStrokeStyles_(){const e=this.state;this.updateFillStyle(e,this.createFill),this.updateStrokeStyle(e,this.applyStroke)}}function ap(s,e,t,n,i){const r=[];let o=t,a=0,l=e.slice(t,2);for(;a<s&&o+i<n;){const[h,c]=l.slice(-2),u=e[o+i],d=e[o+i+1],f=Math.sqrt((u-h)*(u-h)+(d-c)*(d-c));if(a+=f,a>=s){const g=(s-a+f)/f,m=rt(h,u,g),_=rt(c,d,g);l.push(m,_),r.push(l),l=[m,_],a==s&&(o+=i),a=0}else if(a<s)l.push(e[o+i],e[o+i+1]),o+=i;else{const g=f-a,m=rt(h,u,g/f),_=rt(c,d,g/f);l.push(m,_),r.push(l),l=[m,_],a=0,o+=i}}return a>0&&r.push(l),r}function lp(s,e,t,n,i){let r=t,o=t,a=0,l=0,h=t,c,u,d,f,g,m,_,p,y,E;for(u=t;u<n;u+=i){const x=e[u],T=e[u+1];g!==void 0&&(y=x-g,E=T-m,f=Math.sqrt(y*y+E*E),_!==void 0&&(l+=d,c=Math.acos((_*y+p*E)/(d*f)),c>s&&(l>a&&(a=l,r=h,o=u),l=0,h=u-i)),d=f,_=y,p=E),g=x,m=T}return l+=f,l>a?[h,u]:[r,o]}const $r={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class hp extends js{constructor(e,t,n,i){super(e,t,n,i),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Je]={fillStyle:Je},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){const e=super.finish();return e.textStates=this.textStates,e.fillStates=this.fillStates,e.strokeStates=this.strokeStates,e}drawText(e,t,n){const i=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!i&&!r)return;const a=this.coordinates;let l=a.length;const h=e.getType();let c=null,u=e.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){if(!Te(this.maxExtent,e.getExtent()))return;let d;if(c=e.getFlatCoordinates(),h=="LineString")d=[c.length];else if(h=="MultiLineString")d=e.getEnds();else if(h=="Polygon")d=e.getEnds().slice(0,1);else if(h=="MultiPolygon"){const _=e.getEndss();d=[];for(let p=0,y=_.length;p<y;++p)d.push(_[p][0])}this.beginGeometry(e,t,n);const f=o.repeat,g=f?void 0:o.textAlign;let m=0;for(let _=0,p=d.length;_<p;++_){let y;f?y=ap(f*this.resolution,c,m,d[_],u):y=[c.slice(m,d[_])];for(let E=0,x=y.length;E<x;++E){const T=y[E];let R=0,S=T.length;if(g==null){const w=lp(o.maxAngle,T,0,T.length,2);R=w[0],S=w[1]}for(let w=R;w<S;w+=u)a.push(T[w],T[w+1]);const v=a.length;m=d[_],this.drawChars_(l,v),l=v}}this.endGeometry(t)}else{let d=o.overflow?null:[];switch(h){case"Point":case"MultiPoint":c=e.getFlatCoordinates();break;case"LineString":c=e.getFlatMidpoint();break;case"Circle":c=e.getCenter();break;case"MultiLineString":c=e.getFlatMidpoints(),u=2;break;case"Polygon":c=e.getFlatInteriorPoint(),o.overflow||d.push(c[2]/this.resolution),u=3;break;case"MultiPolygon":const x=e.getFlatInteriorPoints();c=[];for(let T=0,R=x.length;T<R;T+=3)o.overflow||d.push(x[T+2]/this.resolution),c.push(x[T],x[T+1]);if(c.length===0)return;u=2;break}const f=this.appendFlatPointCoordinates(c,u);if(f===l)return;if(d&&(f-l)/2!==c.length/u){let x=l/2;d=d.filter((T,R)=>{const S=a[(x+R)*2]===c[R*u]&&a[(x+R)*2+1]===c[R*u+1];return S||--x,S})}this.saveTextStates_();const g=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,m=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(e,t,n);let _=o.padding;if(_!=$n&&(o.scale[0]<0||o.scale[1]<0)){let x=o.padding[0],T=o.padding[1],R=o.padding[2],S=o.padding[3];o.scale[0]<0&&(T=-T,S=-S),o.scale[1]<0&&(x=-x,R=-R),_=[x,T,R,S]}const p=this.pixelRatio;this.instructions.push([X.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,_==$n?$n:_.map(function(x){return x*p}),g,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);const y=1/p,E=g?g.slice(0):null;E&&(E[1]=Je),this.hitDetectionInstructions.push([X.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[y,y],NaN,this.declutterMode_,this.declutterImageWithText_,_,E,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Je:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),this.endGeometry(t)}}saveTextStates_(){const e=this.textStrokeState_,t=this.textState_,n=this.textFillState_,i=this.strokeKey_;e&&(i in this.strokeStates||(this.strokeStates[i]={strokeStyle:e.strokeStyle,lineCap:e.lineCap,lineDashOffset:e.lineDashOffset,lineWidth:e.lineWidth,lineJoin:e.lineJoin,miterLimit:e.miterLimit,lineDash:e.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:t.font,textAlign:t.textAlign||Is,justify:t.justify,textBaseline:t.textBaseline||kr,scale:t.scale});const o=this.fillKey_;n&&(o in this.fillStates||(this.fillStates[o]={fillStyle:n.fillStyle}))}drawChars_(e,t){const n=this.textStrokeState_,i=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,h=$r[i.textBaseline],c=this.textOffsetY_*l,u=this.text_,d=n?n.lineWidth*Math.abs(i.scale[0])/2:0;this.instructions.push([X.DRAW_CHARS,e,t,h,i.overflow,a,i.maxAngle,l,c,r,d*l,u,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([X.DRAW_CHARS,e,t,h,i.overflow,a&&Je,i.maxAngle,l,c,r,d*l,u,o,1/l,this.declutterMode_,this.textKeepUpright_])}setTextStyle(e,t){let n,i,r;if(!e)this.text_="";else{const o=e.getFill();o?(i=this.textFillState_,i||(i={},this.textFillState_=i),i.fillStyle=Ot(o.getColor()||Je)):(i=null,this.textFillState_=i);const a=e.getStroke();if(!a)r=null,this.textStrokeState_=r;else{r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const m=a.getLineDash(),_=a.getLineDashOffset(),p=a.getWidth(),y=a.getMiterLimit();r.lineCap=a.getLineCap()||Bi,r.lineDash=m?m.slice():nn,r.lineDashOffset=_===void 0?sn:_,r.lineJoin=a.getLineJoin()||zi,r.lineWidth=p===void 0?As:p,r.miterLimit=y===void 0?ws:y,r.strokeStyle=Ot(a.getColor()||Ps)}n=this.textState_;const l=e.getFont()||Iu;mm(l);const h=e.getScaleArray();n.overflow=e.getOverflow(),n.font=l,n.maxAngle=e.getMaxAngle(),n.placement=e.getPlacement(),n.textAlign=e.getTextAlign(),n.repeat=e.getRepeat(),n.justify=e.getJustify(),n.textBaseline=e.getTextBaseline()||kr,n.backgroundFill=e.getBackgroundFill(),n.backgroundStroke=e.getBackgroundStroke(),n.padding=e.getPadding()||$n,n.scale=h===void 0?[1,1]:h;const c=e.getOffsetX(),u=e.getOffsetY(),d=e.getRotateWithView(),f=e.getKeepUpright(),g=e.getRotation();this.text_=e.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textKeepUpright_=f===void 0?!0:f,this.textRotation_=g===void 0?0:g,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:D(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=n.font+n.scale+(n.textAlign||"?")+(n.repeat||"?")+(n.justify||"?")+(n.textBaseline||"?"),this.fillKey_=i&&i.fillStyle?typeof i.fillStyle=="string"?i.fillStyle:"|"+D(i.fillStyle):""}this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}}const cp={Circle:ac,Default:js,Image:rp,LineString:op,Polygon:ac,Text:hp};class ju{constructor(e,t,n,i){this.tolerance_=e,this.maxExtent_=t,this.pixelRatio_=i,this.resolution_=n,this.buildersByZIndex_={}}finish(){const e={};for(const t in this.buildersByZIndex_){e[t]=e[t]||{};const n=this.buildersByZIndex_[t];for(const i in n){const r=n[i].finish();e[t][i]=r}}return e}getBuilder(e,t){const n=e!==void 0?e.toString():"0";let i=this.buildersByZIndex_[n];i===void 0&&(i={},this.buildersByZIndex_[n]=i);let r=i[t];if(r===void 0){const o=cp[t];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),i[t]=r}return r}}function $l(s,e,t,n){let i=s[e],r=s[e+1],o=0;for(let a=e+n;a<t;a+=n){const l=s[a],h=s[a+1];o+=Math.sqrt((l-i)*(l-i)+(h-r)*(h-r)),i=l,r=h}return o}function up(s,e,t,n,i,r,o,a,l,h,c,u,d=!0){let f=s[e],g=s[e+1],m=0,_=0,p=0,y=0;function E(){m=f,_=g,e+=n,f=s[e],g=s[e+1],y+=p,p=Math.sqrt((f-m)*(f-m)+(g-_)*(g-_))}do E();while(e<t-n&&y+p<r);let x=p===0?0:(r-y)/p;const T=rt(m,f,x),R=rt(_,g,x),S=e-n,v=y,w=r+a*l(h,i,c);for(;e<t-n&&y+p<w;)E();x=p===0?0:(w-y)/p;const I=rt(m,f,x),F=rt(_,g,x);let A=!1;if(d)if(u){const Z=[T,R,I,F];cl(Z,0,4,2,u,Z,Z),A=Z[0]>Z[2]}else A=T>I;const M=Math.PI,b=[],K=S+n===e;e=S,p=0,y=v,f=s[e],g=s[e+1];let L;if(K){E(),L=Math.atan2(g-_,f-m),A&&(L+=L>0?-M:M);const Z=(I+T)/2,G=(F+R)/2;return b[0]=[Z,G,(w-r)/2,L,i],b}i=i.replace(/\n/g," ");for(let Z=0,G=i.length;Z<G;){E();let H=Math.atan2(g-_,f-m);if(A&&(H+=H>0?-M:M),L!==void 0){let Ee=H-L;if(Ee+=Ee>M?-2*M:Ee<-M?2*M:0,Math.abs(Ee)>o)return null}L=H;const Q=Z;let le=0;for(;Z<G;++Z){const Ee=A?G-Z-1:Z,it=a*l(h,i[Ee],c);if(e+n<t&&y+p<r+le+it/2)break;le+=it}if(Z===Q)continue;const P=A?i.substring(G-Q,G-Z):i.substring(Q,Z);x=p===0?0:(r+le/2-y)/p;const Ge=rt(m,f,x),je=rt(_,g,x);b.push([Ge,je,le/2,H,P]),r+=le}return b}const mi=tt(),dn=[],Yt=[],jt=[],fn=[];function lc(s){return s[3].declutterBox}const hc=new RegExp("[֑-ࣿיִ-﷿ﹰ-ﻼࠀ--]");function qo(s,e){return e==="start"?e=hc.test(s)?"right":"left":e==="end"&&(e=hc.test(s)?"left":"right"),$r[e]}function dp(s,e,t){return t>0&&s.push(`
|
||
`,""),s.push(e,""),s}function fp(s,e,t){return t%2===0&&(s+=e),s}class gp{constructor(e,t,n,i,r){this.overlaps=n,this.pixelRatio=t,this.resolution=e,this.alignAndScaleFill_,this.instructions=i.instructions,this.coordinates=i.coordinates,this.coordinateCache_={},this.renderedTransform_=Ce(),this.hitDetectionInstructions=i.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=i.fillStates||{},this.strokeStates=i.strokeStates||{},this.textStates=i.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new Bl:null}getZIndexContext(){return this.zIndexContext_}createLabel(e,t,n,i){const r=e+t+n+i;if(this.labels_[r])return this.labels_[r];const o=i?this.strokeStates[i]:null,a=n?this.fillStates[n]:null,l=this.textStates[t],h=this.pixelRatio,c=[l.scale[0]*h,l.scale[1]*h],u=l.justify?$r[l.justify]:qo(Array.isArray(e)?e[0]:e,l.textAlign||Is),d=i&&o.lineWidth?o.lineWidth:0,f=Array.isArray(e)?e:String(e).split(`
|
||
`).reduce(dp,[]),{width:g,height:m,widths:_,heights:p,lineWidths:y}=ym(l,f),E=g+d,x=[],T=(E+2)*c[0],R=(m+d)*c[1],S={width:T<0?Math.floor(T):Math.ceil(T),height:R<0?Math.floor(R):Math.ceil(R),contextInstructions:x};(c[0]!=1||c[1]!=1)&&x.push("scale",c),i&&(x.push("strokeStyle",o.strokeStyle),x.push("lineWidth",d),x.push("lineCap",o.lineCap),x.push("lineJoin",o.lineJoin),x.push("miterLimit",o.miterLimit),x.push("setLineDash",[o.lineDash]),x.push("lineDashOffset",o.lineDashOffset)),n&&x.push("fillStyle",a.fillStyle),x.push("textBaseline","middle"),x.push("textAlign","center");const v=.5-u;let w=u*E+v*d;const I=[],F=[];let A=0,M=0,b=0,K=0,L;for(let Z=0,G=f.length;Z<G;Z+=2){const H=f[Z];if(H===`
|
||
`){M+=A,A=0,w=u*E+v*d,++K;continue}const Q=f[Z+1]||l.font;Q!==L&&(i&&I.push("font",Q),n&&F.push("font",Q),L=Q),A=Math.max(A,p[b]);const le=[H,w+v*_[b]+u*(_[b]-y[K]),.5*(d+A)+M];w+=_[b],i&&I.push("strokeText",le),n&&F.push("fillText",le),++b}return Array.prototype.push.apply(x,I),Array.prototype.push.apply(x,F),this.labels_[r]=S,S}replayTextBackground_(e,t,n,i,r,o,a){e.beginPath(),e.moveTo.apply(e,t),e.lineTo.apply(e,n),e.lineTo.apply(e,i),e.lineTo.apply(e,r),e.lineTo.apply(e,t),o&&(this.alignAndScaleFill_=o[2],e.fillStyle=o[1],this.fill_(e)),a&&(this.setStrokeStyle_(e,a),e.stroke())}calculateImageOrLabelDimensions_(e,t,n,i,r,o,a,l,h,c,u,d,f,g,m,_){a*=d[0],l*=d[1];let p=n-a,y=i-l;const E=r+h>e?e-h:r,x=o+c>t?t-c:o,T=g[3]+E*d[0]+g[1],R=g[0]+x*d[1]+g[2],S=p-g[3],v=y-g[0];(m||u!==0)&&(dn[0]=S,fn[0]=S,dn[1]=v,Yt[1]=v,Yt[0]=S+T,jt[0]=Yt[0],jt[1]=v+R,fn[1]=jt[1]);let w;return u!==0?(w=ct(Ce(),n,i,1,1,u,-n,-i),fe(w,dn),fe(w,Yt),fe(w,jt),fe(w,fn),Ut(Math.min(dn[0],Yt[0],jt[0],fn[0]),Math.min(dn[1],Yt[1],jt[1],fn[1]),Math.max(dn[0],Yt[0],jt[0],fn[0]),Math.max(dn[1],Yt[1],jt[1],fn[1]),mi)):Ut(Math.min(S,S+T),Math.min(v,v+R),Math.max(S,S+T),Math.max(v,v+R),mi),f&&(p=Math.round(p),y=Math.round(y)),{drawImageX:p,drawImageY:y,drawImageW:E,drawImageH:x,originX:h,originY:c,declutterBox:{minX:mi[0],minY:mi[1],maxX:mi[2],maxY:mi[3],value:_},canvasTransform:w,scale:d}}replayImageOrLabel_(e,t,n,i,r,o,a){const l=!!(o||a),h=i.declutterBox,c=a?a[2]*i.scale[0]/2:0;return h.minX-c<=t[0]&&h.maxX+c>=0&&h.minY-c<=t[1]&&h.maxY+c>=0&&(l&&this.replayTextBackground_(e,dn,Yt,jt,fn,o,a),xm(e,i.canvasTransform,r,n,i.originX,i.originY,i.drawImageW,i.drawImageH,i.drawImageX,i.drawImageY,i.scale)),!0}fill_(e){const t=this.alignAndScaleFill_;if(t){const n=fe(this.renderedTransform_,[0,0]),i=512*this.pixelRatio;e.save(),e.translate(n[0]%i,n[1]%i),t!==1&&e.scale(t,t),e.rotate(this.viewRotation_)}e.fill(),t&&e.restore()}setStrokeStyle_(e,t){e.strokeStyle=t[1],t[1]&&(e.lineWidth=t[2],e.lineCap=t[3],e.lineJoin=t[4],e.miterLimit=t[5],e.lineDashOffset=t[7],e.setLineDash(t[6]))}drawLabelWithPointPlacement_(e,t,n,i){const r=this.textStates[t],o=this.createLabel(e,t,i,n),a=this.strokeStates[n],l=this.pixelRatio,h=qo(Array.isArray(e)?e[0]:e,r.textAlign||Is),c=$r[r.textBaseline||kr],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*r.scale[0],f=h*d+2*(.5-h)*u,g=c*o.height/l+2*(.5-c)*u;return{label:o,anchorX:f,anchorY:g}}execute_(e,t,n,i,r,o,a,l){const h=this.zIndexContext_;let c;this.pixelCoordinates_&&Bt(n,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=Gt(this.coordinates,0,this.coordinates.length,2,n,this.pixelCoordinates_),tu(this.renderedTransform_,n));let u=0;const d=i.length;let f=0,g,m,_,p,y,E,x,T,R,S,v,w,I,F=0,A=0;const M=this.coordinateCache_,b=this.viewRotation_,K=Math.round(Math.atan2(-n[1],n[0])*1e12)/1e12,L={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:b},Z=this.instructions!=i||this.overlaps?0:200;let G,H,Q,le;for(;u<d;){const P=i[u];switch(P[0]){case X.BEGIN_GEOMETRY:G=P[1],le=P[3],G.getGeometry()?a!==void 0&&!Te(a,le.getExtent())?u=P[2]+1:++u:u=P[2],h&&(h.zIndex=P[4]);break;case X.BEGIN_PATH:F>Z&&(this.fill_(e),F=0),A>Z&&(e.stroke(),A=0),!F&&!A&&(e.beginPath(),y=NaN,E=NaN),++u;break;case X.CIRCLE:f=P[1];const je=c[f],Ee=c[f+1],it=c[f+2],ke=c[f+3],Lt=it-je,St=ke-Ee,st=Math.sqrt(Lt*Lt+St*St);e.moveTo(je+st,Ee),e.arc(je,Ee,st,0,2*Math.PI,!0),++u;break;case X.CLOSE_PATH:e.closePath(),++u;break;case X.CUSTOM:f=P[1],g=P[2];const Vs=P[3],Co=P[4],Ji=P[5];L.geometry=Vs,L.feature=G,u in M||(M[u]=[]);const bn=M[u];Ji?Ji(c,f,g,2,bn):(bn[0]=c[f],bn[1]=c[f+1],bn.length=2),h&&(h.zIndex=P[6]),Co(bn,L),++u;break;case X.DRAW_IMAGE:f=P[1],g=P[2],R=P[3],m=P[4],_=P[5];let dt=P[6];const Ft=P[7],ai=P[8],li=P[9],Qi=P[10];let Dn=P[11];const hi=P[12];let ci=P[13];p=P[14]||"declutter";const Ae=P[15];if(!R&&P.length>=20){S=P[19],v=P[20],w=P[21],I=P[22];const ft=this.drawLabelWithPointPlacement_(S,v,w,I);R=ft.label,P[3]=R;const On=P[23];m=(ft.anchorX-On)*this.pixelRatio,P[4]=m;const gt=P[24];_=(ft.anchorY-gt)*this.pixelRatio,P[5]=_,dt=R.height,P[6]=dt,ci=R.width,P[13]=ci}let Ro;P.length>25&&(Ro=P[25]);let So,Zs,Ks;P.length>17?(So=P[16],Zs=P[17],Ks=P[18]):(So=$n,Zs=null,Ks=null),Qi&&K?Dn+=b:!Qi&&!K&&(Dn-=b);let Qd=0;for(;f<g;f+=2){if(Ro&&Ro[Qd++]<ci/this.pixelRatio)continue;const ft=this.calculateImageOrLabelDimensions_(R.width,R.height,c[f],c[f+1],ci,dt,m,_,ai,li,Dn,hi,r,So,!!Zs||!!Ks,G),On=[e,t,R,ft,Ft,Zs,Ks];if(l){let gt,Mt,_t;if(Ae){const xe=g-f;if(!Ae[xe]){Ae[xe]={args:On,declutterMode:p};continue}const We=Ae[xe];gt=We.args,Mt=We.declutterMode,delete Ae[xe],_t=lc(gt)}let zt,$t;if(gt&&(Mt!=="declutter"||!l.collides(_t))&&(zt=!0),(p!=="declutter"||!l.collides(ft.declutterBox))&&($t=!0),Mt==="declutter"&&p==="declutter"){const xe=zt&&$t;zt=xe,$t=xe}zt&&(Mt!=="none"&&l.insert(_t),this.replayImageOrLabel_.apply(this,gt)),$t&&(p!=="none"&&l.insert(ft.declutterBox),this.replayImageOrLabel_.apply(this,On))}else this.replayImageOrLabel_.apply(this,On)}++u;break;case X.DRAW_CHARS:const ch=P[1],uh=P[2],vo=P[3],ef=P[4];I=P[5];const tf=P[6],dh=P[7],fh=P[8];w=P[9];const wo=P[10];S=P[11],Array.isArray(S)&&(S=S.reduce(fp,"")),v=P[12];const gh=[P[13],P[13]];p=P[14]||"declutter";const nf=P[15],Po=this.textStates[v],es=Po.font,ts=[Po.scale[0]*dh,Po.scale[1]*dh];let ns;es in this.widths_?ns=this.widths_[es]:(ns={},this.widths_[es]=ns);const _h=$l(c,ch,uh,2),mh=Math.abs(ts[0])*Wh(es,S,ns);if(ef||mh<=_h){const ft=this.textStates[v].textAlign,On=(_h-mh)*qo(S,ft),gt=up(c,ch,uh,2,S,On,tf,Math.abs(ts[0]),Wh,es,ns,K?0:this.viewRotation_,nf);e:if(gt){const Mt=[];let _t,zt,$t,xe,We;if(w)for(_t=0,zt=gt.length;_t<zt;++_t){We=gt[_t],$t=We[4],xe=this.createLabel($t,v,"",w),m=We[2]+(ts[0]<0?-wo:wo),_=vo*xe.height+(.5-vo)*2*wo*ts[1]/ts[0]-fh;const Xt=this.calculateImageOrLabelDimensions_(xe.width,xe.height,We[0],We[1],xe.width,xe.height,m,_,0,0,We[3],gh,!1,$n,!1,G);if(l&&p==="declutter"&&l.collides(Xt.declutterBox))break e;Mt.push([e,t,xe,Xt,1,null,null])}if(I)for(_t=0,zt=gt.length;_t<zt;++_t){We=gt[_t],$t=We[4],xe=this.createLabel($t,v,I,""),m=We[2],_=vo*xe.height-fh;const Xt=this.calculateImageOrLabelDimensions_(xe.width,xe.height,We[0],We[1],xe.width,xe.height,m,_,0,0,We[3],gh,!1,$n,!1,G);if(l&&p==="declutter"&&l.collides(Xt.declutterBox))break e;Mt.push([e,t,xe,Xt,1,null,null])}l&&p!=="none"&&l.load(Mt.map(lc));for(let Xt=0,sf=Mt.length;Xt<sf;++Xt)this.replayImageOrLabel_.apply(this,Mt[Xt])}}++u;break;case X.END_GEOMETRY:if(o!==void 0){G=P[1];const ft=o(G,le,p);if(ft)return ft}++u;break;case X.FILL:Z?F++:this.fill_(e),++u;break;case X.MOVE_TO_LINE_TO:for(f=P[1],g=P[2],H=c[f],Q=c[f+1],e.moveTo(H,Q),y=H+.5|0,E=Q+.5|0,f+=2;f<g;f+=2)H=c[f],Q=c[f+1],x=H+.5|0,T=Q+.5|0,(f==g-2||x!==y||T!==E)&&(e.lineTo(H,Q),y=x,E=T);++u;break;case X.SET_FILL_STYLE:this.alignAndScaleFill_=P[2],F&&(this.fill_(e),F=0,A&&(e.stroke(),A=0)),e.fillStyle=P[1],++u;break;case X.SET_STROKE_STYLE:A&&(e.stroke(),A=0),this.setStrokeStyle_(e,P),++u;break;case X.STROKE:Z?A++:e.stroke(),++u;break;default:++u;break}}F&&this.fill_(e),A&&e.stroke()}execute(e,t,n,i,r,o){this.viewRotation_=i,this.execute_(e,t,n,this.instructions,r,void 0,void 0,o)}executeHitDetection(e,t,n,i,r){return this.viewRotation_=n,this.execute_(e,[e.canvas.width,e.canvas.height],t,this.hitDetectionInstructions,!0,i,r)}}const Un=["Polygon","Circle","LineString","Image","Text","Default"],Xr=["Image","Text"],_p=Un.filter(s=>!Xr.includes(s));class Wu{constructor(e,t,n,i,r,o,a){this.maxExtent_=e,this.overlaps_=i,this.pixelRatio_=n,this.resolution_=t,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Ce(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}clip(e,t){const n=this.getClipCoords(t);e.beginPath(),e.moveTo(n[0],n[1]),e.lineTo(n[2],n[3]),e.lineTo(n[4],n[5]),e.lineTo(n[6],n[7]),e.clip()}createExecutors_(e,t){for(const n in e){let i=this.executorsByZIndex_[n];i===void 0&&(i={},this.executorsByZIndex_[n]=i);const r=e[n];for(const o in r){const a=r[o];i[o]=new gp(this.resolution_,this.pixelRatio_,this.overlaps_,a,t)}}}hasExecutors(e){for(const t in this.executorsByZIndex_){const n=this.executorsByZIndex_[t];for(let i=0,r=e.length;i<r;++i)if(e[i]in n)return!0}return!1}forEachFeatureAtCoordinate(e,t,n,i,r,o){i=Math.round(i);const a=i*2+1,l=ct(this.hitDetectionTransform_,i+.5,i+.5,1/t,-1/t,-n,-e[0],-e[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=we(a,a));const c=this.hitDetectionContext_;c.canvas.width!==a||c.canvas.height!==a?(c.canvas.width=a,c.canvas.height=a):h||c.clearRect(0,0,a,a);let u;this.renderBuffer_!==void 0&&(u=tt(),gs(u,e),rn(u,t*(this.renderBuffer_+i),u));const d=mp(i);let f;function g(T,R,S){const v=c.getImageData(0,0,a,a).data;for(let w=0,I=d.length;w<I;w++)if(v[d[w]]>0){if(!o||S==="none"||f!=="Image"&&f!=="Text"||o.includes(T)){const F=(d[w]-3)/4,A=i-F%a,M=i-(F/a|0),b=r(T,R,A*A+M*M);if(b)return b}c.clearRect(0,0,a,a);break}}const m=Object.keys(this.executorsByZIndex_).map(Number);m.sort(Nt);let _,p,y,E,x;for(_=m.length-1;_>=0;--_){const T=m[_].toString();for(y=this.executorsByZIndex_[T],p=Un.length-1;p>=0;--p)if(f=Un[p],E=y[f],E!==void 0&&(x=E.executeHitDetection(c,l,n,g,u),x))return x}}getClipCoords(e){const t=this.maxExtent_;if(!t)return null;const n=t[0],i=t[1],r=t[2],o=t[3],a=[n,i,n,o,r,o,r,i];return Gt(a,0,8,2,e,a),a}isEmpty(){return Vn(this.executorsByZIndex_)}execute(e,t,n,i,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?lf:Nt),o=o||Un;const h=Un.length;for(let c=0,u=l.length;c<u;++c){const d=l[c].toString(),f=this.executorsByZIndex_[d];for(let g=0,m=o.length;g<m;++g){const _=o[g],p=f[_];if(p!==void 0){const y=a===null?void 0:p.getZIndexContext(),E=y?y.getContext():e,x=this.maxExtent_&&_!=="Image"&&_!=="Text";if(x&&(E.save(),this.clip(E,n)),!y||_==="Text"||_==="Image"?p.execute(E,t,n,i,r,a):y.pushFunction(T=>p.execute(T,t,n,i,r,a)),x&&E.restore(),y){y.offset();const T=l[c]*h+Un.indexOf(_);this.deferredZIndexContexts_[T]||(this.deferredZIndexContexts_[T]=[]),this.deferredZIndexContexts_[T].push(y)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const e=this.deferredZIndexContexts_,t=Object.keys(e).map(Number).sort(Nt);for(let n=0,i=t.length;n<i;++n)e[t[n]].forEach(r=>{r.draw(this.renderedContext_),r.clear()}),e[t[n]].length=0}}const Jo={};function mp(s){if(Jo[s]!==void 0)return Jo[s];const e=s*2+1,t=s*s,n=new Array(t+1);for(let r=0;r<=s;++r)for(let o=0;o<=s;++o){const a=r*r+o*o;if(a>t)break;let l=n[a];l||(l=[],n[a]=l),l.push(((s+r)*e+(s+o))*4+3),r>0&&l.push(((s-r)*e+(s+o))*4+3),o>0&&(l.push(((s+r)*e+(s-o))*4+3),r>0&&l.push(((s-r)*e+(s-o))*4+3))}const i=[];for(let r=0,o=n.length;r<o;++r)n[r]&&i.push(...n[r]);return Jo[s]=i,i}class pp extends Yu{constructor(e,t,n,i,r,o,a){super(),this.context_=e,this.pixelRatio_=t,this.extent_=n,this.transform_=i,this.transformRotation_=i?Yi(Math.atan2(i[1],i[0]),10):0,this.viewRotation_=r,this.squaredTolerance_=o,this.userTransform_=a,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=Ce()}drawImages_(e,t,n,i){if(!this.image_)return;const r=Gt(e,t,n,i,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.tmpLocalTransform_,l=o.globalAlpha;this.imageOpacity_!=1&&(o.globalAlpha=l*this.imageOpacity_);let h=this.imageRotation_;this.transformRotation_===0&&(h-=this.viewRotation_),this.imageRotateWithView_&&(h+=this.viewRotation_);for(let c=0,u=r.length;c<u;c+=2){const d=r[c]-this.imageAnchorX_,f=r[c+1]-this.imageAnchorY_;if(h!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){const g=d+this.imageAnchorX_,m=f+this.imageAnchorY_;ct(a,g,m,1,1,h,-g,-m),o.save(),o.transform.apply(o,a),o.translate(g,m),o.scale(this.imageScale_[0],this.imageScale_[1]),o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),o.restore()}else o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,d,f,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(o.globalAlpha=l)}drawText_(e,t,n,i){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);const r=Gt(e,t,n,i,this.transform_,this.pixelCoordinates_),o=this.context_;let a=this.textRotation_;for(this.transformRotation_===0&&(a-=this.viewRotation_),this.textRotateWithView_&&(a+=this.viewRotation_);t<n;t+=i){const l=r[t]+this.textOffsetX_,h=r[t+1]+this.textOffsetY_;a!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(o.save(),o.translate(l-this.textOffsetX_,h-this.textOffsetY_),o.rotate(a),o.translate(this.textOffsetX_,this.textOffsetY_),o.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&o.strokeText(this.text_,0,0),this.textFillState_&&o.fillText(this.text_,0,0),o.restore()):(this.textStrokeState_&&o.strokeText(this.text_,l,h),this.textFillState_&&o.fillText(this.text_,l,h))}}moveToLineTo_(e,t,n,i,r){const o=this.context_,a=Gt(e,t,n,i,this.transform_,this.pixelCoordinates_);o.moveTo(a[0],a[1]);let l=a.length;r&&(l-=2);for(let h=2;h<l;h+=2)o.lineTo(a[h],a[h+1]);return r&&o.closePath(),n}drawRings_(e,t,n,i){for(let r=0,o=n.length;r<o;++r)t=this.moveToLineTo_(e,t,n[r],i,!0);return t}drawCircle(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Te(this.extent_,e.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const t=wg(e,this.transform_,this.pixelCoordinates_),n=t[2]-t[0],i=t[3]-t[1],r=Math.sqrt(n*n+i*i),o=this.context_;o.beginPath(),o.arc(t[0],t[1],r,0,2*Math.PI),this.fillState_&&o.fill(),this.strokeState_&&o.stroke()}this.text_!==""&&this.drawText_(e.getCenter(),0,2,2)}}setStyle(e){this.setFillStrokeStyle(e.getFill(),e.getStroke()),this.setImageStyle(e.getImage()),this.setTextStyle(e.getText())}setTransform(e){this.transform_=e}drawGeometry(e){switch(e.getType()){case"Point":this.drawPoint(e);break;case"LineString":this.drawLineString(e);break;case"Polygon":this.drawPolygon(e);break;case"MultiPoint":this.drawMultiPoint(e);break;case"MultiLineString":this.drawMultiLineString(e);break;case"MultiPolygon":this.drawMultiPolygon(e);break;case"GeometryCollection":this.drawGeometryCollection(e);break;case"Circle":this.drawCircle(e);break}}drawFeature(e,t){const n=t.getGeometryFunction()(e);n&&(this.setStyle(t),this.drawGeometry(n))}drawGeometryCollection(e){const t=e.getGeometriesArray();for(let n=0,i=t.length;n<i;++n)this.drawGeometry(t[n])}drawPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const t=e.getFlatCoordinates(),n=e.getStride();this.image_&&this.drawImages_(t,0,t.length,n),this.text_!==""&&this.drawText_(t,0,t.length,n)}drawMultiPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const t=e.getFlatCoordinates(),n=e.getStride();this.image_&&this.drawImages_(t,0,t.length,n),this.text_!==""&&this.drawText_(t,0,t.length,n)}drawLineString(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Te(this.extent_,e.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const t=this.context_,n=e.getFlatCoordinates();t.beginPath(),this.moveToLineTo_(n,0,n.length,e.getStride(),!1),t.stroke()}if(this.text_!==""){const t=e.getFlatMidpoint();this.drawText_(t,0,2,2)}}}drawMultiLineString(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const t=e.getExtent();if(Te(this.extent_,t)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const n=this.context_,i=e.getFlatCoordinates();let r=0;const o=e.getEnds(),a=e.getStride();n.beginPath();for(let l=0,h=o.length;l<h;++l)r=this.moveToLineTo_(i,r,o[l],a,!1);n.stroke()}if(this.text_!==""){const n=e.getFlatMidpoints();this.drawText_(n,0,n.length,2)}}}drawPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Te(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const t=this.context_;t.beginPath(),this.drawRings_(e.getOrientedFlatCoordinates(),0,e.getEnds(),e.getStride()),this.fillState_&&t.fill(),this.strokeState_&&t.stroke()}if(this.text_!==""){const t=e.getFlatInteriorPoint();this.drawText_(t,0,2,2)}}}drawMultiPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Te(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const t=this.context_,n=e.getOrientedFlatCoordinates();let i=0;const r=e.getEndss(),o=e.getStride();t.beginPath();for(let a=0,l=r.length;a<l;++a){const h=r[a];i=this.drawRings_(n,i,h,o)}this.fillState_&&t.fill(),this.strokeState_&&t.stroke()}if(this.text_!==""){const t=e.getFlatInteriorPoints();this.drawText_(t,0,t.length,2)}}}setContextFillState_(e){const t=this.context_,n=this.contextFillState_;n?n.fillStyle!=e.fillStyle&&(n.fillStyle=e.fillStyle,t.fillStyle=e.fillStyle):(t.fillStyle=e.fillStyle,this.contextFillState_={fillStyle:e.fillStyle})}setContextStrokeState_(e){const t=this.context_,n=this.contextStrokeState_;n?(n.lineCap!=e.lineCap&&(n.lineCap=e.lineCap,t.lineCap=e.lineCap),Bt(n.lineDash,e.lineDash)||t.setLineDash(n.lineDash=e.lineDash),n.lineDashOffset!=e.lineDashOffset&&(n.lineDashOffset=e.lineDashOffset,t.lineDashOffset=e.lineDashOffset),n.lineJoin!=e.lineJoin&&(n.lineJoin=e.lineJoin,t.lineJoin=e.lineJoin),n.lineWidth!=e.lineWidth&&(n.lineWidth=e.lineWidth,t.lineWidth=e.lineWidth),n.miterLimit!=e.miterLimit&&(n.miterLimit=e.miterLimit,t.miterLimit=e.miterLimit),n.strokeStyle!=e.strokeStyle&&(n.strokeStyle=e.strokeStyle,t.strokeStyle=e.strokeStyle)):(t.lineCap=e.lineCap,t.setLineDash(e.lineDash),t.lineDashOffset=e.lineDashOffset,t.lineJoin=e.lineJoin,t.lineWidth=e.lineWidth,t.miterLimit=e.miterLimit,t.strokeStyle=e.strokeStyle,this.contextStrokeState_={lineCap:e.lineCap,lineDash:e.lineDash,lineDashOffset:e.lineDashOffset,lineJoin:e.lineJoin,lineWidth:e.lineWidth,miterLimit:e.miterLimit,strokeStyle:e.strokeStyle})}setContextTextState_(e){const t=this.context_,n=this.contextTextState_,i=e.textAlign?e.textAlign:Is;n?(n.font!=e.font&&(n.font=e.font,t.font=e.font),n.textAlign!=i&&(n.textAlign=i,t.textAlign=i),n.textBaseline!=e.textBaseline&&(n.textBaseline=e.textBaseline,t.textBaseline=e.textBaseline)):(t.font=e.font,t.textAlign=i,t.textBaseline=e.textBaseline,this.contextTextState_={font:e.font,textAlign:i,textBaseline:e.textBaseline})}setFillStrokeStyle(e,t){if(!e)this.fillState_=null;else{const n=e.getColor();this.fillState_={fillStyle:Ot(n||Je)}}if(!t)this.strokeState_=null;else{const n=t.getColor(),i=t.getLineCap(),r=t.getLineDash(),o=t.getLineDashOffset(),a=t.getLineJoin(),l=t.getWidth(),h=t.getMiterLimit(),c=r||nn;this.strokeState_={lineCap:i!==void 0?i:Bi,lineDash:this.pixelRatio_===1?c:c.map(u=>u*this.pixelRatio_),lineDashOffset:(o||sn)*this.pixelRatio_,lineJoin:a!==void 0?a:zi,lineWidth:(l!==void 0?l:As)*this.pixelRatio_,miterLimit:h!==void 0?h:ws,strokeStyle:Ot(n||Ps)}}}setImageStyle(e){let t;if(!e||!(t=e.getSize())){this.image_=null;return}const n=e.getPixelRatio(this.pixelRatio_),i=e.getAnchor(),r=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=i[0]*n,this.imageAnchorY_=i[1]*n,this.imageHeight_=t[1]*n,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();const o=e.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/n,o[1]*this.pixelRatio_/n],this.imageWidth_=t[0]*n}setTextStyle(e){if(!e)this.text_="";else{const t=e.getFill();if(!t)this.textFillState_=null;else{const f=t.getColor();this.textFillState_={fillStyle:Ot(f||Je)}}const n=e.getStroke();if(!n)this.textStrokeState_=null;else{const f=n.getColor(),g=n.getLineCap(),m=n.getLineDash(),_=n.getLineDashOffset(),p=n.getLineJoin(),y=n.getWidth(),E=n.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:Bi,lineDash:m||nn,lineDashOffset:_||sn,lineJoin:p!==void 0?p:zi,lineWidth:y!==void 0?y:As,miterLimit:E!==void 0?E:ws,strokeStyle:Ot(f||Ps)}}const i=e.getFont(),r=e.getOffsetX(),o=e.getOffsetY(),a=e.getRotateWithView(),l=e.getRotation(),h=e.getScaleArray(),c=e.getText(),u=e.getTextAlign(),d=e.getTextBaseline();this.textState_={font:i!==void 0?i:Iu,textAlign:u!==void 0?u:Is,textBaseline:d!==void 0?d:kr},this.text_=c!==void 0?Array.isArray(c)?c.reduce((f,g,m)=>f+=m%2?" ":g,""):c:"",this.textOffsetX_=r!==void 0?this.pixelRatio_*r:0,this.textOffsetY_=o!==void 0?this.pixelRatio_*o:0,this.textRotateWithView_=a!==void 0?a:!1,this.textRotation_=l!==void 0?l:0,this.textScale_=[this.pixelRatio_*h[0],this.pixelRatio_*h[1]]}}}const ot=.5;function Vu(s,e,t,n,i,r,o,a,l){const h=l?so(i):i,c=s[0]*ot,u=s[1]*ot,d=we(c,u);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new pp(d,ot,i,null,o,a,l?Gs(pg(),l):null),m=t.length,_=Math.floor((256*256*256-1)/m),p={};for(let E=1;E<=m;++E){const x=t[E-1],T=x.getStyleFunction()||n;if(!T)continue;let R=T(x,r);if(!R)continue;Array.isArray(R)||(R=[R]);const v=(E*_).toString(16).padStart(7,"#00000");for(let w=0,I=R.length;w<I;++w){const F=R[w],A=F.getGeometryFunction()(x);if(!A||!Te(h,A.getExtent()))continue;const M=F.clone(),b=M.getFill();b&&b.setColor(v);const K=M.getStroke();K&&(K.setColor(v),K.setLineDash(null)),M.setText(void 0);const L=F.getImage();if(L){const Q=L.getImageSize();if(!Q)continue;const le=we(Q[0],Q[1],void 0,{alpha:!1}),P=le.canvas;le.fillStyle=v,le.fillRect(0,0,P.width,P.height),M.setImage(new Ki({img:P,anchor:L.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:L.getOrigin(),opacity:1,size:L.getSize(),scale:L.getScale(),rotation:L.getRotation(),rotateWithView:L.getRotateWithView()}))}const Z=M.getZIndex()||0;let G=p[Z];G||(G={},p[Z]=G,G.Polygon=[],G.Circle=[],G.LineString=[],G.Point=[]);const H=A.getType();if(H==="GeometryCollection"){const Q=A.getGeometriesArrayRecursive();for(let le=0,P=Q.length;le<P;++le){const Ge=Q[le];G[Ge.getType().replace("Multi","")].push(Ge,M)}}else G[H.replace("Multi","")].push(A,M)}}const y=Object.keys(p).map(Number).sort(Nt);for(let E=0,x=y.length;E<x;++E){const T=p[y[E]];for(const R in T){const S=T[R];for(let v=0,w=S.length;v<w;v+=2){g.setStyle(S[v+1]);for(let I=0,F=e.length;I<F;++I)g.setTransform(e[I]),g.drawGeometry(S[v])}}}return d.getImageData(0,0,f.width,f.height)}function Zu(s,e,t){const n=[];if(t){const i=Math.floor(Math.round(s[0])*ot),r=Math.floor(Math.round(s[1])*ot),o=(ge(i,0,t.width-1)+ge(r,0,t.height-1)*t.width)*4,a=t.data[o],l=t.data[o+1],c=t.data[o+2]+256*(l+256*a),u=Math.floor((256*256*256-1)/e.length);c&&c%u===0&&n.push(e[c/u-1])}return n}const yp=.5,Ku={Point:wp,LineString:Rp,Polygon:Ip,MultiPoint:Pp,MultiLineString:Sp,MultiPolygon:vp,GeometryCollection:Cp,Circle:Ep};function xp(s,e){return parseInt(D(s),10)-parseInt(D(e),10)}function ka(s,e){const t=Hu(s,e);return t*t}function Hu(s,e){return yp*s/e}function Ep(s,e,t,n,i){const r=t.getFill(),o=t.getStroke();if(r||o){const l=s.getBuilder(t.getZIndex(),"Circle");l.setFillStrokeStyle(r,o),l.drawCircle(e,n,i)}const a=t.getText();if(a&&a.getText()){const l=s.getBuilder(t.getZIndex(),"Text");l.setTextStyle(a),l.drawText(e,n)}}function Yr(s,e,t,n,i,r,o,a){const l=[],h=t.getImage();if(h){let d=!0;const f=h.getImageState();f==U.LOADED||f==U.ERROR?d=!1:f==U.IDLE&&h.load(),d&&l.push(h.ready())}const c=t.getFill();c&&c.loading()&&l.push(c.ready());const u=l.length>0;return u&&Promise.all(l).then(()=>i(null)),Tp(s,e,t,n,r,o,a),u}function Tp(s,e,t,n,i,r,o){const a=t.getGeometryFunction()(e);if(!a)return;const l=a.simplifyTransformed(n,i);if(t.getRenderer())qu(s,l,t,e,o);else{const c=Ku[l.getType()];c(s,l,t,e,o,r)}}function qu(s,e,t,n,i){if(e.getType()=="GeometryCollection"){const o=e.getGeometries();for(let a=0,l=o.length;a<l;++a)qu(s,o[a],t,n,i);return}s.getBuilder(t.getZIndex(),"Default").drawCustom(e,n,t.getRenderer(),t.getHitDetectionRenderer(),i)}function Cp(s,e,t,n,i,r){const o=e.getGeometriesArray();let a,l;for(a=0,l=o.length;a<l;++a){const h=Ku[o[a].getType()];h(s,o[a],t,n,i,r)}}function Rp(s,e,t,n,i){const r=t.getStroke();if(r){const a=s.getBuilder(t.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawLineString(e,n,i)}const o=t.getText();if(o&&o.getText()){const a=s.getBuilder(t.getZIndex(),"Text");a.setTextStyle(o),a.drawText(e,n,i)}}function Sp(s,e,t,n,i){const r=t.getStroke();if(r){const a=s.getBuilder(t.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawMultiLineString(e,n,i)}const o=t.getText();if(o&&o.getText()){const a=s.getBuilder(t.getZIndex(),"Text");a.setTextStyle(o),a.drawText(e,n,i)}}function vp(s,e,t,n,i){const r=t.getFill(),o=t.getStroke();if(o||r){const l=s.getBuilder(t.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawMultiPolygon(e,n,i)}const a=t.getText();if(a&&a.getText()){const l=s.getBuilder(t.getZIndex(),"Text");l.setTextStyle(a),l.drawText(e,n,i)}}function wp(s,e,t,n,i,r){const o=t.getImage(),a=t.getText(),l=a&&a.getText(),h=r&&o&&l?{}:void 0;if(o){if(o.getImageState()!=U.LOADED)return;const c=s.getBuilder(t.getZIndex(),"Image");c.setImageStyle(o,h),c.drawPoint(e,n,i)}if(l){const c=s.getBuilder(t.getZIndex(),"Text");c.setTextStyle(a,h),c.drawText(e,n,i)}}function Pp(s,e,t,n,i,r){const o=t.getImage(),a=o&&o.getOpacity()!==0,l=t.getText(),h=l&&l.getText(),c=r&&a&&h?{}:void 0;if(a){if(o.getImageState()!=U.LOADED)return;const u=s.getBuilder(t.getZIndex(),"Image");u.setImageStyle(o,c),u.drawMultiPoint(e,n,i)}if(h){const u=s.getBuilder(t.getZIndex(),"Text");u.setTextStyle(l,c),u.drawText(e,n,i)}}function Ip(s,e,t,n,i){const r=t.getFill(),o=t.getStroke();if(r||o){const l=s.getBuilder(t.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawPolygon(e,n,i)}const a=t.getText();if(a&&a.getText()){const l=s.getBuilder(t.getZIndex(),"Text");l.setTextStyle(a),l.drawText(e,n,i)}}class Ju extends zl{constructor(e){super(e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=tt(),this.wrappedRenderedExtent_=tt(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(e,t,n){const i=t.extent,r=t.viewState,o=r.center,a=r.resolution,l=r.projection,h=r.rotation,c=l.getExtent(),u=this.getLayer().getSource(),d=this.getLayer().getDeclutter(),f=t.pixelRatio,g=t.viewHints,m=!(g[he.ANIMATING]||g[he.INTERACTING]),_=this.context,p=Math.round(ie(i)/a*f),y=Math.round(be(i)/a*f),E=u.getWrapX()&&l.canWrapX(),x=E?ie(c):null,T=E?Math.ceil((i[2]-c[2])/x)+1:1;let R=E?Math.floor((i[0]-c[0])/x):0;do{let S=this.getRenderTransform(o,a,0,f,p,y,R*x);t.declutter&&(S=S.slice(0)),e.execute(_,[_.canvas.width,_.canvas.height],S,h,m,n===void 0?Un:n?Xr:_p,n?d&&t.declutter[d]:void 0)}while(++R<T)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=we(this.context.canvas.width,this.context.canvas.height,sc))}resetDrawContext_(){if(this.opacity_!==1&&this.targetContext_){const e=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=e,ho(this.context),sc.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(e){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,e,!0)}renderDeferredInternal(e){this.replayGroup_&&(this.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(e,t){const n=e.layerStatesArray[e.layerIndex];this.opacity_=n.opacity;const i=e.viewState;this.prepareContainer(e,t);const r=this.context,o=this.replayGroup_;let a=o&&!o.isEmpty();if(!a&&!(this.getLayer().hasListener(Me.PRERENDER)||this.getLayer().hasListener(Me.POSTRENDER)))return this.container;if(this.setDrawContext_(),this.preRender(r,e),i.projection,this.clipped_=!1,a&&n.extent&&this.clipping){const l=wt(n.extent);a=Te(l,e.extent),this.clipped_=a&&!yn(l,e.extent),this.clipped_&&this.clipUnrotated(r,e,l)}return a&&this.renderWorlds(o,e,this.getLayer().getDeclutter()?!1:void 0),!e.declutter&&this.clipped_&&r.restore(),this.postRender(r,e),this.renderedRotation_!==i.rotation&&(this.renderedRotation_=i.rotation,this.hitDetectionImageData_=null),e.declutter||this.resetDrawContext_(),this.container}getFeatures(e){return new Promise(t=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const n=this.frameState.size.slice(),i=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],u=n[0]*ot,d=n[1]*ot;c.push(this.getRenderTransform(i,r,o,ot,u,d,0).slice());const f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!yn(g,l)){let m=l[0];const _=ie(g);let p=0,y;for(;m<g[0];)--p,y=_*p,c.push(this.getRenderTransform(i,r,o,ot,u,d,y).slice()),m+=_;for(p=0,m=l[2];m>g[2];)++p,y=_*p,c.push(this.getRenderTransform(i,r,o,ot,u,d,y).slice()),m-=_}this.hitDetectionImageData_=Vu(n,c,this.renderedFeatures_,h.getStyleFunction(),l,r,o,ka(r,this.renderedPixelRatio_),null)}t(Zu(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,t,n,i,r){if(!this.replayGroup_)return;const o=t.viewState.resolution,a=t.viewState.rotation,l=this.getLayer(),h={},c=function(d,f,g){const m=D(d),_=h[m];if(_){if(_!==!0&&g<_.distanceSq){if(g===0)return h[m]=!0,r.splice(r.lastIndexOf(_),1),i(d,l,f);_.geometry=f,_.distanceSq=g}}else{if(g===0)return h[m]=!0,i(d,l,f);r.push(h[m]={feature:d,layer:l,geometry:f,distanceSq:g,callback:i})}},u=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(e,o,a,n,c,u?t.declutter?.[u]?.all().map(d=>d.value):null)}handleFontsChanged(){const e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){const t=this.getLayer(),n=t.getSource();if(!n)return!1;const i=e.viewHints[he.ANIMATING],r=e.viewHints[he.INTERACTING],o=t.getUpdateWhileAnimating(),a=t.getUpdateWhileInteracting();if(this.ready&&!o&&i||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=e.extent,h=e.viewState,c=h.projection,u=h.resolution,d=e.pixelRatio,f=t.getRevision(),g=t.getRenderBuffer();let m=t.getRenderOrder();m===void 0&&(m=xp);const _=h.center.slice(),p=rn(l,g*u),y=p.slice(),E=[p.slice()],x=c.getExtent();if(n.getWrapX()&&c.canWrapX()&&!yn(x,e.extent)){const b=ie(x),K=Math.max(ie(p)/2,b);p[0]=x[0]-K,p[2]=x[2]+K,il(_,c);const L=Xc(E[0],c);L[0]<x[0]&&L[2]<x[2]?E.push([L[0]+b,L[1],L[2]+b,L[3]]):L[0]>x[0]&&L[2]>x[2]&&E.push([L[0]-b,L[1],L[2]-b,L[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==f&&this.renderedRenderOrder_==m&&this.renderedFrameDeclutter_===!!e.declutter&&yn(this.wrappedRenderedExtent_,p))return Bt(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=_,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const T=new ju(Hu(u,d),p,u,d);let R;for(let b=0,K=E.length;b<K;++b)n.loadFeatures(E[b],u,c);const S=ka(u,d);let v=!0;const w=(b,K)=>{let L;const Z=b.getStyleFunction()||t.getStyleFunction();if(Z&&(L=Z(b,u)),L){const G=this.renderFeature(b,S,L,T,R,this.getLayer().getDeclutter(),K);v=v&&!G}},I=so(p),F=n.getFeaturesInExtent(I);m&&F.sort(m);for(let b=0,K=F.length;b<K;++b)w(F[b],b);this.renderedFeatures_=F,this.ready=v;const A=T.finish(),M=new Wu(p,u,d,n.getOverlaps(),A,t.getRenderBuffer(),!!e.declutter);return this.renderedResolution_=u,this.renderedRevision_=f,this.renderedRenderOrder_=m,this.renderedFrameDeclutter_=!!e.declutter,this.renderedExtent_=y,this.wrappedRenderedExtent_=p,this.renderedCenter_=_,this.renderedProjection_=c,this.renderedPixelRatio_=d,this.replayGroup_=M,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(e,t,n,i,r,o,a){if(!n)return!1;let l=!1;if(Array.isArray(n))for(let h=0,c=n.length;h<c;++h)l=Yr(i,e,n[h],t,this.boundHandleStyleImageChange_,r,o,a)||l;else l=Yr(i,e,n,t,this.boundHandleStyleImageChange_,r,o,a);return l}}class Xl extends Hi{constructor(e){super(e)}createRenderer(){return new Ju(this)}}class Ap extends lm{constructor(e,t,n,i,r){const o=r!==void 0?U.IDLE:U.LOADED;super(e,t,n,o),this.loader_=r!==void 0?r:null,this.canvas_=i,this.error_=null}getError(){return this.error_}handleLoad_(e){e?(this.error_=e,this.state=U.ERROR):this.state=U.LOADED,this.changed()}load(){this.state==U.IDLE&&(this.state=U.LOADING,this.changed(),this.loader_(this.handleLoad_.bind(this)))}getImage(){return this.canvas_}}function Lp(s){return Array.isArray(s)?Math.min(...s):s}class Fp extends Xu{constructor(e){super(e),this.vectorRenderer_=new Ju(e),this.layerImageRatio_=e.getImageRatio(),this.coordinateToVectorPixelTransform_=Ce(),this.renderedPixelToCoordinateTransform_=null}disposeInternal(){this.vectorRenderer_.dispose(),super.disposeInternal()}getFeatures(e){if(!this.vectorRenderer_)return Promise.resolve([]);const t=fe(this.coordinateToVectorPixelTransform_,fe(this.renderedPixelToCoordinateTransform_,e.slice()));return this.vectorRenderer_.getFeatures(t)}handleFontsChanged(){this.vectorRenderer_.handleFontsChanged()}prepareFrame(e){const t=e.pixelRatio,n=e.viewState,i=n.resolution,r=e.viewHints,o=this.vectorRenderer_;let a=e.extent;this.layerImageRatio_!==1&&(a=a.slice(0),Af(a,this.layerImageRatio_));const l=ie(a)/i,h=be(a)/i;if(!r[he.ANIMATING]&&!r[he.INTERACTING]&&!ni(a)){o.useContainer(null,null);const c=o.context,u=e.layerStatesArray[e.layerIndex],d=Object.assign({},u,{opacity:1}),f=Object.assign({},e,{extent:a,size:[l,h],viewState:Object.assign({},e.viewState,{rotation:0}),layerStatesArray:[d],layerIndex:0,declutter:null}),g=this.getLayer().getDeclutter();g&&(f.declutter={[g]:new Al(9)});const m=new Ap(a,i,t,c.canvas,function(_){o.prepareFrame(f)&&o.replayGroupChanged&&(o.clipping=!1,o.renderFrame(f,null),o.renderDeclutter(f),o.renderDeferred(f),_())});m.addEventListener(V.CHANGE,()=>{if(m.getState()!==U.LOADED)return;this.image=m;const _=m.getPixelRatio(),p=Lp(m.getResolution())*t/_;this.renderedResolution=p,this.coordinateToVectorPixelTransform_=ct(this.coordinateToVectorPixelTransform_,l/2,h/2,1/p,-1/p,0,-n.center[0],-n.center[1])}),m.load()}return this.image&&(this.renderedPixelToCoordinateTransform_=e.pixelToCoordinateTransform.slice()),!this.getLayer().getSource()?.loading&&!!this.image}preRender(){}postRender(){}renderDeclutter(){}forEachFeatureAtCoordinate(e,t,n,i,r){return this.vectorRenderer_?this.vectorRenderer_.forEachFeatureAtCoordinate(e,t,n,i,r):super.forEachFeatureAtCoordinate(e,t,n,i,r)}}class G0 extends Hi{constructor(e){e=e||{};const t=Object.assign({},e);delete t.imageRatio,super(t),this.imageRatio_=e.imageRatio!==void 0?e.imageRatio:1}getImageRatio(){return this.imageRatio_}createRenderer(){return new Fp(this)}}let Mp=!1;function bp(s,e,t,n,i,r,o){const a=new XMLHttpRequest;a.open("GET",typeof s=="function"?s(t,n,i):s,!0),e.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=Mp,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){const h=e.getType();try{let c;h=="text"||h=="json"?c=a.responseText:h=="xml"?c=a.responseXML||a.responseText:h=="arraybuffer"&&(c=a.response),c?r(e.readFeatures(c,{extent:t,featureProjection:i}),e.readProjection(c)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function cc(s,e){return function(t,n,i,r,o){bp(s,e,t,n,i,(a,l)=>{this.addFeatures(a),r!==void 0&&r(a)},()=>{this.changed(),o!==void 0&&o()})}}function Dp(s,e){return[[-1/0,-1/0,1/0,1/0]]}class $e extends Rt{constructor(e){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),e)if(typeof e.getSimplifiedGeometry=="function"){const t=e;this.setGeometry(t)}else{const t=e;this.setProperties(t)}}clone(){const e=new $e(this.hasProperties()?this.getProperties():null);e.setGeometryName(this.getGeometryName());const t=this.getGeometry();t&&e.setGeometry(t.clone());const n=this.getStyle();return n&&e.setStyle(n),e}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(ue(this.geometryChangeKey_),this.geometryChangeKey_=null);const e=this.getGeometry();e&&(this.geometryChangeKey_=J(e,V.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(e){this.set(this.geometryName_,e)}setStyle(e){this.style_=e,this.styleFunction_=e?Op(e):void 0,this.changed()}setId(e){this.id_=e,this.changed()}setGeometryName(e){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=e,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}}function Op(s){if(typeof s=="function")return s;let e;return Array.isArray(s)?e=s:(te(typeof s.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),e=[s]),function(){return e}}function Qu(s,e,t,n){const i=[];let r=tt();for(let o=0,a=t.length;o<a;++o){const l=t[o];r=Qa(s,e,l[0],n),i.push((r[0]+r[2])/2,(r[1]+r[3])/2),e=l[l.length-1]}return i}function jr(s,e,t,n,i,r,o){let a,l;const h=(t-e)/n;if(h===1)a=e;else if(h===2)a=e,l=i;else if(h!==0){let c=s[e],u=s[e+1],d=0;const f=[0];for(let _=e+n;_<t;_+=n){const p=s[_],y=s[_+1];d+=Math.sqrt((p-c)*(p-c)+(y-u)*(y-u)),f.push(d),c=p,u=y}const g=i*d,m=af(f,g);m<0?(l=(g-f[-m-2])/(f[-m-1]-f[-m-2]),a=e+(-m-2)*n):a=e+m*n}o=o>1?o:2,r=r||new Array(o);for(let c=0;c<o;++c)r[c]=a===void 0?NaN:l===void 0?s[a+c]:rt(s[a+c],s[a+n+c],l);return r}function Ua(s,e,t,n,i,r){if(t==e)return null;let o;if(i<s[e+n-1])return r?(o=s.slice(e,e+n),o[n-1]=i,o):null;if(s[t-1]<i)return r?(o=s.slice(t-n,t),o[n-1]=i,o):null;if(i==s[e+n-1])return s.slice(e,e+n);let a=e/n,l=t/n;for(;a<l;){const d=a+l>>1;i<s[(d+1)*n-1]?l=d:a=d+1}const h=s[a*n-1];if(i==h)return s.slice((a-1)*n,(a-1)*n+n);const c=s[(a+1)*n-1],u=(i-h)/(c-h);o=[];for(let d=0;d<n-1;++d)o.push(rt(s[(a-1)*n+d],s[a*n+d],u));return o.push(i),o}function Np(s,e,t,n,i,r,o){if(o)return Ua(s,e,t[t.length-1],n,i,r);let a;if(i<s[n-1])return r?(a=s.slice(0,n),a[n-1]=i,a):null;if(s[s.length-1]<i)return r?(a=s.slice(s.length-n),a[n-1]=i,a):null;for(let l=0,h=t.length;l<h;++l){const c=t[l];if(e!=c){if(i<s[e+n-1])return null;if(i<=s[c-1])return Ua(s,e,c,n,i,!1);e=c}}return null}class mo extends Mn{constructor(e,t,n){super(),n!==void 0&&t===void 0?this.setFlatCoordinates(n,e):(t=t||0,this.setCenterAndRadius(e,t,n))}clone(){const e=new mo(this.flatCoordinates.slice(),void 0,this.layout);return e.applyProperties(this),e}closestPointXY(e,t,n,i){const r=this.flatCoordinates,o=e-r[0],a=t-r[1],l=o*o+a*a;if(l<i){if(l===0)for(let h=0;h<this.stride;++h)n[h]=r[h];else{const h=this.getRadius()/Math.sqrt(l);n[0]=r[0]+h*o,n[1]=r[1]+h*a;for(let c=2;c<this.stride;++c)n[c]=r[c]}return n.length=this.stride,l}return i}containsXY(e,t){const n=this.flatCoordinates,i=e-n[0],r=t-n[1];return i*i+r*r<=this.getRadiusSquared_()}getCenter(){return this.flatCoordinates.slice(0,this.stride)}computeExtent(e){const t=this.flatCoordinates,n=t[this.stride]-t[0];return Ut(t[0]-n,t[1]-n,t[0]+n,t[1]+n,e)}getRadius(){return Math.sqrt(this.getRadiusSquared_())}getRadiusSquared_(){const e=this.flatCoordinates[this.stride]-this.flatCoordinates[0],t=this.flatCoordinates[this.stride+1]-this.flatCoordinates[1];return e*e+t*t}getType(){return"Circle"}intersectsExtent(e){const t=this.getExtent();if(Te(e,t)){const n=this.getCenter();return e[0]<=n[0]&&e[2]>=n[0]||e[1]<=n[1]&&e[3]>=n[1]?!0:el(e,this.intersectsCoordinate.bind(this))}return!1}setCenter(e){const t=this.stride,n=this.flatCoordinates[t]-this.flatCoordinates[0],i=e.slice();i[t]=i[0]+n;for(let r=1;r<t;++r)i[t+r]=e[r];this.setFlatCoordinates(this.layout,i),this.changed()}setCenterAndRadius(e,t,n){this.setLayout(n,e,0),this.flatCoordinates||(this.flatCoordinates=[]);const i=this.flatCoordinates;let r=ou(i,0,e,this.stride);i[r++]=i[0]+t;for(let o=1,a=this.stride;o<a;++o)i[r++]=i[o];i.length=r,this.changed()}getCoordinates(){return null}setCoordinates(e,t){}setRadius(e){this.flatCoordinates[this.stride]=this.flatCoordinates[0]+e,this.changed()}rotate(e,t){const n=this.getCenter(),i=this.getStride();this.setCenter(cl(n,0,n.length,i,e,t,n)),this.changed()}}mo.prototype.transform;class He extends iu{constructor(e){super(),this.geometries_=e,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(ue),this.changeEventsKeys_.length=0}listenGeometriesChange_(){const e=this.geometries_;for(let t=0,n=e.length;t<n;++t)this.changeEventsKeys_.push(J(e[t],V.CHANGE,this.changed,this))}clone(){const e=new He(Qo(this.geometries_));return e.applyProperties(this),e}closestPointXY(e,t,n,i){if(i<ti(this.getExtent(),e,t))return i;const r=this.geometries_;for(let o=0,a=r.length;o<a;++o)i=r[o].closestPointXY(e,t,n,i);return i}containsXY(e,t){const n=this.geometries_;for(let i=0,r=n.length;i<r;++i)if(n[i].containsXY(e,t))return!0;return!1}computeExtent(e){ji(e);const t=this.geometries_;for(let n=0,i=t.length;n<i;++n)Bc(e,t[n].getExtent());return e}getGeometries(){return Qo(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let e=[];const t=this.geometries_;for(let n=0,i=t.length;n<i;++n)t[n].getType()===this.getType()?e=e.concat(t[n].getGeometriesArrayRecursive()):e.push(t[n]);return e}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<this.simplifiedGeometryMaxMinSquaredTolerance)return this;const t=[],n=this.geometries_;let i=!1;for(let r=0,o=n.length;r<o;++r){const a=n[r],l=a.getSimplifiedGeometry(e);t.push(l),l!==a&&(i=!0)}return i?new He(t):(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getType(){return"GeometryCollection"}intersectsExtent(e){const t=this.geometries_;for(let n=0,i=t.length;n<i;++n)if(t[n].intersectsExtent(e))return!0;return!1}isEmpty(){return this.geometries_.length===0}rotate(e,t){const n=this.geometries_;for(let i=0,r=n.length;i<r;++i)n[i].rotate(e,t);this.changed()}scale(e,t,n){n||(n=In(this.getExtent()));const i=this.geometries_;for(let r=0,o=i.length;r<o;++r)i[r].scale(e,t,n);this.changed()}setGeometries(e){this.setGeometriesArray(Qo(e))}setGeometriesArray(e){this.unlistenGeometriesChange_(),this.geometries_=e,this.listenGeometriesChange_(),this.changed()}applyTransform(e){const t=this.geometries_;for(let n=0,i=t.length;n<i;++n)t[n].applyTransform(e);this.changed()}translate(e,t){const n=this.geometries_;for(let i=0,r=n.length;i<r;++i)n[i].translate(e,t);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}}function Qo(s){return s.map(e=>e.clone())}class ht extends Mn{constructor(e,t){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,t!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(t,e):this.setCoordinates(e,t)}appendCoordinate(e){ne(this.flatCoordinates,e),this.changed()}clone(){const e=new ht(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,t,n,i){return i<ti(this.getExtent(),e,t)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(ul(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),fl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,e,t,n,i))}forEachSegment(e){return cu(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinateAtM(e,t){return this.layout!="XYM"&&this.layout!="XYZM"?null:(t=t!==void 0?t:!1,Ua(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t))}getCoordinates(){return xn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(e,t){return jr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t,this.stride)}getLength(){return $l(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_??void 0),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(e){const t=[];return t.length=ao(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t,0),new ht(t,"XY")}getType(){return"LineString"}intersectsExtent(e){return lo(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,this.getExtent())}setCoordinates(e,t){this.setLayout(t,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=oo(this.flatCoordinates,0,e,this.stride),this.changed()}}class on extends Mn{constructor(e,t,n){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(e[0]))this.setCoordinates(e,t);else if(t!==void 0&&n)this.setFlatCoordinates(t,e),this.ends_=n;else{const i=e,r=[],o=[];for(let l=0,h=i.length;l<h;++l){const c=i[l];ne(r,c.getFlatCoordinates()),o.push(r.length)}const a=i.length===0?this.getLayout():i[0].getLayout();this.setFlatCoordinates(a,r),this.ends_=o}}appendLineString(e){ne(this.flatCoordinates,e.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const e=new on(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,t,n,i){return i<ti(this.getExtent(),e,t)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(dl(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),gl(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,e,t,n,i))}getCoordinateAtM(e,t,n){return this.layout!="XYM"&&this.layout!="XYZM"||this.flatCoordinates.length===0?null:(t=t!==void 0?t:!1,n=n!==void 0?n:!1,Np(this.flatCoordinates,0,this.ends_,this.stride,e,t,n))}getCoordinates(){return Ss(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(e){return e<0||this.ends_.length<=e?null:new ht(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLineStrings(){const e=this.flatCoordinates,t=this.ends_,n=this.layout,i=[];let r=0;for(let o=0,a=t.length;o<a;++o){const l=t[o],h=new ht(e.slice(r,l),n);i.push(h),r=l}return i}getLength(){const e=this.ends_;let t=0,n=0;for(let i=0,r=e.length;i<r;++i)n+=$l(this.flatCoordinates,t,e[i],this.stride),t=e[i];return n}getFlatMidpoints(){const e=[],t=this.flatCoordinates;let n=0;const i=this.ends_,r=this.stride;for(let o=0,a=i.length;o<a;++o){const l=i[o],h=jr(t,n,l,r,.5);ne(e,h),n=l}return e}getSimplifiedGeometryInternal(e){const t=[],n=[];return t.length=lu(this.flatCoordinates,0,this.ends_,this.stride,e,t,0,n),new on(t,"XY",n)}getType(){return"MultiLineString"}intersectsExtent(e){return Dg(this.flatCoordinates,0,this.ends_,this.stride,e)}setCoordinates(e,t){this.setLayout(t,e,2),this.flatCoordinates||(this.flatCoordinates=[]);const n=Us(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=n.length===0?0:n[n.length-1],this.changed()}}class oi extends Mn{constructor(e,t){super(),t&&!Array.isArray(e[0])?this.setFlatCoordinates(t,e):this.setCoordinates(e,t)}appendPoint(e){ne(this.flatCoordinates,e.getFlatCoordinates()),this.changed()}clone(){const e=new oi(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,t,n,i){if(i<ti(this.getExtent(),e,t))return i;const r=this.flatCoordinates,o=this.stride;for(let a=0,l=r.length;a<l;a+=o){const h=Qt(e,t,r[a],r[a+1]);if(h<i){i=h;for(let c=0;c<o;++c)n[c]=r[a+c];n.length=o}}return i}getCoordinates(){return xn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(e){const t=this.flatCoordinates.length/this.stride;return e<0||t<=e?null:new lt(this.flatCoordinates.slice(e*this.stride,(e+1)*this.stride),this.layout)}getPoints(){const e=this.flatCoordinates,t=this.layout,n=this.stride,i=[];for(let r=0,o=e.length;r<o;r+=n){const a=new lt(e.slice(r,r+n),t);i.push(a)}return i}getType(){return"MultiPoint"}intersectsExtent(e){const t=this.flatCoordinates,n=this.stride;for(let i=0,r=t.length;i<r;i+=n){const o=t[i],a=t[i+1];if(Ja(e,o,a))return!0}return!1}setCoordinates(e,t){this.setLayout(t,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=oo(this.flatCoordinates,0,e,this.stride),this.changed()}}class An extends Mn{constructor(e,t,n){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!n&&!Array.isArray(e[0])){const i=e,r=[],o=[];for(let a=0,l=i.length;a<l;++a){const h=i[a],c=r.length,u=h.getEnds();for(let d=0,f=u.length;d<f;++d)u[d]+=c;ne(r,h.getFlatCoordinates()),o.push(u)}t=i.length===0?this.getLayout():i[0].getLayout(),e=r,n=o}t!==void 0&&n?(this.setFlatCoordinates(t,e),this.endss_=n):this.setCoordinates(e,t)}appendPolygon(e){let t;if(!this.flatCoordinates)this.flatCoordinates=e.getFlatCoordinates().slice(),t=e.getEnds().slice(),this.endss_.push();else{const n=this.flatCoordinates.length;ne(this.flatCoordinates,e.getFlatCoordinates()),t=e.getEnds().slice();for(let i=0,r=t.length;i<r;++i)t[i]+=n}this.endss_.push(t),this.changed()}clone(){const e=this.endss_.length,t=new Array(e);for(let i=0;i<e;++i)t[i]=this.endss_[i].slice();const n=new An(this.flatCoordinates.slice(),this.layout,t);return n.applyProperties(this),n}closestPointXY(e,t,n,i){return i<ti(this.getExtent(),e,t)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Ig(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ag(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,e,t,n,i))}containsXY(e,t){return bg(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e,t)}getArea(){return Pg(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(e){let t;return e!==void 0?(t=this.getOrientedFlatCoordinates().slice(),Ia(t,0,this.endss_,this.stride,e)):t=this.flatCoordinates,Pa(t,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const e=Qu(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=hu(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new oi(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const e=this.flatCoordinates;fu(e,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=Ia(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){const t=[],n=[];return t.length=Fg(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(e),t,0,n),new An(t,"XY",n)}getPolygon(e){if(e<0||this.endss_.length<=e)return null;let t;if(e===0)t=0;else{const r=this.endss_[e-1];t=r[r.length-1]}const n=this.endss_[e].slice(),i=n[n.length-1];if(t!==0)for(let r=0,o=n.length;r<o;++r)n[r]-=t;return new qe(this.flatCoordinates.slice(t,i),this.layout,n)}getPolygons(){const e=this.layout,t=this.flatCoordinates,n=this.endss_,i=[];let r=0;for(let o=0,a=n.length;o<a;++o){const l=n[o].slice(),h=l[l.length-1];if(r!==0)for(let u=0,d=l.length;u<d;++u)l[u]-=r;const c=new qe(t.slice(r,h),e,l);i.push(c),r=h}return i}getType(){return"MultiPolygon"}intersectsExtent(e){return Og(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e)}setCoordinates(e,t){this.setLayout(t,e,3),this.flatCoordinates||(this.flatCoordinates=[]);const n=au(this.flatCoordinates,0,e,this.stride,this.endss_);if(n.length===0)this.flatCoordinates.length=0;else{const i=n[n.length-1];this.flatCoordinates.length=i.length===0?0:i[i.length-1]}this.changed()}}const uc=Ce();class Qe{constructor(e,t,n,i,r,o){this.styleFunction,this.extent_,this.id_=o,this.type_=e,this.flatCoordinates_=t,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=n||null,this.properties_=r,this.squaredTolerance_,this.stride_=i,this.simplifiedGeometry_}get(e){return this.properties_[e]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?fs(this.flatCoordinates_):Qa(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const e=In(this.getExtent());this.flatInteriorPoints_=pl(this.flatCoordinates_,0,this.ends_,2,e,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const e=gu(this.flatCoordinates_,this.ends_),t=Qu(this.flatCoordinates_,0,e,2);this.flatInteriorPoints_=hu(this.flatCoordinates_,0,e,2,t)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=jr(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const e=this.flatCoordinates_;let t=0;const n=this.ends_;for(let i=0,r=n.length;i<r;++i){const o=n[i],a=jr(e,t,o,2,.5);ne(this.flatMidpoints_,a),t=o}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(e){return this}simplifyTransformed(e,t){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(e){e=de(e);const t=e.getExtent(),n=e.getWorldExtent();if(t&&n){const i=be(n)/be(t);ct(uc,n[0],n[3],i,-i,0,0,0),Gt(this.flatCoordinates_,0,this.flatCoordinates_.length,2,uc,this.flatCoordinates_)}}applyTransform(e){e(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new Qe(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Dc((e,t)=>{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),t&&this.simplifiedGeometry_.applyTransform(t);const n=this.simplifiedGeometry_.getFlatCoordinates();let i;switch(this.type_){case"LineString":n.length=ao(n,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,n,0),i=[n.length];break;case"MultiLineString":i=[],n.length=lu(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,n,0,i);break;case"Polygon":i=[],n.length=_l(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),n,0,i);break}return i&&(this.simplifiedGeometry_=new Qe(this.type_,n,i,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}}Qe.prototype.getFlatCoordinates=Qe.prototype.getOrientedFlatCoordinates;class Ba{constructor(e){this.rbush_=new Al(e),this.items_={}}insert(e,t){const n={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3],value:t};this.rbush_.insert(n),this.items_[D(t)]=n}load(e,t){const n=new Array(t.length);for(let i=0,r=t.length;i<r;i++){const o=e[i],a=t[i],l={minX:o[0],minY:o[1],maxX:o[2],maxY:o[3],value:a};n[i]=l,this.items_[D(a)]=l}this.rbush_.load(n)}remove(e){const t=D(e),n=this.items_[t];return delete this.items_[t],this.rbush_.remove(n)!==null}update(e,t){const n=this.items_[D(t)],i=[n.minX,n.minY,n.maxX,n.maxY];Hn(i,e)||(this.remove(t),this.insert(e,t))}getAll(){return this.rbush_.all().map(function(t){return t.value})}getInExtent(e){const t={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]};return this.rbush_.search(t).map(function(i){return i.value})}forEach(e){return this.forEach_(this.getAll(),e)}forEachInExtent(e,t){return this.forEach_(this.getInExtent(e),t)}forEach_(e,t){let n;for(let i=0,r=e.length;i<r;i++)if(n=t(e[i]),n)return n;return n}isEmpty(){return Vn(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(e){const t=this.rbush_.toJSON();return Ut(t.minX,t.minY,t.maxX,t.maxY,e)}concat(e){this.rbush_.load(e.rbush_.all());for(const t in e.items_)this.items_[t]=e.items_[t]}}class ed extends Rt{constructor(e){super(),this.projection=de(e.projection),this.attributions_=dc(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible??!0,this.loading=!1,this.state_=e.state!==void 0?e.state:"ready",this.wrapX_=e.wrapX!==void 0?e.wrapX:!1,this.interpolate_=!!e.interpolate,this.viewResolver=null,this.viewRejector=null;const t=this;this.viewPromise_=new Promise(function(n,i){t.viewResolver=n,t.viewRejector=i})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(e){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(e){this.attributions_=dc(e),this.changed()}setState(e){this.state_=e,this.changed()}}function dc(s){return s?typeof s=="function"?s:(Array.isArray(s)||(s=[s]),e=>s):null}const Le={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};class gn extends ut{constructor(e,t,n){super(e),this.feature=t,this.features=n}}class td extends ed{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:e.wrapX!==void 0?e.wrapX:!0}),this.on,this.once,this.un,this.loader_=Ts,this.format_=e.format||null,this.overlaps_=e.overlaps===void 0?!0:e.overlaps,this.url_=e.url,e.loader!==void 0?this.loader_=e.loader:this.url_!==void 0&&(te(this.format_,"`format` must be set when `url` is set"),this.loader_=cc(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:Dp;const t=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=t?new Ba:null,this.loadedExtentsRtree_=new Ba,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let n,i;Array.isArray(e.features)?i=e.features:e.features&&(n=e.features,i=n.getArray()),!t&&n===void 0&&(n=new Ze(i)),i!==void 0&&this.addFeaturesInternal(i),n!==void 0&&this.bindFeaturesCollection_(n)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){const t=D(e);if(!this.addToIndex_(t,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(t,e);const n=e.getGeometry();if(n){const i=n.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(i,e)}else this.nullGeometryFeatures_[t]=e;this.dispatchEvent(new gn(Le.ADDFEATURE,e))}setupChangeEvents_(e,t){t instanceof Qe||(this.featureChangeKeys_[e]=[J(t,V.CHANGE,this.handleFeatureChange_,this),J(t,Ni.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,t){let n=!0;if(t.getId()!==void 0){const i=String(t.getId());if(!(i in this.idIndex_))this.idIndex_[i]=t;else if(t instanceof Qe){const r=this.idIndex_[i];r instanceof Qe?Array.isArray(r)?r.push(t):this.idIndex_[i]=[r,t]:n=!1}else n=!1}return n&&(te(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=t),n}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){const t=[],n=[],i=[];for(let r=0,o=e.length;r<o;r++){const a=e[r],l=D(a);this.addToIndex_(l,a)&&n.push(a)}for(let r=0,o=n.length;r<o;r++){const a=n[r],l=D(a);this.setupChangeEvents_(l,a);const h=a.getGeometry();if(h){const c=h.getExtent();t.push(c),i.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(t,i),this.hasListener(Le.ADDFEATURE))for(let r=0,o=n.length;r<o;r++)this.dispatchEvent(new gn(Le.ADDFEATURE,n[r]))}bindFeaturesCollection_(e){let t=!1;this.addEventListener(Le.ADDFEATURE,function(n){t||(t=!0,e.push(n.feature),t=!1)}),this.addEventListener(Le.REMOVEFEATURE,function(n){t||(t=!0,e.remove(n.feature),t=!1)}),e.addEventListener(Se.ADD,n=>{t||(t=!0,this.addFeature(n.element),t=!1)}),e.addEventListener(Se.REMOVE,n=>{t||(t=!0,this.removeFeature(n.element),t=!1)}),this.featuresCollection_=e}clear(e){if(e){for(const n in this.featureChangeKeys_)this.featureChangeKeys_[n].forEach(ue);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(n=>{this.removeFeatureInternal(n)});for(const n in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[n])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const t=new gn(Le.CLEAR);this.dispatchEvent(t),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,t){const n=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(n,function(i){const r=i.getGeometry();if(r instanceof Qe||r.intersectsCoordinate(e))return t(i)})}forEachFeatureInExtent(e,t){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureIntersectingExtent(e,t){return this.forEachFeatureInExtent(e,function(n){const i=n.getGeometry();if(i instanceof Qe||i.intersectsExtent(e)){const r=t(n);if(r)return r}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let e;return this.featuresCollection_?e=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(e=this.featuresRtree_.getAll(),Vn(this.nullGeometryFeatures_)||ne(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){const t=[];return this.forEachFeatureAtCoordinateDirect(e,function(n){t.push(n)}),t}getFeaturesInExtent(e,t){if(this.featuresRtree_){if(!(t&&t.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);const i=Yc(e,t);return[].concat(...i.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,t){const n=e[0],i=e[1];let r=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return t=t||Pn,this.featuresRtree_.forEachInExtent(l,function(h){if(t(h)){const c=h.getGeometry(),u=a;if(a=c instanceof Qe?0:c.closestPointXY(n,i,o,a),a<u){r=h;const d=Math.sqrt(a);l[0]=n-d,l[1]=i-d,l[2]=n+d,l[3]=i+d}}}),r}getExtent(e){return this.featuresRtree_.getExtent(e)}getFeatureById(e){const t=this.idIndex_[e.toString()];return t!==void 0?t:null}getFeatureByUid(e){const t=this.uidIndex_[e];return t!==void 0?t:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(e){const t=e.target,n=D(t),i=t.getGeometry();if(!i)n in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(t),this.nullGeometryFeatures_[n]=t);else{const o=i.getExtent();n in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[n],this.featuresRtree_&&this.featuresRtree_.insert(o,t)):this.featuresRtree_&&this.featuresRtree_.update(o,t)}const r=t.getId();if(r!==void 0){const o=r.toString();this.idIndex_[o]!==t&&(this.removeFromIdIndex_(t),this.idIndex_[o]=t)}else this.removeFromIdIndex_(t),this.uidIndex_[n]=t;this.changed(),this.dispatchEvent(new gn(Le.CHANGEFEATURE,t))}hasFeature(e){const t=e.getId();return t!==void 0?t in this.idIndex_:D(e)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Vn(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(e,t,n){const i=this.loadedExtentsRtree_,r=this.strategy_(e,t,n);for(let o=0,a=r.length;o<a;++o){const l=r[o];i.forEachInExtent(l,function(c){return yn(c.extent,l)})||(++this.loadingExtentsCount_,this.dispatchEvent(new gn(Le.FEATURESLOADSTART)),this.loader_.call(this,l,t,n,c=>{--this.loadingExtentsCount_,this.dispatchEvent(new gn(Le.FEATURESLOADEND,void 0,c))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new gn(Le.FEATURESLOADERROR))}),i.insert(l,{extent:l.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){const t=this.loadedExtentsRtree_,n=t.forEachInExtent(e,function(i){if(Hn(i.extent,e))return i});n&&t.remove(n)}removeFeatures(e){let t=!1;for(let n=0,i=e.length;n<i;++n)t=this.removeFeatureInternal(e[n])||t;t&&this.changed()}removeFeature(e){if(!e)return;this.removeFeatureInternal(e)&&this.changed()}removeFeatureInternal(e){const t=D(e);if(!(t in this.uidIndex_))return!1;t in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[t]:this.featuresRtree_&&this.featuresRtree_.remove(e),this.featureChangeKeys_[t]?.forEach(ue),delete this.featureChangeKeys_[t];const i=e.getId();if(i!==void 0){const r=i.toString(),o=this.idIndex_[r];o===e?delete this.idIndex_[r]:Array.isArray(o)&&(o.splice(o.indexOf(e),1),o.length===1&&(this.idIndex_[r]=o[0]))}return delete this.uidIndex_[t],this.hasListener(Le.REMOVEFEATURE)&&this.dispatchEvent(new gn(Le.REMOVEFEATURE,e)),!0}removeFromIdIndex_(e){for(const t in this.idIndex_)if(this.idIndex_[t]===e){delete this.idIndex_[t];break}}setLoader(e){this.loader_=e}setUrl(e){te(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(cc(e,this.format_))}setOverlaps(e){this.overlaps_=e,this.changed()}}const fc=4;function nd(s,e){const t=[];Object.keys(e).forEach(function(i){e[i]!==null&&e[i]!==void 0&&t.push(i+"="+encodeURIComponent(e[i]))});const n=t.join("&");return s=s.replace(/[?&]$/,""),s+=s.includes("?")?"&":"?",s+n}const Gp=/\{z\}/g,kp=/\{x\}/g,Up=/\{y\}/g,Bp=/\{-y\}/g;function zp(s,e,t,n,i){return s.replace(Gp,e.toString()).replace(kp,t.toString()).replace(Up,n.toString()).replace(Bp,function(){if(i===void 0)throw new Error("If the URL template has a {-y} placeholder, the grid extent must be known");return(i-n).toString()})}function $p(s){const e=[];let t=/\{([a-z])-([a-z])\}/.exec(s);if(t){const n=t[1].charCodeAt(0),i=t[2].charCodeAt(0);let r;for(r=n;r<=i;++r)e.push(s.replace(t[0],String.fromCharCode(r)));return e}if(t=/\{(\d+)-(\d+)\}/.exec(s),t){const n=parseInt(t[2],10);for(let i=parseInt(t[1],10);i<=n;i++)e.push(s.replace(t[0],i.toString()));return e}return e.push(s),e}const za="1.3.0";function Xp(s,e,t,n,i){i.WIDTH=t[0],i.HEIGHT=t[1];const r=n.getAxisOrientation(),o=jc(i.VERSION,"1.3")>=0;i[o?"CRS":"SRS"]=n.getCode();const a=o&&r.startsWith("ne")?[e[1],e[0],e[3],e[2]]:e;return i.BBOX=a.join(","),nd(s,i)}function Yp(s,e,t,n,i,r,o){r=Object.assign({REQUEST:"GetMap"},r);const a=e/t,l=[Eh(ie(s)/a,fc),Eh(be(s)/a,fc)];if(t!=1)switch(o){case"geoserver":const c=90*t+.5|0;"FORMAT_OPTIONS"in r?r.FORMAT_OPTIONS+=";dpi:"+c:r.FORMAT_OPTIONS="dpi:"+c;break;case"mapserver":r.MAP_RESOLUTION=90*t;break;case"carmentaserver":case"qgis":r.DPI=90*t;break;default:throw new Error("Unknown `serverType` configured")}return Xp(i,s,l,n,r)}function gc(s,e){return Object.assign({REQUEST:e,SERVICE:"WMS",VERSION:za,FORMAT:"image/png",STYLES:"",TRANSPARENT:"TRUE"},s)}const pi=[0,0,0],_n=5;class id{constructor(e){this.minZoom=e.minZoom!==void 0?e.minZoom:0,this.resolutions_=e.resolutions,te(cf(this.resolutions_,(i,r)=>r-i),"`resolutions` must be sorted in descending order");let t;if(!e.origins){for(let i=0,r=this.resolutions_.length-1;i<r;++i)if(!t)t=this.resolutions_[i]/this.resolutions_[i+1];else if(this.resolutions_[i]/this.resolutions_[i+1]!==t){t=void 0;break}}this.zoomFactor_=t,this.maxZoom=this.resolutions_.length-1,this.origin_=e.origin!==void 0?e.origin:null,this.origins_=null,e.origins!==void 0&&(this.origins_=e.origins,te(this.origins_.length==this.resolutions_.length,"Number of `origins` and `resolutions` must be equal"));const n=e.extent;n!==void 0&&!this.origin_&&!this.origins_&&(this.origin_=Fn(n)),te(!this.origin_&&this.origins_||this.origin_&&!this.origins_,"Either `origin` or `origins` must be configured, never both"),this.tileSizes_=null,e.tileSizes!==void 0&&(this.tileSizes_=e.tileSizes,te(this.tileSizes_.length==this.resolutions_.length,"Number of `tileSizes` and `resolutions` must be equal")),this.tileSize_=e.tileSize!==void 0?e.tileSize:this.tileSizes_?null:Rl,te(!this.tileSize_&&this.tileSizes_||this.tileSize_&&!this.tileSizes_,"Either `tileSize` or `tileSizes` must be configured, never both"),this.extent_=n!==void 0?n:null,this.fullTileRanges_=null,this.tmpSize_=[0,0],this.tmpExtent_=[0,0,0,0],e.sizes!==void 0?this.fullTileRanges_=e.sizes.map((i,r)=>{const o=new Ul(Math.min(0,i[0]),Math.max(i[0]-1,-1),Math.min(0,i[1]),Math.max(i[1]-1,-1));if(n){const a=this.getTileRangeForExtentAndZ(n,r);o.minX=Math.max(a.minX,o.minX),o.maxX=Math.min(a.maxX,o.maxX),o.minY=Math.max(a.minY,o.minY),o.maxY=Math.min(a.maxY,o.maxY)}return o}):n&&this.calculateTileRanges_(n)}forEachTileCoord(e,t,n){const i=this.getTileRangeForExtentAndZ(e,t);for(let r=i.minX,o=i.maxX;r<=o;++r)for(let a=i.minY,l=i.maxY;a<=l;++a)n([t,r,a])}forEachTileCoordParentTileRange(e,t,n,i){let r,o,a,l=null,h=e[0]-1;for(this.zoomFactor_===2?(o=e[1],a=e[2]):l=this.getTileCoordExtent(e,i);h>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),r=_i(o,o,a,a,n)):r=this.getTileRangeForExtentAndZ(l,h,n),t(h,r))return!0;--h}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(e){return this.origin_?this.origin_:this.origins_[e]}getResolution(e){return this.resolutions_[e]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(e,t,n){if(e[0]<this.maxZoom){if(this.zoomFactor_===2){const r=e[1]*2,o=e[2]*2;return _i(r,r+1,o,o+1,t)}const i=this.getTileCoordExtent(e,n||this.tmpExtent_);return this.getTileRangeForExtentAndZ(i,e[0]+1,t)}return null}getTileRangeForTileCoordAndZ(e,t,n){if(t>this.maxZoom||t<this.minZoom)return null;const i=e[0],r=e[1],o=e[2];if(t===i)return _i(r,o,r,o,n);if(this.zoomFactor_){const l=Math.pow(this.zoomFactor_,t-i),h=Math.floor(r*l),c=Math.floor(o*l);if(t<i)return _i(h,h,c,c,n);const u=Math.floor(l*(r+1))-1,d=Math.floor(l*(o+1))-1;return _i(h,u,c,d,n)}const a=this.getTileCoordExtent(e,this.tmpExtent_);return this.getTileRangeForExtentAndZ(a,t,n)}getTileRangeForExtentAndZ(e,t,n){this.getTileCoordForXYAndZ_(e[0],e[3],t,!1,pi);const i=pi[1],r=pi[2];this.getTileCoordForXYAndZ_(e[2],e[1],t,!0,pi);const o=pi[1],a=pi[2];return _i(i,o,r,a,n)}getTileCoordCenter(e){const t=this.getOrigin(e[0]),n=this.getResolution(e[0]),i=Xe(this.getTileSize(e[0]),this.tmpSize_);return[t[0]+(e[1]+.5)*i[0]*n,t[1]-(e[2]+.5)*i[1]*n]}getTileCoordExtent(e,t){const n=this.getOrigin(e[0]),i=this.getResolution(e[0]),r=Xe(this.getTileSize(e[0]),this.tmpSize_),o=n[0]+e[1]*r[0]*i,a=n[1]-(e[2]+1)*r[1]*i,l=o+r[0]*i,h=a+r[1]*i;return Ut(o,a,l,h,t)}getTileCoordForCoordAndResolution(e,t,n){return this.getTileCoordForXYAndResolution_(e[0],e[1],t,!1,n)}getTileCoordForXYAndResolution_(e,t,n,i,r){const o=this.getZForResolution(n),a=n/this.getResolution(o),l=this.getOrigin(o),h=Xe(this.getTileSize(o),this.tmpSize_);let c=a*(e-l[0])/n/h[0],u=a*(l[1]-t)/n/h[1];return i?(c=Js(c,_n)-1,u=Js(u,_n)-1):(c=qs(c,_n),u=qs(u,_n)),zr(o,c,u,r)}getTileCoordForXYAndZ_(e,t,n,i,r){const o=this.getOrigin(n),a=this.getResolution(n),l=Xe(this.getTileSize(n),this.tmpSize_);let h=(e-o[0])/a/l[0],c=(o[1]-t)/a/l[1];return i?(h=Js(h,_n)-1,c=Js(c,_n)-1):(h=qs(h,_n),c=qs(c,_n)),zr(n,h,c,r)}getTileCoordForCoordAndZ(e,t,n){return this.getTileCoordForXYAndZ_(e[0],e[1],t,!1,n)}getTileCoordResolution(e){return this.resolutions_[e[0]]}getTileSize(e){return this.tileSize_?this.tileSize_:this.tileSizes_[e]}getFullTileRange(e){return this.fullTileRanges_?this.fullTileRanges_[e]:this.extent_?this.getTileRangeForExtentAndZ(this.extent_,e):null}getZForResolution(e,t){const n=qa(this.resolutions_,e,t||0);return ge(n,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(e,t){return uu(t,0,t.length,2,this.getTileCoordExtent(e))}calculateTileRanges_(e){const t=this.resolutions_.length,n=new Array(t);for(let i=this.minZoom;i<t;++i)n[i]=this.getTileRangeForExtentAndZ(e,i);this.fullTileRanges_=n}}function sd(s){let e=s.getDefaultTileGrid();return e||(e=Zp(s),s.setDefaultTileGrid(e)),e}function jp(s,e,t){const n=e[0],i=s.getTileCoordCenter(e),r=Yl(t);if(!Kn(r,i)){const o=ie(r),a=Math.ceil((r[0]-i[0])/o);return i[0]+=o*a,s.getTileCoordForCoordAndZ(i,n)}return e}function Wp(s,e,t,n){n=n!==void 0?n:"top-left";const i=rd(s,e,t);return new id({extent:s,origin:Pf(s,n),resolutions:i,tileSize:t})}function Vp(s){const e=s||{},t=e.extent||de("EPSG:3857").getExtent(),n={extent:t,minZoom:e.minZoom,tileSize:e.tileSize,resolutions:rd(t,e.maxZoom,e.tileSize,e.maxResolution)};return new id(n)}function rd(s,e,t,n){e=e!==void 0?e:Xg,t=Xe(t!==void 0?t:Rl);const i=be(s),r=ie(s);n=n>0?n:Math.max(r/t[0],i/t[1]);const o=e+1,a=new Array(o);for(let l=0;l<o;++l)a[l]=n/Math.pow(2,l);return a}function Zp(s,e,t,n){const i=Yl(s);return Wp(i,e,t,n)}function Yl(s){s=de(s);let e=s.getExtent();if(!e){const t=180*ki.degrees/s.getMetersPerUnit();e=Ut(-t,-t,t,t)}return e}function Kp(s,e){return(function(t,n,i){if(!t)return;let r;const o=t[0];if(e){const a=e.getFullTileRange(o);a&&(r=a.getHeight()-1)}return zp(s,o,t[1],t[2],r)})}function Hp(s,e){const t=s.length,n=new Array(t);for(let i=0;i<t;++i)n[i]=Kp(s[i],e);return qp(n)}function qp(s){return s.length===1?s[0]:(function(e,t,n){if(!e)return;const i=Bu(e),r=en(i,s.length);return s[r](e,t,n)})}class Jp extends ed{constructor(e){super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,projection:e.projection,state:e.state,wrapX:e.wrapX,interpolate:e.interpolate}),this.on,this.once,this.un,this.tilePixelRatio_=e.tilePixelRatio!==void 0?e.tilePixelRatio:1,this.tileGrid=e.tileGrid!==void 0?e.tileGrid:null;const t=[256,256];this.tileGrid&&Xe(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),t),this.tmpSize=[0,0],this.key_=e.key||D(this),this.tileOptions={transition:e.transition,interpolate:e.interpolate},this.zDirection=e.zDirection?e.zDirection:0}getGutterForProjection(e){return 0}getKey(){return this.key_}setKey(e){this.key_!==e&&(this.key_=e,this.changed())}getResolutions(e){const t=e?this.getTileGridForProjection(e):this.tileGrid;return t?t.getResolutions():null}getTile(e,t,n,i,r,o){return $()}getTileGrid(){return this.tileGrid}getTileGridForProjection(e){return this.tileGrid?this.tileGrid:sd(e)}getTilePixelRatio(e){return this.tilePixelRatio_}getTilePixelSize(e,t,n){const i=this.getTileGridForProjection(n),r=this.getTilePixelRatio(t),o=Xe(i.getTileSize(e),this.tmpSize);return r==1?o:k_(o,r,this.tmpSize)}getTileCoordForTileUrlFunction(e,t){const n=t!==void 0?t:this.getProjection(),i=t!==void 0?this.getTileGridForProjection(n):this.tileGrid||this.getTileGridForProjection(n);return this.getWrapX()&&n.isGlobal()&&(e=jp(i,e,n)),Qm(e,i)?e:null}clear(){}refresh(){this.clear(),super.refresh()}}class Qp extends ut{constructor(e,t){super(e),this.tile=t}}const ea={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};class jl extends Jp{constructor(e){super({attributions:e.attributions,cacheSize:e.cacheSize,projection:e.projection,state:e.state,tileGrid:e.tileGrid,tilePixelRatio:e.tilePixelRatio,wrapX:e.wrapX,transition:e.transition,interpolate:e.interpolate,key:e.key,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===jl.prototype.tileUrlFunction,this.tileLoadFunction=e.tileLoadFunction,e.tileUrlFunction&&(this.tileUrlFunction=e.tileUrlFunction),this.urls=null,e.urls?this.setUrls(e.urls):e.url&&this.setUrl(e.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(e){const t=e.target,n=D(t),i=t.getState();let r;i==B.LOADING?(this.tileLoadingKeys_[n]=!0,r=ea.TILELOADSTART):n in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[n],r=i==B.ERROR?ea.TILELOADERROR:i==B.LOADED?ea.TILELOADEND:void 0),r!=null&&this.dispatchEvent(new Qp(r,t))}setTileLoadFunction(e){this.tileLoadFunction=e,this.changed()}setTileUrlFunction(e,t){this.tileUrlFunction=e,typeof t<"u"?this.setKey(t):this.changed()}setUrl(e){const t=$p(e);this.urls=t,this.setUrls(t)}setUrls(e){this.urls=e;const t=e.join(`
|
||
`);this.generateTileUrlFunction_?this.setTileUrlFunction(Hp(e,this.tileGrid),t):this.setKey(t)}tileUrlFunction(e,t,n){}}class od extends jl{constructor(e){super({attributions:e.attributions,cacheSize:e.cacheSize,projection:e.projection,state:e.state,tileGrid:e.tileGrid,tileLoadFunction:e.tileLoadFunction?e.tileLoadFunction:ad,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX,transition:e.transition,interpolate:e.interpolate!==void 0?e.interpolate:!0,key:e.key,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.crossOrigin=e.crossOrigin!==void 0?e.crossOrigin:null,this.tileClass=e.tileClass!==void 0?e.tileClass:ku,this.tileGridForProjection={},this.reprojectionErrorThreshold_=e.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(e){return this.getProjection()&&e&&!Wn(this.getProjection(),e)?0:this.getGutter()}getGutter(){return 0}getKey(){let e=super.getKey();return this.getInterpolate()||(e+=":disable-interpolation"),e}getTileGridForProjection(e){const t=this.getProjection();if(this.tileGrid&&(!t||Wn(t,e)))return this.tileGrid;const n=D(e);return n in this.tileGridForProjection||(this.tileGridForProjection[n]=sd(e)),this.tileGridForProjection[n]}createTile_(e,t,n,i,r,o){const a=[e,t,n],l=this.getTileCoordForTileUrlFunction(a,r),h=l?this.tileUrlFunction(l,i,r):void 0,c=new this.tileClass(a,h!==void 0?B.IDLE:B.EMPTY,h!==void 0?h:"",this.crossOrigin,this.tileLoadFunction,this.tileOptions);return c.key=o,c.addEventListener(V.CHANGE,this.handleTileChange.bind(this)),c}getTile(e,t,n,i,r,o){const a=this.getProjection();if(!a||!r||Wn(a,r))return this.getTileInternal(e,t,n,i,a||r);const l=[e,t,n],h=this.getKey(),c=this.getTileGridForProjection(a),u=this.getTileGridForProjection(r),d=this.getTileCoordForTileUrlFunction(l,r),f=new Uu(a,c,r,u,l,d,this.getTilePixelRatio(i),this.getGutter(),(g,m,_,p)=>this.getTileInternal(g,m,_,p,a,o),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return f.key=h,f}getTileInternal(e,t,n,i,r,o){const a=this.getKey(),l=Cr(this,a,e,t,n);if(o&&o.containsKey(l))return o.get(l);const h=this.createTile_(e,t,n,i,r,a);return o?.set(l,h),h}setRenderReprojectionEdges(e){this.renderReprojectionEdges_!=e&&(this.renderReprojectionEdges_=e,this.changed())}setTileGridForProjection(e,t){const n=de(e);if(n){const i=D(n);i in this.tileGridForProjection||(this.tileGridForProjection[i]=t)}}}function ad(s,e){if(at){const t=s.getCrossOrigin();let n="same-origin",i="same-origin";t==="anonymous"||t===""?(n="cors",i="omit"):t==="use-credentials"&&(n="cors",i="include"),fetch(e,{mode:n,credentials:i}).then(r=>{if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.blob()}).then(r=>createImageBitmap(r)).then(r=>{const o=s.getImage();o.width=r.width,o.height=r.height,o.getContext("2d").drawImage(r,0,0),r.close?.(),o.dispatchEvent(new Event("load"))}).catch(()=>{s.getImage().dispatchEvent(new Event("error"))});return}s.getImage().src=e}class k0 extends od{constructor(e){e=e||{};const t=Object.assign({},e.params);super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,projection:e.projection,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileClass:e.tileClass,tileGrid:e.tileGrid,tileLoadFunction:e.tileLoadFunction,url:e.url,urls:e.urls,wrapX:e.wrapX!==void 0?e.wrapX:!0,transition:e.transition,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0,this.params_=t,this.v13_=!0,this.serverType_=e.serverType,this.hidpi_=e.hidpi!==void 0?e.hidpi:!0,this.tmpExtent_=tt(),this.updateV13_(),this.setKey(this.getKeyForParams_())}getFeatureInfoUrl(e,t,n,i){const r=de(n),o=this.getProjection()||r;let a=this.getTileGrid();a||(a=this.getTileGridForProjection(o));const l=ks(e,r,o),h=Ga(o,r,e,t),c=a.getZForResolution(h,this.zDirection),u=a.getResolution(c),d=a.getTileCoordForCoordAndZ(l,c);if(a.getResolutions().length<=d[0])return;let f=a.getTileCoordExtent(d,this.tmpExtent_);const g=this.gutter_;g!==0&&(f=rn(f,u*g,f));const m={QUERY_LAYERS:this.params_.LAYERS};Object.assign(m,gc(this.params_,"GetFeatureInfo"),i);const _=Math.floor((l[0]-f[0])/u),p=Math.floor((f[3]-l[1])/u);return m[this.v13_?"I":"X"]=_,m[this.v13_?"J":"Y"]=p,this.getRequestUrl_(d,f,1,o||r,m)}getLegendUrl(e,t){if(this.urls[0]===void 0)return;const n={SERVICE:"WMS",VERSION:za,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(t===void 0||t.LAYER===void 0){const i=this.params_.LAYERS;if(!(!Array.isArray(i)||i.length===1))return;n.LAYER=i}if(e!==void 0){const i=this.getProjection()?this.getProjection().getMetersPerUnit():1,r=28e-5;n.SCALE=e*i/r}return Object.assign(n,t),nd(this.urls[0],n)}getGutter(){return this.gutter_}getParams(){return this.params_}getRequestUrl_(e,t,n,i,r){const o=this.urls;if(!o)return;let a;if(o.length==1)a=o[0];else{const l=en(Bu(e),o.length);a=o[l]}return Yp(t,(this.tileGrid||this.getTileGridForProjection(i)).getResolution(e[0]),n,i,a,r,this.serverType_)}getTilePixelRatio(e){return!this.hidpi_||this.serverType_===void 0?1:e}getKeyForParams_(){let e=0;const t=[];for(const n in this.params_)t[e++]=n+"-"+this.params_[n];return t.join("/")}setParams_(e){this.params_=e,this.updateV13_(),this.setKey(this.getKeyForParams_())}setParams(e){this.setParams_(Object.assign({},e))}updateParams(e){this.setParams_(Object.assign(this.params_,e))}updateV13_(){const e=this.params_.VERSION||za;this.v13_=jc(e,"1.3")>=0}tileUrlFunction(e,t,n){let i=this.getTileGrid();if(i||(i=this.getTileGridForProjection(n)),i.getResolutions().length<=e[0])return;t!=1&&(!this.hidpi_||this.serverType_===void 0)&&(t=1);const r=i.getResolution(e[0]);let o=i.getTileCoordExtent(e,this.tmpExtent_);const a=this.gutter_;a!==0&&(o=rn(o,r*a,o));const l=Object.assign({},gc(this.params_,"GetMap"));return this.getRequestUrl_(e,o,t,n,l)}}class ey extends od{constructor(e){e=e||{};const t=e.projection!==void 0?e.projection:"EPSG:3857",n=e.tileGrid!==void 0?e.tileGrid:Vp({extent:Yl(t),maxResolution:e.maxResolution,maxZoom:e.maxZoom,minZoom:e.minZoom,tileSize:e.tileSize});super({attributions:e.attributions,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,projection:t,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileGrid:n,tileLoadFunction:e.tileLoadFunction,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX!==void 0?e.wrapX:!0,transition:e.transition,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0}getGutter(){return this.gutter_}}const ty='© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.';class U0 extends ey{constructor(e){e=e||{};let t;e.attributions!==void 0?t=e.attributions:t=[ty];const n=e.crossOrigin!==void 0?e.crossOrigin:"anonymous",i=e.url!==void 0?e.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:t,attributionsCollapsible:!1,cacheSize:e.cacheSize,crossOrigin:n,interpolate:e.interpolate,maxZoom:e.maxZoom!==void 0?e.maxZoom:19,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileLoadFunction:(r,o)=>{const a=r.getImage();!at&&a instanceof HTMLImageElement&&(a.referrerPolicy="origin-when-cross-origin"),(e.tileLoadFunction||ad)(r,o)},transition:e.transition,url:i,wrapX:e.wrapX,zDirection:e.zDirection})}}class Wl{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=$e,this.supportedMediaTypes=null}getReadOptions(e,t){if(t){let n=t.dataProjection?de(t.dataProjection):this.readProjection(e);t.extent&&n&&n.getUnits()==="tile-pixels"&&(n=de(n),n.setWorldExtent(t.extent)),t={dataProjection:n,featureProjection:t.featureProjection}}return this.adaptOptions(t)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return $()}readFeature(e,t){return $()}readFeatures(e,t){return $()}readGeometry(e,t){return $()}readProjection(e){return $()}writeFeature(e,t){return $()}writeFeatures(e,t){return $()}writeGeometry(e,t){return $()}}function Qn(s,e,t){const n=t?de(t.featureProjection):null,i=t?de(t.dataProjection):null;let r=s;if(n&&i&&!Wn(n,i)){e&&(r=s.clone());const o=e?n:i,a=e?i:n;o.getUnits()==="tile-pixels"?r.transform(o,a):r.applyTransform(qn(o,a))}if(e&&t&&t.decimals!==void 0){const o=Math.pow(10,t.decimals),a=function(l){for(let h=0,c=l.length;h<c;++h)l[h]=Math.round(l[h]*o)/o;return l};r===s&&(r=s.clone()),r.applyTransform(a)}return r}const ny={Point:lt,LineString:ht,Polygon:qe,MultiPoint:oi,MultiLineString:on,MultiPolygon:An};function iy(s,e,t){return Array.isArray(e[0])?(fu(s,0,e,t)||(s=s.slice(),Ia(s,0,e,t)),s):(xl(s,0,e,t)||(s=s.slice(),br(s,0,e,t)),s)}function ld(s,e){const t=s.geometry;if(!t)return[];if(Array.isArray(t))return t.map(r=>ld({...s,geometry:r})).flat();const n=t.type==="MultiPolygon"?"Polygon":t.type;if(n==="GeometryCollection"||n==="Circle")throw new Error("Unsupported geometry type: "+n);const i=t.layout.length;return Qn(new Qe(n,n==="Polygon"?iy(t.flatCoordinates,t.ends,i):t.flatCoordinates,t.ends?.flat(),i,s.properties||{},s.id).enableSimplifyTransformed(),!1,e)}function Vl(s,e){if(!s)return null;if(Array.isArray(s)){const n=s.map(i=>Vl(i,e));return new He(n)}const t=ny[s.type];return Qn(new t(s.flatCoordinates,s.layout||"XY",s.ends),!1,e)}class sy extends Wl{constructor(){super()}getType(){return"json"}readFeature(e,t){return this.readFeatureFromObject(lr(e),this.getReadOptions(e,t))}readFeatures(e,t){return this.readFeaturesFromObject(lr(e),this.getReadOptions(e,t))}readFeatureFromObject(e,t){return $()}readFeaturesFromObject(e,t){return $()}readGeometry(e,t){return this.readGeometryFromObject(lr(e),this.getReadOptions(e,t))}readGeometryFromObject(e,t){return $()}readProjection(e){return this.readProjectionFromObject(lr(e))}readProjectionFromObject(e){return $()}writeFeature(e,t){return JSON.stringify(this.writeFeatureObject(e,t))}writeFeatureObject(e,t){return $()}writeFeatures(e,t){return JSON.stringify(this.writeFeaturesObject(e,t))}writeFeaturesObject(e,t){return $()}writeGeometry(e,t){return JSON.stringify(this.writeGeometryObject(e,t))}writeGeometryObject(e,t){return $()}}function lr(s){if(typeof s=="string"){const e=JSON.parse(s);return e||null}return s!==null?s:null}class B0 extends sy{constructor(e){e=e||{},super(),this.dataProjection=de(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=de(e.featureProjection)),e.featureClass&&(this.featureClass=e.featureClass),this.geometryName_=e.geometryName,this.extractGeometryName_=e.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(e,t){let n=null;e.type==="Feature"?n=e:n={type:"Feature",geometry:e,properties:null};const i=Zl(n.geometry);if(this.featureClass===Qe)return ld({geometry:i,id:n.id,properties:n.properties},t);const r=new $e;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&n.geometry_name&&r.setGeometryName(n.geometry_name),r.setGeometry(Vl(i,t)),"id"in n&&r.setId(n.id),n.properties&&r.setProperties(n.properties,!0),r}readFeaturesFromObject(e,t){const n=e;let i=null;if(n.type==="FeatureCollection"){const r=e;i=[];const o=r.features;for(let a=0,l=o.length;a<l;++a){const h=this.readFeatureFromObject(o[a],t);h&&i.push(h)}}else i=[this.readFeatureFromObject(e,t)];return i.flat()}readGeometryFromObject(e,t){return ry(e,t)}readProjectionFromObject(e){const t=e.crs;let n;if(t)if(t.type=="name")n=de(t.properties.name);else if(t.type==="EPSG")n=de("EPSG:"+t.properties.code);else throw new Error("Unknown SRS type");else n=this.dataProjection;return n}writeFeatureObject(e,t){t=this.adaptOptions(t);const n={type:"Feature",geometry:null,properties:null},i=e.getId();if(i!==void 0&&(n.id=i),!e.hasProperties())return n;const r=e.getProperties(),o=e.getGeometry();return o&&(n.geometry=$a(o,t),delete r[e.getGeometryName()]),Vn(r)||(n.properties=r),n}writeFeaturesObject(e,t){t=this.adaptOptions(t);const n=[];for(let i=0,r=e.length;i<r;++i)n.push(this.writeFeatureObject(e[i],t));return{type:"FeatureCollection",features:n}}writeGeometryObject(e,t){return $a(e,this.adaptOptions(t))}}function Zl(s,e){if(!s)return null;let t;switch(s.type){case"Point":{t=ay(s);break}case"LineString":{t=ly(s);break}case"Polygon":{t=dy(s);break}case"MultiPoint":{t=cy(s);break}case"MultiLineString":{t=hy(s);break}case"MultiPolygon":{t=uy(s);break}case"GeometryCollection":{t=oy(s);break}default:throw new Error("Unsupported GeoJSON type: "+s.type)}return t}function ry(s,e){const t=Zl(s);return Vl(t,e)}function oy(s,e){return s.geometries.map(function(n){return Zl(n)})}function ay(s){const e=s.coordinates;return{type:"Point",flatCoordinates:e,layout:ii(e.length)}}function ly(s){const e=s.coordinates,t=e.flat();return{type:"LineString",flatCoordinates:t,ends:[t.length],layout:ii(e[0]?.length||2)}}function hy(s){const e=s.coordinates,t=e[0]?.[0]?.length||2,n=[],i=Us(n,0,e,t);return{type:"MultiLineString",flatCoordinates:n,ends:i,layout:ii(t)}}function cy(s){const e=s.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:ii(e[0]?.length||2)}}function uy(s){const e=s.coordinates,t=[],n=e[0]?.[0]?.[0].length||2,i=au(t,0,e,n);return{type:"MultiPolygon",flatCoordinates:t,ends:i,layout:ii(n)}}function dy(s){const e=s.coordinates,t=[],n=e[0]?.[0]?.length,i=Us(t,0,e,n);return{type:"Polygon",flatCoordinates:t,ends:i,layout:ii(n)}}function $a(s,e){s=Qn(s,!0,e);const t=s.getType();let n;switch(t){case"Point":{n=yy(s);break}case"LineString":{n=gy(s);break}case"Polygon":{n=xy(s,e);break}case"MultiPoint":{n=my(s);break}case"MultiLineString":{n=_y(s);break}case"MultiPolygon":{n=py(s,e);break}case"GeometryCollection":{n=fy(s,e);break}case"Circle":{n={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+t)}return n}function fy(s,e){return e=Object.assign({},e),delete e.featureProjection,{type:"GeometryCollection",geometries:s.getGeometriesArray().map(function(n){return $a(n,e)})}}function gy(s,e){return{type:"LineString",coordinates:s.getCoordinates()}}function _y(s,e){return{type:"MultiLineString",coordinates:s.getCoordinates()}}function my(s,e){return{type:"MultiPoint",coordinates:s.getCoordinates()}}function py(s,e){let t;return e&&(t=e.rightHanded),{type:"MultiPolygon",coordinates:s.getCoordinates(t)}}function yy(s,e){return{type:"Point",coordinates:s.getCoordinates()}}function xy(s,e){let t;return e&&(t=e.rightHanded),{type:"Polygon",coordinates:s.getCoordinates(t)}}const ta="units",Ey=[1,2,5],ls=25.4/.28;class z0 extends co{constructor(e){e=e||{};const t=document.createElement("div");t.style.pointerEvents="none",super({element:t,render:e.render,target:e.target}),this.on,this.once,this.un;const n=e.className!==void 0?e.className:e.bar?"ol-scale-bar":"ol-scale-line";this.innerElement_=document.createElement("div"),this.innerElement_.className=n+"-inner",this.element.className=n+" "+Bs,this.element.appendChild(this.innerElement_),this.viewState_=null,this.minWidth_=e.minWidth!==void 0?e.minWidth:64,this.maxWidth_=e.maxWidth,this.renderedVisible_=!1,this.renderedWidth_=void 0,this.renderedHTML_="",this.addChangeListener(ta,this.handleUnitsChanged_),this.setUnits(e.units||"metric"),this.scaleBar_=e.bar||!1,this.scaleBarSteps_=e.steps||4,this.scaleBarText_=e.text||!1,this.dpi_=e.dpi||void 0}getUnits(){return this.get(ta)}handleUnitsChanged_(){this.updateElement_()}setUnits(e){this.set(ta,e)}setDpi(e){this.dpi_=e}updateElement_(){const e=this.viewState_;if(!e){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const t=e.center,n=e.projection,i=this.getUnits(),r=i=="degrees"?"degrees":"m";let o=Fr(n,e.resolution,t,r);const a=this.minWidth_*(this.dpi_||ls)/ls,l=this.maxWidth_!==void 0?this.maxWidth_*(this.dpi_||ls)/ls:void 0;let h=a*o,c="";if(i=="degrees"){const E=ki.degrees;h*=E,h<E/60?(c="″",o*=3600):h<E?(c="′",o*=60):c="°"}else if(i=="imperial")h<.9144?(c="in",o/=.0254):h<1609.344?(c="ft",o/=.3048):(c="mi",o/=1609.344);else if(i=="nautical")o/=1852,c="NM";else if(i=="metric")h<1e-6?(c="nm",o*=1e9):h<.001?(c="μm",o*=1e6):h<1?(c="mm",o*=1e3):h<1e3?c="m":(c="km",o/=1e3);else if(i=="us")h<.9144?(c="in",o*=39.37):h<1609.344?(c="ft",o/=.30480061):(c="mi",o/=1609.3472);else throw new Error("Invalid units");let u=3*Math.floor(Math.log(a*o)/Math.log(10)),d,f,g,m=0,_,p;for(;;){g=Math.floor(u/3);const E=Math.pow(10,g);if(d=Ey[(u%3+3)%3]*E,f=Math.round(d/o),isNaN(f)){this.element.style.display="none",this.renderedVisible_=!1;return}if(l!==void 0&&f>=l){d=m,f=_,g=p;break}else if(f>=a)break;m=d,_=f,p=g,++u}const y=this.scaleBar_?this.createScaleBar(f,d,c):d.toFixed(g<0?-g:0)+" "+c;this.renderedHTML_!=y&&(this.innerElement_.innerHTML=y,this.renderedHTML_=y),this.renderedWidth_!=f&&(this.innerElement_.style.width=f+"px",this.renderedWidth_=f),this.renderedVisible_||(this.element.style.display="",this.renderedVisible_=!0)}createScaleBar(e,t,n){const i=this.getScaleForResolution(),r=i<1?Math.round(1/i).toLocaleString()+" : 1":"1 : "+Math.round(i).toLocaleString(),o=this.scaleBarSteps_,a=e/o,l=[this.createMarker("absolute")];for(let c=0;c<o;++c){const u=c%2===0?"ol-scale-singlebar-odd":"ol-scale-singlebar-even";l.push(`<div><div class="ol-scale-singlebar ${u}" style="width: ${a}px;"></div>`+this.createMarker("relative")+(c%2===0||o===2?this.createStepText(c,e,!1,t,n):"")+"</div>")}return l.push(this.createStepText(o,e,!0,t,n)),(this.scaleBarText_?`<div class="ol-scale-text" style="width: ${e}px;">`+r+"</div>":"")+l.join("")}createMarker(e){return`<div class="ol-scale-step-marker" style="position: ${e}; top: ${e==="absolute"?3:-10}px;"></div>`}createStepText(e,t,n,i,r){const a=(e===0?0:Math.round(i/this.scaleBarSteps_*e*100)/100)+(e===0?"":" "+r),l=e===0?-3:t/this.scaleBarSteps_*-1,h=e===0?0:t/this.scaleBarSteps_*2;return`<div class="ol-scale-step-text" style="margin-left: ${l}px;text-align: ${e===0?"left":"center"};min-width: ${h}px;left: ${n?t+"px":"unset"};">`+a+"</div>"}getScaleForResolution(){const e=Fr(this.viewState_.projection,this.viewState_.resolution,this.viewState_.center,"m"),t=this.dpi_||ls,n=1e3/25.4;return e*n*t}render(e){const t=e.frameState;t?this.viewState_=t.viewState:this.viewState_=null,this.updateElement_()}}const Ty={image:["Polygon","Circle","LineString","Image","Text"],hybrid:["Polygon","LineString"],vector:[]},_c={hybrid:["Image","Text","Default"],vector:["Polygon","Circle","LineString","Image","Text","Default"]};class Cy extends $u{constructor(e,t){super(e,t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.renderedLayerRevision_,this.renderedPixelToCoordinateTransform_=null,this.renderedRotation_,this.renderedOpacity_=1,this.tmpTransform_=Ce(),this.tileClipContexts_=null}enqueueTilesForNextExtent(){return this.getLayer().getRenderMode()!=="vector"}drawTile(e,t,n,i,r,o,a,l){this.updateExecutorGroup_(e,t.pixelRatio,t.viewState.projection),this.tileImageNeedsRender_(e)&&this.renderTileImage_(e,t),super.drawTile(e,t,n,i,r,o,a,l)}getTile(e,t,n,i){const r=this.getOrCreateTile(e,t,n,i);if(!r)return null;const o=i.viewState,a=o.resolution,l=i.viewHints,h=this.getLayer().getSource(),c=h.getTileGridForProjection(o.projection),u=!(l[he.ANIMATING]||l[he.INTERACTING]),d=c.getZForResolution(a,h.zDirection)===e;return u&&d?r.wantedResolution=a:r.wantedResolution||(r.wantedResolution=c.getResolution(e)),r}prepareFrame(e){const t=this.getLayer().getRevision();return this.renderedLayerRevision_!==t&&(this.renderedLayerRevision_=t,this.renderedTiles.length=0),super.prepareFrame(e)}updateExecutorGroup_(e,t,n){const i=this.getLayer(),r=i.getRevision(),o=i.getRenderOrder()||null,a=e.wantedResolution,l=e.getReplayState(i);if(!l.dirty&&l.renderedResolution===a&&l.renderedRevision==r&&l.renderedRenderOrder==o)return;const h=i.getSource(),c=!!i.getDeclutter(),u=h.getTileGrid(),f=h.getTileGridForProjection(n).getTileCoordExtent(e.wrappedTileCoord),g=h.getSourceTiles(t,n,e),m=D(i);delete e.hitDetectionImageData[m],e.executorGroups[m]=[],l.dirty=!1;for(let _=0,p=g.length;_<p;++_){const y=g[_];if(y.getState()!=B.LOADED)continue;const E=h.getProjection(),x=y.tileCoord;let T=u.getTileCoordExtent(x);n&&E&&!Wn(n,E)&&(T=_g(T,E,n,32));const R=tn(f,T),S=rn(R,i.getRenderBuffer()*a,this.tempExtent),v=Hn(T,R)?null:S,w=new ju(0,R,a,t),I=ka(a,t),F=function(L,Z){let G;const H=L.getStyleFunction()||i.getStyleFunction();if(H&&(G=H(L,a)),G){const Q=this.renderFeature(L,I,G,w,c,Z);l.dirty=l.dirty||Q}},A=y.getFeatures();o&&o!==l.renderedRenderOrder&&A.sort(o);for(let L=0,Z=A.length;L<Z;++L){let G=A[L];n&&y.projection&&!Wn(n,y.projection)&&(G=G.clone(),G.getGeometry().applyTransform(qn(y.projection,n))),(!v||Te(v,G.getGeometry().getExtent()))&&F.call(this,G,L)}const M=w.finish(),b=i.getRenderMode()!=="vector"&&c&&g.length===1?null:R,K=new Wu(b,a,t,h.getOverlaps(),M,i.getRenderBuffer(),!0);e.executorGroups[m].push(K)}l.renderedRevision=r,l.renderedRenderOrder=o,l.renderedResolution=a}forEachFeatureAtCoordinate(e,t,n,i,r){const o=t.viewState.resolution,a=t.viewState.rotation;n=n??0;const l=this.getLayer(),c=l.getSource().getTileGridForProjection(t.viewState.projection),u=ze([e]);rn(u,o*n,u);const d={},f=function(E,x,T){let R=E.getId();R===void 0&&(R=D(E));const S=d[R];if(S){if(S!==!0&&T<S.distanceSq){if(T===0)return d[R]=!0,r.splice(r.lastIndexOf(S),1),i(E,l,x);S.geometry=x,S.distanceSq=T}}else{if(T===0)return d[R]=!0,i(E,l,x);r.push(d[R]={feature:E,layer:l,geometry:x,distanceSq:T,callback:i})}},g=this.renderedTiles,m=D(l),_=l.getDeclutter(),p=_?t.declutter?.[_]?.all().map(E=>E.value):null;let y;e:for(let E=0,x=g.length;E<x;++E){const T=g[E],R=c.getTileCoordExtent(T.wrappedTileCoord);if(!Te(R,u))continue;const S=T.executorGroups[m];for(let v=0,w=S.length;v<w;++v)if(y=S[v].forEachFeatureAtCoordinate(e,o,a,n,f,p),y)break e}return y}getFeatures(e){return this.renderedTiles.length===0?Promise.resolve([]):new Promise((t,n)=>{const i=this.getLayer(),r=i.getSource(),o=this.renderedProjection,a=o.getExtent(),l=this.renderedResolution,h=r.getTileGridForProjection(o),c=fe(this.renderedPixelToCoordinateTransform_,e.slice()),u=h.getTileCoordForCoordAndResolution(c,l).toString(),d=this.renderedTiles.find(E=>E.tileCoord.toString()===u&&E.getState()===B.LOADED);if(!d||d.loadingSourceTiles>0){t([]);return}r.getWrapX()&&o.canWrapX()&&!yn(a,h.getTileCoordExtent(d.tileCoord))&&il(c,o);const f=D(i),g=h.getTileCoordExtent(d.wrappedTileCoord),m=Fn(g),_=[(c[0]-m[0])/l,(m[1]-c[1])/l],p=d.getSourceTiles().reduce((E,x)=>E.concat(x.getFeatures()),[]);let y=d.hitDetectionImageData[f];if(!y){const E=Xe(h.getTileSize(h.getZForResolution(l,r.zDirection))),x=this.renderedRotation_,T=[this.getRenderTransform(h.getTileCoordCenter(d.wrappedTileCoord),l,0,ot,E[0]*ot,E[1]*ot,0)];y=Vu(E,T,p,i.getStyleFunction(),h.getTileCoordExtent(d.wrappedTileCoord),d.getReplayState(i).renderedResolution,x),d.hitDetectionImageData[f]=y}t(Zu(_,p,y))})}getFeaturesInExtent(e){const t=[],n=this.getTileCache();if(n.getCount()===0)return t;const r=this.getLayer().getSource().getTileGridForProjection(this.frameState.viewState.projection),o=r.getZForResolution(this.renderedResolution),a={};return n.forEach(l=>{if(l.tileCoord[0]!==o||l.getState()!==B.LOADED)return;const h=l.getSourceTiles();for(let c=0,u=h.length;c<u;++c){const d=h[c],f=d.getKey();if(f in a)continue;a[f]=!0;const g=d.tileCoord;if(Te(e,r.getTileCoordExtent(g))){const m=d.getFeatures();if(m)for(let _=0,p=m.length;_<p;++_){const y=m[_],E=y.getGeometry();Te(e,E.getExtent())&&t.push(y)}}}}),t}handleFontsChanged(){const e=this.getLayer();e.getVisible()&&this.renderedLayerRevision_!==void 0&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}renderDeclutter(e,t){const n=this.context,i=n.globalAlpha;n.globalAlpha=t.opacity;const r=e.viewHints,o=!(r[he.ANIMATING]||r[he.INTERACTING]),a=[this.context.canvas.width,this.context.canvas.height],l=this.getLayer().getDeclutter(),h=l?e.declutter?.[l]:void 0,c=D(this.getLayer()),u=this.renderedTiles;for(let d=0,f=u.length;d<f;++d){const g=u[d],m=g.executorGroups[c];if(m)for(let _=m.length-1;_>=0;--_)m[_].execute(this.context,a,this.getTileRenderTransform(g,e),e.viewState.rotation,o,Xr,h)}n.globalAlpha=i}renderDeferredInternal(e){const t=this.renderedTiles,n=D(this.getLayer()),i=t.reduce((l,h,c)=>(h.executorGroups[n].forEach(u=>l.push({executorGroup:u,index:c})),l),[]),r=i.map(({executorGroup:l})=>l.getDeferredZIndexContexts()),o={};for(let l=0,h=i.length;l<h;++l){const c=i[l].executorGroup.getDeferredZIndexContexts();for(const u in c)o[u]=!0}Object.keys(o).map(Number).sort(Nt).forEach(l=>{r.forEach((h,c)=>{h[l]&&(h[l].forEach(u=>{const{executorGroup:d,index:f}=i[c],g=d.getRenderedContext(),m=g.globalAlpha;g.globalAlpha=this.renderedOpacity_;const _=this.tileClipContexts_[f];_&&_.draw(g),u.draw(g),_&&g.restore(),g.globalAlpha=m,u.clear()}),h[l].length=0)})})}getTileRenderTransform(e,t){const n=t.pixelRatio,i=t.viewState,r=i.center,o=i.resolution,a=i.rotation,l=t.size,h=Math.round(l[0]*n),c=Math.round(l[1]*n),d=this.getLayer().getSource().getTileGridForProjection(t.viewState.projection),f=e.tileCoord,g=d.getTileCoordExtent(e.wrappedTileCoord),m=d.getTileCoordExtent(f,this.tempExtent)[0]-g[0];return ro(Fo(this.inversePixelTransform.slice(),1/n,1/n),this.getRenderTransform(r,o,a,n,h,c,m))}postRender(e,t){const n=t.viewHints,i=!(n[he.ANIMATING]||n[he.INTERACTING]);this.renderedPixelToCoordinateTransform_=t.pixelToCoordinateTransform.slice(),this.renderedRotation_=t.viewState.rotation,this.renderedOpacity_=t.layerStatesArray[t.layerIndex].opacity;const r=this.getLayer(),o=r.getRenderMode(),a=e.globalAlpha;e.globalAlpha=this.renderedOpacity_;const l=r.getDeclutter(),h=l?_c[o].filter(T=>!Xr.includes(T)):_c[o],c=t.viewState,u=c.rotation,d=r.getSource(),g=d.getTileGridForProjection(c.projection).getZForResolution(c.resolution,d.zDirection),m=this.renderedTiles,_=[],p=[],y=[],E=D(r);let x=!0;for(let T=m.length-1;T>=0;--T){const R=m[T];x=x&&!R.getReplayState(r).dirty;const S=R.executorGroups[E].filter(b=>b.hasExecutors(h));if(S.length===0)continue;const v=this.getTileRenderTransform(R,t),w=R.tileCoord[0];let I=!1;const F=S[0].getClipCoords(v);let A=e,M;if(F){M=new Bl,A=M.getContext();for(let b=0,K=_.length;b<K;++b)if(g!==w&&w<p[b]){const L=_[b];Te([F[0],F[3],F[4],F[7]],[L[0],L[3],L[4],L[7]])&&(I||(A.save(),I=!0),A.beginPath(),A.moveTo(F[0],F[1]),A.lineTo(F[2],F[3]),A.lineTo(F[4],F[5]),A.lineTo(F[6],F[7]),A.moveTo(L[6],L[7]),A.lineTo(L[4],L[5]),A.lineTo(L[2],L[3]),A.lineTo(L[0],L[1]),A.clip())}_.push(F),p.push(w)}for(let b=0,K=S.length;b<K;++b)S[b].execute(e,[e.canvas.width,e.canvas.height],v,u,i,h,t.declutter?.[l]);I&&(A===e?A.restore():y[T]=M)}e.globalAlpha=a,this.ready=x,this.tileClipContexts_=y,t.declutter||this.renderDeferredInternal(t),super.postRender(e,t)}renderFeature(e,t,n,i,r,o){if(!n)return!1;let a=!1;if(Array.isArray(n))for(let l=0,h=n.length;l<h;++l)a=Yr(i,e,n[l],t,this.boundHandleStyleImageChange_,void 0,r,o)||a;else a=Yr(i,e,n,t,this.boundHandleStyleImageChange_,void 0,r,o);return a}tileImageNeedsRender_(e){const t=this.getLayer();if(t.getRenderMode()==="vector")return!1;const n=e.getReplayState(t),i=t.getRevision(),r=e.wantedResolution;return n.renderedTileResolution!==r||n.renderedTileRevision!==i}renderTileImage_(e,t){const n=this.getLayer(),i=e.getReplayState(n),r=n.getRevision(),o=e.executorGroups[D(n)];i.renderedTileRevision=r;const a=e.wrappedTileCoord,l=a[0],h=n.getSource();let c=t.pixelRatio;const d=t.viewState.projection,f=h.getTileGridForProjection(d),g=f.getResolution(e.tileCoord[0]),m=t.pixelRatio/e.wantedResolution*g,_=f.getResolution(l),p=e.getContext();c=Math.round(Math.max(c,m/c));const y=h.getTilePixelSize(l,c,d);p.canvas.width=y[0],p.canvas.height=y[1];const E=c/m;if(E!==1){const S=Lh(this.tmpTransform_);Fo(S,E,E),p.setTransform.apply(p,S)}const x=f.getTileCoordExtent(a,this.tempExtent),T=m/_,R=Lh(this.tmpTransform_);Fo(R,T,-T),nu(R,-x[0],-x[3]);for(let S=0,v=o.length;S<v;++S)o[S].execute(p,[p.canvas.width*E,p.canvas.height*E],R,0,!0,Ty[n.getRenderMode()],null);i.renderedTileResolution=e.wantedResolution}}class $0 extends Hi{constructor(e){e=e||{};const t=Object.assign({},e);delete t.preload;const n=e.cacheSize===void 0?0:e.cacheSize;delete e.cacheSize,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.cacheSize_=n;const i=e.renderMode||"hybrid";te(i=="hybrid"||i=="vector","`renderMode` must be `'hybrid'` or `'vector'`"),this.renderMode_=i,this.setPreload(e.preload?e.preload:0),this.setUseInterimTilesOnError(e.useInterimTilesOnError!==void 0?e.useInterimTilesOnError:!0),this.getBackground,this.setBackground}createRenderer(){return new Cy(this,{cacheSize:this.cacheSize_})}getFeatures(e){return super.getFeatures(e)}getFeaturesInExtent(e){return this.getRenderer().getFeaturesInExtent(e)}getRenderMode(){return this.renderMode_}getPreload(){return this.get(Tn.PRELOAD)}getUseInterimTilesOnError(){return this.get(Tn.USE_INTERIM_TILES_ON_ERROR)}setPreload(e){this.set(Tn.PRELOAD,e)}setUseInterimTilesOnError(e){this.set(Tn.USE_INTERIM_TILES_ON_ERROR,e)}}function hd(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Xa(s,e){return s[0]=e[0],s[1]=e[1],s[4]=e[2],s[5]=e[3],s[12]=e[4],s[13]=e[5],s}const Wr=34962,Kl=34963,Ry=35044,na=35048,Sy=5121,vy=5123,wy=5125,cd=5126,mc=["experimental-webgl","webgl","webkit-3d","moz-webgl"];function Py(s,e){e=Object.assign({preserveDrawingBuffer:!0,antialias:!gf},e);const t=mc.length;for(let n=0;n<t;++n)try{const i=s.getContext(mc[n],e);if(i)return i}catch{}return null}const Iy={STATIC_DRAW:Ry};class ia{constructor(e,t){this.array_=null,this.type_=e,te(e===Wr||e===Kl,"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`"),this.usage_=t!==void 0?t:Iy.STATIC_DRAW}ofSize(e){return this.array_=new(hr(this.type_))(e),this}fromArray(e){return this.array_=hr(this.type_).from(e),this}fromArrayBuffer(e){return this.array_=new(hr(this.type_))(e),this}getType(){return this.type_}getArray(){return this.array_}setArray(e){const t=hr(this.type_);if(!(e instanceof t))throw new Error(`Expected ${t}`);this.array_=e}getUsage(){return this.usage_}getSize(){return this.array_?this.array_.length:0}}function hr(s){switch(s){case Wr:return Float32Array;case Kl:return Uint32Array;default:return Float32Array}}const cr={LOST:"webglcontextlost",RESTORED:"webglcontextrestored"},Ay=`
|
||
precision mediump float;
|
||
|
||
attribute vec2 a_position;
|
||
varying vec2 v_texCoord;
|
||
varying vec2 v_screenCoord;
|
||
|
||
uniform vec2 u_screenSize;
|
||
|
||
void main() {
|
||
v_texCoord = a_position * 0.5 + 0.5;
|
||
v_screenCoord = v_texCoord * u_screenSize;
|
||
gl_Position = vec4(a_position, 0.0, 1.0);
|
||
}
|
||
`,Ly=`
|
||
precision mediump float;
|
||
|
||
uniform sampler2D u_image;
|
||
uniform float u_opacity;
|
||
|
||
varying vec2 v_texCoord;
|
||
|
||
void main() {
|
||
gl_FragColor = texture2D(u_image, v_texCoord) * u_opacity;
|
||
}
|
||
`;class pc{constructor(e){this.gl_=e.webGlContext;const t=this.gl_;this.scaleRatio_=e.scaleRatio||1,this.renderTargetTexture_=t.createTexture(),this.renderTargetTextureSize_=null,this.frameBuffer_=t.createFramebuffer(),this.depthBuffer_=t.createRenderbuffer();const n=t.createShader(t.VERTEX_SHADER);t.shaderSource(n,e.vertexShader||Ay),t.compileShader(n);const i=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(i,e.fragmentShader||Ly),t.compileShader(i),this.renderTargetProgram_=t.createProgram(),t.attachShader(this.renderTargetProgram_,n),t.attachShader(this.renderTargetProgram_,i),t.linkProgram(this.renderTargetProgram_),this.renderTargetVerticesBuffer_=t.createBuffer();const r=[-1,-1,1,-1,-1,1,1,-1,1,1,-1,1];t.bindBuffer(t.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),t.bufferData(t.ARRAY_BUFFER,new Float32Array(r),t.STATIC_DRAW),this.renderTargetAttribLocation_=t.getAttribLocation(this.renderTargetProgram_,"a_position"),this.renderTargetUniformLocation_=t.getUniformLocation(this.renderTargetProgram_,"u_screenSize"),this.renderTargetOpacityLocation_=t.getUniformLocation(this.renderTargetProgram_,"u_opacity"),this.renderTargetTextureLocation_=t.getUniformLocation(this.renderTargetProgram_,"u_image"),this.uniforms_=[],e.uniforms&&Object.keys(e.uniforms).forEach(o=>{this.uniforms_.push({value:e.uniforms[o],location:t.getUniformLocation(this.renderTargetProgram_,o)})})}getRenderTargetTexture(){return this.renderTargetTexture_}getGL(){return this.gl_}init(e){const t=this.getGL(),n=[t.drawingBufferWidth*this.scaleRatio_,t.drawingBufferHeight*this.scaleRatio_];if(t.bindFramebuffer(t.FRAMEBUFFER,this.getFrameBuffer()),t.bindRenderbuffer(t.RENDERBUFFER,this.getDepthBuffer()),t.viewport(0,0,n[0],n[1]),!this.renderTargetTextureSize_||this.renderTargetTextureSize_[0]!==n[0]||this.renderTargetTextureSize_[1]!==n[1]){this.renderTargetTextureSize_=n;const i=0,r=t.RGBA,o=0,a=t.RGBA,l=t.UNSIGNED_BYTE,h=null;t.bindTexture(t.TEXTURE_2D,this.renderTargetTexture_),t.texImage2D(t.TEXTURE_2D,i,r,n[0],n[1],o,a,l,h),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.renderTargetTexture_,0),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,n[0],n[1]),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.depthBuffer_)}}apply(e,t,n,i){const r=this.getGL(),o=e.size;if(r.bindFramebuffer(r.FRAMEBUFFER,t?t.getFrameBuffer():null),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.renderTargetTexture_),!t){const l=D(r.canvas);if(!e.renderTargets[l]){const h=r.getContextAttributes();h&&h.preserveDrawingBuffer&&(r.clearColor(0,0,0,0),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT)),e.renderTargets[l]=!0}}r.disable(r.DEPTH_TEST),r.enable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight),r.bindBuffer(r.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),r.useProgram(this.renderTargetProgram_),r.enableVertexAttribArray(this.renderTargetAttribLocation_),r.vertexAttribPointer(this.renderTargetAttribLocation_,2,r.FLOAT,!1,0,0),r.uniform2f(this.renderTargetUniformLocation_,o[0],o[1]),r.uniform1i(this.renderTargetTextureLocation_,0);const a=e.layerStatesArray[e.layerIndex].opacity;r.uniform1f(this.renderTargetOpacityLocation_,a),this.applyUniforms(e),n&&n(r,e),r.drawArrays(r.TRIANGLES,0,6),i&&i(r,e)}getFrameBuffer(){return this.frameBuffer_}getDepthBuffer(){return this.depthBuffer_}applyUniforms(e){const t=this.getGL();let n,i=1;this.uniforms_.forEach(function(r){if(n=typeof r.value=="function"?r.value(e):r.value,n instanceof HTMLCanvasElement||n instanceof ImageData)r.texture||(r.texture=t.createTexture()),t.activeTexture(t[`TEXTURE${i}`]),t.bindTexture(t.TEXTURE_2D,r.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),n instanceof ImageData?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,n.width,n.height,0,t.UNSIGNED_BYTE,new Uint8Array(n.data)):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n),t.uniform1i(r.location,i++);else if(Array.isArray(n))switch(n.length){case 2:t.uniform2f(r.location,n[0],n[1]);return;case 3:t.uniform3f(r.location,n[0],n[1],n[2]);return;case 4:t.uniform4f(r.location,n[0],n[1],n[2],n[3]);return;default:return}else typeof n=="number"&&t.uniform1f(r.location,n)})}}const Vt={PROJECTION_MATRIX:"u_projectionMatrix",SCREEN_TO_WORLD_MATRIX:"u_screenToWorldMatrix",TIME:"u_time",ZOOM:"u_zoom",RESOLUTION:"u_resolution",ROTATION:"u_rotation",VIEWPORT_SIZE_PX:"u_viewportSizePx",PIXEL_RATIO:"u_pixelRatio",HIT_DETECTION:"u_hitDetection"},Oe={UNSIGNED_BYTE:Sy,UNSIGNED_SHORT:vy,UNSIGNED_INT:wy,FLOAT:cd},Vr={};function yc(s){return"shared/"+s}let xc=0;function Fy(){const s="unique/"+xc;return xc+=1,s}function My(s){let e=Vr[s];if(!e){const t=document.createElement("canvas");t.width=1,t.height=1,t.style.position="absolute",t.style.left="0",e={users:0,context:Py(t)},Vr[s]=e}return e.users+=1,e.context}function by(s){const e=Vr[s];if(!e||(e.users-=1,e.users>0))return;const t=e.context,n=t.getExtension("WEBGL_lose_context");n&&n.loseContext();const i=t.canvas;i.width=1,i.height=1,delete Vr[s]}class Dy extends bs{constructor(e){super(),e=e||{},this.boundHandleWebGLContextLost_=this.handleWebGLContextLost.bind(this),this.boundHandleWebGLContextRestored_=this.handleWebGLContextRestored.bind(this),this.canvasCacheKey_=e.canvasCacheKey?yc(e.canvasCacheKey):Fy(),this.gl_=My(this.canvasCacheKey_),this.bufferCache_={},this.extensionCache_={},this.currentProgram_=null,this.needsToBeRecreated_=!1;const t=this.gl_.canvas;t.addEventListener(cr.LOST,this.boundHandleWebGLContextLost_),t.addEventListener(cr.RESTORED,this.boundHandleWebGLContextRestored_),this.offsetRotateMatrix_=Ce(),this.offsetScaleMatrix_=Ce(),this.tmpMat4_=hd(),this.uniformLocationsByProgram_={},this.attribLocationsByProgram_={},this.uniforms_=[],e.uniforms&&this.setUniforms(e.uniforms),this.postProcessPasses_=e.postProcesses?e.postProcesses.map(n=>new pc({webGlContext:this.gl_,scaleRatio:n.scaleRatio,vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,uniforms:n.uniforms})):[new pc({webGlContext:this.gl_})],this.shaderCompileErrors_=null,this.startTime_=Date.now(),this.maxAttributeCount_=this.gl_.getParameter(this.gl_.MAX_VERTEX_ATTRIBS)}setUniforms(e){this.uniforms_=[],this.addUniforms(e)}addUniforms(e){for(const t in e)this.uniforms_.push({name:t,value:e[t]})}canvasCacheKeyMatches(e){return this.canvasCacheKey_===yc(e)}getExtension(e){if(e in this.extensionCache_)return this.extensionCache_[e];const t=this.gl_.getExtension(e);return this.extensionCache_[e]=t,t}getInstancedRenderingExtension_(){const e=this.getExtension("ANGLE_instanced_arrays");return te(!!e,"WebGL extension 'ANGLE_instanced_arrays' is required for vector rendering"),e}bindBuffer(e){const t=this.gl_,n=D(e);let i=this.bufferCache_[n];if(!i){const r=t.createBuffer();i={buffer:e,webGlBuffer:r},this.bufferCache_[n]=i}t.bindBuffer(e.getType(),i.webGlBuffer)}flushBufferData(e){const t=this.gl_;this.bindBuffer(e),t.bufferData(e.getType(),e.getArray(),e.getUsage())}deleteBuffer(e){const t=D(e);delete this.bufferCache_[t]}disposeInternal(){const e=this.gl_.canvas;e.removeEventListener(cr.LOST,this.boundHandleWebGLContextLost_),e.removeEventListener(cr.RESTORED,this.boundHandleWebGLContextRestored_),by(this.canvasCacheKey_),delete this.gl_}prepareDraw(e,t,n){const i=this.gl_,r=this.getCanvas(),o=e.size,a=e.pixelRatio;(r.width!==o[0]*a||r.height!==o[1]*a)&&(r.width=o[0]*a,r.height=o[1]*a,r.style.width=o[0]+"px",r.style.height=o[1]+"px");for(let l=this.postProcessPasses_.length-1;l>=0;l--)this.postProcessPasses_[l].init(e);i.bindTexture(i.TEXTURE_2D,null),i.clearColor(0,0,0,0),i.depthRange(0,1),i.clearDepth(1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),i.enable(i.BLEND),i.blendFunc(i.ONE,t?i.ZERO:i.ONE_MINUS_SRC_ALPHA),n?(i.enable(i.DEPTH_TEST),i.depthFunc(i.LEQUAL)):i.disable(i.DEPTH_TEST)}bindFrameBuffer(e,t){const n=this.getGL();n.bindFramebuffer(n.FRAMEBUFFER,e),t&&n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0)}bindInitialFrameBuffer(){const e=this.getGL(),t=this.postProcessPasses_[0].getFrameBuffer();e.bindFramebuffer(e.FRAMEBUFFER,t);const n=this.postProcessPasses_[0].getRenderTargetTexture();e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0)}bindTexture(e,t,n){const i=this.gl_;i.activeTexture(i.TEXTURE0+t),i.bindTexture(i.TEXTURE_2D,e),i.uniform1i(this.getUniformLocation(n),t)}bindAttribute(e,t,n){const i=this.getGL();this.bindBuffer(e);const r=this.getAttributeLocation(t);i.enableVertexAttribArray(r),i.vertexAttribPointer(r,n,i.FLOAT,!1,0,0)}prepareDrawToRenderTarget(e,t,n,i){const r=this.gl_,o=t.getSize();r.bindFramebuffer(r.FRAMEBUFFER,t.getFramebuffer()),r.bindRenderbuffer(r.RENDERBUFFER,t.getDepthbuffer()),r.viewport(0,0,o[0],o[1]),r.bindTexture(r.TEXTURE_2D,t.getTexture()),r.clearColor(0,0,0,0),r.depthRange(0,1),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT),r.enable(r.BLEND),r.blendFunc(r.ONE,n?r.ZERO:r.ONE_MINUS_SRC_ALPHA),i?(r.enable(r.DEPTH_TEST),r.depthFunc(r.LEQUAL)):r.disable(r.DEPTH_TEST)}drawElements(e,t){const n=this.gl_;this.getExtension("OES_element_index_uint");const i=n.UNSIGNED_INT,r=4,o=t-e,a=e*r;n.drawElements(n.TRIANGLES,o,i,a)}drawElementsInstanced(e,t,n){const i=this.gl_;this.getExtension("OES_element_index_uint");const r=this.getInstancedRenderingExtension_(),o=i.UNSIGNED_INT,a=4,l=t-e,h=e*a;r.drawElementsInstancedANGLE(i.TRIANGLES,l,o,h,n);for(let c=0;c<this.maxAttributeCount_;c++)r.vertexAttribDivisorANGLE(c,0)}finalizeDraw(e,t,n){for(let i=0,r=this.postProcessPasses_.length;i<r;i++)i===r-1?this.postProcessPasses_[i].apply(e,null,t,n):this.postProcessPasses_[i].apply(e,this.postProcessPasses_[i+1])}getCanvas(){return this.gl_.canvas}getGL(){return this.gl_}applyFrameState(e){const t=e.size,n=e.viewState.rotation,i=e.pixelRatio;this.setUniformFloatValue(Vt.TIME,(Date.now()-this.startTime_)*.001),this.setUniformFloatValue(Vt.ZOOM,e.viewState.zoom),this.setUniformFloatValue(Vt.RESOLUTION,e.viewState.resolution),this.setUniformFloatValue(Vt.PIXEL_RATIO,i),this.setUniformFloatVec2(Vt.VIEWPORT_SIZE_PX,[t[0],t[1]]),this.setUniformFloatValue(Vt.ROTATION,n)}applyHitDetectionUniform(e){const t=this.getUniformLocation(Vt.HIT_DETECTION);this.getGL().uniform1i(t,e?1:0),e&&this.setUniformFloatValue(Vt.PIXEL_RATIO,.5)}applyUniforms(e){const t=this.gl_;let n,i=0;this.uniforms_.forEach(r=>{if(n=typeof r.value=="function"?r.value(e):r.value,n instanceof HTMLCanvasElement||n instanceof HTMLImageElement||n instanceof ImageData||n instanceof WebGLTexture){n instanceof WebGLTexture&&!r.texture?(r.prevValue=void 0,r.texture=n):r.texture||(r.prevValue=void 0,r.texture=t.createTexture()),this.bindTexture(r.texture,i,r.name),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE);const o=!(n instanceof HTMLImageElement)||n.complete;!(n instanceof WebGLTexture)&&o&&r.prevValue!==n&&(r.prevValue=n,t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n)),i++}else if(Array.isArray(n)&&n.length===6)this.setUniformMatrixValue(r.name,Xa(this.tmpMat4_,n));else if(Array.isArray(n)&&n.length<=4)switch(n.length){case 2:t.uniform2f(this.getUniformLocation(r.name),n[0],n[1]);return;case 3:t.uniform3f(this.getUniformLocation(r.name),n[0],n[1],n[2]);return;case 4:t.uniform4f(this.getUniformLocation(r.name),n[0],n[1],n[2],n[3]);return;default:return}else typeof n=="number"&&t.uniform1f(this.getUniformLocation(r.name),n)})}useProgram(e,t){this.disableAllAttributes_(),this.gl_.useProgram(e),this.currentProgram_=e,t&&(this.applyFrameState(t),this.applyUniforms(t))}compileShader(e,t){const n=this.gl_,i=n.createShader(t);return n.shaderSource(i,e),n.compileShader(i),i}getProgram(e,t){const n=this.gl_,i=this.compileShader(e,n.FRAGMENT_SHADER),r=this.compileShader(t,n.VERTEX_SHADER),o=n.createProgram();if(n.attachShader(o,i),n.attachShader(o,r),n.linkProgram(o),!n.getShaderParameter(i,n.COMPILE_STATUS)){const a=`Fragment shader compilation failed: ${n.getShaderInfoLog(i)}`;throw new Error(a)}if(n.deleteShader(i),!n.getShaderParameter(r,n.COMPILE_STATUS)){const a=`Vertex shader compilation failed: ${n.getShaderInfoLog(r)}`;throw new Error(a)}if(n.deleteShader(r),!n.getProgramParameter(o,n.LINK_STATUS)){const a=`GL program linking failed: ${n.getProgramInfoLog(o)}`;throw new Error(a)}return o}getUniformLocation(e){const t=D(this.currentProgram_);return this.uniformLocationsByProgram_[t]===void 0&&(this.uniformLocationsByProgram_[t]={}),this.uniformLocationsByProgram_[t][e]===void 0&&(this.uniformLocationsByProgram_[t][e]=this.gl_.getUniformLocation(this.currentProgram_,e)),this.uniformLocationsByProgram_[t][e]}getAttributeLocation(e){const t=D(this.currentProgram_);return this.attribLocationsByProgram_[t]===void 0&&(this.attribLocationsByProgram_[t]={}),this.attribLocationsByProgram_[t][e]===void 0&&(this.attribLocationsByProgram_[t][e]=this.gl_.getAttribLocation(this.currentProgram_,e)),this.attribLocationsByProgram_[t][e]}makeProjectionTransform(e,t){const n=e.size,i=e.viewState.rotation,r=e.viewState.resolution,o=e.viewState.center;return ct(t,0,0,2/(r*n[0]),2/(r*n[1]),-i,-o[0],-o[1]),t}setUniformFloatValue(e,t){this.gl_.uniform1f(this.getUniformLocation(e),t)}setUniformFloatVec2(e,t){this.gl_.uniform2fv(this.getUniformLocation(e),t)}setUniformFloatVec4(e,t){this.gl_.uniform4fv(this.getUniformLocation(e),t)}setUniformMatrixValue(e,t){this.gl_.uniformMatrix4fv(this.getUniformLocation(e),!1,t)}disableAllAttributes_(){for(let e=0;e<this.maxAttributeCount_;e++)this.gl_.disableVertexAttribArray(e)}enableAttributeArray_(e,t,n,i,r,o){const a=this.getAttributeLocation(e);a<0||(this.gl_.enableVertexAttribArray(a),this.gl_.vertexAttribPointer(a,t,n,!1,i,r),o&&this.getInstancedRenderingExtension_().vertexAttribDivisorANGLE(a,1))}enableAttributes_(e,t){const n=Oy(e);let i=0;for(let r=0;r<e.length;r++){const o=e[r];o.name&&this.enableAttributeArray_(o.name,o.size,o.type||cd,n,i,t),i+=o.size*ud(o.type)}}enableAttributes(e){this.enableAttributes_(e,!1)}enableAttributesInstanced(e){this.enableAttributes_(e,!0)}handleWebGLContextLost(e){ei(this.bufferCache_),this.currentProgram_=null,e.preventDefault()}handleWebGLContextRestored(){this.needsToBeRecreated_=!0}needsToBeRecreated(){return this.needsToBeRecreated_}createTexture(e,t,n,i){const r=this.gl_;n=n||r.createTexture();const o=i?r.NEAREST:r.LINEAR;r.bindTexture(r.TEXTURE_2D,n),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);const a=0,l=r.RGBA,h=0,c=r.RGBA,u=r.UNSIGNED_BYTE;return t instanceof Uint8Array?r.texImage2D(r.TEXTURE_2D,a,l,e[0],e[1],h,c,u,t):t?r.texImage2D(r.TEXTURE_2D,a,l,c,u,t):r.texImage2D(r.TEXTURE_2D,a,l,e[0],e[1],h,c,u,null),n}}function Oy(s){let e=0;for(let t=0;t<s.length;t++){const n=s[t];e+=n.size*ud(n.type)}return e}function ud(s){switch(s){case Oe.UNSIGNED_BYTE:return Uint8Array.BYTES_PER_ELEMENT;case Oe.UNSIGNED_SHORT:return Uint16Array.BYTES_PER_ELEMENT;case Oe.UNSIGNED_INT:return Uint32Array.BYTES_PER_ELEMENT;case Oe.FLOAT:default:return Float32Array.BYTES_PER_ELEMENT}}class Hl extends zu{constructor(e,t){super(e),t=t||{},this.inversePixelTransform_=Ce(),this.postProcesses_=t.postProcesses,this.uniforms_=t.uniforms,this.helper,this.onMapChanged_=()=>{this.clearCache(),this.removeHelper()},e.addChangeListener(ae.MAP,this.onMapChanged_),this.dispatchPreComposeEvent=this.dispatchPreComposeEvent.bind(this),this.dispatchPostComposeEvent=this.dispatchPostComposeEvent.bind(this)}dispatchPreComposeEvent(e,t){const n=this.getLayer();if(n.hasListener(Me.PRECOMPOSE)){const i=new ms(Me.PRECOMPOSE,void 0,t,e);n.dispatchEvent(i)}}dispatchPostComposeEvent(e,t){const n=this.getLayer();if(n.hasListener(Me.POSTCOMPOSE)){const i=new ms(Me.POSTCOMPOSE,void 0,t,e);n.dispatchEvent(i)}}reset(e){this.uniforms_=e.uniforms,this.helper&&this.helper.setUniforms(this.uniforms_)}removeHelper(){this.helper&&(this.helper.dispose(),delete this.helper)}prepareFrame(e){if(this.getLayer().getRenderSource()){let t=!0,n=-1,i;for(let o=0,a=e.layerStatesArray.length;o<a;o++){const l=e.layerStatesArray[o].layer,h=l.getRenderer();if(!(h instanceof Hl)){t=!0;continue}const c=l.getClassName();if((t||c!==i)&&(n+=1,t=!1),i=c,h===this)break}const r="map/"+e.mapId+"/group/"+n;(!this.helper||!this.helper.canvasCacheKeyMatches(r)||this.helper.needsToBeRecreated())&&(this.removeHelper(),this.helper=new Dy({postProcesses:this.postProcesses_,uniforms:this.uniforms_,canvasCacheKey:r}),i&&(this.helper.getCanvas().className=i),this.afterHelperCreated())}return this.prepareFrameInternal(e)}afterHelperCreated(){}prepareFrameInternal(e){return!0}clearCache(){}disposeInternal(){this.clearCache(),this.removeHelper(),this.getLayer()?.removeChangeListener(ae.MAP,this.onMapChanged_),super.disposeInternal()}dispatchRenderEvent_(e,t,n){const i=this.getLayer();if(i.hasListener(e)){ct(this.inversePixelTransform_,0,0,n.pixelRatio,-n.pixelRatio,0,0,-n.size[1]);const r=new ms(e,this.inversePixelTransform_,n,t);i.dispatchEvent(r)}}preRender(e,t){this.dispatchRenderEvent_(Me.PRERENDER,e,t)}postRender(e,t){this.dispatchRenderEvent_(Me.POSTRENDER,e,t)}}const sa={TILE_TEXTURE_ARRAY:"u_tileTextures",TEXTURE_PIXEL_WIDTH:"u_texturePixelWidth",TEXTURE_PIXEL_HEIGHT:"u_texturePixelHeight"};class Ny{constructor(e,t){this.name=e,this.data=t,this.texture_=null}getTexture(e){if(!this.texture_){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,this.data.length/4,1,0,e.RGBA,e.UNSIGNED_BYTE,this.data),this.texture_=t}return this.texture_}delete(e){this.texture_&&e.deleteTexture(this.texture_),this.texture_=null}}function Gy(s,e){return`operator_${s}_${Object.keys(e.functions).length}`}function wn(s){const e=s.toString();return e.includes(".")?e:e+".0"}function ql(s){if(s.length<2||s.length>4)throw new Error("`formatArray` can only output `vec2`, `vec3` or `vec4` arrays.");return`vec${s.length}(${s.map(wn).join(", ")})`}function Rr(s){const e=Ct(s),t=e.length>3?e[3]:1;return ql([e[0]/255,e[1]/255,e[2]/255,t])}function ky(s){const e=Xe(s);return ql(e)}const ra={};let Uy=0;function Ms(s){return s in ra||(ra[s]=Uy++),ra[s]}function qt(s){return wn(Ms(s))}function Jl(s){return"u_var_"+s}function dd(){return{variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1}}const oa="getBandValue",By="u_paletteTextures",fd="featureId",gd="geometryType",Ya=-9999999;function zy(s,e,t,n){const i=De(s,e,t);return Ql(i,e,n)}function se(s){return(e,t,n)=>{const i=t.args.length,r=new Array(i);for(let o=0;o<i;++o)r[o]=Ql(t.args[o],n,e);return s(r,e)}}const $y={[C.Get]:(s,e)=>{const n=e.args[0].value;n in s.properties||(s.properties[n]={name:n,type:e.type});let r="a_prop_"+n;return Dt(e.type,ve)&&(r=`(${r} > 0.0)`),r},[C.Id]:s=>(s.featureId=!0,"a_"+fd),[C.GeometryType]:s=>(s.geometryType=!0,"a_"+gd),[C.LineMetric]:()=>"currentLineMetric",[C.Var]:(s,e)=>{const n=e.args[0].value;n in s.variables||(s.variables[n]={name:n,type:e.type});let r=Jl(n);return Dt(e.type,ve)&&(r=`(${r} > 0.0)`),r},[C.Has]:(s,e)=>{const n=e.args[0].value;return n in s.properties||(s.properties[n]={name:n,type:e.type}),`(a_prop_${n} != ${wn(Ya)})`},[C.Resolution]:()=>"u_resolution",[C.Zoom]:()=>"u_zoom",[C.Time]:()=>"u_time",[C.Any]:se(s=>`(${s.join(" || ")})`),[C.All]:se(s=>`(${s.join(" && ")})`),[C.Not]:se(([s])=>`(!${s})`),[C.Equal]:se(([s,e])=>`(${s} == ${e})`),[C.NotEqual]:se(([s,e])=>`(${s} != ${e})`),[C.GreaterThan]:se(([s,e])=>`(${s} > ${e})`),[C.GreaterThanOrEqualTo]:se(([s,e])=>`(${s} >= ${e})`),[C.LessThan]:se(([s,e])=>`(${s} < ${e})`),[C.LessThanOrEqualTo]:se(([s,e])=>`(${s} <= ${e})`),[C.Multiply]:se(s=>`(${s.join(" * ")})`),[C.Divide]:se(([s,e])=>`(${s} / ${e})`),[C.Add]:se(s=>`(${s.join(" + ")})`),[C.Subtract]:se(([s,e])=>`(${s} - ${e})`),[C.Clamp]:se(([s,e,t])=>`clamp(${s}, ${e}, ${t})`),[C.Mod]:se(([s,e])=>`mod(${s}, ${e})`),[C.Pow]:se(([s,e])=>`pow(${s}, ${e})`),[C.Abs]:se(([s])=>`abs(${s})`),[C.Floor]:se(([s])=>`floor(${s})`),[C.Ceil]:se(([s])=>`ceil(${s})`),[C.Round]:se(([s])=>`floor(${s} + 0.5)`),[C.Sin]:se(([s])=>`sin(${s})`),[C.Cos]:se(([s])=>`cos(${s})`),[C.Atan]:se(([s,e])=>e!==void 0?`atan(${s}, ${e})`:`atan(${s})`),[C.Sqrt]:se(([s])=>`sqrt(${s})`),[C.Match]:se(s=>{const e=s[0],t=s[s.length-1];let n=null;for(let i=s.length-3;i>=1;i-=2){const r=s[i],o=s[i+1];n=`(${e} == ${r} ? ${o} : ${n||t})`}return n}),[C.Between]:se(([s,e,t])=>`(${s} >= ${e} && ${s} <= ${t})`),[C.Interpolate]:se(([s,e,...t])=>{let n="";for(let i=0;i<t.length-2;i+=2){const r=t[i],o=n||t[i+1],a=t[i+2],l=t[i+3];let h;s===wn(1)?h=`(${e} - ${r}) / (${a} - ${r})`:h=`(pow(${s}, (${e} - ${r})) - 1.0) / (pow(${s}, (${a} - ${r})) - 1.0)`,n=`mix(${o}, ${l}, clamp(${h}, 0.0, 1.0))`}return n}),[C.Case]:se(s=>{const e=s[s.length-1];let t=null;for(let n=s.length-3;n>=0;n-=2){const i=s[n],r=s[n+1];t=`(${i} ? ${r} : ${t||e})`}return t}),[C.In]:se(([s,...e],t)=>{const n=Gy("in",t),i=[];for(let r=0;r<e.length;r+=1)i.push(` if (inputValue == ${e[r]}) { return true; }`);return t.functions[n]=`bool ${n}(float inputValue) {
|
||
${i.join(`
|
||
`)}
|
||
return false;
|
||
}`,`${n}(${s})`}),[C.Array]:se(s=>`vec${s.length}(${s.join(", ")})`),[C.Color]:se(s=>{if(s.length===1)return`vec4(vec3(${s[0]} / 255.0), 1.0)`;if(s.length===2)return`vec4(vec3(${s[0]} / 255.0), ${s[1]})`;const e=s.slice(0,3).map(n=>`${n} / 255.0`);if(s.length===3)return`vec4(${e.join(", ")}, 1.0)`;const t=s[3];return`vec4(${e.join(", ")}, ${t})`}),[C.Band]:se(([s,e,t],n)=>{if(!(oa in n.functions)){let i="";const r=n.bandCount||1;for(let o=0;o<r;o++){const a=Math.floor(o/4);let l=o%4;o===r-1&&l===1&&(l=3);const h=`${sa.TILE_TEXTURE_ARRAY}[${a}]`;i+=` if (band == ${o+1}.0) {
|
||
return texture2D(${h}, v_textureCoord + vec2(dx, dy))[${l}];
|
||
}
|
||
`}n.functions[oa]=`float getBandValue(float band, float xOffset, float yOffset) {
|
||
float dx = xOffset / ${sa.TEXTURE_PIXEL_WIDTH};
|
||
float dy = yOffset / ${sa.TEXTURE_PIXEL_HEIGHT};
|
||
${i}
|
||
}`}return`${oa}(${s}, ${e??"0.0"}, ${t??"0.0"})`}),[C.Palette]:(s,e)=>{const[t,...n]=e.args,i=n.length,r=new Uint8Array(i*4);for(let h=0;h<n.length;h++){const c=n[h].value,u=Ct(c),d=h*4;r[d]=u[0],r[d+1]=u[1],r[d+2]=u[2],r[d+3]=u[3]*255}s.paletteTextures||(s.paletteTextures=[]);const o=`${By}[${s.paletteTextures.length}]`,a=new Ny(o,r);s.paletteTextures.push(a);const l=Ql(t,N,s);return`texture2D(${o}, vec2((${l} + 0.5) / ${i}.0, 0.5))`}};function Ql(s,e,t){if(s instanceof vu){const n=$y[s.operator];if(n===void 0)throw new Error(`No compiler defined for this operator: ${JSON.stringify(s.operator)}`);return n(t,s,e)}if((s.type&N)>0)return wn(s.value);if((s.type&ve)>0)return s.value.toString();if((s.type&Ie)>0)return qt(s.value.toString());if((s.type&_e)>0)return Rr(s.value);if((s.type&nt)>0)return ql(s.value);if((s.type&yt)>0)return ky(s.value);throw new Error(`Unexpected expression ${s.value} (expected type ${Pi(e)})`)}function Xy(){return{"fill-color":"rgba(255,255,255,0.4)","stroke-color":"#3399CC","stroke-width":1.25,"circle-radius":5,"circle-fill-color":"rgba(255,255,255,0.4)","circle-stroke-width":1.25,"circle-stroke-color":"#3399CC"}}const Ec=.985;function W(s,e,t){const n=Dl();return zy(e,t,n,s)}function Yy(s){const e=Ct(s),t=e[0]*256,n=e[1],i=e[2]*256,r=Math.round(e[3]*255);return[t+n,i+r]}const jy=`vec4 unpackColor(vec2 packedColor) {
|
||
return vec4(
|
||
min(floor(packedColor[0] / 256.0) / 255.0, 1.0),
|
||
min(mod(packedColor[0], 256.0) / 255.0, 1.0),
|
||
min(floor(packedColor[1] / 256.0) / 255.0, 1.0),
|
||
min(mod(packedColor[1], 256.0) / 255.0, 1.0)
|
||
);
|
||
}`;function eh(s){return s===_e||s===yt?2:s===nt?4:1}function ja(s){const e=eh(s);return e>1?`vec${e}`:"float"}function _d(s,e){for(const t in e.variables){const n=e.variables[t],i=Jl(n.name);let r=ja(n.type);n.type===_e&&(r="vec4"),s.addUniform(i,r)}for(const t in e.properties){const n=e.properties[t],i=ja(n.type),r=`a_prop_${n.name}`;n.type===_e?s.addAttribute(r,i,`unpackColor(${r})`,"vec4"):s.addAttribute(r,i)}for(const t in e.functions)s.addVertexShaderFunction(e.functions[t]),s.addFragmentShaderFunction(e.functions[t])}function md(s,e){const t={};for(const n in s.variables){const i=s.variables[n],r=Jl(i.name);t[r]=()=>{const o=e[i.name];if(typeof o=="number")return o;if(typeof o=="boolean")return o?1:0;if(i.type===_e){const a=[...Ct(o||"#eee")];return a[0]/=255,a[1]/=255,a[2]/=255,a[3]??=1,a}return typeof o=="string"?Ms(o):o}}return t}function pd(s){const e={};for(const t in s.properties){const n=s.properties[t],i=r=>{const o=r.get(n.name);return n.type===_e?Yy([...Ct(o||"#eee")]):typeof o=="string"?Ms(o):typeof o=="boolean"?o?1:0:o};e[`prop_${n.name}`]={size:eh(n.type),callback:i}}return e}const yi=`#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||
precision highp float;
|
||
#else
|
||
precision mediump float;
|
||
#endif
|
||
uniform mat4 u_projectionMatrix;
|
||
uniform mat4 u_screenToWorldMatrix;
|
||
uniform vec2 u_viewportSizePx;
|
||
uniform float u_pixelRatio;
|
||
uniform float u_globalAlpha;
|
||
uniform float u_time;
|
||
uniform float u_zoom;
|
||
uniform float u_resolution;
|
||
uniform float u_rotation;
|
||
uniform vec4 u_renderExtent;
|
||
uniform vec2 u_patternOrigin;
|
||
uniform float u_depth;
|
||
uniform mediump int u_hitDetection;
|
||
|
||
const float PI = 3.141592653589793238;
|
||
const float TWO_PI = 2.0 * PI;
|
||
float currentLineMetric = 0.; // an actual value will be used in the stroke shaders
|
||
|
||
${jy}
|
||
`,xi=Xy();class yd{constructor(){this.uniforms_=[],this.attributes_=[],this.hasSymbol_=!1,this.symbolSizeExpression_=`vec2(${wn(xi["circle-radius"])} + ${wn(xi["circle-stroke-width"]*.5)})`,this.symbolRotationExpression_="0.0",this.symbolOffsetExpression_="vec2(0.0)",this.symbolColorExpression_=Rr(xi["circle-fill-color"]),this.texCoordExpression_="vec4(0.0, 0.0, 1.0, 1.0)",this.discardExpression_="false",this.symbolRotateWithView_=!1,this.hasStroke_=!1,this.strokeWidthExpression_=wn(xi["stroke-width"]),this.strokeColorExpression_=Rr(xi["stroke-color"]),this.strokeOffsetExpression_="0.",this.strokeCapExpression_=qt("round"),this.strokeJoinExpression_=qt("round"),this.strokeMiterLimitExpression_="10.",this.strokeDistanceFieldExpression_="-1000.",this.strokePatternLengthExpression_=null,this.hasFill_=!1,this.fillColorExpression_=Rr(xi["fill-color"]),this.vertexShaderFunctions_=[],this.fragmentShaderFunctions_=[]}addUniform(e,t){return this.uniforms_.push({name:e,type:t}),this}addAttribute(e,t,n,i){return this.attributes_.push({name:e,type:t,varyingName:e.replace(/^a_/,"v_"),varyingType:i??t,varyingExpression:n??e}),this}setSymbolSizeExpression(e){return this.hasSymbol_=!0,this.symbolSizeExpression_=e,this}getSymbolSizeExpression(){return this.symbolSizeExpression_}setSymbolRotationExpression(e){return this.symbolRotationExpression_=e,this}setSymbolOffsetExpression(e){return this.symbolOffsetExpression_=e,this}getSymbolOffsetExpression(){return this.symbolOffsetExpression_}setSymbolColorExpression(e){return this.hasSymbol_=!0,this.symbolColorExpression_=e,this}getSymbolColorExpression(){return this.symbolColorExpression_}setTextureCoordinateExpression(e){return this.texCoordExpression_=e,this}setFragmentDiscardExpression(e){return this.discardExpression_=e,this}getFragmentDiscardExpression(){return this.discardExpression_}setSymbolRotateWithView(e){return this.symbolRotateWithView_=e,this}setStrokeWidthExpression(e){return this.hasStroke_=!0,this.strokeWidthExpression_=e,this}setStrokeColorExpression(e){return this.hasStroke_=!0,this.strokeColorExpression_=e,this}getStrokeColorExpression(){return this.strokeColorExpression_}setStrokeOffsetExpression(e){return this.strokeOffsetExpression_=e,this}setStrokeCapExpression(e){return this.strokeCapExpression_=e,this}setStrokeJoinExpression(e){return this.strokeJoinExpression_=e,this}setStrokeMiterLimitExpression(e){return this.strokeMiterLimitExpression_=e,this}setStrokeDistanceFieldExpression(e){return this.strokeDistanceFieldExpression_=e,this}setStrokePatternLengthExpression(e){return this.strokePatternLengthExpression_=e,this}getStrokePatternLengthExpression(){return this.strokePatternLengthExpression_}setFillColorExpression(e){return this.hasFill_=!0,this.fillColorExpression_=e,this}getFillColorExpression(){return this.fillColorExpression_}addVertexShaderFunction(e){return this.vertexShaderFunctions_.includes(e)?this:(this.vertexShaderFunctions_.push(e),this)}addFragmentShaderFunction(e){return this.fragmentShaderFunctions_.includes(e)?this:(this.fragmentShaderFunctions_.push(e),this)}getSymbolVertexShader(){return this.hasSymbol_?`${yi}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
attribute vec2 a_position;
|
||
attribute vec2 a_localPosition;
|
||
attribute vec2 a_hitColor;
|
||
|
||
varying vec2 v_texCoord;
|
||
varying vec2 v_quadCoord;
|
||
varying vec4 v_hitColor;
|
||
varying vec2 v_centerPx;
|
||
varying float v_angle;
|
||
varying vec2 v_quadSizePx;
|
||
|
||
${this.attributes_.map(e=>`attribute ${e.type} ${e.name};
|
||
varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.vertexShaderFunctions_.join(`
|
||
`)}
|
||
vec2 pxToScreen(vec2 coordPx) {
|
||
vec2 scaled = coordPx / u_viewportSizePx / 0.5;
|
||
return scaled;
|
||
}
|
||
|
||
vec2 screenToPx(vec2 coordScreen) {
|
||
return (coordScreen * 0.5 + 0.5) * u_viewportSizePx;
|
||
}
|
||
|
||
void main(void) {
|
||
v_quadSizePx = ${this.symbolSizeExpression_};
|
||
vec2 halfSizePx = v_quadSizePx * 0.5;
|
||
vec2 centerOffsetPx = ${this.symbolOffsetExpression_};
|
||
vec2 offsetPx = centerOffsetPx + a_localPosition * halfSizePx * vec2(1., -1.);
|
||
float angle = ${this.symbolRotationExpression_}${this.symbolRotateWithView_?" + u_rotation":""};
|
||
float c = cos(-angle);
|
||
float s = sin(-angle);
|
||
offsetPx = vec2(c * offsetPx.x - s * offsetPx.y, s * offsetPx.x + c * offsetPx.y);
|
||
vec4 center = u_projectionMatrix * vec4(a_position, 0.0, 1.0);
|
||
gl_Position = center + vec4(pxToScreen(offsetPx), u_depth, 0.);
|
||
vec4 texCoord = ${this.texCoordExpression_};
|
||
float u = mix(texCoord.s, texCoord.p, a_localPosition.x * 0.5 + 0.5);
|
||
float v = mix(texCoord.t, texCoord.q, a_localPosition.y * 0.5 + 0.5);
|
||
v_texCoord = vec2(u, v);
|
||
v_hitColor = unpackColor(a_hitColor);
|
||
v_angle = angle;
|
||
c = cos(-v_angle);
|
||
s = sin(-v_angle);
|
||
centerOffsetPx = vec2(c * centerOffsetPx.x - s * centerOffsetPx.y, s * centerOffsetPx.x + c * centerOffsetPx.y);
|
||
v_centerPx = screenToPx(center.xy) + centerOffsetPx;
|
||
${this.attributes_.map(e=>` ${e.varyingName} = ${e.varyingExpression};`).join(`
|
||
`)}
|
||
}`:null}getSymbolFragmentShader(){return this.hasSymbol_?`${yi}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
varying vec2 v_texCoord;
|
||
varying vec4 v_hitColor;
|
||
varying vec2 v_centerPx;
|
||
varying float v_angle;
|
||
varying vec2 v_quadSizePx;
|
||
${this.attributes_.map(e=>`varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.fragmentShaderFunctions_.join(`
|
||
`)}
|
||
|
||
void main(void) {
|
||
${this.attributes_.map(e=>` ${e.varyingType} ${e.name} = ${e.varyingName}; // assign to original attribute name`).join(`
|
||
`)}
|
||
if (${this.discardExpression_}) { discard; }
|
||
vec2 coordsPx = gl_FragCoord.xy / u_pixelRatio - v_centerPx; // relative to center
|
||
float c = cos(v_angle);
|
||
float s = sin(v_angle);
|
||
coordsPx = vec2(c * coordsPx.x - s * coordsPx.y, s * coordsPx.x + c * coordsPx.y);
|
||
gl_FragColor = ${this.symbolColorExpression_};
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
if (u_hitDetection > 0) {
|
||
if (gl_FragColor.a < 0.05) { discard; };
|
||
gl_FragColor = v_hitColor;
|
||
}
|
||
}`:null}getStrokeVertexShader(){return this.hasStroke_?`${yi}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
attribute vec2 a_segmentStart;
|
||
attribute vec2 a_segmentEnd;
|
||
attribute vec2 a_localPosition;
|
||
attribute float a_measureStart;
|
||
attribute float a_measureEnd;
|
||
attribute float a_angleTangentSum;
|
||
attribute float a_distanceLow;
|
||
attribute float a_distanceHigh;
|
||
attribute vec2 a_joinAngles;
|
||
attribute vec2 a_hitColor;
|
||
|
||
varying vec2 v_segmentStartPx;
|
||
varying vec2 v_segmentEndPx;
|
||
varying float v_angleStart;
|
||
varying float v_angleEnd;
|
||
varying float v_width;
|
||
varying vec4 v_hitColor;
|
||
varying float v_distancePx;
|
||
varying float v_measureStart;
|
||
varying float v_measureEnd;
|
||
|
||
${this.attributes_.map(e=>`attribute ${e.type} ${e.name};
|
||
varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.vertexShaderFunctions_.join(`
|
||
`)}
|
||
vec2 worldToPx(vec2 worldPos) {
|
||
vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);
|
||
return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;
|
||
}
|
||
|
||
vec4 pxToScreen(vec2 pxPos) {
|
||
vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
|
||
return vec4(screenPos, u_depth, 1.0);
|
||
}
|
||
|
||
bool isCap(float joinAngle) {
|
||
return joinAngle < -0.1;
|
||
}
|
||
|
||
vec2 getJoinOffsetDirection(vec2 normalPx, float joinAngle) {
|
||
float halfAngle = joinAngle / 2.0;
|
||
float c = cos(halfAngle);
|
||
float s = sin(halfAngle);
|
||
vec2 angleBisectorNormal = vec2(s * normalPx.x + c * normalPx.y, -c * normalPx.x + s * normalPx.y);
|
||
float length = 1.0 / s;
|
||
return angleBisectorNormal * length;
|
||
}
|
||
|
||
vec2 getOffsetPoint(vec2 point, vec2 normal, float joinAngle, float offsetPx) {
|
||
// if on a cap or the join angle is too high, offset the line along the segment normal
|
||
if (cos(joinAngle) > 0.998 || isCap(joinAngle)) {
|
||
return point - normal * offsetPx;
|
||
}
|
||
// offset is applied along the inverted normal (positive offset goes "right" relative to line direction)
|
||
return point - getJoinOffsetDirection(normal, joinAngle) * offsetPx;
|
||
}
|
||
|
||
void main(void) {
|
||
v_angleStart = a_joinAngles.x;
|
||
v_angleEnd = a_joinAngles.y;
|
||
float startEndRatio = a_localPosition.x * 0.5 + 0.5;
|
||
currentLineMetric = mix(a_measureStart, a_measureEnd, startEndRatio);
|
||
// we're reading the fractional part while keeping the sign (so -4.12 gives -0.12, 3.45 gives 0.45)
|
||
|
||
float lineWidth = ${this.strokeWidthExpression_};
|
||
float lineOffsetPx = ${this.strokeOffsetExpression_};
|
||
|
||
// compute segment start/end in px with offset
|
||
vec2 segmentStartPx = worldToPx(a_segmentStart);
|
||
vec2 segmentEndPx = worldToPx(a_segmentEnd);
|
||
vec2 tangentPx = normalize(segmentEndPx - segmentStartPx);
|
||
vec2 normalPx = vec2(-tangentPx.y, tangentPx.x);
|
||
segmentStartPx = getOffsetPoint(segmentStartPx, normalPx, v_angleStart, lineOffsetPx),
|
||
segmentEndPx = getOffsetPoint(segmentEndPx, normalPx, v_angleEnd, lineOffsetPx);
|
||
|
||
// compute current vertex position
|
||
float normalDir = -1. * a_localPosition.y;
|
||
float tangentDir = -1. * a_localPosition.x;
|
||
float angle = mix(v_angleStart, v_angleEnd, startEndRatio);
|
||
vec2 joinDirection;
|
||
vec2 positionPx = mix(segmentStartPx, segmentEndPx, startEndRatio);
|
||
// if angle is too high, do not make a proper join
|
||
if (cos(angle) > ${Ec} || isCap(angle)) {
|
||
joinDirection = normalPx * normalDir - tangentPx * tangentDir;
|
||
} else {
|
||
joinDirection = getJoinOffsetDirection(normalPx * normalDir, angle);
|
||
}
|
||
positionPx = positionPx + joinDirection * (lineWidth * 0.5 + 1.); // adding 1 pixel for antialiasing
|
||
gl_Position = pxToScreen(positionPx);
|
||
|
||
v_segmentStartPx = segmentStartPx;
|
||
v_segmentEndPx = segmentEndPx;
|
||
v_width = lineWidth;
|
||
v_hitColor = unpackColor(a_hitColor);
|
||
|
||
v_distancePx = a_distanceLow / u_resolution - (lineOffsetPx * a_angleTangentSum);
|
||
float distanceHighPx = a_distanceHigh / u_resolution;
|
||
${this.strokePatternLengthExpression_!==null?`v_distancePx = mod(v_distancePx, ${this.strokePatternLengthExpression_});
|
||
distanceHighPx = mod(distanceHighPx, ${this.strokePatternLengthExpression_});
|
||
`:""}v_distancePx += distanceHighPx;
|
||
|
||
v_measureStart = a_measureStart;
|
||
v_measureEnd = a_measureEnd;
|
||
${this.attributes_.map(e=>` ${e.varyingName} = ${e.varyingExpression};`).join(`
|
||
`)}
|
||
}`:null}getStrokeFragmentShader(){return this.hasStroke_?`${yi}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
varying vec2 v_segmentStartPx;
|
||
varying vec2 v_segmentEndPx;
|
||
varying float v_angleStart;
|
||
varying float v_angleEnd;
|
||
varying float v_width;
|
||
varying vec4 v_hitColor;
|
||
varying float v_distancePx;
|
||
varying float v_measureStart;
|
||
varying float v_measureEnd;
|
||
${this.attributes_.map(e=>`varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.fragmentShaderFunctions_.join(`
|
||
`)}
|
||
|
||
vec2 pxToWorld(vec2 pxPos) {
|
||
vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
|
||
return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;
|
||
}
|
||
|
||
bool isCap(float joinAngle) {
|
||
return joinAngle < -0.1;
|
||
}
|
||
|
||
float segmentDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
||
vec2 tangent = normalize(end - start);
|
||
vec2 normal = vec2(-tangent.y, tangent.x);
|
||
vec2 startToPoint = point - start;
|
||
return abs(dot(startToPoint, normal)) - width * 0.5;
|
||
}
|
||
|
||
float buttCapDistanceField(vec2 point, vec2 start, vec2 end) {
|
||
vec2 startToPoint = point - start;
|
||
vec2 tangent = normalize(end - start);
|
||
return dot(startToPoint, -tangent);
|
||
}
|
||
|
||
float squareCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
||
return buttCapDistanceField(point, start, end) - width * 0.5;
|
||
}
|
||
|
||
float roundCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
||
float onSegment = max(0., 1000. * dot(point - start, end - start)); // this is very high when inside the segment
|
||
return length(point - start) - width * 0.5 - onSegment;
|
||
}
|
||
|
||
float roundJoinDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
||
return roundCapDistanceField(point, start, end, width);
|
||
}
|
||
|
||
float bevelJoinField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {
|
||
vec2 startToPoint = point - start;
|
||
vec2 tangent = normalize(end - start);
|
||
float c = cos(joinAngle * 0.5);
|
||
float s = sin(joinAngle * 0.5);
|
||
float direction = -sign(sin(joinAngle));
|
||
vec2 bisector = vec2(c * tangent.x - s * tangent.y, s * tangent.x + c * tangent.y);
|
||
float radius = width * 0.5 * s;
|
||
return dot(startToPoint, bisector * direction) - radius;
|
||
}
|
||
|
||
float miterJoinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {
|
||
if (cos(joinAngle) > ${Ec}) { // avoid risking a division by zero
|
||
return bevelJoinField(point, start, end, width, joinAngle);
|
||
}
|
||
float miterLength = 1. / sin(joinAngle * 0.5);
|
||
float miterLimit = ${this.strokeMiterLimitExpression_};
|
||
if (miterLength > miterLimit) {
|
||
return bevelJoinField(point, start, end, width, joinAngle);
|
||
}
|
||
return -1000.;
|
||
}
|
||
|
||
float capDistanceField(vec2 point, vec2 start, vec2 end, float width, float capType) {
|
||
if (capType == ${qt("butt")}) {
|
||
return buttCapDistanceField(point, start, end);
|
||
} else if (capType == ${qt("square")}) {
|
||
return squareCapDistanceField(point, start, end, width);
|
||
}
|
||
return roundCapDistanceField(point, start, end, width);
|
||
}
|
||
|
||
float joinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float joinType) {
|
||
if (joinType == ${qt("bevel")}) {
|
||
return bevelJoinField(point, start, end, width, joinAngle);
|
||
} else if (joinType == ${qt("miter")}) {
|
||
return miterJoinDistanceField(point, start, end, width, joinAngle);
|
||
}
|
||
return roundJoinDistanceField(point, start, end, width);
|
||
}
|
||
|
||
float computeSegmentPointDistance(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float capType, float joinType) {
|
||
if (isCap(joinAngle)) {
|
||
return capDistanceField(point, start, end, width, capType);
|
||
}
|
||
return joinDistanceField(point, start, end, width, joinAngle, joinType);
|
||
}
|
||
|
||
float distanceFromSegment(vec2 point, vec2 start, vec2 end) {
|
||
vec2 tangent = end - start;
|
||
vec2 startToPoint = point - start;
|
||
// inspire by capsule fn in https://iquilezles.org/articles/distfunctions/
|
||
float h = clamp(dot(startToPoint, tangent) / dot(tangent, tangent), 0.0, 1.0);
|
||
return length(startToPoint - tangent * h);
|
||
}
|
||
|
||
void main(void) {
|
||
${this.attributes_.map(e=>` ${e.varyingType} ${e.name} = ${e.varyingName}; // assign to original attribute name`).join(`
|
||
`)}
|
||
|
||
vec2 currentPointPx = gl_FragCoord.xy / u_pixelRatio;
|
||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||
vec2 worldPos = pxToWorld(currentPointPx);
|
||
if (
|
||
abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (
|
||
worldPos[0] < u_renderExtent[0] ||
|
||
worldPos[1] < u_renderExtent[1] ||
|
||
worldPos[0] > u_renderExtent[2] ||
|
||
worldPos[1] > u_renderExtent[3]
|
||
)
|
||
) {
|
||
discard;
|
||
}
|
||
#endif
|
||
|
||
float segmentLengthPx = length(v_segmentEndPx - v_segmentStartPx);
|
||
segmentLengthPx = max(segmentLengthPx, 1.17549429e-38); // avoid divide by zero
|
||
vec2 segmentTangent = (v_segmentEndPx - v_segmentStartPx) / segmentLengthPx;
|
||
vec2 segmentNormal = vec2(-segmentTangent.y, segmentTangent.x);
|
||
vec2 startToPointPx = currentPointPx - v_segmentStartPx;
|
||
float lengthToPointPx = max(0., min(dot(segmentTangent, startToPointPx), segmentLengthPx));
|
||
float currentLengthPx = lengthToPointPx + v_distancePx;
|
||
float currentRadiusPx = distanceFromSegment(currentPointPx, v_segmentStartPx, v_segmentEndPx);
|
||
float currentRadiusRatio = dot(segmentNormal, startToPointPx) * 2. / v_width;
|
||
currentLineMetric = mix(v_measureStart, v_measureEnd, lengthToPointPx / segmentLengthPx);
|
||
|
||
if (${this.discardExpression_}) { discard; }
|
||
|
||
float capType = ${this.strokeCapExpression_};
|
||
float joinType = ${this.strokeJoinExpression_};
|
||
float segmentStartDistance = computeSegmentPointDistance(currentPointPx, v_segmentStartPx, v_segmentEndPx, v_width, v_angleStart, capType, joinType);
|
||
float segmentEndDistance = computeSegmentPointDistance(currentPointPx, v_segmentEndPx, v_segmentStartPx, v_width, v_angleEnd, capType, joinType);
|
||
float distanceField = max(
|
||
segmentDistanceField(currentPointPx, v_segmentStartPx, v_segmentEndPx, v_width),
|
||
max(segmentStartDistance, segmentEndDistance)
|
||
);
|
||
distanceField = max(distanceField, ${this.strokeDistanceFieldExpression_});
|
||
|
||
vec4 color = ${this.strokeColorExpression_};
|
||
color.a *= smoothstep(0.5, -0.5, distanceField);
|
||
gl_FragColor = color;
|
||
gl_FragColor.a *= u_globalAlpha;
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
if (u_hitDetection > 0) {
|
||
if (gl_FragColor.a < 0.1) { discard; };
|
||
gl_FragColor = v_hitColor;
|
||
}
|
||
}`:null}getFillVertexShader(){return this.hasFill_?`${yi}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
attribute vec2 a_position;
|
||
attribute vec2 a_hitColor;
|
||
|
||
varying vec4 v_hitColor;
|
||
|
||
${this.attributes_.map(e=>`attribute ${e.type} ${e.name};
|
||
varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.vertexShaderFunctions_.join(`
|
||
`)}
|
||
void main(void) {
|
||
gl_Position = u_projectionMatrix * vec4(a_position, u_depth, 1.0);
|
||
v_hitColor = unpackColor(a_hitColor);
|
||
${this.attributes_.map(e=>` ${e.varyingName} = ${e.varyingExpression};`).join(`
|
||
`)}
|
||
}`:null}getFillFragmentShader(){return this.hasFill_?`${yi}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
varying vec4 v_hitColor;
|
||
${this.attributes_.map(e=>`varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.fragmentShaderFunctions_.join(`
|
||
`)}
|
||
vec2 pxToWorld(vec2 pxPos) {
|
||
vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
|
||
return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;
|
||
}
|
||
|
||
vec2 worldToPx(vec2 worldPos) {
|
||
vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);
|
||
return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;
|
||
}
|
||
|
||
void main(void) {
|
||
${this.attributes_.map(e=>` ${e.varyingType} ${e.name} = ${e.varyingName}; // assign to original attribute name`).join(`
|
||
`)}
|
||
vec2 pxPos = gl_FragCoord.xy / u_pixelRatio;
|
||
vec2 pxOrigin = worldToPx(u_patternOrigin);
|
||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||
vec2 worldPos = pxToWorld(pxPos);
|
||
if (
|
||
abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (
|
||
worldPos[0] < u_renderExtent[0] ||
|
||
worldPos[1] < u_renderExtent[1] ||
|
||
worldPos[0] > u_renderExtent[2] ||
|
||
worldPos[1] > u_renderExtent[3]
|
||
)
|
||
) {
|
||
discard;
|
||
}
|
||
#endif
|
||
if (${this.discardExpression_}) { discard; }
|
||
gl_FragColor = ${this.fillColorExpression_};
|
||
gl_FragColor.a *= u_globalAlpha;
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
if (u_hitDetection > 0) {
|
||
if (gl_FragColor.a < 0.1) { discard; };
|
||
gl_FragColor = v_hitColor;
|
||
}
|
||
}`:null}}class Zr{constructor(){this.globalCounter_=0,this.refToFeature_=new Map,this.uidToRef_=new Map,this.freeGlobalRef_=[],this.polygonBatch={entries:{},geometriesCount:0,verticesCount:0,ringsCount:0},this.pointBatch={entries:{},geometriesCount:0},this.lineStringBatch={entries:{},geometriesCount:0,verticesCount:0}}addFeatures(e,t){for(let n=0;n<e.length;n++)this.addFeature(e[n],t)}addFeature(e,t){let n=e.getGeometry();n&&(t&&(n=n.clone(),n.applyTransform(t)),this.addGeometry_(n,e))}clearFeatureEntryInPointBatch_(e){const t=D(e),n=this.pointBatch.entries[t];if(n)return this.pointBatch.geometriesCount-=n.flatCoordss.length,delete this.pointBatch.entries[t],n}clearFeatureEntryInLineStringBatch_(e){const t=D(e),n=this.lineStringBatch.entries[t];if(n)return this.lineStringBatch.verticesCount-=n.verticesCount,this.lineStringBatch.geometriesCount-=n.flatCoordss.length,delete this.lineStringBatch.entries[t],n}clearFeatureEntryInPolygonBatch_(e){const t=D(e),n=this.polygonBatch.entries[t];if(n)return this.polygonBatch.verticesCount-=n.verticesCount,this.polygonBatch.ringsCount-=n.ringsCount,this.polygonBatch.geometriesCount-=n.flatCoordss.length,delete this.polygonBatch.entries[t],n}addGeometry_(e,t){const n=e.getType();switch(n){case"GeometryCollection":{const i=e.getGeometriesArray();for(const r of i)this.addGeometry_(r,t);break}case"MultiPolygon":{const i=e;this.addCoordinates_(n,i.getFlatCoordinates(),i.getEndss(),t,D(t),i.getStride());break}case"MultiLineString":{const i=e;this.addCoordinates_(n,i.getFlatCoordinates(),i.getEnds(),t,D(t),i.getStride());break}case"MultiPoint":{const i=e;this.addCoordinates_(n,i.getFlatCoordinates(),null,t,D(t),i.getStride());break}case"Polygon":{const i=e;this.addCoordinates_(n,i.getFlatCoordinates(),i.getEnds(),t,D(t),i.getStride());break}case"Point":{const i=e;this.addCoordinates_(n,i.getFlatCoordinates(),null,t,D(t),i.getStride());break}case"LineString":case"LinearRing":{const i=e,r=i.getStride();this.addCoordinates_(n,i.getFlatCoordinates(),null,t,D(t),r,i.getLayout?.());break}}}addCoordinates_(e,t,n,i,r,o,a){let l;switch(e){case"MultiPolygon":{const h=n;for(let c=0,u=h.length;c<u;c++){let d=h[c];const f=c>0?h[c-1]:null,g=f?f[f.length-1]:0,m=d[d.length-1];d=g>0?d.map(_=>_-g):d,this.addCoordinates_("Polygon",t.slice(g,m),d,i,r,o,a)}break}case"MultiLineString":{const h=n;for(let c=0,u=h.length;c<u;c++){const d=c>0?h[c-1]:0;this.addCoordinates_("LineString",t.slice(d,h[c]),null,i,r,o,a)}break}case"MultiPoint":for(let h=0,c=t.length;h<c;h+=o)this.addCoordinates_("Point",t.slice(h,h+2),null,i,r,null,null);break;case"Polygon":{const h=n;if(i instanceof Qe){const d=gu(t,h);if(d.length>1){this.addCoordinates_("MultiPolygon",t,d,i,r,o,a);return}}this.polygonBatch.entries[r]||(this.polygonBatch.entries[r]=this.addRefToEntry_(r,{feature:i,flatCoordss:[],verticesCount:0,ringsCount:0,ringsVerticesCounts:[]})),l=t.length/o;const c=n.length,u=n.map((d,f,g)=>f>0?(d-g[f-1])/o:d/o);this.polygonBatch.verticesCount+=l,this.polygonBatch.ringsCount+=c,this.polygonBatch.geometriesCount++,this.polygonBatch.entries[r].flatCoordss.push(Wy(t,o)),this.polygonBatch.entries[r].ringsVerticesCounts.push(u),this.polygonBatch.entries[r].verticesCount+=l,this.polygonBatch.entries[r].ringsCount+=c;for(let d=0,f=h.length;d<f;d++){const g=d>0?h[d-1]:0;this.addCoordinates_("LinearRing",t.slice(g,h[d]),null,i,r,o,a)}break}case"Point":this.pointBatch.entries[r]||(this.pointBatch.entries[r]=this.addRefToEntry_(r,{feature:i,flatCoordss:[]})),this.pointBatch.geometriesCount++,this.pointBatch.entries[r].flatCoordss.push(t);break;case"LineString":case"LinearRing":this.lineStringBatch.entries[r]||(this.lineStringBatch.entries[r]=this.addRefToEntry_(r,{feature:i,flatCoordss:[],verticesCount:0})),l=t.length/o,this.lineStringBatch.verticesCount+=l,this.lineStringBatch.geometriesCount++,this.lineStringBatch.entries[r].flatCoordss.push(Vy(t,o,a)),this.lineStringBatch.entries[r].verticesCount+=l;break}}addRefToEntry_(e,t){const n=this.uidToRef_.get(e),i=n||this.freeGlobalRef_.pop()||++this.globalCounter_;return t.ref=i,n||(this.refToFeature_.set(i,t.feature),this.uidToRef_.set(e,i)),t}removeRef_(e,t){if(!e)throw new Error("This feature has no ref: "+t);this.refToFeature_.delete(e),this.uidToRef_.delete(t),this.freeGlobalRef_.push(e)}changeFeature(e,t){if(!this.uidToRef_.get(D(e)))return;this.removeFeature(e);let n=e.getGeometry();n&&(t&&(n=n.clone(),n.applyTransform(t)),this.addGeometry_(n,e))}removeFeature(e){let t=this.clearFeatureEntryInPointBatch_(e);t=this.clearFeatureEntryInPolygonBatch_(e)||t,t=this.clearFeatureEntryInLineStringBatch_(e)||t,t&&this.removeRef_(t.ref,D(t.feature))}clear(){this.polygonBatch.entries={},this.polygonBatch.geometriesCount=0,this.polygonBatch.verticesCount=0,this.polygonBatch.ringsCount=0,this.lineStringBatch.entries={},this.lineStringBatch.geometriesCount=0,this.lineStringBatch.verticesCount=0,this.pointBatch.entries={},this.pointBatch.geometriesCount=0,this.globalCounter_=0,this.freeGlobalRef_=[],this.refToFeature_.clear(),this.uidToRef_.clear()}getFeatureFromRef(e){return this.refToFeature_.get(e)}isEmpty(){return this.globalCounter_===0}filter(e){const t=new Zr;t.globalCounter_=this.globalCounter_,t.uidToRef_=this.uidToRef_,t.refToFeature_=this.refToFeature_;let n=!0;for(const i of this.refToFeature_.values())e(i)&&(t.addFeature(i),n=!1);return n?new Zr:t}}function Wy(s,e){return e===2?s:s.filter((t,n)=>n%e<2)}function Vy(s,e,t){return e===3&&t==="XYM"?s:e===4?s.filter((n,i)=>i%e!==2):e===3?s.map((n,i)=>i%e!==2?n:0):new Array(s.length*1.5).fill(0).map((n,i)=>i%3===2?0:s[Math.round(i/1.5)])}function Zy(){const s='function t(t,n,x=2){const o=n&&n.length,i=o?n[0]*x:t.length;let f=e(t,0,i,x,!0);const l=[];if(!f||f.next===f.prev)return l;let c,y,h;if(o&&(f=function(t,n,r,x){const o=[];for(let r=0,i=n.length;r<i;r++){const f=e(t,n[r]*x,r<i-1?n[r+1]*x:t.length,x,!1);f===f.next&&(f.steiner=!0),o.push(a(f))}o.sort(u);for(let t=0;t<o.length;t++)r=s(o[t],r);return r}(t,n,f,x)),t.length>80*x){c=t[0],y=t[1];let e=c,n=y;for(let r=x;r<i;r+=x){const x=t[r],o=t[r+1];x<c&&(c=x),o<y&&(y=o),x>e&&(e=x),o>n&&(n=o)}h=Math.max(e-c,n-y),h=0!==h?32767/h:0}return r(f,l,x,c,y,h,0),l}function e(t,e,n,r,x){let o;if(x===function(t,e,n,r){let x=0;for(let o=e,i=n-r;o<n;o+=r)x+=(t[i]-t[o])*(t[o+1]+t[i+1]),i=o;return x}(t,e,n,r)>0)for(let x=e;x<n;x+=r)o=d(x/r|0,t[x],t[x+1],o);else for(let x=n-r;x>=e;x-=r)o=d(x/r|0,t[x],t[x+1],o);return o&&b(o,o.next)&&(w(o),o=o.next),o}function n(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!b(r,r.next)&&0!==v(r.prev,r,r.next))r=r.next;else{if(w(r),r=e=r.prev,r===r.next)break;n=!0}}while(n||r!==e);return e}function r(t,e,u,s,l,a,y){if(!t)return;!y&&a&&function(t,e,n,r){let x=t;do{0===x.z&&(x.z=c(x.x,x.y,e,n,r)),x.prevZ=x.prev,x.nextZ=x.next,x=x.next}while(x!==t);x.prevZ.nextZ=null,x.prevZ=null,function(t){let e,n=1;do{let r,x=t;t=null;let o=null;for(e=0;x;){e++;let i=x,f=0;for(let t=0;t<n&&(f++,i=i.nextZ,i);t++);let u=n;for(;f>0||u>0&&i;)0!==f&&(0===u||!i||x.z<=i.z)?(r=x,x=x.nextZ,f--):(r=i,i=i.nextZ,u--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;x=i}o.nextZ=null,n*=2}while(e>1)}(x)}(t,s,l,a);let h=t;for(;t.prev!==t.next;){const c=t.prev,p=t.next;if(a?o(t,s,l,a):x(t))e.push(c.i,t.i,p.i),w(t),t=p.next,h=p.next;else if((t=p)===h){y?1===y?r(t=i(n(t),e),e,u,s,l,a,2):2===y&&f(t,e,u,s,l,a):r(n(t),e,u,s,l,a,1);break}}}function x(t){const e=t.prev,n=t,r=t.next;if(v(e,n,r)>=0)return!1;const x=e.x,o=n.x,i=r.x,f=e.y,u=n.y,s=r.y,l=Math.min(x,o,i),c=Math.min(f,u,s),a=Math.max(x,o,i),y=Math.max(f,u,s);let p=r.next;for(;p!==e;){if(p.x>=l&&p.x<=a&&p.y>=c&&p.y<=y&&h(x,f,o,u,i,s,p.x,p.y)&&v(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function o(t,e,n,r){const x=t.prev,o=t,i=t.next;if(v(x,o,i)>=0)return!1;const f=x.x,u=o.x,s=i.x,l=x.y,a=o.y,y=i.y,p=Math.min(f,u,s),b=Math.min(l,a,y),M=Math.max(f,u,s),m=Math.max(l,a,y),A=c(p,b,e,n,r),g=c(M,m,e,n,r);let Z=t.prevZ,d=t.nextZ;for(;Z&&Z.z>=A&&d&&d.z<=g;){if(Z.x>=p&&Z.x<=M&&Z.y>=b&&Z.y<=m&&Z!==x&&Z!==i&&h(f,l,u,a,s,y,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0)return!1;if(Z=Z.prevZ,d.x>=p&&d.x<=M&&d.y>=b&&d.y<=m&&d!==x&&d!==i&&h(f,l,u,a,s,y,d.x,d.y)&&v(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;Z&&Z.z>=A;){if(Z.x>=p&&Z.x<=M&&Z.y>=b&&Z.y<=m&&Z!==x&&Z!==i&&h(f,l,u,a,s,y,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0)return!1;Z=Z.prevZ}for(;d&&d.z<=g;){if(d.x>=p&&d.x<=M&&d.y>=b&&d.y<=m&&d!==x&&d!==i&&h(f,l,u,a,s,y,d.x,d.y)&&v(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function i(t,e){let r=t;do{const n=r.prev,x=r.next.next;!b(n,x)&&M(n,r,r.next,x)&&g(n,x)&&g(x,n)&&(e.push(n.i,r.i,x.i),w(r),w(r.next),r=t=x),r=r.next}while(r!==t);return n(r)}function f(t,e,x,o,i,f){let u=t;do{let t=u.next.next;for(;t!==u.prev;){if(u.i!==t.i&&p(u,t)){let s=Z(u,t);return u=n(u,u.next),s=n(s,s.next),r(u,e,x,o,i,f,0),void r(s,e,x,o,i,f,0)}t=t.next}u=u.next}while(u!==t)}function u(t,e){let n=t.x-e.x;if(0===n&&(n=t.y-e.y,0===n)){n=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return n}function s(t,e){const r=function(t,e){let n=e;const r=t.x,x=t.y;let o,i=-1/0;if(b(t,n))return n;do{if(b(t,n.next))return n.next;if(x<=n.y&&x>=n.next.y&&n.next.y!==n.y){const t=n.x+(x-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>i&&(i=t,o=n.x<n.next.x?n:n.next,t===r))return o}n=n.next}while(n!==e);if(!o)return null;const f=o,u=o.x,s=o.y;let c=1/0;n=o;do{if(r>=n.x&&n.x>=u&&r!==n.x&&y(x<s?r:i,x,u,s,x<s?i:r,x,n.x,n.y)){const e=Math.abs(x-n.y)/(r-n.x);g(n,t)&&(e<c||e===c&&(n.x>o.x||n.x===o.x&&l(o,n)))&&(o=n,c=e)}n=n.next}while(n!==f);return o}(t,e);if(!r)return e;const x=Z(r,t);return n(x,x.next),n(r,r.next)}function l(t,e){return v(t.prev,t,e.prev)<0&&v(e.next,t,t.next)<0}function c(t,e,n,r,x){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*x|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*x|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function a(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function y(t,e,n,r,x,o,i,f){return(x-i)*(e-f)>=(t-i)*(o-f)&&(t-i)*(r-f)>=(n-i)*(e-f)&&(n-i)*(o-f)>=(x-i)*(r-f)}function h(t,e,n,r,x,o,i,f){return!(t===i&&e===f)&&y(t,e,n,r,x,o,i,f)}function p(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&M(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(g(t,e)&&g(e,t)&&function(t,e){let n=t,r=!1;const x=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&x<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(v(t.prev,t,e.prev)||v(t,e.prev,e))||b(t,e)&&v(t.prev,t,t.next)>0&&v(e.prev,e,e.next)>0)}function v(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function b(t,e){return t.x===e.x&&t.y===e.y}function M(t,e,n,r){const x=A(v(t,e,n)),o=A(v(t,e,r)),i=A(v(n,r,t)),f=A(v(n,r,e));return x!==o&&i!==f||(!(0!==x||!m(t,n,e))||(!(0!==o||!m(t,r,e))||(!(0!==i||!m(n,t,r))||!(0!==f||!m(n,e,r)))))}function m(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function A(t){return t>0?1:t<0?-1:0}function g(t,e){return v(t.prev,t,t.next)<0?v(t,e,t.next)>=0&&v(t,t.prev,e)>=0:v(t,e,t.prev)<0||v(t,t.next,e)<0}function Z(t,e){const n=F(t.i,t.x,t.y),r=F(e.i,e.x,e.y),x=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=x,x.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function d(t,e,n,r){const x=F(t,e,n);return r?(x.next=r.next,x.prev=r,r.next.prev=x,r.next=x):(x.prev=x,x.next=x),x}function w(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function F(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function E(t,e){const n=e[0],r=e[1];return e[0]=t[0]*n+t[2]*r+t[4],e[1]=t[1]*n+t[3]*r+t[5],e}function I(t,e){const n=(r=e)[0]*r[3]-r[1]*r[2];var r;!function(t,e){if(!t)throw new Error(e)}(0!==n,"Transformation matrix cannot be inverted");const x=e[0],o=e[1],i=e[2],f=e[3],u=e[4],s=e[5];return t[0]=f/n,t[1]=-o/n,t[2]=-i/n,t[3]=x/n,t[4]=(i*s-f*u)/n,t[5]=-(x*s-o*u)/n,t}new Array(6);const z=[],B={vertexAttributesPosition:0,instanceAttributesPosition:0,indicesPosition:0};function P(t,e,n,r,x){const o=t[e++],i=t[e++],f=z;f.length=r;for(let n=0;n<f.length;n++)f[n]=t[e+n];let u=x?x.instanceAttributesPosition:0;return n[u++]=o,n[u++]=i,f.length&&(n.set(f,u),u+=f.length),B.instanceAttributesPosition=u,B}function N(t,e,n,r,x,o,i,f,u,s){const l=[t[e],t[e+1]],c=[t[n],t[n+1]],a=t[e+2],y=t[n+2],h=E(f,[...l]),p=E(f,[...c]);function v(t,e,n){const r=Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])),x=[(e[0]-t[0])/r,(e[1]-t[1])/r],o=[-x[1],x[0]],i=Math.sqrt((n[0]-t[0])*(n[0]-t[0])+(n[1]-t[1])*(n[1]-t[1])),f=[(n[0]-t[0])/i,(n[1]-t[1])/i];let u=0===r||0===i?0:Math.acos((s=f[0]*x[0]+f[1]*x[1],l=-1,c=1,Math.min(Math.max(s,l),c)));var s,l,c;u=Math.max(u,1e-5);return f[0]*o[0]+f[1]*o[1]>0?u:2*Math.PI-u}let b=-1,M=-1,m=s;const A=null!==x;if(null!==r){b=v(h,p,E(f,[...[t[r],t[r+1]]])),Math.cos(b)<=.985&&(m+=Math.tan((b-Math.PI)/2))}if(A){M=v(p,h,E(f,[...[t[x],t[x+1]]])),Math.cos(M)<=.985&&(m+=Math.tan((Math.PI-M)/2))}const g=Math.pow(2,24),Z=u%g,d=Math.floor(u/g)*g;return o.push(l[0],l[1],a,c[0],c[1],y,b,M,Z,d,s),o.push(...i),{length:u+Math.sqrt((p[0]-h[0])*(p[0]-h[0])+(p[1]-h[1])*(p[1]-h[1])),angle:m}}function R(e,n,r,x,o){const i=2+o;let f=n;const u=e.slice(f,f+o);f+=o;const s=e[f++];let l=0;const c=new Array(s-1);for(let t=0;t<s;t++)l+=e[f++],t<s-1&&(c[t]=l);const a=e.slice(f,f+2*l),y=t(a,c,2);for(let t=0;t<y.length;t++)x.push(y[t]+r.length/i);for(let t=0;t<a.length;t+=2)r.push(a[t],a[t+1],...u);return f+2*l}const S="GENERATE_POLYGON_BUFFERS",T="GENERATE_POINT_BUFFERS",_="GENERATE_LINE_STRING_BUFFERS",O=self;O.onmessage=t=>{const e=t.data;switch(e.type){case T:{const t=2,n=2,r=e.customAttributesSize,x=n+r,o=new Float32Array(e.renderInstructions),i=o.length/x*(t+r),f=Uint32Array.from([0,1,3,1,2,3]),u=Float32Array.from([-1,-1,1,-1,1,1,-1,1]),s=new Float32Array(i);let l;for(let t=0;t<o.length;t+=x)l=P(o,t,s,r,l);const c=Object.assign({indicesBuffer:f.buffer,vertexAttributesBuffer:u.buffer,instanceAttributesBuffer:s.buffer,renderInstructions:o.buffer},e);O.postMessage(c,[u.buffer,s.buffer,f.buffer,o.buffer]);break}case _:{const t=[],n=e.customAttributesSize,r=3,x=new Float32Array(e.renderInstructions);let o=0;const i=[1,0,0,1,0,0];let f,u;for(I(i,e.renderInstructionsTransform);o<x.length;){u=Array.from(x.slice(o,o+n)),o+=n,f=x[o++];const e=o,s=o+(f-1)*r,l=x[e]===x[s]&&x[e+1]===x[s+1];let c=0,a=0;for(let n=0;n<f-1;n++){let y=null;n>0?y=o+(n-1)*r:l&&(y=s-r);let h=null;n<f-2?h=o+(n+2)*r:l&&(h=e+r);const p=N(x,o+n*r,o+(n+1)*r,y,h,t,u,i,c,a);c=p.length,a=p.angle}o+=f*r}const s=Uint32Array.from([0,1,3,1,2,3]),l=Float32Array.from([-1,-1,1,-1,1,1,-1,1]),c=Float32Array.from(t),a=Object.assign({indicesBuffer:s.buffer,vertexAttributesBuffer:l.buffer,instanceAttributesBuffer:c.buffer,renderInstructions:x.buffer},e);O.postMessage(a,[l.buffer,c.buffer,s.buffer,x.buffer]);break}case S:{const t=[],n=[],r=e.customAttributesSize,x=new Float32Array(e.renderInstructions);let o=0;for(;o<x.length;)o=R(x,o,t,n,r);const i=Uint32Array.from(n),f=Float32Array.from(t),u=Float32Array.from([]),s=Object.assign({indicesBuffer:i.buffer,vertexAttributesBuffer:f.buffer,instanceAttributesBuffer:u.buffer,renderInstructions:x.buffer},e);O.postMessage(s,[f.buffer,u.buffer,i.buffer,x.buffer]);break}}};';return new Worker(typeof Blob>"u"?"data:application/javascript;base64,"+Buffer.from(s,"binary").toString("base64"):URL.createObjectURL(new Blob([s],{type:"application/javascript"})))}const aa={GENERATE_POLYGON_BUFFERS:"GENERATE_POLYGON_BUFFERS",GENERATE_POINT_BUFFERS:"GENERATE_POINT_BUFFERS",GENERATE_LINE_STRING_BUFFERS:"GENERATE_LINE_STRING_BUFFERS"};function Ky(s,e){e=e||[];const t=256,n=t-1,i=Math.floor(s/t/t/t)/n,r=Math.floor(s/t/t)%t/n,o=Math.floor(s/t)%t/n,a=s%t/n;return e[0]=i*256*255+r*255,e[1]=o*256*255+a*255,e}function Hy(s){let e=0;const t=256,n=t-1;return e+=Math.round(s[0]*t*t*t*n),e+=Math.round(s[1]*t*t*n),e+=Math.round(s[2]*t*n),e+=Math.round(s[3]*n),e}function th(s,e,t,n){let i=0;for(const r in e){const o=e[r],a=o.callback.call(t,t.feature);let l=a?.[0]??a;l===Ya&&console.warn('The "has" operator might return false positives.'),l===void 0?l=Ya:l===null&&(l=0),s[n+i++]=l,!(!o.size||o.size===1)&&(s[n+i++]=a[1],!(o.size<3)&&(s[n+i++]=a[2],!(o.size<4)&&(s[n+i++]=a[3])))}return i}function po(s){return Object.keys(s).reduce((e,t)=>e+(s[t].size||1),0)}function qy(s,e,t,n){const i=(2+po(t))*s.geometriesCount;(!e||e.length!==i)&&(e=new Float32Array(i));const r=[];let o=0;for(const a in s.entries){const l=s.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++)r[0]=l.flatCoordss[h][0],r[1]=l.flatCoordss[h][1],fe(n,r),e[o++]=r[0],e[o++]=r[1],o+=th(e,t,l,o)}return e}function Jy(s,e,t,n){const i=3*s.verticesCount+(1+po(t))*s.geometriesCount;(!e||e.length!==i)&&(e=new Float32Array(i));const r=[];let o=0;for(const a in s.entries){const l=s.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++){r.length=l.flatCoordss[h].length,Gt(l.flatCoordss[h],0,r.length,3,n,r,3),o+=th(e,t,l,o),e[o++]=r.length/3;for(let u=0,d=r.length;u<d;u+=3)e[o++]=r[u],e[o++]=r[u+1],e[o++]=r[u+2]}}return e}function Qy(s,e,t,n){const i=2*s.verticesCount+(1+po(t))*s.geometriesCount+s.ringsCount;(!e||e.length!==i)&&(e=new Float32Array(i));const r=[];let o=0;for(const a in s.entries){const l=s.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++){r.length=l.flatCoordss[h].length,Gt(l.flatCoordss[h],0,r.length,2,n,r),o+=th(e,t,l,o),e[o++]=l.ringsVerticesCounts[h].length;for(let u=0,d=l.ringsVerticesCounts[h].length;u<d;u++)e[o++]=l.ringsVerticesCounts[h][u];for(let u=0,d=r.length;u<d;u+=2)e[o++]=r[u],e[o++]=r[u+1]}}return e}function Kr(s){return(JSON.stringify(s).split("").reduce((t,n)=>(t<<5)-t+n.charCodeAt(0),0)>>>0).toString()}function nh(s,e,t,n){if(`${n}radius`in s&&n!=="icon-"){let i=W(t,s[`${n}radius`],N);if(`${n}radius2`in s){const r=W(t,s[`${n}radius2`],N);i=`max(${i}, ${r})`}`${n}stroke-width`in s&&(i=`(${i} + ${W(t,s[`${n}stroke-width`],N)} * 0.5)`),e.setSymbolSizeExpression(`vec2(${i} * 2. + 0.5)`)}if(`${n}scale`in s){const i=W(t,s[`${n}scale`],yt);e.setSymbolSizeExpression(`${e.getSymbolSizeExpression()} * ${i}`)}`${n}displacement`in s&&e.setSymbolOffsetExpression(W(t,s[`${n}displacement`],nt)),`${n}rotation`in s&&e.setSymbolRotationExpression(W(t,s[`${n}rotation`],N)),`${n}rotate-with-view`in s&&e.setSymbolRotateWithView(!!s[`${n}rotate-with-view`])}function xd(s,e,t,n,i){let r="vec4(0.)";if(e!==null&&(r=e),t!==null&&n!==null){const l=`smoothstep(-${n} + 0.63, -${n} - 0.58, ${s})`;r=`mix(${t}, ${r}, ${l})`}const o=`(1.0 - smoothstep(-0.63, 0.58, ${s}))`;let a=`${r} * vec4(1.0, 1.0, 1.0, ${o})`;return i!==null&&(a=`${a} * vec4(1.0, 1.0, 1.0, ${i})`),a}function ih(s,e,t,n,i){const r=new Image;r.crossOrigin=s[`${n}cross-origin`]===void 0?"anonymous":s[`${n}cross-origin`],te(typeof s[`${n}src`]=="string",`WebGL layers do not support expressions for the ${n}src style property`),r.src=s[`${n}src`],t[`u_texture${i}_size`]=()=>r.complete?[r.width,r.height]:[0,0],e.addUniform(`u_texture${i}_size`,"vec2");const o=`u_texture${i}_size`;return t[`u_texture${i}`]=r,e.addUniform(`u_texture${i}`,"sampler2D"),o}function sh(s,e,t,n,i){let r=W(t,s[`${e}offset`],yt);if(`${e}offset-origin`in s)switch(s[`${e}offset-origin`]){case"top-right":r=`vec2(${n}.x, 0.) + ${i} * vec2(-1., 0.) + ${r} * vec2(-1., 1.)`;break;case"bottom-left":r=`vec2(0., ${n}.y) + ${i} * vec2(0., -1.) + ${r} * vec2(1., -1.)`;break;case"bottom-right":r=`${n} - ${i} - ${r}`;break}return r}function ex(s,e,t,n){n.functions.circleDistanceField=`float circleDistanceField(vec2 point, float radius) {
|
||
return length(point) - radius;
|
||
}`,nh(s,e,n,"circle-");let i=null;"circle-opacity"in s&&(i=W(n,s["circle-opacity"],N));let r="coordsPx";"circle-scale"in s&&(r=`coordsPx / ${W(n,s["circle-scale"],yt)}`);let o=null;"circle-fill-color"in s&&(o=W(n,s["circle-fill-color"],_e));let a=null;"circle-stroke-color"in s&&(a=W(n,s["circle-stroke-color"],_e));let l=W(n,s["circle-radius"],N),h=null;"circle-stroke-width"in s&&(h=W(n,s["circle-stroke-width"],N),l=`(${l} + ${h} * 0.5)`);const c=`circleDistanceField(${r}, ${l})`,u=xd(c,o,a,h,i);e.setSymbolColorExpression(u)}function tx(s,e,t,n){n.functions.round=`float round(float v) {
|
||
return sign(v) * floor(abs(v) + 0.5);
|
||
}`,n.functions.starDistanceField=`float starDistanceField(vec2 point, float numPoints, float radius, float radius2, float angle) {
|
||
float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle
|
||
float c = cos(startAngle);
|
||
float s = sin(startAngle);
|
||
vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);
|
||
float alpha = TWO_PI / numPoints; // the angle of one sector
|
||
float beta = atan(pointRotated.y, pointRotated.x);
|
||
float gamma = round(beta / alpha) * alpha; // angle in sector
|
||
c = cos(-gamma);
|
||
s = sin(-gamma);
|
||
vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));
|
||
vec2 tipToPoint = inSector + vec2(-radius, 0.);
|
||
vec2 edgeNormal = vec2(radius2 * sin(alpha * 0.5), -radius2 * cos(alpha * 0.5) + radius);
|
||
return dot(normalize(edgeNormal), tipToPoint);
|
||
}`,n.functions.regularDistanceField=`float regularDistanceField(vec2 point, float numPoints, float radius, float angle) {
|
||
float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle
|
||
float c = cos(startAngle);
|
||
float s = sin(startAngle);
|
||
vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);
|
||
float alpha = TWO_PI / numPoints; // the angle of one sector
|
||
float radiusIn = radius * cos(PI / numPoints);
|
||
float beta = atan(pointRotated.y, pointRotated.x);
|
||
float gamma = round((beta - alpha * 0.5) / alpha) * alpha + alpha * 0.5; // angle in sector from mid
|
||
c = cos(-gamma);
|
||
s = sin(-gamma);
|
||
vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));
|
||
return inSector.x - radiusIn;
|
||
}`,nh(s,e,n,"shape-");let i=null;"shape-opacity"in s&&(i=W(n,s["shape-opacity"],N));let r="coordsPx";"shape-scale"in s&&(r=`coordsPx / ${W(n,s["shape-scale"],yt)}`);let o=null;"shape-fill-color"in s&&(o=W(n,s["shape-fill-color"],_e));let a=null;"shape-stroke-color"in s&&(a=W(n,s["shape-stroke-color"],_e));let l=null;"shape-stroke-width"in s&&(l=W(n,s["shape-stroke-width"],N));const h=W(n,s["shape-points"],N);let c="0.";"shape-angle"in s&&(c=W(n,s["shape-angle"],N));let u,d=W(n,s["shape-radius"],N);if(l!==null&&(d=`${d} + ${l} * 0.5`),"shape-radius2"in s){let g=W(n,s["shape-radius2"],N);l!==null&&(g=`${g} + ${l} * 0.5`),u=`starDistanceField(${r}, ${h}, ${d}, ${g}, ${c})`}else u=`regularDistanceField(${r}, ${h}, ${d}, ${c})`;const f=xd(u,o,a,l,i);e.setSymbolColorExpression(f)}function nx(s,e,t,n){let i="vec4(1.0)";"icon-color"in s&&(i=W(n,s["icon-color"],_e)),"icon-opacity"in s&&(i=`${i} * vec4(1.0, 1.0, 1.0, ${W(n,s["icon-opacity"],N)})`);const r=Kr(s["icon-src"]),o=ih(s,e,t,"icon-",r);if(e.setSymbolColorExpression(`${i} * texture2D(u_texture${r}, v_texCoord)`).setSymbolSizeExpression(o),"icon-width"in s&&"icon-height"in s&&e.setSymbolSizeExpression(`vec2(${W(n,s["icon-width"],N)}, ${W(n,s["icon-height"],N)})`),"icon-offset"in s&&"icon-size"in s){const a=W(n,s["icon-size"],nt),l=e.getSymbolSizeExpression();e.setSymbolSizeExpression(a);const h=sh(s,"icon-",n,"v_quadSizePx",a);e.setTextureCoordinateExpression(`(vec4((${h}).xyxy) + vec4(0., 0., ${a})) / (${l}).xyxy`)}if(nh(s,e,n,"icon-"),"icon-anchor"in s){const a=W(n,s["icon-anchor"],nt);let l="1.0";"icon-scale"in s&&(l=W(n,s["icon-scale"],yt));let h;s["icon-anchor-x-units"]==="pixels"&&s["icon-anchor-y-units"]==="pixels"?h=`${a} * ${l}`:s["icon-anchor-x-units"]==="pixels"?h=`${a} * vec2(vec2(${l}).x, v_quadSizePx.y)`:s["icon-anchor-y-units"]==="pixels"?h=`${a} * vec2(v_quadSizePx.x, vec2(${l}).x)`:h=`${a} * v_quadSizePx`;let c=`v_quadSizePx * vec2(0.5, -0.5) + ${h} * vec2(-1., 1.)`;if("icon-anchor-origin"in s)switch(s["icon-anchor-origin"]){case"top-right":c=`v_quadSizePx * -0.5 + ${h}`;break;case"bottom-left":c=`v_quadSizePx * 0.5 - ${h}`;break;case"bottom-right":c=`v_quadSizePx * vec2(-0.5, 0.5) + ${h} * vec2(1., -1.)`;break}e.setSymbolOffsetExpression(`${e.getSymbolOffsetExpression()} + ${c}`)}}function ix(s,e,t,n){if("stroke-color"in s&&e.setStrokeColorExpression(W(n,s["stroke-color"],_e)),"stroke-pattern-src"in s){const i=Kr(s["stroke-pattern-src"]),r=ih(s,e,t,"stroke-pattern-",i);let o=r,a="vec2(0.)";"stroke-pattern-offset"in s&&"stroke-pattern-size"in s&&(o=W(n,s["stroke-pattern-size"],nt),a=sh(s,"stroke-pattern-",n,r,o));let l="0.";"stroke-pattern-spacing"in s&&(l=W(n,s["stroke-pattern-spacing"],N));let h="0.";"stroke-pattern-start-offset"in s&&(h=W(n,s["stroke-pattern-start-offset"],N)),n.functions.sampleStrokePattern=`vec4 sampleStrokePattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, float spacingPx, float startOffsetPx, float currentLengthPx, float currentRadiusRatio, float lineWidth) {
|
||
float currentLengthScaled = (currentLengthPx - startOffsetPx) * sampleSize.y / lineWidth;
|
||
float spacingScaled = spacingPx * sampleSize.y / lineWidth;
|
||
float uCoordPx = mod(currentLengthScaled, (sampleSize.x + spacingScaled));
|
||
float isInsideOfPattern = step(uCoordPx, sampleSize.x);
|
||
float vCoordPx = (-currentRadiusRatio * 0.5 + 0.5) * sampleSize.y;
|
||
// make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels
|
||
uCoordPx = clamp(uCoordPx, 0.5, sampleSize.x - 0.5);
|
||
vCoordPx = clamp(vCoordPx, 0.5, sampleSize.y - 0.5);
|
||
vec2 texCoord = (vec2(uCoordPx, vCoordPx) + textureOffset) / textureSize;
|
||
return texture2D(texture, texCoord) * vec4(1.0, 1.0, 1.0, isInsideOfPattern);
|
||
}`;const c=`u_texture${i}`;let u="1.";"stroke-color"in s&&(u=e.getStrokeColorExpression()),e.setStrokeColorExpression(`${u} * sampleStrokePattern(${c}, ${r}, ${a}, ${o}, ${l}, ${h}, currentLengthPx, currentRadiusRatio, v_width)`),n.functions.computeStrokePatternLength=`float computeStrokePatternLength(vec2 sampleSize, float spacingPx, float lineWidth) {
|
||
float patternLengthPx = sampleSize.x / sampleSize.y * lineWidth;
|
||
return patternLengthPx + spacingPx;
|
||
}`,e.setStrokePatternLengthExpression(`computeStrokePatternLength(${o}, ${l}, v_width)`)}if("stroke-width"in s&&e.setStrokeWidthExpression(W(n,s["stroke-width"],N)),"stroke-offset"in s&&e.setStrokeOffsetExpression(W(n,s["stroke-offset"],N)),"stroke-line-cap"in s&&e.setStrokeCapExpression(W(n,s["stroke-line-cap"],Ie)),"stroke-line-join"in s&&e.setStrokeJoinExpression(W(n,s["stroke-line-join"],Ie)),"stroke-miter-limit"in s&&e.setStrokeMiterLimitExpression(W(n,s["stroke-miter-limit"],N)),"stroke-line-dash"in s){n.functions.getSingleDashDistance=`float getSingleDashDistance(float distance, float radius, float dashOffset, float dashLength, float dashLengthTotal, float capType, float lineWidth) {
|
||
float localDistance = mod(distance, dashLengthTotal);
|
||
float distanceSegment = abs(localDistance - dashOffset - dashLength * 0.5) - dashLength * 0.5;
|
||
distanceSegment = min(distanceSegment, dashLengthTotal - localDistance);
|
||
if (capType == ${qt("square")}) {
|
||
distanceSegment -= lineWidth * 0.5;
|
||
} else if (capType == ${qt("round")}) {
|
||
distanceSegment = min(distanceSegment, sqrt(distanceSegment * distanceSegment + radius * radius) - lineWidth * 0.5);
|
||
}
|
||
return distanceSegment;
|
||
}`;let i=s["stroke-line-dash"].map(g=>W(n,g,N));i.length%2===1&&(i=[...i,...i]);let r="0.";"stroke-line-dash-offset"in s&&(r=W(n,s["stroke-line-dash-offset"],N));const a=`dashDistanceField_${Kr(s["stroke-line-dash"])}`,l=i.map((g,m)=>`float dashLength${m}`).join(", "),h=i.map((g,m)=>`dashLength${m}`).join(" + ");let c="0.",u=`getSingleDashDistance(distance, radius, ${c}, dashLength0, totalDashLength, capType, lineWidth)`;for(let g=2;g<i.length;g+=2)c=`${c} + dashLength${g-2} + dashLength${g-1}`,u=`min(${u}, getSingleDashDistance(distance, radius, ${c}, dashLength${g}, totalDashLength, capType, lineWidth))`;n.functions[a]=`float ${a}(float distance, float radius, float capType, float lineWidth, ${l}) {
|
||
float totalDashLength = ${h};
|
||
return ${u};
|
||
}`;const d=i.map((g,m)=>`${g}`).join(", ");e.setStrokeDistanceFieldExpression(`${a}(currentLengthPx + ${r}, currentRadiusPx, capType, v_width, ${d})`);let f=i.join(" + ");e.getStrokePatternLengthExpression()&&(n.functions.combinePatternLengths=`float combinePatternLengths(float patternLength1, float patternLength2) {
|
||
return patternLength1 * patternLength2;
|
||
}`,f=`combinePatternLengths(${e.getStrokePatternLengthExpression()}, ${f})`),e.setStrokePatternLengthExpression(f)}}function sx(s,e,t,n){if("fill-color"in s&&e.setFillColorExpression(W(n,s["fill-color"],_e)),"fill-pattern-src"in s){const i=Kr(s["fill-pattern-src"]),r=ih(s,e,t,"fill-pattern-",i);let o=r,a="vec2(0.)";"fill-pattern-offset"in s&&"fill-pattern-size"in s&&(o=W(n,s["fill-pattern-size"],nt),a=sh(s,"fill-pattern-",n,r,o)),n.functions.sampleFillPattern=`vec4 sampleFillPattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, vec2 pxOrigin, vec2 pxPosition) {
|
||
float scaleRatio = pow(2., mod(u_zoom + 0.5, 1.) - 0.5);
|
||
vec2 pxRelativePos = pxPosition - pxOrigin;
|
||
// rotate the relative position from origin by the current view rotation
|
||
pxRelativePos = vec2(pxRelativePos.x * cos(u_rotation) - pxRelativePos.y * sin(u_rotation), pxRelativePos.x * sin(u_rotation) + pxRelativePos.y * cos(u_rotation));
|
||
// sample position is computed according to the sample offset & size
|
||
vec2 samplePos = mod(pxRelativePos / scaleRatio, sampleSize);
|
||
// also make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels
|
||
samplePos = clamp(samplePos, vec2(0.5), sampleSize - vec2(0.5));
|
||
samplePos.y = sampleSize.y - samplePos.y; // invert y axis so that images appear upright
|
||
return texture2D(texture, (samplePos + textureOffset) / textureSize);
|
||
}`;const l=`u_texture${i}`;let h="1.";"fill-color"in s&&(h=e.getFillColorExpression()),e.setFillColorExpression(`${h} * sampleFillPattern(${l}, ${r}, ${a}, ${o}, pxOrigin, pxPos)`)}}function Tc(s,e,t){const n=dd(),i=new yd,r={};if("icon-src"in s?nx(s,i,r,n):"shape-points"in s?tx(s,i,r,n):"circle-radius"in s&&ex(s,i,r,n),ix(s,i,r,n),sx(s,i,r,n),t){const l=W(n,t,ve);i.setFragmentDiscardExpression(`!${l}`)}const o={};function a(l,h,c,u){if(!n[l])return;const d=ja(c),f=eh(c);i.addAttribute(`a_${h}`,d),o[h]={size:f,callback:u}}return a("geometryType",gd,Ie,l=>Ms(Ol(l.getGeometry()))),a("featureId",fd,Ie|N,l=>{const h=l.getId()??null;return typeof h=="string"?Ms(h):h}),_d(i,n),{builder:i,attributes:{...o,...pd(n)},uniforms:{...r,...md(n,e)}}}const rx=[];let la;function ox(){return la||(la=Zy()),la}let ax=0;const mt={POSITION:"a_position",LOCAL_POSITION:"a_localPosition",SEGMENT_START:"a_segmentStart",SEGMENT_END:"a_segmentEnd",MEASURE_START:"a_measureStart",MEASURE_END:"a_measureEnd",ANGLE_TANGENT_SUM:"a_angleTangentSum",JOIN_ANGLES:"a_joinAngles",DISTANCE_LOW:"a_distanceLow",DISTANCE_HIGH:"a_distanceHigh"};class lx{constructor(e,t,n,i){this.helper_,this.hitDetectionEnabled_=!!i,this.styleShaders=hx(e,t),this.customAttributes_={},this.uniforms_={},this.hitDetectionEnabled_&&(this.customAttributes_.hitColor={callback(){return Ky(this.ref,rx)},size:2});for(const r of this.styleShaders){for(const o in r.attributes)o in this.customAttributes_||(this.customAttributes_[o]=r.attributes[o]);for(const o in r.uniforms)o in this.uniforms_||(this.uniforms_[o]=r.uniforms[o])}this.renderPasses_=this.styleShaders.map(r=>{const o={},a=Object.entries(this.customAttributes_).map(([l,h])=>({name:l in r.attributes||l==="hitColor"?`a_${l}`:null,size:h.size||1,type:Oe.FLOAT}));return r.builder.getFillVertexShader()&&(o.fillRenderPass={vertexShader:r.builder.getFillVertexShader(),fragmentShader:r.builder.getFillFragmentShader(),attributesDesc:[{name:mt.POSITION,size:2,type:Oe.FLOAT},...a],instancedAttributesDesc:[],instancePrimitiveVertexCount:3}),r.builder.getStrokeVertexShader()&&(o.strokeRenderPass={vertexShader:r.builder.getStrokeVertexShader(),fragmentShader:r.builder.getStrokeFragmentShader(),attributesDesc:[{name:mt.LOCAL_POSITION,size:2,type:Oe.FLOAT}],instancedAttributesDesc:[{name:mt.SEGMENT_START,size:2,type:Oe.FLOAT},{name:mt.MEASURE_START,size:1,type:Oe.FLOAT},{name:mt.SEGMENT_END,size:2,type:Oe.FLOAT},{name:mt.MEASURE_END,size:1,type:Oe.FLOAT},{name:mt.JOIN_ANGLES,size:2,type:Oe.FLOAT},{name:mt.DISTANCE_LOW,size:1,type:Oe.FLOAT},{name:mt.DISTANCE_HIGH,size:1,type:Oe.FLOAT},{name:mt.ANGLE_TANGENT_SUM,size:1,type:Oe.FLOAT},...a],instancePrimitiveVertexCount:6}),r.builder.getSymbolVertexShader()&&(o.symbolRenderPass={vertexShader:r.builder.getSymbolVertexShader(),fragmentShader:r.builder.getSymbolFragmentShader(),attributesDesc:[{name:mt.LOCAL_POSITION,size:2,type:Oe.FLOAT}],instancedAttributesDesc:[{name:mt.POSITION,size:2,type:Oe.FLOAT},...a],instancePrimitiveVertexCount:6}),o}),this.hasFill_=this.renderPasses_.some(r=>r.fillRenderPass),this.hasStroke_=this.renderPasses_.some(r=>r.strokeRenderPass),this.hasSymbol_=this.renderPasses_.some(r=>r.symbolRenderPass),this.setHelper(n)}async generateBuffers(e,t){if(e.isEmpty())return null;const n=this.generateRenderInstructions_(e,t),[i,r,o]=await Promise.all([this.generateBuffersForType_(n.polygonInstructions,"Polygon",t),this.generateBuffersForType_(n.lineStringInstructions,"LineString",t),this.generateBuffersForType_(n.pointInstructions,"Point",t)]),a=Rs(Ce(),t);return{polygonBuffers:i,lineStringBuffers:r,pointBuffers:o,invertVerticesTransform:a}}generateRenderInstructions_(e,t){const n=this.hasFill_?Qy(e.polygonBatch,new Float32Array(0),this.customAttributes_,t):null,i=this.hasStroke_?Jy(e.lineStringBatch,new Float32Array(0),this.customAttributes_,t):null,r=this.hasSymbol_?qy(e.pointBatch,new Float32Array(0),this.customAttributes_,t):null;return{polygonInstructions:n,lineStringInstructions:i,pointInstructions:r}}generateBuffersForType_(e,t,n){if(e===null)return null;const i=ax++;let r;switch(t){case"Polygon":r=aa.GENERATE_POLYGON_BUFFERS;break;case"LineString":r=aa.GENERATE_LINE_STRING_BUFFERS;break;case"Point":r=aa.GENERATE_POINT_BUFFERS;break}const o={id:i,type:r,renderInstructions:e.buffer,renderInstructionsTransform:n,customAttributesSize:po(this.customAttributes_)},a=ox();return a.postMessage(o,[e.buffer]),e=null,new Promise(l=>{const h=c=>{const u=c.data;if(u.id!==i||(a.removeEventListener("message",h),!this.helper_.getGL()))return;const d=new ia(Kl,na).fromArrayBuffer(u.indicesBuffer),f=new ia(Wr,na).fromArrayBuffer(u.vertexAttributesBuffer),g=new ia(Wr,na).fromArrayBuffer(u.instanceAttributesBuffer);this.helper_.flushBufferData(d),this.helper_.flushBufferData(f),this.helper_.flushBufferData(g),l([d,f,g])};a.addEventListener("message",h)})}render(e,t,n){for(const i of this.renderPasses_)i.fillRenderPass&&this.renderInternal_(e.polygonBuffers[0],e.polygonBuffers[1],e.polygonBuffers[2],i.fillRenderPass,t,n),i.strokeRenderPass&&this.renderInternal_(e.lineStringBuffers[0],e.lineStringBuffers[1],e.lineStringBuffers[2],i.strokeRenderPass,t,n),i.symbolRenderPass&&this.renderInternal_(e.pointBuffers[0],e.pointBuffers[1],e.pointBuffers[2],i.symbolRenderPass,t,n)}renderInternal_(e,t,n,i,r,o){const a=e.getSize();if(a===0)return;const l=i.instancedAttributesDesc.length;if(this.helper_.useProgram(i.program,r),this.helper_.bindBuffer(t),this.helper_.bindBuffer(e),this.helper_.enableAttributes(i.attributesDesc),this.helper_.bindBuffer(n),this.helper_.enableAttributesInstanced(i.instancedAttributesDesc),o(),l){const h=i.instancedAttributesDesc.reduce((u,d)=>u+(d.size||1),0),c=n.getSize()/h;this.helper_.drawElementsInstanced(0,a,c)}else this.helper_.drawElements(0,a)}setHelper(e,t=null){this.helper_=e;for(const n of this.renderPasses_)n.fillRenderPass&&(n.fillRenderPass.program=this.helper_.getProgram(n.fillRenderPass.fragmentShader,n.fillRenderPass.vertexShader)),n.strokeRenderPass&&(n.strokeRenderPass.program=this.helper_.getProgram(n.strokeRenderPass.fragmentShader,n.strokeRenderPass.vertexShader)),n.symbolRenderPass&&(n.symbolRenderPass.program=this.helper_.getProgram(n.symbolRenderPass.fragmentShader,n.symbolRenderPass.vertexShader));this.helper_.addUniforms(this.uniforms_),t&&(t.polygonBuffers&&(this.helper_.flushBufferData(t.polygonBuffers[0]),this.helper_.flushBufferData(t.polygonBuffers[1]),this.helper_.flushBufferData(t.polygonBuffers[2])),t.lineStringBuffers&&(this.helper_.flushBufferData(t.lineStringBuffers[0]),this.helper_.flushBufferData(t.lineStringBuffers[1]),this.helper_.flushBufferData(t.lineStringBuffers[2])),t.pointBuffers&&(this.helper_.flushBufferData(t.pointBuffers[0]),this.helper_.flushBufferData(t.pointBuffers[1]),this.helper_.flushBufferData(t.pointBuffers[2])))}}function hx(s,e){const t=Array.isArray(s)?s:[s];if("style"in t[0]){const n=[],i=t,r=[];for(const o of i){const a=Array.isArray(o.style)?o.style:[o.style];let l=o.filter;o.else&&r.length&&(l=["all",...r.map(c=>["!",c])],o.filter&&l.push(o.filter),l.length<3&&(l=l[1])),o.filter&&r.push(o.filter);const h=a.map(c=>Tc(c,e,l));n.push(...h)}return n}return"builder"in t[0]?t:t.map(n=>Tc(n,e,null))}const bt=new Uint8Array(4);class cx{constructor(e,t){this.helper_=e;const n=e.getGL();this.texture_=n.createTexture(),this.framebuffer_=n.createFramebuffer(),this.depthbuffer_=n.createRenderbuffer(),this.size_=t||[1,1],this.data_=new Uint8Array(0),this.dataCacheDirty_=!0,this.updateSize_()}setSize(e){Bt(e,this.size_)||(this.size_[0]=e[0],this.size_[1]=e[1],this.updateSize_())}getSize(){return this.size_}clearCachedData(){this.dataCacheDirty_=!0}readAll(){if(this.dataCacheDirty_){const e=this.size_,t=this.helper_.getGL();t.bindFramebuffer(t.FRAMEBUFFER,this.framebuffer_),t.readPixels(0,0,e[0],e[1],t.RGBA,t.UNSIGNED_BYTE,this.data_),this.dataCacheDirty_=!1}return this.data_}readPixel(e,t){if(e<0||t<0||e>this.size_[0]||t>=this.size_[1])return bt[0]=0,bt[1]=0,bt[2]=0,bt[3]=0,bt;this.readAll();const n=Math.floor(e)+(this.size_[1]-Math.floor(t)-1)*this.size_[0];return bt[0]=this.data_[n*4],bt[1]=this.data_[n*4+1],bt[2]=this.data_[n*4+2],bt[3]=this.data_[n*4+3],bt}getTexture(){return this.texture_}getFramebuffer(){return this.framebuffer_}getDepthbuffer(){return this.depthbuffer_}updateSize_(){const e=this.size_,t=this.helper_.getGL();this.texture_=this.helper_.createTexture(e,null,this.texture_),t.bindFramebuffer(t.FRAMEBUFFER,this.framebuffer_),t.viewport(0,0,e[0],e[1]),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.texture_,0),t.bindRenderbuffer(t.RENDERBUFFER,this.depthbuffer_),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,e[0],e[1]),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.depthbuffer_),this.data_=new Uint8Array(e[0]*e[1]*4)}}function ux(s,e){const t=s.viewState.projection,i=e.getSource().getWrapX()&&t.canWrapX(),r=t.getExtent(),o=s.extent,a=i?ie(r):null,l=i?Math.ceil((o[2]-r[2])/a)+1:1;return[i?Math.floor((o[0]-r[0])/a):0,l,a]}const Ei={...Vt,RENDER_EXTENT:"u_renderExtent",PATTERN_ORIGIN:"u_patternOrigin",GLOBAL_ALPHA:"u_globalAlpha"};class dx extends Hl{constructor(e,t){const n={[Ei.RENDER_EXTENT]:[0,0,0,0],[Ei.PATTERN_ORIGIN]:[0,0],[Ei.GLOBAL_ALPHA]:1};super(e,{uniforms:n,postProcesses:t.postProcesses}),this.hitDetectionEnabled_=!t.disableHitDetection,this.hitRenderTarget_,this.sourceRevision_=-1,this.previousExtent_=tt(),this.currentTransform_=Ce(),this.tmpCoords_=[0,0],this.tmpTransform_=Ce(),this.tmpMat4_=hd(),this.currentFrameStateTransform_=Ce(),this.styleVariables_={},this.style_=[],this.styleRenderer_=null,this.buffers_=null,this.applyOptions_(t),this.batch_=new Zr,this.initialFeaturesAdded_=!1,this.sourceListenKeys_=null}addInitialFeatures_(e){const t=this.getLayer().getSource();let n;this.batch_.addFeatures(t.getFeatures(),n),this.sourceListenKeys_=[J(t,Le.ADDFEATURE,this.handleSourceFeatureAdded_.bind(this,n)),J(t,Le.CHANGEFEATURE,this.handleSourceFeatureChanged_.bind(this,n),this),J(t,Le.REMOVEFEATURE,this.handleSourceFeatureDelete_,this),J(t,Le.CLEAR,this.handleSourceFeatureClear_,this)]}applyOptions_(e){this.styleVariables_=e.variables,this.style_=e.style}createRenderers_(){this.buffers_=null,this.styleRenderer_=new lx(this.style_,this.styleVariables_,this.helper,this.hitDetectionEnabled_)}reset(e){this.applyOptions_(e),this.helper&&this.createRenderers_(),super.reset(e)}afterHelperCreated(){this.styleRenderer_?this.styleRenderer_.setHelper(this.helper,this.buffers_):this.createRenderers_(),this.hitDetectionEnabled_&&(this.hitRenderTarget_=new cx(this.helper))}handleSourceFeatureAdded_(e,t){const n=t.feature;this.batch_.addFeature(n,e)}handleSourceFeatureChanged_(e,t){const n=t.feature;this.batch_.changeFeature(n,e)}handleSourceFeatureDelete_(e){const t=e.feature;this.batch_.removeFeature(t)}handleSourceFeatureClear_(){this.batch_.clear()}applyUniforms_(e){tu(this.tmpTransform_,this.currentFrameStateTransform_),ro(this.tmpTransform_,e),this.helper.setUniformMatrixValue(Ei.PROJECTION_MATRIX,Xa(this.tmpMat4_,this.tmpTransform_)),Rs(this.tmpTransform_,this.tmpTransform_),this.helper.setUniformMatrixValue(Ei.SCREEN_TO_WORLD_MATRIX,Xa(this.tmpMat4_,this.tmpTransform_)),this.tmpCoords_[0]=0,this.tmpCoords_[1]=0,Rs(this.tmpTransform_,e),fe(this.tmpTransform_,this.tmpCoords_),this.helper.setUniformFloatVec2(Ei.PATTERN_ORIGIN,this.tmpCoords_)}renderFrame(e){const t=this.helper.getGL();this.preRender(t,e);const[n,i,r]=ux(e,this.getLayer());this.helper.prepareDraw(e),this.renderWorlds(e,!1,n,i,r),this.helper.finalizeDraw(e,this.dispatchPreComposeEvent,this.dispatchPostComposeEvent);const o=this.helper.getCanvas();return this.hitDetectionEnabled_&&(this.renderWorlds(e,!0,n,i,r),this.hitRenderTarget_.clearCachedData()),this.postRender(t,e),o}prepareFrameInternal(e){this.initialFeaturesAdded_||(this.addInitialFeatures_(e),this.initialFeaturesAdded_=!0);const t=this.getLayer(),n=t.getSource(),i=e.viewState,r=!e.viewHints[he.ANIMATING]&&!e.viewHints[he.INTERACTING],o=!Hn(this.previousExtent_,e.extent),a=this.sourceRevision_<n.getRevision();if(a&&(this.sourceRevision_=n.getRevision()),r&&(o||a)){const l=i.projection,h=i.resolution,c=t instanceof Hi?t.getRenderBuffer():0,u=rn(e.extent,c*h);n.loadFeatures(u,h,l),this.ready=!1;const d=this.helper.makeProjectionTransform(e,Ce());this.styleRenderer_.generateBuffers(this.batch_,d).then(f=>{this.buffers_&&this.disposeBuffers(this.buffers_),this.buffers_=f,this.ready=!0,this.getLayer().changed()}),this.previousExtent_=e.extent.slice()}return!0}renderWorlds(e,t,n,i,r){let o=n;t&&(this.hitRenderTarget_.setSize([Math.floor(e.size[0]/2),Math.floor(e.size[1]/2)]),this.helper.prepareDrawToRenderTarget(e,this.hitRenderTarget_,!0));do this.helper.makeProjectionTransform(e,this.currentFrameStateTransform_),nu(this.currentFrameStateTransform_,o*r,0),this.buffers_&&this.styleRenderer_.render(this.buffers_,e,()=>{this.applyUniforms_(this.buffers_.invertVerticesTransform),this.helper.applyHitDetectionUniform(t)});while(++o<i)}forEachFeatureAtCoordinate(e,t,n,i,r){if(te(this.hitDetectionEnabled_,"`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has been disabled using the `disableHitDetection: true` option."),!this.styleRenderer_||!this.hitDetectionEnabled_)return;const o=fe(t.coordinateToPixelTransform,e.slice()),a=this.hitRenderTarget_.readPixel(o[0]/2,o[1]/2),l=[a[0]/255,a[1]/255,a[2]/255,a[3]/255],h=Hy(l),c=this.batch_.getFeatureFromRef(h);if(c)return i(c,this.getLayer(),null)}disposeBuffers(e){const t=n=>{for(const i of n)i&&this.helper.deleteBuffer(i)};e.pointBuffers&&t(e.pointBuffers),e.lineStringBuffers&&t(e.lineStringBuffers),e.polygonBuffers&&t(e.polygonBuffers)}disposeInternal(){this.buffers_&&this.disposeBuffers(this.buffers_),this.sourceListenKeys_&&(this.sourceListenKeys_.forEach(function(e){ue(e)}),this.sourceListenKeys_=null),super.disposeInternal()}renderDeclutter(){}}const Wt={BLUR:"blur",GRADIENT:"gradient",RADIUS:"radius"},fx=["#00f","#0ff","#0f0","#ff0","#f00"];class X0 extends Hi{constructor(e){e=e||{};const t=Object.assign({},e);delete t.gradient,delete t.radius,delete t.blur,delete t.weight,super(t),this.filter_=e.filter??!0,this.styleVariables_=e.variables||{},this.gradient_=null,this.addChangeListener(Wt.GRADIENT,this.handleGradientChanged_),this.setGradient(e.gradient?e.gradient:fx),this.setBlur(e.blur!==void 0?e.blur:15),this.setRadius(e.radius!==void 0?e.radius:8);const n=e.weight?e.weight:"weight";this.weight_=n,this.setRenderOrder(null)}getBlur(){return this.get(Wt.BLUR)}getGradient(){return this.get(Wt.GRADIENT)}getRadius(){return this.get(Wt.RADIUS)}handleGradientChanged_(){this.gradient_=gx(this.getGradient())}setBlur(e){const t=this.get(Wt.BLUR);if(this.set(Wt.BLUR,e),typeof e=="number"&&typeof t=="number"){this.changed();return}this.clearRenderer()}setGradient(e){this.set(Wt.GRADIENT,e)}setRadius(e){const t=this.get(Wt.RADIUS);if(this.set(Wt.RADIUS,e),typeof e=="number"&&typeof t=="number"){this.changed();return}this.clearRenderer()}setFilter(e){this.filter_=e,this.changed(),this.clearRenderer()}setWeight(e){this.weight_=e,this.changed(),this.clearRenderer()}createRenderer(){const e=new yd,t=dd(),n=W(t,this.filter_,ve);let i=W(t,this.getRadius(),N),r=W(t,this.getBlur(),N);const o={};typeof this.getBlur()=="number"&&(r="a_blur",o.a_blur=()=>this.getBlur(),e.addUniform("a_blur","float")),typeof this.getRadius()=="number"&&(i="a_radius",o.a_radius=()=>this.getRadius(),e.addUniform("a_radius","float"));const a={};let l=null;if(typeof this.weight_=="string"||typeof this.weight_=="function"){const u=typeof this.weight_=="string"?d=>d.get(this.weight_):this.weight_;a.prop_weight={size:1,callback:d=>{const f=u(d);return f!==void 0?ge(f,0,1):1}},l="a_prop_weight",e.addAttribute("a_prop_weight","float")}else{const u=["clamp",this.weight_,0,1];l=W(t,u,N)}e.addFragmentShaderFunction(`float getBlurSlope() {
|
||
float blur = max(1., ${r});
|
||
float radius = ${i};
|
||
return radius / blur;
|
||
}`).setSymbolSizeExpression(`vec2(${i} + ${r}) * 2.`).setSymbolColorExpression(`vec4(smoothstep(0., 1., (1. - length(coordsPx * 2. / v_quadSizePx)) * getBlurSlope()) * ${l})`).setStrokeColorExpression(`vec4(smoothstep(0., 1., (1. - length(currentRadiusPx * 2. / v_width)) * getBlurSlope()) * ${l})`).setStrokeWidthExpression(`(${i} + ${r}) * 2.`).setFillColorExpression(`vec4(${l})`).setFragmentDiscardExpression(`!${n}`),_d(e,t);const h=pd(t),c=md(t,this.styleVariables_);return new dx(this,{className:this.getClassName(),variables:this.styleVariables_,style:{builder:e,attributes:{...h,...a},uniforms:{...c,...o}},disableHitDetection:!1,postProcesses:[{fragmentShader:`
|
||
precision mediump float;
|
||
|
||
uniform sampler2D u_image;
|
||
uniform sampler2D u_gradientTexture;
|
||
uniform float u_opacity;
|
||
|
||
varying vec2 v_texCoord;
|
||
|
||
void main() {
|
||
vec4 color = texture2D(u_image, v_texCoord);
|
||
gl_FragColor.a = color.a * u_opacity;
|
||
gl_FragColor.rgb = texture2D(u_gradientTexture, vec2(0.5, color.a)).rgb;
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
}`,uniforms:{u_gradientTexture:()=>this.gradient_,u_opacity:()=>this.getOpacity()}}]})}updateStyleVariables(e){Object.assign(this.styleVariables_,e),this.changed()}renderDeclutter(){}}function gx(s){const n=we(1,256),i=n.createLinearGradient(0,0,1,256),r=1/(s.length-1);for(let o=0,a=s.length;o<a;++o)i.addColorStop(o*r,s[o]);return n.fillStyle=i,n.fillRect(0,0,1,256),n.canvas}const me={ACCURACY:"accuracy",ACCURACY_GEOMETRY:"accuracyGeometry",ALTITUDE:"altitude",ALTITUDE_ACCURACY:"altitudeAccuracy",HEADING:"heading",POSITION:"position",PROJECTION:"projection",SPEED:"speed",TRACKING:"tracking",TRACKING_OPTIONS:"trackingOptions"},_x={ERROR:"error"};class mx extends ut{constructor(e){super(_x.ERROR),this.code=e.code,this.message=e.message}}class Y0 extends Rt{constructor(e){super(),this.on,this.once,this.un,e=e||{},this.position_=null,this.transform_=ug,this.watchId_=void 0,this.addChangeListener(me.PROJECTION,this.handleProjectionChanged_),this.addChangeListener(me.TRACKING,this.handleTrackingChanged_),e.projection!==void 0&&this.setProjection(e.projection),e.trackingOptions!==void 0&&this.setTrackingOptions(e.trackingOptions),this.setTracking(e.tracking!==void 0?e.tracking:!1)}disposeInternal(){this.setTracking(!1),super.disposeInternal()}handleProjectionChanged_(){const e=this.getProjection();e&&(this.transform_=Gs(de("EPSG:4326"),e),this.position_&&this.set(me.POSITION,this.transform_(this.position_)))}handleTrackingChanged_(){if("geolocation"in navigator){const e=this.getTracking();e&&this.watchId_===void 0?this.watchId_=navigator.geolocation.watchPosition(this.positionChange_.bind(this),this.positionError_.bind(this),this.getTrackingOptions()):!e&&this.watchId_!==void 0&&(navigator.geolocation.clearWatch(this.watchId_),this.watchId_=void 0)}}positionChange_(e){const t=e.coords;this.set(me.ACCURACY,t.accuracy),this.set(me.ALTITUDE,t.altitude===null?void 0:t.altitude),this.set(me.ALTITUDE_ACCURACY,t.altitudeAccuracy===null?void 0:t.altitudeAccuracy),this.set(me.HEADING,t.heading===null?void 0:Ke(t.heading)),this.position_?(this.position_[0]=t.longitude,this.position_[1]=t.latitude):this.position_=[t.longitude,t.latitude];const n=this.transform_(this.position_);this.set(me.POSITION,n.slice()),this.set(me.SPEED,t.speed===null?void 0:t.speed);const i=Gg(this.position_,t.accuracy);i.applyTransform(this.transform_),this.set(me.ACCURACY_GEOMETRY,i),this.changed()}positionError_(e){this.dispatchEvent(new mx(e))}getAccuracy(){return this.get(me.ACCURACY)}getAccuracyGeometry(){return this.get(me.ACCURACY_GEOMETRY)||null}getAltitude(){return this.get(me.ALTITUDE)}getAltitudeAccuracy(){return this.get(me.ALTITUDE_ACCURACY)}getHeading(){return this.get(me.HEADING)}getPosition(){return this.get(me.POSITION)}getProjection(){return this.get(me.PROJECTION)}getSpeed(){return this.get(me.SPEED)}getTracking(){return this.get(me.TRACKING)}getTrackingOptions(){return this.get(me.TRACKING_OPTIONS)}setProjection(e){this.set(me.PROJECTION,de(e))}setTracking(e){this.set(me.TRACKING,e)}setTrackingOptions(e){this.set(me.TRACKING_OPTIONS,e)}}function Rn(s,e){const t=s.length;return e<0?s[e+t]:e>=t?s[e-t]:s[e]}function Ii(s,e){const t=s.length;let n=Math.floor(e);const i=e-n;n>=t?n-=t:n<0&&(n+=t);let r=n+1;r>=t&&(r-=t);const o=s[n],a=o[0],l=o[1],h=s[r],c=h[0]-a,u=h[1]-l;return[a+c*i,l+u*i]}const ur={index:-1,endIndex:NaN,closestTargetDistance:1/0};function Ed(s,e,t,n){const i=s[0],r=s[1];let o=1/0,a=-1,l=NaN;for(let u=0;u<e.targets.length;++u){const d=e.targets[u],f=d.coordinates;let g=1/0,m;for(let _=0;_<f.length-1;++_){const p=f[_],y=f[_+1],E=Rd(i,r,p,y);E.squaredDistance<g&&(g=E.squaredDistance,m=_+E.along)}g<o&&(o=g,d.ring&&e.targetIndex===u&&(d.endIndex>d.startIndex?m<d.startIndex&&(m+=f.length):d.endIndex<d.startIndex&&m>d.startIndex&&(m-=f.length)),l=m,a=u)}const h=e.targets[a];let c=h.ring;if(e.targetIndex===a&&c){const u=Ii(h.coordinates,l),d=t.getPixelFromCoordinate(u),f=t.getPixelFromCoordinate(e.startCoord);vi(d,f)>n&&(c=!1)}if(c){const u=h.coordinates,d=u.length,f=h.startIndex,g=l;if(f<g){const m=gr(u,f,g);gr(u,f,g-d)<m&&(l-=d)}else{const m=gr(u,f,g);gr(u,f,g+d)<m&&(l+=d)}}return ur.index=a,ur.endIndex=l,ur.closestTargetDistance=o,ur}function Td(s,e){const t=[];for(let n=0;n<e.length;++n){const r=e[n].getGeometry();Cd(s,r,t)}return t}function Cd(s,e,t){if(e instanceof ht){dr(s,e.getCoordinates(),!1,t);return}if(e instanceof on){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i)dr(s,n[i],!1,t);return}if(e instanceof qe){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i)dr(s,n[i],!0,t);return}if(e instanceof An){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i){const o=n[i];for(let a=0,l=o.length;a<l;++a)dr(s,o[a],!0,t)}return}if(e instanceof He){const n=e.getGeometries();for(let i=0;i<n.length;++i)Cd(s,n[i],t);return}}function dr(s,e,t,n){const i=s[0],r=s[1];for(let o=0,a=e.length-1;o<a;++o){const l=e[o],h=e[o+1],c=Rd(i,r,l,h);if(c.squaredDistance===0){const u=o+c.along;n.push({coordinates:e,ring:t,startIndex:u,endIndex:u});return}}}function fr(s,e){return Qt(s[0],s[1],e[0],e[1])}function gr(s,e,t){let n,i;e<t?(n=e,i=t):(n=t,i=e);const r=Math.ceil(n),o=Math.floor(i);if(r>o){const l=Ii(s,n),h=Ii(s,i);return fr(l,h)}let a=0;if(n<r){const l=Ii(s,n),h=Rn(s,r);a+=fr(l,h)}if(o<i){const l=Rn(s,o),h=Ii(s,i);a+=fr(l,h)}for(let l=r;l<o-1;++l){const h=Rn(s,l),c=Rn(s,l+1);a+=fr(h,c)}return a}const ha={along:0,squaredDistance:0};function Rd(s,e,t,n){const i=t[0],r=t[1],o=n[0],a=n[1],l=o-i,h=a-r;let c=0,u=i,d=r;return(l!==0||h!==0)&&(c=ge(((s-i)*l+(e-r)*h)/(l*l+h*h),0,1),u+=l*c,d+=h*c),ha.along=c,ha.squaredDistance=Yi(Qt(s,e,u,d),10),ha}const _r={DRAWSTART:"drawstart",DRAWEND:"drawend",DRAWABORT:"drawabort"};class mr extends ut{constructor(e,t){super(e),this.feature=t}}class j0 extends si{constructor(e){const t=e;t.stopDown||(t.stopDown=Xi),super(t),this.on,this.once,this.un,this.options_=e,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=e.source?e.source:null,this.features_=e.features?e.features:null,this.snapTolerance_=e.snapTolerance?e.snapTolerance:12,this.type_=e.type,this.mode_=yx(this.type_),this.stopClick_=!!e.stopClick,this.ignoreNextUpEvent_=!1,this.minPoints_=e.minPoints?e.minPoints:this.mode_==="Polygon"?3:2,this.maxPoints_=this.mode_==="Circle"?2:e.maxPoints?e.maxPoints:1/0,this.finishCondition_=e.finishCondition?e.finishCondition:Pn,this.geometryLayout_=e.geometryLayout?e.geometryLayout:"XY";let n=e.geometryFunction;if(!n){const i=this.mode_;if(i==="Circle")n=(r,o,a)=>{const l=o||new mo([NaN,NaN]),h=pe(r[0]),c=Gi(h,pe(r[r.length-1]));return l.setCenterAndRadius(h,Math.sqrt(c),this.geometryLayout_),l};else{let r;i==="Point"?r=lt:i==="LineString"?r=ht:i==="Polygon"&&(r=qe),n=(o,a,l)=>(a?i==="Polygon"?o[0].length?a.setCoordinates([o[0].concat([o[0][0]])],this.geometryLayout_):a.setCoordinates([],this.geometryLayout_):a.setCoordinates(o,this.geometryLayout_):a=new r(o,this.geometryLayout_),a)}}this.geometryFunction_=n,this.dragVertexDelay_=e.dragVertexDelay!==void 0?e.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=e.clickTolerance?e.clickTolerance*e.clickTolerance:36,this.overlay_=new Xl({source:new td({useSpatialIndex:!1,wrapX:e.wrapX?e.wrapX:!1}),style:e.style?e.style:px(),updateWhileInteracting:!0}),this.geometryName_=e.geometryName,this.condition_=e.condition?e.condition:wl,this.freehandCondition_,e.freehand?this.freehandCondition_=Li:this.freehandCondition_=e.freehandCondition?e.freehandCondition:Nr,this.traceCondition_,this.setTrace(e.trace||!1),this.traceState_={active:!1},this.traceSource_=e.traceSource||e.source||null,this.addChangeListener(Fa.ACTIVE,this.updateState_)}setTrace(e){let t;e?e===!0?t=Li:t=e:t=Or,this.traceCondition_=t}setMap(e){super.setMap(e),this.updateState_()}setFreehand(e){this.freehand_=e,this.freehand_?this.freehandCondition_=Li:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:Nr}getOverlay(){return this.overlay_}getFreehand(){return this.freehand_}handleEvent(e){e.originalEvent.type===V.CONTEXTMENU&&e.originalEvent.preventDefault(),this.freehand_=this.mode_!=="Point"&&this.freehandCondition_(e);let t=e.type===ee.POINTERMOVE,n=!0;return!this.freehand_&&this.lastDragTime_&&e.type===ee.POINTERDRAG&&(Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=e.pixel,this.shouldHandle_=!this.freehand_,t=!0):this.lastDragTime_=void 0,this.shouldHandle_&&this.downTimeout_!==void 0&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)),this.freehand_&&e.type===ee.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(e.coordinate),n=!1):this.freehand_&&e.type===ee.POINTERDOWN?n=!1:t&&this.getPointerCount()<2?(n=e.type===ee.POINTERMOVE,n&&this.freehand_?(this.handlePointerMove_(e),this.shouldHandle_&&e.originalEvent.preventDefault()):(e.originalEvent.pointerType==="mouse"||e.type===ee.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(e)):e.type===ee.DBLCLICK&&(n=!1),super.handleEvent(e)&&n}handleDownEvent(e){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=e.pixel,this.finishCoordinate_||this.startDrawing_(e.coordinate),!0):this.condition_(e)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout(()=>{this.handlePointerMove_(new Zt(ee.POINTERMOVE,e.map,e.originalEvent,!1,e.frameState))},this.dragVertexDelay_),this.downPx_=e.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(e){if(!this.traceSource_||!this.traceCondition_(e))return;if(this.traceState_.active){this.deactivateTrace_();return}const t=this.getMap(),n=t.getCoordinateFromPixel([e.pixel[0]-this.snapTolerance_,e.pixel[1]+this.snapTolerance_]),i=t.getCoordinateFromPixel([e.pixel[0]+this.snapTolerance_,e.pixel[1]-this.snapTolerance_]),r=ze([n,i]),o=this.traceSource_.getFeaturesInExtent(r);if(o.length===0)return;const a=Td(e.coordinate,o);a.length&&(this.traceState_={active:!0,startCoord:e.coordinate.slice(),targets:a,targetIndex:-1})}addOrRemoveTracedCoordinates_(e,t){const n=e.startIndex<=e.endIndex,i=e.startIndex<=t;n===i?n&&t>e.endIndex||!n&&t<e.endIndex?this.addTracedCoordinates_(e,e.endIndex,t):(n&&t<e.endIndex||!n&&t>e.endIndex)&&this.removeTracedCoordinates_(t,e.endIndex):(this.removeTracedCoordinates_(e.startIndex,e.endIndex),this.addTracedCoordinates_(e,e.startIndex,t))}removeTracedCoordinates_(e,t){if(e===t)return;let n=0;if(e<t){const i=Math.ceil(e);let r=Math.floor(t);r===t&&(r-=1),n=r-i+1}else{const i=Math.floor(e);let r=Math.ceil(t);r===t&&(r+=1),n=i-r+1}n>0&&this.removeLastPoints_(n)}addTracedCoordinates_(e,t,n){if(t===n)return;const i=[];if(t<n){const r=Math.ceil(t);let o=Math.floor(n);o===n&&(o-=1);for(let a=r;a<=o;++a)i.push(Rn(e.coordinates,a))}else{const r=Math.floor(t);let o=Math.ceil(n);o===n&&(o+=1);for(let a=r;a>=o;--a)i.push(Rn(e.coordinates,a))}i.length&&this.appendCoordinates(i)}updateTrace_(e){const t=this.traceState_;if(!t.active)return;if(t.targetIndex===-1){const a=e.map.getPixelFromCoordinate(t.startCoord);if(vi(a,e.pixel)<this.snapTolerance_)return}const n=Ed(e.coordinate,t,this.getMap(),this.snapTolerance_);if(t.targetIndex!==n.index){if(t.targetIndex!==-1){const l=t.targets[t.targetIndex];this.removeTracedCoordinates_(l.startIndex,l.endIndex)}const a=t.targets[n.index];this.addTracedCoordinates_(a,a.startIndex,n.endIndex)}else{const a=t.targets[t.targetIndex];this.addOrRemoveTracedCoordinates_(a,n.endIndex)}t.targetIndex=n.index;const i=t.targets[t.targetIndex];i.endIndex=n.endIndex;const r=Ii(i.coordinates,i.endIndex),o=this.getMap().getPixelFromCoordinate(r);e.coordinate=r,e.pixel=[Math.round(o[0]),Math.round(o[1])]}handleDragEvent(e){this.ignoreNextUpEvent_=!0,super.handleDragEvent(e)}handleUpEvent(e){let t=!0;if(this.getPointerCount()===0){this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(e);const n=this.traceState_.active;if(this.ignoreNextUpEvent_||this.toggleTraceState_(e),this.shouldHandle_){const i=!this.finishCoordinate_;i&&this.startDrawing_(e.coordinate),!i&&this.freehand_?this.finishDrawing():!this.freehand_&&(!i||this.mode_==="Point")&&(this.atFinish_(e.pixel,n)?this.finishCondition_(e)&&this.finishDrawing():this.addToDrawing_(e.coordinate)),t=!1}else this.freehand_&&this.abortDrawing()}return this.ignoreNextUpEvent_=!1,!t&&this.stopClick_&&e.preventDefault(),t}handlePointerMove_(e){if(this.pointerType_=e.originalEvent.pointerType,this.downPx_&&(!this.freehand_&&this.shouldHandle_||this.freehand_&&!this.shouldHandle_)){const t=this.downPx_,n=e.pixel,i=t[0]-n[0],r=t[1]-n[1],o=i*i+r*r;if(this.shouldHandle_=this.freehand_?o>this.squaredClickTolerance_:o<=this.squaredClickTolerance_,!this.shouldHandle_)return}if(!this.finishCoordinate_){this.createOrUpdateSketchPoint_(e.coordinate.slice());return}this.updateTrace_(e),this.modifyDrawing_(e.coordinate)}atFinish_(e,t){let n=!1;if(this.sketchFeature_){let i=!1,r=[this.finishCoordinate_];const o=this.mode_;if(o==="Point")n=!0;else if(o==="Circle")n=this.sketchCoords_.length===2;else if(o==="LineString")i=!t&&this.sketchCoords_.length>this.minPoints_;else if(o==="Polygon"){const a=this.sketchCoords_;i=a[0].length>this.minPoints_,r=[a[0][0],a[0][a[0].length-2]],t?r=[a[0][0]]:r=[a[0][0],a[0][a[0].length-2]]}if(i){const a=this.getMap();for(let l=0,h=r.length;l<h;l++){const c=r[l],u=a.getPixelFromCoordinate(c),d=e[0]-u[0],f=e[1]-u[1],g=this.freehand_?1:this.snapTolerance_;if(n=Math.sqrt(d*d+f*f)<=g,n){this.finishCoordinate_=c;break}}}}return n}createOrUpdateSketchPoint_(e){this.sketchPoint_?this.sketchPoint_.getGeometry().setCoordinates(e):(this.sketchPoint_=new $e(new lt(e)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(e){this.sketchLine_||(this.sketchLine_=new $e);const t=e.getLinearRing(0);let n=this.sketchLine_.getGeometry();n?(n.setFlatCoordinates(t.getLayout(),t.getFlatCoordinates()),n.changed()):(n=new ht(t.getFlatCoordinates(),t.getLayout()),this.sketchLine_.setGeometry(n))}startDrawing_(e){const t=this.getMap().getView().getProjection(),n=Mr(this.geometryLayout_);for(;e.length<n;)e.push(0);this.finishCoordinate_=e,this.mode_==="Point"?this.sketchCoords_=e.slice():this.mode_==="Polygon"?(this.sketchCoords_=[[e.slice(),e.slice()]],this.sketchLineCoords_=this.sketchCoords_[0]):this.sketchCoords_=[e.slice(),e.slice()],this.sketchLineCoords_&&(this.sketchLine_=new $e(new ht(this.sketchLineCoords_)));const i=this.geometryFunction_(this.sketchCoords_,void 0,t);this.sketchFeature_=new $e,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(i),this.updateSketchFeatures_(),this.dispatchEvent(new mr(_r.DRAWSTART,this.sketchFeature_))}modifyDrawing_(e){const t=this.getMap(),n=this.sketchFeature_.getGeometry(),i=t.getView().getProjection(),r=Mr(this.geometryLayout_);let o,a;for(;e.length<r;)e.push(0);this.mode_==="Point"?a=this.sketchCoords_:this.mode_==="Polygon"?(o=this.sketchCoords_[0],a=o[o.length-1],this.atFinish_(t.getPixelFromCoordinate(e))&&(e=this.finishCoordinate_.slice())):(o=this.sketchCoords_,a=o[o.length-1]),a[0]=e[0],a[1]=e[1],this.geometryFunction_(this.sketchCoords_,n,i),this.sketchPoint_&&this.sketchPoint_.getGeometry().setCoordinates(e),n.getType()==="Polygon"&&this.mode_!=="Polygon"?this.createOrUpdateCustomSketchLine_(n):this.sketchLineCoords_&&this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_),this.updateSketchFeatures_()}addToDrawing_(e){const t=this.sketchFeature_.getGeometry(),n=this.getMap().getView().getProjection();let i,r;const o=this.mode_;return o==="LineString"||o==="Circle"?(this.finishCoordinate_=e.slice(),r=this.sketchCoords_,r.length>=this.maxPoints_&&(this.freehand_?r.pop():i=!0),r.push(e.slice()),this.geometryFunction_(r,t,n)):o==="Polygon"&&(r=this.sketchCoords_[0],r.length>=this.maxPoints_&&(this.freehand_?r.pop():i=!0),r.push(e.slice()),i&&(this.finishCoordinate_=r[0]),this.geometryFunction_(this.sketchCoords_,t,n)),this.createOrUpdateSketchPoint_(e.slice()),this.updateSketchFeatures_(),i?this.finishDrawing():this.sketchFeature_}removeLastPoints_(e){if(!this.sketchFeature_)return;const t=this.sketchFeature_.getGeometry(),n=this.getMap().getView().getProjection(),i=this.mode_;for(let r=0;r<e;++r){let o;if(i==="LineString"||i==="Circle"){if(o=this.sketchCoords_,o.splice(-2,1),o.length>=2){this.finishCoordinate_=o[o.length-2].slice();const a=this.finishCoordinate_.slice();o[o.length-1]=a,this.createOrUpdateSketchPoint_(a)}this.geometryFunction_(o,t,n),t.getType()==="Polygon"&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(t)}else if(i==="Polygon"){o=this.sketchCoords_[0],o.splice(-2,1);const a=this.sketchLine_.getGeometry();if(o.length>=2){const l=o[o.length-2].slice();o[o.length-1]=l,this.createOrUpdateSketchPoint_(l)}a.setCoordinates(o),this.geometryFunction_(this.sketchCoords_,t,n)}if(o.length===1){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const e=this.abortDrawing_();if(!e)return null;let t=this.sketchCoords_;const n=e.getGeometry(),i=this.getMap().getView().getProjection();return this.mode_==="LineString"?(t.pop(),this.geometryFunction_(t,n,i)):this.mode_==="Polygon"&&(t[0].pop(),this.geometryFunction_(t,n,i),t=n.getCoordinates()),this.type_==="MultiPoint"?e.setGeometry(new oi([t])):this.type_==="MultiLineString"?e.setGeometry(new on([t])):this.type_==="MultiPolygon"&&e.setGeometry(new An([t])),this.dispatchEvent(new mr(_r.DRAWEND,e)),this.features_&&this.features_.push(e),this.source_&&this.source_.addFeature(e),e}abortDrawing_(){this.finishCoordinate_=null;const e=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),e}abortDrawing(){const e=this.abortDrawing_();e&&this.dispatchEvent(new mr(_r.DRAWABORT,e))}appendCoordinates(e){const t=this.mode_,n=!this.sketchFeature_;n&&this.startDrawing_(e[0]);let i;if(t==="LineString"||t==="Circle")i=this.sketchCoords_;else if(t==="Polygon")i=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[];else return;n&&i.shift(),i.pop();for(let o=0;o<e.length;o++)this.addToDrawing_(e[o]);const r=e[e.length-1];this.sketchFeature_=this.addToDrawing_(r),this.modifyDrawing_(r)}extend(e){const n=e.getGeometry();this.sketchFeature_=e,this.sketchCoords_=n.getCoordinates();const i=this.sketchCoords_[this.sketchCoords_.length-1];this.finishCoordinate_=i.slice(),this.sketchCoords_.push(i.slice()),this.sketchPoint_=new $e(new lt(i)),this.updateSketchFeatures_(),this.dispatchEvent(new mr(_r.DRAWSTART,this.sketchFeature_))}updateSketchFeatures_(){const e=[];this.sketchFeature_&&e.push(this.sketchFeature_),this.sketchLine_&&e.push(this.sketchLine_),this.sketchPoint_&&e.push(this.sketchPoint_);const t=this.overlay_.getSource();t.clear(!0),t.addFeatures(e)}updateState_(){const e=this.getMap(),t=this.getActive();(!e||!t)&&this.abortDrawing(),this.overlay_.setMap(t?e:null)}}function px(){const s=Nl();return function(e,t){return s[e.getGeometry().getType()]}}function yx(s){switch(s){case"Point":case"MultiPoint":return"Point";case"LineString":case"MultiLineString":return"LineString";case"Polygon":case"MultiPolygon":return"Polygon";case"Circle":return"Circle";default:throw new Error("Invalid type: "+s)}}const pr={SELECT:"select"};class yr extends ut{constructor(e,t,n,i){super(e),this.selected=t,this.deselected=n,this.mapBrowserEvent=i}}const xr={};class Sd extends Vi{constructor(e){super(),this.on,this.once,this.un,e=e||{},this.boundAddFeature_=this.addFeature_.bind(this),this.boundRemoveFeature_=this.removeFeature_.bind(this),this.condition_=e.condition?e.condition:xu,this.addCondition_=e.addCondition?e.addCondition:Or,this.removeCondition_=e.removeCondition?e.removeCondition:Or,this.toggleCondition_=e.toggleCondition?e.toggleCondition:Nr,this.multi_=e.multi?e.multi:!1,this.filter_=e.filter?e.filter:Pn,this.hitTolerance_=e.hitTolerance?e.hitTolerance:0,this.style_=e.style!==void 0?e.style:xx(),this.features_=e.features||new Ze;let t;if(e.layers)if(typeof e.layers=="function")t=e.layers;else{const n=e.layers;t=function(i){return n.includes(i)}}else t=Pn;this.layerFilter_=t,this.featureLayerAssociation_={}}addFeatureLayerAssociation_(e,t){this.featureLayerAssociation_[D(e)]=t}getFeatures(){return this.features_}getHitTolerance(){return this.hitTolerance_}getLayer(e){return this.featureLayerAssociation_[D(e)]}setHitTolerance(e){this.hitTolerance_=e}setMap(e){this.getMap()&&this.style_&&this.features_.forEach(this.restorePreviousStyle_.bind(this)),super.setMap(e),e?(this.features_.addEventListener(Se.ADD,this.boundAddFeature_),this.features_.addEventListener(Se.REMOVE,this.boundRemoveFeature_),this.style_&&this.features_.forEach(this.applySelectedStyle_.bind(this))):(this.features_.removeEventListener(Se.ADD,this.boundAddFeature_),this.features_.removeEventListener(Se.REMOVE,this.boundRemoveFeature_))}addFeature_(e){const t=e.element;if(this.style_&&this.applySelectedStyle_(t),!this.getLayer(t)){const n=this.findLayerOfFeature_(t);n&&this.addFeatureLayerAssociation_(t,n)}}removeFeature_(e){this.style_&&this.restorePreviousStyle_(e.element)}findLayerOfFeature_(e){return this.getMap().getAllLayers().find(function(n){if(n instanceof Xl&&n.getSource()&&n.getSource().hasFeature(e))return n})}getStyle(){return this.style_}applySelectedStyle_(e){const t=D(e);t in xr||(xr[t]=e.getStyle()),e.setStyle(this.style_)}restorePreviousStyle_(e){const t=this.getMap().getInteractions().getArray();for(let i=t.length-1;i>=0;--i){const r=t[i];if(r!==this&&r instanceof Sd&&r.getStyle()&&r.getFeatures().getArray().lastIndexOf(e)!==-1){e.setStyle(r.getStyle());return}}const n=D(e);e.setStyle(xr[n]),delete xr[n]}removeFeatureLayerAssociation_(e){delete this.featureLayerAssociation_[D(e)]}selectFeatureInternal_(e,t,n){if(!(e instanceof $e)||!this.filter_(e,t))return;const i=this.getFeatures();return i.getArray().includes(e)||(this.addFeatureLayerAssociation_(e,t),i.push(e),n?.push(e)),e}selectFeature(e){const t=this.findLayerOfFeature_(e);if(!this.layerFilter_(t))return!1;const n=this.selectFeatureInternal_(e,t);return n&&this.dispatchEvent(new yr(pr.SELECT,[n],[],void 0)),!!n}removeFeatureInternal_(e,t){const n=this.getFeatures();if(!(!(e instanceof $e)||!n.getArray().includes(e)))return n.remove(e),this.removeFeatureLayerAssociation_(e),t?.push(e),e}deselectFeature(e){const t=this.removeFeatureInternal_(e);return t&&this.dispatchEvent(new yr(pr.SELECT,[],[t],void 0)),!!t}toggleFeature(e){this.deselectFeature(e)||this.selectFeature(e)}clearSelection(){ei(this.featureLayerAssociation_);const e=this.getFeatures(),t=e.getArray().slice();e.clear(),t.length!==0&&this.dispatchEvent(new yr(pr.SELECT,[],t,void 0))}handleEvent(e){if(!this.condition_(e))return!0;const t=this.addCondition_(e),n=this.removeCondition_(e),i=this.toggleCondition_(e),r=!t&&!n&&!i,o=e.map,a=this.getFeatures(),l=[],h=[];if(r){let c=!1;o.forEachFeatureAtPixel(e.pixel,(u,d)=>{if(c=!0,!!this.selectFeatureInternal_(u,d,h))return!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let u=a.getLength()-1;u>=0;--u){const d=a.item(u);(h.length>0&&!h.includes(d)||!c)&&this.removeFeatureInternal_(d,l)}}else o.forEachFeatureAtPixel(e.pixel,(c,u)=>{let d;if((n||i)&&(d=this.removeFeatureInternal_(c,l)),(t||i)&&!d&&(d=this.selectFeatureInternal_(c,u,h)),!!d)return!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});return(h.length>0||l.length>0)&&this.dispatchEvent(new yr(pr.SELECT,h,l,e)),!0}}function xx(){const s=Nl();return ne(s.Polygon,s.LineString),ne(s.GeometryCollection,s.LineString),function(e){return e.getGeometry()?s[e.getGeometry().getType()]:null}}const Cc=0,ps=1,Rc=[0,0,0,0],bi=[],ca={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"};function ua(s,e,t){let n;switch(e){case"LineString":n=s;break;case"MultiLineString":case"Polygon":n=s[t[0]];break;case"MultiPolygon":n=s[t[1]][t[0]];break}return n}class da extends ut{constructor(e,t,n){super(e),this.features=t,this.mapBrowserEvent=n}}class W0 extends si{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:Tu,this.defaultDeleteCondition_=function(n){return o_(n)&&xu(n)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:Li,this.vertexFeature_=null,this.vertexSegments_=null,this.lastCoordinate_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new Ba,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new Xl({source:new td({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:Tx(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.traceSource_=e.traceSource||e.source||null,this.traceCondition_,this.setTrace(e.trace||!1),this.traceState_={active:!1},this.traceSegments_=null,this.hitDetection_=null;let t;if(e.features?t=e.features:e.source&&(this.source_=e.source,t=new Ze(this.source_.getFeatures()),this.source_.addEventListener(Le.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(Le.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!t)throw new Error("The modify interaction requires features, a source or a layer");e.hitDetection&&(this.hitDetection_=e.hitDetection),this.features_=t,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(Se.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(Se.REMOVE,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=e.snapToPointer===void 0?!this.hitDetection_:e.snapToPointer}setTrace(e){let t;e?e===!0?t=Li:t=e:t=Or,this.traceCondition_=t}addFeature_(e){const t=e.getGeometry();if(t){const i=this.SEGMENT_WRITERS_[t.getType()];i&&i(e,t)}const n=this.getMap();n&&n.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastCoordinate_),e.addEventListener(V.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(e,t){if(!this.featuresBeingModified_){this.featuresBeingModified_=new Ze;const n=this.featuresBeingModified_.getArray();for(let i=0,r=t.length;i<r;++i){const o=t[i].feature;o&&!n.includes(o)&&this.featuresBeingModified_.push(o)}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new da(ca.MODIFYSTART,this.featuresBeingModified_,e))}}removeFeature_(e){this.removeFeatureSegmentData_(e),this.vertexFeature_&&this.features_.getLength()===0&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.removeEventListener(V.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(e){const t=this.rBush_,n=[];t.forEach(function(i){e===i.feature&&n.push(i)});for(let i=n.length-1;i>=0;--i){const r=n[i];for(let o=this.dragSegments_.length-1;o>=0;--o)this.dragSegments_[o][0]===r&&this.dragSegments_.splice(o,1);t.remove(r)}}setActive(e){this.vertexFeature_&&!e&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(e)}setMap(e){this.overlay_.setMap(e),super.setMap(e)}getOverlay(){return this.overlay_}handleSourceAdd_(e){e.feature&&this.features_.push(e.feature)}handleSourceRemove_(e){e.feature&&this.features_.remove(e.feature)}handleFeatureAdd_(e){this.addFeature_(e.element)}handleFeatureChange_(e){if(!this.changingFeature_){const t=e.target;this.removeFeature_(t),this.addFeature_(t)}}handleFeatureRemove_(e){this.removeFeature_(e.element)}writePointGeometry_(e,t){const n=t.getCoordinates(),i={feature:e,geometry:t,segment:[n,n]};this.rBush_.insert(t.getExtent(),i)}writeMultiPointGeometry_(e,t){const n=t.getCoordinates();for(let i=0,r=n.length;i<r;++i){const o=n[i],a={feature:e,geometry:t,depth:[i],index:i,segment:[o,o]};this.rBush_.insert(t.getExtent(),a)}}writeLineStringGeometry_(e,t){const n=t.getCoordinates();for(let i=0,r=n.length-1;i<r;++i){const o=n.slice(i,i+2),a={feature:e,geometry:t,index:i,segment:o};this.rBush_.insert(ze(o),a)}}writeMultiLineStringGeometry_(e,t){const n=t.getCoordinates();for(let i=0,r=n.length;i<r;++i){const o=n[i];for(let a=0,l=o.length-1;a<l;++a){const h=o.slice(a,a+2),c={feature:e,geometry:t,depth:[i],index:a,segment:h};this.rBush_.insert(ze(h),c)}}}writePolygonGeometry_(e,t){const n=t.getCoordinates();for(let i=0,r=n.length;i<r;++i){const o=n[i];for(let a=0,l=o.length-1;a<l;++a){const h=o.slice(a,a+2),c={feature:e,geometry:t,depth:[i],index:a,segment:h};this.rBush_.insert(ze(h),c)}}}writeMultiPolygonGeometry_(e,t){const n=t.getCoordinates();for(let i=0,r=n.length;i<r;++i){const o=n[i];for(let a=0,l=o.length;a<l;++a){const h=o[a];for(let c=0,u=h.length-1;c<u;++c){const d=h.slice(c,c+2),f={feature:e,geometry:t,depth:[a,i],index:c,segment:d};this.rBush_.insert(ze(d),f)}}}}writeCircleGeometry_(e,t){const n=t.getCenter(),i={feature:e,geometry:t,index:Cc,segment:[n,n]},r={feature:e,geometry:t,index:ps,segment:[n,n]},o=[i,r];i.featureSegments=o,r.featureSegments=o,this.rBush_.insert(fs(n),i);let a=t;this.rBush_.insert(a.getExtent(),r)}writeGeometryCollectionGeometry_(e,t){const n=t.getGeometriesArray();for(let i=0;i<n.length;++i){const r=n[i],o=this.SEGMENT_WRITERS_[r.getType()];o(e,r)}}createOrUpdateVertexFeature_(e,t,n,i){let r=this.vertexFeature_;return r?r.getGeometry().setCoordinates(e):(r=new $e(new lt(e)),this.vertexFeature_=r,this.overlay_.getSource().addFeature(r)),r.set("features",t),r.set("geometries",n),r.set("existing",i),r}handleEvent(e){if(!e.originalEvent)return!0;this.lastPointerEvent_=e;let t;return!e.map.getView().getInteracting()&&e.type==ee.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(e),this.vertexFeature_&&this.deleteCondition_(e)&&(e.type!=ee.SINGLECLICK||!this.ignoreNextSingleClick_?t=this.removePoint():t=!0),e.type==ee.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(e)&&!t}findInsertVerticesAndUpdateDragSegments_(e){if(this.handlePointerAtPixel_(e),this.dragSegments_.length=0,this.featuresBeingModified_=null,!this.vertexFeature_)return;this.getMap().getView().getProjection();const n=[],i=this.vertexFeature_.getGeometry().getCoordinates(),r=ze([i]),o=this.rBush_.getInExtent(r),a={};o.sort(Ex);for(let l=0,h=o.length;l<h;++l){const c=o[l],u=c.segment;let d=D(c.geometry);const f=c.depth;if(f&&(d+="-"+f.join("-")),a[d]||(a[d]=new Array(2)),c.geometry.getType()==="Circle"&&c.index===ps){const g=vc(e,c);Ve(g,i)&&!a[d][0]&&(this.dragSegments_.push([c,0]),a[d][0]=c);continue}if(Ve(u[0],i)&&!a[d][0]){this.dragSegments_.push([c,0]),a[d][0]=c;continue}if(Ve(u[1],i)&&!a[d][1]){if(a[d][0]&&a[d][0].index===0){let g=c.geometry.getCoordinates();switch(c.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":g=g[f[1]];case"Polygon":if(c.index!==g[f[0]].length-2)continue;break}}this.dragSegments_.push([c,1]),a[d][1]=c;continue}D(u)in this.vertexSegments_&&!a[d][0]&&!a[d][1]&&n.push(c)}return n}deactivateTrace_(){this.traceState_={active:!1}}updateTrace_(e){const t=this.traceState_;if(!t.active)return;if(t.targetIndex===-1){const r=e.map.getPixelFromCoordinate(t.startCoord);if(vi(r,e.pixel)<this.pixelTolerance_)return}const n=Ed(e.coordinate,t,e.map,this.pixelTolerance_);if(t.targetIndex===-1&&Math.sqrt(n.closestTargetDistance)/e.map.getView().getResolution()>this.pixelTolerance_)return;if(t.targetIndex!==n.index){if(t.targetIndex!==-1){const o=t.targets[t.targetIndex];this.removeTracedCoordinates_(o.startIndex,o.endIndex)}else for(const o of this.traceSegments_){const a=o[0],l=a.geometry,h=o[1],c=l.getCoordinates();ua(c,l.getType(),a.depth).splice(a.index+h,1),l.setCoordinates(c),h===0&&(a.index-=1)}const r=t.targets[n.index];this.addTracedCoordinates_(r,r.startIndex,n.endIndex)}else{const r=t.targets[t.targetIndex];this.addOrRemoveTracedCoordinates_(r,n.endIndex)}t.targetIndex=n.index;const i=t.targets[t.targetIndex];i.endIndex=n.endIndex}getTraceCandidates_(e){const t=this.getMap(),n=this.pixelTolerance_,i=t.getCoordinateFromPixel([e.pixel[0]-n,e.pixel[1]+n]),r=t.getCoordinateFromPixel([e.pixel[0]+n,e.pixel[1]-n]),o=ze([i,r]);return this.traceSource_.getFeaturesInExtent(o)}toggleTraceState_(e){if(!this.traceSource_||!this.traceCondition_(e))return;if(this.traceState_.active){this.deactivateTrace_(),this.traceSegments_=null;return}const t=this.getTraceCandidates_(e);if(t.length===0)return;const n=Td(e.coordinate,t);n.length&&(this.traceState_={active:!0,startCoord:e.coordinate.slice(),targets:n,targetIndex:-1})}addOrRemoveTracedCoordinates_(e,t){const n=e.startIndex<=e.endIndex,i=e.startIndex<=t;n===i?n&&t>e.endIndex||!n&&t<e.endIndex?this.addTracedCoordinates_(e,e.endIndex,t):(n&&t<e.endIndex||!n&&t>e.endIndex)&&this.removeTracedCoordinates_(t,e.endIndex):(this.removeTracedCoordinates_(e.startIndex,e.endIndex),this.addTracedCoordinates_(e,e.startIndex,t))}removeTracedCoordinates_(e,t){if(e===t)return;let n=0;if(e<t){const i=Math.ceil(e);let r=Math.floor(t);r===t&&(r-=1),n=r-i+1}else{const i=Math.floor(e);let r=Math.ceil(t);r===t&&(r+=1),n=i-r+1}if(n>0)for(const i of this.traceSegments_){const r=i[0],o=r.geometry,a=i[1];let l=i[0].index+1;a===1&&(l-=n);const h=o.getCoordinates();ua(h,o.getType(),r.depth).splice(l,n),o.setCoordinates(h),a===1&&(r.index-=n)}}addTracedCoordinates_(e,t,n){if(t===n)return;const i=[];if(t<n){const r=Math.ceil(t);let o=Math.floor(n);o===n&&(o-=1);for(let a=r;a<=o;++a)i.push(Rn(e.coordinates,a))}else{const r=Math.floor(t);let o=Math.ceil(n);o===n&&(o+=1);for(let a=r;a>=o;--a)i.push(Rn(e.coordinates,a))}if(i.length)for(const r of this.traceSegments_){const o=r[0],a=o.geometry,l=r[1],h=o.index+1;l===0&&i.reverse();const c=a.getCoordinates();ua(c,a.getType(),o.depth).splice(h,0,...i),a.setCoordinates(c),l===1&&(o.index+=i.length)}}updateGeometry_(e,t){const n=t[0],i=n.depth;let r;const o=n.segment,a=n.geometry,l=t[1];for(;e.length<a.getStride();)e.push(o[l][e.length]);switch(a.getType()){case"Point":r=e,o[0]=e,o[1]=e;break;case"MultiPoint":r=a.getCoordinates(),r[n.index]=e,o[0]=e,o[1]=e;break;case"LineString":r=a.getCoordinates(),r[n.index+l]=e,o[l]=e;break;case"MultiLineString":r=a.getCoordinates(),r[i[0]][n.index+l]=e,o[l]=e;break;case"Polygon":r=a.getCoordinates(),r[i[0]][n.index+l]=e,o[l]=e;break;case"MultiPolygon":r=a.getCoordinates(),r[i[1]][i[0]][n.index+l]=e,o[l]=e;break;case"Circle":const h=a;if(o[0]=e,o[1]=e,n.index===Cc)this.changingFeature_=!0,h.setCenter(e),this.changingFeature_=!1;else{this.changingFeature_=!0,this.getMap().getView().getProjection();let c=vi(pe(h.getCenter()),pe(e));h.setRadius(c),this.changingFeature_=!1}break}r&&this.setGeometryCoordinates_(a,r)}handleDragEvent(e){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(e,this.dragSegments_.map(([o])=>o));const t=[e.coordinate[0]+this.delta_[0],e.coordinate[1]+this.delta_[1]],n=[],i=[],r=this.traceState_.active&&!this.traceSegments_?this.traceState_.startCoord:null;if(r){this.traceSegments_=[];for(const o of this.dragSegments_){const a=o[0];vi(tl(r,a.segment),r)/e.map.getView().getResolution()<1&&this.traceSegments_.push(o)}}for(let o=0,a=this.dragSegments_.length;o<a;++o){const l=this.dragSegments_[o],h=l[0],c=h.feature;n.includes(c)||n.push(c);const u=h.geometry;i.includes(u)||i.push(u),this.updateGeometry_(t,l)}this.updateTrace_(e),this.createOrUpdateVertexFeature_(t,n,i,!0)}handleDownEvent(e){if(!this.condition_(e))return!1;const t=e.coordinate,n=this.findInsertVerticesAndUpdateDragSegments_(t);if(n?.length&&this.insertVertexCondition_(e)&&(this.willModifyFeatures_(e,n),this.vertexFeature_)){const i=this.vertexFeature_.getGeometry().getCoordinates();for(let r=n.length-1;r>=0;--r)this.insertVertex_(n[r],i);this.ignoreNextSingleClick_=!0}return!!this.vertexFeature_}handleUpEvent(e){for(let t=this.dragSegments_.length-1;t>=0;--t){const n=this.dragSegments_[t][0],i=n.geometry;if(i.getType()==="Circle"){const r=i,o=r.getCenter(),a=n.featureSegments[0],l=n.featureSegments[1];a.segment[0]=o,a.segment[1]=o,l.segment[0]=o,l.segment[1]=o,this.rBush_.update(fs(o),a);let h=r;this.rBush_.update(h.getExtent(),l)}else this.rBush_.update(ze(n.segment),n)}return this.featuresBeingModified_&&(this.toggleTraceState_(e),this.dispatchEvent(new da(ca.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null),!1}handlePointerMove_(e){this.lastCoordinate_=e.coordinate,this.handlePointerAtPixel_(this.lastCoordinate_)}handlePointerAtPixel_(e){const t=this.getMap(),n=t.getPixelFromCoordinate(e);t.getView().getProjection();const i=function(a,l){return Sc(e,a)-Sc(e,l)};let r,o;if(this.hitDetection_){const a=typeof this.hitDetection_=="object"?l=>l===this.hitDetection_:void 0;t.forEachFeatureAtPixel(n,(l,h,c)=>{c&&c.getType()==="Point"&&(c=new lt(Jn(c.getCoordinates())));const u=c||l.getGeometry();if(u&&u.getType()==="Point"&&l instanceof $e&&this.features_.getArray().includes(l)){o=u;const d=l.getGeometry().getFlatCoordinates().slice(0,2);r=[{feature:l,geometry:o,segment:[d,d]}]}return!0},{layerFilter:a})}if(!r){const a=wt(fs(e,Rc)),l=t.getView().getResolution()*this.pixelTolerance_,h=so(rn(a,l,Rc));r=this.rBush_.getInExtent(h)}if(r&&r.length>0){const a=r.sort(i)[0],l=a.segment;let h=vc(e,a);const c=t.getPixelFromCoordinate(h);let u=vi(n,c);if(o||u<=this.pixelTolerance_){const d={};if(d[D(l)]=!0,this.snapToPointer_||(this.delta_[0]=h[0]-e[0],this.delta_[1]=h[1]-e[1]),a.geometry.getType()==="Circle"&&a.index===ps)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);else{const f=t.getPixelFromCoordinate(l[0]),g=t.getPixelFromCoordinate(l[1]),m=Gi(c,f),_=Gi(c,g);if(u=Math.sqrt(Math.min(m,_)),this.snappedToVertex_=u<=this.pixelTolerance_,!this.snappedToVertex_&&!this.insertVertexCondition_(this.lastPointerEvent_)){this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null);return}this.snappedToVertex_&&(h=m>_?l[1]:l[0]),this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);const p={};p[D(a.geometry)]=!0;for(let y=1,E=r.length;y<E;++y){const x=r[y].segment;if(Ve(l[0],x[0])&&Ve(l[1],x[1])||Ve(l[0],x[1])&&Ve(l[1],x[0])){const T=D(r[y].geometry);T in p||(p[T]=!0,d[D(x)]=!0)}else break}}this.vertexSegments_=d;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(e,t){const n=e.segment,i=e.feature,r=e.geometry,o=e.depth,a=e.index;let l;for(;t.length<r.getStride();)t.push(0);switch(r.getType()){case"MultiLineString":l=r.getCoordinates(),l[o[0]].splice(a+1,0,t);break;case"Polygon":l=r.getCoordinates(),l[o[0]].splice(a+1,0,t);break;case"MultiPolygon":l=r.getCoordinates(),l[o[1]][o[0]].splice(a+1,0,t);break;case"LineString":l=r.getCoordinates(),l.splice(a+1,0,t);break;default:return!1}this.setGeometryCoordinates_(r,l);const h=this.rBush_;h.remove(e),this.updateSegmentIndices_(r,a,o,1);const c={segment:[n[0],t],feature:i,geometry:r,depth:o,index:a};h.insert(ze(c.segment),c),this.dragSegments_.push([c,1]);const u={segment:[t,n[1]],feature:i,geometry:r,depth:o,index:a+1};return h.insert(ze(u.segment),u),this.dragSegments_.push([u,0]),!0}updatePointer_(e){return e&&this.findInsertVerticesAndUpdateDragSegments_(e),this.vertexFeature_?.getGeometry().getCoordinates()}getPoint(){const e=this.vertexFeature_?.getGeometry().getCoordinates();return e?Jn(e,this.getMap().getView().getProjection()):null}canRemovePoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(n=>n.getType()==="Circle"||n.getType().endsWith("Point")))return!1;const e=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(ze([e])).some(({segment:n})=>Ve(n[0],e)||Ve(n[1],e))}removePoint(e){if(e&&(e=pe(e,this.getMap().getView().getProjection()),this.updatePointer_(e)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=ee.POINTERDRAG){const t=this.lastPointerEvent_;this.willModifyFeatures_(t,this.dragSegments_.map(([i])=>i));const n=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new da(ca.MODIFYEND,this.featuresBeingModified_,t)),this.featuresBeingModified_=null,n}return!1}removeVertex_(){const e=this.dragSegments_,t={};let n=!1,i,r,o,a,l,h,c,u,d,f,g;for(l=e.length-1;l>=0;--l)o=e[l],f=o[0],g=D(f.feature),f.depth&&(g+="-"+f.depth.join("-")),g in t||(t[g]={}),o[1]===0?(t[g].right=f,t[g].index=f.index):o[1]==1&&(t[g].left=f,t[g].index=f.index+1);for(g in t){switch(d=t[g].right,c=t[g].left,h=t[g].index,u=h-1,c!==void 0?f=c:f=d,u<0&&(u=0),a=f.geometry,r=a.getCoordinates(),i=r,n=!1,a.getType()){case"MultiLineString":r[f.depth[0]].length>2&&(r[f.depth[0]].splice(h,1),n=!0);break;case"LineString":r.length>2&&(r.splice(h,1),n=!0);break;case"MultiPolygon":i=i[f.depth[1]];case"Polygon":i=i[f.depth[0]],i.length>4&&(h==i.length-1&&(h=0),i.splice(h,1),n=!0,h===0&&(i.pop(),i.push(i[0]),u=i.length-1));break}if(n){this.setGeometryCoordinates_(a,r);const m=[];if(c!==void 0&&(this.rBush_.remove(c),m.push(c.segment[0])),d!==void 0&&(this.rBush_.remove(d),m.push(d.segment[1])),c!==void 0&&d!==void 0){const _={depth:f.depth,feature:f.feature,geometry:f.geometry,index:u,segment:m};this.rBush_.insert(ze(_.segment),_)}this.updateSegmentIndices_(a,h,f.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.length=0}}return n}canInsertPoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(n=>n.getType()==="Circle"||n.getType().endsWith("Point")))return!1;const e=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(ze([e])).some(({segment:n})=>!(Ve(n[0],e)||Ve(n[1],e)))}insertPoint(e){const t=e?pe(e,this.getMap().getView().getProjection()):this.vertexFeature_?.getGeometry().getCoordinates();return t?this.findInsertVerticesAndUpdateDragSegments_(t).reduce((i,r)=>i||this.insertVertex_(r,t),!1):!1}setGeometryCoordinates_(e,t){this.changingFeature_=!0,e.setCoordinates(t),this.changingFeature_=!1}updateSegmentIndices_(e,t,n,i){this.rBush_.forEachInExtent(e.getExtent(),function(r){r.geometry===e&&(n===void 0||r.depth===void 0||Bt(r.depth,n))&&r.index>t&&(r.index+=i)})}}function Ex(s,e){return s.index-e.index}function Sc(s,e,t){const n=e.geometry;if(n.getType()==="Circle"){let r=n;if(e.index===ps){const o=Gi(r.getCenter(),pe(s)),a=Math.sqrt(o)-r.getRadius();return a*a}}const i=pe(s);return bi[0]=pe(e.segment[0]),bi[1]=pe(e.segment[1]),Df(i,bi)}function vc(s,e,t){const n=e.geometry;if(n.getType()==="Circle"&&e.index===ps)return Jn(n.getClosestPoint(pe(s)));const i=pe(s);return bi[0]=pe(e.segment[0]),bi[1]=pe(e.segment[1]),Jn(tl(i,bi))}function Tx(){const s=Nl();return function(e,t){return s.Point}}class Cx extends Wl{constructor(){super()}getType(){return"text"}readFeature(e,t){return this.readFeatureFromText(Er(e),this.adaptOptions(t))}readFeatureFromText(e,t){return $()}readFeatures(e,t){return this.readFeaturesFromText(Er(e),this.adaptOptions(t))}readFeaturesFromText(e,t){return $()}readGeometry(e,t){return this.readGeometryFromText(Er(e),this.adaptOptions(t))}readGeometryFromText(e,t){return $()}readProjection(e){return this.readProjectionFromText(Er(e))}readProjectionFromText(e){return this.dataProjection}writeFeature(e,t){return this.writeFeatureText(e,this.adaptOptions(t))}writeFeatureText(e,t){return $()}writeFeatures(e,t){return this.writeFeaturesText(e,this.adaptOptions(t))}writeFeaturesText(e,t){return $()}writeGeometry(e,t){return this.writeGeometryText(e,this.adaptOptions(t))}writeGeometryText(e,t){return $()}}function Er(s){return typeof s=="string"?s:""}const Rx={POINT:lt,LINESTRING:ht,POLYGON:qe,MULTIPOINT:oi,MULTILINESTRING:on,MULTIPOLYGON:An},vd="EMPTY",wd="Z",Pd="M",Sx="ZM",oe={START:0,TEXT:1,LEFT_PAREN:2,RIGHT_PAREN:3,NUMBER:4,COMMA:5,EOF:6},vx={Point:"POINT",LineString:"LINESTRING",Polygon:"POLYGON",MultiPoint:"MULTIPOINT",MultiLineString:"MULTILINESTRING",MultiPolygon:"MULTIPOLYGON",GeometryCollection:"GEOMETRYCOLLECTION",Circle:"CIRCLE"};class wx{constructor(e){this.wkt=e,this.index_=-1}isAlpha_(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}isNumeric_(e,t){return t=t!==void 0?t:!1,e>="0"&&e<="9"||e=="."&&!t}isWhiteSpace_(e){return e==" "||e==" "||e=="\r"||e==`
|
||
`}nextChar_(){return this.wkt.charAt(++this.index_)}nextToken(){const e=this.nextChar_(),t=this.index_;let n=e,i;if(e=="(")i=oe.LEFT_PAREN;else if(e==",")i=oe.COMMA;else if(e==")")i=oe.RIGHT_PAREN;else if(this.isNumeric_(e)||e=="-")i=oe.NUMBER,n=this.readNumber_();else if(this.isAlpha_(e))i=oe.TEXT,n=this.readText_();else{if(this.isWhiteSpace_(e))return this.nextToken();if(e==="")i=oe.EOF;else throw new Error("Unexpected character: "+e)}return{position:t,value:n,type:i}}readNumber_(){let e;const t=this.index_;let n=!1,i=!1;do e=="."?n=!0:(e=="e"||e=="E")&&(i=!0),e=this.nextChar_();while(this.isNumeric_(e,n)||!i&&(e=="e"||e=="E")||i&&(e=="-"||e=="+"));return parseFloat(this.wkt.substring(t,this.index_--))}readText_(){let e;const t=this.index_;do e=this.nextChar_();while(this.isAlpha_(e));return this.wkt.substring(t,this.index_--).toUpperCase()}}class Px{constructor(e){this.lexer_=e,this.token_={position:0,type:oe.START},this.layout_="XY"}consume_(){this.token_=this.lexer_.nextToken()}isTokenType(e){return this.token_.type==e}match(e){const t=this.isTokenType(e);return t&&this.consume_(),t}parse(){return this.consume_(),this.parseGeometry_()}parseGeometryLayout_(){let e="XY";const t=this.token_;if(this.isTokenType(oe.TEXT)){const n=t.value;n===wd?e="XYZ":n===Pd?e="XYM":n===Sx&&(e="XYZM"),e!=="XY"&&this.consume_()}return e}parseGeometryCollectionText_(){if(this.match(oe.LEFT_PAREN)){const e=[];do e.push(this.parseGeometry_());while(this.match(oe.COMMA));if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePointText_(){if(this.match(oe.LEFT_PAREN)){const e=this.parsePoint_();if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseLineStringText_(){if(this.match(oe.LEFT_PAREN)){const e=this.parsePointList_();if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePolygonText_(){if(this.match(oe.LEFT_PAREN)){const e=this.parseLineStringTextList_();if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiPointText_(){if(this.match(oe.LEFT_PAREN)){let e;if(this.token_.type==oe.LEFT_PAREN?e=this.parsePointTextList_():e=this.parsePointList_(),this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiLineStringText_(){if(this.match(oe.LEFT_PAREN)){const e=this.parseLineStringTextList_();if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiPolygonText_(){if(this.match(oe.LEFT_PAREN)){const e=this.parsePolygonTextList_();if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePoint_(){const e=[],t=this.layout_.length;for(let n=0;n<t;++n){const i=this.token_;if(this.match(oe.NUMBER))e.push(i.value);else break}if(e.length==t)return e;throw new Error(this.formatErrorMessage_())}parsePointList_(){const e=[this.parsePoint_()];for(;this.match(oe.COMMA);)e.push(this.parsePoint_());return e}parsePointTextList_(){const e=[this.parsePointText_()];for(;this.match(oe.COMMA);)e.push(this.parsePointText_());return e}parseLineStringTextList_(){const e=[this.parseLineStringText_()];for(;this.match(oe.COMMA);)e.push(this.parseLineStringText_());return e}parsePolygonTextList_(){const e=[this.parsePolygonText_()];for(;this.match(oe.COMMA);)e.push(this.parsePolygonText_());return e}isEmptyGeometry_(){const e=this.isTokenType(oe.TEXT)&&this.token_.value==vd;return e&&this.consume_(),e}formatErrorMessage_(){return"Unexpected `"+this.token_.value+"` at position "+this.token_.position+" in `"+this.lexer_.wkt+"`"}parseGeometry_(){const e=this.token_;if(this.match(oe.TEXT)){const t=e.value;this.layout_=this.parseGeometryLayout_();const n=this.isEmptyGeometry_();if(t=="GEOMETRYCOLLECTION"){if(n)return new He([]);const o=this.parseGeometryCollectionText_();return new He(o)}const i=Rx[t];if(!i)throw new Error("Invalid geometry type: "+t);let r;if(n)t=="POINT"?r=[NaN,NaN]:r=[];else switch(t){case"POINT":{r=this.parsePointText_();break}case"LINESTRING":{r=this.parseLineStringText_();break}case"POLYGON":{r=this.parsePolygonText_();break}case"MULTIPOINT":{r=this.parseMultiPointText_();break}case"MULTILINESTRING":{r=this.parseMultiLineStringText_();break}case"MULTIPOLYGON":{r=this.parseMultiPolygonText_();break}}return new i(r,this.layout_)}throw new Error(this.formatErrorMessage_())}}class V0 extends Cx{constructor(e){super(),e=e||{},this.splitCollection_=e.splitCollection!==void 0?e.splitCollection:!1}parse_(e){const t=new wx(e);return new Px(t).parse()}readFeatureFromText(e,t){const n=this.readGeometryFromText(e,t),i=new $e;return i.setGeometry(n),i}readFeaturesFromText(e,t){let n=[];const i=this.readGeometryFromText(e,t);this.splitCollection_&&i.getType()=="GeometryCollection"?n=i.getGeometriesArray():n=[i];const r=[];for(let o=0,a=n.length;o<a;++o){const l=new $e;l.setGeometry(n[o]),r.push(l)}return r}readGeometryFromText(e,t){const n=this.parse_(e);return Qn(n,!1,t)}writeFeatureText(e,t){const n=e.getGeometry();return n?this.writeGeometryText(n,t):""}writeFeaturesText(e,t){if(e.length==1)return this.writeFeatureText(e[0],t);const n=[];for(let r=0,o=e.length;r<o;++r)n.push(e[r].getGeometry());const i=new He(n);return this.writeGeometryText(i,t)}writeGeometryText(e,t){return Ld(Qn(e,!0,t))}}function Id(s){const e=s.getCoordinates();return e.length===0?"":e.join(" ")}function Ix(s){const e=[],t=s.getPoints();for(let n=0,i=t.length;n<i;++n)e.push("("+Id(t[n])+")");return e.join(",")}function Ax(s){const e=[],t=s.getGeometries();for(let n=0,i=t.length;n<i;++n)e.push(Ld(t[n]));return e.join(",")}function rh(s){const e=s.getCoordinates(),t=[];for(let n=0,i=e.length;n<i;++n)t.push(e[n].join(" "));return t.join(",")}function Lx(s){const e=[],t=s.getLineStrings();for(let n=0,i=t.length;n<i;++n)e.push("("+rh(t[n])+")");return e.join(",")}function Ad(s){const e=[],t=s.getLinearRings();for(let n=0,i=t.length;n<i;++n)e.push("("+rh(t[n])+")");return e.join(",")}function Fx(s){const e=[],t=s.getPolygons();for(let n=0,i=t.length;n<i;++n)e.push("("+Ad(t[n])+")");return e.join(",")}function Mx(s){const e=s.getLayout();let t="";return(e==="XYZ"||e==="XYZM")&&(t+=wd),(e==="XYM"||e==="XYZM")&&(t+=Pd),t}const bx={Point:Id,LineString:rh,Polygon:Ad,MultiPoint:Ix,MultiLineString:Lx,MultiPolygon:Fx,GeometryCollection:Ax};function Ld(s){const e=s.getType(),t=bx[e],n=t(s);let i=vx[e];if(typeof s.getFlatCoordinates=="function"){const r=Mx(s);r.length>0&&(i+=" "+r)}return n.length===0?i+" "+vd:i+"("+n+")"}const wc="http://www.w3.org/2001/XMLSchema-instance";function Ws(s,e){return yo().createElementNS(s,e)}function ln(s,e){return Fd(s,e,[]).join("")}function Fd(s,e,t){if(s.nodeType==Node.CDATA_SECTION_NODE||s.nodeType==Node.TEXT_NODE)t.push(s.nodeValue);else{let n;for(n=s.firstChild;n;n=n.nextSibling)Fd(n,e,t)}return t}function Sn(s){return"documentElement"in s}function vn(s){return new DOMParser().parseFromString(s,"application/xml")}function Pc(s,e){return(function(t,n){const i=s.call(e??this,t,n);if(i!==void 0){const r=n[n.length-1];ne(r,i)}})}function pn(s,e){return(function(t,n){const i=s.call(e??this,t,n);i!==void 0&&n[n.length-1].push(i)})}function oh(s,e){return(function(t,n){const i=s.call(this,t,n);i!==void 0&&(n[n.length-1]=i)})}function O(s,e,t){return(function(n,i){const r=s.call(this,n,i);if(r!==void 0){const o=i[i.length-1],a=e!==void 0?e:n.localName;o[a]=r}})}function Y(s,e){return(function(t,n,i){s.call(this,t,n,i),i[i.length-1].node.appendChild(t)})}function hn(s,e){return(function(t,n,i){const o=n[n.length-1].node;let a=s;a===void 0&&(a=i);const l=o.namespaceURI;return Ws(l,a)})}const Tt=hn();function At(s,e){const t=e.length,n=new Array(t);for(let i=0;i<t;++i)n[i]=s[e[i]];return n}function z(s,e,t){t=t!==void 0?t:{};let n,i;for(n=0,i=s.length;n<i;++n)t[s[n]]=e;return t}function qi(s,e,t,n){let i;for(i=e.firstElementChild;i;i=i.nextElementSibling){const r=s[i.namespaceURI];if(r!==void 0){const o=r[i.localName];o!==void 0&&o.call(n,i,t)}}}function ce(s,e,t,n,i){return n.push(s),qi(e,t,n,i),n.pop()}function Dx(s,e,t,n,i,r){const o=(i!==void 0?i:t).length;let a,l;for(let h=0;h<o;++h)a=t[h],a!==void 0&&(l=e.call(r,a,n,i!==void 0?i[h]:void 0),l!==void 0&&s[l.namespaceURI][l.localName].call(r,l,a,n))}function Re(s,e,t,n,i,r,o){return i.push(s),Dx(e,t,n,i,r,o),i.pop()}let fa;function Ox(){return fa===void 0&&typeof XMLSerializer<"u"&&(fa=new XMLSerializer),fa}let ga;function yo(){return ga===void 0&&typeof document<"u"&&(ga=document.implementation.createDocument("","",null)),ga}class Nx extends Wl{constructor(){super(),this.xmlSerializer_=Ox()}getType(){return"xml"}readFeature(e,t){if(!e)return null;if(typeof e=="string"){const n=vn(e);return this.readFeatureFromDocument(n,t)}return Sn(e)?this.readFeatureFromDocument(e,t):this.readFeatureFromNode(e,t)}readFeatureFromDocument(e,t){const n=this.readFeaturesFromDocument(e,t);return n.length>0?n[0]:null}readFeatureFromNode(e,t){return null}readFeatures(e,t){if(!e)return[];if(typeof e=="string"){const n=vn(e);return this.readFeaturesFromDocument(n,t)}return Sn(e)?this.readFeaturesFromDocument(e,t):this.readFeaturesFromNode(e,t)}readFeaturesFromDocument(e,t){const n=[];for(let i=e.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&ne(n,this.readFeaturesFromNode(i,t));return n}readFeaturesFromNode(e,t){return $()}readGeometry(e,t){if(!e)return null;if(typeof e=="string"){const n=vn(e);return this.readGeometryFromDocument(n,t)}return Sn(e)?this.readGeometryFromDocument(e,t):this.readGeometryFromNode(e,t)}readGeometryFromDocument(e,t){return null}readGeometryFromNode(e,t){return null}readProjection(e){if(!e)return null;if(typeof e=="string"){const t=vn(e);return this.readProjectionFromDocument(t)}return Sn(e)?this.readProjectionFromDocument(e):this.readProjectionFromNode(e)}readProjectionFromDocument(e){return this.dataProjection}readProjectionFromNode(e){return this.dataProjection}writeFeature(e,t){const n=this.writeFeatureNode(e,t);return this.xmlSerializer_.serializeToString(n)}writeFeatureNode(e,t){return null}writeFeatures(e,t){const n=this.writeFeaturesNode(e,t);return this.xmlSerializer_.serializeToString(n)}writeFeaturesNode(e,t){return null}writeGeometry(e,t){const n=this.writeGeometryNode(e,t);return this.xmlSerializer_.serializeToString(n)}writeGeometryNode(e,t){return null}}function Ln(s){const e=ln(s,!1);return Gx(e)}function Gx(s){const e=/^\s*(true|1)|(false|0)\s*$/.exec(s);if(e)return e[1]!==void 0||!1}function ye(s){const e=ln(s,!1);return kx(e)}function kx(s){const e=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(s);if(e)return parseFloat(e[1])}function Ye(s){return ln(s,!1).trim()}function $i(s,e){pt(s,e?"1":"0")}function Ux(s,e){s.appendChild(yo().createCDATASection(e))}function Yn(s,e){const t=e.toPrecision();s.appendChild(yo().createTextNode(t))}const Bx=/^\s/,zx=/\s$/,$x=/(\n|\t|\r|<|&| {2})/;function pt(s,e){typeof e=="string"&&(Bx.test(e)||zx.test(e)||$x.test(e))?e.split("]]>").forEach((t,n,i)=>{n<i.length-1&&(t+="]]"),n>0&&(t=">"+t),Ux(s,t)}):s.appendChild(yo().createTextNode(e))}const cn=["http://www.google.com/kml/ext/2.2"],k=[null,"http://earth.google.com/kml/2.0","http://earth.google.com/kml/2.1","http://earth.google.com/kml/2.2","http://www.opengis.net/kml/2.2"],Xx="http://www.opengis.net/kml/2.2 https://developers.google.com/kml/schema/kml22gx.xsd",Ic={fraction:"fraction",pixels:"pixels",insetPixels:"pixels"},Yx=z(k,{ExtendedData:Wd,Region:Vd,MultiGeometry:O(Xd,"geometry"),LineString:O(zd,"geometry"),LinearRing:O($d,"geometry"),Point:O(Yd,"geometry"),Polygon:O(jd,"geometry"),Style:O(hh),StyleMap:wE,address:O(Ye),description:O(Ye),name:O(Ye),open:O(Ln),phoneNumber:O(Ye),styleUrl:O(Nd),visibility:O(Ln)},z(cn,{MultiTrack:O(fE,"geometry"),Track:O(Bd,"geometry")})),jx=z(k,{ExtendedData:Wd,Region:Vd,Link:kE,address:O(Ye),description:O(Ye),name:O(Ye),open:O(Ln),phoneNumber:O(Ye),visibility:O(Ln)}),Wx=z(k,{href:O(Od)}),Vx=z(k,{Altitude:O(ye),Longitude:O(ye),Latitude:O(ye),Tilt:O(ye),AltitudeMode:O(Ye),Heading:O(ye),Roll:O(ye)}),Md=z(k,{LatLonAltBox:FE,Lod:bE}),Zx=z(k,["Document","Placemark"]),Kx=z(k,{Document:Y(WE),Placemark:Y(Hd)});let Di,Sr=null,Wa,ys,xs,Es,Hr,Va=null,ah,Za=null,Ka,jn=null,Ac=null,Ha=null;function qr(s){return 32/Math.min(s[0],s[1])}function Hx(){Di=[255,255,255,1],Sr=new It({color:Di}),Wa=[20,2],ys="pixels",xs="pixels",Es=[64,64],Hr="https://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png",Va=new Ki({anchor:Wa,anchorOrigin:"bottom-left",anchorXUnits:ys,anchorYUnits:xs,crossOrigin:"anonymous",rotation:0,scale:qr(Es),size:Es,src:Hr}),ah="NO_IMAGE",Za=new kt({color:Di,width:1}),Ka=new kt({color:[51,51,51,1],width:2}),jn=new Xs({font:"bold 16px Helvetica",fill:Sr,stroke:Ka,scale:.8}),Ac=new Ne({fill:Sr,image:Va,text:jn,stroke:Za,zIndex:0}),Ha=[Ac]}let Tr;function qx(s){return s}class Z0 extends Nx{constructor(e){super(),e=e||{},Ha||Hx(),this.dataProjection=de("EPSG:4326"),this.defaultStyle_=e.defaultStyle?e.defaultStyle:Ha,this.extractStyles_=e.extractStyles!==void 0?e.extractStyles:!0,this.writeStyles_=e.writeStyles!==void 0?e.writeStyles:!0,this.sharedStyles_={},this.showPointNames_=e.showPointNames!==void 0?e.showPointNames:!0,this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:"anonymous",this.iconUrlFunction_=e.iconUrlFunction?e.iconUrlFunction:qx,this.supportedMediaTypes=["application/vnd.google-earth.kml+xml"]}readDocumentOrFolder_(e,t){const n=z(k,{Document:Pc(this.readDocumentOrFolder_,this),Folder:Pc(this.readDocumentOrFolder_,this),Placemark:pn(this.readPlacemark_,this),Style:this.readSharedStyle_.bind(this),StyleMap:this.readSharedStyleMap_.bind(this)}),i=ce([],n,e,t,this);if(i)return i}readPlacemark_(e,t){const n=ce({geometry:null},Yx,e,t,this);if(!n)return;const i=new $e,r=e.getAttribute("id");r!==null&&i.setId(r);const o=t[0],a=n.geometry;if(a&&Qn(a,!1,o),i.setGeometry(a),delete n.geometry,this.extractStyles_){const l=n.Style,h=n.styleUrl,c=Qx(l,h,this.defaultStyle_,this.sharedStyles_,this.showPointNames_);i.setStyle(c)}return delete n.Style,i.setProperties(n,!0),i}readSharedStyle_(e,t){const n=e.getAttribute("id");if(n!==null){const i=hh.call(this,e,t);if(i){let r,o=e.baseURI;(!o||o=="about:blank")&&(o=window.location.href),o?r=new URL("#"+n,o).href:r="#"+n,this.sharedStyles_[r]=i}}}readSharedStyleMap_(e,t){const n=e.getAttribute("id");if(n===null)return;const i=kd.call(this,e,t);if(!i)return;let r,o=e.baseURI;(!o||o=="about:blank")&&(o=window.location.href),o?r=new URL("#"+n,o).href:r="#"+n,this.sharedStyles_[r]=i}readFeatureFromNode(e,t){if(!k.includes(e.namespaceURI))return null;const n=this.readPlacemark_(e,[this.getReadOptions(e,t)]);return n||null}readFeaturesFromNode(e,t){if(!k.includes(e.namespaceURI))return[];let n;const i=e.localName;if(i=="Document"||i=="Folder")return n=this.readDocumentOrFolder_(e,[this.getReadOptions(e,t)]),n||[];if(i=="Placemark"){const r=this.readPlacemark_(e,[this.getReadOptions(e,t)]);return r?[r]:[]}if(i=="kml"){n=[];for(let r=e.firstElementChild;r;r=r.nextElementSibling){const o=this.readFeaturesFromNode(r,t);o&&ne(n,o)}return n}return[]}readName(e){if(e){if(typeof e=="string"){const t=vn(e);return this.readNameFromDocument(t)}return Sn(e)?this.readNameFromDocument(e):this.readNameFromNode(e)}}readNameFromDocument(e){for(let t=e.firstChild;t;t=t.nextSibling)if(t.nodeType==Node.ELEMENT_NODE){const n=this.readNameFromNode(t);if(n)return n}}readNameFromNode(e){for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(k.includes(t.namespaceURI)&&t.localName=="name")return Ye(t);for(let t=e.firstElementChild;t;t=t.nextElementSibling){const n=t.localName;if(k.includes(t.namespaceURI)&&(n=="Document"||n=="Folder"||n=="Placemark"||n=="kml")){const i=this.readNameFromNode(t);if(i)return i}}}readNetworkLinks(e){const t=[];if(typeof e=="string"){const n=vn(e);ne(t,this.readNetworkLinksFromDocument(n))}else Sn(e)?ne(t,this.readNetworkLinksFromDocument(e)):ne(t,this.readNetworkLinksFromNode(e));return t}readNetworkLinksFromDocument(e){const t=[];for(let n=e.firstChild;n;n=n.nextSibling)n.nodeType==Node.ELEMENT_NODE&&ne(t,this.readNetworkLinksFromNode(n));return t}readNetworkLinksFromNode(e){const t=[];for(let n=e.firstElementChild;n;n=n.nextElementSibling)if(k.includes(n.namespaceURI)&&n.localName=="NetworkLink"){const i=ce({},jx,n,[]);t.push(i)}for(let n=e.firstElementChild;n;n=n.nextElementSibling){const i=n.localName;k.includes(n.namespaceURI)&&(i=="Document"||i=="Folder"||i=="kml")&&ne(t,this.readNetworkLinksFromNode(n))}return t}readRegion(e){const t=[];if(typeof e=="string"){const n=vn(e);ne(t,this.readRegionFromDocument(n))}else Sn(e)?ne(t,this.readRegionFromDocument(e)):ne(t,this.readRegionFromNode(e));return t}readRegionFromDocument(e){const t=[];for(let n=e.firstChild;n;n=n.nextSibling)n.nodeType==Node.ELEMENT_NODE&&ne(t,this.readRegionFromNode(n));return t}readRegionFromNode(e){const t=[];for(let n=e.firstElementChild;n;n=n.nextElementSibling)if(k.includes(n.namespaceURI)&&n.localName=="Region"){const i=ce({},Md,n,[]);t.push(i)}for(let n=e.firstElementChild;n;n=n.nextElementSibling){const i=n.localName;k.includes(n.namespaceURI)&&(i=="Document"||i=="Folder"||i=="kml")&&ne(t,this.readRegionFromNode(n))}return t}readCamera(e){const t=[];if(typeof e=="string"){const n=vn(e);ne(t,this.readCameraFromDocument(n))}else Sn(e)?ne(t,this.readCameraFromDocument(e)):ne(t,this.readCameraFromNode(e));return t}readCameraFromDocument(e){const t=[];for(let n=e.firstChild;n;n=n.nextSibling)n.nodeType===Node.ELEMENT_NODE&&ne(t,this.readCameraFromNode(n));return t}readCameraFromNode(e){const t=[];for(let n=e.firstElementChild;n;n=n.nextElementSibling)if(k.includes(n.namespaceURI)&&n.localName==="Camera"){const i=ce({},Vx,n,[]);t.push(i)}for(let n=e.firstElementChild;n;n=n.nextElementSibling){const i=n.localName;k.includes(n.namespaceURI)&&(i==="Document"||i==="Folder"||i==="Placemark"||i==="kml")&&ne(t,this.readCameraFromNode(n))}return t}writeFeaturesNode(e,t){t=this.adaptOptions(t);const n=Ws(k[4],"kml"),i="http://www.w3.org/2000/xmlns/";n.setAttributeNS(i,"xmlns:gx",cn[0]),n.setAttributeNS(i,"xmlns:xsi",wc),n.setAttributeNS(wc,"xsi:schemaLocation",Xx);const r={node:n},o={};e.length>1?o.Document=e:e.length==1&&(o.Placemark=e[0]);const a=Zx[n.namespaceURI],l=At(o,a);return Re(r,Kx,Tt,l,[t],a,this),n}}function Jx(s,e){const t=[0,0];let n="start";const i=s.getImage();if(i){const a=i.getSize();if(a&&a.length==2){const l=i.getScaleArray(),h=i.getAnchor();t[0]=l[0]*(a[0]-h[0]),t[1]=l[1]*(a[1]/2-h[1]),n="left"}}let r=s.getText();return r?(r=r.clone(),r.setFont(r.getFont()||jn.getFont()),r.setScale(r.getScale()||jn.getScale()),r.setFill(r.getFill()||jn.getFill()),r.setStroke(r.getStroke()||Ka)):r=jn.clone(),r.setText(e),r.setOffsetX(t[0]),r.setOffsetY(t[1]),r.setTextAlign(n),new Ne({image:i,text:r})}function Qx(s,e,t,n,i){return(function(r,o){let a=i,l="",h=[];if(a){const u=r.getGeometry();if(u)if(u instanceof He)h=u.getGeometriesArrayRecursive().filter(function(d){const f=d.getType();return f==="Point"||f==="MultiPoint"}),a=h.length>0;else{const d=u.getType();a=d==="Point"||d==="MultiPoint"}}a&&(l=r.get("name"),a=a&&!!l,a&&/&[^&]+;/.test(l)&&(Tr||(Tr=document.createElement("textarea")),Tr.innerHTML=l,l=Tr.value));let c=t;if(s?c=s:e&&(c=bd(e,t,n)),a){const u=Jx(c[0],l);if(h.length>0){u.setGeometry(new He(h));const d=new Ne({geometry:c[0].getGeometry(),image:null,fill:c[0].getFill(),stroke:c[0].getStroke(),text:null});return[u,d].concat(c.slice(1))}return u}return c})}function bd(s,e,t){return Array.isArray(s)?s:typeof s=="string"?bd(t[s],e,t):e}function xo(s){const e=ln(s,!1),t=/^\s*#?\s*([0-9A-Fa-f]{8})\s*$/.exec(e);if(t){const n=t[1];return[parseInt(n.substr(6,2),16),parseInt(n.substr(4,2),16),parseInt(n.substr(2,2),16),parseInt(n.substr(0,2),16)/255]}}function Dd(s){let e=ln(s,!1);const t=[];e=e.replace(/\s*,\s*/g,",");const n=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?),([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|,|$)(?:([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|$))?\s*/i;let i;for(;i=n.exec(e);){const r=parseFloat(i[1]),o=parseFloat(i[2]),a=i[3]?parseFloat(i[3]):0;t.push(r,o,a),e=e.substr(i[0].length)}if(e==="")return t}function Od(s){const e=ln(s,!1).trim();let t=s.baseURI;return(!t||t=="about:blank")&&(t=window.location.href),t?new URL(e,t).href:e}function Nd(s){const e=ln(s,!1).trim().replace(/^(?!.*#)/,"#");let t=s.baseURI;return(!t||t=="about:blank")&&(t=window.location.href),t?new URL(e,t).href:e}function eE(s){const e=s.getAttribute("xunits"),t=s.getAttribute("yunits");let n;return e!=="insetPixels"?t!=="insetPixels"?n="bottom-left":n="top-left":t!=="insetPixels"?n="bottom-right":n="top-right",{x:parseFloat(s.getAttribute("x")),xunits:Ic[e],y:parseFloat(s.getAttribute("y")),yunits:Ic[t],origin:n}}function Gd(s){return ye(s)}const tE=z(k,{Pair:vE});function kd(s,e){return ce(void 0,tE,s,e,this)}const nE=z(k,{Icon:O(mE),color:O(xo),heading:O(ye),hotSpot:O(eE),scale:O(Gd)});function iE(s,e){const t=ce({},nE,s,e);if(!t)return;const n=e[e.length-1],i="Icon"in t?t.Icon:{},r=!("Icon"in t)||Object.keys(i).length>0;let o;const a=i.href;a?o=a:r&&(o=Hr);let l,h,c,u="bottom-left";const d=t.hotSpot;d?(l=[d.x,d.y],h=d.xunits,c=d.yunits,u=d.origin):/^https?:\/\/maps\.(?:google|gstatic)\.com\//.test(o)&&(o.includes("pushpin")?(l=Wa,h=ys,c=xs):o.includes("arrow-reverse")?(l=[54,42],h=ys,c=xs):o.includes("paddle")&&(l=[32,1],h=ys,c=xs));let f;const g=i.x,m=i.y;g!==void 0&&m!==void 0&&(f=[g,m]);let _;const p=i.w,y=i.h;p!==void 0&&y!==void 0&&(_=[p,y]);let E;const x=t.heading;x!==void 0&&(E=Ke(x));const T=t.scale,R=t.color;if(r){o==Hr&&(_=Es);const S=new Ki({anchor:l,anchorOrigin:u,anchorXUnits:h,anchorYUnits:c,crossOrigin:this.crossOrigin_,offset:f,offsetOrigin:"bottom-left",rotation:E,scale:T,size:_,src:this.iconUrlFunction_(o),color:R}),v=S.getScaleArray()[0],w=S.getSize();if(w===null){const I=S.getImageState();if(I===U.IDLE||I===U.LOADING){const F=function(){const A=S.getImageState();if(!(A===U.IDLE||A===U.LOADING)){const M=S.getSize();if(M&&M.length==2){const b=qr(M);S.setScale(v*b)}S.unlistenImageChange(F)}};S.listenImageChange(F),I===U.IDLE&&S.load()}}else if(w.length==2){const I=qr(w);S.setScale(v*I)}n.imageStyle=S}else n.imageStyle=ah}const sE=z(k,{color:O(xo),scale:O(Gd)});function rE(s,e){const t=ce({},sE,s,e);if(!t)return;const n=e[e.length-1],i=new Xs({fill:new It({color:"color"in t?t.color:Di}),scale:t.scale});n.textStyle=i}const oE=z(k,{color:O(xo),width:O(ye)});function aE(s,e){const t=ce({},oE,s,e);if(!t)return;const n=e[e.length-1],i=new kt({color:"color"in t?t.color:Di,width:"width"in t?t.width:1});n.strokeStyle=i}const lE=z(k,{color:O(xo),fill:O(Ln),outline:O(Ln)});function hE(s,e){const t=ce({},lE,s,e);if(!t)return;const n=e[e.length-1],i=new It({color:"color"in t?t.color:Di});n.fillStyle=i;const r=t.fill;r!==void 0&&(n.fill=r);const o=t.outline;o!==void 0&&(n.outline=o)}const cE=z(k,{coordinates:oh(Dd)});function Ud(s,e){return ce(null,cE,s,e)}function uE(s,e){const n=e[e.length-1].coordinates,i=ln(s,!1),o=/^\s*([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s*$/i.exec(i);if(o){const a=parseFloat(o[1]),l=parseFloat(o[2]),h=parseFloat(o[3]);n.push([a,l,h])}else n.push([])}const dE=z(cn,{Track:pn(Bd)});function fE(s,e){const t=ce([],dE,s,e);if(t)return new on(t)}const gE=z(k,{when:UE},z(cn,{coord:uE}));function Bd(s,e){const t=ce({coordinates:[],whens:[]},gE,s,e);if(!t)return;const n=[],i=t.coordinates,r=t.whens;for(let o=0,a=Math.min(i.length,r.length);o<a;++o)i[o].length==3&&n.push(i[o][0],i[o][1],i[o][2],r[o]);return new ht(n,"XYZM")}const _E=z(k,{href:O(Od)},z(cn,{x:O(ye),y:O(ye),w:O(ye),h:O(ye)}));function mE(s,e){const t=ce({},_E,s,e);return t||null}const pE=z(k,{coordinates:oh(Dd)});function lh(s,e){return ce(null,pE,s,e)}const Eo=z(k,{extrude:O(Ln),tessellate:O(Ln),altitudeMode:O(Ye)});function zd(s,e){const t=ce({},Eo,s,e),n=lh(s,e);if(n){const i=new ht(n,"XYZ");return i.setProperties(t,!0),i}}function $d(s,e){const t=ce({},Eo,s,e),n=lh(s,e);if(n){const i=new qe(n,"XYZ",[n.length]);return i.setProperties(t,!0),i}}const yE=z(k,{LineString:pn(zd),LinearRing:pn($d),MultiGeometry:pn(Xd),Point:pn(Yd),Polygon:pn(jd)});function Xd(s,e){const t=ce([],yE,s,e);if(!t)return null;if(t.length===0)return new He(t);let n,i=!0;const r=t[0].getType();let o;for(let a=1,l=t.length;a<l;++a)if(o=t[a],o.getType()!=r){i=!1;break}if(i){let a,l;if(r=="Point"){const h=t[0];a=h.getLayout(),l=h.getFlatCoordinates();for(let c=1,u=t.length;c<u;++c)o=t[c],ne(l,o.getFlatCoordinates());n=new oi(l,a),_a(n,t)}else if(r=="LineString")n=new on(t),_a(n,t);else if(r=="Polygon")n=new An(t),_a(n,t);else if(r=="GeometryCollection"||r.startsWith("Multi"))n=new He(t);else throw new Error("Unknown geometry type found")}else n=new He(t);return n}function Yd(s,e){const t=ce({},Eo,s,e),n=lh(s,e);if(n){const i=new lt(n,"XYZ");return i.setProperties(t,!0),i}}const xE=z(k,{innerBoundaryIs:OE,outerBoundaryIs:GE});function jd(s,e){const t=ce({},Eo,s,e),n=ce([null],xE,s,e);if(n&&n[0]){const i=n[0],r=[i.length];for(let a=1,l=n.length;a<l;++a)ne(i,n[a]),r.push(i.length);const o=new qe(i,"XYZ",r);return o.setProperties(t,!0),o}}const EE=z(k,{IconStyle:iE,LabelStyle:rE,LineStyle:aE,PolyStyle:hE});function hh(s,e){const t=ce({},EE,s,e,this);if(!t)return null;let n="fillStyle"in t?t.fillStyle:Sr;const i=t.fill;i!==void 0&&!i&&(n=null);let r;"imageStyle"in t?t.imageStyle!=ah&&(r=t.imageStyle):r=Va;const o="textStyle"in t?t.textStyle:jn,a="strokeStyle"in t?t.strokeStyle:Za,l=t.outline;return l!==void 0&&!l?[new Ne({geometry:function(h){const c=h.getGeometry(),u=c.getType();if(u==="GeometryCollection"){const d=c;return new He(d.getGeometriesArrayRecursive().filter(function(f){const g=f.getType();return g!=="Polygon"&&g!=="MultiPolygon"}))}if(u!=="Polygon"&&u!=="MultiPolygon")return c},fill:n,image:r,stroke:a,text:o,zIndex:void 0}),new Ne({geometry:function(h){const c=h.getGeometry(),u=c.getType();if(u==="GeometryCollection"){const d=c;return new He(d.getGeometriesArrayRecursive().filter(function(f){const g=f.getType();return g==="Polygon"||g==="MultiPolygon"}))}if(u==="Polygon"||u==="MultiPolygon")return c},fill:n,stroke:null,zIndex:void 0})]:[new Ne({fill:n,image:r,stroke:a,text:o,zIndex:void 0})]}function _a(s,e){const t=e.length,n=new Array(e.length),i=new Array(e.length),r=new Array(e.length);let o,a,l;o=!1,a=!1,l=!1;for(let h=0;h<t;++h){const c=e[h];n[h]=c.get("extrude"),i[h]=c.get("tessellate"),r[h]=c.get("altitudeMode"),o=o||n[h]!==void 0,a=a||i[h]!==void 0,l=l||r[h]}o&&s.set("extrude",n),a&&s.set("tessellate",i),l&&s.set("altitudeMode",r)}const TE=z(k,{displayName:O(Ye),value:O(Ye)});function CE(s,e){const t=s.getAttribute("name");qi(TE,s,e);const n=e[e.length-1];t&&n.displayName?n[t]={value:n.value,displayName:n.displayName,toString:function(){return n.value}}:t!==null?n[t]=n.value:n.displayName!==null&&(n[n.displayName]=n.value),delete n.value}const RE=z(k,{Data:CE,SchemaData:IE});function Wd(s,e){qi(RE,s,e)}function Vd(s,e){qi(Md,s,e)}const SE=z(k,{Style:O(hh),key:O(Ye),styleUrl:O(Nd)});function vE(s,e){const t=ce({},SE,s,e,this);if(!t)return;const n=t.key;if(n&&n=="normal"){const i=t.styleUrl;i&&(e[e.length-1]=i);const r=t.Style;r&&(e[e.length-1]=r)}}function wE(s,e){const t=kd.call(this,s,e);if(!t)return;const n=e[e.length-1];if(Array.isArray(t))n.Style=t;else if(typeof t=="string")n.styleUrl=t;else throw new Error("`styleMapValue` has an unknown type")}const PE=z(k,{SimpleData:AE});function IE(s,e){qi(PE,s,e)}function AE(s,e){const t=s.getAttribute("name");if(t!==null){const n=Ye(s),i=e[e.length-1];i[t]=n}}const LE=z(k,{altitudeMode:O(Ye),minAltitude:O(ye),maxAltitude:O(ye),north:O(ye),south:O(ye),east:O(ye),west:O(ye)});function FE(s,e){const t=ce({},LE,s,e);if(!t)return;const n=e[e.length-1],i=[parseFloat(t.west),parseFloat(t.south),parseFloat(t.east),parseFloat(t.north)];n.extent=i,n.altitudeMode=t.altitudeMode,n.minAltitude=parseFloat(t.minAltitude),n.maxAltitude=parseFloat(t.maxAltitude)}const ME=z(k,{minLodPixels:O(ye),maxLodPixels:O(ye),minFadeExtent:O(ye),maxFadeExtent:O(ye)});function bE(s,e){const t=ce({},ME,s,e);if(!t)return;const n=e[e.length-1];n.minLodPixels=parseFloat(t.minLodPixels),n.maxLodPixels=parseFloat(t.maxLodPixels),n.minFadeExtent=parseFloat(t.minFadeExtent),n.maxFadeExtent=parseFloat(t.maxFadeExtent)}const DE=z(k,{LinearRing:pn(Ud)});function OE(s,e){const t=ce([],DE,s,e);t.length>0&&e[e.length-1].push(...t)}const NE=z(k,{LinearRing:oh(Ud)});function GE(s,e){const t=ce(void 0,NE,s,e);if(t){const n=e[e.length-1];n[0]=t}}function kE(s,e){qi(Wx,s,e)}function UE(s,e){const n=e[e.length-1].whens,i=ln(s,!1),r=Date.parse(i);n.push(isNaN(r)?0:r)}function To(s,e){const t=Ct(e),i=[(t.length==4?t[3]:1)*255,t[2],t[1],t[0]];for(let r=0;r<4;++r){const o=Math.floor(i[r]).toString(16);i[r]=o.length==1?"0"+o:o}pt(s,i.join(""))}function BE(s,e,t){const n=t[t.length-1],i=n.layout,r=n.stride;let o;if(i=="XY"||i=="XYM")o=2;else if(i=="XYZ"||i=="XYZM")o=3;else throw new Error("Invalid geometry layout");const a=e.length;let l="";if(a>0){l+=e[0];for(let h=1;h<o;++h)l+=","+e[h];for(let h=r;h<a;h+=r){l+=" "+e[h];for(let c=1;c<o;++c)l+=","+e[h+c]}}pt(s,l)}const vr=z(k,{Data:Y(zE),value:Y(XE),displayName:Y($E)});function zE(s,e,t){s.setAttribute("name",e.name);const n={node:s},i=e.value;typeof i=="object"?(i!==null&&i.displayName&&Re(n,vr,Tt,[i.displayName],t,["displayName"]),i!==null&&i.value&&Re(n,vr,Tt,[i.value],t,["value"])):Re(n,vr,Tt,[i],t,["value"])}function $E(s,e){pt(s,e)}function XE(s,e){pt(s,e)}const YE=z(k,{Placemark:Y(Hd)}),jE=function(s,e,t){const n=e[e.length-1].node;return Ws(n.namespaceURI,"Placemark")};function WE(s,e,t){Re({node:s},YE,jE,e,t,void 0,this)}const VE=hn("Data");function ZE(s,e,t){const n={node:s},i=e.names,r=e.values,o=i.length;for(let a=0;a<o;a++)Re(n,vr,VE,[{name:i[a],value:r[a]}],t)}const Lc=z(k,["href"],z(cn,["x","y","w","h"])),Fc=z(k,{href:Y(pt)},z(cn,{x:Y(Yn),y:Y(Yn),w:Y(Yn),h:Y(Yn)})),KE=function(s,e,t){return Ws(cn[0],"gx:"+t)};function HE(s,e,t){const n={node:s},i=t[t.length-1].node;let r=Lc[i.namespaceURI],o=At(e,r);Re(n,Fc,Tt,o,t,r),r=Lc[cn[0]],o=At(e,r),Re(n,Fc,KE,o,t,r)}const qE=z(k,["scale","heading","Icon","color","hotSpot"]),JE=z(k,{Icon:Y(HE),color:Y(To),heading:Y(Yn),hotSpot:Y(v0),scale:Y(Jd)});function QE(s,e,t){const n={node:s},i={},r=e.getSrc(),o=e.getSize(),a=e.getImageSize(),l={href:r};if(o){l.w=o[0],l.h=o[1];const _=e.getAnchor(),p=e.getOrigin();if(p&&a&&p[0]!==0&&p[1]!==o[1]&&(l.x=p[0],l.y=a[1]-(p[1]+o[1])),_&&(_[0]!==o[0]/2||_[1]!==o[1]/2)){const y={x:_[0],xunits:"pixels",y:o[1]-_[1],yunits:"pixels"};i.hotSpot=y}}i.Icon=l;let h=e.getScaleArray()[0],c=o;if(c===null&&(c=Es),c.length==2){const _=qr(c);h=h/_}h!==1&&(i.scale=h);const u=e.getRotation();u!==0&&(i.heading=u);const d=e.getColor();d&&(i.color=d);const f=t[t.length-1].node,g=qE[f.namespaceURI],m=At(i,g);Re(n,JE,Tt,m,t,g)}const e0=z(k,["color","scale"]),t0=z(k,{color:Y(To),scale:Y(Jd)});function n0(s,e,t){const n={node:s},i={},r=e.getFill();r&&(i.color=r.getColor());const o=e.getScale();o&&o!==1&&(i.scale=o);const a=t[t.length-1].node,l=e0[a.namespaceURI],h=At(i,l);Re(n,t0,Tt,h,t,l)}const i0=z(k,["color","width"]),s0=z(k,{color:Y(To),width:Y(Yn)});function r0(s,e,t){const n={node:s},i={color:e.getColor(),width:Number(e.getWidth())||1},r=t[t.length-1].node,o=i0[r.namespaceURI],a=At(i,o);Re(n,s0,Tt,a,t,o)}const o0={Point:"Point",LineString:"LineString",LinearRing:"LinearRing",Polygon:"Polygon",MultiPoint:"MultiGeometry",MultiLineString:"MultiGeometry",MultiPolygon:"MultiGeometry",GeometryCollection:"MultiGeometry"},Zd=function(s,e,t){if(s){const n=e[e.length-1].node;return Ws(n.namespaceURI,o0[s.getType()])}},a0=hn("Point"),l0=hn("LineString"),h0=hn("LinearRing"),c0=hn("Polygon"),u0=z(k,{LineString:Y(Oi),Point:Y(Oi),Polygon:Y(qd),GeometryCollection:Y(Kd)});function Kd(s,e,t){const n={node:s},i=e.getType();let r=[],o;if(i==="GeometryCollection")e.getGeometriesArrayRecursive().forEach(function(a){const l=a.getType();if(l==="MultiPoint")r=r.concat(a.getPoints());else if(l==="MultiLineString")r=r.concat(a.getLineStrings());else if(l==="MultiPolygon")r=r.concat(a.getPolygons());else if(l==="Point"||l==="LineString"||l==="Polygon")r.push(a);else throw new Error("Unknown geometry type")}),o=Zd;else if(i==="MultiPoint")r=e.getPoints(),o=a0;else if(i==="MultiLineString")r=e.getLineStrings(),o=l0;else if(i==="MultiPolygon")r=e.getPolygons(),o=c0;else throw new Error("Unknown geometry type");Re(n,u0,o,r,t)}const d0=z(k,{LinearRing:Y(Oi)});function Mc(s,e,t){Re({node:s},d0,h0,[e],t)}const ma=z(k,{ExtendedData:Y(ZE),MultiGeometry:Y(Kd),LineString:Y(Oi),LinearRing:Y(Oi),Point:Y(Oi),Polygon:Y(qd),Style:Y(S0),address:Y(pt),description:Y(pt),name:Y(pt),open:Y($i),phoneNumber:Y(pt),styleUrl:Y(pt),visibility:Y($i)}),f0=z(k,["name","open","visibility","address","phoneNumber","description","styleUrl","Style"]),g0=hn("ExtendedData");function Hd(s,e,t){const n={node:s};e.getId()&&s.setAttribute("id",e.getId());const i=e.getProperties(),r={address:1,description:1,name:1,open:1,phoneNumber:1,styleUrl:1,visibility:1};r[e.getGeometryName()]=1;const o=Object.keys(i||{}).sort().filter(function(f){return!r[f]}),a=e.getStyleFunction();if(a){const f=a(e,0);if(f){const g=Array.isArray(f)?f:[f];let m=g;if(e.getGeometry()&&(m=g.filter(function(_){const p=_.getGeometryFunction()(e);if(p){const y=p.getType();return y==="GeometryCollection"?p.getGeometriesArrayRecursive().filter(function(E){const x=E.getType();return x==="Point"||x==="MultiPoint"}).length:y==="Point"||y==="MultiPoint"}})),this.writeStyles_){let _=g,p=g;e.getGeometry()&&(_=g.filter(function(y){const E=y.getGeometryFunction()(e);if(E){const x=E.getType();return x==="GeometryCollection"?E.getGeometriesArrayRecursive().filter(function(T){const R=T.getType();return R==="LineString"||R==="MultiLineString"}).length:x==="LineString"||x==="MultiLineString"}}),p=g.filter(function(y){const E=y.getGeometryFunction()(e);if(E){const x=E.getType();return x==="GeometryCollection"?E.getGeometriesArrayRecursive().filter(function(T){const R=T.getType();return R==="Polygon"||R==="MultiPolygon"}).length:x==="Polygon"||x==="MultiPolygon"}})),i.Style={pointStyles:m,lineStyles:_,polyStyles:p}}if(m.length&&i.name===void 0){const _=m[0].getText();_&&(i.name=_.getText())}}}const l=t[t.length-1].node,h=f0[l.namespaceURI],c=At(i,h);if(Re(n,ma,Tt,c,t,h),o.length>0){const f=At(i,o);Re(n,ma,g0,[{names:o,values:f}],t)}const u=t[0];let d=e.getGeometry();d&&(d=Qn(d,!0,u)),Re(n,ma,Zd,[d],t)}const _0=z(k,["extrude","tessellate","altitudeMode","coordinates"]),m0=z(k,{extrude:Y($i),tessellate:Y($i),altitudeMode:Y(pt),coordinates:Y(BE)});function Oi(s,e,t){const n=e.getFlatCoordinates(),i={node:s};i.layout=e.getLayout(),i.stride=e.getStride();const r=e.getProperties();r.coordinates=n;const o=t[t.length-1].node,a=_0[o.namespaceURI],l=At(r,a);Re(i,m0,Tt,l,t,a)}const p0=z(k,["color","fill","outline"]),bc=z(k,{outerBoundaryIs:Y(Mc),innerBoundaryIs:Y(Mc)}),y0=hn("innerBoundaryIs"),x0=hn("outerBoundaryIs");function qd(s,e,t){const n=e.getLinearRings(),i=n.shift(),r={node:s};Re(r,bc,y0,n,t),Re(r,bc,x0,[i],t)}const E0=z(k,{color:Y(To),fill:Y($i),outline:Y($i)});function T0(s,e,t){const n={node:s},i=e.getFill(),r=e.getStroke(),o={color:i?i.getColor():void 0,fill:i?void 0:!1,outline:r?void 0:!1},a=t[t.length-1].node,l=p0[a.namespaceURI],h=At(o,l);Re(n,E0,Tt,h,t,l)}function Jd(s,e){Yn(s,Math.round(e*1e6)/1e6)}const C0=z(k,["IconStyle","LabelStyle","LineStyle","PolyStyle"]),R0=z(k,{IconStyle:Y(QE),LabelStyle:Y(n0),LineStyle:Y(r0),PolyStyle:Y(T0)});function S0(s,e,t){const n={node:s},i={};if(e.pointStyles.length){const l=e.pointStyles[0].getText();l&&(i.LabelStyle=l);const h=e.pointStyles[0].getImage();h&&typeof h.getSrc=="function"&&(i.IconStyle=h)}if(e.lineStyles.length){const l=e.lineStyles[0].getStroke();l&&(i.LineStyle=l)}if(e.polyStyles.length){const l=e.polyStyles[0].getStroke();l&&!i.LineStyle&&(i.LineStyle=l),i.PolyStyle=e.polyStyles[0]}const r=t[t.length-1].node,o=C0[r.namespaceURI],a=At(i,o);Re(n,R0,Tt,a,t,o)}function v0(s,e){s.setAttribute("x",String(e.x)),s.setAttribute("y",String(e.y)),s.setAttribute("xunits",e.xunits),s.setAttribute("yunits",e.yunits)}var K0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function H0(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}export{P0 as $,tt as A,Rt as B,co as C,Tu as D,o_ as E,It as F,Y0 as G,X0 as H,N0 as I,Li as J,j0 as K,ht as L,M0 as M,vs as N,L0 as O,qe as P,Nr as Q,fo as R,kt as S,O0 as T,D0 as U,Xl as V,W0 as W,Xs as X,Zi as Y,Jt as Z,w0 as _,$0 as a,z0 as a0,G0 as a1,Uf as a2,kf as a3,I0 as a4,ey as a5,U0 as a6,B0 as a7,k0 as a8,V0 as a9,Z0 as aa,K0 as ab,H0 as ac,Vi as b,$s as c,Ne as d,td as e,$e as f,D as g,Ca as h,Te as i,mo as j,A0 as k,Kn as l,yn as m,lt as n,Sd as o,on as p,An as q,rn as r,si as s,ks as t,uf as u,Ze as v,Bc as w,bh as x,In as y,ze as z};
|
||
//# sourceMappingURL=openlayers-CUDtI0S3.js.map
|