import e from"@arcgis/core/layers/support/Field";import{assertNever as i,checkArg as r}from"../utilities/checkArg.js";import{Domain as t,DomainType as n}from"./Domain.js";export var Field;!function(i){function s(e,i){r("fieldJson",e).isNotMissing(),r("field",i).isNotMissing(),e.hasOwnProperty("alias")&&(i.alias=e.alias),e.hasOwnProperty("domain")&&e.domain&&(i.domain&&e.domain.type===n.fromEsriApiDomainType(i.domain.type)?t.applyToEsriApiDomain(e.domain,i.domain):i.domain=t.toEsriApiDomain(e.domain)),e.hasOwnProperty("editable")&&null!=e.editable&&(i.editable=e.editable),e.hasOwnProperty("length")&&(i.length=e.length),e.hasOwnProperty("name")&&null!=e.name&&(i.name=e.name),e.hasOwnProperty("nullable")&&null!=e.nullable&&(i.nullable=e.nullable),e.hasOwnProperty("type")&&null!=e.type&&(r("fieldJson.type",e.type).satisfies((()=>!!FieldType.toEsriApiFieldType(e.type))),i.type=FieldType.toEsriApiFieldType(e.type))}i.toEsriApiField=function(i){r("fieldJson",i).isNotMissing();const t=new e;return s(i,t),t},i.applyToEsriApiField=s,i.fromEsriApiField=function(e){return r("field",e).isNotMissing(),e.toJSON()}}(Field||(Field={}));export var FieldType;function s(e,r){const t=e;switch(t){case"esriFieldTypeSmallInteger":return"small-integer";case"esriFieldTypeBigInteger":return"big-integer";case"esriFieldTypeInteger":return"integer";case"esriFieldTypeSingle":return"single";case"esriFieldTypeDouble":return"double";case"esriFieldTypeString":return"string";case"esriFieldTypeDate":return"date";case"esriFieldTypeDateOnly":return"date-only";case"esriFieldTypeTimeOnly":return"time-only";case"esriFieldTypeTimestampOffset":return"timestamp-offset";case"esriFieldTypeOID":return"oid";case"esriFieldTypeGeometry":return"geometry";case"esriFieldTypeBlob":return"blob";case"esriFieldTypeRaster":return"raster";case"esriFieldTypeGUID":return"guid";case"esriFieldTypeGlobalID":return"global-id";case"esriFieldTypeXML":return"xml";default:return i(t,r)}}function l(e,r){const t=e;switch(t){case"small-integer":return"esriFieldTypeSmallInteger";case"big-integer":return"esriFieldTypeBigInteger";case"integer":return"esriFieldTypeInteger";case"single":return"esriFieldTypeSingle";case"double":return"esriFieldTypeDouble";case"string":return"esriFieldTypeString";case"date":return"esriFieldTypeDate";case"date-only":return"esriFieldTypeDateOnly";case"timestamp-offset":return"esriFieldTypeTimestampOffset";case"time-only":return"esriFieldTypeTimeOnly";case"oid":return"esriFieldTypeOID";case"geometry":return"esriFieldTypeGeometry";case"blob":return"esriFieldTypeBlob";case"raster":return"esriFieldTypeRaster";case"guid":return"esriFieldTypeGUID";case"global-id":return"esriFieldTypeGlobalID";case"xml":return"esriFieldTypeXML";case"long":if(r)throw r;return;default:return i(t,r)}}!function(e){e.fromEsriApiFieldType=function(e){return!!s(e)?e:l(e,new Error("FieldType.fromEsriApiFieldType: Unrecognized field type."))},e.toEsriApiFieldType=function(e){return!!l(e)||"long"===e?e:s(e,new Error("FieldType.toEsriApiFieldType: Unrecognized field type."))}}(FieldType||(FieldType={}));