/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../chunks/_rollupPluginBabelHelpers","../../core/Error","../../core/maybe","../../renderers/support/AuthoringInfo","../../renderers/support/AuthoringInfoVisualVariable","../../renderers/visualVariables/OpacityVariable","./support/utils","../statistics/summaryStatistics","../support/utils","../support/adapters/support/layerUtils"],(function(e,i,a,l,s,r,t,n,o,u,p){"use strict";const d="date";function y(e){return c.apply(this,arguments)}function c(){return(c=i._asyncToGenerator((function*(e){if(!(e&&e.layer&&(e.field||e.valueExpression||e.sqlExpression)))throw new a("opacity-visual-variable:missing-parameters","'layer' and 'field', 'valueExpression' or 'sqlExpression' parameters are required");if(e.valueExpression&&!e.view)throw new a("opacity-visual-variable:missing-parameters","View is required when 'valueExpression' is specified");const i={...e},s=p.createLayerAdapter(i.layer,p.featureCapableLayerTypes);if(i.layer=s,!s)throw new a("opacity-visual-variable:invalid-parameters","'layer' must be one of these types: "+p.getLayerTypeLabels(p.featureCapableLayerTypes).join(", "));const r=l.isSome(i.signal)?{signal:i.signal}:null;yield s.load(r);const t=yield u.getFieldsList({field:i.field,normalizationField:i.normalizationField,valueExpression:i.valueExpression}),o=n.verifyBasicFieldValidity(s,t,"opacity-visual-variable:invalid-parameters");if(o)throw o;return i}))).apply(this,arguments)}function f(e,i){const a=i.layer,l=i.field,o=l&&!("function"==typeof l)?a.getField(l):null,u=o&&o.type===d,p=n.createStopValues(e),y=n.getDefaultDataRange(e,u,!0),c=y||[p[0],p[4]],f=new t({field:l,valueExpression:i.valueExpression,valueExpressionTitle:i.valueExpressionTitle,normalizationField:i.normalizationField,stops:[{value:c[0],opacity:.3},{value:c[1],opacity:1}],legendOptions:i.legendOptions}),v=new r({type:"opacity",minSliderValue:null!=i.minValue?i.minValue:e.min,maxSliderValue:null!=i.maxValue?i.maxValue:e.max}),m=new s({visualVariables:[v]});return Promise.resolve({visualVariable:f,statistics:e,defaultValuesUsed:!!y,authoringInfo:m})}function v(e){return m.apply(this,arguments)}function m(){return(m=i._asyncToGenerator((function*(e){const i=yield y(e);let a=null;return a=i.statistics?i.statistics:yield o({layer:i.layer,field:i.field,valueExpression:i.valueExpression,sqlExpression:i.sqlExpression,sqlWhere:i.sqlWhere,normalizationType:i.normalizationField?"field":void 0,normalizationField:i.normalizationField,minValue:i.minValue,maxValue:i.maxValue,view:i.view,signal:i.signal}),f(a,i)}))).apply(this,arguments)}e.createVisualVariable=v,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
