/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{isPromiseLike as t}from"../core/promiseUtils.js";class e{constructor(){}}function n(t,n,r){if(t instanceof e&&!(t instanceof a)){const e=new a;return e.fn=t,e.parameterEvaluator=r,e.context=n,e}return t}class r extends e{constructor(t,e){super(),this._name=e,this.fn=t}get debugName(){return null!=this._name?`<native>.${this._name}`:"<native>"}createFunction(t){return(...e)=>this.fn(t,{preparsed:!0,arguments:e})}call(t,e){return this.fn(t,e)}marshalledCall(r,s,l,i){return i(r,s,(s,u,c)=>{c=c.map(t=>t instanceof e&&!(t instanceof a)?n(t,r,i):t);const o=this.call(l,{args:c});return t(o)?o.then(t=>n(t,l,i)):o})}}class a extends e{constructor(){super(...arguments),this.fn=null,this.context=null}get debugName(){return null!=this.fn.debugName?`<imported>.${this.fn.debugName}`:null}createFunction(t){return this.fn.createFunction(this.context)}call(t,e){return this.fn.marshalledCall(t,e,this.context,this.parameterEvaluator)}marshalledCall(t,e,n){return this.fn.marshalledCall(t,e,this.context,this.parameterEvaluator)}}export{e as ArcadeFunction,r as NativeFunction,a as ScopeMarshalledFunction,n as wrapModuleScopedResponse};
