@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.
Files changed (101) hide show
  1. package/dist/apps-api.d.ts +151 -3
  2. package/dist/apps-api.d.ts.map +1 -1
  3. package/dist/apps-api.js +675 -97
  4. package/dist/apps-api.js.map +1 -1
  5. package/dist/assets/dql-notebook/assets/AgentAnswerCard-Cp0eh6zU.js +5 -0
  6. package/dist/assets/dql-notebook/assets/{AgentLogPage-uvVs284-.js → AgentLogPage-CBGEoGmU.js} +1 -1
  7. package/dist/assets/dql-notebook/assets/{AiBuildDialog-DEUS19WF.js → AiBuildDialog-CwAD3tXE.js} +1 -1
  8. package/dist/assets/dql-notebook/assets/AiBuildResult-CyqTuQe5.js +33 -0
  9. package/dist/assets/dql-notebook/assets/AiSidePanel-DjB8PWHG.js +6 -0
  10. package/dist/assets/dql-notebook/assets/AnalyticsHome-B7BkvA-R.js +6 -0
  11. package/dist/assets/dql-notebook/assets/AppsView-CUrqtEGC.js +4583 -0
  12. package/dist/assets/dql-notebook/assets/BlockStudio-Bl0aGQJR.js +60 -0
  13. package/dist/assets/dql-notebook/assets/{BusinessArtifactView-D8FIgrkF.js → BusinessArtifactView-C4SZVNW-.js} +1 -1
  14. package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-B0uxitnx.js +22 -0
  15. package/dist/assets/dql-notebook/assets/GitPage-BfVD4tVq.js +7 -0
  16. package/dist/assets/dql-notebook/assets/GlobalAiRail-DUwdy3fB.js +1 -0
  17. package/dist/assets/dql-notebook/assets/GovernedContextPage-D9f26ZFb.js +7 -0
  18. package/dist/assets/dql-notebook/assets/{HelpDocsPage-Bc5pLakt.js → HelpDocsPage-BDPNVot1.js} +3 -3
  19. package/dist/assets/dql-notebook/assets/{HomePage-DQSo-K4y.js → HomePage-DiOnRhEG.js} +9 -4
  20. package/dist/assets/dql-notebook/assets/LineageDAG-BiUFX2KL.js +1 -0
  21. package/dist/assets/dql-notebook/assets/{LineageDetailView-CZEx2r1H.js → LineageDetailView-CfbSvlPJ.js} +1 -1
  22. package/dist/assets/dql-notebook/assets/{LineageDrawer-P7ZdOW8-.js → LineageDrawer-CgTScaGB.js} +1 -1
  23. package/dist/assets/dql-notebook/assets/LineagePathBreadcrumb-D7ZA7k68.js +14 -0
  24. package/dist/assets/dql-notebook/assets/{MiniLineageGraph-Ctp_yFh8.js → MiniLineageGraph-GkD4y17x.js} +1 -1
  25. package/dist/assets/dql-notebook/assets/NewBlockModal-B9TfRjt7.js +1 -0
  26. package/dist/assets/dql-notebook/assets/NewNotebookModal-BbO9NKUl.js +46 -0
  27. package/dist/assets/dql-notebook/assets/NotebookEditor-CuMpvXR9.js +200 -0
  28. package/dist/assets/dql-notebook/assets/ReadinessPage-BROJ9YBM.js +1 -0
  29. package/dist/assets/dql-notebook/assets/{SetupOnboarding-DX2f53J2.js → SetupOnboarding-BCcZlpuQ.js} +2 -2
  30. package/dist/assets/dql-notebook/assets/{TrustBadge-DPnKzRSY.js → TrustBadge-vQQh8d0D.js} +1 -1
  31. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-Dj4AXAhT.js +83 -0
  32. package/dist/assets/dql-notebook/assets/{answer-to-notebook-Bm9oByWA.js → answer-to-notebook-DuqCcDDl.js} +1 -1
  33. package/dist/assets/dql-notebook/assets/{arrow-left-D2FbLWqh.js → arrow-left-CMe1kkOL.js} +1 -1
  34. package/dist/assets/dql-notebook/assets/{arrow-right-OYItAZ-s.js → arrow-right-DvB_DONr.js} +2 -2
  35. package/dist/assets/dql-notebook/assets/{book-open-text-BnnirfAc.js → book-open-text-CJ3NAvrs.js} +1 -1
  36. package/dist/assets/dql-notebook/assets/{bot-BJNxPYFm.js → bot-CV8DYRrt.js} +1 -1
  37. package/dist/assets/dql-notebook/assets/{chevron-up-DM5LX-26.js → chevron-up-HxU1l85K.js} +2 -2
  38. package/dist/assets/dql-notebook/assets/{circle-x-Dic_-4tF.js → circle-x-BCgtha1W.js} +1 -1
  39. package/dist/assets/dql-notebook/assets/{codemirror-1_I9gm6Z.js → codemirror-DXt7RW72.js} +1 -1
  40. package/dist/assets/dql-notebook/assets/{dagre.esm-C9zxjHHX.js → dagre.esm-GKp7qoUL.js} +1 -1
  41. package/dist/assets/dql-notebook/assets/{external-link-DHxAcoCE.js → external-link-C-PXokWV.js} +1 -1
  42. package/dist/assets/dql-notebook/assets/{grip-vertical-02I-EOjL.js → grip-vertical-B4EHbGXW.js} +1 -1
  43. package/dist/assets/dql-notebook/assets/index-1mIC_XX4.js +634 -0
  44. package/dist/assets/dql-notebook/assets/{link-2-Delh-lai.js → link-2-BLx-goet.js} +2 -2
  45. package/dist/assets/dql-notebook/assets/{list-tree-BrIZg6l6.js → list-tree-BRFpEmvV.js} +1 -1
  46. package/dist/assets/dql-notebook/assets/{maximize-2-CQOA-bbN.js → maximize-2-CCd5uRIZ.js} +1 -1
  47. package/dist/assets/dql-notebook/assets/{minimize-2-CUDBPkwe.js → minimize-2-CDwSCGlO.js} +1 -1
  48. package/dist/assets/dql-notebook/assets/{panel-right-open-CwhZfkKJ.js → panel-right-open-CunA1xO7.js} +2 -2
  49. package/dist/assets/dql-notebook/assets/{pencil-Cf6-MgpT.js → pencil-D_I14Wyk.js} +2 -2
  50. package/dist/assets/dql-notebook/assets/{rotate-ccw-DndbJAiz.js → rotate-ccw-DOrfTZk8.js} +2 -2
  51. package/dist/assets/dql-notebook/assets/{semantic-fields-DwKPY_mU.js → semantic-fields-AfQvjt5R.js} +1 -1
  52. package/dist/assets/dql-notebook/assets/{star-DvcMC9wZ.js → star-DDhv4e8M.js} +2 -2
  53. package/dist/assets/dql-notebook/assets/{triangle-alert-DUf4Ook0.js → triangle-alert-2ZXx8wAu.js} +1 -1
  54. package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-3rzkZrqc.js +18 -0
  55. package/dist/assets/dql-notebook/assets/{user-round-DSt0xU3K.js → user-round-BA074kiQ.js} +3 -3
  56. package/dist/assets/dql-notebook/assets/{wand-sparkles-ro8Cq0ro.js → wand-sparkles-CEYHLt9b.js} +1 -1
  57. package/dist/assets/dql-notebook/assets/{workflow-DVJXehjU.js → workflow-CZtyrcR-.js} +2 -2
  58. package/dist/assets/dql-notebook/assets/{wrench-DxUnoHtz.js → wrench-Ong23-wu.js} +1 -1
  59. package/dist/assets/dql-notebook/assets/{x-9Gtb3EAd.js → x-CSo1M3tu.js} +2 -2
  60. package/dist/assets/dql-notebook/index.html +1 -1
  61. package/dist/llm/providers/dql-agent-provider.d.ts +4 -3
  62. package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
  63. package/dist/llm/providers/dql-agent-provider.js +13 -10
  64. package/dist/llm/providers/dql-agent-provider.js.map +1 -1
  65. package/dist/local-operation-coordinator.d.ts +59 -0
  66. package/dist/local-operation-coordinator.d.ts.map +1 -0
  67. package/dist/local-operation-coordinator.js +256 -0
  68. package/dist/local-operation-coordinator.js.map +1 -0
  69. package/dist/local-runtime.d.ts +89 -2
  70. package/dist/local-runtime.d.ts.map +1 -1
  71. package/dist/local-runtime.js +2158 -461
  72. package/dist/local-runtime.js.map +1 -1
  73. package/dist/package.json +12 -11
  74. package/dist/project-refresh-coordinator.d.ts +19 -0
  75. package/dist/project-refresh-coordinator.d.ts.map +1 -0
  76. package/dist/project-refresh-coordinator.js +134 -0
  77. package/dist/project-refresh-coordinator.js.map +1 -0
  78. package/dist/project-refresh-worker.d.ts +13 -0
  79. package/dist/project-refresh-worker.d.ts.map +1 -0
  80. package/dist/project-refresh-worker.js +58 -0
  81. package/dist/project-refresh-worker.js.map +1 -0
  82. package/package.json +13 -11
  83. package/dist/assets/dql-notebook/assets/AgentAnswerCard-Dp4odOLE.js +0 -5
  84. package/dist/assets/dql-notebook/assets/AiBuildResult-B9KmBRsh.js +0 -33
  85. package/dist/assets/dql-notebook/assets/AiSidePanel-C7BZVSkM.js +0 -6
  86. package/dist/assets/dql-notebook/assets/AnalyticsHome-4TgtH6SB.js +0 -6
  87. package/dist/assets/dql-notebook/assets/AppsView-CnfNtk5W.js +0 -4466
  88. package/dist/assets/dql-notebook/assets/BlockStudio-DUXN3MKz.js +0 -60
  89. package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-DR8hTZ95.js +0 -22
  90. package/dist/assets/dql-notebook/assets/GitPage-BS2sm9zh.js +0 -7
  91. package/dist/assets/dql-notebook/assets/GlobalAiRail-B_MZsB0z.js +0 -1
  92. package/dist/assets/dql-notebook/assets/GovernedContextPage-CNM5UCAH.js +0 -7
  93. package/dist/assets/dql-notebook/assets/LineageDAG-RdpWmGmR.js +0 -1
  94. package/dist/assets/dql-notebook/assets/LineagePathBreadcrumb-DTUMFkJ8.js +0 -14
  95. package/dist/assets/dql-notebook/assets/NewBlockModal-BLtjuWGy.js +0 -1
  96. package/dist/assets/dql-notebook/assets/NewNotebookModal-xgaKB2kI.js +0 -46
  97. package/dist/assets/dql-notebook/assets/NotebookEditor-D6RgLQw-.js +0 -202
  98. package/dist/assets/dql-notebook/assets/ReadinessPage-C8hATaT_.js +0 -1
  99. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-CwxQ4T19.js +0 -83
  100. package/dist/assets/dql-notebook/assets/index-Ca3UeUWI.js +0 -644
  101. package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-DbdBi0oH.js +0 -18
@@ -1,22 +0,0 @@
1
- import{g as Yt,r as a,j as e,P as ke,u as Qt,t as Po,a as le,a0 as Fe,av as No,Y as Ao,aB as Oo,B as Zt,G as so,N as io,h as lo,aC as Eo,aD as To,S as ro,ai as $t,aE as qo}from"./index-Ca3UeUWI.js";import{S as Lo,K as _o}from"./GovernedContextPage-CNM5UCAH.js";import{u as Fo,i as Wo,B as Ho,C as Uo,b as Ko,M as Vo,T as Wn,N as Jo,H as it,c as lt,d as Go}from"./dagre.esm-C9zxjHHX.js";import{L as Ge}from"./link-2-Delh-lai.js";import{M as ao}from"./maximize-2-CQOA-bbN.js";import{P as Yo}from"./panel-right-open-CwhZfkKJ.js";import{G as Xt}from"./user-round-DSt0xU3K.js";import{C as ut}from"./circle-x-Dic_-4tF.js";import{R as Qo}from"./rotate-ccw-DndbJAiz.js";import"./react-CRB3T2We.js";import"./triangle-alert-DUf4Ook0.js";import"./chevron-up-DM5LX-26.js";import"./pencil-Cf6-MgpT.js";import"./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 Zo=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],co=Yt("columns-3",Zo);/**
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 Xo=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],Bt=Yt("folder-tree",Xo);/**
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 es=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],ts=Yt("panel-right-close",es),en=[{items:[{id:"diagram",label:"Models"},{id:"skills",label:"Skills"},{id:"blocks",label:"Blocks"},{id:"notebooks",label:"Notebooks"},{id:"apps",label:"Apps"}]}],ns=new Set(en.flatMap(t=>t.items.map(n=>n.id)));function os(t){return t!==null&&ns.has(t)}function ss(t,n){const o=new URL(t);return n.domain?o.searchParams.set("domain",n.domain):o.searchParams.delete("domain"),o.searchParams.set("domainSection",n.section),n.modelAreaId?o.searchParams.set("modelArea",n.modelAreaId):o.searchParams.delete("modelArea"),n.selectedId?o.searchParams.set("domainObject",n.selectedId):o.searchParams.delete("domainObject"),`${o.pathname}${o.search}${o.hash}`}function is(t){const n=Object.values(t),o=new Map;for(const c of n){const l=c.parent&&t[c.parent]?c.parent:void 0;o.set(l,[...o.get(l)??[],c])}for(const c of o.values())c.sort((l,d)=>l.id.localeCompare(d.id));const s=[],i=new Set,r=(c,l)=>{for(const d of o.get(c)??[])i.has(d.id)||(i.add(d.id),s.push({id:d.id,parent:d.parent,depth:l,label:l===0?d.id:`${"— ".repeat(l)}${d.id.split(".").at(-1)??d.id}`}),r(d.id,l+1))};r(void 0,0);for(const c of n.sort((l,d)=>l.id.localeCompare(d.id)))i.has(c.id)||s.push({id:c.id,parent:c.parent,depth:0,label:c.id});return s}function uo(t){const n=(t??"").toLowerCase();return n==="dimension"?"var(--status-success)":n==="bridge"?"var(--status-warning)":n==="event"||n==="snapshot"?"var(--accent)":"var(--text-tertiary)"}function tn(t){return Object.entries(t.entities).map(([n,o])=>({recordKey:n,entity:o}))}function Hn(t,n){if(t.entities[n])return n;const o=tn(t).filter(({entity:s})=>s.id===n||s.qualifiedId===n);return o.length===1?o[0].recordKey:void 0}function nn(t,n){return tn(t).filter(({entity:o})=>!n||o.domain===n)}function ls({modeling:t,relationByDbtId:n,detailsByDbtId:o,selectedDomain:s,selectedAreaId:i,selectedId:r,viewMode:c,columnMode:l,search:d,layoutMode:u,density:h,visibleLimit:g,dimUnrelated:b,showEdgeLabels:x,resetLayoutToken:y,focusRequest:j,onVisibleDbtIdsChange:f,onSelectEntity:k,onSelectRelationship:I,onEditRelationship:v,onDraftRelationship:D,onAddRelatedModel:$,onDropDbtModel:T,onCreateDomain:Q,onEditEntity:B,onOpenAi:U,theme:Y}){const q=`dql-model-layout:${i??s??"all"}`,N=`${q}:sizes`,[ne,ue]=a.useState(()=>Un(q)),[S,C]=a.useState(()=>Kn(N));a.useEffect(()=>ue(Un(q)),[q]),a.useEffect(()=>C(Kn(N)),[N]),a.useEffect(()=>{y&&(localStorage.removeItem(q),localStorage.removeItem(N),ue({}),C({}))},[y]);const[R,O]=a.useState(null),[W,Z]=a.useState(null),V=(M,oe)=>{const ae={...S,[M]:Math.round(oe)};C(ae),localStorage.setItem(N,JSON.stringify(ae))},{nodes:re,edges:he}=a.useMemo(()=>ds(t,n,o,s,i,r,c,l,d,u,h,g,b,x,ne,S,$,V,Y),[t,n,o,s,i,r,c,l,d,u,h,g,b,x,ne,S,$,Y]),[Re,ye,We]=Fo(re);a.useEffect(()=>ye(re),[re,ye]);const be=re.map(M=>M.data.entity.dbtUniqueId),ze=be.join("|");if(a.useEffect(()=>f(be),[f,ze]),!re.length)return e.jsxs("div",{style:{display:"flex",flexDirection:"column",placeItems:"center",justifyContent:"center",alignItems:"center",gap:12,height:"100%",color:Y.textMuted},children:[e.jsx("strong",{style:{color:Y.textPrimary},children:d.trim()?`No models or columns match “${d.trim()}”.`:"Start your Domain Model"}),!d.trim()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"Bind a dbt model, then connect its columns to define governed analytical relationships."}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("button",{onClick:Q,style:Jn(Y),children:[e.jsx(ke,{size:13})," Create domain"]}),e.jsxs("button",{onClick:()=>T(""),style:Jn(Y,!0),children:[e.jsx(Ge,{size:13})," Bind first model"]})]})]})]});const L=M=>{!M.source||!M.target||D({from:M.source,to:M.target,fromColumn:Vn(M.sourceHandle),toColumn:Vn(M.targetHandle)})},Se=W?t.relationships[W.recordKey]:void 0;return e.jsxs("div",{style:{height:"100%",position:"relative"},onClick:()=>{O(null),Z(null)},children:[e.jsx("style",{children:xs}),e.jsxs(Wo,{nodes:Re,edges:he,onNodesChange:We,nodeTypes:{entity:as},fitView:!0,fitViewOptions:{padding:.16},minZoom:.2,maxZoom:1.8,nodesDraggable:!0,nodesConnectable:!0,onConnect:L,onNodeDragStop:(M,oe)=>{const ae={...ne,[oe.id]:oe.position};ue(ae),localStorage.setItem(q,JSON.stringify(ae))},onDragOver:M=>{M.dataTransfer.types.includes("application/x-dql-dbt-model")&&M.preventDefault()},onDrop:M=>{const oe=M.dataTransfer.getData("application/x-dql-dbt-model");oe&&(M.preventDefault(),T(oe))},onNodeClick:(M,oe)=>k(oe.id),onNodeDoubleClick:(M,oe)=>B(oe.id),onNodeContextMenu:(M,oe)=>{M.preventDefault(),O({x:M.clientX,y:M.clientY,nodeId:oe.id})},onEdgeClick:(M,oe)=>{M.stopPropagation(),I(oe.id),Z({x:Math.min(M.clientX,window.innerWidth-340),y:Math.min(M.clientY,window.innerHeight-320),recordKey:oe.id})},colorMode:Y.appBg.toLowerCase().includes("0")?"dark":"light",proOptions:{hideAttribution:!0},children:[e.jsx(us,{focusRequest:j}),e.jsx(Ho,{color:"var(--border-strong)",gap:22,size:1}),e.jsx(Uo,{showInteractive:!1}),e.jsx(Ko,{pannable:!0,zoomable:!0,nodeColor:M=>po(String(M.data.entity.domain)),maskColor:`${Y.appBg}bb`})]},`${u}:${h}:${g}:${y}:${d}`),R&&e.jsxs("div",{style:{position:"fixed",left:R.x,top:R.y,zIndex:50,width:178,border:`1px solid ${Y.headerBorder}`,borderRadius:7,background:Y.cellBg,boxShadow:"0 12px 32px #0004",padding:4},onClick:M=>M.stopPropagation(),children:[e.jsx(It,{label:"Inspect entity",onClick:()=>{k(R.nodeId),O(null)},theme:Y}),e.jsx(It,{label:"Edit Domain Model binding",onClick:()=>{B(R.nodeId),O(null)},theme:Y}),e.jsx(It,{label:"Ask AI about entity",onClick:()=>{U(R.nodeId),O(null)},theme:Y}),e.jsx(It,{label:"Start relationship",onClick:()=>{D({from:R.nodeId,to:""}),O(null)},theme:Y})]}),W&&Se&&e.jsx(rs,{relationship:Se,entities:t.entities,x:W.x,y:W.y,theme:Y,onClose:()=>Z(null),onEdit:v?()=>{v(W.recordKey),Z(null)}:void 0,onViewProof:()=>{I(W.recordKey),Z(null)}})]})}function rs({relationship:t,entities:n,x:o,y:s,theme:i,onClose:r,onEdit:c,onViewProof:l}){var b,x;const d=((b=t.validation)==null?void 0:b.status)==="passed",u=t.keys.map(y=>`${y.from} = ${y.to}`).join(" and ")||"No join keys declared",h=y=>{const j=n[y]??Object.values(n).find(f=>f.id===y||f.localId===y);return(j==null?void 0:j.businessName)||(j==null?void 0:j.localId)||y.split("::").pop()||y},g=y=>e.jsx("span",{style:{padding:"3px 8px",borderRadius:6,background:"var(--accent-dim)",color:"var(--accent)",border:"1px solid rgba(107,93,211,0.2)",fontFamily:i.fontMono,fontSize:11.5,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y});return e.jsxs("div",{onClick:y=>y.stopPropagation(),style:{position:"fixed",left:o,top:s,zIndex:60,width:316,background:i.cellBg,border:`1px solid ${i.headerBorder}`,borderRadius:12,boxShadow:"0 12px 34px rgba(26,26,26,0.16)",overflow:"hidden",fontFamily:i.font},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"11px 13px",borderBottom:"1px solid var(--border-subtle)",background:"var(--bg-1)"},children:[e.jsx(Ge,{size:14,color:"var(--accent)",style:{flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:700,color:i.textPrimary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.localId}),e.jsx("span",{style:{flexShrink:0,border:`1px solid ${d?"var(--status-success-border)":"var(--status-warning-border)"}`,color:d?"var(--status-success)":"var(--status-warning)",background:d?"var(--status-success-bg)":"var(--status-warning-bg)",borderRadius:999,padding:"2px 8px",fontSize:9.5,fontWeight:700},children:d?"Proven":"Unproven"}),e.jsx("button",{type:"button",onClick:r,title:"Close",style:{flexShrink:0,width:20,height:20,borderRadius:5,border:"none",background:"none",color:i.textMuted,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0},children:"×"})]}),e.jsxs("div",{style:{padding:"12px 13px",display:"flex",flexDirection:"column",gap:11},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,fontSize:11.5},children:[g(h(t.from)),e.jsx("span",{style:{color:i.textMuted,fontSize:10.5,fontWeight:650,whiteSpace:"nowrap"},children:t.cardinality.replace(/_/g," ")}),g(h(t.to))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:i.textMuted,marginBottom:4},children:"Join"}),e.jsx("div",{style:{fontSize:11,fontFamily:i.fontMono,color:i.textPrimary,background:"var(--bg-1)",border:"1px solid var(--border-subtle)",borderRadius:7,padding:"7px 9px",overflowWrap:"anywhere"},children:u})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:i.textMuted,marginBottom:4},children:"Business context"}),e.jsx("div",{style:{fontSize:12,lineHeight:1.55,color:i.textSecondary},children:t.description||`${t.from} ${t.verb??"relates to"} ${t.to}. Add a business description so agents can pick this route with confidence.`})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:d?"var(--status-success)":"var(--status-warning)"},children:d?`Join proof passed — ${((x=t.validation)==null?void 0:x.joinedRows)??"?"} rows joined, agents may use this route.`:"No warehouse proof yet — automatic agent joins stay blocked."}),e.jsxs("div",{style:{display:"flex",gap:8},children:[c?e.jsx("button",{type:"button",onClick:c,style:{display:"inline-flex",alignItems:"center",gap:5,height:27,padding:"0 11px",borderRadius:7,border:"none",background:"var(--accent)",color:"#fff",fontSize:11.5,fontWeight:650,cursor:"pointer",fontFamily:i.font},children:"Edit relationship"}):null,e.jsx("button",{type:"button",onClick:l,style:{display:"inline-flex",alignItems:"center",gap:5,height:27,padding:"0 11px",borderRadius:7,border:`1px solid ${i.headerBorder}`,background:i.cellBg,color:i.textSecondary,fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:i.font},children:"View join proof"})]})]})]})}function as({data:t}){var T,Q;const{recordKey:n,entity:o,detail:s,relation:i,selected:r,viewMode:c,columnMode:l,density:d,theme:u,onAddRelatedModel:h,onResize:g}=t,[b,x]=a.useState(d==="compact"),y=po(o.domain),j=uo(o.analyticalRole),f=o.analyticalRole&&o.analyticalRole!=="unknown"?o.analyticalRole:"entity",k=(s==null?void 0:s.columns)??[],I=new Set(o.keys.length?o.keys:((T=s==null?void 0:s.dqlMeta)==null?void 0:T.keys)??[]),v=new Set(k.filter(B=>!I.has(B.name)&&/(^|_)id$/.test(B.name)).map(B=>B.name)),D=b||c==="business"?[]:l==="all"?k.slice(0,16):l==="keys"?k.filter(B=>I.has(B.name)).slice(0,10):k.filter(B=>I.has(B.name)||B.tests.length>0).slice(0,10),$=(Q=o.conceptRefs)!=null&&Q.length?o.conceptRefs.join(", "):Jt(o.localId??o.id);return e.jsxs("div",{style:{position:"relative",width:"100%",minWidth:236,borderRadius:10,overflow:"visible",border:`1.5px solid ${r?"var(--accent)":"var(--border-default)"}`,boxShadow:r?"0 1px 6px rgba(107,93,211,0.14)":"0 1px 4px rgba(26,26,26,0.05)",background:u.cellBg,color:u.textPrimary},children:[e.jsx(Jo,{position:"bottom-right",resizeDirection:"horizontal",minWidth:240,maxWidth:620,onResizeEnd:(B,U)=>g(n,U.width),style:{width:16,height:16,border:0,background:"transparent",color:u.textMuted},children:e.jsx("span",{title:"Drag to resize model",style:{display:"grid",placeItems:"center"},children:e.jsx(ao,{size:12})})}),b&&c==="data"&&e.jsx(it,{className:"dql-modeling-handle",id:"entity-target",type:"target",position:lt.Left,style:rt(y)}),e.jsx("button",{className:"nodrag",title:"Add a related model",onClick:B=>{B.stopPropagation(),h({from:n})},style:{position:"absolute",right:-9,top:-9,zIndex:5,width:22,height:22,display:"grid",placeItems:"center",padding:0,borderRadius:999,border:`2px solid ${u.cellBg}`,background:"var(--accent)",color:"#fff",cursor:"pointer",boxShadow:"0 1px 4px rgba(107,93,211,0.3)"},children:e.jsx(ke,{size:12})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"9px 12px",borderBottom:"1px solid var(--border-subtle)",background:"var(--bg-1)",borderRadius:"8.5px 8.5px 0 0"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2.5,background:j,flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:700,color:u.textPrimary,fontFamily:u.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c==="business"?o.businessName||Jt(o.localId??o.id):o.localId??o.id}),e.jsx("span",{style:{flexShrink:0,fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",color:j},children:f}),c==="data"&&e.jsx("button",{className:"nodrag",title:b?"Expand columns":"Collapse columns",onClick:B=>{B.stopPropagation(),x(U=>!U)},style:{border:0,background:"transparent",color:u.textMuted,cursor:"pointer",padding:0,flexShrink:0},children:b?"▾":"▴"})]}),c==="business"?e.jsxs(e.Fragment,{children:[e.jsx("div",{title:o.businessContext,style:{padding:"9px 12px 7px",fontSize:11.5,lineHeight:1.5,color:u.textSecondary,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},children:o.businessContext||$}),e.jsxs("div",{style:{display:"flex",gap:6,padding:"0 12px 10px",flexWrap:"wrap"},children:[o.owner?e.jsx("span",{style:{fontSize:10,color:u.textMuted,border:"1px solid var(--border-subtle)",background:"var(--bg-1)",borderRadius:999,padding:"2px 7px"},children:o.owner}):null,e.jsx("span",{style:{fontSize:10,color:u.textMuted,border:"1px solid var(--border-subtle)",background:"var(--bg-1)",borderRadius:999,padding:"2px 7px"},children:o.grain?`1 row = ${o.grain}`:o.domain})]})]}):null,D.length>0&&e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",maxHeight:242,overflow:"auto"},children:[D.map(B=>e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center",gap:7,padding:"4px 12px",borderBottom:"1px solid var(--border-subtle)",fontSize:11},children:[e.jsx(it,{className:"dql-modeling-handle",id:`target:${B.name}`,type:"target",position:lt.Left,style:{...rt(y),top:"50%"}}),e.jsx("span",{style:{flexShrink:0,width:17,fontSize:8.5,fontWeight:700,fontFamily:u.fontMono,color:I.has(B.name)?"var(--pk)":v.has(B.name)?"var(--fk)":"transparent"},children:I.has(B.name)?"PK":v.has(B.name)?"FK":"·"}),e.jsx("span",{style:{flex:1,minWidth:0,color:u.textSecondary,fontFamily:u.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:I.has(B.name)?700:500},children:B.name}),e.jsx("span",{style:{flexShrink:0,fontSize:9.5,color:u.textMuted,fontFamily:u.fontMono},children:B.type??""}),e.jsx(it,{className:"dql-modeling-handle",id:`source:${B.name}`,type:"source",position:lt.Right,style:{...rt(y),top:"50%"}})]},B.name)),k.length>D.length&&e.jsxs("div",{style:{padding:"6px 12px",color:u.textMuted,fontSize:9},children:["+ ",k.length-D.length," more dbt-owned columns"]})]}),(b||c==="business")&&e.jsxs(e.Fragment,{children:[e.jsx(it,{className:"dql-modeling-handle",id:"entity-target",type:"target",position:lt.Left,style:rt(y)}),e.jsx(it,{className:"dql-modeling-handle",id:"entity-source",type:"source",position:lt.Right,style:rt(y)})]})]})}function ds(t,n,o,s,i,r,c,l,d,u,h,g,b,x,y,j,f,k,I){const v=i?t.areas[i]:void 0,D=new Set(v?[...v.entityIds,...v.referencedEntityIds]:[]),$=Object.entries(t.relationships).flatMap(([S,C])=>{const R=Hn(t,C.from),O=Hn(t,C.to);return R&&O?[{recordKey:S,relationship:C,from:R,to:O}]:[]}).filter(({recordKey:S,from:C,to:R})=>{var O,W;return v?v.relationshipIds.includes(S):s?((O=t.entities[C])==null?void 0:O.domain)===s||((W=t.entities[R])==null?void 0:W.domain)===s:!0}),T=new Set($.flatMap(({from:S,to:C})=>[S,C])),Q=d.trim().toLowerCase();let B=tn(t).filter(({recordKey:S,entity:C})=>{if(v&&!D.has(S)&&!T.has(S)||s&&C.domain!==s&&!T.has(S))return!1;if(!Q)return!0;const R=o[C.dbtUniqueId];return[S,C.id,C.qualifiedId,C.domain,R==null?void 0:R.relation,...(R==null?void 0:R.columns.map(O=>O.name))??[]].some(O=>String(O??"").toLowerCase().includes(Q))});const U=Math.min(200,g>0?g:50);if(B.length>U){const S=new Map;for(const C of $)S.set(C.from,(S.get(C.from)??0)+1),S.set(C.to,(S.get(C.to)??0)+1);B=[...B].sort((C,R)=>C.recordKey===r?-1:R.recordKey===r?1:(S.get(R.recordKey)??0)-(S.get(C.recordKey)??0)||C.recordKey.localeCompare(R.recordKey)).slice(0,U)}const Y=[...new Set(B.map(({entity:S})=>S.domain))].sort(),q=[];Y.forEach((S,C)=>B.filter(({entity:R})=>R.domain===S).sort((R,O)=>R.recordKey.localeCompare(O.recordKey)).forEach(({recordKey:R,entity:O},W)=>{const Z=o[O.dbtUniqueId],V=c==="business"?0:ps(O,Z,l),re=j[R]??hs(O,Z,n[O.dbtUniqueId],h);q.push({id:R,type:"entity",position:{x:C*390,y:W*190},data:{recordKey:R,entity:O,detail:Z,relation:n[O.dbtUniqueId],selected:r===R,viewMode:c,columnMode:l,density:h,theme:I,onAddRelatedModel:f,onResize:k},style:{width:re,height:116+V*29}})}));const N=new Set(q.map(S=>S.id)),ne=$.filter(({from:S,to:C})=>N.has(S)&&N.has(C)).map(({recordKey:S,relationship:C,from:R,to:O})=>{var ze,L;const W=((ze=C.validation)==null?void 0:ze.status)==="passed";C.automaticJoinAllowed||C.staleCertification;const Z=C.keys.map(Se=>`${Se.from} → ${Se.to}`).join(", "),V=C.keys[0],re=t.entities[R],he=t.entities[O],Re=re?Kt(re,o[re.dbtUniqueId],l):new Set,ye=he?Kt(he,o[he.dbtUniqueId],l):new Set,be=((L=C.verb)==null?void 0:L.trim())||Z;return{id:S,source:R,target:O,sourceHandle:c==="data"&&V&&Re.has(V.from)?`source:${V.from}`:void 0,targetHandle:c==="data"&&V&&ye.has(V.to)?`target:${V.to}`:void 0,type:"default",label:x?`${be} · ${cs(C.cardinality)}`:void 0,animated:C.status==="review",markerEnd:{type:Vo.ArrowClosed,color:r===S?"var(--accent)":"var(--border-strong)"},style:{stroke:r===S?"var(--accent)":"var(--border-strong)",strokeWidth:r===S?2:1.5,cursor:"pointer"},labelStyle:{fill:r===S?"var(--accent)":I.textSecondary,fontSize:10.5,fontWeight:650,cursor:"pointer"},labelBgStyle:{fill:I.cellBg,fillOpacity:1,stroke:r===S?"var(--accent)":I.headerBorder,strokeWidth:1},labelBgPadding:[9,4],labelBgBorderRadius:999}}),ue=new Wn.graphlib.Graph().setDefaultEdgeLabel(()=>({}));if(ue.setGraph({rankdir:"LR",ranksep:h==="compact"?90:h==="wide"?190:135,nodesep:h==="compact"?35:h==="wide"?90:60,marginx:35,marginy:35}),q.forEach(S=>{var C,R;return ue.setNode(S.id,{width:Number(((C=S.style)==null?void 0:C.width)??Vt(h)),height:Number(((R=S.style)==null?void 0:R.height)??100)})}),ne.forEach(S=>ue.setEdge(S.source,S.target)),u==="auto"&&Wn.layout(ue),q.forEach(S=>{var O,W;const C=y[S.id];if(C){S.position=C;return}if(u==="grid"){const Z=q.indexOf(S),V=Math.max(1,Math.ceil(Math.sqrt(q.length)));S.position={x:Z%V*360,y:Math.floor(Z/V)*260};return}if(u==="star"){const Z=q.indexOf(S);if(Z===0){S.position={x:0,y:0};return}const V=(Z-1)/Math.max(1,q.length-1)*Math.PI*2;S.position={x:Math.cos(V)*460,y:Math.sin(V)*330};return}const R=ue.node(S.id);R&&(S.position={x:R.x-Number(((O=S.style)==null?void 0:O.width)??Vt(h))/2,y:R.y-Number(((W=S.style)==null?void 0:W.height)??100)/2})}),b&&r&&t.entities[r]){const S=new Set([r]);for(const C of $)C.from===r&&S.add(C.to),C.to===r&&S.add(C.from);for(const C of q)C.style={...C.style,opacity:S.has(C.id)?1:.18,transition:"opacity 160ms ease"}}return{nodes:q,edges:ne}}function cs(t){return t==="one_to_one"?"1:1":t==="one_to_many"?"1:N":t==="many_to_one"?"N:1":t==="many_to_many"?"N:N":"?"}function us({focusRequest:t}){const n=Go(),o=a.useRef(-1);return a.useEffect(()=>{if(!t||t.token===o.current)return;o.current=t.token;const s=window.setTimeout(()=>{var l,d,u,h;const i=n.getNode(t.id);if(!i)return;const r=Number(((l=i.measured)==null?void 0:l.width)??i.width??((d=i.style)==null?void 0:d.width)??280),c=Number(((u=i.measured)==null?void 0:u.height)??i.height??((h=i.style)==null?void 0:h.height)??120);n.setCenter(i.position.x+r/2,i.position.y+c/2,{zoom:Math.max(.85,n.getZoom()),duration:500})},60);return()=>window.clearTimeout(s)},[t,n]),null}function It({label:t,onClick:n,theme:o}){return e.jsx("button",{onClick:n,style:{width:"100%",textAlign:"left",border:0,borderRadius:4,padding:"7px 8px",background:"transparent",color:o.textPrimary,fontSize:11,cursor:"pointer"},children:t})}function ps(t,n,o){return Kt(t,n,o).size}function Kt(t,n,o){var r;const s=(n==null?void 0:n.columns)??[];if(o==="all")return new Set(s.slice(0,16).map(c=>c.name));const i=new Set(t.keys.length?t.keys:((r=n==null?void 0:n.dqlMeta)==null?void 0:r.keys)??[]);return o==="keys"?new Set(s.filter(c=>i.has(c.name)).slice(0,10).map(c=>c.name)):new Set(s.filter(c=>i.has(c.name)||c.tests.length>0).slice(0,10).map(c=>c.name))}function Vt(t){return t==="compact"?250:t==="wide"?340:280}function hs(t,n,o,s){var r;const i=Math.max(Jt(t.localId??t.id).length,(o==null?void 0:o.length)??0,((r=n==null?void 0:n.description)==null?void 0:r.length)??0,...((n==null?void 0:n.columns)??[]).map(c=>c.name.length));return Math.min(s==="wide"?440:380,Vt(s)+Math.max(0,i-34)*2)}function Un(t){try{const n=JSON.parse(localStorage.getItem(t)??"{}");return Object.fromEntries(Object.entries(n).filter(([,o])=>typeof o.x=="number"&&typeof o.y=="number"))}catch{return{}}}function Kn(t){try{const n=JSON.parse(localStorage.getItem(t)??"{}");return Object.fromEntries(Object.entries(n).filter(([,o])=>typeof o=="number"&&o>=240&&o<=620))}catch{return{}}}function Vn(t){return t!=null&&t.includes(":")?t.slice(t.indexOf(":")+1):void 0}function rt(t){return{background:t,border:"2px solid var(--color-bg-card)",width:9,height:9,cursor:"crosshair"}}const xs=`
17
- .dql-modeling-handle { opacity: 0; transition: opacity 0.12s ease; }
18
- .react-flow__node:hover .dql-modeling-handle,
19
- .dql-modeling-handle.connecting,
20
- .dql-modeling-handle:hover { opacity: 1; }
21
- `;function Jn(t,n=!1){return{display:"inline-flex",alignItems:"center",gap:6,border:`1px solid ${n?t.accent:t.headerBorder}`,borderRadius:6,padding:"7px 10px",color:n?t.accent:t.textSecondary,background:n?`${t.accent}12`:t.cellBg,cursor:"pointer",fontSize:11,fontWeight:650}}function Jt(t){return t.replace(/[._-]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function po(t){const n=["#6d5ce7","#2e9b63","#d47822","#377cc8","#bd4f8b","#8a6d3b"];let o=0;for(const s of t)o=(o<<5)-o+s.charCodeAt(0)|0;return n[Math.abs(o)%n.length]}function ms(t){return t instanceof Error?t:void 0}function fs(t){return t.details&&typeof t.details=="object"&&!Array.isArray(t.details)?t.details:void 0}function Gn(t){const n=ms(t);if((n==null?void 0:n.code)==="DBT_FIRST_NOT_ENABLED")return{title:"Set up dbt-first modeling",detail:"Domain Studio requires a connected dbt project with manifest v3 and dbt-first modeling enabled. Open Settings → Project & dbt to connect and apply the project.",status:"Modeling mode · Not enabled"};if((n==null?void 0:n.code)==="DBT_MANIFEST_NOT_FOUND"){const s=fs(n),i=typeof(s==null?void 0:s.manifestPath)=="string"&&s.manifestPath.trim()?s.manifestPath:"target/manifest.json";return{title:"dbt manifest is not ready",detail:`The dbt project is connected, but ${i} was not found. Run dbt parse, dbt compile, or dbt build in the configured dbt project, then refresh Domain Studio.`,status:`dbt manifest · Missing (${i})`}}return(n==null?void 0:n.code)==="DBT_MANIFEST_COMPILE_FAILED"?{title:"dbt manifest could not be loaded",detail:`${n.message} Rebuild the dbt manifest, then refresh Domain Studio.`,status:"dbt manifest · Load failed"}:{title:"Domain Studio could not load",detail:t instanceof Error&&t.message?t.message:"The local DQL notebook server did not return Domain Studio data.",status:"Domain Studio · Unavailable"}}function at(t){return t.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function gs(t,n,o=50){const s=at(n),i=s.split(/\s+/).filter(Boolean);return t.map(r=>{var b;const c=at(r.label),l=at(r.value),d=at(r.description??""),u=at(((b=r.keywords)==null?void 0:b.join(" "))??""),h=`${c} ${l} ${d} ${u}`;if(i.length&&!i.every(x=>h.includes(x)))return null;let g=0;return s&&((c===s||l===s)&&(g+=1e3),c.startsWith(s)&&(g+=500),l.startsWith(s)&&(g+=350),c.includes(s)&&(g+=200),g+=i.reduce((x,y)=>x+(c.startsWith(y)?80:c.includes(y)?40:10),0)),{option:r,score:g}}).filter(r=>!!r).sort((r,c)=>c.score-r.score||r.option.label.localeCompare(c.option.label)||r.option.value.localeCompare(c.option.value)).slice(0,Math.max(1,o)).map(({option:r})=>r)}function ri(){const{state:t,dispatch:n}=Qt(),o=Po[t.themeMode],[s,i]=a.useState(null),[r,c]=a.useState(!0),[l,d]=a.useState(null),u=a.useMemo(()=>Yn(),[]),[h,g]=a.useState(u.section),[b,x]=a.useState(u.domain),[y,j]=a.useState(u.modelAreaId),[f,k]=a.useState(u.selectedId),[I,v]=a.useState(null),[D,$]=a.useState({}),T=a.useRef(new Map),Q=a.useRef(new Set),B=a.useMemo(()=>Ws(),[]),[U,Y]=a.useState(B.viewMode??"business"),[q,N]=a.useState(B.columnMode??"relevant"),[ne,ue]=a.useState(""),[S,C]=a.useState(0),[R,O]=a.useState(null),[W,Z]=a.useState(B.layoutMode??"auto"),[V,re]=a.useState(B.density??"normal"),[he,Re]=a.useState(B.visibleLimit??50),[ye,We]=a.useState(B.dimUnrelated??!0),[be,ze]=a.useState(B.showEdgeLabels??!0),[L,Se]=a.useState(!1),[M,oe]=a.useState(!1),[ae,He]=a.useState(!1),[Ue,Rt]=a.useState(()=>typeof window<"u"&&window.innerWidth<980),Pe=a.useRef(null),pt=a.useRef(null),[xe,H]=a.useState(null),[Qe,Ze]=a.useState(null),[ve,Ke]=a.useState(null),[Xe,ht]=a.useState(!1),[et,Ne]=a.useState(null);a.useEffect(()=>{localStorage.setItem("dql-modeling-preferences",JSON.stringify({modelingView:U,columnMode:q,layoutMode:W,density:V,visibleLimit:he,dimUnrelated:ye,showEdgeLabels:be}))},[U,q,W,V,he,ye,be]),a.useEffect(()=>{const m=()=>Rt(window.innerWidth<980);return window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)},[]);const tt=a.useCallback(()=>{He(m=>{const z=!m;return z?window.requestAnimationFrame(()=>{var J;return(J=pt.current)==null?void 0:J.focus()}):window.requestAnimationFrame(()=>{var J;return(J=Pe.current)==null?void 0:J.focus()}),z})},[]),nt=a.useCallback(m=>{g(m),Mt(b,m,!1,y,f)},[y,b,f]),xt=a.useCallback(m=>{x(m),j(null),k(null),Mt(m,h,!1,null,null)},[h]);a.useEffect(()=>{const m=()=>{const z=Yn();x(z.domain),j(z.modelAreaId),k(z.selectedId),g(z.section)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[]),a.useEffect(()=>{Mt(b,h,!0,y,f)},[y,b,f,h]);const Ae=async()=>{c(!0);try{const m=await le.getDbtFirstModeling();i(m),d(null);const z=b&&m.modeling.packages[b]?b:null;z!==b&&(x(z),Mt(z,h,!0))}catch(m){i(null),d(Gn(m))}finally{c(!1)}};a.useEffect(()=>{Ae()},[]);const X=s==null?void 0:s.modeling.entities[f??""],je=s==null?void 0:s.modeling.relationships[f??""],Oe=a.useMemo(()=>s?Object.values(s.modeling.areas).filter(m=>!b||m.domain===b).sort((m,z)=>m.name.localeCompare(z.name)):[],[s,b]),ee=s==null?void 0:s.modeling.areas[y??""];a.useEffect(()=>{s&&y&&!Oe.some(m=>m.qualifiedId===y)&&j(null)},[s,Oe,y]);const Be=a.useCallback(m=>{const z=T.current.get(m);if(z)return z;if(Q.current.has(m))return Promise.resolve(void 0);const J=le.getDbtModelingNode(m).then(De=>(Q.current.add(m),$(we=>({...we,[m]:De})),De)).catch(()=>{Q.current.add(m)}).finally(()=>T.current.delete(m));return T.current.set(m,J),J},[]);a.useEffect(()=>{if(!X){v(null);return}const m=D[X.dbtUniqueId];if(m){v(m);return}let z=!1;return Be(X.dbtUniqueId).then(J=>{z||v(J??null)}),()=>{z=!0}},[D,Be,X==null?void 0:X.dbtUniqueId]),a.useEffect(()=>{T.current.clear(),Q.current.clear(),$({})},[s==null?void 0:s.dbtProvenance.manifestFingerprint]);const Pt=a.useCallback(m=>{for(const z of m.slice(0,24))Be(z)},[Be]);if(r&&!s)return e.jsx(eo,{t:o,title:"Loading Domain Studio…",detail:"Compiling dbt provenance and the sparse DQL analytical overlay."});if(!s){const m=l??Gn(null);return e.jsx(eo,{t:o,title:m.title,detail:m.detail,status:m.status})}const mt=Object.fromEntries(Object.values(s.dbtProvenance.nodes).map(m=>[m.uniqueId,m.relation])),Nt=Object.entries(s.modeling.entities).flatMap(([m,z])=>{var we;const J=z.businessName||z.localId||z.id,De=[{recordKey:m,type:"model",label:J,sublabel:z.domain,role:z.analyticalRole}];for(const jt of((we=D[z.dbtUniqueId])==null?void 0:we.columns)??[])De.push({recordKey:m,type:"column",label:jt.name,sublabel:J,role:z.analyticalRole});return De}),ft=m=>{k(m),ue(""),O(z=>({id:m,token:((z==null?void 0:z.token)??0)+1}))},Ee=ee?new Set([...ee.entityIds,...ee.referencedEntityIds]):void 0,gt=nn(s.modeling,b).filter(({recordKey:m})=>!Ee||Ee.has(m)),ot=Object.values(s.modeling.relationships).filter(m=>{const z=s.modeling.entities[m.from],J=s.modeling.entities[m.to];return ee?ee.relationshipIds.includes(m.qualifiedId):!b||(z==null?void 0:z.domain)===b||(J==null?void 0:J.domain)===b}),yt=Object.values(s.dbtProvenance.nodes).filter(m=>!Object.values(s.modeling.entities).some(z=>z.dbtUniqueId===m.uniqueId)),bt=ae&&h==="diagram";return e.jsxs("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",background:o.appBg,color:o.textPrimary},children:[e.jsx("header",{style:{minHeight:52,padding:"0 14px",borderBottom:`1px solid ${o.headerBorder}`,background:o.headerBg,display:"flex",alignItems:"center"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,alignItems:"center",width:"100%"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[e.jsx(Fe,{size:16,color:o.accent}),e.jsx("h1",{style:{margin:0,fontSize:12,fontWeight:800,whiteSpace:"nowrap"},children:"Domain workspace"}),e.jsx("span",{style:{color:o.textMuted,fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b?`/${b}`:"/all domains"})]}),e.jsxs("div",{style:{display:"flex",gap:7},children:[b&&e.jsxs(K,{t:o,onClick:()=>{try{window.sessionStorage.setItem("dql-ask-domain-context",JSON.stringify({domain:b,modelAreaId:ee==null?void 0:ee.qualifiedId}))}catch{}n({type:"SET_MAIN_VIEW",view:"ask"})},children:[e.jsx(No,{size:14})," Ask"]}),e.jsxs(K,{t:o,onClick:()=>H(b?{kind:"area"}:{kind:"domain"}),children:[e.jsx(ke,{size:14})," ",b?"New model area":"New domain"]}),e.jsx(qs,{t:o,title:"Recompile",onClick:()=>void Ae(),children:e.jsx(Ao,{size:15})})]})]})}),e.jsxs("div",{style:{flex:1,minHeight:0,display:"grid",gridTemplateColumns:bt&&!Ue?"clamp(190px, 15vw, 232px) minmax(460px, 1fr) clamp(270px, 22vw, 380px)":"clamp(190px, 15vw, 232px) minmax(0, 1fr)"},children:[e.jsxs("aside",{style:{borderRight:`1px solid ${o.headerBorder}`,overflow:"auto",background:o.appBg},children:[e.jsx(bs,{data:s,selectedDomain:b,onSelect:xt,t:o}),e.jsx(js,{data:s,domain:b,active:h,onSelect:nt,t:o}),e.jsx("div",{style:{padding:"10px 12px",borderTop:`1px solid ${o.headerBorder}`,display:"flex",flexDirection:"column",gap:5,fontSize:10.5,color:o.textMuted,fontFamily:o.font},children:e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:999,background:"var(--status-success)",flexShrink:0}}),"dbt synced · ",Object.keys(s.dbtProvenance.nodes).length," model",Object.keys(s.dbtProvenance.nodes).length===1?"":"s"]})})]}),e.jsxs("main",{style:{minWidth:0,minHeight:0,display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{minHeight:42,display:"flex",alignItems:"center",gap:7,padding:"0 10px 0 14px",borderBottom:`1px solid ${o.headerBorder}`,background:o.headerBg},children:[ho(h,14,o),e.jsx("strong",{style:{fontSize:11},children:vs(h)}),e.jsx("span",{style:{width:1,height:15,background:o.headerBorder}}),e.jsx("span",{style:{color:o.textMuted,fontSize:10},children:b??"All domains"}),(h==="diagram"||h==="skills")&&b&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginLeft:5},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:5,color:o.textMuted,fontSize:10},children:["Area",e.jsxs("select",{"aria-label":"Active model area",value:y??"",onChange:m=>{j(m.target.value||null),k(null)},style:{...ge(o),minWidth:146,padding:"4px 6px"},children:[e.jsx("option",{value:"",children:"All domain"}),Oe.map(m=>e.jsx("option",{value:m.qualifiedId,children:m.name},m.qualifiedId))]})]}),e.jsx("button",{"aria-label":"Add model area",title:"Add model area",onClick:()=>H({kind:"area"}),style:{...fe(o),width:27,height:27},children:e.jsx(ke,{size:13})})]}),h==="diagram"&&e.jsx("button",{ref:Pe,"aria-expanded":ae,"aria-controls":"domain-studio-inspector","aria-label":ae?"Hide inspector":"Show inspector",title:ae?"Hide inspector":"Show inspector",onClick:tt,style:{...fe(o),marginLeft:"auto"},children:ae?e.jsx(ts,{size:14}):e.jsx(Yo,{size:14})})]}),e.jsxs("div",{style:{flex:1,minHeight:0},children:[h==="overview"&&e.jsx(ws,{data:s,domain:b,t:o,onOpen:nt}),h==="diagram"&&e.jsxs("div",{id:"dql-modeling-diagram",style:{height:"100%",display:"flex",flexDirection:"column",...M?{position:"fixed",inset:0,zIndex:90,background:o.appBg}:{}},children:[e.jsx(Cs,{modelingView:U,columnMode:q,search:ne,layoutMode:W,density:V,visibleLimit:he,totalEntities:(Ee==null?void 0:Ee.size)??Object.keys(s.modeling.entities).length,dimUnrelated:ye,showEdgeLabels:be,showLegend:L,fullscreen:M,onBindModel:()=>H({kind:"entity"}),onRelationship:()=>H({kind:"relationship"}),onNewArea:()=>H({kind:"area"}),onModelingView:Y,onColumnMode:N,onSearch:ue,searchItems:Nt,onPickModel:ft,onLayoutMode:Z,onDensity:re,onVisibleLimit:Re,onDimUnrelated:We,onEdgeLabels:ze,onLegend:Se,onFullscreen:()=>oe(m=>!m),onExport:()=>Ms(),onReset:()=>C(m=>m+1),t:o}),ee?e.jsxs("div",{style:{padding:"7px 14px",borderBottom:`1px solid ${o.headerBorder}`,background:"var(--accent-dim)",color:o.textSecondary,display:"flex",alignItems:"center",gap:8,fontSize:10.5},children:[e.jsx(Fe,{size:13,color:o.accent}),e.jsx("strong",{style:{color:o.textPrimary},children:ee.name}),e.jsx("span",{children:ee.description??"Focused business modeling area"}),e.jsxs("span",{style:{marginLeft:"auto",color:o.textMuted},children:[ee.entityIds.length," model",ee.entityIds.length===1?"":"s"," · ",ee.intentExamples.length," example question",ee.intentExamples.length===1?"":"s"]})]}):null,L&&e.jsx(Is,{t:o}),e.jsx("div",{style:{flex:1,minHeight:0},children:e.jsx(ls,{modeling:s.modeling,relationByDbtId:mt,detailsByDbtId:D,selectedDomain:b,selectedAreaId:y,selectedId:f,viewMode:U,columnMode:q,search:ne,layoutMode:W,density:V,visibleLimit:he,dimUnrelated:ye,showEdgeLabels:be,resetLayoutToken:S,focusRequest:R??void 0,onVisibleDbtIdsChange:Pt,onSelectEntity:k,onSelectRelationship:k,onEditRelationship:m=>{const z=s.modeling.relationships[m];z&&H({kind:"relationship",relationship:z})},onDraftRelationship:m=>H({kind:"relationship",draft:m}),onAddRelatedModel:m=>H({kind:"entity",relationshipFrom:m}),onDropDbtModel:m=>H({kind:"entity",dbtUniqueId:m}),onCreateDomain:()=>H({kind:"domain"}),onEditEntity:m=>{const z=s.modeling.entities[m];z&&H({kind:"entity",entity:z,dbtUniqueId:z.dbtUniqueId})},onOpenAi:m=>{k(m);try{window.sessionStorage.setItem("dql-ask-domain-context",JSON.stringify({domain:b,modelAreaId:ee==null?void 0:ee.qualifiedId,objectId:m}))}catch{}n({type:"SET_MAIN_VIEW",view:"ask"})},theme:o})})]}),h==="terms"&&e.jsx(Wt,{data:s,domain:b,kinds:["terms"],title:"Domain terms",detail:"Business vocabulary owned by this domain and available to governed retrieval.",t:o}),h==="skills"&&e.jsx(Lo,{embedded:!0,domainFilter:b,modelAreaFilter:y}),h==="knowledge"&&e.jsx("div",{style:{height:"100%",overflow:"auto",padding:"18px 20px"},children:e.jsx(_o,{t:o,domains:Object.values(s.modeling.packages).map(m=>({id:m.id,name:m.id})),initialDomainId:b})}),h==="blocks"&&e.jsx(zs,{data:s,domain:b,t:o}),h==="views"&&e.jsx(Wt,{data:s,domain:b,kinds:["views"],title:"Business views",detail:"Domain-owned business views that compose governed models and blocks.",t:o}),h==="ai"&&e.jsx(Bs,{domain:b,selectedId:f,data:s,t:o,onOpenSkills:()=>nt("skills"),onDraftRelationship:()=>H({kind:"relationship",draft:X&&f?{from:f,to:""}:void 0})}),h==="join-proofs"&&e.jsx($s,{relationships:ot,entities:s.modeling.entities,t:o,onSelect:m=>k(_t(s.modeling.relationships,m)),onEdit:m=>H({kind:"relationship",relationship:m})}),h==="contracts"&&e.jsx(Rs,{data:s,domain:b,t:o,onCreate:()=>H({kind:"contract"})}),h==="interfaces"&&e.jsx(Ds,{data:s,domain:b,t:o,onCreateExport:()=>H({kind:"export"}),onCreateImport:()=>H({kind:"import"})}),h==="evaluations"&&e.jsx(Wt,{data:s,domain:b,kinds:["evaluations","tests"],title:"Evaluations",detail:"Evidence and regression checks required before governed assets guide agents.",t:o}),h==="notebooks"&&e.jsx(Qn,{data:s,domain:b,kind:"notebooks",t:o}),h==="apps"&&e.jsx(Qn,{data:s,domain:b,kind:"apps",t:o}),h==="dbt"&&e.jsx(Ps,{data:s,domain:b,unbound:yt,t:o,onBind:m=>H({kind:"entity",dbtUniqueId:m})})]})]}),bt&&e.jsxs("aside",{id:"domain-studio-inspector",ref:pt,role:"complementary","aria-label":"Domain Studio inspector",tabIndex:-1,onKeyDown:m=>{m.key==="Escape"&&tt()},style:{borderLeft:`1px solid ${o.headerBorder}`,overflow:"auto",background:o.appBg,minWidth:0,...Ue?{position:"fixed",inset:"0 0 0 auto",width:"min(90vw, 380px)",zIndex:95,boxShadow:"-12px 0 30px rgba(0,0,0,.18)"}:{}},children:[e.jsx(Ls,{t:o,children:"Inspector"}),X?e.jsx(Ns,{entity:X,detail:I,relationships:ot,t:o,onEdit:()=>H({kind:"entity",entity:X,dbtUniqueId:X.dbtUniqueId}),onEditDbtSource:()=>Ze(X),onSelectRelationship:m=>k(_t(s.modeling.relationships,m)),onDelete:()=>{Ne(null),Ke({kind:"entity",id:X.localId||X.id,domain:X.domain,areaId:X.areaId,label:X.businessName||X.localId||X.id})}}):je?e.jsx(Os,{relationship:je,t:o,onEdit:()=>H({kind:"relationship",relationship:je}),onDelete:()=>{Ne(null),Ke({kind:"relationship",id:je.localId||je.id,domain:je.ownerDomain??je.qualifiedId.split("::")[0],areaId:je.areaId,label:je.localId||je.id})}}):e.jsx(Es,{data:s,domainEntities:gt.map(({entity:m})=>m),domainRelationships:ot,t:o,onSelectRelationship:m=>k(_t(s.modeling.relationships,m))})]})]}),xe&&e.jsx(Ss,{editor:xe,data:s,selectedDomain:b,selectedArea:ee,t:o,onClose:()=>H(null),onApplied:async m=>{H(null),await Ae(),xe.kind==="entity"&&xe.relationshipFrom&&m.operation==="upsert_entity"&&H({kind:"relationship",draft:{...xe.relationshipFrom,to:m.value.id}})}}),Qe&&I&&e.jsx(As,{entity:Qe,detail:I,snapshotId:s.snapshotId,t:o,onClose:()=>Ze(null),onApplied:async()=>{Ze(null),await Ae()}}),ve&&e.jsx(ys,{pending:ve,busy:Xe,error:et,t:o,onCancel:()=>{Ke(null),Ne(null)},onConfirm:async()=>{ht(!0),Ne(null);try{const m={operation:ve.kind==="entity"?"remove_entity":"remove_relationship",value:{id:ve.id,domain:ve.domain,...ve.areaId?{areaId:ve.areaId}:{}}},z=await le.previewModelingChange(m,s.snapshotId);if(!z.patches.some(J=>J.changed))throw new Error("Nothing to remove — it is no longer in the domain source.");await le.applyModelingChange(m,z.fingerprint,s.snapshotId),Ke(null),k(null),await Ae()}catch(m){Ne(m instanceof Error?m.message:String(m))}finally{ht(!1)}}})]})}function ys({pending:t,busy:n,error:o,t:s,onCancel:i,onConfirm:r}){return e.jsx("div",{role:"dialog","aria-modal":"true","aria-label":`Delete ${t.kind}`,style:{position:"fixed",inset:0,background:"rgba(15,23,42,0.34)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:130},onClick:c=>{c.target===c.currentTarget&&!n&&i()},children:e.jsxs("div",{style:{width:"min(92vw, 420px)",background:s.appBg,border:`1px solid ${s.headerBorder}`,borderRadius:12,padding:18,boxShadow:"0 18px 44px rgba(0,0,0,.22)"},children:[e.jsxs("div",{style:{fontSize:14,fontWeight:700,color:s.textPrimary,marginBottom:6},children:["Delete this ",t.kind,"?"]}),e.jsxs("div",{style:{fontSize:12,color:s.textSecondary,lineHeight:1.5},children:[e.jsx("strong",{style:{fontFamily:s.fontMono},children:t.label})," will be removed from the"," ",e.jsx("strong",{children:t.domain})," domain source. dbt models and warehouse data are not affected."]}),t.kind==="entity"?e.jsx("div",{style:{fontSize:11.5,color:s.textMuted,marginTop:8,lineHeight:1.5},children:"Relationships that reference it are left in place and will report a missing endpoint until you remove or repoint them."}):null,o?e.jsx("div",{style:{fontSize:11.5,color:s.error,marginTop:10,lineHeight:1.5},children:o}):null,e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},children:[e.jsx(K,{t:s,onClick:i,disabled:n,children:"Cancel"}),e.jsx(K,{t:s,danger:!0,onClick:r,disabled:n,children:n?"Deleting…":`Delete ${t.kind}`})]})]})})}function bs({data:t,selectedDomain:n,onSelect:o,t:s}){const i=is(t.modeling.packages);return e.jsx("nav",{"aria-label":"Domain packages",children:e.jsx(Oo,{id:"domain-workspace-filter",ariaLabel:"Domain workspace",value:n??"",options:i.map(r=>({value:r.id,label:r.label})),onChange:r=>o(r||null),summary:e.jsxs(e.Fragment,{children:[i.length," domain",i.length===1?"":"s"," available"]}),t:s})})}function js({data:t,domain:n,active:o,onSelect:s,t:i}){var d;const r=n?[((d=t.domainAssets)==null?void 0:d[n])??{}]:Object.values(t.domainAssets??{}),l={diagram:nn(t.modeling,n).length,skills:r.reduce((u,h)=>{var g;return u+(((g=h.skills)==null?void 0:g.length)??0)},0),blocks:new Set(r.flatMap(u=>u.blocks??[])).size};return e.jsx("nav",{"aria-label":n?`${n} workspace`:"All domains workspace",style:{padding:"10px 7px 14px"},children:en.map((u,h)=>e.jsxs("div",{style:{marginTop:h===0?0:12},children:[u.label?e.jsx("div",{style:{padding:"0 8px 6px",color:i.textMuted,fontSize:9,fontWeight:800,textTransform:"uppercase",letterSpacing:".06em"},children:u.label}):null,u.items.map(g=>e.jsxs("button",{onClick:()=>s(g.id),"aria-current":o===g.id?"page":void 0,style:Us(i,o===g.id,!1),children:[ho(g.id,14,i,o===g.id),e.jsx("span",{style:{flex:1},children:g.label}),l[g.id]!==void 0&&e.jsx("small",{style:{color:o===g.id?i.accent:i.textMuted},children:l[g.id]})]},g.id))]},u.label??`group-${h}`))})}function ho(t,n,o,s=!1){const i=t==="blocks"?Zt:t==="diagram"||t==="dbt"?so:t==="knowledge"||t==="interfaces"?io:t==="skills"?Xt:t==="join-proofs"?Ge:t==="contracts"||t==="evaluations"?lo:t==="views"?co:t==="terms"||t==="notebooks"||t==="apps"?Bt:Fe;return e.jsx(i,{size:n,color:s?o.accent:o.textMuted})}function vs(t){var n;return t==="ai"?"Draft context":((n=en.flatMap(o=>o.items).find(o=>o.id===t))==null?void 0:n.label)??t}function Yn(){if(typeof window>"u")return{domain:null,section:"diagram",modelAreaId:null,selectedId:null};const t=new URL(window.location.href).searchParams,n=t.get("domainSection"),o=os(n)?n:"diagram";return{domain:t.get("domain"),section:o,modelAreaId:t.get("modelArea"),selectedId:o==="diagram"&&n==="diagram"?t.get("domainObject"):null}}function Mt(t,n,o=!1,s=null,i=null){if(typeof window>"u")return;const r=ss(window.location.href,{domain:t,section:n,modelAreaId:s,selectedId:i});o?window.history.replaceState(window.history.state,"",r):window.history.pushState(window.history.state,"",r)}function _t(t,n){const o=Object.entries(t).find(([,s])=>s===n);return o?o[0]:n.qualifiedId??n.id}function Ss({editor:t,data:n,selectedDomain:o,selectedArea:s,t:i,onClose:r,onApplied:c}){var Sn,wn,kn,Cn,In,Mn,zn,Bn,Dn,$n,Rn,Pn,Nn,An,On,En,Tn,qn,Ln,_n,Fn;const l=t.kind==="relationship"?t.relationship:void 0,d=t.kind==="entity"?t.entity:void 0,u=t.kind==="area"?t.area:void 0,h=t.kind==="relationship"?t.draft:void 0,[g,b]=a.useState((u==null?void 0:u.domain)??(d==null?void 0:d.domain)??o??Object.keys(n.modeling.packages)[0]??""),[x,y]=a.useState((u==null?void 0:u.localId)??((Sn=n.modeling.areas[(d==null?void 0:d.areaId)??(l==null?void 0:l.areaId)??""])==null?void 0:Sn.localId)??(s==null?void 0:s.localId)??""),[j,f]=a.useState((l==null?void 0:l.localId)??(d==null?void 0:d.localId)??(u==null?void 0:u.localId)??""),[k,I]=a.useState((l==null?void 0:l.owner)??(d==null?void 0:d.owner)??""),[v,D]=a.useState(""),[$,T]=a.useState(t.kind==="entity"?(d==null?void 0:d.dbtUniqueId)??t.dbtUniqueId??"":""),[Q,B]=a.useState((d==null?void 0:d.businessName)??""),[U,Y]=a.useState((d==null?void 0:d.businessContext)??""),[q,N]=a.useState(((wn=d==null?void 0:d.conceptRefs)==null?void 0:wn.join(", "))??""),[ne,ue]=a.useState((d==null?void 0:d.analyticalRole)??"unknown"),[S,C]=a.useState((d==null?void 0:d.status)??"draft"),[R,O]=a.useState((d==null?void 0:d.grain)??""),[W,Z]=a.useState((d==null?void 0:d.keys.join(", "))??""),[V,re]=a.useState((u==null?void 0:u.name)??""),[he,Re]=a.useState((u==null?void 0:u.description)??""),[ye,We]=a.useState((u==null?void 0:u.intentExamples.join(", "))??""),[be,ze]=a.useState((u==null?void 0:u.referencedEntityIds.map(p=>{var P;return((P=n.modeling.entities[p])==null?void 0:P.localId)??p}).join(", "))??""),[L,Se]=a.useState((l==null?void 0:l.from)??(h==null?void 0:h.from)??""),[M,oe]=a.useState((l==null?void 0:l.to)??(h==null?void 0:h.to)??""),[ae,He]=a.useState((l==null?void 0:l.keys.map(p=>`${p.from}=${p.to}`).join(", "))??(h!=null&&h.fromColumn&&h.toColumn?`${h.fromColumn}=${h.toColumn}`:"")),[Ue,Rt]=a.useState((l==null?void 0:l.cardinality)??"unknown"),[Pe,pt]=a.useState((l==null?void 0:l.fanout)??"unknown"),[xe,H]=a.useState((l==null?void 0:l.status)??"draft"),[Qe,Ze]=a.useState((l==null?void 0:l.verb)??""),[ve,Ke]=a.useState((l==null?void 0:l.description)??""),[Xe,ht]=a.useState(((kn=l==null?void 0:l.roles)==null?void 0:kn.from)??""),[et,Ne]=a.useState(((Cn=l==null?void 0:l.roles)==null?void 0:Cn.to)??""),[tt,nt]=a.useState(((In=l==null?void 0:l.optionality)==null?void 0:In.from)??"unknown"),[xt,Ae]=a.useState(((Mn=l==null?void 0:l.optionality)==null?void 0:Mn.to)??"unknown"),[X,je]=a.useState(((zn=l==null?void 0:l.joinTypes)==null?void 0:zn.join(", "))??"left"),[Oe,ee]=a.useState(((Bn=l==null?void 0:l.aggregation)==null?void 0:Bn.measuresFrom.join(", "))??""),[Be,Pt]=a.useState(((Dn=l==null?void 0:l.aggregation)==null?void 0:Dn.dimensionsFrom.join(", "))??""),[mt,Nt]=a.useState((($n=l==null?void 0:l.importRefs)==null?void 0:$n.join(", "))??""),[ft,Ee]=a.useState((l==null?void 0:l.attributionBlock)??""),[gt,ot]=a.useState((l==null?void 0:l.evidenceExpiresAt)??""),[yt,bt]=a.useState(""),[m,z]=a.useState(""),[J,De]=a.useState(""),[we,jt]=a.useState(""),[vt,sn]=a.useState(""),[St,ln]=a.useState(""),[rn,fo]=a.useState(""),[an,go]=a.useState(""),[dn,yo]=a.useState(""),[cn,bo]=a.useState(""),[un,jo]=a.useState(""),[pn,vo]=a.useState(""),[hn,So]=a.useState("internal"),[xn,wo]=a.useState(""),[wt,At]=a.useState(null),[Ot,ko]=a.useState(null),[Et,Ve]=a.useState(!1),[kt,Je]=a.useState(null),[Tt,st]=a.useState(l==null?void 0:l.validation),[Te,qt]=a.useState(null),[Lt,Co]=a.useState({}),[mn,Io]=a.useState(!!(l&&(l.roles||l.aggregation||(Rn=l.importRefs)!=null&&Rn.length||l.attributionBlock||l.evidenceExpiresAt)));a.useEffect(()=>{t.kind!=="relationship"||l||j||!L||!M||f(`${L}_to_${M}`.replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"").toLowerCase())},[t.kind,l,L,M,j]),a.useEffect(()=>{var P;if(t.kind!=="entity"||j||!$)return;const p=(P=n.dbtProvenance.nodes[$])==null?void 0:P.name;p&&f(p.replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"").toLowerCase())},[t.kind,j,$,n.dbtProvenance.nodes]),a.useEffect(()=>{if(t.kind!=="entity"||!$){qt(null);return}let p=!1;return le.getDbtModelingNode($).then(P=>{var E,se;p||(qt(P),Q||B(P.name.replace(/[_-]+/g," ").replace(/\b\w/g,te=>te.toUpperCase())),!R&&((E=P.dqlMeta)!=null&&E.grain)&&O(P.dqlMeta.grain),!W&&((se=P.dqlMeta)!=null&&se.keys.length)&&Z(P.dqlMeta.keys.join(", ")))}).catch(()=>{p||qt(null)}),()=>{p=!0}},[$,t.kind]),a.useEffect(()=>{if(t.kind!=="relationship")return;const P=[L,M].map(se=>{var te;return(te=n.modeling.entities[se])==null?void 0:te.dbtUniqueId}).filter(se=>!!se).filter(se=>!Lt[se]);if(!P.length)return;let E=!1;return le.getDbtModelingNodes(P).then(({details:se})=>{E||Co(te=>({...te,...Object.fromEntries(se.map(me=>[me.uniqueId,me]))}))}).catch(()=>{}),()=>{E=!0}},[t.kind,L,M]);const fn=()=>{if(t.kind==="domain")return{operation:"upsert_domain",value:{id:j,name:j,owner:k,parent:v||void 0,exports:[]}};if(t.kind==="area")return{operation:"upsert_area",value:{id:j,domain:g,name:V||j,description:he||void 0,intentExamples:G(ye),references:G(be)}};if(t.kind==="entity")return{operation:"upsert_entity",value:{id:j,domain:g,dbtModel:$,areaId:x||void 0,businessName:Q||void 0,businessContext:U||void 0,conceptRefs:G(q),analyticalRole:ne,status:S,owner:k||void 0,grain:R||void 0,keys:G(W)}};if(t.kind==="contract")return{operation:"upsert_contract",value:{id:j,domain:g,entities:G(yt),blocks:G(m),status:"draft",owner:k,requiredEvaluation:!0,purpose:J||void 0,metricRefs:G(we),dimensions:G(vt),allowedFilters:G(St),requiredFilters:G(rn),evaluationRefs:G(an)}};if(t.kind==="export")return{operation:"upsert_export",value:{id:j,domain:g,entity:dn||void 0,metrics:G(we),blocks:G(m),allowedKeys:G(cn),allowedDimensions:G(vt),allowedFilters:G(St),purposes:G(un),consumerDomains:G(pn),classification:hn||void 0,status:xe,owner:k||void 0}};if(t.kind==="import")return{operation:"upsert_import",value:{id:j||void 0,domain:g,exportRef:xn,purpose:J,status:xe,owner:k||void 0}};const p=Fs(ae),E=!l||l.from===L&&l.to===M&&JSON.stringify(l.keys)===JSON.stringify(p)&&l.cardinality===Ue&&l.fanout===Pe?Tt:void 0,se=xe==="certified"&&(E==null?void 0:E.status)!=="passed"?"review":xe,te=n.modeling.entities[L],me=n.modeling.entities[M];return{operation:"upsert_relationship",value:{id:j,domain:g,areaId:x||void 0,from:L,to:M,keys:p,cardinality:Ue,fanout:Pe,status:se,owner:k||void 0,ownerDomain:g,verb:Qe||void 0,description:ve||void 0,roles:Xe||et?{from:Xe||void 0,to:et||void 0}:void 0,optionality:{from:tt,to:xt},joinTypes:G(X),aggregation:Oe||Be?{measuresFrom:G(Oe),dimensionsFrom:G(Be),requiresPreAggregation:Pe!=="safe"}:void 0,attributionBlock:ft||void 0,importRefs:G(mt),evidenceExpiresAt:gt||void 0,crossDomain:(te==null?void 0:te.domain)!==(me==null?void 0:me.domain),validation:E,certifiedAgainst:se==="certified"&&(te!=null&&te.grain)&&(me!=null&&me.grain)?{from:{grain:te.grain,keys:te.keys},to:{grain:me.grain,keys:me.keys}}:void 0}}},Mo=async()=>{try{Ve(!0),Je(null);const p=fn();ko(p),At(await le.previewModelingChange(p,n.snapshotId))}catch(p){Je(p instanceof Error?p.message:String(p))}finally{Ve(!1)}},zo=async()=>{try{Ve(!0),Je(null);const p=fn();if(p.operation!=="upsert_relationship")return;const P=await le.validateModelingRelationship(p.value,n.snapshotId);st(P),Je(P.status==="passed"?"Warehouse proof passed. Preview the source change to save it.":P.message??"Validation failed."),At(null)}catch(p){Je(p instanceof Error?p.message:String(p))}finally{Ve(!1)}},Bo=async()=>{if(!(!wt||!Ot))try{Ve(!0),await le.applyModelingChange(Ot,wt.fingerprint,n.snapshotId),await c(Ot)}catch(p){Je(p instanceof Error?p.message:String(p))}finally{Ve(!1)}},gn=Object.entries(n.modeling.entities).map(([p,P])=>{const E=n.dbtProvenance.nodes[P.dbtUniqueId];return{value:p,label:P.businessName||P.localId||P.id,description:`${P.domain} · ${(E==null?void 0:E.relation)??(E==null?void 0:E.name)??P.dbtUniqueId}`,keywords:[P.qualifiedId,P.businessContext??"",P.analyticalRole??""]}}),qe=Lt[((Pn=n.modeling.entities[L])==null?void 0:Pn.dbtUniqueId)??""],Le=Lt[((Nn=n.modeling.entities[M])==null?void 0:Nn.dbtUniqueId)??""],yn=((qe==null?void 0:qe.columns)??[]).map(p=>({value:p.name,label:p.name,description:[p.type,p.description].filter(Boolean).join(" · ")||"dbt column"})),bn=((Le==null?void 0:Le.columns)??[]).map(p=>({value:p.name,label:p.name,description:[p.type,p.description].filter(Boolean).join(" · ")||"dbt column"})),Ct=yn.map(p=>p.value).filter(p=>bn.some(P=>P.value.toLowerCase()===p.toLowerCase())).slice(0,5),$e=ae?ae.split(",").map(p=>{const[P="",E=""]=p.split("=").map(se=>se.trim());return{from:P,to:E}}):[{from:"",to:""}],jn=(p,P,E)=>{const se=$e.map((te,me)=>me===p?{...te,[P]:E}:te);He(se.map(te=>`${te.from}=${te.to}`).join(", ")),st(void 0)},Do=p=>{const P=$e.filter((E,se)=>se!==p);He(P.map(E=>`${E.from}=${E.to}`).join(", ")),st(void 0)},$o=()=>He([...$e.filter(p=>p.from||p.to),{from:"",to:""}].map(p=>`${p.from}=${p.to}`).join(", ")),vn=t.kind==="entity"?!!(g&&j&&$):t.kind==="relationship"?!!(g&&j&&L&&M&&$e.some(p=>p.from&&p.to)&&$e.every(p=>p.from&&p.to)):!0,Ro=t.kind==="domain"?"Create Domain Package":t.kind==="area"?u?"Edit model area":"Create model area":t.kind==="entity"?d?"Edit business entity":"Add dbt model":t.kind==="contract"?"Create analytical contract":t.kind==="export"?"Publish domain export":t.kind==="import"?"Request domain import":l?"Edit relationship":"Create relationship";return e.jsx(mo,{title:Ro,t:i,onClose:r,children:wt?e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 12px",fontSize:12,color:i.textSecondary},children:"Review the exact Domain Package source change before it is written."}),wt.patches.map(p=>e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("strong",{style:{fontSize:12},children:p.path}),e.jsx("pre",{style:Hs(i),children:p.after})]},p.path)),kt&&e.jsx(ce,{text:kt,t:i}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(K,{t:i,onClick:()=>At(null),children:"Back"}),e.jsx(K,{primary:!0,t:i,onClick:()=>void Bo(),disabled:Et,children:"Apply to Domain Package"})]})]}):e.jsxs("div",{style:{display:"grid",gap:12},children:[t.kind!=="domain"&&e.jsx(w,{label:"Domain",children:e.jsx(de,{value:g,onChange:b,values:Object.keys(n.modeling.packages),t:i})}),t.kind!=="relationship"&&e.jsx(w,{label:t.kind==="entity"?"Entity id":t.kind==="area"?"Area id":t.kind==="contract"?"Contract id":t.kind==="export"?"Export id":t.kind==="import"?"Import id (optional)":"Domain id",children:e.jsx(A,{value:j,onChange:f,t:i,placeholder:"stable_snake_case_id"})}),t.kind==="domain"&&e.jsx(w,{label:"Parent domain (optional)",children:e.jsx(de,{value:v,onChange:D,values:Object.keys(n.modeling.packages),t:i})}),t.kind==="area"&&e.jsxs(e.Fragment,{children:[e.jsx(ce,{text:"A Model Area is one small, reviewable source file. It filters the same domain graph; it never creates a competing semantic model.",t:i}),e.jsx(w,{label:"Area name",children:e.jsx(A,{value:V,onChange:re,t:i,placeholder:"Customer lifecycle"})}),e.jsx(w,{label:"Business question or scope",children:e.jsx(A,{value:he,onChange:Re,t:i,placeholder:"How customers progress from first order to repeat purchase."})}),e.jsx(w,{label:"Example questions (comma-separated)",children:e.jsx(A,{value:ye,onChange:We,t:i,placeholder:"Which customers made a second purchase?"})}),e.jsx(w,{label:"Read-only boundary entities (comma-separated)",children:e.jsx(A,{value:be,onChange:ze,t:i,placeholder:"customer"})})]}),t.kind==="entity"&&e.jsxs(e.Fragment,{children:[e.jsx(to,{current:$?2:1,labels:["Find dbt model","Add business meaning","Review source change"],t:i}),e.jsx(ce,{text:"Search by model name, relation, or source path. Results stay bounded even when the dbt project has thousands of models.",t:i}),e.jsx(w,{label:"Model area",children:e.jsx(de,{value:x,onChange:y,values:Object.values(n.modeling.areas).filter(p=>p.domain===g).map(p=>p.localId),labels:Object.fromEntries(Object.values(n.modeling.areas).filter(p=>p.domain===g).map(p=>[p.localId,p.name])),t:i})}),e.jsx(w,{label:"dbt model",children:e.jsx(Ts,{value:$,onChange:T,selectedNode:n.dbtProvenance.nodes[$],domain:g,t:i})}),Te&&e.jsx(no,{title:Te.name,detail:`${Te.relation??Te.uniqueId} · ${Te.columns.length} columns${(An=Te.dqlMeta)!=null&&An.grain?` · grain: ${Te.dqlMeta.grain}`:""}`,t:i}),e.jsx(w,{label:"Business name",children:e.jsx(A,{value:Q,onChange:B,t:i,placeholder:"Customer order"})}),e.jsx(w,{label:"Business context",children:e.jsx(A,{value:U,onChange:Y,t:i,placeholder:"One order used to understand repeat purchasing and revenue."})}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Business concepts",children:e.jsx(A,{value:q,onChange:N,t:i,placeholder:"customer_lifecycle, revenue"})}),e.jsx(w,{label:"Analytical role",children:e.jsx(de,{value:ne,onChange:p=>ue(p),values:["event","dimension","snapshot","bridge","unknown"],t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Grain override (optional)",children:e.jsx(A,{value:R,onChange:O,t:i,placeholder:"Use dbt meta.dql by default"})}),e.jsx(w,{label:"Key overrides (optional)",children:e.jsx(A,{value:W,onChange:Z,t:i,placeholder:"customer_id, order_id"})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Lifecycle",children:e.jsx(de,{value:S,onChange:p=>C(p),values:["draft","review","certified","deprecated"],t:i})}),e.jsx(w,{label:"Owner",children:e.jsx(A,{value:k,onChange:I,t:i,placeholder:"team@company.com"})})]})]}),t.kind==="relationship"&&e.jsxs(e.Fragment,{children:[e.jsx(to,{current:!L||!M?1:$e.some(p=>p.from&&p.to)?3:2,labels:["Choose models","Match join keys","Review policy"],t:i}),e.jsx(ce,{text:"Search business names or dbt relations, then match columns from only those two models. DQL keeps the relationship in draft until warehouse validation passes.",t:i}),e.jsx(w,{label:"Model area",children:e.jsx(de,{value:x,onChange:y,values:Object.values(n.modeling.areas).filter(p=>p.domain===g).map(p=>p.localId),labels:Object.fromEntries(Object.values(n.modeling.areas).filter(p=>p.domain===g).map(p=>[p.localId,p.name])),t:i})}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"From entity",children:e.jsx(zt,{ariaLabel:"From entity",value:L,onChange:p=>{Se(p),st(void 0)},options:gn,placeholder:"Search source model…",t:i})}),e.jsx(w,{label:"To entity",children:e.jsx(zt,{ariaLabel:"To entity",value:M,onChange:p=>{oe(p),st(void 0)},options:gn.filter(p=>p.value!==L),placeholder:"Search target model…",t:i})})]}),L&&M&&e.jsx(no,{title:`${((On=n.modeling.entities[L])==null?void 0:On.businessName)||((En=n.modeling.entities[L])==null?void 0:En.localId)} → ${((Tn=n.modeling.entities[M])==null?void 0:Tn.businessName)||((qn=n.modeling.entities[M])==null?void 0:qn.localId)}`,detail:`${(qe==null?void 0:qe.columns.length)??0} source columns · ${(Le==null?void 0:Le.columns.length)??0} target columns`,t:i}),e.jsx(w,{label:"Join keys",children:e.jsxs("div",{style:{display:"grid",gap:8},children:[Ct.length>0&&!$e.some(p=>p.from&&p.to)&&e.jsxs("button",{type:"button",onClick:()=>He(`${Ct[0]}=${Ct[0]}`),style:{..._e(i),justifySelf:"start"},children:[e.jsx(ro,{size:13})," Use exact match: ",Ct[0]]}),$e.map((p,P)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) 24px minmax(0, 1fr) 30px",gap:7,alignItems:"center"},children:[e.jsx(zt,{ariaLabel:`Source join column ${P+1}`,value:p.from,onChange:E=>jn(P,"from",E),options:yn,placeholder:L?"Source column…":"Choose source first",disabled:!L||!qe,t:i}),e.jsx("span",{"aria-hidden":"true",style:{color:i.textMuted,textAlign:"center"},children:"→"}),e.jsx(zt,{ariaLabel:`Target join column ${P+1}`,value:p.to,onChange:E=>jn(P,"to",E),options:bn,placeholder:M?"Target column…":"Choose target first",disabled:!M||!Le,t:i}),e.jsx("button",{type:"button","aria-label":"Remove join key",title:"Remove join key",onClick:()=>Do(P),style:fe(i),children:e.jsx(ut,{size:14})})]},`${P}:${p.from}:${p.to}`)),e.jsxs("button",{type:"button",onClick:$o,style:{..._e(i),justifySelf:"start"},children:[e.jsx(ke,{size:13})," Add key pair"]})]})}),j&&e.jsxs("div",{style:{color:i.textMuted,fontSize:9.5},children:["Relationship id: ",e.jsx("code",{children:j})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Cardinality",children:e.jsx(de,{value:Ue,onChange:p=>Rt(p),values:["unknown","one_to_one","one_to_many","many_to_one","many_to_many"],t:i})}),e.jsx(w,{label:"Fanout policy",children:e.jsx(de,{value:Pe,onChange:p=>pt(p),values:["safe","attribution_required","unsafe","unknown"],t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Business verb (optional)",children:e.jsx(A,{value:Qe,onChange:Ze,t:i,placeholder:"belongs to"})}),e.jsx(w,{label:"Description (optional)",children:e.jsx(A,{value:ve,onChange:Ke,t:i,placeholder:"Why this relationship exists"})})]}),L&&M&&((Ln=n.modeling.entities[L])==null?void 0:Ln.domain)!==((_n=n.modeling.entities[M])==null?void 0:_n.domain)&&e.jsx(ce,{text:"This is a cross-domain relationship. Add the approved provider import in Advanced governance before certification.",t:i}),e.jsx("button",{type:"button",onClick:()=>Io(p=>!p),style:{..._e(i),justifySelf:"start",padding:"6px 0"},children:mn?"Hide advanced governance":"Advanced governance and aggregation"}),mn&&e.jsxs("div",{style:{display:"grid",gap:12,padding:12,border:`1px solid ${i.headerBorder}`,borderRadius:8,background:i.cellBg},children:[e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Allowed join types",children:e.jsx(A,{value:X,onChange:je,t:i,placeholder:"left, inner"})}),e.jsx(w,{label:"Lifecycle",children:e.jsx(de,{value:xe??"draft",onChange:p=>H(p),values:["draft","review","certified","deprecated"],t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"From role",children:e.jsx(A,{value:Xe,onChange:ht,t:i})}),e.jsx(w,{label:"To role",children:e.jsx(A,{value:et,onChange:Ne,t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"From optionality",children:e.jsx(de,{value:tt,onChange:p=>nt(p),values:["required","optional","unknown"],t:i})}),e.jsx(w,{label:"To optionality",children:e.jsx(de,{value:xt,onChange:p=>Ae(p),values:["required","optional","unknown"],t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Measures allowed from",children:e.jsx(A,{value:Oe,onChange:ee,t:i,placeholder:"order"})}),e.jsx(w,{label:"Dimensions allowed from",children:e.jsx(A,{value:Be,onChange:Pt,t:i,placeholder:"customer"})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Required import refs",children:e.jsx(A,{value:mt,onChange:Nt,t:i,placeholder:"commerce.customer@1"})}),e.jsx(w,{label:"Attribution block",children:e.jsx(A,{value:ft,onChange:Ee,t:i,placeholder:"growth.revenue_by_channel"})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Evidence expires",children:e.jsx(A,{value:gt,onChange:ot,t:i,placeholder:"2026-12-31"})}),e.jsx(w,{label:"Owner",children:e.jsx(A,{value:k,onChange:I,t:i,placeholder:"team@company.com"})})]})]}),Tt&&e.jsx(xo,{evidence:Tt,t:i})]}),t.kind==="contract"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Covered entities",children:e.jsx(A,{value:yt,onChange:bt,t:i,placeholder:"order, customer"})}),e.jsx(w,{label:"Certified blocks",children:e.jsx(A,{value:m,onChange:z,t:i,placeholder:"orders_360"})}),e.jsx(w,{label:"Decision purpose",children:e.jsx(A,{value:J,onChange:De,t:i,placeholder:"Revenue reporting"})}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Metrics",children:e.jsx(A,{value:we,onChange:jt,t:i})}),e.jsx(w,{label:"Dimensions",children:e.jsx(A,{value:vt,onChange:sn,t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Allowed filters",children:e.jsx(A,{value:St,onChange:ln,t:i})}),e.jsx(w,{label:"Required filters",children:e.jsx(A,{value:rn,onChange:fo,t:i})})]}),e.jsx(w,{label:"Evaluation refs",children:e.jsx(A,{value:an,onChange:go,t:i,placeholder:"revenue_accuracy"})})]}),t.kind==="export"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Exported entity",children:e.jsx(de,{value:dn,onChange:yo,values:Object.keys(n.modeling.entities).filter(p=>{var P;return((P=n.modeling.entities[p])==null?void 0:P.domain)===g}),t:i})}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Allowed keys",children:e.jsx(A,{value:cn,onChange:bo,t:i})}),e.jsx(w,{label:"Allowed dimensions",children:e.jsx(A,{value:vt,onChange:sn,t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Metrics",children:e.jsx(A,{value:we,onChange:jt,t:i})}),e.jsx(w,{label:"Blocks",children:e.jsx(A,{value:m,onChange:z,t:i})})]}),e.jsx(w,{label:"Allowed filters",children:e.jsx(A,{value:St,onChange:ln,t:i})}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Approved purposes",children:e.jsx(A,{value:un,onChange:jo,t:i,placeholder:"revenue reporting"})}),e.jsx(w,{label:"Consumer domains",children:e.jsx(A,{value:pn,onChange:vo,t:i,placeholder:"growth"})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Classification",children:e.jsx(A,{value:hn,onChange:So,t:i})}),e.jsx(w,{label:"Lifecycle",children:e.jsx(de,{value:xe??"draft",onChange:p=>H(p),values:["draft","review","certified","deprecated"],t:i})})]})]}),t.kind==="import"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Provider export",children:e.jsx(de,{value:xn,onChange:wo,values:Object.values(((Fn=n.modeling.interfaces)==null?void 0:Fn.exports)??{}).map(p=>`${p.domain}.${p.localId}@${p.version}`),t:i})}),e.jsx(w,{label:"Exact analytical purpose",children:e.jsx(A,{value:J,onChange:De,t:i,placeholder:"Revenue by acquisition channel"})}),e.jsx(w,{label:"Lifecycle",children:e.jsx(de,{value:xe??"draft",onChange:p=>H(p),values:["draft","review","certified","deprecated"],t:i})})]}),t.kind!=="entity"&&t.kind!=="relationship"&&t.kind!=="area"&&e.jsx(w,{label:"Owner",children:e.jsx(A,{value:k,onChange:I,t:i,placeholder:"team@company.com"})}),kt&&e.jsx(ce,{text:kt,t:i}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[t.kind==="relationship"&&e.jsxs(K,{t:i,onClick:()=>void zo(),disabled:Et||!vn,children:[e.jsx(lo,{size:14})," Validate in warehouse"]}),e.jsx(K,{primary:!0,t:i,onClick:()=>void Mo(),disabled:Et||!vn,children:"Preview source change"})]})]})})}function ws({data:t,domain:n,t:o,onOpen:s}){var l,d,u;const i=Object.values(t.modeling.entities).filter(h=>!n||h.domain===n),r=n?t.modeling.packages[n]:void 0,c=n?((l=t.domainAssets)==null?void 0:l[n])??{}:Object.values(t.domainAssets??{}).reduce((h,g)=>{for(const[b,x]of Object.entries(g))h[b]=[...h[b]??[],...x];return h},{});return e.jsxs(Ie,{children:[e.jsx(Me,{title:(r==null?void 0:r.id)??"Domains",detail:r?"Business context for reusable blocks, safe models, and agent instructions.":"Choose a domain to work with its blocks, modeling, and skills.",t:o}),r&&e.jsxs("div",{style:{display:"grid",gap:16,maxWidth:980},children:[e.jsxs("section",{style:{border:`1px solid ${o.headerBorder}`,borderRadius:8,background:o.cellBg,display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(175px, 1fr))"},children:[e.jsx(Ft,{label:"Owner",value:r.owner??"Not declared",t:o}),e.jsx(Ft,{label:"Parent",value:r.parent??"Top-level domain",t:o}),e.jsx(Ft,{label:"Source",value:r.filePath,t:o})]}),e.jsxs("section",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[e.jsx("h3",{style:{margin:0,fontSize:12},children:"Continue building"}),e.jsxs("span",{style:{color:o.textMuted,fontSize:10},children:["Everything here is scoped to ",r.id,"."]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(190px, 1fr))",gap:8},children:[{id:"blocks",title:"Blocks",count:((d=c.blocks)==null?void 0:d.length)??0,detail:"Reusable analytics.",icon:e.jsx(Zt,{size:16})},{id:"diagram",title:"Modeling",count:i.length,detail:"Models and relationships.",icon:e.jsx(so,{size:16})},{id:"knowledge",title:"Knowledge 360",count:Object.values(t.modeling.relationships).filter(h=>{var g,b;return((g=t.modeling.entities[h.from])==null?void 0:g.domain)===n||((b=t.modeling.entities[h.to])==null?void 0:b.domain)===n}).length,detail:"Governed routes and evidence.",icon:e.jsx(io,{size:16})},{id:"skills",title:"Skills",count:((u=c.skills)==null?void 0:u.length)??0,detail:"Agent instructions.",icon:e.jsx(Xt,{size:16})}].map(h=>e.jsxs("button",{type:"button",onClick:()=>s(h.id),style:Ks(o),children:[e.jsx("span",{style:{display:"grid",placeItems:"center",width:28,height:28,borderRadius:6,color:o.accent,background:`${o.accent}12`},children:h.icon}),e.jsxs("span",{style:{flex:1,minWidth:0,display:"grid",gap:2,textAlign:"left"},children:[e.jsx("b",{style:{fontSize:11},children:h.title}),e.jsx("span",{style:{color:o.textSecondary,fontSize:10},children:h.detail})]}),e.jsx("strong",{style:{color:o.accent,fontSize:16},children:h.count})]},h.id))})]})]})]})}function Ft({label:t,value:n,t:o}){return e.jsxs("div",{style:{minWidth:0,padding:"10px 12px",borderRight:`1px solid ${o.headerBorder}`},children:[e.jsx("div",{style:{color:o.textMuted,fontSize:9,fontWeight:800,textTransform:"uppercase",letterSpacing:".05em"},children:t}),e.jsx("div",{title:n,style:{marginTop:4,color:o.textSecondary,fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n})]})}function ks({search:t,onSearch:n,items:o,onPick:s,t:i}){var b;const[r,c]=a.useState(!1),l=a.useRef(null),d=t.trim().toLowerCase(),u=d?o.filter(x=>x.label.toLowerCase().includes(d)||x.sublabel.toLowerCase().includes(d)).sort((x,y)=>x.type===y.type?x.label.localeCompare(y.label):x.type==="model"?-1:1).slice(0,14):[],h=x=>x==="dimension"?"var(--status-success)":x==="bridge"?"var(--status-warning)":x==="event"||x==="snapshot"?"var(--accent)":"var(--text-tertiary)",g=r&&d?(b=l.current)==null?void 0:b.getBoundingClientRect():void 0;return e.jsxs("label",{ref:l,style:{position:"relative",width:210,flex:"0 0 210px"},children:[e.jsx($t,{size:12,style:{position:"absolute",left:7,top:8,color:i.textMuted}}),e.jsx("input",{"aria-label":"Search diagram",value:t,onChange:x=>{n(x.target.value),c(!0)},onFocus:()=>c(!0),placeholder:"Find model or column",style:{...ge(i),padding:"6px 7px 6px 24px"}}),g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>c(!1),style:{position:"fixed",inset:0,zIndex:60}}),e.jsx("div",{style:{position:"fixed",top:g.bottom+5,left:g.left,zIndex:61,width:300,maxHeight:340,overflow:"auto",background:i.cellBg,border:`1px solid ${i.headerBorder}`,borderRadius:9,boxShadow:"0 12px 30px rgba(26,26,26,0.16)",padding:4},children:u.length===0?e.jsx("div",{style:{padding:"10px 10px",fontSize:11.5,color:i.textMuted,fontFamily:i.font},children:"No matching model or column."}):u.map((x,y)=>e.jsxs("button",{type:"button",onMouseDown:j=>{j.preventDefault(),s(x.recordKey),c(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:8,textAlign:"left",padding:"7px 8px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:i.font},children:[e.jsx("span",{style:{width:7,height:7,borderRadius:999,background:h(x.role),flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:12,fontWeight:x.type==="model"?650:500,color:i.textPrimary,fontFamily:i.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.label}),e.jsx("span",{style:{flexShrink:0,fontSize:9,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:i.textMuted},children:x.type==="model"?"model":x.sublabel})]},`${x.type}-${x.recordKey}-${x.label}-${y}`))})]})]})}function Cs({modelingView:t,columnMode:n,search:o,layoutMode:s,density:i,visibleLimit:r,totalEntities:c,dimUnrelated:l,showEdgeLabels:d,showLegend:u,fullscreen:h,onBindModel:g,onRelationship:b,onNewArea:x,onModelingView:y,onColumnMode:j,onSearch:f,searchItems:k,onPickModel:I,onLayoutMode:v,onDensity:D,onVisibleLimit:$,onDimUnrelated:T,onEdgeLabels:Q,onLegend:B,onFullscreen:U,onExport:Y,onReset:q,t:N}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minHeight:50,padding:"0 10px",borderBottom:`1px solid ${N.headerBorder}`,background:N.headerBg,flexWrap:"nowrap",overflowX:"auto",scrollbarWidth:"thin"},children:[e.jsxs("div",{role:"group","aria-label":"Modeling view",style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,border:`1px solid ${N.headerBorder}`,borderRadius:7,background:N.appBg,flexShrink:0},children:[e.jsx("button",{type:"button",onClick:()=>y("business"),style:{border:"none",borderRadius:5,padding:"4px 11px",fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:N.font,whiteSpace:"nowrap",background:t==="business"?"var(--accent-dim)":"transparent",color:t==="business"?N.accent:N.textMuted},children:"Business modeling"}),e.jsx("button",{type:"button",onClick:()=>y("data"),style:{border:"none",borderRadius:5,padding:"4px 11px",fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:N.font,whiteSpace:"nowrap",background:t==="data"?"var(--accent-dim)":"transparent",color:t==="data"?N.accent:N.textMuted},children:"Data modeling"})]}),e.jsxs("button",{type:"button",onClick:g,style:Ut(N,!0),children:[e.jsx(ke,{size:13})," Add model"]}),e.jsxs("button",{type:"button",onClick:b,style:Ut(N),children:[e.jsx(Ge,{size:13})," Connect"]}),e.jsxs("button",{type:"button",onClick:x,style:Ut(N),children:[e.jsx(Fe,{size:13})," New area"]}),t==="data"&&e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:5,color:N.textMuted,fontSize:10},children:[e.jsx(co,{size:13}),e.jsxs("select",{"aria-label":"Visible columns",value:n,onChange:ne=>j(ne.target.value),style:{...ge(N),width:104,padding:"5px 6px"},children:[e.jsx("option",{value:"keys",children:"Keys only"}),e.jsx("option",{value:"relevant",children:"Relevant"}),e.jsx("option",{value:"all",children:"All columns"})]})]}),e.jsx(ks,{search:o,onSearch:f,items:k,onPick:I,t:N}),e.jsxs("select",{"aria-label":"Diagram layout",value:s,onChange:ne=>{v(ne.target.value),q()},style:{...ge(N),width:94,padding:"5px 6px"},children:[e.jsx("option",{value:"auto",children:"Auto"}),e.jsx("option",{value:"grid",children:"Grid"}),e.jsx("option",{value:"star",children:"Star"})]}),e.jsxs("select",{"aria-label":"Diagram density",value:i,onChange:ne=>D(ne.target.value),style:{...ge(N),width:92,padding:"5px 6px"},children:[e.jsx("option",{value:"compact",children:"Compact"}),e.jsx("option",{value:"normal",children:"Normal"}),e.jsx("option",{value:"wide",children:"Wide"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:4,color:N.textMuted,fontSize:9.5},children:["Canvas ",e.jsxs("select",{"aria-label":"Visible model limit",value:r||50,onChange:ne=>$(Number(ne.target.value)),style:{...ge(N),width:94,padding:"5px 6px"},children:[e.jsx("option",{value:25,children:"25 models"}),e.jsx("option",{value:50,children:"50 models"}),e.jsx("option",{value:100,children:"100 models"}),e.jsx("option",{value:200,children:"200 max"})]})]}),e.jsx("button",{"aria-label":"Dim unrelated models",title:"Dim unrelated models",onClick:()=>T(!l),style:{...fe(N),color:l?N.accent:N.textMuted},children:e.jsx(Eo,{size:14})}),e.jsx("button",{"aria-label":"Toggle relationship labels",title:"Toggle relationship labels",onClick:()=>Q(!d),style:{...fe(N),color:d?N.accent:N.textMuted},children:e.jsx(Ge,{size:14})}),e.jsx("button",{"aria-label":"Relationship legend",title:"Relationship legend",onClick:()=>B(!u),style:{...fe(N),color:u?N.accent:N.textMuted},children:e.jsx(Fe,{size:14})}),e.jsx("button",{"aria-label":"Export diagram as SVG",title:"Export diagram as SVG",onClick:Y,style:fe(N),children:e.jsx(To,{size:14})}),e.jsx("button",{"aria-label":h?"Exit fullscreen":"Fullscreen diagram",title:h?"Exit fullscreen":"Fullscreen diagram",onClick:U,style:fe(N),children:h?e.jsx(ut,{size:14}):e.jsx(ao,{size:14})}),e.jsx("button",{"aria-label":"Reset to automatic layout",title:"Reset to automatic layout",onClick:q,style:fe(N),children:e.jsx(Qo,{size:14})})]})}function Is({t}){return e.jsxs("div",{style:{display:"flex",gap:14,padding:"7px 12px",borderBottom:`1px solid ${t.headerBorder}`,background:t.headerBg,color:t.textSecondary,fontSize:9.5},children:[[["Safe certified","#2e9b63"],["Validated review","#5b73d6"],["Attribution / draft","#9a6b2f"],["Stale certification","#d47822"]].map(([n,o])=>e.jsxs("span",{style:{display:"flex",gap:5,alignItems:"center"},children:[e.jsx("i",{style:{display:"inline-block",width:18,height:3,background:o,borderRadius:2}}),n]},n)),e.jsx("span",{style:{marginLeft:"auto"},children:"1:1 · 1:N · N:1 · N:N"})]})}function Ms(){const t=document.querySelector("#dql-modeling-diagram .react-flow__renderer");if(!(t instanceof HTMLElement))return;const n=t.cloneNode(!0),o=t.getBoundingClientRect(),s=new XMLSerializer().serializeToString(n),i=`<svg xmlns="http://www.w3.org/2000/svg" width="${Math.ceil(o.width)}" height="${Math.ceil(o.height)}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${s}</div></foreignObject></svg>`,r=URL.createObjectURL(new Blob([i],{type:"image/svg+xml"})),c=document.createElement("a");c.href=r,c.download="dql-domain-model.svg",c.click(),URL.revokeObjectURL(r)}function Wt({data:t,domain:n,kinds:o,title:s,detail:i,t:r}){var l;const c=n?((l=t.domainAssets)==null?void 0:l[n])??{}:Object.values(t.domainAssets??{}).reduce((d,u)=>{for(const[h,g]of Object.entries(u))d[h]=[...d[h]??[],...g];return d},{});return e.jsxs(Ie,{children:[e.jsx(Me,{title:s,detail:i,t:r}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(250px, 1fr))",gap:12},children:o.map(d=>{var u,h;return e.jsxs("section",{style:ct(r),children:[e.jsxs("div",{style:{display:"flex",gap:7,alignItems:"center"},children:[e.jsx(Bt,{size:14,color:r.accent}),e.jsx("b",{style:{textTransform:"capitalize"},children:d}),e.jsx(Ye,{t:r,children:((u=c[d])==null?void 0:u.length)??0})]}),(h=c[d])!=null&&h.length?c[d].map(g=>e.jsx("code",{style:{display:"block",padding:"7px 0",borderBottom:`1px solid ${r.headerBorder}`,color:r.textSecondary,fontSize:10},children:g},g)):e.jsxs("p",{style:{color:r.textMuted,fontSize:11},children:["No ",d," in this domain yet."]})]},d)})})]})}function zs({data:t,domain:n,t:o}){var g,b;const{state:s,dispatch:i}=Qt(),[r,c]=a.useState(null),[l,d]=a.useState(null),u=[...new Set(n?((b=(g=t.domainAssets)==null?void 0:g[n])==null?void 0:b.blocks)??[]:Object.values(t.domainAssets??{}).flatMap(x=>x.blocks??[]))].sort(),h=async x=>{c(x),d(null);try{if(n)try{window.localStorage.setItem("dql.block-studio.domain",n)}catch{}const y=s.files.find(f=>f.path===x)??{name:x.split("/").at(-1)??x,path:x,type:"block",folder:x.split("/").slice(0,-1).join("/")};s.files.some(f=>f.path===x)||i({type:"FILE_ADDED",file:y});const j=await le.openBlockStudio(x);i({type:"OPEN_BLOCK_STUDIO",file:y,payload:j})}catch(y){d(y instanceof Error?y.message:String(y))}finally{c(null)}};return e.jsxs(Ie,{children:[e.jsx(Me,{title:"Blocks",detail:n?`Reusable blocks owned by ${n}. Select one to open the exact source in Block Studio.`:"All reusable blocks grouped across the current Domain Packages. Select one to open the exact source in Block Studio.",t:o}),l?e.jsx(ce,{text:l,t:o}):null,u.length?e.jsx("div",{style:{display:"grid",gap:10},children:u.map(x=>{var f;const y=(x.split("/").at(-1)??x).replace(/\.dql$/i,""),j=(f=Object.entries(t.domainAssets??{}).find(([,k])=>{var I;return(I=k.blocks)==null?void 0:I.includes(x)}))==null?void 0:f[0];return e.jsxs("button",{type:"button",onClick:()=>void h(x),"aria-label":`Open block ${y}`,style:{...ct(o),width:"100%",textAlign:"left",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Zt,{size:14,color:o.accent}),e.jsx("b",{children:y}),n?null:e.jsx(Ye,{t:o,children:j??"shared"}),r===x?e.jsx(Ye,{t:o,children:"Opening…"}):null]}),e.jsx("code",{style:{display:"block",marginTop:7,color:o.textMuted,fontSize:10},children:x})]},x)})}):e.jsx(Ce,{title:"No domain blocks yet",detail:"Create a block in Block Studio and assign this domain to make it appear here.",t:o})]})}function Qn({data:t,domain:n,kind:o,t:s}){var k,I;const{state:i,dispatch:r}=Qt(),[c,l]=a.useState([]),[d,u]=a.useState(!0),[h,g]=a.useState(null),[b,x]=a.useState(null);a.useEffect(()=>{let v=!0;return u(!0),(n?le.getRelatedDomainProducts(n):le.getAllRelatedDomainProducts()).then(D=>{v&&l(D[o])}).catch(()=>{v&&l([])}).finally(()=>{v&&u(!1)}),()=>{v=!1}},[n,o]);const y=n?((I=(k=t.domainAssets)==null?void 0:k[n])==null?void 0:I[o])??[]:Object.values(t.domainAssets??{}).flatMap(v=>v[o]??[]),j=o==="notebooks"?"Notebooks":"Apps",f=async v=>{const D=String(v.id??v.filePath??v.title??v.name??"product");g(D),x(null);try{if(o==="apps"){const U=String(v.id??Zn(String(v.filePath??"")));if(!U)throw new Error("This App has no stable id to open.");r({type:"OPEN_APP",appId:U,experience:"view",section:"dashboards"});return}const $=String(v.filePath??"");if(!$)throw new Error("This Notebook has no source path to open.");const T=i.files.find(U=>U.path===$)??{name:$.split("/").at(-1)??String(v.title??D),path:$,type:"notebook",folder:$.split("/").slice(0,-1).join("/"),...typeof v.ownerDomain=="string"?{ownerDomain:v.ownerDomain}:{},usesDomains:Array.isArray(v.usesDomains)?v.usesDomains.map(String):[]};i.files.some(U=>U.path===$)||r({type:"FILE_ADDED",file:T});const{content:Q}=await le.readNotebook($),B=qo($,Q);r({type:"OPEN_FILE",file:T,cells:B.cells,title:B.title,metadata:B.metadata})}catch($){x($ instanceof Error?$.message:String($))}finally{g(null)}};return e.jsxs(Ie,{children:[e.jsx(Me,{title:n?`Related ${j}`:`All ${j}`,detail:n?`${j} are global shared products related to ${n}. This backlink does not create a second copy inside the Domain Package.`:`All global ${j.toLowerCase()} across Domain Packages. Select a domain above to narrow by owner/uses-domain metadata.`,t:s}),b?e.jsx(ce,{text:b,t:s}):null,d?e.jsx(Ce,{title:`Loading related ${j.toLowerCase()}…`,detail:"Resolving global product backlinks from the compiled project snapshot.",t:s}):c.length?e.jsx("div",{style:{display:"grid",gap:10},children:c.map(v=>{const D=String(v.id??v.filePath??v.title??"product"),$=Array.isArray(v.usesDomains)?v.usesDomains.map(String):[],T=String(v.name??v.title??D);return e.jsxs("button",{type:"button",onClick:()=>void f(v),"aria-label":`Open ${o==="notebooks"?"notebook":"app"} ${T}`,style:{...ct(s),width:"100%",textAlign:"left",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Bt,{size:14,color:s.accent}),e.jsx("b",{children:T}),v.lifecycle?e.jsx(Ye,{t:s,children:String(v.lifecycle)}):null,h===D?e.jsx(Ye,{t:s,children:"Opening…"}):null]}),e.jsx("p",{style:{color:s.textSecondary,fontSize:11,margin:"7px 0 0"},children:String(v.purpose??"No analytical purpose declared yet.")}),e.jsx("code",{style:{display:"block",marginTop:7,color:s.textMuted,fontSize:10},children:String(v.filePath??"")}),e.jsxs("div",{style:{marginTop:7,color:s.textMuted,fontSize:10},children:["Owner: ",String(v.ownerDomain??"Shared")," · Uses: ",$.join(", ")||"none declared"]})]},D)})}):y.length?e.jsxs("div",{style:{display:"grid",gap:10},children:[e.jsx(ce,{text:"These paths use the legacy domain-local layout. They remain readable during migration, but new products should be global and declare ownerDomain / usesDomains.",t:s}),y.map(v=>e.jsxs("button",{type:"button",onClick:()=>void f({id:o==="apps"?Zn(v):v,filePath:v}),"aria-label":`Open ${o==="notebooks"?"notebook":"app"} ${v}`,style:{...ct(s),width:"100%",textAlign:"left",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Bt,{size:14,color:s.accent}),e.jsx("code",{style:{color:s.textPrimary,fontSize:11},children:v})]}),e.jsx("p",{style:{color:s.textMuted,fontSize:10,margin:"7px 0 0"},children:"Legacy backlink · migrate without duplicating the product."})]},v))]}):e.jsx(Ce,{title:`No related ${j.toLowerCase()} yet`,detail:`Create the ${o==="notebooks"?"notebook":"app"} from the global ${j} surface, then declare this domain in its product context to make the backlink appear here.`,t:s})]})}function Zn(t){const n=t.replace(/\\/g,"/").split("/").filter(Boolean),o=n.indexOf("apps");return o>=0?n[o+1]??"":""}function Bs({domain:t,selectedId:n,data:o,t:s,onOpenSkills:i,onDraftRelationship:r}){const[c,l]=a.useState(null),[d,u]=a.useState([]),[h,g]=a.useState(!1),[b,x]=a.useState(null),y=async()=>{try{g(!0),x(null);const f=await le.startContextBootstrap({ai:!0});l(f),u(f.candidates.filter(k=>{var I;return!t||k.kind!=="domain"||((I=k.domain)==null?void 0:I.id)===t}).map(k=>k.id))}catch(f){x(f instanceof Error?f.message:String(f))}finally{g(!1)}},j=async()=>{if(c)try{g(!0),await le.saveContextBootstrapSelected(c.id,d),x("Selected domain and skill drafts were saved. Review them in Git before activation.")}catch(f){x(f instanceof Error?f.message:String(f))}finally{g(!1)}};return e.jsxs(Ie,{children:[e.jsx(Me,{title:"Modeling Copilot",detail:"AI can propose business context and modeling work from dbt evidence. It writes drafts only; relationships, contracts, blocks, and skills still require explicit review.",t:s,action:e.jsxs(K,{primary:!0,t:s,onClick:()=>void y(),disabled:h,children:[e.jsx(ro,{size:14})," Analyze project"]})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(190px, 1fr))",gap:10,marginBottom:18},children:[e.jsx(Ht,{icon:e.jsx(Fe,{size:16}),title:"Domains and concepts",detail:"Detect ownership boundaries, vocabulary, concepts, and candidate subdomains.",t:s}),e.jsx(Ht,{icon:e.jsx(Ge,{size:16}),title:"Relationship proposals",detail:"Suggest keys and cardinality from dbt evidence, then require warehouse validation.",t:s,action:e.jsx("button",{style:_e(s),onClick:r,children:"Draft manually"})}),e.jsx(Ht,{icon:e.jsx(Xt,{size:16}),title:"Domain skills",detail:"Draft governed vocabulary, preferred metrics, blocks, and clarification rules.",t:s,action:e.jsx("button",{style:_e(s),onClick:i,children:"Manage skills"})})]}),e.jsx(ce,{text:`Active scope: ${t??"all domains"}${n?` · focused object: ${n}`:""} · ${Object.keys(o.modeling.entities).length} bindings · ${Object.keys(o.modeling.relationships).length} governed relationships. AI proposals never treat dbt lineage as join proof and never auto-certify.`,t:s}),c&&e.jsxs("div",{style:{marginTop:16},children:[e.jsx("h3",{style:Gt(s),children:"Review proposal pack"}),c.candidates.length?c.candidates.map(f=>{var k,I,v;return e.jsxs("label",{style:{display:"grid",gridTemplateColumns:"20px 110px 1fr 70px",gap:8,padding:"10px 8px",borderBottom:`1px solid ${s.headerBorder}`,fontSize:11},children:[e.jsx("input",{type:"checkbox",checked:d.includes(f.id),onChange:D=>u($=>D.target.checked?[...$,f.id]:$.filter(T=>T!==f.id))}),e.jsx("b",{children:f.kind}),e.jsxs("span",{children:[((k=f.domain)==null?void 0:k.name)??((I=f.domain)==null?void 0:I.id)??((v=f.skill)==null?void 0:v.id)??f.id,e.jsx("small",{style:{display:"block",color:s.textMuted,marginTop:3},children:f.evidence.slice(0,2).join(" · ")||"Evidence review required"})]}),e.jsxs("span",{children:[Math.round(f.confidence*100),"%"]})]},f.id)}):e.jsx(Ce,{title:"No proposals",detail:"The current project evidence did not produce a safe domain or skill proposal.",t:s}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:12},children:e.jsx(K,{primary:!0,t:s,onClick:()=>void j(),disabled:h||d.length===0,children:"Save selected drafts"})})]}),b&&e.jsx("div",{style:{marginTop:12},children:e.jsx(ce,{text:b,t:s})})]})}function Ht({icon:t,title:n,detail:o,t:s,action:i}){return e.jsxs("div",{style:ct(s),children:[e.jsxs("div",{style:{display:"flex",gap:7,color:s.accent},children:[t,e.jsx("b",{style:{color:s.textPrimary},children:n})]}),e.jsx("p",{style:{color:s.textSecondary,fontSize:11,lineHeight:1.5},children:o}),i]})}function Ds({data:t,domain:n,t:o,onCreateExport:s,onCreateImport:i}){var l,d;const r=Object.values(((l=t.modeling.interfaces)==null?void 0:l.exports)??{}).filter(u=>!n||u.domain===n),c=Object.values(((d=t.modeling.interfaces)==null?void 0:d.imports)??{}).filter(u=>!n||u.domain===n);return e.jsxs(Ie,{children:[e.jsx(Me,{title:"Cross-domain interfaces",detail:"Domains never join through discovery alone. Providers certify a narrow export; consumers import it for an explicit purpose.",t:o,action:e.jsxs("div",{style:{display:"flex",gap:7},children:[e.jsxs(K,{t:o,onClick:i,children:[e.jsx(ke,{size:14})," Import"]}),e.jsxs(K,{primary:!0,t:o,onClick:s,children:[e.jsx(ke,{size:14})," Export"]})]})}),e.jsx("h3",{style:Gt(o),children:"Published exports"}),r.length?e.jsxs("table",{style:dt,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(_,{children:"Interface"}),e.jsx(_,{children:"Entity"}),e.jsx(_,{children:"Allowed surface"}),e.jsx(_,{children:"Consumers"}),e.jsx(_,{children:"Status"})]})}),e.jsx("tbody",{children:r.map(u=>e.jsxs("tr",{children:[e.jsx(F,{children:e.jsxs("b",{children:[u.domain,".",u.localId,"@",u.version]})}),e.jsx(F,{children:u.entity??"—"}),e.jsx(F,{children:[...u.metrics,...u.blocks,...u.allowedDimensions].join(", ")||"keys only"}),e.jsx(F,{children:u.consumerDomains.join(", ")||"none"}),e.jsx(F,{children:e.jsx(Dt,{status:u.status,t:o})})]},u.qualifiedId))})]}):e.jsx(Ce,{title:"No exports in this scope",detail:"Publish only the entity, metrics, blocks, dimensions, keys, filters, purposes, and consumers another domain may use.",t:o}),e.jsx("h3",{style:Gt(o),children:"Approved imports"}),c.length?e.jsxs("table",{style:dt,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(_,{children:"Import"}),e.jsx(_,{children:"Consumer"}),e.jsx(_,{children:"Provider export"}),e.jsx(_,{children:"Purpose"}),e.jsx(_,{children:"Status"})]})}),e.jsx("tbody",{children:c.map(u=>e.jsxs("tr",{children:[e.jsx(F,{children:e.jsx("b",{children:u.localId})}),e.jsx(F,{children:u.domain}),e.jsx(F,{children:u.exportRef}),e.jsx(F,{children:u.purpose}),e.jsx(F,{children:e.jsx(Dt,{status:u.status,t:o})})]},u.id))})]}):e.jsx(Ce,{title:"No imports in this scope",detail:"A consumer import is required before an automatic cross-domain path can use the provider export.",t:o})]})}function $s({relationships:t,entities:n,t:o,onSelect:s,onEdit:i}){return e.jsxs(Ie,{children:[e.jsx(Me,{title:"Analytical relationships",detail:"Transformation lineage is context; only these governed edges can prove an analytical join.",t:o}),t.length?e.jsxs("table",{style:dt,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(_,{children:"Relationship"}),e.jsx(_,{children:"Path"}),e.jsx(_,{children:"Cardinality"}),e.jsx(_,{children:"Safety"}),e.jsx(_,{children:"Status"}),e.jsx(_,{children:"Proof"}),e.jsx(_,{})]})}),e.jsx("tbody",{children:t.map(r=>{var c,l,d;return e.jsxs("tr",{onClick:()=>s(r),style:{cursor:"pointer"},children:[e.jsx(F,{children:e.jsx("b",{children:r.localId})}),e.jsxs(F,{children:[r.from," ",e.jsx("span",{style:{color:o.textMuted},children:"→"})," ",r.to,((c=n[r.from])==null?void 0:c.domain)!==((l=n[r.to])==null?void 0:l.domain)&&e.jsx(Ye,{t:o,children:"cross-domain"})]}),e.jsx(F,{children:r.cardinality.replace(/_/g," ")}),e.jsx(F,{children:r.fanout}),e.jsx(F,{children:e.jsx(Dt,{status:r.status,t:o})}),e.jsx(F,{children:r.automaticJoinAllowed?e.jsx("span",{style:{color:"#2e9b63"},children:"certified"}):r.staleCertification?e.jsx("span",{style:{color:"#d47822"},children:"stale"}):((d=r.validation)==null?void 0:d.status)??"not run"}),e.jsx(F,{children:e.jsx("button",{onClick:u=>{u.stopPropagation(),i(r)},style:_e(o),children:"Edit"})})]},r.qualifiedId??r.id)})})]}):e.jsx(Ce,{title:"No join proofs in this domain",detail:"Drag from a source column handle to a target column handle in Domain Model to create a draft, then validate its cardinality and fanout.",t:o})]})}function Rs({data:t,domain:n,t:o,onCreate:s}){const i=Object.values(t.modeling.contracts).filter(r=>!n||r.domain===n);return e.jsxs(Ie,{children:[e.jsx(Me,{title:"Analytical contracts",detail:"Contracts bind governed entities and blocks to evaluation and review requirements.",t:o,action:e.jsxs(K,{primary:!0,t:o,onClick:s,children:[e.jsx(ke,{size:14})," Contract"]})}),i.length?e.jsxs("table",{style:dt,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(_,{children:"Contract"}),e.jsx(_,{children:"Domain"}),e.jsx(_,{children:"Entities"}),e.jsx(_,{children:"Blocks"}),e.jsx(_,{children:"Status"}),e.jsx(_,{children:"Evaluation"})]})}),e.jsx("tbody",{children:i.map(r=>e.jsxs("tr",{children:[e.jsx(F,{children:e.jsx("b",{children:r.id})}),e.jsx(F,{children:r.domain}),e.jsx(F,{children:r.entities.join(", ")||"—"}),e.jsx(F,{children:r.blocks.join(", ")||"—"}),e.jsx(F,{children:e.jsx(Dt,{status:r.status,t:o})}),e.jsx(F,{children:r.requiredEvaluation?"Required":"Optional"})]},r.id))})]}):e.jsx(Ce,{title:"No contracts in this scope",detail:"Create a contract when a set of entities and certified blocks must move through evaluation and review together.",t:o})]})}function Ps({data:t,domain:n,unbound:o,t:s,onBind:i}){const[r,c]=a.useState(""),[l,d]=a.useState(0),u=50,h=new Set(nn(t.modeling,n).map(({entity:f})=>f.dbtUniqueId)),g=r.trim().toLowerCase(),b=Object.values(t.dbtProvenance.nodes).filter(f=>n&&!h.has(f.uniqueId)?!1:g?[f.name,f.uniqueId,f.relation,f.sourcePath].some(k=>String(k??"").toLowerCase().includes(g)):!0),x=Math.max(1,Math.ceil(b.length/u)),y=Math.min(l,x-1),j=b.slice(y*u,(y+1)*u);return e.jsxs(Ie,{children:[e.jsx(Me,{title:"dbt-owned scope",detail:`Read on demand from ${t.dbtProvenance.manifestPath}. Columns, descriptions, tests, and MetricFlow formulas remain dbt-owned.${n?" This view shows dbt models already bound to this domain.":""}`,t:s,action:e.jsxs("label",{style:{position:"relative",width:230},children:[e.jsx($t,{size:13,style:{position:"absolute",top:9,left:8,color:s.textMuted}}),e.jsx("input",{"aria-label":"Search dbt scope",value:r,onChange:f=>{c(f.target.value),d(0)},placeholder:"Find model, relation, or path",style:{...ge(s),paddingLeft:27}})]})}),j.length?e.jsxs(e.Fragment,{children:[e.jsxs("table",{style:dt,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(_,{children:"dbt model"}),e.jsx(_,{children:"Relation"}),e.jsx(_,{children:"Source"}),e.jsx(_,{children:"Metadata"}),e.jsx(_,{})]})}),e.jsx("tbody",{children:j.map(f=>{const k=o.some(I=>I.uniqueId===f.uniqueId);return e.jsxs("tr",{children:[e.jsx(F,{children:e.jsx("b",{children:f.name})}),e.jsx(F,{children:f.relation??"—"}),e.jsx(F,{children:f.sourcePath??"—"}),e.jsx(F,{children:Object.entries(f.available).filter(([,I])=>I).map(([I])=>I).join(", ")}),e.jsx(F,{children:k?e.jsx("button",{onClick:()=>i(f.uniqueId),style:_e(s),children:"Bind"}):e.jsx("span",{style:{color:"#2e9b63"},children:"Bound"})})]},f.uniqueId)})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:12,color:s.textMuted,fontSize:10},children:[e.jsxs("span",{children:[b.length," models · page ",y+1," of ",x]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx(K,{t:s,disabled:y===0,onClick:()=>d(f=>Math.max(0,f-1)),children:"Previous"}),e.jsx(K,{t:s,disabled:y>=x-1,onClick:()=>d(f=>Math.min(x-1,f+1)),children:"Next"})]})]})]}):e.jsx(Ce,{title:r?"No dbt models match this search":n?"No dbt models are bound to this domain":"No dbt models found",detail:n?"Use Bind model in Domain Model to add a dbt model without copying its schema.":"Compile the dbt project, then refresh Domain Studio.",t:s})]})}function Ns({entity:t,detail:n,relationships:o=[],t:s,onEdit:i,onEditDbtSource:r,onSelectRelationship:c,onDelete:l}){var b,x,y,j;const d=uo(t.analyticalRole),u=new Set(t.keys.length?t.keys:((b=n==null?void 0:n.dqlMeta)==null?void 0:b.keys)??[]),h={fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:s.textMuted,margin:"0 0 5px"},g=o.filter(f=>f.from===t.id||f.to===t.id||f.from===t.localId||f.to===t.localId);return e.jsxs(on,{t:s,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,marginBottom:12},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2.5,background:d,flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:13.5,fontWeight:700,color:s.textPrimary,fontFamily:s.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.businessName||t.localId}),e.jsx("span",{style:{flexShrink:0,fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",color:d},children:t.analyticalRole??"entity"})]}),e.jsx("p",{style:{margin:"0 0 12px",color:s.textSecondary,fontSize:12,lineHeight:1.6},children:t.businessContext||`Add the DQL-owned business context for ${t.localId}. dbt descriptions remain physical-source documentation.`}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:h,children:"dbt binding"}),e.jsx("div",{style:{fontSize:11,fontFamily:s.fontMono,color:s.textPrimary,background:"var(--bg-1)",border:"1px solid var(--border-subtle)",borderRadius:7,padding:"7px 9px",overflowWrap:"anywhere"},children:(n==null?void 0:n.relation)??t.dbtUniqueId})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsxs("div",{style:h,children:["Columns · ",(n==null?void 0:n.columns.length)??"…"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:n==null?void 0:n.columns.slice(0,16).map(f=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"4px 2px",borderBottom:"1px solid var(--border-subtle)",fontSize:11.5},children:[e.jsx("span",{style:{flexShrink:0,width:17,fontSize:8.5,fontWeight:700,fontFamily:s.fontMono,color:u.has(f.name)?"var(--pk)":/(^|_)id$/.test(f.name)?"var(--fk)":"transparent"},children:u.has(f.name)?"PK":/(^|_)id$/.test(f.name)?"FK":"·"}),e.jsx("span",{style:{flex:1,minWidth:0,color:s.textSecondary,fontFamily:s.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.name}),e.jsx("span",{style:{flexShrink:0,fontSize:10,color:s.textMuted,fontFamily:s.fontMono},children:f.type??"—"})]},f.name))})]}),g.length>0&&c?e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:h,children:"Relationships"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:g.map(f=>e.jsxs("button",{type:"button",onClick:()=>c(f),style:{display:"flex",alignItems:"center",gap:7,padding:"6px 8px",borderRadius:7,border:"1px solid var(--border-subtle)",background:"var(--bg-1)",cursor:"pointer",textAlign:"left",fontFamily:s.font,fontSize:11,color:s.textSecondary},children:[e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.localId}),e.jsx("span",{style:{fontFamily:s.fontMono,fontSize:10,color:s.textMuted,flexShrink:0},children:f.cardinality==="one_to_one"?"1:1":f.cardinality==="one_to_many"?"1:N":f.cardinality==="many_to_one"?"N:1":"N:N"})]},f.qualifiedId??f.localId))})]}):null,e.jsxs("details",{style:{marginBottom:12},children:[e.jsx("summary",{style:{...h,cursor:"pointer"},children:"More metadata"}),e.jsx(pe,{label:"concepts",value:((x=t.conceptRefs)==null?void 0:x.join(", "))||"Not mapped",t:s}),e.jsx(pe,{label:"owner",value:t.owner??"Not declared",t:s}),e.jsx(pe,{label:"grain",value:t.grain??((y=n==null?void 0:n.dqlMeta)==null?void 0:y.grain)??"Not declared",t:s}),e.jsx(pe,{label:"keys",value:(t.keys.length?t.keys:((j=n==null?void 0:n.dqlMeta)==null?void 0:j.keys)??[]).join(", ")||"Not declared",t:s}),e.jsx(pe,{label:"source",value:(n==null?void 0:n.sourcePath)??t.sourcePath,t:s}),e.jsx(pe,{label:"dbt description",value:(n==null?void 0:n.description)??"Not declared",t:s})]}),e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[e.jsx(K,{primary:!0,t:s,onClick:i,children:"Edit entity"}),e.jsx(K,{t:s,onClick:r,children:"Preview dbt source patch"}),l?e.jsx(K,{t:s,danger:!0,onClick:l,children:"Delete entity"}):null]})]})}function As({entity:t,detail:n,snapshotId:o,t:s,onClose:i,onApplied:r}){const c=n.columns.filter(D=>D.tests.length>0).map(D=>`${D.name}: ${D.tests.join(", ")}`).join(`
22
- `),[l,d]=a.useState(n.description??""),[u,h]=a.useState(c),[g,b]=a.useState(null),[x,y]=a.useState(!1),[j,f]=a.useState(null),k=()=>({uniqueId:t.dbtUniqueId,description:l,columns:u.split(/\r?\n/).flatMap(D=>{const $=D.indexOf(":");if($<1)return[];const T=D.slice(0,$).trim(),Q=G(D.slice($+1));return T?[{name:T,tests:Q}]:[]})}),I=async()=>{try{y(!0),f(null),b(await le.previewDbtSourcePatch(k(),o))}catch(D){f(D instanceof Error?D.message:String(D))}finally{y(!1)}},v=async()=>{if(g)try{y(!0),f(null),await le.applyDbtSourcePatch(k(),g.fingerprint,g.snapshotId),await r()}catch(D){f(D instanceof Error?D.message:String(D))}finally{y(!1)}};return e.jsxs(mo,{title:`Edit dbt source · ${n.name}`,t:s,onClose:i,children:[e.jsx(ce,{text:"dbt owns descriptions and tests. DQL will preview a guarded patch to the dbt YAML source; no dbt metadata is copied into the Domain Package.",t:s}),g?e.jsxs("div",{style:{display:"grid",gap:10},children:[e.jsxs("div",{style:{color:s.textSecondary,fontSize:11},children:["Source: ",e.jsx("code",{children:g.patch.path})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[e.jsx(Xn,{title:"Current dbt YAML",source:g.patch.before||"# New dbt schema YAML",t:s}),e.jsx(Xn,{title:"Proposed dbt YAML",source:g.patch.after,t:s})]}),j&&e.jsx(ce,{text:j,t:s}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:7},children:[e.jsx(K,{t:s,onClick:()=>b(null),children:"Back"}),e.jsx(K,{primary:!0,t:s,disabled:x||!g.patch.changed,onClick:()=>void v(),children:g.patch.changed?"Apply dbt source patch":"No changes"})]})]}):e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(w,{label:"Model description",children:e.jsx("textarea",{"aria-label":"Model description",value:l,onChange:D=>d(D.target.value),rows:5,style:{...ge(s),resize:"vertical"}})}),e.jsx(w,{label:"Column tests (one column per line)",children:e.jsx("textarea",{"aria-label":"Column tests",value:u,onChange:D=>h(D.target.value),rows:6,placeholder:"order_id: unique, not_null",style:{...ge(s),resize:"vertical",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"}})}),e.jsx("p",{style:{margin:0,color:s.textMuted,fontSize:10},children:"Descriptions/tests stay in dbt YAML. Business meaning, relationships, contracts, and policies stay in the DQL Domain Package."}),j&&e.jsx(ce,{text:j,t:s}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:7},children:[e.jsx(K,{t:s,onClick:i,children:"Cancel"}),e.jsx(K,{primary:!0,t:s,disabled:x,onClick:()=>void I(),children:"Preview source patch"})]})]})]})}function Xn({title:t,source:n,t:o}){return e.jsxs("section",{children:[e.jsx("strong",{style:{fontSize:10},children:t}),e.jsx("pre",{tabIndex:0,style:{maxHeight:360,overflow:"auto",whiteSpace:"pre-wrap",background:o.appBg,border:`1px solid ${o.headerBorder}`,borderRadius:6,padding:10,fontSize:9.5,color:o.textSecondary},children:n})]})}function Os({relationship:t,t:n,onEdit:o,onDelete:s}){var i,r,c;return e.jsxs(on,{t:n,children:[e.jsx(_s,{title:t.localId,subtitle:`${t.from} → ${t.to}`,t:n}),e.jsx(K,{primary:!0,t:n,onClick:o,children:"Validate / edit"}),e.jsx("h3",{style:oo(n),children:"Business meaning"}),e.jsx(pe,{label:"verb",value:t.verb??"Not described",t:n}),e.jsx("p",{style:{margin:"0 0 8px",color:n.textSecondary,fontSize:11,lineHeight:1.55},children:t.description||`${t.from} relates to ${t.to}. Add a business description so agents can distinguish this route from similarly shaped joins.`}),e.jsx("h3",{style:oo(n),children:"Join route"}),e.jsx(pe,{label:"cardinality",value:t.cardinality,t:n}),e.jsx(pe,{label:"fanout",value:t.fanout,t:n}),e.jsx(pe,{label:"lifecycle",value:t.status,t:n}),e.jsx(pe,{label:"join keys",value:t.keys.map(l=>`${l.from} = ${l.to}`).join(", "),t:n}),e.jsx(pe,{label:"endpoint roles",value:[(i=t.roles)==null?void 0:i.from,(r=t.roles)==null?void 0:r.to].filter(Boolean).join(" → ")||"Not declared",t:n}),e.jsx(pe,{label:"allowed joins",value:((c=t.joinTypes)==null?void 0:c.join(", "))||"left",t:n}),e.jsx(pe,{label:"automatic agent join",value:t.automaticJoinAllowed?"Allowed":"Blocked",t:n}),t.validation?e.jsx(xo,{evidence:t.validation,t:n}):e.jsx(ce,{text:"No warehouse proof has been captured. This edge cannot authorize automatic SQL joins.",t:n}),e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginTop:12},children:[e.jsx(K,{primary:!0,t:n,onClick:o,children:"Edit relationship"}),s?e.jsx(K,{t:n,danger:!0,onClick:s,children:"Delete relationship"}):null]})]})}function Es({data:t,domainEntities:n,domainRelationships:o,t:s,onSelectRelationship:i}){var b;const r=((b=n[0])==null?void 0:b.domain)??"All domains",c=o.filter(x=>{var y;return((y=x.validation)==null?void 0:y.status)==="passed"}).length,l=n.filter(x=>!!x.dbtUniqueId).length,d=n.filter(x=>!x.businessContext),u={fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:s.textMuted,margin:"14px 0 5px"},h=(x,y)=>e.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:9,padding:"10px 12px",background:"var(--bg-1)"},children:[e.jsx("div",{style:{fontSize:18,fontWeight:700,color:s.textPrimary},children:x}),e.jsx("div",{style:{fontSize:10.5,color:s.textMuted},children:y})]}),g=(x,y)=>e.jsxs("span",{style:{display:"flex",alignItems:"flex-start",gap:7,fontSize:11.5,color:s.textSecondary,lineHeight:1.45},children:[e.jsx("span",{style:{color:x?"var(--status-success)":"var(--status-warning)",flexShrink:0,fontWeight:700},children:x?"✓":"△"}),y]},y);return e.jsxs(on,{t:s,children:[e.jsxs("div",{style:{fontSize:11,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:s.textMuted},children:[r," model"]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8,marginTop:12},children:[h(n.length,n.length===1?"entity":"entities"),h(o.length,o.length===1?"relationship":"relationships")]}),e.jsx("p",{style:{margin:"12px 0 0",color:s.textSecondary,fontSize:12,lineHeight:1.6},children:"Select an entity to see its columns and dbt binding, or click a relationship label to review its join, cardinality, and business context."}),e.jsx("div",{style:u,children:"Model health"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[o.length>0?g(c===o.length,c===o.length?"All relationships have join proofs":`${c} of ${o.length} relationships have join proofs`):g(!1,"No relationships yet — drag between column handles to create one"),g(l===n.length&&n.length>0,n.length===0?"No entities bound yet — use Bind model":`${l} of ${n.length} entities bound to dbt`),d.length>0?g(!1,`${d[0].localId}${d.length>1?` and ${d.length-1} more`:""} ha${d.length>1?"ve":"s"} no business description`):n.length>0?g(!0,"Every entity has a business description"):null]}),e.jsx("div",{style:u,children:"Relationships"}),o.length?o.map(x=>e.jsxs("button",{onClick:()=>i(x),style:{display:"flex",alignItems:"center",gap:7,width:"100%",textAlign:"left",border:"1px solid var(--border-subtle)",borderRadius:7,background:"var(--bg-1)",color:s.textSecondary,padding:"6px 8px",marginBottom:4,cursor:"pointer",fontSize:11,fontFamily:s.font},children:[e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.localId}),e.jsx("span",{style:{fontFamily:s.fontMono,fontSize:10,color:s.textMuted,flexShrink:0},children:x.cardinality==="one_to_one"?"1:1":x.cardinality==="one_to_many"?"1:N":x.cardinality==="many_to_one"?"N:1":"N:N"})]},x.qualifiedId)):e.jsx("p",{style:{color:s.textMuted,fontSize:10.5,margin:0},children:"Drag between two column handles to create the first relationship."}),e.jsx("div",{style:u,children:"Ownership boundary"}),e.jsx("p",{style:{color:s.textSecondary,fontSize:11,lineHeight:1.55,margin:0},children:"dbt owns tables, columns, descriptions, tests, and metrics. DQL owns domain membership, analytical identity, safe relationship proof, contracts, certified blocks, and agent policy. Shared apps and notebooks reference this domain without moving inside it."})]})}function xo({evidence:t,t:n}){return e.jsxs("div",{style:{marginTop:12,padding:10,border:`1px solid ${t.status==="passed"?"#2e9b6355":"#c94b5555"}`,background:t.status==="passed"?"#2e9b630d":"#c94b550d",borderRadius:7,fontSize:11},children:[e.jsx("b",{style:{color:t.status==="passed"?"#2e9b63":"#c94b55"},children:t.status==="passed"?"Warehouse proof passed":"Warehouse proof failed"}),e.jsxs("div",{style:{color:n.textSecondary,marginTop:7,lineHeight:1.55},children:["Rows: ",t.fromRows," → ",t.toRows,e.jsx("br",{}),"Joined: ",t.joinedRows," · unmatched: ",t.unmatchedFrom,e.jsx("br",{}),"Max rows/key: ",t.maxFromPerKey," → ",t.maxToPerKey]})]})}function eo({t,title:n,detail:o,status:s}){return e.jsx("div",{style:{flex:1,display:"grid",placeItems:"center",background:t.appBg,color:t.textPrimary},children:e.jsxs("div",{style:{maxWidth:560,textAlign:"center"},children:[e.jsx(Fe,{size:34,color:t.accent}),e.jsx("h1",{style:{fontSize:20},children:n}),e.jsx("p",{style:{color:t.textSecondary,lineHeight:1.6},children:o}),s&&e.jsx("code",{style:{fontSize:12},children:s})]})})}function mo({title:t,t:n,onClose:o,children:s}){return e.jsx("div",{style:{position:"fixed",inset:0,zIndex:100,background:"#0008",display:"grid",placeItems:"center",padding:20},onMouseDown:i=>{i.target===i.currentTarget&&o()},children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":t,tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&o()},style:{width:"min(720px, 94vw)",maxHeight:"88vh",overflow:"auto",background:n.appBg,border:`1px solid ${n.headerBorder}`,borderRadius:12,boxShadow:"0 24px 80px #0006"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"15px 18px",borderBottom:`1px solid ${n.headerBorder}`},children:[e.jsx("strong",{children:t}),e.jsx("button",{"aria-label":`Close ${t}`,title:"Close",onClick:o,style:fe(n),children:e.jsx(ut,{size:17})})]}),e.jsx("div",{style:{padding:18},children:s})]})})}function to({current:t,labels:n,t:o}){return e.jsx("div",{"aria-label":`Step ${t} of ${n.length}`,style:{display:"grid",gridTemplateColumns:`repeat(${n.length}, minmax(0, 1fr))`,gap:6},children:n.map((s,i)=>{const r=i+1,c=r===t,l=r<t;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0,color:c?o.textPrimary:o.textMuted,fontSize:10,fontWeight:c?700:550},children:[e.jsx("span",{style:{display:"grid",placeItems:"center",width:20,height:20,flex:"0 0 auto",borderRadius:999,border:`1px solid ${c||l?o.accent:o.headerBorder}`,background:l?o.accent:c?"var(--accent-dim)":o.appBg,color:l?"#fff":c?o.accent:o.textMuted},children:l?"✓":r}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s})]},s)})})}function no({title:t,detail:n,t:o}){return e.jsxs("div",{style:{display:"grid",gap:3,padding:"9px 11px",border:`1px solid ${o.headerBorder}`,borderRadius:7,background:o.cellBg},children:[e.jsx("strong",{style:{fontSize:11},children:t}),e.jsx("span",{style:{color:o.textMuted,fontSize:9.5,overflowWrap:"anywhere"},children:n})]})}function zt({ariaLabel:t,value:n,onChange:o,options:s,placeholder:i,disabled:r=!1,t:c}){const[l,d]=a.useState(!1),[u,h]=a.useState(""),g=s.find(x=>x.value===n),b=gs(s,u,50);return e.jsxs("div",{style:{position:"relative",minWidth:0},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx($t,{size:13,"aria-hidden":"true",style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)",color:c.textMuted,pointerEvents:"none"}}),e.jsx("input",{role:"combobox","aria-label":t,"aria-expanded":l,"aria-controls":l?"modeling-search-results":void 0,disabled:r,value:l?u:(g==null?void 0:g.label)??n,placeholder:i,onFocus:()=>{d(!0),h("")},onBlur:()=>{d(!1),h("")},onChange:x=>{d(!0),h(x.target.value)},onKeyDown:x=>{x.key==="Escape"&&(d(!1),h(""))},style:{...ge(c),paddingLeft:29,paddingRight:n?29:8,opacity:r?.6:1}}),n&&!r&&e.jsx("button",{type:"button","aria-label":"Clear selection",onMouseDown:x=>x.preventDefault(),onClick:()=>{o(""),h(""),d(!0)},style:{...fe(c),position:"absolute",right:3,top:"50%",transform:"translateY(-50%)",width:24,height:24,border:"none"},children:e.jsx(ut,{size:13})})]}),l&&!r&&e.jsxs("div",{id:"modeling-search-results",role:"listbox",style:{position:"absolute",zIndex:90,top:"calc(100% + 4px)",left:0,right:0,maxHeight:230,overflowY:"auto",border:`1px solid ${c.headerBorder}`,borderRadius:7,background:c.cellBg,boxShadow:"0 12px 32px #0004",padding:4},children:[b.length?b.map(x=>e.jsxs("button",{type:"button",role:"option","aria-selected":x.value===n,onMouseDown:y=>y.preventDefault(),onClick:()=>{o(x.value),d(!1),h("")},style:{display:"grid",width:"100%",gap:2,padding:"8px 9px",border:"none",borderRadius:5,textAlign:"left",background:x.value===n?"var(--accent-dim)":"transparent",color:c.textPrimary,cursor:"pointer"},children:[e.jsx("strong",{style:{fontSize:10.5},children:x.label}),x.description&&e.jsx("span",{style:{color:c.textMuted,fontSize:9,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.description})]},x.value)):e.jsx("div",{style:{padding:12,color:c.textMuted,fontSize:10},children:"No matching results."}),s.length>50&&e.jsxs("div",{style:{padding:"6px 9px 4px",borderTop:`1px solid ${c.headerBorder}`,color:c.textMuted,fontSize:9},children:["Showing the best 50 of ",s.length.toLocaleString(),". Refine your search for a specific result."]})]})]})}function Ts({value:t,onChange:n,selectedNode:o,t:s}){const[i,r]=a.useState(""),[c,l]=a.useState(!1),[d,u]=a.useState(!1),[h,g]=a.useState(0),[b,x]=a.useState([]);return a.useEffect(()=>{let y=!1;const j=window.setTimeout(()=>{u(!0),le.getDbtModelInventory({q:i,limit:50}).then(f=>{y||(g(f.total),x(f.items.map(k=>{var v;const I=k;return{value:I.uniqueId??"",label:I.name??I.uniqueId??"Unnamed model",description:`${I.relation??I.sourcePath??I.uniqueId}${I.binding?` · already bound to ${I.binding.domain??"a domain"}`:" · unbound"}`,keywords:[I.sourcePath??"",((v=I.binding)==null?void 0:v.businessName)??""]}}).filter(k=>k.value)))}).catch(()=>{y||x([])}).finally(()=>{y||u(!1)})},140);return()=>{y=!0,window.clearTimeout(j)}},[i]),e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx($t,{size:13,"aria-hidden":"true",style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)",color:s.textMuted,pointerEvents:"none"}}),e.jsx("input",{role:"combobox","aria-label":"Search dbt models","aria-expanded":c,value:c?i:(o==null?void 0:o.name)??t,placeholder:"Search model, relation, or path…",onFocus:()=>{l(!0),r("")},onBlur:()=>{l(!1),r("")},onChange:y=>{r(y.target.value),l(!0)},onKeyDown:y=>{y.key==="Escape"&&l(!1)},style:{...ge(s),paddingLeft:29,paddingRight:t?29:8}}),t&&e.jsx("button",{type:"button","aria-label":"Clear dbt model",onMouseDown:y=>y.preventDefault(),onClick:()=>{n(""),l(!0)},style:{...fe(s),position:"absolute",right:3,top:"50%",transform:"translateY(-50%)",width:24,height:24,border:"none"},children:e.jsx(ut,{size:13})})]}),c&&e.jsxs("div",{role:"listbox",style:{position:"absolute",zIndex:90,top:"calc(100% + 4px)",left:0,right:0,maxHeight:260,overflowY:"auto",border:`1px solid ${s.headerBorder}`,borderRadius:7,background:s.cellBg,boxShadow:"0 12px 32px #0004",padding:4},children:[d&&e.jsx("div",{style:{padding:10,color:s.textMuted,fontSize:10},children:"Searching project inventory…"}),!d&&b.map(y=>e.jsxs("button",{type:"button",role:"option","aria-selected":y.value===t,onMouseDown:j=>j.preventDefault(),onClick:()=>{n(y.value),l(!1),r("")},style:{display:"grid",width:"100%",gap:2,padding:"8px 9px",border:"none",borderRadius:5,textAlign:"left",background:y.value===t?"var(--accent-dim)":"transparent",color:s.textPrimary,cursor:"pointer"},children:[e.jsx("strong",{style:{fontSize:10.5},children:y.label}),e.jsx("span",{style:{color:s.textMuted,fontSize:9,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y.description})]},y.value)),!d&&!b.length&&e.jsx("div",{style:{padding:10,color:s.textMuted,fontSize:10},children:"No dbt models match this search."}),!d&&h>b.length&&e.jsxs("div",{style:{padding:"6px 9px 4px",borderTop:`1px solid ${s.headerBorder}`,color:s.textMuted,fontSize:9},children:["Showing 50 of ",h.toLocaleString(),". Keep typing to narrow the inventory."]})]})]})}function w({label:t,children:n}){return e.jsxs("label",{style:{display:"grid",gap:6,fontSize:11,fontWeight:650},children:[t,n]})}function A({value:t,onChange:n,t:o,placeholder:s}){return e.jsx("input",{value:t,placeholder:s,onChange:i=>n(i.target.value),style:ge(o)})}function de({value:t,onChange:n,values:o,labels:s,t:i}){return e.jsxs("select",{value:t,onChange:r=>n(r.target.value),style:ge(i),children:[e.jsx("option",{value:"",children:"Select…"}),o.map(r=>e.jsx("option",{value:r,children:(s==null?void 0:s[r])??r},r))]})}function K({children:t,t:n,onClick:o,primary:s,disabled:i,danger:r}){return e.jsx("button",{disabled:i,onClick:o,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,border:`1px solid ${r?n.error:s?n.accent:n.headerBorder}`,background:r?`${n.error}12`:s?n.accent:n.appBg,color:r?n.error:s?"#fff":n.textPrimary,borderRadius:6,padding:"7px 10px",fontSize:11,fontWeight:650,cursor:i?"wait":"pointer",opacity:i?.65:1},children:t})}function qs({children:t,title:n,t:o,onClick:s}){return e.jsx("button",{"aria-label":n,title:n,onClick:s,style:fe(o),children:t})}function Ye({children:t,t:n}){return e.jsx("span",{style:{marginLeft:5,border:`1px solid ${n.accent}55`,color:n.accent,background:`${n.accent}10`,borderRadius:999,padding:"3px 7px",fontSize:9,fontWeight:750},children:t})}function Ls({children:t,t:n}){return e.jsx("div",{style:{padding:"15px 12px 8px",color:n.textMuted,fontSize:10,fontWeight:750,textTransform:"uppercase",letterSpacing:".07em"},children:t})}function Ie({children:t}){return e.jsx("div",{style:{height:"100%",overflow:"auto",padding:20},children:t})}function Me({title:t,detail:n,t:o,action:s}){return e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:20,alignItems:"start",marginBottom:18},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{margin:0,fontSize:16},children:t}),e.jsx("p",{style:{margin:"5px 0 0",color:o.textSecondary,fontSize:11},children:n})]}),s]})}function Ce({title:t,detail:n,t:o}){return e.jsxs("div",{style:{border:`1px dashed ${o.headerBorder}`,borderRadius:10,padding:30,textAlign:"center"},children:[e.jsx("strong",{children:t}),e.jsx("p",{style:{color:o.textSecondary,fontSize:12},children:n})]})}function on({children:t}){return e.jsx("div",{style:{padding:"4px 14px 20px"},children:t})}function _s({title:t,subtitle:n,t:o}){return e.jsxs("div",{style:{marginBottom:14},children:[e.jsx("h2",{style:{margin:0,fontSize:16},children:t}),e.jsx("div",{style:{color:o.textMuted,fontSize:11,marginTop:4},children:n})]})}function pe({label:t,value:n,t:o}){return e.jsxs("div",{style:{padding:"9px 0",borderBottom:`1px solid ${o.headerBorder}`},children:[e.jsx("div",{style:{color:o.textMuted,fontSize:9,textTransform:"uppercase",letterSpacing:".05em"},children:t}),e.jsx("div",{style:{fontSize:11,marginTop:4,overflowWrap:"anywhere"},children:n})]})}function Dt({status:t,t:n}){const o=t==="certified"?"#2e9b63":t==="deprecated"?n.textMuted:t==="review"?"#377cc8":"#9a6b2f";return e.jsx("span",{style:{color:o,background:`${o}15`,borderRadius:999,padding:"3px 7px",fontSize:10},children:t})}function ce({text:t,t:n}){return e.jsx("div",{style:{borderLeft:`3px solid ${n.accent}`,background:`${n.accent}0d`,padding:"9px 10px",color:n.textSecondary,fontSize:11,lineHeight:1.5},children:t})}function _({children:t}){return e.jsx("th",{style:{textAlign:"left",padding:"9px 10px",fontSize:9,textTransform:"uppercase",letterSpacing:".05em",opacity:.65},children:t})}function F({children:t}){return e.jsx("td",{style:{padding:"11px 10px",borderTop:"1px solid var(--border-subtle)",fontSize:11},children:t})}function G(t){return t.split(",").map(n=>n.trim()).filter(Boolean)}function Fs(t){return G(t).map(n=>{const[o,s]=n.split("=").map(i=>i.trim());if(!o||!s)throw new Error(`Invalid join key pair "${n}". Use from_key=to_key.`);return{from:o,to:s}})}function Ws(){try{return JSON.parse(localStorage.getItem("dql-modeling-preferences")??"{}")}catch{return{}}}const ie={display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},Ut=(t,n=!1)=>({display:"inline-flex",alignItems:"center",gap:5,flex:"0 0 auto",border:`1px solid ${n?t.accent:t.headerBorder}`,borderRadius:6,background:n?"var(--accent-dim)":t.appBg,color:n?t.accent:t.textSecondary,padding:"5px 8px",fontSize:10.5,fontWeight:650,cursor:"pointer",whiteSpace:"nowrap"}),dt={width:"100%",borderCollapse:"collapse"},Hs=t=>({whiteSpace:"pre-wrap",maxHeight:300,overflow:"auto",padding:12,borderRadius:7,background:t.activityBarBg,color:t.textSecondary,fontSize:10,lineHeight:1.5}),ge=t=>({width:"100%",boxSizing:"border-box",border:`1px solid ${t.headerBorder}`,background:t.cellBg,color:t.textPrimary,borderRadius:6,padding:"8px 9px",fontSize:11}),fe=t=>({border:`1px solid ${t.headerBorder}`,background:t.appBg,color:t.textSecondary,borderRadius:6,padding:7,display:"grid",placeItems:"center",cursor:"pointer"}),Us=(t,n,o)=>({width:"100%",minHeight:30,padding:o?"6px 8px 6px 14px":"7px 8px",display:"flex",alignItems:"center",gap:7,border:0,borderRadius:6,background:n?`${t.accent}18`:"transparent",color:n?t.accent:t.textSecondary,fontSize:10.5,fontWeight:n?700:500,textAlign:"left",cursor:"pointer"}),_e=t=>({border:0,background:"transparent",color:t.accent,fontSize:10,fontWeight:650,cursor:"pointer"}),oo=t=>({margin:"18px 0 7px",paddingBottom:7,borderBottom:`1px solid ${t.headerBorder}`,fontSize:11,textTransform:"uppercase",letterSpacing:".05em",color:t.textMuted}),Gt=t=>({margin:"22px 0 10px",paddingBottom:8,borderBottom:`1px solid ${t.headerBorder}`,fontSize:12,color:t.textPrimary}),ct=t=>({border:`1px solid ${t.headerBorder}`,background:t.cellBg,borderRadius:9,padding:14}),Ks=t=>({display:"flex",alignItems:"center",gap:9,minHeight:58,border:`1px solid ${t.headerBorder}`,background:t.cellBg,borderRadius:8,padding:"9px 10px",color:t.textPrimary,cursor:"pointer",fontFamily:t.font});export{ri as DbtFirstModelingPage};
@@ -1,7 +0,0 @@
1
- import{g as Ke,u as Ve,t as Xe,r as d,a as g,j as t,G as re,b as Ye,f as ie,P as Je,Y as Ze,aw as et,ax as ke,ai as tt,h as nt,ay as rt,S as it}from"./index-Ca3UeUWI.js";import{E as we}from"./external-link-DHxAcoCE.js";import{X as st}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 ot=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],me=Ke("git-pull-request",ot),lt=[{key:"all",label:"All changes"},{key:"M",label:"Modified"},{key:"A",label:"Added"},{key:"D",label:"Deleted"},{key:"R",label:"Renamed"},{key:"?",label:"Untracked"}];function at(e){const n=e;return n.trim()==="??"?"?":n[0]==="R"||n[1]==="R"?"R":n.includes("A")?"A":n.includes("D")?"D":"M"}function dt(e){const n=[];for(const r of e){const o=r.status[0]??" ",l=r.status[1]??" ",u=at(r.status);if(r.status==="??"){n.push({path:r.path,status:"?",staged:!1,partiallyStaged:!1});continue}const s=o!==" "&&o!=="?";s&&(l!==" "&&l!=="?")?(n.push({path:r.path,status:u,staged:!0,partiallyStaged:!0}),n.push({path:r.path,status:u,staged:!1,partiallyStaged:!0})):s?n.push({path:r.path,status:u,staged:!0,partiallyStaged:!1}):n.push({path:r.path,status:u,staged:!1,partiallyStaged:!1})}return n}function Dt(){const{state:e}=Ve(),n=Xe[e.themeMode],[r,o]=d.useState(null),[l,u]=d.useState({current:null,branches:[]}),[s,a]=d.useState({url:null,name:null}),[h,x]=d.useState(null),[p,w]=d.useState(!1),[m,W]=d.useState(null),[k,F]=d.useState(!1),[I,A]=d.useState(null),[v,q]=d.useState(""),[T,U]=d.useState("all"),[C,z]=d.useState(""),[P,G]=d.useState(null),[O,se]=d.useState(null),[We,oe]=d.useState(!1),[_,E]=d.useState(!1),[Ce,Q]=d.useState(!1),[le,ae]=d.useState(""),[K,V]=d.useState(null),[de,ce]=d.useState(!1),[Re,Me]=d.useState(null),[ue,Pe]=d.useState("plain"),[N,he]=d.useState(null),[xe,De]=d.useState(()=>typeof window<"u"&&window.innerWidth<980);d.useEffect(()=>{const i=()=>De(window.innerWidth<980);return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]);const X=d.useRef(null),R=d.useCallback(async()=>{oe(!0);try{const[i,c,f,S]=await Promise.all([g.fetchGitStatus(),g.fetchGitBranches(),g.fetchGitRemote(),g.fetchGitGovernedContext()]);o(b=>pt(b,i)?b:i),u(b=>b.current===c.current&&xt(b.branches,c.branches)?b:{current:c.current,branches:c.branches}),a(b=>b.url===f.url&&b.name===f.name?b:{url:f.url,name:f.name}),Me(S)}finally{window.setTimeout(()=>oe(!1),350)}},[]);d.useEffect(()=>{R()},[R]),d.useEffect(()=>{const i=window.setInterval(()=>{R()},4e3);return()=>window.clearInterval(i)},[R]),d.useEffect(()=>{if(!_)return;const i=c=>{X.current&&!X.current.contains(c.target)&&(E(!1),Q(!1))};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[_]);const Fe=d.useMemo(()=>((r==null?void 0:r.changes)??[]).map(i=>`${i.status}:${i.path}`).sort().join("|"),[r]);d.useEffect(()=>{if(!h){W(null),A(null),F(!1);return}let i=!1;return F(!0),A(null),W(null),g.fetchGitDiff(h,p).then(c=>{i||W(c)}).catch(c=>{i||A(c instanceof Error?c.message:String(c))}).finally(()=>{i||F(!1)}),()=>{i=!0}},[h,p,Fe]);const $=d.useMemo(()=>dt((r==null?void 0:r.changes)??[]),[r==null?void 0:r.changes]),M=$.filter(i=>i.staged),Y=$.filter(i=>!i.staged),pe=d.useCallback(i=>!(T!=="all"&&i.status!==T||v&&!i.path.toLowerCase().includes(v.toLowerCase())),[T,v]),J=M.filter(pe).sort(ve),Z=Y.filter(pe).sort(ve);d.useEffect(()=>{if(h&&$.some(f=>f.path===h&&f.staged===p))return;const i=Z[0]??J[0];i?(x(i.path),w(i.staged)):x(null)},[$,h,p,J,Z]);const j=d.useCallback((i,c)=>{se({kind:i,text:c}),window.setTimeout(()=>se(null),3e3)},[]),y=d.useCallback(async(i,c,f)=>{G(i);try{const S=await c();return S.ok?(f&&j("ok",f),await R()):j("err",S.error??`${i} failed`),S}finally{G(null)}},[j,R]),fe=i=>y("stage",()=>g.gitStage([i])),ge=i=>y("unstage",()=>g.gitUnstage([i])),Te=i=>{window.confirm(`Discard local changes to ${i}? This cannot be undone.`)&&y("discard",()=>g.gitDiscard([i]),"Discarded local changes")},Ne=()=>y("stage",async()=>{const i=Y.map(c=>c.path);return i.length===0?{ok:!0}:g.gitStage(i)}),Ae=async()=>{const i=C.trim();if(!i)return j("err","Commit message required");const c=M.length===0;(await y("commit",()=>g.gitCommit(i,c),"Committed")).ok&&z("")},Ie=async()=>{const i=C.trim();if(!i)return j("err","Commit message required");const c=M.length===0;(await y("commit",()=>g.gitCommit(i,c))).ok&&(z(""),await y("push",()=>g.gitPush(),"Pushed to remote"))},ye=async()=>{const i=C.trim()||(N==null?void 0:N.message)||"";if(!i)return j("err","Review title required");if(N){const S=await y("request review",()=>g.gitOpenReview({title:i,body:"Created from DQL Source Control. Review the governed analytics changes before merging.",base:N.base}));if(!S.ok)return;V(S.prUrl??null),j("ok",S.warning??"Review request opened.");return}const c=Array.from(new Set($.map(S=>S.path)));if(c.length===0)return j("err","No changes to request review for");const f=await y("request review",()=>g.gitCreateReview({paths:c,title:i,body:"Created from DQL Source Control. Review the governed analytics changes before merging.",base:be(l.current)}));f.ok&&(z(""),V(f.prUrl??null),j("ok",f.warning??`Review branch ${f.branch??""} is ready${f.prUrl?".":"; create the PR from your Git host."}`))},qe=async()=>{(await y("enable governed tracking",()=>g.enableGitGovernedContextTracking())).ok&&j("ok","Governed project source and Hint Graph files are now visible to source control.")},Ge=()=>y("pull",()=>g.gitPull(),"Pulled from remote"),Ee=()=>y("push",()=>g.gitPush(),"Pushed to remote"),Le=()=>{const i=M;if(i.length===0)return j("err","Include at least one change first");const c={M:"Updated",A:"Added",D:"Removed",R:"Renamed","?":"Added"},f=i.slice(0,3).map(b=>{var L;return`${c[b.status]} ${((L=b.path.split("/").pop())==null?void 0:L.replace(/\.(dql|md|json|ya?ml|sql)$/i,""))??b.path}`}),S=i.length>3?` and ${i.length-3} more change${i.length-3===1?"":"s"}`:"";z(`${f.join(", ")}${S}.`)},He=async()=>{const i=C.trim();if(!i)return j("err","Describe your change first");if(M.length===0)return j("err","Include at least one change first");if(!s.url)return j("err","Add a Git remote before sharing changes");const c=M.length,f=be(l.current);if(!l.current||l.current==="HEAD"||l.current==="main"||l.current==="master"){const L=ht(i);if(!(await y("branch",()=>g.gitCreateBranch(L,!0))).ok)return}if(!(await y("commit",()=>g.gitCommit(i,!1))).ok)return;(await y("push",()=>g.gitPush(),"Shared to your branch")).ok&&he({count:c,message:i,base:f}),z("")},Ue=()=>{he(null),V(null),z(""),R()},Oe=i=>{E(!1),y("checkout",()=>g.gitCheckout(i),`Switched to ${i}`)},_e=async()=>{const i=le.trim();i&&(E(!1),Q(!1),ae(""),y("branch",()=>g.gitCreateBranch(i,!0),`Created and switched to ${i}`))},D=$.find(i=>i.path===h&&i.staged===p)??null,Qe=d.useMemo(()=>K??ut(s.url,l.current),[s.url,l.current,K]);return r&&!r.inRepo?t.jsx(Bt,{t:n}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,background:n.appBg},children:[t.jsx(ct,{t:n,branchCurrent:l.current,branches:l.branches,ahead:(r==null?void 0:r.ahead)??0,behind:(r==null?void 0:r.behind)??0,remoteUrl:s.url,refreshing:We,busy:P,onPull:Ge,onPush:Ee,onRefresh:()=>void R(),prUrl:Qe,onCheckout:Oe,branchMenuOpen:_,setBranchMenuOpen:E,newBranchOpen:Ce,setNewBranchOpen:Q,newBranchName:le,setNewBranchName:ae,onCreateBranch:_e,branchMenuRef:X}),t.jsxs("div",{style:{display:"flex",flex:1,minHeight:0,overflow:"hidden"},children:[t.jsx(yt,{t:n,stagedFiles:J,unstagedFiles:Z,totalCount:$.length,selectedPath:h,selectedStaged:p,onSelect:(i,c)=>{x(i),w(c)},query:v,setQuery:q,statusFilter:T,setStatusFilter:U,onStage:fe,onUnstage:ge,onStageAll:Ne,ahead:(r==null?void 0:r.ahead)??0,behind:(r==null?void 0:r.behind)??0,branchCurrent:l.current}),t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden",background:n.appBg},children:[D?t.jsxs(t.Fragment,{children:[t.jsx(bt,{t:n,entry:D,onStage:()=>fe(D.path),onUnstage:()=>ge(D.path),onDiscard:()=>Te(D.path),stagedView:p,diffView:ue,onDiffView:Pe}),ue==="plain"&&!k&&!I?t.jsx(vt,{t:n,diff:(m==null?void 0:m.diff)??"",entry:D}):t.jsx(jt,{t:n,diff:(m==null?void 0:m.diff)??"",entry:D,loading:k,error:I})]}):t.jsx(wt,{t:n,hasFiles:$.length>0}),xe?t.jsx(zt,{t:n,commitMsg:C,setCommitMsg:z,stagedCount:M.length,unstagedCount:Y.length,onCommit:Ae,onCommitAndPush:Ie,onRequestReview:ye,advancedOpen:de,onToggleAdvanced:()=>ce(i=>!i),busy:P}):null]}),xe?null:t.jsx(ft,{t:n,branch:l.current,pickedCount:M.length,totalCount:$.length,commitMsg:C,setCommitMsg:z,busy:P,sharedInfo:N,reviewUrl:K,onSuggest:Le,onShare:()=>void He(),onRequestReview:()=>void ye(),onStartNew:Ue,advancedOpen:de,onToggleAdvanced:()=>ce(i=>!i),context:Re,onEnableTracking:qe})]}),O&&t.jsx($t,{t:n,kind:O.kind,text:O.text})]})}function ct(e){const{t:n}=e;return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 20px",borderBottom:`1px solid ${n.headerBorder}`,background:n.appBg,flexShrink:0,whiteSpace:"nowrap"},children:[t.jsx("span",{style:{fontFamily:n.fontMono,fontSize:10,fontWeight:700,letterSpacing:"0.08em",padding:"3px 7px",borderRadius:3,background:`${n.accent}1f`,color:n.accent,border:`1px solid ${n.accent}40`},children:"GIT"}),t.jsx("span",{style:{fontSize:14,fontWeight:500,color:n.textPrimary},children:"Source control"}),t.jsxs("div",{ref:e.branchMenuRef,style:{position:"relative"},children:[t.jsxs("button",{onClick:()=>e.setBranchMenuOpen(!e.branchMenuOpen),style:{display:"inline-flex",alignItems:"center",gap:5,background:n.cellBg,border:`1px solid ${n.cellBorder}`,color:n.textPrimary,padding:"3px 8px",borderRadius:4,fontSize:11,fontFamily:n.fontMono,cursor:"pointer"},children:[t.jsx(re,{size:11,strokeWidth:1.75}),e.branchCurrent??"detached",t.jsx(Ye,{size:10,strokeWidth:1.75,style:{opacity:.6}})]}),e.branchMenuOpen&&t.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:220,maxHeight:360,overflow:"auto",background:n.cellBg,border:`1px solid ${n.cellBorder}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.18)",padding:"6px 0",zIndex:100},children:[e.branches.map(r=>t.jsxs("button",{onClick:()=>e.onCheckout(r),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"5px 10px",background:"transparent",border:"none",fontFamily:n.fontMono,fontSize:12,color:n.textPrimary,cursor:"pointer",textAlign:"left"},onMouseEnter:o=>o.currentTarget.style.background=n.btnHover,onMouseLeave:o=>o.currentTarget.style.background="transparent",children:[r===e.branchCurrent?t.jsx(ie,{size:11,strokeWidth:2,color:n.success}):t.jsx("span",{style:{width:11,display:"inline-block"}}),r]},r)),t.jsx("div",{style:{borderTop:`1px solid ${n.cellBorder}`,margin:"4px 0"}}),e.newBranchOpen?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"4px 8px"},children:[t.jsx("input",{autoFocus:!0,value:e.newBranchName,onChange:r=>e.setNewBranchName(r.target.value),onKeyDown:r=>{r.key==="Enter"&&e.onCreateBranch(),r.key==="Escape"&&(e.setNewBranchOpen(!1),e.setNewBranchName(""))},placeholder:"new-branch-name",style:{flex:1,background:n.appBg,color:n.textPrimary,border:`1px solid ${n.cellBorder}`,borderRadius:4,padding:"4px 7px",fontSize:12,fontFamily:n.fontMono,outline:"none"}}),t.jsx("button",{onClick:e.onCreateBranch,style:B(n,"primary"),children:"Create"})]}):t.jsxs("button",{onClick:()=>e.setNewBranchOpen(!0),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"6px 10px",background:"transparent",border:"none",fontSize:12,color:n.accent,cursor:"pointer",textAlign:"left"},onMouseEnter:r=>r.currentTarget.style.background=n.btnHover,onMouseLeave:r=>r.currentTarget.style.background="transparent",children:[t.jsx(Je,{size:11,strokeWidth:1.75}),"Create new branch…"]})]})]}),e.remoteUrl&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{fontSize:11,color:n.textMuted},children:"·"}),t.jsx("span",{style:{fontSize:11,color:n.textMuted,fontFamily:n.fontMono,maxWidth:360,overflow:"hidden",textOverflow:"ellipsis"},title:e.remoteUrl,children:ze(e.remoteUrl)})]}),t.jsx("span",{style:{fontSize:11,color:n.textMuted},children:"·"}),t.jsxs("span",{style:{fontSize:11,color:n.success,display:"inline-flex",alignItems:"center",gap:5},children:[t.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:n.success}}),"ready"]}),t.jsx("div",{style:{flex:1}}),t.jsx("button",{onClick:e.onRefresh,title:"Refresh",style:{background:"transparent",border:`1px solid ${n.btnBorder}`,padding:"6px 8px",borderRadius:5,cursor:"pointer",color:n.textMuted},children:t.jsx(Ze,{size:12,strokeWidth:1.75,style:{animation:e.refreshing?"dql-spin 0.6s linear":void 0}})}),t.jsx("style",{children:"@keyframes dql-spin { to { transform: rotate(360deg); } }"}),t.jsxs("button",{onClick:e.onPull,disabled:!!e.busy,style:ee(n),title:"Get updates from the shared project",children:[t.jsx(et,{size:12,strokeWidth:1.75,color:n.warning}),"Get updates",e.behind>0&&t.jsx("span",{style:{fontFamily:n.fontMono,fontSize:10,color:n.textMuted,marginLeft:2},children:e.behind})]}),t.jsxs("button",{onClick:e.onPush,disabled:!!e.busy,style:ee(n,!0),title:"Send the current branch to the shared project",children:[t.jsx(ke,{size:12,strokeWidth:1.75}),"Send branch",e.ahead>0&&t.jsx("span",{style:{fontFamily:n.fontMono,fontSize:10,opacity:.75,marginLeft:2},children:e.ahead})]}),e.prUrl&&t.jsxs("a",{href:e.prUrl,target:"_blank",rel:"noreferrer",style:{...ee(n),textDecoration:"none"},children:[t.jsx(we,{size:12,strokeWidth:1.75}),"Open PR"]})]})}function ee(e,n=!1){return{display:"inline-flex",alignItems:"center",gap:5,background:n?e.accent:e.cellBg,color:n?"#fff":e.textPrimary,border:`1px solid ${n?e.accent:e.btnBorder}`,padding:"5px 12px",borderRadius:6,fontSize:12,fontFamily:e.font,fontWeight:n?500:400,cursor:"pointer",whiteSpace:"nowrap"}}function B(e,n="default"){return{background:n==="primary"?e.accent:e.cellBg,color:n==="primary"?"#fff":e.textPrimary,border:`1px solid ${n==="primary"?e.accent:e.btnBorder}`,padding:"4px 9px",borderRadius:4,fontSize:11,cursor:"pointer",whiteSpace:"nowrap",fontFamily:e.font}}function ze(e){return e.replace(/^git@([^:]+):/,"$1/").replace(/^https?:\/\//,"").replace(/\.git$/,"")}function ut(e,n){if(!e||!n||n==="main"||n==="master"||n==="HEAD")return null;const r=ze(e),o=/(?:^|\/)github\.com\/([^/]+\/[^/]+)$/.exec(r);return o?`https://github.com/${o[1]}/compare/${encodeURIComponent(n)}?expand=1`:null}function ht(e){return`dql/review/${e.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,46)||"governed-update"}-${Date.now().toString(36)}`}function be(e){return e==="master"?"master":"main"}function xt(e,n){return e.length===n.length&&e.every((r,o)=>r===n[o])}function pt(e,n){return!!e&&e.inRepo===n.inRepo&&e.branch===n.branch&&e.ahead===n.ahead&&e.behind===n.behind&&e.changes.length===n.changes.length&&e.changes.every((r,o)=>{var l,u;return r.path===((l=n.changes[o])==null?void 0:l.path)&&r.status===((u=n.changes[o])==null?void 0:u.status)})}function H({t:e,state:n,index:r}){const o=n==="done"?{background:"var(--status-success-bg)",color:"var(--status-success)",border:"1.5px solid var(--status-success-border)"}:n==="active"?{background:"var(--accent-dim)",color:e.accent,border:`1.5px solid ${e.accent}`}:{background:e.appBg,color:e.textMuted,border:`1.5px solid ${e.headerBorder}`};return t.jsx("span",{style:{width:24,height:24,borderRadius:999,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700,flexShrink:0,...o},children:n==="done"?t.jsx(ie,{size:12,strokeWidth:3}):r})}function ft({t:e,branch:n,pickedCount:r,totalCount:o,commitMsg:l,setCommitMsg:u,busy:s,sharedInfo:a,reviewUrl:h,onSuggest:x,onShare:p,onRequestReview:w,onStartNew:m,advancedOpen:W,onToggleAdvanced:k,context:F,onEnableTracking:I}){const A=s==="commit"||s==="push",v=a!==null,q=h!==null&&v,T=r>0||v?"done":"active",U=v||l.trim()?"done":r>0?"active":"todo",C=v?"done":l.trim()?"active":"todo",z=q?"done":v?"active":"todo",P=t.jsx("span",{style:{width:1.5,flex:1,background:"var(--border-subtle)",margin:"4px 0"}});return t.jsxs("aside",{style:{width:"clamp(280px, 26vw, 350px)",flexShrink:0,background:e.cellBg,borderLeft:`1px solid ${e.headerBorder}`,display:"flex",flexDirection:"column",minHeight:0,overflow:"auto"},children:[t.jsxs("div",{style:{padding:"14px 16px 12px",borderBottom:"1px solid var(--border-subtle)"},children:[t.jsx("div",{style:{fontSize:13,fontWeight:700,color:e.textPrimary},children:"Share your work"}),t.jsx("div",{style:{fontSize:11,color:e.textMuted,marginTop:2},children:"Four steps — no git commands needed."})]}),t.jsxs("div",{style:{padding:"14px 16px 20px",display:"flex",flexDirection:"column"},children:[t.jsxs("div",{style:{display:"flex",gap:11},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0},children:[t.jsx(H,{t:e,state:T,index:1}),P]}),t.jsxs("div",{style:{flex:1,minWidth:0,paddingBottom:18},children:[t.jsx("div",{style:{fontSize:12.5,fontWeight:650,color:e.textPrimary},children:"Pick what to share"}),t.jsx("div",{style:{fontSize:11.5,color:e.textMuted,lineHeight:1.5,marginTop:2},children:v?`${a.count} change${a.count===1?"":"s"} shared.`:`${r} of ${o} change${o===1?"":"s"} selected in the left panel. Review each one before moving on.`})]})]}),t.jsxs("div",{style:{display:"flex",gap:11},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0},children:[t.jsx(H,{t:e,state:U,index:2}),P]}),t.jsxs("div",{style:{flex:1,minWidth:0,paddingBottom:18},children:[t.jsx("div",{style:{fontSize:12.5,fontWeight:650,color:e.textPrimary},children:"Describe your change"}),v?t.jsxs("div",{style:{fontSize:11.5,color:e.textMuted,lineHeight:1.5,marginTop:2},children:["“",a.message,"”"]}):t.jsxs("div",{style:{marginTop:7,display:"flex",flexDirection:"column",gap:6},children:[t.jsx("textarea",{rows:2,value:l,onChange:G=>u(G.target.value),placeholder:"What did you change, in plain words?",style:{border:`1px solid ${e.headerBorder}`,background:e.appBg,borderRadius:8,padding:"8px 10px",fontSize:12,lineHeight:1.5,fontFamily:e.font,color:e.textPrimary,outline:"none",resize:"vertical"}}),t.jsxs("button",{type:"button",onClick:x,style:{display:"inline-flex",alignItems:"center",gap:5,width:"fit-content",border:"none",background:"none",color:e.accent,fontSize:11,fontWeight:600,cursor:"pointer",fontFamily:e.font,padding:0},children:[t.jsx(it,{size:11})," Write it for me from the changes"]})]})]})]}),t.jsxs("div",{style:{display:"flex",gap:11},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0},children:[t.jsx(H,{t:e,state:C,index:3}),P]}),t.jsxs("div",{style:{flex:1,minWidth:0,paddingBottom:18},children:[t.jsx("div",{style:{fontSize:12.5,fontWeight:650,color:e.textPrimary},children:"Share to your branch"}),t.jsxs("div",{style:{fontSize:11.5,color:e.textMuted,lineHeight:1.5,marginTop:2},children:["Saves your work to ",n&&n!=="main"&&n!=="master"?t.jsx("span",{style:{fontFamily:e.fontMono,fontSize:10.5},children:n}):"a new review branch"," — main stays untouched."]}),A?t.jsx("div",{style:{marginTop:8,fontSize:12,fontWeight:700,backgroundImage:`linear-gradient(100deg, ${e.textPrimary} 25%, ${e.accent} 50%, ${e.textPrimary} 75%)`,backgroundSize:"220% 100%",WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",WebkitTextFillColor:"transparent",animation:"dql-git-shimmer 2s linear infinite"},children:"Sharing your changes…"}):v?t.jsxs("div",{style:{marginTop:6,display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,color:"var(--status-success)",fontWeight:600},children:[t.jsx(ie,{size:12,strokeWidth:2.5})," Shared · ",a.count," change",a.count===1?"":"s"," on your branch"]}):t.jsxs("button",{type:"button",onClick:p,disabled:!l.trim()||r===0,style:{marginTop:8,display:"inline-flex",alignItems:"center",gap:7,height:32,padding:"0 14px",borderRadius:8,border:"none",background:l.trim()&&r>0?e.accent:e.btnBg,color:l.trim()&&r>0?"#fff":e.textMuted,fontSize:12,fontWeight:650,cursor:l.trim()&&r>0?"pointer":"default",fontFamily:e.font,boxShadow:l.trim()&&r>0?"0 1px 4px rgba(107,93,211,0.25)":"none"},children:[t.jsx(ke,{size:12,strokeWidth:2})," Share ",r>0?`${r} change${r===1?"":"s"}`:"changes"]})]})]}),t.jsxs("div",{style:{display:"flex",gap:11},children:[t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0},children:t.jsx(H,{t:e,state:z,index:4})}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:12.5,fontWeight:650,color:e.textPrimary},children:"Ask for review"}),q?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{marginTop:8,border:"1px solid var(--status-success-border)",background:"var(--status-success-bg)",borderRadius:10,padding:"11px 13px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[t.jsx(me,{size:13,color:"var(--status-success)"}),t.jsx("span",{style:{fontSize:12,fontWeight:700,color:"var(--status-success)"},children:"Review request opened"})]}),t.jsxs("div",{style:{fontSize:11.5,color:"var(--status-success)",lineHeight:1.55,marginTop:5},children:["“",a==null?void 0:a.message,"” — you'll be notified on approval. Nothing reaches main until then."]}),t.jsxs("a",{href:h,target:"_blank",rel:"noreferrer",style:{display:"inline-flex",alignItems:"center",gap:5,marginTop:9,fontSize:11.5,fontWeight:600,color:e.accent,textDecoration:"none"},children:["View on GitHub ",t.jsx(we,{size:11})]})]}),t.jsx("button",{type:"button",onClick:m,style:{marginTop:10,border:"none",background:"none",color:e.textMuted,fontSize:11,fontWeight:600,cursor:"pointer",fontFamily:e.font,padding:0},children:"Start a new change"})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{fontSize:11.5,color:e.textMuted,lineHeight:1.5,marginTop:2},children:"A teammate approves before anything reaches main."}),v?t.jsxs("button",{type:"button",onClick:w,disabled:s==="request review",style:{marginTop:8,display:"inline-flex",alignItems:"center",gap:7,height:32,padding:"0 14px",borderRadius:8,border:"none",background:e.accent,color:"#fff",fontSize:12,fontWeight:650,cursor:"pointer",fontFamily:e.font,width:"fit-content",boxShadow:"0 1px 4px rgba(107,93,211,0.25)",opacity:s==="request review"?.7:1},children:[t.jsx(me,{size:12,strokeWidth:1.75})," ",s==="request review"?"Opening…":"Open review request"]}):null]})]})]})]}),t.jsxs("div",{style:{marginTop:"auto",borderTop:"1px solid var(--border-subtle)"},children:[t.jsxs("button",{type:"button",onClick:k,style:{width:"100%",textAlign:"left",border:"none",background:"none",color:e.textMuted,fontSize:11,fontWeight:600,cursor:"pointer",fontFamily:e.font,padding:"10px 16px"},children:[W?"▾":"▸"," Advanced"]}),W&&F?t.jsx("div",{style:{padding:"0 16px 14px"},children:t.jsx(gt,{t:e,context:F,onEnableTracking:I})}):null]}),t.jsx("style",{children:"@keyframes dql-git-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }"})]})}function gt({t:e,context:n,onEnableTracking:r}){const o=(s,a)=>a.total===0?`${s}: none yet`:a.ignored>0?`${s}: ${a.total} found · ${a.ignored} hidden from Git`:a.changed>0||a.untracked>0?`${s}: ${a.total} · ${a.changed+a.untracked} need review`:`${s}: ${a.total} tracked`,l=[["Domains",n.domains],["Skills",n.skills],["Project source",n.artifacts],["Governed learning",n.learning]],u=!n.trackingReady;return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"7px 10px",background:u?`${e.warning}10`:`${e.success}0d`,border:`1px solid ${u?`${e.warning}45`:`${e.success}35`}`,borderRadius:6,flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:10,fontWeight:750,letterSpacing:"0.05em",textTransform:"uppercase",color:u?e.warning:e.success},children:"Governed context"}),t.jsx("span",{style:{fontSize:11,color:e.textPrimary},children:o("Domains",n.domains)}),t.jsx("span",{style:{color:e.textMuted},children:"·"}),t.jsx("span",{style:{fontSize:11,color:e.textPrimary},children:o("Skills",n.skills)}),t.jsx("span",{style:{color:e.textMuted},children:"·"}),t.jsx("span",{style:{fontSize:11,color:e.textPrimary},children:o("Project source",n.artifacts)}),t.jsx("span",{style:{color:e.textMuted},children:"·"}),t.jsx("span",{style:{fontSize:11,color:e.textPrimary},children:o("Governed learning",n.learning)}),t.jsx("div",{style:{flex:1}}),u?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{fontSize:10,color:e.textMuted},children:n.legacyBroadIgnore?"A legacy .dql/ rule is hiding governed learning.":"Some shared project source is hidden from Git."}),t.jsx("button",{type:"button",onClick:r,style:B(e,"primary"),children:"Repair source-control tracking"})]}):t.jsx("span",{style:{fontSize:10,color:e.textMuted},children:"Shared project source"}),t.jsxs("details",{style:{width:"100%",borderTop:`1px solid ${e.headerBorder}`,paddingTop:5},children:[t.jsx("summary",{style:{cursor:"pointer",fontSize:10,color:e.textSecondary},children:"View governed source inventory"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(210px, 1fr))",gap:8,marginTop:7},children:l.map(([s,a])=>t.jsxs("div",{style:{minWidth:0},children:[t.jsx("div",{style:{fontSize:10,fontWeight:700,color:e.textPrimary,marginBottom:3},children:s}),a.paths.length===0?t.jsx("div",{style:{fontSize:10,color:e.textMuted},children:"No files yet"}):a.paths.map(h=>t.jsxs("div",{title:h.path,style:{display:"flex",gap:5,minWidth:0,fontSize:9.5,lineHeight:1.5},children:[t.jsx("span",{style:{color:h.state==="ignored"?e.error:h.state==="tracked"?e.success:e.warning,flexShrink:0},children:h.state}),t.jsx("span",{style:{color:e.textSecondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.path})]},`${s}:${h.path}`))]},s))})]})]})}function te(e){return e.startsWith(".dql/local/")||/ai[-_]?pin|saved[-_]?view|layout[-_]?override/i.test(e)?{id:"local",label:"Local/private",tone:"danger",rank:4}:e.startsWith(".dql/cache/")||e.startsWith(".dql/imports/")||e.startsWith("data/")||e==="dql-manifest.json"||/\.run\.json$/i.test(e)||/\.(sqlite|duckdb|duckdb\.wal)$/i.test(e)?{id:"generated",label:"Generated",tone:"warn",rank:3}:/\.dqlnb$/i.test(e)?{id:"notebooks",label:"Curated notebook",tone:"neutral",rank:2}:/\/apps\/[^/]+\/dql\.app\.json$/.test(e)||/^apps\/[^/]+\/dql\.app\.json$/.test(e)||/\/dashboards\/[^/]+\.dqld$/.test(e)||/^apps\/[^/]+\/dashboards\/[^/]+\.dqld$/.test(e)?{id:"apps",label:"Shared app",tone:"neutral",rank:1}:e.startsWith("skills/")||e.startsWith(".dql/skills/")||/^domains\//i.test(e)||/^\.dql\/(hints|traces|evaluations|reviews)\//i.test(e)?{id:"business",label:"Governed context",tone:"good",rank:0}:/\.dql$/i.test(e)||e.startsWith("semantic-layer/")||/\.(ya?ml)$/i.test(e)||e==="dql.config.json"||e==="package.json"?{id:"business",label:"Business logic",tone:"good",rank:0}:{id:"apps",label:"Shared source",tone:"neutral",rank:1}}function ve(e,n){const r=te(e.path),o=te(n.path);return r.rank-o.rank||e.path.localeCompare(n.path)}function yt(e){const{t:n}=e;return t.jsxs("div",{style:{width:300,flexShrink:0,background:n.sidebarBg,borderRight:`1px solid ${n.headerBorder}`,display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsxs("div",{style:{padding:"12px 14px 10px",borderBottom:`1px solid ${n.headerBorder}`},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8,fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:n.textMuted},children:"Source control"}),t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,marginBottom:10},children:[t.jsx("span",{style:{fontSize:18,fontWeight:700,letterSpacing:"-0.01em",color:n.textPrimary},children:"Changes"}),t.jsxs("span",{style:{fontSize:11,color:n.textMuted},children:[e.totalCount," files"]}),t.jsx("div",{style:{flex:1}}),e.unstagedFiles.length>0&&t.jsx("button",{onClick:e.onStageAll,style:B(n),children:"Include all"})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,background:n.cellBg,border:`1px solid ${n.cellBorder}`,borderRadius:6,padding:"5px 9px",marginBottom:7},children:[t.jsx(tt,{size:11,strokeWidth:1.75,color:n.textMuted}),t.jsx("input",{value:e.query,onChange:r=>e.setQuery(r.target.value),placeholder:"Filter by path…",style:{background:"transparent",border:"none",outline:"none",color:n.textPrimary,fontSize:12,flex:1,width:"100%",fontFamily:n.font}}),e.query&&t.jsx("button",{onClick:()=>e.setQuery(""),style:{background:"transparent",border:"none",color:n.textMuted,cursor:"pointer",padding:0},children:t.jsx(st,{size:11,strokeWidth:1.75})})]}),t.jsx("select",{value:e.statusFilter,onChange:r=>e.setStatusFilter(r.target.value),style:{width:"100%",background:n.cellBg,color:n.textPrimary,border:`1px solid ${n.cellBorder}`,borderRadius:6,padding:"5px 9px",fontSize:12,cursor:"pointer",fontFamily:n.font},children:lt.map(r=>t.jsx("option",{value:r.key,children:r.label},r.key))})]}),t.jsxs("div",{style:{flex:1,overflow:"auto",padding:"6px 8px"},children:[t.jsx(je,{t:n,label:"Included",count:e.stagedFiles.length}),e.stagedFiles.length===0?t.jsx("div",{style:{fontSize:11,color:n.textMuted,padding:"4px 10px",fontStyle:"italic"},children:"No files included yet"}):e.stagedFiles.map(r=>t.jsx(Se,{t:n,file:r,active:e.selectedPath===r.path&&e.selectedStaged===!0,onClick:()=>e.onSelect(r.path,!0),actionLabel:"Remove",onAction:()=>e.onUnstage(r.path)},`staged-${r.path}`)),t.jsx("div",{style:{height:8}}),t.jsx(je,{t:n,label:"Needs review",count:e.unstagedFiles.length}),e.unstagedFiles.length===0?t.jsx("div",{style:{fontSize:11,color:n.textMuted,padding:"4px 10px",fontStyle:"italic"},children:e.totalCount===0?"Everything is up to date":"No additional files to review"}):e.unstagedFiles.map(r=>t.jsx(Se,{t:n,file:r,active:e.selectedPath===r.path&&e.selectedStaged===!1,onClick:()=>e.onSelect(r.path,!1),actionLabel:"Include",onAction:()=>e.onStage(r.path)},`unstaged-${r.path}`))]}),t.jsx("div",{style:{padding:"10px 14px",borderTop:"1px solid var(--border-subtle)",fontSize:10.5,color:n.textMuted,lineHeight:1.5},children:"Unselected changes stay safely in your workspace — nothing is lost."}),t.jsxs("div",{style:{padding:"8px 14px",borderTop:"1px solid var(--border-subtle)",fontSize:10,color:n.textMuted,display:"flex",alignItems:"center",gap:6},children:[t.jsx(re,{size:11,strokeWidth:1.75}),t.jsx("span",{style:{fontFamily:n.fontMono,color:n.textPrimary},children:e.branchCurrent??"detached"}),t.jsx("span",{children:"·"}),e.behind>0&&t.jsxs("span",{style:{color:n.warning},children:["↓",e.behind]}),e.ahead>0&&t.jsxs("span",{style:{color:n.success},children:["↑",e.ahead]}),e.behind===0&&e.ahead===0&&t.jsx("span",{children:"up to date"})]})]})}function je({t:e,label:n,count:r}){return t.jsxs("div",{style:{fontSize:10,color:e.textMuted,fontWeight:600,letterSpacing:"0.07em",textTransform:"uppercase",padding:"6px 8px 4px",display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{children:n}),t.jsx("span",{style:{color:e.textMuted,opacity:.7},children:"·"}),t.jsx("span",{style:{color:e.textMuted},children:r})]})}function Se({t:e,file:n,active:r,onClick:o,actionLabel:l,onAction:u}){const[s,a]=d.useState(!1),h=n.path.split("/").slice(0,-1).join("/"),x=n.path.split("/").pop()??n.path,p=te(n.path);return t.jsxs("div",{onClick:o,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:5,marginBottom:1,cursor:"pointer",background:r?`${e.accent}18`:s?e.btnHover:"transparent",border:r?`1px solid ${e.accent}45`:"1px solid transparent"},children:[t.jsx($e,{t:e,status:n.status}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:12,color:e.textPrimary,fontFamily:e.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x}),h&&t.jsx("div",{style:{fontSize:10,color:e.textMuted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h}),t.jsx("div",{style:{marginTop:4,display:"flex",alignItems:"center",gap:5},children:t.jsx("span",{style:mt(e,p),children:p.label})})]}),s&&t.jsx("button",{onClick:w=>{w.stopPropagation(),u()},style:{background:e.cellBg,border:`1px solid ${e.btnBorder}`,color:e.textPrimary,padding:"2px 7px",borderRadius:3,fontSize:10,cursor:"pointer",flexShrink:0,fontFamily:e.font},children:l})]})}function mt(e,n){const r=n.tone==="good"?e.success:n.tone==="warn"?e.warning:n.tone==="danger"?e.error:e.textMuted;return{display:"inline-flex",alignItems:"center",minWidth:0,maxWidth:"100%",border:`1px solid ${r}35`,background:`${r}12`,color:r,borderRadius:3,padding:"1px 5px",fontSize:9,fontWeight:650,lineHeight:"14px",whiteSpace:"nowrap"}}function $e({t:e,status:n}){const r={M:{label:"Edited",color:e.warning},A:{label:"New",color:e.success},D:{label:"Removed",color:e.error},R:{label:"Renamed",color:e.accent},"?":{label:"New",color:e.success}},{label:o,color:l}=r[n];return t.jsx("span",{style:{flexShrink:0,padding:"1.5px 7px",borderRadius:999,background:`${l}1a`,color:l,fontSize:9.5,fontWeight:700,fontFamily:e.font,whiteSpace:"nowrap"},children:o})}function bt({t:e,entry:n,stagedView:r,onStage:o,onUnstage:l,onDiscard:u,diffView:s,onDiffView:a}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"9px 16px",borderBottom:`1px solid ${e.headerBorder}`,background:e.cellBg,flexShrink:0},children:[t.jsx("div",{style:{fontSize:12,fontWeight:650,color:e.textPrimary,fontFamily:e.fontMono,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.path}),t.jsx($e,{t:e,status:n.status}),n.partiallyStaged&&t.jsx("span",{style:{fontSize:10.5,color:e.warning,whiteSpace:"nowrap"},children:"partially included"}),t.jsx("div",{style:{flex:1}}),t.jsxs("div",{role:"group","aria-label":"Diff view",style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,border:`1px solid ${e.headerBorder}`,borderRadius:7,background:e.appBg,flexShrink:0},children:[t.jsx("button",{type:"button",onClick:()=>a("plain"),style:{border:"none",borderRadius:5,padding:"3.5px 10px",fontSize:11,fontWeight:600,cursor:"pointer",fontFamily:e.font,background:s==="plain"?"var(--accent-dim)":"transparent",color:s==="plain"?e.accent:e.textMuted},children:"What changed"}),t.jsx("button",{type:"button",onClick:()=>a("code"),style:{border:"none",borderRadius:5,padding:"3.5px 10px",fontSize:11,fontWeight:600,cursor:"pointer",fontFamily:e.font,background:s==="code"?"var(--accent-dim)":"transparent",color:s==="code"?e.accent:e.textMuted},children:"Code view"})]}),!r&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:u,style:B(e),children:"Discard"}),t.jsx("button",{onClick:o,style:B(e,"primary"),children:"Include"})]}),r&&t.jsx("button",{onClick:l,style:B(e),children:"Remove"})]})}function vt({t:e,diff:n,entry:r}){const o=Be(n),l=[];let u="",s=0,a=0;for(const x of o)if(x.kind==="hunk"&&(u=x.text.replace(/^@@[^@]*@@\s*/,"").trim()),x.kind==="add"&&(s+=1),x.kind==="del"&&(a+=1),(x.kind==="add"||x.kind==="del")&&l.length<5){const p=x.text.replace(/^[+-]\s?/,"").trim();p&&!l.some(w=>w.text.includes(p.slice(0,40)))&&l.push({mark:x.kind==="add"?"+":"−",text:`${x.kind==="add"?"Added":"Removed"}${u?` in ${u}`:""}: ${p.slice(0,90)}`})}const h={"+":{bg:"var(--status-success-bg)",color:"var(--status-success)"},"−":{bg:"var(--status-error-bg)",color:"var(--status-error)"},"±":{bg:"var(--status-warning-bg)",color:"var(--status-warning)"}};return t.jsx("div",{style:{flex:1,overflow:"auto",padding:16},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,maxWidth:560},children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:e.textMuted},children:"Summary of this change"}),t.jsx("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:10,background:e.cellBg,overflow:"hidden"},children:l.length===0?t.jsx("div",{style:{padding:"10px 13px",fontSize:12.5,color:e.textMuted},children:r.status==="?"?"A brand-new file — everything in it is an addition.":"No line-level changes to summarize for this selection."}):l.map((x,p)=>t.jsxs("div",{style:{display:"flex",gap:9,padding:"10px 13px",borderBottom:p<l.length-1?"1px solid var(--border-subtle)":"none",alignItems:"flex-start"},children:[t.jsx("span",{style:{flexShrink:0,width:18,height:18,borderRadius:5,background:h[x.mark].bg,color:h[x.mark].color,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700},children:x.mark}),t.jsx("span",{style:{fontSize:12.5,color:e.textPrimary,lineHeight:1.5,fontFamily:e.fontMono,overflowWrap:"anywhere"},children:x.text})]},p))}),t.jsxs("div",{style:{fontSize:11,color:e.textMuted},children:[s," addition",s===1?"":"s"," · ",a," removal",a===1?"":"s"," — switch to Code view for the full detail."]}),t.jsxs("div",{style:{display:"flex",gap:9,alignItems:"flex-start",border:"1px solid var(--status-success-border)",background:"var(--status-success-bg)",borderRadius:10,padding:"10px 13px"},children:[t.jsx(nt,{size:13,color:"var(--status-success)",style:{flexShrink:0,marginTop:1}}),t.jsx("span",{style:{fontSize:12,color:"var(--status-success)",lineHeight:1.55},children:"Nothing reaches main until a reviewer approves — your workspace stays safe."})]})]})})}function jt({t:e,diff:n,entry:r,loading:o,error:l}){return o?t.jsx(ne,{t:e,title:"Loading diff",body:"Preparing the selected change for review."}):l?t.jsx(ne,{t:e,title:"Could not load diff",body:l,tone:"error"}):t.jsx(St,{t:e,diff:n,entry:r})}function St({t:e,diff:n,entry:r}){return n.trim()?t.jsx("div",{style:{flex:1,overflow:"auto",background:e.cellBg,fontFamily:e.fontMono,fontSize:12,lineHeight:"20px"},children:Be(n).map((o,l)=>t.jsx(kt,{t:e,line:o},l))}):t.jsx(ne,{t:e,title:"No text hunks to review",body:r.status==="?"?"This untracked item does not expose a readable text diff yet. Stage it to include it in the next commit.":"Git reports this file changed, but there are no line-level text hunks for this selection."})}function ne({t:e,title:n,body:r,tone:o="muted"}){const l=o==="error"?e.error:e.textMuted;return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:e.appBg,padding:32},children:t.jsxs("div",{style:{maxWidth:420,border:`1px solid ${o==="error"?`${e.error}55`:e.cellBorder}`,background:e.cellBg,borderRadius:8,padding:18,display:"flex",flexDirection:"column",gap:7,textAlign:"center"},children:[t.jsx("div",{style:{fontSize:14,fontWeight:600,color:o==="error"?e.error:e.textPrimary},children:n}),t.jsx("div",{style:{fontSize:12,lineHeight:1.5,color:l},children:r})]})})}function Be(e){const n=[];let r=0,o=0;const l=e.split(`
7
- `);let u=0;for(const s of l){if(u++>1e3){n.push({kind:"meta",text:"… diff truncated (over 1000 lines)",oldNum:null,newNum:null});break}if(!(s.startsWith("diff --git")||s.startsWith("index ")||s.startsWith("+++ ")||s.startsWith("--- "))){if(s.startsWith("new file mode ")||s.startsWith("deleted file mode ")||s.startsWith("old mode ")||s.startsWith("new mode ")||s.startsWith("rename from ")||s.startsWith("rename to ")||s.startsWith("Binary file ")||s.startsWith("# ")){n.push({kind:"meta",text:s,oldNum:null,newNum:null});continue}if(s.startsWith("@@")){const a=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(s);a&&(r=Number(a[1]),o=Number(a[2])),n.push({kind:"hunk",text:s,oldNum:null,newNum:null});continue}s.startsWith("+")?n.push({kind:"add",text:s.slice(1),oldNum:null,newNum:o++}):s.startsWith("-")?n.push({kind:"del",text:s.slice(1),oldNum:r++,newNum:null}):s.startsWith("\\")?n.push({kind:"meta",text:s,oldNum:null,newNum:null}):n.push({kind:"ctx",text:s.startsWith(" ")?s.slice(1):s,oldNum:r++,newNum:o++})}}return n}function kt({t:e,line:n}){if(n.kind==="hunk")return t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"80px 1fr",background:`${e.accent}14`,borderTop:`1px solid ${e.accent}30`,borderBottom:`1px solid ${e.accent}30`,color:e.accent},children:[t.jsx("div",{style:{padding:"2px 10px",textAlign:"right",borderRight:`1px solid ${e.accent}30`,color:e.textMuted},children:"⋯"}),t.jsx("div",{style:{padding:"2px 12px",whiteSpace:"pre"},children:n.text})]});if(n.kind==="meta")return t.jsx("div",{style:{padding:"2px 12px",color:e.textMuted,fontStyle:"italic"},children:n.text});const r={add:{bg:`${e.success}18`,gutter:`${e.success}55`,ch:"+",chColor:e.success},del:{bg:`${e.error}18`,gutter:`${e.error}55`,ch:"−",chColor:e.error},ctx:{bg:"transparent",gutter:e.cellBorder,ch:" ",chColor:e.textMuted}}[n.kind];return t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"40px 40px 20px 1fr",background:r.bg,borderLeft:`3px solid ${r.gutter}`},children:[t.jsx("div",{style:{padding:"0 6px",color:e.textMuted,textAlign:"right",userSelect:"none"},children:n.oldNum??""}),t.jsx("div",{style:{padding:"0 6px",color:e.textMuted,textAlign:"right",userSelect:"none",borderRight:`1px solid ${e.cellBorder}`},children:n.newNum??""}),t.jsx("div",{style:{padding:"0 4px",color:r.chColor,textAlign:"center",userSelect:"none"},children:r.ch}),t.jsx("div",{style:{padding:"0 10px",whiteSpace:"pre",color:e.textPrimary,overflow:"hidden"},children:n.text})]})}function wt({t:e,hasFiles:n}){return t.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:8,color:e.textMuted,fontSize:13,background:e.appBg},children:[t.jsx(rt,{size:28,strokeWidth:1.5,color:e.textMuted,style:{opacity:.4}}),n?"Select a file to view its diff":"Working tree clean — no changes to review"]})}function zt({t:e,commitMsg:n,setCommitMsg:r,stagedCount:o,unstagedCount:l,onCommit:u,onCommitAndPush:s,onRequestReview:a,advancedOpen:h,onToggleAdvanced:x,busy:p}){const w=o===0&&l>0,m=o===0&&l===0,W=w?`${l} change${l===1?"":"s"} will be included in the review request`:o>0?`${o} change${o===1?"":"s"} prepared for review`:"No changes to share";return t.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${e.headerBorder}`,background:e.cellBg,flexShrink:0,display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("div",{style:{fontSize:11,color:e.textMuted,flex:1},children:W}),t.jsx("span",{style:{fontSize:10,color:e.textMuted},children:"A review branch is created when needed."})]}),t.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[t.jsx("input",{value:n,onChange:k=>r(k.target.value),onKeyDown:k=>{(k.metaKey||k.ctrlKey)&&k.key==="Enter"&&(k.preventDefault(),a())},placeholder:"Describe this update for your reviewer…",style:{flex:1,background:e.appBg,color:e.textPrimary,border:`1px solid ${e.cellBorder}`,borderRadius:6,padding:"7px 10px",fontSize:12,outline:"none",fontFamily:e.font}}),t.jsx("button",{onClick:a,disabled:!!p||m||!n.trim(),style:{background:e.accent,color:"#fff",border:`1px solid ${e.accent}`,padding:"7px 14px",borderRadius:6,fontSize:12,fontWeight:700,cursor:"pointer",opacity:m||!n.trim()?.5:1,fontFamily:e.font},children:"Request review"}),t.jsx("button",{onClick:x,style:B(e),children:h?"Hide details":"More options"})]}),h&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,paddingTop:2},children:[t.jsx("span",{style:{fontSize:10,color:e.textMuted,flex:1},children:"Advanced Git actions are optional. They do not merge changes."}),t.jsx("button",{onClick:u,disabled:!!p||m||!n.trim(),style:{...B(e),opacity:m||!n.trim()?.45:1},children:"Save locally"}),t.jsx("button",{onClick:s,disabled:!!p||m||!n.trim(),style:{...B(e),opacity:m||!n.trim()?.45:1},children:"Commit & push"})]})]})}function $t({t:e,kind:n,text:r}){const o=n==="ok"?e.success:e.error;return t.jsx("div",{style:{position:"absolute",bottom:80,right:24,background:e.cellBg,border:`1px solid ${o}55`,borderLeft:`3px solid ${o}`,borderRadius:6,padding:"8px 14px",fontSize:12,color:e.textPrimary,boxShadow:"0 8px 24px rgba(0,0,0,0.18)",maxWidth:420,zIndex:200},children:r})}function Bt({t:e}){return t.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:12,padding:40,background:e.appBg},children:[t.jsx(re,{size:36,strokeWidth:1.5,color:e.textMuted,style:{opacity:.5}}),t.jsx("div",{style:{fontSize:16,fontWeight:600,color:e.textPrimary},children:"Not a git repository"}),t.jsxs("div",{style:{fontSize:13,color:e.textMuted,maxWidth:420,textAlign:"center"},children:["Initialize this folder with ",t.jsx("code",{style:{fontFamily:e.fontMono},children:"git init"})," to start tracking changes."]})]})}export{Dt as GitPage};
@@ -1 +0,0 @@
1
- import{u as m,t as u,r as c,j as s}from"./index-Ca3UeUWI.js";import{U as A}from"./UnifiedAgentRunPanel-CwxQ4T19.js";import{A as g,a as x,b as h}from"./AiSidePanel-C7BZVSkM.js";import{u as b}from"./usePersistedAgentThreadId-DbdBi0oH.js";import"./react-CRB3T2We.js";import"./AgentAnswerCard-Dp4odOLE.js";import"./TrustBadge-DPnKzRSY.js";import"./AiBuildResult-B9KmBRsh.js";import"./user-round-DSt0xU3K.js";import"./triangle-alert-DUf4Ook0.js";import"./rotate-ccw-DndbJAiz.js";import"./x-9Gtb3EAd.js";import"./pencil-Cf6-MgpT.js";import"./list-tree-BrIZg6l6.js";import"./wrench-DxUnoHtz.js";import"./arrow-right-OYItAZ-s.js";import"./chevron-up-DM5LX-26.js";import"./minimize-2-CUDBPkwe.js";import"./maximize-2-CQOA-bbN.js";function O(){const{state:e,dispatch:n}=m(),r=u[e.themeMode],{audience:p,context:t}=e.globalAi,l=t.selectedObject,a=b("global-rail"),[i,d]=c.useState(!1);return s.jsx(g,{t:r,title:t.title??"AI copilot",subtitle:t.scopeHint??"Ask a follow-up about what you are viewing",expanded:i,onToggleExpanded:()=>d(o=>!o),onClose:()=>n({type:"CLOSE_GLOBAL_AI"}),ariaLabel:"App AI",style:{width:i?`min(${x}px, calc(100vw - 96px))`:`min(${h}px, calc(100vw - 64px))`,maxWidth:i?"62vw":"46vw",minWidth:320,flex:"0 0 auto"},children:s.jsx(A,{themeMode:e.themeMode,title:t.title??"AI copilot",scopeHint:t.scopeHint??"Ask a follow-up about what you are viewing",audience:p,selectedObject:l,workspaceContext:t.workspaceContext,examplePrompts:Array.isArray(t.suggestedQuestions)&&t.suggestedQuestions.length>0?t.suggestedQuestions.filter(o=>typeof o=="string").slice(0,4).map(o=>({label:o,prompt:o})):void 0,autoRun:e.globalAi.autoRun?{text:e.globalAi.autoRun.text,mode:e.globalAi.autoRun.mode,nonce:e.globalAi.autoRun.nonce}:void 0,threadId:a.threadId,onThreadIdChange:a.onThreadIdChange,initialMode:"auto"})})}export{O as GlobalAiRail};