/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import e from"../../PopupTemplate.js";import r from"../../core/Error.js";import{fetchMessageBundle as n}from"../../intl/messages.js";import{hasNormalizedField as a,getFieldAndExpressionInfos as i,getContentFromFieldInfos as s}from"./support/utils.js";async function t(e){const{layer:n,renderer:a}=e;await n.load();const i=a??("renderer"in n?n.renderer:void 0);if("unique-value"!==i?.type)throw new r("unique-values-popup:invalid-parameters","renderer.type must be 'unique-value'");return{layer:n,renderer:i}}async function o(r,n,a="divide"){const{fieldInfos:t,expressionInfos:o}=await i({renderer:r,layer:n,normFieldExpressionTemplate:a});return new e({content:await s(n,{fieldInfos:t,expressionInfos:o}),fieldInfos:t,expressionInfos:o})}async function u(e){const[{renderer:r,layer:i},s]=await Promise.all([t(e),n("esri/smartMapping/t9n/smartMapping")]),u={name:"unique-values",title:s.uniqueValues,value:await o(r,i)},p=[];return a(r)&&p.push({name:"unique-values-percent",title:s.uniqueValuesNormFieldAsPercent,value:await o(r,i,"percentage")}),{primaryTemplate:u,secondaryTemplates:p}}export{u as getTemplates};
