// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.16/esri/copyright.txt for details.
//>>built
define("require exports ../core/tsSupport/generatorHelper ../core/tsSupport/awaiterHelper ../core/tsSupport/assignHelper ../geometry ../core/maybe ../core/promiseUtils @dojo/framework/shim/Promise".split(" "),function(r,c,f,h,B,C,D,E){function v(){return h(this,void 0,void 0,function(){var b=this;return f(this,function(a){k||(k=function(){return h(b,void 0,void 0,function(){var a;return f(this,function(b){switch(b.label){case 0:return[4,new Promise(function(a,b){r(["./arcadeUtils"],a,b)})];case 1:return a=
b.sent(),[4,a.arcade.load()];case 2:return b.sent(),[2,{arcade:a.arcade,arcadeUtils:a,Dictionary:a.Dictionary,Feature:a.arcadeFeature}]}})})}());return[2,k]})})}Object.defineProperty(c,"__esModule",{value:!0});var k;c.loadArcade=v;c.createLabelExpression=function(b,a,d){return g.create(b,a,d,null,["$feature"])};c.createVVExpression=function(b,a,d){return g.create(b,a,d,null,["$feature","$view"])};c.createRendererExpression=function(b,a,d){return g.create(b,a,d,null,["$feature","$view"])};c.createDictionaryExpression=
function(b,a,d,c){return g.create(b,a,d,c,["$feature","$view"])};var g=function(){function b(a,b,c,g,f,h,G){this.evaluate=g;this._syntaxTree=c;this._arcade=a;this._arcadeDictionary=b;this._arcadeFeature=f;this._fields=h;this._spatialReference=G;this._referencesGeometry=a.scriptTouchesGeometry(this._syntaxTree);this._referencesScale=this._arcade.referencesMember(this._syntaxTree,"$view.scale")}b.create=function(a,c,g,k,r,F){return h(this,void 0,void 0,function(){var d,e,h,p,q,l,t,m,w,x,u,y,n,z,A;return f(this,
function(f){switch(f.label){case 0:return[4,v()];case 1:return d=f.sent(),e=d.arcade,h=d.Feature,p=d.Dictionary,q=C.SpatialReference.fromJSON(c),l=e.parseScript(a,F),t=r.reduce(function(a,b){var c;return B({},a,(c={},c[b]=null,c))},{}),m=null,D.isSome(k)&&(m=new p(k),m.immutable=!0,t.$config=null),w=e.scriptUsesGeometryEngine(l)&&e.enableGeometrySupport(),x=e.scriptUsesFeatureSet(l)&&e.enableFeatureSetSupport(),u=e.scriptIsAsync(l)&&e.enableAsyncSupport(),y={vars:t,spatialReference:q,useAsync:!!u},
n=new p,n.immutable=!1,n.setField("scale",0),z=e.compileScript(l,y),A=function(a){"$view"in a&&a.$view&&(n.setField("scale",a.$view.scale),a.$view=n);m&&(a.$config=m);return z({vars:a,spatialReference:q})},[4,E.all([w,x,u])];case 2:return f.sent(),[2,new b(e,p,l,A,new h,g,q)]}})})};b.prototype.repurposeFeature=function(a){a.geometry&&!a.geometry.spatialReference&&(a.geometry.spatialReference=this._spatialReference);this._arcadeFeature.repurposeFromGraphicLikeObject(a.geometry,a.attributes,{fields:this._fields});
return this._arcadeFeature};b.prototype.createDictionary=function(){return new this._arcadeDictionary};b.prototype.referencesMember=function(a){return this._arcade.referencesMember(this._syntaxTree,a)};b.prototype.referencesFunction=function(a){return this._arcade.referencesFunction(this._syntaxTree,a)};b.prototype.referencesGeometry=function(){return this._referencesGeometry};b.prototype.referencesScale=function(){return this._referencesScale};b.prototype.extractFieldLiterals=function(a){return this._arcade.extractFieldLiterals(this._syntaxTree,
a)};return b}();c.default=g});