/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../../chunks/_rollupPluginBabelHelpers","../../../chunks/tslib.es6","../../../core/maybe","../../../core/reactiveUtils","../../../core/Logger","../../../core/accessorSupport/ensureType","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/set","../../../core/accessorSupport/decorators/subclass","../../../layers/support/FeatureFilter","./FeatureLayerView2D"],(function(e,r,t,s,i,a,l,n,o,u,y,c){"use strict";function p(e,r){return!e.visible||0!==e.minScale&&r>e.minScale||0!==e.maxScale&&r<e.maxScale}let h=function(r){function i(){return r.apply(this,arguments)||this}e._inheritsLoose(i,r);var a=i.prototype;return a.initialize=function(){this.handles.add([s.watch((()=>{var e;return null==(e=this.view)?void 0:e.viewpoint}),(()=>this._update()),s.initial)])},a._injectOverrides=function(e){let s=r.prototype._injectOverrides.call(this,e);const i=this.view.scale,a=this.layer.sublayers.filter((e=>p(e,i))).map((e=>e.subtypeCode));if(!a.length)return s;s=t.isSome(s)?s:(new y).toJSON();const l=`NOT ${this.layer.subtypeField} IN (${a.join(",")})`;return s.where=s.where?`(${s.where}) AND (${l})`:l,s},a._setLayersForFeature=function(e){const r=this.layer.fieldsIndex.get(this.layer.subtypeField),t=e.attributes[r.name],s=this.layer.sublayers.find((e=>e.subtypeCode===t));e.layer=s,e.sourceLayer=this.layer},a._createSchemaConfig=function(){const e={subtypeField:this.layer.subtypeField,sublayers:Array.from(this.layer.sublayers).map((e=>({featureReduction:null,geometryType:this.layer.geometryType,labelingInfo:e.labelingInfo,labelsVisible:e.labelsVisible,renderer:e.renderer,subtypeCode:e.subtypeCode,orderBy:null})))},t=this.layer.sublayers.map((e=>e.subtypeCode)).join(","),s=this.layer.sublayers.length?`${this.layer.subtypeField} IN (${t})`:"1=2";let i=this.layer.definitionExpression?this.layer.definitionExpression+" AND ":"";return i+=s,{...r.prototype._createSchemaConfig.call(this),...e,definitionExpression:i}},i}(c);h=r.__decorate([u.subclass("esri.views.2d.layers.SubtypeGroupLayerView2D")],h);return h}));
