@duckcodeailabs/dql-cli 1.12.10 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps-api.d.ts +151 -3
- package/dist/apps-api.d.ts.map +1 -1
- package/dist/apps-api.js +675 -97
- package/dist/apps-api.js.map +1 -1
- package/dist/assets/dql-notebook/assets/AgentAnswerCard-Cp0eh6zU.js +5 -0
- package/dist/assets/dql-notebook/assets/{AgentLogPage-uvVs284-.js → AgentLogPage-CBGEoGmU.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildDialog-DEUS19WF.js → AiBuildDialog-CwAD3tXE.js} +1 -1
- package/dist/assets/dql-notebook/assets/AiBuildResult-CyqTuQe5.js +33 -0
- package/dist/assets/dql-notebook/assets/AiSidePanel-DjB8PWHG.js +6 -0
- package/dist/assets/dql-notebook/assets/AnalyticsHome-B7BkvA-R.js +6 -0
- package/dist/assets/dql-notebook/assets/AppsView-CUrqtEGC.js +4583 -0
- package/dist/assets/dql-notebook/assets/BlockStudio-Bl0aGQJR.js +60 -0
- package/dist/assets/dql-notebook/assets/{BusinessArtifactView-D8FIgrkF.js → BusinessArtifactView-C4SZVNW-.js} +1 -1
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-B0uxitnx.js +22 -0
- package/dist/assets/dql-notebook/assets/GitPage-BfVD4tVq.js +7 -0
- package/dist/assets/dql-notebook/assets/GlobalAiRail-DUwdy3fB.js +1 -0
- package/dist/assets/dql-notebook/assets/GovernedContextPage-D9f26ZFb.js +7 -0
- package/dist/assets/dql-notebook/assets/{HelpDocsPage-Bc5pLakt.js → HelpDocsPage-BDPNVot1.js} +3 -3
- package/dist/assets/dql-notebook/assets/{HomePage-DQSo-K4y.js → HomePage-DiOnRhEG.js} +9 -4
- package/dist/assets/dql-notebook/assets/LineageDAG-BiUFX2KL.js +1 -0
- package/dist/assets/dql-notebook/assets/{LineageDetailView-CZEx2r1H.js → LineageDetailView-CfbSvlPJ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDrawer-P7ZdOW8-.js → LineageDrawer-CgTScaGB.js} +1 -1
- package/dist/assets/dql-notebook/assets/LineagePathBreadcrumb-D7ZA7k68.js +14 -0
- package/dist/assets/dql-notebook/assets/{MiniLineageGraph-Ctp_yFh8.js → MiniLineageGraph-GkD4y17x.js} +1 -1
- package/dist/assets/dql-notebook/assets/NewBlockModal-B9TfRjt7.js +1 -0
- package/dist/assets/dql-notebook/assets/NewNotebookModal-BbO9NKUl.js +46 -0
- package/dist/assets/dql-notebook/assets/NotebookEditor-CuMpvXR9.js +200 -0
- package/dist/assets/dql-notebook/assets/ReadinessPage-BROJ9YBM.js +1 -0
- package/dist/assets/dql-notebook/assets/{SetupOnboarding-DX2f53J2.js → SetupOnboarding-BCcZlpuQ.js} +2 -2
- package/dist/assets/dql-notebook/assets/{TrustBadge-DPnKzRSY.js → TrustBadge-vQQh8d0D.js} +1 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-Dj4AXAhT.js +83 -0
- package/dist/assets/dql-notebook/assets/{answer-to-notebook-Bm9oByWA.js → answer-to-notebook-DuqCcDDl.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-left-D2FbLWqh.js → arrow-left-CMe1kkOL.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-right-OYItAZ-s.js → arrow-right-DvB_DONr.js} +2 -2
- package/dist/assets/dql-notebook/assets/{book-open-text-BnnirfAc.js → book-open-text-CJ3NAvrs.js} +1 -1
- package/dist/assets/dql-notebook/assets/{bot-BJNxPYFm.js → bot-CV8DYRrt.js} +1 -1
- package/dist/assets/dql-notebook/assets/{chevron-up-DM5LX-26.js → chevron-up-HxU1l85K.js} +2 -2
- package/dist/assets/dql-notebook/assets/{circle-x-Dic_-4tF.js → circle-x-BCgtha1W.js} +1 -1
- package/dist/assets/dql-notebook/assets/{codemirror-1_I9gm6Z.js → codemirror-DXt7RW72.js} +1 -1
- package/dist/assets/dql-notebook/assets/{dagre.esm-C9zxjHHX.js → dagre.esm-GKp7qoUL.js} +1 -1
- package/dist/assets/dql-notebook/assets/{external-link-DHxAcoCE.js → external-link-C-PXokWV.js} +1 -1
- package/dist/assets/dql-notebook/assets/{grip-vertical-02I-EOjL.js → grip-vertical-B4EHbGXW.js} +1 -1
- package/dist/assets/dql-notebook/assets/index-1mIC_XX4.js +634 -0
- package/dist/assets/dql-notebook/assets/{link-2-Delh-lai.js → link-2-BLx-goet.js} +2 -2
- package/dist/assets/dql-notebook/assets/{list-tree-BrIZg6l6.js → list-tree-BRFpEmvV.js} +1 -1
- package/dist/assets/dql-notebook/assets/{maximize-2-CQOA-bbN.js → maximize-2-CCd5uRIZ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{minimize-2-CUDBPkwe.js → minimize-2-CDwSCGlO.js} +1 -1
- package/dist/assets/dql-notebook/assets/{panel-right-open-CwhZfkKJ.js → panel-right-open-CunA1xO7.js} +2 -2
- package/dist/assets/dql-notebook/assets/{pencil-Cf6-MgpT.js → pencil-D_I14Wyk.js} +2 -2
- package/dist/assets/dql-notebook/assets/{rotate-ccw-DndbJAiz.js → rotate-ccw-DOrfTZk8.js} +2 -2
- package/dist/assets/dql-notebook/assets/{semantic-fields-DwKPY_mU.js → semantic-fields-AfQvjt5R.js} +1 -1
- package/dist/assets/dql-notebook/assets/{star-DvcMC9wZ.js → star-DDhv4e8M.js} +2 -2
- package/dist/assets/dql-notebook/assets/{triangle-alert-DUf4Ook0.js → triangle-alert-2ZXx8wAu.js} +1 -1
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-3rzkZrqc.js +18 -0
- package/dist/assets/dql-notebook/assets/{user-round-DSt0xU3K.js → user-round-BA074kiQ.js} +3 -3
- package/dist/assets/dql-notebook/assets/{wand-sparkles-ro8Cq0ro.js → wand-sparkles-CEYHLt9b.js} +1 -1
- package/dist/assets/dql-notebook/assets/{workflow-DVJXehjU.js → workflow-CZtyrcR-.js} +2 -2
- package/dist/assets/dql-notebook/assets/{wrench-DxUnoHtz.js → wrench-Ong23-wu.js} +1 -1
- package/dist/assets/dql-notebook/assets/{x-9Gtb3EAd.js → x-CSo1M3tu.js} +2 -2
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/llm/providers/dql-agent-provider.d.ts +4 -3
- package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
- package/dist/llm/providers/dql-agent-provider.js +13 -10
- package/dist/llm/providers/dql-agent-provider.js.map +1 -1
- package/dist/local-operation-coordinator.d.ts +59 -0
- package/dist/local-operation-coordinator.d.ts.map +1 -0
- package/dist/local-operation-coordinator.js +256 -0
- package/dist/local-operation-coordinator.js.map +1 -0
- package/dist/local-runtime.d.ts +89 -2
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +2158 -461
- 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-Dp4odOLE.js +0 -5
- package/dist/assets/dql-notebook/assets/AiBuildResult-B9KmBRsh.js +0 -33
- package/dist/assets/dql-notebook/assets/AiSidePanel-C7BZVSkM.js +0 -6
- package/dist/assets/dql-notebook/assets/AnalyticsHome-4TgtH6SB.js +0 -6
- package/dist/assets/dql-notebook/assets/AppsView-CnfNtk5W.js +0 -4466
- package/dist/assets/dql-notebook/assets/BlockStudio-DUXN3MKz.js +0 -60
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-DR8hTZ95.js +0 -22
- package/dist/assets/dql-notebook/assets/GitPage-BS2sm9zh.js +0 -7
- package/dist/assets/dql-notebook/assets/GlobalAiRail-B_MZsB0z.js +0 -1
- package/dist/assets/dql-notebook/assets/GovernedContextPage-CNM5UCAH.js +0 -7
- package/dist/assets/dql-notebook/assets/LineageDAG-RdpWmGmR.js +0 -1
- package/dist/assets/dql-notebook/assets/LineagePathBreadcrumb-DTUMFkJ8.js +0 -14
- package/dist/assets/dql-notebook/assets/NewBlockModal-BLtjuWGy.js +0 -1
- package/dist/assets/dql-notebook/assets/NewNotebookModal-xgaKB2kI.js +0 -46
- package/dist/assets/dql-notebook/assets/NotebookEditor-D6RgLQw-.js +0 -202
- package/dist/assets/dql-notebook/assets/ReadinessPage-C8hATaT_.js +0 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-CwxQ4T19.js +0 -83
- package/dist/assets/dql-notebook/assets/index-Ca3UeUWI.js +0 -644
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-DbdBi0oH.js +0 -18
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{g as Ue,u as fe,t as we,r as d,a as T,j as e,a0 as se,Y as ye,L as H,S as ne,P as X,B as Ye,b as Ae,T as ie,X as We,J as de,N as Ie,h as Je,aF as Oe,e as Ve}from"./index-Ca3UeUWI.js";import{T as Le}from"./triangle-alert-DUf4Ook0.js";import{U as Te,G as re}from"./user-round-DSt0xU3K.js";import{C as Fe}from"./chevron-up-DM5LX-26.js";import{P as Ne}from"./pencil-Cf6-MgpT.js";import{X as me}from"./x-9Gtb3EAd.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 Xe=[["path",{d:"M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z",key:"16rjxf"}],["path",{d:"M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193",key:"178nd4"}],["circle",{cx:"10.5",cy:"6.5",r:".5",fill:"currentColor",key:"12ikhr"}]],Ze=Ue("tags",Xe),le="dql-context-bootstrap-session",ae="dql-context-bootstrap-selection";function et(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").slice(0,64)}function $e(t){return t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)}function tt(){return{id:"",name:"",owner:"",boundedContext:"",sourceSystems:[],description:""}}function nt({embedded:t=!1}={}){const{state:n}=fe(),i=we[n.themeMode],[l,s]=d.useState([]),[p,o]=d.useState(!0),[r,g]=d.useState(null),[k,m]=d.useState(null),[c,W]=d.useState(null),[j,h]=d.useState(!1),[u,I]=d.useState(null),[b,B]=d.useState(null),[P,y]=d.useState(!1),[v,A]=d.useState(!1),[O,M]=d.useState(null),[$,a]=d.useState([]),C=d.useCallback(()=>{let x=!1;return o(!0),g(null),T.getDomains().then(S=>{x||s(Array.isArray(S==null?void 0:S.domains)?S.domains:[])}).catch(S=>{x||(s([]),g(S instanceof Error&&S.message?S.message:"Could not load domains. Is the local DQL server running?"))}).finally(()=>{x||o(!1)}),()=>{x=!0}},[]);d.useEffect(()=>C(),[C]),d.useEffect(()=>{const x=window.sessionStorage.getItem(le);let S=!1;const D=F=>{if(F&&!S){B(F);try{const R=JSON.parse(window.sessionStorage.getItem(ae)??"[]");a(Array.isArray(R)?R.filter(f=>typeof f=="string"):F.candidates.filter(f=>f.action!=="unchanged").map(f=>f.id))}catch{a(F.candidates.filter(R=>R.action!=="unchanged").map(R=>R.id))}}};return(x?T.getContextBootstrap(x):T.getLatestContextBootstrap()).then(D).catch(async()=>{window.sessionStorage.removeItem(le),window.sessionStorage.removeItem(ae),x&&D(await T.getLatestContextBootstrap().catch(()=>null))}),()=>{S=!0}},[]),d.useEffect(()=>{b&&(window.sessionStorage.setItem(le,b.id),window.sessionStorage.setItem(ae,JSON.stringify($)))},[b==null?void 0:b.id,$]);const L=d.useMemo(()=>[...l].sort((x,S)=>x.name.localeCompare(S.name)),[l]),z=d.useCallback(x=>{s(S=>{const D=S.findIndex(F=>F.id===x.id);if(D===-1)return[...S,x];const E=[...S];return E[D]=x,E}),m(null)},[]),J=d.useCallback(async()=>{if(c){h(!0),I(null);try{await T.deleteDomain(c.id),s(x=>x.filter(S=>S.id!==c.id)),W(null)}catch(x){I(x instanceof Error&&x.message?x.message:"Could not delete this domain.")}finally{h(!1)}}},[c]),K=d.useCallback(async()=>{y(!0),M(null);try{const x=await T.startContextBootstrap({ai:!0});B(x);const S=x.candidates.filter(D=>D.action!=="unchanged").map(D=>D.id);a(S),window.sessionStorage.setItem(le,x.id),window.sessionStorage.setItem(ae,JSON.stringify(S))}catch(x){M(x instanceof Error?x.message:"Could not draft repository context.")}finally{y(!1)}},[]);d.useEffect(()=>{if(!t)return;const x=()=>{K()};return window.addEventListener("dql:context-build",x),()=>window.removeEventListener("dql:context-build",x)},[t,K]),d.useEffect(()=>{if(!b||["ready","needs_attention"].includes(b.status))return;let x=!1;const S=async()=>{try{const E=await T.getContextBootstrap(b.id);x||B(E)}catch(E){x||M(E instanceof Error?E.message:"Could not update AI draft progress.")}};S();const D=window.setInterval(()=>void S(),750);return()=>{x=!0,window.clearInterval(D)}},[b==null?void 0:b.id,b==null?void 0:b.status]);const Q=d.useCallback(async()=>{if(!(!b||$.length===0)){A(!0),M(null);try{await T.saveContextBootstrapSelected(b.id,$),B(null),a([]),window.sessionStorage.removeItem(le),window.sessionStorage.removeItem(ae),C()}catch(x){M(x instanceof Error?x.message:"Could not save selected drafts.")}finally{A(!1)}}},[b,$,C]);return e.jsxs("div",{style:{flex:1,minWidth:0,overflow:"auto",background:i.appBg},children:[e.jsxs("div",{style:{maxWidth:980,margin:"0 auto",padding:"22px 28px 40px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-end",justifyContent:"space-between",gap:18,marginBottom:18},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[e.jsx(se,{size:20,strokeWidth:1.9,color:i.accent}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:i.textPrimary},children:"Domains"})]}),e.jsx("div",{style:{fontSize:13,color:i.textMuted,marginTop:6,maxWidth:680,lineHeight:1.5},children:"Domains are the top of your business model — each one owns the terms, skills, and blocks beneath it. Name the business area, who owns it, the bounded context, and the source systems it draws from."})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[e.jsxs("button",{type:"button",onClick:()=>C(),title:"Refresh",style:Z(i),children:[e.jsx(ye,{size:13,strokeWidth:2})," Refresh"]}),e.jsxs("button",{type:"button",onClick:()=>void K(),disabled:P,style:Z(i),children:[P?e.jsx(H,{size:13,strokeWidth:2}):e.jsx(ne,{size:13,strokeWidth:2})," Draft with AI"]}),e.jsxs("button",{type:"button",onClick:()=>m({kind:"create"}),style:ue(i),children:[e.jsx(X,{size:14,strokeWidth:2.2})," Add domain"]})]})]}),p?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:i.textMuted,fontSize:13,padding:"40px 0"},children:[e.jsx(H,{size:15,strokeWidth:2})," Loading domains…"]}):r?e.jsx(ot,{t:i,message:r,onRetry:()=>C()}):L.length===0?e.jsx(rt,{t:i,onAdd:()=>m({kind:"create"})}):e.jsx("div",{style:{display:"grid",gap:10},children:L.map(x=>e.jsx(it,{domain:x,t:i,onEdit:()=>m({kind:"edit",domain:x}),onDelete:()=>{I(null),W(x)}},x.id))}),O?e.jsx("div",{style:{marginTop:12},children:e.jsx(pe,{t:i,tone:"error",children:O})}):null,b?e.jsxs("section",{style:{marginTop:18,border:`1px solid ${i.cellBorder}`,borderRadius:10,background:i.cellBg,padding:14},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,alignItems:"center",flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:750,color:i.textPrimary},children:"Repository-guided AI draft"}),e.jsx("div",{style:{fontSize:12,color:i.textMuted,marginTop:3},children:"Inventory is deterministic; AI may enrich only grounded prose and guidance. Nothing is written to Git until you save."})]}),e.jsxs("button",{type:"button",disabled:v||$.length===0||!["ready","needs_attention"].includes(b.status),onClick:()=>void Q(),style:{...ue(i),opacity:v||$.length===0||!["ready","needs_attention"].includes(b.status)?.55:1},children:[v?e.jsx(H,{size:13,strokeWidth:2}):e.jsx(X,{size:13,strokeWidth:2})," Save selected drafts"]})]}),e.jsx(lt,{t:i,session:b}),e.jsx("div",{style:{display:"grid",gap:9,marginTop:12},children:b.candidates.map(x=>{const S=x.action!=="unchanged",D=$.includes(x.id);return e.jsx(at,{candidate:x,selected:D,selectable:S,disabled:v,t:i,onToggle:()=>a(E=>D?E.filter(F=>F!==x.id):[...E,x.id])},x.id)})})]}):null]}),k?e.jsx(st,{mode:k,existingIds:l.map(x=>x.id),domains:l,t:i,onClose:()=>m(null),onSaved:z}):null,c?e.jsx(dt,{domain:c,t:i,deleting:j,error:u,onCancel:()=>{j||W(null)},onConfirm:J}):null]})}function it({domain:t,t:n,onEdit:i,onDelete:l}){const s=t.sourceSystems??[],[p,o]=d.useState(!1);return e.jsxs("section",{style:{border:`1px solid ${n.cellBorder}`,borderRadius:10,background:n.cellBg,padding:"13px 15px",display:"flex",alignItems:"flex-start",gap:14},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:13.5,fontWeight:750,color:n.textPrimary},children:t.name}),t.parent?e.jsxs("span",{style:Se(n),children:["↳ ",t.parent]}):null,t.owner?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,color:n.textMuted},children:[e.jsx(Te,{size:11,strokeWidth:2})," ",t.owner]}):null,t.businessOwner?e.jsxs("span",{style:Se(n),children:[e.jsx(Te,{size:10,strokeWidth:2.2})," Business owner: ",t.businessOwner]}):null]}),t.description?e.jsx("div",{style:{fontSize:12.5,color:n.textSecondary,marginTop:5,lineHeight:1.5},children:t.description}):e.jsx("div",{style:{fontSize:12,color:n.textMuted,marginTop:5,fontStyle:"italic"},children:"No description yet."}),s.length>0?e.jsx("div",{style:{display:"flex",gap:5,marginTop:9,flexWrap:"wrap"},children:s.map(r=>e.jsx("span",{style:Ce(n),children:r},r))}):null,e.jsxs("div",{style:{display:"flex",gap:7,marginTop:9,flexWrap:"wrap"},children:[e.jsx(je,{t:n,icon:e.jsx(Ye,{size:11,strokeWidth:2}),label:"blocks",count:t.blockCount??0}),e.jsx(je,{t:n,icon:e.jsx(re,{size:11,strokeWidth:2}),label:"skills",count:t.skillCount??0}),e.jsx(je,{t:n,icon:e.jsx(Ze,{size:11,strokeWidth:2}),label:"terms",count:t.termCount??0})]}),p?e.jsxs("div",{style:{display:"grid",gap:9,marginTop:12,paddingTop:11,borderTop:`1px solid ${n.btnBorder}`},children:[t.boundedContext?e.jsx(De,{t:n,label:"Business boundary",children:t.boundedContext}):null,t.businessOutcome?e.jsx(De,{t:n,label:"Decision outcome",children:t.businessOutcome}):null,e.jsx(ce,{t:n,label:"In scope",values:t.inScope,empty:"Not defined yet"}),e.jsx(ce,{t:n,label:"Out of scope",values:t.outOfScope,empty:"Not defined yet"}),e.jsx(ce,{t:n,label:"Primary terms",values:t.primaryTerms,empty:"No terms linked yet"}),e.jsx(ce,{t:n,label:"Tags",values:t.tags,empty:"No tags"})]}):null]}),e.jsxs("div",{style:{display:"flex",gap:6,flexShrink:0},children:[e.jsxs("button",{type:"button",onClick:()=>o(r=>!r),style:{...Z(n),padding:"5px 7px",fontSize:11.5},title:p?"Hide domain details":"Show domain details",children:[p?e.jsx(Fe,{size:13}):e.jsx(Ae,{size:13}),p?"Less":"Details"]}),e.jsx("button",{type:"button",onClick:i,style:ke(n),title:"Edit domain",children:e.jsx(Ne,{size:13,strokeWidth:2})}),e.jsx("button",{type:"button",onClick:l,style:ke(n),title:"Delete domain",children:e.jsx(ie,{size:13,strokeWidth:2})})]})]})}function st({mode:t,existingIds:n,domains:i,t:l,onClose:s,onSaved:p}){const o=t.kind==="edit",[r,g]=d.useState(()=>t.kind==="edit"?{...t.domain}:tt()),[k,m]=d.useState(o),[c,W]=d.useState(!1),[j,h]=d.useState(null),u=d.useCallback((y,v)=>{g(A=>({...A,[y]:v}))},[]),I=y=>{g(v=>({...v,name:y,...!o&&!k?{id:$e(y)}:{}}))},b=!o&&r.id.length>0&&n.includes(r.id),B=r.id.trim().length>0&&r.name.trim().length>0&&!b&&!c,P=d.useCallback(async()=>{var v,A,O,M,$;const y={...r,id:r.id.trim(),name:r.name.trim(),owner:(v=r.owner)!=null&&v.trim()?r.owner.trim():void 0,businessOwner:(A=r.businessOwner)!=null&&A.trim()?r.businessOwner.trim():void 0,parent:(O=r.parent)!=null&&O.trim()?r.parent.trim():void 0,boundedContext:(M=r.boundedContext)!=null&&M.trim()?r.boundedContext.trim():void 0,description:($=r.description)!=null&&$.trim()?r.description.trim():void 0,sourceSystems:(r.sourceSystems??[]).map(a=>a.trim()).filter(Boolean),primaryTerms:(r.primaryTerms??[]).map(a=>a.trim()).filter(Boolean),tags:(r.tags??[]).map(a=>a.trim()).filter(Boolean),inScope:(r.inScope??[]).map(a=>a.trim()).filter(Boolean),outOfScope:(r.outOfScope??[]).map(a=>a.trim()).filter(Boolean),dbtGroups:(r.dbtGroups??[]).map(a=>a.trim()).filter(Boolean),dbtPaths:(r.dbtPaths??[]).map(a=>a.trim()).filter(Boolean),dbtTags:(r.dbtTags??[]).map(a=>a.trim()).filter(Boolean),semanticDomains:(r.semanticDomains??[]).map(a=>a.trim()).filter(Boolean),semanticTags:(r.semanticTags??[]).map(a=>a.trim()).filter(Boolean)};W(!0),h(null);try{const a=o?await T.updateDomain(y.id,y):await T.createDomain(y);p(a.domain??y)}catch(a){h(a instanceof Error&&a.message?a.message:"Could not save this domain. Try again.")}finally{W(!1)}},[r,o,p]);return e.jsx("div",{style:gt,onClick:()=>!c&&s(),children:e.jsxs("div",{style:ht(l),onClick:y=>y.stopPropagation(),children:[e.jsxs("div",{style:ft(l),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(se,{size:16,strokeWidth:2,color:l.accent}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:l.textPrimary},children:o?"Edit domain":"New domain"})]}),e.jsx("button",{type:"button",onClick:()=>!c&&s(),style:ke(l),title:"Close",children:e.jsx(me,{size:15,strokeWidth:2})})]}),e.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"16px 18px",display:"grid",gap:16},children:[e.jsx(q,{label:"Name",t:l,hint:o?void 0:"A short, human label for this business area.",children:e.jsx("input",{type:"text",value:r.name,onChange:y=>I(y.target.value),placeholder:"Revenue",style:U(l)})}),e.jsxs(q,{label:"ID (slug)",t:l,hint:"Used as the on-disk identifier. Letters, numbers, and dashes.",children:[e.jsx("input",{type:"text",value:r.id,disabled:o,onChange:y=>{m(!0),u("id",et(y.target.value))},onBlur:()=>u("id",$e(r.id)),placeholder:"revenue",style:{...U(l),fontFamily:l.fontMono,opacity:o?.7:1}}),b?e.jsx(pe,{t:l,tone:"error",children:"A domain with this id already exists."}):null]}),e.jsx(q,{label:"Parent domain",t:l,hint:"Optional. Depth becomes Domain, Subdomain, Microdomain, and beyond.",children:e.jsxs("select",{value:r.parent??"",onChange:y=>u("parent",y.target.value||void 0),style:U(l),children:[e.jsx("option",{value:"",children:"Top-level domain"}),i.filter(y=>y.id!==r.id).map(y=>e.jsx("option",{value:y.id,children:y.name},y.id))]})}),e.jsx(q,{label:"Owner",t:l,hint:"The team or person accountable for this domain.",children:e.jsx("input",{type:"text",value:r.owner??"",onChange:y=>u("owner",y.target.value),placeholder:"finance-analytics",style:U(l)})}),e.jsx(q,{label:"Business owner",t:l,hint:"The stakeholder accountable for business use and definitions.",children:e.jsx("input",{type:"text",value:r.businessOwner??"",onChange:y=>u("businessOwner",y.target.value),placeholder:"Revenue Operations",style:U(l)})}),e.jsx(q,{label:"Bounded context",t:l,hint:"The conceptual boundary this domain owns, e.g. 'recognized revenue and invoicing'.",children:e.jsx("input",{type:"text",value:r.boundedContext??"",onChange:y=>u("boundedContext",y.target.value),placeholder:"Recognized revenue and invoicing",style:U(l)})}),e.jsx(q,{label:"Source systems",t:l,hint:"The upstream systems this domain draws from — type a name and press Enter.",children:e.jsx(be,{t:l,values:r.sourceSystems??[],onChange:y=>u("sourceSystems",y),placeholder:"Add a source system…"})}),e.jsx(q,{label:"Primary terms",t:l,hint:"Business concepts the agent should use to recognize this domain.",children:e.jsx(be,{t:l,values:r.primaryTerms??[],onChange:y=>u("primaryTerms",y),placeholder:"Add a term…"})}),e.jsx(q,{label:"Scope tags",t:l,hint:"Short labels used for routing and discovery.",children:e.jsx(be,{t:l,values:r.tags??[],onChange:y=>u("tags",y),placeholder:"Add a tag…"})}),e.jsx(q,{label:"Description",t:l,hint:"What this domain covers and how it's used.",children:e.jsx("textarea",{value:r.description??"",onChange:y=>u("description",y.target.value),rows:5,placeholder:"All recognized-revenue metrics and the blocks that report them, sourced from the billing warehouse.",style:pt(l)})}),j?e.jsx(pe,{t:l,tone:"error",children:j}):null]}),e.jsxs("div",{style:yt(l),children:[e.jsx("button",{type:"button",onClick:()=>!c&&s(),style:Z(l),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:P,disabled:!B,style:{...ue(l),opacity:B?1:.55},children:[c?e.jsx(H,{size:13,strokeWidth:2}):null,c?"Saving…":o?"Save changes":"Create domain"]})]})]})})}function be({t,values:n,onChange:i,placeholder:l}){const[s,p]=d.useState(""),o=r=>{const g=r.trim();!g||n.includes(g)||(i([...n,g]),p(""))};return e.jsxs("div",{style:{display:"grid",gap:7},children:[n.length>0?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:n.map(r=>e.jsxs("span",{style:ut(t),children:[r,e.jsx("button",{type:"button",onClick:()=>i(n.filter(g=>g!==r)),style:xt(t),title:"Remove",children:e.jsx(me,{size:11,strokeWidth:2.4})})]},r))}):null,e.jsx("input",{type:"text",value:s,onChange:r=>p(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),o(s))},placeholder:l,style:U(t)})]})}function rt({t,onAdd:n}){return e.jsxs("div",{style:{border:`1px dashed ${t.cellBorder}`,borderRadius:12,background:t.cellBg,padding:"34px 28px",textAlign:"center",display:"grid",gap:12,justifyItems:"center"},children:[e.jsx("div",{style:{width:44,height:44,borderRadius:10,background:`${t.accent}18`,color:t.accent,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(se,{size:22,strokeWidth:1.9})}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:t.textPrimary},children:"Name your business domains"}),e.jsx("div",{style:{fontSize:13,color:t.textMuted,maxWidth:460,lineHeight:1.55},children:`Domains organize everything below them — terms, skills, and blocks. Add your first one, like "Revenue" or "Customer", and you'll be able to pick it when authoring blocks and skills.`}),e.jsxs("button",{type:"button",onClick:n,style:{...ue(t),marginTop:4},children:[e.jsx(X,{size:14,strokeWidth:2.2})," Add your first domain"]})]})}function ot({t,message:n,onRetry:i}){return e.jsxs("div",{style:{border:`1px solid ${t.warning}55`,borderRadius:10,background:`${t.warning}12`,padding:"16px 18px",display:"flex",alignItems:"flex-start",gap:11},children:[e.jsx(Le,{size:16,strokeWidth:2,color:t.warning,style:{marginTop:1,flexShrink:0}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13,fontWeight:650,color:t.textPrimary},children:"Domains are not available right now"}),e.jsx("div",{style:{fontSize:12.5,color:t.textSecondary,marginTop:4,lineHeight:1.5},children:n}),e.jsxs("button",{type:"button",onClick:i,style:{...Z(t),marginTop:10},children:[e.jsx(ye,{size:13,strokeWidth:2})," Retry"]})]})]})}function lt({t,session:n}){var s;const i=!["ready","needs_attention"].includes(n.status),l=n.ai.mode==="evidence_only"?"Evidence-only":n.ai.provider?`${n.ai.provider} grounded`:"Preparing AI";return e.jsxs("div",{style:{marginTop:14,padding:"10px 11px",borderRadius:8,background:t.appBg,border:`1px solid ${t.btnBorder}`},children:[e.jsxs("div",{style:{display:"flex",gap:9,alignItems:"center",flexWrap:"wrap",fontSize:12,color:t.textSecondary},children:[i?e.jsx(H,{size:14,strokeWidth:2,color:t.accent}):e.jsx(ne,{size:14,strokeWidth:2,color:t.accent}),e.jsx("strong",{style:{color:t.textPrimary,textTransform:"capitalize"},children:n.status.replace("_"," ")}),e.jsx("span",{children:l}),e.jsxs("span",{children:[n.progress.domains.ready,"/",n.progress.domains.total," domains"]}),e.jsxs("span",{children:[n.progress.skills.ready,"/",n.progress.skills.total," skills"]})]}),e.jsx("div",{style:{height:5,borderRadius:999,background:t.btnBg,overflow:"hidden",marginTop:9},children:e.jsx("div",{style:{width:`${Math.max(3,Math.min(100,n.progress.percent))}%`,height:"100%",background:t.accent,transition:"width 260ms ease"}})}),e.jsx("div",{style:{marginTop:7,fontSize:11.5,color:t.textMuted,lineHeight:1.45},children:n.progress.message}),(s=n.warnings)!=null&&s.length?e.jsx("div",{style:{marginTop:7,fontSize:11.5,color:t.warning,lineHeight:1.45},children:n.warnings.slice(-2).join(" ")}):null]})}function at({candidate:t,selected:n,selectable:i,disabled:l,t:s,onToggle:p}){var W,j,h,u,I,b,B,P,y,v,A,O,M,$,a,C,L,z,J,K,Q,x,S,D,E,F;const[o,r]=d.useState(!1),g=t.kind==="domain",k=((W=t.domain)==null?void 0:W.name)??((j=t.skill)==null?void 0:j.id)??t.id.replace(/^(domain|skill):/,""),m=g?((h=t.domain)==null?void 0:h.description)??((u=t.domain)==null?void 0:u.boundedContext):((I=t.skill)==null?void 0:I.description)??((B=(b=t.skill)==null?void 0:b.body)==null?void 0:B.split(`
|
|
7
|
-
`).find(Boolean)),c=g?[["Business outcome",(P=t.domain)==null?void 0:P.businessOutcome],["In scope",(v=(y=t.domain)==null?void 0:y.inScope)==null?void 0:v.join(" · ")],["Out of scope",(O=(A=t.domain)==null?void 0:A.outOfScope)==null?void 0:O.join(" · ")],["Primary terms",($=(M=t.domain)==null?void 0:M.primaryTerms)==null?void 0:$.join(" · ")]]:[["Applies when",(C=(a=t.skill)==null?void 0:a.triggers)==null?void 0:C.join(" · ")],["Ask first when",(z=(L=t.skill)==null?void 0:L.clarifyWhen)==null?void 0:z.join(" · ")],["Avoid when",(K=(J=t.skill)==null?void 0:J.exclusions)==null?void 0:K.join(" · ")],["Preferred metrics",(x=(Q=t.skill)==null?void 0:Q.preferredMetrics)==null?void 0:x.join(" · ")],["Preferred blocks",(D=(S=t.skill)==null?void 0:S.preferredBlocks)==null?void 0:D.join(" · ")]];return e.jsx("article",{style:{border:`1px solid ${n?`${s.accent}66`:s.btnBorder}`,background:n?`${s.accent}08`:s.appBg,borderRadius:8,padding:"10px 11px",opacity:i?1:.72},children:e.jsxs("div",{style:{display:"flex",gap:9,alignItems:"flex-start"},children:[e.jsx("input",{"aria-label":`Select ${g?"domain":"skill"} ${k}`,type:"checkbox",disabled:!i||l,checked:n,onChange:p,style:{marginTop:3}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",gap:7,alignItems:"center",flexWrap:"wrap"},children:[e.jsxs("strong",{style:{color:s.textPrimary,fontSize:12.5},children:[g?"Domain":"Skill"," · ",k]}),e.jsx("span",{style:Se(s),children:t.action.replace("_"," ")}),e.jsxs("span",{style:{fontSize:11,color:s.textMuted},children:[Math.round(t.confidence*100),"% evidence confidence"]})]}),m?e.jsx("p",{style:{marginTop:5,color:s.textSecondary,fontSize:12,lineHeight:1.45},children:m}):e.jsx("p",{style:{marginTop:5,color:s.textMuted,fontSize:12,fontStyle:"italic"},children:"Waiting for grounded guidance…"}),e.jsx("div",{style:{display:"flex",gap:5,marginTop:7,flexWrap:"wrap"},children:t.evidence.map(R=>e.jsx("span",{style:Ce(s),children:R},R))}),o?e.jsxs("div",{style:{marginTop:9,display:"grid",gap:6,borderTop:`1px solid ${s.btnBorder}`,paddingTop:9},children:[c.filter(([,R])=>!!R).map(([R,f])=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"116px minmax(0, 1fr)",gap:8,fontSize:11.5,lineHeight:1.45},children:[e.jsx("strong",{style:{color:s.textMuted},children:R}),e.jsx("span",{style:{color:s.textSecondary},children:f})]},R)),!g&&((E=t.skill)!=null&&E.body)?e.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontFamily:s.font,fontSize:11.5,color:s.textSecondary,background:s.cellBg,padding:9,borderRadius:6,maxHeight:180,overflow:"auto"},children:t.skill.body}):null,(F=t.notes)!=null&&F.length?e.jsx("div",{style:{fontSize:11.5,color:s.accent},children:t.notes.join(" ")}):null]}):null]}),e.jsxs("button",{type:"button",onClick:()=>r(R=>!R),style:{...Z(s),padding:"4px 6px",fontSize:11.5},"aria-expanded":o,children:[o?e.jsx(Fe,{size:13}):e.jsx(Ae,{size:13}),o?"Less":"Review"]})]})})}function dt({domain:t,t:n,deleting:i,error:l,onCancel:s,onConfirm:p}){return e.jsx("div",{style:mt,onClick:s,children:e.jsxs("div",{style:bt(n),onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[e.jsx(ie,{size:16,strokeWidth:2,color:n.error}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:n.textPrimary},children:"Delete this domain?"})]}),e.jsxs("div",{style:{fontSize:13,color:n.textSecondary,lineHeight:1.55},children:[e.jsx("span",{style:{fontWeight:700,color:n.textPrimary},children:t.name})," will be removed. Blocks, skills, and terms that referenced it will become unassigned. This can't be undone."]}),l?e.jsx(pe,{t:n,tone:"error",children:l}):null,e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:s,disabled:i,style:Z(n),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:p,disabled:i,style:{...ct(n),opacity:i?.6:1},children:[i?e.jsx(H,{size:13,strokeWidth:2}):e.jsx(ie,{size:13,strokeWidth:2}),i?"Deleting…":"Delete"]})]})]})})}function je({t,icon:n,label:i,count:l}){return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11,fontWeight:600,color:l>0?t.textSecondary:t.textMuted,background:t.btnBg,border:`1px solid ${t.btnBorder}`,borderRadius:6,padding:"3px 8px"},children:[n,l," ",i]})}function De({t,label:n,children:i}){return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"118px minmax(0, 1fr)",gap:10,fontSize:12,lineHeight:1.5},children:[e.jsx("strong",{style:{color:t.textMuted},children:n}),e.jsx("span",{style:{color:t.textSecondary},children:i})]})}function ce({t,label:n,values:i,empty:l}){return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"118px minmax(0, 1fr)",gap:10,fontSize:12,lineHeight:1.5},children:[e.jsx("strong",{style:{color:t.textMuted},children:n}),e.jsx("div",{style:{display:"flex",gap:5,flexWrap:"wrap"},children:i!=null&&i.length?i.map(s=>e.jsx("span",{style:Ce(t),children:s},s)):e.jsx("span",{style:{color:t.textMuted,fontStyle:"italic"},children:l})})]})}function q({label:t,hint:n,t:i,children:l}){return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsx("label",{style:{fontSize:12,fontWeight:700,color:i.textPrimary},children:t}),n?e.jsx("div",{style:{fontSize:11.5,color:i.textMuted,lineHeight:1.45,marginTop:-2},children:n}):null,l]})}function pe({t,tone:n,children:i}){const l=n==="error"?t.error:t.textMuted;return e.jsx("div",{style:{fontSize:11.5,color:l,lineHeight:1.45},children:i})}function ue(t){return{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:7,border:`1px solid ${t.accent}`,background:t.accent,color:"#ffffff",fontSize:12.5,fontWeight:700,fontFamily:t.font,cursor:"pointer"}}function Z(t){return{display:"inline-flex",alignItems:"center",gap:5,padding:"7px 11px",borderRadius:7,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,fontSize:12,fontWeight:600,fontFamily:t.font,cursor:"pointer"}}function ct(t){return{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:7,border:`1px solid ${t.error}`,background:t.error,color:"#ffffff",fontSize:12.5,fontWeight:700,fontFamily:t.font,cursor:"pointer"}}function ke(t){return{display:"inline-flex",alignItems:"center",justifyContent:"center",width:30,height:30,borderRadius:7,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,cursor:"pointer",flexShrink:0}}function U(t){return{width:"100%",border:`1px solid ${t.btnBorder}`,borderRadius:7,background:t.cellBg,color:t.textPrimary,fontSize:12.5,fontFamily:t.font,padding:"8px 10px",boxSizing:"border-box"}}function pt(t){return{...U(t),resize:"vertical",lineHeight:1.5,padding:"9px 11px"}}function Se(t){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:10.5,fontWeight:700,color:t.accent,background:`${t.accent}14`,border:`1px solid ${t.accent}38`,borderRadius:999,padding:"2px 8px"}}function Ce(t){return{fontSize:11,fontWeight:600,color:t.textSecondary,background:t.btnBg,border:`1px solid ${t.btnBorder}`,borderRadius:6,padding:"3px 8px",fontFamily:t.fontMono}}function ut(t){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:11.5,fontWeight:600,color:t.textPrimary,background:`${t.accent}14`,border:`1px solid ${t.accent}38`,borderRadius:6,padding:"3px 4px 3px 9px",fontFamily:t.fontMono}}function xt(t){return{display:"inline-flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",color:t.textMuted,cursor:"pointer",padding:2,borderRadius:4}}const gt={position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.42)",display:"flex",justifyContent:"flex-end",zIndex:60};function ht(t){return{width:"min(560px, 100%)",height:"100%",background:t.appBg,borderLeft:`1px solid ${t.headerBorder}`,display:"flex",flexDirection:"column",boxShadow:"-8px 0 28px rgba(0,0,0,0.18)"}}function ft(t){return{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 18px",borderBottom:`1px solid ${t.headerBorder}`,flexShrink:0}}function yt(t){return{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"13px 18px",borderTop:`1px solid ${t.headerBorder}`,flexShrink:0}}const mt={position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.42)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:70,padding:20};function bt(t){return{width:"min(420px, 100%)",background:t.cellBg,border:`1px solid ${t.cellBorder}`,borderRadius:12,padding:20,display:"grid",gap:13,boxShadow:"0 18px 48px rgba(0,0,0,0.3)"}}function jt(t,n,i){var p,o;if(n&&t.domain!==n&&!((p=t.domains)!=null&&p.includes(n)))return!1;const l=(o=i==null?void 0:i.split("::").at(-1))==null?void 0:o.toLowerCase();if(!l)return!0;const s=(t.modelAreaRefs??[]).map(r=>{var g;return(g=r.split("::").at(-1))==null?void 0:g.toLowerCase()});return s.length===0||s.includes(l)}function vt(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").slice(0,64)}function Re(t){return t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)}function kt(){return{id:"",scope:"project",description:"",body:"",preferredMetrics:[],preferredBlocks:[],vocabulary:{},sourcePath:""}}function St({embedded:t=!1,domainFilter:n=null,modelAreaFilter:i=null}={}){var R;const{state:l}=fe(),s=we[l.themeMode],[p,o]=d.useState([]),[r,g]=d.useState(!0),[k,m]=d.useState(null),[c,W]=d.useState({metrics:[],blocks:[]}),[j,h]=d.useState([]),[u,I]=d.useState(null),[b,B]=d.useState(!1),[P,y]=d.useState("skills"),[v,A]=d.useState(!1),[O,M]=d.useState(null),[$,a]=d.useState(null),[C,L]=d.useState(null),[z,J]=d.useState(!1),[K,Q]=d.useState(null),x=d.useCallback(()=>{let f=!1;return g(!0),m(null),T.getSkills().then(w=>{f||o(Array.isArray(w==null?void 0:w.skills)?w.skills:[])}).catch(w=>{f||(o([]),m(w instanceof Error&&w.message?w.message:"Could not load skills. Is the local DQL server running?"))}).finally(()=>{f||g(!1)}),T.getSkillOptions().then(w=>{f||W({metrics:Array.isArray(w==null?void 0:w.metrics)?w.metrics:[],blocks:Array.isArray(w==null?void 0:w.blocks)?w.blocks:[]})}).catch(()=>{f||W({metrics:[],blocks:[]})}),T.getDomains().then(w=>{f||h(Array.isArray(w==null?void 0:w.domains)?w.domains:[])}).catch(()=>{f||h([])}),T.getSkillPathSettings().then(w=>{f||(I(w),y(w.path))}).catch(()=>{f||I(null)}),()=>{f=!0}},[]);d.useEffect(()=>x(),[x]);const S=d.useMemo(()=>p.filter(f=>jt(f,n,i)).sort((f,w)=>f.id.localeCompare(w.id)),[p,n,i]),D=d.useCallback(f=>{o(w=>{const oe=w.findIndex(Be=>(Be.qualifiedId??Be.id)===(f.qualifiedId??f.id));if(oe===-1)return[...w,f];const ze=[...w];return ze[oe]=f,ze}),a(null)},[]),E=d.useCallback(async()=>{if(C){J(!0),Q(null);try{const f=C.qualifiedId??C.id;await T.deleteSkill(f),o(w=>w.filter(oe=>(oe.qualifiedId??oe.id)!==f)),L(null)}catch(f){Q(f instanceof Error&&f.message?f.message:"Could not delete this skill.")}finally{J(!1)}}},[C]),F=d.useCallback(async()=>{A(!0),M(null);try{const f=await T.updateSkillPath(P);I(f),y(f.path),B(!1),x()}catch(f){M(f instanceof Error&&f.message?f.message:"Could not use this Skills folder.")}finally{A(!1)}},[x,P]);return e.jsxs("div",{style:{flex:1,minWidth:0,overflow:"auto",background:s.appBg},children:[e.jsxs("div",{style:{maxWidth:980,margin:"0 auto",padding:t?"18px 20px 40px":"22px 28px 40px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-end",justifyContent:"space-between",gap:18,marginBottom:18},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[e.jsx(re,{size:20,strokeWidth:1.9,color:s.accent}),e.jsx("div",{style:{fontSize:t?18:22,fontWeight:700,color:s.textPrimary},children:i?`${(R=i.split("::").at(-1))==null?void 0:R.replace(/_/g," ")} skills`:n?`${n} skills`:"Skills"})]}),e.jsxs("div",{style:{fontSize:13,color:s.textMuted,marginTop:6,maxWidth:680,lineHeight:1.5},children:["Definitions, vocabulary, and instructions the AI follows when answering",i?" in this model area":n?" in this domain":"",". Applied only when their triggers match — drafts never guide answers."]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:7,color:s.textMuted,fontSize:10.5,minWidth:0},children:[e.jsx(We,{size:12,strokeWidth:1.8}),e.jsx("span",{children:"Skill folder"}),e.jsx("code",{style:{color:s.textSecondary,fontFamily:s.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(u==null?void 0:u.path)??"skills"}),u?e.jsxs("span",{children:["· ",u.exists?`${u.skillCount} loaded`:"not found"]}):null]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[e.jsxs("button",{type:"button",onClick:()=>x(),title:"Refresh",style:Y(s),children:[e.jsx(ye,{size:13,strokeWidth:2})," Refresh"]}),e.jsxs("button",{type:"button",onClick:()=>{M(null),B(f=>!f)},style:Y(s),children:[e.jsx(We,{size:13,strokeWidth:2})," Skill folder"]}),e.jsxs("button",{type:"button",onClick:()=>a({kind:"create"}),style:ge(s),children:[e.jsx(X,{size:14,strokeWidth:2.2})," Add skill"]})]})]}),b?e.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:10,background:s.cellBg,padding:"12px 14px",marginBottom:16,display:"grid",gap:8},children:[e.jsx("div",{style:{fontSize:12.5,fontWeight:700,color:s.textPrimary},children:"Use an existing Skills folder"}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx("input",{"aria-label":"Existing Skills folder",value:P,onChange:f=>y(f.target.value),onKeyDown:f=>{f.key==="Enter"&&P.trim()&&!v&&F()},placeholder:"skills or ../skills",style:{...N(s),flex:1,fontFamily:s.fontMono}}),e.jsx("button",{type:"button",onClick:()=>B(!1),disabled:v,style:Y(s),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>void F(),disabled:!P.trim()||v,style:{...ge(s),opacity:P.trim()&&!v?1:.55},children:[v?e.jsx(H,{size:13,strokeWidth:2}):null,v?"Connecting…":"Use folder"]})]}),e.jsxs("div",{style:{fontSize:10.5,lineHeight:1.45,color:s.textMuted},children:["Relative paths start from the DQL project. If DQL is in a ",e.jsx("code",{style:{fontFamily:s.fontMono},children:"/dql"})," folder inside your dbt repo, use ",e.jsx("code",{style:{fontFamily:s.fontMono},children:"../skills"}),". Existing ",e.jsx("code",{style:{fontFamily:s.fontMono},children:".skill.md"})," and Markdown skill files are loaded in place and stay Git-owned by that repo."]}),u!=null&&u.resolvedPath?e.jsxs("div",{style:{fontSize:10.5,color:s.textMuted,fontFamily:s.fontMono,overflowWrap:"anywhere"},children:["Resolved: ",u.resolvedPath]}):null,O?e.jsx(xe,{t:s,tone:"error",children:O}):null]}):null,r?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:s.textMuted,fontSize:13,padding:"40px 0"},children:[e.jsx(H,{size:15,strokeWidth:2})," Loading skills…"]}):k?e.jsx(It,{t:s,message:k,onRetry:()=>x()}):S.length===0?e.jsx(Wt,{t:s,onAdd:()=>a({kind:"create"})}):e.jsx("div",{style:{display:"grid",gap:10},children:S.map(f=>e.jsx(wt,{skill:f,t:s,onEdit:()=>a({kind:"edit",skill:f}),onDelete:()=>{Q(null),L(f)}},f.qualifiedId??f.id))})]}),$?e.jsx(Ct,{mode:$,options:c,domains:j,defaultDomain:n,defaultModelArea:i,existingIds:p.map(f=>f.id),t:s,onClose:()=>a(null),onSaved:D}):null,C?e.jsx(Tt,{skill:C,t:s,deleting:z,error:K,onCancel:()=>{z||L(null)},onConfirm:E}):null]})}function wt({skill:t,t:n,onEdit:i,onDelete:l}){var r,g,k;const[s,p]=d.useState(!1),o=(r=t.domains)!=null&&r.length?t.domains:t.domain?[t.domain]:[];return e.jsxs("section",{style:{border:"1px solid var(--border-subtle)",borderRadius:11,background:n.cellBg,overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"12px 14px"},children:[e.jsx("span",{style:{width:28,height:28,borderRadius:7,background:"var(--accent-dim)",color:n.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(re,{size:14,strokeWidth:1.75})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:13,fontWeight:650,color:n.textPrimary,fontFamily:n.fontMono},children:t.id}),t.status==="draft"?e.jsx("span",{style:Pe(n),children:"draft — inactive"}):null,t.status==="active"||!t.status?e.jsx("span",{style:$t(n),children:"active"}):null,o.map(m=>e.jsx("span",{style:Dt(n),children:m},m)),t.isStarter?e.jsxs("span",{style:Pe(n),title:"A dbt-seeded starter — edit it to make it yours",children:[e.jsx(ne,{size:10,strokeWidth:2.2})," starter — edit me"]}):null]}),e.jsx("div",{style:{fontSize:12,color:t.description?n.textSecondary:n.textMuted,fontStyle:t.description?void 0:"italic",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.description||"No description yet."}),e.jsx("div",{title:t.sourcePath,style:{marginTop:3,color:n.textMuted,fontSize:10,fontFamily:n.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.sourcePath})]}),e.jsx("button",{type:"button",onClick:()=>p(m=>!m),style:{...Y(n),height:26,padding:"0 10px",fontSize:11},title:s?"Hide skill details":"Show skill details",children:s?"Hide details":"Details"}),e.jsx("button",{type:"button",onClick:i,style:{...he(n),width:26,height:26},title:"Edit skill",children:e.jsx(Ne,{size:12,strokeWidth:1.75})}),e.jsx("button",{type:"button",onClick:l,style:{...he(n),width:26,height:26},title:"Delete skill",children:e.jsx(ie,{size:12,strokeWidth:1.75})})]}),s?e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",padding:"12px 14px",display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px 20px"},children:[e.jsx(ee,{t:n,label:"Apply when",values:t.triggers,empty:"No trigger phrases defined"}),e.jsx(ee,{t:n,label:"Prefer these metrics",values:t.preferredMetrics,empty:"No preferred metrics",accent:!0,mono:!0}),e.jsx(ee,{t:n,label:"Reuse these blocks",values:t.preferredBlocks,empty:"No preferred blocks",accent:!0,mono:!0}),e.jsx(ee,{t:n,label:"Ask first when",values:t.clarifyWhen,empty:"No clarification rule defined"}),(g=t.exclusions)!=null&&g.length?e.jsx(ee,{t:n,label:"Avoid when",values:t.exclusions,empty:""}):null,(k=t.modelAreaRefs)!=null&&k.length?e.jsx(ee,{t:n,label:"Focus on model areas",values:t.modelAreaRefs,empty:"",mono:!0}):null,t.body?e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:te(n),children:"Guidance"}),e.jsx("div",{style:{fontSize:12,lineHeight:1.6,color:n.textSecondary,background:"var(--bg-1)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"10px 12px",whiteSpace:"pre-wrap",maxHeight:220,overflow:"auto"},children:t.body})]}):null]}):null]})}function Ct({mode:t,options:n,domains:i,defaultDomain:l=null,defaultModelArea:s=null,existingIds:p,t:o,onClose:r,onSaved:g}){const{dispatch:k}=fe(),m=t.kind==="edit",[c,W]=d.useState(()=>t.kind==="edit"?{...t.skill}:{...kt(),domain:l??void 0,domains:l?[l]:[],modelAreaRefs:s?[s]:[]}),[j,h]=d.useState(m),[u,I]=d.useState(()=>t.kind==="edit"?t.skill.id:""),[b,B]=d.useState(!1),[P,y]=d.useState(null),v=d.useCallback((a,C)=>{W(L=>({...L,[a]:C}))},[]),A=a=>{I(a),!m&&!j&&v("id",Re(a))},O=!m&&c.id.length>0&&p.includes(c.id),M=c.id.trim().length>0&&c.body.trim().length>0&&!O&&!b,$=d.useCallback(async()=>{var C,L;const a={...c,id:c.id.trim(),description:(C=c.description)!=null&&C.trim()?c.description.trim():void 0,body:c.body,domain:(L=c.domain)!=null&&L.trim()?c.domain.trim():void 0,domains:(c.domains??(c.domain?[c.domain]:[])).map(z=>z.trim()).filter(Boolean),modelAreaRefs:(c.modelAreaRefs??[]).map(z=>z.trim()).filter(Boolean),triggers:(c.triggers??[]).map(z=>z.trim()).filter(Boolean),exclusions:(c.exclusions??[]).map(z=>z.trim()).filter(Boolean),preferredDimensions:(c.preferredDimensions??[]).map(z=>z.trim()).filter(Boolean),requiredFilters:(c.requiredFilters??[]).map(z=>z.trim()).filter(Boolean),clarifyWhen:(c.clarifyWhen??[]).map(z=>z.trim()).filter(Boolean),examples:(c.examples??[]).map(z=>z.trim()).filter(Boolean)};B(!0),y(null);try{const z=m?await T.updateSkill(a.id,a):await T.createSkill(a);g(z.skill??a)}catch(z){y(z instanceof Error&&z.message?z.message:"Could not save this skill. Try again.")}finally{B(!1)}},[c,m,g]);return e.jsx("div",{style:Et,onClick:()=>!b&&r(),children:e.jsxs("div",{style:At(o),onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{style:Ot(),children:[e.jsx("span",{style:{width:30,height:30,borderRadius:8,background:"var(--accent-dim)",color:o.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(re,{size:15,strokeWidth:1.75})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:o.textPrimary},children:m?"Edit skill":"New skill"}),e.jsx("div",{style:{fontSize:11,color:o.textMuted,marginTop:1},children:"Git-backed guidance · applied only when triggers match"})]}),e.jsx("button",{type:"button",onClick:()=>!b&&r(),style:{...he(o),width:26,height:26,border:"none",background:"none"},title:"Close",children:e.jsx(me,{size:14,strokeWidth:2})})]}),e.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"18px 22px",display:"grid",gridTemplateColumns:"1fr 1fr",gap:"20px 28px",alignContent:"start"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsx("div",{style:te(o),children:"Identity"}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Name"}),e.jsx("input",{type:"text",value:u,onChange:a=>A(a.target.value),placeholder:"e.g. Revenue definition",style:N(o)}),e.jsxs("span",{style:{fontSize:10.5,color:o.textMuted},children:["Saved as"," ",e.jsx("input",{type:"text",value:`skills/${c.id}.skill.md`,disabled:m,onChange:a=>{h(!0),v("id",vt(a.target.value.replace(/^skills\//,"").replace(/\.skill\.md$/,"")))},onBlur:()=>v("id",Re(c.id)),title:"File name — letters, numbers, and dashes",style:{border:"none",background:"none",outline:"none",padding:0,fontFamily:o.fontMono,fontSize:10.5,color:o.textSecondary,width:`${Math.max(20,c.id.length+15)}ch`,borderBottom:m?"none":`1px dashed ${o.btnBorder}`}})]}),O?e.jsx(xe,{t:o,tone:"error",children:"A skill with this id already exists."}):null]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Domain"}),e.jsxs("select",{value:c.domain??"",onChange:a=>{const C=a.target.value||void 0;v("domain",C),v("domains",C?[C]:[])},style:{...N(o),cursor:"pointer",color:c.domain?o.textPrimary:o.textMuted},children:[e.jsx("option",{value:"",children:i.length===0?"No domains yet":"No domain"}),i.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Type"}),e.jsxs("select",{value:c.kind??"custom",onChange:a=>v("kind",a.target.value),style:{...N(o),cursor:"pointer"},children:[e.jsx("option",{value:"custom",children:"Custom guidance"}),e.jsx("option",{value:"domain_reference",children:"Domain reference — broad context"}),e.jsx("option",{value:"metric_policy",children:"Policy — focused rule"}),e.jsx("option",{value:"glossary",children:"Glossary"}),e.jsx("option",{value:"analysis_pattern",children:"Analysis pattern"}),e.jsx("option",{value:"sql_policy",children:"SQL policy"})]})]})]}),e.jsx("button",{type:"button",onClick:()=>k({type:"SET_MAIN_VIEW",view:"domains"}),style:{border:"none",background:"none",padding:0,fontSize:10.5,color:o.accent,cursor:"pointer",fontFamily:o.font,alignSelf:"flex-start"},title:"Create a new domain on the Domains page",children:"+ New domain"}),e.jsxs("div",{children:[e.jsx("span",{style:{..._(o),display:"block",marginBottom:5},children:"Lifecycle"}),e.jsx("div",{style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,border:`1px solid ${o.btnBorder}`,borderRadius:7,background:"var(--bg-1)"},children:["active","draft","deprecated"].map(a=>{const C=(c.status??"active")===a;return e.jsx("button",{type:"button",onClick:()=>v("status",a),style:{border:"none",borderRadius:5,padding:"4px 12px",fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:o.font,background:C?o.cellBg:"transparent",color:C?o.textPrimary:o.textMuted,boxShadow:C?"0 1px 3px rgba(26,26,26,0.1)":"none",textTransform:"capitalize"},children:a},a)})}),e.jsx("span",{style:{fontSize:10.5,color:o.textMuted,marginLeft:8},children:(c.status??"active")==="active"?"Guides matching answers.":c.status==="draft"?"Drafts never guide answers.":"Kept in Git for history only."})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsx("div",{style:te(o),children:"When to apply"}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Apply when the question mentions"}),e.jsx(zt,{t:o,values:c.triggers??[],onChange:a=>v("triggers",a),placeholder:"Add phrase, press Enter"})]}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Ask first when"}),e.jsx(de,{values:c.clarifyWhen??[],onChange:a=>v("clarifyWhen",a),placeholder:"e.g. 'sales' could mean revenue or order count",style:N(o)})]}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Avoid when"}),e.jsx(de,{values:c.exclusions??[],onChange:a=>v("exclusions",a),placeholder:"e.g. question is about pipeline or bookings",style:N(o)})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,gridRow:"span 2"},children:[e.jsx("div",{style:te(o),children:"Guidance"}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"One-line summary"}),e.jsx("input",{type:"text",value:c.description??"",onChange:a=>v("description",a.target.value),placeholder:"What rule does this skill encode?",style:N(o)})]}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Full guidance"}),e.jsx("textarea",{value:c.body,onChange:a=>v("body",a.target.value),rows:9,placeholder:"Definitions, exclusions, edge cases — written for the agent.",style:Mt(o)})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsx("div",{style:te(o),children:"Prefer these assets"}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Metrics"}),e.jsx(Me,{t:o,options:n.metrics,optionKind:"metrics",selected:c.preferredMetrics,onChange:a=>v("preferredMetrics",a),placeholder:"Search metrics…",emptyOptionsHint:"No metrics available from the project yet."})]}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Blocks"}),e.jsx(Me,{t:o,options:n.blocks,optionKind:"blocks",selected:c.preferredBlocks,onChange:a=>v("preferredBlocks",a),placeholder:"Search blocks…",emptyOptionsHint:"No blocks available from the project yet."})]})]}),e.jsxs("details",{style:{gridColumn:"1 / -1"},children:[e.jsx("summary",{style:{fontSize:11.5,fontWeight:650,color:o.accent,cursor:"pointer"},children:"Advanced — model areas, dimensions, and vocabulary"}),e.jsxs("div",{style:{display:"grid",gap:14,marginTop:12},children:[e.jsx(ve,{label:"Focused model areas (optional)",t:o,hint:"Comma-separated area ids from the Model workspace. This boosts the skill only inside its selected domain; it never expands access.",children:e.jsx(de,{values:c.modelAreaRefs??[],onChange:a=>v("modelAreaRefs",a),placeholder:"customer_lifecycle, revenue_reporting",style:N(o)})}),e.jsx(ve,{label:"Preferred dimensions",t:o,hint:"Business-safe dimensions the agent should prefer when they are compatible.",children:e.jsx(de,{values:c.preferredDimensions??[],onChange:a=>v("preferredDimensions",a),placeholder:"region, month",style:N(o)})}),e.jsx(ve,{label:"Vocabulary",t:o,hint:"Map your terms to a target, e.g. arr → metric:arr or revenue → block:revenue_by_region.",children:e.jsx(Bt,{t:o,value:c.vocabulary,onChange:a=>v("vocabulary",a)})})]})]}),P?e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(xe,{t:o,tone:"error",children:P})}):null]}),e.jsxs("div",{style:Lt(),children:[e.jsx("span",{style:{fontSize:10.5,color:o.textMuted,flex:1,textAlign:"left"},children:"Saved to Git — review in source control before merging."}),e.jsx("button",{type:"button",onClick:()=>!b&&r(),style:Y(o),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:$,disabled:!M,style:{...ge(o),opacity:M?1:.55},children:[b?e.jsx(H,{size:13,strokeWidth:2}):null,b?"Saving…":m?"Save changes":"Create skill"]})]})]})})}function zt({t,values:n,onChange:i,placeholder:l}){const[s,p]=d.useState(""),o=r=>{const g=r.trim().replace(/,$/,"");!g||n.includes(g)||(i([...n,g]),p(""))};return e.jsxs("div",{style:He(t),children:[n.map(r=>e.jsxs("span",{style:qe(t),children:[r,e.jsx("button",{type:"button",onClick:()=>i(n.filter(g=>g!==r)),style:Ge(t),title:"Remove",children:"×"})]},r)),e.jsx("input",{type:"text",value:s,onChange:r=>p(r.target.value),onKeyDown:r=>{r.key==="Enter"||r.key===","?(r.preventDefault(),o(s)):r.key==="Backspace"&&!s&&n.length&&i(n.slice(0,-1))},onBlur:()=>o(s),placeholder:n.length?"":l,style:_e(t)})]})}function Me({t,options:n,optionKind:i,selected:l,onChange:s,placeholder:p,emptyOptionsHint:o}){const[r,g]=d.useState(""),[k,m]=d.useState(n);d.useEffect(()=>{let j=!1;const h=window.setTimeout(()=>{T.getSkillOptions(r).then(u=>{j||m(i==="metrics"?u.metrics:u.blocks)}).catch(()=>{j||m(n)})},160);return()=>{j=!0,window.clearTimeout(h)}},[i,n,r]);const c=d.useMemo(()=>k.filter(j=>!l.includes(j)).filter(j=>r?j.toLowerCase().includes(r.toLowerCase()):!0).slice(0,8),[k,l,r]),W=j=>{const h=j.trim();!h||l.includes(h)||(s([...l,h]),g(""))};return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs("div",{style:He(t),children:[l.map(j=>e.jsxs("span",{style:{...qe(t),fontFamily:t.fontMono},children:[j,e.jsx("button",{type:"button",onClick:()=>s(l.filter(h=>h!==j)),style:Ge(t),title:"Remove",children:"×"})]},j)),e.jsx("input",{type:"text",value:r,onChange:j=>g(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),W(r))},placeholder:l.length?"":p,style:_e(t)})]}),c.length>0?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:c.map(j=>e.jsxs("button",{type:"button",onClick:()=>W(j),style:Pt(t),children:[e.jsx(X,{size:10,strokeWidth:2.4})," ",j]},j))}):k.length===0?e.jsxs("div",{style:{fontSize:11,color:t.textMuted},children:[o," You can still type a value and press Enter."]}):null]})}function Bt({t,value:n,onChange:i}){const[l,s]=d.useState(()=>Object.entries(n??{}).map(([r,g])=>({term:r,target:g}))),p=r=>{s(r);const g={};for(const k of r){const m=k.term.trim();m&&(g[m]=k.target.trim())}i(g)},o=(r,g)=>{p(l.map((k,m)=>m===r?{...k,...g}:k))};return e.jsxs("div",{style:{display:"grid",gap:7},children:[l.map((r,g)=>e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("input",{type:"text",value:r.term,onChange:k=>o(g,{term:k.target.value}),placeholder:"arr",style:{...N(t),flex:1}}),e.jsx("span",{style:{color:t.textMuted,fontSize:13},children:"→"}),e.jsx("input",{type:"text",value:r.target,onChange:k=>o(g,{target:k.target.value}),placeholder:"metric:arr",style:{...N(t),flex:1.3,fontFamily:t.fontMono}}),e.jsx("button",{type:"button",onClick:()=>p(l.filter((k,m)=>m!==g)),style:he(t),title:"Remove row",children:e.jsx(me,{size:13,strokeWidth:2})})]},g)),e.jsxs("button",{type:"button",onClick:()=>s([...l,{term:"",target:""}]),style:{...Y(t),justifySelf:"start"},children:[e.jsx(X,{size:12,strokeWidth:2.2})," Add term"]})]})}function Wt({t,onAdd:n}){return e.jsxs("div",{style:{border:`1px dashed ${t.cellBorder}`,borderRadius:12,background:t.cellBg,padding:"34px 28px",textAlign:"center",display:"grid",gap:12,justifyItems:"center"},children:[e.jsx("div",{style:{width:44,height:44,borderRadius:10,background:`${t.accent}18`,color:t.accent,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(re,{size:22,strokeWidth:1.9})}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:t.textPrimary},children:"Teach the AI your business rules"}),e.jsx("div",{style:{fontSize:13,color:t.textMuted,maxWidth:460,lineHeight:1.55},children:'Skills are the definitions, rules, and vocabulary the AI follows when it answers — like "revenue = recognized, not bookings" or "always exclude test accounts." Add your first one to start guiding every answer.'}),e.jsxs("button",{type:"button",onClick:n,style:{...ge(t),marginTop:4},children:[e.jsx(X,{size:14,strokeWidth:2.2})," Add your first skill"]})]})}function It({t,message:n,onRetry:i}){return e.jsxs("div",{style:{border:`1px solid ${t.warning}55`,borderRadius:10,background:`${t.warning}12`,padding:"16px 18px",display:"flex",alignItems:"flex-start",gap:11},children:[e.jsx(Le,{size:16,strokeWidth:2,color:t.warning,style:{marginTop:1,flexShrink:0}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13,fontWeight:650,color:t.textPrimary},children:"Skills are not available right now"}),e.jsx("div",{style:{fontSize:12.5,color:t.textSecondary,marginTop:4,lineHeight:1.5},children:n}),e.jsxs("button",{type:"button",onClick:i,style:{...Y(t),marginTop:10},children:[e.jsx(ye,{size:13,strokeWidth:2})," Retry"]})]})]})}function Tt({skill:t,t:n,deleting:i,error:l,onCancel:s,onConfirm:p}){return e.jsx("div",{style:Ft,onClick:s,children:e.jsxs("div",{style:Nt(n),onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[e.jsx(ie,{size:16,strokeWidth:2,color:n.error}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:n.textPrimary},children:"Delete this skill?"})]}),e.jsxs("div",{style:{fontSize:13,color:n.textSecondary,lineHeight:1.55},children:[e.jsx("span",{style:{fontFamily:n.fontMono,color:n.textPrimary},children:t.id})," will be removed and the AI will stop following it. This can't be undone."]}),l?e.jsx(xe,{t:n,tone:"error",children:l}):null,e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:s,disabled:i,style:Y(n),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:p,disabled:i,style:{...Rt(n),opacity:i?.6:1},children:[i?e.jsx(H,{size:13,strokeWidth:2}):e.jsx(ie,{size:13,strokeWidth:2}),i?"Deleting…":"Delete"]})]})]})})}function te(t){return{fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:t.textMuted,marginBottom:5}}function ee({t,label:n,values:i,empty:l,accent:s=!1,mono:p=!1}){return e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:te(t),children:n}),e.jsx("div",{style:{display:"flex",gap:5,flexWrap:"wrap"},children:i!=null&&i.length?i.map(o=>e.jsx("span",{style:{fontSize:11,padding:"3px 9px",borderRadius:999,background:s?"var(--accent-dim)":"var(--bg-1)",color:s?t.accent:t.textSecondary,border:s?`1px solid ${t.accent}33`:"1px solid var(--border-subtle)",fontFamily:p?t.fontMono:void 0},children:o},o)):e.jsx("span",{style:{fontSize:11.5,color:t.textMuted,fontStyle:"italic"},children:l})})]})}function ve({label:t,hint:n,t:i,children:l}){return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsx("label",{style:{fontSize:12,fontWeight:700,color:i.textPrimary},children:t}),n?e.jsx("div",{style:{fontSize:11.5,color:i.textMuted,lineHeight:1.45,marginTop:-2},children:n}):null,l]})}function xe({t,tone:n,children:i}){const l=n==="error"?t.error:t.textMuted;return e.jsx("div",{style:{fontSize:11.5,color:l,lineHeight:1.45},children:i})}function $t(t){return{display:"inline-flex",alignItems:"center",fontSize:10.5,fontWeight:700,color:t.success,background:`${t.success}14`,border:`1px solid ${t.success}38`,borderRadius:999,padding:"2px 7px"}}function Dt(t){return{display:"inline-flex",alignItems:"center",fontSize:10.5,fontWeight:700,color:t.accent,background:`${t.accent}14`,border:`1px solid ${t.accent}38`,borderRadius:999,padding:"2px 7px"}}function ge(t){return{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:7,border:`1px solid ${t.accent}`,background:t.accent,color:"#ffffff",fontSize:12.5,fontWeight:700,fontFamily:t.font,cursor:"pointer"}}function Y(t){return{display:"inline-flex",alignItems:"center",gap:5,padding:"7px 11px",borderRadius:7,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,fontSize:12,fontWeight:600,fontFamily:t.font,cursor:"pointer"}}function Rt(t){return{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:7,border:`1px solid ${t.error}`,background:t.error,color:"#ffffff",fontSize:12.5,fontWeight:700,fontFamily:t.font,cursor:"pointer"}}function he(t){return{display:"inline-flex",alignItems:"center",justifyContent:"center",width:30,height:30,borderRadius:7,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,cursor:"pointer",flexShrink:0}}function N(t){return{width:"100%",border:`1px solid ${t.btnBorder}`,borderRadius:7,background:t.cellBg,color:t.textPrimary,fontSize:12.5,fontFamily:t.font,padding:"8px 10px",boxSizing:"border-box"}}function Mt(t){return{...N(t),resize:"vertical",lineHeight:1.5,padding:"9px 11px"}}function Pe(t){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,fontWeight:700,letterSpacing:"0.02em",color:t.warning,background:`${t.warning}16`,border:`1px solid ${t.warning}40`,borderRadius:999,padding:"2px 8px"}}function He(t){return{display:"flex",alignItems:"center",gap:5,flexWrap:"wrap",border:`1px solid ${t.btnBorder}`,background:t.cellBg,borderRadius:7,padding:"6px 8px"}}function _e(t){return{flex:1,minWidth:110,border:"none",background:"none",outline:"none",fontSize:11.5,fontFamily:t.font,color:t.textPrimary,padding:2}}function qe(t){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,padding:"2.5px 8px",borderRadius:999,background:"var(--accent-dim)",color:t.accent,border:`1px solid ${t.accent}33`}}function Ge(t){return{border:"none",background:"none",color:t.accent,cursor:"pointer",padding:0,fontSize:12,lineHeight:1,fontFamily:t.font}}const G={display:"flex",flexDirection:"column",gap:4};function _(t){return{fontSize:11,fontWeight:650,color:t.textSecondary}}function Pt(t){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontWeight:600,color:t.textSecondary,background:t.btnBg,border:`1px solid ${t.btnBorder}`,borderRadius:6,padding:"3px 8px",cursor:"pointer",fontFamily:t.fontMono}}const Et={position:"fixed",inset:0,background:"rgba(26, 26, 26, 0.22)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60};function At(t){return{width:"min(860px, 94vw)",height:"min(640px, 90vh)",background:t.cellBg,border:`1px solid ${t.headerBorder}`,borderRadius:14,display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 24px 70px rgba(26,26,26,0.22)"}}function Ot(t){return{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle)",flexShrink:0}}function Lt(t){return{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"12px 18px",borderTop:"1px solid var(--border-subtle)",background:"var(--bg-1)",flexShrink:0}}const Ft={position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.42)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:70,padding:20};function Nt(t){return{width:"min(420px, 100%)",background:t.cellBg,border:`1px solid ${t.cellBorder}`,borderRadius:12,padding:20,display:"grid",gap:13,boxShadow:"0 18px 48px rgba(0,0,0,0.3)"}}function Ht({initialTab:t="overview"}){const{state:n}=fe(),i=we[n.themeMode],[l,s]=d.useState(t),[p,o]=d.useState([]),[r,g]=d.useState([]),[k,m]=d.useState(!0);d.useEffect(()=>s(t),[t]);const c=d.useCallback(()=>{let u=!1;return m(!0),Promise.all([T.getDomains(),T.getSkills()]).then(([I,b])=>{u||(o(Array.isArray(I.domains)?I.domains:[]),g(Array.isArray(b.skills)?b.skills:[]))}).catch(()=>{u||(o([]),g([]))}).finally(()=>{u||m(!1)}),()=>{u=!0}},[]);d.useEffect(()=>c(),[c]);const W=d.useMemo(()=>{const u=p.filter(B=>!!(B.businessOwner||B.owner)).length,I=r.filter(B=>!B.status||B.status==="active").length,b=r.filter(B=>B.status==="draft").length;return{ownedDomains:u,activeSkills:I,draftSkills:b}},[p,r]),j=d.useCallback(()=>{s("domains"),window.setTimeout(()=>window.dispatchEvent(new Event("dql:context-build")),50)},[]),h=[{id:"overview",label:"Overview"},{id:"domains",label:"Domains",count:p.length},{id:"skills",label:"Skills",count:r.length},{id:"knowledge",label:"Knowledge 360"}];return e.jsx("div",{style:{flex:1,minWidth:0,overflow:"auto",background:i.appBg},children:e.jsxs("div",{style:{maxWidth:1040,margin:"0 auto",padding:"22px 28px 40px"},children:[e.jsxs("header",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-end",gap:18,marginBottom:15},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",gap:9,alignItems:"center"},children:[e.jsx(se,{size:20,color:i.accent}),e.jsx("h1",{style:{fontSize:22,color:i.textPrimary},children:"Governed context"})]}),e.jsx("p",{style:{marginTop:6,fontSize:13,lineHeight:1.5,color:i.textMuted,maxWidth:700},children:"Domains define business boundaries. Skills teach the agent approved vocabulary, reuse rules, and when to ask for clarification."})]}),e.jsxs("button",{type:"button",onClick:j,style:Qe(i),children:[e.jsx(ne,{size:14})," Build with AI"]})]}),e.jsx("nav",{"aria-label":"Governed context sections",style:{display:"flex",gap:3,borderBottom:`1px solid ${i.headerBorder}`,marginBottom:18},children:h.map(u=>e.jsxs("button",{type:"button",onClick:()=>s(u.id),style:{border:"none",borderBottom:`2px solid ${l===u.id?i.accent:"transparent"}`,background:"transparent",padding:"9px 12px",color:l===u.id?i.textPrimary:i.textMuted,fontWeight:l===u.id?700:600,cursor:"pointer",fontFamily:i.font,fontSize:12.5},children:[u.label,u.count!==void 0?` · ${u.count}`:""]},u.id))}),l==="overview"?e.jsx(_t,{t:i,loading:k,domains:p,skills:r,status:W,onBuild:j,onTab:s}):null,l==="domains"?e.jsx(nt,{embedded:!0}):null,l==="skills"?e.jsx(St,{embedded:!0}):null,l==="knowledge"?e.jsx(Ke,{t:i,domains:p}):null]})})}function Ke({t,domains:n,initialDomainId:i}){var W,j;const[l,s]=d.useState(i??((W=n[0])==null?void 0:W.id)??""),[p,o]=d.useState(null),[r,g]=d.useState(!1),[k,m]=d.useState(null);d.useEffect(()=>{var h;!l&&((h=n[0])!=null&&h.id)&&s(n[0].id)},[l,n]),d.useEffect(()=>{i&&n.some(h=>h.id===i)&&s(i)},[n,i]),d.useEffect(()=>{if(!l){o(null);return}let h=!1;return g(!0),m(null),T.getDomainKnowledge(l).then(u=>{h||o(u)}).catch(u=>{h||(o(null),m(u instanceof Error?u.message:"Could not load the compiled knowledge capsule."))}).finally(()=>{h||g(!1)}),()=>{h=!0}},[l]);const c=d.useMemo(()=>{const h={};for(const u of(p==null?void 0:p.objects)??[])h[u.kind]=(h[u.kind]??0)+1;return Object.entries(h).sort((u,I)=>I[1]-u[1]||u[0].localeCompare(I[0]))},[p]);return e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx("section",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:10,background:t.cellBg,padding:15},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:12,flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",gap:7,alignItems:"center",color:t.textPrimary,fontWeight:700,fontSize:13},children:[e.jsx(Ie,{size:16,color:t.accent})," Compiled Domain 360"]}),e.jsx("div",{style:{marginTop:4,color:t.textMuted,fontSize:12},children:"The same qualified graph, route policy, and skill snapshot used by Ask."})]}),e.jsxs("select",{"aria-label":"Domain knowledge capsule",value:l,onChange:h=>s(h.target.value),style:{minWidth:210,border:`1px solid ${t.inputBorder}`,borderRadius:7,background:t.inputBg,color:t.textPrimary,padding:"7px 9px",fontFamily:t.font},children:[e.jsx("option",{value:"",children:"Select a domain"}),[...n].sort((h,u)=>h.name.localeCompare(u.name)).map(h=>e.jsx("option",{value:h.id,children:h.name},h.id))]})]})}),r?e.jsxs("div",{style:{color:t.textMuted,display:"flex",gap:8,alignItems:"center",padding:24},children:[e.jsx(H,{size:15})," Loading compiled knowledge…"]}):null,k?e.jsx("div",{style:{border:`1px solid ${t.error}`,background:t.cellBg,color:t.error,borderRadius:8,padding:12,fontSize:12.5},children:k}):null,p?e.jsxs(e.Fragment,{children:[e.jsxs("section",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:9},children:[e.jsx(V,{t,label:"Objects",value:p.counts.objects,detail:"qualified knowledge",icon:e.jsx(se,{size:16})}),e.jsx(V,{t,label:"Relations",value:p.counts.edges,detail:"provenance + policy",icon:e.jsx(Ie,{size:16})}),e.jsx(V,{t,label:"Authorized",value:p.counts.routeStates.authorized??0,detail:"safe cross-domain routes",icon:e.jsx(Je,{size:16})}),e.jsx(V,{t,label:"Blocked / stale",value:(p.counts.routeStates.blocked??0)+(p.counts.routeStates.stale??0),detail:"never auto-joined",icon:e.jsx(Oe,{size:16})})]}),e.jsxs("section",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1.2fr) minmax(0, 1fr)",gap:12},children:[e.jsxs("div",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:9,background:t.cellBg,padding:14},children:[e.jsx("strong",{style:{color:t.textPrimary,fontSize:13},children:"Knowledge capsule"}),e.jsx("p",{style:{color:t.textSecondary,fontSize:12.5,lineHeight:1.5,margin:"7px 0 11px"},children:((j=p.capsule)==null?void 0:j.description)||"Compiled domain boundary and governed references."}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:c.map(([h,u])=>e.jsxs("span",{style:{border:`1px solid ${t.cellBorder}`,background:t.pillBg,color:t.textSecondary,borderRadius:999,padding:"3px 7px",fontSize:11},children:[h.replace(/_/g," ")," · ",u]},h))}),e.jsxs("div",{style:{marginTop:11,color:t.textMuted,fontSize:11},children:["Snapshot ",p.snapshotId.slice(0,12)," · graph ",p.sourceFingerprint.slice(0,12),p.truncated?" · bounded response":""]})]}),e.jsxs("div",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:9,background:t.cellBg,padding:14},children:[e.jsx("strong",{style:{color:t.textPrimary,fontSize:13},children:"Cross-domain routes"}),e.jsx("div",{style:{display:"grid",gap:7,marginTop:9},children:p.routes.length?p.routes.map(h=>e.jsxs("div",{style:{borderTop:`1px solid ${t.headerBorder}`,paddingTop:7},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:8,color:t.textSecondary,fontSize:12},children:[e.jsxs("span",{children:[h.providerDomainId," → ",h.consumerDomainId]}),e.jsx("span",{style:{color:h.state==="authorized"?t.success:h.state==="observed"?t.textMuted:t.warning,fontWeight:700},children:h.state})]}),e.jsx("div",{style:{marginTop:3,color:t.textMuted,fontSize:11},children:h.purpose||h.reasonCodes.join(", ")||"governed route"})]},h.id)):e.jsx("div",{style:{color:t.textMuted,fontSize:12,marginTop:8},children:"No cross-domain routes declared."})})]})]})]}):null]})}function _t({t,loading:n,domains:i,skills:l,status:s,onBuild:p,onTab:o}){if(n)return e.jsxs("div",{style:{padding:"42px 0",color:t.textMuted,display:"flex",gap:8,alignItems:"center",fontSize:13},children:[e.jsx(H,{size:15})," Loading governed context…"]});const r=[];return i.length?s.ownedDomains<i.length&&r.push(`${i.length-s.ownedDomains} domain${i.length-s.ownedDomains===1?"":"s"} still need an owner.`):r.push("Create a business domain before relying on AI guidance."),l.length||r.push("Draft a domain skill so the agent has governed business guidance."),s.draftSkills&&r.push(`${s.draftSkills} skill${s.draftSkills===1?" is":"s are"} still draft-only and will not guide answers.`),e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("section",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:10},children:[e.jsx(V,{t,label:"Domains",value:i.length,detail:`${s.ownedDomains} with an owner`,icon:e.jsx(se,{size:17})}),e.jsx(V,{t,label:"Active skills",value:s.activeSkills,detail:"available to the agent",icon:e.jsx(re,{size:17})}),e.jsx(V,{t,label:"Draft skills",value:s.draftSkills,detail:"review before activation",icon:e.jsx(ne,{size:17})})]}),e.jsxs("section",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:10,background:t.cellBg,padding:16,display:"grid",gap:10},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx(Ve,{size:16,color:r.length?t.warning:t.success}),e.jsx("strong",{style:{color:t.textPrimary,fontSize:13},children:"Readiness"})]}),r.length?e.jsx("div",{style:{display:"grid",gap:6},children:r.map(g=>e.jsxs("div",{style:{display:"flex",gap:7,color:t.textSecondary,fontSize:12.5},children:[e.jsx(Oe,{size:14,color:t.warning}),g]},g))}):e.jsx("div",{style:{color:t.success,fontSize:12.5},children:"Your agent has owned domains and active governed skills available for retrieval."}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:2},children:[e.jsxs("button",{type:"button",onClick:p,style:Qe(t),children:[e.jsx(ne,{size:13})," Build domains & skills with AI"]}),e.jsx("button",{type:"button",onClick:()=>o("domains"),style:Ee(t),children:"Manage domains"}),e.jsx("button",{type:"button",onClick:()=>o("skills"),style:Ee(t),children:"Manage skills"})]})]})]})}function V({t,label:n,value:i,detail:l,icon:s}){return e.jsxs("div",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:9,background:t.cellBg,padding:13},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:t.textMuted,fontSize:12},children:[n,s]}),e.jsx("div",{style:{color:t.textPrimary,fontSize:25,fontWeight:750,marginTop:7},children:i}),e.jsx("div",{style:{color:t.textMuted,fontSize:11.5,marginTop:3},children:l})]})}function Qe(t){return{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 12px",borderRadius:7,border:`1px solid ${t.accent}`,background:t.accent,color:"#fff",fontWeight:700,fontSize:12.5,fontFamily:t.font,cursor:"pointer"}}function Ee(t){return{display:"inline-flex",alignItems:"center",padding:"7px 12px",borderRadius:7,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,fontWeight:650,fontSize:12.5,fontFamily:t.font,cursor:"pointer"}}const Jt=Object.freeze(Object.defineProperty({__proto__:null,GovernedContextPage:Ht,Knowledge360:Ke},Symbol.toStringTag,{value:"Module"}));export{Jt as G,Ke as K,St as S};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as je,t as Se,r as a,ap as O,a as pe,aq as Ce,ar as Re,as as Ee,at as Le,j as e,n as E,an as H,au as Te,h as ge}from"./index-Ca3UeUWI.js";import{u as Be,a as Ie,M as ze,i as We,B as Pe,C as Me,b as Fe,P as Ne,T as he,c as N,H as xe}from"./dagre.esm-C9zxjHHX.js";import"./react-CRB3T2We.js";const G=[{key:"technical",label:"Technical",title:"Physical sources and dbt transformations",types:Ce},{key:"domain",label:"Domain",title:"Business terms, governed domains, semantic metrics, and certified blocks",types:Re},{key:"end-to-end",label:"End-to-end",title:"Complete path from physical sources through governed meaning to consumption",types:O}],Y=[{type:"block",label:"Blocks"},{type:"app",label:"Apps"},{type:"notebook",label:"Notebooks"},{type:"dashboard",label:"Dashboards"}];function Oe(n,h,o="flow",g="LR"){var v;const p=new he.graphlib.Graph().setDefaultEdgeLabel(()=>({})),b=g==="LR";p.setGraph({rankdir:g,ranksep:o==="layered"?120:b?80:60,nodesep:b?40:50,marginx:32,marginy:32});for(const d of n){const y={width:190,height:58};if(o==="layered"&&((v=d.data)!=null&&v.layer)){const x=Te.indexOf(d.data.layer);x>=0&&(y.rank=x)}p.setNode(d.id,y)}for(const d of h)p.setEdge(d.source,d.target);return he.layout(p),n.map(d=>{const y=p.node(d.id);return{...d,position:{x:y.x-95,y:y.y-29},data:{...d.data,direction:g}}})}function $e({data:n,selected:h}){const o=n.nodeType,g=E[o]??"var(--color-text-tertiary)",p=n.direction??"LR",b=p==="LR"?N.Left:N.Top,v=p==="LR"?N.Right:N.Bottom,d=!!n.dimmed,y=n.status==="certified";return e.jsxs("div",{style:{width:196,display:"flex",alignItems:"center",gap:8,background:"var(--color-bg-card)",border:`1.5px solid ${h?"var(--accent)":"var(--border-default)"}`,borderRadius:9,padding:"9px 11px",boxShadow:h?"0 1px 6px rgba(107,93,211,0.16)":"0 1px 4px rgba(26,26,26,0.05)",opacity:d?.3:1,transition:"opacity 0.15s ease"},children:[e.jsx(xe,{type:"target",position:b,style:{width:7,height:7,background:g,border:"none"}}),e.jsx("span",{style:{width:8,height:8,borderRadius:999,background:g,flexShrink:0}}),e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[e.jsx("span",{title:n.label,style:{fontSize:11.5,fontWeight:650,color:"var(--color-text-primary)",fontFamily:"'JetBrains Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.label}),e.jsx("span",{style:{fontSize:9.5,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:g},children:H[o]??o})]}),y?e.jsx(ge,{size:12,color:"var(--status-success)",strokeWidth:2,style:{flexShrink:0}}):null,e.jsx(xe,{type:"source",position:v,style:{width:7,height:7,background:g,border:"none"}})]})}const De={dagNode:$e};function He(){var ae,le,de;const{state:n,dispatch:h}=je(),o=Se[n.themeMode],[g,p]=a.useState(!0),[b,v]=a.useState({nodes:[],edges:[]}),[d,y]=a.useState({nodes:[],edges:[]}),[x,w]=a.useState(null),[c,L]=a.useState(null),[W,T]=a.useState(!1),[l,s]=a.useState(null),[f,S]=a.useState(Object.fromEntries(O.map(t=>[t,!0]))),[k,Q]=a.useState("flow"),[C,J]=a.useState("LR"),[B,P]=a.useState(null),[$,M]=a.useState(!1),[q,V]=a.useState("block"),[U,K]=a.useState(""),[X,F]=a.useState(!1),[Z,ee]=a.useState(""),[ye,te,fe]=Be([]),[be,oe,me]=Ie([]),re=a.useCallback(async()=>{p(!0);const t=await pe.fetchLineage();v({nodes:t.nodes??[],edges:t.edges??[]}),p(!1)},[]);a.useEffect(()=>{re()},[re]);const R=a.useMemo(()=>b.nodes.filter(t=>Y.some(r=>r.type===t.type)).sort((t,r)=>t.name.localeCompare(r.name)),[b.nodes]),I=a.useCallback(async t=>{L(t),M(!1),P(null),s(null),T(!0);const r=await pe.queryLineage({focus:t,upstreamDepth:12,downstreamDepth:12});y(r.graph??{nodes:[],edges:[]}),w(r.focalNode??null),T(!1)},[]);a.useCallback(()=>{L(null),y({nodes:[],edges:[]}),w(null),s(null),P(null),M(!1),h({type:"SET_LINEAGE_FOCUS",nodeId:null})},[h]),a.useEffect(()=>{n.lineageFocusNodeId&&n.lineageFocusNodeId!==c&&I(n.lineageFocusNodeId)},[n.lineageFocusNodeId]);const m=a.useMemo(()=>{const t=new Set(d.nodes.filter(r=>f[r.type]??!0).map(r=>r.id));return{nodes:d.nodes.filter(r=>t.has(r.id)),edges:d.edges.filter(r=>t.has(r.source)&&t.has(r.target))}},[d,f]),z=a.useMemo(()=>{for(const t of G){const r=new Set(t.types);if(O.every(u=>(f[u]??!0)===r.has(u)))return t.key}return"custom"},[f]),ve=a.useCallback(t=>{const r=new Set(t);S(Object.fromEntries(O.map(i=>[i,r.has(i)])))},[]),j=a.useMemo(()=>{if(!B)return null;const t=new Set([B]),r=new Set([B]);let i=!0;for(;i;){i=!1;for(const u of m.edges)t.has(u.target)&&!t.has(u.source)&&(t.add(u.source),i=!0),r.has(u.source)&&!r.has(u.target)&&(r.add(u.target),i=!0)}return new Set([...t,...r])},[B,m.edges]);a.useEffect(()=>{const t=m.nodes.map(i=>({id:i.id,type:"dagNode",selected:i.id===c,position:{x:0,y:0},data:{label:i.name,nodeType:i.type,domain:i.domain,status:i.status,layer:Ee(i),dimmed:j?!j.has(i.id):!1}})),r=m.edges.map((i,u)=>{const A=j?j.has(i.source)&&j.has(i.target):!1,ce=A?"var(--accent)":Le[i.type]??"var(--color-text-tertiary)";return{id:`edge-${u}-${i.source}-${i.target}-${i.type}`,source:i.source,target:i.target,style:{stroke:ce,strokeWidth:A?2:1.5,opacity:j&&!A?.25:1},markerEnd:{type:ze.ArrowClosed,color:ce,width:12,height:12}}});te(Oe(t,r,k,C)),oe(r)},[m,k,C,j,c,oe,te]);const ke=a.useCallback((t,r)=>{P(r.id);const i=m.nodes.find(u=>u.id===r.id)??null;s(i)},[m.nodes]),D=a.useCallback(()=>{P(null),s(null)},[]),_=a.useMemo(()=>{if(!l)return null;const t=d.edges.filter(i=>i.target===l.id).length,r=d.edges.filter(i=>i.source===l.id).length;return{incoming:t,outgoing:r}},[d.edges,l]),ne=(x==null?void 0:x.name)??((ae=R.find(t=>t.id===c))==null?void 0:ae.name)??c??"",we=(x==null?void 0:x.type)??((le=R.find(t=>t.id===c))==null?void 0:le.type)??"block",ie=Z.trim().toLowerCase(),se=(ie?R.filter(t=>t.name.toLowerCase().includes(ie)):R).slice(0,40);return g?e.jsx("div",{style:{padding:16,color:o.textMuted,fontSize:12},children:"Loading lineage graph..."}):b.nodes.length===0?e.jsx("div",{style:{padding:16,color:o.textMuted,fontSize:12},children:"No lineage graph available yet."}):c?e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--color-bg-primary)"},children:[e.jsx("div",{style:{padding:8,borderBottom:`1px solid ${o.headerBorder}`,background:o.sidebarBg},children:e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:8,flexWrap:"wrap",alignItems:"center"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{onClick:()=>M(t=>!t),title:"Change the traced entity",style:{display:"inline-flex",alignItems:"center",gap:7,height:30,padding:"0 11px",borderRadius:8,border:`1px solid ${$?o.accent:o.headerBorder}`,background:$?"var(--accent-dim)":o.cellBg,color:o.textPrimary,cursor:"pointer",fontFamily:o.font,maxWidth:320},children:[e.jsx("span",{style:{fontSize:10.5,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:o.textMuted},children:"Tracing"}),e.jsx("span",{style:{width:8,height:8,borderRadius:999,background:E[we]??"var(--color-text-tertiary)",flexShrink:0}}),e.jsx("span",{style:{fontSize:12.5,fontWeight:650,fontFamily:"'JetBrains Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ne}),e.jsx("span",{style:{fontSize:9,color:o.textMuted},children:"▾"})]}),$&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>M(!1),style:{position:"fixed",inset:0,zIndex:30}}),e.jsx("div",{style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:31,width:340,background:o.cellBg,border:`1px solid ${o.headerBorder}`,borderRadius:11,boxShadow:"0 10px 30px rgba(26,26,26,0.14)",padding:12},children:e.jsx(ue,{t:o,entities:R,activeType:q,onTypeChange:V,query:U,onQueryChange:K,onSelect:t=>void I(t),focalId:c,listHeight:240})})]})]}),e.jsxs("div",{style:{position:"relative",flex:"0 1 300px",minWidth:160},children:[e.jsxs("svg",{style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)",color:o.textMuted,pointerEvents:"none"},width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.3-4.3"})]}),e.jsx("input",{value:Z,onChange:t=>{ee(t.target.value),F(!0)},onFocus:()=>F(!0),placeholder:"Search another block, app, or notebook…",style:{width:"100%",boxSizing:"border-box",height:30,padding:"0 10px 0 28px",borderRadius:8,border:`1px solid ${X?o.accent:o.headerBorder}`,background:"var(--color-bg-sunken)",color:o.textPrimary,fontSize:12,fontFamily:o.font,outline:"none"}}),X&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>F(!1),style:{position:"fixed",inset:0,zIndex:30}}),e.jsx("div",{style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:31,width:"min(340px, 90vw)",maxHeight:300,overflow:"auto",background:o.cellBg,border:`1px solid ${o.headerBorder}`,borderRadius:11,boxShadow:"0 10px 30px rgba(26,26,26,0.14)",padding:4},children:se.length===0?e.jsx("div",{style:{padding:"12px 11px",fontSize:12,color:o.textMuted,fontFamily:o.font},children:"No matching block, app, or notebook."}):se.map(t=>e.jsxs("button",{onClick:()=>{I(t.id),ee(""),F(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:9,textAlign:"left",padding:"8px 10px",border:"none",borderRadius:7,background:t.id===c?"var(--accent-dim)":"transparent",cursor:"pointer",fontFamily:o.font},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:999,background:E[t.type]??"var(--color-text-tertiary)",flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:550,color:o.textPrimary,fontFamily:"'JetBrains Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),e.jsx("span",{style:{fontSize:9.5,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:o.textMuted,flexShrink:0},children:H[t.type]??t.type})]},t.id))})]})]}),e.jsx("div",{style:{width:1,height:20,background:o.headerBorder,margin:"0 2px"}}),e.jsxs("div",{style:{display:"flex",borderRadius:6,border:`1px solid ${o.headerBorder}`,overflow:"hidden"},children:[e.jsx("button",{onClick:()=>Q("flow"),style:{padding:"4px 8px",fontSize:10,fontWeight:700,border:"none",cursor:"pointer",background:k==="flow"?"var(--color-bg-tertiary)":"transparent",color:k==="flow"?"var(--color-text-primary)":"var(--color-text-tertiary)"},children:"Flow"}),e.jsx("button",{onClick:()=>Q("layered"),style:{padding:"4px 8px",fontSize:10,fontWeight:700,border:"none",borderLeft:`1px solid ${o.headerBorder}`,cursor:"pointer",background:k==="layered"?"var(--color-bg-tertiary)":"transparent",color:k==="layered"?"var(--color-text-primary)":"var(--color-text-tertiary)"},children:"Layered"})]}),e.jsxs("div",{style:{display:"flex",borderRadius:6,border:`1px solid ${o.headerBorder}`,overflow:"hidden",marginRight:4},children:[e.jsxs("button",{title:"Horizontal layout (left → right)",onClick:()=>J("LR"),style:{padding:"4px 8px",fontSize:10,fontWeight:700,border:"none",cursor:"pointer",background:C==="LR"?"var(--color-bg-tertiary)":"transparent",color:C==="LR"?"var(--color-text-primary)":"var(--color-text-tertiary)",display:"flex",alignItems:"center",gap:3},children:[e.jsxs("svg",{width:"14",height:"10",viewBox:"0 0 14 10",fill:"none",children:[e.jsx("rect",{x:"0",y:"2",width:"4",height:"6",rx:"1",fill:"currentColor",opacity:"0.7"}),e.jsx("line",{x1:"4",y1:"5",x2:"10",y2:"5",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("path",{d:"M9 3l2 2-2 2",stroke:"currentColor",strokeWidth:"1.2",fill:"none"}),e.jsx("rect",{x:"10",y:"2",width:"4",height:"6",rx:"1",fill:"currentColor"})]}),"LR"]}),e.jsxs("button",{title:"Vertical layout (top → bottom)",onClick:()=>J("TB"),style:{padding:"4px 8px",fontSize:10,fontWeight:700,border:"none",borderLeft:`1px solid ${o.headerBorder}`,cursor:"pointer",background:C==="TB"?"var(--color-bg-tertiary)":"transparent",color:C==="TB"?"var(--color-text-primary)":"var(--color-text-tertiary)",display:"flex",alignItems:"center",gap:3},children:[e.jsxs("svg",{width:"10",height:"14",viewBox:"0 0 10 14",fill:"none",children:[e.jsx("rect",{x:"2",y:"0",width:"6",height:"4",rx:"1",fill:"currentColor",opacity:"0.7"}),e.jsx("line",{x1:"5",y1:"4",x2:"5",y2:"10",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("path",{d:"M3 9l2 2 2-2",stroke:"currentColor",strokeWidth:"1.2",fill:"none"}),e.jsx("rect",{x:"2",y:"10",width:"6",height:"4",rx:"1",fill:"currentColor"})]}),"TB"]})]}),e.jsx("div",{role:"group","aria-label":"Lineage view",style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,border:`1px solid ${o.headerBorder}`,borderRadius:7,background:o.appBg,marginRight:4},children:G.map(t=>e.jsx("button",{onClick:()=>ve(t.types),title:t.title,"aria-pressed":z===t.key,style:{padding:"4px 11px",fontSize:11.5,fontWeight:600,border:"none",borderRadius:5,cursor:"pointer",fontFamily:o.font,whiteSpace:"nowrap",background:z===t.key?"var(--accent-dim)":"transparent",color:z===t.key?o.accent:o.textMuted},children:t.label},t.key))}),B&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{flex:1}}),e.jsx("button",{onClick:D,style:{borderRadius:7,border:`1px solid ${o.accent}`,background:"var(--accent-dim)",color:o.accent,cursor:"pointer",fontSize:11.5,fontWeight:650,padding:"5px 11px",whiteSpace:"nowrap"},children:"Show all"})]})]})}),e.jsx("div",{style:{flex:1,position:"relative"},children:e.jsxs(We,{nodes:ye,edges:be,onNodesChange:fe,onEdgesChange:me,onNodeClick:ke,onPaneClick:D,nodeTypes:De,fitView:!0,fitViewOptions:{padding:.18},proOptions:{hideAttribution:!0},style:{background:"var(--bg-canvas)"},children:[e.jsx(Pe,{color:"var(--border-strong)",gap:22,size:1}),e.jsx(Me,{showInteractive:!1}),e.jsx(Fe,{nodeColor:t=>{var r;return E[((r=t.data)==null?void 0:r.nodeType)??"source_table"]??"var(--color-text-tertiary)"},maskColor:"color-mix(in srgb, var(--color-bg-primary) 55%, transparent)",style:{background:"var(--color-bg-sunken)",border:"1px solid var(--color-border-primary)"}}),e.jsx(Ne,{position:"bottom-left",children:l?e.jsxs("div",{style:{width:264,background:"var(--color-bg-card)",border:"1px solid var(--color-border-primary)",borderRadius:11,boxShadow:"0 8px 26px rgba(26,26,26,0.13)",padding:"12px 14px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:999,background:E[l.type]??"var(--color-text-tertiary)",flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:700,color:"var(--color-text-primary)",fontFamily:"'JetBrains Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l.name}),e.jsx("button",{onClick:D,title:"Clear focus",style:{width:20,height:20,borderRadius:5,border:"none",background:"none",color:"var(--color-text-tertiary)",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,flexShrink:0},children:"×"})]}),e.jsxs("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",marginTop:3},children:[H[l.type]??l.type,_?` · ${_.incoming} upstream · ${_.outgoing} downstream`:""]}),l.domain?e.jsxs("div",{style:{fontSize:11.5,color:"var(--color-text-secondary)",lineHeight:1.5,marginTop:7},children:["Domain: ",l.domain]}):null,e.jsxs("div",{style:{display:"flex",gap:8,marginTop:10},children:[e.jsx("button",{onClick:()=>{l&&l.id!==c&&I(l.id)},disabled:!l||l.id===c,title:(l==null?void 0:l.id)===c?"Already the traced entity":"Re-scope lineage to this node",style:{display:"inline-flex",alignItems:"center",gap:5,height:26,padding:"0 10px",borderRadius:6,border:"none",background:"var(--accent)",color:"#fff",fontSize:11,fontWeight:650,cursor:(l==null?void 0:l.id)===c?"default":"pointer",opacity:(l==null?void 0:l.id)===c?.5:1},children:"Trace from here"}),e.jsx("button",{onClick:()=>h({type:"OPEN_GLOBAL_AI",autoRun:{text:`Explain the lineage of ${l.name} — where does it come from and what consumes it?`}}),style:{display:"inline-flex",alignItems:"center",gap:5,height:26,padding:"0 10px",borderRadius:6,border:"1px solid var(--color-border-primary)",background:"var(--color-bg-card)",color:"var(--color-text-secondary)",fontSize:11,fontWeight:600,cursor:"pointer"},children:"Ask about this"})]})]}):null})]})}),e.jsxs("div",{style:{height:28,flexShrink:0,borderTop:"1px solid var(--border-subtle)",background:"var(--color-bg-card)",display:"flex",alignItems:"center",gap:14,padding:"0 14px",fontSize:10.5,color:"var(--color-text-tertiary)"},children:[e.jsxs("span",{children:[z==="custom"?"Custom":(de=G.find(t=>t.key===z))==null?void 0:de.label," lineage of ",ne," · ",m.nodes.length," nodes · ",m.edges.length," edges",W?" · loading…":""]}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:999,background:"var(--status-success)"}}),"Compiled from the dbt manifest"]}),e.jsx("div",{style:{flex:1}}),e.jsx("span",{children:"Click a node to focus its path · click the canvas to clear"})]})]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--color-bg-primary)",alignItems:"center",justifyContent:"center",padding:24,overflow:"auto"},children:e.jsxs("div",{style:{width:"min(560px, 100%)",border:`1px solid ${o.headerBorder}`,borderRadius:14,background:o.cellBg,padding:"22px 22px 18px",boxShadow:"0 1px 4px rgba(26,26,26,0.05)"},children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:o.textPrimary,fontFamily:o.font},children:"Trace lineage"}),e.jsx("div",{style:{fontSize:12.5,color:o.textMuted,marginTop:3,lineHeight:1.5,fontFamily:o.font},children:"Pick a block, app, or notebook to see its upstream sources and downstream consumers — no project-wide noise."}),e.jsx("div",{style:{marginTop:16},children:e.jsx(ue,{t:o,entities:R,activeType:q,onTypeChange:V,query:U,onQueryChange:K,onSelect:t=>void I(t),focalId:c,listHeight:300})})]})})}function ue({t:n,entities:h,activeType:o,onTypeChange:g,query:p,onQueryChange:b,onSelect:v,focalId:d,listHeight:y}){var T,l;const x=Y.filter(s=>h.some(f=>f.type===s.type)),w=x.some(s=>s.type===o)?o:((T=x[0])==null?void 0:T.type)??o,c=p.trim().toLowerCase(),L=h.filter(s=>s.type===w).filter(s=>!c||s.name.toLowerCase().includes(c)),W=((l=Y.find(s=>s.type===w))==null?void 0:l.label)??"items";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:9,minWidth:0},children:[e.jsx("div",{style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,border:`1px solid ${n.headerBorder}`,borderRadius:8,background:n.appBg,alignSelf:"flex-start",flexWrap:"wrap"},children:x.map(s=>{const f=s.type===w,S=h.filter(k=>k.type===s.type).length;return e.jsxs("button",{onClick:()=>g(s.type),style:{display:"inline-flex",alignItems:"center",gap:6,border:"none",borderRadius:6,padding:"5px 11px",fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:n.font,background:f?"var(--accent-dim)":"transparent",color:f?n.accent:n.textMuted},children:[s.label,e.jsx("span",{style:{fontSize:10.5,color:f?n.accent:n.textMuted,opacity:.8},children:S})]},s.type)})}),e.jsx("input",{value:p,onChange:s=>b(s.target.value),placeholder:`Search ${W.toLowerCase()}…`,style:{padding:"8px 10px",borderRadius:8,border:`1px solid ${n.headerBorder}`,background:"var(--color-bg-sunken)",color:n.textPrimary,fontSize:12,fontFamily:n.font,outline:"none"}}),e.jsx("div",{style:{maxHeight:y,overflow:"auto",border:`1px solid ${n.headerBorder}`,borderRadius:8},children:L.length===0?e.jsx("div",{style:{padding:"14px 12px",fontSize:12,color:n.textMuted,fontFamily:n.font},children:h.some(s=>s.type===w)?"No matches.":`No ${W.toLowerCase()} in this project yet.`}):L.map((s,f)=>{const S=s.id===d;return e.jsxs("button",{onClick:()=>v(s.id),style:{width:"100%",display:"flex",alignItems:"center",gap:9,textAlign:"left",padding:"9px 11px",border:"none",borderTop:f===0?"none":`1px solid ${n.headerBorder}`,background:S?"var(--accent-dim)":"transparent",cursor:"pointer",fontFamily:n.font},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:999,background:E[s.type]??"var(--color-text-tertiary)",flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:S?650:500,color:n.textPrimary,fontFamily:"'JetBrains Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s.name}),s.status==="certified"?e.jsx(ge,{size:12,color:"var(--status-success)",strokeWidth:2,style:{flexShrink:0}}):null]},s.id)})})]})}export{He as LineageDAG};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import{r as v,j as d,t as Pe,V as De,W as ue,aj as _e,a as je,ak as Be,al as Ie,am as Te,R as be,n as ze,o as Oe}from"./index-Ca3UeUWI.js";import{S as Z,g as ye,E as S,s as Ne,a as g,b as ve,c as Ke,P as Qe,d as Ge,e as Ue,F as Ze,f as Ve,h as Se,V as He,D as R,R as Ye,i as Je,C as M,j as we,k as y,r as Xe,l as et,m as tt,u as rt,n as nt,t as st,o as at,p as it,q as ot,v as lt,w as ct,x as ut,y as ht,z as dt,A as ft,B as pt,G as mt,H as gt,I as xt,J as bt,K as yt,L as vt,M as he,N as St,O as u}from"./codemirror-1_I9gm6Z.js";const de=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class P{constructor(e,r,n=0,s=e.length,a,i){this.test=i,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,s),this.bufferStart=n,this.normalize=a?o=>a(de(o)):de,this.query=this.normalize(r)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Ge(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let r=Je(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Ue(e);let s=this.normalize(r);if(s.length)for(let a=0,i=n;;a++){let o=s.charCodeAt(a),l=this.match(o,i,this.bufferPos+this.bufferStart);if(a==s.length-1){if(l)return this.value=l,this;break}i==n&&a<r.length&&r.charCodeAt(a)==o&&i++}}}match(e,r,n){let s=null;for(let a=0;a<this.matches.length;a+=2){let i=this.matches[a],o=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?s={from:this.matches[a+1],to:n}:(this.matches[a]++,o=!0)),o||(this.matches.splice(a,2),a-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:r,to:n}:this.matches.push(1,r)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(P.prototype[Symbol.iterator]=function(){return this});const ke={from:-1,to:-1,match:/.*/.exec("")},se="gm"+(/x/.unicode==null?"":"u");class Ce{constructor(e,r,n,s=0,a=e.length){if(this.text=e,this.to=a,this.curLine="",this.done=!1,this.value=ke,/\\[sWDnr]|\n|\r|\[\^/.test(r))return new Me(e,r,n,s,a);this.re=new RegExp(r,se+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.iter=e.iter();let i=e.lineAt(s);this.curLineStart=i.from,this.matchPos=N(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let r=this.matchPos<=this.to&&this.re.exec(this.curLine);if(r){let n=this.curLineStart+r.index,s=n+r[0].length;if(this.matchPos=N(this.text,s+(n==s?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<s||n>this.value.to)&&(!this.test||this.test(n,s,r)))return this.value={from:n,to:s,match:r},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const J=new WeakMap;class W{constructor(e,r){this.from=e,this.text=r}get to(){return this.from+this.text.length}static get(e,r,n){let s=J.get(e);if(!s||s.from>=n||s.to<=r){let o=new W(r,e.sliceString(r,n));return J.set(e,o),o}if(s.from==r&&s.to==n)return s;let{text:a,from:i}=s;return i>r&&(a=e.sliceString(r,i)+a,i=r),s.to<n&&(a+=e.sliceString(s.to,n)),J.set(e,new W(i,a)),new W(r,a.slice(r-i,n-i))}}class Me{constructor(e,r,n,s,a){this.text=e,this.to=a,this.done=!1,this.value=ke,this.matchPos=N(e,s),this.re=new RegExp(r,se+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.flat=W.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,r=this.re.exec(this.flat.text);if(r&&!r[0]&&r.index==e&&(this.re.lastIndex=e+1,r=this.re.exec(this.flat.text)),r){let n=this.flat.from+r.index,s=n+r[0].length;if((this.flat.to>=this.to||r.index+r[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,s,r)))return this.value={from:n,to:s,match:r},this.matchPos=N(this.text,s+(n==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=W.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Ce.prototype[Symbol.iterator]=Me.prototype[Symbol.iterator]=function(){return this});function wt(t){try{return new RegExp(t,se),!0}catch{return!1}}function N(t,e){if(e>=t.length)return e;let r=t.lineAt(e),n;for(;e<r.to&&(n=r.text.charCodeAt(e-r.from))>=56320&&n<57344;)e++;return e}const kt=t=>{let{state:e}=t,r=String(e.doc.lineAt(t.state.selection.main.head).number),{close:n,result:s}=Ne(t,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:r},focus:!0,submitLabel:e.phrase("go")});return s.then(a=>{let i=a&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(a.elements.line.value);if(!i){t.dispatch({effects:n});return}let o=e.doc.lineAt(e.selection.main.head),[,l,c,m,w]=i,k=m?+m.slice(1):0,f=c?+c:o.number;if(c&&w){let E=f/100;l&&(E=E*(l=="-"?-1:1)+o.number/e.doc.lines),f=Math.round(e.doc.lines*E)}else c&&l&&(f=f*(l=="-"?-1:1)+o.number);let j=e.doc.line(Math.max(1,Math.min(e.doc.lines,f))),A=S.cursor(j.from+Math.max(0,Math.min(k,j.length)));t.dispatch({effects:[n,g.scrollIntoView(A.from,{y:"center"})],selection:A})}),!0},Ct=({state:t,dispatch:e})=>{let{selection:r}=t,n=S.create(r.ranges.map(s=>t.wordAt(s.head)||S.cursor(s.head)),r.mainIndex);return n.eq(r)?!1:(e(t.update({selection:n})),!0)};function Mt(t,e){let{main:r,ranges:n}=t.selection,s=t.wordAt(r.head),a=s&&s.from==r.from&&s.to==r.to;for(let i=!1,o=new P(t.doc,e,n[n.length-1].to);;)if(o.next(),o.done){if(i)return null;o=new P(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),i=!0}else{if(i&&n.some(l=>l.from==o.value.from))continue;if(a){let l=t.wordAt(o.value.from);if(!l||l.from!=o.value.from||l.to!=o.value.to)continue}return o.value}}const Lt=({state:t,dispatch:e})=>{let{ranges:r}=t.selection;if(r.some(a=>a.from===a.to))return Ct({state:t,dispatch:e});let n=t.sliceDoc(r[0].from,r[0].to);if(t.selection.ranges.some(a=>t.sliceDoc(a.from,a.to)!=n))return!1;let s=Mt(t,n);return s?(e(t.update({selection:t.selection.addRange(S.range(s.from,s.to),!1),effects:g.scrollIntoView(s.to)})),!0):!1},q=Ze.define({combine(t){return Ve(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new zt(e),scrollToMatch:e=>g.scrollIntoView(e)})}});function Et(t){return t?[q.of(t),ne]:ne}class Le{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||wt(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(r,n)=>n=="n"?`
|
|
2
|
-
`:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Wt(this):new At(this)}getCursor(e,r=0,n){let s=e.doc?e:Se.create({doc:e});return n==null&&(n=s.doc.length),this.regexp?F(this,s,r,n):$(this,s,r,n)}}class Ee{constructor(e){this.spec=e}}function Rt(t,e,r){return(n,s,a,i)=>{if(r&&!r(n,s,a,i))return!1;let o=n>=i&&s<=i+a.length?a.slice(n-i,s-i):e.doc.sliceString(n,s);return t(o,e,n,s)}}function $(t,e,r,n){let s;return t.wholeWord&&(s=qt(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(s=Rt(t.test,e,s)),new P(e.doc,t.unquoted,r,n,t.caseSensitive?void 0:a=>a.toLowerCase(),s)}function qt(t,e){return(r,n,s,a)=>((a>r||a+s.length<n)&&(a=Math.max(0,r-2),s=t.sliceString(a,Math.min(t.length,n+2))),(e(K(s,r-a))!=M.Word||e(Q(s,r-a))!=M.Word)&&(e(Q(s,n-a))!=M.Word||e(K(s,n-a))!=M.Word))}class At extends Ee{constructor(e){super(e)}nextMatch(e,r,n){let s=$(this.spec,e,n,e.doc.length).nextOverlapping();if(s.done){let a=Math.min(e.doc.length,r+this.spec.unquoted.length);s=$(this.spec,e,0,a).nextOverlapping()}return s.done||s.value.from==r&&s.value.to==n?null:s.value}prevMatchInRange(e,r,n){for(let s=n;;){let a=Math.max(r,s-1e4-this.spec.unquoted.length),i=$(this.spec,e,a,s),o=null;for(;!i.nextOverlapping().done;)o=i.value;if(o)return o;if(a==r)return null;s-=1e4}}prevMatch(e,r,n){let s=this.prevMatchInRange(e,0,r);return s||(s=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),s&&(s.from!=r||s.to!=n)?s:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,r){let n=$(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=r)return null;s.push(n.value)}return s}highlight(e,r,n,s){let a=$(this.spec,e,Math.max(0,r-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}function $t(t,e,r){return(n,s,a)=>(!r||r(n,s,a))&&t(a[0],e,n,s)}function F(t,e,r,n){let s;return t.wholeWord&&(s=Ft(e.charCategorizer(e.selection.main.head))),t.test&&(s=$t(t.test,e,s)),new Ce(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:s},r,n)}function K(t,e){return t.slice(we(t,e,!1),e)}function Q(t,e){return t.slice(e,we(t,e))}function Ft(t){return(e,r,n)=>!n[0].length||(t(K(n.input,n.index))!=M.Word||t(Q(n.input,n.index))!=M.Word)&&(t(Q(n.input,n.index+n[0].length))!=M.Word||t(K(n.input,n.index+n[0].length))!=M.Word)}class Wt extends Ee{nextMatch(e,r,n){let s=F(this.spec,e,n,e.doc.length).next();return s.done&&(s=F(this.spec,e,0,r).next()),s.done?null:s.value}prevMatchInRange(e,r,n){for(let s=1;;s++){let a=Math.max(r,n-s*1e4),i=F(this.spec,e,a,n),o=null;for(;!i.next().done;)o=i.value;if(o&&(a==r||o.from>a+10))return o;if(a==r)return null}}prevMatch(e,r,n){return this.prevMatchInRange(e,0,r)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(r,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let s=n.length;s>0;s--){let a=+n.slice(0,s);if(a>0&&a<e.match.length)return e.match[a]+n.slice(s)}return r})}matchAll(e,r){let n=F(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=r)return null;s.push(n.value)}return s}highlight(e,r,n,s){let a=F(this.spec,e,Math.max(0,r-250),Math.min(n+250,e.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}const D=Z.define(),ae=Z.define(),L=ve.define({create(t){return new X(re(t).create(),null)},update(t,e){for(let r of e.effects)r.is(D)?t=new X(r.value.create(),t.panel):r.is(ae)&&(t=new X(t.query,r.value?ie:null));return t},provide:t=>Ke.from(t,e=>e.panel)});class X{constructor(e,r){this.query=e,this.panel=r}}const Pt=R.mark({class:"cm-searchMatch"}),Dt=R.mark({class:"cm-searchMatch cm-searchMatch-selected"}),_t=He.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(L))}update(t){let e=t.state.field(L);(e!=t.startState.field(L)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return R.none;let{view:r}=this,n=new Ye;for(let s=0,a=r.visibleRanges,i=a.length;s<i;s++){let{from:o,to:l}=a[s];for(;s<i-1&&l>a[s+1].from-500;)l=a[++s].to;t.highlight(r.state,o,l,(c,m)=>{let w=r.state.selection.ranges.some(k=>k.from==c&&k.to==m);n.add(c,m,w?Dt:Pt)})}return n.finish()}},{decorations:t=>t.decorations});function _(t){return e=>{let r=e.state.field(L,!1);return r&&r.query.spec.valid?t(e,r):Ae(e)}}const G=_((t,{query:e})=>{let{to:r}=t.state.selection.main,n=e.nextMatch(t.state,r,r);if(!n)return!1;let s=S.single(n.from,n.to),a=t.state.facet(q);return t.dispatch({selection:s,effects:[oe(t,n),a.scrollToMatch(s.main,t)],userEvent:"select.search"}),qe(t),!0}),U=_((t,{query:e})=>{let{state:r}=t,{from:n}=r.selection.main,s=e.prevMatch(r,n,n);if(!s)return!1;let a=S.single(s.from,s.to),i=t.state.facet(q);return t.dispatch({selection:a,effects:[oe(t,s),i.scrollToMatch(a.main,t)],userEvent:"select.search"}),qe(t),!0}),jt=_((t,{query:e})=>{let r=e.matchAll(t.state,1e3);return!r||!r.length?!1:(t.dispatch({selection:S.create(r.map(n=>S.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),Bt=({state:t,dispatch:e})=>{let r=t.selection;if(r.ranges.length>1||r.main.empty)return!1;let{from:n,to:s}=r.main,a=[],i=0;for(let o=new P(t.doc,t.sliceDoc(n,s));!o.next().done;){if(a.length>1e3)return!1;o.value.from==n&&(i=a.length),a.push(S.range(o.value.from,o.value.to))}return e(t.update({selection:S.create(a,i),userEvent:"select.search.matches"})),!0},fe=_((t,{query:e})=>{let{state:r}=t,{from:n,to:s}=r.selection.main;if(r.readOnly)return!1;let a=e.nextMatch(r,n,n);if(!a)return!1;let i=a,o=[],l,c,m=[];i.from==n&&i.to==s&&(c=r.toText(e.getReplacement(i)),o.push({from:i.from,to:i.to,insert:c}),i=e.nextMatch(r,i.from,i.to),m.push(g.announce.of(r.phrase("replaced match on line $",r.doc.lineAt(n).number)+".")));let w=t.state.changes(o);return i&&(l=S.single(i.from,i.to).map(w),m.push(oe(t,i)),m.push(r.facet(q).scrollToMatch(l.main,t))),t.dispatch({changes:w,selection:l,effects:m,userEvent:"input.replace"}),!0}),It=_((t,{query:e})=>{if(t.state.readOnly)return!1;let r=e.matchAll(t.state,1e9).map(s=>{let{from:a,to:i}=s;return{from:a,to:i,insert:e.getReplacement(s)}});if(!r.length)return!1;let n=t.state.phrase("replaced $ matches",r.length)+".";return t.dispatch({changes:r,effects:g.announce.of(n),userEvent:"input.replace.all"}),!0});function ie(t){return t.state.facet(q).createPanel(t)}function re(t,e){var r,n,s,a,i;let o=t.selection.main,l=o.empty||o.to>o.from+100?"":t.sliceDoc(o.from,o.to);if(e&&!l)return e;let c=t.facet(q);return new Le({search:((r=e==null?void 0:e.literal)!==null&&r!==void 0?r:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:c.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:c.literal,regexp:(a=e==null?void 0:e.regexp)!==null&&a!==void 0?a:c.regexp,wholeWord:(i=e==null?void 0:e.wholeWord)!==null&&i!==void 0?i:c.wholeWord})}function Re(t){let e=ye(t,ie);return e&&e.dom.querySelector("[main-field]")}function qe(t){let e=Re(t);e&&e==t.root.activeElement&&e.select()}const Ae=t=>{let e=t.state.field(L,!1);if(e&&e.panel){let r=Re(t);if(r&&r!=t.root.activeElement){let n=re(t.state,e.query.spec);n.valid&&t.dispatch({effects:D.of(n)}),r.focus(),r.select()}}else t.dispatch({effects:[ae.of(!0),e?D.of(re(t.state,e.query.spec)):Z.appendConfig.of(ne)]});return!0},$e=t=>{let e=t.state.field(L,!1);if(!e||!e.panel)return!1;let r=ye(t,ie);return r&&r.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:ae.of(!1)}),!0},Tt=[{key:"Mod-f",run:Ae,scope:"editor search-panel"},{key:"F3",run:G,shift:U,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:G,shift:U,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:$e,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Bt},{key:"Mod-Alt-g",run:kt},{key:"Mod-d",run:Lt,preventDefault:!0}];class zt{constructor(e){this.view=e;let r=this.query=e.state.field(L).query.spec;this.commit=this.commit.bind(this),this.searchField=y("input",{value:r.search,placeholder:b(e,"Find"),"aria-label":b(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=y("input",{value:r.replace,placeholder:b(e,"Replace"),"aria-label":b(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=y("input",{type:"checkbox",name:"case",form:"",checked:r.caseSensitive,onchange:this.commit}),this.reField=y("input",{type:"checkbox",name:"re",form:"",checked:r.regexp,onchange:this.commit}),this.wordField=y("input",{type:"checkbox",name:"word",form:"",checked:r.wholeWord,onchange:this.commit});function n(s,a,i){return y("button",{class:"cm-button",name:s,onclick:a,type:"button"},i)}this.dom=y("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,n("next",()=>G(e),[b(e,"next")]),n("prev",()=>U(e),[b(e,"previous")]),n("select",()=>jt(e),[b(e,"all")]),y("label",null,[this.caseField,b(e,"match case")]),y("label",null,[this.reField,b(e,"regexp")]),y("label",null,[this.wordField,b(e,"by word")]),...e.state.readOnly?[]:[y("br"),this.replaceField,n("replace",()=>fe(e),[b(e,"replace")]),n("replaceAll",()=>It(e),[b(e,"replace all")])],y("button",{name:"close",onclick:()=>$e(e),"aria-label":b(e,"close"),type:"button"},["×"])])}commit(){let e=new Le({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:D.of(e)}))}keydown(e){Xe(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?U:G)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),fe(this.view))}update(e){for(let r of e.transactions)for(let n of r.effects)n.is(D)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(q).top}}function b(t,e){return t.state.phrase(e)}const T=30,z=/[\s\.,:;?!]/;function oe(t,{from:e,to:r}){let n=t.state.doc.lineAt(e),s=t.state.doc.lineAt(r).to,a=Math.max(n.from,e-T),i=Math.min(s,r+T),o=t.state.sliceDoc(a,i);if(a!=n.from){for(let l=0;l<T;l++)if(!z.test(o[l+1])&&z.test(o[l])){o=o.slice(l);break}}if(i!=s){for(let l=o.length-1;l>o.length-T;l--)if(!z.test(o[l-1])&&z.test(o[l])){o=o.slice(0,l);break}}return g.announce.of(`${t.state.phrase("current match")}. ${o} ${t.state.phrase("on line")} ${n.number}.`)}const Ot=g.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),ne=[L,Qe.low(_t),Ot],pe=[{name:"domain",detail:"business domain (namespace)"},{name:"owner",detail:"accountable owner — required to certify"},{name:"description",detail:"business-facing description"},{name:"status",detail:"draft | certified"},{name:"pattern",detail:"reusable block pattern"},{name:"grain",detail:'row grain, e.g. "one row per customer"'},{name:"outputs",detail:"declared output column names"},{name:"entities",detail:'business entities, e.g. ["order"]'},{name:"tags",detail:"discoverability tags"},{name:"llmContext",detail:"when an agent should use this block"},{name:"reviewCadence",detail:"how often to re-review"},{name:"sourceSystems",detail:"upstream source systems"},{name:"dimensions",detail:"queryable dimensions"},{name:"allowedFilters",detail:"filters an app may bind"},{name:"filterBindings",detail:"filter → column map (app-ready)",snippet:`filterBindings {
|
|
3
|
-
$0
|
|
4
|
-
}`},{name:"parameterPolicy",detail:"per-parameter reuse policy",snippet:`parameterPolicy {
|
|
5
|
-
$0
|
|
6
|
-
}`},{name:"identifiers",detail:"identifier columns"},{name:"synonyms",detail:"alternate names"},{name:"primaryTerms",detail:"governed terms this block defines"},{name:"replacementFor",detail:"block this supersedes"},{name:"boundedContext",detail:"bounded context"},{name:"businessOwner",detail:"business (non-technical) owner"},{name:"businessOutcome",detail:"outcome this supports"},{name:"businessRules",detail:"business rules / caveats"},{name:"decisionUse",detail:"decision this informs"},{name:"caveats",detail:"known caveats"},{name:"invariants",detail:"assertions that must hold"},{name:"chart",detail:"default visualization",snippet:'chart = "bar"'},{name:"examples",detail:"example questions block",snippet:`examples = [
|
|
7
|
-
{ question = "$0" }
|
|
8
|
-
]`},{name:"parameters",detail:"parameters block",snippet:`parameters {
|
|
9
|
-
$0
|
|
10
|
-
}`},{name:"tests",detail:"test assertions block",snippet:`tests {
|
|
11
|
-
assert $0
|
|
12
|
-
}`},{name:"query",detail:"the SQL body",snippet:`query = """
|
|
13
|
-
$0
|
|
14
|
-
"""`}],Nt={chart:["bar","line","area","column","combo","pie","donut","scatter","histogram","heatmap","number","single_value","table"],viz:["bar","line","area","column","combo","pie","donut","scatter","histogram","heatmap","number","single_value","table"],type:["bar","line","area","column","combo","pie","donut","scatter","histogram","heatmap","number","single_value","table"],pattern:["metric_wrapper","entity_profile","entity_rollup","ranking","trend","bridge","drilldown","replacement","custom"],reviewCadence:["daily","weekly","monthly","quarterly","annually"],status:["draft","certified"],type_block:["custom","semantic"]};function Kt(t){return(t.match(/"""/g)??[]).length%2===1}function me(t){return{label:t.name,type:"property",detail:t.detail,apply:t.snippet?Qt(t.snippet):`${t.name} = `}}function Qt(t){return(e,r,n,s)=>{const a=t.indexOf("$0"),i=t.replace("$0",""),o=a>=0?n+a:n+i.length;e.dispatch({changes:{from:n,to:s,insert:i},selection:{anchor:o}})}}const Gt=t=>{const e=t.state.doc.lineAt(t.pos),r=t.state.sliceDoc(0,t.pos),n=r.slice(e.from);if(Kt(r))return null;const s=/([a-zA-Z_]+)\s*=\s*"([^"]*)$/.exec(n);if(s){const i=Nt[s[1]];if(i){const o=t.pos-s[2].length,l=s[2].toLowerCase();return{from:o,options:i.filter(c=>!l||c.toLowerCase().includes(l)).map(c=>({label:c,type:"enum"})),validFor:/^[\w-]*$/}}return null}const a=t.matchBefore(/[a-zA-Z_]+/);if(a&&/^\s*[a-zA-Z_]+$/.test(n)){const i=a.text.toLowerCase();return{from:a.from,options:pe.filter(o=>o.name.toLowerCase().startsWith(i)||o.name.toLowerCase().includes(i)).map(me),validFor:/^[a-zA-Z_]*$/}}return t.explicit&&/^\s*$/.test(n)?{from:t.pos,options:pe.map(me)}:null},ge=new Map;async function ee(t,e,r){const n=`${t}:${r??""}:${e}`.toLowerCase(),s=ge.get(n);if(s&&s.expiresAt>Date.now())return s.items;const a=new URLSearchParams({kind:t,q:e,limit:"60"});r&&a.set("relation",r);const i=await fetch(`${window.location.origin}/api/editor/completions?${a}`);if(!i.ok)return[];const o=await i.json(),l=Array.isArray(o.completions)?o.completions:[];return ge.set(n,{items:l,expiresAt:Date.now()+2e4}),l}const Ut=async t=>{const e=t.state.sliceDoc(0,t.pos),r=/\b(?:from|join)\s+([\w."-]*)$/i.exec(e);if(r){const a=r[1].replace(/^"/,""),i=await ee("relation",a);return te(t.pos-r[1].length,i)}const n=/([A-Za-z_][\w]*)\.([A-Za-z_][\w]*)?$/.exec(e);if(n){const a=n[1],i=n[2]??"",o=Zt(e,a)??a,l=await ee("column",i,o.replace(/^"|"$/g,""));return te(t.pos-i.length,l)}const s=t.matchBefore(/[A-Za-z_][\w]*$/);if(t.explicit&&s){const a=await ee("column",s.text);return te(s.from,a)}return null};function te(t,e){return{from:t,options:e.map(r=>({label:r.label||r.name,apply:r.apply??r.name,detail:[r.detail,r.relation,r.governance].filter(Boolean).join(" · "),info:r.description,type:r.type==="column"?"property":r.type==="dataset"?"class":"variable",boost:r.governance==="semantic"||r.governance==="project_controlled"?20:0})),validFor:/^[\w."-]*$/}}function Zt(t,e){var n;return(n=new RegExp(`\\b(?:from|join)\\s+([\\w."-]+)(?:\\s+(?:as\\s+)?${Vt(e)})\\b`,"i").exec(t))==null?void 0:n[1]}function Vt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xe(t,e){const r=t?he({schema:t,upperCaseKeywords:!1}):he({upperCaseKeywords:!1}),n=[r,r.language.data.of({autocomplete:Be}),r.language.data.of({autocomplete:Ut})];return e&&n.push(r.language.data.of({autocomplete:Gt})),n}function Ht(t){const e=t.match(/LINE\s+(\d+)/i);if(e){const s=parseInt(e[1],10),a=t.match(/\n(\s*)\^/),i=a?a[1].length+1:1;return{line:s,col:i}}const r=t.match(/at line\s+(\d+),?\s*column\s+(\d+)/i);if(r)return{line:parseInt(r[1],10),col:parseInt(r[2],10)};const n=t.match(/line\s+(\d+)/i);return n?{line:parseInt(n[1],10),col:1}:null}const O=Z.define(),Yt=ve.define({create(){return R.none},update(t,e){for(const r of e.effects)if(r.is(O)){if(!r.value)return R.none;const{from:n,to:s,message:a}=r.value;return R.set([R.mark({class:"cm-sql-error",attributes:{title:a}}).range(n,s)])}return t},provide:t=>g.decorations.from(t)}),Jt=St.define([{tag:u.keyword,color:"var(--sql-keyword)",fontWeight:"600"},{tag:[u.controlKeyword,u.moduleKeyword],color:"var(--sql-keyword)",fontWeight:"600"},{tag:[u.string,u.special(u.string)],color:"var(--sql-string)"},{tag:u.number,color:"var(--sql-number)"},{tag:u.bool,color:"var(--sql-number)",fontWeight:"600"},{tag:u.null,color:"var(--sql-number)",fontWeight:"600"},{tag:[u.comment,u.lineComment,u.blockComment,u.docComment],color:"var(--sql-comment)",fontStyle:"italic"},{tag:[u.function(u.variableName),u.function(u.propertyName)],color:"var(--sql-function)"},{tag:[u.typeName,u.className],color:"var(--sql-type)"},{tag:u.operator,color:"var(--sql-punctuation)"},{tag:u.punctuation,color:"var(--sql-punctuation)"},{tag:u.bracket,color:"var(--sql-punctuation)"},{tag:[u.variableName,u.name,u.propertyName,u.attributeName],color:"var(--sql-ident)"},{tag:u.invalid,color:"var(--color-status-error)"}]),Xt=g.baseTheme({".cm-sql-error":{textDecoration:"underline wavy var(--color-status-error)",textUnderlineOffset:"3px",background:"color-mix(in srgb, var(--color-status-error) 10%, transparent)"}});function Fe(t){return g.theme({"&":{background:"transparent",color:"var(--color-text-primary)"},".cm-content":{caretColor:"var(--color-text-primary)"},".cm-cursor":{borderLeftColor:"var(--color-text-primary)"},".cm-selectionBackground":{background:"color-mix(in srgb, var(--color-accent-blue) 30%, transparent)"},"&.cm-focused .cm-selectionBackground":{background:"color-mix(in srgb, var(--color-accent-blue) 30%, transparent)"},".cm-gutters":{background:"transparent",color:"var(--color-text-tertiary)",border:"none",borderRight:"1px solid var(--color-border-subtle)"},".cm-activeLineGutter":{background:"transparent"},".cm-activeLine":{background:"transparent"},"&.cm-focused .cm-activeLineGutter":{background:"var(--color-bg-hover)"},"&.cm-focused .cm-activeLine":{background:"var(--color-bg-hover)"},".cm-matchingBracket":{background:"color-mix(in srgb, var(--color-accent-blue) 18%, transparent)",outline:"1px solid var(--color-accent-blue)"},".cm-foldPlaceholder":{background:"var(--color-bg-tertiary)",border:"1px solid var(--color-border-subtle)",color:"var(--color-text-secondary)",borderRadius:3,padding:"0 4px"},".cm-tooltip":{background:"var(--color-bg-card)",border:"1px solid var(--color-border-primary)",color:"var(--color-text-primary)",borderRadius:6,boxShadow:"0 4px 12px color-mix(in srgb, var(--color-bg-primary) 40%, transparent)"},".cm-tooltip.cm-tooltip-autocomplete":{"& > ul > li":{padding:"3px 8px"},"& > ul > li[aria-selected]":{background:"color-mix(in srgb, var(--color-accent-blue) 20%, transparent)",color:"var(--color-accent-blue)"}},".cm-searchMatch":{background:"color-mix(in srgb, var(--color-status-warning) 25%, transparent)",outline:"1px solid var(--color-status-warning)"},".cm-searchMatch.cm-searchMatch-selected":{background:"color-mix(in srgb, var(--color-status-warning) 50%, transparent)"},".cm-panels":{background:"var(--color-bg-secondary)",borderTop:"1px solid var(--color-border-subtle)"},".cm-panel":{padding:"6px 8px"},".cm-panel input":{background:"var(--color-bg-sunken)",border:"1px solid var(--color-border-subtle)",color:"var(--color-text-primary)",borderRadius:4,padding:"2px 6px",fontSize:12},".cm-panel button":{background:"var(--color-bg-tertiary)",border:"1px solid var(--color-border-subtle)",color:"var(--color-text-primary)",borderRadius:4,padding:"2px 8px",cursor:"pointer",fontSize:12,marginLeft:4}},{dark:t})}const er=Fe(!0),tr=Fe(!1);function rr(t){return t==="midnight"||t==="obsidian"||t==="dark"}function nr({value:t,onChange:e,onRun:r,themeMode:n,autoFocus:s,schema:a,errorMessage:i,editorRef:o,wrap:l=!0,fillHeight:c=!1,dqlMode:m=!1}){const w=Pe[n],k=v.useRef(null),f=v.useRef(null),[j,A]=v.useState(!1),E=v.useRef(r),le=v.useRef(e),ce=v.useRef(new et);return E.current=r,le.current=e,v.useEffect(()=>{o&&(o.current={undo:()=>{f.current&&rt(f.current)},redo:()=>{f.current&&tt(f.current)},resetTo:h=>{const p=f.current;p&&p.dispatch({changes:{from:0,to:p.state.doc.length,insert:h}})}})}),v.useEffect(()=>{if(!k.current)return;const h=nt.of([{key:"Shift-Enter",run:()=>(E.current(),!0)},{key:"Ctrl-Enter",mac:"Cmd-Enter",run:()=>(E.current(),!0)},{key:"Ctrl-/",mac:"Cmd-/",run:st},at,...it,...ot,...lt,...Tt,...ct,...ut]),p=g.updateListener.of(I=>{I.docChanged&&le.current(I.state.doc.toString())}),x=g.domEventHandlers({focus:(I,Y)=>{Te(Y)},blur:(I,Y)=>{Ie(Y)}}),C=g.theme({"&":{background:"var(--color-bg-surface)",color:"var(--color-text-primary)",fontFamily:"var(--font-mono)",fontSize:"13px",minHeight:c?"100%":"80px",maxHeight:c?"none":"480px",...c?{height:"100%"}:{}},".cm-scroller":{overflow:"auto",fontFamily:"inherit",...c?{height:"100%"}:{}},".cm-content":{padding:"10px 0",minHeight:c?"100%":"80px",color:"var(--color-text-primary)"},"&.cm-focused":{outline:"none"},".cm-editor":{border:"none"},".cm-gutters":{minWidth:40},".cm-foldGutter":{cursor:"pointer"}}),B=xe(a,m),V=[h,p,x,C,ce.current.of(B),ht({closeOnBlur:!1}),dt(),ft(),pt(),mt(),gt(),xt(),bt(),yt(),...l?[g.lineWrapping]:[],Et({top:!0}),Yt,Xt,vt(Jt),rr(n)?er:tr],We=Se.create({doc:t,extensions:V}),H=new g({state:We,parent:k.current});return f.current=H,s&&H.focus(),()=>{H.destroy(),f.current=null}},[n]),v.useEffect(()=>{const h=f.current;h&&h.dispatch({effects:ce.current.reconfigure(xe(a,m))})},[a,m]),v.useEffect(()=>{const h=f.current;if(!h)return;const p=h.state.doc.toString();p!==t&&h.dispatch({changes:{from:0,to:p.length,insert:t}})},[t]),v.useEffect(()=>{const h=f.current;if(!h)return;if(!i){h.dispatch({effects:O.of(null)});return}const p=Ht(i),x=h.state.doc;if(p&&p.line>=1&&p.line<=x.lines){const C=x.line(p.line),B=C.from+Math.max(0,p.col-1),V=Math.max(B+1,C.to);h.dispatch({effects:O.of({from:Math.min(B,x.length),to:Math.min(V,x.length),message:i})})}else if(x.lines>=1){const C=x.line(1);h.dispatch({effects:O.of({from:C.from,to:Math.max(C.from+1,C.to),message:i})})}},[i]),d.jsx("div",{onDragOver:h=>{h.dataTransfer.types.includes(ue)&&(h.preventDefault(),A(!0))},onDragLeave:()=>A(!1),onDrop:h=>{const p=f.current;if(!p)return;const x=De(h.dataTransfer.getData(ue));x&&(h.preventDefault(),A(!1),_e(p,x.reference,{x:h.clientX,y:h.clientY}),je.trackUsage(x.name),window.dispatchEvent(new CustomEvent("dql:semantic-used",{detail:{name:x.name}})))},style:{background:"var(--color-bg-surface)",height:c?"100%":void 0,minHeight:c?0:80,border:j?`1px solid ${w.accent}`:"1px solid transparent",borderRadius:c?0:6,transition:"border-color 0.15s",overflow:"hidden"},children:d.jsx("div",{ref:k,style:{height:c?"100%":void 0,minHeight:c?0:80}})})}nr.displayName="SQLCellEditor";function sr({path:t,onNodeClick:e,focalNodeId:r,t:n}){return t.nodes.length===0?null:d.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,alignItems:"center"},children:t.nodes.map((s,a)=>d.jsxs(be.Fragment,{children:[d.jsx(ar,{node:s,isFocal:s.id===r,onClick:e?()=>e(s.id):void 0,t:n}),a<t.nodes.length-1&&d.jsx("span",{style:{color:n.textMuted,fontSize:10,lineHeight:1},children:"→"})]},s.id))})}function lr({title:t,paths:e,onNodeClick:r,focalNodeId:n,maxVisible:s=4,t:a}){const[i,o]=be.useState(!1),l=i?e:e.slice(0,s),c=e.length>s;return e.length===0?null:d.jsxs("div",{style:{border:`1px solid ${a.cellBorder}`,borderRadius:10,overflow:"hidden",background:a.inputBg},children:[d.jsxs("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${a.cellBorder}`,fontSize:11,fontWeight:700,color:a.textMuted,fontFamily:a.font,textTransform:"uppercase",letterSpacing:"0.04em",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[d.jsx("span",{children:t}),d.jsxs("span",{style:{fontWeight:400,fontSize:10},children:[e.length," path",e.length!==1?"s":""]})]}),d.jsxs("div",{style:{display:"grid",gap:8,padding:10},children:[l.map((m,w)=>d.jsx(sr,{path:m,onNodeClick:r,focalNodeId:n,t:a},`path-${w}`)),c&&!i&&d.jsxs("button",{onClick:()=>o(!0),style:{background:"none",border:"none",color:a.accent,cursor:"pointer",fontSize:11,fontFamily:a.font,padding:"2px 0",textAlign:"left"},children:["Show ",e.length-s," more path",e.length-s!==1?"s":"","..."]})]})]})}function ar({node:t,isFocal:e,onClick:r,t:n}){const s=ze[t.type]??"#8b949e",a=Oe[t.type]??t.type.slice(0,3).toUpperCase();return d.jsxs("button",{onClick:r,disabled:!r,style:{display:"inline-flex",alignItems:"center",gap:4,background:e?`${s}18`:n.pillBg??`${n.cellBg}`,border:`1px solid ${e?s:n.cellBorder}`,borderRadius:999,color:n.textPrimary,cursor:r?"pointer":"default",fontSize:10,fontFamily:n.font,padding:"3px 8px",transition:"border-color 0.15s",whiteSpace:"nowrap",maxWidth:180},title:`${t.type}: ${t.name}${t.domain?` (${t.domain})`:""}`,children:[d.jsx("span",{style:{fontSize:8,fontWeight:700,color:"#0d1117",background:s,borderRadius:3,padding:"1px 3px",flexShrink:0},children:a}),d.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name})]})}function cr({layerSummary:t,t:e}){const r=["source","transform","answer","consumption"];if(Object.values(t).reduce((i,o)=>i+o,0)===0)return null;const s={source:"#79c0ff",transform:"#ff7b72",answer:"#56d364",consumption:"#d2a8ff"},a={source:"Sources",transform:"Transform",answer:"Answer",consumption:"Consumption"};return d.jsx("div",{style:{display:"flex",gap:10,fontSize:10,color:e.textMuted,fontFamily:e.font},children:r.map(i=>{const o=t[i]??0;return o===0?null:d.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3},children:[d.jsx("span",{style:{width:8,height:8,borderRadius:2,background:s[i],display:"inline-block"}}),a[i],": ",o]},i)})})}export{sr as L,nr as S,cr as a,lr as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as z,t as D,r as i,a as v,j as t}from"./index-Ca3UeUWI.js";import"./react-CRB3T2We.js";function F(a,s,l,e){var u;const n=l.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),p=`${n?`${n}/`:""}${e}.dql`;if(!s)return`blocks/${p}`;const r=a.find(k=>k.id===s),d=(u=r==null?void 0:r.sourcePath)==null?void 0:u.replace(/\/domain\.dql$/,"");return d?`${d}/blocks/${p}`:`blocks/${s}/${p}`}function E(a){return a.toLowerCase().replace(/[^a-z0-9\-_\s]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").slice(0,64)}function O(a){return a.trim()?/^[a-zA-Z0-9\-_ ]+$/.test(a)?null:"Only letters, numbers, hyphens, underscores, and spaces allowed.":"Name is required."}function W({onFileOpened:a}){const{state:s,dispatch:l}=z(),e=D[s.themeMode],[n,p]=i.useState(""),[r,d]=i.useState(s.newBlockModalDefaultType),[u,k]=i.useState([]),[y,L]=i.useState(""),[g,$]=i.useState(""),[m,f]=i.useState(null),[b,S]=i.useState(!1),B=i.useRef(null);i.useEffect(()=>{var c;(c=B.current)==null||c.focus();let o=!0;return v.getDomains().then(h=>{o&&k(h.domains)}),()=>{o=!1}},[]),i.useEffect(()=>{d(s.newBlockModalDefaultType)},[s.newBlockModalDefaultType]),i.useEffect(()=>{const o=c=>{c.key==="Escape"&&l({type:"CLOSE_NEW_BLOCK_MODAL"})};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[l]);const j=async()=>{var h;const o=O(n);if(o){f(o);return}S(!0),f(null);const c=E(n);try{const x=await v.createBlock(n.trim(),{blockType:r,...y?{domain:y}:{},...g.trim()?{folderPath:g.trim()}:{}}),C={name:`${c}.dql`,path:x.path,type:"block",folder:x.path.split("/").slice(0,-1).join("/"),isNew:!0};l({type:"FILE_ADDED",file:C}),l({type:"CLOSE_NEW_BLOCK_MODAL"}),a(C)}catch(x){(h=x.message)!=null&&h.includes("already exists")?f("A block with this name already exists."):f(x.message??"Failed to create block.")}finally{S(!1)}},w=o=>{o.target===o.currentTarget&&l({type:"CLOSE_NEW_BLOCK_MODAL"})};return t.jsx("div",{onClick:w,style:{position:"fixed",inset:0,background:e.modalOverlay,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,backdropFilter:"blur(4px)"},children:t.jsxs("div",{style:{background:e.modalBg,border:`1px solid ${e.cellBorder}`,borderRadius:12,width:420,maxWidth:"calc(100vw - 48px)",boxShadow:"0 20px 60px rgba(0,0,0,0.5)",overflow:"hidden"},children:[t.jsxs("div",{style:{padding:"20px 24px 0",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("h2",{style:{fontSize:16,fontWeight:600,color:e.textPrimary,fontFamily:e.font,margin:0},children:"New Block"}),t.jsx("button",{onClick:()=>l({type:"CLOSE_NEW_BLOCK_MODAL"}),style:{background:"transparent",border:"none",cursor:"pointer",color:e.textMuted,fontSize:18,lineHeight:1,padding:"2px 4px",borderRadius:4},children:"×"})]}),t.jsxs("div",{style:{padding:"20px 24px 24px",display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[t.jsxs("button",{type:"button",onClick:()=>d("custom"),style:{background:r==="custom"?`${e.accent}18`:e.btnBg,border:`1px solid ${r==="custom"?e.accent:e.btnBorder}`,borderRadius:8,color:r==="custom"?e.accent:e.textSecondary,cursor:"pointer",fontSize:12,fontWeight:700,fontFamily:e.font,padding:"10px 12px",textAlign:"left"},children:["SQL Block",t.jsx("span",{style:{display:"block",marginTop:3,color:e.textMuted,fontWeight:400,fontSize:11},children:"Build from dbt models, tables, and SELECT queries."})]}),t.jsxs("button",{type:"button",onClick:()=>d("semantic"),style:{background:r==="semantic"?`${e.accent}18`:e.btnBg,border:`1px solid ${r==="semantic"?e.accent:e.btnBorder}`,borderRadius:8,color:r==="semantic"?e.accent:e.textSecondary,cursor:"pointer",fontSize:12,fontWeight:700,fontFamily:e.font,padding:"10px 12px",textAlign:"left"},children:["Semantic Block",t.jsx("span",{style:{display:"block",marginTop:3,color:e.textMuted,fontWeight:400,fontSize:11},children:"Build from dbt/DQL metrics and dimensions."})]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:12,fontWeight:500,color:e.textSecondary,fontFamily:e.font},children:"Block Name"}),t.jsx("input",{ref:B,value:n,onChange:o=>{p(o.target.value),f(null)},onKeyDown:o=>{o.key==="Enter"&&j()},placeholder:"revenue-summary",style:{background:e.inputBg,border:`1px solid ${m?e.error:e.inputBorder}`,borderRadius:6,color:e.textPrimary,fontSize:13,fontFamily:e.font,padding:"8px 12px",outline:"none",transition:"border-color 0.15s"}}),m&&t.jsx("span",{style:{fontSize:11,color:e.error,fontFamily:e.font},children:m}),n&&!m&&t.jsxs("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.fontMono},children:["Git path: ",F(u,y,g,E(n))]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[t.jsxs("label",{style:{display:"grid",gap:6,fontSize:12,fontWeight:500,color:e.textSecondary,fontFamily:e.font},children:["Domain",t.jsxs("select",{"aria-label":"Block domain",value:y,onChange:o=>L(o.target.value),style:{background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:6,color:e.textPrimary,fontSize:13,fontFamily:e.font,padding:"8px 10px",outline:"none"},children:[t.jsx("option",{value:"",children:"Global / cross-domain"}),u.map(o=>t.jsx("option",{value:o.id,children:o.id},o.id))]})]}),t.jsxs("label",{style:{display:"grid",gap:6,fontSize:12,fontWeight:500,color:e.textSecondary,fontFamily:e.font},children:["Folder",t.jsx("input",{"aria-label":"Block folder",value:g,onChange:o=>$(o.target.value),placeholder:"reporting/monthly",style:{background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:6,color:e.textPrimary,fontSize:13,fontFamily:e.fontMono,padding:"8px 10px",outline:"none"}})]})]}),t.jsx("div",{style:{fontSize:12,color:e.textMuted,fontFamily:e.font,lineHeight:1.5,padding:"8px 12px",background:e.pillBg,borderRadius:6},children:r==="semantic"?"Semantic blocks use governed metrics, dimensions, and chart intent. They do not start with raw SQL.":"SQL blocks are reusable SELECT queries stored in the blocks/ folder. Use them for dbt models, tables, and imported SQL."})]}),t.jsxs("div",{style:{padding:"14px 24px",borderTop:`1px solid ${e.cellBorder}`,display:"flex",justifyContent:"flex-end",gap:10},children:[t.jsx("button",{onClick:()=>l({type:"CLOSE_NEW_BLOCK_MODAL"}),style:{background:e.btnBg,border:`1px solid ${e.btnBorder}`,borderRadius:6,color:e.textSecondary,cursor:"pointer",fontSize:13,fontFamily:e.font,fontWeight:500,padding:"7px 16px"},children:"Cancel"}),t.jsx("button",{onClick:j,disabled:b||!n.trim(),style:{background:e.accent,border:`1px solid ${e.accent}`,borderRadius:6,color:"#ffffff",cursor:b||!n.trim()?"not-allowed":"pointer",fontSize:13,fontFamily:e.font,fontWeight:500,padding:"7px 20px",opacity:b||!n.trim()?.6:1,display:"flex",alignItems:"center",gap:6},children:b?"Creating...":"Create Block"})]})]})})}export{W as NewBlockModal};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import{g as E,m as o,u as N,t as B,r as l,a as j,j as t,h as T}from"./index-Ca3UeUWI.js";import{B as w}from"./book-open-text-BnnirfAc.js";import{X as q}from"./x-9Gtb3EAd.js";import"./react-CRB3T2We.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 z=[["path",{d:"M12 16v5",key:"zza2cw"}],["path",{d:"M16 14v7",key:"1g90b9"}],["path",{d:"M20 10v11",key:"1iqoj0"}],["path",{d:"m22 3-8.646 8.646a.5.5 0 0 1-.708 0L9.354 8.354a.5.5 0 0 0-.707 0L2 15",key:"1fw8x9"}],["path",{d:"M4 18v3",key:"1yp0dc"}],["path",{d:"M8 14v7",key:"n3cwzv"}]],R=E("chart-no-axes-combined",z);/**
|
|
7
|
-
* @license lucide-react v0.563.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const A=[["path",{d:"M15.6 2.7a10 10 0 1 0 5.7 5.7",key:"1e0p6d"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M13.4 10.6 19 5",key:"1kr7tw"}]],I=E("circle-gauge",A);/**
|
|
12
|
-
* @license lucide-react v0.563.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const F=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],W=E("flask-conical",F),C={blank:"Start empty",analysis:"Explore a question",metric_diagnostic:"Investigate a metric",data_quality:"Check data quality",experiment:"Review an experiment"},$={blank:"Add Ask, DQL, SQL, or notes only when you need them.",analysis:"Move from a business question to evidence, findings, and a decision.",metric_diagnostic:"Trend a metric, break down its drivers, and record the diagnosis.",data_quality:"Profile a source, run checks, and document ownership and remediation.",experiment:"Capture the hypothesis, metrics, results, guardrails, and decision."},P={blank:"Empty canvas · 0 starter cells",analysis:"1 DQL query · 4 note sections",metric_diagnostic:"2 DQL queries · 2 note sections",data_quality:"2 DQL queries · 2 note sections",experiment:"1 DQL query · 3 note sections"};function K(r){switch(r){case"analysis":return[o("markdown",`# TL;DR
|
|
17
|
-
|
|
18
|
-
Summarize the answer and decision here.`),o("markdown",`## Context and methods
|
|
19
|
-
|
|
20
|
-
State the business question, scope, definitions, and assumptions.`),{...o("dql"),name:"analysis_data"},o("markdown",`## Results
|
|
21
|
-
|
|
22
|
-
Explain the material findings and uncertainty.`),o("markdown",`## Takeaways
|
|
23
|
-
|
|
24
|
-
Record the decision, risks, and next action.`)];case"metric_diagnostic":return[o("markdown",`# Metric diagnostic
|
|
25
|
-
|
|
26
|
-
**Question:** What changed, when, and for whom?
|
|
27
|
-
|
|
28
|
-
**Metric definition:** Add the certified definition and expected behavior.`),{...o("dql"),name:"metric_trend"},{...o("dql"),name:"driver_breakdown",dependencies:[]},o("markdown",`## Diagnosis
|
|
29
|
-
|
|
30
|
-
Separate validated drivers from hypotheses and data limitations.`)];case"data_quality":return[o("markdown",`# Data-quality investigation
|
|
31
|
-
|
|
32
|
-
Document the source, owner, freshness expectation, and affected decisions.`),{...o("dql"),name:"quality_profile"},{...o("dql"),name:"quality_checks"},o("markdown",`## Findings and disposition
|
|
33
|
-
|
|
34
|
-
Record severity, impacted metrics, owner, and remediation.`)];case"experiment":return[o("markdown",`# Experiment log
|
|
35
|
-
|
|
36
|
-
**Hypothesis:**
|
|
37
|
-
|
|
38
|
-
**Primary metric:**
|
|
39
|
-
|
|
40
|
-
**Guardrails:**
|
|
41
|
-
|
|
42
|
-
**Population and dates:**`),{...o("dql"),name:"experiment_results"},o("markdown",`## Results
|
|
43
|
-
|
|
44
|
-
Report effect size, uncertainty, guardrails, and data-quality checks.`),o("markdown",`## Decision
|
|
45
|
-
|
|
46
|
-
Ship, iterate, or stop — with rationale.`)];default:return[]}}const H={blank:w,analysis:R,metric_diagnostic:I,data_quality:T,experiment:W};function L(r){return r.toLowerCase().replace(/[^a-z0-9\-_\s]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").slice(0,64)}function Q(r){return r.trim()?/^[a-zA-Z0-9\-_ ]+$/.test(r)?null:"Only letters, numbers, hyphens, underscores, and spaces allowed.":"Name is required."}function Z({onFileOpened:r}){const{state:d,dispatch:a}=N(),e=B[d.themeMode],[s,m]=l.useState(""),[u,i]=l.useState("blank"),[h,y]=l.useState([]),[x,M]=l.useState(""),[f,k]=l.useState(null),[g,_]=l.useState(!1),S=l.useRef(null);l.useEffect(()=>{var c;(c=S.current)==null||c.focus();let n=!0;return j.getDomains().then(b=>{n&&y(b.domains)}),()=>{n=!1}},[]),l.useEffect(()=>{const n=c=>{c.key==="Escape"&&a({type:"CLOSE_NEW_NOTEBOOK_MODAL"})};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[a]);const O=async()=>{const n=Q(s);if(n){k(n);return}_(!0),k(null);const c=L(s),b=K(u);try{const v=await j.createNotebook(c,u,{...x?{ownerDomain:x,usesDomains:[x]}:{}}),p={name:`${c}.dqlnb`,path:v.path,type:"notebook",folder:"notebooks",isNew:!0};a({type:"FILE_ADDED",file:p}),a({type:"OPEN_FILE",file:p,cells:b,title:s.trim()}),a({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),r(p)}catch{const v=`notebooks/${c}.dqlnb`,p={name:`${c}.dqlnb`,path:v,type:"notebook",folder:"notebooks",isNew:!0};a({type:"FILE_ADDED",file:p}),a({type:"OPEN_FILE",file:p,cells:b,title:s.trim()}),a({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),r(p)}finally{_(!1)}},D=n=>{n.target===n.currentTarget&&a({type:"CLOSE_NEW_NOTEBOOK_MODAL"})};return t.jsx("div",{onClick:D,role:"presentation",style:{position:"fixed",inset:0,background:e.modalOverlay,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,backdropFilter:"blur(4px)"},children:t.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"new-notebook-title",style:{background:e.modalBg,border:`1px solid ${e.cellBorder}`,borderRadius:14,width:700,maxWidth:"calc(100vw - 48px)",maxHeight:"min(760px, calc(100vh - 48px))",boxShadow:"0 24px 72px rgba(0,0,0,0.38)",overflow:"hidden",display:"flex",flexDirection:"column"},children:[t.jsxs("div",{style:{padding:"14px 18px",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:16,borderBottom:`1px solid ${e.cellBorder}`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[t.jsx("span",{style:{width:30,height:30,borderRadius:8,display:"inline-grid",placeItems:"center",color:e.accent,background:"var(--accent-dim)",flexShrink:0},children:t.jsx(w,{size:16,strokeWidth:2,"aria-hidden":"true"})}),t.jsxs("div",{children:[t.jsx("h2",{id:"new-notebook-title",style:{fontSize:17,fontWeight:750,color:e.textPrimary,fontFamily:e.font,margin:0},children:"Create notebook"}),t.jsx("p",{style:{margin:"3px 0 0",color:e.textMuted,fontSize:11.5,lineHeight:1.35,fontFamily:e.font},children:"Choose how much starter structure you want. Every option creates the same editable, Git-tracked notebook."})]})]}),t.jsx("button",{type:"button","aria-label":"Close create notebook",onClick:()=>a({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),style:{width:28,height:28,display:"inline-grid",placeItems:"center",background:e.btnBg,border:`1px solid ${e.btnBorder}`,cursor:"pointer",color:e.textMuted,padding:0,borderRadius:7,flexShrink:0},children:t.jsx(q,{size:14,"aria-hidden":"true"})})]}),t.jsxs("div",{style:{padding:"14px 18px",display:"flex",flexDirection:"column",gap:13,overflowY:"auto"},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(210px, 0.72fr)",gap:12},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5,minWidth:0},children:[t.jsx("label",{htmlFor:"new-notebook-name",style:{fontSize:12,fontWeight:500,color:e.textSecondary,fontFamily:e.font},children:"Notebook name"}),t.jsx("input",{id:"new-notebook-name",ref:S,value:s,onChange:n=>{m(n.target.value),k(null)},onKeyDown:n=>{n.key==="Enter"&&O()},placeholder:"e.g. Customer retention analysis",style:{background:e.inputBg,border:`1px solid ${f?e.error:e.inputBorder}`,borderRadius:6,color:e.textPrimary,fontSize:13,fontFamily:e.font,padding:"8px 12px",outline:"none",transition:"border-color 0.15s"}}),f&&t.jsx("span",{style:{fontSize:11,color:e.error,fontFamily:e.font},children:f}),s&&!f&&t.jsxs("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.fontMono},children:["Git path: notebooks/",L(s),".dqlnb"]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5,minWidth:0},children:[t.jsx("label",{style:{fontSize:12,fontWeight:500,color:e.textSecondary,fontFamily:e.font},children:"Domain context"}),t.jsxs("select",{"aria-label":"Notebook owner domain",value:x,onChange:n=>M(n.target.value),style:{background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:6,color:e.textPrimary,fontSize:13,fontFamily:e.font,padding:"8px 12px",outline:"none"},children:[t.jsx("option",{value:"",children:"Global / cross-domain"}),h.map(n=>t.jsx("option",{value:n.id,children:n.id},n.id))]}),t.jsx("span",{style:{fontSize:10.5,lineHeight:1.3,color:e.textMuted,fontFamily:e.font},children:"Optional. Adds a Domain Studio backlink without moving the Git file."})]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:7},children:[t.jsx("label",{style:{fontSize:12,fontWeight:500,color:e.textSecondary,fontFamily:e.font},children:"Starting point"}),t.jsx("div",{style:{padding:"6px 9px",borderRadius:8,border:`1px solid ${e.cellBorder}`,background:e.cellBg,color:e.textMuted,fontSize:10.5,lineHeight:1.35,fontFamily:e.font},children:"Templates only add starter cells. They do not change execution, permissions, governance, or where the notebook is saved."}),t.jsx("div",{role:"radiogroup","aria-label":"Notebook starting point",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:8},children:Object.keys(C).map(n=>t.jsx(G,{value:n,selected:u===n,onSelect:()=>i(n),label:C[n],description:$[n],cellSummary:P[n],Icon:H[n],t:e},n))})]})]}),t.jsxs("div",{style:{padding:"10px 18px",borderTop:`1px solid ${e.cellBorder}`,display:"flex",justifyContent:"flex-end",gap:10,background:e.cellBg},children:[t.jsx("button",{onClick:()=>a({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),style:{background:e.btnBg,border:`1px solid ${e.btnBorder}`,borderRadius:8,color:e.textSecondary,cursor:"pointer",fontSize:13,fontFamily:e.font,fontWeight:500,padding:"8px 15px"},children:"Cancel"}),t.jsxs("button",{onClick:O,disabled:g||!s.trim(),style:{background:e.accent,border:`1px solid ${e.accent}`,borderRadius:8,color:"var(--accent-fg)",cursor:g||!s.trim()?"not-allowed":"pointer",fontSize:13,fontFamily:e.font,fontWeight:500,padding:"8px 16px",opacity:g||!s.trim()?.6:1,display:"flex",alignItems:"center",gap:6},children:[t.jsx(w,{size:14,"aria-hidden":"true"}),g?"Creating…":"Create notebook"]})]})]})})}function G({value:r,selected:d,onSelect:a,label:e,description:s,cellSummary:m,Icon:u,t:i}){const[h,y]=l.useState(!1);return t.jsxs("button",{type:"button",role:"radio","aria-checked":d,"aria-label":`${e}. ${m}`,onClick:a,onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),style:{position:"relative",display:"grid",gridTemplateColumns:"30px minmax(0, 1fr)",gridColumn:r==="blank"?"1 / -1":void 0,alignItems:"start",gap:9,minHeight:r==="blank"?60:88,padding:"10px",borderRadius:10,border:`1px solid ${d?i.accent:h?i.textMuted:i.inputBorder}`,background:d?"var(--accent-dim)":h?i.sidebarItemHover:i.cellBg,color:i.textPrimary,cursor:"pointer",transition:"all 0.15s",textAlign:"left",fontFamily:i.font},children:[t.jsx("span",{style:{width:30,height:30,borderRadius:8,display:"inline-grid",placeItems:"center",color:d?i.accent:i.textSecondary,background:d?i.cellBg:i.btnBg,border:`1px solid ${d?`${i.accent}40`:i.btnBorder}`},children:t.jsx(u,{size:16,strokeWidth:2,"aria-hidden":"true"})}),t.jsxs("span",{style:{minWidth:0,display:"grid",gap:4},children:[t.jsx("span",{style:{fontSize:12.5,fontWeight:750,color:i.textPrimary},children:e}),t.jsx("span",{style:{fontSize:11,color:i.textSecondary,lineHeight:1.3},children:s}),t.jsx("span",{style:{marginTop:1,fontSize:10,color:d?i.accent:i.textMuted,fontWeight:650},children:m})]}),t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",right:10,top:10,width:14,height:14,borderRadius:999,border:`1.5px solid ${d?i.accent:i.textMuted}`,display:"inline-grid",placeItems:"center"},children:d?t.jsx("span",{style:{width:7,height:7,borderRadius:999,background:i.accent}}):null})]})}export{Z as NewNotebookModal};
|