/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../PopupTemplate","../layers/support/fieldUtils","../popup/content/AttachmentsContent","../popup/content/Content","../popup/content/CustomContent","../popup/content/ExpressionContent","../popup/content/FieldsContent","../popup/content/MediaContent","../popup/content/TextContent","../popup/FieldInfo","../popup/support/FieldInfoFormat"],(function(e,t,i,n,o,l,a,s,r,d,u,p){"use strict";const c=["oid","global-id"],f=["oid","global-id","guid"];function m({displayField:e,editFieldsInfo:i,fields:n,objectIdField:o,title:l},a){if(!n)return null;const s=$({editFieldsInfo:i,fields:n,objectIdField:o},a);if(!s.length)return null;const r=v({titleBase:l,fields:n,displayField:e}),d=_();return new t({title:r,content:d,fieldInfos:s})}const F=[/^fnode_$/i,/^tnode_$/i,/^lpoly_$/i,/^rpoly_$/i,/^poly_$/i,/^subclass$/i,/^subclass_$/i,/^rings_ok$/i,/^rings_nok$/i,/shape/i,/perimeter/i,/objectid/i,/_i$/i],b=(e,{editFieldsInfo:t,objectIdField:i,visibleFieldNames:n})=>n?n.has(e.name):!y(e.name,t)&&((!i||e.name!==i)&&(!c.includes(e.type)&&!F.some((t=>t.test(e.name)))));function g(e,t){const i=e;return t&&(e=e.filter((e=>!t.includes(e.type)))),e===i&&(e=e.slice()),e.sort(w),e}function w(e,t){return"oid"===e.type?-1:"oid"===t.type?1:j(e)?-1:j(t)?1:(e.alias||e.name).toLocaleLowerCase().localeCompare((t.alias||t.name).toLocaleLowerCase())}function y(e,t){if(!e||!t)return!1;const{creationDateField:i,creatorField:n,editDateField:o,editorField:l}=t;return[i&&i.toLowerCase(),n&&n.toLowerCase(),o&&o.toLowerCase(),l&&l.toLowerCase()].includes(e.toLowerCase())}function C(e,t){return e.editable&&!f.includes(e.type)&&!y(e.name,t)}function I(e,t){return new s({fieldInfos:$(e,t).filter((e=>e.visible))})}function $({editFieldsInfo:e,fields:t,objectIdField:i},n){return g(t,(null==n?void 0:n.ignoreFieldTypes)||h).map((t=>new u({fieldName:t.name,isEditable:C(t,e),label:t.alias,format:L(t),visible:b(t,{editFieldsInfo:e,objectIdField:i,visibleFieldNames:null==n?void 0:n.visibleFieldNames})})))}function L(e){switch(e.type){case"small-integer":case"integer":case"single":return new p({digitSeparator:!0,places:0});case"double":return new p({digitSeparator:!0,places:2});case"date":return new p({dateFormat:"long-month-day-year"});default:return"string"===e.type&&i.isRasterPixelValueField(e.name)?new p({digitSeparator:!0,places:0}):null}}function _(){return[new s,new n]}function v(e){const t=i.getDisplayFieldName(e),{titleBase:n}=e;return t?`${n}: {${t.trim()}}`:n}function j(e){if("name"===(e.name&&e.name.toLowerCase()))return!0;return"name"===(e.alias&&e.alias.toLowerCase())||void 0}const h=["geometry","blob","raster","guid","xml"];e.createFieldInfos=$,e.createFieldsContent=I,e.createPopupTemplate=m,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
