"use strict";function l(t){return typeof t=="string"?t.trim().toLowerCase():""}function f(t){return String(t.column_name||t.name||t.qualifiedFieldName||"")}function g(t){return Array.from(new Set([t.column_name,t.name,t.qualifiedFieldName,t.alias].filter(e=>typeof e=="string"&&e.trim().length>0).map(e=>e.trim())))}function d(t){const e=p(t);return e?e.includes("int")||e.includes("uint")||e.includes("bigint")||e.includes("smallint")||e.includes("tinyint")||e.includes("numeric")||e.includes("decimal")||e.includes("double")||e.includes("float")||e.includes("number")||e.includes("real")||e.includes("money")||e.includes("currency")||e.includes("percent")?"number":e.includes("timestamp")||e.includes("datetime")||e.startsWith("time")?"datetime":e.includes("date")?"date":e.includes("bool")?"boolean":"string":"unknown"}function p(t){let e=l(t),i="";for(;e&&e!==i;)i=e,e=y(e,"nullable"),e=y(e,"lowcardinality");return e}function y(t,e){const i=`${e}(`;return!t.startsWith(i)||!t.endsWith(")")?t:t.slice(i.length,-1).trim()}function A(t){const e=d(t);return e==="date"||e==="datetime"}function o(t){return A(t.dataType||t.data_type)}function u(t){const e=C(t);return e==="id"||e==="row_id"}function c(t){const e=C(t);return u(t)||e.endsWith("_id")||e.endsWith("_key")||e.endsWith("_number")}function C(t){return l(f(t)||t.name||t.alias).replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function m(t,e={}){const i=l(t.role);return i==="metric"||i==="measure"?!e.excludeIdentifiers||!c(t):i==="groupby"||i==="dimension"||i==="date"||i==="id"?!1:d(t.dataType||t.data_type)==="number"&&(!e.excludeIdentifiers||!c(t))}function D(t){return!m(t)&&!o(t)}function F(t){const e=new Set,i=new Set,s=new Set;for(const a of t){if(u(a))continue;const r=g(a);if(r.length!==0){if(o(a)){r.forEach(n=>i.add(n));continue}if(m(a,{excludeIdentifiers:!0})){r.forEach(n=>e.add(n));continue}r.forEach(n=>s.add(n))}}return{validMetricCandidates:Array.from(e).sort(),validDateCandidates:Array.from(i).sort(),validDimensionCandidates:Array.from(s).sort()}}exports.buildAnalyticsCatalogFieldSummary=F;exports.getAnalyticsCatalogFieldCandidates=g;exports.getAnalyticsCatalogFieldName=f;exports.isAnalyticsCatalogDateField=o;exports.isAnalyticsCatalogDimensionField=D;exports.isAnalyticsCatalogMetricField=m;exports.isAnalyticsDateLikeDataType=A;exports.isAnalyticsMetricIdentifierField=c;exports.isAnalyticsTechnicalIdentifierField=u;exports.normalizeAnalyticsCatalogDataType=d;exports.normalizeAnalyticsCatalogName=l;
