@duckcodeailabs/dql-cli 1.12.9 → 1.12.11

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.
Files changed (72) hide show
  1. package/dist/assets/dql-notebook/assets/{AgentAnswerCard-DbI0CAsX.js → AgentAnswerCard-CpL2kDCV.js} +1 -1
  2. package/dist/assets/dql-notebook/assets/{AgentLogPage-BbMhuJps.js → AgentLogPage-hzHqpD3-.js} +1 -1
  3. package/dist/assets/dql-notebook/assets/{AiBuildDialog-DNgkam6H.js → AiBuildDialog-BQRWoxp9.js} +1 -1
  4. package/dist/assets/dql-notebook/assets/AiBuildResult-D9t_4sQl.js +33 -0
  5. package/dist/assets/dql-notebook/assets/{AiSidePanel-D-EhCOEd.js → AiSidePanel-BCQB9rVF.js} +1 -1
  6. package/dist/assets/dql-notebook/assets/{AnalyticsHome-BTjkolBn.js → AnalyticsHome-Ba4Ve_Gd.js} +1 -1
  7. package/dist/assets/dql-notebook/assets/AppsView-CdAT9BOq.js +4466 -0
  8. package/dist/assets/dql-notebook/assets/{BlockStudio-DTFHMR3y.js → BlockStudio-Brg4fwn5.js} +13 -13
  9. package/dist/assets/dql-notebook/assets/{BusinessArtifactView-DGiHB7OS.js → BusinessArtifactView-CnTbFVGT.js} +1 -1
  10. package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-CQe2FUZq.js +22 -0
  11. package/dist/assets/dql-notebook/assets/{GitPage-BWzPKyws.js → GitPage-DHyDBChc.js} +1 -1
  12. package/dist/assets/dql-notebook/assets/{GlobalAiRail-CGvBUci2.js → GlobalAiRail-Cys4n_rq.js} +1 -1
  13. package/dist/assets/dql-notebook/assets/GovernedContextPage-DyKoDSZ2.js +7 -0
  14. package/dist/assets/dql-notebook/assets/{HelpDocsPage-C7IX_7xh.js → HelpDocsPage-CL0vbSER.js} +3 -3
  15. package/dist/assets/dql-notebook/assets/{HomePage-e0CObjOb.js → HomePage-DzAucwBW.js} +9 -4
  16. package/dist/assets/dql-notebook/assets/{LineageDAG-DV6T_0ha.js → LineageDAG-QHqd_AM5.js} +1 -1
  17. package/dist/assets/dql-notebook/assets/{LineageDetailView-ZVJiCqua.js → LineageDetailView-DdVH-nz6.js} +1 -1
  18. package/dist/assets/dql-notebook/assets/{LineageDrawer-DQdzGIoL.js → LineageDrawer-BvrVZNKY.js} +1 -1
  19. package/dist/assets/dql-notebook/assets/LineagePathBreadcrumb-CSut-zvm.js +14 -0
  20. package/dist/assets/dql-notebook/assets/{MiniLineageGraph-BlJYiAY0.js → MiniLineageGraph-zg_1wW3M.js} +1 -1
  21. package/dist/assets/dql-notebook/assets/NewBlockModal-9cDletl-.js +1 -0
  22. package/dist/assets/dql-notebook/assets/NewNotebookModal-V6de8L4d.js +46 -0
  23. package/dist/assets/dql-notebook/assets/NotebookEditor-EZ0pfWVs.js +200 -0
  24. package/dist/assets/dql-notebook/assets/{ReadinessPage-m8jlEKzQ.js → ReadinessPage-BaGvjyfd.js} +1 -1
  25. package/dist/assets/dql-notebook/assets/{SetupOnboarding-ClldPV4C.js → SetupOnboarding-Bg-MjbC9.js} +2 -2
  26. package/dist/assets/dql-notebook/assets/{TrustBadge-C0FyL1ZO.js → TrustBadge-DGuHB8kP.js} +1 -1
  27. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-BlWAVEwO.js +83 -0
  28. package/dist/assets/dql-notebook/assets/{answer-to-notebook-CgVDBH0o.js → answer-to-notebook-BDzY4MuQ.js} +1 -1
  29. package/dist/assets/dql-notebook/assets/{arrow-left-XTRkwgdW.js → arrow-left-IjlnAihE.js} +1 -1
  30. package/dist/assets/dql-notebook/assets/{arrow-right-BUYb7B8y.js → arrow-right-BI4cXgOY.js} +2 -2
  31. package/dist/assets/dql-notebook/assets/{book-open-text-CQHKAXcN.js → book-open-text-i6xhxu_I.js} +1 -1
  32. package/dist/assets/dql-notebook/assets/{bot-D9ODKCwi.js → bot-C6DE7Q6m.js} +1 -1
  33. package/dist/assets/dql-notebook/assets/{chevron-up-BR57nCns.js → chevron-up-DSEILnDs.js} +2 -2
  34. package/dist/assets/dql-notebook/assets/{circle-x-B3MKf4hs.js → circle-x-BoAorVSm.js} +1 -1
  35. package/dist/assets/dql-notebook/assets/{codemirror-1_I9gm6Z.js → codemirror-DXt7RW72.js} +1 -1
  36. package/dist/assets/dql-notebook/assets/{dagre.esm-BWViOEog.js → dagre.esm-CycymVj6.js} +1 -1
  37. package/dist/assets/dql-notebook/assets/{external-link-D2rxGhQ_.js → external-link-ZwE5iHsX.js} +1 -1
  38. package/dist/assets/dql-notebook/assets/{grip-vertical-Bzs7bIWP.js → grip-vertical-Dnp2st8l.js} +1 -1
  39. package/dist/assets/dql-notebook/assets/index-BTuliKhK.js +634 -0
  40. package/dist/assets/dql-notebook/assets/{link-2-D6nW0_qQ.js → link-2-CTKe6Snr.js} +2 -2
  41. package/dist/assets/dql-notebook/assets/{list-tree-MH5kYamM.js → list-tree-Ced8e_S1.js} +1 -1
  42. package/dist/assets/dql-notebook/assets/{maximize-2-C3bEmsdA.js → maximize-2-Cojc6867.js} +1 -1
  43. package/dist/assets/dql-notebook/assets/{minimize-2-cji4jKmJ.js → minimize-2-CBIAE0XH.js} +1 -1
  44. package/dist/assets/dql-notebook/assets/{panel-right-open-T-_o8FS9.js → panel-right-open-po3bWSeL.js} +2 -2
  45. package/dist/assets/dql-notebook/assets/{pencil-BzJ_vZuL.js → pencil-Cb45c6WU.js} +2 -2
  46. package/dist/assets/dql-notebook/assets/{rotate-ccw-CqSfrg2J.js → rotate-ccw-B9v1LTJ0.js} +2 -2
  47. package/dist/assets/dql-notebook/assets/{semantic-fields-BXNCrm72.js → semantic-fields-B6ii0an0.js} +1 -1
  48. package/dist/assets/dql-notebook/assets/{star-C22MG8pV.js → star-CO4tfaDq.js} +2 -2
  49. package/dist/assets/dql-notebook/assets/{triangle-alert-BtoT0VL-.js → triangle-alert-BSdIu2El.js} +1 -1
  50. package/dist/assets/dql-notebook/assets/{usePersistedAgentThreadId-BL9P0gFB.js → usePersistedAgentThreadId-CkVFrrjk.js} +2 -2
  51. package/dist/assets/dql-notebook/assets/{user-round-CpifcAyh.js → user-round-BfrV8U-W.js} +3 -3
  52. package/dist/assets/dql-notebook/assets/{wand-sparkles-BiOywrQh.js → wand-sparkles-BgTxZNBc.js} +1 -1
  53. package/dist/assets/dql-notebook/assets/{workflow-DDvVMZ2B.js → workflow--2ycp0yy.js} +2 -2
  54. package/dist/assets/dql-notebook/assets/{wrench-CoKg2kyO.js → wrench-LMCrpa9_.js} +1 -1
  55. package/dist/assets/dql-notebook/assets/{x-CCmr0LQ8.js → x-CeNgQwGm.js} +2 -2
  56. package/dist/assets/dql-notebook/index.html +1 -1
  57. package/dist/local-runtime.d.ts +90 -2
  58. package/dist/local-runtime.d.ts.map +1 -1
  59. package/dist/local-runtime.js +1005 -152
  60. package/dist/local-runtime.js.map +1 -1
  61. package/dist/package.json +10 -10
  62. package/package.json +10 -10
  63. package/dist/assets/dql-notebook/assets/AiBuildResult-BuTao779.js +0 -33
  64. package/dist/assets/dql-notebook/assets/AppsView-B3jlWoNm.js +0 -4466
  65. package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-D-fv_dS2.js +0 -22
  66. package/dist/assets/dql-notebook/assets/GovernedContextPage-CxkrtqyP.js +0 -7
  67. package/dist/assets/dql-notebook/assets/LineagePathBreadcrumb-6gFsnWlN.js +0 -14
  68. package/dist/assets/dql-notebook/assets/NewBlockModal-DaxBAFLu.js +0 -1
  69. package/dist/assets/dql-notebook/assets/NewNotebookModal-B7GPLsYc.js +0 -46
  70. package/dist/assets/dql-notebook/assets/NotebookEditor-RuxFQnQC.js +0 -202
  71. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-Bd1qmRFx.js +0 -83
  72. package/dist/assets/dql-notebook/assets/index-CDpukm0G.js +0 -644
@@ -1,6 +1,6 @@
1
- import{g as e}from"./index-CDpukm0G.js";/**
1
+ import{c as e}from"./index-BTuliKhK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const o=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],t=e("link-2",o);export{t as L};
6
+ */const o=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],n=e("link-2",o);export{n as L};
@@ -1,4 +1,4 @@
1
- import{g as e}from"./index-CDpukm0G.js";/**
1
+ import{c as e}from"./index-BTuliKhK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{g as t}from"./index-CDpukm0G.js";/**
1
+ import{c as t}from"./index-BTuliKhK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{g as e}from"./index-CDpukm0G.js";/**
1
+ import{c as e}from"./index-BTuliKhK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,6 +1,6 @@
1
- import{g as e}from"./index-CDpukm0G.js";/**
1
+ import{c as e}from"./index-BTuliKhK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const t=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],n=e("panel-right-open",t);export{n as P};
6
+ */const t=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],c=e("panel-right-open",t);export{c as P};
@@ -1,6 +1,6 @@
1
- import{g as a}from"./index-CDpukm0G.js";/**
1
+ import{c as a}from"./index-BTuliKhK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const e=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],c=a("pencil",e);export{c as P};
6
+ */const c=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],o=a("pencil",c);export{o as P};
@@ -1,6 +1,6 @@
1
- import{g as t}from"./index-CDpukm0G.js";/**
1
+ import{c as t}from"./index-BTuliKhK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const e=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],a=t("rotate-ccw",e);export{a as R};
6
+ */const c=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],o=t("rotate-ccw",c);export{o as R};
@@ -1,3 +1,3 @@
1
- import{r as x,j as l,t as k,R as y}from"./index-CDpukm0G.js";import{c as S,i as j}from"./usePersistedAgentThreadId-BL9P0gFB.js";function w(o,t){const n=o.split(`
1
+ import{r as x,j as l,t as k,R as y}from"./index-BTuliKhK.js";import{c as S,i as j}from"./usePersistedAgentThreadId-CkVFrrjk.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};
@@ -1,6 +1,6 @@
1
- import{g as a}from"./index-CDpukm0G.js";/**
1
+ import{c as a}from"./index-BTuliKhK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const o=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],l=a("star",o);export{l as S};
6
+ */const o=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],c=a("star",o);export{c as S};
@@ -1,4 +1,4 @@
1
- import{g as e}from"./index-CDpukm0G.js";/**
1
+ import{c as e}from"./index-BTuliKhK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{g as C,r as W,j as n,t as R,aJ as be,L as ve,e as ge,h as je,S as se,b as Se,d as we}from"./index-CDpukm0G.js";/**
1
+ import{c as C,r as W,j as n,t as R,aL as be,L as ve,f as je,h as ge,S as se,d as Se,e as we}from"./index-BTuliKhK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -15,4 +15,4 @@ import{g as C,r as W,j as n,t as R,aJ as be,L as ve,e as ge,h as je,S as se,b as
15
15
  * See the LICENSE file in the root directory of this source tree.
16
16
  */const ze=[["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"}]],Mt=C("send",ze),_e=/date|time|_at$|_on$|timestamp/i;function Te(t){return typeof t=="number"||typeof t=="string"&&t!==""&&!isNaN(Number(t))}function Fe(t,s){if(_e.test(t))return"date";const e=s.slice(0,40).map(l=>l[t]).filter(l=>l!=null);return e.length===0?"string":e.every(l=>typeof l=="boolean")?"bool":e.every(l=>typeof l=="object")?"json":e.filter(Te).length/e.length>.8?"numeric":"string"}function $t(t){return t==="numeric"?"measure":t==="date"?"temporal":"dimension"}const le=/(?:^|_)(?:revenue|sales|spend|amount|price|cost|profit|income|expense|balance|budget|bookings|arr|mrr|gmv|fee|fees|charge|charges|tax|value)(?:_|$)/i,Ie=/(?:^|_)(?:percent|percentage|pct|ratio|share|conversion|churn|retention|utilization)(?:_|$)|(?:^|_)margin(?:_|$)/i,Ne=/(?:^|_)(?:count|orders?|customers?|accounts?|users?|products?|items?|units?|quantity|rank|position|days?|months?|years?|distinct)(?:_|$)/i,re=/(?:^|_)(?:average|avg|mean)(?:_|$)/i,We=/(?:^|_)(?:year|yr)$/i,Le=/(?:^|_)(?:month|month_num|month_number|month_of_year)$/i,Be=/(?:^|_)(?:date|day|month|quarter|year|time|timestamp)(?:_|$)|_(?:at|on)$/i,Ee=/^(\d{4})-(\d{2})$/,ee=/^(\d{4})-(\d{2})-(\d{2})$/,Pe=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?$/;function te(t){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"&&t.trim()!==""&&Number.isFinite(Number(t)))return Number(t)}function Re(t){if(t==="currency"||t==="percent"||t==="number")return t;if(t==="duration")return"number"}function He(t,s=[],e){const o=Re(e);if(o)return o;if(Le.test(t))return"month";if(We.test(t))return"year";if(Be.test(t))return"date";if(re.test(t)&&le.test(t))return"currency";if(Ie.test(t))return"percent";if(re.test(t))return"number";if(Ne.test(t))return"integer";if(le.test(t))return"currency";const l=s.filter(r=>r!=null&&r!=="");return l.length===0?"text":l.every(r=>typeof r=="boolean")?"boolean":l.every(r=>te(r)!==void 0)?"number":l.every(r=>typeof r=="object")?"json":"text"}function De(t,s=!1){return t?{notation:"compact",maximumFractionDigits:1}:s?{maximumFractionDigits:0}:{maximumFractionDigits:2}}function ne(t,s,e=[],o={}){if(s==null)return"";const l=He(t,e,o.format),r=te(s);if(l==="year"){const i=typeof s=="string"&&ee.test(s)?Number(s.slice(0,4)):r;if(i!==void 0&&Number.isInteger(i))return new Intl.NumberFormat("en-US",{useGrouping:!1,maximumFractionDigits:0}).format(i)}if(l==="month"){const i=Ue(s);if(i)return i}if(l==="date"&&typeof s=="string"){const i=Ve(s);if(i)return i}if(r!==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(r);if(l==="percent"){const i=Math.abs(r)<=1?r:r/100;return new Intl.NumberFormat("en-US",{style:"percent",maximumFractionDigits:2}).format(i)}return new Intl.NumberFormat("en-US",De(!!o.compact,l==="integer")).format(r)}return l==="boolean"?s?"Yes":"No":l==="json"||typeof s=="object"?JSON.stringify(s):String(s)}function Oe(t,s,e){return ne(t,s,[s],{compact:!0,format:e})}function Ue(t){const s=te(t);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 t!="string")return;const e=Ee.exec(t),o=ee.exec(t),l=e??o;if(!l)return;const r=Number(l[1]),i=Number(l[2]);if(!(i<1||i>12))return new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",timeZone:"UTC"}).format(new Date(Date.UTC(r,i-1,1)))}function Ve(t){const s=ee.exec(t);if(s)return new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",timeZone:"UTC"}).format(new Date(Date.UTC(Number(s[1]),Number(s[2])-1,Number(s[3]))));if(!Pe.test(t))return;const e=new Date(t);if(Number.isNaN(e.getTime()))return;const o=e.getUTCHours()===0&&e.getUTCMinutes()===0&&e.getUTCSeconds()===0;return new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",...o?{}:{hour:"numeric",minute:"2-digit"},timeZone:"UTC"}).format(e)}const Ye=[25,50,100,500];function K(t){return typeof t=="number"?!0:typeof t=="string"?!isNaN(Number(t))&&t.trim()!=="":!1}function Ge(t){switch(t){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 Ze(t){return t==null?"":typeof t=="object"?JSON.stringify(t):String(t)}function qe(t,s){return t==null?1:s==null?-1:K(t)&&K(s)?Number(t)-Number(s):String(t).localeCompare(String(s))}function Xe(t,s){const e=i=>i.includes(",")||i.includes('"')||i.includes(`
17
17
  `)?`"${i.replace(/"/g,'""')}"`:i,o=t.columns.map(e).join(","),l=t.rows.map(i=>t.columns.map(k=>e(Ze(i[k]))).join(",")),r=[o,...l].join(`
18
- `);ue(r,"export.csv","text/csv")}function Ke(t,s){const e=JSON.stringify(t.rows,null,2);ue(e,"export.json","application/json")}function ue(t,s,e){const o=new Blob([t],{type:e}),l=URL.createObjectURL(o),r=document.createElement("a");r.href=l,r.download=s,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(l)}function Je({dir:t,color:s}){return t?n.jsx("svg",{width:"8",height:"10",viewBox:"0 0 8 10",fill:s,style:{marginLeft:3,flexShrink:0},children:t==="asc"?n.jsx("path",{d:"M4 0L7 4H1L4 0Z"}):n.jsx("path",{d:"M4 10L1 6H7L4 10Z"})}):n.jsxs("svg",{width:"8",height:"10",viewBox:"0 0 8 10",fill:s,opacity:.3,style:{marginLeft:3,flexShrink:0},children:[n.jsx("path",{d:"M4 0L7 3.5H1L4 0Z"}),n.jsx("path",{d:"M4 10L1 6.5H7L4 10Z"})]})}function J({result:t,themeMode:s}){const e=R[s],[o,l]=W.useState(null),[r,i]=W.useState(null),[k,A]=W.useState(null),[y,g]=W.useState(""),[b,v]=W.useState(50),[w,p]=W.useState(0),u=W.useCallback(a=>{r===a?k==="asc"?A("desc"):k==="desc"?(i(null),A(null)):A("asc"):(i(a),A("asc")),p(0)},[r,k]),S=W.useMemo(()=>{if(!y.trim())return t.rows;const a=y.toLowerCase();return t.rows.filter(x=>t.columns.some($=>{const f=x[$];return f==null?!1:String(f).toLowerCase().includes(a)}))},[t.rows,t.columns,y]),m=W.useMemo(()=>{if(!r||!k)return S;const a=[...S];return a.sort((x,$)=>{const f=qe(x[r],$[r]);return k==="desc"?-f:f}),a},[S,r,k]),d=W.useMemo(()=>{const a=new Map;for(const x of t.columns)a.set(x,Fe(x,t.rows));return a},[t.columns,t.rows]),c=W.useMemo(()=>new Map(t.columns.map(a=>[a,t.rows.map(x=>x[a])])),[t.columns,t.rows]),[z,F]=W.useState(!1),T=Math.max(1,Math.ceil(m.length/b)),j=Math.min(w,T-1),_=m.slice(j*b,(j+1)*b);return t.columns.length===0?n.jsx("div",{style:{padding:"12px 16px",color:e.textMuted,fontSize:12,fontFamily:e.font,fontStyle:"italic"},children:"Query executed successfully. No columns to display."}):n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderBottom:`1px solid ${e.tableBorder}`,background:`${e.tableHeaderBg}60`,flexWrap:"wrap"},children:[n.jsxs("div",{style:{position:"relative",flex:"0 1 200px",minWidth:120},children:[n.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:e.textMuted,style:{position:"absolute",left:6,top:6},children:n.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"})}),n.jsx("input",{value:y,onChange:a=>{g(a.target.value),p(0)},placeholder:"Filter rows...",style:{width:"100%",background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:4,color:e.textPrimary,fontSize:11,fontFamily:e.font,padding:"3px 8px 3px 22px",outline:"none"}}),y&&n.jsx("button",{onClick:()=>g(""),style:{position:"absolute",right:4,top:3,background:"none",border:"none",color:e.textMuted,cursor:"pointer",fontSize:12,padding:"0 2px"},children:"×"})]}),n.jsxs("span",{style:{fontSize:10,color:e.textMuted,fontFamily:e.font},children:[y?`${m.length} of ${t.rows.length}`:`${t.rows.length}`," ",t.rows.length===1?"row":"rows"]}),n.jsx("div",{style:{flex:1}}),n.jsx(ie,{label:"CSV",onClick:()=>Xe(t),t:e}),n.jsx(ie,{label:"JSON",onClick:()=>Ke(t),t:e}),n.jsx("select",{value:b,onChange:a=>{v(Number(a.target.value)),p(0)},style:{background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:3,color:e.textSecondary,fontSize:10,fontFamily:e.font,padding:"2px 4px",outline:"none"},children:Ye.map(a=>n.jsxs("option",{value:a,children:[a," / page"]},a))}),T>1&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[n.jsx(Y,{disabled:j===0,onClick:()=>p(0),t:e,children:"«"}),n.jsx(Y,{disabled:j===0,onClick:()=>p(j-1),t:e,children:"‹"}),n.jsxs("span",{style:{fontSize:10,color:e.textSecondary,fontFamily:e.font,padding:"0 4px"},children:[j+1,"/",T]}),n.jsx(Y,{disabled:j>=T-1,onClick:()=>p(j+1),t:e,children:"›"}),n.jsx(Y,{disabled:j>=T-1,onClick:()=>p(T-1),t:e,children:"»"})]})]}),n.jsx("div",{style:{maxHeight:440,overflow:"auto",position:"relative"},onScroll:a=>F(a.target.scrollTop>0),children:n.jsxs("table",{style:{width:"100%",borderCollapse:"separate",borderSpacing:0,tableLayout:"auto",fontSize:12.5,fontFamily:e.fontMono},children:[n.jsx("thead",{children:n.jsx("tr",{children:t.columns.map(a=>{const x=d.get(a)??"string",$=x==="numeric";return n.jsx("th",{onClick:()=>u(a),style:{background:e.tableHeaderBg,color:e.textSecondary,fontWeight:600,fontSize:11,textAlign:$?"right":"left",padding:"8px 14px",borderBottom:`1px solid ${e.tableBorder}`,minWidth:80,maxWidth:320,whiteSpace:"nowrap",position:"sticky",top:0,zIndex:1,fontFamily:e.font,letterSpacing:"0.03em",overflow:"hidden",textOverflow:"ellipsis",cursor:"pointer",userSelect:"none",boxShadow:z?"0 2px 4px -2px rgba(0,0,0,0.18)":"none",transition:"background 0.1s, box-shadow 0.18s"},children:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,justifyContent:$?"flex-end":"flex-start"},children:[(()=>{const f=Ge(x);return n.jsx("span",{title:x,style:{fontSize:9,fontFamily:e.fontMono,fontWeight:700,color:f.color,background:`${f.color}15`,border:`1px solid ${f.color}40`,borderRadius:3,padding:"0 4px",minWidth:14,textAlign:"center",lineHeight:"14px",flexShrink:0},children:f.icon})})(),n.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:a}),n.jsx(Je,{dir:r===a?k:null,color:r===a?e.accent:e.textMuted})]})},a)})})}),n.jsx("tbody",{children:_.map((a,x)=>{const $=o===x,I=x%2===1?e.tableHeaderBg:"transparent";return n.jsx("tr",{onMouseEnter:()=>l(x),onMouseLeave:()=>l(null),style:{transition:"background 0.1s"},children:t.columns.map(L=>{const B=a[L],h=B==null,M=K(B);return n.jsx("td",{style:{padding:"7px 14px",borderBottom:`1px solid ${e.tableBorder}`,background:$?e.tableRowHover:I,color:h?e.textMuted:e.textPrimary,fontStyle:h?"italic":"normal",fontVariantNumeric:M?"tabular-nums":"normal",textAlign:M?"right":"left",whiteSpace:"nowrap",maxWidth:320,overflow:"hidden",textOverflow:"ellipsis",transition:"background 0.1s"},children:h?"—":ne(L,B,c.get(L)??[])},L)})},x)})})]})}),n.jsxs("div",{style:{padding:"5px 10px",color:e.textMuted,fontSize:10,fontFamily:e.font,borderTop:`1px solid ${e.tableBorder}`,background:`${e.tableHeaderBg}60`,display:"flex",alignItems:"center",gap:4},children:[T>1&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[n.jsx(Y,{disabled:j===0,onClick:()=>p(j-1),t:e,children:"‹"}),Qe(T,j).map((a,x)=>a==="…"?n.jsx("span",{style:{color:e.textMuted,fontSize:10,padding:"0 2px"},children:"…"},`gap-${x}`):n.jsx("button",{onClick:()=>p(a-1),style:{background:a-1===j?`${e.accent}20`:"transparent",border:"none",color:a-1===j?e.accent:e.textSecondary,fontSize:10,fontFamily:e.font,fontWeight:a-1===j?700:400,padding:"1px 6px",borderRadius:3,cursor:"pointer",minWidth:20},children:a},a)),n.jsx(Y,{disabled:j>=T-1,onClick:()=>p(j+1),t:e,children:"›"})]}),n.jsx("div",{style:{flex:1}}),n.jsxs("span",{style:{fontSize:10,color:e.textSecondary,fontFamily:e.font,marginLeft:6,whiteSpace:"nowrap"},children:[m.length.toLocaleString()," ",m.length===1?"row":"rows",y&&t.rows.length!==m.length&&` of ${t.rows.length.toLocaleString()}`]})]})]})}function Qe(t,s){if(t<=7)return Array.from({length:t},(l,r)=>r+1);const e=s+1,o=[1];e>3&&o.push("…");for(let l=Math.max(2,e-1);l<=Math.min(t-1,e+1);l++)o.push(l);return e<t-2&&o.push("…"),o.push(t),o}function ie({label:t,onClick:s,t:e}){const[o,l]=W.useState(!1);return n.jsxs("button",{onClick:s,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{background:o?e.btnHover:"transparent",border:`1px solid ${o?e.btnBorder:"transparent"}`,borderRadius:3,cursor:"pointer",color:o?e.textSecondary:e.textMuted,fontSize:10,fontFamily:e.font,fontWeight:600,padding:"2px 6px",transition:"all 0.15s",display:"flex",alignItems:"center",gap:3},children:[n.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 16 16",fill:"currentColor",children:[n.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"}),n.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"})]}),t]})}function Y({disabled:t,onClick:s,children:e,t:o}){return n.jsx("button",{disabled:t,onClick:s,style:{background:"transparent",border:"none",cursor:t?"default":"pointer",color:t?o.textMuted:o.textSecondary,fontSize:12,fontFamily:o.font,padding:"0 3px",opacity:t?.4:1,transition:"opacity 0.1s"},children:e})}const At=[{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"}],Ce=/date|time|at|day|month|year/i,pe=/^(label|name|category|status|type|group)$/i,me=/^(value|count|total|revenue|amount|sum|avg|price|quantity|sales)$/i;function U(t){return typeof t=="number"?!0:typeof t=="string"?t.trim()!==""&&!isNaN(Number(t)):!1}function et(t){return typeof t=="string"||typeof t=="number"}const tt=new Set(["bar","line","area","pie","donut","scatter","heatmap","funnel","waterfall","histogram","gauge","stacked-bar","grouped-bar","sankey","kpi","table"]);function nt(t,s){if(s!=null&&s.chart){const e=s.chart.toLowerCase().replace(/_/g,"-");if(tt.has(e))return e}return ot(t)}function ot(t){const{columns:s,rows:e}=t;if(s.length<2||e.length===0)return"table";const o=s[0],l=s[1],r=e.slice(0,5),i=r.every(b=>U(b[l])),k=r.every(b=>et(b[o]));if(Ce.test(o)&&i&&k)return"line";const A=s.find(b=>pe.test(b)),y=s.find(b=>me.test(b));return A&&y&&r.every(v=>U(v[y]))?"bar":r.every(b=>U(b[o]))&&i&&s.length>=2?"scatter":s.length===2&&k&&i?"bar":"table"}const Q={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 D(t){return Q[t??"default"]??Q.default}function E(t,s="value",e){return Oe(s,t,e)}function ae(t,s=8){if(/^\d{4}-\d{2}(-\d{2})?/.test(t)){const e=/^\d{4}-\d{2}$/.test(t),o=new Date(e?`${t}-01T00:00:00Z`:t);if(!isNaN(o.getTime()))return o.toLocaleDateString("en-US",e?{year:"numeric",month:"short",timeZone:"UTC"}:{month:"short",day:"numeric",timeZone:"UTC"})}return String(t).length>s?String(t).slice(0,s):String(t)}function G(t,s){const e=(s!=null&&s.x&&t.columns.includes(s.x)?s.x:void 0)??t.columns.find(l=>pe.test(l))??t.columns[0],o=(s!=null&&s.y&&t.columns.includes(s.y)?s.y:void 0)??t.columns.find(l=>me.test(l))??t.columns[1];return{labelCol:e,valueCol:o}}const V=20;function oe({result:t,themeMode:s,chartConfig:e}){const o=R[s],[l,r]=W.useState(null),{labelCol:i,valueCol:k}=G(t,e),A=(e==null?void 0:e.maxItems)??V,y=D(e==null?void 0:e.colorPalette),g=t.rows.slice(0,A).map(d=>({label:String(d[i]??""),value:Number(d[k]??0)})),b=t.rows.length>A,v=Math.max(...g.map(d=>d.value),1),w=28,p=120,u=6,S=12,m=g.length*(w+u)+S*2;return n.jsxs("div",{style:{padding:"8px 0"},children:[n.jsx("svg",{width:"100%",height:m,viewBox:`0 0 600 ${m}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:g.map((d,c)=>{const z=S+c*(w+u),F=600-p-84,T=Math.max(d.value/v*F,2),j=l===c,_=y[c%y.length];return n.jsxs("g",{onMouseEnter:()=>r(c),onMouseLeave:()=>r(null),style:{cursor:"default"},children:[n.jsx("text",{x:p-8,y:z+w/2+4,textAnchor:"end",fontSize:11,fontFamily:o.font,fill:o.textSecondary,children:d.label.length>16?d.label.slice(0,15)+"…":d.label}),n.jsx("rect",{x:p,y:z,width:T,height:w,rx:3,fill:_,opacity:j?1:.88,style:{transition:"opacity 0.15s"}}),n.jsx("text",{x:p+T+6,y:z+w/2+4,textAnchor:"start",fontSize:11,fontFamily:o.fontMono,fill:o.textMuted,children:E(d.value,k,e==null?void 0:e.format)})]},c)})}),b&&n.jsxs("div",{style:{fontSize:11,color:o.textMuted,fontFamily:o.font,fontStyle:"italic",padding:"4px 12px"},children:["Showing ",V," of ",t.rows.length," rows"]})]})}function st({result:t,themeMode:s,chartConfig:e}){const o=R[s],[l,r]=W.useState(null),i=D(e==null?void 0:e.colorPalette),k=e!=null&&e.x&&t.columns.includes(e.x)?e.x:t.columns[0],A=t.rows.slice(0,5),y=t.columns.filter(d=>d!==k&&A.some(c=>U(c[d])));if(y.length===0)return n.jsx(oe,{result:t,themeMode:s,chartConfig:e});const g=t.rows.slice(0,V).map(d=>String(d[k]??"")),b=Math.max(...t.rows.slice(0,V).flatMap(d=>y.map(c=>Math.abs(Number(d[c]??0)))),1),v=24,w=v/y.length,p=120,u=12,S=8,m=g.length*(v+S)+u*2;return n.jsxs("div",{style:{padding:"8px 0"},children:[n.jsx("div",{style:{display:"flex",gap:12,padding:"0 12px 6px",flexWrap:"wrap"},children:y.map((d,c)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[n.jsx("div",{style:{width:10,height:10,borderRadius:2,background:i[c%i.length]}}),n.jsx("span",{style:{fontSize:10,fontFamily:o.font,color:o.textSecondary},children:d})]},d))}),n.jsx("svg",{width:"100%",height:m,viewBox:`0 0 600 ${m}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:g.map((d,c)=>{const z=u+c*(v+S),F=t.rows[c];return n.jsxs("g",{children:[n.jsx("text",{x:p-8,y:z+v/2+4,textAnchor:"end",fontSize:11,fontFamily:o.font,fill:o.textSecondary,children:d.length>16?d.slice(0,15)+"…":d}),y.map((T,j)=>{const _=Number(F[T]??0),a=600-p-60,x=Math.max(Math.abs(_)/b*a,1),$=z+j*w,f=`${c}-${j}`;return n.jsxs("g",{onMouseEnter:()=>r(f),onMouseLeave:()=>r(null),children:[n.jsx("rect",{x:p,y:$,width:x,height:w-1,rx:2,fill:i[j%i.length],opacity:l===f?1:.85,style:{transition:"opacity 0.15s"}}),l===f&&n.jsx("text",{x:p+x+4,y:$+w/2+3,fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:E(_,T,e==null?void 0:e.format)})]},j)})]},c)})})]})}function lt({result:t,themeMode:s,chartConfig:e}){const o=R[s],[l,r]=W.useState(null),i=D(e==null?void 0:e.colorPalette),k=e!=null&&e.x&&t.columns.includes(e.x)?e.x:t.columns[0],A=t.rows.slice(0,5),y=t.columns.filter(d=>d!==k&&A.some(c=>U(c[d])));if(y.length===0)return n.jsx(oe,{result:t,themeMode:s,chartConfig:e});const g=t.rows.slice(0,V),b=g.map(d=>String(d[k]??"")),v=Math.max(...g.map(d=>y.reduce((c,z)=>c+Math.abs(Number(d[z]??0)),0)),1),w=28,p=120,u=12,S=6,m=b.length*(w+S)+u*2;return n.jsxs("div",{style:{padding:"8px 0"},children:[n.jsx("div",{style:{display:"flex",gap:12,padding:"0 12px 6px",flexWrap:"wrap"},children:y.map((d,c)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[n.jsx("div",{style:{width:10,height:10,borderRadius:2,background:i[c%i.length]}}),n.jsx("span",{style:{fontSize:10,fontFamily:o.font,color:o.textSecondary},children:d})]},d))}),n.jsx("svg",{width:"100%",height:m,viewBox:`0 0 600 ${m}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:b.map((d,c)=>{const z=u+c*(w+S),F=g[c],T=600-p-60;let j=p;return n.jsxs("g",{children:[n.jsx("text",{x:p-8,y:z+w/2+4,textAnchor:"end",fontSize:11,fontFamily:o.font,fill:o.textSecondary,children:d.length>16?d.slice(0,15)+"…":d}),y.map((_,a)=>{const x=Math.abs(Number(F[_]??0)),$=Math.max(x/v*T,0),f=j;j+=$;const I=`${c}-${a}`;return n.jsxs("g",{onMouseEnter:()=>r(I),onMouseLeave:()=>r(null),children:[n.jsx("rect",{x:f,y:z,width:$,height:w,rx:a===0?3:0,fill:i[a%i.length],opacity:l===I?1:.85,style:{transition:"opacity 0.15s"}}),l===I&&$>30&&n.jsx("text",{x:f+$/2,y:z+w/2+4,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:"#fff",fontWeight:600,children:E(x,_,e==null?void 0:e.format)})]},a)})]},c)})})]})}function ce({result:t,themeMode:s,showArea:e,chartConfig:o}){const l=R[s],[r,i]=W.useState(null),A=D(o==null?void 0:o.colorPalette)[0]??l.accent,{labelCol:y,valueCol:g}=G(t,o),b=t.rows.map(M=>({label:String(M[y]??""),value:Number(M[g]??0)}));if(b.length<2)return null;const v=560,w=212,p=56,u=16,S=16,m=48,d=v-p-u,c=w-S-m,z=Math.min(...b.map(M=>M.value)),T=Math.max(...b.map(M=>M.value))-z||1,j=d/(b.length-1),_=M=>p+M*j,a=M=>S+c-(M-z)/T*c,x=b.map((M,N)=>({x:_(N),y:a(M.value)})),$=x.reduce((M,N,P)=>{if(P===0)return`M ${N.x},${N.y}`;const H=x[P-1],O=H.x+(N.x-H.x)/2;return`${M} C ${O},${H.y} ${O},${N.y} ${N.x},${N.y}`},""),f=`${$} L ${x[x.length-1].x},${S+c} L ${p},${S+c} Z`,I=5,L=Array.from({length:I+1},(M,N)=>{const P=z+T*N/I;return{val:P,y:a(P)}}),B=Math.ceil(b.length/8),h=b.filter((M,N)=>N%B===0||N===b.length-1);return n.jsx("div",{style:{position:"relative",padding:"8px 0"},children:n.jsxs("svg",{width:"100%",height:w,viewBox:`0 0 ${v} ${w}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},onMouseLeave:()=>i(null),children:[L.map((M,N)=>n.jsxs("g",{children:[n.jsx("line",{x1:p,y1:M.y,x2:p+d,y2:M.y,stroke:l.tableBorder,strokeWidth:.5}),n.jsx("text",{x:p-6,y:M.y+4,textAnchor:"end",fontSize:10,fontFamily:l.fontMono,fill:l.textMuted,children:E(M.val,g,o==null?void 0:o.format)})]},N)),n.jsx("path",{d:f,fill:A,opacity:e?.3:.15}),n.jsx("path",{d:$,fill:"none",stroke:A,strokeWidth:2,strokeLinejoin:"round"}),x.map((M,N)=>n.jsx("circle",{cx:M.x,cy:M.y,r:3,fill:A,style:{cursor:"crosshair"},onMouseEnter:()=>i({x:M.x,y:M.y,label:b[N].label,value:b[N].value})},N)),h.map((M,N)=>{const P=b.indexOf(M);return n.jsx("text",{x:_(P),y:S+c+16,textAnchor:"middle",fontSize:10,fontFamily:l.font,fill:l.textMuted,children:ae(M.label)},N)}),n.jsx("line",{x1:p,y1:S,x2:p,y2:S+c,stroke:l.tableBorder,strokeWidth:1}),n.jsx("line",{x1:p,y1:S+c,x2:p+d,y2:S+c,stroke:l.tableBorder,strokeWidth:1}),n.jsx("text",{x:p+d/2,y:w-4,textAnchor:"middle",fontSize:10,fontWeight:600,fontFamily:l.font,fill:l.textMuted,letterSpacing:"0.04em",children:y}),n.jsx("text",{x:12,y:S+c/2,textAnchor:"middle",fontSize:10,fontWeight:600,fontFamily:l.font,fill:l.textMuted,letterSpacing:"0.04em",transform:`rotate(-90, 12, ${S+c/2})`,children:g}),r&&n.jsxs("g",{children:[n.jsx("rect",{x:r.x+8,y:r.y-20,width:90,height:32,rx:4,fill:l.cellBg,stroke:l.cellBorder,strokeWidth:1}),n.jsx("text",{x:r.x+13,y:r.y-8,fontSize:10,fontFamily:l.font,fill:l.textSecondary,children:ae(r.label,12)}),n.jsx("text",{x:r.x+13,y:r.y+6,fontSize:11,fontFamily:l.fontMono,fill:l.textPrimary,fontWeight:600,children:E(r.value,g,o==null?void 0:o.format)})]})]})})}function rt({result:t,themeMode:s,chartConfig:e}){const o=R[s],[l,r]=W.useState(null),i=D(e==null?void 0:e.colorPalette),k=e!=null&&e.x&&t.columns.includes(e.x)?e.x:t.columns[0],A=e!=null&&e.y&&t.columns.includes(e.y)?e.y:t.columns[1],y=e!=null&&e.color&&t.columns.includes(e.color)?e.color:void 0,g=t.rows.slice(0,200).map(f=>({x:Number(f[k]??0),y:Number(f[A]??0),color:y?String(f[y]??""):void 0})),b=560,v=300,w=52,p=16,u=16,S=36,m=b-w-p,d=v-u-S,c=Math.min(...g.map(f=>f.x)),z=Math.max(...g.map(f=>f.x)),F=Math.min(...g.map(f=>f.y)),T=Math.max(...g.map(f=>f.y)),j=z-c||1,_=T-F||1,a=f=>w+(f-c)/j*m,x=f=>u+d-(f-F)/_*d,$=y?[...new Set(g.map(f=>f.color))]:[];return n.jsxs("div",{style:{padding:"8px 0"},children:[y&&$.length>0&&n.jsx("div",{style:{display:"flex",gap:12,padding:"0 12px 6px",flexWrap:"wrap"},children:$.slice(0,12).map((f,I)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[n.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:i[I%i.length]}}),n.jsx("span",{style:{fontSize:10,fontFamily:o.font,color:o.textSecondary},children:f})]},f))}),n.jsxs("svg",{width:"100%",height:v,viewBox:`0 0 ${b} ${v}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:[Array.from({length:6},(f,I)=>{const L=F+_*I/5,B=x(L);return n.jsxs("g",{children:[n.jsx("line",{x1:w,y1:B,x2:w+m,y2:B,stroke:o.tableBorder,strokeWidth:.5}),n.jsx("text",{x:w-6,y:B+4,textAnchor:"end",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:E(L,A,e==null?void 0:e.format)})]},I)}),Array.from({length:6},(f,I)=>{const L=c+j*I/5,B=a(L);return n.jsx("text",{x:B,y:u+d+16,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:E(L,k)},I)}),n.jsx("line",{x1:w,y1:u,x2:w,y2:u+d,stroke:o.tableBorder,strokeWidth:1}),n.jsx("line",{x1:w,y1:u+d,x2:w+m,y2:u+d,stroke:o.tableBorder,strokeWidth:1}),n.jsx("text",{x:w+m/2,y:v-2,textAnchor:"middle",fontSize:10,fontFamily:o.font,fill:o.textMuted,children:k}),n.jsx("text",{x:10,y:u+d/2,textAnchor:"middle",fontSize:10,fontFamily:o.font,fill:o.textMuted,transform:`rotate(-90, 10, ${u+d/2})`,children:A}),g.map((f,I)=>{const L=y?$.indexOf(f.color):0;return n.jsx("circle",{cx:a(f.x),cy:x(f.y),r:l===I?5:3.5,fill:i[L%i.length],opacity:l===I?1:.7,style:{cursor:"crosshair",transition:"r 0.1s, opacity 0.1s"},onMouseEnter:()=>r(I),onMouseLeave:()=>r(null)},I)}),l!==null&&n.jsxs("g",{children:[n.jsx("rect",{x:a(g[l].x)+8,y:x(g[l].y)-24,width:100,height:28,rx:4,fill:o.cellBg,stroke:o.cellBorder,strokeWidth:1}),n.jsxs("text",{x:a(g[l].x)+13,y:x(g[l].y)-8,fontSize:10,fontFamily:o.fontMono,fill:o.textPrimary,children:["(",E(g[l].x,k),", ",E(g[l].y,A,e==null?void 0:e.format),")"]})]})]})]})}const it=12;function de({result:t,themeMode:s,chartConfig:e,isDonut:o}){const l=R[s],[r,i]=W.useState(null),{labelCol:k,valueCol:A}=G(t,e),y=D(e==null?void 0:e.colorPalette),g=t.rows.slice(0,it).map(c=>({label:String(c[k]??""),value:Math.abs(Number(c[A]??0))})),b=g.reduce((c,z)=>c+z.value,0)||1,v=90,w=90,p=70,u=o?40:0,S=[];let m=-Math.PI/2;g.forEach((c,z)=>{const F=c.value/b*2*Math.PI,T=m,j=m+F,_=v+p*Math.cos(T),a=w+p*Math.sin(T),x=v+p*Math.cos(j),$=w+p*Math.sin(j),f=F>Math.PI?1:0;let I;if(u>0){const L=v+u*Math.cos(T),B=w+u*Math.sin(T),h=v+u*Math.cos(j),M=w+u*Math.sin(j);I=`M ${_} ${a} A ${p} ${p} 0 ${f} 1 ${x} ${$} L ${h} ${M} A ${u} ${u} 0 ${f} 0 ${L} ${B} Z`}else I=`M ${v} ${w} L ${_} ${a} A ${p} ${p} 0 ${f} 1 ${x} ${$} Z`;S.push({path:I,color:y[z%y.length],label:c.label,value:c.value,pct:c.value/b*100}),m=j});const d=r!==null?S[r]:null;return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"8px 12px",flexWrap:"wrap"},children:[n.jsxs("svg",{width:180,height:180,style:{flexShrink:0},onMouseLeave:()=>i(null),children:[S.map((c,z)=>n.jsx("path",{d:c.path,fill:c.color,opacity:r===null||r===z?1:.55,style:{cursor:"pointer",transition:"opacity 0.15s"},onMouseEnter:()=>i(z)},z)),o&&n.jsxs(n.Fragment,{children:[n.jsx("text",{x:v,y:w-5,textAnchor:"middle",fontSize:11,fontFamily:l.fontMono,fill:l.textSecondary,children:E(d?d.value:b,A,e==null?void 0:e.format)}),n.jsx("text",{x:v,y:w+9,textAnchor:"middle",fontSize:9,fontFamily:l.font,fill:l.textMuted,children:d?`${d.pct.toFixed(1)}%`:"total"})]})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,maxHeight:180,overflowY:"auto",flex:1},children:S.map((c,z)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,cursor:"default",opacity:r===null||r===z?1:.5},onMouseEnter:()=>i(z),onMouseLeave:()=>i(null),children:[n.jsx("div",{style:{width:10,height:10,borderRadius:2,background:c.color,flexShrink:0}}),n.jsx("span",{style:{fontSize:11,fontFamily:l.font,color:l.textSecondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.label}),n.jsxs("span",{style:{fontSize:11,fontFamily:l.fontMono,color:l.textMuted,marginLeft:"auto",flexShrink:0},children:[c.pct.toFixed(1),"%"]})]},z))})]})}function at({result:t,themeMode:s}){const e=R[s],[o,l]=W.useState(null),r=t.columns[0],i=t.columns.slice(1),k=t.rows.slice(0,30),A=k.flatMap(S=>i.map(m=>Number(S[m]??0))),y=Math.min(...A),b=Math.max(...A)-y||1,v=Math.min(50,480/i.length),w=24,p=100;function u(S){const m=(S-y)/b,d=Math.round(56+m*192),c=Math.round(139+m*-58),z=Math.round(253+m*-180);return`rgb(${d},${c},${z})`}return n.jsx("div",{style:{padding:"8px 0",overflowX:"auto"},children:n.jsxs("svg",{width:p+i.length*v+20,height:k.length*w+w+16,style:{display:"block",overflow:"visible"},children:[i.map((S,m)=>n.jsx("text",{x:p+m*v+v/2,y:14,textAnchor:"middle",fontSize:9,fontFamily:e.font,fill:e.textMuted,transform:`rotate(-30, ${p+m*v+v/2}, 14)`,children:S.length>8?S.slice(0,7)+"…":S},m)),k.map((S,m)=>{const d=String(S[r]??""),c=w+m*w;return n.jsxs("g",{children:[n.jsx("text",{x:p-6,y:c+w/2+4,textAnchor:"end",fontSize:10,fontFamily:e.font,fill:e.textSecondary,children:d.length>14?d.slice(0,13)+"…":d}),i.map((z,F)=>{const T=Number(S[z]??0),j=(o==null?void 0:o.r)===m&&(o==null?void 0:o.c)===F;return n.jsxs("g",{onMouseEnter:()=>l({r:m,c:F}),onMouseLeave:()=>l(null),children:[n.jsx("rect",{x:p+F*v,y:c,width:v-1,height:w-1,rx:2,fill:u(T),opacity:j?1:.85,stroke:j?e.accent:"none",strokeWidth:j?1.5:0}),j&&n.jsx("text",{x:p+F*v+v/2,y:c+w/2+4,textAnchor:"middle",fontSize:10,fontFamily:e.fontMono,fill:"#fff",fontWeight:600,children:E(T,z)})]},F)})]},m)})]})})}function ct({result:t,themeMode:s,chartConfig:e}){const o=R[s],[l,r]=W.useState(null),k=D(e==null?void 0:e.colorPalette)[0]??o.accent,A=(e!=null&&e.x&&t.columns.includes(e.x)?e.x:void 0)??t.columns.find(x=>t.rows.slice(0,5).some($=>U($[x])))??t.columns[0],y=t.rows.map(x=>Number(x[A]??0)).filter(x=>!isNaN(x));if(y.length===0)return null;const g=Math.min(20,Math.max(5,Math.ceil(Math.sqrt(y.length)))),b=Math.min(...y),p=(Math.max(...y)-b||1)/g,u=Array.from({length:g},(x,$)=>({low:b+$*p,high:b+($+1)*p,count:0}));y.forEach(x=>{const $=Math.min(Math.floor((x-b)/p),g-1);u[$].count++});const S=Math.max(...u.map(x=>x.count),1),m=560,d=200,c=52,z=16,F=16,T=36,j=m-c-z,_=d-F-T,a=j/g;return n.jsx("div",{style:{padding:"8px 0"},children:n.jsxs("svg",{width:"100%",height:d,viewBox:`0 0 ${m} ${d}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:[Array.from({length:5},(x,$)=>{const f=S*($+1)/5,I=F+_-f/S*_;return n.jsxs("g",{children:[n.jsx("line",{x1:c,y1:I,x2:c+j,y2:I,stroke:o.tableBorder,strokeWidth:.5}),n.jsx("text",{x:c-6,y:I+4,textAnchor:"end",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:Math.round(f)})]},$)}),u.map((x,$)=>{const f=x.count/S*_,I=c+$*a,L=F+_-f,B=l===$;return n.jsxs("g",{onMouseEnter:()=>r($),onMouseLeave:()=>r(null),children:[n.jsx("rect",{x:I+1,y:L,width:a-2,height:f,rx:1,fill:k,opacity:B?1:.85,style:{transition:"opacity 0.1s"}}),B&&n.jsx("text",{x:I+a/2,y:L-4,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textPrimary,children:x.count})]},$)}),u.filter((x,$)=>$%Math.ceil(g/6)===0).map((x,$)=>{const f=u.indexOf(x);return n.jsx("text",{x:c+f*a+a/2,y:F+_+16,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:E(x.low,A,e==null?void 0:e.format)},$)}),n.jsx("line",{x1:c,y1:F,x2:c,y2:F+_,stroke:o.tableBorder,strokeWidth:1}),n.jsx("line",{x1:c,y1:F+_,x2:c+j,y2:F+_,stroke:o.tableBorder,strokeWidth:1}),n.jsx("text",{x:c+j/2,y:d-2,textAnchor:"middle",fontSize:10,fontFamily:o.font,fill:o.textMuted,children:A})]})})}function dt({result:t,themeMode:s,chartConfig:e}){const o=R[s],[l,r]=W.useState(null),{labelCol:i,valueCol:k}=G(t,e),A=D(e==null?void 0:e.colorPalette),y=t.rows.slice(0,10).map(m=>({label:String(m[i]??""),value:Math.abs(Number(m[k]??0))}));if(y.length===0)return null;const g=y[0].value||1,b=400,v=36,w=4,p=16,u=y.length*(v+w)+p*2,S=b/2;return n.jsx("div",{style:{padding:"8px 0",display:"flex",justifyContent:"center"},children:n.jsx("svg",{width:b,height:u,style:{display:"block"},children:y.map((m,d)=>{const c=p+d*(v+w),z=m.value/g,F=Math.max(z*(b-80),40),T=l===d,j=d<y.length-1?y[d+1].value/g:z*.8,_=Math.max(j*(b-80),40),a=S-F/2,x=S+F/2,$=S+_/2,f=S-_/2,I=`M ${a} ${c} L ${x} ${c} L ${$} ${c+v} L ${f} ${c+v} Z`;return n.jsxs("g",{onMouseEnter:()=>r(d),onMouseLeave:()=>r(null),style:{cursor:"default"},children:[n.jsx("path",{d:I,fill:A[d%A.length],opacity:T?1:.85,style:{transition:"opacity 0.15s"}}),n.jsx("text",{x:S,y:c+v/2+1,textAnchor:"middle",fontSize:11,fontFamily:o.font,fill:"#fff",fontWeight:500,children:m.label}),n.jsxs("text",{x:S,y:c+v/2+13,textAnchor:"middle",fontSize:9,fontFamily:o.fontMono,fill:"rgba(255,255,255,0.7)",children:[E(m.value,k,e==null?void 0:e.format)," (",(z*100).toFixed(0),"%)"]})]},d)})})})}function xt({result:t,themeMode:s,chartConfig:e}){const o=R[s],l=D(e==null?void 0:e.colorPalette),[r,i]=W.useState(null),k=t.rows.slice(0,20),A=t.columns.filter(h=>k.some(M=>U(M[h]))),y=t.columns.filter(h=>!A.includes(h)),g=e!=null&&e.x&&y.includes(e.x)?e.x:y.find(h=>/(?:^|_)(?:source|from|origin|upstream|supplier|producer|category)(?:_|$)/i.test(h))??y[0],b=e!=null&&e.color&&y.includes(e.color)&&e.color!==g?e.color:y.find(h=>h!==g&&/(?:^|_)(?:target|to|destination|downstream|consumer|customer|product)(?:_|$)/i.test(h))??y.find(h=>h!==g),v=e!=null&&e.y&&A.includes(e.y)?e.y:A[0];if(!g||!b||!v)return n.jsx(J,{result:t,themeMode:s});const w=new Map;for(const h of t.rows){const M=String(h[g]??"").trim(),N=String(h[b]??"").trim(),P=Math.abs(Number(h[v]??0));if(!M||!N||!Number.isFinite(P)||P<=0)continue;const H=`${M}\0${N}`,O=w.get(H);w.set(H,{source:M,target:N,value:((O==null?void 0:O.value)??0)+P})}const p=[...w.values()].sort((h,M)=>M.value-h.value);if(p.length===0)return n.jsx(J,{result:t,themeMode:s});const u=new Map,S=new Map;p.forEach(h=>{u.set(h.source,(u.get(h.source)??0)+h.value),S.set(h.target,(S.get(h.target)??0)+h.value)});const m=[...u].sort((h,M)=>M[1]-h[1]).slice(0,12).map(([h])=>h),d=[...S].sort((h,M)=>M[1]-h[1]).slice(0,12).map(([h])=>h),c=new Set(m),z=new Set(d),F=p.filter(h=>c.has(h.source)&&z.has(h.target)).slice(0,40),T=Math.max(...F.map(h=>h.value),1),j=640,_=Math.max(250,Math.max(m.length,d.length)*34+40),a=132,x=j-144,$=12,f=28,I=(h,M)=>M<=1?_/2:f+h*((_-f*2)/(M-1)),L=new Map(m.map((h,M)=>[h,M])),B=new Map(d.map((h,M)=>[h,M]));return n.jsx("div",{style:{padding:"8px 0",overflowX:"auto"},children:n.jsxs("svg",{role:"img","aria-label":`${g} to ${b} flow by ${v}`,width:"100%",height:_,viewBox:`0 0 ${j} ${_}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",minWidth:520},children:[n.jsx("text",{x:a,y:14,textAnchor:"middle",fontSize:10,fontWeight:700,fontFamily:o.font,fill:o.textMuted,children:g}),n.jsx("text",{x,y:14,textAnchor:"middle",fontSize:10,fontWeight:700,fontFamily:o.font,fill:o.textMuted,children:b}),F.map((h,M)=>{const N=I(L.get(h.source)??0,m.length),P=I(B.get(h.target)??0,d.length),H=`${h.source}\0${h.target}`,O=r===H,he=`M ${a+$},${N} C ${a+150},${N} ${x-150},${P} ${x},${P}`,Z=j/2,q=(N+P)/2;return n.jsxs("g",{onMouseEnter:()=>i(H),onMouseLeave:()=>i(null),children:[n.jsx("path",{d:he,fill:"none",stroke:l[M%l.length],strokeWidth:Math.max(2,h.value/T*18),opacity:r===null||O?.7:.14,strokeLinecap:"round",style:{transition:"opacity 0.15s",cursor:"default"}}),O?n.jsxs("g",{pointerEvents:"none",children:[n.jsx("rect",{x:Z-72,y:q-18,width:144,height:36,rx:5,fill:o.cellBg,stroke:o.cellBorder}),n.jsxs("text",{x:Z,y:q-3,textAnchor:"middle",fontSize:9.5,fontFamily:o.font,fill:o.textSecondary,children:[h.source," → ",h.target]}),n.jsx("text",{x:Z,y:q+11,textAnchor:"middle",fontSize:11,fontWeight:700,fontFamily:o.fontMono,fill:o.textPrimary,children:E(h.value,v,e==null?void 0:e.format)})]}):null]},H)}),m.map((h,M)=>{const N=I(M,m.length);return n.jsxs("g",{children:[n.jsx("rect",{x:a,y:N-9,width:$,height:18,rx:3,fill:l[M%l.length]}),n.jsx("text",{x:a-7,y:N+3,textAnchor:"end",fontSize:10.5,fontFamily:o.font,fill:o.textSecondary,children:h.length>18?`${h.slice(0,17)}…`:h})]},`source-${h}`)}),d.map((h,M)=>{const N=I(M,d.length);return n.jsxs("g",{children:[n.jsx("rect",{x,y:N-9,width:$,height:18,rx:3,fill:l[(M+m.length)%l.length]}),n.jsx("text",{x:x+$+7,y:N+3,textAnchor:"start",fontSize:10.5,fontFamily:o.font,fill:o.textSecondary,children:h.length>18?`${h.slice(0,17)}…`:h})]},`target-${h}`)})]})})}function ut({result:t,themeMode:s,chartConfig:e}){const o=R[s],[l,r]=W.useState(null),{labelCol:i,valueCol:k}=G(t,e),A=t.rows.slice(0,15).map(a=>({label:String(a[i]??""),value:Number(a[k]??0)}));if(A.length===0)return null;let y=0;const g=A.map(a=>{const x=y;return y+=a.value,{...a,start:x,end:y}}),b=g.flatMap(a=>[a.start,a.end]),v=Math.min(0,...b),p=Math.max(0,...b)-v||1,u=560,S=240,m=52,d=16,c=16,z=44,F=u-m-d,T=S-c-z,j=F/g.length,_=a=>c+T-(a-v)/p*T;return n.jsx("div",{style:{padding:"8px 0"},children:n.jsxs("svg",{width:"100%",height:S,viewBox:`0 0 ${u} ${S}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:[Array.from({length:6},(a,x)=>{const $=v+p*x/5,f=_($);return n.jsxs("g",{children:[n.jsx("line",{x1:m,y1:f,x2:m+F,y2:f,stroke:o.tableBorder,strokeWidth:.5}),n.jsx("text",{x:m-6,y:f+4,textAnchor:"end",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:E($,k,e==null?void 0:e.format)})]},x)}),n.jsx("line",{x1:m,y1:_(0),x2:m+F,y2:_(0),stroke:o.textMuted,strokeWidth:1,strokeDasharray:"3,3"}),g.map((a,x)=>{const $=m+x*j,f=_(Math.max(a.start,a.end)),L=_(Math.min(a.start,a.end))-f,B=a.value>=0,h=l===x;return n.jsxs("g",{onMouseEnter:()=>r(x),onMouseLeave:()=>r(null),children:[x<g.length-1&&n.jsx("line",{x1:$+j-2,y1:_(a.end),x2:$+j+2,y2:_(a.end),stroke:o.textMuted,strokeWidth:1,strokeDasharray:"2,2"}),n.jsx("rect",{x:$+4,y:f,width:j-8,height:Math.max(L,1),rx:2,fill:B?o.success:o.error,opacity:h?1:.8,style:{transition:"opacity 0.1s"}}),h&&n.jsxs("text",{x:$+j/2,y:f-4,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textPrimary,children:[a.value>=0?"+":"",E(a.value,k,e==null?void 0:e.format)]})]},x)}),g.map((a,x)=>n.jsx("text",{x:m+x*j+j/2,y:S-6,textAnchor:"middle",fontSize:9,fontFamily:o.font,fill:o.textMuted,transform:`rotate(-20, ${m+x*j+j/2}, ${S-6})`,children:a.label.length>8?a.label.slice(0,7)+"…":a.label},x)),n.jsx("line",{x1:m,y1:c,x2:m,y2:c+T,stroke:o.tableBorder,strokeWidth:1}),n.jsx("line",{x1:m,y1:c+T,x2:m+F,y2:c+T,stroke:o.tableBorder,strokeWidth:1})]})})}function pt({result:t,themeMode:s,chartConfig:e}){const o=R[s],l=t.rows[0];if(!l)return null;const r=(e!=null&&e.y&&t.columns.includes(e.y)?e.y:void 0)??t.columns.find(_=>U(l[_]))??t.columns[0],i=Number(l[r]??0),k=(e==null?void 0:e.title)??r,A=i>100?i*1.2:100,y=Math.min(Math.max(i/A,0),1),g=120,b=110,v=80,w=Math.PI,p=0,u=w-(w-p)*y,S=g+v*Math.cos(w),m=b+v*Math.sin(w),d=g+v*Math.cos(u),c=b+v*Math.sin(u),z=y>.5?1:0,F=g+v*Math.cos(p),T=b+v*Math.sin(p),j=y<.33?o.error:y<.66?o.warning:o.success;return n.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"16px 24px"},children:n.jsxs("svg",{width:240,height:140,style:{display:"block",overflow:"visible"},children:[n.jsx("path",{d:`M ${S} ${m} A ${v} ${v} 0 1 1 ${F} ${T}`,fill:"none",stroke:o.tableBorder,strokeWidth:12,strokeLinecap:"round"}),y>0&&n.jsx("path",{d:`M ${S} ${m} A ${v} ${v} 0 ${z} 1 ${d} ${c}`,fill:"none",stroke:j,strokeWidth:12,strokeLinecap:"round"}),n.jsx("text",{x:g,y:b-4,textAnchor:"middle",fontSize:28,fontFamily:o.fontMono,fill:j,fontWeight:700,children:E(i,r,e==null?void 0:e.format)}),n.jsx("text",{x:g,y:b+16,textAnchor:"middle",fontSize:11,fontFamily:o.font,fill:o.textMuted,children:k})]})})}function mt(t,s,e,o){const l=Number(s);return s==null||typeof s!="number"&&isNaN(l)?s==null?"—":String(s):ne(t,s,e,{compact:Math.abs(l)>=1e5,format:o})}function ye({result:t,themeMode:s,chartConfig:e}){const o=R[s],l=D(e==null?void 0:e.colorPalette),r=t.rows[0];if(!r)return null;const i=e!=null&&e.y&&t.columns.includes(e.y)?e.y:t.columns.find(A=>U(r[A]))??t.columns[0],k=mt(i,r[i],t.rows.map(A=>A[i]),e==null?void 0:e.format);return n.jsx("div",{style:{containerType:"inline-size",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",padding:"8px 4px",boxSizing:"border-box",minWidth:0},children:n.jsx("span",{title:String(r[i]),style:{fontSize:"clamp(14px, 13cqw, 40px)",fontWeight:750,fontFamily:o.fontMono,color:l[0]??o.accent,lineHeight:1.1,maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k})})}function yt({config:t,columns:s,onChange:e,onClose:o,t:l}){const r={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 n.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:i=>i.stopPropagation(),children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsx("span",{style:{fontSize:11,fontWeight:600,color:l.textPrimary,fontFamily:l.font},children:"Chart Settings"}),n.jsx("button",{onClick:o,style:{background:"none",border:"none",color:l.textMuted,cursor:"pointer",fontSize:14},children:"×"})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Title",n.jsx("input",{value:t.title??"",onChange:i=>e({title:i.target.value||void 0}),placeholder:"Chart title",style:{...r,marginTop:2}})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["X-axis label",n.jsx("input",{value:t.xLabel??"",onChange:i=>e({xLabel:i.target.value||void 0}),placeholder:"Auto",style:{...r,marginTop:2}})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Y-axis label",n.jsx("input",{value:t.yLabel??"",onChange:i=>e({yLabel:i.target.value||void 0}),placeholder:"Auto",style:{...r,marginTop:2}})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Legend",n.jsxs("select",{value:t.legendPosition??"top",onChange:i=>e({legendPosition:i.target.value}),style:{...r,marginTop:2},children:[n.jsx("option",{value:"top",children:"Top"}),n.jsx("option",{value:"bottom",children:"Bottom"}),n.jsx("option",{value:"left",children:"Left"}),n.jsx("option",{value:"right",children:"Right"}),n.jsx("option",{value:"none",children:"Hidden"})]})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Color palette",n.jsx("select",{value:t.colorPalette??"default",onChange:i=>e({colorPalette:i.target.value}),style:{...r,marginTop:2},children:Object.keys(Q).map(i=>n.jsx("option",{value:i,children:i.charAt(0).toUpperCase()+i.slice(1)},i))})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Max items",n.jsx("input",{type:"number",value:t.maxItems??V,min:5,max:200,onChange:i=>e({maxItems:parseInt(i.target.value)||V}),style:{...r,marginTop:2}})]})]})}function kt({result:t,themeMode:s,chartConfig:e,onConfigChange:o}){const l=R[s],r=nt(t,e),[i,k]=W.useState(!1);return r==="kpi"?n.jsx(ye,{result:t,themeMode:s,chartConfig:e}):n.jsxs("div",{style:{position:"relative"},children:[(e==null?void 0:e.title)&&n.jsx("div",{style:{padding:"8px 12px 0",fontSize:13,fontWeight:600,color:l.textPrimary,fontFamily:l.font,textAlign:"center"},children:e.title}),o&&n.jsx("button",{onClick:()=>k(!i),title:"Chart settings",style:{position:"absolute",top:4,right:4,zIndex:50,background:i?`${l.accent}18`:"transparent",border:`1px solid ${i?l.accent:"transparent"}`,borderRadius:4,color:i?l.accent:l.textMuted,cursor:"pointer",fontSize:14,padding:"2px 6px",lineHeight:1},children:"⚙"}),i&&o&&n.jsx(yt,{config:e??{},columns:t.columns,onChange:A=>o(A),onClose:()=>k(!1),t:l}),ft(r,t,s,e)]})}function ft(t,s,e,o){const l=o!=null&&o.x&&s.columns.includes(o.x)?o.x:void 0,r=o!=null&&o.y&&s.columns.includes(o.y)?o.y:void 0,i=l||r?ht(s,l,r):s;switch(t){case"line":return n.jsx(ce,{result:i,themeMode:e,chartConfig:o});case"area":return n.jsx(ce,{result:i,themeMode:e,chartConfig:o,showArea:!0});case"bar":return n.jsx(oe,{result:i,themeMode:e,chartConfig:o});case"grouped-bar":return n.jsx(st,{result:i,themeMode:e,chartConfig:o});case"stacked-bar":return n.jsx(lt,{result:i,themeMode:e,chartConfig:o});case"scatter":return n.jsx(rt,{result:s,themeMode:e,chartConfig:o});case"pie":return n.jsx(de,{result:s,themeMode:e,chartConfig:o,isDonut:!1});case"donut":return n.jsx(de,{result:s,themeMode:e,chartConfig:o,isDonut:!0});case"heatmap":return n.jsx(at,{result:s,themeMode:e});case"histogram":return n.jsx(ct,{result:s,themeMode:e,chartConfig:o});case"funnel":return n.jsx(dt,{result:s,themeMode:e,chartConfig:o});case"sankey":return n.jsx(xt,{result:s,themeMode:e,chartConfig:o});case"waterfall":return n.jsx(ut,{result:s,themeMode:e,chartConfig:o});case"gauge":return n.jsx(pt,{result:s,themeMode:e,chartConfig:o});case"kpi":return n.jsx(ye,{result:s,themeMode:e,chartConfig:o});default:return n.jsx(J,{result:s,themeMode:e})}}function ht(t,s,e){const o=t.columns,l=[];s&&o.includes(s)&&l.push(s),e&&o.includes(e)&&l.push(e);for(const r of o)l.includes(r)||l.push(r);return l.join(",")===o.join(",")?t:{...t,columns:l,rows:t.rows.map(r=>{const i={};for(const k of l)i[k]=r[k];return i})}}function zt(t){return new Set(t.tiles.filter(s=>!s.error&&s.selectedByDefault).map(s=>s.id))}function _t({proposal:t,t:s,selected:e,onToggle:o,onCreate:l,busy:r,error:i,compact:k}){const A=t.tiles.filter(u=>!u.error),y=t.tiles.filter(u=>u.error),g=A.filter(u=>e.has(u.id)).length,b=A.filter(u=>e.has(u.id)&&u.certification==="ai_generated").length,v=A.filter(u=>e.has(u.id)&&u.certification==="reviewed_semantic").length,p=A.filter(u=>e.has(u.id)&&u.certification==="certified").length+v>0;return n.jsxs("div",{style:{display:"grid",gap:10},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[n.jsx("span",{style:{fontSize:12.5,fontWeight:800,color:s.textPrimary},children:"Proposed app content"}),n.jsxs("span",{style:{fontSize:11,color:s.textMuted},children:[t.coverage.certifiedTiles," certified",t.coverage.semanticTiles>0?` · ${t.coverage.semanticTiles} reviewed semantic`:"",t.coverage.generatedTiles>0?` · ${t.coverage.generatedTiles} AI-generated`:"",t.coverage.gaps>0?` · ${t.coverage.gaps} uncovered`:""]})]}),n.jsxs("div",{style:{display:"grid",gap:6},children:[A.map(u=>n.jsx(bt,{tile:u,t:s,checked:e.has(u.id),onToggle:()=>o(u.id),compact:k},u.id)),y.map(u=>n.jsxs("div",{style:{...fe(s),opacity:.75},children:[n.jsx(be,{size:13,color:s.warning,style:{flexShrink:0,marginTop:2}}),n.jsxs("div",{style:{minWidth:0,flex:1},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:s.textSecondary},children:u.title}),n.jsx("div",{style:{fontSize:11,color:s.textMuted,marginTop:1},children:u.error})]})]},u.id))]}),t.gaps.length>0?n.jsxs("div",{style:{display:"grid",gap:4},children:[n.jsx("div",{style:{fontSize:11,fontWeight:800,color:s.textMuted,textTransform:"uppercase",letterSpacing:"0.04em"},children:"Not covered yet"}),t.gaps.map(u=>n.jsxs("div",{style:{display:"flex",gap:7,alignItems:"flex-start",fontSize:11.5,color:s.textMuted},children:[n.jsx(ke,{size:12,style:{flexShrink:0,marginTop:2}}),n.jsx("span",{style:{lineHeight:1.4},children:u.question})]},u.id))]}):null,i?n.jsx("div",{style:{fontSize:12,color:s.error},children:i}):null,n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,flexWrap:"wrap"},children:[n.jsxs("button",{type:"button",className:"dql-hover",onClick:l,disabled:r||!p,style:St(s,p&&!r),children:[r?n.jsx(ve,{size:13,style:{animation:"dql-agent-run-spin 0.8s linear infinite"}}):n.jsx(ge,{size:13}),n.jsx("span",{children:r?"Creating app…":`Create app (${g} tile${g===1?"":"s"})`})]}),n.jsx("span",{style:{fontSize:11,color:s.textMuted},children:p?v>0?`${v} semantic tile${v===1?"":"s"} will compile against the governed semantic layer at run time.`:b>0?`${b} AI-generated tile${b===1?"":"s"} will stay review-required until certified.`:"Nothing is created until you confirm.":"Select at least one certified block or reviewed semantic tile."})]})]})}function bt({tile:t,t:s,checked:e,onToggle:o,compact:l}){const[r,i]=W.useState(!1),k=t.certification==="certified",A=t.certification==="reviewed_semantic",y=!!(t.sql||t.answer||t.preview&&t.preview.rows.length>0);return n.jsxs("div",{style:fe(s),children:[n.jsx("input",{type:"checkbox",checked:e,onChange:o,"aria-label":`Include ${t.title}`,style:{marginTop:2,accentColor:s.accent,cursor:"pointer",flexShrink:0}}),n.jsxs("div",{style:{minWidth:0,flex:1},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[n.jsx("span",{style:{fontSize:12.5,fontWeight:750,color:s.textPrimary},children:t.title}),k?n.jsxs("span",{style:X(s.success),children:[n.jsx(je,{size:10})," certified"]}):A?n.jsxs("span",{style:X(s.accent),children:[n.jsx(se,{size:10})," reviewed semantic"]}):n.jsxs("span",{style:X(s.warning),children:[n.jsx(se,{size:10})," AI-generated · needs review"]}),n.jsx("span",{style:{fontSize:10,color:s.textMuted},children:t.viz})]}),t.description&&!l?n.jsx("div",{style:{fontSize:11.5,color:s.textSecondary,marginTop:2,lineHeight:1.4},children:t.description}):null,t.question&&t.question!==t.title?n.jsxs("div",{style:{fontSize:11,color:s.textMuted,marginTop:2},children:["Answers: ",t.question]}):null,y?n.jsxs("button",{type:"button",onClick:()=>i(g=>!g),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:[r?n.jsx(Se,{size:11}):n.jsx(we,{size:11}),n.jsx($e,{size:11})," ",r?"Hide details":"Show SQL & preview"]}):null,r&&t.answer?n.jsx("div",{style:{fontSize:11.5,color:s.textSecondary,marginTop:5,lineHeight:1.4},children:t.answer}):null,r&&t.sql?n.jsx("pre",{style:jt(s),children:t.sql}):null,r&&t.preview&&t.preview.rows.length>0?n.jsx(vt,{preview:t.preview,t:s}):null]})]})}function vt({preview:t,t:s}){const e=t.columns.slice(0,5),o=t.rows.slice(0,5);return n.jsxs("div",{style:{marginTop:5,overflow:"auto",border:`1px solid ${s.headerBorder}`,borderRadius:6},children:[n.jsxs("table",{style:{borderCollapse:"collapse",fontSize:10.5,fontFamily:s.fontMono,width:"100%"},children:[n.jsx("thead",{children:n.jsx("tr",{children:e.map(l=>n.jsx("th",{style:{textAlign:"left",padding:"3px 8px",color:s.textMuted,borderBottom:`1px solid ${s.headerBorder}`,fontWeight:700,whiteSpace:"nowrap"},children:l},l))})}),n.jsx("tbody",{children:o.map((l,r)=>n.jsx("tr",{children:e.map(i=>n.jsx("td",{style:{padding:"3px 8px",color:s.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:160},children:gt(l[i])},i))},r))})]}),typeof t.rowCount=="number"&&t.rowCount>o.length?n.jsxs("div",{style:{fontSize:10,color:s.textMuted,padding:"3px 8px"},children:[t.rowCount," rows total"]}):null]})}function gt(t){return t==null?"":typeof t=="number"?Number.isInteger(t)?String(t):t.toFixed(2):String(t)}function fe(t){return{display:"flex",gap:9,alignItems:"flex-start",border:`1px solid ${t.cellBorder}`,background:t.cellBg,borderRadius:8,padding:"9px 11px"}}function X(t){return{display:"inline-flex",alignItems:"center",gap:3,border:`1px solid ${t}55`,color:t,background:`${t}12`,borderRadius:999,padding:"1px 7px",fontSize:9.5,fontWeight:800}}function jt(t){return{margin:"5px 0 0",maxHeight:140,overflow:"auto",border:`1px solid ${t.headerBorder}`,background:t.editorBg,borderRadius:6,padding:8,fontSize:10.5,fontFamily:t.fontMono,color:t.textSecondary,lineHeight:1.45,whiteSpace:"pre-wrap"}}function St(t,s){return{display:"inline-flex",alignItems:"center",gap:6,border:"none",borderRadius:8,padding:"8px 14px",fontSize:12.5,fontWeight:800,fontFamily:t.font,cursor:s?"pointer":"default",background:s?t.accent:`${t.accent}55`,color:"#fff"}}function Tt(t){const s=`dql.agent.threadId.${t}`,[e,o]=W.useState(()=>xe(s));W.useEffect(()=>{o(xe(s))},[s]);const l=W.useCallback(i=>{o(i);try{window.localStorage.setItem(s,i)}catch{}},[s]),r=W.useCallback(()=>{o(void 0);try{window.localStorage.removeItem(s)}catch{}},[s]);return{threadId:e,onThreadIdChange:l,resetThreadId:r}}function xe(t){try{return window.localStorage.getItem(t)??void 0}catch{return}}export{_t as A,At as C,ke as F,Mt as S,J as T,nt as a,kt as b,$t as c,$e as d,zt as e,ne as f,Fe as i,ft as r,Tt as u};
18
+ `);ue(r,"export.csv","text/csv")}function Ke(t,s){const e=JSON.stringify(t.rows,null,2);ue(e,"export.json","application/json")}function ue(t,s,e){const o=new Blob([t],{type:e}),l=URL.createObjectURL(o),r=document.createElement("a");r.href=l,r.download=s,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(l)}function Je({dir:t,color:s}){return t?n.jsx("svg",{width:"8",height:"10",viewBox:"0 0 8 10",fill:s,style:{marginLeft:3,flexShrink:0},children:t==="asc"?n.jsx("path",{d:"M4 0L7 4H1L4 0Z"}):n.jsx("path",{d:"M4 10L1 6H7L4 10Z"})}):n.jsxs("svg",{width:"8",height:"10",viewBox:"0 0 8 10",fill:s,opacity:.3,style:{marginLeft:3,flexShrink:0},children:[n.jsx("path",{d:"M4 0L7 3.5H1L4 0Z"}),n.jsx("path",{d:"M4 10L1 6.5H7L4 10Z"})]})}function J({result:t,themeMode:s}){const e=R[s],[o,l]=W.useState(null),[r,i]=W.useState(null),[k,A]=W.useState(null),[y,j]=W.useState(""),[b,v]=W.useState(50),[w,p]=W.useState(0),u=W.useCallback(a=>{r===a?k==="asc"?A("desc"):k==="desc"?(i(null),A(null)):A("asc"):(i(a),A("asc")),p(0)},[r,k]),S=W.useMemo(()=>{if(!y.trim())return t.rows;const a=y.toLowerCase();return t.rows.filter(x=>t.columns.some($=>{const f=x[$];return f==null?!1:String(f).toLowerCase().includes(a)}))},[t.rows,t.columns,y]),m=W.useMemo(()=>{if(!r||!k)return S;const a=[...S];return a.sort((x,$)=>{const f=qe(x[r],$[r]);return k==="desc"?-f:f}),a},[S,r,k]),d=W.useMemo(()=>{const a=new Map;for(const x of t.columns)a.set(x,Fe(x,t.rows));return a},[t.columns,t.rows]),c=W.useMemo(()=>new Map(t.columns.map(a=>[a,t.rows.map(x=>x[a])])),[t.columns,t.rows]),[z,F]=W.useState(!1),T=Math.max(1,Math.ceil(m.length/b)),g=Math.min(w,T-1),_=m.slice(g*b,(g+1)*b);return t.columns.length===0?n.jsx("div",{style:{padding:"12px 16px",color:e.textMuted,fontSize:12,fontFamily:e.font,fontStyle:"italic"},children:"Query executed successfully. No columns to display."}):n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderBottom:`1px solid ${e.tableBorder}`,background:`${e.tableHeaderBg}60`,flexWrap:"wrap"},children:[n.jsxs("div",{style:{position:"relative",flex:"0 1 200px",minWidth:120},children:[n.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:e.textMuted,style:{position:"absolute",left:6,top:6},children:n.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"})}),n.jsx("input",{value:y,onChange:a=>{j(a.target.value),p(0)},placeholder:"Filter rows...",style:{width:"100%",background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:4,color:e.textPrimary,fontSize:11,fontFamily:e.font,padding:"3px 8px 3px 22px",outline:"none"}}),y&&n.jsx("button",{onClick:()=>j(""),style:{position:"absolute",right:4,top:3,background:"none",border:"none",color:e.textMuted,cursor:"pointer",fontSize:12,padding:"0 2px"},children:"×"})]}),n.jsxs("span",{style:{fontSize:10,color:e.textMuted,fontFamily:e.font},children:[y?`${m.length} of ${t.rows.length}`:`${t.rows.length}`," ",t.rows.length===1?"row":"rows"]}),n.jsx("div",{style:{flex:1}}),n.jsx(ie,{label:"CSV",onClick:()=>Xe(t),t:e}),n.jsx(ie,{label:"JSON",onClick:()=>Ke(t),t:e}),n.jsx("select",{value:b,onChange:a=>{v(Number(a.target.value)),p(0)},style:{background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:3,color:e.textSecondary,fontSize:10,fontFamily:e.font,padding:"2px 4px",outline:"none"},children:Ye.map(a=>n.jsxs("option",{value:a,children:[a," / page"]},a))}),T>1&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[n.jsx(Y,{disabled:g===0,onClick:()=>p(0),t:e,children:"«"}),n.jsx(Y,{disabled:g===0,onClick:()=>p(g-1),t:e,children:"‹"}),n.jsxs("span",{style:{fontSize:10,color:e.textSecondary,fontFamily:e.font,padding:"0 4px"},children:[g+1,"/",T]}),n.jsx(Y,{disabled:g>=T-1,onClick:()=>p(g+1),t:e,children:"›"}),n.jsx(Y,{disabled:g>=T-1,onClick:()=>p(T-1),t:e,children:"»"})]})]}),n.jsx("div",{style:{maxHeight:440,overflow:"auto",position:"relative"},onScroll:a=>F(a.target.scrollTop>0),children:n.jsxs("table",{style:{width:"100%",borderCollapse:"separate",borderSpacing:0,tableLayout:"auto",fontSize:12.5,fontFamily:e.fontMono},children:[n.jsx("thead",{children:n.jsx("tr",{children:t.columns.map(a=>{const x=d.get(a)??"string",$=x==="numeric";return n.jsx("th",{onClick:()=>u(a),style:{background:e.tableHeaderBg,color:e.textSecondary,fontWeight:600,fontSize:11,textAlign:$?"right":"left",padding:"8px 14px",borderBottom:`1px solid ${e.tableBorder}`,minWidth:80,maxWidth:320,whiteSpace:"nowrap",position:"sticky",top:0,zIndex:1,fontFamily:e.font,letterSpacing:"0.03em",overflow:"hidden",textOverflow:"ellipsis",cursor:"pointer",userSelect:"none",boxShadow:z?"0 2px 4px -2px rgba(0,0,0,0.18)":"none",transition:"background 0.1s, box-shadow 0.18s"},children:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,justifyContent:$?"flex-end":"flex-start"},children:[(()=>{const f=Ge(x);return n.jsx("span",{title:x,style:{fontSize:9,fontFamily:e.fontMono,fontWeight:700,color:f.color,background:`${f.color}15`,border:`1px solid ${f.color}40`,borderRadius:3,padding:"0 4px",minWidth:14,textAlign:"center",lineHeight:"14px",flexShrink:0},children:f.icon})})(),n.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:a}),n.jsx(Je,{dir:r===a?k:null,color:r===a?e.accent:e.textMuted})]})},a)})})}),n.jsx("tbody",{children:_.map((a,x)=>{const $=o===x,I=x%2===1?e.tableHeaderBg:"transparent";return n.jsx("tr",{onMouseEnter:()=>l(x),onMouseLeave:()=>l(null),style:{transition:"background 0.1s"},children:t.columns.map(L=>{const B=a[L],h=B==null,M=K(B);return n.jsx("td",{style:{padding:"7px 14px",borderBottom:`1px solid ${e.tableBorder}`,background:$?e.tableRowHover:I,color:h?e.textMuted:e.textPrimary,fontStyle:h?"italic":"normal",fontVariantNumeric:M?"tabular-nums":"normal",textAlign:M?"right":"left",whiteSpace:"nowrap",maxWidth:320,overflow:"hidden",textOverflow:"ellipsis",transition:"background 0.1s"},children:h?"—":ne(L,B,c.get(L)??[])},L)})},x)})})]})}),n.jsxs("div",{style:{padding:"5px 10px",color:e.textMuted,fontSize:10,fontFamily:e.font,borderTop:`1px solid ${e.tableBorder}`,background:`${e.tableHeaderBg}60`,display:"flex",alignItems:"center",gap:4},children:[T>1&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[n.jsx(Y,{disabled:g===0,onClick:()=>p(g-1),t:e,children:"‹"}),Qe(T,g).map((a,x)=>a==="…"?n.jsx("span",{style:{color:e.textMuted,fontSize:10,padding:"0 2px"},children:"…"},`gap-${x}`):n.jsx("button",{onClick:()=>p(a-1),style:{background:a-1===g?`${e.accent}20`:"transparent",border:"none",color:a-1===g?e.accent:e.textSecondary,fontSize:10,fontFamily:e.font,fontWeight:a-1===g?700:400,padding:"1px 6px",borderRadius:3,cursor:"pointer",minWidth:20},children:a},a)),n.jsx(Y,{disabled:g>=T-1,onClick:()=>p(g+1),t:e,children:"›"})]}),n.jsx("div",{style:{flex:1}}),n.jsxs("span",{style:{fontSize:10,color:e.textSecondary,fontFamily:e.font,marginLeft:6,whiteSpace:"nowrap"},children:[m.length.toLocaleString()," ",m.length===1?"row":"rows",y&&t.rows.length!==m.length&&` of ${t.rows.length.toLocaleString()}`]})]})]})}function Qe(t,s){if(t<=7)return Array.from({length:t},(l,r)=>r+1);const e=s+1,o=[1];e>3&&o.push("…");for(let l=Math.max(2,e-1);l<=Math.min(t-1,e+1);l++)o.push(l);return e<t-2&&o.push("…"),o.push(t),o}function ie({label:t,onClick:s,t:e}){const[o,l]=W.useState(!1);return n.jsxs("button",{onClick:s,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{background:o?e.btnHover:"transparent",border:`1px solid ${o?e.btnBorder:"transparent"}`,borderRadius:3,cursor:"pointer",color:o?e.textSecondary:e.textMuted,fontSize:10,fontFamily:e.font,fontWeight:600,padding:"2px 6px",transition:"all 0.15s",display:"flex",alignItems:"center",gap:3},children:[n.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 16 16",fill:"currentColor",children:[n.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"}),n.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"})]}),t]})}function Y({disabled:t,onClick:s,children:e,t:o}){return n.jsx("button",{disabled:t,onClick:s,style:{background:"transparent",border:"none",cursor:t?"default":"pointer",color:t?o.textMuted:o.textSecondary,fontSize:12,fontFamily:o.font,padding:"0 3px",opacity:t?.4:1,transition:"opacity 0.1s"},children:e})}const At=[{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"}],Ce=/date|time|at|day|month|year/i,pe=/^(label|name|category|status|type|group)$/i,me=/^(value|count|total|revenue|amount|sum|avg|price|quantity|sales)$/i;function U(t){return typeof t=="number"?!0:typeof t=="string"?t.trim()!==""&&!isNaN(Number(t)):!1}function et(t){return typeof t=="string"||typeof t=="number"}const tt=new Set(["bar","line","area","pie","donut","scatter","heatmap","funnel","waterfall","histogram","gauge","stacked-bar","grouped-bar","sankey","kpi","table"]);function nt(t,s){if(s!=null&&s.chart){const e=s.chart.toLowerCase().replace(/_/g,"-");if(tt.has(e))return e}return ot(t)}function ot(t){const{columns:s,rows:e}=t;if(s.length<2||e.length===0)return"table";const o=s[0],l=s[1],r=e.slice(0,5),i=r.every(b=>U(b[l])),k=r.every(b=>et(b[o]));if(Ce.test(o)&&i&&k)return"line";const A=s.find(b=>pe.test(b)),y=s.find(b=>me.test(b));return A&&y&&r.every(v=>U(v[y]))?"bar":r.every(b=>U(b[o]))&&i&&s.length>=2?"scatter":s.length===2&&k&&i?"bar":"table"}const Q={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 D(t){return Q[t??"default"]??Q.default}function E(t,s="value",e){return Oe(s,t,e)}function ae(t,s=8){if(/^\d{4}-\d{2}(-\d{2})?/.test(t)){const e=/^\d{4}-\d{2}$/.test(t),o=new Date(e?`${t}-01T00:00:00Z`:t);if(!isNaN(o.getTime()))return o.toLocaleDateString("en-US",e?{year:"numeric",month:"short",timeZone:"UTC"}:{month:"short",day:"numeric",timeZone:"UTC"})}return String(t).length>s?String(t).slice(0,s):String(t)}function G(t,s){const e=(s!=null&&s.x&&t.columns.includes(s.x)?s.x:void 0)??t.columns.find(l=>pe.test(l))??t.columns[0],o=(s!=null&&s.y&&t.columns.includes(s.y)?s.y:void 0)??t.columns.find(l=>me.test(l))??t.columns[1];return{labelCol:e,valueCol:o}}const V=20;function oe({result:t,themeMode:s,chartConfig:e}){const o=R[s],[l,r]=W.useState(null),{labelCol:i,valueCol:k}=G(t,e),A=(e==null?void 0:e.maxItems)??V,y=D(e==null?void 0:e.colorPalette),j=t.rows.slice(0,A).map(d=>({label:String(d[i]??""),value:Number(d[k]??0)})),b=t.rows.length>A,v=Math.max(...j.map(d=>d.value),1),w=28,p=120,u=6,S=12,m=j.length*(w+u)+S*2;return n.jsxs("div",{style:{padding:"8px 0"},children:[n.jsx("svg",{width:"100%",height:m,viewBox:`0 0 600 ${m}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:j.map((d,c)=>{const z=S+c*(w+u),F=600-p-84,T=Math.max(d.value/v*F,2),g=l===c,_=y[c%y.length];return n.jsxs("g",{onMouseEnter:()=>r(c),onMouseLeave:()=>r(null),style:{cursor:"default"},children:[n.jsx("text",{x:p-8,y:z+w/2+4,textAnchor:"end",fontSize:11,fontFamily:o.font,fill:o.textSecondary,children:d.label.length>16?d.label.slice(0,15)+"…":d.label}),n.jsx("rect",{x:p,y:z,width:T,height:w,rx:3,fill:_,opacity:g?1:.88,style:{transition:"opacity 0.15s"}}),n.jsx("text",{x:p+T+6,y:z+w/2+4,textAnchor:"start",fontSize:11,fontFamily:o.fontMono,fill:o.textMuted,children:E(d.value,k,e==null?void 0:e.format)})]},c)})}),b&&n.jsxs("div",{style:{fontSize:11,color:o.textMuted,fontFamily:o.font,fontStyle:"italic",padding:"4px 12px"},children:["Showing ",V," of ",t.rows.length," rows"]})]})}function st({result:t,themeMode:s,chartConfig:e}){const o=R[s],[l,r]=W.useState(null),i=D(e==null?void 0:e.colorPalette),k=e!=null&&e.x&&t.columns.includes(e.x)?e.x:t.columns[0],A=t.rows.slice(0,5),y=t.columns.filter(d=>d!==k&&A.some(c=>U(c[d])));if(y.length===0)return n.jsx(oe,{result:t,themeMode:s,chartConfig:e});const j=t.rows.slice(0,V).map(d=>String(d[k]??"")),b=Math.max(...t.rows.slice(0,V).flatMap(d=>y.map(c=>Math.abs(Number(d[c]??0)))),1),v=24,w=v/y.length,p=120,u=12,S=8,m=j.length*(v+S)+u*2;return n.jsxs("div",{style:{padding:"8px 0"},children:[n.jsx("div",{style:{display:"flex",gap:12,padding:"0 12px 6px",flexWrap:"wrap"},children:y.map((d,c)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[n.jsx("div",{style:{width:10,height:10,borderRadius:2,background:i[c%i.length]}}),n.jsx("span",{style:{fontSize:10,fontFamily:o.font,color:o.textSecondary},children:d})]},d))}),n.jsx("svg",{width:"100%",height:m,viewBox:`0 0 600 ${m}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:j.map((d,c)=>{const z=u+c*(v+S),F=t.rows[c];return n.jsxs("g",{children:[n.jsx("text",{x:p-8,y:z+v/2+4,textAnchor:"end",fontSize:11,fontFamily:o.font,fill:o.textSecondary,children:d.length>16?d.slice(0,15)+"…":d}),y.map((T,g)=>{const _=Number(F[T]??0),a=600-p-60,x=Math.max(Math.abs(_)/b*a,1),$=z+g*w,f=`${c}-${g}`;return n.jsxs("g",{onMouseEnter:()=>r(f),onMouseLeave:()=>r(null),children:[n.jsx("rect",{x:p,y:$,width:x,height:w-1,rx:2,fill:i[g%i.length],opacity:l===f?1:.85,style:{transition:"opacity 0.15s"}}),l===f&&n.jsx("text",{x:p+x+4,y:$+w/2+3,fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:E(_,T,e==null?void 0:e.format)})]},g)})]},c)})})]})}function lt({result:t,themeMode:s,chartConfig:e}){const o=R[s],[l,r]=W.useState(null),i=D(e==null?void 0:e.colorPalette),k=e!=null&&e.x&&t.columns.includes(e.x)?e.x:t.columns[0],A=t.rows.slice(0,5),y=t.columns.filter(d=>d!==k&&A.some(c=>U(c[d])));if(y.length===0)return n.jsx(oe,{result:t,themeMode:s,chartConfig:e});const j=t.rows.slice(0,V),b=j.map(d=>String(d[k]??"")),v=Math.max(...j.map(d=>y.reduce((c,z)=>c+Math.abs(Number(d[z]??0)),0)),1),w=28,p=120,u=12,S=6,m=b.length*(w+S)+u*2;return n.jsxs("div",{style:{padding:"8px 0"},children:[n.jsx("div",{style:{display:"flex",gap:12,padding:"0 12px 6px",flexWrap:"wrap"},children:y.map((d,c)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[n.jsx("div",{style:{width:10,height:10,borderRadius:2,background:i[c%i.length]}}),n.jsx("span",{style:{fontSize:10,fontFamily:o.font,color:o.textSecondary},children:d})]},d))}),n.jsx("svg",{width:"100%",height:m,viewBox:`0 0 600 ${m}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:b.map((d,c)=>{const z=u+c*(w+S),F=j[c],T=600-p-60;let g=p;return n.jsxs("g",{children:[n.jsx("text",{x:p-8,y:z+w/2+4,textAnchor:"end",fontSize:11,fontFamily:o.font,fill:o.textSecondary,children:d.length>16?d.slice(0,15)+"…":d}),y.map((_,a)=>{const x=Math.abs(Number(F[_]??0)),$=Math.max(x/v*T,0),f=g;g+=$;const I=`${c}-${a}`;return n.jsxs("g",{onMouseEnter:()=>r(I),onMouseLeave:()=>r(null),children:[n.jsx("rect",{x:f,y:z,width:$,height:w,rx:a===0?3:0,fill:i[a%i.length],opacity:l===I?1:.85,style:{transition:"opacity 0.15s"}}),l===I&&$>30&&n.jsx("text",{x:f+$/2,y:z+w/2+4,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:"#fff",fontWeight:600,children:E(x,_,e==null?void 0:e.format)})]},a)})]},c)})})]})}function ce({result:t,themeMode:s,showArea:e,chartConfig:o}){const l=R[s],[r,i]=W.useState(null),A=D(o==null?void 0:o.colorPalette)[0]??l.accent,{labelCol:y,valueCol:j}=G(t,o),b=t.rows.map(M=>({label:String(M[y]??""),value:Number(M[j]??0)}));if(b.length<2)return null;const v=560,w=212,p=56,u=16,S=16,m=48,d=v-p-u,c=w-S-m,z=Math.min(...b.map(M=>M.value)),T=Math.max(...b.map(M=>M.value))-z||1,g=d/(b.length-1),_=M=>p+M*g,a=M=>S+c-(M-z)/T*c,x=b.map((M,N)=>({x:_(N),y:a(M.value)})),$=x.reduce((M,N,P)=>{if(P===0)return`M ${N.x},${N.y}`;const H=x[P-1],O=H.x+(N.x-H.x)/2;return`${M} C ${O},${H.y} ${O},${N.y} ${N.x},${N.y}`},""),f=`${$} L ${x[x.length-1].x},${S+c} L ${p},${S+c} Z`,I=5,L=Array.from({length:I+1},(M,N)=>{const P=z+T*N/I;return{val:P,y:a(P)}}),B=Math.ceil(b.length/8),h=b.filter((M,N)=>N%B===0||N===b.length-1);return n.jsx("div",{style:{position:"relative",padding:"8px 0"},children:n.jsxs("svg",{width:"100%",height:w,viewBox:`0 0 ${v} ${w}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},onMouseLeave:()=>i(null),children:[L.map((M,N)=>n.jsxs("g",{children:[n.jsx("line",{x1:p,y1:M.y,x2:p+d,y2:M.y,stroke:l.tableBorder,strokeWidth:.5}),n.jsx("text",{x:p-6,y:M.y+4,textAnchor:"end",fontSize:10,fontFamily:l.fontMono,fill:l.textMuted,children:E(M.val,j,o==null?void 0:o.format)})]},N)),n.jsx("path",{d:f,fill:A,opacity:e?.3:.15}),n.jsx("path",{d:$,fill:"none",stroke:A,strokeWidth:2,strokeLinejoin:"round"}),x.map((M,N)=>n.jsx("circle",{cx:M.x,cy:M.y,r:3,fill:A,style:{cursor:"crosshair"},onMouseEnter:()=>i({x:M.x,y:M.y,label:b[N].label,value:b[N].value})},N)),h.map((M,N)=>{const P=b.indexOf(M);return n.jsx("text",{x:_(P),y:S+c+16,textAnchor:"middle",fontSize:10,fontFamily:l.font,fill:l.textMuted,children:ae(M.label)},N)}),n.jsx("line",{x1:p,y1:S,x2:p,y2:S+c,stroke:l.tableBorder,strokeWidth:1}),n.jsx("line",{x1:p,y1:S+c,x2:p+d,y2:S+c,stroke:l.tableBorder,strokeWidth:1}),n.jsx("text",{x:p+d/2,y:w-4,textAnchor:"middle",fontSize:10,fontWeight:600,fontFamily:l.font,fill:l.textMuted,letterSpacing:"0.04em",children:y}),n.jsx("text",{x:12,y:S+c/2,textAnchor:"middle",fontSize:10,fontWeight:600,fontFamily:l.font,fill:l.textMuted,letterSpacing:"0.04em",transform:`rotate(-90, 12, ${S+c/2})`,children:j}),r&&n.jsxs("g",{children:[n.jsx("rect",{x:r.x+8,y:r.y-20,width:90,height:32,rx:4,fill:l.cellBg,stroke:l.cellBorder,strokeWidth:1}),n.jsx("text",{x:r.x+13,y:r.y-8,fontSize:10,fontFamily:l.font,fill:l.textSecondary,children:ae(r.label,12)}),n.jsx("text",{x:r.x+13,y:r.y+6,fontSize:11,fontFamily:l.fontMono,fill:l.textPrimary,fontWeight:600,children:E(r.value,j,o==null?void 0:o.format)})]})]})})}function rt({result:t,themeMode:s,chartConfig:e}){const o=R[s],[l,r]=W.useState(null),i=D(e==null?void 0:e.colorPalette),k=e!=null&&e.x&&t.columns.includes(e.x)?e.x:t.columns[0],A=e!=null&&e.y&&t.columns.includes(e.y)?e.y:t.columns[1],y=e!=null&&e.color&&t.columns.includes(e.color)?e.color:void 0,j=t.rows.slice(0,200).map(f=>({x:Number(f[k]??0),y:Number(f[A]??0),color:y?String(f[y]??""):void 0})),b=560,v=300,w=52,p=16,u=16,S=36,m=b-w-p,d=v-u-S,c=Math.min(...j.map(f=>f.x)),z=Math.max(...j.map(f=>f.x)),F=Math.min(...j.map(f=>f.y)),T=Math.max(...j.map(f=>f.y)),g=z-c||1,_=T-F||1,a=f=>w+(f-c)/g*m,x=f=>u+d-(f-F)/_*d,$=y?[...new Set(j.map(f=>f.color))]:[];return n.jsxs("div",{style:{padding:"8px 0"},children:[y&&$.length>0&&n.jsx("div",{style:{display:"flex",gap:12,padding:"0 12px 6px",flexWrap:"wrap"},children:$.slice(0,12).map((f,I)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[n.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:i[I%i.length]}}),n.jsx("span",{style:{fontSize:10,fontFamily:o.font,color:o.textSecondary},children:f})]},f))}),n.jsxs("svg",{width:"100%",height:v,viewBox:`0 0 ${b} ${v}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:[Array.from({length:6},(f,I)=>{const L=F+_*I/5,B=x(L);return n.jsxs("g",{children:[n.jsx("line",{x1:w,y1:B,x2:w+m,y2:B,stroke:o.tableBorder,strokeWidth:.5}),n.jsx("text",{x:w-6,y:B+4,textAnchor:"end",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:E(L,A,e==null?void 0:e.format)})]},I)}),Array.from({length:6},(f,I)=>{const L=c+g*I/5,B=a(L);return n.jsx("text",{x:B,y:u+d+16,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:E(L,k)},I)}),n.jsx("line",{x1:w,y1:u,x2:w,y2:u+d,stroke:o.tableBorder,strokeWidth:1}),n.jsx("line",{x1:w,y1:u+d,x2:w+m,y2:u+d,stroke:o.tableBorder,strokeWidth:1}),n.jsx("text",{x:w+m/2,y:v-2,textAnchor:"middle",fontSize:10,fontFamily:o.font,fill:o.textMuted,children:k}),n.jsx("text",{x:10,y:u+d/2,textAnchor:"middle",fontSize:10,fontFamily:o.font,fill:o.textMuted,transform:`rotate(-90, 10, ${u+d/2})`,children:A}),j.map((f,I)=>{const L=y?$.indexOf(f.color):0;return n.jsx("circle",{cx:a(f.x),cy:x(f.y),r:l===I?5:3.5,fill:i[L%i.length],opacity:l===I?1:.7,style:{cursor:"crosshair",transition:"r 0.1s, opacity 0.1s"},onMouseEnter:()=>r(I),onMouseLeave:()=>r(null)},I)}),l!==null&&n.jsxs("g",{children:[n.jsx("rect",{x:a(j[l].x)+8,y:x(j[l].y)-24,width:100,height:28,rx:4,fill:o.cellBg,stroke:o.cellBorder,strokeWidth:1}),n.jsxs("text",{x:a(j[l].x)+13,y:x(j[l].y)-8,fontSize:10,fontFamily:o.fontMono,fill:o.textPrimary,children:["(",E(j[l].x,k),", ",E(j[l].y,A,e==null?void 0:e.format),")"]})]})]})]})}const it=12;function de({result:t,themeMode:s,chartConfig:e,isDonut:o}){const l=R[s],[r,i]=W.useState(null),{labelCol:k,valueCol:A}=G(t,e),y=D(e==null?void 0:e.colorPalette),j=t.rows.slice(0,it).map(c=>({label:String(c[k]??""),value:Math.abs(Number(c[A]??0))})),b=j.reduce((c,z)=>c+z.value,0)||1,v=90,w=90,p=70,u=o?40:0,S=[];let m=-Math.PI/2;j.forEach((c,z)=>{const F=c.value/b*2*Math.PI,T=m,g=m+F,_=v+p*Math.cos(T),a=w+p*Math.sin(T),x=v+p*Math.cos(g),$=w+p*Math.sin(g),f=F>Math.PI?1:0;let I;if(u>0){const L=v+u*Math.cos(T),B=w+u*Math.sin(T),h=v+u*Math.cos(g),M=w+u*Math.sin(g);I=`M ${_} ${a} A ${p} ${p} 0 ${f} 1 ${x} ${$} L ${h} ${M} A ${u} ${u} 0 ${f} 0 ${L} ${B} Z`}else I=`M ${v} ${w} L ${_} ${a} A ${p} ${p} 0 ${f} 1 ${x} ${$} Z`;S.push({path:I,color:y[z%y.length],label:c.label,value:c.value,pct:c.value/b*100}),m=g});const d=r!==null?S[r]:null;return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"8px 12px",flexWrap:"wrap"},children:[n.jsxs("svg",{width:180,height:180,style:{flexShrink:0},onMouseLeave:()=>i(null),children:[S.map((c,z)=>n.jsx("path",{d:c.path,fill:c.color,opacity:r===null||r===z?1:.55,style:{cursor:"pointer",transition:"opacity 0.15s"},onMouseEnter:()=>i(z)},z)),o&&n.jsxs(n.Fragment,{children:[n.jsx("text",{x:v,y:w-5,textAnchor:"middle",fontSize:11,fontFamily:l.fontMono,fill:l.textSecondary,children:E(d?d.value:b,A,e==null?void 0:e.format)}),n.jsx("text",{x:v,y:w+9,textAnchor:"middle",fontSize:9,fontFamily:l.font,fill:l.textMuted,children:d?`${d.pct.toFixed(1)}%`:"total"})]})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,maxHeight:180,overflowY:"auto",flex:1},children:S.map((c,z)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,cursor:"default",opacity:r===null||r===z?1:.5},onMouseEnter:()=>i(z),onMouseLeave:()=>i(null),children:[n.jsx("div",{style:{width:10,height:10,borderRadius:2,background:c.color,flexShrink:0}}),n.jsx("span",{style:{fontSize:11,fontFamily:l.font,color:l.textSecondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.label}),n.jsxs("span",{style:{fontSize:11,fontFamily:l.fontMono,color:l.textMuted,marginLeft:"auto",flexShrink:0},children:[c.pct.toFixed(1),"%"]})]},z))})]})}function at({result:t,themeMode:s}){const e=R[s],[o,l]=W.useState(null),r=t.columns[0],i=t.columns.slice(1),k=t.rows.slice(0,30),A=k.flatMap(S=>i.map(m=>Number(S[m]??0))),y=Math.min(...A),b=Math.max(...A)-y||1,v=Math.min(50,480/i.length),w=24,p=100;function u(S){const m=(S-y)/b,d=Math.round(56+m*192),c=Math.round(139+m*-58),z=Math.round(253+m*-180);return`rgb(${d},${c},${z})`}return n.jsx("div",{style:{padding:"8px 0",overflowX:"auto"},children:n.jsxs("svg",{width:p+i.length*v+20,height:k.length*w+w+16,style:{display:"block",overflow:"visible"},children:[i.map((S,m)=>n.jsx("text",{x:p+m*v+v/2,y:14,textAnchor:"middle",fontSize:9,fontFamily:e.font,fill:e.textMuted,transform:`rotate(-30, ${p+m*v+v/2}, 14)`,children:S.length>8?S.slice(0,7)+"…":S},m)),k.map((S,m)=>{const d=String(S[r]??""),c=w+m*w;return n.jsxs("g",{children:[n.jsx("text",{x:p-6,y:c+w/2+4,textAnchor:"end",fontSize:10,fontFamily:e.font,fill:e.textSecondary,children:d.length>14?d.slice(0,13)+"…":d}),i.map((z,F)=>{const T=Number(S[z]??0),g=(o==null?void 0:o.r)===m&&(o==null?void 0:o.c)===F;return n.jsxs("g",{onMouseEnter:()=>l({r:m,c:F}),onMouseLeave:()=>l(null),children:[n.jsx("rect",{x:p+F*v,y:c,width:v-1,height:w-1,rx:2,fill:u(T),opacity:g?1:.85,stroke:g?e.accent:"none",strokeWidth:g?1.5:0}),g&&n.jsx("text",{x:p+F*v+v/2,y:c+w/2+4,textAnchor:"middle",fontSize:10,fontFamily:e.fontMono,fill:"#fff",fontWeight:600,children:E(T,z)})]},F)})]},m)})]})})}function ct({result:t,themeMode:s,chartConfig:e}){const o=R[s],[l,r]=W.useState(null),k=D(e==null?void 0:e.colorPalette)[0]??o.accent,A=(e!=null&&e.x&&t.columns.includes(e.x)?e.x:void 0)??t.columns.find(x=>t.rows.slice(0,5).some($=>U($[x])))??t.columns[0],y=t.rows.map(x=>Number(x[A]??0)).filter(x=>!isNaN(x));if(y.length===0)return null;const j=Math.min(20,Math.max(5,Math.ceil(Math.sqrt(y.length)))),b=Math.min(...y),p=(Math.max(...y)-b||1)/j,u=Array.from({length:j},(x,$)=>({low:b+$*p,high:b+($+1)*p,count:0}));y.forEach(x=>{const $=Math.min(Math.floor((x-b)/p),j-1);u[$].count++});const S=Math.max(...u.map(x=>x.count),1),m=560,d=200,c=52,z=16,F=16,T=36,g=m-c-z,_=d-F-T,a=g/j;return n.jsx("div",{style:{padding:"8px 0"},children:n.jsxs("svg",{width:"100%",height:d,viewBox:`0 0 ${m} ${d}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:[Array.from({length:5},(x,$)=>{const f=S*($+1)/5,I=F+_-f/S*_;return n.jsxs("g",{children:[n.jsx("line",{x1:c,y1:I,x2:c+g,y2:I,stroke:o.tableBorder,strokeWidth:.5}),n.jsx("text",{x:c-6,y:I+4,textAnchor:"end",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:Math.round(f)})]},$)}),u.map((x,$)=>{const f=x.count/S*_,I=c+$*a,L=F+_-f,B=l===$;return n.jsxs("g",{onMouseEnter:()=>r($),onMouseLeave:()=>r(null),children:[n.jsx("rect",{x:I+1,y:L,width:a-2,height:f,rx:1,fill:k,opacity:B?1:.85,style:{transition:"opacity 0.1s"}}),B&&n.jsx("text",{x:I+a/2,y:L-4,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textPrimary,children:x.count})]},$)}),u.filter((x,$)=>$%Math.ceil(j/6)===0).map((x,$)=>{const f=u.indexOf(x);return n.jsx("text",{x:c+f*a+a/2,y:F+_+16,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:E(x.low,A,e==null?void 0:e.format)},$)}),n.jsx("line",{x1:c,y1:F,x2:c,y2:F+_,stroke:o.tableBorder,strokeWidth:1}),n.jsx("line",{x1:c,y1:F+_,x2:c+g,y2:F+_,stroke:o.tableBorder,strokeWidth:1}),n.jsx("text",{x:c+g/2,y:d-2,textAnchor:"middle",fontSize:10,fontFamily:o.font,fill:o.textMuted,children:A})]})})}function dt({result:t,themeMode:s,chartConfig:e}){const o=R[s],[l,r]=W.useState(null),{labelCol:i,valueCol:k}=G(t,e),A=D(e==null?void 0:e.colorPalette),y=t.rows.slice(0,10).map(m=>({label:String(m[i]??""),value:Math.abs(Number(m[k]??0))}));if(y.length===0)return null;const j=y[0].value||1,b=400,v=36,w=4,p=16,u=y.length*(v+w)+p*2,S=b/2;return n.jsx("div",{style:{padding:"8px 0",display:"flex",justifyContent:"center"},children:n.jsx("svg",{width:b,height:u,style:{display:"block"},children:y.map((m,d)=>{const c=p+d*(v+w),z=m.value/j,F=Math.max(z*(b-80),40),T=l===d,g=d<y.length-1?y[d+1].value/j:z*.8,_=Math.max(g*(b-80),40),a=S-F/2,x=S+F/2,$=S+_/2,f=S-_/2,I=`M ${a} ${c} L ${x} ${c} L ${$} ${c+v} L ${f} ${c+v} Z`;return n.jsxs("g",{onMouseEnter:()=>r(d),onMouseLeave:()=>r(null),style:{cursor:"default"},children:[n.jsx("path",{d:I,fill:A[d%A.length],opacity:T?1:.85,style:{transition:"opacity 0.15s"}}),n.jsx("text",{x:S,y:c+v/2+1,textAnchor:"middle",fontSize:11,fontFamily:o.font,fill:"#fff",fontWeight:500,children:m.label}),n.jsxs("text",{x:S,y:c+v/2+13,textAnchor:"middle",fontSize:9,fontFamily:o.fontMono,fill:"rgba(255,255,255,0.7)",children:[E(m.value,k,e==null?void 0:e.format)," (",(z*100).toFixed(0),"%)"]})]},d)})})})}function xt({result:t,themeMode:s,chartConfig:e}){const o=R[s],l=D(e==null?void 0:e.colorPalette),[r,i]=W.useState(null),k=t.rows.slice(0,20),A=t.columns.filter(h=>k.some(M=>U(M[h]))),y=t.columns.filter(h=>!A.includes(h)),j=e!=null&&e.x&&y.includes(e.x)?e.x:y.find(h=>/(?:^|_)(?:source|from|origin|upstream|supplier|producer|category)(?:_|$)/i.test(h))??y[0],b=e!=null&&e.color&&y.includes(e.color)&&e.color!==j?e.color:y.find(h=>h!==j&&/(?:^|_)(?:target|to|destination|downstream|consumer|customer|product)(?:_|$)/i.test(h))??y.find(h=>h!==j),v=e!=null&&e.y&&A.includes(e.y)?e.y:A[0];if(!j||!b||!v)return n.jsx(J,{result:t,themeMode:s});const w=new Map;for(const h of t.rows){const M=String(h[j]??"").trim(),N=String(h[b]??"").trim(),P=Math.abs(Number(h[v]??0));if(!M||!N||!Number.isFinite(P)||P<=0)continue;const H=`${M}\0${N}`,O=w.get(H);w.set(H,{source:M,target:N,value:((O==null?void 0:O.value)??0)+P})}const p=[...w.values()].sort((h,M)=>M.value-h.value);if(p.length===0)return n.jsx(J,{result:t,themeMode:s});const u=new Map,S=new Map;p.forEach(h=>{u.set(h.source,(u.get(h.source)??0)+h.value),S.set(h.target,(S.get(h.target)??0)+h.value)});const m=[...u].sort((h,M)=>M[1]-h[1]).slice(0,12).map(([h])=>h),d=[...S].sort((h,M)=>M[1]-h[1]).slice(0,12).map(([h])=>h),c=new Set(m),z=new Set(d),F=p.filter(h=>c.has(h.source)&&z.has(h.target)).slice(0,40),T=Math.max(...F.map(h=>h.value),1),g=640,_=Math.max(250,Math.max(m.length,d.length)*34+40),a=132,x=g-144,$=12,f=28,I=(h,M)=>M<=1?_/2:f+h*((_-f*2)/(M-1)),L=new Map(m.map((h,M)=>[h,M])),B=new Map(d.map((h,M)=>[h,M]));return n.jsx("div",{style:{padding:"8px 0",overflowX:"auto"},children:n.jsxs("svg",{role:"img","aria-label":`${j} to ${b} flow by ${v}`,width:"100%",height:_,viewBox:`0 0 ${g} ${_}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",minWidth:520},children:[n.jsx("text",{x:a,y:14,textAnchor:"middle",fontSize:10,fontWeight:700,fontFamily:o.font,fill:o.textMuted,children:j}),n.jsx("text",{x,y:14,textAnchor:"middle",fontSize:10,fontWeight:700,fontFamily:o.font,fill:o.textMuted,children:b}),F.map((h,M)=>{const N=I(L.get(h.source)??0,m.length),P=I(B.get(h.target)??0,d.length),H=`${h.source}\0${h.target}`,O=r===H,he=`M ${a+$},${N} C ${a+150},${N} ${x-150},${P} ${x},${P}`,Z=g/2,q=(N+P)/2;return n.jsxs("g",{onMouseEnter:()=>i(H),onMouseLeave:()=>i(null),children:[n.jsx("path",{d:he,fill:"none",stroke:l[M%l.length],strokeWidth:Math.max(2,h.value/T*18),opacity:r===null||O?.7:.14,strokeLinecap:"round",style:{transition:"opacity 0.15s",cursor:"default"}}),O?n.jsxs("g",{pointerEvents:"none",children:[n.jsx("rect",{x:Z-72,y:q-18,width:144,height:36,rx:5,fill:o.cellBg,stroke:o.cellBorder}),n.jsxs("text",{x:Z,y:q-3,textAnchor:"middle",fontSize:9.5,fontFamily:o.font,fill:o.textSecondary,children:[h.source," → ",h.target]}),n.jsx("text",{x:Z,y:q+11,textAnchor:"middle",fontSize:11,fontWeight:700,fontFamily:o.fontMono,fill:o.textPrimary,children:E(h.value,v,e==null?void 0:e.format)})]}):null]},H)}),m.map((h,M)=>{const N=I(M,m.length);return n.jsxs("g",{children:[n.jsx("rect",{x:a,y:N-9,width:$,height:18,rx:3,fill:l[M%l.length]}),n.jsx("text",{x:a-7,y:N+3,textAnchor:"end",fontSize:10.5,fontFamily:o.font,fill:o.textSecondary,children:h.length>18?`${h.slice(0,17)}…`:h})]},`source-${h}`)}),d.map((h,M)=>{const N=I(M,d.length);return n.jsxs("g",{children:[n.jsx("rect",{x,y:N-9,width:$,height:18,rx:3,fill:l[(M+m.length)%l.length]}),n.jsx("text",{x:x+$+7,y:N+3,textAnchor:"start",fontSize:10.5,fontFamily:o.font,fill:o.textSecondary,children:h.length>18?`${h.slice(0,17)}…`:h})]},`target-${h}`)})]})})}function ut({result:t,themeMode:s,chartConfig:e}){const o=R[s],[l,r]=W.useState(null),{labelCol:i,valueCol:k}=G(t,e),A=t.rows.slice(0,15).map(a=>({label:String(a[i]??""),value:Number(a[k]??0)}));if(A.length===0)return null;let y=0;const j=A.map(a=>{const x=y;return y+=a.value,{...a,start:x,end:y}}),b=j.flatMap(a=>[a.start,a.end]),v=Math.min(0,...b),p=Math.max(0,...b)-v||1,u=560,S=240,m=52,d=16,c=16,z=44,F=u-m-d,T=S-c-z,g=F/j.length,_=a=>c+T-(a-v)/p*T;return n.jsx("div",{style:{padding:"8px 0"},children:n.jsxs("svg",{width:"100%",height:S,viewBox:`0 0 ${u} ${S}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:[Array.from({length:6},(a,x)=>{const $=v+p*x/5,f=_($);return n.jsxs("g",{children:[n.jsx("line",{x1:m,y1:f,x2:m+F,y2:f,stroke:o.tableBorder,strokeWidth:.5}),n.jsx("text",{x:m-6,y:f+4,textAnchor:"end",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:E($,k,e==null?void 0:e.format)})]},x)}),n.jsx("line",{x1:m,y1:_(0),x2:m+F,y2:_(0),stroke:o.textMuted,strokeWidth:1,strokeDasharray:"3,3"}),j.map((a,x)=>{const $=m+x*g,f=_(Math.max(a.start,a.end)),L=_(Math.min(a.start,a.end))-f,B=a.value>=0,h=l===x;return n.jsxs("g",{onMouseEnter:()=>r(x),onMouseLeave:()=>r(null),children:[x<j.length-1&&n.jsx("line",{x1:$+g-2,y1:_(a.end),x2:$+g+2,y2:_(a.end),stroke:o.textMuted,strokeWidth:1,strokeDasharray:"2,2"}),n.jsx("rect",{x:$+4,y:f,width:g-8,height:Math.max(L,1),rx:2,fill:B?o.success:o.error,opacity:h?1:.8,style:{transition:"opacity 0.1s"}}),h&&n.jsxs("text",{x:$+g/2,y:f-4,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textPrimary,children:[a.value>=0?"+":"",E(a.value,k,e==null?void 0:e.format)]})]},x)}),j.map((a,x)=>n.jsx("text",{x:m+x*g+g/2,y:S-6,textAnchor:"middle",fontSize:9,fontFamily:o.font,fill:o.textMuted,transform:`rotate(-20, ${m+x*g+g/2}, ${S-6})`,children:a.label.length>8?a.label.slice(0,7)+"…":a.label},x)),n.jsx("line",{x1:m,y1:c,x2:m,y2:c+T,stroke:o.tableBorder,strokeWidth:1}),n.jsx("line",{x1:m,y1:c+T,x2:m+F,y2:c+T,stroke:o.tableBorder,strokeWidth:1})]})})}function pt({result:t,themeMode:s,chartConfig:e}){const o=R[s],l=t.rows[0];if(!l)return null;const r=(e!=null&&e.y&&t.columns.includes(e.y)?e.y:void 0)??t.columns.find(_=>U(l[_]))??t.columns[0],i=Number(l[r]??0),k=(e==null?void 0:e.title)??r,A=i>100?i*1.2:100,y=Math.min(Math.max(i/A,0),1),j=120,b=110,v=80,w=Math.PI,p=0,u=w-(w-p)*y,S=j+v*Math.cos(w),m=b+v*Math.sin(w),d=j+v*Math.cos(u),c=b+v*Math.sin(u),z=y>.5?1:0,F=j+v*Math.cos(p),T=b+v*Math.sin(p),g=y<.33?o.error:y<.66?o.warning:o.success;return n.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"16px 24px"},children:n.jsxs("svg",{width:240,height:140,style:{display:"block",overflow:"visible"},children:[n.jsx("path",{d:`M ${S} ${m} A ${v} ${v} 0 1 1 ${F} ${T}`,fill:"none",stroke:o.tableBorder,strokeWidth:12,strokeLinecap:"round"}),y>0&&n.jsx("path",{d:`M ${S} ${m} A ${v} ${v} 0 ${z} 1 ${d} ${c}`,fill:"none",stroke:g,strokeWidth:12,strokeLinecap:"round"}),n.jsx("text",{x:j,y:b-4,textAnchor:"middle",fontSize:28,fontFamily:o.fontMono,fill:g,fontWeight:700,children:E(i,r,e==null?void 0:e.format)}),n.jsx("text",{x:j,y:b+16,textAnchor:"middle",fontSize:11,fontFamily:o.font,fill:o.textMuted,children:k})]})})}function mt(t,s,e,o){const l=Number(s);return s==null||typeof s!="number"&&isNaN(l)?s==null?"—":String(s):ne(t,s,e,{compact:Math.abs(l)>=1e5,format:o})}function ye({result:t,themeMode:s,chartConfig:e}){const o=R[s],l=D(e==null?void 0:e.colorPalette),r=t.rows[0];if(!r)return null;const i=e!=null&&e.y&&t.columns.includes(e.y)?e.y:t.columns.find(A=>U(r[A]))??t.columns[0],k=mt(i,r[i],t.rows.map(A=>A[i]),e==null?void 0:e.format);return n.jsx("div",{style:{containerType:"inline-size",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",padding:"8px 4px",boxSizing:"border-box",minWidth:0},children:n.jsx("span",{title:String(r[i]),style:{fontSize:"clamp(14px, 13cqw, 40px)",fontWeight:750,fontFamily:o.fontMono,color:l[0]??o.accent,lineHeight:1.1,maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k})})}function yt({config:t,columns:s,onChange:e,onClose:o,t:l}){const r={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 n.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:i=>i.stopPropagation(),children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsx("span",{style:{fontSize:11,fontWeight:600,color:l.textPrimary,fontFamily:l.font},children:"Chart Settings"}),n.jsx("button",{onClick:o,style:{background:"none",border:"none",color:l.textMuted,cursor:"pointer",fontSize:14},children:"×"})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Title",n.jsx("input",{value:t.title??"",onChange:i=>e({title:i.target.value||void 0}),placeholder:"Chart title",style:{...r,marginTop:2}})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["X-axis label",n.jsx("input",{value:t.xLabel??"",onChange:i=>e({xLabel:i.target.value||void 0}),placeholder:"Auto",style:{...r,marginTop:2}})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Y-axis label",n.jsx("input",{value:t.yLabel??"",onChange:i=>e({yLabel:i.target.value||void 0}),placeholder:"Auto",style:{...r,marginTop:2}})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Legend",n.jsxs("select",{value:t.legendPosition??"top",onChange:i=>e({legendPosition:i.target.value}),style:{...r,marginTop:2},children:[n.jsx("option",{value:"top",children:"Top"}),n.jsx("option",{value:"bottom",children:"Bottom"}),n.jsx("option",{value:"left",children:"Left"}),n.jsx("option",{value:"right",children:"Right"}),n.jsx("option",{value:"none",children:"Hidden"})]})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Color palette",n.jsx("select",{value:t.colorPalette??"default",onChange:i=>e({colorPalette:i.target.value}),style:{...r,marginTop:2},children:Object.keys(Q).map(i=>n.jsx("option",{value:i,children:i.charAt(0).toUpperCase()+i.slice(1)},i))})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Max items",n.jsx("input",{type:"number",value:t.maxItems??V,min:5,max:200,onChange:i=>e({maxItems:parseInt(i.target.value)||V}),style:{...r,marginTop:2}})]})]})}function kt({result:t,themeMode:s,chartConfig:e,onConfigChange:o}){const l=R[s],r=nt(t,e),[i,k]=W.useState(!1);return r==="kpi"?n.jsx(ye,{result:t,themeMode:s,chartConfig:e}):n.jsxs("div",{style:{position:"relative"},children:[(e==null?void 0:e.title)&&n.jsx("div",{style:{padding:"8px 12px 0",fontSize:13,fontWeight:600,color:l.textPrimary,fontFamily:l.font,textAlign:"center"},children:e.title}),o&&n.jsx("button",{onClick:()=>k(!i),title:"Chart settings",style:{position:"absolute",top:4,right:4,zIndex:50,background:i?`${l.accent}18`:"transparent",border:`1px solid ${i?l.accent:"transparent"}`,borderRadius:4,color:i?l.accent:l.textMuted,cursor:"pointer",fontSize:14,padding:"2px 6px",lineHeight:1},children:"⚙"}),i&&o&&n.jsx(yt,{config:e??{},columns:t.columns,onChange:A=>o(A),onClose:()=>k(!1),t:l}),ft(r,t,s,e)]})}function ft(t,s,e,o){const l=o!=null&&o.x&&s.columns.includes(o.x)?o.x:void 0,r=o!=null&&o.y&&s.columns.includes(o.y)?o.y:void 0,i=l||r?ht(s,l,r):s;switch(t){case"line":return n.jsx(ce,{result:i,themeMode:e,chartConfig:o});case"area":return n.jsx(ce,{result:i,themeMode:e,chartConfig:o,showArea:!0});case"bar":return n.jsx(oe,{result:i,themeMode:e,chartConfig:o});case"grouped-bar":return n.jsx(st,{result:i,themeMode:e,chartConfig:o});case"stacked-bar":return n.jsx(lt,{result:i,themeMode:e,chartConfig:o});case"scatter":return n.jsx(rt,{result:s,themeMode:e,chartConfig:o});case"pie":return n.jsx(de,{result:s,themeMode:e,chartConfig:o,isDonut:!1});case"donut":return n.jsx(de,{result:s,themeMode:e,chartConfig:o,isDonut:!0});case"heatmap":return n.jsx(at,{result:s,themeMode:e});case"histogram":return n.jsx(ct,{result:s,themeMode:e,chartConfig:o});case"funnel":return n.jsx(dt,{result:s,themeMode:e,chartConfig:o});case"sankey":return n.jsx(xt,{result:s,themeMode:e,chartConfig:o});case"waterfall":return n.jsx(ut,{result:s,themeMode:e,chartConfig:o});case"gauge":return n.jsx(pt,{result:s,themeMode:e,chartConfig:o});case"kpi":return n.jsx(ye,{result:s,themeMode:e,chartConfig:o});default:return n.jsx(J,{result:s,themeMode:e})}}function ht(t,s,e){const o=t.columns,l=[];s&&o.includes(s)&&l.push(s),e&&o.includes(e)&&l.push(e);for(const r of o)l.includes(r)||l.push(r);return l.join(",")===o.join(",")?t:{...t,columns:l,rows:t.rows.map(r=>{const i={};for(const k of l)i[k]=r[k];return i})}}function zt(t){return new Set(t.tiles.filter(s=>!s.error&&s.selectedByDefault).map(s=>s.id))}function _t({proposal:t,t:s,selected:e,onToggle:o,onCreate:l,busy:r,error:i,compact:k}){const A=t.tiles.filter(u=>!u.error),y=t.tiles.filter(u=>u.error),j=A.filter(u=>e.has(u.id)).length,b=A.filter(u=>e.has(u.id)&&u.certification==="ai_generated").length,v=A.filter(u=>e.has(u.id)&&u.certification==="reviewed_semantic").length,p=A.filter(u=>e.has(u.id)&&u.certification==="certified").length+v>0;return n.jsxs("div",{style:{display:"grid",gap:10},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[n.jsx("span",{style:{fontSize:12.5,fontWeight:800,color:s.textPrimary},children:"Proposed app content"}),n.jsxs("span",{style:{fontSize:11,color:s.textMuted},children:[t.coverage.certifiedTiles," certified",t.coverage.semanticTiles>0?` · ${t.coverage.semanticTiles} reviewed semantic`:"",t.coverage.generatedTiles>0?` · ${t.coverage.generatedTiles} AI-generated`:"",t.coverage.gaps>0?` · ${t.coverage.gaps} uncovered`:""]})]}),n.jsxs("div",{style:{display:"grid",gap:6},children:[A.map(u=>n.jsx(bt,{tile:u,t:s,checked:e.has(u.id),onToggle:()=>o(u.id),compact:k},u.id)),y.map(u=>n.jsxs("div",{style:{...fe(s),opacity:.75},children:[n.jsx(be,{size:13,color:s.warning,style:{flexShrink:0,marginTop:2}}),n.jsxs("div",{style:{minWidth:0,flex:1},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:s.textSecondary},children:u.title}),n.jsx("div",{style:{fontSize:11,color:s.textMuted,marginTop:1},children:u.error})]})]},u.id))]}),t.gaps.length>0?n.jsxs("div",{style:{display:"grid",gap:4},children:[n.jsx("div",{style:{fontSize:11,fontWeight:800,color:s.textMuted,textTransform:"uppercase",letterSpacing:"0.04em"},children:"Not covered yet"}),t.gaps.map(u=>n.jsxs("div",{style:{display:"flex",gap:7,alignItems:"flex-start",fontSize:11.5,color:s.textMuted},children:[n.jsx(ke,{size:12,style:{flexShrink:0,marginTop:2}}),n.jsx("span",{style:{lineHeight:1.4},children:u.question})]},u.id))]}):null,i?n.jsx("div",{style:{fontSize:12,color:s.error},children:i}):null,n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,flexWrap:"wrap"},children:[n.jsxs("button",{type:"button",className:"dql-hover",onClick:l,disabled:r||!p,style:St(s,p&&!r),children:[r?n.jsx(ve,{size:13,style:{animation:"dql-agent-run-spin 0.8s linear infinite"}}):n.jsx(je,{size:13}),n.jsx("span",{children:r?"Creating app…":`Create app (${j} tile${j===1?"":"s"})`})]}),n.jsx("span",{style:{fontSize:11,color:s.textMuted},children:p?v>0?`${v} semantic tile${v===1?"":"s"} will compile against the governed semantic layer at run time.`:b>0?`${b} AI-generated tile${b===1?"":"s"} will stay review-required until certified.`:"Nothing is created until you confirm.":"Select at least one certified block or reviewed semantic tile."})]})]})}function bt({tile:t,t:s,checked:e,onToggle:o,compact:l}){const[r,i]=W.useState(!1),k=t.certification==="certified",A=t.certification==="reviewed_semantic",y=!!(t.sql||t.answer||t.preview&&t.preview.rows.length>0);return n.jsxs("div",{style:fe(s),children:[n.jsx("input",{type:"checkbox",checked:e,onChange:o,"aria-label":`Include ${t.title}`,style:{marginTop:2,accentColor:s.accent,cursor:"pointer",flexShrink:0}}),n.jsxs("div",{style:{minWidth:0,flex:1},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[n.jsx("span",{style:{fontSize:12.5,fontWeight:750,color:s.textPrimary},children:t.title}),k?n.jsxs("span",{style:X(s.success),children:[n.jsx(ge,{size:10})," certified"]}):A?n.jsxs("span",{style:X(s.accent),children:[n.jsx(se,{size:10})," reviewed semantic"]}):n.jsxs("span",{style:X(s.warning),children:[n.jsx(se,{size:10})," AI-generated · needs review"]}),n.jsx("span",{style:{fontSize:10,color:s.textMuted},children:t.viz})]}),t.description&&!l?n.jsx("div",{style:{fontSize:11.5,color:s.textSecondary,marginTop:2,lineHeight:1.4},children:t.description}):null,t.question&&t.question!==t.title?n.jsxs("div",{style:{fontSize:11,color:s.textMuted,marginTop:2},children:["Answers: ",t.question]}):null,y?n.jsxs("button",{type:"button",onClick:()=>i(j=>!j),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:[r?n.jsx(Se,{size:11}):n.jsx(we,{size:11}),n.jsx($e,{size:11})," ",r?"Hide details":"Show SQL & preview"]}):null,r&&t.answer?n.jsx("div",{style:{fontSize:11.5,color:s.textSecondary,marginTop:5,lineHeight:1.4},children:t.answer}):null,r&&t.sql?n.jsx("pre",{style:gt(s),children:t.sql}):null,r&&t.preview&&t.preview.rows.length>0?n.jsx(vt,{preview:t.preview,t:s}):null]})]})}function vt({preview:t,t:s}){const e=t.columns.slice(0,5),o=t.rows.slice(0,5);return n.jsxs("div",{style:{marginTop:5,overflow:"auto",border:`1px solid ${s.headerBorder}`,borderRadius:6},children:[n.jsxs("table",{style:{borderCollapse:"collapse",fontSize:10.5,fontFamily:s.fontMono,width:"100%"},children:[n.jsx("thead",{children:n.jsx("tr",{children:e.map(l=>n.jsx("th",{style:{textAlign:"left",padding:"3px 8px",color:s.textMuted,borderBottom:`1px solid ${s.headerBorder}`,fontWeight:700,whiteSpace:"nowrap"},children:l},l))})}),n.jsx("tbody",{children:o.map((l,r)=>n.jsx("tr",{children:e.map(i=>n.jsx("td",{style:{padding:"3px 8px",color:s.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:160},children:jt(l[i])},i))},r))})]}),typeof t.rowCount=="number"&&t.rowCount>o.length?n.jsxs("div",{style:{fontSize:10,color:s.textMuted,padding:"3px 8px"},children:[t.rowCount," rows total"]}):null]})}function jt(t){return t==null?"":typeof t=="number"?Number.isInteger(t)?String(t):t.toFixed(2):String(t)}function fe(t){return{display:"flex",gap:9,alignItems:"flex-start",border:`1px solid ${t.cellBorder}`,background:t.cellBg,borderRadius:8,padding:"9px 11px"}}function X(t){return{display:"inline-flex",alignItems:"center",gap:3,border:`1px solid ${t}55`,color:t,background:`${t}12`,borderRadius:999,padding:"1px 7px",fontSize:9.5,fontWeight:800}}function gt(t){return{margin:"5px 0 0",maxHeight:140,overflow:"auto",border:`1px solid ${t.headerBorder}`,background:t.editorBg,borderRadius:6,padding:8,fontSize:10.5,fontFamily:t.fontMono,color:t.textSecondary,lineHeight:1.45,whiteSpace:"pre-wrap"}}function St(t,s){return{display:"inline-flex",alignItems:"center",gap:6,border:"none",borderRadius:8,padding:"8px 14px",fontSize:12.5,fontWeight:800,fontFamily:t.font,cursor:s?"pointer":"default",background:s?t.accent:`${t.accent}55`,color:"#fff"}}function Tt(t){const s=`dql.agent.threadId.${t}`,[e,o]=W.useState(()=>xe(s));W.useEffect(()=>{o(xe(s))},[s]);const l=W.useCallback(i=>{o(i);try{window.localStorage.setItem(s,i)}catch{}},[s]),r=W.useCallback(()=>{o(void 0);try{window.localStorage.removeItem(s)}catch{}},[s]);return{threadId:e,onThreadIdChange:l,resetThreadId:r}}function xe(t){try{return window.localStorage.getItem(t)??void 0}catch{return}}export{_t as A,At as C,ke as F,Mt as S,J as T,nt as a,kt as b,$t as c,$e as d,zt as e,ne as f,Fe as i,ft as r,Tt as u};
@@ -1,11 +1,11 @@
1
- import{g as a}from"./index-CDpukm0G.js";/**
1
+ import{c as a}from"./index-BTuliKhK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const o=[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]],r=a("graduation-cap",o);/**
6
+ */const c=[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]],r=a("graduation-cap",c);/**
7
7
  * @license lucide-react v0.563.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const c=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],t=a("user-round",c);export{r as G,t as U};
11
+ */const o=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],t=a("user-round",o);export{r as G,t as U};
@@ -1,4 +1,4 @@
1
- import{g as a}from"./index-CDpukm0G.js";/**
1
+ import{c as a}from"./index-BTuliKhK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,6 +1,6 @@
1
- import{g as e}from"./index-CDpukm0G.js";/**
1
+ import{c as e}from"./index-BTuliKhK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const o=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],r=e("workflow",o);export{r as W};
6
+ */const o=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],c=e("workflow",o);export{c as W};
@@ -1,4 +1,4 @@
1
- import{g as c}from"./index-CDpukm0G.js";/**
1
+ import{c}from"./index-BTuliKhK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,6 +1,6 @@
1
- import{g as o}from"./index-CDpukm0G.js";/**
1
+ import{c as o}from"./index-BTuliKhK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const e=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],c=o("x",e);export{c as X};
6
+ */const c=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],t=o("x",c);export{t as X};
@@ -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-CDpukm0G.js"></script>
10
+ <script type="module" crossorigin src="/assets/index-BTuliKhK.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>
@@ -1,8 +1,8 @@
1
1
  import { QueryExecutor, type ConnectionConfig, type DatabaseConnector, type QueryResult, type SQLParamSpec } from "@duckcodeailabs/dql-connectors";
2
- import { type SemanticRefResolutionOptions } from '@duckcodeailabs/dql-notebook';
2
+ import { type NotebookCell, type SemanticRefResolutionOptions } from '@duckcodeailabs/dql-notebook';
3
3
  import { type SemanticLayer, type MetricDefinition, type SemanticLayerProviderConfig, type DashboardDocument, type DashboardGridItem, type DQLManifest, type DqlArtifactReference, type ManifestBlock, type DomainInput } from '@duckcodeailabs/dql-core';
4
4
  import type { AgentRunner as LLMAgentRunner, ProviderId } from './llm/types.js';
5
- import { type JoinPatternCandidate, type AnalyticalFreshnessRequestV1, type AnalyticalFailedRunV1, type AgentAnswer, type ConversationTurnInput, type AgentSchemaTable, type RuntimeSchemaSnapshot, type ProposalResult, type ProposePlan, type ProposePlanCandidate, type ProposeConfigInput, type DomainContextEnvelope, type ResolveDomainContextInput, type AgentRun, type AgentRunExecutors, type AgentRunRequest } from '@duckcodeailabs/dql-agent';
5
+ import { type JoinPatternCandidate, type AnalyticalFreshnessRequestV1, type AnalyticalFailedRunV1, type AgentAnswer, type WarehouseSqlFailureV1, type ConversationTurnInput, type AgentSchemaTable, type RuntimeSchemaSnapshot, type ProposalResult, type ProposePlan, type ProposePlanCandidate, type ProposeConfigInput, type DomainContextEnvelope, type ResolveDomainContextInput, type AgentRun, type AgentRunExecutors, type AgentRunRequest } from '@duckcodeailabs/dql-agent';
6
6
  import type { NotebookResearchDqlArtifact } from '@duckcodeailabs/dql-project';
7
7
  import { type InvariantResult } from '@duckcodeailabs/dql-governance';
8
8
  import { type BlockStudioImportInputMode, type BlockStudioImportSource, type BlockStudioImportSourceKind, type DqlGenerationSession } from './block-studio-import.js';
@@ -179,6 +179,12 @@ export declare function shouldSynthesizeAgentRunAnswer(governedAnswer: Pick<Agen
179
179
  export declare function agentAnswerHasExecutionFailure(governedAnswer: Pick<AgentAnswer, 'executionError'>): boolean;
180
180
  /** Rebuild the immutable failed-run input from the artifact retained by API-007. */
181
181
  export declare function analyticalFailedRunFromAgentRun(run: AgentRun): AnalyticalFailedRunV1 | undefined;
182
+ /** Exact failed statement retained on an immutable run, if one exists. */
183
+ export declare function repairableSqlFromAgentRun(run: AgentRun): string | undefined;
184
+ /** Structured producer failure retained on the source run. */
185
+ export declare function warehouseFailureFromAgentRun(run: AgentRun): WarehouseSqlFailureV1 | undefined;
186
+ /** Permission, authentication, policy and unsafe-query failures are never AI-repaired. */
187
+ export declare function analyticalFailureAllowsDeterministicRetry(failure?: WarehouseSqlFailureV1): boolean;
182
188
  /**
183
189
  * Presentation projection of a run, for anything that SHIPS it — thread history
184
190
  * and the live SSE stream alike.
@@ -492,6 +498,42 @@ export declare function prepareLocalExecution(sql: string, connection: Connectio
492
498
  sql: string;
493
499
  connection: ConnectionConfig;
494
500
  };
501
+ export interface AnalyticalExecutionPreparation {
502
+ /** SQL supplied by the caller, before host-owned normalization. */
503
+ sourceSql: string;
504
+ /** SQL after internal graph identities have been decoded. */
505
+ decodedSql: string;
506
+ /** SQL after dbt macros and project-relative paths have been resolved. */
507
+ preparedSql: string;
508
+ /** Exact statement handed to the connector (may include a safe row bound). */
509
+ executedSql: string;
510
+ connection: ConnectionConfig;
511
+ rewrites: Array<{
512
+ from: string;
513
+ to: string;
514
+ }>;
515
+ rowBound?: AnalyticalRowBoundResult;
516
+ }
517
+ /**
518
+ * One host-owned SQL preparation boundary shared by Ask and Notebook.
519
+ *
520
+ * Surface-specific compilation happens before this function and surface policy
521
+ * (for example exploratory join proof) may run around it, but no analytical
522
+ * entrypoint may decode internal IDs, resolve dbt paths, enforce read-only
523
+ * execution, or append a preview bound differently anymore.
524
+ *
525
+ * Acceptance: API-003, API-006, API-007, EXP-001, E2E-014.
526
+ */
527
+ export declare function prepareAnalyticalExecutionSql(input: {
528
+ sql: string;
529
+ subject: string;
530
+ executor: QueryExecutor;
531
+ connection: ConnectionConfig;
532
+ projectRoot: string;
533
+ projectConfig: ProjectConfig;
534
+ enforceReadOnly?: boolean;
535
+ rowLimit?: number;
536
+ }): Promise<AnalyticalExecutionPreparation>;
495
537
  export interface DashboardFilterApplicationResult {
496
538
  sql: string;
497
539
  sqlParams: SQLParamSpec[];
@@ -630,6 +672,45 @@ export declare function prepareSemanticSql(sql: string, semanticLayer: SemanticL
630
672
  export declare function normalizeProjectConnection(connection: ConnectionConfig, projectRoot: string): ConnectionConfig;
631
673
  export declare function resolveProjectRelativeSqlPaths(sql: string, projectRoot: string, dataDir?: string): string;
632
674
  export declare function staticResponseCacheControl(filePath: string): string;
675
+ export declare function notebookCellRepairSql(cell: NotebookCell): string | undefined;
676
+ export declare function replaceNotebookDqlQueryForRepair(source: string, sql: string): string | undefined;
677
+ /**
678
+ * Notebook background repair is deliberately narrower than conversational
679
+ * repair. Access, policy, target, parameter, and dependency failures require a
680
+ * user decision; only query-shape failures may enter the one-attempt loop.
681
+ * Acceptance: API-006, API-007, UI-012, UI-013, SEC-004, E2E-014.
682
+ */
683
+ export declare function notebookFailureAllowsBackgroundRepair(input: {
684
+ code?: string;
685
+ message?: string;
686
+ }): boolean;
687
+ export declare function applyNotebookRepairRewrites(sql: string, rewrites: Array<{
688
+ from: string;
689
+ to: string;
690
+ }>): string;
691
+ export declare function restoreNotebookDqlParameterInterpolations(sql: string, parameters: SQLParamSpec[]): string;
692
+ /** Normalize DESCRIBE output across Snowflake, DuckDB, and PostgreSQL shapes. */
693
+ export declare function schemaColumnsFromDescribeRows(rows: Array<Record<string, unknown>>): Array<{
694
+ name: string;
695
+ type: string;
696
+ }>;
697
+ /** Parse dbt relation strings without letting relation text become SQL syntax. */
698
+ export declare function splitQualifiedRelationIdentifier(value: string): string[] | null;
699
+ export declare function buildDbtDatabaseSchemaTree(manifest: DQLManifest, limit?: number, physicalIds?: ReadonlySet<string>): Array<{
700
+ id: string;
701
+ label: string;
702
+ kind: 'schema' | 'table' | 'column';
703
+ path?: string;
704
+ type?: string;
705
+ children?: Array<{
706
+ id: string;
707
+ label: string;
708
+ kind: 'schema' | 'table' | 'column';
709
+ path?: string;
710
+ type?: string;
711
+ children?: unknown[];
712
+ }>;
713
+ }>;
633
714
  export declare function openBlockStudioDocument(projectRoot: string, relativePath: string, semanticLayer?: SemanticLayer): {
634
715
  path: string;
635
716
  source: string;
@@ -1052,6 +1133,13 @@ export declare function buildAgentSchemaContext(question: string, rows: unknown[
1052
1133
  * Returns null when nothing safe to ask about survives normalization.
1053
1134
  */
1054
1135
  export declare function buildNamedRelationProbeSql(relations: string[], maxRelations?: number): string | null;
1136
+ /**
1137
+ * Conservative fallback for deciding whether an unparsed statement still
1138
+ * needs DQL's structural join validation. Join-free SELECT syntax may be
1139
+ * newer than the local parser and can safely continue to the read-only
1140
+ * warehouse boundary; an unparsed join must never bypass relationship proof.
1141
+ */
1142
+ export declare function sqlMayContainJoin(sql: string): boolean;
1055
1143
  /**
1056
1144
  * Resolve a BARE internal graph identity (`source::orders` — a name with no
1057
1145
  * database or schema) against the warehouse.