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.a33cbbbf.js";import v from"./FeatureLayerView2D.8da6a32f.js";import{e as O}from"./util.d9684b28.js";import"./utils.4103b17b.js";import"./Utils.2784465f.js";import"./enums.0295eb81.js";import"./enums.2d9e6f64.js";import"./Texture.bb8fc8d4.js";import"./VertexElementDescriptor.1fdca6da.js";import"./MaterialKey.3d30b027.js";import"./LayerView.a376b311.js";import"./schemaUtils.516cb963.js";import"./visualVariablesUtils.d684f3b8.js";import"./createSymbolSchema.2297e3ae.js";import"./ExpandedCIM.a8fa01db.js";import"./BidiEngine.d8bba3fc.js";import"./Rect.95b0fd2e.js";import"./quantizationUtils.cc6dbee4.js";import"./GeometryUtils.4f19e772.js";import"./floatRGBA.c691d660.js";import"./popupUtils.f46478ae.js";import"./RefreshableLayerView.7d31099d.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};