UNPKG

@doegis/core

Version:

DOE GIS API

1 lines 195 kB
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[7014,5660],{25929:(e,t,s)=>{s.d(t,{M:()=>f,a:()=>m,e:()=>g,f:()=>n,i:()=>c,p:()=>d,r:()=>a,t:()=>o,w:()=>h});var r=s(70586),i=s(17452);function n(e,t){const s=t&&t.url&&t.url.path;if(e&&s&&(e=(0,i.hF)(e,s,{preserveProtocolRelative:!0}),t.portalItem&&t.readResourcePaths)){const s=(0,i.PF)(e,t.portalItem.itemUrl);null!=s&&u.test(s)&&t.readResourcePaths.push(t.portalItem.resourceFromPath(s).path)}return p(e,t&&t.portal)}function o(e,t,s=f.YES){if(null==e)return e;!(0,i.YP)(e)&&t&&t.blockedRelativeUrls&&t.blockedRelativeUrls.push(e);let r=(0,i.hF)(e);if(t){const s=t.verifyItemRelativeUrls&&t.verifyItemRelativeUrls.rootPath||t.url&&t.url.path;if(s){const n=p(s,t.portal),o=p(r,t.portal);r=(0,i.PF)(o,n,n),null!=r&&r!==o&&r!==e&&t.verifyItemRelativeUrls&&t.verifyItemRelativeUrls.writtenUrls.push(r)}}return r=g(r,t?.portal),(0,i.YP)(r)&&(r=(0,i.Fv)(r)),t?.resources&&t?.portalItem&&!(0,i.YP)(r)&&!(0,i.HK)(r)&&s===f.YES&&t.resources.toKeep.push({resource:t.portalItem.resourceFromPath(r),compress:!1}),r}function a(e,t,s){return n(e,s)}function h(e,t,s,r){const i=o(e,r);void 0!==i&&(t[s]=i)}const l=/\/items\/([^\/]+)\/resources\/(.*)/,u=/^\.\/resources\//;function c(e){return(e?.match(l)??null)?.[1]??null}function d(e){const t=e?.match(l)??null;if(null==t)return null;const s=t[2],n=s.lastIndexOf("/");if(-1===n){const{path:e,extension:t}=(0,i.fZ)(s);return{prefix:null,filename:e,extension:(0,r.Wg)(t)}}const{path:o,extension:a}=(0,i.fZ)(s.slice(n+1));return{prefix:s.slice(0,n),filename:o,extension:(0,r.Wg)(a)}}function g(e,t){return t&&!t.isPortal&&t.urlKey&&t.customBaseUrl?(0,i.Ie)(e,`${t.urlKey}.${t.customBaseUrl}`,t.portalHostname):e}function p(e,t){if(!t||t.isPortal||!t.urlKey||!t.customBaseUrl)return e;const s=`${t.urlKey}.${t.customBaseUrl}`,r=(0,i.TI)();return(0,i.D6)(r,`${r.scheme}://${s}`)?(0,i.Ie)(e,t.portalHostname,s):(0,i.Ie)(e,s,t.portalHostname)}var f,_;(_=f||(f={}))[_.YES=0]="YES",_[_.NO=1]="NO";const m=Object.freeze(Object.defineProperty({__proto__:null,get MarkKeep(){return f},ensureMainOnlineDomain:g,fromJSON:n,itemIdFromResourceUrl:c,prefixAndFilenameFromResourceUrl:d,read:a,toJSON:o,write:h},Symbol.toStringTag,{value:"Module"}))},96794:(e,t,s)=>{s.d(t,{r:()=>i});var r=s(88764);function i(e,t){if(!(this instanceof i))return new i(e,t);this._maxEntries=Math.max(4,e||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),t&&("function"==typeof t?this.toBBox=t:this._initFormat(t)),this.clear()}function n(e,t,s){if(!s)return t.indexOf(e);for(var r=0;r<t.length;r++)if(s(e,t[r]))return r;return-1}function o(e,t){a(e,0,e.children.length,t,e)}function a(e,t,s,r,i){i||(i=m(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(var n,o=t;o<s;o++)n=e.children[o],h(i,e.leaf?r(n):n);return i}function h(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function l(e,t){return e.minX-t.minX}function u(e,t){return e.minY-t.minY}function c(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function d(e){return e.maxX-e.minX+(e.maxY-e.minY)}function g(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function p(e,t){var s=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),i=Math.min(e.maxX,t.maxX),n=Math.min(e.maxY,t.maxY);return Math.max(0,i-s)*Math.max(0,n-r)}function f(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function _(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function m(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function y(e,t,s,i,n){for(var o,a=[t,s];a.length;)(s=a.pop())-(t=a.pop())<=i||(o=t+Math.ceil((s-t)/i/2)*i,(0,r.q)(e,o,t,s,n),a.push(t,o,o,s))}i.prototype={all:function(){return this._all(this.data,[])},search:function(e){var t=this.data,s=[],r=this.toBBox;if(!_(e,t))return s;for(var i,n,o,a,h=[];t;){for(i=0,n=t.children.length;i<n;i++)o=t.children[i],_(e,a=t.leaf?r(o):o)&&(t.leaf?s.push(o):f(e,a)?this._all(o,s):h.push(o));t=h.pop()}return s},collides:function(e){var t=this.data,s=this.toBBox;if(!_(e,t))return!1;for(var r,i,n,o,a=[];t;){for(r=0,i=t.children.length;r<i;r++)if(n=t.children[r],_(e,o=t.leaf?s(n):n)){if(t.leaf||f(e,o))return!0;a.push(n)}t=a.pop()}return!1},load:function(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(var t=0,s=e.length;t<s;t++)this.insert(e[t]);return this}var r=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===r.height)this._splitRoot(this.data,r);else{if(this.data.height<r.height){var i=this.data;this.data=r,r=i}this._insert(r,this.data.height-r.height-1,!0)}else this.data=r;return this},insert:function(e){return e&&this._insert(e,this.data.height-1),this},clear:function(){return this.data=m([]),this},remove:function(e,t){if(!e)return this;for(var s,r,i,o,a=this.data,h=this.toBBox(e),l=[],u=[];a||l.length;){if(a||(a=l.pop(),r=l[l.length-1],s=u.pop(),o=!0),a.leaf&&-1!==(i=n(e,a.children,t)))return a.children.splice(i,1),l.push(a),this._condense(l),this;o||a.leaf||!f(a,h)?r?(s++,a=r.children[s],o=!1):a=null:(l.push(a),u.push(s),s=0,r=a,a=a.children[0])}return this},toBBox:function(e){return e},compareMinX:l,compareMinY:u,toJSON:function(){return this.data},fromJSON:function(e){return this.data=e,this},_all:function(e,t){for(var s=[];e;)e.leaf?t.push.apply(t,e.children):s.push.apply(s,e.children),e=s.pop();return t},_build:function(e,t,s,r){var i,n=s-t+1,a=this._maxEntries;if(n<=a)return o(i=m(e.slice(t,s+1)),this.toBBox),i;r||(r=Math.ceil(Math.log(n)/Math.log(a)),a=Math.ceil(n/Math.pow(a,r-1))),(i=m([])).leaf=!1,i.height=r;var h,l,u,c,d=Math.ceil(n/a),g=d*Math.ceil(Math.sqrt(a));for(y(e,t,s,g,this.compareMinX),h=t;h<=s;h+=g)for(y(e,h,u=Math.min(h+g-1,s),d,this.compareMinY),l=h;l<=u;l+=d)c=Math.min(l+d-1,u),i.children.push(this._build(e,l,c,r-1));return o(i,this.toBBox),i},_chooseSubtree:function(e,t,s,r){for(var i,n,o,a,h,l,u,d;r.push(t),!t.leaf&&r.length-1!==s;){for(u=d=1/0,i=0,n=t.children.length;i<n;i++)h=c(o=t.children[i]),(l=g(e,o)-h)<d?(d=l,u=h<u?h:u,a=o):l===d&&h<u&&(u=h,a=o);t=a||t.children[0]}return t},_insert:function(e,t,s){var r=this.toBBox,i=s?e:r(e),n=[],o=this._chooseSubtree(i,this.data,t,n);for(o.children.push(e),h(o,i);t>=0&&n[t].children.length>this._maxEntries;)this._split(n,t),t--;this._adjustParentBBoxes(i,n,t)},_split:function(e,t){var s=e[t],r=s.children.length,i=this._minEntries;this._chooseSplitAxis(s,i,r);var n=this._chooseSplitIndex(s,i,r),a=m(s.children.splice(n,s.children.length-n));a.height=s.height,a.leaf=s.leaf,o(s,this.toBBox),o(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(s,a)},_splitRoot:function(e,t){this.data=m([e,t]),this.data.height=e.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},_chooseSplitIndex:function(e,t,s){var r,i,n,o,h,l,u,d;for(l=u=1/0,r=t;r<=s-t;r++)o=p(i=a(e,0,r,this.toBBox),n=a(e,r,s,this.toBBox)),h=c(i)+c(n),o<l?(l=o,d=r,u=h<u?h:u):o===l&&h<u&&(u=h,d=r);return d},_chooseSplitAxis:function(e,t,s){var r=e.leaf?this.compareMinX:l,i=e.leaf?this.compareMinY:u;this._allDistMargin(e,t,s,r)<this._allDistMargin(e,t,s,i)&&e.children.sort(r)},_allDistMargin:function(e,t,s,r){e.children.sort(r);var i,n,o=this.toBBox,l=a(e,0,t,o),u=a(e,s-t,s,o),c=d(l)+d(u);for(i=t;i<s-t;i++)n=e.children[i],h(l,e.leaf?o(n):n),c+=d(l);for(i=s-t-1;i>=t;i--)n=e.children[i],h(u,e.leaf?o(n):n),c+=d(u);return c},_adjustParentBBoxes:function(e,t,s){for(var r=s;r>=0;r--)h(t[r],e)},_condense:function(e){for(var t,s=e.length-1;s>=0;s--)0===e[s].children.length?s>0?(t=e[s-1].children).splice(t.indexOf(e[s]),1):this.clear():o(e[s],this.toBBox)},_initFormat:function(e){var t=["return a"," - b",";"];this.compareMinX=new Function("a","b",t.join(e[0])),this.compareMinY=new Function("a","b",t.join(e[1])),this.toBBox=new Function("a","return {minX: a"+e[0]+", minY: a"+e[1]+", maxX: a"+e[2]+", maxY: a"+e[3]+"};")}}},8557:(e,t,s)=>{s.d(t,{Z:()=>i});var r=s(70586);class i{constructor(e){this.size=0,this._start=0,this.maxSize=e,this._buffer=new Array(e)}get entries(){return this._buffer}enqueue(e){if(this.size===this.maxSize){const t=this._buffer[this._start];return this._buffer[this._start]=e,this._start=(this._start+1)%this.maxSize,t}return this._buffer[(this._start+this.size++)%this.maxSize]=e,null}dequeue(){if(0===this.size)return null;const e=this._buffer[this._start];return this._buffer[this._start]=null,this.size--,this._start=(this._start+1)%this.maxSize,e}peek(){return 0===this.size?null:this._buffer[this._start]}find(e){if(0===this.size)return null;for(const t of this._buffer)if((0,r.pC)(t)&&e(t))return t;return null}clear(e){let t=this.dequeue();for(;(0,r.pC)(t);)e&&e(t),t=this.dequeue()}}},3920:(e,t,s)=>{s.d(t,{p:()=>l,r:()=>u});var r=s(43697),i=s(15923),n=s(61247),o=s(5600),a=s(52011),h=s(72762);const l=e=>{let t=class extends e{destroy(){this.destroyed||(this._get("handles")?.destroy(),this._get("updatingHandles")?.destroy())}get handles(){return this._get("handles")||new n.Z}get updatingHandles(){return this._get("updatingHandles")||new h.t}};return(0,r._)([(0,o.Cb)({readOnly:!0})],t.prototype,"handles",null),(0,r._)([(0,o.Cb)({readOnly:!0})],t.prototype,"updatingHandles",null),t=(0,r._)([(0,a.j)("esri.core.HandleOwner")],t),t};let u=class extends(l(i.Z)){};u=(0,r._)([(0,a.j)("esri.core.HandleOwner")],u)},64830:(e,t,s)=>{s.d(t,{Z:()=>i});var r=s(70586);class i{constructor(e=(e=>e.values().next().value)){this._peeker=e,this._items=new Set}get length(){return this._items.size}clear(){this._items.clear()}last(){if(0===this._items.size)return;let e;for(e of this._items);return e}peek(){if(0!==this._items.size)return this._peeker(this._items)}push(e){this.contains(e)||this._items.add(e)}contains(e){return this._items.has(e)}pop(){if(0===this.length)return;const e=this.peek();return this._items.delete((0,r.j0)(e)),e}popLast(){if(0===this.length)return;const e=this.last();return this._items.delete((0,r.j0)(e)),e}remove(e){this._items.delete(e)}filter(e){return this._items.forEach((t=>{e(t)||this._items.delete(t)})),this}}},72762:(e,t,s)=>{s.d(t,{t:()=>c});var r=s(43697),i=s(15923),n=s(61247),o=s(70586),a=s(17445),h=s(1654),l=s(5600),u=s(52011);let c=class extends i.Z{constructor(){super(...arguments),this.updating=!1,this._handleId=0,this._handles=new n.Z,this._scheduleHandleId=0,this._pendingPromises=new Set}destroy(){this.removeAll(),this._handles.destroy()}add(e,t,s={}){return this._installWatch(e,t,s,a.YP)}addWhen(e,t,s={}){return this._installWatch(e,t,s,a.gx)}addOnCollectionChange(e,t,{initial:s=!1,final:r=!1}={}){const i=++this._handleId;return this._handles.add([(0,a.on)(e,"after-changes",this._createSyncUpdatingCallback(),a.Z_),(0,a.on)(e,"change",t,{onListenerAdd:s?e=>t({added:e.toArray(),removed:[]}):void 0,onListenerRemove:r?e=>t({added:[],removed:e.toArray()}):void 0})],i),{remove:()=>this._handles.remove(i)}}addPromise(e){if((0,o.Wi)(e))return e;const t=++this._handleId;this._handles.add({remove:()=>{this._pendingPromises.delete(e)&&(0!==this._pendingPromises.size||this._handles.has(d)||this._set("updating",!1))}},t),this._pendingPromises.add(e),this._set("updating",!0);const s=()=>this._handles.remove(t);return e.then(s,s),e}removeAll(){this._pendingPromises.clear(),this._handles.removeAll(),this._set("updating",!1)}_installWatch(e,t,s={},r){const i=++this._handleId;s.sync||this._installSyncUpdatingWatch(e,i);const n=r(e,t,s);return this._handles.add(n,i),{remove:()=>this._handles.remove(i)}}_installSyncUpdatingWatch(e,t){const s=this._createSyncUpdatingCallback(),r=(0,a.YP)(e,s,{sync:!0,equals:()=>!1});return this._handles.add(r,t),r}_createSyncUpdatingCallback(){return()=>{this._handles.remove(d),++this._scheduleHandleId;const e=this._scheduleHandleId;this._get("updating")||this._set("updating",!0),this._handles.add((0,h.Os)((()=>{e===this._scheduleHandleId&&(this._set("updating",this._pendingPromises.size>0),this._handles.remove(d))})),d)}}};(0,r._)([(0,l.Cb)({readOnly:!0})],c.prototype,"updating",void 0),c=(0,r._)([(0,u.j)("esri.core.support.WatchUpdatingTracking")],c);const d=-42},80903:(e,t,s)=>{s.d(t,{Z:()=>h});var r=s(50758),i=s(92604),n=s(95330),o=s(64830),a=s(25045);class h{constructor(){this._inUseClients=new Array,this._clients=new Array,this._clientPromises=new Array,this._ongoingJobsQueue=new o.Z}destroy(){this.close()}get closed(){return!this._clients||!this._clients.length}open(e,t){return new Promise(((s,r)=>{let i=!0;const o=e=>{(0,n.k_)(t.signal),i&&(i=!1,e())};this._clients.length=e.length,this._clientPromises.length=e.length,this._inUseClients.length=e.length;for(let i=0;i<e.length;++i){const h=e[i];(0,n.y8)(h)?this._clientPromises[i]=h.then((e=>(this._clients[i]=new a.default(e,t,(()=>this._ongoingJobsQueue.pop()??null)),o(s),this._clients[i])),(()=>(o(r),null))):(this._clients[i]=new a.default(h,t,(()=>this._ongoingJobsQueue.pop()??null)),this._clientPromises[i]=Promise.resolve(this._clients[i]),o(s))}}))}broadcast(e,t,s){const r=new Array(this._clientPromises.length);for(let i=0;i<this._clientPromises.length;++i){const n=this._clientPromises[i];r[i]=n.then((r=>r?.invoke(e,t,s)))}return r}close(){let e;for(;e=this._ongoingJobsQueue.pop();)e.deferred.reject((0,n.zE)(`Worker closing, aborting job calling '${e.methodName}'`));for(const e of this._clientPromises)e.then((e=>e?.close()));this._clients.length=0,this._clientPromises.length=0}invoke(e,t,s){let r;Array.isArray(s)?(i.Z.getLogger("esri.core.workers.Connection").warn("invoke()","The transferList parameter is deprecated, use the options object instead"),r={transferList:s}):r=s;const o=(0,n.dD)();this._ongoingJobsQueue.push({methodName:e,data:t,invokeOptions:r,deferred:o});for(let e=0;e<this._clientPromises.length;e++){const t=this._clients[e];t?t.jobAdded():this._clientPromises[e].then((e=>e?.jobAdded()))}return o.promise}on(e,t){return Promise.all(this._clientPromises).then((()=>(0,r.AL)(this._clients.map((s=>s.on(e,t))))))}openPorts(){return new Promise((e=>{const t=new Array(this._clientPromises.length);let s=t.length;for(let r=0;r<this._clientPromises.length;++r)this._clientPromises[r].then((i=>{i&&(t[r]=i.openPort()),0==--s&&e(t)}))}))}get test(){return{numClients:this._clients.length}}}},95047:(e,t,s)=>{s.r(t),s.d(t,{createConnection:()=>T});var r=s(43697),i=(s(66577),s(3172)),n=s(20102),o=s(92604),a=s(70586),h=s(95330),l=s(17452),u=(s(75215),s(67676),s(80442),s(52011)),c=s(5600),d=s(69285),g=s(32448);let p=class extends g.Z.EventedAccessor{destroy(){this.emit("destroy")}get connectionError(){return this.errorString?new n.Z("stream-connection",this.errorString):null}onFeature(e){this.emit("data-received",e)}onMessage(e){this.emit("message-received",e)}};(0,r._)([(0,c.Cb)({readOnly:!0})],p.prototype,"connectionError",null),p=(0,r._)([(0,u.j)("esri.layers.support.StreamConnection")],p);const f=p;var _,m;(m=_||(_={}))[m.CONNECTING=0]="CONNECTING",m[m.OPEN=1]="OPEN",m[m.CLOSING=2]="CLOSING",m[m.CLOSED=3]="CLOSED";let y=class extends f{constructor(e){super(),this._outstandingMessages=[],this.errorString=null;const{geometryType:t,spatialReference:s,sourceSpatialReference:r}=e;this._config=e,this._featureZScaler=(0,d.k)(t,r,s),this._open()}async _open(){await this._tryCreateWebSocket(),this.destroyed||await this._handshake()}destroy(){super.destroy(),(0,a.pC)(this._websocket)&&(this._websocket.onopen=null,this._websocket.onclose=null,this._websocket.onerror=null,this._websocket.onmessage=null,this._websocket.close()),this._websocket=null}get connectionStatus(){if((0,a.Wi)(this._websocket))return"disconnected";switch(this._websocket.readyState){case _.CONNECTING:case _.OPEN:return"connected";case _.CLOSING:case _.CLOSED:return"disconnected"}}sendMessageToSocket(e){(0,a.Wi)(this._websocket)?this._outstandingMessages.push(e):this._websocket.send(JSON.stringify(e))}sendMessageToClient(e){this._onMessage(e)}updateCustomParameters(e){this._config.customParameters=e,(0,a.pC)(this._websocket)&&this._websocket.close()}async _tryCreateWebSocket(e=this._config.source.path,t=1e3,s=0){try{if(this.destroyed)return;const t=(0,l.fl)(e,this._config.customParameters??{});this._websocket=await this._createWebSocket(t),this.notifyChange("connectionStatus")}catch(r){const i=t/1e3;return this._config.maxReconnectionAttempts&&s>=this._config.maxReconnectionAttempts?(o.Z.getLogger(this.declaredClass).error(new n.Z("websocket-connection","Exceeded maxReconnectionAttempts attempts. No further attempts will be made")),void this.destroy()):(o.Z.getLogger(this.declaredClass).error(new n.Z("websocket-connection",`Failed to connect. Attempting to reconnect in ${i}s`,r)),await(0,h.e4)(t),this._tryCreateWebSocket(e,Math.min(1.5*t,1e3*this._config.maxReconnectionInterval),s+1))}}_setWebSocketJSONParseHandler(e){e.onmessage=e=>{try{const t=JSON.parse(e.data);this._onMessage(t)}catch(e){return void o.Z.getLogger(this.declaredClass).error(new n.Z("websocket-connection","Failed to parse message, invalid JSON",{error:e}))}}}_createWebSocket(e){return new Promise(((t,s)=>{const r=new WebSocket(e);r.onopen=()=>{if(r.onopen=null,this.destroyed)return r.onclose=null,void r.close();r.onclose=e=>this._onClose(e),r.onerror=e=>this._onError(e),this._setWebSocketJSONParseHandler(r),t(r)},r.onclose=e=>{r.onopen=r.onclose=null,s(e)}}))}async _handshake(e=1e4){const t=this._websocket;if((0,a.Wi)(t))return;const s=(0,h.hh)(),r=t.onmessage,{filter:i,outFields:l,spatialReference:u}=this._config;return s.timeout(e),t.onmessage=e=>{let a=null;try{a=JSON.parse(e.data)}catch(e){}a&&"object"==typeof a||(o.Z.getLogger(this.declaredClass).error(new n.Z("websocket-connection","Protocol violation. Handshake failed - malformed message",e.data)),s.reject(),this.destroy()),a.spatialReference?.wkid!==u?.wkid&&(o.Z.getLogger(this.declaredClass).error(new n.Z("websocket-connection",`Protocol violation. Handshake failed - expected wkid of ${u.wkid}`,e.data)),s.reject(),this.destroy()),"json"!==a.format&&(o.Z.getLogger(this.declaredClass).error(new n.Z("websocket-connection","Protocol violation. Handshake failed - format is not set",e.data)),s.reject(),this.destroy()),i&&a.filter!==i&&o.Z.getLogger(this.declaredClass).error(new n.Z("websocket-connection","Tried to set filter, but server doesn't support it")),l&&a.outFields!==l&&o.Z.getLogger(this.declaredClass).error(new n.Z("websocket-connection","Tried to set outFields, but server doesn't support it")),t.onmessage=r;for(const e of this._outstandingMessages)t.send(JSON.stringify(e));this._outstandingMessages=[],s.resolve()},t.send(JSON.stringify({filter:i,outFields:l,format:"json",spatialReference:{wkid:u.wkid}})),s.promise}_onMessage(e){if(this.onMessage(e),"type"in e)switch(e.type){case"features":case"featureResult":for(const t of e.features)(0,a.pC)(this._featureZScaler)&&this._featureZScaler(t.geometry),this.onFeature(t)}}_onError(e){const t="Encountered an error over WebSocket connection";this._set("errorString",t),o.Z.getLogger(this.declaredClass).error("websocket-connection",t)}_onClose(e){this._websocket=null,this.notifyChange("connectionStatus"),1e3!==e.code&&o.Z.getLogger(this.declaredClass).error("websocket-connection",`WebSocket closed unexpectedly with error code ${e.code}`),this.destroyed||this._open()}};(0,r._)([(0,c.Cb)()],y.prototype,"connectionStatus",null),(0,r._)([(0,c.Cb)()],y.prototype,"errorString",void 0),y=(0,r._)([(0,u.j)("esri.layers.graphics.sources.connections.WebSocketConnection")],y);var I=s(34599),b=s(14165),v=s(33955),x=s(82971);const w={maxQueryDepth:5,maxRecordCountFactor:3};let S=class extends y{constructor(e){super({...w,...e}),this._buddyServicesQuery=null,this._relatedFeatures=null}async _open(){const e=await this._fetchServiceDefinition(this._config.source);e.timeInfo.trackIdField||o.Z.getLogger(this.declaredClass).warn("GeoEvent service was configured without a TrackIdField. This may result in certain functionality being disabled. The purgeOptions.maxObservations property will have no effect.");const t=this._fetchWebSocketUrl(e.streamUrls,this._config.spatialReference);this._buddyServicesQuery||(this._buddyServicesQuery=this._queryBuddyServices()),await this._buddyServicesQuery,await this._tryCreateWebSocket(t);const{filter:s,outFields:r}=this._config;this.destroyed||this._setFilter(s,r)}_onMessage(e){if("attributes"in e){let t;try{t=this._enrich(e),(0,a.pC)(this._featureZScaler)&&this._featureZScaler(t.geometry)}catch(e){return void o.Z.getLogger(this.declaredClass).error(new n.Z("geoevent-connection","Failed to parse message",e))}this.onFeature(t)}else this.onMessage(e)}async _fetchServiceDefinition(e){const t={f:"json",...this._config.customParameters},s=(0,i.default)(e.path,{query:t,responseType:"json"}),r=(await s).data;return this._serviceDefinition=r,r}_fetchWebSocketUrl(e,t){const s=e[0],{urls:r,token:i}=s,n=this._inferWebSocketBaseUrl(r);return(0,l.fl)(`${n}/subscribe`,{outSR:""+t.wkid,token:i})}_inferWebSocketBaseUrl(e){if(1===e.length)return e[0];for(const t of e)if(t.includes("wss"))return t;return o.Z.getLogger(this.declaredClass).error(new n.Z("geoevent-connection","Unable to infer WebSocket url",e)),null}async _setFilter(e,t){const s=this._websocket;if((0,a.Wi)(s)||(0,a.Wi)(e)&&(0,a.Wi)(t))return;const r=JSON.stringify({filter:this._serializeFilter(e,t)});let i=!1;const l=(0,h.hh)();return s.onmessage=e=>{const t=JSON.parse(e.data);t.filter&&(t.error&&(o.Z.getLogger(this.declaredClass).error(new n.Z("geoevent-connection","Failed to set service filter",t.error)),this._set("errorString",`Could not set service filter - ${t.error}`),l.reject(t.error)),this._setWebSocketJSONParseHandler(s),i=!0,l.resolve())},s.send(r),setTimeout((()=>{i||(this.destroyed||this._websocket!==s||o.Z.getLogger(this.declaredClass).error(new n.Z("geoevent-connection","Server timed out when setting filter")),l.reject())}),1e4),l.promise}_serializeFilter(e,t){const s={};if((0,a.Wi)(e)&&(0,a.Wi)(t))return s;if((0,a.pC)(e)&&e.geometry)try{const t=(0,v.im)(e.geometry);if("extent"!==t.type)throw new n.Z(`Expected extent but found type ${t.type}`);s.geometry=JSON.stringify(t.shiftCentralMeridian())}catch(e){o.Z.getLogger(this.declaredClass).error(new n.Z("geoevent-connection","Encountered an error when setting connection geometryDefinition",e))}return(0,a.pC)(e)&&e.where&&"1 = 1"!==e.where&&"1=1"!==e.where&&(s.where=e.where),(0,a.pC)(t)&&(s.outFields=t.join(",")),s}_enrich(e){if(!this._relatedFeatures)return e;const t=this._serviceDefinition.relatedFeatures.joinField,s=e.attributes[t],r=this._relatedFeatures.get(s);if(!r)return o.Z.getLogger(this.declaredClass).warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",e),e;const{attributes:i,geometry:a}=r;for(const t in i)e.attributes[t]=i[t];return a&&(e.geometry=a),e.geometry||e.centroid||o.Z.getLogger(this.declaredClass).error(new n.Z("geoevent-connection","Found malformed feature - no geometry found",e)),e}async _queryBuddyServices(){try{const{relatedFeatures:e,keepLatestArchive:t}=this._serviceDefinition,s=this._queryRelatedFeatures(e),r=this._queryArchive(t);await s;const i=await r;if(!i)return;for(const e of i.features)this.onFeature(this._enrich(e))}catch(e){o.Z.getLogger(this.declaredClass).error(new n.Z("geoevent-connection","Encountered an error when querying buddy services",{error:e}))}}async _queryRelatedFeatures(e){if(!e)return;const t=await this._queryBuddy(e.featuresUrl);this._addRelatedFeatures(t)}async _queryArchive(e){if(e)return this._queryBuddy(e.featuresUrl)}async _queryBuddy(e){const t=new((await Promise.all([s.e(2710),s.e(1612),s.e(4729),s.e(9790),s.e(8244),s.e(1423),s.e(911),s.e(5546),s.e(9942),s.e(9238),s.e(5235),s.e(5587),s.e(2156)]).then(s.bind(s,19238))).default)({url:e}),{capabilities:r}=await t.load(),i=r.query.supportsMaxRecordCountFactor,n=r.query.supportsPagination,o=r.query.supportsCentroid,h=this._config.maxRecordCountFactor,l=t.capabilities.query.maxRecordCount,u=i?l*h:l,c=new b.Z;if(c.outFields=(0,a.Pt)(this._config.outFields,["*"]),c.where=(0,a.Pt)((0,a.U2)(this._config.filter,"where"),"1=1"),c.returnGeometry=!0,c.returnExceededLimitFeatures=!0,c.outSpatialReference=x.Z.fromJSON(this._config.spatialReference),o&&(c.returnCentroid=!0),i&&(c.maxRecordCountFactor=h),n)return c.num=u,t.destroy(),this._queryPages(e,c);const d=await(0,I.JT)(e,c,this._config.sourceSpatialReference);return t.destroy(),d.data}async _queryPages(e,t,s=[],r=0){t.start=(0,a.pC)(t.num)?r*t.num:null;const{data:i}=await(0,I.JT)(e,t,this._config.sourceSpatialReference);return i.exceededTransferLimit&&r<(this._config.maxQueryDepth??0)?(i.features.forEach((e=>s.push(e))),this._queryPages(e,t,s,r+1)):(s.forEach((e=>i.features.push(e))),i)}_addRelatedFeatures(e){const t=new Map,s=e.features,r=this._serviceDefinition.relatedFeatures.joinField;for(const e of s){const s=e.attributes[r];t.set(s,e)}this._relatedFeatures=t}};S=(0,r._)([(0,u.j)("esri.layers.graphics.sources.connections.GeoEventConnection")],S);const C=S;let F=class extends f{constructor(e){super(),this.connectionStatus="connected",this.errorString=null;const{geometryType:t,spatialReference:s,sourceSpatialReference:r}=e;this._featureZScaler=(0,d.k)(t,r,s)}updateCustomParameters(e){}sendMessageToSocket(e){}sendMessageToClient(e){if("type"in e)switch(e.type){case"features":case"featureResult":for(const t of e.features)(0,a.pC)(this._featureZScaler)&&this._featureZScaler(t.geometry),this.onFeature(t)}this.onMessage(e)}};function T(e,t,s,r,i,n,o,a){const h={source:e,sourceSpatialReference:t,spatialReference:s,geometryType:r,filter:i,maxReconnectionAttempts:n,maxReconnectionInterval:o,customParameters:a};return e?e.path.startsWith("wss://")||e.path.startsWith("ws://")?new y(h):new C(h):new F(h)}(0,r._)([(0,c.Cb)()],F.prototype,"connectionStatus",void 0),(0,r._)([(0,c.Cb)()],F.prototype,"errorString",void 0),F=(0,r._)([(0,u.j)("esri.layers.support.ClientSideConnection")],F)},92722:(e,t,s)=>{s.d(t,{O3:()=>v,lG:()=>w,my:()=>x,q9:()=>h});var r=s(20102),i=s(70272),n=s(5428),o=s(35671);const a={LineString:"esriGeometryPolyline",MultiLineString:"esriGeometryPolyline",MultiPoint:"esriGeometryMultipoint",Point:"esriGeometryPoint",Polygon:"esriGeometryPolygon",MultiPolygon:"esriGeometryPolygon"};function h(e){return a[e]}function*l(e){switch(e.type){case"Feature":yield e;break;case"FeatureCollection":for(const t of e.features)t&&(yield t)}}function*u(e){if(e)switch(e.type){case"Point":yield e.coordinates;break;case"LineString":case"MultiPoint":yield*e.coordinates;break;case"MultiLineString":case"Polygon":for(const t of e.coordinates)yield*t;break;case"MultiPolygon":for(const t of e.coordinates)for(const e of t)yield*e}}function c(e){for(const t of e)if(t.length>2)return!0;return!1}function d(e){let t=0;for(let s=0;s<e.length;s++){const r=e[s],i=e[(s+1)%e.length];t+=r[0]*i[1]-i[0]*r[1]}return t<=0}function g(e){const t=e[0],s=e[e.length-1];return t[0]===s[0]&&t[1]===s[1]&&t[2]===s[2]||e.push(t),e}function p(e,t,s){switch(t.type){case"LineString":case"MultiPoint":return function(e,t,s){return m(e,t.coordinates,s),e}(e,t,s);case"MultiLineString":return function(e,t,s){for(const r of t.coordinates)m(e,r,s);return e}(e,t,s);case"MultiPolygon":return function(e,t,s){for(const r of t.coordinates){f(e,r[0],s);for(let t=1;t<r.length;t++)_(e,r[t],s)}return e}(e,t,s);case"Point":return function(e,t,s){return I(e,t.coordinates,s),e}(e,t,s);case"Polygon":return function(e,t,s){const r=t.coordinates;f(e,r[0],s);for(let t=1;t<r.length;t++)_(e,r[t],s);return e}(e,t,s)}}function f(e,t,s){const r=g(t);!function(e){return!d(e)}(r)?m(e,r,s):y(e,r,s)}function _(e,t,s){const r=g(t);!function(e){return d(e)}(r)?m(e,r,s):y(e,r,s)}function m(e,t,s){for(const r of t)I(e,r,s);e.lengths.push(t.length)}function y(e,t,s){for(let r=t.length-1;r>=0;r--)I(e,t[r],s);e.lengths.push(t.length)}function I(e,t,s){const[r,i,n]=t;e.coords.push(r,i),s.hasZ&&e.coords.push(n||0)}function b(e){switch(typeof e){case"string":return"esriFieldTypeString";case"number":return"esriFieldTypeDouble";default:return"unknown"}}function v(e){if(!e)throw new r.Z("geojson-layer:empty","GeoJSON data is empty");if("Feature"!==e.type&&"FeatureCollection"!==e.type)throw new r.Z("geojson-layer:unsupported-geojson-object","missing or not supported GeoJSON object type",{data:e});const{crs:t}=e;if(!t)return;const s="string"==typeof t?t:"name"===t.type?t.properties.name:"EPSG"===t.type?t.properties.code:null,i=new RegExp(".*(CRS84H?|4326)$","i");if(!s||!i.test(s))throw new r.Z("geojson-layer:unsupported-crs","unsupported GeoJSON 'crs' member",{crs:t})}function x(e,t={}){const s=[],r=new Set,i=new Set;let n,a=!1,d=null,g=!1,{geometryType:p=null}=t,f=!1;for(const t of l(e)){const{geometry:e,properties:l,id:_}=t;if((!e||(p||(p=h(e.type)),h(e.type)===p))&&(a||(a=c(u(e))),g||(g=null!=_,g&&(n=typeof _,l&&(d=Object.keys(l).filter((e=>l[e]===_))))),l&&d&&g&&null!=_&&(d.length>1?d=d.filter((e=>l[e]===_)):1===d.length&&(d=l[d[0]]===_?d:[])),!f&&l)){let e=!0;for(const t in l){if(r.has(t))continue;const n=l[t];if(null==n){e=!1,i.add(t);continue}const a=b(n);if("unknown"===a){i.add(t);continue}i.delete(t),r.add(t);const h=(0,o.q6)(t);h&&s.push({name:h,alias:t,type:a})}f=e}}const _=(0,o.q6)(1===d?.length&&d[0]||null)??void 0;if(_)for(const e of s)if(e.name===_&&(0,o.H7)(e)){e.type="esriFieldTypeOID";break}return{fields:s,geometryType:p,hasZ:a,objectIdFieldName:_,objectIdFieldType:n,unknownFields:Array.from(i)}}function w(e,t){return Array.from(function*(e,t={}){const{geometryType:s,objectIdField:r}=t;for(const o of e){const{geometry:e,properties:a,id:l}=o;if(e&&h(e.type)!==s)continue;const u=a||{};let c;r&&(c=u[r],null==l||c||(u[r]=c=l));const d=new i.u_(e?p(new n.Z,e,t):null,u,null,c??void 0);yield d}}(l(e),t))}},25278:(e,t,s)=>{s.d(t,{Dm:()=>u,Hq:()=>c,MS:()=>d,bU:()=>a});var r=s(80442),i=s(22974),n=s(61159),o=s(58333);function a(e){return{renderer:{type:"simple",symbol:"esriGeometryPoint"===e||"esriGeometryMultipoint"===e?o.I4:"esriGeometryPolyline"===e?o.ET:o.lF}}}const h=/^[_$a-zA-Z][_$a-zA-Z0-9]*$/;let l=1;function u(e,t){if((0,r.Z)("esri-csp-restrictions"))return()=>({[t]:null,...e});try{let s=`this.${t} = null;`;for(const t in e)s+=`this${h.test(t)?`.${t}`:`["${t}"]`} = ${JSON.stringify(e[t])};`;const r=new Function(`\n return class AttributesClass$${l++} {\n constructor() {\n ${s};\n }\n }\n `)();return()=>new r}catch(s){return()=>({[t]:null,...e})}}function c(e={}){return[{name:"New Feature",description:"",prototype:{attributes:(0,i.d9)(e)}}]}function d(e,t){return{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,supportsAttachment:!1,supportsM:!1,supportsZ:e},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:t,supportsDelete:t,supportsEditing:t,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:t,supportsExceedsLimitStatistics:!0},query:n.g,queryRelated:{supportsCount:!0,supportsOrderBy:!0,supportsPagination:!0,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsGeometryUpdate:t,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateWithoutM:!1,supportsUploadWithItemId:!1,supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1}}}},16467:(e,t,s)=>{s.d(t,{$9:()=>y,G4:()=>v,Lu:()=>m,WW:()=>F,d:()=>S,eS:()=>w,gp:()=>x,j:()=>b,w9:()=>I,yN:()=>C}),s(66577);var r=s(3172),i=s(20102),n=s(92604),o=s(70586),a=s(8744),h=s(40488),l=s(98732),u=s(44876),c=s(92722),d=s(25278),g=s(99514),p=s(86719),f=s(82971);const _=n.Z.getLogger("esri.layers.graphics.sources.ogcfeature"),m="http://www.opengis.net/def/crs/",y=`${m}OGC/1.3/CRS84`;async function I(e,t,s={},n=5){const{links:a}=e,h=E(a,"items","application/geo+json")||E(a,"http://www.opengis.net/def/rel/ogc/1.0/items","application/geo+json");if((0,o.Wi)(h))throw new i.Z("ogc-feature-layer:missing-items-page","Missing items url");const{data:l}=await(0,r.default)(h.href,{signal:s.signal,query:{limit:n,...s.customParameters,token:s.apiKey},headers:{accept:"application/geo+json"}});await(0,c.O3)(l);const u=(0,c.my)(l,{geometryType:t.geometryType}),f=t.fields||u.fields||[],m=null!=t.hasZ?t.hasZ:u.hasZ,y=u.geometryType,I=t.objectIdField||u.objectIdFieldName||"OBJECTID";let b=t.timeInfo;const v=f.find((({name:e})=>e===I));if(v)v.editable=!1,v.nullable=!1;else{if(!u.objectIdFieldType)throw new i.Z("ogc-feature-layer:missing-feature-id","Collection geojson require a feature id as a unique identifier");f.unshift({name:I,alias:I,type:"number"===u.objectIdFieldType?"esriFieldTypeOID":"esriFieldTypeString",editable:!1,nullable:!1})}if(I!==u.objectIdFieldName){const e=f.find((({name:e})=>e===u.objectIdFieldName));e&&(e.type="esriFieldTypeInteger")}f===u.fields&&u.unknownFields.length>0&&_.warn({name:"ogc-feature-layer:unknown-field-types",message:"Some fields types couldn't be inferred from the features and were dropped",details:{unknownFields:u.unknownFields}});for(const e of f){if(null==e.name&&(e.name=e.alias),null==e.alias&&(e.alias=e.name),"esriFieldTypeOID"!==e.type&&"esriFieldTypeGlobalID"!==e.type&&(e.editable=null==e.editable||!!e.editable,e.nullable=null==e.nullable||!!e.nullable),!e.name)throw new i.Z("ogc-feature-layer:invalid-field-name","field name is missing",{field:e});if(!p.v.jsonValues.includes(e.type))throw new i.Z("ogc-feature-layer:invalid-field-type",`invalid type for field "${e.name}"`,{field:e})}if(b){const e=new g.Z(f);if(b.startTimeField){const t=e.get(b.startTimeField);t?(b.startTimeField=t.name,t.type="esriFieldTypeDate"):b.startTimeField=null}if(b.endTimeField){const t=e.get(b.endTimeField);t?(b.endTimeField=t.name,t.type="esriFieldTypeDate"):b.endTimeField=null}if(b.trackIdField){const t=e.get(b.trackIdField);t?b.trackIdField=t.name:(b.trackIdField=null,_.warn({name:"ogc-feature-layer:invalid-timeInfo-trackIdField",message:"trackIdField is missing",details:{timeInfo:b}}))}b.startTimeField||b.endTimeField||(_.warn({name:"ogc-feature-layer:invalid-timeInfo",message:"startTimeField and endTimeField are missing",details:{timeInfo:b}}),b=null)}return{drawingInfo:y?(0,d.bU)(y):null,extent:k(e),geometryType:y,fields:f,hasZ:!!m,objectIdField:I,timeInfo:b}}async function b(e,t={}){const{links:s}=e,n=E(s,"data","application/json")||E(s,"http://www.opengis.net/def/rel/ogc/1.0/data","application/json");if((0,o.Wi)(n))throw new i.Z("ogc-feature-layer:missing-collections-page","Missing collections url");const{apiKey:a,customParameters:h,signal:l}=t,{data:u}=await(0,r.default)(n.href,{signal:l,headers:{accept:"application/json"},query:{...h,token:a}});return u}async function v(e,t={}){const{links:s}=e,n=E(s,"conformance","application/json")||E(s,"http://www.opengis.net/def/rel/ogc/1.0/conformance","application/json");if((0,o.Wi)(n))throw new i.Z("ogc-feature-layer:missing-conformance-page","Missing conformance url");const{apiKey:a,customParameters:h,signal:l}=t,{data:u}=await(0,r.default)(n.href,{signal:l,headers:{accept:"application/json"},query:{...h,token:a}});return u}async function x(e,t={}){const{apiKey:s,customParameters:i,signal:n}=t,{data:o}=await(0,r.default)(e,{signal:n,headers:{accept:"application/json"},query:{...i,token:s}});return o}async function w(e,t={}){const s="application/vnd.oai.openapi+json;version=3.0",i=E(e.links,"service-desc",s);if((0,o.Wi)(i))return _.warn("ogc-feature-layer:missing-openapi-page","The OGC API-Features server does not have an OpenAPI page."),null;const{apiKey:n,customParameters:a,signal:h}=t,{data:l}=await(0,r.default)(i.href,{signal:h,headers:{accept:s},query:{...a,token:n}});return l}function S(e){const t=/^http:\/\/www\.opengis.net\/def\/crs\/(?<authority>.*)\/(?<version>.*)\/(?<code>.*)$/i.exec(e)?.groups;if(!t)return null;const{authority:s,code:r}=t;switch(s.toLowerCase()){case"ogc":switch(r.toLowerCase()){case"crs27":return f.Z.GCS_NAD_1927.wkid;case"crs83":return 4269;case"crs84":case"crs84h":return f.Z.WGS84.wkid;default:return null}case"esri":case"epsg":{const e=Number.parseInt(r,10);return Number.isNaN(e)?null:e}default:return null}}async function C(e,t,s){const r=await F(e,t,s);return(0,l.cn)(r)}async function F(e,t,s){const{collection:n,layerDefinition:d,maxRecordCount:g,queryParameters:{apiKey:p,customParameters:_},spatialReference:m,supportedCrs:y}=e,{links:I}=n,b=E(I,"items","application/geo+json")||E(I,"http://www.opengis.net/def/rel/ogc/1.0/items","application/geo+json");if((0,o.Wi)(b))throw new i.Z("ogc-feature-layer:missing-items-page","Missing items url");const{geometry:v,num:x,start:w,timeExtent:S,where:C}=t;if(t.objectIds)throw new i.Z("ogc-feature-layer:query-by-objectids-not-supported","Queries with objectids are not supported");const F=f.Z.fromJSON(m),M=(0,o.Pt)(t.outSpatialReference,F),k=M.isWGS84?null:T(M,y),R=A(v,y),L=function(e){if((0,o.Wi)(e))return null;const{start:t,end:s}=e;return`${(0,o.pC)(t)?t.toISOString():".."}/${(0,o.pC)(s)?s.toISOString():".."}`}(S),O=(Z=C,(0,o.Wi)(Z)||!Z||"1=1"===Z?null:Z),P=x??(null!=w&&void 0!==w?10:g),{data:U}=await(0,r.default)(b.href,{...s,query:{..._,...R,crs:k,datetime:L,query:O,limit:P,startindex:w,token:p},headers:{accept:"application/geo+json"}});var Z;let B=!1;U.links&&(B=!!U.links.find((e=>"next"===e.rel))),!B&&Number.isInteger(U.numberMatched)&&Number.isInteger(U.numberReturned)&&(B=U.numberReturned<U.numberMatched);const{fields:N,geometryType:D,hasZ:z,objectIdField:q}=d,j=(0,c.lG)(U,{geometryType:D,hasZ:z,objectIdField:q});if(!k&&M.isWebMercator)for(const e of j)if((0,o.pC)(e.geometry)&&null!=D){const t=(0,l.di)(e.geometry,D,z,!1);t.spatialReference=f.Z.WGS84,e.geometry=(0,l.GH)((0,h.iV)(t,M))}for(const e of j)e.objectId=e.attributes[q];const G=k||!k&&M.isWebMercator?M.toJSON():a.Zn,W=new u.Z;return W.exceededTransferLimit=B,W.features=j,W.fields=N,W.geometryType=D,W.hasZ=z,W.objectIdFieldName=q,W.spatialReference=G,W}function T(e,t){const{isWebMercator:s,wkid:r}=e;if(!r)return null;const i=s?t[3857]??t[102100]??t[102113]??t[900913]:t[e.wkid];return i?`${m}${i}`:null}function M(e){if((0,o.Wi)(e))return"";const{xmin:t,ymin:s,xmax:r,ymax:i}=e;return`${t},${s},${r},${i}`}function A(e,t){if(!function(e){return(0,o.pC)(e)&&"extent"===e.type}(e))return null;const{spatialReference:s}=e;if(!s||s.isWGS84)return{bbox:M(e)};const r=T(s,t);return(0,o.pC)(r)?{bbox:M(e),"bbox-crs":r}:s.isWebMercator?{bbox:M((0,h.iV)(e,f.Z.WGS84))}:null}function k(e){const t=e.extent?.spatial;if(!t)return null;const s=t.bbox[0],r=4===s.length,i=s[0],n=s[1],o=r?void 0:s[2];return{xmin:i,ymin:n,xmax:r?s[2]:s[3],ymax:r?s[3]:s[4],zmin:o,zmax:r?void 0:s[5],spatialReference:f.Z.WGS84.toJSON()}}function E(e,t,s){return e.find((e=>e.rel===t&&e.type===s))||e.find((e=>e.rel===t&&!e.type))}},39450:(e,t,s)=>{s.d(t,{Z:()=>u});var r,i=s(43697),n=s(96674),o=s(5600),a=s(75215),h=(s(67676),s(52011));let l=r=class extends n.wq{constructor(e){super(e),this.cols=null,this.level=0,this.levelValue=null,this.origin=null,this.resolution=0,this.rows=null,this.scale=0}clone(){return new r({cols:this.cols,level:this.level,levelValue:this.levelValue,resolution:this.resolution,rows:this.rows,scale:this.scale})}};(0,i._)([(0,o.Cb)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],l.prototype,"cols",void 0),(0,i._)([(0,o.Cb)({type:a.z8,json:{write:!0}})],l.prototype,"level",void 0),(0,i._)([(0,o.Cb)({type:String,json:{write:!0}})],l.prototype,"levelValue",void 0),(0,i._)([(0,o.Cb)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],l.prototype,"origin",void 0),(0,i._)([(0,o.Cb)({type:Number,json:{write:!0}})],l.prototype,"resolution",void 0),(0,i._)([(0,o.Cb)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],l.prototype,"rows",void 0),(0,i._)([(0,o.Cb)({type:Number,json:{write:!0}})],l.prototype,"scale",void 0),l=r=(0,i._)([(0,h.j)("esri.layers.support.LOD")],l);const u=l},11145:(e,t,s)=>{s.d(t,{Z:()=>C});var r,i=s(43697),n=s(35454),o=s(96674),a=s(70586),h=s(67900),l=s(5600),u=s(75215),c=(s(67676),s(71715)),d=s(52011),g=s(30556),p=s(94139),f=s(82971),_=s(24470),m=s(8744),y=s(40488),I=s(39450),b=s(43077);const v=new n.X({PNG:"png",PNG8:"png8",PNG24:"png24",PNG32:"png32",JPEG:"jpg",JPG:"jpg",DIB:"dib",TIFF:"tiff",EMF:"emf",PS:"ps",PDF:"pdf",GIF:"gif",SVG:"svg",SVGZ:"svgz",Mixed:"mixed",MIXED:"mixed",LERC:"lerc",LERC2D:"lerc2d",RAW:"raw",pbf:"pbf"});let x=r=class extends o.wq{static create(e={}){const{resolutionFactor:t=1,scales:s,size:i=256,spatialReference:n=f.Z.WebMercator,numLODs:o=24}=e;if(!(0,m.JY)(n)){const e=[];if(s)for(let t=0;t<s.length;t++){const r=s[t];e.push(new I.Z({level:t,scale:r,resolution:r}))}else{let t=5e-4;for(let s=o-1;s>=0;s--)e.unshift(new I.Z({level:s,scale:t,resolution:t})),t*=2}return new r({dpi:96,lods:e,origin:new p.Z(0,0,n),size:[i,i],spatialReference:n})}const a=(0,m.C5)(n),l=e.origin?new p.Z({x:e.origin.x,y:e.origin.y,spatialReference:n}):new p.Z(a?{x:a.origin[0],y:a.origin[1],spatialReference:n}:{x:0,y:0,spatialReference:n}),u=1/(39.37*(0,h.c9)(n)*96),c=[];if(s)for(let e=0;e<s.length;e++){const t=s[e],r=t*u;c.push(new I.Z({level:e,scale:t,resolution:r}))}else{let e=(0,m.sT)(n)?512/i*591657527.5917094:256/i*591657527.591555;const s=Math.ceil(o/t);c.push(new I.Z({level:0,scale:e,resolution:e*u}));for(let r=1;r<s;r++){const s=e/2**t,i=s*u;c.push(new I.Z({level:r,scale:s,resolution:i})),e=s}}return new r({dpi:96,lods:c,origin:l,size:[i,i],spatialReference:n})}constructor(e){super(e),this.dpi=96,this.format=null,this.origin=null,this.minScale=0,this.maxScale=0,this.size=null,this.spatialReference=null}get isWrappable(){const{spatialReference:e,origin:t}=this;if(e&&t){const s=(0,m.C5)(e);return e.isWrappable&&!!s&&Math.abs(s.origin[0]-t.x)<=s.dx}return!1}readOrigin(e,t){return p.Z.fromJSON({spatialReference:t.spatialReference,...e})}set lods(e){let t=0,s=0;const r=[],i=this._levelToLOD={};e&&(t=-1/0,s=1/0,e.forEach((e=>{r.push(e.scale),t=e.scale>t?e.scale:t,s=e.scale<s?e.scale:s,i[e.level]=e}))),this._set("scales",r),this._set("minScale",t),this._set("maxScale",s),this._set("lods",e),this._initializeUpsampleLevels()}readSize(e,t){return[t.cols,t.rows]}writeSize(e,t){t.cols=e[0],t.rows=e[1]}zoomToScale(e){const t=this.scales;if(e<=0)return t[0];if(e>=t.length-1)return t[t.length-1];const s=Math.floor(e),r=s+1;return t[s]/(t[s]/t[r])**(e-s)}scaleToZoom(e){const t=this.scales,s=t.length-1;let r=0;for(;r<s;r++){const s=t[r],i=t[r+1];if(s<=e)return r;if(i===e)return r+1;if(s>e&&i<e)return r+Math.log(s/e)/Math.log(s/i)}return r}snapScale(e,t=.95){const s=this.scaleToZoom(e);return s%Math.floor(s)>=t?this.zoomToScale(Math.ceil(s)):this.zoomToScale(Math.floor(s))}tileAt(e,t,s,r){const i=this.lodAt(e);if(!i)return null;let n,o;if("number"==typeof t)n=t,o=s;else if((0,m.fS)(t.spatialReference,this.spatialReference))n=t.x,o=t.y,r=s;else{const e=(0,y.iV)(t,this.spatialReference);if((0,a.Wi)(e))return null;n=e.x,o=e.y,r=s}const h=i.resolution*this.size[0],l=i.resolution*this.size[1];return r||(r=new b.f(null,0,0,0,(0,_.Ue)())),r.level=e,r.row=Math.floor((this.origin.y-o)/l+.001),r.col=Math.floor((n-this.origin.x)/h+.001),this.updateTileInfo(r),r}updateTileInfo(e,t=r.ExtrapolateOptions.NONE){let s=this.lodAt(e.level);if(!s&&t===r.ExtrapolateOptions.POWER_OF_TWO){const t=this.lods[this.lods.length-1];t.level<e.level&&(s=t)}if(!s)return;const i=e.level-s.level,n=s.resolution*this.size[0]/2**i,o=s.resolution*this.size[1]/2**i;e.id=`${e.level}/${e.row}/${e.col}`,e.extent||(e.extent=(0,_.Ue)()),e.extent[0]=this.origin.x+e.col*n,e.extent[1]=this.origin.y-(e.row+1)*o,e.extent[2]=e.extent[0]+n,e.extent[3]=e.extent[1]+o}upsampleTile(e){const t=this._upsampleLevels[e.level];return!(!t||-1===t.parentLevel||(e.level=t.parentLevel,e.row=Math.floor(e.row/t.factor+.001),e.col=Math.floor(e.col/t.factor+.001),this.updateTileInfo(e),0))}getTileBounds(e,t){const s=this.lodAt(t.level);if(null==s)return null;const{resolution:r}=s,i=r*this.size[0],n=r*this.size[1];return e[0]=this.origin.x+t.col*i,e[1]=this.origin.y-(t.row+1)*n,e[2]=e[0]+i,e[3]=e[1]+n,e}lodAt(e){return this._levelToLOD?.[e]??null}clone(){return r.fromJSON(this.write({}))}getOrCreateCompatible(e,t){if(256===this.size[0]&&256===this.size[1])return 256===e?this:null;const s=[],i=this.lods.length;for(let e=0;e<i;e++){const r=this.lods[e],i=r.resolution*t;s.push(new I.Z({level:r.level,scale:r.scale,resolution:i}))}return new r({size:[e,e],dpi:this.dpi,format:this.format,compressionQuality:this.compressionQuality,origin:this.origin,spatialReference:this.spatialReference,lods:s})}_initializeUpsampleLevels(){const e=this.lods;this._upsampleLevels=[];let t=null;for(let s=0;s<e.length;s++){const r=e[s];this._upsampleLevels[r.level]={parentLevel:t?t.level:-1,factor:t?t.resolution/r.resolution:0},t=r}}};var w,S;(0,i._)([(0,l.Cb)({type:Number,json:{write:!0}})],x.prototype,"compressionQuality",void 0),(0,i._)([(0,l.Cb)({type:Number,json:{write:!0}})],x.prototype,"dpi",void 0),(0,i._)([(0,l.Cb)({type:String,json:{read:v.read,write:v.write,origins:{"web-scene":{read:!1,write:!1}}}})],x.prototype,"format",void 0),(0,i._)([(0,l.Cb)({readOnly:!0})],x.prototype,"isWrappable",null),(0,i._)([(0,l.Cb)({type:p.Z,json:{write:!0}})],x.prototype,"origin",void 0),(0,i._)([(0,c.r)("origin")],x.prototype,"readOrigin",null),(0,i._)([(0,l.Cb)({type:[I.Z],value:null,json:{write:!0}})],x.prototype,"lods",null),(0,i._)([(0,l.Cb)({readOnly:!0})],x.prototype,"minScale",void 0),(0,i._)([(0,l.Cb)({readOnly:!0})],x.prototype,"maxScale",void 0),(0,i._)([(0,l.Cb)({readOnly:!0})],x.prototype,"scales",void 0),(0,i._)([(0,l.Cb)({cast:e=>Array.isArray(e)?e:"number"==typeof e?[e,e]:[256,256]})],x.prototype,"size",void 0),(0,i._)([(0,c.r)("size",["rows","cols"])],x.prototype,"readSize",null),(0,i._)([(0,g.c)("size",{cols:{type:u.z8},rows:{type:u.z8}})],x.prototype,"writeSize",null),(0,i._)([(0,l.Cb)({type:f.Z,json:{write:!0}})],x.prototype,"spatialReference",void 0),x=r=(0,i._)([(0,d.j)("esri.layers.support.TileInfo")],x),w=x||(x={}),(S=w.ExtrapolateOptions||(w.ExtrapolateOptions={}))[S.NONE=0]="NONE",S[S.POWER_OF_TWO=1]="POWER_OF_TWO";const C=x},43077:(e,t,s)=>{s.d(t,{f:()=>r});class r{constructor(e,t,s,r,i){this.id=e,this.level=t,this.row=s,this.col=r,this.extent=i}}},66677:(e,t,s)=>{s.d(t,{B5:()=>c,DR:()=>g,G:()=>b,M8:()=>_,Nm:()=>m,Qc:()=>d,XG:()=>y,a7:()=>f,ld:()=>p,wH:()=>I});var r=s(70586),i=s(17452),n=s(25929);const o={mapserver:"MapServer",imageserver:"ImageServer",featureserver:"FeatureServer",sceneserver:"SceneServer",streamserver:"StreamServer",vectortileserver:"VectorTileServer"},a=Object.values(o),h=new RegExp(`^((?:https?:)?\\/\\/\\S+?\\/rest\\/services\\/(.+?)\\/(${a.join("|")}))(?:\\/(?:layers\\/)?(\\d+))?`,"i"),l=new RegExp(`^((?:https?:)?\\/\\/\\S+?\\/([^\\/\\n]+)\\/(${a.join("|")}))(?:\\/(?:layers\\/)?(\\d+))?`,"i"),u=/(.*?)\/(?:layers\/)?(\d+)\/?$/i;function c(e){return!!h.test(e)}function d(e){if((0,r.Wi)(e))return null;const t=(0,i.mN)(e),s=t.path.match(h)||t.path.match(l);if(!s)return null;const[,n,a,u,c]=s,d=a.indexOf("/");return{title:p(-1!==d?a.slice(d+1):a),serverType:o[u.toLowerCase()],sublayer:null!=c&&""!==c?parseInt(c,10):null,url:{path:n}}}function g(e){const t=(0,i.mN)(e).path.match(u);return t?{serviceUrl:t[1],sublayerId:Number(t[2])}:null}function p(e){return(e=e.replace(/\s*[/_]+\s*/g," "))[0].toUpperCase()+e.slice(1)}function f(e,t){const s=[];if(e){const t=d(e);(0,r.pC)(t)&&t.title&&s.push(t.title)}if(t){const e=p(t);s.push(e)}if(2===s.length){if(s[0].toLowerCase().includes(s[1].toLowerCase()))return s[0];if(s[1].toLowerCase().includes(s[0].toLowerCase()))return s[1]}return s.join(" - ")}function _(e){if(!e)return!1;const t=(e=e.toLowerCase()).includes(".arcgis.com/"),s=e.includes("//services")||e.includes("//tiles")||e.includes("//features");return t&&s}function m(e,t){return e?(0,i.Qj)((0,i.Hu)(e,t)):e}function y(e){let{url:t}=e;if(!t)return{url:t};t=(0,i.Hu)(t,e.logger);const s=(0,i.mN)(t),n=d(s.path);let o;if((0,r.pC)(n))null!=n.sublayer&&null==e.layer.layerId&&(o=n.sublayer),t=n.url.path;else if(e.nonStandardUrlAllowed){const e=g(s.path);(0,r.pC)(e)&&(t=e.serviceUrl,o=e.sublayerId)}return{url:(0,i.Qj)(t),layerId:o}}function I(e,t,s,r,o){(0,n.w)(t,r,"url",o),r.url&&null!=e.layerId&&(r.url=(0,i.v_)(r.url,s,e.layerId.toString()))}function b(e){if(!e)return!1;const t=e.toLowerCase(),s=t.includes("/services/"),r=t.includes("/mapserver/wmsserver"),i=t.includes("/imageserver/wmsserver"),n=t.includes("/wmsserver");return s&&(r||i||n)}},28694:(e,t,s)=>{s.d(t,{p:()=>n});var r=s(70586),i=s(69285);function n(e,t,s){if(!s||!s.features||!s.hasZ)return;const n=(0,i.k)(s.geometryType,t,e.outSpatialReference);if(!(0,r.Wi)(n))for(const e of s.features)n(e.geometry)}},58333:(e,t,s)=>{s.d(t,{ET:()=>n,I4:()=>i,eG:()=>h,lF:()=>o,lj:()=>u,qP:()=>a,wW:()=>l});const r=[252,146,31,255],i={type:"esriSMS",style:"esriSMSCircle",size:6,color:r,outline:{type:"esriSLS",style:"esriSLSSolid",width:.75,color:[153,153,153,255]}},n={type:"esriSLS",style:"esriSLSSolid",width:.75,color:r},o={type:"esriSFS",style:"esriSFSSolid",color:[252,146,31,196],outline:{type:"esriSLS",style:"esriSLSSolid",width:.75,color:[255,255,255,191]}},a={type:"esriTS",color:[255,255,255,255],font:{family:"arial-unicode-ms",size:10,weight:"bold"},horizontalAlignment:"center",kerning:!0,haloColor:[0,0,0,255],haloSize:1,rotated:!1,text:"",xoffset:0,yoffset:0,angle:0},h={type:"esriSMS",style:"esriSMSCircle",color:[0,0,0,255],outline:null,size:10.5},l={type:"esriSLS",style:"esriSLSSolid",color:[0,0,0,255],width:1.5},u={type:"esriSFS",style:"esriSFSSolid",color:[0,0,0,255],outline:null}},61027:(e,t,s)=>{s.d(t,{KS:()=>l,PX:()=>n,QS:()=>c,_I:()=>r,jL:()=>h,nE:()=>u,vs:()=>a,xp:()=>o});const r=8388607,i=8388608,n=0,o=1,a=e=>(e&i)>>