// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("../../core/Error ../../core/JSONSupport ../../core/Logger ../../core/MapUtils ../../core/sql/UnknownTimeZone ./fieldUtils ../../time/timeZoneUtils ../../chunks/datetime".split(" "),function(w,x,y,z,A,e,f,q){function h(a){return a.trim().toLowerCase()}function r(a){const b=new Map;if(!a.fields)return b;const c=!0===a.datesInUnknownTimezone,{timeInfo:d,editFieldsInfo:g}=a;var n=(d?"startField"in d?d.startField:d.startTimeField:"")??"";const B=(d?"endField"in d?d.endField:d.endTimeField:"")?? "",k="dateFieldsTimeZone"in a?a.dateFieldsTimeZone??null:a.dateFieldsTimeReference?f.fromTimeReference(a.dateFieldsTimeReference):null,t=g?"timeZone"in g?g.timeZone??k:g.dateFieldsTimeReference?f.fromTimeReference(g.dateFieldsTimeReference):k??f.utc:null,u=d?"timeZone"in d?d.timeZone??k:d.timeReference?f.fromTimeReference(d.timeReference):k:null;n=new Map([[h(g?.creationDateField??""),t],[h(g?.editDateField??""),t],[h(n),u],[h(B),u]]);for(const {name:l,type:p}of a.fields)v.has(p)?b.set(l,f.unknown): "date"!==p&&"esriFieldTypeDate"!==p?b.set(l,null):c?b.set(l,f.unknown):(a=n.get(h(l??""))??k,b.set(l,a));return b}const C=new Map;class m{static fromJSON(a){return new m(a.fields,a.timeZoneByFieldName)}static fromLayer(a){return new m(a.fields??[],r(a))}static fromLayerJSON(a){return new m(a.fields??[],r(a))}constructor(a=[],b){this._fieldsMap=new Map;this._normalizedFieldsMap=new Map;this._dateFieldsSet=new Set;this._numericFieldsSet=new Set;this._requiredFields=null;this.dateFields=[];this.numericFields= [];this.fields=a||[];this._timeZoneByFieldName=b?new Map(b):null;a=[];for(const c of this.fields){b=c?.name;const d=e.normalizeFieldName(b)?.toLowerCase()??"";if(b&&d){const g=h(b);this._fieldsMap.set(b,c);this._fieldsMap.set(g,c);this._normalizedFieldsMap.set(d,c);a.push(`${g}:${c.type}:${this._timeZoneByFieldName?.get(b)}`);e.isDateField(c)?(this.dateFields.push(c),this._dateFieldsSet.add(c)):e.isNumericField(c)&&(this._numericFieldsSet.add(c),this.numericFields.push(c));e.isObjectIDField(c)||e.isGlobalIDField(c)|| (c.editable=null==c.editable||!!c.editable,c.nullable=null==c.nullable||!!c.nullable)}}a.sort();this.uid=a.join()}get requiredFields(){if(!this._requiredFields){this._requiredFields=[];for(const a of this.fields)e.isObjectIDField(a)||e.isGlobalIDField(a)||a.nullable||void 0!==e.getFieldDefaultValue(a)||this._requiredFields.push(a)}return this._requiredFields}equals(a){return this.uid===a?.uid}has(a){return null!=this.get(a)}get(a){if(a){var b=this._fieldsMap.get(a);if(b)return b;(b=this._fieldsMap.get(h(a))?? this._normalizedFieldsMap.get(e.normalizeFieldName(a)?.toLowerCase()??""))&&this._fieldsMap.set(a,b);return b}}getTimeZone(a){a=this.get(a&&"string"!==typeof a?a.name:a);return a?this._timeZoneByFieldName?this._timeZoneByFieldName.get(a.name):"date"===a.type||"esriFieldTypeDate"===a.type?(y.getLogger("esri.layers.support.FieldsIndex").error(new w("getTimeZone:no-timezone-information",`no time zone information for field '${a.name}'`)),f.utc):v.has(a.type)?f.unknown:null:null}getLuxonTimeZone(a){const b= this.getTimeZone(a);return b?b===f.unknown?A.UnknownTimeZone.instance:b===f.utc?q.FixedOffsetZone.utcInstance:z.getOrCreateMapValue(C,b,()=>q.IANAZone.create(b)):null}isDateField(a){return this._dateFieldsSet.has(this.get(a))}isTimeOnlyField(a){return e.isTimeOnlyField(this.get(a))}isNumericField(a){return this._numericFieldsSet.has(this.get(a))}normalizeFieldName(a){return this.get(a)?.name??void 0}toJSON(){return{fields:this.fields.map(a=>x.isSerializable(a)?a.toJSON():a),timeZoneByFieldName:this._timeZoneByFieldName? Array.from(this._timeZoneByFieldName.entries()):null}}}const v=new Set("time-only date-only timestamp-offset esriFieldTypeDateOnly esriFieldTypeTimeOnly esriFieldTypeTimestampOffset".split(" "));return m});