/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["require","exports","../chunks/_rollupPluginBabelHelpers","../geometry","../core/maybe","../geometry/SpatialReference"],(function(e,r,t,a,n,i){"use strict";let s;function c(){return s||(s=t._asyncToGenerator((function*(){const r=yield new Promise(((r,t)=>e(["./arcadeUtils"],r,t)));return{arcade:r.arcade,arcadeUtils:r,Dictionary:r.Dictionary,Feature:r.arcadeFeature}}))()),s}const o=(e,r,t)=>p.create(e,r,t,null,["$feature"]),u=(e,r,t)=>p.create(e,r,t,null,["$feature","$view"]),l=u,f=(e,r,t,a)=>p.create(e,r,t,a,["$feature","$view"]);let p=function(){function e(e,r,t,a,n,i,s,c){this.script=e,this.evaluate=n;const o=Array.isArray(s)?s:s.fields;this.fields=o,this._syntaxTree=a,this._arcade=r,this._arcadeDictionary=t,this._arcadeFeature=i,this._spatialReference=c,this._referencesGeometry=r.scriptTouchesGeometry(this._syntaxTree),this._referencesScale=this._arcade.referencesMember(this._syntaxTree,"scale")}e.create=function(){var r=t._asyncToGenerator((function*(r,t,a,s,o,u){const{arcade:l,Feature:f,Dictionary:p}=yield c(),y=i.fromJSON(t),d=l.parseScript(r,u),h=o.reduce(((e,r)=>({...e,[r]:null})),{});let m=null;n.isSome(s)&&(m=new p(s),m.immutable=!0,h.$config=null);const _=l.scriptUsesGeometryEngine(d)&&l.enableGeometrySupport(),F=l.scriptUsesFeatureSet(d)&&l.enableFeatureSetSupport(),b=l.scriptIsAsync(d)&&l.enableAsyncSupport(),x={vars:h,spatialReference:y,useAsync:!!b},S=new p;S.immutable=!1,S.setField("scale",0);const v=l.compileScript(d,x),g=e=>("$view"in e&&e.$view&&(S.setField("scale",e.$view.scale),e.$view=S),m&&(e.$config=m),v({vars:e,spatialReference:y}));return yield Promise.all([_,F,b]),new e(r,l,p,d,g,new f,a,y)}));function a(e,t,a,n,i,s){return r.apply(this,arguments)}return a}();var r=e.prototype;return r.repurposeFeature=function(e){return e.geometry&&!e.geometry.spatialReference&&(e.geometry.spatialReference=this._spatialReference),this._arcadeFeature.repurposeFromGraphicLikeObject(e.geometry,e.attributes,{fields:this.fields}),this._arcadeFeature},r.createDictionary=function(){return new this._arcadeDictionary},r.referencesMember=function(e){return this._arcade.referencesMember(this._syntaxTree,e)},r.referencesFunction=function(e){return this._arcade.referencesFunction(this._syntaxTree,e)},r.referencesGeometry=function(){return this._referencesGeometry},r.referencesScale=function(){return this._referencesScale},r.extractFieldLiterals=function(){return this._arcade.extractExpectedFieldLiterals(this._syntaxTree)},e}();r.ArcadeExpression=p,r.createDictionaryExpression=f,r.createLabelExpression=o,r.createRendererExpression=u,r.createVVExpression=l,r.loadArcade=c,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
