import{_ as n,$ as a,a0 as h,R as p,g as l,cL as f,t as c,a as m}from"./index.6c049565.js";import v from"./FeatureLayerView2D.bab9ad1d.js";import{e as O}from"./util.d5f4af7b.js";import"./utils.eb2c3fd5.js";import"./Utils.e8554a0e.js";import"./enums.0295eb81.js";import"./enums.2d9e6f64.js";import"./Texture.8e8dfb11.js";import"./VertexElementDescriptor.1fdca6da.js";import"./MaterialKey.bbaab8f1.js";import"./LayerView.7c2db9bf.js";import"./schemaUtils.7eee5b9f.js";import"./visualVariablesUtils.88ca310b.js";import"./createSymbolSchema.30665f63.js";import"./ExpandedCIM.64535143.js";import"./BidiEngine.d8bba3fc.js";import"./Rect.95b0fd2e.js";import"./quantizationUtils.4f3ed95a.js";import"./GeometryUtils.4f19e772.js";import"./floatRGBA.c5518572.js";import"./popupUtils.33b7306b.js";import"./RefreshableLayerView.5868f703.js";function d(e,t){if(c(e)&&c(t))return null;const r={};return m(t)&&(r.geometry=t.toJSON()),m(e)&&(r.where=e),r}let o=class extends v{constructor(){super(...arguments),this._enabledDataReceived=!1,this.errorString=null,this.connectionStatus="disconnected"}initialize(){this.handles.add([p(()=>{var e;return(e=this.layer)==null?void 0:e.purgeOptions},()=>this._update()),p(()=>this.suspended,e=>{e?this._proxy.pauseStream():this._proxy.resumeStream()})])}get connectionError(){if(this.errorString)return new l("stream-controller",this.errorString)}on(e,t){e==="data-received"&&(this._enabledDataReceived=!0,this._proxy.enableEvent("data-received",!0));const r=super.on(e,t),i=this;return{remove(){r.remove(),e==="data-received"&&(i._proxy.closed||i.hasEventListener("data-received")||i._proxy.enableEvent("data-received",!1))}}}queryLatestObservations(e,t){if(!(this.layer.timeInfo.endField||this.layer.timeInfo.startField))throw new l("streamlayer-no-timeField","queryLatestObservation can only be used with services that define a TrackIdField");return this._proxy.queryLatestObservations(this._cleanUpQuery(e),t).then(r=>{const i=f.fromJSON(r);return i.features.forEach(s=>{s.layer=this.layer,s.sourceLayer=this.layer}),i})}detach(){super.detach(),this.connectionStatus="disconnected"}_createClientOptions(){return{...super._createClientOptions(),setProperty:e=>{this.set(e.propertyName,e.value)}}}_createTileRendererHash(e){const t=`${JSON.stringify(this.layer.purgeOptions)}.${JSON.stringify(d(this.layer.definitionExpression,this.layer.geometryDefinition))})`;return super._createTileRendererHash(e)+t}async _createServiceOptions(){const e=this.layer,{objectIdField:t}=e,r=e.fields.map(u=>u.toJSON()),i=O(e.geometryType),s=e.timeInfo&&e.timeInfo.toJSON()||null,y=e.spatialReference?e.spatialReference.toJSON():null;return{type:"stream",fields:r,geometryType:i,objectIdField:t,timeInfo:s,source:this.layer.parsedUrl,serviceFilter:d(this.layer.definitionExpression,this.layer.geometryDefinition),purgeOptions:this.layer.purgeOptions.toJSON(),enableDataReceived:this._enabledDataReceived,spatialReference:y,maxReconnectionAttempts:this.layer.maxReconnectionAttempts,maxReconnectionInterval:this.layer.maxReconnectionInterval,updateInterval:this.layer.updateInterval,customParameters:e.customParameters}}};n([a()],o.prototype,"errorString",void 0),n([a({readOnly:!0})],o.prototype,"connectionError",null),n([a()],o.prototype,"connectionStatus",void 0),o=n([h("esri.views.2d.layers.StreamLayerView2D")],o);const U=o;export{U as default};