@bicharts/shape-core 0.6.9 → 0.6.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
- import{B as D,I as E}from"./chunk-PFCJESUQ.mjs";import{v as S}from"./chunk-ILHBRGIO.mjs";import P from"papaparse";function L(e){if(!e)return".";try{return new Intl.NumberFormat(e).formatToParts(1.5).find(t=>t.type==="decimal")?.value===","?",":"."}catch{return"."}}var x="[ \\u00A0\\u202F]",p="(?:[eE][+-]?\\d+)?",O=new RegExp(`^[+-]?(?:\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.\\d+)?${p}$`),k=new RegExp(`^[+-]?(?:\\d{1,3}(?:\\.\\d{3})+|\\d{1,3}(?:${x}\\d{3})+|\\d+)(?:,\\d+)?${p}$`),N=/^[+-]?\d{1,3}[.,]\d{3}$/,_=[/^[+-]?\d{1,3}(?:,\d{3}){2,}$/,new RegExp(`^[+-]?(?:\\d{1,3}(?:,\\d{3})+|\\d+)\\.\\d+${p}$`)],j=[/^[+-]?\d{1,3}(?:\.\d{3}){2,}$/,new RegExp(`^[+-]?(?:\\d{1,3}(?:\\.\\d{3})+|\\d{1,3}(?:${x}\\d{3})+|\\d+),\\d+${p}$`)];function T(e,i){let t=0,n=0;for(let c of e){if(typeof c!="string")continue;let o=c.trim();o===""||N.test(o)||(_.some(s=>s.test(o))?t++:j.some(s=>s.test(o))&&n++)}return n>0&&t===0?",":t>0?".":L(i)}function y(e,i){let t=String(e??"").trim();return t===""?null:i===","?k.test(t)?parseFloat(t.replace(/[.   ]/g,"").replace(",",".")):null:O.test(t)?parseFloat(t.replace(/,/g,"")):null}function R(e,i){return y(e,i)!==null}var C=500,M=/^[+-]?\d{1,15}$/,q=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,F=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function V(e,i="."){let t=0,n=0,c=0,o=0;for(let s of e){if(s==null)continue;if(typeof s=="number"){o++,n++,Number.isInteger(s)&&t++;continue}if(s instanceof Date){o++,c++;continue}if(typeof s=="boolean"){o++;continue}let l=String(s).trim();if(l!==""){if(o++,M.test(l)){t++,n++;continue}if(R(l,i)){n++;continue}if((q.test(l)||F.test(l))&&!isNaN(Date.parse(l))){c++;continue}}}return o===0?"String":c===o?"DateTime":t===o?"Integer":n===o?"Decimal":"String"}function v(e,i,t="."){if(e==null)return null;if(typeof e=="number")return i==="String"?String(e):e;if(e instanceof Date)return i==="DateTime"?e:e.toISOString();if(typeof e=="boolean")return String(e);let n=String(e).trim();if(n==="")return null;switch(i){case"Integer":return M.test(n)?parseInt(n,10):null;case"Decimal":return y(n,t);case"DateTime":return S(n);default:return n}}function B(e){let i=(e||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(i)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(i)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(i)?"DateTime":(/^(bit|bool|boolean)$/.test(i),"String")}function f(e,i,t){if(e.length===0)throw new Error("ingest: no columns were resolved from the source. Supply column descriptors, or use a source shape that carries them (grid/table/objects/sql).");let n=e.length,c=e.map((r,a)=>i.slice(0,C).map(m=>m?.[a])),o=c.map(r=>T(r,t.locale)),s=e.map((r,a)=>r.dataType??V(c[a],o[a])),l=new Set((t.measures??[]).map(r=>r.toLowerCase())),A=new Set((t.dimensions??[]).map(r=>r.toLowerCase())),I=new Set((t.nonAdditive??[]).map(r=>r.toLowerCase())),$=e.map((r,a)=>{let m=r.name.toLowerCase(),u=r.isMeasure??((s[a]==="Integer"||s[a]==="Decimal")&&!D(r.name));l.has(m)&&(u=!0),A.has(m)&&(u=!1);let b={name:r.name,dataType:s[a],isMeasure:u};return u&&I.has(m)&&(b.discourageAggregationAcrossGroups=!0),b}),d=new E;d.dedupRows=t.dedup!==!1,d.setColumns($);for(let r=0;r<i.length;r++){let a=i[r];d.addRow(Array.from({length:n},(m,u)=>v(a?.[u],s[u],o[u])),r)}let w=d.getColumnsWithStats(t.privacyLevel??"20",t.locale??"en"),g=new Map(w.map(r=>[r.name,r]));e.forEach(r=>{let a=g.get(r.name);a&&(r.format&&(a.modelFormat=r.format),r.description&&(a.modelDesc=r.description))});for(let[r,a]of Object.entries(t.formats??{})){let m=g.get(r);m&&(m.modelFormat=a)}for(let[r,a]of Object.entries(t.descriptions??{})){let m=g.get(r);m&&(m.modelDesc=a)}for(let r of t.groupBy??[]){let a=g.get(r);a&&(a.isGrouping=!0)}return{columns:w,rows:d.toObjectArray(),totalRows:d.getRowCount(),index:d}}function h(e,i){return e.map(t=>Array.isArray(t)?t:i.map(n=>t[n]))}function U(e,i){let t=[],n=new Set,c=Math.min(e.length,Math.max(1,i));for(let o=0;o<c;o++){let s=e[o];if(!(!s||typeof s!="object"))for(let l of Object.keys(s))n.has(l)||(n.add(l),t.push(l))}return t}function Y(e,i={}){switch(e.kind){case"csv":{let t=P.parse(e.text,{skipEmptyLines:!0});if(t.errors?.length&&t.data.length===0)throw new Error(`ingest: CSV parse failed - ${t.errors[0].message}`);let n=t.data;if(n.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let c=n[0].map(o=>(o??"").trim());return f(c.map(o=>({name:o})),n.slice(1),i)}case"grid":{if(!e.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return f(e.header.map(t=>({name:(t??"").trim()})),e.rows??[],i)}case"table":{if(!e.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let t=e.columns.map(n=>n.name);return f(e.columns,h(e.rows??[],t),i)}case"objects":{let t=e.rows??[],n=e.columns?.length?e.columns:U(t,i.columnScanLimit??C).map(c=>({name:c}));if(!n.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return f(n,h(t,n.map(c=>c.name)),i)}case"sql":{if(!e.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let t=e.schema.map(n=>{let c=B(n.dataType);return{name:n.name,dataType:c,isMeasure:n.isMeasure,format:n.format,description:n.description}});return f(t,h(e.rows??[],t.map(n=>n.name)),i)}default:{let t=e;throw new Error(`ingest: unknown source kind '${t?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{L as a,T as b,y as c,B as d,Y as e};
2
+ import{H as D,O as E}from"./chunk-WG6XYZLU.mjs";import{v as S}from"./chunk-ILHBRGIO.mjs";import P from"papaparse";function L(e){if(!e)return".";try{return new Intl.NumberFormat(e).formatToParts(1.5).find(t=>t.type==="decimal")?.value===","?",":"."}catch{return"."}}var x="[ \\u00A0\\u202F]",p="(?:[eE][+-]?\\d+)?",O=new RegExp(`^[+-]?(?:\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.\\d+)?${p}$`),k=new RegExp(`^[+-]?(?:\\d{1,3}(?:\\.\\d{3})+|\\d{1,3}(?:${x}\\d{3})+|\\d+)(?:,\\d+)?${p}$`),N=/^[+-]?\d{1,3}[.,]\d{3}$/,_=[/^[+-]?\d{1,3}(?:,\d{3}){2,}$/,new RegExp(`^[+-]?(?:\\d{1,3}(?:,\\d{3})+|\\d+)\\.\\d+${p}$`)],j=[/^[+-]?\d{1,3}(?:\.\d{3}){2,}$/,new RegExp(`^[+-]?(?:\\d{1,3}(?:\\.\\d{3})+|\\d{1,3}(?:${x}\\d{3})+|\\d+),\\d+${p}$`)];function T(e,i){let t=0,n=0;for(let c of e){if(typeof c!="string")continue;let o=c.trim();o===""||N.test(o)||(_.some(s=>s.test(o))?t++:j.some(s=>s.test(o))&&n++)}return n>0&&t===0?",":t>0?".":L(i)}function y(e,i){let t=String(e??"").trim();return t===""?null:i===","?k.test(t)?parseFloat(t.replace(/[.   ]/g,"").replace(",",".")):null:O.test(t)?parseFloat(t.replace(/,/g,"")):null}function R(e,i){return y(e,i)!==null}var C=500,M=/^[+-]?\d{1,15}$/,q=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,F=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function V(e,i="."){let t=0,n=0,c=0,o=0;for(let s of e){if(s==null)continue;if(typeof s=="number"){o++,n++,Number.isInteger(s)&&t++;continue}if(s instanceof Date){o++,c++;continue}if(typeof s=="boolean"){o++;continue}let l=String(s).trim();if(l!==""){if(o++,M.test(l)){t++,n++;continue}if(R(l,i)){n++;continue}if((q.test(l)||F.test(l))&&!isNaN(Date.parse(l))){c++;continue}}}return o===0?"String":c===o?"DateTime":t===o?"Integer":n===o?"Decimal":"String"}function v(e,i,t="."){if(e==null)return null;if(typeof e=="number")return i==="String"?String(e):e;if(e instanceof Date)return i==="DateTime"?e:e.toISOString();if(typeof e=="boolean")return String(e);let n=String(e).trim();if(n==="")return null;switch(i){case"Integer":return M.test(n)?parseInt(n,10):null;case"Decimal":return y(n,t);case"DateTime":return S(n);default:return n}}function B(e){let i=(e||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(i)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(i)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(i)?"DateTime":(/^(bit|bool|boolean)$/.test(i),"String")}function f(e,i,t){if(e.length===0)throw new Error("ingest: no columns were resolved from the source. Supply column descriptors, or use a source shape that carries them (grid/table/objects/sql).");let n=e.length,c=e.map((r,a)=>i.slice(0,C).map(m=>m?.[a])),o=c.map(r=>T(r,t.locale)),s=e.map((r,a)=>r.dataType??V(c[a],o[a])),l=new Set((t.measures??[]).map(r=>r.toLowerCase())),A=new Set((t.dimensions??[]).map(r=>r.toLowerCase())),I=new Set((t.nonAdditive??[]).map(r=>r.toLowerCase())),$=e.map((r,a)=>{let m=r.name.toLowerCase(),u=r.isMeasure??((s[a]==="Integer"||s[a]==="Decimal")&&!D(r.name));l.has(m)&&(u=!0),A.has(m)&&(u=!1);let b={name:r.name,dataType:s[a],isMeasure:u};return u&&I.has(m)&&(b.discourageAggregationAcrossGroups=!0),b}),d=new E;d.dedupRows=t.dedup!==!1,d.setColumns($);for(let r=0;r<i.length;r++){let a=i[r];d.addRow(Array.from({length:n},(m,u)=>v(a?.[u],s[u],o[u])),r)}let w=d.getColumnsWithStats(t.privacyLevel??"20",t.locale??"en"),g=new Map(w.map(r=>[r.name,r]));e.forEach(r=>{let a=g.get(r.name);a&&(r.format&&(a.modelFormat=r.format),r.description&&(a.modelDesc=r.description))});for(let[r,a]of Object.entries(t.formats??{})){let m=g.get(r);m&&(m.modelFormat=a)}for(let[r,a]of Object.entries(t.descriptions??{})){let m=g.get(r);m&&(m.modelDesc=a)}for(let r of t.groupBy??[]){let a=g.get(r);a&&(a.isGrouping=!0)}return{columns:w,rows:d.toObjectArray(),totalRows:d.getRowCount(),index:d}}function h(e,i){return e.map(t=>Array.isArray(t)?t:i.map(n=>t[n]))}function U(e,i){let t=[],n=new Set,c=Math.min(e.length,Math.max(1,i));for(let o=0;o<c;o++){let s=e[o];if(!(!s||typeof s!="object"))for(let l of Object.keys(s))n.has(l)||(n.add(l),t.push(l))}return t}function Y(e,i={}){switch(e.kind){case"csv":{let t=P.parse(e.text,{skipEmptyLines:!0});if(t.errors?.length&&t.data.length===0)throw new Error(`ingest: CSV parse failed - ${t.errors[0].message}`);let n=t.data;if(n.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let c=n[0].map(o=>(o??"").trim());return f(c.map(o=>({name:o})),n.slice(1),i)}case"grid":{if(!e.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return f(e.header.map(t=>({name:(t??"").trim()})),e.rows??[],i)}case"table":{if(!e.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let t=e.columns.map(n=>n.name);return f(e.columns,h(e.rows??[],t),i)}case"objects":{let t=e.rows??[],n=e.columns?.length?e.columns:U(t,i.columnScanLimit??C).map(c=>({name:c}));if(!n.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return f(n,h(t,n.map(c=>c.name)),i)}case"sql":{if(!e.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let t=e.schema.map(n=>{let c=B(n.dataType);return{name:n.name,dataType:c,isMeasure:n.isMeasure,format:n.format,description:n.description}});return f(t,h(e.rows??[],t.map(n=>n.name)),i)}default:{let t=e;throw new Error(`ingest: unknown source kind '${t?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{L as a,T as b,y as c,B as d,Y as e};
@@ -0,0 +1,2 @@
1
+ /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
+ import{a as re}from"./chunk-QEH7WTLB.mjs";import{a as se,b as oe}from"./chunk-2LR73DNS.mjs";import{c as Ne}from"./chunk-C5I73OM2.mjs";import{b as Re,f as Te}from"./chunk-TPVDJHU6.mjs";import{a as Me,b as xe,c as ie}from"./chunk-35Z7JCND.mjs";import{e as ye,f as H,p as Se,q as K,r as _e,s as Ae,v as ce,x as Ce}from"./chunk-ILHBRGIO.mjs";var st=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],ot=[7,72,-172,-52];function Ee(t,e,n){return t>=n[0]&&t<=n[1]&&e>=n[2]&&e<=n[3]}var Z=t=>Math.round(t*10)/10;function Ie(t,e=3){let n=[],r=[],i=0,s=0;for(let l of t){let u=l?.lat,c=l?.lon;if(typeof u!="number"||typeof c!="number"||!isFinite(u)||!isFinite(c)||u<-90||u>90||c<-180||c>180)continue;n.push(u),r.push(c);let d=l?.country?String(l.country).trim().toUpperCase():"",f=d?ae(d):null;f?((d==="US"||d==="USA")&&i++,f==="north-america"&&s++):(st.some(m=>Ee(u,c,m))&&i++,Ee(u,c,ot)&&s++)}let o=n.length;return o<e?null:(n.sort((l,u)=>l-u),r.sort((l,u)=>l-u),{pctUsa:Z(i/o*100),pctNa:Z(s/o*100),latP5:Z(K(n,.05)),latP95:Z(K(n,.95)),lonP5:Z(K(r,.05)),lonP95:Z(K(r,.95)),n:o})}var ve={"north-america":"AG AI AW BB BL BM BQ BS BZ CA CR CU CW DM DO GD GL GP GT HN HT JM KN KY LC MF MQ MS MX NI PA PM PR SV SX TC TT US VC VG VI","south-america":"AR BO BR CL CO EC FK GF GY PE PY SR UY VE",europe:"AD AL AT AX BA BE BG BY CH CY CZ DE DK EE ES FI FO FR GB GG GI GR HR HU IE IM IS IT JE LI LT LU LV MC MD ME MK MT NL NO PL PT RO RS RU SE SI SJ SK SM UA VA",africa:"AO BF BI BJ BW CD CF CG CI CM CV DJ DZ EG EH ER ET GA GH GM GN GQ GW KE KM LR LS LY MA MG ML MR MU MW MZ NA NE NG RE RW SC SD SH SL SN SO SS ST SZ TD TG TN TZ UG YT ZA ZM ZW",asia:"AE AF AM AZ BD BH BN BT CC CN CX GE HK ID IL IN IO IQ IR JO JP KG KH KP KR KW KZ LA LB LK MM MN MO MV MY NP OM PH PK PS QA SA SG SY TH TJ TL TM TR TW UZ VN YE",oceania:"AS AU CK FJ FM GU KI MH MP NC NF NR NU NZ PF PG PN PW SB TK TO TV UM VU WF WS",antarctica:"AQ BV GS HM TF"},q=(()=>{let t=new Map;for(let e of Object.keys(ve))for(let n of ve[e].split(/\s+/))n&&t.set(n,e);return t})();function at(t){for(let[e,n]of t){let r=q.get(e);r&&!q.has(n)&&q.set(n,r)}}at(Re);function ae(t){if(!t)return null;let e=String(t).trim().toUpperCase();if(!e)return null;let n=q.get(e);if(n)return n;let r=Te(String(t));return r?q.get(r)??null:null}function Nn(t,e=2){return me(t.map(n=>[n,1]),e)}function me(t,e=2){let n=new Map,r=0;for(let[o,l]of t){let u=ae(o);if(!u)continue;let c=typeof l=="number"&&isFinite(l)&&l>0?l:1;n.set(u,(n.get(u)??0)+c),r+=c}if(r<e||!n.size)return null;let i="europe",s=-1;for(let o of Array.from(n.keys()).sort()){let l=n.get(o);l>s&&(i=o,s=l)}return{dominantGeoRegion:i,dominantGeoRegionPct:Z(s/r*100),regionCount:n.size,n:r}}import et from"papaparse";var ut=[["Lu",/^\p{Lu}$/u],["Ll",/^\p{Ll}$/u],["Lt",/^\p{Lt}$/u],["Lm",/^\p{Lm}$/u],["Lo",/^\p{Lo}$/u],["Mn",/^\p{Mn}$/u],["Mc",/^\p{Mc}$/u],["Nd",/^\p{Nd}$/u]];function ue(t){for(let[e,n]of ut)if(n.test(t))return e;return null}var lt=[{id:"ascii",test:/^[A-Za-z]$/,ranges:[[65,90],[97,122]]},{id:"latin",test:/^[\u00C0-\u017F]$/u,ranges:[[192,383]]},{id:"cyrillic",test:/^[\u0400-\u045F\u0490-\u0491]$/u,ranges:[[1024,1119],[1168,1169]]},{id:"greek",test:/^[\u0386-\u03CE]$/u,ranges:[[902,974]]},{id:"han",test:/^[\u4E00-\u9FFF]$/u,ranges:[[19968,40959]]},{id:"hiragana",test:/^\p{Script=Hiragana}$/u,ranges:[[12353,12447]]},{id:"katakana",test:/^\p{Script=Katakana}$/u,ranges:[[12448,12543]]},{id:"hangul",test:/^[\uAC00-\uD7A3]$/u,ranges:[[44032,55203]]},{id:"arabic",test:/^[\u0620-\u0652\u0671-\u06D3]$/u,ranges:[[1568,1618],[1649,1747]]},{id:"hebrew",test:/^[\u05B0-\u05EA]$/u,ranges:[[1456,1514]]},{id:"devanagari",test:/^\p{Script=Devanagari}$/u,ranges:[[2304,2431]]},{id:"thai",test:/^\p{Script=Thai}$/u,ranges:[[3585,3662]]}],le=new Map;function we(t,e,n,r){let i=le.get(t);if(i)return i;let s=[];for(let[o,l]of e)for(let u=o;u<=l;u++){let c=String.fromCodePoint(u);ue(c)===n&&(r&&!r.test(c)||s.push(c))}return le.set(t,s),s}function ct(t){let n=t.codePointAt(0);for(let o=0;o<9&&ue(String.fromCodePoint(n-1))==="Nd";o++)n--;let r="nd:"+n.toString(16),i=le.get(r);if(i)return i;let s=[];for(let o=n;o<n+10;o++){let l=String.fromCodePoint(o);ue(l)==="Nd"&&s.push(l)}return le.set(r,s),s}function mt(t,e){if(e==="Nd")return ct(t);for(let i of lt)if(i.test.test(t))return we(i.id+":"+e,i.ranges,e,i.id==="ascii"?null:i.test);let r=t.codePointAt(0)&-128;return we("block:"+r.toString(16)+":"+e,[[r,r+127]],e,null)}function dt(t,e,n,r){let i=t.filter(s=>!e.has(s));return i.length===0&&(i=t.filter(s=>s!==n)),i.length===0?n:i[Math.min(i.length-1,Math.floor(r()*i.length))]}var ft=/^[\p{L}\p{M}\p{Nd}]$/u,Le=/^[\p{L}\p{Nd}]$/u;function De(t,e){if(!t)return t??"";let n=new Set(Array.from(t)),r=d=>{let f=ue(d);return!f||!ft.test(d)?d:dt(mt(d,f),n,d,e)},i=d=>{let f=[];for(let m of d)f.push(r(m)),Le.test(m)&&e()<.2&&f.push(r(m));if(f.length>6){let m=Math.floor(e()*Math.min(3,f.length-6));for(let R=0;R<m;R++)for(let C=0;C<5;C++){let P=Math.floor(e()*f.length);if(Le.test(f[P])){f.splice(P,1);break}}}return f.join("")};if(!(t.includes("@")&&t.includes(".")))return i(t);let[o,l=""]=t.split("@"),u=l.endsWith(".com"),c=u?l.slice(0,-4):l;return`${i(o)}@${i(c)}${u?".com":""}`}var gt=["rate","ratio","pct","percent","percentage","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","utilisation","z[_-]?score","average","avg","mean","median","stddev","variance","gpa","percentile","quantile","efficiency","accuracy","probability","multiplier","coefficient","correlation","occupancy","age","bmi","temperature","density","pressure","humidity","ph","velocity","speed","elevation","altitude","latency","throughput","bandwidth","iops","ppm","ppb","dpmo","bps","temperatuur","temperatur","temperatura","teplota","lampotila","homerseklet","sicaklik","pression","presion","pressao","pressione","druck","tryck","tlak","paine","nyomas","presiune","humidite","humedad","umidade","umidita","feuchtigkeit","vochtigheid","kosteus","vlhkost","vitesse","velocidad","velocidade","velocita","geschwindigkeit","snelheid","hastighet","hastighed","rychlost","nopeus","sebesseg","brzina","predkosc","densite","densidad","densidade","densita","dichte","dichtheid","hustota","tiheys","gustoca","moyenne","mediane","promedio","mediana","gemiddelde","durchschnitt","mittelwert","genomsnitt","gennemsnit","gjennomsnitt","keskiarvo","atlag","ortalama","prosjek","srednia","prumer","priemer","medie","taux","tasa","taxa","tasso","verhaltnis","verhouding","aandeel","anteil","andel","osuus","podil","udzial","udio","pourcentage","porcentaje","percentual","prozent","procent","prosentti","szazalek","yuzde","participacion","participacao","pondere","omjer","arany","oran","rata","leeftijd","edad","idade","wiek","eletkor","varsta","puntuacion","pontuacao","punteggio","betyg","ocena","indice","indeks","wskaznik","puan"],pt=["pct","percent","percentage","rate","ratio","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","utilisation","gpa","percentile","quantile","bmi","density","pressure","humidity","velocity","efficiency","occupancy","latency","throughput","bandwidth","iops","ppm","ppb","dpmo","bps"],ht=["latitude","longitude"],bt=["latitude","longitude"];function X(t){return ye(t)}var de=["somme de","suma de","soma de","summe von","som van","somma di","summa av","sum av","sum af","soucet z","suma z","totaal van","total de","toplam","osszeg","nombre de","recuento de","contagem de","anzahl von","aantal van","conteggio di","antal av","lukumaara","pocet z"],Pe=["moyenne de","promedio de","media de","media di","durchschnitt von","gemiddelde van","medelvarde av","genomsnitt av","gennemsnit af","keskiarvo","atlag","ortalama","prumer z","srednia z","medie de","minimum de","minimo de","minimo di","minimum von","maximum de","maximo de","massimo di","maximum von"];function yt(t){return[...t].sort((e,n)=>n.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var ke=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+yt(de)+")\\s+)","i"),St=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,_t=new RegExp("\\b("+gt.join("|")+")\\b|("+pt.join("|")+")$","i"),At=new RegExp("\\b("+ht.join("|")+")\\b|("+bt.join("|")+")$","i");function Fe(t){if(!t)return"";let e=String(t),n=ke.exec(X(e));return(n?e.slice(n[0].length):e).trim()}function Ct(t){return!!t&&ke.test(X(String(t)))}var Mt=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],Oe=new RegExp("^\\s*("+[...Mt].sort((t,e)=>e.length-t.length).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function Ge(t){if(t==null)return"";let e=String(t),n=Oe.exec(e);if(!n)return e;let r=l=>l.toLowerCase().replace(/\s+/g," ").trim(),i=r(n[1]),s=e.slice(n[0].length),o=0;for(;o<8;){let l=Oe.exec(s);if(!l||r(l[1])!==i)break;let u=s.slice(l[0].length);if(u.trim()==="")break;s=u,o++}return o===0?e:e.slice(0,n[0].length)+s}function fe(t,e){if(!t||!e)return!1;let n=String(t);for(let r of e){let i=r?.hostName;if(i&&i!==r?.name&&n.includes(i))return!0}return!1}var We={Sum:["Sum of "],Avg:["Average of "],Average:["Average of "],Count:["Count of "],CountNonNull:["Count of "],Min:["Min of ","First ","Earliest "],Max:["Max of ","Last ","Latest "],Median:["Median of "],StandardDeviation:["Standard deviation of "],Variance:["Variance of "]},xt=new RegExp("^("+Object.keys(We).join("|")+")\\((.+)\\)$");function Be(t){if(!t)return[];let e=xt.exec(String(t).trim());if(!e)return[];let n=We[e[1]],r=e[2],i=[];for(let s=r.indexOf(".");s>=0;s=r.indexOf(".",s+1)){if(s===0)continue;let o=r.slice(s+1);if(o.trim()!=="")for(let l of n){let u=l+o;i.includes(u)||i.push(u)}}return i}function Rt(t){let e=Fe(t);return e.length===0?"":e.replace(St," ")}function ze(t,e){if(!e)return!1;let n=Fe(e);return t.test(X(Rt(e)))||t.test(X(n))||t.test(X(H(n).join(" ")))}function $e(t){return ze(At,t)}function Tt(t){return ze(_t,t)||$e(t)}var Ue=/int|double|decimal|single|float|number|currency|money/i;function Nt(t){let e=String(t?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||t?.isMeasure===!0||Ue.test(String(t?.dataType??""))?"Continuous":"Categorical"}function Et(t){return t?.isMeasure===!0||Ue.test(String(t?.dataType??""))}function Ve(t){let e=t??{},n=Nt(e);if(n!=="Continuous")return{nature:n,additivity:"unknown",basis:"role",suppressed:!1};if($e(e.name))return{nature:n,additivity:"positional",basis:"name",suppressed:!0};let r=String(e.additivity??"").trim().toLowerCase();if(!(r==="additive"&&Ct(e.name))){if(r==="additive")return{nature:n,additivity:"additive",basis:"measured",suppressed:!1};if(r==="part_of_whole")return{nature:n,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(r==="intensive_rate")return{nature:n,additivity:"intensive_rate",basis:"measured",suppressed:!1}}return e.discourageAggregationAcrossGroups===!0?{nature:n,additivity:"intensive_rate",basis:"host-flag",suppressed:!1}:Tt(e.name)?{nature:n,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:n,additivity:"additive",basis:"default",suppressed:!1}}function Ke(t){let e=Ve(t),n=t??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return Et(n)?["median","average","min","max","first","distinctcount","count"]:["first","distinctcount","count"];switch(e.additivity){case"positional":return["min","max","count","distinctcount","first"];case"intensive_rate":return["average","median","min","max","count","distinctcount","first"];default:return["sum","average","median","min","max","count","distinctcount","first"]}}function Ln(t){return Ke(t)[0]}function Dn(t,e){return Ke(t).indexOf(e)>=0}function On(t,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let n=Ve(t);return n.additivity==="additive"||n.additivity==="part_of_whole"||n.additivity==="unknown"}var vt=/^[A-Za-z_$][A-Za-z0-9_$]*$/,It=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),wt=new RegExp([String.raw`\bisMeasure\b`,String.raw`\bdataType\b`,String.raw`\bcolumns\s*\[\s*-?\d`,String.raw`\.iloc\s*\[[^\]]*,`,String.raw`\.iat\s*\[`,String.raw`\bselect_dtypes\b`,String.raw`\b_get_numeric_data\b`,String.raw`\bis_numeric_dtype\b`,String.raw`\bfor\s+\w+\s+in\s+(?:list\s*\(\s*)?df\.columns\b`,String.raw`\bdf\.columns\s*\.\s*(?:tolist|to_list|difference|drop)\b`,String.raw`\bdf\.dtypes\b`,String.raw`\bObject\s*\.\s*(?:keys|values|entries)\s*\(\s*(?:rows|data|df)?\s*\[\s*0\s*\]`,String.raw`\b(?:row|rw|r)\s*\[\s*\d+\s*\]`].join("|"));function J(t,e){if(!t||!e)return!1;let n=It(e);return new RegExp("['\"`]"+n+"['\"`]").test(t)?!0:vt.test(e)&&new RegExp("\\."+n+"(?![A-Za-z0-9_$])").test(t)}function Lt(t){return!!t&&wt.test(t)}function kn(t,e,n){return t?Lt(t)?[...e]:[...n,...e].some(r=>J(t,r))?e.filter(r=>J(t,r)):[...e]:[]}var Dt=5,Ot=6,Pt=3,j=864e5,kt=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Ft=/^(\d{4})[-/](\d{1,2})$/,Gt=/^(\d{4})[-\s]?Q([1-4])$/i,Wt=/^Q([1-4])[-\s](\d{4})$/i,Bt=/^(\d{4})$/,zt=/^(\d{4})(0[1-9]|1[0-2])$/,$t=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/,Ut=/^(\D+?)[\s\-/.,']*((?:19|20)\d{2})$/u,Vt=/^((?:19|20)\d{2})[\s\-/.,']+(\D+)$/u;function Ye(t,e){let n=se(t);if(!n)return 0;if(n==="sept")return 9;for(let r of e&&!/^en\b/i.test(e)?["en",e]:["en"]){let i=oe(r)[n];if(i!==void 0)return i+1}return 0}function V(t,e,n,r=0,i=0,s=0){if(!(t>=1&&e>=1&&e<=12&&n>=1&&n<=31))return null;let o=Date.UTC(t,e-1,n,r,i,s);if(!Number.isFinite(o))return null;let l=u=>u<10?"0"+u:String(u);return{ms:o,y:t,m:e,d:n,iso:`${t}-${l(e)}-${l(n)}`}}function Kt(t,e){let n=[],r="";for(let u=0;u<e.length;u++){if(e[u]!=="%"){r+=e[u].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");continue}switch(e[++u]){case"Y":n.push("Y"),r+="(\\d{4})";break;case"m":n.push("m"),r+="(\\d{1,2})";break;case"d":n.push("d"),r+="(\\d{1,2})";break;case"H":case"M":case"S":r+="\\d{1,2}";break;case"%":r+="%";break;default:return null}}let i=new RegExp("^"+r+"$").exec(t);if(!i)return null;let s=0,o=1,l=1;return n.forEach((u,c)=>{let d=+i[c+1];u==="Y"?s=d:u==="m"?o=d:l=d}),s?V(s,o,l):null}function ge(t,e,n){let r=(t??"").trim();if(r==="")return null;if(e){let s=Kt(r,e);return s||null}let i=kt.exec(r);if(i)return V(+i[1],+i[2],+i[3],+(i[4]??0),+(i[5]??0),+(i[6]??0));if(i=Gt.exec(r),i)return V(+i[1],(+i[2]-1)*3+1,1);if(i=Wt.exec(r),i)return V(+i[2],(+i[1]-1)*3+1,1);if(i=Ft.exec(r),i&&+i[2]>=1&&+i[2]<=12)return V(+i[1],+i[2],1);if(i=$t.exec(r),i)return V(+i[1],+i[2],+i[3]);if(i=zt.exec(r),i)return V(+i[1],+i[2],1);if(i=Bt.exec(r),i){let s=+i[1];return s>=1900&&s<=2100?V(s,1,1):null}if(i=Ut.exec(r),i){let s=Ye(i[1],n);return s?V(+i[2],s,1):null}if(i=Vt.exec(r),i){let s=Ye(i[2],n);return s?V(+i[1],s,1):null}return null}function He(t){let e=new Date(t).getUTCDay();return e>=1&&e<=5}function Ze(t,e){if(e<=t)return 0;let n=Math.round((e-t)/j),r=Math.floor(n/7),i=r*5,s=t+r*7*j;for(;s<e;)He(s)&&i++,s+=j;return i}function Yt(t){if(t.length===0)return 0;let e=[...t].sort((r,i)=>r-i),n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2}function Ht(t){return t>0?t<.95?"hour":t<=1.05?"day":t>=6.5&&t<=7.5?"week":t>=27&&t<=31.5?"month":t>=88&&t<=93?"quarter":t>=362&&t<=368?"year":"irregular":"irregular"}function ee(t,e,n,r){switch(n){case"year":return e.y-t.y;case"quarter":return e.y*4+Math.floor((e.m-1)/3)-(t.y*4+Math.floor((t.m-1)/3));case"month":return e.y*12+e.m-(t.y*12+t.m);case"week":return Math.round((e.ms-t.ms)/(7*j));case"weekday":return Ze(t.ms,e.ms);case"day":return Math.round((e.ms-t.ms)/j);default:return r>0?Math.round((e.ms-t.ms)/r):0}}function Xe(t,e){return pe(t,e)?.cadence??null}function pe(t,e){let n=e?.gapFactor??Dt,r=0,i=0,s=new Map;for(let p of t){if(p==null||p==="")continue;r++;let W=ge(String(p),e?.pattern,e?.locale);W&&(i++,s.set(W.ms,W))}let o=[...s.values()].sort((p,W)=>p.ms-W.ms);if(o.length<Pt||r>0&&i/r<.8)return null;let l=o[o.length-1].ms-o[0].ms;if(l<=0)return null;let u=[];for(let p=1;p<o.length;p++)u.push(o[p].ms-o[p-1].ms);let c=Yt(u);if(!(c>0))return null;let d=Ht(c/j);d==="day"&&l>=7*j&&o.every(p=>He(p.ms))&&Ze(o[0].ms,o[o.length-1].ms)+1>o.length*.5&&(d="weekday");let f=d==="irregular"?o.length:ee(o[0],o[o.length-1],d,c)+1,m=1,R=1,C=[],P=o[0],y=1;for(let p=1;p<o.length;p++){let W=ee(o[p-1],o[p],d,c);W>m&&(m=W),d!=="irregular"&&W>n?(R++,C.push({from:P.iso,to:o[p-1].iso,points:y}),P=o[p],y=1):y++}C.push({from:P.iso,to:o[o.length-1].iso,points:y});let w={grain:d,points:o.length,expectedPoints:Math.max(f,o.length),coveragePct:Math.round(o.length/Math.max(f,o.length)*1e3)/10,runs:R,largestGapUnits:m,gapFactor:n};return e?.includeBounds&&C.length<=Ot&&(w.runBounds=C),{cadence:w,points:o,stepMs:c}}var Zt=8,Xt=.5,jt=200,Qt=new Set(["category","categories","subcategory","type","types","kind","class","classes","classification","segment","segments","tier","status","priority","severity","grade","level","band","bucket","group","channel","method","mode","stage","phase","period","shift","gender","sex","result","outcome","reason","flag","genre","sector","source"]),qt=["category","classification","segment","status","priority","severity","channel"],Jt=new Set(["UUID","EMAIL_LIKE","URL_LIKE","PHONE_LIKE","NUMERIC_ID","HEX_ID","OPAQUE_ID_ALPHANUMERIC","DATE_STR","BOOLEAN"]);function en(t){let e=H(t);if(e.length===0)return!1;let n=e[e.length-1];return Qt.has(n)?!0:qt.some(r=>n.length>r.length&&n.endsWith(r))}function tn(t){if(t.isMeasure)return"measure";if(t.isTemporal||t.isDatePart||t.isReassembledDate)return"temporal";let e=Array.from(t.values).filter(n=>n!==""&&n!==null&&n!==void 0);return e.length<2||e.length>jt?"cardinality":t.rows>0&&e.length>=t.rows?"row-identity":t.isBinaryFlag?"flag":ie(e,t.locale)!==null?"ordinal":t.identifierNamed||t.dataType==="String"&&Jt.has(re(e))?"identifier":!t.geoKind&&en(t.name)?"attribute":"entity"}function qe(t){let e=-1,n=1/0,r=!1;return t.forEach((i,s)=>{if(tn(i)!=="entity")return;let o=new Set(Array.from(i.values).filter(u=>u!=="")).size,l=!!i.geoKind;(o<n||o===n&&l&&!r)&&(e=s,n=o,r=l)}),e}var je=t=>t<10?"0"+t:String(t);function Qe(t,e){switch(e){case"year":return`${t.y}-01-01`;case"quarter":return`${t.y}-${je(Math.floor((t.m-1)/3)*3+1)}-01`;case"month":return`${t.y}-${je(t.m)}-01`;case"hour":return new Date(t.ms).toISOString().replace(/\.\d{3}Z$/,"Z");default:return t.iso}}function Je(t){let{periods:e,series:n}=t,r=Math.min(e.length,n.length),i=new Set;for(let v=0;v<r;v++)e[v]&&i.add(e[v]);let s=pe(i,{pattern:t.pattern,locale:t.locale});if(!s)return null;let o=s.cadence.grain;if(o==="irregular")return null;let l=s.points[0],u=ee(l,s.points[s.points.length-1],o,s.stepMs)+1;if(u!==s.cadence.expectedPoints)return null;let c=new Map;for(let v of i){let b=ge(v,t.pattern,t.locale);if(!b)continue;let k=ee(l,b,o,s.stepMs);k>=0&&k<u&&c.set(v,{idx:k,stamp:b})}let d=new Map;for(let v=0;v<r;v++){let b=n[v];if(!b)continue;let k=c.get(e[v]);if(!k)continue;let B=d.get(b);B||(B={seen:new Set,lo:k.idx,hi:k.idx,loStamp:k.stamp,hiStamp:k.stamp,order:d.size},d.set(b,B)),B.seen.add(k.idx),k.idx<B.lo&&(B.lo=k.idx,B.loStamp=k.stamp),k.idx>B.hi&&(B.hi=k.idx,B.hiStamp=k.stamp)}if(d.size<2)return null;let f=0;for(let v of d.values())f+=v.seen.size;if(f/(d.size*u)<(t.minFill??Xt))return null;let m=[],R=new Set,C=0,P=0,y=0,w=0,p=0,W=1;for(let[v,b]of d){for(let z of b.seen)R.add(z);if(b.seen.size>=u)continue;let k=[...b.seen].sort((z,a)=>z-a),B=1;for(let z=1;z<k.length;z++)B=Math.max(B,k[z]-k[z-1]);let Y={key:v,acc:b,coverage:b.seen.size/u,before:b.lo,after:u-1-b.hi,interior:b.hi-b.lo+1-b.seen.size,gap:B};m.push(Y),Y.before>0&&C++,Y.after>0&&P++,Y.interior>0&&y++,w=Math.max(w,Y.before),p=Math.max(p,Y.after),W=Math.max(W,B)}if(m.length===0)return null;m.sort((v,b)=>v.coverage-b.coverage||v.acc.order-b.acc.order);let U=m.slice(0,t.maxListed??Zt);return{seriesColumn:t.seriesColumn,grain:o,periods:u,seriesCount:d.size,incompleteSeries:m.length,lateStarts:C,earlyEnds:P,withHoles:y,columnWideMissing:u-R.size,maxMissingBefore:w,maxMissingAfter:p,largestGap:W,series:U.map(v=>{let b={};return t.includeNames&&(b.name=v.key),t.includeDates&&(b.first=Qe(v.acc.loStamp,o),b.last=Qe(v.acc.hiStamp,o)),b.missingBefore=v.before,b.missingAfter=v.after,b.missingInterior=v.interior,b.largestGap=v.gap,b.coverage=Math.round(v.coverage*1e3)/1e3,b}),more:m.length-U.length}}var nn=12,rn=100,sn=.3,on=.9,an=120,un=1900,ln=2100,cn=0,mn=20,dn=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function it(t){if(!t)return!1;let e=H(t);return e.length===0?!1:dn.has(e[e.length-1])}var fn=new Set(["year","yr","fy"]),gn=t=>H(t).some(e=>fn.has(e)),pn=/^(?:(?:19|20)\d{2}(?:[-/ ]?(?:q[1-4]|w(?:0?[1-9]|[1-4]\d|5[0-3])|(?:0?[1-9]|1[0-2])))?|q[1-4][-/ ](?:19|20)\d{2}|(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*[-/ ]?(?:19|20)?\d{2})$/i;function he(t){if(!Number.isInteger(t)||t<190001||t>210012)return!1;let e=t%100;return e>=1&&e<=12}function be(t){if(!Number.isInteger(t)||t<19000101||t>21001231)return!1;let e=Math.floor(t/100)%100,n=t%100;return e>=1&&e<=12&&n>=1&&n<=31}var hn=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,bn=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,yn=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function Sn(t){let e=(t||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}function rt(t,e){let n=0,r=0,i=0,s=0,o=0,l="",u=0,c="",d=0,f=0,m=0,R=0,C=!1;for(let U of t){if(U==null)continue;let v=String(U).trim();if(v==="")continue;n++;let b;if(b=hn.exec(v)){let k=+b[2],B=+b[3];k>=1&&k<=12&&B>=1&&B<=31&&(r++,b[4]!==void 0&&i++,b[6]!==void 0&&s++)}else if(b=bn.exec(v)){let k=+b[3],B=+b[4];k>=1&&k<=12&&B>=1&&B<=31&&(l&&l!==b[2]&&(C=!0),l=b[2],o++)}else if(b=yn.exec(v)){let k=+b[1],B=+b[3];k>=1&&k<=31&&B>=1&&B<=31&&(k<=12||B<=12)&&(c&&c!==b[2]&&(C=!0),c=b[2],u++,k>12&&m++,B>12&&R++,b[5]!==void 0&&d++,b[7]!==void 0&&f++)}if(n>=200)break}if(n<2||(r+o+u)/n<.8||(r>0?1:0)+(o>0?1:0)+(u>0?1:0)!==1||C)return null;if(r>0)return i===r?{pattern:s===r?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(o>0)return{pattern:`%Y${l}%m${l}%d`,orderFrom:"iso"};if(m>0&&R>0)return null;let w,p;m>0?(w=!0,p="values"):R>0?(w=!1,p="values"):(w=!Sn(e),p="locale");let W=w?`%d${c}%m${c}%Y`:`%m${c}%d${c}%Y`;return d===u?{pattern:W+(f===u?" %H:%M:%S":" %H:%M"),orderFrom:p}:{pattern:W,orderFrom:p}}function _n(t,e){if(!e||!/\b(?:19|20)\d{2}\b/.test(t))return!1;let n=t.replace(/\b(?:19|20)\d{2}\b/g,"").replace(/[-/.,]/g," ").trim();if(!n)return!1;let r=se(n);return r.length>0&&e[r]!==void 0}function An(t){let{dataType:e,name:n,isMeasure:r,distinctCount:i}=t;if(e==="DateTime")return!0;if(r)return!1;if(e==="Integer"||e==="Decimal"){let s=t.minNum,o=t.maxNum;if(!(s!=null&&o!=null&&Number.isFinite(s)&&Number.isFinite(o)&&Number.isInteger(s)&&Number.isInteger(o)&&o>=s))return!1;let u=s>=1900&&o<=2100;if(u&&i>=2&&gn(n)||u&&i>=3&&i===o-s+1)return!0;let c=he(s)&&he(o),d=be(s)&&be(o);if(c||d){if(!t.sampleValues)return!0;let f=0,m=0;for(let R of t.sampleValues){if(R==null||R==="")continue;f++;let C=Number(String(R).trim());if(Number.isFinite(C)&&(c?he(C):be(C))&&m++,f>=60)break}if(f>=2&&m===f)return!0}return!1}if(t.sampleValues){let s=t.locale?oe(t.locale):null,o=0,l=0,u=[];for(let c of t.sampleValues){if(c==null||c==="")continue;o++;let d=String(c).trim();if(u.push(d),(pn.test(d)||_n(d,s))&&l++,o>=60)break}if(o>=2&&l/o>=.8||rt(u,t.locale)!==null)return!0}return!1}function Cn(t){let e=X((t||"").trim().toLowerCase());return e.startsWith("sum ")||e.startsWith("total ")?"sum":e.startsWith("average ")||e.startsWith("avg. ")?"avg":e.startsWith("count ")||e.startsWith("distinct count ")||e.startsWith("count (distinct) ")?"count":e.startsWith("min ")||e.startsWith("minimum ")?"min":e.startsWith("max ")||e.startsWith("maximum ")?"max":Pe.some(n=>e.startsWith(n+" "))?/^(minimum|minimo)\b/.test(e)?"min":/^(maximum|maximo|massimo)\b/.test(e)?"max":"avg":de.some(n=>e.startsWith(n+" ")||e===n)?/^(nombre|recuento|contagem|anzahl|aantal|conteggio|antal|lukumaara|pocet)\b/.test(e)?"count":"sum":null}function Mn(t){let{rows:e,measureColIdx:n,measureName:r,candidateDims:i,minNum:s,maxNum:o,discourageAgg:l}=t,u=100,c=.01,d="";for(let m of i){if(m.distinct<2||m.distinct>u)continue;let R=i.filter(p=>p.idx!==m.idx).map(p=>p.idx),C=new Map;for(let p of e){let W=p[n];if(typeof W!="number"||!Number.isFinite(W))continue;let U=R.length?R.map(b=>String(p[b])).join(d):"",v=C.get(U);v||(v={sum:0,cset:new Set},C.set(U,v)),v.sum+=W,v.cset.add(String(p[m.idx]))}let P=0,y=0,w=0;for(let p of C.values())p.cset.size<2||(w++,Math.abs(p.sum-100)<=100*c?P++:Math.abs(p.sum-1)<=1*c&&y++);if(w>=2&&(P/w>=.9||y/w>=.9))return{additivity:"part_of_whole",partOfWholeDim:m.name}}if(l)return{additivity:"intensive_rate"};let f=Cn(r);return f==="avg"||f==="min"||f==="max"?{additivity:"intensive_rate"}:f==="count"?{additivity:"additive"}:f==="sum"?{additivity:"unknown"}:s!=null&&o!=null&&Number.isFinite(s)&&Number.isFinite(o)&&s>=0&&o<=1.0001&&o>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function tt(t){let{dataType:e,isMeasure:n,name:r,distinct:i,nonblank:s,prec:o,maxval:l,minval:u}=t,c=l-u+1,d=c>0?i/c:1,f=s>0?i/s:0,m=e==="Decimal"||o>0;return it(r)?"Categorical":d>=on&&(Me(r)&&i<=an||u>=un&&l<=ln||u>=cn&&l<=mn)?"Ordinal":n||i>nn&&(m||i>=rn||f>=sn)?"Continuous":"Categorical"}function xn(t){let e=null;for(let n=0;n<t.length;n++){let r=t[n];if(typeof r!="string"||r.length===0)continue;let i=r.trim();i.length!==r.length&&(e||(e=t.slice()),e[n]=i)}return e||t}var nt=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;dedupRows=!0;emitLegacyAggAliases=!1;STR(e){return e==null?"":e instanceof Date?this.wholeDayIso(e)??(isNaN(e.getTime())?"":e.toISOString()):e.toString()}getPrecision(e){if(!isFinite(e))return 0;let r=e.toString().split(".")[1];return r?r.length:0}getColumns(){return this._cols}wholeDayIso(e){return Ce(e)}hasTimeComponent(e){return!(e instanceof Date)||isNaN(e.getTime())?!1:this.wholeDayIso(e)===null}getColumnsWithStats(e,n){if(this._computedStatsForLevel==e)return this._cols;let r=0,i=parseInt(e),s=[];for(let a of this._cols){let h=new Map,D=[],N=0,g=0,T=0,I=null,E=null,x=null,G=!1,F=!0,A=!0,M=null,L=!1;for(let S of this._rows){let _=S[r],O=this.STR(_);if(O!=""){if(N+=O.length,h.set(O,(h.get(O)||0)+1),g++,a.dataType=="Integer"||a.dataType=="Decimal"||a.dataType=="DateTime")if((I===null||_<I)&&(I=_),(E===null||_>E)&&(E=_),a.dataType=="Integer"||a.dataType=="Decimal"){if(x===null?x=_:x+=_,a.dataType=="Decimal"){let $=this.getPrecision(_);$>T&&(T=$)}D.push(_)}else G=G||this.hasTimeComponent(_);L&&(_<M?F=!1:_>M&&(A=!1)),M=_,L=!0}}if(g>=3&&(F&&!A?a.sortedDirection="asc":A&&!F?a.sortedDirection="desc":a.sortedDirection="none"),g>0&&h.size>0&&!a.isMeasure){let S=0,_=Number.MAX_SAFE_INTEGER;for(let O of h.values())O>S&&(S=O),O<_&&(_=O);if(a.modalShare=S/g,a.minGroupCount=_===Number.MAX_SAFE_INTEGER?null:_,h.size===2){let O=[...h.keys()].map(ne=>Se(ne).trim().toLowerCase()).sort(),te=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(ne=>O[0]===ne[0]&&O[1]===ne[1]),Q=/^(is|has)[_a-z0-9]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/i.test(a.name);(te||Q)&&(a.isBinaryFlag=!0)}}if(a.dataType=="DateTime"&&(a.dateWithTime=G),a.isTemporal=An({dataType:a.dataType,name:a.name,isMeasure:a.isMeasure,distinctCount:h.size,minNum:typeof I=="number"?I:null,maxNum:typeof E=="number"?E:null,sampleValues:h.keys(),locale:n}),a.isTemporal&&a.dataType==="String"&&!a.isMeasure){let S=rt(h.keys(),n);S&&(a.temporalTextPattern=S.pattern)}if(a.isTemporal&&!a.isMeasure){let S=Xe(h.keys(),{includeBounds:i>=20,pattern:a.temporalTextPattern,locale:n});S&&(a.temporalCadence=S)}this.updateColumnStats10(i,a,g,h,T,E,I),this.updateColumnStats20(i,D,g,x,a,N,G,I,E,T,h,n),!a.isMeasure&&(a.dataType==="Integer"||a.dataType==="Decimal")&&tt({dataType:a.dataType,isMeasure:!1,name:a.name,distinct:h.size,nonblank:g,prec:T,maxval:typeof E=="number"?E:0,minval:typeof I=="number"?I:0})==="Continuous"&&(a.isMeasure=!0,a.geoKind=void 0,a.geoMatchPct=void 0,a.geoAmbiguous=void 0,a.dominantGeoRegion=void 0,a.dominantGeoRegionPct=void 0,a.geoRegionCount=void 0),s[r]=a.isMeasure||h.size>2e3?null:new Set(h.keys()),r++}let o=[];this._cols.forEach((a,h)=>{a.isMeasure||o.push({idx:h,distinct:a.distinctCount??0,name:a.name})}),this._cols.forEach((a,h)=>{if(!a.isMeasure)return;let D=typeof a.lowValue=="number"?a.lowValue:null,N=typeof a.highValue=="number"?a.highValue:null,g=Mn({rows:this._rows,measureColIdx:h,measureName:a.name,candidateDims:o,minNum:D,maxNum:N,discourageAgg:!!a.discourageAggregationAcrossGroups});a.additivity=g.additivity,g.partOfWholeDim&&(a.partOfWholeDim=g.partOfWholeDim)});let l=50,u=4,c=o.filter(a=>a.distinct>=2&&a.distinct<=l);this._cols.forEach((a,h)=>{if(!a.isMeasure)return;let D=[];for(let A of this._rows){let M=A[h];if(M==null||M==="")continue;let L=typeof M=="number"?M:parseFloat(M);isNaN(L)||D.push(L)}if(D.length===0)return;let N=[...D].sort((A,M)=>A-M);if(N[0]===N[N.length-1])a.relativeDispersion=0;else if(N.length>=u){let A=K(N,.5),M=K(N,.1),L=K(N,.9);a.relativeDispersion=Math.abs(A)>1e-9?Math.round((L-M)/Math.abs(A)*1e3)/1e3:void 0}else a.relativeDispersion=void 0;let g=[];for(let A of c){let M=new Set;for(let L of this._rows){let S=L[h];S==null||S===""||M.add(this.STR(L[A.idx])+"")}g.push({otherColumn:A.name,nonBlankGroupCount:M.size})}g.length>0&&(a.nonBlankGroups=g);let T=0;for(let A of D)T+=A;T/=D.length;let I=0;for(let A of D)I+=(A-T)*(A-T);if(I<=1e-12)return;let E=[],x=[],G=A=>{if(A.length<4)return NaN;let M=[...A].sort((S,_)=>S-_),L=S=>M[Math.min(M.length-1,Math.max(0,Math.floor(S*(M.length-1))))];return L(.75)-L(.25)},F=G(D);for(let A of c){let M=new Map;for(let _ of this._rows){let O=_[h];if(O==null||O==="")continue;let $=typeof O=="number"?O:parseFloat(O);if(isNaN($))continue;let te=this.STR(_[A.idx])+"",Q=M.get(te);Q?(Q.s+=$,Q.n++,Q.vals.push($)):M.set(te,{s:$,n:1,vals:[$]})}let L=0;for(let _ of M.values()){let O=_.s/_.n;L+=_.n*(O-T)*(O-T)}E.push({otherColumn:A.name,eta2:Math.round(L/I*1e4)/1e4});let S=[];for(let _ of M.values()){let O=G(_.vals);isNaN(O)||S.push(O)}if(S.length>=2&&isFinite(F)&&F>1e-9){let _=(Math.max(...S)-Math.min(...S))/F;x.push({otherColumn:A.name,spreadRatio:Math.round(_*1e4)/1e4})}}E.length>0&&(a.groupDiscrimination=E),x.length>0&&(a.spreadDiscrimination=x)});let d=.97,f=.8,m=8,R=5,C=this._cols.map((a,h)=>({c:a,i:h})).filter(a=>a.c.isMeasure);for(let a=0;a<C.length;a++)for(let h=a+1;h<C.length;h++){let D=C[a].i,N=C[h].i,g=0,T=0,I=0,E=0,x=0,G=0;for(let L of this._rows){let S=L[D],_=L[N];if(S==null||S===""||_===null||_===void 0||_==="")continue;let O=typeof S=="number"?S:parseFloat(S),$=typeof _=="number"?_:parseFloat(_);isNaN(O)||isNaN($)||(g++,T+=O,I+=$,E+=O*O,x+=$*$,G+=O*$)}if(g<R)continue;let F=g*E-T*T,A=g*x-I*I;if(F<=1e-12||A<=1e-12)continue;let M=(g*G-T*I)/Math.sqrt(F*A);if(Math.abs(M)>=d){let L=C[a].c,S=C[h].c;L.collinearWithMeasures||(L.collinearWithMeasures=[]),S.collinearWithMeasures||(S.collinearWithMeasures=[]),L.collinearWithMeasures.push(S.name),S.collinearWithMeasures.push(L.name)}else if(Math.abs(M)>=f){let L=C[a].c,S=C[h].c,_=Math.round(M*1e3)/1e3;L.correlatedWithMeasures||(L.correlatedWithMeasures=[]),S.correlatedWithMeasures||(S.correlatedWithMeasures=[]),L.correlatedWithMeasures.push({otherColumn:S.name,r:_}),S.correlatedWithMeasures.push({otherColumn:L.name,r:_})}}for(let{c:a}of C)a.correlatedWithMeasures&&(a.correlatedWithMeasures.sort((h,D)=>Math.abs(D.r)-Math.abs(h.r)||(h.otherColumn<D.otherColumn?-1:1)),a.correlatedWithMeasures.length=Math.min(a.correlatedWithMeasures.length,m));for(let a=0;a<this._cols.length;a++){let h=s[a];if(!h||h.size===0)continue;let D=[];for(let N=0;N<this._cols.length;N++){if(N===a)continue;let g=s[N];if(!g||g.size===0)continue;let T=0;for(let E of h)g.has(E)&&T++;let I=Math.round(T/h.size*100);I>0&&D.push({otherColumn:this._cols[N].name,percentShared:I})}D.length>0&&(this._cols[a].sharedValueRatioWithOthers=D)}let P=50,y=[];for(let a=0;a<this._cols.length;a++){let h=s[a];h&&h.size>=2&&h.size<=P&&y.push(a)}if(y.length>=2){let a=new Map,h=(N,g)=>N+":"+g;for(let N=0;N<y.length;N++)for(let g=N+1;g<y.length;g++)a.set(h(y[N],y[g]),new Map);for(let N of this._rows)for(let g=0;g<y.length;g++){let T=this.STR(N[y[g]])+"";for(let I=g+1;I<y.length;I++){let E=""+this.STR(N[y[I]]),x=a.get(h(y[g],y[I])),G=T+""+E;x.set(G,(x.get(G)??0)+1)}}let D=new Map;for(let N=0;N<y.length;N++)for(let g=N+1;g<y.length;g++){let T=y[N],I=y[g],E=s[T].size,x=s[I].size,G=a.get(h(T,I)),F=G.size,A=0;for(let _ of G.values())(A===0||_<A)&&(A=_);let M=Math.round(F/(E*x)*100),L=F===E,S=F===x;if((this._cols[T].categoricalPairStats||=[]).push({otherColumn:this._cols[I].name,fillPct:M,determinesOther:L,minCellCount:A,distinctCombinations:F}),(this._cols[I].categoricalPairStats||=[]).push({otherColumn:this._cols[T].name,fillPct:M,determinesOther:S,minCellCount:A,distinctCombinations:F}),L&&E>x){let _=D.get(T);(!_||x<_.card)&&D.set(T,{name:this._cols[I].name,card:x,ratio:x/E})}if(S&&x>E){let _=D.get(I);(!_||E<_.card)&&D.set(I,{name:this._cols[T].name,card:E,ratio:E/x})}}for(let[N,g]of D)this._cols[N].primaryParentColumn=g.name,this._cols[N].nestingRatio=Math.round(g.ratio*100)/100}let w=6,p=this._rows.length;for(let a=0;a<this._cols.length;a++){let h=this._cols[a];if(h.isMeasure||h.primaryParentColumn)continue;let D=h.distinctCount??0;if(D<=P||p>0&&D>=p)continue;let N=[];for(let g=0;g<this._cols.length;g++){if(g===a)continue;let T=this._cols[g];if(T.isMeasure)continue;let I=T.distinctCount??0;I<2||I>=D||N.push(g)}N.sort((g,T)=>(this._cols[g].distinctCount??0)-(this._cols[T].distinctCount??0));for(let g of N.slice(0,w)){let T=new Map,I=!0;for(let x of this._rows){let G=this.STR(x[a])+"",F=this.STR(x[g])+"",A=T.get(G);if(A===void 0)T.set(G,F);else if(A!==F){I=!1;break}}if(!I)continue;let E=this._cols[g].distinctCount??0;h.primaryParentColumn=this._cols[g].name,h.nestingRatio=Math.round(E/D*100)/100;break}}let W=.01,U=.05,v=.95,b=8,k=8,B=6,Y=500,z=[];for(let a=0;a<this._cols.length&&z.length<k;a++){let h=this._cols[a].dataType;(h==="Double"||h==="Integer"||h==="Decimal")&&z.push(a)}if(z.length>=3&&this._rows.length>=b){let a=Math.min(this._rows.length,Y),h=z.map(E=>{let x=[];for(let A=0;A<a;A++){let M=this._rows[A][E],L=typeof M=="number"?M:parseFloat(String(M).replace(/,/g,""));if(M==null||M===""||!isFinite(L))return null;x.push(L)}let G=x[0],F=!1;for(let A of x)if(A!==G){F=!0;break}return F?x:null}),D=z.map((E,x)=>x).filter(E=>h[E]!==null),N=E=>{let x=E.slice().sort((F,A)=>F-A),G=x.length>>1;return x.length%2?x[G]:(x[G-1]+x[G])/2},g=null,T=[],I=E=>{if(T.length>=3){let x=T.map(M=>h[M]),G=x[0].length,F=new Array(G);for(let M=0;M<G;M++){let L=0;for(let S of x)L+=S[M];F[M]=L}let A=N(F);if(A>0){let M=0;for(let S of F)Math.abs(S-A)<=A*W&&M++;let L=M/G;if(L>=v){let S=1;for(let _ of x){let O=N(_)/A;O<S&&(S=O)}S>=U&&(!g||T.length>g.cols.length)&&(g={cols:T.slice(),total:A,matched:L})}}}if(!(T.length>=B))for(let x=E;x<D.length;x++)T.push(D[x]),I(x+1),T.pop()};if(I(0),g){let E=g,G={columns:E.cols.map(F=>this._cols[z[F]].name),total:Math.round(E.total*1e3)/1e3,matchedPct:Math.round(E.matched*100)/100};for(let F of E.cols)this._cols[z[F]].constantSumGroup=G}}return this.applySeriesCompleteness(i,n,s),this._computedStatsForLevel=e,this._cols}applySeriesCompleteness(e,n,r){for(let m of this._cols)m.seriesCompleteness!==void 0&&delete m.seriesCompleteness;let i=this._cols.map((m,R)=>({c:m,i:R})).filter(({c:m})=>m.isTemporal&&!m.isMeasure&&m.temporalCadence&&m.temporalCadence.grain!=="irregular");if(i.length===0)return;let s=[],o=[];this._cols.forEach((m,R)=>{let C=r[R];C&&(s.push(R),o.push({name:m.name,dataType:m.dataType,isMeasure:!!m.isMeasure,isTemporal:!!m.isTemporal,isDatePart:!!m.isDatePart,isReassembledDate:!!m.isReassembledDate,isBinaryFlag:!!m.isBinaryFlag,geoKind:m.geoKind,identifierNamed:it(m.name),values:C,rows:this._rows.length,locale:n}))});let l=qe(o);if(l<0)return;let u=s[l],c=this._cols[u],d=this._rows.map(m=>this.STR(m[u])),f=e>=20&&(c.dataType!=="String"||Array.isArray(c.safeDistinctValues));for(let{c:m,i:R}of i){let C=Je({periods:this._rows.map(P=>this.STR(P[R])),series:d,seriesColumn:c.name,pattern:m.temporalTextPattern,locale:n,includeDates:e>=20,includeNames:f});C&&(m.seriesCompleteness=C)}}updateColumnStats20(e,n,r,i,s,o,l,u,c,d,f,m){if(e>=20){let R=[...n].sort((y,w)=>y-w),C=Math.floor(R.length/2);if(r>0&&i!=null?s.avgValue=s.dataType=="Integer"?Math.round(i/r):i/r:s.avgValue=null,r>0&&(s.avgLength=o/r),this._rows.length>0){let y=w=>{let p=w instanceof Date?w:typeof w=="string"?ce(w)??new Date(w):new Date(w),W=this.wholeDayIso(p);return W?W+"T00:00:00.000Z":isNaN(p.getTime())?w:p.toISOString().slice(0,10)+"T00:00:00.000Z"};s.dataType!="DateTime"||l||!u?s.lowValue=u:s.lowValue=y(u),s.dataType!="DateTime"||l||!c?s.highValue=c:s.highValue=y(c),s.medianValue=R.length===0?null:R.length%2===0?s.dataType=="Integer"?Math.round((R[C-1]+R[C])/2):(R[C-1]+R[C])/2:R[C],s.numericPrecision=d}if(R.length>0){let y=s.avgValue??0,w=R.length,p=0,W=0;for(let v of R){let b=v-y;p+=b*b,W+=b*b*b}let U=p/w;s.skewness=U===0?0:W/w/Math.pow(Math.sqrt(U),3),s.stdDev=Math.sqrt(U)}i!==null&&(s.sum=i);let P=Array.from(f.entries()).sort((y,w)=>w[1]-y[1]);if(s.topCategories=P.slice(0,10).map(y=>y[1]),!s.isMeasure&&P.length>0){if(s.dataType==="String"){let y=P.map(p=>p[0]);s.formatSignature=re(y);let w=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;s.formatSignature&&!w.test(s.formatSignature)&&(s.avgLength===void 0||s.avgLength>=3)&&(s.isFreeText=!0)}else s.topCategoryValues=P.slice(0,5).map(y=>y[0]);if(e>=20){let y=P.map(p=>p[0]),w=ie(y,m);if(w!==null)s.ordinalPattern=w.pattern,s.orderedDomain=w.orderedDomain;else if(s.dataType==="String"){let p=xe(y);p!==null&&(s.safeDistinctValues=p)}}}if(R.length>=8&&(s.dataType==="Integer"||s.dataType==="Decimal")){let y=w=>R[Math.floor((R.length-1)*w)];s.quantiles={p05:y(.05),p25:y(.25),p75:y(.75),p95:y(.95)}}}if(!s.isMeasure&&f.size>0){let R=Array.from(f.entries()).sort((P,y)=>y[1]-P[1]),C=Ne(R.map(P=>P[0]),s.name,m);if(C!==null&&(s.geoKind=C.geoKind,s.geoMatchPct=C.geoMatchPct,C.geoAmbiguous&&(s.geoAmbiguous=!0),C.geoKind.indexOf("country")===0)){let P=me(R);P&&(s.dominantGeoRegion=P.dominantGeoRegion,s.dominantGeoRegionPct=P.dominantGeoRegionPct,s.geoRegionCount=P.regionCount)}}}updateColumnStats10(e,n,r,i,s,o,l){e>=10&&(n.blankCount=this._rows.length-r,n.distinctCount=i.size+(n.blankCount!=0?1:0),n.valueNature="Categorical",r>0&&(n.dataType==="Integer"||n.dataType==="Decimal"?n.valueNature=tt({dataType:n.dataType,isMeasure:!!n.isMeasure,name:n.name,distinct:i.size,nonblank:r,prec:s,maxval:o,minval:l}):n.dataType==="DateTime"&&(n.valueNature=n.dateWithTime?"Continuous":"Ordinal")))}getRowCount(){return this._rows.length}getLeafCardinality(){if(this._leafCardinality!==null)return this._leafCardinality;let e=[];if(this._cols.forEach((r,i)=>{r.isMeasure||e.push(i)}),e.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let n=new Set;for(let r of this._rows)n.add(JSON.stringify(e.map(i=>r[i])));return this._leafCardinality=n.size,this._leafCardinality}_leafCardinality=null;getGeoExtent(){if(this._geoExtentComputed)return this._geoExtent;this._geoExtentComputed=!0,this._geoExtent=null;let e=o=>String(o||"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z]+/),n=-1,r=-1,i=-1;if(this._cols.forEach((o,l)=>{let u=e(o.name),c=o.dataType==="Integer"||o.dataType==="Decimal";c&&n<0&&u.some(d=>d==="lat"||d==="latitude")?n=l:c&&r<0&&u.some(d=>d==="lon"||d==="lng"||d==="long"||d==="longitude")&&(r=l),i<0&&!o.isMeasure&&typeof o.geoKind=="string"&&o.geoKind.indexOf("country")===0&&(i=l)}),n<0||r<0)return null;let s=[];for(let o of this._rows){let l=o[n],u=o[r],c=l==null||l===""?null:Number(l),d=u==null||u===""?null:Number(u);s.push({lat:c,lon:d,country:i>=0&&ae(this.STR(o[i]))?this.STR(o[i]):null})}return this._geoExtent=Ie(s),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(e){return De(e,Ae)}toObjectArray(){let e=this.liveEnglishAliases();return this._rows.map(n=>{let r={};this._cols.forEach((i,s)=>{r[i.name]=n[s],this.emitLegacyAggAliases&&i.hostName&&i.hostName!==i.name&&!Object.prototype.hasOwnProperty.call(r,i.hostName)&&(r[i.hostName]=n[s])});for(let[i,s]of e)Object.prototype.hasOwnProperty.call(r,s.alias)||(r[s.alias]=n[i]);return r})}async getCSVAsync(e){let n=[],r=e?25:1e7,i=e?4e3:1e7,s=new Map;for(let l of this._rows){let u={};for(let c=0;c<this._cols.length;c++){let d=this._cols[c],f=l[c];if(this.STR(f)!=""){if(e&&d.dataType=="String")if(s.has(f))f=s.get(f);else{let m=this.obfuscateString(f);s.set(f,m),f=m}else if(d.dataType=="DateTime"&&!d.dateWithTime){let m=f instanceof Date?f:typeof f=="string"?ce(f)??new Date(f):new Date(f);f=(this.wholeDayIso(m)??m.toISOString().slice(0,10))+"T00:00:00.000Z"}i-=this.STR(f).length}else f=null;u[c]=f,--i}if(n.push(u),--r,r<=0||i<=0)break}return await et.unparse(n,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return et.unparse([this._cols.map((n,r)=>{if(this.emitLegacyAggAliases&&n.hostName)return this.STR(n.hostName);let i=e.get(r);return this.STR(i&&i.headerName?i.alias:n.name)})])}setHostQueryNames(e){this._hostQueryNames=(e??[]).map(n=>n==null?null:this.STR(n)),this._englishAliases=new Map}aliasesForCode(e){let n=fe(e,this._cols)?this.legacyAliases():[];for(let r of this.englishAliasesFor(e).values())n.push({name:r.name,alias:r.alias,reason:"english-implicit-agg"});return n}armAliasesForCode(e){return this.emitLegacyAggAliases=fe(e,this._cols),this._englishAliases=this.englishAliasesFor(e),this.getArmedAliases()}getArmedAliases(){let e=this.emitLegacyAggAliases?this.legacyAliases():[];for(let n of this.liveEnglishAliases().values())e.push({name:n.name,alias:n.alias,reason:"english-implicit-agg"});return e}legacyAliases(){let e=[];for(let n of this._cols)n&&n.hostName&&n.hostName!==n.name&&e.push({name:this.STR(n.name),alias:this.STR(n.hostName),reason:"doubled-agg-prefix"});return e}englishAliasesFor(e){let n=new Map;if(!e||this._hostQueryNames.length===0||!this._cols||this._cols.length===0)return n;let r=String(e),i=new Set;for(let o of this._cols)o&&(i.add(this.STR(o.name)),o.hostName&&i.add(this.STR(o.hostName)));let s=new Map;for(let o=0;o<this._cols.length;o++){if(!this._cols[o])continue;let l=Be(this._hostQueryNames[o]).filter(u=>!i.has(u)&&J(r,u));l.length===1&&s.set(l[0],[...s.get(l[0])??[],o])}for(let[o,l]of s){if(l.length!==1)continue;let u=this.STR(this._cols[l[0]].name);n.set(l[0],{name:u,alias:o,headerName:!J(r,u)})}return n}liveEnglishAliases(){let e=new Map;for(let[n,r]of this._englishAliases){let i=this._cols?this._cols[n]:null;i&&this.STR(i.name)===r.name&&e.set(n,r)}return e}addRow(e,n){if(this.dedupRows){let r="";for(let s of e)r+=this.STR(s)+"~";let i=_e(r);if(this._rowHashes.has(i))return!1;this._rowHashes.add(i)}return this._rows.push(xn(e)),this._origIndices.push(n??-1),!0}getOriginalRowIndex(e){return e<0||e>=this._origIndices.length?-1:this._origIndices[e]}reset(){this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null,this._hostQueryNames=[],this._englishAliases=new Map}setColumns(e){if(this._cols=e,!e||e.length===0)return;let n=new Set(e.map(r=>this.STR(r?.name)));for(let r of e){if(!r)continue;let i=this.STR(r.name),s=Ge(i);!s||s===i||n.has(s)||(n.delete(i),n.add(s),r.hostName=i,r.name=s)}}};export{Ie as a,at as b,ae as c,Nn as d,gt as e,pt as f,ht as g,bt as h,Fe as i,Ct as j,Ge as k,fe as l,Be as m,$e as n,Tt as o,Ve as p,Ke as q,Ln as r,Dn as s,On as t,J as u,Lt as v,kn as w,Dt as x,Ot as y,ge as z,Xe as A,Zt as B,Xt as C,jt as D,tn as E,qe as F,Je as G,it as H,rt as I,An as J,Cn as K,Mn as L,tt as M,xn as N,nt as O};
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
- import{a as zn,b as Bn}from"./chunk-UQU75XXR.mjs";import{a as Wn,b as $n,c as Kn,d as Vn,e as f,f as Un,g as Hn,h as Qn}from"./chunk-BIC73LQV.mjs";import{a as Gn,b as On,c as _n,d as Fn,e as En}from"./chunk-ZFTP4NSP.mjs";import{A as Mn,B as An,C as Nn,D as wn,E as kn,F as In,G as Ln,I as Dn,a as Ze,b as Xe,c as Ye,d as Je,e as on,f as rn,g as sn,h as an,i as un,j as ln,k as cn,l as mn,m as fn,n as dn,o as pn,p as gn,q as yn,r as Cn,s as Pn,t as hn,u as Rn,v as Sn,w as xn,x as bn,y as Tn,z as vn}from"./chunk-PFCJESUQ.mjs";import{a as en}from"./chunk-QEH7WTLB.mjs";import{a as nn,b as tn}from"./chunk-2LR73DNS.mjs";import{a as j,b as q,c as He,d as Qe,e as je,f as qe}from"./chunk-C5I73OM2.mjs";import{a as w,f as k,g as R,h as I,i as F,j as _e,k as Fe,l as Q,m as y,n as Ee,o as ze,p as Be,q as L,r as We,s as $e,t as Ke,u as Ve,v as E,w as Ue}from"./chunk-TPVDJHU6.mjs";import"./chunk-5MRZID36.mjs";import{a as De,b as Ge,c as Oe}from"./chunk-35Z7JCND.mjs";import{A as Le,a as ae,b as ue,c as le,d as ce,e as me,f as fe,g as de,h as pe,i as ge,j as ye,k as Ce,l as Pe,m as he,n as Re,o as Se,p as xe,r as be,s as Te,t as ve,u as Me,v as Ae,w as Ne,x as we,y as ke,z as Ie}from"./chunk-ILHBRGIO.mjs";var z=2,Y=400;function W(n){return!!k(n)}function v(n){let e=new Set;for(let t of n){if(t==null)continue;let i=w(String(t));if(!I(i)&&!e.has(i)&&(e.add(i),e.size>=Y))break}return Array.from(e)}function T(n){let e=v(n);if(e.length===0||$(n)<95)return!1;let t=e.filter(c=>W(c)&&!y(c)).length,i=e.filter(c=>!W(c)&&!!y(c)).length;return t>=1&&t>=i}function Z(n,e){if(!y(n))return!1;let t=k(n);return t?e==="world"?!0:Q.has(t):!1}function $(n){let e=v(n);if(e.length===0)return 0;let t=0;for(let i of e)W(i)&&t++;return Math.round(t/e.length*1e3)/10}function D(n){let e=v(n);if(e.length===0)return 0;let t=0;for(let i of e)y(i)&&t++;return Math.round(t/e.length*1e3)/10}function V(n){let e=new Set;for(let t of n){if(t==null)continue;let i=String(t).trim();if(!I(w(i))&&!e.has(i)&&(e.add(i),e.size>=Y))break}return Array.from(e)}function K(n){let e=V(n);if(e.length===0)return 0;let t=0;for(let i of e)L(i).length>0&&t++;return Math.round(t/e.length*1e3)/10}function X(n,e){return q(e,j)?!0:V(n).some(t=>/^\d{5}(-\d{4})?$/.test(t.replace(/\.0+$/,"")))}function jn(n,e){let t=v(n);if(t.length===0)return 0;let i=0;for(let c of t)E(c,e)&&i++;return Math.round(i/t.length*1e3)/10}function B(n,e){let t=0;for(let i of v(n))e(i)&&t++;return t}function qn(n,e){let t=0;for(let i of V(n))e(i)&&t++;return t}function Zn(n,e,t,i,c){let a=[],s=[],r={},C={},x=new Set(n),d=o=>e.map(u=>u[o]);for(let o of["city","country"]){let u=t?.[o];u&&x.has(u)&&(r[o]=u)}let re=new Set(c??n);for(let o of["lat","lon"]){let u=t?.[o];u&&re.has(u)&&(r[o]=u)}let P=t?.zip;if(P&&x.has(P)){let o=d(P),u=K(o);u<95?s.push(`zip=${P} (only ${u}% of values read as ZIPs)`):X(o,P)?r.zip=P:s.push(`zip=${P} (all values are 3-4 digits with nothing to say they are postal)`)}let g=t?.state;if(g&&x.has(g)){let o=d(g),u=v(o);u.length>0&&u.every(m=>Z(m,i))?s.push(`state=${g} (every value is "CA", which is both Canada and California)`):T(o)?(s.push(`state=${g} (every value is a country, not a state)`),r.country||(r.country=g)):D(o)<95?s.push(`state=${g} (only ${D(o)}% of values are states/provinces)`):r.state=g}let h=new Set(Object.values(r).filter(Boolean)),A=n.filter(o=>!h.has(o)&&!o.startsWith("__"));if(!r.state){let o=null;for(let u of A){let m=d(u);if(T(m))continue;let p=D(m);if(p<95)continue;let _=B(m,N=>!!y(N)),se=B(m,N=>!!y(N)&&!Z(N,i));_<z&&se<1||(!o||p>o.pct)&&(o={name:u,pct:p})}o&&(r.state=o.name,h.add(o.name),a.push(`state=${o.name} (${o.pct}% states/provinces)`))}if(!r.zip)for(let o of A){if(h.has(o))continue;let u=d(o),m=K(u);if(!(m<95)&&X(u,o)&&!(qn(u,p=>L(p).length>0)<z)){r.zip=o,h.add(o),a.push(`zip=${o} (${m}% ZIP codes)`);break}}let b=r.country;if(!b||!T(d(b))){let o=null;for(let u of A){if(h.has(u)||!T(d(u)))continue;let m=$(d(u));(!o||m>o.pct)&&(o={name:u,pct:m})}o&&(b&&(s.push(`country=${b} (only ${$(d(b))}% of values are country identifiers; using ${o.name} instead)`),C.country=b),r.country=o.name,h.add(o.name),a.push(`country=${o.name}`))}if(!r.city){let o=null;for(let u of A){if(h.has(u))continue;let m=d(u),p=jn(m,i);p<F||B(m,_=>E(_,i))<z||(!o||p>o.pct)&&(o={name:u,pct:p})}o&&(r.city=o.name,a.push(`city=${o.name} (${o.pct}% known cities)`))}let U=r.country?d(r.country):[],G=!!r.country&&T(U),ie=G?new Set(U.map(o=>k(o==null?null:String(o))).filter(Boolean)).size:0,H=G&&ie>=2,O=!!(r.lat&&r.lon)&&e.some(o=>{let u=+String(o[r.lat]??"").trim(),m=+String(o[r.lon]??"").trim();return isFinite(u)&&isFinite(m)&&u>=-90&&u<=90&&m>=-180&&m<=180&&String(o[r.lat]??"").trim()!==""&&String(o[r.lon]??"").trim()!==""});return r.lat&&r.lon&&!O&&s.push(`lat/lon=${r.lat}/${r.lon} (no row holds a usable coordinate pair)`),r.country&&!H&&!(r.city||r.state||r.zip||O)&&s.push(G?`country=${r.country} (every row resolves to the same country - nothing to place apart)`:`country=${r.country} (values are not country identifiers)`),{bind:!!(r.city||r.state||r.zip||H||O)?r:null,backfilled:a,refused:s,...Object.keys(C).length?{labelFallback:C}:{}}}function J(n,e){let t=e?.freemiumMaxShapeColumns;return typeof t!="number"||!isFinite(t)||t<1?null:!isFinite(n)||n<=t?0:Math.round(n-t)}function Xn(n,e,t){let i=J(n,e);if(i===null||i<=0)return null;let c=typeof e?.freemiumColumnCapPivot=="number"?e.freemiumColumnCapPivot:4,a=i>c?e?.freemiumColumnCapMessageMany:e?.freemiumColumnCapMessageFew;if(typeof a!="string"||a.trim().length===0)return null;let s=a.split("{n}").join(String(i)).split("{fields}").join(i===1?"field":"fields"),r=ee(t);return r.length===0?s:s+" "+r.join(" ")}function ee(n){if(!n||n.length===0)return[];let e=[],t=new Map,i=new Map;for(let a of n){let s=typeof a?.dateGroupId=="string"?a.dateGroupId.trim():"";if(s!==""&&(t.has(s)||(e.push(s),t.set(s,0)),a.isDatePart===!0&&t.set(s,t.get(s)+1),a.isReassembledDate===!0&&!i.has(s))){let r=typeof a.sourceField=="string"?a.sourceField.trim():"",C=typeof a.name=="string"?a.name.trim():"",x=r!==""?r:C;x!==""&&i.set(s,x)}}let c=[];for(let a of e){let s=i.get(a),r=t.get(a)??0;!s||r===0||c.push(`'${s}' is a date hierarchy and counts as ${r+1} fields - bind the date itself instead of its hierarchy.`)}return c}var l=n=>n==null?"":String(n),S=n=>n===!0,ne=n=>{if(typeof n=="number")return Number.isFinite(n)?n:null;if(typeof n=="string"&&n.trim()!==""){let e=Number(n);return Number.isFinite(e)?e:null}return null},Yn=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function te(n,e){let t={};for(let[i,c]of Yn){let a=l(f(n,e+c));a&&(t[i]=a)}return t}function Jn(n){let e=a=>f(n,a),t=e("retryAfterSeconds"),i=te(n,"point"),c=te(n,"destPoint");return Object.keys(c).length&&(i.dest=c),{errorMessage:l(e("errorMessage")),code:l(e("code")),language:l(e("language")),version:Number(e("version")??0),codeSummary:l(e("codeSummary")),chartName:l(e("chartName")??e("chartType")),finalChartName:l(e("finalChartName")),warningMessage:l(e("warningMessage")),outputHash:l(e("outputHash")),validatorToken:l(e("validatorToken")),editCodeKey:l(e("editCodeKey")),signedLLMRequestID:l(e("signedLLMRequestID")),userReply:l(e("userReply")),userReplyOutcome:l(e("userReplyOutcome")),improvementSuggestion:l(e("improvementSuggestion")),geoColumn:l(e("geoColumn")),geoKind:l(e("geoKind")),geoPointCols:Object.keys(i).length?i:null,creditBalanceBefore:ne(e("creditBalanceBefore")),creditCost:ne(e("creditCost")),isServiceError:S(e("isServiceError")),isRateLimited:S(e("isRateLimited")),isRefusal:S(e("isRefusal")),isVersionNotFound:S(e("isVersionNotFound")),isGenerationCancelled:S(e("isGenerationCancelled")),retryAfterSeconds:typeof t=="number"&&Number.isFinite(t)?t:null,servedCorrelationId:l(e("servedCorrelationId"))}}var oe=n=>n==null?void 0:Number(n),M=n=>l(n)||void 0;function et(n){let e=f(n,"charts"),t=f(n,"refused"),i=Array.isArray(e)?e.map(a=>{let s=C=>f(a,C),r=s("recommended");return{name:l(s("chartTypeName")??s("name")),description:l(s("description")??s("chartDesc")),rank:oe(s("rank")),score:oe(s("score")),renderer:M(s("renderer")),language:M(s("language")),isPreview:S(s("isPreview")),recommended:typeof r=="boolean"?r:void 0,viaProjection:M(s("viaProjection")),viaProjectionKey:M(s("viaProjectionKey")),detailNote:M(s("detailNote"))}}).filter(a=>a.name):null,c=Array.isArray(t)?t.map(a=>({name:l(f(a,"chartTypeName")??f(a,"name")),reason:l(f(a,"reason")),isVeto:S(f(a,"isVeto"))})).filter(a=>a.name):[];return{errorMessage:l(f(n,"errorMessage")),charts:i,refused:c,noFitSummary:l(f(n,"noFitSummary"))}}function nt(n){return!n||typeof n!="object"?null:{status:String(f(n,"status")??""),verdictReason:f(n,"verdictReason")??null,instruction:f(n,"instruction")??null,fix:f(n,"fix")??null,errorMessage:f(n,"errorMessage")??null}}export{F as CITY_ROLE_MATCH_PCT,ye as COMPOUND_MIN_STEM,bn as DEFAULT_GAP_FACTOR,Me as DEFAULT_TEMPERATURE,Te as GET_RANDOM,Pe as GLUED_STEM_MIN,rn as INTENSIVE_SUFFIX_TOKENS,on as INTENSIVE_WORD_TOKENS,Dn as IndexedText,Tn as MAX_RUN_BOUNDS,an as POSITIONAL_SUFFIX_TOKENS,sn as POSITIONAL_WORD_TOKENS,zn as PREVIEW_OMITTED_FIELDS,R as ROLE_MATCH_PCT,be as SIMPLE_STRING_HASH,xe as STR,Re as SUBSTRING_MIN,ae as SUPPORTED_LANGUAGES,ue as SUPPORTED_LANGUAGE_CODES,D as admin1MatchPct,yn as allowedAggregations,qe as buildGeoIsoColumn,Ke as buildGeoPointColumns,Ue as cityMatchPct,Ve as cityTagsFor,In as classifyAdditivity,gn as classifyForAggregation,Ln as classifyNumericValueNature,wn as classifyTemporal,mn as codeNeedsLegacyAggNames,Rn as codeReadsColumn,Sn as codeReadsColumnsByRoleOrPosition,cn as collapseRepeatedAggPrefix,xn as columnsTheCodeReads,Ye as countryRegion,Gn as decimalSeparatorOf,Cn as defaultAggregation,On as detectDecimalSeparator,en as detectFormatSignature,He as detectGeo,Oe as detectOrdinalDomain,Nn as detectTextDatePattern,$n as encodePayload,Fn as engineTypeForSqlType,fn as englishImplicitAggNames,me as foldName,Xn as freemiumColumnCapRefusal,J as freemiumColumnsOverCap,ee as freemiumDateHierarchyClauses,he as gluedPrefixStems,Wn as gzipWireText,ln as hasDefaultAggPrefix,pe as hasUnsegmentedScript,kn as hostAggHint,En as ingest,Pn as isAggregationAllowed,I as isBlankLike,Fe as isCityTableLoaded,ve as isDeterministicRefusal,We as isGeoPointAmbiguity,An as isIdentifierName,je as isJoinGeoKind,Un as isNdjsonContentType,De as isOrdinalFriendlyName,Kn as keyedSigner,Ie as localMidnightDateColumns,ke as localMidnightToUtcDay,T as looksLikeCountryColumn,Se as matchNameToken,Mn as measureCadence,Vn as messageSignature,tn as monthLookupFor,pn as nameLooksIntensiveRate,dn as nameLooksPositional,fe as nameWords,Ee as normalizeCountry,Le as normalizeLocalMidnightDates,nn as normalizeMonthKey,w as normalizePlaceName,Be as normalizeZip5,Ae as parseDateStable,Jn as parseGenerateResponse,_n as parseNumberText,et as parseQualifyResponse,nt as parseReviewVerdict,vn as parseTemporalPoint,Bn as payloadPreview,Qn as readGenerateStream,de as readName,f as readWireField,_e as registerCityTable,Xe as registerIso3Regions,y as resolveAdmin1,$e as resolveGeoPoint,ce as resolveLanguage,Zn as resolvePointRoles,Ge as safeDistinctValuesToShip,hn as shareOfTotalIsHonest,un as stripHostAggPrefix,Je as summarizeCountryRegions,Ze as summarizeGeoExtent,le as supportedLanguage,Qe as toGeoIso,ge as unsegmentedRuns,Ne as wholeDayFrame,we as wholeDayIso,Hn as wireResponseFromFetch,Ce as wordEndsWith,K as zipMatchPct,L as zipPrefixCandidates,ze as zipToPrefix3};
2
+ import{a as Un,b as Hn}from"./chunk-UQU75XXR.mjs";import{a as Qn,b as jn,c as qn,d as Xn,e as f,f as Zn,g as Yn,h as Jn}from"./chunk-BIC73LQV.mjs";import{a as Bn,b as Kn,c as Wn,d as $n,e as Vn}from"./chunk-6PU2UEMV.mjs";import{A as vn,B as An,C as Nn,D as In,E as wn,F as Ln,G as kn,H as En,I as _n,J as Dn,K as On,L as Gn,M as Fn,O as zn,a as Xe,b as Ze,c as Ye,d as Je,e as on,f as rn,g as sn,h as an,i as un,j as ln,k as cn,l as mn,m as fn,n as dn,o as pn,p as gn,q as yn,r as Cn,s as Pn,t as Sn,u as hn,v as Rn,w as xn,x as bn,y as Tn,z as Mn}from"./chunk-WG6XYZLU.mjs";import{a as en}from"./chunk-QEH7WTLB.mjs";import{a as nn,b as tn}from"./chunk-2LR73DNS.mjs";import{a as j,b as q,c as He,d as Qe,e as je,f as qe}from"./chunk-C5I73OM2.mjs";import{a as I,f as w,g as h,h as L,i as G,j as Oe,k as Ge,l as Q,m as y,n as Fe,o as ze,p as Be,q as k,r as Ke,s as We,t as $e,u as Ve,v as F,w as Ue}from"./chunk-TPVDJHU6.mjs";import"./chunk-5MRZID36.mjs";import{a as Ee,b as _e,c as De}from"./chunk-35Z7JCND.mjs";import{A as ke,a as ae,b as ue,c as le,d as ce,e as me,f as fe,g as de,h as pe,i as ge,j as ye,k as Ce,l as Pe,m as Se,n as he,o as Re,p as xe,r as be,s as Te,t as Me,u as ve,v as Ae,w as Ne,x as Ie,y as we,z as Le}from"./chunk-ILHBRGIO.mjs";var z=2,Y=400;function K(n){return!!w(n)}function M(n){let e=new Set;for(let t of n){if(t==null)continue;let i=I(String(t));if(!L(i)&&!e.has(i)&&(e.add(i),e.size>=Y))break}return Array.from(e)}function T(n){let e=M(n);if(e.length===0||W(n)<95)return!1;let t=e.filter(c=>K(c)&&!y(c)).length,i=e.filter(c=>!K(c)&&!!y(c)).length;return t>=1&&t>=i}function X(n,e){if(!y(n))return!1;let t=w(n);return t?e==="world"?!0:Q.has(t):!1}function W(n){let e=M(n);if(e.length===0)return 0;let t=0;for(let i of e)K(i)&&t++;return Math.round(t/e.length*1e3)/10}function E(n){let e=M(n);if(e.length===0)return 0;let t=0;for(let i of e)y(i)&&t++;return Math.round(t/e.length*1e3)/10}function V(n){let e=new Set;for(let t of n){if(t==null)continue;let i=String(t).trim();if(!L(I(i))&&!e.has(i)&&(e.add(i),e.size>=Y))break}return Array.from(e)}function $(n){let e=V(n);if(e.length===0)return 0;let t=0;for(let i of e)k(i).length>0&&t++;return Math.round(t/e.length*1e3)/10}function Z(n,e){return q(e,j)?!0:V(n).some(t=>/^\d{5}(-\d{4})?$/.test(t.replace(/\.0+$/,"")))}function et(n,e){let t=M(n);if(t.length===0)return 0;let i=0;for(let c of t)F(c,e)&&i++;return Math.round(i/t.length*1e3)/10}function B(n,e){let t=0;for(let i of M(n))e(i)&&t++;return t}function nt(n,e){let t=0;for(let i of V(n))e(i)&&t++;return t}function tt(n,e,t,i,c){let a=[],s=[],r={},C={},x=new Set(n),d=o=>e.map(u=>u[o]);for(let o of["city","country"]){let u=t?.[o];u&&x.has(u)&&(r[o]=u)}let re=new Set(c??n);for(let o of["lat","lon"]){let u=t?.[o];u&&re.has(u)&&(r[o]=u)}let P=t?.zip;if(P&&x.has(P)){let o=d(P),u=$(o);u<95?s.push(`zip=${P} (only ${u}% of values read as ZIPs)`):Z(o,P)?r.zip=P:s.push(`zip=${P} (all values are 3-4 digits with nothing to say they are postal)`)}let g=t?.state;if(g&&x.has(g)){let o=d(g),u=M(o);u.length>0&&u.every(m=>X(m,i))?s.push(`state=${g} (every value is "CA", which is both Canada and California)`):T(o)?(s.push(`state=${g} (every value is a country, not a state)`),r.country||(r.country=g)):E(o)<95?s.push(`state=${g} (only ${E(o)}% of values are states/provinces)`):r.state=g}let S=new Set(Object.values(r).filter(Boolean)),A=n.filter(o=>!S.has(o)&&!o.startsWith("__"));if(!r.state){let o=null;for(let u of A){let m=d(u);if(T(m))continue;let p=E(m);if(p<95)continue;let O=B(m,N=>!!y(N)),se=B(m,N=>!!y(N)&&!X(N,i));O<z&&se<1||(!o||p>o.pct)&&(o={name:u,pct:p})}o&&(r.state=o.name,S.add(o.name),a.push(`state=${o.name} (${o.pct}% states/provinces)`))}if(!r.zip)for(let o of A){if(S.has(o))continue;let u=d(o),m=$(u);if(!(m<95)&&Z(u,o)&&!(nt(u,p=>k(p).length>0)<z)){r.zip=o,S.add(o),a.push(`zip=${o} (${m}% ZIP codes)`);break}}let b=r.country;if(!b||!T(d(b))){let o=null;for(let u of A){if(S.has(u)||!T(d(u)))continue;let m=W(d(u));(!o||m>o.pct)&&(o={name:u,pct:m})}o&&(b&&(s.push(`country=${b} (only ${W(d(b))}% of values are country identifiers; using ${o.name} instead)`),C.country=b),r.country=o.name,S.add(o.name),a.push(`country=${o.name}`))}if(!r.city){let o=null;for(let u of A){if(S.has(u))continue;let m=d(u),p=et(m,i);p<G||B(m,O=>F(O,i))<z||(!o||p>o.pct)&&(o={name:u,pct:p})}o&&(r.city=o.name,a.push(`city=${o.name} (${o.pct}% known cities)`))}let U=r.country?d(r.country):[],_=!!r.country&&T(U),ie=_?new Set(U.map(o=>w(o==null?null:String(o))).filter(Boolean)).size:0,H=_&&ie>=2,D=!!(r.lat&&r.lon)&&e.some(o=>{let u=+String(o[r.lat]??"").trim(),m=+String(o[r.lon]??"").trim();return isFinite(u)&&isFinite(m)&&u>=-90&&u<=90&&m>=-180&&m<=180&&String(o[r.lat]??"").trim()!==""&&String(o[r.lon]??"").trim()!==""});return r.lat&&r.lon&&!D&&s.push(`lat/lon=${r.lat}/${r.lon} (no row holds a usable coordinate pair)`),r.country&&!H&&!(r.city||r.state||r.zip||D)&&s.push(_?`country=${r.country} (every row resolves to the same country - nothing to place apart)`:`country=${r.country} (values are not country identifiers)`),{bind:!!(r.city||r.state||r.zip||H||D)?r:null,backfilled:a,refused:s,...Object.keys(C).length?{labelFallback:C}:{}}}function J(n,e){let t=e?.freemiumMaxShapeColumns;return typeof t!="number"||!isFinite(t)||t<1?null:!isFinite(n)||n<=t?0:Math.round(n-t)}function ot(n,e,t){let i=J(n,e);if(i===null||i<=0)return null;let c=typeof e?.freemiumColumnCapPivot=="number"?e.freemiumColumnCapPivot:4,a=i>c?e?.freemiumColumnCapMessageMany:e?.freemiumColumnCapMessageFew;if(typeof a!="string"||a.trim().length===0)return null;let s=a.split("{n}").join(String(i)).split("{fields}").join(i===1?"field":"fields"),r=ee(t);return r.length===0?s:s+" "+r.join(" ")}function ee(n){if(!n||n.length===0)return[];let e=[],t=new Map,i=new Map;for(let a of n){let s=typeof a?.dateGroupId=="string"?a.dateGroupId.trim():"";if(s!==""&&(t.has(s)||(e.push(s),t.set(s,0)),a.isDatePart===!0&&t.set(s,t.get(s)+1),a.isReassembledDate===!0&&!i.has(s))){let r=typeof a.sourceField=="string"?a.sourceField.trim():"",C=typeof a.name=="string"?a.name.trim():"",x=r!==""?r:C;x!==""&&i.set(s,x)}}let c=[];for(let a of e){let s=i.get(a),r=t.get(a)??0;!s||r===0||c.push(`'${s}' is a date hierarchy and counts as ${r+1} fields - bind the date itself instead of its hierarchy.`)}return c}var l=n=>n==null?"":String(n),R=n=>n===!0,ne=n=>{if(typeof n=="number")return Number.isFinite(n)?n:null;if(typeof n=="string"&&n.trim()!==""){let e=Number(n);return Number.isFinite(e)?e:null}return null},rt=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function te(n,e){let t={};for(let[i,c]of rt){let a=l(f(n,e+c));a&&(t[i]=a)}return t}function it(n){let e=a=>f(n,a),t=e("retryAfterSeconds"),i=te(n,"point"),c=te(n,"destPoint");return Object.keys(c).length&&(i.dest=c),{errorMessage:l(e("errorMessage")),code:l(e("code")),language:l(e("language")),version:Number(e("version")??0),codeSummary:l(e("codeSummary")),chartName:l(e("chartName")??e("chartType")),finalChartName:l(e("finalChartName")),warningMessage:l(e("warningMessage")),outputHash:l(e("outputHash")),validatorToken:l(e("validatorToken")),editCodeKey:l(e("editCodeKey")),signedLLMRequestID:l(e("signedLLMRequestID")),userReply:l(e("userReply")),userReplyOutcome:l(e("userReplyOutcome")),improvementSuggestion:l(e("improvementSuggestion")),geoColumn:l(e("geoColumn")),geoKind:l(e("geoKind")),geoPointCols:Object.keys(i).length?i:null,creditBalanceBefore:ne(e("creditBalanceBefore")),creditCost:ne(e("creditCost")),isServiceError:R(e("isServiceError")),isRateLimited:R(e("isRateLimited")),isRefusal:R(e("isRefusal")),isVersionNotFound:R(e("isVersionNotFound")),isGenerationCancelled:R(e("isGenerationCancelled")),retryAfterSeconds:typeof t=="number"&&Number.isFinite(t)?t:null,servedCorrelationId:l(e("servedCorrelationId"))}}var oe=n=>n==null?void 0:Number(n),v=n=>l(n)||void 0;function st(n){let e=f(n,"charts"),t=f(n,"refused"),i=Array.isArray(e)?e.map(a=>{let s=C=>f(a,C),r=s("recommended");return{name:l(s("chartTypeName")??s("name")),description:l(s("description")??s("chartDesc")),rank:oe(s("rank")),score:oe(s("score")),renderer:v(s("renderer")),language:v(s("language")),isPreview:R(s("isPreview")),recommended:typeof r=="boolean"?r:void 0,viaProjection:v(s("viaProjection")),viaProjectionKey:v(s("viaProjectionKey")),detailNote:v(s("detailNote"))}}).filter(a=>a.name):null,c=Array.isArray(t)?t.map(a=>({name:l(f(a,"chartTypeName")??f(a,"name")),reason:l(f(a,"reason")),isVeto:R(f(a,"isVeto"))})).filter(a=>a.name):[];return{errorMessage:l(f(n,"errorMessage")),charts:i,refused:c,noFitSummary:l(f(n,"noFitSummary"))}}function at(n){return!n||typeof n!="object"?null:{status:String(f(n,"status")??""),verdictReason:f(n,"verdictReason")??null,instruction:f(n,"instruction")??null,fix:f(n,"fix")??null,errorMessage:f(n,"errorMessage")??null}}export{G as CITY_ROLE_MATCH_PCT,ye as COMPOUND_MIN_STEM,bn as DEFAULT_GAP_FACTOR,ve as DEFAULT_TEMPERATURE,Te as GET_RANDOM,Pe as GLUED_STEM_MIN,rn as INTENSIVE_SUFFIX_TOKENS,on as INTENSIVE_WORD_TOKENS,zn as IndexedText,Tn as MAX_RUN_BOUNDS,an as POSITIONAL_SUFFIX_TOKENS,sn as POSITIONAL_WORD_TOKENS,Un as PREVIEW_OMITTED_FIELDS,h as ROLE_MATCH_PCT,An as SERIES_COMPLETENESS_MAX_LISTED,Nn as SERIES_COMPLETENESS_MIN_FILL,In as SERIES_KEY_MAX_DISTINCT,be as SIMPLE_STRING_HASH,xe as STR,he as SUBSTRING_MIN,ae as SUPPORTED_LANGUAGES,ue as SUPPORTED_LANGUAGE_CODES,E as admin1MatchPct,yn as allowedAggregations,qe as buildGeoIsoColumn,$e as buildGeoPointColumns,Ue as cityMatchPct,Ve as cityTagsFor,Gn as classifyAdditivity,gn as classifyForAggregation,Fn as classifyNumericValueNature,Dn as classifyTemporal,mn as codeNeedsLegacyAggNames,hn as codeReadsColumn,Rn as codeReadsColumnsByRoleOrPosition,cn as collapseRepeatedAggPrefix,xn as columnsTheCodeReads,Ye as countryRegion,Bn as decimalSeparatorOf,Cn as defaultAggregation,Kn as detectDecimalSeparator,en as detectFormatSignature,He as detectGeo,De as detectOrdinalDomain,_n as detectTextDatePattern,jn as encodePayload,$n as engineTypeForSqlType,fn as englishImplicitAggNames,me as foldName,ot as freemiumColumnCapRefusal,J as freemiumColumnsOverCap,ee as freemiumDateHierarchyClauses,Se as gluedPrefixStems,Qn as gzipWireText,ln as hasDefaultAggPrefix,pe as hasUnsegmentedScript,On as hostAggHint,Vn as ingest,Pn as isAggregationAllowed,L as isBlankLike,Ge as isCityTableLoaded,Me as isDeterministicRefusal,Ke as isGeoPointAmbiguity,En as isIdentifierName,je as isJoinGeoKind,Zn as isNdjsonContentType,Ee as isOrdinalFriendlyName,qn as keyedSigner,Le as localMidnightDateColumns,we as localMidnightToUtcDay,T as looksLikeCountryColumn,Re as matchNameToken,vn as measureCadence,kn as measureSeriesCompleteness,Xn as messageSignature,tn as monthLookupFor,pn as nameLooksIntensiveRate,dn as nameLooksPositional,fe as nameWords,Fe as normalizeCountry,ke as normalizeLocalMidnightDates,nn as normalizeMonthKey,I as normalizePlaceName,Be as normalizeZip5,Ae as parseDateStable,it as parseGenerateResponse,Wn as parseNumberText,st as parseQualifyResponse,at as parseReviewVerdict,Mn as parseTemporalPoint,Hn as payloadPreview,Ln as pickSeriesColumn,Jn as readGenerateStream,de as readName,f as readWireField,Oe as registerCityTable,Ze as registerIso3Regions,y as resolveAdmin1,We as resolveGeoPoint,ce as resolveLanguage,tt as resolvePointRoles,_e as safeDistinctValuesToShip,wn as seriesKeyVerdict,Sn as shareOfTotalIsHonest,un as stripHostAggPrefix,Je as summarizeCountryRegions,Xe as summarizeGeoExtent,le as supportedLanguage,Qe as toGeoIso,ge as unsegmentedRuns,Ne as wholeDayFrame,Ie as wholeDayIso,Yn as wireResponseFromFetch,Ce as wordEndsWith,$ as zipMatchPct,k as zipPrefixCandidates,ze as zipToPrefix3};
@@ -1,2 +1,2 @@
1
1
  /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
- import{B as a,C as b,D as c,E as d,F as e,G as f,H as g,I as h}from"./chunk-PFCJESUQ.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-C5I73OM2.mjs";import"./chunk-TPVDJHU6.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-35Z7JCND.mjs";import"./chunk-ILHBRGIO.mjs";export{h as IndexedText,e as classifyAdditivity,f as classifyNumericValueNature,c as classifyTemporal,b as detectTextDatePattern,d as hostAggHint,a as isIdentifierName,g as trimmedCells};
2
+ import{H as a,I as b,J as c,K as d,L as e,M as f,N as g,O as h}from"./chunk-WG6XYZLU.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-C5I73OM2.mjs";import"./chunk-TPVDJHU6.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-35Z7JCND.mjs";import"./chunk-ILHBRGIO.mjs";export{h as IndexedText,e as classifyAdditivity,f as classifyNumericValueNature,c as classifyTemporal,b as detectTextDatePattern,d as hostAggHint,a as isIdentifierName,g as trimmedCells};
package/dist/ingest.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
- import{d as a,e as b}from"./chunk-ZFTP4NSP.mjs";import"./chunk-PFCJESUQ.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-C5I73OM2.mjs";import"./chunk-TPVDJHU6.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-35Z7JCND.mjs";import"./chunk-ILHBRGIO.mjs";export{a as engineTypeForSqlType,b as ingest};
2
+ import{d as a,e as b}from"./chunk-6PU2UEMV.mjs";import"./chunk-WG6XYZLU.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-C5I73OM2.mjs";import"./chunk-TPVDJHU6.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-35Z7JCND.mjs";import"./chunk-ILHBRGIO.mjs";export{a as engineTypeForSqlType,b as ingest};
@@ -61,7 +61,8 @@ export type TemporalCadence = {
61
61
  export declare const DEFAULT_GAP_FACTOR = 5;
62
62
  /** Run bounds are for a sentence, not a dataset; a series in 40 pieces needs no more than this. */
63
63
  export declare const MAX_RUN_BOUNDS = 6;
64
- type Stamp = {
64
+ /** One parsed point on the calendar. Exported for the per-series measurement beside this one. */
65
+ export type Stamp = {
65
66
  /** Epoch ms at the point's start. */
66
67
  ms: number;
67
68
  /** Calendar parts, for the month/quarter/year arithmetic that epoch ms cannot do. */
@@ -79,8 +80,14 @@ type Stamp = {
79
80
  * the period and integer-key forms classifyTemporal already recognises as time axes. A value it
80
81
  * cannot read is DROPPED, never guessed at, and a column where most values drop yields no
81
82
  * cadence at all (see the parse floor in measureCadence).
83
+ *
84
+ * `locale` is read only by the month-NAME branch, the last one tried: "Ene 2024" is a month in
85
+ * Spanish and nothing in English.
82
86
  */
83
- export declare function parseTemporalPoint(raw: string, pattern?: string): Stamp | null;
87
+ export declare function parseTemporalPoint(raw: string, pattern?: string, locale?: string): Stamp | null;
88
+ type GrainName = TemporalCadence["grain"];
89
+ /** Distance between two stamps measured in whole periods of `grain`. */
90
+ export declare function unitsBetween(a: Stamp, b: Stamp, grain: GrainName, stepMs: number): number;
84
91
  /**
85
92
  * Measure how a temporal column's distinct values are spaced.
86
93
  *
@@ -94,5 +101,23 @@ export declare function measureCadence(values: Iterable<string>, opts?: {
94
101
  gapFactor?: number;
95
102
  includeBounds?: boolean;
96
103
  pattern?: string;
104
+ locale?: string;
97
105
  }): TemporalCadence | null;
106
+ /**
107
+ * The measurement measureCadence reports, together with the sorted points and the step it was
108
+ * taken from. Not on the package surface: it exists so a measurement made PER SERIES over the
109
+ * same column (seriesCompleteness.ts) indexes its periods on exactly the grid the column's own
110
+ * cadence was measured on, rather than on a second reading that could disagree with it.
111
+ */
112
+ export type CadenceAnalysis = {
113
+ cadence: TemporalCadence;
114
+ points: Stamp[];
115
+ stepMs: number;
116
+ };
117
+ export declare function analyseCadence(values: Iterable<string>, opts?: {
118
+ gapFactor?: number;
119
+ includeBounds?: boolean;
120
+ pattern?: string;
121
+ locale?: string;
122
+ }): CadenceAnalysis | null;
98
123
  export {};
@@ -4,6 +4,8 @@ export { classifyTemporal, detectTextDatePattern, classifyAdditivity, classifyNu
4
4
  export type { TextDateDetection } from "./indexedText";
5
5
  export { measureCadence, parseTemporalPoint, DEFAULT_GAP_FACTOR, MAX_RUN_BOUNDS } from "./cadence";
6
6
  export type { TemporalCadence, TemporalRun } from "./cadence";
7
+ export { measureSeriesCompleteness, pickSeriesColumn, seriesKeyVerdict, SERIES_COMPLETENESS_MAX_LISTED, SERIES_COMPLETENESS_MIN_FILL, SERIES_KEY_MAX_DISTINCT, } from "./seriesCompleteness";
8
+ export type { SeriesCompleteness, SeriesCoverage, SeriesKeyCandidate, SeriesKeyVerdict, } from "./seriesCompleteness";
7
9
  export { classifyForAggregation, allowedAggregations, defaultAggregation, isAggregationAllowed, shareOfTotalIsHonest, nameLooksIntensiveRate, nameLooksPositional, stripHostAggPrefix, hasDefaultAggPrefix, collapseRepeatedAggPrefix, codeNeedsLegacyAggNames, englishImplicitAggNames, INTENSIVE_WORD_TOKENS, INTENSIVE_SUFFIX_TOKENS, POSITIONAL_WORD_TOKENS, POSITIONAL_SUFFIX_TOKENS, } from "./aggregation";
8
10
  export type { AggKind, AggAdditivity, AggBasis, AggNature, AggregationClass, AggregationColumn, } from "./aggregation";
9
11
  export type { LLMColumnWithValue } from "./models";
@@ -151,6 +151,7 @@ export declare class IndexedText implements IValueCollection {
151
151
  private wholeDayIso;
152
152
  private hasTimeComponent;
153
153
  getColumnsWithStats(privacyLevel: string, locale?: string): LLMColumnWithValue[];
154
+ private applySeriesCompleteness;
154
155
  private updateColumnStats20;
155
156
  private updateColumnStats10;
156
157
  getRowCount(): number;
@@ -1,5 +1,7 @@
1
1
  import type { TemporalCadence } from "./cadence";
2
+ import type { SeriesCompleteness } from "./seriesCompleteness";
2
3
  export type { TemporalCadence, TemporalRun } from "./cadence";
4
+ export type { SeriesCompleteness, SeriesCoverage } from "./seriesCompleteness";
3
5
  export type LLMRequestModifier = {
4
6
  code: string;
5
7
  not: boolean;
@@ -60,6 +62,7 @@ export type LLMColumnWithValue = {
60
62
  dateGroupId?: string;
61
63
  sourceField?: string;
62
64
  temporalCadence?: TemporalCadence;
65
+ seriesCompleteness?: SeriesCompleteness;
63
66
  sharedValueRatioWithOthers?: {
64
67
  otherColumn: string;
65
68
  percentShared: number;
@@ -0,0 +1,114 @@
1
+ /** One series that is missing at least one period of the axis. */
2
+ export type SeriesCoverage = {
3
+ /** The series' value. Absent when the privacy tier withholds the column's values. */
4
+ name?: string;
5
+ /** ISO start of the first period the series is observed in. Absent below privacy tier 20. */
6
+ first?: string;
7
+ /** ISO start of the last period the series is observed in. Absent below privacy tier 20. */
8
+ last?: string;
9
+ /** Periods of the axis before the series' first observation: a late start when above 0. */
10
+ missingBefore: number;
11
+ /** Periods of the axis after the series' last observation: an early end when above 0. */
12
+ missingAfter: number;
13
+ /** Periods absent between its own first and last - holes, as distinct from a late start or an early end. */
14
+ missingInterior: number;
15
+ /**
16
+ * The widest step between two consecutive observations of the series, in periods - the unit of
17
+ * the cadence's `largestGapUnits`: 1 = no hole, one missing period reads 2.
18
+ */
19
+ largestGap: number;
20
+ /** Share of the axis's periods the series is observed in, 0..1 to three places. */
21
+ coverage: number;
22
+ };
23
+ export type SeriesCompleteness = {
24
+ /** The categorical the series are read from. */
25
+ seriesColumn: string;
26
+ /** The period grain of the time column, as its cadence names it. */
27
+ grain: string;
28
+ /** Periods on the axis, first to last observed across every series, endpoints included. */
29
+ periods: number;
30
+ /** Series on the axis: the key's values that have at least one observed period. */
31
+ seriesCount: number;
32
+ /** Series missing at least one period. */
33
+ incompleteSeries: number;
34
+ /** Series whose first observation is after the axis's first period. */
35
+ lateStarts: number;
36
+ /** Series whose last observation is before the axis's last period. */
37
+ earlyEnds: number;
38
+ /** Series missing at least one period between their own first and last. */
39
+ withHoles: number;
40
+ /** Periods of the axis that no series is observed in - a gap in the whole panel, not in one series. */
41
+ columnWideMissing: number;
42
+ /** The latest start over every series: the most periods any one misses before its first observation. */
43
+ maxMissingBefore: number;
44
+ /** The earliest end over every series: the most periods any one misses after its last observation. */
45
+ maxMissingAfter: number;
46
+ /** The widest `largestGap` of any series, in the same unit. */
47
+ largestGap: number;
48
+ /** At most SERIES_COMPLETENESS_MAX_LISTED of them, least covered first. */
49
+ series: SeriesCoverage[];
50
+ /** Incomplete series not listed. */
51
+ more: number;
52
+ };
53
+ /** Listed series; the rest are counted in `more`, so a 500-series panel does not write an essay. */
54
+ export declare const SERIES_COMPLETENESS_MAX_LISTED = 8;
55
+ /**
56
+ * The share of the (series x period) lattice that must hold an observation before the columns are
57
+ * treated as a panel at all. Below it the data is events or identifiers, and "incomplete" is the
58
+ * normal state of every series rather than news about any of them.
59
+ */
60
+ export declare const SERIES_COMPLETENESS_MIN_FILL = 0.5;
61
+ /** More distinct values than this and the column is not read as a set of series. */
62
+ export declare const SERIES_KEY_MAX_DISTINCT = 200;
63
+ /** What seriesKeyVerdict needs to know about one column. */
64
+ export type SeriesKeyCandidate = {
65
+ name: string;
66
+ dataType: string;
67
+ isMeasure: boolean;
68
+ isTemporal?: boolean;
69
+ isDatePart?: boolean;
70
+ isReassembledDate?: boolean;
71
+ isBinaryFlag?: boolean;
72
+ geoKind?: string;
73
+ /** The engine's identifier-name test (isIdentifierName), passed in rather than re-derived. */
74
+ identifierNamed: boolean;
75
+ /** Distinct non-blank values. */
76
+ values: ReadonlySet<string> | ReadonlyArray<string>;
77
+ /** Rows in the table, for the row-identity test. */
78
+ rows: number;
79
+ locale?: string;
80
+ };
81
+ export type SeriesKeyVerdict = "entity" | "measure" | "temporal" | "cardinality" | "row-identity" | "identifier" | "flag" | "ordinal" | "attribute";
82
+ /**
83
+ * Whether a column can be the series key, and if not, why not. "entity" is the only yes.
84
+ *
85
+ * Every test is on the column's structure or its name, never on how ragged it is: choosing the key
86
+ * that makes the fact fire would be choosing the answer.
87
+ */
88
+ export declare function seriesKeyVerdict(c: SeriesKeyCandidate): SeriesKeyVerdict;
89
+ /**
90
+ * The series key: the entity-like column with the fewest distinct values; a recognised place wins
91
+ * a tie, then the earlier column. Returns its index in `candidates`, or -1 when none qualifies.
92
+ */
93
+ export declare function pickSeriesColumn(candidates: ReadonlyArray<SeriesKeyCandidate>): number;
94
+ /**
95
+ * Measure per-series completeness over one time column and one series column.
96
+ *
97
+ * `periods[i]` and `series[i]` are row i's two labels, as the engine keys values (a whole-day date
98
+ * as "YYYY-MM-DD"); "" is a blank. The time axis is measured by the same analysis as the column's
99
+ * own cadence, from the same distinct labels, so `grain` and `periods` here always agree with it.
100
+ *
101
+ * `includeDates` and `includeNames` default to FALSE - the safe reading of a missing argument is
102
+ * the strictest tier.
103
+ */
104
+ export declare function measureSeriesCompleteness(input: {
105
+ periods: ReadonlyArray<string>;
106
+ series: ReadonlyArray<string>;
107
+ seriesColumn: string;
108
+ pattern?: string;
109
+ locale?: string;
110
+ includeDates?: boolean;
111
+ includeNames?: boolean;
112
+ maxListed?: number;
113
+ minFill?: number;
114
+ }): SeriesCompleteness | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/shape-core",
3
- "version": "0.6.9",
3
+ "version": "0.6.10",
4
4
  "description": "Host-agnostic data-shape profiler: ingest a dataset's rows through IValueCollection.addRow and read back the measured shape as an LLMColumnWithValue[] payload — types, cardinality, temporal/ordinal detection, geographic region and point resolution, cross-column signals. MEASUREMENT only: the policy that decides what a measured shape means for chart selection lives server-side.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1,2 +0,0 @@
1
- /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
- import{a as Se}from"./chunk-QEH7WTLB.mjs";import{a as Ae,b as Ce}from"./chunk-2LR73DNS.mjs";import{c as _e}from"./chunk-C5I73OM2.mjs";import{b as be,f as ye}from"./chunk-TPVDJHU6.mjs";import{a as ge,b as pe,c as he}from"./chunk-35Z7JCND.mjs";import{e as le,f as j,p as ce,q as z,r as me,s as de,v as ie,x as fe}from"./chunk-ILHBRGIO.mjs";var Xe=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],Qe=[7,72,-172,-52];function Me(n,e,t){return n>=t[0]&&n<=t[1]&&e>=t[2]&&e<=t[3]}var H=n=>Math.round(n*10)/10;function Re(n,e=3){let t=[],i=[],r=0,s=0;for(let l of n){let u=l?.lat,c=l?.lon;if(typeof u!="number"||typeof c!="number"||!isFinite(u)||!isFinite(c)||u<-90||u>90||c<-180||c>180)continue;t.push(u),i.push(c);let p=l?.country?String(l.country).trim().toUpperCase():"",f=p?ee(p):null;f?((p==="US"||p==="USA")&&r++,f==="north-america"&&s++):(Xe.some(v=>Me(u,c,v))&&r++,Me(u,c,Qe)&&s++)}let o=t.length;return o<e?null:(t.sort((l,u)=>l-u),i.sort((l,u)=>l-u),{pctUsa:H(r/o*100),pctNa:H(s/o*100),latP5:H(z(t,.05)),latP95:H(z(t,.95)),lonP5:H(z(i,.05)),lonP95:H(z(i,.95)),n:o})}var xe={"north-america":"AG AI AW BB BL BM BQ BS BZ CA CR CU CW DM DO GD GL GP GT HN HT JM KN KY LC MF MQ MS MX NI PA PM PR SV SX TC TT US VC VG VI","south-america":"AR BO BR CL CO EC FK GF GY PE PY SR UY VE",europe:"AD AL AT AX BA BE BG BY CH CY CZ DE DK EE ES FI FO FR GB GG GI GR HR HU IE IM IS IT JE LI LT LU LV MC MD ME MK MT NL NO PL PT RO RS RU SE SI SJ SK SM UA VA",africa:"AO BF BI BJ BW CD CF CG CI CM CV DJ DZ EG EH ER ET GA GH GM GN GQ GW KE KM LR LS LY MA MG ML MR MU MW MZ NA NE NG RE RW SC SD SH SL SN SO SS ST SZ TD TG TN TZ UG YT ZA ZM ZW",asia:"AE AF AM AZ BD BH BN BT CC CN CX GE HK ID IL IN IO IQ IR JO JP KG KH KP KR KW KZ LA LB LK MM MN MO MV MY NP OM PH PK PS QA SA SG SY TH TJ TL TM TR TW UZ VN YE",oceania:"AS AU CK FJ FM GU KI MH MP NC NF NR NU NZ PF PG PN PW SB TK TO TV UM VU WF WS",antarctica:"AQ BV GS HM TF"},X=(()=>{let n=new Map;for(let e of Object.keys(xe))for(let t of xe[e].split(/\s+/))t&&n.set(t,e);return n})();function qe(n){for(let[e,t]of n){let i=X.get(e);i&&!X.has(t)&&X.set(t,i)}}qe(be);function ee(n){if(!n)return null;let e=String(n).trim().toUpperCase();if(!e)return null;let t=X.get(e);if(t)return t;let i=ye(String(n));return i?X.get(i)??null:null}function an(n,e=2){return se(n.map(t=>[t,1]),e)}function se(n,e=2){let t=new Map,i=0;for(let[o,l]of n){let u=ee(o);if(!u)continue;let c=typeof l=="number"&&isFinite(l)&&l>0?l:1;t.set(u,(t.get(u)??0)+c),i+=c}if(i<e||!t.size)return null;let r="europe",s=-1;for(let o of Array.from(t.keys()).sort()){let l=t.get(o);l>s&&(r=o,s=l)}return{dominantGeoRegion:r,dominantGeoRegionPct:H(s/i*100),regionCount:t.size,n:i}}import Ye from"papaparse";var Je=[["Lu",/^\p{Lu}$/u],["Ll",/^\p{Ll}$/u],["Lt",/^\p{Lt}$/u],["Lm",/^\p{Lm}$/u],["Lo",/^\p{Lo}$/u],["Mn",/^\p{Mn}$/u],["Mc",/^\p{Mc}$/u],["Nd",/^\p{Nd}$/u]];function te(n){for(let[e,t]of Je)if(t.test(n))return e;return null}var et=[{id:"ascii",test:/^[A-Za-z]$/,ranges:[[65,90],[97,122]]},{id:"latin",test:/^[\u00C0-\u017F]$/u,ranges:[[192,383]]},{id:"cyrillic",test:/^[\u0400-\u045F\u0490-\u0491]$/u,ranges:[[1024,1119],[1168,1169]]},{id:"greek",test:/^[\u0386-\u03CE]$/u,ranges:[[902,974]]},{id:"han",test:/^[\u4E00-\u9FFF]$/u,ranges:[[19968,40959]]},{id:"hiragana",test:/^\p{Script=Hiragana}$/u,ranges:[[12353,12447]]},{id:"katakana",test:/^\p{Script=Katakana}$/u,ranges:[[12448,12543]]},{id:"hangul",test:/^[\uAC00-\uD7A3]$/u,ranges:[[44032,55203]]},{id:"arabic",test:/^[\u0620-\u0652\u0671-\u06D3]$/u,ranges:[[1568,1618],[1649,1747]]},{id:"hebrew",test:/^[\u05B0-\u05EA]$/u,ranges:[[1456,1514]]},{id:"devanagari",test:/^\p{Script=Devanagari}$/u,ranges:[[2304,2431]]},{id:"thai",test:/^\p{Script=Thai}$/u,ranges:[[3585,3662]]}],ne=new Map;function Ne(n,e,t,i){let r=ne.get(n);if(r)return r;let s=[];for(let[o,l]of e)for(let u=o;u<=l;u++){let c=String.fromCodePoint(u);te(c)===t&&(i&&!i.test(c)||s.push(c))}return ne.set(n,s),s}function tt(n){let t=n.codePointAt(0);for(let o=0;o<9&&te(String.fromCodePoint(t-1))==="Nd";o++)t--;let i="nd:"+t.toString(16),r=ne.get(i);if(r)return r;let s=[];for(let o=t;o<t+10;o++){let l=String.fromCodePoint(o);te(l)==="Nd"&&s.push(l)}return ne.set(i,s),s}function nt(n,e){if(e==="Nd")return tt(n);for(let r of et)if(r.test.test(n))return Ne(r.id+":"+e,r.ranges,e,r.id==="ascii"?null:r.test);let i=n.codePointAt(0)&-128;return Ne("block:"+i.toString(16)+":"+e,[[i,i+127]],e,null)}function it(n,e,t,i){let r=n.filter(s=>!e.has(s));return r.length===0&&(r=n.filter(s=>s!==t)),r.length===0?t:r[Math.min(r.length-1,Math.floor(i()*r.length))]}var st=/^[\p{L}\p{M}\p{Nd}]$/u,Te=/^[\p{L}\p{Nd}]$/u;function ve(n,e){if(!n)return n??"";let t=new Set(Array.from(n)),i=p=>{let f=te(p);return!f||!st.test(p)?p:it(nt(p,f),t,p,e)},r=p=>{let f=[];for(let v of p)f.push(i(v)),Te.test(v)&&e()<.2&&f.push(i(v));if(f.length>6){let v=Math.floor(e()*Math.min(3,f.length-6));for(let w=0;w<v;w++)for(let N=0;N<5;N++){let P=Math.floor(e()*f.length);if(Te.test(f[P])){f.splice(P,1);break}}}return f.join("")};if(!(n.includes("@")&&n.includes(".")))return r(n);let[o,l=""]=n.split("@"),u=l.endsWith(".com"),c=u?l.slice(0,-4):l;return`${r(o)}@${r(c)}${u?".com":""}`}var rt=["rate","ratio","pct","percent","percentage","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","utilisation","z[_-]?score","average","avg","mean","median","stddev","variance","gpa","percentile","quantile","efficiency","accuracy","probability","multiplier","coefficient","correlation","occupancy","age","bmi","temperature","density","pressure","humidity","ph","velocity","speed","elevation","altitude","latency","throughput","bandwidth","iops","ppm","ppb","dpmo","bps","temperatuur","temperatur","temperatura","teplota","lampotila","homerseklet","sicaklik","pression","presion","pressao","pressione","druck","tryck","tlak","paine","nyomas","presiune","humidite","humedad","umidade","umidita","feuchtigkeit","vochtigheid","kosteus","vlhkost","vitesse","velocidad","velocidade","velocita","geschwindigkeit","snelheid","hastighet","hastighed","rychlost","nopeus","sebesseg","brzina","predkosc","densite","densidad","densidade","densita","dichte","dichtheid","hustota","tiheys","gustoca","moyenne","mediane","promedio","mediana","gemiddelde","durchschnitt","mittelwert","genomsnitt","gennemsnit","gjennomsnitt","keskiarvo","atlag","ortalama","prosjek","srednia","prumer","priemer","medie","taux","tasa","taxa","tasso","verhaltnis","verhouding","aandeel","anteil","andel","osuus","podil","udzial","udio","pourcentage","porcentaje","percentual","prozent","procent","prosentti","szazalek","yuzde","participacion","participacao","pondere","omjer","arany","oran","rata","leeftijd","edad","idade","wiek","eletkor","varsta","puntuacion","pontuacao","punteggio","betyg","ocena","indice","indeks","wskaznik","puan"],ot=["pct","percent","percentage","rate","ratio","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","utilisation","gpa","percentile","quantile","bmi","density","pressure","humidity","velocity","efficiency","occupancy","latency","throughput","bandwidth","iops","ppm","ppb","dpmo","bps"],at=["latitude","longitude"],ut=["latitude","longitude"];function K(n){return le(n)}var re=["somme de","suma de","soma de","summe von","som van","somma di","summa av","sum av","sum af","soucet z","suma z","totaal van","total de","toplam","osszeg","nombre de","recuento de","contagem de","anzahl von","aantal van","conteggio di","antal av","lukumaara","pocet z"],we=["moyenne de","promedio de","media de","media di","durchschnitt von","gemiddelde van","medelvarde av","genomsnitt av","gennemsnit af","keskiarvo","atlag","ortalama","prumer z","srednia z","medie de","minimum de","minimo de","minimo di","minimum von","maximum de","maximo de","massimo di","maximum von"];function lt(n){return[...n].sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var Ie=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+lt(re)+")\\s+)","i"),ct=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,mt=new RegExp("\\b("+rt.join("|")+")\\b|("+ot.join("|")+")$","i"),dt=new RegExp("\\b("+at.join("|")+")\\b|("+ut.join("|")+")$","i");function Le(n){if(!n)return"";let e=String(n),t=Ie.exec(K(e));return(t?e.slice(t[0].length):e).trim()}function ft(n){return!!n&&Ie.test(K(String(n)))}var gt=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],Ee=new RegExp("^\\s*("+[...gt].sort((n,e)=>e.length-n.length).map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function De(n){if(n==null)return"";let e=String(n),t=Ee.exec(e);if(!t)return e;let i=l=>l.toLowerCase().replace(/\s+/g," ").trim(),r=i(t[1]),s=e.slice(t[0].length),o=0;for(;o<8;){let l=Ee.exec(s);if(!l||i(l[1])!==r)break;let u=s.slice(l[0].length);if(u.trim()==="")break;s=u,o++}return o===0?e:e.slice(0,t[0].length)+s}function oe(n,e){if(!n||!e)return!1;let t=String(n);for(let i of e){let r=i?.hostName;if(r&&r!==i?.name&&t.includes(r))return!0}return!1}var Oe={Sum:["Sum of "],Avg:["Average of "],Average:["Average of "],Count:["Count of "],CountNonNull:["Count of "],Min:["Min of ","First ","Earliest "],Max:["Max of ","Last ","Latest "],Median:["Median of "],StandardDeviation:["Standard deviation of "],Variance:["Variance of "]},pt=new RegExp("^("+Object.keys(Oe).join("|")+")\\((.+)\\)$");function Pe(n){if(!n)return[];let e=pt.exec(String(n).trim());if(!e)return[];let t=Oe[e[1]],i=e[2],r=[];for(let s=i.indexOf(".");s>=0;s=i.indexOf(".",s+1)){if(s===0)continue;let o=i.slice(s+1);if(o.trim()!=="")for(let l of t){let u=l+o;r.includes(u)||r.push(u)}}return r}function ht(n){let e=Le(n);return e.length===0?"":e.replace(ct," ")}function ke(n,e){if(!e)return!1;let t=Le(e);return n.test(K(ht(e)))||n.test(K(t))||n.test(K(j(t).join(" ")))}function Fe(n){return ke(dt,n)}function bt(n){return ke(mt,n)||Fe(n)}var Ge=/int|double|decimal|single|float|number|currency|money/i;function yt(n){let e=String(n?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||n?.isMeasure===!0||Ge.test(String(n?.dataType??""))?"Continuous":"Categorical"}function _t(n){return n?.isMeasure===!0||Ge.test(String(n?.dataType??""))}function We(n){let e=n??{},t=yt(e);if(t!=="Continuous")return{nature:t,additivity:"unknown",basis:"role",suppressed:!1};if(Fe(e.name))return{nature:t,additivity:"positional",basis:"name",suppressed:!0};let i=String(e.additivity??"").trim().toLowerCase();if(!(i==="additive"&&ft(e.name))){if(i==="additive")return{nature:t,additivity:"additive",basis:"measured",suppressed:!1};if(i==="part_of_whole")return{nature:t,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(i==="intensive_rate")return{nature:t,additivity:"intensive_rate",basis:"measured",suppressed:!1}}return e.discourageAggregationAcrossGroups===!0?{nature:t,additivity:"intensive_rate",basis:"host-flag",suppressed:!1}:bt(e.name)?{nature:t,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:t,additivity:"additive",basis:"default",suppressed:!1}}function Be(n){let e=We(n),t=n??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return _t(t)?["median","average","min","max","first","distinctcount","count"]:["first","distinctcount","count"];switch(e.additivity){case"positional":return["min","max","count","distinctcount","first"];case"intensive_rate":return["average","median","min","max","count","distinctcount","first"];default:return["sum","average","median","min","max","count","distinctcount","first"]}}function dn(n){return Be(n)[0]}function fn(n,e){return Be(n).indexOf(e)>=0}function gn(n,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let t=We(n);return t.additivity==="additive"||t.additivity==="part_of_whole"||t.additivity==="unknown"}var St=/^[A-Za-z_$][A-Za-z0-9_$]*$/,At=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Ct=new RegExp([String.raw`\bisMeasure\b`,String.raw`\bdataType\b`,String.raw`\bcolumns\s*\[\s*-?\d`,String.raw`\.iloc\s*\[[^\]]*,`,String.raw`\.iat\s*\[`,String.raw`\bselect_dtypes\b`,String.raw`\b_get_numeric_data\b`,String.raw`\bis_numeric_dtype\b`,String.raw`\bfor\s+\w+\s+in\s+(?:list\s*\(\s*)?df\.columns\b`,String.raw`\bdf\.columns\s*\.\s*(?:tolist|to_list|difference|drop)\b`,String.raw`\bdf\.dtypes\b`,String.raw`\bObject\s*\.\s*(?:keys|values|entries)\s*\(\s*(?:rows|data|df)?\s*\[\s*0\s*\]`,String.raw`\b(?:row|rw|r)\s*\[\s*\d+\s*\]`].join("|"));function Q(n,e){if(!n||!e)return!1;let t=At(e);return new RegExp("['\"`]"+t+"['\"`]").test(n)?!0:St.test(e)&&new RegExp("\\."+t+"(?![A-Za-z0-9_$])").test(n)}function Mt(n){return!!n&&Ct.test(n)}function hn(n,e,t){return n?Mt(n)?[...e]:[...t,...e].some(i=>Q(n,i))?e.filter(i=>Q(n,i)):[...e]:[]}var yn=5,_n=6;var xt=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Rt=/^(\d{4})[-/](\d{1,2})$/,Nt=/^(\d{4})[-\s]?Q([1-4])$/i,Tt=/^Q([1-4])[-\s](\d{4})$/i,vt=/^(\d{4})$/,Et=/^(\d{4})(0[1-9]|1[0-2])$/,wt=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/;function U(n,e,t,i=0,r=0,s=0){if(!(n>=1&&e>=1&&e<=12&&t>=1&&t<=31))return null;let o=Date.UTC(n,e-1,t,i,r,s);if(!Number.isFinite(o))return null;let l=u=>u<10?"0"+u:String(u);return{ms:o,y:n,m:e,d:t,iso:`${n}-${l(e)}-${l(t)}`}}function It(n,e){let t=[],i="";for(let u=0;u<e.length;u++){if(e[u]!=="%"){i+=e[u].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");continue}switch(e[++u]){case"Y":t.push("Y"),i+="(\\d{4})";break;case"m":t.push("m"),i+="(\\d{1,2})";break;case"d":t.push("d"),i+="(\\d{1,2})";break;case"H":case"M":case"S":i+="\\d{1,2}";break;case"%":i+="%";break;default:return null}}let r=new RegExp("^"+i+"$").exec(n);if(!r)return null;let s=0,o=1,l=1;return t.forEach((u,c)=>{let p=+r[c+1];u==="Y"?s=p:u==="m"?o=p:l=p}),s?U(s,o,l):null}function Lt(n,e){let t=(n??"").trim();if(t==="")return null;if(e){let r=It(t,e);return r||null}let i=xt.exec(t);if(i)return U(+i[1],+i[2],+i[3],+(i[4]??0),+(i[5]??0),+(i[6]??0));if(i=Nt.exec(t),i)return U(+i[1],(+i[2]-1)*3+1,1);if(i=Tt.exec(t),i)return U(+i[2],(+i[1]-1)*3+1,1);if(i=Rt.exec(t),i&&+i[2]>=1&&+i[2]<=12)return U(+i[1],+i[2],1);if(i=wt.exec(t),i)return U(+i[1],+i[2],+i[3]);if(i=Et.exec(t),i)return U(+i[1],+i[2],1);if(i=vt.exec(t),i){let r=+i[1];return r>=1900&&r<=2100?U(r,1,1):null}return null}function Ve(n){let e=new Date(n).getUTCDay();return e>=1&&e<=5}function ze(n,e){if(e<=n)return 0;let t=Math.round((e-n)/864e5),i=Math.floor(t/7),r=i*5,s=n+i*7*864e5;for(;s<e;)Ve(s)&&r++,s+=864e5;return r}function Dt(n){if(n.length===0)return 0;let e=[...n].sort((i,r)=>i-r),t=e.length>>1;return e.length%2?e[t]:(e[t-1]+e[t])/2}function Ot(n){return n>0?n<.95?"hour":n<=1.05?"day":n>=6.5&&n<=7.5?"week":n>=27&&n<=31.5?"month":n>=88&&n<=93?"quarter":n>=362&&n<=368?"year":"irregular":"irregular"}function $e(n,e,t,i){switch(t){case"year":return e.y-n.y;case"quarter":return e.y*4+Math.floor((e.m-1)/3)-(n.y*4+Math.floor((n.m-1)/3));case"month":return e.y*12+e.m-(n.y*12+n.m);case"week":return Math.round((e.ms-n.ms)/(7*864e5));case"weekday":return ze(n.ms,e.ms);case"day":return Math.round((e.ms-n.ms)/864e5);default:return i>0?Math.round((e.ms-n.ms)/i):0}}function Ue(n,e){let t=e?.gapFactor??5,i=0,r=0,s=new Map;for(let g of n){if(g==null||g==="")continue;i++;let F=Lt(String(g),e?.pattern);F&&(r++,s.set(F.ms,F))}let o=[...s.values()].sort((g,F)=>g.ms-F.ms);if(o.length<3||i>0&&r/i<.8)return null;let l=o[o.length-1].ms-o[0].ms;if(l<=0)return null;let u=[];for(let g=1;g<o.length;g++)u.push(o[g].ms-o[g-1].ms);let c=Dt(u);if(!(c>0))return null;let p=Ot(c/864e5);p==="day"&&l>=7*864e5&&o.every(g=>Ve(g.ms))&&ze(o[0].ms,o[o.length-1].ms)+1>o.length*.5&&(p="weekday");let f=p==="irregular"?o.length:$e(o[0],o[o.length-1],p,c)+1,v=1,w=1,N=[],P=o[0],_=1;for(let g=1;g<o.length;g++){let F=$e(o[g-1],o[g],p,c);F>v&&(v=F),p!=="irregular"&&F>t?(w++,N.push({from:P.iso,to:o[g-1].iso,points:_}),P=o[g],_=1):_++}N.push({from:P.iso,to:o[o.length-1].iso,points:_});let E={grain:p,points:o.length,expectedPoints:Math.max(f,o.length),coveragePct:Math.round(o.length/Math.max(f,o.length)*1e3)/10,runs:w,largestGapUnits:v,gapFactor:t};return e?.includeBounds&&N.length<=6&&(E.runBounds=N),E}var Pt=12,kt=100,Ft=.3,Gt=.9,Wt=120,Bt=1900,$t=2100,Vt=0,zt=20,Ut=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function Yt(n){if(!n)return!1;let e=j(n);return e.length===0?!1:Ut.has(e[e.length-1])}var Ht=new Set(["year","yr","fy"]),Kt=n=>j(n).some(e=>Ht.has(e)),Zt=/^(?:(?:19|20)\d{2}(?:[-/ ]?(?:q[1-4]|w(?:0?[1-9]|[1-4]\d|5[0-3])|(?:0?[1-9]|1[0-2])))?|q[1-4][-/ ](?:19|20)\d{2}|(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*[-/ ]?(?:19|20)?\d{2})$/i;function ae(n){if(!Number.isInteger(n)||n<190001||n>210012)return!1;let e=n%100;return e>=1&&e<=12}function ue(n){if(!Number.isInteger(n)||n<19000101||n>21001231)return!1;let e=Math.floor(n/100)%100,t=n%100;return e>=1&&e<=12&&t>=1&&t<=31}var jt=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Xt=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,Qt=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function qt(n){let e=(n||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}function Ze(n,e){let t=0,i=0,r=0,s=0,o=0,l="",u=0,c="",p=0,f=0,v=0,w=0,N=!1;for(let V of n){if(V==null)continue;let W=String(V).trim();if(W==="")continue;t++;let k;if(k=jt.exec(W)){let B=+k[2],$=+k[3];B>=1&&B<=12&&$>=1&&$<=31&&(i++,k[4]!==void 0&&r++,k[6]!==void 0&&s++)}else if(k=Xt.exec(W)){let B=+k[3],$=+k[4];B>=1&&B<=12&&$>=1&&$<=31&&(l&&l!==k[2]&&(N=!0),l=k[2],o++)}else if(k=Qt.exec(W)){let B=+k[1],$=+k[3];B>=1&&B<=31&&$>=1&&$<=31&&(B<=12||$<=12)&&(c&&c!==k[2]&&(N=!0),c=k[2],u++,B>12&&v++,$>12&&w++,k[5]!==void 0&&p++,k[7]!==void 0&&f++)}if(t>=200)break}if(t<2||(i+o+u)/t<.8||(i>0?1:0)+(o>0?1:0)+(u>0?1:0)!==1||N)return null;if(i>0)return r===i?{pattern:s===i?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(o>0)return{pattern:`%Y${l}%m${l}%d`,orderFrom:"iso"};if(v>0&&w>0)return null;let E,g;v>0?(E=!0,g="values"):w>0?(E=!1,g="values"):(E=!qt(e),g="locale");let F=E?`%d${c}%m${c}%Y`:`%m${c}%d${c}%Y`;return p===u?{pattern:F+(f===u?" %H:%M:%S":" %H:%M"),orderFrom:g}:{pattern:F,orderFrom:g}}function Jt(n,e){if(!e||!/\b(?:19|20)\d{2}\b/.test(n))return!1;let t=n.replace(/\b(?:19|20)\d{2}\b/g,"").replace(/[-/.,]/g," ").trim();if(!t)return!1;let i=Ae(t);return i.length>0&&e[i]!==void 0}function en(n){let{dataType:e,name:t,isMeasure:i,distinctCount:r}=n;if(e==="DateTime")return!0;if(i)return!1;if(e==="Integer"||e==="Decimal"){let s=n.minNum,o=n.maxNum;if(!(s!=null&&o!=null&&Number.isFinite(s)&&Number.isFinite(o)&&Number.isInteger(s)&&Number.isInteger(o)&&o>=s))return!1;let u=s>=1900&&o<=2100;if(u&&r>=2&&Kt(t)||u&&r>=3&&r===o-s+1)return!0;let c=ae(s)&&ae(o),p=ue(s)&&ue(o);if(c||p){if(!n.sampleValues)return!0;let f=0,v=0;for(let w of n.sampleValues){if(w==null||w==="")continue;f++;let N=Number(String(w).trim());if(Number.isFinite(N)&&(c?ae(N):ue(N))&&v++,f>=60)break}if(f>=2&&v===f)return!0}return!1}if(n.sampleValues){let s=n.locale?Ce(n.locale):null,o=0,l=0,u=[];for(let c of n.sampleValues){if(c==null||c==="")continue;o++;let p=String(c).trim();if(u.push(p),(Zt.test(p)||Jt(p,s))&&l++,o>=60)break}if(o>=2&&l/o>=.8||Ze(u,n.locale)!==null)return!0}return!1}function tn(n){let e=K((n||"").trim().toLowerCase());return e.startsWith("sum ")||e.startsWith("total ")?"sum":e.startsWith("average ")||e.startsWith("avg. ")?"avg":e.startsWith("count ")||e.startsWith("distinct count ")||e.startsWith("count (distinct) ")?"count":e.startsWith("min ")||e.startsWith("minimum ")?"min":e.startsWith("max ")||e.startsWith("maximum ")?"max":we.some(t=>e.startsWith(t+" "))?/^(minimum|minimo)\b/.test(e)?"min":/^(maximum|maximo|massimo)\b/.test(e)?"max":"avg":re.some(t=>e.startsWith(t+" ")||e===t)?/^(nombre|recuento|contagem|anzahl|aantal|conteggio|antal|lukumaara|pocet)\b/.test(e)?"count":"sum":null}function nn(n){let{rows:e,measureColIdx:t,measureName:i,candidateDims:r,minNum:s,maxNum:o,discourageAgg:l}=n,u=100,c=.01,p="";for(let v of r){if(v.distinct<2||v.distinct>u)continue;let w=r.filter(g=>g.idx!==v.idx).map(g=>g.idx),N=new Map;for(let g of e){let F=g[t];if(typeof F!="number"||!Number.isFinite(F))continue;let V=w.length?w.map(k=>String(g[k])).join(p):"",W=N.get(V);W||(W={sum:0,cset:new Set},N.set(V,W)),W.sum+=F,W.cset.add(String(g[v.idx]))}let P=0,_=0,E=0;for(let g of N.values())g.cset.size<2||(E++,Math.abs(g.sum-100)<=100*c?P++:Math.abs(g.sum-1)<=1*c&&_++);if(E>=2&&(P/E>=.9||_/E>=.9))return{additivity:"part_of_whole",partOfWholeDim:v.name}}if(l)return{additivity:"intensive_rate"};let f=tn(i);return f==="avg"||f==="min"||f==="max"?{additivity:"intensive_rate"}:f==="count"?{additivity:"additive"}:f==="sum"?{additivity:"unknown"}:s!=null&&o!=null&&Number.isFinite(s)&&Number.isFinite(o)&&s>=0&&o<=1.0001&&o>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function He(n){let{dataType:e,isMeasure:t,name:i,distinct:r,nonblank:s,prec:o,maxval:l,minval:u}=n,c=l-u+1,p=c>0?r/c:1,f=s>0?r/s:0,v=e==="Decimal"||o>0;return Yt(i)?"Categorical":p>=Gt&&(ge(i)&&r<=Wt||u>=Bt&&l<=$t||u>=Vt&&l<=zt)?"Ordinal":t||r>Pt&&(v||r>=kt||f>=Ft)?"Continuous":"Categorical"}function sn(n){let e=null;for(let t=0;t<n.length;t++){let i=n[t];if(typeof i!="string"||i.length===0)continue;let r=i.trim();r.length!==i.length&&(e||(e=n.slice()),e[t]=r)}return e||n}var Ke=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;dedupRows=!0;emitLegacyAggAliases=!1;STR(e){return e==null?"":e instanceof Date?this.wholeDayIso(e)??(isNaN(e.getTime())?"":e.toISOString()):e.toString()}getPrecision(e){if(!isFinite(e))return 0;let i=e.toString().split(".")[1];return i?i.length:0}getColumns(){return this._cols}wholeDayIso(e){return fe(e)}hasTimeComponent(e){return!(e instanceof Date)||isNaN(e.getTime())?!1:this.wholeDayIso(e)===null}getColumnsWithStats(e,t){if(this._computedStatsForLevel==e)return this._cols;let i=0,r=parseInt(e),s=[];for(let a of this._cols){let d=new Map,I=[],M=0,m=0,C=0,R=null,x=null,A=null,O=!1,D=!0,y=!0,S=null,T=!1;for(let h of this._rows){let b=h[i],L=this.STR(b);if(L!=""){if(M+=L.length,d.set(L,(d.get(L)||0)+1),m++,a.dataType=="Integer"||a.dataType=="Decimal"||a.dataType=="DateTime")if((R===null||b<R)&&(R=b),(x===null||b>x)&&(x=b),a.dataType=="Integer"||a.dataType=="Decimal"){if(A===null?A=b:A+=b,a.dataType=="Decimal"){let G=this.getPrecision(b);G>C&&(C=G)}I.push(b)}else O=O||this.hasTimeComponent(b);T&&(b<S?D=!1:b>S&&(y=!1)),S=b,T=!0}}if(m>=3&&(D&&!y?a.sortedDirection="asc":y&&!D?a.sortedDirection="desc":a.sortedDirection="none"),m>0&&d.size>0&&!a.isMeasure){let h=0,b=Number.MAX_SAFE_INTEGER;for(let L of d.values())L>h&&(h=L),L<b&&(b=L);if(a.modalShare=h/m,a.minGroupCount=b===Number.MAX_SAFE_INTEGER?null:b,d.size===2){let L=[...d.keys()].map(J=>ce(J).trim().toLowerCase()).sort(),q=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(J=>L[0]===J[0]&&L[1]===J[1]),Z=/^(is|has)[_a-z0-9]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/i.test(a.name);(q||Z)&&(a.isBinaryFlag=!0)}}if(a.dataType=="DateTime"&&(a.dateWithTime=O),a.isTemporal=en({dataType:a.dataType,name:a.name,isMeasure:a.isMeasure,distinctCount:d.size,minNum:typeof R=="number"?R:null,maxNum:typeof x=="number"?x:null,sampleValues:d.keys(),locale:t}),a.isTemporal&&a.dataType==="String"&&!a.isMeasure){let h=Ze(d.keys(),t);h&&(a.temporalTextPattern=h.pattern)}if(a.isTemporal&&!a.isMeasure){let h=Ue(d.keys(),{includeBounds:r>=20,pattern:a.temporalTextPattern});h&&(a.temporalCadence=h)}this.updateColumnStats10(r,a,m,d,C,x,R),this.updateColumnStats20(r,I,m,A,a,M,O,R,x,C,d,t),!a.isMeasure&&(a.dataType==="Integer"||a.dataType==="Decimal")&&He({dataType:a.dataType,isMeasure:!1,name:a.name,distinct:d.size,nonblank:m,prec:C,maxval:typeof x=="number"?x:0,minval:typeof R=="number"?R:0})==="Continuous"&&(a.isMeasure=!0,a.geoKind=void 0,a.geoMatchPct=void 0,a.geoAmbiguous=void 0,a.dominantGeoRegion=void 0,a.dominantGeoRegionPct=void 0,a.geoRegionCount=void 0),s[i]=a.isMeasure||d.size>2e3?null:new Set(d.keys()),i++}let o=[];this._cols.forEach((a,d)=>{a.isMeasure||o.push({idx:d,distinct:a.distinctCount??0,name:a.name})}),this._cols.forEach((a,d)=>{if(!a.isMeasure)return;let I=typeof a.lowValue=="number"?a.lowValue:null,M=typeof a.highValue=="number"?a.highValue:null,m=nn({rows:this._rows,measureColIdx:d,measureName:a.name,candidateDims:o,minNum:I,maxNum:M,discourageAgg:!!a.discourageAggregationAcrossGroups});a.additivity=m.additivity,m.partOfWholeDim&&(a.partOfWholeDim=m.partOfWholeDim)});let l=50,u=4,c=o.filter(a=>a.distinct>=2&&a.distinct<=l);this._cols.forEach((a,d)=>{if(!a.isMeasure)return;let I=[];for(let y of this._rows){let S=y[d];if(S==null||S==="")continue;let T=typeof S=="number"?S:parseFloat(S);isNaN(T)||I.push(T)}if(I.length===0)return;let M=[...I].sort((y,S)=>y-S);if(M[0]===M[M.length-1])a.relativeDispersion=0;else if(M.length>=u){let y=z(M,.5),S=z(M,.1),T=z(M,.9);a.relativeDispersion=Math.abs(y)>1e-9?Math.round((T-S)/Math.abs(y)*1e3)/1e3:void 0}else a.relativeDispersion=void 0;let m=[];for(let y of c){let S=new Set;for(let T of this._rows){let h=T[d];h==null||h===""||S.add(this.STR(T[y.idx])+"")}m.push({otherColumn:y.name,nonBlankGroupCount:S.size})}m.length>0&&(a.nonBlankGroups=m);let C=0;for(let y of I)C+=y;C/=I.length;let R=0;for(let y of I)R+=(y-C)*(y-C);if(R<=1e-12)return;let x=[],A=[],O=y=>{if(y.length<4)return NaN;let S=[...y].sort((h,b)=>h-b),T=h=>S[Math.min(S.length-1,Math.max(0,Math.floor(h*(S.length-1))))];return T(.75)-T(.25)},D=O(I);for(let y of c){let S=new Map;for(let b of this._rows){let L=b[d];if(L==null||L==="")continue;let G=typeof L=="number"?L:parseFloat(L);if(isNaN(G))continue;let q=this.STR(b[y.idx])+"",Z=S.get(q);Z?(Z.s+=G,Z.n++,Z.vals.push(G)):S.set(q,{s:G,n:1,vals:[G]})}let T=0;for(let b of S.values()){let L=b.s/b.n;T+=b.n*(L-C)*(L-C)}x.push({otherColumn:y.name,eta2:Math.round(T/R*1e4)/1e4});let h=[];for(let b of S.values()){let L=O(b.vals);isNaN(L)||h.push(L)}if(h.length>=2&&isFinite(D)&&D>1e-9){let b=(Math.max(...h)-Math.min(...h))/D;A.push({otherColumn:y.name,spreadRatio:Math.round(b*1e4)/1e4})}}x.length>0&&(a.groupDiscrimination=x),A.length>0&&(a.spreadDiscrimination=A)});let p=.97,f=.8,v=8,w=5,N=this._cols.map((a,d)=>({c:a,i:d})).filter(a=>a.c.isMeasure);for(let a=0;a<N.length;a++)for(let d=a+1;d<N.length;d++){let I=N[a].i,M=N[d].i,m=0,C=0,R=0,x=0,A=0,O=0;for(let T of this._rows){let h=T[I],b=T[M];if(h==null||h===""||b===null||b===void 0||b==="")continue;let L=typeof h=="number"?h:parseFloat(h),G=typeof b=="number"?b:parseFloat(b);isNaN(L)||isNaN(G)||(m++,C+=L,R+=G,x+=L*L,A+=G*G,O+=L*G)}if(m<w)continue;let D=m*x-C*C,y=m*A-R*R;if(D<=1e-12||y<=1e-12)continue;let S=(m*O-C*R)/Math.sqrt(D*y);if(Math.abs(S)>=p){let T=N[a].c,h=N[d].c;T.collinearWithMeasures||(T.collinearWithMeasures=[]),h.collinearWithMeasures||(h.collinearWithMeasures=[]),T.collinearWithMeasures.push(h.name),h.collinearWithMeasures.push(T.name)}else if(Math.abs(S)>=f){let T=N[a].c,h=N[d].c,b=Math.round(S*1e3)/1e3;T.correlatedWithMeasures||(T.correlatedWithMeasures=[]),h.correlatedWithMeasures||(h.correlatedWithMeasures=[]),T.correlatedWithMeasures.push({otherColumn:h.name,r:b}),h.correlatedWithMeasures.push({otherColumn:T.name,r:b})}}for(let{c:a}of N)a.correlatedWithMeasures&&(a.correlatedWithMeasures.sort((d,I)=>Math.abs(I.r)-Math.abs(d.r)||(d.otherColumn<I.otherColumn?-1:1)),a.correlatedWithMeasures.length=Math.min(a.correlatedWithMeasures.length,v));for(let a=0;a<this._cols.length;a++){let d=s[a];if(!d||d.size===0)continue;let I=[];for(let M=0;M<this._cols.length;M++){if(M===a)continue;let m=s[M];if(!m||m.size===0)continue;let C=0;for(let x of d)m.has(x)&&C++;let R=Math.round(C/d.size*100);R>0&&I.push({otherColumn:this._cols[M].name,percentShared:R})}I.length>0&&(this._cols[a].sharedValueRatioWithOthers=I)}let P=50,_=[];for(let a=0;a<this._cols.length;a++){let d=s[a];d&&d.size>=2&&d.size<=P&&_.push(a)}if(_.length>=2){let a=new Map,d=(M,m)=>M+":"+m;for(let M=0;M<_.length;M++)for(let m=M+1;m<_.length;m++)a.set(d(_[M],_[m]),new Map);for(let M of this._rows)for(let m=0;m<_.length;m++){let C=this.STR(M[_[m]])+"";for(let R=m+1;R<_.length;R++){let x=""+this.STR(M[_[R]]),A=a.get(d(_[m],_[R])),O=C+""+x;A.set(O,(A.get(O)??0)+1)}}let I=new Map;for(let M=0;M<_.length;M++)for(let m=M+1;m<_.length;m++){let C=_[M],R=_[m],x=s[C].size,A=s[R].size,O=a.get(d(C,R)),D=O.size,y=0;for(let b of O.values())(y===0||b<y)&&(y=b);let S=Math.round(D/(x*A)*100),T=D===x,h=D===A;if((this._cols[C].categoricalPairStats||=[]).push({otherColumn:this._cols[R].name,fillPct:S,determinesOther:T,minCellCount:y,distinctCombinations:D}),(this._cols[R].categoricalPairStats||=[]).push({otherColumn:this._cols[C].name,fillPct:S,determinesOther:h,minCellCount:y,distinctCombinations:D}),T&&x>A){let b=I.get(C);(!b||A<b.card)&&I.set(C,{name:this._cols[R].name,card:A,ratio:A/x})}if(h&&A>x){let b=I.get(R);(!b||x<b.card)&&I.set(R,{name:this._cols[C].name,card:x,ratio:x/A})}}for(let[M,m]of I)this._cols[M].primaryParentColumn=m.name,this._cols[M].nestingRatio=Math.round(m.ratio*100)/100}let E=6,g=this._rows.length;for(let a=0;a<this._cols.length;a++){let d=this._cols[a];if(d.isMeasure||d.primaryParentColumn)continue;let I=d.distinctCount??0;if(I<=P||g>0&&I>=g)continue;let M=[];for(let m=0;m<this._cols.length;m++){if(m===a)continue;let C=this._cols[m];if(C.isMeasure)continue;let R=C.distinctCount??0;R<2||R>=I||M.push(m)}M.sort((m,C)=>(this._cols[m].distinctCount??0)-(this._cols[C].distinctCount??0));for(let m of M.slice(0,E)){let C=new Map,R=!0;for(let A of this._rows){let O=this.STR(A[a])+"",D=this.STR(A[m])+"",y=C.get(O);if(y===void 0)C.set(O,D);else if(y!==D){R=!1;break}}if(!R)continue;let x=this._cols[m].distinctCount??0;d.primaryParentColumn=this._cols[m].name,d.nestingRatio=Math.round(x/I*100)/100;break}}let F=.01,V=.05,W=.95,k=8,B=8,$=6,je=500,Y=[];for(let a=0;a<this._cols.length&&Y.length<B;a++){let d=this._cols[a].dataType;(d==="Double"||d==="Integer"||d==="Decimal")&&Y.push(a)}if(Y.length>=3&&this._rows.length>=k){let a=Math.min(this._rows.length,je),d=Y.map(x=>{let A=[];for(let y=0;y<a;y++){let S=this._rows[y][x],T=typeof S=="number"?S:parseFloat(String(S).replace(/,/g,""));if(S==null||S===""||!isFinite(T))return null;A.push(T)}let O=A[0],D=!1;for(let y of A)if(y!==O){D=!0;break}return D?A:null}),I=Y.map((x,A)=>A).filter(x=>d[x]!==null),M=x=>{let A=x.slice().sort((D,y)=>D-y),O=A.length>>1;return A.length%2?A[O]:(A[O-1]+A[O])/2},m=null,C=[],R=x=>{if(C.length>=3){let A=C.map(S=>d[S]),O=A[0].length,D=new Array(O);for(let S=0;S<O;S++){let T=0;for(let h of A)T+=h[S];D[S]=T}let y=M(D);if(y>0){let S=0;for(let h of D)Math.abs(h-y)<=y*F&&S++;let T=S/O;if(T>=W){let h=1;for(let b of A){let L=M(b)/y;L<h&&(h=L)}h>=V&&(!m||C.length>m.cols.length)&&(m={cols:C.slice(),total:y,matched:T})}}}if(!(C.length>=$))for(let A=x;A<I.length;A++)C.push(I[A]),R(A+1),C.pop()};if(R(0),m){let x=m,O={columns:x.cols.map(D=>this._cols[Y[D]].name),total:Math.round(x.total*1e3)/1e3,matchedPct:Math.round(x.matched*100)/100};for(let D of x.cols)this._cols[Y[D]].constantSumGroup=O}}return this._computedStatsForLevel=e,this._cols}updateColumnStats20(e,t,i,r,s,o,l,u,c,p,f,v){if(e>=20){let w=[...t].sort((_,E)=>_-E),N=Math.floor(w.length/2);if(i>0&&r!=null?s.avgValue=s.dataType=="Integer"?Math.round(r/i):r/i:s.avgValue=null,i>0&&(s.avgLength=o/i),this._rows.length>0){let _=E=>{let g=E instanceof Date?E:typeof E=="string"?ie(E)??new Date(E):new Date(E),F=this.wholeDayIso(g);return F?F+"T00:00:00.000Z":isNaN(g.getTime())?E:g.toISOString().slice(0,10)+"T00:00:00.000Z"};s.dataType!="DateTime"||l||!u?s.lowValue=u:s.lowValue=_(u),s.dataType!="DateTime"||l||!c?s.highValue=c:s.highValue=_(c),s.medianValue=w.length===0?null:w.length%2===0?s.dataType=="Integer"?Math.round((w[N-1]+w[N])/2):(w[N-1]+w[N])/2:w[N],s.numericPrecision=p}if(w.length>0){let _=s.avgValue??0,E=w.length,g=0,F=0;for(let W of w){let k=W-_;g+=k*k,F+=k*k*k}let V=g/E;s.skewness=V===0?0:F/E/Math.pow(Math.sqrt(V),3),s.stdDev=Math.sqrt(V)}r!==null&&(s.sum=r);let P=Array.from(f.entries()).sort((_,E)=>E[1]-_[1]);if(s.topCategories=P.slice(0,10).map(_=>_[1]),!s.isMeasure&&P.length>0){if(s.dataType==="String"){let _=P.map(g=>g[0]);s.formatSignature=Se(_);let E=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;s.formatSignature&&!E.test(s.formatSignature)&&(s.avgLength===void 0||s.avgLength>=3)&&(s.isFreeText=!0)}else s.topCategoryValues=P.slice(0,5).map(_=>_[0]);if(e>=20){let _=P.map(g=>g[0]),E=he(_,v);if(E!==null)s.ordinalPattern=E.pattern,s.orderedDomain=E.orderedDomain;else if(s.dataType==="String"){let g=pe(_);g!==null&&(s.safeDistinctValues=g)}}}if(w.length>=8&&(s.dataType==="Integer"||s.dataType==="Decimal")){let _=E=>w[Math.floor((w.length-1)*E)];s.quantiles={p05:_(.05),p25:_(.25),p75:_(.75),p95:_(.95)}}}if(!s.isMeasure&&f.size>0){let w=Array.from(f.entries()).sort((P,_)=>_[1]-P[1]),N=_e(w.map(P=>P[0]),s.name,v);if(N!==null&&(s.geoKind=N.geoKind,s.geoMatchPct=N.geoMatchPct,N.geoAmbiguous&&(s.geoAmbiguous=!0),N.geoKind.indexOf("country")===0)){let P=se(w);P&&(s.dominantGeoRegion=P.dominantGeoRegion,s.dominantGeoRegionPct=P.dominantGeoRegionPct,s.geoRegionCount=P.regionCount)}}}updateColumnStats10(e,t,i,r,s,o,l){e>=10&&(t.blankCount=this._rows.length-i,t.distinctCount=r.size+(t.blankCount!=0?1:0),t.valueNature="Categorical",i>0&&(t.dataType==="Integer"||t.dataType==="Decimal"?t.valueNature=He({dataType:t.dataType,isMeasure:!!t.isMeasure,name:t.name,distinct:r.size,nonblank:i,prec:s,maxval:o,minval:l}):t.dataType==="DateTime"&&(t.valueNature=t.dateWithTime?"Continuous":"Ordinal")))}getRowCount(){return this._rows.length}getLeafCardinality(){if(this._leafCardinality!==null)return this._leafCardinality;let e=[];if(this._cols.forEach((i,r)=>{i.isMeasure||e.push(r)}),e.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let t=new Set;for(let i of this._rows)t.add(JSON.stringify(e.map(r=>i[r])));return this._leafCardinality=t.size,this._leafCardinality}_leafCardinality=null;getGeoExtent(){if(this._geoExtentComputed)return this._geoExtent;this._geoExtentComputed=!0,this._geoExtent=null;let e=o=>String(o||"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z]+/),t=-1,i=-1,r=-1;if(this._cols.forEach((o,l)=>{let u=e(o.name),c=o.dataType==="Integer"||o.dataType==="Decimal";c&&t<0&&u.some(p=>p==="lat"||p==="latitude")?t=l:c&&i<0&&u.some(p=>p==="lon"||p==="lng"||p==="long"||p==="longitude")&&(i=l),r<0&&!o.isMeasure&&typeof o.geoKind=="string"&&o.geoKind.indexOf("country")===0&&(r=l)}),t<0||i<0)return null;let s=[];for(let o of this._rows){let l=o[t],u=o[i],c=l==null||l===""?null:Number(l),p=u==null||u===""?null:Number(u);s.push({lat:c,lon:p,country:r>=0&&ee(this.STR(o[r]))?this.STR(o[r]):null})}return this._geoExtent=Re(s),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(e){return ve(e,de)}toObjectArray(){let e=this.liveEnglishAliases();return this._rows.map(t=>{let i={};this._cols.forEach((r,s)=>{i[r.name]=t[s],this.emitLegacyAggAliases&&r.hostName&&r.hostName!==r.name&&!Object.prototype.hasOwnProperty.call(i,r.hostName)&&(i[r.hostName]=t[s])});for(let[r,s]of e)Object.prototype.hasOwnProperty.call(i,s.alias)||(i[s.alias]=t[r]);return i})}async getCSVAsync(e){let t=[],i=e?25:1e7,r=e?4e3:1e7,s=new Map;for(let l of this._rows){let u={};for(let c=0;c<this._cols.length;c++){let p=this._cols[c],f=l[c];if(this.STR(f)!=""){if(e&&p.dataType=="String")if(s.has(f))f=s.get(f);else{let v=this.obfuscateString(f);s.set(f,v),f=v}else if(p.dataType=="DateTime"&&!p.dateWithTime){let v=f instanceof Date?f:typeof f=="string"?ie(f)??new Date(f):new Date(f);f=(this.wholeDayIso(v)??v.toISOString().slice(0,10))+"T00:00:00.000Z"}r-=this.STR(f).length}else f=null;u[c]=f,--r}if(t.push(u),--i,i<=0||r<=0)break}return await Ye.unparse(t,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return Ye.unparse([this._cols.map((t,i)=>{if(this.emitLegacyAggAliases&&t.hostName)return this.STR(t.hostName);let r=e.get(i);return this.STR(r&&r.headerName?r.alias:t.name)})])}setHostQueryNames(e){this._hostQueryNames=(e??[]).map(t=>t==null?null:this.STR(t)),this._englishAliases=new Map}aliasesForCode(e){let t=oe(e,this._cols)?this.legacyAliases():[];for(let i of this.englishAliasesFor(e).values())t.push({name:i.name,alias:i.alias,reason:"english-implicit-agg"});return t}armAliasesForCode(e){return this.emitLegacyAggAliases=oe(e,this._cols),this._englishAliases=this.englishAliasesFor(e),this.getArmedAliases()}getArmedAliases(){let e=this.emitLegacyAggAliases?this.legacyAliases():[];for(let t of this.liveEnglishAliases().values())e.push({name:t.name,alias:t.alias,reason:"english-implicit-agg"});return e}legacyAliases(){let e=[];for(let t of this._cols)t&&t.hostName&&t.hostName!==t.name&&e.push({name:this.STR(t.name),alias:this.STR(t.hostName),reason:"doubled-agg-prefix"});return e}englishAliasesFor(e){let t=new Map;if(!e||this._hostQueryNames.length===0||!this._cols||this._cols.length===0)return t;let i=String(e),r=new Set;for(let o of this._cols)o&&(r.add(this.STR(o.name)),o.hostName&&r.add(this.STR(o.hostName)));let s=new Map;for(let o=0;o<this._cols.length;o++){if(!this._cols[o])continue;let l=Pe(this._hostQueryNames[o]).filter(u=>!r.has(u)&&Q(i,u));l.length===1&&s.set(l[0],[...s.get(l[0])??[],o])}for(let[o,l]of s){if(l.length!==1)continue;let u=this.STR(this._cols[l[0]].name);t.set(l[0],{name:u,alias:o,headerName:!Q(i,u)})}return t}liveEnglishAliases(){let e=new Map;for(let[t,i]of this._englishAliases){let r=this._cols?this._cols[t]:null;r&&this.STR(r.name)===i.name&&e.set(t,i)}return e}addRow(e,t){if(this.dedupRows){let i="";for(let s of e)i+=this.STR(s)+"~";let r=me(i);if(this._rowHashes.has(r))return!1;this._rowHashes.add(r)}return this._rows.push(sn(e)),this._origIndices.push(t??-1),!0}getOriginalRowIndex(e){return e<0||e>=this._origIndices.length?-1:this._origIndices[e]}reset(){this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null,this._hostQueryNames=[],this._englishAliases=new Map}setColumns(e){if(this._cols=e,!e||e.length===0)return;let t=new Set(e.map(i=>this.STR(i?.name)));for(let i of e){if(!i)continue;let r=this.STR(i.name),s=De(r);!s||s===r||t.has(s)||(t.delete(r),t.add(s),i.hostName=r,i.name=s)}}};export{Re as a,qe as b,ee as c,an as d,rt as e,ot as f,at as g,ut as h,Le as i,ft as j,De as k,oe as l,Pe as m,Fe as n,bt as o,We as p,Be as q,dn as r,fn as s,gn as t,Q as u,Mt as v,hn as w,yn as x,_n as y,Lt as z,Ue as A,Yt as B,Ze as C,en as D,tn as E,nn as F,He as G,sn as H,Ke as I};