/*
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","../../support/arcadeOnDemand","../../support/basemapUtils"],(function(e,t,r,n){"use strict";const a={light:["streets","gray","topo","terrain","national-geographic","oceans","osm","gray-vector","streets-vector","topo-vector","streets-relief-vector","streets-navigation-vector","arcgis-light-gray","arcgis-navigation","arcgis-streets","arcgis-streets-relief","arcgis-topographic","arcgis-oceans","osm-standard","osm-standard-relief","osm-streets","osm-streets-relief","osm-light-gray","arcgis-terrain","arcgis-charted-territory","arcgis-community","arcgis-colored-pencil","arcgis-modern-antique","arcgis-midcentury","arcgis-newspaper","arcgis-hillshade-light"],dark:["satellite","hybrid","dark-gray","dark-gray-vector","streets-night-vector","arcgis-imagery","arcgis-imagery-standard","arcgis-dark-gray","arcgis-navigation-night","arcgis-streets-night","osm-dark-gray","arcgis-nova","arcgis-hillshade-dark"]},i="percent-of-total",s="field",o={years:365,months:30,days:1,hours:1/24,minutes:1/1440,seconds:1/86400,milliseconds:1/864e5},l=["integer","small-integer"];let c=null;function g(e){return u.apply(this,arguments)}function u(){return(u=t._asyncToGenerator((function*(e){const t=e.field,n=e.normalizationField,a=e.valueExpression;let i=[];if(a){if(!c){const{arcadeUtils:e}=yield r.loadArcade();c=e}i=c.extractFieldNames(a)}return t&&i.push(t),n&&i.push(n),i}))).apply(this,arguments)}function d(e){let t=e.normalizationType;return t||(e.normalizationField?t=s:null!=e.normalizationTotal&&(t=i)),t}function f(e){return String(e).padStart(2,"0")}function p(e,t,r){let n;if("date"===t||"number"===t){"number"===t&&(e=new Date(e));n=`TIMESTAMP'${r?e.getFullYear():e.getUTCFullYear()}-${f((r?e.getMonth():e.getUTCMonth())+1)}-${f(r?e.getDate():e.getUTCDate())} ${f(r?e.getHours():e.getUTCHours())}:${f(r?e.getMinutes():e.getUTCMinutes())}:${f(r?e.getSeconds():e.getUTCSeconds())}'`}else n=e;return n}function m(e,t,r,n){const{hasQueryEngine:a}=e;let i=`(${p(r,y(e,r),a)} - ${p(t,y(e,t),a)})`;a&&(i=`(${i} * ${o.milliseconds})`);let s=o[n],l="/";s<1&&(s=1/s,l="*");return{sqlExpression:1===s?i:`(${i} ${l} ${s})`,sqlWhere:null}}function y(e,t){if(t instanceof Date)return"date";if("number"==typeof t)return"number";if("string"==typeof t){const r=e.getField(t);if("<now>"===t.toLowerCase())return;if(r&&"date"===r.type)return"field"}}function h(e,t=a){for(const r in t)if(t[r].includes(e))return r}function T(e,t,r=!0){let a=null;return e&&("string"==typeof e?t.includes(e)&&(a=e):a=n.getWellKnownBasemapId(e)),r?a||"gray":a}function v(e,t){const r=t&&e.getField(t);return r&&l.includes(r.type)}function $(e){return`cast(${e} as float)`}e.castIntegerFieldToFloat=$,e.defaultBasemapGroups=a,e.getBasemapGroup=h,e.getBasemapId=T,e.getDateDiffSQL=m,e.getDateType=y,e.getFieldsList=g,e.getNormalizationType=d,e.isIntegerField=v,e.unitValueInDays=o,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
