@bicharts/shape-core 0.6.83 → 0.6.84

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.
@@ -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 fe}from"./chunk-U3H6UBOO.mjs";import{a as rt,f as q,g as ge,h as ie,i as pe,j as ne}from"./chunk-A4PQBWRA.mjs";import{c as nt}from"./chunk-QPIKC2O6.mjs";import{f as et,k as tt}from"./chunk-INMDBTAR.mjs";import{e as Xe,k as me,m as qe,n as Je,o as de}from"./chunk-IIGGO4ES.mjs";import{a as ue,b as Q,c as We,d as ce,g as Ge,h as ze,j as $e,l as Ue,m as Ve,o as Ke,p as X,q as He,r as Ye,u as Me,w as je}from"./chunk-NT6CDI3K.mjs";import{c as Be,f as Ce}from"./chunk-WC4JINEZ.mjs";import{b as Ze,d as Qe}from"./chunk-5HI6TVMM.mjs";var $t=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],Ut=[7,72,-172,-52];function it(t,e,n){return t>=n[0]&&t<=n[1]&&e>=n[2]&&e<=n[3]}var J=t=>Math.round(t*10)/10;function ot(t,e=3){let n=[],s=[],r=0,i=0;for(let l of t){let a=l?.lat,g=l?.lon;if(typeof a!="number"||typeof g!="number"||!isFinite(a)||!isFinite(g)||a<-90||a>90||g<-180||g>180)continue;n.push(a),s.push(g);let p=l?.country?String(l.country).trim().toUpperCase():"",m=p?he(p):null;m?((p==="US"||p==="USA")&&r++,m==="north-america"&&i++):($t.some(c=>it(a,g,c))&&r++,it(a,g,Ut)&&i++)}let o=n.length;return o<e?null:(n.sort((l,a)=>l-a),s.sort((l,a)=>l-a),{pctUsa:J(r/o*100),pctNa:J(i/o*100),latP5:J(X(n,.05)),latP95:J(X(n,.95)),lonP5:J(X(s,.05)),lonP95:J(X(s,.95)),n:o})}var st={"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"},se=(()=>{let t=new Map;for(let e of Object.keys(st))for(let n of st[e].split(/\s+/))n&&t.set(n,e);return t})();function Vt(t){for(let[e,n]of t){let s=se.get(e);s&&!se.has(n)&&se.set(n,s)}}Vt(et);function he(t){if(!t)return null;let e=String(t).trim().toUpperCase();if(!e)return null;let n=se.get(e);if(n)return n;let s=tt(String(t));return s?se.get(s)??null:null}function Xr(t,e=2){return Te(t.map(n=>[n,1]),e)}function Te(t,e=2){let n=new Map,s=0;for(let[o,l]of t){let a=he(o);if(!a)continue;let g=typeof l=="number"&&isFinite(l)&&l>0?l:1;n.set(a,(n.get(a)??0)+g),s+=g}if(s<e||!n.size)return null;let r="europe",i=-1;for(let o of Array.from(n.keys()).sort()){let l=n.get(o);l>i&&(r=o,i=l)}return{dominantGeoRegion:r,dominantGeoRegionPct:J(i/s*100),regionCount:n.size,n:s}}function Ie(t){let e=(t||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}var Re={a:0,b:0,c:0,yearFirst:!1,sep:"",trail:"",word:"",day:0,year:0,namedOrder:"dmy",cjkPattern:""},Kt=/\s+(\d{1,2}):(\d{2})(?::(\d{2})(?:[.,]\d{1,9})?)?(?:\s*([ap])\.?\s?m\.?)?$/i,Ht=/^(\d{1,4})(\s*[./-]\s*)(\d{1,2})(\s*[./-]\s*)(\d{1,4})(\.?)$/,Yt=/^(\d{4})(\s*[年년]\s*)(\d{1,2})(\s*[月월]\s*)(\d{1,2})(\s*[日일号])$/,jt=/(\d)(?:st|nd|rd|th|er|º|ª)(?=[\s.,/-]|$)/gi,Xt=new Set(["de","del","of"]),Zt=new Set(["\u0433","\u0440","r"]),Qt=/^[\p{L}\p{M}\u0970\u05f3]+$/u,we=/^\d+$/;function qt(t){let e=+t[1],n=+t[2],s=t[3]===void 0?0:+t[3],r=t[4]!==void 0;if(n>59||s>59)return null;if(r){if(e<1||e>12)return null;e=e%12+(t[4].toLowerCase()==="p"?12:0)}else if(e>23)return null;return{h:e,mi:n,s,seconds:t[3]!==void 0,meridiem:r}}function at(t){let e=t.replace(/[\u200e\u200f\u061c]/g,"").replace(/\s+/g," ").trim();if(e==="")return null;e=rt(e);let n=null,s=Kt.exec(e);if(s){if(n=qt(s),!n)return null;e=e.slice(0,s.index)}let r;if(r=Yt.exec(e)){let c=`cjk|${r[2]}|${r[4]}|${r[6]}`;return{...Re,form:"cjk",key:c,clock:n,a:+r[1],b:+r[3],c:+r[5],yearFirst:!0,cjkPattern:`%Y${r[2]}%m${r[4]}%d${r[6]}`}}if(r=Ht.exec(e)){let c=r[2],_=r[4];if(c!==_)return null;let M=c.trim(),N=r[6];if(N&&M!==".")return null;let A=[r[1].length,r[3].length,r[5].length],f=A[0]===4,d=A[2]===4;return f===d||(f?A[1]>2||A[2]>2:A[0]>2||A[1]>2)?null:f&&M==="-"&&c==="-"&&A[1]===2&&A[2]===2?"iso":f&&M==="."&&c==="."&&!N&&!(A[1]===2&&A[2]===2)?null:{...Re,form:"numeric",key:`num|${f?"y":"x"}|${c}|${N}`,clock:n,a:+r[1],b:+r[3],c:+r[5],yearFirst:f,sep:c,trail:N}}let i=e.replace(jt,"$1").split(/[\s.,/-]+/).filter(c=>c!==""&&!Xt.has(c.toLowerCase()));if(i.length===4&&we.test(i[2])&&Zt.has(i[3].toLowerCase())&&i.pop(),i.length!==3)return null;let o=i.map(c=>we.test(c)?"N":Qt.test(c)?"W":"?").join(""),l=i.map(c=>we.test(c)?c:""),a=0,g=0,p="",m;if(o==="NWN"&&l[0].length<=2&&l[2].length===4)a=+l[0],p=i[1],g=+l[2],m="dmy";else if(o==="WNN"&&l[1].length<=2&&l[2].length===4)p=i[0],a=+l[1],g=+l[2],m="mdy";else if(o==="NWN"&&l[0].length===4&&l[2].length<=2)g=+l[0],p=i[1],a=+l[2],m="ymd";else return null;return{...Re,form:"named",key:`named|${m}`,clock:n,day:a,year:g,word:p,namedOrder:m}}var Jt=[31,28,31,30,31,30,31,31,30,31,30,31],en=t=>t%4===0&&t%100!==0||t%400===0;function lt(t,e,n){return t>=1&&t<=9999&&e>=1&&e<=12&&n>=1?n<=(e===2&&en(t)?29:Jt[e-1]):!1}function tn(t,e,n,s){let r=new Date(Date.UTC(2e3,e-1,n,s?.h??0,s?.mi??0,s?.s??0));return r.setUTCFullYear(t),r}function ut(t,e={}){let n=(e.floor??1)>=1,s=new Map,r=new Map,i=0,o=null;for(let f of t){if(f==null)continue;if(typeof f!="string"){if(n)return null;i++;continue}let d=f.trim();if(d==="")continue;i++;let b=s.get(d);if(b===void 0&&(b=at(d),s.set(d,b)),b===null||b==="iso"){if(n)return null;continue}if(n){if(o===null)o=b;else if(b.key!==o.key)return null}else r.set(b.key,(r.get(b.key)??0)+1)}if(!n){let f=0,d="";for(let[b,y]of r)y>f&&(f=y,d=b);if(f===0||f/i<e.floor)return null;o=[...s.values()].find(b=>b!==null&&b!=="iso"&&b.key===d)??null}if(o===null)return null;let l=o.key,a=[...s.values()].filter(f=>f!==null&&f!=="iso"&&f.key===l),g,p="shape",m=null;if(o.form==="named"){if(g=o.namedOrder,m=pe(a.map(f=>f.word),e.locale),!m)return null}else if(o.form==="cjk"||o.yearFirst)g="ymd";else{let f=0,d=0;for(let b of a)b.a>12&&f++,b.b>12&&d++;if(f>0&&d>0)return null;f>0?(g="dmy",p="values"):d>0?(g="mdy",p="values"):o.sep.trim()==="."?(g="dmy",p="shape"):(g=Ie(e.locale)?"mdy":"dmy",p="locale")}let c=f=>{if(f.form==="named"){let d=m.get(q(f.word));return d===void 0?null:[f.year,d+1,f.day]}return f.yearFirst?[f.a,f.b,f.c]:g==="dmy"?[f.c,f.b,f.a]:[f.c,f.a,f.b]},_=1/0,M=-1/0,N=0;for(let f of a){let d=c(f);if(!d||!lt(d[0],d[1],d[2])){if(n)return null;N++;continue}_=Math.min(_,d[0]),M=Math.max(M,d[0])}if(!n&&(r.get(l)-N)/i<e.floor||_>=2400&&M<=2699||_>=1300&&M<=1500)return null;let A={form:o.form,order:g,orderFrom:p,hasTime:a.some(f=>f.clock!==null),read(f){if(typeof f!="string")return null;let d=f.trim();if(d==="")return null;let b=s.get(d);if(b===void 0&&(b=at(d),s.set(d,b)),b===null||b==="iso"||b.key!==l)return null;let y=c(b);return!y||!lt(y[0],y[1],y[2])?null:tn(y[0],y[1],y[2],b.clock)}};if(o.form!=="named"&&!a.some(f=>f.clock?.meridiem)){let f;o.form==="cjk"?f=o.cjkPattern:o.yearFirst?f=`%Y${o.sep}%m${o.sep}%d${o.trail}`:f=(g==="dmy"?`%d${o.sep}%m${o.sep}%Y`:`%m${o.sep}%d${o.sep}%Y`)+o.trail;let d=a.filter(b=>b.clock!==null).length;d===0?A.pattern=f:d===a.length&&(A.pattern=f+(a.every(b=>b.clock.seconds)?" %H:%M:%S":" %H:%M"))}return A}import Bt from"papaparse";var nn=["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","capita","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","ocupacion","ocupacao","occupazione","auslastung","bezetting","belaggning","belaegning","belegg","kayttoaste","oblozenie","obsazenost","obsadenost","kihasznaltsag","doluluk","ocupare","popunjenost","efficacite","eficiencia","efficienza","effizienz","effectiviteit","verimlilik"],rn=["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"],sn=["latitude","longitude"],on=["latitude","longitude"];function Z(t){return ue(t)}var dt=["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","sum pa","\u0441\u0443\u043C\u043C\u0430","\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E","\u0441\u0443\u043C\u0430","\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C","\u03B1\u03B8\u03C1\u03BF\u03B9\u03C3\u03BC\u03B1","\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2"],an=["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","prom.","\u0441\u0440\u0435\u0434\u043D\u0435\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435","\u0441\u0440\u0435\u0434\u043D\u0435\u0435","\u0441\u0435\u0440\u0435\u0434\u043D\u0454","\u03BC\u03B5\u03C3\u03BF\u03C2 \u03BF\u03C1\u03BF\u03C2","\u0645\u06CC\u0627\u0646\u06AF\u06CC\u0646"],ln=["osszege","sucet","\u7684\u603B\u548C","\u7684\u8BA1\u6570","\u306E\u5408\u8A08","\uC758 \uD569\uACC4"],un=["atlaga","priemer","\u7684\u5E73\u5747\u503C","\u306E\u5E73\u5747","\uC758 \uD3C9\uADE0"],ye=Object.freeze({"nombre de":"count","recuento de":"count","contagem de":"count","anzahl von":"count","aantal van":"count","conteggio di":"count","antal av":"count",lukumaara:"count","pocet z":"count",\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E:"count",\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C:"count",\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2:"count",\u7684\u8BA1\u6570:"count","minimum de":"min","minimo de":"min","minimo di":"min","minimum von":"min","maximum de":"max","maximo de":"max","massimo di":"max","maximum von":"max"});function Ne(t){return[...t].sort((e,n)=>n.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var ft=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+Ne(dt)+")\\s+)","i");function ct(t){for(let e of t){let n=e.codePointAt(0)??0;if(n>=11904&&n<=40959||n>=44032&&n<=55215)return!0}return!1}var cn="[\u2013\u2014-]";function gt(t){let e=t.filter(r=>!ct(r)),n=t.filter(ct),s=[];return e.length&&s.push("(?:\\s+|\\s*"+cn+"\\s*)("+Ne(e)+")"),n.length&&s.push("\\s*("+Ne(n)+")"),new RegExp("(?:"+s.join("|")+")\\s*$","i")}var Ee=gt(ln),mn=gt(un);function be(t,e){let n=e.exec(t);if(!n)return null;let s=t.slice(0,n.index);return s.trim()===""?null:{base:s,label:(n[1]??n[2]??"").toLowerCase()}}function pt(t){let e=Z(String(t??"").trim().toLowerCase());if(!e)return null;for(let r of an)if(e.startsWith(r+" "))return ye[r]??"avg";for(let r of dt)if(e.startsWith(r+" ")||e===r)return ye[r]??"sum";let n=be(e,mn);if(n)return ye[n.label]??"avg";let s=be(e,Ee);return s?ye[s.label]??"sum":null}var dn=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,fn=new RegExp("\\b("+nn.join("|")+")\\b|("+rn.join("|")+")$","i"),gn=new RegExp("\\b("+sn.join("|")+")\\b|("+on.join("|")+")$","i");function Se(t){if(!t)return"";let e=String(t),n=Z(e),s=ft.exec(n);if(s)return e.slice(s[0].length).trim();let r=be(n,Ee);return(r?e.slice(0,r.base.length):e).trim()}function pn(t){if(!t)return!1;let e=Z(String(t));return ft.test(e)||be(e,Ee)!==null}var hn=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],mt=new RegExp("^\\s*("+[...hn].sort((t,e)=>e.length-t.length).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function ht(t){if(t==null)return"";let e=String(t),n=mt.exec(e);if(!n)return e;let s=l=>l.toLowerCase().replace(/\s+/g," ").trim(),r=s(n[1]),i=e.slice(n[0].length),o=0;for(;o<8;){let l=mt.exec(i);if(!l||s(l[1])!==r)break;let a=i.slice(l[0].length);if(a.trim()==="")break;i=a,o++}return o===0?e:e.slice(0,n[0].length)+i}function ve(t,e){if(!t||!e)return!1;let n=String(t);for(let s of e){let r=s?.hostName;if(r&&r!==s?.name&&n.includes(r))return!0}return!1}var yt={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 "]},yn=new RegExp("^("+Object.keys(yt).join("|")+")\\((.+)\\)$");function bt(t){if(!t)return[];let e=yn.exec(String(t).trim());if(!e)return[];let n=yt[e[1]],s=e[2],r=[];for(let i=s.indexOf(".");i>=0;i=s.indexOf(".",i+1)){if(i===0)continue;let o=s.slice(i+1);if(o.trim()!=="")for(let l of n){let a=l+o;r.includes(a)||r.push(a)}}return r}function bn(t){let e=Se(t);return e.length===0?"":e.replace(dn," ")}function St(t,e){if(!e)return!1;let n=Se(e);return t.test(Z(bn(e)))||t.test(Z(n))||t.test(Z(Q(n).join(" ")))}function At(t){return St(gn,t)}function Sn(t){return St(fn,t)||At(t)}var _t=/int|double|decimal|single|float|number|currency|money/i;function An(t){let e=String(t?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||t?.isMeasure===!0||_t.test(String(t?.dataType??""))?"Continuous":"Categorical"}function _n(t){return t?.isMeasure===!0||_t.test(String(t?.dataType??""))}function xt(t){let e=t??{},n=An(e);if(n!=="Continuous")return{nature:n,additivity:"unknown",basis:"role",suppressed:!1};if(At(e.name))return{nature:n,additivity:"positional",basis:"name",suppressed:!0};let s=String(e.additivity??"").trim().toLowerCase();if(!(s==="additive"&&pn(e.name))){if(s==="additive")return{nature:n,additivity:"additive",basis:"measured",suppressed:!1};if(s==="part_of_whole")return{nature:n,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(s==="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}:Sn(e.name)?{nature:n,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:n,additivity:"additive",basis:"default",suppressed:!1}}function Ct(t){let e=xt(t),n=t??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return _n(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 ni(t){return Ct(t)[0]}function ri(t,e){return Ct(t).indexOf(e)>=0}function ii(t,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let n=xt(t);return n.additivity==="additive"||n.additivity==="part_of_whole"||n.additivity==="unknown"}var xn={de:["nr","nummer","kennung","kennziffer","plz","postleitzahl"],nl:["nr","nummer"],sv:["nr","nummer"],da:["nr","nummer"],nb:["nr","nummer"],fi:["tunnus","koodi","nro"],hu:["azonos\xEDt\xF3","k\xF3d"],tr:["kod","kodu","numaras\u0131","numarasi"],zh:["\u7F16\u53F7","\u4EE3\u7801","\u7F16\u7801","\u53F7\u7801","\u90AE\u7F16"],ja:["\u756A\u53F7","\u30B3\u30FC\u30C9"],ko:["\uBC88\uD638","\uCF54\uB4DC"],hi:["\u0915\u094B\u0921","\u0915\u094D\u0930\u092E\u093E\u0902\u0915"],fr:["num\xE9ro"],es:["c\xF3digo"],pt:["c\xF3digo","cep"],it:["codice"],pl:["kod","numer"],cs:["k\xF3d","\u010D\xEDslo"],sk:["k\xF3d","\u010D\xEDslo"],hr:["\u0161ifra","oznaka"],ru:["\u043A\u043E\u0434","\u043D\u043E\u043C\u0435\u0440"],uk:["\u043A\u043E\u0434","\u043D\u043E\u043C\u0435\u0440"],el:["\u03BA\u03C9\u03B4\u03B9\u03BA\u03CC\u03C2"],ar:["\u0631\u0645\u0632","\u0643\u0648\u062F","\u0631\u0642\u0645"],he:["\u05E7\u05D5\u05D3"],id:["kode","nomor"],vi:["m\xE3"],th:["\u0E23\u0E2B\u0E31\u0E2A"]},Cn=["fr","es","pt","it","pl","cs","sk","hr","ru","uk","el","ar","he","id","vi","th"],Mn=["num\xE9ro"],Tn=t=>t.normalize("NFC").toLowerCase();function Rn(t,e,n,s){let r=Ce(n);return!r||!t?null:t===e?"word":r.wordBreaks===!1?Array.from(e).length<Ve?null:(s?t.startsWith(e):t.endsWith(e))&&t.length>e.length?"suffix":null:s?$e(t,n).includes(e)?"word":null:r.script==="Hang"?Ue(t,e)?"suffix":null:r.compounds&&ze(t,e,Ge)?"suffix":null}function Mt(t){let e=String(t??"").trim();if(!e)return null;let n=ce(e),s=ce(Se(e));for(let[r,i]of Object.entries(xn)){let o=Cn.includes(r),l=o?s:n;for(let a of i){let g=Mn.includes(a)||!!Ce(r)?.foldSensitive,p=g?l.words:l.folded;if(p.length===0)continue;let m=g?Tn(a):ce(a).folded.join(" "),c=Rn(o?p[0]:p[p.length-1],m,r,o);if(c)return{lang:r,word:a,view:c}}}return null}var wn=[["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 Ae(t){for(let[e,n]of wn)if(n.test(t))return e;return null}var In=[{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]]}],_e=new Map;function Tt(t,e,n,s){let r=_e.get(t);if(r)return r;let i=[];for(let[o,l]of e)for(let a=o;a<=l;a++){let g=String.fromCodePoint(a);Ae(g)===n&&(s&&!s.test(g)||i.push(g))}return _e.set(t,i),i}function Nn(t){let n=t.codePointAt(0);for(let o=0;o<9&&Ae(String.fromCodePoint(n-1))==="Nd";o++)n--;let s="nd:"+n.toString(16),r=_e.get(s);if(r)return r;let i=[];for(let o=n;o<n+10;o++){let l=String.fromCodePoint(o);Ae(l)==="Nd"&&i.push(l)}return _e.set(s,i),i}function En(t,e){if(e==="Nd")return Nn(t);for(let r of In)if(r.test.test(t))return Tt(r.id+":"+e,r.ranges,e,r.id==="ascii"?null:r.test);let s=t.codePointAt(0)&-128;return Tt("block:"+s.toString(16)+":"+e,[[s,s+127]],e,null)}function vn(t,e,n,s){let r=t.filter(i=>!e.has(i));return r.length===0&&(r=t.filter(i=>i!==n)),r.length===0?n:r[Math.min(r.length-1,Math.floor(s()*r.length))]}var kn=/^[\p{L}\p{M}\p{Nd}]$/u,Rt=/^[\p{L}\p{Nd}]$/u;function wt(t,e){if(!t)return t??"";let n=new Set(Array.from(t)),s=p=>{let m=Ae(p);return!m||!kn.test(p)?p:vn(En(p,m),n,p,e)},r=p=>{let m=[];for(let c of p)m.push(s(c)),Rt.test(c)&&e()<.2&&m.push(s(c));if(m.length>6){let c=Math.floor(e()*Math.min(3,m.length-6));for(let _=0;_<c;_++)for(let M=0;M<5;M++){let N=Math.floor(e()*m.length);if(Rt.test(m[N])){m.splice(N,1);break}}}return m.join("")};if(!(t.includes("@")&&t.includes(".")))return r(t);let[o,l=""]=t.split("@"),a=l.endsWith(".com"),g=a?l.slice(0,-4):l;return`${r(o)}@${r(g)}${a?".com":""}`}var Dn=/^[A-Za-z_$][A-Za-z0-9_$]*$/,On=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Ln=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 oe(t,e){if(!t||!e)return!1;let n=On(e);return new RegExp("['\"`]"+n+"['\"`]").test(t)?!0:Dn.test(e)&&new RegExp("\\."+n+"(?![A-Za-z0-9_$])").test(t)}function Pn(t){return!!t&&Ln.test(t)}function mi(t,e,n){return t?Pn(t)?[...e]:[...n,...e].some(s=>oe(t,s))?e.filter(s=>oe(t,s)):[...e]:[]}var Fn=5,Bn=6,Wn=3,ee=864e5,Gn=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,zn=/^(\d{4})[-/](\d{1,2})$/,$n=/^(\d{4})[-\s]?Q([1-4])$/i,Un=/^Q([1-4])[-\s](\d{4})$/i,Vn=/^(\d{4})$/,Kn=/^(\d{4})(0[1-9]|1[0-2])$/,Hn=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/,Yn=/^(\D+?)[\s\-/.,']*((?:19|20)\d{2})$/u,jn=/^((?:19|20)\d{2})[\s\-/.,']+(\D+)$/u;function ke(t,e,n){let s=q(t);if(!s)return 0;if(s==="sept")return 9;for(let o of e&&!/^en\b/i.test(e)?["en",e]:["en"]){let l=ge(o)[s];if(l!==void 0)return l+1}let r=n?.get(s);if(r!==void 0)return r+1;let i=ie(t);if(i.length>0){if(i.every(a=>a.month===i[0].month))return i[0].month+1;let o=Be(String(e??"").split(/[-_]/)[0])?.code,l=i.find(a=>a.lang===o);if(l)return l.month+1}return 0}function Xn(t){let e=me(t).filter(s=>s.yearDigits===4);if(e.length===0||e.some(s=>s.lang==="en"))return null;let n=e[0];return e.some(s=>s.grain!=="quarter"||s.n!==n.n||s.year!==n.year)?null:H(n.year,(n.n-1)*3+1,1)}function H(t,e,n,s=0,r=0,i=0){if(!(t>=1&&e>=1&&e<=12&&n>=1&&n<=31))return null;let o=Date.UTC(t,e-1,n,s,r,i);if(!Number.isFinite(o))return null;let l=a=>a<10?"0"+a:String(a);return{ms:o,y:t,m:e,d:n,iso:`${t}-${l(e)}-${l(n)}`}}function Zn(t,e){let n=[],s="";for(let a=0;a<e.length;a++){if(e[a]!=="%"){s+=e[a].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");continue}switch(e[++a]){case"Y":n.push("Y"),s+="(\\d{4})";break;case"m":n.push("m"),s+="(\\d{1,2})";break;case"d":n.push("d"),s+="(\\d{1,2})";break;case"H":case"M":case"S":s+="\\d{1,2}";break;case"%":s+="%";break;default:return null}}let r=new RegExp("^"+s+"$").exec(t);if(!r)return null;let i=0,o=1,l=1;return n.forEach((a,g)=>{let p=+r[g+1];a==="Y"?i=p:a==="m"?o=p:l=p}),i?H(i,o,l):null}function re(t,e,n,s){let r=(t??"").trim();if(r==="")return null;if(e){let a=Zn(r,e);return a||null}let i=Gn.exec(r);if(i)return H(+i[1],+i[2],+i[3],+(i[4]??0),+(i[5]??0),+(i[6]??0));if(i=$n.exec(r),i)return H(+i[1],(+i[2]-1)*3+1,1);if(i=Un.exec(r),i)return H(+i[2],(+i[1]-1)*3+1,1);if(i=zn.exec(r),i&&+i[2]>=1&&+i[2]<=12)return H(+i[1],+i[2],1);if(i=Hn.exec(r),i)return H(+i[1],+i[2],+i[3]);if(i=Kn.exec(r),i)return H(+i[1],+i[2],1);if(i=Vn.exec(r),i){let a=+i[1];return a>=1900&&a<=2100?H(a,1,1):null}let o=Xn(r);if(o)return o;if(i=Yn.exec(r),i){let a=ke(i[1],n,s);if(a)return H(+i[2],a,1)}if(i=jn.exec(r),i){let a=ke(i[2],n,s);if(a)return H(+i[1],a,1)}let l=ne(r);if(l){let a="month"in l?l.month:ke(l.word,n,s);if(a)return H(l.year,a,1)}return null}function It(t){let e=new Date(t).getUTCDay();return e>=1&&e<=5}function Nt(t,e){if(e<=t)return 0;let n=Math.round((e-t)/ee),s=Math.floor(n/7),r=s*5,i=t+s*7*ee;for(;i<e;)It(i)&&r++,i+=ee;return r}function Qn(t){if(t.length===0)return 0;let e=[...t].sort((s,r)=>s-r),n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2}function qn(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 ae(t,e,n,s){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*ee));case"weekday":return Nt(t.ms,e.ms);case"day":return Math.round((e.ms-t.ms)/ee);default:return s>0?Math.round((e.ms-t.ms)/s):0}}function Et(t,e){return De(t,e)?.cadence??null}function De(t,e){let n=e?.gapFactor??Fn,s=0,r=0,i=new Map,o=Array.from(t),l;if(!e?.pattern){let y=[];for(let x of o){if(x==null||x==="")continue;let h=ne(String(x));h&&"word"in h&&y.push(h.word)}y.length>0&&(l=pe(y,e?.locale)??void 0)}for(let y of o){if(y==null||y==="")continue;s++;let x=re(String(y),e?.pattern,e?.locale,l);x&&(r++,i.set(x.ms,x))}let a=[...i.values()].sort((y,x)=>y.ms-x.ms);if(a.length<Wn||s>0&&r/s<.8)return null;let g=a[a.length-1].ms-a[0].ms;if(g<=0)return null;let p=[];for(let y=1;y<a.length;y++)p.push(a[y].ms-a[y-1].ms);let m=Qn(p);if(!(m>0))return null;let c=qn(m/ee);c==="day"&&g>=7*ee&&a.every(y=>It(y.ms))&&Nt(a[0].ms,a[a.length-1].ms)+1>a.length*.5&&(c="weekday");let _=c==="irregular"?a.length:ae(a[0],a[a.length-1],c,m)+1,M=1,N=1,A=[],f=a[0],d=1;for(let y=1;y<a.length;y++){let x=ae(a[y-1],a[y],c,m);x>M&&(M=x),c!=="irregular"&&x>n?(N++,A.push({from:f.iso,to:a[y-1].iso,points:d}),f=a[y],d=1):d++}A.push({from:f.iso,to:a[a.length-1].iso,points:d});let b={grain:c,points:a.length,expectedPoints:Math.max(_,a.length),coveragePct:Math.round(a.length/Math.max(_,a.length)*1e3)/10,runs:N,largestGapUnits:M,gapFactor:n};return e?.includeBounds&&A.length<=Bn&&(b.runBounds=A),{cadence:b,points:a,stepMs:m}}var Jn=8,er=.5,tr=200,nr=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"]),rr=["category","classification","segment","status","priority","severity","channel"],ir=new Set(["UUID","EMAIL_LIKE","URL_LIKE","PHONE_LIKE","NUMERIC_ID","HEX_ID","OPAQUE_ID_ALPHANUMERIC","DATE_STR","BOOLEAN"]);function sr(t){let e=Q(t);if(e.length===0)return!1;let n=e[e.length-1];return nr.has(n)?!0:rr.some(s=>n.length>s.length&&n.endsWith(s))}function or(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>tr?"cardinality":t.rows>0&&e.length>=t.rows?"row-identity":t.isBinaryFlag?"flag":de(e,t.locale)!==null?"ordinal":t.identifierNamed||t.dataType==="String"&&ir.has(fe(e))?"identifier":!t.geoKind&&sr(t.name)?"attribute":"entity"}function Dt(t){let e=-1,n=1/0,s=!1;return t.forEach((r,i)=>{if(or(r)!=="entity")return;let o=new Set(Array.from(r.values).filter(a=>a!=="")).size,l=!!r.geoKind;(o<n||o===n&&l&&!s)&&(e=i,n=o,s=l)}),e}var vt=t=>t<10?"0"+t:String(t);function kt(t,e){switch(e){case"year":return`${t.y}-01-01`;case"quarter":return`${t.y}-${vt(Math.floor((t.m-1)/3)*3+1)}-01`;case"month":return`${t.y}-${vt(t.m)}-01`;case"hour":return new Date(t.ms).toISOString().replace(/\.\d{3}Z$/,"Z");default:return t.iso}}function Ot(t){let{periods:e,series:n}=t,s=Math.min(e.length,n.length),r=new Set;for(let x=0;x<s;x++)e[x]&&r.add(e[x]);let i=De(r,{pattern:t.pattern,locale:t.locale});if(!i)return null;let o=i.cadence.grain;if(o==="irregular")return null;let l=i.points[0],a=ae(l,i.points[i.points.length-1],o,i.stepMs)+1;if(a!==i.cadence.expectedPoints)return null;let g=new Map;for(let x of r){let h=re(x,t.pattern,t.locale);if(!h)continue;let w=ae(l,h,o,i.stepMs);w>=0&&w<a&&g.set(x,{idx:w,stamp:h})}let p=new Map;for(let x=0;x<s;x++){let h=n[x];if(!h)continue;let w=g.get(e[x]);if(!w)continue;let T=p.get(h);T||(T={seen:new Set,lo:w.idx,hi:w.idx,loStamp:w.stamp,hiStamp:w.stamp,order:p.size},p.set(h,T)),T.seen.add(w.idx),w.idx<T.lo&&(T.lo=w.idx,T.loStamp=w.stamp),w.idx>T.hi&&(T.hi=w.idx,T.hiStamp=w.stamp)}if(p.size<2)return null;let m=0;for(let x of p.values())m+=x.seen.size;if(m/(p.size*a)<(t.minFill??er))return null;let c=[],_=new Set,M=0,N=0,A=0,f=0,d=0,b=1;for(let[x,h]of p){for(let G of h.seen)_.add(G);if(h.seen.size>=a)continue;let w=[...h.seen].sort((G,j)=>G-j),T=1;for(let G=1;G<w.length;G++)T=Math.max(T,w[G]-w[G-1]);let U={key:x,acc:h,coverage:h.seen.size/a,before:h.lo,after:a-1-h.hi,interior:h.hi-h.lo+1-h.seen.size,gap:T};c.push(U),U.before>0&&M++,U.after>0&&N++,U.interior>0&&A++,f=Math.max(f,U.before),d=Math.max(d,U.after),b=Math.max(b,T)}if(c.length===0)return null;c.sort((x,h)=>x.coverage-h.coverage||x.acc.order-h.acc.order);let y=c.slice(0,t.maxListed??Jn);return{seriesColumn:t.seriesColumn,grain:o,periods:a,seriesCount:p.size,incompleteSeries:c.length,lateStarts:M,earlyEnds:N,withHoles:A,columnWideMissing:a-_.size,maxMissingBefore:f,maxMissingAfter:d,largestGap:b,series:y.map(x=>{let h={};return t.includeNames&&(h.name=x.key),t.includeDates&&(h.first=kt(x.acc.loStamp,o),h.last=kt(x.acc.hiStamp,o)),h.missingBefore=x.before,h.missingAfter=x.after,h.missingInterior=x.interior,h.largestGap=x.gap,h.coverage=Math.round(x.coverage*1e3)/1e3,h}),more:c.length-y.length}}var ar=5e5,lr=8,ur=4,cr=5,Oe=1,Le=2,mr=4,dr=8;function fr(t,e,n){let[s,r]=[...t];if(e.isTemporal){let i=re(s,e.temporalTextPattern,n),o=re(r,e.temporalTextPattern,n);if(i&&o&&i.ms!==o.ms)return i.ms<o.ms?{a:s,b:r,setOrder:"temporal"}:{a:r,b:s,setOrder:"temporal"}}return s<r?{a:s,b:r,setOrder:"none"}:{a:r,b:s,setOrder:"none"}}function gr(t,e,n){let{rows:s,text:r,locale:i}=t,o=fr(n.values,n,i),l=new Uint8Array(s.length),a=0;for(let g=0;g<s.length;g++){let p=r(s[g][e]);p===o.a?l[g]=1:p===o.b?l[g]=2:a++}return{code:l,blankRows:a,setOrder:o.setOrder}}function pr(t,e){let{rows:n,text:s}=t,r=new Int32Array(n.length),i=new Map;for(let o=0;o<n.length;o++){let l=s(n[o][e]);if(l===""){r[o]=-1;continue}let a=i.get(l);a===void 0&&(a=i.size,i.set(l,a)),r[o]=a}return{ids:r,dict:i}}function hr(t,e,n){let s=new Uint8Array(n);for(let i=0;i<t.length;i++){let o=e[i];if(o===0)continue;let l=t[i];if(l<0)continue;let a=s[l];s[l]=a&o?a|o<<2:a|o}let r={keysA:0,keysB:0,keysBoth:0,dupA:0,dupB:0};for(let i=0;i<n;i++){let o=s[i];o&Oe&&r.keysA++,o&Le&&r.keysB++,(o&(Oe|Le))===(Oe|Le)&&r.keysBoth++,o&mr&&r.dupA++,o&dr&&r.dupB++}return r}function yr(t,e){let n=(t.dupA+t.dupB)*(e.keysA+e.keysB),s=(e.dupA+e.dupB)*(t.keysA+t.keysB);return n<s||n===s&&t.keysBoth>e.keysBoth}var Lt=t=>t==null||typeof t=="string"&&t.trim()==="";function br(t,e,n){if(t===e)return!0;let s=Lt(t),r=Lt(e);return s||r?s&&r:typeof t=="number"&&typeof e=="number"?!1:t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():n(t).trim()===n(e).trim()}function Pt(t){let{rows:e,columns:n}=t,s=e.length;if(s<2||s>ar)return null;let r=n.map((h,w)=>({c:h,i:w})).filter(({c:h})=>!h.isMeasure&&!h.isTemporal&&!h.isDatePart&&h.distinct>=cr).sort((h,w)=>(w.c.identifierNamed?1:0)-(h.c.identifierNamed?1:0)||w.c.distinct-h.c.distinct||h.i-w.i).slice(0,lr),i=n.map((h,w)=>({c:h,i:w})).filter(({c:h})=>!h.isMeasure&&h.values!==null&&h.values.size===2).slice(0,ur);if(r.length===0||i.length===0)return null;let o=i.map(({c:h,i:w})=>gr(t,w,h)),l=null;for(let{i:h}of r){let w=pr(t,h);for(let T=0;T<i.length;T++){if(i[T].i===h)continue;let U=hr(w.ids,o[T].code,w.dict.size);U.keysBoth<1||(!l||yr(U,l.tally))&&(l={tally:U,keyIdx:h,setNo:T,ids:w.ids,dict:w.dict})}}if(!l)return null;let{ids:a,dict:g,tally:p}=l,m=o[l.setNo],c=i[l.setNo].i,_=g.size,M=new Int32Array(_).fill(-1),N=new Int32Array(_).fill(-1);for(let h=0;h<s;h++){let w=m.code[h],T=a[h];w===0||T<0||(w===1?M[T]<0&&(M[T]=h):N[T]<0&&(N[T]=h))}let A=[];for(let h=0;h<n.length;h++)h!==l.keyIdx&&h!==c&&A.push(h);let f=0;for(let h=0;h<_;h++){let w=M[h],T=N[h];if(w<0||T<0)continue;let U=e[w],G=e[T],j=!0;for(let K of A)if(!br(U[K],G[K],t.text)){j=!1;break}j&&f++}let d=f===p.keysBoth?100:f===0?0:Math.min(99,Math.max(1,Math.round(f/p.keysBoth*100))),b=new Map,y=new Map;for(let[h,w]of g){let T=M[w]>=0,U=N[w]>=0;if(!T&&!U)continue;let G=Ze(h);Qe(G)&&(T&&b.set(G,(b.get(G)??0)+1),U&&y.set(G,(y.get(G)??0)+1))}let x=h=>{let w=0;for(let T of h.values())T>=2&&(w+=T);return w};return{key:l.keyIdx,discriminator:c,pairing:{form:"long",key:n[l.keyIdx].name,discriminator:n[c].name,keysA:p.keysA,keysB:p.keysB,keysBoth:p.keysBoth,duplicateKeysA:p.dupA,duplicateKeysB:p.dupB,identicalPct:d,discriminatorBlankRows:m.blankRows,looseCollisionsA:x(b),looseCollisionsB:x(y),setOrder:m.setOrder}}}var Sr=t=>t==="Integer"||t==="Decimal";function Ar(t){let e=[],n=[];return t.forEach((s,r)=>{if(s.twoValues){if(s.isBinaryFlag){e.push(r);return}s.isMeasure||s.isTemporal||s.isDatePart||s.identifierNamed||n.push(r)}}),[...e,...n].slice(0,6)}function _r(t,e){let n=[];for(let s=0;s<t.length&&n.length<12;s++){let r=t[s];e.has(s)||!Sr(r.dataType)||r.isTemporal||r.isDatePart||r.identifierNamed||r.distinct<3||n.push(s)}return n}function Ft(t){let e=new Map,{rows:n,columns:s,text:r}=t;if(n.length===0||n.length>(t.maxRows??5e5))return e;let i=Ar(s);if(i.length===0)return e;let o=_r(s,new Set(i));if(o.length===0)return e;let l=i.map(a=>{let[g,p]=s[a].twoValues,m=new Uint8Array(n.length);for(let c=0;c<n.length;c++){let _=r(n[c][a]);m[c]=_===g?1:_===p?2:0}return m});for(let a of o){let g=new Float64Array(n.length),p=0;for(let d=0;d<n.length;d++){let b=n[d][a],y=b==null||b===""?NaN:typeof b=="number"?b:parseFloat(b);g[d]=y,y===y&&y!==1/0&&y!==-1/0&&p++}if(p<2)continue;let m=new Float64Array(p);for(let d=0,b=0;d<n.length;d++){let y=g[d];y===y&&y!==1/0&&y!==-1/0&&(m[b++]=y)}m.sort();let c=new Float64Array(p),_=0;for(let d=0;d<p;d++)(d===0||m[d]!==m[d-1])&&(c[_++]=m[d]);let M=new Int32Array(n.length).fill(-1);for(let d=0;d<n.length;d++){let b=g[d];if(!(b===b&&b!==1/0&&b!==-1/0))continue;let y=0,x=_-1;for(;y<x;){let h=y+x>>>1;c[h]<b?y=h+1:x=h}M[d]=y}let N=[],A=new Int32Array(_),f=new Int32Array(_);for(let d=0;d<i.length;d++){let b=l[d];A.fill(0),f.fill(0);let y=0,x=0;for(let S=0;S<n.length;S++){let P=M[S];P<0||(b[S]===1?(A[P]++,y++):b[S]===2&&(f[P]++,x++))}if(y===0||x===0)continue;let h=y<=x,w=h?y:x,T=h?x:y,U=h?A:f,G=h?f:A,j=0,K=0,u=0;for(let S=0;S<_;S++){let P=U[S],k=G[S];j+=P*(K+.5*k),K+=k,P+k>=2&&(u+=P+k)}N.push({outcome:s[i[d]].name,aucMinorityHigh:Math.round(j/(w*T)*1e4)/1e4,nMinority:w,nMajority:T,ties:u})}N.length>0&&e.set(a,N)}return e}var xr=12,Cr=100,Mr=.3,Tr=.9,Rr=120,wr=1900,Ir=2100,Nr=0,Er=20,vr=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function xe(t){if(!t)return!1;let e=Q(t);return e.length===0?!1:vr.has(e[e.length-1])?!0:Mt(t)!==null}var kr=new Set(["year","yr","fy"]),Dr=t=>Q(t).some(e=>kr.has(e))||Xe(t)!==null,Or=/^(?:(?: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 Pe(t){if(!Number.isInteger(t)||t<190001||t>210012)return!1;let e=t%100;return e>=1&&e<=12}function Fe(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 Lr=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Pr=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,Fr=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function zt(t,e){let n=[],s=0,r=Br(t,e,n,()=>{s++});if(r)return r;if(s>0||n.length<2)return null;let i=ut(n,{locale:e,floor:.8});return!i||!i.pattern||i.form==="named"?null:{pattern:i.pattern,orderFrom:i.orderFrom==="shape"?i.order==="ymd"?"iso":"shape":i.orderFrom}}function Br(t,e,n,s){let r=0,i=0,o=0,l=0,a=0,g="",p=0,m="",c=0,_=0,M=0,N=0,A=!1;for(let h of t){if(h==null)continue;let w=String(h).trim();if(w==="")continue;r++,n.push(w);let T;if(T=Lr.exec(w)){s();let U=+T[2],G=+T[3];U>=1&&U<=12&&G>=1&&G<=31&&(i++,T[4]!==void 0&&o++,T[6]!==void 0&&l++)}else if(T=Pr.exec(w)){s();let U=+T[3],G=+T[4];U>=1&&U<=12&&G>=1&&G<=31&&(g&&g!==T[2]&&(A=!0),g=T[2],a++)}else if(T=Fr.exec(w)){s();let U=+T[1],G=+T[3];U>=1&&U<=31&&G>=1&&G<=31&&(U<=12||G<=12)&&(m&&m!==T[2]&&(A=!0),m=T[2],p++,U>12&&M++,G>12&&N++,T[5]!==void 0&&c++,T[7]!==void 0&&_++)}if(r>=200)break}if(r<2||(i+a+p)/r<.8||(i>0?1:0)+(a>0?1:0)+(p>0?1:0)!==1||A)return null;if(i>0)return o===i?{pattern:l===i?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(a>0)return{pattern:`%Y${g}%m${g}%d`,orderFrom:"iso"};if(M>0&&N>0)return null;let b,y;M>0?(b=!0,y="values"):N>0?(b=!1,y="values"):m==="."?(b=!0,y="shape"):(b=!Ie(e),y="locale");let x=b?`%d${m}%m${m}%Y`:`%m${m}%d${m}%Y`;return c===p?{pattern:x+(_===p?" %H:%M:%S":" %H:%M"),orderFrom:y}:{pattern:x,orderFrom:y}}function Wr(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 s=q(n);return s.length>0&&e[s]!==void 0}function Gr(t,e){let n=new Map,s=new Map;for(let l of t){let a=ne(l);if(!a||"month"in a)continue;let g=ie(a.word),p=g.some(c=>c.lang==="en"),m=q(a.word);for(let c of new Set(g.map(_=>_.lang)))c!=="en"&&(n.has(c)||(n.set(c,new Set),s.set(c,new Set)),n.get(c).add(m),p||s.get(c).add(m))}let r=[...n.keys()].filter(l=>n.get(l).size>=3&&s.get(l).size>=1),i=0,o=new Map(r.map(l=>[l,0]));for(let l of e){let a=ne(l);if(!a)continue;if("month"in a){i++;continue}let g=ie(a.word);if(g.length===0)continue;let p=g.some(m=>m.lang==="en");for(let m of r)(p||g.some(c=>c.lang===m))&&o.set(m,o.get(m)+1)}return i+Math.max(0,...o.values())}var zr=/(?:19|20)[0-9]{2}/;function $r(t){let e=new Map,n=0;for(let r of t){if(!zr.test(ue(r)))continue;let i=new Set(me(r).filter(o=>o.yearDigits===4&&(o.grain==="quarter"||o.grain==="week")).map(o=>o.lang));if(i.size!==0){if(i.has("en")){n++;continue}for(let o of i)e.set(o,(e.get(o)??0)+1)}}let s=0;for(let r of e.values())s=Math.max(s,r);return s>0?s+n:0}function Ur(t){let{dataType:e,name:n,isMeasure:s,distinctCount:r}=t;if(e==="DateTime")return!0;if(s)return!1;if(e==="Integer"||e==="Decimal"){let i=t.minNum,o=t.maxNum;if(!(i!=null&&o!=null&&Number.isFinite(i)&&Number.isFinite(o)&&Number.isInteger(i)&&Number.isInteger(o)&&o>=i))return!1;let a=i>=1900&&o<=2100;if(a&&r>=2&&Dr(n)||a&&r>=3&&r===o-i+1)return!0;let g=Pe(i)&&Pe(o),p=Fe(i)&&Fe(o);if(g||p){if(!t.sampleValues)return!0;let m=0,c=0;for(let _ of t.sampleValues){if(_==null||_==="")continue;m++;let M=Number(String(_).trim());if(Number.isFinite(M)&&(g?Pe(M):Fe(M))&&c++,m>=60)break}if(m>=2&&c===m)return!0}return!1}if(t.sampleValues){let i=t.locale?ge(t.locale):null,o=0,l=0,a=[],g=[];for(let p of t.sampleValues){if(p==null||p==="")continue;o++;let m=String(p).trim();if(a.push(m),Or.test(m)||Wr(m,i)?l++:g.push(m),o>=60)break}if(o>=2&&l/o>=.8||o>=2&&(l+$r(g)+Gr(a,g))/o>=.8||zt(a,t.locale)!==null)return!0}return!1}function Vr(t){let e=Z((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":pt(t)}function Kr(t){let{rows:e,measureColIdx:n,measureName:s,candidateDims:r,minNum:i,maxNum:o,discourageAgg:l}=t,a=100,g=.01,p="";for(let c of r){if(c.distinct<2||c.distinct>a)continue;let _=r.filter(d=>d.idx!==c.idx).map(d=>d.idx),M=new Map;for(let d of e){let b=d[n];if(typeof b!="number"||!Number.isFinite(b))continue;let y=_.length?_.map(h=>String(d[h])).join(p):"",x=M.get(y);x||(x={sum:0,cset:new Set},M.set(y,x)),x.sum+=b,x.cset.add(String(d[c.idx]))}let N=0,A=0,f=0;for(let d of M.values())d.cset.size<2||(f++,Math.abs(d.sum-100)<=100*g?N++:Math.abs(d.sum-1)<=1*g&&A++);if(f>=2&&(N/f>=.9||A/f>=.9))return{additivity:"part_of_whole",partOfWholeDim:c.name}}if(l)return{additivity:"intensive_rate"};let m=Vr(s);return m==="avg"||m==="min"||m==="max"?{additivity:"intensive_rate"}:m==="count"?{additivity:"additive"}:m==="sum"?{additivity:"unknown"}:i!=null&&o!=null&&Number.isFinite(i)&&Number.isFinite(o)&&i>=0&&o<=1.0001&&o>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function Wt(t){let{dataType:e,isMeasure:n,name:s,distinct:r,nonblank:i,prec:o,maxval:l,minval:a}=t,g=l-a+1,p=g>0?r/g:1,m=i>0?r/i:0,c=e==="Decimal"||o>0;return!n&&xe(s)?"Categorical":p>=Tr&&(qe(s)&&r<=Rr||a>=wr&&l<=Ir||a>=Nr&&l<=Er)?"Ordinal":n||r>xr&&(c||r>=Cr||m>=Mr)?"Continuous":"Categorical"}function Hr(t){let e=null;for(let n=0;n<t.length;n++){let s=t[n];if(typeof s!="string"||s.length===0)continue;let r=s.trim();r.length!==s.length&&(e||(e=t.slice()),e[n]=r)}return e||t}var Gt=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;_declaredDimensions=new WeakSet;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 s=e.toString().split(".")[1];return s?s.length:0}getColumns(){return this._cols}declareDimensions(e){for(let n of e)n&&this._declaredDimensions.add(n)}wholeDayIso(e){return je(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 s=0,r=parseInt(e),i=[],o=[],l=[];for(let u of this._cols){let S=new Map,P=[],k=0,C=0,O=0,F=null,L=null,D=null,z=!1,W=!0,E=!0,v=null,$=!1;for(let I of this._rows){let R=I[s],B=this.STR(R);if(B!=""){if(k+=B.length,S.set(B,(S.get(B)||0)+1),C++,u.dataType=="Integer"||u.dataType=="Decimal"||u.dataType=="DateTime")if((F===null||R<F)&&(F=R),(L===null||R>L)&&(L=R),u.dataType=="Integer"||u.dataType=="Decimal"){if(D===null?D=R:D+=R,u.dataType=="Decimal"){let V=this.getPrecision(R);V>O&&(O=V)}P.push(R)}else z=z||this.hasTimeComponent(R);$&&(R<v?W=!1:R>v&&(E=!1)),v=R,$=!0}}if(C>=3&&(W&&!E?u.sortedDirection="asc":E&&!W?u.sortedDirection="desc":u.sortedDirection="none"),C>0&&S.size>0&&!u.isMeasure){let I=0,R=Number.MAX_SAFE_INTEGER;for(let B of S.values())B>I&&(I=B),B<R&&(R=B);if(u.modalShare=I/C,u.minGroupCount=R===Number.MAX_SAFE_INTEGER?null:R,S.size===2){let B=[...S.keys()].map(le=>Ke(le).trim().toLowerCase()).sort(),Y=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(le=>B[0]===le[0]&&B[1]===le[1]),te=/^(is|has)[_\p{L}\p{N}]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/iu.test(u.name);(Y||te)&&(u.isBinaryFlag=!0)}}else u.isMeasure&&(u.dataType==="Integer"||u.dataType==="Decimal")&&S.size===2&&S.has("0")&&S.has("1")&&(u.isBinaryFlag=!0);if(u.dataType=="DateTime"&&(u.dateWithTime=z),u.isTemporal=Ur({dataType:u.dataType,name:u.name,isMeasure:u.isMeasure,distinctCount:S.size,minNum:typeof F=="number"?F:null,maxNum:typeof L=="number"?L:null,sampleValues:S.keys(),locale:n}),u.isTemporal&&u.dataType==="String"&&!u.isMeasure){let I=zt(S.keys(),n);I&&(u.temporalTextPattern=I.pattern)}if(u.isTemporal&&!u.isMeasure){let I=Et(S.keys(),{includeBounds:r>=20,pattern:u.temporalTextPattern,locale:n});I&&(u.temporalCadence=I)}this.updateColumnStats10(r,u,C,S,O,L,F),this.updateColumnStats20(r,P,C,D,u,k,z,F,L,O,S,n),!u.isMeasure&&!this._declaredDimensions.has(u)&&(u.dataType==="Integer"||u.dataType==="Decimal")&&Wt({dataType:u.dataType,isMeasure:!1,name:u.name,distinct:S.size,nonblank:C,prec:O,maxval:typeof L=="number"?L:0,minval:typeof F=="number"?F:0})==="Continuous"&&(u.isMeasure=!0,u.geoKind=void 0,u.geoMatchPct=void 0,u.geoAmbiguous=void 0,u.dominantGeoRegion=void 0,u.dominantGeoRegionPct=void 0,u.geoRegionCount=void 0),i[s]=u.isMeasure||S.size>2e3?null:new Set(S.keys()),o[s]=S.size,l[s]=S.size===2?[...S.keys()].sort():null,s++}let a=[];this._cols.forEach((u,S)=>{u.isMeasure||a.push({idx:S,distinct:u.distinctCount??0,name:u.name})}),this._cols.forEach((u,S)=>{if(!u.isMeasure)return;let P=typeof u.lowValue=="number"?u.lowValue:null,k=typeof u.highValue=="number"?u.highValue:null,C=Kr({rows:this._rows,measureColIdx:S,measureName:u.name,candidateDims:a,minNum:P,maxNum:k,discourageAgg:!!u.discourageAggregationAcrossGroups});u.additivity=C.additivity,C.partOfWholeDim&&(u.partOfWholeDim=C.partOfWholeDim)});let g=50,p=4,m=a.filter(u=>u.distinct>=2&&u.distinct<=g);this._cols.forEach((u,S)=>{if(!u.isMeasure)return;let P=[];for(let E of this._rows){let v=E[S];if(v==null||v==="")continue;let $=typeof v=="number"?v:parseFloat(v);isNaN($)||P.push($)}if(P.length===0)return;let k=[...P].sort((E,v)=>E-v);if(k[0]===k[k.length-1])u.relativeDispersion=0;else if(k.length>=p){let E=X(k,.5),v=X(k,.1),$=X(k,.9);u.relativeDispersion=Math.abs(E)>1e-9?Math.round(($-v)/Math.abs(E)*1e3)/1e3:void 0}else u.relativeDispersion=void 0;let C=[];for(let E of m){let v=new Set;for(let $ of this._rows){let I=$[S];I==null||I===""||v.add(this.STR($[E.idx])+"")}C.push({otherColumn:E.name,nonBlankGroupCount:v.size})}C.length>0&&(u.nonBlankGroups=C);let O=0;for(let E of P)O+=E;O/=P.length;let F=0;for(let E of P)F+=(E-O)*(E-O);if(F<=1e-12)return;let L=[],D=[],z=E=>{if(E.length<4)return NaN;let v=[...E].sort((I,R)=>I-R),$=I=>v[Math.min(v.length-1,Math.max(0,Math.floor(I*(v.length-1))))];return $(.75)-$(.25)},W=z(P);for(let E of m){let v=new Map;for(let R of this._rows){let B=R[S];if(B==null||B==="")continue;let V=typeof B=="number"?B:parseFloat(B);if(isNaN(V))continue;let Y=this.STR(R[E.idx])+"",te=v.get(Y);te?(te.s+=V,te.n++,te.vals.push(V)):v.set(Y,{s:V,n:1,vals:[V]})}let $=0;for(let R of v.values()){let B=R.s/R.n;$+=R.n*(B-O)*(B-O)}L.push({otherColumn:E.name,eta2:Math.round($/F*1e4)/1e4});let I=[];for(let R of v.values()){let B=z(R.vals);isNaN(B)||I.push(B)}if(I.length>=2&&isFinite(W)&&W>1e-9){let R=(Math.max(...I)-Math.min(...I))/W;D.push({otherColumn:E.name,spreadRatio:Math.round(R*1e4)/1e4})}}L.length>0&&(u.groupDiscrimination=L),D.length>0&&(u.spreadDiscrimination=D)});let c=.97,_=.8,M=8,N=5,A=this._cols.map((u,S)=>({c:u,i:S})).filter(u=>u.c.isMeasure);for(let u=0;u<A.length;u++)for(let S=u+1;S<A.length;S++){let P=A[u].i,k=A[S].i,C=0,O=0,F=0,L=0,D=0,z=0;for(let I of this._rows){let R=I[P],B=I[k];if(R==null||R===""||B===null||B===void 0||B==="")continue;let V=typeof R=="number"?R:parseFloat(R),Y=typeof B=="number"?B:parseFloat(B);isNaN(V)||isNaN(Y)||(C++,O+=V,F+=Y,L+=V*V,D+=Y*Y,z+=V*Y)}if(C<N)continue;let W=C*L-O*O,E=C*D-F*F;if(W<=1e-12||E<=1e-12)continue;let v=(C*z-O*F)/Math.sqrt(W*E),$=Math.min(1,Math.round(Math.abs(v)*1e3)/1e3);for(let I of[A[u].c,A[S].c])(I.maxAbsMeasureCorrelation===void 0||$>I.maxAbsMeasureCorrelation)&&(I.maxAbsMeasureCorrelation=$);if(Math.abs(v)>=c){let I=A[u].c,R=A[S].c;I.collinearWithMeasures||(I.collinearWithMeasures=[]),R.collinearWithMeasures||(R.collinearWithMeasures=[]),I.collinearWithMeasures.push(R.name),R.collinearWithMeasures.push(I.name)}else if(Math.abs(v)>=_){let I=A[u].c,R=A[S].c,B=Math.round(v*1e3)/1e3;I.correlatedWithMeasures||(I.correlatedWithMeasures=[]),R.correlatedWithMeasures||(R.correlatedWithMeasures=[]),I.correlatedWithMeasures.push({otherColumn:R.name,r:B}),R.correlatedWithMeasures.push({otherColumn:I.name,r:B})}}for(let{c:u}of A)u.correlatedWithMeasures&&(u.correlatedWithMeasures.sort((S,P)=>Math.abs(P.r)-Math.abs(S.r)||(S.otherColumn<P.otherColumn?-1:1)),u.correlatedWithMeasures.length=Math.min(u.correlatedWithMeasures.length,M));for(let u=0;u<this._cols.length;u++){let S=i[u];if(!S||S.size===0)continue;let P=[];for(let k=0;k<this._cols.length;k++){if(k===u)continue;let C=i[k];if(!C||C.size===0)continue;let O=0;for(let L of S)C.has(L)&&O++;let F=Math.round(O/S.size*100);F>0&&P.push({otherColumn:this._cols[k].name,percentShared:F})}P.length>0&&(this._cols[u].sharedValueRatioWithOthers=P)}let f=50,d=[];for(let u=0;u<this._cols.length;u++){let S=i[u];S&&S.size>=2&&S.size<=f&&d.push(u)}if(d.length>=2){let u=new Map,S=(k,C)=>k+":"+C;for(let k=0;k<d.length;k++)for(let C=k+1;C<d.length;C++)u.set(S(d[k],d[C]),new Map);for(let k of this._rows)for(let C=0;C<d.length;C++){let O=this.STR(k[d[C]])+"";for(let F=C+1;F<d.length;F++){let L=""+this.STR(k[d[F]]),D=u.get(S(d[C],d[F])),z=O+""+L;D.set(z,(D.get(z)??0)+1)}}let P=new Map;for(let k=0;k<d.length;k++)for(let C=k+1;C<d.length;C++){let O=d[k],F=d[C],L=i[O].size,D=i[F].size,z=u.get(S(O,F)),W=z.size,E=0;for(let R of z.values())(E===0||R<E)&&(E=R);let v=Math.round(W/(L*D)*100),$=W===L,I=W===D;if((this._cols[O].categoricalPairStats||=[]).push({otherColumn:this._cols[F].name,fillPct:v,determinesOther:$,minCellCount:E,distinctCombinations:W}),(this._cols[F].categoricalPairStats||=[]).push({otherColumn:this._cols[O].name,fillPct:v,determinesOther:I,minCellCount:E,distinctCombinations:W}),$&&L>D){let R=P.get(O);(!R||D<R.card)&&P.set(O,{name:this._cols[F].name,card:D,ratio:D/L})}if(I&&D>L){let R=P.get(F);(!R||L<R.card)&&P.set(F,{name:this._cols[O].name,card:L,ratio:L/D})}}for(let[k,C]of P)this._cols[k].primaryParentColumn=C.name,this._cols[k].nestingRatio=Math.round(C.ratio*100)/100}let b=6,y=this._rows.length;for(let u=0;u<this._cols.length;u++){let S=this._cols[u];if(S.isMeasure||S.primaryParentColumn)continue;let P=S.distinctCount??0;if(P<=f||y>0&&P>=y)continue;let k=[];for(let C=0;C<this._cols.length;C++){if(C===u)continue;let O=this._cols[C];if(O.isMeasure)continue;let F=O.distinctCount??0;F<2||F>=P||k.push(C)}k.sort((C,O)=>(this._cols[C].distinctCount??0)-(this._cols[O].distinctCount??0));for(let C of k.slice(0,b)){let O=new Map,F=!0;for(let D of this._rows){let z=this.STR(D[u])+"",W=this.STR(D[C])+"",E=O.get(z);if(E===void 0)O.set(z,W);else if(E!==W){F=!1;break}}if(!F)continue;let L=this._cols[C].distinctCount??0;S.primaryParentColumn=this._cols[C].name,S.nestingRatio=Math.round(L/P*100)/100;break}}let x=.01,h=.05,w=.95,T=8,U=8,G=6,j=500,K=[];for(let u=0;u<this._cols.length&&K.length<U;u++){let S=this._cols[u].dataType;(S==="Double"||S==="Integer"||S==="Decimal")&&K.push(u)}if(K.length>=3&&this._rows.length>=T){let u=Math.min(this._rows.length,j),S=K.map(L=>{let D=[];for(let E=0;E<u;E++){let v=this._rows[E][L],$=typeof v=="number"?v:parseFloat(String(v).replace(/,/g,""));if(v==null||v===""||!isFinite($))return null;D.push($)}let z=D[0],W=!1;for(let E of D)if(E!==z){W=!0;break}return W?D:null}),P=K.map((L,D)=>D).filter(L=>S[L]!==null),k=L=>{let D=L.slice().sort((W,E)=>W-E),z=D.length>>1;return D.length%2?D[z]:(D[z-1]+D[z])/2},C=null,O=[],F=L=>{if(O.length>=3){let D=O.map(v=>S[v]),z=D[0].length,W=new Array(z);for(let v=0;v<z;v++){let $=0;for(let I of D)$+=I[v];W[v]=$}let E=k(W);if(E>0){let v=0;for(let I of W)Math.abs(I-E)<=E*x&&v++;let $=v/z;if($>=w){let I=1;for(let R of D){let B=k(R)/E;B<I&&(I=B)}I>=h&&(!C||O.length>C.cols.length)&&(C={cols:O.slice(),total:E,matched:$})}}}if(!(O.length>=G))for(let D=L;D<P.length;D++)O.push(P[D]),F(D+1),O.pop()};if(F(0),C){let L=C,z={columns:L.cols.map(W=>this._cols[K[W]].name),total:Math.round(L.total*1e3)/1e3,matchedPct:Math.round(L.matched*100)/100};for(let W of L.cols)this._cols[K[W]].constantSumGroup=z}}return this.applyTwoSetPairing(n,i),this.applyScoreSeparation(o,l),this.applySeriesCompleteness(r,n,i),this._computedStatsForLevel=e,this._cols}applyTwoSetPairing(e,n){for(let r of this._cols)r.twoSetPairing!==void 0&&delete r.twoSetPairing;let s=Pt({rows:this._rows,columns:this._cols.map((r,i)=>{let o=n[i];return{name:r.name,values:o,distinct:o?o.size:r.distinctCount??0,isMeasure:!!r.isMeasure,isTemporal:!!r.isTemporal,isDatePart:!!r.isDatePart,identifierNamed:xe(r.name),temporalTextPattern:r.temporalTextPattern}}),text:r=>this.STR(r),locale:e});s&&(this._cols[s.key].twoSetPairing=s.pairing,this._cols[s.discriminator].twoSetPairing=s.pairing)}applyScoreSeparation(e,n){for(let r of this._cols)r.scoreSeparation!==void 0&&delete r.scoreSeparation;let s=Ft({rows:this._rows,columns:this._cols.map((r,i)=>({name:r.name,dataType:r.dataType,isMeasure:!!r.isMeasure,isTemporal:!!r.isTemporal,isDatePart:!!r.isDatePart,identifierNamed:xe(r.name),isBinaryFlag:!!r.isBinaryFlag,distinct:e[i]??0,twoValues:n[i]??null})),text:r=>this.STR(r)});for(let[r,i]of s)this._cols[r].scoreSeparation=i}applySeriesCompleteness(e,n,s){for(let c of this._cols)c.seriesCompleteness!==void 0&&delete c.seriesCompleteness;let r=this._cols.map((c,_)=>({c,i:_})).filter(({c})=>c.isTemporal&&!c.isMeasure&&c.temporalCadence&&c.temporalCadence.grain!=="irregular");if(r.length===0)return;let i=[],o=[];this._cols.forEach((c,_)=>{let M=s[_];M&&(i.push(_),o.push({name:c.name,dataType:c.dataType,isMeasure:!!c.isMeasure,isTemporal:!!c.isTemporal,isDatePart:!!c.isDatePart,isReassembledDate:!!c.isReassembledDate,isBinaryFlag:!!c.isBinaryFlag,geoKind:c.geoKind,identifierNamed:xe(c.name),values:M,rows:this._rows.length,locale:n}))});let l=Dt(o);if(l<0)return;let a=i[l],g=this._cols[a],p=this._rows.map(c=>this.STR(c[a])),m=e>=20&&(g.dataType!=="String"||Array.isArray(g.safeDistinctValues));for(let{c,i:_}of r){let M=Ot({periods:this._rows.map(N=>this.STR(N[_])),series:p,seriesColumn:g.name,pattern:c.temporalTextPattern,locale:n,includeDates:e>=20,includeNames:m});M&&(c.seriesCompleteness=M)}}updateColumnStats20(e,n,s,r,i,o,l,a,g,p,m,c){if(e>=20){let _=[...n].sort((A,f)=>A-f),M=Math.floor(_.length/2);if(s>0&&r!=null?i.avgValue=i.dataType=="Integer"?Math.round(r/s):r/s:i.avgValue=null,s>0&&(i.avgLength=o/s),this._rows.length>0){let A=f=>{let d=f instanceof Date?f:typeof f=="string"?Me(f)??new Date(f):new Date(f),b=this.wholeDayIso(d);return b?b+"T00:00:00.000Z":isNaN(d.getTime())?f:d.toISOString().slice(0,10)+"T00:00:00.000Z"};i.dataType!="DateTime"||l||!a?i.lowValue=a:i.lowValue=A(a),i.dataType!="DateTime"||l||!g?i.highValue=g:i.highValue=A(g),i.medianValue=_.length===0?null:_.length%2===0?i.dataType=="Integer"?Math.round((_[M-1]+_[M])/2):(_[M-1]+_[M])/2:_[M],i.numericPrecision=p}if(_.length>0){let A=i.avgValue??0,f=_.length,d=0,b=0;for(let x of _){let h=x-A;d+=h*h,b+=h*h*h}let y=d/f;i.skewness=y===0?0:b/f/Math.pow(Math.sqrt(y),3),i.stdDev=Math.sqrt(y)}r!==null&&(i.sum=r);let N=Array.from(m.entries()).sort((A,f)=>f[1]-A[1]);if(i.topCategories=N.slice(0,10).map(A=>A[1]),!i.isMeasure&&N.length>0&&(i.dataType!=="String"&&(i.topCategoryValues=N.slice(0,5).map(A=>A[0])),e>=20)){let A=N.map(d=>d[0]),f=de(A,c);if(f!==null)i.ordinalPattern=f.pattern,i.orderedDomain=f.orderedDomain;else if(i.dataType==="String"){let d=Je(A);d!==null&&(i.safeDistinctValues=d)}}if(_.length>=8&&(i.dataType==="Integer"||i.dataType==="Decimal")){let A=f=>_[Math.floor((_.length-1)*f)];i.quantiles={p05:A(.05),p25:A(.25),p75:A(.75),p95:A(.95)}}}if(!i.isMeasure&&i.dataType==="String"&&m.size>0){let _=Array.from(m.entries()).sort((A,f)=>f[1]-A[1]).map(A=>A[0]);i.formatSignature=fe(_);let M=s>0?o/s:void 0,N=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;i.formatSignature&&!N.test(i.formatSignature)&&(M===void 0||M>=3)&&(i.isFreeText=!0)}if(!i.isMeasure&&m.size>0){let _=Array.from(m.entries()).sort((N,A)=>A[1]-N[1]),M=nt(_.map(N=>N[0]),i.name,c);if(M!==null&&(i.geoKind=M.geoKind,i.geoMatchPct=M.geoMatchPct,M.geoAmbiguous&&(i.geoAmbiguous=!0),M.geoKind.indexOf("country")===0)){let N=Te(_);N&&(i.dominantGeoRegion=N.dominantGeoRegion,i.dominantGeoRegionPct=N.dominantGeoRegionPct,i.geoRegionCount=N.regionCount)}}}updateColumnStats10(e,n,s,r,i,o,l){let a=this._rows.length-s;e>=10&&(n.blankCount=a),n.distinctCount=r.size+(a!=0?1:0),n.valueNature="Categorical",s>0&&(n.dataType==="Integer"||n.dataType==="Decimal"?n.valueNature=Wt({dataType:n.dataType,isMeasure:!!n.isMeasure,name:n.name,distinct:r.size,nonblank:s,prec:i,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((s,r)=>{s.isMeasure||e.push(r)}),e.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let n=new Set;for(let s of this._rows)n.add(JSON.stringify(e.map(r=>s[r])));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=>We(o,{camel:!0}),n=-1,s=-1,r=-1;if(this._cols.forEach((o,l)=>{let a=e(o.name),g=o.dataType==="Integer"||o.dataType==="Decimal";g&&n<0&&a.some(p=>p==="lat"||p==="latitude")?n=l:g&&s<0&&a.some(p=>p==="lon"||p==="lng"||p==="long"||p==="longitude")&&(s=l),r<0&&!o.isMeasure&&typeof o.geoKind=="string"&&o.geoKind.indexOf("country")===0&&(r=l)}),n<0||s<0)return null;let i=[];for(let o of this._rows){let l=o[n],a=o[s],g=l==null||l===""?null:Number(l),p=a==null||a===""?null:Number(a);i.push({lat:g,lon:p,country:r>=0&&he(this.STR(o[r]))?this.STR(o[r]):null})}return this._geoExtent=ot(i),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(e){return wt(e,Ye)}toObjectArray(){let e=this.liveEnglishAliases();return this._rows.map(n=>{let s={};this._cols.forEach((r,i)=>{s[r.name]=n[i],this.emitLegacyAggAliases&&r.hostName&&r.hostName!==r.name&&!Object.prototype.hasOwnProperty.call(s,r.hostName)&&(s[r.hostName]=n[i])});for(let[r,i]of e)Object.prototype.hasOwnProperty.call(s,i.alias)||(s[i.alias]=n[r]);return s})}async getCSVAsync(e){let n=[],s=e?25:1e7,r=e?4e3:1e7,i=new Map;for(let l of this._rows){let a={};for(let g=0;g<this._cols.length;g++){let p=this._cols[g],m=l[g];if(this.STR(m)!=""){if(e&&p.dataType=="String")if(i.has(m))m=i.get(m);else{let c=this.obfuscateString(m);i.set(m,c),m=c}else if(p.dataType=="DateTime"&&!p.dateWithTime){let c=m instanceof Date?m:typeof m=="string"?Me(m)??new Date(m):new Date(m);m=(this.wholeDayIso(c)??c.toISOString().slice(0,10))+"T00:00:00.000Z"}r-=this.STR(m).length}else m=null;a[g]=m,--r}if(n.push(a),--s,s<=0||r<=0)break}return await Bt.unparse(n,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return Bt.unparse([this._cols.map((n,s)=>{if(this.emitLegacyAggAliases&&n.hostName)return this.STR(n.hostName);let r=e.get(s);return this.STR(r&&r.headerName?r.alias:n.name)})])}setHostQueryNames(e){this._hostQueryNames=(e??[]).map(n=>n==null?null:this.STR(n)),this._englishAliases=new Map}aliasesForCode(e){let n=ve(e,this._cols)?this.legacyAliases():[];for(let s of this.englishAliasesFor(e).values())n.push({name:s.name,alias:s.alias,reason:"english-implicit-agg"});return n}armAliasesForCode(e){return this.emitLegacyAggAliases=ve(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 s=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 i=new Map;for(let o=0;o<this._cols.length;o++){if(!this._cols[o])continue;let l=bt(this._hostQueryNames[o]).filter(a=>!r.has(a)&&oe(s,a));l.length===1&&i.set(l[0],[...i.get(l[0])??[],o])}for(let[o,l]of i){if(l.length!==1)continue;let a=this.STR(this._cols[l[0]].name);n.set(l[0],{name:a,alias:o,headerName:!oe(s,a)})}return n}liveEnglishAliases(){let e=new Map;for(let[n,s]of this._englishAliases){let r=this._cols?this._cols[n]:null;r&&this.STR(r.name)===s.name&&e.set(n,s)}return e}addRow(e,n){if(this.dedupRows){let s="";for(let i of e)s+=this.STR(i)+"~";let r=He(s);if(this._rowHashes.has(r))return!1;this._rowHashes.add(r)}return this._rows.push(Hr(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(s=>this.STR(s?.name)));for(let s of e){if(!s)continue;let r=this.STR(s.name),i=ht(r);!i||i===r||n.has(i)||(n.delete(r),n.add(i),s.hostName=r,s.name=i)}}};export{ot as a,Vt as b,he as c,Xr as d,ut as e,nn as f,rn as g,sn as h,on as i,Se as j,pn as k,ht as l,ve as m,bt as n,At as o,Sn as p,xt as q,Ct as r,ni as s,ri as t,ii as u,xn as v,Cn as w,Mn as x,Mt as y,oe as z,Pn as A,mi as B,Fn as C,Bn as D,re as E,Et as F,Jn as G,er as H,tr as I,or as J,Dt as K,Ot as L,xe as M,zt as N,Ur as O,Vr as P,Kr as Q,Wt as R,Hr as S,Gt as T};
@@ -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{M as R,T as I,e as L}from"./chunk-KMAKCPZX.mjs";import{a as y,c as C,d as E,e as x}from"./chunk-A4PQBWRA.mjs";import{u as T}from"./chunk-NT6CDI3K.mjs";import A from"papaparse";var M=500,k=/^[+-]?\d{1,15}$/,P=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,N=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function O(e,o=".",n=!1){if(n)return"DateTime";let r=0,a=0,i=0,l=0;for(let m of e){if(m==null)continue;if(typeof m=="number"){l++,a++,Number.isInteger(m)&&r++;continue}if(m instanceof Date){l++,i++;continue}if(typeof m=="boolean"){l++;continue}let c=String(m).trim();if(c!==""){if(l++,k.test(y(c))){r++,a++;continue}if(x(c,o)){a++;continue}if((P.test(c)||N.test(c))&&!isNaN(Date.parse(c))){i++;continue}}}return l===0?"String":i===l?"DateTime":r===l?"Integer":a===l?"Decimal":"String"}function _(e,o,n=".",r=null){if(e==null)return null;if(typeof e=="number")return o==="String"?String(e):e;if(e instanceof Date)return o==="DateTime"?e:e.toISOString();if(typeof e=="boolean")return String(e);let a=String(e).trim();if(a==="")return null;switch(o){case"Integer":{let i=y(a);return k.test(i)?parseInt(i,10):null}case"Decimal":return E(a,n);case"DateTime":return r?r.read(a):T(a);default:return a}}function $(e){let o=(e||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(o)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(o)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(o)?"DateTime":(/^(bit|bool|boolean)$/.test(o),"String")}function*q(e,o){for(let n of e)yield n?.[o]}function f(e,o,n){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 r=e.length,a=e.map((t,s)=>o.slice(0,M).map(u=>u?.[s])),i=a.map(t=>C(t,n.locale)),l=e.map((t,s)=>t.dataType===void 0||t.dataType==="DateTime"?L(q(o,s),{locale:n.locale??"en"}):null),m=e.map((t,s)=>t.dataType??O(a[s],i[s],l[s]!==null)),c=new Set((n.measures??[]).map(t=>t.toLowerCase())),w=new Set((n.dimensions??[]).map(t=>t.toLowerCase())),j=new Set((n.nonAdditive??[]).map(t=>t.toLowerCase())),b=e.map((t,s)=>{let u=t.name.toLowerCase(),g=t.isMeasure??((m[s]==="Integer"||m[s]==="Decimal")&&!R(t.name));c.has(u)&&(g=!0),w.has(u)&&(g=!1);let S={name:t.name,dataType:m[s],isMeasure:g};return g&&j.has(u)&&(S.discourageAggregationAcrossGroups=!0),S}),d=new I;d.dedupRows=n.dedup!==!1,d.setColumns(b),d.declareDimensions(b.filter((t,s)=>w.has(e[s].name.toLowerCase())));for(let t=0;t<o.length;t++){let s=o[t];d.addRow(Array.from({length:r},(u,g)=>_(s?.[g],m[g],i[g],l[g])),t)}let D=d.getColumnsWithStats(n.privacyLevel??"20",n.locale??"en"),p=new Map(D.map(t=>[t.name,t]));e.forEach(t=>{let s=p.get(t.name);s&&(t.format&&(s.modelFormat=t.format),t.description&&(s.modelDesc=t.description))});for(let[t,s]of Object.entries(n.formats??{})){let u=p.get(t);u&&(u.modelFormat=s)}for(let[t,s]of Object.entries(n.descriptions??{})){let u=p.get(t);u&&(u.modelDesc=s)}for(let t of n.groupBy??[]){let s=p.get(t);s&&(s.isGrouping=!0)}return{columns:D,rows:d.toObjectArray(),totalRows:d.getRowCount(),index:d}}function h(e,o){return e.map(n=>Array.isArray(n)?n:o.map(r=>n[r]))}function F(e,o){let n=[],r=new Set,a=Math.min(e.length,Math.max(1,o));for(let i=0;i<a;i++){let l=e[i];if(!(!l||typeof l!="object"))for(let m of Object.keys(l))r.has(m)||(r.add(m),n.push(m))}return n}function V(e){let o=String(e??"").replace(/^\uFEFF/,""),n=[],r=[],a=0;return A.parse(o,{skipEmptyLines:!1,step:i=>{let l=i.meta.cursor,m=o.slice(a,l);a=l,i.errors?.length&&r.push(...i.errors);let c=i.data;c.length===1&&c[0]===""&&m.replace(/[\r\n]/g,"")===""||n.push(c)}}),!n.length&&!r.length&&r.push(...A.parse(o,{skipEmptyLines:!0}).errors),{rows:n,errors:r}}function H(e,o={}){switch(e.kind){case"csv":{let n=V(e.text);if(n.errors.length&&n.rows.length===0)throw new Error(`ingest: CSV parse failed - ${n.errors[0].message}`);let r=n.rows;if(r.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let a=r[0].map(i=>(i??"").trim());return f(a.map(i=>({name:i})),r.slice(1),o)}case"grid":{if(!e.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return f(e.header.map(n=>({name:(n??"").trim()})),e.rows??[],o)}case"table":{if(!e.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let n=e.columns.map(r=>r.name);return f(e.columns,h(e.rows??[],n),o)}case"objects":{let n=e.rows??[],r=e.columns?.length?e.columns:F(n,o.columnScanLimit??M).map(a=>({name:a}));if(!r.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return f(r,h(n,r.map(a=>a.name)),o)}case"sql":{if(!e.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let n=e.schema.map(r=>{let a=$(r.dataType);return{name:r.name,dataType:a,isMeasure:r.isMeasure,format:r.format,description:r.description}});return f(n,h(e.rows??[],n.map(r=>r.name)),o)}default:{let n=e;throw new Error(`ingest: unknown source kind '${n?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{$ as a,V as b,H as c};
2
+ import{M as R,T as I,e as L}from"./chunk-AQ2WZ4TT.mjs";import{a as y,c as C,d as E,e as x}from"./chunk-A4PQBWRA.mjs";import{u as T}from"./chunk-NT6CDI3K.mjs";import A from"papaparse";var M=500,k=/^[+-]?\d{1,15}$/,P=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,N=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function O(e,o=".",n=!1){if(n)return"DateTime";let r=0,a=0,i=0,l=0;for(let m of e){if(m==null)continue;if(typeof m=="number"){l++,a++,Number.isInteger(m)&&r++;continue}if(m instanceof Date){l++,i++;continue}if(typeof m=="boolean"){l++;continue}let c=String(m).trim();if(c!==""){if(l++,k.test(y(c))){r++,a++;continue}if(x(c,o)){a++;continue}if((P.test(c)||N.test(c))&&!isNaN(Date.parse(c))){i++;continue}}}return l===0?"String":i===l?"DateTime":r===l?"Integer":a===l?"Decimal":"String"}function _(e,o,n=".",r=null){if(e==null)return null;if(typeof e=="number")return o==="String"?String(e):e;if(e instanceof Date)return o==="DateTime"?e:e.toISOString();if(typeof e=="boolean")return String(e);let a=String(e).trim();if(a==="")return null;switch(o){case"Integer":{let i=y(a);return k.test(i)?parseInt(i,10):null}case"Decimal":return E(a,n);case"DateTime":return r?r.read(a):T(a);default:return a}}function $(e){let o=(e||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(o)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(o)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(o)?"DateTime":(/^(bit|bool|boolean)$/.test(o),"String")}function*q(e,o){for(let n of e)yield n?.[o]}function f(e,o,n){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 r=e.length,a=e.map((t,s)=>o.slice(0,M).map(u=>u?.[s])),i=a.map(t=>C(t,n.locale)),l=e.map((t,s)=>t.dataType===void 0||t.dataType==="DateTime"?L(q(o,s),{locale:n.locale??"en"}):null),m=e.map((t,s)=>t.dataType??O(a[s],i[s],l[s]!==null)),c=new Set((n.measures??[]).map(t=>t.toLowerCase())),w=new Set((n.dimensions??[]).map(t=>t.toLowerCase())),j=new Set((n.nonAdditive??[]).map(t=>t.toLowerCase())),b=e.map((t,s)=>{let u=t.name.toLowerCase(),g=t.isMeasure??((m[s]==="Integer"||m[s]==="Decimal")&&!R(t.name));c.has(u)&&(g=!0),w.has(u)&&(g=!1);let S={name:t.name,dataType:m[s],isMeasure:g};return g&&j.has(u)&&(S.discourageAggregationAcrossGroups=!0),S}),d=new I;d.dedupRows=n.dedup!==!1,d.setColumns(b),d.declareDimensions(b.filter((t,s)=>w.has(e[s].name.toLowerCase())));for(let t=0;t<o.length;t++){let s=o[t];d.addRow(Array.from({length:r},(u,g)=>_(s?.[g],m[g],i[g],l[g])),t)}let D=d.getColumnsWithStats(n.privacyLevel??"20",n.locale??"en"),p=new Map(D.map(t=>[t.name,t]));e.forEach(t=>{let s=p.get(t.name);s&&(t.format&&(s.modelFormat=t.format),t.description&&(s.modelDesc=t.description))});for(let[t,s]of Object.entries(n.formats??{})){let u=p.get(t);u&&(u.modelFormat=s)}for(let[t,s]of Object.entries(n.descriptions??{})){let u=p.get(t);u&&(u.modelDesc=s)}for(let t of n.groupBy??[]){let s=p.get(t);s&&(s.isGrouping=!0)}return{columns:D,rows:d.toObjectArray(),totalRows:d.getRowCount(),index:d}}function h(e,o){return e.map(n=>Array.isArray(n)?n:o.map(r=>n[r]))}function F(e,o){let n=[],r=new Set,a=Math.min(e.length,Math.max(1,o));for(let i=0;i<a;i++){let l=e[i];if(!(!l||typeof l!="object"))for(let m of Object.keys(l))r.has(m)||(r.add(m),n.push(m))}return n}function V(e){let o=String(e??"").replace(/^\uFEFF/,""),n=[],r=[],a=0;return A.parse(o,{skipEmptyLines:!1,step:i=>{let l=i.meta.cursor,m=o.slice(a,l);a=l,i.errors?.length&&r.push(...i.errors);let c=i.data;c.length===1&&c[0]===""&&m.replace(/[\r\n]/g,"")===""||n.push(c)}}),!n.length&&!r.length&&r.push(...A.parse(o,{skipEmptyLines:!0}).errors),{rows:n,errors:r}}function H(e,o={}){switch(e.kind){case"csv":{let n=V(e.text);if(n.errors.length&&n.rows.length===0)throw new Error(`ingest: CSV parse failed - ${n.errors[0].message}`);let r=n.rows;if(r.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let a=r[0].map(i=>(i??"").trim());return f(a.map(i=>({name:i})),r.slice(1),o)}case"grid":{if(!e.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return f(e.header.map(n=>({name:(n??"").trim()})),e.rows??[],o)}case"table":{if(!e.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let n=e.columns.map(r=>r.name);return f(e.columns,h(e.rows??[],n),o)}case"objects":{let n=e.rows??[],r=e.columns?.length?e.columns:F(n,o.columnScanLimit??M).map(a=>({name:a}));if(!r.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return f(r,h(n,r.map(a=>a.name)),o)}case"sql":{if(!e.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let n=e.schema.map(r=>{let a=$(r.dataType);return{name:r.name,dataType:a,isMeasure:r.isMeasure,format:r.format,description:r.description}});return f(n,h(e.rows??[],n.map(r=>r.name)),o)}default:{let n=e;throw new Error(`ingest: unknown source kind '${n?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{$ as a,V as b,H as c};
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 Hn}from"./chunk-HIVICMC5.mjs";import{a as Kn,b as I,c as Bn,d as D,e as E,f as jn,g as X,h as J}from"./chunk-QMVECPSM.mjs";import{a as Wn,b as qn,c as $n}from"./chunk-UP2L3X76.mjs";import{A as Sn,B as Rn,C as xn,D as wn,E as _n,F as On,G as vn,H as Pn,I as Ln,J as An,K as Mn,L as In,M as Nn,N as Fn,O as Dn,P as kn,Q as Gn,R as Vn,T as Un,a as zt,b as Ht,c as Kt,d as Bt,f as en,g as tn,h as nn,i as rn,j as on,k as sn,l as an,m as ln,n as un,o as cn,p as dn,q as mn,r as fn,s as pn,t as gn,u as yn,v as hn,w as Cn,x as bn,y as En,z as Tn}from"./chunk-KMAKCPZX.mjs";import{a as jt}from"./chunk-U3H6UBOO.mjs";import{b as Yt,c as Qt,d as Xt,f as Jt,g as Zt}from"./chunk-A4PQBWRA.mjs";import{a as le,b as ue,c as Ut,d as Wt,e as qt,f as $t}from"./chunk-QPIKC2O6.mjs";import{a as M,b as V,c as Y,d as U,k as W,l as Lt,m as At,n as ae,o as v,p as Mt,q as It,r as Nt,s as q,t as Ft,u as Dt,v as kt,w as Gt,x as Q,y as Vt}from"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import{a as dt,b as mt,c as ft,d as pt,e as gt,f as yt,g as ht,h as Ct,i as bt,j as Et,k as Tt,l as St,m as Ot,n as vt,o as Pt}from"./chunk-IIGGO4ES.mjs";import{a as We,b as qe,c as $e,d as ze,e as He,f as Ke,g as Be,h as je,i as Ye,j as Qe,k as Xe,l as Je,m as Ze,n as et,o as tt,q as j,r as nt,s as rt,t as ot,u as it,v as st,w as at,x as lt,y as ut,z as ct}from"./chunk-NT6CDI3K.mjs";import{a as Fe,b as De,c as ke,d as Ge,e as Ve,f as B,g as Ue}from"./chunk-WC4JINEZ.mjs";import{b as Rt,c as xt,d as wt,e as _t}from"./chunk-5HI6TVMM.mjs";var Z=2,me=400;function te(e){return!!W(e)}function F(e){let t=new Set;for(let n of e){if(n==null)continue;let o=U(String(n));if(!V(o)&&!t.has(o)&&(t.add(o),t.size>=me))break}return Array.from(t)}function N(e){let t=F(e);if(t.length===0||ne(e)<95)return!1;let n=t.filter(u=>te(u)&&!v(u)).length,o=t.filter(u=>!te(u)&&!!v(u)).length;return n>=1&&n>=o}function ce(e,t){if(!v(e))return!1;let n=W(e);return n?t==="world"?!0:ae.has(n):!1}function ne(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let o of t)te(o)&&n++;return Math.round(n/t.length*1e3)/10}function $(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let o of t)v(o)&&n++;return Math.round(n/t.length*1e3)/10}function oe(e){let t=new Set;for(let n of e){if(n==null)continue;let o=String(n).trim();if(!V(U(o))&&!t.has(o)&&(t.add(o),t.size>=me))break}return Array.from(t)}function re(e){let t=oe(e);if(t.length===0)return 0;let n=0;for(let o of t)q(o).length>0&&n++;return Math.round(n/t.length*1e3)/10}function de(e,t){return ue(t,le)?!0:oe(e).some(n=>/^\d{5}(-\d{4})?$/.test(n.replace(/\.0+$/,"")))}function Yn(e,t){let n=F(e);if(n.length===0)return 0;let o=0;for(let u of n)Q(u,t)&&o++;return Math.round(o/n.length*1e3)/10}function ee(e,t){let n=0;for(let o of F(e))t(o)&&n++;return n}function Qn(e,t){let n=0;for(let o of oe(e))t(o)&&n++;return n}function Xn(e,t,n,o,u){let l=[],a=[],i={},h={},C=new Set(e),y=s=>t.map(d=>d[s]);for(let s of["city","country"]){let d=n?.[s];d&&C.has(d)&&(i[s]=d)}let g=new Set(u??e);for(let s of["lat","lon"]){let d=n?.[s];d&&g.has(d)&&(i[s]=d)}let f=n?.zip;if(f&&C.has(f)){let s=y(f),d=re(s);d<95?a.push(`zip=${f} (only ${d}% of values read as ZIPs)`):de(s,f)?i.zip=f:a.push(`zip=${f} (all values are 3-4 digits with nothing to say they are postal)`)}let c=n?.state;if(c&&C.has(c)){let s=y(c),d=F(s);d.length>0&&d.every(S=>ce(S,o))?a.push(`state=${c} (every value is "CA", which is both Canada and California)`):N(s)?(a.push(`state=${c} (every value is a country, not a state)`),i.country||(i.country=c)):$(s)<95?a.push(`state=${c} (only ${$(s)}% of values are states/provinces)`):i.state=c}let p=new Set(Object.values(i).filter(Boolean)),b=e.filter(s=>!p.has(s)&&!s.startsWith("__"));if(!i.state){let s=null;for(let d of b){let S=y(d);if(N(S))continue;let O=$(S);if(O<95)continue;let K=ee(S,G=>!!v(G)),Ne=ee(S,G=>!!v(G)&&!ce(G,o));K<Z&&Ne<1||(!s||O>s.pct)&&(s={name:d,pct:O})}s&&(i.state=s.name,p.add(s.name),l.push(`state=${s.name} (${s.pct}% states/provinces)`))}if(!i.zip)for(let s of b){if(p.has(s))continue;let d=y(s),S=re(d);if(!(S<95)&&de(d,s)&&!(Qn(d,O=>q(O).length>0)<Z)){i.zip=s,p.add(s),l.push(`zip=${s} (${S}% ZIP codes)`);break}}let T=i.country;if(!T||!N(y(T))){let s=null;for(let d of b){if(p.has(d)||!N(y(d)))continue;let S=ne(y(d));(!s||S>s.pct)&&(s={name:d,pct:S})}s&&(T&&(a.push(`country=${T} (only ${ne(y(T))}% of values are country identifiers; using ${s.name} instead)`),h.country=T),i.country=s.name,p.add(s.name),l.push(`country=${s.name}`))}if(!i.city){let s=null;for(let d of b){if(p.has(d))continue;let S=y(d),O=Yn(S,o);O<Y||ee(S,K=>Q(K,o))<Z||(!s||O>s.pct)&&(s={name:d,pct:O})}s&&(i.city=s.name,l.push(`city=${s.name} (${s.pct}% known cities)`))}let L=i.country?y(i.country):[],R=!!i.country&&N(L),A=R?new Set(L.map(s=>W(s==null?null:String(s))).filter(Boolean)).size:0,x=R&&A>=2,w=!!(i.lat&&i.lon)&&t.some(s=>{let d=+String(s[i.lat]??"").trim(),S=+String(s[i.lon]??"").trim();return isFinite(d)&&isFinite(S)&&d>=-90&&d<=90&&S>=-180&&S<=180&&String(s[i.lat]??"").trim()!==""&&String(s[i.lon]??"").trim()!==""});return i.lat&&i.lon&&!w&&a.push(`lat/lon=${i.lat}/${i.lon} (no row holds a usable coordinate pair)`),i.country&&!x&&!(i.city||i.state||i.zip||w)&&a.push(R?`country=${i.country} (every row resolves to the same country - nothing to place apart)`:`country=${i.country} (values are not country identifiers)`),{bind:!!(i.city||i.state||i.zip||x||w)?i:null,backfilled:l,refused:a,...Object.keys(h).length?{labelFallback:h}:{}}}var r=(e,...t)=>({part:e,langs:Object.freeze(t)}),ie=Object.freeze({jaar:r("year","nl"),kwartaal:r("quarter","nl"),maand:r("month","nl"),dag:r("day","nl","sv","da","nb"),jahr:r("year","de"),quartal:r("quarter","de"),monat:r("month","de"),tag:r("day","de"),ann\u00E9e:r("year","fr"),mois:r("month","fr"),jour:r("day","fr"),trimestre:r("quarter","fr","es","pt","it"),a\u00F1o:r("year","es"),mes:r("month","es"),d\u00EDa:r("day","es"),ano:r("year","pt"),m\u00EAs:r("month","pt"),dia:r("day","pt"),anno:r("year","it"),mese:r("month","it"),giorno:r("day","it"),\u0433\u043E\u0434:r("year","ru"),\u043C\u0435\u0441\u044F\u0446:r("month","ru"),\u0440\u0456\u043A:r("year","uk"),\u043C\u0456\u0441\u044F\u0446\u044C:r("month","uk"),\u043A\u0432\u0430\u0440\u0442\u0430\u043B:r("quarter","ru","uk"),\u0434\u0435\u043D\u044C:r("day","ru","uk"),rok:r("year","pl","cs","sk"),kwarta\u0142:r("quarter","pl"),miesi\u0105c:r("month","pl"),dzie\u0144:r("day","pl"),\u010Dtvrtlet\u00ED:r("quarter","cs"),m\u011Bs\u00EDc:r("month","cs"),den:r("day","cs"),\u0161tvr\u0165rok:r("quarter","sk"),mesiac:r("month","sk"),de\u0148:r("day","sk"),\u00E5r:r("year","sv","da","nb"),kvartal:r("quarter","sv","da","nb"),m\u00E5nad:r("month","sv"),m\u00E5ned:r("month","da","nb"),vuosi:r("year","fi"),vuosinelj\u00E4nnes:r("quarter","fi"),kuukausi:r("month","fi"),p\u00E4iv\u00E4:r("day","fi"),\u00E9v:r("year","hu"),negyed\u00E9v:r("quarter","hu"),h\u00F3nap:r("month","hu"),nap:r("day","hu"),y\u0131l:r("year","tr"),\u00E7eyrek:r("quarter","tr"),ay:r("month","tr"),g\u00FCn:r("day","tr"),\u03AD\u03C4\u03BF\u03C2:r("year","el"),\u03C4\u03C1\u03AF\u03BC\u03B7\u03BD\u03BF:r("quarter","el"),\u03BC\u03AE\u03BD\u03B1\u03C2:r("month","el"),\u03B7\u03BC\u03AD\u03C1\u03B1:r("day","el"),an:r("year","ro"),trimestru:r("quarter","ro"),lun\u0103:r("month","ro"),zi:r("day","ro"),godina:r("year","hr"),tromjese\u010Dje:r("quarter","hr"),mjesec:r("month","hr"),dan:r("day","hr"),\u5E74:r("year","ja","zh"),\u56DB\u534A\u671F:r("quarter","ja"),\u5B63\u5EA6:r("quarter","zh"),\u6708:r("month","ja","zh"),\u65E5:r("day","ja","zh"),\uC5F0\uB3C4:r("year","ko"),\uBD84\uAE30:r("quarter","ko"),\uC6D4:r("month","ko"),\uC77C:r("day","ko"),tahun:r("year","id"),kuartal:r("quarter","id"),triwulan:r("quarter","id"),bulan:r("month","id"),hari:r("day","id"),n\u0103m:r("year","vi"),qu\u00FD:r("quarter","vi"),th\u00E1ng:r("month","vi"),ng\u00E0y:r("day","vi"),\u0E1B\u0E35:r("year","th"),\u0E44\u0E15\u0E23\u0E21\u0E32\u0E2A:r("quarter","th"),\u0E40\u0E14\u0E37\u0E2D\u0E19:r("month","th"),\u0E27\u0E31\u0E19:r("day","th"),\u0627\u0644\u0633\u0646\u0629:r("year","ar"),\u0633\u0646\u0629:r("year","ar"),\u0627\u0644\u0639\u0627\u0645:r("year","ar"),\u0639\u0627\u0645:r("year","ar"),\u0627\u0644\u0631\u0628\u0639:r("quarter","ar"),\u0631\u0628\u0639:r("quarter","ar"),"\u0631\u0628\u0639 \u0627\u0644\u0633\u0646\u0629":r("quarter","ar"),\u0627\u0644\u0634\u0647\u0631:r("month","ar"),\u0634\u0647\u0631:r("month","ar"),\u0627\u0644\u064A\u0648\u0645:r("day","ar"),\u064A\u0648\u0645:r("day","ar"),\u05E9\u05E0\u05D4:r("year","he"),\u05E8\u05D1\u05E2\u05D5\u05DF:r("quarter","he"),\u05D7\u05D5\u05D3\u05E9:r("month","he"),\u05D9\u05D5\u05DD:r("day","he"),\u0935\u0930\u094D\u0937:r("year","hi"),\u0938\u093E\u0932:r("year","hi"),\u0924\u093F\u092E\u093E\u0939\u0940:r("quarter","hi"),\u092E\u0939\u0940\u0928\u093E:r("month","hi"),\u092E\u093E\u0939:r("month","hi"),\u0926\u093F\u0928:r("day","hi"),\u0633\u0627\u0644:r("year","fa"),\u0645\u0627\u0647:r("month","fa"),\u0631\u0648\u0632:r("day","fa")}),Jn=Object.freeze(Array.from(new Set(Object.values(ie).flatMap(e=>e.langs)))),fe=Object.freeze(["fa","ar","he","th"]),pe=1900,ge=2100;function Zn(e,t){let n=[],o=B(t);try{o&&n.push(e.toLocaleLowerCase(o.intl))}catch{}let u=e.toLowerCase();return n.includes(u)||n.push(u),n}function er(e,t){let n=String(e??"").trim().normalize("NFC");if(!n)return null;for(let o of Zn(n,t)){let u=ie[o];if(u&&u.langs.includes(t))return u.part}return null}function tr(e,t){return fe.includes(e)?typeof t=="number"&&Number.isFinite(t)&&t>=pe&&t<=ge:!0}function ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var nr=/\b(?:columns|cols|column)\b/i;function z(e,t){let n=Math.max(0,t-240),o=e.slice(n,t),u=o.lastIndexOf(";");return u>=0&&(o=o.slice(u+1)),nr.test(o)}function he(e,t){return Ce(e,t,n=>new RegExp(String.raw`\b${n}\s*(?:>=\s*0|>\s*-1|[!=]==?\s*-1)`).test(e))}function Ce(e,t,n){let o=ye(t),u=new RegExp(String.raw`(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*?\.name\s*===?\s*(['"])${o}\2`,"g"),l=new RegExp(String.raw`\.name\s*===?\s*(['"])${o}\1`,"g"),a=0,i;for(;(i=l.exec(e))!==null;)z(e,i.index)&&a++;let h=0;for(;(i=u.exec(e))!==null;){let C=i.index+i[0].lastIndexOf(".name");if(!z(e,C))continue;h++;let y=ye(i[1]);if(!n(y))return!1}return h>0&&h===a}function rr(e,t){return Ce(e,t,n=>new RegExp(String.raw`\b${n}\s*(?:>=\s*0|>\s*-1|!==?\s*-1)`).test(e)&&!new RegExp(String.raw`\b${n}\s*===?\s*-1`).test(e))}var be=["__rowIdx__","__geoIso__","__geoLat__","__geoLon__","__geoPrecision__"];function or(e,t){if(!e)return[];let n=new Set(t);for(let i of be)n.add(i);let o=new Set,u=/\.name\s*===?\s*(['"])([^'"]+)\1/g,l;for(;(l=u.exec(e))!==null;)z(e,l.index)&&o.add(l[2]);if(o.size===0)return[];let a=[];return o.forEach(i=>{n.has(i)||he(e,i)||a.push(i)}),a}function ir(e,t){if(!e)return[];let n=(e.getColumns()||[]).map(o=>o.name);if(!t||typeof e.aliasesForCode!="function")return n;for(let o of e.aliasesForCode(t))n.push(o.alias);return n}function Ee(e,t){let n=t?.freemiumMaxShapeColumns;return typeof n!="number"||!isFinite(n)||n<1?null:!isFinite(e)||e<=n?0:Math.round(e-n)}function sr(e,t,n){let o=Ee(e,t);if(o===null||o<=0)return null;let u=typeof t?.freemiumColumnCapPivot=="number"?t.freemiumColumnCapPivot:4,l=o>u?t?.freemiumColumnCapMessageMany:t?.freemiumColumnCapMessageFew;if(typeof l!="string"||l.trim().length===0)return null;let a=l.split("{n}").join(String(o)).split("{fields}").join(o===1?"field":"fields"),i=Te(n);return i.length===0?a:a+" "+i.join(" ")}function Te(e){if(!e||e.length===0)return[];let t=[],n=new Map,o=new Map;for(let l of e){let a=typeof l?.dateGroupId=="string"?l.dateGroupId.trim():"";if(a!==""&&(n.has(a)||(t.push(a),n.set(a,0)),l.isDatePart===!0&&n.set(a,n.get(a)+1),l.isReassembledDate===!0&&!o.has(a))){let i=typeof l.sourceField=="string"?l.sourceField.trim():"",h=typeof l.name=="string"?l.name.trim():"",C=i!==""?i:h;C!==""&&o.set(a,C)}}let u=[];for(let l of t){let a=o.get(l),i=n.get(l)??0;!a||i===0||u.push(`'${a}' is a date hierarchy and counts as ${i+1} fields - bind the date itself instead of its hierarchy.`)}return u}var m=e=>e==null?"":String(e),P=e=>e===!0,Se=e=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let t=Number(e);return Number.isFinite(t)?t:null}return null},ar=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function Re(e,t){let n={};for(let[o,u]of ar){let l=m(E(e,t+u));l&&(n[o]=l)}return n}function lr(e){return Array.isArray(e)?e.map(t=>({code:m(E(t,"code")),severity:m(E(t,"severity")),text:m(E(t,"text"))})).filter(t=>t.text!==""):[]}function ur(e){let t=C=>E(e,C),n=t("retryAfterSeconds"),o=t("overrideThumbnailUpload"),u=t("forceThumbnailUpload"),l=Re(e,"point"),a=Re(e,"destPoint");Object.keys(a).length&&(l.dest=a);let i=t("retryable"),h=t("isPollFinal");return{errorMessage:m(t("errorMessage")),errorCode:m(t("errorCode")),refusalCode:m(t("refusalCode")),retryable:typeof i=="boolean"?i:null,notices:lr(t("notices")),freemiumStatusCode:m(t("freemiumStatusCode")),code:m(t("code")),language:m(t("language")),version:Number(t("version")??0),codeSummary:m(t("codeSummary")),chartName:m(t("chartName")??t("chartType")),finalChartName:m(t("finalChartName")),warningMessage:m(t("warningMessage")),outputHash:m(t("outputHash")),validatorToken:m(t("validatorToken")),editCodeKey:m(t("editCodeKey")),signedLLMRequestID:m(t("signedLLMRequestID")),userReply:m(t("userReply")),userReplyOutcome:m(t("userReplyOutcome")),improvementSuggestion:m(t("improvementSuggestion")),geoColumn:m(t("geoColumn")),geoKind:m(t("geoKind")),geoPointCols:Object.keys(l).length?l:null,creditBalanceBefore:Se(t("creditBalanceBefore")),creditCost:Se(t("creditCost")),isServiceError:P(t("isServiceError")),isRateLimited:P(t("isRateLimited")),isRefusal:P(t("isRefusal")),isVersionNotFound:P(t("isVersionNotFound")),isGenerationCancelled:P(t("isGenerationCancelled")),retryAfterSeconds:typeof n=="number"&&Number.isFinite(n)?n:null,servedCorrelationId:m(t("servedCorrelationId")),...typeof h=="boolean"?{isPollFinal:h}:{},...m(t("pollOutcome"))!==""?{pollOutcome:m(t("pollOutcome"))}:{},...typeof o=="boolean"?{overrideThumbnailUpload:o}:{},...typeof u=="boolean"?{forceThumbnailUpload:u}:{}}}var xe=e=>e==null?void 0:Number(e),k=e=>m(e)||void 0;function cr(e){let t=E(e,"charts"),n=E(e,"refused"),o=Array.isArray(t)?t.map(l=>{let a=h=>E(l,h),i=a("recommended");return{name:m(a("chartTypeName")??a("name")),description:m(a("description")??a("chartDesc")),rank:xe(a("rank")),score:xe(a("score")),renderer:k(a("renderer")),language:k(a("language")),isPreview:P(a("isPreview")),alsoWorthALook:P(a("alsoWorthALook")),recommended:typeof i=="boolean"?i:void 0,viaProjection:k(a("viaProjection")),viaProjectionKey:k(a("viaProjectionKey")),detailNote:k(a("detailNote"))}}).filter(l=>l.name):null,u=Array.isArray(n)?n.map(l=>({name:m(E(l,"chartTypeName")??E(l,"name")),reason:m(E(l,"reason")),reasonCode:m(E(l,"reasonCode")),isVeto:P(E(l,"isVeto"))})).filter(l=>l.name):[];return{errorMessage:m(E(e,"errorMessage")),errorCode:m(E(e,"errorCode")),charts:o,refused:u,noFitSummary:m(E(e,"noFitSummary"))}}function dr(e){return!e||typeof e!="object"?null:{status:String(E(e,"status")??""),verdictReason:E(e,"verdictReason")??null,instruction:E(e,"instruction")??null,fix:E(e,"fix")??null,errorMessage:E(e,"errorMessage")??null,errorCode:E(e,"errorCode")??null}}var we=["working","analyze","generate","refine","review"];function mr(e,t){let n=String(e??"").trim().toLowerCase();if(we.includes(n))return n;let o=String(t??"").toLowerCase();return o.includes("analyz")?"analyze":o.includes("generat")?"generate":o.includes("refin")?"refine":o.includes("review")?"review":null}var fr="FREEMIUM_ATTEMPT_SPENT",pr="CLIENT_SECRET_MISMATCH",gr="FREEMIUM_COLUMN_CAP",yr="OAUTH_TOKEN_EXPIRED",hr="OAUTH_SIGNED_OUT";function Cr(e){let t=e?.retryable;return typeof t=="boolean"?t:null}function br(e){let t=e.linkNonce?(e.linkNonce()??"").trim():null,n=t?null:e.accessToken?(e.accessToken()??"").trim():null,o=t||n?{licensee:"",licenseKey:"",secretKey:""}:e.triple();return{request:{licenseKey:o.licenseKey,licensee:o.licensee,secretKey:o.secretKey,freemiumKey:e.freemiumKey?.()??""},linkNonce:t,accessToken:n}}function Er(e){let{width:t,height:n}=e.measure();return{request:{height:n,width:t},hints:{viewportWidth:t,viewportHeight:n}}}function Tr(e){let t=0;for(let n of e){if(n.isMeasure)continue;let o=n.distinctCount;typeof o=="number"&&o>t&&(t=o)}return t}function _e(e){if(e.recoveryFetchByCorrelation)return{version:null,fetchOnly:!0};if(e.recoveryFetchVersion!=null)return{version:e.recoveryFetchVersion,fetchOnly:!0};let t=e.settingVersion??null;if(e.genNew)return{version:t,fetchOnly:void 0};let n=(t??0)>0?t:null,o=(e.codeVersion??0)>0?e.codeVersion:null,u=n??o??t;return{version:u,fetchOnly:u!=null&&u>0?!0:void 0}}function Sr(e){let t=e.fetchCorrelationId!=null,o=t||e.recoveryFetchVersion!=null?!1:e.genNew,u=_e({genNew:o,recoveryFetchVersion:e.recoveryFetchVersion,recoveryFetchByCorrelation:t,settingVersion:e.settingVersion,codeVersion:e.codeVersion}),l=e.fetchArmedAtMs,a=t&&typeof l=="number"&&Number.isSafeInteger(l)&&l>0?l:void 0;return{genNew:o,version:u.version,fetchOnly:u.fetchOnly,fetchCorrelationId:e.fetchCorrelationId??void 0,...a!==void 0?{fetchArmedAtMs:a}:{}}}function Rr(e){let t=n=>e.renderers.has(n);return{supportsD3:t("D3"),supportsPlotly:t("PLOTLY"),supportsVega:t("VEGA")}}function xr(e){let t=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??t,maxTries:t}}function wr(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}var _r={fit:"Best fit",variety:"Something different"};function Oe(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="fit"||t==="variety"?t:null}function Or(e){let t=Oe(e);return t?{qualifyOrder:t}:{}}function ve(e,t){return e!=null&&t!=null&&e!==t}function vr(e,t){return e?ve(t.capturedFor,t.now)?{shortlist:void 0,stale:!0}:{shortlist:{...e,ageMs:t.atMs>0?Math.max(0,Math.round(t.nowMs-t.atMs)):void 0},stale:!1}:{shortlist:void 0,stale:!1}}var Pr=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function Pe(e){let t=String(e??"").trim().toLowerCase();return Pr[t]??t}function Le(e){let t="";for(let n of e)t+=JSON.stringify([String(n.name??""),n.isMeasure?"M":"D",Pe(n.dataType)]);return t}function Lr(e){return j(Le(e))}var Ar=2,Mr=3,Ir=4,Nr=64,Fr=8e3,Dr=6e4,kr=Object.freeze({RENDER_START:"render-start",RENDER_OK:"render-ok",RENDER_ERROR:"render-error",VIEW:"view",VIEW_VERDICT:"view-verdict",REDRAW:"redraw",INTERACT:"interact"}),Gr=Object.freeze(["open","generate","version","rebind","data","sample","fix","resize","other"]);function Vr(e,t){return t?`${t};draw:${e}`:`draw:${e}`}function Ur(e){return e.hint?e.hint:e.generated?"generate":e.previous?e.outputHash!==e.previous.outputHash?"version":e.dataSignature!==e.previous.dataSignature?"data":e.viewport!==e.previous.viewport?"resize":"other":"open"}function Wr(){let e=new Set,t=new Set;return{firstDraw(n,o){if(!n)return!1;let u=`${n}|${o}`;return e.has(u)?!1:(e.add(u),!0)},firstInteract(n){return!n||t.has(n)?!1:(t.add(n),!0)}}}function qr(e){return!!e&&!e.includes("|")&&!e.includes(",")}function se(e,t,n,o){let u=`${e},${t}|${n}`;return o?`${u}|${Math.max(0,Math.round(o.count))}|${o.nonce}`:u}function $r(e,t){let n=e;if(!n||!n.signer||typeof n.signer.sign!="function")throw new TypeError("createTelemetryClient needs the host's signer");if(!n.transport||typeof n.transport.post!="function")throw new TypeError("createTelemetryClient needs the host's transport");if(!n.clock||typeof n.clock.now!="function")throw new TypeError("createTelemetryClient needs the host's clock");if(!t||typeof t.baseUrl!="string"&&typeof t.baseUrl!="function")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof t.baseUrl=="string"&&t.baseUrl==="")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof t.clientVersion!="string"||t.clientVersion==="")throw new TypeError("createTelemetryClient needs the client version");if(typeof t.timeoutMs!="number"||!Number.isFinite(t.timeoutMs)||t.timeoutMs<=0)throw new TypeError("createTelemetryClient needs a positive deadline in milliseconds");let{signer:o,transport:u,clock:l}=n,a=t.apiPath??"/api",i=t.timeoutMs,h=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,C=g=>{try{t.onFailure?.(g)}catch{}},y=async(g,f,c,p)=>{let b;try{let T=await u.post(f,c,p,{timeoutMs:i});b=T.status;try{T.body?.cancel().catch(()=>{})}catch{}}catch(T){C({channel:g,stage:"post",status:null,error:T});return}(b<200||b>299)&&C({channel:g,stage:"status",status:b,error:null})};return{async sendClientMessage(g){let f,c,p;try{f=`${h()}${a}/LogClientMsg/?nocache=${l.now()}`,c=I(g),p=D(c,o)}catch(b){C({channel:"client-message",stage:"build",status:null,error:b});return}await y("client-message",f,c,{"Content-Type":"text/plain","X-Signature":p})},async countEvent(g,f,c){let p,b;try{p=`${h()}${a}/eventlog`,b=se(g,t.clientVersion,f,c)}catch(T){C({channel:"event-count",stage:"build",status:null,error:T});return}await y("event-count",p,b,{"Content-Type":"text/plain"})}}}var Ae=2**31-1;function Me(e){return Object.assign(new Error(`The request did not finish within ${e} ms.`),{name:"TimeoutError"})}function zr(e){return typeof e=="number"&&e>0&&e<=Ae?null:new RangeError(`fetchTransport cannot keep a deadline of ${String(e)} ms: it must be a number of milliseconds above 0 and at most ${Ae} (about 24.8 days), the longest a timer can wait. Nothing was sent.`)}function Hr(e,t={}){if(typeof e!="function")throw new TypeError("fetchTransport needs the host's fetch");let n=e,o=t.credentials??"omit";return{async post(u,l,a,i){let h=i.timeoutMs,C=zr(h);if(C)throw C;let y=new AbortController,g=!1,f=setTimeout(()=>{g=!0,y.abort(Me(h))},h),c=()=>y.abort(i.signal?.reason);i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c,{once:!0}));let p=!1,b=()=>{p||(p=!0,clearTimeout(f),i.signal?.removeEventListener("abort",c))},T=_=>g?Me(h):_,L;try{L=await n(u,{method:"POST",body:l,headers:a,credentials:o,signal:y.signal})}catch(_){throw b(),T(_)}let R=X(L),A=R.statusText!==void 0?{statusText:R.statusText}:{};if(!R.body)return{status:R.status,...A,contentType:R.contentType,body:null,text:async()=>{try{return await R.text()}catch(_){throw T(_)}finally{b()}}};let x=R.body.getReader(),w=new ReadableStream({async pull(_){try{let s=await x.read();if(s.done){b(),_.close();return}_.enqueue(s.value)}catch(s){b(),_.error(T(s))}},cancel(_){return b(),x.cancel(_)}});return{status:R.status,...A,contentType:R.contentType,body:w,text:()=>new Response(w).text()}}}}var Ie=300,Kr="/LLMChart/",Br="/LLMChart/qualify",jr="/VisionReview/",Yr="/LLMChart/sample",Qr="/RefundGenerate/",Xr=e=>!!e&&typeof e=="object"&&e.name==="TimeoutError",H=async e=>JSON.parse(await e.text());function Jr(e){try{e.body?e.body.cancel().catch(()=>{}):e.text().catch(()=>{})}catch{}}function Zr(e,t){let n=e;if(!n||!n.signer||typeof n.signer.sign!="function")throw new TypeError("createGenerateClient needs the host's signer");if(!n.transport||typeof n.transport.post!="function")throw new TypeError("createGenerateClient needs the host's transport");if(!n.clock||typeof n.clock.now!="function")throw new TypeError("createGenerateClient needs the host's clock");if(!t||typeof t.baseUrl!="string"&&typeof t.baseUrl!="function")throw new TypeError("createGenerateClient needs the service's base URL");if(typeof t.baseUrl=="string"&&t.baseUrl==="")throw new TypeError("createGenerateClient needs the service's base URL");if(t.apiPath!==void 0&&typeof t.apiPath!="string")throw new TypeError("createGenerateClient's apiPath must be a string");if(t.nocache!==void 0&&t.nocache!==null&&typeof t.nocache!="function")throw new TypeError("createGenerateClient's nocache must be a function");let{signer:o,transport:u,clock:l}=n,a=t.apiPath??"/api",i=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,h=g=>t.nocache?t.nocache(g):String(l.now());async function C(g,f,c,p,b){let T=`${i()}${a}${f}?nocache=${h(g)}`,L={"Content-Type":"text/plain","X-Signature":D(c,o)},R=p.signal??void 0,A=(w,_)=>{let s=!!R?.aborted;return{kind:"transport",headersReceived:w,timedOut:!s&&Xr(_),cancelled:s,error:_}},x;try{x=await u.post(T,c,L,R?{timeoutMs:p.timeoutMs,signal:R}:{timeoutMs:p.timeoutMs})}catch(w){return A(!1,w)}if(x.status<200||x.status>299){let w="";if(p.readErrorBody===!1)Jr(x);else try{w=(await x.text()).slice(0,Ie)}catch{}return{kind:"http",status:x.status,statusText:x.statusText??"",bodyStart:w}}try{return{kind:"answer",status:x.status,value:await b(x)}}catch(w){return A(!0,w)}}function y(g,f){if(!f||typeof f.timeoutMs!="number"||!Number.isFinite(f.timeoutMs)||f.timeoutMs<=0)throw new TypeError(`The ${g} call needs a positive deadline in milliseconds`);return f}return{async generate(g,f){let c=y("generate",f),p=c.onStage??void 0;return C("generate",Kr,I(g),c,b=>J(b,p))},async qualify(g,f){let c=y("qualify",f),p=c.route??Br;if(typeof p!="string"||!p.startsWith("/"))throw new TypeError("The qualify route must start with '/'");return C("qualify",p,I(g),c,H)},async review(g,f){let c=y("review",f),p=JSON.stringify(g);if(typeof p!="string")throw new TypeError("The review wire did not serialize to JSON");return C("review",jr,p,c,H)},async sample(g,f){let c=y("sample",f);return C("sample",Yr,I(g),c,H)},async refund(g,f){let c=y("refund",f);if(typeof g!="string"||g.trim()==="")throw new TypeError("A refund needs the generation's correlation id");return C("refund",Qr,JSON.stringify({CorrelationID:g.trim()}),c,H)}}}export{Y as CITY_ROLE_MATCH_PCT,kr as CLIENT_EVENT_KINDS,pr as CLIENT_SECRET_MISMATCH,Be as COMPOUND_MIN_STEM,dt as CYCLE_MEMBERS,ft as CYCLE_WORDS,ge as DATE_LEVEL_GREGORIAN_YEAR_MAX,pe as DATE_LEVEL_GREGORIAN_YEAR_MIN,Jn as DATE_LEVEL_LANGUAGES,ie as DATE_LEVEL_NAMES,fe as DATE_LEVEL_NON_GREGORIAN_LANGUAGES,xn as DEFAULT_GAP_FACTOR,ot as DEFAULT_TEMPERATURE,Gr as DRAW_REASONS,fr as FREEMIUM_ATTEMPT_SPENT,gr as FREEMIUM_COLUMN_CAP,nt as GET_RANDOM,Ye as GLUED_STEM_MIN,Xe as HANGUL_MIN_STEM,be as HOST_SYNTHETIC_COLUMNS,Ie as HTTP_BODY_START_CHARS,Cn as IDENTIFIER_HEAD_INITIAL,bn as IDENTIFIER_UNFOLDED,hn as IDENTIFIER_WORDS,tn as INTENSIVE_SUFFIX_TOKENS,en as INTENSIVE_WORD_TOKENS,Un as IndexedText,xt as LOOSE_KEY_MIN_LENGTH,_t as LooseIndex,wn as MAX_RUN_BOUNDS,hr as OAUTH_SIGNED_OUT,yr as OAUTH_TOKEN_EXPIRED,Ct as PERIOD_CODE_FORMS,ht as PERIOD_CODE_MEMBERS,bt as PERIOD_ORDINALS,Et as PERIOD_UNFOLDED,rn as POSITIONAL_SUFFIX_TOKENS,nn as POSITIONAL_WORD_TOKENS,zn as PREVIEW_OMITTED_FIELDS,we as PROGRESS_STAGE_IDS,_r as QUALIFY_ORDER_LABELS,M as ROLE_MATCH_PCT,vn as SERIES_COMPLETENESS_MAX_LISTED,Pn as SERIES_COMPLETENESS_MIN_FILL,Ln as SERIES_KEY_MAX_DISTINCT,Ir as SEV_ERROR,Ar as SEV_INFO,Nr as SEV_USER_PRESENTED,Mr as SEV_WARNING,j as SIMPLE_STRING_HASH,tt as STR,Ze as SUBSTRING_MIN,Fe as SUPPORTED_LANGUAGES,De as SUPPORTED_LANGUAGE_CODES,Dr as TELEMETRY_TIMEOUT_DEV_MS,Fr as TELEMETRY_TIMEOUT_MS,Ve as VOCABULARY_LANGUAGE_CODES,Ge as VOCABULARY_ONLY_LANGUAGES,mt as YEAR_WORDS,$ as admin1MatchPct,fn as allowedAggregations,Cr as answerIsRetryable,$t as buildGeoIsoColumn,kt as buildGeoPointColumns,pt as calendarWordIn,Rr as capabilityFields,Vt as cityMatchPct,Gt as cityTagsFor,Gn as classifyAdditivity,Ur as classifyDraw,mn as classifyForAggregation,Vn as classifyNumericValueNature,Dn as classifyTemporal,ln as codeNeedsLegacyAggNames,Tn as codeReadsColumn,Sn as codeReadsColumnsByRoleOrPosition,an as collapseRepeatedAggPrefix,Rn as columnsTheCodeReads,Kt as countryRegion,Wr as createDrawLedger,Zr as createGenerateClient,$r as createTelemetryClient,br as credentialFields,er as dateLevelPart,tr as dateLevelYearAdmits,Yt as decimalSeparatorOf,pn as defaultAggregation,Qt as detectDecimalSeparator,jt as detectFormatSignature,Ut as detectGeo,Pt as detectOrdinalDomain,Fn as detectTextDatePattern,Vr as drawLocation,I as encodePayload,Wn as engineTypeForSqlType,un as englishImplicitAggNames,se as eventLogLine,Sr as fetchFields,Hr as fetchTransport,We as foldName,sr as freemiumColumnCapRefusal,Ee as freemiumColumnsOverCap,Te as freemiumDateHierarchyClauses,Qe as gluedPrefixStems,ir as guardColumnNames,Kn as gzipWireText,Je as hangulWordEndsWith,sn as hasDefaultAggPrefix,He as hasUnsegmentedScript,kn as hostAggHint,$n as ingest,gn as isAggregationAllowed,V as isBlankLike,At as isCityTableLoaded,z as isColumnContextRef,rt as isDeterministicRefusal,qr as isEventLogCode,Ft as isGeoPointAmbiguity,Nn as isIdentifierName,qt as isJoinGeoKind,jn as isNdjsonContentType,Ot as isOrdinalFriendlyName,wt as isUsableLooseKey,Bn as keyedSigner,wr as leafCardinalityField,ut as localMidnightDateColumns,lt as localMidnightToUtcDay,yt as localizedCycleIn,En as localizedIdentifierWordIn,gt as localizedYearWordIn,N as looksLikeCountryColumn,Rt as looseNameKey,et as matchNameToken,Tr as maxNonMeasureCardinality,On as measureCadence,In as measureSeriesCompleteness,D as messageSignature,or as missingHardColumnRefs,Zt as monthLookupFor,$e as nameLetterRuns,dn as nameLooksIntensiveRate,cn as nameLooksPositional,he as nameProbeIsGuarded,rr as nameProbeKeepsDrawing,qe as nameWords,Mt as normalizeCountry,ct as normalizeLocalMidnightDates,Jt as normalizeMonthKey,U as normalizePlaceName,Nt as normalizeZip5,vr as offeredShortlistFor,qn as parseCsvRows,it as parseDateStable,ur as parseGenerateResponse,Xt as parseNumberText,cr as parseQualifyResponse,dr as parseReviewVerdict,_n as parseTemporalPoint,Hn as payloadPreview,St as periodCodeSeries,Mn as pickSeriesColumn,mr as progressStageOf,Or as qualifyOrderField,Oe as qualifyOrderOf,J as readGenerateStream,ze as readName,Tt as readPeriodCode,E as readWireField,Lt as registerCityTable,Ht as registerIso3Regions,v as resolveAdmin1,_e as resolveFetchVersion,Dt as resolveGeoPoint,Ue as resolveLanguage,Xn as resolvePointRoles,xr as retryFields,vt as safeDistinctValuesToShip,Le as schemaIdentity,Lr as schemaIdentityKey,Pe as schemaTypeFamily,An as seriesKeyVerdict,yn as shareOfTotalIsHonest,ve as shortlistIsStale,on as stripHostAggPrefix,Bt as summarizeCountryRegions,zt as summarizeGeoExtent,ke as supportedLanguage,Wt as toGeoIso,Ke as unsegmentedRuns,Er as viewportFields,B as vocabularyLanguage,st as wholeDayFrame,at as wholeDayIso,X as wireResponseFromFetch,je as wordEndsWith,re as zipMatchPct,q as zipPrefixCandidates,It as zipToPrefix3};
2
+ import{a as zn,b as Hn}from"./chunk-HIVICMC5.mjs";import{a as Kn,b as I,c as Bn,d as D,e as E,f as jn,g as X,h as J}from"./chunk-QMVECPSM.mjs";import{a as Wn,b as qn,c as $n}from"./chunk-D5DKZQJT.mjs";import{A as Sn,B as Rn,C as xn,D as wn,E as _n,F as On,G as vn,H as Pn,I as Ln,J as An,K as Mn,L as In,M as Nn,N as Fn,O as Dn,P as kn,Q as Gn,R as Vn,T as Un,a as zt,b as Ht,c as Kt,d as Bt,f as en,g as tn,h as nn,i as rn,j as on,k as sn,l as an,m as ln,n as un,o as cn,p as dn,q as mn,r as fn,s as pn,t as gn,u as yn,v as hn,w as Cn,x as bn,y as En,z as Tn}from"./chunk-AQ2WZ4TT.mjs";import{a as jt}from"./chunk-U3H6UBOO.mjs";import{b as Yt,c as Qt,d as Xt,f as Jt,g as Zt}from"./chunk-A4PQBWRA.mjs";import{a as le,b as ue,c as Ut,d as Wt,e as qt,f as $t}from"./chunk-QPIKC2O6.mjs";import{a as M,b as V,c as Y,d as U,k as W,l as Lt,m as At,n as ae,o as v,p as Mt,q as It,r as Nt,s as q,t as Ft,u as Dt,v as kt,w as Gt,x as Q,y as Vt}from"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import{a as dt,b as mt,c as ft,d as pt,e as gt,f as yt,g as ht,h as Ct,i as bt,j as Et,k as Tt,l as St,m as Ot,n as vt,o as Pt}from"./chunk-IIGGO4ES.mjs";import{a as We,b as qe,c as $e,d as ze,e as He,f as Ke,g as Be,h as je,i as Ye,j as Qe,k as Xe,l as Je,m as Ze,n as et,o as tt,q as j,r as nt,s as rt,t as ot,u as it,v as st,w as at,x as lt,y as ut,z as ct}from"./chunk-NT6CDI3K.mjs";import{a as Fe,b as De,c as ke,d as Ge,e as Ve,f as B,g as Ue}from"./chunk-WC4JINEZ.mjs";import{b as Rt,c as xt,d as wt,e as _t}from"./chunk-5HI6TVMM.mjs";var Z=2,me=400;function te(e){return!!W(e)}function F(e){let t=new Set;for(let n of e){if(n==null)continue;let o=U(String(n));if(!V(o)&&!t.has(o)&&(t.add(o),t.size>=me))break}return Array.from(t)}function N(e){let t=F(e);if(t.length===0||ne(e)<95)return!1;let n=t.filter(a=>te(a)&&!v(a)).length,o=t.filter(a=>!te(a)&&!!v(a)).length;return n>=1&&n>=o}function ce(e,t){if(!v(e))return!1;let n=W(e);return n?t==="world"?!0:ae.has(n):!1}function ne(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let o of t)te(o)&&n++;return Math.round(n/t.length*1e3)/10}function $(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let o of t)v(o)&&n++;return Math.round(n/t.length*1e3)/10}function oe(e){let t=new Set;for(let n of e){if(n==null)continue;let o=String(n).trim();if(!V(U(o))&&!t.has(o)&&(t.add(o),t.size>=me))break}return Array.from(t)}function re(e){let t=oe(e);if(t.length===0)return 0;let n=0;for(let o of t)q(o).length>0&&n++;return Math.round(n/t.length*1e3)/10}function de(e,t){return ue(t,le)?!0:oe(e).some(n=>/^\d{5}(-\d{4})?$/.test(n.replace(/\.0+$/,"")))}function Yn(e,t){let n=F(e);if(n.length===0)return 0;let o=0;for(let a of n)Q(a,t)&&o++;return Math.round(o/n.length*1e3)/10}function ee(e,t){let n=0;for(let o of F(e))t(o)&&n++;return n}function Qn(e,t){let n=0;for(let o of oe(e))t(o)&&n++;return n}function Xn(e,t,n,o,a){let u=[],l=[],i={},h={},C=new Set(e),y=s=>t.map(d=>d[s]);for(let s of["city","country"]){let d=n?.[s];d&&C.has(d)&&(i[s]=d)}let g=new Set(a??e);for(let s of["lat","lon"]){let d=n?.[s];d&&g.has(d)&&(i[s]=d)}let f=n?.zip;if(f&&C.has(f)){let s=y(f),d=re(s);d<95?l.push(`zip=${f} (only ${d}% of values read as ZIPs)`):de(s,f)?i.zip=f:l.push(`zip=${f} (all values are 3-4 digits with nothing to say they are postal)`)}let c=n?.state;if(c&&C.has(c)){let s=y(c),d=F(s);d.length>0&&d.every(S=>ce(S,o))?l.push(`state=${c} (every value is "CA", which is both Canada and California)`):N(s)?(l.push(`state=${c} (every value is a country, not a state)`),i.country||(i.country=c)):$(s)<95?l.push(`state=${c} (only ${$(s)}% of values are states/provinces)`):i.state=c}let p=new Set(Object.values(i).filter(Boolean)),b=e.filter(s=>!p.has(s)&&!s.startsWith("__"));if(!i.state){let s=null;for(let d of b){let S=y(d);if(N(S))continue;let O=$(S);if(O<95)continue;let K=ee(S,G=>!!v(G)),Ne=ee(S,G=>!!v(G)&&!ce(G,o));K<Z&&Ne<1||(!s||O>s.pct)&&(s={name:d,pct:O})}s&&(i.state=s.name,p.add(s.name),u.push(`state=${s.name} (${s.pct}% states/provinces)`))}if(!i.zip)for(let s of b){if(p.has(s))continue;let d=y(s),S=re(d);if(!(S<95)&&de(d,s)&&!(Qn(d,O=>q(O).length>0)<Z)){i.zip=s,p.add(s),u.push(`zip=${s} (${S}% ZIP codes)`);break}}let T=i.country;if(!T||!N(y(T))){let s=null;for(let d of b){if(p.has(d)||!N(y(d)))continue;let S=ne(y(d));(!s||S>s.pct)&&(s={name:d,pct:S})}s&&(T&&(l.push(`country=${T} (only ${ne(y(T))}% of values are country identifiers; using ${s.name} instead)`),h.country=T),i.country=s.name,p.add(s.name),u.push(`country=${s.name}`))}if(!i.city){let s=null;for(let d of b){if(p.has(d))continue;let S=y(d),O=Yn(S,o);O<Y||ee(S,K=>Q(K,o))<Z||(!s||O>s.pct)&&(s={name:d,pct:O})}s&&(i.city=s.name,u.push(`city=${s.name} (${s.pct}% known cities)`))}let L=i.country?y(i.country):[],R=!!i.country&&N(L),A=R?new Set(L.map(s=>W(s==null?null:String(s))).filter(Boolean)).size:0,x=R&&A>=2,w=!!(i.lat&&i.lon)&&t.some(s=>{let d=+String(s[i.lat]??"").trim(),S=+String(s[i.lon]??"").trim();return isFinite(d)&&isFinite(S)&&d>=-90&&d<=90&&S>=-180&&S<=180&&String(s[i.lat]??"").trim()!==""&&String(s[i.lon]??"").trim()!==""});return i.lat&&i.lon&&!w&&l.push(`lat/lon=${i.lat}/${i.lon} (no row holds a usable coordinate pair)`),i.country&&!x&&!(i.city||i.state||i.zip||w)&&l.push(R?`country=${i.country} (every row resolves to the same country - nothing to place apart)`:`country=${i.country} (values are not country identifiers)`),{bind:!!(i.city||i.state||i.zip||x||w)?i:null,backfilled:u,refused:l,...Object.keys(h).length?{labelFallback:h}:{}}}var r=(e,...t)=>({part:e,langs:Object.freeze(t)}),ie=Object.freeze({jaar:r("year","nl"),kwartaal:r("quarter","nl"),maand:r("month","nl"),dag:r("day","nl","sv","da","nb"),jahr:r("year","de"),quartal:r("quarter","de"),monat:r("month","de"),tag:r("day","de"),ann\u00E9e:r("year","fr"),mois:r("month","fr"),jour:r("day","fr"),trimestre:r("quarter","fr","es","pt","it"),a\u00F1o:r("year","es"),mes:r("month","es"),d\u00EDa:r("day","es"),ano:r("year","pt"),m\u00EAs:r("month","pt"),dia:r("day","pt"),anno:r("year","it"),mese:r("month","it"),giorno:r("day","it"),\u0433\u043E\u0434:r("year","ru"),\u043C\u0435\u0441\u044F\u0446:r("month","ru"),\u0440\u0456\u043A:r("year","uk"),\u043C\u0456\u0441\u044F\u0446\u044C:r("month","uk"),\u043A\u0432\u0430\u0440\u0442\u0430\u043B:r("quarter","ru","uk"),\u0434\u0435\u043D\u044C:r("day","ru","uk"),rok:r("year","pl","cs","sk"),kwarta\u0142:r("quarter","pl"),miesi\u0105c:r("month","pl"),dzie\u0144:r("day","pl"),\u010Dtvrtlet\u00ED:r("quarter","cs"),m\u011Bs\u00EDc:r("month","cs"),den:r("day","cs"),\u0161tvr\u0165rok:r("quarter","sk"),mesiac:r("month","sk"),de\u0148:r("day","sk"),\u00E5r:r("year","sv","da","nb"),kvartal:r("quarter","sv","da","nb"),m\u00E5nad:r("month","sv"),m\u00E5ned:r("month","da","nb"),vuosi:r("year","fi"),vuosinelj\u00E4nnes:r("quarter","fi"),kuukausi:r("month","fi"),p\u00E4iv\u00E4:r("day","fi"),\u00E9v:r("year","hu"),negyed\u00E9v:r("quarter","hu"),h\u00F3nap:r("month","hu"),nap:r("day","hu"),y\u0131l:r("year","tr"),\u00E7eyrek:r("quarter","tr"),ay:r("month","tr"),g\u00FCn:r("day","tr"),\u03AD\u03C4\u03BF\u03C2:r("year","el"),\u03C4\u03C1\u03AF\u03BC\u03B7\u03BD\u03BF:r("quarter","el"),\u03BC\u03AE\u03BD\u03B1\u03C2:r("month","el"),\u03B7\u03BC\u03AD\u03C1\u03B1:r("day","el"),an:r("year","ro"),trimestru:r("quarter","ro"),lun\u0103:r("month","ro"),zi:r("day","ro"),godina:r("year","hr"),tromjese\u010Dje:r("quarter","hr"),mjesec:r("month","hr"),dan:r("day","hr"),\u5E74:r("year","ja","zh"),\u56DB\u534A\u671F:r("quarter","ja"),\u5B63\u5EA6:r("quarter","zh"),\u6708:r("month","ja","zh"),\u65E5:r("day","ja","zh"),\uC5F0\uB3C4:r("year","ko"),\uBD84\uAE30:r("quarter","ko"),\uC6D4:r("month","ko"),\uC77C:r("day","ko"),tahun:r("year","id"),kuartal:r("quarter","id"),triwulan:r("quarter","id"),bulan:r("month","id"),hari:r("day","id"),n\u0103m:r("year","vi"),qu\u00FD:r("quarter","vi"),th\u00E1ng:r("month","vi"),ng\u00E0y:r("day","vi"),\u0E1B\u0E35:r("year","th"),\u0E44\u0E15\u0E23\u0E21\u0E32\u0E2A:r("quarter","th"),\u0E40\u0E14\u0E37\u0E2D\u0E19:r("month","th"),\u0E27\u0E31\u0E19:r("day","th"),\u0627\u0644\u0633\u0646\u0629:r("year","ar"),\u0633\u0646\u0629:r("year","ar"),\u0627\u0644\u0639\u0627\u0645:r("year","ar"),\u0639\u0627\u0645:r("year","ar"),\u0627\u0644\u0631\u0628\u0639:r("quarter","ar"),\u0631\u0628\u0639:r("quarter","ar"),"\u0631\u0628\u0639 \u0627\u0644\u0633\u0646\u0629":r("quarter","ar"),\u0627\u0644\u0634\u0647\u0631:r("month","ar"),\u0634\u0647\u0631:r("month","ar"),\u0627\u0644\u064A\u0648\u0645:r("day","ar"),\u064A\u0648\u0645:r("day","ar"),\u05E9\u05E0\u05D4:r("year","he"),\u05E8\u05D1\u05E2\u05D5\u05DF:r("quarter","he"),\u05D7\u05D5\u05D3\u05E9:r("month","he"),\u05D9\u05D5\u05DD:r("day","he"),\u0935\u0930\u094D\u0937:r("year","hi"),\u0938\u093E\u0932:r("year","hi"),\u0924\u093F\u092E\u093E\u0939\u0940:r("quarter","hi"),\u092E\u0939\u0940\u0928\u093E:r("month","hi"),\u092E\u093E\u0939:r("month","hi"),\u0926\u093F\u0928:r("day","hi"),\u0633\u0627\u0644:r("year","fa"),\u0645\u0627\u0647:r("month","fa"),\u0631\u0648\u0632:r("day","fa")}),Jn=Object.freeze(Array.from(new Set(Object.values(ie).flatMap(e=>e.langs)))),fe=Object.freeze(["fa","ar","he","th"]),pe=1900,ge=2100;function Zn(e,t){let n=[],o=B(t);try{o&&n.push(e.toLocaleLowerCase(o.intl))}catch{}let a=e.toLowerCase();return n.includes(a)||n.push(a),n}function er(e,t){let n=String(e??"").trim().normalize("NFC");if(!n)return null;for(let o of Zn(n,t)){let a=ie[o];if(a&&a.langs.includes(t))return a.part}return null}function tr(e,t){return fe.includes(e)?typeof t=="number"&&Number.isFinite(t)&&t>=pe&&t<=ge:!0}function ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var nr=/\b(?:columns|cols|column)\b/i;function z(e,t){let n=Math.max(0,t-240),o=e.slice(n,t),a=o.lastIndexOf(";");return a>=0&&(o=o.slice(a+1)),nr.test(o)}function he(e,t){return Ce(e,t,n=>new RegExp(String.raw`\b${n}\s*(?:>=\s*0|>\s*-1|[!=]==?\s*-1)`).test(e))}function Ce(e,t,n){let o=ye(t),a=new RegExp(String.raw`(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*?\.name\s*===?\s*(['"])${o}\2`,"g"),u=new RegExp(String.raw`\.name\s*===?\s*(['"])${o}\1`,"g"),l=0,i;for(;(i=u.exec(e))!==null;)z(e,i.index)&&l++;let h=0;for(;(i=a.exec(e))!==null;){let C=i.index+i[0].lastIndexOf(".name");if(!z(e,C))continue;h++;let y=ye(i[1]);if(!n(y))return!1}return h>0&&h===l}function rr(e,t){return Ce(e,t,n=>new RegExp(String.raw`\b${n}\s*(?:>=\s*0|>\s*-1|!==?\s*-1)`).test(e)&&!new RegExp(String.raw`\b${n}\s*===?\s*-1`).test(e))}var be=["__rowIdx__","__geoIso__","__geoLat__","__geoLon__","__geoPrecision__"];function or(e,t){if(!e)return[];let n=new Set(t);for(let i of be)n.add(i);let o=new Set,a=/\.name\s*===?\s*(['"])([^'"]+)\1/g,u;for(;(u=a.exec(e))!==null;)z(e,u.index)&&o.add(u[2]);if(o.size===0)return[];let l=[];return o.forEach(i=>{n.has(i)||he(e,i)||l.push(i)}),l}function ir(e,t){if(!e)return[];let n=(e.getColumns()||[]).map(o=>o.name);if(!t||typeof e.aliasesForCode!="function")return n;for(let o of e.aliasesForCode(t))n.push(o.alias);return n}function Ee(e,t){let n=t?.freemiumMaxShapeColumns;return typeof n!="number"||!isFinite(n)||n<1?null:!isFinite(e)||e<=n?0:Math.round(e-n)}function sr(e,t,n){let o=Ee(e,t);if(o===null||o<=0)return null;let a=typeof t?.freemiumColumnCapPivot=="number"?t.freemiumColumnCapPivot:4,u=o>a?t?.freemiumColumnCapMessageMany:t?.freemiumColumnCapMessageFew;if(typeof u!="string"||u.trim().length===0)return null;let l=u.split("{n}").join(String(o)).split("{fields}").join(o===1?"field":"fields"),i=Te(n);return i.length===0?l:l+" "+i.join(" ")}function Te(e){if(!e||e.length===0)return[];let t=[],n=new Map,o=new Map;for(let u of e){let l=typeof u?.dateGroupId=="string"?u.dateGroupId.trim():"";if(l!==""&&(n.has(l)||(t.push(l),n.set(l,0)),u.isDatePart===!0&&n.set(l,n.get(l)+1),u.isReassembledDate===!0&&!o.has(l))){let i=typeof u.sourceField=="string"?u.sourceField.trim():"",h=typeof u.name=="string"?u.name.trim():"",C=i!==""?i:h;C!==""&&o.set(l,C)}}let a=[];for(let u of t){let l=o.get(u),i=n.get(u)??0;!l||i===0||a.push(`'${l}' is a date hierarchy and counts as ${i+1} fields - bind the date itself instead of its hierarchy.`)}return a}var m=e=>e==null?"":String(e),P=e=>e===!0,Se=e=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let t=Number(e);return Number.isFinite(t)?t:null}return null},ar=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function Re(e,t){let n={};for(let[o,a]of ar){let u=m(E(e,t+a));u&&(n[o]=u)}return n}function lr(e){return Array.isArray(e)?e.map(t=>({code:m(E(t,"code")),severity:m(E(t,"severity")),text:m(E(t,"text"))})).filter(t=>t.text!==""):[]}function ur(e){let t=C=>E(e,C),n=t("retryAfterSeconds"),o=t("overrideThumbnailUpload"),a=t("forceThumbnailUpload"),u=Re(e,"point"),l=Re(e,"destPoint");Object.keys(l).length&&(u.dest=l);let i=t("retryable"),h=t("isPollFinal");return{errorMessage:m(t("errorMessage")),errorCode:m(t("errorCode")),refusalCode:m(t("refusalCode")),retryable:typeof i=="boolean"?i:null,notices:lr(t("notices")),freemiumStatusCode:m(t("freemiumStatusCode")),code:m(t("code")),language:m(t("language")),version:Number(t("version")??0),codeSummary:m(t("codeSummary")),chartName:m(t("chartName")??t("chartType")),finalChartName:m(t("finalChartName")),warningMessage:m(t("warningMessage")),outputHash:m(t("outputHash")),validatorToken:m(t("validatorToken")),editCodeKey:m(t("editCodeKey")),signedLLMRequestID:m(t("signedLLMRequestID")),userReply:m(t("userReply")),userReplyOutcome:m(t("userReplyOutcome")),improvementSuggestion:m(t("improvementSuggestion")),geoColumn:m(t("geoColumn")),geoKind:m(t("geoKind")),geoPointCols:Object.keys(u).length?u:null,creditBalanceBefore:Se(t("creditBalanceBefore")),creditCost:Se(t("creditCost")),isServiceError:P(t("isServiceError")),isRateLimited:P(t("isRateLimited")),isRefusal:P(t("isRefusal")),isVersionNotFound:P(t("isVersionNotFound")),isGenerationCancelled:P(t("isGenerationCancelled")),retryAfterSeconds:typeof n=="number"&&Number.isFinite(n)?n:null,servedCorrelationId:m(t("servedCorrelationId")),...typeof h=="boolean"?{isPollFinal:h}:{},...m(t("pollOutcome"))!==""?{pollOutcome:m(t("pollOutcome"))}:{},...typeof o=="boolean"?{overrideThumbnailUpload:o}:{},...typeof a=="boolean"?{forceThumbnailUpload:a}:{}}}var xe=e=>e==null?void 0:Number(e),k=e=>m(e)||void 0;function cr(e){let t=E(e,"charts"),n=E(e,"refused"),o=Array.isArray(t)?t.map(u=>{let l=h=>E(u,h),i=l("recommended");return{name:m(l("chartTypeName")??l("name")),description:m(l("description")??l("chartDesc")),rank:xe(l("rank")),score:xe(l("score")),renderer:k(l("renderer")),language:k(l("language")),isPreview:P(l("isPreview")),alsoWorthALook:P(l("alsoWorthALook")),recommended:typeof i=="boolean"?i:void 0,viaProjection:k(l("viaProjection")),viaProjectionKey:k(l("viaProjectionKey")),detailNote:k(l("detailNote"))}}).filter(u=>u.name):null,a=Array.isArray(n)?n.map(u=>({name:m(E(u,"chartTypeName")??E(u,"name")),reason:m(E(u,"reason")),reasonCode:m(E(u,"reasonCode")),isVeto:P(E(u,"isVeto"))})).filter(u=>u.name):[];return{errorMessage:m(E(e,"errorMessage")),errorCode:m(E(e,"errorCode")),charts:o,refused:a,noFitSummary:m(E(e,"noFitSummary"))}}function dr(e){return!e||typeof e!="object"?null:{status:String(E(e,"status")??""),verdictReason:E(e,"verdictReason")??null,instruction:E(e,"instruction")??null,fix:E(e,"fix")??null,errorMessage:E(e,"errorMessage")??null,errorCode:E(e,"errorCode")??null}}var we=["working","analyze","generate","refine","review"];function mr(e,t){let n=String(e??"").trim().toLowerCase();if(we.includes(n))return n;let o=String(t??"").toLowerCase();return o.includes("analyz")?"analyze":o.includes("generat")?"generate":o.includes("refin")?"refine":o.includes("review")?"review":null}var fr="FREEMIUM_ATTEMPT_SPENT",pr="CLIENT_SECRET_MISMATCH",gr="FREEMIUM_COLUMN_CAP",yr="OAUTH_TOKEN_EXPIRED",hr="OAUTH_SIGNED_OUT";function Cr(e){let t=e?.retryable;return typeof t=="boolean"?t:null}function br(e){let t=e.linkNonce?(e.linkNonce()??"").trim():null,n=t?null:e.accessToken?(e.accessToken()??"").trim():null,o=t||n?{licensee:"",licenseKey:"",secretKey:""}:e.triple();return{request:{licenseKey:o.licenseKey,licensee:o.licensee,secretKey:o.secretKey,freemiumKey:e.freemiumKey?.()??""},linkNonce:t,accessToken:n}}function Er(e){let{width:t,height:n}=e.measure();return{request:{height:n,width:t},hints:{viewportWidth:t,viewportHeight:n}}}function Tr(e){let t=0;for(let n of e){if(n.isMeasure)continue;let o=n.distinctCount;typeof o=="number"&&o>t&&(t=o)}return t}function _e(e){if(e.recoveryFetchByCorrelation)return{version:null,fetchOnly:!0};if(e.recoveryFetchVersion!=null)return{version:e.recoveryFetchVersion,fetchOnly:!0};let t=e.settingVersion??null;if(e.genNew)return{version:t,fetchOnly:void 0};let n=(t??0)>0?t:null,o=(e.codeVersion??0)>0?e.codeVersion:null,a=n??o??t;return{version:a,fetchOnly:a!=null&&a>0?!0:void 0}}function Sr(e){let t=e.fetchCorrelationId!=null,o=t||e.recoveryFetchVersion!=null?!1:e.genNew,a=_e({genNew:o,recoveryFetchVersion:e.recoveryFetchVersion,recoveryFetchByCorrelation:t,settingVersion:e.settingVersion,codeVersion:e.codeVersion}),u=e.fetchArmedAtMs,l=t&&typeof u=="number"&&Number.isSafeInteger(u)&&u>0?u:void 0;return{genNew:o,version:a.version,fetchOnly:a.fetchOnly,fetchCorrelationId:e.fetchCorrelationId??void 0,...l!==void 0?{fetchArmedAtMs:l}:{}}}function Rr(e){let t=n=>e.renderers.has(n);return{supportsD3:t("D3"),supportsPlotly:t("PLOTLY"),supportsVega:t("VEGA")}}function xr(e){let t=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??t,maxTries:t}}function wr(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}function _r(e,t,n){let o=a=>typeof a=="number"&&Number.isInteger(a)&&a>0;return{...typeof e=="boolean"?{dataComplete:e}:{},...o(t)?{rowsWithheld:t}:{},...o(n)?{rowsFilteredOut:n}:{}}}var Or={fit:"Best fit",variety:"Something different"};function Oe(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="fit"||t==="variety"?t:null}function vr(e){let t=Oe(e);return t?{qualifyOrder:t}:{}}function ve(e,t){return e!=null&&t!=null&&e!==t}function Pr(e,t){return e?ve(t.capturedFor,t.now)?{shortlist:void 0,stale:!0}:{shortlist:{...e,ageMs:t.atMs>0?Math.max(0,Math.round(t.nowMs-t.atMs)):void 0},stale:!1}:{shortlist:void 0,stale:!1}}var Lr=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function Pe(e){let t=String(e??"").trim().toLowerCase();return Lr[t]??t}function Le(e){let t="";for(let n of e)t+=JSON.stringify([String(n.name??""),n.isMeasure?"M":"D",Pe(n.dataType)]);return t}function Ar(e){return j(Le(e))}var Mr=2,Ir=3,Nr=4,Fr=64,Dr=8e3,kr=6e4,Gr=Object.freeze({RENDER_START:"render-start",RENDER_OK:"render-ok",RENDER_ERROR:"render-error",VIEW:"view",VIEW_VERDICT:"view-verdict",REDRAW:"redraw",INTERACT:"interact"}),Vr=Object.freeze(["open","generate","version","rebind","data","sample","fix","resize","other"]);function Ur(e,t){return t?`${t};draw:${e}`:`draw:${e}`}function Wr(e){return e.hint?e.hint:e.generated?"generate":e.previous?e.outputHash!==e.previous.outputHash?"version":e.dataSignature!==e.previous.dataSignature?"data":e.viewport!==e.previous.viewport?"resize":"other":"open"}function qr(){let e=new Set,t=new Set;return{firstDraw(n,o){if(!n)return!1;let a=`${n}|${o}`;return e.has(a)?!1:(e.add(a),!0)},firstInteract(n){return!n||t.has(n)?!1:(t.add(n),!0)}}}function $r(e){return!!e&&!e.includes("|")&&!e.includes(",")}function se(e,t,n,o){let a=`${e},${t}|${n}`;return o?`${a}|${Math.max(0,Math.round(o.count))}|${o.nonce}`:a}function zr(e,t){let n=e;if(!n||!n.signer||typeof n.signer.sign!="function")throw new TypeError("createTelemetryClient needs the host's signer");if(!n.transport||typeof n.transport.post!="function")throw new TypeError("createTelemetryClient needs the host's transport");if(!n.clock||typeof n.clock.now!="function")throw new TypeError("createTelemetryClient needs the host's clock");if(!t||typeof t.baseUrl!="string"&&typeof t.baseUrl!="function")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof t.baseUrl=="string"&&t.baseUrl==="")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof t.clientVersion!="string"||t.clientVersion==="")throw new TypeError("createTelemetryClient needs the client version");if(typeof t.timeoutMs!="number"||!Number.isFinite(t.timeoutMs)||t.timeoutMs<=0)throw new TypeError("createTelemetryClient needs a positive deadline in milliseconds");let{signer:o,transport:a,clock:u}=n,l=t.apiPath??"/api",i=t.timeoutMs,h=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,C=g=>{try{t.onFailure?.(g)}catch{}},y=async(g,f,c,p)=>{let b;try{let T=await a.post(f,c,p,{timeoutMs:i});b=T.status;try{T.body?.cancel().catch(()=>{})}catch{}}catch(T){C({channel:g,stage:"post",status:null,error:T});return}(b<200||b>299)&&C({channel:g,stage:"status",status:b,error:null})};return{async sendClientMessage(g){let f,c,p;try{f=`${h()}${l}/LogClientMsg/?nocache=${u.now()}`,c=I(g),p=D(c,o)}catch(b){C({channel:"client-message",stage:"build",status:null,error:b});return}await y("client-message",f,c,{"Content-Type":"text/plain","X-Signature":p})},async countEvent(g,f,c){let p,b;try{p=`${h()}${l}/eventlog`,b=se(g,t.clientVersion,f,c)}catch(T){C({channel:"event-count",stage:"build",status:null,error:T});return}await y("event-count",p,b,{"Content-Type":"text/plain"})}}}var Ae=2**31-1;function Me(e){return Object.assign(new Error(`The request did not finish within ${e} ms.`),{name:"TimeoutError"})}function Hr(e){return typeof e=="number"&&e>0&&e<=Ae?null:new RangeError(`fetchTransport cannot keep a deadline of ${String(e)} ms: it must be a number of milliseconds above 0 and at most ${Ae} (about 24.8 days), the longest a timer can wait. Nothing was sent.`)}function Kr(e,t={}){if(typeof e!="function")throw new TypeError("fetchTransport needs the host's fetch");let n=e,o=t.credentials??"omit";return{async post(a,u,l,i){let h=i.timeoutMs,C=Hr(h);if(C)throw C;let y=new AbortController,g=!1,f=setTimeout(()=>{g=!0,y.abort(Me(h))},h),c=()=>y.abort(i.signal?.reason);i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c,{once:!0}));let p=!1,b=()=>{p||(p=!0,clearTimeout(f),i.signal?.removeEventListener("abort",c))},T=_=>g?Me(h):_,L;try{L=await n(a,{method:"POST",body:u,headers:l,credentials:o,signal:y.signal})}catch(_){throw b(),T(_)}let R=X(L),A=R.statusText!==void 0?{statusText:R.statusText}:{};if(!R.body)return{status:R.status,...A,contentType:R.contentType,body:null,text:async()=>{try{return await R.text()}catch(_){throw T(_)}finally{b()}}};let x=R.body.getReader(),w=new ReadableStream({async pull(_){try{let s=await x.read();if(s.done){b(),_.close();return}_.enqueue(s.value)}catch(s){b(),_.error(T(s))}},cancel(_){return b(),x.cancel(_)}});return{status:R.status,...A,contentType:R.contentType,body:w,text:()=>new Response(w).text()}}}}var Ie=300,Br="/LLMChart/",jr="/LLMChart/qualify",Yr="/VisionReview/",Qr="/LLMChart/sample",Xr="/RefundGenerate/",Jr=e=>!!e&&typeof e=="object"&&e.name==="TimeoutError",H=async e=>JSON.parse(await e.text());function Zr(e){try{e.body?e.body.cancel().catch(()=>{}):e.text().catch(()=>{})}catch{}}function eo(e,t){let n=e;if(!n||!n.signer||typeof n.signer.sign!="function")throw new TypeError("createGenerateClient needs the host's signer");if(!n.transport||typeof n.transport.post!="function")throw new TypeError("createGenerateClient needs the host's transport");if(!n.clock||typeof n.clock.now!="function")throw new TypeError("createGenerateClient needs the host's clock");if(!t||typeof t.baseUrl!="string"&&typeof t.baseUrl!="function")throw new TypeError("createGenerateClient needs the service's base URL");if(typeof t.baseUrl=="string"&&t.baseUrl==="")throw new TypeError("createGenerateClient needs the service's base URL");if(t.apiPath!==void 0&&typeof t.apiPath!="string")throw new TypeError("createGenerateClient's apiPath must be a string");if(t.nocache!==void 0&&t.nocache!==null&&typeof t.nocache!="function")throw new TypeError("createGenerateClient's nocache must be a function");let{signer:o,transport:a,clock:u}=n,l=t.apiPath??"/api",i=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,h=g=>t.nocache?t.nocache(g):String(u.now());async function C(g,f,c,p,b){let T=`${i()}${l}${f}?nocache=${h(g)}`,L={"Content-Type":"text/plain","X-Signature":D(c,o)},R=p.signal??void 0,A=(w,_)=>{let s=!!R?.aborted;return{kind:"transport",headersReceived:w,timedOut:!s&&Jr(_),cancelled:s,error:_}},x;try{x=await a.post(T,c,L,R?{timeoutMs:p.timeoutMs,signal:R}:{timeoutMs:p.timeoutMs})}catch(w){return A(!1,w)}if(x.status<200||x.status>299){let w="";if(p.readErrorBody===!1)Zr(x);else try{w=(await x.text()).slice(0,Ie)}catch{}return{kind:"http",status:x.status,statusText:x.statusText??"",bodyStart:w}}try{return{kind:"answer",status:x.status,value:await b(x)}}catch(w){return A(!0,w)}}function y(g,f){if(!f||typeof f.timeoutMs!="number"||!Number.isFinite(f.timeoutMs)||f.timeoutMs<=0)throw new TypeError(`The ${g} call needs a positive deadline in milliseconds`);return f}return{async generate(g,f){let c=y("generate",f),p=c.onStage??void 0;return C("generate",Br,I(g),c,b=>J(b,p))},async qualify(g,f){let c=y("qualify",f),p=c.route??jr;if(typeof p!="string"||!p.startsWith("/"))throw new TypeError("The qualify route must start with '/'");return C("qualify",p,I(g),c,H)},async review(g,f){let c=y("review",f),p=JSON.stringify(g);if(typeof p!="string")throw new TypeError("The review wire did not serialize to JSON");return C("review",Yr,p,c,H)},async sample(g,f){let c=y("sample",f);return C("sample",Qr,I(g),c,H)},async refund(g,f){let c=y("refund",f);if(typeof g!="string"||g.trim()==="")throw new TypeError("A refund needs the generation's correlation id");return C("refund",Xr,JSON.stringify({CorrelationID:g.trim()}),c,H)}}}export{Y as CITY_ROLE_MATCH_PCT,Gr as CLIENT_EVENT_KINDS,pr as CLIENT_SECRET_MISMATCH,Be as COMPOUND_MIN_STEM,dt as CYCLE_MEMBERS,ft as CYCLE_WORDS,ge as DATE_LEVEL_GREGORIAN_YEAR_MAX,pe as DATE_LEVEL_GREGORIAN_YEAR_MIN,Jn as DATE_LEVEL_LANGUAGES,ie as DATE_LEVEL_NAMES,fe as DATE_LEVEL_NON_GREGORIAN_LANGUAGES,xn as DEFAULT_GAP_FACTOR,ot as DEFAULT_TEMPERATURE,Vr as DRAW_REASONS,fr as FREEMIUM_ATTEMPT_SPENT,gr as FREEMIUM_COLUMN_CAP,nt as GET_RANDOM,Ye as GLUED_STEM_MIN,Xe as HANGUL_MIN_STEM,be as HOST_SYNTHETIC_COLUMNS,Ie as HTTP_BODY_START_CHARS,Cn as IDENTIFIER_HEAD_INITIAL,bn as IDENTIFIER_UNFOLDED,hn as IDENTIFIER_WORDS,tn as INTENSIVE_SUFFIX_TOKENS,en as INTENSIVE_WORD_TOKENS,Un as IndexedText,xt as LOOSE_KEY_MIN_LENGTH,_t as LooseIndex,wn as MAX_RUN_BOUNDS,hr as OAUTH_SIGNED_OUT,yr as OAUTH_TOKEN_EXPIRED,Ct as PERIOD_CODE_FORMS,ht as PERIOD_CODE_MEMBERS,bt as PERIOD_ORDINALS,Et as PERIOD_UNFOLDED,rn as POSITIONAL_SUFFIX_TOKENS,nn as POSITIONAL_WORD_TOKENS,zn as PREVIEW_OMITTED_FIELDS,we as PROGRESS_STAGE_IDS,Or as QUALIFY_ORDER_LABELS,M as ROLE_MATCH_PCT,vn as SERIES_COMPLETENESS_MAX_LISTED,Pn as SERIES_COMPLETENESS_MIN_FILL,Ln as SERIES_KEY_MAX_DISTINCT,Nr as SEV_ERROR,Mr as SEV_INFO,Fr as SEV_USER_PRESENTED,Ir as SEV_WARNING,j as SIMPLE_STRING_HASH,tt as STR,Ze as SUBSTRING_MIN,Fe as SUPPORTED_LANGUAGES,De as SUPPORTED_LANGUAGE_CODES,kr as TELEMETRY_TIMEOUT_DEV_MS,Dr as TELEMETRY_TIMEOUT_MS,Ve as VOCABULARY_LANGUAGE_CODES,Ge as VOCABULARY_ONLY_LANGUAGES,mt as YEAR_WORDS,$ as admin1MatchPct,fn as allowedAggregations,Cr as answerIsRetryable,$t as buildGeoIsoColumn,kt as buildGeoPointColumns,pt as calendarWordIn,Rr as capabilityFields,Vt as cityMatchPct,Gt as cityTagsFor,Gn as classifyAdditivity,Wr as classifyDraw,mn as classifyForAggregation,Vn as classifyNumericValueNature,Dn as classifyTemporal,ln as codeNeedsLegacyAggNames,Tn as codeReadsColumn,Sn as codeReadsColumnsByRoleOrPosition,an as collapseRepeatedAggPrefix,Rn as columnsTheCodeReads,Kt as countryRegion,qr as createDrawLedger,eo as createGenerateClient,zr as createTelemetryClient,br as credentialFields,_r as dataCompletenessFields,er as dateLevelPart,tr as dateLevelYearAdmits,Yt as decimalSeparatorOf,pn as defaultAggregation,Qt as detectDecimalSeparator,jt as detectFormatSignature,Ut as detectGeo,Pt as detectOrdinalDomain,Fn as detectTextDatePattern,Ur as drawLocation,I as encodePayload,Wn as engineTypeForSqlType,un as englishImplicitAggNames,se as eventLogLine,Sr as fetchFields,Kr as fetchTransport,We as foldName,sr as freemiumColumnCapRefusal,Ee as freemiumColumnsOverCap,Te as freemiumDateHierarchyClauses,Qe as gluedPrefixStems,ir as guardColumnNames,Kn as gzipWireText,Je as hangulWordEndsWith,sn as hasDefaultAggPrefix,He as hasUnsegmentedScript,kn as hostAggHint,$n as ingest,gn as isAggregationAllowed,V as isBlankLike,At as isCityTableLoaded,z as isColumnContextRef,rt as isDeterministicRefusal,$r as isEventLogCode,Ft as isGeoPointAmbiguity,Nn as isIdentifierName,qt as isJoinGeoKind,jn as isNdjsonContentType,Ot as isOrdinalFriendlyName,wt as isUsableLooseKey,Bn as keyedSigner,wr as leafCardinalityField,ut as localMidnightDateColumns,lt as localMidnightToUtcDay,yt as localizedCycleIn,En as localizedIdentifierWordIn,gt as localizedYearWordIn,N as looksLikeCountryColumn,Rt as looseNameKey,et as matchNameToken,Tr as maxNonMeasureCardinality,On as measureCadence,In as measureSeriesCompleteness,D as messageSignature,or as missingHardColumnRefs,Zt as monthLookupFor,$e as nameLetterRuns,dn as nameLooksIntensiveRate,cn as nameLooksPositional,he as nameProbeIsGuarded,rr as nameProbeKeepsDrawing,qe as nameWords,Mt as normalizeCountry,ct as normalizeLocalMidnightDates,Jt as normalizeMonthKey,U as normalizePlaceName,Nt as normalizeZip5,Pr as offeredShortlistFor,qn as parseCsvRows,it as parseDateStable,ur as parseGenerateResponse,Xt as parseNumberText,cr as parseQualifyResponse,dr as parseReviewVerdict,_n as parseTemporalPoint,Hn as payloadPreview,St as periodCodeSeries,Mn as pickSeriesColumn,mr as progressStageOf,vr as qualifyOrderField,Oe as qualifyOrderOf,J as readGenerateStream,ze as readName,Tt as readPeriodCode,E as readWireField,Lt as registerCityTable,Ht as registerIso3Regions,v as resolveAdmin1,_e as resolveFetchVersion,Dt as resolveGeoPoint,Ue as resolveLanguage,Xn as resolvePointRoles,xr as retryFields,vt as safeDistinctValuesToShip,Le as schemaIdentity,Ar as schemaIdentityKey,Pe as schemaTypeFamily,An as seriesKeyVerdict,yn as shareOfTotalIsHonest,ve as shortlistIsStale,on as stripHostAggPrefix,Bt as summarizeCountryRegions,zt as summarizeGeoExtent,ke as supportedLanguage,Wt as toGeoIso,Ke as unsegmentedRuns,Er as viewportFields,B as vocabularyLanguage,st as wholeDayFrame,at as wholeDayIso,X as wireResponseFromFetch,je as wordEndsWith,re as zipMatchPct,q as zipPrefixCandidates,It 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{M as a,N as b,O as c,P as d,Q as e,R as f,S as g,T as h}from"./chunk-KMAKCPZX.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-A4PQBWRA.mjs";import"./chunk-QPIKC2O6.mjs";import"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-IIGGO4ES.mjs";import"./chunk-NT6CDI3K.mjs";import"./chunk-WC4JINEZ.mjs";import"./chunk-5HI6TVMM.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{M as a,N as b,O as c,P as d,Q as e,R as f,S as g,T as h}from"./chunk-AQ2WZ4TT.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-A4PQBWRA.mjs";import"./chunk-QPIKC2O6.mjs";import"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-IIGGO4ES.mjs";import"./chunk-NT6CDI3K.mjs";import"./chunk-WC4JINEZ.mjs";import"./chunk-5HI6TVMM.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{a,b,c}from"./chunk-UP2L3X76.mjs";import"./chunk-KMAKCPZX.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-A4PQBWRA.mjs";import"./chunk-QPIKC2O6.mjs";import"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-IIGGO4ES.mjs";import"./chunk-NT6CDI3K.mjs";import"./chunk-WC4JINEZ.mjs";import"./chunk-5HI6TVMM.mjs";export{a as engineTypeForSqlType,c as ingest,b as parseCsvRows};
2
+ import{a,b,c}from"./chunk-D5DKZQJT.mjs";import"./chunk-AQ2WZ4TT.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-A4PQBWRA.mjs";import"./chunk-QPIKC2O6.mjs";import"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-IIGGO4ES.mjs";import"./chunk-NT6CDI3K.mjs";import"./chunk-WC4JINEZ.mjs";import"./chunk-5HI6TVMM.mjs";export{a as engineTypeForSqlType,c as ingest,b as parseCsvRows};
@@ -8,7 +8,7 @@ export { measureSeriesCompleteness, pickSeriesColumn, seriesKeyVerdict, SERIES_C
8
8
  export type { SeriesCompleteness, SeriesCoverage, SeriesKeyCandidate, SeriesKeyVerdict, } from "./seriesCompleteness";
9
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";
10
10
  export type { AggKind, AggAdditivity, AggBasis, AggNature, AggregationClass, AggregationColumn, } from "./aggregation";
11
- export type { LLMColumnWithValue } from "./models";
11
+ export type { LLMColumnWithValue, TwoSetPairing, ScoreSeparationEntry } from "./models";
12
12
  export type { LLMRequestModifier, SimpleColumn, VegaRendererPayload, LLMClientHints, LLMRequestCode, LLMQualifyResult, LLMRequestCodeResult, LLMResultNotice, GetLicenseStatusResult, } from "./models";
13
13
  export { ROLE_MATCH_PCT, CITY_ROLE_MATCH_PCT, isBlankLike } from "./matchQuality";
14
14
  export { detectOrdinalDomain, safeDistinctValuesToShip, isOrdinalFriendlyName } from "./ordinalDetector";
@@ -57,8 +57,8 @@ export { parseGenerateResponse, parseQualifyResponse, parseReviewVerdict } from
57
57
  export type { ParsedGenerateResponse, ParsedQualifyResponse, ParsedQualifyChart, ParsedQualifyRefusal, ParsedReviewVerdict, ParsedNotice, WirePointBinding, WirePointColumns, } from "./wireParse";
58
58
  export { PROGRESS_STAGE_IDS, progressStageOf, FREEMIUM_ATTEMPT_SPENT, CLIENT_SECRET_MISMATCH, FREEMIUM_COLUMN_CAP, OAUTH_TOKEN_EXPIRED, OAUTH_SIGNED_OUT, answerIsRetryable, } from "./messageCodes";
59
59
  export type { ProgressStageId } from "./messageCodes";
60
- export { viewportFields, maxNonMeasureCardinality, credentialFields, resolveFetchVersion, fetchFields, capabilityFields, retryFields, leafCardinalityField, qualifyOrderOf, qualifyOrderField, QUALIFY_ORDER_LABELS, shortlistIsStale, offeredShortlistFor, } from "./wireBuild";
61
- export type { ViewportFields, CredentialFields, FetchRequest, FetchFields, CapabilityFields, RetryFields, QualifyOrder, } from "./wireBuild";
60
+ export { viewportFields, maxNonMeasureCardinality, credentialFields, resolveFetchVersion, fetchFields, capabilityFields, retryFields, leafCardinalityField, dataCompletenessFields, qualifyOrderOf, qualifyOrderField, QUALIFY_ORDER_LABELS, shortlistIsStale, offeredShortlistFor, } from "./wireBuild";
61
+ export type { ViewportFields, CredentialFields, FetchRequest, FetchFields, CapabilityFields, RetryFields, QualifyOrder, DataCompletenessFields, } from "./wireBuild";
62
62
  export { schemaIdentity, schemaIdentityKey, schemaTypeFamily } from "./schemaIdentity";
63
63
  export type { SchemaIdentityColumn } from "./schemaIdentity";
64
64
  export { SEV_INFO, SEV_WARNING, SEV_ERROR, SEV_USER_PRESENTED, CLIENT_EVENT_KINDS, isEventLogCode, eventLogLine, TELEMETRY_TIMEOUT_MS, TELEMETRY_TIMEOUT_DEV_MS, DRAW_REASONS, drawLocation, classifyDraw, createDrawLedger, } from "./telemetry";
@@ -164,6 +164,8 @@ export declare class IndexedText implements IValueCollection {
164
164
  private wholeDayIso;
165
165
  private hasTimeComponent;
166
166
  getColumnsWithStats(privacyLevel: string, locale?: string): LLMColumnWithValue[];
167
+ private applyTwoSetPairing;
168
+ private applyScoreSeparation;
167
169
  private applySeriesCompleteness;
168
170
  private updateColumnStats20;
169
171
  private updateColumnStats10;
@@ -17,6 +17,76 @@ export type VegaRendererPayload = {
17
17
  vegaMode: string;
18
18
  configSpec?: string;
19
19
  };
20
+ /**
21
+ * TWO-SET PAIRING, long form (2026-10-09): the table holds the SAME RECORDS TWICE, once per set, and one
22
+ * column identifies the record. `key` names that column and `discriminator` names the column with exactly
23
+ * two non-blank values that says which set a row belongs to; both columns carry this one object.
24
+ *
25
+ * Counts, one integer percentage, two column names and an enum - never a value - so it ships at every
26
+ * privacy tier. A = the discriminator's FIRST value in `setOrder`; B = the other.
27
+ *
28
+ * Measured on the rows the engine holds. The visual and the chart MCP collapse byte-for-byte duplicate
29
+ * rows before the engine sees them, so a row repeated exactly inside one set is invisible to the
30
+ * duplicate counts; a key repeated with ANY differing value is counted.
31
+ */
32
+ export type TwoSetPairing = {
33
+ /** "wide" is reserved for the chart's own build. */
34
+ form: "long";
35
+ key: string;
36
+ discriminator: string;
37
+ /** Distinct keys present in set A / set B / both sets. A row with a blank key joins no key. */
38
+ keysA: number;
39
+ keysB: number;
40
+ keysBoth: number;
41
+ /** Keys appearing in two or more rows of that set. > 0 means the key is NOT unique per record. */
42
+ duplicateKeysA: number;
43
+ duplicateKeysB: number;
44
+ /**
45
+ * Integer 0-100: the share of `keysBoth` whose every COMPARED field is equal (every column but the
46
+ * key and the discriminator). Text is compared on the trimmed cell, numbers as numbers and exactly,
47
+ * a blank equals a blank. A key repeated inside a set is compared by its first row there. 100 only
48
+ * when every key in both sets is identical, and 0 only when none is, however the share rounds.
49
+ */
50
+ identicalPct: number;
51
+ /** Rows whose discriminator cell is blank: they belong to neither set (never a third set). */
52
+ discriminatorBlankRows: number;
53
+ /**
54
+ * Keys of that set that merge with another key of the SAME set under `looseNameKey` (case,
55
+ * punctuation and accents ignored), counted as the keys involved. A loose form under four characters
56
+ * is a code and is never merged.
57
+ */
58
+ looseCollisionsA: number;
59
+ looseCollisionsB: number;
60
+ /**
61
+ * How A was chosen. "temporal": the discriminator is a time column whose two values read as calendar
62
+ * points, and A is the earlier. "none": A is the alphabetically first value (UTF-16 order of the
63
+ * cell text), the fallback for any other column and for a time column whose values do not read as
64
+ * calendar points ("Jan" / "Feb" alone carry no year, so they order as text).
65
+ */
66
+ setOrder: "temporal" | "none";
67
+ };
68
+ /**
69
+ * SCORE SEPARATION (2026-10-09), one entry per yes/no outcome a numeric column could rank. The statistic
70
+ * is the area under the ROC curve with the RARER outcome value as the positive class and a HIGHER score
71
+ * as the positive direction, so no outcome value ever ships: a consumer that knows the class it flags for
72
+ * reads `1 - aucMinorityHigh` when that is the other value, and `1 - auc` again when lower scores point at
73
+ * it. Scores tied across the two classes count half. An exact tie of the two class counts takes the
74
+ * alphabetically first value (UTF-16 order of the cell text) as the rare one.
75
+ *
76
+ * Counts, a count of tied rows and a probability rounded to four places, with the outcome's column name:
77
+ * never a value, so it ships at every privacy tier.
78
+ */
79
+ export type ScoreSeparationEntry = {
80
+ /** The outcome column's name. */
81
+ outcome: string;
82
+ /** AUC, rare value positive, higher score positive. 4 decimal places. */
83
+ aucMinorityHigh: number;
84
+ /** Rows of the rarer / the commoner outcome value that carry a score. */
85
+ nMinority: number;
86
+ nMajority: number;
87
+ /** Rows that share their score with at least one other row, among the rows counted above. */
88
+ ties: number;
89
+ };
20
90
  export type LLMColumnWithValue = {
21
91
  name: string;
22
92
  hostName?: string;
@@ -81,6 +151,8 @@ export type LLMColumnWithValue = {
81
151
  total: number;
82
152
  matchedPct: number;
83
153
  };
154
+ twoSetPairing?: TwoSetPairing;
155
+ scoreSeparation?: ScoreSeparationEntry[];
84
156
  relativeDispersion?: number;
85
157
  groupDiscrimination?: {
86
158
  otherColumn: string;
@@ -119,6 +191,9 @@ export type LLMClientHints = {
119
191
  pyEnvFailedBefore?: boolean;
120
192
  pyProbeOk?: boolean;
121
193
  leafCardinality?: number;
194
+ dataComplete?: boolean;
195
+ rowsWithheld?: number;
196
+ rowsFilteredOut?: number;
122
197
  randomSeed?: number;
123
198
  favorTitle?: string;
124
199
  legendPlacement?: string;
@@ -0,0 +1,37 @@
1
+ import type { ScoreSeparationEntry } from "./models";
2
+ /** Above this many rows nothing is computed or emitted. */
3
+ export declare const SCORE_SEPARATION_MAX_ROWS = 500000;
4
+ /** Outcome candidates examined: the flagged ones first, then any other two-valued column, in column order. */
5
+ export declare const SCORE_SEPARATION_MAX_OUTCOMES = 6;
6
+ /** Score candidates examined, in column order. */
7
+ export declare const SCORE_SEPARATION_MAX_SCORES = 12;
8
+ /** A score needs this many distinct values; two make a second flag and not a ranking. */
9
+ export declare const SCORE_SEPARATION_MIN_DISTINCT = 3;
10
+ /** What the pass needs to know about one column. The caller builds these from its own column stats. */
11
+ export interface ScoreSeparationColumn {
12
+ name: string;
13
+ dataType: string;
14
+ isMeasure: boolean;
15
+ isTemporal: boolean;
16
+ isDatePart: boolean;
17
+ identifierNamed: boolean;
18
+ /** The engine's yes/no flag test, including a numeric column whose values are exactly 0 and 1. */
19
+ isBinaryFlag: boolean;
20
+ /** Distinct non-blank values, as the engine counted them. */
21
+ distinct: number;
22
+ /** The column's two non-blank values as text when it has exactly two, else null. */
23
+ twoValues: readonly [string, string] | null;
24
+ }
25
+ export interface ScoreSeparationInput {
26
+ rows: ReadonlyArray<ReadonlyArray<any>>;
27
+ columns: ReadonlyArray<ScoreSeparationColumn>;
28
+ /** The engine's cell-to-text rule, so an outcome cell reads here exactly as it did when the columns were measured. */
29
+ text: (cell: any) => string;
30
+ /** Row ceiling; the default is SCORE_SEPARATION_MAX_ROWS. */
31
+ maxRows?: number;
32
+ }
33
+ /**
34
+ * The separation entries per score column: a map from the score's column index to one entry per outcome it
35
+ * could be measured against. A column with no measurable outcome has no key. Empty above the row ceiling.
36
+ */
37
+ export declare function measureScoreSeparation(input: ScoreSeparationInput): Map<number, ScoreSeparationEntry[]>;
@@ -0,0 +1,43 @@
1
+ import type { TwoSetPairing } from "./models";
2
+ /** Above this many rows nothing is computed or emitted. */
3
+ export declare const TWO_SET_PAIRING_MAX_ROWS = 500000;
4
+ /** Key candidates examined, ranked as described above. */
5
+ export declare const TWO_SET_PAIRING_MAX_KEYS = 8;
6
+ /** Set candidates examined, in column order. */
7
+ export declare const TWO_SET_PAIRING_MAX_SETS = 4;
8
+ /** A key needs at least this many distinct non-blank values; fewer is a category. */
9
+ export declare const TWO_SET_PAIRING_MIN_KEY_DISTINCT = 5;
10
+ /** What the pass needs to know about one column. The caller builds these from its own column stats. */
11
+ export interface TwoSetColumn {
12
+ name: string;
13
+ /** The column's distinct NON-BLANK values as text, when the engine kept them (a dimension of at most
14
+ * 2,000 distinct values); null otherwise. Exactly two entries is what makes a set candidate. */
15
+ values: ReadonlySet<string> | null;
16
+ /** Distinct non-blank values: `values.size` when kept, else the column's own count. */
17
+ distinct: number;
18
+ isMeasure: boolean;
19
+ isTemporal: boolean;
20
+ isDatePart: boolean;
21
+ identifierNamed: boolean;
22
+ /** The strptime pattern of a date stored as text, when the engine detected one. */
23
+ temporalTextPattern?: string;
24
+ }
25
+ export interface TwoSetInput {
26
+ rows: ReadonlyArray<ReadonlyArray<any>>;
27
+ columns: ReadonlyArray<TwoSetColumn>;
28
+ /** The engine's cell-to-text rule, so a cell reads here exactly as it did when the columns were measured. */
29
+ text: (cell: any) => string;
30
+ locale?: string;
31
+ }
32
+ export interface TwoSetResult {
33
+ /** Index of the key column. */
34
+ key: number;
35
+ /** Index of the discriminator column. */
36
+ discriminator: number;
37
+ pairing: TwoSetPairing;
38
+ }
39
+ /**
40
+ * The best (key, discriminator) pairing of a table's rows, or null when nothing qualifies. See the header
41
+ * for the search, the winner rule and the ceiling.
42
+ */
43
+ export declare function measureTwoSetPairing(input: TwoSetInput): TwoSetResult | null;
@@ -207,6 +207,28 @@ export declare function retryFields(p: {
207
207
  export declare function leafCardinalityField(count: number | null | undefined): {
208
208
  leafCardinality?: number;
209
209
  };
210
+ /** The completeness fields a request's client hints carry. Each is absent when the host does not know it. */
211
+ export interface DataCompletenessFields {
212
+ dataComplete?: boolean;
213
+ rowsWithheld?: number;
214
+ rowsFilteredOut?: number;
215
+ }
216
+ /**
217
+ * WHETHER EVERY ROW ARRIVED, AS THE REQUEST STATES IT - the client hints' `dataComplete`, `rowsWithheld`
218
+ * and `rowsFilteredOut`.
219
+ * - `dataComplete` is false when rows the reader did not choose to remove never reached the chart: a row
220
+ * cap, a load that stalled, a host memory ceiling, a query limit. A filter the reader applied (a slicer,
221
+ * a sheet filter) is their view of the data, not a cut, and never lowers it.
222
+ * - `rowsWithheld` is how many rows such a cut left out, sent only when the host knows the exact number.
223
+ * - `rowsFilteredOut` is how many rows the reader's own filter hides inside the bound range, kept apart
224
+ * from the cut so a chart can say so without the cut's warning.
225
+ *
226
+ * ABSENT MEANS UNKNOWN, NEVER TRUE: a server that reads a missing `dataComplete` as "complete" would call
227
+ * a cut table whole, so the host says nothing unless it knows. Only a boolean is a statement about
228
+ * completeness, and a count travels only when it is a whole number above zero - a zero, a fraction or a
229
+ * non-number says nothing the absence did not. Spread where the host builds its hints.
230
+ */
231
+ export declare function dataCompletenessFields(complete?: boolean | null, withheld?: number | null, filteredOut?: number | null): DataCompletenessFields;
210
232
  /** The order of the "what fits" list: by how well each type suits the data, or by the picker's selection order. */
211
233
  export type QualifyOrder = "fit" | "variety";
212
234
  /** The two orders' reader-facing names, for any host's control. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/shape-core",
3
- "version": "0.6.83",
3
+ "version": "0.6.84",
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 ce}from"./chunk-U3H6UBOO.mjs";import{a as Ze,f as Z,g as me,h as te,i as de,j as ee}from"./chunk-A4PQBWRA.mjs";import{c as Xe}from"./chunk-QPIKC2O6.mjs";import{f as Ye,k as je}from"./chunk-INMDBTAR.mjs";import{e as Ve,k as ue,m as He,n as Ke,o as le}from"./chunk-IIGGO4ES.mjs";import{a as oe,b as X,c as ke,d as ae,g as Oe,h as Pe,j as Fe,l as Ge,m as We,o as ze,p as Y,q as $e,r as Be,u as xe,w as Ue}from"./chunk-NT6CDI3K.mjs";import{c as Le,f as Se}from"./chunk-WC4JINEZ.mjs";var Lt=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],kt=[7,72,-172,-52];function qe(t,e,n){return t>=n[0]&&t<=n[1]&&e>=n[2]&&e<=n[3]}var q=t=>Math.round(t*10)/10;function Je(t,e=3){let n=[],i=[],s=0,r=0;for(let u of t){let o=u?.lat,f=u?.lon;if(typeof o!="number"||typeof f!="number"||!isFinite(o)||!isFinite(f)||o<-90||o>90||f<-180||f>180)continue;n.push(o),i.push(f);let g=u?.country?String(u.country).trim().toUpperCase():"",m=g?fe(g):null;m?((g==="US"||g==="USA")&&s++,m==="north-america"&&r++):(Lt.some(c=>qe(o,f,c))&&s++,qe(o,f,kt)&&r++)}let a=n.length;return a<e?null:(n.sort((u,o)=>u-o),i.sort((u,o)=>u-o),{pctUsa:q(s/a*100),pctNa:q(r/a*100),latP5:q(Y(n,.05)),latP95:q(Y(n,.95)),lonP5:q(Y(i,.05)),lonP95:q(Y(i,.95)),n:a})}var Qe={"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"},ne=(()=>{let t=new Map;for(let e of Object.keys(Qe))for(let n of Qe[e].split(/\s+/))n&&t.set(n,e);return t})();function Ot(t){for(let[e,n]of t){let i=ne.get(e);i&&!ne.has(n)&&ne.set(n,i)}}Ot(Ye);function fe(t){if(!t)return null;let e=String(t).trim().toUpperCase();if(!e)return null;let n=ne.get(e);if(n)return n;let i=je(String(t));return i?ne.get(i)??null:null}function Tr(t,e=2){return _e(t.map(n=>[n,1]),e)}function _e(t,e=2){let n=new Map,i=0;for(let[a,u]of t){let o=fe(a);if(!o)continue;let f=typeof u=="number"&&isFinite(u)&&u>0?u:1;n.set(o,(n.get(o)??0)+f),i+=f}if(i<e||!n.size)return null;let s="europe",r=-1;for(let a of Array.from(n.keys()).sort()){let u=n.get(a);u>r&&(s=a,r=u)}return{dominantGeoRegion:s,dominantGeoRegionPct:q(r/i*100),regionCount:n.size,n:i}}function Me(t){let e=(t||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}var Ce={a:0,b:0,c:0,yearFirst:!1,sep:"",trail:"",word:"",day:0,year:0,namedOrder:"dmy",cjkPattern:""},Pt=/\s+(\d{1,2}):(\d{2})(?::(\d{2})(?:[.,]\d{1,9})?)?(?:\s*([ap])\.?\s?m\.?)?$/i,Ft=/^(\d{1,4})(\s*[./-]\s*)(\d{1,2})(\s*[./-]\s*)(\d{1,4})(\.?)$/,Gt=/^(\d{4})(\s*[年년]\s*)(\d{1,2})(\s*[月월]\s*)(\d{1,2})(\s*[日일号])$/,Wt=/(\d)(?:st|nd|rd|th|er|º|ª)(?=[\s.,/-]|$)/gi,zt=new Set(["de","del","of"]),$t=new Set(["\u0433","\u0440","r"]),Bt=/^[\p{L}\p{M}\u0970\u05f3]+$/u,Ae=/^\d+$/;function Ut(t){let e=+t[1],n=+t[2],i=t[3]===void 0?0:+t[3],s=t[4]!==void 0;if(n>59||i>59)return null;if(s){if(e<1||e>12)return null;e=e%12+(t[4].toLowerCase()==="p"?12:0)}else if(e>23)return null;return{h:e,mi:n,s:i,seconds:t[3]!==void 0,meridiem:s}}function et(t){let e=t.replace(/[\u200e\u200f\u061c]/g,"").replace(/\s+/g," ").trim();if(e==="")return null;e=Ze(e);let n=null,i=Pt.exec(e);if(i){if(n=Ut(i),!n)return null;e=e.slice(0,i.index)}let s;if(s=Gt.exec(e)){let c=`cjk|${s[2]}|${s[4]}|${s[6]}`;return{...Ce,form:"cjk",key:c,clock:n,a:+s[1],b:+s[3],c:+s[5],yearFirst:!0,cjkPattern:`%Y${s[2]}%m${s[4]}%d${s[6]}`}}if(s=Ft.exec(e)){let c=s[2],_=s[4];if(c!==_)return null;let b=c.trim(),L=s[6];if(L&&b!==".")return null;let p=[s[1].length,s[3].length,s[5].length],d=p[0]===4,h=p[2]===4;return d===h||(d?p[1]>2||p[2]>2:p[0]>2||p[1]>2)?null:d&&b==="-"&&c==="-"&&p[1]===2&&p[2]===2?"iso":d&&b==="."&&c==="."&&!L&&!(p[1]===2&&p[2]===2)?null:{...Ce,form:"numeric",key:`num|${d?"y":"x"}|${c}|${L}`,clock:n,a:+s[1],b:+s[3],c:+s[5],yearFirst:d,sep:c,trail:L}}let r=e.replace(Wt,"$1").split(/[\s.,/-]+/).filter(c=>c!==""&&!zt.has(c.toLowerCase()));if(r.length===4&&Ae.test(r[2])&&$t.has(r[3].toLowerCase())&&r.pop(),r.length!==3)return null;let a=r.map(c=>Ae.test(c)?"N":Bt.test(c)?"W":"?").join(""),u=r.map(c=>Ae.test(c)?c:""),o=0,f=0,g="",m;if(a==="NWN"&&u[0].length<=2&&u[2].length===4)o=+u[0],g=r[1],f=+u[2],m="dmy";else if(a==="WNN"&&u[1].length<=2&&u[2].length===4)g=r[0],o=+u[1],f=+u[2],m="mdy";else if(a==="NWN"&&u[0].length===4&&u[2].length<=2)f=+u[0],g=r[1],o=+u[2],m="ymd";else return null;return{...Ce,form:"named",key:`named|${m}`,clock:n,day:o,year:f,word:g,namedOrder:m}}var Vt=[31,28,31,30,31,30,31,31,30,31,30,31],Ht=t=>t%4===0&&t%100!==0||t%400===0;function tt(t,e,n){return t>=1&&t<=9999&&e>=1&&e<=12&&n>=1?n<=(e===2&&Ht(t)?29:Vt[e-1]):!1}function Kt(t,e,n,i){let s=new Date(Date.UTC(2e3,e-1,n,i?.h??0,i?.mi??0,i?.s??0));return s.setUTCFullYear(t),s}function nt(t,e={}){let n=(e.floor??1)>=1,i=new Map,s=new Map,r=0,a=null;for(let d of t){if(d==null)continue;if(typeof d!="string"){if(n)return null;r++;continue}let h=d.trim();if(h==="")continue;r++;let C=i.get(h);if(C===void 0&&(C=et(h),i.set(h,C)),C===null||C==="iso"){if(n)return null;continue}if(n){if(a===null)a=C;else if(C.key!==a.key)return null}else s.set(C.key,(s.get(C.key)??0)+1)}if(!n){let d=0,h="";for(let[C,M]of s)M>d&&(d=M,h=C);if(d===0||d/r<e.floor)return null;a=[...i.values()].find(C=>C!==null&&C!=="iso"&&C.key===h)??null}if(a===null)return null;let u=a.key,o=[...i.values()].filter(d=>d!==null&&d!=="iso"&&d.key===u),f,g="shape",m=null;if(a.form==="named"){if(f=a.namedOrder,m=de(o.map(d=>d.word),e.locale),!m)return null}else if(a.form==="cjk"||a.yearFirst)f="ymd";else{let d=0,h=0;for(let C of o)C.a>12&&d++,C.b>12&&h++;if(d>0&&h>0)return null;d>0?(f="dmy",g="values"):h>0?(f="mdy",g="values"):a.sep.trim()==="."?(f="dmy",g="shape"):(f=Me(e.locale)?"mdy":"dmy",g="locale")}let c=d=>{if(d.form==="named"){let h=m.get(Z(d.word));return h===void 0?null:[d.year,h+1,d.day]}return d.yearFirst?[d.a,d.b,d.c]:f==="dmy"?[d.c,d.b,d.a]:[d.c,d.a,d.b]},_=1/0,b=-1/0,L=0;for(let d of o){let h=c(d);if(!h||!tt(h[0],h[1],h[2])){if(n)return null;L++;continue}_=Math.min(_,h[0]),b=Math.max(b,h[0])}if(!n&&(s.get(u)-L)/r<e.floor||_>=2400&&b<=2699||_>=1300&&b<=1500)return null;let p={form:a.form,order:f,orderFrom:g,hasTime:o.some(d=>d.clock!==null),read(d){if(typeof d!="string")return null;let h=d.trim();if(h==="")return null;let C=i.get(h);if(C===void 0&&(C=et(h),i.set(h,C)),C===null||C==="iso"||C.key!==u)return null;let M=c(C);return!M||!tt(M[0],M[1],M[2])?null:Kt(M[0],M[1],M[2],C.clock)}};if(a.form!=="named"&&!o.some(d=>d.clock?.meridiem)){let d;a.form==="cjk"?d=a.cjkPattern:a.yearFirst?d=`%Y${a.sep}%m${a.sep}%d${a.trail}`:d=(f==="dmy"?`%d${a.sep}%m${a.sep}%Y`:`%m${a.sep}%d${a.sep}%Y`)+a.trail;let h=o.filter(C=>C.clock!==null).length;h===0?p.pattern=d:h===o.length&&(p.pattern=d+(o.every(C=>C.clock.seconds)?" %H:%M:%S":" %H:%M"))}return p}import Et from"papaparse";var Yt=["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","capita","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","ocupacion","ocupacao","occupazione","auslastung","bezetting","belaggning","belaegning","belegg","kayttoaste","oblozenie","obsazenost","obsadenost","kihasznaltsag","doluluk","ocupare","popunjenost","efficacite","eficiencia","efficienza","effizienz","effectiviteit","verimlilik"],jt=["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"],Xt=["latitude","longitude"],Zt=["latitude","longitude"];function j(t){return oe(t)}var st=["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","sum pa","\u0441\u0443\u043C\u043C\u0430","\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E","\u0441\u0443\u043C\u0430","\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C","\u03B1\u03B8\u03C1\u03BF\u03B9\u03C3\u03BC\u03B1","\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2"],qt=["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","prom.","\u0441\u0440\u0435\u0434\u043D\u0435\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435","\u0441\u0440\u0435\u0434\u043D\u0435\u0435","\u0441\u0435\u0440\u0435\u0434\u043D\u0454","\u03BC\u03B5\u03C3\u03BF\u03C2 \u03BF\u03C1\u03BF\u03C2","\u0645\u06CC\u0627\u0646\u06AF\u06CC\u0646"],Qt=["osszege","sucet","\u7684\u603B\u548C","\u7684\u8BA1\u6570","\u306E\u5408\u8A08","\uC758 \uD569\uACC4"],Jt=["atlaga","priemer","\u7684\u5E73\u5747\u503C","\u306E\u5E73\u5747","\uC758 \uD3C9\uADE0"],ge=Object.freeze({"nombre de":"count","recuento de":"count","contagem de":"count","anzahl von":"count","aantal van":"count","conteggio di":"count","antal av":"count",lukumaara:"count","pocet z":"count",\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E:"count",\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C:"count",\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2:"count",\u7684\u8BA1\u6570:"count","minimum de":"min","minimo de":"min","minimo di":"min","minimum von":"min","maximum de":"max","maximo de":"max","massimo di":"max","maximum von":"max"});function Te(t){return[...t].sort((e,n)=>n.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var ot=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+Te(st)+")\\s+)","i");function rt(t){for(let e of t){let n=e.codePointAt(0)??0;if(n>=11904&&n<=40959||n>=44032&&n<=55215)return!0}return!1}var en="[\u2013\u2014-]";function at(t){let e=t.filter(s=>!rt(s)),n=t.filter(rt),i=[];return e.length&&i.push("(?:\\s+|\\s*"+en+"\\s*)("+Te(e)+")"),n.length&&i.push("\\s*("+Te(n)+")"),new RegExp("(?:"+i.join("|")+")\\s*$","i")}var Re=at(Qt),tn=at(Jt);function pe(t,e){let n=e.exec(t);if(!n)return null;let i=t.slice(0,n.index);return i.trim()===""?null:{base:i,label:(n[1]??n[2]??"").toLowerCase()}}function ut(t){let e=j(String(t??"").trim().toLowerCase());if(!e)return null;for(let s of qt)if(e.startsWith(s+" "))return ge[s]??"avg";for(let s of st)if(e.startsWith(s+" ")||e===s)return ge[s]??"sum";let n=pe(e,tn);if(n)return ge[n.label]??"avg";let i=pe(e,Re);return i?ge[i.label]??"sum":null}var nn=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,rn=new RegExp("\\b("+Yt.join("|")+")\\b|("+jt.join("|")+")$","i"),sn=new RegExp("\\b("+Xt.join("|")+")\\b|("+Zt.join("|")+")$","i");function he(t){if(!t)return"";let e=String(t),n=j(e),i=ot.exec(n);if(i)return e.slice(i[0].length).trim();let s=pe(n,Re);return(s?e.slice(0,s.base.length):e).trim()}function on(t){if(!t)return!1;let e=j(String(t));return ot.test(e)||pe(e,Re)!==null}var an=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],it=new RegExp("^\\s*("+[...an].sort((t,e)=>e.length-t.length).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function lt(t){if(t==null)return"";let e=String(t),n=it.exec(e);if(!n)return e;let i=u=>u.toLowerCase().replace(/\s+/g," ").trim(),s=i(n[1]),r=e.slice(n[0].length),a=0;for(;a<8;){let u=it.exec(r);if(!u||i(u[1])!==s)break;let o=r.slice(u[0].length);if(o.trim()==="")break;r=o,a++}return a===0?e:e.slice(0,n[0].length)+r}function Ne(t,e){if(!t||!e)return!1;let n=String(t);for(let i of e){let s=i?.hostName;if(s&&s!==i?.name&&n.includes(s))return!0}return!1}var ct={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 "]},un=new RegExp("^("+Object.keys(ct).join("|")+")\\((.+)\\)$");function mt(t){if(!t)return[];let e=un.exec(String(t).trim());if(!e)return[];let n=ct[e[1]],i=e[2],s=[];for(let r=i.indexOf(".");r>=0;r=i.indexOf(".",r+1)){if(r===0)continue;let a=i.slice(r+1);if(a.trim()!=="")for(let u of n){let o=u+a;s.includes(o)||s.push(o)}}return s}function ln(t){let e=he(t);return e.length===0?"":e.replace(nn," ")}function dt(t,e){if(!e)return!1;let n=he(e);return t.test(j(ln(e)))||t.test(j(n))||t.test(j(X(n).join(" ")))}function ft(t){return dt(sn,t)}function cn(t){return dt(rn,t)||ft(t)}var gt=/int|double|decimal|single|float|number|currency|money/i;function mn(t){let e=String(t?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||t?.isMeasure===!0||gt.test(String(t?.dataType??""))?"Continuous":"Categorical"}function dn(t){return t?.isMeasure===!0||gt.test(String(t?.dataType??""))}function pt(t){let e=t??{},n=mn(e);if(n!=="Continuous")return{nature:n,additivity:"unknown",basis:"role",suppressed:!1};if(ft(e.name))return{nature:n,additivity:"positional",basis:"name",suppressed:!0};let i=String(e.additivity??"").trim().toLowerCase();if(!(i==="additive"&&on(e.name))){if(i==="additive")return{nature:n,additivity:"additive",basis:"measured",suppressed:!1};if(i==="part_of_whole")return{nature:n,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(i==="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}:cn(e.name)?{nature:n,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:n,additivity:"additive",basis:"default",suppressed:!1}}function ht(t){let e=pt(t),n=t??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return dn(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 Dr(t){return ht(t)[0]}function Lr(t,e){return ht(t).indexOf(e)>=0}function kr(t,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let n=pt(t);return n.additivity==="additive"||n.additivity==="part_of_whole"||n.additivity==="unknown"}var fn={de:["nr","nummer","kennung","kennziffer","plz","postleitzahl"],nl:["nr","nummer"],sv:["nr","nummer"],da:["nr","nummer"],nb:["nr","nummer"],fi:["tunnus","koodi","nro"],hu:["azonos\xEDt\xF3","k\xF3d"],tr:["kod","kodu","numaras\u0131","numarasi"],zh:["\u7F16\u53F7","\u4EE3\u7801","\u7F16\u7801","\u53F7\u7801","\u90AE\u7F16"],ja:["\u756A\u53F7","\u30B3\u30FC\u30C9"],ko:["\uBC88\uD638","\uCF54\uB4DC"],hi:["\u0915\u094B\u0921","\u0915\u094D\u0930\u092E\u093E\u0902\u0915"],fr:["num\xE9ro"],es:["c\xF3digo"],pt:["c\xF3digo","cep"],it:["codice"],pl:["kod","numer"],cs:["k\xF3d","\u010D\xEDslo"],sk:["k\xF3d","\u010D\xEDslo"],hr:["\u0161ifra","oznaka"],ru:["\u043A\u043E\u0434","\u043D\u043E\u043C\u0435\u0440"],uk:["\u043A\u043E\u0434","\u043D\u043E\u043C\u0435\u0440"],el:["\u03BA\u03C9\u03B4\u03B9\u03BA\u03CC\u03C2"],ar:["\u0631\u0645\u0632","\u0643\u0648\u062F","\u0631\u0642\u0645"],he:["\u05E7\u05D5\u05D3"],id:["kode","nomor"],vi:["m\xE3"],th:["\u0E23\u0E2B\u0E31\u0E2A"]},gn=["fr","es","pt","it","pl","cs","sk","hr","ru","uk","el","ar","he","id","vi","th"],pn=["num\xE9ro"],hn=t=>t.normalize("NFC").toLowerCase();function bn(t,e,n,i){let s=Se(n);return!s||!t?null:t===e?"word":s.wordBreaks===!1?Array.from(e).length<We?null:(i?t.startsWith(e):t.endsWith(e))&&t.length>e.length?"suffix":null:i?Fe(t,n).includes(e)?"word":null:s.script==="Hang"?Ge(t,e)?"suffix":null:s.compounds&&Pe(t,e,Oe)?"suffix":null}function bt(t){let e=String(t??"").trim();if(!e)return null;let n=ae(e),i=ae(he(e));for(let[s,r]of Object.entries(fn)){let a=gn.includes(s),u=a?i:n;for(let o of r){let f=pn.includes(o)||!!Se(s)?.foldSensitive,g=f?u.words:u.folded;if(g.length===0)continue;let m=f?hn(o):ae(o).folded.join(" "),c=bn(a?g[0]:g[g.length-1],m,s,a);if(c)return{lang:s,word:o,view:c}}}return null}var yn=[["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 be(t){for(let[e,n]of yn)if(n.test(t))return e;return null}var Sn=[{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]]}],ye=new Map;function yt(t,e,n,i){let s=ye.get(t);if(s)return s;let r=[];for(let[a,u]of e)for(let o=a;o<=u;o++){let f=String.fromCodePoint(o);be(f)===n&&(i&&!i.test(f)||r.push(f))}return ye.set(t,r),r}function xn(t){let n=t.codePointAt(0);for(let a=0;a<9&&be(String.fromCodePoint(n-1))==="Nd";a++)n--;let i="nd:"+n.toString(16),s=ye.get(i);if(s)return s;let r=[];for(let a=n;a<n+10;a++){let u=String.fromCodePoint(a);be(u)==="Nd"&&r.push(u)}return ye.set(i,r),r}function _n(t,e){if(e==="Nd")return xn(t);for(let s of Sn)if(s.test.test(t))return yt(s.id+":"+e,s.ranges,e,s.id==="ascii"?null:s.test);let i=t.codePointAt(0)&-128;return yt("block:"+i.toString(16)+":"+e,[[i,i+127]],e,null)}function Cn(t,e,n,i){let s=t.filter(r=>!e.has(r));return s.length===0&&(s=t.filter(r=>r!==n)),s.length===0?n:s[Math.min(s.length-1,Math.floor(i()*s.length))]}var An=/^[\p{L}\p{M}\p{Nd}]$/u,St=/^[\p{L}\p{Nd}]$/u;function xt(t,e){if(!t)return t??"";let n=new Set(Array.from(t)),i=g=>{let m=be(g);return!m||!An.test(g)?g:Cn(_n(g,m),n,g,e)},s=g=>{let m=[];for(let c of g)m.push(i(c)),St.test(c)&&e()<.2&&m.push(i(c));if(m.length>6){let c=Math.floor(e()*Math.min(3,m.length-6));for(let _=0;_<c;_++)for(let b=0;b<5;b++){let L=Math.floor(e()*m.length);if(St.test(m[L])){m.splice(L,1);break}}}return m.join("")};if(!(t.includes("@")&&t.includes(".")))return s(t);let[a,u=""]=t.split("@"),o=u.endsWith(".com"),f=o?u.slice(0,-4):u;return`${s(a)}@${s(f)}${o?".com":""}`}var Mn=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Tn=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Rn=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 re(t,e){if(!t||!e)return!1;let n=Tn(e);return new RegExp("['\"`]"+n+"['\"`]").test(t)?!0:Mn.test(e)&&new RegExp("\\."+n+"(?![A-Za-z0-9_$])").test(t)}function Nn(t){return!!t&&Rn.test(t)}function $r(t,e,n){return t?Nn(t)?[...e]:[...n,...e].some(i=>re(t,i))?e.filter(i=>re(t,i)):[...e]:[]}var En=5,wn=6,In=3,Q=864e5,vn=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Dn=/^(\d{4})[-/](\d{1,2})$/,Ln=/^(\d{4})[-\s]?Q([1-4])$/i,kn=/^Q([1-4])[-\s](\d{4})$/i,On=/^(\d{4})$/,Pn=/^(\d{4})(0[1-9]|1[0-2])$/,Fn=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/,Gn=/^(\D+?)[\s\-/.,']*((?:19|20)\d{2})$/u,Wn=/^((?:19|20)\d{2})[\s\-/.,']+(\D+)$/u;function Ee(t,e,n){let i=Z(t);if(!i)return 0;if(i==="sept")return 9;for(let a of e&&!/^en\b/i.test(e)?["en",e]:["en"]){let u=me(a)[i];if(u!==void 0)return u+1}let s=n?.get(i);if(s!==void 0)return s+1;let r=te(t);if(r.length>0){if(r.every(o=>o.month===r[0].month))return r[0].month+1;let a=Le(String(e??"").split(/[-_]/)[0])?.code,u=r.find(o=>o.lang===a);if(u)return u.month+1}return 0}function zn(t){let e=ue(t).filter(i=>i.yearDigits===4);if(e.length===0||e.some(i=>i.lang==="en"))return null;let n=e[0];return e.some(i=>i.grain!=="quarter"||i.n!==n.n||i.year!==n.year)?null:H(n.year,(n.n-1)*3+1,1)}function H(t,e,n,i=0,s=0,r=0){if(!(t>=1&&e>=1&&e<=12&&n>=1&&n<=31))return null;let a=Date.UTC(t,e-1,n,i,s,r);if(!Number.isFinite(a))return null;let u=o=>o<10?"0"+o:String(o);return{ms:a,y:t,m:e,d:n,iso:`${t}-${u(e)}-${u(n)}`}}function $n(t,e){let n=[],i="";for(let o=0;o<e.length;o++){if(e[o]!=="%"){i+=e[o].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");continue}switch(e[++o]){case"Y":n.push("Y"),i+="(\\d{4})";break;case"m":n.push("m"),i+="(\\d{1,2})";break;case"d":n.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 s=new RegExp("^"+i+"$").exec(t);if(!s)return null;let r=0,a=1,u=1;return n.forEach((o,f)=>{let g=+s[f+1];o==="Y"?r=g:o==="m"?a=g:u=g}),r?H(r,a,u):null}function we(t,e,n,i){let s=(t??"").trim();if(s==="")return null;if(e){let o=$n(s,e);return o||null}let r=vn.exec(s);if(r)return H(+r[1],+r[2],+r[3],+(r[4]??0),+(r[5]??0),+(r[6]??0));if(r=Ln.exec(s),r)return H(+r[1],(+r[2]-1)*3+1,1);if(r=kn.exec(s),r)return H(+r[2],(+r[1]-1)*3+1,1);if(r=Dn.exec(s),r&&+r[2]>=1&&+r[2]<=12)return H(+r[1],+r[2],1);if(r=Fn.exec(s),r)return H(+r[1],+r[2],+r[3]);if(r=Pn.exec(s),r)return H(+r[1],+r[2],1);if(r=On.exec(s),r){let o=+r[1];return o>=1900&&o<=2100?H(o,1,1):null}let a=zn(s);if(a)return a;if(r=Gn.exec(s),r){let o=Ee(r[1],n,i);if(o)return H(+r[2],o,1)}if(r=Wn.exec(s),r){let o=Ee(r[2],n,i);if(o)return H(+r[1],o,1)}let u=ee(s);if(u){let o="month"in u?u.month:Ee(u.word,n,i);if(o)return H(u.year,o,1)}return null}function _t(t){let e=new Date(t).getUTCDay();return e>=1&&e<=5}function Ct(t,e){if(e<=t)return 0;let n=Math.round((e-t)/Q),i=Math.floor(n/7),s=i*5,r=t+i*7*Q;for(;r<e;)_t(r)&&s++,r+=Q;return s}function Bn(t){if(t.length===0)return 0;let e=[...t].sort((i,s)=>i-s),n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2}function Un(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 ie(t,e,n,i){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*Q));case"weekday":return Ct(t.ms,e.ms);case"day":return Math.round((e.ms-t.ms)/Q);default:return i>0?Math.round((e.ms-t.ms)/i):0}}function At(t,e){return Ie(t,e)?.cadence??null}function Ie(t,e){let n=e?.gapFactor??En,i=0,s=0,r=new Map,a=Array.from(t),u;if(!e?.pattern){let M=[];for(let A of a){if(A==null||A==="")continue;let w=ee(String(A));w&&"word"in w&&M.push(w.word)}M.length>0&&(u=de(M,e?.locale)??void 0)}for(let M of a){if(M==null||M==="")continue;i++;let A=we(String(M),e?.pattern,e?.locale,u);A&&(s++,r.set(A.ms,A))}let o=[...r.values()].sort((M,A)=>M.ms-A.ms);if(o.length<In||i>0&&s/i<.8)return null;let f=o[o.length-1].ms-o[0].ms;if(f<=0)return null;let g=[];for(let M=1;M<o.length;M++)g.push(o[M].ms-o[M-1].ms);let m=Bn(g);if(!(m>0))return null;let c=Un(m/Q);c==="day"&&f>=7*Q&&o.every(M=>_t(M.ms))&&Ct(o[0].ms,o[o.length-1].ms)+1>o.length*.5&&(c="weekday");let _=c==="irregular"?o.length:ie(o[0],o[o.length-1],c,m)+1,b=1,L=1,p=[],d=o[0],h=1;for(let M=1;M<o.length;M++){let A=ie(o[M-1],o[M],c,m);A>b&&(b=A),c!=="irregular"&&A>n?(L++,p.push({from:d.iso,to:o[M-1].iso,points:h}),d=o[M],h=1):h++}p.push({from:d.iso,to:o[o.length-1].iso,points:h});let C={grain:c,points:o.length,expectedPoints:Math.max(_,o.length),coveragePct:Math.round(o.length/Math.max(_,o.length)*1e3)/10,runs:L,largestGapUnits:b,gapFactor:n};return e?.includeBounds&&p.length<=wn&&(C.runBounds=p),{cadence:C,points:o,stepMs:m}}var Vn=8,Hn=.5,Kn=200,Yn=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"]),jn=["category","classification","segment","status","priority","severity","channel"],Xn=new Set(["UUID","EMAIL_LIKE","URL_LIKE","PHONE_LIKE","NUMERIC_ID","HEX_ID","OPAQUE_ID_ALPHANUMERIC","DATE_STR","BOOLEAN"]);function Zn(t){let e=X(t);if(e.length===0)return!1;let n=e[e.length-1];return Yn.has(n)?!0:jn.some(i=>n.length>i.length&&n.endsWith(i))}function qn(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>Kn?"cardinality":t.rows>0&&e.length>=t.rows?"row-identity":t.isBinaryFlag?"flag":le(e,t.locale)!==null?"ordinal":t.identifierNamed||t.dataType==="String"&&Xn.has(ce(e))?"identifier":!t.geoKind&&Zn(t.name)?"attribute":"entity"}function Rt(t){let e=-1,n=1/0,i=!1;return t.forEach((s,r)=>{if(qn(s)!=="entity")return;let a=new Set(Array.from(s.values).filter(o=>o!=="")).size,u=!!s.geoKind;(a<n||a===n&&u&&!i)&&(e=r,n=a,i=u)}),e}var Mt=t=>t<10?"0"+t:String(t);function Tt(t,e){switch(e){case"year":return`${t.y}-01-01`;case"quarter":return`${t.y}-${Mt(Math.floor((t.m-1)/3)*3+1)}-01`;case"month":return`${t.y}-${Mt(t.m)}-01`;case"hour":return new Date(t.ms).toISOString().replace(/\.\d{3}Z$/,"Z");default:return t.iso}}function Nt(t){let{periods:e,series:n}=t,i=Math.min(e.length,n.length),s=new Set;for(let A=0;A<i;A++)e[A]&&s.add(e[A]);let r=Ie(s,{pattern:t.pattern,locale:t.locale});if(!r)return null;let a=r.cadence.grain;if(a==="irregular")return null;let u=r.points[0],o=ie(u,r.points[r.points.length-1],a,r.stepMs)+1;if(o!==r.cadence.expectedPoints)return null;let f=new Map;for(let A of s){let w=we(A,t.pattern,t.locale);if(!w)continue;let $=ie(u,w,a,r.stepMs);$>=0&&$<o&&f.set(A,{idx:$,stamp:w})}let g=new Map;for(let A=0;A<i;A++){let w=n[A];if(!w)continue;let $=f.get(e[A]);if(!$)continue;let P=g.get(w);P||(P={seen:new Set,lo:$.idx,hi:$.idx,loStamp:$.stamp,hiStamp:$.stamp,order:g.size},g.set(w,P)),P.seen.add($.idx),$.idx<P.lo&&(P.lo=$.idx,P.loStamp=$.stamp),$.idx>P.hi&&(P.hi=$.idx,P.hiStamp=$.stamp)}if(g.size<2)return null;let m=0;for(let A of g.values())m+=A.seen.size;if(m/(g.size*o)<(t.minFill??Hn))return null;let c=[],_=new Set,b=0,L=0,p=0,d=0,h=0,C=1;for(let[A,w]of g){for(let B of w.seen)_.add(B);if(w.seen.size>=o)continue;let $=[...w.seen].sort((B,l)=>B-l),P=1;for(let B=1;B<$.length;B++)P=Math.max(P,$[B]-$[B-1]);let U={key:A,acc:w,coverage:w.seen.size/o,before:w.lo,after:o-1-w.hi,interior:w.hi-w.lo+1-w.seen.size,gap:P};c.push(U),U.before>0&&b++,U.after>0&&L++,U.interior>0&&p++,d=Math.max(d,U.before),h=Math.max(h,U.after),C=Math.max(C,P)}if(c.length===0)return null;c.sort((A,w)=>A.coverage-w.coverage||A.acc.order-w.acc.order);let M=c.slice(0,t.maxListed??Vn);return{seriesColumn:t.seriesColumn,grain:a,periods:o,seriesCount:g.size,incompleteSeries:c.length,lateStarts:b,earlyEnds:L,withHoles:p,columnWideMissing:o-_.size,maxMissingBefore:d,maxMissingAfter:h,largestGap:C,series:M.map(A=>{let w={};return t.includeNames&&(w.name=A.key),t.includeDates&&(w.first=Tt(A.acc.loStamp,a),w.last=Tt(A.acc.hiStamp,a)),w.missingBefore=A.before,w.missingAfter=A.after,w.missingInterior=A.interior,w.largestGap=A.gap,w.coverage=Math.round(A.coverage*1e3)/1e3,w}),more:c.length-M.length}}var Qn=12,Jn=100,er=.3,tr=.9,nr=120,rr=1900,ir=2100,sr=0,or=20,ar=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function vt(t){if(!t)return!1;let e=X(t);return e.length===0?!1:ar.has(e[e.length-1])?!0:bt(t)!==null}var ur=new Set(["year","yr","fy"]),lr=t=>X(t).some(e=>ur.has(e))||Ve(t)!==null,cr=/^(?:(?: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 ve(t){if(!Number.isInteger(t)||t<190001||t>210012)return!1;let e=t%100;return e>=1&&e<=12}function De(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 mr=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,dr=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,fr=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function Dt(t,e){let n=[],i=0,s=gr(t,e,n,()=>{i++});if(s)return s;if(i>0||n.length<2)return null;let r=nt(n,{locale:e,floor:.8});return!r||!r.pattern||r.form==="named"?null:{pattern:r.pattern,orderFrom:r.orderFrom==="shape"?r.order==="ymd"?"iso":"shape":r.orderFrom}}function gr(t,e,n,i){let s=0,r=0,a=0,u=0,o=0,f="",g=0,m="",c=0,_=0,b=0,L=0,p=!1;for(let w of t){if(w==null)continue;let $=String(w).trim();if($==="")continue;s++,n.push($);let P;if(P=mr.exec($)){i();let U=+P[2],B=+P[3];U>=1&&U<=12&&B>=1&&B<=31&&(r++,P[4]!==void 0&&a++,P[6]!==void 0&&u++)}else if(P=dr.exec($)){i();let U=+P[3],B=+P[4];U>=1&&U<=12&&B>=1&&B<=31&&(f&&f!==P[2]&&(p=!0),f=P[2],o++)}else if(P=fr.exec($)){i();let U=+P[1],B=+P[3];U>=1&&U<=31&&B>=1&&B<=31&&(U<=12||B<=12)&&(m&&m!==P[2]&&(p=!0),m=P[2],g++,U>12&&b++,B>12&&L++,P[5]!==void 0&&c++,P[7]!==void 0&&_++)}if(s>=200)break}if(s<2||(r+o+g)/s<.8||(r>0?1:0)+(o>0?1:0)+(g>0?1:0)!==1||p)return null;if(r>0)return a===r?{pattern:u===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${f}%m${f}%d`,orderFrom:"iso"};if(b>0&&L>0)return null;let C,M;b>0?(C=!0,M="values"):L>0?(C=!1,M="values"):m==="."?(C=!0,M="shape"):(C=!Me(e),M="locale");let A=C?`%d${m}%m${m}%Y`:`%m${m}%d${m}%Y`;return c===g?{pattern:A+(_===g?" %H:%M:%S":" %H:%M"),orderFrom:M}:{pattern:A,orderFrom:M}}function pr(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 i=Z(n);return i.length>0&&e[i]!==void 0}function hr(t,e){let n=new Map,i=new Map;for(let u of t){let o=ee(u);if(!o||"month"in o)continue;let f=te(o.word),g=f.some(c=>c.lang==="en"),m=Z(o.word);for(let c of new Set(f.map(_=>_.lang)))c!=="en"&&(n.has(c)||(n.set(c,new Set),i.set(c,new Set)),n.get(c).add(m),g||i.get(c).add(m))}let s=[...n.keys()].filter(u=>n.get(u).size>=3&&i.get(u).size>=1),r=0,a=new Map(s.map(u=>[u,0]));for(let u of e){let o=ee(u);if(!o)continue;if("month"in o){r++;continue}let f=te(o.word);if(f.length===0)continue;let g=f.some(m=>m.lang==="en");for(let m of s)(g||f.some(c=>c.lang===m))&&a.set(m,a.get(m)+1)}return r+Math.max(0,...a.values())}var br=/(?:19|20)[0-9]{2}/;function yr(t){let e=new Map,n=0;for(let s of t){if(!br.test(oe(s)))continue;let r=new Set(ue(s).filter(a=>a.yearDigits===4&&(a.grain==="quarter"||a.grain==="week")).map(a=>a.lang));if(r.size!==0){if(r.has("en")){n++;continue}for(let a of r)e.set(a,(e.get(a)??0)+1)}}let i=0;for(let s of e.values())i=Math.max(i,s);return i>0?i+n:0}function Sr(t){let{dataType:e,name:n,isMeasure:i,distinctCount:s}=t;if(e==="DateTime")return!0;if(i)return!1;if(e==="Integer"||e==="Decimal"){let r=t.minNum,a=t.maxNum;if(!(r!=null&&a!=null&&Number.isFinite(r)&&Number.isFinite(a)&&Number.isInteger(r)&&Number.isInteger(a)&&a>=r))return!1;let o=r>=1900&&a<=2100;if(o&&s>=2&&lr(n)||o&&s>=3&&s===a-r+1)return!0;let f=ve(r)&&ve(a),g=De(r)&&De(a);if(f||g){if(!t.sampleValues)return!0;let m=0,c=0;for(let _ of t.sampleValues){if(_==null||_==="")continue;m++;let b=Number(String(_).trim());if(Number.isFinite(b)&&(f?ve(b):De(b))&&c++,m>=60)break}if(m>=2&&c===m)return!0}return!1}if(t.sampleValues){let r=t.locale?me(t.locale):null,a=0,u=0,o=[],f=[];for(let g of t.sampleValues){if(g==null||g==="")continue;a++;let m=String(g).trim();if(o.push(m),cr.test(m)||pr(m,r)?u++:f.push(m),a>=60)break}if(a>=2&&u/a>=.8||a>=2&&(u+yr(f)+hr(o,f))/a>=.8||Dt(o,t.locale)!==null)return!0}return!1}function xr(t){let e=j((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":ut(t)}function _r(t){let{rows:e,measureColIdx:n,measureName:i,candidateDims:s,minNum:r,maxNum:a,discourageAgg:u}=t,o=100,f=.01,g="";for(let c of s){if(c.distinct<2||c.distinct>o)continue;let _=s.filter(h=>h.idx!==c.idx).map(h=>h.idx),b=new Map;for(let h of e){let C=h[n];if(typeof C!="number"||!Number.isFinite(C))continue;let M=_.length?_.map(w=>String(h[w])).join(g):"",A=b.get(M);A||(A={sum:0,cset:new Set},b.set(M,A)),A.sum+=C,A.cset.add(String(h[c.idx]))}let L=0,p=0,d=0;for(let h of b.values())h.cset.size<2||(d++,Math.abs(h.sum-100)<=100*f?L++:Math.abs(h.sum-1)<=1*f&&p++);if(d>=2&&(L/d>=.9||p/d>=.9))return{additivity:"part_of_whole",partOfWholeDim:c.name}}if(u)return{additivity:"intensive_rate"};let m=xr(i);return m==="avg"||m==="min"||m==="max"?{additivity:"intensive_rate"}:m==="count"?{additivity:"additive"}:m==="sum"?{additivity:"unknown"}:r!=null&&a!=null&&Number.isFinite(r)&&Number.isFinite(a)&&r>=0&&a<=1.0001&&a>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function wt(t){let{dataType:e,isMeasure:n,name:i,distinct:s,nonblank:r,prec:a,maxval:u,minval:o}=t,f=u-o+1,g=f>0?s/f:1,m=r>0?s/r:0,c=e==="Decimal"||a>0;return!n&&vt(i)?"Categorical":g>=tr&&(He(i)&&s<=nr||o>=rr&&u<=ir||o>=sr&&u<=or)?"Ordinal":n||s>Qn&&(c||s>=Jn||m>=er)?"Continuous":"Categorical"}function Cr(t){let e=null;for(let n=0;n<t.length;n++){let i=t[n];if(typeof i!="string"||i.length===0)continue;let s=i.trim();s.length!==i.length&&(e||(e=t.slice()),e[n]=s)}return e||t}var It=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;_declaredDimensions=new WeakSet;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}declareDimensions(e){for(let n of e)n&&this._declaredDimensions.add(n)}wholeDayIso(e){return Ue(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 i=0,s=parseInt(e),r=[];for(let l of this._cols){let S=new Map,F=[],v=0,y=0,I=0,k=null,D=null,E=null,W=!1,G=!0,R=!0,N=null,z=!1;for(let T of this._rows){let x=T[i],O=this.STR(x);if(O!=""){if(v+=O.length,S.set(O,(S.get(O)||0)+1),y++,l.dataType=="Integer"||l.dataType=="Decimal"||l.dataType=="DateTime")if((k===null||x<k)&&(k=x),(D===null||x>D)&&(D=x),l.dataType=="Integer"||l.dataType=="Decimal"){if(E===null?E=x:E+=x,l.dataType=="Decimal"){let V=this.getPrecision(x);V>I&&(I=V)}F.push(x)}else W=W||this.hasTimeComponent(x);z&&(x<N?G=!1:x>N&&(R=!1)),N=x,z=!0}}if(y>=3&&(G&&!R?l.sortedDirection="asc":R&&!G?l.sortedDirection="desc":l.sortedDirection="none"),y>0&&S.size>0&&!l.isMeasure){let T=0,x=Number.MAX_SAFE_INTEGER;for(let O of S.values())O>T&&(T=O),O<x&&(x=O);if(l.modalShare=T/y,l.minGroupCount=x===Number.MAX_SAFE_INTEGER?null:x,S.size===2){let O=[...S.keys()].map(se=>ze(se).trim().toLowerCase()).sort(),K=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(se=>O[0]===se[0]&&O[1]===se[1]),J=/^(is|has)[_\p{L}\p{N}]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/iu.test(l.name);(K||J)&&(l.isBinaryFlag=!0)}}if(l.dataType=="DateTime"&&(l.dateWithTime=W),l.isTemporal=Sr({dataType:l.dataType,name:l.name,isMeasure:l.isMeasure,distinctCount:S.size,minNum:typeof k=="number"?k:null,maxNum:typeof D=="number"?D:null,sampleValues:S.keys(),locale:n}),l.isTemporal&&l.dataType==="String"&&!l.isMeasure){let T=Dt(S.keys(),n);T&&(l.temporalTextPattern=T.pattern)}if(l.isTemporal&&!l.isMeasure){let T=At(S.keys(),{includeBounds:s>=20,pattern:l.temporalTextPattern,locale:n});T&&(l.temporalCadence=T)}this.updateColumnStats10(s,l,y,S,I,D,k),this.updateColumnStats20(s,F,y,E,l,v,W,k,D,I,S,n),!l.isMeasure&&!this._declaredDimensions.has(l)&&(l.dataType==="Integer"||l.dataType==="Decimal")&&wt({dataType:l.dataType,isMeasure:!1,name:l.name,distinct:S.size,nonblank:y,prec:I,maxval:typeof D=="number"?D:0,minval:typeof k=="number"?k:0})==="Continuous"&&(l.isMeasure=!0,l.geoKind=void 0,l.geoMatchPct=void 0,l.geoAmbiguous=void 0,l.dominantGeoRegion=void 0,l.dominantGeoRegionPct=void 0,l.geoRegionCount=void 0),r[i]=l.isMeasure||S.size>2e3?null:new Set(S.keys()),i++}let a=[];this._cols.forEach((l,S)=>{l.isMeasure||a.push({idx:S,distinct:l.distinctCount??0,name:l.name})}),this._cols.forEach((l,S)=>{if(!l.isMeasure)return;let F=typeof l.lowValue=="number"?l.lowValue:null,v=typeof l.highValue=="number"?l.highValue:null,y=_r({rows:this._rows,measureColIdx:S,measureName:l.name,candidateDims:a,minNum:F,maxNum:v,discourageAgg:!!l.discourageAggregationAcrossGroups});l.additivity=y.additivity,y.partOfWholeDim&&(l.partOfWholeDim=y.partOfWholeDim)});let u=50,o=4,f=a.filter(l=>l.distinct>=2&&l.distinct<=u);this._cols.forEach((l,S)=>{if(!l.isMeasure)return;let F=[];for(let R of this._rows){let N=R[S];if(N==null||N==="")continue;let z=typeof N=="number"?N:parseFloat(N);isNaN(z)||F.push(z)}if(F.length===0)return;let v=[...F].sort((R,N)=>R-N);if(v[0]===v[v.length-1])l.relativeDispersion=0;else if(v.length>=o){let R=Y(v,.5),N=Y(v,.1),z=Y(v,.9);l.relativeDispersion=Math.abs(R)>1e-9?Math.round((z-N)/Math.abs(R)*1e3)/1e3:void 0}else l.relativeDispersion=void 0;let y=[];for(let R of f){let N=new Set;for(let z of this._rows){let T=z[S];T==null||T===""||N.add(this.STR(z[R.idx])+"")}y.push({otherColumn:R.name,nonBlankGroupCount:N.size})}y.length>0&&(l.nonBlankGroups=y);let I=0;for(let R of F)I+=R;I/=F.length;let k=0;for(let R of F)k+=(R-I)*(R-I);if(k<=1e-12)return;let D=[],E=[],W=R=>{if(R.length<4)return NaN;let N=[...R].sort((T,x)=>T-x),z=T=>N[Math.min(N.length-1,Math.max(0,Math.floor(T*(N.length-1))))];return z(.75)-z(.25)},G=W(F);for(let R of f){let N=new Map;for(let x of this._rows){let O=x[S];if(O==null||O==="")continue;let V=typeof O=="number"?O:parseFloat(O);if(isNaN(V))continue;let K=this.STR(x[R.idx])+"",J=N.get(K);J?(J.s+=V,J.n++,J.vals.push(V)):N.set(K,{s:V,n:1,vals:[V]})}let z=0;for(let x of N.values()){let O=x.s/x.n;z+=x.n*(O-I)*(O-I)}D.push({otherColumn:R.name,eta2:Math.round(z/k*1e4)/1e4});let T=[];for(let x of N.values()){let O=W(x.vals);isNaN(O)||T.push(O)}if(T.length>=2&&isFinite(G)&&G>1e-9){let x=(Math.max(...T)-Math.min(...T))/G;E.push({otherColumn:R.name,spreadRatio:Math.round(x*1e4)/1e4})}}D.length>0&&(l.groupDiscrimination=D),E.length>0&&(l.spreadDiscrimination=E)});let g=.97,m=.8,c=8,_=5,b=this._cols.map((l,S)=>({c:l,i:S})).filter(l=>l.c.isMeasure);for(let l=0;l<b.length;l++)for(let S=l+1;S<b.length;S++){let F=b[l].i,v=b[S].i,y=0,I=0,k=0,D=0,E=0,W=0;for(let T of this._rows){let x=T[F],O=T[v];if(x==null||x===""||O===null||O===void 0||O==="")continue;let V=typeof x=="number"?x:parseFloat(x),K=typeof O=="number"?O:parseFloat(O);isNaN(V)||isNaN(K)||(y++,I+=V,k+=K,D+=V*V,E+=K*K,W+=V*K)}if(y<_)continue;let G=y*D-I*I,R=y*E-k*k;if(G<=1e-12||R<=1e-12)continue;let N=(y*W-I*k)/Math.sqrt(G*R),z=Math.min(1,Math.round(Math.abs(N)*1e3)/1e3);for(let T of[b[l].c,b[S].c])(T.maxAbsMeasureCorrelation===void 0||z>T.maxAbsMeasureCorrelation)&&(T.maxAbsMeasureCorrelation=z);if(Math.abs(N)>=g){let T=b[l].c,x=b[S].c;T.collinearWithMeasures||(T.collinearWithMeasures=[]),x.collinearWithMeasures||(x.collinearWithMeasures=[]),T.collinearWithMeasures.push(x.name),x.collinearWithMeasures.push(T.name)}else if(Math.abs(N)>=m){let T=b[l].c,x=b[S].c,O=Math.round(N*1e3)/1e3;T.correlatedWithMeasures||(T.correlatedWithMeasures=[]),x.correlatedWithMeasures||(x.correlatedWithMeasures=[]),T.correlatedWithMeasures.push({otherColumn:x.name,r:O}),x.correlatedWithMeasures.push({otherColumn:T.name,r:O})}}for(let{c:l}of b)l.correlatedWithMeasures&&(l.correlatedWithMeasures.sort((S,F)=>Math.abs(F.r)-Math.abs(S.r)||(S.otherColumn<F.otherColumn?-1:1)),l.correlatedWithMeasures.length=Math.min(l.correlatedWithMeasures.length,c));for(let l=0;l<this._cols.length;l++){let S=r[l];if(!S||S.size===0)continue;let F=[];for(let v=0;v<this._cols.length;v++){if(v===l)continue;let y=r[v];if(!y||y.size===0)continue;let I=0;for(let D of S)y.has(D)&&I++;let k=Math.round(I/S.size*100);k>0&&F.push({otherColumn:this._cols[v].name,percentShared:k})}F.length>0&&(this._cols[l].sharedValueRatioWithOthers=F)}let L=50,p=[];for(let l=0;l<this._cols.length;l++){let S=r[l];S&&S.size>=2&&S.size<=L&&p.push(l)}if(p.length>=2){let l=new Map,S=(v,y)=>v+":"+y;for(let v=0;v<p.length;v++)for(let y=v+1;y<p.length;y++)l.set(S(p[v],p[y]),new Map);for(let v of this._rows)for(let y=0;y<p.length;y++){let I=this.STR(v[p[y]])+"";for(let k=y+1;k<p.length;k++){let D=""+this.STR(v[p[k]]),E=l.get(S(p[y],p[k])),W=I+""+D;E.set(W,(E.get(W)??0)+1)}}let F=new Map;for(let v=0;v<p.length;v++)for(let y=v+1;y<p.length;y++){let I=p[v],k=p[y],D=r[I].size,E=r[k].size,W=l.get(S(I,k)),G=W.size,R=0;for(let x of W.values())(R===0||x<R)&&(R=x);let N=Math.round(G/(D*E)*100),z=G===D,T=G===E;if((this._cols[I].categoricalPairStats||=[]).push({otherColumn:this._cols[k].name,fillPct:N,determinesOther:z,minCellCount:R,distinctCombinations:G}),(this._cols[k].categoricalPairStats||=[]).push({otherColumn:this._cols[I].name,fillPct:N,determinesOther:T,minCellCount:R,distinctCombinations:G}),z&&D>E){let x=F.get(I);(!x||E<x.card)&&F.set(I,{name:this._cols[k].name,card:E,ratio:E/D})}if(T&&E>D){let x=F.get(k);(!x||D<x.card)&&F.set(k,{name:this._cols[I].name,card:D,ratio:D/E})}}for(let[v,y]of F)this._cols[v].primaryParentColumn=y.name,this._cols[v].nestingRatio=Math.round(y.ratio*100)/100}let d=6,h=this._rows.length;for(let l=0;l<this._cols.length;l++){let S=this._cols[l];if(S.isMeasure||S.primaryParentColumn)continue;let F=S.distinctCount??0;if(F<=L||h>0&&F>=h)continue;let v=[];for(let y=0;y<this._cols.length;y++){if(y===l)continue;let I=this._cols[y];if(I.isMeasure)continue;let k=I.distinctCount??0;k<2||k>=F||v.push(y)}v.sort((y,I)=>(this._cols[y].distinctCount??0)-(this._cols[I].distinctCount??0));for(let y of v.slice(0,d)){let I=new Map,k=!0;for(let E of this._rows){let W=this.STR(E[l])+"",G=this.STR(E[y])+"",R=I.get(W);if(R===void 0)I.set(W,G);else if(R!==G){k=!1;break}}if(!k)continue;let D=this._cols[y].distinctCount??0;S.primaryParentColumn=this._cols[y].name,S.nestingRatio=Math.round(D/F*100)/100;break}}let C=.01,M=.05,A=.95,w=8,$=8,P=6,U=500,B=[];for(let l=0;l<this._cols.length&&B.length<$;l++){let S=this._cols[l].dataType;(S==="Double"||S==="Integer"||S==="Decimal")&&B.push(l)}if(B.length>=3&&this._rows.length>=w){let l=Math.min(this._rows.length,U),S=B.map(D=>{let E=[];for(let R=0;R<l;R++){let N=this._rows[R][D],z=typeof N=="number"?N:parseFloat(String(N).replace(/,/g,""));if(N==null||N===""||!isFinite(z))return null;E.push(z)}let W=E[0],G=!1;for(let R of E)if(R!==W){G=!0;break}return G?E:null}),F=B.map((D,E)=>E).filter(D=>S[D]!==null),v=D=>{let E=D.slice().sort((G,R)=>G-R),W=E.length>>1;return E.length%2?E[W]:(E[W-1]+E[W])/2},y=null,I=[],k=D=>{if(I.length>=3){let E=I.map(N=>S[N]),W=E[0].length,G=new Array(W);for(let N=0;N<W;N++){let z=0;for(let T of E)z+=T[N];G[N]=z}let R=v(G);if(R>0){let N=0;for(let T of G)Math.abs(T-R)<=R*C&&N++;let z=N/W;if(z>=A){let T=1;for(let x of E){let O=v(x)/R;O<T&&(T=O)}T>=M&&(!y||I.length>y.cols.length)&&(y={cols:I.slice(),total:R,matched:z})}}}if(!(I.length>=P))for(let E=D;E<F.length;E++)I.push(F[E]),k(E+1),I.pop()};if(k(0),y){let D=y,W={columns:D.cols.map(G=>this._cols[B[G]].name),total:Math.round(D.total*1e3)/1e3,matchedPct:Math.round(D.matched*100)/100};for(let G of D.cols)this._cols[B[G]].constantSumGroup=W}}return this.applySeriesCompleteness(s,n,r),this._computedStatsForLevel=e,this._cols}applySeriesCompleteness(e,n,i){for(let c of this._cols)c.seriesCompleteness!==void 0&&delete c.seriesCompleteness;let s=this._cols.map((c,_)=>({c,i:_})).filter(({c})=>c.isTemporal&&!c.isMeasure&&c.temporalCadence&&c.temporalCadence.grain!=="irregular");if(s.length===0)return;let r=[],a=[];this._cols.forEach((c,_)=>{let b=i[_];b&&(r.push(_),a.push({name:c.name,dataType:c.dataType,isMeasure:!!c.isMeasure,isTemporal:!!c.isTemporal,isDatePart:!!c.isDatePart,isReassembledDate:!!c.isReassembledDate,isBinaryFlag:!!c.isBinaryFlag,geoKind:c.geoKind,identifierNamed:vt(c.name),values:b,rows:this._rows.length,locale:n}))});let u=Rt(a);if(u<0)return;let o=r[u],f=this._cols[o],g=this._rows.map(c=>this.STR(c[o])),m=e>=20&&(f.dataType!=="String"||Array.isArray(f.safeDistinctValues));for(let{c,i:_}of s){let b=Nt({periods:this._rows.map(L=>this.STR(L[_])),series:g,seriesColumn:f.name,pattern:c.temporalTextPattern,locale:n,includeDates:e>=20,includeNames:m});b&&(c.seriesCompleteness=b)}}updateColumnStats20(e,n,i,s,r,a,u,o,f,g,m,c){if(e>=20){let _=[...n].sort((p,d)=>p-d),b=Math.floor(_.length/2);if(i>0&&s!=null?r.avgValue=r.dataType=="Integer"?Math.round(s/i):s/i:r.avgValue=null,i>0&&(r.avgLength=a/i),this._rows.length>0){let p=d=>{let h=d instanceof Date?d:typeof d=="string"?xe(d)??new Date(d):new Date(d),C=this.wholeDayIso(h);return C?C+"T00:00:00.000Z":isNaN(h.getTime())?d:h.toISOString().slice(0,10)+"T00:00:00.000Z"};r.dataType!="DateTime"||u||!o?r.lowValue=o:r.lowValue=p(o),r.dataType!="DateTime"||u||!f?r.highValue=f:r.highValue=p(f),r.medianValue=_.length===0?null:_.length%2===0?r.dataType=="Integer"?Math.round((_[b-1]+_[b])/2):(_[b-1]+_[b])/2:_[b],r.numericPrecision=g}if(_.length>0){let p=r.avgValue??0,d=_.length,h=0,C=0;for(let A of _){let w=A-p;h+=w*w,C+=w*w*w}let M=h/d;r.skewness=M===0?0:C/d/Math.pow(Math.sqrt(M),3),r.stdDev=Math.sqrt(M)}s!==null&&(r.sum=s);let L=Array.from(m.entries()).sort((p,d)=>d[1]-p[1]);if(r.topCategories=L.slice(0,10).map(p=>p[1]),!r.isMeasure&&L.length>0&&(r.dataType!=="String"&&(r.topCategoryValues=L.slice(0,5).map(p=>p[0])),e>=20)){let p=L.map(h=>h[0]),d=le(p,c);if(d!==null)r.ordinalPattern=d.pattern,r.orderedDomain=d.orderedDomain;else if(r.dataType==="String"){let h=Ke(p);h!==null&&(r.safeDistinctValues=h)}}if(_.length>=8&&(r.dataType==="Integer"||r.dataType==="Decimal")){let p=d=>_[Math.floor((_.length-1)*d)];r.quantiles={p05:p(.05),p25:p(.25),p75:p(.75),p95:p(.95)}}}if(!r.isMeasure&&r.dataType==="String"&&m.size>0){let _=Array.from(m.entries()).sort((p,d)=>d[1]-p[1]).map(p=>p[0]);r.formatSignature=ce(_);let b=i>0?a/i:void 0,L=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;r.formatSignature&&!L.test(r.formatSignature)&&(b===void 0||b>=3)&&(r.isFreeText=!0)}if(!r.isMeasure&&m.size>0){let _=Array.from(m.entries()).sort((L,p)=>p[1]-L[1]),b=Xe(_.map(L=>L[0]),r.name,c);if(b!==null&&(r.geoKind=b.geoKind,r.geoMatchPct=b.geoMatchPct,b.geoAmbiguous&&(r.geoAmbiguous=!0),b.geoKind.indexOf("country")===0)){let L=_e(_);L&&(r.dominantGeoRegion=L.dominantGeoRegion,r.dominantGeoRegionPct=L.dominantGeoRegionPct,r.geoRegionCount=L.regionCount)}}}updateColumnStats10(e,n,i,s,r,a,u){let o=this._rows.length-i;e>=10&&(n.blankCount=o),n.distinctCount=s.size+(o!=0?1:0),n.valueNature="Categorical",i>0&&(n.dataType==="Integer"||n.dataType==="Decimal"?n.valueNature=wt({dataType:n.dataType,isMeasure:!!n.isMeasure,name:n.name,distinct:s.size,nonblank:i,prec:r,maxval:a,minval:u}):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((i,s)=>{i.isMeasure||e.push(s)}),e.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let n=new Set;for(let i of this._rows)n.add(JSON.stringify(e.map(s=>i[s])));return this._leafCardinality=n.size,this._leafCardinality}_leafCardinality=null;getGeoExtent(){if(this._geoExtentComputed)return this._geoExtent;this._geoExtentComputed=!0,this._geoExtent=null;let e=a=>ke(a,{camel:!0}),n=-1,i=-1,s=-1;if(this._cols.forEach((a,u)=>{let o=e(a.name),f=a.dataType==="Integer"||a.dataType==="Decimal";f&&n<0&&o.some(g=>g==="lat"||g==="latitude")?n=u:f&&i<0&&o.some(g=>g==="lon"||g==="lng"||g==="long"||g==="longitude")&&(i=u),s<0&&!a.isMeasure&&typeof a.geoKind=="string"&&a.geoKind.indexOf("country")===0&&(s=u)}),n<0||i<0)return null;let r=[];for(let a of this._rows){let u=a[n],o=a[i],f=u==null||u===""?null:Number(u),g=o==null||o===""?null:Number(o);r.push({lat:f,lon:g,country:s>=0&&fe(this.STR(a[s]))?this.STR(a[s]):null})}return this._geoExtent=Je(r),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(e){return xt(e,Be)}toObjectArray(){let e=this.liveEnglishAliases();return this._rows.map(n=>{let i={};this._cols.forEach((s,r)=>{i[s.name]=n[r],this.emitLegacyAggAliases&&s.hostName&&s.hostName!==s.name&&!Object.prototype.hasOwnProperty.call(i,s.hostName)&&(i[s.hostName]=n[r])});for(let[s,r]of e)Object.prototype.hasOwnProperty.call(i,r.alias)||(i[r.alias]=n[s]);return i})}async getCSVAsync(e){let n=[],i=e?25:1e7,s=e?4e3:1e7,r=new Map;for(let u of this._rows){let o={};for(let f=0;f<this._cols.length;f++){let g=this._cols[f],m=u[f];if(this.STR(m)!=""){if(e&&g.dataType=="String")if(r.has(m))m=r.get(m);else{let c=this.obfuscateString(m);r.set(m,c),m=c}else if(g.dataType=="DateTime"&&!g.dateWithTime){let c=m instanceof Date?m:typeof m=="string"?xe(m)??new Date(m):new Date(m);m=(this.wholeDayIso(c)??c.toISOString().slice(0,10))+"T00:00:00.000Z"}s-=this.STR(m).length}else m=null;o[f]=m,--s}if(n.push(o),--i,i<=0||s<=0)break}return await Et.unparse(n,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return Et.unparse([this._cols.map((n,i)=>{if(this.emitLegacyAggAliases&&n.hostName)return this.STR(n.hostName);let s=e.get(i);return this.STR(s&&s.headerName?s.alias:n.name)})])}setHostQueryNames(e){this._hostQueryNames=(e??[]).map(n=>n==null?null:this.STR(n)),this._englishAliases=new Map}aliasesForCode(e){let n=Ne(e,this._cols)?this.legacyAliases():[];for(let i of this.englishAliasesFor(e).values())n.push({name:i.name,alias:i.alias,reason:"english-implicit-agg"});return n}armAliasesForCode(e){return this.emitLegacyAggAliases=Ne(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 i=String(e),s=new Set;for(let a of this._cols)a&&(s.add(this.STR(a.name)),a.hostName&&s.add(this.STR(a.hostName)));let r=new Map;for(let a=0;a<this._cols.length;a++){if(!this._cols[a])continue;let u=mt(this._hostQueryNames[a]).filter(o=>!s.has(o)&&re(i,o));u.length===1&&r.set(u[0],[...r.get(u[0])??[],a])}for(let[a,u]of r){if(u.length!==1)continue;let o=this.STR(this._cols[u[0]].name);n.set(u[0],{name:o,alias:a,headerName:!re(i,o)})}return n}liveEnglishAliases(){let e=new Map;for(let[n,i]of this._englishAliases){let s=this._cols?this._cols[n]:null;s&&this.STR(s.name)===i.name&&e.set(n,i)}return e}addRow(e,n){if(this.dedupRows){let i="";for(let r of e)i+=this.STR(r)+"~";let s=$e(i);if(this._rowHashes.has(s))return!1;this._rowHashes.add(s)}return this._rows.push(Cr(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(i=>this.STR(i?.name)));for(let i of e){if(!i)continue;let s=this.STR(i.name),r=lt(s);!r||r===s||n.has(r)||(n.delete(s),n.add(r),i.hostName=s,i.name=r)}}};export{Je as a,Ot as b,fe as c,Tr as d,nt as e,Yt as f,jt as g,Xt as h,Zt as i,he as j,on as k,lt as l,Ne as m,mt as n,ft as o,cn as p,pt as q,ht as r,Dr as s,Lr as t,kr as u,fn as v,gn as w,pn as x,bt as y,re as z,Nn as A,$r as B,En as C,wn as D,we as E,At as F,Vn as G,Hn as H,Kn as I,qn as J,Rt as K,Nt as L,vt as M,Dt as N,Sr as O,xr as P,_r as Q,wt as R,Cr as S,It as T};