/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import e from"../../../core/Error.js";async function n(n,r){const{layer:i,view:t,forBinning:a,filter:s}=n;if(!i||!t)throw new e(`${r}:missing-parameters`,"'layer' and 'view' parameters are required");await i.load();const o="featureReduction"in i?i.featureReduction:null;if(a){if("binning"!==o?.type)throw new e(`${r}:invalid-parameters`,"'layer' must have 'featureReduction' property defined with 'binning' type when 'forBinning' parameter is true");if(s)throw new e(`${r}:invalid-parameters`,"'filter' parameter is not supported when 'forBinning' parameter is true")}return n}async function r(n){const{layer:r,forBinning:i,renderer:t}=n;await r.load();const a="featureReduction"in r?r.featureReduction:null,s=t?.clone()??(i&&"binning"===a?.type?a?.renderer?.clone():"renderer"in r?r.renderer?.clone():null);if(!s)throw new e("get-renderer-to-update:invalid-parameters","renderer not available");return s}function i(e,n,r){const i=e?.authoringInfo?.visualVariables;return i?.find(e=>"reference-size"===r?e.type===n&&"reference-size"===e.theme:"spike"===r?e.type===n&&"spike"===e.theme:e.type===n)}function t(e){if(!e)return null;const n=e.type,r="visualVariables"in e?e.visualVariables:null,t=r?.find(d),a=r?.find(z),s=e.authoringInfo,o=i(e,"color"),u=i(e,"size"),l=i(e,"size","reference-size"),c=i(e,"size","spike");if("class-breaks"===n){if("univariate-color-size"===s?.type)return"univariate-color-size";if(t)return a?u?.units?"color-size-age":o?.units?"color-age-size":"color-size":o?.units?"color-age":l||c?"color-size":"color-continuous";if(a)return u?.units?"size-age":"size-continuous";if(e.classBreakInfos.length>1)return"class-breaks-color"===s?.type?"color-class-breaks":"class-breaks-size"===s?.type?"size-class-breaks":null;if(l||c)return"size-continuous"}return"unique-value"===n?e.valueExpression?"predominance"===s?.type?"predominance":"relationship"===s?.type?a||l||c?"relationship-size":"relationship":a||l||c?"type-size":"type":a?u?.units?"type-size-age":"type-size":l||c?"type-size":"type":"pie-chart"===n?"pie-chart":"dot-density"===n?"dot-density":"heatmap"===n?"heatmap":"simple"===n?"location":null}function a(e){return!!e.visualVariables?.some(h)}function s(e){return!!e.visualVariables?.some(v)}function o(e){return e?.findIndex(h)??-1}function u(e){return e?.findIndex(z)??-1}function l(e){return e?.findIndex(d)??-1}function c(e){return e?.findIndex(y)??-1}function f(e){return e?.findIndex(m)??-1}function p(e){return e?.findIndex(v)??-1}function d(e){return"color"===e.type}function y(e){return"opacity"===e.type}function m(e){return"rotation"===e.type}function z(e){return"size"===e.type&&"outline"!==e.target&&"$view.scale"!==e.valueExpression}function h(e){return"size"===e.type&&"outline"===e.target}function v(e){return"size"===e.type&&"$view.scale"===e.valueExpression&&"outline"!==e.target&&Array.isArray(e.stops)}function g(e,n,r){const i=e.visualVariables,t=r(i);if(!n||Array.isArray(n)&&!n.length)return;Array.isArray(n)||(n=[n]);const a=n.map(e=>e.clone());i?t>-1?i.splice(t,1,...a):i.push(...a):e.visualVariables=a}function b(e,n,r){const t=n?.visualVariables.find(e=>e.type===r),a=i(e,r);a&&t&&(a.dataSeriesName=t.dataSeriesName,a.minSliderValue=t.minSliderValue,a.maxSliderValue=t.maxSliderValue,"size"===r&&("reference-size"!==a.theme&&"spike"!==a.theme||(a.sizeStops=t.sizeStops?.map(e=>e.clone()),"reference-size"===a.theme&&(a.referenceSizeScale=t.referenceSizeScale))))}export{l as findColorVVIndex,c as findOpacityVVIndex,o as findOutlineVVIndex,f as findRotationVVIndex,p as findScaleDependentSizeVVIndex,u as findSizeVVIndex,i as getAuthoringInfoVisualVariable,r as getRendererToUpdate,t as getStyleType,a as hasOutlineVV,s as hasScaleDependentSizeVV,d as isColorVV,y as isOpacityVV,h as isOutlineVV,m as isRotationVV,v as isScaleDependentSizeVV,z as isSizeVV,n as processRegenerateParams,g as spliceVisualVariables,b as updateAuthoringInfoVisualVariable};
