/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import"../../../../core/has.js";import{numericHash as t}from"../../../../core/string.js";import{isBarcodeScannerInput as n,isComboBoxInput as e,isRadioButtonsInput as i,isDatePickerInput as r,isDateTimePickerInput as o,isDateTimeOffsetPickerInput as $,isSwitchInput as u,isTextAreaInput as f,isTextBoxInput as s,isTimePickerInput as l}from"../../../../form/elements/inputs/inputUtils.js";import{isFieldElementTemplate as c,isGroupElementTemplate as m,isExcludedFromSharedForm as a}from"./templateUtils.js";const p="",g="num:";function d(n){return c(n)?t(y(n)).toString():m(n)?t(S(n)).toString():t(JSON.stringify(n)).toString()}function y(t){return`${V(t)}.${O(t.field)}.${j(t.domain)}.${t.hint??p}.${b(t.input)}.${t.layerTimeZone??""}`}function S(t){const n=V(t)+`.${t.initialState}`;let e=p;for(const i of t.elements)a(i)||(e+="."+d(i).toString());return`${n}${e}`}function V(t){return`${t.label??p}.${t.description??p}`}function b(t){if(!t)return p;const{type:c}=t;if(n(t))return c??p;if(e(t)||i(t)){const{showNoValueOption:n}=t;return`${c}.${n}.${t.noValueOptionLabel??p}`}if(r(t))return`${c}.${h(t)}`;if(o(t)){const n=t.min?.getTime(),e=t.max?.getTime(),{includeTime:i}=t;return`${c}.${n}.${e}.${i}`}if($(t)){const n=h(t),{includeTimeOffset:e,timeResolution:i}=t;return`${c}.${n}.${e}.${i}`}if(u(t)){const{offValue:n,onValue:e}=t;return`${c}.${T(n)}.${T(e)}`}if(f(t)||s(t)){return`${c}.${t.minLength?.toString()??p}.${t.maxLength?.toString()??p}`}if(l(t)){const n=h(t),{timeResolution:e}=t;return`${c}.${n}.${e}`}return JSON.stringify(t)}function h(t){return`${t.min??p}.${t.max??p}`}function O(t){const n=t.name,e=t.alias??p;return`${n}.${e===n?p:e}.${t.nullable}.${t.type}.${t.length??p}.${t.defaultValue??p}.${t.description??p}.${t.editable}.${t.visible}`}function j(t){return t?"coded-value"===t.type?x(t):"range"===t.type?N(t):JSON.stringify(t):p}function x(t){const{type:n}=t;return`${n}.${t.codedValues.map(({code:t,name:n})=>`${T(t)}.${n}`).sort().join(".")}`}function T(t){return"number"==typeof t?`${g}${t}`:t}function N(t){const{maxValue:n,minValue:e,type:i}=t;return`${i}.${e}.${n}`}export{d as hashElementTemplate};
