@bicharts/shape-core 0.6.90 → 0.6.92

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 Ut=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],Vt=[7,72,-172,-52];function it(n,e,t){return n>=t[0]&&n<=t[1]&&e>=t[2]&&e<=t[3]}var J=n=>Math.round(n*10)/10;function ot(n,e=3){let t=[],s=[],r=0,i=0;for(let l of n){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;t.push(a),s.push(g);let d=l?.country?String(l.country).trim().toUpperCase():"",m=d?he(d):null;m?((d==="US"||d==="USA")&&r++,m==="north-america"&&i++):(Ut.some(u=>it(a,g,u))&&r++,it(a,g,Vt)&&i++)}let o=t.length;return o<e?null:(t.sort((l,a)=>l-a),s.sort((l,a)=>l-a),{pctUsa:J(r/o*100),pctNa:J(i/o*100),latP5:J(X(t,.05)),latP95:J(X(t,.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 n=new Map;for(let e of Object.keys(st))for(let t of st[e].split(/\s+/))t&&n.set(t,e);return n})();function Kt(n){for(let[e,t]of n){let s=se.get(e);s&&!se.has(t)&&se.set(t,s)}}Kt(et);function he(n){if(!n)return null;let e=String(n).trim().toUpperCase();if(!e)return null;let t=se.get(e);if(t)return t;let s=tt(String(n));return s?se.get(s)??null:null}function Zr(n,e=2){return Te(n.map(t=>[t,1]),e)}function Te(n,e=2){let t=new Map,s=0;for(let[o,l]of n){let a=he(o);if(!a)continue;let g=typeof l=="number"&&isFinite(l)&&l>0?l:1;t.set(a,(t.get(a)??0)+g),s+=g}if(s<e||!t.size)return null;let r="europe",i=-1;for(let o of Array.from(t.keys()).sort()){let l=t.get(o);l>i&&(r=o,i=l)}return{dominantGeoRegion:r,dominantGeoRegionPct:J(i/s*100),regionCount:t.size,n:s}}function Ie(n){let e=(n||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}var we={a:0,b:0,c:0,yearFirst:!1,sep:"",trail:"",word:"",day:0,year:0,namedOrder:"dmy",cjkPattern:""},Ht=/\s+(\d{1,2}):(\d{2})(?::(\d{2})(?:[.,]\d{1,9})?)?(?:\s*([ap])\.?\s?m\.?)?$/i,Yt=/^(\d{1,4})(\s*[./-]\s*)(\d{1,2})(\s*[./-]\s*)(\d{1,4})(\.?)$/,jt=/^(\d{4})(\s*[年년]\s*)(\d{1,2})(\s*[月월]\s*)(\d{1,2})(\s*[日일号])$/,Xt=/(\d)(?:st|nd|rd|th|er|º|ª)(?=[\s.,/-]|$)/gi,Zt=new Set(["de","del","of"]),Qt=new Set(["\u0433","\u0440","r"]),qt=/^[\p{L}\p{M}\u0970\u05f3]+$/u,Re=/^\d+$/;function Jt(n){let e=+n[1],t=+n[2],s=n[3]===void 0?0:+n[3],r=n[4]!==void 0;if(t>59||s>59)return null;if(r){if(e<1||e>12)return null;e=e%12+(n[4].toLowerCase()==="p"?12:0)}else if(e>23)return null;return{h:e,mi:t,s,seconds:n[3]!==void 0,meridiem:r}}function at(n){let e=n.replace(/[\u200e\u200f\u061c]/g,"").replace(/\s+/g," ").trim();if(e==="")return null;e=rt(e);let t=null,s=Ht.exec(e);if(s){if(t=Jt(s),!t)return null;e=e.slice(0,s.index)}let r;if(r=jt.exec(e)){let u=`cjk|${r[2]}|${r[4]}|${r[6]}`;return{...we,form:"cjk",key:u,clock:t,a:+r[1],b:+r[3],c:+r[5],yearFirst:!0,cjkPattern:`%Y${r[2]}%m${r[4]}%d${r[6]}`}}if(r=Yt.exec(e)){let u=r[2],_=r[4];if(u!==_)return null;let M=u.trim(),I=r[6];if(I&&M!==".")return null;let A=[r[1].length,r[3].length,r[5].length],p=A[0]===4,f=A[2]===4;return p===f||(p?A[1]>2||A[2]>2:A[0]>2||A[1]>2)?null:p&&M==="-"&&u==="-"&&A[1]===2&&A[2]===2?"iso":p&&M==="."&&u==="."&&!I&&!(A[1]===2&&A[2]===2)?null:{...we,form:"numeric",key:`num|${p?"y":"x"}|${u}|${I}`,clock:t,a:+r[1],b:+r[3],c:+r[5],yearFirst:p,sep:u,trail:I}}let i=e.replace(Xt,"$1").split(/[\s.,/-]+/).filter(u=>u!==""&&!Zt.has(u.toLowerCase()));if(i.length===4&&Re.test(i[2])&&Qt.has(i[3].toLowerCase())&&i.pop(),i.length!==3)return null;let o=i.map(u=>Re.test(u)?"N":qt.test(u)?"W":"?").join(""),l=i.map(u=>Re.test(u)?u:""),a=0,g=0,d="",m;if(o==="NWN"&&l[0].length<=2&&l[2].length===4)a=+l[0],d=i[1],g=+l[2],m="dmy";else if(o==="WNN"&&l[1].length<=2&&l[2].length===4)d=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],d=i[1],a=+l[2],m="ymd";else return null;return{...we,form:"named",key:`named|${m}`,clock:t,day:a,year:g,word:d,namedOrder:m}}var en=[31,28,31,30,31,30,31,31,30,31,30,31],tn=n=>n%4===0&&n%100!==0||n%400===0;function lt(n,e,t){return n>=1&&n<=9999&&e>=1&&e<=12&&t>=1?t<=(e===2&&tn(n)?29:en[e-1]):!1}function nn(n,e,t,s){let r=new Date(Date.UTC(2e3,e-1,t,s?.h??0,s?.mi??0,s?.s??0));return r.setUTCFullYear(n),r}function ut(n,e={}){let t=(e.floor??1)>=1,s=new Map,r=new Map,i=0,o=null;for(let p of n){if(p==null)continue;if(typeof p!="string"){if(t)return null;i++;continue}let f=p.trim();if(f==="")continue;i++;let b=s.get(f);if(b===void 0&&(b=at(f),s.set(f,b)),b===null||b==="iso"){if(t)return null;continue}if(t){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(!t){let p=0,f="";for(let[b,y]of r)y>p&&(p=y,f=b);if(p===0||p/i<e.floor)return null;o=[...s.values()].find(b=>b!==null&&b!=="iso"&&b.key===f)??null}if(o===null)return null;let l=o.key,a=[...s.values()].filter(p=>p!==null&&p!=="iso"&&p.key===l),g,d="shape",m=null;if(o.form==="named"){if(g=o.namedOrder,m=pe(a.map(p=>p.word),e.locale),!m)return null}else if(o.form==="cjk"||o.yearFirst)g="ymd";else{let p=0,f=0;for(let b of a)b.a>12&&p++,b.b>12&&f++;if(p>0&&f>0)return null;p>0?(g="dmy",d="values"):f>0?(g="mdy",d="values"):o.sep.trim()==="."?(g="dmy",d="shape"):(g=Ie(e.locale)?"mdy":"dmy",d="locale")}let u=p=>{if(p.form==="named"){let f=m.get(q(p.word));return f===void 0?null:[p.year,f+1,p.day]}return p.yearFirst?[p.a,p.b,p.c]:g==="dmy"?[p.c,p.b,p.a]:[p.c,p.a,p.b]},_=1/0,M=-1/0,I=0;for(let p of a){let f=u(p);if(!f||!lt(f[0],f[1],f[2])){if(t)return null;I++;continue}_=Math.min(_,f[0]),M=Math.max(M,f[0])}if(!t&&(r.get(l)-I)/i<e.floor||_>=2400&&M<=2699||_>=1300&&M<=1500)return null;let A={form:o.form,order:g,orderFrom:d,hasTime:a.some(p=>p.clock!==null),read(p){if(typeof p!="string")return null;let f=p.trim();if(f==="")return null;let b=s.get(f);if(b===void 0&&(b=at(f),s.set(f,b)),b===null||b==="iso"||b.key!==l)return null;let y=u(b);return!y||!lt(y[0],y[1],y[2])?null:nn(y[0],y[1],y[2],b.clock)}};if(o.form!=="named"&&!a.some(p=>p.clock?.meridiem)){let p;o.form==="cjk"?p=o.cjkPattern:o.yearFirst?p=`%Y${o.sep}%m${o.sep}%d${o.trail}`:p=(g==="dmy"?`%d${o.sep}%m${o.sep}%Y`:`%m${o.sep}%d${o.sep}%Y`)+o.trail;let f=a.filter(b=>b.clock!==null).length;f===0?A.pattern=p:f===a.length&&(A.pattern=p+(a.every(b=>b.clock.seconds)?" %H:%M:%S":" %H:%M"))}return A}import Bt from"papaparse";var rn=["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"],sn=["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"],on=["latitude","longitude"],an=["latitude","longitude"];function Z(n){return ue(n)}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"],ln=["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"],un=["osszege","sucet","\u7684\u603B\u548C","\u7684\u8BA1\u6570","\u306E\u5408\u8A08","\uC758 \uD569\uACC4"],cn=["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(n){return[...n].sort((e,t)=>t.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(n){for(let e of n){let t=e.codePointAt(0)??0;if(t>=11904&&t<=40959||t>=44032&&t<=55215)return!0}return!1}var mn="[\u2013\u2014-]";function gt(n){let e=n.filter(r=>!ct(r)),t=n.filter(ct),s=[];return e.length&&s.push("(?:\\s+|\\s*"+mn+"\\s*)("+Ne(e)+")"),t.length&&s.push("\\s*("+Ne(t)+")"),new RegExp("(?:"+s.join("|")+")\\s*$","i")}var Ee=gt(un),dn=gt(cn);function be(n,e){let t=e.exec(n);if(!t)return null;let s=n.slice(0,t.index);return s.trim()===""?null:{base:s,label:(t[1]??t[2]??"").toLowerCase()}}function pt(n){let e=Z(String(n??"").trim().toLowerCase());if(!e)return null;for(let r of ln)if(e.startsWith(r+" "))return ye[r]??"avg";for(let r of dt)if(e.startsWith(r+" ")||e===r)return ye[r]??"sum";let t=be(e,dn);if(t)return ye[t.label]??"avg";let s=be(e,Ee);return s?ye[s.label]??"sum":null}var fn=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,gn=new RegExp("\\b("+rn.join("|")+")\\b|("+sn.join("|")+")$","i"),pn=new RegExp("\\b("+on.join("|")+")\\b|("+an.join("|")+")$","i");function Se(n){if(!n)return"";let e=String(n),t=Z(e),s=ft.exec(t);if(s)return e.slice(s[0].length).trim();let r=be(t,Ee);return(r?e.slice(0,r.base.length):e).trim()}function hn(n){if(!n)return!1;let e=Z(String(n));return ft.test(e)||be(e,Ee)!==null}var yn=["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*("+[...yn].sort((n,e)=>e.length-n.length).map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function ht(n){if(n==null)return"";let e=String(n),t=mt.exec(e);if(!t)return e;let s=l=>l.toLowerCase().replace(/\s+/g," ").trim(),r=s(t[1]),i=e.slice(t[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,t[0].length)+i}function ve(n,e){if(!n||!e)return!1;let t=String(n);for(let s of e){let r=s?.hostName;if(r&&r!==s?.name&&t.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 "]},bn=new RegExp("^("+Object.keys(yt).join("|")+")\\((.+)\\)$");function bt(n){if(!n)return[];let e=bn.exec(String(n).trim());if(!e)return[];let t=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 t){let a=l+o;r.includes(a)||r.push(a)}}return r}function Sn(n){let e=Se(n);return e.length===0?"":e.replace(fn," ")}function St(n,e){if(!e)return!1;let t=Se(e);return n.test(Z(Sn(e)))||n.test(Z(t))||n.test(Z(Q(t).join(" ")))}function At(n){return St(pn,n)}function An(n){return St(gn,n)||At(n)}var _t=/int|double|decimal|single|float|number|currency|money/i;function _n(n){let e=String(n?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||n?.isMeasure===!0||_t.test(String(n?.dataType??""))?"Continuous":"Categorical"}function xn(n){return n?.isMeasure===!0||_t.test(String(n?.dataType??""))}function xt(n){let e=n??{},t=_n(e);if(t!=="Continuous")return{nature:t,additivity:"unknown",basis:"role",suppressed:!1};if(At(e.name))return{nature:t,additivity:"positional",basis:"name",suppressed:!0};let s=String(e.additivity??"").trim().toLowerCase();if(!(s==="additive"&&hn(e.name))){if(s==="additive")return{nature:t,additivity:"additive",basis:"measured",suppressed:!1};if(s==="part_of_whole")return{nature:t,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(s==="intensive_rate")return{nature:t,additivity:"intensive_rate",basis:"measured",suppressed:!1}}return e.discourageAggregationAcrossGroups===!0?{nature:t,additivity:"intensive_rate",basis:"host-flag",suppressed:!1}:An(e.name)?{nature:t,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:t,additivity:"additive",basis:"default",suppressed:!1}}function Ct(n){let e=xt(n),t=n??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return xn(t)?["median","average","min","max","first","distinctcount","count"]:["first","distinctcount","count"];switch(e.additivity){case"positional":return["min","max","count","distinctcount","first"];case"intensive_rate":return["average","median","min","max","count","distinctcount","first"];default:return["sum","average","median","min","max","count","distinctcount","first"]}}function ri(n){return Ct(n)[0]}function ii(n,e){return Ct(n).indexOf(e)>=0}function si(n,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let t=xt(n);return t.additivity==="additive"||t.additivity==="part_of_whole"||t.additivity==="unknown"}var Cn={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"]},Mn=["fr","es","pt","it","pl","cs","sk","hr","ru","uk","el","ar","he","id","vi","th"],Tn=["num\xE9ro"],wn=n=>n.normalize("NFC").toLowerCase();function Rn(n,e,t,s){let r=Ce(t);return!r||!n?null:n===e?"word":r.wordBreaks===!1?Array.from(e).length<Ve?null:(s?n.startsWith(e):n.endsWith(e))&&n.length>e.length?"suffix":null:s?$e(n,t).includes(e)?"word":null:r.script==="Hang"?Ue(n,e)?"suffix":null:r.compounds&&ze(n,e,Ge)?"suffix":null}function Mt(n){let e=String(n??"").trim();if(!e)return null;let t=ce(e),s=ce(Se(e));for(let[r,i]of Object.entries(Cn)){let o=Mn.includes(r),l=o?s:t;for(let a of i){let g=Tn.includes(a)||!!Ce(r)?.foldSensitive,d=g?l.words:l.folded;if(d.length===0)continue;let m=g?wn(a):ce(a).folded.join(" "),u=Rn(o?d[0]:d[d.length-1],m,r,o);if(u)return{lang:r,word:a,view:u}}}return null}var In=[["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(n){for(let[e,t]of In)if(t.test(n))return e;return null}var Nn=[{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(n,e,t,s){let r=_e.get(n);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)===t&&(s&&!s.test(g)||i.push(g))}return _e.set(n,i),i}function En(n){let t=n.codePointAt(0);for(let o=0;o<9&&Ae(String.fromCodePoint(t-1))==="Nd";o++)t--;let s="nd:"+t.toString(16),r=_e.get(s);if(r)return r;let i=[];for(let o=t;o<t+10;o++){let l=String.fromCodePoint(o);Ae(l)==="Nd"&&i.push(l)}return _e.set(s,i),i}function vn(n,e){if(e==="Nd")return En(n);for(let r of Nn)if(r.test.test(n))return Tt(r.id+":"+e,r.ranges,e,r.id==="ascii"?null:r.test);let s=n.codePointAt(0)&-128;return Tt("block:"+s.toString(16)+":"+e,[[s,s+127]],e,null)}function kn(n,e,t,s){let r=n.filter(i=>!e.has(i));return r.length===0&&(r=n.filter(i=>i!==t)),r.length===0?t:r[Math.min(r.length-1,Math.floor(s()*r.length))]}var Dn=/^[\p{L}\p{M}\p{Nd}]$/u,wt=/^[\p{L}\p{Nd}]$/u;function Rt(n,e){if(!n)return n??"";let t=new Set(Array.from(n)),s=d=>{let m=Ae(d);return!m||!Dn.test(d)?d:kn(vn(d,m),t,d,e)},r=d=>{let m=[];for(let u of d)m.push(s(u)),wt.test(u)&&e()<.2&&m.push(s(u));if(m.length>6){let u=Math.floor(e()*Math.min(3,m.length-6));for(let _=0;_<u;_++)for(let M=0;M<5;M++){let I=Math.floor(e()*m.length);if(wt.test(m[I])){m.splice(I,1);break}}}return m.join("")};if(!(n.includes("@")&&n.includes(".")))return r(n);let[o,l=""]=n.split("@"),a=l.endsWith(".com"),g=a?l.slice(0,-4):l;return`${r(o)}@${r(g)}${a?".com":""}`}var On=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Ln=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Pn=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(n,e){if(!n||!e)return!1;let t=Ln(e);return new RegExp("['\"`]"+t+"['\"`]").test(n)?!0:On.test(e)&&new RegExp("\\."+t+"(?![A-Za-z0-9_$])").test(n)}function Fn(n){return!!n&&Pn.test(n)}function di(n,e,t){return n?Fn(n)?[...e]:[...t,...e].some(s=>oe(n,s))?e.filter(s=>oe(n,s)):[...e]:[]}var Bn=5,Wn=6,Gn=3,ee=864e5,zn=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,$n=/^(\d{4})[-/](\d{1,2})$/,Un=/^(\d{4})[-\s]?Q([1-4])$/i,Vn=/^Q([1-4])[-\s](\d{4})$/i,Kn=/^(\d{4})$/,Hn=/^(\d{4})(0[1-9]|1[0-2])$/,Yn=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/,jn=/^(\D+?)[\s\-/.,']*((?:19|20)\d{2})$/u,Xn=/^((?:19|20)\d{2})[\s\-/.,']+(\D+)$/u;function ke(n,e,t){let s=q(n);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=t?.get(s);if(r!==void 0)return r+1;let i=ie(n);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 Zn(n){let e=me(n).filter(s=>s.yearDigits===4);if(e.length===0||e.some(s=>s.lang==="en"))return null;let t=e[0];return e.some(s=>s.grain!=="quarter"||s.n!==t.n||s.year!==t.year)?null:H(t.year,(t.n-1)*3+1,1)}function H(n,e,t,s=0,r=0,i=0){if(!(n>=1&&e>=1&&e<=12&&t>=1&&t<=31))return null;let o=Date.UTC(n,e-1,t,s,r,i);if(!Number.isFinite(o))return null;let l=a=>a<10?"0"+a:String(a);return{ms:o,y:n,m:e,d:t,iso:`${n}-${l(e)}-${l(t)}`}}function Qn(n,e){let t=[],s="";for(let a=0;a<e.length;a++){if(e[a]!=="%"){s+=e[a].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");continue}switch(e[++a]){case"Y":t.push("Y"),s+="(\\d{4})";break;case"m":t.push("m"),s+="(\\d{1,2})";break;case"d":t.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(n);if(!r)return null;let i=0,o=1,l=1;return t.forEach((a,g)=>{let d=+r[g+1];a==="Y"?i=d:a==="m"?o=d:l=d}),i?H(i,o,l):null}function re(n,e,t,s){let r=(n??"").trim();if(r==="")return null;if(e){let a=Qn(r,e);return a||null}let i=zn.exec(r);if(i)return H(+i[1],+i[2],+i[3],+(i[4]??0),+(i[5]??0),+(i[6]??0));if(i=Un.exec(r),i)return H(+i[1],(+i[2]-1)*3+1,1);if(i=Vn.exec(r),i)return H(+i[2],(+i[1]-1)*3+1,1);if(i=$n.exec(r),i&&+i[2]>=1&&+i[2]<=12)return H(+i[1],+i[2],1);if(i=Yn.exec(r),i)return H(+i[1],+i[2],+i[3]);if(i=Hn.exec(r),i)return H(+i[1],+i[2],1);if(i=Kn.exec(r),i){let a=+i[1];return a>=1900&&a<=2100?H(a,1,1):null}let o=Zn(r);if(o)return o;if(i=jn.exec(r),i){let a=ke(i[1],t,s);if(a)return H(+i[2],a,1)}if(i=Xn.exec(r),i){let a=ke(i[2],t,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,t,s);if(a)return H(l.year,a,1)}return null}function It(n){let e=new Date(n).getUTCDay();return e>=1&&e<=5}function Nt(n,e){if(e<=n)return 0;let t=Math.round((e-n)/ee),s=Math.floor(t/7),r=s*5,i=n+s*7*ee;for(;i<e;)It(i)&&r++,i+=ee;return r}function qn(n){if(n.length===0)return 0;let e=[...n].sort((s,r)=>s-r),t=e.length>>1;return e.length%2?e[t]:(e[t-1]+e[t])/2}function Jn(n){return n>0?n<.95?"hour":n<=1.05?"day":n>=6.5&&n<=7.5?"week":n>=27&&n<=31.5?"month":n>=88&&n<=93?"quarter":n>=362&&n<=368?"year":"irregular":"irregular"}function ae(n,e,t,s){switch(t){case"year":return e.y-n.y;case"quarter":return e.y*4+Math.floor((e.m-1)/3)-(n.y*4+Math.floor((n.m-1)/3));case"month":return e.y*12+e.m-(n.y*12+n.m);case"week":return Math.round((e.ms-n.ms)/(7*ee));case"weekday":return Nt(n.ms,e.ms);case"day":return Math.round((e.ms-n.ms)/ee);default:return s>0?Math.round((e.ms-n.ms)/s):0}}function Et(n,e){return De(n,e)?.cadence??null}function De(n,e){let t=e?.gapFactor??Bn,s=0,r=0,i=new Map,o=Array.from(n),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<Gn||s>0&&r/s<.8)return null;let g=a[a.length-1].ms-a[0].ms;if(g<=0)return null;let d=[];for(let y=1;y<a.length;y++)d.push(a[y].ms-a[y-1].ms);let m=qn(d);if(!(m>0))return null;let u=Jn(m/ee);u==="day"&&g>=7*ee&&a.every(y=>It(y.ms))&&Nt(a[0].ms,a[a.length-1].ms)+1>a.length*.5&&(u="weekday");let _=u==="irregular"?a.length:ae(a[0],a[a.length-1],u,m)+1,M=1,I=1,A=[],p=a[0],f=1;for(let y=1;y<a.length;y++){let x=ae(a[y-1],a[y],u,m);x>M&&(M=x),u!=="irregular"&&x>t?(I++,A.push({from:p.iso,to:a[y-1].iso,points:f}),p=a[y],f=1):f++}A.push({from:p.iso,to:a[a.length-1].iso,points:f});let b={grain:u,points:a.length,expectedPoints:Math.max(_,a.length),coveragePct:Math.round(a.length/Math.max(_,a.length)*1e3)/10,runs:I,largestGapUnits:M,gapFactor:t};return e?.includeBounds&&A.length<=Wn&&(b.runBounds=A),{cadence:b,points:a,stepMs:m}}var er=8,tr=.5,nr=200,rr=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"]),ir=["category","classification","segment","status","priority","severity","channel"],sr=new Set(["UUID","EMAIL_LIKE","URL_LIKE","PHONE_LIKE","NUMERIC_ID","HEX_ID","OPAQUE_ID_ALPHANUMERIC","DATE_STR","BOOLEAN"]);function or(n){let e=Q(n);if(e.length===0)return!1;let t=e[e.length-1];return rr.has(t)?!0:ir.some(s=>t.length>s.length&&t.endsWith(s))}function ar(n){if(n.isMeasure)return"measure";if(n.isTemporal||n.isDatePart||n.isReassembledDate)return"temporal";let e=Array.from(n.values).filter(t=>t!==""&&t!==null&&t!==void 0);return e.length<2||e.length>nr?"cardinality":n.rows>0&&e.length>=n.rows?"row-identity":n.isBinaryFlag?"flag":de(e,n.locale)!==null?"ordinal":n.identifierNamed||n.dataType==="String"&&sr.has(fe(e))?"identifier":!n.geoKind&&or(n.name)?"attribute":"entity"}function Dt(n){let e=-1,t=1/0,s=!1;return n.forEach((r,i)=>{if(ar(r)!=="entity")return;let o=new Set(Array.from(r.values).filter(a=>a!=="")).size,l=!!r.geoKind;(o<t||o===t&&l&&!s)&&(e=i,t=o,s=l)}),e}var vt=n=>n<10?"0"+n:String(n);function kt(n,e){switch(e){case"year":return`${n.y}-01-01`;case"quarter":return`${n.y}-${vt(Math.floor((n.m-1)/3)*3+1)}-01`;case"month":return`${n.y}-${vt(n.m)}-01`;case"hour":return new Date(n.ms).toISOString().replace(/\.\d{3}Z$/,"Z");default:return n.iso}}function Ot(n){let{periods:e,series:t}=n,s=Math.min(e.length,t.length),r=new Set;for(let x=0;x<s;x++)e[x]&&r.add(e[x]);let i=De(r,{pattern:n.pattern,locale:n.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,n.pattern,n.locale);if(!h)continue;let R=ae(l,h,o,i.stepMs);R>=0&&R<a&&g.set(x,{idx:R,stamp:h})}let d=new Map;for(let x=0;x<s;x++){let h=t[x];if(!h)continue;let R=g.get(e[x]);if(!R)continue;let T=d.get(h);T||(T={seen:new Set,lo:R.idx,hi:R.idx,loStamp:R.stamp,hiStamp:R.stamp,order:d.size},d.set(h,T)),T.seen.add(R.idx),R.idx<T.lo&&(T.lo=R.idx,T.loStamp=R.stamp),R.idx>T.hi&&(T.hi=R.idx,T.hiStamp=R.stamp)}if(d.size<2)return null;let m=0;for(let x of d.values())m+=x.seen.size;if(m/(d.size*a)<(n.minFill??tr))return null;let u=[],_=new Set,M=0,I=0,A=0,p=0,f=0,b=1;for(let[x,h]of d){for(let G of h.seen)_.add(G);if(h.seen.size>=a)continue;let R=[...h.seen].sort((G,j)=>G-j),T=1;for(let G=1;G<R.length;G++)T=Math.max(T,R[G]-R[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};u.push(U),U.before>0&&M++,U.after>0&&I++,U.interior>0&&A++,p=Math.max(p,U.before),f=Math.max(f,U.after),b=Math.max(b,T)}if(u.length===0)return null;u.sort((x,h)=>x.coverage-h.coverage||x.acc.order-h.acc.order);let y=u.slice(0,n.maxListed??er);return{seriesColumn:n.seriesColumn,grain:o,periods:a,seriesCount:d.size,incompleteSeries:u.length,lateStarts:M,earlyEnds:I,withHoles:A,columnWideMissing:a-_.size,maxMissingBefore:p,maxMissingAfter:f,largestGap:b,series:y.map(x=>{let h={};return n.includeNames&&(h.name=x.key),n.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:u.length-y.length}}var lr=5e5,ur=8,cr=4,mr=5,Oe=1,Le=2,dr=4,fr=8;function gr(n,e,t){let[s,r]=[...n];if(e.isTemporal){let i=re(s,e.temporalTextPattern,t),o=re(r,e.temporalTextPattern,t);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 pr(n,e,t){let{rows:s,text:r,locale:i}=n,o=gr(t.values,t,i),l=new Uint8Array(s.length),a=0;for(let g=0;g<s.length;g++){let d=r(s[g][e]);d===o.a?l[g]=1:d===o.b?l[g]=2:a++}return{code:l,blankRows:a,setOrder:o.setOrder}}function hr(n,e){let{rows:t,text:s}=n,r=new Int32Array(t.length),i=new Map;for(let o=0;o<t.length;o++){let l=s(t[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 yr(n,e,t){let s=new Uint8Array(t);for(let i=0;i<n.length;i++){let o=e[i];if(o===0)continue;let l=n[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<t;i++){let o=s[i];o&Oe&&r.keysA++,o&Le&&r.keysB++,(o&(Oe|Le))===(Oe|Le)&&r.keysBoth++,o&dr&&r.dupA++,o&fr&&r.dupB++}return r}function br(n,e){let t=(n.dupA+n.dupB)*(e.keysA+e.keysB),s=(e.dupA+e.dupB)*(n.keysA+n.keysB);return t<s||t===s&&n.keysBoth>e.keysBoth}var Lt=n=>n==null||typeof n=="string"&&n.trim()==="";function Sr(n,e,t){if(n===e)return!0;let s=Lt(n),r=Lt(e);return s||r?s&&r:typeof n=="number"&&typeof e=="number"?!1:n instanceof Date&&e instanceof Date?n.getTime()===e.getTime():t(n).trim()===t(e).trim()}function Pt(n){let{rows:e,columns:t}=n,s=e.length;if(s<2||s>lr)return null;let r=t.map((h,R)=>({c:h,i:R})).filter(({c:h})=>!h.isMeasure&&!h.isTemporal&&!h.isDatePart&&h.distinct>=mr).sort((h,R)=>(R.c.identifierNamed?1:0)-(h.c.identifierNamed?1:0)||R.c.distinct-h.c.distinct||h.i-R.i).slice(0,ur),i=t.map((h,R)=>({c:h,i:R})).filter(({c:h})=>!h.isMeasure&&h.values!==null&&h.values.size===2).slice(0,cr);if(r.length===0||i.length===0)return null;let o=i.map(({c:h,i:R})=>pr(n,R,h)),l=null;for(let{i:h}of r){let R=hr(n,h);for(let T=0;T<i.length;T++){if(i[T].i===h)continue;let U=yr(R.ids,o[T].code,R.dict.size);U.keysBoth<1||(!l||br(U,l.tally))&&(l={tally:U,keyIdx:h,setNo:T,ids:R.ids,dict:R.dict})}}if(!l)return null;let{ids:a,dict:g,tally:d}=l,m=o[l.setNo],u=i[l.setNo].i,_=g.size,M=new Int32Array(_).fill(-1),I=new Int32Array(_).fill(-1);for(let h=0;h<s;h++){let R=m.code[h],T=a[h];R===0||T<0||(R===1?M[T]<0&&(M[T]=h):I[T]<0&&(I[T]=h))}let A=[];for(let h=0;h<t.length;h++)h!==l.keyIdx&&h!==u&&A.push(h);let p=0;for(let h=0;h<_;h++){let R=M[h],T=I[h];if(R<0||T<0)continue;let U=e[R],G=e[T],j=!0;for(let K of A)if(!Sr(U[K],G[K],n.text)){j=!1;break}j&&p++}let f=p===d.keysBoth?100:p===0?0:Math.min(99,Math.max(1,Math.round(p/d.keysBoth*100))),b=new Map,y=new Map;for(let[h,R]of g){let T=M[R]>=0,U=I[R]>=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 R=0;for(let T of h.values())T>=2&&(R+=T);return R};return{key:l.keyIdx,discriminator:u,pairing:{form:"long",key:t[l.keyIdx].name,discriminator:t[u].name,keysA:d.keysA,keysB:d.keysB,keysBoth:d.keysBoth,duplicateKeysA:d.dupA,duplicateKeysB:d.dupB,identicalPct:f,discriminatorBlankRows:m.blankRows,looseCollisionsA:x(b),looseCollisionsB:x(y),setOrder:m.setOrder}}}var Ar=n=>n==="Integer"||n==="Decimal";function _r(n){let e=[],t=[];return n.forEach((s,r)=>{if(s.twoValues){if(s.isBinaryFlag){e.push(r);return}s.isMeasure||s.isTemporal||s.isDatePart||s.identifierNamed||t.push(r)}}),[...e,...t].slice(0,6)}function xr(n,e){let t=[];for(let s=0;s<n.length&&t.length<12;s++){let r=n[s];e.has(s)||!Ar(r.dataType)||r.isTemporal||r.isDatePart||r.identifierNamed||r.distinct<3||t.push(s)}return t}function Ft(n){let e=new Map,{rows:t,columns:s,text:r}=n;if(t.length===0||t.length>(n.maxRows??5e5))return e;let i=_r(s);if(i.length===0)return e;let o=xr(s,new Set(i));if(o.length===0)return e;let l=i.map(a=>{let[g,d]=s[a].twoValues,m=new Uint8Array(t.length);for(let u=0;u<t.length;u++){let _=r(t[u][a]);m[u]=_===g?1:_===d?2:0}return m});for(let a of o){let g=new Float64Array(t.length),d=0;for(let f=0;f<t.length;f++){let b=t[f][a],y=b==null||b===""?NaN:typeof b=="number"?b:parseFloat(b);g[f]=y,y===y&&y!==1/0&&y!==-1/0&&d++}if(d<2)continue;let m=new Float64Array(d);for(let f=0,b=0;f<t.length;f++){let y=g[f];y===y&&y!==1/0&&y!==-1/0&&(m[b++]=y)}m.sort();let u=new Float64Array(d),_=0;for(let f=0;f<d;f++)(f===0||m[f]!==m[f-1])&&(u[_++]=m[f]);let M=new Int32Array(t.length).fill(-1);for(let f=0;f<t.length;f++){let b=g[f];if(!(b===b&&b!==1/0&&b!==-1/0))continue;let y=0,x=_-1;for(;y<x;){let h=y+x>>>1;u[h]<b?y=h+1:x=h}M[f]=y}let I=[],A=new Int32Array(_),p=new Int32Array(_);for(let f=0;f<i.length;f++){let b=l[f];A.fill(0),p.fill(0);let y=0,x=0;for(let S=0;S<t.length;S++){let P=M[S];P<0||(b[S]===1?(A[P]++,y++):b[S]===2&&(p[P]++,x++))}if(y===0||x===0)continue;let h=y<=x,R=h?y:x,T=h?x:y,U=h?A:p,G=h?p:A,j=0,K=0,c=0;for(let S=0;S<_;S++){let P=U[S],k=G[S];j+=P*(K+.5*k),K+=k,P+k>=2&&(c+=P+k)}I.push({outcome:s[i[f]].name,aucMinorityHigh:Math.round(j/(R*T)*1e4)/1e4,nMinority:R,nMajority:T,ties:c})}I.length>0&&e.set(a,I)}return e}var Cr=12,Mr=100,Tr=.3,wr=.9,Rr=120,Ir=1900,Nr=2100,Er=0,vr=20,kr=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function xe(n){if(!n)return!1;let e=Q(n);return e.length===0?!1:kr.has(e[e.length-1])?!0:Mt(n)!==null}var Dr=new Set(["year","yr","fy"]),Or=n=>Q(n).some(e=>Dr.has(e))||Xe(n)!==null,Lr=/^(?:(?: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(n){if(!Number.isInteger(n)||n<190001||n>210012)return!1;let e=n%100;return e>=1&&e<=12}function Fe(n){if(!Number.isInteger(n)||n<19000101||n>21001231)return!1;let e=Math.floor(n/100)%100,t=n%100;return e>=1&&e<=12&&t>=1&&t<=31}var Pr=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Fr=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,Br=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function zt(n,e){let t=[],s=0,r=Wr(n,e,t,()=>{s++});if(r)return r;if(s>0||t.length<2)return null;let i=ut(t,{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 Wr(n,e,t,s){let r=0,i=0,o=0,l=0,a=0,g="",d=0,m="",u=0,_=0,M=0,I=0,A=!1;for(let h of n){if(h==null)continue;let R=String(h).trim();if(R==="")continue;r++,t.push(R);let T;if(T=Pr.exec(R)){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=Fr.exec(R)){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=Br.exec(R)){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],d++,U>12&&M++,G>12&&I++,T[5]!==void 0&&u++,T[7]!==void 0&&_++)}if(r>=200)break}if(r<2||(i+a+d)/r<.8||(i>0?1:0)+(a>0?1:0)+(d>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&&I>0)return null;let b,y;M>0?(b=!0,y="values"):I>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 u===d?{pattern:x+(_===d?" %H:%M:%S":" %H:%M"),orderFrom:y}:{pattern:x,orderFrom:y}}function Gr(n,e){if(!e||!/\b(?:19|20)\d{2}\b/.test(n))return!1;let t=n.replace(/\b(?:19|20)\d{2}\b/g,"").replace(/[-/.,]/g," ").trim();if(!t)return!1;let s=q(t);return s.length>0&&e[s]!==void 0}function zr(n,e){let t=new Map,s=new Map;for(let l of n){let a=ne(l);if(!a||"month"in a)continue;let g=ie(a.word),d=g.some(u=>u.lang==="en"),m=q(a.word);for(let u of new Set(g.map(_=>_.lang)))u!=="en"&&(t.has(u)||(t.set(u,new Set),s.set(u,new Set)),t.get(u).add(m),d||s.get(u).add(m))}let r=[...t.keys()].filter(l=>t.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 d=g.some(m=>m.lang==="en");for(let m of r)(d||g.some(u=>u.lang===m))&&o.set(m,o.get(m)+1)}return i+Math.max(0,...o.values())}var $r=/(?:19|20)[0-9]{2}/;function Ur(n){let e=new Map,t=0;for(let r of n){if(!$r.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")){t++;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+t:0}function Vr(n){let{dataType:e,name:t,isMeasure:s,distinctCount:r}=n;if(e==="DateTime")return!0;if(s)return!1;if(e==="Integer"||e==="Decimal"){let i=n.minNum,o=n.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&&Or(t)||a&&r>=3&&r===o-i+1)return!0;let g=Pe(i)&&Pe(o),d=Fe(i)&&Fe(o);if(g||d){if(!n.sampleValues)return!0;let m=0,u=0;for(let _ of n.sampleValues){if(_==null||_==="")continue;m++;let M=Number(String(_).trim());if(Number.isFinite(M)&&(g?Pe(M):Fe(M))&&u++,m>=60)break}if(m>=2&&u===m)return!0}return!1}if(n.sampleValues){let i=n.locale?ge(n.locale):null,o=0,l=0,a=[],g=[];for(let d of n.sampleValues){if(d==null||d==="")continue;o++;let m=String(d).trim();if(a.push(m),Lr.test(m)||Gr(m,i)?l++:g.push(m),o>=60)break}if(o>=2&&l/o>=.8||o>=2&&(l+Ur(g)+zr(a,g))/o>=.8||zt(a,n.locale)!==null)return!0}return!1}function Kr(n){let e=Z((n||"").trim().toLowerCase());return e.startsWith("sum ")||e.startsWith("total ")?"sum":e.startsWith("average ")||e.startsWith("avg. ")?"avg":e.startsWith("count ")||e.startsWith("distinct count ")||e.startsWith("count (distinct) ")?"count":e.startsWith("min ")||e.startsWith("minimum ")?"min":e.startsWith("max ")||e.startsWith("maximum ")?"max":pt(n)}function Hr(n){let{rows:e,measureColIdx:t,measureName:s,candidateDims:r,minNum:i,maxNum:o,discourageAgg:l}=n,a=100,g=.01,d="";for(let u of r){if(u.distinct<2||u.distinct>a)continue;let _=r.filter(f=>f.idx!==u.idx).map(f=>f.idx),M=new Map;for(let f of e){let b=f[t];if(typeof b!="number"||!Number.isFinite(b))continue;let y=_.length?_.map(h=>String(f[h])).join(d):"",x=M.get(y);x||(x={sum:0,cset:new Set},M.set(y,x)),x.sum+=b,x.cset.add(String(f[u.idx]))}let I=0,A=0,p=0;for(let f of M.values())f.cset.size<2||(p++,Math.abs(f.sum-100)<=100*g?I++:Math.abs(f.sum-1)<=1*g&&A++);if(p>=2&&(I/p>=.9||A/p>=.9))return{additivity:"part_of_whole",partOfWholeDim:u.name}}if(l)return{additivity:"intensive_rate"};let m=Kr(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 $t(n){let{dataType:e,isMeasure:t,name:s,distinct:r,nonblank:i,prec:o,maxval:l,minval:a}=n,g=l-a+1,d=g>0?r/g:1,m=i>0?r/i:0,u=e==="Decimal"||o>0;return!t&&xe(s)?"Categorical":d>=wr&&(qe(s)&&r<=Rr||a>=Ir&&l<=Nr||a>=Er&&l<=vr)?"Ordinal":t||r>Cr&&(u||r>=Mr||m>=Tr)?"Continuous":"Categorical"}function Wt(n,e,t){return!n||n.isMeasure||e||n.dataType!=="Integer"&&n.dataType!=="Decimal"?!1:$t({dataType:n.dataType,isMeasure:!1,name:n.name,distinct:t.distinct,nonblank:t.nonblank,prec:t.prec,maxval:typeof t.maxval=="number"?t.maxval:0,minval:typeof t.minval=="number"?t.minval:0})==="Continuous"}function Yr(n){let e=null;for(let t=0;t<n.length;t++){let s=n[t];if(typeof s!="string"||s.length===0)continue;let r=s.trim();r.length!==s.length&&(e||(e=n.slice()),e[t]=r)}return e||n}var Gt=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;_declaredDimensions=new WeakSet;_inferredMeasureFlags=null;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}inferredMeasureFlags(){if(this._inferredMeasureFlags)return this._inferredMeasureFlags;let e=this._cols.map(t=>!!(t&&t.isMeasure));return this._cols.forEach((t,s)=>{if(!t||t.isMeasure||this._declaredDimensions.has(t)||t.dataType!=="Integer"&&t.dataType!=="Decimal")return;let r=new Set,i=0,o=0,l=null,a=null;for(let g of this._rows){let d=g[s],m=this.STR(d);if(m!=""&&(r.add(m),i++,(l===null||d<l)&&(l=d),(a===null||d>a)&&(a=d),t.dataType=="Decimal")){let u=this.getPrecision(d);u>o&&(o=u)}}e[s]=Wt(t,!1,{distinct:r.size,nonblank:i,prec:o,minval:l,maxval:a})}),Object.freeze(e),this._inferredMeasureFlags=e,e}declareDimensions(e){this._inferredMeasureFlags=null;for(let t of e)t&&this._declaredDimensions.add(t)}wholeDayIso(e){return je(e)}hasTimeComponent(e){return!(e instanceof Date)||isNaN(e.getTime())?!1:this.wholeDayIso(e)===null}getColumnsWithStats(e,t){if(this._computedStatsForLevel==e)return this._cols;let s=0,r=parseInt(e),i=[],o=[],l=[];for(let c 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 N of this._rows){let w=N[s],B=this.STR(w);if(B!=""){if(k+=B.length,S.set(B,(S.get(B)||0)+1),C++,c.dataType=="Integer"||c.dataType=="Decimal"||c.dataType=="DateTime")if((F===null||w<F)&&(F=w),(L===null||w>L)&&(L=w),c.dataType=="Integer"||c.dataType=="Decimal"){if(D===null?D=w:D+=w,c.dataType=="Decimal"){let V=this.getPrecision(w);V>O&&(O=V)}P.push(w)}else z=z||this.hasTimeComponent(w);$&&(w<v?W=!1:w>v&&(E=!1)),v=w,$=!0}}if(C>=3&&(W&&!E?c.sortedDirection="asc":E&&!W?c.sortedDirection="desc":c.sortedDirection="none"),C>0&&S.size>0&&!c.isMeasure){let N=0,w=Number.MAX_SAFE_INTEGER;for(let B of S.values())B>N&&(N=B),B<w&&(w=B);if(c.modalShare=N/C,c.minGroupCount=w===Number.MAX_SAFE_INTEGER?null:w,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(c.name);(Y||te)&&(c.isBinaryFlag=!0)}}else c.isMeasure&&(c.dataType==="Integer"||c.dataType==="Decimal")&&S.size===2&&S.has("0")&&S.has("1")&&(c.isBinaryFlag=!0);if(c.dataType=="DateTime"&&(c.dateWithTime=z),c.isTemporal=Vr({dataType:c.dataType,name:c.name,isMeasure:c.isMeasure,distinctCount:S.size,minNum:typeof F=="number"?F:null,maxNum:typeof L=="number"?L:null,sampleValues:S.keys(),locale:t}),c.isTemporal&&c.dataType==="String"&&!c.isMeasure){let N=zt(S.keys(),t);N&&(c.temporalTextPattern=N.pattern)}if(c.isTemporal&&!c.isMeasure){let N=Et(S.keys(),{includeBounds:r>=20,pattern:c.temporalTextPattern,locale:t});N&&(c.temporalCadence=N)}this.updateColumnStats10(r,c,C,S,O,L,F),this.updateColumnStats20(r,P,C,D,c,k,z,F,L,O,S,t),Wt(c,this._declaredDimensions.has(c),{distinct:S.size,nonblank:C,prec:O,minval:F,maxval:L})&&(c.isMeasure=!0,c.geoKind=void 0,c.geoMatchPct=void 0,c.geoAmbiguous=void 0,c.dominantGeoRegion=void 0,c.dominantGeoRegionPct=void 0,c.geoRegionCount=void 0),i[s]=c.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((c,S)=>{c.isMeasure||a.push({idx:S,distinct:c.distinctCount??0,name:c.name})}),this._cols.forEach((c,S)=>{if(!c.isMeasure)return;let P=typeof c.lowValue=="number"?c.lowValue:null,k=typeof c.highValue=="number"?c.highValue:null,C=Hr({rows:this._rows,measureColIdx:S,measureName:c.name,candidateDims:a,minNum:P,maxNum:k,discourageAgg:!!c.discourageAggregationAcrossGroups});c.additivity=C.additivity,C.partOfWholeDim&&(c.partOfWholeDim=C.partOfWholeDim)});let g=50,d=4,m=a.filter(c=>c.distinct>=2&&c.distinct<=g);this._cols.forEach((c,S)=>{if(!c.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])c.relativeDispersion=0;else if(k.length>=d){let E=X(k,.5),v=X(k,.1),$=X(k,.9);c.relativeDispersion=Math.abs(E)>1e-9?Math.round(($-v)/Math.abs(E)*1e3)/1e3:void 0}else c.relativeDispersion=void 0;let C=[];for(let E of m){let v=new Set;for(let $ of this._rows){let N=$[S];N==null||N===""||v.add(this.STR($[E.idx])+"")}C.push({otherColumn:E.name,nonBlankGroupCount:v.size})}C.length>0&&(c.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((N,w)=>N-w),$=N=>v[Math.min(v.length-1,Math.max(0,Math.floor(N*(v.length-1))))];return $(.75)-$(.25)},W=z(P);for(let E of m){let v=new Map;for(let w of this._rows){let B=w[S];if(B==null||B==="")continue;let V=typeof B=="number"?B:parseFloat(B);if(isNaN(V))continue;let Y=this.STR(w[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 w of v.values()){let B=w.s/w.n;$+=w.n*(B-O)*(B-O)}L.push({otherColumn:E.name,eta2:Math.round($/F*1e4)/1e4});let N=[];for(let w of v.values()){let B=z(w.vals);isNaN(B)||N.push(B)}if(N.length>=2&&isFinite(W)&&W>1e-9){let w=(Math.max(...N)-Math.min(...N))/W;D.push({otherColumn:E.name,spreadRatio:Math.round(w*1e4)/1e4})}}L.length>0&&(c.groupDiscrimination=L),D.length>0&&(c.spreadDiscrimination=D)});let u=.97,_=.8,M=8,I=5,A=this._cols.map((c,S)=>({c,i:S})).filter(c=>c.c.isMeasure);for(let c=0;c<A.length;c++)for(let S=c+1;S<A.length;S++){let P=A[c].i,k=A[S].i,C=0,O=0,F=0,L=0,D=0,z=0;for(let N of this._rows){let w=N[P],B=N[k];if(w==null||w===""||B===null||B===void 0||B==="")continue;let V=typeof w=="number"?w:parseFloat(w),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<I)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 N of[A[c].c,A[S].c])(N.maxAbsMeasureCorrelation===void 0||$>N.maxAbsMeasureCorrelation)&&(N.maxAbsMeasureCorrelation=$);if(Math.abs(v)>=u){let N=A[c].c,w=A[S].c;N.collinearWithMeasures||(N.collinearWithMeasures=[]),w.collinearWithMeasures||(w.collinearWithMeasures=[]),N.collinearWithMeasures.push(w.name),w.collinearWithMeasures.push(N.name)}else if(Math.abs(v)>=_){let N=A[c].c,w=A[S].c,B=Math.round(v*1e3)/1e3;N.correlatedWithMeasures||(N.correlatedWithMeasures=[]),w.correlatedWithMeasures||(w.correlatedWithMeasures=[]),N.correlatedWithMeasures.push({otherColumn:w.name,r:B}),w.correlatedWithMeasures.push({otherColumn:N.name,r:B})}}for(let{c}of A)c.correlatedWithMeasures&&(c.correlatedWithMeasures.sort((S,P)=>Math.abs(P.r)-Math.abs(S.r)||(S.otherColumn<P.otherColumn?-1:1)),c.correlatedWithMeasures.length=Math.min(c.correlatedWithMeasures.length,M));for(let c=0;c<this._cols.length;c++){let S=i[c];if(!S||S.size===0)continue;let P=[];for(let k=0;k<this._cols.length;k++){if(k===c)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[c].sharedValueRatioWithOthers=P)}let p=50,f=[];for(let c=0;c<this._cols.length;c++){let S=i[c];S&&S.size>=2&&S.size<=p&&f.push(c)}if(f.length>=2){let c=new Map,S=(k,C)=>k+":"+C;for(let k=0;k<f.length;k++)for(let C=k+1;C<f.length;C++)c.set(S(f[k],f[C]),new Map);for(let k of this._rows)for(let C=0;C<f.length;C++){let O=this.STR(k[f[C]])+"";for(let F=C+1;F<f.length;F++){let L=""+this.STR(k[f[F]]),D=c.get(S(f[C],f[F])),z=O+""+L;D.set(z,(D.get(z)??0)+1)}}let P=new Map;for(let k=0;k<f.length;k++)for(let C=k+1;C<f.length;C++){let O=f[k],F=f[C],L=i[O].size,D=i[F].size,z=c.get(S(O,F)),W=z.size,E=0;for(let w of z.values())(E===0||w<E)&&(E=w);let v=Math.round(W/(L*D)*100),$=W===L,N=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:N,minCellCount:E,distinctCombinations:W}),$&&L>D){let w=P.get(O);(!w||D<w.card)&&P.set(O,{name:this._cols[F].name,card:D,ratio:D/L})}if(N&&D>L){let w=P.get(F);(!w||L<w.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 c=0;c<this._cols.length;c++){let S=this._cols[c];if(S.isMeasure||S.primaryParentColumn)continue;let P=S.distinctCount??0;if(P<=p||y>0&&P>=y)continue;let k=[];for(let C=0;C<this._cols.length;C++){if(C===c)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[c])+"",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,R=.95,T=8,U=8,G=6,j=500,K=[];for(let c=0;c<this._cols.length&&K.length<U;c++){let S=this._cols[c].dataType;(S==="Double"||S==="Integer"||S==="Decimal")&&K.push(c)}if(K.length>=3&&this._rows.length>=T){let c=Math.min(this._rows.length,j),S=K.map(L=>{let D=[];for(let E=0;E<c;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 N of D)$+=N[v];W[v]=$}let E=k(W);if(E>0){let v=0;for(let N of W)Math.abs(N-E)<=E*x&&v++;let $=v/z;if($>=R){let N=1;for(let w of D){let B=k(w)/E;B<N&&(N=B)}N>=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(t,i),this.applyScoreSeparation(o,l),this.applySeriesCompleteness(r,t,i),this._computedStatsForLevel=e,this._cols}applyTwoSetPairing(e,t){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=t[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,t){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:t[i]??null})),text:r=>this.STR(r)});for(let[r,i]of s)this._cols[r].scoreSeparation=i}applySeriesCompleteness(e,t,s){for(let u of this._cols)u.seriesCompleteness!==void 0&&delete u.seriesCompleteness;let r=this._cols.map((u,_)=>({c:u,i:_})).filter(({c:u})=>u.isTemporal&&!u.isMeasure&&u.temporalCadence&&u.temporalCadence.grain!=="irregular");if(r.length===0)return;let i=[],o=[];this._cols.forEach((u,_)=>{let M=s[_];M&&(i.push(_),o.push({name:u.name,dataType:u.dataType,isMeasure:!!u.isMeasure,isTemporal:!!u.isTemporal,isDatePart:!!u.isDatePart,isReassembledDate:!!u.isReassembledDate,isBinaryFlag:!!u.isBinaryFlag,geoKind:u.geoKind,identifierNamed:xe(u.name),values:M,rows:this._rows.length,locale:t}))});let l=Dt(o);if(l<0)return;let a=i[l],g=this._cols[a],d=this._rows.map(u=>this.STR(u[a])),m=e>=20&&(g.dataType!=="String"||Array.isArray(g.safeDistinctValues));for(let{c:u,i:_}of r){let M=Ot({periods:this._rows.map(I=>this.STR(I[_])),series:d,seriesColumn:g.name,pattern:u.temporalTextPattern,locale:t,includeDates:e>=20,includeNames:m});M&&(u.seriesCompleteness=M)}}updateColumnStats20(e,t,s,r,i,o,l,a,g,d,m,u){if(e>=20){let _=[...t].sort((A,p)=>A-p),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=p=>{let f=p instanceof Date?p:typeof p=="string"?Me(p)??new Date(p):new Date(p),b=this.wholeDayIso(f);return b?b+"T00:00:00.000Z":isNaN(f.getTime())?p:f.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=d}if(_.length>0){let A=i.avgValue??0,p=_.length,f=0,b=0;for(let x of _){let h=x-A;f+=h*h,b+=h*h*h}let y=f/p;i.skewness=y===0?0:b/p/Math.pow(Math.sqrt(y),3),i.stdDev=Math.sqrt(y)}r!==null&&(i.sum=r);let I=Array.from(m.entries()).sort((A,p)=>p[1]-A[1]);if(i.topCategories=I.slice(0,10).map(A=>A[1]),!i.isMeasure&&I.length>0&&(i.dataType!=="String"&&(i.topCategoryValues=I.slice(0,5).map(A=>A[0])),e>=20)){let A=I.map(f=>f[0]),p=de(A,u);if(p!==null)i.ordinalPattern=p.pattern,i.orderedDomain=p.orderedDomain;else if(i.dataType==="String"){let f=Je(A);f!==null&&(i.safeDistinctValues=f)}}if(_.length>=8&&(i.dataType==="Integer"||i.dataType==="Decimal")){let A=p=>_[Math.floor((_.length-1)*p)];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,p)=>p[1]-A[1]).map(A=>A[0]);i.formatSignature=fe(_);let M=s>0?o/s:void 0,I=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;i.formatSignature&&!I.test(i.formatSignature)&&(M===void 0||M>=3)&&(i.isFreeText=!0)}if(!i.isMeasure&&m.size>0){let _=Array.from(m.entries()).sort((I,A)=>A[1]-I[1]),M=nt(_.map(I=>I[0]),i.name,u);if(M!==null&&(i.geoKind=M.geoKind,i.geoMatchPct=M.geoMatchPct,M.geoAmbiguous&&(i.geoAmbiguous=!0),M.geoKind.indexOf("country")===0)){let I=Te(_);I&&(i.dominantGeoRegion=I.dominantGeoRegion,i.dominantGeoRegionPct=I.dominantGeoRegionPct,i.geoRegionCount=I.regionCount)}}}updateColumnStats10(e,t,s,r,i,o,l){let a=this._rows.length-s;e>=10&&(t.blankCount=a),t.distinctCount=r.size+(a!=0?1:0),t.valueNature="Categorical",s>0&&(t.dataType==="Integer"||t.dataType==="Decimal"?t.valueNature=$t({dataType:t.dataType,isMeasure:!!t.isMeasure,name:t.name,distinct:r.size,nonblank:s,prec:i,maxval:o,minval:l}):t.dataType==="DateTime"&&(t.valueNature=t.dateWithTime?"Continuous":"Ordinal"))}getRowCount(){return this._rows.length}getLeafCardinality(){if(this._leafCardinality!==null)return this._leafCardinality;let e=[];if(this._cols.forEach((s,r)=>{s.isMeasure||e.push(r)}),e.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let t=new Set;for(let s of this._rows)t.add(JSON.stringify(e.map(r=>s[r])));return this._leafCardinality=t.size,this._leafCardinality}_leafCardinality=null;getGeoExtent(){if(this._geoExtentComputed)return this._geoExtent;this._geoExtentComputed=!0,this._geoExtent=null;let e=o=>We(o,{camel:!0}),t=-1,s=-1,r=-1;if(this._cols.forEach((o,l)=>{let a=e(o.name),g=o.dataType==="Integer"||o.dataType==="Decimal";g&&t<0&&a.some(d=>d==="lat"||d==="latitude")?t=l:g&&s<0&&a.some(d=>d==="lon"||d==="lng"||d==="long"||d==="longitude")&&(s=l),r<0&&!o.isMeasure&&typeof o.geoKind=="string"&&o.geoKind.indexOf("country")===0&&(r=l)}),t<0||s<0)return null;let i=[];for(let o of this._rows){let l=o[t],a=o[s],g=l==null||l===""?null:Number(l),d=a==null||a===""?null:Number(a);i.push({lat:g,lon:d,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 Rt(e,Ye)}toObjectArray(){let e=this.liveEnglishAliases();return this._rows.map(t=>{let s={};this._cols.forEach((r,i)=>{s[r.name]=t[i],this.emitLegacyAggAliases&&r.hostName&&r.hostName!==r.name&&!Object.prototype.hasOwnProperty.call(s,r.hostName)&&(s[r.hostName]=t[i])});for(let[r,i]of e)Object.prototype.hasOwnProperty.call(s,i.alias)||(s[i.alias]=t[r]);return s})}async getCSVAsync(e){let t=[],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 d=this._cols[g],m=l[g];if(this.STR(m)!=""){if(e&&d.dataType=="String")if(i.has(m))m=i.get(m);else{let u=this.obfuscateString(m);i.set(m,u),m=u}else if(d.dataType=="DateTime"&&!d.dateWithTime){let u=m instanceof Date?m:typeof m=="string"?Me(m)??new Date(m):new Date(m);m=(this.wholeDayIso(u)??u.toISOString().slice(0,10))+"T00:00:00.000Z"}r-=this.STR(m).length}else m=null;a[g]=m,--r}if(t.push(a),--s,s<=0||r<=0)break}return await Bt.unparse(t,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return Bt.unparse([this._cols.map((t,s)=>{if(this.emitLegacyAggAliases&&t.hostName)return this.STR(t.hostName);let r=e.get(s);return this.STR(r&&r.headerName?r.alias:t.name)})])}setHostQueryNames(e){this._hostQueryNames=(e??[]).map(t=>t==null?null:this.STR(t)),this._englishAliases=new Map}aliasesForCode(e){let t=ve(e,this._cols)?this.legacyAliases():[];for(let s of this.englishAliasesFor(e).values())t.push({name:s.name,alias:s.alias,reason:"english-implicit-agg"});return t}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 t of this.liveEnglishAliases().values())e.push({name:t.name,alias:t.alias,reason:"english-implicit-agg"});return e}legacyAliases(){let e=[];for(let t of this._cols)t&&t.hostName&&t.hostName!==t.name&&e.push({name:this.STR(t.name),alias:this.STR(t.hostName),reason:"doubled-agg-prefix"});return e}englishAliasesFor(e){let t=new Map;if(!e||this._hostQueryNames.length===0||!this._cols||this._cols.length===0)return t;let 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);t.set(l[0],{name:a,alias:o,headerName:!oe(s,a)})}return t}liveEnglishAliases(){let e=new Map;for(let[t,s]of this._englishAliases){let r=this._cols?this._cols[t]:null;r&&this.STR(r.name)===s.name&&e.set(t,s)}return e}addRow(e,t){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(Yr(e)),this._inferredMeasureFlags=null,this._origIndices.push(t??-1),!0}getOriginalRowIndex(e){return e<0||e>=this._origIndices.length?-1:this._origIndices[e]}reset(){this._inferredMeasureFlags=null,this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null,this._hostQueryNames=[],this._englishAliases=new Map}setColumns(e){if(this._inferredMeasureFlags=null,this._cols=e,!e||e.length===0)return;let t=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||t.has(i)||(t.delete(r),t.add(i),s.hostName=r,s.name=i)}}};export{ot as a,Kt as b,he as c,Zr as d,ut as e,rn as f,sn as g,on as h,an as i,Se as j,hn as k,ht as l,ve as m,bt as n,At as o,An as p,xt as q,Ct as r,ri as s,ii as t,si as u,Cn as v,Mn as w,Tn as x,Mt as y,oe as z,Fn as A,di as B,Bn as C,Wn as D,re as E,Et as F,er as G,tr as H,nr as I,ar as J,Dt as K,Ot as L,xe as M,zt as N,Vr as O,Kr as P,Hr as Q,$t as R,Wt as S,Yr as T,Gt as U};
@@ -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-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};
2
+ import{M as R,U as I,e as L}from"./chunk-TBH5LFYH.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-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 P,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)&&!P(a)).length,o=t.filter(a=>!te(a)&&!!P(a)).length;return n>=1&&n>=o}function ce(e,t){if(!P(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)P(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=>!!P(G)),Ne=ee(S,G=>!!P(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),v=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:v(t("isServiceError")),isRateLimited:v(t("isRateLimited")),suppressSelectionGlyph:v(t("suppressSelectionGlyph")),isRefusal:v(t("isRefusal")),isVersionNotFound:v(t("isVersionNotFound")),isGenerationCancelled:v(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:v(l("isPreview")),alsoWorthALook:v(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:v(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,P 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};
2
+ import{a as Hn,b as Kn}from"./chunk-HIVICMC5.mjs";import{a as Bn,b as I,c as jn,d as D,e as E,f as Yn,g as X,h as J}from"./chunk-QMVECPSM.mjs";import{a as qn,b as $n,c as zn}from"./chunk-ZKRTZ3TY.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,S as Un,U as Wn,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-TBH5LFYH.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 P,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)&&!P(a)).length,o=t.filter(a=>!te(a)&&!!P(a)).length;return n>=1&&n>=o}function ce(e,t){if(!P(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)P(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 Qn(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 Xn(e,t){let n=0;for(let o of oe(e))t(o)&&n++;return n}function Jn(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=>!!P(G)),Ne=ee(S,G=>!!P(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)&&!(Xn(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=Qn(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")}),Zn=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 er(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 tr(e,t){let n=String(e??"").trim().normalize("NFC");if(!n)return null;for(let o of er(n,t)){let a=ie[o];if(a&&a.langs.includes(t))return a.part}return null}function nr(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 rr=/\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)),rr.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 or(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 ir(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 sr(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 ar(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),v=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},lr=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function Re(e,t){let n={};for(let[o,a]of lr){let u=m(E(e,t+a));u&&(n[o]=u)}return n}function ur(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 cr(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:ur(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:v(t("isServiceError")),isRateLimited:v(t("isRateLimited")),suppressSelectionGlyph:v(t("suppressSelectionGlyph")),isRefusal:v(t("isRefusal")),isVersionNotFound:v(t("isVersionNotFound")),isGenerationCancelled:v(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 dr(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:v(l("isPreview")),alsoWorthALook:v(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:v(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 mr(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 fr(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 pr="FREEMIUM_ATTEMPT_SPENT",gr="CLIENT_SECRET_MISMATCH",yr="FREEMIUM_COLUMN_CAP",hr="OAUTH_TOKEN_EXPIRED",Cr="OAUTH_SIGNED_OUT";function br(e){let t=e?.retryable;return typeof t=="boolean"?t:null}function Er(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 Tr(e){let{width:t,height:n}=e.measure();return{request:{height:n,width:t},hints:{viewportWidth:t,viewportHeight:n}}}function Sr(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 Rr(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 xr(e){let t=n=>e.renderers.has(n);return{supportsD3:t("D3"),supportsPlotly:t("PLOTLY"),supportsVega:t("VEGA")}}function wr(e){let t=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??t,maxTries:t}}function _r(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}function Or(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 vr={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 Pr(e){let t=Oe(e);return t?{qualifyOrder:t}:{}}function ve(e,t){return e!=null&&t!=null&&e!==t}function Lr(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 Ar=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 Ar[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 Mr(e){return j(Le(e))}var Ir=2,Nr=3,Fr=4,Dr=64,kr=8e3,Gr=6e4,Vr=Object.freeze({RENDER_START:"render-start",RENDER_OK:"render-ok",RENDER_ERROR:"render-error",VIEW:"view",VIEW_VERDICT:"view-verdict",REDRAW:"redraw",INTERACT:"interact"}),Ur=Object.freeze(["open","generate","version","rebind","data","sample","fix","resize","other"]);function Wr(e,t){return t?`${t};draw:${e}`:`draw:${e}`}function qr(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 $r(){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 zr(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 Hr(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 Kr(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 Br(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=Kr(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,jr="/LLMChart/",Yr="/LLMChart/qualify",Qr="/VisionReview/",Xr="/LLMChart/sample",Jr="/RefundGenerate/",Zr=e=>!!e&&typeof e=="object"&&e.name==="TimeoutError",H=async e=>JSON.parse(await e.text());function eo(e){try{e.body?e.body.cancel().catch(()=>{}):e.text().catch(()=>{})}catch{}}function to(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&&Zr(_),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)eo(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",jr,I(g),c,b=>J(b,p))},async qualify(g,f){let c=y("qualify",f),p=c.route??Yr;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",Qr,p,c,H)},async sample(g,f){let c=y("sample",f);return C("sample",Xr,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",Jr,JSON.stringify({CorrelationID:g.trim()}),c,H)}}}export{Y as CITY_ROLE_MATCH_PCT,Vr as CLIENT_EVENT_KINDS,gr 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,Zn 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,Ur as DRAW_REASONS,pr as FREEMIUM_ATTEMPT_SPENT,yr 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,Wn as IndexedText,xt as LOOSE_KEY_MIN_LENGTH,_t as LooseIndex,wn as MAX_RUN_BOUNDS,Cr as OAUTH_SIGNED_OUT,hr 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,Hn as PREVIEW_OMITTED_FIELDS,we as PROGRESS_STAGE_IDS,vr 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,Fr as SEV_ERROR,Ir as SEV_INFO,Dr as SEV_USER_PRESENTED,Nr as SEV_WARNING,j as SIMPLE_STRING_HASH,tt as STR,Ze as SUBSTRING_MIN,Fe as SUPPORTED_LANGUAGES,De as SUPPORTED_LANGUAGE_CODES,Gr as TELEMETRY_TIMEOUT_DEV_MS,kr as TELEMETRY_TIMEOUT_MS,Ve as VOCABULARY_LANGUAGE_CODES,Ge as VOCABULARY_ONLY_LANGUAGES,mt as YEAR_WORDS,$ as admin1MatchPct,fn as allowedAggregations,br as answerIsRetryable,$t as buildGeoIsoColumn,kt as buildGeoPointColumns,pt as calendarWordIn,xr as capabilityFields,Vt as cityMatchPct,Gt as cityTagsFor,Gn as classifyAdditivity,qr 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,$r as createDrawLedger,to as createGenerateClient,Hr as createTelemetryClient,Er as credentialFields,Or as dataCompletenessFields,tr as dateLevelPart,nr as dateLevelYearAdmits,Yt as decimalSeparatorOf,pn as defaultAggregation,Qt as detectDecimalSeparator,jt as detectFormatSignature,Ut as detectGeo,Pt as detectOrdinalDomain,Fn as detectTextDatePattern,Wr as drawLocation,I as encodePayload,qn as engineTypeForSqlType,un as englishImplicitAggNames,se as eventLogLine,Rr as fetchFields,Br as fetchTransport,We as foldName,ar as freemiumColumnCapRefusal,Ee as freemiumColumnsOverCap,Te as freemiumDateHierarchyClauses,Qe as gluedPrefixStems,sr as guardColumnNames,Bn as gzipWireText,Je as hangulWordEndsWith,sn as hasDefaultAggPrefix,He as hasUnsegmentedScript,kn as hostAggHint,zn as ingest,gn as isAggregationAllowed,V as isBlankLike,At as isCityTableLoaded,z as isColumnContextRef,rt as isDeterministicRefusal,zr as isEventLogCode,Ft as isGeoPointAmbiguity,Nn as isIdentifierName,qt as isJoinGeoKind,Yn as isNdjsonContentType,Ot as isOrdinalFriendlyName,wt as isUsableLooseKey,jn as keyedSigner,_r 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,Sr as maxNonMeasureCardinality,On as measureCadence,In as measureSeriesCompleteness,D as messageSignature,ir as missingHardColumnRefs,Zt as monthLookupFor,$e as nameLetterRuns,dn as nameLooksIntensiveRate,cn as nameLooksPositional,he as nameProbeIsGuarded,or as nameProbeKeepsDrawing,qe as nameWords,Mt as normalizeCountry,ct as normalizeLocalMidnightDates,Jt as normalizeMonthKey,U as normalizePlaceName,Nt as normalizeZip5,Lr as offeredShortlistFor,$n as parseCsvRows,it as parseDateStable,cr as parseGenerateResponse,Xt as parseNumberText,dr as parseQualifyResponse,mr as parseReviewVerdict,_n as parseTemporalPoint,Kn as payloadPreview,St as periodCodeSeries,Mn as pickSeriesColumn,fr as progressStageOf,Un as promotesToMeasure,Pr as qualifyOrderField,Oe as qualifyOrderOf,J as readGenerateStream,ze as readName,Tt as readPeriodCode,E as readWireField,Lt as registerCityTable,Ht as registerIso3Regions,P as resolveAdmin1,_e as resolveFetchVersion,Dt as resolveGeoPoint,Ue as resolveLanguage,Jn as resolvePointRoles,wr as retryFields,vt as safeDistinctValuesToShip,Le as schemaIdentity,Mr 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,Tr 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-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};
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,U as i}from"./chunk-TBH5LFYH.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{i as IndexedText,e as classifyAdditivity,f as classifyNumericValueNature,c as classifyTemporal,b as detectTextDatePattern,d as hostAggHint,a as isIdentifierName,g as promotesToMeasure,h 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-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};
2
+ import{a,b,c}from"./chunk-ZKRTZ3TY.mjs";import"./chunk-TBH5LFYH.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};
@@ -1,6 +1,6 @@
1
1
  export { IndexedText } from "./indexedText";
2
2
  export type { IValueCollection, ColumnNameAlias } from "./indexedText";
3
- export { classifyTemporal, detectTextDatePattern, classifyAdditivity, classifyNumericValueNature, hostAggHint, isIdentifierName, } from "./indexedText";
3
+ export { classifyTemporal, detectTextDatePattern, classifyAdditivity, classifyNumericValueNature, promotesToMeasure, hostAggHint, isIdentifierName, } from "./indexedText";
4
4
  export type { TextDateDetection } from "./indexedText";
5
5
  export { measureCadence, parseTemporalPoint, DEFAULT_GAP_FACTOR, MAX_RUN_BOUNDS } from "./cadence";
6
6
  export type { TemporalCadence, TemporalRun } from "./cadence";
@@ -47,6 +47,18 @@ export declare function classifyNumericValueNature(i: {
47
47
  maxval: number;
48
48
  minval: number;
49
49
  }): ValueNature;
50
+ /**
51
+ * THE MEASURE-INFERENCE VERDICT for one column - the one rule both the stats pass and inferredMeasureFlags use, so a
52
+ * host that renders without profiling hands its code the same flags the shape carried. A column already a measure,
53
+ * one the caller declared a dimension, and anything but an Integer/Decimal are never promoted.
54
+ */
55
+ export declare function promotesToMeasure(col: LLMColumnWithValue, declaredDimension: boolean, s: {
56
+ distinct: number;
57
+ nonblank: number;
58
+ prec: number;
59
+ minval: unknown;
60
+ maxval: unknown;
61
+ }): boolean;
50
62
  export interface IValueCollection {
51
63
  addRow(colvals: any[], originalIdx?: number): boolean;
52
64
  setColumns(cols: LLMColumnWithValue[]): void;
@@ -66,6 +78,7 @@ export interface IValueCollection {
66
78
  getCSVHeaderLine(): string;
67
79
  getColumnsWithStats(privacyLevel: string, locale?: string): LLMColumnWithValue[];
68
80
  getColumns(): LLMColumnWithValue[];
81
+ inferredMeasureFlags?(): readonly boolean[];
69
82
  toObjectArray(): Record<string, any>[];
70
83
  getOriginalRowIndex(i: number): number;
71
84
  emitLegacyAggAliases?: boolean;
@@ -114,6 +127,7 @@ export declare class IndexedText implements IValueCollection {
114
127
  private _hostQueryNames;
115
128
  private _englishAliases;
116
129
  private _declaredDimensions;
130
+ private _inferredMeasureFlags;
117
131
  /**
118
132
  * Collapse value-identical rows on addRow. DEFAULT TRUE — the long-standing behaviour,
119
133
  * and the right one for shape measurement. See addRow for when to turn it off.
@@ -139,6 +153,13 @@ export declare class IndexedText implements IValueCollection {
139
153
  private STR;
140
154
  private getPrecision;
141
155
  getColumns(): LLMColumnWithValue[];
156
+ /**
157
+ * Which columns are measures as the shape would say - the flags the stats pass ends with - WITHOUT running that pass and
158
+ * without changing any column. A host that renders code generated against the shape (and has not profiled since its
159
+ * data was last indexed) reads this to hand the code the flags it was written for. One scan of the numeric columns
160
+ * not already measures; cached until rows or columns change.
161
+ */
162
+ inferredMeasureFlags(): readonly boolean[];
142
163
  /**
143
164
  * Mark columns as dimensions BY DECLARATION, so measure inference in getColumnsWithStats
144
165
  * never promotes them. Pass the same objects given to setColumns, before the stats pass.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/shape-core",
3
- "version": "0.6.90",
3
+ "version": "0.6.92",
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 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};