@duckcodeailabs/dql-cli 1.12.11 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps-api.d.ts +151 -3
- package/dist/apps-api.d.ts.map +1 -1
- package/dist/apps-api.js +675 -97
- package/dist/apps-api.js.map +1 -1
- package/dist/args.d.ts +2 -0
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +3 -0
- package/dist/args.js.map +1 -1
- package/dist/assets/dql-notebook/assets/AgentAnswerCard-c8QUo6NH.js +5 -0
- package/dist/assets/dql-notebook/assets/{AgentLogPage-hzHqpD3-.js → AgentLogPage-D6fgEAEy.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildDialog-BQRWoxp9.js → AiBuildDialog-8miXFPse.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildResult-D9t_4sQl.js → AiBuildResult-DPJ_SI0R.js} +3 -3
- package/dist/assets/dql-notebook/assets/AiSidePanel-NVA6lZnn.js +6 -0
- package/dist/assets/dql-notebook/assets/AnalyticsHome-DgwnRW71.js +6 -0
- package/dist/assets/dql-notebook/assets/AppsView-B6LYUpgm.js +4578 -0
- package/dist/assets/dql-notebook/assets/BlockStudio--jNw9XUI.js +60 -0
- package/dist/assets/dql-notebook/assets/{BusinessArtifactView-CnTbFVGT.js → BusinessArtifactView-DtRMiaF4.js} +1 -1
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-DhBsLCYr.js +22 -0
- package/dist/assets/dql-notebook/assets/GitPage-CazC-eTR.js +7 -0
- package/dist/assets/dql-notebook/assets/GlobalAiRail-1Tgweuu2.js +1 -0
- package/dist/assets/dql-notebook/assets/GovernedContextPage-C7qGrH3d.js +16 -0
- package/dist/assets/dql-notebook/assets/{HelpDocsPage-CL0vbSER.js → HelpDocsPage-DMHPsVqP.js} +1 -1
- package/dist/assets/dql-notebook/assets/{HomePage-DzAucwBW.js → HomePage-DcSI4dnU.js} +1 -1
- package/dist/assets/dql-notebook/assets/LineageDAG-BJ6xz06u.js +1 -0
- package/dist/assets/dql-notebook/assets/{LineageDetailView-DdVH-nz6.js → LineageDetailView-8WrQm-MF.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDrawer-BvrVZNKY.js → LineageDrawer-hnqCW_t-.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineagePathBreadcrumb-CSut-zvm.js → LineagePathBreadcrumb-B4LZTUsl.js} +3 -3
- package/dist/assets/dql-notebook/assets/{MiniLineageGraph-zg_1wW3M.js → MiniLineageGraph-CotnRuxa.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewBlockModal-9cDletl-.js → NewBlockModal-DHn-CEEW.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewNotebookModal-V6de8L4d.js → NewNotebookModal-BPGp-8oq.js} +2 -2
- package/dist/assets/dql-notebook/assets/NotebookEditor-B0OTHM6W.js +195 -0
- package/dist/assets/dql-notebook/assets/ReadinessPage-CoOIpxWq.js +1 -0
- package/dist/assets/dql-notebook/assets/{SetupOnboarding-Bg-MjbC9.js → SetupOnboarding-DxK_mFzf.js} +2 -2
- package/dist/assets/dql-notebook/assets/{TrustBadge-DGuHB8kP.js → TrustBadge-ZuD5N5Ww.js} +1 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-duFXXNV_.js +88 -0
- package/dist/assets/dql-notebook/assets/{answer-to-notebook-BDzY4MuQ.js → answer-to-notebook-WAVAYjBv.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-left-IjlnAihE.js → arrow-left-L8odLbyN.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-right-BI4cXgOY.js → arrow-right-WIF1V9a9.js} +1 -1
- package/dist/assets/dql-notebook/assets/{book-open-text-i6xhxu_I.js → book-open-text-BpqWMa4m.js} +1 -1
- package/dist/assets/dql-notebook/assets/{bot-C6DE7Q6m.js → bot-CLR1V6dO.js} +1 -1
- package/dist/assets/dql-notebook/assets/{circle-x-BoAorVSm.js → circle-x-CQBOM0b0.js} +1 -1
- package/dist/assets/dql-notebook/assets/{dagre.esm-CycymVj6.js → dagre.esm-DlZi7NR3.js} +1 -1
- package/dist/assets/dql-notebook/assets/{external-link-ZwE5iHsX.js → external-link-DYqdQIGp.js} +1 -1
- package/dist/assets/dql-notebook/assets/{grip-vertical-Dnp2st8l.js → grip-vertical-HmUijbwN.js} +1 -1
- package/dist/assets/dql-notebook/assets/index-Cpx47jCH.js +634 -0
- package/dist/assets/dql-notebook/assets/{list-tree-Ced8e_S1.js → list-tree-DGKqCxmz.js} +1 -1
- package/dist/assets/dql-notebook/assets/{minimize-2-CBIAE0XH.js → minimize-2-C8dvqCxX.js} +1 -1
- package/dist/assets/dql-notebook/assets/{panel-right-open-po3bWSeL.js → panel-right-open-yuVkIo5n.js} +1 -1
- package/dist/assets/dql-notebook/assets/{rotate-ccw-B9v1LTJ0.js → rotate-ccw-Di0kRnrM.js} +1 -1
- package/dist/assets/dql-notebook/assets/{semantic-fields-B6ii0an0.js → semantic-fields-BMQV0li8.js} +1 -1
- package/dist/assets/dql-notebook/assets/sliders-horizontal-alebptlJ.js +6 -0
- package/dist/assets/dql-notebook/assets/{star-CO4tfaDq.js → star-CgCQbnXc.js} +1 -1
- package/dist/assets/dql-notebook/assets/{triangle-alert-BSdIu2El.js → triangle-alert-SyuSZ4ht.js} +1 -1
- package/dist/assets/dql-notebook/assets/upload-BPhfea_E.js +11 -0
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-Bnl9gWhj.js +28 -0
- package/dist/assets/dql-notebook/assets/{user-round-BfrV8U-W.js → user-round-J4PQHxo9.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wand-sparkles-BgTxZNBc.js → wand-sparkles-c4WDXTCk.js} +1 -1
- package/dist/assets/dql-notebook/assets/{workflow--2ycp0yy.js → workflow-NtRLaq7n.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wrench-LMCrpa9_.js → wrench-CS1f1Zv4.js} +1 -1
- package/dist/assets/dql-notebook/assets/{x-CeNgQwGm.js → x-CbKEfe5m.js} +1 -1
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/commands/model.d.ts.map +1 -1
- package/dist/commands/model.js +62 -1
- package/dist/commands/model.js.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/llm/providers/dql-agent-provider.d.ts +4 -3
- package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
- package/dist/llm/providers/dql-agent-provider.js +13 -10
- package/dist/llm/providers/dql-agent-provider.js.map +1 -1
- package/dist/local-operation-coordinator.d.ts +59 -0
- package/dist/local-operation-coordinator.d.ts.map +1 -0
- package/dist/local-operation-coordinator.js +256 -0
- package/dist/local-operation-coordinator.js.map +1 -0
- package/dist/local-runtime.d.ts +59 -1
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +2653 -342
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +12 -11
- package/dist/project-refresh-coordinator.d.ts +19 -0
- package/dist/project-refresh-coordinator.d.ts.map +1 -0
- package/dist/project-refresh-coordinator.js +134 -0
- package/dist/project-refresh-coordinator.js.map +1 -0
- package/dist/project-refresh-worker.d.ts +13 -0
- package/dist/project-refresh-worker.d.ts.map +1 -0
- package/dist/project-refresh-worker.js +58 -0
- package/dist/project-refresh-worker.js.map +1 -0
- package/package.json +13 -11
- package/dist/assets/dql-notebook/assets/AgentAnswerCard-CpL2kDCV.js +0 -5
- package/dist/assets/dql-notebook/assets/AiSidePanel-BCQB9rVF.js +0 -6
- package/dist/assets/dql-notebook/assets/AnalyticsHome-Ba4Ve_Gd.js +0 -6
- package/dist/assets/dql-notebook/assets/AppsView-CdAT9BOq.js +0 -4466
- package/dist/assets/dql-notebook/assets/BlockStudio-Brg4fwn5.js +0 -60
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-CQe2FUZq.js +0 -22
- package/dist/assets/dql-notebook/assets/GitPage-DHyDBChc.js +0 -7
- package/dist/assets/dql-notebook/assets/GlobalAiRail-Cys4n_rq.js +0 -1
- package/dist/assets/dql-notebook/assets/GovernedContextPage-DyKoDSZ2.js +0 -7
- package/dist/assets/dql-notebook/assets/LineageDAG-QHqd_AM5.js +0 -1
- package/dist/assets/dql-notebook/assets/NotebookEditor-EZ0pfWVs.js +0 -200
- package/dist/assets/dql-notebook/assets/ReadinessPage-BaGvjyfd.js +0 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-BlWAVEwO.js +0 -83
- package/dist/assets/dql-notebook/assets/chevron-up-DSEILnDs.js +0 -6
- package/dist/assets/dql-notebook/assets/index-BTuliKhK.js +0 -634
- package/dist/assets/dql-notebook/assets/link-2-CTKe6Snr.js +0 -6
- package/dist/assets/dql-notebook/assets/maximize-2-Cojc6867.js +0 -6
- package/dist/assets/dql-notebook/assets/pencil-Cb45c6WU.js +0 -6
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-CkVFrrjk.js +0 -18
package/dist/args.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export interface CLIFlags {
|
|
|
18
18
|
host?: string | null;
|
|
19
19
|
chart: string;
|
|
20
20
|
domain: string;
|
|
21
|
+
/** Model Area for context/model import authoring. */
|
|
22
|
+
area?: string;
|
|
21
23
|
/** Governed analytical purpose used to authorize exact cross-domain imports. */
|
|
22
24
|
purpose?: string;
|
|
23
25
|
owner: string;
|
package/dist/args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,CA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,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAoKpD"}
|
package/dist/args.js
CHANGED
|
@@ -83,6 +83,9 @@ export function parseArgs(argv) {
|
|
|
83
83
|
else if (arg === '--domain' && i + 1 < argv.length) {
|
|
84
84
|
flags.domain = argv[++i];
|
|
85
85
|
}
|
|
86
|
+
else if (arg === '--area' && i + 1 < argv.length) {
|
|
87
|
+
flags.area = argv[++i];
|
|
88
|
+
}
|
|
86
89
|
else if (arg === '--purpose' && i + 1 < argv.length) {
|
|
87
90
|
flags.purpose = argv[++i];
|
|
88
91
|
}
|
package/dist/args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAgGA,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,MAAM,KAAK,GAAa;QACtB,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,EAAE;QACT,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,SAAS,EAAE,KAAK;QAChB,IAAI,EAAE,KAAK;QACX,KAAK,E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IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{R as q,j as i,b3 as We,r as $,u as $t,t as Ct,a as Q}from"./index-Cpx47jCH.js";import{C as ce,b as Ke,T as Ze,a as Bt,f as At}from"./usePersistedAgentThreadId-Bnl9gWhj.js";import{T as zt}from"./TrustBadge-ZuD5N5Ww.js";import{R as Lt,G as Tt}from"./AiBuildResult-DPJ_SI0R.js";const Rt={value:"Value",block:"Certified block",term:"Business term",metric:"Metric",dimension:"Dimension",model:"dbt model",source:"Source table",consumer:"Used by"};function Oe(e){const t=(e??"").toLowerCase();return t==="certified"?"success":t==="deprecated"?"neutral":t.includes("review")||t==="draft"||t==="pending"?"warning":"neutral"}function Mt({walk:e,defaultOpen:t=!1,triggerLabel:r}){const[n,s]=q.useState(t),o=Math.min(e.steps.length,2),[a,d]=q.useState(o),u=()=>d(o),l=e.steps.slice(0,a),f=e.steps.length-a;return i.jsxs("div",{style:{border:"1px solid var(--border-subtle, rgba(127,127,127,0.25))",borderRadius:8,background:"var(--bg-1, transparent)",overflow:"hidden"},children:[i.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>{s(c=>!c),n&&u()},style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,border:0,background:"transparent",color:"var(--text-secondary, inherit)",cursor:"pointer",padding:"8px 11px",font:"inherit",fontSize:12,fontWeight:700},children:[i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:7},children:[i.jsx("span",{"aria-hidden":!0,style:{transform:n?"rotate(90deg)":"none",transition:"transform 120ms",display:"inline-block"},children:"▸"}),r??"Why?"]}),i.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary, inherit)",fontWeight:600},children:n?"Hide derivation":"Show how this was derived"})]}),n&&i.jsxs("div",{style:{padding:"2px 11px 11px",display:"flex",flexDirection:"column",gap:10},children:[i.jsx("div",{style:{fontSize:12.5,lineHeight:1.5,color:"var(--text-primary, inherit)"},children:e.summary}),(e.trustLabel||e.freshness)&&i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[e.trustLabel&&i.jsx(We,{tone:Oe(e.trustLabel),children:qe(e.trustLabel)}),e.freshness&&i.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary, inherit)"},children:["Fresh as of ",_t(e.freshness)]})]}),i.jsx("ol",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:7},children:l.map((c,p)=>i.jsxs("li",{style:{display:"flex",gap:9,alignItems:"flex-start",paddingLeft:2},children:[i.jsx("span",{"aria-hidden":!0,style:{marginTop:3,width:7,height:7,borderRadius:999,flexShrink:0,background:"var(--accent, currentColor)",opacity:.7}}),i.jsxs("div",{style:{minWidth:0,display:"flex",flexDirection:"column",gap:2},children:[i.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",flexWrap:"wrap"},children:[i.jsx("span",{style:{fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--text-tertiary, inherit)"},children:Rt[c.kind]}),i.jsx("span",{style:{fontSize:12.5,fontWeight:700,color:"var(--text-primary, inherit)",overflowWrap:"anywhere"},children:c.name}),c.status&&i.jsx(We,{tone:Oe(c.status),children:qe(c.status)})]}),(c.owner||c.detail)&&i.jsxs("div",{style:{fontSize:11.5,color:"var(--text-secondary, inherit)",lineHeight:1.45},children:[c.owner&&i.jsxs("span",{children:["Owner: ",c.owner,". "]}),c.detail]})]})]},`${c.kind}-${c.name}-${p}`))}),f>0&&i.jsxs("button",{type:"button",onClick:()=>d(c=>Math.min(e.steps.length,c+1)),style:{alignSelf:"flex-start",border:"1px solid var(--border-default, rgba(127,127,127,0.3))",borderRadius:6,background:"transparent",color:"var(--accent, inherit)",cursor:"pointer",padding:"4px 9px",fontSize:11,fontWeight:700},children:["Show next step (",f," more)"]}),e.caveats&&e.caveats.length>0&&i.jsxs("div",{style:{borderLeft:"3px solid var(--status-warning, #d29922)",background:"var(--status-warning-bg, rgba(210,153,34,0.08))",borderRadius:6,padding:"8px 10px",display:"flex",flexDirection:"column",gap:4},children:[i.jsx("span",{style:{fontSize:10,fontWeight:800,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--status-warning, inherit)"},children:"Caveats"}),e.caveats.map((c,p)=>i.jsx("span",{style:{fontSize:11.5,color:"var(--text-secondary, inherit)",lineHeight:1.45},children:c},p))]})]})]})}function qe(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function _t(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString()}const ue=/date|time|day|month|year|week|quarter|period|_at$|^at$/i,fe=/(?:^|_)(?:id|uuid|key|code)$/i,he=/(?:name|title|label|display|description|customer|account|product|region|segment|category|channel)$/i,It=new Set(["bar","grouped-bar","stacked-bar","line","area","scatter","pie","donut","heatmap","histogram","funnel","sankey","waterfall","gauge","kpi","table"]);function Pe(e){return typeof e=="number"?Number.isFinite(e):typeof e=="string"?e.trim()!==""&&Number.isFinite(Number(e)):!1}function et(e){const t=e.rows.slice(0,20);return t.length===0?[]:e.columns.filter(r=>t.some(n=>Pe(n[r]))&&t.every(n=>{const s=n[r];return s==null||s===""||Pe(s)}))}function Dt(e,t){const r=e.columns.filter(n=>!t.includes(n));return r.find(n=>he.test(n)&&!fe.test(n))??r.find(n=>!fe.test(n))??r[0]??e.columns[0]}function Wt(e){return e.columns.filter(t=>{if(!fe.test(t))return!1;const r=t.replace(/(?:_)?(?:id|uuid|key|code)$/i,"").replace(/_+$/,"");return e.columns.some(n=>n!==t&&(r.length>0&&n.toLowerCase().startsWith(r.toLowerCase())&&he.test(n)||r.length===0&&he.test(n)))})}function Ot(e,t){if(t.length===0)return e;const r=new Set(t);return{...e,columns:e.columns.filter(n=>!r.has(n)),rows:e.rows.map(n=>Object.fromEntries(Object.entries(n).filter(([s])=>!r.has(s))))}}function tt(e,t){const r=et(e),n=e.rows.length>0,s=e.columns.filter(g=>!r.includes(g));if(!(n&&r.length>=1))return{config:{...t??{},chart:"table",decisionSource:"data",rationale:"The returned rows do not contain a numeric measure to plot."},chartable:!1,reason:"No numeric measure"};const a=Dt(e,r),d=t!=null&&t.x&&e.columns.includes(t.x)?t.x:a,u=t!=null&&t.y&&e.columns.includes(t.y)?t.y:r.find(g=>g!==d)??r[0],l=Pt(e,r,s,d),f=qt(t==null?void 0:t.chart),c=t==null?void 0:t.decisionSource,p=c==="authored"||c==="user",x=p&&f||f&&Et(f,e,r,s,d,u)?f:l.chart,h=!!(f&&f!==x&&!p),b=t!=null&&t.color&&e.columns.includes(t.color)?t.color:x==="sankey"?s.find(g=>g!==d):t==null?void 0:t.color,j=h?`${l.reason}; replaced the agent suggestion because the returned data is not compatible.`:f&&!p?"Agent-selected visualization validated against the returned data.":l.reason;return{config:{...t??{},chart:x,x:d,y:u,...b?{color:b}:{},decisionSource:p?c:f&&!h?"agent":"data",rationale:j},chartable:x!=="table",reason:j}}function qt(e){if(typeof e!="string")return;const t=e.toLowerCase().replace(/_/g,"-").replace("single-value","kpi");return It.has(t)?t:void 0}function Pt(e,t,r,n){return e.rows.length===1&&t.length>=1?{chart:"kpi",reason:"Single returned value"}:ue.test(n)&&t.length>=1?{chart:"line",reason:`Time-like field ${n}`}:r.length>0&&t.length>=2?{chart:"grouped-bar",reason:"One category with multiple numeric measures"}:r.length>0&&t.length===1?{chart:"bar",reason:"Categorical comparison with one numeric measure"}:t.length>=2?{chart:"scatter",reason:"Two continuous numeric measures"}:{chart:"table",reason:"No comparable category or time axis was returned"}}function Et(e,t,r,n,s,o){return e==="table"?!0:e==="kpi"||e==="gauge"?r.length>=1&&t.rows.length===1:e==="line"||e==="area"?r.includes(o)&&ue.test(s):e==="scatter"?r.length>=2:e==="sankey"?n.length>=2&&r.length>=1:e==="histogram"?r.length>=1:e==="grouped-bar"||e==="stacked-bar"?n.length>=1&&r.length>=2:e==="pie"||e==="donut"?n.length>=1&&r.length>=1&&t.rows.length>=2&&t.rows.length<=8:e==="heatmap"?t.columns.length>=3&&r.length>=1:e==="funnel"||e==="waterfall"?n.length>=1&&r.length>=1:e==="bar"?n.length>=1&&r.length>=1&&!ue.test(s):!1}function Qn({result:e,themeMode:t,t:r,chartConfig:n,embedded:s=!1,tabLabels:o,contentMaxHeight:a,tableMaxHeight:d}){const u=e.rows.length===0,[l,f]=$.useState(),[c,p]=$.useState(!1),x=$.useMemo(()=>({...n??{},...l??{}}),[n,l]),{config:h,chartable:b}=tt(e,x),j=$.useMemo(()=>et(e),[e]),g=$.useMemo(()=>Wt(e),[e]),w=$.useMemo(()=>c?e:Ot(e,g),[g,e,c]),[v,L]=$.useState("table"),R=y=>({border:"none",background:"transparent",cursor:"pointer",fontFamily:r.font,fontSize:11,fontWeight:700,padding:"2px 4px",color:y?r.accent:r.textMuted,borderBottom:`2px solid ${y?r.accent:"transparent"}`}),V=ce.some(y=>y.value===h.chart)?h.chart:"bar";return i.jsxs("div",{style:{border:s?"none":`1px solid ${r.headerBorder}`,background:r.cellBg,borderRadius:s?0:8,overflow:"hidden"},children:[i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",padding:s?"9px 14px":"5px 9px",borderBottom:`1px solid ${r.headerBorder}`},children:[b&&i.jsx("button",{type:"button",onClick:()=>L("table"),style:R(v==="table"),children:(o==null?void 0:o.table)??"Table"}),b&&i.jsx("button",{type:"button",onClick:()=>L("chart"),style:R(v==="chart"),children:(o==null?void 0:o.chart)??"Chart"}),!b&&!u&&i.jsx("span",{style:{fontSize:11,fontWeight:700,color:r.textMuted},children:(o==null?void 0:o.table)??"Table"}),b&&v==="chart"?i.jsx("select",{value:V,onChange:y=>f(B=>({...B??{},chart:y.target.value,decisionSource:"user",rationale:"Selected manually."})),title:"Chart type",style:{fontFamily:r.font,fontSize:10.5,fontWeight:600,color:r.textSecondary,background:r.cellBg,border:`1px solid ${r.headerBorder}`,borderRadius:5,padding:"1px 4px",cursor:"pointer"},children:ce.map(y=>i.jsx("option",{value:y.value,children:y.label},y.value))}):null,b&&v==="chart"?i.jsxs(i.Fragment,{children:[i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:3,color:r.textMuted,fontSize:10.5},children:["X",i.jsx("select",{"aria-label":"X-axis field",value:h.x??"",onChange:y=>f(B=>({...B??{},x:y.target.value,decisionSource:"user",rationale:"Axis selected manually."})),style:{fontFamily:r.font,fontSize:10.5,color:r.textSecondary,background:r.cellBg,border:`1px solid ${r.headerBorder}`,borderRadius:5,padding:"1px 3px",cursor:"pointer",maxWidth:120},children:e.columns.map(y=>i.jsx("option",{value:y,children:y},y))})]}),j.length>0?i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:3,color:r.textMuted,fontSize:10.5},children:["Y",i.jsx("select",{"aria-label":"Y-axis field",value:h.y??"",onChange:y=>f(B=>({...B??{},y:y.target.value,decisionSource:"user",rationale:"Axis selected manually."})),style:{fontFamily:r.font,fontSize:10.5,color:r.textSecondary,background:r.cellBg,border:`1px solid ${r.headerBorder}`,borderRadius:5,padding:"1px 3px",cursor:"pointer",maxWidth:120},children:j.map(y=>i.jsx("option",{value:y,children:y},y))})]}):null,h.chart==="sankey"?i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:3,color:r.textMuted,fontSize:10.5},children:["Target",i.jsx("select",{"aria-label":"Sankey target field",value:h.color??"",onChange:y=>f(B=>({...B??{},color:y.target.value,decisionSource:"user",rationale:"Sankey target selected manually."})),style:{fontFamily:r.font,fontSize:10.5,color:r.textSecondary,background:r.cellBg,border:`1px solid ${r.headerBorder}`,borderRadius:5,padding:"1px 3px",cursor:"pointer",maxWidth:120},children:e.columns.filter(y=>!j.includes(y)&&y!==h.x).map(y=>i.jsx("option",{value:y,children:y},y))})]}):null]}):null,b&&v==="chart"&&h.rationale?i.jsxs("span",{title:h.rationale,style:{fontSize:10.5,color:r.textMuted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:230},children:["Smart chart · ",h.chart]}):null,i.jsxs("span",{style:{marginLeft:"auto",fontSize:10.5,color:r.textMuted,alignSelf:"center"},children:[e.rowCount??e.rows.length," rows"]})]}),i.jsx("div",{style:{padding:s?12:8,minHeight:b&&v==="chart"?200:void 0,maxHeight:a??(s?380:320),overflow:"auto"},children:u?i.jsxs("div",{style:{padding:"18px 8px",textAlign:"center",color:r.textMuted,fontSize:12},children:["The query ran successfully and matched 0 rows",e.columns.length>0?` (columns: ${e.columns.join(", ")})`:"","."]}):b&&v==="chart"?i.jsx(Ke,{result:e,themeMode:t,chartConfig:h,onConfigChange:y=>f(B=>({...B??{},...y,decisionSource:"user",rationale:"Adjusted manually."}))}):i.jsxs(i.Fragment,{children:[g.length>0?i.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:6},children:i.jsx("button",{type:"button",onClick:()=>p(y=>!y),style:{border:"none",background:"transparent",color:r.accent,cursor:"pointer",fontSize:10.5,padding:0},children:c?"Hide technical fields":"Show IDs"})}):null,i.jsx(Ze,{result:w,themeMode:t,maxHeight:d})]})})]})}const Ft=3;function Qt(e){const{business360:t,block:r,value:n,generated:s=!1}=e,o=e.maxPerKind??Ft,a=t.focus,d=[];n&&d.push({kind:"value",name:n,detail:a.name?`Reported by ${a.name}.`:void 0});const u=(r==null?void 0:r.owner)??a.owner,l=(r==null?void 0:r.status)??a.status,f=(r==null?void 0:r.reviewCadence)??oe(a.metadata,"reviewCadence");d.push({kind:"block",name:a.name,owner:u,status:l,detail:Nt({reviewCadence:f,businessOutcome:(r==null?void 0:r.businessOutcome)??oe(a.metadata,"businessOutcome"),decisionUse:r==null?void 0:r.decisionUse})});const c=Ee([...t.businessDefinition.terms,...t.businessDefinition.definedByTerms]);for(const h of c.slice(0,o))h.id!==a.id&&d.push({kind:"term",name:h.name,owner:h.owner,detail:"Business term this answer is defined in."});for(const h of se(r==null?void 0:r.metricRefs).slice(0,o))d.push({kind:"metric",name:h,detail:"Governed metric used in the calculation."});for(const h of se(r==null?void 0:r.dimensionRefs).slice(0,o))d.push({kind:"dimension",name:h,detail:"Dimension used to slice the value."});for(const h of t.technicalSources.dbtModels.slice(0,o))d.push({kind:"model",name:h.name,detail:"dbt model the certified SQL builds on."});const p=Ee([...t.technicalSources.dbtSources,...t.technicalSources.sourceTables]);for(const h of p.slice(0,o))d.push({kind:"source",name:h.name,detail:"Raw source table the data originates from."});const x=se((r==null?void 0:r.caveats)??Vt(a.metadata,"caveats"));return{value:n,summary:Ut({focus:a,blockOwner:u,reviewCadence:f,generated:s,sourceAssets:p}),steps:d,trustLabel:e.trustLabel??(s?"review_required":void 0),freshness:e.freshness??Ht(r==null?void 0:r.dataState,r==null?void 0:r.dataStateDetail)??oe(a.metadata,"freshness"),caveats:x.length>0?x:void 0}}function Ht(e,t){switch(e){case"failed":return t?`upstream failed — ${t}`:"upstream failed";case"stale":return t?`stale data — ${t}`:"stale data";default:return}}function Nt(e){const t=[];return e.businessOutcome?t.push(e.businessOutcome):e.decisionUse&&t.push(`Supports: ${e.decisionUse}.`),e.reviewCadence&&t.push(`Reviewed ${e.reviewCadence}.`),t.length>0?t.join(" "):void 0}function Ut(e){const t=e.blockOwner?` owned by ${e.blockOwner}`:"",r=e.sourceAssets.length>0?` It traces back to ${e.sourceAssets[0].name}.`:"";if(e.generated)return`This value was generated from ${e.focus.name}${t} and still needs analyst review before it can be certified.${r}`;const n=e.reviewCadence?`, reviewed ${e.reviewCadence}`:"";return`This value comes from the certified ${e.focus.name}${t}${n}.${r}`}function oe(e,t){const r=e==null?void 0:e[t];return typeof r=="string"&&r.trim().length>0?r:void 0}function Vt(e,t){const r=e==null?void 0:e[t];return Array.isArray(r)?r.filter(n=>typeof n=="string"&&n.trim().length>0):[]}function se(e){if(!e)return[];const t=new Set,r=[];for(const n of e){const s=typeof n=="string"?n.trim():"";!s||t.has(s.toLowerCase())||(t.add(s.toLowerCase()),r.push(s))}return r}function Ee(e){const t=new Set,r=[];for(const n of e)t.has(n.id)||(t.add(n.id),r.push(n));return r}function nt(e){var n,s;const t=e.dqlArtifact,r=(n=t==null?void 0:t.source)==null?void 0:n.trim();return r?{source:r,kind:t==null?void 0:t.kind,name:t==null?void 0:t.name,sourcePath:t==null?void 0:t.sourcePath,metrics:le(t==null?void 0:t.metrics),dimensions:le(t==null?void 0:t.dimensions),filters:((t==null?void 0:t.filters)??[]).map(o=>{var l,f;const a=(l=o.dimension)==null?void 0:l.trim(),d=((f=o.operator)==null?void 0:f.trim())||"equals",u=le(o.values);return!a||u.length===0?"":`${a} ${d} ${u.join(", ")}`}).filter(Boolean),timeDimension:(s=t==null?void 0:t.timeDimension)!=null&&s.name?[t.timeDimension.name,t.timeDimension.granularity].filter(Boolean).join(" / "):void 0,orderBy:((t==null?void 0:t.orderBy)??[]).map(o=>{var u,l;const a=(u=o.name)==null?void 0:u.trim(),d=(l=o.direction)==null?void 0:l.trim();return a&&d?`${a} ${d}`:""}).filter(Boolean),limit:typeof(t==null?void 0:t.limit)=="number"&&Number.isFinite(t.limit)?t.limit:void 0}:null}function Jt(e){for(let t=e.length-1;t>=0;t--){const r=e[t];if(r.kind!=="tool_result"||r.id!=="governed_answer")continue;const n=r.output;if(n&&typeof n=="object"&&"kind"in n)return n}return null}function le(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?t.trim():"").filter(Boolean):[]}function Gt(e){const t=e.result;if(!t||!Array.isArray(t.rows))return null;const n=(Array.isArray(t.columns)?t.columns:[]).map(o=>typeof o=="string"?o:o&&typeof o=="object"&&typeof o.name=="string"?String(o.name):String(o)),s=t.rows.filter(o=>!!(o&&typeof o=="object"&&!Array.isArray(o))).map(o=>o);return{columns:n,rows:s,rowCount:typeof t.rowCount=="number"?t.rowCount:s.length,executionTime:t.executionTime}}function Xt(e,t){const r=e&&typeof e=="object"?e:{},n=typeof r.chart=="string"?r.chart:void 0,s=r.decisionSource==="authored"||r.decisionSource==="agent"||r.decisionSource==="data"||r.decisionSource==="user"?r.decisionSource:void 0,o=n||(typeof t.suggestedViz=="string"?t.suggestedViz:void 0),a=o?o.toLowerCase().replace(/_/g,"-")==="single-value"?"kpi":o:void 0;return{...a?{chart:a}:{},...a?{decisionSource:s??(n?"authored":"agent")}:{},...typeof r.rationale=="string"?{rationale:r.rationale}:{},...typeof r.x=="string"?{x:r.x}:{},...typeof r.y=="string"?{y:r.y}:{},...typeof r.color=="string"?{color:r.color}:{},...typeof r.title=="string"?{title:r.title}:{}}}function Yt(e,t){return!t||t.columns.length===0?e:tt(t,e).config}function ae(e){if(typeof e!="string")return;const t=e.replace(/\s+/g," ").trim();if(t)return t.length>180?`${t.slice(0,177)}...`:t}function rt(e){const t=Kt(e,["Answer","Business summary","Summary"]);if(t)return Fe(t,340);const r=/^(?:reuse evidence|certified result preview|result preview|result summary|trust status|next action|recommended action|sql used by block|reusable block sql|proposed sql|sql generated|sql draft|evidence|parameters|lineage|technical lineage)\s*:/i,n=/^(?:SELECT|WITH|FROM|WHERE|GROUP BY|ORDER BY|LIMIT)\b/i,s=[];for(const a of e.split(/\r?\n/)){const d=a.trim();if(!(!d||/^#{1,6}\s*/.test(d)||/^```/.test(d)||/^\|/.test(d))&&!/^outcome\s*:/i.test(d)){if(r.test(d)||n.test(d)){if(s.length>0)break;continue}if(s.push(d),s.length>=5)break}}const o=s.join(" ").replace(/[*_`]+/g,"").replace(/\s+/g," ").trim();return Fe(o,340)}function Kt(e,t){var f,c,p;const r=e.split(/\r?\n/),n=t.map(x=>x.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),s=new RegExp(`^\\s*(?:#{1,6}\\s*)?(?:[-*]\\s*)?(?:\\*\\*)?(${n})(?:\\*\\*)?\\s*:\\s*(.*)$`,"i"),o=/^\s*(?:#{1,6}\s*)?(?:[-*]\s*)?(?:\*\*)?[A-Z][A-Za-z /-]{2,42}(?:\*\*)?\s*:/,a=r.findIndex(x=>s.test(x));if(a<0)return;const d=((p=(c=(f=r[a])==null?void 0:f.match(s))==null?void 0:c[2])==null?void 0:p.trim())??"",u=d?[d]:[];for(let x=a+1;x<r.length;x+=1){const h=r[x]??"";if(o.test(h)||/^\s*```/.test(h))break;h.trim()&&u.push(h.trim())}return u.join(" ").replace(/[*_`]+/g,"").replace(/\s+/g," ").trim()||void 0}function Fe(e,t){const r=e.replace(/\s+/g," ").trim();if(r.length<=t)return r;const n=r.slice(0,t-1),s=Math.max(n.lastIndexOf(". "),n.lastIndexOf("; "));if(s>100)return n.slice(0,s+1).trim();const o=n.lastIndexOf(" ");return`${n.slice(0,o>80?o:n.length).trim()}...`}function Zt({answer:e,themeMode:t,showSql:r=!0,compact:n=!1,addToAppTarget:s,sourceQuestion:o,onInvestigate:a,onInsertSql:d,onCreateBlock:u}){var we,ke,$e,Ce,Be,Ae,ze,Le,Te,Re,Me,_e,Ie;const l=Ct[t],{dispatch:f}=$t(),c=Gt(e),p=Xt((we=e.result)==null?void 0:we.chartConfig,e),[x,h]=$.useState(),b=Yt({...p??{},...x??{}},c),j=!!(c&&Bt(c,b)!=="table"),g=e.analysisPlan??((ke=e.evidence)==null?void 0:ke.analysisPlan),w=r?e.sql??(($e=e.result)==null?void 0:$e.sql)??e.proposedSql??(g==null?void 0:g.sql):void 0,v=nt(e),L=e.executionError??(((Be=(Ce=e.evidence)==null?void 0:Ce.execution)==null?void 0:Be.status)==="failed"?e.evidence.execution.message:void 0),R=((Ae=e.result)==null?void 0:Ae.blockPath)??((ze=e.block)==null?void 0:ze.sourcePath),V=!!(w||L||r&&R),y=!!e.evidence,[B,pe]=$.useState("answer"),[ct,xe]=$.useState(!1),[ge,ut]=$.useState(!1),me=dt(e),ye=zn(me,l),be=(e.answer??e.text??"").replace(/\n\n_Question:_[\s\S]*$/m,"").trim(),_=n?rt(be):be,k=((Le=e.result)==null?void 0:Le.blockName)??((Te=e.block)==null?void 0:Te.name)??((Me=(Re=e.citations)==null?void 0:Re.find(m=>m.kind==="block"))==null?void 0:Me.name),te=Mn(e,k),ft=Ln(e,c,k,R),[ht,ve]=$.useState(!1),[J,G]=$.useState(null),[je,pt]=$.useState(null),xt=!!(s&&(c||w||_||k)),gt=!!(d&&w),mt=!!(u&&w),P=ae(g==null?void 0:g.question)??ae(o)??ae(_)??"Investigate this answer",yt=!!(a&&P),bt=it(e,{sql:w,executionError:L,blockName:k,result:c}),vt=()=>{!d||!w||(d(w,k??(g==null?void 0:g.question)??"AI SQL preview",{question:o??(g==null?void 0:g.question)}),pt("Inserted SQL preview cell for review."))},jt=()=>{!u||!w||u(w,{title:(v==null?void 0:v.name)??k??(g==null?void 0:g.question)??"AI DQL draft",description:_||(g==null?void 0:g.routeReason)||"AI generated DQL draft.",tags:["ai-generated","review-required"]})},St=async(m="auto")=>{if(!s)return;const O=m==="both"?["chart","data"]:m==="data"?["data"]:m==="chart"?["chart"]:c?[j?"chart":"data"]:[];ve(!0),xe(!1),G(null);try{if(e.certification==="certified"&&k){const A=await Q.getDashboard(s.appId,s.dashboardId);if(!A)throw new Error("Dashboard could not be loaded.");const I=[...A.dashboard.layout.items],M=O.length>0?O:["chart"];for(const F of M){const Y=M.length>1?`${k}_${F}`:k,De={...A.dashboard,layout:{...A.dashboard.layout,items:I}},kt=Dn(De,Y);I.push({i:kt,...In(De),block:{blockId:k},viz:{type:F==="data"?"table":Wn(b==null?void 0:b.chart)},title:M.length>1?`${k} ${F==="data"?"data":"chart"}`:k})}const E={...A.dashboard.layout,items:I},T=await Q.patchDashboardLayout(s.appId,s.dashboardId,E);if(!T.ok)throw new Error(T.error);G(M.length>1?"Added certified chart and data tiles.":"Added certified block tile.")}else{const A=!!(w&&window.confirm("Keep this AI result refreshed daily?")),I=k??(_.slice(0,60)||"AI result"),M=O.length>0?O:["data"];let E=c??void 0;if(!E&&w){const T=await Q.previewGeneratedSql(w);if(!T.ok)throw new Error(`SQL preview failed: ${T.error}`);E=T.result}for(const T of M){const F=T==="data"?{...b??{},chart:"table",title:`${I} data`}:b,Y=await Q.createAiPin(s.appId,{dashboardId:s.dashboardId,title:M.length>1?`${I} ${T==="data"?"data":"chart"}`:I,answer:_||e.answer||e.text||"AI generated answer",question:g==null?void 0:g.question,sql:w,sourceTier:e.sourceTier,certification:e.certification==="certified"?"certified":"ai_generated",reviewStatus:"needs_review",refreshCadence:A?"daily":"none",chartConfig:F,result:E,citations:e.citations,analysisPlan:g,evidence:e.evidence,followUps:g==null?void 0:g.followUps});if(!Y.ok)throw new Error(Y.error)}G(M.length>1?"Pinned chart and data tiles for review.":"Pinned AI result for review.")}window.dispatchEvent(new CustomEvent("dql-app-dashboard-updated",{detail:s}))}catch(A){G(A instanceof Error?A.message:String(A))}finally{ve(!1)}},wt=()=>{!a||!P||a({question:P,title:te?`${te}: ${P}`:P,answerSummary:_,blockName:te,sql:w,evidence:e.evidence})},ne=[{id:"answer",label:n?"Summary":"Answer",visible:!0},{id:"dql",label:"DQL",visible:!!v},{id:"visual",label:n?"Chart":"Visualization",visible:j},{id:"data",label:"Data",visible:!!c},{id:"sql",label:"SQL / Block",visible:r&&V},{id:"lineage",label:n?"Trace":"Lineage",visible:y},{id:"context",label:n?"Context":"Business Context",visible:y},{id:"review",label:n?"Trust":"Review",visible:y||!!((_e=e.citations)!=null&&_e.length)}].filter(m=>m.visible),Se=ne.some(m=>m.id===B)?B:"answer",X=ne.filter(m=>m.id!=="answer"),re=X.some(m=>m.id===B)?B:(Ie=X[0])==null?void 0:Ie.id,ie=m=>m==="answer"?i.jsx(on,{summary:_,answer:e,blockName:k,evidence:e.evidence,analysisPlan:g,result:c,sourceTier:e.sourceTier,compact:n,t:l}):m==="dql"&&v?i.jsx(Sn,{artifact:v,t:l}):m==="visual"&&c&&j?i.jsxs("div",{style:{padding:n?"8px 10px":"10px 12px",minHeight:n?180:220,display:"grid",gap:10},children:[i.jsx($n,{result:c,chartConfig:b,t:l,onChange:O=>h(A=>({...A??{},...O,decisionSource:"user",rationale:"Adjusted manually."}))}),i.jsx(Ke,{result:c,themeMode:t,chartConfig:b})]}):m==="data"&&c?i.jsx("div",{style:{maxHeight:n?320:420,overflow:"auto"},children:i.jsx(Ze,{result:c,themeMode:t})}):m==="lineage"?i.jsx(bn,{evidence:e.evidence,t:l}):m==="context"?i.jsx(vn,{evidence:e.evidence,t:l}):m==="sql"&&r&&V?i.jsx(wn,{sql:w,blockPath:R,executionError:L,t:l}):m==="review"?i.jsx(jn,{answer:e,t:l}):null;return i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:n?8:10,whiteSpace:"normal"},children:[i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[i.jsx(zt,{state:me}),i.jsx(Lt,{t:l,route:e.route}),W(e.cascade)&&i.jsx("span",{style:{border:`1px solid ${l.cellBorder}`,borderRadius:999,padding:"3px 8px",fontSize:11,fontWeight:700,color:l.textSecondary,background:l.tableHeaderBg},children:W(e.cascade)}),!n&&k&&i.jsxs("span",{style:{fontSize:12,fontFamily:l.fontMono,color:l.textSecondary},children:["block: ",k]}),c&&i.jsxs("span",{style:{fontSize:12,color:l.textMuted},children:[(c.rowCount??c.rows.length).toLocaleString()," rows",c.executionTime!==void 0&&i.jsxs(i.Fragment,{children:[" - ",Math.round(c.executionTime),"ms"]})]}),xt&&i.jsx(Cn,{t:l,adding:ht,hasResult:!!c,hasChart:j,fallbackLabel:e.certification==="certified"&&k?n?"Add":"Add block":"Pin answer",open:ct,onToggle:()=>xe(m=>!m),onAdd:m=>void St(m)}),yt&&i.jsx("button",{type:"button",onClick:wt,style:{border:`1px solid ${l.accent}`,borderRadius:6,background:`${l.accent}12`,color:l.accent,cursor:"pointer",padding:n?"4px 8px":"5px 10px",fontSize:11,fontFamily:l.font,fontWeight:800},children:n?"Investigate":"Investigate deeper"}),mt&&i.jsx("button",{type:"button",onClick:jt,style:{border:`1px solid ${l.accent}`,borderRadius:6,background:l.cellBg,color:l.accent,cursor:"pointer",padding:n?"4px 8px":"5px 10px",fontSize:11,fontFamily:l.font,fontWeight:700},children:n?"DQL draft":v?"Review DQL draft":"Create DQL draft"}),gt&&i.jsx("button",{type:"button",onClick:vt,style:{border:`1px solid ${l.accent}`,borderRadius:6,background:`${l.accent}18`,color:l.accent,cursor:"pointer",padding:n?"4px 8px":"5px 10px",fontSize:11,fontFamily:l.font,fontWeight:700},children:n?"SQL preview":"Insert SQL preview"})]}),J&&i.jsx("div",{style:{fontSize:11,color:J.toLowerCase().includes("added")||J.toLowerCase().includes("pinned")?"#3fb950":"#ff7b72"},children:J}),je&&i.jsx("div",{style:{fontSize:11,color:"#3fb950"},children:je}),i.jsx(en,{outcome:bt,t:l,compact:n}),i.jsxs("div",{style:{border:`1px solid ${l.cellBorder}`,borderTop:`2px solid ${ye}`,borderRadius:n?10:6,overflow:"hidden",background:l.cellBg},children:[!n&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"4px 10px",borderBottom:`1px solid ${l.cellBorder}`,background:`${l.tableHeaderBg}70`,flexWrap:"wrap"},children:[ne.map(m=>i.jsx(Xe,{active:Se===m.id,label:m.label,onClick:()=>pe(m.id),t:l},m.id)),!r&&R&&i.jsx("span",{style:{marginLeft:"auto",minWidth:0,fontSize:11,fontFamily:l.fontMono,color:l.textMuted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:R})]}),ie(n?"answer":Se),n&&X.length>0&&i.jsxs("div",{style:{borderTop:`1px solid ${l.cellBorder}`,background:`${l.tableHeaderBg}45`},children:[i.jsxs("button",{type:"button",onClick:()=>ut(m=>!m),style:{width:"100%",border:0,background:"transparent",color:l.textSecondary,padding:"8px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",fontSize:11,fontWeight:800},children:[i.jsx("span",{children:"Details"}),i.jsx("span",{style:{color:l.textMuted,fontFamily:l.fontMono},children:ge?"hide":"show evidence"})]}),ge&&i.jsxs("div",{style:{borderTop:`1px solid ${l.cellBorder}`},children:[i.jsx("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"4px 12px",flexWrap:"wrap"},children:X.map(m=>i.jsx(Xe,{active:re===m.id,label:m.label,onClick:()=>pe(m.id),t:l},m.id))}),re?ie(re):null]})]}),i.jsx(kn,{items:ft,t:l,accent:ye}),i.jsx(Tt,{t:l,skills:e.appliedSkills,onOpenSkills:()=>f({type:"SET_MAIN_VIEW",view:"skills"}),onSuggestCorrection:m=>{try{window.sessionStorage.setItem("dql-skill-ai-correction",JSON.stringify({skillId:m.id,question:o,feedback:"Correct the guidance that shaped this answer."}))}catch{}f({type:"SET_MAIN_VIEW",view:"skills"})}})]})]})}function it(e,t){var r,n,s,o,a;if(e.kind==="no_answer")return{kind:"cannot_answer",label:"Cannot answer yet",detail:"The assistant did not find enough trusted context to safely answer or generate SQL.",nextAction:"Clarify the business object, metric, grain, or source table.",tone:"error"};if(e.certification==="certified"||e.kind==="certified"){const d=t.blockName??e.sourceCertifiedBlock??((r=e.block)==null?void 0:r.name);return{kind:"reuse_certified_block",label:"Reuse certified block",detail:d?`Existing DQL block ${d} answers this request.`:"A certified DQL artifact answers this request.",nextAction:"Use the certified block instead of creating duplicate SQL.",tone:"success"}}return t.executionError||e.executionError?{kind:"fix_sql",label:"Fix SQL",detail:"The generated or selected SQL needs correction before it can become reusable DQL.",nextAction:"Ask AI to repair, edit manually, then rerun preview.",tone:"error"}:(n=e.draftBlock)!=null&&n.path||e.draftBlockId?{kind:"use_existing_draft",label:"Use existing draft",detail:`A review-required DQL draft is available at ${((s=e.draftBlock)==null?void 0:s.path)??e.draftBlockId}.`,nextAction:"Open the draft, review metadata/tests/lineage, then certify manually.",tone:"accent"}:(a=(o=e.dqlArtifact)==null?void 0:o.source)!=null&&a.trim()?{kind:"create_dql_draft",label:"Review DQL draft",detail:"A review-required DQL artifact is available for analyst review.",nextAction:"Review DQL metadata, query logic, lineage, and result preview before certification.",tone:"warning"}:t.sql?{kind:t.result?"generate_sql_cell":"create_dql_draft",label:t.result?"Review SQL preview":"Create DQL draft",detail:t.result?`Review-required SQL preview returned ${(t.result.rowCount??t.result.rows.length).toLocaleString()} row${(t.result.rowCount??t.result.rows.length)===1?"":"s"}.`:"Review-required SQL is available but still needs preview and DQL metadata review.",nextAction:t.result?"Create a DQL draft after reviewing parameters and lineage; insert SQL only as a notebook preview.":"Run preview, inspect parameters, then create a draft block.",tone:"warning"}:{kind:"needs_review",label:"Needs review",detail:"The assistant returned business context but no executable certified answer or SQL draft.",nextAction:"Review evidence and ask for a specific SQL, reuse, or DQL draft action.",tone:"muted"}}function en({outcome:e,t,compact:r}){const n=tn(e.tone,t);return i.jsxs("div",{style:{border:`1px solid ${n}45`,borderLeft:`3px solid ${n}`,borderRadius:r?10:7,background:`${n}10`,padding:r?"9px 10px":"10px 12px",display:"grid",gap:r?4:5},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,minWidth:0},children:[i.jsx("span",{style:{border:`1px solid ${n}55`,background:`${n}14`,color:n,borderRadius:999,padding:"2px 7px",fontSize:10,fontWeight:850,lineHeight:1.1,textTransform:"uppercase",letterSpacing:0,flexShrink:0},children:e.label}),i.jsx("span",{style:{fontSize:r?12:12.5,color:t.textPrimary,fontWeight:750,overflow:"hidden",textOverflow:"ellipsis"},children:e.detail})]}),i.jsxs("div",{style:{fontSize:r?11.5:12,color:t.textSecondary,lineHeight:1.45},children:["Next: ",e.nextAction]})]})}function tn(e,t){switch(e){case"success":return t.success;case"accent":return t.accent;case"warning":return t.warning;case"error":return t.error;case"muted":default:return t.textMuted}}function nn({answer:e,blockName:t}){const[r,n]=$.useState(null),[s,o]=$.useState(!1),[a,d]=$.useState(!1),u=q.useCallback(async()=>{var l,f;if(!a){d(!0),o(!0);try{const c=await Q.fetchBusiness360(t);if(!c){n(null);return}const p=(l=e.evidence)==null?void 0:l.outcome,x=Qe(e,"metric"),h=Qe(e,"dimension"),b=e.certification!=="certified"&&e.kind!=="certified",j=Qt({business360:c,block:{name:t,owner:p==null?void 0:p.owner,status:((f=e.block)==null?void 0:f.status)??e.certification,reviewCadence:p==null?void 0:p.reviewCadence,caveats:p==null?void 0:p.caveats,decisionUse:p==null?void 0:p.decisionUse,metricRefs:x,dimensionRefs:h},value:rn(e),generated:b,trustLabel:e.trustLabel});n(j)}catch{n(null)}finally{o(!1)}}},[e,t,a]);return a?s?i.jsx("div",{style:{fontSize:11.5,color:"var(--text-tertiary, inherit)"},children:"Assembling derivation…"}):r?i.jsx(Mt,{walk:r,defaultOpen:!0}):null:i.jsx("button",{type:"button",onClick:()=>void u(),"aria-expanded":!1,style:{alignSelf:"flex-start",border:0,background:"transparent",color:"var(--accent, inherit)",cursor:"pointer",padding:"4px 0",fontSize:12,fontWeight:700,textDecoration:"underline",textUnderlineOffset:3},children:"Why? Show how this was derived"})}function Qe(e,t){var s,o;const r=(((s=e.evidence)==null?void 0:s.semanticObjects)??[]).filter(a=>a.kind===t).map(a=>a.name).filter(a=>!!a);if(r.length>0)return r;const n=e.analysisPlan??((o=e.evidence)==null?void 0:o.analysisPlan);return(t==="metric"?n==null?void 0:n.measures:n==null?void 0:n.dimensions)??[]}function rn(e){const t=e.result;if(t&&Array.isArray(t.rows)&&t.rows.length===1){const r=t.rows[0];if(r&&typeof r=="object"&&!Array.isArray(r)){const n=Object.values(r);if(n.length===1&&(typeof n[0]=="number"||typeof n[0]=="string"))return String(n[0])}}}function on({summary:e,answer:t,blockName:r,evidence:n,analysisPlan:s,result:o,sourceTier:a,compact:d,t:u}){var f,c,p,x,h,b,j,g,w;const l=(f=s==null?void 0:s.followUps)==null?void 0:f[0];return i.jsxs("div",{style:{padding:d?14:12,display:"flex",flexDirection:"column",gap:d?10:12},children:[e?i.jsx(ot,{text:e,t:u,compact:d,summaryOnly:d}):i.jsx("div",{style:{fontSize:12,color:u.textMuted},children:"No summary text was returned."}),t&&r&&i.jsx(nn,{answer:t,blockName:r}),d?i.jsx("div",{style:{fontSize:11.5,color:u.textMuted,display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[a?An(a):null,o?`${(o.rowCount??o.rows.length).toLocaleString()} rows`:null,((c=n==null?void 0:n.validation)==null?void 0:c.status)==="failed"?"needs review":null,((p=n==null?void 0:n.execution)==null?void 0:p.status)==="failed"?"data check failed":null].filter(Boolean).map((v,L)=>i.jsxs(q.Fragment,{children:[L>0&&i.jsx("span",{style:{color:u.cellBorder},children:"·"}),i.jsx("span",{children:v})]},`${v}-${L}`))}):i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[a&&i.jsx(z,{label:C(a),t:u}),o&&i.jsx(z,{label:`${(o.rowCount??o.rows.length).toLocaleString()} rows`,t:u}),((x=n==null?void 0:n.validation)==null?void 0:x.status)&&i.jsx(z,{label:`validation: ${n.validation.status}`,t:u}),((h=n==null?void 0:n.execution)==null?void 0:h.status)&&i.jsx(z,{label:`execution: ${n.execution.status}`,t:u})]}),o&&!d&&i.jsx(yn,{result:o,t:u,compact:d}),s&&!d&&i.jsxs("div",{style:{display:"grid",gap:7,padding:d?"9px 10px":10,border:`1px solid ${u.cellBorder}`,borderRadius:8,background:`${u.tableHeaderBg}45`},children:[s.routeReason&&i.jsx("div",{style:{fontSize:d?12.5:12,lineHeight:1.45,color:u.textSecondary},children:s.routeReason}),(s.grain||((b=s.measures)==null?void 0:b.length)||((j=s.dimensions)==null?void 0:j.length))&&i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[s.grain&&i.jsx(z,{label:`grain: ${s.grain}`,t:u}),(g=s.measures)==null?void 0:g.slice(0,2).map(v=>i.jsx(z,{label:v,t:u},`measure-${v}`)),(w=s.dimensions)==null?void 0:w.slice(0,2).map(v=>i.jsx(z,{label:v,t:u},`dimension-${v}`))]}),s.candidateJoins&&s.candidateJoins.length>0&&i.jsxs("div",{style:{fontSize:12,color:u.textMuted},children:["Join: ",i.jsx("span",{style:{color:u.textSecondary},children:at(s.candidateJoins[0])})]}),l&&i.jsxs("div",{style:{fontSize:12,color:u.textMuted},children:["Next: ",i.jsx("span",{style:{color:u.textSecondary},children:l})]})]})]})}function ot({text:e,t,compact:r=!1,summaryOnly:n=!1}){const s=n?rt(e):e,o=sn(s,t,r);return i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:r?7:8,color:t.textPrimary,fontFamily:t.font,overflowWrap:"anywhere"},children:o})}function sn(e,t,r){var d;const n=ln(e).split(`
|
|
2
|
+
`),s=[];let o=0,a=0;for(;o<n.length;){const l=n[o].trim();if(!l){o+=1;continue}if(l.startsWith("```")){const x=l.replace(/^```/,"").trim(),h=[];for(o+=1;o<n.length&&!n[o].trim().startsWith("```");)h.push(n[o]),o+=1;o<n.length&&(o+=1),s.push(i.jsx("pre",{style:mn(t,r),"aria-label":x?`${x} code`:"code",children:h.join(`
|
|
3
|
+
`)},`code-${a++}`));continue}const f=l.match(/^(#{1,4})\s+(.+)$/);if(f){const x=f[1].length;s.push(i.jsx("div",{style:hn(t,r,x),children:D(f[2],t)},`heading-${a++}`)),o+=1;continue}if(/^[-*_]{3,}$/.test(l)){s.push(i.jsx("hr",{style:{width:"100%",border:0,borderTop:`1px solid ${t.cellBorder}`,margin:r?"2px 0":"4px 0"}},`hr-${a++}`)),o+=1;continue}if(an(n,o)){const x=[];for(;o<n.length&&ee(n[o].trim());)x.push(n[o].trim()),o+=1;s.push(i.jsx(cn,{lines:x,t,compact:r},`table-${a++}`));continue}if(l.startsWith(">")){const x=[];for(;o<n.length&&n[o].trim().startsWith(">");)x.push(n[o].trim().replace(/^>\s?/,"")),o+=1;s.push(i.jsx("div",{style:Ne(t,r),children:D(x.join(" "),t)},`quote-${a++}`));continue}if(/^[-*+]\s+/.test(l)){const x=[];for(;o<n.length&&/^[-*+]\s+/.test(n[o].trim());)x.push(n[o].trim().replace(/^[-*+]\s+/,"")),o+=1;s.push(i.jsx("ul",{style:Ue(t,r),children:x.map((h,b)=>i.jsx("li",{style:Ve(t,r),children:D(h,t)},`${h}-${b}`))},`ul-${a++}`));continue}if(/^\d+\.\s+/.test(l)){const x=[];for(;o<n.length&&/^\d+\.\s+/.test(n[o].trim());)x.push(n[o].trim().replace(/^\d+\.\s+/,"")),o+=1;s.push(i.jsx("ol",{style:Ue(t,r),children:x.map((h,b)=>i.jsx("li",{style:Ve(t,r),children:D(h,t)},`${h}-${b}`))},`ol-${a++}`));continue}const c=[];for(;o<n.length;){const x=n[o].trim();if(!x||He(x)&&c.length>0||(c.push(x),o+=1,He(((d=n[o])==null?void 0:d.trim())??"")))break}const p=c.join(" ");s.push(i.jsx("div",{style:s.length===0&&un(p)?Ne(t,r):fn(t,r),children:D(p,t)},`p-${a++}`))}return s}function ln(e){return e.replace(/\r\n/g,`
|
|
4
|
+
`).replace(/\|\s+\|(?=[^\n]*\|)/g,`|
|
|
5
|
+
|`)}function He(e){return!!(e.startsWith("```")||/^(#{1,4})\s+/.test(e)||/^[-*_]{3,}$/.test(e)||ee(e)||e.startsWith(">")||/^[-*+]\s+/.test(e)||/^\d+\.\s+/.test(e))}function an(e,t){var s,o;const r=((s=e[t])==null?void 0:s.trim())??"",n=((o=e[t+1])==null?void 0:o.trim())??"";return ee(r)&&dn(n)}function ee(e){return e.startsWith("|")&&e.endsWith("|")&&N(e).length>=2}function dn(e){if(!ee(e))return!1;const t=N(e);return t.length>=2&&t.every(r=>/^:?-{3,}:?$/.test(r.replace(/\s+/g,"")))}function N(e){return e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim())}function cn({lines:e,t,compact:r}){const n=N(e[0]??""),s=N(e[1]??""),o=e.slice(2).map(N).filter(l=>l.length>0),a=Math.max(n.length,...o.map(l=>l.length),0);if(a===0)return null;const d=Array.from({length:a},(l,f)=>{var p;const c=((p=s[f])==null?void 0:p.replace(/\s+/g,""))??"";return c.startsWith(":")&&c.endsWith(":")?"center":c.endsWith(":")?"right":"left"}),u=Array.from({length:a},(l,f)=>n[f]??"");return i.jsx("div",{style:pn(t),children:i.jsxs("table",{style:xn(t,r),children:[i.jsx("thead",{children:i.jsx("tr",{children:u.map((l,f)=>i.jsx("th",{style:Je(t,r,!0,d[f]),children:D(l,t)},`h-${f}`))})}),i.jsx("tbody",{children:o.map((l,f)=>i.jsx("tr",{children:Array.from({length:a},(c,p)=>i.jsx("td",{style:Je(t,r,!1,d[p]),children:D(l[p]??"",t)},`c-${f}-${p}`))},`r-${f}`))})]})})}function un(e){return/\b(certified|uncertified|review[- ]required|draft|trusted|trust)\b/i.test(e)}function D(e,t){const r=[];let n=e,s=0;for(;n.length>0;){const o=n.match(/\*{3}(.+?)\*{3}/),a=n.match(/\*{2}(.+?)\*{2}/),d=n.match(/`([^`]+?)`/),u=n.match(/\[([^\]]+?)\]\((https?:\/\/[^)\s]+|\/[^)\s]+|#[^)\s]+)\)/),l=n.match(/\*([^\s*](?:.*?[^\s*])?)\*/),f=[o?{match:o,type:"boldItalic"}:null,a?{match:a,type:"bold"}:null,d?{match:d,type:"code"}:null,u?{match:u,type:"link"}:null,l?{match:l,type:"italic"}:null].filter(Boolean);if(f.length===0){r.push(i.jsx(q.Fragment,{children:n},`plain-${s++}`));break}const c=f.reduce((x,h)=>(x.match.index??0)<=(h.match.index??0)?x:h),p=c.match.index??0;p>0&&r.push(i.jsx(q.Fragment,{children:n.slice(0,p)},`plain-${s++}`)),c.type==="boldItalic"?r.push(i.jsx("strong",{style:{fontStyle:"italic",color:t.textPrimary},children:c.match[1]},`bi-${s++}`)):c.type==="bold"?r.push(i.jsx("strong",{style:{color:t.textPrimary},children:c.match[1]},`b-${s++}`)):c.type==="italic"?r.push(i.jsx("em",{children:c.match[1]},`i-${s++}`)):c.type==="code"?r.push(i.jsx("code",{style:gn(t),children:c.match[1]},`code-${s++}`)):c.type==="link"&&r.push(i.jsx("a",{href:c.match[2],target:"_blank",rel:"noopener noreferrer",style:{color:t.accent,textDecoration:"underline"},children:c.match[1]},`link-${s++}`)),n=n.slice(p+c.match[0].length)}return i.jsx(i.Fragment,{children:r})}function fn(e,t){return{color:e.textPrimary,fontSize:13,lineHeight:t?1.55:1.6}}function hn(e,t,r){return{color:e.textPrimary,fontSize:t?13:Math.max(13,15-r),fontWeight:800,lineHeight:1.35,marginTop:r<=2?2:0}}function Ne(e,t){return{color:e.textPrimary,fontSize:12.5,lineHeight:1.5,padding:t?"8px 9px":"9px 10px",border:`1px solid ${e.cellBorder}`,borderLeft:`3px solid ${e.accent}`,borderRadius:6,background:`${e.tableHeaderBg}55`}}function Ue(e,t){return{margin:0,paddingLeft:t?18:20,color:e.textPrimary,display:"grid",gap:t?4:5}}function Ve(e,t){return{color:e.textPrimary,fontSize:13,lineHeight:1.5,paddingLeft:2}}function pn(e){return{width:"100%",maxWidth:"100%",overflowX:"auto",border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.editorBg}}function xn(e,t){return{width:"100%",minWidth:t?360:420,borderCollapse:"collapse",color:e.textPrimary,fontSize:t?12:12.5,lineHeight:1.45}}function Je(e,t,r,n){return{padding:t?"6px 8px":"7px 9px",borderBottom:`1px solid ${e.cellBorder}`,color:r?e.textMuted:e.textPrimary,background:r?`${e.tableHeaderBg}75`:void 0,fontFamily:r?e.fontMono:e.font,fontSize:r?t?10.5:11:void 0,fontWeight:r?800:500,textAlign:n,whiteSpace:"nowrap",verticalAlign:"top"}}function gn(e){return{background:e.editorBg,border:`1px solid ${e.cellBorder}`,borderRadius:4,color:e.accent,fontFamily:e.fontMono,fontSize:"0.92em",padding:"1px 4px"}}function mn(e,t){return{margin:0,padding:t?9:10,overflow:"auto",maxHeight:t?220:280,borderRadius:6,background:e.editorBg,color:e.textPrimary,border:`1px solid ${e.cellBorder}`,fontSize:t?11.5:12,fontFamily:e.fontMono,lineHeight:1.5,whiteSpace:"pre"}}function yn({result:e,t,compact:r}){const n=(e.columns.length>0?e.columns:Object.keys(e.rows[0]??{})).slice(0,r?3:4),s=e.rows.slice(0,r?4:5);return n.length===0||s.length===0?null:i.jsxs("div",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:8,overflow:"hidden",background:t.editorBg},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:10,padding:"7px 9px",borderBottom:`1px solid ${t.cellBorder}`,color:t.textMuted,fontSize:11,fontFamily:t.fontMono,textTransform:"uppercase",letterSpacing:"0.06em"},children:[i.jsx("span",{children:"Preview"}),i.jsxs("span",{children:[s.length," of ",(e.rowCount??e.rows.length).toLocaleString()," rows"]})]}),i.jsx("div",{style:{overflowX:"auto"},children:i.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed"},children:[i.jsx("thead",{children:i.jsx("tr",{children:n.map(o=>i.jsx("th",{style:{textAlign:"left",padding:"7px 9px",color:t.textMuted,fontSize:11,fontFamily:t.fontMono,borderBottom:`1px solid ${t.cellBorder}`,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C(o)},o))})}),i.jsx("tbody",{children:s.map((o,a)=>i.jsx("tr",{children:n.map(d=>i.jsx("td",{style:{padding:"7px 9px",color:t.textPrimary,fontSize:r?12:12.5,borderBottom:a<s.length-1?`1px solid ${t.cellBorder}`:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Bn(d,o[d],s.map(u=>u[d]))},`${a}-${d}`))},a))})]})})]})}function bn({evidence:e,t}){const r=(e==null?void 0:e.lineage)??[];return r.length===0?i.jsx(lt,{t,children:"No lineage evidence was returned for this answer."}):i.jsx("div",{style:{padding:12,display:"flex",flexDirection:"column",gap:10},children:r.map((n,s)=>i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"20px 1fr",gap:8},children:[i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[i.jsx("div",{style:{width:8,height:8,borderRadius:8,marginTop:5,background:n.role==="question"?t.accent:t.textMuted}}),s<r.length-1&&i.jsx("div",{style:{width:1,flex:1,minHeight:18,background:t.cellBorder}})]}),i.jsxs("div",{style:{minWidth:0},children:[i.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",flexWrap:"wrap"},children:[i.jsx("span",{style:{fontSize:12,fontWeight:700,color:t.textPrimary},children:n.name??n.nodeId}),n.role&&i.jsx(z,{label:C(n.role),t}),n.kind&&i.jsx(z,{label:C(n.kind),t})]}),n.description&&i.jsx("div",{style:{fontSize:12,color:t.textSecondary,marginTop:3},children:n.description}),(n.sourcePath||n.provenance)&&i.jsxs("div",{style:{fontSize:11,color:t.textMuted,fontFamily:t.fontMono,marginTop:3,overflow:"hidden",textOverflow:"ellipsis"},children:[n.provenance??n.sourcePath,n.sourcePath&&n.provenance?` - ${n.sourcePath}`:""]})]})]},`${n.nodeId??n.name}-${s}`))})}function vn({evidence:e,t}){var s;const r=(e==null?void 0:e.businessContext)??[],n=e==null?void 0:e.outcome;return!n&&r.length===0?i.jsx(lt,{t,children:"No business context was returned for this answer."}):i.jsxs("div",{style:{padding:12,display:"flex",flexDirection:"column",gap:12},children:[n&&i.jsxs("div",{style:{display:"grid",gap:6},children:[i.jsx(U,{t,children:"Outcome"}),n.name&&i.jsx(S,{label:"Outcome",value:n.name,t}),n.owner&&i.jsx(S,{label:"Owner",value:n.owner,t}),n.decisionUse&&i.jsx(S,{label:"Decision Use",value:n.decisionUse,t}),n.reviewCadence&&i.jsx(S,{label:"Review Cadence",value:n.reviewCadence,t}),(s=n.caveats)==null?void 0:s.map((o,a)=>i.jsx(S,{label:"Caveat",value:o,t},`caveat-${a}`))]}),r.length>0&&i.jsxs("div",{style:{display:"grid",gap:6},children:[i.jsx(U,{t,children:"Context"}),r.map((o,a)=>i.jsx(S,{label:o.label??"Context",value:o.value??"",source:o.source,t},`${o.label}-${a}`))]}),(e==null?void 0:e.semanticObjects)&&e.semanticObjects.length>0&&i.jsx(Ge,{title:"Semantic Objects",assets:e.semanticObjects,t}),(e==null?void 0:e.sourceTables)&&e.sourceTables.length>0&&i.jsx(Ge,{title:"Source Tables",assets:e.sourceTables,t})]})}function jn({answer:e,t}){var o,a;const r=e.evidence,n=e.analysisPlan??(r==null?void 0:r.analysisPlan),s=(r==null?void 0:r.citations)??e.citations??[];return i.jsxs("div",{style:{padding:12,display:"flex",flexDirection:"column",gap:12},children:[i.jsxs("div",{style:{display:"grid",gap:6},children:[i.jsx(S,{label:"Certification",value:C(e.certification??e.kind),t}),W(e.cascade)&&i.jsx(S,{label:"Cascade",value:W(e.cascade)??"",t}),e.reviewStatus&&i.jsx(S,{label:"Review Status",value:C(e.reviewStatus),t}),typeof e.confidence=="number"&&i.jsx(S,{label:"Confidence",value:`${Math.round(e.confidence*100)}%`,t}),((o=r==null?void 0:r.validation)==null?void 0:o.message)&&i.jsx(S,{label:`Validation ${r.validation.status??""}`.trim(),value:r.validation.message,t}),((a=r==null?void 0:r.execution)==null?void 0:a.message)&&i.jsx(S,{label:`Execution ${r.execution.status??""}`.trim(),value:r.execution.message,t}),e.executionError&&i.jsx(S,{label:"Execution Error",value:e.executionError,t}),e.kind!=="certified"&&i.jsx(S,{label:"Promotion Path",value:"Create draft block, edit SQL, attach tests, then certify after analyst approval.",t})]}),n&&i.jsxs("div",{style:{display:"grid",gap:6},children:[i.jsx(U,{t,children:"Analysis Plan"}),n.question&&i.jsx(S,{label:"Question",value:n.question,t}),n.intent&&i.jsx(S,{label:"Intent",value:C(n.intent),t}),n.grain&&i.jsx(S,{label:"Grain",value:n.grain,t}),n.candidateTables&&n.candidateTables.length>0&&i.jsx(S,{label:"Tables",value:n.candidateTables.slice(0,5).map(d=>d.relation).filter(Boolean).join(", "),t}),n.candidateJoins&&n.candidateJoins.length>0&&i.jsx(S,{label:"Join Paths",value:n.candidateJoins.slice(0,3).map(at).join("; "),t}),n.assumptions&&n.assumptions.length>0&&i.jsx(S,{label:"Assumptions",value:n.assumptions.join(" "),t}),typeof n.repairAttempts=="number"&&n.repairAttempts>0&&i.jsx(S,{label:"SQL Repair",value:`${n.repairAttempts} retry`,t})]}),s.length>0&&i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx(U,{t,children:"Citations"}),s.slice(0,8).map((d,u)=>i.jsxs("div",{style:{fontSize:12,color:t.textSecondary,fontFamily:t.fontMono},children:[d.kind??"source",": ",d.name??"unknown",d.provenance&&i.jsxs("span",{style:{color:t.textMuted},children:[" (",d.provenance,")"]})]},`${d.kind}-${d.name}-${u}`))]})]})}function Ge({title:e,assets:t,t:r}){return i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx(U,{t:r,children:e}),t.map((n,s)=>i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,paddingBottom:4},children:[i.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",flexWrap:"wrap"},children:[i.jsx("span",{style:{fontSize:12,fontWeight:700,color:r.textPrimary},children:n.name??n.nodeId}),n.kind&&i.jsx(z,{label:C(n.kind),t:r}),n.certification&&i.jsx(z,{label:C(n.certification),t:r})]}),n.description&&i.jsx("div",{style:{fontSize:12,color:r.textSecondary},children:n.description}),(n.sourcePath||n.owner||n.domain)&&i.jsx("div",{style:{fontSize:11,color:r.textMuted,fontFamily:r.fontMono},children:[n.domain,n.owner,n.sourcePath].filter(Boolean).join(" - ")})]},`${n.nodeId??n.name}-${s}`))]})}function Sn({artifact:e,t}){const r=[e.kind?{label:"Kind",value:C(e.kind)}:null,e.name?{label:"Name",value:e.name}:null,e.sourcePath?{label:"Source Path",value:e.sourcePath}:null,e.metrics.length>0?{label:"Metrics",value:e.metrics.join(", ")}:null,e.dimensions.length>0?{label:"Dimensions",value:e.dimensions.join(", ")}:null,e.timeDimension?{label:"Time",value:e.timeDimension}:null,e.filters.length>0?{label:"Filters",value:e.filters.join("; ")}:null].filter(n=>!!n);return i.jsxs("div",{style:{padding:12,display:"flex",flexDirection:"column",gap:10},children:[r.length>0&&i.jsx("div",{style:{display:"grid",gap:6},children:r.map(n=>i.jsx(S,{label:n.label,value:n.value,t},n.label))}),i.jsx("pre",{style:st(t,340),children:e.source})]})}function wn({sql:e,blockPath:t,executionError:r,t:n}){return i.jsxs("div",{style:{padding:12,display:"flex",flexDirection:"column",gap:8},children:[t&&i.jsxs("div",{style:{fontSize:12,color:n.textSecondary},children:["Source block: ",i.jsx("span",{style:{fontFamily:n.fontMono,color:n.textPrimary},children:t})]}),r&&i.jsx("div",{style:{padding:10,border:"1px solid rgba(248, 81, 73, 0.35)",borderRadius:6,background:"rgba(248, 81, 73, 0.10)",color:"#ff7b72",fontSize:12,lineHeight:1.45,whiteSpace:"pre-wrap"},children:r}),e?i.jsx("pre",{style:st(n,260),children:e}):i.jsx("div",{style:{fontSize:12,color:n.textMuted},children:"No SQL text was returned for this answer."})]})}function st(e,t){return{margin:0,padding:10,overflow:"auto",maxHeight:t,borderRadius:4,background:e.editorBg,color:e.textPrimary,border:`1px solid ${e.cellBorder}`,fontSize:12,fontFamily:e.fontMono,whiteSpace:"pre"}}function S({label:e,value:t,source:r,t:n}){return t?i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"130px 1fr",gap:10,fontSize:12,alignItems:"baseline"},children:[i.jsx("span",{style:{color:n.textMuted},children:e}),i.jsxs("span",{style:{color:n.textSecondary},children:[t,r&&i.jsxs("span",{style:{color:n.textMuted},children:[" (",r,")"]})]})]}):null}function U({children:e,t}){return i.jsx("div",{style:{fontSize:11,fontWeight:700,fontFamily:t.fontMono,color:t.textMuted,textTransform:"uppercase",letterSpacing:"0.08em"},children:e})}function lt({children:e,t}){return i.jsx("div",{style:{padding:12,fontSize:12,color:t.textMuted},children:e})}function z({label:e,t}){return i.jsx("span",{style:{fontSize:11,fontFamily:t.fontMono,color:t.textSecondary,padding:"2px 6px",borderRadius:4,background:t.editorBg,border:`1px solid ${t.cellBorder}`},children:e})}function kn({items:e,t,accent:r}){return e.length===0?null:i.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 16px",alignItems:"center",padding:"7px 10px",borderTop:`1px solid ${t.cellBorder}`,boxShadow:`inset 0 2px 0 ${r}`,background:t.editorBg,color:t.textMuted,fontFamily:t.fontMono,fontSize:10.5},children:e.map(n=>i.jsxs("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[i.jsx("span",{style:{color:t.textMuted},children:n.label})," ",i.jsx("strong",{style:{color:t.textSecondary,fontWeight:600},children:n.value})]},`${n.label}-${n.value}`))})}function Xe({active:e,label:t,onClick:r,t:n}){return i.jsx("button",{onClick:r,style:{padding:"4px 2px",fontSize:11.5,border:0,borderBottom:`2px solid ${e?n.accent:"transparent"}`,borderRadius:0,background:"transparent",color:e?n.accent:n.textSecondary,fontWeight:e?700:500,cursor:"pointer"},children:t})}function $n({result:e,chartConfig:t,t:r,onChange:n}){const s=e.columns;if(s.length===0)return null;const o=ce.filter(l=>l.value!=="table"),a=t!=null&&t.x&&s.includes(t.x)?t.x:s[0]??"",d=t!=null&&t.y&&s.includes(t.y)?t.y:s.find(l=>l!==a)??s[0]??"",u=t!=null&&t.color&&s.includes(t.color)?t.color:"";return i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(130px, 1fr))",gap:8,alignItems:"end",border:`1px solid ${r.cellBorder}`,borderRadius:7,background:`${r.tableHeaderBg}55`,padding:10},children:[i.jsx(K,{label:"Chart type",t:r,children:i.jsx("select",{value:(t==null?void 0:t.chart)??"bar",onChange:l=>n({chart:l.target.value}),style:Z(r),children:o.map(l=>i.jsx("option",{value:l.value,children:l.label},l.value))})}),i.jsx(K,{label:"X axis",t:r,children:i.jsx("select",{value:a,onChange:l=>n({x:l.target.value}),style:Z(r),children:s.map(l=>i.jsx("option",{value:l,children:l},l))})}),i.jsx(K,{label:"Y axis",t:r,children:i.jsx("select",{value:d,onChange:l=>n({y:l.target.value}),style:Z(r),children:s.map(l=>i.jsx("option",{value:l,children:l},l))})}),i.jsx(K,{label:"Color",t:r,children:i.jsxs("select",{value:u,onChange:l=>n({color:l.target.value||void 0}),style:Z(r),children:[i.jsx("option",{value:"",children:"None"}),s.map(l=>i.jsx("option",{value:l,children:l},l))]})})]})}function K({label:e,t,children:r}){return i.jsxs("label",{style:{display:"grid",gap:4,minWidth:0},children:[i.jsx("span",{style:{fontSize:10.5,color:t.textMuted,fontWeight:800,textTransform:"uppercase",letterSpacing:0},children:e}),r]})}function Z(e){return{width:"100%",minWidth:0,height:30,border:`1px solid ${e.inputBorder}`,borderRadius:6,background:e.editorBg,color:e.textPrimary,fontFamily:e.font,fontSize:12,padding:"0 8px"}}function Cn({t:e,adding:t,hasResult:r,hasChart:n,fallbackLabel:s,open:o,onToggle:a,onAdd:d}){if(!r)return i.jsx("button",{type:"button",onClick:()=>d("auto"),disabled:t,style:{...Ye(e,t),marginLeft:"auto"},children:t?"Adding...":s});const u=n?[{mode:"both",label:"Chart + data",description:"Add chart and table tiles"},{mode:"chart",label:"Chart only",description:"Add the visualization tile"},{mode:"data",label:"Data table",description:"Add the rows as a table tile"}]:[{mode:"data",label:"Data table",description:"Add the rows as a table tile"}];return i.jsxs("div",{style:{marginLeft:"auto",position:"relative"},children:[i.jsxs("button",{type:"button",onClick:a,disabled:t,style:Ye(e,t),children:[t?"Adding...":"Add to App",!t&&i.jsx("span",{style:{marginLeft:6,fontSize:10},children:"v"})]}),o&&!t&&i.jsx("div",{style:{position:"absolute",right:0,top:"calc(100% + 6px)",zIndex:30,width:190,border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.cellBg,boxShadow:"0 14px 34px rgba(0, 0, 0, 0.18)",padding:6},children:u.map(l=>i.jsxs("button",{type:"button",onClick:()=>d(l.mode),style:{width:"100%",border:0,borderRadius:6,background:"transparent",color:e.textPrimary,textAlign:"left",padding:"8px 9px",cursor:"pointer"},children:[i.jsx("div",{style:{fontSize:12,fontWeight:700},children:l.label}),i.jsx("div",{style:{fontSize:11,color:e.textMuted,marginTop:2},children:l.description})]},l.mode))})]})}function Ye(e,t){return{border:`1px solid ${e.btnBorder}`,borderRadius:5,background:t?e.editorBg:`${e.accent}18`,color:t?e.textMuted:e.accent,padding:"4px 8px",fontSize:11,cursor:t?"default":"pointer"}}function C(e){return e.replace(/_/g," ")}function at(e){const t=[e.leftRelation,e.leftColumn].filter(Boolean).join("."),r=[e.rightRelation,e.rightColumn].filter(Boolean).join("."),n=[t,r].filter(Boolean).join(" to ");return e.reason?`${n} (${e.reason})`:n}function Bn(e,t,r){return t==null?"-":At(e,t,r)}function An(e){const t=e.toLowerCase();return t.includes("certified")?"trusted business context":t.includes("ai")||t.includes("generated")?"AI draft":t.includes("no_answer")?"needs more context":C(e)}function dt(e){var t;switch((t=e.trustLabelInfo)==null?void 0:t.id){case"certified":return"certified";case"reviewed":return"review";case"ai_generated":return"ai_generated";case"conflict":return"review";case"insufficient_context":return e.kind==="no_answer"?"no_answer":"uncertified"}return e.kind==="no_answer"?"no_answer":e.certification==="certified"||e.reviewStatus==="certified"?"certified":e.reviewStatus==="draft_ready"||e.reviewStatus==="analyst_review_required"?"review":e.certification==="ai_generated"?"ai_generated":e.certification==="analyst_review_required"||e.certification==="uncertified"?"uncertified":e.kind==="certified"?"certified":"draft"}function zn(e,t){return e==="certified"?t.success:e==="no_answer"?t.error:e==="deprecated"?t.textMuted:t.warning}function Ln(e,t,r,n){var u,l,f,c,p,x,h,b;const s=[],o=((l=(u=e.evidence)==null?void 0:u.selectedAssets)==null?void 0:l[0])??((c=(f=e.evidence)==null?void 0:f.lineage)==null?void 0:c.find(j=>j.owner||j.domain||j.sourcePath)),a=r??(o==null?void 0:o.name),d=n??(o==null?void 0:o.sourcePath)??(o==null?void 0:o.provenance);if(a&&s.push({label:e.kind==="certified"?"source":"draft source",value:a}),((o==null?void 0:o.owner)??((x=(p=e.evidence)==null?void 0:p.outcome)==null?void 0:x.owner))&&s.push({label:"owner",value:(o==null?void 0:o.owner)??((b=(h=e.evidence)==null?void 0:h.outcome)==null?void 0:b.owner)??""}),d&&s.push({label:"path",value:d}),e.sourceTier&&s.push({label:"tier",value:C(e.sourceTier)}),W(e.cascade)&&s.push({label:"cascade",value:W(e.cascade)??""}),t){const j=t.rowCount??t.rows.length,g=t.executionTime!==void 0?` - ${Math.round(t.executionTime)}ms`:"";s.push({label:"run",value:`${j.toLocaleString()} rows${g}`})}return e.reviewStatus&&e.reviewStatus!=="certified"&&s.push({label:"next",value:C(e.reviewStatus)}),_n(s).slice(0,5)}function W(e){if(!(e!=null&&e.terminalLane)&&!(e!=null&&e.routeTier))return;const t=Tn(e.terminalLane),r=Rn(e.routeTier);return[t,r].filter(Boolean).join(" · ")||void 0}function Tn(e){switch(e){case"certified":return"Lane 1 certified";case"semantic":return"Lane 2 semantic";case"generated":return"Lane 3 generated";case"refusal":return"Lane 4 refusal";default:return e?C(e):void 0}}function Rn(e){switch(e){case"certified_block":return"Certified block";case"semantic_metric":return"Semantic metric";case"generated_sql":return"Generated SQL";case"business_context":return"Business context";case"no_answer":return"No answer";default:return e?C(e):void 0}}function Mn(e,t){var r,n,s,o;return H(e.sourceCertifiedBlock)??de((r=e.evidence)==null?void 0:r.selectedAssets)??de((n=e.evidence)==null?void 0:n.lineage)??de(e.citations)??H((s=e.block)==null?void 0:s.name)??H((o=e.result)==null?void 0:o.blockName)??H(t)}function de(e){return e==null?void 0:e.map(t=>t.kind==="block"?H(t.name):void 0).find(t=>!!t)}function H(e){return typeof e!="string"?void 0:e.replace(/\s+/g," ").trim()||void 0}function _n(e){const t=new Set;return e.filter(r=>{const n=r.value.trim();if(!n)return!1;const s=`${r.label}:${n}`;return t.has(s)?!1:(t.add(s),!0)})}function In(e){return{x:0,y:e.layout.items.reduce((r,n)=>Math.max(r,n.y+n.h),0),w:6,h:3}}function Dn(e,t){const r=t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"tile",n=new Set(e.layout.items.map(s=>s.i));if(!n.has(r))return r;for(let s=2;s<1e3;s++){const o=`${r}-${s}`;if(!n.has(o))return o}return`${r}-${Date.now()}`}function Wn(e){const t=String(e??"table").toLowerCase().replace(/-/g,"_");return t==="single_value"||t==="kpi"||t==="line"||t==="bar"||t==="area"||t==="pie"||t==="donut"||t==="grouped_bar"||t==="stacked_bar"||t==="scatter"||t==="heatmap"||t==="histogram"||t==="waterfall"||t==="pivot"||t==="map"||t==="funnel"||t==="sankey"?t:"table"}const Hn=Object.freeze(Object.defineProperty({__proto__:null,AgentAnswerCard:Zt,StructuredAnswerText:ot,extractGovernedAnswer:Jt,formatCascadeOutcome:W,resolveAgentOutcome:it,resolveAnswerTrustState:dt,resolveDqlArtifactMeta:nt},Symbol.toStringTag,{value:"Module"}));export{Hn as A,Qn as R,ot as S,tt as d};
|
package/dist/assets/dql-notebook/assets/{AgentLogPage-hzHqpD3-.js → AgentLogPage-D6fgEAEy.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as x,t as m,j as n,G as y,
|
|
1
|
+
import{u as x,t as m,j as n,G as y,aH as j,r as b,f as k}from"./index-Cpx47jCH.js";import{A as S}from"./arrow-left-L8odLbyN.js";import{W as M}from"./wrench-CS1f1Zv4.js";import{C as v}from"./circle-x-CQBOM0b0.js";import"./react-CRB3T2We.js";function H(){const{state:e,dispatch:t}=x(),r=m[e.themeMode],s=e.agentLogRun;return s?n.jsxs("div",{style:{padding:"20px 28px",fontFamily:r.font,color:r.textPrimary,maxWidth:900,margin:"0 auto"},children:[n.jsxs("button",{type:"button",onClick:()=>t({type:"SET_MAIN_VIEW",view:"ask"}),style:C(r),children:[n.jsx(S,{size:14})," Back to Ask AI"]}),n.jsx(w,{run:s,t:r}),n.jsx(z,{run:s,t:r}),u(s).reason&&n.jsx(W,{run:s,t:r}),s.evaluations.length>0&&n.jsx(I,{run:s,t:r})]}):n.jsx("div",{style:{padding:32,color:r.textMuted,fontFamily:r.font},children:"No agent run selected. Open one from the “View steps” link on an AI answer."})}function w({run:e,t}){const r=f(e.startedAt,e.completedAt);return n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:{fontSize:18,fontWeight:600,marginBottom:8,lineHeight:1.35},children:e.question}),n.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[n.jsxs("span",{style:c(t),children:[n.jsx(y,{size:12})," ",p(e.route)]}),n.jsx("span",{style:N(t,e.trustState),children:_(e.trustState)}),r!=null&&n.jsxs("span",{style:c(t),children:[n.jsx(j,{size:12})," ",g(r)," total"]}),n.jsx("span",{style:{...c(t),color:t.textMuted},children:e.status})]})]})}function z({run:e,t}){const r=b.useMemo(()=>$(e),[e]),s=r.reduce((i,o)=>Math.max(i,o.deltaMs),0);return n.jsxs("section",{style:{marginBottom:22},children:[n.jsx(d,{t,children:"What the agent did · where the time went"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:r.map(i=>{const o=s>0&&i.deltaMs===s&&i.deltaMs>=250;return n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 10px",borderRadius:8,background:o?l(t.warning,.1):t.cellBg,border:`1px solid ${o?l(t.warning,.4):t.cellBorder}`},children:[n.jsx("span",{style:{marginTop:1,color:i.isTool?t.accent:t.textMuted,flexShrink:0},children:i.isTool?n.jsx(M,{size:13}):n.jsx("span",{style:{fontSize:13},children:"•"})}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:13,fontWeight:500},children:i.label}),i.detail&&n.jsx("div",{style:{fontSize:12,color:t.textMuted,marginTop:2,wordBreak:"break-word"},children:i.detail})]}),n.jsx("span",{style:{fontSize:12,fontFamily:t.fontMono,color:o?t.warning:t.textMuted,fontWeight:o?600:400,flexShrink:0,whiteSpace:"nowrap"},children:i.deltaMs>0?`+${g(i.deltaMs)}`:"—"})]},i.key)})}),s>=1e3&&n.jsx("div",{style:{fontSize:12,color:t.textMuted,marginTop:8},children:"The highlighted step took the longest. Long generation/tool steps usually mean the question fell through to LLM generation — a governed metric or certified block would answer it instantly."})]})}function W({run:e,t}){const r=u(e);return n.jsxs("section",{style:{marginBottom:22},children:[n.jsx(d,{t,children:"Why this route"}),n.jsxs("div",{style:{fontSize:13,color:t.textSecondary,lineHeight:1.5},children:[r.reason,typeof r.confidence=="number"&&n.jsxs("span",{style:{color:t.textMuted},children:[" · confidence ",(r.confidence*100).toFixed(0),"%"]})]})]})}function u(e){const t=e.routeDecision;return{reason:typeof(t==null?void 0:t.reason)=="string"?t.reason:void 0,confidence:typeof(t==null?void 0:t.confidence)=="number"?t.confidence:void 0}}function I({run:e,t}){return n.jsxs("section",{style:{marginBottom:22},children:[n.jsx(d,{t,children:"Governance checks"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.evaluations.map(r=>n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8,fontSize:13},children:[n.jsx("span",{style:{marginTop:1,color:r.passed?t.success:t.error,flexShrink:0},children:r.passed?n.jsx(k,{size:14}):n.jsx(v,{size:14})}),n.jsxs("div",{children:[n.jsx("span",{style:{fontWeight:500},children:r.label}),!r.passed&&r.message&&n.jsxs("span",{style:{color:t.textMuted},children:[" — ",r.message]})]})]},r.id))})]})}function d({t:e,children:t}){return n.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.6,color:e.textMuted,marginBottom:10},children:t})}function $(e){var i;const t=[...e.events].sort((o,a)=>o.at.localeCompare(a.at)),r=[];let s=e.startedAt??((i=t[0])==null?void 0:i.at);for(const o of t){const a=T(o);if(!a)continue;const h=f(s,o.at)??0;r.push({key:o.id,label:a,detail:A(o),deltaMs:h,isTool:B(o)}),s=o.at}return r}function B(e){const t=e.payload;return typeof(t==null?void 0:t.tool)=="string"}function T(e){switch(e.type){case"run.started":return"Started";case"route.decided":return`Routed to ${p(e.route)}`;case"plan.created":return"Planned the approach";case"step.started":return L(e)??"Working";case"executor.started":return R(e.route);case"evaluation.recorded":return"Checked grounding & trust";case"repair.attempted":return"Repaired and retried";case"replan.decided":return"Re-planned";case"escalated":return"Escalated to a deeper approach";case"artifact.created":return"Produced the answer";case"step.completed":return"Step complete";case"run.completed":return"Done";case"run.failed":return"Failed";default:return null}}function A(e){const t=e.payload;if(typeof(t==null?void 0:t.tool)=="string")return`tool: ${t.tool}`;if(e.type==="route.decided"||e.type==="run.failed")return e.message||void 0}function L(e){var r;const t=(r=e.payload)==null?void 0:r.goal;return t?`Working on: ${D(t,80)}`:null}function R(e){switch(e){case"certified_answer":return"Searching certified blocks & governed metrics";case"generated_answer":return"Composing the answer (semantic compile → generation)";case"research":return"Researching across governed data";case"app_build":return"Assembling the app";case"sql_cell":return"Writing the query";case"dql_block_draft":return"Drafting the block";case"modeling_draft":return"Drafting modeling changes";case"skill_draft":return"Drafting Skill guidance";case"conversation":return"Replying";default:return"Working"}}function p(e){return e?e.replace(/_/g," "):"the answer"}function _(e){return String(e).replace(/_/g," ")}function f(e,t){if(!e||!t)return null;const r=Date.parse(e),s=Date.parse(t);return Number.isNaN(r)||Number.isNaN(s)?null:Math.max(0,s-r)}function g(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(e<1e4?1:0)}s`}function D(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function l(e,t){const r=e.trim(),s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(r);if(!s)return e;let i,o,a;return s[1].length===3?(i=parseInt(s[1][0]+s[1][0],16),o=parseInt(s[1][1]+s[1][1],16),a=parseInt(s[1][2]+s[1][2],16)):(i=parseInt(s[1].slice(0,2),16),o=parseInt(s[1].slice(2,4),16),a=parseInt(s[1].slice(4,6),16)),`rgba(${i}, ${o}, ${a}, ${t})`}function C(e){return{display:"inline-flex",alignItems:"center",gap:6,marginBottom:16,background:"transparent",border:"none",cursor:"pointer",color:e.textMuted,fontSize:13,fontFamily:e.font,padding:0}}function c(e){return{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,padding:"3px 9px",borderRadius:999,background:e.pillBg,border:`1px solid ${e.cellBorder}`,color:e.textSecondary}}function N(e,t){const r=t==="certified"?e.success:t==="blocked"?e.error:e.accent;return{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,padding:"3px 9px",borderRadius:999,background:l(r,.12),border:`1px solid ${l(r,.4)}`,color:r,fontWeight:500}}export{H as AgentLogPage};
|
package/dist/assets/dql-notebook/assets/{AiBuildDialog-BQRWoxp9.js → AiBuildDialog-8miXFPse.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u,t as f,r as a,j as o,S as h,m as b}from"./index-
|
|
1
|
+
import{u,t as f,r as a,j as o,S as h,m as b}from"./index-Cpx47jCH.js";import{s as g}from"./ai-build-bus-1BR770pY.js";import{u as y,A as k}from"./AiBuildResult-DPJ_SI0R.js";import{X as j}from"./x-CbKEfe5m.js";import"./react-CRB3T2We.js";import"./user-round-J4PQHxo9.js";import"./triangle-alert-SyuSZ4ht.js";import"./rotate-ccw-Di0kRnrM.js";function z(){const{state:n,dispatch:c}=u(),t=f[n.themeMode],[e,l]=a.useState(null),p=y();if(a.useEffect(()=>g(i=>l(i)),[]),!e)return null;const s=()=>l(null),m=i=>{const r=i.trim();if(!r)return;const d=b("sql",r);d.name="ai_sql_preview",c({type:"ADD_CELL",cell:d})},x=(i,r)=>{p(i,r).finally(s)};return o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Ask AI to build",style:v,children:o.jsxs("div",{style:{width:"min(720px, calc(100vw - 32px))",maxHeight:"min(760px, calc(100vh - 64px))",background:t.appBg,border:`1px solid ${t.headerBorder}`,borderRadius:12,boxShadow:"0 24px 80px rgba(0,0,0,0.34)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 14px",borderBottom:`1px solid ${t.headerBorder}`},children:[o.jsx("div",{style:{width:30,height:30,borderRadius:8,background:`${t.accent}16`,border:`1px solid ${t.accent}38`,color:t.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto"},children:o.jsx(h,{size:16,strokeWidth:2.2})}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:{fontSize:14,fontWeight:850,color:t.textPrimary,fontFamily:t.font},children:e.mode==="edit"?"Ask AI to modify a block":"Ask AI to build a block"}),o.jsx("div",{style:{fontSize:11.5,color:t.textMuted,fontFamily:t.font,marginTop:1},children:e.sourceLabel??(e.mode==="edit"?"Describe the change and review a before/after diff. Nothing is certified.":"Generate a draft from your dbt + semantic context. Nothing is certified.")})]}),o.jsx("button",{type:"button",onClick:s,title:"Close",style:{width:28,height:28,borderRadius:6,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:o.jsx(j,{size:15,strokeWidth:2})})]}),o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto"},children:o.jsx(k,{themeMode:n.themeMode,initialTarget:e.target,lockTarget:e.lockTarget,initialPrompt:e.prompt,context:e.context,initialMode:e.mode,initialBlockPath:e.blockPath,onInsertCell:m,onOpenBlock:x},`${e.target}:${e.mode??"create"}:${e.blockPath??""}:${e.prompt??""}:${e.sourceLabel??""}`)})]})})}const v={position:"fixed",inset:0,zIndex:60,background:"rgba(0,0,0,0.32)",display:"flex",alignItems:"center",justifyContent:"center",padding:16};export{z as AiBuildDialog};
|
package/dist/assets/dql-notebook/assets/{AiBuildResult-D9t_4sQl.js → AiBuildResult-DPJ_SI0R.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as M,u as U,r as u,a as E,j as t,B as Q,t as Ce,S as V,L as
|
|
1
|
+
import{c as M,u as U,r as u,a as E,j as t,B as Q,t as Ce,S as V,L as oe,a5 as Be,ap as Fe,f as K,b as se,T as re,d as le,e as ae,R as de}from"./index-Cpx47jCH.js";import{U as ce,G as pe}from"./user-round-J4PQHxo9.js";import{T as ue}from"./triangle-alert-SyuSZ4ht.js";import{R as Y}from"./rotate-ccw-Di0kRnrM.js";/**
|
|
2
2
|
* @license lucide-react v0.563.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -28,6 +28,6 @@ import{c as M,u as U,r as u,a as E,j as t,B as Q,t as Ce,S as V,L as se,a1 as Be
|
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const qe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],A=M("square-plus",qe),Ee={cell:"Cell",block:"Block"};function
|
|
31
|
+
*/const qe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],A=M("square-plus",qe),Ee={cell:"Cell",block:"Block"};function ot({themeMode:e,initialTarget:n="cell",lockTarget:i=!1,initialPrompt:d="",context:s,onInsertCell:p,onOpenBlock:a,quickActions:x,initialMode:f="create",initialBlockPath:c}){const r=Ce[e],{dispatch:o}=U(),y=u.useCallback(()=>{o({type:"SET_MAIN_VIEW",view:"skills"})},[o]),[g,R]=u.useState(f==="edit"?"block":n),[k,L]=u.useState(d),[z,v]=u.useState("idle"),[m,j]=u.useState(null),[W,b]=u.useState(null),[C,Se]=u.useState(null),[ve,D]=u.useState(!1),T=u.useRef(""),[S,we]=u.useState(f),[B,X]=u.useState(c),[I,ze]=u.useState(void 0);u.useEffect(()=>{let l=!1;return E.getIdentity().then(h=>{!l&&(h!=null&&h.owner)&&Se(h.owner)}).catch(()=>{}),()=>{l=!0}},[]);const P=u.useCallback(async(l,h)=>{const O=l.trim();if(!O)return;const te=h==="block"&&S==="edit";if(!(te&&!B)){T.current=O,v("building"),b(null),D(!1);try{const _=await E.aiBuild({prompt:O,context:s,target:h,...C?{owner:C}:{},...h==="block"?{mode:S}:{},...te&&B?{blockPath:B}:{},...I?{domain:I}:{}});j(_),v("ready")}catch(_){b(_ instanceof Error&&_.message?_.message:"Could not build that. Try rewording the request."),j(null),v("error")}}},[s,C,S,B,I]),ee=u.useCallback(()=>{P(k,g)},[k,P,g]),We=u.useCallback(l=>{const h=l.target&&!i?l.target:g;l.target&&!i&&R(l.target),L(l.prompt),P(l.prompt,h)},[i,P,g]),H=u.useCallback(()=>{v("idle"),j(null),b(null),D(!1),!k.trim()&&T.current&&L(T.current)},[k]),$=u.useCallback(()=>{j(null),b(null),D(!1),v("idle")},[]),F=z==="building",q=g==="block"&&S==="edit",N=q&&!B;return t.jsx("div",{style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",overflow:"auto"},children:t.jsxs("div",{style:{padding:12,display:"grid",gap:10},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx("div",{role:"group","aria-label":"Build target",style:ne(r),children:["cell","block"].map(l=>{const h=g===l;return t.jsxs("button",{type:"button",disabled:i&&!h,onClick:()=>{i||(R(l),$())},"aria-pressed":h,style:ie(r,h,i&&!h),children:[l==="cell"?t.jsx(A,{size:13,strokeWidth:2}):t.jsx(Q,{size:13,strokeWidth:2}),Ee[l]]},l)})}),t.jsx("span",{style:{fontSize:11,color:r.textMuted,fontFamily:r.font},children:g==="cell"?"Create a review-required SQL preview for a notebook cell.":S==="edit"?"Rewrite an existing draft DQL block.":"Generate a reusable draft DQL block."}),C&&t.jsxs("span",{title:"Drafts are attributed to you",style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:5,fontSize:11,color:r.textMuted,fontFamily:r.font},children:[t.jsx(ce,{size:12,strokeWidth:2}),"drafting as ",C]})]}),g==="block"?t.jsx(Ke,{t:r,value:I,onChange:ze}):null,g==="block"?t.jsxs("div",{style:{display:"grid",gap:8},children:[t.jsx("div",{role:"group","aria-label":"Block build mode",style:ne(r),children:["create","edit"].map(l=>{const h=S===l;return t.jsxs("button",{type:"button",onClick:()=>{we(l),$(),l==="create"&&X(void 0)},"aria-pressed":h,style:ie(r,h,!1),children:[l==="create"?t.jsx(A,{size:13,strokeWidth:2}):t.jsx(xe,{size:13,strokeWidth:2}),l==="create"?"New block":"Modify existing"]},l)})}),S==="edit"?t.jsx(Ve,{t:r,selectedPath:B,onSelect:l=>{X(l),$()}}):null]}):null,x&&x.length>0?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:x.map(l=>t.jsxs("button",{type:"button",disabled:F,onClick:()=>We(l),style:{...w(r),opacity:F?.6:1},children:[t.jsx(V,{size:12,strokeWidth:2})," ",l.label]},l.label))}):null,t.jsxs("div",{style:{display:"grid",gap:7},children:[t.jsx("textarea",{value:k,onChange:l=>L(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.metaKey||l.ctrlKey)&&(l.preventDefault(),ee())},rows:3,placeholder:g==="cell"?'Describe the preview SQL you want, e.g. "monthly revenue by region for the last 12 months".':S==="edit"?'Describe the change, e.g. "add a 12-month trailing window and exclude test accounts".':'Describe the reusable block, e.g. "active customers by signup cohort".',style:Ze(r)}),s!=null&&s.cellSql?t.jsxs("div",{style:{fontSize:10.5,color:r.textMuted,fontFamily:r.font},children:["Using the active SQL cell",s.selection?" and your selection":""," as context."]}):null,N?t.jsx("div",{style:{fontSize:10.5,color:r.textMuted,fontFamily:r.font},children:"Pick the block you want to modify above."}):null,t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:t.jsxs("button",{type:"button",onClick:ee,disabled:F||!k.trim()||N,style:{...J(r),opacity:F||!k.trim()||N?.6:1},children:[F?t.jsx(oe,{size:13,strokeWidth:2}):t.jsx(Ie,{size:13,strokeWidth:2}),F?q?"Updating…":"Building…":q?"Update block":"Build"]})})]}),z==="error"&&t.jsx(Ye,{t:r,message:W??"Could not build that.",onRefine:H}),z==="ready"&&(m==null?void 0:m.target)==="cell"&&t.jsx(Te,{t:r,sql:m.sql,explanation:m.explanation,appliedSkills:m.appliedSkills,diagnostics:m.diagnostics,route:m.route,inserted:ve,onInsert:()=>{p==null||p(m.sql),D(!0)},onRefine:H,onDiscard:$,onOpenSkills:y}),z==="ready"&&(m==null?void 0:m.target)==="block"&&t.jsx(He,{t:r,result:m,owner:C,editing:q,onOpen:()=>a==null?void 0:a(m.path,m.name),onRefine:H,onDiscard:$,onOpenSkills:y})]})})}function Ae(){return{heading:"SQL preview",badge:"Review-required",guidance:"Use this as a notebook preview. For reusable governed analytics, promote the reviewed logic into a DQL draft.",insertLabel:"Insert preview",insertedLabel:"Preview inserted"}}function Te({t:e,sql:n,explanation:i,appliedSkills:d,diagnostics:s,route:p,inserted:a,onInsert:x,onRefine:f,onDiscard:c,onOpenSkills:r}){const o=Ae();return t.jsxs("section",{style:Z(e),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx(V,{size:14,strokeWidth:2,color:e.accent}),t.jsx("div",{style:{fontSize:12.5,fontWeight:800,color:e.textPrimary,fontFamily:e.font},children:o.heading}),t.jsx("span",{style:je(e),children:o.badge}),t.jsx(ge,{t:e,route:p})]}),i?t.jsx("div",{style:{fontSize:12,color:e.textSecondary,lineHeight:1.5,fontFamily:e.font},children:i}):null,t.jsx("div",{style:{fontSize:11.5,color:e.textMuted,lineHeight:1.45,fontFamily:e.font},children:o.guidance}),t.jsx(me,{t:e,code:n}),t.jsx(he,{t:e,skills:d,onOpenSkills:r}),t.jsx(ye,{t:e,diagnostics:s}),t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:x,disabled:a,style:{...J(e),opacity:a?.65:1},children:[a?t.jsx(K,{size:13,strokeWidth:2}):t.jsx(A,{size:13,strokeWidth:2}),a?o.insertedLabel:o.insertLabel]}),t.jsxs("button",{type:"button",onClick:f,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine"]}),t.jsxs("button",{type:"button",onClick:c,style:w(e),children:[t.jsx(re,{size:13,strokeWidth:2})," Discard"]})]})]})}function He({t:e,result:n,owner:i,editing:d,onOpen:s,onRefine:p,onDiscard:a,onOpenSkills:x}){const[f,c]=u.useState(!1),{name:r,description:o,sqlPreview:y,grain:g,outputs:R,examples:k,certifierVerdict:L,appliedSkills:z,diagnostics:v,route:m,previousSql:j}=n,W=d||typeof j=="string";return t.jsxs("section",{style:Z(e),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx(Q,{size:14,strokeWidth:2,color:e.accent}),t.jsx("div",{style:{fontSize:13,fontWeight:850,color:e.textPrimary,fontFamily:e.font},children:r}),t.jsx("span",{style:je(e),children:W?"AI-edited · draft":"AI-generated · draft"}),g?t.jsxs("span",{style:Je(e),children:["grain ",g]}):null,t.jsx(ge,{t:e,route:m})]}),o?t.jsx("div",{style:{fontSize:12,color:e.textSecondary,lineHeight:1.5,fontFamily:e.font},children:o}):null,W&&typeof j=="string"?t.jsx(Oe,{t:e,previousSql:j,nextSql:y}):t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>c(b=>!b),style:ke(e),children:[f?t.jsx(le,{size:13,strokeWidth:2}):t.jsx(ae,{size:13,strokeWidth:2}),f?"Hide SQL this block will run":"Show SQL this block will run"]}),f?t.jsx("div",{style:{marginTop:7},children:t.jsx(me,{t:e,code:y})}):null]}),R.length>0?t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"Outputs"}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:R.map(b=>t.jsx("span",{style:Xe(e),children:b},b))})]}):null,k.length>0?t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"Answers questions like"}),t.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:3},children:k.slice(0,3).map(b=>t.jsx("li",{style:{fontSize:11.5,color:e.textSecondary,lineHeight:1.45,fontFamily:e.font},children:b},b))})]}):null,t.jsx(Qe,{t:e,verdict:L}),t.jsx(he,{t:e,skills:z,onOpenSkills:x}),t.jsx(ye,{t:e,diagnostics:v}),i?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsx(ce,{size:12,strokeWidth:2})," drafting as ",i]}):null,t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:s,style:J(e),children:[W?t.jsx(xe,{size:13,strokeWidth:2}):t.jsx(Q,{size:13,strokeWidth:2}),W?"Update block in Block Studio":"Open in Block Studio"]}),t.jsxs("button",{type:"button",onClick:p,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine"]}),t.jsxs("button",{type:"button",onClick:a,style:w(e),children:[t.jsx(re,{size:13,strokeWidth:2})," Discard"]})]})]})}function Ne(e,n){const i=e.replace(/\s+$/g,"").split(`
|
|
32
32
|
`),d=n.replace(/\s+$/g,"").split(`
|
|
33
|
-
`),o=i.length,p=d.length,a=Array.from({length:o+1},()=>new Array(p+1).fill(0));for(let r=o-1;r>=0;r--)for(let s=p-1;s>=0;s--)a[r][s]=i[r]===d[s]?a[r+1][s+1]+1:Math.max(a[r+1][s],a[r][s+1]);const x=[];let f=0,c=0;for(;f<o&&c<p;)i[f]===d[c]?(x.push({kind:"context",text:i[f]}),f++,c++):a[f+1][c]>=a[f][c+1]?(x.push({kind:"remove",text:i[f]}),f++):(x.push({kind:"add",text:d[c]}),c++);for(;f<o;)x.push({kind:"remove",text:i[f]}),f++;for(;c<p;)x.push({kind:"add",text:d[c]}),c++;return x}function Oe({t:e,previousSql:n,nextSql:i}){const[d,o]=u.useState(!0),p=de.useMemo(()=>Ne(n.trim(),i.trim()),[n,i]),a=p.filter(c=>c.kind==="add").length,x=p.filter(c=>c.kind==="remove").length,f=a===0&&x===0;return t.jsxs("div",{style:{display:"grid",gap:7},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:()=>o(c=>!c),style:ke(e),children:[d?t.jsx(le,{size:13,strokeWidth:2}):t.jsx(ae,{size:13,strokeWidth:2}),t.jsx(_e,{size:13,strokeWidth:2}),d?"Hide what changed":"Show what changed"]}),f?t.jsx("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.font},children:"No SQL changes."}):t.jsxs("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsxs("span",{style:{color:e.success,fontWeight:700},children:["+",a]})," ",t.jsxs("span",{style:{color:e.error,fontWeight:700},children:["-",x]})," line",a+x===1?"":"s"]})]}),d?t.jsx("pre",{style:{...be(e),padding:0},children:t.jsx("code",{style:{display:"block",fontFamily:e.fontMono,fontSize:11.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:p.map((c,r)=>t.jsxs("span",{style:{display:"block",padding:"0 11px",color:c.kind==="add"?e.success:c.kind==="remove"?e.error:e.textPrimary,background:c.kind==="add"?`${e.success}14`:c.kind==="remove"?`${e.error}14`:"transparent"},children:[t.jsx("span",{"aria-hidden":!0,style:{userSelect:"none",opacity:.7},children:c.kind==="add"?"+ ":c.kind==="remove"?"- ":" "}),c.text||" "]},r))})}):null]})}function Qe({t:e,verdict:n}){if(!n)return null;const i=n.ready&&n.blocking.length===0,d=i?[]:[...n.blocking,...n.warnings];return t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"What's missing to certify"}),i?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:e.success,fontFamily:e.font},children:[t.jsx(K,{size:14,strokeWidth:2}),"Grain, outputs, and context are set."]}):t.jsxs("div",{style:{display:"grid",gap:4},children:[t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:e.warning,fontFamily:e.font},children:[t.jsx(ue,{size:14,strokeWidth:2}),"Needs an owner and passing tests before it can be certified."]}),d.length>0?t.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:2},children:d.map(o=>t.jsx("li",{style:{fontSize:11,color:e.textSecondary,lineHeight:1.4,fontFamily:e.font},children:o},o))}):null]})]})}function ye({t:e,diagnostics:n}){if(!n)return null;const i=n.sourceTrust==="governed_semantic_source",d=n.activeDomain?`domain ${n.activeDomain}`:"project metadata",o=n.allowedRelations.length,p=n.warnings[0];return t.jsxs("div",{style:{display:"grid",gap:3,fontSize:10.5,color:e.textMuted,lineHeight:1.4,fontFamily:e.font},children:[t.jsxs("span",{title:n.contextPackId?`Context pack ${n.contextPackId}`:void 0,children:[i?"Built from governed semantic context":"Exploratory DBT-grounded draft"," · ",d," · ",o," allowed relation",o===1?"":"s"," · review required"]}),p?t.jsx("span",{style:{color:e.warning},children:p}):null]})}function he({t:e,skills:n,onOpenSkills:i}){return!n||n.length===0?null:t.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:5,fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsx(pe,{size:12,strokeWidth:2}),t.jsx("span",{children:"guided by"}),n.map((d,o)=>t.jsxs(de.Fragment,{children:[o>0?t.jsx("span",{"aria-hidden":!0,style:{color:e.textMuted},children:","}):null,t.jsx("button",{type:"button",onClick:i,title:d.description??`Open the ${d.id} skill`,style:{padding:0,border:"none",background:"transparent",color:e.accent,fontSize:11,fontWeight:700,fontFamily:e.font,cursor:"pointer",textDecoration:"underline",textUnderlineOffset:2},children:d.id})]},d.id))]})}const Ge={certified_block:{tone:"success",icon:Re},semantic_metric:{tone:"accent",icon:V},generated_sql:{tone:"textMuted",icon:fe},business_context:{tone:"accent",icon:pe},no_answer:null};function ge({t:e,route:n}){var a;if(!n)return null;const i=Ge[n.tier];if(!i)return null;const d=i.icon,o=e[i.tone]??e.textMuted,p=((a=n.label)==null?void 0:a.trim())||Ue(n);return t.jsxs("span",{title:n.ref?`${p} (${n.ref})`:p,style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:10.5,fontWeight:700,color:o,background:`${o}14`,border:`1px solid ${o}3a`,borderRadius:999,padding:"2px 9px",fontFamily:e.font,maxWidth:"100%"},children:[t.jsx(d,{size:11,strokeWidth:2.2,style:{flexShrink:0}}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p})]})}function Ue(e){switch(e.tier){case"certified_block":return e.ref?`Certified block ${e.ref}`:"Certified block";case"semantic_metric":return e.ref?`Answered from metric ${e.ref}`:"Answered from metric";case"generated_sql":return"Generated SQL preview";case"business_context":return"From business context";default:return""}}function Ve({t:e,selectedPath:n,onSelect:i}){const[d,o]=u.useState([]),[p,a]=u.useState(!0),[x,f]=u.useState("");u.useEffect(()=>{let s=!1;return a(!0),E.getBlockLibrary().then(y=>{s||o(Array.isArray(y==null?void 0:y.blocks)?y.blocks.map(g=>({name:g.name,domain:g.domain,path:g.path})):[])}).catch(()=>{s||o([])}).finally(()=>{s||a(!1)}),()=>{s=!0}},[]);const c=d.filter(s=>{if(!x.trim())return!0;const y=x.toLowerCase();return s.name.toLowerCase().includes(y)||s.path.toLowerCase().includes(y)||(s.domain??"").toLowerCase().includes(y)}).slice(0,40),r=d.find(s=>s.path===n);return t.jsxs("div",{style:{display:"grid",gap:7,border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.cellBg,padding:9},children:[t.jsxs("div",{style:{position:"relative"},children:[t.jsx(Fe,{size:13,strokeWidth:2,color:e.textMuted,style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)"}}),t.jsx("input",{type:"text",value:x,onChange:s=>f(s.target.value),placeholder:r?`Modifying ${r.name} — search to change`:"Search blocks to modify…",style:{width:"100%",border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.appBg,color:e.textPrimary,fontSize:12,fontFamily:e.font,padding:"7px 9px 7px 28px",boxSizing:"border-box"}})]}),p?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"4px 2px"},children:[t.jsx(se,{size:12,strokeWidth:2})," Loading blocks…"]}):d.length===0?t.jsxs("div",{style:{fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"2px 2px",lineHeight:1.45},children:["No blocks found. Type the block file path you want to modify, then press Enter.",t.jsx("input",{type:"text",defaultValue:n??"",onKeyDown:s=>{if(s.key==="Enter"){const y=s.target.value.trim();y&&i(y)}},placeholder:"blocks/revenue_by_region.dql",style:{marginTop:6,width:"100%",border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.appBg,color:e.textPrimary,fontSize:12,fontFamily:e.fontMono,padding:"7px 9px",boxSizing:"border-box"}})]}):t.jsx("div",{style:{display:"grid",gap:3,maxHeight:184,overflow:"auto"},children:c.length===0?t.jsxs("div",{style:{fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"4px 2px"},children:["No blocks match “",x,"”."]}):c.map(s=>{const y=s.path===n;return t.jsxs("button",{type:"button",onClick:()=>i(s.path),style:{display:"flex",alignItems:"center",gap:8,textAlign:"left",width:"100%",border:`1px solid ${y?e.accent:"transparent"}`,background:y?`${e.accent}14`:"transparent",borderRadius:6,padding:"6px 8px",cursor:"pointer"},children:[t.jsx(fe,{size:13,strokeWidth:2,color:y?e.accent:e.textMuted,style:{flexShrink:0}}),t.jsxs("span",{style:{minWidth:0,display:"grid",gap:1},children:[t.jsx("span",{style:{fontSize:12,fontWeight:700,color:e.textPrimary,fontFamily:e.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s.name}),t.jsxs("span",{style:{fontSize:10.5,color:e.textMuted,fontFamily:e.font,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s.domain?`${s.domain} · `:"",s.path]})]}),y?t.jsx(K,{size:14,strokeWidth:2,color:e.accent,style:{marginLeft:"auto",flexShrink:0}}):null]},s.path)})})]})}function Ke({t:e,value:n,onChange:i}){const{state:d,dispatch:o}=U(),p=Be(n,d.authoredDomains);return t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:11,fontWeight:700,color:e.textSecondary,fontFamily:e.font},children:"Domain"}),t.jsxs("select",{value:n??"",onChange:a=>i(a.target.value||void 0),style:{border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.btnBg,color:n?e.textPrimary:e.textMuted,fontSize:12,fontFamily:e.font,padding:"5px 9px",cursor:"pointer"},children:[t.jsx("option",{value:"",children:p.length===0?"No domains yet":"No domain"}),p.map(a=>t.jsx("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]}),t.jsxs("button",{type:"button",onClick:()=>o({type:"SET_MAIN_VIEW",view:"domains"}),style:w(e),title:"Create a new domain on the Domains page",children:[t.jsx(A,{size:12,strokeWidth:2})," New"]})]})}function Ye({t:e,message:n,onRefine:i}){return t.jsxs("section",{style:{...Z(e),borderColor:`${e.error}66`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[t.jsx(ue,{size:15,strokeWidth:2,color:e.error,style:{marginTop:1,flexShrink:0}}),t.jsx("div",{style:{fontSize:12.5,color:e.textPrimary,lineHeight:1.5,fontFamily:e.font},children:n})]}),t.jsx("div",{style:{display:"flex",gap:8},children:t.jsxs("button",{type:"button",onClick:i,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine and try again"]})})]})}function me({t:e,code:n}){return t.jsx("pre",{style:be(e),children:t.jsx("code",{style:{fontFamily:e.fontMono,fontSize:11.5,color:e.textPrimary,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:n.trim()})})}function G({t:e,children:n}){return t.jsx("div",{style:{fontSize:10,fontWeight:800,letterSpacing:"0.05em",textTransform:"uppercase",color:e.textMuted,fontFamily:e.font},children:n})}function ne(e){return{display:"inline-flex",padding:2,gap:2,border:`1px solid ${e.btnBorder}`,borderRadius:8,background:e.btnBg}}function ie(e,n,i){return{display:"inline-flex",alignItems:"center",gap:5,padding:"5px 11px",borderRadius:6,border:"1px solid transparent",background:n?e.accent:"transparent",color:n?"#ffffff":e.textSecondary,fontSize:12,fontWeight:n?800:600,fontFamily:e.font,cursor:i?"default":"pointer",opacity:i?.45:1}}function Ze(e){return{width:"100%",resize:"vertical",border:`1px solid ${e.btnBorder}`,borderRadius:8,background:e.cellBg,color:e.textPrimary,fontSize:12.5,fontFamily:e.font,lineHeight:1.5,padding:"9px 11px",boxSizing:"border-box"}}function Z(e){return{border:`1px solid ${e.cellBorder}`,borderRadius:10,background:e.cellBg,padding:12,display:"grid",gap:10}}function be(e){return{margin:0,border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.appBg,padding:"9px 11px",overflow:"auto",maxHeight:280}}function J(e){return oe(e,{variant:"primary",size:"md"})}function w(e){return oe(e,{variant:"ghost",size:"md"})}function ke(e){return{display:"inline-flex",alignItems:"center",gap:5,padding:0,border:"none",background:"transparent",color:e.accent,fontSize:11.5,fontWeight:700,fontFamily:e.font,cursor:"pointer"}}function je(e){return{fontSize:10,fontWeight:800,letterSpacing:"0.03em",textTransform:"uppercase",color:e.accent,background:`${e.accent}18`,border:`1px solid ${e.accent}40`,borderRadius:999,padding:"2px 8px",fontFamily:e.font}}function Je(e){return{fontSize:10.5,fontWeight:600,color:e.textMuted,background:e.btnBg,border:`1px solid ${e.btnBorder}`,borderRadius:999,padding:"2px 8px",fontFamily:e.font}}function Xe(e){return{fontSize:11,fontWeight:600,color:e.textSecondary,background:e.btnBg,border:`1px solid ${e.btnBorder}`,borderRadius:6,padding:"3px 8px",fontFamily:e.fontMono}}function ot(){const{state:e,dispatch:n}=U();return u.useCallback(async(i,d)=>{const o={name:i.split("/").pop()??`${d}.dql`,path:i,type:"block",folder:"blocks"};e.files.some(a=>a.path===i)||n({type:"FILE_ADDED",file:o});const p=await E.openBlockStudio(i);n({type:"OPEN_BLOCK_STUDIO",file:o,payload:p})},[n,e.files])}export{st as A,Qe as C,he as G,ge as R,ot as u};
|
|
33
|
+
`),s=i.length,p=d.length,a=Array.from({length:s+1},()=>new Array(p+1).fill(0));for(let r=s-1;r>=0;r--)for(let o=p-1;o>=0;o--)a[r][o]=i[r]===d[o]?a[r+1][o+1]+1:Math.max(a[r+1][o],a[r][o+1]);const x=[];let f=0,c=0;for(;f<s&&c<p;)i[f]===d[c]?(x.push({kind:"context",text:i[f]}),f++,c++):a[f+1][c]>=a[f][c+1]?(x.push({kind:"remove",text:i[f]}),f++):(x.push({kind:"add",text:d[c]}),c++);for(;f<s;)x.push({kind:"remove",text:i[f]}),f++;for(;c<p;)x.push({kind:"add",text:d[c]}),c++;return x}function Oe({t:e,previousSql:n,nextSql:i}){const[d,s]=u.useState(!0),p=de.useMemo(()=>Ne(n.trim(),i.trim()),[n,i]),a=p.filter(c=>c.kind==="add").length,x=p.filter(c=>c.kind==="remove").length,f=a===0&&x===0;return t.jsxs("div",{style:{display:"grid",gap:7},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:()=>s(c=>!c),style:ke(e),children:[d?t.jsx(le,{size:13,strokeWidth:2}):t.jsx(ae,{size:13,strokeWidth:2}),t.jsx(_e,{size:13,strokeWidth:2}),d?"Hide what changed":"Show what changed"]}),f?t.jsx("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.font},children:"No SQL changes."}):t.jsxs("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsxs("span",{style:{color:e.success,fontWeight:700},children:["+",a]})," ",t.jsxs("span",{style:{color:e.error,fontWeight:700},children:["-",x]})," line",a+x===1?"":"s"]})]}),d?t.jsx("pre",{style:{...be(e),padding:0},children:t.jsx("code",{style:{display:"block",fontFamily:e.fontMono,fontSize:11.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:p.map((c,r)=>t.jsxs("span",{style:{display:"block",padding:"0 11px",color:c.kind==="add"?e.success:c.kind==="remove"?e.error:e.textPrimary,background:c.kind==="add"?`${e.success}14`:c.kind==="remove"?`${e.error}14`:"transparent"},children:[t.jsx("span",{"aria-hidden":!0,style:{userSelect:"none",opacity:.7},children:c.kind==="add"?"+ ":c.kind==="remove"?"- ":" "}),c.text||" "]},r))})}):null]})}function Qe({t:e,verdict:n}){if(!n)return null;const i=n.ready&&n.blocking.length===0,d=i?[]:[...n.blocking,...n.warnings];return t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"What's missing to certify"}),i?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:e.success,fontFamily:e.font},children:[t.jsx(K,{size:14,strokeWidth:2}),"Grain, outputs, and context are set."]}):t.jsxs("div",{style:{display:"grid",gap:4},children:[t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:e.warning,fontFamily:e.font},children:[t.jsx(ue,{size:14,strokeWidth:2}),"Needs an owner and passing tests before it can be certified."]}),d.length>0?t.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:2},children:d.map(s=>t.jsx("li",{style:{fontSize:11,color:e.textSecondary,lineHeight:1.4,fontFamily:e.font},children:s},s))}):null]})]})}function ye({t:e,diagnostics:n}){if(!n)return null;const i=n.sourceTrust==="governed_semantic_source",d=n.activeDomain?`domain ${n.activeDomain}`:"project metadata",s=n.allowedRelations.length,p=n.warnings[0];return t.jsxs("div",{style:{display:"grid",gap:3,fontSize:10.5,color:e.textMuted,lineHeight:1.4,fontFamily:e.font},children:[t.jsxs("span",{title:n.contextPackId?`Context pack ${n.contextPackId}`:void 0,children:[i?"Built from governed semantic context":"Exploratory DBT-grounded draft"," · ",d," · ",s," allowed relation",s===1?"":"s"," · review required"]}),p?t.jsx("span",{style:{color:e.warning},children:p}):null]})}function he({t:e,skills:n,onOpenSkills:i,onSuggestCorrection:d}){return!n||n.length===0?null:t.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:5,fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsx(pe,{size:12,strokeWidth:2}),t.jsx("span",{children:"guided by"}),n.map((s,p)=>t.jsxs(de.Fragment,{children:[p>0?t.jsx("span",{"aria-hidden":!0,style:{color:e.textMuted},children:","}):null,t.jsx("button",{type:"button",onClick:i,title:s.description??`Open the ${s.id} skill`,style:{padding:0,border:"none",background:"transparent",color:e.accent,fontSize:11,fontWeight:700,fontFamily:e.font,cursor:"pointer",textDecoration:"underline",textUnderlineOffset:2},children:s.id})]},s.id)),d&&n.length===1?t.jsx("button",{type:"button",onClick:()=>d(n[0]),style:{marginLeft:5,border:"1px solid var(--border-subtle)",borderRadius:6,background:"var(--bg-1)",color:e.accent,padding:"3px 7px",cursor:"pointer",fontSize:10},children:"Suggest skill correction"}):null]})}const Ge={certified_block:{tone:"success",icon:Re},semantic_metric:{tone:"accent",icon:V},generated_sql:{tone:"textMuted",icon:fe},business_context:{tone:"accent",icon:pe},no_answer:null};function ge({t:e,route:n}){var a;if(!n)return null;const i=Ge[n.tier];if(!i)return null;const d=i.icon,s=e[i.tone]??e.textMuted,p=((a=n.label)==null?void 0:a.trim())||Ue(n);return t.jsxs("span",{title:n.ref?`${p} (${n.ref})`:p,style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:10.5,fontWeight:700,color:s,background:`${s}14`,border:`1px solid ${s}3a`,borderRadius:999,padding:"2px 9px",fontFamily:e.font,maxWidth:"100%"},children:[t.jsx(d,{size:11,strokeWidth:2.2,style:{flexShrink:0}}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p})]})}function Ue(e){switch(e.tier){case"certified_block":return e.ref?`Certified block ${e.ref}`:"Certified block";case"semantic_metric":return e.ref?`Answered from metric ${e.ref}`:"Answered from metric";case"generated_sql":return"Generated SQL preview";case"business_context":return"From business context";default:return""}}function Ve({t:e,selectedPath:n,onSelect:i}){const[d,s]=u.useState([]),[p,a]=u.useState(!0),[x,f]=u.useState("");u.useEffect(()=>{let o=!1;return a(!0),E.getBlockLibrary().then(y=>{o||s(Array.isArray(y==null?void 0:y.blocks)?y.blocks.map(g=>({name:g.name,domain:g.domain,path:g.path})):[])}).catch(()=>{o||s([])}).finally(()=>{o||a(!1)}),()=>{o=!0}},[]);const c=d.filter(o=>{if(!x.trim())return!0;const y=x.toLowerCase();return o.name.toLowerCase().includes(y)||o.path.toLowerCase().includes(y)||(o.domain??"").toLowerCase().includes(y)}).slice(0,40),r=d.find(o=>o.path===n);return t.jsxs("div",{style:{display:"grid",gap:7,border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.cellBg,padding:9},children:[t.jsxs("div",{style:{position:"relative"},children:[t.jsx(Fe,{size:13,strokeWidth:2,color:e.textMuted,style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)"}}),t.jsx("input",{type:"text",value:x,onChange:o=>f(o.target.value),placeholder:r?`Modifying ${r.name} — search to change`:"Search blocks to modify…",style:{width:"100%",border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.appBg,color:e.textPrimary,fontSize:12,fontFamily:e.font,padding:"7px 9px 7px 28px",boxSizing:"border-box"}})]}),p?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"4px 2px"},children:[t.jsx(oe,{size:12,strokeWidth:2})," Loading blocks…"]}):d.length===0?t.jsxs("div",{style:{fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"2px 2px",lineHeight:1.45},children:["No blocks found. Type the block file path you want to modify, then press Enter.",t.jsx("input",{type:"text",defaultValue:n??"",onKeyDown:o=>{if(o.key==="Enter"){const y=o.target.value.trim();y&&i(y)}},placeholder:"blocks/revenue_by_region.dql",style:{marginTop:6,width:"100%",border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.appBg,color:e.textPrimary,fontSize:12,fontFamily:e.fontMono,padding:"7px 9px",boxSizing:"border-box"}})]}):t.jsx("div",{style:{display:"grid",gap:3,maxHeight:184,overflow:"auto"},children:c.length===0?t.jsxs("div",{style:{fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"4px 2px"},children:["No blocks match “",x,"”."]}):c.map(o=>{const y=o.path===n;return t.jsxs("button",{type:"button",onClick:()=>i(o.path),style:{display:"flex",alignItems:"center",gap:8,textAlign:"left",width:"100%",border:`1px solid ${y?e.accent:"transparent"}`,background:y?`${e.accent}14`:"transparent",borderRadius:6,padding:"6px 8px",cursor:"pointer"},children:[t.jsx(fe,{size:13,strokeWidth:2,color:y?e.accent:e.textMuted,style:{flexShrink:0}}),t.jsxs("span",{style:{minWidth:0,display:"grid",gap:1},children:[t.jsx("span",{style:{fontSize:12,fontWeight:700,color:e.textPrimary,fontFamily:e.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.name}),t.jsxs("span",{style:{fontSize:10.5,color:e.textMuted,fontFamily:e.font,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[o.domain?`${o.domain} · `:"",o.path]})]}),y?t.jsx(K,{size:14,strokeWidth:2,color:e.accent,style:{marginLeft:"auto",flexShrink:0}}):null]},o.path)})})]})}function Ke({t:e,value:n,onChange:i}){const{state:d,dispatch:s}=U(),p=Be(n,d.authoredDomains);return t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:11,fontWeight:700,color:e.textSecondary,fontFamily:e.font},children:"Domain"}),t.jsxs("select",{value:n??"",onChange:a=>i(a.target.value||void 0),style:{border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.btnBg,color:n?e.textPrimary:e.textMuted,fontSize:12,fontFamily:e.font,padding:"5px 9px",cursor:"pointer"},children:[t.jsx("option",{value:"",children:p.length===0?"No domains yet":"No domain"}),p.map(a=>t.jsx("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]}),t.jsxs("button",{type:"button",onClick:()=>s({type:"SET_MAIN_VIEW",view:"domains"}),style:w(e),title:"Create a new domain on the Domains page",children:[t.jsx(A,{size:12,strokeWidth:2})," New"]})]})}function Ye({t:e,message:n,onRefine:i}){return t.jsxs("section",{style:{...Z(e),borderColor:`${e.error}66`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[t.jsx(ue,{size:15,strokeWidth:2,color:e.error,style:{marginTop:1,flexShrink:0}}),t.jsx("div",{style:{fontSize:12.5,color:e.textPrimary,lineHeight:1.5,fontFamily:e.font},children:n})]}),t.jsx("div",{style:{display:"flex",gap:8},children:t.jsxs("button",{type:"button",onClick:i,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine and try again"]})})]})}function me({t:e,code:n}){return t.jsx("pre",{style:be(e),children:t.jsx("code",{style:{fontFamily:e.fontMono,fontSize:11.5,color:e.textPrimary,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:n.trim()})})}function G({t:e,children:n}){return t.jsx("div",{style:{fontSize:10,fontWeight:800,letterSpacing:"0.05em",textTransform:"uppercase",color:e.textMuted,fontFamily:e.font},children:n})}function ne(e){return{display:"inline-flex",padding:2,gap:2,border:`1px solid ${e.btnBorder}`,borderRadius:8,background:e.btnBg}}function ie(e,n,i){return{display:"inline-flex",alignItems:"center",gap:5,padding:"5px 11px",borderRadius:6,border:"1px solid transparent",background:n?e.accent:"transparent",color:n?"#ffffff":e.textSecondary,fontSize:12,fontWeight:n?800:600,fontFamily:e.font,cursor:i?"default":"pointer",opacity:i?.45:1}}function Ze(e){return{width:"100%",resize:"vertical",border:`1px solid ${e.btnBorder}`,borderRadius:8,background:e.cellBg,color:e.textPrimary,fontSize:12.5,fontFamily:e.font,lineHeight:1.5,padding:"9px 11px",boxSizing:"border-box"}}function Z(e){return{border:`1px solid ${e.cellBorder}`,borderRadius:10,background:e.cellBg,padding:12,display:"grid",gap:10}}function be(e){return{margin:0,border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.appBg,padding:"9px 11px",overflow:"auto",maxHeight:280}}function J(e){return se(e,{variant:"primary",size:"md"})}function w(e){return se(e,{variant:"ghost",size:"md"})}function ke(e){return{display:"inline-flex",alignItems:"center",gap:5,padding:0,border:"none",background:"transparent",color:e.accent,fontSize:11.5,fontWeight:700,fontFamily:e.font,cursor:"pointer"}}function je(e){return{fontSize:10,fontWeight:800,letterSpacing:"0.03em",textTransform:"uppercase",color:e.accent,background:`${e.accent}18`,border:`1px solid ${e.accent}40`,borderRadius:999,padding:"2px 8px",fontFamily:e.font}}function Je(e){return{fontSize:10.5,fontWeight:600,color:e.textMuted,background:e.btnBg,border:`1px solid ${e.btnBorder}`,borderRadius:999,padding:"2px 8px",fontFamily:e.font}}function Xe(e){return{fontSize:11,fontWeight:600,color:e.textSecondary,background:e.btnBg,border:`1px solid ${e.btnBorder}`,borderRadius:6,padding:"3px 8px",fontFamily:e.fontMono}}function st(){const{state:e,dispatch:n}=U();return u.useCallback(async(i,d)=>{const s={name:i.split("/").pop()??`${d}.dql`,path:i,type:"block",folder:"blocks"};e.files.some(a=>a.path===i)||n({type:"FILE_ADDED",file:s});const p=await E.openBlockStudio(i);n({type:"OPEN_BLOCK_STUDIO",file:s,payload:p})},[n,e.files])}export{ot as A,Qe as C,he as G,ge as R,st as u};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as te,r as o,j as n,S as ne,L as ie}from"./index-Cpx47jCH.js";import{M as re}from"./minimize-2-C8dvqCxX.js";import{M as oe}from"./usePersistedAgentThreadId-Bnl9gWhj.js";import{X as ae}from"./x-CbKEfe5m.js";/**
|
|
2
|
+
* @license lucide-react v0.563.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const se=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],le=te("message-square-plus",se),H=420,P=720;function we({t,title:l,subtitle:j,children:v,onClose:D,expanded:g=!1,onToggleExpanded:y,onNewChat:F,headerActions:U,running:O=!1,compact:M=!1,floating:S=!1,resizable:w=!1,minResizeWidth:A=360,maxResizeWidth:E,fitViewportHeight:B=!1,heightResizable:p=!1,minResizeHeight:f=420,maxResizeHeight:C,dock:z="column",ariaLabel:V=l,className:G,style:J}){const c=o.useRef(null),s=o.useRef(null),[b,W]=o.useState(null),[h,k]=o.useState(null),[m,N]=o.useState(null),[X,q]=o.useState(!1),[K,Y]=o.useState(!1),I=o.useCallback(e=>{const i=typeof window>"u"?Math.max(A,E??P):Math.max(A,window.innerWidth-96);return Math.min(Math.max(e,A),Math.min(E??i,i))},[E,A]),Q=o.useCallback(e=>{var u;if(!w||!c.current)return;e.preventDefault();const i=e.clientX,a=c.current.getBoundingClientRect().width;q(!0);const d=$=>{W(I(a+i-$.clientX))},r=()=>{window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",r),window.removeEventListener("pointercancel",r),s.current=null,q(!1)};(u=s.current)==null||u.call(s),s.current=r,window.addEventListener("pointermove",d),window.addEventListener("pointerup",r),window.addEventListener("pointercancel",r)},[I,w]);o.useEffect(()=>()=>{var e;return(e=s.current)==null?void 0:e.call(s)},[]);const L=o.useCallback(e=>typeof window>"u"?C??P:Math.max(240,Math.min(C??Number.POSITIVE_INFINITY,window.innerHeight-Math.max(0,e)-16)),[C]),x=o.useCallback((e,i)=>{var r;const a=L(i??((r=c.current)==null?void 0:r.getBoundingClientRect().top)??0),d=Math.min(f,a);return Math.min(Math.max(e,d),a)},[L,f]);o.useEffect(()=>{if(!B){N(null);return}let e=null;const i=()=>{e===null&&(e=window.requestAnimationFrame(()=>{var r;e=null;const a=((r=c.current)==null?void 0:r.getBoundingClientRect().top)??0,d=a<window.innerHeight-80?L(a):null;N(d),d!==null&&k(u=>u===null?u:x(u,a))}))};return i(),window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),()=>{e!==null&&window.cancelAnimationFrame(e),window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0)}},[L,x,B]);const R=o.useCallback(e=>{var a;if(!w||e.key!=="ArrowLeft"&&e.key!=="ArrowRight")return;e.preventDefault();const i=b??((a=c.current)==null?void 0:a.getBoundingClientRect().width)??H;W(I(i+(e.key==="ArrowLeft"?40:-40)))},[I,b,w]),Z=o.useCallback(e=>{var u;if(!p||!c.current)return;e.preventDefault();const i=e.clientY,a=c.current.getBoundingClientRect().height;Y(!0);const d=$=>{k(x(a+$.clientY-i))},r=()=>{window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",r),window.removeEventListener("pointercancel",r),s.current=null,Y(!1)};(u=s.current)==null||u.call(s),s.current=r,window.addEventListener("pointermove",d),window.addEventListener("pointerup",r),window.addEventListener("pointercancel",r)},[x,p]),T=o.useCallback(e=>{var a;if(!p)return;if(e.key==="Enter"||e.key==="Home"){e.preventDefault(),k(null);return}if(e.key!=="ArrowUp"&&e.key!=="ArrowDown")return;e.preventDefault();const i=h??((a=c.current)==null?void 0:a.getBoundingClientRect().height)??m??f;k(x(i+(e.key==="ArrowDown"?40:-40)))},[x,p,h,f,m]),ee=o.useCallback(()=>{W(null),y==null||y()},[y]);return n.jsxs("aside",{ref:c,"aria-label":V,className:G,"data-ai-side-panel":"true","data-expanded":g?"true":"false","data-resizable":w?"true":"false","data-height-resizable":p?"true":"false","data-height-mode":h!==null?"manual":B?"viewport":"surface",style:{minWidth:0,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden",background:t.cellBg,...z==="overlay"&&!M?{position:"absolute",inset:"0 0 0 auto",zIndex:30,width:g?`min(${P}px, calc(100% - 40px))`:`min(${H}px, calc(100% - 40px))`,maxWidth:g?"72vw":"52vw",minWidth:Math.min(H,400),flex:"0 0 auto",boxShadow:"-16px 0 36px rgba(0,0,0,0.18)"}:{},...z==="overlay"&&M?{position:"relative",width:"100%",flex:"0 0 auto"}:{},borderLeft:M?"none":`1px solid ${t.headerBorder}`,border:S?`1px solid ${t.headerBorder}`:void 0,borderRadius:S?12:void 0,boxShadow:S?"0 18px 60px rgba(15, 23, 42, 0.22)":void 0,transition:"width 180ms ease, max-width 180ms ease",...J,...b!==null?{width:b,maxWidth:E??"calc(100vw - 96px)",flexBasis:b,transition:X?"none":"width 120ms ease, max-width 120ms ease"}:{},...(h??m)!==null?{height:h??m??void 0,minHeight:Math.min(f,h??m??f),maxHeight:h??m??void 0,transition:K?"none":"height 120ms ease, max-height 120ms ease"}:{}},children:[w?n.jsx("div",{role:"separator","aria-label":`Resize ${l}`,"aria-orientation":"vertical",tabIndex:0,title:`Drag to resize ${l}. Use left and right arrow keys for precise adjustment.`,onPointerDown:Q,onKeyDown:R,style:{position:"absolute",inset:"0 auto 0 -5px",width:10,zIndex:4,cursor:"col-resize",outline:"none",touchAction:"none"},children:n.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:4,top:"42%",width:2,height:48,borderRadius:999,background:X?t.accent:t.headerBorder,transition:"background 120ms ease"}})}):null,p?n.jsx("div",{role:"separator","aria-label":`Resize ${l} height`,"aria-orientation":"horizontal",tabIndex:0,title:`Drag to adjust ${l} height. Use up and down arrow keys; press Enter to fit the viewport.`,onPointerDown:Z,onDoubleClick:()=>k(null),onKeyDown:T,style:{position:"absolute",inset:"auto 0 -5px 0",height:10,zIndex:4,cursor:"row-resize",outline:"none",touchAction:"none"},children:n.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:"calc(50% - 24px)",top:4,width:48,height:2,borderRadius:999,background:K?t.accent:t.headerBorder,transition:"background 120ms ease"}})}):null,n.jsxs("div",{style:{minHeight:52,padding:"9px 12px",borderBottom:`1px solid ${t.headerBorder}`,background:t.cellBg,display:"flex",alignItems:"center",gap:10,flex:"0 0 auto"},children:[n.jsx("div",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,background:`${t.accent}14`,border:`1px solid ${t.accent}36`,color:t.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto"},children:n.jsx(ne,{size:16,strokeWidth:2.1})}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[n.jsx("span",{style:{fontSize:13,fontWeight:800,color:t.textPrimary,fontFamily:t.font},children:l}),O?n.jsx(ie,{size:12,"aria-label":"AI is working",style:{color:t.accent,animation:"dql-agent-run-spin 0.8s linear infinite"}}):null]}),n.jsx("div",{title:j,style:{marginTop:2,color:t.textMuted,fontSize:11,fontFamily:t.font,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:j})]}),U,F?n.jsx(_,{t,label:"New AI chat",onClick:F,children:n.jsx(le,{size:15,strokeWidth:2})}):null,!M&&y?n.jsx(_,{t,label:g?"Return AI panel to standard width":"Expand AI panel",onClick:ee,children:g?n.jsx(re,{size:15,strokeWidth:2}):n.jsx(oe,{size:15,strokeWidth:2})}):null,n.jsx(_,{t,label:`Close ${l}`,onClick:D,children:n.jsx(ae,{size:15,strokeWidth:2})})]}),n.jsx("div",{style:{flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:v})]})}function _({t,label:l,onClick:j,active:v=!1,children:D}){return n.jsx("button",{type:"button","aria-label":l,title:l,onClick:j,style:{width:30,height:30,borderRadius:7,border:`1px solid ${v?`${t.accent}66`:t.btnBorder}`,background:v?`${t.accent}14`:t.btnBg,color:v?t.accent:t.textSecondary,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto"},children:D})}export{we as A,le as M,P as a,H as b,_ as c};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as ne,h as re,i as ie,k as oe,t as se,r as f,a as R,j as o,m as ae,P as de,L as J,l as ce,T as le}from"./index-Cpx47jCH.js";import{u as ue,f as fe,c as pe}from"./answer-to-notebook-WAVAYjBv.js";import{U as he}from"./UnifiedAgentRunPanel-duFXXNV_.js";import{S as G}from"./star-CgCQbnXc.js";import{P as me}from"./usePersistedAgentThreadId-Bnl9gWhj.js";import"./react-CRB3T2We.js";import"./AgentAnswerCard-c8QUo6NH.js";import"./TrustBadge-ZuD5N5Ww.js";import"./AiBuildResult-DPJ_SI0R.js";import"./user-round-J4PQHxo9.js";import"./triangle-alert-SyuSZ4ht.js";import"./rotate-ccw-Di0kRnrM.js";import"./x-CbKEfe5m.js";import"./list-tree-DGKqCxmz.js";import"./wrench-CS1f1Zv4.js";import"./minimize-2-C8dvqCxX.js";import"./arrow-right-WIF1V9a9.js";/**
|
|
2
|
+
* @license lucide-react v0.563.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const ge=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],xe=ne("message-square",ge),H="dql-ask-domain-scope",K="dql-ask-domain-context";function Y(e){if(e)try{const t=JSON.parse(e);return typeof t.domain!="string"||!t.domain.trim()?void 0:{domain:t.domain.trim(),purpose:typeof t.purpose=="string"?t.purpose:void 0,modelAreaId:typeof t.modelAreaId=="string"?t.modelAreaId:void 0}}catch{return}}function Ae(e,t){try{const s=Y(e.getItem(K));return e.removeItem(K),s?(t.setItem(H,JSON.stringify(s)),s):Y(t.getItem(H))}catch{return}}function Se(e,t){try{t||e.removeItem(H)}catch{}}function ve(){if(!(typeof window>"u"))return Ae(window.sessionStorage,window.localStorage)}function Ie(e){typeof window>"u"||Se(window.localStorage,e)}const B="dql-ask-conversations",Z="dql-ask-active-conversation",Q="dql-ask-deleted-thread-queue",N=100;function we(e){return(e??"AI analysis").replace(/[^a-zA-Z0-9_ -]+/g," ").replace(/\s+/g,"_").replace(/^_+|_+$/g,"").slice(0,48)||"ai_analysis"}function ke(e){var v,p,a,d,w;const t=(p=(v=e.dqlArtifact)==null?void 0:v.source)==null?void 0:p.trim(),s=(a=e.sql)==null?void 0:a.trim(),n=t||s;if(!n)return;const u=ae(t?"dql":"sql",n);return u.name=we(e.title??((d=e.dqlArtifact)==null?void 0:d.name)),e.result&&(u.result=e.result,u.status="success",u.executionCount=1),e.chartConfig&&(u.chartConfig=e.chartConfig),u.correctionProvenance=pe({question:e.question,generatedSql:e.sql??((w=e.dqlArtifact)==null?void 0:w.compiledSql),generatedDql:t,sourceRunId:e.sourceRunId}),e.dqlArtifact&&(u.dqlArtifact={source:e.dqlArtifact.source,sql:e.sql,name:e.dqlArtifact.name,sourcePath:e.dqlArtifact.sourcePath,kind:e.dqlArtifact.kind,metrics:e.dqlArtifact.metrics,dimensions:e.dqlArtifact.dimensions,parameters:e.dqlArtifact.parameters,parameterValues:e.dqlArtifact.parameterValues,persistence:e.dqlArtifact.persistence,trustState:e.dqlArtifact.trustState,compiledSql:e.dqlArtifact.compiledSql??e.sql,reviewState:e.dqlArtifact.trustState==="certified"?"certified":"review_required",...e.question?{question:e.question}:{}},u.dqlParameterValues=e.dqlArtifact.parameterValues),u}function F(){return`conv_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function ee(e){return`conv_server_${e}`}function ye(e,t,s=new Set){const n=t.filter(a=>!s.has(a.id)),u=new Map(e.flatMap(a=>a.threadId?[[a.threadId,a]]:[])),v=n.map(a=>{var w;const d=u.get(a.id);return{id:(d==null?void 0:d.id)??ee(a.id),title:((w=a.title)==null?void 0:w.trim())||(d!=null&&d.title&&d.title!=="New chat"?d.title:"Recovered chat"),createdAt:(d==null?void 0:d.createdAt)??a.createdAt,updatedAt:a.updatedAt>((d==null?void 0:d.updatedAt)??"")?a.updatedAt:(d==null?void 0:d.updatedAt)??a.updatedAt,items:(d==null?void 0:d.items)??[],threadId:a.id,favorite:a.favorite??(d==null?void 0:d.favorite)??!1}}),p=new Set(n.map(a=>a.id));return[...v,...e.filter(a=>(!a.threadId||!p.has(a.threadId))&&(!a.threadId||!s.has(a.threadId)))].sort((a,d)=>d.updatedAt.localeCompare(a.updatedAt)).slice(0,N)}function b(){if(typeof window>"u")return new Set;try{const e=JSON.parse(window.localStorage.getItem(Q)??"[]");return new Set(Array.isArray(e)?e.filter(t=>typeof t=="string"):[])}catch{return new Set}}function te(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Q,JSON.stringify([...e].slice(-N)))}catch{}}function Ce(e){const t=b();t.add(e),te(t)}function U(e){const t=b();t.delete(e),te(t)}function qe(e){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object")return[];const s=t;if(s.kind==="run"&&s.run&&typeof s.run=="object"){const n=s.run;n.nextActions=Array.isArray(n.nextActions)?n.nextActions:[],n.artifacts=Array.isArray(n.artifacts)?n.artifacts:[],n.evaluations=Array.isArray(n.evaluations)?n.evaluations:[],n.steps=Array.isArray(n.steps)?n.steps:[]}return[t]}):[]}function be(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(B);if(!e)return[];const t=JSON.parse(e);if(!Array.isArray(t))return[];const s=b();return t.filter(n=>!n.threadId||!s.has(n.threadId)).map(n=>({...n,items:qe(n.items)}))}catch{return[]}}function je(){if(!(typeof window>"u"))try{return window.localStorage.getItem(Z)??void 0}catch{return}}function X(e){return e.map(t=>({...t,items:t.items.map(s=>s.kind==="run"?{...s,run:{...s.run,events:[]}}:s)}))}function C(e){const t=e.slice(0,N);if(typeof window>"u")return t;try{return window.localStorage.setItem(B,JSON.stringify(X(t))),t}catch{const s=t.slice(0,8);try{window.localStorage.setItem(B,JSON.stringify(X(s)))}catch{}return s}}function De(e){const t=e.find(n=>n.kind==="user"),s=t&&t.kind==="user"?t.text.trim():"";return s?s.length>48?`${s.slice(0,48).trimEnd()}…`:s:"New chat"}function Te(e){const t=new Date(e).getTime();if(Number.isNaN(t))return"";const s=Date.now()-t,n=Math.floor(s/6e4);if(n<1)return"just now";if(n<60)return`${n}m`;const u=Math.floor(n/60);if(u<24)return`${u}h`;const v=Math.floor(u/24);return v<7?`${v}d`:new Date(e).toLocaleDateString()}function Ye(){var V;const e=re(ie(r=>({activeFile:r.activeFile,themeMode:r.themeMode}))),t=oe(),s=ue(),n=se[e.themeMode],[u,v]=f.useState(()=>ve()),[p,a]=f.useState(()=>be()),[d,w]=f.useState(!0),j=f.useMemo(()=>p.length>0,[]),[h,y]=f.useState(()=>{const r=je();return r&&p.some(i=>i.id===r)?r:F()}),[I,D]=f.useState(!1);f.useEffect(()=>{try{window.localStorage.setItem(Z,h)}catch{}},[h]),f.useEffect(()=>{for(const r of b())R.deleteAgentThread(r).then(()=>U(r)).catch(()=>{})},[]),f.useEffect(()=>{let r=!1;const i=b();return R.listAgentThreads({limit:N}).then(({threads:l})=>{if(r)return;const m=l.filter(x=>x.surface==="ask"||x.surface==="notebook"&&!x.notebookPath),g=new Set([...i,...b()]),k=m.filter(x=>!g.has(x.id));a(x=>C(ye(x,k,g))),!j&&k[0]&&y(ee(k[0].id))}).catch(()=>{}).finally(()=>{r||w(!1)}),()=>{r=!0}},[j]);const T=f.useMemo(()=>{var r;return((r=p.find(i=>i.id===h))==null?void 0:r.items)??[]},[p,h]),E=f.useMemo(()=>{var r;return(r=p.find(i=>i.id===h))==null?void 0:r.threadId},[p,h]),_=f.useCallback(r=>{r.length!==0&&a(i=>{const l=i.find(x=>x.id===h);if(l&&l.items.length>=r.length)return i;const m=new Date().toISOString(),k=[{id:h,title:De(r),createdAt:(l==null?void 0:l.createdAt)??m,updatedAt:m,items:r,threadId:l==null?void 0:l.threadId},...i.filter(x=>x.id!==h)].slice(0,N);return C(k)})},[h]),$=f.useCallback(r=>{a(i=>{const l=i.find(g=>g.id===h),m=new Date().toISOString();return C(l?i.map(g=>g.id===h?{...g,threadId:r}:g):[{id:h,title:"New chat",createdAt:m,updatedAt:m,items:[],threadId:r},...i])})},[h]),M=f.useCallback((r,i)=>{var g;const l=i.trim();if(!l)return;a(k=>C(k.map(x=>x.id===r?{...x,title:l}:x)));const m=(g=p.find(k=>k.id===r))==null?void 0:g.threadId;m&&R.updateAgentThread(m,{title:l}).catch(()=>{})},[p]),O=f.useCallback(r=>{const i=p.find(m=>m.id===r),l=!(i!=null&&i.favorite);a(m=>C(m.map(g=>g.id===r?{...g,favorite:l}:g))),i!=null&&i.threadId&&R.updateAgentThread(i.threadId,{favorite:l}).catch(()=>{})},[p]),P=f.useCallback(()=>{I||y(F())},[I]),c=f.useCallback(r=>{I||y(r)},[I]),A=f.useCallback(r=>{var l;if(I)return;const i=(l=p.find(m=>m.id===r))==null?void 0:l.threadId;i&&(Ce(i),R.deleteAgentThread(i).then(()=>U(i)).catch(()=>{})),a(m=>C(m.filter(g=>g.id!==r))),r===h&&y(F())},[h,p,I]),q=(r,i)=>{t({type:"OPEN_APP",appId:r,dashboardId:i})},z=(r,i)=>{t({type:"OPEN_GLOBAL_AI",audience:"stakeholder",context:{title:"Research",scopeHint:"Follow up on this research",selectedObject:{kind:"research",id:r,path:i}}})},S=f.useCallback(r=>{if(!e.activeFile||e.activeFile.type==="block"){s(r);return}const i=ke(r);i&&(t({type:"ADD_CELL",cell:i}),t({type:"SET_MAIN_VIEW",view:"notebook"}),fe(i.id))},[t,s,e.activeFile]);return o.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",overflow:"hidden",background:n.appBg},children:[o.jsx(Re,{t:n,conversations:p,activeId:h,busy:I,loading:d,onNewChat:P,onSelect:c,onDelete:A,onRename:M,onToggleFavorite:O}),o.jsx("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:o.jsx(he,{themeMode:e.themeMode,title:"Ask your data",askLayout:!0,scopeHint:u?`Scoped to ${u.domain}${u.modelAreaId?` · ${(V=u.modelAreaId.split("::").at(-1))==null?void 0:V.replace(/_/g," ")}`:""}${u.purpose?` for ${u.purpose}`:""}`:"Ask a question or request deep research",onClearScope:u?()=>{v(void 0),Ie(void 0)}:void 0,workspaceContext:u,audience:"stakeholder",initialMode:"auto",initialItems:T,onItemsChange:_,threadId:E,onThreadIdChange:$,onRunningChange:D,onOpenResearch:z,onOpenApp:q,onInsertSql:(r,i,l)=>S({sql:r,title:i,question:l==null?void 0:l.question,sourceRunId:l==null?void 0:l.sourceRunId}),onInsertDql:S,insertDqlActionLabel:"Open in notebook"},h)})]})}function Re({t:e,conversations:t,activeId:s,busy:n,loading:u,onNewChat:v,onSelect:p,onDelete:a,onRename:d,onToggleFavorite:w}){const j=n?"Finish the current question first":void 0,[h,y]=f.useState(null),[I,D]=f.useState(null),[T,E]=f.useState(""),_=t.filter(c=>c.favorite),$=t.filter(c=>!c.favorite),M=c=>{D(c.id),E(c.title)},O=()=>{I&&T.trim()&&d(I,T),D(null)},P=c=>{const A=c.id===s,q=h===c.id,z=I===c.id;return o.jsxs("div",{onMouseEnter:()=>y(c.id),onMouseLeave:()=>y(S=>S===c.id?null:S),style:{position:"relative",display:"flex",alignItems:"center"},children:[z?o.jsx("input",{autoFocus:!0,value:T,onChange:S=>E(S.target.value),onBlur:O,onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),O()),S.key==="Escape"&&(S.preventDefault(),D(null))},"aria-label":"Conversation name",style:{flex:1,minWidth:0,padding:"7px 10px",borderRadius:7,border:`1px solid ${e.accent}`,background:e.appBg,color:e.textPrimary,fontSize:12.5,fontWeight:600}}):o.jsxs("button",{type:"button",onClick:()=>p(c.id),onDoubleClick:()=>M(c),disabled:n&&!A,title:n&&!A?j:`${c.title} — double-click to rename`,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:7,border:"none",background:A?`${e.accent}1f`:q?`${e.textPrimary}0d`:"transparent",color:A?e.accent:e.textSecondary,cursor:n&&!A?"not-allowed":"pointer",opacity:n&&!A?.5:1,textAlign:"left",fontSize:12.5,fontWeight:A?600:500,paddingRight:q?56:10},children:[A&&n?o.jsx(J,{size:13,style:{flexShrink:0,color:e.accent,animation:"dql-agent-run-spin 0.8s linear infinite"}}):c.favorite?o.jsx(G,{size:13,style:{flexShrink:0,color:e.accent},fill:"currentColor"}):o.jsx(xe,{size:13,style:{flexShrink:0,opacity:.7}}),o.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:A&&n?"Working…":c.title}),q?null:o.jsx("span",{style:{flexShrink:0,fontSize:10,color:A&&n?e.accent:e.textMuted,fontWeight:A&&n?650:400},children:A&&n?"Live":Te(c.updatedAt)})]}),q&&!z?o.jsxs("div",{style:{position:"absolute",right:4,display:"inline-flex",gap:2},children:[o.jsx(W,{t:e,label:c.favorite?"Unpin conversation":"Pin conversation",onClick:()=>w(c.id),children:o.jsx(G,{size:12,fill:c.favorite?"currentColor":"none"})}),o.jsx(W,{t:e,label:"Rename conversation",onClick:()=>M(c),children:o.jsx(me,{size:12})}),o.jsx(W,{t:e,label:"Delete conversation",onClick:()=>a(c.id),children:o.jsx(le,{size:12})})]}):null]},c.id)};return o.jsxs("aside",{style:{width:248,flexShrink:0,borderRight:`1px solid ${e.headerBorder}`,background:e.cellBg,display:"flex",flexDirection:"column",minHeight:0},children:[o.jsx("div",{style:{padding:12},children:o.jsxs("button",{type:"button",onClick:v,disabled:n,title:j,style:{width:"100%",display:"inline-flex",alignItems:"center",gap:8,justifyContent:"center",padding:"9px 12px",borderRadius:8,border:`1px solid ${e.accent}`,background:e.accent,color:"var(--accent-on, #fff)",fontSize:13,fontWeight:650,cursor:n?"not-allowed":"pointer",opacity:n?.55:1},children:[o.jsx(de,{size:15,strokeWidth:2.4})," New chat"]})}),o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"0 8px 12px",display:"flex",flexDirection:"column",gap:2},children:u&&t.length===0?o.jsxs("div",{style:{padding:"10px 8px",display:"flex",alignItems:"center",gap:7,fontSize:11.5,color:e.textMuted},children:[o.jsx(J,{size:13,style:{animation:"dql-agent-run-spin 0.8s linear infinite"}}),"Restoring project chats…"]}):t.length===0?o.jsx("div",{style:{padding:"10px 8px",fontSize:11.5,color:e.textMuted,lineHeight:1.5},children:"No past chats yet. Your conversations show up here so you can pick up where you left off."}):o.jsxs(o.Fragment,{children:[_.length>0?o.jsxs(o.Fragment,{children:[o.jsx(L,{t:e,children:"Favourites"}),_.map(c=>P(c)),o.jsx(L,{t:e,children:"Recent"})]}):o.jsx(L,{t:e,children:"Recent"}),$.map(c=>P(c))]})}),o.jsxs("div",{style:{padding:"10px 12px",borderTop:`1px solid ${e.headerBorder}`,display:"flex",alignItems:"center",gap:7,fontSize:11,color:e.textMuted},children:[o.jsx(ce,{size:12,style:{flexShrink:0,color:e.success}}),o.jsx("span",{children:"Private project history · not committed to Git"})]})]})}function L({t:e,children:t}){return o.jsx("div",{style:{padding:"8px 8px 4px",fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:e.textMuted},children:t})}function W({t:e,label:t,onClick:s,children:n}){return o.jsx("button",{type:"button","aria-label":t,title:t,onClick:u=>{u.stopPropagation(),s()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:5,border:"none",background:e.cellBg,color:e.textMuted,cursor:"pointer"},children:n})}export{Ye as AnalyticsHome,ke as askNotebookCellFromPayload,ye as mergePersistedAskConversations};
|