/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as a}from"tslib";import{property as r,subclass as i}from"../../core/accessorSupport/decorators.js";import{collectField as s,collectArcadeFieldNames as e}from"../../layers/support/fieldUtils.js";import t from"../visualVariables/ColorVariable.js";import l from"../visualVariables/OpacityVariable.js";import o from"../visualVariables/RotationVariable.js";import u from"../visualVariables/SizeVariable.js";import V from"../visualVariables/VisualVariable.js";import p from"../visualVariables/VisualVariableFactory.js";import{matchRandomRotationExpression as n}from"../../support/arcadeExpressionUtils.js";import{reader as b}from"../../core/accessorSupport/decorators/reader.js";import{writer as c}from"../../core/accessorSupport/decorators/writer.js";const v={base:V,key:"type",typeMap:{opacity:l,color:t,rotation:o,size:u}},m=t=>{const l=t;let o=class extends l{constructor(){super(...arguments),this._vvFactory=new p}set visualVariables(a){this._vvFactory.visualVariables=a,this._set("visualVariables",this._vvFactory.visualVariables)}readVisualVariables(a,r,i){return this._vvFactory.readVariables(a,r,i)}writeVisualVariables(a,r,i,s){r[i]=this._vvFactory.writeVariables(a,s)}get arcadeRequiredForVisualVariables(){return this.visualVariables?.some(({arcadeRequired:a})=>a)??!1}hasVisualVariables(a,r){return a?this.getVisualVariablesForType(a,r).length>0:this.getVisualVariablesForType("size",r).length>0||this.getVisualVariablesForType("color",r).length>0||this.getVisualVariablesForType("opacity",r).length>0||this.getVisualVariablesForType("rotation",r).length>0}getVisualVariablesForType(a,r){return this.visualVariables?.filter(i=>i.type===a&&("string"==typeof r?i.target===r:!1!==r||!i.target))??[]}async collectVVRequiredFields(a,r){let i=[];this.visualVariables&&(i=i.concat(this.visualVariables));for(const t of i)t&&(t.field&&s(a,r,t.field),t.normalizationField&&s(a,r,t.normalizationField),t.valueExpression&&(y(t.valueExpression,a,r)||await e(a,r,null,t.valueExpression)))}};return a([r({types:[v],value:null,json:{write:!0}})],o.prototype,"visualVariables",null),a([b("visualVariables",["visualVariables","rotationType","rotationExpression"])],o.prototype,"readVisualVariables",null),a([c("visualVariables")],o.prototype,"writeVisualVariables",null),o=a([i("esri.renderers.mixins.VisualVariablesMixin")],o),o};function y(a,r,i){const e=n(a);return null!=e&&(s(r,i,e),!0)}export{m as VisualVariablesMixin};
