@bicharts/shape-core 0.6.133 → 0.6.134

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
- import{R,Z as N,f as L}from"./chunk-R7VGZR7L.mjs";import{a as h,c as x,d as A,e as I}from"./chunk-TZ74QIKA.mjs";import{u as C}from"./chunk-CZJ7M6A5.mjs";import k from"papaparse";var O=["#N/A","#NV","#N/D","#N/D!","#N/B","#\u041D/\u0414","#I/T","#PUUTTUU!","#SAKNAS!","#HI\xC1NYZIK","#NEN\xCD_K_DISPOZICI","#YOK","#GETTING_DATA"],j=new Set(O.map(e=>e.toUpperCase())),$=/^#[\p{Lu}\p{Nd}_/.¡¿]{1,24}[!?]$/u;function w(e){if(typeof e!="string")return!1;let o=e.trim();return o.length<2||o[0]!=="#"?!1:j.has(o.toUpperCase())||$.test(o)}var M=500,P=/^[+-]?\d{1,15}$/,v=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,V=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function q(e,o=".",n=!1){if(n)return"DateTime";let r=0,a=0,i=0,l=0;for(let c of e){if(c==null)continue;if(typeof c=="number"){l++,a++,Number.isInteger(c)&&r++;continue}if(c instanceof Date){l++,i++;continue}if(typeof c=="boolean"){l++;continue}let m=String(c).trim();if(m!==""){if(l++,P.test(h(m))){r++,a++;continue}if(I(m,o)){a++;continue}if((v.test(m)||V.test(m))&&!isNaN(Date.parse(m))){i++;continue}}}return l===0?"String":i===l?"DateTime":r===l?"Integer":a===l?"Decimal":"String"}function F(e,o){let n=r=>!!r&&o.some((a,i)=>a&&w(r[i]));return e.some(n)?e.map(r=>n(r)?r.map((a,i)=>o[i]&&w(a)?null:a):r):e}function U(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=h(a);return P.test(i)?parseInt(i,10):null}case"Decimal":return A(a,n);case"DateTime":return r?r.read(a):C(a);default:return a}}function G(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*W(e,o){for(let n of e)yield n?.[o]}function p(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;o=F(o,e.map(t=>t.dataType===void 0));let a=e.map((t,s)=>o.slice(0,M).map(u=>u?.[s])),i=a.map(t=>x(t,n.locale)),l=e.map((t,s)=>t.dataType===void 0||t.dataType==="DateTime"?L(W(o,s),{locale:n.locale??"en"}):null),c=e.map((t,s)=>t.dataType??q(a[s],i[s],l[s]!==null)),m=new Set((n.measures??[]).map(t=>t.toLowerCase())),D=new Set((n.dimensions??[]).map(t=>t.toLowerCase())),_=new Set((n.nonAdditive??[]).map(t=>t.toLowerCase())),S=e.map((t,s)=>{let u=t.name.toLowerCase(),f=t.isMeasure??((c[s]==="Integer"||c[s]==="Decimal")&&!R(t.name));m.has(u)&&(f=!0),D.has(u)&&(f=!1);let E={name:t.name,dataType:c[s],isMeasure:f};return f&&_.has(u)&&(E.discourageAggregationAcrossGroups=!0),E}),d=new N;d.dedupRows=n.dedup!==!1,d.deriveProvinces=n.deriveProvinces!==!1,d.setColumns(S),d.declareDimensions(S.filter((t,s)=>D.has(e[s].name.toLowerCase())));for(let t=0;t<o.length;t++){let s=o[t];d.addRow(Array.from({length:r},(u,f)=>U(s?.[f],c[f],i[f],l[f])),t)}let g=d.getColumnsWithStats(n.privacyLevel??"20",n.locale??"en"),T=new Map(g.map(t=>[t.name,t]));e.forEach(t=>{let s=T.get(t.name);s&&(t.format&&(s.modelFormat=t.format),t.description&&(s.modelDesc=t.description))});let y=t=>{let s=T.get(t);if(s)return[s];let u=t.toLowerCase();return g.filter(f=>f.name.toLowerCase()===u)};for(let[t,s]of Object.entries(n.formats??{}))for(let u of y(t))u.modelFormat=s;for(let[t,s]of Object.entries(n.descriptions??{}))for(let u of y(t))u.modelDesc=s;for(let t of n.groupBy??[])for(let s of y(t))s.isGrouping=!0;return{columns:g,rows:d.toObjectArray(),totalRows:d.getRowCount(),index:d}}function b(e,o){return e.map(n=>Array.isArray(n)?n:o.map(r=>n[r]))}function B(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 c of Object.keys(l))r.has(c)||(r.add(c),n.push(c))}return n}function K(e){let o=String(e??"").replace(/^\uFEFF/,""),n=[],r=[],a=0;return k.parse(o,{skipEmptyLines:!1,step:i=>{let l=i.meta.cursor,c=o.slice(a,l);a=l,i.errors?.length&&r.push(...i.errors);let m=i.data;m.length===1&&m[0]===""&&c.replace(/[\r\n]/g,"")===""||n.push(m)}}),!n.length&&!r.length&&r.push(...k.parse(o,{skipEmptyLines:!0}).errors),{rows:n,errors:r}}function ee(e,o={}){switch(e.kind){case"csv":{let n=K(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 p(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 p(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 p(e.columns,b(e.rows??[],n),o)}case"objects":{let n=e.rows??[],r=e.columns?.length?e.columns:B(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 p(r,b(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=G(r.dataType);return{name:r.name,dataType:a,isMeasure:r.isMeasure,format:r.format,description:r.description}});return p(n,b(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{O as a,w as b,G as c,K as d,ee as e};
2
+ import{R,Z as N,f as L}from"./chunk-UHEXA4HI.mjs";import{a as h,c as x,d as A,e as I}from"./chunk-TZ74QIKA.mjs";import{u as C}from"./chunk-CZJ7M6A5.mjs";import k from"papaparse";var O=["#N/A","#NV","#N/D","#N/D!","#N/B","#\u041D/\u0414","#I/T","#PUUTTUU!","#SAKNAS!","#HI\xC1NYZIK","#NEN\xCD_K_DISPOZICI","#YOK","#GETTING_DATA"],j=new Set(O.map(e=>e.toUpperCase())),$=/^#[\p{Lu}\p{Nd}_/.¡¿]{1,24}[!?]$/u;function w(e){if(typeof e!="string")return!1;let o=e.trim();return o.length<2||o[0]!=="#"?!1:j.has(o.toUpperCase())||$.test(o)}var M=500,P=/^[+-]?\d{1,15}$/,v=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,V=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function q(e,o=".",n=!1){if(n)return"DateTime";let r=0,a=0,i=0,l=0;for(let c of e){if(c==null)continue;if(typeof c=="number"){l++,a++,Number.isInteger(c)&&r++;continue}if(c instanceof Date){l++,i++;continue}if(typeof c=="boolean"){l++;continue}let m=String(c).trim();if(m!==""){if(l++,P.test(h(m))){r++,a++;continue}if(I(m,o)){a++;continue}if((v.test(m)||V.test(m))&&!isNaN(Date.parse(m))){i++;continue}}}return l===0?"String":i===l?"DateTime":r===l?"Integer":a===l?"Decimal":"String"}function F(e,o){let n=r=>!!r&&o.some((a,i)=>a&&w(r[i]));return e.some(n)?e.map(r=>n(r)?r.map((a,i)=>o[i]&&w(a)?null:a):r):e}function U(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=h(a);return P.test(i)?parseInt(i,10):null}case"Decimal":return A(a,n);case"DateTime":return r?r.read(a):C(a);default:return a}}function G(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*W(e,o){for(let n of e)yield n?.[o]}function p(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;o=F(o,e.map(t=>t.dataType===void 0));let a=e.map((t,s)=>o.slice(0,M).map(u=>u?.[s])),i=a.map(t=>x(t,n.locale)),l=e.map((t,s)=>t.dataType===void 0||t.dataType==="DateTime"?L(W(o,s),{locale:n.locale??"en"}):null),c=e.map((t,s)=>t.dataType??q(a[s],i[s],l[s]!==null)),m=new Set((n.measures??[]).map(t=>t.toLowerCase())),D=new Set((n.dimensions??[]).map(t=>t.toLowerCase())),_=new Set((n.nonAdditive??[]).map(t=>t.toLowerCase())),S=e.map((t,s)=>{let u=t.name.toLowerCase(),f=t.isMeasure??((c[s]==="Integer"||c[s]==="Decimal")&&!R(t.name));m.has(u)&&(f=!0),D.has(u)&&(f=!1);let E={name:t.name,dataType:c[s],isMeasure:f};return f&&_.has(u)&&(E.discourageAggregationAcrossGroups=!0),E}),d=new N;d.dedupRows=n.dedup!==!1,d.deriveProvinces=n.deriveProvinces!==!1,d.setColumns(S),d.declareDimensions(S.filter((t,s)=>D.has(e[s].name.toLowerCase())));for(let t=0;t<o.length;t++){let s=o[t];d.addRow(Array.from({length:r},(u,f)=>U(s?.[f],c[f],i[f],l[f])),t)}let g=d.getColumnsWithStats(n.privacyLevel??"20",n.locale??"en"),T=new Map(g.map(t=>[t.name,t]));e.forEach(t=>{let s=T.get(t.name);s&&(t.format&&(s.modelFormat=t.format),t.description&&(s.modelDesc=t.description))});let y=t=>{let s=T.get(t);if(s)return[s];let u=t.toLowerCase();return g.filter(f=>f.name.toLowerCase()===u)};for(let[t,s]of Object.entries(n.formats??{}))for(let u of y(t))u.modelFormat=s;for(let[t,s]of Object.entries(n.descriptions??{}))for(let u of y(t))u.modelDesc=s;for(let t of n.groupBy??[])for(let s of y(t))s.isGrouping=!0;return{columns:g,rows:d.toObjectArray(),totalRows:d.getRowCount(),index:d}}function b(e,o){return e.map(n=>Array.isArray(n)?n:o.map(r=>n[r]))}function B(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 c of Object.keys(l))r.has(c)||(r.add(c),n.push(c))}return n}function K(e){let o=String(e??"").replace(/^\uFEFF/,""),n=[],r=[],a=0;return k.parse(o,{skipEmptyLines:!1,step:i=>{let l=i.meta.cursor,c=o.slice(a,l);a=l,i.errors?.length&&r.push(...i.errors);let m=i.data;m.length===1&&m[0]===""&&c.replace(/[\r\n]/g,"")===""||n.push(m)}}),!n.length&&!r.length&&r.push(...k.parse(o,{skipEmptyLines:!0}).errors),{rows:n,errors:r}}function ee(e,o={}){switch(e.kind){case"csv":{let n=K(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 p(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 p(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 p(e.columns,b(e.rows??[],n),o)}case"objects":{let n=e.rows??[],r=e.columns?.length?e.columns:B(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 p(r,b(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=G(r.dataType);return{name:r.name,dataType:a,isMeasure:r.isMeasure,format:r.format,description:r.description}});return p(n,b(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{O as a,w as b,G as c,K as d,ee as e};
@@ -0,0 +1,2 @@
1
+ /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
+ import{a as Se}from"./chunk-U3H6UBOO.mjs";import{a as wt,f as te,g as _e,h as oe,i as Ae,j as ie}from"./chunk-TZ74QIKA.mjs";import{b as St,c as _t,d as At,e as Ct,f as xt}from"./chunk-YDYFP2T4.mjs";import{c as ht,l as yt,n as ye,p as bt,s as se,w as be,x as De,y as Oe,z as Pe}from"./chunk-DTBXJVUG.mjs";import{e as dt,k as pe,m as gt,n as pt,o as he}from"./chunk-3ZAS32F5.mjs";import{b as mt,d as ft}from"./chunk-5HI6TVMM.mjs";import{A as ge,B as ut,E as ct,a as re,b as ee,c as Je,d as me,g as et,h as tt,j as nt,l as rt,m as it,o as st,p as fe,q as ot,r as at,u as ke,w as lt}from"./chunk-CZJ7M6A5.mjs";import{c as Qe,f as Ee}from"./chunk-WC4JINEZ.mjs";var pn=85,hn=60,yn=/(^|[^a-z])(state|province|provincia|provinz|region|regione|regiao|county|department|departement|departamento|prefecture|oblast|canton|kanton|bundesland|land|territory)([^a-z]|$)/i,Le=t=>Math.round(t*10)/10,Ce=t=>t.split("-")[0];function Mt(t){let e=new Map,n=0;if(t.forEach((i,a)=>{let l=ye(a);l&&(e.set(l,(e.get(l)||0)+i),n+=i)}),n===0)return{};let[s,r]=[...e].sort((i,a)=>a[1]-i[1])[0];return{dominantRegion:s,dominantRegionPct:Le(100*r/n)}}function Ti(t){let e=t.province===null||t.province===void 0?"":String(t.province).trim();if(e)return Tt(e,t.provinceKind,t.country);if(!se())return null;let n=t.city===null||t.city===void 0?"":String(t.city).trim();if(!n)return null;let s=be(n,{country:t.country===null||t.country===void 0?null:String(t.country)});return s.status==="resolved"?s.provinceId:null}function Tt(t,e,n){if(e==="us-state-code"||e==="us-state-name"){let i=xt(t,e);return i?"US-"+i:null}if(!se())return null;if(e==="admin1-code")return Pe(t)?t.toUpperCase():null;let s=n==null?null:String(n),r=new Set(De(t,s).map(Oe).filter(i=>!!i));return r.size===1?[...r][0]:null}function vi(t,e={}){let n=e.deriveProvinces!==!1,s=new Array(t.length),r=new Array(t.length),i=new Set,a=[],l=new Set,o=[],u=0,c=0,f=0,m=C=>{let S=C.toLowerCase();i.has(S)||(i.add(S),a.push(C))},h=C=>C==null||C===""?null:Number(C),w=new Map;return t.forEach((C,S)=>{s[S]=null,r[S]=null;let g=C.country===null||C.country===void 0||String(C.country).trim()===""?null:String(C.country).trim(),y=C.province===null||C.province===void 0?"":String(C.province).trim();if(y){let x=Tt(y,e.provinceKind,g);x?(s[S]=x,r[S]="province",u++):m(y);return}if(!n)return;let A=h(C.lat),p=h(C.lon),_=!1;if(e.locate&&A!==null&&p!==null&&isFinite(A)&&isFinite(p)){_=!0;let x=e.locate(A,p);if(x){s[S]=x,r[S]="coordinates",u++;return}}let b=C.city===null||C.city===void 0?"":String(C.city).trim();if(b&&se()){let x=b.toLowerCase()+""+(g??""),M=w.get(x);if(M||(M=be(b,{country:g}),w.set(x,M)),M.status==="resolved"&&M.provinceId){s[S]=M.provinceId,r[S]="city",u++;return}if(M.status==="ambiguous"){c++,l.has(x)||(l.add(x),o.length<8&&o.push(b));return}m(b);return}_&&f++}),{iso:s,source:r,unmatched:a,matchedRows:u,totalRows:t.length,ambiguousRows:c,ambiguousExamples:o,unplacedPoints:f}}function vt(t,e,n={}){let s=new Map;if(!se()||e.length===0)return s;let r=t.findIndex(l=>!l.isMeasure&&(l.geoKind||"").startsWith("country")),i=l=>l==null?"":String(l).trim(),a=l=>{let o=new Map;for(let h of e){let w=i(h[l]);if(!w)continue;let C=r>=0&&i(h[r])||null,S=w+""+(C??""),g=o.get(S);g?g.rows++:o.set(S,{city:w,country:C,rows:1})}if(o.size===0)return null;let u=0,c=0,f=new Set,m=new Map;return o.forEach(h=>{let w=be(h.city,{country:h.country});w.status!=="unmatched"&&c++,!(w.status!=="resolved"||!w.provinceId)&&(u++,f.add(w.provinceId),m.set(w.cc,(m.get(w.cc)||0)+h.rows))}),{signals:{rollupPct:Le(100*u/o.size),regionCount:f.size,countryCount:m.size,...Mt(m)},cityPct:100*c/o.size,distinct:o.size}};return t.forEach((l,o)=>{if(l.isMeasure||o===r)return;let u=l.geoKind||"";if(u.startsWith("city")){if(n.cities===!1)return;let x=a(o);x&&s.set(o,x.signals);return}if(u)return;let c=new Map,f=new Map;for(let x of e){let M=i(x[o]);M&&(c.set(M,(c.get(M)||0)+1),f.has(M)||f.set(M,r>=0&&i(x[r])||null))}if(c.size<3)return;let m=0,h=0,w=0,C=new Set,S=new Map;c.forEach((x,M)=>{if(Pe(M)){m++;let z=M.toUpperCase();C.add(z),S.set(Ce(z),(S.get(Ce(z))||0)+x);return}let W=new Set(De(M,f.get(M)).map(Oe).filter(z=>!!z));if(W.size===1){h++;let z=[...W][0];C.add(z),S.set(Ce(z),(S.get(Ce(z))||0)+x)}else W.size>1&&w++});let y=yn.test(l.name.replace(/[_-]+/g," "))?hn:pn,A=100*m/c.size,p=100*h/c.size,_=A>=p,b=_?A:p;if(b<y){if(n.cities===!1)return;let x=a(o);if(!x||x.cityPct<ht||x.distinct<At&&!_t(l.name,St))return;s.set(o,x.signals);return}s.set(o,{kind:_?"admin1-code":"admin1-name",matchPct:Le(b),ambiguous:!_&&w/c.size>.15?!0:void 0,regionCount:C.size,countryCount:S.size,...Mt(S)})}),s}function We(t){let e=(t||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}var Fe={a:0,b:0,c:0,yearFirst:!1,sep:"",trail:"",word:"",day:0,year:0,namedOrder:"dmy",cjkPattern:""},bn=/\s+(\d{1,2}):(\d{2})(?::(\d{2})(?:[.,]\d{1,9})?)?(?:\s*([ap])\.?\s?m\.?)?$/i,Sn=/^(\d{1,4})(\s*[./-]\s*)(\d{1,2})(\s*[./-]\s*)(\d{1,4})(\.?)$/,_n=/^(\d{4})(\s*[年년]\s*)(\d{1,2})(\s*[月월]\s*)(\d{1,2})(\s*[日일号])$/,An=/(\d)(?:st|nd|rd|th|er|º|ª)(?=[\s.,/-]|$)/gi,Cn=new Set(["de","del","of"]),xn=new Set(["\u0433","\u0440","r"]),wn=/^[\p{L}\p{M}\u0970\u05f3]+$/u,ze=/^\d+$/;function Mn(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 Rt(t){let e=t.replace(/[\u200e\u200f\u061c]/g,"").replace(/\s+/g," ").trim();if(e==="")return null;e=wt(e);let n=null,s=bn.exec(e);if(s){if(n=Mn(s),!n)return null;e=e.slice(0,s.index)}let r;if(r=_n.exec(e)){let m=`cjk|${r[2]}|${r[4]}|${r[6]}`;return{...Fe,form:"cjk",key:m,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=Sn.exec(e)){let m=r[2],h=r[4];if(m!==h)return null;let w=m.trim(),C=r[6];if(C&&w!==".")return null;let S=[r[1].length,r[3].length,r[5].length],g=S[0]===4,y=S[2]===4;return g===y||(g?S[1]>2||S[2]>2:S[0]>2||S[1]>2)?null:g&&w==="-"&&m==="-"&&S[1]===2&&S[2]===2?"iso":g&&w==="."&&m==="."&&!C&&!(S[1]===2&&S[2]===2)?null:{...Fe,form:"numeric",key:`num|${g?"y":"x"}|${m}|${C}`,clock:n,a:+r[1],b:+r[3],c:+r[5],yearFirst:g,sep:m,trail:C}}let i=e.replace(An,"$1").split(/[\s.,/-]+/).filter(m=>m!==""&&!Cn.has(m.toLowerCase()));if(i.length===4&&ze.test(i[2])&&xn.has(i[3].toLowerCase())&&i.pop(),i.length!==3)return null;let a=i.map(m=>ze.test(m)?"N":wn.test(m)?"W":"?").join(""),l=i.map(m=>ze.test(m)?m:""),o=0,u=0,c="",f;if(a==="NWN"&&l[0].length<=2&&l[2].length===4)o=+l[0],c=i[1],u=+l[2],f="dmy";else if(a==="WNN"&&l[1].length<=2&&l[2].length===4)c=i[0],o=+l[1],u=+l[2],f="mdy";else if(a==="NWN"&&l[0].length===4&&l[2].length<=2)u=+l[0],c=i[1],o=+l[2],f="ymd";else return null;return{...Fe,form:"named",key:`named|${f}`,clock:n,day:o,year:u,word:c,namedOrder:f}}var Tn=[31,28,31,30,31,30,31,31,30,31,30,31],vn=t=>t%4===0&&t%100!==0||t%400===0;function It(t,e,n){return t>=1&&t<=9999&&e>=1&&e<=12&&n>=1?n<=(e===2&&vn(t)?29:Tn[e-1]):!1}function Rn(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 Nt(t,e={}){let n=(e.floor??1)>=1,s=new Map,r=new Map,i=0,a=null;for(let g of t){if(g==null)continue;if(typeof g!="string"){if(n)return null;i++;continue}let y=g.trim();if(y==="")continue;i++;let A=s.get(y);if(A===void 0&&(A=Rt(y),s.set(y,A)),A===null||A==="iso"){if(n)return null;continue}if(n){if(a===null)a=A;else if(A.key!==a.key)return null}else r.set(A.key,(r.get(A.key)??0)+1)}if(!n){let g=0,y="";for(let[A,p]of r)p>g&&(g=p,y=A);if(g===0||g/i<e.floor)return null;a=[...s.values()].find(A=>A!==null&&A!=="iso"&&A.key===y)??null}if(a===null)return null;let l=a.key,o=[...s.values()].filter(g=>g!==null&&g!=="iso"&&g.key===l),u,c="shape",f=null;if(a.form==="named"){if(u=a.namedOrder,f=Ae(o.map(g=>g.word),e.locale),!f)return null}else if(a.form==="cjk"||a.yearFirst)u="ymd";else{let g=0,y=0;for(let A of o)A.a>12&&g++,A.b>12&&y++;if(g>0&&y>0)return null;g>0?(u="dmy",c="values"):y>0?(u="mdy",c="values"):a.sep.trim()==="."?(u="dmy",c="shape"):(u=We(e.locale)?"mdy":"dmy",c="locale")}let m=g=>{if(g.form==="named"){let y=f.get(te(g.word));return y===void 0?null:[g.year,y+1,g.day]}return g.yearFirst?[g.a,g.b,g.c]:u==="dmy"?[g.c,g.b,g.a]:[g.c,g.a,g.b]},h=1/0,w=-1/0,C=0;for(let g of o){let y=m(g);if(!y||!It(y[0],y[1],y[2])){if(n)return null;C++;continue}h=Math.min(h,y[0]),w=Math.max(w,y[0])}if(!n&&(r.get(l)-C)/i<e.floor||h>=2400&&w<=2699||h>=1300&&w<=1500)return null;let S={form:a.form,order:u,orderFrom:c,hasTime:o.some(g=>g.clock!==null),read(g){if(typeof g!="string")return null;let y=g.trim();if(y==="")return null;let A=s.get(y);if(A===void 0&&(A=Rt(y),s.set(y,A)),A===null||A==="iso"||A.key!==l)return null;let p=m(A);return!p||!It(p[0],p[1],p[2])?null:Rn(p[0],p[1],p[2],A.clock)}};if(a.form!=="named"&&!o.some(g=>g.clock?.meridiem)){let g;a.form==="cjk"?g=a.cjkPattern:a.yearFirst?g=`%Y${a.sep}%m${a.sep}%d${a.trail}`:g=(u==="dmy"?`%d${a.sep}%m${a.sep}%Y`:`%m${a.sep}%d${a.sep}%Y`)+a.trail;let y=o.filter(A=>A.clock!==null).length;y===0?S.pattern=g:y===o.length&&(S.pattern=g+(o.every(A=>A.clock.seconds)?" %H:%M:%S":" %H:%M"))}return S}import ln from"papaparse";var In={es:["latitud"],pt:["latitude"],fr:["latitude"],it:["latitudine"],nl:["breedtegraad"],de:["breitengrad"]},Nn={es:["longitud"],pt:["longitude"],fr:["longitude"],it:["longitudine"],nl:["lengtegraad"],de:["l\xE4ngengrad"]},$e=t=>re(t.normalize("NFC")).toLowerCase(),En=new Set(Object.values(In).flatMap(t=>(t??[]).map($e))),kn=new Set(Object.values(Nn).flatMap(t=>(t??[]).map($e)));function Et(t){let e=!1,n=!1;for(let s of t){let r=$e(s);En.has(r)?e=!0:kn.has(r)&&(n=!0)}return e===n?null:e?"lat":"lon"}var Dn=["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"],On=["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"],Pn=["latitude","longitude"],Ln=["latitude","longitude"];function Q(t){return re(t)}var Ot=["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"],Fn=["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"],zn=["osszege","sucet","\u7684\u603B\u548C","\u7684\u8BA1\u6570","\u306E\u5408\u8A08","\uC758 \uD569\uACC4"],Wn=["atlaga","priemer","\u7684\u5E73\u5747\u503C","\u306E\u5E73\u5747","\uC758 \uD3C9\uADE0"],xe=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 Be(t){return[...t].sort((e,n)=>n.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var Pt=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+Be(Ot)+")\\s+)","i");function kt(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 $n="[\u2013\u2014-]";function Lt(t){let e=t.filter(r=>!kt(r)),n=t.filter(kt),s=[];return e.length&&s.push("(?:\\s+|\\s*"+$n+"\\s*)("+Be(e)+")"),n.length&&s.push("\\s*("+Be(n)+")"),new RegExp("(?:"+s.join("|")+")\\s*$","i")}var Ge=Lt(zn),Bn=Lt(Wn);function we(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 Ft(t){let e=Q(String(t??"").trim().toLowerCase());if(!e)return null;for(let r of Fn)if(e.startsWith(r+" "))return xe[r]??"avg";for(let r of Ot)if(e.startsWith(r+" ")||e===r)return xe[r]??"sum";let n=we(e,Bn);if(n)return xe[n.label]??"avg";let s=we(e,Ge);return s?xe[s.label]??"sum":null}var Gn=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Kn=new RegExp("\\b("+Dn.join("|")+")\\b|("+On.join("|")+")$","i"),Vn=new RegExp("\\b("+Pn.join("|")+")\\b|("+Ln.join("|")+")$","i");function Te(t){if(!t)return"";let e=String(t),n=Q(e),s=Pt.exec(n);if(s)return e.slice(s[0].length).trim();let r=we(n,Ge);return(r?e.slice(0,r.base.length):e).trim()}function Un(t){if(!t)return!1;let e=Q(String(t));return Pt.test(e)||we(e,Ge)!==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"],Dt=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 Ke(t){if(t==null)return"";let e=String(t),n=Dt.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),a=0;for(;a<8;){let l=Dt.exec(i);if(!l||s(l[1])!==r)break;let o=i.slice(l[0].length);if(o.trim()==="")break;i=o,a++}return a===0?e:e.slice(0,n[0].length)+i}function zt(t){let e=t.map(r=>String(r??"")),n=new Set(e),s=new Set;for(let r=0;r<e.length;r++){if(!s.has(e[r])){s.add(e[r]);continue}let i=2;for(;n.has(`${e[r]} (${i})`);)i++;e[r]=`${e[r]} (${i})`,n.add(e[r]),s.add(e[r])}return e}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 Me={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 "]},Wt=new RegExp("^("+Object.keys(Me).join("|")+")\\((.+)\\)$");function $t(t){if(!t)return[];let e=Wt.exec(String(t).trim());if(!e)return[];let n=Me[e[1]],s=e[2],r=[];for(let i=s.indexOf(".");i>=0;i=s.indexOf(".",i+1)){if(i===0)continue;let a=s.slice(i+1);if(a.trim()!=="")for(let l of n){let o=l+a;r.includes(o)||r.push(o)}}return r}function Bt(t,e,n){let s=Wt.exec(String(t??"").trim());if(!s)return!1;let r=s[1];if((r==="Count"||r==="CountNonNull")&&n==="Decimal")return!0;let i=new Set(Me[r]),a=String(e??""),l=s[2];for(let o=l.indexOf(".");o>=0;o=l.indexOf(".",o+1)){if(o===0)continue;let u=l.slice(o+1);if(u.trim()!==""){for(let c of Object.values(Me))for(let f of c)if(!i.has(f)&&a===f+u)return!0}}return!1}function Yn(t){let e=Te(t);return e.length===0?"":e.replace(Gn," ")}function Gt(t,e){if(!e)return!1;let n=Te(e);return t.test(Q(Yn(e)))||t.test(Q(n))||t.test(Q(ee(n).join(" ")))}function Kt(t){return Gt(Vn,t)}function jn(t){return Gt(Kn,t)||Kt(t)}var Vt=/int|double|decimal|single|float|number|currency|money/i;function Xn(t){let e=String(t?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||t?.isMeasure===!0||Vt.test(String(t?.dataType??""))?"Continuous":"Categorical"}function qn(t){return t?.isMeasure===!0||Vt.test(String(t?.dataType??""))}function Ut(t){let e=t??{},n=Xn(e);if(n!=="Continuous")return{nature:n,additivity:"unknown",basis:"role",suppressed:!1};if(Kt(e.name))return{nature:n,additivity:"positional",basis:"name",suppressed:!0};let s=String(e.additivity??"").trim().toLowerCase();if(!(s==="additive"&&Un(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}:jn(e.name)?{nature:n,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:n,additivity:"additive",basis:"default",suppressed:!1}}function Ht(t){let e=Ut(t),n=t??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return qn(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 Li(t){return Ht(t)[0]}function Fi(t,e){return Ht(t).indexOf(e)>=0}function zi(t,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let n=Ut(t);return n.additivity==="additive"||n.additivity==="part_of_whole"||n.additivity==="unknown"}var Zn={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"]},Qn=["fr","es","pt","it","pl","cs","sk","hr","ru","uk","el","ar","he","id","vi","th"],Jn=["num\xE9ro"],er=t=>t.normalize("NFC").toLowerCase();function tr(t,e,n,s){let r=Ee(n);return!r||!t?null:t===e?"word":r.wordBreaks===!1?Array.from(e).length<it?null:(s?t.startsWith(e):t.endsWith(e))&&t.length>e.length?"suffix":null:s?nt(t,n).includes(e)?"word":null:r.script==="Hang"?rt(t,e)?"suffix":null:r.compounds&&tt(t,e,et)?"suffix":null}function Yt(t){let e=String(t??"").trim();if(!e)return null;let n=me(e),s=me(Te(e));for(let[r,i]of Object.entries(Zn)){let a=Qn.includes(r),l=a?s:n;for(let o of i){let u=Jn.includes(o)||!!Ee(r)?.foldSensitive,c=u?l.words:l.folded;if(c.length===0)continue;let f=u?er(o):me(o).folded.join(" "),m=tr(a?c[0]:c[c.length-1],f,r,a);if(m)return{lang:r,word:o,view:m}}}return null}var nr=[["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 ve(t){for(let[e,n]of nr)if(n.test(t))return e;return null}var rr=[{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]]}],Re=new Map;function jt(t,e,n,s){let r=Re.get(t);if(r)return r;let i=[];for(let[a,l]of e)for(let o=a;o<=l;o++){let u=String.fromCodePoint(o);ve(u)===n&&(s&&!s.test(u)||i.push(u))}return Re.set(t,i),i}function ir(t){let n=t.codePointAt(0);for(let a=0;a<9&&ve(String.fromCodePoint(n-1))==="Nd";a++)n--;let s="nd:"+n.toString(16),r=Re.get(s);if(r)return r;let i=[];for(let a=n;a<n+10;a++){let l=String.fromCodePoint(a);ve(l)==="Nd"&&i.push(l)}return Re.set(s,i),i}function sr(t,e){if(e==="Nd")return ir(t);for(let r of rr)if(r.test.test(t))return jt(r.id+":"+e,r.ranges,e,r.id==="ascii"?null:r.test);let s=t.codePointAt(0)&-128;return jt("block:"+s.toString(16)+":"+e,[[s,s+127]],e,null)}function or(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 ar=/^[\p{L}\p{M}\p{Nd}]$/u,Xt=/^[\p{L}\p{Nd}]$/u;function qt(t,e){if(!t)return t??"";let n=new Set(Array.from(t)),s=c=>{let f=ve(c);return!f||!ar.test(c)?c:or(sr(c,f),n,c,e)},r=c=>{let f=[];for(let m of c)f.push(s(m)),Xt.test(m)&&e()<.2&&f.push(s(m));if(f.length>6){let m=Math.floor(e()*Math.min(3,f.length-6));for(let h=0;h<m;h++)for(let w=0;w<5;w++){let C=Math.floor(e()*f.length);if(Xt.test(f[C])){f.splice(C,1);break}}}return f.join("")};if(!(t.includes("@")&&t.includes(".")))return r(t);let[a,l=""]=t.split("@"),o=l.endsWith(".com"),u=o?l.slice(0,-4):l;return`${r(a)}@${r(u)}${o?".com":""}`}var lr=/^[A-Za-z_$][A-Za-z0-9_$]*$/,ur=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),cr=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 ae(t,e){if(!t||!e)return!1;let n=ur(e);return new RegExp("['\"`]"+n+"['\"`]").test(t)?!0:lr.test(e)&&new RegExp("\\."+n+"(?![A-Za-z0-9_$])").test(t)}function dr(t){return!!t&&cr.test(t)}function Ui(t,e,n){return t?dr(t)?[...e]:[...n,...e].some(s=>ae(t,s))?e.filter(s=>ae(t,s)):[...e]:[]}var mr=5,fr=6,gr=3,ne=864e5,pr=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,hr=/^(\d{4})[-/](\d{1,2})$/,yr=/^(\d{4})[-\s]?Q([1-4])$/i,br=/^Q([1-4])[-\s](\d{4})$/i,Sr=/^(\d{4})$/,_r=/^(\d{4})(0[1-9]|1[0-2])$/,Ar=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/,Cr=/^(\D+?)[\s\-/.,']*((?:19|20)\d{2})$/u,xr=/^((?:19|20)\d{2})[\s\-/.,']+(\D+)$/u;function Ue(t,e,n){let s=te(t);if(!s)return 0;if(s==="sept")return 9;for(let a of e&&!/^en\b/i.test(e)?["en",e]:["en"]){let l=_e(a)[s];if(l!==void 0)return l+1}let r=n?.get(s);if(r!==void 0)return r+1;let i=oe(t);if(i.length>0){if(i.every(o=>o.month===i[0].month))return i[0].month+1;let a=Qe(String(e??"").split(/[-_]/)[0])?.code,l=i.find(o=>o.lang===a);if(l)return l.month+1}return 0}function wr(t){let e=pe(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:j(n.year,(n.n-1)*3+1,1)}function j(t,e,n,s=0,r=0,i=0){if(!(t>=1&&e>=1&&e<=12&&n>=1&&n<=31))return null;let a=Date.UTC(t,e-1,n,s,r,i);if(!Number.isFinite(a))return null;let l=o=>o<10?"0"+o:String(o);return{ms:a,y:t,m:e,d:n,iso:`${t}-${l(e)}-${l(n)}`}}function Mr(t,e){let n=[],s="";for(let o=0;o<e.length;o++){if(e[o]!=="%"){s+=e[o].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");continue}switch(e[++o]){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,a=1,l=1;return n.forEach((o,u)=>{let c=+r[u+1];o==="Y"?i=c:o==="m"?a=c:l=c}),i?j(i,a,l):null}function X(t,e,n,s){let r=(t??"").trim();if(r==="")return null;if(e){let o=Mr(r,e);return o||null}let i=pr.exec(r);if(i)return j(+i[1],+i[2],+i[3],+(i[4]??0),+(i[5]??0),+(i[6]??0));if(i=yr.exec(r),i)return j(+i[1],(+i[2]-1)*3+1,1);if(i=br.exec(r),i)return j(+i[2],(+i[1]-1)*3+1,1);if(i=hr.exec(r),i&&+i[2]>=1&&+i[2]<=12)return j(+i[1],+i[2],1);if(i=Ar.exec(r),i)return j(+i[1],+i[2],+i[3]);if(i=_r.exec(r),i)return j(+i[1],+i[2],1);if(i=Sr.exec(r),i){let o=+i[1];return o>=1900&&o<=2100?j(o,1,1):null}let a=wr(r);if(a)return a;if(i=Cr.exec(r),i){let o=Ue(i[1],n,s);if(o)return j(+i[2],o,1)}if(i=xr.exec(r),i){let o=Ue(i[2],n,s);if(o)return j(+i[1],o,1)}let l=ie(r);if(l){let o="month"in l?l.month:Ue(l.word,n,s);if(o)return j(l.year,o,1)}return null}function Zt(t){let e=new Date(t).getUTCDay();return e>=1&&e<=5}function Qt(t,e){if(e<=t)return 0;let n=Math.round((e-t)/ne),s=Math.floor(n/7),r=s*5,i=t+s*7*ne;for(;i<e;)Zt(i)&&r++,i+=ne;return r}function Tr(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 vr(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 le(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*ne));case"weekday":return Qt(t.ms,e.ms);case"day":return Math.round((e.ms-t.ms)/ne);default:return s>0?Math.round((e.ms-t.ms)/s):0}}function Jt(t,e){return He(t,e)?.cadence??null}function He(t,e){let n=e?.gapFactor??mr,s=0,r=0,i=new Map,a=Array.from(t),l;if(!e?.pattern){let p=[];for(let _ of a){if(_==null||_==="")continue;let b=ie(String(_));b&&"word"in b&&p.push(b.word)}p.length>0&&(l=Ae(p,e?.locale)??void 0)}for(let p of a){if(p==null||p==="")continue;s++;let _=X(String(p),e?.pattern,e?.locale,l);_&&(r++,i.set(_.ms,_))}let o=[...i.values()].sort((p,_)=>p.ms-_.ms);if(o.length<gr||s>0&&r/s<.8)return null;let u=o[o.length-1].ms-o[0].ms;if(u<=0)return null;let c=[];for(let p=1;p<o.length;p++)c.push(o[p].ms-o[p-1].ms);let f=Tr(c);if(!(f>0))return null;let m=vr(f/ne);m==="day"&&u>=7*ne&&o.every(p=>Zt(p.ms))&&Qt(o[0].ms,o[o.length-1].ms)+1>o.length*.5&&(m="weekday");let h=m==="irregular"?o.length:le(o[0],o[o.length-1],m,f)+1,w=1,C=1,S=[],g=o[0],y=1;for(let p=1;p<o.length;p++){let _=le(o[p-1],o[p],m,f);_>w&&(w=_),m!=="irregular"&&_>n?(C++,S.push({from:g.iso,to:o[p-1].iso,points:y}),g=o[p],y=1):y++}S.push({from:g.iso,to:o[o.length-1].iso,points:y});let A={grain:m,points:o.length,expectedPoints:Math.max(h,o.length),coveragePct:Math.round(o.length/Math.max(h,o.length)*1e3)/10,runs:C,largestGapUnits:w,gapFactor:n};return e?.includeBounds&&S.length<=fr&&(A.runBounds=S),{cadence:A,points:o,stepMs:f}}var Rr=8,Ir=.5,Nr=200,Er=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"]),kr=["category","classification","segment","status","priority","severity","channel"],Dr=new Set(["UUID","EMAIL_LIKE","URL_LIKE","PHONE_LIKE","NUMERIC_ID","HEX_ID","OPAQUE_ID_ALPHANUMERIC","DATE_STR","BOOLEAN"]);function Or(t){let e=ee(t);if(e.length===0)return!1;let n=e[e.length-1];return Er.has(n)?!0:kr.some(s=>n.length>s.length&&n.endsWith(s))}function Pr(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>Nr?"cardinality":t.rows>0&&e.length>=t.rows?"row-identity":t.isBinaryFlag?"flag":he(e,t.locale)!==null?"ordinal":t.identifierNamed||t.dataType==="String"&&Dr.has(Se(e))?"identifier":!t.geoKind&&Or(t.name)?"attribute":"entity"}function nn(t){let e=-1,n=1/0,s=!1;return t.forEach((r,i)=>{if(Pr(r)!=="entity")return;let a=new Set(Array.from(r.values).filter(o=>o!=="")).size,l=!!r.geoKind;(a<n||a===n&&l&&!s)&&(e=i,n=a,s=l)}),e}var en=t=>t<10?"0"+t:String(t);function tn(t,e){switch(e){case"year":return`${t.y}-01-01`;case"quarter":return`${t.y}-${en(Math.floor((t.m-1)/3)*3+1)}-01`;case"month":return`${t.y}-${en(t.m)}-01`;case"hour":return new Date(t.ms).toISOString().replace(/\.\d{3}Z$/,"Z");default:return t.iso}}function rn(t){let{periods:e,series:n}=t,s=Math.min(e.length,n.length),r=new Set;for(let _=0;_<s;_++)e[_]&&r.add(e[_]);let i=He(r,{pattern:t.pattern,locale:t.locale});if(!i)return null;let a=i.cadence.grain;if(a==="irregular")return null;let l=i.points[0],o=le(l,i.points[i.points.length-1],a,i.stepMs)+1;if(o!==i.cadence.expectedPoints)return null;let u=new Map;for(let _ of r){let b=X(_,t.pattern,t.locale);if(!b)continue;let x=le(l,b,a,i.stepMs);x>=0&&x<o&&u.set(_,{idx:x,stamp:b})}let c=new Map;for(let _=0;_<s;_++){let b=n[_];if(!b)continue;let x=u.get(e[_]);if(!x)continue;let M=c.get(b);M||(M={seen:new Set,lo:x.idx,hi:x.idx,loStamp:x.stamp,hiStamp:x.stamp,order:c.size},c.set(b,M)),M.seen.add(x.idx),x.idx<M.lo&&(M.lo=x.idx,M.loStamp=x.stamp),x.idx>M.hi&&(M.hi=x.idx,M.hiStamp=x.stamp)}if(c.size<2)return null;let f=0;for(let _ of c.values())f+=_.seen.size;if(f/(c.size*o)<(t.minFill??Ir))return null;let m=[],h=new Set,w=0,C=0,S=0,g=0,y=0,A=1;for(let[_,b]of c){for(let z of b.seen)h.add(z);if(b.seen.size>=o)continue;let x=[...b.seen].sort((z,q)=>z-q),M=1;for(let z=1;z<x.length;z++)M=Math.max(M,x[z]-x[z-1]);let W={key:_,acc:b,coverage:b.seen.size/o,before:b.lo,after:o-1-b.hi,interior:b.hi-b.lo+1-b.seen.size,gap:M};m.push(W),W.before>0&&w++,W.after>0&&C++,W.interior>0&&S++,g=Math.max(g,W.before),y=Math.max(y,W.after),A=Math.max(A,M)}if(m.length===0)return null;m.sort((_,b)=>_.coverage-b.coverage||_.acc.order-b.acc.order);let p=m.slice(0,t.maxListed??Rr);return{seriesColumn:t.seriesColumn,grain:a,periods:o,seriesCount:c.size,incompleteSeries:m.length,lateStarts:w,earlyEnds:C,withHoles:S,columnWideMissing:o-h.size,maxMissingBefore:g,maxMissingAfter:y,largestGap:A,series:p.map(_=>{let b={};return t.includeNames&&(b.name=_.key),t.includeDates&&(b.first=tn(_.acc.loStamp,a),b.last=tn(_.acc.hiStamp,a)),b.missingBefore=_.before,b.missingAfter=_.after,b.missingInterior=_.interior,b.largestGap=_.gap,b.coverage=Math.round(_.coverage*1e3)/1e3,b}),more:m.length-p.length}}var Ie=6;function ue(t){let e=t.slice().sort((s,r)=>s-r),n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2}function Lr(t){let e=t.length;if(e<Ie)return null;let n=t[0],s=t[0],r=0;for(let p of t)p<n&&(n=p),p>s&&(s=p),r+=p;if(n===s)return null;let i=ue(t.map(Math.abs));if(i===0)return null;let a=[];for(let p=1;p<e;p++)a.push(t[p]-t[p-1]);let l=ue(a.map(Math.abs))/i,o=(e-1)/2,u=r/e,c=0,f=0,m=0;for(let p=0;p<e;p++)c+=(p-o)*(t[p]-u),f+=(p-o)*(p-o),m+=(t[p]-u)*(t[p]-u);m/=e;let h=c/f,w=u-h*o,C=t.map((p,_)=>p-(w+h*_)),S=C.reduce((p,_)=>p+_,0)/e,g=0,y=0;for(let p=0;p<e;p++)g+=(C[p]-S)*(C[p]-S),p>0&&(y+=(C[p]-C[p-1])*(C[p]-C[p-1]));return g/=e,y/=e-1,{vnDetrended:g<=m*1e-12?2:y/g,relStep:l}}function Ye(t){let{stamps:e,series:n,values:s}=t,r=Math.min(e.length,s.length),i=new Map;for(let u=0;u<r;u++){let c=e[u],f=s[u];if(c===null||f===null||!Number.isFinite(f))continue;let m="";if(n&&(m=n[u]??"",m===""))continue;let h=i.get(m);h||i.set(m,h=new Map),h.set(c,(h.get(c)??0)+f)}let a=[],l=[],o=[];for(let u of i.values()){let c=[...u.entries()].sort((m,h)=>m[0]-h[0]).map(m=>m[1]),f=Lr(c);f&&(a.push(f.vnDetrended),l.push(f.relStep),o.push(c.length))}return a.length===0?null:{series:a.length,points:Math.round(ue(o)),vnDetrended:Math.round(ue(a)*1e3)/1e3,relStep:Math.round(ue(l)*1e4)/1e4}}function rs(t){let e=t.times.map(n=>X(n,t.pattern,t.locale)?.ms??null);return Ye({stamps:e,series:t.series,values:t.values})}var Fr=5e5,zr=8,Wr=4,$r=5,je=1,Xe=2,Br=4,Gr=8;function Kr(t,e,n){let[s,r]=[...t];if(e.isTemporal){let i=X(s,e.temporalTextPattern,n),a=X(r,e.temporalTextPattern,n);if(i&&a&&i.ms!==a.ms)return i.ms<a.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 Vr(t,e,n){let{rows:s,text:r,locale:i}=t,a=Kr(n.values,n,i),l=new Uint8Array(s.length),o=0;for(let u=0;u<s.length;u++){let c=r(s[u][e]);c===a.a?l[u]=1:c===a.b?l[u]=2:o++}return{code:l,blankRows:o,setOrder:a.setOrder}}function Ur(t,e){let{rows:n,text:s}=t,r=new Int32Array(n.length),i=new Map;for(let a=0;a<n.length;a++){let l=s(n[a][e]);if(l===""){r[a]=-1;continue}let o=i.get(l);o===void 0&&(o=i.size,i.set(l,o)),r[a]=o}return{ids:r,dict:i}}function Hr(t,e,n){let s=new Uint8Array(n);for(let i=0;i<t.length;i++){let a=e[i];if(a===0)continue;let l=t[i];if(l<0)continue;let o=s[l];s[l]=o&a?o|a<<2:o|a}let r={keysA:0,keysB:0,keysBoth:0,dupA:0,dupB:0};for(let i=0;i<n;i++){let a=s[i];a&je&&r.keysA++,a&Xe&&r.keysB++,(a&(je|Xe))===(je|Xe)&&r.keysBoth++,a&Br&&r.dupA++,a&Gr&&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 sn=t=>t==null||typeof t=="string"&&t.trim()==="";function jr(t,e,n){if(t===e)return!0;let s=sn(t),r=sn(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 on(t){let{rows:e,columns:n}=t,s=e.length;if(s<2||s>Fr)return null;let r=n.map((b,x)=>({c:b,i:x})).filter(({c:b})=>!b.isMeasure&&!b.isTemporal&&!b.isDatePart&&b.distinct>=$r).sort((b,x)=>(x.c.identifierNamed?1:0)-(b.c.identifierNamed?1:0)||x.c.distinct-b.c.distinct||b.i-x.i).slice(0,zr),i=n.map((b,x)=>({c:b,i:x})).filter(({c:b})=>!b.isMeasure&&b.values!==null&&b.values.size===2).slice(0,Wr);if(r.length===0||i.length===0)return null;let a=i.map(({c:b,i:x})=>Vr(t,x,b)),l=null;for(let{i:b}of r){let x=Ur(t,b);for(let M=0;M<i.length;M++){if(i[M].i===b)continue;let W=Hr(x.ids,a[M].code,x.dict.size);W.keysBoth<1||(!l||Yr(W,l.tally))&&(l={tally:W,keyIdx:b,setNo:M,ids:x.ids,dict:x.dict})}}if(!l)return null;let{ids:o,dict:u,tally:c}=l,f=a[l.setNo],m=i[l.setNo].i,h=u.size,w=new Int32Array(h).fill(-1),C=new Int32Array(h).fill(-1);for(let b=0;b<s;b++){let x=f.code[b],M=o[b];x===0||M<0||(x===1?w[M]<0&&(w[M]=b):C[M]<0&&(C[M]=b))}let S=[];for(let b=0;b<n.length;b++)b!==l.keyIdx&&b!==m&&S.push(b);let g=0;for(let b=0;b<h;b++){let x=w[b],M=C[b];if(x<0||M<0)continue;let W=e[x],z=e[M],q=!0;for(let J of S)if(!jr(W[J],z[J],t.text)){q=!1;break}q&&g++}let y=g===c.keysBoth?100:g===0?0:Math.min(99,Math.max(1,Math.round(g/c.keysBoth*100))),A=new Map,p=new Map;for(let[b,x]of u){let M=w[x]>=0,W=C[x]>=0;if(!M&&!W)continue;let z=mt(b);ft(z)&&(M&&A.set(z,(A.get(z)??0)+1),W&&p.set(z,(p.get(z)??0)+1))}let _=b=>{let x=0;for(let M of b.values())M>=2&&(x+=M);return x};return{key:l.keyIdx,discriminator:m,pairing:{form:"long",key:n[l.keyIdx].name,discriminator:n[m].name,keysA:c.keysA,keysB:c.keysB,keysBoth:c.keysBoth,duplicateKeysA:c.dupA,duplicateKeysB:c.dupB,identicalPct:y,discriminatorBlankRows:f.blankRows,looseCollisionsA:_(A),looseCollisionsB:_(p),setOrder:f.setOrder}}}var Xr=t=>t==="Integer"||t==="Decimal";function qr(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 Zr(t,e){let n=[];for(let s=0;s<t.length&&n.length<12;s++){let r=t[s];e.has(s)||!Xr(r.dataType)||r.isTemporal||r.isDatePart||r.identifierNamed||r.distinct<3||n.push(s)}return n}function an(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=qr(s);if(i.length===0)return e;let a=Zr(s,new Set(i));if(a.length===0)return e;let l=i.map(o=>{let[u,c]=s[o].twoValues,f=new Uint8Array(n.length);for(let m=0;m<n.length;m++){let h=r(n[m][o]);f[m]=h===u?1:h===c?2:0}return f});for(let o of a){let u=new Float64Array(n.length),c=0;for(let y=0;y<n.length;y++){let A=n[y][o],p=A==null||A===""?NaN:typeof A=="number"?A:parseFloat(A);u[y]=p,p===p&&p!==1/0&&p!==-1/0&&c++}if(c<2)continue;let f=new Float64Array(c);for(let y=0,A=0;y<n.length;y++){let p=u[y];p===p&&p!==1/0&&p!==-1/0&&(f[A++]=p)}f.sort();let m=new Float64Array(c),h=0;for(let y=0;y<c;y++)(y===0||f[y]!==f[y-1])&&(m[h++]=f[y]);let w=new Int32Array(n.length).fill(-1);for(let y=0;y<n.length;y++){let A=u[y];if(!(A===A&&A!==1/0&&A!==-1/0))continue;let p=0,_=h-1;for(;p<_;){let b=p+_>>>1;m[b]<A?p=b+1:_=b}w[y]=p}let C=[],S=new Int32Array(h),g=new Int32Array(h);for(let y=0;y<i.length;y++){let A=l[y];S.fill(0),g.fill(0);let p=0,_=0;for(let Y=0;Y<n.length;Y++){let U=w[Y];U<0||(A[Y]===1?(S[U]++,p++):A[Y]===2&&(g[U]++,_++))}if(p===0||_===0)continue;let b=p<=_,x=b?p:_,M=b?_:p,W=b?S:g,z=b?g:S,q=0,J=0,ce=0;for(let Y=0;Y<h;Y++){let U=W[Y],d=z[Y];q+=U*(J+.5*d),J+=d,U+d>=2&&(ce+=U+d)}C.push({outcome:s[i[y]].name,aucMinorityHigh:Math.round(q/(x*M)*1e4)/1e4,nMinority:x,nMajority:M,ties:ce})}C.length>0&&e.set(o,C)}return e}var un=12,Qr=100,Jr=.3,ei=.9,ti=120,ni=1900,ri=2100,ii=0,si=20,oi=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function Ne(t){if(!t)return!1;let e=ee(t);return e.length===0?!1:oi.has(e[e.length-1])?!0:Yt(t)!==null}var ai=new Set(["year","yr","fy"]),li=t=>ee(t).some(e=>ai.has(e))||dt(t)!==null,ui=/^(?:(?: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 qe(t){if(!Number.isInteger(t)||t<190001||t>210012)return!1;let e=t%100;return e>=1&&e<=12}function Ze(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 ci=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,di=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,mi=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function mn(t,e){let n=[],s=0,r=fi(t,e,n,()=>{s++});if(r)return r;if(s>0||n.length<2)return null;let i=Nt(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 fi(t,e,n,s){let r=0,i=0,a=0,l=0,o=0,u="",c=0,f="",m=0,h=0,w=0,C=0,S=!1;for(let b of t){if(b==null)continue;let x=String(b).trim();if(x==="")continue;r++,n.push(x);let M;if(M=ci.exec(x)){s();let W=+M[2],z=+M[3];W>=1&&W<=12&&z>=1&&z<=31&&(i++,M[4]!==void 0&&a++,M[6]!==void 0&&l++)}else if(M=di.exec(x)){s();let W=+M[3],z=+M[4];W>=1&&W<=12&&z>=1&&z<=31&&(u&&u!==M[2]&&(S=!0),u=M[2],o++)}else if(M=mi.exec(x)){s();let W=+M[1],z=+M[3];W>=1&&W<=31&&z>=1&&z<=31&&(W<=12||z<=12)&&(f&&f!==M[2]&&(S=!0),f=M[2],c++,W>12&&w++,z>12&&C++,M[5]!==void 0&&m++,M[7]!==void 0&&h++)}if(r>=200)break}if(r<2||(i+o+c)/r<.8||(i>0?1:0)+(o>0?1:0)+(c>0?1:0)!==1||S)return null;if(i>0)return a===i?{pattern:l===i?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(o>0)return{pattern:`%Y${u}%m${u}%d`,orderFrom:"iso"};if(w>0&&C>0)return null;let A,p;w>0?(A=!0,p="values"):C>0?(A=!1,p="values"):f==="."?(A=!0,p="shape"):(A=!We(e),p="locale");let _=A?`%d${f}%m${f}%Y`:`%m${f}%d${f}%Y`;return m===c?{pattern:_+(h===c?" %H:%M:%S":" %H:%M"),orderFrom:p}:{pattern:_,orderFrom:p}}function gi(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=te(n);return s.length>0&&e[s]!==void 0}function pi(t,e){let n=new Map,s=new Map;for(let l of t){let o=ie(l);if(!o||"month"in o)continue;let u=oe(o.word),c=u.some(m=>m.lang==="en"),f=te(o.word);for(let m of new Set(u.map(h=>h.lang)))m!=="en"&&(n.has(m)||(n.set(m,new Set),s.set(m,new Set)),n.get(m).add(f),c||s.get(m).add(f))}let r=[...n.keys()].filter(l=>n.get(l).size>=3&&s.get(l).size>=1),i=0,a=new Map(r.map(l=>[l,0]));for(let l of e){let o=ie(l);if(!o)continue;if("month"in o){i++;continue}let u=oe(o.word);if(u.length===0)continue;let c=u.some(f=>f.lang==="en");for(let f of r)(c||u.some(m=>m.lang===f))&&a.set(f,a.get(f)+1)}return i+Math.max(0,...a.values())}var hi=/(?:19|20)[0-9]{2}/;function yi(t){let e=new Map,n=0;for(let r of t){if(!hi.test(re(r)))continue;let i=new Set(pe(r).filter(a=>a.yearDigits===4&&(a.grain==="quarter"||a.grain==="week")).map(a=>a.lang));if(i.size!==0){if(i.has("en")){n++;continue}for(let a of i)e.set(a,(e.get(a)??0)+1)}}let s=0;for(let r of e.values())s=Math.max(s,r);return s>0?s+n:0}function bi(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,a=t.maxNum;if(!(i!=null&&a!=null&&Number.isFinite(i)&&Number.isFinite(a)&&Number.isInteger(i)&&Number.isInteger(a)&&a>=i))return!1;let o=i>=1900&&a<=2100;if(o&&r>=2&&li(n)||o&&r>=3&&r===a-i+1)return!0;let u=qe(i)&&qe(a),c=Ze(i)&&Ze(a);if(u||c){if(!t.sampleValues)return!0;let f=0,m=0;for(let h of t.sampleValues){if(h==null||h==="")continue;f++;let w=Number(String(h).trim());if(Number.isFinite(w)&&(u?qe(w):Ze(w))&&m++,f>=60)break}if(f>=2&&m===f)return!0}return!1}if(t.sampleValues){let i=t.locale?_e(t.locale):null,a=0,l=0,o=[],u=[];for(let c of t.sampleValues){if(c==null||c==="")continue;a++;let f=String(c).trim();if(o.push(f),ui.test(f)||gi(f,i)?l++:u.push(f),a>=60)break}if(a>=2&&l/a>=.8||a>=2&&(l+yi(u)+pi(o,u))/a>=.8||mn(o,t.locale)!==null)return!0}return!1}function Si(t){let e=Q((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":Ft(t)}function _i(t){let{rows:e,measureColIdx:n,measureName:s,candidateDims:r,minNum:i,maxNum:a,discourageAgg:l}=t,o=100,u=.01,c="";for(let m of r){if(m.distinct<2||m.distinct>o)continue;let h=r.filter(y=>y.idx!==m.idx).map(y=>y.idx),w=new Map;for(let y of e){let A=y[n];if(typeof A!="number"||!Number.isFinite(A))continue;let p=h.length?h.map(b=>String(y[b])).join(c):"",_=w.get(p);_||(_={sum:0,cset:new Set},w.set(p,_)),_.sum+=A,_.cset.add(String(y[m.idx]))}let C=0,S=0,g=0;for(let y of w.values())y.cset.size<2||(g++,Math.abs(y.sum-100)<=100*u?C++:Math.abs(y.sum-1)<=1*u&&S++);if(g>=2&&(C/g>=.9||S/g>=.9))return{additivity:"part_of_whole",partOfWholeDim:m.name}}if(l)return{additivity:"intensive_rate"};let f=Si(s);return f==="avg"||f==="min"||f==="max"?{additivity:"intensive_rate"}:f==="count"?{additivity:"additive"}:f==="sum"?{additivity:"unknown"}:i!=null&&a!=null&&Number.isFinite(i)&&Number.isFinite(a)&&i>=0&&a<=1.0001&&a>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function fn(t){let{dataType:e,isMeasure:n,name:s,distinct:r,nonblank:i,prec:a,maxval:l,minval:o}=t,u=l-o+1,c=u>0?r/u:1,f=i>0?r/i:0,m=e==="Decimal"||a>0;return!n&&Ne(s)?"Categorical":c>=ei&&!(t.ordinalNeedsWholeNumbers&&a>0)&&(gt(s)&&r<=ti||o>=ni&&l<=ri||o>=ii&&l<=si)?"Ordinal":n?"Continuous":!m&&Number.isFinite(u)&&r>un&&r===i&&u===r?"Categorical":r>un&&(m||r>=Qr||f>=Jr)?"Continuous":"Categorical"}function cn(t,e,n){return!t||t.isMeasure||e||t.dataType!=="Integer"&&t.dataType!=="Decimal"?!1:fn({dataType:t.dataType,isMeasure:!1,name:t.name,distinct:n.distinct,nonblank:n.nonblank,prec:n.prec,maxval:typeof n.maxval=="number"?n.maxval:0,minval:typeof n.minval=="number"?n.minval:0,ordinalNeedsWholeNumbers:!0})==="Continuous"}function Ai(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 dn=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;_generationColumns=[];_generationColumnsSig="[]";_declaredDimensions=new WeakSet;_inferredMeasureFlags=null;_preStatsFields=null;_statsAddedKeys=null;dedupRows=!0;tellApartNames=!0;_renamedRepeats=[];getRenamedRepeats(){return this._renamedRepeats}emitLegacyAggAliases=!1;deriveProvinces=!0;dateCellsAreLocalWallClock=!1;wallClockColumnIndexes(){let e=new Set;if(!this.dateCellsAreLocalWallClock||!this._cols)return e;for(let n=0;n<this._cols.length;n++){let s=this._cols[n];!s||!/date|time/i.test(String(s.dataType??""))||ut(this._rows.map(r=>r[n]))&&e.add(n)}return e}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(n=>!!(n&&n.isMeasure));return this._cols.forEach((n,s)=>{if(!n||n.isMeasure||this._declaredDimensions.has(n)||n.dataType!=="Integer"&&n.dataType!=="Decimal")return;let r=new Set,i=0,a=0,l=null,o=null;for(let u of this._rows){let c=u[s],f=this.STR(c);if(f!=""&&(r.add(f),i++,(l===null||c<l)&&(l=c),(o===null||c>o)&&(o=c),n.dataType=="Decimal")){let m=this.getPrecision(c);m>a&&(a=m)}}e[s]=cn(n,!1,{distinct:r.size,nonblank:i,prec:a,minval:l,maxval:o})}),Object.freeze(e),this._inferredMeasureFlags=e,e}declareDimensions(e){this._inferredMeasureFlags=null;for(let n of e)n&&this._declaredDimensions.add(n)}wholeDayIso(e){return lt(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;this._preStatsFields&&this._statsAddedKeys&&this._preStatsFields.length===this._cols.length?this._cols.forEach((d,T)=>{let E=this._preStatsFields[T];if(!(!d||!E)){for(let k of this._statsAddedKeys[T]??[])delete d[k];for(let k of Object.keys(E))d[k]=E[k]}}):this._preStatsFields=this._cols.map(d=>d?{...d}:null);let s=this._cols.map(d=>new Set(d?Object.keys(d):[])),r=0,i=parseInt(e),a=this.wallClockColumnIndexes(),l=[],o=[],u=[];for(let d of this._cols){let T=new Map,E=[],k=0,v=0,O=0,F=null,P=null,D=null,G=!1,K=!0,I=!0,N=null,V=!1,L=a.has(r);for(let R of this._rows){let $=R[r],B=L&&$ instanceof Date?ge($):$,H=this.STR(B);if(H!=""){if(k+=H.length,T.set(H,(T.get(H)||0)+1),v++,d.dataType=="Integer"||d.dataType=="Decimal"||d.dataType=="DateTime")if((F===null||B<F)&&(F=B),(P===null||B>P)&&(P=B),d.dataType=="Integer"||d.dataType=="Decimal"){if(D===null?D=B:D+=B,d.dataType=="Decimal"){let Z=this.getPrecision(B);Z>O&&(O=Z)}E.push(B)}else G=G||this.hasTimeComponent(B);V&&(B<N?K=!1:B>N&&(I=!1)),N=B,V=!0}}if(v>=3&&(K&&!I?d.sortedDirection="asc":I&&!K?d.sortedDirection="desc":d.sortedDirection="none"),v>0&&T.size>0&&!d.isMeasure){let R=0,$=Number.MAX_SAFE_INTEGER;for(let B of T.values())B>R&&(R=B),B<$&&($=B);if(d.modalShare=R/v,d.minGroupCount=$===Number.MAX_SAFE_INTEGER?null:$,T.size===2){let B=[...T.keys()].map(de=>st(de).trim().toLowerCase()).sort(),Z=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(de=>B[0]===de[0]&&B[1]===de[1]),gn=/^(is|has)[_\p{L}\p{N}]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/iu.test(d.name);(Z||gn)&&(d.isBinaryFlag=!0)}}else d.isMeasure&&(d.dataType==="Integer"||d.dataType==="Decimal")&&T.size===2&&T.has("0")&&T.has("1")&&(d.isBinaryFlag=!0);if(d.dataType=="DateTime"&&(d.dateWithTime=G,G&&ct(L?this._rows.map(R=>R[r]instanceof Date?ge(R[r]):R[r]):this._rows.map(R=>R[r]))?d.timeOfDayOnly=!0:delete d.timeOfDayOnly),d.isTemporal=bi({dataType:d.dataType,name:d.name,isMeasure:d.isMeasure,distinctCount:T.size,minNum:typeof F=="number"?F:null,maxNum:typeof P=="number"?P:null,sampleValues:T.keys(),locale:n}),d.isTemporal&&d.dataType==="String"&&!d.isMeasure){let R=mn(T.keys(),n);R&&(d.temporalTextPattern=R.pattern)}if(d.timeOfDayOnly)delete d.temporalCadence;else if(d.isTemporal&&!d.isMeasure){let R=Jt(T.keys(),{includeBounds:i>=20,pattern:d.temporalTextPattern,locale:n});R&&(d.temporalCadence=R)}this.updateColumnStats10(i,d,v,T,O,P,F),this.updateColumnStats20(i,E,v,D,d,k,G,F,P,O,T,n),cn(d,this._declaredDimensions.has(d),{distinct:T.size,nonblank:v,prec:O,minval:F,maxval:P})&&(d.isMeasure=!0,d.valueNature="Continuous",d.geoKind=void 0,d.geoMatchPct=void 0,d.geoAmbiguous=void 0,d.dominantGeoRegion=void 0,d.dominantGeoRegionPct=void 0,d.geoRegionCount=void 0),l[r]=d.isMeasure||T.size>2e3?null:new Set(T.keys()),o[r]=T.size,u[r]=T.size===2?[...T.keys()].sort():null,r++}vt(this._cols,this._rows,{cities:this.deriveProvinces}).forEach((d,T)=>{let E=this._cols[T];d.kind&&(E.geoKind=d.kind,E.geoMatchPct=d.matchPct,d.ambiguous&&(E.geoAmbiguous=!0)),d.rollupPct!==void 0&&(E.admin1RollupPct=d.rollupPct),d.regionCount!==void 0&&(E.admin1RegionCount=d.regionCount),d.countryCount!==void 0&&(E.admin1CountryCount=d.countryCount),d.dominantRegion&&(E.dominantGeoRegion=d.dominantRegion,E.dominantGeoRegionPct=d.dominantRegionPct)});let c=this.getGeoExtent();if(c&&c.dominantFrame&&this._geoExtentLatIdx>=0){let d=this._cols[this._geoExtentLatIdx];d.geoKind||(d.dominantGeoRegion=c.dominantFrame,d.dominantGeoRegionPct=c.dominantFramePct,this.deriveProvinces&&(d.admin1RollupPct=c.dominantFramePct))}let f=[];this._cols.forEach((d,T)=>{d.isMeasure||f.push({idx:T,distinct:d.distinctCount??0,name:d.name})}),this._cols.forEach((d,T)=>{if(!d.isMeasure)return;let E=typeof d.lowValue=="number"?d.lowValue:null,k=typeof d.highValue=="number"?d.highValue:null,v=_i({rows:this._rows,measureColIdx:T,measureName:d.name,candidateDims:f,minNum:E,maxNum:k,discourageAgg:!!d.discourageAggregationAcrossGroups});d.additivity=v.additivity,v.partOfWholeDim&&(d.partOfWholeDim=v.partOfWholeDim)});let m=50,h=4,w=f.filter(d=>d.distinct>=2&&d.distinct<=m);this._cols.forEach((d,T)=>{if(!d.isMeasure)return;let E=[];for(let I of this._rows){let N=I[T];if(N==null||N==="")continue;let V=typeof N=="number"?N:parseFloat(N);isNaN(V)||E.push(V)}if(E.length===0)return;let k=[...E].sort((I,N)=>I-N);if(k[0]===k[k.length-1])d.relativeDispersion=0;else if(k.length>=h){let I=fe(k,.5),N=fe(k,.1),V=fe(k,.9);d.relativeDispersion=Math.abs(I)>1e-9?Math.round((V-N)/Math.abs(I)*1e3)/1e3:void 0}else d.relativeDispersion=void 0;let v=[];for(let I of w){let N=new Set;for(let V of this._rows){let L=V[T];L==null||L===""||N.add(this.STR(V[I.idx])+"")}v.push({otherColumn:I.name,nonBlankGroupCount:N.size})}v.length>0&&(d.nonBlankGroups=v);let O=0;for(let I of E)O+=I;O/=E.length;let F=0;for(let I of E)F+=(I-O)*(I-O);if(F<=1e-12)return;let P=[],D=[],G=I=>{if(I.length<4)return NaN;let N=[...I].sort((L,R)=>L-R),V=L=>N[Math.min(N.length-1,Math.max(0,Math.floor(L*(N.length-1))))];return V(.75)-V(.25)},K=G(E);for(let I of w){let N=new Map;for(let R of this._rows){let $=R[T];if($==null||$==="")continue;let B=typeof $=="number"?$:parseFloat($);if(isNaN(B))continue;let H=this.STR(R[I.idx])+"",Z=N.get(H);Z?(Z.s+=B,Z.n++,Z.vals.push(B)):N.set(H,{s:B,n:1,vals:[B]})}let V=0;for(let R of N.values()){let $=R.s/R.n;V+=R.n*($-O)*($-O)}P.push({otherColumn:I.name,eta2:Math.round(V/F*1e4)/1e4});let L=[];for(let R of N.values()){let $=G(R.vals);isNaN($)||L.push($)}if(L.length>=2&&isFinite(K)&&K>1e-9){let R=(Math.max(...L)-Math.min(...L))/K;D.push({otherColumn:I.name,spreadRatio:Math.round(R*1e4)/1e4})}}P.length>0&&(d.groupDiscrimination=P),D.length>0&&(d.spreadDiscrimination=D)});let C=.97,S=.8,g=8,y=5,A=this._cols.map((d,T)=>({c:d,i:T})).filter(d=>d.c.isMeasure);for(let d=0;d<A.length;d++)for(let T=d+1;T<A.length;T++){let E=A[d].i,k=A[T].i,v=0,O=0,F=0,P=0,D=0,G=0;for(let L of this._rows){let R=L[E],$=L[k];if(R==null||R===""||$===null||$===void 0||$==="")continue;let B=typeof R=="number"?R:parseFloat(R),H=typeof $=="number"?$:parseFloat($);isNaN(B)||isNaN(H)||(v++,O+=B,F+=H,P+=B*B,D+=H*H,G+=B*H)}if(v<y)continue;let K=v*P-O*O,I=v*D-F*F;if(K<=1e-12||I<=1e-12)continue;let N=(v*G-O*F)/Math.sqrt(K*I),V=Math.min(1,Math.round(Math.abs(N)*1e3)/1e3);for(let L of[A[d].c,A[T].c])(L.maxAbsMeasureCorrelation===void 0||V>L.maxAbsMeasureCorrelation)&&(L.maxAbsMeasureCorrelation=V);if(Math.abs(N)>=C){let L=A[d].c,R=A[T].c;L.collinearWithMeasures||(L.collinearWithMeasures=[]),R.collinearWithMeasures||(R.collinearWithMeasures=[]),L.collinearWithMeasures.push(R.name),R.collinearWithMeasures.push(L.name)}else if(Math.abs(N)>=S){let L=A[d].c,R=A[T].c,$=Math.round(N*1e3)/1e3;L.correlatedWithMeasures||(L.correlatedWithMeasures=[]),R.correlatedWithMeasures||(R.correlatedWithMeasures=[]),L.correlatedWithMeasures.push({otherColumn:R.name,r:$}),R.correlatedWithMeasures.push({otherColumn:L.name,r:$})}}for(let{c:d}of A)d.correlatedWithMeasures&&(d.correlatedWithMeasures.sort((T,E)=>Math.abs(E.r)-Math.abs(T.r)||(T.otherColumn<E.otherColumn?-1:1)),d.correlatedWithMeasures.length=Math.min(d.correlatedWithMeasures.length,g));for(let d=0;d<this._cols.length;d++){let T=l[d];if(!T||T.size===0)continue;let E=[];for(let k=0;k<this._cols.length;k++){if(k===d)continue;let v=l[k];if(!v||v.size===0)continue;let O=0;for(let P of T)v.has(P)&&O++;let F=Math.round(O/T.size*100);F>0&&E.push({otherColumn:this._cols[k].name,percentShared:F})}E.length>0&&(this._cols[d].sharedValueRatioWithOthers=E)}let p=50,_=[];for(let d=0;d<this._cols.length;d++){let T=l[d];T&&T.size>=2&&T.size<=p&&_.push(d)}if(_.length>=2){let d=new Map,T=(k,v)=>k+":"+v;for(let k=0;k<_.length;k++)for(let v=k+1;v<_.length;v++)d.set(T(_[k],_[v]),new Map);for(let k of this._rows)for(let v=0;v<_.length;v++){let O=this.STR(k[_[v]])+"";for(let F=v+1;F<_.length;F++){let P=""+this.STR(k[_[F]]),D=d.get(T(_[v],_[F])),G=O+""+P;D.set(G,(D.get(G)??0)+1)}}let E=new Map;for(let k=0;k<_.length;k++)for(let v=k+1;v<_.length;v++){let O=_[k],F=_[v],P=l[O].size,D=l[F].size,G=d.get(T(O,F)),K=G.size,I=0;for(let R of G.values())(I===0||R<I)&&(I=R);let N=Math.round(K/(P*D)*100),V=K===P,L=K===D;if((this._cols[O].categoricalPairStats||=[]).push({otherColumn:this._cols[F].name,fillPct:N,determinesOther:V,minCellCount:I,distinctCombinations:K}),(this._cols[F].categoricalPairStats||=[]).push({otherColumn:this._cols[O].name,fillPct:N,determinesOther:L,minCellCount:I,distinctCombinations:K}),V&&P>D){let R=E.get(O);(!R||D<R.card)&&E.set(O,{name:this._cols[F].name,card:D,ratio:D/P})}if(L&&D>P){let R=E.get(F);(!R||P<R.card)&&E.set(F,{name:this._cols[O].name,card:P,ratio:P/D})}}for(let[k,v]of E)this._cols[k].primaryParentColumn=v.name,this._cols[k].nestingRatio=Math.round(v.ratio*100)/100}let b=6,x=this._rows.length;for(let d=0;d<this._cols.length;d++){let T=this._cols[d];if(T.isMeasure||T.primaryParentColumn)continue;let E=T.distinctCount??0;if(E<=p||x>0&&E>=x)continue;let k=[];for(let v=0;v<this._cols.length;v++){if(v===d)continue;let O=this._cols[v];if(O.isMeasure)continue;let F=O.distinctCount??0;F<2||F>=E||k.push(v)}k.sort((v,O)=>(this._cols[v].distinctCount??0)-(this._cols[O].distinctCount??0));for(let v of k.slice(0,b)){let O=new Map,F=!0;for(let D of this._rows){let G=this.STR(D[d])+"",K=this.STR(D[v])+"",I=O.get(G);if(I===void 0)O.set(G,K);else if(I!==K){F=!1;break}}if(!F)continue;let P=this._cols[v].distinctCount??0;T.primaryParentColumn=this._cols[v].name,T.nestingRatio=Math.round(P/E*100)/100;break}}let M=.01,W=.05,z=.95,q=8,J=8,ce=6,Y=500,U=[];for(let d=0;d<this._cols.length&&U.length<J;d++){let T=this._cols[d].dataType;(T==="Double"||T==="Integer"||T==="Decimal")&&U.push(d)}if(U.length>=3&&this._rows.length>=q){let d=Math.min(this._rows.length,Y),T=U.map(P=>{let D=[];for(let I=0;I<d;I++){let N=this._rows[I][P],V=typeof N=="number"?N:parseFloat(String(N).replace(/,/g,""));if(N==null||N===""||!isFinite(V))return null;D.push(V)}let G=D[0],K=!1;for(let I of D)if(I!==G){K=!0;break}return K?D:null}),E=U.map((P,D)=>D).filter(P=>T[P]!==null),k=P=>{let D=P.slice().sort((K,I)=>K-I),G=D.length>>1;return D.length%2?D[G]:(D[G-1]+D[G])/2},v=null,O=[],F=P=>{if(O.length>=3){let D=O.map(N=>T[N]),G=D[0].length,K=new Array(G);for(let N=0;N<G;N++){let V=0;for(let L of D)V+=L[N];K[N]=V}let I=k(K);if(I>0){let N=0;for(let L of K)Math.abs(L-I)<=I*M&&N++;let V=N/G;if(V>=z){let L=1;for(let R of D){let $=k(R)/I;$<L&&(L=$)}L>=W&&(!v||O.length>v.cols.length)&&(v={cols:O.slice(),total:I,matched:V})}}}if(!(O.length>=ce))for(let D=P;D<E.length;D++)O.push(E[D]),F(D+1),O.pop()};if(F(0),v){let P=v,G={columns:P.cols.map(K=>this._cols[U[K]].name),total:Math.round(P.total*1e3)/1e3,matchedPct:Math.round(P.matched*100)/100};for(let K of P.cols)this._cols[U[K]].constantSumGroup=G}}return this.applyTwoSetPairing(n,l),this.applyScoreSeparation(o,u),this.applySeriesCompleteness(i,n,l),this.applyMeasurePersistence(n,l),this._statsAddedKeys=this._cols.map((d,T)=>d?Object.keys(d).filter(E=>!s[T].has(E)):[]),this._computedStatsForLevel=e,this._cols}applyTwoSetPairing(e,n){for(let r of this._cols)r.twoSetPairing!==void 0&&delete r.twoSetPairing;let s=on({rows:this._rows,columns:this._cols.map((r,i)=>{let a=n[i];return{name:r.name,values:a,distinct:a?a.size:r.distinctCount??0,isMeasure:!!r.isMeasure,isTemporal:!!r.isTemporal,isDatePart:!!r.isDatePart,identifierNamed:Ne(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=an({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:Ne(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 u of this._cols)u.seriesCompleteness!==void 0&&delete u.seriesCompleteness;let r=this._cols.map((u,c)=>({c:u,i:c})).filter(({c:u})=>u.isTemporal&&!u.isMeasure&&u.temporalCadence&&u.temporalCadence.grain!=="irregular");if(r.length===0)return;let i=this.seriesKeyIndex(n,s);if(i<0)return;let a=this._cols[i],l=this._rows.map(u=>this.STR(u[i])),o=e>=20&&(a.dataType!=="String"||Array.isArray(a.safeDistinctValues));for(let{c:u,i:c}of r){let f=rn({periods:this._rows.map(m=>this.STR(m[c])),series:l,seriesColumn:a.name,pattern:u.temporalTextPattern,locale:n,includeDates:e>=20,includeNames:o});f&&(u.seriesCompleteness=f)}}seriesKeyIndex(e,n){let s=[],r=[];this._cols.forEach((a,l)=>{let o=n[l];o&&(s.push(l),r.push({name:a.name,dataType:a.dataType,isMeasure:!!a.isMeasure,isTemporal:!!a.isTemporal,isDatePart:!!a.isDatePart,isReassembledDate:!!a.isReassembledDate,isBinaryFlag:!!a.isBinaryFlag,geoKind:a.geoKind,identifierNamed:Ne(a.name),values:o,rows:this._rows.length,locale:e}))});let i=nn(r);return i<0?-1:s[i]}applyMeasurePersistence(e,n){for(let o of this._cols)o.persistence!==void 0&&delete o.persistence;let s=[];if(this._cols.forEach((o,u)=>{o.isMeasure&&(o.dataType==="Integer"||o.dataType==="Decimal"||o.dataType==="Double")&&s.push(u)}),s.length===0||this._rows.length<Ie)return;let r=-1,i=[];for(let o=0;o<this._cols.length&&r<0;o++){let u=this._cols[o];if(!u.isTemporal||u.isMeasure||u.isDatePart)continue;let c=this._rows.map(f=>X(this.STR(f[o]),u.temporalTextPattern,e)?.ms??null);new Set(c.filter(f=>f!==null)).size<Ie||(r=o,i=c)}if(r<0)return;let a=this.seriesKeyIndex(e,n),l=a>=0?this._rows.map(o=>this.STR(o[a])):void 0;for(let o of s){let u=this._rows.map(f=>{let m=f[o];if(m==null||m==="")return null;let h=typeof m=="number"?m:parseFloat(String(m).replace(/,/g,""));return Number.isFinite(h)?h:null}),c=Ye({stamps:i,series:l,values:u});c&&(this._cols[o].persistence={timeColumn:this._cols[r].name,...a>=0?{seriesColumn:this._cols[a].name}:{},...c})}}updateColumnStats20(e,n,s,r,i,a,l,o,u,c,f,m){if(e>=20){let h=[...n].sort((S,g)=>S-g),w=Math.floor(h.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=a/s),this._rows.length>0){let S=g=>{let y=g instanceof Date?g:typeof g=="string"?ke(g)??new Date(g):new Date(g),A=this.wholeDayIso(y);return A?A+"T00:00:00.000Z":isNaN(y.getTime())?g:y.toISOString().slice(0,10)+"T00:00:00.000Z"};i.dataType!="DateTime"||l||!o?i.lowValue=o:i.lowValue=S(o),i.dataType!="DateTime"||l||!u?i.highValue=u:i.highValue=S(u),i.medianValue=h.length===0?null:h.length%2===0?i.dataType=="Integer"?Math.round((h[w-1]+h[w])/2):(h[w-1]+h[w])/2:h[w],i.numericPrecision=c}if(h.length>0){let S=s>0&&r!=null?r/s:i.avgValue??0,g=h.length,y=0,A=0;for(let b of h){let x=b-S;y+=x*x,A+=x*x*x}let p=y/g,_=Math.sqrt(p);i.skewness=p===0?0:A/g/(_*_*_),i.stdDev=Math.sqrt(p)}r!==null&&(i.sum=r);let C=Array.from(f.entries()).sort((S,g)=>g[1]-S[1]);if(i.topCategories=C.slice(0,10).map(S=>S[1]),!i.isMeasure&&C.length>0&&(i.dataType!=="String"&&(i.topCategoryValues=C.slice(0,5).map(S=>S[0])),e>=20)){let S=C.map(y=>y[0]),g=he(S,m);if(g!==null)i.ordinalPattern=g.pattern,i.orderedDomain=g.orderedDomain;else if(i.dataType==="String"){let y=pt(S);y!==null&&(i.safeDistinctValues=y)}}if(h.length>=8&&(i.dataType==="Integer"||i.dataType==="Decimal")){let S=g=>h[Math.floor((h.length-1)*g)];i.quantiles={p05:S(.05),p25:S(.25),p75:S(.75),p95:S(.95)}}}if(!i.isMeasure&&i.dataType==="String"&&f.size>0){let h=Array.from(f.entries()).sort((S,g)=>g[1]-S[1]).map(S=>S[0]);i.formatSignature=Se(h);let w=s>0?a/s:void 0,C=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;i.formatSignature&&!C.test(i.formatSignature)&&(w===void 0||w>=3)&&(i.isFreeText=!0)}if(!i.isMeasure&&f.size>0){let h=Array.from(f.entries()).sort((C,S)=>S[1]-C[1]),w=Ct(h.map(C=>C[0]),i.name,m);if(w!==null&&(i.geoKind=w.geoKind,i.geoMatchPct=w.geoMatchPct,w.geoAmbiguous&&(i.geoAmbiguous=!0),w.geoKind.indexOf("country")===0)){let C=bt(h);C&&(i.dominantGeoRegion=C.dominantGeoRegion,i.dominantGeoRegionPct=C.dominantGeoRegionPct,i.geoRegionCount=C.regionCount,C.middleEastPct>0&&(i.middleEastPct=C.middleEastPct))}}}updateColumnStats10(e,n,s,r,i,a,l){let o=this._rows.length-s;e>=10&&(n.blankCount=o),n.distinctCount=r.size+(o!=0?1:0),n.valueNature="Categorical",s>0&&(n.dataType==="Integer"||n.dataType==="Decimal"?n.valueNature=fn({dataType:n.dataType,isMeasure:!!n.isMeasure,name:n.name,distinct:r.size,nonblank:s,prec:i,maxval:a,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=a=>Je(a,{camel:!0}),n=-1,s=-1,r=-1;if(this._cols.forEach((a,l)=>{let o=e(a.name),u=a.dataType==="Integer"||a.dataType==="Decimal";u&&n<0&&o.some(c=>c==="lat"||c==="latitude")?n=l:u&&s<0&&o.some(c=>c==="lon"||c==="lng"||c==="long"||c==="longitude")&&(s=l),r<0&&!a.isMeasure&&typeof a.geoKind=="string"&&a.geoKind.indexOf("country")===0&&(r=l)}),n<0||s<0){let a=(u,c)=>{let f=0;for(let m of this._rows){let h=m[u];if(h==null||h==="")continue;let w=Number(h);if(!Number.isFinite(w)||w<-c||w>c)return!1;f++}return f>0},l=-1,o=-1;if(this._cols.forEach((u,c)=>{if(!(u.dataType==="Integer"||u.dataType==="Decimal"))return;let f=e(u.name),m=f.some(h=>h==="lat"||h==="latitude")?"lat":f.some(h=>h==="lon"||h==="lng"||h==="long"||h==="longitude")?"lon":Et(f);m==="lat"&&l<0&&a(c,90)?l=c:m==="lon"&&o<0&&a(c,180)&&(o=c)}),l<0||o<0)return null;n=l,s=o}this._geoExtentLatIdx=n;let i=[];for(let a of this._rows){let l=a[n],o=a[s],u=l==null||l===""?null:Number(l),c=o==null||o===""?null:Number(o);i.push({lat:u,lon:c,country:r>=0&&ye(this.STR(a[r]))?this.STR(a[r]):null})}return this._geoExtent=yt(i),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;_geoExtentLatIdx=-1;obfuscateString(e){return qt(e,at)}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,a=this.wallClockColumnIndexes();for(let o of this._rows){let u={};for(let c=0;c<this._cols.length;c++){let f=this._cols[c],m=o[c];if(this.STR(m)!=""){if(e&&f.dataType=="String")if(i.has(m))m=i.get(m);else{let h=this.obfuscateString(m);i.set(m,h),m=h}else if(f.dataType=="DateTime"&&!f.dateWithTime){let h=m instanceof Date?m:typeof m=="string"?ke(m)??new Date(m):new Date(m);m=(this.wholeDayIso(h)??h.toISOString().slice(0,10))+"T00:00:00.000Z"}else a.has(c)&&m instanceof Date&&(m=ge(m));r-=this.STR(m).length}else m=null;u[c]=m,--r}if(n.push(u),--s,s<=0||r<=0)break}return await ln.unparse(n,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return ln.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}setGenerationColumns(e){let n=(e??[]).filter(r=>!!r&&typeof r.n=="string"&&r.n!==""&&typeof r.q=="string"&&r.q!=="").map(r=>({n:r.n,q:r.q})),s=JSON.stringify(n);s!==this._generationColumnsSig&&(this._generationColumns=n,this._generationColumnsSig=s,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:s.reason});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:n.reason});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,s=(this._cols??[]).some(u=>!!u&&!!u.isReassembledDate&&!!u.sourceField);if(!e||this._hostQueryNames.length===0&&!s||!this._cols||this._cols.length===0)return n;let r=String(e),i=new Set;for(let u of this._cols)u&&(i.add(this.STR(u.name)),u.hostName&&i.add(this.STR(u.hostName)));let a=new Map,l=new Set,o=new Set;for(let u=0;u<this._cols.length;u++){if(!this._cols[u])continue;let c=this._hostQueryNames[u],f=Bt(c,this._cols[u].name,this._cols[u].dataType)?[]:$t(c),m=this.STR(this._cols[u].name),h=[];if(c){for(let g of this._generationColumns)if(g.q===c)for(let y of[g.n,Ke(g.n)])y&&y!==m&&!f.includes(y)&&!h.includes(y)&&h.push(y)}let w=this._cols[u].isReassembledDate?this.STR(this._cols[u].sourceField):"",C=w&&w!==m&&!f.includes(w)&&!h.includes(w)?[w]:[],S=[...f,...h,...C].filter(g=>!i.has(g)&&ae(r,g));S.length===1&&(a.set(S[0],[...a.get(S[0])??[],u]),h.includes(S[0])?l.add(S[0]):C.includes(S[0])&&o.add(S[0]))}for(let[u,c]of a){if(c.length!==1)continue;let f=this.STR(this._cols[c[0]].name);n.set(c[0],{name:f,alias:u,headerName:!ae(r,f),reason:l.has(u)?"stored-query-name":o.has(u)?"reassembled-date-source-field":"english-implicit-agg"})}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=ot(s);if(this._rowHashes.has(r))return!1;this._rowHashes.add(r)}return this._rows.push(Ai(e)),this.invalidateStats(),this._origIndices.push(n??-1),!0}getOriginalRowIndex(e){return e<0||e>=this._origIndices.length?-1:this._origIndices[e]}invalidateStats(){this._computedStatsForLevel=null,this._geoExtentComputed=!1,this._geoExtent=null,this._geoExtentLatIdx=-1,this._leafCardinality=null,this._inferredMeasureFlags=null}reset(){this.invalidateStats(),this._preStatsFields=null,this._statsAddedKeys=null,this._inferredMeasureFlags=null,this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null,this._hostQueryNames=[],this._englishAliases=new Map,this._generationColumns=[],this._generationColumnsSig="[]",this._renamedRepeats=[]}setColumns(e){if(this.invalidateStats(),this._preStatsFields=null,this._statsAddedKeys=null,this._inferredMeasureFlags=null,this._cols=e,this._renamedRepeats=[],!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=Ke(r);!i||i===r||n.has(i)||(n.delete(r),n.add(i),s.hostName=r,s.name=i)}if(this.tellApartNames){let s=e.map(i=>this.STR(i?.name)),r=zt(s);for(let i=0;i<e.length;i++)!e[i]||r[i]===s[i]||(this._renamedRepeats.push({index:i,from:s[i],to:r[i]}),e[i].name=r[i])}}};export{pn as a,hn as b,Ti as c,vi as d,vt as e,Nt as f,In as g,Nn as h,Et as i,Dn as j,On as k,Pn as l,Ln as m,Te as n,Un as o,Ke as p,Ve as q,$t as r,Kt as s,jn as t,Ut as u,Ht as v,Li as w,Fi as x,zi as y,Zn as z,Qn as A,Jn as B,Yt as C,ae as D,dr as E,Ui as F,mr as G,fr as H,X as I,Jt as J,Rr as K,Ir as L,Nr as M,Pr as N,nn as O,rn as P,rs as Q,Ne as R,mn as S,bi as T,Si as U,_i as V,fn as W,cn as X,Ai as Y,dn as Z};