@duckcodeailabs/dql-cli 1.13.1 → 1.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps-api.d.ts +249 -7
- package/dist/apps-api.d.ts.map +1 -1
- package/dist/apps-api.js +2855 -160
- package/dist/apps-api.js.map +1 -1
- package/dist/assets/dql-notebook/assets/{AgentLogPage-D6fgEAEy.js → AgentLogPage-B3ugEb3H.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildDialog-8miXFPse.js → AiBuildDialog-BK_TDNcM.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildResult-DPJ_SI0R.js → AiBuildResult-Cob_Lj05.js} +8 -8
- package/dist/assets/dql-notebook/assets/{AiSidePanel-NVA6lZnn.js → AiSidePanel-CzIgxmP9.js} +1 -1
- package/dist/assets/dql-notebook/assets/AnalyticsHome-C2vJ2fxY.js +6 -0
- package/dist/assets/dql-notebook/assets/AppsView-DEWQ0sHT.js +5588 -0
- package/dist/assets/dql-notebook/assets/BlockStudio-CaDNTKMM.js +55 -0
- package/dist/assets/dql-notebook/assets/{BusinessArtifactView-DtRMiaF4.js → BusinessArtifactView-zwUOtddi.js} +1 -1
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-BlnhTMu3.js +22 -0
- package/dist/assets/dql-notebook/assets/{GitPage-CazC-eTR.js → GitPage-Coevr9NJ.js} +3 -3
- package/dist/assets/dql-notebook/assets/GlobalAiRail-BTZS11x5.js +1 -0
- package/dist/assets/dql-notebook/assets/GovernedContextPage-CjyyM_ne.js +7 -0
- package/dist/assets/dql-notebook/assets/{HelpDocsPage-DMHPsVqP.js → HelpDocsPage-C1UeP85v.js} +1 -1
- package/dist/assets/dql-notebook/assets/{HomePage-DcSI4dnU.js → HomePage-zGPFIvOY.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDAG-BJ6xz06u.js → LineageDAG-DbXnQWu3.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDetailView-8WrQm-MF.js → LineageDetailView-Ch1Db01I.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDrawer-hnqCW_t-.js → LineageDrawer-DLxqJO6D.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineagePathBreadcrumb-B4LZTUsl.js → LineagePathBreadcrumb-B2tNdkr_.js} +3 -3
- package/dist/assets/dql-notebook/assets/{MiniLineageGraph-CotnRuxa.js → MiniLineageGraph-0gY-ZwCy.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewBlockModal-DHn-CEEW.js → NewBlockModal-DKVkXD20.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewNotebookModal-BPGp-8oq.js → NewNotebookModal-BUIByvYT.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NotebookEditor-B0OTHM6W.js → NotebookEditor-D2fIUxjE.js} +5 -5
- package/dist/assets/dql-notebook/assets/{ReadinessPage-CoOIpxWq.js → ReadinessPage-Ci4LyNiQ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{SetupOnboarding-DxK_mFzf.js → SetupOnboarding-BF7ai_0t.js} +1 -1
- package/dist/assets/dql-notebook/assets/SkillsPage-BgYrgirJ.js +10 -0
- package/dist/assets/dql-notebook/assets/{TrustBadge-ZuD5N5Ww.js → TrustBadge-Bob1Laiq.js} +1 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-IxDUKSG8.js +88 -0
- package/dist/assets/dql-notebook/assets/{answer-to-notebook-WAVAYjBv.js → answer-to-notebook-Dk42N0pU.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-left-L8odLbyN.js → arrow-left-DKuuTw9l.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-right-WIF1V9a9.js → arrow-right-TH8_ufKG.js} +1 -1
- package/dist/assets/dql-notebook/assets/{book-open-text-BpqWMa4m.js → book-open-text-B-dcHHn0.js} +1 -1
- package/dist/assets/dql-notebook/assets/{circle-x-CQBOM0b0.js → circle-x-BOc2KCZQ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{dagre.esm-DlZi7NR3.js → dagre.esm-CPT_vn5p.js} +1 -1
- package/dist/assets/dql-notebook/assets/{external-link-DYqdQIGp.js → external-link-DtOfpYc6.js} +1 -1
- package/dist/assets/dql-notebook/assets/{grip-vertical-HmUijbwN.js → grip-vertical-B8joDDH9.js} +1 -1
- package/dist/assets/dql-notebook/assets/index-B3shyZsg.css +1 -0
- package/dist/assets/dql-notebook/assets/index-DJRMz64S.js +635 -0
- package/dist/assets/dql-notebook/assets/link-2-DMZPHawg.js +6 -0
- package/dist/assets/dql-notebook/assets/{list-tree-DGKqCxmz.js → list-tree-Dw0qlxPK.js} +1 -1
- package/dist/assets/dql-notebook/assets/{minimize-2-C8dvqCxX.js → minimize-2-DUiSrPS3.js} +1 -1
- package/dist/assets/dql-notebook/assets/{panel-right-open-yuVkIo5n.js → panel-right-open-BrrFrRZQ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{bot-CLR1V6dO.js → play-Ced0HT9g.js} +7 -2
- package/dist/assets/dql-notebook/assets/{rotate-ccw-Di0kRnrM.js → rotate-ccw-D_9U9o7X.js} +1 -1
- package/dist/assets/dql-notebook/assets/{semantic-fields-BMQV0li8.js → semantic-fields-BlDOaonV.js} +1 -1
- package/dist/assets/dql-notebook/assets/{sliders-horizontal-alebptlJ.js → sliders-horizontal-BDt6KRGR.js} +1 -1
- package/dist/assets/dql-notebook/assets/{star-CgCQbnXc.js → star-CxUbF_BW.js} +1 -1
- package/dist/assets/dql-notebook/assets/{triangle-alert-SyuSZ4ht.js → triangle-alert-COWnsSdh.js} +1 -1
- package/dist/assets/dql-notebook/assets/upload-DSFC2kJX.js +6 -0
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-DYdx896E.js +32 -0
- package/dist/assets/dql-notebook/assets/{user-round-J4PQHxo9.js → user-round-Bfu7fosn.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wand-sparkles-c4WDXTCk.js → wand-sparkles-DSpG0c0j.js} +1 -1
- package/dist/assets/dql-notebook/assets/{workflow-NtRLaq7n.js → workflow-B1_pj9gq.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wrench-CS1f1Zv4.js → wrench-CvfM03KZ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{x-CbKEfe5m.js → x-B4coLiOl.js} +1 -1
- package/dist/assets/dql-notebook/index.html +2 -2
- package/dist/commands/app.d.ts.map +1 -1
- package/dist/commands/app.js +65 -133
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/model.js +21 -2
- package/dist/commands/model.js.map +1 -1
- package/dist/llm/providers/dql-agent-provider.d.ts +16 -0
- package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
- package/dist/llm/providers/dql-agent-provider.js +65 -2
- package/dist/llm/providers/dql-agent-provider.js.map +1 -1
- package/dist/local-runtime.d.ts +112 -19
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +2026 -694
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +10 -10
- package/dist/sql-result-filter.d.ts +9 -0
- package/dist/sql-result-filter.d.ts.map +1 -1
- package/dist/sql-result-filter.js +25 -0
- package/dist/sql-result-filter.js.map +1 -1
- package/package.json +10 -10
- package/dist/assets/dql-notebook/assets/AgentAnswerCard-c8QUo6NH.js +0 -5
- package/dist/assets/dql-notebook/assets/AnalyticsHome-DgwnRW71.js +0 -6
- package/dist/assets/dql-notebook/assets/AppsView-B6LYUpgm.js +0 -4578
- package/dist/assets/dql-notebook/assets/BlockStudio--jNw9XUI.js +0 -60
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-DhBsLCYr.js +0 -22
- package/dist/assets/dql-notebook/assets/GlobalAiRail-1Tgweuu2.js +0 -1
- package/dist/assets/dql-notebook/assets/GovernedContextPage-C7qGrH3d.js +0 -16
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-duFXXNV_.js +0 -88
- package/dist/assets/dql-notebook/assets/index-Cpx47jCH.js +0 -634
- package/dist/assets/dql-notebook/assets/index-DKu4CZt3.css +0 -1
- package/dist/assets/dql-notebook/assets/upload-BPhfea_E.js +0 -11
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-Bnl9gWhj.js +0 -28
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import{c as cn,r as a,j as e,P as Ce,aI as Zn,aJ as Uo,aK as fo,a as te,ap as wt,$ as Ko,L as Yo,u as Ut,t as Vo,aL as un,a4 as Fe,aC as Jo,a0 as Qo,aM as Go,aN as Zo,aO as Xo,V as es,aP as ts,aQ as yo,B as pn,S as hn,G as bo,N as jo,l as vo,aR as ns,aS as os,aT as ss}from"./index-Cpx47jCH.js";import{S as is,K as ls,C as rs}from"./GovernedContextPage-C7qGrH3d.js";import{u as as,i as ds,B as cs,C as us,b as ps,M as hs,T as Xn,N as xs,H as gt,c as ft,d as ms}from"./dagre.esm-DlZi7NR3.js";import{L as it,U as gs}from"./upload-BPhfea_E.js";import{M as So,F as xn,u as fs}from"./usePersistedAgentThreadId-Bnl9gWhj.js";import{U as ys}from"./UnifiedAgentRunPanel-duFXXNV_.js";import{X as bs}from"./x-CbKEfe5m.js";import{P as js}from"./panel-right-open-yuVkIo5n.js";import{G as mn}from"./user-round-J4PQHxo9.js";import{S as vs}from"./sliders-horizontal-alebptlJ.js";import{C as kt}from"./circle-x-CQBOM0b0.js";import{R as Ss}from"./rotate-ccw-Di0kRnrM.js";import"./react-CRB3T2We.js";import"./triangle-alert-SyuSZ4ht.js";import"./wrench-CS1f1Zv4.js";import"./AgentAnswerCard-c8QUo6NH.js";import"./TrustBadge-ZuD5N5Ww.js";import"./AiBuildResult-DPJ_SI0R.js";import"./list-tree-DGKqCxmz.js";import"./minimize-2-C8dvqCxX.js";import"./arrow-right-WIF1V9a9.js";/**
|
|
2
|
-
* @license lucide-react v0.563.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ws=[["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"}]],wo=cn("columns-3",ws);/**
|
|
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 ks=[["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"}]],Wt=cn("folder-tree",ks);/**
|
|
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 Cs=[["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"}]],Is=cn("panel-right-close",Cs);function Ms({modeling:t,relationByDbtId:n,detailsByDbtId:o,selectedDomain:s,selectedAreaId:i,selectedId:r,viewMode:c,columnMode:f,search:y,layoutMode:l,density:d,visibleLimit:g,dimUnrelated:m,showEdgeLabels:u,resetLayoutToken:x,focusRequest:C,onVisibleDbtIdsChange:j,onSelectEntity:w,onSelectRelationship:$,onEditRelationship:v,onDraftRelationship:k,onAddRelatedModel:O,onDropDbtModel:q,onCreateDomain:E,onEditEntity:S,onOpenAi:L,theme:b}){const M=`dql-model-layout:${i??s??"all"}`,oe=`${M}:sizes`,[le,de]=a.useState(()=>eo(M)),[I,R]=a.useState(()=>to(oe));a.useEffect(()=>de(eo(M)),[M]),a.useEffect(()=>R(to(oe)),[oe]),a.useEffect(()=>{x&&(localStorage.removeItem(M),localStorage.removeItem(oe),de({}),R({}))},[x]);const[A,T]=a.useState(null),[U,Z]=a.useState(null),K=(B,ne)=>{const _={...I,[B]:Math.round(ne)};R(_),localStorage.setItem(oe,JSON.stringify(_))},{nodes:re,edges:pe}=a.useMemo(()=>Rs(t,n,o,s,i,r,c,f,y,l,d,g,m,u,le,I,O,K,b),[t,n,o,s,i,r,c,f,y,l,d,g,m,u,le,I,O,b]),[Ae,ge,He]=as(re);a.useEffect(()=>ge(re),[re,ge]);const fe=re.map(B=>B.data.entity.dbtUniqueId),ze=fe.join("|");if(a.useEffect(()=>j(fe),[j,ze]),!re.length)return e.jsxs("div",{style:{display:"flex",flexDirection:"column",placeItems:"center",justifyContent:"center",alignItems:"center",gap:12,height:"100%",color:b.textMuted},children:[e.jsx("strong",{style:{color:b.textPrimary},children:y.trim()?`No models or columns match “${y.trim()}”.`:"Start your Domain Model"}),!y.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:E,style:oo(b),children:[e.jsx(Ce,{size:13})," Create domain"]}),e.jsxs("button",{onClick:()=>q(""),style:oo(b,!0),children:[e.jsx(it,{size:13})," Bind first model"]})]})]})]});const Se=B=>{!B.source||!B.target||k({from:B.source,to:B.target,fromColumn:no(B.sourceHandle),toColumn:no(B.targetHandle)})},we=U?t.relationships[U.recordKey]:void 0;return e.jsxs("div",{style:{height:"100%",position:"relative"},onClick:()=>{T(null),Z(null)},children:[e.jsx("style",{children:Os}),e.jsxs(ds,{nodes:Ae,edges:pe,onNodesChange:He,nodeTypes:{entity:Ds},fitView:!0,fitViewOptions:{padding:.16},minZoom:.2,maxZoom:1.8,nodesDraggable:!0,nodesConnectable:!0,onConnect:Se,onNodeDragStop:(B,ne)=>{const _={...le,[ne.id]:ne.position};de(_),localStorage.setItem(M,JSON.stringify(_))},onDragOver:B=>{B.dataTransfer.types.includes("application/x-dql-dbt-model")&&B.preventDefault()},onDrop:B=>{const ne=B.dataTransfer.getData("application/x-dql-dbt-model");ne&&(B.preventDefault(),q(ne))},onNodeClick:(B,ne)=>w(ne.id),onNodeDoubleClick:(B,ne)=>S(ne.id),onNodeContextMenu:(B,ne)=>{B.preventDefault(),T({x:B.clientX,y:B.clientY,nodeId:ne.id})},onEdgeClick:(B,ne)=>{B.stopPropagation(),$(ne.id),Z({x:Math.min(B.clientX,window.innerWidth-340),y:Math.min(B.clientY,window.innerHeight-320),recordKey:ne.id})},colorMode:b.appBg.toLowerCase().includes("0")?"dark":"light",proOptions:{hideAttribution:!0},children:[e.jsx(Bs,{focusRequest:C}),e.jsx(cs,{color:"var(--border-strong)",gap:22,size:1}),e.jsx(us,{showInteractive:!1}),e.jsx(ps,{pannable:!0,zoomable:!0,nodeColor:B=>ko(String(B.data.entity.domain)),maskColor:`${b.appBg}bb`})]},`${l}:${d}:${g}:${x}:${y}`),A&&e.jsxs("div",{style:{position:"fixed",left:A.x,top:A.y,zIndex:50,width:178,border:`1px solid ${b.headerBorder}`,borderRadius:7,background:b.cellBg,boxShadow:"0 12px 32px #0004",padding:4},onClick:B=>B.stopPropagation(),children:[e.jsx(qt,{label:"Inspect entity",onClick:()=>{w(A.nodeId),T(null)},theme:b}),e.jsx(qt,{label:"Edit Domain Model binding",onClick:()=>{S(A.nodeId),T(null)},theme:b}),e.jsx(qt,{label:"Ask AI about entity",onClick:()=>{L(A.nodeId),T(null)},theme:b}),e.jsx(qt,{label:"Start relationship",onClick:()=>{k({from:A.nodeId,to:""}),T(null)},theme:b})]}),U&&we&&e.jsx(zs,{relationship:we,entities:t.entities,x:U.x,y:U.y,theme:b,onClose:()=>Z(null),onEdit:v?()=>{v(U.recordKey),Z(null)}:void 0,onViewProof:()=>{$(U.recordKey),Z(null)}})]})}function zs({relationship:t,entities:n,x:o,y:s,theme:i,onClose:r,onEdit:c,onViewProof:f}){var m,u;const y=((m=t.validation)==null?void 0:m.status)==="passed",l=t.keys.map(x=>`${x.from} = ${x.to}`).join(" and ")||"No join keys declared",d=x=>{const C=n[x]??Object.values(n).find(j=>j.id===x||j.localId===x);return(C==null?void 0:C.businessName)||(C==null?void 0:C.localId)||x.split("::").pop()||x},g=x=>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:x});return e.jsxs("div",{onClick:x=>x.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(it,{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 ${y?"var(--status-success-border)":"var(--status-warning-border)"}`,color:y?"var(--status-success)":"var(--status-warning)",background:y?"var(--status-success-bg)":"var(--status-warning-bg)",borderRadius:999,padding:"2px 8px",fontSize:9.5,fontWeight:700},children:y?"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(d(t.from)),e.jsx("span",{style:{color:i.textMuted,fontSize:10.5,fontWeight:650,whiteSpace:"nowrap"},children:t.cardinality.replace(/_/g," ")}),g(d(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:l})]}),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:y?"var(--status-success)":"var(--status-warning)"},children:y?`Join proof passed — ${((u=t.validation)==null?void 0:u.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:f,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 Ds({data:t}){var q,E;const{recordKey:n,entity:o,detail:s,relation:i,selected:r,viewMode:c,columnMode:f,density:y,theme:l,onAddRelatedModel:d,onResize:g}=t,[m,u]=a.useState(y==="compact"),x=ko(o.domain),C=fo(o.analyticalRole),j=o.analyticalRole&&o.analyticalRole!=="unknown"?o.analyticalRole:"entity",w=(s==null?void 0:s.columns)??[],$=new Set(o.keys.length?o.keys:((q=s==null?void 0:s.dqlMeta)==null?void 0:q.keys)??[]),v=new Set(w.filter(S=>!$.has(S.name)&&/(^|_)id$/.test(S.name)).map(S=>S.name)),k=m||c==="business"?[]:f==="all"?w.slice(0,16):f==="keys"?w.filter(S=>$.has(S.name)).slice(0,10):w.filter(S=>$.has(S.name)||S.tests.length>0).slice(0,10),O=(E=o.conceptRefs)!=null&&E.length?o.conceptRefs.join(", "):rn(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:l.cellBg,color:l.textPrimary},children:[e.jsx(xs,{position:"bottom-right",resizeDirection:"horizontal",minWidth:240,maxWidth:620,onResizeEnd:(S,L)=>g(n,L.width),style:{width:16,height:16,border:0,background:"transparent",color:l.textMuted},children:e.jsx("span",{title:"Drag to resize model",style:{display:"grid",placeItems:"center"},children:e.jsx(So,{size:12})})}),m&&c==="data"&&e.jsx(gt,{className:"dql-modeling-handle",id:"entity-target",type:"target",position:ft.Left,style:yt(x)}),e.jsx("button",{className:"nodrag",title:"Add a related model",onClick:S=>{S.stopPropagation(),d({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 ${l.cellBg}`,background:"var(--accent)",color:"#fff",cursor:"pointer",boxShadow:"0 1px 4px rgba(107,93,211,0.3)"},children:e.jsx(Ce,{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:C,flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:700,color:l.textPrimary,fontFamily:l.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c==="business"?o.businessName||rn(o.localId??o.id):o.localId??o.id}),e.jsx("span",{style:{flexShrink:0,fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",color:C},children:j}),c==="data"&&e.jsx("button",{className:"nodrag",title:m?"Expand columns":"Collapse columns",onClick:S=>{S.stopPropagation(),u(L=>!L)},style:{border:0,background:"transparent",color:l.textMuted,cursor:"pointer",padding:0,flexShrink:0},children:m?"▾":"▴"})]}),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:l.textSecondary,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},children:o.businessContext||O}),e.jsxs("div",{style:{display:"flex",gap:6,padding:"0 12px 10px",flexWrap:"wrap"},children:[o.owner?e.jsx("span",{style:{fontSize:10,color:l.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:l.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,k.length>0&&e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",maxHeight:242,overflow:"auto"},children:[k.map(S=>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(gt,{className:"dql-modeling-handle",id:`target:${S.name}`,type:"target",position:ft.Left,style:{...yt(x),top:"50%"}}),e.jsx("span",{style:{flexShrink:0,width:17,fontSize:8.5,fontWeight:700,fontFamily:l.fontMono,color:$.has(S.name)?"var(--pk)":v.has(S.name)?"var(--fk)":"transparent"},children:$.has(S.name)?"PK":v.has(S.name)?"FK":"·"}),e.jsx("span",{style:{flex:1,minWidth:0,color:l.textSecondary,fontFamily:l.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:$.has(S.name)?700:500},children:S.name}),e.jsx("span",{style:{flexShrink:0,fontSize:9.5,color:l.textMuted,fontFamily:l.fontMono},children:S.type??""}),e.jsx(gt,{className:"dql-modeling-handle",id:`source:${S.name}`,type:"source",position:ft.Right,style:{...yt(x),top:"50%"}})]},S.name)),w.length>k.length&&e.jsxs("div",{style:{padding:"6px 12px",color:l.textMuted,fontSize:9},children:["+ ",w.length-k.length," more dbt-owned columns"]})]}),(m||c==="business")&&e.jsxs(e.Fragment,{children:[e.jsx(gt,{className:"dql-modeling-handle",id:"entity-target",type:"target",position:ft.Left,style:yt(x)}),e.jsx(gt,{className:"dql-modeling-handle",id:"entity-source",type:"source",position:ft.Right,style:yt(x)})]})]})}function Rs(t,n,o,s,i,r,c,f,y,l,d,g,m,u,x,C,j,w,$){const v=i?t.areas[i]:void 0,k=new Set(v?[...v.entityIds,...v.referencedEntityIds]:[]),O=Object.entries(t.relationships).flatMap(([I,R])=>{const A=Zn(t,R.from),T=Zn(t,R.to);return A&&T?[{recordKey:I,relationship:R,from:A,to:T}]:[]}).filter(({recordKey:I,from:R,to:A})=>{var T,U;return v?v.relationshipIds.includes(I):s?((T=t.entities[R])==null?void 0:T.domain)===s||((U=t.entities[A])==null?void 0:U.domain)===s:!0}),q=new Set(O.flatMap(({from:I,to:R})=>[I,R])),E=y.trim().toLowerCase();let S=Uo(t).filter(({recordKey:I,entity:R})=>{if(v&&!k.has(I)&&!q.has(I)||s&&R.domain!==s&&!q.has(I))return!1;if(!E)return!0;const A=o[R.dbtUniqueId];return[I,R.id,R.qualifiedId,R.domain,A==null?void 0:A.relation,...(A==null?void 0:A.columns.map(T=>T.name))??[]].some(T=>String(T??"").toLowerCase().includes(E))});const L=Math.min(200,g>0?g:50);if(S.length>L){const I=new Map;for(const R of O)I.set(R.from,(I.get(R.from)??0)+1),I.set(R.to,(I.get(R.to)??0)+1);S=[...S].sort((R,A)=>R.recordKey===r?-1:A.recordKey===r?1:(I.get(A.recordKey)??0)-(I.get(R.recordKey)??0)||R.recordKey.localeCompare(A.recordKey)).slice(0,L)}const b=[...new Set(S.map(({entity:I})=>I.domain))].sort(),M=[];b.forEach((I,R)=>S.filter(({entity:A})=>A.domain===I).sort((A,T)=>A.recordKey.localeCompare(T.recordKey)).forEach(({recordKey:A,entity:T},U)=>{const Z=o[T.dbtUniqueId],K=c==="business"?0:Ps(T,Z,f),re=C[A]??As(T,Z,n[T.dbtUniqueId],d);M.push({id:A,type:"entity",position:{x:R*390,y:U*190},data:{recordKey:A,entity:T,detail:Z,relation:n[T.dbtUniqueId],selected:r===A,viewMode:c,columnMode:f,density:d,theme:$,onAddRelatedModel:j,onResize:w},style:{width:re,height:116+K*29}})}));const oe=new Set(M.map(I=>I.id)),le=O.filter(({from:I,to:R})=>oe.has(I)&&oe.has(R)).map(({recordKey:I,relationship:R,from:A,to:T})=>{var ze,Se;const U=((ze=R.validation)==null?void 0:ze.status)==="passed";R.automaticJoinAllowed||R.staleCertification;const Z=R.keys.map(we=>`${we.from} → ${we.to}`).join(", "),K=R.keys[0],re=t.entities[A],pe=t.entities[T],Ae=re?sn(re,o[re.dbtUniqueId],f):new Set,ge=pe?sn(pe,o[pe.dbtUniqueId],f):new Set,fe=((Se=R.verb)==null?void 0:Se.trim())||Z;return{id:I,source:A,target:T,sourceHandle:c==="data"&&K&&Ae.has(K.from)?`source:${K.from}`:void 0,targetHandle:c==="data"&&K&&ge.has(K.to)?`target:${K.to}`:void 0,type:"default",label:u?`${fe} · ${$s(R.cardinality)}`:void 0,animated:R.status==="review"||R.status==="reviewed",markerEnd:{type:hs.ArrowClosed,color:r===I?"var(--accent)":"var(--border-strong)"},style:{stroke:r===I?"var(--accent)":"var(--border-strong)",strokeWidth:r===I?2:1.5,cursor:"pointer"},labelStyle:{fill:r===I?"var(--accent)":$.textSecondary,fontSize:10.5,fontWeight:650,cursor:"pointer"},labelBgStyle:{fill:$.cellBg,fillOpacity:1,stroke:r===I?"var(--accent)":$.headerBorder,strokeWidth:1},labelBgPadding:[9,4],labelBgBorderRadius:999}}),de=new Xn.graphlib.Graph().setDefaultEdgeLabel(()=>({}));if(de.setGraph({rankdir:"LR",ranksep:d==="compact"?90:d==="wide"?190:135,nodesep:d==="compact"?35:d==="wide"?90:60,marginx:35,marginy:35}),M.forEach(I=>{var R,A;return de.setNode(I.id,{width:Number(((R=I.style)==null?void 0:R.width)??ln(d)),height:Number(((A=I.style)==null?void 0:A.height)??100)})}),le.forEach(I=>de.setEdge(I.source,I.target)),l==="auto"&&Xn.layout(de),M.forEach(I=>{var T,U;const R=x[I.id];if(R){I.position=R;return}if(l==="grid"){const Z=M.indexOf(I),K=Math.max(1,Math.ceil(Math.sqrt(M.length)));I.position={x:Z%K*360,y:Math.floor(Z/K)*260};return}if(l==="star"){const Z=M.indexOf(I);if(Z===0){I.position={x:0,y:0};return}const K=(Z-1)/Math.max(1,M.length-1)*Math.PI*2;I.position={x:Math.cos(K)*460,y:Math.sin(K)*330};return}const A=de.node(I.id);A&&(I.position={x:A.x-Number(((T=I.style)==null?void 0:T.width)??ln(d))/2,y:A.y-Number(((U=I.style)==null?void 0:U.height)??100)/2})}),m&&r&&t.entities[r]){const I=new Set([r]);for(const R of O)R.from===r&&I.add(R.to),R.to===r&&I.add(R.from);for(const R of M)R.style={...R.style,opacity:I.has(R.id)?1:.18,transition:"opacity 160ms ease"}}return{nodes:M,edges:le}}function $s(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 Bs({focusRequest:t}){const n=ms(),o=a.useRef(-1);return a.useEffect(()=>{if(!t||t.token===o.current)return;o.current=t.token;const s=window.setTimeout(()=>{var f,y,l,d;const i=n.getNode(t.id);if(!i)return;const r=Number(((f=i.measured)==null?void 0:f.width)??i.width??((y=i.style)==null?void 0:y.width)??280),c=Number(((l=i.measured)==null?void 0:l.height)??i.height??((d=i.style)==null?void 0:d.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 qt({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 sn(t,n,o).size}function sn(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 ln(t){return t==="compact"?250:t==="wide"?340:280}function As(t,n,o,s){var r;const i=Math.max(rn(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,ln(s)+Math.max(0,i-34)*2)}function eo(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 to(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 no(t){return t!=null&&t.includes(":")?t.slice(t.indexOf(":")+1):void 0}function yt(t){return{background:t,border:"2px solid var(--color-bg-card)",width:9,height:9,cursor:"crosshair"}}const Os=`
|
|
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 oo(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 rn(t){return t.replace(/[._-]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function ko(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 Ns({data:t,domain:n,areaId:o,theme:s,onClose:i,onProposal:r}){const[c,f]=a.useState(""),[y,l]=a.useState([]),[d,g]=a.useState({}),[m,u]=a.useState([]),[x,C]=a.useState(1),[j,w]=a.useState(!1),[$,v]=a.useState(null),k=t.modeling.areas[o??""];a.useEffect(()=>{let S=!0;const L=window.setTimeout(()=>{te.getDbtModelInventory({q:c,limit:100,physicalOnly:!0}).then(b=>{if(!S)return;const M=b.items.filter(oe=>!oe.binding);l(M),g(oe=>({...oe,...Object.fromEntries(M.map(le=>[le.uniqueId,le]))}))}).catch(b=>{S&&v(b instanceof Error?b.message:String(b))})},180);return()=>{S=!1,window.clearTimeout(L)}},[c]);const O=m.flatMap(S=>d[S]?[d[S]]:[]),q=a.useMemo(()=>qs(t,n,k,O),[k,t,n,O]),E=async()=>{var S;w(!0),v(null);try{const L=await te.createContextProposal({origin:"dbt_discovery",expectedSnapshotId:(S=t.snapshot)==null?void 0:S.id,operations:q});r(L)}catch(L){v(L instanceof Error?L.message:String(L))}finally{w(!1)}};return e.jsxs(Co,{title:"Add models",subtitle:`Step ${x} of 3 · ${x===1?"Select dbt models":x===2?"Assign ownership":"Review proposal inputs"}`,theme:s,busy:j,onClose:i,children:[x===1?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(wt,{size:14,style:{position:"absolute",left:10,top:10,color:s.textMuted}}),e.jsx("input",{autoFocus:!0,"aria-label":"Search dbt models",value:c,onChange:S=>f(S.target.value),placeholder:"Search model name, package, or relation",style:{...dn(s),width:"100%",paddingLeft:32}})]}),e.jsxs("div",{style:{display:"grid",gap:6,marginTop:12},children:[y.map(S=>e.jsxs("label",{style:vt(s),children:[e.jsx("input",{type:"checkbox",checked:m.includes(S.uniqueId),onChange:L=>u(b=>L.target.checked?[...b,S.uniqueId]:b.filter(M=>M!==S.uniqueId))}),e.jsxs("span",{style:{flex:1},children:[e.jsx("b",{style:{display:"block",fontSize:11.5},children:S.name}),e.jsx("code",{style:{color:s.textMuted,fontSize:9.5},children:S.uniqueId})]}),e.jsx("small",{style:{color:s.textMuted},children:S.packageName})]},S.uniqueId)),y.length?null:e.jsx(jt,{theme:s,children:"No unbound dbt models match this search."})]})]}):x===2?e.jsxs(e.Fragment,{children:[e.jsx(so,{label:"Domain",value:n??"Select a Domain in Modeling first",theme:s}),e.jsx(so,{label:"Area",value:(k==null?void 0:k.name)??"Select one Area in Modeling first",theme:s}),e.jsx(jt,{theme:s,children:"Every model receives exactly one Domain and Area. DQL stores the dbt unique ID and business overlay; dbt-owned columns, SQL, tests, descriptions, and lineage remain in dbt."})]}):e.jsxs(e.Fragment,{children:[e.jsxs(jt,{theme:s,children:[q.length," sparse entity-binding patch",q.length===1?"":"es"," will be prepared. No source changes occur until the exact proposal is reviewed and explicitly saved."]}),O.map(S=>e.jsxs("div",{style:vt(s),children:[e.jsxs("span",{style:{flex:1},children:[e.jsx("b",{style:{display:"block",fontSize:11},children:S.name}),e.jsx("code",{style:{fontSize:9.5,color:s.textMuted},children:S.uniqueId})]}),e.jsxs("span",{style:{fontSize:10,color:s.textMuted},children:[n," / ",k==null?void 0:k.name]})]},S.uniqueId))]}),$?e.jsx("div",{role:"alert",style:{color:"var(--status-error)",fontSize:11,marginTop:10},children:$}):null,e.jsx(an,{theme:s,busy:j,back:x>1?()=>C(x-1):void 0,next:x<3?()=>C(x+1):()=>void E(),nextLabel:x<3?"Continue":"Create review proposal",disabled:m.length===0||!n||!k})]})}function Ls({data:t,domain:n,areaId:o,theme:s,onClose:i,onProposal:r}){const[c,f]=a.useState("current_project"),[y,l]=a.useState(""),[d,g]=a.useState(""),[m,u]=a.useState("modeling.yml"),[x,C]=a.useState(null),[j,w]=a.useState([]),[$,v]=a.useState(!1),[k,O]=a.useState(null),q=t.modeling.areas[o??""],E=async()=>{v(!0),O(null);try{const b=await te.createModelingImport({mode:c,...c==="path"?{path:y}:{},...c==="paste"||c==="upload"?{content:d,filename:m}:{}});C(b),w(b.candidates.filter(M=>M.action==="import").map(M=>M.id))}catch(b){O(b instanceof Error?b.message:String(b))}finally{v(!1)}},S=async()=>{var b;if(!(!x||!n||!q)){v(!0),O(null);try{const M=await te.previewModelingImport(x.id,{selectedCandidateIds:j,domain:n,areaId:q.localId||q.id,expectedSnapshotId:((b=t.snapshot)==null?void 0:b.id)??""});r(M.proposal)}catch(M){O(M instanceof Error?M.message:String(M))}finally{v(!1)}}},L=b=>{if(!b)return;u(b.name);const M=new FileReader;M.onload=()=>g(String(M.result??"")),M.onerror=()=>O("Could not read the selected YAML file."),M.readAsText(b)};return e.jsxs(Co,{title:"Import modeling YAML",subtitle:x?"Classify, select, and review":"Choose a safe import source",theme:s,busy:$,onClose:i,children:[x?e.jsxs(e.Fragment,{children:[e.jsxs(jt,{theme:s,children:[e.jsx(xn,{size:13,style:{verticalAlign:-2,marginRight:5}}),"DQL modeling becomes a reviewed copy; dbt YAML becomes a sparse overlay. Generic YAML is not imported."]}),e.jsx("div",{style:{display:"grid",gap:7},children:x.candidates.map(b=>e.jsxs("label",{style:{...vt(s),opacity:b.action==="import"?1:.72},children:[e.jsx("input",{type:"checkbox",disabled:b.action!=="import",checked:j.includes(b.id),onChange:M=>w(oe=>M.target.checked?[...oe,b.id]:oe.filter(le=>le!==b.id))}),e.jsxs("span",{style:{flex:1},children:[e.jsx("b",{style:{display:"block",fontSize:11},children:b.name}),e.jsxs("span",{style:{display:"block",marginTop:2,color:s.textMuted,fontSize:9.5},children:[b.dialect.replace(/_/g," ")," · ",b.summary]}),b.warnings.map(M=>e.jsx("small",{style:{display:"block",color:"var(--status-warning)",marginTop:3},children:M},M))]}),e.jsx("span",{style:{fontSize:9.5,color:s.textMuted},children:b.action.replace(/_/g," ")})]},b.id))}),!n||!q?e.jsx("div",{role:"alert",style:{color:"var(--status-warning)",fontSize:11,marginTop:10},children:"Select exactly one Domain and Area in Modeling before previewing the import."}):null,e.jsx(an,{theme:s,busy:$,back:()=>{C(null),w([])},next:()=>void S(),nextLabel:"Review exact patches",disabled:!j.length||!n||!q})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:6},children:["current_project","path","upload","paste"].map(b=>e.jsx("button",{type:"button",onClick:()=>f(b),style:{...Kt(s),...c===b?{borderColor:s.accent,color:s.accent,background:"var(--accent-dim)"}:{}},children:b==="current_project"?"Project":b[0].toUpperCase()+b.slice(1)},b))}),c==="current_project"?e.jsxs(jt,{theme:s,children:[e.jsx(Ko,{size:13,style:{verticalAlign:-2,marginRight:5}}),"Search the current project for DQL and dbt YAML. Existing DQL source opens in place and is not copied."]}):null,c==="path"?e.jsxs("label",{style:io(s),children:["Local file or directory",e.jsx("input",{"aria-label":"Local YAML path",value:y,onChange:b=>l(b.target.value),placeholder:"models or domains/sales",style:dn(s)}),e.jsx("small",{children:"Loopback-only and confined to the current approved project root."})]}):null,c==="upload"?e.jsxs("label",{style:{...vt(s),marginTop:12},children:[e.jsx(gs,{size:15}),e.jsx("span",{style:{flex:1},children:"Choose a YAML file"}),e.jsx("input",{type:"file",accept:".yml,.yaml,text/yaml",onChange:b=>{var M;return L((M=b.target.files)==null?void 0:M[0])}})]}):null,c==="paste"?e.jsxs("label",{style:io(s),children:["Paste DQL or dbt YAML",e.jsx("textarea",{"aria-label":"Paste modeling YAML",value:d,onChange:b=>g(b.target.value),rows:14,style:{...dn(s),resize:"vertical",fontFamily:s.fontMono}})]}):null,e.jsx(an,{theme:s,busy:$,next:()=>void E(),nextLabel:"Discover YAML",disabled:c==="path"&&!y.trim()||(c==="paste"||c==="upload")&&!d.trim()})]}),k?e.jsx("div",{role:"alert",style:{color:"var(--status-error)",fontSize:11,marginTop:10},children:k}):null]})}function qs(t,n,o,s){if(!n||!o)return[];const i=new Set(Object.values(t.modeling.entities).filter(r=>r.domain===n).map(r=>r.localId||r.id));return[...s].sort((r,c)=>r.uniqueId.localeCompare(c.uniqueId)).map(r=>{const c=Ts(r.name)||"model";let f=c;i.has(f)&&(f=`${c}-${r.identityFingerprint.slice(0,6).toLowerCase()}`);let y=2;for(;i.has(f);)f=`${c}-${y++}`;return i.add(f),{id:`bind:${r.uniqueId}`,kind:"modeling_change",change:{operation:"upsert_entity",value:{id:f,domain:n,areaId:o.localId||o.id,dbtModel:r.uniqueId,businessName:Es(r.name),status:"draft"}},evidence:[`dbt unique id ${r.uniqueId}`,`manifest fingerprint ${r.identityFingerprint}`]}})}function Ts(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,64)}function Es(t){return t.replace(/[_-]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function Co({title:t,subtitle:n,theme:o,busy:s,onClose:i,children:r}){return e.jsx("div",{onClick:()=>!s&&i(),style:{position:"fixed",inset:0,zIndex:120,background:"rgba(8,10,16,.46)",display:"flex",justifyContent:"flex-end"},children:e.jsxs("aside",{role:"dialog","aria-modal":"true","aria-label":t,onClick:c=>c.stopPropagation(),style:{width:"min(600px, 96vw)",height:"100%",background:o.appBg,borderLeft:"1px solid var(--border-default)",boxShadow:"-16px 0 45px rgba(0,0,0,.22)",display:"flex",flexDirection:"column"},children:[e.jsxs("header",{style:{minHeight:58,padding:"0 18px",borderBottom:"1px solid var(--border-subtle)",display:"flex",alignItems:"center",gap:9},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("b",{style:{display:"block",fontSize:14},children:t}),e.jsx("small",{style:{color:o.textMuted},children:n})]}),e.jsx("button",{"aria-label":"Close",disabled:s,onClick:i,style:{...Kt(o),width:30,padding:0},children:e.jsx(bs,{size:14})})]}),e.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:18},children:r})]})})}function an({theme:t,busy:n,back:o,next:s,nextLabel:i,disabled:r=!1}){return e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},children:[o?e.jsx("button",{type:"button",onClick:o,disabled:n,style:Kt(t),children:"Back"}):null,e.jsxs("button",{type:"button",onClick:s,disabled:n||r,style:{..._s(t),opacity:n||r?.55:1},children:[n?e.jsx(Yo,{size:13}):null,i]})]})}function jt({theme:t,children:n}){return e.jsx("div",{style:{margin:"12px 0",padding:"10px 11px",border:"1px solid var(--border-subtle)",borderRadius:8,background:"var(--bg-1)",color:t.textSecondary,fontSize:10.5,lineHeight:1.5},children:n})}function so({label:t,value:n,theme:o}){return e.jsxs("div",{style:{...vt(o),marginBottom:8},children:[e.jsx("b",{style:{width:72,fontSize:11},children:t}),e.jsx("span",{style:{color:o.textSecondary,fontSize:11},children:n})]})}const dn=t=>({boxSizing:"border-box",border:"1px solid var(--border-default)",background:t.inputBg,color:t.textPrimary,borderRadius:7,padding:"8px 9px",outline:"none"}),io=t=>({display:"grid",gap:6,marginTop:12,color:t.textSecondary,fontSize:11}),vt=t=>({display:"flex",gap:9,alignItems:"center",border:"1px solid var(--border-subtle)",borderRadius:8,background:t.cellBg,padding:"9px 10px"}),Kt=t=>({minHeight:31,border:"1px solid var(--border-default)",borderRadius:7,background:t.cellBg,color:t.textPrimary,padding:"0 11px",cursor:"pointer",display:"inline-flex",gap:6,alignItems:"center",justifyContent:"center"}),_s=t=>({...Kt(t),background:t.accent,borderColor:t.accent,color:"var(--accent-fg)",fontWeight:650});function Fs(t){return t instanceof Error?t:void 0}function Ws(t){return t.details&&typeof t.details=="object"&&!Array.isArray(t.details)?t.details:void 0}function lo(t){const n=Fs(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=Ws(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 bt(t){return t.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function Hs(t,n,o=50){const s=bt(n),i=s.split(/\s+/).filter(Boolean);return t.map(r=>{var m;const c=bt(r.label),f=bt(r.value),y=bt(r.description??""),l=bt(((m=r.keywords)==null?void 0:m.join(" "))??""),d=`${c} ${f} ${y} ${l}`;if(i.length&&!i.every(u=>d.includes(u)))return null;let g=0;return s&&((c===s||f===s)&&(g+=1e3),c.startsWith(s)&&(g+=500),f.startsWith(s)&&(g+=350),c.includes(s)&&(g+=200),g+=i.reduce((u,x)=>u+(c.startsWith(x)?80:c.includes(x)?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 Fi(){var ht,qe;const{state:t,dispatch:n}=Ut(),o=Vo[t.themeMode],[s,i]=a.useState(null),[r,c]=a.useState(!0),[f,y]=a.useState(null),l=a.useMemo(()=>ro(),[]),[d,g]=a.useState(l.section),[m,u]=a.useState(l.domain),[x,C]=a.useState(l.modelAreaId),[j,w]=a.useState(l.selectedId),[$,v]=a.useState(null),[k,O]=a.useState({}),q=a.useRef(new Map),E=a.useRef(new Set),S=a.useMemo(()=>fi(),[]),[L,b]=a.useState(S.viewMode??"business"),[M,oe]=a.useState(S.columnMode??"relevant"),[le,de]=a.useState(""),[I,R]=a.useState(0),[A,T]=a.useState(null),[U,Z]=a.useState(S.layoutMode??"auto"),[K,re]=a.useState(S.density??"normal"),[pe,Ae]=a.useState(S.visibleLimit??50),[ge,He]=a.useState(S.dimUnrelated??!0),[fe,ze]=a.useState(S.showEdgeLabels??!0),[Se,we]=a.useState(!1),[B,ne]=a.useState(!1),[_,Yt]=a.useState(!1),[Ue,Ke]=a.useState(()=>typeof window<"u"&&window.innerWidth<980),Ye=a.useRef(null),Ct=a.useRef(null),[je,Y]=a.useState(null),[he,ye]=a.useState(null),[at,ke]=a.useState(null),[It,Mt]=a.useState(null),[Ve,dt]=a.useState(null),[ve,Je]=a.useState(null),[zt,Dt]=a.useState(!1),[Rt,Oe]=a.useState(null);a.useEffect(()=>{localStorage.setItem("dql-modeling-preferences",JSON.stringify({modelingView:L,columnMode:M,layoutMode:U,density:K,visibleLimit:pe,dimUnrelated:ge,showEdgeLabels:fe}))},[L,M,U,K,pe,ge,fe]),a.useEffect(()=>{const h=()=>Ke(window.innerWidth<980);return window.addEventListener("resize",h),()=>window.removeEventListener("resize",h)},[]);const ct=a.useCallback(()=>{Yt(h=>{const D=!h;return D?window.requestAnimationFrame(()=>{var X;return(X=Ct.current)==null?void 0:X.focus()}):window.requestAnimationFrame(()=>{var X;return(X=Ye.current)==null?void 0:X.focus()}),D})},[]),Qe=a.useCallback(h=>{g(h),Tt(m,h,!1,x,j)},[x,m,j]),ut=a.useCallback(h=>{u(h),C(null),w(null),Tt(h,d,!1,null,null)},[d]);a.useEffect(()=>{const h=()=>{const D=ro();u(D.domain),C(D.modelAreaId),w(D.selectedId),g(D.section)};return window.addEventListener("popstate",h),()=>window.removeEventListener("popstate",h)},[]),a.useEffect(()=>{Tt(m,d,!0,x,j)},[x,m,j,d]);const De=async()=>{c(!0);try{const h=await te.getDbtFirstModeling();i(h),y(null);const D=m&&h.modeling.packages[m]?m:null;D!==m&&(u(D),Tt(D,d,!0))}catch(h){i(null),y(lo(h))}finally{c(!1)}};a.useEffect(()=>{De()},[]),a.useEffect(()=>{let h=null;try{h=window.sessionStorage.getItem("dql-context-proposal-handoff"),h&&window.sessionStorage.removeItem("dql-context-proposal-handoff")}catch{}h&&te.getContextProposal(h).then(D=>{ke(D),g(D.impact.skillChanges>0&&D.impact.modelingChanges===0?"skills":"ai")}).catch(()=>{})},[]);const J=s==null?void 0:s.modeling.entities[j??""],be=s==null?void 0:s.modeling.relationships[j??""],Ge=a.useMemo(()=>s?Object.values(s.modeling.areas).filter(h=>!m||h.domain===m).sort((h,D)=>h.name.localeCompare(D.name)):[],[s,m]),Q=s==null?void 0:s.modeling.areas[x??""];a.useEffect(()=>{s&&x&&!Ge.some(h=>h.qualifiedId===x)&&C(null)},[s,Ge,x]);const Ne=a.useCallback(h=>{const D=q.current.get(h);if(D)return D;if(E.current.has(h))return Promise.resolve(void 0);const X=te.getDbtModelingNode(h).then(Re=>(E.current.add(h),O(tt=>({...tt,[h]:Re})),Re)).catch(()=>{E.current.add(h)}).finally(()=>q.current.delete(h));return q.current.set(h,X),X},[]);a.useEffect(()=>{if(!J){v(null);return}const h=k[J.dbtUniqueId];if(h){v(h);return}let D=!1;return Ne(J.dbtUniqueId).then(X=>{D||v(X??null)}),()=>{D=!0}},[k,Ne,J==null?void 0:J.dbtUniqueId]),a.useEffect(()=>{q.current.clear(),E.current.clear(),O({})},[s==null?void 0:s.dbtProvenance.manifestFingerprint]);const Vt=a.useCallback(h=>{for(const D of h.slice(0,24))Ne(D)},[Ne]);if(r&&!s)return e.jsx(po,{t:o,title:"Loading Domain Studio…",detail:"Compiling dbt provenance and the sparse DQL analytical overlay."});if(!s){const h=f??lo(null);return e.jsx(po,{t:o,title:h.title,detail:h.detail,status:h.status})}const $t=Object.fromEntries(Object.values(s.dbtProvenance.nodes).map(h=>[h.uniqueId,h.relation])),Jt=Object.entries(s.modeling.entities).flatMap(([h,D])=>{var tt;const X=D.businessName||D.localId||D.id,Re=[{recordKey:h,type:"model",label:X,sublabel:D.domain,role:D.analyticalRole}];for(const At of((tt=k[D.dbtUniqueId])==null?void 0:tt.columns)??[])Re.push({recordKey:h,type:"column",label:At.name,sublabel:X,role:D.analyticalRole});return Re}),Bt=h=>{w(h),de(""),T(D=>({id:h,token:((D==null?void 0:D.token)??0)+1}))},Pt=Q?new Set([...Q.entityIds,...Q.referencedEntityIds]):void 0,Le=un(s.modeling,m).filter(({recordKey:h})=>!Pt||Pt.has(h)),Ze=Object.values(s.modeling.relationships).filter(h=>{const D=s.modeling.entities[h.from],X=s.modeling.entities[h.to];return Q?Q.relationshipIds.includes(h.qualifiedId):!m||(D==null?void 0:D.domain)===m||(X==null?void 0:X.domain)===m}),Xe=Object.values(s.dbtProvenance.nodes).filter(h=>!Object.values(s.modeling.entities).some(D=>D.dbtUniqueId===h.uniqueId)),pt=_&&d==="diagram",et=[...new Set(m?((qe=(ht=s.domainAssets)==null?void 0:ht[m])==null?void 0:qe.skills)??[]:Object.values(s.domainAssets??{}).flatMap(h=>h.skills??[]))].sort();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:"Modeling workspace"}),e.jsx("span",{style:{color:o.textMuted,fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m?`/${m}`:"/all domains"})]}),e.jsxs("div",{style:{display:"flex",gap:7},children:[m&&e.jsxs(G,{t:o,onClick:()=>{try{window.sessionStorage.setItem("dql-ask-domain-context",JSON.stringify({domain:m,modelAreaId:Q==null?void 0:Q.qualifiedId}))}catch{}n({type:"SET_MAIN_VIEW",view:"ask"})},children:[e.jsx(Jo,{size:14})," Ask"]}),e.jsxs(G,{t:o,onClick:()=>ye("yaml"),children:[e.jsx(xn,{size:14})," Import YAML"]}),e.jsx(hi,{t:o,title:"Recompile",onClick:()=>void De(),children:e.jsx(Qo,{size:15})})]})]})}),e.jsxs("div",{style:{flex:1,minHeight:0,display:"grid",gridTemplateColumns:pt&&!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(Ks,{data:s,selectedDomain:m,onSelect:ut,t:o}),e.jsx(Ys,{data:s,domain:m,active:d,onSelect:Qe,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:[Io(d,14,o),e.jsx("strong",{style:{fontSize:11},children:Vs(d)}),e.jsx("span",{style:{width:1,height:15,background:o.headerBorder}}),e.jsx("span",{style:{color:o.textMuted,fontSize:10},children:m??"All domains"}),(d==="diagram"||d==="ai"||d==="skills")&&m&&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:x??"",onChange:h=>{C(h.target.value||null),w(null)},style:{...me(o),minWidth:146,padding:"4px 6px"},children:[e.jsx("option",{value:"",children:"All domain"}),Ge.map(h=>e.jsx("option",{value:h.qualifiedId,children:h.name},h.qualifiedId))]})]}),e.jsx("button",{"aria-label":"Add model area",title:"Add model area",onClick:()=>Y({kind:"area"}),style:{...We(o),width:27,height:27},children:e.jsx(Ce,{size:13})})]}),d==="diagram"&&e.jsx("button",{ref:Ye,"aria-expanded":_,"aria-controls":"domain-studio-inspector","aria-label":_?"Hide inspector":"Show inspector",title:_?"Hide inspector":"Show inspector",onClick:ct,style:{...We(o),marginLeft:"auto"},children:_?e.jsx(Is,{size:14}):e.jsx(js,{size:14})})]}),e.jsxs("div",{style:{flex:1,minHeight:0},children:[d==="overview"&&e.jsx(Qs,{data:s,domain:m,t:o,onOpen:Qe}),d==="diagram"&&e.jsxs("div",{id:"dql-modeling-diagram",style:{height:"100%",display:"flex",flexDirection:"column",...B?{position:"fixed",inset:0,zIndex:90,background:o.appBg}:{}},children:[e.jsx(Zs,{modelingView:L,columnMode:M,search:le,layoutMode:U,density:K,visibleLimit:pe,dimUnrelated:ge,showEdgeLabels:fe,showLegend:Se,fullscreen:B,onBindModel:()=>ye("models"),onRelationship:()=>Y({kind:"relationship"}),onModelingView:b,onColumnMode:oe,onSearch:de,searchItems:Jt,onPickModel:Bt,onLayoutMode:Z,onDensity:re,onVisibleLimit:Ae,onDimUnrelated:He,onEdgeLabels:ze,onLegend:we,onFullscreen:()=>ne(h=>!h),onExport:()=>ti(),onReset:()=>R(h=>h+1),t:o}),Q?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:Q.name}),e.jsx("span",{children:Q.description??"Focused business modeling area"}),e.jsxs("span",{style:{marginLeft:"auto",color:o.textMuted},children:[Q.entityIds.length," model",Q.entityIds.length===1?"":"s"," · ",Q.intentExamples.length," example question",Q.intentExamples.length===1?"":"s"]})]}):null,Se&&e.jsx(Xs,{t:o}),e.jsx("div",{style:{flex:1,minHeight:0},children:Le.length===0?e.jsx(ei,{t:o,connectedModels:Object.keys(s.dbtProvenance.nodes).length,domainReady:!!(m&&Q),onDbt:()=>ye("models"),onYaml:()=>ye("yaml"),onManual:()=>Y(m?Q?{kind:"entity"}:{kind:"area"}:{kind:"domain"})}):e.jsx(Ms,{modeling:s.modeling,relationByDbtId:$t,detailsByDbtId:k,selectedDomain:m,selectedAreaId:x,selectedId:j,viewMode:L,columnMode:M,search:le,layoutMode:U,density:K,visibleLimit:pe,dimUnrelated:ge,showEdgeLabels:fe,resetLayoutToken:I,focusRequest:A??void 0,onVisibleDbtIdsChange:Vt,onSelectEntity:w,onSelectRelationship:w,onEditRelationship:h=>{const D=s.modeling.relationships[h];D&&Y({kind:"relationship",relationship:D})},onDraftRelationship:h=>Y({kind:"relationship",draft:h}),onAddRelatedModel:h=>Y({kind:"entity",relationshipFrom:h}),onDropDbtModel:h=>Y({kind:"entity",dbtUniqueId:h}),onCreateDomain:()=>Y({kind:"domain"}),onEditEntity:h=>{const D=s.modeling.entities[h];D&&Y({kind:"entity",entity:D,dbtUniqueId:D.dbtUniqueId})},onOpenAi:h=>{w(h);try{window.sessionStorage.setItem("dql-ask-domain-context",JSON.stringify({domain:m,modelAreaId:Q==null?void 0:Q.qualifiedId,objectId:h}))}catch{}n({type:"SET_MAIN_VIEW",view:"ask"})},theme:o})})]}),d==="terms"&&e.jsx(tn,{data:s,domain:m,kinds:["terms"],title:"Domain terms",detail:"Business vocabulary owned by this domain and available to governed retrieval.",t:o}),d==="skills"&&e.jsx(is,{embedded:!0,domainFilter:m,modelAreaFilter:x,sourcePathFilter:et}),d==="knowledge"&&e.jsx("div",{style:{height:"100%",overflow:"auto",padding:"18px 20px"},children:e.jsx(ls,{t:o,domains:Object.values(s.modeling.packages).map(h=>({id:h.id,name:h.id})),initialDomainId:m})}),d==="blocks"&&e.jsx(ni,{data:s,domain:m,t:o}),d==="views"&&e.jsx(tn,{data:s,domain:m,kinds:["views"],title:"Business views",detail:"Domain-owned business views that compose governed models and blocks.",t:o}),d==="ai"&&e.jsx(oi,{domain:m,areaId:x,selectedId:j,data:s,themeMode:t.themeMode,t:o,correction:It,onCorrectionStarted:()=>Mt(null),onReviewProposal:ke,onOpenSkills:()=>Qe("skills"),onDraftRelationship:()=>Y({kind:"relationship",draft:J&&j?{from:j,to:""}:void 0})}),d==="join-proofs"&&e.jsx(ii,{relationships:Ze,entities:s.modeling.entities,t:o,onSelect:h=>w(Ft(s.modeling.relationships,h)),onEdit:h=>Y({kind:"relationship",relationship:h})}),d==="contracts"&&e.jsx(li,{data:s,domain:m,t:o,onCreate:()=>Y({kind:"contract"})}),d==="interfaces"&&e.jsx(si,{data:s,domain:m,t:o,onCreateExport:()=>Y({kind:"export"}),onCreateImport:()=>Y({kind:"import"})}),d==="evaluations"&&e.jsx(tn,{data:s,domain:m,kinds:["evaluations","tests"],title:"Evaluations",detail:"Evidence and regression checks required before governed assets guide agents.",t:o}),d==="notebooks"&&e.jsx(ao,{data:s,domain:m,kind:"notebooks",t:o}),d==="apps"&&e.jsx(ao,{data:s,domain:m,kind:"apps",t:o}),d==="dbt"&&e.jsx(ri,{data:s,domain:m,unbound:Xe,t:o,onBind:h=>Y({kind:"entity",dbtUniqueId:h})})]})]}),pt&&e.jsxs("aside",{id:"domain-studio-inspector",ref:Ct,role:"complementary","aria-label":"Domain Studio inspector",tabIndex:-1,onKeyDown:h=>{h.key==="Escape"&&ct()},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(xi,{t:o,children:"Inspector"}),J?e.jsx(ai,{entity:J,detail:$,relationships:Ze,t:o,onEdit:()=>Y({kind:"entity",entity:J,dbtUniqueId:J.dbtUniqueId}),onEditDbtSource:()=>dt(J),onSelectRelationship:h=>w(Ft(s.modeling.relationships,h)),onDelete:()=>{Oe(null),Je({kind:"entity",id:J.localId||J.id,domain:J.domain,areaId:J.areaId,label:J.businessName||J.localId||J.id})}}):be?e.jsx(ci,{relationship:be,t:o,onEdit:()=>Y({kind:"relationship",relationship:be}),onDelete:()=>{Oe(null),Je({kind:"relationship",id:be.localId||be.id,domain:be.ownerDomain??be.qualifiedId.split("::")[0],areaId:be.areaId,label:be.localId||be.id})}}):e.jsx(ui,{data:s,domainEntities:Le.map(({entity:h})=>h),domainRelationships:Ze,t:o,onSelectRelationship:h=>w(Ft(s.modeling.relationships,h))})]})]}),he==="models"?e.jsx(Ns,{data:s,domain:m,areaId:x,theme:o,onClose:()=>ye(null),onProposal:h=>{ye(null),ke(h)}}):null,he==="yaml"?e.jsx(Ls,{data:s,domain:m,areaId:x,theme:o,onClose:()=>ye(null),onProposal:h=>{ye(null),ke(h)}}):null,at?e.jsx(rs,{proposal:at,theme:o,onClose:()=>ke(null),onCommitted:()=>{ke(null),De()}}):null,je&&e.jsx(Js,{editor:je,data:s,selectedDomain:m,selectedArea:Q,t:o,onClose:()=>Y(null),onProposal:h=>{Y(null),ke(h)},onFixWithAi:(h,D)=>{Y(null),h&&w(h),Qe("ai"),Mt({text:"Fix the failed relationship validation. Keep it draft, remove stale proof, and explain the corrected cardinality, fanout, or keys using the attached receipt.",nonce:Date.now(),evidence:D})},onApplied:async h=>{Y(null),await De(),je.kind==="entity"&&je.relationshipFrom&&h.operation==="upsert_entity"&&Y({kind:"relationship",draft:{...je.relationshipFrom,to:h.value.id}})}}),Ve&&$&&e.jsx(di,{entity:Ve,detail:$,snapshotId:s.snapshotId,t:o,onClose:()=>dt(null),onApplied:async()=>{dt(null),await De()}}),ve&&e.jsx(Us,{pending:ve,busy:zt,error:Rt,t:o,onCancel:()=>{Je(null),Oe(null)},onConfirm:async()=>{Dt(!0),Oe(null);try{const h={operation:ve.kind==="entity"?"remove_entity":"remove_relationship",value:{id:ve.id,domain:ve.domain,...ve.areaId?{areaId:ve.areaId}:{}}},D=await te.previewModelingChange(h,s.snapshotId);if(!D.patches.some(X=>X.changed))throw new Error("Nothing to remove — it is no longer in the domain source.");await te.applyModelingChange(h,D.fingerprint,s.snapshotId),Je(null),w(null),await De()}catch(h){Oe(h instanceof Error?h.message:String(h))}finally{Dt(!1)}}})]})}function Us({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(G,{t:s,onClick:i,disabled:n,children:"Cancel"}),e.jsx(G,{t:s,danger:!0,onClick:r,disabled:n,children:n?"Deleting…":`Delete ${t.kind}`})]})]})})}function Ks({data:t,selectedDomain:n,onSelect:o,t:s}){const{state:i}=Ut(),r=Xo(t.modeling.packages),c=new Map(es(i.authoredDomains).map(f=>[f.value,f.label]));return e.jsx("nav",{"aria-label":"Domain packages",children:e.jsx(ts,{id:"domain-workspace-filter",ariaLabel:"Domain workspace",value:n??"",options:r.map(f=>({value:f.id,label:c.get(f.id)??f.label})),onChange:f=>o(f||null),summary:e.jsxs(e.Fragment,{children:[r.length," authored domain",r.length===1?"":"s"," available"]}),t:s})})}function Ys({data:t,domain:n,active:o,onSelect:s,t:i}){var y;const r=n?[((y=t.domainAssets)==null?void 0:y[n])??{}]:Object.values(t.domainAssets??{}),f={diagram:un(t.modeling,n).length,skills:r.reduce((l,d)=>{var g;return l+(((g=d.skills)==null?void 0:g.length)??0)},0),blocks:new Set(r.flatMap(l=>l.blocks??[])).size};return e.jsx("nav",{"aria-label":n?`${n} workspace`:"All domains workspace",style:{padding:"10px 7px 14px"},children:yo.map((l,d)=>e.jsxs("div",{style:{marginTop:d===0?0:12},children:[l.label?e.jsx("div",{style:{padding:"0 8px 6px",color:i.textMuted,fontSize:9,fontWeight:800,textTransform:"uppercase",letterSpacing:".06em"},children:l.label}):null,l.items.map(g=>e.jsxs("button",{onClick:()=>s(g.id),"aria-current":o===g.id?"page":void 0,style:bi(i,o===g.id,!1),children:[Io(g.id,14,i,o===g.id),e.jsx("span",{style:{flex:1},children:g.label}),f[g.id]!==void 0&&e.jsx("small",{style:{color:o===g.id?i.accent:i.textMuted},children:f[g.id]})]},g.id))]},l.label??`group-${d}`))})}function Io(t,n,o,s=!1){const i=t==="blocks"?pn:t==="ai"?hn:t==="diagram"||t==="dbt"?bo:t==="knowledge"||t==="interfaces"?jo:t==="skills"?mn:t==="join-proofs"?it:t==="contracts"||t==="evaluations"?vo:t==="views"?wo:t==="terms"||t==="notebooks"||t==="apps"?Wt:Fe;return e.jsx(i,{size:n,color:s?o.accent:o.textMuted})}function Vs(t){var n;return((n=yo.flatMap(o=>o.items).find(o=>o.id===t))==null?void 0:n.label)??t}function ro(){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=Go(n)?n:"diagram";return{domain:t.get("domain"),section:o,modelAreaId:t.get("modelArea"),selectedId:o==="diagram"&&n==="diagram"?t.get("domainObject"):null}}function Tt(t,n,o=!1,s=null,i=null){if(typeof window>"u")return;const r=Zo(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 Ft(t,n){const o=Object.entries(t).find(([,s])=>s===n);return o?o[0]:n.qualifiedId??n.id}function Js({editor:t,data:n,selectedDomain:o,selectedArea:s,t:i,onClose:r,onProposal:c,onFixWithAi:f,onApplied:y}){var $n,Bn,Pn,An,On,Nn,Ln,qn,Tn,En,_n,Fn,Wn,Hn,Un,Kn,Yn,Vn,Jn,Qn,Gn;const l=t.kind==="relationship"?t.relationship:void 0,d=t.kind==="entity"?t.entity:void 0,g=t.kind==="area"?t.area:void 0,m=t.kind==="relationship"?t.draft:void 0,[u,x]=a.useState((g==null?void 0:g.domain)??(d==null?void 0:d.domain)??o??Object.keys(n.modeling.packages)[0]??""),[C,j]=a.useState((g==null?void 0:g.localId)??(($n=n.modeling.areas[(d==null?void 0:d.areaId)??(l==null?void 0:l.areaId)??""])==null?void 0:$n.localId)??(s==null?void 0:s.localId)??""),[w,$]=a.useState((l==null?void 0:l.localId)??(d==null?void 0:d.localId)??(g==null?void 0:g.localId)??""),[v,k]=a.useState((l==null?void 0:l.owner)??(d==null?void 0:d.owner)??""),[O,q]=a.useState(""),[E,S]=a.useState(t.kind==="entity"?(d==null?void 0:d.dbtUniqueId)??t.dbtUniqueId??"":""),[L,b]=a.useState((d==null?void 0:d.businessName)??""),[M,oe]=a.useState((d==null?void 0:d.businessContext)??""),[le,de]=a.useState(((Bn=d==null?void 0:d.conceptRefs)==null?void 0:Bn.join(", "))??""),[I,R]=a.useState((d==null?void 0:d.analyticalRole)??"unknown"),[A,T]=a.useState((d==null?void 0:d.status)??"draft"),[U,Z]=a.useState((d==null?void 0:d.grain)??""),[K,re]=a.useState((d==null?void 0:d.keys.join(", "))??""),[pe,Ae]=a.useState((g==null?void 0:g.name)??""),[ge,He]=a.useState((g==null?void 0:g.description)??""),[fe,ze]=a.useState((g==null?void 0:g.intentExamples.join(", "))??""),[Se,we]=a.useState((g==null?void 0:g.referencedEntityIds.map(p=>{var P;return((P=n.modeling.entities[p])==null?void 0:P.localId)??p}).join(", "))??""),[B,ne]=a.useState((l==null?void 0:l.from)??(m==null?void 0:m.from)??""),[_,Yt]=a.useState((l==null?void 0:l.to)??(m==null?void 0:m.to)??""),[Ue,Ke]=a.useState((l==null?void 0:l.keys.map(p=>`${p.from}=${p.to}`).join(", "))??(m!=null&&m.fromColumn&&m.toColumn?`${m.fromColumn}=${m.toColumn}`:"")),[Ye,Ct]=a.useState((l==null?void 0:l.cardinality)??"unknown"),[je,Y]=a.useState((l==null?void 0:l.fanout)??"unknown"),[he,ye]=a.useState((l==null?void 0:l.status)??"draft"),[at,ke]=a.useState((l==null?void 0:l.verb)??""),[It,Mt]=a.useState((l==null?void 0:l.description)??""),[Ve,dt]=a.useState(((Pn=l==null?void 0:l.roles)==null?void 0:Pn.from)??""),[ve,Je]=a.useState(((An=l==null?void 0:l.roles)==null?void 0:An.to)??""),[zt,Dt]=a.useState(((On=l==null?void 0:l.optionality)==null?void 0:On.from)??"unknown"),[Rt,Oe]=a.useState(((Nn=l==null?void 0:l.optionality)==null?void 0:Nn.to)??"unknown"),[ct,Qe]=a.useState(((Ln=l==null?void 0:l.joinTypes)==null?void 0:Ln.join(", "))??"left"),[ut,De]=a.useState(((qn=l==null?void 0:l.aggregation)==null?void 0:qn.measuresFrom.join(", "))??""),[J,be]=a.useState(((Tn=l==null?void 0:l.aggregation)==null?void 0:Tn.dimensionsFrom.join(", "))??""),[Ge,Q]=a.useState(((En=l==null?void 0:l.importRefs)==null?void 0:En.join(", "))??""),[Ne,Vt]=a.useState((l==null?void 0:l.attributionBlock)??""),[$t,Jt]=a.useState((l==null?void 0:l.evidenceExpiresAt)??""),[Bt,Pt]=a.useState(""),[Le,Ze]=a.useState(""),[Xe,pt]=a.useState(""),[et,ht]=a.useState(""),[qe,h]=a.useState(""),[D,X]=a.useState(""),[Re,tt]=a.useState(""),[At,Do]=a.useState(""),[fn,Ro]=a.useState(""),[yn,$o]=a.useState(""),[bn,Bo]=a.useState(""),[jn,Po]=a.useState(""),[vn,Ao]=a.useState("internal"),[Sn,Oo]=a.useState(""),[Ot,wn]=a.useState(null),[Qt,No]=a.useState(null),[Gt,nt]=a.useState(!1),[Nt,ot]=a.useState(null),[xt,mt]=a.useState(l==null?void 0:l.validation),[Te,Zt]=a.useState(null),[Xt,Lo]=a.useState({}),[kn,qo]=a.useState(!!(l&&(l.roles||l.aggregation||(_n=l.importRefs)!=null&&_n.length||l.attributionBlock||l.evidenceExpiresAt)));a.useEffect(()=>{t.kind!=="relationship"||l||w||!B||!_||$(`${B}_to_${_}`.replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"").toLowerCase())},[t.kind,l,B,_,w]),a.useEffect(()=>{var P;if(t.kind!=="entity"||w||!E)return;const p=(P=n.dbtProvenance.nodes[E])==null?void 0:P.name;p&&$(p.replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"").toLowerCase())},[t.kind,w,E,n.dbtProvenance.nodes]),a.useEffect(()=>{if(t.kind!=="entity"||!E){Zt(null);return}let p=!1;return te.getDbtModelingNode(E).then(P=>{var F,se;p||(Zt(P),L||b(P.name.replace(/[_-]+/g," ").replace(/\b\w/g,ee=>ee.toUpperCase())),!U&&((F=P.dqlMeta)!=null&&F.grain)&&Z(P.dqlMeta.grain),!K&&((se=P.dqlMeta)!=null&&se.keys.length)&&re(P.dqlMeta.keys.join(", ")))}).catch(()=>{p||Zt(null)}),()=>{p=!0}},[E,t.kind]),a.useEffect(()=>{if(t.kind!=="relationship")return;const P=[B,_].map(se=>{var ee;return(ee=n.modeling.entities[se])==null?void 0:ee.dbtUniqueId}).filter(se=>!!se).filter(se=>!Xt[se]);if(!P.length)return;let F=!1;return te.getDbtModelingNodes(P).then(({details:se})=>{F||Lo(ee=>({...ee,...Object.fromEntries(se.map(xe=>[xe.uniqueId,xe]))}))}).catch(()=>{}),()=>{F=!0}},[t.kind,B,_]);const Cn=()=>{if(t.kind==="domain")return{operation:"upsert_domain",value:{id:w,name:w,owner:v,parent:O||void 0,exports:[]}};if(t.kind==="area")return{operation:"upsert_area",value:{id:w,domain:u,name:pe||w,description:ge||void 0,intentExamples:V(fe),references:V(Se)}};if(t.kind==="entity")return{operation:"upsert_entity",value:{id:w,domain:u,dbtModel:E,areaId:C||void 0,businessName:L||void 0,businessContext:M||void 0,conceptRefs:V(le),analyticalRole:I,status:A,owner:v||void 0,grain:U||void 0,keys:V(K)}};if(t.kind==="contract")return{operation:"upsert_contract",value:{id:w,domain:u,entities:V(Bt),blocks:V(Le),status:"draft",owner:v,requiredEvaluation:!0,purpose:Xe||void 0,metricRefs:V(et),dimensions:V(qe),allowedFilters:V(D),requiredFilters:V(Re),evaluationRefs:V(At)}};if(t.kind==="export")return{operation:"upsert_export",value:{id:w,domain:u,entity:fn||void 0,metrics:V(et),blocks:V(Le),allowedKeys:V(yn),allowedDimensions:V(qe),allowedFilters:V(D),purposes:V(bn),consumerDomains:V(jn),classification:vn||void 0,status:he,owner:v||void 0}};if(t.kind==="import")return{operation:"upsert_import",value:{id:w||void 0,domain:u,exportRef:Sn,purpose:Xe,status:he,owner:v||void 0}};const p=gi(Ue),F=!l||l.from===B&&l.to===_&&JSON.stringify(l.keys)===JSON.stringify(p)&&l.cardinality===Ye&&l.fanout===je?xt:void 0,se=he==="certified"&&(F==null?void 0:F.status)!=="passed"?"reviewed":he,ee=n.modeling.entities[B],xe=n.modeling.entities[_];return{operation:"upsert_relationship",value:{id:w,domain:u,areaId:C||void 0,from:B,to:_,keys:p,cardinality:Ye,fanout:je,status:se,owner:v||void 0,ownerDomain:u,verb:at||void 0,description:It||void 0,roles:Ve||ve?{from:Ve||void 0,to:ve||void 0}:void 0,optionality:{from:zt,to:Rt},joinTypes:V(ct),aggregation:ut||J?{measuresFrom:V(ut),dimensionsFrom:V(J),requiresPreAggregation:je!=="safe"}:void 0,attributionBlock:Ne||void 0,importRefs:V(Ge),evidenceExpiresAt:$t||void 0,crossDomain:(ee==null?void 0:ee.domain)!==(xe==null?void 0:xe.domain),validation:F,certifiedAgainst:se==="certified"&&(ee!=null&&ee.grain)&&(xe!=null&&xe.grain)?{from:{grain:ee.grain,keys:ee.keys},to:{grain:xe.grain,keys:xe.keys}}:void 0}}},To=async()=>{try{nt(!0),ot(null);const p=Cn();No(p);const P=await te.createContextProposal({origin:"manual",expectedSnapshotId:n.snapshotId,operations:[{id:`manual:${p.operation}:${w||Date.now().toString(36)}`,kind:"modeling_change",change:p,evidence:["manual Modeling workspace authoring"]}]});c(P)}catch(p){ot(p instanceof Error?p.message:String(p))}finally{nt(!1)}},Eo=async()=>{try{nt(!0),ot(null);const p=Cn();if(p.operation!=="upsert_relationship")return;const P=await te.validateModelingRelationship(p.value,n.snapshotId);mt(P),ot(P.status==="passed"?"Warehouse proof passed. Preview the source change to save it.":P.message??"Validation failed."),wn(null)}catch(p){ot(p instanceof Error?p.message:String(p))}finally{nt(!1)}},_o=async()=>{if(!(!Ot||!Qt))try{nt(!0),await te.applyModelingChange(Qt,Ot.fingerprint,n.snapshotId),await y(Qt)}catch(p){ot(p instanceof Error?p.message:String(p))}finally{nt(!1)}},In=Object.entries(n.modeling.entities).map(([p,P])=>{const F=n.dbtProvenance.nodes[P.dbtUniqueId];return{value:p,label:P.businessName||P.localId||P.id,description:`${P.domain} · ${(F==null?void 0:F.relation)??(F==null?void 0:F.name)??P.dbtUniqueId}`,keywords:[P.qualifiedId,P.businessContext??"",P.analyticalRole??""]}}),Ee=Xt[((Fn=n.modeling.entities[B])==null?void 0:Fn.dbtUniqueId)??""],_e=Xt[((Wn=n.modeling.entities[_])==null?void 0:Wn.dbtUniqueId)??""],Mn=((Ee==null?void 0:Ee.columns)??[]).map(p=>({value:p.name,label:p.name,description:[p.type,p.description].filter(Boolean).join(" · ")||"dbt column"})),zn=((_e==null?void 0:_e.columns)??[]).map(p=>({value:p.name,label:p.name,description:[p.type,p.description].filter(Boolean).join(" · ")||"dbt column"})),Lt=Mn.map(p=>p.value).filter(p=>zn.some(P=>P.value.toLowerCase()===p.toLowerCase())).slice(0,5),$e=Ue?Ue.split(",").map(p=>{const[P="",F=""]=p.split("=").map(se=>se.trim());return{from:P,to:F}}):[{from:"",to:""}],Dn=(p,P,F)=>{const se=$e.map((ee,xe)=>xe===p?{...ee,[P]:F}:ee);Ke(se.map(ee=>`${ee.from}=${ee.to}`).join(", ")),mt(void 0)},Fo=p=>{const P=$e.filter((F,se)=>se!==p);Ke(P.map(F=>`${F.from}=${F.to}`).join(", ")),mt(void 0)},Wo=()=>Ke([...$e.filter(p=>p.from||p.to),{from:"",to:""}].map(p=>`${p.from}=${p.to}`).join(", ")),Rn=t.kind==="entity"?!!(u&&w&&E):t.kind==="relationship"?!!(u&&w&&B&&_&&$e.some(p=>p.from&&p.to)&&$e.every(p=>p.from&&p.to)):!0,Ho=t.kind==="domain"?"Create Domain Package":t.kind==="area"?g?"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(zo,{title:Ho,t:i,onClose:r,children:Ot?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."}),Ot.patches.map(p=>e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("strong",{style:{fontSize:12},children:p.path}),e.jsx("pre",{style:yi(i),children:p.after})]},p.path)),Nt&&e.jsx(ue,{text:Nt,t:i}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(G,{t:i,onClick:()=>wn(null),children:"Back"}),e.jsx(G,{primary:!0,t:i,onClick:()=>void _o(),disabled:Gt,children:"Apply to Domain Package"})]})]}):e.jsxs("div",{style:{display:"grid",gap:12},children:[t.kind!=="domain"&&e.jsx(z,{label:"Domain",children:e.jsx(ae,{value:u,onChange:x,values:Object.keys(n.modeling.packages),t:i})}),t.kind!=="relationship"&&e.jsx(z,{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(N,{value:w,onChange:$,t:i,placeholder:"stable_snake_case_id"})}),t.kind==="domain"&&e.jsx(z,{label:"Parent domain (optional)",children:e.jsx(ae,{value:O,onChange:q,values:Object.keys(n.modeling.packages),t:i})}),t.kind==="area"&&e.jsxs(e.Fragment,{children:[e.jsx(ue,{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(z,{label:"Area name",children:e.jsx(N,{value:pe,onChange:Ae,t:i,placeholder:"Customer lifecycle"})}),e.jsx(z,{label:"Business question or scope",children:e.jsx(N,{value:ge,onChange:He,t:i,placeholder:"How customers progress from first order to repeat purchase."})}),e.jsx(z,{label:"Example questions (comma-separated)",children:e.jsx(N,{value:fe,onChange:ze,t:i,placeholder:"Which customers made a second purchase?"})}),e.jsx(z,{label:"Read-only boundary entities (comma-separated)",children:e.jsx(N,{value:Se,onChange:we,t:i,placeholder:"customer"})})]}),t.kind==="entity"&&e.jsxs(e.Fragment,{children:[e.jsx(ho,{current:E?2:1,labels:["Find dbt model","Add business meaning","Review source change"],t:i}),e.jsx(ue,{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(z,{label:"Model area",children:e.jsx(ae,{value:C,onChange:j,values:Object.values(n.modeling.areas).filter(p=>p.domain===u).map(p=>p.localId),labels:Object.fromEntries(Object.values(n.modeling.areas).filter(p=>p.domain===u).map(p=>[p.localId,p.name])),t:i})}),e.jsx(z,{label:"dbt model",children:e.jsx(pi,{value:E,onChange:S,selectedNode:n.dbtProvenance.nodes[E],domain:u,t:i})}),Te&&e.jsx(xo,{title:Te.name,detail:`${Te.relation??Te.uniqueId} · ${Te.columns.length} columns${(Hn=Te.dqlMeta)!=null&&Hn.grain?` · grain: ${Te.dqlMeta.grain}`:""}`,t:i}),e.jsx(z,{label:"Business name",children:e.jsx(N,{value:L,onChange:b,t:i,placeholder:"Customer order"})}),e.jsx(z,{label:"Business context",children:e.jsx(N,{value:M,onChange:oe,t:i,placeholder:"One order used to understand repeat purchasing and revenue."})}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"Business concepts",children:e.jsx(N,{value:le,onChange:de,t:i,placeholder:"customer_lifecycle, revenue"})}),e.jsx(z,{label:"Analytical role",children:e.jsx(ae,{value:I,onChange:p=>R(p),values:["event","dimension","snapshot","bridge","unknown"],t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"Grain override (optional)",children:e.jsx(N,{value:U,onChange:Z,t:i,placeholder:"Use dbt meta.dql by default"})}),e.jsx(z,{label:"Key overrides (optional)",children:e.jsx(N,{value:K,onChange:re,t:i,placeholder:"customer_id, order_id"})})]}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"Lifecycle",children:e.jsx(ae,{value:A==="review"?"reviewed":A,onChange:p=>T(p),values:["draft","evaluated","reviewed","certified","deprecated"],t:i})}),e.jsx(z,{label:"Owner",children:e.jsx(N,{value:v,onChange:k,t:i,placeholder:"team@company.com"})})]})]}),t.kind==="relationship"&&e.jsxs(e.Fragment,{children:[e.jsx(ho,{current:!B||!_?1:$e.some(p=>p.from&&p.to)?3:2,labels:["Choose models","Match join keys","Review policy"],t:i}),e.jsx(ue,{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(z,{label:"Model area",children:e.jsx(ae,{value:C,onChange:j,values:Object.values(n.modeling.areas).filter(p=>p.domain===u).map(p=>p.localId),labels:Object.fromEntries(Object.values(n.modeling.areas).filter(p=>p.domain===u).map(p=>[p.localId,p.name])),t:i})}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"From entity",children:e.jsx(_t,{ariaLabel:"From entity",value:B,onChange:p=>{ne(p),mt(void 0)},options:In,placeholder:"Search source model…",t:i})}),e.jsx(z,{label:"To entity",children:e.jsx(_t,{ariaLabel:"To entity",value:_,onChange:p=>{Yt(p),mt(void 0)},options:In.filter(p=>p.value!==B),placeholder:"Search target model…",t:i})})]}),B&&_&&e.jsx(xo,{title:`${((Un=n.modeling.entities[B])==null?void 0:Un.businessName)||((Kn=n.modeling.entities[B])==null?void 0:Kn.localId)} → ${((Yn=n.modeling.entities[_])==null?void 0:Yn.businessName)||((Vn=n.modeling.entities[_])==null?void 0:Vn.localId)}`,detail:`${(Ee==null?void 0:Ee.columns.length)??0} source columns · ${(_e==null?void 0:_e.columns.length)??0} target columns`,t:i}),e.jsx(z,{label:"Join keys",children:e.jsxs("div",{style:{display:"grid",gap:8},children:[Lt.length>0&&!$e.some(p=>p.from&&p.to)&&e.jsxs("button",{type:"button",onClick:()=>Ke(`${Lt[0]}=${Lt[0]}`),style:{...Be(i),justifySelf:"start"},children:[e.jsx(hn,{size:13})," Use exact match: ",Lt[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(_t,{ariaLabel:`Source join column ${P+1}`,value:p.from,onChange:F=>Dn(P,"from",F),options:Mn,placeholder:B?"Source column…":"Choose source first",disabled:!B||!Ee,t:i}),e.jsx("span",{"aria-hidden":"true",style:{color:i.textMuted,textAlign:"center"},children:"→"}),e.jsx(_t,{ariaLabel:`Target join column ${P+1}`,value:p.to,onChange:F=>Dn(P,"to",F),options:zn,placeholder:_?"Target column…":"Choose target first",disabled:!_||!_e,t:i}),e.jsx("button",{type:"button","aria-label":"Remove join key",title:"Remove join key",onClick:()=>Fo(P),style:We(i),children:e.jsx(kt,{size:14})})]},`${P}:${p.from}:${p.to}`)),e.jsxs("button",{type:"button",onClick:Wo,style:{...Be(i),justifySelf:"start"},children:[e.jsx(Ce,{size:13})," Add key pair"]})]})}),w&&e.jsxs("div",{style:{color:i.textMuted,fontSize:9.5},children:["Relationship id: ",e.jsx("code",{children:w})]}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"Cardinality",children:e.jsx(ae,{value:Ye,onChange:p=>Ct(p),values:["unknown","one_to_one","one_to_many","many_to_one","many_to_many"],t:i})}),e.jsx(z,{label:"Fanout policy",children:e.jsx(ae,{value:je==="unsafe"?"forbidden":je,onChange:p=>Y(p),values:["safe","dedupe_required","attribution_required","forbidden","unknown"],t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"Business verb (optional)",children:e.jsx(N,{value:at,onChange:ke,t:i,placeholder:"belongs to"})}),e.jsx(z,{label:"Description (optional)",children:e.jsx(N,{value:It,onChange:Mt,t:i,placeholder:"Why this relationship exists"})})]}),B&&_&&((Jn=n.modeling.entities[B])==null?void 0:Jn.domain)!==((Qn=n.modeling.entities[_])==null?void 0:Qn.domain)&&e.jsx(ue,{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:()=>qo(p=>!p),style:{...Be(i),justifySelf:"start",padding:"6px 0"},children:kn?"Hide advanced governance":"Advanced governance and aggregation"}),kn&&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(z,{label:"Allowed join types",children:e.jsx(N,{value:ct,onChange:Qe,t:i,placeholder:"left, inner"})}),e.jsx(z,{label:"Lifecycle",children:e.jsx(ae,{value:he==="review"?"reviewed":he??"draft",onChange:p=>ye(p),values:["draft","evaluated","reviewed","certified","deprecated"],t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"From role",children:e.jsx(N,{value:Ve,onChange:dt,t:i})}),e.jsx(z,{label:"To role",children:e.jsx(N,{value:ve,onChange:Je,t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"From optionality",children:e.jsx(ae,{value:zt,onChange:p=>Dt(p),values:["required","optional","unknown"],t:i})}),e.jsx(z,{label:"To optionality",children:e.jsx(ae,{value:Rt,onChange:p=>Oe(p),values:["required","optional","unknown"],t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"Measures allowed from",children:e.jsx(N,{value:ut,onChange:De,t:i,placeholder:"order"})}),e.jsx(z,{label:"Dimensions allowed from",children:e.jsx(N,{value:J,onChange:be,t:i,placeholder:"customer"})})]}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"Required import refs",children:e.jsx(N,{value:Ge,onChange:Q,t:i,placeholder:"commerce.customer@1"})}),e.jsx(z,{label:"Attribution block",children:e.jsx(N,{value:Ne,onChange:Vt,t:i,placeholder:"growth.revenue_by_channel"})})]}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"Evidence expires",children:e.jsx(N,{value:$t,onChange:Jt,t:i,placeholder:"2026-12-31"})}),e.jsx(z,{label:"Owner",children:e.jsx(N,{value:v,onChange:k,t:i,placeholder:"team@company.com"})})]})]}),xt&&e.jsx(Mo,{evidence:xt,t:i,onFixWithAi:xt.status==="failed"?()=>f(l?Ft(n.modeling.relationships,l):null,xt):void 0})]}),t.kind==="contract"&&e.jsxs(e.Fragment,{children:[e.jsx(z,{label:"Covered entities",children:e.jsx(N,{value:Bt,onChange:Pt,t:i,placeholder:"order, customer"})}),e.jsx(z,{label:"Certified blocks",children:e.jsx(N,{value:Le,onChange:Ze,t:i,placeholder:"orders_360"})}),e.jsx(z,{label:"Decision purpose",children:e.jsx(N,{value:Xe,onChange:pt,t:i,placeholder:"Revenue reporting"})}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"Metrics",children:e.jsx(N,{value:et,onChange:ht,t:i})}),e.jsx(z,{label:"Dimensions",children:e.jsx(N,{value:qe,onChange:h,t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"Allowed filters",children:e.jsx(N,{value:D,onChange:X,t:i})}),e.jsx(z,{label:"Required filters",children:e.jsx(N,{value:Re,onChange:tt,t:i})})]}),e.jsx(z,{label:"Evaluation refs",children:e.jsx(N,{value:At,onChange:Do,t:i,placeholder:"revenue_accuracy"})})]}),t.kind==="export"&&e.jsxs(e.Fragment,{children:[e.jsx(z,{label:"Exported entity",children:e.jsx(ae,{value:fn,onChange:Ro,values:Object.keys(n.modeling.entities).filter(p=>{var P;return((P=n.modeling.entities[p])==null?void 0:P.domain)===u}),t:i})}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"Allowed keys",children:e.jsx(N,{value:yn,onChange:$o,t:i})}),e.jsx(z,{label:"Allowed dimensions",children:e.jsx(N,{value:qe,onChange:h,t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"Metrics",children:e.jsx(N,{value:et,onChange:ht,t:i})}),e.jsx(z,{label:"Blocks",children:e.jsx(N,{value:Le,onChange:Ze,t:i})})]}),e.jsx(z,{label:"Allowed filters",children:e.jsx(N,{value:D,onChange:X,t:i})}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"Approved purposes",children:e.jsx(N,{value:bn,onChange:Bo,t:i,placeholder:"revenue reporting"})}),e.jsx(z,{label:"Consumer domains",children:e.jsx(N,{value:jn,onChange:Po,t:i,placeholder:"growth"})})]}),e.jsxs("div",{style:ie,children:[e.jsx(z,{label:"Classification",children:e.jsx(N,{value:vn,onChange:Ao,t:i})}),e.jsx(z,{label:"Lifecycle",children:e.jsx(ae,{value:he==="review"?"reviewed":he??"draft",onChange:p=>ye(p),values:["draft","evaluated","reviewed","certified","deprecated"],t:i})})]})]}),t.kind==="import"&&e.jsxs(e.Fragment,{children:[e.jsx(z,{label:"Provider export",children:e.jsx(ae,{value:Sn,onChange:Oo,values:Object.values(((Gn=n.modeling.interfaces)==null?void 0:Gn.exports)??{}).map(p=>`${p.domain}.${p.localId}@${p.version}`),t:i})}),e.jsx(z,{label:"Exact analytical purpose",children:e.jsx(N,{value:Xe,onChange:pt,t:i,placeholder:"Revenue by acquisition channel"})}),e.jsx(z,{label:"Lifecycle",children:e.jsx(ae,{value:he==="review"?"reviewed":he??"draft",onChange:p=>ye(p),values:["draft","evaluated","reviewed","certified","deprecated"],t:i})})]}),t.kind!=="entity"&&t.kind!=="relationship"&&t.kind!=="area"&&e.jsx(z,{label:"Owner",children:e.jsx(N,{value:v,onChange:k,t:i,placeholder:"team@company.com"})}),Nt&&e.jsx(ue,{text:Nt,t:i}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[t.kind==="relationship"&&e.jsxs(G,{t:i,onClick:()=>void Eo(),disabled:Gt||!Rn,children:[e.jsx(vo,{size:14})," Validate in warehouse"]}),e.jsx(G,{primary:!0,t:i,onClick:()=>void To(),disabled:Gt||!Rn,children:"Preview source change"})]})]})})}function Qs({data:t,domain:n,t:o,onOpen:s}){var f,y,l;const i=Object.values(t.modeling.entities).filter(d=>!n||d.domain===n),r=n?t.modeling.packages[n]:void 0,c=n?((f=t.domainAssets)==null?void 0:f[n])??{}:Object.values(t.domainAssets??{}).reduce((d,g)=>{for(const[m,u]of Object.entries(g))d[m]=[...d[m]??[],...u];return d},{});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(en,{label:"Owner",value:r.owner??"Not declared",t:o}),e.jsx(en,{label:"Parent",value:r.parent??"Top-level domain",t:o}),e.jsx(en,{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:((y=c.blocks)==null?void 0:y.length)??0,detail:"Reusable analytics.",icon:e.jsx(pn,{size:16})},{id:"diagram",title:"Modeling",count:i.length,detail:"Models and relationships.",icon:e.jsx(bo,{size:16})},{id:"knowledge",title:"Knowledge 360",count:Object.values(t.modeling.relationships).filter(d=>{var g,m;return((g=t.modeling.entities[d.from])==null?void 0:g.domain)===n||((m=t.modeling.entities[d.to])==null?void 0:m.domain)===n}).length,detail:"Governed routes and evidence.",icon:e.jsx(jo,{size:16})},{id:"skills",title:"Skills",count:((l=c.skills)==null?void 0:l.length)??0,detail:"Agent instructions.",icon:e.jsx(mn,{size:16})}].map(d=>e.jsxs("button",{type:"button",onClick:()=>s(d.id),style:ji(o),children:[e.jsx("span",{style:{display:"grid",placeItems:"center",width:28,height:28,borderRadius:6,color:o.accent,background:`${o.accent}12`},children:d.icon}),e.jsxs("span",{style:{flex:1,minWidth:0,display:"grid",gap:2,textAlign:"left"},children:[e.jsx("b",{style:{fontSize:11},children:d.title}),e.jsx("span",{style:{color:o.textSecondary,fontSize:10},children:d.detail})]}),e.jsx("strong",{style:{color:o.accent,fontSize:16},children:d.count})]},d.id))})]})]})]})}function en({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 Gs({search:t,onSearch:n,items:o,onPick:s,t:i}){var m;const[r,c]=a.useState(!1),f=a.useRef(null),y=t.trim().toLowerCase(),l=y?o.filter(u=>u.label.toLowerCase().includes(y)||u.sublabel.toLowerCase().includes(y)).sort((u,x)=>u.type===x.type?u.label.localeCompare(x.label):u.type==="model"?-1:1).slice(0,14):[],d=u=>u==="dimension"?"var(--status-success)":u==="bridge"?"var(--status-warning)":u==="event"||u==="snapshot"?"var(--accent)":"var(--text-tertiary)",g=r&&y?(m=f.current)==null?void 0:m.getBoundingClientRect():void 0;return e.jsxs("label",{ref:f,style:{position:"relative",width:210,flex:"0 0 210px"},children:[e.jsx(wt,{size:12,style:{position:"absolute",left:7,top:8,color:i.textMuted}}),e.jsx("input",{"aria-label":"Search diagram",value:t,onChange:u=>{n(u.target.value),c(!0)},onFocus:()=>c(!0),placeholder:"Find model or column",style:{...me(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:l.length===0?e.jsx("div",{style:{padding:"10px 10px",fontSize:11.5,color:i.textMuted,fontFamily:i.font},children:"No matching model or column."}):l.map((u,x)=>e.jsxs("button",{type:"button",onMouseDown:C=>{C.preventDefault(),s(u.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:d(u.role),flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:12,fontWeight:u.type==="model"?650:500,color:i.textPrimary,fontFamily:i.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.label}),e.jsx("span",{style:{flexShrink:0,fontSize:9,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:i.textMuted},children:u.type==="model"?"model":u.sublabel})]},`${u.type}-${u.recordKey}-${u.label}-${x}`))})]})]})}function Zs({modelingView:t,columnMode:n,search:o,layoutMode:s,density:i,visibleLimit:r,dimUnrelated:c,showEdgeLabels:f,showLegend:y,fullscreen:l,onBindModel:d,onRelationship:g,onModelingView:m,onColumnMode:u,onSearch:x,searchItems:C,onPickModel:j,onLayoutMode:w,onDensity:$,onVisibleLimit:v,onDimUnrelated:k,onEdgeLabels:O,onLegend:q,onFullscreen:E,onExport:S,onReset:L,t:b}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minHeight:50,padding:"0 10px",borderBottom:`1px solid ${b.headerBorder}`,background:b.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 ${b.headerBorder}`,borderRadius:7,background:b.appBg,flexShrink:0},children:[e.jsx("button",{type:"button",onClick:()=>m("business"),style:{border:"none",borderRadius:5,padding:"4px 11px",fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:b.font,whiteSpace:"nowrap",background:t==="business"?"var(--accent-dim)":"transparent",color:t==="business"?b.accent:b.textMuted},children:"Business modeling"}),e.jsx("button",{type:"button",onClick:()=>m("data"),style:{border:"none",borderRadius:5,padding:"4px 11px",fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:b.font,whiteSpace:"nowrap",background:t==="data"?"var(--accent-dim)":"transparent",color:t==="data"?b.accent:b.textMuted},children:"Data modeling"})]}),e.jsx(Gs,{search:o,onSearch:x,items:C,onPick:j,t:b}),e.jsxs("button",{type:"button",onClick:d,style:on(b,!0),children:[e.jsx(Ce,{size:13})," Add models"]}),e.jsxs("button",{type:"button",onClick:g,style:on(b),children:[e.jsx(it,{size:13})," Connect"]}),e.jsxs("details",{style:{position:"relative",flexShrink:0},children:[e.jsxs("summary",{style:{...on(b),listStyle:"none"},children:[e.jsx(vs,{size:13})," View"]}),e.jsxs("div",{role:"group","aria-label":"Modeling view options",style:{position:"fixed",zIndex:70,width:250,marginTop:6,right:12,padding:10,display:"grid",gap:9,border:`1px solid ${b.headerBorder}`,borderRadius:9,background:b.cellBg,boxShadow:"0 14px 34px rgba(0,0,0,.18)"},children:[t==="data"&&e.jsxs("label",{style:Et(b),children:[e.jsxs("span",{children:[e.jsx(wo,{size:13})," Columns"]}),e.jsxs("select",{"aria-label":"Visible columns",value:n,onChange:M=>u(M.target.value),style:{...me(b),width:108,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.jsxs("label",{style:Et(b),children:[e.jsx("span",{children:"Layout"}),e.jsxs("select",{"aria-label":"Diagram layout",value:s,onChange:M=>{w(M.target.value),L()},style:{...me(b),width:108,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("label",{style:Et(b),children:[e.jsx("span",{children:"Density"}),e.jsxs("select",{"aria-label":"Diagram density",value:i,onChange:M=>$(M.target.value),style:{...me(b),width:108,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:Et(b),children:[e.jsx("span",{children:"Canvas"}),e.jsxs("select",{"aria-label":"Visible model limit",value:r||50,onChange:M=>v(Number(M.target.value)),style:{...me(b),width:108,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.jsxs("button",{type:"button",onClick:()=>k(!c),style:st(b,c),children:[e.jsx(ns,{size:14})," Dim unrelated models"]}),e.jsxs("button",{type:"button",onClick:()=>O(!f),style:st(b,f),children:[e.jsx(it,{size:14})," Relationship labels"]}),e.jsxs("button",{type:"button",onClick:()=>q(!y),style:st(b,y),children:[e.jsx(Fe,{size:14})," Relationship legend"]}),e.jsxs("button",{type:"button",onClick:S,style:st(b),children:[e.jsx(os,{size:14})," Export SVG"]}),e.jsxs("button",{type:"button",onClick:E,style:st(b,l),children:[l?e.jsx(kt,{size:14}):e.jsx(So,{size:14})," ",l?"Exit fullscreen":"Fullscreen"]}),e.jsxs("button",{type:"button",onClick:L,style:st(b),children:[e.jsx(Ss,{size:14})," Reset layout"]})]})]})]})}const Et=t=>({display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,color:t.textSecondary,fontSize:10.5}),st=(t,n=!1)=>({border:"none",borderRadius:6,padding:"6px 7px",display:"flex",alignItems:"center",gap:7,background:n?"var(--accent-dim)":"transparent",color:n?t.accent:t.textSecondary,fontSize:10.5,textAlign:"left",cursor:"pointer"});function Xs({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 ei({t,connectedModels:n,domainReady:o,onDbt:s,onYaml:i,onManual:r}){const c=[{icon:e.jsx(Fe,{size:20}),title:"Use connected dbt",detail:`${n} model${n===1?"":"s"} available. Search, multi-select, assign one Domain and Area, then review bindings.`,action:s,disabled:!o},{icon:e.jsx(xn,{size:20}),title:"Import modeling YAML",detail:"Discover DQL modeling or dbt YAML from this project, a safe local path, an upload, or pasted content.",action:i,disabled:!o},{icon:e.jsx(Ce,{size:20}),title:"Start manually",detail:o?"Create one model binding or relationship with guided review.":"Create or select a Domain and Area first.",action:r,disabled:!1}];return e.jsx("div",{style:{height:"100%",display:"grid",placeItems:"center",padding:28},children:e.jsxs("div",{style:{width:"min(840px, 100%)"},children:[e.jsxs("div",{style:{textAlign:"center",marginBottom:18},children:[e.jsx("h2",{style:{margin:0,fontSize:18},children:"Start modeling domain context"}),e.jsx("p",{style:{margin:"7px 0 0",color:t.textMuted,fontSize:11.5},children:"Choose the source you already have. Every path creates the same write-free proposal before a draft can be saved."})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:10},children:c.map(f=>e.jsxs("button",{type:"button",disabled:f.disabled,onClick:f.action,style:{...rt(t),minHeight:150,textAlign:"left",cursor:f.disabled?"not-allowed":"pointer",opacity:f.disabled?.55:1},children:[e.jsx("span",{style:{width:38,height:38,borderRadius:9,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--accent-dim)",color:t.accent},children:f.icon}),e.jsx("b",{style:{display:"block",marginTop:12},children:f.title}),e.jsx("span",{style:{display:"block",marginTop:6,color:t.textSecondary,fontSize:10.5,lineHeight:1.5},children:f.detail})]},f.title))})]})})}function ti(){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 tn({data:t,domain:n,kinds:o,title:s,detail:i,t:r}){var f;const c=n?((f=t.domainAssets)==null?void 0:f[n])??{}:Object.values(t.domainAssets??{}).reduce((y,l)=>{for(const[d,g]of Object.entries(l))y[d]=[...y[d]??[],...g];return y},{});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(y=>{var l,d;return e.jsxs("section",{style:rt(r),children:[e.jsxs("div",{style:{display:"flex",gap:7,alignItems:"center"},children:[e.jsx(Wt,{size:14,color:r.accent}),e.jsx("b",{style:{textTransform:"capitalize"},children:y}),e.jsx(lt,{t:r,children:((l=c[y])==null?void 0:l.length)??0})]}),(d=c[y])!=null&&d.length?c[y].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 ",y," in this domain yet."]})]},y)})})]})}function ni({data:t,domain:n,t:o}){var g,m;const{state:s,dispatch:i}=Ut(),[r,c]=a.useState(null),[f,y]=a.useState(null),l=[...new Set(n?((m=(g=t.domainAssets)==null?void 0:g[n])==null?void 0:m.blocks)??[]:Object.values(t.domainAssets??{}).flatMap(u=>u.blocks??[]))].sort(),d=async u=>{c(u),y(null);try{if(n)try{window.localStorage.setItem("dql.block-studio.domain",n)}catch{}const x=s.files.find(j=>j.path===u)??{name:u.split("/").at(-1)??u,path:u,type:"block",folder:u.split("/").slice(0,-1).join("/")};s.files.some(j=>j.path===u)||i({type:"FILE_ADDED",file:x});const C=await te.openBlockStudio(u);i({type:"OPEN_BLOCK_STUDIO",file:x,payload:C})}catch(x){y(x instanceof Error?x.message:String(x))}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}),f?e.jsx(ue,{text:f,t:o}):null,l.length?e.jsx("div",{style:{display:"grid",gap:10},children:l.map(u=>{var j;const x=(u.split("/").at(-1)??u).replace(/\.dql$/i,""),C=(j=Object.entries(t.domainAssets??{}).find(([,w])=>{var $;return($=w.blocks)==null?void 0:$.includes(u)}))==null?void 0:j[0];return e.jsxs("button",{type:"button",onClick:()=>void d(u),"aria-label":`Open block ${x}`,style:{...rt(o),width:"100%",textAlign:"left",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(pn,{size:14,color:o.accent}),e.jsx("b",{children:x}),n?null:e.jsx(lt,{t:o,children:C??"shared"}),r===u?e.jsx(lt,{t:o,children:"Opening…"}):null]}),e.jsx("code",{style:{display:"block",marginTop:7,color:o.textMuted,fontSize:10},children:u})]},u)})}):e.jsx(Pe,{title:"No domain blocks yet",detail:"Create a block in Block Studio and assign this domain to make it appear here.",t:o})]})}function ao({data:t,domain:n,kind:o,t:s}){var w,$;const{state:i,dispatch:r}=Ut(),[c,f]=a.useState([]),[y,l]=a.useState(!0),[d,g]=a.useState(null),[m,u]=a.useState(null);a.useEffect(()=>{let v=!0;return l(!0),(n?te.getRelatedDomainProducts(n):te.getAllRelatedDomainProducts()).then(k=>{v&&f(k[o])}).catch(()=>{v&&f([])}).finally(()=>{v&&l(!1)}),()=>{v=!1}},[n,o]);const x=n?(($=(w=t.domainAssets)==null?void 0:w[n])==null?void 0:$[o])??[]:Object.values(t.domainAssets??{}).flatMap(v=>v[o]??[]),C=o==="notebooks"?"Notebooks":"Apps",j=async v=>{const k=String(v.id??v.filePath??v.title??v.name??"product");g(k),u(null);try{if(o==="apps"){const L=String(v.id??co(String(v.filePath??"")));if(!L)throw new Error("This App has no stable id to open.");r({type:"OPEN_APP",appId:L,experience:"view",section:"dashboards"});return}const O=String(v.filePath??"");if(!O)throw new Error("This Notebook has no source path to open.");const q=i.files.find(L=>L.path===O)??{name:O.split("/").at(-1)??String(v.title??k),path:O,type:"notebook",folder:O.split("/").slice(0,-1).join("/"),...typeof v.ownerDomain=="string"?{ownerDomain:v.ownerDomain}:{},usesDomains:Array.isArray(v.usesDomains)?v.usesDomains.map(String):[]};i.files.some(L=>L.path===O)||r({type:"FILE_ADDED",file:q});const{content:E}=await te.readNotebook(O),S=ss(O,E);r({type:"OPEN_FILE",file:q,cells:S.cells,title:S.title,metadata:S.metadata})}catch(O){u(O instanceof Error?O.message:String(O))}finally{g(null)}};return e.jsxs(Ie,{children:[e.jsx(Me,{title:n?`Related ${C}`:`All ${C}`,detail:n?`${C} are global shared products related to ${n}. This backlink does not create a second copy inside the Domain Package.`:`All global ${C.toLowerCase()} across Domain Packages. Select a domain above to narrow by owner/uses-domain metadata.`,t:s}),m?e.jsx(ue,{text:m,t:s}):null,y?e.jsx(Pe,{title:`Loading related ${C.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 k=String(v.id??v.filePath??v.title??"product"),O=Array.isArray(v.usesDomains)?v.usesDomains.map(String):[],q=String(v.name??v.title??k);return e.jsxs("button",{type:"button",onClick:()=>void j(v),"aria-label":`Open ${o==="notebooks"?"notebook":"app"} ${q}`,style:{...rt(s),width:"100%",textAlign:"left",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Wt,{size:14,color:s.accent}),e.jsx("b",{children:q}),v.lifecycle?e.jsx(lt,{t:s,children:String(v.lifecycle)}):null,d===k?e.jsx(lt,{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: ",O.join(", ")||"none declared"]})]},k)})}):x.length?e.jsxs("div",{style:{display:"grid",gap:10},children:[e.jsx(ue,{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}),x.map(v=>e.jsxs("button",{type:"button",onClick:()=>void j({id:o==="apps"?co(v):v,filePath:v}),"aria-label":`Open ${o==="notebooks"?"notebook":"app"} ${v}`,style:{...rt(s),width:"100%",textAlign:"left",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Wt,{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(Pe,{title:`No related ${C.toLowerCase()} yet`,detail:`Create the ${o==="notebooks"?"notebook":"app"} from the global ${C} surface, then declare this domain in its product context to make the backlink appear here.`,t:s})]})}function co(t){const n=t.replace(/\\/g,"/").split("/").filter(Boolean),o=n.indexOf("apps");return o>=0?n[o+1]??"":""}function oi({domain:t,areaId:n,selectedId:o,data:s,themeMode:i,t:r,correction:c,onCorrectionStarted:f,onReviewProposal:y,onOpenSkills:l,onDraftRelationship:d}){const g=`modeling:${t??"new"}:${n??"all"}:${o??"new"}`,{threadId:m,onThreadIdChange:u}=fs(g),x=o?s.modeling.relationships[o]:void 0,C=o?s.modeling.entities[o]:void 0,j=n?s.modeling.areas[n]:void 0,w=x?{kind:"relationship",id:x.qualifiedId,title:x.id}:C?{kind:"model",id:C.qualifiedId,title:C.businessName||C.id}:j?{kind:"model_area",id:j.qualifiedId,title:j.name}:t?{kind:"domain",id:t,title:t}:{kind:"workspace",title:"New modeling draft"},$=v=>{const k=v.payload;(k==null?void 0:k.version)===1&&k.trustState==="review_required"&&y(k)};return e.jsxs(Ie,{children:[e.jsx(Me,{title:"Modeling AI",detail:"Ask for a new binding, business-context update, relationship draft, ownership move, or correction. Each answer is an immutable, metadata-bound proposal; generation never writes source.",t:r}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(190px, 1fr))",gap:10,marginBottom:18},children:[e.jsx(nn,{icon:e.jsx(Fe,{size:16}),title:"Domains and concepts",detail:"Detect ownership boundaries, vocabulary, concepts, and candidate subdomains.",t:r}),e.jsx(nn,{icon:e.jsx(it,{size:16}),title:"Relationship proposals",detail:"Suggest keys and cardinality from dbt evidence, then require warehouse validation.",t:r,action:e.jsx("button",{style:Be(r),onClick:d,children:"Draft manually"})}),e.jsx(nn,{icon:e.jsx(mn,{size:16}),title:"Domain skills",detail:"Draft governed vocabulary, preferred metrics, blocks, and clarification rules.",t:r,action:e.jsx("button",{style:Be(r),onClick:l,children:"Manage skills"})})]}),e.jsx(ue,{text:`Active scope: ${t??"new domain"}${n?` · ${n}`:""}${o?` · focused object: ${o}`:""} · ${Object.keys(s.modeling.entities).length} bindings · ${Object.keys(s.modeling.relationships).length} relationships. Tests, lineage, and matching names are evidence suggestions, never certification or join authority.`,t:r}),e.jsx("div",{style:{height:"min(650px, calc(100vh - 330px))",minHeight:380,marginTop:14,border:`1px solid ${r.headerBorder}`,borderRadius:10,overflow:"hidden"},children:e.jsx(ys,{themeMode:i,title:"Modeling AI",scopeHint:"Modeling proposal · metadata only · explicit draft save",composerPlaceholder:"Describe a modeling proposal or correction…",initialMode:"modeling",selectedObject:w,workspaceContext:{domain:t,modelAreaId:n,snapshotId:s.snapshotId,focusedObjectId:o,providerSafety:"no_query_rows",...c?{correction:!0,validationReceipt:c.evidence}:{}},threadId:m,onThreadIdChange:u,autoRun:c?{text:c.text,mode:"modeling",nonce:c.nonce}:void 0,onRunningChange:v=>{v&&c&&f()},onReviewAuthoringProposal:v=>$(v),emptyHint:"Describe the modeling change. The AI resolves every model and column against the current dbt snapshot before it can offer Review.",examplePrompts:[{label:"Add unbound models",prompt:"Propose draft bindings for the relevant unbound dbt models in this area."},{label:"Improve business context",prompt:"Improve the focused model business context using only current metadata evidence."},{label:"Draft a relationship",prompt:"Propose a draft relationship for the focused model and explain every evidence suggestion."}]})})]})}function nn({icon:t,title:n,detail:o,t:s,action:i}){return e.jsxs("div",{style:rt(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 si({data:t,domain:n,t:o,onCreateExport:s,onCreateImport:i}){var f,y;const r=Object.values(((f=t.modeling.interfaces)==null?void 0:f.exports)??{}).filter(l=>!n||l.domain===n),c=Object.values(((y=t.modeling.interfaces)==null?void 0:y.imports)??{}).filter(l=>!n||l.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(G,{t:o,onClick:i,children:[e.jsx(Ce,{size:14})," Import"]}),e.jsxs(G,{primary:!0,t:o,onClick:s,children:[e.jsx(Ce,{size:14})," Export"]})]})}),e.jsx("h3",{style:go(o),children:"Published exports"}),r.length?e.jsxs("table",{style:St,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(W,{children:"Interface"}),e.jsx(W,{children:"Entity"}),e.jsx(W,{children:"Allowed surface"}),e.jsx(W,{children:"Consumers"}),e.jsx(W,{children:"Status"})]})}),e.jsx("tbody",{children:r.map(l=>e.jsxs("tr",{children:[e.jsx(H,{children:e.jsxs("b",{children:[l.domain,".",l.localId,"@",l.version]})}),e.jsx(H,{children:l.entity??"—"}),e.jsx(H,{children:[...l.metrics,...l.blocks,...l.allowedDimensions].join(", ")||"keys only"}),e.jsx(H,{children:l.consumerDomains.join(", ")||"none"}),e.jsx(H,{children:e.jsx(Ht,{status:l.status,t:o})})]},l.qualifiedId))})]}):e.jsx(Pe,{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:go(o),children:"Approved imports"}),c.length?e.jsxs("table",{style:St,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(W,{children:"Import"}),e.jsx(W,{children:"Consumer"}),e.jsx(W,{children:"Provider export"}),e.jsx(W,{children:"Purpose"}),e.jsx(W,{children:"Status"})]})}),e.jsx("tbody",{children:c.map(l=>e.jsxs("tr",{children:[e.jsx(H,{children:e.jsx("b",{children:l.localId})}),e.jsx(H,{children:l.domain}),e.jsx(H,{children:l.exportRef}),e.jsx(H,{children:l.purpose}),e.jsx(H,{children:e.jsx(Ht,{status:l.status,t:o})})]},l.id))})]}):e.jsx(Pe,{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 ii({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:St,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(W,{children:"Relationship"}),e.jsx(W,{children:"Path"}),e.jsx(W,{children:"Cardinality"}),e.jsx(W,{children:"Safety"}),e.jsx(W,{children:"Status"}),e.jsx(W,{children:"Proof"}),e.jsx(W,{})]})}),e.jsx("tbody",{children:t.map(r=>{var c,f,y;return e.jsxs("tr",{onClick:()=>s(r),style:{cursor:"pointer"},children:[e.jsx(H,{children:e.jsx("b",{children:r.localId})}),e.jsxs(H,{children:[r.from," ",e.jsx("span",{style:{color:o.textMuted},children:"→"})," ",r.to,((c=n[r.from])==null?void 0:c.domain)!==((f=n[r.to])==null?void 0:f.domain)&&e.jsx(lt,{t:o,children:"cross-domain"})]}),e.jsx(H,{children:r.cardinality.replace(/_/g," ")}),e.jsx(H,{children:r.fanout}),e.jsx(H,{children:e.jsx(Ht,{status:r.status,t:o})}),e.jsx(H,{children:r.automaticJoinAllowed?e.jsx("span",{style:{color:"#2e9b63"},children:"certified"}):r.staleCertification?e.jsx("span",{style:{color:"#d47822"},children:"stale"}):((y=r.validation)==null?void 0:y.status)??"not run"}),e.jsx(H,{children:e.jsx("button",{onClick:l=>{l.stopPropagation(),i(r)},style:Be(o),children:"Edit"})})]},r.qualifiedId??r.id)})})]}):e.jsx(Pe,{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 li({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(G,{primary:!0,t:o,onClick:s,children:[e.jsx(Ce,{size:14})," Contract"]})}),i.length?e.jsxs("table",{style:St,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(W,{children:"Contract"}),e.jsx(W,{children:"Domain"}),e.jsx(W,{children:"Entities"}),e.jsx(W,{children:"Blocks"}),e.jsx(W,{children:"Status"}),e.jsx(W,{children:"Evaluation"})]})}),e.jsx("tbody",{children:i.map(r=>e.jsxs("tr",{children:[e.jsx(H,{children:e.jsx("b",{children:r.id})}),e.jsx(H,{children:r.domain}),e.jsx(H,{children:r.entities.join(", ")||"—"}),e.jsx(H,{children:r.blocks.join(", ")||"—"}),e.jsx(H,{children:e.jsx(Ht,{status:r.status,t:o})}),e.jsx(H,{children:r.requiredEvaluation?"Required":"Optional"})]},r.id))})]}):e.jsx(Pe,{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 ri({data:t,domain:n,unbound:o,t:s,onBind:i}){const[r,c]=a.useState(""),[f,y]=a.useState(0),l=50,d=new Set(un(t.modeling,n).map(({entity:j})=>j.dbtUniqueId)),g=r.trim().toLowerCase(),m=Object.values(t.dbtProvenance.nodes).filter(j=>n&&!d.has(j.uniqueId)?!1:g?[j.name,j.uniqueId,j.relation,j.sourcePath].some(w=>String(w??"").toLowerCase().includes(g)):!0),u=Math.max(1,Math.ceil(m.length/l)),x=Math.min(f,u-1),C=m.slice(x*l,(x+1)*l);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(wt,{size:13,style:{position:"absolute",top:9,left:8,color:s.textMuted}}),e.jsx("input",{"aria-label":"Search dbt scope",value:r,onChange:j=>{c(j.target.value),y(0)},placeholder:"Find model, relation, or path",style:{...me(s),paddingLeft:27}})]})}),C.length?e.jsxs(e.Fragment,{children:[e.jsxs("table",{style:St,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(W,{children:"dbt model"}),e.jsx(W,{children:"Relation"}),e.jsx(W,{children:"Source"}),e.jsx(W,{children:"Metadata"}),e.jsx(W,{})]})}),e.jsx("tbody",{children:C.map(j=>{const w=o.some($=>$.uniqueId===j.uniqueId);return e.jsxs("tr",{children:[e.jsx(H,{children:e.jsx("b",{children:j.name})}),e.jsx(H,{children:j.relation??"—"}),e.jsx(H,{children:j.sourcePath??"—"}),e.jsx(H,{children:Object.entries(j.available).filter(([,$])=>$).map(([$])=>$).join(", ")}),e.jsx(H,{children:w?e.jsx("button",{onClick:()=>i(j.uniqueId),style:Be(s),children:"Bind"}):e.jsx("span",{style:{color:"#2e9b63"},children:"Bound"})})]},j.uniqueId)})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:12,color:s.textMuted,fontSize:10},children:[e.jsxs("span",{children:[m.length," models · page ",x+1," of ",u]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx(G,{t:s,disabled:x===0,onClick:()=>y(j=>Math.max(0,j-1)),children:"Previous"}),e.jsx(G,{t:s,disabled:x>=u-1,onClick:()=>y(j=>Math.min(u-1,j+1)),children:"Next"})]})]})]}):e.jsx(Pe,{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 ai({entity:t,detail:n,relationships:o=[],t:s,onEdit:i,onEditDbtSource:r,onSelectRelationship:c,onDelete:f}){var m,u,x,C;const y=fo(t.analyticalRole),l=new Set(t.keys.length?t.keys:((m=n==null?void 0:n.dqlMeta)==null?void 0:m.keys)??[]),d={fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:s.textMuted,margin:"0 0 5px"},g=o.filter(j=>j.from===t.id||j.to===t.id||j.from===t.localId||j.to===t.localId);return e.jsxs(gn,{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:y,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:y},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:d,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:d,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(j=>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:l.has(j.name)?"var(--pk)":/(^|_)id$/.test(j.name)?"var(--fk)":"transparent"},children:l.has(j.name)?"PK":/(^|_)id$/.test(j.name)?"FK":"·"}),e.jsx("span",{style:{flex:1,minWidth:0,color:s.textSecondary,fontFamily:s.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:j.name}),e.jsx("span",{style:{flexShrink:0,fontSize:10,color:s.textMuted,fontFamily:s.fontMono},children:j.type??"—"})]},j.name))})]}),g.length>0&&c?e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:d,children:"Relationships"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:g.map(j=>e.jsxs("button",{type:"button",onClick:()=>c(j),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:j.localId}),e.jsx("span",{style:{fontFamily:s.fontMono,fontSize:10,color:s.textMuted,flexShrink:0},children:j.cardinality==="one_to_one"?"1:1":j.cardinality==="one_to_many"?"1:N":j.cardinality==="many_to_one"?"N:1":"N:N"})]},j.qualifiedId??j.localId))})]}):null,e.jsxs("details",{style:{marginBottom:12},children:[e.jsx("summary",{style:{...d,cursor:"pointer"},children:"More metadata"}),e.jsx(ce,{label:"concepts",value:((u=t.conceptRefs)==null?void 0:u.join(", "))||"Not mapped",t:s}),e.jsx(ce,{label:"owner",value:t.owner??"Not declared",t:s}),e.jsx(ce,{label:"grain",value:t.grain??((x=n==null?void 0:n.dqlMeta)==null?void 0:x.grain)??"Not declared",t:s}),e.jsx(ce,{label:"keys",value:(t.keys.length?t.keys:((C=n==null?void 0:n.dqlMeta)==null?void 0:C.keys)??[]).join(", ")||"Not declared",t:s}),e.jsx(ce,{label:"source",value:(n==null?void 0:n.sourcePath)??t.sourcePath,t:s}),e.jsx(ce,{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(G,{primary:!0,t:s,onClick:i,children:"Edit entity"}),e.jsx(G,{t:s,onClick:r,children:"Preview dbt source patch"}),f?e.jsx(G,{t:s,danger:!0,onClick:f,children:"Delete entity"}):null]})]})}function di({entity:t,detail:n,snapshotId:o,t:s,onClose:i,onApplied:r}){const c=n.columns.filter(k=>k.tests.length>0).map(k=>`${k.name}: ${k.tests.join(", ")}`).join(`
|
|
22
|
-
`),[f,y]=a.useState(n.description??""),[l,d]=a.useState(c),[g,m]=a.useState(null),[u,x]=a.useState(!1),[C,j]=a.useState(null),w=()=>({uniqueId:t.dbtUniqueId,description:f,columns:l.split(/\r?\n/).flatMap(k=>{const O=k.indexOf(":");if(O<1)return[];const q=k.slice(0,O).trim(),E=V(k.slice(O+1));return q?[{name:q,tests:E}]:[]})}),$=async()=>{try{x(!0),j(null),m(await te.previewDbtSourcePatch(w(),o))}catch(k){j(k instanceof Error?k.message:String(k))}finally{x(!1)}},v=async()=>{if(g)try{x(!0),j(null),await te.applyDbtSourcePatch(w(),g.fingerprint,g.snapshotId),await r()}catch(k){j(k instanceof Error?k.message:String(k))}finally{x(!1)}};return e.jsxs(zo,{title:`Edit dbt source · ${n.name}`,t:s,onClose:i,children:[e.jsx(ue,{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(uo,{title:"Current dbt YAML",source:g.patch.before||"# New dbt schema YAML",t:s}),e.jsx(uo,{title:"Proposed dbt YAML",source:g.patch.after,t:s})]}),C&&e.jsx(ue,{text:C,t:s}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:7},children:[e.jsx(G,{t:s,onClick:()=>m(null),children:"Back"}),e.jsx(G,{primary:!0,t:s,disabled:u||!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(z,{label:"Model description",children:e.jsx("textarea",{"aria-label":"Model description",value:f,onChange:k=>y(k.target.value),rows:5,style:{...me(s),resize:"vertical"}})}),e.jsx(z,{label:"Column tests (one column per line)",children:e.jsx("textarea",{"aria-label":"Column tests",value:l,onChange:k=>d(k.target.value),rows:6,placeholder:"order_id: unique, not_null",style:{...me(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."}),C&&e.jsx(ue,{text:C,t:s}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:7},children:[e.jsx(G,{t:s,onClick:i,children:"Cancel"}),e.jsx(G,{primary:!0,t:s,disabled:u,onClick:()=>void $(),children:"Preview source patch"})]})]})]})}function uo({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 ci({relationship:t,t:n,onEdit:o,onDelete:s}){var i,r,c;return e.jsxs(gn,{t:n,children:[e.jsx(mi,{title:t.localId,subtitle:`${t.from} → ${t.to}`,t:n}),e.jsx(G,{primary:!0,t:n,onClick:o,children:"Validate / edit"}),e.jsx("h3",{style:mo(n),children:"Business meaning"}),e.jsx(ce,{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:mo(n),children:"Join route"}),e.jsx(ce,{label:"cardinality",value:t.cardinality,t:n}),e.jsx(ce,{label:"fanout",value:t.fanout,t:n}),e.jsx(ce,{label:"lifecycle",value:t.status,t:n}),e.jsx(ce,{label:"join keys",value:t.keys.map(f=>`${f.from} = ${f.to}`).join(", "),t:n}),e.jsx(ce,{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(ce,{label:"allowed joins",value:((c=t.joinTypes)==null?void 0:c.join(", "))||"left",t:n}),e.jsx(ce,{label:"automatic agent join",value:t.automaticJoinAllowed?"Allowed":"Blocked",t:n}),t.validation?e.jsx(Mo,{evidence:t.validation,t:n}):e.jsx(ue,{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(G,{primary:!0,t:n,onClick:o,children:"Edit relationship"}),s?e.jsx(G,{t:n,danger:!0,onClick:s,children:"Delete relationship"}):null]})]})}function ui({data:t,domainEntities:n,domainRelationships:o,t:s,onSelectRelationship:i}){var m;const r=((m=n[0])==null?void 0:m.domain)??"All domains",c=o.filter(u=>{var x;return((x=u.validation)==null?void 0:x.status)==="passed"}).length,f=n.filter(u=>!!u.dbtUniqueId).length,y=n.filter(u=>!u.businessContext),l={fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:s.textMuted,margin:"14px 0 5px"},d=(u,x)=>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:u}),e.jsx("div",{style:{fontSize:10.5,color:s.textMuted},children:x})]}),g=(u,x)=>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:u?"var(--status-success)":"var(--status-warning)",flexShrink:0,fontWeight:700},children:u?"✓":"△"}),x]},x);return e.jsxs(gn,{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:[d(n.length,n.length===1?"entity":"entities"),d(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:l,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(f===n.length&&n.length>0,n.length===0?"No entities bound yet — use Bind model":`${f} of ${n.length} entities bound to dbt`),y.length>0?g(!1,`${y[0].localId}${y.length>1?` and ${y.length-1} more`:""} ha${y.length>1?"ve":"s"} no business description`):n.length>0?g(!0,"Every entity has a business description"):null]}),e.jsx("div",{style:l,children:"Relationships"}),o.length?o.map(u=>e.jsxs("button",{onClick:()=>i(u),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:u.localId}),e.jsx("span",{style:{fontFamily:s.fontMono,fontSize:10,color:s.textMuted,flexShrink:0},children:u.cardinality==="one_to_one"?"1:1":u.cardinality==="one_to_many"?"1:N":u.cardinality==="many_to_one"?"N:1":"N:N"})]},u.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:l,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 Mo({evidence:t,t:n,onFixWithAi:o}){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]}),o?e.jsxs("button",{type:"button",onClick:o,style:{...Be(n),marginTop:9},children:[e.jsx(hn,{size:13})," Fix with Modeling AI"]}):null]})}function po({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 zo({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:We(n),children:e.jsx(kt,{size:17})})]}),e.jsx("div",{style:{padding:18},children:s})]})})}function ho({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,f=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||f?o.accent:o.headerBorder}`,background:f?o.accent:c?"var(--accent-dim)":o.appBg,color:f?"#fff":c?o.accent:o.textMuted},children:f?"✓":r}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s})]},s)})})}function xo({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 _t({ariaLabel:t,value:n,onChange:o,options:s,placeholder:i,disabled:r=!1,t:c}){const[f,y]=a.useState(!1),[l,d]=a.useState(""),g=s.find(u=>u.value===n),m=Hs(s,l,50);return e.jsxs("div",{style:{position:"relative",minWidth:0},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(wt,{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":f,"aria-controls":f?"modeling-search-results":void 0,disabled:r,value:f?l:(g==null?void 0:g.label)??n,placeholder:i,onFocus:()=>{y(!0),d("")},onBlur:()=>{y(!1),d("")},onChange:u=>{y(!0),d(u.target.value)},onKeyDown:u=>{u.key==="Escape"&&(y(!1),d(""))},style:{...me(c),paddingLeft:29,paddingRight:n?29:8,opacity:r?.6:1}}),n&&!r&&e.jsx("button",{type:"button","aria-label":"Clear selection",onMouseDown:u=>u.preventDefault(),onClick:()=>{o(""),d(""),y(!0)},style:{...We(c),position:"absolute",right:3,top:"50%",transform:"translateY(-50%)",width:24,height:24,border:"none"},children:e.jsx(kt,{size:13})})]}),f&&!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:[m.length?m.map(u=>e.jsxs("button",{type:"button",role:"option","aria-selected":u.value===n,onMouseDown:x=>x.preventDefault(),onClick:()=>{o(u.value),y(!1),d("")},style:{display:"grid",width:"100%",gap:2,padding:"8px 9px",border:"none",borderRadius:5,textAlign:"left",background:u.value===n?"var(--accent-dim)":"transparent",color:c.textPrimary,cursor:"pointer"},children:[e.jsx("strong",{style:{fontSize:10.5},children:u.label}),u.description&&e.jsx("span",{style:{color:c.textMuted,fontSize:9,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.description})]},u.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 pi({value:t,onChange:n,selectedNode:o,t:s}){const[i,r]=a.useState(""),[c,f]=a.useState(!1),[y,l]=a.useState(!1),[d,g]=a.useState(0),[m,u]=a.useState([]);return a.useEffect(()=>{let x=!1;const C=window.setTimeout(()=>{l(!0),te.getDbtModelInventory({q:i,limit:50}).then(j=>{x||(g(j.total),u(j.items.map(w=>{var v;const $=w;return{value:$.uniqueId??"",label:$.name??$.uniqueId??"Unnamed model",description:`${$.relation??$.sourcePath??$.uniqueId}${$.binding?` · already bound to ${$.binding.domain??"a domain"}`:" · unbound"}`,keywords:[$.sourcePath??"",((v=$.binding)==null?void 0:v.businessName)??""]}}).filter(w=>w.value)))}).catch(()=>{x||u([])}).finally(()=>{x||l(!1)})},140);return()=>{x=!0,window.clearTimeout(C)}},[i]),e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(wt,{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:()=>{f(!0),r("")},onBlur:()=>{f(!1),r("")},onChange:x=>{r(x.target.value),f(!0)},onKeyDown:x=>{x.key==="Escape"&&f(!1)},style:{...me(s),paddingLeft:29,paddingRight:t?29:8}}),t&&e.jsx("button",{type:"button","aria-label":"Clear dbt model",onMouseDown:x=>x.preventDefault(),onClick:()=>{n(""),f(!0)},style:{...We(s),position:"absolute",right:3,top:"50%",transform:"translateY(-50%)",width:24,height:24,border:"none"},children:e.jsx(kt,{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:[y&&e.jsx("div",{style:{padding:10,color:s.textMuted,fontSize:10},children:"Searching project inventory…"}),!y&&m.map(x=>e.jsxs("button",{type:"button",role:"option","aria-selected":x.value===t,onMouseDown:C=>C.preventDefault(),onClick:()=>{n(x.value),f(!1),r("")},style:{display:"grid",width:"100%",gap:2,padding:"8px 9px",border:"none",borderRadius:5,textAlign:"left",background:x.value===t?"var(--accent-dim)":"transparent",color:s.textPrimary,cursor:"pointer"},children:[e.jsx("strong",{style:{fontSize:10.5},children:x.label}),e.jsx("span",{style:{color:s.textMuted,fontSize:9,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.description})]},x.value)),!y&&!m.length&&e.jsx("div",{style:{padding:10,color:s.textMuted,fontSize:10},children:"No dbt models match this search."}),!y&&d>m.length&&e.jsxs("div",{style:{padding:"6px 9px 4px",borderTop:`1px solid ${s.headerBorder}`,color:s.textMuted,fontSize:9},children:["Showing 50 of ",d.toLocaleString(),". Keep typing to narrow the inventory."]})]})]})}function z({label:t,children:n}){return e.jsxs("label",{style:{display:"grid",gap:6,fontSize:11,fontWeight:650},children:[t,n]})}function N({value:t,onChange:n,t:o,placeholder:s}){return e.jsx("input",{value:t,placeholder:s,onChange:i=>n(i.target.value),style:me(o)})}function ae({value:t,onChange:n,values:o,labels:s,t:i}){return e.jsxs("select",{value:t,onChange:r=>n(r.target.value),style:me(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 G({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 hi({children:t,title:n,t:o,onClick:s}){return e.jsx("button",{"aria-label":n,title:n,onClick:s,style:We(o),children:t})}function lt({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 xi({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 Pe({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 gn({children:t}){return e.jsx("div",{style:{padding:"4px 14px 20px"},children:t})}function mi({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 ce({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 Ht({status:t,t:n}){const o=t==="certified"?"#2e9b63":t==="deprecated"?n.textMuted:t==="review"||t==="reviewed"?"#377cc8":"#9a6b2f";return e.jsx("span",{style:{color:o,background:`${o}15`,borderRadius:999,padding:"3px 7px",fontSize:10},children:t})}function ue({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 W({children:t}){return e.jsx("th",{style:{textAlign:"left",padding:"9px 10px",fontSize:9,textTransform:"uppercase",letterSpacing:".05em",opacity:.65},children:t})}function H({children:t}){return e.jsx("td",{style:{padding:"11px 10px",borderTop:"1px solid var(--border-subtle)",fontSize:11},children:t})}function V(t){return t.split(",").map(n=>n.trim()).filter(Boolean)}function gi(t){return V(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 fi(){try{return JSON.parse(localStorage.getItem("dql-modeling-preferences")??"{}")}catch{return{}}}const ie={display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},on=(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"}),St={width:"100%",borderCollapse:"collapse"},yi=t=>({whiteSpace:"pre-wrap",maxHeight:300,overflow:"auto",padding:12,borderRadius:7,background:t.activityBarBg,color:t.textSecondary,fontSize:10,lineHeight:1.5}),me=t=>({width:"100%",boxSizing:"border-box",border:`1px solid ${t.headerBorder}`,background:t.cellBg,color:t.textPrimary,borderRadius:6,padding:"8px 9px",fontSize:11}),We=t=>({border:`1px solid ${t.headerBorder}`,background:t.appBg,color:t.textSecondary,borderRadius:6,padding:7,display:"grid",placeItems:"center",cursor:"pointer"}),bi=(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"}),Be=t=>({border:0,background:"transparent",color:t.accent,fontSize:10,fontWeight:650,cursor:"pointer"}),mo=t=>({margin:"18px 0 7px",paddingBottom:7,borderBottom:`1px solid ${t.headerBorder}`,fontSize:11,textTransform:"uppercase",letterSpacing:".05em",color:t.textMuted}),go=t=>({margin:"22px 0 10px",paddingBottom:8,borderBottom:`1px solid ${t.headerBorder}`,fontSize:12,color:t.textPrimary}),rt=t=>({border:`1px solid ${t.headerBorder}`,background:t.cellBg,borderRadius:9,padding:14}),ji=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{Fi as DbtFirstModelingPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as A,t as h,r as g,j as n,a as x}from"./index-Cpx47jCH.js";import{U as b}from"./UnifiedAgentRunPanel-duFXXNV_.js";import{A as I,a as w,b as E}from"./AiSidePanel-NVA6lZnn.js";import{u as _}from"./usePersistedAgentThreadId-Bnl9gWhj.js";import"./react-CRB3T2We.js";import"./AgentAnswerCard-c8QUo6NH.js";import"./TrustBadge-ZuD5N5Ww.js";import"./AiBuildResult-DPJ_SI0R.js";import"./user-round-J4PQHxo9.js";import"./triangle-alert-SyuSZ4ht.js";import"./rotate-ccw-Di0kRnrM.js";import"./x-CbKEfe5m.js";import"./list-tree-DGKqCxmz.js";import"./wrench-CS1f1Zv4.js";import"./minimize-2-C8dvqCxX.js";import"./arrow-right-WIF1V9a9.js";function M(){const{state:o,dispatch:i}=A(),p=h[o.themeMode],{audience:r,context:e}=o.globalAi,l=e.selectedObject,s=_("global-rail"),[a,d]=g.useState(!1),m=(t,c)=>{i({type:"OPEN_APP",appId:t,dashboardId:c,experience:"view",section:"dashboards"}),i({type:"CLOSE_GLOBAL_AI"}),x.listApps().then(u=>i({type:"SET_APPS",apps:u})).catch(()=>{})};return n.jsx(I,{t:p,title:e.title??"AI copilot",subtitle:e.scopeHint??"Ask a follow-up about what you are viewing",expanded:a,onToggleExpanded:()=>d(t=>!t),resizable:!0,minResizeWidth:360,maxResizeWidth:1200,onClose:()=>i({type:"CLOSE_GLOBAL_AI"}),ariaLabel:"App AI",style:{position:"relative",width:a?`min(${w}px, calc(100vw - 96px))`:`min(${E}px, calc(100vw - 64px))`,maxWidth:a?"62vw":"46vw",minWidth:320,flex:"0 0 auto"},children:n.jsx(b,{themeMode:o.themeMode,title:e.title??"AI copilot",scopeHint:e.scopeHint??"Ask a follow-up about what you are viewing",audience:r,selectedObject:l,workspaceContext:e.workspaceContext,examplePrompts:Array.isArray(e.suggestedQuestions)&&e.suggestedQuestions.length>0?e.suggestedQuestions.filter(t=>typeof t=="string").slice(0,4).map(t=>({label:t,prompt:t})):void 0,autoRun:o.globalAi.autoRun?{text:o.globalAi.autoRun.text,mode:o.globalAi.autoRun.mode,nonce:o.globalAi.autoRun.nonce}:void 0,threadId:s.threadId,onThreadIdChange:s.onThreadIdChange,initialMode:"auto",onOpenApp:m})})}export{M as GlobalAiRail};
|