@duckcodeailabs/dql-cli 1.12.11 → 1.13.0
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.
- package/dist/apps-api.d.ts +151 -3
- package/dist/apps-api.d.ts.map +1 -1
- package/dist/apps-api.js +675 -97
- package/dist/apps-api.js.map +1 -1
- package/dist/assets/dql-notebook/assets/AgentAnswerCard-Cp0eh6zU.js +5 -0
- package/dist/assets/dql-notebook/assets/{AgentLogPage-hzHqpD3-.js → AgentLogPage-CBGEoGmU.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildDialog-BQRWoxp9.js → AiBuildDialog-CwAD3tXE.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildResult-D9t_4sQl.js → AiBuildResult-CyqTuQe5.js} +1 -1
- package/dist/assets/dql-notebook/assets/AiSidePanel-DjB8PWHG.js +6 -0
- package/dist/assets/dql-notebook/assets/AnalyticsHome-B7BkvA-R.js +6 -0
- package/dist/assets/dql-notebook/assets/AppsView-CUrqtEGC.js +4583 -0
- package/dist/assets/dql-notebook/assets/BlockStudio-Bl0aGQJR.js +60 -0
- package/dist/assets/dql-notebook/assets/{BusinessArtifactView-CnTbFVGT.js → BusinessArtifactView-C4SZVNW-.js} +1 -1
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-B0uxitnx.js +22 -0
- package/dist/assets/dql-notebook/assets/GitPage-BfVD4tVq.js +7 -0
- package/dist/assets/dql-notebook/assets/GlobalAiRail-DUwdy3fB.js +1 -0
- package/dist/assets/dql-notebook/assets/GovernedContextPage-D9f26ZFb.js +7 -0
- package/dist/assets/dql-notebook/assets/{HelpDocsPage-CL0vbSER.js → HelpDocsPage-BDPNVot1.js} +1 -1
- package/dist/assets/dql-notebook/assets/{HomePage-DzAucwBW.js → HomePage-DiOnRhEG.js} +1 -1
- package/dist/assets/dql-notebook/assets/LineageDAG-BiUFX2KL.js +1 -0
- package/dist/assets/dql-notebook/assets/{LineageDetailView-DdVH-nz6.js → LineageDetailView-CfbSvlPJ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDrawer-BvrVZNKY.js → LineageDrawer-CgTScaGB.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineagePathBreadcrumb-CSut-zvm.js → LineagePathBreadcrumb-D7ZA7k68.js} +3 -3
- package/dist/assets/dql-notebook/assets/{MiniLineageGraph-zg_1wW3M.js → MiniLineageGraph-GkD4y17x.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewBlockModal-9cDletl-.js → NewBlockModal-B9TfRjt7.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewNotebookModal-V6de8L4d.js → NewNotebookModal-BbO9NKUl.js} +2 -2
- package/dist/assets/dql-notebook/assets/NotebookEditor-CuMpvXR9.js +200 -0
- package/dist/assets/dql-notebook/assets/ReadinessPage-BROJ9YBM.js +1 -0
- package/dist/assets/dql-notebook/assets/{SetupOnboarding-Bg-MjbC9.js → SetupOnboarding-BCcZlpuQ.js} +2 -2
- package/dist/assets/dql-notebook/assets/{TrustBadge-DGuHB8kP.js → TrustBadge-vQQh8d0D.js} +1 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-Dj4AXAhT.js +83 -0
- package/dist/assets/dql-notebook/assets/{answer-to-notebook-BDzY4MuQ.js → answer-to-notebook-DuqCcDDl.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-left-IjlnAihE.js → arrow-left-CMe1kkOL.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-right-BI4cXgOY.js → arrow-right-DvB_DONr.js} +1 -1
- package/dist/assets/dql-notebook/assets/{book-open-text-i6xhxu_I.js → book-open-text-CJ3NAvrs.js} +1 -1
- package/dist/assets/dql-notebook/assets/{bot-C6DE7Q6m.js → bot-CV8DYRrt.js} +1 -1
- package/dist/assets/dql-notebook/assets/{chevron-up-DSEILnDs.js → chevron-up-HxU1l85K.js} +1 -1
- package/dist/assets/dql-notebook/assets/{circle-x-BoAorVSm.js → circle-x-BCgtha1W.js} +1 -1
- package/dist/assets/dql-notebook/assets/{dagre.esm-CycymVj6.js → dagre.esm-GKp7qoUL.js} +1 -1
- package/dist/assets/dql-notebook/assets/{external-link-ZwE5iHsX.js → external-link-C-PXokWV.js} +1 -1
- package/dist/assets/dql-notebook/assets/{grip-vertical-Dnp2st8l.js → grip-vertical-B4EHbGXW.js} +1 -1
- package/dist/assets/dql-notebook/assets/index-1mIC_XX4.js +634 -0
- package/dist/assets/dql-notebook/assets/{link-2-CTKe6Snr.js → link-2-BLx-goet.js} +1 -1
- package/dist/assets/dql-notebook/assets/{list-tree-Ced8e_S1.js → list-tree-BRFpEmvV.js} +1 -1
- package/dist/assets/dql-notebook/assets/{maximize-2-Cojc6867.js → maximize-2-CCd5uRIZ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{minimize-2-CBIAE0XH.js → minimize-2-CDwSCGlO.js} +1 -1
- package/dist/assets/dql-notebook/assets/{panel-right-open-po3bWSeL.js → panel-right-open-CunA1xO7.js} +1 -1
- package/dist/assets/dql-notebook/assets/{pencil-Cb45c6WU.js → pencil-D_I14Wyk.js} +1 -1
- package/dist/assets/dql-notebook/assets/{rotate-ccw-B9v1LTJ0.js → rotate-ccw-DOrfTZk8.js} +1 -1
- package/dist/assets/dql-notebook/assets/{semantic-fields-B6ii0an0.js → semantic-fields-AfQvjt5R.js} +1 -1
- package/dist/assets/dql-notebook/assets/{star-CO4tfaDq.js → star-DDhv4e8M.js} +1 -1
- package/dist/assets/dql-notebook/assets/{triangle-alert-BSdIu2El.js → triangle-alert-2ZXx8wAu.js} +1 -1
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-3rzkZrqc.js +18 -0
- package/dist/assets/dql-notebook/assets/{user-round-BfrV8U-W.js → user-round-BA074kiQ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wand-sparkles-BgTxZNBc.js → wand-sparkles-CEYHLt9b.js} +1 -1
- package/dist/assets/dql-notebook/assets/{workflow--2ycp0yy.js → workflow-CZtyrcR-.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wrench-LMCrpa9_.js → wrench-Ong23-wu.js} +1 -1
- package/dist/assets/dql-notebook/assets/{x-CeNgQwGm.js → x-CSo1M3tu.js} +1 -1
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/llm/providers/dql-agent-provider.d.ts +4 -3
- package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
- package/dist/llm/providers/dql-agent-provider.js +13 -10
- package/dist/llm/providers/dql-agent-provider.js.map +1 -1
- package/dist/local-operation-coordinator.d.ts +59 -0
- package/dist/local-operation-coordinator.d.ts.map +1 -0
- package/dist/local-operation-coordinator.js +256 -0
- package/dist/local-operation-coordinator.js.map +1 -0
- package/dist/local-runtime.d.ts +49 -1
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +1590 -323
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +12 -11
- package/dist/project-refresh-coordinator.d.ts +19 -0
- package/dist/project-refresh-coordinator.d.ts.map +1 -0
- package/dist/project-refresh-coordinator.js +134 -0
- package/dist/project-refresh-coordinator.js.map +1 -0
- package/dist/project-refresh-worker.d.ts +13 -0
- package/dist/project-refresh-worker.d.ts.map +1 -0
- package/dist/project-refresh-worker.js +58 -0
- package/dist/project-refresh-worker.js.map +1 -0
- package/package.json +13 -11
- package/dist/assets/dql-notebook/assets/AgentAnswerCard-CpL2kDCV.js +0 -5
- package/dist/assets/dql-notebook/assets/AiSidePanel-BCQB9rVF.js +0 -6
- package/dist/assets/dql-notebook/assets/AnalyticsHome-Ba4Ve_Gd.js +0 -6
- package/dist/assets/dql-notebook/assets/AppsView-CdAT9BOq.js +0 -4466
- package/dist/assets/dql-notebook/assets/BlockStudio-Brg4fwn5.js +0 -60
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-CQe2FUZq.js +0 -22
- package/dist/assets/dql-notebook/assets/GitPage-DHyDBChc.js +0 -7
- package/dist/assets/dql-notebook/assets/GlobalAiRail-Cys4n_rq.js +0 -1
- package/dist/assets/dql-notebook/assets/GovernedContextPage-DyKoDSZ2.js +0 -7
- package/dist/assets/dql-notebook/assets/LineageDAG-QHqd_AM5.js +0 -1
- package/dist/assets/dql-notebook/assets/NotebookEditor-EZ0pfWVs.js +0 -200
- package/dist/assets/dql-notebook/assets/ReadinessPage-BaGvjyfd.js +0 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-BlWAVEwO.js +0 -83
- package/dist/assets/dql-notebook/assets/index-BTuliKhK.js +0 -634
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-CkVFrrjk.js +0 -18
package/dist/assets/dql-notebook/assets/{semantic-fields-B6ii0an0.js → semantic-fields-AfQvjt5R.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as x,j as l,t as k,R as y}from"./index-
|
|
1
|
+
import{r as x,j as l,t as k,R as y}from"./index-1mIC_XX4.js";import{c as S,i as j}from"./usePersistedAgentThreadId-3rzkZrqc.js";function w(o,t){const n=o.split(`
|
|
2
2
|
`),s=[];let e=0;for(;e<n.length;){const a=n[e],d=a.match(/^(#{1,6})\s+(.+)$/);if(d){const i=d[1].length,h=d[2],c=[28,22,18,16,14,13][i-1];s.push(l.jsx("div",{style:{fontSize:c,fontWeight:i<=2?700:600,color:t.textPrimary,fontFamily:t.font,lineHeight:1.3,marginBottom:i===1?12:8,marginTop:e>0?i===1?16:10:0,borderBottom:i===1?`1px solid ${t.cellBorder}`:void 0,paddingBottom:i===1?8:void 0},children:p(h,t)},e)),e++;continue}if(/^[-*_]{3,}$/.test(a.trim())){s.push(l.jsx("hr",{style:{border:"none",borderTop:`1px solid ${t.cellBorder}`,margin:"12px 0"}},e)),e++;continue}if(a.startsWith("> ")){s.push(l.jsx("div",{style:{borderLeft:`3px solid ${t.textMuted}`,paddingLeft:12,marginLeft:4,color:t.textSecondary,fontStyle:"italic",fontFamily:t.fontSerif,fontSize:14},children:p(a.slice(2),t)},e)),e++;continue}if(a.startsWith("```")){const i=[];for(e++;e<n.length&&!n[e].startsWith("```");)i.push(n[e]),e++;s.push(l.jsx("pre",{style:{background:"var(--color-bg-surface)",border:"1px solid var(--color-border-subtle)",borderRadius:6,padding:"10px 12px",fontSize:12,fontFamily:"var(--font-mono)",color:"var(--color-text-primary)",overflow:"auto",margin:"8px 0",lineHeight:1.6},children:i.join(`
|
|
3
3
|
`)},e)),e++;continue}if(/^[-*+]\s/.test(a)){const i=e,h=[];for(;e<n.length&&/^[-*+]\s/.test(n[e]);)h.push(n[e].replace(/^[-*+]\s/,"")),e++;s.push(l.jsx("ul",{style:{paddingLeft:20,marginBottom:8,color:t.textSecondary},children:h.map((m,c)=>l.jsx("li",{style:{fontSize:14,fontFamily:t.font,lineHeight:1.6,marginBottom:2},children:p(m,t)},c))},`ul-${i}`));continue}if(/^\d+\.\s/.test(a)){const i=e,h=[];for(;e<n.length&&/^\d+\.\s/.test(n[e]);)h.push(n[e].replace(/^\d+\.\s/,"")),e++;s.push(l.jsx("ol",{style:{paddingLeft:20,marginBottom:8,color:t.textSecondary},children:h.map((m,c)=>l.jsx("li",{style:{fontSize:14,fontFamily:t.font,lineHeight:1.6,marginBottom:2},children:p(m,t)},c))},`ol-${i}`));continue}if(!a.trim()){s.push(l.jsx("div",{style:{height:8}},e)),e++;continue}s.push(l.jsx("p",{style:{fontSize:14,lineHeight:1.7,fontFamily:t.fontSerif,color:t.textSecondary,marginBottom:6},children:p(a,t)},e)),e++}return s}function p(o,t){const n=[];let s=o,e=0;for(;s.length>0;){const a=s.match(/\*{3}(.+?)\*{3}/),d=s.match(/\*{2}(.+?)\*{2}/),i=s.match(/\*(.+?)\*/),h=s.match(/`(.+?)`/),m=s.match(/\[(.+?)\]\((.+?)\)/),c=[a?{match:a,type:"boldItalic"}:null,d?{match:d,type:"bold"}:null,i?{match:i,type:"italic"}:null,h?{match:h,type:"code"}:null,m?{match:m,type:"link"}:null].filter(Boolean);if(c.length===0){n.push(l.jsx(y.Fragment,{children:s},e++));break}const r=c.reduce((u,g)=>(u.match.index??0)<(g.match.index??0)?u:g),f=r.match.index??0;switch(f>0&&n.push(l.jsx(y.Fragment,{children:s.slice(0,f)},e++)),r.type){case"boldItalic":n.push(l.jsx("strong",{style:{fontStyle:"italic"},children:r.match[1]},e++));break;case"bold":n.push(l.jsx("strong",{children:r.match[1]},e++));break;case"italic":n.push(l.jsx("em",{children:r.match[1]},e++));break;case"code":n.push(l.jsx("code",{style:{background:"var(--color-bg-surface)",border:"1px solid var(--color-border-subtle)",borderRadius:4,padding:"1px 5px",fontSize:"0.9em",fontFamily:"var(--font-mono)",color:"var(--color-accent-blue)"},children:r.match[1]},e++));break;case"link":n.push(l.jsx("a",{href:r.match[2],target:"_blank",rel:"noopener noreferrer",style:{color:t.accent,textDecoration:"underline"},children:r.match[1]},e++));break}s=s.slice(f+r.match[0].length)}return l.jsx(l.Fragment,{children:n})}function z({value:o,onChange:t,onRun:n,themeMode:s}){const e=k[s],[a,d]=x.useState(!1),i=x.useRef(null);x.useEffect(()=>{if(a&&i.current){i.current.focus();const r=i.current;r.style.height="auto",r.style.height=`${Math.max(r.scrollHeight,80)}px`}},[a]);const h=()=>{d(!1)},m=r=>{if(r.key==="Escape"&&d(!1),r.key==="Enter"&&r.shiftKey&&(r.preventDefault(),d(!1),n==null||n()),r.key==="Tab"){r.preventDefault();const f=r.currentTarget,u=f.selectionStart,g=f.selectionEnd,b=o.slice(0,u)+" "+o.slice(g);t(b),requestAnimationFrame(()=>{f.selectionStart=f.selectionEnd=u+2})}},c=r=>{t(r.target.value);const f=r.target;f.style.height="auto",f.style.height=`${Math.max(f.scrollHeight,80)}px`};return a?l.jsx("textarea",{ref:i,value:o,onChange:c,onBlur:h,onKeyDown:m,placeholder:"Write markdown here...",spellCheck:!1,style:{display:"block",width:"100%",minHeight:80,padding:"12px 16px",background:e.editorBg,color:e.textPrimary,border:"none",outline:"none",resize:"none",fontFamily:e.fontMono,fontSize:13,lineHeight:"20px",borderRadius:0,caretColor:e.accent}}):o.trim()?l.jsx("div",{onDoubleClick:()=>d(!0),title:"Double-click to edit",style:{padding:"12px 16px",cursor:"text",minHeight:48},children:w(o,e)}):l.jsx("div",{onDoubleClick:()=>d(!0),style:{padding:"12px 16px",color:e.textMuted,fontFamily:e.font,fontSize:13,fontStyle:"italic",cursor:"text",minHeight:48,display:"flex",alignItems:"center"},children:"Double-click to add markdown..."})}function F(o){var h,m;if(!o)return{metrics:[],dimensions:[],columns:[],fields:[],hasSemanticBinding:!1};const t=new Set(((h=o.semanticRefs)==null?void 0:h.metrics)??[]),n=new Set(((m=o.semanticRefs)==null?void 0:m.dimensions)??[]),s=t.size>0||n.size>0,e=[],a=[],d=[],i=[];for(const c of o.columns)t.has(c)?(e.push(c),i.push({name:c,kind:"metric"})):n.has(c)&&(a.push(c),i.push({name:c,kind:"dimension"}));for(const c of o.columns)t.has(c)||n.has(c)||(d.push(c),i.push({name:c,kind:"column",chartRole:S(j(c,o.rows))}));return{metrics:e,dimensions:a,columns:d,fields:i,hasSemanticBinding:s}}function H(o){return o==="metric"?"#":o==="dimension"?"∴":"A"}function M(o,t){return o==="metric"?t:o==="dimension"?"#e3b341":"#56d364"}function C(o){return o==="metric"?"metric":o==="dimension"?"dimension":"column"}export{z as M,M as a,C as b,F as c,H as f,w as r};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{c as te,r as W,j as t,t as R,a_ as je,L as Se,f as we,l as Me,S as le,d as $e,e as Ae}from"./index-1mIC_XX4.js";import{W as ke}from"./wrench-Ong23-wu.js";/**
|
|
2
|
+
* @license lucide-react v0.563.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const ze=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],_e=te("code-xml",ze);/**
|
|
7
|
+
* @license lucide-react v0.563.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Te=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]],Fe=te("file-search",Te);/**
|
|
12
|
+
* @license lucide-react v0.563.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const Ne=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],kt=te("send",Ne),Ie=/date|time|_at$|_on$|timestamp/i;function We(e){return typeof e=="number"||typeof e=="string"&&e!==""&&!isNaN(Number(e))}function Be(e,s){if(Ie.test(e))return"date";const n=s.slice(0,40).map(l=>l[e]).filter(l=>l!=null);return n.length===0?"string":n.every(l=>typeof l=="boolean")?"bool":n.every(l=>typeof l=="object")?"json":n.filter(We).length/n.length>.8?"numeric":"string"}function zt(e){return e==="numeric"?"measure":e==="date"?"temporal":"dimension"}const re=/(?:^|_)(?:revenue|sales|spend|amount|price|cost|profit|margin|income|expense|balance|budget|bookings|arr|mrr|gmv|fee|fees|charge|charges|tax|value)(?:_|$)/i,Le=/(?:^|_)(?:percent|percentage|pct|ratio|share|conversion|churn|retention|utilization)(?:_|$)/i,Ee=/(?:^|_)(?:count|orders?|customers?|accounts?|users?|products?|items?|units?|quantity|rank|position|days?|months?|years?|distinct)(?:_|$)/i,ie=/(?:^|_)(?:average|avg|mean)(?:_|$)/i,Pe=/(?:^|_)(?:year|yr)$/i,Re=/(?:^|_)(?:month|monthly|month_num|month_number|month_of_year)$/i,De=/(?:^|_)(?:date|day|month|quarter|year|time|timestamp|daily|weekly|monthly|quarterly|yearly|hourly)(?:_|$)|_(?:at|on)$/i,pe=/^(\d{4})-(\d{2})$/,Z=/^(\d{4})-(\d{2})-(\d{2})$/,G=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?$/,me=/^(\d{1,2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?Z?$/;function ne(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()!==""&&Number.isFinite(Number(e)))return Number(e)}function He(e){if(e==="currency"||e==="percent"||e==="number")return e;if(e==="duration")return"number"}function Oe(e,s=[],n){const o=He(n);if(o)return o;if(Re.test(e))return"month";if(Pe.test(e))return"year";if(De.test(e))return"date";if(ie.test(e)&&re.test(e))return"currency";if(Le.test(e))return"percent";if(ie.test(e))return"number";if(Ee.test(e))return"integer";if(re.test(e))return"currency";const l=s.filter(i=>i!=null&&i!=="");return l.length===0?"text":l.every(i=>typeof i=="boolean")?"boolean":l.every(i=>ne(i)!==void 0)?"number":l.every(i=>typeof i=="string"&&pe.test(i))?"month":l.every(i=>typeof i=="string"&&(Z.test(i)||G.test(i)||me.test(i)))?"date":l.every(i=>typeof i=="object")?"json":"text"}function Ue(e,s=!1){return e?{notation:"compact",maximumFractionDigits:1}:s?{maximumFractionDigits:0}:{maximumFractionDigits:2}}function oe(e,s,n=[],o={}){if(s==null)return"";const l=Oe(e,n,o.format),i=ne(s);if(l==="year"){const r=typeof s=="string"&&(Z.test(s)||G.test(s))?Number(s.slice(0,4)):i;if(r!==void 0&&Number.isInteger(r))return new Intl.NumberFormat("en-US",{useGrouping:!1,maximumFractionDigits:0}).format(r)}if(l==="month"){const r=Ye(s);if(r)return r}if(l==="date"&&typeof s=="string"){const r=Ze(s);if(r)return r}if(i!==void 0){if(l==="currency")return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",...o.compact?{notation:"compact",maximumFractionDigits:1}:{minimumFractionDigits:2,maximumFractionDigits:2}}).format(i);if(l==="percent"){const r=Math.abs(i)<=1?i:i/100;return new Intl.NumberFormat("en-US",{style:"percent",maximumFractionDigits:2}).format(r)}return new Intl.NumberFormat("en-US",Ue(!!o.compact,l==="integer")).format(i)}return l==="boolean"?s?"Yes":"No":l==="json"||typeof s=="object"?JSON.stringify(s):String(s)}function Ve(e,s,n){return oe(e,s,[s],{compact:!0,format:n})}function Ye(e){const s=ne(e);if(s!==void 0&&Number.isInteger(s)&&s>=1&&s<=12)return new Intl.DateTimeFormat("en-US",{month:"short",timeZone:"UTC"}).format(new Date(Date.UTC(2e3,s-1,1)));if(typeof e!="string")return;const n=pe.exec(e),o=Z.exec(e)??(G.test(e)?Z.exec(e.slice(0,10)):null),l=n??o;if(!l)return;const i=Number(l[1]),r=Number(l[2]);if(!(r<1||r>12))return new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",timeZone:"UTC"}).format(new Date(Date.UTC(i,r-1,1)))}function Ze(e){const s=me.exec(e);if(s){const r=Number(s[1]),z=Number(s[2]),j=Number(s[3]??0);return r>23||z>59||j>59?void 0:new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",timeZone:"UTC"}).format(new Date(Date.UTC(2e3,0,1,r,z,j)))}const n=Z.exec(e);if(n)return new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",timeZone:"UTC"}).format(new Date(Date.UTC(Number(n[1]),Number(n[2])-1,Number(n[3]))));if(!G.test(e))return;const o=/(?:Z|[+-]\d{2}:?\d{2})$/.test(e),l=new Date(o?e:`${e}Z`);if(Number.isNaN(l.getTime()))return;const i=l.getUTCHours()===0&&l.getUTCMinutes()===0&&l.getUTCSeconds()===0;return new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",...i?{}:{hour:"numeric",minute:"2-digit"},timeZone:"UTC"}).format(l)}const qe=[25,50,100,500];function Q(e){return typeof e=="number"?!0:typeof e=="string"?!isNaN(Number(e))&&e.trim()!=="":!1}function Ge(e){switch(e){case"numeric":return{icon:"#",color:"#79c0ff"};case"date":return{icon:"D",color:"#e3b341"};case"bool":return{icon:"B",color:"#a371f7"};case"json":return{icon:"{}",color:"#ff7b72"};case"string":default:return{icon:"A",color:"#56d364"}}}function Xe(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Ke(e,s){return e==null?1:s==null?-1:Q(e)&&Q(s)?Number(e)-Number(s):String(e).localeCompare(String(s))}function Je(e,s){const n=r=>r.includes(",")||r.includes('"')||r.includes(`
|
|
17
|
+
`)?`"${r.replace(/"/g,'""')}"`:r,o=e.columns.map(n).join(","),l=e.rows.map(r=>e.columns.map(z=>n(Xe(r[z]))).join(",")),i=[o,...l].join(`
|
|
18
|
+
`);ye(i,"export.csv","text/csv")}function Qe(e,s){const n=JSON.stringify(e.rows,null,2);ye(n,"export.json","application/json")}function ye(e,s,n){const o=new Blob([e],{type:n}),l=URL.createObjectURL(o),i=document.createElement("a");i.href=l,i.download=s,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(l)}function Ce({dir:e,color:s}){return e?t.jsx("svg",{width:"8",height:"10",viewBox:"0 0 8 10",fill:s,style:{marginLeft:3,flexShrink:0},children:e==="asc"?t.jsx("path",{d:"M4 0L7 4H1L4 0Z"}):t.jsx("path",{d:"M4 10L1 6H7L4 10Z"})}):t.jsxs("svg",{width:"8",height:"10",viewBox:"0 0 8 10",fill:s,opacity:.3,style:{marginLeft:3,flexShrink:0},children:[t.jsx("path",{d:"M4 0L7 3.5H1L4 0Z"}),t.jsx("path",{d:"M4 10L1 6.5H7L4 10Z"})]})}function C({result:e,themeMode:s,maxHeight:n=440}){const o=R[s],[l,i]=W.useState(null),[r,z]=W.useState(null),[j,b]=W.useState(null),[u,m]=W.useState(""),[p,S]=W.useState(50),[v,x]=W.useState(0),w=W.useCallback(a=>{r===a?j==="asc"?b("desc"):j==="desc"?(z(null),b(null)):b("asc"):(z(a),b("asc")),x(0)},[r,j]),y=W.useMemo(()=>{if(!u.trim())return e.rows;const a=u.toLowerCase();return e.rows.filter(h=>e.columns.some(g=>{const _=h[g];return _==null?!1:String(_).toLowerCase().includes(a)}))},[e.rows,e.columns,u]),d=W.useMemo(()=>{if(!r||!j)return y;const a=[...y];return a.sort((h,g)=>{const _=Ke(h[r],g[r]);return j==="desc"?-_:_}),a},[y,r,j]),c=W.useMemo(()=>{const a=new Map;for(const h of e.columns)a.set(h,Be(h,e.rows));return a},[e.columns,e.rows]),T=W.useMemo(()=>new Map(e.columns.map(a=>[a,e.rows.map(h=>h[a])])),[e.columns,e.rows]),[F,I]=W.useState(!1),A=Math.max(1,Math.ceil(d.length/p)),$=Math.min(v,A-1),k=d.slice($*p,($+1)*p);return e.columns.length===0?t.jsx("div",{style:{padding:"12px 16px",color:o.textMuted,fontSize:12,fontFamily:o.font,fontStyle:"italic"},children:"Query executed successfully. No columns to display."}):t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderBottom:`1px solid ${o.tableBorder}`,background:`${o.tableHeaderBg}60`,flexWrap:"wrap"},children:[t.jsxs("div",{style:{position:"relative",flex:"0 1 200px",minWidth:120},children:[t.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:o.textMuted,style:{position:"absolute",left:6,top:6},children:t.jsx("path",{d:"M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"})}),t.jsx("input",{value:u,onChange:a=>{m(a.target.value),x(0)},placeholder:"Filter rows...",style:{width:"100%",background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:11,fontFamily:o.font,padding:"3px 8px 3px 22px",outline:"none"}}),u&&t.jsx("button",{onClick:()=>m(""),style:{position:"absolute",right:4,top:3,background:"none",border:"none",color:o.textMuted,cursor:"pointer",fontSize:12,padding:"0 2px"},children:"×"})]}),t.jsxs("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:[u?`${d.length} of ${e.rows.length}`:`${e.rows.length}`," ",e.rows.length===1?"row":"rows"]}),t.jsx("div",{style:{flex:1}}),t.jsx(ae,{label:"CSV",onClick:()=>Je(e),t:o}),t.jsx(ae,{label:"JSON",onClick:()=>Qe(e),t:o}),t.jsx("select",{value:p,onChange:a=>{S(Number(a.target.value)),x(0)},style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:3,color:o.textSecondary,fontSize:10,fontFamily:o.font,padding:"2px 4px",outline:"none"},children:qe.map(a=>t.jsxs("option",{value:a,children:[a," / page"]},a))}),A>1&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[t.jsx(Y,{disabled:$===0,onClick:()=>x(0),t:o,children:"«"}),t.jsx(Y,{disabled:$===0,onClick:()=>x($-1),t:o,children:"‹"}),t.jsxs("span",{style:{fontSize:10,color:o.textSecondary,fontFamily:o.font,padding:"0 4px"},children:[$+1,"/",A]}),t.jsx(Y,{disabled:$>=A-1,onClick:()=>x($+1),t:o,children:"›"}),t.jsx(Y,{disabled:$>=A-1,onClick:()=>x(A-1),t:o,children:"»"})]})]}),t.jsx("div",{style:{maxHeight:n,overflow:"auto",position:"relative"},onScroll:a=>I(a.target.scrollTop>0),children:t.jsxs("table",{style:{width:"100%",borderCollapse:"separate",borderSpacing:0,tableLayout:"auto",fontSize:12.5,fontFamily:o.fontMono},children:[t.jsx("thead",{children:t.jsx("tr",{children:e.columns.map(a=>{const h=c.get(a)??"string",g=h==="numeric";return t.jsx("th",{onClick:()=>w(a),style:{background:o.tableHeaderBg,color:o.textSecondary,fontWeight:600,fontSize:11,textAlign:g?"right":"left",padding:"8px 14px",borderBottom:`1px solid ${o.tableBorder}`,minWidth:80,maxWidth:320,whiteSpace:"nowrap",position:"sticky",top:0,zIndex:1,fontFamily:o.font,letterSpacing:"0.03em",overflow:"hidden",textOverflow:"ellipsis",cursor:"pointer",userSelect:"none",boxShadow:F?"0 2px 4px -2px rgba(0,0,0,0.18)":"none",transition:"background 0.1s, box-shadow 0.18s"},children:t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,justifyContent:g?"flex-end":"flex-start"},children:[(()=>{const _=Ge(h);return t.jsx("span",{title:h,style:{fontSize:9,fontFamily:o.fontMono,fontWeight:700,color:_.color,background:`${_.color}15`,border:`1px solid ${_.color}40`,borderRadius:3,padding:"0 4px",minWidth:14,textAlign:"center",lineHeight:"14px",flexShrink:0},children:_.icon})})(),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:a}),t.jsx(Ce,{dir:r===a?j:null,color:r===a?o.accent:o.textMuted})]})},a)})})}),t.jsx("tbody",{children:k.map((a,h)=>{const g=l===h,L=h%2===1?o.tableHeaderBg:"transparent";return t.jsx("tr",{onMouseEnter:()=>i(h),onMouseLeave:()=>i(null),style:{transition:"background 0.1s"},children:e.columns.map(B=>{const f=a[B],M=f==null,N=Q(f);return t.jsx("td",{style:{padding:"7px 14px",borderBottom:`1px solid ${o.tableBorder}`,background:g?o.tableRowHover:L,color:M?o.textMuted:o.textPrimary,fontStyle:M?"italic":"normal",fontVariantNumeric:N?"tabular-nums":"normal",textAlign:N?"right":"left",whiteSpace:"nowrap",maxWidth:320,overflow:"hidden",textOverflow:"ellipsis",transition:"background 0.1s"},children:M?"—":oe(B,f,T.get(B)??[])},B)})},h)})})]})}),t.jsxs("div",{style:{padding:"5px 10px",color:o.textMuted,fontSize:10,fontFamily:o.font,borderTop:`1px solid ${o.tableBorder}`,background:`${o.tableHeaderBg}60`,display:"flex",alignItems:"center",gap:4},children:[A>1&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[t.jsx(Y,{disabled:$===0,onClick:()=>x($-1),t:o,children:"‹"}),et(A,$).map((a,h)=>a==="…"?t.jsx("span",{style:{color:o.textMuted,fontSize:10,padding:"0 2px"},children:"…"},`gap-${h}`):t.jsx("button",{onClick:()=>x(a-1),style:{background:a-1===$?`${o.accent}20`:"transparent",border:"none",color:a-1===$?o.accent:o.textSecondary,fontSize:10,fontFamily:o.font,fontWeight:a-1===$?700:400,padding:"1px 6px",borderRadius:3,cursor:"pointer",minWidth:20},children:a},a)),t.jsx(Y,{disabled:$>=A-1,onClick:()=>x($+1),t:o,children:"›"})]}),t.jsx("div",{style:{flex:1}}),t.jsxs("span",{style:{fontSize:10,color:o.textSecondary,fontFamily:o.font,marginLeft:6,whiteSpace:"nowrap"},children:[d.length.toLocaleString()," ",d.length===1?"row":"rows",u&&e.rows.length!==d.length&&` of ${e.rows.length.toLocaleString()}`]})]})]})}function et(e,s){if(e<=7)return Array.from({length:e},(l,i)=>i+1);const n=s+1,o=[1];n>3&&o.push("…");for(let l=Math.max(2,n-1);l<=Math.min(e-1,n+1);l++)o.push(l);return n<e-2&&o.push("…"),o.push(e),o}function ae({label:e,onClick:s,t:n}){const[o,l]=W.useState(!1);return t.jsxs("button",{onClick:s,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{background:o?n.btnHover:"transparent",border:`1px solid ${o?n.btnBorder:"transparent"}`,borderRadius:3,cursor:"pointer",color:o?n.textSecondary:n.textMuted,fontSize:10,fontFamily:n.font,fontWeight:600,padding:"2px 6px",transition:"all 0.15s",display:"flex",alignItems:"center",gap:3},children:[t.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 16 16",fill:"currentColor",children:[t.jsx("path",{d:"M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0v2.5A1.75 1.75 0 0 1 13.25 14Z"}),t.jsx("path",{d:"M7.25 7.689V2a.75.75 0 0 1 1.5 0v5.689l1.97-1.97a.749.749 0 1 1 1.06 1.06l-3.25 3.25a.749.749 0 0 1-1.06 0L4.22 6.779a.749.749 0 1 1 1.06-1.06l1.97 1.97Z"})]}),e]})}function Y({disabled:e,onClick:s,children:n,t:o}){return t.jsx("button",{disabled:e,onClick:s,style:{background:"transparent",border:"none",cursor:e?"default":"pointer",color:e?o.textMuted:o.textSecondary,fontSize:12,fontFamily:o.font,padding:"0 3px",opacity:e?.4:1,transition:"opacity 0.1s"},children:n})}const _t=[{value:"bar",label:"Bar"},{value:"grouped-bar",label:"Grouped Bar"},{value:"stacked-bar",label:"Stacked Bar"},{value:"line",label:"Line"},{value:"area",label:"Area"},{value:"scatter",label:"Scatter"},{value:"pie",label:"Pie"},{value:"donut",label:"Donut"},{value:"heatmap",label:"Heatmap"},{value:"histogram",label:"Histogram"},{value:"funnel",label:"Funnel"},{value:"sankey",label:"Sankey"},{value:"waterfall",label:"Waterfall"},{value:"gauge",label:"Gauge"},{value:"kpi",label:"KPI"}],tt=/date|time|at|day|month|year/i,fe=/^(label|name|category|status|type|group)$/i,he=/^(value|count|total|revenue|amount|sum|avg|price|quantity|sales)$/i;function U(e){return typeof e=="number"?!0:typeof e=="string"?e.trim()!==""&&!isNaN(Number(e)):!1}function nt(e){return typeof e=="string"||typeof e=="number"}const ot=new Set(["bar","line","area","pie","donut","scatter","heatmap","funnel","waterfall","histogram","gauge","stacked-bar","grouped-bar","sankey","kpi","table"]);function st(e,s){if(s!=null&&s.chart){const n=s.chart.toLowerCase().replace(/_/g,"-");if(ot.has(n))return n}return lt(e)}function lt(e){const{columns:s,rows:n}=e;if(s.length<2||n.length===0)return"table";const o=s[0],l=s[1],i=n.slice(0,5),r=i.every(m=>U(m[l])),z=i.every(m=>nt(m[o]));if(tt.test(o)&&r&&z)return"line";const j=s.find(m=>fe.test(m)),b=s.find(m=>he.test(m));return j&&b&&i.every(p=>U(p[b]))?"bar":i.every(m=>U(m[o]))&&r&&s.length>=2?"scatter":s.length===2&&z&&r?"bar":"table"}const ee={default:["#388bfd","#56d364","#e3b341","#f78166","#a371f7","#39c5cf","#ffa657","#ff7b72","#89d185","#d2a8ff","#58a6ff","#3fb950"],warm:["#f85149","#f78166","#ffa657","#e3b341","#d29922","#db6d28","#ff7b72","#ffa198","#ffdfb6","#e6c174","#c4a35a","#b08c3e"],cool:["#388bfd","#58a6ff","#79c0ff","#39c5cf","#56d364","#3fb950","#a371f7","#d2a8ff","#bc8cff","#6cb6ff","#2ea043","#1f6feb"],mono:["#c9d1d9","#b1bac4","#8b949e","#6e7681","#484f58","#30363d","#21262d","#161b22","#a0a8b2","#9e9e9e","#757575","#616161"],pastel:["#b8d8f8","#b4e6c8","#f4e6a0","#f8c4a4","#d2b8f0","#a8e0e0","#f8d8a0","#f4b8b4","#c0e8c0","#e0d0f8","#a8d8f8","#b0e8b0"],corporate:["#2563eb","#16a34a","#7c3aed","#0891b2","#f59e0b","#dc2626","#475569","#0f766e","#9333ea","#0284c7","#65a30d","#ea580c"]};function H(e){return ee[e??"default"]??ee.default}function E(e,s="value",n){return Ve(s,e,n)}function ce(e,s=8){if(/^\d{4}-\d{2}(-\d{2})?/.test(e)){const n=/^\d{4}-\d{2}$/.test(e),o=new Date(n?`${e}-01T00:00:00Z`:e);if(!isNaN(o.getTime()))return o.toLocaleDateString("en-US",n?{year:"numeric",month:"short",timeZone:"UTC"}:{month:"short",day:"numeric",timeZone:"UTC"})}return String(e).length>s?String(e).slice(0,s):String(e)}function q(e,s){const n=(s!=null&&s.x&&e.columns.includes(s.x)?s.x:void 0)??e.columns.find(l=>fe.test(l))??e.columns[0],o=(s!=null&&s.y&&e.columns.includes(s.y)?s.y:void 0)??e.columns.find(l=>he.test(l))??e.columns[1];return{labelCol:n,valueCol:o}}const V=20;function se({result:e,themeMode:s,chartConfig:n}){const o=R[s],[l,i]=W.useState(null),{labelCol:r,valueCol:z}=q(e,n),j=(n==null?void 0:n.maxItems)??V,b=H(n==null?void 0:n.colorPalette),u=e.rows.slice(0,j).map(d=>({label:String(d[r]??""),value:Number(d[z]??0)})),m=e.rows.length>j,p=Math.max(...u.map(d=>d.value),1),S=28,v=120,x=6,w=12,y=u.length*(S+x)+w*2;return t.jsxs("div",{style:{padding:"8px 0"},children:[t.jsx("svg",{width:"100%",height:y,viewBox:`0 0 600 ${y}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:u.map((d,c)=>{const T=w+c*(S+x),F=600-v-84,I=Math.max(d.value/p*F,2),A=l===c,$=b[c%b.length];return t.jsxs("g",{onMouseEnter:()=>i(c),onMouseLeave:()=>i(null),style:{cursor:"default"},children:[t.jsx("text",{x:v-8,y:T+S/2+4,textAnchor:"end",fontSize:11,fontFamily:o.font,fill:o.textSecondary,children:d.label.length>16?d.label.slice(0,15)+"…":d.label}),t.jsx("rect",{x:v,y:T,width:I,height:S,rx:3,fill:$,opacity:A?1:.88,style:{transition:"opacity 0.15s"}}),t.jsx("text",{x:v+I+6,y:T+S/2+4,textAnchor:"start",fontSize:11,fontFamily:o.fontMono,fill:o.textMuted,children:E(d.value,z,n==null?void 0:n.format)})]},c)})}),m&&t.jsxs("div",{style:{fontSize:11,color:o.textMuted,fontFamily:o.font,fontStyle:"italic",padding:"4px 12px"},children:["Showing ",V," of ",e.rows.length," rows"]})]})}function rt({result:e,themeMode:s,chartConfig:n}){const o=R[s],[l,i]=W.useState(null),r=H(n==null?void 0:n.colorPalette),z=n!=null&&n.x&&e.columns.includes(n.x)?n.x:e.columns[0],j=e.rows.slice(0,5),b=e.columns.filter(d=>d!==z&&j.some(c=>U(c[d])));if(b.length===0)return t.jsx(se,{result:e,themeMode:s,chartConfig:n});const u=e.rows.slice(0,V).map(d=>String(d[z]??"")),m=Math.max(...e.rows.slice(0,V).flatMap(d=>b.map(c=>Math.abs(Number(d[c]??0)))),1),p=24,S=p/b.length,v=120,x=12,w=8,y=u.length*(p+w)+x*2;return t.jsxs("div",{style:{padding:"8px 0"},children:[t.jsx("div",{style:{display:"flex",gap:12,padding:"0 12px 6px",flexWrap:"wrap"},children:b.map((d,c)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[t.jsx("div",{style:{width:10,height:10,borderRadius:2,background:r[c%r.length]}}),t.jsx("span",{style:{fontSize:10,fontFamily:o.font,color:o.textSecondary},children:d})]},d))}),t.jsx("svg",{width:"100%",height:y,viewBox:`0 0 600 ${y}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:u.map((d,c)=>{const T=x+c*(p+w),F=e.rows[c];return t.jsxs("g",{children:[t.jsx("text",{x:v-8,y:T+p/2+4,textAnchor:"end",fontSize:11,fontFamily:o.font,fill:o.textSecondary,children:d.length>16?d.slice(0,15)+"…":d}),b.map((I,A)=>{const $=Number(F[I]??0),k=600-v-60,a=Math.max(Math.abs($)/m*k,1),h=T+A*S,g=`${c}-${A}`;return t.jsxs("g",{onMouseEnter:()=>i(g),onMouseLeave:()=>i(null),children:[t.jsx("rect",{x:v,y:h,width:a,height:S-1,rx:2,fill:r[A%r.length],opacity:l===g?1:.85,style:{transition:"opacity 0.15s"}}),l===g&&t.jsx("text",{x:v+a+4,y:h+S/2+3,fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:E($,I,n==null?void 0:n.format)})]},A)})]},c)})})]})}function it({result:e,themeMode:s,chartConfig:n}){const o=R[s],[l,i]=W.useState(null),r=H(n==null?void 0:n.colorPalette),z=n!=null&&n.x&&e.columns.includes(n.x)?n.x:e.columns[0],j=e.rows.slice(0,5),b=e.columns.filter(d=>d!==z&&j.some(c=>U(c[d])));if(b.length===0)return t.jsx(se,{result:e,themeMode:s,chartConfig:n});const u=e.rows.slice(0,V),m=u.map(d=>String(d[z]??"")),p=Math.max(...u.map(d=>b.reduce((c,T)=>c+Math.abs(Number(d[T]??0)),0)),1),S=28,v=120,x=12,w=6,y=m.length*(S+w)+x*2;return t.jsxs("div",{style:{padding:"8px 0"},children:[t.jsx("div",{style:{display:"flex",gap:12,padding:"0 12px 6px",flexWrap:"wrap"},children:b.map((d,c)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[t.jsx("div",{style:{width:10,height:10,borderRadius:2,background:r[c%r.length]}}),t.jsx("span",{style:{fontSize:10,fontFamily:o.font,color:o.textSecondary},children:d})]},d))}),t.jsx("svg",{width:"100%",height:y,viewBox:`0 0 600 ${y}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:m.map((d,c)=>{const T=x+c*(S+w),F=u[c],I=600-v-60;let A=v;return t.jsxs("g",{children:[t.jsx("text",{x:v-8,y:T+S/2+4,textAnchor:"end",fontSize:11,fontFamily:o.font,fill:o.textSecondary,children:d.length>16?d.slice(0,15)+"…":d}),b.map(($,k)=>{const a=Math.abs(Number(F[$]??0)),h=Math.max(a/p*I,0),g=A;A+=h;const _=`${c}-${k}`;return t.jsxs("g",{onMouseEnter:()=>i(_),onMouseLeave:()=>i(null),children:[t.jsx("rect",{x:g,y:T,width:h,height:S,rx:k===0?3:0,fill:r[k%r.length],opacity:l===_?1:.85,style:{transition:"opacity 0.15s"}}),l===_&&h>30&&t.jsx("text",{x:g+h/2,y:T+S/2+4,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:"#fff",fontWeight:600,children:E(a,$,n==null?void 0:n.format)})]},k)})]},c)})})]})}function de({result:e,themeMode:s,showArea:n,chartConfig:o}){const l=R[s],[i,r]=W.useState(null),j=H(o==null?void 0:o.colorPalette)[0]??l.accent,{labelCol:b,valueCol:u}=q(e,o),m=e.rows.map(M=>({label:String(M[b]??""),value:Number(M[u]??0)}));if(m.length<2)return null;const p=560,S=212,v=56,x=16,w=16,y=48,d=p-v-x,c=S-w-y,T=Math.min(...m.map(M=>M.value)),I=Math.max(...m.map(M=>M.value))-T||1,A=d/(m.length-1),$=M=>v+M*A,k=M=>w+c-(M-T)/I*c,a=m.map((M,N)=>({x:$(N),y:k(M.value)})),h=a.reduce((M,N,P)=>{if(P===0)return`M ${N.x},${N.y}`;const D=a[P-1],O=D.x+(N.x-D.x)/2;return`${M} C ${O},${D.y} ${O},${N.y} ${N.x},${N.y}`},""),g=`${h} L ${a[a.length-1].x},${w+c} L ${v},${w+c} Z`,_=5,L=Array.from({length:_+1},(M,N)=>{const P=T+I*N/_;return{val:P,y:k(P)}}),B=Math.ceil(m.length/8),f=m.filter((M,N)=>N%B===0||N===m.length-1);return t.jsx("div",{style:{position:"relative",padding:"8px 0"},children:t.jsxs("svg",{width:"100%",height:S,viewBox:`0 0 ${p} ${S}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},onMouseLeave:()=>r(null),children:[L.map((M,N)=>t.jsxs("g",{children:[t.jsx("line",{x1:v,y1:M.y,x2:v+d,y2:M.y,stroke:l.tableBorder,strokeWidth:.5}),t.jsx("text",{x:v-6,y:M.y+4,textAnchor:"end",fontSize:10,fontFamily:l.fontMono,fill:l.textMuted,children:E(M.val,u,o==null?void 0:o.format)})]},N)),t.jsx("path",{d:g,fill:j,opacity:n?.3:.15}),t.jsx("path",{d:h,fill:"none",stroke:j,strokeWidth:2,strokeLinejoin:"round"}),a.map((M,N)=>t.jsx("circle",{cx:M.x,cy:M.y,r:3,fill:j,style:{cursor:"crosshair"},onMouseEnter:()=>r({x:M.x,y:M.y,label:m[N].label,value:m[N].value})},N)),f.map((M,N)=>{const P=m.indexOf(M);return t.jsx("text",{x:$(P),y:w+c+16,textAnchor:"middle",fontSize:10,fontFamily:l.font,fill:l.textMuted,children:ce(M.label)},N)}),t.jsx("line",{x1:v,y1:w,x2:v,y2:w+c,stroke:l.tableBorder,strokeWidth:1}),t.jsx("line",{x1:v,y1:w+c,x2:v+d,y2:w+c,stroke:l.tableBorder,strokeWidth:1}),t.jsx("text",{x:v+d/2,y:S-4,textAnchor:"middle",fontSize:10,fontWeight:600,fontFamily:l.font,fill:l.textMuted,letterSpacing:"0.04em",children:b}),t.jsx("text",{x:12,y:w+c/2,textAnchor:"middle",fontSize:10,fontWeight:600,fontFamily:l.font,fill:l.textMuted,letterSpacing:"0.04em",transform:`rotate(-90, 12, ${w+c/2})`,children:u}),i&&t.jsxs("g",{children:[t.jsx("rect",{x:i.x+8,y:i.y-20,width:90,height:32,rx:4,fill:l.cellBg,stroke:l.cellBorder,strokeWidth:1}),t.jsx("text",{x:i.x+13,y:i.y-8,fontSize:10,fontFamily:l.font,fill:l.textSecondary,children:ce(i.label,12)}),t.jsx("text",{x:i.x+13,y:i.y+6,fontSize:11,fontFamily:l.fontMono,fill:l.textPrimary,fontWeight:600,children:E(i.value,u,o==null?void 0:o.format)})]})]})})}function at({result:e,themeMode:s,chartConfig:n}){const o=R[s],[l,i]=W.useState(null),r=H(n==null?void 0:n.colorPalette),z=n!=null&&n.x&&e.columns.includes(n.x)?n.x:e.columns[0],j=n!=null&&n.y&&e.columns.includes(n.y)?n.y:e.columns[1],b=n!=null&&n.color&&e.columns.includes(n.color)?n.color:void 0,u=e.rows.slice(0,200).map(g=>({x:Number(g[z]??0),y:Number(g[j]??0),color:b?String(g[b]??""):void 0})),m=560,p=300,S=52,v=16,x=16,w=36,y=m-S-v,d=p-x-w,c=Math.min(...u.map(g=>g.x)),T=Math.max(...u.map(g=>g.x)),F=Math.min(...u.map(g=>g.y)),I=Math.max(...u.map(g=>g.y)),A=T-c||1,$=I-F||1,k=g=>S+(g-c)/A*y,a=g=>x+d-(g-F)/$*d,h=b?[...new Set(u.map(g=>g.color))]:[];return t.jsxs("div",{style:{padding:"8px 0"},children:[b&&h.length>0&&t.jsx("div",{style:{display:"flex",gap:12,padding:"0 12px 6px",flexWrap:"wrap"},children:h.slice(0,12).map((g,_)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[t.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:r[_%r.length]}}),t.jsx("span",{style:{fontSize:10,fontFamily:o.font,color:o.textSecondary},children:g})]},g))}),t.jsxs("svg",{width:"100%",height:p,viewBox:`0 0 ${m} ${p}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:[Array.from({length:6},(g,_)=>{const L=F+$*_/5,B=a(L);return t.jsxs("g",{children:[t.jsx("line",{x1:S,y1:B,x2:S+y,y2:B,stroke:o.tableBorder,strokeWidth:.5}),t.jsx("text",{x:S-6,y:B+4,textAnchor:"end",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:E(L,j,n==null?void 0:n.format)})]},_)}),Array.from({length:6},(g,_)=>{const L=c+A*_/5,B=k(L);return t.jsx("text",{x:B,y:x+d+16,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:E(L,z)},_)}),t.jsx("line",{x1:S,y1:x,x2:S,y2:x+d,stroke:o.tableBorder,strokeWidth:1}),t.jsx("line",{x1:S,y1:x+d,x2:S+y,y2:x+d,stroke:o.tableBorder,strokeWidth:1}),t.jsx("text",{x:S+y/2,y:p-2,textAnchor:"middle",fontSize:10,fontFamily:o.font,fill:o.textMuted,children:z}),t.jsx("text",{x:10,y:x+d/2,textAnchor:"middle",fontSize:10,fontFamily:o.font,fill:o.textMuted,transform:`rotate(-90, 10, ${x+d/2})`,children:j}),u.map((g,_)=>{const L=b?h.indexOf(g.color):0;return t.jsx("circle",{cx:k(g.x),cy:a(g.y),r:l===_?5:3.5,fill:r[L%r.length],opacity:l===_?1:.7,style:{cursor:"crosshair",transition:"r 0.1s, opacity 0.1s"},onMouseEnter:()=>i(_),onMouseLeave:()=>i(null)},_)}),l!==null&&t.jsxs("g",{children:[t.jsx("rect",{x:k(u[l].x)+8,y:a(u[l].y)-24,width:100,height:28,rx:4,fill:o.cellBg,stroke:o.cellBorder,strokeWidth:1}),t.jsxs("text",{x:k(u[l].x)+13,y:a(u[l].y)-8,fontSize:10,fontFamily:o.fontMono,fill:o.textPrimary,children:["(",E(u[l].x,z),", ",E(u[l].y,j,n==null?void 0:n.format),")"]})]})]})]})}const ct=12;function xe({result:e,themeMode:s,chartConfig:n,isDonut:o}){const l=R[s],[i,r]=W.useState(null),{labelCol:z,valueCol:j}=q(e,n),b=H(n==null?void 0:n.colorPalette),u=e.rows.slice(0,ct).map(c=>({label:String(c[z]??""),value:Math.abs(Number(c[j]??0))})),m=u.reduce((c,T)=>c+T.value,0)||1,p=90,S=90,v=70,x=o?40:0,w=[];let y=-Math.PI/2;u.forEach((c,T)=>{const F=c.value/m*2*Math.PI,I=y,A=y+F,$=p+v*Math.cos(I),k=S+v*Math.sin(I),a=p+v*Math.cos(A),h=S+v*Math.sin(A),g=F>Math.PI?1:0;let _;if(x>0){const L=p+x*Math.cos(I),B=S+x*Math.sin(I),f=p+x*Math.cos(A),M=S+x*Math.sin(A);_=`M ${$} ${k} A ${v} ${v} 0 ${g} 1 ${a} ${h} L ${f} ${M} A ${x} ${x} 0 ${g} 0 ${L} ${B} Z`}else _=`M ${p} ${S} L ${$} ${k} A ${v} ${v} 0 ${g} 1 ${a} ${h} Z`;w.push({path:_,color:b[T%b.length],label:c.label,value:c.value,pct:c.value/m*100}),y=A});const d=i!==null?w[i]:null;return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"8px 12px",flexWrap:"wrap"},children:[t.jsxs("svg",{width:180,height:180,style:{flexShrink:0},onMouseLeave:()=>r(null),children:[w.map((c,T)=>t.jsx("path",{d:c.path,fill:c.color,opacity:i===null||i===T?1:.55,style:{cursor:"pointer",transition:"opacity 0.15s"},onMouseEnter:()=>r(T)},T)),o&&t.jsxs(t.Fragment,{children:[t.jsx("text",{x:p,y:S-5,textAnchor:"middle",fontSize:11,fontFamily:l.fontMono,fill:l.textSecondary,children:E(d?d.value:m,j,n==null?void 0:n.format)}),t.jsx("text",{x:p,y:S+9,textAnchor:"middle",fontSize:9,fontFamily:l.font,fill:l.textMuted,children:d?`${d.pct.toFixed(1)}%`:"total"})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,maxHeight:180,overflowY:"auto",flex:1},children:w.map((c,T)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,cursor:"default",opacity:i===null||i===T?1:.5},onMouseEnter:()=>r(T),onMouseLeave:()=>r(null),children:[t.jsx("div",{style:{width:10,height:10,borderRadius:2,background:c.color,flexShrink:0}}),t.jsx("span",{style:{fontSize:11,fontFamily:l.font,color:l.textSecondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.label}),t.jsxs("span",{style:{fontSize:11,fontFamily:l.fontMono,color:l.textMuted,marginLeft:"auto",flexShrink:0},children:[c.pct.toFixed(1),"%"]})]},T))})]})}function dt({result:e,themeMode:s}){const n=R[s],[o,l]=W.useState(null),i=e.columns[0],r=e.columns.slice(1),z=e.rows.slice(0,30),j=z.flatMap(w=>r.map(y=>Number(w[y]??0))),b=Math.min(...j),m=Math.max(...j)-b||1,p=Math.min(50,480/r.length),S=24,v=100;function x(w){const y=(w-b)/m,d=Math.round(56+y*192),c=Math.round(139+y*-58),T=Math.round(253+y*-180);return`rgb(${d},${c},${T})`}return t.jsx("div",{style:{padding:"8px 0",overflowX:"auto"},children:t.jsxs("svg",{width:v+r.length*p+20,height:z.length*S+S+16,style:{display:"block",overflow:"visible"},children:[r.map((w,y)=>t.jsx("text",{x:v+y*p+p/2,y:14,textAnchor:"middle",fontSize:9,fontFamily:n.font,fill:n.textMuted,transform:`rotate(-30, ${v+y*p+p/2}, 14)`,children:w.length>8?w.slice(0,7)+"…":w},y)),z.map((w,y)=>{const d=String(w[i]??""),c=S+y*S;return t.jsxs("g",{children:[t.jsx("text",{x:v-6,y:c+S/2+4,textAnchor:"end",fontSize:10,fontFamily:n.font,fill:n.textSecondary,children:d.length>14?d.slice(0,13)+"…":d}),r.map((T,F)=>{const I=Number(w[T]??0),A=(o==null?void 0:o.r)===y&&(o==null?void 0:o.c)===F;return t.jsxs("g",{onMouseEnter:()=>l({r:y,c:F}),onMouseLeave:()=>l(null),children:[t.jsx("rect",{x:v+F*p,y:c,width:p-1,height:S-1,rx:2,fill:x(I),opacity:A?1:.85,stroke:A?n.accent:"none",strokeWidth:A?1.5:0}),A&&t.jsx("text",{x:v+F*p+p/2,y:c+S/2+4,textAnchor:"middle",fontSize:10,fontFamily:n.fontMono,fill:"#fff",fontWeight:600,children:E(I,T)})]},F)})]},y)})]})})}function xt({result:e,themeMode:s,chartConfig:n}){const o=R[s],[l,i]=W.useState(null),z=H(n==null?void 0:n.colorPalette)[0]??o.accent,j=(n!=null&&n.x&&e.columns.includes(n.x)?n.x:void 0)??e.columns.find(a=>e.rows.slice(0,5).some(h=>U(h[a])))??e.columns[0],b=e.rows.map(a=>Number(a[j]??0)).filter(a=>!isNaN(a));if(b.length===0)return null;const u=Math.min(20,Math.max(5,Math.ceil(Math.sqrt(b.length)))),m=Math.min(...b),v=(Math.max(...b)-m||1)/u,x=Array.from({length:u},(a,h)=>({low:m+h*v,high:m+(h+1)*v,count:0}));b.forEach(a=>{const h=Math.min(Math.floor((a-m)/v),u-1);x[h].count++});const w=Math.max(...x.map(a=>a.count),1),y=560,d=200,c=52,T=16,F=16,I=36,A=y-c-T,$=d-F-I,k=A/u;return t.jsx("div",{style:{padding:"8px 0"},children:t.jsxs("svg",{width:"100%",height:d,viewBox:`0 0 ${y} ${d}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:[Array.from({length:5},(a,h)=>{const g=w*(h+1)/5,_=F+$-g/w*$;return t.jsxs("g",{children:[t.jsx("line",{x1:c,y1:_,x2:c+A,y2:_,stroke:o.tableBorder,strokeWidth:.5}),t.jsx("text",{x:c-6,y:_+4,textAnchor:"end",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:Math.round(g)})]},h)}),x.map((a,h)=>{const g=a.count/w*$,_=c+h*k,L=F+$-g,B=l===h;return t.jsxs("g",{onMouseEnter:()=>i(h),onMouseLeave:()=>i(null),children:[t.jsx("rect",{x:_+1,y:L,width:k-2,height:g,rx:1,fill:z,opacity:B?1:.85,style:{transition:"opacity 0.1s"}}),B&&t.jsx("text",{x:_+k/2,y:L-4,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textPrimary,children:a.count})]},h)}),x.filter((a,h)=>h%Math.ceil(u/6)===0).map((a,h)=>{const g=x.indexOf(a);return t.jsx("text",{x:c+g*k+k/2,y:F+$+16,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:E(a.low,j,n==null?void 0:n.format)},h)}),t.jsx("line",{x1:c,y1:F,x2:c,y2:F+$,stroke:o.tableBorder,strokeWidth:1}),t.jsx("line",{x1:c,y1:F+$,x2:c+A,y2:F+$,stroke:o.tableBorder,strokeWidth:1}),t.jsx("text",{x:c+A/2,y:d-2,textAnchor:"middle",fontSize:10,fontFamily:o.font,fill:o.textMuted,children:j})]})})}function ut({result:e,themeMode:s,chartConfig:n}){const o=R[s],[l,i]=W.useState(null),{labelCol:r,valueCol:z}=q(e,n),j=H(n==null?void 0:n.colorPalette),b=e.rows.slice(0,10).map(y=>({label:String(y[r]??""),value:Math.abs(Number(y[z]??0))}));if(b.length===0)return null;const u=b[0].value||1,m=400,p=36,S=4,v=16,x=b.length*(p+S)+v*2,w=m/2;return t.jsx("div",{style:{padding:"8px 0",display:"flex",justifyContent:"center"},children:t.jsx("svg",{width:m,height:x,style:{display:"block"},children:b.map((y,d)=>{const c=v+d*(p+S),T=y.value/u,F=Math.max(T*(m-80),40),I=l===d,A=d<b.length-1?b[d+1].value/u:T*.8,$=Math.max(A*(m-80),40),k=w-F/2,a=w+F/2,h=w+$/2,g=w-$/2,_=`M ${k} ${c} L ${a} ${c} L ${h} ${c+p} L ${g} ${c+p} Z`;return t.jsxs("g",{onMouseEnter:()=>i(d),onMouseLeave:()=>i(null),style:{cursor:"default"},children:[t.jsx("path",{d:_,fill:j[d%j.length],opacity:I?1:.85,style:{transition:"opacity 0.15s"}}),t.jsx("text",{x:w,y:c+p/2+1,textAnchor:"middle",fontSize:11,fontFamily:o.font,fill:"#fff",fontWeight:500,children:y.label}),t.jsxs("text",{x:w,y:c+p/2+13,textAnchor:"middle",fontSize:9,fontFamily:o.fontMono,fill:"rgba(255,255,255,0.7)",children:[E(y.value,z,n==null?void 0:n.format)," (",(T*100).toFixed(0),"%)"]})]},d)})})})}function pt({result:e,themeMode:s,chartConfig:n}){const o=R[s],l=H(n==null?void 0:n.colorPalette),[i,r]=W.useState(null),z=e.rows.slice(0,20),j=e.columns.filter(f=>z.some(M=>U(M[f]))),b=e.columns.filter(f=>!j.includes(f)),u=n!=null&&n.x&&b.includes(n.x)?n.x:b.find(f=>/(?:^|_)(?:source|from|origin|upstream|supplier|producer|category)(?:_|$)/i.test(f))??b[0],m=n!=null&&n.color&&b.includes(n.color)&&n.color!==u?n.color:b.find(f=>f!==u&&/(?:^|_)(?:target|to|destination|downstream|consumer|customer|product)(?:_|$)/i.test(f))??b.find(f=>f!==u),p=n!=null&&n.y&&j.includes(n.y)?n.y:j[0];if(!u||!m||!p)return t.jsx(C,{result:e,themeMode:s});const S=new Map;for(const f of e.rows){const M=String(f[u]??"").trim(),N=String(f[m]??"").trim(),P=Math.abs(Number(f[p]??0));if(!M||!N||!Number.isFinite(P)||P<=0)continue;const D=`${M}\0${N}`,O=S.get(D);S.set(D,{source:M,target:N,value:((O==null?void 0:O.value)??0)+P})}const v=[...S.values()].sort((f,M)=>M.value-f.value);if(v.length===0)return t.jsx(C,{result:e,themeMode:s});const x=new Map,w=new Map;v.forEach(f=>{x.set(f.source,(x.get(f.source)??0)+f.value),w.set(f.target,(w.get(f.target)??0)+f.value)});const y=[...x].sort((f,M)=>M[1]-f[1]).slice(0,12).map(([f])=>f),d=[...w].sort((f,M)=>M[1]-f[1]).slice(0,12).map(([f])=>f),c=new Set(y),T=new Set(d),F=v.filter(f=>c.has(f.source)&&T.has(f.target)).slice(0,40),I=Math.max(...F.map(f=>f.value),1),A=640,$=Math.max(250,Math.max(y.length,d.length)*34+40),k=132,a=A-144,h=12,g=28,_=(f,M)=>M<=1?$/2:g+f*(($-g*2)/(M-1)),L=new Map(y.map((f,M)=>[f,M])),B=new Map(d.map((f,M)=>[f,M]));return t.jsx("div",{style:{padding:"8px 0",overflowX:"auto"},children:t.jsxs("svg",{role:"img","aria-label":`${u} to ${m} flow by ${p}`,width:"100%",height:$,viewBox:`0 0 ${A} ${$}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",minWidth:520},children:[t.jsx("text",{x:k,y:14,textAnchor:"middle",fontSize:10,fontWeight:700,fontFamily:o.font,fill:o.textMuted,children:u}),t.jsx("text",{x:a,y:14,textAnchor:"middle",fontSize:10,fontWeight:700,fontFamily:o.font,fill:o.textMuted,children:m}),F.map((f,M)=>{const N=_(L.get(f.source)??0,y.length),P=_(B.get(f.target)??0,d.length),D=`${f.source}\0${f.target}`,O=i===D,ve=`M ${k+h},${N} C ${k+150},${N} ${a-150},${P} ${a},${P}`,X=A/2,K=(N+P)/2;return t.jsxs("g",{onMouseEnter:()=>r(D),onMouseLeave:()=>r(null),children:[t.jsx("path",{d:ve,fill:"none",stroke:l[M%l.length],strokeWidth:Math.max(2,f.value/I*18),opacity:i===null||O?.7:.14,strokeLinecap:"round",style:{transition:"opacity 0.15s",cursor:"default"}}),O?t.jsxs("g",{pointerEvents:"none",children:[t.jsx("rect",{x:X-72,y:K-18,width:144,height:36,rx:5,fill:o.cellBg,stroke:o.cellBorder}),t.jsxs("text",{x:X,y:K-3,textAnchor:"middle",fontSize:9.5,fontFamily:o.font,fill:o.textSecondary,children:[f.source," → ",f.target]}),t.jsx("text",{x:X,y:K+11,textAnchor:"middle",fontSize:11,fontWeight:700,fontFamily:o.fontMono,fill:o.textPrimary,children:E(f.value,p,n==null?void 0:n.format)})]}):null]},D)}),y.map((f,M)=>{const N=_(M,y.length);return t.jsxs("g",{children:[t.jsx("rect",{x:k,y:N-9,width:h,height:18,rx:3,fill:l[M%l.length]}),t.jsx("text",{x:k-7,y:N+3,textAnchor:"end",fontSize:10.5,fontFamily:o.font,fill:o.textSecondary,children:f.length>18?`${f.slice(0,17)}…`:f})]},`source-${f}`)}),d.map((f,M)=>{const N=_(M,d.length);return t.jsxs("g",{children:[t.jsx("rect",{x:a,y:N-9,width:h,height:18,rx:3,fill:l[(M+y.length)%l.length]}),t.jsx("text",{x:a+h+7,y:N+3,textAnchor:"start",fontSize:10.5,fontFamily:o.font,fill:o.textSecondary,children:f.length>18?`${f.slice(0,17)}…`:f})]},`target-${f}`)})]})})}function mt({result:e,themeMode:s,chartConfig:n}){const o=R[s],[l,i]=W.useState(null),{labelCol:r,valueCol:z}=q(e,n),j=e.rows.slice(0,15).map(k=>({label:String(k[r]??""),value:Number(k[z]??0)}));if(j.length===0)return null;let b=0;const u=j.map(k=>{const a=b;return b+=k.value,{...k,start:a,end:b}}),m=u.flatMap(k=>[k.start,k.end]),p=Math.min(0,...m),v=Math.max(0,...m)-p||1,x=560,w=240,y=52,d=16,c=16,T=44,F=x-y-d,I=w-c-T,A=F/u.length,$=k=>c+I-(k-p)/v*I;return t.jsx("div",{style:{padding:"8px 0"},children:t.jsxs("svg",{width:"100%",height:w,viewBox:`0 0 ${x} ${w}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:[Array.from({length:6},(k,a)=>{const h=p+v*a/5,g=$(h);return t.jsxs("g",{children:[t.jsx("line",{x1:y,y1:g,x2:y+F,y2:g,stroke:o.tableBorder,strokeWidth:.5}),t.jsx("text",{x:y-6,y:g+4,textAnchor:"end",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:E(h,z,n==null?void 0:n.format)})]},a)}),t.jsx("line",{x1:y,y1:$(0),x2:y+F,y2:$(0),stroke:o.textMuted,strokeWidth:1,strokeDasharray:"3,3"}),u.map((k,a)=>{const h=y+a*A,g=$(Math.max(k.start,k.end)),L=$(Math.min(k.start,k.end))-g,B=k.value>=0,f=l===a;return t.jsxs("g",{onMouseEnter:()=>i(a),onMouseLeave:()=>i(null),children:[a<u.length-1&&t.jsx("line",{x1:h+A-2,y1:$(k.end),x2:h+A+2,y2:$(k.end),stroke:o.textMuted,strokeWidth:1,strokeDasharray:"2,2"}),t.jsx("rect",{x:h+4,y:g,width:A-8,height:Math.max(L,1),rx:2,fill:B?o.success:o.error,opacity:f?1:.8,style:{transition:"opacity 0.1s"}}),f&&t.jsxs("text",{x:h+A/2,y:g-4,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textPrimary,children:[k.value>=0?"+":"",E(k.value,z,n==null?void 0:n.format)]})]},a)}),u.map((k,a)=>t.jsx("text",{x:y+a*A+A/2,y:w-6,textAnchor:"middle",fontSize:9,fontFamily:o.font,fill:o.textMuted,transform:`rotate(-20, ${y+a*A+A/2}, ${w-6})`,children:k.label.length>8?k.label.slice(0,7)+"…":k.label},a)),t.jsx("line",{x1:y,y1:c,x2:y,y2:c+I,stroke:o.tableBorder,strokeWidth:1}),t.jsx("line",{x1:y,y1:c+I,x2:y+F,y2:c+I,stroke:o.tableBorder,strokeWidth:1})]})})}function yt({result:e,themeMode:s,chartConfig:n}){const o=R[s],l=e.rows[0];if(!l)return null;const i=(n!=null&&n.y&&e.columns.includes(n.y)?n.y:void 0)??e.columns.find($=>U(l[$]))??e.columns[0],r=Number(l[i]??0),z=(n==null?void 0:n.title)??i,j=r>100?r*1.2:100,b=Math.min(Math.max(r/j,0),1),u=120,m=110,p=80,S=Math.PI,v=0,x=S-(S-v)*b,w=u+p*Math.cos(S),y=m+p*Math.sin(S),d=u+p*Math.cos(x),c=m+p*Math.sin(x),T=b>.5?1:0,F=u+p*Math.cos(v),I=m+p*Math.sin(v),A=b<.33?o.error:b<.66?o.warning:o.success;return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"16px 24px"},children:t.jsxs("svg",{width:240,height:140,style:{display:"block",overflow:"visible"},children:[t.jsx("path",{d:`M ${w} ${y} A ${p} ${p} 0 1 1 ${F} ${I}`,fill:"none",stroke:o.tableBorder,strokeWidth:12,strokeLinecap:"round"}),b>0&&t.jsx("path",{d:`M ${w} ${y} A ${p} ${p} 0 ${T} 1 ${d} ${c}`,fill:"none",stroke:A,strokeWidth:12,strokeLinecap:"round"}),t.jsx("text",{x:u,y:m-4,textAnchor:"middle",fontSize:28,fontFamily:o.fontMono,fill:A,fontWeight:700,children:E(r,i,n==null?void 0:n.format)}),t.jsx("text",{x:u,y:m+16,textAnchor:"middle",fontSize:11,fontFamily:o.font,fill:o.textMuted,children:z})]})})}function ft(e,s,n,o){const l=Number(s);return s==null||typeof s!="number"&&isNaN(l)?s==null?"—":String(s):oe(e,s,n,{compact:Math.abs(l)>=1e5,format:o})}function be({result:e,themeMode:s,chartConfig:n}){const o=R[s],l=H(n==null?void 0:n.colorPalette),i=e.rows[0];if(!i)return null;const r=n!=null&&n.y&&e.columns.includes(n.y)?n.y:e.columns.find(j=>U(i[j]))??e.columns[0],z=ft(r,i[r],e.rows.map(j=>j[r]),n==null?void 0:n.format);return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:54,padding:"8px 4px",boxSizing:"border-box",minWidth:0},children:t.jsx("span",{title:String(i[r]),style:{fontSize:"clamp(24px, 3.2vw, 40px)",fontWeight:750,fontFamily:o.fontMono,color:l[0]??o.accent,lineHeight:1.1,maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z})})}function ht({config:e,columns:s,onChange:n,onClose:o,t:l}){const i={background:l.inputBg,border:`1px solid ${l.inputBorder}`,borderRadius:4,color:l.textPrimary,fontSize:11,fontFamily:l.font,padding:"4px 8px",outline:"none",width:"100%",boxSizing:"border-box"};return t.jsxs("div",{style:{position:"absolute",top:4,right:4,zIndex:100,background:l.cellBg,border:`1px solid ${l.headerBorder}`,borderRadius:8,padding:12,width:240,boxShadow:"0 4px 16px rgba(0,0,0,0.3)",display:"grid",gap:8},onClick:r=>r.stopPropagation(),children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,color:l.textPrimary,fontFamily:l.font},children:"Chart Settings"}),t.jsx("button",{onClick:o,style:{background:"none",border:"none",color:l.textMuted,cursor:"pointer",fontSize:14},children:"×"})]}),t.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Title",t.jsx("input",{value:e.title??"",onChange:r=>n({title:r.target.value||void 0}),placeholder:"Chart title",style:{...i,marginTop:2}})]}),t.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["X-axis label",t.jsx("input",{value:e.xLabel??"",onChange:r=>n({xLabel:r.target.value||void 0}),placeholder:"Auto",style:{...i,marginTop:2}})]}),t.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Y-axis label",t.jsx("input",{value:e.yLabel??"",onChange:r=>n({yLabel:r.target.value||void 0}),placeholder:"Auto",style:{...i,marginTop:2}})]}),t.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Legend",t.jsxs("select",{value:e.legendPosition??"top",onChange:r=>n({legendPosition:r.target.value}),style:{...i,marginTop:2},children:[t.jsx("option",{value:"top",children:"Top"}),t.jsx("option",{value:"bottom",children:"Bottom"}),t.jsx("option",{value:"left",children:"Left"}),t.jsx("option",{value:"right",children:"Right"}),t.jsx("option",{value:"none",children:"Hidden"})]})]}),t.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Color palette",t.jsx("select",{value:e.colorPalette??"default",onChange:r=>n({colorPalette:r.target.value}),style:{...i,marginTop:2},children:Object.keys(ee).map(r=>t.jsx("option",{value:r,children:r.charAt(0).toUpperCase()+r.slice(1)},r))})]}),t.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Max items",t.jsx("input",{type:"number",value:e.maxItems??V,min:5,max:200,onChange:r=>n({maxItems:parseInt(r.target.value)||V}),style:{...i,marginTop:2}})]})]})}function Tt({result:e,themeMode:s,chartConfig:n,onConfigChange:o}){const l=R[s],i=st(e,n),[r,z]=W.useState(!1);return i==="kpi"?t.jsx(be,{result:e,themeMode:s,chartConfig:n}):t.jsxs("div",{style:{position:"relative"},children:[(n==null?void 0:n.title)&&t.jsx("div",{style:{padding:"8px 12px 0",fontSize:13,fontWeight:600,color:l.textPrimary,fontFamily:l.font,textAlign:"center"},children:n.title}),o&&t.jsx("button",{onClick:()=>z(!r),title:"Chart settings",style:{position:"absolute",top:4,right:4,zIndex:50,background:r?`${l.accent}18`:"transparent",border:`1px solid ${r?l.accent:"transparent"}`,borderRadius:4,color:r?l.accent:l.textMuted,cursor:"pointer",fontSize:14,padding:"2px 6px",lineHeight:1},children:"⚙"}),r&&o&&t.jsx(ht,{config:n??{},columns:e.columns,onChange:j=>o(j),onClose:()=>z(!1),t:l}),bt(i,e,s,n)]})}function bt(e,s,n,o){const l=o!=null&&o.x&&s.columns.includes(o.x)?o.x:void 0,i=o!=null&&o.y&&s.columns.includes(o.y)?o.y:void 0,r=l||i?gt(s,l,i):s;switch(e){case"line":return t.jsx(de,{result:r,themeMode:n,chartConfig:o});case"area":return t.jsx(de,{result:r,themeMode:n,chartConfig:o,showArea:!0});case"bar":return t.jsx(se,{result:r,themeMode:n,chartConfig:o});case"grouped-bar":return t.jsx(rt,{result:r,themeMode:n,chartConfig:o});case"stacked-bar":return t.jsx(it,{result:r,themeMode:n,chartConfig:o});case"scatter":return t.jsx(at,{result:s,themeMode:n,chartConfig:o});case"pie":return t.jsx(xe,{result:s,themeMode:n,chartConfig:o,isDonut:!1});case"donut":return t.jsx(xe,{result:s,themeMode:n,chartConfig:o,isDonut:!0});case"heatmap":return t.jsx(dt,{result:s,themeMode:n});case"histogram":return t.jsx(xt,{result:s,themeMode:n,chartConfig:o});case"funnel":return t.jsx(ut,{result:s,themeMode:n,chartConfig:o});case"sankey":return t.jsx(pt,{result:s,themeMode:n,chartConfig:o});case"waterfall":return t.jsx(mt,{result:s,themeMode:n,chartConfig:o});case"gauge":return t.jsx(yt,{result:s,themeMode:n,chartConfig:o});case"kpi":return t.jsx(be,{result:s,themeMode:n,chartConfig:o});default:return t.jsx(C,{result:s,themeMode:n})}}function gt(e,s,n){const o=e.columns,l=[];s&&o.includes(s)&&l.push(s),n&&o.includes(n)&&l.push(n);for(const i of o)l.includes(i)||l.push(i);return l.join(",")===o.join(",")?e:{...e,columns:l,rows:e.rows.map(i=>{const r={};for(const z of l)r[z]=i[z];return r})}}function Ft(e){return new Set(e.tiles.filter(s=>!s.error&&s.selectedByDefault).map(s=>s.id))}function Nt({proposal:e,t:s,selected:n,onToggle:o,onCreate:l,busy:i,error:r,compact:z}){const j=e.tiles.filter(x=>!x.error),b=e.tiles.filter(x=>x.error),u=j.filter(x=>n.has(x.id)).length,m=j.filter(x=>n.has(x.id)&&x.certification==="ai_generated").length,p=j.filter(x=>n.has(x.id)&&x.certification==="reviewed_semantic").length,v=j.filter(x=>n.has(x.id)&&x.certification==="certified").length+p>0||e.intent.target==="personal"&&m>0;return t.jsxs("div",{style:{display:"grid",gap:10},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12.5,fontWeight:800,color:s.textPrimary},children:"Build Brief"}),t.jsxs("span",{style:{fontSize:11,color:s.textMuted},children:[e.coverage.certifiedTiles," certified",e.coverage.semanticTiles>0?` · ${e.coverage.semanticTiles} governed semantic`:"",e.coverage.generatedTiles>0?` · ${e.coverage.generatedTiles} exploratory`:"",e.coverage.gaps>0?` · ${e.coverage.gaps} uncovered`:""]}),t.jsxs("span",{style:{fontSize:10.5,color:s.textMuted},children:[e.intent.target==="personal"?"Personal Draft":"Shared Project target"," · starts private"]})]}),t.jsxs("div",{style:{display:"grid",gap:6},children:[j.map(x=>t.jsx(vt,{tile:x,t:s,checked:n.has(x.id),onToggle:()=>o(x.id),compact:z},x.id)),b.map(x=>t.jsxs("div",{style:{...ge(s),opacity:.75},children:[t.jsx(je,{size:13,color:s.warning,style:{flexShrink:0,marginTop:2}}),t.jsxs("div",{style:{minWidth:0,flex:1},children:[t.jsx("div",{style:{fontSize:12,fontWeight:700,color:s.textSecondary},children:x.title}),t.jsx("div",{style:{fontSize:11,color:s.textMuted,marginTop:1},children:x.error})]})]},x.id))]}),e.gaps.length>0?t.jsxs("div",{style:{display:"grid",gap:4},children:[t.jsx("div",{style:{fontSize:11,fontWeight:800,color:s.textMuted,textTransform:"uppercase",letterSpacing:"0.04em"},children:"Not covered yet"}),e.gaps.map(x=>t.jsxs("div",{style:{display:"flex",gap:7,alignItems:"flex-start",fontSize:11.5,color:s.textMuted},children:[t.jsx(Fe,{size:12,style:{flexShrink:0,marginTop:2}}),t.jsx("span",{style:{lineHeight:1.4},children:x.question})]},x.id))]}):null,r?t.jsx("div",{style:{fontSize:12,color:s.error},children:r}):null,t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",className:"dql-hover",onClick:l,disabled:i||!v,style:Mt(s,v&&!i),children:[i?t.jsx(Se,{size:13,style:{animation:"dql-agent-run-spin 0.8s linear infinite"}}):t.jsx(we,{size:13}),t.jsx("span",{children:i?"Building draft…":`Build draft (${u} tile${u===1?"":"s"})`})]}),t.jsx("span",{style:{fontSize:11,color:s.textMuted},children:v?p>0?`${p} semantic tile${p===1?"":"s"} will compile against the governed semantic layer and still require result review.`:m>0?`${m} AI-generated tile${m===1?"":"s"} will stay review-required until certified.`:"No App files are written until you confirm this brief.":e.intent.target==="personal"?"Select a certified, semantic, or explicitly accepted exploratory tile.":"Select at least one certified block or governed semantic tile."})]})]})}function vt({tile:e,t:s,checked:n,onToggle:o,compact:l}){var u,m;const[i,r]=W.useState(!1),z=e.certification==="certified",j=e.certification==="reviewed_semantic",b=!!(e.sql||e.answer||e.preview&&e.preview.rows.length>0);return t.jsxs("div",{style:ge(s),children:[t.jsx("input",{type:"checkbox",checked:n,onChange:o,"aria-label":`Include ${e.title}`,style:{marginTop:2,accentColor:s.accent,cursor:"pointer",flexShrink:0}}),t.jsxs("div",{style:{minWidth:0,flex:1},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12.5,fontWeight:750,color:s.textPrimary},children:e.title}),z?t.jsxs("span",{style:J(s.success),children:[t.jsx(Me,{size:10})," certified"]}):j?t.jsxs("span",{style:J(s.accent),children:[t.jsx(le,{size:10})," governed semantic · review required"]}):t.jsxs("span",{style:J(s.warning),children:[((u=e.repair)==null?void 0:u.status)==="repaired"?t.jsx(ke,{size:10}):t.jsx(le,{size:10}),((m=e.repair)==null?void 0:m.status)==="repaired"?"auto-repaired · needs review":"AI-generated · needs review"]}),t.jsx("span",{style:{fontSize:10,color:s.textMuted},children:e.viz})]}),e.description&&!l?t.jsx("div",{style:{fontSize:11.5,color:s.textSecondary,marginTop:2,lineHeight:1.4},children:e.description}):null,e.question&&e.question!==e.title?t.jsxs("div",{style:{fontSize:11,color:s.textMuted,marginTop:2},children:["Answers: ",e.question]}):null,l?null:t.jsxs("div",{style:{fontSize:10.5,color:e.preflight.status==="passed"?s.success:e.preflight.status==="blocked"?s.error:s.textMuted,marginTop:2},children:["Preflight: ",e.preflight.status.replace("_"," ")," · ",e.preflight.message]}),e.repair?t.jsxs("div",{style:{fontSize:10.5,color:e.repair.status==="repaired"?s.warning:s.error,marginTop:3,lineHeight:1.4},children:["Repair evidence: ",e.repair.message]}):null,b?t.jsxs("button",{type:"button",onClick:()=>r(p=>!p),style:{border:"none",background:"transparent",color:s.accent,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:3,fontSize:10.5,fontWeight:700,padding:0,marginTop:4,fontFamily:s.font},children:[i?t.jsx($e,{size:11}):t.jsx(Ae,{size:11}),t.jsx(_e,{size:11})," ",i?"Hide details":"Show SQL & preview"]}):null,i&&e.answer?t.jsx("div",{style:{fontSize:11.5,color:s.textSecondary,marginTop:5,lineHeight:1.4},children:e.answer}):null,i&&e.sql?t.jsx("pre",{style:wt(s),children:e.sql}):null,i&&e.preview&&e.preview.rows.length>0?t.jsx(jt,{preview:e.preview,t:s}):null]})]})}function jt({preview:e,t:s}){const n=e.columns.slice(0,5),o=e.rows.slice(0,5);return t.jsxs("div",{style:{marginTop:5,overflow:"auto",border:`1px solid ${s.headerBorder}`,borderRadius:6},children:[t.jsxs("table",{style:{borderCollapse:"collapse",fontSize:10.5,fontFamily:s.fontMono,width:"100%"},children:[t.jsx("thead",{children:t.jsx("tr",{children:n.map(l=>t.jsx("th",{style:{textAlign:"left",padding:"3px 8px",color:s.textMuted,borderBottom:`1px solid ${s.headerBorder}`,fontWeight:700,whiteSpace:"nowrap"},children:l},l))})}),t.jsx("tbody",{children:o.map((l,i)=>t.jsx("tr",{children:n.map(r=>t.jsx("td",{style:{padding:"3px 8px",color:s.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:160},children:St(l[r])},r))},i))})]}),typeof e.rowCount=="number"&&e.rowCount>o.length?t.jsxs("div",{style:{fontSize:10,color:s.textMuted,padding:"3px 8px"},children:[e.rowCount," rows total"]}):null]})}function St(e){return e==null?"":typeof e=="number"?Number.isInteger(e)?String(e):e.toFixed(2):String(e)}function ge(e){return{display:"flex",gap:9,alignItems:"flex-start",border:`1px solid ${e.cellBorder}`,background:e.cellBg,borderRadius:8,padding:"9px 11px"}}function J(e){return{display:"inline-flex",alignItems:"center",gap:3,border:`1px solid ${e}55`,color:e,background:`${e}12`,borderRadius:999,padding:"1px 7px",fontSize:9.5,fontWeight:800}}function wt(e){return{margin:"5px 0 0",maxHeight:140,overflow:"auto",border:`1px solid ${e.headerBorder}`,background:e.editorBg,borderRadius:6,padding:8,fontSize:10.5,fontFamily:e.fontMono,color:e.textSecondary,lineHeight:1.45,whiteSpace:"pre-wrap"}}function Mt(e,s){return{display:"inline-flex",alignItems:"center",gap:6,border:"none",borderRadius:8,padding:"8px 14px",fontSize:12.5,fontWeight:800,fontFamily:e.font,cursor:s?"pointer":"default",background:s?e.accent:`${e.accent}55`,color:"#fff"}}function It(e){const s=`dql.agent.threadId.${e}`,[n,o]=W.useState(()=>ue(s));W.useEffect(()=>{o(ue(s))},[s]);const l=W.useCallback(r=>{o(r);try{window.localStorage.setItem(s,r)}catch{}},[s]),i=W.useCallback(()=>{o(void 0);try{window.localStorage.removeItem(s)}catch{}},[s]);return{threadId:n,onThreadIdChange:l,resetThreadId:i}}function ue(e){try{return window.localStorage.getItem(e)??void 0}catch{return}}export{Nt as A,_t as C,Fe as F,kt as S,C as T,st as a,Tt as b,zt as c,_e as d,Ft as e,oe as f,Be as i,bt as r,It as u};
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
8
8
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
9
9
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&family=Kalam:wght@400;700&family=Caveat:wght@400;600;700&display=swap" rel="stylesheet" />
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-1mIC_XX4.js"></script>
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/react-CRB3T2We.js">
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/index-DKu4CZt3.css">
|
|
13
13
|
</head>
|
|
@@ -10,9 +10,10 @@ type SimpleProviderId = Extract<ProviderId, 'anthropic' | 'openai' | 'gemini' |
|
|
|
10
10
|
declare function createCertifiedFitConfirmation(provider: AgentProvider, signal?: AbortSignal): CertifiedFitConfirmation;
|
|
11
11
|
/**
|
|
12
12
|
* Decide whether the answer path needs a live warehouse-schema read up front.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Generated SQL must verify retrieved relation columns against the selected
|
|
14
|
+
* execution target: dbt/catalog metadata can legitimately be ahead of (or
|
|
15
|
+
* behind) the deployed warehouse. The runtime performs a bounded point lookup,
|
|
16
|
+
* not a broad warehouse scan, and falls back to the catalog if access is denied.
|
|
16
17
|
*/
|
|
17
18
|
declare function shouldLoadSchemaContext(contextPack: LocalContextPack | undefined, hasSemanticLayer: boolean): boolean;
|
|
18
19
|
declare function shouldSearchProjectFiles(contextPack: LocalContextPack | undefined): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dql-agent-provider.d.ts","sourceRoot":"","sources":["../../../src/llm/providers/dql-agent-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAgBL,KAAK,WAAW,EAEhB,KAAK,wBAAwB,EAE7B,KAAK,oBAAoB,EAGzB,KAAK,aAAa,EAElB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAGtB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAA4B,UAAU,EAAE,MAAM,aAAa,CAAC;AACtG,OAAO,EAAE,oBAAoB,EAAkC,MAAM,yBAAyB,CAAC;AAS/F;;;;GAIG;AACH,KAAK,gBAAgB,GACjB,OAAO,CAAC,UAAU,EAAE,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,eAAe,CAAC,GACnF,aAAa,GACb,OAAO,CAAC;AAwEZ,iBAAS,8BAA8B,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,wBAAwB,CAmC/G;AAED
|
|
1
|
+
{"version":3,"file":"dql-agent-provider.d.ts","sourceRoot":"","sources":["../../../src/llm/providers/dql-agent-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAgBL,KAAK,WAAW,EAEhB,KAAK,wBAAwB,EAE7B,KAAK,oBAAoB,EAGzB,KAAK,aAAa,EAElB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAGtB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAA4B,UAAU,EAAE,MAAM,aAAa,CAAC;AACtG,OAAO,EAAE,oBAAoB,EAAkC,MAAM,yBAAyB,CAAC;AAS/F;;;;GAIG;AACH,KAAK,gBAAgB,GACjB,OAAO,CAAC,UAAU,EAAE,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,eAAe,CAAC,GACnF,aAAa,GACb,OAAO,CAAC;AAwEZ,iBAAS,8BAA8B,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,wBAAwB,CAmC/G;AAED;;;;;;GAMG;AACH,iBAAS,uBAAuB,CAC9B,WAAW,EAAE,gBAAgB,GAAG,SAAS,EACzC,gBAAgB,EAAE,OAAO,GACxB,OAAO,CAmBT;AAED,iBAAS,wBAAwB,CAAC,WAAW,EAAE,gBAAgB,GAAG,SAAS,GAAG,OAAO,CAYpF;AAED,iBAAS,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAarE;AAqBD,iBAAS,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAkBhI;AAqDD,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,gBAAgB,GAAG,WAAW,CAgQ9E;AAmBD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAmBrE;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,oBAAoB,GAAG,MAAM,CAGjG;AA6KD,iBAAS,oBAAoB,CAAC,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAkBtG;AAwBD;;;;;GAKG;AACH,iBAAS,oBAAoB,CAC3B,QAAQ,EAAE,oBAAoB,GAAG,SAAS,EAC1C,QAAQ,EAAE,oBAAoB,GAAG,SAAS,GACzC,oBAAoB,GAAG,SAAS,CAYlC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC/C,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,oBAAoB,GAAG,SAAS,CAKlC;AA8HD,iBAAS,+BAA+B,CAAC,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAEjH;AAuiBD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;CAapB,CAAC;AAwBF;;;;;;;;;;;;GAYG;AACH,iBAAS,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,GAAE,MAAM,EAAO,GAAG,OAAO,CAiBjF;AA6ED,iBAAS,oBAAoB,CAAC,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG,MAAM,GAAG,SAAS,CAKjF"}
|
|
@@ -110,9 +110,10 @@ function createCertifiedFitConfirmation(provider, signal) {
|
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
112
|
* Decide whether the answer path needs a live warehouse-schema read up front.
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
113
|
+
* Generated SQL must verify retrieved relation columns against the selected
|
|
114
|
+
* execution target: dbt/catalog metadata can legitimately be ahead of (or
|
|
115
|
+
* behind) the deployed warehouse. The runtime performs a bounded point lookup,
|
|
116
|
+
* not a broad warehouse scan, and falls back to the catalog if access is denied.
|
|
116
117
|
*/
|
|
117
118
|
function shouldLoadSchemaContext(contextPack, hasSemanticLayer) {
|
|
118
119
|
if (!contextPack)
|
|
@@ -122,14 +123,18 @@ function shouldLoadSchemaContext(contextPack, hasSemanticLayer) {
|
|
|
122
123
|
return false;
|
|
123
124
|
if (contextPack.questionPlan.requestedShape.filters.length > 0)
|
|
124
125
|
return true;
|
|
126
|
+
// Relations are useful semantic context, but their physical columns still
|
|
127
|
+
// need verification on the active DuckDB, Snowflake, or other target before
|
|
128
|
+
// generated SQL is executed.
|
|
129
|
+
if (contextPack.allowedSqlContext.relations.length > 0)
|
|
130
|
+
return true;
|
|
125
131
|
const hasSemanticCandidates = hasSemanticLayer && contextPack.objects.some((object) => object.objectType === 'metric'
|
|
126
132
|
|| object.objectType === 'dimension'
|
|
127
133
|
|| object.objectType === 'measure'
|
|
128
134
|
|| object.objectType === 'semantic_model');
|
|
129
135
|
if (hasSemanticCandidates)
|
|
130
136
|
return false;
|
|
131
|
-
return contextPack.allowedSqlContext.
|
|
132
|
-
&& contextPack.allowedSqlContext.sourceBlockSql.length === 0;
|
|
137
|
+
return contextPack.allowedSqlContext.sourceBlockSql.length === 0;
|
|
133
138
|
}
|
|
134
139
|
function shouldSearchProjectFiles(contextPack) {
|
|
135
140
|
if (!contextPack)
|
|
@@ -371,11 +376,9 @@ export function createDqlAgentProviderRunner(id) {
|
|
|
371
376
|
renderExtraContext(req, followUp),
|
|
372
377
|
renderProjectSourceSearch(earlySourceSearch),
|
|
373
378
|
].filter((value) => Boolean(value)).join('\n\n') || undefined;
|
|
374
|
-
//
|
|
375
|
-
//
|
|
376
|
-
//
|
|
377
|
-
// usable relation). This also passes the prepared pack so the runtime
|
|
378
|
-
// never builds a second metadata context pack for the same question.
|
|
379
|
+
// Verify retrieved relation columns against the active execution
|
|
380
|
+
// target before generated SQL runs. The runtime limits this to a few
|
|
381
|
+
// named relations and reuses this prepared context pack.
|
|
379
382
|
const schemaStartedAt = Date.now();
|
|
380
383
|
if (req.getSchemaContext && shouldLoadSchemaContext(contextPack, Boolean(semanticLayer))) {
|
|
381
384
|
emit({ kind: 'thinking', text: 'Inspecting the runtime schema needed to ground this answer.' });
|