@bicharts/shape-core 0.6.74 → 0.6.76

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{L as x,S as T}from"./chunk-OPDY2YEA.mjs";import{B as E}from"./chunk-4VN252CK.mjs";import A from"papaparse";function k(e){if(!e)return".";try{return new Intl.NumberFormat(e).formatToParts(1.5).find(t=>t.type==="decimal")?.value===","?",":"."}catch{return"."}}var C="[ \\u00A0\\u202F]",y="(?:[eE][+-]?\\d+)?",O=new RegExp(`^[+-]?(?:\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.\\d+)?${y}$`),N=new RegExp(`^[+-]?(?:\\d{1,3}(?:\\.\\d{3})+|\\d{1,3}(?:${C}\\d{3})+|\\d+)(?:,\\d+)?${y}$`),P=/^[+-]?\d{1,3}[.,]\d{3}$/,_=[/^[+-]?\d{1,3}(?:,\d{3}){2,}$/,new RegExp(`^[+-]?(?:\\d{1,3}(?:,\\d{3})+|\\d+)\\.\\d+${y}$`)],j=[/^[+-]?\d{1,3}(?:\.\d{3}){2,}$/,new RegExp(`^[+-]?(?:\\d{1,3}(?:\\.\\d{3})+|\\d{1,3}(?:${C}\\d{3})+|\\d+),\\d+${y}$`)];function R(e,r){let t=0,n=0;for(let c of e){if(typeof c!="string")continue;let i=c.trim();i===""||P.test(i)||(_.some(s=>s.test(i))?t++:j.some(s=>s.test(i))&&n++)}return n>0&&t===0?",":t>0?".":k(r)}function h(e,r){let t=String(e??"").trim();return t===""?null:r===","?N.test(t)?parseFloat(t.replace(/[.   ]/g,"").replace(",",".")):null:O.test(t)?parseFloat(t.replace(/,/g,"")):null}function M(e,r){return h(e,r)!==null}var I=500,$=/^[+-]?\d{1,15}$/,F=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,q=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function V(e,r="."){let t=0,n=0,c=0,i=0;for(let s of e){if(s==null)continue;if(typeof s=="number"){i++,n++,Number.isInteger(s)&&t++;continue}if(s instanceof Date){i++,c++;continue}if(typeof s=="boolean"){i++;continue}let l=String(s).trim();if(l!==""){if(i++,$.test(l)){t++,n++;continue}if(M(l,r)){n++;continue}if((F.test(l)||q.test(l))&&!isNaN(Date.parse(l))){c++;continue}}}return i===0?"String":c===i?"DateTime":t===i?"Integer":n===i?"Decimal":"String"}function v(e,r,t="."){if(e==null)return null;if(typeof e=="number")return r==="String"?String(e):e;if(e instanceof Date)return r==="DateTime"?e:e.toISOString();if(typeof e=="boolean")return String(e);let n=String(e).trim();if(n==="")return null;switch(r){case"Integer":return $.test(n)?parseInt(n,10):null;case"Decimal":return h(n,t);case"DateTime":return E(n);default:return n}}function B(e){let r=(e||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(r)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(r)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(r)?"DateTime":(/^(bit|bool|boolean)$/.test(r),"String")}function f(e,r,t){if(e.length===0)throw new Error("ingest: no columns were resolved from the source. Supply column descriptors, or use a source shape that carries them (grid/table/objects/sql).");let n=e.length,c=e.map((o,a)=>r.slice(0,I).map(m=>m?.[a])),i=c.map(o=>R(o,t.locale)),s=e.map((o,a)=>o.dataType??V(c[a],i[a])),l=new Set((t.measures??[]).map(o=>o.toLowerCase())),p=new Set((t.dimensions??[]).map(o=>o.toLowerCase())),L=new Set((t.nonAdditive??[]).map(o=>o.toLowerCase())),b=e.map((o,a)=>{let m=o.name.toLowerCase(),d=o.isMeasure??((s[a]==="Integer"||s[a]==="Decimal")&&!x(o.name));l.has(m)&&(d=!0),p.has(m)&&(d=!1);let D={name:o.name,dataType:s[a],isMeasure:d};return d&&L.has(m)&&(D.discourageAggregationAcrossGroups=!0),D}),u=new T;u.dedupRows=t.dedup!==!1,u.setColumns(b),u.declareDimensions(b.filter((o,a)=>p.has(e[a].name.toLowerCase())));for(let o=0;o<r.length;o++){let a=r[o];u.addRow(Array.from({length:n},(m,d)=>v(a?.[d],s[d],i[d])),o)}let S=u.getColumnsWithStats(t.privacyLevel??"20",t.locale??"en"),g=new Map(S.map(o=>[o.name,o]));e.forEach(o=>{let a=g.get(o.name);a&&(o.format&&(a.modelFormat=o.format),o.description&&(a.modelDesc=o.description))});for(let[o,a]of Object.entries(t.formats??{})){let m=g.get(o);m&&(m.modelFormat=a)}for(let[o,a]of Object.entries(t.descriptions??{})){let m=g.get(o);m&&(m.modelDesc=a)}for(let o of t.groupBy??[]){let a=g.get(o);a&&(a.isGrouping=!0)}return{columns:S,rows:u.toObjectArray(),totalRows:u.getRowCount(),index:u}}function w(e,r){return e.map(t=>Array.isArray(t)?t:r.map(n=>t[n]))}function U(e,r){let t=[],n=new Set,c=Math.min(e.length,Math.max(1,r));for(let i=0;i<c;i++){let s=e[i];if(!(!s||typeof s!="object"))for(let l of Object.keys(s))n.has(l)||(n.add(l),t.push(l))}return t}function W(e){let r=String(e??"").replace(/^\uFEFF/,""),t=[],n=[],c=0;return A.parse(r,{skipEmptyLines:!1,step:i=>{let s=i.meta.cursor,l=r.slice(c,s);c=s,i.errors?.length&&n.push(...i.errors);let p=i.data;p.length===1&&p[0]===""&&l.replace(/[\r\n]/g,"")===""||t.push(p)}}),!t.length&&!n.length&&n.push(...A.parse(r,{skipEmptyLines:!0}).errors),{rows:t,errors:n}}function Z(e,r={}){switch(e.kind){case"csv":{let t=W(e.text);if(t.errors.length&&t.rows.length===0)throw new Error(`ingest: CSV parse failed - ${t.errors[0].message}`);let n=t.rows;if(n.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let c=n[0].map(i=>(i??"").trim());return f(c.map(i=>({name:i})),n.slice(1),r)}case"grid":{if(!e.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return f(e.header.map(t=>({name:(t??"").trim()})),e.rows??[],r)}case"table":{if(!e.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let t=e.columns.map(n=>n.name);return f(e.columns,w(e.rows??[],t),r)}case"objects":{let t=e.rows??[],n=e.columns?.length?e.columns:U(t,r.columnScanLimit??I).map(c=>({name:c}));if(!n.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return f(n,w(t,n.map(c=>c.name)),r)}case"sql":{if(!e.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let t=e.schema.map(n=>{let c=B(n.dataType);return{name:n.name,dataType:c,isMeasure:n.isMeasure,format:n.format,description:n.description}});return f(t,w(e.rows??[],t.map(n=>n.name)),r)}default:{let t=e;throw new Error(`ingest: unknown source kind '${t?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{k as a,R as b,h as c,B as d,W as e,Z as f};
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 $n,b as zn}from"./chunk-HIVICMC5.mjs";import{a as Hn,b as I,c as qn,d as D,e as E,f as Kn,g as X,h as J}from"./chunk-HMLAY26J.mjs";import{a as kn,b as Gn,c as Vn,d as Un,e as Wn}from"./chunk-N52JPYZI.mjs";import{A as bn,B as En,C as Tn,D as Sn,E as Rn,F as xn,G as wn,H as _n,I as Pn,J as vn,K as On,L as Ln,M as Mn,N as In,O as Nn,P as An,Q as Fn,S as Dn,a as zt,b as Ht,c as qt,d as Kt,e as Qt,f as Xt,g as Jt,h as Zt,i as en,j as tn,k as nn,l as rn,m as on,n as sn,o as an,p as ln,q as un,r as cn,s as dn,t as mn,u as fn,v as pn,w as gn,x as yn,y as hn,z as Cn}from"./chunk-OPDY2YEA.mjs";import{a as Bt}from"./chunk-U3H6UBOO.mjs";import{a as jt,b as Yt}from"./chunk-555PKUBU.mjs";import{a as le,b as ue,c as Vt,d as Ut,e as Wt,f as $t}from"./chunk-KQOVPOVU.mjs";import{a as M,b as V,c as Y,d as U,k as W,l as Ot,m as Lt,n as ae,o as v,p as Mt,q as It,r as Nt,s as $,t as At,u as Ft,v as Dt,w as kt,x as Q,y as Gt}from"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import{a as ct,b as dt,c as mt,d as ft,e as pt,f as gt,g as yt,h as ht,i as Ct,j as bt,k as Et,l as Tt,m as _t,n as Pt,o as vt}from"./chunk-GKXYRUK5.mjs";import{A as rt,B as ot,C as it,D as st,E as at,F as lt,G as ut,a as Ae,b as Fe,c as De,d as ke,e as Ge,f as B,g as Ve,h as Ue,i as We,j as $e,k as ze,l as He,m as qe,n as Ke,o as Be,p as je,q as Ye,r as Qe,s as Xe,t as Je,u as Ze,v as et,x as j,y as tt,z as nt}from"./chunk-4VN252CK.mjs";import{b as St,c as Rt,d as xt,e as wt}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 A(e){let t=F(e);if(t.length===0||ne(e)<95)return!1;let n=t.filter(a=>te(a)&&!v(a)).length,o=t.filter(a=>!te(a)&&!!v(a)).length;return n>=1&&n>=o}function ce(e,t){if(!v(e))return!1;let n=W(e);return n?t==="world"?!0:ae.has(n):!1}function ne(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let o of t)te(o)&&n++;return Math.round(n/t.length*1e3)/10}function z(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let o of t)v(o)&&n++;return Math.round(n/t.length*1e3)/10}function oe(e){let t=new Set;for(let n of e){if(n==null)continue;let o=String(n).trim();if(!V(U(o))&&!t.has(o)&&(t.add(o),t.size>=me))break}return Array.from(t)}function re(e){let t=oe(e);if(t.length===0)return 0;let n=0;for(let o of t)$(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 Bn(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 jn(e,t){let n=0;for(let o of oe(e))t(o)&&n++;return n}function Yn(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)`):A(s)?(l.push(`state=${c} (every value is a country, not a state)`),i.country||(i.country=c)):z(s)<95?l.push(`state=${c} (only ${z(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(A(S))continue;let P=z(S);if(P<95)continue;let K=ee(S,G=>!!v(G)),Ne=ee(S,G=>!!v(G)&&!ce(G,o));K<Z&&Ne<1||(!s||P>s.pct)&&(s={name:d,pct:P})}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)&&!(jn(d,P=>$(P).length>0)<Z)){i.zip=s,p.add(s),u.push(`zip=${s} (${S}% ZIP codes)`);break}}let T=i.country;if(!T||!A(y(T))){let s=null;for(let d of b){if(p.has(d)||!A(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),P=Bn(S,o);P<Y||ee(S,K=>Q(K,o))<Z||(!s||P>s.pct)&&(s={name:d,pct:P})}s&&(i.city=s.name,u.push(`city=${s.name} (${s.pct}% known cities)`))}let O=i.country?y(i.country):[],R=!!i.country&&A(O),L=R?new Set(O.map(s=>W(s==null?null:String(s))).filter(Boolean)).size:0,x=R&&L>=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")}),Qn=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 Xn(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 Jn(e,t){let n=String(e??"").trim().normalize("NFC");if(!n)return null;for(let o of Xn(n,t)){let a=ie[o];if(a&&a.langs.includes(t))return a.part}return null}function Zn(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 er=/\b(?:columns|cols|column)\b/i;function H(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)),er.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;)H(e,i.index)&&l++;let h=0;for(;(i=a.exec(e))!==null;){let C=i.index+i[0].lastIndexOf(".name");if(!H(e,C))continue;h++;let y=ye(i[1]);if(!n(y))return!1}return h>0&&h===l}function tr(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 nr(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;)H(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 rr(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 or(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),N=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},ir=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function Re(e,t){let n={};for(let[o,a]of ir){let u=m(E(e,t+a));u&&(n[o]=u)}return n}function sr(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 ar(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:sr(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:N(t("isServiceError")),isRateLimited:N(t("isRateLimited")),isRefusal:N(t("isRefusal")),isVersionNotFound:N(t("isVersionNotFound")),isGenerationCancelled:N(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 lr(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:N(l("isPreview")),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:N(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 ur(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 cr(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 dr="FREEMIUM_ATTEMPT_SPENT",mr="CLIENT_SECRET_MISMATCH",fr="FREEMIUM_COLUMN_CAP",pr="OAUTH_TOKEN_EXPIRED",gr="OAUTH_SIGNED_OUT";function yr(e){let t=e?.retryable;return typeof t=="boolean"?t:null}function hr(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 Cr(e){let{width:t,height:n}=e.measure();return{request:{height:n,width:t},hints:{viewportWidth:t,viewportHeight:n}}}function br(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 Er(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});return{genNew:o,version:a.version,fetchOnly:a.fetchOnly,fetchCorrelationId:e.fetchCorrelationId??void 0}}function Tr(e){let t=n=>e.renderers.has(n);return{supportsD3:t("D3"),supportsPlotly:t("PLOTLY"),supportsVega:t("VEGA")}}function Sr(e){let t=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??t,maxTries:t}}function Rr(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}function Pe(e,t){return e!=null&&t!=null&&e!==t}function xr(e,t){return e?Pe(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 wr=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function ve(e){let t=String(e??"").trim().toLowerCase();return wr[t]??t}function Oe(e){let t="";for(let n of e)t+=JSON.stringify([String(n.name??""),n.isMeasure?"M":"D",ve(n.dataType)]);return t}function _r(e){return j(Oe(e))}var Pr=2,vr=3,Or=4,Lr=64,Mr=8e3,Ir=6e4,Nr=Object.freeze({RENDER_START:"render-start",RENDER_OK:"render-ok",RENDER_ERROR:"render-error",VIEW:"view",VIEW_VERDICT:"view-verdict",REDRAW:"redraw",INTERACT:"interact"}),Ar=Object.freeze(["open","generate","version","rebind","data","sample","fix","resize","other"]);function Fr(e,t){return t?`${t};draw:${e}`:`draw:${e}`}function Dr(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 kr(){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 Gr(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 Vr(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 Le=2**31-1;function Me(e){return Object.assign(new Error(`The request did not finish within ${e} ms.`),{name:"TimeoutError"})}function Ur(e){return typeof e=="number"&&e>0&&e<=Le?null:new RangeError(`fetchTransport cannot keep a deadline of ${String(e)} ms: it must be a number of milliseconds above 0 and at most ${Le} (about 24.8 days), the longest a timer can wait. Nothing was sent.`)}function Wr(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=Ur(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):_,O;try{O=await n(a,{method:"POST",body:u,headers:l,credentials:o,signal:y.signal})}catch(_){throw b(),T(_)}let R=X(O),L=R.statusText!==void 0?{statusText:R.statusText}:{};if(!R.body)return{status:R.status,...L,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,...L,contentType:R.contentType,body:w,text:()=>new Response(w).text()}}}}var Ie=300,$r="/LLMChart/",zr="/LLMChart/qualify",Hr="/VisionReview/",qr="/LLMChart/sample",Kr="/RefundGenerate/",Br=e=>!!e&&typeof e=="object"&&e.name==="TimeoutError",q=async e=>JSON.parse(await e.text());function jr(e){try{e.body?e.body.cancel().catch(()=>{}):e.text().catch(()=>{})}catch{}}function Yr(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)}`,O={"Content-Type":"text/plain","X-Signature":D(c,o)},R=p.signal??void 0,L=(w,_)=>{let s=!!R?.aborted;return{kind:"transport",headersReceived:w,timedOut:!s&&Br(_),cancelled:s,error:_}},x;try{x=await a.post(T,c,O,R?{timeoutMs:p.timeoutMs,signal:R}:{timeoutMs:p.timeoutMs})}catch(w){return L(!1,w)}if(x.status<200||x.status>299){let w="";if(p.readErrorBody===!1)jr(x);else try{w=(await x.text()).slice(0,Ie)}catch{}return{kind:"http",status:x.status,statusText:x.statusText??"",bodyStart:w}}try{return{kind:"answer",status:x.status,value:await b(x)}}catch(w){return L(!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",$r,I(g),c,b=>J(b,p))},async qualify(g,f){let c=y("qualify",f),p=c.route??zr;if(typeof p!="string"||!p.startsWith("/"))throw new TypeError("The qualify route must start with '/'");return C("qualify",p,I(g),c,q)},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",Hr,p,c,q)},async sample(g,f){let c=y("sample",f);return C("sample",qr,I(g),c,q)},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",Kr,JSON.stringify({CorrelationID:g.trim()}),c,q)}}}export{Y as CITY_ROLE_MATCH_PCT,Nr as CLIENT_EVENT_KINDS,mr as CLIENT_SECRET_MISMATCH,Ke as COMPOUND_MIN_STEM,ct as CYCLE_MEMBERS,mt as CYCLE_WORDS,ge as DATE_LEVEL_GREGORIAN_YEAR_MAX,pe as DATE_LEVEL_GREGORIAN_YEAR_MIN,Qn as DATE_LEVEL_LANGUAGES,ie as DATE_LEVEL_NAMES,fe as DATE_LEVEL_NON_GREGORIAN_LANGUAGES,En as DEFAULT_GAP_FACTOR,rt as DEFAULT_TEMPERATURE,Ar as DRAW_REASONS,dr as FREEMIUM_ATTEMPT_SPENT,fr as FREEMIUM_COLUMN_CAP,tt as GET_RANDOM,je as GLUED_STEM_MIN,Qe as HANGUL_MIN_STEM,be as HOST_SYNTHETIC_COLUMNS,Ie as HTTP_BODY_START_CHARS,pn as IDENTIFIER_HEAD_INITIAL,gn as IDENTIFIER_UNFOLDED,fn as IDENTIFIER_WORDS,Xt as INTENSIVE_SUFFIX_TOKENS,Qt as INTENSIVE_WORD_TOKENS,Dn as IndexedText,Rt as LOOSE_KEY_MIN_LENGTH,wt as LooseIndex,Tn as MAX_RUN_BOUNDS,gr as OAUTH_SIGNED_OUT,pr as OAUTH_TOKEN_EXPIRED,ht as PERIOD_CODE_FORMS,yt as PERIOD_CODE_MEMBERS,Ct as PERIOD_ORDINALS,bt as PERIOD_UNFOLDED,Zt as POSITIONAL_SUFFIX_TOKENS,Jt as POSITIONAL_WORD_TOKENS,$n as PREVIEW_OMITTED_FIELDS,we as PROGRESS_STAGE_IDS,M as ROLE_MATCH_PCT,xn as SERIES_COMPLETENESS_MAX_LISTED,wn as SERIES_COMPLETENESS_MIN_FILL,_n as SERIES_KEY_MAX_DISTINCT,Or as SEV_ERROR,Pr as SEV_INFO,Lr as SEV_USER_PRESENTED,vr as SEV_WARNING,j as SIMPLE_STRING_HASH,et as STR,Je as SUBSTRING_MIN,Ae as SUPPORTED_LANGUAGES,Fe as SUPPORTED_LANGUAGE_CODES,Ir as TELEMETRY_TIMEOUT_DEV_MS,Mr as TELEMETRY_TIMEOUT_MS,Ge as VOCABULARY_LANGUAGE_CODES,ke as VOCABULARY_ONLY_LANGUAGES,dt as YEAR_WORDS,z as admin1MatchPct,un as allowedAggregations,yr as answerIsRetryable,$t as buildGeoIsoColumn,Dt as buildGeoPointColumns,ft as calendarWordIn,Tr as capabilityFields,Gt as cityMatchPct,kt as cityTagsFor,An as classifyAdditivity,Dr as classifyDraw,ln as classifyForAggregation,Fn as classifyNumericValueNature,In as classifyTemporal,rn as codeNeedsLegacyAggNames,hn as codeReadsColumn,Cn as codeReadsColumnsByRoleOrPosition,nn as collapseRepeatedAggPrefix,bn as columnsTheCodeReads,qt as countryRegion,kr as createDrawLedger,Yr as createGenerateClient,Vr as createTelemetryClient,hr as credentialFields,Jn as dateLevelPart,Zn as dateLevelYearAdmits,kn as decimalSeparatorOf,cn as defaultAggregation,Gn as detectDecimalSeparator,Bt as detectFormatSignature,Vt as detectGeo,vt as detectOrdinalDomain,Mn as detectTextDatePattern,Fr as drawLocation,I as encodePayload,Un as engineTypeForSqlType,on as englishImplicitAggNames,se as eventLogLine,Er as fetchFields,Wr as fetchTransport,Ue as foldName,or as freemiumColumnCapRefusal,Ee as freemiumColumnsOverCap,Te as freemiumDateHierarchyClauses,Ye as gluedPrefixStems,rr as guardColumnNames,Hn as gzipWireText,Xe as hangulWordEndsWith,tn as hasDefaultAggPrefix,He as hasUnsegmentedScript,Nn as hostAggHint,Wn as ingest,dn as isAggregationAllowed,V as isBlankLike,Lt as isCityTableLoaded,H as isColumnContextRef,nt as isDeterministicRefusal,Gr as isEventLogCode,At as isGeoPointAmbiguity,Ln as isIdentifierName,Wt as isJoinGeoKind,Kn as isNdjsonContentType,_t as isOrdinalFriendlyName,xt as isUsableLooseKey,qn as keyedSigner,Rr as leafCardinalityField,lt as localMidnightDateColumns,at as localMidnightToUtcDay,gt as localizedCycleIn,yn as localizedIdentifierWordIn,pt as localizedYearWordIn,A as looksLikeCountryColumn,St as looseNameKey,Ze as matchNameToken,br as maxNonMeasureCardinality,Rn as measureCadence,On as measureSeriesCompleteness,D as messageSignature,nr as missingHardColumnRefs,Yt as monthLookupFor,$e as nameLetterRuns,an as nameLooksIntensiveRate,sn as nameLooksPositional,he as nameProbeIsGuarded,tr as nameProbeKeepsDrawing,We as nameWords,Mt as normalizeCountry,ut as normalizeLocalMidnightDates,jt as normalizeMonthKey,U as normalizePlaceName,Nt as normalizeZip5,xr as offeredShortlistFor,ot as parseDateStable,ar as parseGenerateResponse,Vn as parseNumberText,lr as parseQualifyResponse,ur as parseReviewVerdict,Sn as parseTemporalPoint,zn as payloadPreview,Tt as periodCodeSeries,vn as pickSeriesColumn,cr as progressStageOf,J as readGenerateStream,ze as readName,Et as readPeriodCode,E as readWireField,Ot as registerCityTable,Ht as registerIso3Regions,v as resolveAdmin1,_e as resolveFetchVersion,Ft as resolveGeoPoint,Ve as resolveLanguage,Yn as resolvePointRoles,Sr as retryFields,Pt as safeDistinctValuesToShip,Oe as schemaIdentity,_r as schemaIdentityKey,ve as schemaTypeFamily,Pn as seriesKeyVerdict,mn as shareOfTotalIsHonest,Pe as shortlistIsStale,en as stripHostAggPrefix,Kt as summarizeCountryRegions,zt as summarizeGeoExtent,De as supportedLanguage,Ut as toGeoIso,qe as unsegmentedRuns,Cr as viewportFields,B as vocabularyLanguage,it as wholeDayFrame,st as wholeDayIso,X as wireResponseFromFetch,Be as wordEndsWith,re as zipMatchPct,$ as zipPrefixCandidates,It as zipToPrefix3};
2
+ import{a as zn,b as Hn}from"./chunk-HIVICMC5.mjs";import{a as Kn,b as I,c as Bn,d as D,e as E,f as jn,g as X,h as J}from"./chunk-HMLAY26J.mjs";import{a as Gn,b as Vn,c as Un,d as Wn,e as qn,f as $n}from"./chunk-O46IPJKL.mjs";import{A as En,B as Tn,C as Sn,D as Rn,E as xn,F as wn,G as _n,H as On,I as vn,J as Pn,K as Ln,L as An,M as Mn,N as In,O as Nn,P as Fn,Q as Dn,S as kn,a as zt,b as Ht,c as Kt,d as Bt,e as Xt,f as Jt,g as Zt,h as en,i as tn,j as nn,k as rn,l as on,m as sn,n as an,o as ln,p as un,q as cn,r as dn,s as mn,t as fn,u as pn,v as gn,w as yn,x as hn,y as Cn,z as bn}from"./chunk-OPDY2YEA.mjs";import{a as jt}from"./chunk-U3H6UBOO.mjs";import{a as Yt,b as Qt}from"./chunk-555PKUBU.mjs";import{a as le,b as ue,c as Ut,d as Wt,e as qt,f as $t}from"./chunk-KQOVPOVU.mjs";import{a as M,b as V,c as Y,d as U,k as W,l as Lt,m as At,n as ae,o as v,p as Mt,q as It,r as Nt,s as q,t as Ft,u as Dt,v as kt,w as Gt,x as Q,y as Vt}from"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import{a as dt,b as mt,c as ft,d as pt,e as gt,f as yt,g as ht,h as Ct,i as bt,j as Et,k as Tt,l as St,m as Ot,n as vt,o as Pt}from"./chunk-GKXYRUK5.mjs";import{A as ot,B as it,C as st,D as at,E as lt,F as ut,G as ct,a as Fe,b as De,c as ke,d as Ge,e as Ve,f as B,g as Ue,h as We,i as qe,j as $e,k as ze,l as He,m as Ke,n as Be,o as je,p as Ye,q as Qe,r as Xe,s as Je,t as Ze,u as et,v as tt,x as j,y as nt,z as rt}from"./chunk-4VN252CK.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(l=>te(l)&&!v(l)).length,o=t.filter(l=>!te(l)&&!!v(l)).length;return n>=1&&n>=o}function ce(e,t){if(!v(e))return!1;let n=W(e);return n?t==="world"?!0:ae.has(n):!1}function ne(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let o of t)te(o)&&n++;return Math.round(n/t.length*1e3)/10}function $(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let o of t)v(o)&&n++;return Math.round(n/t.length*1e3)/10}function oe(e){let t=new Set;for(let n of e){if(n==null)continue;let o=String(n).trim();if(!V(U(o))&&!t.has(o)&&(t.add(o),t.size>=me))break}return Array.from(t)}function re(e){let t=oe(e);if(t.length===0)return 0;let n=0;for(let o of t)q(o).length>0&&n++;return Math.round(n/t.length*1e3)/10}function de(e,t){return ue(t,le)?!0:oe(e).some(n=>/^\d{5}(-\d{4})?$/.test(n.replace(/\.0+$/,"")))}function Yn(e,t){let n=F(e);if(n.length===0)return 0;let o=0;for(let l of n)Q(l,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,l){let u=[],a=[],i={},h={},C=new Set(e),y=s=>t.map(d=>d[s]);for(let s of["city","country"]){let d=n?.[s];d&&C.has(d)&&(i[s]=d)}let g=new Set(l??e);for(let s of["lat","lon"]){let d=n?.[s];d&&g.has(d)&&(i[s]=d)}let f=n?.zip;if(f&&C.has(f)){let s=y(f),d=re(s);d<95?a.push(`zip=${f} (only ${d}% of values read as ZIPs)`):de(s,f)?i.zip=f:a.push(`zip=${f} (all values are 3-4 digits with nothing to say they are postal)`)}let c=n?.state;if(c&&C.has(c)){let s=y(c),d=F(s);d.length>0&&d.every(S=>ce(S,o))?a.push(`state=${c} (every value is "CA", which is both Canada and California)`):N(s)?(a.push(`state=${c} (every value is a country, not a state)`),i.country||(i.country=c)):$(s)<95?a.push(`state=${c} (only ${$(s)}% of values are states/provinces)`):i.state=c}let p=new Set(Object.values(i).filter(Boolean)),b=e.filter(s=>!p.has(s)&&!s.startsWith("__"));if(!i.state){let s=null;for(let d of b){let S=y(d);if(N(S))continue;let O=$(S);if(O<95)continue;let K=ee(S,G=>!!v(G)),Ne=ee(S,G=>!!v(G)&&!ce(G,o));K<Z&&Ne<1||(!s||O>s.pct)&&(s={name:d,pct:O})}s&&(i.state=s.name,p.add(s.name),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&&(a.push(`country=${T} (only ${ne(y(T))}% of values are country identifiers; using ${s.name} instead)`),h.country=T),i.country=s.name,p.add(s.name),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&&a.push(`lat/lon=${i.lat}/${i.lon} (no row holds a usable coordinate pair)`),i.country&&!x&&!(i.city||i.state||i.zip||w)&&a.push(R?`country=${i.country} (every row resolves to the same country - nothing to place apart)`:`country=${i.country} (values are not country identifiers)`),{bind:!!(i.city||i.state||i.zip||x||w)?i:null,backfilled:u,refused:a,...Object.keys(h).length?{labelFallback:h}:{}}}var r=(e,...t)=>({part:e,langs:Object.freeze(t)}),ie=Object.freeze({jaar:r("year","nl"),kwartaal:r("quarter","nl"),maand:r("month","nl"),dag:r("day","nl","sv","da","nb"),jahr:r("year","de"),quartal:r("quarter","de"),monat:r("month","de"),tag:r("day","de"),ann\u00E9e:r("year","fr"),mois:r("month","fr"),jour:r("day","fr"),trimestre:r("quarter","fr","es","pt","it"),a\u00F1o:r("year","es"),mes:r("month","es"),d\u00EDa:r("day","es"),ano:r("year","pt"),m\u00EAs:r("month","pt"),dia:r("day","pt"),anno:r("year","it"),mese:r("month","it"),giorno:r("day","it"),\u0433\u043E\u0434:r("year","ru"),\u043C\u0435\u0441\u044F\u0446:r("month","ru"),\u0440\u0456\u043A:r("year","uk"),\u043C\u0456\u0441\u044F\u0446\u044C:r("month","uk"),\u043A\u0432\u0430\u0440\u0442\u0430\u043B:r("quarter","ru","uk"),\u0434\u0435\u043D\u044C:r("day","ru","uk"),rok:r("year","pl","cs","sk"),kwarta\u0142:r("quarter","pl"),miesi\u0105c:r("month","pl"),dzie\u0144:r("day","pl"),\u010Dtvrtlet\u00ED:r("quarter","cs"),m\u011Bs\u00EDc:r("month","cs"),den:r("day","cs"),\u0161tvr\u0165rok:r("quarter","sk"),mesiac:r("month","sk"),de\u0148:r("day","sk"),\u00E5r:r("year","sv","da","nb"),kvartal:r("quarter","sv","da","nb"),m\u00E5nad:r("month","sv"),m\u00E5ned:r("month","da","nb"),vuosi:r("year","fi"),vuosinelj\u00E4nnes:r("quarter","fi"),kuukausi:r("month","fi"),p\u00E4iv\u00E4:r("day","fi"),\u00E9v:r("year","hu"),negyed\u00E9v:r("quarter","hu"),h\u00F3nap:r("month","hu"),nap:r("day","hu"),y\u0131l:r("year","tr"),\u00E7eyrek:r("quarter","tr"),ay:r("month","tr"),g\u00FCn:r("day","tr"),\u03AD\u03C4\u03BF\u03C2:r("year","el"),\u03C4\u03C1\u03AF\u03BC\u03B7\u03BD\u03BF:r("quarter","el"),\u03BC\u03AE\u03BD\u03B1\u03C2:r("month","el"),\u03B7\u03BC\u03AD\u03C1\u03B1:r("day","el"),an:r("year","ro"),trimestru:r("quarter","ro"),lun\u0103:r("month","ro"),zi:r("day","ro"),godina:r("year","hr"),tromjese\u010Dje:r("quarter","hr"),mjesec:r("month","hr"),dan:r("day","hr"),\u5E74:r("year","ja","zh"),\u56DB\u534A\u671F:r("quarter","ja"),\u5B63\u5EA6:r("quarter","zh"),\u6708:r("month","ja","zh"),\u65E5:r("day","ja","zh"),\uC5F0\uB3C4:r("year","ko"),\uBD84\uAE30:r("quarter","ko"),\uC6D4:r("month","ko"),\uC77C:r("day","ko"),tahun:r("year","id"),kuartal:r("quarter","id"),triwulan:r("quarter","id"),bulan:r("month","id"),hari:r("day","id"),n\u0103m:r("year","vi"),qu\u00FD:r("quarter","vi"),th\u00E1ng:r("month","vi"),ng\u00E0y:r("day","vi"),\u0E1B\u0E35:r("year","th"),\u0E44\u0E15\u0E23\u0E21\u0E32\u0E2A:r("quarter","th"),\u0E40\u0E14\u0E37\u0E2D\u0E19:r("month","th"),\u0E27\u0E31\u0E19:r("day","th"),\u0627\u0644\u0633\u0646\u0629:r("year","ar"),\u0633\u0646\u0629:r("year","ar"),\u0627\u0644\u0639\u0627\u0645:r("year","ar"),\u0639\u0627\u0645:r("year","ar"),\u0627\u0644\u0631\u0628\u0639:r("quarter","ar"),\u0631\u0628\u0639:r("quarter","ar"),"\u0631\u0628\u0639 \u0627\u0644\u0633\u0646\u0629":r("quarter","ar"),\u0627\u0644\u0634\u0647\u0631:r("month","ar"),\u0634\u0647\u0631:r("month","ar"),\u0627\u0644\u064A\u0648\u0645:r("day","ar"),\u064A\u0648\u0645:r("day","ar"),\u05E9\u05E0\u05D4:r("year","he"),\u05E8\u05D1\u05E2\u05D5\u05DF:r("quarter","he"),\u05D7\u05D5\u05D3\u05E9:r("month","he"),\u05D9\u05D5\u05DD:r("day","he"),\u0935\u0930\u094D\u0937:r("year","hi"),\u0938\u093E\u0932:r("year","hi"),\u0924\u093F\u092E\u093E\u0939\u0940:r("quarter","hi"),\u092E\u0939\u0940\u0928\u093E:r("month","hi"),\u092E\u093E\u0939:r("month","hi"),\u0926\u093F\u0928:r("day","hi"),\u0633\u0627\u0644:r("year","fa"),\u0645\u0627\u0647:r("month","fa"),\u0631\u0648\u0632:r("day","fa")}),Jn=Object.freeze(Array.from(new Set(Object.values(ie).flatMap(e=>e.langs)))),fe=Object.freeze(["fa","ar","he","th"]),pe=1900,ge=2100;function Zn(e,t){let n=[],o=B(t);try{o&&n.push(e.toLocaleLowerCase(o.intl))}catch{}let l=e.toLowerCase();return n.includes(l)||n.push(l),n}function er(e,t){let n=String(e??"").trim().normalize("NFC");if(!n)return null;for(let o of Zn(n,t)){let l=ie[o];if(l&&l.langs.includes(t))return l.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),l=o.lastIndexOf(";");return l>=0&&(o=o.slice(l+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),l=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"),a=0,i;for(;(i=u.exec(e))!==null;)z(e,i.index)&&a++;let h=0;for(;(i=l.exec(e))!==null;){let C=i.index+i[0].lastIndexOf(".name");if(!z(e,C))continue;h++;let y=ye(i[1]);if(!n(y))return!1}return h>0&&h===a}function rr(e,t){return Ce(e,t,n=>new RegExp(String.raw`\b${n}\s*(?:>=\s*0|>\s*-1|!==?\s*-1)`).test(e)&&!new RegExp(String.raw`\b${n}\s*===?\s*-1`).test(e))}var be=["__rowIdx__","__geoIso__","__geoLat__","__geoLon__","__geoPrecision__"];function or(e,t){if(!e)return[];let n=new Set(t);for(let i of be)n.add(i);let o=new Set,l=/\.name\s*===?\s*(['"])([^'"]+)\1/g,u;for(;(u=l.exec(e))!==null;)z(e,u.index)&&o.add(u[2]);if(o.size===0)return[];let a=[];return o.forEach(i=>{n.has(i)||he(e,i)||a.push(i)}),a}function ir(e,t){if(!e)return[];let n=(e.getColumns()||[]).map(o=>o.name);if(!t||typeof e.aliasesForCode!="function")return n;for(let o of e.aliasesForCode(t))n.push(o.alias);return n}function Ee(e,t){let n=t?.freemiumMaxShapeColumns;return typeof n!="number"||!isFinite(n)||n<1?null:!isFinite(e)||e<=n?0:Math.round(e-n)}function sr(e,t,n){let o=Ee(e,t);if(o===null||o<=0)return null;let l=typeof t?.freemiumColumnCapPivot=="number"?t.freemiumColumnCapPivot:4,u=o>l?t?.freemiumColumnCapMessageMany:t?.freemiumColumnCapMessageFew;if(typeof u!="string"||u.trim().length===0)return null;let a=u.split("{n}").join(String(o)).split("{fields}").join(o===1?"field":"fields"),i=Te(n);return i.length===0?a:a+" "+i.join(" ")}function Te(e){if(!e||e.length===0)return[];let t=[],n=new Map,o=new Map;for(let u of e){let a=typeof u?.dateGroupId=="string"?u.dateGroupId.trim():"";if(a!==""&&(n.has(a)||(t.push(a),n.set(a,0)),u.isDatePart===!0&&n.set(a,n.get(a)+1),u.isReassembledDate===!0&&!o.has(a))){let i=typeof u.sourceField=="string"?u.sourceField.trim():"",h=typeof u.name=="string"?u.name.trim():"",C=i!==""?i:h;C!==""&&o.set(a,C)}}let l=[];for(let u of t){let a=o.get(u),i=n.get(u)??0;!a||i===0||l.push(`'${a}' is a date hierarchy and counts as ${i+1} fields - bind the date itself instead of its hierarchy.`)}return l}var m=e=>e==null?"":String(e),P=e=>e===!0,Se=e=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let t=Number(e);return Number.isFinite(t)?t:null}return null},ar=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function Re(e,t){let n={};for(let[o,l]of ar){let u=m(E(e,t+l));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"),l=t("forceThumbnailUpload"),u=Re(e,"point"),a=Re(e,"destPoint");Object.keys(a).length&&(u.dest=a);let i=t("retryable"),h=t("isPollFinal");return{errorMessage:m(t("errorMessage")),errorCode:m(t("errorCode")),refusalCode:m(t("refusalCode")),retryable:typeof i=="boolean"?i:null,notices:lr(t("notices")),freemiumStatusCode:m(t("freemiumStatusCode")),code:m(t("code")),language:m(t("language")),version:Number(t("version")??0),codeSummary:m(t("codeSummary")),chartName:m(t("chartName")??t("chartType")),finalChartName:m(t("finalChartName")),warningMessage:m(t("warningMessage")),outputHash:m(t("outputHash")),validatorToken:m(t("validatorToken")),editCodeKey:m(t("editCodeKey")),signedLLMRequestID:m(t("signedLLMRequestID")),userReply:m(t("userReply")),userReplyOutcome:m(t("userReplyOutcome")),improvementSuggestion:m(t("improvementSuggestion")),geoColumn:m(t("geoColumn")),geoKind:m(t("geoKind")),geoPointCols:Object.keys(u).length?u:null,creditBalanceBefore:Se(t("creditBalanceBefore")),creditCost:Se(t("creditCost")),isServiceError:P(t("isServiceError")),isRateLimited:P(t("isRateLimited")),isRefusal:P(t("isRefusal")),isVersionNotFound:P(t("isVersionNotFound")),isGenerationCancelled:P(t("isGenerationCancelled")),retryAfterSeconds:typeof n=="number"&&Number.isFinite(n)?n:null,servedCorrelationId:m(t("servedCorrelationId")),...typeof h=="boolean"?{isPollFinal:h}:{},...m(t("pollOutcome"))!==""?{pollOutcome:m(t("pollOutcome"))}:{},...typeof o=="boolean"?{overrideThumbnailUpload:o}:{},...typeof l=="boolean"?{forceThumbnailUpload:l}:{}}}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 a=h=>E(u,h),i=a("recommended");return{name:m(a("chartTypeName")??a("name")),description:m(a("description")??a("chartDesc")),rank:xe(a("rank")),score:xe(a("score")),renderer:k(a("renderer")),language:k(a("language")),isPreview:P(a("isPreview")),alsoWorthALook:P(a("alsoWorthALook")),recommended:typeof i=="boolean"?i:void 0,viaProjection:k(a("viaProjection")),viaProjectionKey:k(a("viaProjectionKey")),detailNote:k(a("detailNote"))}}).filter(u=>u.name):null,l=Array.isArray(n)?n.map(u=>({name:m(E(u,"chartTypeName")??E(u,"name")),reason:m(E(u,"reason")),reasonCode:m(E(u,"reasonCode")),isVeto:P(E(u,"isVeto"))})).filter(u=>u.name):[];return{errorMessage:m(E(e,"errorMessage")),errorCode:m(E(e,"errorCode")),charts:o,refused:l,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,l=n??o??t;return{version:l,fetchOnly:l!=null&&l>0?!0:void 0}}function Sr(e){let t=e.fetchCorrelationId!=null,o=t||e.recoveryFetchVersion!=null?!1:e.genNew,l=_e({genNew:o,recoveryFetchVersion:e.recoveryFetchVersion,recoveryFetchByCorrelation:t,settingVersion:e.settingVersion,codeVersion:e.codeVersion});return{genNew:o,version:l.version,fetchOnly:l.fetchOnly,fetchCorrelationId:e.fetchCorrelationId??void 0}}function Rr(e){let t=n=>e.renderers.has(n);return{supportsD3:t("D3"),supportsPlotly:t("PLOTLY"),supportsVega:t("VEGA")}}function xr(e){let t=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??t,maxTries:t}}function wr(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}var _r={fit:"Best fit",variety:"Something different"};function Oe(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="fit"||t==="variety"?t:null}function Or(e){let t=Oe(e);return t?{qualifyOrder:t}:{}}function ve(e,t){return e!=null&&t!=null&&e!==t}function vr(e,t){return e?ve(t.capturedFor,t.now)?{shortlist:void 0,stale:!0}:{shortlist:{...e,ageMs:t.atMs>0?Math.max(0,Math.round(t.nowMs-t.atMs)):void 0},stale:!1}:{shortlist:void 0,stale:!1}}var Pr=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function Pe(e){let t=String(e??"").trim().toLowerCase();return Pr[t]??t}function Le(e){let t="";for(let n of e)t+=JSON.stringify([String(n.name??""),n.isMeasure?"M":"D",Pe(n.dataType)]);return t}function Lr(e){return j(Le(e))}var Ar=2,Mr=3,Ir=4,Nr=64,Fr=8e3,Dr=6e4,kr=Object.freeze({RENDER_START:"render-start",RENDER_OK:"render-ok",RENDER_ERROR:"render-error",VIEW:"view",VIEW_VERDICT:"view-verdict",REDRAW:"redraw",INTERACT:"interact"}),Gr=Object.freeze(["open","generate","version","rebind","data","sample","fix","resize","other"]);function Vr(e,t){return t?`${t};draw:${e}`:`draw:${e}`}function Ur(e){return e.hint?e.hint:e.generated?"generate":e.previous?e.outputHash!==e.previous.outputHash?"version":e.dataSignature!==e.previous.dataSignature?"data":e.viewport!==e.previous.viewport?"resize":"other":"open"}function Wr(){let e=new Set,t=new Set;return{firstDraw(n,o){if(!n)return!1;let l=`${n}|${o}`;return e.has(l)?!1:(e.add(l),!0)},firstInteract(n){return!n||t.has(n)?!1:(t.add(n),!0)}}}function qr(e){return!!e&&!e.includes("|")&&!e.includes(",")}function se(e,t,n,o){let l=`${e},${t}|${n}`;return o?`${l}|${Math.max(0,Math.round(o.count))}|${o.nonce}`:l}function $r(e,t){let n=e;if(!n||!n.signer||typeof n.signer.sign!="function")throw new TypeError("createTelemetryClient needs the host's signer");if(!n.transport||typeof n.transport.post!="function")throw new TypeError("createTelemetryClient needs the host's transport");if(!n.clock||typeof n.clock.now!="function")throw new TypeError("createTelemetryClient needs the host's clock");if(!t||typeof t.baseUrl!="string"&&typeof t.baseUrl!="function")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof t.baseUrl=="string"&&t.baseUrl==="")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof t.clientVersion!="string"||t.clientVersion==="")throw new TypeError("createTelemetryClient needs the client version");if(typeof t.timeoutMs!="number"||!Number.isFinite(t.timeoutMs)||t.timeoutMs<=0)throw new TypeError("createTelemetryClient needs a positive deadline in milliseconds");let{signer:o,transport:l,clock:u}=n,a=t.apiPath??"/api",i=t.timeoutMs,h=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,C=g=>{try{t.onFailure?.(g)}catch{}},y=async(g,f,c,p)=>{let b;try{let T=await l.post(f,c,p,{timeoutMs:i});b=T.status;try{T.body?.cancel().catch(()=>{})}catch{}}catch(T){C({channel:g,stage:"post",status:null,error:T});return}(b<200||b>299)&&C({channel:g,stage:"status",status:b,error:null})};return{async sendClientMessage(g){let f,c,p;try{f=`${h()}${a}/LogClientMsg/?nocache=${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()}${a}/eventlog`,b=se(g,t.clientVersion,f,c)}catch(T){C({channel:"event-count",stage:"build",status:null,error:T});return}await y("event-count",p,b,{"Content-Type":"text/plain"})}}}var Ae=2**31-1;function Me(e){return Object.assign(new Error(`The request did not finish within ${e} ms.`),{name:"TimeoutError"})}function zr(e){return typeof e=="number"&&e>0&&e<=Ae?null:new RangeError(`fetchTransport cannot keep a deadline of ${String(e)} ms: it must be a number of milliseconds above 0 and at most ${Ae} (about 24.8 days), the longest a timer can wait. Nothing was sent.`)}function Hr(e,t={}){if(typeof e!="function")throw new TypeError("fetchTransport needs the host's fetch");let n=e,o=t.credentials??"omit";return{async post(l,u,a,i){let h=i.timeoutMs,C=zr(h);if(C)throw C;let y=new AbortController,g=!1,f=setTimeout(()=>{g=!0,y.abort(Me(h))},h),c=()=>y.abort(i.signal?.reason);i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c,{once:!0}));let p=!1,b=()=>{p||(p=!0,clearTimeout(f),i.signal?.removeEventListener("abort",c))},T=_=>g?Me(h):_,L;try{L=await n(l,{method:"POST",body:u,headers:a,credentials:o,signal:y.signal})}catch(_){throw b(),T(_)}let R=X(L),A=R.statusText!==void 0?{statusText:R.statusText}:{};if(!R.body)return{status:R.status,...A,contentType:R.contentType,body:null,text:async()=>{try{return await R.text()}catch(_){throw T(_)}finally{b()}}};let x=R.body.getReader(),w=new ReadableStream({async pull(_){try{let s=await x.read();if(s.done){b(),_.close();return}_.enqueue(s.value)}catch(s){b(),_.error(T(s))}},cancel(_){return b(),x.cancel(_)}});return{status:R.status,...A,contentType:R.contentType,body:w,text:()=>new Response(w).text()}}}}var Ie=300,Kr="/LLMChart/",Br="/LLMChart/qualify",jr="/VisionReview/",Yr="/LLMChart/sample",Qr="/RefundGenerate/",Xr=e=>!!e&&typeof e=="object"&&e.name==="TimeoutError",H=async e=>JSON.parse(await e.text());function Jr(e){try{e.body?e.body.cancel().catch(()=>{}):e.text().catch(()=>{})}catch{}}function Zr(e,t){let n=e;if(!n||!n.signer||typeof n.signer.sign!="function")throw new TypeError("createGenerateClient needs the host's signer");if(!n.transport||typeof n.transport.post!="function")throw new TypeError("createGenerateClient needs the host's transport");if(!n.clock||typeof n.clock.now!="function")throw new TypeError("createGenerateClient needs the host's clock");if(!t||typeof t.baseUrl!="string"&&typeof t.baseUrl!="function")throw new TypeError("createGenerateClient needs the service's base URL");if(typeof t.baseUrl=="string"&&t.baseUrl==="")throw new TypeError("createGenerateClient needs the service's base URL");if(t.apiPath!==void 0&&typeof t.apiPath!="string")throw new TypeError("createGenerateClient's apiPath must be a string");if(t.nocache!==void 0&&t.nocache!==null&&typeof t.nocache!="function")throw new TypeError("createGenerateClient's nocache must be a function");let{signer:o,transport:l,clock:u}=n,a=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()}${a}${f}?nocache=${h(g)}`,L={"Content-Type":"text/plain","X-Signature":D(c,o)},R=p.signal??void 0,A=(w,_)=>{let s=!!R?.aborted;return{kind:"transport",headersReceived:w,timedOut:!s&&Xr(_),cancelled:s,error:_}},x;try{x=await l.post(T,c,L,R?{timeoutMs:p.timeoutMs,signal:R}:{timeoutMs:p.timeoutMs})}catch(w){return A(!1,w)}if(x.status<200||x.status>299){let w="";if(p.readErrorBody===!1)Jr(x);else try{w=(await x.text()).slice(0,Ie)}catch{}return{kind:"http",status:x.status,statusText:x.statusText??"",bodyStart:w}}try{return{kind:"answer",status:x.status,value:await b(x)}}catch(w){return A(!0,w)}}function y(g,f){if(!f||typeof f.timeoutMs!="number"||!Number.isFinite(f.timeoutMs)||f.timeoutMs<=0)throw new TypeError(`The ${g} call needs a positive deadline in milliseconds`);return f}return{async generate(g,f){let c=y("generate",f),p=c.onStage??void 0;return C("generate",Kr,I(g),c,b=>J(b,p))},async qualify(g,f){let c=y("qualify",f),p=c.route??Br;if(typeof p!="string"||!p.startsWith("/"))throw new TypeError("The qualify route must start with '/'");return C("qualify",p,I(g),c,H)},async review(g,f){let c=y("review",f),p=JSON.stringify(g);if(typeof p!="string")throw new TypeError("The review wire did not serialize to JSON");return C("review",jr,p,c,H)},async sample(g,f){let c=y("sample",f);return C("sample",Yr,I(g),c,H)},async refund(g,f){let c=y("refund",f);if(typeof g!="string"||g.trim()==="")throw new TypeError("A refund needs the generation's correlation id");return C("refund",Qr,JSON.stringify({CorrelationID:g.trim()}),c,H)}}}export{Y as CITY_ROLE_MATCH_PCT,kr as CLIENT_EVENT_KINDS,pr as CLIENT_SECRET_MISMATCH,Be as COMPOUND_MIN_STEM,dt as CYCLE_MEMBERS,ft as CYCLE_WORDS,ge as DATE_LEVEL_GREGORIAN_YEAR_MAX,pe as DATE_LEVEL_GREGORIAN_YEAR_MIN,Jn as DATE_LEVEL_LANGUAGES,ie as DATE_LEVEL_NAMES,fe as DATE_LEVEL_NON_GREGORIAN_LANGUAGES,Tn as DEFAULT_GAP_FACTOR,ot as DEFAULT_TEMPERATURE,Gr as DRAW_REASONS,fr as FREEMIUM_ATTEMPT_SPENT,gr as FREEMIUM_COLUMN_CAP,nt as GET_RANDOM,Ye as GLUED_STEM_MIN,Xe as HANGUL_MIN_STEM,be as HOST_SYNTHETIC_COLUMNS,Ie as HTTP_BODY_START_CHARS,gn as IDENTIFIER_HEAD_INITIAL,yn as IDENTIFIER_UNFOLDED,pn as IDENTIFIER_WORDS,Jt as INTENSIVE_SUFFIX_TOKENS,Xt as INTENSIVE_WORD_TOKENS,kn as IndexedText,xt as LOOSE_KEY_MIN_LENGTH,_t as LooseIndex,Sn 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,en as POSITIONAL_SUFFIX_TOKENS,Zt as POSITIONAL_WORD_TOKENS,zn as PREVIEW_OMITTED_FIELDS,we as PROGRESS_STAGE_IDS,_r as QUALIFY_ORDER_LABELS,M as ROLE_MATCH_PCT,wn as SERIES_COMPLETENESS_MAX_LISTED,_n as SERIES_COMPLETENESS_MIN_FILL,On as SERIES_KEY_MAX_DISTINCT,Ir as SEV_ERROR,Ar as SEV_INFO,Nr as SEV_USER_PRESENTED,Mr as SEV_WARNING,j as SIMPLE_STRING_HASH,tt as STR,Ze as SUBSTRING_MIN,Fe as SUPPORTED_LANGUAGES,De as SUPPORTED_LANGUAGE_CODES,Dr as TELEMETRY_TIMEOUT_DEV_MS,Fr as TELEMETRY_TIMEOUT_MS,Ve as VOCABULARY_LANGUAGE_CODES,Ge as VOCABULARY_ONLY_LANGUAGES,mt as YEAR_WORDS,$ as admin1MatchPct,cn as allowedAggregations,Cr as answerIsRetryable,$t as buildGeoIsoColumn,kt as buildGeoPointColumns,pt as calendarWordIn,Rr as capabilityFields,Vt as cityMatchPct,Gt as cityTagsFor,Fn as classifyAdditivity,Ur as classifyDraw,un as classifyForAggregation,Dn as classifyNumericValueNature,In as classifyTemporal,on as codeNeedsLegacyAggNames,Cn as codeReadsColumn,bn as codeReadsColumnsByRoleOrPosition,rn as collapseRepeatedAggPrefix,En as columnsTheCodeReads,Kt as countryRegion,Wr as createDrawLedger,Zr as createGenerateClient,$r as createTelemetryClient,br as credentialFields,er as dateLevelPart,tr as dateLevelYearAdmits,Gn as decimalSeparatorOf,dn as defaultAggregation,Vn as detectDecimalSeparator,jt as detectFormatSignature,Ut as detectGeo,Pt as detectOrdinalDomain,Mn as detectTextDatePattern,Vr as drawLocation,I as encodePayload,Wn as engineTypeForSqlType,sn as englishImplicitAggNames,se as eventLogLine,Sr as fetchFields,Hr as fetchTransport,We as foldName,sr as freemiumColumnCapRefusal,Ee as freemiumColumnsOverCap,Te as freemiumDateHierarchyClauses,Qe as gluedPrefixStems,ir as guardColumnNames,Kn as gzipWireText,Je as hangulWordEndsWith,nn as hasDefaultAggPrefix,He as hasUnsegmentedScript,Nn as hostAggHint,$n as ingest,mn as isAggregationAllowed,V as isBlankLike,At as isCityTableLoaded,z as isColumnContextRef,rt as isDeterministicRefusal,qr as isEventLogCode,Ft as isGeoPointAmbiguity,An 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,hn as localizedIdentifierWordIn,gt as localizedYearWordIn,N as looksLikeCountryColumn,Rt as looseNameKey,et as matchNameToken,Tr as maxNonMeasureCardinality,xn as measureCadence,Ln as measureSeriesCompleteness,D as messageSignature,or as missingHardColumnRefs,Qt as monthLookupFor,$e as nameLetterRuns,ln as nameLooksIntensiveRate,an as nameLooksPositional,he as nameProbeIsGuarded,rr as nameProbeKeepsDrawing,qe as nameWords,Mt as normalizeCountry,ct as normalizeLocalMidnightDates,Yt as normalizeMonthKey,U as normalizePlaceName,Nt as normalizeZip5,vr as offeredShortlistFor,qn as parseCsvRows,it as parseDateStable,ur as parseGenerateResponse,Un as parseNumberText,cr as parseQualifyResponse,dr as parseReviewVerdict,Rn as parseTemporalPoint,Hn as payloadPreview,St as periodCodeSeries,Pn as pickSeriesColumn,mr as progressStageOf,Or as qualifyOrderField,Oe as qualifyOrderOf,J as readGenerateStream,ze as readName,Tt as readPeriodCode,E as readWireField,Lt as registerCityTable,Ht as registerIso3Regions,v as resolveAdmin1,_e as resolveFetchVersion,Dt as resolveGeoPoint,Ue as resolveLanguage,Xn as resolvePointRoles,xr as retryFields,vt as safeDistinctValuesToShip,Le as schemaIdentity,Lr as schemaIdentityKey,Pe as schemaTypeFamily,vn as seriesKeyVerdict,fn as shareOfTotalIsHonest,ve as shortlistIsStale,tn 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};
package/dist/ingest.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
- import{d as a,e as b}from"./chunk-N52JPYZI.mjs";import"./chunk-OPDY2YEA.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-555PKUBU.mjs";import"./chunk-KQOVPOVU.mjs";import"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-GKXYRUK5.mjs";import"./chunk-4VN252CK.mjs";import"./chunk-5HI6TVMM.mjs";export{a as engineTypeForSqlType,b as ingest};
2
+ import{d as a,e as b,f as c}from"./chunk-O46IPJKL.mjs";import"./chunk-OPDY2YEA.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-555PKUBU.mjs";import"./chunk-KQOVPOVU.mjs";import"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-GKXYRUK5.mjs";import"./chunk-4VN252CK.mjs";import"./chunk-5HI6TVMM.mjs";export{a as engineTypeForSqlType,c as ingest,b as parseCsvRows};
@@ -1,17 +1,9 @@
1
1
  /**
2
2
  * Freemium entitlement walls a host can ANTICIPATE, in the server's own words.
3
3
  *
4
- * Added 2026-09-17, from a review of production requests.
5
- *
6
- * A first-time freemium reader behind a corporate proxy bound twenty fields against a cap of
7
- * twelve. The server did everything right: it refused at the routing boundary in 31 ms, charged
8
- * nothing, handed the rate-limit slot back, and composed a sentence naming exactly how many fields
9
- * to drop. The response never came back through the proxy, so what the reader actually read was
10
- * "We couldn't reach the charting service - it may be offline, or blocked on this network", and
11
- * they left inside a second.
12
- *
13
- * The question never needed the wire. The bound column count and the freemium state are both in
14
- * the host's hand before the request is built.
4
+ * The question never needs the wire: the bound column count and the freemium state are both in
5
+ * the host's hand before the request is built, so a host can say so before a refusal has to
6
+ * travel back through a network that may swallow it.
15
7
  *
16
8
  * TWO RULES THIS MODULE EXISTS TO KEEP:
17
9
  *
@@ -40,7 +40,7 @@ export { foldName, readName, matchNameToken, wordEndsWith, gluedPrefixStems, uns
40
40
  export type { NameReading, NameTokenView } from "./nameReader";
41
41
  export { detectDecimalSeparator, decimalSeparatorOf, parseNumberText } from "./numberText";
42
42
  export type { DecimalSeparator } from "./numberText";
43
- export { ingest, engineTypeForSqlType } from "./ingest";
43
+ export { ingest, engineTypeForSqlType, parseCsvRows } from "./ingest";
44
44
  export type { DataSource, IngestOptions, IngestResult, ColumnDescriptor, SqlColumnMeta, EngineDataType, } from "./ingest";
45
45
  export { payloadPreview, PREVIEW_OMITTED_FIELDS } from "./payloadPreview";
46
46
  export type { PayloadPreviewOptions } from "./payloadPreview";
@@ -57,8 +57,8 @@ export { parseGenerateResponse, parseQualifyResponse, parseReviewVerdict } from
57
57
  export type { ParsedGenerateResponse, ParsedQualifyResponse, ParsedQualifyChart, ParsedQualifyRefusal, ParsedReviewVerdict, ParsedNotice, WirePointBinding, WirePointColumns, } from "./wireParse";
58
58
  export { PROGRESS_STAGE_IDS, progressStageOf, FREEMIUM_ATTEMPT_SPENT, CLIENT_SECRET_MISMATCH, FREEMIUM_COLUMN_CAP, OAUTH_TOKEN_EXPIRED, OAUTH_SIGNED_OUT, answerIsRetryable, } from "./messageCodes";
59
59
  export type { ProgressStageId } from "./messageCodes";
60
- export { viewportFields, maxNonMeasureCardinality, credentialFields, resolveFetchVersion, fetchFields, capabilityFields, retryFields, leafCardinalityField, shortlistIsStale, offeredShortlistFor, } from "./wireBuild";
61
- export type { ViewportFields, CredentialFields, FetchRequest, FetchFields, CapabilityFields, RetryFields, } from "./wireBuild";
60
+ export { viewportFields, maxNonMeasureCardinality, credentialFields, resolveFetchVersion, fetchFields, capabilityFields, retryFields, leafCardinalityField, qualifyOrderOf, qualifyOrderField, QUALIFY_ORDER_LABELS, shortlistIsStale, offeredShortlistFor, } from "./wireBuild";
61
+ export type { ViewportFields, CredentialFields, FetchRequest, FetchFields, CapabilityFields, RetryFields, QualifyOrder, } from "./wireBuild";
62
62
  export { schemaIdentity, schemaIdentityKey, schemaTypeFamily } from "./schemaIdentity";
63
63
  export type { SchemaIdentityColumn } from "./schemaIdentity";
64
64
  export { SEV_INFO, SEV_WARNING, SEV_ERROR, SEV_USER_PRESENTED, CLIENT_EVENT_KINDS, isEventLogCode, eventLogLine, TELEMETRY_TIMEOUT_MS, TELEMETRY_TIMEOUT_DEV_MS, DRAW_REASONS, drawLocation, classifyDraw, createDrawLedger, } from "./telemetry";
@@ -1,3 +1,4 @@
1
+ import Papa from "papaparse";
1
2
  import { IndexedText } from "./indexedText";
2
3
  import type { LLMColumnWithValue } from "./models";
3
4
  /** Engine value types. Anything a decoder cannot map confidently becomes "String". */
@@ -111,6 +112,21 @@ export type DataSource = {
111
112
  * be parsed is better described as a label than silently nulled.
112
113
  */
113
114
  export declare function engineTypeForSqlType(sqlType: string): EngineDataType;
115
+ /**
116
+ * Parse CSV text into rows of cells, the header first - the CSV decoder's own parse, exported so a host
117
+ * that reads CSV for any other purpose counts the same rows.
118
+ *
119
+ * A ROW WHOSE VALUE IS BLANK IS A ROW. Papa's `skipEmptyLines` drops any row that parses to one empty
120
+ * cell, and in a one-column CSV that is not only an empty line but also a quoted blank value, `""` - how
121
+ * a one-column CSV writes a blank. A lone text column with a blank in it measured one row short of what a
122
+ * host reading the same table through its own data API counts. So the raw text of each row decides: a line
123
+ * with nothing on it at all (the trailing newline, a blank line between rows) is not a row, as pandas
124
+ * reads it; a line holding `""` is.
125
+ */
126
+ export declare function parseCsvRows(text: string): {
127
+ rows: string[][];
128
+ errors: Papa.ParseError[];
129
+ };
114
130
  /**
115
131
  * Turn a data source into a measured shape plus directly bindable rows.
116
132
  *
@@ -137,6 +137,13 @@ export type LLMClientHints = {
137
137
  * that admits the type.
138
138
  */
139
139
  favorProjection?: string;
140
+ /**
141
+ * The order the "What fits?" list comes back in (older servers ignore it and use their default): "fit" ranks by how
142
+ * well each type suits the data, "variety" by the picker's selection order, which favors newer
143
+ * and less-common types. Read on qualify only. Absent means the server's own default, and a
144
+ * server that predates the field ignores it. Build it with `qualifyOrderField`.
145
+ */
146
+ qualifyOrder?: "fit" | "variety";
140
147
  /**
141
148
  * Does this host let the reader CHOOSE a grain, and send it back as `favorProjection`?
142
149
  *
@@ -293,6 +300,7 @@ export type LLMQualifyResult = {
293
300
  */
294
301
  viaProjectionKey?: string;
295
302
  isPreview?: boolean;
303
+ alsoWorthALook?: boolean;
296
304
  detailNote?: string;
297
305
  }[];
298
306
  refused?: {
@@ -193,6 +193,20 @@ export declare function retryFields(p: {
193
193
  export declare function leafCardinalityField(count: number | null | undefined): {
194
194
  leafCardinality?: number;
195
195
  };
196
+ /** The order of the "what fits" list: by how well each type suits the data, or by the picker's selection order. */
197
+ export type QualifyOrder = "fit" | "variety";
198
+ /** The two orders' reader-facing names, for any host's control. */
199
+ export declare const QUALIFY_ORDER_LABELS: Readonly<Record<QualifyOrder, string>>;
200
+ /** A stored or typed order read back: one of the two the server knows (case and padding ignored), else null. */
201
+ export declare function qualifyOrderOf(raw: unknown): QualifyOrder | null;
202
+ /**
203
+ * THE ORDER A "WHAT FITS" REQUEST ASKS FOR - the client hints' `qualifyOrder`. Sent only when the reader
204
+ * has chosen one: an unmade choice sends no field, so the server's own default applies, and a server
205
+ * that predates the field ignores it. Spread where the host builds its hints.
206
+ */
207
+ export declare function qualifyOrderField(raw: unknown): {
208
+ qualifyOrder?: QualifyOrder;
209
+ };
196
210
  /**
197
211
  * IS A CAPTURED "WHAT FITS" LIST STALE? True when the list was captured for one schema and the
198
212
  * request now describes another - the reader changed the fields since they looked, so the list is not
@@ -111,6 +111,8 @@ export interface ParsedQualifyChart {
111
111
  language: string | undefined;
112
112
  /** True only when the server said so: a newer, less proven type. */
113
113
  isPreview: boolean;
114
+ /** True only when the server said so: one of the "also worth a look" picks below the top fits, drawn for variety. A hint, never a gate. */
115
+ alsoWorthALook: boolean;
114
116
  /** False = a required channel is poorly served; undefined = unassessed, never a demotion. */
115
117
  recommended: boolean | undefined;
116
118
  /** Non-empty when the type qualifies only against an aggregated projection. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/shape-core",
3
- "version": "0.6.74",
3
+ "version": "0.6.76",
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{L as x,S as T}from"./chunk-OPDY2YEA.mjs";import{B as E}from"./chunk-4VN252CK.mjs";import P from"papaparse";function L(e){if(!e)return".";try{return new Intl.NumberFormat(e).formatToParts(1.5).find(t=>t.type==="decimal")?.value===","?",":"."}catch{return"."}}var C="[ \\u00A0\\u202F]",p="(?:[eE][+-]?\\d+)?",O=new RegExp(`^[+-]?(?:\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.\\d+)?${p}$`),k=new RegExp(`^[+-]?(?:\\d{1,3}(?:\\.\\d{3})+|\\d{1,3}(?:${C}\\d{3})+|\\d+)(?:,\\d+)?${p}$`),N=/^[+-]?\d{1,3}[.,]\d{3}$/,_=[/^[+-]?\d{1,3}(?:,\d{3}){2,}$/,new RegExp(`^[+-]?(?:\\d{1,3}(?:,\\d{3})+|\\d+)\\.\\d+${p}$`)],j=[/^[+-]?\d{1,3}(?:\.\d{3}){2,}$/,new RegExp(`^[+-]?(?:\\d{1,3}(?:\\.\\d{3})+|\\d{1,3}(?:${C}\\d{3})+|\\d+),\\d+${p}$`)];function R(e,i){let t=0,n=0;for(let c of e){if(typeof c!="string")continue;let o=c.trim();o===""||N.test(o)||(_.some(s=>s.test(o))?t++:j.some(s=>s.test(o))&&n++)}return n>0&&t===0?",":t>0?".":L(i)}function y(e,i){let t=String(e??"").trim();return t===""?null:i===","?k.test(t)?parseFloat(t.replace(/[.   ]/g,"").replace(",",".")):null:O.test(t)?parseFloat(t.replace(/,/g,"")):null}function M(e,i){return y(e,i)!==null}var A=500,I=/^[+-]?\d{1,15}$/,q=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,F=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function V(e,i="."){let t=0,n=0,c=0,o=0;for(let s of e){if(s==null)continue;if(typeof s=="number"){o++,n++,Number.isInteger(s)&&t++;continue}if(s instanceof Date){o++,c++;continue}if(typeof s=="boolean"){o++;continue}let l=String(s).trim();if(l!==""){if(o++,I.test(l)){t++,n++;continue}if(M(l,i)){n++;continue}if((q.test(l)||F.test(l))&&!isNaN(Date.parse(l))){c++;continue}}}return o===0?"String":c===o?"DateTime":t===o?"Integer":n===o?"Decimal":"String"}function v(e,i,t="."){if(e==null)return null;if(typeof e=="number")return i==="String"?String(e):e;if(e instanceof Date)return i==="DateTime"?e:e.toISOString();if(typeof e=="boolean")return String(e);let n=String(e).trim();if(n==="")return null;switch(i){case"Integer":return I.test(n)?parseInt(n,10):null;case"Decimal":return y(n,t);case"DateTime":return E(n);default:return n}}function B(e){let i=(e||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(i)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(i)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(i)?"DateTime":(/^(bit|bool|boolean)$/.test(i),"String")}function f(e,i,t){if(e.length===0)throw new Error("ingest: no columns were resolved from the source. Supply column descriptors, or use a source shape that carries them (grid/table/objects/sql).");let n=e.length,c=e.map((r,a)=>i.slice(0,A).map(m=>m?.[a])),o=c.map(r=>R(r,t.locale)),s=e.map((r,a)=>r.dataType??V(c[a],o[a])),l=new Set((t.measures??[]).map(r=>r.toLowerCase())),w=new Set((t.dimensions??[]).map(r=>r.toLowerCase())),$=new Set((t.nonAdditive??[]).map(r=>r.toLowerCase())),b=e.map((r,a)=>{let m=r.name.toLowerCase(),d=r.isMeasure??((s[a]==="Integer"||s[a]==="Decimal")&&!x(r.name));l.has(m)&&(d=!0),w.has(m)&&(d=!1);let D={name:r.name,dataType:s[a],isMeasure:d};return d&&$.has(m)&&(D.discourageAggregationAcrossGroups=!0),D}),u=new T;u.dedupRows=t.dedup!==!1,u.setColumns(b),u.declareDimensions(b.filter((r,a)=>w.has(e[a].name.toLowerCase())));for(let r=0;r<i.length;r++){let a=i[r];u.addRow(Array.from({length:n},(m,d)=>v(a?.[d],s[d],o[d])),r)}let S=u.getColumnsWithStats(t.privacyLevel??"20",t.locale??"en"),g=new Map(S.map(r=>[r.name,r]));e.forEach(r=>{let a=g.get(r.name);a&&(r.format&&(a.modelFormat=r.format),r.description&&(a.modelDesc=r.description))});for(let[r,a]of Object.entries(t.formats??{})){let m=g.get(r);m&&(m.modelFormat=a)}for(let[r,a]of Object.entries(t.descriptions??{})){let m=g.get(r);m&&(m.modelDesc=a)}for(let r of t.groupBy??[]){let a=g.get(r);a&&(a.isGrouping=!0)}return{columns:S,rows:u.toObjectArray(),totalRows:u.getRowCount(),index:u}}function h(e,i){return e.map(t=>Array.isArray(t)?t:i.map(n=>t[n]))}function U(e,i){let t=[],n=new Set,c=Math.min(e.length,Math.max(1,i));for(let o=0;o<c;o++){let s=e[o];if(!(!s||typeof s!="object"))for(let l of Object.keys(s))n.has(l)||(n.add(l),t.push(l))}return t}function Y(e,i={}){switch(e.kind){case"csv":{let t=P.parse(e.text,{skipEmptyLines:!0});if(t.errors?.length&&t.data.length===0)throw new Error(`ingest: CSV parse failed - ${t.errors[0].message}`);let n=t.data;if(n.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let c=n[0].map(o=>(o??"").trim());return f(c.map(o=>({name:o})),n.slice(1),i)}case"grid":{if(!e.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return f(e.header.map(t=>({name:(t??"").trim()})),e.rows??[],i)}case"table":{if(!e.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let t=e.columns.map(n=>n.name);return f(e.columns,h(e.rows??[],t),i)}case"objects":{let t=e.rows??[],n=e.columns?.length?e.columns:U(t,i.columnScanLimit??A).map(c=>({name:c}));if(!n.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return f(n,h(t,n.map(c=>c.name)),i)}case"sql":{if(!e.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let t=e.schema.map(n=>{let c=B(n.dataType);return{name:n.name,dataType:c,isMeasure:n.isMeasure,format:n.format,description:n.description}});return f(t,h(e.rows??[],t.map(n=>n.name)),i)}default:{let t=e;throw new Error(`ingest: unknown source kind '${t?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{L as a,R as b,y as c,B as d,Y as e};