/*
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","../Dictionary","../../chunks/languageUtils","../featureset/support/shared"],(function(e,n,t,r,o){"use strict";function i(e){return e&&e.domain?"coded-value"===e.domain.type||"codedValue"===e.domain.type?t.convertObjectToArcadeDictionary({type:"codedValue",name:e.domain.name,dataType:o.layerFieldEsriConstants[e.field.type],codedValues:e.domain.codedValues.map((e=>({name:e.name,code:e.code})))}):t.convertObjectToArcadeDictionary({type:"range",name:e.domain.name,dataType:o.layerFieldEsriConstants[e.field.type],min:e.domain.min,max:e.domain.max}):null}function a(e){"async"===e.mode&&(e.functions.domain=function(t,o){return e.standardFunctionAsync(t,o,function(){var e=n._asyncToGenerator((function*(e,n,t){if(r.pcCheck(t,2,3),r.isFeature(t[0])){return i(r.featureFullDomain(t[0],r.toString(t[1]),void 0===t[2]?void 0:r.toNumber(t[2])))}if(r.isFeatureSet(t[0])){yield t[0]._ensureLoaded();return i(r.getDomain(r.toString(t[1]),t[0],null,void 0===t[2]?void 0:r.toNumber(t[2])))}throw new Error("Invalid Parameter")}));return function(n,t,r){return e.apply(this,arguments)}}())},e.functions.subtypes=function(o,i){return e.standardFunctionAsync(o,i,function(){var e=n._asyncToGenerator((function*(e,n,o){if(r.pcCheck(o,1,1),r.isFeature(o[0])){const e=r.featureSubtypes(o[0]);return e?t.convertObjectToArcadeDictionary(e):null}if(r.isFeatureSet(o[0])){yield o[0]._ensureLoaded();const e=o[0].subtypes();return e?t.convertObjectToArcadeDictionary(e):null}throw new Error("Invalid Parameter")}));return function(n,t,r){return e.apply(this,arguments)}}())},e.functions.domainname=function(t,o){return e.standardFunctionAsync(t,o,function(){var e=n._asyncToGenerator((function*(e,n,t){if(r.pcCheck(t,2,4),r.isFeature(t[0]))return r.featureDomainValueLookup(t[0],r.toString(t[1]),t[2],void 0===t[3]?void 0:r.toNumber(t[3]));if(r.isFeatureSet(t[0])){yield t[0]._ensureLoaded();const e=r.getDomain(r.toString(t[1]),t[0],null,void 0===t[3]?void 0:r.toNumber(t[3]));return r.getDomainValue(e,t[2])}throw new Error("Invalid Parameter")}));return function(n,t,r){return e.apply(this,arguments)}}())},e.signatures.push({name:"domainname",min:"2",max:"4"}),e.functions.domaincode=function(t,o){return e.standardFunctionAsync(t,o,function(){var e=n._asyncToGenerator((function*(e,n,t){if(r.pcCheck(t,2,4),r.isFeature(t[0]))return r.featureDomainCodeLookup(t[0],r.toString(t[1]),t[2],void 0===t[3]?void 0:r.toNumber(t[3]));if(r.isFeatureSet(t[0])){yield t[0]._ensureLoaded();const e=r.getDomain(r.toString(t[1]),t[0],null,void 0===t[3]?void 0:r.toNumber(t[3]));return r.getDomainCode(e,t[2])}throw new Error("Invalid Parameter")}));return function(n,t,r){return e.apply(this,arguments)}}())},e.signatures.push({name:"domaincode",min:"2",max:"4"})),e.functions.text=function(n,t){return e.standardFunctionAsync(n,t,(function(e,n,t){if(r.pcCheck(t,1,2),!r.isFeatureSet(t[0]))return r.toStringExplicit(t[0],t[1]);{const n=r.defaultUndefined(t[1],"");if(""===n)return t[0].castToText();if("schema"===n.toLowerCase())return t[0].convertToText("schema",e.abortSignal);if("featureset"===n.toLowerCase())return t[0].convertToText("featureset",e.abortSignal)}}))},e.functions.gdbversion=function(t,o){return e.standardFunctionAsync(t,o,function(){var e=n._asyncToGenerator((function*(e,n,t){if(r.pcCheck(t,1,1),r.isFeature(t[0]))return t[0].gdbVersion();if(r.isFeatureSet(t[0])){return(yield t[0].load()).gdbVersion}throw new Error("Invalid Parameter")}));return function(n,t,r){return e.apply(this,arguments)}}())},e.functions.schema=function(o,i){return e.standardFunctionAsync(o,i,function(){var e=n._asyncToGenerator((function*(e,n,o){if(r.pcCheck(o,1,1),r.isFeatureSet(o[0]))return yield o[0].load(),t.convertObjectToArcadeDictionary(o[0].schema());if(r.isFeature(o[0])){const e=r.featureSchema(o[0]);return e?t.convertObjectToArcadeDictionary(e):null}throw new Error("Invalid Parameter")}));return function(n,t,r){return e.apply(this,arguments)}}())}}e.registerFunctions=a,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
